2 lines
59 KiB
JavaScript
2 lines
59 KiB
JavaScript
|
import{$ as A,r as u,a as yl,j as y,b as bl,o as H,d as Ne,u as vl,c as $l}from"./index-f45b8810.js";import{d as N,e as pe,f as He,g as ee,i as xl,j as Kl,k as Pl,l as wl,m as Ue,n as Sl,o as se,p as ae,q as ce,r as J,b as ie,s as Ml,t as Cl,v as Ve,w as Al,x as Il,y as $e,z as kl,A as We,C as El,D as xe,E as Ke,F as Fl,G as Xe,H as Ol,I as Pe,J as Tl,K as Dl,M as jl,N as we,P as T,O as qe,Q as Ze,a as Rl,R as Ll,B as Q,L as Ye,S as Bl,u as zl,h as Nl}from"./fetch.client-5aab1c76.js";import{A as Hl}from"./alert-38484668.js";import{H as Ul,a as Vl,b as Wl,L as Xl,E as ql}from"./label-979d47e9.js";function Ge(l){return null}Ge.getCollectionNode=function*(e,t){let{childItems:s,title:i,children:r}=e,n=e.title||e.children,o=e.textValue||(typeof n=="string"?n:"")||e["aria-label"]||"";!o&&!(t!=null&&t.suppressTextValueWarning)&&console.warn("<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop."),yield{type:"item",props:e,rendered:n,textValue:o,"aria-label":e["aria-label"],hasChildNodes:Zl(e),*childNodes(){if(s)for(let a of s)yield{type:"item",value:a};else if(i){let a=[];A.Children.forEach(r,d=>{a.push({type:"item",element:d})}),yield*a}}}};function Zl(l){return l.hasChildItems!=null?l.hasChildItems:!!(l.childItems||l.title&&A.Children.count(l.children)>0)}let Yl=Ge;class Gl{build(e,t){return this.context=t,Se(()=>this.iterateCollection(e))}*iterateCollection(e){let{children:t,items:s}=e;if(typeof t=="function"){if(!s)throw new Error("props.children was a function but props.items is missing");for(let i of e.items)yield*this.getFullNode({value:i},{renderer:t})}else{let i=[];A.Children.forEach(t,n=>{i.push(n)});let r=0;for(let n of i){let o=this.getFullNode({element:n,index:r},{});for(let a of o)r++,yield a}}}getKey(e,t,s,i){if(e.key!=null)return e.key;if(t.type==="cell"&&t.key!=null)return`${i}${t.key}`;let r=t.value;if(r!=null){var n;let o=(n=r.key)!==null&&n!==void 0?n:r.id;if(o==null)throw new Error("No key found for item");return o}return i?`${i}.${t.index}`:`$.${t.index}`}getChildState(e,t){return{renderer:t.renderer||e.renderer}}*getFullNode(e,t,s,i){let r=e.element;if(!r&&e.value&&t&&t.renderer){let a=this.cache.get(e.value);if(a&&(!a.shouldInvalidate||!a.shouldInvalidate(this.context))){a.index=e.index,a.parentKey=i?i.key:null,yield a;return}r=t.renderer(e.value)}if(A.isValidElement(r)){let a=r.type;if(typeof a!="function"&&typeof a.getCollectionNode!="function"){let b=typeof r.type=="function"?r.type.name:r.type;throw new Error(`Unknown element <${b}> in collection.`)}let d=a.getCollectionNode(r.props,this.context),m=e.index,$=d.next();for(;!$.done&&$.value;){let b=$.value;e.index=m;let c=b.key;c||(c=b.element?null:this.getKey(r,e,t,s));let v=[...this.getFullNode({...b,key:c,index:m,wrapper:Jl(e.wrapper,b.wrapper)},this.getChildState(t,b),s?`${s}${r.key}`:r.key,i)];for(let g of v){if(g.value=b.value||e.value,g.value&&this.cache.set(g.value,g),e.type&&g.type!==e.type)throw new Error(`Unsupported type <${re(g.type)}> in <${re(i.type)}>. Only <${re(e.type)}> is supported.`);m++,yield g}$=d.next(v)}return}if(e.key==null)return;let n=this,o={type:e.type,props:e.props,key:e.key,parentKey:i?i.key:null,value:e.value,level:i?i.level+1:0,index:e.index,rendered:e.rendered,textValue:e.textValue,"aria-label":e["aria-label"],wrapper:e.wrapper,shouldInvalidate:e.shouldInvalidate,hasChildNodes:e.hasChildNodes,childNodes:Se(function*(){if(!e.hasChildNodes)return;let a=0;for(let d of e.childNodes()){d.key!=null&&(d.key=`${o.key}${d.key}`),d.index=a;let m=n.getFullNode(d,n.getChildState(t,d),o.key,o);for(let $ of m)a++,yield $}})};yield o}constructor(){this.cache=new WeakMap}}function Se(l){let e=[],t=null;return{*[Symbol.iterator](){for(let s of e)yield s;t||(t=l());for(let s of t)e.push(s),yield s}}}function Jl(l,e){if(l&&e)return t=>l(e(t));if(l)return l;if(e)return e}function re(l){return l[0].toUpperCase()+l.slice(1)}function Ql(l,e,t){let s=u.useMemo(()=>new Gl,[]),{children:i,items:r,collection:n}=l;return u.useMemo(()=>{if(n)return n;let a=s.build({children:i,items
|