@tempots/ui 16.0.4 → 16.0.6

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.
Files changed (3) hide show
  1. package/index.cjs +1 -1
  2. package/index.js +2 -2
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@tempots/dom"),f=require("@tempots/std"),P=require("@floating-ui/dom"),at=e=>{const t=e.split("/").pop();if(t==null||t.startsWith("."))return;const n=t.split(".")||[];return n.length>1?"."+n.pop():void 0},ot=(e,t)=>{const n=at(t);return n!=null&&(e.length===0||!e.some(s=>n==s))},bt=(e,t,n,s)=>{let a=e.target;for(;a!=null&&!(a instanceof HTMLAnchorElement);)a=a.parentElement;if(a==null)return!0;const o=a;if(e.button!==0||e.ctrlKey||e.metaKey||o.target!=="_self"&&o.target!==""||o.getAttribute("download")!=null)return!0;const{pathname:r,search:c,hash:l}=o;if(s){const h=r+c+l,d=o.getAttribute("href");if(!d?.startsWith("#")&&d!==h)return!0}return t?!1:ot(n,r)},it=(e,t={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const n=t.ignoreUrlWithExtension===!0&&Array.isArray(t.allowedExtensions)?t.allowedExtensions.map(s=>s.startsWith(".")?s:"."+s):[];return s=>{bt(s,t.ignoreUrlWithExtension??!0,n,t.ignoreExternalUrl??!0)||e()&&s.preventDefault()}},ct=(e,t)=>e.pathname===t.pathname&&JSON.stringify(e.search)===JSON.stringify(t.search)&&e.hash===t.hash,V=(e,t)=>{const n=new URL(e,t??i.getWindow()?.location.toString()),s=Object.fromEntries(n.searchParams?.entries()??[]);let a=n.hash;return a.startsWith("#")&&(a=a.substring(1)),{pathname:n.pathname,search:s,hash:a===""?void 0:a}},b=e=>{const n=new URLSearchParams(e.search).toString(),s=e.hash;return`${e.pathname}${n?`?${n}`:""}${s?`#${s}`:""}`},xt=e=>{document.startViewTransition?document.startViewTransition(e):e()},X=()=>{const e=i.getWindow(),t=e?.location.hash??"";return{pathname:e?.location.pathname??"",search:Object.fromEntries(new URLSearchParams(e?.location.search??"").entries()),hash:t.startsWith("#")?t.substring(1)||void 0:t===""?void 0:t}},G=e=>{if(e?.scroll!=="auto")return;const t=i.getWindow();t&&t.requestAnimationFrame(()=>t.scrollTo({top:0,left:0,behavior:"auto"}))},Z=(e,t)=>{t?.viewTransition?xt(e):e()},Lt=()=>{const e=i.prop(X(),ct),t=i.getWindow(),n=()=>{e.set(X())};t?.addEventListener("popstate",n),t?.addEventListener("hashchange",n);const s=(l,h,d)=>{Z(()=>{if(t){const w=b(l),R=h?.state??{};d==="replaceState"||h?.replace?t.history.replaceState(R,"",w):t.history.pushState(R,"",w)}e.set(l)},h),G(h)},a=(l,h)=>{Z(()=>{t?.history.go(l)},h),G(h)};return{location:e,commit:s,go:a,back:l=>a(-1,l),forward:l=>a(1,l),resolve:l=>V(l),dispose:()=>{t?.removeEventListener("popstate",n),t?.removeEventListener("hashchange",n),e.dispose()}}},Wt=e=>e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//"),Tt=e=>{const t=e.container.currentURL,n=t.iso(r=>V(r,t.value),r=>{if(Wt(r.pathname))return b(r);const c=new URL(r.pathname,t.value),l=c.origin+c.pathname;return b({...r,pathname:l})});return{location:n,dispose:()=>{n.dispose()},commit:(r,c,l)=>{n.set(r)},go:(r,c)=>{},back:r=>{},forward:r=>{},resolve:r=>V(r,t.value)}},L=e=>({pathname:e.pathname,search:{...e.search},hash:e.hash??void 0}),N=e=>{if(e==null)return;const t=`${e}`;return t===""?void 0:t},lt=(e,t)=>{const n={...e};for(const[s,a]of Object.entries(t))a==null?delete n[s]:n[s]=a;return n},Ht=(e,t)=>{const n=t?.includeSearch??!0,s=t?.includeHash??!0,a=t?.ignoreSearchParams??[];let o;if(!n)o={};else if(a.length===0)o={...e.search};else{const r=new Set(a);o={};for(const[c,l]of Object.entries(e.search))r.has(c)||(o[c]=l)}return{pathname:e.pathname,search:o,hash:s?e.hash:void 0}},z=(e,t,n)=>{const s=Ht(e,n);return typeof t=="string"?b(s)===t:t instanceof RegExp?((t.global||t.sticky)&&(t.lastIndex=0),t.test(b(s))):t(s)};class Dt{constructor(t){this.current=t}get location(){return this.current}setLocation(t){return this.current=L(t),this}setPathname(t){return this.current={...this.current,pathname:t},this}setHash(t){const n=N(t);if(n==null){const{hash:s,...a}=this.current;this.current=a}else this.current={...this.current,hash:n};return this}clearHash(){const{hash:t,...n}=this.current;return this.current=n,this}setSearch(t){return this.current={...this.current,search:lt(this.current.search,t)},this}setSearchParam(t,n){return this.setSearch({[t]:n})}updateSearch(t){return this.current={...this.current,search:{...t({...this.current.search})}},this}}const Mt=(e,t)=>e?.replace?"replaceState":t,Vt=e=>{const t=e.location,n=t.map(b),s=t.map(u=>u.pathname),a=t.map(u=>({...u.search})),o=t.map(u=>u.hash),r=(u,p)=>z(e.location.value,u,p),c=(u,p)=>i.computedOf(t,u)((m,k)=>z(m,k,p)),l=(u,p,m)=>{const k=L({...u,hash:N(u.hash??void 0)});e.commit(k,p,m)},h=(u,p)=>{const m=Mt(p,"pushState");l(u,p,m)},d=(u,p)=>{const m=u(L(e.location.value));h(m,p)},w=(u,p)=>{const m=e.resolve(u);h(m,p)},R=(u,p)=>{const m={...p,replace:!0};w(u,m)},O=(u,p)=>{e.go(u,p)},g=u=>{e.back(u)},E=u=>{e.forward(u)},v=(u,p)=>d(m=>({...m,pathname:u}),p),S=(u,p)=>d(m=>{const k={...m},J=N(u);return J==null?delete k.hash:k.hash=J,k},p),A=u=>S(void 0,u),y=(u,p)=>d(m=>({...m,search:lt(m.search,u)}),p);return{handle:{location:t,url:n,pathname:s,search:a,hash:o,setLocation:h,updateLocation:d,navigate:w,replace:R,go:O,back:g,forward:E,setPathname:v,setHash:S,clearHash:A,setSearch:y,setSearchParam:(u,p,m)=>y({[u]:p},m),updateSearch:(u,p)=>d(m=>({...m,search:{...u({...m.search})}}),p),queryParam:u=>t.map(p=>p.search[u]),run:(u,p)=>{const m=new Dt(L(e.location.value));u(m),h(L(m.location),p)},match:r,matchSignal:c},dispose:()=>{e.dispose(),n.dispose(),s.dispose(),a.dispose(),o.dispose()}}},Ft=e=>{if(e.isBrowser())return Lt();if(e.isHeadless())return Tt(e);throw new Error("Unknown context")},K={mark:i.makeProviderMark("Location"),create:(e,t)=>{const n=Ft(t),{handle:s,dispose:a}=Vt(n);return{value:s,dispose:a}}},ut=(e,...t)=>{if(typeof e=="string"||i.Signal.is(e))return ut({href:e},...t);const{href:n,state:s,scroll:a,viewTransition:o,replace:r,...c}=e;return i.Use(K,l=>i.html.a(i.on.click(it(()=>{let h=!1;const d={};return s!==void 0&&(d.state=s,h=!0),a!==void 0&&(d.scroll=a,h=!0),o!==void 0&&(d.viewTransition=o,h=!0),r!==void 0&&(d.replace=r,h=!0),l.navigate(i.Value.get(n),h?d:void 0),!0},c)),i.attr.href(n),...t))},Ut={mark:i.makeProviderMark("Appearance"),create:()=>{const e=ht();return{value:e,dispose:()=>e.dispose()}}};function ht(){const e=i.getWindow(),t=e!=null&&e.matchMedia!=null?e.matchMedia("(prefers-color-scheme: dark)"):void 0,n=t?.matches??!1,s=i.prop(n?"dark":"light"),a=o=>s.set(o.matches?"dark":"light");return t?.addEventListener("change",a),s.onDispose(()=>t?.removeEventListener("change",a)),s}const j=(e,t)=>{if(typeof t=="function")return j(e,{success:t});const n=t.failure??(r=>r.map(c=>`Error: ${c}`)),s=t.success,a=t.loading??(()=>i.Empty),o=t.notAsked??(()=>i.Empty);return i.OneOfType(i.Value.toSignal(e),{AsyncSuccess:r=>s(r.$.value),AsyncFailure:r=>n(r.$.error),Loading:r=>a(r.map(c=>c.previousValue)),NotAsked:o})},Kt=(e=10)=>i.WithElement(t=>i.OnDispose(f.delayed(()=>t?.focus(),e))),Ct=(e=10)=>i.WithElement(t=>{const n=f.delayed(()=>t.select(),e);return i.OnDispose(n)});function Nt(e){const t=Object.entries(e);return i.Fragment(...t.map(([n,s])=>i.attr.class(i.Value.map(s,a=>a?n:void 0))))}const zt=i.WithElement(e=>{const t=e.style.getPropertyValue(":empty");return e.style.setProperty(":empty","display:none"),i.OnDispose(n=>{n&&e.style.setProperty(":empty",t)})}),_t=e=>i.Portal("head > title",i.attr.innerText(e)),$t={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},M={partial:new Map,full:new Map},W={partial:null,full:null};function jt(e){return W[e]==null&&(W[e]=new IntersectionObserver(t=>{t.forEach(n=>{M[e].get(n.target)?.set(n.isIntersecting)})},$t[e])),W[e]}const pt=({mode:e="partial",once:t=!1},n)=>{const s=i.prop(!1);return i.Fragment(i.WithElement(a=>{const o=typeof IntersectionObserver<"u"?jt(e):null;M[e].set(a,s),o?.observe(a);function r(){o?.unobserve(a),M[e].delete(a),M[e].size===0&&(W[e]?.disconnect(),W[e]=null)}let c=null;return t&&(c=s.on(l=>{l&&r()})),i.OnDispose(()=>{s.dispose(),r(),c?.()})}),i.renderableOfTNode(n(s)))},It=(e,t,n)=>pt(e,s=>i.When(s,t,n??(()=>i.Empty)));function dt(e){return i.WithElement(t=>{const n=s=>{t.contains(s.target)||e(s)};return document.addEventListener("click",n),i.OnDispose(()=>{document.removeEventListener("click",n)})})}const x=(e,t)=>e===void 0||e===t,tt=(e,t)=>e===void 0||e===t;function mt(e,t){return typeof e=="string"?t.key===e:tt(e.key,t.key)&&tt(e.code,t.code)&&x(e.ctrlKey,t.ctrlKey)&&x(e.altKey,t.altKey)&&x(e.shiftKey,t.shiftKey)&&x(e.metaKey,t.metaKey)&&x(e.repeat,t.repeat)&&x(e.commandOrControlKey,t.metaKey||t.ctrlKey)}function I({allowedKeys:e,handler:t}){return i.WithElement(n=>{const s=a=>{if(n.contains(a.target)){for(const o of e)if(mt(o,a)){t(a);break}}};return document.addEventListener("keydown",s),i.OnDispose(()=>{document.removeEventListener("keydown",s)})})}function qt(e){return I({allowedKeys:["Enter"],handler:e})}function Qt(e){return I({allowedKeys:["Escape"],handler:e})}const ft=({mutate:e,convertError:t,onSuccess:n,onError:s,onSettled:a})=>{let o;const r=i.prop(f.AsyncResult.notAsked),c=r.map(g=>f.AsyncResult.isSuccess(g)?g.value:void 0),l=r.map(g=>f.AsyncResult.isFailure(g)?g.error:void 0),h=r.map(g=>f.AsyncResult.isLoading(g)),d=()=>{o?.abort(),o=void 0};return{status:r,value:c,error:l,pending:h,execute:async(g,E)=>{d(),o=new AbortController;const v=o.signal,S=r.get(),A=E?.optimisticValue??(E?.optimisticFromRequest!=null?E.optimisticFromRequest(g):void 0);A!=null?r.set(f.AsyncResult.loading(A)):r.set(f.AsyncResult.loading(f.AsyncResult.getOrUndefined(S)));try{const y=await e({request:g,abortSignal:v,previous:S});o=void 0,r.set(f.AsyncResult.success(y)),n?.(y,g)}catch(y){o=void 0,r.set(f.AsyncResult.failure(t(y))),s?.(t(y),g)}a?.(r.get(),g)},cancel:g=>{d(),r.set(g??f.AsyncResult.notAsked)},dispose:()=>{o?.abort(),o=void 0,r.dispose()}}},gt=(e,t)=>{const{status:n,dispose:s,execute:a,cancel:o,pending:r,error:c,value:l}=e,{content:h}=t,d=i.previousSignal(l);return i.Fragment(i.OnDispose(s),h({previous:d,execute:a,cancel:o,pending:r,error:c,value:l,status:n}))},Bt=({mutate:e,convertError:t=r=>r,onSuccess:n,onError:s,onSettled:a,content:o})=>{const r=ft({mutate:e,convertError:t,onSuccess:n,onError:s,onSettled:a});return gt(r,{content:o})},Yt=["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],Jt=(e,t={isOpen:!1})=>{const n=[];let s=null;const a=i.Value.deriveProp(t.isOpen);function o(c){s=c,a.set(!0)}function r(){a.set(!1),n.forEach(c=>c()),n.length=0}return i.Fragment(e(o,r),i.When(a,()=>i.Fragment(s?.onClickOutside!=null?dt(s.onClickOutside):null,i.WithElement(c=>i.Portal("body",i.html.div(i.WithElement(l=>{l.style.position="absolute";const h=typeof s?.target=="string"?c.querySelector(s.target):s?.target??c;if(h==null)throw new Error(`Target not found: ${s?.target}`);let d=null;const w=i.Value.toSignal(s?.mainAxisOffset??0),R=i.Value.toSignal(s?.crossAxisOffset??0),O=i.Value.toSignal(s?.placement??"top"),g=i.Value.toSignal(s?.arrowPadding??0),E=s?.arrow,v=i.prop({centerOffset:0,alignmentOffset:0,containerWidth:0,containerHeight:0,x:void 0,y:void 0});async function S(){const y=[P.flip(),P.offset({mainAxis:w.get(),crossAxis:R.get()}),P.shift(),P.flip()];E!=null&&d!=null&&y.push(P.arrow({element:d,padding:g.get()}));const D=await P.computePosition(h,l,{placement:O.get(),strategy:"absolute",middleware:y}),{x:Q,y:B,middlewareData:C}=D;if(l.style.top=`${B}px`,l.style.left=`${Q}px`,d!=null&&C.arrow!=null){const{x:Y,y:u,centerOffset:p,alignmentOffset:m}=C.arrow;v.set({x:Y,y:u,centerOffset:p,alignmentOffset:m,containerWidth:l.offsetWidth,containerHeight:l.offsetHeight})}}const A=i.effectOf(w,R,O)(S);return i.Fragment(s?.content,s?.arrow!=null?i.html.div(s?.arrow(i.computedOf(v,O)((y,D)=>({...y,placement:D}))),i.WithElement(y=>{d=y,S()})):null,i.OnDispose(P.autoUpdate(h,l,S),A))})))))))},vt=({request:e,load:t,convertError:n,onSuccess:s,onError:a,onSettled:o})=>{let r;const c=i.prop(f.AsyncResult.notAsked),l=c.map(v=>f.AsyncResult.isSuccess(v)?v.value:void 0),h=c.map(v=>f.AsyncResult.isFailure(v)?v.error:void 0),d=c.map(v=>f.AsyncResult.isLoading(v)),w=()=>{r?.abort(),r=void 0},R=v=>{w(),c.set(v??f.AsyncResult.notAsked)},O=async v=>{w(),r=new AbortController;const S=r.signal,A=c.get();c.set(f.AsyncResult.loading(f.AsyncResult.getOrUndefined(A)));try{const y=await t({request:v,abortSignal:S,previous:A});await Promise.resolve(),r=void 0,c.set(f.AsyncResult.success(y)),s?.(y,v)}catch(y){r=void 0,c.set(f.AsyncResult.failure(n(y))),a?.(n(y),v)}o?.(c.get(),v)},g=()=>O(i.Value.get(e)),E=()=>{r?.abort(),r=void 0,c.dispose()};return c.onDispose(i.Value.on(e,O)),{status:c,value:l,error:h,loading:d,cancel:R,reload:g,dispose:E}},yt=(e,t)=>{const{status:n,dispose:s,reload:a}=e,{pending:o,failure:r,success:c}=t;return i.Fragment(i.OnDispose(s),j(n,{loading:o!=null?l=>o({previous:l,reload:a,cancel:e.cancel}):void 0,failure:r!=null?l=>r({error:l,reload:a}):void 0,success:l=>c({value:l,reload:a})}))},Xt=({request:e,load:t,convertError:n=h=>h,onSuccess:s,onError:a,onSettled:o,success:r,pending:c,failure:l})=>{const h=vt({request:e,load:t,convertError:n,onSuccess:s,onError:a,onSettled:o});return yt(h,{success:r,pending:c,failure:l})},wt=(e,t)=>{if(typeof t=="function")return wt(e,{success:t});const n=t.failure??(a=>(a.on(console.error),a.map(o=>`Error: ${o}`))),s=t.success;return i.OneOfType(i.Value.toSignal(e),{Success:a=>s(a.$.value),Failure:a=>n(a.$.error)})},Gt=()=>i.on.focus(e=>e.target?.select());class H{constructor(t,n,s,a,o,r){this.left=t,this.top=n,this.width=s,this.height=a,this.localLeft=o,this.localTop=r}static of({left:t=0,top:n=0,width:s=0,height:a=0,localLeft:o=0,localTop:r=0}){return new H(t,n,s,a,o,r)}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}}equals=t=>f.nearEqual(this.left,t.left)&&f.nearEqual(this.top,t.top)&&f.nearEqual(this.width,t.width)&&f.nearEqual(this.height,t.height)}function _(e){const t=e.getBoundingClientRect();return H.of({top:t.top+window.scrollY,left:t.left+window.scrollX,width:t.width,height:t.height,localLeft:e.offsetLeft,localTop:e.offsetTop})}const Zt=e=>i.WithBrowserCtx(t=>{const{element:n}=t,s=i.prop(_(n),(c,l)=>c.equals(l)),a=i.renderableOfTNode(e(s)).render(t),o=()=>s.set(H.of(_(n)));let r=null;return typeof ResizeObserver<"u"&&(r=new ResizeObserver(o)),r?.observe(n),i.OnDispose(c=>{r?.disconnect(),a(c)})});function et(e){return{width:e?.innerWidth??0,height:e?.innerHeight??0}}const te=e=>i.WithCtx(()=>{const t=i.getWindow(),n=i.prop(et(t),(a,o)=>a.width===o.width&&a.height===o.height),s=()=>n.set(et(t));return t?.addEventListener("resize",s),i.Fragment(i.OnDispose(()=>{t?.removeEventListener("resize",s)}),e(n))}),St=(e,t)=>{const n=t.split("/").filter(o=>o!==""),s=o=>{try{return decodeURIComponent(o)}catch{return o}},a={};for(let o=0;o<e.length;o++){const r=e[o],c=n[o];if(!c&&r.type!=="catch-all")return null;if(r.type==="literal"){if(r.value!==c)return null}else if(r.type==="param")a[r.name]=s(c);else if(r.type==="catch-all"){if(r.name){const l=n.slice(o).join("/");a[r.name]=s(l)}return{params:a,path:t}}}return n.length!==e.length?null:{params:a,path:t}},q=e=>e.split("/").map(t=>{if(t.startsWith(":"))return{type:"param",name:t.slice(1)};if(t.startsWith("*")){const n=t.slice(1);return n!=""?{type:"catch-all",name:n}:{type:"catch-all"}}else return{type:"literal",value:t}}).filter(t=>t.type!=="literal"||t.value!==""),ee=e=>{const t=e.map(n=>{const s=q(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of t){const r=St(a,s);if(r)return{...r,route:o}}return null}},ne=e=>{if(e==null)throw new Error("NavigationService: no Location handle attached. Make sure to attach one before calling navigation helpers.");return e};class se{handles=[];attach(t){const n=this.handles.lastIndexOf(t);return n!==-1&&this.handles.splice(n,1),this.handles.push(t),()=>this.detach(t)}detach(t){for(let n=this.handles.length-1;n>=0;n--)if(this.handles[n]===t){this.handles.splice(n,1);break}}get current(){return this.handles[this.handles.length-1]}getHandle(){return ne(this.current)}navigate(t,n){this.getHandle().navigate(t,n)}replace(t,n){this.getHandle().replace(t,n)}go(t,n){this.getHandle().go(t,n)}back(t){this.getHandle().back(t)}forward(t){this.getHandle().forward(t)}setPathname(t,n){this.getHandle().setPathname(t,n)}setSearch(t,n){this.getHandle().setSearch(t,n)}setSearchParam(t,n,s){this.getHandle().setSearchParam(t,n,s)}updateSearch(t,n){this.getHandle().updateSearch(t,n)}setHash(t,n){this.getHandle().setHash(t,n)}clearHash(t){this.getHandle().clearHash(t)}run(t,n){this.getHandle().run(t,n)}}const re=new se,F={mark:i.makeProviderMark("RouterContext"),create:()=>{const e=i.prop([]);return{value:e,dispose:()=>e.dispose()}}},ae=(e,t,n)=>{const s=n.split("/").filter(r=>r!==""),a={};let o=0;for(let r=0;r<e.length;r++){const c=e[r],l=s[r];if(!l&&c.type!=="catch-all")return null;if(c.type==="literal"){if(c.value!==l)return null;o++}else if(c.type==="param")a[c.name]=l,o++;else if(c.type==="catch-all"){c.name&&(a[c.name]=s.slice(o).join("/"));const h="/"+s.slice(0,o).join("/"),d="/"+s.slice(o).join("/");return{params:a,matchedPath:h==="/"?"":h,remainingPath:d==="/"?"":d,route:t}}}if(s.length===e.length){const r="/"+s.join("/");return{params:a,matchedPath:r==="/"?"":r,remainingPath:"",route:t}}return null},Rt=e=>{const t=e.map(n=>{const s=q(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of t){const r=ae(a,o,s);if(r)return r}return null}},oe=e=>{const t=Rt(Object.keys(e));return i.Provide(F,{},()=>i.Use(K,n=>i.Use(F,s=>{const a=n.location.map(o=>{const r=t(o.pathname);if(r==null)throw console.error("No route found for",o),new Error("No route found");const c={matchedPath:r.matchedPath,remainingPath:r.remainingPath,fullPath:o.pathname,params:r.params};return s.value=[...s.value,c],{params:r.params,route:r.route,path:r.matchedPath||o.pathname,search:o.search,hash:o.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),e)})))},ie=e=>{const t=Rt(Object.keys(e));return i.Use(F,n=>i.Use(K,s=>{const a=n.map(o=>{const r=o[o.length-1];if(r==null)throw console.error("No router context available for ChildRouter",o),new Error("No router context available for ChildRouter");const c=r.remainingPath??"",l=t(c);if(l==null)throw console.error("No route found for remaining path",c),new Error("No route found");return{params:l.params,route:l.route,path:l.matchedPath,search:s.location.value.search,hash:s.location.value.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),e)}))},U=60*1e3,$=60*U,T=24*$,nt=7*T,st=30*T,ce=365*T,le=[{max:U*90,value:U,name:"minute",past:{singular:"a minute ago",plural:"{} minutes ago"},future:{singular:"in a minute",plural:"in {} minutes"}},{max:$*36,value:$,name:"hour",past:{singular:"an hour ago",plural:"{} hours ago"},future:{singular:"in an hour",plural:"in {} hours"}},{max:T*10,value:T,name:"day",past:{singular:"yesterday",plural:"{} days ago"},future:{singular:"tomorrow",plural:"in {} days"}},{max:nt*6,value:nt,name:"week",past:{singular:"last week",plural:"{} weeks ago"},future:{singular:"in a week",plural:"in {} weeks"}},{max:st*18,value:st,name:"month",past:{singular:"last month",plural:"{} months ago"},future:{singular:"in a month",plural:"in {} months"}},{max:1/0,value:ce,name:"year",past:{singular:"last year",plural:"{} years ago"},future:{singular:"in a year",plural:"in {} years"}}];function rt(e,t,n,s){const a=Math.round(e/t);return a<=1?n:s.replace("{}",a.toLocaleString(void 0,{maximumFractionDigits:0,minimumFractionDigits:0}))}const Ot=(e=1e3)=>{const t=i.prop(new Date),n=f.interval(()=>t.set(new Date),e);return t.onDispose(n),t},Et=e=>{const t=Math.abs(e);if(t<U)return e<0?"just now":"in a moment";for(const n of le)if(t<n.max)return e<0?rt(t,n.value,n.past.singular,n.past.plural):rt(t,n.value,n.future.singular,n.future.plural);throw new Error("unreachable")},At=(e,{now:t,frequency:n=1e4}={})=>{const s=t!=null?i.Signal.is(t)?t.derive():i.prop(t):Ot(n),a=i.computedOf(e,s)((o,r)=>o.getTime()-r.getTime());return a.onDispose(()=>i.Value.dispose(s)),a},kt=(e,t={})=>{const n=At(e,t),s=n.map(Et);return s.onDispose(()=>n.dispose()),s},ue=(e,t={})=>kt(e,t);class Pt extends i.Prop{tick=()=>this.update(t=>t+1)}const he=(e=0)=>new Pt(e,i.strictEquals);exports.Anchor=ut;exports.Appearance=Ut;exports.AsyncResultView=j;exports.AutoFocus=Kt;exports.AutoSelect=Ct;exports.ChildRouter=ie;exports.ElementRect=Zt;exports.HTMLTitle=_t;exports.HiddenWhenEmpty=zt;exports.InViewport=pt;exports.Location=K;exports.Mutation=Bt;exports.MutationDisplay=gt;exports.NavigationService=re;exports.OnClickOutside=dt;exports.OnEnterKey=qt;exports.OnEscapeKey=Qt;exports.OnKeyPressed=I;exports.PopOver=Jt;exports.Query=Xt;exports.QueryDisplay=yt;exports.Rect=H;exports.ResultView=wt;exports.RootRouter=oe;exports.RouterContextProvider=F;exports.SelectOnFocus=Gt;exports.Ticker=Pt;exports.WhenInViewport=It;exports.WindowSize=te;exports._checkExtensionCondition=ot;exports._getExtension=at;exports._makeRouteMatcher=ee;exports._parseRouteSegments=q;exports.allPlacements=Yt;exports.areLocationsEqual=ct;exports.classes=Nt;exports.evaluateLocationMatch=z;exports.getAbsoluteRect=_;exports.handleAnchorClick=it;exports.locationFromURL=V;exports.makeMutationResource=ft;exports.makeQueryResource=vt;exports.matchesKeyCombo=mt;exports.matchesRoute=St;exports.nowSignal=Ot;exports.relativeTime=ue;exports.relativeTimeMillisSignal=At;exports.relativeTimeSignal=kt;exports.ticker=he;exports.timeDiffToString=Et;exports.urlFromLocation=b;exports.useAppearance=ht;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@tempots/dom"),f=require("@tempots/std"),P=require("@floating-ui/dom"),at=e=>{const t=e.split("/").pop();if(t==null||t.startsWith("."))return;const n=t.split(".")||[];return n.length>1?"."+n.pop():void 0},ot=(e,t)=>{const n=at(t);return n!=null&&(e.length===0||!e.some(s=>n==s))},bt=(e,t,n,s)=>{let a=e.target;for(;a!=null&&!(a instanceof HTMLAnchorElement);)a=a.parentElement;if(a==null)return!0;const o=a;if(e.button!==0||e.ctrlKey||e.metaKey||o.target!=="_self"&&o.target!==""||o.getAttribute("download")!=null)return!0;const{pathname:r,search:c,hash:l}=o;if(s){const h=r+c+l,d=o.getAttribute("href");if(!d?.startsWith("#")&&d!==h)return!0}return t?!1:ot(n,r)},it=(e,t={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const n=t.ignoreUrlWithExtension===!0&&Array.isArray(t.allowedExtensions)?t.allowedExtensions.map(s=>s.startsWith(".")?s:"."+s):[];return s=>{bt(s,t.ignoreUrlWithExtension??!0,n,t.ignoreExternalUrl??!0)||e()&&s.preventDefault()}},ct=(e,t)=>e.pathname===t.pathname&&JSON.stringify(e.search)===JSON.stringify(t.search)&&e.hash===t.hash,V=(e,t)=>{const n=new URL(e,t??i.getWindow()?.location.toString()),s=Object.fromEntries(n.searchParams?.entries()??[]);let a=n.hash;return a.startsWith("#")&&(a=a.substring(1)),{pathname:n.pathname,search:s,hash:a===""?void 0:a}},b=e=>{const n=new URLSearchParams(e.search).toString(),s=e.hash;return`${e.pathname}${n?`?${n}`:""}${s?`#${s}`:""}`},xt=e=>{document.startViewTransition?document.startViewTransition(e):e()},X=()=>{const e=i.getWindow(),t=e?.location.hash??"";return{pathname:e?.location.pathname??"",search:Object.fromEntries(new URLSearchParams(e?.location.search??"").entries()),hash:t.startsWith("#")?t.substring(1)||void 0:t===""?void 0:t}},G=e=>{if(e?.scroll!=="auto")return;const t=i.getWindow();t&&t.requestAnimationFrame(()=>t.scrollTo({top:0,left:0,behavior:"auto"}))},Z=(e,t)=>{t?.viewTransition?xt(e):e()},Lt=()=>{const e=i.prop(X(),ct),t=i.getWindow(),n=()=>{e.set(X())};t?.addEventListener("popstate",n),t?.addEventListener("hashchange",n);const s=(l,h,d)=>{Z(()=>{if(t){const w=b(l),R=h?.state??{};d==="replaceState"||h?.replace?t.history.replaceState(R,"",w):t.history.pushState(R,"",w)}e.set(l)},h),G(h)},a=(l,h)=>{Z(()=>{t?.history.go(l)},h),G(h)};return{location:e,commit:s,go:a,back:l=>a(-1,l),forward:l=>a(1,l),resolve:l=>V(l),dispose:()=>{t?.removeEventListener("popstate",n),t?.removeEventListener("hashchange",n),e.dispose()}}},Wt=e=>e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//"),Tt=e=>{const t=e.container.currentURL,n=t.iso(r=>V(r,t.value),r=>{if(Wt(r.pathname))return b(r);const c=new URL(r.pathname,t.value),l=c.origin+c.pathname;return b({...r,pathname:l})});return{location:n,dispose:()=>{n.dispose()},commit:(r,c,l)=>{n.set(r)},go:(r,c)=>{},back:r=>{},forward:r=>{},resolve:r=>V(r,t.value)}},L=e=>({pathname:e.pathname,search:{...e.search},hash:e.hash??void 0}),N=e=>{if(e==null)return;const t=`${e}`;return t===""?void 0:t},lt=(e,t)=>{const n={...e};for(const[s,a]of Object.entries(t))a==null?delete n[s]:n[s]=a;return n},Ht=(e,t)=>{const n=t?.includeSearch??!0,s=t?.includeHash??!0,a=t?.ignoreSearchParams??[];let o;if(!n)o={};else if(a.length===0)o={...e.search};else{const r=new Set(a);o={};for(const[c,l]of Object.entries(e.search))r.has(c)||(o[c]=l)}return{pathname:e.pathname,search:o,hash:s?e.hash:void 0}},z=(e,t,n)=>{const s=Ht(e,n);return typeof t=="string"?b(s)===t:t instanceof RegExp?((t.global||t.sticky)&&(t.lastIndex=0),t.test(b(s))):t(s)};class Dt{constructor(t){this.current=t}get location(){return this.current}setLocation(t){return this.current=L(t),this}setPathname(t){return this.current={...this.current,pathname:t},this}setHash(t){const n=N(t);if(n==null){const{hash:s,...a}=this.current;this.current=a}else this.current={...this.current,hash:n};return this}clearHash(){const{hash:t,...n}=this.current;return this.current=n,this}setSearch(t){return this.current={...this.current,search:lt(this.current.search,t)},this}setSearchParam(t,n){return this.setSearch({[t]:n})}updateSearch(t){return this.current={...this.current,search:{...t({...this.current.search})}},this}}const Mt=(e,t)=>e?.replace?"replaceState":t,Vt=e=>{const t=e.location,n=t.map(b),s=t.map(u=>u.pathname),a=t.map(u=>({...u.search})),o=t.map(u=>u.hash),r=(u,p)=>z(e.location.value,u,p),c=(u,p)=>i.computedOf(t,u)((m,k)=>z(m,k,p)),l=(u,p,m)=>{const k=L({...u,hash:N(u.hash??void 0)});e.commit(k,p,m)},h=(u,p)=>{const m=Mt(p,"pushState");l(u,p,m)},d=(u,p)=>{const m=u(L(e.location.value));h(m,p)},w=(u,p)=>{const m=e.resolve(u);h(m,p)},R=(u,p)=>{const m={...p,replace:!0};w(u,m)},O=(u,p)=>{e.go(u,p)},g=u=>{e.back(u)},E=u=>{e.forward(u)},v=(u,p)=>d(m=>({...m,pathname:u}),p),S=(u,p)=>d(m=>{const k={...m},J=N(u);return J==null?delete k.hash:k.hash=J,k},p),A=u=>S(void 0,u),y=(u,p)=>d(m=>({...m,search:lt(m.search,u)}),p);return{handle:{location:t,url:n,pathname:s,search:a,hash:o,setLocation:h,updateLocation:d,navigate:w,replace:R,go:O,back:g,forward:E,setPathname:v,setHash:S,clearHash:A,setSearch:y,setSearchParam:(u,p,m)=>y({[u]:p},m),updateSearch:(u,p)=>d(m=>({...m,search:{...u({...m.search})}}),p),queryParam:u=>t.map(p=>p.search[u]),run:(u,p)=>{const m=new Dt(L(e.location.value));u(m),h(L(m.location),p)},match:r,matchSignal:c},dispose:()=>{e.dispose(),n.dispose(),s.dispose(),a.dispose(),o.dispose()}}},Ft=e=>{if(e.isBrowser())return Lt();if(e.isHeadless())return Tt(e);throw new Error("Unknown context")},K={mark:i.makeProviderMark("Location"),create:(e,t)=>{const n=Ft(t),{handle:s,dispose:a}=Vt(n);return{value:s,dispose:a}}},ut=(e,...t)=>{if(typeof e=="string"||i.Signal.is(e))return ut({href:e},...t);const{href:n,state:s,scroll:a,viewTransition:o,replace:r,...c}=e;return i.Use(K,l=>i.html.a(i.on.click(it(()=>{let h=!1;const d={};return s!==void 0&&(d.state=s,h=!0),a!==void 0&&(d.scroll=a,h=!0),o!==void 0&&(d.viewTransition=o,h=!0),r!==void 0&&(d.replace=r,h=!0),l.navigate(i.Value.get(n),h?d:void 0),!0},c)),i.attr.href(n),...t))},Ut={mark:i.makeProviderMark("Appearance"),create:()=>{const e=ht();return{value:e,dispose:()=>e.dispose()}}};function ht(){const e=i.getWindow(),t=e!=null&&e.matchMedia!=null?e.matchMedia("(prefers-color-scheme: dark)"):void 0,n=t?.matches??!1,s=i.prop(n?"dark":"light"),a=o=>s.set(o.matches?"dark":"light");return t?.addEventListener("change",a),s.onDispose(()=>t?.removeEventListener("change",a)),s}const j=(e,t)=>{if(typeof t=="function")return j(e,{success:t});const n=t.failure??(r=>r.map(c=>`Error: ${c}`)),s=t.success,a=t.loading??(()=>i.Empty),o=t.notAsked??(()=>i.Empty);return i.OneOfType(i.Value.toSignal(e),{AsyncSuccess:r=>s(r.$.value),AsyncFailure:r=>n(r.$.error),Loading:r=>a(r.map(c=>c.previousValue)),NotAsked:o})},Kt=(e=10)=>i.WithElement(t=>i.OnDispose(f.delayed(()=>t?.focus(),e))),Ct=(e=10)=>i.WithElement(t=>{const n=f.delayed(()=>t.select(),e);return i.OnDispose(n)});function Nt(e){const t=Object.entries(e);return i.Fragment(...t.map(([n,s])=>i.attr.class(i.Value.map(s,a=>a?n:void 0))))}const zt=i.WithElement(e=>{const t=e.style.getPropertyValue(":empty");return e.style.setProperty(":empty","display:none"),i.OnDispose(n=>{n&&e.style.setProperty(":empty",t)})}),_t=e=>i.Portal("head > title",i.attr.innerText(e)),$t={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},M={partial:new Map,full:new Map},W={partial:null,full:null};function jt(e){return W[e]==null&&(W[e]=new IntersectionObserver(t=>{t.forEach(n=>{M[e].get(n.target)?.set(n.isIntersecting)})},$t[e])),W[e]}const pt=({mode:e="partial",once:t=!1},n)=>{const s=i.prop(!1);return i.Fragment(i.WithElement(a=>{const o=typeof IntersectionObserver<"u"?jt(e):null;M[e].set(a,s),o?.observe(a);function r(){o?.unobserve(a),M[e].delete(a),M[e].size===0&&(W[e]?.disconnect(),W[e]=null)}let c=null;return t&&(c=s.on(l=>{l&&r()})),i.OnDispose(()=>{s.dispose(),r(),c?.()})}),i.renderableOfTNode(n(s)))},It=(e,t,n)=>pt(e,s=>i.When(s,t,n??(()=>i.Empty)));function dt(e){return i.WithElement(t=>{const n=s=>{t.contains(s.target)||e(s)};return document.addEventListener("click",n),i.OnDispose(()=>{document.removeEventListener("click",n)})})}const x=(e,t)=>e===void 0||e===t,tt=(e,t)=>e===void 0||e===t;function mt(e,t){return typeof e=="string"?t.key===e:tt(e.key,t.key)&&tt(e.code,t.code)&&x(e.ctrlKey,t.ctrlKey)&&x(e.altKey,t.altKey)&&x(e.shiftKey,t.shiftKey)&&x(e.metaKey,t.metaKey)&&x(e.repeat,t.repeat)&&x(e.commandOrControlKey,t.metaKey||t.ctrlKey)}function I({allowedKeys:e,handler:t}){return i.WithElement(n=>{const s=a=>{if(n.contains(a.target)){for(const o of e)if(mt(o,a)){t(a);break}}};return document.addEventListener("keydown",s),i.OnDispose(()=>{document.removeEventListener("keydown",s)})})}function qt(e){return I({allowedKeys:["Enter"],handler:e})}function Qt(e){return I({allowedKeys:["Escape"],handler:e})}const ft=({mutate:e,convertError:t,onSuccess:n,onError:s,onSettled:a})=>{let o;const r=i.prop(f.AsyncResult.notAsked),c=r.map(g=>f.AsyncResult.isSuccess(g)?g.value:void 0),l=r.map(g=>f.AsyncResult.isFailure(g)?g.error:void 0),h=r.map(g=>f.AsyncResult.isLoading(g)),d=()=>{o?.abort(),o=void 0};return{status:r,value:c,error:l,pending:h,execute:async(g,E)=>{d(),o=new AbortController;const v=o.signal,S=r.get(),A=E?.optimisticValue??(E?.optimisticFromRequest!=null?E.optimisticFromRequest(g):void 0);A!=null?r.set(f.AsyncResult.loading(A)):r.set(f.AsyncResult.loading(f.AsyncResult.getOrUndefined(S)));try{const y=await e({request:g,abortSignal:v,previous:S});o=void 0,r.set(f.AsyncResult.success(y)),n?.(y,g)}catch(y){o=void 0,r.set(f.AsyncResult.failure(t(y))),s?.(t(y),g)}a?.(r.get(),g)},cancel:g=>{d(),r.set(g??f.AsyncResult.notAsked)},dispose:()=>{o?.abort(),o=void 0,r.dispose()}}},gt=(e,t)=>{const{status:n,dispose:s,execute:a,cancel:o,pending:r,error:c,value:l}=e,{content:h}=t,d=i.previousSignal(l);return i.Fragment(i.OnDispose(s),h({previous:d,execute:a,cancel:o,pending:r,error:c,value:l,status:n}))},Bt=({mutate:e,convertError:t=r=>r,onSuccess:n,onError:s,onSettled:a,content:o})=>{const r=ft({mutate:e,convertError:t,onSuccess:n,onError:s,onSettled:a});return gt(r,{content:o})},Yt=["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],Jt=(e,t={isOpen:!1})=>{const n=[];let s=null;const a=i.Value.deriveProp(t.isOpen);function o(c){s=c,a.set(!0)}function r(){a.set(!1),n.forEach(c=>c()),n.length=0}return i.Fragment(e(o,r),i.When(a,()=>i.Fragment(s?.onClickOutside!=null?dt(s.onClickOutside):null,i.WithElement(c=>i.Portal("body",i.html.div(i.WithElement(l=>{l.style.position="absolute",l.style.top="0",l.style.left="0";const h=typeof s?.target=="string"?c.querySelector(s.target):s?.target??c;if(h==null)throw new Error(`Target not found: ${s?.target}`);let d=null;const w=i.Value.toSignal(s?.mainAxisOffset??0),R=i.Value.toSignal(s?.crossAxisOffset??0),O=i.Value.toSignal(s?.placement??"top"),g=i.Value.toSignal(s?.arrowPadding??0),E=s?.arrow,v=i.prop({centerOffset:0,alignmentOffset:0,containerWidth:0,containerHeight:0,x:void 0,y:void 0});async function S(){const y=[P.flip(),P.offset({mainAxis:w.get(),crossAxis:R.get()}),P.shift(),P.flip()];E!=null&&d!=null&&y.push(P.arrow({element:d,padding:g.get()}));const D=await P.computePosition(h,l,{placement:O.get(),strategy:"absolute",middleware:y}),{x:Q,y:B,middlewareData:C}=D;if(l.style.transform=`translate(${Q}px, ${B}px)`,d!=null&&C.arrow!=null){const{x:Y,y:u,centerOffset:p,alignmentOffset:m}=C.arrow;v.set({x:Y,y:u,centerOffset:p,alignmentOffset:m,containerWidth:l.offsetWidth,containerHeight:l.offsetHeight})}}const A=i.effectOf(w,R,O)(S);return i.Fragment(s?.content,s?.arrow!=null?i.html.div(s?.arrow(i.computedOf(v,O)((y,D)=>({...y,placement:D}))),i.WithElement(y=>{d=y,S()})):null,i.OnDispose(P.autoUpdate(h,l,S),A))})))))))},vt=({request:e,load:t,convertError:n,onSuccess:s,onError:a,onSettled:o})=>{let r;const c=i.prop(f.AsyncResult.notAsked),l=c.map(v=>f.AsyncResult.isSuccess(v)?v.value:void 0),h=c.map(v=>f.AsyncResult.isFailure(v)?v.error:void 0),d=c.map(v=>f.AsyncResult.isLoading(v)),w=()=>{r?.abort(),r=void 0},R=v=>{w(),c.set(v??f.AsyncResult.notAsked)},O=async v=>{w(),r=new AbortController;const S=r.signal,A=c.get();c.set(f.AsyncResult.loading(f.AsyncResult.getOrUndefined(A)));try{const y=await t({request:v,abortSignal:S,previous:A});await Promise.resolve(),r=void 0,c.set(f.AsyncResult.success(y)),s?.(y,v)}catch(y){r=void 0,c.set(f.AsyncResult.failure(n(y))),a?.(n(y),v)}o?.(c.get(),v)},g=()=>O(i.Value.get(e)),E=()=>{r?.abort(),r=void 0,c.dispose()};return c.onDispose(i.Value.on(e,O)),{status:c,value:l,error:h,loading:d,cancel:R,reload:g,dispose:E}},yt=(e,t)=>{const{status:n,dispose:s,reload:a}=e,{pending:o,failure:r,success:c}=t;return i.Fragment(i.OnDispose(s),j(n,{loading:o!=null?l=>o({previous:l,reload:a,cancel:e.cancel}):void 0,failure:r!=null?l=>r({error:l,reload:a}):void 0,success:l=>c({value:l,reload:a})}))},Xt=({request:e,load:t,convertError:n=h=>h,onSuccess:s,onError:a,onSettled:o,success:r,pending:c,failure:l})=>{const h=vt({request:e,load:t,convertError:n,onSuccess:s,onError:a,onSettled:o});return yt(h,{success:r,pending:c,failure:l})},wt=(e,t)=>{if(typeof t=="function")return wt(e,{success:t});const n=t.failure??(a=>(a.on(console.error),a.map(o=>`Error: ${o}`))),s=t.success;return i.OneOfType(i.Value.toSignal(e),{Success:a=>s(a.$.value),Failure:a=>n(a.$.error)})},Gt=()=>i.on.focus(e=>e.target?.select());class H{constructor(t,n,s,a,o,r){this.left=t,this.top=n,this.width=s,this.height=a,this.localLeft=o,this.localTop=r}static of({left:t=0,top:n=0,width:s=0,height:a=0,localLeft:o=0,localTop:r=0}){return new H(t,n,s,a,o,r)}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}}equals=t=>f.nearEqual(this.left,t.left)&&f.nearEqual(this.top,t.top)&&f.nearEqual(this.width,t.width)&&f.nearEqual(this.height,t.height)}function _(e){const t=e.getBoundingClientRect();return H.of({top:t.top+window.scrollY,left:t.left+window.scrollX,width:t.width,height:t.height,localLeft:e.offsetLeft,localTop:e.offsetTop})}const Zt=e=>i.WithBrowserCtx(t=>{const{element:n}=t,s=i.prop(_(n),(c,l)=>c.equals(l)),a=i.renderableOfTNode(e(s)).render(t),o=()=>s.set(H.of(_(n)));let r=null;return typeof ResizeObserver<"u"&&(r=new ResizeObserver(o)),r?.observe(n),i.OnDispose(c=>{r?.disconnect(),a(c)})});function et(e){return{width:e?.innerWidth??0,height:e?.innerHeight??0}}const te=e=>i.WithCtx(()=>{const t=i.getWindow(),n=i.prop(et(t),(a,o)=>a.width===o.width&&a.height===o.height),s=()=>n.set(et(t));return t?.addEventListener("resize",s),i.Fragment(i.OnDispose(()=>{t?.removeEventListener("resize",s)}),e(n))}),St=(e,t)=>{const n=t.split("/").filter(o=>o!==""),s=o=>{try{return decodeURIComponent(o)}catch{return o}},a={};for(let o=0;o<e.length;o++){const r=e[o],c=n[o];if(!c&&r.type!=="catch-all")return null;if(r.type==="literal"){if(r.value!==c)return null}else if(r.type==="param")a[r.name]=s(c);else if(r.type==="catch-all"){if(r.name){const l=n.slice(o).join("/");a[r.name]=s(l)}return{params:a,path:t}}}return n.length!==e.length?null:{params:a,path:t}},q=e=>e.split("/").map(t=>{if(t.startsWith(":"))return{type:"param",name:t.slice(1)};if(t.startsWith("*")){const n=t.slice(1);return n!=""?{type:"catch-all",name:n}:{type:"catch-all"}}else return{type:"literal",value:t}}).filter(t=>t.type!=="literal"||t.value!==""),ee=e=>{const t=e.map(n=>{const s=q(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of t){const r=St(a,s);if(r)return{...r,route:o}}return null}},ne=e=>{if(e==null)throw new Error("NavigationService: no Location handle attached. Make sure to attach one before calling navigation helpers.");return e};class se{handles=[];attach(t){const n=this.handles.lastIndexOf(t);return n!==-1&&this.handles.splice(n,1),this.handles.push(t),()=>this.detach(t)}detach(t){for(let n=this.handles.length-1;n>=0;n--)if(this.handles[n]===t){this.handles.splice(n,1);break}}get current(){return this.handles[this.handles.length-1]}getHandle(){return ne(this.current)}navigate(t,n){this.getHandle().navigate(t,n)}replace(t,n){this.getHandle().replace(t,n)}go(t,n){this.getHandle().go(t,n)}back(t){this.getHandle().back(t)}forward(t){this.getHandle().forward(t)}setPathname(t,n){this.getHandle().setPathname(t,n)}setSearch(t,n){this.getHandle().setSearch(t,n)}setSearchParam(t,n,s){this.getHandle().setSearchParam(t,n,s)}updateSearch(t,n){this.getHandle().updateSearch(t,n)}setHash(t,n){this.getHandle().setHash(t,n)}clearHash(t){this.getHandle().clearHash(t)}run(t,n){this.getHandle().run(t,n)}}const re=new se,F={mark:i.makeProviderMark("RouterContext"),create:()=>{const e=i.prop([]);return{value:e,dispose:()=>e.dispose()}}},ae=(e,t,n)=>{const s=n.split("/").filter(r=>r!==""),a={};let o=0;for(let r=0;r<e.length;r++){const c=e[r],l=s[r];if(!l&&c.type!=="catch-all")return null;if(c.type==="literal"){if(c.value!==l)return null;o++}else if(c.type==="param")a[c.name]=l,o++;else if(c.type==="catch-all"){c.name&&(a[c.name]=s.slice(o).join("/"));const h="/"+s.slice(0,o).join("/"),d="/"+s.slice(o).join("/");return{params:a,matchedPath:h==="/"?"":h,remainingPath:d==="/"?"":d,route:t}}}if(s.length===e.length){const r="/"+s.join("/");return{params:a,matchedPath:r==="/"?"":r,remainingPath:"",route:t}}return null},Rt=e=>{const t=e.map(n=>{const s=q(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of t){const r=ae(a,o,s);if(r)return r}return null}},oe=e=>{const t=Rt(Object.keys(e));return i.Provide(F,{},()=>i.Use(K,n=>i.Use(F,s=>{const a=n.location.map(o=>{const r=t(o.pathname);if(r==null)throw console.error("No route found for",o),new Error("No route found");const c={matchedPath:r.matchedPath,remainingPath:r.remainingPath,fullPath:o.pathname,params:r.params};return s.value=[...s.value,c],{params:r.params,route:r.route,path:r.matchedPath||o.pathname,search:o.search,hash:o.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),e)})))},ie=e=>{const t=Rt(Object.keys(e));return i.Use(F,n=>i.Use(K,s=>{const a=n.map(o=>{const r=o[o.length-1];if(r==null)throw console.error("No router context available for ChildRouter",o),new Error("No router context available for ChildRouter");const c=r.remainingPath??"",l=t(c);if(l==null)throw console.error("No route found for remaining path",c),new Error("No route found");return{params:l.params,route:l.route,path:l.matchedPath,search:s.location.value.search,hash:s.location.value.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),e)}))},U=60*1e3,$=60*U,T=24*$,nt=7*T,st=30*T,ce=365*T,le=[{max:U*90,value:U,name:"minute",past:{singular:"a minute ago",plural:"{} minutes ago"},future:{singular:"in a minute",plural:"in {} minutes"}},{max:$*36,value:$,name:"hour",past:{singular:"an hour ago",plural:"{} hours ago"},future:{singular:"in an hour",plural:"in {} hours"}},{max:T*10,value:T,name:"day",past:{singular:"yesterday",plural:"{} days ago"},future:{singular:"tomorrow",plural:"in {} days"}},{max:nt*6,value:nt,name:"week",past:{singular:"last week",plural:"{} weeks ago"},future:{singular:"in a week",plural:"in {} weeks"}},{max:st*18,value:st,name:"month",past:{singular:"last month",plural:"{} months ago"},future:{singular:"in a month",plural:"in {} months"}},{max:1/0,value:ce,name:"year",past:{singular:"last year",plural:"{} years ago"},future:{singular:"in a year",plural:"in {} years"}}];function rt(e,t,n,s){const a=Math.round(e/t);return a<=1?n:s.replace("{}",a.toLocaleString(void 0,{maximumFractionDigits:0,minimumFractionDigits:0}))}const Ot=(e=1e3)=>{const t=i.prop(new Date),n=f.interval(()=>t.set(new Date),e);return t.onDispose(n),t},Et=e=>{const t=Math.abs(e);if(t<U)return e<0?"just now":"in a moment";for(const n of le)if(t<n.max)return e<0?rt(t,n.value,n.past.singular,n.past.plural):rt(t,n.value,n.future.singular,n.future.plural);throw new Error("unreachable")},At=(e,{now:t,frequency:n=1e4}={})=>{const s=t!=null?i.Signal.is(t)?t.derive():i.prop(t):Ot(n),a=i.computedOf(e,s)((o,r)=>o.getTime()-r.getTime());return a.onDispose(()=>i.Value.dispose(s)),a},kt=(e,t={})=>{const n=At(e,t),s=n.map(Et);return s.onDispose(()=>n.dispose()),s},ue=(e,t={})=>kt(e,t);class Pt extends i.Prop{tick=()=>this.update(t=>t+1)}const he=(e=0)=>new Pt(e,i.strictEquals);exports.Anchor=ut;exports.Appearance=Ut;exports.AsyncResultView=j;exports.AutoFocus=Kt;exports.AutoSelect=Ct;exports.ChildRouter=ie;exports.ElementRect=Zt;exports.HTMLTitle=_t;exports.HiddenWhenEmpty=zt;exports.InViewport=pt;exports.Location=K;exports.Mutation=Bt;exports.MutationDisplay=gt;exports.NavigationService=re;exports.OnClickOutside=dt;exports.OnEnterKey=qt;exports.OnEscapeKey=Qt;exports.OnKeyPressed=I;exports.PopOver=Jt;exports.Query=Xt;exports.QueryDisplay=yt;exports.Rect=H;exports.ResultView=wt;exports.RootRouter=oe;exports.RouterContextProvider=F;exports.SelectOnFocus=Gt;exports.Ticker=Pt;exports.WhenInViewport=It;exports.WindowSize=te;exports._checkExtensionCondition=ot;exports._getExtension=at;exports._makeRouteMatcher=ee;exports._parseRouteSegments=q;exports.allPlacements=Yt;exports.areLocationsEqual=ct;exports.classes=Nt;exports.evaluateLocationMatch=z;exports.getAbsoluteRect=_;exports.handleAnchorClick=it;exports.locationFromURL=V;exports.makeMutationResource=ft;exports.makeQueryResource=vt;exports.matchesKeyCombo=mt;exports.matchesRoute=St;exports.nowSignal=Ot;exports.relativeTime=ue;exports.relativeTimeMillisSignal=At;exports.relativeTimeSignal=kt;exports.ticker=he;exports.timeDiffToString=Et;exports.urlFromLocation=b;exports.useAppearance=ht;
package/index.js CHANGED
@@ -556,7 +556,7 @@ const ie = ({
556
556
  "body",
557
557
  V.div(
558
558
  L((c) => {
559
- c.style.position = "absolute";
559
+ c.style.position = "absolute", c.style.top = "0", c.style.left = "0";
560
560
  const u = typeof s?.target == "string" ? i.querySelector(
561
561
  s.target
562
562
  ) : s?.target ?? i;
@@ -599,7 +599,7 @@ const ie = ({
599
599
  strategy: "absolute",
600
600
  middleware: g
601
601
  }), { x: Z, y: tt, middlewareData: j } = N;
602
- if (c.style.top = `${tt}px`, c.style.left = `${Z}px`, d != null && j.arrow != null) {
602
+ if (c.style.transform = `translate(${Z}px, ${tt}px)`, d != null && j.arrow != null) {
603
603
  const {
604
604
  x: et,
605
605
  y: l,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/ui",
3
- "version": "16.0.4",
3
+ "version": "16.0.6",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./index.cjs",