UNPKG

@tempots/ui

Version:

Provides a higher level of renderables to help fast development with Tempo.

2 lines (1 loc) 33.2 kB
"use strict";var Ae=Object.defineProperty;var Ee=(t,e,o)=>e in t?Ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var vt=(t,e,o)=>Ee(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@tempots/dom"),E=require("@tempots/std"),qt=t=>{const e=t.split("/").pop();if(e==null||e.startsWith("."))return;const o=e.split(".")||[];return o.length>1?"."+o.pop():void 0},Yt=(t,e)=>{const o=qt(e);return o!=null&&(t.length===0||!t.some(n=>o==n))},Le=(t,e,o,n)=>{let s=t.target;for(;s!=null&&!(s instanceof HTMLAnchorElement);)s=s.parentElement;if(s==null)return!0;const r=s;if(t.button!==0||t.ctrlKey||t.metaKey||r.target!=="_self"&&r.target!==""||r.getAttribute("download")!=null)return!0;const{pathname:i,search:c,hash:a}=r;if(n){const u=i+c+a,d=r.getAttribute("href");if(!(d!=null&&d.startsWith("#"))&&d!==u)return!0}return e?!1:Yt(o,i)},Xt=(t,e={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const o=e.ignoreUrlWithExtension===!0&&Array.isArray(e.allowedExtensions)?e.allowedExtensions.map(n=>n.startsWith(".")?n:"."+n):[];return n=>{Le(n,e.ignoreUrlWithExtension??!0,o,e.ignoreExternalUrl??!0)||t()&&n.preventDefault()}},Jt=(t,e)=>t.pathname===e.pathname&&JSON.stringify(t.search)===JSON.stringify(e.search)&&t.hash===e.hash,Pt=(t,e)=>{var r,i;const o=new URL(t,e??((r=l.getWindow())==null?void 0:r.location.toString())),n=Object.fromEntries(((i=o.searchParams)==null?void 0:i.entries())??[]);let s=o.hash;return s.startsWith("#")&&(s=s.substring(1)),{pathname:o.pathname,search:n,hash:s===""?void 0:s}},Rt=(t,e)=>{const o=Pt(e);return t.set(o),t},lt=t=>{const o=new URLSearchParams(t.search).toString(),n=t.hash;return`${t.pathname}${o?`?${o}`:""}${n?`#${n}`:""}`},Pe=t=>t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//"),Se=t=>{const e=t.container.currentURL,o=e.iso(n=>Pt(n),n=>{if(Pe(n.pathname))return lt(n);const s=new URL(n.pathname,e.value),r=s.origin+s.pathname;return lt({...n,pathname:r})});return{value:o,dispose:o.dispose}},Te=()=>{const t=l.getWindow(),e=(t==null?void 0:t.location.hash)===""?void 0:(t==null?void 0:t.location.hash.substring(1))??void 0;return{pathname:(t==null?void 0:t.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((t==null?void 0:t.location.search)??"").entries()),hash:e}},ke=()=>{const t=l.prop(Te(),Jt),e=l.getWindow(),o=()=>{let n=(e==null?void 0:e.location.hash)??"";n.startsWith("#")&&(n=n.substring(1));const s={pathname:(e==null?void 0:e.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((e==null?void 0:e.location.search)??"").entries()),hash:n===""?void 0:n};t.set(s)};return e==null||e.addEventListener("popstate",o),t.onDispose(()=>{e==null||e.removeEventListener("popstate",o)}),t.on(n=>{e==null||e.history.pushState({},"",lt(n))}),{value:t,dispose:t.dispose}},gt={mark:l.makeProviderMark("Location"),create:(t,e)=>{if(e.isBrowser())return ke();if(e.isHeadless())return Se(e);throw new Error("Unknown context")}},De=t=>{document.startViewTransition?document.startViewTransition(t):t()},Gt=(t,...e)=>{if(typeof t=="string"||l.Signal.is(t))return Gt({href:t},...e);const{href:o,withViewTransition:n,...s}=t;return l.Use(gt,r=>l.html.a(l.on.click(Xt(()=>(n===!0?De(()=>{Rt(r,l.Value.get(o))}):Rt(r,l.Value.get(o)),!0),s)),l.attr.href(o),...e))},Ce={mark:l.makeProviderMark("Appearance"),create:()=>{const t=Qt();return{value:t,dispose:t.dispose}}};function Qt(){const t=l.getWindow(),e=t!=null&&t.matchMedia!=null?t.matchMedia("(prefers-color-scheme: dark)"):void 0,o=(e==null?void 0:e.matches)??!1,n=l.prop(o?"dark":"light"),s=r=>n.set(r.matches?"dark":"light");return e==null||e.addEventListener("change",s),n.onDispose(()=>e==null?void 0:e.removeEventListener("change",s)),n}const St=(t,e)=>{if(typeof e=="function")return St(t,{success:e});const o=e.failure??(i=>i.map(c=>`Error: ${c}`)),n=e.success,s=e.loading??(()=>l.Empty),r=e.notAsked??(()=>l.Empty);return l.OneOfType(l.Value.toSignal(t),{AsyncSuccess:i=>n(i.$.value),AsyncFailure:i=>o(i.$.error),Loading:i=>s(i.map(c=>c.previousValue)),NotAsked:r})},We=(t=10)=>l.WithElement(e=>l.OnDispose(E.delayed(()=>e==null?void 0:e.focus(),t))),Fe=(t=10)=>l.WithElement(e=>{const o=E.delayed(()=>e.select(),t);return l.OnDispose(o)});function Ve(t){const e=Object.entries(t);return l.Fragment(...e.map(([o,n])=>l.attr.class(l.Value.map(n,s=>s?o:void 0))))}const Me=l.WithElement(t=>{const e=t.style.getPropertyValue(":empty");return t.style.setProperty(":empty","display:none"),l.OnDispose(o=>{o&&t.style.setProperty(":empty",e)})}),Ne=t=>l.Portal("head > title",l.attr.innerText(t)),Ue={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},at={partial:new Map,full:new Map},tt={partial:null,full:null};function He(t){return tt[t]==null&&(tt[t]=new IntersectionObserver(e=>{e.forEach(o=>{const n=at[t].get(o.target);n==null||n.set(o.isIntersecting)})},Ue[t])),tt[t]}const Zt=({mode:t="partial",once:e=!1},o)=>{const n=l.prop(!1);return l.Fragment(l.WithElement(s=>{const r=typeof IntersectionObserver<"u"?He(t):null;at[t].set(s,n),r==null||r.observe(s);function i(){var a;r==null||r.unobserve(s),at[t].delete(s),at[t].size===0&&((a=tt[t])==null||a.disconnect(),tt[t]=null)}let c=null;return e&&(c=n.on(a=>{a&&i()})),l.OnDispose(()=>{n.dispose(),i(),c==null||c()})}),l.renderableOfTNode(o(n)))},$e=(t,e,o)=>Zt(t,n=>l.When(n,e,o??(()=>l.Empty)));function te(t){return l.WithElement(e=>{const o=n=>{e.contains(n.target)||t(n)};return document.addEventListener("click",o),l.OnDispose(()=>{document.removeEventListener("click",o)})})}const Y=(t,e)=>t===void 0||t===e,Nt=(t,e)=>t===void 0||t===e;function ee(t,e){return typeof t=="string"?e.key===t:Nt(t.key,e.key)&&Nt(t.code,e.code)&&Y(t.ctrlKey,e.ctrlKey)&&Y(t.altKey,e.altKey)&&Y(t.shiftKey,e.shiftKey)&&Y(t.metaKey,e.metaKey)&&Y(t.repeat,e.repeat)&&Y(t.commandOrControlKey,e.metaKey||e.ctrlKey)}function Tt({allowedKeys:t,handler:e}){return l.WithElement(o=>{const n=s=>{if(o.contains(s.target)){for(const r of t)if(ee(r,s)){e(s);break}}};return document.addEventListener("keydown",n),l.OnDispose(()=>{document.removeEventListener("keydown",n)})})}function Ke(t){return Tt({allowedKeys:["Enter"],handler:t})}function Be(t){return Tt({allowedKeys:["Escape"],handler:t})}const J=Math.min,j=Math.max,ut=Math.round,ct=Math.floor,W=t=>({x:t,y:t}),ze={left:"right",right:"left",bottom:"top",top:"bottom"},_e={start:"end",end:"start"};function Ot(t,e,o){return j(t,J(e,o))}function ot(t,e){return typeof t=="function"?t(e):t}function I(t){return t.split("-")[0]}function st(t){return t.split("-")[1]}function ne(t){return t==="x"?"y":"x"}function kt(t){return t==="y"?"height":"width"}function H(t){return["top","bottom"].includes(I(t))?"y":"x"}function Dt(t){return ne(H(t))}function je(t,e,o){o===void 0&&(o=!1);const n=st(t),s=Dt(t),r=kt(s);let i=s==="x"?n===(o?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(i=ft(i)),[i,ft(i)]}function Ie(t){const e=ft(t);return[bt(t),e,bt(e)]}function bt(t){return t.replace(/start|end/g,e=>_e[e])}function qe(t,e,o){const n=["left","right"],s=["right","left"],r=["top","bottom"],i=["bottom","top"];switch(t){case"top":case"bottom":return o?e?s:n:e?n:s;case"left":case"right":return e?r:i;default:return[]}}function Ye(t,e,o,n){const s=st(t);let r=qe(I(t),o==="start",n);return s&&(r=r.map(i=>i+"-"+s),e&&(r=r.concat(r.map(bt)))),r}function ft(t){return t.replace(/left|right|bottom|top/g,e=>ze[e])}function Xe(t){return{top:0,right:0,bottom:0,left:0,...t}}function oe(t){return typeof t!="number"?Xe(t):{top:t,right:t,bottom:t,left:t}}function ht(t){const{x:e,y:o,width:n,height:s}=t;return{width:n,height:s,top:o,left:e,right:e+n,bottom:o+s,x:e,y:o}}function Ut(t,e,o){let{reference:n,floating:s}=t;const r=H(e),i=Dt(e),c=kt(i),a=I(e),u=r==="y",d=n.x+n.width/2-s.width/2,h=n.y+n.height/2-s.height/2,g=n[c]/2-s[c]/2;let f;switch(a){case"top":f={x:d,y:n.y-s.height};break;case"bottom":f={x:d,y:n.y+n.height};break;case"right":f={x:n.x+n.width,y:h};break;case"left":f={x:n.x-s.width,y:h};break;default:f={x:n.x,y:n.y}}switch(st(e)){case"start":f[i]-=g*(o&&u?-1:1);break;case"end":f[i]+=g*(o&&u?-1:1);break}return f}const Je=async(t,e,o)=>{const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:i}=o,c=r.filter(Boolean),a=await(i.isRTL==null?void 0:i.isRTL(e));let u=await i.getElementRects({reference:t,floating:e,strategy:s}),{x:d,y:h}=Ut(u,n,a),g=n,f={},m=0;for(let y=0;y<c.length;y++){const{name:w,fn:p}=c[y],{x,y:v,data:O,reset:R}=await p({x:d,y:h,initialPlacement:n,placement:g,strategy:s,middlewareData:f,rects:u,platform:i,elements:{reference:t,floating:e}});d=x??d,h=v??h,f={...f,[w]:{...f[w],...O}},R&&m<=50&&(m++,typeof R=="object"&&(R.placement&&(g=R.placement),R.rects&&(u=R.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:s}):R.rects),{x:d,y:h}=Ut(u,g,a)),y=-1)}return{x:d,y:h,placement:g,strategy:s,middlewareData:f}};async function se(t,e){var o;e===void 0&&(e={});const{x:n,y:s,platform:r,rects:i,elements:c,strategy:a}=t,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:g=!1,padding:f=0}=ot(e,t),m=oe(f),w=c[g?h==="floating"?"reference":"floating":h],p=ht(await r.getClippingRect({element:(o=await(r.isElement==null?void 0:r.isElement(w)))==null||o?w:w.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:u,rootBoundary:d,strategy:a})),x=h==="floating"?{x:n,y:s,width:i.floating.width,height:i.floating.height}:i.reference,v=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),O=await(r.isElement==null?void 0:r.isElement(v))?await(r.getScale==null?void 0:r.getScale(v))||{x:1,y:1}:{x:1,y:1},R=ht(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:x,offsetParent:v,strategy:a}):x);return{top:(p.top-R.top+m.top)/O.y,bottom:(R.bottom-p.bottom+m.bottom)/O.y,left:(p.left-R.left+m.left)/O.x,right:(R.right-p.right+m.right)/O.x}}const Ge=t=>({name:"arrow",options:t,async fn(e){const{x:o,y:n,placement:s,rects:r,platform:i,elements:c,middlewareData:a}=e,{element:u,padding:d=0}=ot(t,e)||{};if(u==null)return{};const h=oe(d),g={x:o,y:n},f=Dt(s),m=kt(f),y=await i.getDimensions(u),w=f==="y",p=w?"top":"left",x=w?"bottom":"right",v=w?"clientHeight":"clientWidth",O=r.reference[m]+r.reference[f]-g[f]-r.floating[m],R=g[f]-r.reference[f],P=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let b=P?P[v]:0;(!b||!await(i.isElement==null?void 0:i.isElement(P)))&&(b=c.floating[v]||r.floating[m]);const K=O/2-R/2,M=b/2-y[m]/2-1,S=J(h[p],M),B=J(h[x],M),z=S,Z=b-y[m]-B,A=b/2-y[m]/2+K,_=Ot(z,A,Z),N=!a.arrow&&st(s)!=null&&A!==_&&r.reference[m]/2-(A<z?S:B)-y[m]/2<0,T=N?A<z?A-z:A-Z:0;return{[f]:g[f]+T,data:{[f]:_,centerOffset:A-_-T,...N&&{alignmentOffset:T}},reset:N}}}),Qe=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var o,n;const{placement:s,middlewareData:r,rects:i,initialPlacement:c,platform:a,elements:u}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:y=!0,...w}=ot(t,e);if((o=r.arrow)!=null&&o.alignmentOffset)return{};const p=I(s),x=H(c),v=I(c)===c,O=await(a.isRTL==null?void 0:a.isRTL(u.floating)),R=g||(v||!y?[ft(c)]:Ie(c)),P=m!=="none";!g&&P&&R.push(...Ye(c,y,m,O));const b=[c,...R],K=await se(e,w),M=[];let S=((n=r.flip)==null?void 0:n.overflows)||[];if(d&&M.push(K[p]),h){const A=je(s,i,O);M.push(K[A[0]],K[A[1]])}if(S=[...S,{placement:s,overflows:M}],!M.every(A=>A<=0)){var B,z;const A=(((B=r.flip)==null?void 0:B.index)||0)+1,_=b[A];if(_&&(!(h==="alignment"?x!==H(_):!1)||S.every(k=>k.overflows[0]>0&&H(k.placement)===x)))return{data:{index:A,overflows:S},reset:{placement:_}};let N=(z=S.filter(T=>T.overflows[0]<=0).sort((T,k)=>T.overflows[1]-k.overflows[1])[0])==null?void 0:z.placement;if(!N)switch(f){case"bestFit":{var Z;const T=(Z=S.filter(k=>{if(P){const U=H(k.placement);return U===x||U==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(U=>U>0).reduce((U,be)=>U+be,0)]).sort((k,U)=>k[1]-U[1])[0])==null?void 0:Z[0];T&&(N=T);break}case"initialPlacement":N=c;break}if(s!==N)return{reset:{placement:N}}}return{}}}};async function Ze(t,e){const{placement:o,platform:n,elements:s}=t,r=await(n.isRTL==null?void 0:n.isRTL(s.floating)),i=I(o),c=st(o),a=H(o)==="y",u=["left","top"].includes(i)?-1:1,d=r&&a?-1:1,h=ot(e,t);let{mainAxis:g,crossAxis:f,alignmentAxis:m}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return c&&typeof m=="number"&&(f=c==="end"?m*-1:m),a?{x:f*d,y:g*u}:{x:g*u,y:f*d}}const tn=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var o,n;const{x:s,y:r,placement:i,middlewareData:c}=e,a=await Ze(e,t);return i===((o=c.offset)==null?void 0:o.placement)&&(n=c.arrow)!=null&&n.alignmentOffset?{}:{x:s+a.x,y:r+a.y,data:{...a,placement:i}}}}},en=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:o,y:n,placement:s}=e,{mainAxis:r=!0,crossAxis:i=!1,limiter:c={fn:w=>{let{x:p,y:x}=w;return{x:p,y:x}}},...a}=ot(t,e),u={x:o,y:n},d=await se(e,a),h=H(I(s)),g=ne(h);let f=u[g],m=u[h];if(r){const w=g==="y"?"top":"left",p=g==="y"?"bottom":"right",x=f+d[w],v=f-d[p];f=Ot(x,f,v)}if(i){const w=h==="y"?"top":"left",p=h==="y"?"bottom":"right",x=m+d[w],v=m-d[p];m=Ot(x,m,v)}const y=c.fn({...e,[g]:f,[h]:m});return{...y,data:{x:y.x-o,y:y.y-n,enabled:{[g]:r,[h]:i}}}}}};function pt(){return typeof window<"u"}function Q(t){return re(t)?(t.nodeName||"").toLowerCase():"#document"}function L(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function V(t){var e;return(e=(re(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function re(t){return pt()?t instanceof Node||t instanceof L(t).Node:!1}function D(t){return pt()?t instanceof Element||t instanceof L(t).Element:!1}function F(t){return pt()?t instanceof HTMLElement||t instanceof L(t).HTMLElement:!1}function Ht(t){return!pt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof L(t).ShadowRoot}function rt(t){const{overflow:e,overflowX:o,overflowY:n,display:s}=C(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+o)&&!["inline","contents"].includes(s)}function nn(t){return["table","td","th"].includes(Q(t))}function yt(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function Ct(t){const e=Wt(),o=D(t)?C(t):t;return["transform","translate","scale","rotate","perspective"].some(n=>o[n]?o[n]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!e&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!e&&(o.filter?o.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(n=>(o.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(o.contain||"").includes(n))}function on(t){let e=$(t);for(;F(e)&&!G(e);){if(Ct(e))return e;if(yt(e))return null;e=$(e)}return null}function Wt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function G(t){return["html","body","#document"].includes(Q(t))}function C(t){return L(t).getComputedStyle(t)}function wt(t){return D(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function $(t){if(Q(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Ht(t)&&t.host||V(t);return Ht(e)?e.host:e}function ie(t){const e=$(t);return G(e)?t.ownerDocument?t.ownerDocument.body:t.body:F(e)&&rt(e)?e:ie(e)}function et(t,e,o){var n;e===void 0&&(e=[]),o===void 0&&(o=!0);const s=ie(t),r=s===((n=t.ownerDocument)==null?void 0:n.body),i=L(s);if(r){const c=At(i);return e.concat(i,i.visualViewport||[],rt(s)?s:[],c&&o?et(c):[])}return e.concat(s,et(s,[],o))}function At(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ce(t){const e=C(t);let o=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const s=F(t),r=s?t.offsetWidth:o,i=s?t.offsetHeight:n,c=ut(o)!==r||ut(n)!==i;return c&&(o=r,n=i),{width:o,height:n,$:c}}function Ft(t){return D(t)?t:t.contextElement}function X(t){const e=Ft(t);if(!F(e))return W(1);const o=e.getBoundingClientRect(),{width:n,height:s,$:r}=ce(e);let i=(r?ut(o.width):o.width)/n,c=(r?ut(o.height):o.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const sn=W(0);function ae(t){const e=L(t);return!Wt()||!e.visualViewport?sn:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function rn(t,e,o){return e===void 0&&(e=!1),!o||e&&o!==L(t)?!1:e}function q(t,e,o,n){e===void 0&&(e=!1),o===void 0&&(o=!1);const s=t.getBoundingClientRect(),r=Ft(t);let i=W(1);e&&(n?D(n)&&(i=X(n)):i=X(t));const c=rn(r,o,n)?ae(r):W(0);let a=(s.left+c.x)/i.x,u=(s.top+c.y)/i.y,d=s.width/i.x,h=s.height/i.y;if(r){const g=L(r),f=n&&D(n)?L(n):n;let m=g,y=At(m);for(;y&&n&&f!==m;){const w=X(y),p=y.getBoundingClientRect(),x=C(y),v=p.left+(y.clientLeft+parseFloat(x.paddingLeft))*w.x,O=p.top+(y.clientTop+parseFloat(x.paddingTop))*w.y;a*=w.x,u*=w.y,d*=w.x,h*=w.y,a+=v,u+=O,m=L(y),y=At(m)}}return ht({width:d,height:h,x:a,y:u})}function Vt(t,e){const o=wt(t).scrollLeft;return e?e.left+o:q(V(t)).left+o}function le(t,e,o){o===void 0&&(o=!1);const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-(o?0:Vt(t,n)),r=n.top+e.scrollTop;return{x:s,y:r}}function cn(t){let{elements:e,rect:o,offsetParent:n,strategy:s}=t;const r=s==="fixed",i=V(n),c=e?yt(e.floating):!1;if(n===i||c&&r)return o;let a={scrollLeft:0,scrollTop:0},u=W(1);const d=W(0),h=F(n);if((h||!h&&!r)&&((Q(n)!=="body"||rt(i))&&(a=wt(n)),F(n))){const f=q(n);u=X(n),d.x=f.x+n.clientLeft,d.y=f.y+n.clientTop}const g=i&&!h&&!r?le(i,a,!0):W(0);return{width:o.width*u.x,height:o.height*u.y,x:o.x*u.x-a.scrollLeft*u.x+d.x+g.x,y:o.y*u.y-a.scrollTop*u.y+d.y+g.y}}function an(t){return Array.from(t.getClientRects())}function ln(t){const e=V(t),o=wt(t),n=t.ownerDocument.body,s=j(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=j(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let i=-o.scrollLeft+Vt(t);const c=-o.scrollTop;return C(n).direction==="rtl"&&(i+=j(e.clientWidth,n.clientWidth)-s),{width:s,height:r,x:i,y:c}}function un(t,e){const o=L(t),n=V(t),s=o.visualViewport;let r=n.clientWidth,i=n.clientHeight,c=0,a=0;if(s){r=s.width,i=s.height;const u=Wt();(!u||u&&e==="fixed")&&(c=s.offsetLeft,a=s.offsetTop)}return{width:r,height:i,x:c,y:a}}function fn(t,e){const o=q(t,!0,e==="fixed"),n=o.top+t.clientTop,s=o.left+t.clientLeft,r=F(t)?X(t):W(1),i=t.clientWidth*r.x,c=t.clientHeight*r.y,a=s*r.x,u=n*r.y;return{width:i,height:c,x:a,y:u}}function $t(t,e,o){let n;if(e==="viewport")n=un(t,o);else if(e==="document")n=ln(V(t));else if(D(e))n=fn(e,o);else{const s=ae(t);n={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ht(n)}function ue(t,e){const o=$(t);return o===e||!D(o)||G(o)?!1:C(o).position==="fixed"||ue(o,e)}function hn(t,e){const o=e.get(t);if(o)return o;let n=et(t,[],!1).filter(c=>D(c)&&Q(c)!=="body"),s=null;const r=C(t).position==="fixed";let i=r?$(t):t;for(;D(i)&&!G(i);){const c=C(i),a=Ct(i);!a&&c.position==="fixed"&&(s=null),(r?!a&&!s:!a&&c.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||rt(i)&&!a&&ue(t,i))?n=n.filter(d=>d!==i):s=c,i=$(i)}return e.set(t,n),n}function dn(t){let{element:e,boundary:o,rootBoundary:n,strategy:s}=t;const i=[...o==="clippingAncestors"?yt(e)?[]:hn(e,this._c):[].concat(o),n],c=i[0],a=i.reduce((u,d)=>{const h=$t(e,d,s);return u.top=j(h.top,u.top),u.right=J(h.right,u.right),u.bottom=J(h.bottom,u.bottom),u.left=j(h.left,u.left),u},$t(e,c,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function mn(t){const{width:e,height:o}=ce(t);return{width:e,height:o}}function gn(t,e,o){const n=F(e),s=V(e),r=o==="fixed",i=q(t,!0,r,e);let c={scrollLeft:0,scrollTop:0};const a=W(0);function u(){a.x=Vt(s)}if(n||!n&&!r)if((Q(e)!=="body"||rt(s))&&(c=wt(e)),n){const f=q(e,!0,r,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else s&&u();r&&!n&&s&&u();const d=s&&!n&&!r?le(s,c):W(0),h=i.left+c.scrollLeft-a.x-d.x,g=i.top+c.scrollTop-a.y-d.y;return{x:h,y:g,width:i.width,height:i.height}}function xt(t){return C(t).position==="static"}function Kt(t,e){if(!F(t)||C(t).position==="fixed")return null;if(e)return e(t);let o=t.offsetParent;return V(t)===o&&(o=o.ownerDocument.body),o}function fe(t,e){const o=L(t);if(yt(t))return o;if(!F(t)){let s=$(t);for(;s&&!G(s);){if(D(s)&&!xt(s))return s;s=$(s)}return o}let n=Kt(t,e);for(;n&&nn(n)&&xt(n);)n=Kt(n,e);return n&&G(n)&&xt(n)&&!Ct(n)?o:n||on(t)||o}const pn=async function(t){const e=this.getOffsetParent||fe,o=this.getDimensions,n=await o(t.floating);return{reference:gn(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function yn(t){return C(t).direction==="rtl"}const wn={convertOffsetParentRelativeRectToViewportRelativeRect:cn,getDocumentElement:V,getClippingRect:dn,getOffsetParent:fe,getElementRects:pn,getClientRects:an,getDimensions:mn,getScale:X,isElement:D,isRTL:yn};function he(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function vn(t,e){let o=null,n;const s=V(t);function r(){var c;clearTimeout(n),(c=o)==null||c.disconnect(),o=null}function i(c,a){c===void 0&&(c=!1),a===void 0&&(a=1),r();const u=t.getBoundingClientRect(),{left:d,top:h,width:g,height:f}=u;if(c||e(),!g||!f)return;const m=ct(h),y=ct(s.clientWidth-(d+g)),w=ct(s.clientHeight-(h+f)),p=ct(d),v={rootMargin:-m+"px "+-y+"px "+-w+"px "+-p+"px",threshold:j(0,J(1,a))||1};let O=!0;function R(P){const b=P[0].intersectionRatio;if(b!==a){if(!O)return i();b?i(!1,b):n=setTimeout(()=>{i(!1,1e-7)},1e3)}b===1&&!he(u,t.getBoundingClientRect())&&i(),O=!1}try{o=new IntersectionObserver(R,{...v,root:s.ownerDocument})}catch{o=new IntersectionObserver(R,v)}o.observe(t)}return i(!0),r}function xn(t,e,o,n){n===void 0&&(n={});const{ancestorScroll:s=!0,ancestorResize:r=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:a=!1}=n,u=Ft(t),d=s||r?[...u?et(u):[],...et(e)]:[];d.forEach(p=>{s&&p.addEventListener("scroll",o,{passive:!0}),r&&p.addEventListener("resize",o)});const h=u&&c?vn(u,o):null;let g=-1,f=null;i&&(f=new ResizeObserver(p=>{let[x]=p;x&&x.target===u&&f&&(f.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var v;(v=f)==null||v.observe(e)})),o()}),u&&!a&&f.observe(u),f.observe(e));let m,y=a?q(t):null;a&&w();function w(){const p=q(t);y&&!he(y,p)&&o(),y=p,m=requestAnimationFrame(w)}return o(),()=>{var p;d.forEach(x=>{s&&x.removeEventListener("scroll",o),r&&x.removeEventListener("resize",o)}),h==null||h(),(p=f)==null||p.disconnect(),f=null,a&&cancelAnimationFrame(m)}}const Rn=tn,On=en,Bt=Qe,bn=Ge,An=(t,e,o)=>{const n=new Map,s={platform:wn,...o},r={...s.platform,_c:n};return Je(t,e,{...s,platform:r})},En=["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],Ln=(t,e={isOpen:!1})=>{const o=[];let n=null;const s=l.Value.deriveProp(e.isOpen);function r(c){n=c,s.set(!0)}function i(){s.set(!1),o.forEach(c=>c()),o.length=0}return l.Fragment(t(r,i),l.When(s,()=>l.Fragment((n==null?void 0:n.onClickOutside)!=null?te(n.onClickOutside):null,l.WithElement(c=>l.Portal("body",l.html.div(l.WithElement(a=>{a.style.position="absolute";const u=typeof(n==null?void 0:n.target)=="string"?c.querySelector(n.target):(n==null?void 0:n.target)??c;if(u==null)throw new Error(`Target not found: ${n==null?void 0:n.target}`);let d=null;const h=l.Value.toSignal((n==null?void 0:n.mainAxisOffset)??0),g=l.Value.toSignal((n==null?void 0:n.crossAxisOffset)??0),f=l.Value.toSignal((n==null?void 0:n.placement)??"top"),m=l.Value.toSignal((n==null?void 0:n.arrowPadding)??0),y=n==null?void 0:n.arrow,w=l.prop({centerOffset:0,alignmentOffset:0,containerWidth:0,containerHeight:0,x:void 0,y:void 0});async function p(){const v=[Bt(),Rn({mainAxis:h.get(),crossAxis:g.get()}),On(),Bt()];y!=null&&d!=null&&v.push(bn({element:d,padding:m.get()}));const O=await An(u,a,{placement:f.get(),strategy:"absolute",middleware:v}),{x:R,y:P,middlewareData:b}=O;if(a.style.top=`${P}px`,a.style.left=`${R}px`,d!=null&&b.arrow!=null){const{x:K,y:M,centerOffset:S,alignmentOffset:B}=b.arrow;w.set({x:K,y:M,centerOffset:S,alignmentOffset:B,containerWidth:a.offsetWidth,containerHeight:a.offsetHeight})}}const x=l.effectOf(h,g,f)(p);return l.Fragment(n==null?void 0:n.content,(n==null?void 0:n.arrow)!=null?l.html.div(n==null?void 0:n.arrow(l.computedOf(w,f)((v,O)=>({...v,placement:O}))),l.WithElement(v=>{d=v,p()})):null,l.OnDispose(w.dispose,xn(u,a,p),x))})))))))},de=(t,e,o)=>{const n=l.prop(E.AsyncResult.notAsked),s=n.map(h=>E.AsyncResult.isSuccess(h)?h.value:void 0),r=n.map(h=>E.AsyncResult.isFailure(h)?h.error:void 0),i=n.map(h=>E.AsyncResult.isLoading(h));let c;const a=async h=>{c==null||c.abort(),c=new AbortController;const g=c.signal,f=n.get();n.set(E.AsyncResult.loading(E.AsyncResult.getOrUndefined(f)));try{const m=await e({request:h,abortSignal:g,previous:f});await Promise.resolve(),c=void 0,n.set(E.AsyncResult.success(m))}catch(m){c=void 0,n.set(E.AsyncResult.failure(o(m)))}},u=()=>a(l.Value.get(t)),d=()=>{c==null||c.abort(),c=void 0,n.dispose()};return n.onDispose(l.Value.on(t,a)),{status:n,value:s,error:r,loading:i,reload:u,dispose:d}},me=(t,e)=>{const{status:o,dispose:n,reload:s}=t,{loading:r,failure:i,success:c}=e;return l.Fragment(l.OnDispose(n),St(o,{loading:r!=null?a=>r(a,s):void 0,failure:i!=null?a=>i(a,s):void 0,success:a=>c(a,s)}))},Pn=({request:t,load:e,mapError:o=n=>n})=>{const n=de(t,e,o);return s=>me(n,s)},ge=(t,e)=>{if(typeof e=="function")return ge(t,{success:e});const o=e.failure??(s=>l.Fragment(l.OnDispose(s.on(console.error)),s.map(r=>`Error: ${r}`))),n=e.success;return l.OneOfType(l.Value.toSignal(t),{Success:s=>n(s.$.value),Failure:s=>o(s.$.error)})},Sn=()=>l.on.focus(t=>{var e;return(e=t.target)==null?void 0:e.select()});class it{constructor(e,o,n,s,r,i){vt(this,"equals",e=>E.nearEqual(this.left,e.left)&&E.nearEqual(this.top,e.top)&&E.nearEqual(this.width,e.width)&&E.nearEqual(this.height,e.height));this.left=e,this.top=o,this.width=n,this.height=s,this.localLeft=r,this.localTop=i}static of({left:e=0,top:o=0,width:n=0,height:s=0,localLeft:r=0,localTop:i=0}){return new it(e,o,n,s,r,i)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return{x:this.left+this.width/2,y:this.top+this.height/2}}get localCenter(){return{x:this.localLeft+this.width/2,y:this.localTop+this.height/2}}get localBottom(){return this.localTop+this.height}get localRight(){return this.localLeft+this.width}get size(){return{width:this.width,height:this.height}}}function Et(t){const e=t.getBoundingClientRect();return it.of({top:e.top+window.scrollY,left:e.left+window.scrollX,width:e.width,height:e.height,localLeft:t.offsetLeft,localTop:t.offsetTop})}const Tn=t=>l.WithBrowserCtx(e=>{const{element:o}=e,n=l.prop(Et(o),(c,a)=>c.equals(a)),s=l.renderableOfTNode(t(n))(e),r=()=>n.set(it.of(Et(o)));let i=null;return typeof ResizeObserver<"u"&&(i=new ResizeObserver(r)),i==null||i.observe(o),l.OnDispose(c=>{i==null||i.disconnect(),s(c)})});function zt(t){return{width:(t==null?void 0:t.innerWidth)??0,height:(t==null?void 0:t.innerHeight)??0}}const kn=t=>e=>{const o=l.getWindow(),n=l.prop(zt(o),(i,c)=>i.width===c.width&&i.height===c.height),s=l.renderableOfTNode(t(n))(e),r=()=>n.set(zt(o));return o==null||o.addEventListener("resize",r),i=>{o==null||o.removeEventListener("resize",r),s(i)}},pe=(t,e)=>{const o=e.split("/").filter(s=>s!==""),n={};for(let s=0;s<t.length;s++){const r=t[s],i=o[s];if(!i&&r.type!=="catch-all")return null;if(r.type==="literal"){if(r.value!==i)return null}else if(r.type==="param")n[r.name]=i;else if(r.type==="catch-all")return{params:n,path:e}}return o.length!==t.length?null:{params:n,path:e}},Mt=t=>t.split("/").map(e=>e.startsWith(":")?{type:"param",name:e.slice(1)}:e==="*"?{type:"catch-all"}:{type:"literal",value:e}).filter(e=>e.type!=="literal"||e.value!==""),Dn=t=>{const e=t.map(o=>{const n=Mt(o);return{route:o,segments:n}});return function(n){for(const{segments:s,route:r}of e){const i=pe(s,n);if(i)return{...i,route:r}}return null}},dt={mark:l.makeProviderMark("RouterContext"),create:()=>{const t=l.prop([]);return{value:t,dispose:()=>t.dispose()}}},Cn=(t,e,o)=>{const n=o.split("/").filter(i=>i!==""),s={};let r=0;for(let i=0;i<t.length;i++){const c=t[i],a=n[i];if(!a&&c.type!=="catch-all")return null;if(c.type==="literal"){if(c.value!==a)return null;r++}else if(c.type==="param")s[c.name]=a,r++;else if(c.type==="catch-all"){const u="/"+n.slice(0,r).join("/"),d="/"+n.slice(r).join("/");return{params:s,matchedPath:u==="/"?"":u,remainingPath:d==="/"?"":d,route:e}}}if(n.length===t.length){const i="/"+n.join("/");return{params:s,matchedPath:i==="/"?"":i,remainingPath:"",route:e}}return null},ye=t=>{const e=t.map(o=>{const n=Mt(o);return{route:o,segments:n}});return function(n){for(const{segments:s,route:r}of e){const i=Cn(s,r,n);if(i)return i}return null}},Wn=t=>{const e=ye(Object.keys(t));return l.Provide(dt,{},()=>l.Use(gt,o=>l.Use(dt,n=>{const s=o.map(r=>{const i=e(r.pathname);if(i==null)throw console.error("No route found for",r),new Error("No route found");const c={matchedPath:i.matchedPath,remainingPath:i.remainingPath,fullPath:r.pathname,params:i.params};return n.value=[...n.value,c],{params:i.params,route:i.route,path:i.matchedPath||r.pathname,search:r.search,hash:r.hash}});return l.OneOfTuple(s.map(r=>[r.route,r]),t)})))},Fn=t=>{const e=ye(Object.keys(t));return l.Use(dt,o=>l.Use(gt,n=>{const s=o.map(r=>{const i=r[r.length-1],c=(i==null?void 0:i.remainingPath)||"";if(c==="")throw console.error("No remaining path for SubRouter",r),new Error("No remaining path for SubRouter");const a=e(c);if(a==null)throw console.error("No route found for remaining path",c),new Error("No route found");return{params:a.params,route:a.route,path:a.matchedPath,search:n.value.search,hash:n.value.hash}});return l.OneOfTuple(s.map(r=>[r.route,r]),t)}))},mt=60*1e3,Lt=60*mt,nt=24*Lt,_t=7*nt,jt=30*nt,Vn=365*nt,Mn=[{max:mt*90,value:mt,name:"minute",past:{singular:"a minute ago",plural:"{} minutes ago"},future:{singular:"in a minute",plural:"in {} minutes"}},{max:Lt*36,value:Lt,name:"hour",past:{singular:"an hour ago",plural:"{} hours ago"},future:{singular:"in an hour",plural:"in {} hours"}},{max:nt*10,value:nt,name:"day",past:{singular:"yesterday",plural:"{} days ago"},future:{singular:"tomorrow",plural:"in {} days"}},{max:_t*6,value:_t,name:"week",past:{singular:"last week",plural:"{} weeks ago"},future:{singular:"in a week",plural:"in {} weeks"}},{max:jt*18,value:jt,name:"month",past:{singular:"last month",plural:"{} months ago"},future:{singular:"in a month",plural:"in {} months"}},{max:1/0,value:Vn,name:"year",past:{singular:"last year",plural:"{} years ago"},future:{singular:"in a year",plural:"in {} years"}}];function It(t,e,o,n){const s=Math.round(t/e);return s<=1?o:n.replace("{}",s.toLocaleString(void 0,{maximumFractionDigits:0,minimumFractionDigits:0}))}const we=(t=1e3)=>{const e=l.prop(new Date),o=E.interval(()=>e.set(new Date),t);return e.onDispose(o),e},ve=t=>{const e=Math.abs(t);if(e<mt)return t<0?"just now":"in a moment";for(const o of Mn)if(e<o.max)return t<0?It(e,o.value,o.past.singular,o.past.plural):It(e,o.value,o.future.singular,o.future.plural);throw new Error("unreachable")},xe=(t,{now:e,frequency:o=1e4}={})=>{const n=e!=null?l.Signal.is(e)?e.derive():l.prop(e):we(o),s=l.computedOf(t,n)((r,i)=>r.getTime()-i.getTime());return s.onDispose(()=>l.Value.dispose(n)),s},Re=(t,e={})=>{const o=xe(t,e),n=o.map(ve);return n.onDispose(o.dispose),n},Nn=(t,e={})=>Re(t,e);class Oe extends l.Prop{constructor(){super(...arguments);vt(this,"tick",()=>this.update(o=>o+1))}}const Un=(t=0)=>new Oe(t,(e,o)=>e===o);exports.Anchor=Gt;exports.Appearance=Ce;exports.AsyncResultView=St;exports.AutoFocus=We;exports.AutoSelect=Fe;exports.ChildRouter=Fn;exports.ElementRect=Tn;exports.HTMLTitle=Ne;exports.HiddenWhenEmpty=Me;exports.InViewport=Zt;exports.Location=gt;exports.OnClickOutside=te;exports.OnEnterKey=Ke;exports.OnEscapeKey=Be;exports.OnKeyPressed=Tt;exports.PopOver=Ln;exports.Rect=it;exports.Resource=Pn;exports.ResourceDisplay=me;exports.ResultView=ge;exports.RootRouter=Wn;exports.RouterContextProvider=dt;exports.SelectOnFocus=Sn;exports.Ticker=Oe;exports.WhenInViewport=$e;exports.WindowSize=kn;exports._checkExtensionCondition=Yt;exports._getExtension=qt;exports._makeRouteMatcher=Dn;exports._parseRouteSegments=Mt;exports.allPlacements=En;exports.areLocationsEqual=Jt;exports.classes=Ve;exports.getAbsoluteRect=Et;exports.handleAnchorClick=Xt;exports.locationFromURL=Pt;exports.makeResource=de;exports.matchesKeyCombo=ee;exports.matchesRoute=pe;exports.nowSignal=we;exports.relativeTime=Nn;exports.relativeTimeMillisSignal=xe;exports.relativeTimeSignal=Re;exports.setLocationFromUrl=Rt;exports.ticker=Un;exports.timeDiffToString=ve;exports.urlFromLocation=lt;exports.useAppearance=Qt;