julien-c's picture
julien-c HF staff
npm run build
2dfc950 verified
raw
history blame
22.3 kB
import{html as p}from"https://cdn.jsdelivr.net/npm/htl@0.3.1/+esm";import{format as Ke,parse as Ve}from"https://cdn.jsdelivr.net/npm/isoformat@0.2.1/+esm";import{AbstractFile as Ge}from"../stdlib.js";function C(e){return e==null?null:typeof e=="number"?`${e}px`:`${e}`}function D(e){return{"--input-width":C(e)}}const ae={bubbles:!0};function G(e){e.preventDefault()}function te({currentTarget:e}){(e.form||e).dispatchEvent(new Event("input",ae))}function be(e){return e.checkValidity()}function P(e){return e}let Je=0;function ne(){return`inputs-3a86ea-${++Je}`}function z(e,t){if(e)return e=p`<label>${e}`,t!==void 0&&(e.htmlFor=t.id=ne()),e}function Re(e="\u2261",{label:t="",value:n,reduce:i,disabled:r,required:o=!1,width:a}={}){const c=typeof e=="string"||e instanceof Node;c?(!o&&n===void 0&&(n=0),i===void 0&&(i=(v=0)=>v+1),r=new Set(r?[e]:[]),e=[[e,i]]):(!o&&n===void 0&&(n=null),r=new Set(r===!0?Array.from(e,([v])=>v):r||void 0));const f=p`<form class=inputs-3a86ea>`;f.addEventListener("submit",G);const u={width:C(a)},m=Array.from(e,([v,g=P])=>{if(typeof g!="function")throw new TypeError("reduce is not a function");return p`<button disabled=${r.has(v)} style=${u} onclick=${h=>{f.value=g(f.value),te(h)}}>${v}`});return(t=z(t,c?m[0]:void 0))&&f.append(t),f.append(...m),f.value=n,f}function H(e){return Array.isArray(e)?e:Array.from(e)}function ye(e){return e?typeof e[Symbol.iterator]=="function":!1}function _e(e){if(ye(e.columns))return e.columns;if(e.schema&&ye(e.schema.fields))return Array.from(e.schema.fields,t=>t.name);if(typeof e.columnNames=="function")return e.columnNames()}function U(e){return e==null?"":`${e}`}const re=ie(e=>{const t=J(e);return n=>n==null?"":typeof n=="number"?t(n):n instanceof Date?ue(n):`${n}`}),J=ie(e=>t=>t===0?"0":t.toLocaleString(e)),We=re(),Be=J();function ge(e){const t=e.toString(),n=t.length;let i=-1,r;e:for(let o=1;o<n;++o)switch(t[o]){case".":i=r=o;break;case"0":i===0&&(i=o),r=o;break;default:if(!+t[o])break e;i>0&&(i=0);break}return i>0?t.slice(0,i)+t.slice(r+1):t}function ue(e){return Ke(e,"Invalid Date")}function ie(e){let t=ie,n;return(i="en")=>i===t?n:n=e(t=i)}function se(e,t){return R(t)-R(e)||(e<t?-1:e>t?1:e>=t?0:NaN)}function we(e,t){return R(t)-R(e)||(t<e?-1:t>e?1:t>=e?0:NaN)}function R(e){return e!=null&&!Number.isNaN(e)}const Xe=([e])=>e,ke=([,e])=>e;function xe({multiple:e,render:t,selectedIndexes:n,select:i}){return function(r,{locale:o,keyof:a=r instanceof Map?Xe:P,valueof:c=r instanceof Map?ke:P,format:f=(y=>(b,E,k)=>y(a(b,E,k)))(re(o)),multiple:u,key:m,value:v,disabled:g=!1,sort:h,unique:$,...N}={}){if(typeof a!="function")throw new TypeError("keyof is not a function");if(typeof c!="function")throw new TypeError("valueof is not a function");if(typeof f!="function")throw new TypeError("format is not a function");e!==void 0&&(u=e),h=Qe(h);let y=+u;v===void 0&&(v=m!==void 0&&r instanceof Map?y>0?Array.from(m,x=>r.get(x)):r.get(m):void 0),$=!!$,r=H(r);let b=r.map((x,O)=>[a(x,O,r),O]);h!==void 0&&b.sort(([x],[O])=>h(x,O)),$&&(b=[...new Map(b.map(x=>[tt(x[0]),x])).values()]);const E=b.map(ke);u===!0?y=Math.max(1,Math.min(10,E.length)):y>0?u=!0:(u=!1,y=void 0);const[k,d]=t(r,E,Ye(r,E,v,u,c),Ze(r,E,g,c),{...N,format:f,multiple:u,size:y});k.addEventListener("input",w),k.addEventListener("change",te),k.addEventListener("submit",G);function w(x){if(x&&x.isTrusted&&k.removeEventListener("change",te),u)v=n(d).map(O=>c(r[O],O,r));else{const O=et(d);v=O<0?null:c(r[O],O,r)}}return w(),Object.defineProperty(k,"value",{get(){return v},set(x){if(u){const O=new Set(x);for(const j of d){const T=+j.value;i(j,O.has(c(r[T],T,r)))}}else d.value=E.find(O=>x===c(r[O],O,r));w()}})}}function Ye(e,t,n,i,r){const o=new Set(n===void 0?[]:i?H(n):[n]);if(!o.size)return()=>!1;const a=new Set;for(const c of t)o.has(r(e[c],c,e))&&a.add(c);return c=>a.has(c)}function Ze(e,t,n,i){if(typeof n=="boolean")return n;const r=new Set(H(n)),o=new Set;for(const a of t)r.has(i(e[a],a,e))&&o.add(a);return a=>o.has(a)}function Qe(e){if(!(e===void 0||e===!1)){if(e===!0||e==="ascending")return se;if(e==="descending")return we;if(typeof e=="function")return e;throw new TypeError("sort is not a function")}}function et(e){return e.value?+e.value:-1}function tt(e){return e!==null&&typeof e=="object"?e.valueOf():e}function Ne(e,t){return xe({multiple:e,render(n,i,r,o,{format:a,label:c}){const f=p`<form class="inputs-3a86ea inputs-3a86ea-checkbox">
${z(c)}<div>
${i.map(u=>p`<label><input type=${t} disabled=${typeof o=="function"?o(u):o} name=input value=${u} checked=${r(u)}>${a(n[u],u,n)}`)}
</div>
</form>`;return[f,ot(f.elements.input,e)]},selectedIndexes(n){return Array.from(n).filter(i=>i.checked).map(i=>+i.value)},select(n,i){n.checked=i}})}const nt=Ne(!1,"radio"),rt=Ne(!0,"checkbox");function it({label:e,value:t,values:n,disabled:i}={}){const r=p`<input class=inputs-3a86ea-input type=checkbox name=input disabled=${i}>`,o=p`<form class="inputs-3a86ea inputs-3a86ea-toggle">${z(e,r)}${r}`;return Object.defineProperty(o,"value",{get(){return n===void 0?r.checked:n[r.checked?0:1]},set(a){r.checked=n===void 0?!!a:a===n[0]}}),t!==void 0&&(o.value=t),o}function ot(e,t){return e===void 0?new lt(t?[]:null):typeof e.length>"u"?new(t?ut:at)(e):e}let lt=class{constructor(t){this._value=t}get value(){return this._value}set value(t){}*[Symbol.iterator](){}},at=class{constructor(t){this._input=t}get value(){const{_input:t}=this;return t.checked?t.value:""}set value(t){const{_input:n}=this;n.checked||(n.checked=U(t)===n.value)}*[Symbol.iterator](){yield this._input}},ut=class{constructor(t){this._input=t,this._value=t.checked?[t.value]:[]}get value(){return this._value}set value(t){const{_input:n}=this;n.checked||(n.checked=U(t)===n.value,this._value=n.checked?[n.value]:[])}*[Symbol.iterator](){yield this._input}};function ce(e){if(e===void 0)return[null,null];const t=ne();return[p`<datalist id=${t}>${Array.from(e,n=>p`<option value=${U(n)}>`)}`,t]}function W(e,t,n,{validate:i=be,submit:r}={},{get:o=u=>u.value,set:a=(u,m)=>u.value=U(m),same:c=(u,m)=>u.value===m,after:f=u=>t.after(u)}={}){r=r===!0?"Submit":r||null;const u=r?p`<button type=submit disabled>${r}`:null;r&&f(u),a(t,n),n=i(t)?o(t):void 0,e.addEventListener("submit",v),t.oninput=g;function m(){if(i(t))return n=o(t),!0}function v(h){G(h),r&&(m()?(u.disabled=!0,te(h)):t.reportValidity())}function g(h){r?(u.disabled=c(t,n),h.stopPropagation()):m()||h.stopPropagation()}return Object.defineProperty(e,"value",{get(){return n},set(h){a(t,h),m()}})}function B({label:e,value:t="",type:n="text",placeholder:i,pattern:r,spellcheck:o,autocomplete:a,autocapitalize:c,min:f,max:u,minlength:m,maxlength:v,required:g=m>0,datalist:h,readonly:$,disabled:N,width:y,...b}={}){const[E,k]=ce(h),d=p`<input
type=${n}
name=text
list=${k}
readonly=${$}
disabled=${N}
required=${g}
min=${f}
max=${u}
minlength=${m}
maxlength=${v}
pattern=${r}
spellcheck=${fe(o)}
autocomplete=${K(a)}
autocapitalize=${K(c)}
placeholder=${i}
>`,w=p`<form class=inputs-3a86ea style=${D(y)}>
${z(e,d)}<div class=inputs-3a86ea-input>
${d}
</div>${E}
</form>`;return W(w,d,t,b)}function st(e){return B({...e,type:"email"})}function ct(e){return B({...e,type:"tel"})}function ft(e){return B({...e,type:"url"})}function dt(e){return B({...e,type:"password"})}function fe(e){return e==null?null:`${e}`}function K(e){return e==null?null:`${e===!1?"off":e===!0?"on":e}`}function pt({label:e,value:t,required:n,datalist:i,readonly:r,disabled:o,width:a,...c}={}){const[f,u]=ce(i),m=ne(),v=p`<input
type=color
name=text
value=${t}
id=${m}
list=${u}
readonly=${r}
disabled=${o}
required=${n}
>`,g=p`<output
for=${m}
>`;g.value=v.value,v.addEventListener("input",()=>g.value=v.value);const h=p`<form class=inputs-3a86ea style=${D(a)}>
${z(e,v)}<div class=inputs-3a86ea-input>
<div class=inputs-3a86ea-input>${v}${g}</div>
</div>${f}
</form>`;return W(h,v,t,c,{after:$=>v.parentNode.after($)})}const mt={type:"date",get:e=>e.valueAsDate,set:(e,t)=>e.value=Ee(t),same:(e,t)=>+e.valueAsDate==+t,format:Ee},vt={type:"datetime-local",get:e=>e.value?new Date(e.value):null,set:(e,t)=>e.value=Oe(t),same:(e,t)=>+new Date(e.value)==+t,format:Oe};function Ae({label:e,min:t,max:n,required:i,readonly:r,disabled:o,width:a,value:c,...f}={},{type:u,format:m,...v}){const g=p`<input type=${u} name=date readonly=${r} disabled=${o} required=${i} min=${m(t)} max=${m(n)}>`,h=p`<form class=inputs-3a86ea style=${D(a)}>
${z(e,g)}<div class=inputs-3a86ea-input>
${g}
</div>
</form>`;return W(h,g,de(c),f,v)}function ht(e){return Ae(e,mt)}function $t(e){return Ae(e,vt)}function de(e){return e instanceof Date&&!isNaN(e)?e:typeof e=="string"?Ve(e,null):e==null||isNaN(e=+e)?null:new Date(+e)}function Ee(e){return(e=de(e))?e.toISOString().slice(0,10):e}function Oe(e){return(e=de(e))?new Date(+e-e.getTimezoneOffset()*1e3*60).toISOString().slice(0,16):e}function bt(e,t){return(Array.isArray(e)?_t:wt)(e,t)}function yt(e){return p`<div>${e}`}function _t(e,{template:t=yt}={}){e=[...e];let n=e.map(({value:i})=>i);return Object.defineProperty(t(e),"value",{get(){for(let i=0,r=e.length;i<r;++i){const o=e[i].value;Object.is(o,n[i])||(n=[...n],n[i]=o)}return n},set(i=[]){for(let r=0,o=e.length;r<o;++r)e[r].value=i[r]}})}function gt(e){return p`<div>${Object.values(e)}`}function wt(e,{template:t=gt}={}){e={...e};let n=Object.fromEntries(Object.entries(e).map(([i,{value:r}])=>[i,r]));return Object.defineProperty(t(e),"value",{get(){for(const i in n){const r=e[i].value;Object.is(r,n[i])||(n={...n},n[i]=r)}return n},set(i={}){for(const r in e)e[r].value=i[r]}})}function Se(e){class t extends e{constructor(i){super(i.name),Object.defineProperty(this,"_",{value:i}),Object.defineProperty(this,"_url",{writable:!0})}async url(){return this._url||(this._url=URL.createObjectURL(this._))}async blob(){return this._}async stream(){return this._.stream()}}return function({label:n,required:i,accept:r,capture:o,multiple:a,disabled:c,width:f,value:u,submit:m,...v}={}){const g=p`<input
type=file
name=file
disabled=${c}
required=${i}
accept=${r}
capture=${o}
multiple=${a}
>`,h=p`<form class=inputs-3a86ea style=${D(f)}>
${z(n,g)}<div class=inputs-3a86ea-input>
${g}
</div>
</form>`;return W(h,g,void 0,v,{get:$=>a?Array.from($.files,N=>new t(N)):$.files.length?new t($.files[0]):null,set:()=>{},same:()=>!1})}}const oe=1e-6;function kt(e,t){return arguments.length<2&&(t=e,e=void 0),e===void 0&&(e=[]),je({extent:e},t)}function xt(e=[0,1],t){return je({extent:e,range:!0},t)}function je({extent:[e,t],range:n},{format:i=ge,transform:r,invert:o,label:a="",value:c,step:f,disabled:u,placeholder:m,validate:v=be,width:g}={}){let h;if(typeof i!="function")throw new TypeError("format is not a function");(e==null||isNaN(e=+e))&&(e=-1/0),(t==null||isNaN(t=+t))&&(t=1/0),e>t&&([e,t]=[t,e],r===void 0&&(r=pe)),f!==void 0&&(f=+f);const $=p`<input type=number min=${isFinite(e)?e:null} max=${isFinite(t)?t:null} step=${f??"any"} name=number required placeholder=${m} oninput=${k} disabled=${u}>`;let N;if(n){if(r===void 0&&(r=P),typeof r!="function")throw new TypeError("transform is not a function");if(o===void 0&&(o=r.invert===void 0?At(r):r.invert),typeof o!="function")throw new TypeError("invert is not a function");let d=+r(e),w=+r(t);d>w&&([d,w]=[w,d]),n=p`<input type=range min=${isFinite(d)?d:null} max=${isFinite(w)?w:null} step=${f===void 0||r!==P&&r!==pe?"any":f} name=range oninput=${E} disabled=${u}>`,N=r===P?n:p`<input type=range min=${e} max=${t} step=${f===void 0?"any":f} name=range disabled=${u}>`}else n=null,r=o=P;const y=p`<form class=inputs-3a86ea style=${D(g)}>
${z(a,$)}<div class=inputs-3a86ea-input>
${$}${n}
</div>
</form>`;y.addEventListener("submit",G);function b(d){return N?(d=Math.max(e,Math.min(t,d)),isFinite(d)?(N.valueAsNumber=d,N.valueAsNumber):d):+d}function E(d){const w=b(o(n.valueAsNumber));if(isFinite(w)&&($.valueAsNumber=Math.max(e,Math.min(t,w)),v($))){h=$.valueAsNumber,$.value=i(h);return}d&&d.stopPropagation()}function k(d){const w=b($.valueAsNumber);if(isFinite(w)&&(n&&(n.valueAsNumber=r(w)),v($))){h=w;return}d&&d.stopPropagation()}return Object.defineProperty(y,"value",{get(){return h},set(d){d=b(d),isFinite(d)&&($.valueAsNumber=d,n&&(n.valueAsNumber=r(d)),v($)&&(h=d,$.value=i(h)))}}),c===void 0&&N&&(c=N.valueAsNumber),c!==void 0&&(y.value=c),y}function pe(e){return-e}function Nt(e){return e*e}function At(e){return e===P||e===pe?e:e===Math.sqrt?Nt:e===Math.log?Math.exp:e===Math.exp?Math.log:t=>Et(e,t,t)}function Et(e,t,n){let i=100,r,o,a;n=n===void 0?0:+n,t=+t;do o=e(n),a=e(n+oe),o===a&&(a=o+oe),n-=r=-1*oe*(o-t)/(o-a);while(i-- >0&&Math.abs(r)>oe);return i<0?NaN:n}function Ot(e,{locale:t,format:n=Lt(t),label:i,query:r="",placeholder:o="Search",columns:a=_e(e),spellcheck:c,autocomplete:f,autocapitalize:u,filter:m=a===void 0?ze:St(a),datalist:v,disabled:g,required:h=!0,width:$}={}){let N=[];e=H(e),h=!!h;const[y,b]=ce(v),E=p`<input
name=input
type=search
list=${b}
disabled=${g}
spellcheck=${fe(c)}
autocomplete=${K(f)}
autocapitalize=${K(u)}
placeholder=${o}
value=${r}
oninput=${w}
>`,k=p`<output name=output>`,d=p`<form class=inputs-3a86ea style=${D($)}>
${z(i,E)}<div class=inputs-3a86ea-input>
${E}${k}
</div>${y}
</form>`;d.addEventListener("submit",G);function w(){N=E.value||h?e.filter(m(E.value)):[],a!==void 0&&(N.columns=a),k.value=n(N.length)}return w(),Object.defineProperties(d,{value:{get(){return N}},query:{get(){return r},set(x){r=E.value=U(x),w()}}})}function ze(e){const t=`${e}`.split(/\s+/g).filter(n=>n).map(Le);return n=>{if(n==null)return!1;if(typeof n=="object")e:for(const i of t){for(const r of jt(n))if(i.test(r))continue e;return!1}else for(const i of t)if(!i.test(n))return!1;return!0}}function St(e){return t=>{const n=`${t}`.split(/\s+/g).filter(i=>i).map(Le);return i=>{e:for(const r of n){for(const o of e)if(r.test(i[o]))continue e;return!1}return!0}}}function*jt(e){for(const t in e)yield e[t]}function Le(e){return new RegExp(`(?:^|[^\\p{L}-])${zt(e)}`,"iu")}function zt(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}const Lt=ie(e=>{const t=J(e);return n=>`${t(n)} result${n===1?"":"s"}`}),Tt=xe({render(e,t,n,i,{format:r,multiple:o,size:a,label:c,width:f}){const u=p`<select class=inputs-3a86ea-input disabled=${i===!0} multiple=${o} size=${a} name=input>
${t.map(m=>p`<option value=${m} disabled=${typeof i=="function"?i(m):!1} selected=${n(m)}>${U(r(e[m],m,e))}`)}
</select>`;return[p`<form class=inputs-3a86ea style=${D(f)}>${z(c,u)}${u}`,u]},selectedIndexes(e){return Array.from(e.selectedOptions,t=>+t.value)},select(e,t){e.selected=t}}),Te=22;function qt(e,t={}){const{rows:n=11.5,height:i,maxHeight:r=i===void 0?(n+1)*Te-1:void 0,width:o={},maxWidth:a}=t,c=ne(),f=p`<form class="inputs-3a86ea inputs-3a86ea-table" id=${c} style=${{height:C(i),maxHeight:C(r),width:typeof o=="string"||typeof o=="number"?C(o):void 0,maxWidth:C(a)}}>`;return e&&typeof e.then=="function"?(Object.defineProperty(f,"value",{configurable:!0,set(){throw new Error("cannot set value while data is unresolved")}}),Promise.resolve(e).then(u=>qe({root:f,id:c},u,t))):qe({root:f,id:c},e,t),f}function qe({root:e,id:t},n,{columns:i=_e(n),value:r,required:o=!0,sort:a,reverse:c=!1,format:f,locale:u,align:m,header:v,rows:g=11.5,width:h={},multiple:$=!0,layout:N}={}){i=i===void 0?Ft(n):H(i),N===void 0&&(N=i.length>=12?"auto":"fixed"),f=Pt(f,n,i,u),m=Mt(m,n,i);let y=[],b=[],E=n[Symbol.iterator](),k=0,d=Dt(n),w=O(g*2);function x(){k>=0&&(k=E=void 0,b=Uint32Array.from(y=H(n),(l,s)=>s),d=b.length)}function O(l){if(l=Math.floor(l),d!==void 0)return Math.min(d,l);if(l<=k)return l;for(;l>k;){const{done:s,value:_}=E.next();if(s)return d=k;b.push(k++),y.push(_)}return k}let j=null,T=!1,A=new Set,M=null,F=null;const L=p`<tbody>`,Ce=p`<tr><td><input type=${$?"checkbox":"radio"} name=${$?null:"radio"}></td>${i.map(()=>p`<td>`)}`,Y=p`<tr><th><input type=checkbox onclick=${He} disabled=${!$}></th>${i.map(l=>p`<th title=${l} onclick=${s=>$e(s,l)}><span></span>${v&&l in v?v[l]:l}</th>`)}</tr>`;e.appendChild(p.fragment`<table style=${{tableLayout:N}}>
<thead>${O(1)||i.length?Y:null}</thead>
${L}
</table>
<style>${i.map((l,s)=>{const _=[];if(m[l]!=null&&_.push(`text-align:${m[l]}`),h[l]!=null&&_.push(`width:${C(h[l])}`),_.length)return`#${t} tr>:nth-child(${s+2}){${_.join(";")}}`}).filter(P).join(`
`)}</style>`);function le(l,s){if(k===l){for(;l<s;++l)ve(E.next().value,l);k=s}else for(let _;l<s;++l)_=b[l],ve(y[_],_)}function ve(l,s){const _=Ce.cloneNode(!0),S=X(_);if(S.onclick=Ue,S.checked=A.has(s),S.value=s,l!=null)for(let I=0;I<i.length;++I){let ee=i[I],q=l[ee];R(q)&&(q=f[ee](q,s,n),q instanceof Node||(q=document.createTextNode(q)),_.childNodes[I+1].appendChild(q))}L.append(_)}function V(l){x();let s=b.indexOf(l);if(s<L.childNodes.length){const _=L.childNodes[s];X(_).checked=!1}A.delete(l)}function Z(l){x();let s=b.indexOf(l);if(s<L.childNodes.length){const _=L.childNodes[s];X(_).checked=!0}A.add(l)}function*he(l,s){if(x(),l=b.indexOf(l),s=b.indexOf(s),l<s)for(;l<=s;)yield b[l++];else for(;s<=l;)yield b[s++]}function Ie(l){return l[Symbol.iterator]().next().value}function He(l){if(x(),this.checked){A=new Set(b);for(const s of L.childNodes)X(s).checked=!0}else{for(let s of A)V(s);M=F=null,l.detail&&l.currentTarget.blur()}Q()}function Ue(l){x();let s=+this.value;if($)if(l.shiftKey){if(M===null)M=A.size?Ie(A):b[0];else for(let _ of he(M,F))V(_);F=s;for(let _ of he(M,F))Z(_)}else M=F=s,A.has(s)?(V(s),M=F=null,l.detail&&l.currentTarget.blur()):Z(s);else{for(let _ of A)V(_);Z(s)}Q()}function $e(l,s){x();const _=l.currentTarget;let S;if(j===_&&l.metaKey)me(j).textContent="",j=null,T=!1,S=se;else{j===_?T=!T:(j&&(me(j).textContent=""),j=_,T=l.altKey);const I=T?we:se;S=(ee,q)=>I(y[ee][s],y[q][s]),me(_).textContent=T?"\u25BE":"\u25B4"}for(b.sort(S),A=new Set(Array.from(A).sort(S)),e.scrollTo(e.scrollLeft,0);L.firstChild;)L.firstChild.remove();le(0,w=O(g*2)),M=F=null,Q()}function Q(){const l=X(Y);l.disabled=!$&&!A.size,l.indeterminate=$&&A.size&&A.size!==d,l.checked=A.size,r=void 0}if(e.addEventListener("scroll",()=>{e.scrollHeight-e.scrollTop<g*Te*1.5&&w<O(w+1)&&le(w,w=O(w+g))}),a===void 0&&c&&(x(),b.reverse()),r!==void 0){if(x(),$){const l=new Set(r);A=new Set(b.filter(s=>l.has(y[s])))}else{const l=y.indexOf(r);A=l<0?new Set:new Set([l])}Q()}if(O(1)?le(0,w):L.append(p`<tr>${i.length?p`<td>`:null}<td rowspan=${i.length} style="padding-left: var(--length3); font-style: italic;">No results.</td></tr>`),a!==void 0){let l=i.indexOf(a);l>=0&&(c&&(j=Y.childNodes[l+1]),$e({currentTarget:Y.childNodes[l+1]},i[l]))}return Object.defineProperty(e,"value",{get(){if(r===void 0)if(x(),$)r=Array.from(o&&A.size===0?b:A,l=>y[l]),r.columns=i;else if(A.size){const[l]=A;r=y[l]}else r=null;return r},set(l){if(x(),$){const s=new Set(l),_=new Set(b.filter(S=>s.has(y[S])));for(const S of A)_.has(S)||V(S);for(const S of _)A.has(S)||Z(S)}else{const s=y.indexOf(l);A=s<0?new Set:new Set([s])}r=void 0}})}function X(e){return e.firstChild.firstChild}function me(e){return e.firstChild}function Pt(e={},t,n,i){const r=Object.create(null);for(const o of n){if(o in e){r[o]=e[o];continue}switch(Pe(t,o)){case"number":r[o]=J(i);break;case"date":r[o]=ue;break;default:r[o]=re(i);break}}return r}function Mt(e={},t,n){const i=Object.create(null);for(const r of n)r in e?i[r]=e[r]:Pe(t,r)==="number"&&(i[r]="right");return i}function Pe(e,t){for(const n of e){if(n==null)continue;const i=n[t];if(i!=null)return typeof i=="number"?"number":i instanceof Date?"date":void 0}}function Dt(e){if(typeof e.length=="number")return e.length;if(typeof e.size=="number")return e.size;if(typeof e.numRows=="function")return e.numRows()}function Ft(e){const t=new Set;for(const n of e)for(const i in n)t.add(i);return Array.from(t)}function Ct({value:e="",label:t,placeholder:n,spellcheck:i,autocomplete:r,autocapitalize:o,rows:a=3,minlength:c,maxlength:f,required:u=c>0,readonly:m,disabled:v,monospace:g=!1,resize:h=a<12,width:$,...N}={}){const y=p`<textarea
name=text
readonly=${m}
disabled=${v}
required=${u}
rows=${a}
minlength=${c}
maxlength=${f}
spellcheck=${fe(i)}
autocomplete=${K(r)}
autocapitalize=${K(o)}
placeholder=${n}
onkeydown=${E}
style=${{width:$,fontFamily:g?"var(--monospace, monospace)":null,resize:h?null:"none"}}
>`,b=p`<form class="inputs-3a86ea inputs-3a86ea-textarea" style=${D($)}>
${z(t,y)}<div>
${y}
</div>
</form>`;function E(k){if(N.submit&&k.key==="Enter"&&(k.metaKey||k.ctrlKey))return b.dispatchEvent(new Event("submit",ae))}return W(b,y,e,N)}function It(e){const t=new EventTarget;return t.value=e,t}function Me(e){return new Promise(t=>{requestAnimationFrame(()=>{const n=e.closest(".observablehq");if(!n)return t();const i=new MutationObserver(()=>{n.contains(e)||(i.disconnect(),t())});i.observe(n,{childList:!0})})})}function Ht(e,t,n=Me(e)){const i=Fe(t),r=()=>De(e,t),o=()=>(De(t,e),t.dispatchEvent(new Event(i,ae)));return r(),e.addEventListener(Fe(e),o),t.addEventListener(i,r),n.then(()=>t.removeEventListener(i,r)),e}function Ut(e){switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":return e.multiple?e.files:e.files[0];default:return e.value}}function De(e,t){const n=Ut(t);switch(e.type){case"range":case"number":e.valueAsNumber=n;break;case"date":e.valueAsDate=n;break;case"checkbox":e.checked=n;break;case"file":e.multiple?e.files=n:e.files=[n];break;default:e.value=n;break}}function Fe(e){switch(e.type){case"button":case"submit":return"click";case"file":return"change";default:return"input"}}const Kt=Se(Ge);export{Ht as bind,Re as button,rt as checkbox,pt as color,ht as date,$t as datetime,Me as disposal,st as email,Kt as file,Se as fileOf,bt as form,We as formatAuto,ue as formatDate,re as formatLocaleAuto,J as formatLocaleNumber,Be as formatNumber,ge as formatTrim,It as input,kt as number,dt as password,nt as radio,xt as range,Ot as search,ze as searchFilter,Tt as select,qt as table,ct as tel,B as text,Ct as textarea,it as toggle,ft as url};