@adia-ai/web-modules 0.6.44 → 0.6.46
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/CHANGELOG.md +15 -0
- package/README.md +16 -5
- package/dist/everything.min.js +17 -17
- package/package.json +1 -1
package/dist/everything.min.js
CHANGED
|
@@ -38,10 +38,10 @@ var TE=Object.defineProperty;var B=(s,t)=>()=>(s&&(t=s(s=0)),t);var Ft=(s,t)=>{f
|
|
|
38
38
|
`?"":e;else{let n=e.indexOf(`
|
|
39
39
|
`);i=n<0?e:e.slice(0,n)}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=fu.create(t,i,this.lineStart+e,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(t,e,i=0){this.startContext(this.parser.getNodeType(t),e,i)}addNode(t,e,i){typeof t=="number"&&(t=new Y(this.parser.nodeSet.types[t],to,to,(i??this.prevLineEnd())-e)),this.block.addChild(t,e-this.block.from)}addElement(t){this.block.addChild(t.toTree(this.parser.nodeSet),t.from-this.block.from)}addLeafElement(t,e){this.addNode(this.buffer.writeElements(Eg(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?$w(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=Eg(this.parser.parseInline(t.content,t.start),t.marks);this.addNode(this.buffer.writeElements(e,-t.start).finish(L.Paragraph,t.content.length),t.start)}elt(t,e,i,n){return typeof t=="string"?et(this.parser.getNodeType(t),e,i,n):new vu(t,e)}get buffer(){return new yu(this.parser.nodeSet)}};io=class s extends Ye{constructor(t,e,i,n,r,o,a,l,h){super(),this.nodeSet=t,this.blockParsers=e,this.leafBlockParsers=i,this.blockNames=n,this.endLeafBlock=r,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 n=new bu(this,t,e,i);for(let r of this.wrappers)n=r(n,t,e,i);return n}configure(t){let e=kg(t);if(!e)return this;let{nodeSet:i,skipContextMarkup:n}=this,r=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($l(e.defineNodes)){n=Object.assign({},n);let d=i.types.slice(),f;for(let p of e.defineNodes){let{name:m,block:b,composite:g,style:y}=typeof p=="string"?{name:p}:p;if(d.some(k=>k.name==m))continue;g&&(n[d.length]=(k,E,A)=>g(E,A,k.value));let v=d.length,w=g?["Block","BlockContext"]:b?v>=L.ATXHeading1&&v<=L.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;d.push(dt.define({id:v,name:m,props:w&&[[z.group,w]]})),y&&(f||(f={}),Array.isArray(y)||y instanceof le?f[m]=y:Object.assign(f,y))}i=new Fe(d),f&&(i=i.extend(Lt(f)))}if($l(e.props)&&(i=i.extend(...e.props)),$l(e.remove))for(let d of e.remove){let f=this.blockNames.indexOf(d),p=this.inlineNames.indexOf(d);f>-1&&(r[f]=o[f]=void 0),p>-1&&(l[p]=void 0)}if($l(e.parseBlock))for(let d of e.parseBlock){let f=a.indexOf(d.name);if(f>-1)r[f]=d.parse,o[f]=d.leaf;else{let p=d.before?Ou(a,d.before):d.after?Ou(a,d.after)+1:a.length-1;r.splice(p,0,d.parse),o.splice(p,0,d.leaf),a.splice(p,0,d.name)}d.endLeaf&&c.push(d.endLeaf)}if($l(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?Ou(h,d.before):d.after?Ou(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,r,o,a,c,n,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 n=e;n<i.end;){let r=i.char(n);for(let o of this.inlineParsers)if(o){let a=o(i,r,n);if(a>=0){n=a;continue t}}n++}return i.resolveMarkers(0)}};Pw=[dt.none];for(let s=1,t;t=L[s];s++)Pw[s]=dt.define({id:s,name:t,props:s>=L.Escape?[]:[[z.group,s in gw?["Block","BlockContext"]:["Block","LeafBlock"]]],top:t=="Document"});to=[],yu=class{constructor(t){this.nodeSet=t,this.content=[],this.nodes=[]}write(t,e,i,n=0){return this.content.push(t,e,i,4+n*4),this}writeElements(t,e=0){for(let i of t)i.writeTo(this,e);return this}finish(t,e){return Y.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:t,length:e})}},Ki=class{constructor(t,e,i,n=to){this.type=t,this.from=e,this.to=i,this.children=n}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 yu(t).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}},vu=class{constructor(t,e){this.tree=t,this.from=e}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return to}writeTo(t,e){t.nodes.push(this.tree),t.content.push(t.nodes.length-1,this.from+e,this.to+e,-1)}toTree(){return this.tree}};Qw={resolve:"Emphasis",mark:"EmphasisMark"},Tw={resolve:"Emphasis",mark:"EmphasisMark"},Zs={},xu={},ie=class{constructor(t,e,i,n){this.type=t,this.from=e,this.to=i,this.side=n}},Lw="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",Pl=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{Pl=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}Ag={Escape(s,t,e){if(t!=92||e==s.end-1)return-1;let i=s.char(e+1);for(let n=0;n<Lw.length;n++)if(Lw.charCodeAt(n)==i)return s.append(et(L.Escape,e,e+2));return-1},Entity(s,t,e){if(t!=38)return-1;let i=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(s.slice(e+1,e+31));return i?s.append(et(L.Entity,e,e+1+i[0].length)):-1},InlineCode(s,t,e){if(t!=96||e&&s.char(e-1)==96)return-1;let i=e+1;for(;i<s.end&&s.char(i)==96;)i++;let n=i-e,r=0;for(;i<s.end;i++)if(s.char(i)==96){if(r++,r==n&&s.char(i+1)!=96)return s.append(et(L.InlineCode,e,i+1,[et(L.CodeMark,e,e+n),et(L.CodeMark,i+1-n,i+1)]))}else r=0;return-1},HTMLTag(s,t,e){if(t!=60||e==s.end-1)return-1;let i=s.slice(e+1,s.end),n=/^(?:[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(n)return s.append(et(L.Autolink,e,e+1+n[0].length,[et(L.LinkMark,e,e+1),et(L.URL,e+1,e+n[0].length),et(L.LinkMark,e+n[0].length,e+1+n[0].length)]));let r=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(i);if(r)return s.append(et(L.Comment,e,e+1+r[0].length));let o=/^\?[^]*?\?>/.exec(i);if(o)return s.append(et(L.ProcessingInstruction,e,e+1+o[0].length));let a=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);return a?s.append(et(L.HTMLTag,e,e+1+a[0].length)):-1},Emphasis(s,t,e){if(t!=95&&t!=42)return-1;let i=e+1;for(;s.char(i)==t;)i++;let n=s.slice(e-1,e),r=s.slice(i,i+1),o=Pl.test(n),a=Pl.test(r),l=/\s|^$/.test(n),h=/\s|^$/.test(r),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 ie(t==95?Qw:Tw,e,i,(d?1:0)|(f?2:0)))},HardBreak(s,t,e){if(t==92&&s.char(e+1)==10)return s.append(et(L.HardBreak,e,e+2));if(t==32){let i=e+1;for(;s.char(i)==32;)i++;if(s.char(i)==10&&i>=e+2)return s.append(et(L.HardBreak,e,i+1))}return-1},Link(s,t,e){return t==91?s.append(new ie(Zs,e,e+1,1)):-1},Image(s,t,e){return t==33&&s.char(e+1)==91?s.append(new ie(xu,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 n=s.parts[i];if(n instanceof ie&&(n.type==Zs||n.type==xu)){if(!n.side||s.skipSpace(n.to)==e&&!/[(\[]/.test(s.slice(e+1,e+2)))return s.parts[i]=null,-1;let r=s.takeContent(i),o=s.parts[i]=N2(s,r,n.type==Zs?L.Link:L.Image,n.from,e+1);if(n.type==Zs)for(let a=0;a<i;a++){let l=s.parts[a];l instanceof ie&&l.type==Zs&&(l.side=0)}return o.to}}return-1}};eo=class{constructor(t,e,i){this.parser=t,this.text=e,this.offset=i,this.parts=[]}char(t){return t>=this.end?-1:this.text.charCodeAt(t-this.offset)}get end(){return this.offset+this.text.length}slice(t,e){return this.text.slice(t-this.offset,e-this.offset)}append(t){return this.parts.push(t),t.to}addDelimiter(t,e,i,n,r){return this.append(new ie(t,e,i,(n?1:0)|(r?2:0)))}get hasOpenLink(){for(let t=this.parts.length-1;t>=0;t--){let e=this.parts[t];if(e instanceof ie&&(e.type==Zs||e.type==xu))return!0}return!1}addElement(t){return this.append(t)}resolveMarkers(t){for(let i=t;i<this.parts.length;i++){let n=this.parts[i];if(!(n instanceof ie&&n.type.resolve&&n.side&2))continue;let r=n.type==Qw||n.type==Tw,o=n.to-n.from,a,l=i-1;for(;l>=t;l--){let m=this.parts[l];if(m instanceof ie&&m.side&1&&m.type==n.type&&!(r&&(n.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=n.type.resolve,c=[],u=a.from,d=n.to;if(r){let m=Math.min(2,a.to-a.from,o);u=a.to-m,d=n.from+m,h=m==1?"Emphasis":"StrongEmphasis"}a.type.mark&&c.push(this.elt(a.type.mark,u,a.to));for(let m=l+1;m<i;m++)this.parts[m]instanceof Ki&&c.push(this.parts[m]),this.parts[m]=null;n.type.mark&&c.push(this.elt(n.type.mark,n.from,d));let f=this.elt(h,u,d,c);this.parts[l]=r&&a.from!=u?new ie(a.type,a.from,u,a.side):null,(this.parts[i]=r&&n.to!=d?new ie(n.type,d,n.to,n.side):null)?this.parts.splice(i,0,f):this.parts[i]=f}let e=[];for(let i=t;i<this.parts.length;i++){let n=this.parts[i];n instanceof Ki&&e.push(n)}return e}findOpeningDelimiter(t){for(let e=this.parts.length-1;e>=0;e--){let i=this.parts[e];if(i instanceof ie&&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 ie?e:null}skipSpace(t){return Cl(this.text,t-this.offset)+this.offset}elt(t,e,i,n){return typeof t=="string"?et(this.parser.getNodeType(t),e,i,n):new vu(t,e)}};eo.linkStart=Zs,eo.imageStart=xu;Z2=[L.CodeBlock,L.ListItem,L.OrderedList,L.BulletList],Cg=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 r=this.fragment.to;for(;r>0&&this.input.read(r-1,r)!=`
|
|
40
40
|
`;)r--;this.fragmentEnd=r?r-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let n=t+this.fragment.offset;for(;i.to<=n;)if(!i.parent())return!1;for(;;){if(i.from>=n)return this.fragment.from<=e;if(!i.childAfter(n))return!1}}matches(t){let e=this.cursor.tree;return e&&e.prop(z.contextHash)==t}takeNodes(t){let e=this.cursor,i=this.fragment.offset,n=this.fragmentEnd-(this.fragment.openEnd?1:0),r=t.absoluteLineStart,o=r,a=t.block.children.length,l=o,h=a;for(;;){if(e.to-i>n){if(e.type.isAnonymous&&e.firstChild())continue;break}let c=Dw(e.from-i,t.ranges);if(e.to-i<=t.ranges[t.rangeI].to)t.addNode(e.tree,c);else{let u=new Y(t.parser.nodeSet.types[L.Paragraph],[],[],0,t.block.hashProp);t.reusePlaceholders.set(u,e.tree),t.addNode(u,c)}if(e.type.is("Block")&&(Z2.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-r}};B2=Lt({"Blockquote/...":O.quote,HorizontalRule:O.contentSeparator,"ATXHeading1/... SetextHeading1/...":O.heading1,"ATXHeading2/... SetextHeading2/...":O.heading2,"ATXHeading3/...":O.heading3,"ATXHeading4/...":O.heading4,"ATXHeading5/...":O.heading5,"ATXHeading6/...":O.heading6,"Comment CommentBlock":O.comment,Escape:O.escape,Entity:O.character,"Emphasis/...":O.emphasis,"StrongEmphasis/...":O.strong,"Link/... Image/...":O.link,"OrderedList/... BulletList/...":O.list,"BlockQuote/...":O.quote,"InlineCode CodeText":O.monospace,"URL Autolink":O.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":O.processingInstruction,"CodeInfo LinkLabel":O.labelName,LinkTitle:O.string,Paragraph:O.content}),Pg=new io(new Fe(Pw).extend(B2),Object.keys(gu).map(s=>gu[s]),Object.keys(gu).map(s=>Cw[s]),Object.keys(gu),q2,gw,Object.keys(Ag).map(s=>Ag[s]),Object.keys(Ag),[]);_2={resolve:"Strikethrough",mark:"StrikethroughMark"},qw={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":O.strikethrough}},{name:"StrikethroughMark",style:O.processingInstruction}],parseInline:[{name:"Strikethrough",parse(s,t,e){if(t!=126||s.char(e+1)!=126||s.char(e+2)==126)return-1;let i=s.slice(e-1,e),n=s.slice(e+2,e+3),r=/\s|^$/.test(i),o=/\s|^$/.test(n),a=Pl.test(i),l=Pl.test(n);return s.addDelimiter(_2,e,e+2,!o&&(!l||r||a),!r&&(!a||o||l))},after:"Emphasis"}]};Nw=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,Su=class{constructor(){this.rows=null}nextLine(t,e,i){if(this.rows==null){this.rows=!1;let n;if((e.next==45||e.next==58||e.next==124)&&Nw.test(n=e.text.slice(e.pos))){let r=[];Ql(t,i.content,0,r,i.start)==Ql(t,n,e.pos)&&(this.rows=[t.elt("TableHeader",i.start,i.start+i.content.length,r),t.elt("TableDelimiter",t.lineStart+e.pos,t.lineStart+e.text.length)])}}else if(this.rows){let n=[];Ql(t,e.text,e.pos,n,t.lineStart),this.rows.push(t.elt("TableRow",t.lineStart+e.pos,t.lineStart+e.text.length,n))}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}},Zw={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":O.heading}},"TableRow",{name:"TableCell",style:O.content},{name:"TableDelimiter",style:O.processingInstruction}],parseBlock:[{name:"Table",leaf(s,t){return Xw(t.content,0)?new Su:null},endLeaf(s,t,e){if(e.parsers.some(n=>n instanceof Su)||!Xw(t.text,t.basePos))return!1;let i=s.peekLine();return Nw.test(i)&&Ql(s,t.text,t.basePos)==Ql(s,i,t.basePos)},before:"SetextHeading"}]},$g=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}},Bw={defineNodes:[{name:"Task",block:!0,style:O.list},{name:"TaskMarker",style:O.atom}],parseBlock:[{name:"TaskList",leaf(s,t){return/^\[[ xX]\][ \t]/.test(t.content)&&s.parentType().name=="ListItem"?new $g:null},after:"SetextHeading"}]},zw=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,_w=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,j2=/[\w-]+\.[\w-]+($|\/)/,jw=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,Vw=/\/[a-zA-Z\d@.]+/gy;Fw={parseInline:[{name:"Autolink",parse(s,t,e){let i=e-s.offset;if(i&&/\w/.test(s.text[i-1]))return-1;zw.lastIndex=i;let n=zw.exec(s.text),r=-1;if(!n)return-1;if(n[1]||n[2]){if(r=V2(s.text,i+n[0].length),r>-1&&s.hasOpenLink){let o=/([^\[\]]|\[[^\]]*\])*/.exec(s.text.slice(i,r));r=i+o[0].length}}else n[3]?r=Uw(s.text,i):(r=Uw(s.text,i+n[0].length),r>-1&&n[0]=="xmpp:"&&(Vw.lastIndex=r,n=Vw.exec(s.text),n&&(r=n.index+n[0].length)));return r<0?-1:(s.addElement(s.elt("URL",e,r+s.offset)),r+s.offset)}}]},Tg=[Zw,Bw,qw,Fw];Lg={defineNodes:[{name:"Superscript",style:O.special(O.content)},{name:"SuperscriptMark",style:O.processingInstruction}],parseInline:[{name:"Superscript",parse:Yw(94,"Superscript","SuperscriptMark")}]},Mg={defineNodes:[{name:"Subscript",style:O.special(O.content)},{name:"SubscriptMark",style:O.processingInstruction}],parseInline:[{name:"Subscript",parse:Yw(126,"Subscript","SubscriptMark")}]},Rg={defineNodes:[{name:"Emoji",style:O.character}],parseInline:[{name:"Emoji",parse(s,t,e){let i;return t!=58||!(i=/^[a-zA-Z_0-9]+:/.exec(s.slice(e+1,s.end)))?-1:s.addElement(s.elt("Emoji",e,e+1+i[0].length))}}]}});var ok={};Ft(ok,{commonmarkLanguage:()=>Zg,deleteMarkupBackward:()=>_g,insertNewlineContinueMarkup:()=>zg,insertNewlineContinueMarkupCommand:()=>Bg,markdown:()=>rk,markdownKeymap:()=>jg,markdownLanguage:()=>so,pasteURLAsLink:()=>Vg});function Ig(s){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(s.name);return t?+t[1]:void 0}function W2(s){return s.name=="OrderedList"||s.name=="BulletList"}function U2(s,t){let e=s;for(;;){let i=e.nextSibling,n;if(!i||(n=Ig(i.type))!=null&&n<=t)break;e=i}return e.to}function Dg(s){return new Qt(Gw,s,[],"markdown")}function H2(s,t){return e=>{if(e&&s){let i=null;if(e=/\S*/.exec(e)[0],typeof s=="function"?i=s(e):i=Ur.matchLanguageName(s,e,!0),i instanceof Ur)return i.support?i.support.language.parser:Yi.getSkippingParser(i.load());if(i)return i.parser}return t?t.parser:null}}function tk(s,t){let e=[],i=[];for(let n=s;n;n=n.parent){if(n.name=="FencedCode")return i;(n.name=="ListItem"||n.name=="Blockquote")&&e.push(n)}for(let n=e.length-1;n>=0;n--){let r=e[n],o,a=t.lineAt(r.from),l=r.from-a.from;if(r.name=="Blockquote"&&(o=/^ *>( ?)/.exec(a.text.slice(l))))i.push(new Tl(r,l,l+o[0].length,"",o[1],">",null));else if(r.name=="ListItem"&&r.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 Tl(r.parent,l,l+c,o[1],h,o[2],r))}else if(r.name=="ListItem"&&r.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 Tl(r.parent,l,l+c,o[1],h,u,r))}}return i}function ek(s,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(s.from,s.from+10))}function qg(s,t,e,i=0){for(let n=-1,r=s;;){if(r.name=="ListItem"){let a=ek(r,t),l=+a[2];if(n>=0){if(l!=n+1)return;e.push({from:r.from+a[1].length,to:r.from+a[0].length,insert:String(n+2+i)})}n=l}let o=r.nextSibling;if(!o)break;r=o}}function Xg(s,t){let e=/^[ \t]*/.exec(s)[0].length;if(!e||t.facet($i)!=" ")return s;let i=zt(s,4,e),n="";for(let r=i;r>0;)r>=4?(n+=" ",r-=4):(n+=" ",r--);return n+s.slice(e)}function ik(s){return s.name=="QuoteMark"||s.name=="ListMark"}function G2(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 n=t.lineAt(e.to),r=t.lineAt(i.from),o=/^[\s>]*$/.test(n.text);return n.number+(o?0:1)<r.number}function sk(s,t,e){let i="";for(let n=0,r=s.length-2;n<=r;n++)i+=s[n].blank(n<r?zt(e.text,4,s[n+1].from)-i.length:null,n<r);return Xg(i,t)}function K2(s,t){let e=s.resolveInner(t,-1),i=t;ik(e)&&(i=e.from,e=e.parent);for(let n;n=e.childBefore(i);)if(ik(n))i=n.from;else if(n.name=="OrderedList"||n.name=="BulletList")e=n.lastChild,i=e.to;else break;return e}function rk(s={}){let{codeLanguages:t,defaultCodeLanguage:e,addKeymap:i=!0,base:{parser:n}=Zg,completeHTMLTags:r=!0,pasteURLAsLink:o=!0,htmlTagLanguage:a=nk}=s;if(!(n instanceof io))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let l=s.extensions?[s.extensions]:[],h=[a.support,F2],c;o&&h.push(Vg),e instanceof vt?(h.push(e.support),c=e.language):e&&(c=e);let u=t||c?H2(t,c):void 0;l.push(Qg({codeParser:u,htmlParser:a.language.parser})),i&&h.push(he.high(ni.of(jg)));let d=Dg(n.configure(l));return r&&h.push(d.data.of({autocomplete:J2})),new vt(d,h)}function J2(s){let{state:t,pos:e}=s,i=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(e-25,e));if(!i)return null;let n=G(t).resolveInner(e,-1);for(;n&&!n.type.isTop;){if(n.name=="CodeBlock"||n.name=="FencedCode"||n.name=="ProcessingInstructionBlock"||n.name=="CommentBlock"||n.name=="Link"||n.name=="Image")return null;n=n.parent}return{from:e-i[0].length,to:e,options:tR(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}function tR(){if(Ng)return Ng;let s=uu(new Xs(rt.create({extensions:nk}),0,!0));return Ng=s?s.options:[]}var Gw,Kw,Jw,F2,Zg,Y2,so,Tl,Bg,zg,_g,jg,nk,Ng,eR,Vg,ak=B(()=>{ei();Si();ai();eg();Hw();mg();Be();Gw=Ms({commentTokens:{block:{open:"<!--",close:"-->"}}}),Kw=new z,Jw=Pg.configure({props:[ee.add(s=>!s.is("Block")||s.is("Document")||Ig(s)!=null||W2(s)?void 0:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})),Kw.add(Ig),te.add({Document:()=>null}),ri.add({Document:Gw})]});F2=Wc.of((s,t,e)=>{for(let i=G(s).resolveInner(e,-1);i&&!(i.from<t);i=i.parent){let n=i.type.prop(Kw);if(n==null)continue;let r=U2(i,n);if(r>e)return{from:e,to:r}}return null});Zg=Dg(Jw),Y2=Jw.configure([Tg,Mg,Lg,Rg,{props:[ee.add({Table:(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}]),so=Dg(Y2);Tl=class{constructor(t,e,i,n,r,o,a){this.node=t,this.from=e,this.to=i,this.spaceBefore=n,this.spaceAfter=r,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 n=this.to-this.from-i.length-this.spaceAfter.length;n>0;n--)i+=" ";return i+(e?this.spaceAfter:"")}}marker(t,e){let i=this.node.name=="OrderedList"?String(+ek(this.item,t)[2]+e):"";return this.spaceBefore+i+this.type+this.spaceAfter}};Bg=(s={})=>({state:t,dispatch:e})=>{let i=G(t),{doc:n}=t,r=null,o=t.changeByRange(a=>{if(!a.empty||!so.isActiveAt(t,a.from,-1)&&!so.isActiveAt(t,a.from,1))return r={range:a};let l=a.from,h=n.lineAt(l),c=tk(i.resolveInner(l,-1),n);for(;c.length&&c[c.length-1].from>l-h.from;)c.pop();if(!c.length)return r={range:a};let u=c[c.length-1];if(u.to-u.spaceAfter.length>l-h.from)return r={range:a};let d=l>=u.to-u.spaceAfter.length&&!/\S/.test(h.text.slice(u.to));if(u.item&&d){let g=u.node.firstChild,y=u.node.getChild("ListItem","ListItem");if(g.to>=l||y&&y.to<l||h.from>0&&!/[^\s>]/.test(n.lineAt(h.from-1).text)||s.nonTightLists===!1){let v=c.length>1?c[c.length-2]:null,w,k="";v&&v.item?(w=h.from+v.from,k=v.marker(n,1)):w=h.from+(v?v.to:0);let E=[{from:w,to:l,insert:k}];return u.node.name=="OrderedList"&&qg(u.item,n,E,-2),v&&v.node.name=="OrderedList"&&qg(v.item,n,E),{range:$.cursor(w+k.length),changes:E}}else{let v=sk(c,t,h);return{range:$.cursor(l+v.length+1),changes:{from:h.from,insert:v+t.lineBreak}}}}if(u.node.name=="Blockquote"&&d&&h.from){let g=n.lineAt(h.from-1),y=/>\s*$/.exec(g.text);if(y&&y.index==u.from){let v=t.changes([{from:g.from+y.index,to:g.to},{from:h.from+u.from,to:h.to}]);return{range:a.map(v),changes:v}}}let f=[];u.node.name=="OrderedList"&&qg(u.item,n,f);let p=u.item&&u.item.from<h.from,m="";if(!p||/^[\s\d.)\-+*>]*/.exec(h.text)[0].length>=u.to)for(let g=0,y=c.length-1;g<=y;g++)m+=g==y&&!p?c[g].marker(n,1):c[g].blank(g<y?zt(h.text,4,c[g+1].from)-m.length:null);let b=l;for(;b>h.from&&/\s/.test(h.text.charAt(b-h.from-1));)b--;return m=Xg(m,t),G2(u.node,t.doc)&&(m=sk(c,t,h)+t.lineBreak+m),f.push({from:b,to:l,insert:t.lineBreak+m}),{range:$.cursor(b+m.length+1),changes:f}});return r?!1:(e(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},zg=Bg();_g=({state:s,dispatch:t})=>{let e=G(s),i=null,n=s.changeByRange(r=>{let o=r.from,{doc:a}=s;if(r.empty&&so.isActiveAt(s,r.from)){let l=a.lineAt(o),h=tk(K2(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:$.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(zt(l.text,4,c.to)-zt(l.text,4,c.from));return d==l.from&&(f=Xg(f,s)),{range:$.cursor(d+f.length),changes:{from:d,to:l.from+c.to,insert:f}}}if(d<o)return{range:$.cursor(d),changes:{from:d,to:o}}}}}return i={range:r}});return i?!1:(t(s.update(n,{scrollIntoView:!0,userEvent:"delete"})),!0)},jg=[{key:"Enter",run:zg},{key:"Backspace",run:_g}],nk=du({matchClosingTags:!1});Ng=null;eR=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Vg=I.domEventHandlers({paste:(s,t)=>{var e;let{main:i}=t.state.selection;if(i.empty)return!1;let n=(e=s.clipboardData)===null||e===void 0?void 0:e.getData("text/plain");if(!n||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(n)||(/^www\./.test(n)&&(n="https://"+n),!so.isActiveAt(t.state,i.from,1)))return!1;let r=G(t.state),o=!1;return r.iterate({from:i.from,to:i.to,enter:a=>{(a.from>i.from||eR.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:`](${n})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}})});function Ml(s,t){for(let e=0,i=t-s.pos-1;;i--,e++){let n=s.peek(i);if(Mi(n)||n==-1)return e}}function Yg(s){return s==32||s==9}function Mi(s){return s==10||s==13}function fk(s){return Yg(s)||Mi(s)}function Bs(s){return s<0||fk(s)}function ro(s,t,e=0){return s.peek(e)==t&&s.peek(e+1)==t&&s.peek(e+2)==t&&Bs(s.peek(e+3))}function wR(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 pk(s){return s>=48&&s<=57||s>=97&&s<=102||s>=65&&s<=70}function mk(s,t){return s.next==37?(s.advance(),pk(s.next)&&s.advance(),pk(s.next)&&s.advance(),!0):wR(s.next)||t&&s.next==44?(s.advance(),!0):!1}function gk(s){if(s.advance(),s.next==60){for(s.advance();;)if(!mk(s,!0)){s.next==62&&s.advance();break}}else for(;mk(s,!1););}function Hg(s){for(s.advance();!Bs(s.next)&&wu(s.next)!="f";)s.advance()}function Gg(s,t){let e=s.next,i=!1,n=s.pos;for(s.advance();;){let r=s.next;if(r<0)break;if(s.advance(),r==e)if(r==39)if(s.next==39)s.advance();else break;else break;else if(r==92&&e==34)s.next>=0&&s.advance();else if(Mi(r)){if(t)return!1;i=!0}else if(t&&s.pos>=n+1024)return!1}return!i}function kR(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(!Gg(s,!0))return!1}else if(s.next==93||s.next==125){if(t[t.length-1]!=s.next-2)return!1;if(t.pop(),s.advance(),!t.length)return!0}else{if(s.next<0||s.pos>e||Mi(s.next))return!1;s.advance()}}function wu(s){return s<33?"u":s>125?"s":AR[s-33]}function Kg(s,t){let e=wu(s);return e!="u"&&!(t&&e=="f")}function bk(s,t,e,i){if(wu(s.next)=="s"||(s.next==63||s.next==58||s.next==45)&&Kg(s.peek(1),e))s.advance();else return!1;let n=s.pos;for(;;){let r=s.next,o=0,a=i+1;for(;fk(r);){if(Mi(r)){if(t)return!1;a=0}else a++;r=s.peek(++o)}if(!(r>=0&&(r==58?Kg(s.peek(o+1),e):r==35?s.peek(o-1)!=32:Kg(r,e)))||!e&&a<=i||a==0&&!e&&(ro(s,45,o)||ro(s,46,o)))break;if(t&&wu(r)=="f")return!1;for(let h=o;h>=0;h--)s.advance();if(t&&s.pos>n+1024)return!1}return!0}var no,lk,iR,sR,hk,nR,ck,rR,oR,uk,aR,lR,hR,cR,uR,dR,dk,fR,pR,mR,gR,bR,OR,yR,Wg,Ug,Ll,Fg,Li,vR,xR,SR,AR,ER,CR,$R,Jg,Ok=B(()=>{gs();Je();no=63,lk=64,iR=1,sR=2,hk=3,nR=4,ck=5,rR=6,oR=7,uk=65,aR=66,lR=8,hR=9,cR=10,uR=11,dR=12,dk=13,fR=19,pR=20,mR=29,gR=33,bR=34,OR=47,yR=0,Wg=1,Ug=2,Ll=3,Fg=4,Li=class{constructor(t,e,i){this.parent=t,this.depth=e,this.type=i,this.hash=(t?t.hash+t.hash<<8:0)+e+(e<<4)+i}};Li.top=new Li(null,-1,yR);vR=new bi({start:Li.top,reduce(s,t){return s.type==Ll&&(t==pR||t==bR)?s.parent:s},shift(s,t,e,i){if(t==hk)return new Li(s,Ml(i,i.pos),Wg);if(t==uk||t==ck)return new Li(s,Ml(i,i.pos),Ug);if(t==no)return s.parent;if(t==fR||t==gR)return new Li(s,0,Ll);if(t==dk&&s.type==Fg)return s.parent;if(t==OR){let n=/[1-9]/.exec(i.read(i.pos,e.pos));if(n)return new Li(s,s.depth+ +n[0],Fg)}return s},hash(s){return s.hash}});xR=new ft((s,t)=>{if(s.next==-1&&t.canShift(lk))return s.acceptToken(lk);let e=s.peek(-1);if((Mi(e)||e<0)&&t.context.type!=Ll){if(ro(s,45))if(t.canShift(no))s.acceptToken(no);else return s.acceptToken(iR,3);if(ro(s,46))if(t.canShift(no))s.acceptToken(no);else return s.acceptToken(sR,3);let i=0;for(;s.next==32;)i++,s.advance();(i<t.context.depth||i==t.context.depth&&t.context.type==Wg&&(s.next!=45||!Bs(s.peek(1))))&&s.next!=-1&&!Mi(s.next)&&s.next!=35&&s.acceptToken(no,-i)}},{contextual:!0}),SR=new ft((s,t)=>{if(t.context.type==Ll){s.next==63&&(s.advance(),Bs(s.next)&&s.acceptToken(oR));return}if(s.next==45)s.advance(),Bs(s.next)&&s.acceptToken(t.context.type==Wg&&t.context.depth==Ml(s,s.pos-1)?nR:hk);else if(s.next==63)s.advance(),Bs(s.next)&&s.acceptToken(t.context.type==Ug&&t.context.depth==Ml(s,s.pos-1)?rR:ck);else{let e=s.pos;for(;;)if(Yg(s.next)){if(s.pos==e)return;s.advance()}else if(s.next==33)gk(s);else if(s.next==38)Hg(s);else if(s.next==42){Hg(s);break}else if(s.next==39||s.next==34){if(Gg(s,!0))break;return}else if(s.next==91||s.next==123){if(!kR(s))return;break}else{bk(s,!0,!1,0);break}for(;Yg(s.next);)s.advance();if(s.next==58){if(s.pos==e&&t.canShift(mR))return;let i=s.peek(1);Bs(i)&&s.acceptTokenTo(t.context.type==Ug&&t.context.depth==Ml(s,e)?aR:uk,e)}}},{contextual:!0});AR="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";ER=new ft((s,t)=>{if(s.next==33)gk(s),s.acceptToken(dR);else if(s.next==38||s.next==42){let e=s.next==38?cR:uR;Hg(s),s.acceptToken(e)}else s.next==39||s.next==34?(Gg(s,!1),s.acceptToken(hR)):bk(s,!1,t.context.type==Ll,t.context.depth)&&s.acceptToken(lR)}),CR=new ft((s,t)=>{let e=t.context.type==Fg?t.context.depth:-1,i=s.pos;t:for(;;){let n=0,r=s.next;for(;r==32;)r=s.peek(++n);if(!n&&(ro(s,45,n)||ro(s,46,n))||!Mi(r)&&(e<0&&(e=Math.max(t.context.depth+1,n)),n<e))break;for(;;){if(s.next<0)break t;let o=Mi(s.next);if(s.advance(),o)continue t;i=s.pos}}s.acceptTokenTo(dk,i)}),$R=Lt({DirectiveName:O.keyword,DirectiveContent:O.attributeValue,"DirectiveEnd DocEnd":O.meta,QuotedLiteral:O.string,BlockLiteralHeader:O.special(O.string),BlockLiteralContent:O.content,Literal:O.content,"Key/Literal Key/QuotedLiteral":O.definition(O.propertyName),"Anchor Alias":O.labelName,Tag:O.typeName,Comment:O.lineComment,": , -":O.separator,"?":O.punctuation,"[ ]":O.squareBracket,"{ }":O.brace}),Jg=Yt.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:vR,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[$R],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:[xR,SR,ER,CR,0,1],topRules:{Stream:[0,15]},tokenPrec:0})});var xk={};Ft(xk,{yaml:()=>yk,yamlFrontmatter:()=>vk,yamlLanguage:()=>ku});function yk(){return new vt(ku)}function vk(s){let{language:t,support:e}=s.content instanceof vt?s.content:{language:s.content,support:[]};return new vt(QR.configure({wrap:ms(i=>i.name=="FrontmatterContent"?{parser:ku.parser}:i.name=="Body"?{parser:t.parser}:null)}),e)}var PR,ku,QR,Sk=B(()=>{Ok();ai();Be();Je();gs();PR=Yt.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}),ku=fe.define({name:"yaml",parser:Jg.configure({props:[te.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:Yr({closing:"}"}),FlowSequence:Yr({closing:"]"})}),ee.add({"FlowMapping FlowSequence":Pi,"Item Pair BlockLiteral":(s,t)=>({from:t.doc.lineAt(s.from).to,to:s.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});QR=fe.define({name:"yaml-frontmatter",parser:PR.configure({props:[Lt({DashLine:O.meta})]})})});function zs(s,t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=s(t,e);return n?(i(e.update(n)),!0):!1}}function tb(s,t){let e=s.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}function IR(s,{open:t,close:e},i,n){let r=s.sliceDoc(i-Rl,i),o=s.sliceDoc(n,n+Rl),a=/\s*$/.exec(r)[0].length,l=/^\s*/.exec(o)[0].length,h=r.length-a;if(r.slice(h-t.length,h)==t&&o.slice(l,l+e.length)==e)return{open:{pos:i-a,margin:a&&1},close:{pos:n+l,margin:l&&1}};let c,u;n-i<=2*Rl?c=u=s.sliceDoc(i,n):(c=s.sliceDoc(i,i+Rl),u=s.sliceDoc(n-Rl,n));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:n-f-e.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function DR(s){let t=[];for(let e of s.selection.ranges){let i=s.doc.lineAt(e.from),n=e.to<=i.to?i:s.doc.lineAt(e.to);n.from>i.from&&n.from==e.to&&(n=e.to==i.to+1?i:s.doc.lineAt(e.to-1));let r=t.length-1;r>=0&&t[r].to>i.from?t[r].to=n.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:n.to})}return t}function Au(s,t,e=t.selection.ranges){let i=e.map(r=>tb(t,r.from).block);if(!i.every(r=>r))return null;let n=e.map((r,o)=>IR(t,i[o],r.from,r.to));if(s!=2&&!n.every(r=>r))return{changes:t.changes(e.map((r,o)=>n[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(s!=1&&n.some(r=>r)){let r=[];for(let o=0,a;o<n.length;o++)if(a=n[o]){let l=i[o],{open:h,close:c}=a;r.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:r}}return null}function eb(s,t,e=t.selection.ranges){let i=[],n=-1;t:for(let{from:r,to:o}of e){let a=i.length,l=1e9,h;for(let c=r;c<=o;){let u=t.doc.lineAt(c);if(h==null&&(h=tb(t,u.from).line,!h))continue t;if(u.from>n&&(r==o||o>u.from)){n=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(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:a,token:l,indent:h,empty:c,single:u}of i)(u||!c)&&r.push({from:a.from+h,insert:l+" "});let o=t.changes(r);return{changes:o,selection:t.selection.map(o,1)}}else if(s!=1&&i.some(r=>r.comment>=0)){let r=[];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++,r.push({from:h,to:c})}return{changes:r}}return null}function Zu(s={}){return[Eu,Pk.of(s),I.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?sb:t.inputType=="historyRedo"?$u:null;return i?(t.preventDefault(),i(e)):!1}})]}function Cu(s,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let n=e.field(Eu,!1);if(!n)return!1;let r=n.pop(s,e,t);return r?(i(r),!0):!1}}function Lk(s){return function(t){let e=t.field(Eu,!1);if(!e)return 0;let i=s==0?e.done:e.undone;return i.length-(i.length&&!i[0].changes?1:0)}}function Pu(s,t,e,i){let n=t+1>e+20?t-e-1:0,r=s.slice(n,t);return r.push(i),r}function ZR(s,t){let e=[],i=!1;return s.iterChangedRanges((n,r)=>e.push(n,r)),t.iterChangedRanges((n,r,o,a)=>{for(let l=0;l<e.length;){let h=e[l++],c=e[l++];a>=h&&o<=c&&(i=!0)}}),i}function BR(s,t){return s.ranges.length==t.ranges.length&&s.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function Mk(s,t){return s.length?t.length?s.concat(t):s:t}function Rk(s,t){if(s.length){let e=s[s.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-zR));return i.length&&i[i.length-1].eq(t)?s:(i.push(t),Pu(s,s.length-1,1e9,e.setSelAfter(i)))}else return[_e.selection([t])]}function _R(s){let t=s[s.length-1],e=s.slice();return e[s.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),e}function nb(s,t){if(!s.length)return s;let e=s.length,i=De;for(;e;){let n=jR(s[e-1],t,i);if(n.changes&&!n.changes.empty||n.effects.length){let r=s.slice(0,e);return r[e-1]=n,r}else t=n.mapped,e--,i=n.selectionsAfter}return i.length?[_e.selection(i)]:De}function jR(s,t,e){let i=Mk(s.selectionsAfter.length?s.selectionsAfter.map(a=>a.map(t)):De,e);if(!s.changes)return _e.selection(i);let n=s.changes.map(t),r=t.mapDesc(s.changes,!0),o=s.mapped?s.mapped.composeDesc(r):r;return new _e(n,W.mapEffects(s.effects,t),o,s.startSelection.map(r),i)}function oo(s,t){return $.create(s.ranges.map(t),s.mainIndex)}function je(s,t){return s.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function me({state:s,dispatch:t},e){let i=oo(s.selection,e);return i.eq(s.selection,!0)?!1:(t(je(s,i)),!0)}function js(s,t){return $.cursor(t?s.to:s.from)}function Qu(s,t){return me(s,e=>e.empty?s.moveByChar(e,t):js(e,t))}function jt(s){return s.textDirectionAt(s.state.selection.main.head)==st.LTR}function ab(s,t,e){let i=t.head,n=s.doc.lineAt(i);return i==(e?n.to:n.from)?i=e?Math.min(s.doc.length,n.to+1):Math.max(0,n.from-1):i=n.from+kt(n.text,i-n.from,e),$.cursor(i,e?-1:1)}function Ik(s,t){return me(s,e=>e.empty?ab(s.state,e,t):js(e,t))}function Tu(s,t){return me(s,e=>e.empty?s.moveByGroup(e,t):js(e,t))}function lb(s,t,e){let i=s.state.charCategorizer(t),n=i(e),r=n!=pt.Space;return o=>{let a=i(o);return a!=pt.Space?r&&a==n:(r=!1,!0)}}function Nk(s,t,e){let i=s.state.charCategorizer(t.from),n=pt.Space,r=t.from,o=0,a=!1,l=!1,h=!1,c=d=>{if(a)return!1;r+=e?d.length:-d.length;let f=i(d),p;if(f==pt.Word&&d.charCodeAt(0)<128&&/[\W_]/.test(d)&&(f=-1),n==pt.Space&&(n=f),n!=f)return!1;if(n==pt.Word)if(d.toLowerCase()==d){if(!e&&l)return!1;h=!0}else if(h){if(e)return!1;a=!0}else{if(l&&e&&i(p=s.state.sliceDoc(r,r+1))==pt.Word&&p.toLowerCase()==p)return!1;l=!0}return o++,!0},u=s.moveByChar(t,e,d=>(c(d),c));if(Xk&&n==pt.Word&&u.from==t.from+o*(e?1:-1)){let d=Math.min(t.head,u.head),f=Math.max(t.head,u.head),p=s.state.sliceDoc(d,f);if(p.length>1&&/[\u4E00-\uffff]/.test(p)){let m=Array.from(Xk.segment(p));if(m.length>1)return e?$.cursor(t.head+m[1].index,-1):$.cursor(u.head+m[m.length-1].index,1)}}return u}function Zk(s,t){return me(s,e=>e.empty?Nk(s,e,t):js(e,t))}function eI(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 Lu(s,t,e){let i=G(s).resolveInner(t.head),n=e?z.closedBy:z.openedBy;for(let l=t.head;;){let h=e?i.childAfter(l):i.childBefore(l);if(!h)break;eI(s,h,n)?i=h:l=e?h.to:h.from}let r=i.type.prop(n),o,a;return r&&(o=e?Re(s,i.from,1):Re(s,i.to,-1))&&o.matched?a=e?o.end.to:o.end.from:a=e?i.to:i.from,$.cursor(a,e?-1:1)}function _k(s,t){return me(s,e=>{if(!e.empty)return js(e,t);let i=s.moveVertically(e,t);return i.head!=e.head?i:s.moveToLineBoundary(e,t)})}function jk(s){let t=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,e=0,i=0,n;if(t){for(let r of s.state.facet(I.scrollMargins)){let o=r(s);o?.top&&(e=Math.max(o?.top,e)),o?.bottom&&(i=Math.max(o?.bottom,i))}n=s.scrollDOM.clientHeight-e-i}else n=(s.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:e,marginBottom:i,selfScroll:t,height:Math.max(s.defaultLineHeight,n-5)}}function Vk(s,t){let e=jk(s),{state:i}=s,n=oo(i.selection,o=>o.empty?s.moveVertically(o,t,e.height):js(o,t));if(n.eq(i.selection))return!1;let r;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&&(r=I.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-l}))}return s.dispatch(je(i,n),{effects:r}),!0}function Ji(s,t,e){let i=s.lineBlockAt(t.head),n=s.moveToLineBoundary(t,e);if(n.head==t.head&&n.head!=(e?i.to:i.from)&&(n=s.moveToLineBoundary(t,e,!1)),!e&&n.head==i.from&&i.length){let r=/^\s*/.exec(s.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&t.head!=i.from+r&&(n=$.cursor(i.from+r))}return n}function Kk(s,t,e){let i=!1,n=oo(s.selection,r=>{let o=Re(s,r.head,-1)||Re(s,r.head,1)||r.head>0&&Re(s,r.head-1,1)||r.head<s.doc.length&&Re(s,r.head+1,-1);if(!o||!o.end)return r;i=!0;let a=o.start.from==r.head?o.end.to:o.end.from;return e?$.range(r.anchor,a):$.cursor(a)});return i?(t(je(s,n)),!0):!1}function Vt(s,t){let e=oo(s.state.selection,i=>{let n=t(i);return $.range(i.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return e.eq(s.state.selection)?!1:(s.dispatch(je(s.state,e)),!0)}function Ru(s,t){return Vt(s,e=>s.moveByChar(e,t))}function Iu(s,t){return Vt(s,e=>s.moveByGroup(e,t))}function iA(s,t){return Vt(s,e=>Nk(s,e,t))}function rA(s,t){return Vt(s,e=>s.moveVertically(e,t))}function oA(s,t){return Vt(s,e=>s.moveVertically(e,t,jk(s).height))}function gA(s,t){let{state:e}=s,i=e.selection,n=e.selection.ranges.slice();for(let r of e.selection.ranges){let o=e.doc.lineAt(r.head);if(t?o.to<s.state.doc.length:o.from>0)for(let a=r;;){let l=s.moveVertically(a,t);if(l.head<o.from||l.head>o.to){n.some(h=>h.head==l.head)||n.push(l);break}else{if(l.head==a.head)break;a=l}}}return n.length==i.ranges.length?!1:(s.dispatch(je(e,$.create(n,n.length-1))),!0)}function Vs(s,t){if(s.state.readOnly)return!1;let e="delete.selection",{state:i}=s,n=i.changeByRange(r=>{let{from:o,to:a}=r;if(o==a){let l=t(r);l<o?(e="delete.backward",l=Du(s,l,!1)):l>o&&(e="delete.forward",l=Du(s,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=Du(s,o,!1),a=Du(s,a,!0);return o==a?{range:r}:{changes:{from:o,to:a},range:$.cursor(o,o<r.head?-1:1)}});return n.changes.empty?!1:(s.dispatch(i.update(n,{scrollIntoView:!0,userEvent:e,effects:e=="delete.selection"?I.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Du(s,t,e){if(s instanceof I)for(let i of s.state.facet(I.atomicRanges).map(n=>n(s)))i.between(t,t,(n,r)=>{n<t&&r>t&&(t=e?r:n)});return t}function Xu(s){let t=[],e=-1;for(let i of s.selection.ranges){let n=s.doc.lineAt(i.from),r=s.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=s.doc.lineAt(i.to-1)),e>=n.number){let o=t[t.length-1];o.to=r.to,o.ranges.push(i)}else t.push({from:n.from,to:r.to,ranges:[i]});e=r.number+1}return t}function CA(s,t,e){if(s.readOnly)return!1;let i=[],n=[];for(let r of Xu(s)){if(e?r.to==s.doc.length:r.from==0)continue;let o=s.doc.lineAt(e?r.to+1:r.from-1),a=o.length+1;if(e){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+s.lineBreak});for(let l of r.ranges)n.push($.range(Math.min(s.doc.length,l.anchor+a),Math.min(s.doc.length,l.head+a)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:s.lineBreak+o.text});for(let l of r.ranges)n.push($.range(l.anchor-a,l.head-a))}}return i.length?(t(s.update({changes:i,scrollIntoView:!0,selection:$.create(n,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}function QA(s,t,e){if(s.readOnly)return!1;let i=[];for(let r of Xu(s))e?i.push({from:r.from,insert:s.doc.slice(r.from,r.to)+s.lineBreak}):i.push({from:r.to,insert:s.lineBreak+s.doc.slice(r.from,r.to)});let n=s.changes(i);return t(s.update({changes:n,selection:s.selection.map(n,e?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}function OI(s,t){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=G(s).resolveInner(t),i=e.childBefore(t),n=e.childAfter(t),r;return i&&n&&i.to<=t&&n.from>=t&&(r=i.type.prop(z.closedBy))&&r.indexOf(n.name)>-1&&s.doc.lineAt(i.to).from==s.doc.lineAt(n.from).from&&!/\S/.test(s.sliceDoc(i.to,n.from))?{from:i.to,to:n.from}:null}function IA(s){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>{let{from:r,to:o}=n,a=t.doc.lineAt(r),l=!s&&r==o&&OI(t,r);s&&(r=o=(o<=a.to?a:t.doc.lineAt(o)).to);let h=new Ai(t,{simulateBreak:r,simulateDoubleBreak:!!l}),c=Fr(h,r);for(c==null&&(c=zt(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:r,to:o}=l:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let u=["",Hi(t,c)];return l&&u.push(Hi(t,h.lineIndent(a.from,-1))),{changes:{from:r,to:o,insert:K.of(u)},range:$.cursor(r+1+u[1].length)}});return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Eb(s,t){let e=-1;return s.changeByRange(i=>{let n=[];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,n,i),e=a.number),o=a.to+1}let r=s.changes(n);return{changes:n,range:$.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}var wk,kk,TR,LR,Ak,MR,RR,Ek,Rl,ib,Ck,$k,Pk,Eu,qR,sb,$u,Qk,Tk,XR,NR,_e,De,zR,VR,_s,Bu,rb,ob,WR,UR,FR,YR,Dk,qk,HR,GR,KR,Xk,JR,tI,Bk,zk,hb,cb,ub,Mu,Wk,Uk,Fk,Yk,Hk,Gk,Jk,iI,db,fb,sI,nI,rI,oI,tA,eA,aI,lI,hI,cI,uI,sA,nA,pb,mb,gb,bb,aA,lA,hA,cA,uA,dA,Ob,yb,vb,xb,fA,pA,mA,bA,OA,yA,Sb,qu,dI,wb,vA,kb,xA,fI,SA,pI,wA,kA,mI,AA,EA,$A,PA,TA,LA,MA,gI,bI,Ab,RA,DA,Nu,Cb,qA,yI,vI,XA,NA,zu,_u,ZA=B(()=>{ei();Si();ai();Be();wk=s=>{let{state:t}=s,e=t.doc.lineAt(t.selection.main.from),i=tb(s.state,e.from);return i.line?kk(s):i.block?Ek(s):!1};kk=zs(eb,0),TR=zs(eb,1),LR=zs(eb,2),Ak=zs(Au,0),MR=zs(Au,1),RR=zs(Au,2),Ek=zs((s,t)=>Au(s,t,DR(t)),0);Rl=50;ib=Ht.define(),Ck=Ht.define(),$k=X.define(),Pk=X.define({combine(s){return Gt(s,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}}),Eu=mt.define({create(){return _s.empty},update(s,t){let e=t.state.facet(Pk),i=t.annotation(ib);if(i){let l=_e.fromTransaction(t,i.selection),h=i.side,c=h==0?s.undone:s.done;return l?c=Pu(c,c.length,e.minDepth,l):c=Rk(c,t.startState.selection),new _s(h==0?i.rest:c,h==0?c:i.rest)}let n=t.annotation(Ck);if((n=="full"||n=="before")&&(s=s.isolate()),t.annotation(yt.addToHistory)===!1)return t.changes.empty?s:s.addMapping(t.changes.desc);let r=_e.fromTransaction(t),o=t.annotation(yt.time),a=t.annotation(yt.userEvent);return r?s=s.addChanges(r,o,a,e,t):t.selection&&(s=s.addSelection(t.startState.selection,o,a,e.newGroupDelay)),(n=="full"||n=="after")&&(s=s.isolate()),s},toJSON(s){return{done:s.done.map(t=>t.toJSON()),undone:s.undone.map(t=>t.toJSON())}},fromJSON(s){return new _s(s.done.map(_e.fromJSON),s.undone.map(_e.fromJSON))}});qR=Eu;sb=Cu(0,!1),$u=Cu(1,!1),Qk=Cu(0,!0),Tk=Cu(1,!0);XR=Lk(0),NR=Lk(1),_e=class s{constructor(t,e,i,n,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}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(n=>n.toJSON())}}static fromJSON(t){return new s(t.changes&&Zt.fromJSON(t.changes),[],t.mapped&&ti.fromJSON(t.mapped),t.startSelection&&$.fromJSON(t.startSelection),t.selectionsAfter.map($.fromJSON))}static fromTransaction(t,e){let i=De;for(let n of t.startState.facet($k)){let r=n(t);r.length&&(i=i.concat(r))}return!i.length&&t.changes.empty?null:new s(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,De)}static selection(t){return new s(void 0,De,void 0,void 0,t)}};De=[],zR=200;VR=/^(input\.type|delete)($|\.)/,_s=class s{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new s(this.done,this.undone):this}addChanges(t,e,i,n,r){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&t.changes&&(!i||VR.test(i))&&(!a.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,ZR(a.changes,t.changes))||i=="input.type.compose")?o=Pu(o,o.length-1,n.minDepth,new _e(t.changes.compose(a.changes),Mk(W.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,De)):o=Pu(o,o.length,n.minDepth,t),new s(o,De,e,i)}addSelection(t,e,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:De;return r.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&BR(r[r.length-1],t)?this:new s(Rk(this.done,t),this.undone,e,i)}addMapping(t){return new s(nb(this.done,t),nb(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=t==0?this.done:this.undone;if(n.length==0)return null;let r=n[n.length-1],o=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):e.selection);if(i&&r.selectionsAfter.length)return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:ib.of({side:t,rest:_R(n),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let a=n.length==1?De:n.slice(0,n.length-1);return r.mapped&&(a=nb(a,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:ib.of({side:t,rest:a,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};_s.empty=new _s(De,De);Bu=[{key:"Mod-z",run:sb,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:$u,preventDefault:!0},{linux:"Ctrl-Shift-z",run:$u,preventDefault:!0},{key:"Mod-u",run:Qk,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Tk,preventDefault:!0}];rb=s=>Qu(s,!jt(s)),ob=s=>Qu(s,jt(s)),WR=s=>Qu(s,!0),UR=s=>Qu(s,!1);FR=s=>Ik(s,!0),YR=s=>Ik(s,!1);Dk=s=>Tu(s,!jt(s)),qk=s=>Tu(s,jt(s)),HR=s=>Tu(s,!0),GR=s=>Tu(s,!1);KR=s=>me(s,t=>t.empty?s.moveByChar(t,!0,e=>lb(s,t.head,e)):js(t,!0)),Xk=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;JR=s=>Zk(s,!0),tI=s=>Zk(s,!1);Bk=s=>me(s,t=>Lu(s.state,t,!jt(s))),zk=s=>me(s,t=>Lu(s.state,t,jt(s)));hb=s=>_k(s,!1),cb=s=>_k(s,!0);ub=s=>Vk(s,!1),Mu=s=>Vk(s,!0);Wk=s=>me(s,t=>Ji(s,t,!0)),Uk=s=>me(s,t=>Ji(s,t,!1)),Fk=s=>me(s,t=>Ji(s,t,!jt(s))),Yk=s=>me(s,t=>Ji(s,t,jt(s))),Hk=s=>me(s,t=>$.cursor(s.lineBlockAt(t.head).from,1)),Gk=s=>me(s,t=>$.cursor(s.lineBlockAt(t.head).to,-1));Jk=({state:s,dispatch:t})=>Kk(s,t,!1),iI=({state:s,dispatch:t})=>Kk(s,t,!0);db=s=>Ru(s,!jt(s)),fb=s=>Ru(s,jt(s)),sI=s=>Ru(s,!0),nI=s=>Ru(s,!1),rI=s=>Vt(s,t=>ab(s.state,t,!0)),oI=s=>Vt(s,t=>ab(s.state,t,!1));tA=s=>Iu(s,!jt(s)),eA=s=>Iu(s,jt(s)),aI=s=>Iu(s,!0),lI=s=>Iu(s,!1),hI=s=>Vt(s,t=>s.moveByChar(t,!0,e=>lb(s,t.head,e)));cI=s=>iA(s,!0),uI=s=>iA(s,!1),sA=s=>Vt(s,t=>Lu(s.state,t,!jt(s))),nA=s=>Vt(s,t=>Lu(s.state,t,jt(s)));pb=s=>rA(s,!1),mb=s=>rA(s,!0);gb=s=>oA(s,!1),bb=s=>oA(s,!0),aA=s=>Vt(s,t=>Ji(s,t,!0)),lA=s=>Vt(s,t=>Ji(s,t,!1)),hA=s=>Vt(s,t=>Ji(s,t,!jt(s))),cA=s=>Vt(s,t=>Ji(s,t,jt(s))),uA=s=>Vt(s,t=>$.cursor(s.lineBlockAt(t.head).from)),dA=s=>Vt(s,t=>$.cursor(s.lineBlockAt(t.head).to)),Ob=({state:s,dispatch:t})=>(t(je(s,{anchor:0})),!0),yb=({state:s,dispatch:t})=>(t(je(s,{anchor:s.doc.length})),!0),vb=({state:s,dispatch:t})=>(t(je(s,{anchor:s.selection.main.anchor,head:0})),!0),xb=({state:s,dispatch:t})=>(t(je(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),fA=({state:s,dispatch:t})=>(t(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),pA=({state:s,dispatch:t})=>{let e=Xu(s).map(({from:i,to:n})=>$.range(i,Math.min(n+1,s.doc.length)));return t(s.update({selection:$.create(e),userEvent:"select"})),!0},mA=({state:s,dispatch:t})=>{let e=oo(s.selection,i=>{let n=G(s),r=n.resolveStack(i.from,1);if(i.empty){let o=n.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;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 $.range(a.to,a.from)}return i});return e.eq(s.selection)?!1:(t(je(s,e)),!0)};bA=s=>gA(s,!1),OA=s=>gA(s,!0),yA=({state:s,dispatch:t})=>{let e=s.selection,i=null;return e.ranges.length>1?i=$.create([e.main]):e.main.empty||(i=$.create([$.cursor(e.main.head)])),i?(t(je(s,i)),!0):!1};Sb=(s,t,e)=>Vs(s,i=>{let n=i.from,{state:r}=s,o=r.doc.lineAt(n),a,l;if(e&&!t&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,n-o.from))){if(a[a.length-1]==" ")return n-1;let h=zt(a,r.tabSize),c=h%Ei(r)||Ei(r);for(let u=0;u<c&&a[a.length-1-u]==" ";u++)n--;l=n}else l=kt(o.text,n-o.from,t,t)+o.from,l==n&&o.number!=(t?r.doc.lines:1)?l+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,n-o.from))&&(l=kt(o.text,l-o.from,!1,!1)+o.from);return l}),qu=s=>Sb(s,!1,!0),dI=s=>Sb(s,!1,!1),wb=s=>Sb(s,!0,!1),vA=(s,t)=>Vs(s,e=>{let i=e.head,{state:n}=s,r=n.doc.lineAt(i),o=n.charCategorizer(i);for(let a=null;;){if(i==(t?r.to:r.from)){i==e.head&&r.number!=(t?n.doc.lines:1)&&(i+=t?1:-1);break}let l=kt(r.text,i-r.from,t)+r.from,h=r.text.slice(Math.min(i,l)-r.from,Math.max(i,l)-r.from),c=o(h);if(a!=null&&c!=a)break;(h!=" "||i!=e.head)&&(a=c),i=l}return i}),kb=s=>vA(s,!1),xA=s=>vA(s,!0),fI=s=>Vs(s,t=>s.moveByChar(t,!0,e=>lb(s,t.head,e)).head),SA=s=>Vs(s,t=>{let e=s.lineBlockAt(t.head).to;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),pI=s=>Vs(s,t=>{let e=s.lineBlockAt(t.head).from;return t.head>e?e:Math.max(0,t.head-1)}),wA=s=>Vs(s,t=>{let e=s.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),kA=s=>Vs(s,t=>{let e=s.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),mI=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=[];for(let i=0,n="",r=s.doc.iter();;){if(r.next(),r.lineBreak||r.done){let o=n.search(/\s+$/);if(o>-1&&e.push({from:i-(n.length-o),to:i}),r.done)break;n=""}else n=r.value;i+=r.value.length}return e.length?(t(s.update({changes:e,userEvent:"delete"})),!0):!1},AA=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:K.of(["",""])},range:$.cursor(i.from)}));return t(s.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},EA=({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 n=i.from,r=s.doc.lineAt(n),o=n==r.from?n-1:kt(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:kt(r.text,n-r.from,!0)+r.from;return{changes:{from:o,to:a,insert:s.doc.slice(n,a).append(s.doc.slice(o,n))},range:$.cursor(a)}});return e.changes.empty?!1:(t(s.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};$A=({state:s,dispatch:t})=>CA(s,t,!1),PA=({state:s,dispatch:t})=>CA(s,t,!0);TA=({state:s,dispatch:t})=>QA(s,t,!1),LA=({state:s,dispatch:t})=>QA(s,t,!0),MA=s=>{if(s.state.readOnly)return!1;let{state:t}=s,e=t.changes(Xu(t).map(({from:n,to:r})=>(n>0?n--:r<t.doc.length&&r++,{from:n,to:r}))),i=oo(t.selection,n=>{let r;if(s.lineWrapping){let o=s.lineBlockAt(n.head),a=s.coordsAtPos(n.head,n.assoc||1);a&&(r=o.bottom+s.documentTop-a.bottom+s.defaultLineHeight/2)}return s.moveVertically(n,!0,r)}).map(e);return s.dispatch({changes:e,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0},gI=({state:s,dispatch:t})=>(t(s.update(s.replaceSelection(s.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),bI=({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:$.cursor(e.from+i.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0);Ab=IA(!1),RA=IA(!0);DA=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=Object.create(null),i=new Ai(s,{overrideIndentation:r=>{let o=e[r];return o??-1}}),n=Eb(s,(r,o,a)=>{let l=Fr(i,r.from);if(l==null)return;/\S/.test(r.text)||(l=0);let h=/^\s*/.exec(r.text)[0],c=Hi(s,l);(h!=c||a.from<r.from+h.length)&&(e[r.from]=l,o.push({from:r.from,to:r.from+h.length,insert:c}))});return n.changes.empty||t(s.update(n,{userEvent:"indent"})),!0},Nu=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Eb(s,(e,i)=>{i.push({from:e.from,insert:s.facet($i)})}),{userEvent:"input.indent"})),!0),Cb=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Eb(s,(e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let r=zt(n,s.tabSize),o=0,a=Hi(s,Math.max(0,r-Ei(s)));for(;o<n.length&&o<a.length&&n.charCodeAt(o)==a.charCodeAt(o);)o++;i.push({from:e.from+o,to:e.from+n.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),qA=s=>(s.setTabFocusMode(),!0),yI=s=>(s.setTabFocusMode(2e3),!0),vI=({state:s,dispatch:t})=>s.selection.ranges.some(e=>!e.empty)?Nu({state:s,dispatch:t}):(t(s.update(s.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),XA=[{key:"Ctrl-b",run:rb,shift:db,preventDefault:!0},{key:"Ctrl-f",run:ob,shift:fb},{key:"Ctrl-p",run:hb,shift:pb},{key:"Ctrl-n",run:cb,shift:mb},{key:"Ctrl-a",run:Hk,shift:uA},{key:"Ctrl-e",run:Gk,shift:dA},{key:"Ctrl-d",run:wb},{key:"Ctrl-h",run:qu},{key:"Ctrl-k",run:SA},{key:"Ctrl-Alt-h",run:kb},{key:"Ctrl-o",run:AA},{key:"Ctrl-t",run:EA},{key:"Ctrl-v",run:Mu}],NA=[{key:"ArrowLeft",run:rb,shift:db,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Dk,shift:tA,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Fk,shift:hA,preventDefault:!0},{key:"ArrowRight",run:ob,shift:fb,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:qk,shift:eA,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Yk,shift:cA,preventDefault:!0},{key:"ArrowUp",run:hb,shift:pb,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Ob,shift:vb},{mac:"Ctrl-ArrowUp",run:ub,shift:gb},{key:"ArrowDown",run:cb,shift:mb,preventDefault:!0},{mac:"Cmd-ArrowDown",run:yb,shift:xb},{mac:"Ctrl-ArrowDown",run:Mu,shift:bb},{key:"PageUp",run:ub,shift:gb},{key:"PageDown",run:Mu,shift:bb},{key:"Home",run:Uk,shift:lA,preventDefault:!0},{key:"Mod-Home",run:Ob,shift:vb},{key:"End",run:Wk,shift:aA,preventDefault:!0},{key:"Mod-End",run:yb,shift:xb},{key:"Enter",run:Ab,shift:Ab},{key:"Mod-a",run:fA},{key:"Backspace",run:qu,shift:qu,preventDefault:!0},{key:"Delete",run:wb,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:kb,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:xA,preventDefault:!0},{mac:"Mod-Backspace",run:wA,preventDefault:!0},{mac:"Mod-Delete",run:kA,preventDefault:!0}].concat(XA.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),zu=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Bk,shift:sA},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:zk,shift:nA},{key:"Alt-ArrowUp",run:$A},{key:"Shift-Alt-ArrowUp",run:TA},{key:"Alt-ArrowDown",run:PA},{key:"Shift-Alt-ArrowDown",run:LA},{key:"Mod-Alt-ArrowUp",run:bA},{key:"Mod-Alt-ArrowDown",run:OA},{key:"Escape",run:yA},{key:"Mod-Enter",run:RA},{key:"Alt-l",mac:"Ctrl-l",run:pA},{key:"Mod-i",run:mA,preventDefault:!0},{key:"Mod-[",run:Cb},{key:"Mod-]",run:Nu},{key:"Mod-Alt-\\",run:DA},{key:"Shift-Mod-k",run:MA},{key:"Shift-Mod-\\",run:Jk},{key:"Mod-/",run:wk},{key:"Alt-A",run:Ak},{key:"Ctrl-m",mac:"Shift-Alt-m",run:qA}].concat(NA),_u={key:"Tab",run:Nu,shift:Cb}});function ts(s,t=null,e=0){let i=null;return s.between(e,1e9,(n,r,{spec:o})=>{if(!(t&&o.diagnostics.indexOf(t)<0))if(!i)i=new ju(n,r,t||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ju(i.from,r,i.diagnostic)}}),i}function BA(s,t){let e=t.pos,i=t.end||e,n=s.state.facet(li).hideOn(s,e,i);if(n!=null)return n;let r=s.startState.doc.lineAt(t.pos);return!!(s.effects.some(o=>o.is(Il))||s.changes.touchesRange(r.from,Math.max(r.to,i)))}function zA(s,t){return s.field(Wt,!1)?t:t.concat(W.appendConfig.of(t1))}function _A(s,t){return{effects:zA(s,[Il.of(t)])}}function xI(s){let t=s.field(Wt,!1);return t?t.diagnostics.size:0}function wI(s,t,e){let{diagnostics:i}=s.state.field(Wt),n,r=-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 n=c.diagnostics,r=l,o=h,!1});let a=s.state.facet(li).tooltipFilter;return n&&a&&(n=a(n,s.state)),n?{pos:r,end:o,above:s.state.doc.lineAt(r).to<o,create(){return{dom:VA(s,n)}}}:null}function VA(s,t){return $t("ul",{class:"cm-tooltip-lint"},t.map(e=>GA(s,e,!1)))}function EI(s,t,e){let i=[],n=-1;for(let r of s)r.then(o=>{i.push(o),clearTimeout(n),i.length==s.length?t(i):n=setTimeout(()=>t(i),200)},e)}function YA(s,t){return s?t?(e,i)=>t(s(e,i),i):s:t}function ql(s,t={}){return[li.of({source:s,config:t}),FA,t1]}function CI(s){let t=s.plugin(FA);t&&t.force()}function HA(s){let t=[];if(s)t:for(let{name:e}of s){for(let i=0;i<e.length;i++){let n=e[i];if(/[a-zA-Z]/.test(n)&&!t.some(r=>r.toLowerCase()==n.toLowerCase())){t.push(n);continue t}}t.push("")}return t}function GA(s,t,e){var i;let n=e?HA(t.actions):[];return $t("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},$t("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(s):t.message),(i=t.actions)===null||i===void 0?void 0:i.map((r,o)=>{let a=!1,l=f=>{if(f.preventDefault(),a)return;a=!0;let p=ts(s.state.field(Wt).diagnostics,t);p&&r.apply(s,p.from,p.to)},{name:h}=r,c=n[o]?h.indexOf(n[o]):-1,u=c<0?h:[h.slice(0,c),$t("u",h.slice(c,c+1)),h.slice(c+1)],d=r.markClass?" "+r.markClass:"";return $t("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:l,onmousedown:l,"aria-label":` Action: ${h}${c<0?"":` (access key "${n[o]})"`}.`},u)}),t.source&&$t("div",{class:"cm-diagnosticSource"},t.source))}function Wu(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 Uu(s){return Wu(`<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 PI(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function KA(s){let t="hint",e=1;for(let i of s){let n=PI(i.severity);n>e&&(e=n,t=i.severity)}return t}function QI(s,t){let e=i=>{let n=t.getBoundingClientRect();if(!(i.clientX>n.left-10&&i.clientX<n.right+10&&i.clientY>n.top-10&&i.clientY<n.bottom+10)){for(let r=i.target;r;r=r.parentNode)if(r.nodeType==1&&r.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",e),s.state.field(JA)&&s.dispatch({effects:Lb.of(null)})}};window.addEventListener("mousemove",e)}function TI(s,t,e){function i(){let o=s.elementAtHeight(t.getBoundingClientRect().top+5-s.documentTop);s.coordsAtPos(o.from)&&s.dispatch({effects:Lb.of({pos:o.from,above:!1,clip:!1,create(){return{dom:VA(s,e),getCoords:()=>t.getBoundingClientRect()}}})}),t.onmouseout=t.onmousemove=null,QI(s,t)}let{hoverTime:n}=s.state.facet(Yu),r=setTimeout(i,n);t.onmouseout=()=>{clearTimeout(r),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,n)}}function LI(s,t){let e=Object.create(null);for(let n of t){let r=s.lineAt(n.from);(e[r.from]||(e[r.from]=[])).push(n)}let i=[];for(let n in e)i.push(new Fu(e[n]).range(+n));return H.of(i,!0)}function Hu(s={}){return[Yu.of(s),Tb,MI,RI,JA]}function II(s,t){let e=s.field(Wt,!1);if(e&&e.diagnostics.size){let i=[],n=[],r=-1;for(let o=H.iter([e.diagnostics]);;o.next()){for(let a=0;a<i.length;a++)(!o.value||o.value.spec.diagnostics.indexOf(i[a])<0)&&(t(i[a],n[a],r),i.splice(a,1),n.splice(a--,1));if(!o.value)break;for(let a of o.value.spec.diagnostics)i.indexOf(a)<0&&(i.push(a),n.push(o.from));r=o.to}}}var ju,Ws,Il,$b,jA,Wt,SI,WA,Pb,UA,kI,AI,FA,li,Qb,Vu,Dl,$I,Fu,MI,Tb,Lb,JA,RI,t1,Yu,e1=B(()=>{Si();ei();Zf();ju=class{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}},Ws=class s{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let n=i.facet(li).markerFilter;n&&(t=n(t,i));let r=t.slice().sort((f,p)=>f.from-p.from||f.to-p.to),o=new ke,a=[],l=0,h=i.doc.iter(),c=0,u=i.doc.length;for(let f=0;;){let p=f==r.length?null:r[f];if(!p&&!a.length)break;let m,b;if(a.length)m=l,b=a.reduce((v,w)=>Math.min(v,w.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>u)break;b=p.to,a.push(p),f++}for(;f<r.length;){let v=r[f];if(v.from==m&&(v.to>v.from||v.to==m))a.push(v),f++,b=Math.min(v.to,b);else{b=Math.min(v.from,b);break}}b=Math.min(b,u);let g=!1;if(a.some(v=>v.from==m&&(v.to==b||b==u))&&(g=m==b,!g&&b-m<10)){let v=m-(c+h.value.length);v>0&&(h.next(v),c=m);for(let w=m;;){if(w>=b){g=!0;break}if(!h.lineBreak&&c+h.value.length>w)break;w=c+h.value.length,c+=h.value.length,h.next()}}let y=KA(a);if(g)o.add(m,m,j.widget({widget:new Qb(y),diagnostics:a.slice()}));else{let v=a.reduce((w,k)=>k.markClass?w+" "+k.markClass:w,"");o.add(m,b,j.mark({class:"cm-lintRange cm-lintRange-"+y+v,diagnostics:a.slice(),inclusiveEnd:a.some(w=>w.to>b)}))}if(l=b,l==u)break;for(let v=0;v<a.length;v++)a[v].to<=l&&a.splice(v--,1)}let d=o.finish();return new s(d,e,ts(d))}};Il=W.define(),$b=W.define(),jA=W.define(),Wt=mt.define({create(){return new Ws(j.none,null,null)},update(s,t){if(t.docChanged&&s.diagnostics.size){let e=s.diagnostics.map(t.changes),i=null,n=s.panel;if(s.selected){let r=t.changes.mapPos(s.selected.from,1);i=ts(e,s.selected.diagnostic,r)||ts(e,null,r)}!e.size&&n&&t.state.facet(li).autoPanel&&(n=null),s=new Ws(e,n,i)}for(let e of t.effects)if(e.is(Il)){let i=t.state.facet(li).autoPanel?e.value.length?Dl.open:null:s.panel;s=Ws.init(e.value,i,t.state)}else e.is($b)?s=new Ws(s.diagnostics,e.value?Dl.open:null,s.selected):e.is(jA)&&(s=new Ws(s.diagnostics,s.panel,e.value));return s},provide:s=>[jr.from(s,t=>t.panel),I.decorations.from(s,t=>t.diagnostics)]});SI=j.mark({class:"cm-lintRange cm-lintRange-active"});WA=s=>{let t=s.state.field(Wt,!1);(!t||!t.panel)&&s.dispatch({effects:zA(s.state,[$b.of(!0)])});let e=Rc(s,Dl.open);return e&&e.dom.querySelector(".cm-panel-lint ul").focus(),!0},Pb=s=>{let t=s.state.field(Wt,!1);return!t||!t.panel?!1:(s.dispatch({effects:$b.of(!1)}),!0)},UA=s=>{let t=s.state.field(Wt,!1);if(!t)return!1;let e=s.state.selection.main,i=ts(t.diagnostics,null,e.to+1);return!i&&(i=ts(t.diagnostics,null,0),!i||i.from==e.from&&i.to==e.to)?!1:(s.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},kI=s=>{let{state:t}=s,e=t.field(Wt,!1);if(!e)return!1;let i=t.selection.main,n,r,o,a;return e.diagnostics.between(0,t.doc.length,(l,h)=>{h<i.to&&(n==null||n<l)&&(n=l,r=h),(o==null||l>o)&&(o=l,a=h)}),o==null||n==null&&o==i.from?!1:(s.dispatch({selection:{anchor:n??o,head:r??a},scrollIntoView:!0}),!0)},AI=[{key:"Mod-Shift-m",run:WA,preventDefault:!0},{key:"F8",run:UA}],FA=ht.fromClass(class{constructor(s){this.view=s,this.timeout=-1,this.set=!0;let{delay:t}=s.state.facet(li);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(li);e.length&&EI(e.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==t.doc&&this.view.dispatch(_A(this.view.state,i.reduce((n,r)=>n.concat(r))))},i=>{Pt(this.view.state,i)})}}update(s){let t=s.state.facet(li);(s.docChanged||t!=s.startState.facet(li)||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)}});li=X.define({combine(s){return{sources:s.map(t=>t.source).filter(t=>t!=null),...Gt(s.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:YA,tooltipFilter:YA,needsRefresh:(t,e)=>t?e?i=>t(i)||e(i):t:e,hideOn:(t,e)=>t?e?(i,n,r)=>t(i,n,r)||e(i,n,r):t:e,autoPanel:(t,e)=>t||e})}}});Qb=class extends Dt{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return $t("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},Vu=class{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=GA(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Dl=class s{constructor(t){this.view=t,this.items=[];let e=n=>{if(!(n.ctrlKey||n.altKey||n.metaKey)){if(n.keyCode==27)Pb(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=HA(r.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==n.keyCode){let l=ts(this.view.state.field(Wt).diagnostics,r);l&&r.actions[a].apply(t,l.from,l.to)}}else return;n.preventDefault()}},i=n=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(n.target)&&this.moveSelection(r)};this.list=$t("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e,onclick:i}),this.dom=$t("div",{class:"cm-panel-lint"},this.list,$t("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Pb(this.view)},"\xD7")),this.update()}get selectedIndex(){let t=this.view.state.field(Wt).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(Wt),i=0,n=!1,r=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 Vu(this.view,c),this.items.splice(i,0,d),n=!0):(d=this.items[u],u>i&&(this.items.splice(i,u-i),n=!0)),e&&d.diagnostic==e.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),r=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);)n=!0,this.items.pop();this.items.length==0&&(this.items.push(new Vu(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.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"),n&&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(Wt),i=ts(e.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:jA.of(i)})}static open(t){return new s(t)}};$I=I.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Uu("#d11")},".cm-lintRange-warning":{backgroundImage:Uu("orange")},".cm-lintRange-info":{backgroundImage:Uu("#999")},".cm-lintRange-hint":{backgroundImage:Uu("#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"}}});Fu=class extends Jt{constructor(t){super(),this.diagnostics=t,this.severity=KA(t)}toDOM(t){let e=document.createElement("div");e.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,n=t.state.facet(Yu).tooltipFilter;return n&&(i=n(i,t.state)),i.length&&(e.onmouseover=()=>TI(t,e,i)),e}};MI=hl({class:"cm-gutter-lint",markers:s=>s.state.field(Tb),widgetMarker:(s,t,e)=>{let i=[];return s.state.field(Tb).between(e.from,e.to,(n,r,o)=>{n>e.from&&n<e.to&&i.push(...o.diagnostics)}),i.length?new Fu(i):null}}),Tb=mt.define({create(){return H.empty},update(s,t){s=s.map(t.changes);let e=t.state.facet(Yu).markerFilter;for(let i of t.effects)if(i.is(Il)){let n=i.value;e&&(n=e(n||[],t.state)),s=LI(t.state.doc,n.slice(0))}return s}}),Lb=W.define(),JA=mt.define({create(){return null},update(s,t){return s&&t.docChanged&&(s=BA(t,s)?null:{...s,pos:t.changes.mapPos(s.pos)}),t.effects.reduce((e,i)=>i.is(Lb)?i.value:e,s)},provide:s=>Ts.from(s)}),RI=I.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Wu('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Wu('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Wu('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),t1=[Wt,I.decorations.compute([Wt],s=>{let{selected:t,panel:e}=s.field(Wt);return!t||!e||t.from==t.to?j.none:j.set([SI.range(t.from,t.to)])}),Jp(wI,{hideOn:BA}),$I],Yu=X.define({combine(s){return Gt(s,{hoverTime:300,markerFilter:null,tooltipFilter:null})}})});var Rb={};Ft(Rb,{Compartment:()=>_i,EditorSelection:()=>$,EditorState:()=>rt,EditorView:()=>I,HighlightStyle:()=>Ci,LOAD_TIMEOUT_MS:()=>Mb,LanguageSupport:()=>vt,StateEffect:()=>W,adiaBaseTheme:()=>DI,adiaHighlightStyle:()=>qI,defaultHighlightStyle:()=>Yc,defaultKeymap:()=>zu,drawSelection:()=>Ic,highlightActiveLine:()=>Dc,highlightActiveLineGutter:()=>Zc,history:()=>Zu,historyKeymap:()=>Bu,importWithTimeout:()=>NI,indentWithTab:()=>_u,jsonLinter:()=>ZI,keymap:()=>ni,languages:()=>XI,lineNumbers:()=>Nc,lintGutter:()=>Hu,linter:()=>ql,placeholder:()=>qc,syntaxHighlighting:()=>Fc});function NI(s,t){return Promise.race([s(),new Promise((e,i)=>setTimeout(()=>i(new Error(`code-editor: ${t} load timed out after ${Mb}ms`)),Mb))])}function BI(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 n=s.match(/line (\d+) column (\d+)/);if(n){let o=Number(n[1]),a=Number(n[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 r=Math.max(0,e);return{from:Math.max(0,r-1),to:r}}var DI,qI,XI,Mb,ZI,Ib=B(()=>{"use strict";ei();Si();ZA();ai();e1();Je();DI=I.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{padding:"0",caretColor:"inherit"},".cm-focused":{outline:"none"}}),qI=Ci.define([{tag:[O.comment,O.lineComment,O.blockComment,O.docComment],class:"tok-comment"},{tag:[O.keyword,O.controlKeyword,O.modifier,O.operatorKeyword],class:"tok-keyword"},{tag:[O.string,O.character,O.regexp,O.escape,O.special(O.string)],class:"tok-string"},{tag:[O.number,O.integer,O.float],class:"tok-number"},{tag:[O.bool,O.null,O.atom],class:"tok-boolean"},{tag:[O.operator,O.logicOperator,O.arithmeticOperator,O.compareOperator,O.updateOperator,O.definitionOperator],class:"tok-operator"},{tag:[O.punctuation,O.bracket,O.paren,O.brace,O.squareBracket,O.angleBracket,O.separator],class:"tok-punctuation"},{tag:[O.function(O.variableName),O.function(O.propertyName),O.macroName],class:"tok-function"},{tag:[O.variableName,O.local(O.variableName),O.self],class:"tok-variable"},{tag:[O.typeName,O.className,O.namespace],class:"tok-type"},{tag:[O.propertyName,O.labelName,O.definition(O.variableName)],class:"tok-property"},{tag:[O.tagName,O.heading,O.contentSeparator],class:"tok-tag"},{tag:[O.attributeName,O.attributeValue],class:"tok-attribute"},{tag:[O.url,O.link],class:"tok-url"},{tag:[O.invalid,O.deleted],class:"tok-invalid"}]),XI={json:()=>Promise.resolve().then(()=>(Dx(),Ix)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(mg(),pw)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(lg(),iw)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Mm(),dS)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(ak(),ok)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(Sk(),xk)).then(s=>({extension:s.yaml()}))},Mb=1e4;ZI=ql(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:n,to:r}=BI(i,t);return[{from:n,to:r,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function td(s){return qt.get(s)||null}function y1(s,t){qt.set(s,t)}var qt,jb=B(()=>{"use strict";qt=new Map([["Row","row-ui"],["Column","col-ui"],["List","list-ui"],["ListItem","list-item-ui"],["Grid","grid-ui"],["Stack","stack-ui"],["Block","block-ui"],["Text","text-ui"],["Image","image-ui"],["Icon","icon-ui"],["Divider","divider-ui"],["Badge","badge-ui"],["Avatar","avatar-ui"],["AvatarGroup","avatar-group-ui"],["Progress","progress-ui"],["ProgressRow","progress-row-ui"],["DateRangePicker","date-range-picker-ui"],["DatetimePicker","datetime-picker-ui"],["CalendarGrid","calendar-grid-ui"],["CalendarPicker","calendar-picker-ui"],["Combobox","combobox-ui"],["Skeleton","skeleton-ui"],["Stepper","stepper-ui"],["StepperItem","stepper-item-ui"],["Tour","tour-ui"],["TourStep","tour-step-ui"],["IntegrationCard","integration-card-ui"],["Code","code-ui"],["Stat","stat-ui"],["EmptyState","empty-state-ui"],["Input","input-ui"],["TextField","input-ui"],["TextArea","textarea-ui"],["Field","field-ui"],["CheckBox","check-ui"],["Toggle","switch-ui"],["Switch","switch-ui"],["Slider","slider-ui"],["Range","range-ui"],["Rating","rating-ui"],["ChoicePicker","select-ui"],["Select","select-ui"],["Radio","radio-ui"],["DateTimeInput","calendar-picker-ui"],["CalendarPicker","calendar-picker-ui"],["ColorPicker","color-picker-ui"],["Upload","upload-ui"],["OtpInput","otp-input-ui"],["Button","button-ui"],["LoadingIndicator","progress-ui"],["ErrorContainer","card-ui"],["Card","card-ui"],["Tabs","tabs-ui"],["Tab","tab-ui"],["Panel","pane-ui"],["Pane","pane-ui"],["Modal","modal-ui"],["Dialog","modal-ui"],["Drawer","drawer-ui"],["Toast","toast-ui"],["Popover","popover-ui"],["Accordion","accordion-ui"],["AccordionItem","accordion-item-ui"],["Alert","alert-ui"],["Tooltip","tooltip-ui"],["Menu","menu-ui"],["Section","section"],["Header","header"],["Footer","footer"],["Stream","stream-ui"],["Table","table-ui"],["ColDef","col-def"],["Chart","chart-ui"],["Embed","embed-ui"],["Swiper","swiper-ui"],["Slideshow","swiper-ui"],["Carousel","swiper-ui"],["Breadcrumb","breadcrumb-ui"],["Link","link-ui"],["Anchor","link-ui"],["Hyperlink","link-ui"],["NavLink","link-ui"],["Nav","nav-ui"],["NavGroup","nav-group-ui"],["NavItem","nav-item-ui"],["Noodles","noodles-ui"],["Pagination","pagination-ui"],["SegmentedControl","segmented-ui"],["Segment","segment-ui"],["ToggleGroup","toggle-group-ui"],["Command","command-ui"],["Kbd","kbd-ui"],["Toolbar","toolbar-ui"],["Tag","tag-ui"],["Timeline","timeline-ui"],["TimelineItem","timeline-item-ui"],["button-ui","button-ui"],["card-ui","card-ui"],["text-ui","text-ui"],["input-ui","input-ui"],["text-field-ui","input-ui"],["select-ui","select-ui"],["toggle-ui","switch-ui"],["check-ui","check-ui"],["slider-ui","slider-ui"],["badge-ui","badge-ui"],["avatar-ui","avatar-ui"],["icon-ui","icon-ui"],["image-ui","image-ui"],["divider-ui","divider-ui"],["progress-ui","progress-ui"],["skeleton-ui","skeleton-ui"],["tabs-ui","tabs-ui"],["tab-ui","tab-ui"],["modal-ui","modal-ui"],["dialog-ui","modal-ui"],["drawer-ui","drawer-ui"],["toast-ui","toast-ui"],["popover-ui","popover-ui"],["panel-ui","pane-ui"],["accordion-ui","accordion-ui"],["alert-ui","alert-ui"],["tooltip-ui","tooltip-ui"],["menu-ui","menu-ui"],["table-ui","table-ui"],["chart-ui","chart-ui"],["code-ui","code-ui"],["textarea-ui","textarea-ui"],["radio-ui","radio-ui"],["tag-ui","tag-ui"],["search-ui","search-ui"],["upload-ui","upload-ui"],["breadcrumb-ui","breadcrumb-ui"],["link-ui","link-ui"],["nav-ui","nav-ui"],["noodles-ui","noodles-ui"],["pagination-ui","pagination-ui"],["segmented-control-ui","segmented-ui"],["segment-ui","segment-ui"],["command-ui","command-ui"],["calendar-picker-ui","calendar-picker-ui"],["color-picker-ui","color-picker-ui"],["kbd-ui","kbd-ui"],["toolbar-ui","toolbar-ui"],["otp-input-ui","otp-input-ui"],["embed-ui","embed-ui"],["stream-ui","stream-ui"],["row-ui","row-ui"],["col-ui","col-ui"],["grid-ui","grid-ui"],["stack-ui","stack-ui"],["block-ui","block-ui"],["list-ui","list-ui"],["range-ui","range-ui"],["datetime-ui","calendar-picker-ui"],["timeline-ui","timeline-ui"],["timeline-item-ui","timeline-item-ui"],["avatar-group-ui","avatar-group-ui"],["Keyboard","kbd-ui"],["DatePicker","calendar-picker-ui"],["CommandPalette","command-ui"],["FormContainer","form"],["Sidebar","admin-sidebar"],["Segmented","segmented-ui"],["OTP","otp-input-ui"],["Textarea","textarea-ui"],["RichText","richtext-ui"],["Richtext","richtext-ui"],["DescriptionList","description-list-ui"],["ActionItem","action-item-ui"],["ActionList","action-list-ui"],["Inspector","inspector-ui"],["Heatmap","heatmap-ui"],["ChatThread","chat-thread"],["ChatInput","chat-input-ui"],["OptionCard","option-card-ui"],["Option","option-card-ui"],["AdminCommand","admin-command"],["AdminContent","admin-content"],["AdminPage","admin-page"],["AdminPageBody","admin-page-body"],["AdminPageHeader","admin-page-header"],["AdminScroll","admin-scroll"],["AdminShell","admin-shell"],["AdminSidebar","admin-sidebar"],["AdminStatusbar","admin-statusbar"],["AdminTopbar","admin-topbar"],["ChatComposer","chat-composer"],["ChatEmpty","chat-empty"],["ChatHeader","chat-header"],["ChatShell","chat-shell"],["ChatSidebar","chat-sidebar"],["ChatStatus","chat-status"],["EditorCanvas","editor-canvas"],["EditorCanvasEmpty","editor-canvas-empty"],["EditorShell","editor-shell"],["EditorSidebar","editor-sidebar"],["EditorStatusbar","editor-statusbar"],["EditorToolbar","editor-toolbar"],["GenRoot","gen-root"],["SimpleContent","simple-content"],["SimpleHero","simple-hero"],["SimpleShell","simple-shell"],["ThemePanel","theme-panel"]])});function v1(s,t){if(!t||t==="/")return s;let e=t.replace(/^\//,"").split("/"),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function bD(s,t,e){if(!t||t==="/")return;let i=t.replace(/^\//,"").split("/"),n=s;for(let r=0;r<i.length-1;r++){let o=i[r];n[o]==null&&(n[o]={}),n=n[o]}n[i[i.length-1]]=e}var ed,Ko,Vb=B(()=>{"use strict";ed={provider:0,controller:1,source:2,action:3,lifecycle:4},Ko=class{surfaceId;#t=new Map;#e={};#i={};#s=new Map;#n;#r;constructor(t,e,i){this.surfaceId=t,this.#n=e,this.#r=i}get context(){return{surfaceId:this.surfaceId,getElement:t=>this.#r.get(t)||null,getRootElement:()=>this.#n,getModel:t=>t?v1(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,n)=>(ed[i.kind]??9)-(ed[n.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)=>(ed[i[1].dockable.kind]??9)-(ed[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.#r=t}#a(t,e){bD(this.#e,t,e);for(let[i,n]of this.#s)if(t===i||t.startsWith(i+"/"))for(let r of n)r(v1(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.#r.get(t.target):this.#n;e&&e.dispatchEvent(new CustomEvent(t.event,{bubbles:!0,detail:t}))}}});var ge,Ys=B(()=>{"use strict";ge=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 Jo,Wb=B(()=>{"use strict";Ys();Jo=class extends ge{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 n=[];if(this.bind)for(let[r,o]of Object.entries(this.bind)){if(this.controller.subscribe){let l=this.controller.subscribe(r,h=>{t.setModel(o,h)});l&&n.push(l)}let a=t.getModel(o);a!==void 0&&this.controller.setState&&this.controller.setState(r,a)}return e.controller=this.controller,()=>{e.controller=null,n.forEach(r=>r())}}undock(){this.controller&&(this.controller.disconnect?.(),this.controller=null)}}});var ta,Ub=B(()=>{"use strict";Ys();ta=class extends ge{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=n=>{try{t.setModel(this.path,JSON.parse(n.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 id,ea,Fb=B(()=>{"use strict";Ys();id={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"},ea=class extends ge{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=id[this.event.event]||this.event.event,n=this.#t(this.handler);if(!n){console.warn(`ActionDock: unknown handler "${this.handler}"`);return}let r=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 n(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=r,a;r=(...l)=>{clearTimeout(a),a=setTimeout(()=>o(...l),this.event.debounce)}}if(this.event.throttle>0){let o=r,a=0;r=(...l)=>{let h=Date.now();h-a>=this.event.throttle&&(a=h,o(...l))}}return e.addEventListener(i,r),()=>e.removeEventListener(i,r)}undock(){}}});var ia,Yb=B(()=>{"use strict";Ys();ia=class extends ge{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 sa,Hb=B(()=>{"use strict";Ys();sa=class extends ge{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 n=()=>this.#i(i,t);if(i.debounce>0){let r=n,o;n=()=>{clearTimeout(o),o=setTimeout(r,i.debounce)}}return t.watchModel(i.path,n)});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(n){console.warn(`LifecycleDock: ${t.handler} failed`,n)}}}});var x1,be,Hs=B(()=>{"use strict";x1=new WeakSet,be=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!x1.has(e)&&e!==s&&(x1.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 S1={};Ft(S1,{FormController:()=>Gb});var Gb,w1=B(()=>{"use strict";Hs();Gb=class extends be{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")}#n(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.#n(t),this.notify()},validate:(t,e)=>{this.#s[t]=e,this.#n(t),this.notify()},reset:()=>{this.#e={...this.#t},this.#i={};for(let t of Object.keys(this.#s))this.#n(t);this.notify()},setInitial:t=>{this.#t={...t}}}}});var k1={};Ft(k1,{DataStreamController:()=>Kb});var Kb,A1=B(()=>{"use strict";Hs();Kb=class extends be{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;#n=null;#r=0;#a=1;#o=null;#l=0;constructor({max:t=100,throttle:e=0,sample:i=1,initial:n=[]}={}){super(),this.#e=t,this.#r=e,this.#a=Math.max(1,Math.round(i)),this.#t=n.slice(-t)}getState(){return{data:this.#t,status:this.#i,error:this.#s}}reflect(){this.host&&this.host.setAttribute("data-stream-status",this.#i)}onDisconnect(){this.commands.stop()}#c(t){this.#l++,!(this.#a>1&&this.#l%this.#a!==0)&&(this.#t.push(t),this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u())}#h(t){if(this.#a>1){let e=[];for(let i of t)this.#l++,this.#l%this.#a===0&&e.push(i);this.#t.push(...e)}else this.#t.push(...t);this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u()}#u(){if(this.#r<=0){this.notify();return}this.#o===null&&(this.#o=setTimeout(()=>{this.#o=null,this.notify()},this.#r))}#d(t,e=null){this.#i=t,this.#s=e,this.notify()}commands={push:t=>{this.#c(t)},pushMany:t=>{this.#h(t)},connect:(t,e)=>{this.commands.stop(),this.#n=new AbortController,t==="sse"?this.#p(e):t==="ws"?this.#f(e):this.#d("error",`Unknown stream type: ${t}`)},poll:(t,e=2e3)=>{this.commands.stop(),this.#n=new AbortController,this.#m(t,e)},consume:t=>{this.commands.stop(),this.#n=new AbortController,this.#O(t)},stop:()=>{this.#n&&(this.#n.abort(),this.#n=null),this.#o!==null&&(clearTimeout(this.#o),this.#o=null),(this.#i==="streaming"||this.#i==="connecting")&&this.#d("stopped")},clear:()=>{this.#t=[],this.notify()}};#p(t){this.#d("connecting");let e=new EventSource(t),i=this.#n.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#d("streaming"),e.onmessage=n=>{try{let r=JSON.parse(n.data);this.#c(r)}catch{}},e.onerror=()=>{i.aborted||(this.#d("error","SSE connection lost"),e.close())}}#f(t){this.#d("connecting");let e=new WebSocket(t),i=this.#n.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#d("streaming"),e.onmessage=n=>{try{let r=JSON.parse(n.data);Array.isArray(r)?this.#h(r):this.#c(r)}catch{}},e.onerror=()=>{i.aborted||this.#d("error","WebSocket error")},e.onclose=()=>{i.aborted||this.#d("stopped")}}async#m(t,e){this.#d("streaming");let i=this.#n.signal;for(;!i.aborted;){try{let r=await(await fetch(t,{signal:i})).json();Array.isArray(r)?this.#h(r):this.#c(r)}catch(n){if(i.aborted)break;this.#d("error",n.message);break}await new Promise(n=>setTimeout(n,e))}}async#O(t){this.#d("streaming");let e=this.#n.signal;try{for await(let i of t){if(e.aborted)break;Array.isArray(i)?this.#h(i):this.#c(i)}e.aborted||this.#d("idle")}catch(i){e.aborted||this.#d("error",i.message)}}}});var E1={};Ft(E1,{SelectionController:()=>Jb});var Jb,C1=B(()=>{"use strict";Hs();Jb=class extends be{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 $1={};Ft($1,{ToggleController:()=>tO});var tO,P1=B(()=>{"use strict";Hs();tO=class extends be{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 Q1={};Ft(Q1,{AccordionController:()=>eO});var eO,T1=B(()=>{"use strict";Hs();eO=class extends be{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 L1={};Ft(L1,{StateMachineController:()=>iO});var iO,M1=B(()=>{"use strict";Hs();iO=class extends be{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 n of i){let r=t[n]||{},o={};for(let[a,l]of Object.entries(r.on||{})){if(typeof l!="string"||!(l in t)){console.warn(`[state-machine] state "${n}" transition "${a}" \u2192 "${l}" \u2014 target not declared`);continue}o[a]=l}e[n]={on:o}}return e}}});function R1(s,t){Di.controllers.set(s,t)}function I1(s,t){Di.handlers.set(s,t)}function D1(s,t){Di.resolvers.set(s,t)}async function sd(s){let t=Di.controllers.get(s);return t?t():null}function nd(s){return Di.handlers.get(s)||null}async function Zl(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 n=e.slice(0,i),r=Di.resolvers.get(n);if(!r)throw new Error(`No resolver for scheme "${n}"`);return r(e,t)}async function OD(s){let{action:t,params:e}=s,i=sO(t.body,s),n=t.uri;for(let[c,u]of Object.entries(e))n=n.replace(`{${c}}`,encodeURIComponent(u));let r=n.indexOf("://"),o=r>-1?n.slice(0,r):"api",a=Di.resolvers.get(o),l=n.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 yD(s){let{action:t}=s,e=sO(t.value,s);s.updateModel(t.path,e)}async function vD(s){let{action:t,params:e}=s,i=t.navigate||t.path||"";for(let[n,r]of Object.entries(e))i=i.replace(`{${n}}`,encodeURIComponent(r));i==="back"?history.back():i&&(location.hash=i)}async function xD(){history.back()}async function SD(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 wD(s){let{action:t,source:e}=s,i=sO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function kD(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function AD(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 sO(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 ED(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}function ED(s,t){if(!t||!s)return;let e=t.split("/").filter(Boolean),i=s;for(let n of e){if(i==null||typeof i!="object")return;i=i[n]}return i}async function CD(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 $D(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 PD(s,t){return{_source:s,_mock:!0}}var Di,nO=B(()=>{"use strict";Di={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>(w1(),S1))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(A1(),k1))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>(C1(),E1))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(P1(),$1))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(T1(),Q1))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(M1(),L1))).StateMachineController]]),handlers:new Map([["submit-resource",OD],["update-model",yD],["navigate",vD],["navigate-back",xD],["controller-command",SD],["emit-event",wD],["refresh-source",kD],["notify",AD]]),resolvers:new Map([["resource",CD],["api",$D],["mock",PD]])}});function QD(s){return async(t,e,i)=>{let n={action:t,event:i instanceof Event?i:null,source:i instanceof Event?i.target:null,dataModel:e.getModel(),updateModel:(r,o)=>e.setModel(r,o),controllers:Object.fromEntries(e.listDockables("controller").map(r=>[r.id,r.controller])),params:{},resolveData:Zl};return s(n)}}function TD(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=nd(t);if(!e)return null;let i=QD(e);return s.set(t,i),i}}function LD(){return async s=>sd(s)}function MD(){return async(s,t)=>Zl(s,{})}function rd(s){let t=[],e=TD(),i=LD(),n=MD();if(s.data?.sources)for(let o of s.data.sources)t.push(new ta(o,n));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new Jo(o,i));if(s.actions)for(let o of s.actions)t.push(new ea(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new ia(a))}s.lifecycle&&t.push(new sa(s.lifecycle,e));let r=s.state?.model||null;return{dockables:t,initialModel:r}}var rO=B(()=>{"use strict";Wb();Ub();Fb();Yb();Hb();nO()});var q1={};Ft(q1,{WiringEngine:()=>Bl});var Bl,oO=B(()=>{"use strict";Vb();rO();Bl=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.#n(t.data.params));let{dockables:n,initialModel:r}=rd(t);r&&i.setInitialModel(r),t.undock&&i.undockMany(t.undock);for(let o of n)await i.dock(o)}catch(n){console.warn(`Wiring: error processing wireComponents for "${e}":`,n.message)}}teardown(t){let e=this.#t.get(t);e&&(e.undockAll(),this.#t.delete(t))}teardownAll(){for(let t of this.#t.keys())this.teardown(t)}getSurface(t){return this.#t.get(t)||null}getSurfaceState(t){let e=this.#t.get(t);if(!e)return null;let i=e.context.listDockables();return{surfaceId:t,controllerCount:i.filter(n=>n.kind==="controller").length,sourceCount:i.filter(n=>n.kind==="source").length,actionCount:i.filter(n=>n.kind==="action").length,providerCount:i.filter(n=>n.kind==="provider").length,hasLifecycle:i.some(n=>n.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"),n=new Proxy(new Map,{get(h,c){return c==="get"?u=>e.get(u):c==="has"?u=>e.has(u):h[c]}}),r=new Ko(t,i,n),o=r.context,a=o.setModel,l=this.#e;return Object.defineProperty(r,"context",{get(){return{...o,setModel(c,u){a(c,u),l(t,c,u)}}}}),r}#n(t){let e={};for(let[i,n]of Object.entries(t))switch(n.from){case"route":{let o=location.hash.slice(1).match(new RegExp(`${n.key}/([^/]+)`));o&&(e[i]=o[1]);break}case"query":{let o=new URL(location.href).searchParams.get(n.key);o&&(e[i]=o);break}case"literal":e[i]=n.value;break;default:typeof n=="string"&&(e[i]=n)}return e}}});var is,X1=B(()=>{"use strict";jb();is=class s{#t;#e;#i=new Map;#s=new Map;#n=new Map;#r=[];#a=null;#o=!1;constructor(t,e=qt,{batch:i=!1}={}){this.#t=t,this.#e=e,this.#o=i}process(t){t&&(this.#o?(this.#r.push(t),this.#a===null&&(this.#a=requestAnimationFrame(()=>this.#l()))):this.#c(t))}#l(){this.#a=null;let t=this.#r.splice(0);for(let e of t)this.#c(e)}#c(t){switch(t.type||t.messageType){case"createSurface":this.#d(t);break;case"updateComponents":this.#p(t);break;case"updateDataModel":this.#P(t);break;case"wireComponents":this.#u(t);break;case"deleteSurface":this.#R(t);break;case"updateStyles":this.#q(t);break;case"removeStyles":this.#Q(t);break;case"meta":break;default:console.warn("A2UI: unknown message type",t.type)}}#h=null;async#u(t){if(!this.#h){let{WiringEngine:e}=await Promise.resolve().then(()=>(oO(),q1));this.#h=new e({updateDataModel:(i,n,r)=>{this.#P({surfaceId:i,path:n,value:r})},getElement:(i,n)=>this.#i.get(i)?.elements.get(n)||null})}await this.#h.process(t)}async processStream(t){for await(let e of t)this.process(e)}#d({surfaceId:t,catalogId:e,root:i}){if(this.#i.has(t))return;let n=document.createElement("div");n.setAttribute("data-a2ui-surface",t),e&&n.setAttribute("data-catalog",e),this.#t.appendChild(n),this.#i.set(t,{root:n,rootId:typeof i=="string"&&i?i:"root",elements:new Map,dataModel:{},bindings:new Map,adoptedSheets:new Map})}#p({surfaceId:t,components:e}){let i=this.#i.get(t);i||(i={root:this.#t,rootId:"root",elements:new Map,dataModel:{},bindings:new Map,adoptedSheets:new Map},this.#i.set(t,i),this.#t&&typeof this.#t.setAttribute=="function"&&this.#t.setAttribute("data-a2ui-surface",t));for(let l of e)if(!(!l.id&&l.id!==0)){if(l.component==="ContextBindings"){i.contextBindings=l;continue}try{let h=i.elements.get(l.id),c=l.component==="Text"?this.#S(l.variant,l):td(l.component,this.#e);if(!c){h||(h=document.createElement("div"),h.setAttribute("data-a2ui-id",l.id),h.setAttribute("data-a2ui-unknown",l.component),h.textContent=`[unknown: ${l.component}]`,i.elements.set(l.id,h),this.#s.set(l.id,h));continue}if(!h)h=document.createElement(c),h.setAttribute("data-a2ui-id",l.id),i.elements.set(l.id,h),this.#s.set(l.id,h);else if(h.localName!==c){let d=document.createElement(c);d.setAttribute("data-a2ui-id",l.id),h.replaceWith(d),h=d,i.elements.set(l.id,h),this.#s.set(l.id,h)}l._surfaceId=t,Object.values(l).some(d=>d&&typeof d=="object"&&d.path)&&i.bindings.set(l.id,l),this.#x(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#b(e);let n=new Map;for(let l of e){for(let h of Array.isArray(l.children)?l.children:[])n.set(h,l.id);l.child&&n.set(l.child,l.id)}let r=(l,h)=>{let c=new Set,u=l;for(;u!=null;){if(u===h||c.has(u))return!0;c.add(u),u=n.get(u)}return!1};for(let l of e){let h=i.elements.get(l.id);if(h)try{let c=Array.isArray(l.children)?l.children:[];for(let u of c){if(u===l.id||r(l.id,u))continue;let d=i.elements.get(u);d&&d.parentElement!==h&&h.appendChild(d)}if(l.child&&l.child!==l.id&&!r(l.id,l.child)){let u=i.elements.get(l.child);u&&u.parentElement!==h&&h.appendChild(u)}}catch(c){console.warn(`A2UI: tree build failed for "${l.id}":`,c.message)}}let o=i.rootId??"root";if(e.find(l=>l.id===o)){let l=i.elements.get(o);l&&l.parentElement!==i.root&&i.root.appendChild(l)}}static#f=new Set(["Header","Section","Footer","Img","Image","Video","Picture","Iframe","Aside","Divider"]);static#m=new Set(["Header","Section","Footer"]);static#O=new Set(["header","body","footer"]);#g=new Set;#b(t){let e=new Map;for(let i of t)i.id!=null&&e.set(i.id,i);for(let i of t){let n=i.component==="Card"||i.component==="ErrorContainer",r=i.component==="Drawer";if(!n&&!r)continue;let o=r?s.#m:s.#f,a=r?"<drawer-ui>":"<card-ui>",l=Array.isArray(i.children)?i.children:[];for(let h of l){let c=e.get(h);if(!c||typeof c.slot=="string"&&s.#O.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#g.has(u)||(this.#g.add(u),console.warn(`A2UI: ${a} (id="${i.id}") body must wrap "${c.component}" (id="${h}") in <Section>. Direct flow children bypass the canonical body slot and lose --card-inset margin. Canonical children: ${[...o].join(", ")}`+(r?', or slot="header|body|footer".':".")))}}}static#y=new Set(["data","columns","options","itemRenderer","textContent"]);static#w=new Set(["h1","h2","h3","h4","h5","h6","p","small","span","em","strong","code","text-ui"]);static#v={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",body:"p",caption:"small"};static#k=new Set(["autocomplete","autofocus","autocapitalize","autocorrect","inputmode","enterkeyhint","spellcheck","maxlength","minlength","readonly","novalidate","formnovalidate","formaction","formenctype","formmethod","formtarget","multiple","pattern","placeholder","required","tabindex","accesskey","autoplay","autopictureinpicture","controls","crossorigin","disablepictureinpicture","disableremoteplayback","loop","muted","playsinline","preload","srcset","srcdoc","srclang","sizes","loading","decoding","fetchpriority","ismap","usemap","hreflang","referrerpolicy","download","contenteditable","contextmenu","draggable","dirname","colspan","rowspan","headers","allowfullscreen","allowpaymentrequest","itemid","itemprop","itemref","itemscope","itemtype","nomodule","nonce"]);#S(t,e){return!e?.slot&&s.#v[t]?s.#v[t]:"text-ui"}#x(t,e){let i=new Set(["id","component","children","child","_surfaceId"]);e.component==="Text"&&e.variant&&!e.slot&&s.#v[e.variant]&&i.add("variant");let n=this.#n.get(e.id),r={};for(let[o,a]of Object.entries(e)){if(i.has(o))continue;let l=a&&typeof a=="object"&&a.path,h=this.#E(a,e._surfaceId);if(r[o]=h,!(n&&Object.is(n[o],h))){if(o==="style"&&typeof h=="string"){t.style.cssText=h;continue}if(s.#y.has(o)&&h!=null){if(o==="textContent"&&!s.#w.has(t.localName)){t.setAttribute("text",String(h));continue}let c=h;if(typeof c=="string"&&(c.startsWith("[")||c.startsWith("{")))try{c=JSON.parse(c)}catch{}t[o]=c;continue}typeof h=="boolean"?h?t.setAttribute(o,""):t.removeAttribute(o):h!=null?t.setAttribute(this.#A(o),String(h)):l&&t.removeAttribute(this.#A(o))}}if(n)for(let o of Object.keys(n))!(o in r)&&!i.has(o)&&t.removeAttribute(this.#A(o));this.#n.set(e.id,r)}#A(t){return s.#k.has(t.toLowerCase())?t.toLowerCase():t.replace(/([A-Z])/g,"-$1").toLowerCase()}#E(t,e){if(t==null)return null;if(typeof t!="object")return t;if(t.path){let i=e?this.#i.get(e):null;return i?this.#C(i.dataModel,t.path):t.path}return t}#C(t,e){return!e||e==="/"?t:e.split("/").filter(Boolean).reduce((i,n)=>i?.[n],t)}#P({surfaceId:t,path:e,value:i}){let n=this.#i.get(t);if(n){if(!e||e==="/")n.dataModel=i??{};else{let r=e.split("/").filter(Boolean),o=n.dataModel;for(let a=0;a<r.length-1;a++)o[r[a]]==null&&(o[r[a]]={}),o=o[r[a]];o[r[r.length-1]]=i}for(let[r,o]of n.bindings){let a=n.elements.get(r);a&&this.#x(a,o)}}}#R({surfaceId:t}){let e=this.#i.get(t);if(e){this.#h?.teardown(t);for(let[i]of e.elements)this.#s.delete(i);if(e.adoptedSheets&&e.adoptedSheets.size>0){let i=new Set;for(let n of e.adoptedSheets.values())i.add(n.sheet);document.adoptedStyleSheets=document.adoptedStyleSheets.filter(n=>!i.has(n)),e.adoptedSheets.clear()}e.root.remove(),this.#i.delete(t)}}static#T=new Set(["root","html","body"]);#q({surfaceId:t,styleId:e,css:i}){if(typeof e!="string"||e.length===0){this.#M(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#M(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: css must be a string"});return}let n=this.#i.get(t);if(!n){this.#M(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let r=this.#N(i,t);if(r.rejected){this.#M(n.root,"styles-rejected",{surfaceId:t,styleId:e,reason:r.reason});return}let o=n.adoptedSheets.get(e);o&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(a=>a!==o.sheet)),document.adoptedStyleSheets=[...document.adoptedStyleSheets,r.sheet],n.adoptedSheets.set(e,{sheet:r.sheet,ruleCount:r.sheet.cssRules.length,appliedAt:typeof performance<"u"?performance.now():Date.now()}),this.#M(n.root,"styles-applied",{surfaceId:t,styleId:e,ruleCount:r.sheet.cssRules.length,validationWarnings:r.warnings})}#Q({surfaceId:t,styleId:e}){let i=this.#i.get(t);if(!i)return;let n=i.adoptedSheets.get(e);n&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(r=>r!==n.sheet),i.adoptedSheets.delete(e),this.#M(i.root,"styles-removed",{surfaceId:t,styleId:e}))}#N(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 n=new CSSStyleSheet;try{n.replaceSync(t)}catch(l){return{rejected:!0,reason:"parse-error: "+(l?.message||String(l))}}for(let l of n.cssRules){let h=this.#L(l);if(h)return{rejected:!0,reason:h}}if(/url\s*\(\s*["']?\s*(?:https?:|\/\/)/i.test(t))return{rejected:!0,reason:"external-url"};for(let l of n.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 r=this.#D(n,e),o=this.#I(n,e),a=new CSSStyleSheet;try{a.replaceSync(o)}catch(l){return{rejected:!0,reason:"scope-wrap-failed: "+(l?.message||String(l))}}return r.length>0&&i.push({kind:"animations-namespaced",count:r.length}),{rejected:!1,sheet:a,warnings:i}}#L(t){let e=t.cssText||"";if(/^@import\b/i.test(e))return"forbidden-import";if(/^@charset\b/i.test(e))return"forbidden-charset";if(/^@scope\b/i.test(e))return"forbidden-scope-directive";if(t.selectorText){let i=this.#$(t.selectorText);for(let n of i){let r=n.trim().replace(/^:scope\s*/,"");if(r.startsWith(":root"))return"forbidden-root-selector";let o=r.match(/^([a-zA-Z*][\w-]*)/);if(!o)continue;let a=o[1].toLowerCase();if(s.#T.has(a))return`forbidden-${a}-selector`}}return null}#$(t){let e=[],i=0,n=0;for(let r=0;r<t.length;r++){let o=t[r];o==="("?i++:o===")"?i--:o===","&&i===0&&(e.push(t.slice(n,r)),n=r+1)}return e.push(t.slice(n)),e}#D(t,e){let i=[],n=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=`${n}_${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 r=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=>r.has(c)?r.get(c):c);h!==l&&o.style.setProperty(a,h)}return i}#I(t,e){let i=[];for(let r of t.cssRules)i.push(r.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 r=Math.max(0,e);return{from:Math.max(0,r-1),to:r}}var DI,qI,XI,Mb,ZI,Ib=B(()=>{"use strict";ei();Si();ZA();ai();e1();Je();DI=I.theme({"&":{fontFamily:"inherit",fontSize:"inherit",color:"inherit",backgroundColor:"transparent"},".cm-content":{padding:"0",caretColor:"inherit"},".cm-focused":{outline:"none"}}),qI=Ci.define([{tag:[O.comment,O.lineComment,O.blockComment,O.docComment],class:"tok-comment"},{tag:[O.keyword,O.controlKeyword,O.modifier,O.operatorKeyword],class:"tok-keyword"},{tag:[O.string,O.character,O.regexp,O.escape,O.special(O.string)],class:"tok-string"},{tag:[O.number,O.integer,O.float],class:"tok-number"},{tag:[O.bool,O.null,O.atom],class:"tok-boolean"},{tag:[O.operator,O.logicOperator,O.arithmeticOperator,O.compareOperator,O.updateOperator,O.definitionOperator],class:"tok-operator"},{tag:[O.punctuation,O.bracket,O.paren,O.brace,O.squareBracket,O.angleBracket,O.separator],class:"tok-punctuation"},{tag:[O.function(O.variableName),O.function(O.propertyName),O.macroName],class:"tok-function"},{tag:[O.variableName,O.local(O.variableName),O.self],class:"tok-variable"},{tag:[O.typeName,O.className,O.namespace],class:"tok-type"},{tag:[O.propertyName,O.labelName,O.definition(O.variableName)],class:"tok-property"},{tag:[O.tagName,O.heading,O.contentSeparator],class:"tok-tag"},{tag:[O.attributeName,O.attributeValue],class:"tok-attribute"},{tag:[O.url,O.link],class:"tok-url"},{tag:[O.invalid,O.deleted],class:"tok-invalid"}]),XI={json:()=>Promise.resolve().then(()=>(Dx(),Ix)).then(s=>({extension:s.json()})),html:()=>Promise.resolve().then(()=>(mg(),pw)).then(s=>({extension:s.html()})),javascript:()=>Promise.resolve().then(()=>(lg(),iw)).then(s=>({extension:s.javascript({jsx:!1,typescript:!1})})),css:()=>Promise.resolve().then(()=>(Mm(),dS)).then(s=>({extension:s.css()})),markdown:()=>Promise.resolve().then(()=>(ak(),ok)).then(s=>({extension:s.markdown()})),yaml:()=>Promise.resolve().then(()=>(Sk(),xk)).then(s=>({extension:s.yaml()}))},Mb=1e4;ZI=ql(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:n,to:r}=BI(i,t);return[{from:n,to:r,severity:"error",message:i.replace(/^SyntaxError:\s*/,""),source:"json"}]}})});function td(s){return qt.get(s)||null}function y1(s,t){qt.set(s,t)}var qt,jb=B(()=>{"use strict";qt=new Map([["Row","row-ui"],["Column","col-ui"],["List","list-ui"],["ListItem","list-item-ui"],["Grid","grid-ui"],["Stack","stack-ui"],["Block","block-ui"],["Text","text-ui"],["Image","image-ui"],["Icon","icon-ui"],["Divider","divider-ui"],["Badge","badge-ui"],["Avatar","avatar-ui"],["AvatarGroup","avatar-group-ui"],["Progress","progress-ui"],["ProgressRow","progress-row-ui"],["DateRangePicker","date-range-picker-ui"],["DatetimePicker","datetime-picker-ui"],["CalendarGrid","calendar-grid-ui"],["CalendarPicker","calendar-picker-ui"],["Combobox","combobox-ui"],["Skeleton","skeleton-ui"],["Stepper","stepper-ui"],["StepperItem","stepper-item-ui"],["Tour","tour-ui"],["TourStep","tour-step-ui"],["IntegrationCard","integration-card-ui"],["Code","code-ui"],["Stat","stat-ui"],["EmptyState","empty-state-ui"],["Input","input-ui"],["TextField","input-ui"],["TextArea","textarea-ui"],["Field","field-ui"],["CheckBox","check-ui"],["Toggle","switch-ui"],["Switch","switch-ui"],["Slider","slider-ui"],["Range","range-ui"],["Rating","rating-ui"],["ChoicePicker","select-ui"],["Select","select-ui"],["Radio","radio-ui"],["DateTimeInput","calendar-picker-ui"],["CalendarPicker","calendar-picker-ui"],["ColorPicker","color-picker-ui"],["Upload","upload-ui"],["OtpInput","otp-input-ui"],["Button","button-ui"],["LoadingIndicator","progress-ui"],["ErrorContainer","card-ui"],["Card","card-ui"],["Tabs","tabs-ui"],["Tab","tab-ui"],["Panel","pane-ui"],["Pane","pane-ui"],["Modal","modal-ui"],["Dialog","modal-ui"],["Drawer","drawer-ui"],["Toast","toast-ui"],["Popover","popover-ui"],["Accordion","accordion-ui"],["AccordionItem","accordion-item-ui"],["Alert","alert-ui"],["Tooltip","tooltip-ui"],["Menu","menu-ui"],["Section","section"],["Header","header"],["Footer","footer"],["Stream","stream-ui"],["Table","table-ui"],["ColDef","col-def"],["Chart","chart-ui"],["Embed","embed-ui"],["Swiper","swiper-ui"],["Slideshow","swiper-ui"],["Carousel","swiper-ui"],["Breadcrumb","breadcrumb-ui"],["Link","link-ui"],["Anchor","link-ui"],["Hyperlink","link-ui"],["NavLink","link-ui"],["Nav","nav-ui"],["NavGroup","nav-group-ui"],["NavItem","nav-item-ui"],["Noodles","noodles-ui"],["Pagination","pagination-ui"],["SegmentedControl","segmented-ui"],["Segment","segment-ui"],["ToggleGroup","toggle-group-ui"],["Command","command-ui"],["Kbd","kbd-ui"],["Toolbar","toolbar-ui"],["Tag","tag-ui"],["Timeline","timeline-ui"],["TimelineItem","timeline-item-ui"],["button-ui","button-ui"],["card-ui","card-ui"],["text-ui","text-ui"],["input-ui","input-ui"],["text-field-ui","input-ui"],["select-ui","select-ui"],["toggle-ui","switch-ui"],["check-ui","check-ui"],["slider-ui","slider-ui"],["badge-ui","badge-ui"],["avatar-ui","avatar-ui"],["icon-ui","icon-ui"],["image-ui","image-ui"],["divider-ui","divider-ui"],["progress-ui","progress-ui"],["skeleton-ui","skeleton-ui"],["tabs-ui","tabs-ui"],["tab-ui","tab-ui"],["modal-ui","modal-ui"],["dialog-ui","modal-ui"],["drawer-ui","drawer-ui"],["toast-ui","toast-ui"],["popover-ui","popover-ui"],["panel-ui","pane-ui"],["accordion-ui","accordion-ui"],["alert-ui","alert-ui"],["tooltip-ui","tooltip-ui"],["menu-ui","menu-ui"],["table-ui","table-ui"],["chart-ui","chart-ui"],["code-ui","code-ui"],["textarea-ui","textarea-ui"],["radio-ui","radio-ui"],["tag-ui","tag-ui"],["search-ui","search-ui"],["upload-ui","upload-ui"],["breadcrumb-ui","breadcrumb-ui"],["link-ui","link-ui"],["nav-ui","nav-ui"],["noodles-ui","noodles-ui"],["pagination-ui","pagination-ui"],["segmented-control-ui","segmented-ui"],["segment-ui","segment-ui"],["command-ui","command-ui"],["calendar-picker-ui","calendar-picker-ui"],["color-picker-ui","color-picker-ui"],["kbd-ui","kbd-ui"],["toolbar-ui","toolbar-ui"],["otp-input-ui","otp-input-ui"],["embed-ui","embed-ui"],["stream-ui","stream-ui"],["row-ui","row-ui"],["col-ui","col-ui"],["grid-ui","grid-ui"],["stack-ui","stack-ui"],["block-ui","block-ui"],["list-ui","list-ui"],["range-ui","range-ui"],["datetime-ui","calendar-picker-ui"],["timeline-ui","timeline-ui"],["timeline-item-ui","timeline-item-ui"],["avatar-group-ui","avatar-group-ui"],["Keyboard","kbd-ui"],["DatePicker","calendar-picker-ui"],["CommandPalette","command-ui"],["FormContainer","form"],["Sidebar","admin-sidebar"],["Segmented","segmented-ui"],["OTP","otp-input-ui"],["Textarea","textarea-ui"],["RichText","richtext-ui"],["Richtext","richtext-ui"],["DescriptionList","description-list-ui"],["ActionItem","action-item-ui"],["ActionList","action-list-ui"],["Inspector","inspector-ui"],["Heatmap","heatmap-ui"],["ChatThread","chat-thread"],["ChatInput","chat-input-ui"],["OptionCard","option-card-ui"],["Option","option-card-ui"],["AdminCommand","admin-command"],["AdminContent","admin-content"],["AdminPage","admin-page"],["AdminPageBody","admin-page-body"],["AdminPageHeader","admin-page-header"],["AdminScroll","admin-scroll"],["AdminShell","admin-shell"],["AdminSidebar","admin-sidebar"],["AdminStatusbar","admin-statusbar"],["AdminTopbar","admin-topbar"],["ChatComposer","chat-composer"],["ChatEmpty","chat-empty"],["ChatHeader","chat-header"],["ChatShell","chat-shell"],["ChatSidebar","chat-sidebar"],["ChatStatus","chat-status"],["EditorCanvas","editor-canvas"],["EditorCanvasEmpty","editor-canvas-empty"],["EditorShell","editor-shell"],["EditorSidebar","editor-sidebar"],["EditorStatusbar","editor-statusbar"],["EditorToolbar","editor-toolbar"],["GenRoot","gen-root"],["SimpleContent","simple-content"],["SimpleHero","simple-hero"],["SimpleShell","simple-shell"],["ThemePanel","theme-panel"]])});function v1(s,t){if(!t||t==="/")return s;let e=t.replace(/^\//,"").split("/"),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function bD(s,t,e){if(!t||t==="/")return;let i=t.replace(/^\//,"").split("/"),n=s;for(let r=0;r<i.length-1;r++){let o=i[r];n[o]==null&&(n[o]={}),n=n[o]}n[i[i.length-1]]=e}var ed,Ko,Vb=B(()=>{"use strict";ed={provider:0,controller:1,source:2,action:3,lifecycle:4},Ko=class{surfaceId;#t=new Map;#e={};#i={};#s=new Map;#n;#r;constructor(t,e,i){this.surfaceId=t,this.#n=e,this.#r=i}get context(){return{surfaceId:this.surfaceId,getElement:t=>this.#r.get(t)||null,getRootElement:()=>this.#n,getModel:t=>t?v1(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,n)=>(ed[i.kind]??9)-(ed[n.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)=>(ed[i[1].dockable.kind]??9)-(ed[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.#r=t}#a(t,e){bD(this.#e,t,e);for(let[i,n]of this.#s)if(t===i||t.startsWith(i+"/"))for(let r of n)r(v1(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.#r.get(t.target):this.#n;e&&e.dispatchEvent(new CustomEvent(t.event,{bubbles:!0,detail:t}))}}});var ge,Ys=B(()=>{"use strict";ge=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 Jo,Wb=B(()=>{"use strict";Ys();Jo=class extends ge{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 n=[];if(this.bind)for(let[r,o]of Object.entries(this.bind)){if(this.controller.subscribe){let l=this.controller.subscribe(r,h=>{t.setModel(o,h)});l&&n.push(l)}let a=t.getModel(o);a!==void 0&&this.controller.setState&&this.controller.setState(r,a)}return e.controller=this.controller,()=>{e.controller=null,n.forEach(r=>r())}}undock(){this.controller&&(this.controller.disconnect?.(),this.controller=null)}}});var ta,Ub=B(()=>{"use strict";Ys();ta=class extends ge{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=n=>{try{t.setModel(this.path,JSON.parse(n.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 id,ea,Fb=B(()=>{"use strict";Ys();id={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"},ea=class extends ge{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=id[this.event.event]||this.event.event,n=this.#t(this.handler);if(!n){console.warn(`ActionDock: unknown handler "${this.handler}"`);return}let r=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 n(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=r,a;r=(...l)=>{clearTimeout(a),a=setTimeout(()=>o(...l),this.event.debounce)}}if(this.event.throttle>0){let o=r,a=0;r=(...l)=>{let h=Date.now();h-a>=this.event.throttle&&(a=h,o(...l))}}return e.addEventListener(i,r),()=>e.removeEventListener(i,r)}undock(){}}});var ia,Yb=B(()=>{"use strict";Ys();ia=class extends ge{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 sa,Hb=B(()=>{"use strict";Ys();sa=class extends ge{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 n=()=>this.#i(i,t);if(i.debounce>0){let r=n,o;n=()=>{clearTimeout(o),o=setTimeout(r,i.debounce)}}return t.watchModel(i.path,n)});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(n){console.warn(`LifecycleDock: ${t.handler} failed`,n)}}}});var x1,be,Hs=B(()=>{"use strict";x1=new WeakSet,be=class s{#t=null;#e=new Set;get host(){return this.#t}connect(t){let e=this.constructor;!x1.has(e)&&e!==s&&(x1.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 S1={};Ft(S1,{FormController:()=>Gb});var Gb,w1=B(()=>{"use strict";Hs();Gb=class extends be{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")}#n(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.#n(t),this.notify()},validate:(t,e)=>{this.#s[t]=e,this.#n(t),this.notify()},reset:()=>{this.#e={...this.#t},this.#i={};for(let t of Object.keys(this.#s))this.#n(t);this.notify()},setInitial:t=>{this.#t={...t}}}}});var k1={};Ft(k1,{DataStreamController:()=>Kb});var Kb,A1=B(()=>{"use strict";Hs();Kb=class extends be{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;#n=null;#r=0;#a=1;#o=null;#l=0;constructor({max:t=100,throttle:e=0,sample:i=1,initial:n=[]}={}){super(),this.#e=t,this.#r=e,this.#a=Math.max(1,Math.round(i)),this.#t=n.slice(-t)}getState(){return{data:this.#t,status:this.#i,error:this.#s}}reflect(){this.host&&this.host.setAttribute("data-stream-status",this.#i)}onDisconnect(){this.commands.stop()}#c(t){this.#l++,!(this.#a>1&&this.#l%this.#a!==0)&&(this.#t.push(t),this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u())}#h(t){if(this.#a>1){let e=[];for(let i of t)this.#l++,this.#l%this.#a===0&&e.push(i);this.#t.push(...e)}else this.#t.push(...t);this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e)),this.#u()}#u(){if(this.#r<=0){this.notify();return}this.#o===null&&(this.#o=setTimeout(()=>{this.#o=null,this.notify()},this.#r))}#d(t,e=null){this.#i=t,this.#s=e,this.notify()}commands={push:t=>{this.#c(t)},pushMany:t=>{this.#h(t)},connect:(t,e)=>{this.commands.stop(),this.#n=new AbortController,t==="sse"?this.#p(e):t==="ws"?this.#f(e):this.#d("error",`Unknown stream type: ${t}`)},poll:(t,e=2e3)=>{this.commands.stop(),this.#n=new AbortController,this.#m(t,e)},consume:t=>{this.commands.stop(),this.#n=new AbortController,this.#O(t)},stop:()=>{this.#n&&(this.#n.abort(),this.#n=null),this.#o!==null&&(clearTimeout(this.#o),this.#o=null),(this.#i==="streaming"||this.#i==="connecting")&&this.#d("stopped")},clear:()=>{this.#t=[],this.notify()}};#p(t){this.#d("connecting");let e=new EventSource(t),i=this.#n.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#d("streaming"),e.onmessage=n=>{try{let r=JSON.parse(n.data);this.#c(r)}catch{}},e.onerror=()=>{i.aborted||(this.#d("error","SSE connection lost"),e.close())}}#f(t){this.#d("connecting");let e=new WebSocket(t),i=this.#n.signal;i.addEventListener("abort",()=>e.close()),e.onopen=()=>this.#d("streaming"),e.onmessage=n=>{try{let r=JSON.parse(n.data);Array.isArray(r)?this.#h(r):this.#c(r)}catch{}},e.onerror=()=>{i.aborted||this.#d("error","WebSocket error")},e.onclose=()=>{i.aborted||this.#d("stopped")}}async#m(t,e){this.#d("streaming");let i=this.#n.signal;for(;!i.aborted;){try{let r=await(await fetch(t,{signal:i})).json();Array.isArray(r)?this.#h(r):this.#c(r)}catch(n){if(i.aborted)break;this.#d("error",n.message);break}await new Promise(n=>setTimeout(n,e))}}async#O(t){this.#d("streaming");let e=this.#n.signal;try{for await(let i of t){if(e.aborted)break;Array.isArray(i)?this.#h(i):this.#c(i)}e.aborted||this.#d("idle")}catch(i){e.aborted||this.#d("error",i.message)}}}});var E1={};Ft(E1,{SelectionController:()=>Jb});var Jb,C1=B(()=>{"use strict";Hs();Jb=class extends be{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 $1={};Ft($1,{ToggleController:()=>tO});var tO,P1=B(()=>{"use strict";Hs();tO=class extends be{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 Q1={};Ft(Q1,{AccordionController:()=>eO});var eO,T1=B(()=>{"use strict";Hs();eO=class extends be{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 L1={};Ft(L1,{StateMachineController:()=>iO});var iO,M1=B(()=>{"use strict";Hs();iO=class extends be{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 n of i){let r=t[n]||{},o={};for(let[a,l]of Object.entries(r.on||{})){if(typeof l!="string"||!(l in t)){console.warn(`[state-machine] state "${n}" transition "${a}" \u2192 "${l}" \u2014 target not declared`);continue}o[a]=l}e[n]={on:o}}return e}}});function R1(s,t){Di.controllers.set(s,t)}function I1(s,t){Di.handlers.set(s,t)}function D1(s,t){Di.resolvers.set(s,t)}async function sd(s){let t=Di.controllers.get(s);return t?t():null}function nd(s){return Di.handlers.get(s)||null}async function Zl(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 n=e.slice(0,i),r=Di.resolvers.get(n);if(!r)throw new Error(`No resolver for scheme "${n}"`);return r(e,t)}async function OD(s){let{action:t,params:e}=s,i=sO(t.body,s),n=t.uri;for(let[c,u]of Object.entries(e))n=n.replace(`{${c}}`,encodeURIComponent(u));let r=n.indexOf("://"),o=r>-1?n.slice(0,r):"api",a=Di.resolvers.get(o),l=n.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 yD(s){let{action:t}=s,e=sO(t.value,s);s.updateModel(t.path,e)}async function vD(s){let{action:t,params:e}=s,i=t.navigate||t.path||"";for(let[n,r]of Object.entries(e))i=i.replace(`{${n}}`,encodeURIComponent(r));i==="back"?history.back():i&&(location.hash=i)}async function xD(){history.back()}async function SD(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 wD(s){let{action:t,source:e}=s,i=sO(t.detail,s);e.dispatchEvent(new CustomEvent(t.eventName||t.event,{bubbles:!0,detail:i}))}async function kD(s){let t=s.action.sourceId;return document.dispatchEvent(new CustomEvent("a2ui-refresh-source",{detail:{sourceId:t}})),{refreshSource:t}}async function AD(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 sO(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 ED(t.dataModel,s.path);case"literal":return s.value;case"param":return t.params?.[s.key];default:return s}}}function ED(s,t){if(!t||!s)return;let e=t.split("/").filter(Boolean),i=s;for(let n of e){if(i==null||typeof i!="object")return;i=i[n]}return i}async function CD(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 $D(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 PD(s,t){return{_source:s,_mock:!0}}var Di,nO=B(()=>{"use strict";Di={controllers:new Map([["FormController",async()=>(await Promise.resolve().then(()=>(w1(),S1))).FormController],["DataStreamController",async()=>(await Promise.resolve().then(()=>(A1(),k1))).DataStreamController],["SelectionController",async()=>(await Promise.resolve().then(()=>(C1(),E1))).SelectionController],["ToggleController",async()=>(await Promise.resolve().then(()=>(P1(),$1))).ToggleController],["AccordionController",async()=>(await Promise.resolve().then(()=>(T1(),Q1))).AccordionController],["StateMachineController",async()=>(await Promise.resolve().then(()=>(M1(),L1))).StateMachineController]]),handlers:new Map([["submit-resource",OD],["update-model",yD],["navigate",vD],["navigate-back",xD],["controller-command",SD],["emit-event",wD],["refresh-source",kD],["notify",AD]]),resolvers:new Map([["resource",CD],["api",$D],["mock",PD]])}});function QD(s){return async(t,e,i)=>{let n={action:t,event:i instanceof Event?i:null,source:i instanceof Event?i.target:null,dataModel:e.getModel(),updateModel:(r,o)=>e.setModel(r,o),controllers:Object.fromEntries(e.listDockables("controller").map(r=>[r.id,r.controller])),params:{},resolveData:Zl};return s(n)}}function TD(){let s=new Map;return t=>{if(s.has(t))return s.get(t);let e=nd(t);if(!e)return null;let i=QD(e);return s.set(t,i),i}}function LD(){return async s=>sd(s)}function MD(){return async(s,t)=>Zl(s,{})}function rd(s){let t=[],e=TD(),i=LD(),n=MD();if(s.data?.sources)for(let o of s.data.sources)t.push(new ta(o,n));if(s.state?.controllers)for(let o of s.state.controllers)t.push(new Jo(o,i));if(s.actions)for(let o of s.actions)t.push(new ea(o,e));if(s.provides){let o=Array.isArray(s.provides)?s.provides:[s.provides];for(let a of o)t.push(new ia(a))}s.lifecycle&&t.push(new sa(s.lifecycle,e));let r=s.state?.model||null;return{dockables:t,initialModel:r}}var rO=B(()=>{"use strict";Wb();Ub();Fb();Yb();Hb();nO()});var q1={};Ft(q1,{WiringEngine:()=>Bl});var Bl,oO=B(()=>{"use strict";Vb();rO();Bl=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.#n(t.data.params));let{dockables:n,initialModel:r}=rd(t);r&&i.setInitialModel(r),t.undock&&i.undockMany(t.undock);for(let o of n)await i.dock(o)}catch(n){console.warn(`Wiring: error processing wireComponents for "${e}":`,n.message)}}teardown(t){let e=this.#t.get(t);e&&(e.undockAll(),this.#t.delete(t))}teardownAll(){for(let t of this.#t.keys())this.teardown(t)}getSurface(t){return this.#t.get(t)||null}getSurfaceState(t){let e=this.#t.get(t);if(!e)return null;let i=e.context.listDockables();return{surfaceId:t,controllerCount:i.filter(n=>n.kind==="controller").length,sourceCount:i.filter(n=>n.kind==="source").length,actionCount:i.filter(n=>n.kind==="action").length,providerCount:i.filter(n=>n.kind==="provider").length,hasLifecycle:i.some(n=>n.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"),n=new Proxy(new Map,{get(h,c){return c==="get"?u=>e.get(u):c==="has"?u=>e.has(u):h[c]}}),r=new Ko(t,i,n),o=r.context,a=o.setModel,l=this.#e;return Object.defineProperty(r,"context",{get(){return{...o,setModel(c,u){a(c,u),l(t,c,u)}}}}),r}#n(t){let e={};for(let[i,n]of Object.entries(t))switch(n.from){case"route":{let o=location.hash.slice(1).match(new RegExp(`${n.key}/([^/]+)`));o&&(e[i]=o[1]);break}case"query":{let o=new URL(location.href).searchParams.get(n.key);o&&(e[i]=o);break}case"literal":e[i]=n.value;break;default:typeof n=="string"&&(e[i]=n)}return e}}});var is,X1=B(()=>{"use strict";jb();is=class s{#t;#e;#i=new Map;#s=new Map;#n=new Map;#r=[];#a=null;#o=!1;constructor(t,e=qt,{batch:i=!1}={}){this.#t=t,this.#e=e,this.#o=i}process(t){t&&(this.#o?(this.#r.push(t),this.#a===null&&(this.#a=requestAnimationFrame(()=>this.#l()))):this.#c(t))}#l(){this.#a=null;let t=this.#r.splice(0);for(let e of t)this.#c(e)}#c(t){switch(t.type||t.messageType){case"createSurface":this.#d(t);break;case"updateComponents":this.#p(t);break;case"updateDataModel":this.#$(t);break;case"wireComponents":this.#u(t);break;case"deleteSurface":this.#L(t);break;case"updateStyles":this.#q(t);break;case"removeStyles":this.#T(t);break;case"meta":break;default:console.warn("A2UI: unknown message type",t.type)}}#h=null;async#u(t){if(!this.#h){let{WiringEngine:e}=await Promise.resolve().then(()=>(oO(),q1));this.#h=new e({updateDataModel:(i,n,r)=>{this.#$({surfaceId:i,path:n,value:r})},getElement:(i,n)=>this.#i.get(i)?.elements.get(n)||null})}await this.#h.process(t)}async processStream(t){for await(let e of t)this.process(e)}#d({surfaceId:t,catalogId:e,root:i}){if(this.#i.has(t))return;let n=document.createElement("div");n.setAttribute("data-a2ui-surface",t),e&&n.setAttribute("data-catalog",e),this.#t.appendChild(n),this.#i.set(t,{root:n,rootId:typeof i=="string"&&i?i:"root",elements:new Map,dataModel:{},bindings:new Map,adoptedSheets:new Map})}#p({surfaceId:t,components:e}){let i=this.#i.get(t);i||(i={root:this.#t,rootId:"root",elements:new Map,dataModel:{},bindings:new Map,adoptedSheets:new Map},this.#i.set(t,i),this.#t&&typeof this.#t.setAttribute=="function"&&this.#t.setAttribute("data-a2ui-surface",t));for(let l of e)if(!(!l.id&&l.id!==0)){if(l.component==="ContextBindings"){i.contextBindings=l;continue}try{let h=i.elements.get(l.id),c=l.component==="Text"?this.#S(l.variant,l):td(l.component,this.#e);if(!c){h||(h=document.createElement("div"),h.setAttribute("data-a2ui-id",l.id),h.setAttribute("data-a2ui-unknown",l.component),h.textContent=`[unknown: ${l.component}]`,i.elements.set(l.id,h),this.#s.set(l.id,h));continue}if(!h)h=document.createElement(c),h.setAttribute("data-a2ui-id",l.id),i.elements.set(l.id,h),this.#s.set(l.id,h);else if(h.localName!==c){let d=document.createElement(c);d.setAttribute("data-a2ui-id",l.id),h.replaceWith(d),h=d,i.elements.set(l.id,h),this.#s.set(l.id,h)}l._surfaceId=t,Object.values(l).some(d=>d&&typeof d=="object"&&d.path)&&i.bindings.set(l.id,l),this.#x(h,l)}catch(h){console.warn(`A2UI: component "${l.id}" (${l.component}) failed:`,h.message)}}this.#b(e);let n=new Map;for(let l of e){for(let h of Array.isArray(l.children)?l.children:[])n.set(h,l.id);l.child&&n.set(l.child,l.id)}let r=(l,h)=>{let c=new Set,u=l;for(;u!=null;){if(u===h||c.has(u))return!0;c.add(u),u=n.get(u)}return!1};for(let l of e){let h=i.elements.get(l.id);if(h)try{let c=Array.isArray(l.children)?l.children:[];for(let u of c){if(u===l.id||r(l.id,u))continue;let d=i.elements.get(u);d&&d.parentElement!==h&&h.appendChild(d)}if(l.child&&l.child!==l.id&&!r(l.id,l.child)){let u=i.elements.get(l.child);u&&u.parentElement!==h&&h.appendChild(u)}}catch(c){console.warn(`A2UI: tree build failed for "${l.id}":`,c.message)}}let o=i.rootId??"root";if(e.find(l=>l.id===o)){let l=i.elements.get(o);l&&l.parentElement!==i.root&&i.root.appendChild(l)}}static#f=new Set(["Header","Section","Footer","Img","Image","Video","Picture","Iframe","Aside","Divider"]);static#m=new Set(["Header","Section","Footer"]);static#O=new Set(["header","body","footer"]);#g=new Set;#b(t){let e=new Map;for(let i of t)i.id!=null&&e.set(i.id,i);for(let i of t){let n=i.component==="Card"||i.component==="ErrorContainer",r=i.component==="Drawer";if(!n&&!r)continue;let o=r?s.#m:s.#f,a=r?"<drawer-ui>":"<card-ui>",l=Array.isArray(i.children)?i.children:[];for(let h of l){let c=e.get(h);if(!c||typeof c.slot=="string"&&s.#O.has(c.slot)||o.has(c.component))continue;let u=`${i.id}::${h}::${c.component}`;this.#g.has(u)||(this.#g.add(u),console.warn(`A2UI: ${a} (id="${i.id}") body must wrap "${c.component}" (id="${h}") in <Section>. Direct flow children bypass the canonical body slot and lose --card-inset margin. Canonical children: ${[...o].join(", ")}`+(r?', or slot="header|body|footer".':".")))}}}static#y=new Set(["data","columns","options","itemRenderer","textContent"]);static#w=new Set(["h1","h2","h3","h4","h5","h6","p","small","span","em","strong","code","text-ui"]);static#v={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",body:"p",caption:"small"};static#k=new Set(["autocomplete","autofocus","autocapitalize","autocorrect","inputmode","enterkeyhint","spellcheck","maxlength","minlength","readonly","novalidate","formnovalidate","formaction","formenctype","formmethod","formtarget","multiple","pattern","placeholder","required","tabindex","accesskey","autoplay","autopictureinpicture","controls","crossorigin","disablepictureinpicture","disableremoteplayback","loop","muted","playsinline","preload","srcset","srcdoc","srclang","sizes","loading","decoding","fetchpriority","ismap","usemap","hreflang","referrerpolicy","download","contenteditable","contextmenu","draggable","dirname","colspan","rowspan","headers","allowfullscreen","allowpaymentrequest","itemid","itemprop","itemref","itemscope","itemtype","nomodule","nonce"]);#S(t,e){return!e?.slot&&s.#v[t]?s.#v[t]:"text-ui"}#x(t,e){let i=new Set(["id","component","children","child","_surfaceId"]);e.component==="Text"&&e.variant&&!e.slot&&s.#v[e.variant]&&i.add("variant");let n=this.#n.get(e.id),r={};for(let[o,a]of Object.entries(e)){if(i.has(o))continue;let l=a&&typeof a=="object"&&a.path,h=this.#E(a,e._surfaceId);if(r[o]=h,!(n&&Object.is(n[o],h))){if(o==="style"&&typeof h=="string"){t.style.cssText=h;continue}if(s.#y.has(o)&&h!=null){if(o==="textContent"&&!s.#w.has(t.localName)){t.setAttribute("text",String(h));continue}let c=h;if(typeof c=="string"&&(c.startsWith("[")||c.startsWith("{")))try{c=JSON.parse(c)}catch{}t[o]=c;continue}typeof h=="boolean"?h?t.setAttribute(o,""):t.removeAttribute(o):h!=null?t.setAttribute(this.#A(o),String(h)):l&&t.removeAttribute(this.#A(o))}}if(n)for(let o of Object.keys(n))!(o in r)&&!i.has(o)&&t.removeAttribute(this.#A(o));this.#n.set(e.id,r)}#A(t){return s.#k.has(t.toLowerCase())?t.toLowerCase():t.replace(/([A-Z])/g,"-$1").toLowerCase()}#E(t,e){if(t==null)return null;if(typeof t!="object")return t;if(t.path){let i=e?this.#i.get(e):null;return i?this.#C(i.dataModel,t.path):t.path}return t}#C(t,e){return!e||e==="/"?t:e.split("/").filter(Boolean).reduce((i,n)=>i?.[n],t)}#$({surfaceId:t,path:e,value:i}){let n=this.#i.get(t);if(n){if(!e||e==="/")n.dataModel=i??{};else{let r=e.split("/").filter(Boolean),o=n.dataModel;for(let a=0;a<r.length-1;a++)o[r[a]]==null&&(o[r[a]]={}),o=o[r[a]];o[r[r.length-1]]=i}for(let[r,o]of n.bindings){let a=n.elements.get(r);a&&this.#x(a,o)}}}#L({surfaceId:t}){let e=this.#i.get(t);if(e){this.#h?.teardown(t);for(let[i]of e.elements)this.#s.delete(i);if(e.adoptedSheets&&e.adoptedSheets.size>0){let i=new Set;for(let n of e.adoptedSheets.values())i.add(n.sheet);document.adoptedStyleSheets=document.adoptedStyleSheets.filter(n=>!i.has(n)),e.adoptedSheets.clear()}e.root.remove(),this.#i.delete(t)}}static#P=new Set(["root","html","body"]);#q({surfaceId:t,styleId:e,css:i}){if(typeof e!="string"||e.length===0){this.#R(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: styleId must be a non-empty string"});return}if(typeof i!="string"){this.#R(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"invalid-payload: css must be a string"});return}let n=this.#i.get(t);if(!n){this.#R(null,"styles-rejected",{surfaceId:t,styleId:e,reason:"no-such-surface"});return}let r=this.#N(i,t);if(r.rejected){this.#R(n.root,"styles-rejected",{surfaceId:t,styleId:e,reason:r.reason});return}let o=n.adoptedSheets.get(e);o&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(a=>a!==o.sheet)),document.adoptedStyleSheets=[...document.adoptedStyleSheets,r.sheet],n.adoptedSheets.set(e,{sheet:r.sheet,ruleCount:r.sheet.cssRules.length,appliedAt:typeof performance<"u"?performance.now():Date.now()}),this.#R(n.root,"styles-applied",{surfaceId:t,styleId:e,ruleCount:r.sheet.cssRules.length,validationWarnings:r.warnings})}#T({surfaceId:t,styleId:e}){let i=this.#i.get(t);if(!i)return;let n=i.adoptedSheets.get(e);n&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(r=>r!==n.sheet),i.adoptedSheets.delete(e),this.#R(i.root,"styles-removed",{surfaceId:t,styleId:e}))}#N(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 n=new CSSStyleSheet;try{n.replaceSync(t)}catch(l){return{rejected:!0,reason:"parse-error: "+(l?.message||String(l))}}for(let l of n.cssRules){let h=this.#M(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 n.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 r=this.#D(n,e),o=this.#I(n,e),a=new CSSStyleSheet;try{a.replaceSync(o)}catch(l){return{rejected:!0,reason:"scope-wrap-failed: "+(l?.message||String(l))}}return r.length>0&&i.push({kind:"animations-namespaced",count:r.length}),{rejected:!1,sheet:a,warnings:i}}#M(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.#Q(t.selectorText);for(let n of i){let r=n.trim().replace(/^:scope\s*/,"");if(r.startsWith(":root"))return"forbidden-root-selector";let o=r.match(/^([a-zA-Z*][\w-]*)/);if(!o)continue;let a=o[1].toLowerCase();if(s.#P.has(a))return`forbidden-${a}-selector`}}return null}#Q(t){let e=[],i=0,n=0;for(let r=0;r<t.length;r++){let o=t[r];o==="("?i++:o===")"?i--:o===","&&i===0&&(e.push(t.slice(n,r)),n=r+1)}return e.push(t.slice(n)),e}#D(t,e){let i=[],n=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=`${n}_${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 r=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=>r.has(c)?r.get(c):c);h!==l&&o.style.setProperty(a,h)}return i}#I(t,e){let i=[];for(let r of t.cssRules)i.push(r.cssText);return`@scope ([data-a2ui-surface="${String(e).replace(/"/g,'\\"')}"]) {
|
|
42
42
|
${i.join(`
|
|
43
43
|
`)}
|
|
44
|
-
}`}#
|
|
44
|
+
}`}#R(t,e,i){let n=t||this.#t;if(!(!n||typeof CustomEvent>"u"))try{n.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.#r.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.#n.clear()}set batching(t){this.#o=!!t}get batching(){return this.#o}}});function od(s,t={}){let e=s;if(t.catalog){let i=t.catalog instanceof Map?[...t.catalog.keys()]:Object.keys(t.catalog),n=s.includes("?")?"&":"?";e=`${s}${n}a2ui_catalog=${encodeURIComponent(i.join(","))}`}return{[Symbol.asyncIterator](){let i=new EventSource(e),n=[],r=null,o=!1;return i.onmessage=a=>{try{let l=JSON.parse(a.data);if(r){let h=r;r=null,h({value:l,done:!1})}else n.push(l)}catch{console.warn("A2UI SSE: invalid JSON",a.data)}},i.onerror=()=>{if(o=!0,i.close(),r){let a=r;r=null,a({value:void 0,done:!0})}},t.signal&&t.signal.addEventListener("abort",()=>{if(o=!0,i.close(),r){let a=r;r=null,a({value:void 0,done:!0})}}),{next(){return n.length>0?Promise.resolve({value:n.shift(),done:!1}):o?Promise.resolve({value:void 0,done:!0}):new Promise(a=>{r=a})},return(){return o=!0,i.close(),Promise.resolve({value:void 0,done:!0})}}}}}function ad(s,t={}){return{[Symbol.asyncIterator](){let e=new WebSocket(s),i=[],n=null,r=!1;return e.onopen=()=>{if(t.catalog){let o=t.catalog instanceof Map?[...t.catalog.keys()]:Object.keys(t.catalog);e.send(JSON.stringify({type:"a2ui:catalog",supportedTypes:o}))}},e.onmessage=o=>{try{let a=JSON.parse(o.data);if(n){let l=n;n=null,l({value:a,done:!1})}else i.push(a)}catch{console.warn("A2UI WS: invalid JSON",o.data)}},e.onclose=()=>{if(r=!0,n){let o=n;n=null,o({value:void 0,done:!0})}},e.onerror=()=>{r=!0,e.close()},{next(){return i.length>0?Promise.resolve({value:i.shift(),done:!1}):r?Promise.resolve({value:void 0,done:!0}):new Promise(o=>{n=o})},return(){return r=!0,e.close(),Promise.resolve({value:void 0,done:!0})}}}}}function B1(s,t=0){return{async*[Symbol.asyncIterator](){for(let e of s)t>0&&await new Promise(i=>setTimeout(i,t)),yield e}}}function ld(s,t={}){let e=(s.split(":")[0]||"").toLowerCase();return e==="ws"||e==="wss"?RD(s,t):Z1(s,t)}function N1(s,t){if(s.result?.content){for(let e of s.result.content)if(e.type==="resource"&&e.resource?.mimeType==="application/json+a2ui")try{let i=JSON.parse(e.resource.text);for(let n of Array.isArray(i)?i:[i])t(n)}catch{}else if(e.type==="text")try{let i=JSON.parse(e.text);i.type&&(i.type.startsWith("create")||i.type.startsWith("update")||i.type.startsWith("delete"))&&t(i)}catch{}}}function RD(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:n}=t,r=new WebSocket(s);if(await new Promise((c,u)=>{r.onopen=c,r.onerror=u,e&&e.addEventListener("abort",()=>{r.close(),u(new DOMException("Aborted","AbortError"))},{once:!0})}),i){let c=i instanceof Map?[...i.keys()]:Object.keys(i);r.send(JSON.stringify({jsonrpc:"2.0",method:"a2ui/catalog",params:{supportedTypes:c}}))}let o=[],a=null,l=!1,h=c=>{if(a){let u=a;a=null,u({value:c,done:!1})}else o.push(c)};for(r.onmessage=c=>{try{let u=JSON.parse(c.data);N1(u,h),u.method==="a2ui/action"&&n&&n(u.params?.name,u.params?.arguments).then(d=>{r.send(JSON.stringify({jsonrpc:"2.0",id:u.id,result:d}))}).catch(d=>{r.send(JSON.stringify({jsonrpc:"2.0",id:u.id,error:{code:-1,message:d.message}}))})}catch{console.warn("A2UI MCP: invalid message",c.data)}},r.onclose=()=>{if(l=!0,a){let c=a;a=null,c({value:void 0,done:!0})}},r.onerror=()=>{l=!0,r.close()},e&&e.addEventListener("abort",()=>{if(l=!0,r.close(),a){let c=a;a=null,c({value:void 0,done:!0})}});!l||o.length>0;)if(o.length>0)yield o.shift();else{if(l)break;{let c=await new Promise(u=>{a=u});if(c.done)break;yield c.value}}}}}function Z1(s,t){return{async*[Symbol.asyncIterator](){let{signal:e,catalog:i,onAction:n}=t,r=[],o=null,a=!1,l=g=>{if(o){let y=o;o=null,y({value:g,done:!1})}else r.push(g)},h=()=>{if(a=!0,o){let g=o;o=null,g({value:void 0,done:!0})}},c={jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-11-25",capabilities:{},clientInfo:{name:"a2ui-runtime",version:"0.0.0"}}},u;try{u=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream"},body:JSON.stringify(c),signal:e})}catch(g){console.warn("A2UI MCP HTTP: initialize failed",g);return}if(!u.ok){console.warn(`A2UI MCP HTTP: initialize returned ${u.status}`);return}let d=u.headers.get("mcp-session-id");if(!d){console.warn("A2UI MCP HTTP: server did not return mcp-session-id header");try{await u.text()}catch{}return}try{if((u.headers.get("content-type")||"").includes("text/event-stream")){let y=u.body.getReader(),v=new TextDecoder,w="";for(;;){let{done:k,value:E}=await y.read();if(k||(w+=v.decode(E,{stream:!0}),w.includes(`
|
|
45
45
|
|
|
46
46
|
`)))break}try{y.cancel()}catch{}}else await u.json().catch(()=>null)}catch{}try{await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","mcp-session-id":d},body:JSON.stringify({jsonrpc:"2.0",method:"notifications/initialized"}),signal:e}).then(g=>g.text()).catch(()=>null)}catch{}if(i){let g=i instanceof Map?[...i.keys()]:Object.keys(i);try{await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","mcp-session-id":d},body:JSON.stringify({jsonrpc:"2.0",method:"a2ui/catalog",params:{supportedTypes:g}}),signal:e}).then(y=>y.text()).catch(()=>null)}catch{}}let f=g=>fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","mcp-session-id":d},body:JSON.stringify(g),signal:e}).then(y=>y.text()).catch(()=>null),p=g=>{N1(g,l),g.method==="a2ui/action"&&n&&Promise.resolve().then(()=>n(g.params?.name,g.params?.arguments)).then(y=>f({jsonrpc:"2.0",id:g.id,result:y})).catch(y=>f({jsonrpc:"2.0",id:g.id,error:{code:-1,message:y.message}}))},m;try{m=await fetch(s,{method:"GET",headers:{Accept:"text/event-stream","mcp-session-id":d},signal:e})}catch(g){g?.name!=="AbortError"&&console.warn("A2UI MCP HTTP: GET stream failed",g);return}if(!m.ok||!m.body){console.warn(`A2UI MCP HTTP: GET stream returned ${m.status}`);return}e&&e.addEventListener("abort",h,{once:!0});let b=()=>{try{fetch(s,{method:"DELETE",headers:{"mcp-session-id":d}}).catch(()=>null)}catch{}};for((async()=>{let g=m.body.getReader(),y=new TextDecoder,v="";try{for(;!a;){let{done:w,value:k}=await g.read();if(w)break;v+=y.decode(k,{stream:!0});let E;for(;(E=v.indexOf(`
|
|
47
47
|
|
|
@@ -65,7 +65,7 @@ ${i.join(`
|
|
|
65
65
|
aria-label="Undo" \u2190 explicit accessible name
|
|
66
66
|
title="Undo" \u2190 auto-mirrored to aria-label + tooltip
|
|
67
67
|
aria-labelledby="..." \u2190 reference an existing label element
|
|
68
|
-
Without an accessible name screen readers announce nothing meaningful.`)))}}static#t=new WeakSet;static#e=new WeakSet;#i=t=>{if(this.disabled){t.stopPropagation();return}if(this.type==="submit"){let e=this.closest("form");e?.requestSubmit&&e.requestSubmit()}else if(this.type==="reset"){let e=this.closest("form");e?.reset&&e.reset()}this.dispatchEvent(new Event("press",{bubbles:!0}))};#s=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.click())};disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s)}};S("button-ui",rn);P();var on=class extends x{static properties={text:{type:String,default:"",reflect:!0},href:{type:String,default:"",reflect:!0},target:{type:String,default:"",reflect:!0},rel:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},block:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=t=>{if(this.disabled){t.preventDefault();return}let e={href:this.href,target:this.target},i=new CustomEvent("press",{bubbles:!0,cancelable:!0,detail:e});this.dispatchEvent(i)||t.preventDefault()};#e=t=>{this.disabled&&t.key==="Enter"&&t.preventDefault()};#i(){let t=this.querySelector(":scope > a");t||(t=document.createElement("a"),t.dataset.autostamped="true",this.appendChild(t));let e=[];for(let i of this.childNodes)i!==t&&i.parentNode===this&&e.push(i);for(let i of e)t.appendChild(i);return t}connected(){let t=this.#i();this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e),this.disabled&&this.setAttribute("aria-disabled","true")}render(){let t=this.querySelector(":scope > a");if(!t)return;let e=t.dataset.autostamped==="true";if(e&&(this.href?t.setAttribute("href",this.href):t.removeAttribute("href"),this.target?t.setAttribute("target",this.target):t.removeAttribute("target"),this.rel?t.setAttribute("rel",this.rel):this.target==="_blank"?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("rel")),this.disabled?(this.setAttribute("aria-disabled","true"),t.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),t.removeAttribute("tabindex")),e){let i=this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:"",n=this.text?`<span>${this.text}</span>`:"";t.innerHTML=`${i}${n}`}}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};S("link-ui",on);P();var M=class s extends x{static formAssociated=!0;static get properties(){return{name:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},pattern:{type:String,default:"",reflect:!0},minlength:{type:Number,default:null,reflect:!0},maxlength:{type:Number,default:null,reflect:!0},throttle:{type:Number,default:0,reflect:!0}}}#t=!1;#e=null;#i=void 0;get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}syncValue(t){t=t??this.value??"",this.internals.setFormValue(t),this.#s(t)}setValid(){this.internals.setValidity({}),this.removeAttribute("aria-invalid"),this.error&&(this.error="")}setInvalid(t,e){this.internals.setValidity({customError:!0},t||"Invalid",e||this),this.setAttribute("aria-invalid","true"),this.error=t||"Invalid"}validate(){let t=this.#s(this.value??"");return t?(this.removeAttribute("aria-invalid"),this.error&&(this.error="")):(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),t}scheduleThrottledInput(t=null){let e=Number(this.throttle)||0,i=()=>new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}});if(e>0){this.#e!=null&&clearTimeout(this.#e),this.#i=this.value,this.#e=setTimeout(()=>{this.#e=null,this.#i=void 0,this.dispatchEvent(i())},e);return}this.dispatchEvent(i())}flushPendingInput(t=null){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}})))}dropPendingInput(){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0)}#s(t){t=t??this.value??"";let e=String(t);if(this.required&&!e.trim())return this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),!1;if(this.pattern&&e)try{if(!new RegExp(`^(?:${this.pattern})$`).test(e))return this.internals.setValidity({patternMismatch:!0},this.getAttribute("data-msg-pattern")||"Please match the requested format.",this),!1}catch{}return this.minlength!=null&&this.minlength>0&&e.length>0&&e.length<this.minlength?(this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-minlength")||`Please use at least ${this.minlength} characters.`,this),!1):this.maxlength!=null&&this.maxlength>0&&e.length>this.maxlength?(this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-maxlength")||`Please use no more than ${this.maxlength} characters.`,this),!1):(this.internals.setValidity({}),!0)}#n=t=>{t.preventDefault(),this.setAttribute("aria-invalid","true"),this.error=this.validationMessage};#r=()=>{this.#t=!0,this.error&&this.validate()};#a=()=>{this.#t&&this.validate()};connected(){super.connected(),this.syncValue(),this.addEventListener("invalid",this.#n),this.addEventListener("input",this.#r),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.#n),this.removeEventListener("input",this.#r),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 FO=s=>wd(s)?`<icon-ui name="${s}"></icon-ui>`:s,an=class s extends M{static labelDeprecated=!1;static properties={...M.properties,placeholder:{type:String,default:"",reflect:!0},type:{type:String,default:"text",reflect:!0},label:{type:String,default:"",reflect:!0},prefix:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},min:{type:Number,default:null,reflect:!0},max:{type:Number,default:null,reflect:!0},step:{type:Number,default:1,reflect:!0},precision:{type:Number,default:null,reflect:!0},locale:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n="";#r=null;#a=null;#o=".";#l="";#c=null;static#h=0;static#u=400;static#d=60;get#p(){return this.type==="password"}get#f(){return this.type==="number"}get valueAsNumber(){let t=String(this.value??"").trim();if(!t)return NaN;let e=this.#S(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.#x(t)}connected(){super.connected(),this.setAttribute("role",this.#f?"spinbutton":"textbox");let t=Array.from(this.querySelectorAll(':scope > [slot="leading"]')),e=Array.from(this.querySelectorAll(':scope > [slot="trailing"]'));if(!this.querySelector('[slot="text"]')){let i=this.label?`input-label-${++s.#h}`:"";this.innerHTML=this.#m(i),this.#O(t,e)}this.#t=this.querySelector('[slot="text"]'),this.#e=this.querySelector('[slot="label"]'),this.#i=this.querySelector('[data-step="up"]'),this.#s=this.querySelector('[data-step="down"]'),!this.#p&&this.value&&(this.#t.textContent=this.#f?this.#E(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#
|
|
68
|
+
Without an accessible name screen readers announce nothing meaningful.`)))}}static#t=new WeakSet;static#e=new WeakSet;#i=t=>{if(this.disabled){t.stopPropagation();return}if(this.type==="submit"){let e=this.closest("form");e?.requestSubmit&&e.requestSubmit()}else if(this.type==="reset"){let e=this.closest("form");e?.reset&&e.reset()}this.dispatchEvent(new Event("press",{bubbles:!0}))};#s=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.click())};disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s)}};S("button-ui",rn);P();var on=class extends x{static properties={text:{type:String,default:"",reflect:!0},href:{type:String,default:"",reflect:!0},target:{type:String,default:"",reflect:!0},rel:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},block:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=t=>{if(this.disabled){t.preventDefault();return}let e={href:this.href,target:this.target},i=new CustomEvent("press",{bubbles:!0,cancelable:!0,detail:e});this.dispatchEvent(i)||t.preventDefault()};#e=t=>{this.disabled&&t.key==="Enter"&&t.preventDefault()};#i(){let t=this.querySelector(":scope > a");t||(t=document.createElement("a"),t.dataset.autostamped="true",this.appendChild(t));let e=[];for(let i of this.childNodes)i!==t&&i.parentNode===this&&e.push(i);for(let i of e)t.appendChild(i);return t}connected(){let t=this.#i();this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e),this.disabled&&this.setAttribute("aria-disabled","true")}render(){let t=this.querySelector(":scope > a");if(!t)return;let e=t.dataset.autostamped==="true";if(e&&(this.href?t.setAttribute("href",this.href):t.removeAttribute("href"),this.target?t.setAttribute("target",this.target):t.removeAttribute("target"),this.rel?t.setAttribute("rel",this.rel):this.target==="_blank"?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("rel")),this.disabled?(this.setAttribute("aria-disabled","true"),t.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),t.removeAttribute("tabindex")),e){let i=this.icon?`<icon-ui name="${this.icon}"></icon-ui>`:"",n=this.text?`<span>${this.text}</span>`:"";t.innerHTML=`${i}${n}`}}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}};S("link-ui",on);P();var M=class s extends x{static formAssociated=!0;static get properties(){return{name:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},pattern:{type:String,default:"",reflect:!0},minlength:{type:Number,default:null,reflect:!0},maxlength:{type:Number,default:null,reflect:!0},throttle:{type:Number,default:0,reflect:!0}}}#t=!1;#e=null;#i=void 0;get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}syncValue(t){t=t??this.value??"",this.internals.setFormValue(t),this.#s(t)}setValid(){this.internals.setValidity({}),this.removeAttribute("aria-invalid"),this.error&&(this.error="")}setInvalid(t,e){this.internals.setValidity({customError:!0},t||"Invalid",e||this),this.setAttribute("aria-invalid","true"),this.error=t||"Invalid"}validate(){let t=this.#s(this.value??"");return t?(this.removeAttribute("aria-invalid"),this.error&&(this.error="")):(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),t}scheduleThrottledInput(t=null){let e=Number(this.throttle)||0,i=()=>new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}});if(e>0){this.#e!=null&&clearTimeout(this.#e),this.#i=this.value,this.#e=setTimeout(()=>{this.#e=null,this.#i=void 0,this.dispatchEvent(i())},e);return}this.dispatchEvent(i())}flushPendingInput(t=null){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:t||{value:this.value}})))}dropPendingInput(){this.#e!=null&&(clearTimeout(this.#e),this.#e=null,this.#i=void 0)}#s(t){t=t??this.value??"";let e=String(t);if(this.required&&!e.trim())return this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),!1;if(this.pattern&&e)try{if(!new RegExp(`^(?:${this.pattern})$`).test(e))return this.internals.setValidity({patternMismatch:!0},this.getAttribute("data-msg-pattern")||"Please match the requested format.",this),!1}catch{}return this.minlength!=null&&this.minlength>0&&e.length>0&&e.length<this.minlength?(this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-minlength")||`Please use at least ${this.minlength} characters.`,this),!1):this.maxlength!=null&&this.maxlength>0&&e.length>this.maxlength?(this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-maxlength")||`Please use no more than ${this.maxlength} characters.`,this),!1):(this.internals.setValidity({}),!0)}#n=t=>{t.preventDefault(),this.setAttribute("aria-invalid","true"),this.error=this.validationMessage};#r=()=>{this.#t=!0,this.error&&this.validate()};#a=()=>{this.#t&&this.validate()};connected(){super.connected(),this.syncValue(),this.addEventListener("invalid",this.#n),this.addEventListener("input",this.#r),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.#n),this.removeEventListener("input",this.#r),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 FO=s=>wd(s)?`<icon-ui name="${s}"></icon-ui>`:s,an=class s extends M{static labelDeprecated=!1;static properties={...M.properties,placeholder:{type:String,default:"",reflect:!0},type:{type:String,default:"text",reflect:!0},label:{type:String,default:"",reflect:!0},prefix:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},min:{type:Number,default:null,reflect:!0},max:{type:Number,default:null,reflect:!0},step:{type:Number,default:1,reflect:!0},precision:{type:Number,default:null,reflect:!0},locale:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n="";#r=null;#a=null;#o=".";#l="";#c=null;static#h=0;static#u=400;static#d=60;get#p(){return this.type==="password"}get#f(){return this.type==="number"}get valueAsNumber(){let t=String(this.value??"").trim();if(!t)return NaN;let e=this.#S(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.#x(t)}connected(){super.connected(),this.setAttribute("role",this.#f?"spinbutton":"textbox");let t=Array.from(this.querySelectorAll(':scope > [slot="leading"]')),e=Array.from(this.querySelectorAll(':scope > [slot="trailing"]'));if(!this.querySelector('[slot="text"]')){let i=this.label?`input-label-${++s.#h}`:"";this.innerHTML=this.#m(i),this.#O(t,e)}this.#t=this.querySelector('[slot="text"]'),this.#e=this.querySelector('[slot="label"]'),this.#i=this.querySelector('[data-step="up"]'),this.#s=this.querySelector('[data-step="down"]'),!this.#p&&this.value&&(this.#t.textContent=this.#f?this.#E(this.value):this.value),this.#t&&(this.#t.addEventListener("input",this.#L),this.#t.addEventListener("keydown",this.#Q),this.#t.addEventListener("blur",this.#I),this.#t.addEventListener("focus",this.#D),this.#t.addEventListener("paste",this.#Z),this.#f&&this.#t.addEventListener("beforeinput",this.#P)),this.#i?.addEventListener("pointerdown",this.#W),this.#s?.addEventListener("pointerdown",this.#B),(this.prefix||this.suffix)&&TO.then(()=>this.#g())}#m(t){let e=this.prefix?`<span slot="prefix">${FO(this.prefix)}</span>`:"",i=this.label?`<span slot="label" id="${t}">${this.label}</span>`:"",n=this.suffix?`<span slot="suffix">${FO(this.suffix)}</span>`:"",r=t?`aria-labelledby="${t}"`:"";if(this.#p)return`
|
|
69
69
|
<div slot="field">
|
|
70
70
|
${e}${i}
|
|
71
71
|
<input slot="text" type="password" tabindex="0"
|
|
@@ -89,7 +89,7 @@ ${i.join(`
|
|
|
89
89
|
<div slot="field"${this.#f?" data-number":""}>
|
|
90
90
|
${e}${i}${o}${n}${a}
|
|
91
91
|
</div>
|
|
92
|
-
`}#O(t,e){let i=this.querySelector(':scope > [slot="field"]');if(i){if(t.length){let n=i.querySelector(':scope > [slot="label"]')||i.querySelector(':scope > [slot="prefix"]');if(n){let r=n;for(let o of t)r.after(o),r=o}else for(let r of t.slice().reverse())i.prepend(r)}if(e.length){let n=i.querySelector(':scope > [slot="controls"]'),r=i.querySelector(':scope > [slot="suffix"]')||i.querySelector(':scope > [slot="text"]');if(r){let o=r;for(let a of e)o.after(a),o=a}else if(n){let o=n.previousElementSibling||n;for(let a of e)o.after(a),o=a}else for(let o of e)i.appendChild(o)}}}#g(){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")&&wd(e)){i.replaceChildren();let n=document.createElement("icon-ui");n.setAttribute("name",e),i.appendChild(n)}}}render(){if(!this.#t)return;let t=this.value??"";if(this.#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 e=this.#f&&document.activeElement!==this.#t?this.#E(t):String(t);this.#t.textContent!==e&&(this.#t.textContent=e,this.#t.toggleAttribute("data-empty",!e))}if(this.#e&&(this.#e.textContent=this.label||""),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#f){let e=this.valueAsNumber;Number.isFinite(e)?(this.setAttribute("aria-valuenow",String(e)),this.setAttribute("aria-valuetext",`${this.#x(e)}${this.suffix?" "+this.suffix:""}`)):(this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuetext")),this.min!=null?this.setAttribute("aria-valuemin",String(this.min)):this.removeAttribute("aria-valuemin"),this.max!=null?this.setAttribute("aria-valuemax",String(this.max)):this.removeAttribute("aria-valuemax");let i=this.disabled||this.readonly||this.max!=null&&Number.isFinite(e)&&e>=this.max,n=this.disabled||this.readonly||this.min!=null&&Number.isFinite(e)&&e<=this.min;this.#i?.toggleAttribute("disabled",!!i),this.#s?.toggleAttribute("disabled",!!n)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#f&&this.#b(String(t))}validate(){let t=super.validate();if(!this.#f)return t;if(!t)return!1;let e=this.#b(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#b(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#S(e),n=Number(i);return Number.isFinite(n)?this.min!=null&&n<this.min?(this.internals.setValidity({rangeUnderflow:!0},this.getAttribute("data-msg-min")||`Value must be ${this.min} or greater.`,this),!1):this.max!=null&&n>this.max?(this.internals.setValidity({rangeOverflow:!0},this.getAttribute("data-msg-max")||`Value must be ${this.max} or less.`,this),!1):!0:(this.internals.setValidity({badInput:!0},this.getAttribute("data-msg-bad-input")||"Please enter a valid number.",this),!1)}#y(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#w(){return this.locale?this.#c===this.locale?this.#o:(this.#k(),this.#o):"."}#v(){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}#S(t){let e=this.#w(),i=this.#v(),n=String(t);return i&&(n=n.split(i).join("")),e!=="."&&(n=n.replace(new RegExp(`\\${e}`,"g"),".")),n}#x(t){if(!Number.isFinite(t))return"";let e=this.#y();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))}#A(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#x(t);let e=this.#y();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#x(t)}}#E(t){let e=String(t??"");if(!e)return"";let i=Number(this.#S(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#x(i):this.#A(i):e}#C(t){let e=this.step||1,i=this.min!=null?this.min:0,n=Math.round((t-i)/e)*e+i,r=Math.max(this.min!=null?this.min:-1/0,Math.min(this.max!=null?this.max:1/0,n));return parseFloat(r.toFixed(10))}#P(t){if(this.disabled||this.readonly)return;let e=(this.step||1)*t,i=Number.isFinite(this.valueAsNumber)?this.valueAsNumber:this.min!=null?this.min:0,n=this.#C(i+e);n!==this.valueAsNumber&&(this.value=this.#x(n),this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#R=()=>{let t;if(this.#p)t=this.#t.value||"";else if(this.#f){let e=this.#t.textContent||"";t=this.#Q(e),t!==e&&(this.#t.textContent=t,this.#L())}else t=this.#t.textContent||"";this.value=t,this.#p||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#T=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;let n=this.#t.textContent||"",r=window.getSelection(),o=n.length,a=n.length;if(r&&r.rangeCount&&this.#t.contains(r.anchorNode)){let h=r.getRangeAt(0);o=this.#N(h.startContainer,h.startOffset),a=this.#N(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=n.slice(0,o)+i+n.slice(a);this.#q(l)||t.preventDefault()};#q(t){let e=this.#S(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.#w(),i="",n=!1;for(let r=0;r<t.length;r++){let o=t[r];o>="0"&&o<="9"||o==="-"&&i===""&&(this.min==null||this.min<0)?i+=o:o===e&&!n&&(i+=e,n=!0)}return i}#N(t,e){if(!this.#t.contains(t))return 0;let i=0,n=document.createTreeWalker(this.#t,NodeFilter.SHOW_TEXT),r;for(;r=n.nextNode();){if(r===t)return i+e;i+=r.textContent.length}return t===this.#t?e:i}#L(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#$=t=>{if(this.#f){switch(t.key){case"ArrowUp":t.preventDefault(),this.#P(1);return;case"ArrowDown":t.preventDefault(),this.#P(-1);return;case"PageUp":t.preventDefault(),this.#P(10);return;case"PageDown":t.preventDefault(),this.#P(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#_(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#_(this.max));return;case"Escape":t.preventDefault(),this.value=this.#n,this.#t.textContent=this.#E(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#M(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0}));return}return}t.key==="Enter"&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#D=()=>{if(this.#n=this.value??"",this.#f&&this.locale){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#S(t));if(!Number.isFinite(e))return;let i=this.#x(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#I=()=>{this.#f&&this.#M(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#M(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#S(t));if(!Number.isFinite(e))return;let i=this.#C(e),n=this.#x(i),r=this.#A(i);this.value!==n&&(this.value=n,this.syncValue(n),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}}))),this.#t.textContent!==r&&(this.#t.textContent=r,this.#t.toggleAttribute("data-empty",!r))}#_(t){let e=this.#C(t);e!==this.valueAsNumber&&(this.value=this.#x(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}})))}#Z=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#f?this.#Q(e):e;document.execCommand("insertText",!1,i)};#W=t=>this.#V(t,1);#B=t=>this.#V(t,-1);#V(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#P(e),this.#H(),document.addEventListener("pointerup",this.#U,{once:!0}),document.addEventListener("pointercancel",this.#U,{once:!0}),this.#a=window.setTimeout(()=>{this.#a=null,this.#r=window.setInterval(()=>{let i=this.valueAsNumber;this.#P(e),this.valueAsNumber===i&&this.#H()},s.#d)},s.#u))}#U=()=>this.#H();#H(){this.#a!=null&&(window.clearTimeout(this.#a),this.#a=null),this.#r!=null&&(window.clearInterval(this.#r),this.#r=null),document.removeEventListener("pointerup",this.#U),document.removeEventListener("pointercancel",this.#U)}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.#$),this.#t.removeEventListener("blur",this.#I),this.#t.removeEventListener("focus",this.#D),this.#t.removeEventListener("paste",this.#Z),this.#t.removeEventListener("beforeinput",this.#T)),this.#i?.removeEventListener("pointerdown",this.#W),this.#s?.removeEventListener("pointerdown",this.#B),this.#H(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};S("input-ui",an);var ln=class extends M{static labelDeprecated=!1;static properties={...M.properties,placeholder:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},rows:{type:Number,default:3,reflect:!0},resize:{type:String,default:"vertical",reflect:!0}};static template=()=>null;#t=null;connected(){super.connected(),this.setAttribute("role","textbox"),this.setAttribute("aria-multiline","true"),this.querySelector('[slot="text"]')||(this.innerHTML=`
|
|
92
|
+
`}#O(t,e){let i=this.querySelector(':scope > [slot="field"]');if(i){if(t.length){let n=i.querySelector(':scope > [slot="label"]')||i.querySelector(':scope > [slot="prefix"]');if(n){let r=n;for(let o of t)r.after(o),r=o}else for(let r of t.slice().reverse())i.prepend(r)}if(e.length){let n=i.querySelector(':scope > [slot="controls"]'),r=i.querySelector(':scope > [slot="suffix"]')||i.querySelector(':scope > [slot="text"]');if(r){let o=r;for(let a of e)o.after(a),o=a}else if(n){let o=n.previousElementSibling||n;for(let a of e)o.after(a),o=a}else for(let o of e)i.appendChild(o)}}}#g(){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")&&wd(e)){i.replaceChildren();let n=document.createElement("icon-ui");n.setAttribute("name",e),i.appendChild(n)}}}render(){if(!this.#t)return;let t=this.value??"";if(this.#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 e=this.#f&&document.activeElement!==this.#t?this.#E(t):String(t);this.#t.textContent!==e&&(this.#t.textContent=e,this.#t.toggleAttribute("data-empty",!e))}if(this.#e&&(this.#e.textContent=this.label||""),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#f){let e=this.valueAsNumber;Number.isFinite(e)?(this.setAttribute("aria-valuenow",String(e)),this.setAttribute("aria-valuetext",`${this.#x(e)}${this.suffix?" "+this.suffix:""}`)):(this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuetext")),this.min!=null?this.setAttribute("aria-valuemin",String(this.min)):this.removeAttribute("aria-valuemin"),this.max!=null?this.setAttribute("aria-valuemax",String(this.max)):this.removeAttribute("aria-valuemax");let i=this.disabled||this.readonly||this.max!=null&&Number.isFinite(e)&&e>=this.max,n=this.disabled||this.readonly||this.min!=null&&Number.isFinite(e)&&e<=this.min;this.#i?.toggleAttribute("disabled",!!i),this.#s?.toggleAttribute("disabled",!!n)}}syncValue(t){t=t??this.value??"",super.syncValue(String(t)),this.#f&&this.#b(String(t))}validate(){let t=super.validate();if(!this.#f)return t;if(!t)return!1;let e=this.#b(this.value??"");return e||(this.setAttribute("aria-invalid","true"),this.error=this.validationMessage),e}#b(t){let e=String(t??"").trim();if(!e)return!0;let i=this.#S(e),n=Number(i);return Number.isFinite(n)?this.min!=null&&n<this.min?(this.internals.setValidity({rangeUnderflow:!0},this.getAttribute("data-msg-min")||`Value must be ${this.min} or greater.`,this),!1):this.max!=null&&n>this.max?(this.internals.setValidity({rangeOverflow:!0},this.getAttribute("data-msg-max")||`Value must be ${this.max} or less.`,this),!1):!0:(this.internals.setValidity({badInput:!0},this.getAttribute("data-msg-bad-input")||"Please enter a valid number.",this),!1)}#y(){return this.precision!=null?Math.max(0,this.precision|0):(String(this.step??1).split(".")[1]||"").length}#w(){return this.locale?this.#c===this.locale?this.#o:(this.#k(),this.#o):"."}#v(){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}#S(t){let e=this.#w(),i=this.#v(),n=String(t);return i&&(n=n.split(i).join("")),e!=="."&&(n=n.replace(new RegExp(`\\${e}`,"g"),".")),n}#x(t){if(!Number.isFinite(t))return"";let e=this.#y();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))}#A(t){if(!Number.isFinite(t))return"";if(!this.locale)return this.#x(t);let e=this.#y();try{return new Intl.NumberFormat(this.locale,{minimumFractionDigits:e,maximumFractionDigits:e,useGrouping:!0}).format(t)}catch{return this.#x(t)}}#E(t){let e=String(t??"");if(!e)return"";let i=Number(this.#S(e));return Number.isFinite(i)?document.activeElement===this.#t?this.#x(i):this.#A(i):e}#C(t){let e=this.step||1,i=this.min!=null?this.min:0,n=Math.round((t-i)/e)*e+i,r=Math.max(this.min!=null?this.min:-1/0,Math.min(this.max!=null?this.max:1/0,n));return parseFloat(r.toFixed(10))}#$(t){if(this.disabled||this.readonly)return;let e=(this.step||1)*t,i=Number.isFinite(this.valueAsNumber)?this.valueAsNumber:this.min!=null?this.min:0,n=this.#C(i+e);n!==this.valueAsNumber&&(this.value=this.#x(n),this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#L=()=>{let t;if(this.#p)t=this.#t.value||"";else if(this.#f){let e=this.#t.textContent||"";t=this.#T(e),t!==e&&(this.#t.textContent=t,this.#M())}else t=this.#t.textContent||"";this.value=t,this.#p||this.#t.toggleAttribute("data-empty",!t),this.syncValue(t),this.scheduleThrottledInput()};#P=t=>{let e=t.inputType;if(!e||!e.startsWith("insert")||e==="insertCompositionText")return;let i=t.data??"";if(!i)return;let n=this.#t.textContent||"",r=window.getSelection(),o=n.length,a=n.length;if(r&&r.rangeCount&&this.#t.contains(r.anchorNode)){let h=r.getRangeAt(0);o=this.#N(h.startContainer,h.startOffset),a=this.#N(h.endContainer,h.endOffset),o>a&&([o,a]=[a,o])}let l=n.slice(0,o)+i+n.slice(a);this.#q(l)||t.preventDefault()};#q(t){let e=this.#S(t);return e===""||e==="-"||e==="."||e==="-."?e===""||e==="-"||this.min==null||this.min<0:!(!/^-?\d*\.?\d*$/.test(e)||e.startsWith("-")&&this.min!=null&&this.min>=0)}#T(t){let e=this.#w(),i="",n=!1;for(let r=0;r<t.length;r++){let o=t[r];o>="0"&&o<="9"||o==="-"&&i===""&&(this.min==null||this.min<0)?i+=o:o===e&&!n&&(i+=e,n=!0)}return i}#N(t,e){if(!this.#t.contains(t))return 0;let i=0,n=document.createTreeWalker(this.#t,NodeFilter.SHOW_TEXT),r;for(;r=n.nextNode();){if(r===t)return i+e;i+=r.textContent.length}return t===this.#t?e:i}#M(){let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#t),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}#Q=t=>{if(this.#f){switch(t.key){case"ArrowUp":t.preventDefault(),this.#$(1);return;case"ArrowDown":t.preventDefault(),this.#$(-1);return;case"PageUp":t.preventDefault(),this.#$(10);return;case"PageDown":t.preventDefault(),this.#$(-10);return;case"Home":this.min!=null&&(t.preventDefault(),this.#_(this.min));return;case"End":this.max!=null&&(t.preventDefault(),this.#_(this.max));return;case"Escape":t.preventDefault(),this.value=this.#n,this.#t.textContent=this.#E(this.value),this.#t.toggleAttribute("data-empty",!this.value),this.syncValue(this.value),this.#t.blur();return;case"Enter":t.preventDefault(),this.#R(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0}));return}return}t.key==="Enter"&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new Event("submit",{bubbles:!0})))};#D=()=>{if(this.#n=this.value??"",this.#f&&this.locale){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#S(t));if(!Number.isFinite(e))return;let i=this.#x(e);this.#t.textContent!==i&&(this.#t.textContent=i)}};#I=()=>{this.#f&&this.#R(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))};#R(){let t=String(this.value??"").trim();if(!t)return;let e=Number(this.#S(t));if(!Number.isFinite(e))return;let i=this.#C(e),n=this.#x(i),r=this.#A(i);this.value!==n&&(this.value=n,this.syncValue(n),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}}))),this.#t.textContent!==r&&(this.#t.textContent=r,this.#t.toggleAttribute("data-empty",!r))}#_(t){let e=this.#C(t);e!==this.valueAsNumber&&(this.value=this.#x(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}})))}#Z=t=>{t.preventDefault();let e=t.clipboardData?.getData("text/plain")||"",i=this.#f?this.#T(e):e;document.execCommand("insertText",!1,i)};#W=t=>this.#V(t,1);#B=t=>this.#V(t,-1);#V(t,e){t.preventDefault(),!(this.disabled||this.readonly)&&(this.#$(e),this.#H(),document.addEventListener("pointerup",this.#U,{once:!0}),document.addEventListener("pointercancel",this.#U,{once:!0}),this.#a=window.setTimeout(()=>{this.#a=null,this.#r=window.setInterval(()=>{let i=this.valueAsNumber;this.#$(e),this.valueAsNumber===i&&this.#H()},s.#d)},s.#u))}#U=()=>this.#H();#H(){this.#a!=null&&(window.clearTimeout(this.#a),this.#a=null),this.#r!=null&&(window.clearInterval(this.#r),this.#r=null),document.removeEventListener("pointerup",this.#U),document.removeEventListener("pointercancel",this.#U)}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.#L),this.#t.removeEventListener("keydown",this.#Q),this.#t.removeEventListener("blur",this.#I),this.#t.removeEventListener("focus",this.#D),this.#t.removeEventListener("paste",this.#Z),this.#t.removeEventListener("beforeinput",this.#P)),this.#i?.removeEventListener("pointerdown",this.#W),this.#s?.removeEventListener("pointerdown",this.#B),this.#H(),this.#t=null,this.#e=null,this.#i=null,this.#s=null}};S("input-ui",an);var ln=class extends M{static labelDeprecated=!1;static properties={...M.properties,placeholder:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},rows:{type:Number,default:3,reflect:!0},resize:{type:String,default:"vertical",reflect:!0}};static template=()=>null;#t=null;connected(){super.connected(),this.setAttribute("role","textbox"),this.setAttribute("aria-multiline","true"),this.querySelector('[slot="text"]')||(this.innerHTML=`
|
|
93
93
|
${this.label?`<label slot="label" label="${this.label}"></label>`:""}
|
|
94
94
|
<div slot="text" contenteditable="plaintext-only" tabindex="0"
|
|
95
95
|
${this.value?"":'data-empty=""'}
|
|
@@ -116,7 +116,7 @@ ${i.join(`
|
|
|
116
116
|
.value=\${signal.value} \u2190 read the signal's current value
|
|
117
117
|
Functions are not auto-invoked at render time; the slider reads
|
|
118
118
|
.value synchronously. See USAGE.md "Reactive binding" for the
|
|
119
|
-
parent-template-re-read pattern that works across frameworks.`);return}if(this.dual){if(this.lowerValue>this.upperValue){let a=!Number.isNaN(this.#l)&&this.lowerValue!==this.#l;!Number.isNaN(this.#c)&&this.upperValue!==this.#c&&!a?this.upperValue=this.lowerValue:this.lowerValue=this.upperValue}this.#l=this.lowerValue,this.#c=this.upperValue;let i=this.#h(this.lowerValue),n=this.#h(this.upperValue);this.style.setProperty("--slider-pct-lower",String(i)),this.style.setProperty("--slider-pct-upper",String(n));let r=this.querySelector('[slot="value-lower"]'),o=this.querySelector('[slot="value-upper"]');r&&(r.textContent=this.#u(this.lowerValue)),o&&(o.textContent=this.#u(this.upperValue)),this.#s&&(this.#s.setAttribute("aria-valuenow",this.lowerValue),this.#s.setAttribute("aria-valuetext",`${this.#u(this.lowerValue)}${this.suffix?" "+this.suffix:""}`)),this.#n&&(this.#n.setAttribute("aria-valuenow",this.upperValue),this.#n.setAttribute("aria-valuetext",`${this.#u(this.upperValue)}${this.suffix?" "+this.suffix:""}`)),this.syncValue(`${this.lowerValue},${this.upperValue}`)}else{let i=this.#h(this.value);this.style.setProperty("--slider-pct",String(i));let n=this.querySelector('[slot="value"]');n&&(n.textContent=this.#u(this.value)),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.#u(this.value)}${this.suffix?" "+this.suffix:""}`),this.syncValue(String(this.value))}let t=this.querySelector('[slot="label"]');if(t)t.textContent=this.label;else if(this.label){let i=this.querySelector('[slot="header"]');if(i){let n=document.createElement("span");n.slot="label",n.textContent=this.label,i.prepend(n)}}this.label&&this.setAttribute("aria-label",this.label);let e=this.querySelector('[slot="suffix"]');e&&(e.textContent=this.suffix)}#d(t,e=null){let i=this.#i||this.#s||this.#n;if(!this.#e||!i)return this.min;let n=this.#e.getBoundingClientRect(),r=i.getBoundingClientRect().width,o=n.width,a,l;if(this.dual?(a=o-2*r,l=e==="upper"?1.5*r:.5*r):(a=o-r,l=.5*r),a<=0)return this.min;let h=t-n.left,c=Math.max(0,Math.min(1,(h-l)/a)),u=this.min+c*(this.max-this.min);return this.#f(u)}#p(t){if(!this.#e)return 0;let e=this.#i||this.#s||this.#n;if(!e)return 0;let i=this.#e.getBoundingClientRect(),n=e.getBoundingClientRect().width,r=i.width;if(this.dual){let o=r-2*n,a=t==="upper"?this.#h(this.upperValue):this.#h(this.lowerValue),l=t==="upper"?1.5*n:.5*n;return i.left+l+a*o}else return i.left+.5*n+this.#h(this.value)*(r-n)}#f(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())}#O(t){let e=Math.min(Math.max(t,this.min),this.upperValue);e!==this.lowerValue&&(this.lowerValue=e,this.scheduleThrottledInput())}#g(t){let e=Math.max(Math.min(t,this.max),this.lowerValue);e!==this.upperValue&&(this.upperValue=e,this.scheduleThrottledInput())}#b(){let t=this.dual?{lower:this.lowerValue,upper:this.upperValue}:{value:this.value};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:t}))}#y=t=>{if(this.disabled)return;t.preventDefault(),this.#r=!0,this.setAttribute("data-dragging","");let e;if(this.dual){let i=t.currentTarget?.dataset?.thumb;this.#a=i==="upper"?"upper":"lower",e=this.#a==="lower"?this.#s:this.#n,e?.setAttribute("data-active","")}else e=this.#i;if(this.#e&&e){let i=this.dual?this.#a:null;this.#o=t.clientX-this.#p(i)}else this.#o=0;e.setPointerCapture(t.pointerId),e.addEventListener("pointermove",this.#w),e.addEventListener("pointerup",this.#v)};#w=t=>{if(!this.#r)return;let e=t.clientX-this.#o;if(this.dual){let i=this.#d(e,this.#a);this.#a==="lower"?this.#O(i):this.#g(i)}else this.#m(this.#d(e))};#v=t=>{this.#r=!1,this.#o=0,this.removeAttribute("data-dragging");let e=this.dual?this.#a==="lower"?this.#s:this.#n:this.#i;e?.releasePointerCapture(t.pointerId),e?.removeEventListener("pointermove",this.#w),e?.removeEventListener("pointerup",this.#v),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#b(),this.#a=null};#k=t=>{if(!this.disabled){if(this.dual){if(t.target===this.#s||t.target===this.#n)return;let e=Math.abs(t.clientX-this.#p("lower")),i=Math.abs(t.clientX-this.#p("upper"));e<=i?this.#O(this.#d(t.clientX,"lower")):this.#g(this.#d(t.clientX,"upper"))}else{if(t.target===this.#i)return;this.#m(this.#d(t.clientX))}this.flushPendingInput(),this.#b()}};#S=t=>{if(this.disabled)return;let e=0,i=null;switch(t.key){case"ArrowRight":case"ArrowUp":e=this.step;break;case"ArrowLeft":case"ArrowDown":e=-this.step;break;case"Home":i=this.min;break;case"End":i=this.max;break;case"PageUp":e=this.step*10;break;case"PageDown":e=-this.step*10;break;default:return}if(t.preventDefault(),this.dual){let r=this.ownerDocument?.activeElement===this.#n?"upper":"lower",o=r==="lower"?this.lowerValue:this.upperValue,a=i!==null?i:o+e;a=this.#f(a),r==="lower"?this.#O(a):this.#g(a)}else{let n=i!==null?i:this.value+e;this.#m(this.#f(n))}this.flushPendingInput(),this.#b()};disconnected(){super.disconnected(),this.#i?.removeEventListener("pointerdown",this.#y),this.#s?.removeEventListener("pointerdown",this.#y),this.#n?.removeEventListener("pointerdown",this.#y),this.#e?.removeEventListener("click",this.#k),this.removeEventListener("keydown",this.#S),this.#e=null,this.#i=null,this.#s=null,this.#n=null}};S("slider-ui",pn);var KE=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,JE=0;function ct(s,t,e={}){let{placement:i="bottom-start",gap:n=4,matchWidth:r=!1}=e;return KE?tC(s,t,{placement:i,gap:n,matchWidth:r}):sC(s,t,{placement:i,gap:n,matchWidth:r})}function tC(s,t,{placement:e,gap:i,matchWidth:n}){let r=`--a-anchor-${++JE}`,o=s.style.anchorName,a={position:t.style.position,positionAnchor:t.style.positionAnchor,positionArea:t.style.positionArea,positionTryFallbacks:t.style.positionTryFallbacks,margin:t.style.margin,width:t.style.width,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,overflowY:t.style.overflowY,top:t.style.top,left:t.style.left};return s.style.anchorName=r,t.style.position="fixed",t.style.positionAnchor=r,t.style.positionArea=iC(e),t.style.margin=eC(e,i),t.style.positionTryFallbacks="flip-block, flip-inline, flip-block flip-inline",t.style.width=n?`anchor-size(${r} width)`:"max-content",t.style.maxWidth="min(calc(100vw - 1rem), 32rem)",t.style.maxHeight="calc(100vh - 3rem)",t.style.overflowY="auto",t.style.top="",t.style.left="",()=>{s.style.anchorName=o;for(let[l,h]of Object.entries(a))t.style[l]=h}}function eC(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 iC(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 sC(s,t,{placement:e,gap:i,matchWidth:n}){function r(){if(!s||!t)return;let a=s.getBoundingClientRect(),l=t.getBoundingClientRect(),h=window.innerWidth,c=window.innerHeight,u=e;u.startsWith("bottom")&&a.bottom+i+l.height>c&&a.top-i-l.height>0?u=u.replace("bottom","top"):u.startsWith("top")&&a.top-i-l.height<0&&a.bottom+i+l.height<c&&(u=u.replace("top","bottom"));let d,f;u.startsWith("top")?d=a.top-l.height-i:u.startsWith("bottom")?d=a.bottom+i:u.startsWith("left")?(f=a.left-l.width-i,u==="left-start"?d=a.top:u==="left-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2):u.startsWith("right")&&(f=a.right+i,u==="right-start"?d=a.top:u==="right-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2),f===void 0&&(u.endsWith("-start")?f=a.left:u.endsWith("-end")?f=a.right-l.width:f=a.left+(a.width-l.width)/2),f+l.width>h-i&&(f=a.right-l.width),f<i&&(f=a.left),d=Math.max(i,Math.min(d,c-l.height-i)),f=Math.max(i,Math.min(f,h-l.width-i)),t.style.position="fixed",t.style.top=`${d}px`,t.style.left=`${f}px`,n&&(t.style.width=`${a.width}px`)}t.style.opacity="0",requestAnimationFrame(()=>{r(),t.style.opacity=""});let o=nC(s);for(let a of o)a.addEventListener("scroll",r,{passive:!0});return window.addEventListener("resize",r,{passive:!0}),()=>{for(let a of o)a.removeEventListener("scroll",r);window.removeEventListener("resize",r)}}function nC(s){let t=[document],e=s?.parentElement;for(;e;){let i=getComputedStyle(e);/auto|scroll/.test(i.overflow+i.overflowX+i.overflowY)&&t.push(e),e=e.parentElement}return t}Ct();function ye(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var mn=class s extends M{static labelDeprecated=!1;static requiredIcons=["caret-up-down","check","x","magnifying-glass"];static#t=new WeakSet;static properties={...M.properties,placeholder:{type:String,default:"Select...",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},avatar:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0},searchable:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},divider:{type:Boolean,default:!1,reflect:!0},hint:{type:String,default:"",reflect:!0},maxChips:{type:Number,default:0,reflect:!0,attribute:"max-chips"},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:0,reflect:!0},selectAll:{type:Boolean,default:!1,reflect:!0,attribute:"select-all"},clearable:{type:Boolean,default:!1,reflect:!0}};static#e=0;static template=()=>null;#i=[];#s=null;#n=null;#r="";#a=null;#o=null;#l=()=>{this.disabled||(this.open=!0)};#c=t=>{t.stopPropagation(),this.disabled||(this.open=!0)};#h=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.#r="",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(n=>n.trim()).filter(Boolean);if(this.min>0&&i.length<this.min){this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please select at least ${this.min}.`,this);return}if(this.max>0&&i.length>this.max){this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-max")||`Please select no more than ${this.max}.`,this);return}if(this.required&&i.length===0){this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this);return}this.internals.setValidity({})}#u(){return this.value?String(this.value).split(",").map(t=>t.trim()).filter(Boolean):[]}#d(t){let e=new Set,i=[];for(let n of t){if(n==null||n==="")continue;let r=String(n);e.has(r)||(e.add(r),i.push(r))}return i.join(",")}toggle(t){if(!this.multiple){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}let e=this.#u(),i=e.indexOf(String(t)),n=e.slice(),r=[],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:n,reason:"max"}}));return}e.push(String(t)),r=[String(t)]}let a=this.#d(e);this.value=a,this.syncValue(a),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e,added:r,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.#d(t.map(o=>o.value));if(e===this.value)return;let i=this.#u();this.value=e,this.syncValue(e),this.render();let n=this.#u(),r=n.filter(o=>!i.includes(o));this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,added:r,removed:[]}}))}clear(){if(!this.multiple){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:""}}));return}let t=this.#u();t.length!==0&&(this.value="",this.syncValue(""),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:[],added:[],removed:t}})))}#p(){let t=this.#u();if(t.length===0)return;let e=t.pop(),i=this.#d(t);this.value=i,this.syncValue(i),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,added:[],removed:[e]}}))}#f=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 n=this.#u().filter(o=>o!==i),r=this.#d(n);this.value=r,this.syncValue(r),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,added:[],removed:[i]}}))};#m=t=>{t.stopPropagation(),!this.disabled&&(this.open=!0)};#O=t=>{t.stopPropagation(),!(this.disabled||this.readonly)&&this.clear()};#g=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)),n=new Set(this.#u());i.length>0&&i.every(o=>n.has(o))?this.clear():this.selectAllOptions()};connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#S),this.addEventListener("keydown",this.#A),this.addEventListener("remove",this.#f),this.#i.length===0&&this.#b()}render(){if(this.multiple?this.setAttribute("data-multi-chips",""):this.removeAttribute("data-multi-chips"),this.querySelector('[slot="trigger"]')){let e=this.querySelector('[slot="display"]');if(e&&!this.multiple)e.tagName==="INPUT"?this.#r||(e.value=this.#k()===this.placeholder?"":this.#k()):e.textContent=this.#k();else if(e&&this.multiple){let i=this.#u().length>0;e.tagName==="INPUT"?(e.placeholder=i?"":this.placeholder||"",this.#r||(e.value="")):e.textContent=i?"":this.placeholder||""}}else{let e=this.#s;e?.parentNode===this&&this.removeChild(e);let i=this.avatar?`<img slot="leading" src="${this.avatar}" alt="" />`:this.icon?`<icon-ui slot="leading" name="${this.icon}"></icon-ui>`:"",n=this.searchable?`<input slot="display" type="text" role="combobox" aria-autocomplete="list" autocomplete="off" placeholder="${ye(this.placeholder||"")}" value="${ye(this.#k()===this.placeholder?"":this.#k())}" />`:`<span slot="display">${ye(this.#k())}</span>`,r=this.hint?`select-hint-${++s.#e}`:"",o=this.hint?`<span slot="hint" id="${r}">${ye(this.hint)}</span>`:"";this.innerHTML=`
|
|
119
|
+
parent-template-re-read pattern that works across frameworks.`);return}if(this.dual){if(this.lowerValue>this.upperValue){let a=!Number.isNaN(this.#l)&&this.lowerValue!==this.#l;!Number.isNaN(this.#c)&&this.upperValue!==this.#c&&!a?this.upperValue=this.lowerValue:this.lowerValue=this.upperValue}this.#l=this.lowerValue,this.#c=this.upperValue;let i=this.#h(this.lowerValue),n=this.#h(this.upperValue);this.style.setProperty("--slider-pct-lower",String(i)),this.style.setProperty("--slider-pct-upper",String(n));let r=this.querySelector('[slot="value-lower"]'),o=this.querySelector('[slot="value-upper"]');r&&(r.textContent=this.#u(this.lowerValue)),o&&(o.textContent=this.#u(this.upperValue)),this.#s&&(this.#s.setAttribute("aria-valuenow",this.lowerValue),this.#s.setAttribute("aria-valuetext",`${this.#u(this.lowerValue)}${this.suffix?" "+this.suffix:""}`)),this.#n&&(this.#n.setAttribute("aria-valuenow",this.upperValue),this.#n.setAttribute("aria-valuetext",`${this.#u(this.upperValue)}${this.suffix?" "+this.suffix:""}`)),this.syncValue(`${this.lowerValue},${this.upperValue}`)}else{let i=this.#h(this.value);this.style.setProperty("--slider-pct",String(i));let n=this.querySelector('[slot="value"]');n&&(n.textContent=this.#u(this.value)),this.setAttribute("aria-valuenow",this.value),this.setAttribute("aria-valuetext",`${this.#u(this.value)}${this.suffix?" "+this.suffix:""}`),this.syncValue(String(this.value))}let t=this.querySelector('[slot="label"]');if(t)t.textContent=this.label;else if(this.label){let i=this.querySelector('[slot="header"]');if(i){let n=document.createElement("span");n.slot="label",n.textContent=this.label,i.prepend(n)}}this.label&&this.setAttribute("aria-label",this.label);let e=this.querySelector('[slot="suffix"]');e&&(e.textContent=this.suffix)}#d(t,e=null){let i=this.#i||this.#s||this.#n;if(!this.#e||!i)return this.min;let n=this.#e.getBoundingClientRect(),r=i.getBoundingClientRect().width,o=n.width,a,l;if(this.dual?(a=o-2*r,l=e==="upper"?1.5*r:.5*r):(a=o-r,l=.5*r),a<=0)return this.min;let h=t-n.left,c=Math.max(0,Math.min(1,(h-l)/a)),u=this.min+c*(this.max-this.min);return this.#f(u)}#p(t){if(!this.#e)return 0;let e=this.#i||this.#s||this.#n;if(!e)return 0;let i=this.#e.getBoundingClientRect(),n=e.getBoundingClientRect().width,r=i.width;if(this.dual){let o=r-2*n,a=t==="upper"?this.#h(this.upperValue):this.#h(this.lowerValue),l=t==="upper"?1.5*n:.5*n;return i.left+l+a*o}else return i.left+.5*n+this.#h(this.value)*(r-n)}#f(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())}#O(t){let e=Math.min(Math.max(t,this.min),this.upperValue);e!==this.lowerValue&&(this.lowerValue=e,this.scheduleThrottledInput())}#g(t){let e=Math.max(Math.min(t,this.max),this.lowerValue);e!==this.upperValue&&(this.upperValue=e,this.scheduleThrottledInput())}#b(){let t=this.dual?{lower:this.lowerValue,upper:this.upperValue}:{value:this.value};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:t}))}#y=t=>{if(this.disabled)return;t.preventDefault(),this.#r=!0,this.setAttribute("data-dragging","");let e;if(this.dual){let i=t.currentTarget?.dataset?.thumb;this.#a=i==="upper"?"upper":"lower",e=this.#a==="lower"?this.#s:this.#n,e?.setAttribute("data-active","")}else e=this.#i;if(this.#e&&e){let i=this.dual?this.#a:null;this.#o=t.clientX-this.#p(i)}else this.#o=0;e.setPointerCapture(t.pointerId),e.addEventListener("pointermove",this.#w),e.addEventListener("pointerup",this.#v)};#w=t=>{if(!this.#r)return;let e=t.clientX-this.#o;if(this.dual){let i=this.#d(e,this.#a);this.#a==="lower"?this.#O(i):this.#g(i)}else this.#m(this.#d(e))};#v=t=>{this.#r=!1,this.#o=0,this.removeAttribute("data-dragging");let e=this.dual?this.#a==="lower"?this.#s:this.#n:this.#i;e?.releasePointerCapture(t.pointerId),e?.removeEventListener("pointermove",this.#w),e?.removeEventListener("pointerup",this.#v),e?.removeAttribute("data-active"),this.flushPendingInput(),this.#b(),this.#a=null};#k=t=>{if(!this.disabled){if(this.dual){if(t.target===this.#s||t.target===this.#n)return;let e=Math.abs(t.clientX-this.#p("lower")),i=Math.abs(t.clientX-this.#p("upper"));e<=i?this.#O(this.#d(t.clientX,"lower")):this.#g(this.#d(t.clientX,"upper"))}else{if(t.target===this.#i)return;this.#m(this.#d(t.clientX))}this.flushPendingInput(),this.#b()}};#S=t=>{if(this.disabled)return;let e=0,i=null;switch(t.key){case"ArrowRight":case"ArrowUp":e=this.step;break;case"ArrowLeft":case"ArrowDown":e=-this.step;break;case"Home":i=this.min;break;case"End":i=this.max;break;case"PageUp":e=this.step*10;break;case"PageDown":e=-this.step*10;break;default:return}if(t.preventDefault(),this.dual){let r=this.ownerDocument?.activeElement===this.#n?"upper":"lower",o=r==="lower"?this.lowerValue:this.upperValue,a=i!==null?i:o+e;a=this.#f(a),r==="lower"?this.#O(a):this.#g(a)}else{let n=i!==null?i:this.value+e;this.#m(this.#f(n))}this.flushPendingInput(),this.#b()};disconnected(){super.disconnected(),this.#i?.removeEventListener("pointerdown",this.#y),this.#s?.removeEventListener("pointerdown",this.#y),this.#n?.removeEventListener("pointerdown",this.#y),this.#e?.removeEventListener("click",this.#k),this.removeEventListener("keydown",this.#S),this.#e=null,this.#i=null,this.#s=null,this.#n=null}};S("slider-ui",pn);var KE=typeof CSS<"u"?(CSS.supports?.("anchor-name: --x")??!1)&&(CSS.supports?.("position-area: bottom")??!1):!1,JE=0;function ct(s,t,e={}){let{placement:i="bottom-start",gap:n=4,matchWidth:r=!1}=e;return KE?tC(s,t,{placement:i,gap:n,matchWidth:r}):sC(s,t,{placement:i,gap:n,matchWidth:r})}function tC(s,t,{placement:e,gap:i,matchWidth:n}){let r=`--a-anchor-${++JE}`,o=s.style.anchorName,a={position:t.style.position,positionAnchor:t.style.positionAnchor,positionArea:t.style.positionArea,positionTryFallbacks:t.style.positionTryFallbacks,margin:t.style.margin,width:t.style.width,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,overflowY:t.style.overflowY,top:t.style.top,left:t.style.left};return s.style.anchorName=r,t.style.position="fixed",t.style.positionAnchor=r,t.style.positionArea=iC(e),t.style.margin=eC(e,i),t.style.positionTryFallbacks="flip-block, flip-inline, flip-block flip-inline",t.style.width=n?`anchor-size(${r} width)`:"max-content",t.style.maxWidth="min(calc(100vw - 1rem), 32rem)",t.style.maxHeight="calc(100vh - 3rem)",t.style.overflowY="auto",t.style.top="",t.style.left="",()=>{s.style.anchorName=o;for(let[l,h]of Object.entries(a))t.style[l]=h}}function eC(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 iC(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 sC(s,t,{placement:e,gap:i,matchWidth:n}){function r(){if(!s||!t)return;let a=s.getBoundingClientRect(),l=t.getBoundingClientRect(),h=window.innerWidth,c=window.innerHeight,u=e;u.startsWith("bottom")&&a.bottom+i+l.height>c&&a.top-i-l.height>0?u=u.replace("bottom","top"):u.startsWith("top")&&a.top-i-l.height<0&&a.bottom+i+l.height<c&&(u=u.replace("top","bottom"));let d,f;u.startsWith("top")?d=a.top-l.height-i:u.startsWith("bottom")?d=a.bottom+i:u.startsWith("left")?(f=a.left-l.width-i,u==="left-start"?d=a.top:u==="left-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2):u.startsWith("right")&&(f=a.right+i,u==="right-start"?d=a.top:u==="right-end"?d=a.bottom-l.height:d=a.top+(a.height-l.height)/2),f===void 0&&(u.endsWith("-start")?f=a.left:u.endsWith("-end")?f=a.right-l.width:f=a.left+(a.width-l.width)/2),f+l.width>h-i&&(f=a.right-l.width),f<i&&(f=a.left),d=Math.max(i,Math.min(d,c-l.height-i)),f=Math.max(i,Math.min(f,h-l.width-i)),t.style.position="fixed",t.style.top=`${d}px`,t.style.left=`${f}px`,n&&(t.style.width=`${a.width}px`)}t.style.opacity="0",requestAnimationFrame(()=>{r(),t.style.opacity=""});let o=nC(s);for(let a of o)a.addEventListener("scroll",r,{passive:!0});return window.addEventListener("resize",r,{passive:!0}),()=>{for(let a of o)a.removeEventListener("scroll",r);window.removeEventListener("resize",r)}}function nC(s){let t=[document],e=s?.parentElement;for(;e;){let i=getComputedStyle(e);/auto|scroll/.test(i.overflow+i.overflowX+i.overflowY)&&t.push(e),e=e.parentElement}return t}Ct();function ye(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var mn=class s extends M{static labelDeprecated=!1;static requiredIcons=["caret-up-down","check","x","magnifying-glass"];static#t=new WeakSet;static properties={...M.properties,placeholder:{type:String,default:"Select...",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},avatar:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0},searchable:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},divider:{type:Boolean,default:!1,reflect:!0},hint:{type:String,default:"",reflect:!0},maxChips:{type:Number,default:0,reflect:!0,attribute:"max-chips"},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:0,reflect:!0},selectAll:{type:Boolean,default:!1,reflect:!0,attribute:"select-all"},clearable:{type:Boolean,default:!1,reflect:!0}};static#e=0;static template=()=>null;#i=[];#s=null;#n=null;#r="";#a=null;#o=null;#l=()=>{this.disabled||(this.open=!0)};#c=t=>{t.stopPropagation(),this.disabled||(this.open=!0)};#h=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.#r="",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(n=>n.trim()).filter(Boolean);if(this.min>0&&i.length<this.min){this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please select at least ${this.min}.`,this);return}if(this.max>0&&i.length>this.max){this.internals.setValidity({tooLong:!0},this.getAttribute("data-msg-max")||`Please select no more than ${this.max}.`,this);return}if(this.required&&i.length===0){this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this);return}this.internals.setValidity({})}#u(){return this.value?String(this.value).split(",").map(t=>t.trim()).filter(Boolean):[]}#d(t){let e=new Set,i=[];for(let n of t){if(n==null||n==="")continue;let r=String(n);e.has(r)||(e.add(r),i.push(r))}return i.join(",")}toggle(t){if(!this.multiple){this.value=t,this.syncValue(t),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}));return}let e=this.#u(),i=e.indexOf(String(t)),n=e.slice(),r=[],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:n,reason:"max"}}));return}e.push(String(t)),r=[String(t)]}let a=this.#d(e);this.value=a,this.syncValue(a),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:e,added:r,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.#d(t.map(o=>o.value));if(e===this.value)return;let i=this.#u();this.value=e,this.syncValue(e),this.render();let n=this.#u(),r=n.filter(o=>!i.includes(o));this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,added:r,removed:[]}}))}clear(){if(!this.multiple){this.value="",this.syncValue(""),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:""}}));return}let t=this.#u();t.length!==0&&(this.value="",this.syncValue(""),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:[],added:[],removed:t}})))}#p(){let t=this.#u();if(t.length===0)return;let e=t.pop(),i=this.#d(t);this.value=i,this.syncValue(i),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,added:[],removed:[e]}}))}#f=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 n=this.#u().filter(o=>o!==i),r=this.#d(n);this.value=r,this.syncValue(r),this.render(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:n,added:[],removed:[i]}}))};#m=t=>{t.stopPropagation(),!this.disabled&&(this.open=!0)};#O=t=>{t.stopPropagation(),!(this.disabled||this.readonly)&&this.clear()};#g=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)),n=new Set(this.#u());i.length>0&&i.every(o=>n.has(o))?this.clear():this.selectAllOptions()};#b=!1;#y(){let t="Select...",e=this.hasAttribute("aria-label")&&!this.#b,i=!!this.label||this.hasAttribute("aria-labelledby");!e&&!i&&this.placeholder&&this.placeholder!==t?(this.setAttribute("aria-label",this.placeholder),this.#b=!0):this.#b&&(this.removeAttribute("aria-label"),this.#b=!1)}connected(){super.connected(),this.setAttribute("role","combobox"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#A),this.addEventListener("keydown",this.#C),this.addEventListener("remove",this.#f),this.#i.length===0&&this.#w()}render(){if(this.multiple?this.setAttribute("data-multi-chips",""):this.removeAttribute("data-multi-chips"),this.#y(),this.querySelector('[slot="trigger"]')){let e=this.querySelector('[slot="display"]');if(e&&!this.multiple)e.tagName==="INPUT"?this.#r||(e.value=this.#x()===this.placeholder?"":this.#x()):e.textContent=this.#x();else if(e&&this.multiple){let i=this.#u().length>0;e.tagName==="INPUT"?(e.placeholder=i?"":this.placeholder||"",this.#r||(e.value="")):e.textContent=i?"":this.placeholder||""}}else{let e=this.#s;e?.parentNode===this&&this.removeChild(e);let i=this.avatar?`<img slot="leading" src="${this.avatar}" alt="" />`:this.icon?`<icon-ui slot="leading" name="${this.icon}"></icon-ui>`:"",n=this.searchable?`<input slot="display" type="text" role="combobox" aria-autocomplete="list" autocomplete="off" placeholder="${ye(this.placeholder||"")}" value="${ye(this.#x()===this.placeholder?"":this.#x())}" />`:`<span slot="display">${ye(this.#x())}</span>`,r=this.hint?`select-hint-${++s.#e}`:"",o=this.hint?`<span slot="hint" id="${r}">${ye(this.hint)}</span>`:"";this.innerHTML=`
|
|
120
120
|
<span slot="trigger">
|
|
121
121
|
${i}
|
|
122
122
|
<span data-chips></span>
|
|
@@ -127,7 +127,7 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
127
127
|
<icon-ui name="caret-up-down" slot="caret"></icon-ui>
|
|
128
128
|
</span>
|
|
129
129
|
${o}
|
|
130
|
-
`,this.hint&&this.setAttribute("aria-describedby",r);let a=this.querySelector("[data-clear-all]");a&&(a.removeEventListener("click",this.#O),a.addEventListener("click",this.#O)),this.searchable&&(this.#a&&(this.#a.removeEventListener("input",this.#E),this.#a.removeEventListener("focus",this.#l),this.#a.removeEventListener("click",this.#c)),this.#a=this.querySelector('input[slot="display"]'),this.#a&&(this.#a.addEventListener("input",this.#E),this.#a.addEventListener("focus",this.#l),this.#a.addEventListener("click",this.#c))),e&&this.appendChild(e)}this.multiple&&this.#v();let t=this.querySelector("[data-clear-all]");if(t&&(this.multiple&&this.clearable&&this.#u().length>0&&!this.disabled&&!this.readonly?t.removeAttribute("hidden"):t.setAttribute("hidden","")),this.#s||(this.#s=this.querySelector('[slot="listbox"]'),this.#s||(this.#s=document.createElement("div"),this.#s.setAttribute("slot","listbox"),this.#s.setAttribute("role","listbox"),this.#s.setAttribute("popover","manual"),this.appendChild(this.#s)),this.#y()),this.#s){let e=this.multiple?new Set(this.value.split(",").map(i=>i.trim()).filter(Boolean)):null;for(let i of this.#s.querySelectorAll('[role="option"]')){let n=i.getAttribute("data-value");(e?e.has(n):n===this.value)?i.setAttribute("aria-selected","true"):i.removeAttribute("aria-selected")}}if(this.setAttribute("aria-expanded",String(this.open)),this.open){this.#s?.showPopover?.();let e=this.querySelector('[slot="trigger"]')||this;this.#s.style.minWidth=`${e.getBoundingClientRect().width}px`,this.#s.style.width="max-content",this.#n=ct(e,this.#s,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#o=requestAnimationFrame(()=>{this.#o=null,document.addEventListener("pointerdown",this.#x,{once:!0})})}else this.#n?.(),this.#n=null,this.#s?.hidePopover?.(),this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),document.removeEventListener("pointerdown",this.#x)}#b(){this.#i=[];let t=new Set,e=[];for(let i of this.children)if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled}),r.hasAttribute("selected")&&e.push(r.value);this.#i.push(n)}else i.tagName==="OPTION"?(this.#i.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&e.push(i.value)):i.hasAttribute("slot")||t.add(i.tagName.toLowerCase());for(let i of[...this.querySelectorAll("option, optgroup")])i.remove();!this.value&&e.length&&(this.value=this.multiple?e.join(","):e[0]),t.size>0&&!s.#t.has(this)&&(s.#t.add(this),console.warn(`<select-ui>: ignoring unrecognized child element(s) [${[...t].join(", ")}]. Consumer-authored children must be native <option> or <optgroup>, NOT <select-option> or other <*-ui> shapes. Or set element.options = [...] programmatically. (Once-per-element warn; see select.yaml usage: for details.)`))}set options(t){F(()=>{this.#i=t,this.#s||(this.#s=this.querySelector('[slot="listbox"]'),this.#s||(this.#s=document.createElement("div"),this.#s.setAttribute("slot","listbox"),this.#s.setAttribute("role","listbox"),this.#s.setAttribute("popover","manual"),this.appendChild(this.#s))),this.#y();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#k())})}get options(){return this.#i}#y(){if(!this.#s)return;if(this.#s.innerHTML="",this.multiple?this.#s.setAttribute("aria-multiselectable","true"):this.#s.removeAttribute("aria-multiselectable"),this.multiple&&this.selectAll){let e=document.createElement("div");e.setAttribute("data-select-all","");let i=document.createElement("button");i.type="button",i.dataset.selectAllBtn="",i.textContent=this.#w()?"Clear":"Select all",i.addEventListener("click",this.#g),e.appendChild(i),this.#s.appendChild(e)}let t=e=>{if(e.separator){let o=document.createElement("hr");return o.setAttribute("data-separator",""),o}let i=document.createElement("div");i.setAttribute("role","option"),i.setAttribute("data-value",e.value||"");let n=this.multiple?new Set(this.value.split(",").map(o=>o.trim()).filter(Boolean)):null,r=n?n.has(e.value):e.value===this.value;if(this.multiple){i.setAttribute("data-multi-option","");let o=document.createElement("span");o.setAttribute("data-checkbox",""),o.innerHTML='<icon-ui name="check" aria-hidden="true"></icon-ui>',i.appendChild(o);let a=document.createElement("span");a.setAttribute("data-option-label",""),e.icon?a.innerHTML=`<icon-ui name="${ye(e.icon)}"></icon-ui>${ye(e.label)}`:a.textContent=e.label,i.appendChild(a)}else e.icon?i.innerHTML=`<icon-ui name="${ye(e.icon)}"></icon-ui>${ye(e.label)}`:i.textContent=e.label;return r&&i.setAttribute("aria-selected","true"),e.disabled&&i.setAttribute("aria-disabled","true"),e.action&&(i.dataset.action=e.action),i.__adiaOption=e,i.addEventListener("click",this.#h),i};for(let e of this.#i)if(e.separator)this.#s.appendChild(t(e));else if(e.header){let i=document.createElement("div");i.setAttribute("data-menu-header",""),i.innerHTML=e.avatar?`<img src="${e.avatar}" alt="" /><div><strong>${ye(e.label)}</strong><span>${ye(e.description||"")}</span></div>`:`<div><strong>${ye(e.label)}</strong><span>${ye(e.description||"")}</span></div>`,this.#s.appendChild(i)}else if(e.options){let i=document.createElement("div");i.setAttribute("role","group"),i.innerHTML=`<div slot="group-label">${ye(e.label)}</div>`;for(let n of e.options)i.appendChild(t(n));this.#s.appendChild(i)}else this.#s.appendChild(t(e));if(this.#i.length===0){let e=document.createElement("div");e.setAttribute("data-empty",""),e.textContent="No options",this.#s.appendChild(e)}this.#r&&this.#C()}#w(){if(!this.multiple)return!1;let t=this.#i.flatMap(i=>i.options||[i]).filter(i=>!i.disabled&&!i.separator&&!i.header&&i.value!=null);if(t.length===0)return!1;let e=new Set(this.#u());return t.every(i=>e.has(String(i.value)))}#v(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;let e=this.#u(),i=Number(this.maxChips)||0,n=i>0&&e.length>i?e.slice(0,i):e,r=i>0&&e.length>i?e.length-i:0,o=this.#i.flatMap(l=>l.options||[l]).filter(l=>!l.separator&&!l.header&&l.value!=null),a=l=>{let h=o.find(c=>String(c.value)===String(l));return h?h.label:String(l)};for(;t.firstChild;)t.removeChild(t.firstChild);for(let l of n){let h=document.createElement("tag-ui");h.setAttribute("size","sm"),!this.disabled&&!this.readonly&&h.setAttribute("removable",""),h.dataset.chipValue=String(l),h.setAttribute("text",a(l)),t.appendChild(h)}if(r>0){let l=document.createElement("button");l.type="button",l.dataset.more="",l.textContent=`+${r} more`,l.addEventListener("click",this.#m),t.appendChild(l)}}#k(){return this.multiple?this.value?"":this.placeholder:this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#S=t=>{this.disabled||this.#s&&t.composedPath().includes(this.#s)||(this.open=!this.open)};#x=t=>{!this.contains(t.target)&&!(this.#s&&t.composedPath().includes(this.#s))&&(this.open=!1)};#A=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.tagName==="INPUT"&&e.getAttribute("slot")==="display",n=!this.#r||this.#r.length===0;if((!i||n)&&this.#u().length>0){t.preventDefault(),this.#p();return}}if(t.key==="Escape"){if(this.searchable&&this.#r){this.#r="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#C();return}this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.open){let e=this.#s?.querySelector('[role="option"][data-focused]:not([data-filtered-out])');if(e)e.click(),this.multiple&&(this.open=!1);else if(this.searchable&&this.freeText&&this.#r){let i=this.#r;this.value=i,this.#r="",this.open=!1,this.syncValue?.(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}else this.open=!1}else this.open=!0;return}if(t.key===" "&&!this.searchable){if(t.preventDefault(),this.open){let e=this.#s?.querySelector('[role="option"][data-focused]');e?e.click():this.multiple||(this.open=!1)}else this.open=!0;return}t.key==="ArrowDown"&&this.open&&(t.preventDefault(),this.#P(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#P(-1))};#E=t=>{this.#r=t.target.value||"",this.open||(this.open=!0),this.#C()};#C(){if(!this.#s)return;let t=this.#r.toLowerCase(),e=this.#s.querySelectorAll('[role="option"]'),i=!1;for(let r of e){let o=(r.textContent||"").toLowerCase();!t||o.includes(t)?(r.removeAttribute("data-filtered-out"),r.style.display="",i=!0):(r.setAttribute("data-filtered-out",""),r.style.display="none")}for(let r of this.#s.querySelectorAll('[role="group"]')){let o=r.querySelectorAll('[role="option"]:not([data-filtered-out])').length;r.style.display=o?"":"none"}let n=this.#s.querySelector('[role="option"][data-focused]');n&&n.hasAttribute("data-filtered-out")&&n.removeAttribute("data-focused")}#P(t){if(!this.#s)return;let e=[...this.#s.querySelectorAll('[role="option"]:not([aria-disabled]):not([data-filtered-out])')];if(!e.length)return;let i=this.#s.querySelector('[role="option"][data-focused]'),n=i?e.indexOf(i):-1,r=e[(n+t+e.length)%e.length];i&&i.removeAttribute("data-focused"),r&&(r.setAttribute("data-focused",""),r.scrollIntoView({block:"nearest"}))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#S),this.removeEventListener("keydown",this.#A),this.removeEventListener("remove",this.#f),this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),document.removeEventListener("pointerdown",this.#x),this.#a&&(this.#a.removeEventListener("input",this.#E),this.#a.removeEventListener("focus",this.#l),this.#a.removeEventListener("click",this.#c),this.#a=null),this.#n?.(),this.#n=null,this.#s?.hidePopover?.(),this.#s=null}};S("select-ui",mn);P();var gn=class extends x{static properties={value:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","radio"),this.getAttribute("tabindex")||this.setAttribute("tabindex","-1")}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.setAttribute("aria-checked",this.selected?"true":"false"),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t?.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("aria-hidden","true"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};S("segment-ui",gn);var bn=class s extends M{static properties={...M.properties,value:{type:String,default:"",reflect:!0}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#n=null;#r=null;connected(){if(super.connected(),this.setAttribute("role","radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#h),this.addEventListener("keydown",this.#u)),!this.value){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#l(this.#a)),this.#n.observe(this)),document.fonts?.ready&&(this.#r=document.fonts.ready.then(()=>{this.#r=null,this.#l(this.#a)}))}disconnected(){super.disconnected(),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n?.disconnect(),this.#n=null,this.#r&&(this.#r=null),this.removeEventListener("click",this.#h),this.removeEventListener("keydown",this.#u),this.#e=null,this.#i=!1}get#a(){return[...this.querySelectorAll("segment-ui")]}get#o(){return this.#a.filter(t=>!t.disabled)}render(){if(!s.#t.has(this)){let e=[...this.children].find(i=>i.tagName!=="SEGMENT-UI"&&!i.hasAttribute("data-indicator")&&!(i.tagName==="SPAN"&&i.style.display==="contents"));e&&(s.#t.add(this),console.warn(`[segmented-ui] child <${e.tagName.toLowerCase()}> is not <segment-ui> \u2014 bare <segment> tags render text but receive no sliding indicator or aria-checked state. Use <segment-ui>.`))}let t=this.#a;if(t.length){for(let e of t){let n=(e.value||e.getAttribute("value")||"")===this.value;n?e.setAttribute("selected",""):e.removeAttribute("selected"),e.setAttribute("tabindex",n?"0":"-1")}this.label&&this.setAttribute("aria-label",this.label),this.#l(t)}}#l(t){let e=t.findIndex(n=>(n.value||n.getAttribute("value")||"")===this.value);if(e<0){this.removeAttribute("data-indicator-ready");return}let i=!this.#e||!this.contains(this.#e);if(i){for(let n of this.querySelectorAll(":scope > [data-indicator]"))n.remove();this.#e=document.createElement("span"),this.#e.setAttribute("data-indicator",""),this.prepend(this.#e)}this.style.setProperty("--_segment-count",`${t.length}`),i?(this.#e.style.transition="none",this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""),this.#s=requestAnimationFrame(()=>{this.#s=null,this.#e&&(this.#e.style.transition="")})):(this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""))}#c(t){t.disabled||(this.value=t.value,this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#h=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#c(e)};#u=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;let i=this.#o,n=i.indexOf(e);if(n<0)return;let r;switch(t.key){case"ArrowRight":case"ArrowDown":r=n<i.length-1?n+1:0;break;case"ArrowLeft":case"ArrowUp":r=n>0?n-1:i.length-1;break;case"Home":r=0;break;case"End":r=i.length-1;break;default:return}t.preventDefault(),i[r].focus(),this.#c(i[r])}};S("segmented-ui",bn);var On=class extends M{static labelDeprecated=!1;static properties={...M.properties,value:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:100,reflect:!0},step:{type:Number,default:1,reflect:!0},label:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=0;#n=0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
|
|
130
|
+
`,this.hint&&this.setAttribute("aria-describedby",r);let a=this.querySelector("[data-clear-all]");a&&(a.removeEventListener("click",this.#O),a.addEventListener("click",this.#O)),this.searchable&&(this.#a&&(this.#a.removeEventListener("input",this.#$),this.#a.removeEventListener("focus",this.#l),this.#a.removeEventListener("click",this.#c)),this.#a=this.querySelector('input[slot="display"]'),this.#a&&(this.#a.addEventListener("input",this.#$),this.#a.addEventListener("focus",this.#l),this.#a.addEventListener("click",this.#c))),e&&this.appendChild(e)}this.multiple&&this.#S();let t=this.querySelector("[data-clear-all]");if(t&&(this.multiple&&this.clearable&&this.#u().length>0&&!this.disabled&&!this.readonly?t.removeAttribute("hidden"):t.setAttribute("hidden","")),this.#s||(this.#s=this.querySelector('[slot="listbox"]'),this.#s||(this.#s=document.createElement("div"),this.#s.setAttribute("slot","listbox"),this.#s.setAttribute("role","listbox"),this.#s.setAttribute("popover","manual"),this.appendChild(this.#s)),this.#v()),this.#s){let e=this.multiple?new Set(this.value.split(",").map(i=>i.trim()).filter(Boolean)):null;for(let i of this.#s.querySelectorAll('[role="option"]')){let n=i.getAttribute("data-value");(e?e.has(n):n===this.value)?i.setAttribute("aria-selected","true"):i.removeAttribute("aria-selected")}}if(this.setAttribute("aria-expanded",String(this.open)),this.open){this.#s?.showPopover?.();let e=this.querySelector('[slot="trigger"]')||this;this.#s.style.minWidth=`${e.getBoundingClientRect().width}px`,this.#s.style.width="max-content",this.#n=ct(e,this.#s,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#o=requestAnimationFrame(()=>{this.#o=null,document.addEventListener("pointerdown",this.#E,{once:!0})})}else this.#n?.(),this.#n=null,this.#s?.hidePopover?.(),this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),document.removeEventListener("pointerdown",this.#E)}#w(){this.#i=[];let t=new Set,e=[];for(let i of this.children)if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled}),r.hasAttribute("selected")&&e.push(r.value);this.#i.push(n)}else i.tagName==="OPTION"?(this.#i.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&e.push(i.value)):i.hasAttribute("slot")||t.add(i.tagName.toLowerCase());for(let i of[...this.querySelectorAll("option, optgroup")])i.remove();!this.value&&e.length&&(this.value=this.multiple?e.join(","):e[0]),t.size>0&&!s.#t.has(this)&&(s.#t.add(this),console.warn(`<select-ui>: ignoring unrecognized child element(s) [${[...t].join(", ")}]. Consumer-authored children must be native <option> or <optgroup>, NOT <select-option> or other <*-ui> shapes. Or set element.options = [...] programmatically. (Once-per-element warn; see select.yaml usage: for details.)`))}set options(t){F(()=>{this.#i=t,this.#s||(this.#s=this.querySelector('[slot="listbox"]'),this.#s||(this.#s=document.createElement("div"),this.#s.setAttribute("slot","listbox"),this.#s.setAttribute("role","listbox"),this.#s.setAttribute("popover","manual"),this.appendChild(this.#s))),this.#v();let e=this.querySelector('[slot="display"]');e&&(e.textContent=this.#x())})}get options(){return this.#i}#v(){if(!this.#s)return;if(this.#s.innerHTML="",this.multiple?this.#s.setAttribute("aria-multiselectable","true"):this.#s.removeAttribute("aria-multiselectable"),this.multiple&&this.selectAll){let e=document.createElement("div");e.setAttribute("data-select-all","");let i=document.createElement("button");i.type="button",i.dataset.selectAllBtn="",i.textContent=this.#k()?"Clear":"Select all",i.addEventListener("click",this.#g),e.appendChild(i),this.#s.appendChild(e)}let t=e=>{if(e.separator){let o=document.createElement("hr");return o.setAttribute("data-separator",""),o}let i=document.createElement("div");i.setAttribute("role","option"),i.setAttribute("data-value",e.value||"");let n=this.multiple?new Set(this.value.split(",").map(o=>o.trim()).filter(Boolean)):null,r=n?n.has(e.value):e.value===this.value;if(this.multiple){i.setAttribute("data-multi-option","");let o=document.createElement("span");o.setAttribute("data-checkbox",""),o.innerHTML='<icon-ui name="check" aria-hidden="true"></icon-ui>',i.appendChild(o);let a=document.createElement("span");a.setAttribute("data-option-label",""),e.icon?a.innerHTML=`<icon-ui name="${ye(e.icon)}"></icon-ui>${ye(e.label)}`:a.textContent=e.label,i.appendChild(a)}else e.icon?i.innerHTML=`<icon-ui name="${ye(e.icon)}"></icon-ui>${ye(e.label)}`:i.textContent=e.label;return r&&i.setAttribute("aria-selected","true"),e.disabled&&i.setAttribute("aria-disabled","true"),e.action&&(i.dataset.action=e.action),i.__adiaOption=e,i.addEventListener("click",this.#h),i};for(let e of this.#i)if(e.separator)this.#s.appendChild(t(e));else if(e.header){let i=document.createElement("div");i.setAttribute("data-menu-header",""),i.innerHTML=e.avatar?`<img src="${e.avatar}" alt="" /><div><strong>${ye(e.label)}</strong><span>${ye(e.description||"")}</span></div>`:`<div><strong>${ye(e.label)}</strong><span>${ye(e.description||"")}</span></div>`,this.#s.appendChild(i)}else if(e.options){let i=document.createElement("div");i.setAttribute("role","group"),i.innerHTML=`<div slot="group-label">${ye(e.label)}</div>`;for(let n of e.options)i.appendChild(t(n));this.#s.appendChild(i)}else this.#s.appendChild(t(e));if(this.#i.length===0){let e=document.createElement("div");e.setAttribute("data-empty",""),e.textContent="No options",this.#s.appendChild(e)}this.#r&&this.#L()}#k(){if(!this.multiple)return!1;let t=this.#i.flatMap(i=>i.options||[i]).filter(i=>!i.disabled&&!i.separator&&!i.header&&i.value!=null);if(t.length===0)return!1;let e=new Set(this.#u());return t.every(i=>e.has(String(i.value)))}#S(){let t=this.querySelector('[slot="trigger"] [data-chips]');if(!t)return;let e=this.#u(),i=Number(this.maxChips)||0,n=i>0&&e.length>i?e.slice(0,i):e,r=i>0&&e.length>i?e.length-i:0,o=this.#i.flatMap(l=>l.options||[l]).filter(l=>!l.separator&&!l.header&&l.value!=null),a=l=>{let h=o.find(c=>String(c.value)===String(l));return h?h.label:String(l)};for(;t.firstChild;)t.removeChild(t.firstChild);for(let l of n){let h=document.createElement("tag-ui");h.setAttribute("size","sm"),!this.disabled&&!this.readonly&&h.setAttribute("removable",""),h.dataset.chipValue=String(l),h.setAttribute("text",a(l)),t.appendChild(h)}if(r>0){let l=document.createElement("button");l.type="button",l.dataset.more="",l.textContent=`+${r} more`,l.addEventListener("click",this.#m),t.appendChild(l)}}#x(){return this.multiple?this.value?"":this.placeholder:this.#i.flatMap(i=>i.options||[i]).find(i=>i.value===this.value||i.header&&i.label===this.value)?.label||this.value||this.placeholder}#A=t=>{this.disabled||this.#s&&t.composedPath().includes(this.#s)||(this.open=!this.open)};#E=t=>{!this.contains(t.target)&&!(this.#s&&t.composedPath().includes(this.#s))&&(this.open=!1)};#C=t=>{if(t.key==="Backspace"&&this.multiple&&!this.disabled&&!this.readonly){let e=t.target,i=e&&e.tagName==="INPUT"&&e.getAttribute("slot")==="display",n=!this.#r||this.#r.length===0;if((!i||n)&&this.#u().length>0){t.preventDefault(),this.#p();return}}if(t.key==="Escape"){if(this.searchable&&this.#r){this.#r="";let e=this.querySelector('input[slot="display"]');e&&(e.value=""),this.#L();return}this.open=!1;return}if(t.key==="Enter"){if(t.preventDefault(),this.open){let e=this.#s?.querySelector('[role="option"][data-focused]:not([data-filtered-out])');if(e)e.click(),this.multiple&&(this.open=!1);else if(this.searchable&&this.freeText&&this.#r){let i=this.#r;this.value=i,this.#r="",this.open=!1,this.syncValue?.(i),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}}))}else this.open=!1}else this.open=!0;return}if(t.key===" "&&!this.searchable){if(t.preventDefault(),this.open){let e=this.#s?.querySelector('[role="option"][data-focused]');e?e.click():this.multiple||(this.open=!1)}else this.open=!0;return}t.key==="ArrowDown"&&this.open&&(t.preventDefault(),this.#P(1)),t.key==="ArrowUp"&&this.open&&(t.preventDefault(),this.#P(-1))};#$=t=>{this.#r=t.target.value||"",this.open||(this.open=!0),this.#L()};#L(){if(!this.#s)return;let t=this.#r.toLowerCase(),e=this.#s.querySelectorAll('[role="option"]'),i=!1;for(let r of e){let o=(r.textContent||"").toLowerCase();!t||o.includes(t)?(r.removeAttribute("data-filtered-out"),r.style.display="",i=!0):(r.setAttribute("data-filtered-out",""),r.style.display="none")}for(let r of this.#s.querySelectorAll('[role="group"]')){let o=r.querySelectorAll('[role="option"]:not([data-filtered-out])').length;r.style.display=o?"":"none"}let n=this.#s.querySelector('[role="option"][data-focused]');n&&n.hasAttribute("data-filtered-out")&&n.removeAttribute("data-focused")}#P(t){if(!this.#s)return;let e=[...this.#s.querySelectorAll('[role="option"]:not([aria-disabled]):not([data-filtered-out])')];if(!e.length)return;let i=this.#s.querySelector('[role="option"][data-focused]'),n=i?e.indexOf(i):-1,r=e[(n+t+e.length)%e.length];i&&i.removeAttribute("data-focused"),r&&(r.setAttribute("data-focused",""),r.scrollIntoView({block:"nearest"}))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#A),this.removeEventListener("keydown",this.#C),this.removeEventListener("remove",this.#f),this.#o!=null&&(cancelAnimationFrame(this.#o),this.#o=null),document.removeEventListener("pointerdown",this.#E),this.#a&&(this.#a.removeEventListener("input",this.#$),this.#a.removeEventListener("focus",this.#l),this.#a.removeEventListener("click",this.#c),this.#a=null),this.#n?.(),this.#n=null,this.#s?.hidePopover?.(),this.#s=null}};S("select-ui",mn);P();var gn=class extends x{static properties={value:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","radio"),this.getAttribute("tabindex")||this.setAttribute("tabindex","-1")}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.setAttribute("aria-checked",this.selected?"true":"false"),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.icon){let t=this.querySelector(":scope > icon-ui");if(!t||t.getAttribute("name")!==this.icon){t?.remove();let e=document.createElement("icon-ui");e.setAttribute("name",this.icon),e.setAttribute("aria-hidden","true"),this.prepend(e)}}else this.querySelector(":scope > icon-ui")?.remove()}};S("segment-ui",gn);var bn=class s extends M{static properties={...M.properties,value:{type:String,default:"",reflect:!0}};static template=()=>null;static#t=new WeakSet;#e=null;#i=!1;#s=null;#n=null;#r=null;connected(){if(super.connected(),this.setAttribute("role","radiogroup"),this.#i||(this.#i=!0,this.addEventListener("click",this.#h),this.addEventListener("keydown",this.#u)),!this.value){let t=this.querySelector("segment-ui:not([disabled])");t&&(this.value=t.value||t.getAttribute("value")||"")}typeof ResizeObserver<"u"&&(this.#n=new ResizeObserver(()=>this.#l(this.#a)),this.#n.observe(this)),document.fonts?.ready&&(this.#r=document.fonts.ready.then(()=>{this.#r=null,this.#l(this.#a)}))}disconnected(){super.disconnected(),this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n?.disconnect(),this.#n=null,this.#r&&(this.#r=null),this.removeEventListener("click",this.#h),this.removeEventListener("keydown",this.#u),this.#e=null,this.#i=!1}get#a(){return[...this.querySelectorAll("segment-ui")]}get#o(){return this.#a.filter(t=>!t.disabled)}render(){if(!s.#t.has(this)){let e=[...this.children].find(i=>i.tagName!=="SEGMENT-UI"&&!i.hasAttribute("data-indicator")&&!(i.tagName==="SPAN"&&i.style.display==="contents"));e&&(s.#t.add(this),console.warn(`[segmented-ui] child <${e.tagName.toLowerCase()}> is not <segment-ui> \u2014 bare <segment> tags render text but receive no sliding indicator or aria-checked state. Use <segment-ui>.`))}let t=this.#a;if(t.length){for(let e of t){let n=(e.value||e.getAttribute("value")||"")===this.value;n?e.setAttribute("selected",""):e.removeAttribute("selected"),e.setAttribute("tabindex",n?"0":"-1")}this.label&&this.setAttribute("aria-label",this.label),this.#l(t)}}#l(t){let e=t.findIndex(n=>(n.value||n.getAttribute("value")||"")===this.value);if(e<0){this.removeAttribute("data-indicator-ready");return}let i=!this.#e||!this.contains(this.#e);if(i){for(let n of this.querySelectorAll(":scope > [data-indicator]"))n.remove();this.#e=document.createElement("span"),this.#e.setAttribute("data-indicator",""),this.prepend(this.#e)}this.style.setProperty("--_segment-count",`${t.length}`),i?(this.#e.style.transition="none",this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""),this.#s=requestAnimationFrame(()=>{this.#s=null,this.#e&&(this.#e.style.transition="")})):(this.#e.style.transform=`translateX(${e*100}%)`,this.setAttribute("data-indicator-ready",""))}#c(t){t.disabled||(this.value=t.value,this.syncValue(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})))}#h=t=>{let e=t.target.closest("segment-ui");e&&this.contains(e)&&this.#c(e)};#u=t=>{let e=t.target;if(e.tagName!=="SEGMENT-UI")return;let i=this.#o,n=i.indexOf(e);if(n<0)return;let r;switch(t.key){case"ArrowRight":case"ArrowDown":r=n<i.length-1?n+1:0;break;case"ArrowLeft":case"ArrowUp":r=n>0?n-1:i.length-1;break;case"Home":r=0;break;case"End":r=i.length-1;break;default:return}t.preventDefault(),i[r].focus(),this.#c(i[r])}};S("segmented-ui",bn);var On=class extends M{static labelDeprecated=!1;static properties={...M.properties,value:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},max:{type:Number,default:100,reflect:!0},step:{type:Number,default:1,reflect:!0},label:{type:String,default:"",reflect:!0},suffix:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=0;#n=0;connected(){if(super.connected(),this.setAttribute("role","spinbutton"),this.setAttribute("tabindex","0"),!this.querySelector('[slot="field"]')){let t=`
|
|
131
131
|
<span slot="label">${this.label}</span>
|
|
132
132
|
<span slot="value">${this.#r(this.value)}</span>
|
|
133
133
|
${this.suffix?`<span slot="suffix">${this.suffix}</span>`:""}
|
|
@@ -172,8 +172,8 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
172
172
|
${t.icon?`<icon-ui name="${t.icon}"></icon-ui>`:""}
|
|
173
173
|
<span data-text>${t.label}</span>
|
|
174
174
|
${t.shortcut?`<span data-shortcut>${t.shortcut}</span>`:""}
|
|
175
|
-
`,this.#l.set(i,t),i}#b(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#y(t){let e=this.#n.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#n.querySelector("[data-active]");i&&i.removeAttribute("data-active");let n=[...e].find(r=>parseInt(r.dataset.idx)===t);n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#i=t)}#w(t){let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#n.querySelector("[data-active]"),r=(i?e.indexOf(i):-1)+t;r<0&&(r=e.length-1),r>=e.length&&(r=0),this.#y(parseInt(e[r].dataset.idx))}#v(t){this.#O(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#k(){let t=this.#n.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",r=(this.#l.get(t)||this.#m(e))?.category||"";this.#O(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:r}}))}#S=()=>{this.#f(this.#s.value)};#x=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#w(1);break;case"ArrowUp":t.preventDefault(),this.#w(-1);break;case"Enter":t.preventDefault(),this.#k();break;case"Tab":t.preventDefault(),this.#k();break;case"Escape":t.preventDefault(),this.dispatchEvent(new Event("dismiss",{bubbles:!0}));break}};disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),this.removeEventListener("keydown",this.#x),this.#s?.removeEventListener("input",this.#S),this.#n?.removeEventListener("click",this.#h),this.#n?.removeEventListener("pointerover",this.#u),this.#s=null,this.#n=null,this.#a=null,this.#o=!1}};S("command-ui",Ln);var Ca=.4;function Dd(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function qd(s,t,e){let i=s+.3963377774*t+.2158037573*e,n=s-.1055613458*t-.0638541728*e,r=s-.0894841775*t-1.291485548*e,o=i*i*i,a=n*n*n,l=r*r*r;return[4.0767416621*o-3.3077115913*a+.2309699292*l,-1.2684380046*o+2.6097574011*a-.3413193965*l,-.0041960863*o-.7034186147*a+1.707614701*l]}function ui(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function Xd(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function GO(s,t,e){let{a:i,b:n}=Dd(s,t,e),[r,o,a]=qd(s,i,n);return[Math.max(0,Math.min(1,ui(r))),Math.max(0,Math.min(1,ui(o))),Math.max(0,Math.min(1,ui(a)))]}function lC(s,t,e){let i=n=>Math.round(n*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Mn(s,t,e){let[i,n,r]=GO(s,t,e);return lC(i,n,r)}function hC(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=Xd(parseInt(s.slice(0,2),16)/255),e=Xd(parseInt(s.slice(2,4),16)/255),i=Xd(parseInt(s.slice(4,6),16)/255),n=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*i),r=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*i),o=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*i),a=.2104542553*n+.793617785*r-.0040720468*o,l=1.9779984951*n-2.428592205*r+.4505937099*o,h=.0259040371*n+.7827717662*r-.808675766*o,c=Math.sqrt(l*l+h*h),u=Math.atan2(h,l)*180/Math.PI;return u<0&&(u+=360),{L:a,C:c,H:u}}function KO(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function $a(s,t,e){let{a:i,b:n}=Dd(s,t,e),[r,o,a]=qd(s,i,n);if(KO(ui(r),ui(o),ui(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=Dd(s,u,e),[p,m,b]=qd(s,d,f);KO(ui(p),ui(m),ui(b))?l=u:h=u}return l}var Rn=class s extends M{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={...M.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0,attribute:"max-chroma"},maxL:{type:Number,default:1,reflect:!0,attribute:"max-l"},minL:{type:Number,default:0,reflect:!0,attribute:"min-l"},hueDriftMax:{type:Number,default:NaN,reflect:!0,attribute:"hue-drift-max"},baseHue:{type:Number,default:NaN,reflect:!0,attribute:"base-hue"}};#e=.6;#i=.15;#s=230;#n=NaN;#r=!1;#a=null;#o=!1;#l=null;#c=null;#h=null;#u=null;#d=null;#p=null;#f=null;#m=null;#O=null;#g=null;#b=null;#y=null;#w=[];#v=null;static template=()=>null;#k=t=>{let e=t.currentTarget,i=e.getAttribute("data-channel");i==="hue"?this.#s=+e.value:i==="chroma"?this.#i=+e.value:i==="lightness"&&(this.#e=+e.value),this.#L("input")};#S=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#q(t))};#x=t=>{this.#a==="area"&&this.#q(t)};#A=()=>{this.#a==="area"&&(this.#a=null,this.#L("change"))};#E=t=>{this.disabled||(this.#a="hue",this.#d.setPointerCapture(t.pointerId),this.#Q(t))};#C=t=>{this.#a==="hue"&&this.#Q(t)};#P=()=>{this.#a==="hue"&&(this.#a=null,this.#L("change"))};#R=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(Ca,this.#i+i);break;case"ArrowLeft":t.preventDefault(),this.#i=Math.max(0,this.#i-i);break;case"ArrowUp":t.preventDefault(),this.#e=Math.min(1,this.#e+e);break;case"ArrowDown":t.preventDefault(),this.#e=Math.max(0,this.#e-e);break;default:return}this.#L("change")};#T=t=>{if(this.disabled)return;let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#s=(this.#s+e)%360;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#s=(this.#s-e+360)%360;break;default:return}this.#L("change")};connected(){if(super.connected(),this.#N(this.value),this.#r)return;this.#r=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#u=document.createElement("div"),this.#u.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#u),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(r,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",r),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#k),t.appendChild(c),c};this.#g=e("H","hue",0,360,1),this.#b=e("C","chroma",0,Ca,.001),this.#y=e("L","lightness",0,1,.001),this.appendChild(t),this.#d=document.createElement("div"),this.#d.setAttribute("data-hue-track",""),this.#d.setAttribute("tabindex","0"),this.#d.setAttribute("role","slider"),this.#d.setAttribute("aria-label","Hue"),this.#p=document.createElement("div"),this.#p.setAttribute("data-hue-thumb",""),this.#d.appendChild(this.#p),this.appendChild(this.#d);let i=document.createElement("div");i.setAttribute("data-output","");let n=r=>{let o=document.createElement("div");o.setAttribute("data-output-group","");let a=document.createElement("span");a.setAttribute("data-output-value",""),a.setAttribute("data-format",r);let l=document.createElement("div");l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-copy",r),l.setAttribute("aria-label",`Copy ${r}`),l.innerHTML='<icon-ui name="copy"></icon-ui>';let h=()=>this.#D(r,l);return l.addEventListener("click",h),this.#w.push({el:l,handler:h}),o.appendChild(a),o.appendChild(l),i.appendChild(o),a};this.#f=n("oklch"),this.#m=n("hex"),this.appendChild(i),this.#h.addEventListener("pointerdown",this.#S),this.#h.addEventListener("pointermove",this.#x),this.#h.addEventListener("pointerup",this.#A),this.#d.addEventListener("pointerdown",this.#E),this.#d.addEventListener("pointermove",this.#C),this.#d.addEventListener("pointerup",this.#P),this.#h.addEventListener("keydown",this.#R),this.#d.addEventListener("keydown",this.#T),this.#O=new ResizeObserver(()=>this.#I()),this.#O.observe(this.#h)}disconnected(){super.disconnected(),this.#v!=null&&(clearTimeout(this.#v),this.#v=null),this.#O&&(this.#O.disconnect(),this.#O=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#S),this.#h.removeEventListener("pointermove",this.#x),this.#h.removeEventListener("pointerup",this.#A),this.#h.removeEventListener("keydown",this.#R)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#E),this.#d.removeEventListener("pointermove",this.#C),this.#d.removeEventListener("pointerup",this.#P),this.#d.removeEventListener("keydown",this.#T)),this.#g?.removeEventListener("input",this.#k),this.#b?.removeEventListener("input",this.#k),this.#y?.removeEventListener("input",this.#k);for(let{el:t,handler:e}of this.#w)t.removeEventListener("click",e);this.#w=[],this.#r=!1}#q(t){let e=this.#h.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),n=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.#i=i*Ca,this.#e=1-n,this.#L("input")}#Q(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#L("input")}#N(t){if(t){if(t.startsWith("#")){let e=hC(t);this.#e=e.L,this.#i=e.C,this.#s=e.H;return}if(t.startsWith("oklch(")){let e=t.match(/oklch\(\s*([\d.]+%?|NaN|none)\s+([\d.]+%?|NaN|none)\s+([\d.]+|NaN|none)/i);if(e){let i=(n,r)=>n==="none"||/^NaN$/i.test(n)?0:r&&n.endsWith("%")||n.endsWith("%")?+n.slice(0,-1)/100:+n;this.#e=i(e[1],!0),this.#i=i(e[2],!1),this.#s=i(e[3],!1);return}s.#t.has(this)||(s.#t.add(this),console.warn(`<color-picker-ui>: could not parse value=${JSON.stringify(t)}. Expected #rrggbb or oklch(L C H) with numeric, NaN, 'none' (CSS L4 powerless), or % channels. Picker is keeping prior state.`))}}}#L(t){let e=[];if(this.#e>this.maxL&&(e.push({axis:"l",requested:this.#e,clamped:this.maxL,reason:"max-l"}),this.#e=this.maxL),this.#e<this.minL&&(e.push({axis:"l",requested:this.#e,clamped:this.minL,reason:"min-l"}),this.#e=this.minL),this.#i>this.maxChroma&&(e.push({axis:"c",requested:this.#i,clamped:this.maxChroma,reason:"max-chroma"}),this.#i=this.maxChroma),Number.isFinite(this.hueDriftMax)){let a=Number.isFinite(this.baseHue)?this.baseHue:Number.isFinite(this.#n)?this.#n:this.#s;Number.isFinite(this.#n)||(this.#n=a);let l=(this.#s-a+540)%360-180,h=this.hueDriftMax;if(l>h){let c=this.#s;this.#s=(a+h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}else if(l<-h){let c=this.#s;this.#s=(a-h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}}let i=$a(this.#e,this.#i,this.#s),n=Mn(this.#e,i,this.#s),r=this.#$();this.#o=!0,this.value=this.format==="oklch"?r:n,this.syncValue(),e.length&&this.dispatchEvent(new CustomEvent("constraint-clamp",{bubbles:!0,detail:{clamps:e}}));let o={value:this.value,l:this.#e,c:this.#i,h:this.#s,hex:n,oklch:r};this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}#$(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#D(t,e){let i=t==="oklch"?this.#$():Mn(this.#e,$a(this.#e,this.#i,this.#s),this.#s),n=e.querySelector("icon-ui"),r=o=>{n&&(n.setAttribute("name",o?"check":"warning"),this.#v!=null&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,n.setAttribute("name","copy")},1500))};if(navigator.clipboard?.writeText)navigator.clipboard.writeText(i).then(()=>{this.isConnected&&r(!0)},()=>{this.isConnected&&r(!1)});else{let o=Object.assign(document.createElement("textarea"),{value:i});o.style.cssText="position:fixed;opacity:0",document.body.appendChild(o),o.select(),r(document.execCommand("copy")),o.remove()}}#I(){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 n=this.#c.createImageData(e,i),r=n.data,o=this.#s;for(let a=0;a<i;a++){let l=1-a/(i-1);for(let h=0;h<e;h++){let c=h/(e-1)*Ca,u=$a(l,c,o),[d,f,p]=GO(l,u,o),m=(a*e+h)*4;r[m]=Math.round(d*255),r[m+1]=Math.round(f*255),r[m+2]=Math.round(p*255),r[m+3]=255}}this.#c.putImageData(n,0,0)}render(){if(this.#o?this.#o=!1:this.#N(this.value),this.#I(),this.#u){let r=this.#i/Ca*100,o=(1-this.#e)*100;this.#u.style.left=`${r}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Mn(this.#e,$a(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let r=[];for(let o=0;o<=360;o+=30)r.push(Mn(.7,.15,o));this.#d.style.background=`linear-gradient(to right, ${r.join(", ")})`,this.#d.setAttribute("aria-valuenow",String(Math.round(this.#s)))}this.#p&&(this.#p.style.left=`${this.#s/360*100}%`,this.#p.style.background=Mn(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#$());let t=this.querySelector('slider-ui[data-channel="hue"]'),e=this.querySelector('slider-ui[data-channel="chroma"]'),i=this.querySelector('slider-ui[data-channel="lightness"]');t&&(t.value=Math.round(this.#s)),e&&(e.value=+this.#i.toFixed(3)),i&&(i.value=+this.#e.toFixed(3)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");let n=Mn(this.#e,$a(this.#e,this.#i,this.#s),this.#s);this.#f&&(this.#f.textContent=this.#$()),this.#m&&(this.#m.textContent=n)}onFormReset(){this.value="#3b82f6"}};S("color-picker-ui",Rn);var In=class extends M{static get properties(){return{...M.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0},maxL:{type:Number,default:1,reflect:!0},minL:{type:Number,default:0,reflect:!0},hueDriftMax:{type:Number,default:NaN,reflect:!0},baseHue:{type:Number,default:NaN,reflect:!0}}}#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#a=null;connected(){this.#o(),this.#l(),this.#d(),this.syncValue(this.value)}render(){this.#d(),this.#t&&this.#t.open!==this.open&&(this.#t.open=this.open),this.#i&&(this.#i.format!==this.format&&(this.#i.format=this.format),Object.is(this.#i.maxChroma,this.maxChroma)||(this.#i.maxChroma=this.maxChroma),Object.is(this.#i.maxL,this.maxL)||(this.#i.maxL=this.maxL),Object.is(this.#i.minL,this.minL)||(this.#i.minL=this.minL),Object.is(this.#i.hueDriftMax,this.hueDriftMax)||(this.#i.hueDriftMax=this.hueDriftMax),Object.is(this.#i.baseHue,this.baseHue)||(this.#i.baseHue=this.baseHue)),this.#e&&(this.disabled?this.#e.setAttribute("disabled",""):this.#e.removeAttribute("disabled"))}showPicker(){this.open=!0}hidePicker(){this.open=!1}#o(){if(this.firstElementChild&&(this.#t=this.querySelector(":scope > popover-ui"),this.#e=this.querySelector(':scope > popover-ui > button-ui[slot="trigger"]'),this.#i=this.querySelector(':scope > popover-ui > color-picker-ui[slot="content"]'),this.#s=this.querySelector(".color-input__swatch"),this.#n=this.querySelector(".color-input__value"),this.#t&&this.#e&&this.#i))return;let t=document.createElement("popover-ui");t.setAttribute("trigger","click"),t.setAttribute("placement",this.placement);let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("variant","outline"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-label",this.getAttribute("aria-label")||"Pick a color");let i=document.createElement("span");i.className="color-input__swatch",i.setAttribute("aria-hidden","true");let n=document.createElement("span");n.className="color-input__value",e.append(i,n);let r=document.createElement("color-picker-ui");r.setAttribute("slot","content"),r.setAttribute("format",this.format),r.setAttribute("value",this.value),r.maxChroma=this.maxChroma,r.maxL=this.maxL,r.minL=this.minL,r.hueDriftMax=this.hueDriftMax,r.baseHue=this.baseHue,t.append(e,r),this.append(t),this.#t=t,this.#e=e,this.#i=r,this.#s=i,this.#n=n}#l(){if(this.#r)return;this.#r=!0,this.#i.addEventListener("change",this.#c),this.#i.addEventListener("input",this.#h);let t=()=>{let e=!!this.#t?.open;this.open!==e&&(this.open=e)};this.#t.addEventListener("toggle",t),this.#a=new MutationObserver(t),this.#a.observe(this.#t,{attributes:!0,attributeFilter:["open"]})}#c=t=>{this.#u(t.detail,"change")};#h=t=>{this.#u(t.detail,"input")};#u(t,e){if(!t)return;let i=this.format==="oklch"?t.oklch:t.hex;i&&i!==this.value&&(this.value=i,this.syncValue(i)),this.#d(),this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:{value:i??this.value,hex:t.hex,oklch:t.oklch,l:t.l,c:t.c,h:t.h}}))}#d(){this.#s&&this.#s.style.setProperty("--swatch-color",this.value),this.#n&&(this.#n.textContent=this.value)}disconnected(){this.#i?.removeEventListener("change",this.#c),this.#i?.removeEventListener("input",this.#h),this.#a?.disconnect(),this.#a=null,this.#r=!1}};S("color-input-ui",In);P();var Nd=0,Dn=class extends x{static properties={editable:{type:Boolean,default:!1,reflect:!0},color:{type:String,default:"",reflect:!0},strokeWidth:{type:Number,default:2,reflect:!0,attribute:"stroke-width"},tension:{type:Number,default:.5,reflect:!0},showPorts:{type:Boolean,default:!1,reflect:!0,attribute:"show-ports"},portSize:{type:Number,default:10,attribute:"port-size",reflect:!0},curve:{type:String,default:"bezier",reflect:!0},animated:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=[];#i=new Map;#s=null;#n=null;#r=null;#a=!1;#o=null;#l=null;#c=null;get connections(){return this.#e.map(t=>({...t}))}connect(t,e,i="right",n="left"){let r=`noodle-${++Nd}`,o={id:r,from:t,to:e,fromPort:i,toPort:n};return this.#e.push(o),this.#h(),this.dispatchEvent(new CustomEvent("noodle-connect",{bubbles:!0,detail:{...o}})),r}disconnect(t){let e=this.#e.findIndex(n=>n.id===t);if(e===-1)return;let[i]=this.#e.splice(e,1);this.#h(),this.dispatchEvent(new CustomEvent("noodle-disconnect",{bubbles:!0,detail:{...i}}))}setConnections(t){this.#e=t.map(e=>({id:e.id||`noodle-${++Nd}`,from:e.from,to:e.to,fromPort:e.fromPort||"right",toPort:e.toPort||"left"})),this.#h()}clear(){this.#e=[],this.#h()}update(){this.#p()}connected(){this.#t=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#t.setAttribute("data-noodle-svg",""),this.prepend(this.#t),this.#s=new ResizeObserver(()=>this.#h()),this.#n=new MutationObserver(()=>{this.#k(),this.#h()}),this.#s.observe(this),this.#u();for(let t of this.#m())this.#s.observe(t);this.#k(),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.#n?.disconnect(),this.#r&&cancelAnimationFrame(this.#r),this.#r=null,this.#S(),this.#t?.remove(),this.#t=null,this.#a=!1}#h(){this.#r||(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#p()}))}#u(){this.#n?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-noodle-port","style"]})}#d(){this.#n?.disconnect()}#p(){if(!this.#t)return;this.#d();let t=this.#m();for(let r of t)this.#s.observe(r);this.#x();let e=this.#e.map(r=>{let o=this.#f(r.from),a=this.#f(r.to);if(!o||!a)return null;let l=this.#O(o,r.fromPort),h=this.#O(a,r.toPort);return!l||!h?null:{id:r.id,d:this.#g(l,h,r.fromPort,r.toPort)}}).filter(Boolean),i=new Map;for(let r of this.#t.querySelectorAll("path[data-noodle-id]"))i.set(r.getAttribute("data-noodle-id"),r);let n=new Set(e.map(r=>r.id));for(let[r,o]of i)n.has(r)||o.remove();for(let{id:r,d:o}of e){let a=i.get(r);a||(a=document.createElementNS("http://www.w3.org/2000/svg","path"),a.setAttribute("data-noodle-id",r),this.#t.appendChild(a)),a.setAttribute("d",o),a.setAttribute("stroke-width",this.strokeWidth)}if(this.#o&&this.#l){let r=this.#t.querySelector("path[data-noodle-preview]");r||(r=document.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("data-noodle-preview",""),r.style.opacity="0.5",r.style.strokeDasharray="6 3",this.#t.appendChild(r)),r.setAttribute("d",this.#l),r.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#u()}#f(t){return t instanceof HTMLElement?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#m()[t]??null:null}#m(){return[...this.querySelectorAll("[data-noodle-port]")]}#O(t,e){let i=t.getBoundingClientRect(),n=this.getBoundingClientRect(),r=this.offsetWidth&&n.width?n.width/this.offsetWidth:1,o=(i.left-n.left)/r,a=(i.top-n.top)/r,l=i.width/r,h=i.height/r;switch(e){case"left":return{x:o,y:a+h/2};case"right":return{x:o+l,y:a+h/2};case"top":return{x:o+l/2,y:a};case"bottom":return{x:o+l/2,y:a+h};default:return{x:o+l/2,y:a+h/2}}}#g(t,e,i,n){switch(this.curve){case"step":return this.#w(t,e);case"straight":return this.#v(t,e);default:return this.#b(t,e,i,n)}}#b(t,e,i,n){let r=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(r*r+o*o),l=Math.max(50,a*this.tension),h=this.#y(t,i,l),c=this.#y(e,n,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#y(t,e,i){switch(e){case"left":return{x:t.x-i,y:t.y};case"right":return{x:t.x+i,y:t.y};case"top":return{x:t.x,y:t.y-i};case"bottom":return{x:t.x,y:t.y+i};default:return{x:t.x+i,y:t.y}}}#w(t,e){let i=(t.x+e.x)/2;return`M ${t.x} ${t.y} L ${i} ${t.y} L ${i} ${e.y} L ${e.x} ${e.y}`}#v(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#k(){this.#d(),this.#S();let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#A(e,n),o=document.createElement("div");o.setAttribute("data-noodle-port-indicator",""),o.setAttribute("data-noodle-side",n),o.dataset.portElement=e.id||"",this.editable&&o.addEventListener("pointerdown",a=>this.#E(a,e,n)),this.appendChild(o),this.#i.set(r,o)}}this.#x(),this.#u()}#S(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#x(){let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#A(e,n),o=this.#i.get(r);if(!o)continue;let a=this.#O(e,n);o.style.left=`${a.x}px`,o.style.top=`${a.y}px`}}}#A(t,e){return t._noodleId||(t._noodleId=`_n${++Nd}`),`${t._noodleId}:${e}`}#E=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget;n.setPointerCapture(t.pointerId),n.setAttribute("data-noodle-dragging","");let r=this.#O(e,i),o=l=>{if(!this.#o)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#g(r,{x:c,y:u},i,this.#C(r,{x:c,y:u})),this.#h(),this.#P(l.clientX,l.clientY,e),this.dispatchEvent(new CustomEvent("noodle-drag",{bubbles:!0,detail:{from:e,fromPort:i,x:c,y:u}}))},a=l=>{try{n.releasePointerCapture(l.pointerId)}catch{}if(n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),l.type==="pointerup"&&l.clientX!==void 0){let h=this.#R(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#T(),this.#o=null,this.#l=null,this.#c=null,this.#h()};this.#c=()=>{this.#o=null,n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),this.#T(),this.#l=null,this.#c=null},this.#o={fromEl:e,fromSide:i,startPos:r,pointerId:t.pointerId},this.#l=null,n.addEventListener("pointermove",o),n.addEventListener("pointerup",a)};#C(t,e){let i=e.x-t.x,n=e.y-t.y;return Math.abs(i)>Math.abs(n)?i>0?"left":"right":n>0?"top":"bottom"}#P(t,e,i){this.#T();let n=this.#R(t,e,i);n?.dot&&n.dot.setAttribute("data-noodle-drop-ready","")}#R(t,e,i){let n=this.portSize*2,r=null,o=1/0;for(let[a,l]of this.#i){let h=l.getBoundingClientRect(),c=h.left+h.width/2,u=h.top+h.height/2,d=Math.sqrt((t-c)**2+(e-u)**2),[f,p]=a.split(":"),m=this.#m().find(b=>b._noodleId===f);!m||m===i||d<n&&d<o&&(o=d,r={el:m,side:p,dot:l})}return r}#T(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};S("noodles-ui",Dn);var Xi={};function ve(s,t){Xi[s]=t}function qn(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 Zd={basic:(s,t)=>s<t?-1:s>t?1:0,alphanumeric:(s,t)=>String(s??"").localeCompare(String(t??""),void 0,{numeric:!0,sensitivity:"base"}),numeric:(s,t)=>(Number(s)||0)-(Number(t)||0),datetime:(s,t)=>new Date(s||0).getTime()-new Date(t||0).getTime()};ve("text",{render(s,t,e){qn(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("number",{render(s,t,e){qn(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),ve("currency",{render(s,t,e,i){qn(e,s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:i?.currency||"USD"}).format(s):"")},format(s,t,e){return s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:e?.currency||"USD"}).format(s):""},align:"right",sortFn:"numeric"}),ve("percent",{render(s,t,e){qn(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var JO={year:"numeric",month:"short",day:"numeric"};ve("date",{render(s,t,e){qn(e,s?new Intl.DateTimeFormat("en-US",JO).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",JO).format(new Date(s)):""},align:"left",sortFn:"datetime"});var ty={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};ve("datetime",{render(s,t,e){qn(e,s?new Intl.DateTimeFormat("en-US",ty).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",ty).format(new Date(s)):""},align:"left",sortFn:"datetime"}),ve("boolean",{render(s,t,e){let i=e.querySelector("check-ui");i||(e.textContent="",i=document.createElement("check-ui"),i.setAttribute("disabled",""),e.appendChild(i)),s?i.setAttribute("checked",""):i.removeAttribute("checked")},format(s){return s?"Yes":"No"},align:"center",sortFn:"basic"}),ve("badge",{render(s,t,e,i){let n=e.querySelector("badge-ui");n||(e.textContent="",n=document.createElement("badge-ui"),e.appendChild(n)),n.setAttribute("text",String(s??""));let r=i?.variants||{};n.setAttribute("variant",r[s]||"neutral")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("avatar",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("avatar-ui");o.setAttribute("size","sm");let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("avatar-ui"),r=i.querySelector("span");n.setAttribute("text",String(s??"")),r.textContent=String(s??""),e.title=String(s??"")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("link",{render(s,t,e,i){let n=e.querySelector("a");n||(e.textContent="",n=document.createElement("a"),n.style.color="var(--table-accent, var(--a-primary))",n.style.textDecoration="none",e.appendChild(n));let r=String(s??""),o=r.includes("@")&&!r.startsWith("http");n.href=o?`mailto:${r}`:r,n.textContent=i?.label??r},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("progress",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("progress-ui");o.setAttribute("size","sm"),o.style.flex="1";let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("progress-ui"),r=i.querySelector("span");n.setAttribute("value",s!=null?String(s):"0"),r.textContent=s!=null?`${s}%`:""},format(s){return s!=null?`${s}%`:""},align:"left",sortFn:"numeric"}),ve("actions",{render(s,t,e,i){let n=i?.actions||[],r=e.querySelector("row-ui");if(r&&r.children.length!==n.length&&(r.remove(),r=null),!r){e.textContent="",r=document.createElement("row-ui"),r.setAttribute("gap","1");for(let o of n){let a=document.createElement("button-ui");a.setAttribute("icon",o.icon||""),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label",o.label||""),a.addEventListener("click",()=>{a.dispatchEvent(new CustomEvent(o.event,{bubbles:!0,detail:{row:t}}))}),r.appendChild(a)}e.appendChild(r)}},format(){return""},align:"center",sortFn:null});P();function cC(s,t){if(!t||!s)return;let e=t.split("."),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function di(s,t){return typeof t.accessor=="function"?t.accessor(s):cC(s,t.key)}function yh(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
|
|
176
|
-
`)?'"'+t.replace(/"/g,'""')+'"':t}var Xn=class extends x{static requiredIcons=["caret-right","caret-up-down","table","arrow-up","arrow-down","funnel-simple","funnel-simple-fill"];static properties={sortable:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},expandable:{type:Boolean,default:!1,reflect:!0},striped:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},density:{type:String,default:"standard",reflect:!0},paginate:{type:Number,default:0,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},search:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=new Map;#n=new Set;#r=null;#a=0;#o=new Set;#l=new Map;#c=null;#h=!1;#u=-1;#d=null;#p=null;set columns(t){this.#t=Array.isArray(t)?t:[],this.#b()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#o.clear(),this.#a=0,this.#b()}get data(){return this.#e}get selected(){return[...this.#o].sort((t,e)=>t-e)}set selected(t){if(this.#o.clear(),t)for(let e of t)Number.isInteger(e)&&e>=0&&e<this.#e.length&&this.#o.add(e);this.#b(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#o.size!==0&&(this.#o.clear(),this.#b(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:[]},bubbles:!0})))}get sortState(){return this.#i.map(t=>({...t}))}setFilter(t,e,i="contains"){e==null||e===""?this.#s.delete(t):this.#s.set(t,{op:i,value:e}),this.#a=0,this.#b(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#d=null,this.#a=0,this.#b(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}toggleExpand(t){this.#n.has(t)?(this.#n.delete(t),this.dispatchEvent(new CustomEvent("row-collapse",{detail:{index:t,row:this.#e[t]},bubbles:!0}))):(this.#n.add(t),this.dispatchEvent(new CustomEvent("row-expand",{detail:{index:t,row:this.#e[t]},bubbles:!0}))),this.#b()}get expanded(){return[...this.#n]}expandRenderer=null;getState(){return{sort:this.#i.map(t=>({...t})),filters:Object.fromEntries(this.#s),columnWidths:Object.fromEntries(this.#l),hiddenColumns:this.#t.filter(t=>t.hidden).map(t=>t.key),page:this.#a,density:this.density}}setState(t){if(t){if(t.sort&&(this.#i=t.sort),t.filters){this.#s.clear();for(let[e,i]of Object.entries(t.filters))this.#s.set(e,i)}if(t.columnWidths){this.#l.clear();for(let[e,i]of Object.entries(t.columnWidths))this.#l.set(e,i)}if(t.hiddenColumns)for(let e of this.#t)e.hidden=t.hiddenColumns.includes(e.key);t.page!=null&&(this.#a=t.page),t.density&&(this.density=t.density),this.#b()}}#f(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#m(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){this.#O(),this.setAttribute("role","grid"),this.setAttribute("tabindex","0"),this.#m(),this.#h||(this.#h=!0,this.addEventListener("click",this.#N),this.addEventListener("keydown",this.#_),this.addEventListener("pointerdown",this.#Q))}disconnected(){this.removeEventListener("click",this.#N),this.removeEventListener("keydown",this.#_),this.removeEventListener("pointerdown",this.#Q),this.#h=!1,this.#M(),this.#g&&(cancelAnimationFrame(this.#g),this.#g=null),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null)}#O(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let n={key:i.getAttribute("key")||"",label:i.getAttribute("label")||i.getAttribute("key")||"",type:i.getAttribute("type")||"text",pinned:i.getAttribute("pinned")||null,hidden:i.hasAttribute("hidden"),sortable:i.hasAttribute("sortable"),resizable:i.hasAttribute("resizable"),filterable:i.hasAttribute("filterable"),filterType:i.getAttribute("filter-type")||null},r=i.getAttribute("width");r&&(n.width=Number(r));let o=i.getAttribute("min-width");o&&(n.minWidth=Number(o));let a=i.getAttribute("max-width");a&&(n.maxWidth=Number(a));let l=i.getAttribute("flex");l&&(n.flex=Number(l)),e.push(n),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#g=null;#b(){!this.isConnected||this.#g||(this.#g=requestAnimationFrame(()=>{this.#g=null,this.render(),this.#f()}))}get#y(){return this.#t.filter(t=>!t.hidden)}#w(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#y)this.#l.has(e.key)?t.push(`${this.#l.get(e.key)}px`):e.width?t.push(`${e.width}px`):e.flex?t.push(`minmax(6rem, ${e.flex}fr)`):t.push("minmax(6rem, 1fr)");return t.join(" ")}#v(){let t=this.#e.map((e,i)=>i);if(this.search){let e=this.search.toLowerCase();t=t.filter(i=>{let n=this.#e[i];return this.#y.some(r=>{let o=di(n,r);return o!=null&&String(o).toLowerCase().includes(e)})})}return this.#s.size&&(t=t.filter(e=>{let i=this.#e[e];for(let[n,{op:r,value:o}]of this.#s){let a=this.#t.find(u=>u.key===n),l=di(i,a||{key:n}),h=String(l??"").toLowerCase(),c=String(o).toLowerCase();switch(r){case"contains":if(!h.includes(c))return!1;break;case"equals":if(h!==c)return!1;break;case"startsWith":if(!h.startsWith(c))return!1;break;case"gt":if(Number(l)<=Number(o))return!1;break;case"lt":if(Number(l)>=Number(o))return!1;break;case"gte":if(Number(l)<Number(o))return!1;break;case"lte":if(Number(l)>Number(o))return!1;break;case"between":{let[u,d]=String(o).split(",").map(Number),f=Number(l);if(f<u||f>d)return!1;break}case"select":{if(!c.split(",").map(d=>d.trim()).includes(h))return!1;break}default:if(!h.includes(c))return!1}}return!0})),this.#i.length&&t.sort((e,i)=>{for(let{key:n,dir:r}of this.#i){let o=this.#t.find(u=>u.key===n),a=di(this.#e[e],o||{key:n}),l=di(this.#e[i],o||{key:n}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Xi[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=Zd[d]||Zd.alphanumeric}if(a==null&&l==null)continue;if(a==null)return 1;if(l==null)return-1;let c=h(a,l);if(c!==0)return r==="asc"?c:-c}return 0}),t}#k(t){if(!this.paginate||this.paginate<=0)return t;let e=this.#a*this.paginate;return t.slice(e,e+this.paginate)}get#S(){if(!this.paginate||this.paginate<=0)return 1;let t=this.#v().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#y;this.style.gridTemplateColumns=this.#w();let e=this.querySelector(":scope > [data-header]");e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-header",""),this.prepend(e)),this.#x(e,t),this.#q();let i=this.querySelector(":scope > [data-body]");i||(i=document.createElement("div"),i.setAttribute("role","rowgroup"),i.setAttribute("data-body",""),e.after(i));let n=this.#v(),r=this.#k(n),o=[];for(let c of r){let u=i.querySelector(`:scope > [role="row"][data-index="${c}"]`),d=u||this.#A(c,t);if(u&&this.#E(u,c,t),this.expandable&&(this.#n.has(c)?d.setAttribute("data-expanded",""):d.removeAttribute("data-expanded")),o.push(d),this.expandable&&this.#n.has(c)){let f=i.querySelector(`:scope > [data-detail-row][data-for="${c}"]`);if(!f&&(f=document.createElement("div"),f.setAttribute("data-detail-row",""),f.dataset.for=c,this.expandRenderer)){let p=this.expandRenderer(this.#e[c],c);p instanceof Node?f.appendChild(p):f.textContent=String(p)}o.push(f)}}let a=[...i.children];for(let c of a)o.includes(c)||c.remove();for(let c=0;c<o.length;c++)i.children[c]!==o[c]&&(i.children[c]?i.insertBefore(o[c],i.children[c]):i.appendChild(o[c]));this.#C(i),this.#P(i,n,t);let l=this.paginate>0&&this.#e.length>0,h=this.querySelector(":scope > [data-footer]");l?(h||(h=document.createElement("div"),h.setAttribute("data-footer",""),this.appendChild(h)),this.#R(h,n.length)):h&&h.remove()}#x(t,e){let i=this.#e.length>0&&this.#o.size===this.#e.length,n=[];if(this.selectable){let r=document.createElement("div");r.setAttribute("role","columnheader"),r.setAttribute("data-check-col","");let o=document.createElement("check-ui");i&&o.setAttribute("checked",""),o.setAttribute("aria-label","Select all rows"),r.appendChild(o),n.push(r)}for(let r of e){let o=document.createElement("div");o.setAttribute("role","columnheader");let a=document.createElement("span");if(a.textContent=r.label||r.key,o.appendChild(a),r.sortable!==!1&&this.sortable){o.dataset.sortKey=r.key,o.setAttribute("aria-label",`Sort by ${r.label||r.key}`);let h=document.createElement("icon-ui");h.setAttribute("data-sort-icon","");let c=this.#i.find(u=>u.key===r.key);c?(o.setAttribute("aria-sort",c.dir==="asc"?"ascending":"descending"),h.setAttribute("name",c.dir==="asc"?"arrow-up":"arrow-down")):h.setAttribute("name","caret-up-down"),o.appendChild(h)}if(r.pinned&&o.setAttribute("data-pinned",r.pinned),r.resizable!==!1){let h=document.createElement("div");h.setAttribute("data-resize-handle",""),h.dataset.resizeKey=r.key,o.appendChild(h)}if(r.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=r.key,h.setAttribute("aria-label",`Filter ${r.label||r.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(r.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#d===r.key){let u=this.#T(r);o.appendChild(u),o.setAttribute("data-filter-open","")}}n.push(o)}for(;t.children.length>n.length;)t.lastChild.remove();for(let r=0;r<n.length;r++)t.children[r]?t.replaceChild(n[r],t.children[r]):t.appendChild(n[r])}#A(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#E(i,t,e),i}#E(t,e,i){let n=this.#e[e],r=this.#o.has(e);t.dataset.index=e,r?(t.setAttribute("data-selected",""),t.setAttribute("aria-selected","true")):(t.removeAttribute("data-selected"),t.removeAttribute("aria-selected"));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col","");let l=document.createElement("button");l.setAttribute("data-expand-toggle",""),l.setAttribute("aria-label","Expand row");let h=document.createElement("icon-ui");h.setAttribute("name","caret-right"),h.setAttribute("size","xs"),l.appendChild(h),a.appendChild(l),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-check-col","");let l=document.createElement("check-ui");r&&l.setAttribute("checked",""),l.setAttribute("aria-label",`Select row ${e+1}`),a.appendChild(l),o.push(a)}for(let a of i){let l=document.createElement("div");l.setAttribute("role","gridcell"),l.dataset.key=a.key;let h=di(n,a);if(typeof a.render=="function"){let u=a.render(h,n,l,e);u instanceof Node?l.replaceChildren(u):typeof u=="string"&&(l.innerHTML=u)}else if(typeof a.format=="function"){let u=a.format(h,n);l.appendChild(Object.assign(document.createElement("span"),{textContent:u})),l.title=u}else{let u=Xi[a.type||"text"];if(u?.render)u.render(h,n,l,a.meta);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Xi[a.type||"text"];c?.align&&(l.dataset.align=c.align),a.pinned&&l.setAttribute("data-pinned",a.pinned),a.wrap&&l.setAttribute("data-wrap",""),o.push(l)}for(;t.children.length>o.length;)t.lastChild.remove();for(let a=0;a<o.length;a++)t.children[a]?t.replaceChild(o[a],t.children[a]):t.appendChild(o[a])}#C(t){let e=this.querySelector(":scope > [data-empty]"),i=this.querySelector(":scope > [data-loading]");if(this.loading){this.setAttribute("aria-busy","true");let n=this.#y,r=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+n.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<r;a++){let l=document.createElement("div");l.setAttribute("role","row"),l.setAttribute("data-skeleton-row","");for(let h=0;h<o;h++){let c=document.createElement("div");c.setAttribute("role","gridcell");let u=document.createElement("skeleton-ui"),d=["60%","80%","70%","50%","90%"];u.setAttribute("width",d[h%d.length]),u.setAttribute("height","1em"),u.setAttribute("radius","sm"),c.appendChild(u),l.appendChild(c)}t.appendChild(l)}i&&i.remove(),e&&e.remove()}else if(this.#e.length===0){if(this.removeAttribute("aria-busy"),!e){e=document.createElement("div"),e.setAttribute("data-empty","");let n=document.createElement("icon-ui");n.setAttribute("name","table");let r=document.createElement("span");r.textContent="No data",e.appendChild(n),e.appendChild(r),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#P(t,e,i){let n=i.some(a=>a.aggregate),r=this.querySelector(":scope > [data-agg-row]");if(!n||this.#e.length===0){r&&r.remove();return}r||(r=document.createElement("div"),r.setAttribute("role","row"),r.setAttribute("data-agg-row",""),t.after(r));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}for(let a of i){let l=document.createElement("div");if(l.setAttribute("role","gridcell"),a.aggregate){let h=e.map(d=>{let f=di(this.#e[d],a);return f!=null?Number(f):NaN}).filter(d=>!isNaN(d)),c;switch(a.aggregate){case"sum":c=h.reduce((d,f)=>d+f,0);break;case"avg":c=h.length?h.reduce((d,f)=>d+f,0)/h.length:0;break;case"min":c=h.length?Math.min(...h):0;break;case"max":c=h.length?Math.max(...h):0;break;case"count":c=e.length;break;default:c=""}let u=Xi[a.type||"text"];typeof c=="number"&&u?.render?u.render(c,{},l,a.meta):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}for(;r.children.length>o.length;)r.lastChild.remove();for(let a=0;a<o.length;a++)r.children[a]?r.replaceChild(o[a],r.children[a]):r.appendChild(o[a])}#R(t,e){let i=t.querySelector("pagination-ui");i||(t.innerHTML="",i=document.createElement("pagination-ui"),i.addEventListener("page-change",r=>{this.#a=r.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#a}}))}),t.appendChild(i));let n=this.paginate>0?Math.max(1,Math.ceil(e/this.paginate)):1;i.setAttribute("page",String(this.#a+1)),i.setAttribute("total",String(n))}#T(t){let e=document.createElement("div");e.setAttribute("data-filter-dropdown","");let i=this.#s.get(t.key);if(t.filter==="select"){let n=[...new Set(this.#e.map(o=>{let a=di(o,t);return a!=null?String(a):""}))].filter(Boolean).sort(),r=new Set(i?.op==="select"?String(i.value).split(","):[]);for(let o of n){let a=document.createElement("label");a.setAttribute("data-filter-option","");let l=document.createElement("input");l.type="checkbox",l.value=o,l.checked=r.has(o.toLowerCase()),l.addEventListener("change",()=>{let h=[...e.querySelectorAll("input[type=checkbox]:checked")].map(c=>c.value);h.length?this.setFilter(t.key,h.join(","),"select"):this.setFilter(t.key,null)}),a.appendChild(l),a.appendChild(document.createTextNode(` ${o}`)),e.appendChild(a)}}else if(t.filter==="number"){let n=document.createElement("input");n.type="number",n.placeholder="Filter...",n.value=i?.value??"",n.setAttribute("data-filter-input","");let r=document.createElement("select");r.setAttribute("data-filter-op","");for(let[a,l]of[["gte","\u2265"],["lte","\u2264"],["gt",">"],["lt","<"],["equals","="]]){let h=document.createElement("option");h.value=a,h.textContent=l,i?.op===a&&(h.selected=!0),r.appendChild(h)}let o=()=>{n.value?this.setFilter(t.key,n.value,r.value):this.setFilter(t.key,null)};n.addEventListener("input",o),r.addEventListener("change",o),e.appendChild(r),e.appendChild(n)}else{let n=document.createElement("input");n.type="text",n.placeholder=`Filter ${t.label||t.key}...`,n.value=i?.value??"",n.setAttribute("data-filter-input",""),n.addEventListener("input",()=>{n.value?this.setFilter(t.key,n.value,"contains"):this.setFilter(t.key,null)}),e.appendChild(n)}if(i){let n=document.createElement("button");n.textContent="Clear",n.setAttribute("data-filter-clear",""),n.addEventListener("click",()=>{this.setFilter(t.key,null),this.#d=null,this.#b()}),e.appendChild(n)}return this.#p!=null&&cancelAnimationFrame(this.#p),this.#p=requestAnimationFrame(()=>{if(this.#p=null,!this.isConnected)return;let n=e.querySelector("input");n&&n.focus()}),e}#q(){let t=this.querySelector(":scope > [data-filter-bar]");if(this.#s.size===0){t&&t.remove();return}if(!t){t=document.createElement("div"),t.setAttribute("data-filter-bar",""),t.setAttribute("role","status");let i=this.querySelector(":scope > [data-header]");i?i.after(t):this.prepend(t)}t.innerHTML="";for(let[i,{op:n,value:r}]of this.#s){let a=this.#t.find(u=>u.key===i)?.label||i,l=document.createElement("badge-ui"),h=n==="select"?`${r.split(",").length} selected`:r;l.setAttribute("text",`${a}: ${h}`),l.setAttribute("size","xs"),l.setAttribute("data-filter-chip",i);let c=document.createElement("button");c.textContent="\xD7",c.setAttribute("data-chip-dismiss",""),c.addEventListener("click",u=>{u.stopPropagation(),this.setFilter(i,null)}),l.appendChild(c),t.appendChild(l)}let e=document.createElement("button");e.textContent="Clear all",e.setAttribute("data-filter-clear-all",""),e.addEventListener("click",()=>this.clearFilters()),t.appendChild(e)}#Q=t=>{if(t.button!==void 0&&t.button!==0)return;let e=t.target.closest("[data-resize-handle]");e&&this.contains(e)&&(t.preventDefault(),this.#$(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.#d=this.#d===c?null:c,this.#b();return}this.#d&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#d=null,this.#b());let n=e.closest("[data-expand-toggle]");if(n&&this.expandable&&this.contains(n)){let c=n.closest('[role="row"]');c?.dataset?.index!=null&&this.toggleExpand(Number(c.dataset.index));return}let r=e.closest("[data-resize-handle]");if(r&&this.contains(r)){this.#$(t,r);return}let o=e.closest("[data-sort-key]");if(o&&this.sortable&&this.contains(o)){let c=o.dataset.sortKey,u=this.#i.findIndex(m=>m.key===c),f=this.#t.find(m=>m.key===c)?.sortDescFirst?"desc":"asc",p=f==="asc"?"desc":"asc";if(t.shiftKey)if(u>=0){let m=this.#i[u];m.dir===p?this.#i.splice(u,1):m.dir=m.dir===f?p:f}else this.#i.push({key:c,dir:f});else if(u>=0&&this.#i.length===1){let m=this.#i[0];m.dir===p?this.#i=[]:m.dir=m.dir===f?p:f}else this.#i=[{key:c,dir:f}];this.render(),this.dispatchEvent(new CustomEvent("sort",{bubbles:!0,detail:{key:c,dir:this.#i.find(m=>m.key===c)?.dir||null,sortState:this.sortState}}));return}let a=e.closest("[data-header] check-ui");if(a&&this.selectable){if(a.hasAttribute("checked"))for(let u=0;u<this.#e.length;u++)this.#o.add(u);else this.#o.clear();this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}));return}let l=e.closest('[role="row"]:not([data-header]) check-ui');if(l&&this.selectable){let c=l.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=l.hasAttribute("checked");if(t.shiftKey&&this.#u>=0){let f=Math.min(this.#u,u),p=Math.max(this.#u,u);for(let m=f;m<=p;m++)d?this.#o.add(m):this.#o.delete(m)}else d?this.#o.add(u):this.#o.delete(u);this.#u=u,this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}))}return}let h=e.closest('[role="gridcell"][data-key]');if(h&&this.contains(h)){let c=h.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=h.dataset.key,f=this.#e[u],p=this.#t.find(b=>b.key===d),m=p?di(f,p):void 0;this.dispatchEvent(new CustomEvent("cell-click",{bubbles:!0,detail:{key:d,row:f,value:m,dataIndex:u}})),this.dispatchEvent(new CustomEvent("row-click",{bubbles:!0,detail:{row:f,dataIndex:u}}))}}};#L=null;#$(t,e){t.preventDefault(),t.stopPropagation();let i=e.dataset.resizeKey,n=this.#t.find(l=>l.key===i);if(!n)return;let r=e.closest('[role="columnheader"]'),o=r?r.getBoundingClientRect().width:100,a=t.clientX;this.setAttribute("data-resizing",""),this.#L={key:i,col:n,startX:a,startWidth:o},document.addEventListener("pointermove",this.#D),document.addEventListener("pointerup",this.#I)}#D=t=>{if(!this.#L)return;let{key:e,col:i,startX:n,startWidth:r}=this.#L,o=t.clientX-n,a=r+o,l=i.minWidth||48,h=i.maxWidth||1/0;a=Math.max(l,Math.min(h,a)),this.#l.set(e,Math.round(a)),this.style.gridTemplateColumns=this.#w()};#I=t=>{if(!this.#L)return;let{key:e}=this.#L;document.removeEventListener("pointermove",this.#D),document.removeEventListener("pointerup",this.#I),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#L=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:i}})),this.render()};#M(){document.removeEventListener("pointermove",this.#D),document.removeEventListener("pointerup",this.#I),this.#L=null}#_=t=>{let i=this.#y.length+(this.selectable?1:0),n=this.querySelector(":scope > [data-body]"),r=n?n.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,r-1);break;case"ArrowUp":o=Math.max(o-1,-1);break;case"ArrowRight":a=Math.min(a+1,i-1);break;case"ArrowLeft":a=Math.max(a-1,0);break;case"Tab":if(t.shiftKey?(a--,a<0&&(a=i-1,o--)):(a++,a>=i&&(a=0,o++)),o<-1||o>=r){l=!1;break}break;case"Enter":if(o===-1){let c=this.querySelector(":scope > [data-header]")?.children[a];c?.dataset.sortKey&&c.click()}else{let h=this.querySelector("[data-focused]");h&&h.click()}break;default:l=!1}l&&(t.preventDefault(),this.#c={row:o,col:a},this.#Z())};#Z(){let t=this.querySelector("[data-focused]");if(t&&t.removeAttribute("data-focused"),!this.#c)return;let{row:e,col:i}=this.#c,n;e===-1?n=this.querySelector(":scope > [data-header]")?.children[i]:n=this.querySelector(":scope > [data-body]")?.children[e]?.children[i],n&&(n.setAttribute("data-focused",""),n.scrollIntoView?.({block:"nearest",inline:"nearest"}))}exportCSV(t="export.csv"){let e=this.#y,i=this.#v(),n=e.map(c=>yh(c.label||c.key)),r=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=di(u,d);if(typeof d.format=="function")return yh(d.format(f,u));let p=Xi[d.type||"text"];return p?.format?yh(p.format(f,u,d.meta)):yh(f)})}),o=[n.join(","),...r.map(c=>c.join(","))].join(`
|
|
175
|
+
`,this.#l.set(i,t),i}#b(t,e){return e?(t.label||"").toLowerCase().includes(e)||(t.value||"").toLowerCase().includes(e)||(t.keywords||"").toLowerCase().includes(e):!0}#y(t){let e=this.#n.querySelectorAll('[role="option"]:not([aria-disabled])'),i=this.#n.querySelector("[data-active]");i&&i.removeAttribute("data-active");let n=[...e].find(r=>parseInt(r.dataset.idx)===t);n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#i=t)}#w(t){let e=[...this.#n.querySelectorAll('[role="option"]:not([aria-disabled])')];if(!e.length)return;let i=this.#n.querySelector("[data-active]"),r=(i?e.indexOf(i):-1)+t;r<0&&(r=e.length-1),r>=e.length&&(r=0),this.#y(parseInt(e[r].dataset.idx))}#v(t){this.#O(t.value),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:t.value,label:t.label,category:t.category||""}}))}#k(){let t=this.#n.querySelector("[data-active]");if(!t)return;let e=t.dataset.value,i=t.querySelector("[data-text]")?.textContent||"",r=(this.#l.get(t)||this.#m(e))?.category||"";this.#O(e),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:e,label:i,category:r}}))}#S=()=>{this.#f(this.#s.value)};#x=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#w(1);break;case"ArrowUp":t.preventDefault(),this.#w(-1);break;case"Enter":t.preventDefault(),this.#k();break;case"Tab":t.preventDefault(),this.#k();break;case"Escape":t.preventDefault(),this.dispatchEvent(new Event("dismiss",{bubbles:!0}));break}};disconnected(){this.#r!=null&&(cancelAnimationFrame(this.#r),this.#r=null),this.removeEventListener("keydown",this.#x),this.#s?.removeEventListener("input",this.#S),this.#n?.removeEventListener("click",this.#h),this.#n?.removeEventListener("pointerover",this.#u),this.#s=null,this.#n=null,this.#a=null,this.#o=!1}};S("command-ui",Ln);var Ca=.4;function Dd(s,t,e){let i=e*Math.PI/180;return{L:s,a:t*Math.cos(i),b:t*Math.sin(i)}}function qd(s,t,e){let i=s+.3963377774*t+.2158037573*e,n=s-.1055613458*t-.0638541728*e,r=s-.0894841775*t-1.291485548*e,o=i*i*i,a=n*n*n,l=r*r*r;return[4.0767416621*o-3.3077115913*a+.2309699292*l,-1.2684380046*o+2.6097574011*a-.3413193965*l,-.0041960863*o-.7034186147*a+1.707614701*l]}function ui(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055}function Xd(s){return s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function GO(s,t,e){let{a:i,b:n}=Dd(s,t,e),[r,o,a]=qd(s,i,n);return[Math.max(0,Math.min(1,ui(r))),Math.max(0,Math.min(1,ui(o))),Math.max(0,Math.min(1,ui(a)))]}function lC(s,t,e){let i=n=>Math.round(n*255).toString(16).padStart(2,"0");return`#${i(s)}${i(t)}${i(e)}`}function Mn(s,t,e){let[i,n,r]=GO(s,t,e);return lC(i,n,r)}function hC(s){s=s.replace("#",""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=Xd(parseInt(s.slice(0,2),16)/255),e=Xd(parseInt(s.slice(2,4),16)/255),i=Xd(parseInt(s.slice(4,6),16)/255),n=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*i),r=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*i),o=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*i),a=.2104542553*n+.793617785*r-.0040720468*o,l=1.9779984951*n-2.428592205*r+.4505937099*o,h=.0259040371*n+.7827717662*r-.808675766*o,c=Math.sqrt(l*l+h*h),u=Math.atan2(h,l)*180/Math.PI;return u<0&&(u+=360),{L:a,C:c,H:u}}function KO(s,t,e){return s>=-.001&&s<=1+.001&&t>=-.001&&t<=1+.001&&e>=-.001&&e<=1+.001}function $a(s,t,e){let{a:i,b:n}=Dd(s,t,e),[r,o,a]=qd(s,i,n);if(KO(ui(r),ui(o),ui(a)))return t;let l=0,h=t;for(let c=0;c<8;c++){let u=(l+h)/2,{a:d,b:f}=Dd(s,u,e),[p,m,b]=qd(s,d,f);KO(ui(p),ui(m),ui(b))?l=u:h=u}return l}var Rn=class s extends M{static requiredIcons=["copy","check","warning"];static#t=new WeakSet;static properties={...M.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0,attribute:"max-chroma"},maxL:{type:Number,default:1,reflect:!0,attribute:"max-l"},minL:{type:Number,default:0,reflect:!0,attribute:"min-l"},hueDriftMax:{type:Number,default:NaN,reflect:!0,attribute:"hue-drift-max"},baseHue:{type:Number,default:NaN,reflect:!0,attribute:"base-hue"}};#e=.6;#i=.15;#s=230;#n=NaN;#r=!1;#a=null;#o=!1;#l=null;#c=null;#h=null;#u=null;#d=null;#p=null;#f=null;#m=null;#O=null;#g=null;#b=null;#y=null;#w=[];#v=null;static template=()=>null;#k=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.#M("input")};#S=t=>{this.disabled||(this.#a="area",this.#h.setPointerCapture(t.pointerId),this.#q(t))};#x=t=>{this.#a==="area"&&this.#q(t)};#A=()=>{this.#a==="area"&&(this.#a=null,this.#M("change"))};#E=t=>{this.disabled||(this.#a="hue",this.#d.setPointerCapture(t.pointerId),this.#T(t))};#C=t=>{this.#a==="hue"&&this.#T(t)};#$=()=>{this.#a==="hue"&&(this.#a=null,this.#M("change"))};#L=t=>{if(this.disabled)return;let e=t.shiftKey?.05:.01,i=t.shiftKey?.04:.004;switch(t.key){case"ArrowRight":t.preventDefault(),this.#i=Math.min(Ca,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.#M("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.#M("change")};connected(){if(super.connected(),this.#N(this.value),this.#r)return;this.#r=!0,this.#h=document.createElement("div"),this.#h.setAttribute("data-area",""),this.#h.setAttribute("tabindex","0"),this.#h.setAttribute("role","slider"),this.#h.setAttribute("aria-label","Color area: chroma and lightness"),this.#l=document.createElement("canvas"),this.#l.style.cssText="width:100%;height:100%;display:block;border-radius:inherit;",this.#h.appendChild(this.#l),this.#c=this.#l.getContext("2d",{willReadFrequently:!0}),this.#u=document.createElement("div"),this.#u.setAttribute("data-area-thumb",""),this.#h.appendChild(this.#u),this.appendChild(this.#h);let t=document.createElement("div");t.setAttribute("data-sliders","");let e=(r,o,a,l,h)=>{let c=document.createElement("slider-ui");return c.setAttribute("data-channel",o),c.setAttribute("label",r),c.setAttribute("min",a),c.setAttribute("max",l),c.setAttribute("step",h),c.addEventListener("input",this.#k),t.appendChild(c),c};this.#g=e("H","hue",0,360,1),this.#b=e("C","chroma",0,Ca,.001),this.#y=e("L","lightness",0,1,.001),this.appendChild(t),this.#d=document.createElement("div"),this.#d.setAttribute("data-hue-track",""),this.#d.setAttribute("tabindex","0"),this.#d.setAttribute("role","slider"),this.#d.setAttribute("aria-label","Hue"),this.#p=document.createElement("div"),this.#p.setAttribute("data-hue-thumb",""),this.#d.appendChild(this.#p),this.appendChild(this.#d);let i=document.createElement("div");i.setAttribute("data-output","");let n=r=>{let o=document.createElement("div");o.setAttribute("data-output-group","");let a=document.createElement("span");a.setAttribute("data-output-value",""),a.setAttribute("data-format",r);let l=document.createElement("div");l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("data-copy",r),l.setAttribute("aria-label",`Copy ${r}`),l.innerHTML='<icon-ui name="copy"></icon-ui>';let h=()=>this.#D(r,l);return l.addEventListener("click",h),this.#w.push({el:l,handler:h}),o.appendChild(a),o.appendChild(l),i.appendChild(o),a};this.#f=n("oklch"),this.#m=n("hex"),this.appendChild(i),this.#h.addEventListener("pointerdown",this.#S),this.#h.addEventListener("pointermove",this.#x),this.#h.addEventListener("pointerup",this.#A),this.#d.addEventListener("pointerdown",this.#E),this.#d.addEventListener("pointermove",this.#C),this.#d.addEventListener("pointerup",this.#$),this.#h.addEventListener("keydown",this.#L),this.#d.addEventListener("keydown",this.#P),this.#O=new ResizeObserver(()=>this.#I()),this.#O.observe(this.#h)}disconnected(){super.disconnected(),this.#v!=null&&(clearTimeout(this.#v),this.#v=null),this.#O&&(this.#O.disconnect(),this.#O=null),this.#h&&(this.#h.removeEventListener("pointerdown",this.#S),this.#h.removeEventListener("pointermove",this.#x),this.#h.removeEventListener("pointerup",this.#A),this.#h.removeEventListener("keydown",this.#L)),this.#d&&(this.#d.removeEventListener("pointerdown",this.#E),this.#d.removeEventListener("pointermove",this.#C),this.#d.removeEventListener("pointerup",this.#$),this.#d.removeEventListener("keydown",this.#P)),this.#g?.removeEventListener("input",this.#k),this.#b?.removeEventListener("input",this.#k),this.#y?.removeEventListener("input",this.#k);for(let{el:t,handler:e}of this.#w)t.removeEventListener("click",e);this.#w=[],this.#r=!1}#q(t){let e=this.#h.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width)),n=Math.max(0,Math.min(1,(t.clientY-e.top)/e.height));this.#i=i*Ca,this.#e=1-n,this.#M("input")}#T(t){let e=this.#d.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-e.left)/e.width));this.#s=i*360,this.#M("input")}#N(t){if(t){if(t.startsWith("#")){let e=hC(t);this.#e=e.L,this.#i=e.C,this.#s=e.H;return}if(t.startsWith("oklch(")){let e=t.match(/oklch\(\s*([\d.]+%?|NaN|none)\s+([\d.]+%?|NaN|none)\s+([\d.]+|NaN|none)/i);if(e){let i=(n,r)=>n==="none"||/^NaN$/i.test(n)?0:r&&n.endsWith("%")||n.endsWith("%")?+n.slice(0,-1)/100:+n;this.#e=i(e[1],!0),this.#i=i(e[2],!1),this.#s=i(e[3],!1);return}s.#t.has(this)||(s.#t.add(this),console.warn(`<color-picker-ui>: could not parse value=${JSON.stringify(t)}. Expected #rrggbb or oklch(L C H) with numeric, NaN, 'none' (CSS L4 powerless), or % channels. Picker is keeping prior state.`))}}}#M(t){let e=[];if(this.#e>this.maxL&&(e.push({axis:"l",requested:this.#e,clamped:this.maxL,reason:"max-l"}),this.#e=this.maxL),this.#e<this.minL&&(e.push({axis:"l",requested:this.#e,clamped:this.minL,reason:"min-l"}),this.#e=this.minL),this.#i>this.maxChroma&&(e.push({axis:"c",requested:this.#i,clamped:this.maxChroma,reason:"max-chroma"}),this.#i=this.maxChroma),Number.isFinite(this.hueDriftMax)){let a=Number.isFinite(this.baseHue)?this.baseHue:Number.isFinite(this.#n)?this.#n:this.#s;Number.isFinite(this.#n)||(this.#n=a);let l=(this.#s-a+540)%360-180,h=this.hueDriftMax;if(l>h){let c=this.#s;this.#s=(a+h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}else if(l<-h){let c=this.#s;this.#s=(a-h+360)%360,e.push({axis:"h",requested:c,clamped:this.#s,reason:"hue-drift-max"})}}let i=$a(this.#e,this.#i,this.#s),n=Mn(this.#e,i,this.#s),r=this.#Q();this.#o=!0,this.value=this.format==="oklch"?r:n,this.syncValue(),e.length&&this.dispatchEvent(new CustomEvent("constraint-clamp",{bubbles:!0,detail:{clamps:e}}));let o={value:this.value,l:this.#e,c:this.#i,h:this.#s,hex:n,oklch:r};this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}#Q(){return`oklch(${this.#e.toFixed(2)} ${this.#i.toFixed(3)} ${Math.round(this.#s)})`}#D(t,e){let i=t==="oklch"?this.#Q():Mn(this.#e,$a(this.#e,this.#i,this.#s),this.#s),n=e.querySelector("icon-ui"),r=o=>{n&&(n.setAttribute("name",o?"check":"warning"),this.#v!=null&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,n.setAttribute("name","copy")},1500))};if(navigator.clipboard?.writeText)navigator.clipboard.writeText(i).then(()=>{this.isConnected&&r(!0)},()=>{this.isConnected&&r(!1)});else{let o=Object.assign(document.createElement("textarea"),{value:i});o.style.cssText="position:fixed;opacity:0",document.body.appendChild(o),o.select(),r(document.execCommand("copy")),o.remove()}}#I(){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 n=this.#c.createImageData(e,i),r=n.data,o=this.#s;for(let a=0;a<i;a++){let l=1-a/(i-1);for(let h=0;h<e;h++){let c=h/(e-1)*Ca,u=$a(l,c,o),[d,f,p]=GO(l,u,o),m=(a*e+h)*4;r[m]=Math.round(d*255),r[m+1]=Math.round(f*255),r[m+2]=Math.round(p*255),r[m+3]=255}}this.#c.putImageData(n,0,0)}render(){if(this.#o?this.#o=!1:this.#N(this.value),this.#I(),this.#u){let r=this.#i/Ca*100,o=(1-this.#e)*100;this.#u.style.left=`${r}%`,this.#u.style.top=`${o}%`,this.#u.style.background=Mn(this.#e,$a(this.#e,this.#i,this.#s),this.#s)}if(this.#d){let r=[];for(let o=0;o<=360;o+=30)r.push(Mn(.7,.15,o));this.#d.style.background=`linear-gradient(to right, ${r.join(", ")})`,this.#d.setAttribute("aria-valuenow",String(Math.round(this.#s)))}this.#p&&(this.#p.style.left=`${this.#s/360*100}%`,this.#p.style.background=Mn(.7,.15,this.#s)),this.#h&&this.#h.setAttribute("aria-valuetext",this.#Q());let t=this.querySelector('slider-ui[data-channel="hue"]'),e=this.querySelector('slider-ui[data-channel="chroma"]'),i=this.querySelector('slider-ui[data-channel="lightness"]');t&&(t.value=Math.round(this.#s)),e&&(e.value=+this.#i.toFixed(3)),i&&(i.value=+this.#e.toFixed(3)),this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");let n=Mn(this.#e,$a(this.#e,this.#i,this.#s),this.#s);this.#f&&(this.#f.textContent=this.#Q()),this.#m&&(this.#m.textContent=n)}onFormReset(){this.value="#3b82f6"}};S("color-picker-ui",Rn);var In=class extends M{static get properties(){return{...M.properties,value:{type:String,default:"#3b82f6",reflect:!0},format:{type:String,default:"hex",reflect:!0},placement:{type:String,default:"bottom",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},maxChroma:{type:Number,default:1/0,reflect:!0},maxL:{type:Number,default:1,reflect:!0},minL:{type:Number,default:0,reflect:!0},hueDriftMax:{type:Number,default:NaN,reflect:!0},baseHue:{type:Number,default:NaN,reflect:!0}}}#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#a=null;connected(){this.#o(),this.#l(),this.#d(),this.syncValue(this.value)}render(){this.#d(),this.#t&&this.#t.open!==this.open&&(this.#t.open=this.open),this.#i&&(this.#i.format!==this.format&&(this.#i.format=this.format),Object.is(this.#i.maxChroma,this.maxChroma)||(this.#i.maxChroma=this.maxChroma),Object.is(this.#i.maxL,this.maxL)||(this.#i.maxL=this.maxL),Object.is(this.#i.minL,this.minL)||(this.#i.minL=this.minL),Object.is(this.#i.hueDriftMax,this.hueDriftMax)||(this.#i.hueDriftMax=this.hueDriftMax),Object.is(this.#i.baseHue,this.baseHue)||(this.#i.baseHue=this.baseHue)),this.#e&&(this.disabled?this.#e.setAttribute("disabled",""):this.#e.removeAttribute("disabled"))}showPicker(){this.open=!0}hidePicker(){this.open=!1}#o(){if(this.firstElementChild&&(this.#t=this.querySelector(":scope > popover-ui"),this.#e=this.querySelector(':scope > popover-ui > button-ui[slot="trigger"]'),this.#i=this.querySelector(':scope > popover-ui > color-picker-ui[slot="content"]'),this.#s=this.querySelector(".color-input__swatch"),this.#n=this.querySelector(".color-input__value"),this.#t&&this.#e&&this.#i))return;let t=document.createElement("popover-ui");t.setAttribute("trigger","click"),t.setAttribute("placement",this.placement);let e=document.createElement("button-ui");e.setAttribute("slot","trigger"),e.setAttribute("variant","outline"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-label",this.getAttribute("aria-label")||"Pick a color");let i=document.createElement("span");i.className="color-input__swatch",i.setAttribute("aria-hidden","true");let n=document.createElement("span");n.className="color-input__value",e.append(i,n);let r=document.createElement("color-picker-ui");r.setAttribute("slot","content"),r.setAttribute("format",this.format),r.setAttribute("value",this.value),r.maxChroma=this.maxChroma,r.maxL=this.maxL,r.minL=this.minL,r.hueDriftMax=this.hueDriftMax,r.baseHue=this.baseHue,t.append(e,r),this.append(t),this.#t=t,this.#e=e,this.#i=r,this.#s=i,this.#n=n}#l(){if(this.#r)return;this.#r=!0,this.#i.addEventListener("change",this.#c),this.#i.addEventListener("input",this.#h);let t=()=>{let e=!!this.#t?.open;this.open!==e&&(this.open=e)};this.#t.addEventListener("toggle",t),this.#a=new MutationObserver(t),this.#a.observe(this.#t,{attributes:!0,attributeFilter:["open"]})}#c=t=>{this.#u(t.detail,"change")};#h=t=>{this.#u(t.detail,"input")};#u(t,e){if(!t)return;let i=this.format==="oklch"?t.oklch:t.hex;i&&i!==this.value&&(this.value=i,this.syncValue(i)),this.#d(),this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:{value:i??this.value,hex:t.hex,oklch:t.oklch,l:t.l,c:t.c,h:t.h}}))}#d(){this.#s&&this.#s.style.setProperty("--swatch-color",this.value),this.#n&&(this.#n.textContent=this.value)}disconnected(){this.#i?.removeEventListener("change",this.#c),this.#i?.removeEventListener("input",this.#h),this.#a?.disconnect(),this.#a=null,this.#r=!1}};S("color-input-ui",In);P();var Nd=0,Dn=class extends x{static properties={editable:{type:Boolean,default:!1,reflect:!0},color:{type:String,default:"",reflect:!0},strokeWidth:{type:Number,default:2,reflect:!0,attribute:"stroke-width"},tension:{type:Number,default:.5,reflect:!0},showPorts:{type:Boolean,default:!1,reflect:!0,attribute:"show-ports"},portSize:{type:Number,default:10,attribute:"port-size",reflect:!0},curve:{type:String,default:"bezier",reflect:!0},animated:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=[];#i=new Map;#s=null;#n=null;#r=null;#a=!1;#o=null;#l=null;#c=null;get connections(){return this.#e.map(t=>({...t}))}connect(t,e,i="right",n="left"){let r=`noodle-${++Nd}`,o={id:r,from:t,to:e,fromPort:i,toPort:n};return this.#e.push(o),this.#h(),this.dispatchEvent(new CustomEvent("noodle-connect",{bubbles:!0,detail:{...o}})),r}disconnect(t){let e=this.#e.findIndex(n=>n.id===t);if(e===-1)return;let[i]=this.#e.splice(e,1);this.#h(),this.dispatchEvent(new CustomEvent("noodle-disconnect",{bubbles:!0,detail:{...i}}))}setConnections(t){this.#e=t.map(e=>({id:e.id||`noodle-${++Nd}`,from:e.from,to:e.to,fromPort:e.fromPort||"right",toPort:e.toPort||"left"})),this.#h()}clear(){this.#e=[],this.#h()}update(){this.#p()}connected(){this.#t=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.#t.setAttribute("data-noodle-svg",""),this.prepend(this.#t),this.#s=new ResizeObserver(()=>this.#h()),this.#n=new MutationObserver(()=>{this.#k(),this.#h()}),this.#s.observe(this),this.#u();for(let t of this.#m())this.#s.observe(t);this.#k(),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.#n?.disconnect(),this.#r&&cancelAnimationFrame(this.#r),this.#r=null,this.#S(),this.#t?.remove(),this.#t=null,this.#a=!1}#h(){this.#r||(this.#r=requestAnimationFrame(()=>{this.#r=null,this.#p()}))}#u(){this.#n?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-noodle-port","style"]})}#d(){this.#n?.disconnect()}#p(){if(!this.#t)return;this.#d();let t=this.#m();for(let r of t)this.#s.observe(r);this.#x();let e=this.#e.map(r=>{let o=this.#f(r.from),a=this.#f(r.to);if(!o||!a)return null;let l=this.#O(o,r.fromPort),h=this.#O(a,r.toPort);return!l||!h?null:{id:r.id,d:this.#g(l,h,r.fromPort,r.toPort)}}).filter(Boolean),i=new Map;for(let r of this.#t.querySelectorAll("path[data-noodle-id]"))i.set(r.getAttribute("data-noodle-id"),r);let n=new Set(e.map(r=>r.id));for(let[r,o]of i)n.has(r)||o.remove();for(let{id:r,d:o}of e){let a=i.get(r);a||(a=document.createElementNS("http://www.w3.org/2000/svg","path"),a.setAttribute("data-noodle-id",r),this.#t.appendChild(a)),a.setAttribute("d",o),a.setAttribute("stroke-width",this.strokeWidth)}if(this.#o&&this.#l){let r=this.#t.querySelector("path[data-noodle-preview]");r||(r=document.createElementNS("http://www.w3.org/2000/svg","path"),r.setAttribute("data-noodle-preview",""),r.style.opacity="0.5",r.style.strokeDasharray="6 3",this.#t.appendChild(r)),r.setAttribute("d",this.#l),r.setAttribute("stroke-width",this.strokeWidth)}else this.#t.querySelector("path[data-noodle-preview]")?.remove();this.#u()}#f(t){return t instanceof HTMLElement?t:typeof t=="string"?this.querySelector(`#${CSS.escape(t)}`):typeof t=="number"?this.#m()[t]??null:null}#m(){return[...this.querySelectorAll("[data-noodle-port]")]}#O(t,e){let i=t.getBoundingClientRect(),n=this.getBoundingClientRect(),r=this.offsetWidth&&n.width?n.width/this.offsetWidth:1,o=(i.left-n.left)/r,a=(i.top-n.top)/r,l=i.width/r,h=i.height/r;switch(e){case"left":return{x:o,y:a+h/2};case"right":return{x:o+l,y:a+h/2};case"top":return{x:o+l/2,y:a};case"bottom":return{x:o+l/2,y:a+h};default:return{x:o+l/2,y:a+h/2}}}#g(t,e,i,n){switch(this.curve){case"step":return this.#w(t,e);case"straight":return this.#v(t,e);default:return this.#b(t,e,i,n)}}#b(t,e,i,n){let r=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y),a=Math.sqrt(r*r+o*o),l=Math.max(50,a*this.tension),h=this.#y(t,i,l),c=this.#y(e,n,l);return`M ${t.x} ${t.y} C ${h.x} ${h.y}, ${c.x} ${c.y}, ${e.x} ${e.y}`}#y(t,e,i){switch(e){case"left":return{x:t.x-i,y:t.y};case"right":return{x:t.x+i,y:t.y};case"top":return{x:t.x,y:t.y-i};case"bottom":return{x:t.x,y:t.y+i};default:return{x:t.x+i,y:t.y}}}#w(t,e){let i=(t.x+e.x)/2;return`M ${t.x} ${t.y} L ${i} ${t.y} L ${i} ${e.y} L ${e.x} ${e.y}`}#v(t,e){return`M ${t.x} ${t.y} L ${e.x} ${e.y}`}#k(){this.#d(),this.#S();let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#A(e,n),o=document.createElement("div");o.setAttribute("data-noodle-port-indicator",""),o.setAttribute("data-noodle-side",n),o.dataset.portElement=e.id||"",this.editable&&o.addEventListener("pointerdown",a=>this.#E(a,e,n)),this.appendChild(o),this.#i.set(r,o)}}this.#x(),this.#u()}#S(){for(let[,t]of this.#i)t.remove();this.#i.clear()}#x(){let t=this.#m();for(let e of t){let i=(e.getAttribute("data-noodle-port")||"").split(/\s+/).filter(Boolean);for(let n of i){let r=this.#A(e,n),o=this.#i.get(r);if(!o)continue;let a=this.#O(e,n);o.style.left=`${a.x}px`,o.style.top=`${a.y}px`}}}#A(t,e){return t._noodleId||(t._noodleId=`_n${++Nd}`),`${t._noodleId}:${e}`}#E=(t,e,i)=>{if(!this.editable||this.readonly)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget;n.setPointerCapture(t.pointerId),n.setAttribute("data-noodle-dragging","");let r=this.#O(e,i),o=l=>{if(!this.#o)return;let h=this.getBoundingClientRect(),c=l.clientX-h.left,u=l.clientY-h.top;this.#l=this.#g(r,{x:c,y:u},i,this.#C(r,{x:c,y:u})),this.#h(),this.#$(l.clientX,l.clientY,e),this.dispatchEvent(new CustomEvent("noodle-drag",{bubbles:!0,detail:{from:e,fromPort:i,x:c,y:u}}))},a=l=>{try{n.releasePointerCapture(l.pointerId)}catch{}if(n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),l.type==="pointerup"&&l.clientX!==void 0){let h=this.#L(l.clientX,l.clientY,e);h&&this.connect(e,h.el,i,h.side)}this.#P(),this.#o=null,this.#l=null,this.#c=null,this.#h()};this.#c=()=>{this.#o=null,n.removeAttribute("data-noodle-dragging"),n.removeEventListener("pointermove",o),n.removeEventListener("pointerup",a),this.#P(),this.#l=null,this.#c=null},this.#o={fromEl:e,fromSide:i,startPos:r,pointerId:t.pointerId},this.#l=null,n.addEventListener("pointermove",o),n.addEventListener("pointerup",a)};#C(t,e){let i=e.x-t.x,n=e.y-t.y;return Math.abs(i)>Math.abs(n)?i>0?"left":"right":n>0?"top":"bottom"}#$(t,e,i){this.#P();let n=this.#L(t,e,i);n?.dot&&n.dot.setAttribute("data-noodle-drop-ready","")}#L(t,e,i){let n=this.portSize*2,r=null,o=1/0;for(let[a,l]of this.#i){let h=l.getBoundingClientRect(),c=h.left+h.width/2,u=h.top+h.height/2,d=Math.sqrt((t-c)**2+(e-u)**2),[f,p]=a.split(":"),m=this.#m().find(b=>b._noodleId===f);!m||m===i||d<n&&d<o&&(o=d,r={el:m,side:p,dot:l})}return r}#P(){for(let[,t]of this.#i)t.removeAttribute("data-noodle-drop-ready")}};S("noodles-ui",Dn);var Xi={};function ve(s,t){Xi[s]=t}function qn(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 Zd={basic:(s,t)=>s<t?-1:s>t?1:0,alphanumeric:(s,t)=>String(s??"").localeCompare(String(t??""),void 0,{numeric:!0,sensitivity:"base"}),numeric:(s,t)=>(Number(s)||0)-(Number(t)||0),datetime:(s,t)=>new Date(s||0).getTime()-new Date(t||0).getTime()};ve("text",{render(s,t,e){qn(e,String(s??""))},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("number",{render(s,t,e){qn(e,s!=null?new Intl.NumberFormat().format(s):"")},format(s){return String(s??"")},align:"right",sortFn:"numeric"}),ve("currency",{render(s,t,e,i){qn(e,s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:i?.currency||"USD"}).format(s):"")},format(s,t,e){return s!=null?new Intl.NumberFormat("en-US",{style:"currency",currency:e?.currency||"USD"}).format(s):""},align:"right",sortFn:"numeric"}),ve("percent",{render(s,t,e){qn(e,s!=null?`${s}%`:"")},format(s){return s!=null?`${s}%`:""},align:"right",sortFn:"numeric"});var JO={year:"numeric",month:"short",day:"numeric"};ve("date",{render(s,t,e){qn(e,s?new Intl.DateTimeFormat("en-US",JO).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",JO).format(new Date(s)):""},align:"left",sortFn:"datetime"});var ty={year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"};ve("datetime",{render(s,t,e){qn(e,s?new Intl.DateTimeFormat("en-US",ty).format(new Date(s)):"")},format(s){return s?new Intl.DateTimeFormat("en-US",ty).format(new Date(s)):""},align:"left",sortFn:"datetime"}),ve("boolean",{render(s,t,e){let i=e.querySelector("check-ui");i||(e.textContent="",i=document.createElement("check-ui"),i.setAttribute("disabled",""),e.appendChild(i)),s?i.setAttribute("checked",""):i.removeAttribute("checked")},format(s){return s?"Yes":"No"},align:"center",sortFn:"basic"}),ve("badge",{render(s,t,e,i){let n=e.querySelector("badge-ui");n||(e.textContent="",n=document.createElement("badge-ui"),e.appendChild(n)),n.setAttribute("text",String(s??""));let r=i?.variants||{};n.setAttribute("variant",r[s]||"neutral")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("avatar",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("avatar-ui");o.setAttribute("size","sm");let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("avatar-ui"),r=i.querySelector("span");n.setAttribute("text",String(s??"")),r.textContent=String(s??""),e.title=String(s??"")},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("link",{render(s,t,e,i){let n=e.querySelector("a");n||(e.textContent="",n=document.createElement("a"),n.style.color="var(--table-accent, var(--a-primary))",n.style.textDecoration="none",e.appendChild(n));let r=String(s??""),o=r.includes("@")&&!r.startsWith("http");n.href=o?`mailto:${r}`:r,n.textContent=i?.label??r},format(s){return String(s??"")},align:"left",sortFn:"alphanumeric"}),ve("progress",{render(s,t,e){let i=e.querySelector("row-ui");if(!i){e.textContent="",i=document.createElement("row-ui"),i.setAttribute("gap","2"),i.setAttribute("align","center");let o=document.createElement("progress-ui");o.setAttribute("size","sm"),o.style.flex="1";let a=document.createElement("span");i.appendChild(o),i.appendChild(a),e.appendChild(i)}let n=i.querySelector("progress-ui"),r=i.querySelector("span");n.setAttribute("value",s!=null?String(s):"0"),r.textContent=s!=null?`${s}%`:""},format(s){return s!=null?`${s}%`:""},align:"left",sortFn:"numeric"}),ve("actions",{render(s,t,e,i){let n=i?.actions||[],r=e.querySelector("row-ui");if(r&&r.children.length!==n.length&&(r.remove(),r=null),!r){e.textContent="",r=document.createElement("row-ui"),r.setAttribute("gap","1");for(let o of n){let a=document.createElement("button-ui");a.setAttribute("icon",o.icon||""),a.setAttribute("variant","ghost"),a.setAttribute("size","sm"),a.setAttribute("aria-label",o.label||""),a.addEventListener("click",()=>{a.dispatchEvent(new CustomEvent(o.event,{bubbles:!0,detail:{row:t}}))}),r.appendChild(a)}e.appendChild(r)}},format(){return""},align:"center",sortFn:null});P();function cC(s,t){if(!t||!s)return;let e=t.split("."),i=s;for(let n of e){if(i==null)return;i=i[n]}return i}function di(s,t){return typeof t.accessor=="function"?t.accessor(s):cC(s,t.key)}function yh(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
|
|
176
|
+
`)?'"'+t.replace(/"/g,'""')+'"':t}var Xn=class extends x{static requiredIcons=["caret-right","caret-up-down","table","arrow-up","arrow-down","funnel-simple","funnel-simple-fill"];static properties={sortable:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},expandable:{type:Boolean,default:!1,reflect:!0},striped:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},density:{type:String,default:"standard",reflect:!0},paginate:{type:Number,default:0,reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},search:{type:String,default:"",reflect:!0}};static template=()=>null;#t=[];#e=[];#i=[];#s=new Map;#n=new Set;#r=null;#a=0;#o=new Set;#l=new Map;#c=null;#h=!1;#u=-1;#d=null;#p=null;set columns(t){this.#t=Array.isArray(t)?t:[],this.#b()}get columns(){return this.#t}set data(t){this.#e=Array.isArray(t)?t:[],this.#o.clear(),this.#a=0,this.#b()}get data(){return this.#e}get selected(){return[...this.#o].sort((t,e)=>t-e)}set selected(t){if(this.#o.clear(),t)for(let e of t)Number.isInteger(e)&&e>=0&&e<this.#e.length&&this.#o.add(e);this.#b(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:this.selected},bubbles:!0}))}clearSelection(){this.#o.size!==0&&(this.#o.clear(),this.#b(),this.dispatchEvent(new CustomEvent("select",{detail:{selected:[]},bubbles:!0})))}get sortState(){return this.#i.map(t=>({...t}))}setFilter(t,e,i="contains"){e==null||e===""?this.#s.delete(t):this.#s.set(t,{op:i,value:e}),this.#a=0,this.#b(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:Object.fromEntries(this.#s)},bubbles:!0}))}clearFilters(){this.#s.clear(),this.#d=null,this.#a=0,this.#b(),this.dispatchEvent(new CustomEvent("filter-change",{detail:{filters:{}},bubbles:!0}))}get filters(){return Object.fromEntries(this.#s)}toggleExpand(t){this.#n.has(t)?(this.#n.delete(t),this.dispatchEvent(new CustomEvent("row-collapse",{detail:{index:t,row:this.#e[t]},bubbles:!0}))):(this.#n.add(t),this.dispatchEvent(new CustomEvent("row-expand",{detail:{index:t,row:this.#e[t]},bubbles:!0}))),this.#b()}get expanded(){return[...this.#n]}expandRenderer=null;getState(){return{sort:this.#i.map(t=>({...t})),filters:Object.fromEntries(this.#s),columnWidths:Object.fromEntries(this.#l),hiddenColumns:this.#t.filter(t=>t.hidden).map(t=>t.key),page:this.#a,density:this.density}}setState(t){if(t){if(t.sort&&(this.#i=t.sort),t.filters){this.#s.clear();for(let[e,i]of Object.entries(t.filters))this.#s.set(e,i)}if(t.columnWidths){this.#l.clear();for(let[e,i]of Object.entries(t.columnWidths))this.#l.set(e,i)}if(t.hiddenColumns)for(let e of this.#t)e.hidden=t.hiddenColumns.includes(e.key);t.page!=null&&(this.#a=t.page),t.density&&(this.density=t.density),this.#b()}}#f(){let t=this.getAttribute("state-key");if(t)try{localStorage.setItem(`table-state:${t}`,JSON.stringify(this.getState()))}catch{}}#m(){let t=this.getAttribute("state-key");if(t)try{let e=localStorage.getItem(`table-state:${t}`);e&&this.setState(JSON.parse(e))}catch{}}connected(){this.#O(),this.setAttribute("role","grid"),this.setAttribute("tabindex","0"),this.#m(),this.#h||(this.#h=!0,this.addEventListener("click",this.#N),this.addEventListener("keydown",this.#_),this.addEventListener("pointerdown",this.#T))}disconnected(){this.removeEventListener("click",this.#N),this.removeEventListener("keydown",this.#_),this.removeEventListener("pointerdown",this.#T),this.#h=!1,this.#R(),this.#g&&(cancelAnimationFrame(this.#g),this.#g=null),this.#p!=null&&(cancelAnimationFrame(this.#p),this.#p=null)}#O(){let t=this.querySelectorAll(":scope > col-def");if(!t.length)return;let e=[];for(let i of t){let n={key:i.getAttribute("key")||"",label:i.getAttribute("label")||i.getAttribute("key")||"",type:i.getAttribute("type")||"text",pinned:i.getAttribute("pinned")||null,hidden:i.hasAttribute("hidden"),sortable:i.hasAttribute("sortable"),resizable:i.hasAttribute("resizable"),filterable:i.hasAttribute("filterable"),filterType:i.getAttribute("filter-type")||null},r=i.getAttribute("width");r&&(n.width=Number(r));let o=i.getAttribute("min-width");o&&(n.minWidth=Number(o));let a=i.getAttribute("max-width");a&&(n.maxWidth=Number(a));let l=i.getAttribute("flex");l&&(n.flex=Number(l)),e.push(n),i.remove()}e.length&&!this.#t.length&&(this.#t=e)}#g=null;#b(){!this.isConnected||this.#g||(this.#g=requestAnimationFrame(()=>{this.#g=null,this.render(),this.#f()}))}get#y(){return this.#t.filter(t=>!t.hidden)}#w(){let t=[];this.expandable&&t.push("2.5rem"),this.selectable&&t.push("2.5rem");for(let e of this.#y)this.#l.has(e.key)?t.push(`${this.#l.get(e.key)}px`):e.width?t.push(`${e.width}px`):e.flex?t.push(`minmax(6rem, ${e.flex}fr)`):t.push("minmax(6rem, 1fr)");return t.join(" ")}#v(){let t=this.#e.map((e,i)=>i);if(this.search){let e=this.search.toLowerCase();t=t.filter(i=>{let n=this.#e[i];return this.#y.some(r=>{let o=di(n,r);return o!=null&&String(o).toLowerCase().includes(e)})})}return this.#s.size&&(t=t.filter(e=>{let i=this.#e[e];for(let[n,{op:r,value:o}]of this.#s){let a=this.#t.find(u=>u.key===n),l=di(i,a||{key:n}),h=String(l??"").toLowerCase(),c=String(o).toLowerCase();switch(r){case"contains":if(!h.includes(c))return!1;break;case"equals":if(h!==c)return!1;break;case"startsWith":if(!h.startsWith(c))return!1;break;case"gt":if(Number(l)<=Number(o))return!1;break;case"lt":if(Number(l)>=Number(o))return!1;break;case"gte":if(Number(l)<Number(o))return!1;break;case"lte":if(Number(l)>Number(o))return!1;break;case"between":{let[u,d]=String(o).split(",").map(Number),f=Number(l);if(f<u||f>d)return!1;break}case"select":{if(!c.split(",").map(d=>d.trim()).includes(h))return!1;break}default:if(!h.includes(c))return!1}}return!0})),this.#i.length&&t.sort((e,i)=>{for(let{key:n,dir:r}of this.#i){let o=this.#t.find(u=>u.key===n),a=di(this.#e[e],o||{key:n}),l=di(this.#e[i],o||{key:n}),h;if(typeof o?.sortFn=="function")h=o.sortFn;else{let u=Xi[o?.type||"text"],d=o?.sortFn||u?.sortFn||"alphanumeric";h=Zd[d]||Zd.alphanumeric}if(a==null&&l==null)continue;if(a==null)return 1;if(l==null)return-1;let c=h(a,l);if(c!==0)return r==="asc"?c:-c}return 0}),t}#k(t){if(!this.paginate||this.paginate<=0)return t;let e=this.#a*this.paginate;return t.slice(e,e+this.paginate)}get#S(){if(!this.paginate||this.paginate<=0)return 1;let t=this.#v().length;return Math.max(1,Math.ceil(t/this.paginate))}render(){if(this.raw)return;let t=this.#y;this.style.gridTemplateColumns=this.#w();let e=this.querySelector(":scope > [data-header]");e||(e=document.createElement("div"),e.setAttribute("role","row"),e.setAttribute("data-header",""),this.prepend(e)),this.#x(e,t),this.#q();let i=this.querySelector(":scope > [data-body]");i||(i=document.createElement("div"),i.setAttribute("role","rowgroup"),i.setAttribute("data-body",""),e.after(i));let n=this.#v(),r=this.#k(n),o=[];for(let c of r){let u=i.querySelector(`:scope > [role="row"][data-index="${c}"]`),d=u||this.#A(c,t);if(u&&this.#E(u,c,t),this.expandable&&(this.#n.has(c)?d.setAttribute("data-expanded",""):d.removeAttribute("data-expanded")),o.push(d),this.expandable&&this.#n.has(c)){let f=i.querySelector(`:scope > [data-detail-row][data-for="${c}"]`);if(!f&&(f=document.createElement("div"),f.setAttribute("data-detail-row",""),f.dataset.for=c,this.expandRenderer)){let p=this.expandRenderer(this.#e[c],c);p instanceof Node?f.appendChild(p):f.textContent=String(p)}o.push(f)}}let a=[...i.children];for(let c of a)o.includes(c)||c.remove();for(let c=0;c<o.length;c++)i.children[c]!==o[c]&&(i.children[c]?i.insertBefore(o[c],i.children[c]):i.appendChild(o[c]));this.#C(i),this.#$(i,n,t);let l=this.paginate>0&&this.#e.length>0,h=this.querySelector(":scope > [data-footer]");l?(h||(h=document.createElement("div"),h.setAttribute("data-footer",""),this.appendChild(h)),this.#L(h,n.length)):h&&h.remove()}#x(t,e){let i=this.#e.length>0&&this.#o.size===this.#e.length,n=[];if(this.selectable){let r=document.createElement("div");r.setAttribute("role","columnheader"),r.setAttribute("data-check-col","");let o=document.createElement("check-ui");i&&o.setAttribute("checked",""),o.setAttribute("aria-label","Select all rows"),r.appendChild(o),n.push(r)}for(let r of e){let o=document.createElement("div");o.setAttribute("role","columnheader");let a=document.createElement("span");if(a.textContent=r.label||r.key,o.appendChild(a),r.sortable!==!1&&this.sortable){o.dataset.sortKey=r.key,o.setAttribute("aria-label",`Sort by ${r.label||r.key}`);let h=document.createElement("icon-ui");h.setAttribute("data-sort-icon","");let c=this.#i.find(u=>u.key===r.key);c?(o.setAttribute("aria-sort",c.dir==="asc"?"ascending":"descending"),h.setAttribute("name",c.dir==="asc"?"arrow-up":"arrow-down")):h.setAttribute("name","caret-up-down"),o.appendChild(h)}if(r.pinned&&o.setAttribute("data-pinned",r.pinned),r.resizable!==!1){let h=document.createElement("div");h.setAttribute("data-resize-handle",""),h.dataset.resizeKey=r.key,o.appendChild(h)}if(r.filter){let h=document.createElement("button");h.setAttribute("data-filter-btn",""),h.dataset.filterKey=r.key,h.setAttribute("aria-label",`Filter ${r.label||r.key}`);let c=document.createElement("icon-ui");if(c.setAttribute("name",this.#s.has(r.key)?"funnel-simple-fill":"funnel-simple"),c.setAttribute("size","xs"),h.appendChild(c),o.appendChild(h),this.#d===r.key){let u=this.#P(r);o.appendChild(u),o.setAttribute("data-filter-open","")}}n.push(o)}for(;t.children.length>n.length;)t.lastChild.remove();for(let r=0;r<n.length;r++)t.children[r]?t.replaceChild(n[r],t.children[r]):t.appendChild(n[r])}#A(t,e){let i=document.createElement("div");return i.setAttribute("role","row"),this.#E(i,t,e),i}#E(t,e,i){let n=this.#e[e],r=this.#o.has(e);t.dataset.index=e,r?(t.setAttribute("data-selected",""),t.setAttribute("aria-selected","true")):(t.removeAttribute("data-selected"),t.removeAttribute("aria-selected"));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-expand-col","");let l=document.createElement("button");l.setAttribute("data-expand-toggle",""),l.setAttribute("aria-label","Expand row");let h=document.createElement("icon-ui");h.setAttribute("name","caret-right"),h.setAttribute("size","xs"),l.appendChild(h),a.appendChild(l),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),a.setAttribute("data-check-col","");let l=document.createElement("check-ui");r&&l.setAttribute("checked",""),l.setAttribute("aria-label",`Select row ${e+1}`),a.appendChild(l),o.push(a)}for(let a of i){let l=document.createElement("div");l.setAttribute("role","gridcell"),l.dataset.key=a.key;let h=di(n,a);if(typeof a.render=="function"){let u=a.render(h,n,l,e);u instanceof Node?l.replaceChildren(u):typeof u=="string"&&(l.innerHTML=u)}else if(typeof a.format=="function"){let u=a.format(h,n);l.appendChild(Object.assign(document.createElement("span"),{textContent:u})),l.title=u}else{let u=Xi[a.type||"text"];if(u?.render)u.render(h,n,l,a.meta);else{let d=h!=null?String(h):"";l.appendChild(Object.assign(document.createElement("span"),{textContent:d})),l.title=d}}let c=Xi[a.type||"text"];c?.align&&(l.dataset.align=c.align),a.pinned&&l.setAttribute("data-pinned",a.pinned),a.wrap&&l.setAttribute("data-wrap",""),o.push(l)}for(;t.children.length>o.length;)t.lastChild.remove();for(let a=0;a<o.length;a++)t.children[a]?t.replaceChild(o[a],t.children[a]):t.appendChild(o[a])}#C(t){let e=this.querySelector(":scope > [data-empty]"),i=this.querySelector(":scope > [data-loading]");if(this.loading){this.setAttribute("aria-busy","true");let n=this.#y,r=this.paginate>0?Math.min(this.paginate,8):5,o=(this.expandable?1:0)+(this.selectable?1:0)+n.length;for(;t.firstChild;)t.firstChild.remove();for(let a=0;a<r;a++){let l=document.createElement("div");l.setAttribute("role","row"),l.setAttribute("data-skeleton-row","");for(let h=0;h<o;h++){let c=document.createElement("div");c.setAttribute("role","gridcell");let u=document.createElement("skeleton-ui"),d=["60%","80%","70%","50%","90%"];u.setAttribute("width",d[h%d.length]),u.setAttribute("height","1em"),u.setAttribute("radius","sm"),c.appendChild(u),l.appendChild(c)}t.appendChild(l)}i&&i.remove(),e&&e.remove()}else if(this.#e.length===0){if(this.removeAttribute("aria-busy"),!e){e=document.createElement("div"),e.setAttribute("data-empty","");let n=document.createElement("icon-ui");n.setAttribute("name","table");let r=document.createElement("span");r.textContent="No data",e.appendChild(n),e.appendChild(r),t.after(e)}i&&i.remove()}else this.removeAttribute("aria-busy"),e&&e.remove(),i&&i.remove()}#$(t,e,i){let n=i.some(a=>a.aggregate),r=this.querySelector(":scope > [data-agg-row]");if(!n||this.#e.length===0){r&&r.remove();return}r||(r=document.createElement("div"),r.setAttribute("role","row"),r.setAttribute("data-agg-row",""),t.after(r));let o=[];if(this.expandable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}if(this.selectable){let a=document.createElement("div");a.setAttribute("role","gridcell"),o.push(a)}for(let a of i){let l=document.createElement("div");if(l.setAttribute("role","gridcell"),a.aggregate){let h=e.map(d=>{let f=di(this.#e[d],a);return f!=null?Number(f):NaN}).filter(d=>!isNaN(d)),c;switch(a.aggregate){case"sum":c=h.reduce((d,f)=>d+f,0);break;case"avg":c=h.length?h.reduce((d,f)=>d+f,0)/h.length:0;break;case"min":c=h.length?Math.min(...h):0;break;case"max":c=h.length?Math.max(...h):0;break;case"count":c=e.length;break;default:c=""}let u=Xi[a.type||"text"];typeof c=="number"&&u?.render?u.render(c,{},l,a.meta):l.textContent=typeof c=="number"?c.toLocaleString():c}o.push(l)}for(;r.children.length>o.length;)r.lastChild.remove();for(let a=0;a<o.length;a++)r.children[a]?r.replaceChild(o[a],r.children[a]):r.appendChild(o[a])}#L(t,e){let i=t.querySelector("pagination-ui");i||(t.innerHTML="",i=document.createElement("pagination-ui"),i.addEventListener("page-change",r=>{this.#a=r.detail.page-1,this.render(),this.dispatchEvent(new CustomEvent("page",{bubbles:!0,detail:{page:this.#a}}))}),t.appendChild(i));let n=this.paginate>0?Math.max(1,Math.ceil(e/this.paginate)):1;i.setAttribute("page",String(this.#a+1)),i.setAttribute("total",String(n))}#P(t){let e=document.createElement("div");e.setAttribute("data-filter-dropdown","");let i=this.#s.get(t.key);if(t.filter==="select"){let n=[...new Set(this.#e.map(o=>{let a=di(o,t);return a!=null?String(a):""}))].filter(Boolean).sort(),r=new Set(i?.op==="select"?String(i.value).split(","):[]);for(let o of n){let a=document.createElement("label");a.setAttribute("data-filter-option","");let l=document.createElement("input");l.type="checkbox",l.value=o,l.checked=r.has(o.toLowerCase()),l.addEventListener("change",()=>{let h=[...e.querySelectorAll("input[type=checkbox]:checked")].map(c=>c.value);h.length?this.setFilter(t.key,h.join(","),"select"):this.setFilter(t.key,null)}),a.appendChild(l),a.appendChild(document.createTextNode(` ${o}`)),e.appendChild(a)}}else if(t.filter==="number"){let n=document.createElement("input");n.type="number",n.placeholder="Filter...",n.value=i?.value??"",n.setAttribute("data-filter-input","");let r=document.createElement("select");r.setAttribute("data-filter-op","");for(let[a,l]of[["gte","\u2265"],["lte","\u2264"],["gt",">"],["lt","<"],["equals","="]]){let h=document.createElement("option");h.value=a,h.textContent=l,i?.op===a&&(h.selected=!0),r.appendChild(h)}let o=()=>{n.value?this.setFilter(t.key,n.value,r.value):this.setFilter(t.key,null)};n.addEventListener("input",o),r.addEventListener("change",o),e.appendChild(r),e.appendChild(n)}else{let n=document.createElement("input");n.type="text",n.placeholder=`Filter ${t.label||t.key}...`,n.value=i?.value??"",n.setAttribute("data-filter-input",""),n.addEventListener("input",()=>{n.value?this.setFilter(t.key,n.value,"contains"):this.setFilter(t.key,null)}),e.appendChild(n)}if(i){let n=document.createElement("button");n.textContent="Clear",n.setAttribute("data-filter-clear",""),n.addEventListener("click",()=>{this.setFilter(t.key,null),this.#d=null,this.#b()}),e.appendChild(n)}return this.#p!=null&&cancelAnimationFrame(this.#p),this.#p=requestAnimationFrame(()=>{if(this.#p=null,!this.isConnected)return;let n=e.querySelector("input");n&&n.focus()}),e}#q(){let t=this.querySelector(":scope > [data-filter-bar]");if(this.#s.size===0){t&&t.remove();return}if(!t){t=document.createElement("div"),t.setAttribute("data-filter-bar",""),t.setAttribute("role","status");let i=this.querySelector(":scope > [data-header]");i?i.after(t):this.prepend(t)}t.innerHTML="";for(let[i,{op:n,value:r}]of this.#s){let a=this.#t.find(u=>u.key===i)?.label||i,l=document.createElement("badge-ui"),h=n==="select"?`${r.split(",").length} selected`:r;l.setAttribute("text",`${a}: ${h}`),l.setAttribute("size","xs"),l.setAttribute("data-filter-chip",i);let c=document.createElement("button");c.textContent="\xD7",c.setAttribute("data-chip-dismiss",""),c.addEventListener("click",u=>{u.stopPropagation(),this.setFilter(i,null)}),l.appendChild(c),t.appendChild(l)}let e=document.createElement("button");e.textContent="Clear all",e.setAttribute("data-filter-clear-all",""),e.addEventListener("click",()=>this.clearFilters()),t.appendChild(e)}#T=t=>{if(t.button!==void 0&&t.button!==0)return;let e=t.target.closest("[data-resize-handle]");e&&this.contains(e)&&(t.preventDefault(),this.#Q(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.#d=this.#d===c?null:c,this.#b();return}this.#d&&!e.closest("[data-filter-dropdown]")&&!e.closest("[data-filter-btn]")&&(this.#d=null,this.#b());let n=e.closest("[data-expand-toggle]");if(n&&this.expandable&&this.contains(n)){let c=n.closest('[role="row"]');c?.dataset?.index!=null&&this.toggleExpand(Number(c.dataset.index));return}let r=e.closest("[data-resize-handle]");if(r&&this.contains(r)){this.#Q(t,r);return}let o=e.closest("[data-sort-key]");if(o&&this.sortable&&this.contains(o)){let c=o.dataset.sortKey,u=this.#i.findIndex(m=>m.key===c),f=this.#t.find(m=>m.key===c)?.sortDescFirst?"desc":"asc",p=f==="asc"?"desc":"asc";if(t.shiftKey)if(u>=0){let m=this.#i[u];m.dir===p?this.#i.splice(u,1):m.dir=m.dir===f?p:f}else this.#i.push({key:c,dir:f});else if(u>=0&&this.#i.length===1){let m=this.#i[0];m.dir===p?this.#i=[]:m.dir=m.dir===f?p:f}else this.#i=[{key:c,dir:f}];this.render(),this.dispatchEvent(new CustomEvent("sort",{bubbles:!0,detail:{key:c,dir:this.#i.find(m=>m.key===c)?.dir||null,sortState:this.sortState}}));return}let a=e.closest("[data-header] check-ui");if(a&&this.selectable){if(a.hasAttribute("checked"))for(let u=0;u<this.#e.length;u++)this.#o.add(u);else this.#o.clear();this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}));return}let l=e.closest('[role="row"]:not([data-header]) check-ui');if(l&&this.selectable){let c=l.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=l.hasAttribute("checked");if(t.shiftKey&&this.#u>=0){let f=Math.min(this.#u,u),p=Math.max(this.#u,u);for(let m=f;m<=p;m++)d?this.#o.add(m):this.#o.delete(m)}else d?this.#o.add(u):this.#o.delete(u);this.#u=u,this.render(),this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{selected:this.selected}}))}return}let h=e.closest('[role="gridcell"][data-key]');if(h&&this.contains(h)){let c=h.closest('[role="row"]'),u=c?+c.dataset.index:-1;if(u>=0){let d=h.dataset.key,f=this.#e[u],p=this.#t.find(b=>b.key===d),m=p?di(f,p):void 0;this.dispatchEvent(new CustomEvent("cell-click",{bubbles:!0,detail:{key:d,row:f,value:m,dataIndex:u}})),this.dispatchEvent(new CustomEvent("row-click",{bubbles:!0,detail:{row:f,dataIndex:u}}))}}};#M=null;#Q(t,e){t.preventDefault(),t.stopPropagation();let i=e.dataset.resizeKey,n=this.#t.find(l=>l.key===i);if(!n)return;let r=e.closest('[role="columnheader"]'),o=r?r.getBoundingClientRect().width:100,a=t.clientX;this.setAttribute("data-resizing",""),this.#M={key:i,col:n,startX:a,startWidth:o},document.addEventListener("pointermove",this.#D),document.addEventListener("pointerup",this.#I)}#D=t=>{if(!this.#M)return;let{key:e,col:i,startX:n,startWidth:r}=this.#M,o=t.clientX-n,a=r+o,l=i.minWidth||48,h=i.maxWidth||1/0;a=Math.max(l,Math.min(h,a)),this.#l.set(e,Math.round(a)),this.style.gridTemplateColumns=this.#w()};#I=t=>{if(!this.#M)return;let{key:e}=this.#M;document.removeEventListener("pointermove",this.#D),document.removeEventListener("pointerup",this.#I),this.removeAttribute("data-resizing");let i=this.#l.get(e);this.#M=null,this.dispatchEvent(new CustomEvent("resize",{bubbles:!0,detail:{key:e,width:i}})),this.render()};#R(){document.removeEventListener("pointermove",this.#D),document.removeEventListener("pointerup",this.#I),this.#M=null}#_=t=>{let i=this.#y.length+(this.selectable?1:0),n=this.querySelector(":scope > [data-body]"),r=n?n.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,r-1);break;case"ArrowUp":o=Math.max(o-1,-1);break;case"ArrowRight":a=Math.min(a+1,i-1);break;case"ArrowLeft":a=Math.max(a-1,0);break;case"Tab":if(t.shiftKey?(a--,a<0&&(a=i-1,o--)):(a++,a>=i&&(a=0,o++)),o<-1||o>=r){l=!1;break}break;case"Enter":if(o===-1){let c=this.querySelector(":scope > [data-header]")?.children[a];c?.dataset.sortKey&&c.click()}else{let h=this.querySelector("[data-focused]");h&&h.click()}break;default:l=!1}l&&(t.preventDefault(),this.#c={row:o,col:a},this.#Z())};#Z(){let t=this.querySelector("[data-focused]");if(t&&t.removeAttribute("data-focused"),!this.#c)return;let{row:e,col:i}=this.#c,n;e===-1?n=this.querySelector(":scope > [data-header]")?.children[i]:n=this.querySelector(":scope > [data-body]")?.children[e]?.children[i],n&&(n.setAttribute("data-focused",""),n.scrollIntoView?.({block:"nearest",inline:"nearest"}))}exportCSV(t="export.csv"){let e=this.#y,i=this.#v(),n=e.map(c=>yh(c.label||c.key)),r=i.map(c=>{let u=this.#e[c];return e.map(d=>{let f=di(u,d);if(typeof d.format=="function")return yh(d.format(f,u));let p=Xi[d.type||"text"];return p?.format?yh(p.format(f,u,d.meta)):yh(f)})}),o=[n.join(","),...r.map(c=>c.join(","))].join(`
|
|
177
177
|
`),a=new Blob([o],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(a),h=document.createElement("a");h.href=l,h.download=t,h.style.display="none",document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(l)}};S("table-ui",Xn);P();var uC=200;function Bd(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 zd(s){let t=document.createElement("text-ui");return t.setAttribute("data-popover-head",""),t.setAttribute("variant","kicker"),t.setAttribute("color","subtle"),t.textContent=s,t}var dC=50,ey=500;function iy(s,t){if(typeof t?.accessor=="function")return t.accessor(s);let e=t?.key;if(!e||s==null)return;let i=String(e).split("."),n=s;for(let r of i){if(n==null)return;n=n[r]}return n}function fC(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 pC(s,t){if(s?.filter==="select"||s?.filter==="text")return s.filter;if(fC(s?.key))return"text";let e=[],i=Math.min(t?.length??0,ey),n=new Set;for(let r=0;r<i;r++){let o=iy(t[r],s);if(!(o==null||o==="")&&(e.push(o),n.add(String(o)),n.size>dC))return"text"}return e.length?"select":"text"}function mC(s,t){let e=new Set,i=Math.min(t?.length??0,ey);for(let n=0;n<i;n++){let r=iy(t[n],s);r==null||r===""||e.add(String(r))}return[...e].sort((n,r)=>n.localeCompare(r,void 0,{numeric:!0}))}var Nn=class s extends x{static properties={for:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!1},count:{type:String,default:"",reflect:!1},noFilter:{type:Boolean,default:!1,reflect:!0,attribute:"no-filter"},noSort:{type:Boolean,default:!1,reflect:!0,attribute:"no-sort"},noColumns:{type:Boolean,default:!1,reflect:!0,attribute:"no-columns"},noSearch:{type:Boolean,default:!1,reflect:!0,attribute:"no-search"},placeholder:{type:String,default:"Search...",reflect:!1},variant:{type:String,default:"default",reflect:!0}};static requiredIcons=["arrow-up","arrow-down","caret-up-down"];static template=()=>null;#t=null;#e=[];#i=null;#s=!1;#n=null;#r=new Set;static _warnedUnknownAttrs=new WeakSet;static _CANONICAL_OPT_OUT_ATTRS=new Set(["no-search","no-filter","no-sort","no-columns"]);static _OPT_OUT_PREFIX_RE=/^(search|export|sort|filter|column)/i;connected(){this.setAttribute("role","toolbar"),this.#a(),this.#h(),this.#o(),this.#O()}disconnected(){this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null);for(let t of this.#r)cancelAnimationFrame(t);this.#r.clear(),this.#b(),this.#c()}render(){this.#o(),this.#O(),this.#p()}#a(){if(s._warnedUnknownAttrs.has(this))return;let t=[];for(let i of this.attributes){let n=i.name.toLowerCase();s._CANONICAL_OPT_OUT_ATTRS.has(n)||s._OPT_OUT_PREFIX_RE.test(n)&&t.push(n)}if(t.length===0)return;s._warnedUnknownAttrs.add(this);let e=t.map(i=>`"${i}"`).join(", ");console.warn(`[table-toolbar-ui] Unknown opt-out attribute(s) ${e}. Canonical opt-out attrs are: no-search, no-filter, no-sort, no-columns. See packages/web-components/components/table-toolbar/table-toolbar.yaml or run \`npx adia-ui-doc table-toolbar\` for the full attribute reference.`)}#o(){let t=this.#l();if(t===this.#t||(this.#c(),!t))return;this.#t=t;let e=()=>this.#x(),i=()=>this.#k();t.addEventListener("sort",e),t.addEventListener("filter-change",i),this.#e.push(["sort",e],["filter-change",i])}#l(){if(this.for){let i=this.getRootNode?.()?.getElementById?.(this.for)||document.getElementById(this.for);return i&&i.tagName?.toLowerCase()==="table-ui"?i:null}let t=this.parentElement;return t&&t.querySelector(":scope table-ui")||null}#c(){if(this.#t)for(let[t,e]of this.#e)this.#t.removeEventListener(t,e);this.#e=[],this.#t=null}#h(){if(this.querySelector(":scope > [data-toolbar]"))return;let t=document.createElement("div");t.setAttribute("data-toolbar","");let e=document.createElement("div");e.setAttribute("data-title","");let i=document.createElement("span");i.setAttribute("data-heading",""),e.appendChild(i);let n=document.createElement("badge-ui");n.setAttribute("data-count-badge",""),n.setAttribute("size","sm"),n.setAttribute("variant","muted"),n.hidden=!0,e.appendChild(n);let r=document.createElement("div");r.setAttribute("data-controls",""),r.appendChild(this.#d("filter","Filter","funnel-simple")),r.appendChild(this.#d("sort","Sort","arrows-down-up")),r.appendChild(this.#d("columns","Columns","columns"));let o=document.createElement("search-ui");o.setAttribute("data-search",""),o.setAttribute("size","sm"),o.setAttribute("placeholder",this.placeholder),o.setAttribute("debounce",String(uC)),o.addEventListener("search",this.#m);let a=document.createElement("div");a.setAttribute("data-actions","");for(let l of[...this.children])l!==t&&l.getAttribute?.("slot")==="actions"&&a.appendChild(l);t.appendChild(e),t.appendChild(r),t.appendChild(o),t.appendChild(a),this.appendChild(t),this.#p(),this.#f()}#u(t,e){let i=document.createElement("button-ui");return i.setAttribute("data-popover-action",""),i.setAttribute("text",t),i.setAttribute("variant","ghost"),i.setAttribute("size","sm"),i.setAttribute("stretch",""),i.addEventListener("click",e),i}#d(t,e,i){let n=document.createElement("button-ui");return n.setAttribute("data-toolbar-btn",t),n.setAttribute("icon",i),n.setAttribute("text",e),n.setAttribute("variant","outline"),n.setAttribute("size","sm"),n.setAttribute("aria-haspopup","menu"),n.addEventListener("click",r=>{r.stopPropagation(),this.#g(t,n)}),n}#p(){let t=this.querySelector(":scope [data-heading]");if(!t)return;this.text?(t.textContent=this.text,t.hidden=!1):t.textContent.trim()?t.hidden=!1:t.hidden=!0;let e=this.querySelector(":scope [data-count-badge]");if(!e)return;let i=this.count?.toString().trim(),n=this.#t?.data?.length,r=i||(Number.isFinite(n)?String(n):"");r?(e.setAttribute("text",r),e.hidden=!1):e.hidden=!0}#f(){let t=this.querySelector(":scope > [data-toolbar]");if(!t)return;let e=(i,n)=>{let r=t.querySelector(i);r&&(r.hidden=n)};e('[data-toolbar-btn="filter"]',this.noFilter),e('[data-toolbar-btn="sort"]',this.noSort),e('[data-toolbar-btn="columns"]',this.noColumns),e("[data-search]",this.noSearch)}attributeChanged(t){["no-filter","no-sort","no-columns","no-search"].includes(t)&&this.#f(),t==="placeholder"&&this.querySelector(":scope [data-search]")?.setAttribute("placeholder",this.placeholder)}#m=t=>{let e=t.detail?.value??"";this.#t&&(this.#t.search=e),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:e}}))};#O(){if(!this.#t)return;let t=this.querySelector(":scope [data-search]");t&&this.#t.search&&(t.value=this.#t.search),this.#p()}#g(t,e){if(this.#i?.kind===t){this.#b();return}this.#b();let i=document.createElement("div");i.setAttribute("data-toolbar-popover",t),i.setAttribute("popover","manual"),i.setAttribute("role","menu"),t==="filter"&&this.#v(i),t==="sort"&&this.#S(i),t==="columns"&&this.#A(i),document.body.appendChild(i);try{i.showPopover()}catch{}let n=ct(e,i,{placement:"bottom",gap:4});this.#i={kind:t,btn:e,panel:i,cleanup:n},this.#s||(this.#s=!0,this.#n=requestAnimationFrame(()=>{this.#n=null,!(!this.isConnected||!this.#s)&&(document.addEventListener("pointerdown",this.#y,!0),document.addEventListener("keydown",this.#w,!0))}))}#b(){let t=this.#i;if(t){if(t.cleanup?.(),t.panel?.matches?.(":popover-open"))try{t.panel.hidePopover()}catch{}t.panel?.remove(),this.#i=null,this.#s&&(this.#s=!1,document.removeEventListener("pointerdown",this.#y,!0),document.removeEventListener("keydown",this.#w,!0))}}#y=t=>{let e=this.#i;e&&(e.btn.contains(t.target)||e.panel.contains(t.target)||this.#b())};#w=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#b(),this.#i?.btn?.focus?.({preventScroll:!0}))};#v(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Bd("No filterable columns"));return}let i=e.filters||{};t.appendChild(zd("Filter rows"));let n=document.createElement("div");n.setAttribute("data-popover-list","");let r=e.data||[];for(let o of e.columns){if(o.hidden)continue;let a=document.createElement("field-ui");a.setAttribute("data-filter-row",""),a.setAttribute("inline",""),a.setAttribute("label",o.label||o.key);let l=pC(o,r),h=i[o.key];if(l==="select"){let c=document.createElement("select-ui");c.setAttribute("data-filter-input",""),c.setAttribute("multiple",""),c.setAttribute("placeholder","\u2014");let u=mC(o,r);u.length>=12&&c.setAttribute("searchable","");for(let d of u){let f=document.createElement("option");f.setAttribute("value",d),f.textContent=d,c.appendChild(f)}h?.op==="select"&&h.value&&(c.value=h.value),c.addEventListener("change",()=>{let d=c.value||"";d?e.setFilter(o.key,d,"select"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}else{let c=document.createElement("input-ui");c.setAttribute("type","text"),c.setAttribute("size","sm"),c.setAttribute("data-filter-input",""),c.setAttribute("placeholder","\u2014"),h?.op==="contains"&&(c.value=h.value??""),c.addEventListener("input",()=>{let u=c.value;u?e.setFilter(o.key,u,"contains"):e.setFilter(o.key,null),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:e.filters}}))}),a.appendChild(c)}n.appendChild(a)}if(t.appendChild(n),Object.keys(i).length){let o=this.#u("Clear all filters",()=>{e.clearFilters(),this.dispatchEvent(new CustomEvent("filter-change",{bubbles:!0,detail:{filters:{}}})),this.#k()});t.appendChild(o)}}#k(){let t=this.#i;!t||t.kind!=="filter"||(t.panel.replaceChildren(),this.#v(t.panel))}#S(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Bd("No sortable columns"));return}t.appendChild(zd("Sort by"));let i=e.sortState||[],n=new Map(i.map(o=>[o.key,o.dir])),r=document.createElement("div");r.setAttribute("data-popover-list","");for(let o of e.columns){if(o.hidden||o.sortable===!1)continue;let a=n.get(o.key),l=document.createElement("menu-item-ui");l.setAttribute("data-sort-row",""),l.setAttribute("text",o.label||o.key),l.dataset.key=o.key,a&&(l.dataset.active=a);let h=requestAnimationFrame(()=>{if(this.#r.delete(h),!this.isConnected)return;let c=document.createElement("icon-ui");c.setAttribute("data-sort-indicator",""),c.setAttribute("size","xs"),c.setAttribute("name",a==="asc"?"arrow-up":a==="desc"?"arrow-down":"caret-up-down"),l.appendChild(c)});this.#r.add(h),l.addEventListener("click",c=>{let u=e.querySelector(`:scope > [data-header] [data-sort-key="${o.key}"]`);if(!u)return;let d=new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c.shiftKey});u.dispatchEvent(d),this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#x()}),r.appendChild(l)}if(t.appendChild(r),i.length){let o=this.#u("Clear sort",()=>{for(let a of[...i]){let l=e.querySelector(`:scope > [data-header] [data-sort-key="${a.key}"]`);if(!l)continue;let h=c=>l.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,shiftKey:c}));i.length>1?(h(!0),h(!0)):(h(!1),h(!1))}this.dispatchEvent(new CustomEvent("sort-change",{bubbles:!0,detail:{sortState:e.sortState}})),this.#x()});t.appendChild(o)}}#x(){let t=this.#i;!t||t.kind!=="sort"||(t.panel.replaceChildren(),this.#S(t.panel))}#A(t){let e=this.#t;if(!e?.columns?.length){t.appendChild(Bd("No columns"));return}t.appendChild(zd("Visible columns"));let i=document.createElement("div");i.setAttribute("data-popover-list","");for(let n of e.columns){let r=document.createElement("field-ui");r.setAttribute("data-columns-row",""),r.setAttribute("inline",""),r.setAttribute("label",n.label||n.key);let o=document.createElement("check-ui");n.hidden||o.setAttribute("checked",""),o.dataset.key=n.key,o.addEventListener("change",()=>{let a=e.columns.map(l=>l.key===n.key?{...l,hidden:!o.hasAttribute("checked")}:{...l});e.columns=a,this.dispatchEvent(new CustomEvent("columns-change",{bubbles:!0,detail:{hiddenColumns:a.filter(l=>l.hidden).map(l=>l.key)}}))}),r.appendChild(o),i.appendChild(r)}t.appendChild(i)}};S("table-toolbar-ui",Nn);P();var Zn=class extends x{static properties={orientation:{type:String,default:"vertical",reflect:!0},size:{type:String,default:"md",reflect:!0}};static template=()=>null;render(){let t=[...this.querySelectorAll(":scope > timeline-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];e&&e.setAttribute("data-last","")}},Bn=class extends x{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},time:{type:String,default:"",reflect:!0},duration:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},status:{type:String,default:"idle",reflect:!0},spinner:{type:Boolean,default:!1,reflect:!0}};static requiredIcons=["caret-down","caret-right"];static template=()=>null;#t=[];#e=!1;get outcomes(){return this.#t}set outcomes(t){this.#t=Array.isArray(t)?t.slice():[],this.render()}connected(){this.querySelector(':scope > [slot="label"]')||(this.innerHTML=`
|
|
178
178
|
<span slot="label"></span>
|
|
179
179
|
<span slot="description"></span>
|
|
@@ -181,13 +181,13 @@ parent-template-re-read pattern that works across frameworks.`);return}if(this.d
|
|
|
181
181
|
`)}render(){let t=this.querySelector(':scope > [slot="label"]'),e=this.querySelector(':scope > [slot="description"]'),i=this.querySelector(':scope > [slot="time"]');if(t&&(t.textContent=this.text),e&&(e.textContent=this.description),i&&(i.textContent=this.duration||this.time),this.icon){let r=this.querySelector(':scope > [slot="icon"]');r||(r=document.createElement("icon-ui"),r.setAttribute("slot","icon"),this.prepend(r)),r.setAttribute("name",this.icon)}else this.querySelector(':scope > [slot="icon"]')?.remove();let n=this.querySelector(':scope > [slot="outcomes"]');if(this.#t.length>0){n||(n=document.createElement("ul"),n.setAttribute("slot","outcomes"),this.appendChild(n)),n.innerHTML="";for(let a of this.#t){let l=document.createElement("li");l.textContent=a,n.appendChild(l)}n.hidden=!this.#e;let r=this.querySelector(":scope > [data-timeline-toggle]");r||(r=document.createElement("button"),r.type="button",r.setAttribute("data-timeline-toggle",""),r.setAttribute("aria-label","Toggle details"),r.addEventListener("click",a=>{a.stopPropagation(),this.#e=!this.#e,this.render(),this.dispatchEvent(new CustomEvent("timeline-toggle",{bubbles:!0,detail:{expanded:this.#e}}))}),this.appendChild(r)),r.innerHTML="";let o=document.createElement("icon-ui");o.setAttribute("name",this.#e?"caret-down":"caret-right"),o.setAttribute("color","muted"),o.setAttribute("size","sm"),r.appendChild(o)}else this.querySelector(":scope > [data-timeline-toggle]")?.remove(),n?.remove()}};S("timeline-ui",Zn),S("timeline-item-ui",Bn);P();var zn=class extends x{static properties={step:{type:Number,default:0,reflect:!0},orientation:{type:String,default:"horizontal",reflect:!0}};static template=()=>null;render(){let t=[...this.querySelectorAll("stepper-item-ui")];for(let i of t)i.removeAttribute("data-last");let e=t[t.length-1];e&&e.setAttribute("data-last",""),t.forEach((i,n)=>{i.setAttribute("data-index",n),n<this.step?i.setAttribute("status","completed"):n===this.step?i.setAttribute("status","active"):i.setAttribute("status","idle")})}next(){let t=this.querySelectorAll("stepper-item-ui").length;this.step<t-1&&this.step++}prev(){this.step>0&&this.step--}goTo(t){let e=this.querySelectorAll("stepper-item-ui").length-1;this.step=Math.max(0,Math.min(t,e))}},_n=class extends x{static properties={text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},status:{type:String,default:"idle",reflect:!0}};static template=()=>null;connected(){this.querySelector('[slot="label"]')||(this.innerHTML=`
|
|
182
182
|
<span slot="label"></span>
|
|
183
183
|
<span slot="description"></span>
|
|
184
|
-
`)}render(){let t=this.querySelector('[slot="label"]'),e=this.querySelector('[slot="description"]');if(t&&(t.textContent=this.text),e&&(e.textContent=this.description),this.icon){let i=this.querySelector('[slot="icon"]');i||(i=document.createElement("icon-ui"),i.setAttribute("slot","icon"),this.prepend(i)),i.setAttribute("name",this.icon)}else this.querySelector('[slot="icon"]')?.remove()}};S("stepper-ui",zn),S("stepper-item-ui",_n);P();var jn=class extends x{static properties={autoplay:{type:Boolean,default:!1,reflect:!0},interval:{type:Number,default:5e3,reflect:!0},noPauseOnHover:{type:Boolean,default:!1,reflect:!0,attribute:"no-pause-on-hover"},loop:{type:Boolean,default:!1,reflect:!0},peek:{type:Boolean,default:!1,reflect:!0},snap:{type:String,default:"start",reflect:!0},gap:{type:String,default:"",reflect:!0},slidesPerView:{type:String,default:"",reflect:!0,attribute:"slides-per-view"},chrome:{type:String,default:"default",reflect:!0},label:{type:String,default:""},counter:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=0;#r=!1;#a=!1;#o=null;get slides(){return this.#t?[...this.#t.children]:[]}get activeIndex(){return this.#n}connected(){if(!this.#t){for(this.#t=document.createElement("div"),this.#t.setAttribute("data-swiper-track","");this.firstChild;)this.#t.appendChild(this.firstChild);this.appendChild(this.#t)}this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),this.getAttribute("aria-label")||this.setAttribute("aria-label","Carousel"),this.#l(),this.#c(),this.#O(),this.#r||(this.#r=!0,this.noPauseOnHover||(this.addEventListener("pointerenter",this.#k),this.addEventListener("pointerleave",this.#S),this.addEventListener("focusin",this.#x),this.addEventListener("focusout",this.#A)),this.addEventListener("keydown",this.#E),this.#t.addEventListener("pointerdown",this
|
|
184
|
+
`)}render(){let t=this.querySelector('[slot="label"]'),e=this.querySelector('[slot="description"]');if(t&&(t.textContent=this.text),e&&(e.textContent=this.description),this.icon){let i=this.querySelector('[slot="icon"]');i||(i=document.createElement("icon-ui"),i.setAttribute("slot","icon"),this.prepend(i)),i.setAttribute("name",this.icon)}else this.querySelector('[slot="icon"]')?.remove()}};S("stepper-ui",zn),S("stepper-item-ui",_n);P();var jn=class extends x{static properties={autoplay:{type:Boolean,default:!1,reflect:!0},interval:{type:Number,default:5e3,reflect:!0},noPauseOnHover:{type:Boolean,default:!1,reflect:!0,attribute:"no-pause-on-hover"},loop:{type:Boolean,default:!1,reflect:!0},peek:{type:Boolean,default:!1,reflect:!0},snap:{type:String,default:"start",reflect:!0},gap:{type:String,default:"",reflect:!0},slidesPerView:{type:String,default:"",reflect:!0,attribute:"slides-per-view"},chrome:{type:String,default:"default",reflect:!0},label:{type:String,default:""},counter:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=0;#r=!1;#a=!1;#o=null;get slides(){return this.#t?[...this.#t.children]:[]}get activeIndex(){return this.#n}connected(){if(!this.#t){for(this.#t=document.createElement("div"),this.#t.setAttribute("data-swiper-track","");this.firstChild;)this.#t.appendChild(this.firstChild);this.appendChild(this.#t)}this.setAttribute("role","region"),this.setAttribute("aria-roledescription","carousel"),this.getAttribute("aria-label")||this.setAttribute("aria-label","Carousel"),this.#l(),this.#c(),this.#O(),this.#r||(this.#r=!0,this.noPauseOnHover||(this.addEventListener("pointerenter",this.#k),this.addEventListener("pointerleave",this.#S),this.addEventListener("focusin",this.#x),this.addEventListener("focusout",this.#A)),this.addEventListener("keydown",this.#E),this.#t.addEventListener("pointerdown",this.#$),this.#t.addEventListener("pointermove",this.#L),this.#t.addEventListener("pointerup",this.#P),this.#t.addEventListener("pointercancel",this.#P),this.#t.addEventListener("click",this.#q,!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.#k),this.removeEventListener("pointerleave",this.#S),this.removeEventListener("focusin",this.#x),this.removeEventListener("focusout",this.#A),this.removeEventListener("keydown",this.#E),this.#t&&(this.#t.removeEventListener("pointerdown",this.#$),this.#t.removeEventListener("pointermove",this.#L),this.#t.removeEventListener("pointerup",this.#P),this.#t.removeEventListener("pointercancel",this.#P),this.#t.removeEventListener("click",this.#q,!0),this.#t.removeEventListener("dragstart",this.#T)),this.#o=null,this.#t=null,this.#r=!1}next(){let t=this.#u()-1,e=this.#m(this.#n),i=Math.min(e+1,t);if(i!==e||this.loop){let n=this.loop&&i===e?0:i;this.goTo(this.#f(n))}}prev(){let t=this.#u()-1,e=this.#m(this.#n),i=Math.max(e-1,0);if(i!==e||this.loop){let n=this.loop&&i===e?t:i;this.goTo(this.#f(n))}}goTo(t){let e=this.slides[t];if(!e||!this.#t)return;let i=Math.max(0,this.#d(e));this.#t.scrollTo({left:i,behavior:"smooth"})}play(){this.pause(),!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(this.#e=setInterval(()=>{let t=this.#u()-1,i=this.#m(this.#n)>=t;i&&this.loop?this.goTo(this.#f(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.#p();t!==this.#n&&(this.#n=t,this.#v(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{index:t,slide:this.slides[t]}})))},this.#t.addEventListener("scroll",this.#s,{passive:!0}),this.#n=this.#p()}#h(){if(!this.#t)return 1;let t=getComputedStyle(this.#t).getPropertyValue("--swiper-columns").trim(),e=parseInt(t,10);return Number.isFinite(e)&&e>0?e:1}#u(){let t=this.slides.length;return t===0?0:this.snap==="center"?t:Math.max(1,t-this.#h()+1)}#d(t){let e=this.#t.clientWidth,i=t.offsetLeft-this.#t.offsetLeft,n=t.offsetWidth;return this.snap==="center"?i+n/2-e/2:this.snap==="end"?i+n-e:i}#p(){if(!this.#t)return 0;let t=this.slides;if(t.length===0)return 0;let e=this.#t.scrollLeft,i=Math.max(0,this.#t.scrollWidth-this.#t.clientWidth),n=0,r=1/0;for(let o=0;o<t.length;o++){let a=Math.max(0,Math.min(i,this.#d(t[o]))),l=Math.abs(e-a);l<r&&(r=l,n=o)}return n}#f(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)}#O(){this.#a||(this.#a=!0,this.chrome==="toolbar"?this.#b():this.#g(),this.#w(),typeof ResizeObserver<"u"&&(this.#i=new ResizeObserver(()=>this.#w()),this.#i.observe(this)))}#g(){let t=document.createElement("button-ui");t.setAttribute("data-swiper-btn",""),t.setAttribute("data-swiper-prev",""),t.setAttribute("icon","caret-left"),t.setAttribute("variant","ghost"),t.setAttribute("aria-label","Previous slide"),t.addEventListener("press",()=>this.prev());let e=document.createElement("button-ui");e.setAttribute("data-swiper-btn",""),e.setAttribute("data-swiper-next",""),e.setAttribute("icon","caret-right"),e.setAttribute("variant","ghost"),e.setAttribute("aria-label","Next slide"),e.addEventListener("press",()=>this.next()),this.appendChild(t),this.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-dots",""),i.setAttribute("role","tablist"),i.setAttribute("aria-label","Slide indicators"),this.appendChild(i)}#b(){let t=document.createElement("div");t.setAttribute("data-swiper-head","");let e=document.createElement("span");e.setAttribute("data-swiper-label",""),e.textContent=this.label||"",t.appendChild(e);let i=document.createElement("div");i.setAttribute("data-swiper-paddles","");let n=document.createElement("button-ui");n.setAttribute("icon","caret-left"),n.setAttribute("variant","ghost"),n.setAttribute("size","sm"),n.setAttribute("aria-label","Previous slide"),n.addEventListener("press",()=>this.prev());let r=document.createElement("button-ui");r.setAttribute("icon","caret-right"),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("aria-label","Next slide"),r.addEventListener("press",()=>this.next()),i.appendChild(n),i.appendChild(r),t.appendChild(i),this.insertBefore(t,this.#t);let o=document.createElement("div");o.setAttribute("data-swiper-foot","");let a=document.createElement("span");a.setAttribute("data-swiper-counter",""),o.appendChild(a);let l=document.createElement("div");l.setAttribute("data-swiper-dots",""),l.setAttribute("role","tablist"),l.setAttribute("aria-label","Slide indicators"),o.appendChild(l),this.appendChild(o),this.#y()}#y(){let t=this.querySelector("[data-swiper-counter]");if(!t)return;if(!this.counter){t.textContent="";return}let e=this.#m(this.#n)+1,i=this.#u();t.textContent=`${e} / ${i}`}#w(){let t=this.querySelector("[data-swiper-dots]");if(!t)return;let e=this.#u();if(t.children.length!==e){for(;t.firstChild;)t.removeChild(t.firstChild);for(let i=0;i<e;i++){let n=document.createElement("button");n.setAttribute("role","tab"),n.setAttribute("aria-label",`Page ${i+1}`),n.addEventListener("click",()=>this.goTo(this.#f(i))),t.appendChild(n)}}this.#v()}#v(){if(!this.#a)return;let t=this.querySelector("[data-swiper-dots]");if(t){let e=this.#u()-1,i=Math.min(Math.max(this.#m(this.#n),0),e);[...t.children].forEach((n,r)=>{n.setAttribute("aria-current",r===i?"true":"false")})}this.#y()}#k=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"hover"}})))};#S=()=>{this.autoplay&&!this.#e&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#x=()=>{this.#e&&(this.pause(),this.dispatchEvent(new CustomEvent("autoplay-pause",{bubbles:!0,detail:{reason:"focus"}})))};#A=t=>{this.autoplay&&!this.contains(t.relatedTarget)&&(this.play(),this.dispatchEvent(new CustomEvent("autoplay-resume",{bubbles:!0})))};#E=t=>{t.key==="ArrowRight"&&(t.preventDefault(),this.next()),t.key==="ArrowLeft"&&(t.preventDefault(),this.prev())};#C=5;#$=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","")))};#L=t=>{if(!this.#o||t.pointerId!==this.#o.pointerId)return;let e=t.clientX-this.#o.startX;if(Math.abs(e)>=this.#C){if(!this.#o.hasMoved){this.#o.hasMoved=!0;try{this.#t.setPointerCapture(t.pointerId)}catch{}}this.#t.scrollLeft=this.#o.startScrollLeft-e,t.preventDefault()}};#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")))};#q=t=>{this.#t?.hasAttribute("data-just-dragged")&&(t.preventDefault(),t.stopPropagation())};#T=t=>{this.#o&&t.preventDefault()}};S("swiper-ui",jn);var Vn=class extends M{static labelDeprecated=!1;static properties={...M.properties,label:{type:String,default:"",reflect:!0},accept:{type:String,default:"",reflect:!0},multiple:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=null;connected(){super.connected(),this.querySelector("[data-dropzone]")||(this.innerHTML=`
|
|
185
185
|
<div data-dropzone tabindex="0" role="button">Drop files here or click to browse</div>
|
|
186
186
|
<span hint="${this.hint||""}"></span>
|
|
187
187
|
<div data-filelist></div>
|
|
188
188
|
`),this.#e=this.querySelector("[data-dropzone]"),this.#e&&(this.#e.addEventListener("click",this.#i),this.#e.addEventListener("keydown",this.#s),this.#e.addEventListener("dragover",this.#o),this.#e.addEventListener("dragleave",this.#l),this.#e.addEventListener("drop",this.#c))}render(){let t=this.querySelector("[data-filelist]");if(!this.#e||!t)return;let e=this.querySelector("span[hint]");e&&this.hint&&e.setAttribute("hint",this.hint),t.innerHTML="";for(let i of this.#t){let n=document.createElement("span");n.textContent=i.name,t.appendChild(n)}}get files(){return this.#t}#i=()=>{this.disabled||this.#n()};#s=t=>{this.disabled||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#n())};async#n(){try{if(window.showOpenFilePicker){let t=this.#a(),e={multiple:this.multiple};t.length&&(e.types=t);let i=await window.showOpenFilePicker(e);if(!this.isConnected)return;let n=await Promise.all(i.map(r=>r.getFile()));if(!this.isConnected)return;this.#h(n)}else this.#r()}catch(t){if(t.name!=="AbortError")throw t}}#r(){let t=document.createElement("input");t.type="file",this.accept&&(t.accept=this.accept),this.multiple&&(t.multiple=!0),t.style.display="none",document.body.appendChild(t),t.addEventListener("change",()=>{t.files?.length&&this.#h([...t.files]),t.remove()},{once:!0}),t.addEventListener("cancel",()=>t.remove(),{once:!0}),t.click()}#a(){if(!this.accept)return[];let t={};for(let e of this.accept.split(",")){let i=e.trim();i&&(i.startsWith(".")?(t["application/octet-stream"]=t["application/octet-stream"]||[],t["application/octet-stream"].push(i)):t[i]=t[i]||[])}return Object.keys(t).length?[{accept:t}]:[]}#o=t=>{t.preventDefault(),this.querySelector("[data-dropzone]")?.setAttribute("data-dragover","")};#l=()=>{this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover")};#c=t=>{if(t.preventDefault(),this.querySelector("[data-dropzone]")?.removeAttribute("data-dragover"),this.disabled)return;let e=t.dataTransfer;e?.files?.length&&this.#h([...e.files])};#h(t){this.#t=t;let e=new FormData;for(let i of this.#t)e.append(this.name||"file",i);this.internals.setFormValue(e),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value,files:this.files}})),this.render()}disconnected(){super.disconnected(),this.#e&&(this.#e.removeEventListener("click",this.#i),this.#e.removeEventListener("keydown",this.#s),this.#e.removeEventListener("dragover",this.#o),this.#e.removeEventListener("dragleave",this.#l),this.#e.removeEventListener("drop",this.#c)),this.#e=null}};S("upload-ui",Vn);Td();var Wn=_O({name:"draggable",category:"motion-positioning",description:"Pointer drag to reposition",attributes:["data-draggable-dragging"],events:["drag-end"],config:[],setup({host:s}){let t=!1,e=0,i=0,n=0,r=0;function o(){return s.hasAttribute("disabled")}function a(c){if(o())return;t=!0,e=c.clientX,i=c.clientY;let u=getComputedStyle(s),d=u.translate;if(d&&d!=="none"){let f=d.split(/\s+/).map(parseFloat);n=f[0]||0,r=f[1]||0}else{let f=new DOMMatrixReadOnly(u.transform);n=f.m41,r=f.m42}s.setPointerCapture(c.pointerId),s.setAttribute("data-draggable-dragging",""),s.style.touchAction="none"}function l(c){if(!t)return;let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.style.translate=`${f}px ${p}px`}function h(c){if(!t)return;t=!1,s.removeAttribute("data-draggable-dragging");let u=c.clientX-e,d=c.clientY-i,f=n+u,p=r+d;s.dispatchEvent(new CustomEvent("drag-end",{bubbles:!0,detail:{x:f,y:p}}))}return s.addEventListener("pointerdown",a),s.addEventListener("pointermove",l),s.addEventListener("pointerup",h),()=>{s.removeEventListener("pointerdown",a),s.removeEventListener("pointermove",l),s.removeEventListener("pointerup",h),s.removeAttribute("data-draggable-dragging"),s.style.touchAction=""}}});P();var Un=class extends x{static properties={variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"",reflect:!0},elevation:{type:Number,default:1,reflect:!0},raw:{type:Boolean,default:!1,reflect:!0},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Wn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Wn),this.#t=!0)}};S("card-ui",Un);P();var Fn=class s extends x{static properties={src:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},shape:{type:String,default:"circle",reflect:!0}};get displayName(){return this.text||this.name}static template=()=>null;static#t=!1;#e=null;#i=null;#s=null;connected(){this.setAttribute("role","img"),this.name&&!this.text&&!s.#t&&(s.#t=!0,console.warn('[AdiaUI] <avatar-ui name="\u2026"> is deprecated \u2014 use text="\u2026" instead. Docs: https://ui-kit.exe.xyz/site/components/avatar'))}render(){!this.src&&!this.displayName&&!this.icon||(this.src?(this.#e||(this.#e=document.createElement("img"),this.#e.setAttribute("slot","img"),this.#e.onerror=()=>{this.#e.remove(),this.#e=null,this.#n()}),this.#e.src=this.src,this.#e.alt=this.name||"",this.#e.parentElement||this.appendChild(this.#e),this.#i&&(this.#i.remove(),this.#i=null)):this.icon?(this.#e&&(this.#e.remove(),this.#e=null),this.#i&&(this.#i.remove(),this.#i=null),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s)),this.#s.setAttribute("name",this.icon)):(this.#e&&(this.#e.remove(),this.#e=null),this.#s&&(this.#s.remove(),this.#s=null),this.#n()),this.setAttribute("aria-label",this.displayName||this.icon||""))}#n(){if(!this.displayName)return;let t=this.displayName.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","initials"),this.appendChild(this.#i)),this.#i.textContent=t}},Yn=class extends x{static properties={max:{type:Number,default:5,reflect:!0},size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Avatar group")}render(){let t=[...this.querySelectorAll("avatar-ui")],e=this.max,i=t.length-e;if(this.size)for(let r of t)r.setAttribute("size",this.size);t.forEach((r,o)=>{r.style.display=o<e?"":"none",r.style.zIndex=String(t.length-o)});let n=this.querySelector('[slot="overflow"]');i>0?(n||(n=document.createElement("span"),n.setAttribute("slot","overflow"),this.appendChild(n)),n.textContent=`+${i}`,n.setAttribute("aria-label",`${i} more`),n.style.zIndex="0"):n&&n.remove()}};S("avatar-ui",Fn),S("avatar-group-ui",Yn);P();var Hn=class extends x{static properties={value:{type:Number,default:null,reflect:!0},variant:{type:String,default:"bar",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","100"),this.variant==="bar"&&(this.#t=document.createElement("div"),this.#t.setAttribute("slot","track"),this.#e=document.createElement("div"),this.#e.setAttribute("slot","fill"),this.#t.appendChild(this.#e),this.appendChild(this.#t))}render(){let t=this.value==null||this.value<0,e=Math.max(0,Math.min(100,this.value));this.setAttribute("aria-busy",String(t)),t?this.removeAttribute("aria-valuenow"):this.setAttribute("aria-valuenow",String(e)),this.#e&&(this.#e.style.width=t?"100%":`${e}%`)}disconnected(){this.#t?.remove(),this.#t=null,this.#e=null}};S("progress-ui",Hn);P();var Gn=class extends x{static properties={value:{type:Number,default:0,reflect:!0},total:{type:Number,default:0,reflect:!0},caption:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;connected(){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),!this.querySelector(':scope > [slot="caption"]')&&!this.querySelector(':scope > [slot="track"]')?(this.#t=document.createElement("span"),this.#t.setAttribute("slot","caption"),this.appendChild(this.#t),this.#e=document.createElement("div"),this.#e.setAttribute("slot","track"),this.appendChild(this.#e)):(this.#t=this.querySelector(':scope > [slot="caption"]'),this.#e=this.querySelector(':scope > [slot="track"]'))}render(){let t=Math.max(0,this.total|0),e=Math.max(0,Math.min(t,this.value|0));if(this.setAttribute("aria-valuemax",String(t)),this.setAttribute("aria-valuenow",String(e)),this.#t&&!this.#t.dataset.custom&&(this.#t.textContent=this.caption||"",this.#t.toggleAttribute("hidden",!this.caption)),this.#e){let i=this.#e.children.length;for(;this.#e.children.length<t;)this.#e.appendChild(document.createElement("span"));for(;this.#e.children.length>t;)this.#e.lastElementChild.remove();for(let n=0;n<this.#e.children.length;n++)this.#e.children[n].toggleAttribute("data-active",n<e)}}disconnected(){this.#t=null,this.#e=null}};S("step-progress-ui",Gn);P();var Kn=class extends x{static properties={width:{type:String,default:"100%",reflect:!0},height:{type:String,default:"1.2em",reflect:!0},radius:{type:String,default:"sm",reflect:!0},static:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("aria-hidden","true"),this.#t()}render(){this.#t()}#t(){this.style.width=this.width,this.style.height=this.height}};S("skeleton-ui",Kn);P();var Jn=class extends x{static properties={size:{type:String,default:"md",reflect:!0},variant:{type:String,default:"arc",reflect:!0},tone:{type:String,default:"current",reflect:!0},paused:{type:Boolean,default:!1,reflect:!0},label:{type:String,default:"Loading",reflect:!1}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","progressbar"),this.hasAttribute("aria-busy")||this.setAttribute("aria-busy","true"),this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}render(){this.setAttribute("aria-valuetext",this.label||"Loading"),this.#t()}#t(){let t=this.variant==="dots",e=this.querySelectorAll(":scope > [data-spinner-dot]");if(t){if(e.length===3)return;e.forEach(n=>n.remove());let i=document.createDocumentFragment();for(let n=1;n<=3;n++){let r=document.createElement("span");r.setAttribute("data-spinner-dot",String(n)),r.setAttribute("aria-hidden","true"),i.appendChild(r)}this.appendChild(i)}else e.length&&e.forEach(i=>i.remove())}};S("spinner-ui",Jn);P();var tr=class extends x{static properties={active:{type:Boolean,default:!1,reflect:!0},delay:{type:Number,default:200,reflect:!0},label:{type:String,default:"Loading\u2026",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;constructor(){super();let t=Object.getOwnPropertyDescriptor(this,"active");if(t?.set){let e=t.set;Object.defineProperty(this,"active",{get:t.get,set:i=>{let n=!!t.get.call(this);e.call(this,i),!!i!==n&&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.#r(),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.#n():this.#e=setTimeout(()=>{this.#e=null,this.active&&this.#n()},e)}else this.#i&&this.#r()}#n(){let t=this.#t||this.parentElement;t&&!t.hasAttribute("aria-busy")&&t.setAttribute("aria-busy","true"),this.#i=!0}#r(){let t=this.#t||this.parentElement;t&&t.getAttribute("aria-busy")==="true"&&t.removeAttribute("aria-busy"),this.#i=!1}#a(){this.#e!==null&&(clearTimeout(this.#e),this.#e=null)}#o(){let t=document.createElement("spinner-ui");t.setAttribute("size","lg"),t.setAttribute("tone","subtle"),t.setAttribute("label",this.label||"Loading"),t.setAttribute("data-loading-overlay-auto",""),this.appendChild(t)}};S("loading-overlay-ui",tr);P();var sy=new Set;function ny(s,t){sy.has(s)||(sy.add(s),console.warn(`[alert-ui] ${t}`))}var er=class s extends x{static properties={text:{type:String,default:"",reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},closable:{type:Boolean,default:!1,reflect:!0},dismissible:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0},pattern:{type:String,default:"",reflect:!0},amount:{type:Number,default:0,reflect:!0},currency:{type:String,default:"USD",reflect:!0},dueAt:{type:String,default:"",reflect:!0,attribute:"due-at"},cardLast4:{type:String,default:"",reflect:!0,attribute:"card-last4"},reason:{type:String,default:"",reflect:!0}};static parts={leading:'<icon-ui slot="leading"></icon-ui>',content:'<span slot="content"></span>',close:'<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>'};static#t={declined:"x-circle",expired:"clock",insufficient:"wallet",network:"wifi-slash"};static template=()=>null;#e(){this.getAttribute("variant")==="error"&&(ny("variant-error",'variant="error" is not in the canonical enum [default, info, success, warning, danger, muted, neutral]. Mapping to "danger". Fix the source (LLM prompt / corpus pattern) to emit "danger" directly.'),this.setAttribute("variant","danger")),this.hasAttribute("closeable")&&!this.hasAttribute("closable")&&!this.hasAttribute("dismissible")&&(ny("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 n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}}else if(this.title||this.description){if(t.setAttribute("data-alert-auto","title-desc"),t.replaceChildren(),this.title){let r=document.createElement("strong");r.textContent=this.title,t.appendChild(r),this.description&&t.appendChild(document.createTextNode(" "))}this.description&&t.appendChild(document.createTextNode(this.description));let n=[this.title,this.description].filter(Boolean).join(". ");this.setAttribute("aria-label",n)}else this.text&&(t.setAttribute("data-alert-auto","text"),t.textContent=this.text)}this.closable||this.dismissible?this.ensure("close"):this.drop("close"),this.#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 n=this.title||this.#n();if(n){let l=document.createElement("strong");l.setAttribute("data-dunning-title",""),l.textContent=n,i.appendChild(l)}let r=this.#r(),o=this.#o();if(r||o){if(i.appendChild(document.createTextNode(" ")),r){let l=document.createElement("span");l.setAttribute("data-dunning-amount",""),l.textContent=r,i.appendChild(l)}if(r&&o&&i.appendChild(document.createTextNode(" ")),o){let l=document.createElement("span");l.setAttribute("data-dunning-meta",""),l.textContent=o,i.appendChild(l)}}let a=[n,r,o].filter(Boolean).join(". ");a&&this.setAttribute("aria-label",a),this.closable||this.dismissible?this.ensure("close"):this.drop("close")}#n(){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"}}#r(){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=new Date(this.dueAt);if(Number.isNaN(t.getTime()))return"";try{let e=this.getAttribute("lang")||this.lang||void 0;return new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"}).format(t)}catch{return t.toDateString()}}#o(){let t=[];this.cardLast4&&t.push(`Card ending ${this.cardLast4}`),this.reason&&this.reason!=="declined"&&t.push(this.#l());let e=this.#a();if(e){let i=this.variant==="warning"?"due":"failed";t.push(`${i} ${e}`)}return t.join(" \xB7 ")}#l(){switch(this.reason){case"expired":return"expired";case"insufficient":return"insufficient funds";case"network":return"network error";case"declined":return"declined";default:return""}}#c(){let t=this.variant==="danger"||this.variant==="warning"?"alert":"status";this.setAttribute("role",t)}#h(){this.dispatchEvent(new Event("close",{bubbles:!0})),this.remove()}};S("alert-ui",er);P();var gC={info:"info",success:"check-circle",warning:"warning",danger:"x-circle"},ir=class extends x{static properties={text:{type:String,default:"",reflect:!1},variant:{type:String,default:"default",reflect:!0},icon:{type:String,default:"",reflect:!0},live:{type:String,default:"",reflect:!0}};static parts={leading:'<icon-ui slot="leading"></icon-ui>'};static requiredIcons=["info","check-circle","warning","x-circle"];static template=()=>null;#t(t){return!!(t&&(t._uiPart||t.hasAttribute("data-im-auto")))}connected(){}render(){this.live?this.setAttribute("aria-live",this.live):this.hasAttribute("aria-live")&&this.removeAttribute("aria-live"),this.#e();let t=this.icon||gC[this.variant]||"",e=this.querySelector(':scope > [slot="leading"]');if(!(e&&!this.#t(e)))if(t){let i=this.ensure("leading");i&&(i.setAttribute("data-im-auto",""),i.getAttribute("name")!==t&&i.setAttribute("name",t))}else this.drop("leading")}#e(){let t=this.querySelector(":scope > [data-im-text]");if(Array.from(this.childNodes).some(i=>i===t?!1:i.nodeType===Node.ELEMENT_NODE?!(i.getAttribute&&i.getAttribute("slot")==="leading"):!!(i.nodeType===Node.TEXT_NODE&&i.textContent.trim()))){t&&t.remove();return}this.text?(t||(t=document.createElement("span"),t.setAttribute("data-im-text",""),this.appendChild(t)),t.textContent!==this.text&&(t.textContent=this.text)):t&&t.remove()}};S("inline-message-ui",ir);P();var sr=class extends x{static properties={size:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","presentation")}};S("kbd-ui",sr);P();var nr=class extends x{static requiredIcons=["x"];static properties={text:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0},removable:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static parts={dismiss:'<button slot="dismiss" type="button" aria-label="Remove"><icon-ui name="x" weight="bold"></icon-ui></button>'};static template=()=>null;#t=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};#e=t=>{this.disabled||t.target.closest('[slot="dismiss"]')&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("remove",{bubbles:!0,detail:{text:this.text,value:this.text}})),this.remove())};connected(){this.setAttribute("role","status"),this.setAttribute("tabindex","0"),this.addEventListener("click",this.#t),this.addEventListener("keydown",this.#e)}disconnected(){this.removeEventListener("click",this.#t),this.removeEventListener("keydown",this.#e)}render(){if(this.text&&this.setAttribute("aria-label",this.text),this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0")),this.removable&&!this.disabled){let t=this.ensure("dismiss");t&&t.parentElement!==this&&this.appendChild(t)}else this.drop("dismiss")}};S("tag-ui",nr);P();var bC=new Set(["block","dot","square","line","dashed"]),OC=new Set(["sm","md","lg"]),yC=new Set(["out-of-gamut","p3-only","apca-pass","apca-fail"]),vC={"out-of-gamut":"\u25B3","p3-only":"\u2726","apca-pass":"\u2713","apca-fail":"\u2717"},xC={"out-of-gamut":"Outside sRGB gamut","p3-only":"Display-P3 only","apca-pass":"Contrast passes APCA","apca-fail":"Contrast fails APCA"};function SC(s){return s?s.split(/[\s,]+/).map(t=>t.trim()).filter(t=>t&&yC.has(t)):[]}var hs=null;function wC(s){if(!s||typeof s!="string"||typeof document>"u")return null;try{if(!hs){let u=document.createElement("canvas");u.width=1,u.height=1,hs=u.getContext("2d")}hs.fillStyle="#000",hs.clearRect(0,0,1,1),hs.fillStyle=s,hs.fillRect(0,0,1,1);let[t,e,i]=hs.getImageData(0,0,1,1).data;if(t===0&&e===0&&i===0&&s!=="#000"&&s!=="black"&&s!=="#000000")return null;let n=u=>{let d=u/255;return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)},r=n(t),o=n(e),a=n(i),l=Math.cbrt(.4122214708*r+.5363325363*o+.0514459929*a),h=Math.cbrt(.2119034982*r+.6806995451*o+.1073969566*a),c=Math.cbrt(.0883024619*r+.2817188376*o+.6299787005*a);return .2104542553*l+.793617785*h-.0040720468*c}catch{return null}}var rr=class extends x{static properties={shape:{type:String,default:"square",reflect:!0},size:{type:String,default:"md",reflect:!0},color:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},detail:{type:String,default:"",reflect:!0},badge:{type:String,default:"",reflect:!0},copyable:{type:Boolean,default:!1,reflect:!0},copyValue:{type:String,default:""},selectable:{type:Boolean,default:!1,reflect:!0},selected:{type:Boolean,default:!1,reflect:!0},autoContrast:{type:Boolean,default:!1,reflect:!0},labelPosition:{type:String,default:"below",reflect:!0,attribute:"label-position"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;connected(){this.#d(),this.#w(),this.#u=new MutationObserver(t=>{let e=!1;for(let i of t){for(let n of i.addedNodes)if(n.nodeType===1){if(n.getAttribute?.("slot")==="chrome"){e=!0;break}if(n.tagName==="SPAN"&&n.style?.display==="contents"&&n.querySelector?.('[slot="chrome"]')){e=!0;break}}if(e)break}e&&(this.#p(),this.#u.takeRecords())}),this.#u.observe(this,{childList:!0})}render(){this.#d(),this.#f(),this.#m(),this.#g(),this.#b(),this.#y(),this.#O()}#d(){if(this.#r)return;let t=Array.from(this.children).filter(r=>r.getAttribute&&r.getAttribute("slot")==="chrome");for(let r of t)r.remove();let e=Array.from(this.children).filter(r=>r.tagName==="SPAN"&&r.style?.display==="contents"&&r.querySelector?.('[slot="chrome"]'));for(let r of e)r.remove();let i=[];for(let r of Array.from(this.childNodes))(r.nodeType===3&&!r.data||r.nodeType===8)&&i.push(r);for(let r of i)r.remove();let n=Array.from(this.childNodes).filter(r=>!(r.nodeType===1&&r.dataset&&(r.dataset.tile!==void 0||r.dataset.label!==void 0||r.dataset.detail!==void 0||r.dataset.badge!==void 0||r.dataset.copy!==void 0))&&!(r.nodeType===3&&!r.textContent.trim()));this.innerHTML="",this.#t=document.createElement("span"),this.#t.setAttribute("data-tile",""),this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t);for(let r of t)this.appendChild(r);for(let r of e)this.appendChild(r);for(let r of i)this.appendChild(r);if(this.#s=document.createElement("span"),this.#s.setAttribute("data-badge",""),this.#s.setAttribute("hidden",""),this.appendChild(this.#s),this.#e=document.createElement("span"),this.#e.setAttribute("data-label",""),n.length)for(let r of n)this.#e.appendChild(r);this.appendChild(this.#e),this.#i=document.createElement("span"),this.#i.setAttribute("data-detail",""),this.#i.setAttribute("hidden",""),this.appendChild(this.#i),this.#n=document.createElement("button"),this.#n.setAttribute("data-copy",""),this.#n.setAttribute("type","button"),this.#n.setAttribute("aria-label","Copy value"),this.#n.setAttribute("hidden",""),this.#n.textContent="\u29C9",this.appendChild(this.#n),this.#r=!0}#p(){if(!this.#t||!this.#s)return;let t=[];for(let e of this.children)if(e!==this.#t){if(e===this.#s)break;e.getAttribute?.("slot")==="chrome"&&t.push(e)}for(let e of Array.from(this.children))e!==this.#t&&e!==this.#s&&e!==this.#e&&e!==this.#i&&e!==this.#n&&e.getAttribute?.("slot")==="chrome"&&this.insertBefore(e,this.#s);for(let e of Array.from(this.children))e===this.#t||e===this.#s||e===this.#e||e===this.#i||e===this.#n||!(e.tagName==="SPAN"&&e.style?.display==="contents")||!e.querySelector?.('[slot="chrome"]')||this.insertBefore(e,this.#s)}#f(){if(!this.#t||!this.#e)return;this.#p();let t=bC.has(this.shape)?this.shape:"square",e=OC.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=SC(this.badge);if(t.length===0){this.#s.setAttribute("hidden",""),this.#s.replaceChildren();return}this.#s.removeAttribute("hidden");let e=Array.from(this.#s.children).map(r=>r.dataset.badgeVariant);if(e.length===t.length&&e.every((r,o)=>r===t[o]))return;let n=document.createDocumentFragment();for(let r of t){let o=document.createElement("span");o.setAttribute("data-badge-variant",r),o.setAttribute("role","img"),o.setAttribute("aria-label",xC[r]),o.textContent=vC[r],n.appendChild(o)}this.#s.replaceChildren(n)}#O(){if(!this.#e)return;if(!this.autoContrast){this.#e.removeAttribute("data-on-light"),this.#e.removeAttribute("data-on-dark"),this.#a=null;return}let t=this.color||getComputedStyle(this).getPropertyValue("--swatch-color").trim();if(t===this.#a)return;this.#a=t;let e=wC(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)}#g(){if(!this.#i)return;let t=(this.detail||"").trim();if(!t){this.#i.setAttribute("hidden",""),this.#i.textContent="";return}this.#i.removeAttribute("hidden"),this.#i.textContent!==t&&(this.#i.textContent=t)}#b(){if(!this.#n)return;if(!this.copyable){this.#n.setAttribute("hidden","");return}this.#n.removeAttribute("hidden");let t=this.#k();t?this.#n.setAttribute("aria-label",`Copy ${t}`):this.#n.setAttribute("aria-label","Copy value")}#y(){this.selectable?(this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.setAttribute("aria-pressed",this.selected?"true":"false")):(this.getAttribute("role")==="button"&&this.removeAttribute("role"),this.getAttribute("tabindex")==="0"&&this.removeAttribute("tabindex"),this.removeAttribute("aria-pressed"))}#w(){this.#o=t=>{!this.selectable||(t.composedPath?t.composedPath():[]).includes(this.#n)||this.#v()},this.#l=t=>{this.selectable&&(t.key!=="Enter"&&t.key!==" "||t.target!==this.#n&&(t.preventDefault(),this.#v()))},this.addEventListener("click",this.#o),this.addEventListener("keydown",this.#l),this.#c=t=>{if(t.stopPropagation(),!this.copyable)return;let e=this.#k();e&&this.#S(e)},this.#n.addEventListener("click",this.#c)}#v(){this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:this.color||this.label,color:this.color,label:this.label}}))}#k(){return this.copyValue?this.copyValue:this.color?this.color:""}async#S(t){let e=!1;try{navigator?.clipboard?.writeText&&(await navigator.clipboard.writeText(t),e=!0)}catch{}this.#x(e)}#x(t){this.#n&&(this.#h!=null&&clearTimeout(this.#h),this.#n.setAttribute("data-copy-state",t?"ok":"fail"),this.#n.textContent=t?"\u2713":"\u26A0",this.#h=setTimeout(()=>{this.#n&&(this.#n.removeAttribute("data-copy-state"),this.#n.textContent="\u29C9",this.#h=null)},1200))}disconnected(){this.#h!=null&&(clearTimeout(this.#h),this.#h=null),this.#u&&(this.#u.disconnect(),this.#u=null),this.#o&&this.removeEventListener("click",this.#o),this.#l&&this.removeEventListener("keydown",this.#l),this.#n&&this.#c&&this.#n.removeEventListener("click",this.#c),this.#t=null,this.#e=null,this.#i=null,this.#s=null,this.#n=null,this.#r=!1}};S("swatch-ui",rr);Ct();var ry={xs:0,sm:480,md:768,lg:1024,xl:1280},cs=Object.keys(ry),_d=Object.values(ry);function oy(){if(typeof window>"u")return"lg";let s=window.innerWidth;for(let t=cs.length-1;t>=0;t--)if(s>=_d[t])return cs[t];return"xs"}var Ce=qi(oy());if(typeof window<"u")for(let s=1;s<_d.length;s++)window.matchMedia(`(min-width: ${_d[s]}px)`).addEventListener("change",()=>{Ce.value=oy()});function Xt(s,t=Ce.value){if(!s)return null;if(!s.includes("@"))return s;let e=null,i=new Map;for(let a of s.trim().split(/\s+/)){let l=a.lastIndexOf("@");l===-1?e=a:i.set(a.slice(l+1),a.slice(0,l))}let n=cs.indexOf(t),r=null,o=-1;for(let[a,l]of i){let h=cs.indexOf(a);h!==-1&&h<=n&&h>o&&(r=l,o=h)}return r??e}P();var or=class extends x{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"stretch",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;render(){let t=this.gap,e=this.align,i=this.justify,r=t?.includes("@")||e?.includes("@")||i?.includes("@")?Ce.value:"";if(t?.includes("@")?this.style.setProperty("--col-gap",EC(Xt(t,r))):this.style.removeProperty("--col-gap"),e?.includes("@")){let o=Xt(e,r);this.style.setProperty("--col-align",CC(o)),this.style.textAlign=$C(o)}else this.style.removeProperty("--col-align"),this.style.textAlign="";i?.includes("@")?this.style.setProperty("--col-justify",PC(Xt(i,r))):this.style.removeProperty("--col-justify")}},kC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},AC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function EC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function CC(s){return kC[s]??s}function $C(s){return{start:"start",center:"center",end:"end"}[s]??""}function PC(s){return AC[s]??s}S("col-ui",or);P();var ar=class s extends x{static properties={label:{type:String,default:"",reflect:!0},hint:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},align:{type:String,default:"start",reflect:!0}};get error(){return this.#O()?.error??""}static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=t=>{let e=this.#O();if(!e)return;let i=this.#g(e);i&&(t.preventDefault(),i.focus())};connected(){this.#u(),this.#d(),this.#p(),this.#f(),this.#c(),this.#t?.addEventListener("click",this.#r),this.#n=new MutationObserver(()=>{this.#f(),this.#c(),this.#m(),this.#a()}),this.#n.observe(this,{childList:!0}),this.#a()}disconnected(){this.#n?.disconnect(),this.#n=null,this.#h(),this.#t?.removeEventListener("click",this.#r),this.#t=null,this.#e=null,this.#i=null,this.#s=null}render(){this.#t&&this.#t.childNodes[0]&&(this.#t.childNodes[0].nodeValue=this.label||""),this.#e&&(this.#e.hidden=!this.required),this.#i&&(this.#i.textContent=this.hint||"",this.#i.hidden=!this.hint||!!this.error),this.#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.#O();t!==this.#l&&(this.#h(),t&&(this.#l=t,t.addEventListener("invalid",this.#o,!0),t.addEventListener("change",this.#o),t.addEventListener("input",this.#o)))}#h(){let t=this.#l;t&&(t.removeEventListener("invalid",this.#o,!0),t.removeEventListener("change",this.#o),t.removeEventListener("input",this.#o),this.#l=null)}#u(){if(this.#t=this.querySelector(":scope > [data-field-label]"),!this.#t){let t=document.createElement("label");t.setAttribute("slot","label"),t.setAttribute("data-field-label",""),t.appendChild(document.createTextNode(this.label||"")),this.prepend(t),this.#t=t}if(this.#e=this.#t.querySelector("[data-field-required]"),!this.#e){let t=document.createElement("span");t.setAttribute("data-field-required",""),t.setAttribute("aria-hidden","true"),t.textContent="*",t.hidden=!0,this.#t.appendChild(t),this.#e=t}}#d(){if(this.#i=this.querySelector(":scope > [data-field-hint]"),this.#i)return;let t=document.createElement("div");t.setAttribute("slot","hint"),t.setAttribute("data-field-hint",""),t.setAttribute("id",s.#v("hint")),t.hidden=!0,this.appendChild(t),this.#i=t}#p(){if(this.#s=this.querySelector(":scope > [data-field-error]"),this.#s)return;let t=document.createElement("div");t.setAttribute("slot","error"),t.setAttribute("data-field-error",""),t.setAttribute("id",s.#v("err")),t.setAttribute("role","alert"),t.hidden=!0,this.appendChild(t),this.#s=t}#f(){if(!this.#t)return;let t=this.#O();if(!t){this.#t.removeAttribute("for");return}t.id||(t.id=s.#y()),this.#t.setAttribute("for",t.id)}#m(){let t=this.#O();if(!t)return;let e=new Set;this.#i&&!this.#i.hidden&&e.add(this.#i.id),this.#s&&!this.#s.hidden&&e.add(this.#s.id);let n=[...(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(r=>r&&!r.startsWith("field-hint-")&&!r.startsWith("field-err-")),...e].join(" ").trim();n?t.setAttribute("aria-describedby",n):t.removeAttribute("aria-describedby")}#O(){for(let t of this.children)if(!t.hasAttribute("slot"))return t;return null}#g(t){let e='input, textarea, select, button, [contenteditable], [tabindex]:not([tabindex="-1"])';return t.matches?.(e)?t:t.querySelector?.(e)??null}static#b=0;static#y(){return`field-ctl-${++s.#b}`}static#w=0;static#v(t){return`field-${t}-${++s.#w}`}};S("field-ui",ar);P();var lr=class extends x{static properties={inline:{type:Boolean,default:!1,reflect:!0},columns:{type:Number,default:6,reflect:!0}};static template=()=>null;#t=null;connected(){this.#e(),this.#t=new MutationObserver(t=>{for(let e of t)if(e.type==="childList"&&(this.#i(e.addedNodes)||this.#i(e.removedNodes))){this.#e();return}}),this.#t.observe(this,{childList:!0})}disconnected(){this.#t?.disconnect(),this.#t=null}render(){this.#e()}#e(){let t=this.hasAttribute("inline");for(let e of this.children)e.localName==="field-ui"&&(t?e.hasAttribute("inline")||e.setAttribute("inline",""):e.hasAttribute("inline")&&e.removeAttribute("inline"))}#i(t){for(let e of t)if(e.nodeType===1&&e.localName==="field-ui")return!0;return!1}};S("fields-ui",lr);P();var hr=class extends x{static properties={justify:{type:String,default:"start",reflect:!0},align:{type:String,default:"center",reflect:!0},gap:{type:String,default:"md",reflect:!0},grow:{type:Boolean,default:!1,reflect:!0},wrap:{type:Boolean,default:!1,reflect:!0},wrapAt:{type:String,default:"",reflect:!0,attribute:"wrap-at"},draggable:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){this.draggable&&!this.#t&&(this.addTrait(Wn),this.#t=!0)}updated(t){t.has("draggable")&&this.draggable&&!this.#t&&(this.addTrait(Wn),this.#t=!0)}render(){let t=this.gap,e=this.align,i=this.justify,n=this.wrapAt,o=t?.includes("@")||e?.includes("@")||i?.includes("@")||!!n?Ce.value:"";if(t?.includes("@")?this.style.setProperty("--row-gap",LC(Xt(t,o))):this.style.removeProperty("--row-gap"),e?.includes("@")?this.style.setProperty("--row-align",MC(Xt(e,o))):this.style.removeProperty("--row-align"),i?.includes("@")?this.style.setProperty("--row-justify",RC(Xt(i,o))):this.style.removeProperty("--row-justify"),n){let a=cs.indexOf(o),l=cs.indexOf(n);this.style.flexWrap=l!==-1&&a>=l?"wrap":""}else this.style.flexWrap=""}},QC={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},TC={start:"flex-start",end:"flex-end",center:"center",between:"space-between","space-between":"space-between","space-around":"space-around"};function LC(s){return!s||s==="0"?"0":/^\d+$/.test(s)?`var(--a-space-${s})`:`var(--a-gap-${s})`}function MC(s){return QC[s]??s}function RC(s){return TC[s]??s}S("row-ui",hr);P();var cr=class extends x{static properties={columns:{type:String,default:"3",reflect:!0},gap:{type:String,default:"md",reflect:!0},columnGap:{type:String,default:"",reflect:!0,attribute:"column-gap"},rowGap:{type:String,default:"",reflect:!0,attribute:"row-gap"}};static template=()=>null;render(){let t=Ce.value,e=this.columns;if(e?.includes("@")){let n=Xt(e,t);this.style.gridTemplateColumns=this.#t(n),this.style.gridAutoFlow=n?"row":"",this.style.gridAutoColumns=n?"auto":""}else this.style.gridTemplateColumns="",this.style.gridAutoFlow="",this.style.gridAutoColumns="";let i=this.gap;if(i?.includes("@")){let n=Xt(i,t),r=this.#e(n);this.style.columnGap=r,this.style.rowGap=r}else this.style.columnGap="",this.style.rowGap=""}#t(t){return t?/^\d+$/.test(t)?`repeat(${t}, 1fr)`:t==="auto-fill"?"repeat(auto-fill, minmax(12rem, 1fr))":t==="auto-fit"?"repeat(auto-fit, minmax(12rem, 1fr))":t:""}#e(t){return!t||t==="0"?"0":/^\d+$/.test(t)?`var(--a-space-${t})`:`var(--a-gap-${t})`}};S("grid-ui",cr);P();var ur=class extends x{static properties={align:{type:String,default:"center",reflect:!0}};static template=()=>null};S("stack-ui",ur);P();function us(s,t,e=5){let n=(t-s||1)/e,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,l=(o<=1.5?1:o<=3?2:o<=7?5:10)*r,h=Math.floor(s/l)*l,c=Math.ceil(t/l)*l,u=[];for(let d=h;d<=c+l*.5;d+=l)u.push(+d.toFixed(10));return u}function ay(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 se(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function St({label:s,value:t,pct:e,series:i}){let n="";return s!=null&&(n+=` data-tip-label="${se(String(s))}"`),t!=null&&(n+=` data-tip-value="${t}"`),e!=null&&(n+=` data-tip-pct="${e}"`),i!=null&&(n+=` data-tip-series="${se(String(i))}"`),n}function ne(s,t,e){return s+t*Math.cos(e)}function re(s,t,e){return s+t*Math.sin(e)}function IC(s,t,e,i,n){let r=ne(s,e,i),o=re(t,e,i),a=ne(s,e,n),l=re(t,e,n),h=n-i>Math.PI?1:0;return`M ${s} ${t} L ${r} ${o} A ${e} ${e} 0 ${h} 1 ${a} ${l} Z`}function jd(s,t,e,i,n,r,o=0){let a=(e-i)/2,l=r-n,h=Math.max(0,Math.min(o,a)),c=()=>{let ut=ne(s,e,n),ot=re(t,e,n),bt=ne(s,e,r),xt=re(t,e,r),Ot=ne(s,i,r),Et=re(t,i,r),Tt=ne(s,i,n),Ut=re(t,i,n),ns=l>Math.PI?1:0;return`M ${ut} ${ot} A ${e} ${e} 0 ${ns} 1 ${bt} ${xt} L ${Ot} ${Et} A ${i} ${i} 0 ${ns} 0 ${Tt} ${Ut} Z`};if(h<=0)return c();let u=h/e,d=h/i;if(l<=(u+d)*1.05)return c();let f=n+u,p=r-u,m=n+d,b=r-d,g=p-f>Math.PI?1:0,y=ne(s,e,f),v=re(t,e,f),w=ne(s,e,p),k=re(t,e,p),E=ne(s,i,b),A=re(t,i,b),C=ne(s,i,m),T=re(t,i,m),Q=ne(s,e-h,n),D=re(t,e-h,n),R=ne(s,i+h,n),_=re(t,i+h,n),V=ne(s,e-h,r),U=re(t,e-h,r),J=ne(s,i+h,r),nt=re(t,i+h,r);return`M ${y} ${v} A ${e} ${e} 0 ${g} 1 ${w} ${k} A ${h} ${h} 0 0 1 ${V} ${U} L ${J} ${nt} A ${h} ${h} 0 0 1 ${E} ${A} A ${i} ${i} 0 ${g} 0 ${C} ${T} A ${h} ${h} 0 0 1 ${R} ${_} L ${Q} ${D} A ${h} ${h} 0 0 1 ${y} ${v} Z`}function Pa(s,t=.4){if(s.length<2)return"";if(t<=0)return"M"+s.map(n=>`${n.x},${n.y}`).join(" L");let e=s.length,i=`M${s[0].x},${s[0].y}`;for(let n=0;n<e-1;n++){let r=s[Math.max(n-1,0)],o=s[n],a=s[n+1],l=s[Math.min(n+2,e-1)],h=o.x+(a.x-r.x)*t/3,c=o.y+(a.y-r.y)*t/3,u=a.x-(l.x-o.x)*t/3,d=a.y-(l.y-o.y)*t/3;i+=` C${h},${c} ${u},${d} ${a.x},${a.y}`}return i}function Vd(s,t,e=.4){let i=Pa(s,e),n=s[s.length-1],r=s[0];return`${i} L${n.x},${t} L${r.x},${t} Z`}function vh(s,t,e,i,n=0){if(i<=0||e<=0)return"";let r=Math.max(0,Math.min(n,e/2,i));return r===0?`M${s},${t} H${s+e} V${t+i} H${s} Z`:`M${s},${t+i} V${t+r} Q${s},${t} ${s+r},${t} H${s+e-r} Q${s+e},${t} ${s+e},${t+r} V${t+i} Z`}var ly={std:{ratio:4/3},wide:{ratio:16/9},square:{ratio:1},tall:{ratio:3/4}},dr=class extends x{static properties={type:{type:String,default:"bar",reflect:!0},heading:{type:String,default:"",reflect:!0},x:{type:String,default:"",reflect:!0},y:{type:String,default:"",reflect:!0},hideAverage:{type:Boolean,default:!1,reflect:!0,attribute:"hide-average"},color:{type:String,default:"",reflect:!0},hideGrid:{type:Boolean,default:!1,reflect:!0,attribute:"hide-grid"},hideValues:{type:Boolean,default:!1,reflect:!0,attribute:"hide-values"},radius:{type:Number,default:null,reflect:!0},smooth:{type:Number,default:.4,reflect:!0},aspect:{type:String,default:"std",reflect:!0},size:{type:String,default:"",reflect:!0},format:{type:String,default:"abbr",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=[];#e=!1;#i=null;#s=null;#n=0;#r=0;#a=new Set;#o(){if(this.radius!=null)return this.radius;let t=getComputedStyle(this).getPropertyValue("--a-radius").trim(),e=parseFloat(t);return Number.isFinite(e)&&e>0?e:6}set data(t){!Array.isArray(t)&&!this.#e&&(this.#e=!0,console.warn(`[chart-ui] .data must be an array of plain objects \u2014 received ${t===null?"null":typeof t}. The {labels, datasets} envelope is the Chart.js API, not the chart-ui API.
|
|
189
189
|
Correct shape for <chart-ui x="label" y="value">:
|
|
190
|
-
[{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#c(),this.#p()}get data(){return this.#t}#l=!1;#c(){if(this.#l)return;let t=this.#h();this.#t.length>t&&(console.warn(`[chart-ui] .data has ${this.#t.length} rows which exceeds the recommended perf budget of ${t}. Consider downsampling at the data layer (e.g., LTTB, bucket aggregation). Override the budget via CSS: chart-ui { --chart-perf-budget: 10000 }.`),this.#l=!0)}#h(){let t=getComputedStyle(this).getPropertyValue("--chart-perf-budget").trim(),e=parseInt(t,10);return Number.isFinite(e)&&e>0?e:5e3}connected(){if(this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.heading||`${this.type} chart`),this.#t.length===0&&this.hasAttribute("data"))try{let t=JSON.parse(this.getAttribute("data"));Array.isArray(t)&&(this.data=t)}catch{}document.addEventListener("toggle",this.#w),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#L),this.addEventListener("focus",this.#Q),this.addEventListener("blur",this.#N),this.addEventListener("pointerover",this.#D),this.addEventListener("pointermove",this.#I),this.addEventListener("pointerleave",this.#M),this.addEventListener("pointerdown",this.#_),this.addEventListener("click",this.#W),this.#S(),this.#i=new ResizeObserver(t=>{let{inlineSize:e,blockSize:i}=t[0].contentBoxSize[0];if(!this.#t.length)return;let n=Math.round(e),r=Math.round(i);n===this.#n&&(!this.hasAttribute("resize")||r===this.#r)||(this.#n=n,this.#r=r,!this.#s&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.#p()})))}),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.#p()}#u(){let t=this.clientWidth||300,e=this.clientHeight||0,i=ly[this.aspect]||ly.std,n=this.#t.length||1,r=Math.max(t,120),a=(this.hasAttribute("resize")||this.style.height)&&e>40?e:Math.round(r/i.ratio),l=parseFloat(getComputedStyle(this).maxHeight);isFinite(l)&&l>0&&a>l&&(a=Math.round(l));let h=Math.min(r,a),c=this.size||(h<150?"sm":h<300?"md":"lg"),u=c==="sm"?9:c==="md"?10:11,d=u,f=c==="sm"?8:c==="md"?9:10,p=this.hideGrid,m=p?0:u*3.2,b=!!this.x,g={top:p?2:u*1.6,right:p?2:u*1.2,bottom:!b||p?2:u*2.2,left:m},y=r-g.left-g.right,v=Math.max(4,y/n*.6);return{width:r,height:a,pad:g,fontSize:u,labelSize:d,valueSize:f,barMinW:v,plotW:y,n,sizeClass:c}}#d=null;#p(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#d&&(this.#d=t.cloneNode(!0)),this.innerHTML="",this.#d&&this.appendChild(this.#d.cloneNode(!0)),!this.#t.length){this.removeAttribute("data-has-data");return}if(this.setAttribute("data-has-data",""),this.#f(),this.heading){let o=document.createElement("div");o.setAttribute("data-chart-heading",""),o.textContent=this.heading,this.appendChild(o)}let e=document.createElement("div");this.type==="sparkline"&&e.setAttribute("data-sparkline",""),this.appendChild(e);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");e.appendChild(i);let n="",r="";switch(this.type){case"bar":({svg:n,viewBox:r}=this.#K());break;case"line":({svg:n,viewBox:r}=this.#tt());break;case"pie":({svg:n,viewBox:r}=this.#et());break;case"donut":({svg:n,viewBox:r}=this.#it());break;case"radar":({svg:n,viewBox:r}=this.#st());break;case"sparkline":({svg:n,viewBox:r}=this.#G());break;case"segments":({svg:n,viewBox:r}=this.#ut());break;case"area":({svg:n,viewBox:r}=this.#j());break;case"scatter":({svg:n,viewBox:r}=this.#nt());break;case"radial-bar":({svg:n,viewBox:r}=this.#rt());break;case"gauge":({svg:n,viewBox:r}=this.#ot());break;case"funnel":({svg:n,viewBox:r}=this.#at());break;case"treemap":({svg:n,viewBox:r}=this.#lt());break;case"sankey":({svg:n,viewBox:r}=this.#ht());break;case"composed":({svg:n,viewBox:r}=this.#ct());break;case"stacked-bar":({svg:n,viewBox:r}=this.#dt());break;case"grouped-bar":({svg:n,viewBox:r}=this.#ft());break;case"multi-line":({svg:n,viewBox:r}=this.#pt());break;default:({svg:n,viewBox:r}=this.#K());break}if(i.setAttribute("viewBox",r),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=n,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#b()){let o=this.#mt();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#f(){let t=this.#X();for(let e=0;e<t.length;e++){let i=e%10;this.style.setProperty(`--color-${t[e]}`,`var(--chart-${i})`)}}#m(t,e){return e?` data-slice="${t}" data-series-key="${se(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#O(t,e){return e?` data-slice="${t}" data-series-key="${se(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#w),document.removeEventListener("pointerdown",this.#Z),this.removeEventListener("keydown",this.#L),this.removeEventListener("focus",this.#Q),this.removeEventListener("blur",this.#N),this.removeEventListener("pointerover",this.#D),this.removeEventListener("pointermove",this.#I),this.removeEventListener("pointerleave",this.#M),this.removeEventListener("pointerdown",this.#_),this.removeEventListener("click",this.#W),this.#F()}#b(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#y(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#w=t=>{let e=t.target?.closest?.("chart-legend-ui[for]");if(!e||e.getAttribute("for")!==this.id)return;let{key:i,active:n}=t.detail||{};i&&(n?this.#a.delete(i):this.#a.add(i),this.#p())};#v(t){return!!t&&this.#a.has(t)}#k=!1;#S(){this.#k||(this.aspect&&this.aspect!=="std"&&(console.warn(`[chart-ui] aspect="${this.aspect}" is deprecated. Parents should size the chart directly (width/height on the card or container). The attribute will be removed in a future major.`),this.#k=!0),this.heading&&(console.warn(`[chart-ui] heading="${this.heading}" is deprecated. Place the title in an enclosing card-ui <header><span slot="heading"> instead. The attribute will be removed in a future major.`),this.#k=!0))}#x(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let n=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),`${n||"$"}${ay(e)}`}default:return ay(e)}}#A=-1;#E(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#C(t){let e=this.#E();if(!e.length){this.#R();return}this.#A=Math.max(0,Math.min(t,e.length-1)),this.#P(),this.#T()}#P(){let t=this.#E();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#A];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#R(){this.#A=-1;for(let t of this.#E())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#T(){let t=this.#E()[this.#A];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#B(t,i)}#q(){let t=this.#E()[this.#A];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.#U(t,i)}))}#Q=()=>{this.#A===-1&&this.#C(0)};#N=()=>{this.#R(),this.#$&&this.#V()};#L=t=>{let e=this.#E();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#C(this.#A+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#C(Math.max(0,this.#A-1));break;case"Home":t.preventDefault(),this.#C(0);break;case"End":t.preventDefault(),this.#C(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#q();break;case"Escape":t.preventDefault(),this.#R(),this.#$&&this.#V();break}};#$=null;#D=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#J(e,t),this.#B(e,t))};#I=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#$&&this.#V(),this.#F();this.#J(e,t),e!==this.#$&&this.#B(e,t)};#M=t=>{t&&t.pointerType==="touch"||(this.#F(),this.#$&&this.#V())};#_=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#$&&this.#V(),this.#F();this.#J(e,t),e!==this.#$&&this.#B(e,t),document.addEventListener("pointerdown",this.#Z)};#Z=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#F(),this.#$&&this.#V(),document.removeEventListener("pointerdown",this.#Z)))};#W=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#U(e,t)}))};#B(t,e){this.#$=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#U(t,e)}))}#V(){this.#$=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#U(t,e){let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=n!=null?Number(n):null,h=r!=null?Number(r):null,c=i??null,u=o??null,d=this.#H(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#H(t,e){if(t==null)return null;let i=this.x,n=this.#X();if(!i||n.length===0)return null;let r=this.#t.find(l=>String(l[i]??"")===String(t));if(!r)return null;let o=n.filter(l=>!this.#v(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(r[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#J(t,e){if(this.#y())return;let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset;if(!this.#g){let b=document.createElement("div");b.setAttribute("popover","manual"),b.setAttribute("role","tooltip"),b.classList.add("chart-tooltip-popup"),document.body.appendChild(b),this.#g=b}let a=[];if(o&&a.push(`<span data-tip-role="series">${se(o)}</span>`),i&&a.push(`<span data-tip-role="label">${se(i)}</span>`),n!==void 0){let b=r!==void 0?` <span data-tip-role="pct">(${r}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#x(n)}${b}</span>`)}this.#g.innerHTML=a.join("");try{this.#g.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#g.offsetWidth||0,f=this.#g.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.#g.style.left=`${p}px`,this.#g.style.top=`${m}px`}#F(){if(this.#g){try{this.#g.hidePopover()}catch{}this.#g.remove(),this.#g=null}}#X(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#Y(t,e,i,n,r,o){let a=r,l=o?.fontSize||10,h=o?.labelSize||l,c="",u=i;if(o?.sizeClass==="sm"&&i.length>4&&(u=i.filter((d,f)=>f%2===0||f===i.length-1)),!this.hideGrid){let f=i[i.length-1]-i[0]||1;for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<line data-grid x1="${a.left}" y1="${m}" x2="${t-a.right}" y2="${m}"/>`}for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<text data-y-label x="${a.left-4}" y="${m+l*.35}" text-anchor="end" font-size="${l}">${this.#x(p)}</text>`}if(n){let m=(t-a.left-a.right)/n.length,g=n.reduce((w,k)=>Math.max(w,String(k).length),1)*h*.6+h*.75,y=Math.max(1,Math.ceil(g/m)),v=n.length-1;for(let w=0;w<n.length;w++){if(w%y!==0&&w!==v||w!==v&&v-w<y)continue;let k=a.left+m*w+m/2;c+=`<text data-x-label x="${k}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${se(n[w])}</text>`}}}return c}#K(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(v=>+(v[i]??0)),r=e.map(v=>v[this.x]??""),o=us(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/e.length,p=f*.6,m=(f-p)/2,b=this.#Y(l,h,o,r,c,t),g=!this.hideValues&&t.sizeClass!=="sm",y=!this.hideAverage&&n.length>1&&t.sizeClass!=="sm"&&!this.hideGrid;for(let v=0;v<e.length;v++){let w=n[v],k=a?w/a*u:0,E=c.left+f*v+m,A=c.top+u-k;b+=`<path data-bar${St({label:r[v],value:w})} d="${vh(E,A,p,k,this.#o())}"/>`,g&&(b+=`<text data-value x="${E+p/2}" y="${A-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#x(w)}</text>`)}if(y){let v=n.reduce((k,E)=>k+E,0)/n.length,w=c.top+u-(a?v/a*u:0);b+=`<line data-avg x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}"/>`,b+=`<text data-avg-label x="${l-c.right+2}" y="${w+3}" text-anchor="start" font-size="${t.valueSize}">${this.#x(v)}</text>`,b+=`<line data-hit${St({label:"Average",value:v})} x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}" stroke="transparent" stroke-width="12"/>`}return{svg:b,viewBox:`0 0 ${l} ${h}`}}#tt(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(A=>+(A[i]??0)),r=e.map(A=>A[this.x]??""),o=us(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#Y(l,h,o,r,c,t),m=n.map((A,C)=>{let T=c.left+f*C,Q=c.top+u-(a?A/a*u:0);return{x:T,y:Q,v:A,label:r[C]}}),b=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${Vd(m,b,g)}"/>`,p+=`<path data-line d="${Pa(m,g)}"/>`;let y=t.sizeClass==="sm",v=y?1.5:3,w=Math.max(v,10),k=!this.hideValues&&!y,E=!this.hideAverage&&n.length>1&&!y&&!this.hideGrid;for(let A of m)p+=`<circle data-dot cx="${A.x}" cy="${A.y}" r="${v}"/>`,p+=`<circle data-hit${St({label:A.label,value:A.v})} cx="${A.x}" cy="${A.y}" r="${w}" fill="transparent"/>`,k&&(p+=`<text data-value x="${A.x}" y="${A.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#x(A.v)}</text>`);if(E){let A=n.reduce((T,Q)=>T+Q,0)/n.length,C=c.top+u-(a?A/a*u:0);p+=`<line data-avg x1="${c.left}" y1="${C}" x2="${l-c.right}" y2="${C}"/>`,p+=`<text data-avg-label x="${l-c.right+2}" y="${C+3}" text-anchor="start" font-size="${t.valueSize}">${this.#x(A)}</text>`,p+=`<line data-hit${St({label:"Average",value:A})} x1="${c.left}" y1="${C}" x2="${l-c.right}" y2="${C}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#et(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d="",f=-Math.PI/2;for(let p=0;p<i.length;p++){let m=i[p]/n*Math.PI*2;if(m===0)continue;let b=f+m,g=(i[p]/n*100).toFixed(1),y=` data-slice="${p%10}"${St({label:r[p],value:i[p],pct:g})}`;Math.abs(m-Math.PI*2)<.001?d+=`<circle${y} cx="${h}" cy="${c}" r="${u}"/>`:d+=`<path${y} d="${IC(h,c,u,f,b)}"/>`,f=b}return this.#z=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:d,viewBox:`0 0 ${a} ${l}`}}#it(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=i.reduce((g,y)=>g+y,0)||1,r=t.map(g=>g[this.x]??""),o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d=u*.72,f="",p=-Math.PI/2;for(let g=0;g<i.length;g++){let y=i[g]/n*Math.PI*2;if(y===0)continue;let v=p+y,w=(i[g]/n*100).toFixed(1),k=` data-slice="${g%10}"${St({label:r[g],value:i[g],pct:w})}`;Math.abs(y-Math.PI*2)<.001?(f+=`<circle${k} cx="${h}" cy="${c}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,f+=`<path${k} d="M ${h-u} ${c} A ${u} ${u} 0 1 1 ${h+u} ${c} A ${u} ${u} 0 1 1 ${h-u} ${c} Z M ${h-d} ${c} A ${d} ${d} 0 1 0 ${h+d} ${c} A ${d} ${d} 0 1 0 ${h-d} ${c} Z" fill-rule="evenodd"/>`):f+=`<path${k} d="${jd(h,c,u,d,p,v,this.#o())}"/>`,p=v}let m=Math.max(14,Math.round(u*.32)),b=Math.max(9,Math.round(u*.16));return f+=`<text data-donut-total x="${h}" y="${c}" text-anchor="middle" dominant-baseline="central" font-size="${m}">${this.#x(n)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${b}">Total</text>`,this.#z=t.map((g,y)=>({label:r[y],value:i[y],pct:(i[y]/n*100).toFixed(1),slot:y%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#st(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(k=>+(k[e]??0)),n=t.map(k=>k[this.x]??""),r=Math.max(...i)||1,o=t.length,a=this.#u(),{width:l,height:h,fontSize:c}=a,u=l/2,d=h/2,f=c*3.5,p=Math.max(40,Math.min(l,h)/2-f),m="",b=Math.PI*2/o;for(let k=1;k<=3;k++){let E=p*k/3,A="";for(let C=0;C<o;C++){let T=-Math.PI/2+b*C,Q=u+E*Math.cos(T),D=d+E*Math.sin(T);A+=(C===0?"M":"L")+` ${Q} ${D}`}A+=" Z",m+=`<path data-grid d="${A}"/>`}for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=u+p*Math.cos(E),C=d+p*Math.sin(E);m+=`<line data-grid x1="${u}" y1="${d}" x2="${A}" y2="${C}"/>`}let g="",y=[];for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=i[k]/r*p,C=u+A*Math.cos(E),T=d+A*Math.sin(E);g+=(k===0?"M":"L")+` ${C} ${T}`,y.push({px:C,py:T})}g+=" Z",m+=`<path data-radar-fill d="${g}"/>`,m+=`<path data-radar-line d="${g}"/>`;let v=Math.max(c,10);for(let k=0;k<o;k++){let{px:E,py:A}=y[k];m+=`<circle data-hit${St({label:n[k],value:i[k]})} cx="${E}" cy="${A}" r="${v}" fill="transparent"/>`}let w=c*1.3;for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=u+(p+w)*Math.cos(E),C=d+(p+w)*Math.sin(E),T=Math.abs(Math.cos(E))<.1?"middle":Math.cos(E)>0?"start":"end";m+=`<text data-x-label x="${A}" y="${C}" text-anchor="${T}" dominant-baseline="central" font-size="${c}">${se(n[k])}</text>`}return{svg:m,viewBox:`0 0 ${l} ${h}`}}#G(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(y=>+(y[e]??0)),n=Math.max(...i)||1,r=Math.min(...i),o=n-r||1,a=this.clientWidth||120,l=this.clientHeight||32,h=Math.max(40,a),c=Math.max(16,l),u=h/Math.max(i.length-1,1),d=Math.max(2,Math.min(6,c*.1)),f=t.map(y=>y[this.x]??""),p=i.map((y,v)=>({x:u*v,y:c-(y-r)/o*(c-d*2)-d,v:y,label:f[v]})),m=Math.max(0,Math.min(1,this.smooth)),b="";b+=`<path data-area d="${Vd(p,c,m)}"/>`,b+=`<path data-line d="${Pa(p,m)}"/>`;let g=Math.max(u/2,6);for(let y of p)b+=`<circle data-hit${St({label:y.label,value:y.v})} cx="${y.x}" cy="${y.y}" r="${g}" fill="transparent"/>`;return{svg:b,viewBox:`0 0 ${h} ${c}`}}#j(){return this.#tt()}#nt(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(g=>+(g[i]??0)),r=e.map(g=>g[this.x]??""),o=us(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#Y(l,h,o,r,c,t),m=t.sizeClass==="sm"?2.5:4,b=Math.max(m*2,10);for(let g=0;g<n.length;g++){let y=c.left+f*g,v=c.top+u-(a?n[g]/a*u:0);p+=`<circle data-dot data-scatter cx="${y}" cy="${v}" r="${m}"/>`,p+=`<circle data-hit${St({label:r[g],value:n[g]})} cx="${y}" cy="${v}" r="${b}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#rt(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=t.map(g=>g[this.x]??""),r=Math.max(...i)||1,o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.45),d=u*.3,f=i.length||1,p=(u-d)/f,m=Math.min(2,p*.15),b="";for(let g=0;g<i.length;g++){let y=d+p*g+m/2,v=d+p*(g+1)-m/2,w=(y+v)/2,k=v-y,E=2*Math.PI*w,A=Math.max(0,Math.min(1,i[g]/r))*E;if(b+=`<circle data-radial-track cx="${h}" cy="${c}" r="${w}" fill="none" stroke-width="${k}"/>`,A<=0)continue;let C=(i[g]/r*100).toFixed(1),T=St({label:n[g],value:i[g],pct:C}),Q=Math.abs(A-E)<.5,D=Q?"butt":"round",R=Q?`${E} 0`:`${A} ${E-A}`;b+=`<circle data-slice="${g%10}"${T} data-radial-bar cx="${h}" cy="${c}" r="${w}" fill="none" stroke-width="${k}" stroke-linecap="${D}" stroke-dasharray="${R}" transform="rotate(-90 ${h} ${c})"/>`}return this.#z=t.map((g,y)=>({label:n[y],key:n[y],value:i[y],pct:(i[y]/r*100).toFixed(1),slot:y%10})),{svg:b,viewBox:`0 0 ${a} ${l}`}}#ot(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(w=>+(w[e]??0)),n=i.reduce((w,k)=>w+k,0)||1,r=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(r,1):n,a=Math.max(0,Math.min(1,r/o)),l=this.#u(),{width:h,height:c}=l,u=h/2,d=c*.68,f=Math.max(40,Math.min(h*.45,c*.6)),p=f*.72,m=(f-p)/2,b="";if(b+=`<path data-radial-track d="${jd(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let w=Math.PI+Math.PI*a,k=St({label:t[0]?.[this.x]??"Value",value:r,pct:(a*100).toFixed(1)});b+=`<path data-slice="0"${k} data-gauge-fill d="${jd(u,d,f,p,Math.PI,w,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),y=Math.max(10,Math.round(f*.2)),v=d-f*.15;return b+=`<text data-gauge-value x="${u}" y="${v}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#x(r)}</text>`,o!==r&&(b+=`<text data-gauge-max x="${u}" y="${v+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${y}">of ${this.#x(o)}</text>`),{svg:b,viewBox:`0 0 ${h} ${c}`}}#at(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(v=>+(v[e]??0)),n=t.map(v=>v[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#u(),{width:l,height:h}=a,c=a.fontSize,u=Math.max(l*.18,80),d=c*.8,f=l-u*2,m=(h-d*2)/r,b=Math.max(2,m*.08),g=l/2,y="";for(let v=0;v<r;v++){let w=i[v],k=v<r-1?i[v+1]:i[v],E=w/o*(f/2),A=k/o*(f/2),C=d+m*v+b/2,T=d+m*(v+1)-b/2,Q=(w/o*100).toFixed(1),D=St({label:n[v],value:w,pct:Q}),R=`M ${g-E} ${C} L ${g+E} ${C} L ${g+A} ${T} L ${g-A} ${T} Z`;if(y+=`<path data-slice="${v%10}" data-funnel-stage${D} d="${R}"/>`,y+=`<text data-funnel-label x="${u-8}" y="${C+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${se(n[v])}</text>`,y+=`<text data-funnel-value x="${l-u+8}" y="${C+m/2}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#x(w)}</text>`,v>0){let _=(i[v]/i[0]*100).toFixed(0);y+=`<text data-funnel-drop x="${l-u+8}" y="${C+m/2+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${_}%</text>`}}return this.#z=t.map((v,w)=>({label:n[w],value:i[w],pct:(i[w]/o*100).toFixed(1),slot:w%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#lt(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(Q=>+(Q[e]??0)),n=t.map(Q=>Q[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#u(),{width:a,height:l,fontSize:h}=o,c=i.reduce((Q,D)=>Q+D,0)||1,u=Array.from({length:r},(Q,D)=>D).sort((Q,D)=>i[D]-i[Q]),d=[],f=a*l,p=u.map(Q=>i[Q]/c*f),m=0,b=0,g=a,y=l,v=[],w=0,k=(Q,D)=>{if(Q.length===0)return 1/0;let R=Q.reduce((nt,ut)=>nt+ut,0),_=Math.max(...Q),V=Math.min(...Q),U=D*D,J=R*R;return Math.max(U*_/J,J/(U*V))},E=(Q,D,R,_,V,U)=>{let J=Q.reduce((xt,Ot)=>xt+Ot,0),nt=V>=U,ut=nt?J/V:U,ot=nt?V:J/U,bt=0;for(let xt=0;xt<Q.length;xt++){let Ot=Q[xt]/J,Et=u[D+xt];if(nt){let Tt=Ot*V;d.push({i:Et,x:R+bt,y:_,w:Tt,h:ut}),bt+=Tt}else{let Tt=Ot*U;d.push({i:Et,x:R,y:_+bt,w:ot,h:Tt}),bt+=Tt}}return nt?{x:R,y:_+ut,w:V,h:U-ut}:{x:R+ot,y:_,w:V-ot,h:U}},A=p.slice();for(;A.length>0;){v=[A[0]],w=p.length-A.length;let Q=Math.min(g,y),D=1;for(;D<A.length;){let _=v.concat(A[D]);if(k(_,Q)>k(v,Q))break;v=_,D++}let R=E(v,w,m,b,g,y);m=R.x,b=R.y,g=R.w,y=R.h,A=A.slice(v.length)}let C="",T=2;for(let Q of d){let D=(i[Q.i]/c*100).toFixed(1),R=St({label:n[Q.i],value:i[Q.i],pct:D});C+=`<rect data-slice="${Q.i%10}" data-treemap-tile${R} x="${Q.x+T}" y="${Q.y+T}" width="${Math.max(0,Q.w-T*2)}" height="${Math.max(0,Q.h-T*2)}" rx="${this.#o()}"/>`;let _=Q.x+8,V=Q.w>h*4,U=V&&Q.h>h*2.5,J=V&&!U&&Q.h>h*1.2;if(U)C+=`<text data-treemap-label x="${_}" y="${Q.y+h+4}" font-size="${h}" dominant-baseline="hanging">${se(n[Q.i])}</text>`,C+=`<text data-treemap-value x="${_}" y="${Q.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#x(i[Q.i])}</text>`;else if(J){let nt=Q.y+Q.h/2;C+=`<text data-treemap-label x="${_}" y="${nt}" font-size="${h}" dominant-baseline="central">${se(n[Q.i])}</text>`}}return this.#z=t.map((Q,D)=>({label:n[D],value:i[D],pct:(i[D]/c*100).toFixed(1),slot:D%10})),{svg:C,viewBox:`0 0 ${a} ${l}`}}#ht(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let w of t){let k=w.source??w.from??"",E=w.target??w.to??"",A=+(w.value??w.v??0);e.has(k)||e.set(k,{name:k,flow:0}),i.has(E)||i.set(E,{name:E,flow:0}),e.get(k).flow+=A,i.get(E).flow+=A}let n=this.#u(),{width:r,height:o,fontSize:a}=n,l=Math.max(8,r*.03),h=l+a*5,c=[...e.values()].reduce((w,k)=>w+k.flow,0)||1,u=[...i.values()].reduce((w,k)=>w+k.flow,0)||1,d=a*.6,f=[...e.values()],p=[...i.values()],m=o-d*(f.length-1),b=o-d*(p.length-1),g=0;for(let w of f){let k=w.flow/c*m;w.y0=g,w.y1=g+k,w.cursor=g,g+=k+d}g=0;for(let w of p){let k=w.flow/u*b;w.y0=g,w.y1=g+k,w.cursor=g,g+=k+d}let y="",v=Math.min(this.#o(),l/2);f.forEach((w,k)=>{y+=`<rect data-sankey-node data-slice="${k%10}" x="${h-l}" y="${w.y0}" width="${l}" height="${w.y1-w.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${h-l-6}" y="${(w.y0+w.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${se(w.name)}</text>`}),p.forEach((w,k)=>{y+=`<rect data-sankey-node data-slice="${(f.length+k)%10}" x="${r-h}" y="${w.y0}" width="${l}" height="${w.y1-w.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${r-h+l+6}" y="${(w.y0+w.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${se(w.name)}</text>`});for(let w of t){let k=e.get(w.source??w.from??""),E=i.get(w.target??w.to??"");if(!k||!E)continue;let A=+(w.value??w.v??0);if(A<=0)continue;let C=A/c*m,T=A/u*b,Q=k.cursor,D=Q+C,R=E.cursor,_=R+T;k.cursor+=C,E.cursor+=T;let V=h,U=r-h,J=(V+U)/2,nt=St({label:`${k.name} \u2192 ${E.name}`,value:A}),ut=`M ${V} ${Q} C ${J} ${Q}, ${J} ${R}, ${U} ${R} L ${U} ${_} C ${J} ${_}, ${J} ${D}, ${V} ${D} Z`;y+=`<path data-sankey-link${nt} d="${ut}"/>`}return{svg:y,viewBox:`0 0 ${r} ${o}`}}#ct(){let t=this.#u(),e=this.#t,i=this.#X(),n=i[0]||"bar",r=i[1]||"line",o=e.map(E=>E[this.x]??""),a=e.map(E=>+(E[n]??0)),l=e.map(E=>+(E[r]??0)),h=[...a,...l],c=us(0,Math.max(...h),5),u=c[c.length-1],{width:d,height:f,pad:p}=t,m=f-p.top-p.bottom,b=d-p.left-p.right,g=b/e.length,y=g*.6,v=(g-y)/2,w=b/Math.max(e.length-1,1),k=this.#Y(d,f,c,o,p,t);if(!this.#v(n))for(let E=0;E<e.length;E++){let A=a[E],C=u?A/u*m:0,T=p.left+g*E+v,Q=p.top+m-C;k+=`<path${this.#m(0,n)}${St({label:o[E],value:A,series:n})} d="${vh(T,Q,y,C,this.#o())}"/>`}if(!this.#v(r)){let E=l.map((C,T)=>({x:p.left+g*T+g/2,y:p.top+m-(u?C/u*m:0),v:C,label:o[T]})),A=Math.max(0,Math.min(1,this.smooth));k+=`<path data-line${this.#O(1,r)} d="${Pa(E,A)}"/>`;for(let C of E)k+=`<circle data-dot${this.#m(1,r)} cx="${C.x}" cy="${C.y}" r="3"/>`,k+=`<circle data-hit${St({label:C.label,value:C.v,series:r})} cx="${C.x}" cy="${C.y}" r="10" fill="transparent"/>`}return this.#z=[{label:n,key:n,slot:0},{label:r,key:r,slot:1}],{svg:k,viewBox:`0 0 ${d} ${f}`}}#ut(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=getComputedStyle(this),a=Math.max(40,this.clientWidth||200),l=24,h=Math.min(this.#o(),l/2),c=Math.max(0,parseFloat(o.getPropertyValue("--chart-segments-gap"))||2),u=[],d=0;for(let p=0;p<i.length;p++){let m=p===i.length-1?a:Math.round((d*n+i[p]*a)/n),b=p===i.length-1?a:i.slice(0,p+1).reduce((y,v)=>y+v,0)/n*a,g=p===0?0:i.slice(0,p).reduce((y,v)=>y+v,0)/n*a;u.push({x:g,w:Math.max(0,b-g)}),d=m}let f="";for(let p=0;p<u.length;p++){let{x:m,w:b}=u[p];if(b<=0)continue;let g=p===0,y=p===u.length-1,v=Math.max(0,b-(y?0:c)),w=(i[p]/n*100).toFixed(1),k=St({label:r[p],value:i[p],pct:w}),E=`<title>${se(r[p])}: ${i[p]} (${w}%)</title>`;if(g&&y||!g&&!y||h===0)f+=`<rect data-slice="${p%10}"${k} x="${m}" y="0" width="${v}" height="${l}"${(g||y)&&h?` rx="${h}"`:""}>${E}</rect>`;else{let A=h,C=m+v,T;g?T=`M ${m+A} 0 H ${C} V ${l} H ${m+A} A ${A} ${A} 0 0 1 ${m} ${l-A} V ${A} A ${A} ${A} 0 0 1 ${m+A} 0 Z`:T=`M ${m} 0 H ${C-A} A ${A} ${A} 0 0 1 ${C} ${A} V ${l-A} A ${A} ${A} 0 0 1 ${C-A} ${l} H ${m} Z`,f+=`<path data-slice="${p%10}"${k} d="${T}">${E}</path>`}}return this.#z=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#dt(){let t=this.#t,e=this.#X(),i=t.map(g=>g[this.x]??""),n=t.map(g=>e.reduce((y,v)=>y+ +(g[v]??0),0)),r=us(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=f*.6,m=(f-p)/2,b=this.#Y(l,h,r,i,c,a);for(let g=0;g<t.length;g++){let y=c.top+u,v=e.length;for(let w=0;w<v;w++){if(this.#v(e[w]))continue;let k=+(t[g][e[w]]??0),E=o?k/o*u:0;if(E<=0){y-=E;continue}y-=E;let A=c.left+f*g+m,C=y,T=E,Q=w===v-1,D=this.#o(),R=`${this.#m(w%10,e[w])}${St({label:i[g],value:k,series:e[w]})}`;Q?b+=`<path${R} d="${vh(A,C,p,T,D)}"/>`:b+=`<rect${R} x="${A}" y="${C}" width="${p}" height="${T}"/>`}}return this.#z=e.map((g,y)=>({label:g,key:g,slot:y%10})),{svg:b,viewBox:`0 0 ${l} ${h}`}}#ft(){let t=this.#t,e=this.#X(),i=t.map(v=>v[this.x]??""),n=t.flatMap(v=>e.map(w=>+(v[w]??0))),r=us(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=3,m=f*.7,b=(m-p*(e.length-1))/e.length,g=(f-m)/2,y=this.#Y(l,h,r,i,c,a);for(let v=0;v<t.length;v++)for(let w=0;w<e.length;w++){if(this.#v(e[w]))continue;let k=+(t[v][e[w]]??0),E=o?k/o*u:0,A=c.left+f*v+g+(b+p)*w,C=c.top+u-E;y+=`<path${this.#m(w%10,e[w])}${St({label:i[v],value:k,series:e[w]})} d="${vh(A,C,b,E,this.#o())}"/>`,this.hideValues||(y+=`<text data-value x="${A+b/2}" y="${C-4}" text-anchor="middle" font-size="${a.valueSize}">${this.#x(k)}</text>`)}return this.#z=e.map((v,w)=>({label:v,key:v,slot:w%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#pt(){let t=this.#t,e=this.#X(),i=t.map(m=>m[this.x]??""),n=t.flatMap(m=>e.map(b=>+(m[b]??0))),r=us(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(t.length-1,1),p=this.#Y(l,h,r,i,c,a);for(let m=0;m<e.length;m++){if(this.#v(e[m]))continue;let g=t.map(w=>+(w[e[m]]??0)).map((w,k)=>{let E=c.left+f*k,A=c.top+u-(o?w/o*u:0);return{x:E,y:A,v:w,label:i[k]}}),y=c.top+u,v=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area${this.#m(m%10,e[m])} d="${Vd(g,y,v)}"/>`,p+=`<path data-line${this.#O(m%10,e[m])} d="${Pa(g,v)}"/>`;for(let w of g)p+=`<circle data-dot${this.#m(m%10,e[m])} cx="${w.x}" cy="${w.y}" r="3"/>`,p+=`<circle data-hit${St({label:w.label,value:w.v,series:e[m]})} cx="${w.x}" cy="${w.y}" r="10" fill="transparent"/>`}return this.#z=e.map((m,b)=>({label:m,key:m,slot:b%10})),{svg:p,viewBox:`0 0 ${l} ${h}`}}#z=null;get legendData(){return this.#z?this.#z.map(t=>({...t})):null}#mt(){if(!this.#z||!this.#z.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#z){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let n=document.createElement("span");n.setAttribute("data-legend-dot",""),n.setAttribute("data-slice",String(e.slot)),e.key&&(n.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(n);let r=document.createElement("span");r.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(r),t.appendChild(i)}return t}};S("chart-ui",dr);P();var fr=class s extends x{static properties={for:{type:String,default:"",reflect:!0},items:{type:String,default:"",reflect:!1},shape:{type:String,default:"dot",reflect:!0},position:{type:String,default:"bottom",reflect:!0},static:{type:Boolean,default:!1,reflect:!0},onToggle:{type:String,default:"hide",reflect:!0,attribute:"on-toggle"}};static template=()=>null;#t=null;#e=null;#i=new Set;connected(){this.setAttribute("role","list"),this.#s(),this.#a()}disconnected(){this.#n()}render(){this.#s(),this.#a()}#s(){if(this.#n(),!this.for)return;let t=this.getRootNode()?.getElementById?.(this.for)||document.getElementById(this.for);if(!t){s._warned||(s._warned=new WeakSet);let e={el:this,id:this.for};s._warned.has(this)||(console.warn(`[chart-legend-ui] [for="${this.for}"] did not resolve to an element.`),s._warned.add(this));return}this.#t=t,this.#e=()=>this.#a(),t.addEventListener("legend-update",this.#e)}#n(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#r(){if(this.items)try{let t=JSON.parse(this.items);if(Array.isArray(t))return t}catch{}return this.#t&&Array.isArray(this.#t.legendData)?this.#t.legendData:[]}#a(){let t=this.#r();if(this.innerHTML="",!!t.length)for(let e of t){let i=e.key??e.label??"",n=e.label??i,r=e.slot!=null?e.slot:0,o=!this.#i.has(i),a=document.createElement("badge-ui");a.setAttribute("data-row",""),a.setAttribute("role",this.static?"listitem":"button"),a.setAttribute("text",n),i&&a.setAttribute("data-key",i),o&&a.setAttribute("data-active",""),this.static||(a.setAttribute("tabindex","0"),a.setAttribute("aria-pressed",o?"true":"false"));let l=this.shape||"dot",h=document.createElement("swatch-ui");h.setAttribute("shape",l),h.setAttribute("size","sm");let c=i?`var(--color-${i}, var(--a-data-${r}))`:`var(--a-data-${r})`;h.style.setProperty("--swatch-color",c),a.appendChild(h),this.static||(a.addEventListener("click",u=>this.#o(u,i)),a.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.#o(u,i))})),this.appendChild(a)}}#o(t,e){if(!e)return;let n=!!this.#i.has(e);n?this.#i.delete(e):this.#i.add(e);let r=t.currentTarget;n?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.setAttribute("aria-pressed",n?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:n,mode:this.onToggle||"hide"}}))}};S("chart-legend-ui",fr);P();var DC=120,pr=class extends x{static properties={placement:{type:String,default:"bottom",reflect:!0},gap:{type:Number,default:4,reflect:!0},open:{type:Boolean,default:!1,reflect:!0},trigger:{type:String,default:"click",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=null;#s=null;#n=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#d),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#o),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#u),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#u))))}render(){this.open?this.#r():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){let t=this.querySelector('[slot="trigger"]'),e=this.#s??this.querySelector('[slot="content"]');if(!(!t||!e)){if(!e.matches(":popover-open"))try{e.showPopover()}catch{}this.#t?.(),this.#t=ct(t,e,{placement:this.placement,gap:this.gap}),(this.trigger==="click"||this.trigger==="manual")&&(this.#n=requestAnimationFrame(()=>{this.#n=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#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.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#c)}#o=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.open=!this.open)};#l=t=>{if(!this.open)return;let e=this.#s;this.contains(t.target)||e?.contains(t.target)||(this.open=!1)};#c=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#u=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},DC)};#d=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#a(),this.trigger==="click"&&this.removeEventListener("click",this.#o),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#u),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#u))),this.#s?.removeEventListener("toggle",this.#d),this.#s=null,this.#e=!1}};S("popover-ui",pr);P();var mr=class extends x{static requiredIcons=["caret-down"];static properties={multiple:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.addEventListener("toggle",this.#t)}disconnected(){this.removeEventListener("toggle",this.#t)}#t=t=>{if(this.multiple)return;let e=t.target;if(!e.open)return;let i=this.querySelectorAll("accordion-item-ui");for(let n of i)n!==e&&n.open&&(n.open=!1)}},gr=class extends x{static properties={text:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){if(!this.querySelector('[slot="header"]')){let t=document.createElement("div");t.setAttribute("slot","header");let e=document.createElement("span");e.setAttribute("slot","header-text"),t.appendChild(e);let i=document.createElement("icon-ui");i.setAttribute("name","caret-down"),i.setAttribute("slot","caret"),t.appendChild(i),this.prepend(t)}if(!this.querySelector('[slot="body"]')){let t=document.createElement("div");t.setAttribute("slot","body");let e=[...this.childNodes].filter(i=>i.nodeType===1?!i.hasAttribute("slot"):i.nodeType===3&&i.textContent.trim());for(let i of e)t.appendChild(i);this.appendChild(t)}this.#t||(this.#t=!0,this.addEventListener("click",this.#e))}disconnected(){this.removeEventListener("click",this.#e),this.#t=!1}render(){let t=this.querySelector('[slot="header-text"]');t&&(t.textContent=this.text)}#e=t=>{let e=this.querySelector('[slot="header"]');!e||!e.contains(t.target)||t.target.closest('[slot="action"], [slot="actions"], [data-no-toggle]')||(this.open=!this.open,this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{open:this.open}})))}};S("accordion-ui",mr),S("accordion-item-ui",gr);P();var br=class extends x{static properties={label:{type:String,default:"",reflect:!0},vertical:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","separator")}render(){if(this.vertical?this.setAttribute("aria-orientation","vertical"):this.removeAttribute("aria-orientation"),this.label){let t=this.querySelector('[slot="label"]');t||(t=document.createElement("span"),t.setAttribute("slot","label"),this.appendChild(t)),t.textContent=this.label}else{let t=this.querySelector('[slot="label"]');t&&t.remove()}}};S("divider-ui",br);P();var Or=class extends x{static properties={cite:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","blockquote")}render(){let t=this.querySelector('[slot="cite"]:not([data-cite-stamped])'),e=this.querySelector('[slot="cite"][data-cite-stamped]');if(t){e?.remove();return}if(this.cite)if(e)e.textContent=this.cite;else{let i=document.createElement("span");i.setAttribute("slot","cite"),i.setAttribute("data-cite-stamped",""),i.textContent=this.cite,this.appendChild(i)}else e&&e.remove()}};S("blockquote-ui",Or);P();var Wd=[{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}],yr=class extends x{static properties={datetime:{type:String,default:"",reflect:!0},timeStyle:{type:String,default:"long",reflect:!0,attribute:"time-style"},numeric:{type:String,default:"auto",reflect:!0},locale:{type:String,default:"",reflect:!0},updateInterval:{type:Number,default:60,reflect:!0,attribute:"update-interval"}};static template=()=>null;#t=null;#e(){return this.locale?this.locale:this.ownerDocument?.documentElement?.lang||void 0}#i(){if(!this.datetime)return"";let t=new Date(this.datetime);if(Number.isNaN(t.getTime()))return"";let e=(t.getTime()-Date.now())/1e3,i=Math.abs(e),n=Wd.find(o=>i<=o.limit)||Wd[Wd.length-1],r=Math.round(e/n.divisor);try{return new Intl.RelativeTimeFormat(this.#e(),{style:this.timeStyle,numeric:this.numeric}).format(r,n.unit)}catch{let o=e<0,a=Math.abs(r);return o?`${a} ${n.unit}${a===1?"":"s"} ago`:`in ${a} ${n.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.#n()}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.#n()}#n(){this.#r();let t=Number(this.updateInterval);!Number.isFinite(t)||t<=0||(this.#t=setInterval(()=>{this.textContent=this.#i()},t*1e3))}#r(){this.#t!=null&&(clearInterval(this.#t),this.#t=null)}disconnected(){super.disconnected(),this.#r()}};S("relative-time-ui",yr);P();var vr=class extends x{static properties={value:{type:Number,default:0,reflect:!0},numberStyle:{type:String,default:"decimal",reflect:!0,attribute:"number-style"},currency:{type:String,default:"",reflect:!0},unit:{type:String,default:"",reflect:!0},notation:{type:String,default:"standard",reflect:!0},compactDisplay:{type:String,default:"short",reflect:!0,attribute:"compact-display"},minimumFractionDigits:{type:Number,default:0,reflect:!0,attribute:"minimum-fraction-digits"},maximumFractionDigits:{type:Number,default:2,reflect:!0,attribute:"maximum-fraction-digits"},locale:{type:String,default:"",reflect:!0},signDisplay:{type:String,default:"auto",reflect:!0,attribute:"sign-display"}};static template=()=>null;#t(){return this.locale?this.locale:this.ownerDocument?.documentElement?.lang||void 0}#e(){let t=Number(this.value);if(!Number.isFinite(t)||this.numberStyle==="currency"&&!this.currency||this.numberStyle==="unit"&&!this.unit)return"";let e={style:this.numberStyle,notation:this.notation,signDisplay:this.signDisplay};this.numberStyle==="currency"&&(e.currency=this.currency),this.numberStyle==="unit"&&(e.unit=this.unit),this.notation==="compact"&&(e.compactDisplay=this.compactDisplay),Number.isFinite(this.minimumFractionDigits)&&(e.minimumFractionDigits=this.minimumFractionDigits),Number.isFinite(this.maximumFractionDigits)&&(e.maximumFractionDigits=this.maximumFractionDigits);try{return new Intl.NumberFormat(this.#t(),e).format(t)}catch{return String(t)}}connected(){super.connected()}render(){let t=this.#e();this.textContent=t,t&&Number.isFinite(Number(this.value))?this.setAttribute("aria-label",`${t} (raw: ${this.value})`):this.removeAttribute("aria-label")}};S("number-format-ui",vr);P();var Ud=["Weak","Fair","Good","Strong"];function qC(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 xr=class extends x{static properties={value:{type:String,default:""},minScore:{type:Number,default:2,reflect:!0,attribute:"min-score"},showLabel:{type:Boolean,default:!0,reflect:!0,attribute:"show-label"}};static template=()=>null;#t=-2;connected(){super.connected(),this.querySelector('[slot="bar"]')||(this.innerHTML=`
|
|
190
|
+
[{ label: "Jan", value: 100 }, { label: "Feb", value: 200 }]`)),this.#t=Array.isArray(t)?t:[],this.#c(),this.#p()}get data(){return this.#t}#l=!1;#c(){if(this.#l)return;let t=this.#h();this.#t.length>t&&(console.warn(`[chart-ui] .data has ${this.#t.length} rows which exceeds the recommended perf budget of ${t}. Consider downsampling at the data layer (e.g., LTTB, bucket aggregation). Override the budget via CSS: chart-ui { --chart-perf-budget: 10000 }.`),this.#l=!0)}#h(){let t=getComputedStyle(this).getPropertyValue("--chart-perf-budget").trim(),e=parseInt(t,10);return Number.isFinite(e)&&e>0?e:5e3}connected(){if(this.hasAttribute("role")||this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.heading||`${this.type} chart`),this.#t.length===0&&this.hasAttribute("data"))try{let t=JSON.parse(this.getAttribute("data"));Array.isArray(t)&&(this.data=t)}catch{}document.addEventListener("toggle",this.#w),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",this.#M),this.addEventListener("focus",this.#T),this.addEventListener("blur",this.#N),this.addEventListener("pointerover",this.#D),this.addEventListener("pointermove",this.#I),this.addEventListener("pointerleave",this.#R),this.addEventListener("pointerdown",this.#_),this.addEventListener("click",this.#W),this.#S(),this.#i=new ResizeObserver(t=>{let{inlineSize:e,blockSize:i}=t[0].contentBoxSize[0];if(!this.#t.length)return;let n=Math.round(e),r=Math.round(i);n===this.#n&&(!this.hasAttribute("resize")||r===this.#r)||(this.#n=n,this.#r=r,!this.#s&&(this.#s=requestAnimationFrame(()=>{this.#s=null,this.#p()})))}),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.#p()}#u(){let t=this.clientWidth||300,e=this.clientHeight||0,i=ly[this.aspect]||ly.std,n=this.#t.length||1,r=Math.max(t,120),a=(this.hasAttribute("resize")||this.style.height)&&e>40?e:Math.round(r/i.ratio),l=parseFloat(getComputedStyle(this).maxHeight);isFinite(l)&&l>0&&a>l&&(a=Math.round(l));let h=Math.min(r,a),c=this.size||(h<150?"sm":h<300?"md":"lg"),u=c==="sm"?9:c==="md"?10:11,d=u,f=c==="sm"?8:c==="md"?9:10,p=this.hideGrid,m=p?0:u*3.2,b=!!this.x,g={top:p?2:u*1.6,right:p?2:u*1.2,bottom:!b||p?2:u*2.2,left:m},y=r-g.left-g.right,v=Math.max(4,y/n*.6);return{width:r,height:a,pad:g,fontSize:u,labelSize:d,valueSize:f,barMinW:v,plotW:y,n,sizeClass:c}}#d=null;#p(){if(!this.isConnected)return;let t=this.querySelector(':scope > [slot="empty"]');if(t&&!this.#d&&(this.#d=t.cloneNode(!0)),this.innerHTML="",this.#d&&this.appendChild(this.#d.cloneNode(!0)),!this.#t.length){this.removeAttribute("data-has-data");return}if(this.setAttribute("data-has-data",""),this.#f(),this.heading){let o=document.createElement("div");o.setAttribute("data-chart-heading",""),o.textContent=this.heading,this.appendChild(o)}let e=document.createElement("div");this.type==="sparkline"&&e.setAttribute("data-sparkline",""),this.appendChild(e);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");e.appendChild(i);let n="",r="";switch(this.type){case"bar":({svg:n,viewBox:r}=this.#K());break;case"line":({svg:n,viewBox:r}=this.#tt());break;case"pie":({svg:n,viewBox:r}=this.#et());break;case"donut":({svg:n,viewBox:r}=this.#it());break;case"radar":({svg:n,viewBox:r}=this.#st());break;case"sparkline":({svg:n,viewBox:r}=this.#G());break;case"segments":({svg:n,viewBox:r}=this.#ut());break;case"area":({svg:n,viewBox:r}=this.#j());break;case"scatter":({svg:n,viewBox:r}=this.#nt());break;case"radial-bar":({svg:n,viewBox:r}=this.#rt());break;case"gauge":({svg:n,viewBox:r}=this.#ot());break;case"funnel":({svg:n,viewBox:r}=this.#at());break;case"treemap":({svg:n,viewBox:r}=this.#lt());break;case"sankey":({svg:n,viewBox:r}=this.#ht());break;case"composed":({svg:n,viewBox:r}=this.#ct());break;case"stacked-bar":({svg:n,viewBox:r}=this.#dt());break;case"grouped-bar":({svg:n,viewBox:r}=this.#ft());break;case"multi-line":({svg:n,viewBox:r}=this.#pt());break;default:({svg:n,viewBox:r}=this.#K());break}if(i.setAttribute("viewBox",r),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.innerHTML=n,["pie","donut","stacked-bar","grouped-bar","multi-line","radial-bar"].includes(this.type)&&!this.#b()){let o=this.#mt();o&&this.appendChild(o)}this.dispatchEvent(new CustomEvent("legend-update",{bubbles:!0}))}#f(){let t=this.#X();for(let e=0;e<t.length;e++){let i=e%10;this.style.setProperty(`--color-${t[e]}`,`var(--chart-${i})`)}}#m(t,e){return e?` data-slice="${t}" data-series-key="${se(e)}" style="fill: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#O(t,e){return e?` data-slice="${t}" data-series-key="${se(e)}" style="stroke: var(--color-${e}, var(--chart-${t}))"`:` data-slice="${t}"`}#g=null;disconnected(){this.#i?.disconnect(),this.#i=null,this.#s&&(cancelAnimationFrame(this.#s),this.#s=null),document.removeEventListener("toggle",this.#w),document.removeEventListener("pointerdown",this.#Z),this.removeEventListener("keydown",this.#M),this.removeEventListener("focus",this.#T),this.removeEventListener("blur",this.#N),this.removeEventListener("pointerover",this.#D),this.removeEventListener("pointermove",this.#I),this.removeEventListener("pointerleave",this.#R),this.removeEventListener("pointerdown",this.#_),this.removeEventListener("click",this.#W),this.#F()}#b(){return this.id?!!document.querySelector(`chart-legend-ui[for="${CSS.escape(this.id)}"]`):!1}#y(){return this.id?!!document.querySelector(`tooltip-ui[follows="pointer"][for="${CSS.escape(this.id)}"]`):!1}#w=t=>{let e=t.target?.closest?.("chart-legend-ui[for]");if(!e||e.getAttribute("for")!==this.id)return;let{key:i,active:n}=t.detail||{};i&&(n?this.#a.delete(i):this.#a.add(i),this.#p())};#v(t){return!!t&&this.#a.has(t)}#k=!1;#S(){this.#k||(this.aspect&&this.aspect!=="std"&&(console.warn(`[chart-ui] aspect="${this.aspect}" is deprecated. Parents should size the chart directly (width/height on the card or container). The attribute will be removed in a future major.`),this.#k=!0),this.heading&&(console.warn(`[chart-ui] heading="${this.heading}" is deprecated. Place the title in an enclosing card-ui <header><span slot="heading"> instead. The attribute will be removed in a future major.`),this.#k=!0))}#x(t){if(t==null||t==="")return"";let e=+t;if(!Number.isFinite(e))return String(t);switch(this.format||"abbr"){case"decimal":return e.toFixed(2);case"percent":return`${(e*100).toFixed(1)}%`;case"currency":{let n=getComputedStyle(this).getPropertyValue("--chart-currency-prefix").trim();return(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),`${n||"$"}${ay(e)}`}default:return ay(e)}}#A=-1;#E(){return Array.from(this.querySelectorAll("[data-tip-label], [data-tip-value]"))}#C(t){let e=this.#E();if(!e.length){this.#L();return}this.#A=Math.max(0,Math.min(t,e.length-1)),this.#$(),this.#P()}#$(){let t=this.#E();for(let i of t)i.removeAttribute("data-a11y-focus");let e=t[this.#A];if(!e)return this.removeAttribute("data-a11y-focused");e.setAttribute("data-a11y-focus",""),this.setAttribute("data-a11y-focused","")}#L(){this.#A=-1;for(let t of this.#E())t.removeAttribute("data-a11y-focus");this.removeAttribute("data-a11y-focused")}#P(){let t=this.#E()[this.#A];if(!t)return;let e=t.getBoundingClientRect(),i={clientX:e.left+e.width/2,clientY:e.top+e.height/2};this.#B(t,i)}#q(){let t=this.#E()[this.#A];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.#U(t,i)}))}#T=()=>{this.#A===-1&&this.#C(0)};#N=()=>{this.#L(),this.#Q&&this.#V()};#M=t=>{let e=this.#E();if(e.length)switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),this.#C(this.#A+1);break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.#C(Math.max(0,this.#A-1));break;case"Home":t.preventDefault(),this.#C(0);break;case"End":t.preventDefault(),this.#C(e.length-1);break;case"Enter":case" ":t.preventDefault(),this.#q();break;case"Escape":t.preventDefault(),this.#L(),this.#Q&&this.#V();break}};#Q=null;#D=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&(this.#J(e,t),this.#B(e,t))};#I=t=>{if(t.pointerType==="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#Q&&this.#V(),this.#F();this.#J(e,t),e!==this.#Q&&this.#B(e,t)};#R=t=>{t&&t.pointerType==="touch"||(this.#F(),this.#Q&&this.#V())};#_=t=>{if(t.pointerType!=="touch")return;let e=t.target.closest("[data-tip-label], [data-tip-value]");if(!e)return this.#Q&&this.#V(),this.#F();this.#J(e,t),e!==this.#Q&&this.#B(e,t),document.addEventListener("pointerdown",this.#Z)};#Z=t=>{t.pointerType==="touch"&&(this.contains(t.target)||(this.#F(),this.#Q&&this.#V(),document.removeEventListener("pointerdown",this.#Z)))};#W=t=>{let e=t.target.closest("[data-tip-label], [data-tip-value]");e&&this.dispatchEvent(new CustomEvent("chart-select",{bubbles:!0,detail:this.#U(e,t)}))};#B(t,e){this.#Q=t,this.dispatchEvent(new CustomEvent("chart-hover",{bubbles:!0,detail:this.#U(t,e)}))}#V(){this.#Q=null,this.dispatchEvent(new CustomEvent("chart-leave",{bubbles:!0}))}#U(t,e){let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset,a=t.dataset.slice!=null?Number(t.dataset.slice):null,l=n!=null?Number(n):null,h=r!=null?Number(r):null,c=i??null,u=o??null,d=this.#H(c,u)??[{series:u,label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,slot:a}];return{label:c,value:Number.isFinite(l)?l:n??null,pct:Number.isFinite(h)?h:null,series:u,slot:a,payload:d,pointerX:e?.clientX??null,pointerY:e?.clientY??null}}#H(t,e){if(t==null)return null;let i=this.x,n=this.#X();if(!i||n.length===0)return null;let r=this.#t.find(l=>String(l[i]??"")===String(t));if(!r)return null;let o=n.filter(l=>!this.#v(l)),a=e||(o.length===1?o[0]:null);return o.map((l,h)=>{let c=+(r[l]??0);return{series:l,label:t,value:Number.isFinite(c)?c:null,pct:null,slot:h%10,hovered:l===a}})}#J(t,e){if(this.#y())return;let{tipLabel:i,tipValue:n,tipPct:r,tipSeries:o}=t.dataset;if(!this.#g){let b=document.createElement("div");b.setAttribute("popover","manual"),b.setAttribute("role","tooltip"),b.classList.add("chart-tooltip-popup"),document.body.appendChild(b),this.#g=b}let a=[];if(o&&a.push(`<span data-tip-role="series">${se(o)}</span>`),i&&a.push(`<span data-tip-role="label">${se(i)}</span>`),n!==void 0){let b=r!==void 0?` <span data-tip-role="pct">(${r}%)</span>`:"";a.push(`<span data-tip-role="value">${this.#x(n)}${b}</span>`)}this.#g.innerHTML=a.join("");try{this.#g.showPopover()}catch{}let l=12,h=8,{clientX:c,clientY:u}=e,d=this.#g.offsetWidth||0,f=this.#g.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.#g.style.left=`${p}px`,this.#g.style.top=`${m}px`}#F(){if(this.#g){try{this.#g.hidePopover()}catch{}this.#g.remove(),this.#g=null}}#X(){return this.y?this.y.split(",").map(t=>t.trim()).filter(Boolean):[]}#Y(t,e,i,n,r,o){let a=r,l=o?.fontSize||10,h=o?.labelSize||l,c="",u=i;if(o?.sizeClass==="sm"&&i.length>4&&(u=i.filter((d,f)=>f%2===0||f===i.length-1)),!this.hideGrid){let f=i[i.length-1]-i[0]||1;for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<line data-grid x1="${a.left}" y1="${m}" x2="${t-a.right}" y2="${m}"/>`}for(let p of u){let m=a.top+(e-a.top-a.bottom)*(1-(p-i[0])/f);c+=`<text data-y-label x="${a.left-4}" y="${m+l*.35}" text-anchor="end" font-size="${l}">${this.#x(p)}</text>`}if(n){let m=(t-a.left-a.right)/n.length,g=n.reduce((w,k)=>Math.max(w,String(k).length),1)*h*.6+h*.75,y=Math.max(1,Math.ceil(g/m)),v=n.length-1;for(let w=0;w<n.length;w++){if(w%y!==0&&w!==v||w!==v&&v-w<y)continue;let k=a.left+m*w+m/2;c+=`<text data-x-label x="${k}" y="${e-l*.5}" text-anchor="middle" font-size="${h}">${se(n[w])}</text>`}}}return c}#K(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(v=>+(v[i]??0)),r=e.map(v=>v[this.x]??""),o=us(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/e.length,p=f*.6,m=(f-p)/2,b=this.#Y(l,h,o,r,c,t),g=!this.hideValues&&t.sizeClass!=="sm",y=!this.hideAverage&&n.length>1&&t.sizeClass!=="sm"&&!this.hideGrid;for(let v=0;v<e.length;v++){let w=n[v],k=a?w/a*u:0,E=c.left+f*v+m,A=c.top+u-k;b+=`<path data-bar${St({label:r[v],value:w})} d="${vh(E,A,p,k,this.#o())}"/>`,g&&(b+=`<text data-value x="${E+p/2}" y="${A-4}" text-anchor="middle" font-size="${t.valueSize}">${this.#x(w)}</text>`)}if(y){let v=n.reduce((k,E)=>k+E,0)/n.length,w=c.top+u-(a?v/a*u:0);b+=`<line data-avg x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}"/>`,b+=`<text data-avg-label x="${l-c.right+2}" y="${w+3}" text-anchor="start" font-size="${t.valueSize}">${this.#x(v)}</text>`,b+=`<line data-hit${St({label:"Average",value:v})} x1="${c.left}" y1="${w}" x2="${l-c.right}" y2="${w}" stroke="transparent" stroke-width="12"/>`}return{svg:b,viewBox:`0 0 ${l} ${h}`}}#tt(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(A=>+(A[i]??0)),r=e.map(A=>A[this.x]??""),o=us(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#Y(l,h,o,r,c,t),m=n.map((A,C)=>{let T=c.left+f*C,Q=c.top+u-(a?A/a*u:0);return{x:T,y:Q,v:A,label:r[C]}}),b=c.top+u,g=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area d="${Vd(m,b,g)}"/>`,p+=`<path data-line d="${Pa(m,g)}"/>`;let y=t.sizeClass==="sm",v=y?1.5:3,w=Math.max(v,10),k=!this.hideValues&&!y,E=!this.hideAverage&&n.length>1&&!y&&!this.hideGrid;for(let A of m)p+=`<circle data-dot cx="${A.x}" cy="${A.y}" r="${v}"/>`,p+=`<circle data-hit${St({label:A.label,value:A.v})} cx="${A.x}" cy="${A.y}" r="${w}" fill="transparent"/>`,k&&(p+=`<text data-value x="${A.x}" y="${A.y-8}" text-anchor="middle" font-size="${t.valueSize}">${this.#x(A.v)}</text>`);if(E){let A=n.reduce((T,Q)=>T+Q,0)/n.length,C=c.top+u-(a?A/a*u:0);p+=`<line data-avg x1="${c.left}" y1="${C}" x2="${l-c.right}" y2="${C}"/>`,p+=`<text data-avg-label x="${l-c.right+2}" y="${C+3}" text-anchor="start" font-size="${t.valueSize}">${this.#x(A)}</text>`,p+=`<line data-hit${St({label:"Average",value:A})} x1="${c.left}" y1="${C}" x2="${l-c.right}" y2="${C}" stroke="transparent" stroke-width="12"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#et(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d="",f=-Math.PI/2;for(let p=0;p<i.length;p++){let m=i[p]/n*Math.PI*2;if(m===0)continue;let b=f+m,g=(i[p]/n*100).toFixed(1),y=` data-slice="${p%10}"${St({label:r[p],value:i[p],pct:g})}`;Math.abs(m-Math.PI*2)<.001?d+=`<circle${y} cx="${h}" cy="${c}" r="${u}"/>`:d+=`<path${y} d="${IC(h,c,u,f,b)}"/>`,f=b}return this.#z=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:d,viewBox:`0 0 ${a} ${l}`}}#it(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=i.reduce((g,y)=>g+y,0)||1,r=t.map(g=>g[this.x]??""),o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.42),d=u*.72,f="",p=-Math.PI/2;for(let g=0;g<i.length;g++){let y=i[g]/n*Math.PI*2;if(y===0)continue;let v=p+y,w=(i[g]/n*100).toFixed(1),k=` data-slice="${g%10}"${St({label:r[g],value:i[g],pct:w})}`;Math.abs(y-Math.PI*2)<.001?(f+=`<circle${k} cx="${h}" cy="${c}" r="${(u+d)/2}" fill="none" stroke-width="${u-d}" style="fill:none"/>`,f+=`<path${k} d="M ${h-u} ${c} A ${u} ${u} 0 1 1 ${h+u} ${c} A ${u} ${u} 0 1 1 ${h-u} ${c} Z M ${h-d} ${c} A ${d} ${d} 0 1 0 ${h+d} ${c} A ${d} ${d} 0 1 0 ${h-d} ${c} Z" fill-rule="evenodd"/>`):f+=`<path${k} d="${jd(h,c,u,d,p,v,this.#o())}"/>`,p=v}let m=Math.max(14,Math.round(u*.32)),b=Math.max(9,Math.round(u*.16));return f+=`<text data-donut-total x="${h}" y="${c}" text-anchor="middle" dominant-baseline="central" font-size="${m}">${this.#x(n)}</text>`,f+=`<text data-donut-label x="${h}" y="${c+m}" text-anchor="middle" dominant-baseline="central" font-size="${b}">Total</text>`,this.#z=t.map((g,y)=>({label:r[y],value:i[y],pct:(i[y]/n*100).toFixed(1),slot:y%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#st(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(k=>+(k[e]??0)),n=t.map(k=>k[this.x]??""),r=Math.max(...i)||1,o=t.length,a=this.#u(),{width:l,height:h,fontSize:c}=a,u=l/2,d=h/2,f=c*3.5,p=Math.max(40,Math.min(l,h)/2-f),m="",b=Math.PI*2/o;for(let k=1;k<=3;k++){let E=p*k/3,A="";for(let C=0;C<o;C++){let T=-Math.PI/2+b*C,Q=u+E*Math.cos(T),D=d+E*Math.sin(T);A+=(C===0?"M":"L")+` ${Q} ${D}`}A+=" Z",m+=`<path data-grid d="${A}"/>`}for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=u+p*Math.cos(E),C=d+p*Math.sin(E);m+=`<line data-grid x1="${u}" y1="${d}" x2="${A}" y2="${C}"/>`}let g="",y=[];for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=i[k]/r*p,C=u+A*Math.cos(E),T=d+A*Math.sin(E);g+=(k===0?"M":"L")+` ${C} ${T}`,y.push({px:C,py:T})}g+=" Z",m+=`<path data-radar-fill d="${g}"/>`,m+=`<path data-radar-line d="${g}"/>`;let v=Math.max(c,10);for(let k=0;k<o;k++){let{px:E,py:A}=y[k];m+=`<circle data-hit${St({label:n[k],value:i[k]})} cx="${E}" cy="${A}" r="${v}" fill="transparent"/>`}let w=c*1.3;for(let k=0;k<o;k++){let E=-Math.PI/2+b*k,A=u+(p+w)*Math.cos(E),C=d+(p+w)*Math.sin(E),T=Math.abs(Math.cos(E))<.1?"middle":Math.cos(E)>0?"start":"end";m+=`<text data-x-label x="${A}" y="${C}" text-anchor="${T}" dominant-baseline="central" font-size="${c}">${se(n[k])}</text>`}return{svg:m,viewBox:`0 0 ${l} ${h}`}}#G(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(y=>+(y[e]??0)),n=Math.max(...i)||1,r=Math.min(...i),o=n-r||1,a=this.clientWidth||120,l=this.clientHeight||32,h=Math.max(40,a),c=Math.max(16,l),u=h/Math.max(i.length-1,1),d=Math.max(2,Math.min(6,c*.1)),f=t.map(y=>y[this.x]??""),p=i.map((y,v)=>({x:u*v,y:c-(y-r)/o*(c-d*2)-d,v:y,label:f[v]})),m=Math.max(0,Math.min(1,this.smooth)),b="";b+=`<path data-area d="${Vd(p,c,m)}"/>`,b+=`<path data-line d="${Pa(p,m)}"/>`;let g=Math.max(u/2,6);for(let y of p)b+=`<circle data-hit${St({label:y.label,value:y.v})} cx="${y.x}" cy="${y.y}" r="${g}" fill="transparent"/>`;return{svg:b,viewBox:`0 0 ${h} ${c}`}}#j(){return this.#tt()}#nt(){let t=this.#u(),e=this.#t,i=this.#X()[0]||this.y,n=e.map(g=>+(g[i]??0)),r=e.map(g=>g[this.x]??""),o=us(0,Math.max(...n),5),a=o[o.length-1],{width:l,height:h,pad:c}=t,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(e.length-1,1),p=this.#Y(l,h,o,r,c,t),m=t.sizeClass==="sm"?2.5:4,b=Math.max(m*2,10);for(let g=0;g<n.length;g++){let y=c.left+f*g,v=c.top+u-(a?n[g]/a*u:0);p+=`<circle data-dot data-scatter cx="${y}" cy="${v}" r="${m}"/>`,p+=`<circle data-hit${St({label:r[g],value:n[g]})} cx="${y}" cy="${v}" r="${b}" fill="transparent"/>`}return{svg:p,viewBox:`0 0 ${l} ${h}`}}#rt(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(g=>+(g[e]??0)),n=t.map(g=>g[this.x]??""),r=Math.max(...i)||1,o=this.#u(),{width:a,height:l}=o,h=a/2,c=l/2,u=Math.max(30,Math.min(a,l)*.45),d=u*.3,f=i.length||1,p=(u-d)/f,m=Math.min(2,p*.15),b="";for(let g=0;g<i.length;g++){let y=d+p*g+m/2,v=d+p*(g+1)-m/2,w=(y+v)/2,k=v-y,E=2*Math.PI*w,A=Math.max(0,Math.min(1,i[g]/r))*E;if(b+=`<circle data-radial-track cx="${h}" cy="${c}" r="${w}" fill="none" stroke-width="${k}"/>`,A<=0)continue;let C=(i[g]/r*100).toFixed(1),T=St({label:n[g],value:i[g],pct:C}),Q=Math.abs(A-E)<.5,D=Q?"butt":"round",R=Q?`${E} 0`:`${A} ${E-A}`;b+=`<circle data-slice="${g%10}"${T} data-radial-bar cx="${h}" cy="${c}" r="${w}" fill="none" stroke-width="${k}" stroke-linecap="${D}" stroke-dasharray="${R}" transform="rotate(-90 ${h} ${c})"/>`}return this.#z=t.map((g,y)=>({label:n[y],key:n[y],value:i[y],pct:(i[y]/r*100).toFixed(1),slot:y%10})),{svg:b,viewBox:`0 0 ${a} ${l}`}}#ot(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(w=>+(w[e]??0)),n=i.reduce((w,k)=>w+k,0)||1,r=i[0]??0,o=t[0]?.max!=null?+t[0].max:i.length===1?Math.max(r,1):n,a=Math.max(0,Math.min(1,r/o)),l=this.#u(),{width:h,height:c}=l,u=h/2,d=c*.68,f=Math.max(40,Math.min(h*.45,c*.6)),p=f*.72,m=(f-p)/2,b="";if(b+=`<path data-radial-track d="${jd(u,d,f,p,Math.PI,2*Math.PI,m)}"/>`,a>0){let w=Math.PI+Math.PI*a,k=St({label:t[0]?.[this.x]??"Value",value:r,pct:(a*100).toFixed(1)});b+=`<path data-slice="0"${k} data-gauge-fill d="${jd(u,d,f,p,Math.PI,w,m)}"/>`}let g=Math.max(18,Math.round(f*.42)),y=Math.max(10,Math.round(f*.2)),v=d-f*.15;return b+=`<text data-gauge-value x="${u}" y="${v}" text-anchor="middle" dominant-baseline="central" font-size="${g}">${this.#x(r)}</text>`,o!==r&&(b+=`<text data-gauge-max x="${u}" y="${v+g*.8}" text-anchor="middle" dominant-baseline="central" font-size="${y}">of ${this.#x(o)}</text>`),{svg:b,viewBox:`0 0 ${h} ${c}`}}#at(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(v=>+(v[e]??0)),n=t.map(v=>v[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=Math.max(...i)||1,a=this.#u(),{width:l,height:h}=a,c=a.fontSize,u=Math.max(l*.18,80),d=c*.8,f=l-u*2,m=(h-d*2)/r,b=Math.max(2,m*.08),g=l/2,y="";for(let v=0;v<r;v++){let w=i[v],k=v<r-1?i[v+1]:i[v],E=w/o*(f/2),A=k/o*(f/2),C=d+m*v+b/2,T=d+m*(v+1)-b/2,Q=(w/o*100).toFixed(1),D=St({label:n[v],value:w,pct:Q}),R=`M ${g-E} ${C} L ${g+E} ${C} L ${g+A} ${T} L ${g-A} ${T} Z`;if(y+=`<path data-slice="${v%10}" data-funnel-stage${D} d="${R}"/>`,y+=`<text data-funnel-label x="${u-8}" y="${C+m/2}" text-anchor="end" dominant-baseline="central" font-size="${c}">${se(n[v])}</text>`,y+=`<text data-funnel-value x="${l-u+8}" y="${C+m/2}" text-anchor="start" dominant-baseline="central" font-size="${c}">${this.#x(w)}</text>`,v>0){let _=(i[v]/i[0]*100).toFixed(0);y+=`<text data-funnel-drop x="${l-u+8}" y="${C+m/2+c*1.1}" text-anchor="start" dominant-baseline="central" font-size="${c*.85}">${_}%</text>`}}return this.#z=t.map((v,w)=>({label:n[w],value:i[w],pct:(i[w]/o*100).toFixed(1),slot:w%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#lt(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(Q=>+(Q[e]??0)),n=t.map(Q=>Q[this.x]??""),r=i.length;if(r===0)return{svg:"",viewBox:"0 0 100 100"};let o=this.#u(),{width:a,height:l,fontSize:h}=o,c=i.reduce((Q,D)=>Q+D,0)||1,u=Array.from({length:r},(Q,D)=>D).sort((Q,D)=>i[D]-i[Q]),d=[],f=a*l,p=u.map(Q=>i[Q]/c*f),m=0,b=0,g=a,y=l,v=[],w=0,k=(Q,D)=>{if(Q.length===0)return 1/0;let R=Q.reduce((nt,ut)=>nt+ut,0),_=Math.max(...Q),V=Math.min(...Q),U=D*D,J=R*R;return Math.max(U*_/J,J/(U*V))},E=(Q,D,R,_,V,U)=>{let J=Q.reduce((xt,Ot)=>xt+Ot,0),nt=V>=U,ut=nt?J/V:U,ot=nt?V:J/U,bt=0;for(let xt=0;xt<Q.length;xt++){let Ot=Q[xt]/J,Et=u[D+xt];if(nt){let Tt=Ot*V;d.push({i:Et,x:R+bt,y:_,w:Tt,h:ut}),bt+=Tt}else{let Tt=Ot*U;d.push({i:Et,x:R,y:_+bt,w:ot,h:Tt}),bt+=Tt}}return nt?{x:R,y:_+ut,w:V,h:U-ut}:{x:R+ot,y:_,w:V-ot,h:U}},A=p.slice();for(;A.length>0;){v=[A[0]],w=p.length-A.length;let Q=Math.min(g,y),D=1;for(;D<A.length;){let _=v.concat(A[D]);if(k(_,Q)>k(v,Q))break;v=_,D++}let R=E(v,w,m,b,g,y);m=R.x,b=R.y,g=R.w,y=R.h,A=A.slice(v.length)}let C="",T=2;for(let Q of d){let D=(i[Q.i]/c*100).toFixed(1),R=St({label:n[Q.i],value:i[Q.i],pct:D});C+=`<rect data-slice="${Q.i%10}" data-treemap-tile${R} x="${Q.x+T}" y="${Q.y+T}" width="${Math.max(0,Q.w-T*2)}" height="${Math.max(0,Q.h-T*2)}" rx="${this.#o()}"/>`;let _=Q.x+8,V=Q.w>h*4,U=V&&Q.h>h*2.5,J=V&&!U&&Q.h>h*1.2;if(U)C+=`<text data-treemap-label x="${_}" y="${Q.y+h+4}" font-size="${h}" dominant-baseline="hanging">${se(n[Q.i])}</text>`,C+=`<text data-treemap-value x="${_}" y="${Q.y+h*2+6}" font-size="${h*.9}" dominant-baseline="hanging">${this.#x(i[Q.i])}</text>`;else if(J){let nt=Q.y+Q.h/2;C+=`<text data-treemap-label x="${_}" y="${nt}" font-size="${h}" dominant-baseline="central">${se(n[Q.i])}</text>`}}return this.#z=t.map((Q,D)=>({label:n[D],value:i[D],pct:(i[D]/c*100).toFixed(1),slot:D%10})),{svg:C,viewBox:`0 0 ${a} ${l}`}}#ht(){let t=this.#t;if(!t.length)return{svg:"",viewBox:"0 0 100 100"};let e=new Map,i=new Map;for(let w of t){let k=w.source??w.from??"",E=w.target??w.to??"",A=+(w.value??w.v??0);e.has(k)||e.set(k,{name:k,flow:0}),i.has(E)||i.set(E,{name:E,flow:0}),e.get(k).flow+=A,i.get(E).flow+=A}let n=this.#u(),{width:r,height:o,fontSize:a}=n,l=Math.max(8,r*.03),h=l+a*5,c=[...e.values()].reduce((w,k)=>w+k.flow,0)||1,u=[...i.values()].reduce((w,k)=>w+k.flow,0)||1,d=a*.6,f=[...e.values()],p=[...i.values()],m=o-d*(f.length-1),b=o-d*(p.length-1),g=0;for(let w of f){let k=w.flow/c*m;w.y0=g,w.y1=g+k,w.cursor=g,g+=k+d}g=0;for(let w of p){let k=w.flow/u*b;w.y0=g,w.y1=g+k,w.cursor=g,g+=k+d}let y="",v=Math.min(this.#o(),l/2);f.forEach((w,k)=>{y+=`<rect data-sankey-node data-slice="${k%10}" x="${h-l}" y="${w.y0}" width="${l}" height="${w.y1-w.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${h-l-6}" y="${(w.y0+w.y1)/2}" text-anchor="end" dominant-baseline="central" font-size="${a}">${se(w.name)}</text>`}),p.forEach((w,k)=>{y+=`<rect data-sankey-node data-slice="${(f.length+k)%10}" x="${r-h}" y="${w.y0}" width="${l}" height="${w.y1-w.y0}" rx="${v}"/>`,y+=`<text data-sankey-label x="${r-h+l+6}" y="${(w.y0+w.y1)/2}" text-anchor="start" dominant-baseline="central" font-size="${a}">${se(w.name)}</text>`});for(let w of t){let k=e.get(w.source??w.from??""),E=i.get(w.target??w.to??"");if(!k||!E)continue;let A=+(w.value??w.v??0);if(A<=0)continue;let C=A/c*m,T=A/u*b,Q=k.cursor,D=Q+C,R=E.cursor,_=R+T;k.cursor+=C,E.cursor+=T;let V=h,U=r-h,J=(V+U)/2,nt=St({label:`${k.name} \u2192 ${E.name}`,value:A}),ut=`M ${V} ${Q} C ${J} ${Q}, ${J} ${R}, ${U} ${R} L ${U} ${_} C ${J} ${_}, ${J} ${D}, ${V} ${D} Z`;y+=`<path data-sankey-link${nt} d="${ut}"/>`}return{svg:y,viewBox:`0 0 ${r} ${o}`}}#ct(){let t=this.#u(),e=this.#t,i=this.#X(),n=i[0]||"bar",r=i[1]||"line",o=e.map(E=>E[this.x]??""),a=e.map(E=>+(E[n]??0)),l=e.map(E=>+(E[r]??0)),h=[...a,...l],c=us(0,Math.max(...h),5),u=c[c.length-1],{width:d,height:f,pad:p}=t,m=f-p.top-p.bottom,b=d-p.left-p.right,g=b/e.length,y=g*.6,v=(g-y)/2,w=b/Math.max(e.length-1,1),k=this.#Y(d,f,c,o,p,t);if(!this.#v(n))for(let E=0;E<e.length;E++){let A=a[E],C=u?A/u*m:0,T=p.left+g*E+v,Q=p.top+m-C;k+=`<path${this.#m(0,n)}${St({label:o[E],value:A,series:n})} d="${vh(T,Q,y,C,this.#o())}"/>`}if(!this.#v(r)){let E=l.map((C,T)=>({x:p.left+g*T+g/2,y:p.top+m-(u?C/u*m:0),v:C,label:o[T]})),A=Math.max(0,Math.min(1,this.smooth));k+=`<path data-line${this.#O(1,r)} d="${Pa(E,A)}"/>`;for(let C of E)k+=`<circle data-dot${this.#m(1,r)} cx="${C.x}" cy="${C.y}" r="3"/>`,k+=`<circle data-hit${St({label:C.label,value:C.v,series:r})} cx="${C.x}" cy="${C.y}" r="10" fill="transparent"/>`}return this.#z=[{label:n,key:n,slot:0},{label:r,key:r,slot:1}],{svg:k,viewBox:`0 0 ${d} ${f}`}}#ut(){let t=this.#t,e=this.#X()[0]||this.y,i=t.map(p=>+(p[e]??0)),n=i.reduce((p,m)=>p+m,0)||1,r=t.map(p=>p[this.x]??""),o=getComputedStyle(this),a=Math.max(40,this.clientWidth||200),l=24,h=Math.min(this.#o(),l/2),c=Math.max(0,parseFloat(o.getPropertyValue("--chart-segments-gap"))||2),u=[],d=0;for(let p=0;p<i.length;p++){let m=p===i.length-1?a:Math.round((d*n+i[p]*a)/n),b=p===i.length-1?a:i.slice(0,p+1).reduce((y,v)=>y+v,0)/n*a,g=p===0?0:i.slice(0,p).reduce((y,v)=>y+v,0)/n*a;u.push({x:g,w:Math.max(0,b-g)}),d=m}let f="";for(let p=0;p<u.length;p++){let{x:m,w:b}=u[p];if(b<=0)continue;let g=p===0,y=p===u.length-1,v=Math.max(0,b-(y?0:c)),w=(i[p]/n*100).toFixed(1),k=St({label:r[p],value:i[p],pct:w}),E=`<title>${se(r[p])}: ${i[p]} (${w}%)</title>`;if(g&&y||!g&&!y||h===0)f+=`<rect data-slice="${p%10}"${k} x="${m}" y="0" width="${v}" height="${l}"${(g||y)&&h?` rx="${h}"`:""}>${E}</rect>`;else{let A=h,C=m+v,T;g?T=`M ${m+A} 0 H ${C} V ${l} H ${m+A} A ${A} ${A} 0 0 1 ${m} ${l-A} V ${A} A ${A} ${A} 0 0 1 ${m+A} 0 Z`:T=`M ${m} 0 H ${C-A} A ${A} ${A} 0 0 1 ${C} ${A} V ${l-A} A ${A} ${A} 0 0 1 ${C-A} ${l} H ${m} Z`,f+=`<path data-slice="${p%10}"${k} d="${T}">${E}</path>`}}return this.#z=t.map((p,m)=>({label:r[m],value:i[m],pct:(i[m]/n*100).toFixed(1),slot:m%10})),{svg:f,viewBox:`0 0 ${a} ${l}`}}#dt(){let t=this.#t,e=this.#X(),i=t.map(g=>g[this.x]??""),n=t.map(g=>e.reduce((y,v)=>y+ +(g[v]??0),0)),r=us(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=f*.6,m=(f-p)/2,b=this.#Y(l,h,r,i,c,a);for(let g=0;g<t.length;g++){let y=c.top+u,v=e.length;for(let w=0;w<v;w++){if(this.#v(e[w]))continue;let k=+(t[g][e[w]]??0),E=o?k/o*u:0;if(E<=0){y-=E;continue}y-=E;let A=c.left+f*g+m,C=y,T=E,Q=w===v-1,D=this.#o(),R=`${this.#m(w%10,e[w])}${St({label:i[g],value:k,series:e[w]})}`;Q?b+=`<path${R} d="${vh(A,C,p,T,D)}"/>`:b+=`<rect${R} x="${A}" y="${C}" width="${p}" height="${T}"/>`}}return this.#z=e.map((g,y)=>({label:g,key:g,slot:y%10})),{svg:b,viewBox:`0 0 ${l} ${h}`}}#ft(){let t=this.#t,e=this.#X(),i=t.map(v=>v[this.x]??""),n=t.flatMap(v=>e.map(w=>+(v[w]??0))),r=us(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/t.length,p=3,m=f*.7,b=(m-p*(e.length-1))/e.length,g=(f-m)/2,y=this.#Y(l,h,r,i,c,a);for(let v=0;v<t.length;v++)for(let w=0;w<e.length;w++){if(this.#v(e[w]))continue;let k=+(t[v][e[w]]??0),E=o?k/o*u:0,A=c.left+f*v+g+(b+p)*w,C=c.top+u-E;y+=`<path${this.#m(w%10,e[w])}${St({label:i[v],value:k,series:e[w]})} d="${vh(A,C,b,E,this.#o())}"/>`,this.hideValues||(y+=`<text data-value x="${A+b/2}" y="${C-4}" text-anchor="middle" font-size="${a.valueSize}">${this.#x(k)}</text>`)}return this.#z=e.map((v,w)=>({label:v,key:v,slot:w%10})),{svg:y,viewBox:`0 0 ${l} ${h}`}}#pt(){let t=this.#t,e=this.#X(),i=t.map(m=>m[this.x]??""),n=t.flatMap(m=>e.map(b=>+(m[b]??0))),r=us(0,Math.max(...n),5),o=r[r.length-1],a=this.#u(),{width:l,height:h,pad:c}=a,u=h-c.top-c.bottom,f=(l-c.left-c.right)/Math.max(t.length-1,1),p=this.#Y(l,h,r,i,c,a);for(let m=0;m<e.length;m++){if(this.#v(e[m]))continue;let g=t.map(w=>+(w[e[m]]??0)).map((w,k)=>{let E=c.left+f*k,A=c.top+u-(o?w/o*u:0);return{x:E,y:A,v:w,label:i[k]}}),y=c.top+u,v=Math.max(0,Math.min(1,this.smooth));p+=`<path data-area${this.#m(m%10,e[m])} d="${Vd(g,y,v)}"/>`,p+=`<path data-line${this.#O(m%10,e[m])} d="${Pa(g,v)}"/>`;for(let w of g)p+=`<circle data-dot${this.#m(m%10,e[m])} cx="${w.x}" cy="${w.y}" r="3"/>`,p+=`<circle data-hit${St({label:w.label,value:w.v,series:e[m]})} cx="${w.x}" cy="${w.y}" r="10" fill="transparent"/>`}return this.#z=e.map((m,b)=>({label:m,key:m,slot:b%10})),{svg:p,viewBox:`0 0 ${l} ${h}`}}#z=null;get legendData(){return this.#z?this.#z.map(t=>({...t})):null}#mt(){if(!this.#z||!this.#z.length)return null;let t=document.createElement("div");t.setAttribute("data-legend","");for(let e of this.#z){let i=document.createElement("span");i.setAttribute("data-legend-item",""),e.key&&i.setAttribute("data-series-key",e.key);let n=document.createElement("span");n.setAttribute("data-legend-dot",""),n.setAttribute("data-slice",String(e.slot)),e.key&&(n.style.background=`var(--color-${e.key}, var(--chart-${e.slot}))`),i.appendChild(n);let r=document.createElement("span");r.textContent=e.pct?`${e.label} (${e.pct}%)`:e.label,i.appendChild(r),t.appendChild(i)}return t}};S("chart-ui",dr);P();var fr=class s extends x{static properties={for:{type:String,default:"",reflect:!0},items:{type:String,default:"",reflect:!1},shape:{type:String,default:"dot",reflect:!0},position:{type:String,default:"bottom",reflect:!0},static:{type:Boolean,default:!1,reflect:!0},onToggle:{type:String,default:"hide",reflect:!0,attribute:"on-toggle"}};static template=()=>null;#t=null;#e=null;#i=new Set;connected(){this.setAttribute("role","list"),this.#s(),this.#a()}disconnected(){this.#n()}render(){this.#s(),this.#a()}#s(){if(this.#n(),!this.for)return;let t=this.getRootNode()?.getElementById?.(this.for)||document.getElementById(this.for);if(!t){s._warned||(s._warned=new WeakSet);let e={el:this,id:this.for};s._warned.has(this)||(console.warn(`[chart-legend-ui] [for="${this.for}"] did not resolve to an element.`),s._warned.add(this));return}this.#t=t,this.#e=()=>this.#a(),t.addEventListener("legend-update",this.#e)}#n(){this.#t&&this.#e&&this.#t.removeEventListener("legend-update",this.#e),this.#t=null,this.#e=null}#r(){if(this.items)try{let t=JSON.parse(this.items);if(Array.isArray(t))return t}catch{}return this.#t&&Array.isArray(this.#t.legendData)?this.#t.legendData:[]}#a(){let t=this.#r();if(this.innerHTML="",!!t.length)for(let e of t){let i=e.key??e.label??"",n=e.label??i,r=e.slot!=null?e.slot:0,o=!this.#i.has(i),a=document.createElement("badge-ui");a.setAttribute("data-row",""),a.setAttribute("role",this.static?"listitem":"button"),a.setAttribute("text",n),i&&a.setAttribute("data-key",i),o&&a.setAttribute("data-active",""),this.static||(a.setAttribute("tabindex","0"),a.setAttribute("aria-pressed",o?"true":"false"));let l=this.shape||"dot",h=document.createElement("swatch-ui");h.setAttribute("shape",l),h.setAttribute("size","sm");let c=i?`var(--color-${i}, var(--a-data-${r}))`:`var(--a-data-${r})`;h.style.setProperty("--swatch-color",c),a.appendChild(h),this.static||(a.addEventListener("click",u=>this.#o(u,i)),a.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.#o(u,i))})),this.appendChild(a)}}#o(t,e){if(!e)return;let n=!!this.#i.has(e);n?this.#i.delete(e):this.#i.add(e);let r=t.currentTarget;n?r.setAttribute("data-active",""):r.removeAttribute("data-active"),r.setAttribute("aria-pressed",n?"true":"false"),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{key:e,active:n,mode:this.onToggle||"hide"}}))}};S("chart-legend-ui",fr);P();var DC=120,pr=class extends x{static properties={placement:{type:String,default:"bottom",reflect:!0},gap:{type:Number,default:4,reflect:!0},open:{type:Boolean,default:!1,reflect:!0},trigger:{type:String,default:"click",reflect:!0}};static template=()=>null;#t=null;#e=!1;#i=null;#s=null;#n=null;connected(){let t=this.querySelector('[slot="content"]');t&&(t.hasAttribute("popover")||t.setAttribute("popover","manual"),t.addEventListener("toggle",this.#d),this.#s=t),this.#e||(this.#e=!0,this.trigger==="click"&&this.addEventListener("click",this.#o),this.trigger==="hover"&&(this.addEventListener("pointerenter",this.#h),this.addEventListener("pointerleave",this.#u),t&&(t.addEventListener("pointerenter",this.#h),t.addEventListener("pointerleave",this.#u))))}render(){this.open?this.#r():this.#a()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){let t=this.querySelector('[slot="trigger"]'),e=this.#s??this.querySelector('[slot="content"]');if(!(!t||!e)){if(!e.matches(":popover-open"))try{e.showPopover()}catch{}this.#t?.(),this.#t=ct(t,e,{placement:this.placement,gap:this.gap}),(this.trigger==="click"||this.trigger==="manual")&&(this.#n=requestAnimationFrame(()=>{this.#n=null,document.addEventListener("pointerdown",this.#l),document.addEventListener("keydown",this.#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.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#l),document.removeEventListener("keydown",this.#c)}#o=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.open=!this.open)};#l=t=>{if(!this.open)return;let e=this.#s;this.contains(t.target)||e?.contains(t.target)||(this.open=!1)};#c=t=>{t.key==="Escape"&&this.open&&(t.stopPropagation(),this.open=!1)};#h=()=>{clearTimeout(this.#i),this.open=!0};#u=()=>{clearTimeout(this.#i),this.#i=setTimeout(()=>{this.open=!1},DC)};#d=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){clearTimeout(this.#i),this.#a(),this.trigger==="click"&&this.removeEventListener("click",this.#o),this.trigger==="hover"&&(this.removeEventListener("pointerenter",this.#h),this.removeEventListener("pointerleave",this.#u),this.#s&&(this.#s.removeEventListener("pointerenter",this.#h),this.#s.removeEventListener("pointerleave",this.#u))),this.#s?.removeEventListener("toggle",this.#d),this.#s=null,this.#e=!1}};S("popover-ui",pr);P();var mr=class extends x{static requiredIcons=["caret-down"];static properties={multiple:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.addEventListener("toggle",this.#t)}disconnected(){this.removeEventListener("toggle",this.#t)}#t=t=>{if(this.multiple)return;let e=t.target;if(!e.open)return;let i=this.querySelectorAll("accordion-item-ui");for(let n of i)n!==e&&n.open&&(n.open=!1)}},gr=class extends x{static properties={text:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=!1;connected(){if(!this.querySelector('[slot="header"]')){let t=document.createElement("div");t.setAttribute("slot","header");let e=document.createElement("span");e.setAttribute("slot","header-text"),t.appendChild(e);let i=document.createElement("icon-ui");i.setAttribute("name","caret-down"),i.setAttribute("slot","caret"),t.appendChild(i),this.prepend(t)}if(!this.querySelector('[slot="body"]')){let t=document.createElement("div");t.setAttribute("slot","body");let e=[...this.childNodes].filter(i=>i.nodeType===1?!i.hasAttribute("slot"):i.nodeType===3&&i.textContent.trim());for(let i of e)t.appendChild(i);this.appendChild(t)}this.#t||(this.#t=!0,this.addEventListener("click",this.#e))}disconnected(){this.removeEventListener("click",this.#e),this.#t=!1}render(){let t=this.querySelector('[slot="header-text"]');t&&(t.textContent=this.text)}#e=t=>{let e=this.querySelector('[slot="header"]');!e||!e.contains(t.target)||t.target.closest('[slot="action"], [slot="actions"], [data-no-toggle]')||(this.open=!this.open,this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,detail:{open:this.open}})))}};S("accordion-ui",mr),S("accordion-item-ui",gr);P();var br=class extends x{static properties={label:{type:String,default:"",reflect:!0},vertical:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","separator")}render(){if(this.vertical?this.setAttribute("aria-orientation","vertical"):this.removeAttribute("aria-orientation"),this.label){let t=this.querySelector('[slot="label"]');t||(t=document.createElement("span"),t.setAttribute("slot","label"),this.appendChild(t)),t.textContent=this.label}else{let t=this.querySelector('[slot="label"]');t&&t.remove()}}};S("divider-ui",br);P();var Or=class extends x{static properties={cite:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.hasAttribute("role")||this.setAttribute("role","blockquote")}render(){let t=this.querySelector('[slot="cite"]:not([data-cite-stamped])'),e=this.querySelector('[slot="cite"][data-cite-stamped]');if(t){e?.remove();return}if(this.cite)if(e)e.textContent=this.cite;else{let i=document.createElement("span");i.setAttribute("slot","cite"),i.setAttribute("data-cite-stamped",""),i.textContent=this.cite,this.appendChild(i)}else e&&e.remove()}};S("blockquote-ui",Or);P();var Wd=[{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}],yr=class extends x{static properties={datetime:{type:String,default:"",reflect:!0},timeStyle:{type:String,default:"long",reflect:!0,attribute:"time-style"},numeric:{type:String,default:"auto",reflect:!0},locale:{type:String,default:"",reflect:!0},updateInterval:{type:Number,default:60,reflect:!0,attribute:"update-interval"}};static template=()=>null;#t=null;#e(){return this.locale?this.locale:this.ownerDocument?.documentElement?.lang||void 0}#i(){if(!this.datetime)return"";let t=new Date(this.datetime);if(Number.isNaN(t.getTime()))return"";let e=(t.getTime()-Date.now())/1e3,i=Math.abs(e),n=Wd.find(o=>i<=o.limit)||Wd[Wd.length-1],r=Math.round(e/n.divisor);try{return new Intl.RelativeTimeFormat(this.#e(),{style:this.timeStyle,numeric:this.numeric}).format(r,n.unit)}catch{let o=e<0,a=Math.abs(r);return o?`${a} ${n.unit}${a===1?"":"s"} ago`:`in ${a} ${n.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.#n()}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.#n()}#n(){this.#r();let t=Number(this.updateInterval);!Number.isFinite(t)||t<=0||(this.#t=setInterval(()=>{this.textContent=this.#i()},t*1e3))}#r(){this.#t!=null&&(clearInterval(this.#t),this.#t=null)}disconnected(){super.disconnected(),this.#r()}};S("relative-time-ui",yr);P();var vr=class extends x{static properties={value:{type:Number,default:0,reflect:!0},numberStyle:{type:String,default:"decimal",reflect:!0,attribute:"number-style"},currency:{type:String,default:"",reflect:!0},unit:{type:String,default:"",reflect:!0},notation:{type:String,default:"standard",reflect:!0},compactDisplay:{type:String,default:"short",reflect:!0,attribute:"compact-display"},minimumFractionDigits:{type:Number,default:0,reflect:!0,attribute:"minimum-fraction-digits"},maximumFractionDigits:{type:Number,default:2,reflect:!0,attribute:"maximum-fraction-digits"},locale:{type:String,default:"",reflect:!0},signDisplay:{type:String,default:"auto",reflect:!0,attribute:"sign-display"}};static template=()=>null;#t(){return this.locale?this.locale:this.ownerDocument?.documentElement?.lang||void 0}#e(){let t=Number(this.value);if(!Number.isFinite(t)||this.numberStyle==="currency"&&!this.currency||this.numberStyle==="unit"&&!this.unit)return"";let e={style:this.numberStyle,notation:this.notation,signDisplay:this.signDisplay};this.numberStyle==="currency"&&(e.currency=this.currency),this.numberStyle==="unit"&&(e.unit=this.unit),this.notation==="compact"&&(e.compactDisplay=this.compactDisplay),Number.isFinite(this.minimumFractionDigits)&&(e.minimumFractionDigits=this.minimumFractionDigits),Number.isFinite(this.maximumFractionDigits)&&(e.maximumFractionDigits=this.maximumFractionDigits);try{return new Intl.NumberFormat(this.#t(),e).format(t)}catch{return String(t)}}connected(){super.connected()}render(){let t=this.#e();this.textContent=t,t&&Number.isFinite(Number(this.value))?this.setAttribute("aria-label",`${t} (raw: ${this.value})`):this.removeAttribute("aria-label")}};S("number-format-ui",vr);P();var Ud=["Weak","Fair","Good","Strong"];function qC(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 xr=class extends x{static properties={value:{type:String,default:""},minScore:{type:Number,default:2,reflect:!0,attribute:"min-score"},showLabel:{type:Boolean,default:!0,reflect:!0,attribute:"show-label"}};static template=()=>null;#t=-2;connected(){super.connected(),this.querySelector('[slot="bar"]')||(this.innerHTML=`
|
|
191
191
|
<div slot="bar" aria-hidden="true">
|
|
192
192
|
<div slot="segment" data-i="0"></div>
|
|
193
193
|
<div slot="segment" data-i="1"></div>
|
|
@@ -201,7 +201,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
201
201
|
</svg>`}P();var wr=class extends x{static properties={value:{type:String,default:"",reflect:!0},matrix:{type:String,default:"",reflect:!0},size:{type:Number,default:200,reflect:!0},errorCorrection:{type:String,default:"M",reflect:!0,attribute:"error-correction"},margin:{type:Number,default:4,reflect:!0},color:{type:String,default:"",reflect:!0},background:{type:String,default:"",reflect:!0},label:{type:String,default:"QR code",reflect:!0}};static template=()=>null;#t="";#e(t){if(!t)return null;try{let e=JSON.parse(t);return!Array.isArray(e)||e.length===0||!Array.isArray(e[0])?null:e.map(i=>i.map(n=>n?1:0))}catch(e){return console.warn("[qr-code-ui] invalid [matrix] JSON:",e.message),null}}#i(){let t=this.#e(this.matrix);if(t)return this.removeAttribute("data-error"),t;if(!this.value)return this.removeAttribute("data-error"),null;try{let e=gy(this.value,{errorCorrection:this.errorCorrection||"M"});return this.removeAttribute("data-error"),e.matrix}catch(e){return this.setAttribute("data-error",""),console.warn(`[qr-code-ui] encode failed for value (${this.value?.length||0} chars at ECC=${this.errorCorrection}): ${e.message}. Lower ECC, shorten input, or supply a precomputed [matrix].`),null}}connected(){super.connected(),this.setAttribute("role","img"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.label||"QR code")}render(){let t=`${this.value}|${this.matrix}|${this.size}|${this.errorCorrection}|${this.margin}|${this.color}|${this.background}`;if(t===this.#t&&this.querySelector("svg"))return;this.#t=t,this.label&&this.setAttribute("aria-label",this.label);let e=this.#i();if(!e){this.innerHTML="";return}let i=by(e,{cellSize:8,margin:Number.isFinite(this.margin)?this.margin:4,color:this.color||"#000000",background:this.background||"#ffffff"});this.innerHTML=i;let n=this.querySelector("svg");n&&Number.isFinite(this.size)&&(n.setAttribute("width",String(this.size)),n.setAttribute("height",String(this.size)))}};S("qr-code-ui",wr);P();var kr=class extends x{static properties={page:{type:Number,default:1,reflect:!0},total:{type:Number,default:1,reflect:!0},siblings:{type:Number,default:1,reflect:!0},variant:{type:String,default:"default",reflect:!0},size:{type:String,default:"md",reflect:!0}};static requiredIcons=["caret-left","caret-right"];static template=()=>null;#t=null;#e=!1;connected(){this.#t||(this.#t=document.createElement("nav"),this.#t.setAttribute("slot","nav"),this.#t.setAttribute("aria-label","Pagination"),this.appendChild(this.#t)),this.#e||(this.#e=!0,this.#t.addEventListener("press",this.#a))}disconnected(){this.#t?.removeEventListener("press",this.#a),this.#t=null,this.#e=!1}render(){if(!this.#t)return;let t=Math.max(1,Math.min(this.page,this.total)),e=Math.max(1,this.total),i=Math.max(0,this.siblings),n=this.#i(t,e,i);this.reconcile(this.#t,n,r=>r.key,(r,o,a)=>a?(this.#r(a,r,t),a):this.#n(r,t))}#i(t,e,i){let n=[];n.push({key:"prev",type:"prev",value:t-1});let r=2*i+5;if(e<=r)for(let o=1;o<=e;o++)n.push({key:`page-${o}`,type:"page",value:o});else{let o=t<=i+3,a=t>=e-i-2;if(o){let l=r-2;for(let h=1;h<=l;h++)n.push({key:`page-${h}`,type:"page",value:h});n.push({key:"ellipsis-end",type:"ellipsis"}),n.push({key:`page-${e}`,type:"page",value:e})}else if(a){n.push({key:"page-1",type:"page",value:1}),n.push({key:"ellipsis-start",type:"ellipsis"});let l=e-r+3;for(let h=l;h<=e;h++)n.push({key:`page-${h}`,type:"page",value:h})}else{n.push({key:"page-1",type:"page",value:1}),n.push({key:"ellipsis-start",type:"ellipsis"});for(let l=t-i;l<=t+i;l++)n.push({key:`page-${l}`,type:"page",value:l});n.push({key:"ellipsis-end",type:"ellipsis"}),n.push({key:`page-${e}`,type:"page",value:e})}}return n.push({key:"next",type:"next",value:t+1}),n}#s(){return this.variant==="button"?"outline":"ghost"}#n(t,e){if(t.type==="ellipsis"){let n=document.createElement("span");return n.setAttribute("data-ellipsis",""),n.textContent="\u2026",n}let i=document.createElement("button-ui");return i.setAttribute("size",this.size),t.type==="prev"?(i.setAttribute("data-prev",""),i.setAttribute("icon","caret-left"),i.setAttribute("aria-label","Previous page")):t.type==="next"?(i.setAttribute("data-next",""),i.setAttribute("icon","caret-right"),i.setAttribute("aria-label","Next page")):(i.setAttribute("data-page",""),i.dataset.value=String(t.value),i.setAttribute("text",String(t.value)),i.setAttribute("aria-label",`Page ${t.value}`)),this.#r(i,t,e),i}#r(t,e,i){e.type!=="ellipsis"&&(t.setAttribute("size",this.size),e.type==="prev"?(t.setAttribute("variant",this.#s()),i<=1?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0"))):e.type==="next"?(t.setAttribute("variant",this.#s()),i>=this.total?(t.setAttribute("disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("disabled"),t.setAttribute("tabindex","0"))):(t.dataset.value=String(e.value),t.setAttribute("text",String(e.value)),t.setAttribute("aria-label",`Page ${e.value}`),e.value===i?(t.setAttribute("variant","primary"),t.setAttribute("data-active",""),t.setAttribute("aria-current","page")):(t.setAttribute("variant",this.#s()),t.removeAttribute("data-active"),t.removeAttribute("aria-current"))))}#a=t=>{let e=t.target.closest("[data-prev], [data-next], [data-page]");if(!e||e.hasAttribute("disabled")||!this.#t.contains(e))return;let i;e.hasAttribute("data-prev")?i=this.page-1:e.hasAttribute("data-next")?i=this.page+1:e.hasAttribute("data-page")&&(i=Number(e.dataset.value)),!(i==null||i<1||i>this.total||i===this.page)&&(this.page=i,this.dispatchEvent(new CustomEvent("page-change",{bubbles:!0,detail:{page:this.page}})))}};S("pagination-ui",kr);P();var zI=new Set(["json","html","javascript","js","css","markdown","md","yaml","yml"]),_I={js:"javascript",md:"markdown",yml:"yaml"};function Db(s){if(!s)return"";let t=String(s).toLowerCase();return _I[t]??t}var ao=class s extends x{static formAssociated=!0;static properties={language:{type:String,default:"",reflect:!0},inline:{type:Boolean,default:!1,reflect:!0},text:{type:String,default:"",reflect:!0},lineNumbers:{type:Boolean,default:!1,reflect:!0,attribute:"line-numbers"},editable:{type:Boolean,default:!1,reflect:!0},bare:{type:Boolean,default:!1,reflect:!0},placeholder:{type:String,default:"",reflect:!0},name:{type:String,default:"",reflect:!0},required:{type:Boolean,default:!1,reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=0;#n=!1;#r=null;#a="";#o=null;#l=()=>this.#b();connected(){this.#s+=1,!this.inline&&!this.querySelector(":scope > pre")&&this.#c(),this.#t=this.querySelector(':scope > header [slot="copy"]'),this.#t&&this.#t.addEventListener("click",this.#l);let t=Db(this.language),e=this.hasAttribute("data-line-states")||t==="diff";!this.inline&&!e&&(zI.has(t)||this.editable)&&this.#u()}disconnected(){this.#s+=1,this.#e!=null&&(clearTimeout(this.#e),this.#e=null),this.#t&&(this.#t.removeEventListener("click",this.#l),this.#t=null),this.#i&&(this.#i.destroy(),this.#i=null)}#c(){let t=this.querySelector(":scope > template"),e=this.text?this.text.trim():t?s.#h(t.innerHTML):(this.textContent||"").trim();if(this.textContent="",!this.bare){let l=document.createElement("header"),h=document.createElement("span");h.setAttribute("slot","label"),h.textContent=this.language||"code",l.appendChild(h);let c=document.createElement("div");c.setAttribute("role","button"),c.setAttribute("tabindex","0"),c.setAttribute("slot","copy"),c.textContent="Copy",l.appendChild(c),this.appendChild(l)}let i=document.createElement("pre"),n=document.createElement("code"),r=Db(this.language),o=this.getAttribute("data-line-states");if(o!=null||r==="diff"){n.setAttribute("data-line-state-mode",""),this.lineNumbers&&n.setAttribute("data-line-numbers","");let l=o?.split(",").map(c=>c.trim())??null;e.split(`
|
|
202
202
|
`).forEach((c,u)=>{let d="unchanged";if(l&&l[u])d=l[u];else if(r==="diff"){let m=c.charAt(0);m==="+"?d="added":m==="-"&&(d="removed")}let f=document.createElement("span");if(f.setAttribute("data-line-state",d),this.lineNumbers){let m=document.createElement("span");m.setAttribute("data-line-num",""),m.textContent=String(u+1),f.appendChild(m)}let p=document.createElement("span");p.setAttribute("data-line-body",""),p.textContent=c,f.appendChild(p),n.appendChild(f)})}else n.textContent=e;i.appendChild(n),this.appendChild(i)}static#h(t){let e=t.replace(/^\n+|\n+$/g,"");if(!e)return"";let i=e.split(`
|
|
203
203
|
`),n=i.filter(o=>o.trim().length>0).map(o=>o.match(/^[ \t]*/)[0].length),r=n.length?Math.min(...n):0;return r>0?i.map(o=>o.slice(r)).join(`
|
|
204
|
-
`):e}async#u(){if(this.#n||this.#i)return;let t=this.#s,e=Db(this.language);this.#n=!0;try{let i=await Promise.resolve().then(()=>(Ib(),Rb)),n=null;try{n=(await i.importWithTimeout(i.languages[e],`lang-${e}`))?.extension??null}catch(r){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"language",language:e,error:r}}))}if(t!==this.#s||!this.isConnected)return;this.#d(i,n,e)}catch(i){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"core",error:i}})),console.warn("[code-ui] CodeMirror failed to load; staying on static fallback.",i)}finally{this.#n=!1}}#d(t,e,i){let{EditorState:n,EditorView:r,Compartment:o,lineNumbers:a,placeholder:l,syntaxHighlighting:h,history:c,historyKeymap:u,defaultKeymap:d,indentWithTab:f,keymap:p,adiaBaseTheme:m,adiaHighlightStyle:b,lintGutter:g,jsonLinter:y}=t,v=this.querySelector(":scope > pre"),w=v?v.querySelector("code")?.textContent??"":"",k=this.text||w||"";this.#a=k;let E=document.createElement("div");E.setAttribute("data-cm-mount",""),v?v.replaceWith(E):this.appendChild(E);let A=[m,h(b)];this.editable&&A.push(c(),p.of([{key:"Mod-s",run:C=>(this.#g(C),!0)},...d,...u,f]),r.updateListener.of(C=>{if(!C.docChanged)return;let T=C.state.doc.toString();this.#m(T),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:T}}))}),r.domEventHandlers({focus:(C,T)=>(this.#r=T.state.doc.toString(),!1),blur:(C,T)=>{let Q=T.state.doc.toString();return this.#r!==null&&Q!==this.#r&&this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:Q}})),this.#r=null,!1}})),this.#o=new o,A.push(this.#o.of(this.#p(r,n))),e&&A.push(e),this.lineNumbers&&A.push(a()),this.placeholder&&A.push(l(this.placeholder)),this.editable&&i==="json"&&A.push(y,g()),this.#i=new r({parent:E,state:n.create({doc:k,extensions:A})}),this.editable&&this.#m(k)}#p(t,e){return this.editable&&!this.disabled&&!this.readonly?[]:[t.editable.of(!1),e.readOnly.of(!0)]}async#f(){if(!this.#i||!this.#o)return;let t=await Promise.resolve().then(()=>(Ib(),Rb));this.#i.dispatch({effects:this.#o.reconfigure(this.#p(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.#O(t))}#O(t){return t=t??"",this.required&&!t.trim()?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),this.setAttribute("aria-invalid","true"),!1):(this.internals.setValidity({}),this.removeAttribute("aria-invalid"),!0)}formResetCallback(){this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:this.#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)}#g(t){this.dispatchEvent(new CustomEvent("save",{bubbles:!0,cancelable:!0,detail:{value:t.state.doc.toString()}}))}get value(){return this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??this.text??""}set value(t){this.text=String(t??"")}#b(){let t=this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??"";t&&navigator.clipboard.writeText(t).then(()=>{let e=this.querySelector(':scope > header [slot="copy"]');if(!e)return;let i=e.textContent;e.textContent="Copied!",this.#e!=null&&clearTimeout(this.#e),this.#e=setTimeout(()=>{this.#e=null,e.textContent=i},1500)})}render(){let t=this.querySelector(':scope > header [slot="label"]');if(t&&this.language&&(t.textContent=this.language),this.#f(),!this.inline&&this.text!=="")if(this.#i){if(this.editable&&this.#i.hasFocus)return;let e=this.#i.state.doc.toString();e!==this.text&&this.#i.dispatch({changes:{from:0,to:e.length,insert:this.text}})}else{let e=this.querySelector(":scope > pre > code");e&&e.textContent!==this.text&&(e.textContent=this.text)}}};S("code-ui",ao);P();var lo=class extends x{static properties={divider:{type:Boolean,default:!1,reflect:!0},spacing:{type:String,default:"md",reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},selectedKey:{type:String,default:"",reflect:!0,attribute:"selected-key"}};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#r))}disconnected(){this.removeEventListener("click",this.#n),this.removeEventListener("keydown",this.#r),this.#t=!1}render(){if(!this.selectable){for(let n of this.#e())n.removeAttribute("aria-selected"),n.removeAttribute("tabindex");return}let t=this.selectedKey||"",e=this.#e(),i=null;for(let n of e){let r=this.#i(n),o=r&&r===t;n.setAttribute("aria-selected",o?"true":"false"),n.setAttribute("tabindex",o?"0":"-1"),o&&(i=n)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#e(){return[...this.children].filter(t=>t.getAttribute&&t.getAttribute("role")==="listitem")}#i(t){return t.id||t.getAttribute("data-key")||""}#s(t,{focus:e=!1}={}){if(!this.selectable||!t)return;let i=this.selectedKey||"";t!==i&&(this.selectedKey=t,this.dispatchEvent(new CustomEvent("selection-change",{detail:{key:t,previousKey:i},bubbles:!0})),e&&[...this.#e()].find(r=>this.#i(r)===t)?.focus?.())}#n=t=>{if(!this.selectable)return;let e=t.target.closest?.('[role="listitem"]');if(!e||e.parentElement!==this)return;let i=this.#i(e);i&&this.#s(i)};#r=t=>{if(!this.selectable)return;let e=this.#e();if(!e.length)return;let i=document.activeElement,n=e.indexOf(i);if(n<0)return;let r=n;switch(t.key){case"ArrowDown":r=Math.min(e.length-1,n+1);break;case"ArrowUp":r=Math.max(0,n-1);break;case"Home":r=0;break;case"End":r=e.length-1;break;case"Enter":case" ":{t.preventDefault();let o=this.#i(e[n]);o&&this.#s(o);return}default:return}r!==n&&(t.preventDefault(),e[r]?.focus?.())}},ho=class extends x{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","listitem"),this.#s()}#t(t){for(let e of this.children)if(e.matches(t))return e;return null}#e(t){return t.dataset.listStamped="1",t}#i(t){return t?.dataset?.listStamped==="1"}#s(){if(!this.#t('[slot="content"]')){if(this.icon){let t=this.#t('[slot="icon"]')||this.#t("icon-ui");t||(t=this.#e(document.createElement("icon-ui")),t.setAttribute("slot","icon"),this.prepend(t)),t.setAttribute("name",this.icon)}if(this.text){let t=this.#t('[slot="text"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","text"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.text)}if(this.description){let t=this.#t('[slot="description"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","description"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.description)}}}render(){let t=this.#t('[slot="icon"]');if(this.icon)if(t)this.#i(t)&&t.setAttribute("name",this.icon);else{let n=this.#e(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#i(t)&&t.remove();let e=this.#t('[slot="text"]');if(this.text)if(e)this.#i(e)&&(e.textContent=this.text);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","text"),n.textContent=this.text,this.appendChild(n)}else this.#i(e)&&e.remove();let i=this.#t('[slot="description"]');if(this.description)if(i)this.#i(i)&&(i.textContent=this.description);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","description"),n.textContent=this.description,this.appendChild(n)}else this.#i(i)&&i.remove()}};S("list-ui",lo),S("list-item-ui",ho);P();var co=class extends x{static properties={items:{type:Array,default:[],reflect:!1},itemSize:{type:Number,default:0,reflect:!0,attribute:"item-size"},itemSizeRem:{type:Number,default:0,reflect:!0,attribute:"item-size-rem"},estimatedSize:{type:Number,default:48,reflect:!0,attribute:"estimated-size"},overscan:{type:Number,default:3,reflect:!0},direction:{type:String,default:"vertical",reflect:!0},pinBottom:{type:Boolean,default:!1,reflect:!0,attribute:"pin-bottom"},startIndex:{type:Number,default:0,reflect:!1,attribute:"start-index"},loading:{type:Boolean,default:!1,reflect:!0}};static parts={phantom:"<div data-phantom></div>",window:"<div data-window></div>",sentinelTop:'<div data-sentinel="top"></div>',sentinelBottom:'<div data-sentinel="bottom"></div>'};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=(t,e)=>t&&typeof t=="object"&&"id"in t?t.id:e;#a=new Map;#o=new Map;#l=1e5;#c=-1;#h=-1;#u=0;#d=!0;#p=null;#f=null;#m=()=>{this.#T();let t=this.#A();this.#u=t,this.#d=this.#C()};#O=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 n=this.items?.[i];n!=null&&this.dispatchEvent(new CustomEvent("item-click",{detail:{item:n,index:i},bubbles:!0}))};#g=t=>{if(t.target!==this)return;let e=this.#w()||this.estimatedSize||48,i=this.#x(),n=0;switch(t.key){case"ArrowDown":n=+e;break;case"ArrowUp":n=-e;break;case"PageDown":n=+i;break;case"PageUp":n=-i;break;case" ":n=+i;break;case"Home":t.preventDefault(),this.scrollToTop();return;case"End":t.preventDefault(),this.scrollToBottom();return;default:return}t.preventDefault();let r=this.#A();this.#E(r+n)};#b=t=>{for(let e of t){if(!e.isIntersecting)continue;let i=e.target?.dataset?.sentinel;if(i==="top"){let n=this.#c>=0?this.#c:0;this.dispatchEvent(new CustomEvent("scroll-start",{detail:{index:n},bubbles:!0}))}else if(i==="bottom"){let n=this.items||[],r=this.#h>=0?this.#h:n.length-1;this.dispatchEvent(new CustomEvent("scroll-end",{detail:{index:r},bubbles:!0}))}}};#y=t=>{if(this.itemSize>0)return;let e=!1;for(let i of t){let n=i.target;if(!n||n.parentElement!==this.#e)continue;let r=Number(n.dataset.index);if(!Number.isInteger(r))continue;let o=this.direction==="horizontal"?i.contentRect.width:i.contentRect.height,a=Math.max(1,Math.round(o));this.#o.get(r)!==a&&(this.#o.set(r,a),this.dispatchEvent(new CustomEvent("measure",{detail:{index:r,height:a},bubbles:!0})),e=!0)}e&&(this.#D(),this.#P(),this.#T())};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.#f=new IntersectionObserver(this.#b,{root:this,rootMargin:"0px",threshold:0}),this.#f.observe(this.#i),this.#f.observe(this.#s)),typeof ResizeObserver<"u"&&(this.#p=new ResizeObserver(this.#y)),this.addEventListener("scroll",this.#m,{passive:!0}),this.addEventListener("click",this.#O),this.addEventListener("keydown",this.#g),this.startIndex>0&&queueMicrotask(()=>this.scrollToIndex(this.startIndex))}disconnected(){this.removeEventListener("scroll",this.#m),this.removeEventListener("click",this.#O),this.removeEventListener("keydown",this.#g),this.#f?.disconnect(),this.#f=null,this.#p?.disconnect(),this.#p=null,this.#a.clear()}render(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=this.pinBottom&&(this.#d||this.#C());t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.setAttribute("aria-rowcount",String(t.length)),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy"),this.#P(),this.#T(),e&&this.scrollToBottom(),this.#d=this.#C()}set renderRow(t){this.#n=typeof t=="function"?t:null,this.#a.clear(),this.#T()}get renderRow(){return this.#n}set keyFn(t){this.#r=typeof t=="function"?t:((e,i)=>i),this.#a.clear(),this.#T()}get keyFn(){return this.#r}scrollToIndex(t,{behavior:e="auto",align:i="start"}={}){let n=this.items||[];if(!n.length)return;let r=Math.max(0,Math.min(n.length-1,t|0)),o=this.#k(r),a=this.#x(),l=this.#v(r),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#E(Math.max(0,h),e)}scrollToTop(){this.#E(0)}scrollToBottom(){let t=this.#S();this.#E(Math.max(0,t))}getVisibleRange(){return{startIndex:this.#c,endIndex:this.#h}}invalidateMeasurements(t=0){if(t<=0)this.#o.clear();else for(let e of[...this.#o.keys()])e>=t&&this.#o.delete(e);this.#P(),this.#T()}#w(){if(this.itemSize>0)return this.itemSize;if(this.itemSizeRem>0){let t=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return this.itemSizeRem*t}return 0}#v(t){let e=this.#w();if(e>0)return e;let i=this.#o.get(t);return i??(this.estimatedSize||48)}#k(t){let e=this.#w();if(e>0)return t*e;let i=0;for(let n=0;n<t;n++)i+=this.#v(n);return i}#S(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#w();if(i>0)return e*i;let n=0,r=this.estimatedSize||48;for(let o=0;o<e;o++)n+=this.#o.get(o)??r;return n}#x(){return this.direction==="horizontal"?this.clientWidth||0:this.clientHeight||0}#A(){return this.direction==="horizontal"?this.scrollLeft:this.scrollTop}#E(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#C(){let t=this.#A(),e=this.#x(),i=this.#S();return t+e>=i-1}#P(){if(!this.#t)return;let t=this.#S();this.direction==="horizontal"?(this.#t.style.width=`${t}px`,this.#t.style.height="1px"):(this.#t.style.height=`${t}px`,this.#t.style.width="1px")}#R(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return{start:0,end:0};let i=this.#x(),n=this.#A(),r=this.#w(),o,a;if(r>0)o=Math.floor(n/r),a=Math.ceil((n+i)/r);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>n){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}}#T(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=t.length,{start:i,end:n}=this.#R(),r=this.#k(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${r}px)`:this.#e.style.transform=`translateY(${r}px)`,this.loading?this.#Q(n-i):this.#q(t,i,n),(i!==this.#c||n!==this.#h)&&(this.#c=i,this.#h=n,this.dispatchEvent(new CustomEvent("range-change",{detail:{startIndex:i,endIndex:n,items:t.slice(i,n)},bubbles:!0})))}#q(t,e,i){if(!this.#e)return;let n=new Set,r=this.#n??this.#L();for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l);n.add(c);let u=this.#a.get(c);u?(u.dataset.index=String(l),u.setAttribute("aria-rowindex",String(l+1))):(u=this.#N(h,l,r),this.#a.set(c,u))}let o=[];for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l),u=this.#a.get(c);u&&o.push(u)}for(let[l,h]of this.#a)n.has(l)||(this.#p?.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.#p)for(let l of o)this.#p.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 n=0;n<e;n++){let r=document.createElement("div");if(r.setAttribute("data-row",""),r.setAttribute("data-skeleton-row",""),r.dataset.index=String(n),i?.content)r.appendChild(i.content.cloneNode(!0));else{let o=document.createElement("skeleton-ui");r.appendChild(o)}this.#e.appendChild(r)}}#N(t,e,i){let n=document.createElement("div");n.setAttribute("data-row",""),n.setAttribute("role","listitem"),n.dataset.index=String(e),n.setAttribute("aria-rowindex",String(e+1));let r=null;if(typeof i=="function")try{r=i(t,e)}catch(o){console.warn("[list-window-ui] render() threw:",o)}if(r instanceof Node)n.appendChild(r);else if(r!=null)n.textContent=String(r);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)),n.appendChild(o)}else t!=null&&(n.textContent=String(t));return n}#L(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#$==null&&(this.#$=t.innerHTML);let e=this.#$;return(i,n)=>{let r=e.replace(/\$\{item\.([a-zA-Z0-9_]+)\}/g,(a,l)=>{let h=i&&typeof i=="object"?i[l]:"";return h==null?"":jI(String(h))}),o=document.createElement("template");return o.innerHTML=r,o.content.cloneNode(!0)}}#$=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 jI(s){return s.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}S("list-window-ui",co);P();var uo=class extends x{static properties={open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},gap:{type:Number,default:4,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=null;#n=null;connected(){this.#i||(this.#i=!0,this.addEventListener("click",this.#d),this.addEventListener("keydown",this.#p))}render(){this.open?this.#a():this.#o()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){if(this.#e)return this.#e;let t=document.createElement("div");return t.setAttribute("data-menu-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.addEventListener("toggle",this.#b),t.addEventListener("click",this.#f),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.#r(),i=this.querySelectorAll(":scope > menu-item-ui, :scope > menu-divider-ui");for(let n of i)e.appendChild(n);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=ct(t,e,{placement:this.placement,gap:this.gap}),this.#u&&(this.#u=!1,this.#n=requestAnimationFrame(()=>{this.#n=null,this.#c(0)})),this.#s=requestAnimationFrame(()=>{this.#s=null,document.addEventListener("pointerdown",this.#O),document.addEventListener("keydown",this.#g,!0)})}#o(){this.#t?.(),this.#t=null;let t=this.#e;if(t){t.matches(":popover-open")&&t.hidePopover?.();let e=t.querySelectorAll("menu-item-ui, menu-divider-ui");for(let i of e)this.insertBefore(i,t)}this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#O),document.removeEventListener("keydown",this.#g,!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,n=e[i];n.setAttribute("tabindex","-1"),n.focus({preventScroll:!0})}#h(){return this.#l().indexOf(document.activeElement)}#u=!1;#d=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.#u=!1,this.open=!this.open)};#p=t=>{let e=this.querySelector('[slot="trigger"]');!e||!(t.target===e||e.contains(t.target))||(t.key==="ArrowDown"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#u=!0,this.open=!0)};#f=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}}};#O=t=>{this.open&&(this.contains(t.target)||(this.open=!1))};#g=t=>{t.key==="Escape"&&this.open?(t.stopPropagation(),t.preventDefault(),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0})):t.key==="Tab"&&this.open&&(this.open=!1)};#b=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#o(),this.#e&&(this.#e.removeEventListener("toggle",this.#b),this.#e.removeEventListener("click",this.#f),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},fo=class extends x{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","menuitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),this.#s(),this.#n()}#t(t){return t.dataset.menuItemStamped="1",t}#e(t){return t?.dataset?.menuItemStamped==="1"}#i(t){for(let e of this.children)if(e.matches(t))return e;return null}#s(){if(!this.#i('[slot="text"]')){if(this.icon&&!this.#i('[slot="icon"]')){let t=this.#t(document.createElement("icon-ui"));t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=this.#t(document.createElement("span"));t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#n(){this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}render(){let t=this.#i('[slot="icon"]');if(this.icon)if(t)this.#e(t)&&t.setAttribute("name",this.icon);else{let i=this.#t(document.createElement("icon-ui"));i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else this.#e(t)&&t.remove();let e=this.#i('[slot="text"]');this.#e(e)&&(e.textContent=this.text),this.#n()}},po=class extends x{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}};S("menu-ui",uo),S("menu-item-ui",fo),S("menu-divider-ui",po);P();var i1=500,mo=class extends x{static properties={for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:i1,reflect:!1,attribute:"long-press-ms"}};static template=()=>null;#t=null;#e=null;#i=null;#s=[];#n=null;#r=null;#a=null;#o=null;connected(){super.connected(),this.#l()}disconnected(){super.disconnected(),this.#c(),this.#w(),this.#t?.remove(),this.#t=null}openAt(t,e,i=null){if(i??=this.#s[0]??null,!!i){if(this.#r=i,t==null||e==null){let n=i.getBoundingClientRect();t=n.left+n.width/2,e=n.top+n.height/2}this.#b(t,e)}}close(t="manual"){this.#y(t)}#l(){this.#s=this.#h();for(let t of this.#s)t.addEventListener("contextmenu",this.#u),t.addEventListener("touchstart",this.#d,{passive:!0}),t.addEventListener("touchend",this.#p),t.addEventListener("touchcancel",this.#p),t.addEventListener("keydown",this.#f)}#c(){for(let t of this.#s)t.removeEventListener("contextmenu",this.#u),t.removeEventListener("touchstart",this.#d),t.removeEventListener("touchend",this.#p),t.removeEventListener("touchcancel",this.#p),t.removeEventListener("keydown",this.#f);this.#s=[]}#h(){if(this.for)try{return[...document.querySelectorAll(this.for)]}catch(t){return console.warn(`[context-menu-ui] invalid [for] selector: ${this.for}`,t),[]}for(let t of this.children){let e=t.tagName.toLowerCase();if(e!=="menu-item-ui"&&e!=="menu-divider-ui")return[t]}return[]}#u=t=>{t.defaultPrevented||this.#m()&&(t.preventDefault(),this.#r=t.currentTarget,this.#b(t.clientX,t.clientY))};#d=t=>{if(!this.#m())return;let e=t.touches[0];e&&(this.#n=setTimeout(()=>{this.#r=t.currentTarget,this.#b(e.clientX,e.clientY)},this.longPressMs??i1))};#p=()=>{this.#n&&clearTimeout(this.#n),this.#n=null};#f=t=>{if(t.shiftKey&&t.key==="F10"||t.key==="ContextMenu"){if(!this.#m())return;t.preventDefault(),this.#r=t.currentTarget,this.openAt(null,null,t.currentTarget)}};#m(){return[...this.children].some(t=>t.tagName.toLowerCase()==="menu-item-ui")}#O(){if(this.#t)return this.#t;let t=document.createElement("div");return t.setAttribute("data-context-menu-surface",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.setAttribute("aria-label",this.getAttribute("aria-label")||"Context menu"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#S),document.body.appendChild(t),this.#t=t,t}#g(t,e){if(!this.#e){let i=document.createElement("div");i.setAttribute("data-context-menu-anchor",""),i.style.cssText="position:fixed;width:1px;height:1px;pointer-events:none;opacity:0;",document.body.appendChild(i),this.#e=i}return this.#e.style.left=`${t}px`,this.#e.style.top=`${e}px`,this.#e}#b(t,e){let i=this.#O();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 n=this.#g(t,e);this.#i?.(),this.#i=ct(n,i,{placement:"bottom-start",gap:0}),this.open=!0,this.#v();let r=i.querySelector("menu-item-ui:not([disabled])");queueMicrotask(()=>r?.focus?.()),this.dispatchEvent(new CustomEvent("context-menu-open",{bubbles:!0,detail:{target:this.#r,x:t,y:e}}))}#y(t="manual"){if(this.open){this.open=!1,this.#w(),this.dispatchEvent(new CustomEvent("context-menu-close",{bubbles:!0,detail:{reason:t}}));try{this.#r?.focus?.()}catch{}}}#w(){this.#k(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#v(){this.#a=t=>{this.#t?.contains(t.target)||this.#y("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#a),document.addEventListener("keydown",this.#o)})}#k(){this.#a&&document.removeEventListener("pointerdown",this.#a),this.#o&&document.removeEventListener("keydown",this.#o),this.#a=null,this.#o=null}#S=t=>{let e=t.target.closest("menu-item-ui");if(!e||e.hasAttribute("disabled"))return;let i=e.getAttribute("value")||"",n=e.getAttribute("text")||e.textContent.trim();this.dispatchEvent(new CustomEvent("context-menu-select",{bubbles:!0,detail:{value:i,text:n}})),this.#y("select")}};S("context-menu-ui",mo);P();var go=class extends x{static properties={};static template=()=>null};S("visually-hidden-ui",go);P();var bo=class extends x{static properties={target:{type:String,default:"#main",reflect:!0},text:{type:String,default:"Skip to main content",reflect:!0}};static template=({target:t,text:e})=>it`<a href="${t}" data-skip-link>${e}</a>`;connected(){super.connected(),this.addEventListener("click",this.#t)}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t)}#t=t=>{if(!t.target.closest("[data-skip-link]"))return;let i=this.target.replace(/^#/,""),n=document.getElementById(i);n&&queueMicrotask(()=>{n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),n.focus({preventScroll:!1})})}};S("skip-nav-ui",bo);P();var Oo=class extends x{static properties={variant:{type:String,default:"warning",reflect:!0}};static template=()=>null;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","mark")}};S("mark-ui",Oo);var yo=class extends M{static properties={...M.properties,placeholder:{type:String,default:"Click to edit",reflect:!0},editing:{type:Boolean,default:!1,reflect:!0},commit:{type:String,default:"blur",reflect:!0}};static template=()=>null;#t="";#e=!1;#i=!1;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","textbox"),!this.hasAttribute("tabindex")&&!this.disabled&&this.setAttribute("tabindex","0"),this.value&&this.textContent.trim()===""?this.textContent=this.value:!this.value&&this.textContent.trim()&&(this.value=this.textContent.trim(),this.syncValue()),this.#e||(this.#e=!0,this.addEventListener("click",this.#s),this.addEventListener("keydown",this.#n),this.addEventListener("focus",this.#r),this.addEventListener("blur",this.#a))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#n),this.removeEventListener("focus",this.#r),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())};#n=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()}};#r=()=>{};#a=()=>{if(this.editing){if(this.#i){this.#i=!1;return}this.commit==="blur"?this.commitEdit():this.commit==="enter"&&this.cancelEdit()}};#o(){let t=document.createRange();t.selectNodeContents(this);let e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(t))}};S("inline-edit-ui",yo);P();var vo=class extends x{static properties={active:{type:Boolean,default:!1,reflect:!0},step:{type:Number,default:0,reflect:!1},autoStart:{type:Boolean,default:!1,reflect:!0,attribute:"auto-start"},storageKey:{type:String,default:"",reflect:!0,attribute:"storage-key"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=null;connected(){super.connected(),this.autoStart&&!this.#o()&&requestAnimationFrame(()=>{this.isConnected&&this.autoStart&&this.start()})}disconnected(){super.disconnected(),this.#h()}start(){if(!this.active){if(!this.#a.length){console.warn("[tour-ui] start() called with no <tour-step> children \u2014 nothing to render.");return}this.step=0,this.active=!0,this.#c(),this.#u(),this.dispatchEvent(new CustomEvent("tour-start",{bubbles:!0,detail:{step:0}}))}}next(){if(!this.active)return;let t=this.#a.length;if(this.step>=t-1){this.finish();return}let e=this.step;this.step=e+1,this.#u(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:e,to:this.step,totalSteps:t}}))}previous(){if(!this.active||this.step<=0)return;let t=this.step;this.step=t-1,this.#u(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:t,to:this.step,totalSteps:this.#a.length}}))}skip(){if(!this.active)return;let t=this.#a.length,e=this.step;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-skip",{bubbles:!0,detail:{step:e,totalSteps:t}}))}finish(){if(!this.active)return;let t=this.#a.length;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-finish",{bubbles:!0,detail:{totalSteps:t}}))}get#a(){return[...this.querySelectorAll(":scope > tour-step-ui")]}#o(){if(!this.storageKey)return!1;try{return localStorage.getItem(this.storageKey)==="done"}catch{return!1}}#l(){if(this.storageKey)try{localStorage.setItem(this.storageKey,"done")}catch{}}#c(){if(!this.#t){let t=document.createElement("div");t.setAttribute("data-tour-spotlight",""),t.setAttribute("aria-hidden","true"),document.body.appendChild(t),this.#t=t}if(!this.#e){let t=document.createElement("div");t.setAttribute("data-tour-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","false"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#f),document.body.appendChild(t),this.#e=t}this.#s=()=>this.#p(),this.#n=()=>this.#p(),window.addEventListener("resize",this.#s),window.addEventListener("scroll",this.#n,!0),this.#r=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.#r)}#h(){this.#i?.(),this.#i=null,this.#s&&window.removeEventListener("resize",this.#s),this.#n&&window.removeEventListener("scroll",this.#n,!0),this.#r&&document.removeEventListener("keydown",this.#r),this.#s=this.#n=this.#r=null;try{this.#e?.hidePopover?.()}catch{}this.#e?.removeEventListener("click",this.#f),this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null}#u(){let t=this.#a[this.step];if(!t)return;let e=this.#a.length,i=this.step===e-1,n=this.step===0,r=t.getAttribute("title")||"",o=t.getAttribute("placement")||"bottom",a=t.getAttribute("target")||"",l=a?document.querySelector(a):null;this.#d=l,this.#p();let h=`${this.step+1} of ${e}`,c=t.innerHTML;this.#e.innerHTML=`
|
|
204
|
+
`):e}async#u(){if(this.#n||this.#i)return;let t=this.#s,e=Db(this.language);this.#n=!0;try{let i=await Promise.resolve().then(()=>(Ib(),Rb)),n=null;try{n=(await i.importWithTimeout(i.languages[e],`lang-${e}`))?.extension??null}catch(r){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"language",language:e,error:r}}))}if(t!==this.#s||!this.isConnected)return;this.#d(i,n,e)}catch(i){this.dispatchEvent(new CustomEvent("language-load-error",{bubbles:!0,detail:{phase:"core",error:i}})),console.warn("[code-ui] CodeMirror failed to load; staying on static fallback.",i)}finally{this.#n=!1}}#d(t,e,i){let{EditorState:n,EditorView:r,Compartment:o,lineNumbers:a,placeholder:l,syntaxHighlighting:h,history:c,historyKeymap:u,defaultKeymap:d,indentWithTab:f,keymap:p,adiaBaseTheme:m,adiaHighlightStyle:b,lintGutter:g,jsonLinter:y}=t,v=this.querySelector(":scope > pre"),w=v?v.querySelector("code")?.textContent??"":"",k=this.text||w||"";this.#a=k;let E=document.createElement("div");E.setAttribute("data-cm-mount",""),v?v.replaceWith(E):this.appendChild(E);let A=[m,h(b)];this.editable&&A.push(c(),p.of([{key:"Mod-s",run:C=>(this.#g(C),!0)},...d,...u,f]),r.updateListener.of(C=>{if(!C.docChanged)return;let T=C.state.doc.toString();this.#m(T),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:T}}))}),r.domEventHandlers({focus:(C,T)=>(this.#r=T.state.doc.toString(),!1),blur:(C,T)=>{let Q=T.state.doc.toString();return this.#r!==null&&Q!==this.#r&&this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:Q}})),this.#r=null,!1}})),this.#o=new o,A.push(this.#o.of(this.#p(r,n))),e&&A.push(e),this.lineNumbers&&A.push(a()),this.placeholder&&A.push(l(this.placeholder)),this.editable&&i==="json"&&A.push(y,g()),this.#i=new r({parent:E,state:n.create({doc:k,extensions:A})}),this.editable&&this.#m(k)}#p(t,e){return this.editable&&!this.disabled&&!this.readonly?[]:[t.editable.of(!1),e.readOnly.of(!0)]}async#f(){if(!this.#i||!this.#o)return;let t=await Promise.resolve().then(()=>(Ib(),Rb));this.#i.dispatch({effects:this.#o.reconfigure(this.#p(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.#O(t))}#O(t){return t=t??"",this.required&&!t.trim()?(this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"This field is required.",this),this.setAttribute("aria-invalid","true"),!1):(this.internals.setValidity({}),this.removeAttribute("aria-invalid"),!0)}formResetCallback(){this.#i?this.#i.dispatch({changes:{from:0,to:this.#i.state.doc.length,insert:this.#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)}#g(t){this.dispatchEvent(new CustomEvent("save",{bubbles:!0,cancelable:!0,detail:{value:t.state.doc.toString()}}))}get value(){return this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??this.text??""}set value(t){this.text=String(t??"")}#b(){let t=this.#i?this.#i.state.doc.toString():this.querySelector(":scope > pre > code")?.textContent??"";t&&navigator.clipboard.writeText(t).then(()=>{let e=this.querySelector(':scope > header [slot="copy"]');if(!e)return;let i=e.textContent;e.textContent="Copied!",this.#e!=null&&clearTimeout(this.#e),this.#e=setTimeout(()=>{this.#e=null,e.textContent=i},1500)})}render(){let t=this.querySelector(':scope > header [slot="label"]');if(t&&this.language&&(t.textContent=this.language),this.#f(),!this.inline&&this.text!=="")if(this.#i){if(this.editable&&this.#i.hasFocus)return;let e=this.#i.state.doc.toString();e!==this.text&&this.#i.dispatch({changes:{from:0,to:e.length,insert:this.text}})}else{let e=this.querySelector(":scope > pre > code");e&&e.textContent!==this.text&&(e.textContent=this.text)}}};S("code-ui",ao);P();var lo=class extends x{static properties={divider:{type:Boolean,default:!1,reflect:!0},spacing:{type:String,default:"md",reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},selectedKey:{type:String,default:"",reflect:!0,attribute:"selected-key"}};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#n),this.addEventListener("keydown",this.#r))}disconnected(){this.removeEventListener("click",this.#n),this.removeEventListener("keydown",this.#r),this.#t=!1}render(){if(!this.selectable){for(let n of this.#e())n.removeAttribute("aria-selected"),n.removeAttribute("tabindex");return}let t=this.selectedKey||"",e=this.#e(),i=null;for(let n of e){let r=this.#i(n),o=r&&r===t;n.setAttribute("aria-selected",o?"true":"false"),n.setAttribute("tabindex",o?"0":"-1"),o&&(i=n)}!i&&e.length&&e[0].setAttribute("tabindex","0")}#e(){return[...this.children].filter(t=>t.getAttribute&&t.getAttribute("role")==="listitem")}#i(t){return t.id||t.getAttribute("data-key")||""}#s(t,{focus:e=!1}={}){if(!this.selectable||!t)return;let i=this.selectedKey||"";t!==i&&(this.selectedKey=t,this.dispatchEvent(new CustomEvent("selection-change",{detail:{key:t,previousKey:i},bubbles:!0})),e&&[...this.#e()].find(r=>this.#i(r)===t)?.focus?.())}#n=t=>{if(!this.selectable)return;let e=t.target.closest?.('[role="listitem"]');if(!e||e.parentElement!==this)return;let i=this.#i(e);i&&this.#s(i)};#r=t=>{if(!this.selectable)return;let e=this.#e();if(!e.length)return;let i=document.activeElement,n=e.indexOf(i);if(n<0)return;let r=n;switch(t.key){case"ArrowDown":r=Math.min(e.length-1,n+1);break;case"ArrowUp":r=Math.max(0,n-1);break;case"Home":r=0;break;case"End":r=e.length-1;break;case"Enter":case" ":{t.preventDefault();let o=this.#i(e[n]);o&&this.#s(o);return}default:return}r!==n&&(t.preventDefault(),e[r]?.focus?.())}},ho=class extends x{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","listitem"),this.#s()}#t(t){for(let e of this.children)if(e.matches(t))return e;return null}#e(t){return t.dataset.listStamped="1",t}#i(t){return t?.dataset?.listStamped==="1"}#s(){if(!this.#t('[slot="content"]')){if(this.icon){let t=this.#t('[slot="icon"]')||this.#t("icon-ui");t||(t=this.#e(document.createElement("icon-ui")),t.setAttribute("slot","icon"),this.prepend(t)),t.setAttribute("name",this.icon)}if(this.text){let t=this.#t('[slot="text"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","text"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.text)}if(this.description){let t=this.#t('[slot="description"]');t||(t=this.#e(document.createElement("span")),t.setAttribute("slot","description"),this.appendChild(t)),this.#i(t)&&(t.textContent=this.description)}}}render(){let t=this.#t('[slot="icon"]');if(this.icon)if(t)this.#i(t)&&t.setAttribute("name",this.icon);else{let n=this.#e(document.createElement("icon-ui"));n.setAttribute("slot","icon"),n.setAttribute("name",this.icon),this.prepend(n)}else this.#i(t)&&t.remove();let e=this.#t('[slot="text"]');if(this.text)if(e)this.#i(e)&&(e.textContent=this.text);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","text"),n.textContent=this.text,this.appendChild(n)}else this.#i(e)&&e.remove();let i=this.#t('[slot="description"]');if(this.description)if(i)this.#i(i)&&(i.textContent=this.description);else{let n=this.#e(document.createElement("span"));n.setAttribute("slot","description"),n.textContent=this.description,this.appendChild(n)}else this.#i(i)&&i.remove()}};S("list-ui",lo),S("list-item-ui",ho);P();var co=class extends x{static properties={items:{type:Array,default:[],reflect:!1},itemSize:{type:Number,default:0,reflect:!0,attribute:"item-size"},itemSizeRem:{type:Number,default:0,reflect:!0,attribute:"item-size-rem"},estimatedSize:{type:Number,default:48,reflect:!0,attribute:"estimated-size"},overscan:{type:Number,default:3,reflect:!0},direction:{type:String,default:"vertical",reflect:!0},pinBottom:{type:Boolean,default:!1,reflect:!0,attribute:"pin-bottom"},startIndex:{type:Number,default:0,reflect:!1,attribute:"start-index"},loading:{type:Boolean,default:!1,reflect:!0}};static parts={phantom:"<div data-phantom></div>",window:"<div data-window></div>",sentinelTop:'<div data-sentinel="top"></div>',sentinelBottom:'<div data-sentinel="bottom"></div>'};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=(t,e)=>t&&typeof t=="object"&&"id"in t?t.id:e;#a=new Map;#o=new Map;#l=1e5;#c=-1;#h=-1;#u=0;#d=!0;#p=null;#f=null;#m=()=>{this.#P();let t=this.#A();this.#u=t,this.#d=this.#C()};#O=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 n=this.items?.[i];n!=null&&this.dispatchEvent(new CustomEvent("item-click",{detail:{item:n,index:i},bubbles:!0}))};#g=t=>{if(t.target!==this)return;let e=this.#w()||this.estimatedSize||48,i=this.#x(),n=0;switch(t.key){case"ArrowDown":n=+e;break;case"ArrowUp":n=-e;break;case"PageDown":n=+i;break;case"PageUp":n=-i;break;case" ":n=+i;break;case"Home":t.preventDefault(),this.scrollToTop();return;case"End":t.preventDefault(),this.scrollToBottom();return;default:return}t.preventDefault();let r=this.#A();this.#E(r+n)};#b=t=>{for(let e of t){if(!e.isIntersecting)continue;let i=e.target?.dataset?.sentinel;if(i==="top"){let n=this.#c>=0?this.#c:0;this.dispatchEvent(new CustomEvent("scroll-start",{detail:{index:n},bubbles:!0}))}else if(i==="bottom"){let n=this.items||[],r=this.#h>=0?this.#h:n.length-1;this.dispatchEvent(new CustomEvent("scroll-end",{detail:{index:r},bubbles:!0}))}}};#y=t=>{if(this.itemSize>0)return;let e=!1;for(let i of t){let n=i.target;if(!n||n.parentElement!==this.#e)continue;let r=Number(n.dataset.index);if(!Number.isInteger(r))continue;let o=this.direction==="horizontal"?i.contentRect.width:i.contentRect.height,a=Math.max(1,Math.round(o));this.#o.get(r)!==a&&(this.#o.set(r,a),this.dispatchEvent(new CustomEvent("measure",{detail:{index:r,height:a},bubbles:!0})),e=!0)}e&&(this.#D(),this.#$(),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.#f=new IntersectionObserver(this.#b,{root:this,rootMargin:"0px",threshold:0}),this.#f.observe(this.#i),this.#f.observe(this.#s)),typeof ResizeObserver<"u"&&(this.#p=new ResizeObserver(this.#y)),this.addEventListener("scroll",this.#m,{passive:!0}),this.addEventListener("click",this.#O),this.addEventListener("keydown",this.#g),this.startIndex>0&&queueMicrotask(()=>this.scrollToIndex(this.startIndex))}disconnected(){this.removeEventListener("scroll",this.#m),this.removeEventListener("click",this.#O),this.removeEventListener("keydown",this.#g),this.#f?.disconnect(),this.#f=null,this.#p?.disconnect(),this.#p=null,this.#a.clear()}render(){if(!this.#e)return;let t=Array.isArray(this.items)?this.items:[],e=this.pinBottom&&(this.#d||this.#C());t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.setAttribute("aria-rowcount",String(t.length)),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy"),this.#$(),this.#P(),e&&this.scrollToBottom(),this.#d=this.#C()}set renderRow(t){this.#n=typeof t=="function"?t:null,this.#a.clear(),this.#P()}get renderRow(){return this.#n}set keyFn(t){this.#r=typeof t=="function"?t:((e,i)=>i),this.#a.clear(),this.#P()}get keyFn(){return this.#r}scrollToIndex(t,{behavior:e="auto",align:i="start"}={}){let n=this.items||[];if(!n.length)return;let r=Math.max(0,Math.min(n.length-1,t|0)),o=this.#k(r),a=this.#x(),l=this.#v(r),h=o;i==="center"?h=o-a/2+l/2:i==="end"&&(h=o-a+l),this.#E(Math.max(0,h),e)}scrollToTop(){this.#E(0)}scrollToBottom(){let t=this.#S();this.#E(Math.max(0,t))}getVisibleRange(){return{startIndex:this.#c,endIndex:this.#h}}invalidateMeasurements(t=0){if(t<=0)this.#o.clear();else for(let e of[...this.#o.keys()])e>=t&&this.#o.delete(e);this.#$(),this.#P()}#w(){if(this.itemSize>0)return this.itemSize;if(this.itemSizeRem>0){let t=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return this.itemSizeRem*t}return 0}#v(t){let e=this.#w();if(e>0)return e;let i=this.#o.get(t);return i??(this.estimatedSize||48)}#k(t){let e=this.#w();if(e>0)return t*e;let i=0;for(let n=0;n<t;n++)i+=this.#v(n);return i}#S(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return 0;let i=this.#w();if(i>0)return e*i;let n=0,r=this.estimatedSize||48;for(let o=0;o<e;o++)n+=this.#o.get(o)??r;return n}#x(){return this.direction==="horizontal"?this.clientWidth||0:this.clientHeight||0}#A(){return this.direction==="horizontal"?this.scrollLeft:this.scrollTop}#E(t,e="auto"){this.direction==="horizontal"?this.scrollTo({left:t,behavior:e}):this.scrollTo({top:t,behavior:e})}#C(){let t=this.#A(),e=this.#x(),i=this.#S();return t+e>=i-1}#$(){if(!this.#t)return;let t=this.#S();this.direction==="horizontal"?(this.#t.style.width=`${t}px`,this.#t.style.height="1px"):(this.#t.style.height=`${t}px`,this.#t.style.width="1px")}#L(){let e=(Array.isArray(this.items)?this.items:[]).length;if(e===0)return{start:0,end:0};let i=this.#x(),n=this.#A(),r=this.#w(),o,a;if(r>0)o=Math.floor(n/r),a=Math.ceil((n+i)/r);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>n){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:n}=this.#L(),r=this.#k(i);this.direction==="horizontal"?this.#e.style.transform=`translateX(${r}px)`:this.#e.style.transform=`translateY(${r}px)`,this.loading?this.#T(n-i):this.#q(t,i,n),(i!==this.#c||n!==this.#h)&&(this.#c=i,this.#h=n,this.dispatchEvent(new CustomEvent("range-change",{detail:{startIndex:i,endIndex:n,items:t.slice(i,n)},bubbles:!0})))}#q(t,e,i){if(!this.#e)return;let n=new Set,r=this.#n??this.#M();for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l);n.add(c);let u=this.#a.get(c);u?(u.dataset.index=String(l),u.setAttribute("aria-rowindex",String(l+1))):(u=this.#N(h,l,r),this.#a.set(c,u))}let o=[];for(let l=e;l<i;l++){let h=t[l],c=this.#r(h,l),u=this.#a.get(c);u&&o.push(u)}for(let[l,h]of this.#a)n.has(l)||(this.#p?.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.#p)for(let l of o)this.#p.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 n=0;n<e;n++){let r=document.createElement("div");if(r.setAttribute("data-row",""),r.setAttribute("data-skeleton-row",""),r.dataset.index=String(n),i?.content)r.appendChild(i.content.cloneNode(!0));else{let o=document.createElement("skeleton-ui");r.appendChild(o)}this.#e.appendChild(r)}}#N(t,e,i){let n=document.createElement("div");n.setAttribute("data-row",""),n.setAttribute("role","listitem"),n.dataset.index=String(e),n.setAttribute("aria-rowindex",String(e+1));let r=null;if(typeof i=="function")try{r=i(t,e)}catch(o){console.warn("[list-window-ui] render() threw:",o)}if(r instanceof Node)n.appendChild(r);else if(r!=null)n.textContent=String(r);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)),n.appendChild(o)}else t!=null&&(n.textContent=String(t));return n}#M(){let t=this.querySelector(":scope > template:not([slot])");if(!t)return null;this.#Q==null&&(this.#Q=t.innerHTML);let e=this.#Q;return(i,n)=>{let r=e.replace(/\$\{item\.([a-zA-Z0-9_]+)\}/g,(a,l)=>{let h=i&&typeof i=="object"?i[l]:"";return h==null?"":jI(String(h))}),o=document.createElement("template");return o.innerHTML=r,o.content.cloneNode(!0)}}#Q=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 jI(s){return s.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}S("list-window-ui",co);P();var uo=class extends x{static properties={open:{type:Boolean,default:!1,reflect:!0},placement:{type:String,default:"bottom-start",reflect:!0},gap:{type:Number,default:4,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=!1;#s=null;#n=null;connected(){this.#i||(this.#i=!0,this.addEventListener("click",this.#d),this.addEventListener("keydown",this.#p))}render(){this.open?this.#a():this.#o()}show(){this.open=!0}hide(){this.open=!1}toggle(){this.open=!this.open}#r(){if(this.#e)return this.#e;let t=document.createElement("div");return t.setAttribute("data-menu-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.addEventListener("toggle",this.#b),t.addEventListener("click",this.#f),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.#r(),i=this.querySelectorAll(":scope > menu-item-ui, :scope > menu-divider-ui");for(let n of i)e.appendChild(n);e.matches(":popover-open")||e.showPopover?.(),this.#t?.(),this.#t=ct(t,e,{placement:this.placement,gap:this.gap}),this.#u&&(this.#u=!1,this.#n=requestAnimationFrame(()=>{this.#n=null,this.#c(0)})),this.#s=requestAnimationFrame(()=>{this.#s=null,document.addEventListener("pointerdown",this.#O),document.addEventListener("keydown",this.#g,!0)})}#o(){this.#t?.(),this.#t=null;let t=this.#e;if(t){t.matches(":popover-open")&&t.hidePopover?.();let e=t.querySelectorAll("menu-item-ui, menu-divider-ui");for(let i of e)this.insertBefore(i,t)}this.#s!=null&&(cancelAnimationFrame(this.#s),this.#s=null),this.#n!=null&&(cancelAnimationFrame(this.#n),this.#n=null),document.removeEventListener("pointerdown",this.#O),document.removeEventListener("keydown",this.#g,!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,n=e[i];n.setAttribute("tabindex","-1"),n.focus({preventScroll:!0})}#h(){return this.#l().indexOf(document.activeElement)}#u=!1;#d=t=>{let e=this.querySelector('[slot="trigger"]');e&&(t.target===e||e.contains(t.target))&&(this.#u=!1,this.open=!this.open)};#p=t=>{let e=this.querySelector('[slot="trigger"]');!e||!(t.target===e||e.contains(t.target))||(t.key==="ArrowDown"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#u=!0,this.open=!0)};#f=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}}};#O=t=>{this.open&&(this.contains(t.target)||(this.open=!1))};#g=t=>{t.key==="Escape"&&this.open?(t.stopPropagation(),t.preventDefault(),this.open=!1,this.querySelector('[slot="trigger"]')?.focus?.({preventScroll:!0})):t.key==="Tab"&&this.open&&(this.open=!1)};#b=t=>{let e=t.newState==="open";e!==this.open&&(this.open=e)};disconnected(){this.#o(),this.#e&&(this.#e.removeEventListener("toggle",this.#b),this.#e.removeEventListener("click",this.#f),this.#e.removeEventListener("keydown",this.#m)),this.#e=null,this.#i=!1}},fo=class extends x{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","menuitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),this.#s(),this.#n()}#t(t){return t.dataset.menuItemStamped="1",t}#e(t){return t?.dataset?.menuItemStamped==="1"}#i(t){for(let e of this.children)if(e.matches(t))return e;return null}#s(){if(!this.#i('[slot="text"]')){if(this.icon&&!this.#i('[slot="icon"]')){let t=this.#t(document.createElement("icon-ui"));t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=this.#t(document.createElement("span"));t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#n(){this.disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled")}render(){let t=this.#i('[slot="icon"]');if(this.icon)if(t)this.#e(t)&&t.setAttribute("name",this.icon);else{let i=this.#t(document.createElement("icon-ui"));i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else this.#e(t)&&t.remove();let e=this.#i('[slot="text"]');this.#e(e)&&(e.textContent=this.text),this.#n()}},po=class extends x{static properties={};static template=()=>null;connected(){this.setAttribute("role","separator")}};S("menu-ui",uo),S("menu-item-ui",fo),S("menu-divider-ui",po);P();var i1=500,mo=class extends x{static properties={for:{type:String,default:"",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},longPressMs:{type:Number,default:i1,reflect:!1,attribute:"long-press-ms"}};static template=()=>null;#t=null;#e=null;#i=null;#s=[];#n=null;#r=null;#a=null;#o=null;connected(){super.connected(),this.#l()}disconnected(){super.disconnected(),this.#c(),this.#w(),this.#t?.remove(),this.#t=null}openAt(t,e,i=null){if(i??=this.#s[0]??null,!!i){if(this.#r=i,t==null||e==null){let n=i.getBoundingClientRect();t=n.left+n.width/2,e=n.top+n.height/2}this.#b(t,e)}}close(t="manual"){this.#y(t)}#l(){this.#s=this.#h();for(let t of this.#s)t.addEventListener("contextmenu",this.#u),t.addEventListener("touchstart",this.#d,{passive:!0}),t.addEventListener("touchend",this.#p),t.addEventListener("touchcancel",this.#p),t.addEventListener("keydown",this.#f)}#c(){for(let t of this.#s)t.removeEventListener("contextmenu",this.#u),t.removeEventListener("touchstart",this.#d),t.removeEventListener("touchend",this.#p),t.removeEventListener("touchcancel",this.#p),t.removeEventListener("keydown",this.#f);this.#s=[]}#h(){if(this.for)try{return[...document.querySelectorAll(this.for)]}catch(t){return console.warn(`[context-menu-ui] invalid [for] selector: ${this.for}`,t),[]}for(let t of this.children){let e=t.tagName.toLowerCase();if(e!=="menu-item-ui"&&e!=="menu-divider-ui")return[t]}return[]}#u=t=>{t.defaultPrevented||this.#m()&&(t.preventDefault(),this.#r=t.currentTarget,this.#b(t.clientX,t.clientY))};#d=t=>{if(!this.#m())return;let e=t.touches[0];e&&(this.#n=setTimeout(()=>{this.#r=t.currentTarget,this.#b(e.clientX,e.clientY)},this.longPressMs??i1))};#p=()=>{this.#n&&clearTimeout(this.#n),this.#n=null};#f=t=>{if(t.shiftKey&&t.key==="F10"||t.key==="ContextMenu"){if(!this.#m())return;t.preventDefault(),this.#r=t.currentTarget,this.openAt(null,null,t.currentTarget)}};#m(){return[...this.children].some(t=>t.tagName.toLowerCase()==="menu-item-ui")}#O(){if(this.#t)return this.#t;let t=document.createElement("div");return t.setAttribute("data-context-menu-surface",""),t.setAttribute("popover","manual"),t.setAttribute("role","menu"),t.setAttribute("aria-label",this.getAttribute("aria-label")||"Context menu"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#S),document.body.appendChild(t),this.#t=t,t}#g(t,e){if(!this.#e){let i=document.createElement("div");i.setAttribute("data-context-menu-anchor",""),i.style.cssText="position:fixed;width:1px;height:1px;pointer-events:none;opacity:0;",document.body.appendChild(i),this.#e=i}return this.#e.style.left=`${t}px`,this.#e.style.top=`${e}px`,this.#e}#b(t,e){let i=this.#O();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 n=this.#g(t,e);this.#i?.(),this.#i=ct(n,i,{placement:"bottom-start",gap:0}),this.open=!0,this.#v();let r=i.querySelector("menu-item-ui:not([disabled])");queueMicrotask(()=>r?.focus?.()),this.dispatchEvent(new CustomEvent("context-menu-open",{bubbles:!0,detail:{target:this.#r,x:t,y:e}}))}#y(t="manual"){if(this.open){this.open=!1,this.#w(),this.dispatchEvent(new CustomEvent("context-menu-close",{bubbles:!0,detail:{reason:t}}));try{this.#r?.focus?.()}catch{}}}#w(){this.#k(),this.#i?.(),this.#i=null;try{this.#t?.hidePopover()}catch{}this.#e&&(this.#e.remove(),this.#e=null)}#v(){this.#a=t=>{this.#t?.contains(t.target)||this.#y("outside")},this.#o=t=>{t.key==="Escape"&&(t.stopPropagation(),this.#y("escape"))},requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.#a),document.addEventListener("keydown",this.#o)})}#k(){this.#a&&document.removeEventListener("pointerdown",this.#a),this.#o&&document.removeEventListener("keydown",this.#o),this.#a=null,this.#o=null}#S=t=>{let e=t.target.closest("menu-item-ui");if(!e||e.hasAttribute("disabled"))return;let i=e.getAttribute("value")||"",n=e.getAttribute("text")||e.textContent.trim();this.dispatchEvent(new CustomEvent("context-menu-select",{bubbles:!0,detail:{value:i,text:n}})),this.#y("select")}};S("context-menu-ui",mo);P();var go=class extends x{static properties={};static template=()=>null};S("visually-hidden-ui",go);P();var bo=class extends x{static properties={target:{type:String,default:"#main",reflect:!0},text:{type:String,default:"Skip to main content",reflect:!0}};static template=({target:t,text:e})=>it`<a href="${t}" data-skip-link>${e}</a>`;connected(){super.connected(),this.addEventListener("click",this.#t)}disconnected(){super.disconnected(),this.removeEventListener("click",this.#t)}#t=t=>{if(!t.target.closest("[data-skip-link]"))return;let i=this.target.replace(/^#/,""),n=document.getElementById(i);n&&queueMicrotask(()=>{n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),n.focus({preventScroll:!1})})}};S("skip-nav-ui",bo);P();var Oo=class extends x{static properties={variant:{type:String,default:"warning",reflect:!0}};static template=()=>null;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","mark")}};S("mark-ui",Oo);var yo=class extends M{static properties={...M.properties,placeholder:{type:String,default:"Click to edit",reflect:!0},editing:{type:Boolean,default:!1,reflect:!0},commit:{type:String,default:"blur",reflect:!0}};static template=()=>null;#t="";#e=!1;#i=!1;connected(){super.connected(),this.hasAttribute("role")||this.setAttribute("role","textbox"),!this.hasAttribute("tabindex")&&!this.disabled&&this.setAttribute("tabindex","0"),this.value&&this.textContent.trim()===""?this.textContent=this.value:!this.value&&this.textContent.trim()&&(this.value=this.textContent.trim(),this.syncValue()),this.#e||(this.#e=!0,this.addEventListener("click",this.#s),this.addEventListener("keydown",this.#n),this.addEventListener("focus",this.#r),this.addEventListener("blur",this.#a))}disconnected(){super.disconnected(),this.removeEventListener("click",this.#s),this.removeEventListener("keydown",this.#n),this.removeEventListener("focus",this.#r),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())};#n=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()}};#r=()=>{};#a=()=>{if(this.editing){if(this.#i){this.#i=!1;return}this.commit==="blur"?this.commitEdit():this.commit==="enter"&&this.cancelEdit()}};#o(){let t=document.createRange();t.selectNodeContents(this);let e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(t))}};S("inline-edit-ui",yo);P();var vo=class extends x{static properties={active:{type:Boolean,default:!1,reflect:!0},step:{type:Number,default:0,reflect:!1},autoStart:{type:Boolean,default:!1,reflect:!0,attribute:"auto-start"},storageKey:{type:String,default:"",reflect:!0,attribute:"storage-key"}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=null;connected(){super.connected(),this.autoStart&&!this.#o()&&requestAnimationFrame(()=>{this.isConnected&&this.autoStart&&this.start()})}disconnected(){super.disconnected(),this.#h()}start(){if(!this.active){if(!this.#a.length){console.warn("[tour-ui] start() called with no <tour-step> children \u2014 nothing to render.");return}this.step=0,this.active=!0,this.#c(),this.#u(),this.dispatchEvent(new CustomEvent("tour-start",{bubbles:!0,detail:{step:0}}))}}next(){if(!this.active)return;let t=this.#a.length;if(this.step>=t-1){this.finish();return}let e=this.step;this.step=e+1,this.#u(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:e,to:this.step,totalSteps:t}}))}previous(){if(!this.active||this.step<=0)return;let t=this.step;this.step=t-1,this.#u(),this.dispatchEvent(new CustomEvent("tour-step-change",{bubbles:!0,detail:{from:t,to:this.step,totalSteps:this.#a.length}}))}skip(){if(!this.active)return;let t=this.#a.length,e=this.step;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-skip",{bubbles:!0,detail:{step:e,totalSteps:t}}))}finish(){if(!this.active)return;let t=this.#a.length;this.#l(),this.active=!1,this.#h(),this.dispatchEvent(new CustomEvent("tour-finish",{bubbles:!0,detail:{totalSteps:t}}))}get#a(){return[...this.querySelectorAll(":scope > tour-step-ui")]}#o(){if(!this.storageKey)return!1;try{return localStorage.getItem(this.storageKey)==="done"}catch{return!1}}#l(){if(this.storageKey)try{localStorage.setItem(this.storageKey,"done")}catch{}}#c(){if(!this.#t){let t=document.createElement("div");t.setAttribute("data-tour-spotlight",""),t.setAttribute("aria-hidden","true"),document.body.appendChild(t),this.#t=t}if(!this.#e){let t=document.createElement("div");t.setAttribute("data-tour-popover",""),t.setAttribute("popover","manual"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","false"),t.tabIndex=-1,t.style.outline="none",t.addEventListener("click",this.#f),document.body.appendChild(t),this.#e=t}this.#s=()=>this.#p(),this.#n=()=>this.#p(),window.addEventListener("resize",this.#s),window.addEventListener("scroll",this.#n,!0),this.#r=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.#r)}#h(){this.#i?.(),this.#i=null,this.#s&&window.removeEventListener("resize",this.#s),this.#n&&window.removeEventListener("scroll",this.#n,!0),this.#r&&document.removeEventListener("keydown",this.#r),this.#s=this.#n=this.#r=null;try{this.#e?.hidePopover?.()}catch{}this.#e?.removeEventListener("click",this.#f),this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null}#u(){let t=this.#a[this.step];if(!t)return;let e=this.#a.length,i=this.step===e-1,n=this.step===0,r=t.getAttribute("title")||"",o=t.getAttribute("placement")||"bottom",a=t.getAttribute("target")||"",l=a?document.querySelector(a):null;this.#d=l,this.#p();let h=`${this.step+1} of ${e}`,c=t.innerHTML;this.#e.innerHTML=`
|
|
205
205
|
<div data-tour-header>
|
|
206
206
|
<span data-tour-indicator>${h}</span>
|
|
207
207
|
<span></span>
|
|
@@ -231,7 +231,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
231
231
|
placeholder="${this.placeholder}"
|
|
232
232
|
${this.disabled?"disabled":""}
|
|
233
233
|
${t?`size="${t}"`:""}
|
|
234
|
-
></input-ui>`}this.#t=this.querySelector("input-ui"),this.#t&&(this.#t.addEventListener("input",this.#s),this.#t.addEventListener("keydown",this.#n),this.#e=this.#t.querySelector('[slot="suffix"]'),this.#e&&(this.#e.style.cursor="pointer",this.#e.addEventListener("click",this.#r)))}render(){this.#t&&(this.#t.setAttribute("placeholder",this.placeholder),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"),this.setAttribute("value",this.value||""))}#s=()=>{this.value=this.#t.value,this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))},this.debounce||300)};#n=t=>{t.key==="Enter"&&(clearTimeout(this.#i),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))),t.key==="Escape"&&this.#r()};#r=()=>{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.#r()}disconnected(){super.disconnected(),clearTimeout(this.#i),this.#i=null,this.#t&&(this.#t.removeEventListener("input",this.#s),this.#t.removeEventListener("keydown",this.#n)),this.#e&&this.#e.removeEventListener("click",this.#r),this.#t=null,this.#e=null}};S("search-ui",Po);Ct();function Us(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function HI(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var GI=0,Qo=class extends M{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle","check"];static properties={...M.properties,placeholder:{type:String,default:"Select...",reflect:!0},label:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},creatable:{type:Boolean,default:!1,reflect:!0},clearable:{type:Boolean,default:!1,reflect:!0},filterMode:{type:String,default:"substring",reflect:!0,attribute:"filter-mode"},loading:{type:Boolean,default:!1,reflect:!0},maxOptions:{type:Number,default:100,reflect:!0,attribute:"max-options"},highlightMatch:{type:Boolean,default:!0,reflect:!0,attribute:"highlight-match"}};static template=()=>null;#t=[];#e="";#i="";#s=-1;#n=!1;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#p=null;#f=null;#m=`combobox-${++GI}`;#O=()=>this.#D();#g=t=>this.#I(t);#b=()=>this.#
|
|
234
|
+
></input-ui>`}this.#t=this.querySelector("input-ui"),this.#t&&(this.#t.addEventListener("input",this.#s),this.#t.addEventListener("keydown",this.#n),this.#e=this.#t.querySelector('[slot="suffix"]'),this.#e&&(this.#e.style.cursor="pointer",this.#e.addEventListener("click",this.#r)))}render(){this.#t&&(this.#t.setAttribute("placeholder",this.placeholder),this.disabled?this.#t.setAttribute("disabled",""):this.#t.removeAttribute("disabled"),this.setAttribute("value",this.value||""))}#s=()=>{this.value=this.#t.value,this.syncValue(this.value),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:this.value}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:this.value}})),clearTimeout(this.#i),this.#i=setTimeout(()=>{this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))},this.debounce||300)};#n=t=>{t.key==="Enter"&&(clearTimeout(this.#i),this.dispatchEvent(new CustomEvent("search",{bubbles:!0,detail:{value:this.value}}))),t.key==="Escape"&&this.#r()};#r=()=>{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.#r()}disconnected(){super.disconnected(),clearTimeout(this.#i),this.#i=null,this.#t&&(this.#t.removeEventListener("input",this.#s),this.#t.removeEventListener("keydown",this.#n)),this.#e&&this.#e.removeEventListener("click",this.#r),this.#t=null,this.#e=null}};S("search-ui",Po);Ct();function Us(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function HI(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var GI=0,Qo=class extends M{static labelDeprecated=!1;static requiredIcons=["caret-down","x-circle","check"];static properties={...M.properties,placeholder:{type:String,default:"Select...",reflect:!0},label:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0},open:{type:Boolean,default:!1,reflect:!0},freeText:{type:Boolean,default:!1,reflect:!0,attribute:"free-text"},creatable:{type:Boolean,default:!1,reflect:!0},clearable:{type:Boolean,default:!1,reflect:!0},filterMode:{type:String,default:"substring",reflect:!0,attribute:"filter-mode"},loading:{type:Boolean,default:!1,reflect:!0},maxOptions:{type:Number,default:100,reflect:!0,attribute:"max-options"},highlightMatch:{type:Boolean,default:!0,reflect:!0,attribute:"highlight-match"}};static template=()=>null;#t=[];#e="";#i="";#s=-1;#n=!1;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#p=null;#f=null;#m=`combobox-${++GI}`;#O=()=>this.#D();#g=t=>this.#I(t);#b=()=>this.#R();#y=t=>this.#_(t);#w=t=>this.#V(t);#v=t=>this.#U(t);#k=t=>this.#Y(t);#S=t=>this.#tt(t);#x=t=>this.#et(t);connected(){super.connected(),this.#t.length===0&&this.#L(),this.#e=this.value||"",this.#A(),this.#T(),this.#j()}disconnected(){super.disconnected(),this.#$(),this.#p?.(),this.#p=null,this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null),document.removeEventListener("pointerdown",this.#x),this.#o?.hidePopover?.(),this.#o=null,this.#r=null,this.#a=null,this.#l=null,this.#c=null,this.#h=null,this.#u=null,this.#d=null}render(){this.#r&&(this.#r.setAttribute("aria-expanded",String(this.open)),this.disabled||this.readonly?this.#r.contentEditable="false":this.#r.contentEditable="plaintext-only",this.#a&&(this.#a.textContent=this.label||"",this.#a.style.display=this.label?"":"none"),this.label?this.removeAttribute("aria-label"):this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label"),this.#u&&(this.#u.style.display=this.clearable&&this.value?"":"none"),this.#c&&(this.#c.style.display=this.loading?"":"none"),this.open?this.#st():this.#G())}#A(){if(this.querySelector(":scope > [data-field]")){this.#E(),this.#C();return}let t=`${this.#m}-label`,e=`${this.#m}-listbox`,i=`${this.#m}-input`,n=Array.from(this.querySelectorAll(':scope > [slot="prefix"]')),r=Array.from(this.querySelectorAll(':scope > [slot="suffix"]')),o=Array.from(this.querySelectorAll(':scope > [slot="empty"]')),a=Array.from(this.querySelectorAll(':scope > [slot="loading"]')),l=Array.from(this.querySelectorAll(':scope > [slot="footer"]'));this.innerHTML=`
|
|
235
235
|
<span data-label id="${t}"${this.label?"":' style="display:none"'}>${Us(this.label||"")}</span>
|
|
236
236
|
<div data-field>
|
|
237
237
|
<span data-prefix></span>
|
|
@@ -258,8 +258,8 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
258
258
|
<div data-empty>No matches</div>
|
|
259
259
|
<div data-footer></div>
|
|
260
260
|
</div>
|
|
261
|
-
`,this.#E(),n.length&&this.querySelector(":scope > [data-field] > [data-prefix]").replaceChildren(...n),r.length&&this.#d.replaceChildren(...r),o.length&&this.#l.replaceChildren(...o),a.length&&this.#c.replaceChildren(...a),l.length&&this.#h.replaceChildren(...l),this.#C()}#E(){this.#r=this.querySelector(":scope > [data-field] > [data-input]"),this.#a=this.querySelector(":scope > [data-label]"),this.#u=this.querySelector(":scope > [data-field] > [data-clear]"),this.#d=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#o=this.querySelector(":scope > [data-listbox]"),this.#c=this.querySelector(":scope > [data-listbox] > [data-loading]"),this.#l=this.querySelector(":scope > [data-listbox] > [data-empty]"),this.#h=this.querySelector(":scope > [data-listbox] > [data-footer]")}#C(){this.#r&&(this.#r.addEventListener("input",this.#O),this.#r.addEventListener("keydown",this.#g),this.#r.addEventListener("focus",this.#b),this.#r.addEventListener("blur",this.#y)),this.#u&&this.#u.addEventListener("click",this.#k),this.#d&&this.#d.addEventListener("click",this.#S)}#P(){this.#r&&(this.#r.removeEventListener("input",this.#O),this.#r.removeEventListener("keydown",this.#g),this.#r.removeEventListener("focus",this.#b),this.#r.removeEventListener("blur",this.#y)),this.#u&&this.#u.removeEventListener("click",this.#k),this.#d&&this.#d.removeEventListener("click",this.#S)}#R(){let t=[],e="";for(let i of Array.from(this.children))if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled}),r.hasAttribute("selected")&&!e&&(e=r.value);t.push(n)}else i.tagName==="OPTION"&&(t.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&!e&&(e=i.value));for(let i of[...this.querySelectorAll(":scope > option, :scope > optgroup")])i.remove();this.#t=t,!this.value&&e&&(this.value=e)}set options(t){F(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#Q(),this.#j()})}get options(){return this.#t}#T(){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.#T().find(e=>e.value===t)||null}#Q(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#T(),i=this.#$(e).slice(0,Number(this.maxOptions)||100),n=0,r=a=>{n+=1;let l=document.createElement("div");return l.setAttribute("role","option"),l.setAttribute("id",`${this.#m}-opt-${n}`),l.dataset.value=a.value??"",a.disabled&&l.setAttribute("aria-disabled","true"),a.value===this.value&&l.setAttribute("aria-selected","true"),l.innerHTML=this.#N(a.label??a.value),l.addEventListener("click",this.#w),l.addEventListener("mouseenter",this.#v),l};if(this.#t.some(a=>a&&Array.isArray(a.options)))for(let a of this.#t)if(a&&Array.isArray(a.options)){let l=this.#$(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(r(u));t.appendChild(h)}else a&&this.#L(a)&&t.appendChild(r(a));else for(let a of i)t.appendChild(r(a));let o=t.querySelectorAll('[role="option"]').length;this.#l&&(this.#l.style.display=o||this.loading?"none":""),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant")}#N(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return Us(e);let i=this.#i,n=new RegExp(HI(i),"i"),r=e.match(n);if(!r)return Us(e);let o=r.index??0,a=o+r[0].length;return Us(e.slice(0,o))+"<mark>"+Us(e.slice(o,a))+"</mark>"+Us(e.slice(a))}#L(t){if(!this.#i)return!0;let e=this.#i.toLowerCase(),i=String(t.label??t.value??"").toLowerCase();switch(this.filterMode){case"prefix":return i.startsWith(e);case"fuzzy":{let n=0;for(let r of e){if(n=i.indexOf(r,n),n===-1)return!1;n+=1}return!0}default:return i.includes(e)}}#$(t){return this.#i?t.filter(e=>this.#L(e)):t.slice()}#D(){if(this.#n)return;let t=this.#r.textContent||"";this.#i=t.trim(),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"typing"}}))),this.#Q(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#I(t){let e=t.key;if(e==="ArrowDown"){t.preventDefault(),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}))),this.#W(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#W(-1);return}if(e==="Home"&&this.open){t.preventDefault(),this.#B(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#Z();this.#B(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#H();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#it("escape"));return}if(e==="Tab"){this.#J();return}if(e==="Backspace"){let i=!(this.#r.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#K("keyboard"));return}}#M(){}#_(t){!this.freeText&&this.#i&&!this.value&&(this.#j(),this.#i="")}#Z(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#W(t){let e=this.#Z();if(!e.length)return;if(this.#s<0){this.#B(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#B(i)}#B(t){let e=this.#Z();if(!e.length){this.#s=-1,this.#r?.removeAttribute("aria-activedescendant");return}for(let r of e)r.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),n=e[i];n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#s=i,this.#r?.setAttribute("aria-activedescendant",n.id))}#V(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#F(i,"click")}#U(t){let e=t.currentTarget,n=this.#Z().indexOf(e);n>=0&&this.#B(n)}#H(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#Z(),e=this.#s>=0?t[this.#s]:null;if(e){this.#F(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(!i){this.#G("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#X(i,"keyboard");return}if(this.freeText){this.#X(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#j(),this.#i="",this.#Q()}#J(){if(!this.open)return;let t=this.#Z(),e=this.#s>=0?t[this.#s]:null;if(e){this.#F(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#q(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#X(i,"keyboard");return}this.#j(),this.#i="",this.#G("blur")}#F(t,e){if(this.readonly){this.#G("select");return}let i=this.#q(t);F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#j(),this.#Q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:i,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#X(t,e){if(this.readonly){this.#G("select");return}F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#j(),this.#Q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,option:null,source:e}})),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"select"}}))}#Y(t){t.preventDefault(),t.stopPropagation(),this.#K("click"),this.#r?.focus()}#K(t){F(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#j(),this.#Q(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#K("programmatic")}#tt(t){t.preventDefault(),t.stopPropagation(),!this.disabled&&(this.open?(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}}))):(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"click"}})),this.#r?.focus()))}#et(t){let e=this.contains(t.target),i=this.#o&&t.composedPath().includes(this.#o);!e&&!i&&(this.#i&&!this.freeText&&(this.#j(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#it(t){this.#j(),this.#i="",this.#Q(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#st(){if(!this.#o)return;this.#o.showPopover?.();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#p?.(),this.#p=ct(t,this.#o,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#f!=null&&cancelAnimationFrame(this.#f),this.#f=requestAnimationFrame(()=>{this.#f=null,document.addEventListener("pointerdown",this.#x)});let e=this.#Z();if(!e.length)return;let i=e.findIndex(n=>n.dataset.value===this.value);this.#B(i>=0?i:0)}#G(t){this.#o&&(this.#p?.(),this.#p=null,this.#o.hidePopover?.(),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null),document.removeEventListener("pointerdown",this.#x),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant"))}#j(){if(!this.#r)return;let t=this.#q(this.value),e=t?t.label??t.value??"":this.value||"";(this.#r.textContent||"")!==e&&(this.#n=!0,this.#r.textContent=e,this.#n=!1),this.#r.toggleAttribute("data-empty",!e)}open$(){this.open=!0}close$(){this.open=!1}focus(){this.#r?.focus()}selectOption(t){return this.#q(t)?(this.#F(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};S("combobox-ui",Qo);Ct();var KI=0;function JI(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var To=class extends M{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=M.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
|
|
262
|
-
`,reflect:!0,attribute:"paste-split"},max:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},minLength:{type:Number,default:1,reflect:!0,attribute:"min-length"},maxLength:{type:Number,default:0,reflect:!0,attribute:"max-length"},unique:{type:Boolean,default:!0,reflect:!0},transform:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0}}}static get observedAttributes(){let t=super.observedAttributes;return t.includes("value")?t:[...t,"value"]}attributeChangedCallback(t,e,i){if(t==="value"){if(i!=null&&e!==i){let n=this.#B(i);n&&(this.value=n)}return}super.attributeChangedCallback(t,e,i)}static template=()=>null;#t=[];#e=[];#i=null;#s=-1;#n=!1;#r=0;#a=null;#o=null;#l=null;#c=null;#h=`tags-input-${++KI}`;#u=()=>this.#A();#d=t=>this.#E(t);#p=t=>this.#C(t);#f=t=>this
|
|
261
|
+
`,this.#E(),n.length&&this.querySelector(":scope > [data-field] > [data-prefix]").replaceChildren(...n),r.length&&this.#d.replaceChildren(...r),o.length&&this.#l.replaceChildren(...o),a.length&&this.#c.replaceChildren(...a),l.length&&this.#h.replaceChildren(...l),this.#C()}#E(){this.#r=this.querySelector(":scope > [data-field] > [data-input]"),this.#a=this.querySelector(":scope > [data-label]"),this.#u=this.querySelector(":scope > [data-field] > [data-clear]"),this.#d=this.querySelector(":scope > [data-field] > [data-suffix]"),this.#o=this.querySelector(":scope > [data-listbox]"),this.#c=this.querySelector(":scope > [data-listbox] > [data-loading]"),this.#l=this.querySelector(":scope > [data-listbox] > [data-empty]"),this.#h=this.querySelector(":scope > [data-listbox] > [data-footer]")}#C(){this.#r&&(this.#r.addEventListener("input",this.#O),this.#r.addEventListener("keydown",this.#g),this.#r.addEventListener("focus",this.#b),this.#r.addEventListener("blur",this.#y)),this.#u&&this.#u.addEventListener("click",this.#k),this.#d&&this.#d.addEventListener("click",this.#S)}#$(){this.#r&&(this.#r.removeEventListener("input",this.#O),this.#r.removeEventListener("keydown",this.#g),this.#r.removeEventListener("focus",this.#b),this.#r.removeEventListener("blur",this.#y)),this.#u&&this.#u.removeEventListener("click",this.#k),this.#d&&this.#d.removeEventListener("click",this.#S)}#L(){let t=[],e="";for(let i of Array.from(this.children))if(i.tagName==="OPTGROUP"){let n={label:i.label||i.getAttribute("label")||"",options:[]};for(let r of i.querySelectorAll("option"))n.options.push({value:r.value,label:r.textContent.trim(),disabled:r.disabled}),r.hasAttribute("selected")&&!e&&(e=r.value);t.push(n)}else i.tagName==="OPTION"&&(t.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled}),i.hasAttribute("selected")&&!e&&(e=i.value));for(let i of[...this.querySelectorAll(":scope > option, :scope > optgroup")])i.remove();this.#t=t,!this.value&&e&&(this.value=e)}set options(t){F(()=>{this.#t=Array.isArray(t)?t:[],this.#o&&this.#T(),this.#j()})}get options(){return this.#t}#P(){let t=[];for(let e of this.#t)if(e&&Array.isArray(e.options))for(let i of e.options)t.push(i);else e&&t.push(e);return t}#q(t){return this.#P().find(e=>e.value===t)||null}#T(){if(!this.#o)return;let t=this.querySelector(":scope > [data-listbox] > [data-options]");if(!t)return;t.replaceChildren();let e=this.#P(),i=this.#Q(e).slice(0,Number(this.maxOptions)||100),n=0,r=a=>{n+=1;let l=document.createElement("div");return l.setAttribute("role","option"),l.setAttribute("id",`${this.#m}-opt-${n}`),l.dataset.value=a.value??"",a.disabled&&l.setAttribute("aria-disabled","true"),a.value===this.value&&l.setAttribute("aria-selected","true"),l.innerHTML=this.#N(a.label??a.value),l.addEventListener("click",this.#w),l.addEventListener("mouseenter",this.#v),l};if(this.#t.some(a=>a&&Array.isArray(a.options)))for(let a of this.#t)if(a&&Array.isArray(a.options)){let l=this.#Q(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(r(u));t.appendChild(h)}else a&&this.#M(a)&&t.appendChild(r(a));else for(let a of i)t.appendChild(r(a));let o=t.querySelectorAll('[role="option"]').length;this.#l&&(this.#l.style.display=o||this.loading?"none":""),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant")}#N(t){let e=String(t??"");if(!this.highlightMatch||!this.#i)return Us(e);let i=this.#i,n=new RegExp(HI(i),"i"),r=e.match(n);if(!r)return Us(e);let o=r.index??0,a=o+r[0].length;return Us(e.slice(0,o))+"<mark>"+Us(e.slice(o,a))+"</mark>"+Us(e.slice(a))}#M(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 n=0;for(let r of e){if(n=i.indexOf(r,n),n===-1)return!1;n+=1}return!0}default:return i.includes(e)}}#Q(t){return this.#i?t.filter(e=>this.#M(e)):t.slice()}#D(){if(this.#n)return;let t=this.#r.textContent||"";this.#i=t.trim(),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"typing"}}))),this.#T(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{value:t,query:this.#i.toLowerCase()}}))}#I(t){let e=t.key;if(e==="ArrowDown"){t.preventDefault(),this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}))),this.#W(1);return}if(e==="ArrowUp"){if(!this.open)return;t.preventDefault(),this.#W(-1);return}if(e==="Home"&&this.open){t.preventDefault(),this.#B(0);return}if(e==="End"&&this.open){t.preventDefault();let i=this.#Z();this.#B(i.length-1);return}if(e==="Enter"){t.preventDefault(),this.#H();return}if(e==="Escape"){this.open&&(t.preventDefault(),this.#it("escape"));return}if(e==="Tab"){this.#J();return}if(e==="Backspace"){let i=!(this.#r.textContent||"").length;this.clearable&&i&&this.value&&(t.preventDefault(),this.#K("keyboard"));return}}#R(){}#_(t){!this.freeText&&this.#i&&!this.value&&(this.#j(),this.#i="")}#Z(){return this.#o?Array.from(this.#o.querySelectorAll('[role="option"]:not([aria-disabled="true"])')):[]}#W(t){let e=this.#Z();if(!e.length)return;if(this.#s<0){this.#B(t>0?0:e.length-1);return}let i=(this.#s+t+e.length)%e.length;this.#B(i)}#B(t){let e=this.#Z();if(!e.length){this.#s=-1,this.#r?.removeAttribute("aria-activedescendant");return}for(let r of e)r.removeAttribute("data-active");let i=Math.max(0,Math.min(t,e.length-1)),n=e[i];n&&(n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"}),this.#s=i,this.#r?.setAttribute("aria-activedescendant",n.id))}#V(t){let e=t.currentTarget;if(e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.value||"";this.#F(i,"click")}#U(t){let e=t.currentTarget,n=this.#Z().indexOf(e);n>=0&&this.#B(n)}#H(){if(!this.open){this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"keyboard"}}));return}let t=this.#Z(),e=this.#s>=0?t[this.#s]:null;if(e){this.#F(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(!i){this.#G("select");return}if(this.creatable){this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#X(i,"keyboard");return}if(this.freeText){this.#X(i,"keyboard");return}this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{query:i}})),this.#j(),this.#i="",this.#T()}#J(){if(!this.open)return;let t=this.#Z(),e=this.#s>=0?t[this.#s]:null;if(e){this.#F(e.dataset.value||"","keyboard");return}let i=(this.#r.textContent||"").trim();if(i&&(this.freeText||this.creatable)){this.creatable&&!this.#q(i)&&this.dispatchEvent(new CustomEvent("create",{bubbles:!0,detail:{value:i}})),this.#X(i,"keyboard");return}this.#j(),this.#i="",this.#G("blur")}#F(t,e){if(this.readonly){this.#G("select");return}let i=this.#q(t);F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#j(),this.#T(),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"}}))}#X(t,e){if(this.readonly){this.#G("select");return}F(()=>{this.value=t}),this.#e=t,this.#i="",this.syncValue(t),this.#j(),this.#T(),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"}}))}#Y(t){t.preventDefault(),t.stopPropagation(),this.#K("click"),this.#r?.focus()}#K(t){F(()=>{this.value=""}),this.#e="",this.#i="",this.syncValue(""),this.#j(),this.#T(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:"",option:null,source:t}}))}clear(){this.#K("programmatic")}#tt(t){t.preventDefault(),t.stopPropagation(),!this.disabled&&(this.open?(this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}}))):(this.open=!0,this.dispatchEvent(new CustomEvent("open",{bubbles:!0,detail:{trigger:"click"}})),this.#r?.focus()))}#et(t){let e=this.contains(t.target),i=this.#o&&t.composedPath().includes(this.#o);!e&&!i&&(this.#i&&!this.freeText&&(this.#j(),this.#i=""),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:"outside"}})))}#it(t){this.#j(),this.#i="",this.#T(),this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{reason:t}}))}#st(){if(!this.#o)return;this.#o.showPopover?.();let t=this.querySelector(":scope > [data-field]")||this;this.#o.style.minWidth=`${t.getBoundingClientRect().width}px`,this.#p?.(),this.#p=ct(t,this.#o,{placement:this.getAttribute("placement")||"bottom-start",gap:4,matchWidth:!1}),this.#f!=null&&cancelAnimationFrame(this.#f),this.#f=requestAnimationFrame(()=>{this.#f=null,document.addEventListener("pointerdown",this.#x)});let e=this.#Z();if(!e.length)return;let i=e.findIndex(n=>n.dataset.value===this.value);this.#B(i>=0?i:0)}#G(t){this.#o&&(this.#p?.(),this.#p=null,this.#o.hidePopover?.(),this.#f!=null&&(cancelAnimationFrame(this.#f),this.#f=null),document.removeEventListener("pointerdown",this.#x),this.#s=-1,this.#r?.removeAttribute("aria-activedescendant"))}#j(){if(!this.#r)return;let t=this.#q(this.value),e=t?t.label??t.value??"":this.value||"";(this.#r.textContent||"")!==e&&(this.#n=!0,this.#r.textContent=e,this.#n=!1),this.#r.toggleAttribute("data-empty",!e)}open$(){this.open=!0}close$(){this.open=!1}focus(){this.#r?.focus()}selectOption(t){return this.#q(t)?(this.#F(t,"programmatic"),!0):!1}syncValue(t){let e=t??this.value??"";super.syncValue(String(e))}};S("combobox-ui",Qo);Ct();var KI=0;function JI(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var To=class extends M{static labelDeprecated=!1;static requiredIcons=["circle-notch"];static get properties(){let{value:t,...e}=M.properties;return{...e,placeholder:{type:String,default:"Add tag\u2026",reflect:!0},delimiter:{type:String,default:",",reflect:!0},pasteSplit:{type:String,default:`,
|
|
262
|
+
`,reflect:!0,attribute:"paste-split"},max:{type:Number,default:0,reflect:!0},min:{type:Number,default:0,reflect:!0},minLength:{type:Number,default:1,reflect:!0,attribute:"min-length"},maxLength:{type:Number,default:0,reflect:!0,attribute:"max-length"},unique:{type:Boolean,default:!0,reflect:!0},transform:{type:String,default:"",reflect:!0},size:{type:String,default:"md",reflect:!0}}}static get observedAttributes(){let t=super.observedAttributes;return t.includes("value")?t:[...t,"value"]}attributeChangedCallback(t,e,i){if(t==="value"){if(i!=null&&e!==i){let n=this.#B(i);n&&(this.value=n)}return}super.attributeChangedCallback(t,e,i)}static template=()=>null;#t=[];#e=[];#i=null;#s=-1;#n=!1;#r=0;#a=null;#o=null;#l=null;#c=null;#h=`tags-input-${++KI}`;#u=()=>this.#A();#d=t=>this.#E(t);#p=t=>this.#C(t);#f=t=>this.#$(t);#m=t=>this.#L(t);#O=t=>this.#P(t);connected(){if(super.connected(),!this.#t.length&&this.hasAttribute("value")){let t=this.#B(this.getAttribute("value"));t&&(this.#t=t)}this.#g(),this.#v(),this.#S(),this.#x()}disconnected(){super.disconnected(),this.#w(),this.#a=null,this.#o=null,this.#l=null,this.#c=null}render(){this.#o&&(this.disabled||this.readonly?this.#o.contentEditable="false":this.#o.contentEditable="plaintext-only",this.#o.setAttribute("data-placeholder",this.placeholder||""),this.#e.length?(this.setAttribute("role","combobox"),this.setAttribute("aria-haspopup","listbox"),this.setAttribute("aria-expanded",String(!!this.hasAttribute("suggesting")))):(this.setAttribute("role","group"),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded")),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.placeholder||"Tags"))}set value(t){F(()=>{let e=Array.isArray(t)?t.map(n=>String(n??"")):typeof t=="string"?this.#B(t)||[]:[],i=this.#t.slice();this.#t=e,this.#v(),this.#S(),this.#x(),this.#D(i,e,"programmatic")})}get value(){return this.#t.slice()}set suggestions(t){F(()=>{this.#e=Array.isArray(t)?t.map(e=>String(e??"")):[],this.#k(),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.#T(String(t??""),"programmatic")}removeToken(t){let e=Number(t);!Number.isInteger(e)||e<0||e>=this.#t.length||this.#Q(e,"programmatic")}clear(){if(this.#t.length===0)return;let t=this.#t.slice();this.#t=[],this.#v(),this.#S(),this.#x(),this.#D(t,[],"programmatic")}focus(){this.#o?.focus()}#g(){if(this.querySelector(":scope > [data-chip-list]")){this.#b(),this.#y();return}let t=`${this.#h}-suggestions`,e=`${this.#h}-input`;this.innerHTML=`
|
|
263
263
|
<div data-chip-list role="list" aria-label="Tags"></div>
|
|
264
264
|
<span data-inline-input
|
|
265
265
|
id="${e}"
|
|
@@ -275,7 +275,7 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
275
275
|
<icon-ui name="circle-notch"></icon-ui>
|
|
276
276
|
</span>
|
|
277
277
|
<div data-suggestions id="${t}" role="listbox" hidden></div>
|
|
278
|
-
`,this.#b(),this.#y()}#b(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#y(){this.#o&&(this.#o.addEventListener("input",this.#u),this.#o.addEventListener("keydown",this.#d),this.#o.addEventListener("paste",this.#p)),this.#a&&this.#a.addEventListener("remove",this.#f),this.#l&&this.#l.addEventListener("click",this.#O),this.addEventListener("mousedown",this.#m)}#w(){this.#o&&(this.#o.removeEventListener("input",this.#u),this.#o.removeEventListener("keydown",this.#d),this.#o.removeEventListener("paste",this.#p)),this.#a&&this.#a.removeEventListener("remove",this.#f),this.#l&&this.#l.removeEventListener("click",this.#O),this.removeEventListener("mousedown",this.#m)}#v(){if(!this.#a)return;let t=Array.from(this.#a.querySelectorAll(":scope > tag-ui"));for(let e=0;e<this.#t.length;e++){let i=this.#t[e],n=t[e];n||(n=document.createElement("tag-ui"),n.setAttribute("role","listitem"),this.#a.appendChild(n)),n.setAttribute("text",i),this.readonly||this.disabled?n.removeAttribute("removable"):n.setAttribute("removable",""),n.setAttribute("data-index",String(e))}for(let e=this.#t.length;e<t.length;e++)t[e].remove()}#k(){if(!this.#l)return;let t=this.#o?(this.#o.textContent||"").trim().toLowerCase():"",e=this.#e.filter(n=>!this.#t.includes(n)).filter(n=>!t||n.toLowerCase().includes(t));this.#l.replaceChildren(),e.forEach((n,r)=>{let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("id",`${this.#h}-opt-${r}`),o.dataset.value=n,o.textContent=n,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 n of this.#l.children)n.removeAttribute("data-active")}#S(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#o)return;let t=!(this.#o.textContent||"").length;this.#o.toggleAttribute("data-empty",t),this.toggleAttribute("editing",!t)}#x(){let t=this.#t.length?JSON.stringify(this.#t):"";super.syncValue(t),this.required&&this.#t.length===0?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please add at least one tag.",this):this.min>0&&this.#t.length<this.min?this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please add at least ${this.min} tag${this.min===1?"":"s"}.`,this):this.internals.setValidity({})}#A(){if(this.#n)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(),n=!1;for(let r of e)r.length&&this.#Q(r,"delimiter")&&(n=!0);this.#n=!0,this.#o.textContent=i||"",this.#n=!1,this.#_(),this.#S(),this.#k(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#S(),this.#k(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#E(t){let e=t.key;if(this.disabled||this.readonly)return;let i=this.#o&&this.#o.textContent||"";if(e==="Enter"){if(t.preventDefault(),this.#s>=0){let n=this.#l?.children[this.#s];if(n){this.#Q(n.dataset.value||"","suggestion");return}}i&&this.#Q(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#$(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#Z(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#Z(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#W())}#C(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(`[${JI(this.pasteSplit)}]+`),n=e.split(i).map(o=>o.trim()).filter(Boolean);if(n.length===0)return;if(n.length===1){document.execCommand("insertText",!1,n[0]),this.#S(),this.#k();return}let r="";for(let o=0;o<n.length;o++){let a=n[o];!this.#Q(a,"paste")&&o===n.length-1&&(r=a)}r&&(this.#n=!0,this.#o.textContent=r,this.#n=!1,this.#_(),this.#S(),this.#k())}#P(t){let e=t.target.closest("tag-ui[data-index]");if(!e)return;t.stopPropagation();let i=Number(e.dataset.index);Number.isInteger(i)&&(e.remove(),this.#$(i,"chip-click"))}#R(t){if(this.disabled)return;let e=t.target.closest('[slot="dismiss"], tag-ui'),i=t.target.closest('[role="option"]');e||i||t.target!==this.#o&&(t.preventDefault(),this.#o?.focus(),this.#_())}#T(t){let e=t.target.closest('[role="option"]');e&&this.#Q(e.dataset.value||"","suggestion")}#q(t){let e=this.transform;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#Q(t,e){if(this.disabled||this.readonly)return!1;let i=this.#q(t.trim());if(!i)return this.#M(),!1;if(i.length<this.minLength)return this.#I(i,"too-short"),!1;if(this.maxLength>0&&i.length>this.maxLength)return this.#I(i,"too-long"),!1;if(this.unique&&this.#t.includes(i))return this.#M(),!1;if(this.max>0&&this.#t.length>=this.max)return this.#I(i,"max"),!1;let n=new CustomEvent("commit",{bubbles:!0,cancelable:!0,detail:{value:i,accepted:!0}});if(!this.dispatchEvent(n))return this.#I(i,"validator"),!1;if(this.#i)try{let o=this.#i(i,this.#t.length);if(o&&typeof o.then=="function")return this.#N(i,o,e),!1;if(o===!1)return this.#I(i,"validator"),!1}catch{return this.#I(i,"validator"),!1}return this.#L(i,e),!0}#N(t,e,i){let n=++this.#r;this.setAttribute("validating",""),this.#c&&(this.#c.hidden=!1),e.then(r=>{if(!(n!==this.#r||!this.isConnected)){if(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),r===!1){this.#I(t,"validator");return}this.#L(t,i)}},()=>{n!==this.#r||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#I(t,"validator"))})}#L(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#M(),this.#S(),this.#x(),this.#D(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#$(t,e){if(t<0||t>=this.#t.length)return;let i=this.#t.slice(),n=i.slice();n.splice(t,1),this.#t=n,this.#v(),this.#S(),this.#x(),this.#D(i,n,e),e!=="programmatic"&&this.#o?.focus()}#D(t,e,i){let n=new Set(t),r=new Set(e),o=e.filter(l=>!n.has(l)),a=t.filter(l=>!r.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}}))}#I(t,e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:e}}))}#M(){this.#o&&(this.#n=!0,this.#o.textContent="",this.#n=!1,this.#o.setAttribute("data-empty",""),this.removeAttribute("editing"),this.#k())}#_(){if(!(!this.#o||!this.#o.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#Z(t){if(!this.#l)return;let e=Array.from(this.#l.querySelectorAll('[role="option"]'));if(!e.length)return;this.#s<0?this.#s=t>0?0:e.length-1:this.#s=(this.#s+t+e.length)%e.length;for(let n of e)n.removeAttribute("data-active");let i=e[this.#s];i.setAttribute("data-active",""),i.scrollIntoView({block:"nearest"}),this.#o?.setAttribute("aria-activedescendant",i.id)}#W(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#B(t){if(t==null)return null;let e=String(t).trim();if(!e)return[];try{let i=JSON.parse(e);if(Array.isArray(i))return i.map(n=>String(n??""))}catch{}return e.includes(",")?(this.#I(e,"validator"),e.split(",").map(i=>i.trim()).filter(Boolean)):[e]}syncValue(t){if(typeof t=="string"){let e=this.#B(t);if(e){this.value=e;return}}super.syncValue(t)}};S("tags-input-ui",To);P();var Xl=class extends x{static properties={value:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},change:{type:String,default:"",reflect:!0},trend:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;connected(){this.#t=this.querySelector(':scope > [slot="value"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","value"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="label"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","label"),this.appendChild(this.#e)),this.#i=this.querySelector(':scope > [slot="change"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","change"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="icon"]'),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0,this.#e.textContent=this.label;return}this.removeAttribute("aria-busy"),this.#t.textContent=this.value,this.#e.textContent=this.label,this.change?(this.#i.textContent=this.change,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null}};customElements.define("stat-ui",Xl);P();var Lo=class extends x{static properties={label:{type:String,default:"",reflect:!0},value:{type:Number,default:null,reflect:!0},meta:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","group"),this.#t=this.querySelector(':scope > [slot="label"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","label"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="meta"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","meta"),this.appendChild(this.#e)),this.#i=this.querySelector(":scope > progress-ui"),this.#i||(this.#i=document.createElement("progress-ui"),this.value!=null&&this.value>=0&&this.#i.setAttribute("value",String(this.value)),this.appendChild(this.#i))}disconnected(){this.#t=null,this.#e=null,this.#i=null}render(){this.#t&&(this.#t.textContent=this.label,this.#t.hidden=!this.label,this.#e.textContent=this.meta,this.#e.hidden=!this.meta,this.value!=null&&this.value>=0?this.#i.setAttribute("value",String(this.value)):this.#i.removeAttribute("value"),this.label?this.setAttribute("aria-label",this.meta?`${this.label}, ${this.meta}`:this.label):this.removeAttribute("aria-label"))}};S("progress-row-ui",Lo);P();var Mo=class extends x{static properties={};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s))}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s),this.#t=!1}#e(){return Array.from(this.querySelectorAll(":scope > action-item-ui:not([disabled])"))}#i=t=>{let e=t.target.closest("action-item-ui");!e||e.hasAttribute("disabled")||this.contains(e)&&this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.getAttribute("value")||"",text:e.getAttribute("text")||e.textContent.trim(),item:e}}))};#s=t=>{let e=this.#e();if(!e.length)return;let i=document.activeElement?.closest?.("action-item-ui"),n=i?e.indexOf(i):-1,r=o=>{e[(o+e.length)%e.length]?.focus?.({preventScroll:!0})};switch(t.key){case"ArrowDown":t.preventDefault(),r(n+1);break;case"ArrowUp":t.preventDefault(),r(n-1);break;case"Home":t.preventDefault(),r(0);break;case"End":t.preventDefault(),r(e.length-1);break;case"Enter":case" ":{i&&(t.preventDefault(),i.click());break}}}},Ro=class extends x{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t(),this.#e()}#t(){if(!this.querySelector('[slot="text"]')){if(this.icon){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#e(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.querySelector('[slot="icon"]');if(this.icon)if(t)t.setAttribute("name",this.icon);else{let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else t&&t.remove();let e=this.querySelector('[slot="text"]');e&&(e.textContent=this.text),this.#e()}};S("action-list-ui",Mo),S("action-item-ui",Ro);P();var Io=class extends x{static properties={icon:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},variant:{type:String,default:"",reflect:!0},minimal:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s(t){return t.dataset.emptyStateStamped="1",t}#n(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.#n(this.#t)&&(this.icon?(this.#t.setAttribute("name",this.icon),this.#t.hidden=!1):this.#t.hidden=!0),this.#n(this.#e)&&(this.heading?(this.#e.textContent=this.heading,this.#e.hidden=!1):this.#e.hidden=!0),this.#n(this.#i)&&(this.description?(this.#i.textContent=this.description,this.#i.hidden=!1):this.#i.hidden=!0))}disconnected(){this.#t=null,this.#e=null,this.#i=null}};S("empty-state-ui",Io);P();var tD=["S","M","T","W","T","F","S"],eD=["January","February","March","April","May","June","July","August","September","October","November","December"];function a1(s){return String(s).padStart(2,"0")}function qb(s,t,e){return`${s}-${a1(t+1)}-${a1(e)}`}function Ri(s){if(!s)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s).trim());return t?new Date(+t[1],+t[2]-1,+t[3]):null}function Ku(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var Do=class extends x{static requiredIcons=["caret-left","caret-right"];static properties={value:{type:String,default:"",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},rangeStart:{type:String,default:"",reflect:!0,attribute:"range-start"},rangeEnd:{type:String,default:"",reflect:!0,attribute:"range-end"}};static template=()=>null;#t=new Date().getFullYear();#e=new Date().getMonth();#i=null;#s=!1;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Calendar");let t=Ri(this.value);t&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#s||(this.#s=!0,this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#o))}disconnected(){this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#o),this.#s=!1}render(){let t=Ri(this.value);t&&(t.getFullYear()!==this.#t||t.getMonth()!==this.#e)&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#n()}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.#n()}focusDay(t){let e=new Date(this.#t,this.#e+1,0).getDate();t<1||t>e||(this.#i=t,this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.())}#n(){let t=this.#t,e=this.#e,i=new Date,n=Ri(this.value),r=Ri(this.min),o=Ri(this.max),a=Ri(this.rangeStart),l=Ri(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
|
|
278
|
+
`,this.#b(),this.#y()}#b(){this.#a=this.querySelector(":scope > [data-chip-list]"),this.#o=this.querySelector(":scope > [data-inline-input]"),this.#c=this.querySelector(":scope > [data-spinner]"),this.#l=this.querySelector(":scope > [data-suggestions]")}#y(){this.#o&&(this.#o.addEventListener("input",this.#u),this.#o.addEventListener("keydown",this.#d),this.#o.addEventListener("paste",this.#p)),this.#a&&this.#a.addEventListener("remove",this.#f),this.#l&&this.#l.addEventListener("click",this.#O),this.addEventListener("mousedown",this.#m)}#w(){this.#o&&(this.#o.removeEventListener("input",this.#u),this.#o.removeEventListener("keydown",this.#d),this.#o.removeEventListener("paste",this.#p)),this.#a&&this.#a.removeEventListener("remove",this.#f),this.#l&&this.#l.removeEventListener("click",this.#O),this.removeEventListener("mousedown",this.#m)}#v(){if(!this.#a)return;let t=Array.from(this.#a.querySelectorAll(":scope > tag-ui"));for(let e=0;e<this.#t.length;e++){let i=this.#t[e],n=t[e];n||(n=document.createElement("tag-ui"),n.setAttribute("role","listitem"),this.#a.appendChild(n)),n.setAttribute("text",i),this.readonly||this.disabled?n.removeAttribute("removable"):n.setAttribute("removable",""),n.setAttribute("data-index",String(e))}for(let e=this.#t.length;e<t.length;e++)t[e].remove()}#k(){if(!this.#l)return;let t=this.#o?(this.#o.textContent||"").trim().toLowerCase():"",e=this.#e.filter(n=>!this.#t.includes(n)).filter(n=>!t||n.toLowerCase().includes(t));this.#l.replaceChildren(),e.forEach((n,r)=>{let o=document.createElement("div");o.setAttribute("role","option"),o.setAttribute("id",`${this.#h}-opt-${r}`),o.dataset.value=n,o.textContent=n,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 n of this.#l.children)n.removeAttribute("data-active")}#S(){if(this.toggleAttribute("populated",this.#t.length>0),!this.#o)return;let t=!(this.#o.textContent||"").length;this.#o.toggleAttribute("data-empty",t),this.toggleAttribute("editing",!t)}#x(){let t=this.#t.length?JSON.stringify(this.#t):"";super.syncValue(t),this.required&&this.#t.length===0?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Please add at least one tag.",this):this.min>0&&this.#t.length<this.min?this.internals.setValidity({tooShort:!0},this.getAttribute("data-msg-min")||`Please add at least ${this.min} tag${this.min===1?"":"s"}.`,this):this.internals.setValidity({})}#A(){if(this.#n)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(),n=!1;for(let r of e)r.length&&this.#T(r,"delimiter")&&(n=!0);this.#n=!0,this.#o.textContent=i||"",this.#n=!1,this.#_(),this.#S(),this.#k(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:i||""}}));return}this.#S(),this.#k(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:{query:t}}))}#E(t){let e=t.key;if(this.disabled||this.readonly)return;let i=this.#o&&this.#o.textContent||"";if(e==="Enter"){if(t.preventDefault(),this.#s>=0){let n=this.#l?.children[this.#s];if(n){this.#T(n.dataset.value||"","suggestion");return}}i&&this.#T(i,"keyboard");return}if(e==="Backspace"&&i.length===0){this.#t.length>0&&(t.preventDefault(),this.#Q(this.#t.length-1,"backspace"));return}if(e==="ArrowDown"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#Z(1);return}if(e==="ArrowUp"){if(!this.hasAttribute("suggesting"))return;t.preventDefault(),this.#Z(-1);return}e==="Escape"&&this.hasAttribute("suggesting")&&(t.preventDefault(),this.#W())}#C(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(`[${JI(this.pasteSplit)}]+`),n=e.split(i).map(o=>o.trim()).filter(Boolean);if(n.length===0)return;if(n.length===1){document.execCommand("insertText",!1,n[0]),this.#S(),this.#k();return}let r="";for(let o=0;o<n.length;o++){let a=n[o];!this.#T(a,"paste")&&o===n.length-1&&(r=a)}r&&(this.#n=!0,this.#o.textContent=r,this.#n=!1,this.#_(),this.#S(),this.#k())}#$(t){let e=t.target.closest("tag-ui[data-index]");if(!e)return;t.stopPropagation();let i=Number(e.dataset.index);Number.isInteger(i)&&(e.remove(),this.#Q(i,"chip-click"))}#L(t){if(this.disabled)return;let e=t.target.closest('[slot="dismiss"], tag-ui'),i=t.target.closest('[role="option"]');e||i||t.target!==this.#o&&(t.preventDefault(),this.#o?.focus(),this.#_())}#P(t){let e=t.target.closest('[role="option"]');e&&this.#T(e.dataset.value||"","suggestion")}#q(t){let e=this.transform;return e==="lowercase"?t.toLowerCase():e==="trim"?t.trim():e==="strip-spaces"?t.replace(/\s+/g,""):t}#T(t,e){if(this.disabled||this.readonly)return!1;let i=this.#q(t.trim());if(!i)return this.#R(),!1;if(i.length<this.minLength)return this.#I(i,"too-short"),!1;if(this.maxLength>0&&i.length>this.maxLength)return this.#I(i,"too-long"),!1;if(this.unique&&this.#t.includes(i))return this.#R(),!1;if(this.max>0&&this.#t.length>=this.max)return this.#I(i,"max"),!1;let n=new CustomEvent("commit",{bubbles:!0,cancelable:!0,detail:{value:i,accepted:!0}});if(!this.dispatchEvent(n))return this.#I(i,"validator"),!1;if(this.#i)try{let o=this.#i(i,this.#t.length);if(o&&typeof o.then=="function")return this.#N(i,o,e),!1;if(o===!1)return this.#I(i,"validator"),!1}catch{return this.#I(i,"validator"),!1}return this.#M(i,e),!0}#N(t,e,i){let n=++this.#r;this.setAttribute("validating",""),this.#c&&(this.#c.hidden=!1),e.then(r=>{if(!(n!==this.#r||!this.isConnected)){if(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),r===!1){this.#I(t,"validator");return}this.#M(t,i)}},()=>{n!==this.#r||!this.isConnected||(this.removeAttribute("validating"),this.#c&&(this.#c.hidden=!0),this.#I(t,"validator"))})}#M(t,e){let i=this.#t.slice();this.#t=[...this.#t,t],this.#v(),this.#R(),this.#S(),this.#x(),this.#D(i,this.#t,e),e!=="programmatic"&&this.#o?.focus()}#Q(t,e){if(t<0||t>=this.#t.length)return;let i=this.#t.slice(),n=i.slice();n.splice(t,1),this.#t=n,this.#v(),this.#S(),this.#x(),this.#D(i,n,e),e!=="programmatic"&&this.#o?.focus()}#D(t,e,i){let n=new Set(t),r=new Set(e),o=e.filter(l=>!n.has(l)),a=t.filter(l=>!r.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}}))}#I(t,e){this.dispatchEvent(new CustomEvent("invalid",{bubbles:!0,detail:{value:t,reason:e}}))}#R(){this.#o&&(this.#n=!0,this.#o.textContent="",this.#n=!1,this.#o.setAttribute("data-empty",""),this.removeAttribute("editing"),this.#k())}#_(){if(!(!this.#o||!this.#o.isConnected))try{let t=window.getSelection(),e=document.createRange();e.selectNodeContents(this.#o),e.collapse(!1),t.removeAllRanges(),t.addRange(e)}catch{}}#Z(t){if(!this.#l)return;let e=Array.from(this.#l.querySelectorAll('[role="option"]'));if(!e.length)return;this.#s<0?this.#s=t>0?0:e.length-1:this.#s=(this.#s+t+e.length)%e.length;for(let n of e)n.removeAttribute("data-active");let i=e[this.#s];i.setAttribute("data-active",""),i.scrollIntoView({block:"nearest"}),this.#o?.setAttribute("aria-activedescendant",i.id)}#W(){this.removeAttribute("suggesting"),this.#l&&(this.#l.hidden=!0),this.#s=-1,this.#o?.removeAttribute("aria-activedescendant"),this.removeAttribute("aria-expanded")}#B(t){if(t==null)return null;let e=String(t).trim();if(!e)return[];try{let i=JSON.parse(e);if(Array.isArray(i))return i.map(n=>String(n??""))}catch{}return e.includes(",")?(this.#I(e,"validator"),e.split(",").map(i=>i.trim()).filter(Boolean)):[e]}syncValue(t){if(typeof t=="string"){let e=this.#B(t);if(e){this.value=e;return}}super.syncValue(t)}};S("tags-input-ui",To);P();var Xl=class extends x{static properties={value:{type:String,default:"",reflect:!0},label:{type:String,default:"",reflect:!0},change:{type:String,default:"",reflect:!0},trend:{type:String,default:"",reflect:!0},icon:{type:String,default:"",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;connected(){this.#t=this.querySelector(':scope > [slot="value"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","value"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="label"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","label"),this.appendChild(this.#e)),this.#i=this.querySelector(':scope > [slot="change"]'),this.#i||(this.#i=document.createElement("span"),this.#i.setAttribute("slot","change"),this.appendChild(this.#i)),this.#s=this.querySelector(':scope > [slot="icon"]'),this.#s||(this.#s=document.createElement("icon-ui"),this.#s.setAttribute("slot","icon"),this.appendChild(this.#s))}render(){if(this.#t){if(this.loading){this.setAttribute("aria-busy","true"),this.#t.textContent="",this.#t.innerHTML='<skeleton-ui width="60%" height="2em" radius="sm"></skeleton-ui>',this.#i.textContent="",this.#i.innerHTML='<skeleton-ui width="40%" height="1em" radius="sm"></skeleton-ui>',this.#i.hidden=!1,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0,this.#e.textContent=this.label;return}this.removeAttribute("aria-busy"),this.#t.textContent=this.value,this.#e.textContent=this.label,this.change?(this.#i.textContent=this.change,this.#i.hidden=!1):this.#i.hidden=!0,this.icon?(this.#s.setAttribute("name",this.icon),this.#s.hidden=!1):this.#s.hidden=!0}}disconnected(){this.#t=null,this.#e=null,this.#i=null,this.#s=null}};customElements.define("stat-ui",Xl);P();var Lo=class extends x{static properties={label:{type:String,default:"",reflect:!0},value:{type:Number,default:null,reflect:!0},meta:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;connected(){this.setAttribute("role","group"),this.#t=this.querySelector(':scope > [slot="label"]'),this.#t||(this.#t=document.createElement("span"),this.#t.setAttribute("slot","label"),this.appendChild(this.#t)),this.#e=this.querySelector(':scope > [slot="meta"]'),this.#e||(this.#e=document.createElement("span"),this.#e.setAttribute("slot","meta"),this.appendChild(this.#e)),this.#i=this.querySelector(":scope > progress-ui"),this.#i||(this.#i=document.createElement("progress-ui"),this.value!=null&&this.value>=0&&this.#i.setAttribute("value",String(this.value)),this.appendChild(this.#i))}disconnected(){this.#t=null,this.#e=null,this.#i=null}render(){this.#t&&(this.#t.textContent=this.label,this.#t.hidden=!this.label,this.#e.textContent=this.meta,this.#e.hidden=!this.meta,this.value!=null&&this.value>=0?this.#i.setAttribute("value",String(this.value)):this.#i.removeAttribute("value"),this.label?this.setAttribute("aria-label",this.meta?`${this.label}, ${this.meta}`:this.label):this.removeAttribute("aria-label"))}};S("progress-row-ui",Lo);P();var Mo=class extends x{static properties={};static template=()=>null;#t=!1;connected(){this.setAttribute("role","list"),this.#t||(this.#t=!0,this.addEventListener("click",this.#i),this.addEventListener("keydown",this.#s))}disconnected(){this.removeEventListener("click",this.#i),this.removeEventListener("keydown",this.#s),this.#t=!1}#e(){return Array.from(this.querySelectorAll(":scope > action-item-ui:not([disabled])"))}#i=t=>{let e=t.target.closest("action-item-ui");!e||e.hasAttribute("disabled")||this.contains(e)&&this.dispatchEvent(new CustomEvent("action",{bubbles:!0,detail:{value:e.getAttribute("value")||"",text:e.getAttribute("text")||e.textContent.trim(),item:e}}))};#s=t=>{let e=this.#e();if(!e.length)return;let i=document.activeElement?.closest?.("action-item-ui"),n=i?e.indexOf(i):-1,r=o=>{e[(o+e.length)%e.length]?.focus?.({preventScroll:!0})};switch(t.key){case"ArrowDown":t.preventDefault(),r(n+1);break;case"ArrowUp":t.preventDefault(),r(n-1);break;case"Home":t.preventDefault(),r(0);break;case"End":t.preventDefault(),r(e.length-1);break;case"Enter":case" ":{i&&(t.preventDefault(),i.click());break}}}},Ro=class extends x{static properties={icon:{type:String,default:"",reflect:!0},text:{type:String,default:"",reflect:!0},value:{type:String,default:"",reflect:!0},variant:{type:String,default:"default",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;connected(){this.setAttribute("role","listitem"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.#t(),this.#e()}#t(){if(!this.querySelector('[slot="text"]')){if(this.icon){let t=document.createElement("icon-ui");t.setAttribute("slot","icon"),t.setAttribute("name",this.icon),this.appendChild(t)}if(this.text){let t=document.createElement("span");t.setAttribute("slot","text"),t.textContent=this.text,this.appendChild(t)}}}#e(){this.disabled?(this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"))}render(){let t=this.querySelector('[slot="icon"]');if(this.icon)if(t)t.setAttribute("name",this.icon);else{let i=document.createElement("icon-ui");i.setAttribute("slot","icon"),i.setAttribute("name",this.icon),this.prepend(i)}else t&&t.remove();let e=this.querySelector('[slot="text"]');e&&(e.textContent=this.text),this.#e()}};S("action-list-ui",Mo),S("action-item-ui",Ro);P();var Io=class extends x{static properties={icon:{type:String,default:"",reflect:!0},heading:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},variant:{type:String,default:"",reflect:!0},minimal:{type:Boolean,default:!1,reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s(t){return t.dataset.emptyStateStamped="1",t}#n(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.#n(this.#t)&&(this.icon?(this.#t.setAttribute("name",this.icon),this.#t.hidden=!1):this.#t.hidden=!0),this.#n(this.#e)&&(this.heading?(this.#e.textContent=this.heading,this.#e.hidden=!1):this.#e.hidden=!0),this.#n(this.#i)&&(this.description?(this.#i.textContent=this.description,this.#i.hidden=!1):this.#i.hidden=!0))}disconnected(){this.#t=null,this.#e=null,this.#i=null}};S("empty-state-ui",Io);P();var tD=["S","M","T","W","T","F","S"],eD=["January","February","March","April","May","June","July","August","September","October","November","December"];function a1(s){return String(s).padStart(2,"0")}function qb(s,t,e){return`${s}-${a1(t+1)}-${a1(e)}`}function Ri(s){if(!s)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s).trim());return t?new Date(+t[1],+t[2]-1,+t[3]):null}function Ku(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}var Do=class extends x{static requiredIcons=["caret-left","caret-right"];static properties={value:{type:String,default:"",reflect:!0},min:{type:String,default:"",reflect:!0},max:{type:String,default:"",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0},readonly:{type:Boolean,default:!1,reflect:!0},rangeStart:{type:String,default:"",reflect:!0,attribute:"range-start"},rangeEnd:{type:String,default:"",reflect:!0,attribute:"range-end"}};static template=()=>null;#t=new Date().getFullYear();#e=new Date().getMonth();#i=null;#s=!1;connected(){this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Calendar");let t=Ri(this.value);t&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#s||(this.#s=!0,this.addEventListener("click",this.#a),this.addEventListener("keydown",this.#o))}disconnected(){this.removeEventListener("click",this.#a),this.removeEventListener("keydown",this.#o),this.#s=!1}render(){let t=Ri(this.value);t&&(t.getFullYear()!==this.#t||t.getMonth()!==this.#e)&&(this.#t=t.getFullYear(),this.#e=t.getMonth()),this.#n()}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.#n()}focusDay(t){let e=new Date(this.#t,this.#e+1,0).getDate();t<1||t>e||(this.#i=t,this.#n(),this.querySelector("[data-cal-day][data-focused]")?.focus?.())}#n(){let t=this.#t,e=this.#e,i=new Date,n=Ri(this.value),r=Ri(this.min),o=Ri(this.max),a=Ri(this.rangeStart),l=Ri(this.rangeEnd),h=a&&l&&a<=l?a:null,c=a&&l&&a<=l?l:null,u=`<div data-cal-header>
|
|
279
279
|
<button data-cal-prev type="button" aria-label="Previous month" tabindex="-1"><icon-ui name="caret-left"></icon-ui></button>
|
|
280
280
|
<span data-cal-title>${eD[e]} ${t}</span>
|
|
281
281
|
<button data-cal-next type="button" aria-label="Next month" tabindex="-1"><icon-ui name="caret-right"></icon-ui></button>
|
|
@@ -426,10 +426,10 @@ Correct shape for <chart-ui x="label" y="value">:
|
|
|
426
426
|
text="Open"
|
|
427
427
|
></button-ui>`:null}
|
|
428
428
|
</list-item-ui>
|
|
429
|
-
`}#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 n=i.getAttribute("data-step-id")||"";if(!n)return;let r=this.#u(n),o=!!i.checked;r!==o&&this.#d(n,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 n=i.getAttribute("data-step-id")||"",r=i.getAttribute("data-href")||"";n&&this.dispatchEvent(new CustomEvent("onboarding-step-action",{bubbles:!0,detail:{id:n,href:r}}))}#c(t){t?.stopPropagation?.();let e=!this.collapsed;this.collapsed=e,e&&this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:"collapsed"}}))}#h(t){if(!t)return!1;let e=t.id;return e!=null&&Object.prototype.hasOwnProperty.call(this.value||{},e)?!!this.value[e]:!!t.done}#u(t){let i=(Array.isArray(this.items)?this.items:[]).find(n=>n&&String(n.id)===String(t));return this.#h(i)}#d(t,e,{emit:i=!0}={}){let n={...this.value||{},[t]:!!e};this.value=n,this.#w(),i&&e&&this.dispatchEvent(new CustomEvent("onboarding-step-complete",{bubbles:!0,detail:{id:t,value:n}}))}#p(){let t=Array.isArray(this.items)?this.items:[],e=t.length,i=0;for(let r of t)this.#h(r)&&i++;let n=e===0?0:Math.round(i/e*100);return{done:i,total:e,percent:n}}#f(){let{done:t,total:e}=this.#p();return e>0&&t===e}#m(){this.#f()?this.setAttribute("data-complete",""):this.removeAttribute("data-complete")}#O(){let t=this.#f();t&&!this.#s?(this.#s=!0,this.dispatchEvent(new CustomEvent("onboarding-complete",{bubbles:!0,detail:{value:this.value}})),this["dismiss-on-complete"]&&(this.setAttribute("hidden",""),this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:"complete"}})))):t||(this.#s=!1)}#g(){}#b(){if(this.#i||this.storage==="none"||!this["storage-key"]||typeof window>"u")return null;try{return this.storage==="session"?window.sessionStorage:window.localStorage}catch{return null}}#y(){let t=this.#b();if(!t)return null;try{let e=t.getItem(this["storage-key"]);if(!e)return null;let i=JSON.parse(e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}#w(){let t=this.#b();if(t)try{t.setItem(this["storage-key"],JSON.stringify(this.value||{}))}catch{}}complete(t){if(t==null)return;let e=String(t);this.#u(e)||this.#d(e,!0,{emit:!0})}reset(t){if(t==null){this.value={};let i=this.#b();try{i?.removeItem(this["storage-key"])}catch{}this.#s=!1,this.removeAttribute("hidden");return}let e=String(t);Object.prototype.hasOwnProperty.call(this.value||{},e)&&this.#d(e,!1,{emit:!1})}progress(){return this.#p()}};customElements.get("onboarding-checklist-ui")||customElements.define("onboarding-checklist-ui",rh);P();Ct();var gO=new Set(["","comfortable","compact","spacious"]),bO=new Set(["2","3","4","5","6"]),cE=new Set(["","2","2:1","3:2","3:1"]),OO=["toolbar","kpis","charts","table","aside"],md=class extends x{static get properties(){return{density:{type:String,default:"",reflect:!0},"kpi-columns":{type:String,default:"4",reflect:!0,attribute:"kpi-columns"},"chart-split":{type:String,default:"",reflect:!0,attribute:"chart-split"},loading:{type:Boolean,default:!1,reflect:!0},gap:{type:String,default:"",reflect:!0}}}static template=()=>null;#t={toolbar:!1,kpis:!1,charts:!1,table:!1,aside:!1};#e=null;#i=!1;setDensity(t){let e=gO.has(t)?t:"";this.density!==e&&(this.density=e)}getRegion(t){return OO.includes(t)?this.querySelector(`:scope > [slot="${t}"]`):null}connected(){this.hasAttribute("role")||this.setAttribute("role","region"),F(()=>this.#s()),this.#n(),this.#r(),this.#a(),this.#e=new MutationObserver(t=>this.#o(t)),this.#e.observe(this,{childList:!0})}disconnected(){this.#e&&(this.#e.disconnect(),this.#e=null)}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!this.#i){if(t==="density"&&e!==i){if(!gO.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&&!bO.has(i)){console.warn(`[dashboard-layout-ui] kpi-columns="${i}" out of range \u2014 falling back to "4". Use one of: ${[...bO].join(", ")}.`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}return}if(t==="chart-split"&&e!==i){if(i!=null&&!cE.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.#n();return}if(t==="gap"&&e!==i){this.#r();return}}}#s(){if(!gO.has(this.density)){this.#i=!0;try{this.density=""}finally{this.#i=!1}}if(!bO.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(!cE.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}}}#n(){this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy")}#r(){let t=(this.gap||"").trim();if(t===""){this.style.removeProperty("--dashboard-layout-gap");return}/^[1-6]$/.test(t)?this.style.setProperty("--dashboard-layout-gap",`var(--a-space-${t})`):this.style.setProperty("--dashboard-layout-gap",t)}#a(){for(let t of OO)this.#t[t]=!!this.querySelector(`:scope > [slot="${t}"]`)}#o(t){for(let e of OO){let i=this.#t[e],n=!!this.querySelector(`:scope > [slot="${e}"]`);i&&!n&&this.dispatchEvent(new CustomEvent("region-empty",{bubbles:!0,detail:{region:e}})),this.#t[e]=n}}};customElements.get("dashboard-layout-ui")||customElements.define("dashboard-layout-ui",md);Ct();var Gs=new Set,uE=!1;function dE(s){return String(s).padStart(2,"0")}function gd(s){return`${s.getFullYear()}-${dE(s.getMonth()+1)}-${dE(s.getDate())}`}function fE(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 pE={today:"Today","7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days",qtd:"Quarter to date",ytd:"Year to date",custom:"Custom"},Ks=new Set(Object.keys(pE));function oh(s,t=new Date){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=gd(e),n=r=>{let o=new Date(e);return o.setDate(o.getDate()-r),gd(o)};switch(s){case"today":return{from:i,to:i};case"7d":return{from:n(6),to:i};case"30d":return{from:n(29),to:i};case"90d":return{from:n(89),to:i};case"qtd":{let r=Math.floor(e.getMonth()/3)*3;return{from:gd(new Date(e.getFullYear(),r,1)),to:i}}case"ytd":return{from:gd(new Date(e.getFullYear(),0,1)),to:i};case"custom":return null;default:return null}}function tq(s,t){let e=fE(s),i=fE(t);if(!e||!i)return"";let n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=e.getFullYear()===i.getFullYear(),o=r&&e.getMonth()===i.getMonth();return r&&e.getMonth()===i.getMonth()&&e.getDate()===i.getDate()?`${n[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`:o?`${n[e.getMonth()]} ${e.getDate()} \u2013 ${i.getDate()}, ${i.getFullYear()}`:r?`${n[e.getMonth()]} ${e.getDate()} \u2013 ${n[i.getMonth()]} ${i.getDate()}, ${i.getFullYear()}`:`${n[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()} \u2013 ${n[i.getMonth()]} ${i.getDate()}, ${i.getFullYear()}`}var bd=class s extends M{static labelDeprecated=!0;static get properties(){return{...M.properties,value:{type:String,default:"7d",reflect:!0},from:{type:String,default:"",reflect:!0},to:{type:String,default:"",reflect:!0},presets:{type:String,default:"today,7d,30d,90d,qtd,ytd,custom"},broadcast:{type:String,default:"document",reflect:!0},ariaLabelAttr:{type:String,default:"Time period",attribute:"aria-label",reflect:!0},pickerOpen:{type:Boolean,default:!1,attribute:"picker-open",reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r={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 r=this.#f(e,i);this.#d("custom",r.from,r.to);return}if(!Ks.has(t)){console.warn(`[date-range-selector-ui] unknown preset "${t}" \u2014 ignored. Use one of: ${[...Ks].join(", ")}.`);return}let n=oh(t);n&&this.#d(t,n.from,n.to)}getRange(){return{value:this.value,preset:this.value,from:this.from,to:this.to}}subscribe(t){let e=this.#O();return e?(e.addEventListener("range-change",t),()=>e.removeEventListener("range-change",t)):()=>{}}connected(){super.connected(),this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.ariaLabelAttr||"Time period"),this.#t||(this.#c(),this.#u(),this.#t=!0),this.broadcast==="document"&&this.#y(),F(()=>{let t=this.#m();t&&this.#d(this.value,t.from,t.to,{initial:!0})})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0,this.#w()}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#o)){if(t==="presets"){this.#h();return}if(t==="broadcast"){e==="document"&&i!=="document"&&this.#w(),i==="document"?(this.#y(),this.#b()):i==="self"&&this.#b();return}if(t==="value"&&e!==i&&i&&Ks.has(i)){if(i!=="custom"){let n=oh(i);n&&this.#d(i,n.from,n.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.#n){let t=tq(this.from,this.to);this.#n.textContent=t,this.#n.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.#r.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.#r.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.#n=i,this.#r.readout=i,this.#h()}#h(){if(!this.#i)return;let t=(this.presets||"").split(",").map(i=>i.trim()).filter(Boolean),e=this.#i.querySelector(":scope > [data-indicator]");this.#i.replaceChildren(),e&&this.#i.appendChild(e);for(let i of t){if(!Ks.has(i)){s.#l.has(this)||(s.#l.add(this),console.warn(`[date-range-selector-ui] unknown preset key "${i}" in [presets] \u2014 ignored. Use one of: ${[...Ks].join(", ")}.`));continue}let n=document.createElement("segment-ui");n.setAttribute("value",i),n.setAttribute("text",pE[i]),this.#i.appendChild(n)}this.#i.value=this.value}#u(){let t=r=>{let o=r.detail?.value;if(!o||!Ks.has(o))return;if(r.stopPropagation(),o==="custom"){this.#v(),this.#p("custom");return}let a=oh(o);a&&this.#d(o,a.from,a.to)};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=r=>{r.stopPropagation();let a=(r.detail||{}).value||null;if(!a||!a.from||!a.to)return;let l=this.#f(a.from,a.to);this.#d("custom",l.from,l.to)};this.#s.addEventListener("change",e),this.#e.push(()=>this.#s.removeEventListener("change",e));let i=()=>{this.pickerOpen=!0},n=()=>{this.pickerOpen=!1};this.#s.addEventListener("open",i),this.#s.addEventListener("close",n),this.#e.push(()=>this.#s.removeEventListener("open",i)),this.#e.push(()=>this.#s.removeEventListener("close",n))}#d(t,e,i,n={}){if(this.from===e&&this.to===i&&this.value===t&&!n.initial)return;this.#o=!0;try{this.from=e,this.to=i,this.value=t}finally{this.#o=!1}this.syncValue(),this.#b();let o={value:t,from:e,to:i,preset:t};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,from:e,to:i}}));let a=this.#O();a&&a.dispatchEvent(new CustomEvent("range-change",{bubbles:a===this,detail:o}))}#p(t){if(this.value!==t){this.#o=!0;try{this.value=t}finally{this.#o=!1}}}#f(t,e){return t<=e?{from:t,to:e}:{from:e,to:t}}#m(){if(this.value==="custom")return this.from&&this.to?this.#f(this.from,this.to):oh("7d");let t=Ks.has(this.value)?this.value:"7d";return oh(t)}#O(){return this.broadcast==="document"?document:this.broadcast==="self"?this:null}#g(){return this.broadcast==="document"?document.documentElement:this.broadcast==="self"?this:null}#b(){let t=this.#g();t&&(this.broadcast==="document"&&!this.#a||(this.from?t.setAttribute("data-range-from",this.from):t.removeAttribute("data-range-from"),this.to?t.setAttribute("data-range-to",this.to):t.removeAttribute("data-range-to")))}#y(){if(Gs.size>0&&!Gs.has(this)){uE||(uE=!0,console.warn('[date-range-selector-ui] multiple instances with broadcast="document" on the same page; only the first writes data-range-from / data-range-to to <html>. Use broadcast="self" for secondary instances. See SPEC-019 \xA76 nesting rules.')),this.#a=!1,Gs.add(this);return}Gs.add(this),this.#a=!0}#w(){if(Gs.has(this)&&(Gs.delete(this),this.#a)){document.documentElement.removeAttribute("data-range-from"),document.documentElement.removeAttribute("data-range-to"),this.#a=!1;let t=Gs.values().next().value;t&&(t.#a=!0,t.#b())}}#v(){this.#s&&(typeof this.#s.openPopover=="function"?this.#s.openPopover():this.#s.open=!0)}};customElements.get("date-range-selector-ui")||customElements.define("date-range-selector-ui",bd);P();var Od=class extends x{static properties={open:{type:Boolean,default:!1,reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},confirmText:{type:String,default:"Confirm",reflect:!0,attribute:"confirm-text"},cancelText:{type:String,default:"Cancel",reflect:!0,attribute:"cancel-text"},confirmVariant:{type:String,default:"primary",reflect:!0,attribute:"confirm-variant"},size:{type:String,default:"sm",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=null;#a=null;#o=null;#l=null;#c=null;#h=[];#u=!1;#d="";#p="";#f=!1;connected(){this.#u||(this.#d=`${this.#b}-title`,this.#p=`${this.#b}-desc`,this.#m(),this.#O(),this.#u=!0)}disconnected(){for(let t of this.#h)try{t()}catch{}this.#h.length=0}show(){this.open=!0}hide(){this.open=!1}render(){if(!this.#u)return;this.#t&&(this.#t.setAttribute("size",this.size||"sm"),this.#t.open=!!this.open),this.#s&&(this.#s.id=this.#d,this.#s.textContent=this.title||""),this.#r&&(this.#r.id=this.#p,this.#r.textContent=this.description||"",this.#r.hidden=!this.description),this.#i&&(this.querySelector(':scope > [slot="icon"]')?this.#i.hidden=!0:this.icon?(this.#i.hidden=!1,this.#i.setAttribute("name",this.icon)):this.#i.hidden=!0);let t=this.#t?.querySelector(':scope > [slot="dialog"]');t&&(t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),this.title?t.setAttribute("aria-labelledby",this.#d):t.removeAttribute("aria-labelledby"),this.description?t.setAttribute("aria-describedby",this.#p):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.#g()}#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 n=document.createElement("text-ui");n.setAttribute("slot","heading"),n.id=this.#d,this.title&&(n.textContent=this.title),e.appendChild(n),this.#s=n,this.#e=e;let r=document.createElement("text-ui");r.setAttribute("slot","description"),r.id=this.#p,this.description?r.textContent=this.description:r.hidden=!0,e.appendChild(r),this.#r=r;let o=document.createElement("section");o.setAttribute("slot","body");let a=document.createElement("div");a.setAttribute("data-extra",""),o.appendChild(a),this.#a=a,this.#n=o;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(o),t.appendChild(l),this.appendChild(t),this.#t=t}#O(){let t=n=>{this.loading||(n.stopPropagation(),this.#f=!0,this.dispatchEvent(new CustomEvent("confirm",{bubbles:!0,detail:{}})))};this.#c.addEventListener("press",t),this.#h.push(()=>this.#c.removeEventListener("press",t));let e=n=>{this.loading||(n.stopPropagation(),this.#f=!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=n=>{n.stopPropagation(),this.open=!1,this.#f||this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.#f=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{}}))};this.#t.addEventListener("close",i),this.#h.push(()=>this.#t.removeEventListener("close",i))}#g(){let t=()=>{if(!(!this.open||!this.#l||this.loading))try{this.#l.focus()}catch{}};typeof requestAnimationFrame=="function"?requestAnimationFrame(t):queueMicrotask(t)}get#b(){return this.id||"confirm-dialog"}};customElements.get("confirm-dialog-ui")||customElements.define("confirm-dialog-ui",Od);P();Ct();var eq=new Set(["active","trialing","past_due","canceled","paused"]),iq={active:"success",trialing:"info",past_due:"danger",canceled:"muted",paused:"warning"},sq={active:"Active",trialing:"Trialing",past_due:"Past due",canceled:"Canceled",paused:"Paused"},nq={update:"update-card",retry:"retry"};function mE(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 rq(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 ga=class extends x{static get properties(){return{account:{type:Object,default:null},variant:{type:String,default:"full",reflect:!0},currency:{type:String,default:"USD",reflect:!0},locale:{type:String,default:""},loading:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#p=null;#f=null;#m=null;#O=null;#g=null;#b=null;#y=null;#w=null;#v=null;#k=null;#S="";#x=!1;#A=0;async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#A;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let n=await i.json();if(e!==this.#A)return;this.loading=!1;let r=n&&typeof n=="object"&&n.account?n.account:n;this.account=r,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{account:r}}))}catch(i){if(e!==this.#A)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#E(),this.#P(),this.#I(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),this.#t&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;let t=this.account,e=!t&&!this.getAttribute("data-stream-src");e?this.setAttribute("empty",""):this.removeAttribute("empty"),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");let i=t?.status||"";if(i==="past_due"?this.setAttribute("past-due",""):this.removeAttribute("past-due"),i==="trialing"?this.setAttribute("trial",""):this.removeAttribute("trial"),i&&!eq.has(i)&&!this.#x&&(this.#x=!0,console.warn(`[billing-overview-ui] unknown account.status "${i}" \u2014 rendering default chrome.`)),e){this.#R(null),this.#$(null);return}if(!t){this.#R(null);return}this.#R(t),this.#T(t),this.#q(t),this.#Q(t),this.#N(t),this.#L(t),this.#$(t)}#E(){let t=this.querySelector(':scope > script[type="application/json"][data-account]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.account&&typeof e.account=="object"?e.account:e;this.account=i}}catch(e){console.warn("[billing-overview-ui] failed to parse <script data-account> JSON:",e?.message)}finally{t.remove()}}#C(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let n of i)e.appendChild(n)}#P(){this.#S=`bo-h-${Math.random().toString(36).slice(2,8)}`;let t=document.createElement("card-ui");t.setAttribute("data-header","");let e=document.createElement("header"),i=document.createElement("span");i.setAttribute("slot","icon");let n=document.createElement("avatar-ui");n.setAttribute("icon","credit-card"),i.appendChild(n);let r=document.createElement("span");r.setAttribute("slot","heading");let o=document.createElement("h2");o.id=this.#S,o.setAttribute("data-billing-plan-name",""),r.appendChild(o);let a=document.createElement("tag-ui");a.setAttribute("data-billing-status",""),a.setAttribute("size","md"),r.appendChild(a);let l=document.createElement("span");l.setAttribute("slot","description");let h=document.createElement("div");h.setAttribute("data-billing-plan-meta",""),l.appendChild(h);let c=document.createElement("span");c.setAttribute("slot","action");let u=document.createElement("div");u.setAttribute("data-header-actions",""),c.appendChild(u),e.append(i,r,l,c),t.appendChild(e),this.appendChild(t),this.#i=t,this.#s=o,this.#n=h,this.#r=a,this.#a=u,this.#C("header-actions",u);let d=document.createElement("section");d.setAttribute("data-kpis","");let f=(bt,xt,Ot)=>{let Et=document.createElement("card-ui");Et.setAttribute("data-kpi-card",bt);let Tt=document.createElement("section"),Ut=document.createElement("stat-ui");return Ut.setAttribute("data-kpi",bt),Ut.setAttribute("label",xt),Ut.setAttribute("value","\u2014"),Ut.setAttribute("icon",Ot),Tt.appendChild(Ut),Et.appendChild(Tt),[Et,Ut]},[p,m]=f("spend","Current month","credit-card"),[b,g]=f("seats","Seats","users-three"),[y,v]=f("next-invoice","Next invoice","calendar");d.append(p,b,y),this.appendChild(d),this.#o=d,this.#l=m,this.#c=g,this.#h=v;let w=document.createElement("section");w.setAttribute("data-dunning",""),w.setAttribute("hidden","");let k=document.createElement("alert-ui");k.setAttribute("pattern","dunning"),k.setAttribute("variant","danger"),w.appendChild(k),this.appendChild(w),this.#u=w,this.#d=k;let E=document.createElement("section");E.setAttribute("data-plan-picker","");let A=document.createElement("h3");A.setAttribute("data-section-heading",""),A.textContent="Plan";let C=document.createElement("plan-picker-ui");C.setAttribute("data-billing-plan-picker",""),C.setAttribute("name","billing-overview-plan"),E.append(A,C),this.appendChild(E),this.#p=E,this.#f=A,this.#m=C;let T=document.createElement("div");T.setAttribute("data-before-plan-picker",""),E.insertBefore(T,A),this.#C("before-plan-picker",T);let Q=document.createElement("section");Q.setAttribute("data-payment-methods","");let D=document.createElement("h3");D.setAttribute("data-section-heading",""),D.textContent="Payment methods";let R=document.createElement("payment-method-list-ui");R.setAttribute("data-billing-payment-methods",""),R.setAttribute("name","billing-overview-payment-method"),Q.append(D,R),this.appendChild(Q),this.#O=Q,this.#g=D,this.#b=R;let _=document.createElement("section");_.setAttribute("data-invoice-history","");let V=document.createElement("h3");V.setAttribute("data-section-heading",""),V.textContent="Invoice history";let U=document.createElement("invoice-history-ui");U.setAttribute("data-billing-invoice-history",""),_.append(V,U),this.appendChild(_),this.#y=_,this.#w=V,this.#v=U;let J=document.createElement("div");J.setAttribute("data-after-invoice-history",""),_.appendChild(J),this.#C("after-invoice-history",J);let nt=document.createElement("div");nt.setAttribute("data-empty","");let ut=document.createElement("p");ut.setAttribute("data-empty-heading",""),ut.textContent="No billing account loaded";let ot=document.createElement("p");ot.setAttribute("data-empty-description",""),ot.textContent="Pass an `account` snapshot or `data-stream-src` to render the dashboard.",nt.append(ut,ot),this.appendChild(nt),this.#k=nt,this.#C("empty",this)}#R(t){if(!this.#s||!this.#r||!this.#n)return;let e=t?.plan||null,i=e?.name?String(e.name):"Billing overview";this.#s.textContent!==i&&(this.#s.textContent=i);let n=this.#n;if(n.replaceChildren(),e&&Number.isFinite(e.price)){let o=e.currency||this.currency||"USD",a=this.#D(),l=e.cycle==="year"?"/yr":"/mo",h=document.createElement("span");h.setAttribute("data-plan-price",""),h.textContent=`${mE(e.price,o,a)} ${l}`,n.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`,n.appendChild(o)}let r=t?.status||"";if(!r)this.#r.setAttribute("hidden","");else{this.#r.removeAttribute("hidden");let o=iq[r]||"default",a=sq[r]||r;this.#r.getAttribute("variant")!==o&&this.#r.setAttribute("variant",o),this.#r.getAttribute("text")!==a&&this.#r.setAttribute("text",a),this.#r.setAttribute("aria-label",`Account status: ${a}`)}}#T(t){if(!this.#l||!this.#c||!this.#h)return;let e=t?.plan?.currency||this.currency||"USD",i=this.#D();if(Number.isFinite(t?.currentSpend)?this.#l.setAttribute("value",mE(t.currentSpend,e,i)):this.#l.setAttribute("value","\u2014"),t?.seats&&Number.isFinite(t.seats.used)){let n=t.seats.used,r=Number.isFinite(t.seats.total)?t.seats.total:null;this.#c.setAttribute("value",r!=null?`${n} / ${r}`:String(n))}else this.#c.setAttribute("value","\u2014");t?.nextInvoiceDate?this.#h.setAttribute("value",rq(t.nextInvoiceDate,i)):this.#h.setAttribute("value","\u2014");for(let n of[this.#l,this.#c,this.#h])this.loading?n.setAttribute("loading",""):n.removeAttribute("loading")}#q(t){if(!this.#u||!this.#d)return;let e=t?.dunning||null;if(!(t?.status==="past_due")||!e){this.#u.setAttribute("hidden","");return}this.#u.removeAttribute("hidden");let n=Number.isFinite(e.amount)?e.amount:null,r=e.currency||t?.plan?.currency||this.currency||"USD";if(n!=null?this.#d.setAttribute("amount",String(n)):this.#d.removeAttribute("amount"),this.#d.setAttribute("currency",r),e.dueAt&&this.#d.setAttribute("due-at",String(e.dueAt)),e.cardLast4&&this.#d.setAttribute("card-last4",String(e.cardLast4)),e.reason&&this.#d.setAttribute("reason",String(e.reason)),!this.#d.querySelector(':scope > [slot="actions"]')){let o=document.createElement("button-ui");o.setAttribute("slot","actions"),o.setAttribute("data-dunning-action","update"),o.setAttribute("variant","primary"),o.setAttribute("text","Update payment method"),this.#d.appendChild(o);let a=document.createElement("button-ui");a.setAttribute("slot","actions"),a.setAttribute("data-dunning-action","retry"),a.setAttribute("variant","outline"),a.setAttribute("text","Retry charge"),this.#d.appendChild(a)}}#Q(t){if(!this.#p||!this.#m)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.#m.plans=t.plans,t?.plan?.id&&this.#m.setAttribute("current",String(t.plan.id)),this.loading?this.#m.setAttribute("loading",""):this.#m.removeAttribute("loading")}#N(t){if(!this.#b)return;let e=Array.isArray(t?.paymentMethods)?t.paymentMethods:[];this.#b.methods=e,this.loading?this.#b.setAttribute("loading",""):this.#b.removeAttribute("loading")}#L(t){if(!this.#v)return;let e=Array.isArray(t?.invoices)?t.invoices:[];this.#v.invoices=e;let i=t?.plan?.currency||this.currency||"USD";this.#v.setAttribute("currency",i),this.loading?this.#v.setAttribute("loading",""):this.#v.removeAttribute("loading")}#$(t){this.#S&&this.setAttribute("aria-labelledby",this.#S),!t&&!this.hasAttribute("aria-label")?this.setAttribute("aria-label","No billing account loaded"):t&&this.removeAttribute("aria-label")}#D(){return this.locale?this.locale:typeof document<"u"&&document.documentElement.lang||""}#I(){let t=u=>{let d=u.target?.closest?.("[data-account-action]");if(!d||!this.contains(d))return;let f=d.getAttribute("data-account-action")||"";f&&(u.stopPropagation(),this.#M(f,"header",{target:d}))};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=u=>{let d=u.detail?.action||"",f=nq[d]||d||"dunning";this.#M(f,"alert-dunning",u.detail)};this.addEventListener("dunning-action",e),this.#e.push(()=>this.removeEventListener("dunning-action",e));let i=u=>{let d=u.detail?.value??u.detail?.plan?.id??"";this.#M("select-plan","plan-picker",{planId:d,...u.detail})};this.addEventListener("plan-change",i),this.#e.push(()=>this.removeEventListener("plan-change",i));let n=u=>{!this.#m||!this.#m.contains(u.target)&&u.target!==this.#m||this.#M("select-plan","plan-picker",u.detail)};this.addEventListener("change",n),this.#e.push(()=>this.removeEventListener("change",n));let r=()=>{this.#M("add-payment-method","payment-method-list",null)};this.addEventListener("add",r),this.#e.push(()=>this.removeEventListener("add",r));let o=u=>{this.#M("remove-payment-method","payment-method-list",u.detail)};this.addEventListener("remove",o),this.#e.push(()=>this.removeEventListener("remove",o));let a=u=>{this.#M("set-default-payment-method","payment-method-list",u.detail)};this.addEventListener("select",a),this.#e.push(()=>this.removeEventListener("select",a));let l=u=>{this.#M("view-invoice","invoice-history",u.detail)};this.addEventListener("invoice-row-click",l),this.#e.push(()=>this.removeEventListener("invoice-row-click",l));let h=u=>{this.#M("download-invoice","invoice-history",u.detail)};this.addEventListener("invoice-export",h),this.#e.push(()=>this.removeEventListener("invoice-export",h));let c=u=>{let d=u.detail?.action||"invoice";this.#M(d,"invoice-history",u.detail)};this.addEventListener("invoice-action",c),this.#e.push(()=>this.removeEventListener("invoice-action",c))}#M(t,e,i){this.dispatchEvent(new CustomEvent("account-action",{bubbles:!0,detail:{action:t,source:e,payload:i||null}}))}};customElements.get("billing-overview-ui")||customElements.define("billing-overview-ui",ga);P();Ct();var oq=new Set(["draft","open","paid","past-due","void"]),aq={paid:"success",open:"info","past-due":"danger",void:"muted",draft:"neutral"},gE={paid:"Paid",open:"Open","past-due":"Past due",void:"Void",draft:"Draft"},lq=[{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"}],bE=["Number","Issued","Due","Amount","Currency","Status"];function OE(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 yE(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 vE(s,t){return(s||"/invoices/{number}").replace("{number}",encodeURIComponent(t?.number??"")).replace("{id}",encodeURIComponent(t?.id??""))}function Xe(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
|
|
429
|
+
`}#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 n=i.getAttribute("data-step-id")||"";if(!n)return;let r=this.#u(n),o=!!i.checked;r!==o&&this.#d(n,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 n=i.getAttribute("data-step-id")||"",r=i.getAttribute("data-href")||"";n&&this.dispatchEvent(new CustomEvent("onboarding-step-action",{bubbles:!0,detail:{id:n,href:r}}))}#c(t){t?.stopPropagation?.();let e=!this.collapsed;this.collapsed=e,e&&this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:"collapsed"}}))}#h(t){if(!t)return!1;let e=t.id;return e!=null&&Object.prototype.hasOwnProperty.call(this.value||{},e)?!!this.value[e]:!!t.done}#u(t){let i=(Array.isArray(this.items)?this.items:[]).find(n=>n&&String(n.id)===String(t));return this.#h(i)}#d(t,e,{emit:i=!0}={}){let n={...this.value||{},[t]:!!e};this.value=n,this.#w(),i&&e&&this.dispatchEvent(new CustomEvent("onboarding-step-complete",{bubbles:!0,detail:{id:t,value:n}}))}#p(){let t=Array.isArray(this.items)?this.items:[],e=t.length,i=0;for(let r of t)this.#h(r)&&i++;let n=e===0?0:Math.round(i/e*100);return{done:i,total:e,percent:n}}#f(){let{done:t,total:e}=this.#p();return e>0&&t===e}#m(){this.#f()?this.setAttribute("data-complete",""):this.removeAttribute("data-complete")}#O(){let t=this.#f();t&&!this.#s?(this.#s=!0,this.dispatchEvent(new CustomEvent("onboarding-complete",{bubbles:!0,detail:{value:this.value}})),this["dismiss-on-complete"]&&(this.setAttribute("hidden",""),this.dispatchEvent(new CustomEvent("onboarding-dismiss",{bubbles:!0,detail:{reason:"complete"}})))):t||(this.#s=!1)}#g(){}#b(){if(this.#i||this.storage==="none"||!this["storage-key"]||typeof window>"u")return null;try{return this.storage==="session"?window.sessionStorage:window.localStorage}catch{return null}}#y(){let t=this.#b();if(!t)return null;try{let e=t.getItem(this["storage-key"]);if(!e)return null;let i=JSON.parse(e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}#w(){let t=this.#b();if(t)try{t.setItem(this["storage-key"],JSON.stringify(this.value||{}))}catch{}}complete(t){if(t==null)return;let e=String(t);this.#u(e)||this.#d(e,!0,{emit:!0})}reset(t){if(t==null){this.value={};let i=this.#b();try{i?.removeItem(this["storage-key"])}catch{}this.#s=!1,this.removeAttribute("hidden");return}let e=String(t);Object.prototype.hasOwnProperty.call(this.value||{},e)&&this.#d(e,!1,{emit:!1})}progress(){return this.#p()}};customElements.get("onboarding-checklist-ui")||customElements.define("onboarding-checklist-ui",rh);P();Ct();var gO=new Set(["","comfortable","compact","spacious"]),bO=new Set(["2","3","4","5","6"]),cE=new Set(["","2","2:1","3:2","3:1"]),OO=["toolbar","kpis","charts","table","aside"],md=class extends x{static get properties(){return{density:{type:String,default:"",reflect:!0},"kpi-columns":{type:String,default:"4",reflect:!0,attribute:"kpi-columns"},"chart-split":{type:String,default:"",reflect:!0,attribute:"chart-split"},loading:{type:Boolean,default:!1,reflect:!0},gap:{type:String,default:"",reflect:!0}}}static template=()=>null;#t={toolbar:!1,kpis:!1,charts:!1,table:!1,aside:!1};#e=null;#i=!1;setDensity(t){let e=gO.has(t)?t:"";this.density!==e&&(this.density=e)}getRegion(t){return OO.includes(t)?this.querySelector(`:scope > [slot="${t}"]`):null}connected(){this.hasAttribute("role")||this.setAttribute("role","region"),F(()=>this.#s()),this.#n(),this.#r(),this.#a(),this.#e=new MutationObserver(t=>this.#o(t)),this.#e.observe(this,{childList:!0})}disconnected(){this.#e&&(this.#e.disconnect(),this.#e=null)}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!this.#i){if(t==="density"&&e!==i){if(!gO.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&&!bO.has(i)){console.warn(`[dashboard-layout-ui] kpi-columns="${i}" out of range \u2014 falling back to "4". Use one of: ${[...bO].join(", ")}.`),this.#i=!0;try{this["kpi-columns"]="4"}finally{this.#i=!1}}return}if(t==="chart-split"&&e!==i){if(i!=null&&!cE.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.#n();return}if(t==="gap"&&e!==i){this.#r();return}}}#s(){if(!gO.has(this.density)){this.#i=!0;try{this.density=""}finally{this.#i=!1}}if(!bO.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(!cE.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}}}#n(){this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy")}#r(){let t=(this.gap||"").trim();if(t===""){this.style.removeProperty("--dashboard-layout-gap");return}/^[1-6]$/.test(t)?this.style.setProperty("--dashboard-layout-gap",`var(--a-space-${t})`):this.style.setProperty("--dashboard-layout-gap",t)}#a(){for(let t of OO)this.#t[t]=!!this.querySelector(`:scope > [slot="${t}"]`)}#o(t){for(let e of OO){let i=this.#t[e],n=!!this.querySelector(`:scope > [slot="${e}"]`);i&&!n&&this.dispatchEvent(new CustomEvent("region-empty",{bubbles:!0,detail:{region:e}})),this.#t[e]=n}}};customElements.get("dashboard-layout-ui")||customElements.define("dashboard-layout-ui",md);Ct();var Gs=new Set,uE=!1;function dE(s){return String(s).padStart(2,"0")}function gd(s){return`${s.getFullYear()}-${dE(s.getMonth()+1)}-${dE(s.getDate())}`}function fE(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 pE={today:"Today","7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days",qtd:"Quarter to date",ytd:"Year to date",custom:"Custom"},Ks=new Set(Object.keys(pE));function oh(s,t=new Date){let e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=gd(e),n=r=>{let o=new Date(e);return o.setDate(o.getDate()-r),gd(o)};switch(s){case"today":return{from:i,to:i};case"7d":return{from:n(6),to:i};case"30d":return{from:n(29),to:i};case"90d":return{from:n(89),to:i};case"qtd":{let r=Math.floor(e.getMonth()/3)*3;return{from:gd(new Date(e.getFullYear(),r,1)),to:i}}case"ytd":return{from:gd(new Date(e.getFullYear(),0,1)),to:i};case"custom":return null;default:return null}}function tq(s,t){let e=fE(s),i=fE(t);if(!e||!i)return"";let n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=e.getFullYear()===i.getFullYear(),o=r&&e.getMonth()===i.getMonth();return r&&e.getMonth()===i.getMonth()&&e.getDate()===i.getDate()?`${n[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`:o?`${n[e.getMonth()]} ${e.getDate()} \u2013 ${i.getDate()}, ${i.getFullYear()}`:r?`${n[e.getMonth()]} ${e.getDate()} \u2013 ${n[i.getMonth()]} ${i.getDate()}, ${i.getFullYear()}`:`${n[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()} \u2013 ${n[i.getMonth()]} ${i.getDate()}, ${i.getFullYear()}`}var bd=class s extends M{static labelDeprecated=!0;static get properties(){return{...M.properties,value:{type:String,default:"7d",reflect:!0},from:{type:String,default:"",reflect:!0},to:{type:String,default:"",reflect:!0},presets:{type:String,default:"today,7d,30d,90d,qtd,ytd,custom"},broadcast:{type:String,default:"document",reflect:!0},ariaLabelAttr:{type:String,default:"Time period",attribute:"aria-label",reflect:!0},pickerOpen:{type:Boolean,default:!1,attribute:"picker-open",reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r={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 r=this.#f(e,i);this.#d("custom",r.from,r.to);return}if(!Ks.has(t)){console.warn(`[date-range-selector-ui] unknown preset "${t}" \u2014 ignored. Use one of: ${[...Ks].join(", ")}.`);return}let n=oh(t);n&&this.#d(t,n.from,n.to)}getRange(){return{value:this.value,preset:this.value,from:this.from,to:this.to}}subscribe(t){let e=this.#O();return e?(e.addEventListener("range-change",t),()=>e.removeEventListener("range-change",t)):()=>{}}connected(){super.connected(),this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.ariaLabelAttr||"Time period"),this.#t||(this.#c(),this.#u(),this.#t=!0),this.broadcast==="document"&&this.#y(),F(()=>{let t=this.#m();t&&this.#d(this.value,t.from,t.to,{initial:!0})})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0,this.#w()}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#o)){if(t==="presets"){this.#h();return}if(t==="broadcast"){e==="document"&&i!=="document"&&this.#w(),i==="document"?(this.#y(),this.#b()):i==="self"&&this.#b();return}if(t==="value"&&e!==i&&i&&Ks.has(i)){if(i!=="custom"){let n=oh(i);n&&this.#d(i,n.from,n.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.#n){let t=tq(this.from,this.to);this.#n.textContent=t,this.#n.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.#r.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.#r.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.#n=i,this.#r.readout=i,this.#h()}#h(){if(!this.#i)return;let t=(this.presets||"").split(",").map(i=>i.trim()).filter(Boolean),e=this.#i.querySelector(":scope > [data-indicator]");this.#i.replaceChildren(),e&&this.#i.appendChild(e);for(let i of t){if(!Ks.has(i)){s.#l.has(this)||(s.#l.add(this),console.warn(`[date-range-selector-ui] unknown preset key "${i}" in [presets] \u2014 ignored. Use one of: ${[...Ks].join(", ")}.`));continue}let n=document.createElement("segment-ui");n.setAttribute("value",i),n.setAttribute("text",pE[i]),this.#i.appendChild(n)}this.#i.value=this.value}#u(){let t=r=>{let o=r.detail?.value;if(!o||!Ks.has(o))return;if(r.stopPropagation(),o==="custom"){this.#v(),this.#p("custom");return}let a=oh(o);a&&this.#d(o,a.from,a.to)};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=r=>{r.stopPropagation();let a=(r.detail||{}).value||null;if(!a||!a.from||!a.to)return;let l=this.#f(a.from,a.to);this.#d("custom",l.from,l.to)};this.#s.addEventListener("change",e),this.#e.push(()=>this.#s.removeEventListener("change",e));let i=()=>{this.pickerOpen=!0},n=()=>{this.pickerOpen=!1};this.#s.addEventListener("open",i),this.#s.addEventListener("close",n),this.#e.push(()=>this.#s.removeEventListener("open",i)),this.#e.push(()=>this.#s.removeEventListener("close",n))}#d(t,e,i,n={}){if(this.from===e&&this.to===i&&this.value===t&&!n.initial)return;this.#o=!0;try{this.from=e,this.to=i,this.value=t}finally{this.#o=!1}this.syncValue(),this.#b();let o={value:t,from:e,to:i,preset:t};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,from:e,to:i}}));let a=this.#O();a&&a.dispatchEvent(new CustomEvent("range-change",{bubbles:a===this,detail:o}))}#p(t){if(this.value!==t){this.#o=!0;try{this.value=t}finally{this.#o=!1}}}#f(t,e){return t<=e?{from:t,to:e}:{from:e,to:t}}#m(){if(this.value==="custom")return this.from&&this.to?this.#f(this.from,this.to):oh("7d");let t=Ks.has(this.value)?this.value:"7d";return oh(t)}#O(){return this.broadcast==="document"?document:this.broadcast==="self"?this:null}#g(){return this.broadcast==="document"?document.documentElement:this.broadcast==="self"?this:null}#b(){let t=this.#g();t&&(this.broadcast==="document"&&!this.#a||(this.from?t.setAttribute("data-range-from",this.from):t.removeAttribute("data-range-from"),this.to?t.setAttribute("data-range-to",this.to):t.removeAttribute("data-range-to")))}#y(){if(Gs.size>0&&!Gs.has(this)){uE||(uE=!0,console.warn('[date-range-selector-ui] multiple instances with broadcast="document" on the same page; only the first writes data-range-from / data-range-to to <html>. Use broadcast="self" for secondary instances. See SPEC-019 \xA76 nesting rules.')),this.#a=!1,Gs.add(this);return}Gs.add(this),this.#a=!0}#w(){if(Gs.has(this)&&(Gs.delete(this),this.#a)){document.documentElement.removeAttribute("data-range-from"),document.documentElement.removeAttribute("data-range-to"),this.#a=!1;let t=Gs.values().next().value;t&&(t.#a=!0,t.#b())}}#v(){this.#s&&(typeof this.#s.openPopover=="function"?this.#s.openPopover():this.#s.open=!0)}};customElements.get("date-range-selector-ui")||customElements.define("date-range-selector-ui",bd);P();var Od=class extends x{static properties={open:{type:Boolean,default:!1,reflect:!0},title:{type:String,default:"",reflect:!0},description:{type:String,default:"",reflect:!0},confirmText:{type:String,default:"Confirm",reflect:!0,attribute:"confirm-text"},cancelText:{type:String,default:"Cancel",reflect:!0,attribute:"cancel-text"},confirmVariant:{type:String,default:"primary",reflect:!0,attribute:"confirm-variant"},size:{type:String,default:"sm",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},icon:{type:String,default:"",reflect:!0}};static template=()=>null;#t=null;#e=null;#i=null;#s=null;#n=null;#r=null;#a=null;#o=null;#l=null;#c=null;#h=[];#u=!1;#d="";#p="";#f=!1;connected(){this.#u||(this.#d=`${this.#b}-title`,this.#p=`${this.#b}-desc`,this.#m(),this.#O(),this.#u=!0)}disconnected(){for(let t of this.#h)try{t()}catch{}this.#h.length=0}show(){this.open=!0}hide(){this.open=!1}render(){if(!this.#u)return;this.#t&&(this.#t.setAttribute("size",this.size||"sm"),this.#t.open=!!this.open),this.#s&&(this.#s.id=this.#d,this.#s.textContent=this.title||""),this.#r&&(this.#r.id=this.#p,this.#r.textContent=this.description||"",this.#r.hidden=!this.description),this.#i&&(this.querySelector(':scope > [slot="icon"]')?this.#i.hidden=!0:this.icon?(this.#i.hidden=!1,this.#i.setAttribute("name",this.icon)):this.#i.hidden=!0);let t=this.#t?.querySelector(':scope > [slot="dialog"]');t&&(t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),this.title?t.setAttribute("aria-labelledby",this.#d):t.removeAttribute("aria-labelledby"),this.description?t.setAttribute("aria-describedby",this.#p):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.#g()}#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 n=document.createElement("text-ui");n.setAttribute("slot","heading"),n.id=this.#d,this.title&&(n.textContent=this.title),e.appendChild(n),this.#s=n,this.#e=e;let r=document.createElement("text-ui");r.setAttribute("slot","description"),r.id=this.#p,this.description?r.textContent=this.description:r.hidden=!0,e.appendChild(r),this.#r=r;let o=document.createElement("section");o.setAttribute("slot","body");let a=document.createElement("div");a.setAttribute("data-extra",""),o.appendChild(a),this.#a=a,this.#n=o;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(o),t.appendChild(l),this.appendChild(t),this.#t=t}#O(){let t=n=>{this.loading||(n.stopPropagation(),this.#f=!0,this.dispatchEvent(new CustomEvent("confirm",{bubbles:!0,detail:{}})))};this.#c.addEventListener("press",t),this.#h.push(()=>this.#c.removeEventListener("press",t));let e=n=>{this.loading||(n.stopPropagation(),this.#f=!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=n=>{n.stopPropagation(),this.open=!1,this.#f||this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,detail:{}})),this.#f=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,detail:{}}))};this.#t.addEventListener("close",i),this.#h.push(()=>this.#t.removeEventListener("close",i))}#g(){let t=()=>{if(!(!this.open||!this.#l||this.loading))try{this.#l.focus()}catch{}};typeof requestAnimationFrame=="function"?requestAnimationFrame(t):queueMicrotask(t)}get#b(){return this.id||"confirm-dialog"}};customElements.get("confirm-dialog-ui")||customElements.define("confirm-dialog-ui",Od);P();Ct();var eq=new Set(["active","trialing","past_due","canceled","paused"]),iq={active:"success",trialing:"info",past_due:"danger",canceled:"muted",paused:"warning"},sq={active:"Active",trialing:"Trialing",past_due:"Past due",canceled:"Canceled",paused:"Paused"},nq={update:"update-card",retry:"retry"};function mE(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 rq(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 ga=class extends x{static get properties(){return{account:{type:Object,default:null},variant:{type:String,default:"full",reflect:!0},currency:{type:String,default:"USD",reflect:!0},locale:{type:String,default:""},loading:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#p=null;#f=null;#m=null;#O=null;#g=null;#b=null;#y=null;#w=null;#v=null;#k=null;#S="";#x=!1;#A=0;async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#A;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let n=await i.json();if(e!==this.#A)return;this.loading=!1;let r=n&&typeof n=="object"&&n.account?n.account:n;this.account=r,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{account:r}}))}catch(i){if(e!==this.#A)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#E(),this.#$(),this.#I(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),this.#t&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;let t=this.account,e=!t&&!this.getAttribute("data-stream-src");e?this.setAttribute("empty",""):this.removeAttribute("empty"),this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");let i=t?.status||"";if(i==="past_due"?this.setAttribute("past-due",""):this.removeAttribute("past-due"),i==="trialing"?this.setAttribute("trial",""):this.removeAttribute("trial"),i&&!eq.has(i)&&!this.#x&&(this.#x=!0,console.warn(`[billing-overview-ui] unknown account.status "${i}" \u2014 rendering default chrome.`)),e){this.#L(null),this.#Q(null);return}if(!t){this.#L(null);return}this.#L(t),this.#P(t),this.#q(t),this.#T(t),this.#N(t),this.#M(t),this.#Q(t)}#E(){let t=this.querySelector(':scope > script[type="application/json"][data-account]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.account&&typeof e.account=="object"?e.account:e;this.account=i}}catch(e){console.warn("[billing-overview-ui] failed to parse <script data-account> JSON:",e?.message)}finally{t.remove()}}#C(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let n of i)e.appendChild(n)}#$(){this.#S=`bo-h-${Math.random().toString(36).slice(2,8)}`;let t=document.createElement("card-ui");t.setAttribute("data-header","");let e=document.createElement("header"),i=document.createElement("span");i.setAttribute("slot","icon");let n=document.createElement("avatar-ui");n.setAttribute("icon","credit-card"),i.appendChild(n);let r=document.createElement("span");r.setAttribute("slot","heading");let o=document.createElement("h2");o.id=this.#S,o.setAttribute("data-billing-plan-name",""),r.appendChild(o);let a=document.createElement("tag-ui");a.setAttribute("data-billing-status",""),a.setAttribute("size","md"),r.appendChild(a);let l=document.createElement("span");l.setAttribute("slot","description");let h=document.createElement("div");h.setAttribute("data-billing-plan-meta",""),l.appendChild(h);let c=document.createElement("span");c.setAttribute("slot","action");let u=document.createElement("div");u.setAttribute("data-header-actions",""),c.appendChild(u),e.append(i,r,l,c),t.appendChild(e),this.appendChild(t),this.#i=t,this.#s=o,this.#n=h,this.#r=a,this.#a=u,this.#C("header-actions",u);let d=document.createElement("section");d.setAttribute("data-kpis","");let f=(bt,xt,Ot)=>{let Et=document.createElement("card-ui");Et.setAttribute("data-kpi-card",bt);let Tt=document.createElement("section"),Ut=document.createElement("stat-ui");return Ut.setAttribute("data-kpi",bt),Ut.setAttribute("label",xt),Ut.setAttribute("value","\u2014"),Ut.setAttribute("icon",Ot),Tt.appendChild(Ut),Et.appendChild(Tt),[Et,Ut]},[p,m]=f("spend","Current month","credit-card"),[b,g]=f("seats","Seats","users-three"),[y,v]=f("next-invoice","Next invoice","calendar");d.append(p,b,y),this.appendChild(d),this.#o=d,this.#l=m,this.#c=g,this.#h=v;let w=document.createElement("section");w.setAttribute("data-dunning",""),w.setAttribute("hidden","");let k=document.createElement("alert-ui");k.setAttribute("pattern","dunning"),k.setAttribute("variant","danger"),w.appendChild(k),this.appendChild(w),this.#u=w,this.#d=k;let E=document.createElement("section");E.setAttribute("data-plan-picker","");let A=document.createElement("h3");A.setAttribute("data-section-heading",""),A.textContent="Plan";let C=document.createElement("plan-picker-ui");C.setAttribute("data-billing-plan-picker",""),C.setAttribute("name","billing-overview-plan"),E.append(A,C),this.appendChild(E),this.#p=E,this.#f=A,this.#m=C;let T=document.createElement("div");T.setAttribute("data-before-plan-picker",""),E.insertBefore(T,A),this.#C("before-plan-picker",T);let Q=document.createElement("section");Q.setAttribute("data-payment-methods","");let D=document.createElement("h3");D.setAttribute("data-section-heading",""),D.textContent="Payment methods";let R=document.createElement("payment-method-list-ui");R.setAttribute("data-billing-payment-methods",""),R.setAttribute("name","billing-overview-payment-method"),Q.append(D,R),this.appendChild(Q),this.#O=Q,this.#g=D,this.#b=R;let _=document.createElement("section");_.setAttribute("data-invoice-history","");let V=document.createElement("h3");V.setAttribute("data-section-heading",""),V.textContent="Invoice history";let U=document.createElement("invoice-history-ui");U.setAttribute("data-billing-invoice-history",""),_.append(V,U),this.appendChild(_),this.#y=_,this.#w=V,this.#v=U;let J=document.createElement("div");J.setAttribute("data-after-invoice-history",""),_.appendChild(J),this.#C("after-invoice-history",J);let nt=document.createElement("div");nt.setAttribute("data-empty","");let ut=document.createElement("p");ut.setAttribute("data-empty-heading",""),ut.textContent="No billing account loaded";let ot=document.createElement("p");ot.setAttribute("data-empty-description",""),ot.textContent="Pass an `account` snapshot or `data-stream-src` to render the dashboard.",nt.append(ut,ot),this.appendChild(nt),this.#k=nt,this.#C("empty",this)}#L(t){if(!this.#s||!this.#r||!this.#n)return;let e=t?.plan||null,i=e?.name?String(e.name):"Billing overview";this.#s.textContent!==i&&(this.#s.textContent=i);let n=this.#n;if(n.replaceChildren(),e&&Number.isFinite(e.price)){let o=e.currency||this.currency||"USD",a=this.#D(),l=e.cycle==="year"?"/yr":"/mo",h=document.createElement("span");h.setAttribute("data-plan-price",""),h.textContent=`${mE(e.price,o,a)} ${l}`,n.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`,n.appendChild(o)}let r=t?.status||"";if(!r)this.#r.setAttribute("hidden","");else{this.#r.removeAttribute("hidden");let o=iq[r]||"default",a=sq[r]||r;this.#r.getAttribute("variant")!==o&&this.#r.setAttribute("variant",o),this.#r.getAttribute("text")!==a&&this.#r.setAttribute("text",a),this.#r.setAttribute("aria-label",`Account status: ${a}`)}}#P(t){if(!this.#l||!this.#c||!this.#h)return;let e=t?.plan?.currency||this.currency||"USD",i=this.#D();if(Number.isFinite(t?.currentSpend)?this.#l.setAttribute("value",mE(t.currentSpend,e,i)):this.#l.setAttribute("value","\u2014"),t?.seats&&Number.isFinite(t.seats.used)){let n=t.seats.used,r=Number.isFinite(t.seats.total)?t.seats.total:null;this.#c.setAttribute("value",r!=null?`${n} / ${r}`:String(n))}else this.#c.setAttribute("value","\u2014");t?.nextInvoiceDate?this.#h.setAttribute("value",rq(t.nextInvoiceDate,i)):this.#h.setAttribute("value","\u2014");for(let n of[this.#l,this.#c,this.#h])this.loading?n.setAttribute("loading",""):n.removeAttribute("loading")}#q(t){if(!this.#u||!this.#d)return;let e=t?.dunning||null;if(!(t?.status==="past_due")||!e){this.#u.setAttribute("hidden","");return}this.#u.removeAttribute("hidden");let n=Number.isFinite(e.amount)?e.amount:null,r=e.currency||t?.plan?.currency||this.currency||"USD";if(n!=null?this.#d.setAttribute("amount",String(n)):this.#d.removeAttribute("amount"),this.#d.setAttribute("currency",r),e.dueAt&&this.#d.setAttribute("due-at",String(e.dueAt)),e.cardLast4&&this.#d.setAttribute("card-last4",String(e.cardLast4)),e.reason&&this.#d.setAttribute("reason",String(e.reason)),!this.#d.querySelector(':scope > [slot="actions"]')){let o=document.createElement("button-ui");o.setAttribute("slot","actions"),o.setAttribute("data-dunning-action","update"),o.setAttribute("variant","primary"),o.setAttribute("text","Update payment method"),this.#d.appendChild(o);let a=document.createElement("button-ui");a.setAttribute("slot","actions"),a.setAttribute("data-dunning-action","retry"),a.setAttribute("variant","outline"),a.setAttribute("text","Retry charge"),this.#d.appendChild(a)}}#T(t){if(!this.#p||!this.#m)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.#m.plans=t.plans,t?.plan?.id&&this.#m.setAttribute("current",String(t.plan.id)),this.loading?this.#m.setAttribute("loading",""):this.#m.removeAttribute("loading")}#N(t){if(!this.#b)return;let e=Array.isArray(t?.paymentMethods)?t.paymentMethods:[];this.#b.methods=e,this.loading?this.#b.setAttribute("loading",""):this.#b.removeAttribute("loading")}#M(t){if(!this.#v)return;let e=Array.isArray(t?.invoices)?t.invoices:[];this.#v.invoices=e;let i=t?.plan?.currency||this.currency||"USD";this.#v.setAttribute("currency",i),this.loading?this.#v.setAttribute("loading",""):this.#v.removeAttribute("loading")}#Q(t){this.#S&&this.setAttribute("aria-labelledby",this.#S),!t&&!this.hasAttribute("aria-label")?this.setAttribute("aria-label","No billing account loaded"):t&&this.removeAttribute("aria-label")}#D(){return this.locale?this.locale:typeof document<"u"&&document.documentElement.lang||""}#I(){let t=u=>{let d=u.target?.closest?.("[data-account-action]");if(!d||!this.contains(d))return;let f=d.getAttribute("data-account-action")||"";f&&(u.stopPropagation(),this.#R(f,"header",{target:d}))};this.addEventListener("press",t),this.addEventListener("click",t),this.#e.push(()=>this.removeEventListener("press",t)),this.#e.push(()=>this.removeEventListener("click",t));let e=u=>{let d=u.detail?.action||"",f=nq[d]||d||"dunning";this.#R(f,"alert-dunning",u.detail)};this.addEventListener("dunning-action",e),this.#e.push(()=>this.removeEventListener("dunning-action",e));let i=u=>{let d=u.detail?.value??u.detail?.plan?.id??"";this.#R("select-plan","plan-picker",{planId:d,...u.detail})};this.addEventListener("plan-change",i),this.#e.push(()=>this.removeEventListener("plan-change",i));let n=u=>{!this.#m||!this.#m.contains(u.target)&&u.target!==this.#m||this.#R("select-plan","plan-picker",u.detail)};this.addEventListener("change",n),this.#e.push(()=>this.removeEventListener("change",n));let r=()=>{this.#R("add-payment-method","payment-method-list",null)};this.addEventListener("add",r),this.#e.push(()=>this.removeEventListener("add",r));let o=u=>{this.#R("remove-payment-method","payment-method-list",u.detail)};this.addEventListener("remove",o),this.#e.push(()=>this.removeEventListener("remove",o));let a=u=>{this.#R("set-default-payment-method","payment-method-list",u.detail)};this.addEventListener("select",a),this.#e.push(()=>this.removeEventListener("select",a));let l=u=>{this.#R("view-invoice","invoice-history",u.detail)};this.addEventListener("invoice-row-click",l),this.#e.push(()=>this.removeEventListener("invoice-row-click",l));let h=u=>{this.#R("download-invoice","invoice-history",u.detail)};this.addEventListener("invoice-export",h),this.#e.push(()=>this.removeEventListener("invoice-export",h));let c=u=>{let d=u.detail?.action||"invoice";this.#R(d,"invoice-history",u.detail)};this.addEventListener("invoice-action",c),this.#e.push(()=>this.removeEventListener("invoice-action",c))}#R(t,e,i){this.dispatchEvent(new CustomEvent("account-action",{bubbles:!0,detail:{action:t,source:e,payload:i||null}}))}};customElements.get("billing-overview-ui")||customElements.define("billing-overview-ui",ga);P();Ct();var oq=new Set(["draft","open","paid","past-due","void"]),aq={paid:"success",open:"info","past-due":"danger",void:"muted",draft:"neutral"},gE={paid:"Paid",open:"Open","past-due":"Past due",void:"Void",draft:"Draft"},lq=[{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"}],bE=["Number","Issued","Due","Amount","Currency","Status"];function OE(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 yE(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 vE(s,t){return(s||"/invoices/{number}").replace("{number}",encodeURIComponent(t?.number??"")).replace("{id}",encodeURIComponent(t?.id??""))}function Xe(s){let t=String(s??"");return t.includes(",")||t.includes('"')||t.includes(`
|
|
430
430
|
`)?'"'+t.replace(/"/g,'""')+'"':t}var ba=class extends x{static properties={invoices:{type:Array,default:[]},currency:{type:String,default:"USD",reflect:!0},density:{type:String,default:"standard",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},selectable:{type:Boolean,default:!1,reflect:!0},hrefPattern:{type:String,default:"/invoices/{number}",reflect:!0,attribute:"href-pattern"},paginate:{type:Number,default:25,reflect:!0},exportable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""},filter:{type:String,default:"",reflect:!0}};static template=()=>null;static requiredIcons=["download-simple","receipt","magnifying-glass"];#t=!1;#e=[];#i=null;#s=null;#n=null;#r=null;#a=null;#o=null;#l=null;#c=!1;#h=0;#u=!1;setFilter(t){let e=t||"";return e&&!oq.has(e)?!1:F(()=>{if(this.filter===e)return!0;let i=this.filter;return this.filter=e,this.dispatchEvent(new CustomEvent("invoice-filter-change",{bubbles:!0,detail:{filter:e,previous:i}})),!0})}exportCsv(){let t=this.#m(),e=[bE.join(",")];for(let n of t){let r=[Xe(n.number??""),Xe(n.issuedAt??""),Xe(n.dueAt??""),Xe(Number.isFinite(n.amount)?n.amount:""),Xe(n.currency||this.currency||"USD"),Xe(n.status??"")];e.push(r.join(","))}let i=e.join(`\r
|
|
431
431
|
`);return new Blob([i],{type:"text/csv;charset=utf-8;"})}getSelected(){if(!this.#o)return[];let t=this.#o.selected||[],e=this.#m();return t.map(i=>e[i]).filter(Boolean)}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#h;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let n=await i.json();if(e!==this.#h)return;this.removeAttribute("loading");let r=Array.isArray(n)?n:Array.isArray(n?.invoices)?n.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("role","region"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Invoice history"),this.#t||(this.#d(),this.#p(),this.#g(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){super.disconnected?.();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#c)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}render(){if(!this.#t)return;(Array.isArray(this.invoices)?this.invoices:[]).length===0&&!this.loading?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#f(),this.#o&&(this.#o.columns=this.#O(),this.#o.data=this.#m(),this.#o.density!==this.density&&(this.#o.density=this.density),!!this.#o.loading!=!!this.loading&&(this.#o.loading=!!this.loading),Number(this.#o.paginate||0)!==Number(this.paginate||0)&&(this.#o.paginate=Number(this.paginate||0)),!!this.#o.selectable!=!!this.selectable&&(this.#o.selectable=!!this.selectable)),this.#s&&this.#s.setAttribute("count",String(this.#m().length)),this.#r&&(this.#r.hidden=!this.exportable)}#d(){let t=this.querySelector(':scope > script[type="application/json"][data-invoices]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.invoices=e)}catch(e){console.warn("[invoice-history-ui] failed to parse <script data-invoices> JSON:",e?.message)}finally{t.remove()}}#p(){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 r=document.createElement("table-toolbar-ui");r.setAttribute("data-default-toolbar",""),r.setAttribute("text","Invoices");let o=document.createElement("div");o.setAttribute("data-invoice-filter",""),o.setAttribute("role","group"),o.setAttribute("aria-label","Filter invoices by status"),o.setAttribute("slot","actions"),r.appendChild(o);let a=document.createElement("button-ui");a.setAttribute("data-export",""),a.setAttribute("slot","actions"),a.setAttribute("variant","outline"),a.setAttribute("size","sm"),a.setAttribute("text","Export CSV"),a.setAttribute("icon","download-simple"),r.appendChild(a),t.appendChild(r),this.#s=r,this.#n=o,this.#r=a}let i=document.createElement("div");i.setAttribute("data-table-host",""),this.appendChild(i),this.#a=i;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",""),i.appendChild(n),this.#o=n,this.#s&&this.#s.setAttribute("for",n.id),!this.querySelector(':scope > [slot="empty"]')){let r=document.createElement("empty-state-ui");r.setAttribute("data-empty",""),r.setAttribute("icon","receipt"),r.setAttribute("heading","No invoices yet"),r.setAttribute("description","Invoices will appear here once issued."),this.appendChild(r),this.#l=r}}#f(){if(!this.#n)return;if(this.#n.children.length===0)for(let e of lq){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.#n.appendChild(i)}let t=this.filter||"";for(let e of this.#n.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}#O(){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=>yE(i,t)},{key:"dueAt",label:"Due",sortable:!0,format:i=>yE(i,t)},{key:"amount",label:"Amount",sortable:!0,align:"end",render:(i,n,r)=>{let o=n?.currency||e,a=document.createElement("span");return a.setAttribute("data-invoice-amount",""),a.textContent=OE(i,o,t),r.dataset.align="end",a},format:(i,n)=>OE(i,n?.currency||e,t)},{key:"status",label:"Status",sortable:!0,render:i=>{let n=String(i||"").toLowerCase(),r=aq[n]||"neutral",o=gE[n]||(i?String(i):"\u2014"),a=document.createElement("badge-ui");return a.setAttribute("data-invoice-status",""),a.setAttribute("variant",r),a.setAttribute("text",o),a.setAttribute("aria-label",o),a},format:i=>gE[String(i||"").toLowerCase()]||(i?String(i):"")},{key:"actions",label:"",sortable:!1,align:"end",accessor:i=>i,render:(i,n)=>{let r=document.createElement("span");r.setAttribute("data-invoice-actions","");let o=document.createElement("button-ui");o.setAttribute("data-invoice-action","view"),o.setAttribute("data-invoice-id",String(n?.id??n?.number??"")),o.setAttribute("size","sm"),o.setAttribute("variant","ghost"),o.setAttribute("text","View"),r.appendChild(o);let a=document.createElement("button-ui");return a.setAttribute("data-invoice-action","download"),a.setAttribute("data-invoice-id",String(n?.id??n?.number??"")),a.setAttribute("size","sm"),a.setAttribute("variant","ghost"),a.setAttribute("icon","download-simple"),a.setAttribute("aria-label",`Download invoice ${n?.number??""}`),r.appendChild(a),r}}]}#g(){let t=o=>{let a=o.target?.closest?.("[data-filter-chip]");if(!a||!this.#n?.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=vE(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=vE(this.hrefPattern,c),d=new CustomEvent("invoice-row-click",{bubbles:!0,cancelable:!0,detail:{invoice:c,href:u}});if(this.dispatchEvent(d)&&typeof window<"u"&&window.location?.assign)try{window.location.assign(u)}catch{}}else if(l==="download"){let u=this.#b(c);this.dispatchEvent(new CustomEvent("invoice-export",{bubbles:!0,cancelable:!0,detail:{blob:u,rowCount:1,invoice:c}}))}}};this.addEventListener("press",i),this.addEventListener("click",i),this.#e.push(()=>this.removeEventListener("press",i)),this.#e.push(()=>this.removeEventListener("click",i));let n=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",n),this.addEventListener("click",n),this.#e.push(()=>this.removeEventListener("press",n)),this.#e.push(()=>this.removeEventListener("click",n));let r=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",r),this.#e.push(()=>this.removeEventListener("select",r))}#b(t){let e=[bE.join(","),[Xe(t.number??""),Xe(t.issuedAt??""),Xe(t.dueAt??""),Xe(Number.isFinite(t.amount)?t.amount:""),Xe(t.currency||this.currency||"USD"),Xe(t.status??"")].join(",")];return new Blob([e.join(`\r
|
|
432
|
-
`)],{type:"text/csv;charset=utf-8;"})}};customElements.get("invoice-history-ui")||customElements.define("invoice-history-ui",ba);P();Ct();var hq=new Set(["draft","open","paid","past-due","void"]),cq={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},uq={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function yd(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 xE(s,t){if(!s)return"";try{let e=new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"numeric"}).format(e)}catch{return String(s)}}var Oa=class extends x{static get properties(){return{invoice:{type:Object,default:null},status:{type:String,default:"draft",reflect:!0},currency:{type:String,default:"USD",reflect:!0},density:{type:String,default:"standard",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},printable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#p=null;#f=null;#m="";#O=!1;#g=!1;#b=0;#y="";print(){if(typeof globalThis.window?.print=="function"){try{globalThis.window.print()}catch(t){this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable",message:String(t?.message||t)}}))}return}this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable"}}))}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#b;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let n=await i.json();if(e!==this.#b)return;this.loading=!1;let r=n&&typeof n=="object"&&n.invoice?n.invoice:n;if(this.invoice=r,r?.status){this.#O=!0;try{this.status=String(r.status)}finally{this.#O=!1}}let o=r?.number||"";this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{invoiceNumber:o}})),this.#y=o}catch(i){if(e!==this.#b)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#w(),this.#k(),this.#P(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#O)&&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 n=(this.hasAttribute("status")?this.getAttribute("status"):"")||t?.status||this.status||"draft";if(hq.has(n)||this.#g||(this.#g=!0,console.warn(`[invoice-detail-ui] unknown status "${n}" \u2014 rendering default badge.`)),e){this.#S(null,n),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#S(null,n);return}this.#S(t,n),this.#x(t),this.#A(t),this.#E(t),this.#C(t)}#w(){let t=this.querySelector(':scope > script[type="application/json"][data-invoice]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.invoice&&typeof e.invoice=="object"?e.invoice:e;if(this.invoice=i,i?.status){this.#O=!0;try{this.status=String(i.status)}finally{this.#O=!1}}}}catch(e){console.warn("[invoice-detail-ui] failed to parse <script data-invoice> JSON:",e?.message)}finally{t.remove()}}#v(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let n of i)e.appendChild(n)}#k(){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 n=document.createElement("tag-ui");n.setAttribute("data-invoice-status",""),n.setAttribute("size","md"),e.appendChild(n);let r=document.createElement("div");r.setAttribute("data-header-meta","");let o=document.createElement("div");o.setAttribute("data-header-actions",""),o.setAttribute("data-invoice-actions",""),t.append(e,r,o),this.appendChild(t),this.#i=t,this.#s=i,this.#n=n,this.#r=r,this.#a=o,this.#v("header-actions",o);let a=document.createElement("section");a.setAttribute("data-parties","");let l=document.createElement("div");l.setAttribute("data-customer","");let h=document.createElement("div");h.setAttribute("data-customer-default",""),l.appendChild(h),this.#l=h;let c=document.createElement("div");c.setAttribute("data-remit-to","");let u=document.createElement("div");u.setAttribute("data-remit-to-default",""),c.appendChild(u),this.#c=u,a.append(l,c),this.appendChild(a),this.#o=a,this.#v("customer-block",l),this.#v("remit-to-block",c);let d=document.createElement("section");d.setAttribute("data-lines","");let f=document.createElement("card-ui");f.setAttribute("data-lines-card",""),f.setAttribute("padding","none");let p=document.createElement("section");p.setAttribute("bleed",""),f.appendChild(p);let m=document.createElement("table-ui");m.setAttribute("data-lines-table",""),m.setAttribute("density",this.density||"standard"),p.appendChild(m),d.appendChild(f),this.appendChild(d),this.#h=d,this.#u=m;let b=document.createElement("section");b.setAttribute("data-totals",""),this.appendChild(b),this.#d=b;let g=document.createElement("footer");g.setAttribute("data-footer","");let y=document.createElement("div");y.setAttribute("data-footer-notes",""),g.appendChild(y),this.appendChild(g),this.#p=g,this.#v("footer",g);let v=document.createElement("empty-state-ui");v.setAttribute("data-empty",""),v.setAttribute("icon","receipt"),v.setAttribute("heading","No invoice loaded"),v.setAttribute("description","Pass an `invoice` record or `data-stream-src` to render an invoice."),this.appendChild(v),this.#f=v}#S(t,e){if(!this.#s||!this.#n||!this.#r)return;let i=t?.number?String(t.number):"";this.#s.textContent!==i&&(this.#s.textContent=i);let n=cq[e]||"default",r=uq[e]||(e?String(e):"Draft");if(this.#n.getAttribute("variant")!==n&&this.#n.setAttribute("variant",n),this.#n.getAttribute("text")!==r&&this.#n.setAttribute("text",r),this.#n.setAttribute("aria-label",`Status: ${r}`),t?this.#n.removeAttribute("hidden"):this.#n.setAttribute("hidden",""),this.#r.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 ${xE(t.issuedAt,o)}`,this.#r.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${xE(t.dueAt,o)}`,this.#r.appendChild(a)}}#x(t){if(!(!this.#l||!this.#c)){if(this.#l.replaceChildren(),t?.customer){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Billed to",this.#l.appendChild(e),t.customer.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.customer.name),this.#l.appendChild(i)}if(t.customer.email){let i=document.createElement("div");i.setAttribute("data-party-email",""),i.textContent=String(t.customer.email),this.#l.appendChild(i)}if(t.customer.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.customer.address),this.#l.appendChild(i)}}if(this.#c.replaceChildren(),t?.remitTo){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Remit to",this.#c.appendChild(e),t.remitTo.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.remitTo.name),this.#c.appendChild(i)}if(t.remitTo.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.remitTo.address),this.#c.appendChild(i)}}}}#A(t){if(!this.#u)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");this.#u.columns=[{key:"description",label:"Description",flex:1},{key:"qty",label:"Qty",width:80,format:r=>String(r??"")},{key:"unitAmount",label:"Unit",width:120,format:r=>yd(r,e,i)},{key:"amount",label:"Amount",width:140,format:r=>yd(r,e,i)}];let n=Array.isArray(t?.lines)?t.lines:[];this.#u.data=n.map((r,o)=>({__row:o,description:r?.description??"",qty:r?.qty??"",unitAmount:r?.unitAmount??0,amount:r?.amount??0})),this.#u.getAttribute("density")!==this.density&&this.#u.setAttribute("density",this.density||"standard")}#E(t){if(!this.#d)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(this.#d.replaceChildren(),!t)return;let n=[{key:"subtotal",label:"Subtotal",value:t.subtotal},{key:"tax",label:"Tax",value:t.tax}];Number.isFinite(t.discount)&&t.discount>0&&n.push({key:"discount",label:"Discount",value:-Math.abs(t.discount)});for(let r of n){if(!Number.isFinite(r.value))continue;let o=document.createElement("div");o.setAttribute("data-totals-row",""),o.setAttribute("data-totals-key",r.key);let a=document.createElement("span");a.setAttribute("data-totals-label",""),a.textContent=r.label;let l=document.createElement("span");l.setAttribute("data-totals-value",""),l.textContent=yd(r.value,e,i),o.append(a,l),this.#d.appendChild(o)}if(Number.isFinite(t.total)){let r=document.createElement("div");r.setAttribute("data-totals-row",""),r.setAttribute("data-totals-key","total"),r.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=yd(t.total,e,i),r.append(o,a),this.#d.appendChild(r)}}#C(t){t&&this.#m&&this.setAttribute("aria-labelledby",this.#m)}#P(){let t=i=>{let n=i.target?.closest?.("[data-invoice-action]");if(!n||!this.contains(n))return;let r=n.getAttribute("data-invoice-action")||"";if(!r)return;let o=this.invoice?.number||"";i.stopPropagation(),this.dispatchEvent(new CustomEvent("invoice-action",{bubbles:!0,detail:{action:r,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 r=(i.composedPath?i.composedPath():[]).find(l=>l?.getAttribute&&l.getAttribute("data-row")!=null);if(!r||!this.#h.contains(r))return;let o=Number(r.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",Oa);Ct();var dq=[{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 vd(s){if(!s)return"unknown";for(let{brand:t,re:e}of dq)if(e.test(s))return t;return"unknown"}function xd(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function oG(s,t){return s?t==="amex"?s.replace(/^(\d{0,4})(\d{0,6})(\d{0,5}).*$/,(e,i,n,r)=>[i,n,r].filter(Boolean).join(" ")):s.match(/.{1,4}/g)?.join(" ")??"":""}function SE(s){if(!s||s.length<12)return!1;let t=0,e=!1;for(let i=s.length-1;i>=0;i--){let n=s.charCodeAt(i)-48;if(n<0||n>9)return!1;e&&(n*=2,n>9&&(n-=9)),t+=n,e=!e}return t%10===0}function wE(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 kE(s){let t=wE(s);if(!t)return"expiry-format";let{month:e,year:i}=t;if(e<1||e>12)return"expiry-month";let n=new Date,r=n.getFullYear(),o=n.getMonth()+1;return i<r||i===r&&e<o?"expiry-past":i>r+50?"expiry-far":null}function AE(s,t){let e=String(s||"").replace(/\D+/g,""),i=t==="amex"?4:3;return e.length!==i?"cvc-length":null}function fq(s){let t=Math.random().toString(36).slice(2);return`pm_local_${Date.now().toString(36)}_${t}_${String(s).slice(0,4)}`}var pq=["US","CA","GB","DE","FR","AU"],mq={US:"United States",CA:"Canada",GB:"United Kingdom",DE:"Germany",FR:"France",AU:"Australia",JP:"Japan",ES:"Spain",IT:"Italy",NL:"Netherlands",SE:"Sweden",IE:"Ireland",SG:"Singapore",IN:"India",BR:"Brazil",MX:"Mexico"};function gq(s){return mq[s]||s}var ya=class extends M{static labelDeprecated=!1;static get properties(){return{...M.properties,name:{type:String,default:"paymentMethod",reflect:!0},value:{type:String,default:"",reflect:!0},prefill:{type:String,default:"",attribute:"prefill"},countries:{type:Array,default:[]},defaultCountry:{type:String,default:"US",reflect:!0,attribute:"default-country"},requireBillingAddress:{type:Boolean,default:!1,reflect:!0,attribute:"require-billing-address"},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},autofocus:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r=null;#a={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#o={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#l="unknown";#c=!1;#h=null;#u=null;#d=!1;async tokenize(){if(this.#d)return Promise.reject(new Error("tokenize-inflight"));this.#d=!0,this.setAttribute("tokenizing","");try{let t=this.#A();if(!t.ok){let n=new Error(t.message);throw n.code=t.code,n.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"),n}let e=t.detail;this.#c=!0;try{this.value=fq(e.last4)}finally{this.#c=!1}this.syncValue(),this.removeAttribute("aria-invalid");let i={token:this.value,...e};return this.dispatchEvent(new CustomEvent("submit-payment-method",{bubbles:!0,detail:i})),i}finally{this.removeAttribute("tokenizing"),this.#d=!1}}reset(){F(()=>{for(let t of Object.keys(this.#o)){let e=this.#o[t];e&&(e.value="",e.removeAttribute("error"))}this.#o.country&&(this.#o.country.value=this.defaultCountry||"US"),this.#c=!0;try{this.value="",this.error=""}finally{this.#c=!1}this.syncValue(),this.#l="unknown",this.removeAttribute("aria-invalid"),this.removeAttribute("error"),this.#S()})}syncValue(t){this.internals.setFormValue(this.value||""),this.required&&!this.value?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Payment method required.",this):this.internals.setValidity({})}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment method form"),this.#t||(this.#p(),this.#O(),this.#t=!0),F(()=>this.render()),this.autofocus&&requestAnimationFrame(()=>{this.#o.name?.focus?.()})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#c)){if(t==="prefill"&&e!==i)this.render();else if(t==="disabled"&&e!==i)this.#w();else if(t==="error"&&e!==i)this.#v();else if(t==="require-billing-address"&&e!==i)this.#y();else if(t==="default-country"&&e!==i){let n=this.#o.country;n&&!n.value&&(n.value=i||"US")}}}render(){this.#t&&(this.#b(),this.#y(),this.#w(),this.#v(),this.#k(),this.#S())}#p(){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 n=document.createElement("div");n.setAttribute("data-summary-text",""),e.appendChild(n);let r=document.createElement("button-ui");r.setAttribute("data-summary-edit",""),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("text","Edit card"),e.appendChild(r),this.appendChild(e),this.#s=e,this.#n=r;let o=document.createElement("div");o.setAttribute("data-grid",""),this.appendChild(o),this.#r=o,this.#a.name=this.#f("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.#f("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.#f("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.#f("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.#f("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.#f("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.#f("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.#f("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)}#f(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 n;if(e.kind==="select"){if(n=document.createElement("select-ui"),Array.isArray(e.seedOptions))for(let r of e.seedOptions){let o=document.createElement("option");o.value=r.value,o.textContent=r.label,e.seedValue&&r.value===e.seedValue&&o.setAttribute("selected",""),n.appendChild(o)}}else n=document.createElement("input-ui");n.setAttribute("name",t),n.setAttribute("data-control",t),e.required&&n.setAttribute("required","");for(let[r,o]of Object.entries(e.input||{}))o==null||o===""||n.setAttribute(r,String(o));return i.appendChild(n),this.#r.appendChild(i),i}#m(){return(Array.isArray(this.countries)&&this.countries.length>0?this.countries:pq).map(e=>({value:e,label:gq(e)}))}#O(){let t=n=>{if(!this.#o.cardNumber||n.target!==this.#o.cardNumber)return;let r=String(this.#o.cardNumber.value||""),o=xd(r),a=vd(o);a!==this.#l&&(this.#l=a,this.#S()),this.#g()};this.addEventListener("input",t),this.#e.push(()=>this.removeEventListener("input",t));let e=n=>{n.target!==this&&this.#g()};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.#r&&(this.#r.hidden=!1))};this.#n.addEventListener("click",i),this.#n.addEventListener("press",i),this.#e.push(()=>{this.#n.removeEventListener("click",i),this.#n.removeEventListener("press",i)})}#g(){let t=xd(this.#o.cardNumber?.value),e=vd(t),i=this.#x();this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{valid:i.ok,brand:e}}))}#b(){let t=this.#o.country;if(!t)return;let e=this.#m();Array.isArray(t.options)&&t.options.length===e.length&&t.options.every((n,r)=>n?.value===e[r].value&&n?.label===e[r].label)||(t.options=e),t.value||(t.value=this.defaultCountry||e[0]?.value||"US")}#y(){let t=!!this.requireBillingAddress;this.#a.addressLine1&&(this.#a.addressLine1.hidden=!t),this.#a.addressLine2&&(this.#a.addressLine2.hidden=!t)}#w(){let t=!!this.disabled;for(let e of Object.values(this.#o))e&&(t?e.setAttribute("disabled",""):e.removeAttribute("disabled"))}#v(){if(!this.#i)return;let t=this.error||"";t?(this.#i.setAttribute("text",t),this.#i.hidden=!1,this.setAttribute("aria-invalid","true")):(this.#i.removeAttribute("text"),this.#i.hidden=!0,this.removeAttribute("aria-invalid"))}#k(){if(!this.#s)return;let t=this.#E();if(!t||this.hasAttribute("prefilled-dismissed")){this.#s.hidden=!0,this.#r&&(this.#r.hidden=!1),this.removeAttribute("prefilled");return}let e=this.#s.querySelector(":scope > [data-summary-text]");if(e){let i=(t.brand||"Card").toUpperCase(),n=t.last4||"\u2022\u2022\u2022\u2022",r=t.expMonth&&t.expYear?` \xB7 expires ${String(t.expMonth).padStart(2,"0")}/${String(t.expYear).slice(-2)}`:"";e.textContent=`${i} ending in ${n}${r}`}this.#s.hidden=!1,this.#r&&(this.#r.hidden=!0),this.setAttribute("prefilled","")}#S(){let t=this.#o.cardNumber;if(!t)return;let e=t.querySelector(":scope > [data-brand-badge]");if(!e)return;if(this.#l==="unknown"||!this.#l){e.replaceChildren();return}let i=e.querySelector(":scope > [data-brand]");if(i&&i.getAttribute("data-brand")===this.#l)return;e.replaceChildren();let n=document.createElement("span");n.setAttribute("data-brand",this.#l),n.textContent=this.#l.toUpperCase(),e.appendChild(n)}#x(){let t=xd(this.#o.cardNumber?.value);return t?SE(t)?kE(this.#o.expiry?.value)?{ok:!1}:AE(this.#o.cvc?.value,vd(t))?{ok:!1}:(this.#o.name?.value||"").trim()?(this.#o.postalCode?.value||"").trim()?{ok:!0}:{ok:!1}:{ok:!1}:{ok:!1}:{ok:!1}}#A(){for(let d of Object.values(this.#o))d?.removeAttribute?.("error");let t=String(this.#o.name?.value||"").trim();if(!t)return this.#o.name?.setAttribute("error","Name on card is required."),{ok:!1,message:"Name on card is required.",code:"validation-failed",field:"name"};let e=this.#o.cardNumber?.value||"",i=xd(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(!SE(i))return this.#o.cardNumber?.setAttribute("error","Card number is invalid."),{ok:!1,message:"Card number is invalid.",code:"card-invalid",field:"cardNumber"};let n=kE(this.#o.expiry?.value||"");if(n){let d=n==="expiry-past"?"Card has expired.":n==="expiry-month"?"Expiry month must be 01-12.":n==="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:n==="expiry-past"?"expired":"validation-failed",field:"expiry"}}let r=vd(i);if(AE(this.#o.cvc?.value||"",r)){let f=`CVC must be ${r==="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=wE(this.#o.expiry.value);return{ok:!0,detail:{last4:i.slice(-4),brand:r,expMonth:h.month,expYear:h.year,name:t,country:a}}}#E(){let t=this.prefill||this.getAttribute("prefill")||"";if(!t)return null;try{let e=JSON.parse(t);return!e||typeof e!="object"?null:e}catch{return null}}};customElements.get("payment-method-form-ui")||customElements.define("payment-method-form-ui",ya);Ct();var bq=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),EE=new Set(["card","bank","wallet"]),CE={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},Oq={card:"credit-card",bank:"bank",wallet:"credit-card"},$E={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 PE(s){let t=(s?.brand||"").toLowerCase();if(CE[t])return CE[t];let e=(s?.type||"card").toLowerCase();return Oq[e]||"credit-card"}function QE(s){let t=(s?.brand||"").toLowerCase();if($E[t])return $E[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function yO(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=QE(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function vO(s){let t=(s?.expiry||"").trim();if(!t)return"";let e="",i="",n=t.match(/^(\d{1,2})\/(\d{2}|\d{4})$/);if(n)e=n[1].padStart(2,"0"),i=n[2].length===4?n[2].slice(-2):n[2];else{let r=t.match(/^(\d{4})-(\d{2})-\d{2}$/);r&&(i=r[1].slice(-2),e=r[2])}return!e||!i?"":`Expires ${e}/${i}`}var va=class extends M{static get properties(){return{...M.properties,methods:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},"add-label":{type:String,default:"Add payment method",attribute:"add-label"},"add-icon":{type:String,default:"plus",attribute:"add-icon"},"no-add":{type:Boolean,default:!1,reflect:!0,attribute:"no-add"},"no-remove":{type:Boolean,default:!1,reflect:!0,attribute:"no-remove"},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r=null;#a=new Map;#o=!1;setDefault(t){return t?F(()=>{let e=(this.methods||[]).find(n=>n.id===t);if(!e)return!1;if(this.value===t)return!0;let i=this.value||"";this.#o=!0;try{this.value=t}finally{this.#o=!1}return this.syncValue(),this.#m(t,i,e),!0}):!1}remove(t){return t?F(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(n=>n.id===t);if(i<0)return!1;if(e.splice(i,1),this.methods=e,this.value===t){let n=e[0]?.id||"";this.#o=!0;try{this.value=n}finally{this.#o=!1}this.syncValue()}return!0}):!1}add(t){!t||!t.id||F(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(n=>n.id===t.id);if(i>=0?e[i]=t:e.push(t),this.methods=e,t.default){let n=this.value||"";this.#o=!0;try{this.value=t.id}finally{this.#o=!1}this.syncValue(),n!==t.id&&this.#m(t.id,n,t)}})}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment methods"),this.#t||(this.#c(),this.#h(),this.#f(),this.#t=!0),F(()=>this.render())}disconnected(){super.disconnected?.();for(let t of this.#e)try{t()}catch{}this.#e.length=0}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.methods)?this.methods:[],e=this.#l(t);if(e&&this.value!==e){this.#o=!0;try{this.value=e}finally{this.#o=!1}this.syncValue()}if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#n&&(this.#n.hidden=!!this["no-add"]),this.#r){this.#r.setAttribute("text",this["add-label"]||"Add payment method");let i=this["add-icon"]||"plus";i?this.#r.setAttribute("icon",i):this.#r.removeAttribute("icon"),this.disabled?this.#r.setAttribute("disabled",""):this.#r.removeAttribute("disabled")}this.#u(t)}#l(t){if(!t.length)return"";if(this.value&&t.some(i=>i.id===this.value))return this.value;let e=t.find(i=>i.default);return e?e.id:t[0].id||""}#c(){let t=this.querySelector(':scope > script[type="application/json"][data-methods]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.methods=e)}catch(e){console.warn("[payment-method-list-ui] failed to parse <script data-methods> JSON:",e?.message)}finally{t.remove()}}#h(){let t=document.createElement("div");if(t.setAttribute("data-rows",""),t.setAttribute("role","presentation"),this.appendChild(t),this.#i=t,!this.querySelector(':scope > [slot="empty"]')){let i=document.createElement("empty-state-ui");i.setAttribute("data-empty",""),i.setAttribute("icon","credit-card"),i.setAttribute("heading","No payment methods"),i.setAttribute("description","Add a method to get started."),this.appendChild(i),this.#s=i}let e=document.createElement("div");if(e.setAttribute("data-add",""),this.appendChild(e),this.#n=e,!this.querySelector(':scope > [slot="add"]')){let i=document.createElement("button-ui");i.setAttribute("data-add-cta",""),i.setAttribute("variant","outline"),i.setAttribute("icon",this["add-icon"]||"plus"),i.setAttribute("text",this["add-label"]||"Add payment method"),e.appendChild(i),this.#r=i}}#u(t){if(!this.#i)return;let e=new Map;for(let i of t){if(!i?.id)continue;let n=this.#a.get(i.id);n||(n=this.#d(i),this.#i.appendChild(n)),this.#p(n,i),e.set(i.id,n)}for(let[i,n]of this.#a)if(!e.has(i))try{n.remove()}catch{}for(let i of t){let n=e.get(i.id);n&&this.#i.appendChild(n)}this.#a=e}#d(t){let e=document.createElement("card-ui");e.setAttribute("data-row",""),e.setAttribute("role","radio"),e.setAttribute("tabindex","0");let i=document.createElement("header"),n=document.createElement("span");n.setAttribute("slot","icon");let r=document.createElement("icon-ui");r.setAttribute("aria-hidden","true"),n.appendChild(r);let o=document.createElement("span");o.setAttribute("slot","heading");let a=document.createElement("span");a.setAttribute("data-primary","");let l=document.createElement("tag-ui");l.setAttribute("data-default-tag",""),l.setAttribute("text","Default"),l.setAttribute("variant","success"),l.setAttribute("size","sm"),l.setAttribute("hidden",""),o.appendChild(a),o.appendChild(l);let h=document.createElement("p");h.setAttribute("slot","description"),h.setAttribute("data-secondary","");let c=document.createElement("span");c.setAttribute("slot","action");let u=document.createElement("button-ui");u.setAttribute("data-action","set-default"),u.setAttribute("variant","ghost"),u.setAttribute("size","sm"),u.setAttribute("text","Set default");let d=document.createElement("button-ui");d.setAttribute("data-action","edit"),d.setAttribute("variant","ghost"),d.setAttribute("size","sm"),d.setAttribute("icon","pencil"),d.setAttribute("aria-label","Edit payment method");let f=document.createElement("button-ui");return f.setAttribute("data-action","remove"),f.setAttribute("variant","ghost"),f.setAttribute("size","sm"),f.setAttribute("icon","trash"),f.setAttribute("aria-label","Remove payment method"),c.appendChild(u),c.appendChild(d),c.appendChild(f),i.appendChild(n),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 n=(e?.type||"card").toLowerCase();EE.has(n)&&t.setAttribute("data-type",n);let r=e.id===this.value;r?(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=PE(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=yO(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=vO(e);l.textContent=m,m?l.removeAttribute("hidden"):l.setAttribute("hidden","")}let h=t.querySelector(':scope > header > [slot="heading"] > [data-default-tag]');h&&(r?h.removeAttribute("hidden"):h.setAttribute("hidden",""));let c=vO(e),u=[yO(e)];c&&u.push(c),r&&u.push("default"),t.setAttribute("aria-label",u.join(", "));let d=t.querySelector(':scope > header > [slot="action"] > [data-action="set-default"]');d&&(r?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"))}#f(){let t=n=>{let r=n.target?.closest?.("button-ui[data-action]");if(r&&this.#i.contains(r)){let a=r.closest("[data-row]");if(!a)return;let l=a.getAttribute("data-id")||"";if(!l)return;if(this.disabled||r.hasAttribute("disabled")){n.stopPropagation();return}let h=(this.methods||[]).find(u=>u.id===l);if(!h)return;let c=r.getAttribute("data-action");n.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=n.target?.closest?.("button-ui[data-add-cta]");if(o&&this.#n?.contains(o)){if(this.disabled||o.hasAttribute("disabled")){n.stopPropagation();return}n.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=n=>{if(n.target?.closest?.("button-ui[data-action]")||n.target?.closest?.("button-ui[data-add-cta]"))return;let r=n.target?.closest?.("[data-row]");if(!r||!this.#i.contains(r))return;let o=r.getAttribute("data-id")||"";o&&(this.disabled||this.setDefault(o))};this.#i.addEventListener("click",e),this.#e.push(()=>this.#i.removeEventListener("click",e));let i=n=>{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(n.key==="ArrowDown"||n.key==="ArrowRight")n.preventDefault(),a[(l+1)%a.length]?.focus?.();else if(n.key==="ArrowUp"||n.key==="ArrowLeft")n.preventDefault(),a[(l-1+a.length)%a.length]?.focus?.();else if(n.key==="Home")n.preventDefault(),a[0]?.focus?.();else if(n.key==="End")n.preventDefault(),a[a.length-1]?.focus?.();else if(n.key===" "||n.key==="Enter"){n.preventDefault();let h=o.getAttribute("data-id")||"";h&&!this.disabled&&this.setDefault(h)}}};this.#i.addEventListener("keydown",i),this.#e.push(()=>this.#i.removeEventListener("keydown",i))}#m(t,e,i){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,method:i}}))}};customElements.get("payment-method-list-ui")||customElements.define("payment-method-list-ui",va);Ct();var Sd=new Set(["monthly","annual"]),yq={monthly:"Monthly",annual:"Annual"},vq={monthly:"/month",annual:"/year"};function xq(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 Sq(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(n=>n.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 xa=class extends M{static labelDeprecated=!0;static get properties(){return{...M.properties,plans:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},current:{type:String,default:"",reflect:!0},cycle:{type:String,default:"monthly",reflect:!0},cycleToggle:{type:Boolean,default:!1,reflect:!0,attribute:"cycle-toggle"},currency:{type:String,default:"USD"},locale:{type:String,default:""},layout:{type:String,default:"grid",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r=null;#a=null;#o=new Map;#l=!1;#c=!1;#h=!1;#u=0;setValue(t){return t?F(()=>{let e=(this.plans||[]).find(n=>n.id===t);if(!e)return!1;if(e.disabled)return this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}})),!1;if(this.value===t)return!0;let i=this.value||"";return this.value=t,this.syncValue(),this.#y(t,i),!0}):!1}setCycle(t){return Sd.has(t)?F(()=>{if(this.cycle===t)return!0;let e=this.cycle;return this.cycle=t,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:t,previous:e}})),!0}):!1}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#u;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let n=await i.json();if(e!==this.#u)return;this.removeAttribute("loading");let r=Array.isArray(n)?n:Array.isArray(n?.plans)?n.plans:[];this.plans=r,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:r.length}}))}catch(i){if(e!==this.#u)return;this.removeAttribute("loading"),this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Choose a plan"),this.#t||(this.#d(),this.#p(),this.#b(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#l)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.plans)?this.plans:[];if(!Sd.has(this.cycle)){this.#c||(this.#c=!0,console.warn(`[plan-picker-ui] unknown cycle "${this.cycle}" \u2014 coercing to "monthly".`)),this.#l=!0;try{this.cycle="monthly"}finally{this.#l=!1}}let e=t.filter(n=>n.recommended);e.length>1&&!this.#h&&(this.#h=!0,console.warn(`[plan-picker-ui] ${e.length} plans carry recommended:true \u2014 using the first ("${e[0].id}"); ignoring the rest.`));let i=e[0]?.id||"";if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#i){let n=this.cycleToggle&&t.length>0;this.#i.hidden=!n,n&&this.#f()}this.#m(t,i)}#d(){let t=this.querySelector(':scope > script[type="application/json"][data-plans]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.plans=e)}catch(e){console.warn("[plan-picker-ui] failed to parse <script data-plans> JSON:",e?.message)}finally{t.remove()}}#p(){let t=document.createElement("div");t.setAttribute("data-toggle",""),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("div");e.setAttribute("data-plans",""),e.setAttribute("role","presentation"),this.appendChild(e),this.#n=e;let i=document.createElement("div");if(i.setAttribute("data-skeleton",""),i.hidden=!0,this.appendChild(i),this.#r=i,!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.#a=n}}#f(){if(!this.#i)return;let t=this.#s;if(!t){t=document.createElement("segmented-ui"),t.setAttribute("aria-label","Billing cycle"),this.#i.appendChild(t),this.#s=t;for(let e of["monthly","annual"]){let i=document.createElement("segment-ui");i.setAttribute("value",e),i.setAttribute("text",yq[e]),t.appendChild(i)}}t.value!==this.cycle&&(t.value=this.cycle)}#m(t,e){if(!this.#n)return;let i=new Map;for(let n of t){if(!n?.id)continue;let r=this.#o.get(n.id);r||(r=document.createElement("option-card-ui"),r.setAttribute("layout","tile"),this.#n.appendChild(r)),this.#O(r,n,e),i.set(n.id,r)}for(let[n,r]of this.#o)if(!i.has(n))try{r.remove()}catch{}for(let n of t){let r=i.get(n.id);r&&this.#n.appendChild(r)}this.#o=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 n=!!(this.current&&e.id===this.current),r=e.id===i;n?t.setAttribute("data-current",""):t.removeAttribute("data-current"),r?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&&n?t.setAttribute("checked",""):t.removeAttribute("checked");let a=t.querySelector(":scope > [data-plan-body]");a||(a=document.createElement("div"),a.setAttribute("data-plan-body",""),t.appendChild(a)),this.#g(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(),n){let h=document.createElement("tag-ui");h.setAttribute("text","Current plan"),h.setAttribute("variant","muted"),l.appendChild(h)}else if(r){let h=document.createElement("tag-ui");h.setAttribute("text","Recommended"),h.setAttribute("variant","accent"),l.appendChild(h)}}#g(t,e){t.replaceChildren();let i=document.createElement("div");i.setAttribute("data-price-row","");let n=Sd.has(this.cycle)?this.cycle:"monthly",r=e.prices||{},o=r[n]||r.monthly||null;if(o){let l=document.createElement("span");l.setAttribute("data-price","");let h=o.currency||this.currency||"USD";l.textContent=xq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:vq[n];c.textContent=u,i.appendChild(c)}else{let l=document.createElement("span");l.setAttribute("data-price",""),l.textContent="Contact sales",i.appendChild(l)}if(t.appendChild(i),o?.note){let l=document.createElement("span");l.setAttribute("data-price-note",""),l.textContent=o.note,t.appendChild(l)}if(Array.isArray(e.features)&&e.features.length){let l=document.createElement("ul");l.setAttribute("data-features","");for(let h of e.features){let c=document.createElement("li"),u=document.createElement("icon-ui");u.setAttribute("name","check"),u.setAttribute("aria-hidden","true"),c.appendChild(u);let d=document.createElement("span");d.textContent=String(h),c.appendChild(d),l.appendChild(c)}t.appendChild(l)}if(!!!(this.current&&e.id===this.current)||e.cta){let l=document.createElement("button-ui");l.setAttribute("data-cta",""),l.setAttribute("variant",e.recommended?"primary":"outline"),l.setAttribute("text",Sq(e,Array.isArray(this.plans)?this.plans:[],this.current)),(e.disabled||this.disabled)&&l.setAttribute("disabled",""),t.appendChild(l)}}#b(){let t=n=>{let r=n?.detail?.value;if(!Sd.has(r)||this.cycle===r)return;n.stopPropagation();let o=this.cycle;this.cycle=r,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:r,previous:o}}))};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=n=>{let r=n.target?.closest?.("option-card-ui");if(!r||!this.#n.contains(r))return;let o=r.getAttribute("value")||"";if(!o)return;let a=(this.plans||[]).find(h=>h.id===o);if(!a)return;if(a.disabled||this.disabled){r.removeAttribute("checked"),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}}));return}n.stopPropagation();let l=this.value||"";if(l!==o){this.#l=!0;try{this.value=o}finally{this.#l=!1}this.syncValue(),this.#y(o,l)}};this.#n.addEventListener("change",e),this.#e.push(()=>this.#n.removeEventListener("change",e));let i=n=>{let r=n.target?.closest?.("button-ui[data-cta]");if(!r||!this.#n.contains(r))return;let o=r.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;n.stopPropagation();let h=this.value||"";if(h!==a){this.#l=!0;try{this.value=a}finally{this.#l=!1}this.syncValue(),this.#y(a,h)}this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:a,cycle:this.cycle}}))};this.#n.addEventListener("press",i),this.#n.addEventListener("click",i),this.#e.push(()=>this.#n.removeEventListener("press",i)),this.#e.push(()=>this.#n.removeEventListener("click",i))}#y(t,e){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,cycle:this.cycle}}))}};customElements.get("plan-picker-ui")||customElements.define("plan-picker-ui",xa);P();var wq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),kq=6,ah=class extends x{static properties={integrations:{type:Array,default:[]},loading:{type:Boolean,default:!1,reflect:!0},"search-placeholder":{type:String,default:"Search integrations",reflect:!0},"group-by":{type:String,default:"category",reflect:!0},"status-filter":{type:String,default:"all",reflect:!0}};static template=t=>t._renderTemplate();#t="";#e=`intpage-h-${Math.random().toString(36).slice(2,8)}`;#i=null;attributeChangedCallback(t,e,i){if(t==="integrations"){if(i==null)this.integrations=[];else try{let n=JSON.parse(i);this.integrations=Array.isArray(n)?n:[]}catch{this.integrations=[]}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#e),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Integrations"),this.hasAttribute("integrations")&&!Array.isArray(this.integrations))try{this.integrations=JSON.parse(this.getAttribute("integrations"))}catch{this.integrations=[]}this.addEventListener("input",this.#u),this.addEventListener("change",this.#d)}disconnected(){this.removeEventListener("input",this.#u),this.removeEventListener("change",this.#d),this.#i&&(clearTimeout(this.#i),this.#i=null)}render(){this.#h()}_renderTemplate(){let t=this["search-placeholder"]||"Search integrations",e=this["status-filter"]||"all",i=!!this.loading,n=this.#l();return it`
|
|
432
|
+
`)],{type:"text/csv;charset=utf-8;"})}};customElements.get("invoice-history-ui")||customElements.define("invoice-history-ui",ba);P();Ct();var hq=new Set(["draft","open","paid","past-due","void"]),cq={draft:"default",open:"info",paid:"success","past-due":"warning",void:"default"},uq={draft:"Draft",open:"Open",paid:"Paid","past-due":"Past due",void:"Void"};function yd(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 xE(s,t){if(!s)return"";try{let e=new Date(s);return Number.isNaN(e.getTime())?String(s):new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"numeric"}).format(e)}catch{return String(s)}}var Oa=class extends x{static get properties(){return{invoice:{type:Object,default:null},status:{type:String,default:"draft",reflect:!0},currency:{type:String,default:"USD",reflect:!0},density:{type:String,default:"standard",reflect:!0},loading:{type:Boolean,default:!1,reflect:!0},printable:{type:Boolean,default:!0,reflect:!0},locale:{type:String,default:""}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r=null;#a=null;#o=null;#l=null;#c=null;#h=null;#u=null;#d=null;#p=null;#f=null;#m="";#O=!1;#g=!1;#b=0;#y="";print(){if(typeof globalThis.window?.print=="function"){try{globalThis.window.print()}catch(t){this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable",message:String(t?.message||t)}}))}return}this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"print-unavailable"}}))}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#b;this.loading=!0,this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let n=await i.json();if(e!==this.#b)return;this.loading=!1;let r=n&&typeof n=="object"&&n.invoice?n.invoice:n;if(this.invoice=r,r?.status){this.#O=!0;try{this.status=String(r.status)}finally{this.#O=!1}}let o=r?.number||"";this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{invoiceNumber:o}})),this.#y=o}catch(i){if(e!==this.#b)return;this.loading=!1,this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){this.setAttribute("role","region"),this.#t||(this.#w(),this.#k(),this.#$(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#O)&&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 n=(this.hasAttribute("status")?this.getAttribute("status"):"")||t?.status||this.status||"draft";if(hq.has(n)||this.#g||(this.#g=!0,console.warn(`[invoice-detail-ui] unknown status "${n}" \u2014 rendering default badge.`)),e){this.#S(null,n),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","No invoice loaded");return}if(!t){this.#S(null,n);return}this.#S(t,n),this.#x(t),this.#A(t),this.#E(t),this.#C(t)}#w(){let t=this.querySelector(':scope > script[type="application/json"][data-invoice]');if(t)try{let e=JSON.parse(t.textContent||"{}");if(e&&typeof e=="object"){let i=e.invoice&&typeof e.invoice=="object"?e.invoice:e;if(this.invoice=i,i?.status){this.#O=!0;try{this.status=String(i.status)}finally{this.#O=!1}}}}catch(e){console.warn("[invoice-detail-ui] failed to parse <script data-invoice> JSON:",e?.message)}finally{t.remove()}}#v(t,e){let i=this.querySelectorAll(`:scope > [slot="${t}"]`);for(let n of i)e.appendChild(n)}#k(){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 n=document.createElement("tag-ui");n.setAttribute("data-invoice-status",""),n.setAttribute("size","md"),e.appendChild(n);let r=document.createElement("div");r.setAttribute("data-header-meta","");let o=document.createElement("div");o.setAttribute("data-header-actions",""),o.setAttribute("data-invoice-actions",""),t.append(e,r,o),this.appendChild(t),this.#i=t,this.#s=i,this.#n=n,this.#r=r,this.#a=o,this.#v("header-actions",o);let a=document.createElement("section");a.setAttribute("data-parties","");let l=document.createElement("div");l.setAttribute("data-customer","");let h=document.createElement("div");h.setAttribute("data-customer-default",""),l.appendChild(h),this.#l=h;let c=document.createElement("div");c.setAttribute("data-remit-to","");let u=document.createElement("div");u.setAttribute("data-remit-to-default",""),c.appendChild(u),this.#c=u,a.append(l,c),this.appendChild(a),this.#o=a,this.#v("customer-block",l),this.#v("remit-to-block",c);let d=document.createElement("section");d.setAttribute("data-lines","");let f=document.createElement("card-ui");f.setAttribute("data-lines-card",""),f.setAttribute("padding","none");let p=document.createElement("section");p.setAttribute("bleed",""),f.appendChild(p);let m=document.createElement("table-ui");m.setAttribute("data-lines-table",""),m.setAttribute("density",this.density||"standard"),p.appendChild(m),d.appendChild(f),this.appendChild(d),this.#h=d,this.#u=m;let b=document.createElement("section");b.setAttribute("data-totals",""),this.appendChild(b),this.#d=b;let g=document.createElement("footer");g.setAttribute("data-footer","");let y=document.createElement("div");y.setAttribute("data-footer-notes",""),g.appendChild(y),this.appendChild(g),this.#p=g,this.#v("footer",g);let v=document.createElement("empty-state-ui");v.setAttribute("data-empty",""),v.setAttribute("icon","receipt"),v.setAttribute("heading","No invoice loaded"),v.setAttribute("description","Pass an `invoice` record or `data-stream-src` to render an invoice."),this.appendChild(v),this.#f=v}#S(t,e){if(!this.#s||!this.#n||!this.#r)return;let i=t?.number?String(t.number):"";this.#s.textContent!==i&&(this.#s.textContent=i);let n=cq[e]||"default",r=uq[e]||(e?String(e):"Draft");if(this.#n.getAttribute("variant")!==n&&this.#n.setAttribute("variant",n),this.#n.getAttribute("text")!==r&&this.#n.setAttribute("text",r),this.#n.setAttribute("aria-label",`Status: ${r}`),t?this.#n.removeAttribute("hidden"):this.#n.setAttribute("hidden",""),this.#r.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 ${xE(t.issuedAt,o)}`,this.#r.appendChild(a)}if(t.dueAt){let a=document.createElement("span");a.setAttribute("data-due",""),a.textContent=`Due ${xE(t.dueAt,o)}`,this.#r.appendChild(a)}}#x(t){if(!(!this.#l||!this.#c)){if(this.#l.replaceChildren(),t?.customer){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Billed to",this.#l.appendChild(e),t.customer.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.customer.name),this.#l.appendChild(i)}if(t.customer.email){let i=document.createElement("div");i.setAttribute("data-party-email",""),i.textContent=String(t.customer.email),this.#l.appendChild(i)}if(t.customer.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.customer.address),this.#l.appendChild(i)}}if(this.#c.replaceChildren(),t?.remitTo){let e=document.createElement("div");if(e.setAttribute("data-party-heading",""),e.textContent="Remit to",this.#c.appendChild(e),t.remitTo.name){let i=document.createElement("div");i.setAttribute("data-party-name",""),i.textContent=String(t.remitTo.name),this.#c.appendChild(i)}if(t.remitTo.address){let i=document.createElement("div");i.setAttribute("data-party-address",""),i.textContent=String(t.remitTo.address),this.#c.appendChild(i)}}}}#A(t){if(!this.#u)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");this.#u.columns=[{key:"description",label:"Description",flex:1},{key:"qty",label:"Qty",width:80,format:r=>String(r??"")},{key:"unitAmount",label:"Unit",width:120,format:r=>yd(r,e,i)},{key:"amount",label:"Amount",width:140,format:r=>yd(r,e,i)}];let n=Array.isArray(t?.lines)?t.lines:[];this.#u.data=n.map((r,o)=>({__row:o,description:r?.description??"",qty:r?.qty??"",unitAmount:r?.unitAmount??0,amount:r?.amount??0})),this.#u.getAttribute("density")!==this.density&&this.#u.setAttribute("density",this.density||"standard")}#E(t){if(!this.#d)return;let e=t?.currency||this.currency||"USD",i=this.locale||(typeof document<"u"?document.documentElement.lang:"");if(this.#d.replaceChildren(),!t)return;let n=[{key:"subtotal",label:"Subtotal",value:t.subtotal},{key:"tax",label:"Tax",value:t.tax}];Number.isFinite(t.discount)&&t.discount>0&&n.push({key:"discount",label:"Discount",value:-Math.abs(t.discount)});for(let r of n){if(!Number.isFinite(r.value))continue;let o=document.createElement("div");o.setAttribute("data-totals-row",""),o.setAttribute("data-totals-key",r.key);let a=document.createElement("span");a.setAttribute("data-totals-label",""),a.textContent=r.label;let l=document.createElement("span");l.setAttribute("data-totals-value",""),l.textContent=yd(r.value,e,i),o.append(a,l),this.#d.appendChild(o)}if(Number.isFinite(t.total)){let r=document.createElement("div");r.setAttribute("data-totals-row",""),r.setAttribute("data-totals-key","total"),r.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=yd(t.total,e,i),r.append(o,a),this.#d.appendChild(r)}}#C(t){t&&this.#m&&this.setAttribute("aria-labelledby",this.#m)}#$(){let t=i=>{let n=i.target?.closest?.("[data-invoice-action]");if(!n||!this.contains(n))return;let r=n.getAttribute("data-invoice-action")||"";if(!r)return;let o=this.invoice?.number||"";i.stopPropagation(),this.dispatchEvent(new CustomEvent("invoice-action",{bubbles:!0,detail:{action:r,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 r=(i.composedPath?i.composedPath():[]).find(l=>l?.getAttribute&&l.getAttribute("data-row")!=null);if(!r||!this.#h.contains(r))return;let o=Number(r.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",Oa);Ct();var dq=[{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 vd(s){if(!s)return"unknown";for(let{brand:t,re:e}of dq)if(e.test(s))return t;return"unknown"}function xd(s){return String(s||"").replace(/\D+/g,"").slice(0,19)}function oG(s,t){return s?t==="amex"?s.replace(/^(\d{0,4})(\d{0,6})(\d{0,5}).*$/,(e,i,n,r)=>[i,n,r].filter(Boolean).join(" ")):s.match(/.{1,4}/g)?.join(" ")??"":""}function SE(s){if(!s||s.length<12)return!1;let t=0,e=!1;for(let i=s.length-1;i>=0;i--){let n=s.charCodeAt(i)-48;if(n<0||n>9)return!1;e&&(n*=2,n>9&&(n-=9)),t+=n,e=!e}return t%10===0}function wE(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 kE(s){let t=wE(s);if(!t)return"expiry-format";let{month:e,year:i}=t;if(e<1||e>12)return"expiry-month";let n=new Date,r=n.getFullYear(),o=n.getMonth()+1;return i<r||i===r&&e<o?"expiry-past":i>r+50?"expiry-far":null}function AE(s,t){let e=String(s||"").replace(/\D+/g,""),i=t==="amex"?4:3;return e.length!==i?"cvc-length":null}function fq(s){let t=Math.random().toString(36).slice(2);return`pm_local_${Date.now().toString(36)}_${t}_${String(s).slice(0,4)}`}var pq=["US","CA","GB","DE","FR","AU"],mq={US:"United States",CA:"Canada",GB:"United Kingdom",DE:"Germany",FR:"France",AU:"Australia",JP:"Japan",ES:"Spain",IT:"Italy",NL:"Netherlands",SE:"Sweden",IE:"Ireland",SG:"Singapore",IN:"India",BR:"Brazil",MX:"Mexico"};function gq(s){return mq[s]||s}var ya=class extends M{static labelDeprecated=!1;static get properties(){return{...M.properties,name:{type:String,default:"paymentMethod",reflect:!0},value:{type:String,default:"",reflect:!0},prefill:{type:String,default:"",attribute:"prefill"},countries:{type:Array,default:[]},defaultCountry:{type:String,default:"US",reflect:!0,attribute:"default-country"},requireBillingAddress:{type:Boolean,default:!1,reflect:!0,attribute:"require-billing-address"},disabled:{type:Boolean,default:!1,reflect:!0},required:{type:Boolean,default:!1,reflect:!0},error:{type:String,default:"",reflect:!0},autofocus:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r=null;#a={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#o={name:null,cardNumber:null,expiry:null,cvc:null,country:null,postalCode:null,addressLine1:null,addressLine2:null};#l="unknown";#c=!1;#h=null;#u=null;#d=!1;async tokenize(){if(this.#d)return Promise.reject(new Error("tokenize-inflight"));this.#d=!0,this.setAttribute("tokenizing","");try{let t=this.#A();if(!t.ok){let n=new Error(t.message);throw n.code=t.code,n.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"),n}let e=t.detail;this.#c=!0;try{this.value=fq(e.last4)}finally{this.#c=!1}this.syncValue(),this.removeAttribute("aria-invalid");let i={token:this.value,...e};return this.dispatchEvent(new CustomEvent("submit-payment-method",{bubbles:!0,detail:i})),i}finally{this.removeAttribute("tokenizing"),this.#d=!1}}reset(){F(()=>{for(let t of Object.keys(this.#o)){let e=this.#o[t];e&&(e.value="",e.removeAttribute("error"))}this.#o.country&&(this.#o.country.value=this.defaultCountry||"US"),this.#c=!0;try{this.value="",this.error=""}finally{this.#c=!1}this.syncValue(),this.#l="unknown",this.removeAttribute("aria-invalid"),this.removeAttribute("error"),this.#S()})}syncValue(t){this.internals.setFormValue(this.value||""),this.required&&!this.value?this.internals.setValidity({valueMissing:!0},this.getAttribute("data-msg-required")||"Payment method required.",this):this.internals.setValidity({})}connected(){super.connected(),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment method form"),this.#t||(this.#p(),this.#O(),this.#t=!0),F(()=>this.render()),this.autofocus&&requestAnimationFrame(()=>{this.#o.name?.focus?.()})}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){if(super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#c)){if(t==="prefill"&&e!==i)this.render();else if(t==="disabled"&&e!==i)this.#w();else if(t==="error"&&e!==i)this.#v();else if(t==="require-billing-address"&&e!==i)this.#y();else if(t==="default-country"&&e!==i){let n=this.#o.country;n&&!n.value&&(n.value=i||"US")}}}render(){this.#t&&(this.#b(),this.#y(),this.#w(),this.#v(),this.#k(),this.#S())}#p(){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 n=document.createElement("div");n.setAttribute("data-summary-text",""),e.appendChild(n);let r=document.createElement("button-ui");r.setAttribute("data-summary-edit",""),r.setAttribute("variant","ghost"),r.setAttribute("size","sm"),r.setAttribute("text","Edit card"),e.appendChild(r),this.appendChild(e),this.#s=e,this.#n=r;let o=document.createElement("div");o.setAttribute("data-grid",""),this.appendChild(o),this.#r=o,this.#a.name=this.#f("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.#f("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.#f("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.#f("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.#f("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.#f("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.#f("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.#f("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)}#f(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 n;if(e.kind==="select"){if(n=document.createElement("select-ui"),Array.isArray(e.seedOptions))for(let r of e.seedOptions){let o=document.createElement("option");o.value=r.value,o.textContent=r.label,e.seedValue&&r.value===e.seedValue&&o.setAttribute("selected",""),n.appendChild(o)}}else n=document.createElement("input-ui");n.setAttribute("name",t),n.setAttribute("data-control",t),e.required&&n.setAttribute("required","");for(let[r,o]of Object.entries(e.input||{}))o==null||o===""||n.setAttribute(r,String(o));return i.appendChild(n),this.#r.appendChild(i),i}#m(){return(Array.isArray(this.countries)&&this.countries.length>0?this.countries:pq).map(e=>({value:e,label:gq(e)}))}#O(){let t=n=>{if(!this.#o.cardNumber||n.target!==this.#o.cardNumber)return;let r=String(this.#o.cardNumber.value||""),o=xd(r),a=vd(o);a!==this.#l&&(this.#l=a,this.#S()),this.#g()};this.addEventListener("input",t),this.#e.push(()=>this.removeEventListener("input",t));let e=n=>{n.target!==this&&this.#g()};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.#r&&(this.#r.hidden=!1))};this.#n.addEventListener("click",i),this.#n.addEventListener("press",i),this.#e.push(()=>{this.#n.removeEventListener("click",i),this.#n.removeEventListener("press",i)})}#g(){let t=xd(this.#o.cardNumber?.value),e=vd(t),i=this.#x();this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{valid:i.ok,brand:e}}))}#b(){let t=this.#o.country;if(!t)return;let e=this.#m();Array.isArray(t.options)&&t.options.length===e.length&&t.options.every((n,r)=>n?.value===e[r].value&&n?.label===e[r].label)||(t.options=e),t.value||(t.value=this.defaultCountry||e[0]?.value||"US")}#y(){let t=!!this.requireBillingAddress;this.#a.addressLine1&&(this.#a.addressLine1.hidden=!t),this.#a.addressLine2&&(this.#a.addressLine2.hidden=!t)}#w(){let t=!!this.disabled;for(let e of Object.values(this.#o))e&&(t?e.setAttribute("disabled",""):e.removeAttribute("disabled"))}#v(){if(!this.#i)return;let t=this.error||"";t?(this.#i.setAttribute("text",t),this.#i.hidden=!1,this.setAttribute("aria-invalid","true")):(this.#i.removeAttribute("text"),this.#i.hidden=!0,this.removeAttribute("aria-invalid"))}#k(){if(!this.#s)return;let t=this.#E();if(!t||this.hasAttribute("prefilled-dismissed")){this.#s.hidden=!0,this.#r&&(this.#r.hidden=!1),this.removeAttribute("prefilled");return}let e=this.#s.querySelector(":scope > [data-summary-text]");if(e){let i=(t.brand||"Card").toUpperCase(),n=t.last4||"\u2022\u2022\u2022\u2022",r=t.expMonth&&t.expYear?` \xB7 expires ${String(t.expMonth).padStart(2,"0")}/${String(t.expYear).slice(-2)}`:"";e.textContent=`${i} ending in ${n}${r}`}this.#s.hidden=!1,this.#r&&(this.#r.hidden=!0),this.setAttribute("prefilled","")}#S(){let t=this.#o.cardNumber;if(!t)return;let e=t.querySelector(":scope > [data-brand-badge]");if(!e)return;if(this.#l==="unknown"||!this.#l){e.replaceChildren();return}let i=e.querySelector(":scope > [data-brand]");if(i&&i.getAttribute("data-brand")===this.#l)return;e.replaceChildren();let n=document.createElement("span");n.setAttribute("data-brand",this.#l),n.textContent=this.#l.toUpperCase(),e.appendChild(n)}#x(){let t=xd(this.#o.cardNumber?.value);return t?SE(t)?kE(this.#o.expiry?.value)?{ok:!1}:AE(this.#o.cvc?.value,vd(t))?{ok:!1}:(this.#o.name?.value||"").trim()?(this.#o.postalCode?.value||"").trim()?{ok:!0}:{ok:!1}:{ok:!1}:{ok:!1}:{ok:!1}}#A(){for(let d of Object.values(this.#o))d?.removeAttribute?.("error");let t=String(this.#o.name?.value||"").trim();if(!t)return this.#o.name?.setAttribute("error","Name on card is required."),{ok:!1,message:"Name on card is required.",code:"validation-failed",field:"name"};let e=this.#o.cardNumber?.value||"",i=xd(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(!SE(i))return this.#o.cardNumber?.setAttribute("error","Card number is invalid."),{ok:!1,message:"Card number is invalid.",code:"card-invalid",field:"cardNumber"};let n=kE(this.#o.expiry?.value||"");if(n){let d=n==="expiry-past"?"Card has expired.":n==="expiry-month"?"Expiry month must be 01-12.":n==="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:n==="expiry-past"?"expired":"validation-failed",field:"expiry"}}let r=vd(i);if(AE(this.#o.cvc?.value||"",r)){let f=`CVC must be ${r==="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=wE(this.#o.expiry.value);return{ok:!0,detail:{last4:i.slice(-4),brand:r,expMonth:h.month,expYear:h.year,name:t,country:a}}}#E(){let t=this.prefill||this.getAttribute("prefill")||"";if(!t)return null;try{let e=JSON.parse(t);return!e||typeof e!="object"?null:e}catch{return null}}};customElements.get("payment-method-form-ui")||customElements.define("payment-method-form-ui",ya);Ct();var bq=new Set(["visa","mastercard","amex","discover","jcb","unionpay","diners","paypal","apple-pay","google-pay","ach","sepa"]),EE=new Set(["card","bank","wallet"]),CE={paypal:"paypal-logo","apple-pay":"apple-logo",ach:"bank",sepa:"bank"},Oq={card:"credit-card",bank:"bank",wallet:"credit-card"},$E={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 PE(s){let t=(s?.brand||"").toLowerCase();if(CE[t])return CE[t];let e=(s?.type||"card").toLowerCase();return Oq[e]||"credit-card"}function QE(s){let t=(s?.brand||"").toLowerCase();if($E[t])return $E[t];let e=(s?.type||"card").toLowerCase();return e==="bank"?"Bank account":e==="wallet"?"Wallet":"Card"}function yO(s){let t=(s?.last4||"").trim(),e=(s?.holder||"").trim(),i=QE(s);return(s?.type||"card").toLowerCase()==="bank"&&e?e:t?`${i} \xB7\xB7\xB7\xB7 ${t}`:e?`${i} \u2014 ${e}`:i}function vO(s){let t=(s?.expiry||"").trim();if(!t)return"";let e="",i="",n=t.match(/^(\d{1,2})\/(\d{2}|\d{4})$/);if(n)e=n[1].padStart(2,"0"),i=n[2].length===4?n[2].slice(-2):n[2];else{let r=t.match(/^(\d{4})-(\d{2})-\d{2}$/);r&&(i=r[1].slice(-2),e=r[2])}return!e||!i?"":`Expires ${e}/${i}`}var va=class extends M{static get properties(){return{...M.properties,methods:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},"add-label":{type:String,default:"Add payment method",attribute:"add-label"},"add-icon":{type:String,default:"plus",attribute:"add-icon"},"no-add":{type:Boolean,default:!1,reflect:!0,attribute:"no-add"},"no-remove":{type:Boolean,default:!1,reflect:!0,attribute:"no-remove"},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r=null;#a=new Map;#o=!1;setDefault(t){return t?F(()=>{let e=(this.methods||[]).find(n=>n.id===t);if(!e)return!1;if(this.value===t)return!0;let i=this.value||"";this.#o=!0;try{this.value=t}finally{this.#o=!1}return this.syncValue(),this.#m(t,i,e),!0}):!1}remove(t){return t?F(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(n=>n.id===t);if(i<0)return!1;if(e.splice(i,1),this.methods=e,this.value===t){let n=e[0]?.id||"";this.#o=!0;try{this.value=n}finally{this.#o=!1}this.syncValue()}return!0}):!1}add(t){!t||!t.id||F(()=>{let e=Array.isArray(this.methods)?this.methods.slice():[],i=e.findIndex(n=>n.id===t.id);if(i>=0?e[i]=t:e.push(t),this.methods=e,t.default){let n=this.value||"";this.#o=!0;try{this.value=t.id}finally{this.#o=!1}this.syncValue(),n!==t.id&&this.#m(t.id,n,t)}})}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Payment methods"),this.#t||(this.#c(),this.#h(),this.#f(),this.#t=!0),F(()=>this.render())}disconnected(){super.disconnected?.();for(let t of this.#e)try{t()}catch{}this.#e.length=0}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.methods)?this.methods:[],e=this.#l(t);if(e&&this.value!==e){this.#o=!0;try{this.value=e}finally{this.#o=!1}this.syncValue()}if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#n&&(this.#n.hidden=!!this["no-add"]),this.#r){this.#r.setAttribute("text",this["add-label"]||"Add payment method");let i=this["add-icon"]||"plus";i?this.#r.setAttribute("icon",i):this.#r.removeAttribute("icon"),this.disabled?this.#r.setAttribute("disabled",""):this.#r.removeAttribute("disabled")}this.#u(t)}#l(t){if(!t.length)return"";if(this.value&&t.some(i=>i.id===this.value))return this.value;let e=t.find(i=>i.default);return e?e.id:t[0].id||""}#c(){let t=this.querySelector(':scope > script[type="application/json"][data-methods]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.methods=e)}catch(e){console.warn("[payment-method-list-ui] failed to parse <script data-methods> JSON:",e?.message)}finally{t.remove()}}#h(){let t=document.createElement("div");if(t.setAttribute("data-rows",""),t.setAttribute("role","presentation"),this.appendChild(t),this.#i=t,!this.querySelector(':scope > [slot="empty"]')){let i=document.createElement("empty-state-ui");i.setAttribute("data-empty",""),i.setAttribute("icon","credit-card"),i.setAttribute("heading","No payment methods"),i.setAttribute("description","Add a method to get started."),this.appendChild(i),this.#s=i}let e=document.createElement("div");if(e.setAttribute("data-add",""),this.appendChild(e),this.#n=e,!this.querySelector(':scope > [slot="add"]')){let i=document.createElement("button-ui");i.setAttribute("data-add-cta",""),i.setAttribute("variant","outline"),i.setAttribute("icon",this["add-icon"]||"plus"),i.setAttribute("text",this["add-label"]||"Add payment method"),e.appendChild(i),this.#r=i}}#u(t){if(!this.#i)return;let e=new Map;for(let i of t){if(!i?.id)continue;let n=this.#a.get(i.id);n||(n=this.#d(i),this.#i.appendChild(n)),this.#p(n,i),e.set(i.id,n)}for(let[i,n]of this.#a)if(!e.has(i))try{n.remove()}catch{}for(let i of t){let n=e.get(i.id);n&&this.#i.appendChild(n)}this.#a=e}#d(t){let e=document.createElement("card-ui");e.setAttribute("data-row",""),e.setAttribute("role","radio"),e.setAttribute("tabindex","0");let i=document.createElement("header"),n=document.createElement("span");n.setAttribute("slot","icon");let r=document.createElement("icon-ui");r.setAttribute("aria-hidden","true"),n.appendChild(r);let o=document.createElement("span");o.setAttribute("slot","heading");let a=document.createElement("span");a.setAttribute("data-primary","");let l=document.createElement("tag-ui");l.setAttribute("data-default-tag",""),l.setAttribute("text","Default"),l.setAttribute("variant","success"),l.setAttribute("size","sm"),l.setAttribute("hidden",""),o.appendChild(a),o.appendChild(l);let h=document.createElement("p");h.setAttribute("slot","description"),h.setAttribute("data-secondary","");let c=document.createElement("span");c.setAttribute("slot","action");let u=document.createElement("button-ui");u.setAttribute("data-action","set-default"),u.setAttribute("variant","ghost"),u.setAttribute("size","sm"),u.setAttribute("text","Set default");let d=document.createElement("button-ui");d.setAttribute("data-action","edit"),d.setAttribute("variant","ghost"),d.setAttribute("size","sm"),d.setAttribute("icon","pencil"),d.setAttribute("aria-label","Edit payment method");let f=document.createElement("button-ui");return f.setAttribute("data-action","remove"),f.setAttribute("variant","ghost"),f.setAttribute("size","sm"),f.setAttribute("icon","trash"),f.setAttribute("aria-label","Remove payment method"),c.appendChild(u),c.appendChild(d),c.appendChild(f),i.appendChild(n),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 n=(e?.type||"card").toLowerCase();EE.has(n)&&t.setAttribute("data-type",n);let r=e.id===this.value;r?(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=PE(e);o.getAttribute("name")!==m&&o.setAttribute("name",m)}let a=t.querySelector(':scope > header > [slot="heading"] > [data-primary]');a&&(a.textContent=yO(e));let l=t.querySelector(':scope > header > [data-secondary][slot="description"]');if(l){let m=vO(e);l.textContent=m,m?l.removeAttribute("hidden"):l.setAttribute("hidden","")}let h=t.querySelector(':scope > header > [slot="heading"] > [data-default-tag]');h&&(r?h.removeAttribute("hidden"):h.setAttribute("hidden",""));let c=vO(e),u=[yO(e)];c&&u.push(c),r&&u.push("default"),t.setAttribute("aria-label",u.join(", "));let d=t.querySelector(':scope > header > [slot="action"] > [data-action="set-default"]');d&&(r?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"))}#f(){let t=n=>{let r=n.target?.closest?.("button-ui[data-action]");if(r&&this.#i.contains(r)){let a=r.closest("[data-row]");if(!a)return;let l=a.getAttribute("data-id")||"";if(!l)return;if(this.disabled||r.hasAttribute("disabled")){n.stopPropagation();return}let h=(this.methods||[]).find(u=>u.id===l);if(!h)return;let c=r.getAttribute("data-action");n.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=n.target?.closest?.("button-ui[data-add-cta]");if(o&&this.#n?.contains(o)){if(this.disabled||o.hasAttribute("disabled")){n.stopPropagation();return}n.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=n=>{if(n.target?.closest?.("button-ui[data-action]")||n.target?.closest?.("button-ui[data-add-cta]"))return;let r=n.target?.closest?.("[data-row]");if(!r||!this.#i.contains(r))return;let o=r.getAttribute("data-id")||"";o&&(this.disabled||this.setDefault(o))};this.#i.addEventListener("click",e),this.#e.push(()=>this.#i.removeEventListener("click",e));let i=n=>{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(n.key==="ArrowDown"||n.key==="ArrowRight")n.preventDefault(),a[(l+1)%a.length]?.focus?.();else if(n.key==="ArrowUp"||n.key==="ArrowLeft")n.preventDefault(),a[(l-1+a.length)%a.length]?.focus?.();else if(n.key==="Home")n.preventDefault(),a[0]?.focus?.();else if(n.key==="End")n.preventDefault(),a[a.length-1]?.focus?.();else if(n.key===" "||n.key==="Enter"){n.preventDefault();let h=o.getAttribute("data-id")||"";h&&!this.disabled&&this.setDefault(h)}}};this.#i.addEventListener("keydown",i),this.#e.push(()=>this.#i.removeEventListener("keydown",i))}#m(t,e,i){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,method:i}}))}};customElements.get("payment-method-list-ui")||customElements.define("payment-method-list-ui",va);Ct();var Sd=new Set(["monthly","annual"]),yq={monthly:"Monthly",annual:"Annual"},vq={monthly:"/month",annual:"/year"};function xq(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 Sq(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(n=>n.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 xa=class extends M{static labelDeprecated=!0;static get properties(){return{...M.properties,plans:{type:Array,default:[]},value:{type:String,default:"",reflect:!0},current:{type:String,default:"",reflect:!0},cycle:{type:String,default:"monthly",reflect:!0},cycleToggle:{type:Boolean,default:!1,reflect:!0,attribute:"cycle-toggle"},currency:{type:String,default:"USD"},locale:{type:String,default:""},layout:{type:String,default:"grid",reflect:!0},disabled:{type:Boolean,default:!1,reflect:!0}}}static template=()=>null;#t=!1;#e=[];#i=null;#s=null;#n=null;#r=null;#a=null;#o=new Map;#l=!1;#c=!1;#h=!1;#u=0;setValue(t){return t?F(()=>{let e=(this.plans||[]).find(n=>n.id===t);if(!e)return!1;if(e.disabled)return this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}})),!1;if(this.value===t)return!0;let i=this.value||"";return this.value=t,this.syncValue(),this.#y(t,i),!0}):!1}setCycle(t){return Sd.has(t)?F(()=>{if(this.cycle===t)return!0;let e=this.cycle;return this.cycle=t,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:t,previous:e}})),!0}):!1}async refresh(){let t=this.getAttribute("data-stream-src");if(!t)return;let e=++this.#u;this.setAttribute("loading",""),this.removeAttribute("error");try{let i=await fetch(t);if(!i.ok)throw new Error(`HTTP ${i.status}`);let n=await i.json();if(e!==this.#u)return;this.removeAttribute("loading");let r=Array.isArray(n)?n:Array.isArray(n?.plans)?n.plans:[];this.plans=r,this.dispatchEvent(new CustomEvent("load",{bubbles:!0,detail:{count:r.length}}))}catch(i){if(e!==this.#u)return;this.removeAttribute("loading"),this.setAttribute("error",""),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"fetch-failed",message:String(i?.message||i)}}))}}connected(){super.connected(),this.setAttribute("role","radiogroup"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Choose a plan"),this.#t||(this.#d(),this.#p(),this.#b(),this.#t=!0),F(()=>this.render()),this.getAttribute("data-stream-src")&&this.refresh()}disconnected(){super.disconnected();for(let t of this.#e)try{t()}catch{}this.#e.length=0}attributeChangedCallback(t,e,i){super.attributeChangedCallback?.(t,e,i),!(!this.#t||this.#l)&&t==="data-stream-src"&&e!==i&&i&&this.refresh()}syncValue(t){this.internals.setFormValue(this.value||"")}render(){if(!this.#t)return;let t=Array.isArray(this.plans)?this.plans:[];if(!Sd.has(this.cycle)){this.#c||(this.#c=!0,console.warn(`[plan-picker-ui] unknown cycle "${this.cycle}" \u2014 coercing to "monthly".`)),this.#l=!0;try{this.cycle="monthly"}finally{this.#l=!1}}let e=t.filter(n=>n.recommended);e.length>1&&!this.#h&&(this.#h=!0,console.warn(`[plan-picker-ui] ${e.length} plans carry recommended:true \u2014 using the first ("${e[0].id}"); ignoring the rest.`));let i=e[0]?.id||"";if(t.length===0?this.setAttribute("empty",""):this.removeAttribute("empty"),this.#i){let n=this.cycleToggle&&t.length>0;this.#i.hidden=!n,n&&this.#f()}this.#m(t,i)}#d(){let t=this.querySelector(':scope > script[type="application/json"][data-plans]');if(t)try{let e=JSON.parse(t.textContent||"[]");Array.isArray(e)&&(this.plans=e)}catch(e){console.warn("[plan-picker-ui] failed to parse <script data-plans> JSON:",e?.message)}finally{t.remove()}}#p(){let t=document.createElement("div");t.setAttribute("data-toggle",""),t.hidden=!0,this.appendChild(t),this.#i=t;let e=document.createElement("div");e.setAttribute("data-plans",""),e.setAttribute("role","presentation"),this.appendChild(e),this.#n=e;let i=document.createElement("div");if(i.setAttribute("data-skeleton",""),i.hidden=!0,this.appendChild(i),this.#r=i,!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.#a=n}}#f(){if(!this.#i)return;let t=this.#s;if(!t){t=document.createElement("segmented-ui"),t.setAttribute("aria-label","Billing cycle"),this.#i.appendChild(t),this.#s=t;for(let e of["monthly","annual"]){let i=document.createElement("segment-ui");i.setAttribute("value",e),i.setAttribute("text",yq[e]),t.appendChild(i)}}t.value!==this.cycle&&(t.value=this.cycle)}#m(t,e){if(!this.#n)return;let i=new Map;for(let n of t){if(!n?.id)continue;let r=this.#o.get(n.id);r||(r=document.createElement("option-card-ui"),r.setAttribute("layout","tile"),this.#n.appendChild(r)),this.#O(r,n,e),i.set(n.id,r)}for(let[n,r]of this.#o)if(!i.has(n))try{r.remove()}catch{}for(let n of t){let r=i.get(n.id);r&&this.#n.appendChild(r)}this.#o=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 n=!!(this.current&&e.id===this.current),r=e.id===i;n?t.setAttribute("data-current",""):t.removeAttribute("data-current"),r?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&&n?t.setAttribute("checked",""):t.removeAttribute("checked");let a=t.querySelector(":scope > [data-plan-body]");a||(a=document.createElement("div"),a.setAttribute("data-plan-body",""),t.appendChild(a)),this.#g(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(),n){let h=document.createElement("tag-ui");h.setAttribute("text","Current plan"),h.setAttribute("variant","muted"),l.appendChild(h)}else if(r){let h=document.createElement("tag-ui");h.setAttribute("text","Recommended"),h.setAttribute("variant","accent"),l.appendChild(h)}}#g(t,e){t.replaceChildren();let i=document.createElement("div");i.setAttribute("data-price-row","");let n=Sd.has(this.cycle)?this.cycle:"monthly",r=e.prices||{},o=r[n]||r.monthly||null;if(o){let l=document.createElement("span");l.setAttribute("data-price","");let h=o.currency||this.currency||"USD";l.textContent=xq(o.amount,h,this.locale),i.appendChild(l);let c=document.createElement("span");c.setAttribute("data-cycle","");let u=o.unit?`/${o.unit}`:vq[n];c.textContent=u,i.appendChild(c)}else{let l=document.createElement("span");l.setAttribute("data-price",""),l.textContent="Contact sales",i.appendChild(l)}if(t.appendChild(i),o?.note){let l=document.createElement("span");l.setAttribute("data-price-note",""),l.textContent=o.note,t.appendChild(l)}if(Array.isArray(e.features)&&e.features.length){let l=document.createElement("ul");l.setAttribute("data-features","");for(let h of e.features){let c=document.createElement("li"),u=document.createElement("icon-ui");u.setAttribute("name","check"),u.setAttribute("aria-hidden","true"),c.appendChild(u);let d=document.createElement("span");d.textContent=String(h),c.appendChild(d),l.appendChild(c)}t.appendChild(l)}if(!!!(this.current&&e.id===this.current)||e.cta){let l=document.createElement("button-ui");l.setAttribute("data-cta",""),l.setAttribute("variant",e.recommended?"primary":"outline"),l.setAttribute("text",Sq(e,Array.isArray(this.plans)?this.plans:[],this.current)),(e.disabled||this.disabled)&&l.setAttribute("disabled",""),t.appendChild(l)}}#b(){let t=n=>{let r=n?.detail?.value;if(!Sd.has(r)||this.cycle===r)return;n.stopPropagation();let o=this.cycle;this.cycle=r,this.dispatchEvent(new CustomEvent("cycle-change",{bubbles:!0,detail:{cycle:r,previous:o}}))};this.#i.addEventListener("change",t),this.#e.push(()=>this.#i.removeEventListener("change",t));let e=n=>{let r=n.target?.closest?.("option-card-ui");if(!r||!this.#n.contains(r))return;let o=r.getAttribute("value")||"";if(!o)return;let a=(this.plans||[]).find(h=>h.id===o);if(!a)return;if(a.disabled||this.disabled){r.removeAttribute("checked"),this.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{reason:"plan-disabled"}}));return}n.stopPropagation();let l=this.value||"";if(l!==o){this.#l=!0;try{this.value=o}finally{this.#l=!1}this.syncValue(),this.#y(o,l)}};this.#n.addEventListener("change",e),this.#e.push(()=>this.#n.removeEventListener("change",e));let i=n=>{let r=n.target?.closest?.("button-ui[data-cta]");if(!r||!this.#n.contains(r))return;let o=r.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;n.stopPropagation();let h=this.value||"";if(h!==a){this.#l=!0;try{this.value=a}finally{this.#l=!1}this.syncValue(),this.#y(a,h)}this.dispatchEvent(new CustomEvent("select",{bubbles:!0,detail:{value:a,cycle:this.cycle}}))};this.#n.addEventListener("press",i),this.#n.addEventListener("click",i),this.#e.push(()=>this.#n.removeEventListener("press",i)),this.#e.push(()=>this.#n.removeEventListener("click",i))}#y(t,e){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{value:t,previous:e,cycle:this.cycle}}))}};customElements.get("plan-picker-ui")||customElements.define("plan-picker-ui",xa);P();var wq=Object.freeze([{value:"all",label:"All"},{value:"available",label:"Available"},{value:"connected",label:"Connected"},{value:"error",label:"Issues"},{value:"coming-soon",label:"Coming soon"}]),kq=6,ah=class extends x{static properties={integrations:{type:Array,default:[]},loading:{type:Boolean,default:!1,reflect:!0},"search-placeholder":{type:String,default:"Search integrations",reflect:!0},"group-by":{type:String,default:"category",reflect:!0},"status-filter":{type:String,default:"all",reflect:!0}};static template=t=>t._renderTemplate();#t="";#e=`intpage-h-${Math.random().toString(36).slice(2,8)}`;#i=null;attributeChangedCallback(t,e,i){if(t==="integrations"){if(i==null)this.integrations=[];else try{let n=JSON.parse(i);this.integrations=Array.isArray(n)?n:[]}catch{this.integrations=[]}return}super.attributeChangedCallback(t,e,i)}connected(){if(this.setAttribute("role","region"),this.setAttribute("aria-labelledby",this.#e),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Integrations"),this.hasAttribute("integrations")&&!Array.isArray(this.integrations))try{this.integrations=JSON.parse(this.getAttribute("integrations"))}catch{this.integrations=[]}this.addEventListener("input",this.#u),this.addEventListener("change",this.#d)}disconnected(){this.removeEventListener("input",this.#u),this.removeEventListener("change",this.#d),this.#i&&(clearTimeout(this.#i),this.#i=null)}render(){this.#h()}_renderTemplate(){let t=this["search-placeholder"]||"Search integrations",e=this["status-filter"]||"all",i=!!this.loading,n=this.#l();return it`
|
|
433
433
|
<header data-part="header">
|
|
434
434
|
<h2 data-part="title" id=${this.#e}>Integrations</h2>
|
|
435
435
|
<slot name="header"></slot>
|