@shllg/emend 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/emend.mjs +21086 -19217
- package/dist/publish-worker.mjs +4181 -3998
- package/dist/skills/emend-publish/SKILL.md +15 -7
- package/dist/skills/emend-review/SKILL.md +5 -2
- package/dist/skills/emend-review/references/manifest.md +5 -2
- package/dist/web/assets/App-DW8Zqj6N.js +4 -0
- package/dist/web/assets/DiffPane-CnM0c-g-.js +238 -0
- package/dist/web/assets/app-DXKT0r1-.css +2 -0
- package/dist/web/assets/{app-BrSxOaSi.js → app-fqzCAY_o.js} +2 -2
- package/dist/web/assets/diff-counts-aavca3cx.js +95 -0
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/dist/web/assets/App-DPbforeN.js +0 -4
- package/dist/web/assets/DiffPane-Ck50eAdK.js +0 -238
- package/dist/web/assets/app-RgxpbwFB.css +0 -2
- package/dist/web/assets/diff-counts-MdwymqCR.js +0 -95
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffPane-Ck50eAdK.js","assets/rolldown-runtime-XKyaHtl9.js","assets/jsx-runtime-BwolrYx8.js","assets/diff-counts-MdwymqCR.js","assets/diff-counts-CdprTo7g.css","assets/preload-helper-BLdHbfdN.js","assets/hastToHtml-ptNQFKyE.js","assets/unwrapDefault-ByDmBtHB.js","assets/lib-6HYXi0_j.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";import{n,r,t as i}from"./jsx-runtime-BwolrYx8.js";import{$ as a,$t as o,A as s,An as c,At as l,B as u,Bt as d,C as f,Cn as p,Ct as m,D as h,Dn as g,Dt as _,E as v,En as y,Et as b,Fn as x,Ft as S,G as C,Gt as w,H as T,Ht as E,I as D,In as O,It as k,J as A,Jt as j,K as ee,Kt as M,L as N,Ln as te,Lt as P,M as ne,Mn as F,N as re,Nn as I,Nt as ie,O as L,On as R,Ot as ae,P as oe,Pn as se,Pt as z,Q as ce,Qt as le,R as ue,Rn as de,Rt as fe,S as pe,Sn as me,T as B,Tn as he,Tt as ge,U as _e,Ut as ve,V,Vt as ye,W as be,Wt as xe,X as Se,Xt as Ce,Y as H,Yt as U,Z as we,Zt as Te,_ as W,_n as Ee,_t as De,a as Oe,an as ke,at as Ae,b as je,bn as Me,bt as Ne,c as Pe,cn as Fe,ct as G,dn as Ie,dt as Le,en as Re,et as ze,f as Be,g as Ve,gn as He,gt as Ue,h as We,hn as Ge,ht as Ke,i as qe,in as Je,it as Ye,j as Xe,jn as Ze,jt as Qe,k as $e,kn as et,kt as tt,l as nt,ln as rt,lt as it,mn as K,mt as at,nn as ot,nt as st,o as ct,on as lt,ot as ut,pn as q,pt as dt,q as ft,qt as pt,r as mt,rn as ht,rt as gt,s as _t,sn as vt,st as yt,t as bt,tn as xt,tt as St,u as Ct,un as wt,ut as Tt,v as Et,vn as Dt,vt as Ot,w as kt,wn as At,wt as jt,x as Mt,xn as J,xt as Nt,yn as Pt,yt as Ft,z as It,zn as Lt,zt as Rt}from"./diff-counts-MdwymqCR.js";import{a as zt,i as Bt,n as Vt,o as Ht,r as Ut}from"./pairing-secret-YzFjEOKw.js";import{t as Wt}from"./preload-helper-BLdHbfdN.js";var Gt=class extends p{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new Dt({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Kt(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Kt(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Kt(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Kt(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){J.batch(()=>{let e=this.getAll();this.#e.clear(),this.#t.clear(),e.forEach(e=>{this.notify({type:`removed`,mutation:e})})})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>g(t,e))}findAll(e={}){return this.getAll().filter(t=>g(e,t))}notify(e){J.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return J.batch(()=>Promise.all(e.map(e=>e.continue().catch(et))))}};function Kt(e){return e.options.scope?.id}var qt=class extends p{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??y(r,t),a=this.get(i);return a||(a=new Pt({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){J.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>R(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>R(e,t)):t}notify(e){J.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){J.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){J.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Jt=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new qt,this.#t=e.mutationCache||new Gt,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=me.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Me.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Ze(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=At(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return J.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;J.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return J.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=J.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(et).catch(et)}invalidateQueries(e,t={}){return J.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=J.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(et)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(et)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(Ze(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Ze(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(et).catch(et)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(et).catch(et)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Me.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(he(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{c(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(he(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{c(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=y(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===F&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function Yt(e){return e}var Y=e(r(),1),Xt=Y.useLayoutEffect;function Zt(e){return e[e.length-1]}function Qt(e,t){return typeof e==`function`?e(t):e}var $t=Object.prototype.hasOwnProperty;function en(e){for(let t in e)if($t.call(e,t))return!0;return!1}var tn=()=>Object.create(null),nn=(e,t)=>rn(e,t,!0);function rn(e,t,n,r=0){if(e===t)return e;if(r++>500)return t;let i=Array.isArray(e)&&Array.isArray(t);if(!i&&!(an(e)&&an(t)))return t;let a=Object.keys(e),o=a.length,s=Object.keys(t),c=s.length;if(i?o!==e.length||c!==t.length||o&&Zt(a)!==`${o-1}`||c&&Zt(s)!==`${c-1}`:o!==Object.getOwnPropertyNames(e).length||c!==Object.getOwnPropertyNames(t).length||Object.getOwnPropertySymbols(t).length)return t;let l=0,u,d,f;if(i){for(;l<c&&(f=l,d=e[f],u=t[f],u=d===u?d:typeof d==`object`?rn(d,u,n,r):u,u===d);l++);if(l===c&&o===c)return e}else{let i=o===c,p=!0;for(;l<c;l++){f=s[l],d=e[f];let o=t[f];u=d===o?d:typeof d==`object`?rn(d,o,n,r):o,i&&=u===d&&(a[l]===f||$t.call(e,f)),p&&=Object.is(u,o),a[l]=u}if(i)return Object.getOwnPropertySymbols(e).length?t:e;if(p)return t}let p=i?s.fill(0):n?tn():{};for(let o=0;o<c;o++)f=i?o:s[o],i?(d=e[f],o>l&&(u=t[f],u=d===u?d:typeof d==`object`?rn(d,u,n,r):u),p[f]=o<l?d:u):p[f]=a[o];return p}function an(e){return!e||typeof e!=`object`?!1:(Object.getPrototypeOf(e)?.constructor??Object)===Object}function on(e,t,n,r){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0,a=e.length;i<a;i++){let a=e[i],o=t[i];if(a!==o&&!on(a,o,n,r))return!1}return!0}if(an(e)&&an(t)){if(n){for(let i in t)if((r||t[i]!==void 0)&&!on(e[i],t[i],n,r))return!1;return!0}let i=0;if(r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;for(let a in t)if((r||t[a]!==void 0)&&(i--===0||!on(e[a],t[a],n,r)))return!1;return i===0}return!1}var sn=/[\x00-\x1f\x7f"<>`{}]/g;function cn(e){return e.replace(sn,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function ln(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return cn(t)}var un=[`http:`,`https:`,`mailto:`,`tel:`];function dn(e){if(e[0]!==`/`&&e.includes(`:`))return/^[\x00-\x20]*([a-z][a-z\d+.\t\n\r-]*:)/i.exec(e)?.[1]?.replace(/[\t\n\r]/g,``).toLowerCase()}var fn=/^[\x00-\x20]*[\\/][\t\n\r]*[\\/]/;function pn(e,t){if(!e)return!1;if(fn.test(e))return!0;let n=dn(e);return n?!t.has(n):!1}function mn(e){if(!e)return e;let t=e;if(/[%\\\x00-\x1f\x7f]/.test(e)){let n=/%25|%5C/gi,r=0,i;for(t=``;(i=n.exec(e))!==null;)t+=ln(e.slice(r,i.index))+i[0],r=n.lastIndex;t+=ln(r?e.slice(r):e)}return t}function hn(e){return/[\s\u0080-\uFFFF]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function gn(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function _n(){throw Error(`Invariant failed`)}function vn(e){return e.replace(/\/{2,}/g,`/`)}function yn(e){return e===`/`?e:e.replace(/^\/+/,``)}function bn(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/+$/,``):e}function xn(e){return bn(yn(e))}function Sn(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function Cn(e,t,n=`never`,r){if(t.includes(`//`)&&(t=vn(t)),t.startsWith(`/`))return t.length===1||n===`preserve`?t:n===`always`?t.endsWith(`/`)?t:`${t}/`:t.endsWith(`/`)?t.slice(0,-1):t;let i=t===`.`,a;if(r){a=i?e:e+`\0`+t;let n=r.get(a);if(n)return n}let o;if(i)o=e.split(`/`);else{for(e.includes(`//`)&&(e=vn(e)),o=e.split(`/`);o.length>1&&Zt(o)===``;)o.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&o.push(r):o=[r]:r===`..`?o.length>1?o.pop():o=[``]:r===`.`||o.push(r)}}o.length>1&&(Zt(o)===``?n===`never`&&o.pop():n===`always`&&o.push(``));let s=o.join(`/`),c=(i?vn(s):s)||`/`;return a&&r&&r.set(a,c),c}function wn(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=new RegExp([...t.keys()].join(`|`).replace(/[.*()]/g,`\\$&`),`g`);return e=>e.replace(n,e=>t.get(e)??e)}function Tn(e){return e==null||e===``}function En(e,t,n){if(typeof t!=`string`)return``+(t??void 0);let r=e===`_splat`;if(r&&(!t||/^[a-zA-Z0-9\-._~!/]*$/.test(t)))return t;let i=encodeURIComponent(t);return r&&(i=i.replaceAll(`%2F`,`/`)),n?n(i):i}function Dn(e,t,n,r,i){let a=e.endsWith(`/`)?`/`:``,o=``;for(let e of t){if(typeof e==`string`){o+=e;continue}let[t,s,c,l]=e,u=t===2,d=u&&l!==void 0?l+a:l,f=n[s];if(t!==3||f!=null){if(i&&(i[s]=f,u&&(i[`*`]=f)),u&&Tn(f)){if(c===`/`&&!d)continue;f=``}o+=c+En(s,f,r)+(d||``)}}return o+a||`/`}function On(e){return e?.isNotFound===!0}function kn(){try{return sessionStorage}catch{return}}var An=`tsr-scroll-restoration-v1_3`,jn=kn();function Mn(){try{return JSON.parse(jn?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}var Nn=Mn(),Pn=`data-scroll-restoration-id`,Fn=e=>e.state.__TSR_key||e.href;function In(e){let t=e.getAttribute(Pn);if(t)return`[${Pn}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var Ln=!1,Rn=`window`;function zn(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function Bn(e){let t=new Set;for(let n of e){if(n===Rn)continue;let e=zn(n);e&&t.add(e)}return t}function Vn(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.e=!0);let i=e.options.getScrollRestorationKey||Fn,a=new Set,o=e=>{let t=Nn[e]||={};for(let e of a)e===document?t[Rn]={scrollX,scrollY}:e.isConnected&&(t[In(e)]={scrollX:e.scrollLeft,scrollY:e.scrollTop})};n&&!r.s&&(r.s=!0,Ln=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,e=>{Ln||a.add(e.target)},!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&o(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{history.scrollRestoration=`auto`,o(i(e.stores.resolvedLocation.get()??e.stores.location.get()));try{jn?.setItem(An,JSON.stringify(Nn))}catch{}}),addEventListener(`pageshow`,e=>{e.persisted&&(history.scrollRestoration=`manual`)})),!r.r&&(r.r=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.n,c=r.h,l;if(a.clear(),r.n=!0,r.h=!1,typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let u=i(t.toLocation),d=t.fromLocation&&i(t.fromLocation);if(r.e&&d&&d!==u){let e=Nn[d];if(e){let t=Nn[u];for(let n in e){if(n===Rn){if(s)continue}else{let e=zn(n);if(!e||s&&o&&(l??=Bn(o),l.has(e)))continue}t||=Nn[u]={},t[n]??=e[n]}}}Ln=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){!e&&o&&(l??=Bn(o));let t=e&&i&&c,s=r.e?Nn[u]:void 0;if(s)for(let e in s){let{scrollX:r,scrollY:i}=s[e];if(e===Rn){if(t)continue;scrollTo({top:i,left:r,behavior:n}),a=!0}else{let t=zn(e);t&&(t.scrollLeft=r,t.scrollTop=i,l?.delete(t))}}if(!e){let e={top:0,left:0,behavior:n};if(a||scrollTo(e),l)for(let t of l)t.scrollTo(e)}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{Ln=!1}}))}function Hn(e,t=String){let n;for(let r in e){let i=e[r];i!==void 0&&(n||=new URLSearchParams).set(r,t(i))}return n?n.toString():``}function Un(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function Wn(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=Un(r):Array.isArray(t)?t.push(Un(r)):n[e]=[t,Un(r)]}return n}var Gn=/^(?:\s|["[{\d-]|fa|nu|tr)/,Kn=Jn(JSON.parse),qn=Yn(JSON.stringify,JSON.parse);function Jn(e){let t=e===JSON.parse;return n=>{n[0]===`?`&&(n=n.slice(1));let r=Wn(n);for(let n in r){let i=r[n];if(typeof i==`string`){if(t&&!Gn.test(i))continue;try{r[n]=e(i)}catch{}}}return r}}function Yn(e,t){let n=t===JSON.parse;function r(r){if(r&&typeof r==`object`)try{return e(r)}catch{}else if(t&&typeof r==`string`){if(n&&!Gn.test(r))return r;try{return t(r),e(r)}catch{}}return r}return e=>{let t=Hn(e,r);return t?`?${t}`:``}}var Xn=`__root__`;function Zn(e){e.statusCode=e.statusCode||e.code||307;let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function Qn(e){return e instanceof Response&&!!e.options}function $n(e){let t=new Map,n,r;return{get(e){let n=t.get(e);if(n)return n.visited=!0,n.value},set(i,a){let o=t.get(i);if(o){o.value=a;return}if(t.size>=e){let e=n?.next().value;for(;!e||e.visited;)e?e.visited=!1:n=t.values(),e=n.next().value;e===r&&(n=void 0),t.delete(e.key)}let s={key:i,value:a,visited:!1};r=s,t.set(i,s)},clear(){t.clear(),n=void 0,r=void 0}}}var er=4,tr=5;function nr(e){let t=e.names;if(t)return t;let n=[];for(let t of e)typeof t!=`string`&&n.push(t[1]);return e.names=n}function rr(e,t,n){let r=e.slice(t,n);if(r.charCodeAt(0)===36)return r.length===1?[2,`_splat`,``,void 0]:[1,r.slice(1),``,``];let i=r.indexOf(`{`);if(i>=0){let a=r.indexOf(`}`,i),o=r.charCodeAt(i+1)===45,s=i+(o?3:2);if(a>=0&&r.charCodeAt(s-1)===36&&(!o||s<a)){let c=r.slice(s,a);return[o?3:c?1:2,c||`_splat`,r.slice(0,i),e.slice(t+a+1,c?n:e.length)]}}return r}function ir(e,t,n,r,i,a){let o=n,s=t.fullPath??t.from,c=t.options,l=s.length,u=s.endsWith(`/`)?l-1:l,d=c?.caseSensitive??e,f=c?.params?.parse??c?.parseParams,p,m=a?n-1:0;if(!r||s.includes(`$`)){p=a?.slice()??[];let e=Zt(p);e&&typeof e!=`string`&&e[0]===2&&(p[p.length-1]=[e[0],e[1],e[2],e[3]===void 0?void 0:e[3]+s.substring(n-(s[n-2]===`/`?2:1),u)],m=l)}for(;o<l;){let e=o,t=s.indexOf(`/`,e),n=t===-1?l:t,a=rr(s,e,n);o=n+1;let c;if(typeof a==`string`){if(!r)continue;let e=a,t;d?t=r.static??=new Map:(e=a.toLowerCase(),t=r.staticInsensitive??=new Map);let n=t.get(e);if(n)c=n;else{let n=or(r);c=n,t.set(e,n)}}else{let t=a[0],h=a[2],g=a[3]??``;if(t===2&&(n=l,o=n+1),p&&m<n&&(m<e-1&&p.push(s.slice(m,e-1)),a[2]=`/`+h,t===2&&a[3]!==void 0&&u<l&&(a[3]=g.slice(0,-1)),p.push(a),m=n),!r)continue;let _=d&&!!(h||g);d||(h=h.toLowerCase(),g=g.toLowerCase());let v=t===1?r.dynamic??=[]:t===3?r.optional??=[]:r.wildcard??=[],y=t!==2&&!f&&v.find(e=>!e.parse&&e.caseSensitive===_&&e.prefix===h&&e.suffix===g);if(y)c=y;else{let e=or(r,t,_,h,g);c=e,v.push(e),v.length===2&&i?.push(v)}}r=c}p&&m<u&&p.push(s.slice(m,u));let h=p?.slice();if(!r)return h;if(f&&t.children&&!t.isRoot&&t.id&&t.id.charCodeAt(t.id.lastIndexOf(`/`)+1)===95){let e=or(r,tr);(r.pathless??=[]).push(e),r=e}let g=(t.path||!t.children)&&!t.isRoot;if(g&&u<l){let e=or(r,er);r.index=e,r=e}return r.parse=f??null,r.priority=c?.params?.priority??0,r.route||(r.data=h,g&&(r.route=t)),[r,o,h]}function ar(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function or(e,t=0,n,r,i){return{kind:t,depth:e?e.depth+1:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,data:void 0,parent:e,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function sr(e,t){let n=or(),r=[];function i(e,t,n,a){let[o,s,c]=ir(!1,e,t,n,r,a);if(e.children)for(let t of e.children)i(t,s,o,c)}for(let t of e)i(t,1,n);for(let e of r)e.sort(ar);t.masksTree=n,t.flatCache=$n(1e3)}function cr(e,t){e||=`/`;let n=t.flatCache.get(e);if(n!==void 0)return n;let r=fr(e,t.masksTree);return t.flatCache.set(e,r),r}function lr(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=or(),ir(t,{from:e},1,o),i.singleCache.set(a,o)),fr(r,o,n)}function ur(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=fr(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=mr(a.route)),t.matchCache.set(r,a),a}function dr(e,t=!1){let n=or(),r=[],i={},a={},o=0;function s(e,n,c,l){if(e.init(o),e.id in i&&_n(),i[e.id]=e,o!==0&&e.path){let t=bn(e.fullPath);(!a[t]||e.fullPath.endsWith(`/`))&&(a[t]=e)}o++;let[u,d,f]=ir(t,e,n,c,r,l);if(e._interpolation=f,e.children)for(let t of e.children)s(t,d,u,f)}s(e,1,n);for(let e of r)e.sort(ar);return{processedTree:{segmentTree:n,singleCache:$n(1e3),matchCache:$n(1e3),flatCache:null,masksTree:null},routesById:i,routesByPath:a}}function fr(e,t,n=!1){let r=e.split(`/`),i=gr(e,r,t,n);if(!i)return null;let[a]=pr(e,r,i);return{route:i.node.route,rawParams:a}}function pr(e,t,n){let r=hr(n.node),i=n.node.data&&nr(n.node.data),a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.param??0;for(;s<r.length;o++,s++,c++){let u=r[s];if(u.kind===er)break;if(u.kind===tr){o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1||u.kind===3){let e=i[l++];if(u.kind===3&&n.skipped&1<<s){o--,c=f-1;continue}let t=u.suffix||u.prefix?d.substring(u.prefix.length,d.length-u.suffix.length):d;(t||u.kind===1)&&(a[e]=decodeURIComponent(t))}else if(u.kind===2){let t=u,n=e.substring(f+t.prefix.length,e.length-t.suffix.length),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,param:l}]}function mr(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function hr(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function gr(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!Zt(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,statics:f,dynamics:p,optionals:m}=n,{extract:h,rawParams:g}=n;if(i.kind===2&&i.route&&!br(l,n))continue;if(i.parse){if(!yr(e,t,n))continue;g=n.rawParams,h=n.extract}r&&i.route&&i.kind!==er&&br(c,n)&&(c=n);let _=u===o;if(_&&(i.route&&(!a||i.kind===er||i.kind===2)&&br(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let v=_?void 0:t[u],y;if(_&&i.index){let n={node:i.index,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g},r=!0;if(i.index.parse&&(yr(e,t,n)||(r=!1)),r){if(!p&&!m&&!d&&vr(f,o))return n;br(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!r||!_&&(n.caseSensitive?v:y??=v.toLowerCase()).startsWith(r)){if(a){if(_)continue;let e=t.slice(u).join(`/`),i=e.slice(-a.length);if((n.caseSensitive?i:i.toLowerCase())!==a||e.length-a.length<r.length)continue}s.push({node:n,index:o,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(i.optional){let e=d|1<<i.depth+1;for(let t=i.optional.length-1;t>=0;t--){let n=i.optional[t];s.push({node:n,index:u,skipped:e,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_)for(let e=i.optional.length-1;e>=0;e--){let t=i.optional[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&e.indexOf(r,e.length-r.length)<n.length)continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p,optionals:m+_r(o,u),extract:h,rawParams:g})}}if(!_&&i.dynamic&&v)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&e.indexOf(r,e.length-r.length)<n.length)continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p+_r(o,u),optionals:m,extract:h,rawParams:g})}if(!_&&i.staticInsensitive){let e=i.staticInsensitive.get(y??=v.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,statics:f+_r(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_&&i.static){let e=i.static.get(v);e&&s.push({node:e,index:u+1,skipped:d,statics:f+_r(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(i.pathless)for(let e=i.pathless.length-1;e>=0;e--){let t=i.pathless[e];s.push({node:t,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function _r(e,t){return 2**(e-t-1)}function vr(e,t){return e===2**(t-1)-1}function yr(e,t,n){let r,i;try{[r,i]=pr(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function br(e,t){return!e||t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===er)>(e.node.kind===er)||t.node.kind===er==(e.node.kind===er)&&t.node.depth>e.node.depth)))}function xr(e,t,n){let r=xn(e),i=`/${r}`,a=t?i:i.toLowerCase(),o=`${a}/`,s={input:({url:e})=>{let n=t?e.pathname:e.pathname.toLowerCase();return n===a?e.pathname=`/`:n.startsWith(o)&&(e.pathname=e.pathname.slice(i.length)),e},output:({url:e})=>(e.pathname=vn(`/${r}${e.pathname}`),e)};return n?{input:({url:e})=>Sr(n,s.input({url:e})),output:({url:e})=>s.output({url:Cr(n,e)})}:s}function Sr(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Cr(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function wr(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i}=t,a=new Map,o=n(`idle`),s=n(e),c=n(void 0),l=n([]),u=r(()=>l.get().map(e=>a.get(e).get())),d=r(()=>({status:o.get(),isLoading:o.get()===`pending`,matches:u.get(),location:s.get(),resolvedLocation:c.get()}));function f(e){let t=a.get(e);return t||(t=n(void 0),a.set(e,t)),t}let p={status:o,location:s,resolvedLocation:c,ids:l,matches:u,byRoute:a,__store:d,getMatchStore:f,setMatches:m};function m(e){let t=l.get(),n=e.map(e=>e.routeId);i(()=>{gn(t,n)||l.set(n);for(let e of t)n.includes(e)||a.get(e).set(()=>void 0);for(let t of e){let e=f(t.routeId);e.get()!==t&&e.set(t)}})}return p}var Tr=`__TSR_index`,Er=`popstate`,Dr=`beforeunload`,Or=/^[\x00-\x20]*(?:[\\/][\t\n\r]*){2,}/;function kr(e){let t=Or.exec(e);return t?`/`+e.slice(t[0].length):e}function Ar(e){return/[\x00-\x1f\x7f]/.test(e)&&(e=e.replace(/[\x00-\x1f\x7f]/g,e=>`
|
|
3
|
-
\r`.includes(e)?``:encodeURIComponent(e))),kr(e)}function jr(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async n=>{let r=n.navigateOpts?.ignoreBlocker?void 0:e.getBlockers?.();if(typeof document<`u`&&r?.length&&(n.type===`PUSH`||n.type===`REPLACE`))for(let i of r){let r=Pr(n.path,n.state);if(await i.blockerFn({currentLocation:t,nextLocation:r,action:n.type})){e.onBlocked?.();return}}n.task()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[Tr];i=Mr(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[Tr];i=Mr(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t,n?.ignoreBlocker??!1),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[Tr]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r,_getBlockers:()=>e.getBlockers?.()??[]}}function Mr(e,t){let n=Fr();return{...t,key:n,__TSR_key:n,[Tr]:e}}function Nr(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=t=>Ar(e?.createHref?e.createHref(t):t),c=e?.parseLocation??(()=>Pr(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=Fr();t.history.replaceState({[Tr]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_=()=>{g&&(S._ignoreSubscribers=!0,(g[2]?t.history.pushState:t.history.replaceState)(g[1],``,g[0]),S._ignoreSubscribers=!1,g=void 0,u=void 0)},v=(t,n,r)=>{let i=e?.createHref?s(n):void 0,a=!!g;a||(u=l),l=Pr(n,r),g=[i??l.href,r,g?.[2]||t],a||queueMicrotask(()=>_())},y=e=>{l=c(),S.notify({type:e})},b=async()=>{if(m=!1,f){f=!1;return}let e=c(),n=e.state[Tr]-l.state[Tr],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let r=a();if(typeof document<`u`&&r.length){for(let i of r)if(await i.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(-n),S.notify(u);return}}}l=c(),S.notify(u)},x=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0||typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},S=jr({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>v(!0,e,t),replaceState:(e,t)=>v(!1,e,t),back:e=>(e&&(p=!0,m=!0),t.history.back()),forward:e=>{e&&(p=!0,m=!0),t.history.forward()},go:(e,n)=>{d=!0,n&&(p=!0,m=!0),t.history.go(e)},createHref:s,flush:_,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(Dr,x,{capture:!0}),t.removeEventListener(Er,b)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return S._ignoreNextBeforeUnload=e=>{m=!1;try{e=new URL(e,t.document.baseURI).href,m=/^https?:/.test(e)&&(!e.includes(`#`)||e.split(`#`)[0]!==t.location.href.split(`#`)[0])}catch{}},t.addEventListener(Dr,x,{capture:!0}),t.addEventListener(Er,b),t.history.pushState=function(...e){let r=n.apply(t.history,e);return S._ignoreSubscribers||y(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return S._ignoreSubscribers||y(`REPLACE`),n},S}function Pr(e,t){let n=Ar(e),r=n.indexOf(`#`),i=n.indexOf(`?`);if(!t){let e=Fr();t={[Tr]:0,key:e,__TSR_key:e}}return{href:n,pathname:n.slice(0,r>-1?i>-1?Math.min(r,i):r:i>-1?i:n.length),hash:r>-1?n.slice(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t}}function Fr(){return(Math.random()+1).toString(36).slice(7)}function Ir(e,t){return e.protocol!==`http:`&&e.protocol!==`https:`||e.origin!==t||!!e.username||!!e.password}function Lr(e){return e.pathname+e.search+e.hash}function Rr(e){return e.options.loader||e.options.beforeLoad||e.lazyFn||e.options.component?.preload||e.options.pendingComponent?.preload}function zr(e,t){return{fromLocation:t,toLocation:e,pathChanged:t?.pathname!==e.pathname,hrefChanged:t?.href!==e.href,hashChanged:t?.hash!==e.hash}}function Br({key:e,__TSR_key:t,__TSR_index:n,__hashScrollIntoViewOptions:r,...i}){return i}function Vr(e){return e.findIndex(e=>e.status===`error`||e.status===`notFound`||e._notFound)+1}function Hr(e,t,n,r,i,a){r&&(t=t.slice(0,r)),i&&(n=n.slice(0,i));for(let r of t){if(a&&e._tx!==a)return;n.some(e=>e.routeId===r.routeId)||e.routesById[r.routeId].options.onLeave?.(r)}for(let r of n){if(a&&e._tx!==a)return;e.routesById[r.routeId].options[t.some(e=>e.routeId===r.routeId)?`onStay`:`onEnter`]?.(r)}}var Ur=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={n:!0},this.subscribers=new Set,this._cache=new Map,this._committed=[],this.startTransition=async e=>(e(),!1),this.update=e=>{let t=this.options;this.options={...t,...e},this.isServer=this.options.isServer??!1??typeof document>`u`,this.staticLocations=new WeakMap,this.protocolAllowlist=new Set(this.options.protocolAllowlist),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history?this.options.history:Nr()),this.origin=this.options.origin,this.origin||=window?.origin&&window.origin!==`null`?window.origin:`http://localhost`;let n=this.options.basepath??`/`,r=this.options.rewrite,i=this.basepath!==n||t?.rewrite!==r||t?.caseSensitive!==this.options.caseSensitive;if(i&&(this.basepath=n,this.rewrite=n!==`/`&&xn(n)?xr(n,this.options.caseSensitive,r):r),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;e=this.buildRouteTree(),this.setRoutes(e)}if(this.stores)i&&this.stores.location.set(this.latestLocation);else if(this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=wr(this.latestLocation,e),Vn(this)}},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=dr(this.routeTree,this.options.caseSensitive);return this.options.routeMasks&&sr(this.options.routeMasks,e.processedTree),{...e,resolvePathCache:$n(1e3)}},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{for(let t of this.subscribers)if(t.eventType===e.type)try{t.fn(e)}catch(e){console.error(e)}},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i},a)=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:mn(e),external:!1,searchStr:o,search:nn(t?.search,i),hash:mn(r.slice(1)),state:rn(t?.state,a)}}let o=Sr(this.rewrite,new URL(i,this.origin)),s=this.options.parseSearch(o.search),c=this.options.stringifySearch(s);return o.search=c,{href:o.href.replace(o.origin,``),publicHref:i,pathname:mn(kr(o.pathname)),external:!!this.rewrite&&Ir(o,this.origin),searchStr:c,search:nn(t?.search,s),hash:mn(o.hash.slice(1)),state:rn(t?.state,a)}},r=n(e,e.state),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i,{...i.state,__tempLocation:void 0,key:r.state.key,__TSR_key:r.state.__TSR_key});return e.maskedLocation=r,e}return r},this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>{let t=Object.create(null),n=ur(bn(e),this.processedTree,!0);return n&&Object.assign(t,n.rawParams),[n?.branch||[this.routesById.__root__],t,n?.route]},this.buildLocation=e=>{{let t=this.staticLocations.get(e);if(t)return t}let t=!1,n=(n={})=>{if(n.href){let e=Pr(n.href,{});n={...n,to:Sr(this.rewrite,new URL(e.pathname,this.origin)).pathname,search:this.options.parseSearch(e.search),hash:e.hash.slice(1)}}let r=e._fromLocation||this._pendingLocation||this.latestLocation,i,a=()=>(t=!0,r),o=()=>i??=this.matchRoutesLightweight(a()),s=n.to?`${n.to}`:`.`,c=Cn(s[0]===`/`?``:n.unsafeRelative===`path`?a().pathname:n.from??o()[1],s,this.options.trailingSlash,this.resolvePathCache),l=this.routesByPath[bn(c)],u=c.includes(`$`),d;if(l)d=l._branch??=mr(l);else if(u)d=[];else{let[e,t,n]=this.getMatchedRoutes(c);d=e,this.options.notFoundRoute&&(!n||n.path!==`/`&&t[`**`])&&(d=[...d,this.options.notFoundRoute])}let f=u?l?._interpolation??ir(!1,{fullPath:c},0):void 0,p;for(let e of d){let t=e.options.params?.stringify??e.options.stringifyParams;if(t){let e=o()[3];if(p??=Jr(n.params,e),!en(p))break;p===e&&(p=Object.assign(tn(),p));try{Object.assign(p,t(p))}catch{}}}p??=Jr(n.params,Yr(n.params,f)?o()[3]:Xr);let m=e.leaveParams?c:kr(mn(f?Dn(c,f,p,this.pathParamsDecoder):c)),h=Zr(d,e._includeValidateSearch),g=()=>{let t=o()[2];if(e._includeValidateSearch&&this.options.search?.strict){let e={};d.forEach(n=>{if(n.options.validateSearch)try{Object.assign(e,qr(n.options.validateSearch,{...e,...t}))}catch{}}),t=e}return t},_=h.length?Qr(h,g(),n):n.search===!0?g():typeof n.search==`function`?n.search(g()):n.search||Xr,v=this.options.stringifySearch(_),y=n.hash===!0?a().hash:typeof n.hash==`function`?n.hash(a().hash):n.hash||void 0,b=y?`#${y}`:``,x=n.state?n.state===!0?a().state:typeof n.state==`function`?n.state(a().state):n.state:Xr,S=`${m}${v}${b}`,C,w,T=!1;if(this.rewrite){let e=new URL(S,this.origin),t=e.origin,n=Cr(this.rewrite,e);C=Lr(e),Ir(n,t)?(w=n.href,T=!0):w=kr(Lr(n))}else C=hn(S),w=C;return{publicHref:w,href:C,pathname:m,search:_,searchStr:v,state:x,hash:y??``,external:T,unmaskOnReload:n.unmaskOnReload}},r=n(e);if(e.mask)r.maskedLocation=n({from:e.from,...e.mask});else if(this.options.routeMasks){let t=cr(r.pathname,this.processedTree);if(t){let i=Object.assign(tn(),t.rawParams),{from:a,params:o,...s}=t.route,c=Jr(o,i);r.maskedLocation=n({from:e.from,...s,params:c})}}return!t&&e._fromLocation&&this.staticLocations.set(e,r),r},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r=n.maskedLocation??n;if(r.external)return Wr(this,r.publicHref,{replace:n.replace,ignoreBlocker:t});let i,a=bn(this.latestLocation.href)===bn(n.href)&&on(Br(n.state),Br(this.latestLocation.state)),o=this._commitPromise,s,c=new Promise(e=>{s=e});if(c.resolve=()=>{s(),o?.resolve()},this._commitPromise=c,a)this.load();else{let{maskedLocation:r,hashScrollIntoView:a,...o}=n;r&&(o={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state={...o.state,__hashScrollIntoViewOptions:a??this.options.defaultHashScrollIntoView??!0},this.shouldViewTransition=e,i=n.replace?`REPLACE`:`PUSH`,this.history[i===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t}),this.history.subscribers.size||this.load({action:{type:i}})}return this._scroll.n=n.resetScroll??!0,this._commitPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,...a}={})=>{let o=this.buildLocation({...a,_includeValidateSearch:!0});this._pendingLocation=o;let s=this.commitLocation({...o,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return queueMicrotask(()=>{this._pendingLocation===o&&(this._pendingLocation=void 0)}),s},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=n?dn(n):void 0;if(a||t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i}),a=t.maskedLocation??t;n??=a.publicHref,r??=a.publicHref}let t=!a&&r?r:n;return Wr(this,t,i)}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.load=async e=>{this.updateLatestLocation(),e?.action&&(this._scroll.h=e.action.type===`PUSH`||e.action.type===`REPLACE`),await Ui(this,e)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&window.CSS?.supports?.(`selector(:active-view-transition-type(a))`)){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(zr(r,i)):t.types;if(a===!1)return e();n={update:e,types:a}}else n=e;return document.startViewTransition(n).updateCallbackDone}return e()},this.invalidate=e=>{let t=this._committed,n=e?.filter,r=this._preloads,i=new Set,a=e=>{(!n||n(e))&&i.add(e.id)};t.forEach(a),this._cache.forEach(a),r?.forEach(e=>e.forEach(a)),this._tx?.[3].forEach(a);let o=[];for(let[e,t]of r??[])t.some(e=>i.has(e.id))&&(r.delete(e),o.push(e));let s=t=>{if(i.has(t.id)){let n=this.routesById[t.routeId],r={...t,invalid:!0,...(e?.forcePending||t.status===`error`||t.status===`notFound`)&&Rr(n)?{status:`pending`,error:void 0}:void 0};return t._flight=void 0,r}return t};this._committed=t.map(s);for(let[t,n]of this._cache)i.has(t)&&(n.invalid=!0,e?.forcePending&&(n.status=`pending`));for(let e of i){let t=this._flights?.get(e);this._flights?.delete(e),t&&!t[2]&&o.push(t[1])}for(let e of o)e.abort();return this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.resolveRedirect=e=>{let t=e.options,n=e.headers.get(`Location`)||t.href;if(!n){let e=this.buildLocation(t);n=(e.maskedLocation??e).publicHref||`/`}let r;if(fn.test(n)||(r=dn(n))&&!this.protocolAllowlist.has(r))throw Error(`Redirect blocked: unsafe protocol`);if(r===`http:`||r===`https:`){let e=new URL(n);e.pathname.startsWith(`//`)?n=e.href:Ir(e,this.origin)||(n=Lr(e),r=void 0)}return r&&(t.reloadDocument=!0),t.href=n,e.headers.set(`Location`,n),e},this.clearCache=e=>{let t=this._cache,n=this._preloads,r=e?.filter,i=[],a=[];for(let[e,n]of t)(!r||r(n))&&(a.push(e),i.push(n));let o=[];for(let[e,t]of n??[])(!r||t.some(r))&&(o.push(e),i.push(...t));for(let e of a)t.delete(e);for(let e of o)n.delete(e);for(let e of i){let t=e._flight;e._flight=void 0,t&&!--t[2]&&(this._flights?.get(e.id)===t&&this._flights.delete(e.id),o.push(t[1]))}for(let e of o)e.abort()},this.loadRouteChunk=ri,this.preloadRoute=e=>Wi(this,e),this.matchRoute=(e,t)=>{let n={...e,to:e.to?Cn(e.from||``,e.to,this.options.trailingSlash,this.resolvePathCache):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n),i=this.stores.status.get()===`pending`;if(t?.pending&&!i)return!1;let a=t?.pending??!i?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),o=lr(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,a.pathname,this.processedTree);return!o||e.params&&!on(o.rawParams,e.params,!0)?!1:t?.includeSearch??!0?on(a.search,r.search,!0)?o.rawParams:!1:o.rawParams},this.getStoreConfig=t,e.pathParamsAllowedCharacters?.length&&(this.pathParamsDecoder=wn(e.pathParamsAllowedCharacters)),this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??qn,parseSearch:e.parseSearch??Kn,protocolAllowlist:e.protocolAllowlist??un}),self.__TSR_ROUTER__=this}isShell(){return!!this.options.isShell}get state(){return this.stores.__store.get()}setRoutes(e){Object.assign(this,e),this.lightweightCache=new WeakMap,this.staticLocations=new WeakMap;let t=this.options.notFoundRoute;t&&(t.init(99999999999),this.routesById[t.id]!==t&&(t._interpolation=ir(!1,t,0)),this.routesById[t.id]=t)}matchRoutesInternal(e,t){let[n,r,i]=this.getMatchedRoutes(e.pathname),a=n,o=!1;(i?i.path!==`/`&&r[`**`]:bn(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=o?$r(this.options.notFoundMode,a):void 0,c=Array(a.length),l=this._committed,u=(e,t)=>{let n=l[t];return n?.routeId===e.id?n:e===this.options.notFoundRoute?l.find(t=>t.routeId===e.id):void 0},d;for(let n=0;n<a.length;n++){let i=a[n],o=c[n-1],l,f,p;{let n=o?.search??e.search,r=o?._strictSearch??void 0;try{let e=qr(i.options.validateSearch,{...n})??void 0;l={...n,...e},f={...r,...e}}catch(e){let r=e;if(e instanceof Gr||(r=new Gr(e.message,{cause:e})),t?.throwOnError)throw r;l=n,f={},p=r}}let m=``,h=``;try{m=i.options.loaderDeps?.({search:l})??``,h=m&&JSON.stringify(m)||``}catch(e){if(t?.throwOnError)throw e;p??=e}let g=tn(),_=i._interpolation?Dn(i.fullPath,i._interpolation,r,this.pathParamsDecoder,g):i.fullPath,v=i.id+_+h,y=u(i,n),b=this._cache.get(v)??(y?.id===v?y:void 0);d=b?._strictParams??Object.assign(g,d);let x;if(!b)try{ei(i,d)}catch(e){if(x=On(e)||Qn(e)?e:new Kr(e.message,{cause:e}),t?.throwOnError)throw x}let S=y?`stay`:`enter`,C;if(b)C={...b,cause:S,search:nn(y?y.search:b.search,l),_strictSearch:f,searchError:p};else{let e=Rr(i)?`pending`:`success`;C={id:v,ssr:i.options.ssr,index:n,routeId:i.id,params:y?.params??d,_strictParams:d,pathname:_,updatedAt:Date.now(),search:y?nn(y.search,l):l,_strictSearch:f,searchError:p,status:e,isFetching:!1,error:void 0,paramsError:x,context:{},abortController:t?._controller??new AbortController,cause:S,loaderDeps:y?rn(y.loaderDeps,m):m,invalid:!1,preload:!1,staticData:i.options.staticData||{},fullPath:i.fullPath}}let w=s===i.id;C._notFound&&!w&&(C.error=void 0),C._notFound=w,c[n]=C}for(let e=0;e<c.length;e++){let n=c[e];n.params=n.cause===`stay`?nn(n.params,d):d,t?._controller&&(n.context={})}return c}matchRoutesLightweight(e){let t=Zt(this.stores.ids.get()),n=t?this.stores.byRoute.get(t).get():void 0,r=n?.id,i=this.lightweightCache.get(e);if(i&&i[0]===r)return i[1];let[a,o]=this.getMatchedRoutes(e.pathname),s=Zt(a),c={...e.search};for(let e of a)try{Object.assign(c,qr(e.options.validateSearch,c))}catch{}let l=n&&n.routeId===s.id&&n.pathname===e.pathname,u;if(l)u=n.params;else{let e=o;for(let t of a)try{ei(t,e)}catch{}u=e}let d=[a,s.fullPath,c,u];return this.lightweightCache.set(e,[r,d]),d}};async function Wr(e,t,{replace:n,ignoreBlocker:r}){if(!pn(t,e.protocolAllowlist)){if(!r){let t=e.history._getBlockers();for(let r of t)if(r?.blockerFn&&await r.blockerFn({currentLocation:e.history.location,nextLocation:e.history.location,action:n?`REPLACE`:`PUSH`}))return}e.history._ignoreNextBeforeUnload?.(t),n?window.location.replace(t):window.location.href=t}}var Gr=class extends Error{},Kr=class extends Error{};function qr(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new Gr(`Async validation not supported`);if(n.issues)throw new Gr(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function Jr(e,t){if(e===void 0||e===!0)return t;let n=Object.create(null);return e===!1||e===null?n:typeof e==`function`?(Object.assign(n,t),Object.assign(n,e(n))):Object.assign(n,t,e)}function Yr(e,t){return typeof e==`function`?!0:!t||e===!1||e===null?!1:e===void 0||e===!0||t.some(t=>typeof t!=`string`&&!$t.call(e,t[1]))}var Xr=Object.freeze({});function Zr(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r].options;`search`in i?i.search?.middlewares&&n.push(...i.search.middlewares):(i.preSearchFilters||i.postSearchFilters)&&n.push(({search:e,next:t})=>{let n=t(i.preSearchFilters?i.preSearchFilters.reduce((e,t)=>t(e),e):e);return i.postSearchFilters?i.postSearchFilters.reduce((e,t)=>t(e),n):n});let a=i.validateSearch;t&&a&&n.push(({search:e,next:t,meta:n})=>{let r=t(e);try{let e=qr(a,r);if(n&&e)for(let t in e)t in r||(n.defaulted||=new Map).set(t,e[t]);return{...r,...e}}catch{}return r})}return n}function Qr(e,t,n){let r=(t,i,a)=>{if(t>=e.length){if(!n.search)return{};if(n.search===!0)return i;let e=Qt(n.search,i);return a&&(a.explicit=e),e}return e[t]({search:i,next:(e,n)=>{if(n){let n=a||{};return{search:r(t+1,e,n),meta:n}}return r(t+1,e,a)},meta:a})};return r(0,t)}function $r(e,t){if(e!==`root`){let e;for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.options.notFoundComponent)return r.id;e||=r.children&&r.id}if(e)return e}return Xn}function ei(e,t){let n=e.options.params?.parse??e.options.parseParams;n&&Object.assign(t,n(t))}function ti(e,t){return e.options[t]?.preload?.()}function ni(e,t){let n=ti(e,`component`),r=ti(e,`pendingComponent`);return t&&(r?r=r.then(t):t()),n&&r?Promise.all([n,r]).then(()=>{}):n??r}function ri(e,t,n){let r=()=>t===!1?void 0:t?ti(e,t):ni(e,n),i=e._lazy;if(i)return i===!0?r():i.then(r);if(!e.lazyFn)return r();let a=e.lazyFn().then(t=>{{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazy=!0}},t=>{throw e._lazy=void 0,t});return e._lazy=a,a.then(r)}function ii(e){let t=e.findIndex(e=>e.status!==`success`||e._notFound)+1;return t&&t<e.length?e.slice(0,t):e}function ai(e,t,n){let r=e._tx;return t&&r?.[2]===n&&!r[3].some(e=>e.routeId===t)}var oi=0,si=1,ci=2,X=3,li=[4];function ui(e){return typeof e[0]==`number`}function di(e,t){return t.aborted?Promise.race([Promise.reject(t),e]):new Promise((n,r)=>{let i=()=>r(t);t.addEventListener(`abort`,i,{once:!0}),Promise.resolve(e).then(n,r).then(()=>t.removeEventListener(`abort`,i))})}function fi(e,t){return e.routesById[t.routeId]}function pi(e,t,n){return Qn(e)?[X,e]:On(e)?(e.routeId||=n,[ci,e]):t?(typeof e?.then==`function`&&(e=Error(`A Promise was thrown`,{cause:e})),[si,e]):[oi,e]}function mi(e,t){let n=pi(t,!0,e.id);if(n[0]!==si)return n;try{e.options.onError?.(n[1])}catch(t){n=pi(t,!0,e.id)}return n}function hi(e,t,n,r,i){return i[0].signal.aborted?li:Ai(e,t,n,mi(n,r),i)}async function gi(e,t,n,r,i,a){let[o,s]=t,c=n[0].signal,l=!!n[3];for(let i=n[6]??0;i<r;i++){let r=s[i],u=fi(e,r);r.abortController=n[0];let d=s[i-1]?.context??e.options.context??{},f={params:r.params,location:o,navigate:t=>e.navigate({...t,_fromLocation:o}),buildLocation:e.buildLocation,cause:l?`preload`:r.cause,abortController:n[0],preload:l,matches:s,routeId:u.id};try{let e=r._ctx||=u.options.context?u.options.context({...f,deps:r.loaderDeps,context:d})||{}:void 0;r.context={...d,...e}}catch(a){return vi(e,r),[i,hi(e,t,u,a,n)]}if(c.aborted)return[i,li];let p=r.paramsError??r.searchError;if(p!==void 0)return vi(e,r),[i,hi(e,t,u,p,n)];let m=u.options.beforeLoad;if(!m)continue;let h=r.status;i>=a&&(r.status=`pending`,n[7]?.());try{bi(e,r,`beforeLoad`,n[0]);let a=m({...f,search:r.search,context:r.context,...e.options.additionalContext}),o=await(typeof a?.then==`function`?di(a,c):a);if(c.aborted)return[i,li];let s=Ai(e,t,u,pi(o,!1,u.id),n);if(s[0]!==oi)return vi(e,r),[i,s];r.context={...r.context,...o}}catch(a){return vi(e,r),[i,hi(e,t,u,a,n)]}finally{r.status=h,bi(e,r,!1,n[0])}}i()}function _i(e,t,n){if(!(!n||--n[2])){if(e._flights?.get(t.id)===n){let n=e._tx;if(n&&!n[0].signal.aborted&&!n[3].includes(t)&&n[3].some(e=>e.id===t.id)&&n[3].some(e=>e.isFetching===`beforeLoad`))return;e._flights.delete(t.id)}return n[1]}}function vi(e,t){let n=t._flight;t._flight=void 0,_i(e,t,n)?.abort()}function Z(e,t,n,r){let i=[];for(let a of t)if(!n?.includes(a)){let t=a._flight;if(a._flight=void 0,r&&t?.[2]===1&&e._flights?.get(a.id)===t&&n?.some(e=>e.id===a.id))t[2]=0;else{let n=_i(e,a,t);n&&i.push(n)}}for(let e of i)e.abort()}function yi(e){for(let t of e){let e=t._flight;e&&e[2]++}}function bi(e,t,n,r){if(t.isFetching=n,r&&e._tx?.[0]!==r)return;let i=e.stores.byRoute.get(t.routeId),a=i?.get();a?.id===t.id&&i.set({...a,isFetching:n})}function xi(e,t,n,r,i,a,o){let s=t[0];return{params:n.params,location:s,navigate:t=>e.navigate({...t,_fromLocation:s}),cause:o?`preload`:n.cause,abortController:i,preload:o,deps:n.loaderDeps,parentMatchPromise:a,context:n.context,route:r,...e.options.additionalContext}}async function Si(e,t,n,r,i,a,o){let s=o[0],c=s.signal;if(c.aborted)return li;if(!i)return[oi,void 0];let l=n._flight;bi(e,n,`loader`,s);try{if(!l){let s=new AbortController;l=[Promise.resolve().then(()=>i(xi(e,t,n,r,s,a,!!o[3]))).then(e=>pi(e,!1,r.id),e=>pi(e,!0,r.id)).then(t=>(t[0]!==oi&&e._flights?.get(n.id)===l&&(e._flights.delete(n.id),l[2]||s.abort()),t[0]===si&&l[2]?mi(r,t[1]):t)),s,1],(e._flights??=new Map).set(n.id,l)}return n._flight=l,n.abortController=l[1],Ai(e,t,r,await di(l[0],c),o)}catch(t){if(t!==c||!c.aborted)throw t;return vi(e,n),li}finally{bi(e,n,!1,s)}}function Ci(e,t,n){t[0]!==X&&(e.status=`success`,e.error=void 0,t[0]===oi?(e.loaderData=t[1],e.invalid=!1,e.updatedAt=Date.now(),e.preload=n):e.invalid=!0)}function wi(e,t,n){let r=e._cache.get(t.id);if(r!==n||e._committed.some(e=>e.id===t.id&&e._flight===t._flight))return;let i={...t,_notFound:void 0,context:{}};i._flight&&i._flight[2]++,e._cache.set(t.id,i),r&&vi(e,r)}function Ti(e,t){return t[0]===si||t[0]===ci?{...e,status:t[0]===si?`error`:`notFound`,error:t[1],_flight:void 0}:e}function Ei(e,t,n,r,i,a,o){let s=t[1][n],c=fi(e,s),l=!!a[3],u=e._cache.get(s.id),d,f=!1,p;try{if(s.status===`success`&&(d=c.options.shouldReload,typeof d==`function`&&(d=d(xi(e,t,s,c,a[0],i,l))),a[0].signal.aborted&&(p=li)),!p){if(s.status!==`success`)f=!0;else{let t=l||s.preload?c.options.preloadStaleTime??e.options.defaultPreloadStaleTime??3e4:c.options.staleTime??e.options.defaultStaleTime??0;f=!!(s.invalid||d||d===void 0&&Date.now()-s.updatedAt>=t&&(a[5]||s.cause===`enter`||a[2].some(e=>e.routeId===s.routeId&&e.id!==s.id)))}}}catch(n){s.invalid=!0,vi(e,s),p=hi(e,t,c,n,a)}let m=c.options.loader,h=typeof m==`function`,g=h?m:m?.handler,_=!l||c.options.preload!==!1,v=_&&m?e._flights?.get(s.id):void 0;v===s._flight||p?v=void 0:v&&!f&&!l&&d===void 0?f=!0:f||(v=void 0);let y=!(!m||!f||s.status!==`success`||l||a[4]||((h?void 0:m.staleReloadMode)??e.options.defaultStaleReloadMode)===`blocking`),b=f&&_,x=b&&!y&&(s.status!==`success`||!!m),S=n>=o?a[7]:void 0,C=c.lazyFn&&c._lazy!==!0?S:void 0;if(b&&!m&&(s.invalid=!1,s.updatedAt=Date.now()),v&&v[2]++,x){let t=s._flight;s._flight=v,_i(e,s,t)?.abort(),n>=o&&(s.status=`pending`),S?.()}b||(s.isFetching=!1);let w=!p&&x?Si(e,t,s,c,g,i,a).then(t=>(Ci(s,t,l),t[0]===oi&&(m&&!a[0].signal.aborted&&wi(e,s,u),n>=o&&(s.status=`pending`)),t)):Promise.resolve(p??[oi,s.loaderData]),T=(async()=>{try{let e=ri(c,void 0,C);e&&await di(e,a[0].signal)}catch(r){if(!t[1].some((e,t)=>t<=n&&(e.status===`error`||e.status===`notFound`||e._notFound)))return[n,hi(e,t,c,r,a)]}let r=await w;x&&r[0]===oi&&s.status===`pending`&&!a[0].signal.aborted&&(s.status=`success`,S?.())})();if(r.push([n,w,T]),!y)return w.then(e=>Ti(s,e));let E={...s,status:`pending`,preload:!1,_flight:v};s.invalid=!1,s.isFetching=`loader`;let D=Si(e,t,E,c,g,i,a).then(e=>(s.isFetching=!1,Ci(E,e,!1),e));return(t[2]??=[]).push([n,D,T,E]),D.then(e=>Ti(E,e))}async function Di(e,t,n,r,i=0){let a=n?.[1][1],o=a?.routeId?t.findIndex(e=>e.routeId===a.routeId):n?.[0]??t.length-1;o<0&&(o=0);for(let n=o;n>=0;n--){let i=fi(e,t[n]);try{let e=ri(i,!1);e&&await di(e,r)}catch(e){if(e===r&&r.aborted)throw e}if(i.options.notFoundComponent)return n}return a?.routeId?o:i}function Oi(e,t){t[2]&&=(Z(e,t[2].map(e=>e[3])),void 0)}async function ki(e,t,n,r){let i;try{await Promise.all(e.map(e=>e[1].then(async t=>{let a=e[0];if(!(r&&a>=await r)){if(t[0]>=X)throw[a,t];!i&&t[0]!==oi&&(i=[a,t],await Promise.all((n??[]).map(e=>{if(!(e[0]<=a))return e[1].then(t=>{if(t[0]===X)throw[e[0],t]})})))}})))}catch(e){return e}return t??i}function Ai(e,t,n,r,i,a){for(;r[0]===X;){let o=r[1],s=o.options;try{if((s.href||o.headers.has(`Location`))&&(e.resolveRedirect(o),s.reloadDocument)||(s.reloadDocument?i[3]:i[1]>=20))return r;let n=e.buildLocation({...s,_fromLocation:t[0],_includeValidateSearch:!0}),a=n.maskedLocation??n;if(a.external){let t=o.clone();return t.options={...s},t.headers.set(`Location`,a.publicHref),e.resolveRedirect(t),i[3]?[X,t]:[X,t,a]}return[X,o,n]}catch(e){r=a?[si,e]:mi(n,e),a=!0}}return r}async function ji(e,t,n,r,i,a){let o=t[1],s=await i,c=!1,l=o.findIndex(e=>e._notFound),u=t=>t[1][0]===ci?Di(e,o,t,r.signal):t[0],d=l<0?o.length:l;if((s?.[1][0]??0)>=X)d=0;else if(s){d=s[2]??=await u(s);for(let e of n){if(e[0]>=d)break;let t=await e[1];if(t[0]!==oi&&t[0]<X&&!(`loaderData`in o[e[0]])){s=[e[0],t],d=s[2]=await u(s);break}}}for(let e of n){if(e[0]>=d)break;let t=await e[2];if(t){s=t;break}}if((s?.[1][0]??0)>=X){let n=s[1];if(n[0]!==X||n[1].options.reloadDocument||n[2])return Oi(e,t),n;c=!0,s=[0,[si,Error(`Too many redirects`)]]}let f=s?s[2]??await u(s):l;if(f>=0){let i=s?.[1],l=i?.[0],u=o[f],d=i?.[1],p=()=>{i&&(u._notFound=void 0,l===si?u.status=`error`:(d.routeId=u.routeId,u.routeId===e.routeTree.id?(u.status=`success`,u._notFound=!0):u.status=`notFound`),u.error=d,u.isFetching=!1)};p(),i||a?.();let m=fi(e,u);try{await di(i?Promise.resolve().then(()=>ri(m,l===si?`errorComponent`:`notFoundComponent`)):Promise.all([ri(m),ri(m,`notFoundComponent`)]),r.signal)}catch(n){if(n===r.signal&&r.signal.aborted)return Oi(e,t),li}i?c&&(r.abort(),await Promise.all([...n.map(e=>e[1]),...n.map(e=>e[2]),...(t[2]??[]).map(e=>e[1])]),Oi(e,t),Z(e,o),p()):u.status=`success`}return t}async function Mi(e,t,n,r=0,i=t[1].length){let a=t[1];for(let t=r;t<i;t++){let r=a[t],i=fi(e,r).options;if(i.head||i.scripts)try{let t={ssr:e.options.ssr,matches:a,match:r,params:r.params,loaderData:r.loaderData},[o,s]=await di(Promise.all([i.head?.(t),i.scripts?.(t)]),n);r.meta=o?.meta,r.links=o?.links,r.headScripts=o?.scripts,r.styles=o?.styles,r.scripts=s}catch(e){if(e===n&&n.aborted)break;console.error(e)}if(r.status!==`success`||r._notFound)break}return t}async function Ni(e,t,n,r){let i=[t,n],a=r[0].signal,o;try{let t=e.stores.matches.get(),s=n.findIndex(e=>e._notFound);if(e.options.notFoundMode!==`root`&&s>=0){let t=await Di(e,n,void 0,a,s);n[s]._notFound=void 0,n[t]._notFound=!0,s=t}let c=s<0?n.length:s+1,l=0;for(;l<c&&l!==s;){let e=n[l],i=r[2][l],a=t[l];if(i?.id!==e.id||i.status!==`success`||e.preload||a?.id!==e.id||a.status!==`success`||(l++,i._notFound||a._notFound))break}let u=[],d=r[6]??0,f=d?Promise.resolve(n[d-1]):void 0,p=()=>{for(let t=d;t<c&&!a.aborted;t++)f=Ei(e,i,t,u,f,r,l)},m=await gi(e,i,r,c,p,l);if(m){if(r[4]=!0,c=m[0],m[1][0]===ci){let t=await Di(e,n,m,a);m[2]=t,c=Math.min(c,t+1)}else m[1][0]>=X&&(c=0);p()}if(!a.aborted&&!r[3]){let t=[];for(let[n,r]of e._flights??[])r[2]||(e._flights.delete(n),t.push(r[1]));for(let e of t)e.abort()}let h=ji(e,i,u,r[0],ki(u,m,i[2]),r[7]);i[2]?.length&&(i[3]=ki(i[2],void 0,void 0,h.then(e=>ui(e)?0:ii(n).length,()=>0))),o=await h}catch(t){if(Oi(e,i),t===a&&a.aborted)return li;throw t}return ui(o)?o:Mi(e,o,a,r[6]===n.length?r[6]:0)}function Pi(e,t){if(e._tx!==t)return;let n=t[3],r=e.stores.matches.get(),i=e._pending;for(let a=0;a<n.length;a++){let o=n[a],s=o.status===`success`&&!o._notFound,c=r[a]?.id===o.id&&r[a]?.status===`pending`;if(s&&!c)continue;let l=fi(e,o),u=s||o.invalid?0:l.options.pendingMs??e.options.defaultPendingMs,d=l.options.pendingComponent??e.options.defaultPendingComponent;if(!d||typeof u!=`number`||u===1/0){i&&(i[0]=t,i[2]=0,i[4]=!0);return}let f=l.options.pendingMinMs??e.options.defaultPendingMinMs??0,p=!1;if(i?.[1]===o.id?(p=i[0]!==t,i[0]=t):(clearTimeout(i?.[3]),e._pending=i=void 0),i||(e._pending=i=[t,o.id,c?Date.now()+f:t[4]+u,void 0,c||void 0,d]),i[4]&&!p&&i[5]===d)return;if(i[5]=d,!i[4]){clearTimeout(i[3]);let n=i[2]-Date.now();if(n>0){i[3]=setTimeout(()=>Pi(e,t),n);return}i[2]=0}let m=n.map(e=>({...e,_flight:void 0}));m[a].status=`pending`;let h=i[4]=e.startTransition(()=>e.stores.setMatches(m),m).then(t=>(t&&e._pending===i&&i[4]===h&&!i[2]&&(i[2]=Date.now()+f),t));return}}function Fi(e,t){let n=e._pending;e._tx!==t&&e._tx?.[3].some(e=>e.id===n?.[1])||(clearTimeout(n?.[3]),e._pending=void 0)}async function Ii(e,t){let n=e._pending;if(!n)return;clearTimeout(n[3]);let r=n[2]-Date.now();if(!n[4]||r<=0||!ii(t[3]).some(e=>e.id===n[1]))return;let i;try{await di(new Promise(e=>{i=setTimeout(e,r)}),t[0].signal)}catch{}clearTimeout(i)}function Li(e,t){e._committed=t,e.stores.setMatches(t)}function Ri(e,t,n,r){let i=e._committed,a=e._lifecycleEnd,o=e._cache;for(let e of n)e.preload=!1,r&&(e._assetEnd=void 0);let s=ii(n).length,c=new Map;{let t=Date.now(),r=new Set;for(let e=0;e<n.length;e++){let t=n[e];(e<s||t.status===`success`)&&r.add(t.id)}for(let n of[...i,...o.values()]){if(n.status!==`success`||r.has(n.id))continue;let i=fi(e,n);!i.options.loader||t-n.updatedAt>=(n.preload?i.options.preloadGcTime??e.options.defaultPreloadGcTime??3e5:i.options.gcTime??e.options.defaultGcTime??3e5)||c.set(n.id,o.get(n.id)===n?n:{...n,_flight:void 0,isFetching:!1,context:{}})}}t[3]=[],e._cache=c;let l=e._lifecycleEnd=Vr(n);Li(e,n),Z(e,[...o.values(),...i].filter(e=>e._flight&&c.get(e.id)!==e),n),Hr(e,i,n,a,l,t)}async function zi(e,t){let n=e._tx;for(;n&&n!==t;)t=n,await n[5],n=e._tx}function Bi(e,t,n){let r=n[1].options,i=n[2];if(!i)return e.navigate({...r,replace:!0,ignoreBlocker:!0});if(r.reloadDocument)return e.navigate({href:(i.maskedLocation??i).publicHref,reloadDocument:!0,replace:!0,ignoreBlocker:!0});i._redirects=t[1]+1,e._pendingLocation=i;let a=e.commitLocation({...i,viewTransition:r.viewTransition,replace:!0,resetScroll:r.resetScroll,hashScrollIntoView:r.hashScrollIntoView,ignoreBlocker:!0});return queueMicrotask(()=>{e._pendingLocation===i&&(e._pendingLocation=void 0)}),a}async function Vi(e,t,n,r,i){let a=n.map(e=>({...e}));yi(a);for(let t of r)vi(e,a[t[0]]),a[t[0]]=t[3];let o=[t[2],a],s;try{s=await ji(e,o,r,t[0],i)}catch(t){throw Z(e,a),t}if(ui(s))Z(e,a),s[0]===X&&e._tx===t&&e._committed===n&&await Bi(e,t,s);else if(await Mi(e,s,t[0].signal),e._tx!==t||e._committed!==n)Z(e,a);else{for(let t of a){let n=e._cache.get(t.id);n?._flight&&n._flight===t._flight&&(e._cache.delete(t.id),vi(e,n))}Li(e,a),Z(e,n,a)}}async function Hi(e,t,n,r,i,a){let o=await Ni(e,t[2],t[3],[t[0],t[1],e._committed,void 0,i,n,a,r]);if(ui(o)){let n=o[0]===X&&e._tx===t;if((!n||o[1].options.reloadDocument)&&Fi(e,t),Z(e,t[3]),t[3]=[],!n)return;if(e._tx!==t){Fi(e,t);return}await Bi(e,t,o);return}let s=o[1];if(e._tx===t&&await Ii(e,t),e._tx!==t){Fi(e,t),Z(e,s),Oi(e,o);return}let c=t[2],l=zr(c,e.stores.resolvedLocation.get()),u=o[2];await e.startViewTransition(async()=>{if(e._tx===t&&await Ii(e,t),e._tx!==t){Fi(e,t),Z(e,s),Oi(e,o);return}let n=await e.startTransition(()=>{Fi(e,t),Ri(e,t,s,a),e._tx===t&&(e.emit({type:`onLoad`,...l}),e._tx===t&&e.emit({type:`onBeforeRouteMount`,...l}))},s);e._tx===t?(u?.length&&Vi(e,t,s,u,o[3]).catch(console.error),e.batch(()=>{e.stores.resolvedLocation.set(c),e.stores.status.set(`idle`),e._tx===t&&e.emit({type:`onResolved`,...l}),n&&e._tx===t&&e.emit({type:`onRendered`,...l})}),e._tx===t&&(e._commitPromise?.resolve(),e._commitPromise=void 0)):Oi(e,o)})}async function Ui(e,t){let n=e._tx,r=e.stores.resolvedLocation.get(),i=r??e.stores.location.get(),a=e.latestLocation,o=e._pendingLocation,s=o?.href===a.href?o._redirects??0:0,c=e._handoff,l=c?.[0](),u=new AbortController,d=e._preflight;if(e._preflight=u,l||c?.[1](),d?.abort(),!u.signal.aborted){let t=zr(a,r);e.emit({type:`onBeforeNavigate`,...t}),u.signal.aborted||e.emit({type:`onBeforeLoad`,...t})}if(u.signal.aborted){await zi(e,n);return}let f=i.href===a.href,p=u,m=e.matchRoutes(a,{_controller:u});yi(m);let h=l?c[1](m):void 0;if(h?p=l:l?.abort(),u.signal.aborted){Z(e,m),await zi(e,n);return}e._preflight=void 0;let g,_=()=>Hi(e,y,f,()=>Pi(e,y),t?.sync,h),v=t?.sync?new Promise(e=>g=e):Promise.resolve().then(_),y=[p,s,a,m,Date.now(),v.then(()=>zi(e,y))];if(e._tx=y,n){for(let t of e.stores.matches.get()){if(e._tx!==y)break;t.isFetching&&bi(e,t,!1)}n[0].abort(),Z(e,n[3],y[3],!0)}e._tx===y?(e.batch(()=>{e.stores.status.set(`pending`),e.stores.location.set(a)}),(h||!e._committed.length&&m[0]?.status!==`success`&&!m.some(e=>e._notFound))&&Pi(e,y),g?.(_()),await y[5]):(Z(e,y[3]),y[3]=[],g?.(),await zi(e,y))}async function Wi(e,t){let n=e.buildLocation(t);for(let t=0;;t++){let r=e._committed,i=new AbortController,a,o,s;try{try{a=e.matchRoutes(n,{_controller:i}),yi(a),o=(e._preloads??=new Map).set(i,a),s=await Ni(e,n,a,[i,t,r,!0])}finally{o&&(o=o.delete(i),Z(e,a)),i.abort()}if(!ui(s))return s[1];if(!o||s.length<3)return;n=s[2]}catch(e){On(e)||console.error(e);return}}}var Gi=`Error preloading route! ☝️`,Ki=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e,this._branch=void 0;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=Xn:this.parentRoute||_n();let r=n?Xn:t?.path;r&&r!==`/`&&(r=yn(r));let i=t?.id||r,a=n?Xn:vn((this.parentRoute.id===`__root__`?``:this.parentRoute.id)+`/`+(i??``));r===`__root__`&&(r=`/`);let o=a===`__root__`?`/`:r===void 0?this.parentRoute.fullPath:vn(this.parentRoute.fullPath+`/`+r);this._path=r,this._id=a,this._fullPath=o,this._to=bn(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>Zn({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},qi=class extends Ki{constructor(e){super(e)}},Q=i(),Ji=class extends Y.Component{constructor(...e){super(...e),this.state={error:0},this.reset=()=>{this.setState({error:0})}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:0}:{resetKey:n}}static getDerivedStateFromError(e){return{error:[e]}}componentDidCatch(e,t){this.props.onCatch?.(e,t)}render(){let e=this.state.error;return e?Y.createElement(this.props.errorComponent??Yi,{error:e[0],reset:this.reset}):this.props.children}};function Yi({error:e}){let[t,n]=Y.useState(!1);return(0,Q.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,Q.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,Q.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,Q.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,Q.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e?.message?(0,Q.jsx)(`code`,{children:e.message}):null})}):null]})}var Xi=()=>!0,Zi=()=>!1;function Qi({children:e,fallback:t=null}){return(0,Q.jsx)(Y.Fragment,{children:$i()?e:t})}function $i(e=!0){return Y.useSyncExternalStore(ea,Xi,e?Zi:Xi)}function ea(){return()=>{}}function ta(e,t){let n=e.stores.location,r=new Set,i,a,o=n=>{ai(e,t,n)||(i=n,r.forEach(e=>e()))};return[()=>i??n.get(),e=>(r.size||(i=n.get(),a=n.subscribe(o).unsubscribe),r.add(e),()=>{r.delete(e),r.size||(a(),i=void 0)})]}var na=Y.createContext(void 0),ra=Y.createContext(void 0);function ia({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0)n=e.nextSub;else{for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}}while(1)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(1)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function aa(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var oa=[],sa=0,{link:ca,unlink:la,propagate:ua,checkDirty:da,shallowPropagate:fa}=ia({update(e){return e._update()},notify(e){oa[ma++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,va(e))}}),pa=0,ma=0,ha,ga=0;function _a(e){try{++ga,e()}finally{--ga||ya()}}function va(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=la(n,e)}function ya(){if(!(ga>0)){for(;pa<ma;){let e=oa[pa];oa[pa++]=void 0,e.notify()}pa=0,ma=0}}function ba(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return ha!==void 0&&ca(i,ha,sa),i._snapshot},subscribe(e){let t=aa(e),n={current:!1},r=xa(()=>{i.get(),n.current?(ha=void 0,t.next?.(i._snapshot)):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=ha,o=t?.compare??Object.is;if(n)ha=i,++sa,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{ha=a,n&&(i.flags&=-5),va(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&da(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&fa(e)}}else e&32&&(i.flags=e&-33);return ha!==void 0&&ca(i,ha,sa),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(ua(e),fa(e),ya())}},i}function xa(e){let t=()=>{let t=ha;ha=n,++sa,n.depsTail=void 0,n.flags=6;try{return e()}finally{ha=t,n.flags&=-5,va(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&da(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,va(this)}};return t(),n}var Sa=t((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Ca=t(((e,t)=>{t.exports=Sa()})),wa=t((e=>{var t=r(),n=Ca();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Ta=t(((e,t)=>{t.exports=wa()}))();function Ea(e,t){return e===t}function Da(e,t=e=>e,n){let r=n?.compare??Ea,i=(0,Y.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,Y.useCallback)(()=>e.get(),[e]);return(0,Ta.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var Oa={};function ka(e,t){let n=Y.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=rn(n.current,i):i}}function Aa(e){let t=K(),n=Y.useContext(e.from?ra:na),r=e.from??n,i=t.stores.getMatchStore(r),a=ka(e,t),o=Da(i,e=>e?a(e):Oa);if(o!==Oa)return o;(e.shouldThrow??!0)&&_n()}function ja(e){return Aa({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function Ma(e){let{select:t,...n}=e;return Aa({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function Na(e){return Aa({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function Pa(e){return Aa({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function Fa(e){let t=K();return Y.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function Ia(e){return Aa({...e,select:t=>e.select?e.select(t.context):t.context})}function La(...e){let t=Y.useRef(e),n=t.current;return e.forEach((e,t)=>{on(n[t],e,!1,!0)||(n[t]=e)}),t.current}function Ra(e,t){e.preloadRoute(t).catch(e=>{console.warn(e),console.warn(Gi)})}function za(e,t){let n=typeof e==`string`&&dn(e);if(n)return t.has(n)?e:null}function Ba(e,t,n,r){let i=Sn(e.pathname,r),a=Sn(t.pathname,r);return(n?.exact?i!==a:!i.startsWith(a)||i.length!==a.length&&i[a.length]!==`/`)||(n?.includeSearch??!0)&&!on(e.search,t.search,!n?.exact,n?.explicitUndefined)?!1:!n?.includeHash||e.hash===t.hash}function Va(e,t,n){let r=K(),i=Y.useRef(null),a=Y.useCallback(e=>{if(i.current=e,typeof t==`function`)return t(e);t&&(t.current=e)},[t]),{activeOptions:o,to:s,preload:c,preloadDelay:l,disabled:u,target:d,onClick:f,onBlur:p,onFocus:m,onMouseEnter:h,onMouseLeave:g,onTouchStart:_}=e,[v,y,b]=La(e.search,e.params,o),x=Y.useContext(na),S=(r.stores._linkScopes??={})[x]??=ta(r,x),[C,w,T]=Y.useMemo(()=>{let t=za(s,r.protocolAllowlist);if(t!==void 0){let n=[t??void 0];return[e,()=>n]}let n={...e},i,a,o,c=()=>{let e=S[0]();if(e!==i){n._fromLocation=e;let t=r.buildLocation(n),o=Ya(t,r,u),s=u||o&&!dn(o)?Ba(e,t,b,r.basepath):void 0;a&&a[0]===o&&a[1]===s||(a=[o,s]),i=e}return a};return[n,c,b?.includeHash&&(()=>{let e=c();return e[1]?o??=[e[0],!1]:e})]},[r,S,e.from,e.hash,e.href,s,v,y,e.state,e.mask,e.unsafeRelative,b,u]),[E,D]=Y.useSyncExternalStore(S[1],w,T||w),O=D===void 0&&E,k=u||E===void 0,A=Y.useRef(!1),j=e.reloadDocument||O||k?!1:c??r.options.defaultPreload,ee=l??r.options.defaultPreloadDelay??0,M=Y.useCallback(e=>{let t=e?.isIntersecting;t??j===`intent`?ee?i.t??=setTimeout(()=>{i.t=void 0,Ra(r,C)},ee):Ra(r,C):t===!1&&qa(i)},[r,C,i,j,ee]);Y.useEffect(()=>{if(!j)return;j===`render`&&!A.current&&(A.current=!0,Ra(r,C));let e=!0,t;return j===`viewport`&&i.current&&typeof IntersectionObserver==`function`&&(t=new IntersectionObserver(t=>{e&&M(t.pop())},{rootMargin:`100px`}),t.observe(i.current)),()=>{e=!1,t?.disconnect(),qa(i)}},[r,C,j,M,i]);let N=Ga(e,n);if(N.ref=t?a:i,O)return N.href=O,N;let te=t=>{let n=d??t.currentTarget.getAttribute(`target`);k||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.defaultPrevented||n&&n!==`_self`||t.button!==0||(t.preventDefault(),qa(i),r.navigate({...e,_fromLocation:C._fromLocation}))},P=()=>{j===`intent`&&Ra(r,C)},ne=()=>{j===`intent`&&qa(i)};return N.onClick=Ja(f,te),N.onBlur=Ja(p,ne),N.onFocus=Ja(m,M),N.onMouseEnter=Ja(h,M),N.onMouseLeave=Ja(g,ne),N.onTouchStart=Ja(_,P),Ka(N,e,D,E,k,n)}var Ha={},Ua={className:`active`},Wa=new Set([`to`,`params`,`search`,`hash`,`state`,`mask`,`from`,`unsafeRelative`,`reloadDocument`,`preload`,`preloadDelay`,`preloadIntentProximity`,`hashScrollIntoView`,`replace`,`startTransition`,`resetScroll`,`viewTransition`,`ignoreBlocker`,`activeProps`,`inactiveProps`,`activeOptions`,`_asChild`]);function Ga(e,t){let n={};for(let r in e)Wa.has(r)||r===`type`&&t!==void 0||r===`disabled`&&t===`a`||(n[r]=e[r]);return n}function Ka(e,t,n,r,i,a){let{activeProps:o,inactiveProps:s,className:c,style:l,target:u}=t,d=Qt(n?o:s,{})??(n?Ua:Ha);Object.assign(e,d),e.href=r,a!==`a`&&(e.disabled=i),e.target=u;let f=d.style;(l||f)&&(e.style=l&&f?{...l,...f}:l||f);let p=d.className;return(c||p)&&(e.className=c?p?`${c} ${p}`:c:p),i&&(e.role=`link`,e[`aria-disabled`]=!0),n&&(e[`data-status`]=`active`,e[`aria-current`]=`page`),e}var qa=e=>{clearTimeout(e.t),e.t=void 0},Ja=(e,t)=>e?n=>n.defaultPrevented||(e(n),n.defaultPrevented||t(n)):t;function Ya(e,t,n){if(n)return;let r=e.maskedLocation??e,i=r.external?r.publicHref:t.history.createHref(r.publicHref)||`/`;if(!r.external&&i===r.publicHref||!pn(i,t.protocolAllowlist))return i}var $=Y.memo(Y.forwardRef((e,t)=>{let n=e._asChild||`a`,r=Va(e,t,n),i=typeof e.children==`function`?e.children({isActive:r[`data-status`]===`active`}):e.children;return Y.createElement(n,r,i)}),Xa);function Xa(e,t){let n=0;for(let r in t)if(n++,e[r]!==t[r]&&(!Wa.has(r)||!on(e[r],t[r],!1,!0)))return!1;for(let t in e)n--;return n===0}var Za=class extends Ki{constructor(e){super(e),this.useMatch=e=>Aa({...e,from:this.id}),this.useRouteContext=e=>Ia({...e,from:this.id}),this.useSearch=e=>Pa({...e,from:this.id}),this.useParams=e=>Na({...e,from:this.id}),this.useLoaderDeps=e=>Ma({...e,from:this.id}),this.useLoaderData=e=>ja({...e,from:this.id}),this.useNavigate=()=>Fa({from:this.fullPath}),this.Link=Y.forwardRef((e,t)=>(0,Q.jsx)($,{ref:t,from:this.fullPath,...e}))}};function Qa(e){return new Za(e)}var $a=class extends qi{constructor(e){super(e),this.useMatch=e=>Aa({...e,from:this.id}),this.useRouteContext=e=>Ia({...e,from:this.id}),this.useSearch=e=>Pa({...e,from:this.id}),this.useParams=e=>Na({...e,from:this.id}),this.useLoaderDeps=e=>Ma({...e,from:this.id}),this.useLoaderData=e=>ja({...e,from:this.id}),this.useNavigate=()=>Fa({from:this.fullPath}),this.Link=Y.forwardRef((e,t)=>(0,Q.jsx)($,{ref:t,from:this.fullPath,...e}))}};function eo(e){return new $a(e)}function to(e){let t=K(),n=`not-found-${Da(t.stores.location,e=>e.pathname)}-${Da(t.stores.status)}`;return(0,Q.jsx)(Ji,{getResetKey:()=>n,onCatch:(t,n)=>{if(On(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(On(t))return e.fallback?.(t);throw t},children:e.children})}function no(){return(0,Q.jsx)(`p`,{children:`Not Found`})}function ro(e,t,n){return t.options.notFoundComponent?(0,Q.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,Q.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,Q.jsx)(no,{})}function io(e,t){let n=t?.options.pendingComponent??e.options.defaultPendingComponent;return n?(0,Q.jsx)(n,{}):null}var ao=(e,t)=>e[0]===t[0]&&e[1]===t[1],oo=(e,t,n)=>!t.isRoot||t.options.shellComponent||t.options.wrapInSuspense||n===!1||n===`data-only`||!e.ssr,so=Y.memo(function({routeId:e}){let t=K();return co(t,Da(t.stores.getMatchStore(e)))});function co(e,t){let n=e.routesById[t.routeId],r=io(e,n),i=n.options.errorComponent??e.options.defaultErrorComponent,a=n.options.onCatch??e.options.defaultOnCatch,o=n.isRoot?n.options.notFoundComponent??e.options.notFoundRoute?.options.component:n.options.notFoundComponent,s=t.ssr===!1||t.ssr===`data-only`,c=oo(e,n,t.ssr)&&(n.options.wrapInSuspense??r??(n.options.errorComponent?.preload||s)),l=(0,Q.jsx)(lo,{match:t});s&&(l=(0,Q.jsx)(Qi,{fallback:r,children:l})),o&&(l=(0,Q.jsx)(to,{fallback:e=>{if(e.routeId??=t.routeId,e.routeId!==t.routeId)throw e;return Y.createElement(o,e)},children:l})),i&&(l=(0,Q.jsx)(Ji,{getResetKey:()=>t,errorComponent:i,onCatch:(e,n)=>{if(On(e))throw e.routeId??=t.routeId,e;a?.(e,n)},children:l})),c&&(l=(0,Q.jsx)(Y.Suspense,{fallback:r,children:l}));let u=n.isRoot&&n.options.shellComponent;return u?(0,Q.jsx)(na.Provider,{value:t.routeId,children:(0,Q.jsxs)(u,{children:[l,null]})}):(0,Q.jsxs)(na.Provider,{value:t.routeId,children:[l,null]})}var lo=Y.memo(function({match:e}){let t=K(),n=e.routeId,r=t.routesById[n],i=Y.useMemo(()=>{let i=(r.options.remountDeps??t.options.defaultRemountDeps)?.({routeId:n,loaderDeps:e.loaderDeps,params:e._strictParams,search:e._strictSearch});return i?JSON.stringify(i):void 0},[n,e.loaderDeps,e._strictParams,e._strictSearch,r.options.remountDeps,t.options.defaultRemountDeps]),a=Y.useMemo(()=>{let e=r.options.component??t.options.defaultComponent;return e?(0,Q.jsx)(e,{},i):(0,Q.jsx)(uo,{})},[i,r.options.component,t.options.defaultComponent]);if(e.status===`pending`){if(t.ssr&&!oo(t,r,e.ssr))return a;if(t._tx)throw t._tx[5];return io(t,r)}if(e.status===`notFound`)return ro(t,r,e.error);if(e.status===`error`)throw e.error;return a}),uo=Y.memo(function(){let e=K(),t=Y.useContext(na),n,r,i;{let a=e.stores.getMatchStore(t);[n,r]=Da(a,e=>[!!e._notFound,e.error],{compare:ao}),i=Da(e.stores.ids,e=>e[e.indexOf(t)+1])}if(n)return ro(e,e.routesById[t],r);if(!i)return null;let a=(0,Q.jsx)(so,{routeId:i});return t===`__root__`?(0,Q.jsx)(Y.Suspense,{fallback:io(e),children:a}):a});function fo(e,t){let n=e[1];e.length=0,n?.(t)}function po({t:e}){let t=K(),n=t._rendered??=[];return t.startTransition=(r,i)=>new Promise(a=>{fo(n,!1),n.push(i,a),e(t),Y.startTransition(r)}),Xt(()=>{let e=t.history.subscribe(t.load);t.updateLatestLocation();let r=t.latestLocation,i=t.buildLocation({to:r.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});if(bn(r.publicHref)!==bn(i.publicHref))return t.commitLocation({...i,replace:!0,ignoreBlocker:!0}),e;let a=t.stores.resolvedLocation.get();return a?.href===r.href&&a.state.__TSR_key===r.state.__TSR_key?n.push(t.stores.matches.get(),e=>{e&&t.emit({type:`onRendered`,...zr(a,a)})}):t._tx||t.load({sync:!0}).catch(console.error),e},[t,t.history]),null}function mo(){let e=K(),t=e.routesById[Xn],n=io(e,t),r=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(po,{t:Y.useState()[1]}),e.ssr?(0,Q.jsx)(ho,{}):(0,Q.jsx)(Y.Suspense,{fallback:n,children:(0,Q.jsx)(ho,{})})]});return e.options.InnerWrap?(0,Q.jsx)(e.options.InnerWrap,{children:r}):r}function ho(){let e=K(),t=e._rendered,n=Da(e.stores.matches,e=>t[0]??e),r=n[0],i=r?.routeId;Xt(()=>{t[0]===n&&fo(t,!0)},[t,n]);let a=i?(0,Q.jsx)(so,{routeId:i}):null;return e.options.disableGlobalCatchBoundary?a:(0,Q.jsx)(Ji,{getResetKey:()=>r,onCatch:void 0,children:a})}var go=e=>({createMutableStore:ba,createReadonlyStore:ba,batch:_a}),_o=e=>new vo(e),vo=class extends Ur{constructor(e){super(e,go)}};function yo({router:e,children:t,...n}){en(n)&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,Q.jsx)(Ge.Provider,{value:e,children:t});return e.options.Wrap?(0,Q.jsx)(e.options.Wrap,{children:r}):r}function bo({router:e,...t}){return(0,Q.jsx)(yo,{router:e,...t,children:(0,Q.jsx)(mo,{})})}function xo(e){let t=K({warn:e?.router===void 0}),n=e?.router||t;return Da(n.stores.__store,ka(e,n))}function So(e){let t=K();return Da(t.stores.location,ka(e,t))}var Co={name:`alarm-clock`,size:24,node:[[`circle`,{cx:`12`,cy:`13`,r:`8`,key:`3y4lt7`}],[`path`,{d:`M12 9v4l2 2`,key:`1c63tq`}],[`path`,{d:`M5 3 2 6`,key:`18tl5t`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.38 18.7 4 21`,key:`17xu3x`}],[`path`,{d:`M17.64 18.67 20 21`,key:`kv2oe2`}]]};Co.node;var wo=q(Co),To={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};To.node;var Eo=q(To),Do={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};Do.node;var Oo=q(Do),ko={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};ko.node;var Ao=q(ko),jo={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};jo.node;var Mo=q(jo),No={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};No.node;var Po=q(No),Fo={name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]};Fo.node;var Io=q(Fo),Lo={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};Lo.node;var Ro=q(Lo),zo={name:`circle-dot`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};zo.node;var Bo=q(zo),Vo={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};Vo.node;var Ho=q(Vo),Uo={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};Uo.node;var Wo=q(Uo),Go={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};Go.node;var Ko=q(Go),qo={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};qo.node;var Jo=q(qo),Yo={name:`file-diff`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]};Yo.node;var Xo=q(Yo),Zo={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};Zo.node;var Qo=q(Zo),$o={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};$o.node;var es=q($o),ts={name:`git-commit-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]],aliases:[`git-commit`]};ts.node;var ns=q(ts),rs={name:`git-pull-request`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]};rs.node;var is=q(rs),as={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};as.node;var os=q(as),ss={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};ss.node;var cs=q(ss),ls={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};ls.node;var us=q(ls),ds={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};ds.node;var fs=q(ds),ps={name:`monitor-smartphone`,size:24,node:[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]};ps.node;var ms=q(ps),hs={name:`panel-left-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]],aliases:[`sidebar-close`]};hs.node;var gs=q(hs),_s={name:`panel-left-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]],aliases:[`sidebar-open`]};_s.node;var vs=q(_s),ys={name:`qr-code`,size:24,node:[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]};ys.node;var bs=q(ys),xs={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};xs.node;var Ss=q(xs),Cs={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};Cs.node;var ws=q(Cs),Ts={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Ts.node;var Es=q(Ts),Ds={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};Ds.node;var Os=q(Ds),ks={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};ks.node;var As=q(ks),js={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};js.node;var Ms=q(js),Ns={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Ns.node;var Ps=q(Ns),Fs={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Fs.node;var Is=q(Fs),Ls={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};Ls.node;var Rs=q(Ls),zs={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};zs.node;var Bs=q(zs),Vs=e(n(),1),Hs={neutral:Ie,success:Ro,info:Je,danger:Io},Us={neutral:`text-(--ochre-400)`,success:`text-(--green-400)`,info:`text-(--blue-400)`,danger:`text-(--red-400)`};function Ws({title:e,description:t,tone:n=`neutral`,onClose:r}){return(0,Q.jsxs)(`div`,{className:`flex min-w-[min(260px,100%)] max-w-[380px] animate-[em-sheet-up_var(--dur-3)_var(--ease-out)] items-start gap-2.5 rounded-lg bg-inverse py-2.5 pr-2 pl-3 font-sans text-13 font-medium leading-(--lh-snug) text-fg-inverse shadow-3`,children:[(0,Q.jsx)(j,{icon:Hs[n],className:U(`mt-px`,Us[n])}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 pt-px wrap-break-word`,children:[(0,Q.jsx)(`span`,{children:e}),t&&(0,Q.jsx)(`span`,{className:`font-sans text-12 font-normal leading-(--lh-snug) opacity-75`,children:t})]}),(0,Q.jsx)(w,{label:`Dismiss`,icon:le,size:`sm`,onClick:r,className:`size-6 text-inherit opacity-70 [@media(pointer:coarse)]:size-10`})]})}var Gs=(0,Y.createContext)(null);function Ks({children:e}){let[t,n]=(0,Y.useState)(null),r=(0,Y.useCallback)(e=>n({...e}),[]),i=(0,Y.useCallback)(()=>n(null),[]),a=(0,Y.useMemo)(()=>({show:r}),[r]);return(0,Y.useEffect)(()=>{if(!t)return;let e=window.setTimeout(i,3200);return()=>window.clearTimeout(e)},[t,i]),(0,Q.jsxs)(Gs.Provider,{value:a,children:[e,(0,Vs.createPortal)((0,Q.jsx)(`div`,{"data-emend-toast":!0,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-auto fixed inset-x-4 bottom-[calc(var(--sendbar-h)+var(--tabbar-h)+var(--space-4)+env(safe-area-inset-bottom))] z-(--z-toast) flex justify-center md:bottom-[calc(var(--sendbar-h)+var(--space-4)+env(safe-area-inset-bottom))]`,children:t&&(0,Q.jsx)(Ws,{...t,onClose:i})}),document.body)]})}function qs(){let e=(0,Y.useContext)(Gs);if(!e)throw Error(`useToast requires a ToastProvider`);return e}function Js(e){if(!e||typeof e!=`object`||!(`kind`in e))return null;if((e.kind===`open`||e.kind===`ping`)&&Object.keys(e).length===1)return e.kind;if(e.kind!==`event`||!(`type`in e)||!(`data`in e)||typeof e.data!=`string`)return null;try{return k.parse({...JSON.parse(e.data),type:e.type})}catch{return null}}var Ys=5e3,Xs=1e3,Zs=1e4,Qs=3e4;function $s(e){let t,n=!1,r=1e3,i,a,o,s=!1,c=0,l,u=()=>{n||i!==void 0||(i=setTimeout(()=>{i=void 0,p()},r),r=Math.min(r*2,6e4))},d=()=>{clearTimeout(a),a=setTimeout(()=>h(!0),Rt)},f=async e=>{if(n||t!==e||o||i!==void 0)return;let r=new AbortController;o=r;try{await m(`/api/v1/events`,r.signal)}catch(t){!r.signal.aborted&&t instanceof Ft&&(t.status===401||t.status===403)&&(n=!0,e.close())}finally{o===r&&(o=void 0),!n&&t===e&&!r.signal.aborted&&(s?(s=!1,p()):u())}},p=()=>{if(n)return;clearTimeout(a),t?.close(),c=Date.now();let o;try{o=new EventSource(`/api/v1/events`)}catch{t=void 0,u();return}t=o,o.addEventListener(`error`,()=>{o.readyState===EventSource.CLOSED&&(clearTimeout(a),f(o))}),o.addEventListener(`open`,()=>{n||t!==o||(clearTimeout(i),i=void 0,r=1e3,d(),e({kind:`open`}))}),o.addEventListener(fe,()=>{n||t!==o||(d(),e({kind:`ping`}))});for(let r of P.options)o.addEventListener(r,i=>{n||t!==o||(d(),e({kind:`event`,type:r,data:i.data}))})},h=(e=!1)=>{if(!n&&!(!e&&Date.now()-c<Xs)){if(o){if(!e){s=!0;return}o.abort(),o=void 0,s=!1}clearTimeout(i),i=void 0,p()}},g=()=>{n||t&&t.readyState!==EventSource.CLOSED||(o?s=!0:(clearTimeout(i),i=void 0,p()))},_=()=>{t&&t.readyState!==EventSource.CLOSED?h():g()},v=()=>{if(document.visibilityState!==`visible`){l??=Date.now();return}let e=l===void 0?0:Date.now()-l;l=void 0,e>Ys?_():g()};return window.addEventListener(`online`,_),window.addEventListener(`pageshow`,_),document.addEventListener(`visibilitychange`,v),p(),{reconnect:()=>!n&&(r=1e3,h(!0),!0),stop:()=>{n=!0,clearTimeout(i),clearTimeout(a),o?.abort(),t?.close(),window.removeEventListener(`online`,_),window.removeEventListener(`pageshow`,_),document.removeEventListener(`visibilitychange`,v)}}}var ec,tc=new Set;function nc(e=3e3){let t=ec;return t?new Promise(n=>{let r=e=>{clearTimeout(a),tc.delete(i),n(e)},i=()=>r(!0),a=setTimeout(()=>r(!1),e);tc.add(i),t()||r(!1)}):Promise.resolve(!1)}function rc(e,t){let n=!1,r=Date.now(),i=r=>{if(n)return;let i=Js(r);if(i===`open`){t();for(let e of[...tc])e()}else i&&i!==`ping`&&e(i)};if(!navigator.locks?.request||typeof BroadcastChannel>`u`){let e=$s(i);return ec=e.reconnect,()=>{ec===e.reconnect&&(ec=void 0),e.stop()}}let a=new BroadcastChannel(`emend-events`);a.addEventListener(`message`,e=>{Js(e.data)&&(r=Date.now()),i(e.data)});let o=new Map,s,c,l=!1,u=e=>{if(n)return;if(e){if(l||s)return;l=!0}else c?.abort();let t=new AbortController,d=!1,f,p=()=>{},m=new Promise(e=>{p=e});o.set(t,p),e||(c=t);let h=e?{steal:!0}:{signal:t.signal};navigator.locks.request(`emend-events`,h,async()=>{n||t.signal.aborted||(d=!0,e&&(l=!1,c?.abort()),(c===t||e)&&(c=void 0),r=Date.now(),f=$s(e=>{r=Date.now(),i(e),a.postMessage(e)}),s=f,await m)}).catch(()=>{e&&(l=!1),!(n||t.signal.aborted)&&(d?(f?.stop(),s===f&&(s=void 0),r=Date.now(),u(!1)):e||(f=$s(i),s=f))}).finally(()=>{o.delete(t),p()})};u(!1);let d=()=>n?!1:s?s.reconnect():l?!0:Date.now()-r<=Qs?!1:(u(!0),!0);ec=d;let f=setInterval(()=>{s||n||document.visibilityState!==`visible`||Date.now()-r<=4e4||(r=Date.now(),u(!0))},Zs),p=()=>{document.visibilityState===`visible`&&(r=Date.now())};return document.addEventListener(`visibilitychange`,p),()=>{n=!0,clearInterval(f),document.removeEventListener(`visibilitychange`,p),ec===d&&(ec=void 0),s?.stop(),a.close();for(let[e,t]of o)e.abort(),t()}}function ic(){let e=null,t=new Set,n=new Set,r=new Set,i=e=>{t=e;for(let e of n)e()},a=e=>{let n=new Set(e.map(({id:e})=>e));[...t].some(e=>n.has(e))&&i(new Set([...t].filter(e=>!n.has(e))))};return{subscribe(e){return n.add(e),()=>{n.delete(e)}},snapshot:()=>t,baseline(t){e??=new Set(t.map(({id:e})=>e))},show(n){if(!e)return;let o=n.filter(({id:t})=>!e?.has(t));if(!o.length)return;for(let{id:t}of o)e.add(t);i(new Set([...t,...o.map(({id:e})=>e)]));let s=setTimeout(()=>{r.delete(s),a(o)},1e3);r.add(s)},hide:a,reset(){for(let e of r)clearTimeout(e);r.clear(),e=null,i(new Set)}}}var ac=(0,Y.createContext)(null);function oc({children:e,enabled:t}){let n=se(),[r]=(0,Y.useState)(ic);return(0,Y.useEffect)(()=>{if(!t)return;let e=n.getQueryCache().subscribe(e=>{if(e.type!==`updated`||e.action.type!==`success`||e.action.manual||e.query.queryKey.length!==1||e.query.queryKey[0]!==`inbox`)return;let t=n.getQueryData([`inbox`]);t&&r.baseline(t.items)});return()=>{e(),r.reset()}},[n,t,r]),(0,Q.jsx)(ac.Provider,{value:r,children:e})}function sc(e){let t=(0,Y.useContext)(ac);if(!t)throw Error(`Missing inbox arrivals provider`);let n=(0,Y.useRef)(e),r=(0,Y.useSyncExternalStore)(t.subscribe,t.snapshot);return(0,Y.useEffect)(()=>{n.current=e,t.show(e)},[t,e]),(0,Y.useEffect)(()=>()=>t.hide(n.current),[t]),r}var cc=(0,Y.createContext)(new Map);function lc({children:e,enabled:t=!0}){let n=se(),[r,i]=(0,Y.useState)(()=>new Map);return(0,Y.useEffect)(()=>{if(!t){i(new Map);return}let e=rc(e=>{let{reviewId:t}=e;e.type===`publish`&&i(n=>e.revision>(n.get(t)??0)?new Map(n).set(t,e.revision):n);let r=e.type===`viewed`?[]:[[`inbox`],[`review`,t]];[`thread`,`send`,`claimed`,`confirmed`,`viewed`].includes(e.type)&&r.push([`revision`,t]),Ot(n,r)},()=>{Ot(n,[],{opened:!0})});return()=>{e()}},[n,t]),(0,Q.jsx)(cc.Provider,{value:r,children:(0,Q.jsx)(oc,{enabled:t,children:e})})}function uc(e){return(0,Y.useContext)(cc).get(e)??0}var dc;function fc(e,t){e.defaultPrevented||e.button!==0||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.currentTarget.target&&e.currentTarget.target!==`_self`||(dc={devicesIndex:/^\/devices\/?$/.test(t.pathname)?t.state.__TSR_index:void 0})}function pc(){let e=dc;return dc=void 0,e}var mc=e=>new Promise(t=>setTimeout(t,e));function hc(){let e=se(),[t,n]=(0,Y.useState)(!1),r=(0,Y.useRef)(!1);return{refresh:(0,Y.useCallback)(async()=>{if(!r.current){r.current=!0,n(!0);try{let t=e=>!De(e);if(await nc()){await mc(300);for(let n=0;e.isFetching({predicate:t})>0&&n<1e4;n+=100)await mc(100)}else await e.refetchQueries({type:`active`,predicate:t})}catch{}finally{r.current=!1,n(!1)}}},[e]),busy:t}}function gc(e){return[{heading:`Writeup and docs`},{radioGroup:{label:`Writeup and docs`,segmented:!0,value:String(e.proseSize),onValueChange:e=>{let t=Number(e);(t===15||t===16||t===17||t===18)&&at.update({proseSize:t})},items:[15,16,17,18].map(e=>({value:String(e),label:`${e} px`}))}},{heading:`Code in diffs`},{radioGroup:{label:`Code in diffs`,segmented:!0,value:String(e.codeSize),onValueChange:e=>{let t=Number(e);(t===11||t===12||t===13||t===14)&&at.update({codeSize:t})},items:[11,12,13,14].map(e=>({value:String(e),label:`${e} px`}))}}]}function _c(){let e=Tt(),t=Ke();return e===`phone`?null:(0,Q.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(ut,{label:`Panes`,size:`sm`,value:t.pane[e],options:[{value:`split`,label:`Split`,icon:Fe},{value:`tabs`,label:`Tabs`,icon:Qo}],onChange:n=>{(n===`split`||n===`tabs`)&&at.update({pane:{...t.pane,[e]:n}})}}),(0,Q.jsx)(yt,{label:`Text size`,trigger:(0,Q.jsx)(G,{variant:`ghost`,size:`sm`,icon:Rs,children:`Text`}),items:gc(t)})]})}var vc=(0,Y.createContext)(null);function yc(){let e=(0,Y.useContext)(vc);if(!e)throw Error(`useRequestUpdate needs an AppFrame`);return e}function bc(e){e===`update`?Bt.installUpdate():Bt.reloadNow()}function xc(e){return e.length<2?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function Sc(e){return e.saving||e.sending||e.unstored}function Cc(e){return`Reloading now could lose ${xc([e.saving?`a comment that is still saving`:``,e.sending?`a Send in progress`:``,e.unstored?`text that could not be stored on this device`:``].filter(Boolean))}.`}function wc(e){let[t,n]=(0,Y.useState)(null);function r(e){let t=Ae();Sc(t)?n({action:e,work:t}):bc(e)}function i(e){let t=Ae();Sc(t)&&JSON.stringify(t)!==JSON.stringify(e.work)?n({action:e.action,work:t}):(n(null),bc(e.action))}let a=t?.action===`reload`;return{request:r,dialog:t&&(0,Q.jsx)(_e,{open:!0,returnFocus:e,onOpenChange:e=>{e||n(null)},title:a?`Reload now?`:`Update now?`,description:Cc(t.work),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(G,{"data-autofocus":!0,variant:`ghost`,onClick:()=>n(null),children:`Cancel`}),(0,Q.jsx)(G,{variant:`danger`,onClick:()=>i(t),children:a?`Reload anyway`:`Update anyway`})]})})}}function Tc({isReview:e=!1,children:t,onCommentReview:n}){let r=Tt(),i=Ke(),a=K(),o=qs(),{refresh:s,busy:c}=hc(),l=Ht(),u=(0,Y.useRef)(null),d=wc(u),f=l.state===`available`?[{label:`Update available`,icon:Ko,opensDialog:!0,onSelect:()=>d.request(`update`)}]:l.state===`reload-needed`?[{label:`Reload to finish the update`,icon:ws,opensDialog:!0,onSelect:()=>d.request(`reload`)}]:[],p={label:`Refresh`,icon:Ss,disabled:c,onSelect:()=>void s()};async function m(){try{await navigator.clipboard.writeText(location.origin+location.pathname+location.search),o.show({title:`Link copied`})}catch{o.show({title:`Could not copy the link. Copy it from the address bar.`,tone:`danger`})}}let h={label:`Devices`,icon:Ps,asChild:!0,children:(0,Q.jsx)($,{to:`/devices`,children:`Devices`})},g=e?[...f,p,{label:`Copy link`,icon:cs,onSelect:()=>void m()},...n?[{label:`Comment on review`,icon:ht,onSelect:n}]:[],{separator:!0},...gc(i),{heading:`Long lines`},{radioGroup:{label:`Long lines`,segmented:!0,value:i.wrap?`wrap`:`scroll`,onValueChange:e=>{(e===`scroll`||e===`wrap`)&&at.update({wrap:e===`wrap`})},items:[{value:`scroll`,label:`Scroll`},{value:`wrap`,label:`Wrap`}]}},{separator:!0},{label:`Inbox`,icon:os,asChild:!0,children:(0,Q.jsx)($,{to:`/`,children:`Inbox`})},h]:[...f,p,h,{label:`Pair a device`,icon:bs,asChild:!0,children:(0,Q.jsx)($,{to:`/devices/pair`,onClick:e=>fc(e,a.history.location),children:`Pair a device`})}];return(0,Q.jsxs)(`div`,{className:`em-app flex h-dvh min-h-0 flex-col bg-app`,style:{"--reader-prose-size":`${i.proseSize}px`,"--reader-code-size":`${i.codeSize}px`},children:[(0,Q.jsxs)(`header`,{className:U(`flex shrink-0 items-center justify-between border-b border-line-1 bg-app pr-2 pl-4`,r===`phone`?`h-[calc(var(--topbar-h)+env(safe-area-inset-top))] pt-[env(safe-area-inset-top)]`:`h-(--topbar-h)`),children:[r===`phone`&&e?(0,Q.jsxs)($,{to:`/`,className:`inline-flex min-h-11 items-center gap-1 text-13 font-medium text-fg-2 no-underline hover:text-fg-1`,children:[(0,Q.jsx)(j,{icon:Po,size:20}),`Inbox`]}):(0,Q.jsx)($,{to:`/`,className:`font-mono text-14 font-medium leading-none font-stretch-mono text-fg-3 no-underline hover:text-fg-1`,children:`emend`}),r===`phone`?(0,Q.jsx)(yt,{label:`More`,size:`lg`,triggerRef:u,trigger:(0,Q.jsx)(w,{label:`More`,icon:vt,size:`lg`,tooltip:!1}),items:g}):(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(w,{label:`Refresh`,icon:Ss,"aria-busy":c,className:c?`[&>svg]:animate-spin`:void 0,onClick:()=>void s()}),(0,Q.jsx)(w,{label:`Devices`,icon:Ps,asChild:!0,children:(0,Q.jsx)($,{to:`/devices`})})]})]}),(0,Q.jsx)(`div`,{role:`status`,children:l.state===`reload-needed`&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1 border-b border-line-1 bg-sunken py-1.5 pr-2 pl-4 text-13 text-fg-2`,children:[(0,Q.jsx)(`p`,{children:`emend was updated in another window. Reload to keep working.`}),(0,Q.jsx)(G,{size:`sm`,icon:ws,onClick:()=>d.request(`reload`),children:`Reload`})]})}),(0,Q.jsx)(vc.Provider,{value:d.request,children:t}),d.dialog]})}function Ec(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=(t-n.getTime())/1e3;return r<60?`now`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:r<604800?new Intl.DateTimeFormat(void 0,{weekday:`short`}).format(n):new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)}function Dc(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(t)}var Oc=864e5;function kc(e,t){let n=new Date(e).getTime();return!Number.isNaN(n)&&n<=t}function Ac(e,t){let n=typeof e==`string`?new Date(e):e;if(Number.isNaN(n.getTime()))return``;let r={hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`},i=new Date(t);return n.getTime()-t>=6*Oc||n.toDateString()!==i.toDateString()&&n.getDay()===i.getDay()?new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,...r}).format(n):new Intl.DateTimeFormat(void 0,{weekday:`short`,...r}).format(n)}function jc(e){let t=t=>new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,9,0,0,0);return[{id:`revision`,label:`Until it changes`},{id:`later`,label:`Later today`,until:new Date(e.getTime()+108e5)},{id:`tomorrow`,label:`Tomorrow morning`,until:t(e.getHours()<5?0:1)},{id:`week`,label:`Next week`,until:t((8-e.getDay())%7||7)}]}function Mc(e,t){let n=new Date(e).getTime();if(Number.isNaN(n))return``;let r=(t-n)/1e3;return r<60?`Checked just now.`:r<3600?`Checked ${Math.floor(r/60)}m ago.`:r<86400?`Checked ${Math.floor(r/3600)}h ago.`:`Checked on ${Ec(e,t)}.`}function Nc(e){switch(e.state){case`unsupported`:return`Updates need the installed app over a secure connection.`;case`checking`:return`Checking for updates…`;case`current`:return`This is the newest version.`;case`available`:return`An update is ready.`;case`updating`:return`Updating…`;case`reload-needed`:return`Another window installed an update. Reload to use it.`;case`error`:return`Could not check for updates: ${e.reason??`the check failed`}.`;default:return``}}function Pc({now:e}){let t=Ht(),n=yc(),r=zt(),i=t.state===`checking`||t.state===`updating`,a=t.checkedAt===null?``:Mc(new Date(t.checkedAt).toISOString(),e);return(0,Q.jsxs)(`section`,{"aria-labelledby":`app-heading`,className:`mt-10`,children:[(0,Q.jsx)(`h2`,{id:`app-heading`,className:`text-18 font-semibold leading-(--lh-snug)`,children:`App`}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 rounded-lg border border-line-1 bg-surface px-3.5 py-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 basis-60`,children:[(0,Q.jsx)(`p`,{className:`text-14 font-semibold`,children:`emend 0.2.0${r?` (${r})`:``}`}),(0,Q.jsx)(`p`,{"aria-live":`polite`,className:`mt-0.5 text-12 text-fg-3`,children:Nc(t)}),a&&t.state!==`unsupported`&&(0,Q.jsx)(`p`,{className:`text-12 text-fg-3`,children:a})]}),t.state===`available`&&(0,Q.jsx)(G,{size:`sm`,variant:`primary`,icon:Ko,onClick:()=>n(`update`),children:`Update now`}),t.state===`reload-needed`&&(0,Q.jsx)(G,{size:`sm`,variant:`primary`,icon:ws,onClick:()=>n(`reload`),children:`Reload`}),t.state!==`unsupported`&&(0,Q.jsx)(G,{size:`sm`,icon:Ss,"aria-disabled":i,onClick:()=>{i||Bt.checkForUpdate()},children:`Check for update`})]})]})}function Fc(){let e=K(),t=se(),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(Date.now),o=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{let e=window.setInterval(()=>a(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let s=Ee({queryKey:[`devices`],queryFn:({signal:e})=>Nt(`/api/v1/devices`,d,e)});async function c(){r(null),await t.invalidateQueries({queryKey:[`devices`]})}let l=He({mutationFn:e=>Ne(`/api/v1/devices/${e.id}`,`DELETE`),onSuccess:async(e,n)=>{n.current?(t.clear(),window.location.assign(`/pair`)):await c()},onError:async e=>{e instanceof Ft&&e.status===404&&await c()},onSettled:()=>{o.current=!1}});return(0,Q.jsxs)(Tc,{children:[(0,Q.jsx)(`main`,{className:`relative min-h-0 flex-1 overflow-y-auto`,children:(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-[760px] px-5 pt-8 pb-20`,children:[(0,Q.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 basis-80`,children:[(0,Q.jsx)(`h1`,{className:`text-24 font-semibold leading-(--lh-tight) tracking-(--tracking-tight)`,children:`Devices`}),(0,Q.jsx)(`p`,{className:`mt-1 text-14 text-fg-3`,children:`Browsers and machines that can use this hub. Sign-ins last 30 days and renew while in use.`})]}),(0,Q.jsx)(G,{asChild:!0,variant:`primary`,icon:bs,children:(0,Q.jsx)($,{to:`/devices/pair`,onClick:t=>fc(t,e.history.location),children:`Pair a device`})})]}),s.isPending&&(0,Q.jsx)(`p`,{role:`status`,children:`Loading devices…`}),s.isError&&(0,Q.jsx)(`p`,{role:`alert`,children:`Could not load devices. Try again.`}),s.data?.items.length===0&&(0,Q.jsx)(`p`,{className:`text-14 text-fg-3`,children:`No paired devices.`}),!!s.data?.items.length&&(0,Q.jsx)(`ul`,{className:`divide-y divide-line-1 rounded-lg border border-line-1 bg-surface`,children:s.data.items.map(e=>(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 px-3.5 py-3`,children:[(0,Q.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-sunken text-fg-2`,children:(0,Q.jsx)(j,{icon:e.kind===`browser`?ms:As,size:18})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 basis-36`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 text-14 font-semibold wrap-anywhere`,children:e.name}),e.current&&(0,Q.jsx)(`span`,{className:`rounded-sm border border-line-1 bg-sunken px-1.5 py-0.5 text-11 font-medium text-fg-2`,children:`This device`})]}),(0,Q.jsxs)(`p`,{className:`mt-0.5 text-12 text-fg-3`,children:[e.kind===`browser`?`Browser · paired `:`Machine · attached `,(0,Q.jsx)(`time`,{dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleDateString()})]})]}),(0,Q.jsxs)(`p`,{className:`text-12 text-fg-3`,children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:`Last seen: `}),e.lastSeenAt?(0,Q.jsx)(`time`,{dateTime:e.lastSeenAt,children:Ec(e.lastSeenAt,i)}):`never`]}),(0,Q.jsx)(G,{size:`sm`,variant:e.current?`ghost`:`danger`,icon:e.current?fs:void 0,disabled:l.isPending,onClick:()=>{l.reset(),r(e)},children:e.current?`Sign out`:`Revoke`})]},e.id))}),(0,Q.jsx)(Pc,{now:i})]})}),n&&(0,Q.jsx)(_e,{open:!0,onOpenChange:e=>{!e&&!o.current&&r(null)},title:n.current?`Sign out of this browser?`:`Revoke ${n.name}?`,description:n.current?`You will need a new code to sign in again.`:n.kind===`browser`?`It signs out now and needs a new code to pair again.`:`It loses access to this hub now and needs a new code to attach again.`,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(G,{"data-autofocus":!0,variant:`ghost`,disabled:l.isPending,onClick:()=>r(null),children:`Cancel`}),(0,Q.jsx)(G,{variant:`danger`,disabled:l.isPending,onClick:()=>{o.current||(o.current=!0,l.mutate(n))},children:n.current?`Sign out`:`Revoke`})]}),children:l.isError&&(0,Q.jsx)(`p`,{role:`alert`,className:`mt-4 text-13 text-danger-fg`,children:`Could not revoke the device. Try again.`})}),(0,Q.jsx)(uo,{})]})}var Ic=()=>Yt({queryKey:[`inbox`],queryFn:({signal:e})=>Nt(`/api/v1/reviews`,_,e)}),Lc=e=>Yt({queryKey:[`review`,e],queryFn:({signal:t})=>Nt(`/api/v1/reviews/${encodeURIComponent(e)}`,ae,t)}),Rc=(e,t)=>Yt({queryKey:[`revision`,e,t],queryFn:({signal:n,client:r})=>T(r).fetch(e,t,n,()=>Nt(`/api/v1/reviews/${encodeURIComponent(e)}/revisions/${t}`,tt,n)),staleTime:1/0});function zc(e){return e.state===`approved`?`approved`:e.agentWaiting?`waiting`:e.pendingSend?`pending`:e.pickedUpAt?`pickedUp`:null}var Bc={approved:`Approved`,waiting:`Agent waiting`,pending:`Not picked up yet`,pickedUp:`Picked up`},Vc={waiting:`bg-agent-waiting text-agent-waiting animate-[em-pulse_var(--dur-pulse)_var(--ease-out)_infinite]`,pending:`border-[1.5px] border-agent-none`,pickedUp:`bg-agent-none`};function Hc(e,t,n){let r=Bc[e],i=e===`pickedUp`&&t?Ec(t,n):``;return i?`${r} ${i}`:r}function Uc({status:e,pickedUpAt:t=null,now:n=Date.now(),pill:r=!1,className:i}){if(!e)return null;let a=e===`pickedUp`&&t?Ec(t,n):``;return(0,Q.jsxs)(`span`,{className:U(`inline-flex items-center gap-1.5 whitespace-nowrap text-12 font-medium leading-[1.2]`,e===`approved`?`text-success-fg`:e===`waiting`?`text-fg-1`:`text-fg-2`,r&&`h-6 rounded-full border border-line-1 bg-surface pr-[9px] pl-2`,i),children:[e===`approved`?(0,Q.jsx)(j,{icon:Ie,size:13,strokeWidth:2.25}):(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:U(`size-2 shrink-0 rounded-full`,Vc[e])}),(0,Q.jsx)(`span`,{children:Bc[e]}),a&&(0,Q.jsx)(`time`,{dateTime:t??void 0,children:a})]})}var Wc=[[`bg-origin-1-bg text-origin-1-fg`,`bg-origin-1-fg`],[`bg-origin-2-bg text-origin-2-fg`,`bg-origin-2-fg`],[`bg-origin-3-bg text-origin-3-fg`,`bg-origin-3-fg`],[`bg-origin-4-bg text-origin-4-fg`,`bg-origin-4-fg`],[`bg-origin-5-bg text-origin-5-fg`,`bg-origin-5-fg`],[`bg-origin-6-bg text-origin-6-fg`,`bg-origin-6-fg`],[`bg-origin-7-bg text-origin-7-fg`,`bg-origin-7-fg`],[`bg-origin-8-bg text-origin-8-fg`,`bg-origin-8-fg`]];function Gc({origin:e,size:t=`md`,dot:n=!1,className:r}){let i=0;for(let t of e.id)i=Math.imul(i,31)+t.charCodeAt(0)>>>0;let a=Wc[i%Wc.length];return n?(0,Q.jsx)(`span`,{role:`img`,"aria-label":`From ${e.name}`,className:U(`inline-block size-2 shrink-0 rounded-[2px]`,a?.[1],r)}):(0,Q.jsx)(`span`,{title:`From ${e.name}`,className:U(`inline-flex shrink-0 items-center whitespace-nowrap rounded-sm pr-1.5 pl-[5px] font-mono font-medium leading-none font-stretch-mono`,t===`sm`?`h-[18px] text-[10px]`:`h-5 text-[10.5px]`,a?.[0],r),children:e.name})}var Kc={open:{icon:Bo,label:`Open`,pill:`bg-state-open-bg text-state-open-fg`,inline:`text-state-open-fg`},approved:{icon:Ro,label:`Approved`,pill:`bg-state-approved-bg text-state-approved-fg`,inline:`text-success-fg`},settled:{icon:Mo,label:`Retired`,pill:`bg-state-settled-bg text-state-settled-fg inset-ring-1 inset-ring-line-1`,inline:`text-fg-3`}};function qc({state:e,revision:t,variant:n=`pill`}){let r=Kc[e];return(0,Q.jsxs)(`span`,{className:U(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-11 leading-none`,n===`pill`?[`h-5 rounded-full pr-[7px] pl-[5px] font-semibold tracking-[.01em]`,r.pill]:[`font-medium`,r.inline]),children:[(0,Q.jsx)(j,{icon:r.icon,size:n===`pill`?12:11,strokeWidth:2}),r.label,e===`approved`&&t!=null?` · rev ${t}`:``]})}function Jc(e){return e.state===`open`&&!e.snoozed&&!e.movedTo&&(e.agentWaiting||e.unsentCount>0)}function Yc({review:e,now:t,onOpen:n,highlight:r=!1}){let i=Jc(e),a=zc(e),o=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`col-start-1 row-start-1 flex min-w-0 items-center gap-1.5 text-11 leading-[1.2] text-fg-3`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex [&>span]:size-[7px] [&>span]:opacity-85`,children:(0,Q.jsx)(Gc,{origin:e.origin,dot:!0})}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.origin.name})]}),(0,Q.jsx)(`span`,{className:`col-start-2 row-start-1 inline-flex items-center whitespace-nowrap text-12 font-normal text-fg-3 tabular-nums`,children:e.snoozed?e.snoozedUntil?kc(e.snoozedUntil,t)?(0,Q.jsx)(`span`,{children:`waking up`}):(0,Q.jsxs)(`time`,{dateTime:e.snoozedUntil,title:new Date(e.snoozedUntil).toLocaleString(),children:[`until `,Ac(e.snoozedUntil,t)]}):(0,Q.jsx)(`span`,{children:`until it changes`}):e.state===`open`?(0,Q.jsx)(`time`,{dateTime:e.updatedAt,title:new Date(e.updatedAt).toLocaleString(),children:Ec(e.updatedAt,t)}):(0,Q.jsx)(qc,{state:e.state,variant:`inline`})}),(0,Q.jsxs)(`span`,{className:U(`relative col-span-2 row-start-2 min-w-0 text-13 leading-[1.35] font-[450] group-aria-[current=page]:font-medium group-aria-[current=page]:text-fg-1`,i&&`font-medium text-fg-1`),children:[i&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1/2 -left-2.5 size-[5px] -translate-y-1/2 rounded-full bg-accent`}),(0,Q.jsxs)(`span`,{className:`block truncate`,children:[i&&(0,Q.jsx)(`span`,{className:`sr-only`,children:`Needs you. `}),e.title]})]}),(0,Q.jsx)(`span`,{className:`col-start-1 row-start-3 truncate font-mono text-11 leading-[1.3] font-stretch-mono text-fg-3`,children:e.movedTo?`Moved to ${new URL(e.movedTo).host}`:e.branch}),!e.movedTo&&(0,Q.jsxs)(`span`,{className:`col-start-2 row-start-3 flex items-center justify-end gap-2 text-11 font-medium leading-none text-fg-3 tabular-nums`,children:[e.openThreads>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-[3px]`,children:[(0,Q.jsx)(j,{icon:ot,size:11}),e.openThreads,(0,Q.jsx)(`span`,{className:`sr-only`,children:V(e.openThreads,` open thread`)})]}),e.unsentCount>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-[3px] text-accent-text`,children:[(0,Q.jsx)(j,{icon:xt,size:11}),e.unsentCount,(0,Q.jsx)(`span`,{className:`sr-only`,children:` unsent`})]}),a&&a!==`approved`&&(0,Q.jsx)(`span`,{role:`img`,"aria-label":Hc(a,e.pickedUpAt,t),className:U(`size-[7px] shrink-0 rounded-full`,Vc[a])})]})]}),s=U(`group relative grid w-full grid-cols-[minmax(0,1fr)_auto] grid-rows-[auto_auto_auto] gap-x-2 gap-y-[3px] rounded-sm px-2.5 pt-2 pb-[9px] text-left text-fg-2 no-underline`,r&&`em-inbox-new`);return(0,Q.jsx)(`li`,{children:e.movedTo?(0,Q.jsx)(`div`,{className:U(s,`opacity-50`),"aria-disabled":`true`,children:o}):(0,Q.jsx)($,{to:`/r/$reviewId`,params:{reviewId:e.id},search:{rev:e.newestRevision},activeOptions:{includeSearch:!1},activeProps:{"aria-current":`page`},onClick:e=>{e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||n?.()},className:U(s,`hover:bg-hover hover:text-fg-2 aria-[current=page]:bg-active`,e.list===`done`&&`opacity-60 hover:opacity-100 focus-within:opacity-100 aria-[current=page]:opacity-100`),children:o})})}var Xc=`flex min-w-0 flex-col gap-1.5`,Zc=`font-sans text-13 font-medium leading-(--lh-snug) text-fg-1`,Qc=`box-border w-full rounded-md border border-line-2 bg-surface px-2.5 font-sans text-14 font-normal leading-(--lh-body) text-fg-1 shadow-inset transition-[border-color,box-shadow] duration-(--dur-1) ease-(--ease-out) placeholder:text-fg-3 enabled:hover:border-line-strong focus:border-line-focus focus:outline-none focus:shadow-[0_0_0_3px_var(--accent-tint-2)] disabled:cursor-not-allowed disabled:bg-sunken disabled:text-fg-disabled aria-invalid:border-danger-solid aria-invalid:focus:shadow-[0_0_0_3px_var(--danger-bg)]`,$c={sm:`h-7 rounded-sm text-13`,md:`h-8`,lg:`h-10 text-15`};function el(e,t,n,r){let i=(0,Y.useId)(),a=e??i,o=`${a}-description`;return{id:a,messageId:o,describedBy:[r,(t||n)&&o].filter(Boolean).join(` `)||void 0}}function tl({id:e,hint:t,error:n}){return n?(0,Q.jsxs)(`span`,{id:e,role:`alert`,className:`flex items-center gap-[5px] font-sans text-12 font-normal leading-(--lh-snug) text-danger-fg`,children:[(0,Q.jsx)(j,{icon:Io,size:13}),n]}):t?(0,Q.jsx)(`span`,{id:e,className:`font-sans text-12 font-normal leading-(--lh-snug) text-fg-3`,children:t}):null}function nl({label:e,hint:t,options:n,size:r=`md`,id:i,className:a,...o}){let s=el(i,t,void 0,o[`aria-describedby`]);return(0,Q.jsxs)(`div`,{className:U(Xc,a),children:[e&&(0,Q.jsx)(`label`,{htmlFor:s.id,className:`font-sans text-13 font-medium leading-(--lh-snug) text-fg-1`,children:e}),(0,Q.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,Q.jsx)(`select`,{...o,id:s.id,"aria-describedby":s.describedBy,className:U(Qc,`appearance-none pr-[30px] font-sans text-13 font-medium font-[450]`,$c[r],`leading-(--lh-snug)`),children:n.map(e=>typeof e==`string`?(0,Q.jsx)(`option`,{value:e,children:e},e):(0,Q.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))}),(0,Q.jsx)(j,{icon:wt,size:14,className:`pointer-events-none absolute right-2 text-fg-3`})]}),(0,Q.jsx)(tl,{id:s.messageId,hint:t})]})}function rl({label:e,hint:t,error:n,icon:r,size:i=`md`,mono:a=!1,id:o,className:s,...c}){let l=el(o,t,n,c[`aria-describedby`]);return(0,Q.jsxs)(`div`,{className:U(Xc,s),children:[e&&(0,Q.jsx)(`label`,{htmlFor:l.id,className:`font-sans text-13 font-medium leading-(--lh-snug) text-fg-1`,children:e}),(0,Q.jsxs)(`div`,{className:`relative flex items-center`,children:[r&&(0,Q.jsx)(j,{icon:r,size:14,className:`pointer-events-none absolute left-[9px] text-fg-3`}),(0,Q.jsx)(`input`,{...c,id:l.id,"aria-invalid":n?!0:c[`aria-invalid`],"aria-describedby":l.describedBy,className:U(Qc,a&&`font-mono text-12 font-normal font-stretch-mono`,$c[i],a?`leading-[1.6]`:`leading-(--lh-body)`,r&&`pl-[30px]`)})]}),(0,Q.jsx)(tl,{id:l.messageId,hint:t,error:n})]})}var il=2**31-1,al=500;function ol(e,t){let n=(0,Y.useRef)(t);n.current=t;let[r,i]=(0,Y.useState)(0),a=e.join(`|`);(0,Y.useEffect)(()=>{let t=Date.now(),r=e.map(e=>e?new Date(e).getTime():NaN).filter(e=>e>t-al);if(r.length===0)return;let a=Math.min(...r),o=setTimeout(()=>{let t=Date.now(),r=e.filter(e=>!!e&&new Date(e).getTime()<=t);r.length>0&&n.current(r),i(e=>e+1)},Math.min(Math.max(a-t,0)+al,il));return()=>clearTimeout(o)},[a,r])}var sl=[{list:`active`,title:`Active`},{list:`snoozed`,title:`Snoozed`},{list:`done`,title:`Done`}],cl=`emend:inbox-kind`;function ll(){try{let e=localStorage.getItem(cl);return e===`review`||e===`publish`?e:``}catch{return``}}function ul({compact:e=!1,currentReviewId:t,hideHead:n=!1,onCollapse:r,onOpen:i}){let a=Ee(Ic()),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(ll),f=e=>{d(e);try{e?localStorage.setItem(cl,e):localStorage.removeItem(cl)}catch{}},[p,m]=(0,Y.useState)(Date.now),[h,g]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=window.setInterval(()=>m(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let _=a.data?.items??[],v=se();ol(_.map(e=>e.snoozedUntil),e=>{m(Date.now()),v.invalidateQueries({queryKey:[`inbox`]});for(let t of _)t.snoozedUntil&&e.includes(t.snoozedUntil)&&v.invalidateQueries({queryKey:[`review`,t.id]})});let y=[...new Map(_.map(({origin:e})=>[e.id,e])).values()].sort((e,t)=>e.name.localeCompare(t.name)),b=!e&&y.length>1&&y.some(e=>e.id===c)?c:``,x=o.toLocaleLowerCase(),S=_.filter(n=>(!b||n.origin.id===b)&&(!u||n.kind===u||u===`review`&&n.agentWaiting||e&&n.id===t)&&[n.title,n.branch,n.origin.name].some(e=>e?.toLocaleLowerCase().includes(x))),C=sc(_),T=e?`h3`:`h2`,E=_.filter(Jc).length;return(0,Q.jsxs)(`div`,{className:e?`flex min-h-0 flex-1 flex-col`:`mx-auto w-full max-w-[760px] px-5 pt-8 pb-20`,children:[!n&&(e?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between pt-2.5 pr-2 pb-1.5 pl-4`,children:[(0,Q.jsx)(`h2`,{className:`text-13 font-medium leading-[1.2] text-fg-2`,children:`Inbox`}),(0,Q.jsx)(w,{label:`Collapse inbox`,icon:gs,size:`sm`,onClick:r})]}):(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.jsx)(`h1`,{className:`text-24 font-semibold leading-(--lh-tight) tracking-(--tracking-tight)`,children:`Inbox`}),a.data&&(0,Q.jsxs)(`p`,{className:`mt-1 text-14 text-fg-3`,children:[E?`${E} ${V(E,`needs`,`need`)} you`:`Nothing needs you`,` ·`,` `,y.length,` `,V(y.length,`machine`)]})]})),(0,Q.jsxs)(`div`,{className:e?`flex flex-col gap-2 px-2.5 pb-2`:`mb-3 flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(rl,{"aria-label":`Filter reviews`,placeholder:`Filter by title, branch, machine`,icon:Es,size:`sm`,value:o,onChange:e=>s(e.target.value),className:e?`min-w-0`:`min-w-0 flex-[1_1_16rem]`}),_.length>0&&(0,Q.jsx)(ut,{label:`Kind`,size:`sm`,className:e?`w-full [&>button]:flex-1 [&>button]:justify-center`:`max-w-full shrink-0`,value:u,onChange:e=>{(e===``||e===`review`||e===`publish`)&&f(e)},options:[{value:``,label:`All`},{value:`review`,label:`Reviews`},{value:`publish`,label:`Pubs`}]}),!e&&y.length>1&&(0,Q.jsx)(nl,{"aria-label":`Machine`,size:`sm`,className:`min-w-0 max-w-full`,value:b,onChange:e=>l(e.target.value),options:[{value:``,label:`All machines`},...y.map(e=>({value:e.id,label:e.name}))]})]}),(0,Q.jsxs)(`div`,{className:e?`relative min-h-0 flex-1 overflow-y-auto px-1.5 pt-1 pb-3`:`py-1`,children:[a.isPending&&(0,Q.jsx)(`p`,{role:`status`,className:`p-4`,children:`Loading reviews…`}),a.isError&&(0,Q.jsxs)(`div`,{className:`p-4`,children:[(0,Q.jsx)(`p`,{role:`alert`,children:`Could not load reviews.`}),(0,Q.jsx)(G,{onClick:()=>void a.refetch(),children:`Retry`})]}),a.data&&_.length===0&&(0,Q.jsx)(`p`,{className:`p-4 text-fg-3`,children:`No reviews yet.`}),_.length>0&&S.length===0&&(0,Q.jsxs)(`div`,{className:`p-4`,children:[(0,Q.jsx)(`p`,{className:`text-fg-3`,children:`No reviews match this filter.`}),(0,Q.jsx)(G,{variant:`ghost`,onClick:()=>{s(``),l(``),f(``)},children:`Clear filter`})]}),a.data&&_.length>0&&S.length>0&&sl.map(({list:e,title:t})=>{let n=S.filter(t=>t.list===e),r=e===`active`&&!_.some(e=>e.list===`active`);if(n.length===0&&!r)return null;let a=e!==`done`||h||x!==``,o=(0,Q.jsxs)(Q.Fragment,{children:[t,(0,Q.jsx)(`span`,{className:`ml-1.5 font-normal tabular-nums text-fg-3`,children:n.length})]});return(0,Q.jsxs)(`section`,{"aria-label":t,children:[(0,Q.jsx)(T,{className:`m-0 px-2.5 pt-3 pb-1 font-mono text-11 font-medium leading-(--lh-snug) font-stretch-mono tracking-(--tracking-label) text-fg-3 uppercase`,children:e===`done`&&x===``?(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":a,className:`inline-flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0 font-[inherit] text-[inherit] uppercase`,onClick:()=>g(!h),children:[(0,Q.jsx)(j,{icon:a?wt:rt,size:12}),o]}):o}),r&&(0,Q.jsx)(`p`,{className:`px-2.5 py-2 text-13 text-fg-3`,children:`No active reviews.`}),a&&n.length>0&&(0,Q.jsx)(`ul`,{children:n.map(e=>(0,Q.jsx)(Yc,{review:e,now:p,onOpen:i,highlight:C.has(e.id)},e.id))})]},e)})]})]})}function dl(){return(0,Q.jsx)(Tc,{children:(0,Q.jsx)(`main`,{className:`relative min-h-0 flex-1 overflow-y-auto`,children:(0,Q.jsx)(ul,{})})})}function fl(e){let t=e.toUpperCase().replace(/O/g,`0`).replace(/[IL]/g,`1`).replace(/[^0-9A-HJKMNP-TV-Z]/g,``).slice(0,8);return t.length>4?`${t.slice(0,4)}-${t.slice(4)}`:t}function pl({value:e,defaultValue:t=``,onChange:n,error:r,label:i=`Pairing code`,id:a,className:o,onPaste:s,...c}){let[l,u]=(0,Y.useState)(()=>fl(t)),d=e===void 0?l:fl(e),f=(0,Y.useRef)(null);(0,Y.useLayoutEffect)(()=>{let e=f.current;f.current=null,e?.value===d&&e.input.setSelectionRange(e.caret,e.caret)});let p=el(a,void 0,r,c[`aria-describedby`]);function m(t,r,i){if(t.value=d,c.readOnly||c.disabled)return;let a=fl(r),o=fl(r.slice(0,i)).length,s={input:t,value:a,caret:o};f.current=s,a===d&&t.setSelectionRange(o,o),e===void 0&&u(a),n?.(a),queueMicrotask(()=>{f.current===s&&(f.current=null)})}return(0,Q.jsxs)(`div`,{className:U(Xc,o),children:[(0,Q.jsx)(`label`,{htmlFor:p.id,className:Zc,children:i}),(0,Q.jsx)(`input`,{...c,id:p.id,"data-own-size":!0,type:`text`,value:d,maxLength:9,pattern:`[0-9A-HJKMNP-TV-Z]{4}-[0-9A-HJKMNP-TV-Z]{4}`,autoComplete:`one-time-code`,inputMode:`text`,autoCapitalize:`characters`,spellCheck:!1,placeholder:c.placeholder??`XXXX-XXXX`,"aria-invalid":r?!0:c[`aria-invalid`],"aria-describedby":p.describedBy,onChange:e=>m(e.currentTarget,e.currentTarget.value,e.currentTarget.selectionStart??e.currentTarget.value.length),onPaste:e=>{if(c.readOnly||c.disabled){e.preventDefault();return}if(s?.(e),e.defaultPrevented)return;e.preventDefault();let t=e.currentTarget,n=t.selectionStart??t.value.length,r=t.selectionEnd??n,i=e.clipboardData.getData(`text`);m(t,t.value.slice(0,n)+i+t.value.slice(r),n+i.length)},className:`box-border h-[60px] w-full rounded-lg border border-line-2 bg-surface px-3 text-center font-mono text-[26px] leading-none font-semibold font-stretch-mono tracking-[0.16em] text-fg-1 uppercase shadow-inset placeholder:text-fg-disabled focus:border-line-focus focus:outline-none focus:shadow-[0_0_0_3px_var(--accent-tint-2)] disabled:cursor-not-allowed disabled:bg-sunken disabled:text-fg-disabled aria-invalid:border-danger-solid aria-invalid:focus:shadow-[0_0_0_3px_var(--danger-bg)]`}),(0,Q.jsx)(tl,{id:p.messageId,error:r})]})}function ml(){let e=[`127.0.0.1`,`localhost`,`[::1]`,`::1`].includes(window.location.hostname),t=Fa(),n=se(),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(``),l=(0,Y.useRef)(null),u=(0,Y.useRef)(new Set);(0,Y.useEffect)(()=>{s&&!a&&l.current?.focus()},[s,a]);let d=(0,Y.useCallback)(async e=>{o(!0),c(``);try{await jt(e),n.clear(),await t({to:`/`,replace:!0})}catch(e){c(e instanceof Ft&&e.status===429?`Too many wrong codes. Wait 10 minutes, then try again.`:e instanceof Ft&&(e.status===401||e.status===400)?`That code did not work. Check it on the hub and try again.`:`Could not pair. Check your connection and try again.`)}finally{o(!1)}},[n,t]);return(0,Y.useEffect)(()=>{let e=()=>{let e=Ut();e&&!u.current.has(e)&&(u.current.add(e),d({secret:e}))},t=Vt(e);return e(),t},[d]),(0,Q.jsxs)(`main`,{className:`mx-auto flex min-h-dvh w-full max-w-md flex-col gap-5 px-6 pt-14 pb-6`,children:[(0,Q.jsx)(`p`,{className:`mb-3 font-mono text-30 font-medium leading-none font-stretch-mono text-fg-1`,children:`emend`}),(0,Q.jsx)(`h1`,{className:`text-24 font-semibold leading-(--lh-tight) tracking-(--tracking-tight)`,children:e?`Sign in`:`Pair this device`}),e?(0,Q.jsxs)(Q.Fragment,{children:[a?(0,Q.jsx)(`p`,{role:`status`,children:`Pairing…`}):(0,Q.jsxs)(`p`,{className:`text-15 text-fg-2`,children:[`Run `,(0,Q.jsx)(`code`,{children:`emend`}),` in a terminal on the machine that runs emend. It opens this page signed in, or prints a one-time link you can open here.`]}),s&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-13 text-danger-fg`,children:s})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-15 text-fg-2`,children:`On a browser that is already signed in, open Devices, choose Pair a device, and type the code it shows here.`}),(0,Q.jsx)(`p`,{className:`text-12 text-fg-3`,children:`The app on your home screen pairs once more with a code, even after Safari has paired.`}),(0,Q.jsxs)(`form`,{className:`space-y-5`,onSubmit:e=>{e.preventDefault(),!a&&r.replace(/-/g,``).length===8&&d({code:r})},children:[(0,Q.jsx)(pl,{ref:l,id:`pairing-code`,label:`Pairing code`,value:r,onChange:e=>{i(e),c(``)},error:s,required:!0,disabled:a}),(0,Q.jsx)(G,{type:`submit`,disabled:a||r.replace(/-/g,``).length!==8,variant:`primary`,size:`lg`,fullWidth:!0,children:`Pair`}),a&&(0,Q.jsx)(`p`,{role:`status`,children:`Pairing…`})]})]})]})}var hl=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(hl||{}),gl=[0,1],_l=[1,0],vl=[2,3],yl=[3,2],bl={L:gl,M:_l,Q:vl,H:yl},xl=/^\d*$/,Sl=/^[A-Z0-9 $%*+./:-]*$/,Cl=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,wl=1,Tl=40,El=3,Dl=3,Ol=40,kl=10,Al=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],jl=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],Ml=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<wl||e>Tl)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,hl.Timing),this.setFunctionModule(e,6,e%2==0,hl.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,Pl(r,e));this.setFunctionModule(8,7,Pl(r,6)),this.setFunctionModule(8,8,Pl(r,7)),this.setFunctionModule(7,8,Pl(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,Pl(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,Pl(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,Pl(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=Pl(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,hl.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,hl.Alignment)}setFunctionModule(e,t,n,r=hl.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==Yl(t,n))throw RangeError(`Invalid argument`);let r=jl[n[0]][t],i=Al[n[0]][t],a=Math.floor(Jl(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=Xl(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=Zl(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(Jl(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=Pl(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=El:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Ol),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Ol}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=El:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Ol),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Ol}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=Dl)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*kl,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Nl(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function Pl(e,t){return!!(e>>>t&1)}var Fl=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},Il=[1,10,12,14],Ll=[2,9,11,13],Rl=[4,8,16,16];function zl(e,t){return e[Math.floor((t+7)/17)+1]}function Bl(e){let t=[];for(let n of e)Nl(n,8,t);return new Fl(Rl,e.length,t)}function Vl(e){if(!Wl(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);Nl(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new Fl(Il,e.length,t)}function Hl(e){if(!Gl(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Cl.indexOf(e.charAt(n))*45;r+=Cl.indexOf(e.charAt(n+1)),Nl(r,11,t)}return n<e.length&&Nl(Cl.indexOf(e.charAt(n)),6,t),new Fl(Ll,e.length,t)}function Ul(e){return e===``?[]:Wl(e)?[Vl(e)]:Gl(e)?[Hl(e)]:[Bl(ql(e))]}function Wl(e){return xl.test(e)}function Gl(e){return Sl.test(e)}function Kl(e,t){let n=0;for(let r of e){let e=zl(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function ql(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function Jl(e){if(e<wl||e>Tl)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function Yl(e,t){return Math.floor(Jl(e)/8)-Al[t[0]][e]*jl[t[0]][e]}function Xl(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=Ql(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=Ql(n,2)}return t}function Zl(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=Ql(t,e))}return n}function Ql(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function $l(e,t,n=1,r=40,i=-1,a=!0){if(!(wl<=n&&n<=r&&r<=Tl)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=Yl(o,t)*8,i=Kl(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[_l,vl,yl])a&&s<=Yl(o,e)*8&&(t=e);let c=[];for(let t of e){Nl(t.mode[0],4,c),Nl(t.numChars,zl(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=Yl(o,t)*8;Nl(0,Math.min(4,l-c.length),c),Nl(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Nl(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new Ml(o,t,u,i)}function eu(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?Ul(e):Array.isArray(e)?[Bl(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=$l(c,bl[n],i,a,o,r),u=tu({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function tu(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=hl.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}var nu={info:Ss,warning:Is,danger:Io,neutral:Je},ru={info:`bg-info-bg text-info-fg border-[color-mix(in_oklch,var(--info-solid)_22%,transparent)]`,warning:`bg-warning-bg text-warning-fg border-[color-mix(in_oklch,var(--warning-solid)_30%,transparent)]`,danger:`bg-danger-bg text-danger-fg border-[color-mix(in_oklch,var(--danger-solid)_25%,transparent)]`,neutral:`bg-sunken text-fg-2 border-line-1`};function iu({tone:e=`info`,inline:t=!1,actionLabel:n,onAction:r,onDismiss:i,icon:a,children:o}){return(0,Q.jsxs)(`div`,{role:e===`danger`?`alert`:`status`,className:U(`flex min-h-10 items-center gap-2.5 border-b py-1.5 pr-2 pl-3.5 font-sans text-13 font-medium leading-(--lh-snug) font-[450]`,t&&`rounded-md border`,ru[e]),children:[(0,Q.jsx)(j,{icon:a??nu[e]}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1 text-pretty`,children:o}),n&&(0,Q.jsx)(G,{size:`sm`,onClick:r,className:`shrink-0 shadow-none`,children:n}),i&&(0,Q.jsx)(w,{label:`Dismiss`,icon:le,size:`sm`,onClick:i})]})}async function au(){let e=await ge(`/api/v1/pairings`,{purpose:`device`},ye),t=Date.now(),n=t+Math.max(0,Math.min(6e5,Date.parse(e.expiresAt)-t)),r=new URL(e.url),i=eu(e.url,{border:4});return{code:e.code,deadline:n,origin:r.origin,loopback:[`127.0.0.1`,`localhost`,`[::1]`].includes(r.hostname),qr:{size:i.size,cells:i.data.flatMap((e,t)=>e.flatMap((e,n)=>e?[{x:n,y:t}]:[]))}}}function ou(e){return Math.max(0,Math.min(600,Math.ceil((e-Date.now())/1e3)))}function su(){let e=Fa(),t=K(),n=(0,Y.useRef)(void 0),r=se(),i=(0,Y.useRef)(null),a=(0,Y.useRef)(!1),o=(0,Y.useRef)(0),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(0),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{let e=pc();e&&(n.current=e,m(1))},[]),(0,Y.useEffect)(()=>{let e=++o.current;return()=>{queueMicrotask(()=>{o.current===e&&r.invalidateQueries({queryKey:[`devices`],refetchType:`all`})})}},[r]),(0,Y.useEffect)(()=>{if(p===0)return;let e=!0;return i.current?.attempt!==p&&(i.current={attempt:p,promise:au()}),i.current.promise.then(t=>{if(!e)return;let n=ou(t.deadline);u(n),n===0?(i.current=null,c({expired:!0,origin:t.origin,loopback:t.loopback})):c({...t,expired:!1})},()=>{e&&f(!0)}),()=>{e=!1}},[p]),(0,Y.useEffect)(()=>{if(!s||s.expired)return;let e=window.setInterval(()=>{let e=ou(s.deadline);u(e),e===0&&(i.current=null,c({expired:!0,origin:s.origin,loopback:s.loopback}))},1e3);return()=>window.clearInterval(e)},[s]);function h(){c(void 0),f(!1),m(e=>e+1)}async function g(){if(a.current)return;a.current=!0;let r=n.current?.devicesIndex,i=r!==void 0&&t.history.location.state.__TSR_index===r+1;await e({to:`/devices`,replace:!0}),i&&t.history.back()}return(0,Q.jsx)(_e,{open:!0,onOpenChange:e=>{e||g()},title:`Pair a device`,description:p===0?`Create a code for another browser or phone.`:(0,Q.jsxs)(Q.Fragment,{children:[`Scan the QR code to pair with this hub, or open`,` `,s?(0,Q.jsx)(`span`,{className:`font-mono text-12 wrap-anywhere`,children:s.origin}):`this hub`,` on your device and type the code.`]}),actions:(0,Q.jsx)(G,{"data-autofocus":!0,variant:`ghost`,onClick:()=>void g(),children:`Done`}),children:(0,Q.jsxs)(`div`,{className:`mt-4`,children:[p===0?(0,Q.jsx)(G,{variant:`primary`,onClick:h,children:`Create code`}):d?(0,Q.jsx)(iu,{tone:`danger`,inline:!0,actionLabel:`Try again`,onAction:h,children:`Could not create a pairing. Try again.`}):!s&&(0,Q.jsx)(`p`,{role:`status`,children:`Creating pairing…`}),s&&(0,Q.jsxs)(Q.Fragment,{children:[s.loopback&&(0,Q.jsx)(iu,{tone:`warning`,inline:!0,children:`This hub accepts connections from this computer only. To pair a phone, start emend with --tailscale.`}),s.expired?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-col items-start gap-2`,children:[(0,Q.jsx)(`p`,{role:`status`,className:`text-12 text-fg-3`,children:`This code expired.`}),(0,Q.jsx)(G,{onClick:h,children:`New code`})]}):(0,Q.jsxs)(`div`,{className:`mt-4 grid grid-cols-[minmax(0,1fr)] items-center justify-items-center gap-5`,children:[(0,Q.jsxs)(`svg`,{role:`img`,"aria-label":`Pairing QR code`,viewBox:`0 0 ${s.qr.size} ${s.qr.size}`,width:`256`,height:`256`,className:`h-auto min-w-0 w-full max-w-[256px]`,shapeRendering:`crispEdges`,children:[(0,Q.jsx)(`title`,{children:`Pairing QR code`}),(0,Q.jsx)(`rect`,{width:s.qr.size,height:s.qr.size,fill:`white`}),s.qr.cells.map(({x:e,y:t})=>(0,Q.jsx)(`rect`,{x:e,y:t,width:`1`,height:`1`,fill:`black`},`${e}:${t}`))]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-11 font-medium font-stretch-mono tracking-(--tracking-label) text-fg-3 uppercase`,children:`Code`}),(0,Q.jsx)(`p`,{className:`font-mono text-24 leading-none font-semibold font-stretch-mono tracking-[0.12em]`,children:s.code}),(0,Q.jsxs)(`p`,{className:`inline-flex items-center gap-1 text-12 text-fg-3`,children:[(0,Q.jsx)(j,{icon:Ho,size:12}),`Expires in `,Math.floor(l/60),`:`,String(l%60).padStart(2,`0`)]})]})]})]})]})})}var cu=()=>Wt(()=>import(`./DiffPane-Ck50eAdK.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),lu=class extends Y.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,Q.jsxs)(`div`,{className:`space-y-3 p-5`,children:[(0,Q.jsx)(`p`,{role:`alert`,children:`Could not load the diff.`}),(0,Q.jsx)(G,{onClick:this.props.retry,children:`Retry`}),this.props.retried&&(0,Q.jsx)(G,{onClick:()=>window.location.reload(),children:`Reload the page`})]}):this.props.children}};function uu({load:e=cu,...t}){let[n,r]=(0,Y.useState)(()=>({Pane:(0,Y.lazy)(e),number:0})),i=n.Pane;return(0,Q.jsx)(lu,{retried:n.number>0,retry:()=>r({Pane:(0,Y.lazy)(e),number:n.number+1}),children:(0,Q.jsx)(Y.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,className:`p-5`,children:`Loading diff…`}),children:(0,Q.jsx)(i,{...t})})},n.number)}function du({revision:e,counts:t,onViewed:n,onNavigate:r}){let i=h(e),a=new Map(Xe([...i.values()].map(({topic:e})=>e)).map(({topic:e,rank:t})=>[e.slug,t])),o=e.files.filter(e=>e.role===`diff`),s=o.filter(e=>e.viewed===`viewed`).length,c=new Map;for(let t of e.threads){if(t.placement.status!==`placed`)continue;let e=$e(o,t.placement.location);e&&c.set(e.id,(c.get(e.id)??0)+1)}return(0,Q.jsxs)(`div`,{className:`em-files-view`,children:[[...i.values()].map(({topic:e,files:i})=>{let o=i.filter(e=>e.viewed===`viewed`).length,s=i.length>0&&o===i.length,l=a.get(e.slug),u=e.slug===ve.slug?`Other files`:e.title;return(0,Q.jsxs)(`section`,{className:`em-files-group`,"aria-label":u,children:[(0,Q.jsxs)(`div`,{className:`em-files-group__head`,children:[l?(0,Q.jsx)(kt,{rank:l}):(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`··`}),(0,Q.jsx)(`h3`,{className:`em-files-group__title`,children:u}),(0,Q.jsxs)(`span`,{className:`em-files-group__count`,children:[o,`/`,i.length]}),(0,Q.jsx)(f,{state:s?`viewed`:void 0,label:`topic ${u}`,disabled:!i.length,onToggle:()=>n(i.map(e=>e.path),!s)})]}),i.map(e=>{let i=e.path.lastIndexOf(`/`),a=t.get(e.id);return(0,Q.jsxs)(`div`,{className:`em-files-row`,"data-viewed":e.viewed,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`em-files-row__main`,"aria-label":[`Open diff for ${e.path}`,e.status?.replaceAll(`-`,` `),a&&`${a.additions} added, ${a.deletions} removed`,(c.get(e.id)??0)>0&&`${c.get(e.id)} ${c.get(e.id)===1?`thread`:`threads`}`].filter(Boolean).join(`, `),onClick:()=>r(e),children:[(0,Q.jsx)(v,{status:e.status}),(0,Q.jsx)(`span`,{className:`em-files-row__path`,title:e.path,children:(0,Q.jsxs)(`bdi`,{children:[(0,Q.jsx)(`span`,{className:`em-files-row__dir`,children:e.path.slice(0,i+1)}),e.path.slice(i+1)]})}),(0,Q.jsx)(`span`,{className:`em-files-row__counts`,children:a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`text-diff-add-fg`,children:[`+`,a.additions]}),(0,Q.jsxs)(`span`,{className:`text-diff-del-fg`,children:[`−`,a.deletions]})]}):null}),(0,Q.jsx)(B,{count:c.get(e.id)??0})]}),(0,Q.jsx)(f,{state:e.viewed,viewedOn:e.viewedOn,label:e.path,onToggle:()=>n([e.path],e.viewed!==`viewed`)})]},e.id)})]},e.slug)}),(0,Q.jsxs)(`div`,{className:`em-files-progress`,children:[(0,Q.jsx)(`progress`,{className:`em-files-progress__bar`,value:s,max:o.length||1,"aria-label":`Files viewed`}),(0,Q.jsxs)(`span`,{children:[s,` of `,o.length,` viewed`]})]})]})}function fu(e,t,n){return Math.min(n,Math.max(t,e))}function pu({label:e,value:t,min:n,max:r,onPreview:i,onCommit:a,onReset:o}){let s=(0,Y.useRef)(null),[c,l]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>()=>{s.current&&i(void 0)},[i]),(0,Y.useEffect)(()=>{if(c)return document.body.classList.add(`em-resizing`),()=>document.body.classList.remove(`em-resizing`)},[c]);let u=(e,t)=>{let o=s.current;o&&o.id===e.pointerId&&(s.current=null,t&&o.value!==o.width&&a(fu(o.value,n,r)),i(void 0),l(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,Q.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":e,"aria-valuemin":Math.round(n),"aria-valuemax":Math.round(r),"aria-valuenow":Math.round(t),className:`em-resize-handle ${Ce}`,style:{"--resize-handle-width":`8px`},"data-active":c||void 0,title:`Drag to resize · double-click or Enter to reset`,onDoubleClick:o,onKeyDown:e=>{let i=e.shiftKey?64:16,s={ArrowLeft:t-i,ArrowRight:t+i,Home:n,End:r}[e.key];(s!==void 0||e.key===`Enter`)&&(e.preventDefault(),e.key===`Enter`?o():s!==void 0&&a(fu(s,n,r)))},onPointerDown:e=>{e.button!==0||s.current||(e.preventDefault(),e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId),s.current={id:e.pointerId,x:e.clientX,width:t,value:t},l(!0))},onPointerMove:e=>{let t=s.current;t&&t.id===e.pointerId&&(t.value=fu(t.width+e.clientX-t.x,n,r),i(t.value))},onPointerUp:e=>u(e,!0),onPointerCancel:e=>u(e,!1),onLostPointerCapture:e=>u(e,!1)})}function mu({inbox:e,header:t,reading:n,diff:r,phoneTabs:i,sendBar:a,tab:o,hasDiff:s,tabs:c}){let l=Tt(),u=Ke(),d=l!==`phone`&&u.pane[l]===`split`,f=d&&s,[p,m]=(0,Y.useState)(),[h,g]=(0,Y.useState)(),_=(0,Y.useRef)(null),v=(0,Y.useRef)(null),[y,b]=(0,Y.useState)(0),[x,S]=(0,Y.useState)(0);(0,Y.useLayoutEffect)(()=>{let e=v.current,t=_.current;if(!e||!t)return;let n=()=>{b(e.getBoundingClientRect().width),S(t.getBoundingClientRect().width)};if(n(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,n),()=>window.removeEventListener(`resize`,n);let r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[]);let C=Math.max(360,y-8-440),w=u.readingShare===dt.readingShare?fu(y*dt.readingShare,420,760):y*u.readingShare,T=fu(h??w,360,C),E=fu(x-8*(f?2:1)-360-440,220,520),D=l===`desktop`?fu(p??u.inboxWidth,220,E):dt.inboxWidth;return(0,Q.jsxs)(`div`,{ref:_,className:`em-panes flex min-h-0 flex-1`,style:{"--inbox-w":`${D}px`},children:[l!==`phone`&&e,l===`desktop`&&e&&!u.inboxCollapsed&&(0,Q.jsx)(pu,{label:`Resize inbox`,value:D,min:220,max:E,onPreview:m,onCommit:e=>at.update({inboxWidth:e}),onReset:()=>at.update({inboxWidth:dt.inboxWidth})}),(0,Q.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[t,l!==`phone`&&!d&&c,(0,Q.jsxs)(`div`,{ref:v,className:`flex min-h-0 flex-1`,children:[(l!==`phone`||o!==`diff`||!s)&&(0,Q.jsxs)(`section`,{"aria-label":`Reading`,"data-testid":`reading-pane`,"data-reading-scroll":!0,hidden:!d&&s&&o===`diff`,tabIndex:-1,className:`relative min-w-0 flex-1 overflow-y-auto`,style:f?{flex:`0 0 ${T}px`}:void 0,children:[d&&c,n]},`reading`),f&&(0,Q.jsx)(pu,{label:`Resize reading pane`,value:T,min:360,max:C,onPreview:g,onCommit:e=>{y>0&&at.update({readingShare:e/y})},onReset:()=>at.update({readingShare:dt.readingShare})},`reading-handle`),s&&(l!==`phone`||o===`diff`)&&(0,Q.jsx)(`section`,{"aria-label":`Diff`,"data-testid":`diff-pane`,"data-diff-scroll":!0,hidden:!d&&o!==`diff`,className:`relative min-w-0 flex-1 overflow-y-auto`,children:r},`diff`)]}),a,l===`phone`&&i]})]})}var hu=[{id:`writeup`,label:`Writeup`,icon:ke},{id:`files`,label:`Files`,icon:us},{id:`docs`,label:`Docs`,icon:Qo},{id:`comments`,label:`Comments`,icon:ot},{id:`diff`,label:`Diff`,icon:Xo}];function gu({id:e,search:t,hasDocs:n,hasWriteup:r,hasDiff:i,unsentCount:a,filesCount:o=0,viewedCount:s=0}){return(0,Q.jsx)(`nav`,{"aria-label":`Review tabs`,className:`grid shrink-0 auto-cols-fr grid-flow-col border-t border-line-1 bg-surface pb-[env(safe-area-inset-bottom)]`,children:hu.filter(e=>({writeup:r,files:o>0,diff:i,docs:n,comments:!0})[e.id]).map(n=>(0,Q.jsx)($,{to:`/r/$reviewId`,params:{reviewId:e},search:{...t,tab:n.id,thread:void 0},hash:``,"aria-current":n.id===t.tab?`page`:void 0,className:U(`relative flex h-(--tab-touch) items-center justify-center text-11 font-medium leading-none no-underline hover:text-fg-1`,n.id===t.tab?`text-fg-1 before:absolute before:-top-px before:right-[28%] before:left-[28%] before:h-0.5 before:rounded-b-[2px] before:bg-accent before:content-['']`:`text-fg-3`),children:(0,Q.jsxs)(`span`,{className:`relative flex flex-col items-center gap-[3px]`,children:[(0,Q.jsx)(j,{icon:n.icon,size:18}),(0,Q.jsx)(`span`,{children:n.id===`files`?`Files ${s}/${o}`:n.label}),n.id===`comments`&&a>0&&(0,Q.jsxs)(`span`,{className:`absolute -top-1.5 left-[calc(50%+3px)] inline-grid h-[15px] min-w-[15px] place-items-center rounded-full bg-accent px-1 text-[9.5px] font-semibold leading-none text-accent-fg tabular-nums`,children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:` `}),a,(0,Q.jsx)(`span`,{className:`sr-only`,children:` unsent`})]})]})},n.id))})}function _u({onShow:e}){let t=Ee(Ic());return(0,Q.jsxs)(`aside`,{"aria-label":`Inbox`,className:`flex w-(--inbox-w-collapsed) shrink-0 flex-col items-center gap-2 border-r border-line-1 bg-app py-2`,children:[(0,Q.jsx)(w,{label:`Show inbox`,icon:vs,onClick:e}),(0,Q.jsx)(`div`,{className:`relative min-h-0 w-full flex-1 overflow-y-auto`,children:(0,Q.jsx)(`ul`,{className:`flex flex-col items-center gap-0.5`,children:t.data?.items.filter(e=>!e.movedTo).map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(M,{content:e.title,children:(0,Q.jsxs)($,{to:`/r/$reviewId`,params:{reviewId:e.id},search:{rev:e.newestRevision},"aria-label":`${Jc(e)?`Needs you: `:``}${e.title}`,activeOptions:{includeSearch:!1},activeProps:{"aria-current":`page`},className:U(`relative grid h-8 w-9 place-items-center rounded-[6px] no-underline hover:bg-hover aria-[current=page]:bg-selected [&>span[role=img]]:size-2.5`,e.list===`done`&&`opacity-60 hover:opacity-100 focus-within:opacity-100 aria-[current=page]:opacity-100`),children:[(0,Q.jsx)(Gc,{origin:e.origin,dot:!0}),Jc(e)&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1.5 right-[7px] size-1.5 rounded-full bg-accent`})]})})},e.id))})})]})}function vu({currentReviewId:e,collapsed:t,onCollapsedChange:n}){let r=Tt(),[i,a]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{r!==`tablet`&&a(!1)},[r]),r===`desktop`&&!t?(0,Q.jsx)(`aside`,{"aria-label":`Inbox`,"data-testid":`inbox-pane`,className:`flex min-h-0 w-(--inbox-w) shrink-0 flex-col bg-app`,children:(0,Q.jsx)(ul,{compact:!0,currentReviewId:e,onCollapse:()=>n(!0)})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_u,{onShow:()=>r===`tablet`?a(!0):n(!1)}),r===`tablet`&&(0,Q.jsx)(pe,{side:`left`,title:`Inbox`,open:i,onOpenChange:a,children:(0,Q.jsx)(ul,{compact:!0,hideHead:!0,currentReviewId:e,onOpen:()=>a(!1)})})]})}function yu({items:e,value:t,onChange:n,label:r,className:i,idBase:a}){let o=(0,Y.useId)(),s=a??o,c=(0,Y.useRef)(new Map),l=e.filter(e=>!e.hidden),u=l.some(e=>e.id===t)?t:l[0]?.id;return(0,Q.jsx)(`div`,{role:`tablist`,"aria-label":r,className:U(`flex items-stretch gap-0.5 overflow-x-auto border-b border-line-1 px-2 [scrollbar-width:none]`,i),children:l.map((e,r)=>(0,Q.jsxs)(`button`,{ref:t=>{t?c.current.set(e.id,t):c.current.delete(e.id)},type:`button`,role:`tab`,id:`${s}-tab-${e.id}`,"aria-selected":e.id===t,"aria-controls":e[`aria-controls`],tabIndex:e.id===u?0:-1,onClick:()=>n?.(e.id),onKeyDown:e=>{let t=Te(e.key,r,l.length);if(t===void 0)return;e.preventDefault();let i=l[t];i&&(c.current.get(i.id)?.focus(),n?.(i.id))},className:`relative inline-flex h-10 shrink-0 items-center gap-1.5 whitespace-nowrap border-0 bg-transparent px-2.5 font-sans text-13 font-medium leading-(--lh-snug) text-fg-3 [-webkit-tap-highlight-color:transparent] hover:text-fg-1 focus-visible:outline-none focus-visible:shadow-[inset_0_0_0_2px_var(--ochre-500)] aria-selected:text-fg-1 aria-selected:after:absolute aria-selected:after:right-2 aria-selected:after:-bottom-px aria-selected:after:left-2 aria-selected:after:h-0.5 aria-selected:after:rounded-t-[2px] aria-selected:after:bg-(--ochre-500) aria-selected:after:content-['']`,children:[e.label,e.count!=null&&e.count!==0&&(0,Q.jsx)(`span`,{className:U(`inline-grid h-[18px] min-w-[18px] place-items-center rounded-[9px] bg-active px-[5px] font-sans text-[10.5px] leading-none font-semibold text-fg-2 tabular-nums`,e.accent&&`bg-accent text-accent-fg`),children:e.count})]},e.id))})}function bu({id:e,search:t,hasDocs:n,hasWriteup:r,hasDiff:i,unsentCount:a,filesCount:o=0,viewedCount:s=0,docsCount:c,idBase:l}){let u=Fa(),d=Tt()===`phone`,{reading:f}=Ke(),p=Le()===`tabs`&&i,m=(t.tab===`diff`&&!p||t.tab===`files`&&!o?r?`writeup`:n?`docs`:`comments`:t.tab)??(r?`writeup`:n?`docs`:`comments`);return(0,Q.jsxs)(`div`,{className:`em-review-tabs sticky top-0 z-(--z-sticky) flex shrink-0 items-center border-b border-line-1 bg-surface`,children:[(0,Q.jsx)(yu,{idBase:l,label:`Reading tabs`,className:`min-w-0 flex-1 border-b-0`,value:m,items:[{id:`writeup`,label:`Writeup`,hidden:!r},{id:`files`,label:`Files ${s}/${o}`,hidden:!o},{id:`docs`,label:`Docs`,hidden:!n,count:c},{id:`comments`,label:`Comments`,count:a,accent:!0},{id:`diff`,label:`Diff`,hidden:!p}].map(e=>({...e,"aria-controls":`${l}-${e.id===`diff`?`diff`:`reading`}-panel`})),onChange:n=>{(n===`writeup`||n===`files`||n===`docs`||n===`comments`||n===`diff`)&&u({to:`/r/$reviewId`,params:{reviewId:e},search:{...t,tab:n,thread:void 0},hash:``})}}),!d&&r&&m===`writeup`&&(0,Q.jsx)(ut,{label:`Reading mode`,size:`sm`,className:`mx-2 shrink-0`,options:[{value:`standard`,label:`Standard`},{value:`focus`,label:`Focus`}],value:f,onChange:e=>{(e===`standard`||e===`focus`)&&at.update({reading:e})}})]})}var xu;function Su(e){if(e.dataset.blockKind===`diagram`||e.dataset.blockText===void 0)return;let t=[],n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=``;for(let e=n.nextNode();e;e=n.nextNode()){let n=r.length;r+=e.textContent??``,r.length>n&&t.push({node:e,start:n,end:r.length})}xu??=new Intl.Segmenter(void 0,{granularity:`grapheme`});let i=``,a=[],o=[];for(let{segment:e,index:t}of xu.segment(r)){let n=e.normalize(`NFC`),r=n!==e;i+=n;for(let i=0;i<n.length;i++)a.push(r?t:t+i),o.push(r?t+e.length:t+i+1)}let s=``,c=[],l=[];for(let e of i.matchAll(/\p{White_Space}+|[^\p{White_Space}]/gu)){let t=/^\p{White_Space}/u.test(e[0])?` `:e[0];s+=t;for(let n=0;n<t.length;n++)c.push(a[e.index+n]),l.push(o[e.index+(t===` `?e[0].length-1:n)])}let d=s.length-s.trimStart().length,f=s.trim();if(f===u(e.dataset.blockText))return(n,r)=>{if(!Number.isInteger(n)||!Number.isInteger(r)||n<0||r<=n||r>f.length)return;let i=c[d+n],a=l[d+r-1];if(i===void 0||a===void 0)return;let o=t.find(e=>e.start<=i&&i<e.end),s=t.find(e=>e.start<a&&a<=e.end);if(!o||!s)return;let u=e.ownerDocument.createRange();return u.setStart(o.node,i-o.start),u.setEnd(s.node,a-s.start),u}}function Cu(e,t,n,r){(0,Y.useLayoutEffect)(()=>{let i=e.current;if(!i||!r)return;let a=new Map,o=new Map;for(let e of n){if(e.role!==`diff`||!e.topic)continue;let t=o.get(e.topic)??new Map;for(let n of e.notes??[])n.ref&&t.set(n.ref,{id:n.id,path:e.path});o.set(e.topic,t)}for(let e of t){let t=e.topic&&o.get(e.topic.slug);if(t&&!e.path)for(let n of[...e.blocks,...e.subsections?.flatMap(e=>e.blocks)??[]]){let e=document.getElementById(`block-${n.id}`);if(e&&i.contains(e))for(let n of e.querySelectorAll(`span.user-content-ref`)){let e=n.textContent??``,r=e.length===5?/^ref ([A-Z])$/.exec(e)?.[1]:void 0,i=r&&t.get(r);i&&(n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Go to agent note ${r} in ${i.path}`),n.setAttribute(`data-agent-note-ref`,i.id),a.set(n,i.id))}}}let s=e=>{if(e instanceof KeyboardEvent&&e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof HTMLElement?e.target:null;for(;t&&t!==i;){let n=a.get(t);if(n){e.preventDefault(),r(n);return}t=t.parentElement}};return i.addEventListener(`click`,s),i.addEventListener(`keydown`,s),()=>{i.removeEventListener(`click`,s),i.removeEventListener(`keydown`,s);for(let e of a.keys())for(let t of[`role`,`tabindex`,`aria-label`,`data-agent-note-ref`])e.removeAttribute(t)}},[e,t,n,r])}function wu({block:e,drift:t,changedIn:n,continuesChange:r,commenting:i,onComment:a,children:o}){return(0,Q.jsxs)(`div`,{className:`em-reading-block relative rounded-sm`,"data-drift":t?``:void 0,"data-commenting":i?``:void 0,"data-change-continuation":n!==void 0&&r?``:void 0,children:[n!==void 0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`em-reading-block__change absolute w-0.5 bg-changed-line`}),!r&&(0,Q.jsx)(`div`,{className:`em-reading-block__marker mb-1.5 flex`,children:(0,Q.jsx)(Pe,{revision:n})})]}),(0,Q.jsx)(Ct,{block:e}),e.kind!==`heading`&&We(e).quote!==``&&(0,Q.jsx)(`span`,{className:`em-reading-block__comment`,children:(0,Q.jsx)(w,{icon:ht,label:e.kind===`diagram`?`Comment on diagram`:`Comment on block`,size:`sm`,variant:`ghost`,className:`size-6 [&:not(:disabled):not([aria-disabled=true])]:hover:bg-accent-tint [&:not(:disabled):not([aria-disabled=true])]:hover:text-accent-text`,onMouseUpCapture:e=>e.stopPropagation(),onKeyUpCapture:e=>e.stopPropagation(),onClick:a})}),o]})}function Tu({focus:e,reviewId:t,threads:n,composing:r,jump:i,children:a}){let o=(0,Y.useId)(),[s,c]=(0,Y.useState)(0),l=(0,Y.useCallback)(()=>(c(e=>e+1),()=>c(e=>e-1)),[]),u=(0,Y.useMemo)(()=>({replies:n.map(e=>ft(t,e.target,e.id)),edits:n.flatMap(e=>e.comments.filter(e=>e.author===`user`&&!e.sent).map(e=>A(t,e.id)))}),[t,n]),d=(0,Y.useSyncExternalStore)(Ye,()=>u.replies.some(we)||u.edits.some(e=>Se(e)&&Et(e))),f=r||s>0||d||n.some(e=>e.comments.some(e=>e.author===`user`&&!e.sent)),[p,m]=(0,Y.useState)(f),[h,g]=(0,Y.useState)();i&&h!==i.token&&n.some(e=>e.id===i.threadId)&&(g(i.token),m(!0)),f&&!p&&m(!0);let _=!e||p||f,v=n.every(e=>e.state===`resolved`)?` · resolved`:n.some(e=>e.state===`answered`)?` · answered`:``;return(0,Q.jsx)(nt,{value:l,children:(0,Q.jsxs)(`div`,{className:`em-focus-threads`,children:[_&&(0,Q.jsx)(`div`,{id:o,className:`em-focus-threads__cards`,children:a}),e&&n.length>0&&!f&&(0,Q.jsx)(`button`,{type:`button`,className:`em-focus-pill`,"aria-expanded":_,"aria-controls":_?o:void 0,onClick:e=>{m(!_),_&&e.currentTarget.focus()},children:_?`Hide`:`${n.length} ${V(n.length,`comment`)}${v}`})]})})}var Eu=(0,Y.createContext)(null);function Du({group:e,headingId:t,changedIn:n,children:r}){let i=(0,Y.useRef)(null),a=(0,Y.useRef)(null),o=(0,Y.useContext)(Eu),s=JSON.stringify([o?.reviewId,o?.revision,e.key]),[c,l]=(0,Y.useState)(()=>o?.choices.get(s)??(n!==void 0||e.presentation!==`glossary`&&e.topic?.attention!==`skim`)),u=(0,Y.useCallback)(e=>{o?.choices.set(s,e),l(e)},[o,s]),d=`${t}-body`;(0,Y.useLayoutEffect)(()=>{c||a.current?.setAttribute(`hidden`,`until-found`)},[c]),(0,Y.useEffect)(()=>{let t=i.current,n=()=>{if(a.current&&(a.current.hidden=!1),e.presentation===`glossary`){let e=t?.querySelector(`details.em-writeup-glossary`);e&&(e.open=!0)}u(!0)};return t?.addEventListener(`emend:reveal-reading`,n),t?.addEventListener(`beforematch`,n),()=>{t?.removeEventListener(`emend:reveal-reading`,n),t?.removeEventListener(`beforematch`,n)}},[e.presentation,u]);let f=e.heading!=null&&(0,Q.jsxs)(`div`,{className:e.topic?`em-topic-header`:`mb-3 flex items-center gap-2.5`,children:[e.topic&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{type:`button`,className:`em-topic-fold`,"aria-labelledby":t,"aria-expanded":c,"aria-controls":d,onClick:()=>u(!c),children:c?(0,Q.jsx)(wt,{size:16,"aria-hidden":`true`}):(0,Q.jsx)(rt,{size:16,"aria-hidden":`true`})}),(0,Q.jsx)(qe,{topic:e.topic}),e.rank!==void 0&&(0,Q.jsx)(kt,{rank:e.rank})]}),(0,Q.jsx)(`h2`,{id:t,className:e.topic?`em-topic-title`:e.presentation===`tldr`||e.presentation===`decisions`?`em-writeup-kicker`:`min-w-0 flex-1 wrap-anywhere text-fg-1 [font:var(--type-h2)]`,children:e.heading}),!c&&!!e.commentCount&&(0,Q.jsxs)(`span`,{className:`em-topic-comments`,children:[e.commentCount,` `,V(e.commentCount,`comment`)]}),e.topic&&!c&&n!==void 0&&(0,Q.jsx)(Pe,{revision:n}),e.action]}),p=e.blocks.filter(e=>e.kind===`item`).length||e.blocks.length;return(0,Q.jsx)(`section`,{ref:i,id:e.id,"data-reading-section":e.key,"aria-labelledby":e.labelledBy??t,className:`em-reading-group${e.topic?` em-topic-section`:``}${e.presentation===`tldr`?` em-writeup-card`:e.presentation===`decisions`?` em-writeup-callout em-writeup-decisions`:``}`,children:e.presentation===`glossary`?(0,Q.jsxs)(`details`,{className:`em-writeup-glossary`,open:c,onToggle:e=>{e.target===e.currentTarget&&u(e.currentTarget.open)},children:[(0,Q.jsxs)(`summary`,{id:t,children:[`Glossary · `,p,` `,V(p,`term`)]}),r]}):(0,Q.jsxs)(Q.Fragment,{children:[f,e.meta,e.topic?(0,Q.jsx)(`div`,{ref:a,id:d,hidden:!c,children:r}):r]})})}var Ou=[];function ku(e){return[...e.blocks,...e.subsections?.flatMap(e=>e.blocks)??[]]}function Au({reviewId:e,revision:t,changedBlocks:n,threads:r,topics:i,groups:a,resumedBlockId:o,activeThreadId:s,threadJump:c,focus:l=!1,files:u=Ou,onNote:d}){let f=(0,Y.useId)(),p=(0,Y.useRef)(null);Cu(p,a,u,d);let m=(0,Y.useRef)(null),h=(0,Y.useRef)(void 0),g=(0,Y.useRef)(null),_=(0,Y.useRef)(null),v=(0,Y.useRef)(0),y=(0,Y.useRef)(!1),[b,x]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(``),E=t=>{g.current=document.activeElement instanceof HTMLElement&&p.current?.contains(document.activeElement)?document.activeElement:null,W(ft(e,t),`reading`),x(t),C(!0),T(``)},D=()=>{_.current=null,C(!1),x(null)};(0,Y.useEffect)(()=>{b||(_.current=null)},[b]);let O=new Map(n.map(e=>[e.blockId,e.revision])),k=(0,Y.useMemo)(()=>new Map(a.flatMap(e=>ku(e).map(t=>[t.id,e.path]))),[a]),A=(0,Y.useMemo)(()=>{let e=new Map;for(let t of r){if(t.placement.status!==`placed`)continue;let n=t.placement.location;if(!(`blockId`in n)||!k.has(n.blockId))continue;let r=k.get(n.blockId);if(r===void 0?n.kind!==`writeup-span`:n.kind!==`doc-span`||n.path!==r)continue;let i=e.get(n.blockId)??[];i.push(t),e.set(n.blockId,i)}return e},[r,k]);(0,Y.useLayoutEffect)(()=>{if(!p.current||!Mt())return;let e=[];for(let t of p.current.querySelectorAll(`[data-block-id]`))try{let n=A.get(t.dataset.blockId??``);if(!n)continue;let r=Su(t);if(!r)continue;let i=new Map;for(let e of n){if(e.state===`resolved`||e.placement.status!==`placed`)continue;let t=e.placement.location;if(t.kind!==`writeup-span`&&t.kind!==`doc-span`)continue;let n=r(t.start,t.end);n&&i.set(e.id,n)}e.push(i)}catch{}let t=je(e);return h.current=t,()=>{t?.unregister(),h.current=void 0}},[A,t,e]),(0,Y.useLayoutEffect)(()=>h.current?.setActiveThread(s)),(0,Y.useEffect)(()=>{let e=e=>{if(!p.current||S||e?.target instanceof Node&&m.current?.contains(e.target))return;let t=window.getSelection();if(!e){if(y.current||Date.now()<v.current)return;if(t&&!t.isCollapsed&&!(p.current.contains(t.anchorNode)&&p.current.contains(t.focusNode))){x(null),T(``);return}}if(!t||t.isCollapsed){x(null),T(``);return}let n=Ve(t,p.current);if(`error`in n){x(null),T(n.error===`cross-block`?`Select text within one paragraph`:n.error===`too-long`?`Select at most 2000 characters.`:``);return}let r=k.get(n.blockId);x(r===void 0?{kind:`writeup-span`,...n}:{kind:`doc-span`,path:r,...n}),T(``)},t=p.current;t?.addEventListener(`mouseup`,e),t?.addEventListener(`keyup`,e);let n=0,r=()=>{y.current||Date.now()<v.current||(window.clearTimeout(n),n=window.setTimeout(()=>e(),200))},i=e=>{e.pointerType===`mouse`&&(y.current=!0)},a=()=>{y.current=!1,v.current===1/0&&(v.current=Date.now()+600)};return document.addEventListener(`selectionchange`,r),document.addEventListener(`pointerdown`,i,!0),document.addEventListener(`pointerup`,a,!0),document.addEventListener(`pointercancel`,a,!0),()=>{window.clearTimeout(n),document.removeEventListener(`selectionchange`,r),document.removeEventListener(`pointerdown`,i,!0),document.removeEventListener(`pointerup`,a,!0),document.removeEventListener(`pointercancel`,a,!0),t?.removeEventListener(`mouseup`,e),t?.removeEventListener(`keyup`,e)}},[S,k]);let j=(r,a,s=!1)=>r.map((u,d)=>(0,Q.jsxs)(wu,{block:u,drift:s&&/^drift:/i.test(u.text.trimStart()),changedIn:O.get(u.id),continuesChange:d>0&&O.get(r[d-1]?.id??``)===O.get(u.id),commenting:o===u.id||S&&!!b&&`blockId`in b&&b.blockId===u.id,onComment:()=>{let e=We(u);e.quote&&E(a===void 0?{kind:`writeup-span`,...e}:{kind:`doc-span`,path:a,...e})},children:[(0,Q.jsx)(Tu,{focus:l,reviewId:e,threads:A.get(u.id)??[],composing:o===u.id||S&&!!b&&`blockId`in b&&b.blockId===u.id,jump:c,children:A.get(u.id)?.map(r=>(0,Q.jsx)(`div`,{className:`mt-2.5 mb-1.5`,children:(0,Q.jsx)(Oe,{reviewId:e,revision:t,thread:r,changedBlocks:n,topics:i})},r.id))}),S&&b&&`blockId`in b&&b.blockId===u.id&&(0,Q.jsx)(Be,{reviewId:e,revision:t,target:b,topics:i,onSaved:D,onCancel:D,returnFocus:()=>g.current?.isConnected?g.current:p.current?.closest(`[data-reading-scroll]`)??p.current,wrap:e=>(0,Q.jsx)(`div`,{className:`mt-3`,children:e})})]},u.id));return(0,Q.jsxs)(`div`,{ref:p,tabIndex:-1,className:l?`em-reading-column em-focus-prose`:`em-reading-column pt-4 pb-8 md:pt-7 md:pb-[72px]`,children:[a.map((n,r)=>(0,Q.jsxs)(Du,{group:n,headingId:`${f}-${r}`,changedIn:ku(n).reduce((e,t)=>Math.max(e,O.get(t.id)??0),0)||void 0,children:[n.content,j(n.blocks,n.path,n.presentation===`decisions`),n.subsections?.map(e=>(0,Q.jsxs)(`div`,{className:e.kind===`body`?`em-writeup-details`:`em-writeup-callout em-writeup-${e.kind}`,children:[(0,Q.jsx)(`h3`,{className:e.kind===`body`?`sr-only`:`em-writeup-kicker`,children:e.heading}),j(e.blocks,n.path)]},e.key))]},`${e}:${t}:${n.key}`)),!S&&(w||b)&&(0,Q.jsxs)(`div`,{ref:m,className:`sticky bottom-0 space-y-3 rounded-lg border border-line-2 bg-raised p-3 shadow-2`,style:{userSelect:`none`,WebkitUserSelect:`none`,WebkitTouchCallout:`none`,touchAction:`manipulation`},children:[w&&(0,Q.jsx)(`p`,{role:`status`,children:w}),b&&(0,Q.jsx)(G,{variant:`primary`,size:`sm`,icon:Re,onPointerDown:e=>{e.preventDefault(),_.current=b,v.current=1/0},onClick:()=>{let e=Date.now()<v.current?_.current:null;_.current=null,E(e??b)},children:`Comment on selection`})]})]})}var ju=Qe.pick({quote:!0,prefix:!0,suffix:!0}).strict(),Mu=Qe.pick({}).strict(),Nu=e=>Qe.shape.quote.refine(t=>t===e).transform(()=>e),Pu=l.shape.id,Fu=ju.extend({type:Nu(`emend:anchor`)}).or(Mu.extend({type:Nu(`emend:ready`)})).or(Mu.extend({type:Nu(`emend:navigate`),path:E,fragment:b.shape.mediaType.max(1024).refine(e=>e.isWellFormed())}));Mu.extend({type:Nu(`emend:highlight`),anchors:ju.extend({threadId:Pu}).array()}).or(Mu.extend({type:Nu(`emend:scroll`),threadId:Pu}));function Iu({path:e,contentUrl:t,reviewId:n,revision:r,threads:i,topics:a,changedBlocks:o,navigation:s,docNavigation:c,onNavigate:l,composerOpen:u=!1}){let d=(0,Y.useRef)(null),f=(0,Y.useRef)(null),p=(0,Y.useRef)(null),m=(0,Y.useRef)(0),h=(0,Y.useRef)(!1),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(0),[b,x]=(0,Y.useState)(t),[S,C]=(0,Y.useState)(0),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(),A=(0,Y.useRef)(void 0),ee=(0,Y.useCallback)(e=>{d.current=e,e&&(m.current=0,h.current=!1)},[]);(0,Y.useEffect)(()=>{c&&(x(`${t}#${encodeURIComponent(c.fragment)}`),C(0),_(!1),k(void 0),y(e=>e+1))},[t,c]);let M=i.filter(t=>t.placement.status===`placed`&&t.placement.location.kind===`html-span`&&t.placement.location.path===e).sort((e,t)=>{let n=e=>e.placement.status===`placed`&&e.placement.location.kind===`html-span`?e.placement.location.start:0;return n(e)-n(t)}),N=JSON.stringify(M.flatMap(e=>e.target.kind===`html-span`?[{threadId:e.id,quote:e.target.quote,prefix:e.target.prefix,suffix:e.target.suffix}]:[])),te=e=>{h.current||d.current?.contentWindow?.postMessage(e,`*`)};(0,Y.useEffect)(()=>{let t=t=>{if(h.current||!d.current?.contentWindow||t.source!==d.current.contentWindow)return;let n=Fu.safeParse(t.data);if(n.success){if(n.data.type===`emend:ready`)C(e=>e+1);else if(n.data.type===`emend:navigate`)l?.(n.data);else if(!E&&!u){let{quote:t,prefix:r,suffix:i}=n.data;T({kind:`html-span`,path:e,quote:t,prefix:r,suffix:i})}}};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e,E,u,l]),(0,Y.useEffect)(()=>{S&&!h.current&&d.current?.contentWindow?.postMessage({type:`emend:highlight`,anchors:JSON.parse(N)},`*`)},[S,N]),(0,Y.useEffect)(()=>{k(s)},[s]),(0,Y.useEffect)(()=>{S&&!h.current&&O&&A.current!==O&&M.some(e=>e.id===O.threadId)&&(d.current?.contentWindow?.postMessage({type:`emend:scroll`,threadId:O.threadId},`*`),A.current=O)},[S,O,M]);let P=()=>{D(!1),T(null)};return(0,Q.jsxs)(`div`,{ref:f,tabIndex:-1,className:`space-y-4`,id:`html-doc-${e}`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`iframe`,{ref:ee,sandbox:`allow-scripts`,src:b,title:e,referrerPolicy:`no-referrer`,className:`w-full rounded-md border border-line-1 bg-[#fff]`,style:{height:`70vh`,minHeight:`320px`},onLoad:()=>{++m.current<=1||(h.current=!0,_(!0),C(0),E||T(null))}},v),(0,Q.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-fg-3 [font:var(--type-meta)]`,children:[(0,Q.jsx)(j,{icon:Ms,size:13}),`Shown in a sandbox. Scripts in this doc never run.`]})]}),g&&(0,Q.jsxs)(`div`,{role:`status`,className:`space-y-2`,children:[(0,Q.jsx)(`p`,{children:`This doc navigated away.`}),(0,Q.jsxs)(G,{onClick:()=>{x(t),_(!1),C(0),A.current=void 0,y(e=>e+1)},children:[`Reload `,e]})]}),M.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(G,{onClick:()=>{f.current?.scrollIntoView?.({block:`start`}),S?te({type:`emend:scroll`,threadId:e.id}):h.current||k({threadId:e.id,intent:{}})},children:`Show in doc`}),(0,Q.jsx)(Oe,{reviewId:n,revision:r,changedBlocks:o,thread:e,topics:a})]},e.id)),w&&!u&&(0,Q.jsx)(`div`,{className:E?`pt-3`:`sticky bottom-0 space-y-3 rounded-lg border border-line-2 bg-raised p-3 shadow-2`,style:E?void 0:{userSelect:`none`,WebkitUserSelect:`none`,WebkitTouchCallout:`none`,touchAction:`manipulation`},children:E?(0,Q.jsx)(Be,{reviewId:n,revision:r,target:w,topics:a,onSaved:P,onCancel:P,returnFocus:()=>p.current?.isConnected?p.current:f.current?.closest(`[data-reading-scroll]`)??f.current}):(0,Q.jsx)(G,{variant:`primary`,size:`sm`,icon:Re,onClick:()=>{p.current=document.activeElement instanceof HTMLElement&&f.current?.contains(document.activeElement)?document.activeElement:null,W(ft(n,w),`reading`),D(!0)},children:`Comment on selection`})})]})}function Lu({docs:e,openDoc:t,search:n,targeted:r,onOpenDoc:i,navigation:a,composingPath:o,...s}){let c=(0,Y.useId)(),l=(0,Y.useRef)(null),u=(0,Y.useRef)(new Map),d=(0,Y.useRef)(null),[f,p]=(0,Y.useState)(),m=t?.path;(0,Y.useEffect)(()=>{let e=d.current;if(d.current={path:m,doc:n.doc},e&&m===e.path)return;let t=e&&e.doc!==n.doc&&!r;if(p(e=>e?.path===m?e:void 0),m){if(!r){let e=l.current?.closest(`[data-reading-scroll]`);e&&(e.scrollTop=0)}t&&l.current?.focus({preventScroll:!0})}else if(e?.path&&t){let t=u.current.get(e.path);t?.focus({preventScroll:!0}),t?.scrollIntoView?.({block:`nearest`})}},[m,n.doc,r]);let h=t=>{let n=e.find(e=>e.path===t.path);n&&n.path!==m&&(p(n.kind===`html`&&t.fragment?t:void 0),i(n.path))},g=t?.kind===`html`?(0,Q.jsx)(Iu,{...s,path:t.path,contentUrl:t.contentUrl,navigation:a,docNavigation:f?.path===t.path?f:void 0,onNavigate:h,composerOpen:o===t.path},t.contentUrl):void 0,_=(0,Y.useMemo)(()=>t?[{key:t.path,id:`doc-${t.path}`,labelledBy:c,path:t.path,blocks:t.kind===`markdown`?t.blocks:[],content:g}]:[],[t,c,g]);return t?(0,Q.jsxs)(`div`,{className:`em-doc-view`,"data-multiple-docs":e.length>1?``:void 0,children:[(0,Q.jsxs)(`div`,{className:`em-doc-bar sticky z-(--z-sticky) flex items-center gap-2 border-b border-line-1 bg-surface px-3 py-1.5`,children:[e.length>1&&(0,Q.jsx)(G,{asChild:!0,variant:`ghost`,size:`sm`,icon:Oo,children:(0,Q.jsx)($,{to:`/r/$reviewId`,params:{reviewId:s.reviewId},search:{...n,tab:`docs`,doc:void 0,thread:void 0},hash:``,children:`All docs`})}),(0,Q.jsx)(`h2`,{ref:l,id:c,tabIndex:-1,title:t.path,className:`em-doc-path min-w-0 truncate font-stretch-mono text-fg-3`,children:t.path})]}),(0,Q.jsx)(Au,{...s,groups:_},t.path)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h2`,{className:`sr-only`,children:`Docs`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2 p-4`,children:e.map(e=>{let t=e.kind===`markdown`&&e.blocks.find(e=>e.kind===`heading`)?.text||e.path.split(`/`).at(-1);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)($,{ref:t=>{t?u.current.set(e.path,t):u.current.delete(e.path)},to:`/r/$reviewId`,params:{reviewId:s.reviewId},search:{...n,tab:`docs`,doc:e.path,thread:void 0},hash:``,className:`em-doc-row grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-line-1 bg-surface px-3.5 py-3 text-fg-2 no-underline hover:border-line-2 hover:bg-sunken`,children:[(0,Q.jsx)(j,{icon:e.kind===`html`?lt:ke,size:18}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-[3px]`,children:[(0,Q.jsx)(`span`,{className:`truncate font-sans text-14 leading-[1.3] font-semibold text-fg-1`,children:t}),(0,Q.jsx)(`span`,{className:`em-doc-path truncate font-stretch-mono text-fg-3`,children:e.path})]}),(0,Q.jsx)(j,{icon:rt,size:16})]})},e.path)})})]})}function Ru(e){for(let t=e;t;t=t.parentElement)t instanceof HTMLDetailsElement&&(t.open=!0);e.dispatchEvent(new Event(`emend:reveal-reading`,{bubbles:!0}))}function zu({root:e,groups:t,threads:n,visible:r,onCurrentTopic:i}){let a=(0,Y.useRef)(null),o=(0,Y.useMemo)(()=>t.filter(e=>e.key!==`topics-map`),[t]),[s,c]=(0,Y.useState)(o[0]?.key),l=(0,Y.useMemo)(()=>{let e=new Map(o.flatMap(e=>[...e.blocks,...e.subsections?.flatMap(e=>e.blocks)??[]].map(t=>[t.id,e.key]))),t=new Map(o.flatMap(e=>e.topic?[[e.topic.slug,e.key]]:[])),r=new Map;for(let i of n){if(i.placement.status!==`placed`)continue;let n=i.placement.location,a=n.kind===`writeup-span`?e.get(n.blockId):n.kind===`topic`?t.get(n.slug):void 0;a&&r.set(a,(r.get(a)??0)+1)}return r},[o,n]);return(0,Y.useEffect)(()=>{let t=e.current,n=t?.closest(`[data-reading-scroll]`);if(!r||!t||!n)return;let s=!1,l,u,d=null,f=0,p=!1,m=o.flatMap(e=>{let n=[...t.querySelectorAll(`[data-reading-section]`)].find(t=>t.dataset.readingSection===e.key)?.querySelector(`h2, summary`);return n?[{group:e,heading:n}]:[]}),h=()=>!s&&!n.closest(`[hidden]`),g=()=>{if(!h())return;let e=n.getBoundingClientRect().top,t=e+f+96,r=m.map(e=>({...e,rect:e.heading.getBoundingClientRect()})),a=(p?r.findLast(({rect:t})=>t.bottom>e+f&&t.top<e+n.clientHeight):void 0)??r.findLast(({rect:e})=>e.top<=t)??r[0];c(a?.group.key),i?.(a?.group.topic?.slug)},_=()=>{if(l=void 0,!h()||!a.current)return;let e=n.scrollHeight-n.clientHeight,t=n.scrollTop,r=e>0?Math.min(1,Math.max(0,t/e)):1;a.current.style.transform=`scaleX(${r})`;let i=e>0&&t>=e-1;i!==p&&(p=i,g())},v=()=>{h()&&l===void 0&&(l=requestAnimationFrame(_))},y=()=>{if(!h())return;u?.disconnect();let e=n.querySelector(`.em-review-tabs`);d!==e&&(d&&b.unobserve(d),d=e,d&&b.observe(d)),f=d?.getBoundingClientRect().height??0,t.style.setProperty(`--reading-sticky-top`,`${f}px`);let r=f+96;u=new IntersectionObserver(g,{root:n,rootMargin:`-${r}px 0px ${n.scrollHeight}px 0px`,threshold:1});for(let{heading:e}of m)u.observe(e);g(),v()},b=new ResizeObserver(y);return y(),b.observe(n),b.observe(t),n.addEventListener(`scroll`,v,{passive:!0}),()=>{s=!0,u?.disconnect(),b.disconnect(),n.removeEventListener(`scroll`,v),l!==void 0&&cancelAnimationFrame(l),t.style.removeProperty(`--reading-sticky-top`)}},[e,o,r,i]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:a,className:`em-focus-progress`,style:{transform:`scaleX(0)`},"aria-hidden":`true`}),(0,Q.jsxs)(`nav`,{className:`em-focus-outline`,"aria-label":`Writeup outline`,children:[(0,Q.jsx)(`div`,{className:`em-focus-outline__label`,children:`WRITEUP`}),o.map(t=>{let n=l.get(t.key)??0;return(0,Q.jsxs)(`button`,{type:`button`,className:`em-focus-outline__item`,"aria-current":s===t.key?`location`:void 0,onClick:()=>{let n=[...e.current?.querySelectorAll(`[data-reading-section]`)??[]].find(e=>e.dataset.readingSection===t.key);n&&(c(t.key),i?.(t.topic?.slug),Ru(n),n.scrollIntoView({block:`start`}))},children:[t.rank!==void 0&&(0,Q.jsx)(kt,{rank:t.rank}),(0,Q.jsx)(`span`,{className:`em-focus-outline__text`,children:t.topic?.title??t.heading}),n>0&&(0,Q.jsxs)(`span`,{className:`em-focus-outline__count`,title:`${n} ${V(n,`comment`)}`,children:[n,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[` `,V(n,`comment`)]})]})]},t.key)})]})]})}function Bu({topics:e,fileCount:t,href:n}){return(0,Q.jsx)(`ol`,{className:`-mx-2.5 mb-2 flex list-none flex-col gap-0.5`,children:e.map(({topic:e,rank:r})=>{let i=n(e.slug),a=t(e.slug);return(0,Q.jsxs)(`li`,{className:`relative grid grid-cols-[auto_minmax(0,1fr)] items-start gap-x-2.5 gap-y-0.5 rounded-md px-2.5 py-2 hover:bg-hover`,children:[(0,Q.jsx)(`span`,{className:`mt-px`,children:(0,Q.jsx)(kt,{rank:r})}),(0,Q.jsx)(`span`,{className:`wrap-anywhere text-[15px] font-medium leading-[1.35] text-fg-1`,children:i?(0,Q.jsx)(`a`,{href:i,className:`after:absolute after:inset-0 after:rounded-md after:content-['']`,children:e.title}):e.title}),(0,Q.jsx)(`p`,{className:`col-start-2 text-pretty wrap-anywhere text-14 leading-[1.45] text-fg-2`,children:e.summary}),(e.attention||e.door||e.blastRadius||a>0)&&(0,Q.jsxs)(`div`,{className:`col-start-2 mt-0.5 flex flex-wrap gap-x-3 gap-y-1 text-fg-3 [font:var(--type-meta)]`,children:[(0,Q.jsx)(mt,{topic:e}),a>0&&(0,Q.jsxs)(`span`,{children:[a,` `,V(a,`file`)]})]})]},e.slug)})})}function Vu(e,t,n,r=!0){(0,Y.useEffect)(()=>{let i=e.current,a=i?.closest(`[data-reading-scroll]`);if(!i||!a||!t||!r)return;let o=!1,s=new Set(n.map(e=>e.topic).filter(Boolean)),c=[...i.querySelectorAll(`section[id^="topic-"]`)].filter(e=>s.has(e.id.slice(6))),l=()=>{if(o||a.closest(`[hidden]`))return;let e=a.querySelector(`[role="tablist"]`)?.getBoundingClientRect().height??0,n=a.getBoundingClientRect().top+e+1;t(c.findLast(e=>e.getBoundingClientRect().top<=n)?.id.slice(6))},u,d=()=>{if(o||a.closest(`[hidden]`))return;u?.disconnect();let e=a.querySelector(`[role="tablist"]`)?.getBoundingClientRect().height??0;u=new IntersectionObserver(l,{root:a,rootMargin:`-${e}px 0px -${Math.max(0,a.clientHeight-e-1)}px 0px`,threshold:0});for(let e of c)u.observe(e)};d();let f=new ResizeObserver(d);return f.observe(a),()=>{o=!0,u?.disconnect(),f.disconnect()}},[e,t,n,r])}var Hu=[],Uu=[];function Wu({writeup:e,topics:t=Hu,files:n=Uu,search:r={},phone:i=!1,visible:a=!0,onCurrentTopic:o,onNote:s,...c}){let l=(0,Y.useRef)(null),{reading:u}=Ke(),d=!i&&u===`focus`;Vu(l,o,e.sections,a&&!d),(0,Y.useEffect)(()=>()=>o?.(void 0),[o]);let f=(0,Y.useMemo)(()=>{let a=Xe(t),o=new Map(a.map(e=>[e.topic.slug,e])),s=new Map;for(let e of n)e.role===`diff`&&e.topic&&s.set(e.topic,(s.get(e.topic)??0)+1);let l=e=>s.get(e)??0,u=(e,t=!1)=>{let n={tab:t&&i?`diff`:r.tab,rev:r.rev},a=new URLSearchParams;for(let[e,t]of Object.entries(n))t!==void 0&&a.set(e,String(t));return`/r/${encodeURIComponent(c.reviewId)}${a.size?`?${a}`:``}#${e}`},d=new Map(e.sections.flatMap(e=>e.blocks.map(t=>[t.id,e.topic]))),f=new Map;for(let e of c.threads){if(e.state===`resolved`||e.placement.status!==`placed`)continue;let t=e.placement.location,n=t.kind===`topic`?t.slug:t.kind===`writeup-span`?d.get(t.blockId):void 0;n&&f.set(n,(f.get(n)??0)+1)}let p=[];for(let t of e.sections){let e=t.topic?o.get(t.topic):void 0;if(!e){p.push({key:t.key,heading:t.key===`decisions`?`Decisions & drift`:t.label,blocks:t.blocks,presentation:t.key===`tldr`||t.key===`decisions`||t.key===`glossary`?t.key:void 0});continue}let{topic:n,rank:r}=e,i=p.at(-1);i?.id!==`topic-${n.slug}`&&(i={key:t.key,id:`topic-${n.slug}`,topic:n,rank:r,commentCount:f.get(n.slug)??0,heading:(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsxs)(`span`,{children:[(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`Topic `,r,`: `]}),n.title]})}),blocks:[],subsections:[],action:l(n.slug)>0&&(0,Q.jsxs)(`a`,{href:u(`diff-topic-${n.slug}`,!0),"aria-label":`Files in diff: ${n.title}`,className:`em-topic-files`,children:[l(n.slug),` `,V(l(n.slug),`file`),` · Files in diff`,` `,(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]}),meta:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`em-topic-summary`,children:n.summary}),n.blastRadius&&(0,Q.jsxs)(`p`,{className:`em-topic-blast`,children:[`Blast radius: `,(0,Q.jsx)(`strong`,{children:n.blastRadius.scope}),` — `,n.blastRadius.note]})]})},p.push(i));let a=t.key.slice(t.key.lastIndexOf(`-`)+1),s=a===`why`||a===`example`?a:`body`,c=s===`why`?`Why`:s===`example`?`Example`:`Details`;i.subsections?.push({key:t.key,heading:c,kind:s,blocks:t.blocks})}if(a.length){let e=new Set(p.flatMap(e=>e.id?[e.id]:[])),t=p.findLastIndex(e=>[`overview`,`tldr`,`decisions`,`glossary`].includes(e.key))+1;p.splice(t,0,{key:`topics-map`,heading:`Topics`,blocks:[],content:(0,Q.jsx)(Bu,{topics:a,fileCount:l,href:t=>e.has(`topic-${t}`)?u(`topic-${t}`):l(t)>0?u(`diff-topic-${t}`,!0):void 0})})}return p},[e.sections,t,n,r.tab,r.rev,i,c.reviewId,c.threads]);return(0,Q.jsx)(`div`,{className:d?`em-focus-container`:`contents`,children:(0,Q.jsxs)(`div`,{ref:l,className:d?`em-focus`:`contents`,children:[d&&(0,Q.jsx)(zu,{root:l,groups:f,threads:c.threads,visible:a,onCurrentTopic:o}),(0,Q.jsx)(Au,{...c,topics:t,groups:f,focus:d,files:n,onNote:s})]})})}function Gu({review:e,seq:t,onChange:n}){let r=e.newestRevision,i=t<r,a=Date.now();return(0,Q.jsx)(yt,{label:i?`Revision ${t}, ${r} is newer`:`Revision ${t} of ${r}`,align:`left`,trigger:(0,Q.jsxs)(G,{size:`sm`,iconRight:wt,className:`gap-1.5 pr-1.5 leading-none shadow-none`,children:[`Revision `,(0,Q.jsx)(`span`,{className:`font-mono text-11 font-semibold font-stretch-mono`,children:t}),i?(0,Q.jsxs)(`span`,{className:`font-semibold text-warning-fg`,children:[`· `,r,` is newer`]}):(0,Q.jsxs)(`span`,{className:`text-fg-3`,children:[`of `,r]})]}),items:[{radioGroup:{value:String(t),onValueChange:e=>n(Number(e)),items:[...e.revisions].sort((e,t)=>t.seq-e.seq).map(e=>({value:String(e.seq),label:(0,Q.jsxs)(Q.Fragment,{children:[`Revision `,e.seq,e.seq===r&&(0,Q.jsx)(`span`,{className:`inline-flex h-4 shrink-0 items-center rounded-xs bg-accent px-[5px] text-[9.5px] font-semibold leading-none tracking-[.04em] text-accent-fg uppercase`,children:`Latest`})]}),hint:Ec(e.createdAt,a)}))}}]})}var Ku={pr:is,issue:Bo,other:Jo};function qu(e){return(e??[]).flatMap(e=>{try{let t=new URL(e.url);return t.protocol===`https:`&&t.username===``&&t.password===``?[{...e,host:t.host,href:t.href}]:[]}catch{return[]}})}function Ju({review:e,revision:t,seq:n,ready:r,phone:i,titleRef:a,onRevisionChange:o,onCommentReview:s}){let c=zc(e),[l,u]=(0,Y.useState)(Date.now);(0,Y.useEffect)(()=>{let e=window.setInterval(()=>u(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let d=t&&[t.base?.slice(0,7),t.head===`worktree`?`working tree`:t.head?.slice(0,7)].filter(Boolean).join(` → `),f=qu(t?.links),p=`inline-flex min-w-0 items-center gap-[5px] wrap-anywhere`;return(0,Q.jsxs)(`div`,{className:U(`flex shrink-0 flex-col gap-1 border-b border-line-1 bg-surface`,i?`px-4 py-3`:`px-5 pt-3 pb-2.5`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,Q.jsx)(`h1`,{ref:a,tabIndex:-1,className:`m-0 min-w-0 flex-[1_1_240px] text-pretty wrap-anywhere text-[17px] font-semibold leading-[1.3] tracking-[-0.01em] text-fg-1`,children:e.title}),!i&&(0,Q.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(G,{variant:`ghost`,size:`sm`,icon:ht,disabled:!t,onClick:s,children:`Comment on review`}),(0,Q.jsx)(_c,{})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-fg-3 [font:var(--type-meta)]`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 wrap-anywhere`,children:[(0,Q.jsx)(Gc,{origin:e.origin,dot:!0,className:`size-[7px] opacity-85`}),e.origin.name]}),e.state!==`open`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`text-line-strong`,children:`·`}),(0,Q.jsx)(qc,{state:e.state})]}),e.snoozed&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`text-line-strong`,children:`·`}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 whitespace-nowrap font-medium`,children:[(0,Q.jsx)(j,{icon:Ao,size:12}),e.snoozedUntil?kc(e.snoozedUntil,Date.now())?`Waking up`:`Snoozed until ${Ac(e.snoozedUntil,Date.now())}`:`Snoozed until it changes`]})]}),c&&c!==`approved`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`text-line-strong`,children:`·`}),(0,Q.jsx)(Uc,{status:c,pickedUpAt:e.pickedUpAt,now:l,className:`font-normal text-fg-3`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3.5 gap-y-1.5 font-mono text-12 leading-[1.2] font-stretch-mono text-fg-3`,children:[e.branch&&(0,Q.jsxs)(`span`,{className:p,children:[(0,Q.jsx)(j,{icon:es,size:13}),e.branch]}),!i&&d&&(0,Q.jsxs)(`span`,{className:p,children:[(0,Q.jsx)(j,{icon:ns,size:13}),d]}),t?.files.length===0&&(0,Q.jsxs)(`span`,{className:p,children:[(0,Q.jsx)(j,{icon:ke,size:13}),t.docs.length,` `,V(t.docs.length,`doc`),` · no code changes`]}),(0,Q.jsx)(Gu,{review:e,seq:n,onChange:o})]}),f.length>0&&(0,Q.jsx)(`ul`,{"aria-label":`Links`,className:`m-0 flex min-w-0 list-none flex-wrap items-center gap-1.5 p-0 text-12 leading-[1.2]`,children:f.map((e,t)=>(0,Q.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,Q.jsxs)(`a`,{href:e.href,title:e.href,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`inline-flex max-w-full items-center gap-1 rounded-sm border border-line-1 px-1.5 py-[3px] text-fg-2 no-underline hover:bg-hover hover:text-fg-1`,children:[(0,Q.jsx)(j,{icon:Ku[e.kind??`other`],size:12}),(0,Q.jsx)(`span`,{className:`min-w-0 shrink-[0.2] truncate`,children:e.label}),(0,Q.jsx)(`span`,{className:`min-w-0 shrink-[3] truncate text-11 text-fg-3`,children:e.host})]})},`${t}:${e.url}`))}),e.importedAt&&(0,Q.jsxs)(`p`,{className:`m-0 wrap-anywhere text-fg-3 [font:var(--type-meta)]`,children:[`Copied from `,e.origin.name,` on `,new Date(e.importedAt).toLocaleDateString(),`. Comments, Sends and approvals before then were made there.`]}),r>n&&(0,Q.jsxs)(iu,{tone:`info`,actionLabel:`Show`,onAction:()=>o(r),children:[`Revision `,r,` is ready.`]})]})}function Yu({label:e,hint:t,error:n,maxLength:r,value:i,defaultValue:a,onChange:o,rows:s=3,id:c,className:l,ref:u,...d}){let[f,p]=(0,Y.useState)(String(a??``).length),m=(0,Y.useRef)(null),h=(0,Y.useCallback)(e=>{if(m.current=e,typeof u==`function`)return u(e);u&&(u.current=e)},[u]);(0,Y.useEffect)(()=>{let e=m.current,t=e?.form;if(i!=null||!e||!t)return;let n,r=()=>{window.clearTimeout(n),n=window.setTimeout(()=>p(e.value.length),0)};return t.addEventListener(`reset`,r),()=>{t.removeEventListener(`reset`,r),window.clearTimeout(n)}},[i,d.form]);let g=i==null?f:String(i).length,_=r!=null&&g>r,v=r!=null&&g>=r*.9,y=el(c,t,n,d[`aria-describedby`]),b=`${y.id}-count`;return(0,Q.jsxs)(`div`,{className:U(Xc,l),children:[(e||r!=null)&&(0,Q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[e&&(0,Q.jsx)(`label`,{htmlFor:y.id,className:`font-sans text-13 font-medium leading-(--lh-snug) text-fg-1`,children:e}),r!=null&&(0,Q.jsxs)(`span`,{id:b,"aria-live":v?`polite`:`off`,"aria-atomic":`true`,className:U(`font-mono text-11 font-medium leading-(--lh-snug) font-stretch-mono text-fg-3`,_&&`text-danger-fg`),children:[g,` / `,r]})]}),(0,Q.jsx)(`textarea`,{...d,ref:h,id:y.id,rows:s,value:i,defaultValue:a,onChange:e=>{p(e.target.value.length),o?.(e)},"aria-invalid":n||_?!0:d[`aria-invalid`],"aria-describedby":[y.describedBy,r!=null&&b].filter(Boolean).join(` `)||void 0,className:U(Qc,`h-auto min-h-[76px] resize-y py-2 font-sans leading-[1.5]`)}),(0,Q.jsx)(tl,{id:y.messageId,hint:t,error:n})]})}var Xu=2e3,Zu=`\xA0`;function Qu({reviewId:e,compact:t=!1}){let n=`/emend:emend-feedback ${e}`,r=(0,Y.useRef)(null),i=(0,Y.useRef)(void 0),[a,o]=(0,Y.useState)(`idle`),[s,c]=(0,Y.useState)(0),l=(0,Y.useRef)(!0);return(0,Y.useEffect)(()=>(l.current=!0,()=>{l.current=!1,window.clearTimeout(i.current)}),[]),(0,Q.jsxs)(`div`,{className:U(`flex min-w-0 flex-col gap-1.5`,t&&`gap-1`),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`code`,{ref:r,className:`min-w-0 break-all rounded-sm border border-line-1 bg-sunken px-2 py-1 font-mono text-12 text-fg-1 select-all`,children:n}),(0,Q.jsx)(G,{size:`sm`,icon:Wo,onClick:()=>{window.clearTimeout(i.current);let e=()=>{l.current&&(o(`copied`),i.current=window.setTimeout(()=>o(`idle`),Xu))},t=()=>{if(!l.current)return;let t=r.current,n=window.getSelection();if(t&&n){let e=document.createRange();e.selectNodeContents(t),n.removeAllRanges(),n.addRange(e)}let i=!1;try{i=typeof document.execCommand==`function`&&document.execCommand(`copy`)}catch{i=!1}i?e():(o(`failed`),c(e=>e+1))};try{navigator.clipboard.writeText(n).then(e,t)}catch{t()}},children:a===`copied`?`Copied`:`Copy`}),(0,Q.jsx)(`span`,{role:`status`,className:U(`text-fg-3 [font:var(--type-meta)]`,a!==`failed`&&`sr-only`),children:a===`failed`?`Select and copy the command${s%2==0?Zu:``}`:a===`copied`?`Command copied`:``})]}),(0,Q.jsxs)(`p`,{className:`m-0 text-fg-3 [font:var(--type-meta)]`,children:[`Run `,(0,Q.jsxs)(`code`,{className:`font-mono`,children:[`emend feedback `,e]}),` and handle the result with the emend-feedback skill.`]})]})}var $u=15e3,ed=Error(`The review refetch did not finish in time.`),td=3e3,nd=3e3;function rd(e,t){if(e.agentWaiting)return`An agent is waiting. It gets this now.`;let n=e.releasedAt?Dc(e.releasedAt):``;return n?t?.state===`settled`?`The agent stopped waiting when you retired this on ${n}.`:t?.snoozed?`The agent stopped waiting when you snoozed this on ${n}.`:`The agent stopped waiting on ${n}.`:`No agent is waiting. emend keeps this until an agent picks it up.`}function id({reviewId:e,agent:t,lifecycle:n,className:r}){return(0,Q.jsxs)(`div`,{className:r,children:[(0,Q.jsx)(`p`,{className:`m-0 text-fg-3 [font:var(--type-meta)]`,children:rd(t,n)}),!t.agentWaiting&&(0,Q.jsx)(Qu,{reviewId:e,compact:!0})]})}function ad({reviewId:e,baseline:t,agent:n,phone:r,onClose:i,returnFocus:a,returnFocusPhone:o}){let s=se(),{waited:c}=t,l=n.pickedUpAt!==null&&n.pickedUpAt!==t.pickedUpAt||n.newestRevision>t.newestRevision&&!n.pendingSend,[u,d]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{l&&d(!0)},[l]);let f=u||l,[p,m]=(0,Y.useState)(!c),[h,g]=(0,Y.useState)(!1),_=(0,Y.useRef)(null),[v,y]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(v)return s.getQueryCache().subscribe(t=>{let[n,r]=t.query.queryKey;n===`review`&&r===e&&t.type===`updated`&&t.action.type===`success`&&!t.action.manual&&y(!1)})},[v,s,e]),(0,Y.useEffect)(()=>{if(f)return;let t=!0,n,r=async()=>{let r=!1;try{r=await nc()}catch{r=!1}if(r||!t)return;let i={cancelRefetch:!1};s.invalidateQueries({queryKey:[`inbox`]},i).catch(()=>void 0);try{await Promise.race([s.invalidateQueries({queryKey:[`review`,e]},{...i,throwOnError:!0}),new Promise((e,t)=>{n=window.setTimeout(()=>t(ed),td)})])}catch(e){t&&(e===ed||e instanceof TypeError)&&y(!0)}window.clearTimeout(n)};if(!c)return r(),()=>{t=!1,window.clearTimeout(n)};let i=window.setTimeout(()=>{m(!0),r()},$u);return()=>{t=!1,window.clearTimeout(i),window.clearTimeout(n)}},[f,c,s,e]),(0,Y.useEffect)(()=>{if(!f||h)return;let e=window.setTimeout(i,nd);return()=>window.clearTimeout(e)},[f,h,i]),(0,Y.useEffect)(()=>{let e=()=>{let e=window.getSelection(),t=_.current?.closest(`[role="alertdialog"], [role="dialog"]`);e&&e.toString()!==``&&e.anchorNode&&t?.contains(e.anchorNode)&&g(!0)};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[]);let b=(0,Q.jsx)(`span`,{role:`status`,ref:_,children:f?`The agent picked up your feedback.`:p?v?`emend cannot reach its server right now, so a pick-up may not show here. If no agent has it yet, hand it over with the command below.`:`No agent has picked this up yet. emend keeps it until one does.`:`Waiting for the agent to pick this up…`}),x=!f&&p&&(0,Q.jsx)(Qu,{reviewId:e}),S=e=>{e||i()},C=()=>g(!0);return(0,Q.jsx)(`div`,{className:`contents`,onPointerDownCapture:C,onKeyDownCapture:C,children:r?(0,Q.jsx)(pe,{side:`bottom`,title:`Sent`,description:b,open:!0,onOpenChange:S,returnFocus:o,children:x}):(0,Q.jsx)(_e,{title:`Sent`,description:b,open:!0,onOpenChange:S,returnFocus:a,preferReturnFocus:!0,actions:(0,Q.jsx)(G,{"data-autofocus":!0,onClick:i,children:`Close`}),children:x?(0,Q.jsx)(`div`,{className:`mt-3`,children:x}):null})})}function od({label:e,options:t,value:n,onChange:r,name:i,variant:a=`cards`,className:o}){let s=(0,Y.useId)();return(0,Q.jsxs)(`fieldset`,{className:U(`m-0 flex min-w-0 flex-col gap-1.5 border-0 p-0`,o),children:[(0,Q.jsx)(`legend`,{className:U(Zc,`mb-2 p-0`),children:e}),t.map((e,t)=>(0,Q.jsxs)(`label`,{className:U(`relative flex cursor-pointer items-start gap-2.5 rounded-md border border-line-1 bg-surface px-3 py-2.5 transition-[border-color,background] duration-(--dur-1) hover:border-line-2 has-checked:border-(--ochre-500) has-checked:bg-accent-tint has-focus-visible:shadow-(--focus-ring)`,a===`plain`&&`border-transparent bg-transparent px-1 py-1.5 hover:border-transparent has-checked:border-transparent has-checked:bg-transparent`),children:[(0,Q.jsx)(`input`,{type:`radio`,className:`peer sr-only`,name:i??s,value:e.value,checked:n===e.value,onChange:()=>r?.(e.value),"aria-describedby":e.description?`${s}-${t}-description`:void 0}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 grid size-4 shrink-0 place-items-center rounded-full border-[1.5px] border-line-strong bg-surface peer-checked:border-fg-1 peer-checked:after:size-2 peer-checked:after:rounded-full peer-checked:after:bg-fg-1 peer-checked:after:content-['']`}),(0,Q.jsxs)(`span`,{className:`flex flex-col gap-0.5 font-sans text-13 font-medium leading-(--lh-snug) text-fg-1`,children:[e.label,e.description&&(0,Q.jsx)(`span`,{id:`${s}-${t}-description`,className:`font-sans text-12 font-normal leading-(--lh-snug) text-fg-3`,children:e.description})]})]},e.value))]})}var sd=z.options.map(e=>({value:e,label:S[e]}));function cd({value:e,onChange:t,disabled:n,cards:r=!1}){return r?(0,Q.jsx)(`fieldset`,{disabled:n,className:`m-0 min-w-0 border-0 p-0`,children:(0,Q.jsx)(od,{label:`Mode`,variant:`cards`,value:e,onChange:e=>t(z.parse(e)),options:sd})}):(0,Q.jsx)(nl,{"aria-label":`Mode`,size:`sm`,options:sd,disabled:n,value:e,onChange:e=>t(z.parse(e.target.value))})}var ld=1e3;function ud({reviewId:e,lifecycle:t,unsentCount:n,phone:r}){let{title:i,state:a,snoozed:s,onDeleted:c}=t,[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(Date.now),[p,m]=(0,Y.useState)(0),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(!1),y=re(e),b=qs(),x=(0,Y.useRef)(null),S=(0,Y.useRef)(!0),C=(0,Y.useRef)(!1),T=(0,Y.useRef)(!1),E=y.isPending;(0,Y.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]);let D=e=>{T.current||(f(Date.now()),g(!1),m(n),u(e))},O=()=>{C.current||u(null)},k=async e=>{if(C.current||T.current)return!1;C.current=!0;try{return await y.mutateAsync(e),e.action===`delete`&&(T.current=!0,S.current&&u(null)),!0}catch(t){return t instanceof Ft&&t.code===`unsent_comments`&&e.action===`retire`?S.current&&g(!0):b.show({tone:`danger`,title:ne(t)}),!1}finally{C.current=!1}},A=async e=>{let t=e.id===`revision`?void 0:e.until;await k({action:`snooze`,body:t?{until:t.toISOString()}:{untilRevision:!0}})&&(S.current&&u(null),b.show({tone:`success`,title:t?`Snoozed until ${Ac(t,Date.now())}`:`Snoozed until it changes`}))},j=async()=>{await k({action:`unsnooze`})&&b.show({tone:`success`,title:`Review unsnoozed`})},ee=async()=>{await k({action:`reopen`})&&b.show({tone:`success`,title:`Review reopened`})},M=n>0,N=n-p,te=N>0?`${N} new unsent ${V(N,`comment`)} arrived.`:h?`New unsent comments arrived.`:N<0?`Some unsent comments were sent or deleted.`:null,P=M?`Discard ${n} unsent ${V(n,`comment`)} and retire`:`Retire`,F=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(l!==`retire`){F.current=null,v(!1);return}let e=F.current!==null&&F.current!==P;if(F.current=P,!e)return;v(!0);let t=setTimeout(()=>v(!1),ld);return()=>clearTimeout(t)},[l,P]);let I=async()=>{_||await k({action:`retire`,body:M?{discardUnsent:!0}:{}})&&(S.current&&u(null),b.show({tone:`success`,title:`Review retired`}))},ie=async()=>{await k({action:`delete`})&&(c(),b.show({tone:`success`,title:`Deleted “${i}”`}))},L=[];a===`open`&&(L.push({label:s?`Snooze again`:`Snooze`,icon:wo,opensDialog:!0,onSelect:()=>D(`snooze`)}),s&&L.push({label:`Unsnooze`,icon:Ao,onSelect:()=>void j()}),L.push({label:`Retire`,icon:Eo,opensDialog:!0,onSelect:()=>D(`retire`)})),a===`settled`&&L.push({label:`Reopen`,icon:Bs,onSelect:()=>void ee()}),L.length>0&&L.push({separator:!0}),L.push({label:`Delete`,icon:o,danger:!0,opensDialog:!0,onSelect:()=>D(`delete`)});let R=(0,Q.jsx)(G,{"data-autofocus":!0,disabled:E,onClick:O,children:`Cancel`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yt,{label:`More review actions`,size:r?`lg`:`md`,triggerRef:x,trigger:(0,Q.jsx)(w,{label:`More review actions`,icon:vt,size:r?`lg`:`md`,tooltip:!1,"aria-disabled":E,"aria-busy":E,onPointerDown:e=>E&&e.preventDefault(),onKeyDown:e=>{E&&[` `,`Enter`,`ArrowDown`,`ArrowUp`].includes(e.key)&&e.preventDefault()}}),items:L}),(0,Q.jsx)(_e,{open:l===`snooze`,returnFocus:x,onOpenChange:e=>!e&&O(),title:`Snooze this review`,description:`It leaves your active list until then. A new revision wakes it early.`,actions:R,children:(0,Q.jsx)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:jc(new Date(d)).map(e=>(0,Q.jsxs)(G,{fullWidth:!0,disabled:E,className:`justify-start`,onClick:()=>void A(e),children:[(0,Q.jsx)(`span`,{children:e.label}),e.id!==`revision`&&(0,Q.jsxs)(`span`,{className:`font-normal text-fg-3`,children:[` · `,Ac(e.until,d)]})]},e.id))})}),(0,Q.jsx)(_e,{open:l===`retire`,returnFocus:x,onOpenChange:e=>!e&&O(),title:`Retire this review?`,description:M?`It moves to Done without an approval, and an agent waiting on it stops. Its ${n} unsent ${V(n,`comment`)} will be deleted.`:`It moves to Done without an approval, and an agent waiting on it stops.`,actions:(0,Q.jsxs)(Q.Fragment,{children:[R,(0,Q.jsx)(G,{variant:M?`danger`:`primary`,loading:E,"aria-disabled":_||void 0,onClick:()=>void I(),children:P})]}),children:te&&(0,Q.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-13 text-danger-fg`,children:te})}),(0,Q.jsx)(_e,{open:l===`delete`,returnFocus:x,onOpenChange:e=>!e&&O(),title:`Delete “${i}”?`,description:`This removes the review, its revisions, comments and Sends for good. An agent waiting on it stops. This cannot be undone.`,actions:(0,Q.jsxs)(Q.Fragment,{children:[R,(0,Q.jsx)(G,{variant:`danger`,loading:E,onClick:()=>void ie(),children:`Delete review`})]})})]})}function dd({reviewId:e,revision:t,newestRevision:n,revisionError:r=!1,unsentCount:i,approved:o=!1,lifecycle:s,agent:c,phone:l=!1}){let[u,d]=(0,Y.useState)(ie),f=ce(e),p=(0,Y.useSyncExternalStore)(Ye,()=>st(f)),m=(0,Y.useSyncExternalStore)(Ye,()=>St(e).length),h=(0,Y.useSyncExternalStore)(Ye,()=>a(e)),g=(0,Y.useSyncExternalStore)(Ye,()=>ze(e)),_=/Mac|iPhone|iPad|iPod/.test(navigator.platform)?`⌘↵`:`Ctrl ↵`,[v,y]=(0,Y.useState)(!1),b=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]);let x=(0,Y.useRef)(!1),S=(0,Y.useRef)(null),[w,T]=(0,Y.useState)(!1),E=(0,Y.useRef)(c);(0,Y.useLayoutEffect)(()=>{E.current=c});let D=(0,Y.useRef)(!1),O=(0,Y.useRef)(null),[k,A]=(0,Y.useState)(null),M=(0,Y.useRef)(null),N=(0,Y.useCallback)(()=>A(null),[]),te=(0,Y.useCallback)(()=>{let e=M.current;M.current=null,e&&A(e)},[]),P=(0,Y.useRef)(null);(0,Y.useLayoutEffect)(()=>{let e=P.current;if(!e||l||(e.style.height=``,!p||CSS.supports?.(`field-sizing`,`content`)))return;e.style.height=`auto`;let t=getComputedStyle(e),n=(Number.parseFloat(t.borderTopWidth)||0)+(Number.parseFloat(t.borderBottomWidth)||0);e.style.height=`${e.scrollHeight+n}px`},[p,l]);let F=(0,Y.useRef)(!1),re=(0,Y.useCallback)(e=>{if(!e)return;let t=e.closest(`[role="dialog"]`);return()=>{F.current=t?.contains(document.activeElement)??!1}},[]),I=oe(e),L=I.isPending||g;D.current=v,(0,Y.useEffect)(()=>{l||te()},[l,te]),(0,Y.useEffect)(()=>{if(l){F.current=!1;return}v&&y(!1);let e=P.current;F.current&&e&&!L&&(F.current=!1,document.activeElement===document.body&&e.focus())},[l,v,L]);let R=qs(),ae=(0,Y.useId)(),se=(0,Y.useId)(),z=(0,Y.useId)(),le=(0,Y.useId)(),ue=(0,Y.useId)(),de=s?.state===`settled`,fe=!o&&(!de||!!c?.releasedAt),me=t===void 0?r?`Could not load this revision.`:`Loading revision…`:void 0,B=t!==void 0&&t<n?`Revision ${n} is newer. Switch to it to send or approve.`:void 0,he=L||h||m>0||t===void 0||!!B||de,ge=i>0&&!o&&!de,ve=h||m>0||t===void 0||!!B||de||i>0||o;(0,Y.useEffect)(()=>{w&&ve&&!L&&(o&&Ce(!0),T(!1))},[w,ve,L,o]);let ye=(0,Y.useRef)(null),[Se,Ce]=(0,Y.useState)(!1),we=m?m===1?`1 unsaved comment: save or discard it first.`:`${m} unsaved comments: save or discard them first.`:void 0,Te=de?`This review is retired. Reopen it to send or approve.`:void 0,W=Te??we??(p.length>xe.instructionChars?`Shorten the instructions to ${xe.instructionChars} characters.`:i===0&&!p.trim()?`Write a comment or an instruction first.`:void 0),Ee=`${i} ${V(i,`comment`)}`,De=e=>{x.current||I.reset(),e?gt(f,e):C(f)},Oe=e=>{x.current||I.reset(),d(e)},ke=async n=>{if(x.current||he||St(e).length>0||a(e)||ze(e)||(n===`go`?W:i>0||o)||!be(e))return;x.current=!0;let r={waited:E.current?.agentWaiting??!1,pickedUpAt:E.current?.pickedUpAt??null,newestRevision:E.current?.newestRevision??0};try{if(await I.mutateAsync({path:`/api/v1/reviews/${encodeURIComponent(e)}/sends`,body:n===`approve`?{revision:t,kind:n}:{revision:t,kind:n,mode:u,instruction:p},refresh:`background`,accepted:n===`approve`?`approve`:`send`}),n===`go`&&ee(f,p),!b.current)return;n===`go`?(l&&D.current?M.current=r:A(r),y(!1)):(Ce(!0),T(!1),R.show({tone:`success`,title:`Approved revision ${t}`}))}catch{}finally{x.current=!1,H(e)}},Ae=I.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`m-0 text-13 text-danger-fg`,children:ne(I.error)}),je=W&&(0,Q.jsx)(`span`,{id:z,className:`text-fg-3 [font:var(--type-meta)]`,children:W}),Me=B&&(0,Q.jsx)(`span`,{id:ue,children:B}),Ne=[me&&le,W&&z,B&&ue].filter(Boolean).join(` `)||void 0,Pe=(0,Q.jsx)(`span`,{id:se,children:`Send or delete before approving`}),Fe=(0,Q.jsx)(G,{ref:S,variant:`approve`,size:l?`lg`:`md`,icon:Ie,disabled:he||i>0||o,"aria-describedby":[ge&&se,(we||Te)&&z,me&&le,B&&ue].filter(Boolean).join(` `)||void 0,onClick:()=>{x.current||(I.reset(),Ce(!1),T(!0))},children:o?`Approved`:l||t===void 0?`Approve`:`Approve revision ${t}`}),Le=s&&(0,Q.jsx)(ud,{reviewId:e,lifecycle:s,unsentCount:i,phone:l}),Re=(0,Q.jsxs)(`div`,{ref:ye,tabIndex:-1,className:U(`flex min-w-0 flex-col gap-0.5 outline-none`,l&&`flex-1 overflow-hidden`),children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 whitespace-nowrap text-13 font-semibold leading-[1.2] text-fg-1`,children:[i>0&&(0,Q.jsx)(`span`,{"aria-hidden":!l||void 0,className:`inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-accent px-[5px] text-[10.5px] font-semibold tabular-nums text-accent-fg`,children:i}),i>0&&` `,l?i>0?`unsent`:`Nothing to send`:i>0?`${i} unsent ${V(i,`comment`)}`:`No unsent comments`]}),(0,Q.jsxs)(`span`,{className:`text-fg-3 [font:var(--type-meta)]`,children:[t!==void 0&&`Revision ${t}`,!l&&ge&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,Pe]}),!l&&W&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,je]}),!l&&B&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,Me]})]})]});return(0,Q.jsxs)(`section`,{"aria-label":`Send and approve`,className:`shrink-0 border-t border-line-1 bg-surface`,children:[l?(0,Q.jsxs)(`div`,{className:`flex min-h-[52px] flex-nowrap items-center gap-2.5 py-1.5 pr-2.5 pl-3.5`,children:[Re,(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-nowrap items-center gap-1.5 [&>*]:shrink-0`,children:[Le,Fe,(0,Q.jsx)(pe,{side:`bottom`,title:`Send feedback`,open:v,onClosed:te,onOpenChange:e=>{e&&!x.current&&I.reset(),y(e)},trigger:(0,Q.jsx)(G,{ref:O,variant:`primary`,size:`lg`,icon:Os,disabled:he,loading:L,"aria-describedby":[me&&le,(we||Te)&&z,B&&ue].filter(Boolean).join(` `)||void 0,children:`Send`}),footer:(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,children:[je,B&&(0,Q.jsx)(`p`,{className:`m-0 text-fg-3 [font:var(--type-meta)]`,children:Me}),me&&(0,Q.jsx)(`p`,{id:le,role:r?`alert`:`status`,className:`m-0 text-fg-3 [font:var(--type-meta)]`,children:me}),Ae,(0,Q.jsx)(G,{type:`submit`,form:ae,variant:`primary`,size:`lg`,fullWidth:!0,icon:Os,disabled:he||!!W,loading:L,"aria-describedby":Ne,children:i>0?`Send ${Ee} on revision ${t??`…`}`:`Send instructions on revision ${t??`…`}`})]}),children:(0,Q.jsxs)(`form`,{ref:re,id:ae,className:`space-y-4`,onKeyDown:e=>{e.key===`Enter`&&e.target instanceof HTMLInputElement&&e.target.type===`radio`&&e.preventDefault()},onSubmit:e=>{e.preventDefault(),ke(`go`)},children:[(0,Q.jsx)(cd,{cards:!0,value:u,onChange:Oe,disabled:L}),(0,Q.jsx)(Yu,{label:`Instructions`,placeholder:`Optional. Applies to every comment in this Send.`,rows:2,maxLength:xe.instructionChars,disabled:L,value:p,onChange:e=>De(e.target.value)}),fe&&c&&(0,Q.jsx)(id,{reviewId:e,agent:c,lifecycle:s})]})})]})]}):(0,Q.jsxs)(`form`,{className:`flex min-h-(--sendbar-h) items-center gap-2.5 py-2 pr-3 pl-4`,onSubmit:e=>{e.preventDefault(),ke(`go`)},children:[Re,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 justify-end gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative flex min-w-0 max-w-[520px] flex-1 items-center`,children:[(0,Q.jsx)(j,{icon:xt,size:14,className:`pointer-events-none absolute left-[9px] text-fg-3`}),(0,Q.jsx)(`textarea`,{ref:P,"aria-label":`Instructions`,rows:1,enterKeyHint:`enter`,placeholder:`Instructions for the agent (optional)`,className:U(Qc,$c.sm,`min-h-7 max-h-32 resize-none overflow-y-auto py-[3px] pl-[30px] leading-5`,p&&`h-auto [field-sizing:content]`),maxLength:xe.instructionChars,disabled:L,value:p,onChange:e=>De(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.nativeEvent.isComposing&&e.keyCode!==229&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,Q.jsx)(`kbd`,{className:`ml-1.5 shrink-0 text-fg-3 [font:var(--type-meta)]`,children:_})]}),(0,Q.jsx)(cd,{value:u,onChange:Oe,disabled:L})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[Le,Fe,(0,Q.jsx)(G,{type:`submit`,variant:`primary`,icon:Os,disabled:he||!!W,loading:L,"aria-describedby":Ne,children:i>0?`Send ${i}`:`Send`})]})]}),!l&&fe&&c&&(0,Q.jsx)(id,{reviewId:e,agent:c,lifecycle:s,className:`px-4 pb-2`}),(0,Q.jsx)(_e,{open:w,returnFocus:Se?ye:S,preferReturnFocus:Se,onOpenChange:e=>{!e&&!L&&T(!1)},title:t===void 0?`Approve this revision?`:`Approve revision ${t}?`,description:`The agent receives the approval, now if one is waiting and otherwise when it next picks up. The review moves to Done.`,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(G,{"data-autofocus":!0,disabled:L,onClick:()=>T(!1),children:`Cancel`}),(0,Q.jsx)(G,{variant:`approve`,loading:L,onClick:()=>void ke(`approve`),children:`Approve`})]}),children:Ae&&(0,Q.jsx)(`div`,{className:`mt-2`,children:Ae})}),k&&(0,Q.jsx)(ad,{reviewId:e,baseline:k,agent:c??{agentWaiting:!1,pendingSend:!0,pickedUpAt:null,releasedAt:null,newestRevision:0},phone:l,onClose:N,returnFocus:P,returnFocusPhone:()=>O.current}),(!l||!v)&&(me||l&&(ge||B||we||Te)||I.error&&!w)&&(0,Q.jsxs)(`div`,{className:`space-y-1 px-4 pb-2`,children:[me&&(0,Q.jsx)(`p`,{id:le,role:r?`alert`:`status`,className:`m-0 text-fg-3 [font:var(--type-meta)]`,children:me}),l&&ge&&(0,Q.jsx)(`p`,{className:`m-0 text-fg-3 [font:var(--type-meta)]`,children:Pe}),l&&(we||Te)&&je,l&&B&&(0,Q.jsx)(`p`,{className:`m-0 text-fg-3 [font:var(--type-meta)]`,children:Me}),!w&&Ae]})]})}function fd({reviewId:e,topics:t,onResume:n}){let[r,i]=(0,Y.useState)(()=>St(e));return(0,Y.useEffect)(()=>{let t=()=>i(St(e));return t(),Ye(t)},[e]),r.length?(0,Q.jsxs)(`section`,{"aria-label":`Unsaved comments`,className:`space-y-3`,children:[(0,Q.jsxs)(`h2`,{className:`em-comment-group`,children:[`Unsaved comments`,(0,Q.jsx)(`span`,{children:r.length})]}),r.map(e=>{let{label:r,icon:i}=e.commentId?{label:`Unsaved edit`,icon:xt}:e.target?s(e.target,t):{label:`Unreadable target`,icon:ot};return(0,Q.jsxs)(`article`,{className:`rounded-lg border border-line-1 bg-surface px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`em-card__target`,title:r,children:[(0,Q.jsx)(j,{icon:i,size:13}),(0,Q.jsx)(`span`,{children:r})]}),(0,Q.jsx)(`p`,{className:`my-2 line-clamp-2 whitespace-pre-wrap wrap-anywhere text-fg-2 [font:var(--type-body)]`,children:st(e.key)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(e.target||e.commentId)&&(0,Q.jsx)(G,{variant:`ghost`,size:`sm`,onClick:()=>n(e),children:`Resume`}),(0,Q.jsx)(G,{variant:`ghost`,size:`sm`,icon:o,onClick:()=>C(e.key),children:`Discard`})]})]},e.key)})]}):null}function pd({reviewId:e,revision:t,threads:n,changedBlocks:r,topics:i,search:a={},phone:o=!1,onResume:s}){let c=(0,Y.useSyncExternalStore)(Ye,()=>St(e).length>0),l={reviewId:e,revision:t,changedBlocks:r,topics:i,surface:`comments`};return(0,Q.jsxs)(`div`,{className:`space-y-6 px-4 pt-4 pb-8 md:mx-auto md:max-w-[calc(1000px+88px)] md:pt-7 md:pr-8 md:pb-[72px] md:pl-14`,children:[(0,Q.jsx)(fd,{reviewId:e,topics:i,onResume:s}),!c&&n.length===0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`p`,{children:`No comments yet.`}),(0,Q.jsx)(`p`,{className:`text-fg-3 [font:var(--type-meta)]`,children:`Select text in the writeup or a doc, or click a line in the diff.`})]}),[`unsent`,`sent`,`answered`,`open`,`unplaced`,`resolved`].map(t=>{let r=n.filter(e=>(e.placement.status===`unplaced`?`unplaced`:_t(e))===t);if(!r.length)return null;let i=t[0]?.toUpperCase()+t.slice(1);return(0,Q.jsxs)(`section`,{"aria-label":i,className:`space-y-3`,children:[(0,Q.jsxs)(`h2`,{className:`em-comment-group`,children:[i,(0,Q.jsx)(`span`,{children:r.length})]}),r.map(t=>(0,Q.jsx)(Oe,{...l,thread:t,showInPlace:ct(e,t,a,o)},t.id))]},t)})]})}function md(e){if(e.main===`writeup`)return{tab:`writeup`};let t=e.docs.find(t=>t.path===e.main);if(t)return{tab:`docs`,doc:t.path};if(!e.writeupEmpty)return{tab:`writeup`};let n=e.docs[0];return n?{tab:`docs`,doc:n.path}:e.files.some(e=>e.role===`diff`)?{tab:`diff`}:{tab:`writeup`}}var hd=`emend.reading.v1`,gd=O({id:de().min(1).max(600),fraction:x().min(0).max(1),at:x().finite()}),_d=te(de(),Lt());function vd(e,t,n=``){return[e,t,n].join(`
|
|
4
|
-
`)}function yd(){try{let e=_d.safeParse(JSON.parse(localStorage.getItem(`emend.reading.v1`)??`{}`));if(!e.success)return{};let t={};for(let[n,r]of Object.entries(e.data)){let e=gd.safeParse(r);e.success&&(t[n]=e.data)}return t}catch{return{}}}function bd(e){let t=yd()[e];return t?{id:t.id,fraction:t.fraction}:void 0}function xd(e,t,n=Date.now()){try{let r=yd();t?r[e]={id:t.id,fraction:Math.min(1,Math.max(0,t.fraction)),at:n}:delete r[e];let i=Object.entries(r).sort((e,t)=>t[1].at-e[1].at).slice(0,200);localStorage.setItem(hd,JSON.stringify(Object.fromEntries(i)))}catch{}}var Sd=e=>e.width===0&&e.height===0;function Cd(e,t){if(e.scrollTop<=0)return null;let n=e.getBoundingClientRect().top,r=Array.from(e.querySelectorAll(t)),i=e=>r[e],a,o=0,s=r.length;for(;o<s;){let e=o+s>>1,t=e,r=i(t).getBoundingClientRect();for(;Sd(r)&&++t<s;)r=i(t).getBoundingClientRect();t>=s?s=e:r.bottom>n?(a={element:i(t),rect:r},s=e):o=t+1}if(a){let e=a.rect.height>0?(n-a.rect.top)/a.rect.height:0;return{id:a.element.id,fraction:Math.min(1,Math.max(0,e))}}for(let e=r.length-1;e>=0;e--)if(!Sd(i(e).getBoundingClientRect()))return{id:i(e).id,fraction:1};return null}function wd(e,t){let n=document.getElementById(t.id);if(!n||!e.contains(n))return;let r=n.getBoundingClientRect(),i=r.top+t.fraction*r.height-e.getBoundingClientRect().top;return Math.abs(i)>=1&&(e.scrollTop+=i),e.scrollTop}var Td=[0,100,300,800,1500],Ed=250,Dd=new WeakMap,Od=new Set([`PageUp`,`PageDown`,`Home`,`End`,`ArrowUp`,`ArrowDown`,` `]),kd=`input, textarea, select, [contenteditable]:not([contenteditable="false"])`;function Ad({storageKey:e,selector:t,active:n,intentState:r}){let i=(0,Y.useRef)(r);i.current=r,(0,Y.useLayoutEffect)(()=>{if(!n)return;let r=document.querySelector(`[data-reading-scroll]`);if(!r)return;let a=new Set,o=i.current().epoch,s=Dd.get(r),c=s!==void 0&&s!==e;Dd.set(r,e);let l=!1,u=!1,d=!1,f=null,p,m=()=>{l=!1;for(let e of a)clearTimeout(e);a.clear()},h=()=>{d&&(d=!1,xd(e,f))},g=()=>{u&&(f=Cd(r,t),d=!0,p===void 0&&(h(),p=setTimeout(()=>{p=void 0,h()},Ed)))},_=()=>{u=!0,m()},v=()=>{document.visibilityState===`hidden`&&h()};r.addEventListener(`scroll`,g,{passive:!0});let y=e=>{if(e.defaultPrevented||!Od.has(e.key))return;let t=e.target;t instanceof Node&&(t===document.body||r.contains(t))&&(t instanceof HTMLElement&&t.closest(kd)||_())};r.addEventListener(`wheel`,_,{passive:!0}),r.addEventListener(`touchstart`,_,{passive:!0}),r.addEventListener(`touchmove`,_,{passive:!0}),r.addEventListener(`pointerdown`,_,{passive:!0}),window.addEventListener(`keydown`,y),window.addEventListener(`pagehide`,h),document.addEventListener(`visibilitychange`,v);let b=bd(e);l=!0;let x=e=>{if(!l)return;let t=i.current();if(t.current||t.epoch!==o){m();return}let n=b?wd(r,b):void 0;e&&n===void 0&&c&&(r.scrollTop=0)};return Td.forEach((e,t)=>{let n=setTimeout(()=>{a.delete(n),(b||t===0)&&x(t===0),t===Td.length-1&&m()},e);a.add(n)}),()=>{h(),m(),clearTimeout(p),r.removeEventListener(`scroll`,g),r.removeEventListener(`wheel`,_),r.removeEventListener(`touchstart`,_),r.removeEventListener(`touchmove`,_),r.removeEventListener(`pointerdown`,_),window.removeEventListener(`keydown`,y),window.removeEventListener(`pagehide`,h),document.removeEventListener(`visibilitychange`,v)}},[n,e,t])}function jd({reviewId:e,revision:t,tab:n,onResume:r,htmlNavigation:i,composingPath:a,resumedBlockId:o,activeThreadId:s,threadJump:c,search:l,phone:u,openDoc:d,targeted:f,onOpenDoc:p,onCurrentTopic:m,onNote:h,visible:g,intentState:_}){Ad({storageKey:vd(e,n,n===`docs`?d?.path??``:``),selector:n===`comments`?`[id^="thread-"]`:`[id^="block-"], [id^="html-doc-"]`,active:g,intentState:_});let v={reviewId:e,revision:t.seq,threads:t.threads,changedBlocks:t.changedBlocks,topics:t.topics,activeThreadId:s,threadJump:c};return n===`comments`?(0,Q.jsx)(pd,{...v,search:l,phone:u,onResume:r}):n===`docs`?(0,Q.jsx)(Lu,{...v,docs:t.docs,openDoc:d,search:l,targeted:f,onOpenDoc:p,navigation:i,composingPath:a,resumedBlockId:o}):(0,Q.jsx)(Wu,{...v,writeup:t.writeup,files:t.files,search:l,phone:u,visible:g,resumedBlockId:o,onCurrentTopic:m,onNote:h})}function Md(e,t){if(e.threadId)return t.threads.find(t=>t.id===e.threadId)?.placement;let n=e.target;if(n?.kind===`writeup-span`)return It(t.writeup.sections.flatMap(e=>e.blocks),n);if(n?.kind===`doc-span`){let e=t.docs.find(e=>e.path===n.path);return It(e?.kind===`markdown`?e.blocks:[],n)}}function Nd(e,t,n){let r=e.tab===`comments`&&!!e.thread;return{navigation:JSON.stringify([n,e.tab,e.doc,e.thread,t]),elementId:r?`thread-${e.thread}`:t,reply:r,threadId:e.thread??(t.startsWith(`thread-`)?t.slice(7):void 0),routeThread:!0,block:`center`}}function Pd(e,t,n,r,i){let a=e.docs.find(e=>e.path===t.doc);if(a)return a;let o=e.threads.find(e=>e.id===n.threadId),s=o?.placement.status===`placed`?o.placement.location:void 0;return e.docs.find(e=>n.elementId===`doc-${e.path}`||n.elementId===`html-doc-${e.path}`||e.kind===`markdown`&&e.blocks.some(e=>n.elementId===`block-${e.id}`)||(s?.kind===`doc-span`||s?.kind===`html-span`)&&s.path===e.path&&e.kind===(s.kind===`html-span`?`html`:`markdown`))??e.docs.find(e=>e.path===r)??(i&&e.docs.length===1?e.docs[0]:void 0)}function Fd({review:e,published:t,titleRef:n,collapsed:r,setCollapsed:i}){let a=So(),o=(0,Y.useMemo)(()=>Ld(a.search),[a.search]),s=a.hash,[c]=(0,Y.useState)(e.newestRevision),l=o.rev??c,u=(0,Y.useMemo)(()=>({reviewId:e.id,revision:l,choices:new Map}),[e.id,l]),d=Ee(Rc(e.id,l)),f=N(e.id),p=D(e.id),m=(e,t)=>f.mutate({revision:l,paths:e,viewed:t}),{counts:h}=bt(),g=Fa({from:`/r/$reviewId`}),_=se();ol([e.snoozedUntil],()=>{_.invalidateQueries({queryKey:[`review`,e.id]}),_.invalidateQueries({queryKey:[`inbox`]})});let v=Tt(),y=Le(),b=(0,Y.useId)(),[,x]=(0,Y.useState)(0),S=(0,Y.useCallback)(()=>x(e=>e+1),[]),C=(0,Y.useRef)(null),w=(0,Y.useCallback)(e=>{C.current=e},[]),[T,E]=(0,Y.useState)(),O=ue(e.id,d.data),k=O?.files.filter(e=>e.role===`diff`)??[],[A,j]=(0,Y.useState)(null),ee=A&&O?Md(A,O):void 0,M=ee?.status===`placed`&&`blockId`in ee.location?ee.location.blockId:void 0,te=()=>j(e=>e===A?null:e);(0,Y.useEffect)(()=>{if(!A)return;let e=()=>{Se(A.key)||j(e=>e===A?null:e)};return e(),Ye(e)},[A]);let P=(O?.docs.length??0)>0||A?.tab===`docs`,F=(O?.files.some(e=>e.role===`diff`)??!1)||A?.tab===`diff`,re=!!O&&(!O.writeupEmpty||O.main===`writeup`)||A?.tab===`writeup`,I=O?md(O):{tab:`writeup`},ie=!o.tab||!{writeup:re,files:k.length>0,diff:F,docs:P,comments:!0}[o.tab],R=ie?I.tab:o.tab??I.tab,[ae,oe]=(0,Y.useState)();R!==`diff`&&ae!==R&&oe(R);let z=R===`diff`?v!==`phone`&&y===`tabs`&&ae||(re?`writeup`:P?`docs`:`comments`):R,ce=z===`docs`&&(y===`split`||R!==`diff`),le=Nd(o,s,l),de=O?Pd(O,o,le,ie?I.doc:void 0,ce):void 0,fe=e=>{g({search:{...o,tab:R,rev:e}})},[pe,me]=(0,Y.useState)(null),[B,he]=(0,Y.useState)(),[ge,_e]=(0,Y.useState)(),ve=(0,Y.useRef)(null),V=(0,Y.useRef)(null),ye=(0,Y.useRef)(0),be=(0,Y.useRef)(-1),xe=(0,Y.useRef)(0),Ce=(0,Y.useCallback)(()=>({current:be.current===ye.current,epoch:xe.current}),[]),H=(0,Y.useCallback)((e,t=``)=>{me({...Nd(e,t,e.rev??c),token:{},jumpThread:!0}),g({search:e,hash:t})},[c,g]),U=(0,Y.useCallback)(e=>H({...o,tab:y===`tabs`||v===`phone`?`diff`:`writeup`,thread:void 0},`diff-note-${e}`),[H,o,y,v]),we=t=>{if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null;if(!(n instanceof HTMLAnchorElement)||n.hasAttribute(`download`)||n.target&&n.target!==`_self`)return;let r=new URL(n.href);if(r.origin!==window.location.origin||r.pathname!==`/r/${encodeURIComponent(e.id)}`)return;t.preventDefault();let i=Ld(Object.fromEntries(r.searchParams));H({...i,rev:i.rev??o.rev},r.hash.slice(1))},Te=e=>{if(e.commentId&&O){O.threads.find(t=>t.comments.some(t=>t.id===e.commentId))&&(j(null),W(e.key,`comments`),H({...o,tab:`comments`,thread:void 0}));return}if(!e.target||!O)return;let t=e.threadId?O.threads.find(t=>t.id===e.threadId):void 0;if(t){let n=t.placement.status===`placed`?t.placement.location:void 0;j(null),H({...o,tab:`comments`,doc:n?.kind===`doc-span`||n?.kind===`html-span`?n.path:o.doc,thread:e.threadId});return}if(L(e.target)){W(e.key,`diff`),j({...e,tab:`diff`}),H({...o,tab:`diff`,thread:void 0});return}if(W(e.key,`resumed`),e.target.kind===`html-span`){j({...e,tab:`docs`}),H({...o,tab:`docs`,doc:e.target.path,thread:void 0},`html-doc-${e.target.path}`);return}let n=Md(e,O);if(n?.status===`placed`&&`blockId`in n.location){let t=n.location.kind===`doc-span`?`docs`:`writeup`;j({...e,tab:t}),H({...o,tab:t,doc:e.target.kind===`doc-span`?e.target.path:o.doc,thread:void 0},`block-${n.location.blockId}`)}else{let t=e.target.kind===`doc-span`?`docs`:z;j({...e,tab:t}),H({...o,tab:t,doc:e.target.kind===`doc-span`?e.target.path:o.doc,thread:void 0})}},De=()=>{let t={kind:`review`},n=ft(e.id,t);Se(n)||gt(n,``),Te({key:n,target:t})};(0,Y.useEffect)(()=>{let t=le,n=!1;pe&&pe!==V.current?.requested?(ve.current={...pe},n=!0):t.navigation!==V.current?.navigation&&ve.current?.navigation!==t.navigation&&(ve.current={...t,token:{},jumpThread:t.elementId!==V.current?.elementId||t.threadId!==V.current?.threadId},n=!0),n&&(ye.current+=1,ve.current?.jumpThread&&(ve.current.elementId||ve.current.threadId)&&(be.current=ye.current,xe.current+=1)),V.current={navigation:t.navigation,elementId:t.elementId,threadId:t.threadId,requested:pe};let r=ve.current;if(!r||r.navigation!==t.navigation)return;let i=()=>{be.current===ye.current&&(be.current=-1,xe.current+=1),ve.current=null,he(void 0)};if(r.jumpThread&&!r.reply&&r.threadId&&r.elementId===`thread-${r.threadId}`&&r.threadId){if(B?.token!==r.token||B.navigation!==t.navigation){he({threadId:r.threadId,token:r.token,navigation:t.navigation});return}}else if(B){he(void 0);return}if(!O)return;if(ce&&o.doc!==de?.path){let e={...o,doc:de?.path};r.navigation=Nd(e,s,l).navigation,g({search:e,hash:s,replace:!0});return}let a=O.threads.find(e=>e.id===r.threadId);if(r.routeThread){if(r.threadId&&!a)return;if(r.routeThread=!1,_e(void 0),a?.target.kind===`html-span`&&(o.tab!==`comments`||o.thread)){let e=a.placement.status===`placed`?a.placement.location:void 0,t=e?.kind===`html-span`&&O.docs.some(t=>t.kind===`html`&&t.path===e.path),n={...o,tab:t?`docs`:`comments`,doc:t?de?.path??e.path:o.doc},i=`thread-${a.id}`;if(r.elementId=t?`html-doc-${e.path}`:i,t&&(r.block=`start`),r.reply||=!t,t&&_e({threadId:a.id,intent:r}),o.tab!==n.tab||o.doc!==n.doc||s!==i){r.navigation=Nd(n,i,l).navigation,g({search:n,hash:i,replace:!0});return}}}if(!r.elementId){i();return}if(r.reply){if(!a)return;i(),W(ft(e.id,a.target,a.id),o.tab===`docs`?`reading`:`comments`);return}if(r.elementId.startsWith(`diff-`)){if(y===`tabs`&&F&&R!==`diff`){let e={...o,tab:`diff`};r.navigation=Nd(e,s,l).navigation,g({search:e,hash:s,replace:!0});return}C.current?.({elementId:r.elementId})&&i();return}let c=document.getElementById(r.elementId);c&&(i(),Ru(c),c.scrollIntoView?.({block:r.block}))});let Oe={id:e.id,search:{...o,tab:R},hasDocs:P,hasDiff:F,hasWriteup:re,unsentCount:e.unsentCount,filesCount:k.length,viewedCount:k.filter(e=>e.viewed===`viewed`).length},ke=Math.max(t,e.newestRevision);return(0,Q.jsx)(Tc,{isReview:!0,onCommentReview:O?De:void 0,children:(0,Q.jsx)(`div`,{className:`contents`,onClickCapture:we,children:(0,Q.jsx)(mu,{inbox:(0,Q.jsx)(vu,{currentReviewId:e.id,collapsed:r,onCollapsedChange:i}),tab:R,hasDiff:F,phoneTabs:(0,Q.jsx)(gu,{...Oe}),tabs:(0,Q.jsx)(bu,{...Oe,docsCount:O?.docs.length??0,idBase:b}),sendBar:(0,Q.jsx)(dd,{reviewId:e.id,revision:O?.seq,newestRevision:ke,revisionError:d.isError,unsentCount:e.unsentCount,approved:e.state===`approved`,agent:{agentWaiting:e.agentWaiting,pendingSend:e.pendingSend,pickedUpAt:e.pickedUpAt,releasedAt:e.releasedAt,newestRevision:e.newestRevision},lifecycle:{title:e.title,state:e.state,snoozed:e.snoozed,snoozedUntil:e.snoozedUntil,onDeleted:()=>{g({to:`/`}).then(()=>{_.removeQueries({queryKey:[`review`,e.id]}),_.removeQueries({queryKey:[`revision`,e.id]})})}},phone:v===`phone`},e.id),header:(0,Q.jsxs)(Q.Fragment,{children:[p.errors.map(e=>(0,Q.jsxs)(`div`,{role:`alert`,className:`px-4 py-2 text-danger-fg`,children:[(0,Q.jsxs)(`p`,{children:[e.error&&ne(e.error),` `,(0,Q.jsx)(`bdi`,{children:e.failedPaths?.[0]}),(e.failedPaths?.length??0)>1&&` and ${(e.failedPaths?.length??1)-1} other files`]}),(0,Q.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>p.dismiss(e.id),children:`Dismiss`})]},e.id)),(v!==`phone`||R!==`diff`)&&(0,Q.jsx)(Ju,{review:e,revision:O,seq:l,ready:ke,phone:v===`phone`,titleRef:n,onRevisionChange:fe,onCommentReview:De})]}),reading:(0,Q.jsx)(`div`,{className:`contents`,children:(0,Q.jsxs)(`div`,{...v===`phone`?{}:{role:`tabpanel`,id:`${b}-reading-panel`,"aria-labelledby":`${b}-tab-${z}`},children:[d.isPending&&(0,Q.jsx)(`p`,{role:`status`,className:`p-5`,children:`Loading revision…`}),d.isError&&(0,Q.jsxs)(`div`,{className:`p-5`,children:[(0,Q.jsx)(`p`,{role:`alert`,children:`Could not load this revision.`}),(0,Q.jsx)(G,{onClick:()=>void d.refetch(),children:`Retry`})]}),O&&(0,Q.jsx)(Eu,{value:u,children:z===`files`?(0,Q.jsx)(du,{revision:O,counts:h,onViewed:m,onNavigate:e=>H({...o,tab:y===`tabs`?`diff`:`files`,thread:void 0},`diff-file-${e.id}`)}):(0,Q.jsx)(jd,{reviewId:e.id,revision:O,tab:z,visible:y===`split`||R!==`diff`||!F,intentState:Ce,search:o,openDoc:de,targeted:!!s||!!o.thread,activeThreadId:le.threadId,threadJump:B?.navigation===le.navigation?B:void 0,onOpenDoc:e=>H({...o,tab:`docs`,doc:e,thread:void 0}),phone:v===`phone`,onResume:Te,htmlNavigation:ge,composingPath:A?.target?.kind===`html-span`?A.target.path:void 0,resumedBlockId:M,onCurrentTopic:v!==`phone`&&F?E:void 0,onNote:U},`${l}:${z}`)}),A?.target&&!L(A.target)&&(0,Q.jsx)(Be,{surface:`resumed`,placeholder:!1,reviewId:e.id,revision:l,target:A.target,topics:O?.topics,threadId:A.threadId,storageKey:A.key,onSaved:te,onCancel:te,wrap:e=>(0,Q.jsx)(`section`,{"aria-label":`Resumed comment`,className:`sticky bottom-0 px-4 pt-4 pb-8 md:pr-8 md:pl-14`,children:e})})]})}),diff:(0,Q.jsx)(`div`,{...v!==`phone`&&y===`tabs`?{role:`tabpanel`,id:`${b}-diff-panel`,"aria-labelledby":`${b}-tab-diff`}:{},children:O?(0,Q.jsx)(uu,{reviewId:e.id,revision:O,resume:A?.target&&L(A.target)?A:void 0,onResumeEnd:te,onRendered:S,onNavigator:w,currentTopic:T,writeupVisible:z===`writeup`&&y===`split`,search:o,onViewed:m},l):(0,Q.jsx)(`p`,{role:d.isError?`alert`:`status`,className:`p-5`,children:d.isError?`Could not load this revision.`:`Loading revision…`})})})})})}function Id(){let{reviewId:e}=Na({from:`/r/$reviewId`}),t=Ee(Lc(e)),n=uc(e),[r,i]=it(),a=(0,Y.useRef)(e),o=(0,Y.useRef)(!1),s=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{a.current!==e&&(a.current=e,o.current=!0),t.isError&&!t.data&&(o.current=!1),o.current&&t.data?.id===e&&(o.current=!1,s.current?.focus())},[e,t.data,t.isError]),t.error instanceof Ft&&t.error.status===404&&t.error.code===`unknown_review`?(0,Q.jsx)(Tc,{isReview:!0,children:(0,Q.jsxs)(`main`,{className:`p-5`,children:[(0,Q.jsx)(`p`,{role:`status`,children:`This review was deleted or never existed.`}),(0,Q.jsx)($,{to:`/`,children:`Back to the inbox`})]})}):t.data?(0,Q.jsx)(Fd,{review:t.data,published:n,titleRef:s,collapsed:r,setCollapsed:i},e):(0,Q.jsx)(Tc,{isReview:!0,children:(0,Q.jsx)(`main`,{className:`p-5`,children:t.isError?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{role:`alert`,children:`Could not load this review.`}),(0,Q.jsx)(G,{onClick:()=>void t.refetch(),children:`Retry`})]}):(0,Q.jsx)(`p`,{role:`status`,children:`Loading review…`})})})}function Ld(e){let t=typeof e.rev==`string`||typeof e.rev==`number`?Number(e.rev):NaN;return{tab:e.tab===`writeup`||e.tab===`files`||e.tab===`diff`||e.tab===`docs`||e.tab===`comments`?e.tab:void 0,rev:Number.isSafeInteger(t)&&t>0?t:void 0,doc:E.safeParse(e.doc).data,thread:typeof e.thread==`string`&&/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(e.thread)?e.thread:void 0}}var Rd=eo({component:uo,notFoundComponent:()=>(0,Q.jsxs)(`main`,{className:`p-6`,children:[(0,Q.jsx)(`h1`,{children:`Page not found`}),(0,Q.jsx)($,{to:`/`,children:`Inbox`})]})}),zd=Qa({getParentRoute:()=>Rd,path:`/`,component:dl}),Bd=Qa({getParentRoute:()=>Rd,path:`/r/$reviewId`,validateSearch:Ld,component:Id}),Vd=Qa({getParentRoute:()=>Rd,path:`/pair`,component:ml}),Hd=Qa({getParentRoute:()=>Rd,path:`/devices`,component:Fc}),Ud=Qa({getParentRoute:()=>Hd,path:`pair`,component:su}),Wd=e=>{let t=_o({routeTree:Rd.addChildren([zd,Bd,Vd,Hd.addChildren([Ud])]),history:e,search:{strict:!0}});return t.subscribe(`onBeforeNavigate`,Ue),t.update({scrollRestoration:({location:e})=>!/^\/r\/[^/]+\/?$/.test(e.pathname)}),t};function Gd({children:e}){let t=xo({select:e=>/^\/pair\/?$/i.test(e.location.pathname)});return(0,Q.jsx)(lc,{enabled:!t,children:e})}function Kd({queryClient:e,history:t}={}){let[n]=(0,Y.useState)(()=>e??new Jt({defaultOptions:{queries:{retry:!1}}})),[r]=(0,Y.useState)(()=>Wd(t));return(0,Q.jsx)(I,{client:n,children:(0,Q.jsx)(pt,{children:(0,Q.jsx)(Ks,{children:(0,Q.jsx)(bo,{router:r,InnerWrap:Gd})})})})}export{Kd as App};
|