azdiffs 1.0.0 → 1.1.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 +17 -3
- package/dist/cli.js +211 -84
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId-BfEZAJVI.js +1 -0
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.commits._commitId-DvqTmFzX.js +1 -0
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.commits.index-Bd3xdIex.js +1 -0
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.conflicts-DV0pCnK1.js +1 -0
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.files-Mr-AIHvi.js +1 -0
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.index-DoV2Gs7F.js +1 -0
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId-ChLX3uCr.js +1 -0
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.commits._commitId-DXZcIPBR.js +1 -0
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.commits.index-Bd3xdIex.js +1 -0
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.conflicts-DkEZ314x.js +1 -0
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.files-N3xJdxPo.js +1 -0
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.index-Dt7ItZCC.js +1 -0
- package/dist/web/assets/_organization.index-DVTzM87W.js +1 -0
- package/dist/web/assets/commit-diff-view-BNA-1iz5.js +1 -0
- package/dist/web/assets/commits-view-Cq3oHLFX.js +13 -0
- package/dist/web/assets/conflicts-view-Bca0Tnmk.js +8 -0
- package/dist/web/assets/dev.diff-jb6X8hTd.js +1 -0
- package/dist/web/assets/file-header-B2S9b0sl.js +49 -0
- package/dist/web/assets/files-view-C2YnVYtG.js +1460 -0
- package/dist/web/assets/grammars-B3laSCck.js +2 -0
- package/dist/web/assets/{highlights-BJb1-tzP.js → highlights-C-SBVYal.js} +1 -1
- package/dist/web/assets/home-page-BUnNaCN6.js +1 -0
- package/dist/web/assets/inbox-D8-BBgQT.js +1 -0
- package/dist/web/assets/index-DsrXp1aY.js +11 -0
- package/dist/web/assets/overview-view-B9qPTEMk.js +2 -0
- package/dist/web/assets/pull-request-layout-R9F6zMxd.js +35 -0
- package/dist/web/assets/routes-D2t0cGUy.js +1 -0
- package/dist/web/assets/shiki-mTy6Inae.js +1 -0
- package/dist/web/assets/shortcut-help-D99FihA2.js +1 -0
- package/dist/web/assets/{stream-tokenizer-B5Ok5N3S.js → stream-tokenizer-CKeNSKPz.js} +2 -2
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId-D7saE-jO.js +0 -1
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.commits._commitId-DOwGbBTQ.js +0 -1
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.commits.index-DzGjUdAz.js +0 -1
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.conflicts-Cjr34xFt.js +0 -1
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.files-BjjJ4Yb8.js +0 -1
- package/dist/web/assets/_organization.___git._repository.pullrequest._pullRequestId.index-iY62N_zR.js +0 -1
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId-CrHRklAE.js +0 -1
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.commits._commitId-WC7fEryq.js +0 -1
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.commits.index-DzGjUdAz.js +0 -1
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.conflicts-BhUkafpV.js +0 -1
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.files-_RVmv4sD.js +0 -1
- package/dist/web/assets/_organization._project.___git._repository.pullrequest._pullRequestId.index-BJrgfbSD.js +0 -1
- package/dist/web/assets/_organization.index-hKcWlBrk.js +0 -1
- package/dist/web/assets/commit-diff-view-CQeZylif.js +0 -1
- package/dist/web/assets/commits-view-B_TQ6AnD.js +0 -13
- package/dist/web/assets/conflicts-view-CnGEkjaP.js +0 -8
- package/dist/web/assets/dev.diff-DH1qvnWe.js +0 -1
- package/dist/web/assets/file-header-keBlejWu.js +0 -49
- package/dist/web/assets/files-view-Bu3bjrNf.js +0 -1460
- package/dist/web/assets/grammars-DmFYBwmS.js +0 -2
- package/dist/web/assets/home-page-Y5jGxOav.js +0 -1
- package/dist/web/assets/inbox-jP8QPtzZ.js +0 -1
- package/dist/web/assets/index-B297yCgq.js +0 -11
- package/dist/web/assets/overview-view-cEOsI9TY.js +0 -2
- package/dist/web/assets/pull-request-layout-DsDKURcq.js +0 -35
- package/dist/web/assets/routes-BruvNNp9.js +0 -1
- package/dist/web/assets/shiki-DueA5xDi.js +0 -1
- package/dist/web/assets/shortcut-help-Cb0be4f3.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-BLXQ4ufn.js";import{$ as t,$t as n,Bn as r,C as i,E as a,N as o,Nn as s,Pn as c,Qt as l,S as u,T as d,_n as f,an as p,cn as m,dn as h,en as g,gn as ee,in as _,ln as te,nn as ne,on as v,pn as re,rn as ie,sn as y,tn as ae,vn as oe,xn as se,yn as ce,zn as le}from"./index-B297yCgq.js";import{C as ue,D as de,E as b,N as fe,T as pe,a as me,d as he,f as ge,g as _e,h as ve,i as ye,j as be,k as x,l as xe,m as Se,o as S,r as Ce,s as we,t as Te,u as Ee,v as De,y as Oe}from"./file-header-keBlejWu.js";import{_ as C,a as w,c as ke,d as T,f as Ae,g as E,h as D,i as je,l as Me,m as Ne,o as O,p as k,r as A,s as j,u as M}from"./inbox-jP8QPtzZ.js";import{i as Pe,r as Fe,t as Ie}from"./commits-view-B_TQ6AnD.js";import{F as Le,I as N,O as P,a as Re,c as ze,d as Be,f as Ve,h as He,i as Ue,k as F,l as We,m as Ge,o as Ke,p as qe,r as Je,s as I,t as Ye,u as Xe,v as Ze}from"./pull-request-layout-DsDKURcq.js";var L=e(r(),1);function Qe(e){return`Sends this pull request's changes to ${e.provider} (${e.name})`}function $e(e){if(e.included>=e.total)return null;let{generated:t,binary:n,unavailable:r}=e.skipped,i=e.skipped[`too-large`]+e.skipped[`over-budget`],a=[[t,`generated`],[n,`binary`],[i,`over the size limit`],[r,`could not be loaded`]].filter(([e])=>e>0).map(([e,t])=>`${e} ${t}`).join(`, `),o=e.total===1?`file`:`files`;return`Covers ${e.included} of ${e.total} ${o}${a.length>0?` (${a})`:``}`}function et(e,t){switch(e){case`tool-missing`:return`${t.name} was not found. Install it, then try again.`;case`not-signed-in`:return`${t.name} is not signed in. Run ${t.id} once in a terminal to sign in.`;case`timeout`:return`${t.name} took longer than 3 minutes and was stopped.`;case`too-large`:return`These changes are too large to summarize.`;case`busy`:return`Another summary is running. Try again when it is done.`;case`failed`:return`${t.name} could not summarize these changes.`;case`nothing-to-summarize`:return`Nothing to summarize: every changed file was left out or could not be loaded.`;case`server`:return`azdiffs did not answer. Check that it is still running in your terminal.`}}function tt(e){let t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${String(t%60).padStart(2,`0`)}s`}var nt=`X-Azdiffs-Key`,rt=_({id:p([`claude`,`codex`,`copilot`]),name:v(m(),g(1)),provider:v(m(),g(1))}),it=_({tools:l(rt)}),R=v(ie(),n(),ae(0)),z=_({summary:m(),tool:p([`claude`,`codex`,`copilot`]),generatedAt:m(),iterationId:R,sourceCommit:m(),coverage:_({included:R,total:R,skipped:_({generated:R,binary:R,"too-large":R,"over-budget":R,unavailable:R})})}),at=te([z,_({summary:ne()})]),ot=_({error:m()}),B=class extends Error{name=`SummaryError`;kind;constructor(e){super(`Summary failed: ${e}`),this.kind=e}};async function V(e,t,n){let r=c();if(r===null)throw new B(`server`);try{return await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`,[nt]:r},body:JSON.stringify(t),credentials:`same-origin`,cache:`no-store`,...n===void 0?{}:{signal:n}})}catch(e){throw n?.aborted===!0?e:new B(`server`)}}async function st(){try{let e=await V(`/api/ai/tools`,{});if(!e.ok)return[];let t=y(it,await e.json().catch(()=>null));return t.success?t.output.tools:[]}catch{return[]}}var ct={title:``,description:``,targetBranch:``,sourceBranch:``,patch:``,includedFiles:0,skipped:[]};async function lt(e){let t=await V(`/api/ai/summary`,{...e,...ct,cachedOnly:!0});if(!t.ok)throw await H(t);let n=y(at,await t.json().catch(()=>null));if(!n.success)throw new B(`server`);return n.output.summary===null?null:n.output}async function ut(e,t,n){let r=await V(`/api/ai/summary`,{...e,...t,regenerate:n.regenerate},n.signal);if(!r.ok)throw await H(r);let i=y(z,await r.json().catch(()=>null));if(!i.success)throw new B(`failed`);return i.output}var dt=[`tool-missing`,`not-signed-in`,`timeout`,`too-large`,`busy`,`failed`];async function H(e){if(e.status===403)return new B(`server`);let t=y(ot,await e.json().catch(()=>null)),n=dt.find(e=>t.success&&e===t.output.error);return n===void 0?new B(e.status>=500&&e.status!==502?`server`:`failed`):new B(n)}var ft=new TextEncoder;async function pt({changeSet:e,load:t,signal:n,concurrency:r=4}){n?.throwIfAborted();let i=e.files,a=new Map;for(let e of i)a.set(e.path,ht());let o=new Map(i.map(e=>[e.path,e])),s=ve({concurrency:r,run:async n=>{let r=await mt(o.get(n),e.baseCommit,t).catch(()=>({kind:`skip`,reason:`unavailable`}));a.get(n)?.resolve(r)}}),c=()=>s.dispose();n?.addEventListener(`abort`,c,{once:!0});try{s.add(i.filter(e=>!_e(e.path)).map(e=>e.path));let e=[],t=[],r=0,o=!1;for(let c of i){if(_e(c.path)){t.push({path:c.path,reason:`generated`});continue}if(o){t.push({path:c.path,reason:`over-budget`});continue}let i=await gt(a.get(c.path).promise,n);i.kind===`skip`?t.push({path:c.path,reason:i.reason}):r+i.bytes>307200?(o=!0,s.dispose(),t.push({path:c.path,reason:`over-budget`})):(e.push(i.patch),r+=i.bytes)}return{patch:e.join(``),files:{included:e.length,total:i.length},skipped:t}}finally{n?.removeEventListener(`abort`,c),s.dispose()}}async function mt(e,t,n){let r=async e=>{if(e===null)return{kind:`text`,text:``};try{return Se(await n(ge(e),e))}catch{return null}},[i,a]=await Promise.all([r(he(e,t)),r(Ee(e))]);if(i===null||a===null)return{kind:`skip`,reason:`unavailable`};if(i.kind===`binary`||a.kind===`binary`)return{kind:`skip`,reason:`binary`};if(i.kind===`too-large`||a.kind===`too-large`)return{kind:`skip`,reason:`too-large`};let o=Pe(e.change===`added`?`/dev/null`:`a/${e.originalPath??e.path}`,e.change===`deleted`?`/dev/null`:`b/${e.path}`,i.text,a.text,void 0,void 0,{context:3,headerOptions:Fe}),s=ft.encode(o).byteLength;return s>40960?{kind:`skip`,reason:`too-large`}:{kind:`patch`,patch:o,bytes:s}}function ht(){let e=()=>{};return{promise:new Promise(t=>{e=t}),resolve:e}}function gt(e,t){return t===void 0?e:new Promise((n,r)=>{let i=()=>r(t.reason);if(t.aborted)return i();t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}var U={tools:[`ai`,`tools`],summary:e=>[`ai`,`summary`,e.tool,e.pullRequest.organization.toLowerCase(),e.pullRequest.project,e.pullRequest.repository,e.pullRequest.pullRequestId,e.iterationId,e.sourceCommit]};function _t(){return se({queryKey:U.tools,queryFn:st,staleTime:1/0,retry:!1})}var W=`azdiffs.summaryTool`;function vt(){try{return window.localStorage.getItem(W)}catch{return null}}function yt(e){try{window.localStorage.setItem(W,e)}catch{}}function bt({tools:e,pullRequest:t,scope:n,latest:r,changeSet:i}){let a=s(),[o,c]=(0,L.useState)(vt),l=e.find(e=>e.id===o)??e[0],[u,d]=(0,L.useState)({kind:`idle`}),f=(0,L.useRef)(null),p=(0,L.useMemo)(()=>({tool:l.id,pullRequest:{organization:n.organization,project:t.repository.projectName,repository:t.repository.name,pullRequestId:t.pullRequestId},iterationId:r.id,sourceCommit:r.sourceCommit}),[l.id,n.organization,t,r.id,r.sourceCommit]),m=se({queryKey:U.summary(p),queryFn:()=>lt(p),staleTime:1/0,retry:!1}).data??null;(0,L.useEffect)(()=>()=>f.current?.abort(),[]);let h=(0,L.useCallback)(({regenerate:e})=>{if(i===void 0)return;f.current?.abort();let r=new AbortController;f.current=r,d({kind:`running`,startedAt:Date.now()}),(async()=>{try{let o=await pt({changeSet:i,load:(e,t)=>xe(a,n,e,t),signal:r.signal});if(o.files.included===0)throw new B(`nothing-to-summarize`);let s=await ut(p,{title:t.title,description:t.description,targetBranch:t.targetBranch,sourceBranch:t.sourceBranch,patch:o.patch,includedFiles:o.files.included,skipped:o.skipped},{regenerate:e,signal:r.signal});if(r.signal.aborted)return;a.setQueryData(U.summary(p),s),d({kind:`idle`})}catch(e){if(r.signal.aborted)return;d({kind:`error`,error:e instanceof B?e.kind:`failed`})}})()},[i,a,n,p,t]),g=(0,L.useCallback)(()=>{f.current?.abort(),f.current=null,d({kind:`idle`})},[]);return{tool:l,chooseTool:(0,L.useCallback)(e=>{yt(e),c(e),d({kind:`idle`})},[]),summary:m,stale:m!==null&&m.iterationId!==r.id,run:u,ready:i!==void 0,start:h,cancel:g}}var G=le(),xt=`rounded-[10px] border border-border bg-surface px-4 py-3`;function St(){let{pullRequest:e,scope:t}=I(),n=_t(),r=N(e.supportsIterations?t:null).data?.at(-1);return n.data===void 0||n.data.length===0||r===void 0||r.sourceCommit===null?null:(0,G.jsx)(Ct,{tools:n.data,pullRequest:e,latest:{...r,sourceCommit:r.sourceCommit}},r.id)}function Ct({tools:e,pullRequest:t,latest:n}){let{scope:r}=I(),i=(0,L.useMemo)(()=>({iteration:n,since:null}),[n]),a=bt({tools:e,pullRequest:t,scope:r,latest:n,changeSet:Le(r,i).data}),o=(0,L.useId)(),s=(0,L.useRef)(null),c=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{let e=a.run.kind===`running`;c.current&&!e&&s.current?.contains(document.activeElement)!==!0&&s.current?.focus(),c.current=e},[a.run.kind]),(0,G.jsxs)(`section`,{ref:s,tabIndex:-1,"aria-labelledby":o,className:`mt-6 ${xt}`,"data-testid":`summary-card`,"data-state":a.run.kind===`idle`&&a.summary!==null?`done`:a.run.kind,children:[(0,G.jsx)(`h2`,{id:o,className:`sr-only`,children:`Summary`}),(0,G.jsx)(wt,{summary:a,tools:e})]})}function wt({summary:e,tools:t}){let{run:n,tool:r}=e;return n.kind===`running`?(0,G.jsx)(Et,{summary:e,startedAt:n.startedAt}):n.kind===`error`?(0,G.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 text-[13px]`,children:[(0,G.jsxs)(`p`,{className:`min-w-0 flex-1 text-fg`,children:[(0,G.jsx)(D,{className:`mr-1.5 inline size-3.5 align-[-2px] text-danger`}),et(n.error,r)]}),(0,G.jsx)(`button`,{type:`button`,className:ce,onClick:()=>e.start({regenerate:e.summary!==null}),children:`Try again`})]}):e.summary===null?(0,G.jsx)(Tt,{summary:e,tools:t}):(0,G.jsx)(Dt,{summary:e})}function Tt({summary:e,tools:t}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsxs)(`button`,{type:`button`,className:oe,disabled:!e.ready,onClick:()=>e.start({regenerate:!1}),"data-testid":`summarize`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`✦`}),`Summarize changes`]}),t.length>1&&(0,G.jsx)(Ze,{label:`Summarize with`,align:`start`,entries:t.map(t=>({kind:`radio`,label:t.name,checked:t.id===e.tool.id,onSelect:()=>e.chooseTool(t.id)})),trigger:t=>(0,G.jsxs)(`button`,{type:`button`,...t,className:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-7 px-2 text-muted hover:bg-hover hover:text-fg`,"aria-label":`Summarize with ${e.tool.name}: choose the tool`,children:[e.tool.name,(0,G.jsx)(d,{className:`size-3.5`})]})})]}),(0,G.jsx)(`p`,{className:`min-w-0 text-xs text-muted`,"data-testid":`summary-provider`,children:Qe(e.tool)})]})}function Et({summary:e,startedAt:t}){let[n,r]=(0,L.useState)(()=>Date.now()),i=(0,L.useRef)(null);return(0,L.useEffect)(()=>{i.current?.focus();let e=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(e)},[]),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-[13px]`,children:[(0,G.jsx)(Ot,{}),(0,G.jsxs)(`p`,{className:`min-w-0 flex-1 text-fg`,children:[(0,G.jsxs)(`span`,{role:`status`,children:[`Summarizing with `,e.tool.name,`…`]}),` `,(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted tabular-nums`,children:tt(n-t)})]}),(0,G.jsx)(`button`,{ref:i,type:`button`,className:ce,onClick:e.cancel,"data-testid":`summary-cancel`,children:`Cancel`})]})}function Dt({summary:e}){let[t,n]=(0,L.useState)(!0),r=(0,L.useId)(),i=e.summary;if(i===null)return null;let o=$e(i.coverage),s=(0,G.jsx)(`button`,{type:`button`,className:`font-medium text-fg hover:underline`,onClick:()=>e.start({regenerate:!0}),children:`Regenerate`});return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`p`,{"aria-hidden":`true`,className:`text-[13px] font-medium text-muted`,children:[(0,G.jsx)(`span`,{className:`mr-1.5`,children:`✦`}),`Summary`]}),(0,G.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,"aria-label":t?`Hide summary`:`Show summary`,onClick:()=>n(e=>!e),className:`${re} ml-auto`,children:[t?(0,G.jsx)(d,{className:`size-3.5`}):(0,G.jsx)(a,{className:`size-3.5`}),t?`Hide`:`Show`]})]}),t&&(0,G.jsx)(`div`,{id:r,className:`mt-2`,"data-testid":`summary-text`,children:(0,G.jsx)(S,{source:i.summary})}),e.stale&&(0,G.jsxs)(`p`,{className:`mt-3 text-xs text-fg`,"data-testid":`summary-stale`,children:[(0,G.jsx)(D,{className:`mr-1 inline size-3.5 align-[-2px] text-modified`}),`Newer changes since this summary · `,s]}),(0,G.jsxs)(`div`,{className:`mt-3 space-y-0.5 border-t border-border pt-2.5 text-xs text-muted`,children:[(0,G.jsxs)(`p`,{"data-testid":`summary-footer`,children:[e.tool.name,` · for update `,i.iterationId,` ·`,` `,(0,G.jsx)(`time`,{dateTime:i.generatedAt,title:E(i.generatedAt),children:C(i.generatedAt)}),` `,`· `,s]}),o!==null&&(0,G.jsx)(`p`,{"data-testid":`summary-coverage`,children:o})]})]})}function Ot(){return(0,G.jsxs)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,className:`size-4 shrink-0 animate-spin text-accent motion-reduce:animate-none`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,children:[(0,G.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,className:`opacity-25`}),(0,G.jsx)(`path`,{d:`M14 8a6 6 0 0 0-6-6`})]})}var kt={VoteUpdate:`vote`,RefUpdate:`push`,ReviewersUpdate:`reviewers`,StatusUpdate:`status`,PolicyStatusUpdate:`policy`,MergeAttempt:`merge`};function At(e){return kt[e.threadType??``]??`other`}var jt={vote:`Vote`,push:`Push`,reviewers:`Reviewers`,status:`Status`,policy:`Policy`,merge:`Merge`,other:`Activity`};function K(e){let t=e.comments[0]?.publishedDate??null,n=t===null?NaN:Date.parse(t);return Number.isNaN(n)?fe(e):n}function q(e){let t=[];for(let n of e){let e=x(n);e.kind===`pull-request`?t.push({kind:`thread`,at:K(n),thread:n}):e.kind===`system`&&t.push({kind:`activity`,at:K(n),thread:n,activity:At(n)})}return t.sort((e,t)=>e.at-t.at||e.thread.id-t.thread.id)}function Mt(e){let t=0,n=0;for(let r of e){let e=x(r).kind;(e===`line`||e===`file`)&&(t++,be(r.status)||n++)}return{total:t,active:n}}var Nt=/@<([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})>/gi,Pt=/^[A-Za-z][\w-]*(?:\.[A-Za-z][\w-]*)+:\s+(?=\S)/;function J(e){return/^[A-Za-z][\w-]*(?:\.[A-Za-z][\w-]*)+$/.test(e.trim())}var Ft={10:`approved`,5:`approved with suggestions`,0:`reset their vote`,[-5]:`is waiting for the author`,[-10]:`rejected`},It=/^(.*?)\s*\bvoted\s+(-?\d+)\.?$/;function Lt(e){let t=e.comments[0];if(t===void 0)return``;let n=new Map(e.identities.map(e=>[e.id.toLowerCase(),e])),r=t.content.replace(Nt,(e,t)=>{let r=n.get(t.toLowerCase());return r===void 0?e:`@${r.displayName}`}).replace(/\s+/g,` `).trim().replace(Pt,``),i=t.author.displayName.trim(),a=e.threadType===`VoteUpdate`?It.exec(r):null;if(a!==null){let t=Ft[e.voteResult??Number(a[2])];if(t!==void 0){let e=(a[1]??``).trim();return e.length>0?`${e} ${t}`:i.length>0&&!J(i)?`${i} ${t}`:t}}return i.length===0||i===`Unknown`||J(i)||r.includes(i)?r:r.length===0?i:`${i}: ${r}`}var Rt={approved:`Approved`,"approved-with-suggestions":`Approved with suggestions`,"waiting-for-author":`Waiting for author`,rejected:`Rejected`,"no-response":`No response`,declined:`Declined`};function Y(e){return e.vote>=10?`approved`:e.vote>0?`approved-with-suggestions`:e.vote<=-10?`rejected`:e.vote<0?`waiting-for-author`:e.hasDeclined?`declined`:`no-response`}var X={rejected:0,"waiting-for-author":1,approved:2,"approved-with-suggestions":3,"no-response":4,declined:5};function zt(e){let t=[...e].sort((e,t)=>X[Y(e)]-X[Y(t)]||e.displayName.localeCompare(t.displayName));return{required:t.filter(e=>e.isRequired),optional:t.filter(e=>!e.isRequired)}}function Bt(e){return/^\[[^\]]+\]\\(.+)$/.exec(e.displayName)?.[1]??e.displayName}var Vt={approved:`text-added`,"approved-with-suggestions":`text-added`,"waiting-for-author":`text-warning`,rejected:`text-danger`,"no-response":`text-muted`,declined:`text-muted`};function Ht({state:e}){let t=`size-3.5 ${Vt[e]}`;switch(e){case`approved`:case`approved-with-suggestions`:return(0,G.jsx)(A,{className:t});case`waiting-for-author`:return(0,G.jsx)(w,{className:t});case`rejected`:return(0,G.jsx)(O,{className:t});case`declined`:return(0,G.jsx)(Ne,{className:t});case`no-response`:return(0,G.jsx)(je,{className:t})}}function Ut({reviewer:e}){let t=Y(e),n=e.isContainer===!0;return(0,G.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2.5 py-1 text-[13px]`,"data-testid":`reviewer`,"data-state":t,children:[(0,G.jsx)(`span`,{className:`mt-0.5`,children:(0,G.jsx)(Ht,{state:t})}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`truncate text-fg`,title:e.displayName,children:Bt(e)}),n&&(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 rounded-md border border-border px-1 text-[11px] leading-4 text-muted`,children:[(0,G.jsx)(Me,{className:`size-3`}),`Group`]})]}),(0,G.jsx)(`span`,{className:`block text-xs ${Vt[t]}`,"data-testid":`reviewer-vote`,children:Rt[t]})]})]})}function Wt({pullRequest:e}){let{required:t,optional:n}=zt(e.reviewers),r=e.reviewers.filter(e=>e.vote>0).length;return(0,G.jsx)(T,{title:`Reviewers`,testId:`reviewers`,aside:e.reviewers.length>0?`${r} of ${e.reviewers.length} approved`:void 0,children:e.reviewers.length===0?(0,G.jsx)(j,{children:`No reviewers.`}):(0,G.jsxs)(`div`,{className:`space-y-2`,children:[t.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`mb-0.5 text-xs text-muted`,children:`Required`}),(0,G.jsx)(`ul`,{"aria-label":`Required reviewers`,children:t.map(e=>(0,G.jsx)(Ut,{reviewer:e},e.id))})]}),n.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`mb-0.5 text-xs text-muted`,children:`Optional`}),(0,G.jsx)(`ul`,{"aria-label":`Optional reviewers`,children:n.map(e=>(0,G.jsx)(Ut,{reviewer:e},e.id))})]})]})})}var Gt={failed:`text-danger`,running:`text-accent`,pending:`text-warning`,passed:`text-added`};function Kt({state:e}){let t=`size-3.5 ${Gt[e]}`;switch(e){case`failed`:return(0,G.jsx)(O,{className:t});case`running`:return(0,G.jsx)(Ae,{className:t});case`pending`:return(0,G.jsx)(w,{className:t});case`passed`:return(0,G.jsx)(A,{className:t})}}function qt({check:e}){return(0,G.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2.5 py-1 text-[13px]`,"data-testid":`check`,"data-state":e.state,"data-blocking":e.blocking?`true`:`false`,children:[(0,G.jsx)(`span`,{className:`mt-0.5`,children:(0,G.jsx)(Kt,{state:e.state})}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[e.url===void 0?(0,G.jsx)(`span`,{className:`block truncate text-fg`,title:e.name,children:e.name}):(0,G.jsxs)(P,{href:e.url,className:`flex min-w-0 items-center gap-1 text-fg hover:underline`,children:[(0,G.jsx)(`span`,{className:`truncate`,title:e.name,children:e.name}),(0,G.jsx)(ke,{className:`size-3 text-muted`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`(opens in a new tab)`})]}),(0,G.jsxs)(`span`,{className:`block text-xs text-muted`,children:[(0,G.jsx)(`span`,{className:Gt[e.state],"data-testid":`check-state`,children:qe[e.state]}),` · `,e.blocking?`Required`:`Optional`,e.detail!==void 0&&(0,G.jsx)(`span`,{className:`block truncate`,title:e.detail,children:e.detail})]})]})]})}function Jt({result:e}){let{checks:t,pending:n,evaluationsError:r,statusesError:i}=e,a=r!==null&&i!==null,o=Ge(t),s;return s=n?(0,G.jsx)(M,{label:`Loading checks`}):a?(0,G.jsx)(k,{what:`Checks could not be loaded.`,error:r,onRetry:e.retry}):(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-[13px] ${o.requiredNotPassed>0?`text-fg`:`text-muted`}`,"data-testid":`checks-summary`,children:[o.required>0&&(o.requiredNotPassed===0?(0,G.jsx)(A,{className:`size-3.5 text-added`}):(0,G.jsx)(D,{className:`size-3.5 text-warning`})),o.text]}),t.length>0&&(0,G.jsx)(`ul`,{"aria-label":`Checks`,className:`space-y-0.5`,children:t.map(e=>(0,G.jsx)(qt,{check:e},e.id))}),(r!==null||i!==null)&&(0,G.jsx)(Yt,{what:r===null?`Statuses could not be loaded; only policies are shown.`:`Policies could not be loaded; only statuses are shown.`,onRetry:e.retry})]}),(0,G.jsx)(T,{title:`Checks`,testId:`checks`,children:s})}function Yt({what:e,onRetry:t}){return(0,G.jsxs)(`p`,{role:`alert`,className:`flex flex-wrap items-center gap-x-2 text-[13px] text-muted`,children:[(0,G.jsx)(D,{className:`size-3.5 text-danger`}),e,(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`font-medium text-fg hover:underline`,children:`Try again`})]})}function Xt(e){let t=e.targetBranch;if(e.status===`completed`)return{text:`Completed into ${t}`,tone:`good`};if(e.status===`abandoned`)return{text:`Abandoned`,tone:`neutral`};switch(e.mergeStatus){case`conflicts`:return{text:`Conflicts with ${t}`,tone:`bad`};case`queued`:return{text:`Checking mergeability`,tone:`neutral`};case`succeeded`:return{text:`No conflicts`,tone:`good`};case`rejectedByPolicy`:return{text:`Merge rejected by policy`,tone:`bad`};case`failure`:return{text:`The merge check failed`,tone:`bad`};default:return{text:`Mergeability not checked yet`,tone:`neutral`}}}function Zt({pullRequest:e,children:t}){let n=Xt(e);return(0,G.jsxs)(T,{title:`Branch`,testId:`merge`,children:[(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-[13px] ${n.tone===`bad`?`text-danger`:n.tone===`good`?`text-fg`:`text-muted`}`,"data-testid":`merge-state`,children:[n.tone===`bad`?(0,G.jsx)(D,{className:`size-3.5`}):n.tone===`good`?(0,G.jsx)(A,{className:`size-3.5 text-added`}):(0,G.jsx)(w,{className:`size-3.5`}),n.text]}),(0,G.jsxs)(`p`,{className:`mt-1 truncate pl-[22px] font-mono text-xs text-muted`,title:`${e.sourceBranch} → ${e.targetBranch}`,children:[e.sourceBranch,` → `,e.targetBranch]}),t!==void 0&&(0,G.jsx)(`div`,{className:`mt-2.5`,children:t})]})}function Qt(e,t,n){return`https://dev.azure.com/${encodeURIComponent(e)}/${encodeURIComponent(t)}/_workitems/edit/${n}`}function $t({organization:e,project:t,query:n}){let r;if(n.isPending)r=(0,G.jsx)(M,{label:`Loading work items`,lines:2});else if(n.data===void 0)r=(0,G.jsx)(k,{what:`Work items could not be loaded.`,error:n.error,onRetry:()=>void n.refetch()});else if(n.data.ids.length===0)r=(0,G.jsx)(j,{children:`No linked work items.`});else{let{ids:i,details:a,detailsProblem:o}=n.data;r=(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`ul`,{"aria-label":`Linked work items`,className:`space-y-1`,children:i.map(n=>{let r=a?.get(n);return(0,G.jsxs)(`li`,{className:`text-[13px]`,"data-testid":`work-item`,children:[(0,G.jsxs)(P,{href:Qt(e,t,n),className:`group flex min-w-0 items-baseline gap-1.5 text-fg`,children:[(0,G.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-muted group-hover:text-fg`,children:[`#`,n]}),r!==void 0&&(0,G.jsx)(`span`,{className:`min-w-0 truncate group-hover:underline`,title:r.title,children:r.title.length>0?r.title:`(untitled)`})]}),r!==void 0&&(0,G.jsx)(`span`,{className:`block text-xs text-muted`,children:[r.type,r.state].filter(e=>e.length>0).join(` · `)})]},n)})}),a===null&&(0,G.jsx)(`p`,{className:`text-xs text-muted`,"data-testid":`work-items-restricted`,children:o===`access`?`Titles unavailable: your sign-in may not have Work Items: Read access.`:`Titles unavailable: Azure DevOps did not return them.`})]})}return(0,G.jsx)(T,{title:`Work items`,testId:`work-items`,aside:n.data!==void 0&&n.data.ids.length>0?String(n.data.ids.length):void 0,children:r})}function en({labels:e}){return e.length===0?null:(0,G.jsx)(T,{title:`Labels`,testId:`labels`,children:(0,G.jsx)(`ul`,{"aria-label":`Labels`,className:`flex flex-wrap gap-1`,children:e.map(e=>(0,G.jsx)(`li`,{className:`rounded-full bg-raised px-2.5 text-xs leading-6 text-fg shadow-[0_0_0_1px_var(--azd-border)]`,children:e},e))})})}function tn({section:e}){let{location:n,pullRequest:r}=I();return(0,G.jsx)(t,{sidebarLabel:`Inbox`,sidebar:(0,G.jsx)(Ye,{location:n}),topBar:(0,G.jsx)(Je,{mode:`overview`}),children:(0,G.jsx)(an,{section:e},`${r.repository.id}:${r.pullRequestId}`)})}var nn=[],rn=()=>null;function an({section:e}){let{location:t,shortForm:n,pullRequest:r,scope:i}=I(),a=(0,L.useMemo)(()=>We.threads(i),[i]),o=pe({scope:i,comparison:null,repositoryName:r.repository.name,files:nn,lineText:rn,threadsKey:a}),s=Xe(i),c=Ve(i),l=Be(i),u=(0,L.useMemo)(()=>l.data===void 0?null:q(l.data).filter(e=>e.kind===`thread`).length,[l.data]);return(0,G.jsx)(ue,{controller:o,children:(0,G.jsx)(`div`,{className:`azd-scrollbar min-h-0 flex-1 overflow-auto`,"data-testid":`overview`,children:(0,G.jsxs)(`div`,{className:`mx-auto grid w-full max-w-[1240px] gap-x-12 gap-y-10 px-8 pt-10 pb-20 xl:grid-cols-[minmax(0,1fr)_260px]`,children:[(0,G.jsxs)(`div`,{className:`mx-auto w-full max-w-[820px] min-w-0`,children:[(0,G.jsx)(on,{pullRequest:r}),(0,G.jsx)(St,{}),(0,G.jsx)(cn,{location:t,shortForm:n,section:e,discussionCount:u}),(0,G.jsxs)(`div`,{className:`mt-5`,children:[e===`description`&&(0,G.jsx)(dn,{pullRequest:r}),e===`discussion`&&(0,G.jsx)(fn,{scope:i,review:o,location:t,shortForm:n}),e===`commits`&&(0,G.jsx)(Ie,{location:t,shortForm:n,scope:i})]}),(0,G.jsx)(hn,{})]}),(0,G.jsxs)(`aside`,{"aria-label":`Pull request details`,className:`min-w-0 space-y-7`,children:[(0,G.jsx)(Wt,{pullRequest:r}),(0,G.jsx)(Jt,{result:s}),(0,G.jsx)(Zt,{pullRequest:r,children:(0,G.jsx)(He,{})}),(0,G.jsx)($t,{organization:t.organization,project:t.project,query:c}),(0,G.jsx)(en,{labels:r.labels})]})]})})})}function on({pullRequest:e}){let t=Ke(e),{counts:n,scope:r}=I(),i=N(e.supportsIterations?r:null).data?.at(-1)?.id,a=i===void 0?void 0:De(Oe({...r,iteration:i}));return(0,G.jsxs)(`header`,{className:`space-y-3.5`,children:[(0,G.jsxs)(`h1`,{className:`text-[28px] leading-[1.2] font-semibold tracking-[-0.02em] text-fg-strong [text-wrap:balance]`,children:[e.title,` `,(0,G.jsxs)(`span`,{className:`font-normal text-muted tabular-nums`,children:[`#`,e.pullRequestId]})]}),(0,G.jsxs)(`dl`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 text-[13px] text-muted`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`sr-only`,children:`Status`}),(0,G.jsxs)(`dd`,{className:`inline-flex h-6 items-center gap-1.5 rounded-full bg-raised px-2.5 font-medium shadow-[0_0_0_1px_var(--azd-border)] ${Re[t]}`,children:[(0,G.jsx)(ze,{status:t,className:`size-3.5`}),(0,G.jsx)(`span`,{"data-testid":`pull-request-status`,children:Ue[t]})]})]}),(0,G.jsx)(Z,{}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`dt`,{className:`sr-only`,children:`Author`}),(0,G.jsxs)(`dd`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(h,{name:e.author.displayName,size:`sm`}),(0,G.jsx)(`span`,{className:`text-fg`,children:e.author.displayName})]})]}),(0,G.jsx)(Z,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`sr-only`,children:`Created`}),(0,G.jsxs)(`dd`,{children:[`Created`,` `,(0,G.jsx)(`time`,{dateTime:e.creationDate,title:E(e.creationDate),children:C(e.creationDate)})]})]}),n.files!==null&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`sr-only`,children:`Files changed`}),(0,G.jsxs)(`dd`,{className:`flex items-baseline gap-2 tabular-nums`,children:[n.files,` `,n.files===`1`?`file`:`files`,a!==void 0&&(0,G.jsx)(ee,{additions:a.additions,deletions:a.deletions})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px]`,children:[(0,G.jsxs)(`span`,{className:`sr-only`,"data-testid":`pull-request-branches`,children:[e.sourceBranch,` → `,e.targetBranch]}),(0,G.jsx)(sn,{name:e.targetBranch,label:`Target branch`}),(0,G.jsx)(u,{className:`size-3.5 text-muted`}),(0,G.jsx)(sn,{name:e.sourceBranch,label:`Source branch`,copy:!0})]})]})}function Z(){return(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted/60`,children:`·`})}function sn({name:e,label:t,copy:n=!1}){let[r,i]=(0,L.useState)(!1);return(0,G.jsxs)(`span`,{className:`inline-flex h-7 max-w-full min-w-0 items-center gap-1 rounded-[7px] border border-border bg-surface pr-1 pl-2.5 font-mono text-xs text-fg`,title:`${t}: ${e}`,children:[(0,G.jsxs)(`span`,{className:`sr-only`,children:[t,`: `]}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n?(0,G.jsx)(`button`,{type:`button`,"aria-label":r?`Copied`:`Copy branch name ${e}`,title:`Copy branch name`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)},()=>i(!1))},className:`inline-flex size-5 items-center justify-center rounded text-muted hover:bg-hover hover:text-fg`,children:r?(0,G.jsx)(`span`,{className:`text-[10px]`,children:`✓`}):(0,G.jsx)(o,{className:`size-3.5`})}):(0,G.jsx)(`span`,{className:`w-1.5`})]})}var Q=`inline-flex h-8 items-center gap-1.5 rounded-[6px] px-3 text-[13px] font-medium text-muted transition-colors hover:text-fg aria-[current=page]:bg-[var(--azd-selected)] aria-[current=page]:text-fg aria-[current=page]:shadow-[0_0_0_1px_var(--azd-border)]`;function cn({location:e,shortForm:t,section:n,discussionCount:r}){let{counts:i}=I();return(0,G.jsxs)(`nav`,{"aria-label":`Pull request sections`,className:`mt-7 inline-flex items-center gap-0.5 rounded-[8px] bg-raised p-0.5`,children:[(0,G.jsx)(F,{location:e,shortForm:t,page:{tab:`overview`},current:n===`description`,className:Q,testId:`tab-description`,children:`Description`}),(0,G.jsxs)(F,{location:e,shortForm:t,page:{tab:`discussion`},current:n===`discussion`,className:Q,testId:`tab-discussion`,children:[`Discussion`,r!==null&&r>0&&(0,G.jsxs)(`span`,{className:`font-normal tabular-nums text-muted`,children:[r,(0,G.jsx)(`span`,{className:`sr-only`,children:` comment threads`})]})]}),(0,G.jsxs)(F,{location:e,shortForm:t,page:{tab:`commits`},current:n===`commits`,className:Q,testId:`tab-commits`,children:[`Commits`,i.commits!==null&&(0,G.jsxs)(`span`,{className:`font-normal tabular-nums text-muted`,children:[i.commits,(0,G.jsx)(`span`,{className:`sr-only`,children:` commits`})]})]})]})}var ln=1500,un=30;function dn({pullRequest:e}){let t=e.description.trim(),n=t.length>ln||t.split(`
|
|
2
|
-
`).length>un,[r,i]=(0,L.useState)(!1),a=n&&!r;return(0,G.jsx)(`section`,{"aria-label":`Description`,"data-testid":`description`,children:t.length===0?(0,G.jsx)(`p`,{className:`text-[14px] text-muted`,children:`No description provided.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{id:`overview-description-body`,className:`text-[14px] leading-[1.65] text-fg ${a?`relative max-h-96 overflow-hidden`:``}`,children:[(0,G.jsx)(S,{source:e.description}),a&&(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-[var(--azd-canvas)] to-transparent`})]}),n&&(0,G.jsx)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":`overview-description-body`,onClick:()=>i(e=>!e),className:`mt-2 text-[13px] font-medium text-muted hover:text-fg`,children:r?`Show less`:`Show full description`})]})})}function fn({scope:e,review:t,location:n,shortForm:r}){let i=Be(e),[a,o]=(0,L.useState)(!0),s=(0,L.useMemo)(()=>q(i.data??[]),[i.data]),c=(0,L.useMemo)(()=>Mt(i.data??[]),[i.data]),l=a?s:s.filter(e=>e.kind===`thread`),u=s.length-s.filter(e=>e.kind===`thread`).length,d;return d=i.isPending?(0,G.jsx)(M,{label:`Loading the discussion`}):i.data===void 0?(0,G.jsx)(k,{what:`The discussion could not be loaded.`,error:i.error,onRetry:()=>void i.refetch()}):(0,G.jsxs)(G.Fragment,{children:[l.length===0?(0,G.jsx)(j,{children:s.length===0?`No discussion yet.`:`No comments yet. Activity is hidden.`}):(0,G.jsx)(`ol`,{id:`overview-timeline`,"aria-label":`Timeline`,className:`space-y-2.5`,"data-testid":`timeline`,children:l.map(e=>(0,G.jsx)(pn,{entry:e},e.thread.id))}),c.total>0&&(0,G.jsxs)(`p`,{className:`mt-4 text-[13px] text-muted`,"data-testid":`file-comments`,children:[c.total,` file `,c.total===1?`comment`:`comments`,`,`,` `,c.active===0?`none`:c.active,` active ·`,` `,(0,G.jsx)(F,{location:n,shortForm:r,page:{tab:`files`},className:`font-medium text-fg hover:underline`,onClick:()=>we({commentFilter:c.active>0?`active`:`all`}),children:c.active>0?`Show active comments in Files`:`Show them in Files`})]})]}),(0,G.jsxs)(`section`,{"aria-labelledby":`overview-discussion`,"data-testid":`discussion`,children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(`h2`,{id:`overview-discussion`,className:`sr-only`,children:`Discussion`}),u>0&&(0,G.jsxs)(`button`,{type:`button`,"aria-controls":`overview-timeline`,onClick:()=>o(e=>!e),className:`ml-auto h-7 rounded-[7px] px-2 text-xs font-medium text-muted hover:bg-hover hover:text-fg`,"data-testid":`activity-toggle`,"data-showing":a?`true`:`false`,children:[a?`Hide`:`Show`,` activity (`,u,`)`]})]}),d,(0,G.jsx)(`div`,{className:`mt-4`,children:(0,G.jsx)(mn,{review:t})})]})}function pn({entry:e}){if(e.kind===`thread`)return(0,G.jsx)(`li`,{"data-testid":`timeline-thread`,children:(0,G.jsx)(Ce,{thread:e.thread})});let t=e.thread.comments[0]?.publishedDate??e.thread.publishedDate;return(0,G.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-3 px-3 text-[13px] text-muted`,"data-testid":`activity`,"data-activity":e.activity,children:[(0,G.jsx)(`span`,{className:`w-20 shrink-0 text-xs text-muted`,children:jt[e.activity]}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-fg/90`,children:Lt(e.thread)}),(0,G.jsx)(`time`,{className:`shrink-0 text-xs tabular-nums`,dateTime:t??void 0,title:E(t),children:C(t)})]})}function mn({review:e}){let t=de,[n,r]=(0,L.useState)(!1),i=b(e.store,e=>e.busy.has(t)),a=b(e.store,e=>e.errors.get(t)),o=b(e.store,e=>e.focus===t),s=(0,L.useRef)(null),c=e.drafts.read(t).length>0;return i||!n&&!c&&a===void 0?(0,G.jsx)(`button`,{ref:s,type:`button`,disabled:i,onClick:()=>{r(!0),e.store.update(()=>({focus:t}))},className:`flex h-10 w-full items-center rounded-[10px] border border-border bg-surface px-3.5 text-left text-[13px] text-muted hover:border-border-strong hover:text-fg disabled:opacity-60`,"data-testid":`pull-request-comment-opener`,children:i?`Sending…`:`Add a comment to the pull request…`}):(0,G.jsx)(me,{drafts:e.drafts,draftKey:t,label:`Comment on the pull request`,submitLabel:`Comment`,busy:i,autoFocus:o,onFocused:()=>e.store.update(()=>({focus:null})),onSubmit:t=>{r(!1),e.commentOnPullRequest(t)},onCancel:()=>{r(!1),e.clearError(t)},returnFocus:()=>requestAnimationFrame(()=>s.current?.focus()),problem:a===void 0?null:(0,G.jsx)(ye,{review:e,errorKey:t,error:a,organization:e.organization}),testId:`pull-request-composer`})}var $=12;function hn(){let{location:e,shortForm:t,pullRequest:n,scope:r}=I(),i=N(n.supportsIterations?r:null).data?.at(-1),a=(0,L.useMemo)(()=>i===void 0?null:{iteration:i,since:null},[i]),o=Le(n.supportsIterations?r:null,a).data?.files;return(0,G.jsxs)(`section`,{"aria-labelledby":`overview-files`,className:`mt-12 border-t border-border pt-6`,"data-testid":`changed-files`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`h2`,{id:`overview-files`,className:`text-[18px] font-semibold tracking-[-0.01em] text-fg-strong`,children:o===void 0?`Files changed`:`${o.length} ${o.length===1?`file`:`files`} changed`}),(0,G.jsx)(F,{location:e,shortForm:t,page:{tab:`files`},className:`${f} ml-auto`,testId:`review-changes`,children:`Review changes`})]}),o!==void 0&&o.length>0&&(0,G.jsxs)(`ul`,{className:`mt-4 overflow-hidden rounded-[10px] border border-border bg-surface`,children:[o.slice(0,$).map(e=>(0,G.jsx)(_n,{file:e},e.path)),o.length>$&&(0,G.jsxs)(`li`,{className:`border-t border-border px-3.5 py-2 text-[13px] text-muted`,children:[`and `,o.length-$,` more`]})]})]})}var gn={added:`text-added`,modified:`text-modified`,deleted:`text-deleted`,renamed:`text-renamed`};function _n({file:e}){let t=e.path.lastIndexOf(`/`),n=e.path.slice(t+1),r=t===-1?``:e.path.slice(0,t);return(0,G.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2.5 border-t border-border px-3.5 py-2 text-[13px] first:border-t-0`,children:[(0,G.jsxs)(`span`,{className:gn[e.change],title:Te[e.change],children:[(0,G.jsx)(i,{change:e.change}),(0,G.jsx)(`span`,{className:`sr-only`,children:Te[e.change]})]}),(0,G.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:n}),r.length>0&&(0,G.jsx)(`span`,{className:`ml-2 text-muted`,children:r})]})]})}export{tn as t};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-DfsS1UI1.js","assets/rolldown-runtime-BLXQ4ufn.js","assets/lib-C2gVWm_O.js","assets/lib-rf_jxHx0.js","assets/highlights-BJb1-tzP.js","assets/stream-tokenizer-B5Ok5N3S.js","assets/lineChanges-Dw4ZXwVU.js","assets/shiki-DueA5xDi.js","assets/utils-Tkdy0sOA.js","assets/index-B297yCgq.js","assets/index-CjZUV4-4.css","assets/grammars-DmFYBwmS.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e,t}from"./rolldown-runtime-BLXQ4ufn.js";import{$ as n,An as r,At as i,Bn as a,Bt as o,Cn as s,Dn as c,En as l,F as u,Ft as d,Gt as f,Ht as p,It as m,Jt as h,Kt as g,Ln as _,Lt as v,M as y,Mn as b,Nn as x,O as S,On as C,Ot as w,P as T,Pt as ee,Q as E,Rn as te,Rt as D,Sn as ne,T as re,Tn as ie,V as ae,Vt as oe,W as se,Wt as ce,Xt as le,Yt as ue,Z as de,Zt as fe,_n as pe,_t as me,at as he,ct as ge,et as _e,fn as ve,ft as O,gt as ye,hn as be,ht as xe,jn as Se,kn as Ce,kt as k,lt as we,m as Te,mt as Ee,nt as De,p as A,pt as j,qt as Oe,tt as ke,un as M,vn as Ae,w as je,wn as Me,wt as Ne,xn as N,yt as Pe,zn as Fe,zt as Ie}from"./index-B297yCgq.js";import{n as Le,t as Re}from"./inbox-jP8QPtzZ.js";var ze=class extends Me{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,u=n.fetchMeta?.fetchMore?.direction,d=o&&u===`forward`,f=i&&u===`forward`,p=o&&u===`backward`,m=i&&u===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:l(t,n.data),hasPreviousPage:c(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:s&&!d&&!p,isRefetching:a&&!f&&!m}}},Be=class extends b{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),r(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&C(t.mutationKey)!==C(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??s();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){ie.batch(()=>{let t=this.#r;if(t&&this.hasListeners()){let n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{t.onSuccess?.(e.data,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(e.data,null,n,r,i)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{t.onError?.(e.error,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(void 0,e.error,n,r,i)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},P=e(a(),1);function Ve(e,t){let n=x(t),[r]=P.useState(()=>new Be(n,e));P.useEffect(()=>{r.setOptions(e)},[r,e]);let i=P.useSyncExternalStore(P.useCallback(e=>r.subscribe(ie.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=P.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(Ce)},[r]);if(i.error&&Se(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function He(e,t){return ne(e,ze,t)}async function Ue(e,{objectId:t,...n}){let r=await e.binary({path:[n.project,`_apis`,`git`,`repositories`,n.repositoryId,`blobs`,t],query:{$format:`octetstream`},accept:`application/octet-stream`,...n.signal===void 0?{}:{signal:n.signal}});return{bytes:r.data,contentType:r.headers.get(`content-type`)}}async function We(e,{path:t,commitId:n,...r}){let i=await e.binary({path:[r.project,`_apis`,`git`,`repositories`,r.repositoryId,`items`],query:{path:t,"versionDescriptor.version":n,"versionDescriptor.versionType":`commit`,$format:`octetStream`,download:!1},accept:`application/octet-stream`,...r.signal===void 0?{}:{signal:r.signal}});return{bytes:i.data,contentType:i.headers.get(`content-type`)}}var Ge=`diffs-container`,Ke=/(?=^diff --git)/gm,qe=/(?<=\n)/,Je=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Ye=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,Xe=`header-prefix`,Ze=`header-filename-suffix`,Qe=`header-metadata`,$e=`header-custom`,et={dark:`pierre-dark`,light:`pierre-light`},tt=`data-theme-css`,nt=`data-unsafe-css`,rt=`data-diffs-scrollbar-measure`,it=`data-diffs-code-view-header`,at=`data-diffs-code-view-footer`,ot=`--diffs-scrollbar-gutter-measured`,st=1e5,ct={unmodifiedLines:`{count, plural, one {# unmodified line} other {# unmodified lines}}`,unknownUnmodifiedLines:`More unchanged context may be available`,expandAll:`Expand all`,expandLine:`Show full line`,noNewlineAtEndOfFile:`No newline at end of file`,acceptCurrentChange:`Accept current change`,acceptIncomingChange:`Accept incoming change`,acceptBoth:`Accept both`,searchPlaceholder:`Search`,replacePlaceholder:`Replace`,noSearchResults:`0/0`,searching:`Searching…`,searchResultCount:`{count, plural, one {# result} other {# results}}`,searchResultPosition:`{index}/{count}`,matchCase:`Match Case`,wholeWord:`Whole Word`,regularExpression:`Regexp`,replaceMatch:`Replace`,replaceAllMatches:`Replace All`,previousMatch:`Previous`,nextMatch:`Next`,closeSearch:`Close`,toggleReplace:`Toggle Replace`},lt={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},ut={...lt,hunkLineCount:1},dt={paddingTop:8,paddingBottom:8,gap:8},ft={omega:.015,positionEpsilon:.5,velocityEpsilon:.05},pt=Object.freeze({fromStart:0,fromEnd:0}),mt={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},ht=Object.freeze([]);function gt(e,t){return e-(t===0?0:1)}function _t(e,t){return gt(e,t)+t}var F,vt=0,yt=class extends Error{constructor(){super(`Highlighter is disposed`),this.name=`HighlighterDisposedError`}};function bt(){return F}function I(e){return e??F??`shiki-js`}function xt(e){if(F!=null&&F!==e)throw Error(`Cannot load the "${e}" highlighter while "${F}" is in use. Only one highlighter type can be active at a time; dispose every "${F}" instance (disposeHighlighter() disposes the shared one) before switching.`)}function St(e){xt(e),F=e,vt++}function Ct(){vt--,vt===0&&(F=void 0)}var wt=new Map,Tt=new Map,Et=new Map,Dt=new Map,Ot=new Map,kt=new Set;function L(e=et){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}function At(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}function jt(e){let t;return()=>t??=e().then(e=>(t=e,e),e=>{throw t=void 0,e})}function Mt(e){return typeof e==`object`&&e&&`default`in e?e.default:e}var Nt=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name=`DuplicateThemeError`}},Pt=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name=`UnregisteredThemeError`}},Ft=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name=`UnresolvedThemeError`}};function It(e={}){let t=new Map,n=new Map,r=new Map,i=0;function a(e,n){if(t.has(e))throw new Nt(e);t.set(e,n)}function o(e,n){return!t.has(e)&&(t.set(e,n),!0)}function s(e){return t.has(e)}function c(a){let o=n.get(a);if(o!==void 0)return Promise.resolve(o);let s=r.get(a);if(s!==void 0)return s;let c=t.get(a);if(c===void 0&&e.fallbackLoader===void 0)return Promise.reject(new Pt(a));let l=i,u=Promise.resolve().then(()=>c===void 0?e.fallbackLoader?.(a):c()).then(async t=>{if(t===void 0)throw new Pt(a);let o=Mt(t),s=e.normalizeTheme===void 0?o:await e.normalizeTheme(o,a);return l===i&&n.set(a,s),r.get(a)===u&&r.delete(a),s}).catch(e=>{throw r.get(a)===u&&r.delete(a),e});return r.set(a,u),u}function l(e){return Promise.all(e.map(e=>c(e)))}function u(e,t){n.set(e,t)}function d(e){for(let[t,n]of e)u(t,n)}function f(e){return n.get(e)}function p(e){let t=[];for(let r of e){let e=n.get(r);if(e===void 0)throw new Ft(r);t.push(e)}return t}function m(e){return n.has(e)}function h(e){for(let t of e)if(!n.has(t))return!1;return!0}function g(e){let t=n.get(e);return t===void 0?c(e):t}function _(){i++,n.clear(),r.clear()}return{clearResolvedThemes:_,getResolvedOrResolveTheme:g,getResolvedTheme:f,getResolvedThemes:p,hasRegisteredTheme:s,hasResolvedTheme:m,hasResolvedThemes:h,registerTheme:a,registerThemeIfAbsent:o,resolveTheme:c,resolveThemes:l,seedResolvedTheme:u,seedResolvedThemes:d}}var Lt=new Map,Rt=new Map,zt=jt(()=>A(()=>import(`./loader-BljfpPoZ.js`),[])),Bt=jt(()=>A(()=>import(`./themes-SQq_asFq.js`),[])),Vt=jt(()=>A(()=>import(`./core-DfsS1UI1.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3]))),Ht=[[`editor.lineHighlightBackground`,`editor.active_line.background`],[`editor.selectionBackground`,`element.selected`],[`editor.findMatchHighlightBackground`,`search.match_background`],[`editorBracketMatch.background`,`editor.document_highlight.bracket_background`],[`editorError.foreground`,`error`],[`editorWarning.foreground`,`warning`],[`editorInfo.foreground`,`info`],[`editorHint.foreground`,`hint`],[`gitDecoration.addedResourceForeground`,`created`,`terminal.ansi.green`],[`gitDecoration.deletedResourceForeground`,`deleted`,`terminal.ansi.red`],[`gitDecoration.modifiedResourceForeground`,`modified`,`terminal.ansi.blue`]];function Ut(e,t){let n=`themes`in t?t.themes[0]:t;if(n==null)throw Error(`Theme "${e}" is an empty Zed theme family.`);let r={...n,name:e},i={};for(let[e,t]of Object.entries(r.style))typeof t==`string`&&(i[e]=t);let a=r.style.players?.[0];a?.cursor!=null&&(i[`editorCursor.foreground`]??=a.cursor),a?.selection!=null&&(i[`editor.selectionBackground`]??=a.selection);for(let[e,...t]of Ht){if(i[e]!=null)continue;let n=t.find(e=>i[e]!=null);n!=null&&(i[e]=i[n])}if(r.cssVariables===!0)i[`editor.foreground`]=`var(--hls-foreground)`,i[`editor.background`]=`var(--hls-background)`;else if(typeof r.cssVariables==`object`){i[`editor.foreground`]??=i.text??i.foreground??`foreground`,i[`editor.background`]??=i.background??`background`;let{prefix:e=`--hls-`,defaults:t}=r.cssVariables;for(let[n,r]of Object.entries(i)){let a=t?.[r];i[n]=`var(${e}${r}${a?`, ${a}`:``})`}}let o=r.appearance===`light`?`light`:`dark`;return{name:e,type:o,colors:i,zed:r,fg:i[`editor.foreground`]??i.text??i.foreground??(o===`light`?`#333333`:`#bbbbbb`),bg:i[`editor.background`]??i.background??(o===`light`?`#ffffff`:`#1e1e1e`)}}function Wt(e){let t=Rt.get(e);return t??(t=It({fallbackLoader:async t=>{if(typeof __DIFFS_WORKER__<`u`?__DIFFS_WORKER__:At())throw Error(`Theme "${t}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedThemes parameter.`);let n=Lt.get(t);if(e===`highlights`){let e=n?.zed??n?.diffs;if(e!=null){let n=await e(),r=`default`in n?n.default:n;if(`zed`in r&&r.zed!=null)return r;if(`style`in r||`themes`in r)return Ut(t,r);throw Error(`Theme "${t}" is a TextMate theme; register a Zed theme with registerCustomTheme(name, loader, 'zed') for Highlights.`)}let r=zt(),{themes:i}=r instanceof Promise?await r:r,a=i[t];if(a!=null)return Ut(t,(await a()).default);if(n?.textmate!=null)throw Error(`Theme "${t}" is only registered for TextMate; use registerCustomTheme(name, loader, 'zed') for Highlights.`)}else{let e=n?.textmate??n?.diffs,r;if(e!=null){let t=await e();r=`default`in t?t.default:t}else{let e=Bt(),{themes:i}=e instanceof Promise?await e:e,a=i.getTheme(t);if(a==null&&n?.zed!=null)throw Error(`Theme "${t}" is only registered for Zed; use registerCustomTheme(name, loader, 'textmate') for Shiki.`);if(a==null)throw Error(`No valid theme loader registered for "${t}"`);let o=await a.load();r=`default`in o?o.default:o}if(`style`in r||`themes`in r)throw Error(`Theme "${t}" is a Zed theme; use preferredHighlighter: 'highlights' or register a TextMate theme for Shiki.`);let i=Vt(),{normalizeTheme:a,createCssVariablesTheme:o}=i instanceof Promise?await i:i;if(`cssVariables`in r&&r.cssVariables!=null)return{...r,textmate:a(o(r.cssVariables))};if(`textmate`in r&&r.textmate!=null)return{...r,textmate:a(r.textmate)};let s=a(r);return{name:s.name,type:s.type,fg:s.fg,bg:s.bg,colors:s.colors,textmate:s}}throw Error(`No valid theme loader registered for "${t}"`)},normalizeTheme:(e,t)=>{if(e.name!==t)throw Error(`resolvedTheme: themeName: ${t} does not match theme.name: ${e.name}`);return e}}),Rt.set(e,t)),t}function Gt(e,t=I()){return typeof t!=`string`&&t.isDisposed?!1:(typeof t==`string`?Wt(t):t.themeResolver).hasResolvedThemes(L(e))}var R;async function Kt(e){let t=I(e);St(t);try{if(t===`highlights`){let{HighlightsHighlighter:e}=await A(async()=>{let{HighlightsHighlighter:e}=await import(`./highlights-BJb1-tzP.js`);return{HighlightsHighlighter:e}},__vite__mapDeps([4,5,6,2,3,1]));return new e}let{ShikiHighlighter:e}=await A(async()=>{let{ShikiHighlighter:e}=await import(`./shiki-DueA5xDi.js`);return{ShikiHighlighter:e}},__vite__mapDeps([7,5,6,2,3,1,8,0,9,10]));return await e.create(t)}finally{Ct()}}async function qt({themes:e,langs:t,preferredHighlighter:n}){Jt();let r=R??=Kt(bt()??n),i;try{i=await r}catch(e){throw R===r&&(R=void 0),e}if(R===r&&(R=i),await Promise.all([i.themeResolver.resolveThemes(e),i.loadLanguages(t)]),i.isDisposed)throw new yt;return i}function Jt(){R!=null&&!(`then`in R)&&R.isDisposed&&(R=void 0)}function z({theme:e,lang:t,langs:n}={}){Jt();let r=R;if(!(r==null||`then`in r||e!=null&&!Gt(e,r)||(t!=null||n!=null)&&!r.hasLoadedLanguages([...t==null?[]:[t],...n??[]])))return r}async function Yt(e){await qt(e)}function Xt(e,t){return e==null||t==null||typeof e==`string`||typeof t==`string`?e===t:e.dark===t.dark&&e.light===t.light}function Zt(e,t){let n=Array.isArray(e)?e:[e];return t==null?n.every(e=>e===`text`||e===`ansi`||kt.has(e)):t.hasLoadedLanguages(n)}function Qt(e,t){return Xt(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}var B=new Map,$t=0,V={"1c":`1c`,abap:`abap`,as:`actionscript-3`,ada:`ada`,adb:`ada`,ads:`ada`,adoc:`asciidoc`,asciidoc:`asciidoc`,"component.html":`angular-html`,"component.ts":`angular-ts`,conf:`nginx`,htaccess:`apache`,cls:`tex`,trigger:`apex`,apl:`apl`,applescript:`applescript`,scpt:`applescript`,ara:`ara`,asm:`asm`,s:`riscv`,astro:`astro`,awk:`awk`,bal:`ballerina`,sh:`zsh`,bash:`zsh`,bat:`cmd`,cmd:`cmd`,be:`berry`,beancount:`beancount`,bib:`bibtex`,bicep:`bicep`,"blade.php":`blade`,bsl:`bsl`,c:`c`,h:`objective-cpp`,cs:`csharp`,cpp:`cpp`,cppm:`cpp`,hpp:`cpp`,cc:`cpp`,cxx:`cpp`,hh:`cpp`,cdc:`cdc`,cairo:`cairo`,clar:`clarity`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,soy:`soy`,cmake:`cmake`,"CMakeLists.txt":`cmake`,cob:`cobol`,cbl:`cobol`,cobol:`cobol`,CODEOWNERS:`codeowners`,ql:`ql`,coffee:`coffeescript`,lisp:`lisp`,cl:`lisp`,lsp:`lisp`,log:`log`,v:`verilog`,cql:`cql`,cr:`crystal`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cypher`,cyp:`cypher`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,patch:`diff`,Dockerfile:`dockerfile`,dockerfile:`dockerfile`,env:`dotenv`,dm:`dream-maker`,edge:`edge`,el:`emacs-lisp`,ex:`elixir`,exs:`elixir`,elm:`elm`,erb:`erb`,erl:`erlang`,hrl:`erlang`,f:`fortran-fixed-form`,for:`fortran-fixed-form`,fs:`fsharp`,fsi:`fsharp`,fsx:`fsharp`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`fortran-free-form`,f95:`fortran-free-form`,fnl:`fennel`,fish:`fish`,ftl:`ftl`,tres:`gdresource`,res:`gdresource`,gd:`gdscript`,gdshader:`gdshader`,gs:`genie`,feature:`gherkin`,COMMIT_EDITMSG:`git-commit`,"git-rebase-todo":`git-rebase`,gjs:`glimmer-js`,gleam:`gleam`,gts:`glimmer-ts`,glsl:`glsl`,vert:`glsl`,frag:`glsl`,shader:`shaderlab`,gp:`gnuplot`,plt:`gnuplot`,gnuplot:`gnuplot`,go:`go`,graphql:`graphql`,gql:`graphql`,groovy:`groovy`,gvy:`groovy`,hack:`hack`,haml:`haml`,hbs:`handlebars`,handlebars:`handlebars`,hs:`haskell`,lhs:`haskell`,hx:`haxe`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,fx:`hlsl`,html:`html`,htm:`html`,http:`http`,rest:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,cfg:`ini`,jade:`pug`,pug:`pug`,java:`java`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jinja:`jinja`,jinja2:`jinja`,j2:`jinja`,jison:`jison`,jl:`julia`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,libsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,kt:`kotlin`,kts:`kts`,kql:`kusto`,tex:`tex`,ltx:`tex`,lean:`lean4`,less:`less`,liquid:`liquid`,lit:`lit`,ll:`llvm`,logo:`logo`,lua:`lua`,luau:`luau`,Makefile:`makefile`,mk:`makefile`,makefile:`makefile`,md:`markdown`,markdown:`markdown`,marko:`marko`,m:`wolfram`,mat:`matlab`,mdc:`mdc`,mdx:`mdx`,wiki:`wikitext`,mediawiki:`wikitext`,mmd:`mermaid`,mermaid:`mermaid`,mips:`mipsasm`,mojo:`mojo`,"🔥":`mojo`,move:`move`,nar:`narrat`,nf:`nextflow`,nim:`nim`,nims:`nim`,nimble:`nim`,nix:`nix`,nu:`nushell`,mm:`objective-cpp`,ml:`ocaml`,mli:`ocaml`,mll:`ocaml`,mly:`ocaml`,odin:`odin`,pas:`pascal`,p:`pascal`,pl:`prolog`,pm:`perl`,t:`perl`,raku:`raku`,p6:`raku`,pl6:`raku`,php:`php`,phtml:`php`,pls:`plsql`,sql:`sql`,po:`po`,polar:`polar`,pcss:`postcss`,pot:`pot`,potx:`potx`,pq:`powerquery`,pqm:`powerquery`,ps1:`powershell`,psm1:`powershell`,psd1:`powershell`,prisma:`prisma`,pro:`prolog`,P:`prolog`,properties:`properties`,proto:`protobuf`,pp:`puppet`,purs:`purescript`,py:`python`,pyw:`python`,pyi:`python`,BUCK:`python`,BUILD:`python`,PACKAGE:`python`,WORKSPACE:`python`,Tiltfile:`python`,bazel:`python`,bxl:`python`,bzl:`python`,bzlmod:`python`,star:`python`,sky:`python`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,R:`r`,rkt:`racket`,rktl:`racket`,razor:`razor`,cshtml:`razor`,rb:`ruby`,rbw:`ruby`,reg:`reg`,regex:`regexp`,rel:`rel`,rs:`rust`,rst:`rst`,rake:`ruby`,gemspec:`ruby`,jbuilder:`ruby`,builder:`ruby`,rabl:`ruby`,arb:`ruby`,ru:`ruby`,podspec:`ruby`,Gemfile:`ruby`,Rakefile:`ruby`,Guardfile:`ruby`,Capfile:`ruby`,Berksfile:`ruby`,Brewfile:`ruby`,Vagrantfile:`ruby`,Thorfile:`ruby`,Appraisals:`ruby`,Dangerfile:`ruby`,sas:`sas`,sass:`sass`,scala:`scala`,sc:`scala`,scm:`scheme`,ss:`scheme`,sld:`scheme`,scss:`scss`,sdbl:`sdbl`,shadergraph:`shader`,st:`smalltalk`,sol:`solidity`,sparql:`sparql`,rq:`sparql`,spl:`splunk`,config:`ssh-config`,do:`stata`,ado:`stata`,dta:`stata`,styl:`stylus`,stylus:`stylus`,svelte:`svelte`,swift:`swift`,sv:`system-verilog`,svh:`system-verilog`,service:`systemd`,socket:`systemd`,device:`systemd`,timer:`systemd`,talon:`talonscript`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsp:`typespec`,tsv:`tsv`,tsx:`tsx`,ttl:`turtle`,twig:`twig`,typ:`typst`,vv:`v`,vala:`vala`,vapi:`vala`,vb:`vb`,vbs:`vb`,bas:`vb`,vh:`verilog`,vhd:`vhdl`,vhdl:`vhdl`,vim:`vimscript`,vue:`vue`,"vine.ts":`vue-vine`,vy:`vyper`,wasm:`wasm`,wat:`wasm`,wy:`文言`,wgsl:`wgsl`,wit:`wit`,wl:`wolfram`,nb:`wolfram`,xml:`xml`,xsl:`xsl`,xslt:`xsl`,yaml:`yaml`,yml:`yml`,zs:`zenscript`,zig:`zig`,zsh:`zsh`,sty:`tex`};function H(e){let t=en(e);if(t!=null)return t;let n=e.split(/[/\\]/).pop()??e;return n===e?`text`:en(n)??`text`}function en(e){if(B.has(e))return B.get(e)??`text`;if(Object.hasOwn(V,e))return V[e]??null;let t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(B.has(t[1]))return B.get(t[1])??`text`;if(Object.hasOwn(V,t[1]))return V[t[1]]??`text`}let n=e.match(/\.([^.]+)$/)?.[1]??``;return B.has(n)?B.get(n)??`text`:Object.hasOwn(V,n)?V[n]??`text`:null}function tn(){return $t}function nn(){return Object.fromEntries(B)}function rn(e){return(e.lang??H(e.name))===`text`}function U(e){return`--${e===`token`?`diffs-token`:`diffs`}-`}var an=/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i,on=/^0(?:\.0+)?%?$/;function sn(e){let t=e.indexOf(`(`);if(t<=0||!e.endsWith(`)`))return;let n=e.slice(0,t).trim();if(!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(n))return;let r=e.slice(t+1,-1).trim();if(r.length===0)return;let i=r.lastIndexOf(`/`);if(i!==-1)return r.slice(i+1).trim();if(/^(?:rgba|hsla)$/i.test(n)){let e=r.split(`,`);if(e.length===4)return e[3]?.trim()}}function cn(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(e.trim());if(t==null)return null;let n=t[1],r,i=1;return n.length===3?r=n.split(``).map(e=>e+e).join(``):n.length===6?r=n:(r=n.slice(0,6),i=parseInt(n.slice(6,8),16)/255),[parseInt(r.slice(0,2),16),parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16),i]}function ln(e){if(e==null)return null;let t=cn(e);if(t==null)return null;let n=t[0]/255,r=t[1]/255,i=t[2]/255,a=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*a(n)+.7152*a(r)+.0722*a(i)}function un(e){if(e==null)return!1;let t=e.trim().toLowerCase();if(t===`transparent`||an.test(t))return!0;let n=sn(t);return n!=null&&on.test(n)}function dn(e,t,n){if(t==null||n==null)return!1;let r=ln(e),i=ln(t),a=ln(n);return r==null||i==null||a==null?!1:Math.abs(r-a)<Math.abs(r-i)}var fn=new WeakMap;function pn(e){let t=fn.get(e);if(t!=null)return t;let n=e.colors??{},r={...n},i=n[`editor.background`]??e.bg,a=n[`editor.foreground`]??e.fg,o=n[`sideBar.background`]??i,s=n[`sideBar.foreground`]??a;W(r,`editor.background`,i),W(r,`editor.foreground`,a),W(r,`sideBar.background`,o),W(r,`sideBar.foreground`,s),W(r,`input.background`,n[`input.background`]??o),W(r,`sideBarSectionHeader.foreground`,n[`sideBarSectionHeader.foreground`]??s),W(r,`list.activeSelectionForeground`,n[`list.activeSelectionForeground`]??s),W(r,`gitDecoration.addedResourceForeground`,mn(n[`gitDecoration.addedResourceForeground`],n[`terminal.ansiGreen`],n[`editorGutter.addedBackground`])),W(r,`gitDecoration.modifiedResourceForeground`,mn(n[`gitDecoration.modifiedResourceForeground`],n[`terminal.ansiBlue`],n[`editorGutter.modifiedBackground`])),W(r,`gitDecoration.deletedResourceForeground`,mn(n[`gitDecoration.deletedResourceForeground`],n[`terminal.ansiRed`],n[`editorGutter.deletedBackground`]));let c=(un(n[`list.focusOutline`])?void 0:n[`list.focusOutline`])??(un(n.focusBorder)?void 0:n.focusBorder);c==null?delete r[`list.focusOutline`]:r[`list.focusOutline`]=c;let l=n[`list.hoverBackground`];l!=null&&(hn(l,o)||dn(l,o,s))&&delete r[`list.hoverBackground`];let u=Object.freeze({...e,colors:Object.freeze(r)});return fn.set(e,u),u}function W(e,t,n){n!=null&&n!==``&&(e[t]=n)}function mn(...e){for(let t of e)if(t!=null&&t!==``)return t}function hn(e,t){return t!=null&&e.toLowerCase()===t.toLowerCase()}function gn({theme:e=et,highlighter:t,prefix:n}){let r=``;if(typeof e==`string`){let i=t.getTheme(e),a=_n(i,t);r+=`color:${a.fg};`,r+=`background-color:${a.bg};`,r+=`${U(`global`)}fg:${a.fg};`,r+=`${U(`global`)}bg:${a.bg};`,r+=vn(i,n),r+=yn(i)}else{let n=t.getTheme(e.dark),i=_n(n,t);r+=`${U(`global`)}dark:${i.fg};`,r+=`${U(`global`)}dark-bg:${i.bg};`,r+=vn(n,`dark`),r+=yn(n,`dark`),n=t.getTheme(e.light),i=_n(n,t),r+=`${U(`global`)}light:${i.fg};`,r+=`${U(`global`)}light-bg:${i.bg};`,r+=vn(n,`light`),r+=yn(n,`light`)}return r}function _n(e,t){if(t.name===`highlights`&&e.zed?.cssVariables===!0){let e=U(`token`);return{fg:`var(${e}foreground)`,bg:`var(${e}background)`}}return pn(e)}function vn(e,t){t=t==null?``:`${t}-`;let n=``,r=e.colors?.[`gitDecoration.addedResourceForeground`]??e.colors?.[`terminal.ansiGreen`];r!=null&&(n+=`${U(`global`)}${t}addition-color:${r};`);let i=e.colors?.[`gitDecoration.deletedResourceForeground`]??e.colors?.[`terminal.ansiRed`];i!=null&&(n+=`${U(`global`)}${t}deletion-color:${i};`);let a=e.colors?.[`gitDecoration.modifiedResourceForeground`]??e.colors?.[`terminal.ansiBlue`];return a!=null&&(n+=`${U(`global`)}${t}modified-color:${a};`),n}function yn(e,t){t=t==null?``:`${t}-`;let n=U(`global`),r=e.colors,i=``,a=r?.[`editor.findMatchHighlightBackground`],o=r?.[`editor.findMatchHighlightForeground`];a!=null&&o!=null&&(i+=`${n}${t}bg-search-match-theme:${a};`,i+=`${n}${t}fg-search-match-theme:${o};`);let s=r?.[`editor.findMatchBackground`],c=r?.[`editor.findMatchForeground`];return s!=null&&c!=null&&(i+=`${n}${t}bg-search-match-current-theme:${s};`,i+=`${n}${t}fg-search-match-current-theme:${c};`),i}var bn=10,xn=13,Sn=4,Cn=40;function wn(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
|
|
3
|
-
`),i=0,a=0;for(;n!==-1||r!==-1;){let o;if(n!==-1&&(r===-1||n<r)?r===n+1?(o=r+1,n=e.indexOf(`\r`,o),r=e.indexOf(`
|
|
4
|
-
`,o)):(o=n+1,n=e.indexOf(`\r`,o)):(o=r+1,r=e.indexOf(`
|
|
5
|
-
`,o)),t.push(o),++a===Sn){if(o-i<=Cn){for(let n=o;n<e.length;n++){let r=e.charCodeAt(n);(r===bn||r===xn)&&(r===xn&&n+1<e.length&&e.charCodeAt(n+1)===bn&&n++,t.push(n+1))}return t}i=o,a=0}}return t}function Tn(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r===bn||r===xn)&&(r===xn&&n+1<e.length&&e.charCodeAt(n+1)===bn&&n++,t++)}return t}function En(e){let t=wn(e),n=t.length,r=Array(n);for(let i=0;i<n;i++){let a=i+1<n?t[i+1]:e.length;r[i]=e.slice(t[i],a)}return r}function Dn(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}function On(e,t){for(let n of t)e.push(n)}function kn(e,t,n){return{lang:e,...typeof t==`string`?{theme:t}:{themes:t},defaultColor:!1,cssVariablePrefix:U(`token`),tokenizeMaxLineLength:n,tokenizeTimeLimit:0}}var An=class{parent;nextEdge;#e;#t;#n=[];#r=0;#i=[];#a=[];constructor(e,t,n,r){this.parent=this.#e=e,this.#t=r,t.length>1&&t.sort((e,t)=>e.start.line===t.start.line?e.start.character===t.start.character?e.end.line===t.end.line?t.end.character-e.end.character:t.end.line-e.end.line:e.start.character-t.start.character:e.start.line-t.start.line);let i=this.#n;for(let e=0;e<t.length;e++){let a=t[e],o={decoration:a,order:e,from:a.start.line===n?a.start.character:0,to:a.end.line===n?a.end.character:r};i.push({position:Math.max(0,Math.min(o.from,r)),range:o,start:!0},{position:Math.max(0,Math.min(o.to,r)),range:o,start:!1})}i.sort((e,t)=>e.position-t.position),this.nextEdge=i[0]?.position??r}moveTo(e){this.nextEdge===e&&this.#r<this.#n.length&&this.#o(e)}#o(e){let t=this.#n,n=this.#t,r=this.#r,i=r;for(;t[i]?.position===e;)i++;this.#r=i,this.nextEdge=t[i]?.position??this.#t;let a=!1;for(let a=r;a<i;a++){let{range:r,start:i}=t[a];!i&&r.from!==r.to&&e<n&&this.#s(r,!1)}for(let o=r;o<i;o++){let{range:r,start:i}=t[o];i&&r.from<=e&&r.to>=e&&(r.to>e||r.from===e||e===n)&&(this.#s(r,!0),r.from===r.to&&(a=!0))}if(a){this.#c();for(let e=r;e<i;e++){let{range:n,start:r}=t[e];r&&n.from===n.to&&this.#s(n,!1)}}e<n&&(this.parent=this.#c())}#s(e,t){let n=this.#i,r=0,i=n.length;for(;r<i;){let t=r+i>>>1;n[t].order<e.order?r=t+1:i=t}t?n.splice(r,0,e):n[r]===e&&n.splice(r,1)}#c(){let e=this.#a,t=this.#e,n=0;for(let r of this.#i){if(e[n]?.range!==r){e.length=n;let i={type:`element`,tagName:`span`,properties:{...r.decoration.properties},children:[]};t.children.push(i),e.push({range:r,node:i})}t=e[n++].node}return e.length=n,t}};function G(e){return{type:`text`,value:e}}function K({tagName:e,children:t=[],properties:n={}}){return{type:`element`,tagName:e,properties:n,children:t}}function jn({name:e,width:t=16,height:n=16,properties:r}){return K({tagName:`svg`,properties:{width:t,height:n,viewBox:`0 0 16 16`,...r},children:[K({tagName:`use`,properties:{href:`#${e.replace(/^#/,``)}`}})]})}function Mn(e){return K({tagName:`div`,properties:{"data-gutter":``},children:e})}function Nn(e,t,n,r={}){return K({tagName:`div`,properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t==null?void 0:[K({tagName:`span`,properties:{"data-line-number-content":``},children:[G(`${t}`)]})]})}function Pn(e,t,n){return K({tagName:`div`,properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t===`annotation`?void 0:e,style:t===`annotation`?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function Fn(e){return K({tagName:`div`,children:e.map(([e,t,n])=>e===0&&t===``?n===``?K({tagName:`br`}):G(n):K({tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[G(n)]}))})}function In(e){return K({tagName:`div`,children:e===``?[K({tagName:`br`})]:[K({tagName:`span`,properties:{"data-char":0},children:[G(e)]})]})}function Ln(e,t,n){let r=typeof n.lineInfo==`function`?n.lineInfo(t):n.lineInfo[t-1];if(r==null){let r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),Error(r)}return e.tagName=`div`,e.properties[`data-line`]=r.lineNumber,e.properties[`data-alt-line`]=r.altLineNumber,e.properties[`data-line-type`]=r.type,e.properties[`data-line-index`]=r.lineIndex,e.children.length===0&&e.children.push(G(`
|
|
6
|
-
`)),e}function Rn(e,t,n,{retain:r=!0}={}){let i=!1,a;Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){if(i)return a;let o=n();return r?(a=o,i=!0,Object.getOwnPropertyDescriptor(e,t)?.configurable===!0&&Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:a}),a):o},set(n){if(Object.getOwnPropertyDescriptor(e,t)?.configurable===!0)Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n});else if(Object.isFrozen(e))throw TypeError(`Cannot assign to read only array index '${t}'`);else a=n,i=!0}})}var zn=new WeakMap;function Bn(e,t=!1){let{htmlStyle:n}=e;if(n!=null){let e=t?zn.get(n):void 0;if(e==null){e=``;for(let t in n)e+=`${e===``?``:`;`}${t}:${n[t]}`;t&&zn.set(n,e)}return e}let r=e.color==null?``:`color:${e.color}`;if(e.bgColor!=null&&(r+=`;background-color:${e.bgColor}`),e.fontStyle!=null){e.fontStyle&1&&(r+=`;font-style:italic`),e.fontStyle&2&&(r+=`;font-weight:bold`);let t=!!(e.fontStyle&4),n=!!(e.fontStyle&8);(t||n)&&(r+=`;text-decoration:${t?`underline`:``}${t&&n?` `:``}${n?`line-through`:``}`)}return r.replace(/^;/,``)}var Vn=Symbol(`no-token`),Hn=Symbol(`multiple-tokens`);function Un(e){let t=Wn(e);if(t!=null)return t;let n=Vn,r=[],i=[],a,o=()=>{if(i.length===0||a==null)i=[],a=void 0;else if(i.length===1){let e=i[0];if(e?.type===`element`){Kn(e,a);for(let t of e.children)Gn(t)}else Gn(e);r.push(e),i=[],a=void 0}else{for(let e of i)Gn(e);r.push(K({tagName:`span`,properties:{"data-char":a},children:i})),i=[],a=void 0}},s=e=>{e!==Vn&&(e===Hn?n=Hn:n===Vn?n=e:n!==e&&(n=Hn))};for(let t of e.children){let e=t.type===`element`?Un(t):Vn;s(e),typeof e==`number`?(a!=null&&a!==e&&o(),a??=e,i.push(t)):(o(),r.push(t))}return o(),e.children=r,n}function Wn(e){let t=e.properties[`data-char`];if(typeof t==`number`)return t}function Gn(e){if(e.type===`element`){e.properties[`data-char`]=void 0;for(let t of e.children)Gn(t)}}function Kn(e,t){e.properties[`data-char`]=t}function qn(e,{state:t,lazyLineAST:n=!1,cacheHtmlStyles:r=!1,useTokenTransformer:i=!1,mergeWhitespaces:a=`always`,decorations:o=[],lineOffsets:s=[]}){let c;for(let t of o){let n=c??=new Map,r={...t,start:Zn(t.start,s),end:Zn(t.end,s)},i=Math.min(r.end.line,e.length-1);for(let e=r.start.line;e<=i;e++){let t=n.get(e);t??n.set(e,t=[]),t.push(r)}}let l=(e,n)=>{let o;if(i||a!==`never`){let t=``,n=0;for(let r=0;r<e.length;r++){let a=e[r];if(i){let t=a.content.trim();if(t!==``&&t!==a.content){o??=e.slice(0,r);let n=a.content.indexOf(t);n>0&&o.push({content:a.content.slice(0,n),offset:a.offset}),o.push({...a,content:t,offset:a.offset+n});let i=n+t.length;i<a.content.length&&o.push({content:a.content.slice(i),offset:a.offset+i});continue}}else{let i=!!((a.fontStyle??0)&12);if(!i&&/^\s+$/.test(a.content)&&r<e.length-1){o??=e.slice(0,r),t===``&&(n=a.offset),t+=a.content;continue}t!==``&&o!=null&&(i?o.push({content:t,offset:n}):a={...a,content:t+a.content,offset:n},t=``)}o?.push(a)}}o??=e;let s={type:`element`,tagName:t==null?`span`:`div`,properties:t==null?{class:`line`}:{},children:[]},l=c?.get(n),u=l==null?Jn(s,o,i,r):Yn(s,o,l,n,i,r);return i&&u===0&&s.children.push({type:`element`,tagName:`br`,properties:{},children:[]}),i&&l!=null&&Un(s),t==null?s:Ln(s,n+1,t)};if(!n)return e.map(l);let u=Array(e.length);for(let t=0;t<e.length;t++){let n=e[t];Rn(u,t,()=>l(n,t))}return u}function Jn(e,t,n,r){let i=0;for(let a of t)a.content!==``&&(e.children.push(Xn(a,Bn(a,r),a.content,i,n)),i+=a.content.length);return i}function Yn(e,t,n,r,i,a){let o=0;for(let e of t)o+=e.content.length;let s=new An(e,n,r,o),c=0;for(let e of t){let{content:t}=e;if(t===``)continue;let n=c,r=n+t.length,o=Bn(e,a);for(;c<r;){s.moveTo(c);let a=Math.min(r,s.nextEdge);s.parent.children.push(Xn(e,o,c===n&&a===r?t:t.slice(c-n,a-n),n,i)),c=a}}return s.moveTo(c),c}function Xn(e,t,n,r,i){let a=e.htmlAttrs==null?{}:{...e.htmlAttrs};return t!==``&&(a.style=t),i&&(a[`data-char`]=r),{type:`element`,tagName:`span`,properties:a,children:[{type:`text`,value:n}]}}function Zn(e,t){if(typeof e!=`number`)return e;let n=0,r=t.length;for(;n+1<r;){let i=n+r>>>1;t[i]<=e?n=i:r=i}return{line:n,character:e-(t[n]??0)}}var Qn={forcePlainText:!1};function $n(e,t,{theme:n,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:a,lazyLineAST:o=!1,startingLine:s,totalLines:c,lines:l}=Qn){a?(s??=0,c??=1/0):(s=0,c=1/0);let u=s>0||c<1/0,d=u?l??En(e.contents):void 0,f={lineInfo:[]},p=a?`text`:e.lang??H(e.name),m=typeof n==`string`?t.getTheme(n).type:void 0,h=gn({theme:n,highlighter:t});if(d!=null&&Math.min(s+c,d.length)<=s)return{code:Array(s),themeStyles:h,baseThemeType:m};f.lineInfo=e=>({type:`context`,lineIndex:e-1+s,lineNumber:e+s});let g=qn(t.codeToTokens(er(d==null?e.contents:tr(d,s,c)),kn(p,n,r)).tokens,{state:f,useTokenTransformer:i,lazyLineAST:o&&!a&&!i,cacheHtmlStyles:t.name===`highlights`}),_=u?Array(s):g;return u&&On(_,g),{code:_,themeStyles:h,baseThemeType:m}}function er(e){return e.replace(/\r(?!\n)/g,`
|
|
7
|
-
`)}function tr(e,t,n){if(e.length===0)return``;let r=Math.min(t+n,e.length),i=e.slice(t,r).join(``);return r<e.length?Dn(i):i}var nr=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled because the pool terminated`),this.name=`WorkerPoolTerminatedError`}},rr=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled before the task completed`),this.name=`WorkerPoolTaskCanceledError`}},q=class extends Error{constructor(e,t){super(e,t),this.name=`WorkerPoolWorkerError`}},ir=new WeakSet;function ar(e){ir.add(e)}function or(e){return e instanceof nr||e instanceof rr}function sr(e){return or(e)||e instanceof q&&ir.has(e)}function cr(e,t){return e?.cacheKey!=null||t?.cacheKey!=null?e?.cacheKey===t?.cacheKey:e===t}function lr(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}function ur(e,t){return Xt(e.theme,t.theme)&&(e.preferredDiffLib??`jsdiff`)===(t.preferredDiffLib??`jsdiff`)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function dr(e){let t=e.lang??H(e.name),n=e.lang??(e.prevName==null?`text`:H(e.prevName));return t===`text`&&n===`text`}function fr(e,t){let n=t===`additions`?e.additionLines:e.deletionLines;if(n.length===0)return!1;if(e.isPartial){let n=e.hunks.at(-1);return n!=null&&!(t===`additions`?n.noEOFCRAdditions:n.noEOFCRDeletions)}return n.at(-1)?.endsWith(`
|
|
8
|
-
`)===!0}function pr(e){return{...lt,...e}}function mr(e,t){return hr(e,t)+gr(e,t)}function hr(e,t){return t?0:e.diffHeaderHeight}function gr(e,t){return e.paddingTop??(t?e.spacing:0)}function _r(e){return e.paddingBottom??e.spacing}function vr(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}function yr(e){return[gt(e.additionStart,e.additionCount)+1,_t(e.additionStart,e.additionCount)+1]}function br(e){return[gt(e.deletionStart,e.deletionCount)+1,_t(e.deletionStart,e.deletionCount)+1]}function xr(e,t){return t===`additions`?yr(e):br(e)}function Sr(e,t,n){let r={fromStart:e?.fromStart??0,fromEnd:e?.fromEnd??0};return(t===`up`||t===`both`)&&(r.fromStart+=n),(t===`down`||t===`both`)&&(r.fromEnd+=n),r}function Cr({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let a=Math.max(t,0);if(a===0||e)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(n===!0||a<=i)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(r),s=Math.min(Math.max(o?.fromStart??0,0),a),c=Math.min(Math.max(o?.fromEnd??0,0),a),l=s+c,u=l>=a;return{fromStart:u?a:s,fromEnd:u?0:c,rangeSize:a,collapsedLines:Math.max(a-l,0),renderAll:u}}function wr({fileDiff:e,errorPrefix:t}){let n=e.hunks[e.hunks.length-1];if(n==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let r=e.additionLines.length-_t(n.additionStart,n.additionCount),i=e.deletionLines.length-_t(n.deletionStart,n.deletionCount);if(r<=0&&i<=0)return 0;if(r!==i)throw Error(`${t}: trailing context mismatch (additions=${r}, deletions=${i}) for ${e.name}`);return Math.min(r,i)}function Tr({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=wr({fileDiff:e,errorPrefix:i});if(a<=0)return;if(n===!0||a<=r)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(e.hunks.length),s=Math.min(Math.max(o?.fromStart??0,0),a);return{fromStart:s,fromEnd:0,rangeSize:a,collapsedLines:a-s,renderAll:s>=a}}function Er({fileDiff:e,lineNumber:t,side:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return!1;for(let[a,o]of e.hunks.entries()){let[s,c]=xr(o,n);if(t<s){let n=Cr({isPartial:e.isPartial,rangeSize:o.collapsedBefore,expandedHunks:r,hunkIndex:a,collapsedContextThreshold:i}),c=s-n.rangeSize;return!n.renderAll&&t>=c+n.fromStart&&t<s-n.fromEnd}if(t<c)return!1}let a=Tr({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:`isDiffLineInCollapsedContext`});if(a==null||a.renderAll)return!1;let[,o]=xr(e.hunks[e.hunks.length-1],n);return t>=o+a.fromStart&&t<o+a.rangeSize}function Dr({fileDiff:e,lineNumber:t,direction:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return t;let a=[],o=1;for(let[t,n]of e.hunks.entries()){let[s,c]=yr(n),l=Cr({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:r,hunkIndex:t,collapsedContextThreshold:i}),u=s-l.rangeSize;l.renderAll?a.push([u,s]):(l.fromStart>0&&a.push([u,u+l.fromStart]),l.fromEnd>0&&a.push([s-l.fromEnd,s])),a.push([s,c]),o=c}let s=Tr({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:`getNearestRenderableAdditionLine`});if(s!=null){let e=o;o=e+s.rangeSize,s.renderAll?a.push([e,o]):s.fromStart>0&&a.push([e,e+s.fromStart])}if(t>=o)return t;if(n===`down`){for(let[e,n]of a)if(n>t)return Math.max(e,t)}else for(let e=a.length-1;e>=0;e--){let[n,r]=a[e];if(n<=t)return Math.min(r-1,t)}}function Or({type:e,metrics:t}){return t.hunkSeparatorHeight??vr(e)}function kr({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function Ar({type:e,hunkIndex:t,hunkSpecs:n}){switch(e){case`simple`:return t>0;case`metadata`:return n!=null;case`line-info`:case`line-info-basic`:case`custom`:return!0}}function jr(e){return e!==`simple`&&e!==`metadata`}function Mr({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!Ar({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=Or({type:e,metrics:t}),a=kr({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function Nr({type:e,metrics:t}){if(!jr(e))return;let n=Or({type:e,metrics:t}),r=kr({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function J(e){throw Error(`DiffRowCursor: row has no ${e} line`)}var Pr=0,Fr=1,Ir=2,Lr=3,Rr=4,zr=5,Br=6,Vr=7,Hr=class{diff;diffStyle;expandedHunks;collapsedContextThreshold;includeTrailingNewline;startingLine;windowEnd;unifiedCount=0;splitCount=0;rowType=`context`;rowHunkIndex=0;rowHunk=void 0;rowHasDeletion=!1;rowHasAddition=!1;index=-1;end=0;secondStretchFirst=0;secondStretchEnd=0;deletionIndexStart=0;deletionNumberStart=0;deletionUnifiedStart=0;additionIndexStart=0;additionNumberStart=0;additionUnifiedStart=0;splitStart=0;firstRowCollapsedBefore=0;collapsedAfterValue=0;collapsedAfterRow=-1;deletionNoEOFCRRow=-1;additionNoEOFCRRow=-1;part=Pr;walkHunkIndex=0;walkHunk=void 0;contentIndex=0;pendingCollapsed=0;leadingStartRows=0;leadingEndRows=0;leadingRangeSize=0;trailingRows=-1;trailingCollapsed=0;unifiedAt=0;splitAt=0;deletionIndexAt=0;additionIndexAt=0;deletionNumberAt=0;additionNumberAt=0;collapsedAfterAt=-1;constructor({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,includeTrailingNewline:o=!1}){this.diff=e,this.diffStyle=t,this.startingLine=n,this.windowEnd=n+r,this.expandedHunks=i,this.collapsedContextThreshold=a,this.includeTrailingNewline=o,r===0?this.part=Vr:n>0&&this.findStartingHunk()}next(){let{index:e,end:t}=this,n=e+1;return n<t?(this.index=n,!0):this.nextRun()}get type(){return this.rowType}get hunkIndex(){return this.rowHunkIndex}get hunk(){return this.rowHunk}get hasDeletion(){return this.rowHasDeletion}get hasAddition(){return this.rowHasAddition}get deletionLineIndex(){let{rowHasDeletion:e,deletionIndexStart:t,index:n}=this;return e||J(`deletion`),t+n}get deletionLineNumber(){let{rowHasDeletion:e,deletionNumberStart:t,index:n}=this;return e||J(`deletion`),t+n}get deletionUnifiedLineIndex(){let{rowHasDeletion:e,deletionUnifiedStart:t,index:n}=this;return e||J(`deletion`),t+n}get deletionNoEOFCR(){let{rowHasDeletion:e,deletionNoEOFCRRow:t,index:n}=this;return e||J(`deletion`),n===t}get additionLineIndex(){let{rowHasAddition:e,additionIndexStart:t,index:n}=this;return e||J(`addition`),t+n}get additionLineNumber(){let{rowHasAddition:e,additionNumberStart:t,index:n}=this;return e||J(`addition`),t+n}get additionUnifiedLineIndex(){let{rowHasAddition:e,additionUnifiedStart:t,index:n}=this;return e||J(`addition`),t+n}get additionNoEOFCR(){let{rowHasAddition:e,additionNoEOFCRRow:t,index:n}=this;return e||J(`addition`),n===t}get unifiedLineIndex(){let{rowHasAddition:e,additionUnifiedStart:t,deletionUnifiedStart:n,index:r}=this;return(e?t:n)+r}get splitLineIndex(){let{splitStart:e,index:t}=this;return e+t}get collapsedBefore(){let{index:e,firstRowCollapsedBefore:t}=this;return e===0?t:0}get collapsedAfter(){let{index:e,collapsedAfterRow:t,collapsedAfterValue:n}=this;return e===t?n:0}findStartingHunk(){let{diff:e,diffStyle:t,startingLine:n}=this,r=e.hunks.length-1,i=0;for(let a of e.hunks){let e=this.getLeadingRegion(a,i),o=e.fromStart+e.fromEnd;if(i===r){let e=this.getTrailingRegion();o+=(e?.fromStart??0)+(e?.fromEnd??0),this.hasTrailingNewlineRow(e?.collapsedLines??0)&&o++}let s=o+a.unifiedLineCount,c=o+a.splitLineCount,{unifiedCount:l,splitCount:u}=this;if((t===`split`?u+c:l+s)>n)break;this.unifiedCount+=s,this.splitCount+=c,i++}this.walkHunkIndex=i}getLeadingRegion(e,t){let{diff:n,expandedHunks:r,collapsedContextThreshold:i}=this;return Cr({isPartial:n.isPartial,rangeSize:e.collapsedBefore,expandedHunks:r,hunkIndex:t,collapsedContextThreshold:i})}getTrailingRegion(){let{diff:e,expandedHunks:t,collapsedContextThreshold:n}=this;return Tr({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`DiffRowCursor`})}hasTrailingNewlineRow(e){let{diff:t,includeTrailingNewline:n}=this;return n&&e===0&&fr(t,`additions`)}clipRun(e,t,n,r){let{diffStyle:i,startingLine:a,windowEnd:o}=this;if(a===0&&o===1/0)return this.index=0,this.end=e,e>0;if(i!==`both`){let r=i===`unified`?t:n;return this.index=Math.max(0,a-r),this.end=Math.min(e,o-r),this.index<this.end}let s=Math.max(0,a-t),c=Math.min(e,o-t),l=Math.max(0,a-n),u=Math.min(e,o-n),d=0,f=0;if(l<u&&(s<c?l<=c?c=Math.max(c,u):(d=l,f=u):(s=l,c=u)),r!=null){let t=Math.max(0,a-r),n=Math.min(e,o-r);t<n&&(s<c?n>=s?s=t:(d=s,f=c,s=t,c=n):(s=t,c=n))}return s>=c?!1:(this.index=s,this.end=c,d<f&&(this.secondStretchFirst=d,this.secondStretchEnd=f),!0)}isPastWindow(){let{diffStyle:e,unifiedCount:t,splitCount:n,windowEnd:r}=this;return e===`unified`?t>=r:(e===`split`||t>=r)&&n>=r}nextRun(){let{diff:e,secondStretchFirst:t,secondStretchEnd:n}=this;if(t<n)return this.index=t,this.end=n,this.secondStretchFirst=0,this.secondStretchEnd=0,!0;for(;;){if(this.part===Vr||this.isPastWindow())return this.part=Vr,!1;switch(this.part){case Pr:{let t=e.hunks[this.walkHunkIndex];if(t==null)return this.part=Vr,!1;this.enterHunk(t),this.part=Fr;break}case Fr:if(this.part=Ir,this.leadingStartRows>0&&this.startExpandedRun(this.leadingStartRows,this.leadingRangeSize,0))return!0;break;case Ir:if(this.part=Lr,this.leadingEndRows>0&&this.startExpandedRun(this.leadingEndRows,this.leadingEndRows,this.takePendingCollapsed()))return!0;this.startingLine>0&&this.skipBlocksBeforeWindow();break;case Lr:{let{walkHunk:e}=this;if(e==null)throw Error(`DiffRowCursor: missing hunk`);let t=e.hunkContent[this.contentIndex];if(t==null){this.part=zr;break}let n=this.contentIndex===e.hunkContent.length-1;if(t.type===`context`){if(this.contentIndex++,this.startContextRun(e,t,n))return!0;break}if(this.part=Rr,this.startChangeRun(e,t,n,!1))return!0;break}case Rr:{let{walkHunk:e}=this;if(e==null)throw Error(`DiffRowCursor: missing hunk`);let t=e.hunkContent[this.contentIndex];if(t==null||t.type!==`change`)throw Error(`DiffRowCursor: missing change content`);let n=this.contentIndex===e.hunkContent.length-1;this.part=Lr,this.contentIndex++;let r=this.startChangeRun(e,t,n,!0),{deletions:i,additions:a}=t;if(this.unifiedCount+=i+a,this.splitCount+=Math.max(i,a),this.unifiedAt+=i+a,this.splitAt+=Math.max(i,a),this.deletionIndexAt+=i,this.additionIndexAt+=a,this.deletionNumberAt+=i,this.additionNumberAt+=a,r)return!0;break}case zr:if(this.part=Br,this.trailingRows>0&&this.startTrailingRun())return!0;break;case Br:{let t=this.walkHunkIndex===e.hunks.length-1;if(this.walkHunkIndex++,this.part=Pr,t&&this.hasTrailingNewlineRow(this.trailingCollapsed)&&this.startTrailingNewlineRun())return!0;break}}}}skipBlocksBeforeWindow(){let{walkHunk:e,diffStyle:t,startingLine:n,unifiedCount:r}=this;if(e==null)throw Error(`DiffRowCursor: missing hunk`);for(;this.contentIndex<e.hunkContent.length;){let r=e.hunkContent[this.contentIndex],i=r.type===`context`?r.lines:r.deletions,a=r.type===`context`?r.lines:r.additions,o=r.type===`context`?r.lines:i+a,s=Math.max(i,a),{unifiedCount:c,splitCount:l}=this;if((t===`split`?l+s:c+o)>n)break;this.unifiedCount+=o,this.splitCount+=s,this.unifiedAt+=o,this.splitAt+=s,this.deletionIndexAt+=i,this.additionIndexAt+=a,this.deletionNumberAt+=i,this.additionNumberAt+=a,this.contentIndex++}this.unifiedCount>r&&(this.pendingCollapsed=0)}enterHunk(e){let{diff:t,diffStyle:n,walkHunkIndex:r}=this,i=gt(e.deletionStart,e.deletionCount),a=gt(e.additionStart,e.additionCount),o=this.getLeadingRegion(e,r),s=r===t.hunks.length-1?this.getTrailingRegion():void 0;this.walkHunk=e,this.contentIndex=0,this.leadingStartRows=o.fromStart,this.leadingEndRows=o.fromEnd,this.leadingRangeSize=o.rangeSize,this.pendingCollapsed=o.collapsedLines,this.trailingRows=s==null?-1:s.fromStart+s.fromEnd,this.trailingCollapsed=s?.collapsedLines??0,this.unifiedAt=e.unifiedLineStart,this.splitAt=e.splitLineStart,this.deletionIndexAt=!t.isPartial&&e.deletionCount===0?i:e.deletionLineIndex,this.additionIndexAt=!t.isPartial&&e.additionCount===0?a:e.additionLineIndex,this.deletionNumberAt=i+1,this.additionNumberAt=a+1,this.collapsedAfterAt=s!=null&&s.collapsedLines>0&&s.fromStart+s.fromEnd===0?n===`unified`?e.unifiedLineStart+e.unifiedLineCount-1:e.splitLineStart+e.splitLineCount-1:-1}takePendingCollapsed(){let{pendingCollapsed:e}=this;return this.pendingCollapsed=0,e}startExpandedRun(e,t,n){let{unifiedCount:r,splitCount:i,walkHunkIndex:a,walkHunk:o,deletionIndexAt:s,deletionNumberAt:c,additionIndexAt:l,additionNumberAt:u,unifiedAt:d,splitAt:f}=this;return this.rowType=`context-expanded`,this.rowHunkIndex=a,this.rowHunk=o,this.rowHasDeletion=!0,this.rowHasAddition=!0,this.deletionIndexStart=s-t,this.deletionNumberStart=c-t,this.deletionUnifiedStart=d-t,this.additionIndexStart=l-t,this.additionNumberStart=u-t,this.additionUnifiedStart=d-t,this.splitStart=f-t,this.firstRowCollapsedBefore=n,this.collapsedAfterRow=-1,this.deletionNoEOFCRRow=-1,this.additionNoEOFCRRow=-1,this.unifiedCount+=e,this.splitCount+=e,this.clipRun(e,r,i)}startContextRun(e,t,n){let{lines:r}=t,{diffStyle:i,unifiedCount:a,splitCount:o,walkHunkIndex:s,deletionIndexAt:c,deletionNumberAt:l,additionIndexAt:u,additionNumberAt:d,unifiedAt:f,splitAt:p}=this,m=r>0;return m&&(this.rowType=`context`,this.rowHunkIndex=s,this.rowHunk=e,this.rowHasDeletion=!0,this.rowHasAddition=!0,this.deletionIndexStart=c,this.deletionNumberStart=l,this.deletionUnifiedStart=f,this.additionIndexStart=u,this.additionNumberStart=d,this.additionUnifiedStart=f,this.splitStart=p,this.firstRowCollapsedBefore=this.takePendingCollapsed(),this.setCollapsedAfterRow(i===`unified`?f:p),this.deletionNoEOFCRRow=n&&e.noEOFCRDeletions?r-1:-1,this.additionNoEOFCRRow=n&&e.noEOFCRAdditions?r-1:-1),this.unifiedCount+=r,this.splitCount+=r,this.unifiedAt+=r,this.splitAt+=r,this.deletionIndexAt+=r,this.additionIndexAt+=r,this.deletionNumberAt+=r,this.additionNumberAt+=r,m&&this.clipRun(r,a,o)}startChangeRun(e,t,n,r){let{deletions:i,additions:a}=t,{diffStyle:o,unifiedCount:s,splitCount:c,walkHunkIndex:l,deletionIndexAt:u,deletionNumberAt:d,additionIndexAt:f,additionNumberAt:p,unifiedAt:m,splitAt:h}=this,g=o===`unified`,_=Math.min(i,a),v=g?r?i:0:r?_:0,y=g?r?a:i:r?Math.max(i,a)-_:_;if(y<=0)return!1;let b=g?!r:!r||i>a,x=g?r:!r||a>i;this.rowType=`change`,this.rowHunkIndex=l,this.rowHunk=e,this.rowHasDeletion=b,this.rowHasAddition=x;let S=g?0:v;this.deletionIndexStart=u+S,this.deletionNumberStart=d+S,this.deletionUnifiedStart=m+S,this.additionIndexStart=f+S,this.additionNumberStart=p+S,this.additionUnifiedStart=m+i+S,this.splitStart=h+S,this.firstRowCollapsedBefore=this.takePendingCollapsed(),this.setCollapsedAfterRow(g?m+v:h+v);let C=g||r||i===a;this.deletionNoEOFCRRow=n&&b&&C&&e.noEOFCRDeletions?y-1:-1,this.additionNoEOFCRRow=n&&x&&C&&e.noEOFCRAdditions?y-1:-1;let w=s+v,T=s+i+S;return this.clipRun(y,b?w:T,c+v,b&&x?T:void 0)}startTrailingRun(){let{diff:e,trailingRows:t,trailingCollapsed:n,unifiedCount:r,splitCount:i,deletionIndexAt:a,deletionNumberAt:o,additionIndexAt:s,additionNumberAt:c,unifiedAt:l,splitAt:u}=this;return this.rowType=`context-expanded`,this.rowHunkIndex=e.hunks.length,this.rowHunk=void 0,this.rowHasDeletion=!0,this.rowHasAddition=!0,this.deletionIndexStart=a,this.deletionNumberStart=o,this.deletionUnifiedStart=l,this.additionIndexStart=s,this.additionNumberStart=c,this.additionUnifiedStart=l,this.splitStart=u,this.firstRowCollapsedBefore=0,this.collapsedAfterValue=n,this.collapsedAfterRow=t-1,this.deletionNoEOFCRRow=-1,this.additionNoEOFCRRow=-1,this.unifiedCount+=t,this.splitCount+=t,this.clipRun(t,r,i)}startTrailingNewlineRun(){let{diff:e,trailingRows:t,unifiedCount:n,splitCount:r,deletionIndexAt:i,deletionNumberAt:a,additionIndexAt:o,additionNumberAt:s,unifiedAt:c,splitAt:l}=this,u=Math.max(t,0),d=fr(e,`deletions`),f=o+u,p=i+u;return this.rowType=d?`context`:`change`,this.rowHunkIndex=e.hunks.length,this.rowHunk=void 0,this.rowHasDeletion=d,this.rowHasAddition=!0,this.deletionIndexStart=p,this.deletionNumberStart=a+u,this.deletionUnifiedStart=c+u,this.additionIndexStart=f,this.additionNumberStart=s+u,this.additionUnifiedStart=c+u,this.splitStart=l+u,this.firstRowCollapsedBefore=0,this.collapsedAfterRow=-1,this.deletionNoEOFCRRow=-1,this.additionNoEOFCRRow=-1,this.unifiedCount++,this.splitCount++,this.clipRun(1,n,r)}setCollapsedAfterRow(e){let{collapsedAfterAt:t,trailingCollapsed:n}=this;t===-1?this.collapsedAfterRow=-1:(this.collapsedAfterValue=n,this.collapsedAfterRow=t-e)}},Ur={forcePlainText:!1};function Wr(e,t,n,{forcePlainText:r,lazyLineAST:i=!1,startingLine:a,totalLines:o,expandedHunks:s,collapsedContextThreshold:c=1}=Ur){r?(a??=0,o??=1/0):(a=0,o=1/0);let l=a>0||o<1/0;i&&=!r&&!n.useTokenTransformer;let u=typeof n.theme==`string`?t.getTheme(n.theme).type:void 0,d=gn({theme:n.theme,highlighter:t}),f={deletionLines:[],additionLines:[]},p=!r&&!e.isPartial,m=r?s:void 0,h=new Map;function g(e){let t=p?0:e,n=h.get(t)??Gr();return h.set(t,n),n}function _(e,t,n,r){if(l){let e=n.at(-1);(e==null||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}let v=new Hr({diff:e,diffStyle:`both`,startingLine:a,totalLines:o,expandedHunks:!l||m,collapsedContextThreshold:c});for(;v.next();){let{hunkIndex:t,type:n,splitLineIndex:r}=v,i=g(t);if(v.hasDeletion){let{deletionLineIndex:t,deletionLineNumber:a,deletionUnifiedLineIndex:o}=v;_(e.deletionLines[t],t,i.deletionSegments,i.deletionContent),i.deletionInfo.push({type:n===`change`?`change-deletion`:n,lineNumber:a,altLineNumber:n===`change`?void 0:v.additionLineNumber,lineIndex:`${o},${r}`})}if(v.hasAddition){let{additionLineIndex:t,additionLineNumber:a,additionUnifiedLineIndex:o}=v;_(e.additionLines[t],t,i.additionSegments,i.additionContent),i.additionInfo.push({type:n===`change`?`change-addition`:n,lineNumber:a,altLineNumber:n===`change`?void 0:v.deletionLineNumber,lineIndex:`${o},${r}`})}}for(let a of h.values()){if(a.deletionContent.length===0&&a.additionContent.length===0)continue;let o={name:e.prevName??e.name,contents:a.deletionContent.value},s={name:e.name,contents:a.additionContent.value},{deletionLines:c,additionLines:l}=Kr({deletionFile:o,deletionInfo:a.deletionInfo,additionFile:s,additionInfo:a.additionInfo,highlighter:t,options:n,languageOverride:r?`text`:e.lang,lazyLineAST:i});if(p)f.deletionLines=c,f.additionLines=l;else for(let[e,t,n]of[[f.deletionLines,c,a.deletionSegments],[f.additionLines,l,a.additionSegments]])if(n.length>0)for(let r of n)for(let n=0;n<r.count;n++)e[r.targetIndex+n]=t[r.originalOffset+n];else if(i){let n=e.length;for(let r=0;r<t.length;r++)Rn(e,n+r,()=>t[r])}else On(e,t)}return{code:f,themeStyles:d,baseThemeType:u}}function Gr(){return{deletionContent:{push(e){this.value+=e,this.length++},value:``,length:0},additionContent:{push(e){this.value+=e,this.length++},value:``,length:0},deletionInfo:[],additionInfo:[],deletionSegments:[],additionSegments:[]}}function Kr({lazyLineAST:e,deletionFile:t,additionFile:n,deletionInfo:r,additionInfo:i,highlighter:a,languageOverride:o,options:{theme:s,useTokenTransformer:c,tokenizeMaxLineLength:l}}){let u=(t,n)=>t.contents===``?[]:qn(a.codeToTokens(Dn(t.contents),kn(o??H(t.name),s,l)).tokens,{state:{lineInfo:n},useTokenTransformer:c,lazyLineAST:e,cacheHtmlStyles:a.name===`highlights`});return{deletionLines:u(t,r),additionLines:u(n,i)}}function qr(e){let t=[];for(let n of e){let e=wt.get(n);if(e==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(e)}return t}function Jr(e){for(let t of Array.isArray(e)?e:[e])if(!wt.has(t))return!1;return!0}async function Yr(e){if(typeof __DIFFS_WORKER__<`u`?__DIFFS_WORKER__:At())throw Error(`resolveLanguage("${e}") cannot be called from a worker context. Languages must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);let t=Tt.get(e);if(t!=null)return t;let n=(async()=>{let t=Et.get(e);if(t==null){let{bundledLanguages:n}=await A(async()=>{let{bundledLanguages:e}=await import(`./grammars-DmFYBwmS.js`).then(e=>e.n);return{bundledLanguages:e}},__vite__mapDeps([11,1,9,10]));Object.prototype.hasOwnProperty.call(n,e)&&(t=n[e])}if(t==null&&!Dt.has(e))throw Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);let n={name:e,data:t==null?[{name:e,scopeName:`text.${e}`,patterns:[],repository:{}}]:(await t()).default};return wt.has(e)||wt.set(e,n),n})();Tt.set(e,n);try{return await n}finally{Tt.get(e)===n&&Tt.delete(e)}}function Xr(e){return wt.get(e)??Yr(e)}async function Zr(e){let t=[],n=[];for(let r of e){if(r===`text`||r===`ansi`)continue;let e=Xr(r)??Yr(r);`then`in e?n.push(e):t.push(e)}return n.length>0&&await Promise.all(n).then(e=>{for(let n of e){if(n==null)throw Error(`resolvedLanguages: unable to resolve language`);t.push(n)}}),t}function Qr(e,t=I()){return Wt(t).getResolvedThemes(e)}function $r(e,t=I()){return Wt(t).hasResolvedThemes(e)}function ei(e,t=I()){return Wt(t).resolveThemes(e)}function ti(){let e=globalThis.navigator?.hardwareConcurrency??1;return Math.min(3,Math.max(1,e-1))}function ni(e){let t=[],n=[];for(let r of e){let e=Dt.get(r);if(e==null)continue;let i=Ot.get(r);if(i!=null){t.push(i);continue}let a=t.push({name:r,data:[]})-1;n.push(e().then(({default:e})=>{let n=Ot.get(r);n??(n={name:r,data:[],highlights:e},Ot.set(r,n)),t[a]=n}))}return n.length===0?t:Promise.all(n).then(()=>t)}var ri=0,ii=1,ai=2,oi=4,si=5,ci=6,li=[void 0,null,!0,!1];function ui(e){if(Array.isArray(e))return e;let{ops:t,offsets:n,strings:r,text:i,extras:a}=e,o=Array(n.length/2),s=0,c=0;function l(e){let n=Array(e);for(let o=0;o<e;o++){let e=t[s++];if(e!==ri){if(e===ii){let e=c+t[s++];n[o]={type:`text`,value:i.slice(c,e)},c=e}else if(e===ai){let e=r[t[s++]],i={};for(let e=t[s++];e>0;e--){let e=r[t[s++]],n=t[s++],o=n===oi?r[t[s++]]:n===si?t[s++]:n===ci?a[t[s++]]:li[n];e===`__proto__`?Object.defineProperty(i,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):i[e]=o}n[o]={type:`element`,tagName:e,properties:i,children:l(t[s++])}}else n[o]=a[t[s++]]}}return n}for(let e=0;e<o.length;e++)t[n[e*2]]!==ri&&Rn(o,e,()=>(s=n[e*2],c=n[e*2+1],l(1)[0]),{retain:!1});return o}var di=e(t(((e,t,n)=>{var r;(function(n,i){typeof e==`object`&&t!==void 0?i(e):typeof r==`function`&&r.amd?r([`exports`],i):i((n||=self).lru_map=n.lru_map||{})})(n,function(e){let t=Symbol(`newer`),n=Symbol(`older`);class r{constructor(e,t){typeof e!=`number`&&(t=e,e=0),this.size=0,this.limit=e,this.oldest=this.newest=void 0,this._keymap=new Map,t&&(this.assign(t),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[t]&&(e===this.oldest&&(this.oldest=e[t]),e[t][n]=e[n]),e[n]&&(e[n][t]=e[t]),e[t]=void 0,e[n]=this.newest,this.newest&&(this.newest[t]=e),this.newest=e)}assign(e){let r,a=this.limit||Number.MAX_VALUE;this._keymap.clear();let o=e[Symbol.iterator]();for(let e=o.next();!e.done;e=o.next()){let o=new i(e.value[0],e.value[1]);if(this._keymap.set(o.key,o),r?(r[t]=o,o[n]=r):this.oldest=o,r=o,a--==0)throw Error(`overflow`)}this.newest=r,this.size=this._keymap.size}get(e){var t=this._keymap.get(e);return t?(this._markEntryAsUsed(t),t.value):void 0}set(e,r){var a=this._keymap.get(e);return a?(a.value=r,this._markEntryAsUsed(a),this):(this._keymap.set(e,a=new i(e,r)),this.newest?(this.newest[t]=a,a[n]=this.newest):this.oldest=a,this.newest=a,++this.size,this.size>this.limit&&this.shift(),this)}shift(){var e=this.oldest;if(e)return this.oldest[t]?(this.oldest=this.oldest[t],this.oldest[n]=void 0):(this.oldest=void 0,this.newest=void 0),e[t]=e[n]=void 0,this._keymap.delete(e.key),--this.size,[e.key,e.value]}find(e){let t=this._keymap.get(e);return t?t.value:void 0}has(e){return this._keymap.has(e)}delete(e){var r=this._keymap.get(e);return r?(this._keymap.delete(r.key),r[t]&&r[n]?(r[n][t]=r[t],r[t][n]=r[n]):r[t]?(r[t][n]=void 0,this.oldest=r[t]):r[n]?(r[n][t]=void 0,this.newest=r[n]):this.oldest=this.newest=void 0,this.size--,r.value):void 0}clear(){this.oldest=this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new o(this.oldest)}values(){return new s(this.oldest)}entries(){return this}[Symbol.iterator](){return new a(this.oldest)}forEach(e,n){typeof n!=`object`&&(n=this);let r=this.oldest;for(;r;)e.call(n,r.value,r.key,this),r=r[t]}toJSON(){for(var e=Array(this.size),n=0,r=this.oldest;r;)e[n++]={key:r.key,value:r.value},r=r[t];return e}toString(){for(var e=``,n=this.oldest;n;)e+=String(n.key)+`:`+n.value,n=n[t],n&&(e+=` < `);return e}}e.LRUMap=r;function i(e,r){this.key=e,this.value=r,this[t]=void 0,this[n]=void 0}function a(e){this.entry=e}a.prototype[Symbol.iterator]=function(){return this},a.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}};function o(e){this.entry=e}o.prototype[Symbol.iterator]=function(){return this},o.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:e.key}):{done:!0,value:void 0}};function s(e){this.entry=e}s.prototype[Symbol.iterator]=function(){return this},s.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:e.value}):{done:!0,value:void 0}}})}))(),1),fi=Symbol(`IGNORE_RESPONSE`),pi=5e3,mi=class{options;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialization;configuredWorkers;workerSlots=[];readyWorkerCount=0;workerSlotsExhausted=!1;resolvedWorkerThemes=[];resolvedWorkerLanguages=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;failedHighlightKeys;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;pendingThemeRenders=new Map;terminated=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:n=et,useTokenTransformer:r=!1,lineDiffType:i=`word-alt`,preferredDiffLib:a,maxLineDiffLength:o=1e3,tokenizeMaxLineLength:s=1e3,preferredHighlighter:c}){this.options=e,this.configuredWorkers=e.poolSize??ti(),this.preferredHighlighter=I(c),this.renderOptions={theme:n,useTokenTransformer:r,lineDiffType:i,preferredDiffLib:a,maxLineDiffLength:o,tokenizeMaxLineLength:s},this.fileCache=new di.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new di.default.LRUMap(e.totalASTLRUCacheSize??100),this.failedHighlightKeys=new di.default.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.terminated&&!this.shouldUseLocalFallback()}shouldUseLocalFallback(){let{initialization:e}=this;return e?.state===`failed`||e?.state===`succeeded`&&this.readyWorkerCount===0}renderWhenLocalThemeLoads(e,t,n=[]){return z({theme:this.renderOptions.theme})==null?(this.pendingThemeRenders.set(e,t),this.loadLocalThemeForRender(this.isWorkingPool()?void 0:e),n.length>0&&this.loadSharedHighlighter([],n).catch(()=>{}),!0):(this.pendingThemeRenders.delete(e),!1)}cancelLocalThemeRender(e){this.pendingThemeRenders.delete(e)}loadLocalThemeForRender(e){let{theme:t}=this.renderOptions,{lifecycleGeneration:n}=this;this.loadSharedHighlighter(L(t),[`text`]).then(()=>{(this.terminated||this.isCurrentLifecycle(n))&&Xt(t,this.renderOptions.theme)&&this.renderPendingThemeViews()},t=>e?.onHighlightError(t))}renderPendingThemeViews(){if(z({theme:this.renderOptions.theme})!=null)for(let e of[...this.pendingThemeRenders.keys()]){let t=this.pendingThemeRenders.get(e);if(t!=null){this.pendingThemeRenders.delete(e);try{t()}catch(e){console.error(e)}}}}shouldHighlightOnMainThread(e){let{mainThreadMaxCharacters:t=-1}=this.options;return(`contents`in e?e.contents.length:e.deletionCharacterCount+e.additionCharacterCount)<=t}didHighlightFail(e){let t=`contents`in e?this.getFileHighlightKey(e):this.getDiffHighlightKey(e);return t!=null&&this.failedHighlightKeys.has(t)}getFileResultCache(e){return e.cacheKey==null?void 0:this.fileCache.get(e.cacheKey)}getDiffResultCache(e){return e.cacheKey==null?void 0:this.diffCache.get(e.cacheKey)}setFileResultCache(e,{result:t,options:n}){return e==null||!Qt(n,this.getFileRenderOptions())?!1:(this.fileCache.set(e,{result:t,options:n}),this.queueBroadcastStateChanges(),!0)}setDiffResultCache(e,{result:t,options:n}){return e==null||!ur(n,this.getDiffRenderOptions())?!1:(this.diffCache.set(e,{result:t,options:n}),this.queueBroadcastStateChanges(),!0)}inspectCaches(){let{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??et,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:n=this.renderOptions.lineDiffType??`word-alt`,preferredDiffLib:r=this.renderOptions.preferredDiffLib,maxLineDiffLength:i=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:a=this.renderOptions.tokenizeMaxLineLength??1e3}){let{lifecycleGeneration:o}=this,s=++this.renderOptionsRequestVersion,c=()=>this.isCurrentLifecycle(o)&&this.renderOptionsRequestVersion===s;try{let o={theme:e,useTokenTransformer:t,lineDiffType:n,preferredDiffLib:r,maxLineDiffLength:i,tokenizeMaxLineLength:a};if(this.terminated&&this.queueInitialization(),!c()||ur(o,this.renderOptions))return;let s=L(e),l=!Xt(e,this.renderOptions.theme),u=!l&&this.resolvedWorkerThemes.length>0?this.resolvedWorkerThemes:$r(s,this.preferredHighlighter)?Qr(s,this.preferredHighlighter):await ei(s,this.preferredHighlighter);if(!c()||z({theme:e})==null&&(await this.loadSharedHighlighter(s,[`text`]),!c()))return;if(this.renderOptions=o,this.resolvedWorkerThemes=u,this.renderOptionsVersion++,this.initialization?.state===`pending`&&this.initialization.stopThemeWait?.(),this.diffCache.clear(),this.fileCache.clear(),this.failedHighlightKeys.clear(),this.invalidateRenderTasks(),l&&this.initialization?.state===`failed`&&this.initialization.reason===`preparation`){let{languages:e}=this.initialization;this.initialization=void 0,this.queueInitialization(e)}let d=this.setRenderOptionsOnWorkers(l);for(let e of this.themeSubscribers)e.onThemeChange();l&&this.renderPendingThemeViews(),await d}catch(e){if(e instanceof nr||!c())return;throw e}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){let{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:n}=this.renderOptions;return{theme:t,useTokenTransformer:n,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e){let{renderOptionsVersion:t}=this,n=[];for(let r of this.workerSlots){let{worker:i}=r;if(r.state===`ready`&&i!=null){let a=e||i.pendingSetupRequestId!=null?this.resolvedWorkerThemes:[];n.push(this.setRenderOptionsOnWorker(i,a).catch(e=>{throw r.worker===i&&this.renderOptionsVersion===t&&this.failWorkerSlot(r,yi(e)),e}))}}await Promise.all(n)}setRenderOptionsOnWorker(e,t){let{renderOptionsVersion:n}=this;return new Promise((r,i)=>{let a=this.generateRequestId(),o={type:`set-render-options`,id:a,request:{type:`set-render-options`,id:a,renderOptions:this.renderOptions,resolvedThemes:t},resolve(){e.renderOptionsVersion=n,r()},reject:i,requestStart:Date.now()};this.postWorkerSetup(e,o)})}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){this._queuedBroadcast??=requestAnimationFrame(this._broadcastStateChanges)}_broadcastStateChanges=()=>{this._queuedBroadcast!=null&&(cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0);let e=this.getStats();for(let t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);let t=this.activeRequestByInstance.get(e);if(t!=null){let n=this.activeTaskById.get(t);Y(n)?(this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeActiveTask(n)):this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialization?.state===`succeeded`}async initialize(e){let{initialization:t}=this;if(t?.state===`succeeded`){z({theme:this.renderOptions.theme})??await this.preloadLocalHighlighter(e??[]);return}if(t?.state===`pending`)return t.promise;if(t?.state===`failed`){if(t.reason===`workers`)throw t.error;e??=t.languages}this.terminated=!1;let n=this.initialization={state:`pending`,promise:Promise.resolve(),resolve(){},reject(){}};return n.promise=new Promise((e,t)=>{n.resolve=e,n.reject=t}),this.workerSlots=Array.from({length:this.configuredWorkers},()=>({state:`starting`})),this.startPool(n,e??[]),this.queueBroadcastStateChanges(),n.promise}async startPool(e,t){let{lifecycleGeneration:n,renderOptionsVersion:r}=this,i=L(this.renderOptions.theme);this.preloadLocalHighlighter(t).catch(e=>{this.isCurrentLifecycle(n)&&console.error(e)});try{try{let t=$r(i,this.preferredHighlighter)?Qr(i,this.preferredHighlighter):await this.waitForWorkerThemes(e,i);this.initialization===e&&this.renderOptionsVersion===r&&(this.resolvedWorkerThemes=t)}catch(e){if(this.renderOptionsVersion===r)throw e}if(this.initialization!==e)return;let n=this.resolveWorkerLanguages(t),a=Array.isArray(n)?n:await n;if(this.initialization!==e)return;if(this.resolvedWorkerLanguages=a,this.workerSlots.length===0){let t=new q(`WorkerPoolManager: no workers configured`);this.workerSlotsExhausted=!0,this.rejectInitialization(e,{reason:`workers`,error:t}),this.rejectAllQueuedRenderTasks(t);return}this.startWorkerAttempts(this.workerSlots,`starting`)}catch(n){if(this.initialization!==e)return;this.workerSlots=[];let r=vi(n);this.rejectInitialization(e,{reason:`preparation`,error:r,languages:[...t]}),this.rejectAllQueuedRenderTasks(r)}}waitForWorkerThemes(e,t){let n=new Promise(t=>{e.stopThemeWait=()=>t(this.resolvedWorkerThemes)});return Promise.race([ei(t,this.preferredHighlighter),n])}preloadLocalHighlighter(e){return this.pendingThemeRenders.size>0&&this.loadLocalThemeForRender(),this.loadSharedHighlighter(L(this.renderOptions.theme),[`text`,...e])}async loadSharedHighlighter(e,t){try{await qt({themes:e,langs:t,preferredHighlighter:this.preferredHighlighter})}catch(e){if(!(e instanceof yt))throw e}}async retryFailedWorkers(){let e=this.workerSlots.filter(e=>e.state===`failed`);return e.length>0&&await Promise.all(this.startWorkerAttempts(e,`retrying`)),this.getStats()}startWorkerAttempts(e,t){let n=e.map(e=>new Promise(n=>{let r={resolve:n};e.startup=r,e.state=t,e.error=void 0,this.startWorkerAttempt(e,r)}));return this.queueBroadcastStateChanges(),n}async startWorkerAttempt(e,t){let n=this.options.workerInitializationTimeout??pi;t.timeout=setTimeout(()=>{this.failWorkerAttempt(e,t,new q(`WorkerPoolManager: worker initialization timed out after ${n}ms`))},n);try{let n=this.options.workerFactory(),r={worker:n,requestId:void 0,pendingSetupRequestId:void 0,renderOptionsVersion:this.renderOptionsVersion,langs:new Set([`text`,...this.resolvedWorkerLanguages.map(({name:e})=>e)]),customExtensionsVersion:0};for(e.worker=r,n.addEventListener(`message`,t=>{e.worker===r&&this.handleWorkerMessage(r,t.data)}),n.addEventListener(`error`,t=>{e.worker===r&&this.handleWorkerError(e,r,t)}),await new Promise((e,t)=>{let n=this.generateRequestId(),i={type:`initialize`,id:n,request:{type:`initialize`,resultFormat:`hast-ops-v1`,id:n,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:this.resolvedWorkerThemes,resolvedLanguages:this.resolvedWorkerLanguages},resolve:e,reject:t,requestStart:Date.now()};this.postWorkerSetup(r,i)});e.startup===t&&r.renderOptionsVersion!==this.renderOptionsVersion;)await this.setRenderOptionsOnWorker(r,this.resolvedWorkerThemes);if(e.startup!==t)return;e.state=`ready`,this.settleWorkerStartup(e),this.readyWorkerCount++,this.workerSlotsExhausted=!1;let{initialization:i}=this;i?.state!==`succeeded`&&(this.initialization={state:`succeeded`},i?.state===`pending`&&i.resolve()),this.queueDrain(),this.queueBroadcastStateChanges()}catch(n){this.failWorkerAttempt(e,t,n)}}postWorkerSetup(e,t){this.cancelWorkerSetup(e),this.activeTaskById.set(t.id,t),e.pendingSetupRequestId=t.id,this.executeTask(e,t)}cancelWorkerSetup(e,t){let{pendingSetupRequestId:n}=e;if(n!=null){let r=this.activeTaskById.get(n);(r?.type===`initialize`||r?.type===`set-render-options`)&&r.reject(t??new rr),this.cleanWorkerAndTask(e,r,n)}}retireWorker(e,t){let{worker:n}=e;n!=null&&(e.worker=void 0,this.cancelWorkerSetup(n,t),n.worker.terminate())}failWorkerAttempt(e,t,n){if(e.startup!==t)return;let r=yi(n);if(e.state!==`starting`){this.failWorkerSlot(e,r);return}clearTimeout(t.timeout);let i={resolve:t.resolve};e.startup=i,e.state=`retrying`,this.retireWorker(e,r),this.queueBroadcastStateChanges(),this.startWorkerAttempt(e,i)}failWorkerSlot(e,t){let n=e.state===`ready`;if(this.retireWorker(e,t),e.state=`failed`,e.error=t,this.settleWorkerStartup(e),n&&this.readyWorkerCount--,this.queueBroadcastStateChanges(),this.readyWorkerCount>0||this.workerSlotsExhausted)return;let r=this.workerSlots.map(({error:e})=>e);if(!r.every(e=>e!=null)){n&&this.rejectAllQueuedRenderTasks(e.error);return}this.workerSlotsExhausted=!0;let i=r.length===1?e.error:new q(`WorkerPoolManager: all ${r.length} worker slots failed`,{cause:AggregateError(r,`Worker slot failures`)});r.length>1&&r.every(sr)&&ar(i);let{initialization:a}=this;a?.state===`pending`&&this.rejectInitialization(a,{reason:`workers`,error:i}),this.rejectAllQueuedRenderTasks(i)}settleWorkerStartup(e){let{startup:t}=e;t!=null&&(e.startup=void 0,clearTimeout(t.timeout),t.resolve())}rejectInitialization(e,t){this.initialization={state:`failed`,...t},e.reject(t.error)}rejectAllQueuedRenderTasks(e){let t=new Set;for(let n of this.removeAllQueuedRenderTasks()){this.rejectRenderTaskCallbacks(n,e);for(let e of _i(n))t.add(e)}this.queueBroadcastStateChanges();for(let e of t)try{e.onLocalFallback()}catch(e){console.error(e)}}handleWorkerError(e,t,n){let{onWorkerError:r}=this.options;if(r!=null)try{r(n,t.worker)}catch(e){console.error(`WorkerPoolManager: onWorkerError threw:`,e)}else console.error(`Worker error:`,n,t);let{pendingSetupRequestId:i}=t;if(e.startup==null||i==null)return;let a=this.activeTaskById.get(i);if(a==null||!(`reject`in a))return;let o=bi(n);r!=null&&ar(o),this.cleanWorkerAndTask(t,a),a.reject(o)}drainQueue=()=>{if(this._queuedDrain=void 0,this.readyWorkerCount!==0&&this.queuedTasks.length!==0){for(let e=0;e<this.queuedTasks.length;){let t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}let n=gi(t.request),r=this.getAvailableWorker(n);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,n)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){let n=this.getFileResultCache(t);rn(t)||n!=null&&Qt(n.options,this.getFileRenderOptions())||this.hasMatchingFileInstanceTask(e,t)||this.submitTask(e,{type:`file`,file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeFileHighlightCache: worker pool is not working`));if(!this.shouldPrimeFileHighlightCache(e))return Promise.resolve();if(this.shouldHighlightOnMainThread(e)){let t=this.getFileRenderOptions();return this.primeHighlightCacheOnMainThread(gi({type:`file`,file:e}),t.theme,n=>this.setFileResultCache(e.cacheKey,{result:$n(e,n,t),options:t}))}let t=this.getOrCreateFileHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}shouldPrimeFileHighlightCache(e){if(e.cacheKey==null)return console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`),!1;let t=this.getFileResultCache(e);return!rn(e)&&(t==null||!Qt(t.options,this.getFileRenderOptions()))}getOrCreateFileHighlightCacheTask(e){let t=this.getFileHighlightKey(e);if(t==null)return;let n=this.getTaskByHighlightKey(t);if(n!=null){if(n.type!==`file`)throw Error(`WorkerPoolManager.getOrCreateFileHighlightCacheTask: Invalid task type`);return n.primeCache=!0,n}{let n=this.submitCacheTask({type:`file`,file:e},t);if(n.type!==`file`)throw Error(`WorkerPoolManager.getOrCreateFileHighlightCacheTask: Invalid task created`);return n}}getPlainFileAST(e,t,n,r){let i=z({theme:this.renderOptions.theme});if(i==null)this.queueInitialization();else return $n(e,i,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);dr(t)||n!=null&&ur(n.options,this.getDiffRenderOptions())||this.hasMatchingDiffInstanceTask(e,t)||this.submitTask(e,{type:`diff`,diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeDiffHighlightCache: worker pool is not working`));if(!this.shouldPrimeDiffHighlightCache(e))return Promise.resolve();if(this.shouldHighlightOnMainThread(e)){let t=this.getDiffRenderOptions();return this.primeHighlightCacheOnMainThread(gi({type:`diff`,diff:e}),t.theme,n=>this.setDiffResultCache(e.cacheKey,{result:Wr(e,n,t),options:t}))}let t=this.getOrCreateDiffHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}shouldPrimeDiffHighlightCache(e){if(e.cacheKey==null)return console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`),!1;let t=this.getDiffResultCache(e);return!dr(e)&&(t==null||!ur(t.options,this.getDiffRenderOptions()))}primeHighlightCacheOnMainThread(e,t,n){function r(){let r=z({theme:t,langs:e});return r!=null&&n(r)}if(r())return Promise.resolve();let{lifecycleGeneration:i}=this;return this.loadSharedHighlighter(L(t),[`text`,...e]).then(()=>{if(!this.isCurrentLifecycle(i))throw new nr;if(!r())throw new rr})}getOrCreateDiffHighlightCacheTask(e){let t=this.getDiffHighlightKey(e);if(t==null)return;let n=this.getTaskByHighlightKey(t);if(n!=null){if(n.type!==`diff`)throw Error(`WorkerPoolManager.getOrCreateDiffHighlightCacheTask: Invalid task type`);return n.primeCache=!0,n}{let n=this.submitCacheTask({type:`diff`,diff:e},t);if(n.type!==`diff`)throw Error(`WorkerPoolManager.getOrCreateDiffHighlightCacheTask: Invalid task created`);return n}}getPlainDiffAST(e,t,n,r,i){let a=z({theme:this.renderOptions.theme});if(a==null)this.queueInitialization();else return Wr(e,a,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,expandedHunks:r,collapsedContextThreshold:i})}terminate(){this.lifecycleGeneration++;let e=new nr;this.terminated=!0,this.readyWorkerCount=0,this.workerSlotsExhausted=!1,this.initialization?.state===`pending`&&(this.initialization.stopThemeWait?.(),this.initialization.resolve()),this.initialization=void 0;for(let t of this.workerSlots)this.settleWorkerStartup(t),this.retireWorker(t,e);this.workerSlots.length=0,this.resolvedWorkerThemes.length=0,this.resolvedWorkerLanguages.length=0;for(let t of this.removeAllQueuedRenderTasks())this.rejectRenderTaskCallbacks(t,e);for(let t of this.activeTaskById.values())`reject`in t?t.reject(e):Y(t)&&this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.failedHighlightKeys.clear(),this.activeRequestByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}initializeIfNeeded(){this.initialization??this.queueInitialization()}queueInitialization(e){this.initialization?.state!==`failed`&&this.initialize(e).catch(e=>{sr(e)||console.error(e)})}removeAllQueuedRenderTasks(){let{queuedTasks:e}=this;this.queuedTasks=[],this.queuedTaskByInstance.clear();for(let t of e)this.clearHighlightKey(t);return e}getStats(){let e=this.initialization?.state,t=0,n=0,r=0,i=0;for(let{state:e,worker:a}of this.workerSlots)switch(a!=null&&(t++,(a.requestId!=null||a.pendingSetupRequestId!=null)&&n++),e){case`retrying`:r++;break;case`failed`:i++}return{managerState:e===`succeeded`?`initialized`:e===`pending`?`initializing`:`waiting`,configuredWorkers:this.configuredWorkers,totalWorkers:t,readyWorkers:this.readyWorkerCount,retryingWorkerSlots:r,failedWorkerSlots:i,workersFailed:this.workerSlotsExhausted,busyWorkers:n,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){if(this.shouldUseLocalFallback())return;this.initializeIfNeeded();let n=this.getHighlightKeyForRequest(t),r=n==null?void 0:this.getTaskByHighlightKey(n);if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);let i=this.generateRequestId(),a=Date.now(),{renderOptionsVersion:o}=this,s=(()=>{switch(t.type){case`file`:return{type:`file`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a};case`diff`:return{type:`diff`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a}}})();this.enqueueRenderTask(s,e)}submitCacheTask(e,t){this.initializeIfNeeded();let n=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:i}=this,a=(()=>{switch(e.type){case`file`:return{type:`file`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r};case`diff`:return{type:`diff`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r}}})();return this.enqueueRenderTask(a),a}enqueueRenderTask(e,t){this.queuedTasks.push(e),t!=null&&this.queuedTaskByInstance.set(t,e),e.highlightKey!=null&&this.taskByHighlightKey.set(e.highlightKey,e),this.queueDrain()}resolveWorkerLanguages(e){return this.preferredHighlighter===`highlights`?ni(e):Jr(e)?qr(e):Zr(e)}async resolveLanguagesAndExecuteTask(e,t,n){try{let r=z(),i=n.filter(e=>r==null||!Zt(e,r));i.length>0&&this.loadSharedHighlighter(L(this.renderOptions.theme),[`text`,...i]).catch(e=>{console.error(e)});let a=n.filter(t=>!e.langs.has(t)&&(this.preferredHighlighter!==`highlights`||Dt.has(t)));if(a.length>0){let e=this.resolveWorkerLanguages(a);t.request.resolvedLanguages=Array.isArray(e)?e:await e}if(!this.activeTaskById.has(t.id)){e.requestId===t.id&&(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain());return}this.executeTask(e,t)}catch(n){this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,vi(n)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}}handleWorkerMessage(e,t){let n=this.activeTaskById.get(t.id);try{if(n==null)throw fi;if(t.type===`error`){let e=Error(t.error);if(t.stack&&(e.stack=t.stack),`reject`in n)n.reject(e);else if(Y(n))this.notifyHighlightError(n,e),this.rejectRenderTaskCallbacks(n,e);else throw Error(`handleWorkerMessage: unknown task type`);throw e}if(Y(n))for(let{name:t}of n.request.resolvedLanguages??[])e.langs.add(t);switch(t.requestType){case`initialize`:if(n.type!==`initialize`)throw Error(`handleWorkerMessage: task/response dont match`);this.syncCustomExtensionVersion(e,n.request),n.resolve();break;case`set-render-options`:if(n.type!==`set-render-options`)throw Error(`handleWorkerMessage: task/response dont match`);n.resolve();break;case`file`:{if(n.type!==`file`)throw Error(`handleWorkerMessage: task/response dont match`);let{options:r}=t;if(!this.isCurrentRenderTask(n)||!Qt(r,this.getFileRenderOptions()))throw fi;let{request:i}=n,a={...t.result,code:ui(t.result.code)};this.syncCustomExtensionVersion(e,i),n.cacheKeyAtDispatch!=null&&this.fileCache.set(n.cacheKeyAtDispatch,{result:a,options:r}),this.resolveRenderTaskCallbacks(n),this.notifyFileInstances(n,a,r);break}case`diff`:{if(n.type!==`diff`)throw Error(`handleWorkerMessage: task/response dont match`);let{options:r}=t;if(!this.isCurrentRenderTask(n)||!ur(r,this.getDiffRenderOptions()))throw fi;let{request:i}=n,a={...t.result,code:{deletionLines:ui(t.result.code.deletionLines),additionLines:ui(t.result.code.additionLines)}};this.syncCustomExtensionVersion(e,i),n.cacheKeyAtDispatch!=null&&this.diffCache.set(n.cacheKeyAtDispatch,{result:a,options:r}),this.resolveRenderTaskCallbacks(n),this.notifyDiffInstances(n,a,r);break}}}catch(e){e!==fi&&console.error(e,n,t)}this.cleanWorkerAndTask(e,n,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}_queuedDrain;queueDrain(){this._queuedDrain??(this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges())}assignWorkerToTask(e,t){t.requestId=e.id,this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e),this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,n=t?.id){e.requestId===n&&(e.requestId=void 0),e.pendingSetupRequestId===n&&(e.pendingSetupRequestId=void 0),t!=null&&(Y(t)&&(this.rejectRenderTaskCallbacks(t,new rr),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){hi(t.request)&&this.maybeAttachCustomExtensions(e,t.request);try{t.type===`file`?t.cacheKeyAtDispatch=t.request.file.cacheKey:t.type===`diff`&&(t.cacheKeyAtDispatch=t.request.diff.cacheKey),e.worker.postMessage(t.request)}catch(n){console.error(`Failed to post message to worker:`,n),Y(t)?(this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,vi(n))):`reject`in t&&t.reject(n),this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0&&this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;let n=tn();e.customExtensionsVersion>=n||(t.customExtensionsVersion=n,t.customExtensionMap=nn())}syncCustomExtensionVersion(e,t){t.customExtensionsVersion!=null&&(e.customExtensionsVersion=t.customExtensionsVersion)}getAvailableWorker(e){let t;for(let{state:n,worker:r}of this.workerSlots){if(n!==`ready`||r==null||r.requestId!=null||r.pendingSetupRequestId!=null||r.renderOptionsVersion!==this.renderOptionsVersion)continue;if(t=r,e.length===0)break;let i=!0;for(let t of e)if(!r.langs.has(t)&&(this.preferredHighlighter!==`highlights`||Dt.has(t))){i=!1;break}if(i)break}return t}getFileHighlightKey(e){if(e.cacheKey!=null)return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey!=null)return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case`file`:return this.getFileHighlightKey(e.file);case`diff`:return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(let t of _i(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){e.type,e.instances.add(t),this.activeTaskById.has(e.id)?this.activeRequestByInstance.set(t,e.id):this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){let n=this.queuedTaskByInstance.get(e);n!=null&&n!==t&&(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeQueuedTask(n))}detachInstanceFromRenderTask(e,t){e.type,e.instances.delete(t)}removeQueuedTask(e){let t=this.queuedTasks.indexOf(e);t!==-1&&this.queuedTasks.splice(t,1),this.rejectRenderTaskCallbacks(e,new rr),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new rr),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,n)=>{e.callbacks.add({resolve:t,reject:n})})}resolveRenderTaskCallbacks(e){e.highlightKey!=null&&this.failedHighlightKeys.delete(e.highlightKey);for(let t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(let n of e.callbacks)n.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){let t=this.queuedTasks[e];t.renderOptionsVersion!==this.renderOptionsVersion&&this.removeQueuedTask(t)}for(let e of Array.from(this.activeTaskById.values()))Y(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of _i(e))this.queuedTaskByInstance.get(t)===e&&this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e&&this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(let t of _i(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of _i(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.file,t,n)}notifyDiffInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.diff,t,n)}notifyHighlightError(e,t){e.highlightKey!=null&&this.failedHighlightKeys.set(e.highlightKey,!0);for(let n of _i(e))this.activeRequestByInstance.get(n)===e.id&&n.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`file`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&lr(t,n.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`diff`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&cr(n.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){let t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(let e of this.queuedTasks)yield e;for(let e of this.activeTaskById.values())Y(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function hi(e){return e.type===`initialize`||e.type===`file`||e.type===`diff`}function gi(e){let t=new Set;switch(e.type){case`file`:t.add(e.file.lang??H(e.file.name));break;case`diff`:t.add(e.diff.lang??H(e.diff.name)),t.add(e.diff.lang??H(e.diff.prevName??`-`))}return t.delete(`text`),Array.from(t)}function Y(e){return e?.type===`file`||e?.type===`diff`}function _i(e){return e.instances}function vi(e){if(e instanceof Error)return e;if(typeof e==`object`&&e){if(`error`in e&&e.error instanceof Error)return e.error;if(`message`in e&&typeof e.message==`string`)return Error(e.message)}return Error(String(e))}function yi(e){return e instanceof q?e:new q(vi(e).message,{cause:e})}function bi(e){let t=`error`in e?e.error:void 0;return new q(`WorkerPoolManager: worker failed: ${`message`in e&&typeof e.message==`string`&&e.message!==``?e.message:t instanceof Error?t.message:`the worker script failed to load (the error event carries no message)`}`,t instanceof Error?{cause:t}:void 0)}var xi;function Si({poolOptions:e,highlighterOptions:t}){return xi??=new mi(e,t),xi}function Ci(){xi!=null&&(xi.terminate(),xi=void 0)}var X=Fe(),wi=(0,P.createContext)(void 0),Ti=0;function Ei({children:e,poolOptions:t,highlighterOptions:n}){let[r]=(0,P.useState)(()=>{if(typeof window<`u`)return Si({poolOptions:t,highlighterOptions:n})});return(0,P.useInsertionEffect)(()=>{if(r!=null)return Ti++,()=>{Ti--}},[r]),(0,P.useEffect)(()=>()=>{Ti===0&&Ci()},[]),(0,X.jsx)(wi.Provider,{value:r,children:e})}function Di(e,t,n=`textmate`){let r=Lt.get(e)??{};r[n]==null?(r[n]=t,Lt.set(e,r)):console.error(`SharedHighlight.registerCustomTheme: theme name and type already registered`,e,n)}function Oi(e){return new Worker(`/assets/worker-B--T_fs_.js`,{type:`module`,name:e?.name})}var ki={dark:`pierre-dark`,light:`pierre-light`},Ai=`
|
|
9
|
-
:host {
|
|
10
|
-
--diffs-dark-bg: #131313;
|
|
11
|
-
--diffs-light-bg: #ffffff;
|
|
12
|
-
--diffs-header-font-family: var(--font-sans, system-ui, sans-serif);
|
|
13
|
-
--diffs-bg-separator-override: light-dark(#f6f6f7, #191919);
|
|
14
|
-
--diffs-addition-color-override: light-dark(#13784f, #7ee2b8);
|
|
15
|
-
--diffs-deletion-color-override: light-dark(#c23434, #ff8a8a);
|
|
16
|
-
}
|
|
17
|
-
[data-separator-content],
|
|
18
|
-
[data-expand-button] {
|
|
19
|
-
font-size: 12px;
|
|
20
|
-
}
|
|
21
|
-
/* The comment \`+\` sits just past the line numbers (over the code's first columns, as on
|
|
22
|
-
GitHub), so the whole number column stays a target for selecting lines. */
|
|
23
|
-
[data-gutter-utility-slot] {
|
|
24
|
-
right: -22px;
|
|
25
|
-
}
|
|
26
|
-
`;Di(ki.dark,(()=>A(()=>import(`./pierre-dark-DMS-zpcK.js`),[])),`textmate`),Di(ki.light,(()=>A(()=>import(`./pierre-light-BHq6aQNU.js`),[])),`textmate`);var ji={workerFactory:()=>new Oi({name:`azdiffs-highlighter`})},Mi={theme:ki,preferredHighlighter:`shiki-js`};function Ni({children:e}){return(0,X.jsx)(Ei,{poolOptions:ji,highlighterOptions:Mi,children:e})}var Pi=/^( {0,3})(`{3,}|~{3,})(.*)$/;function Fi(e){let t=e.replace(/\r\n?/g,`
|
|
27
|
-
`).split(`
|
|
28
|
-
`),n=[],r=0;for(;r<t.length;){let e=Pi.exec(t[r]??``);if(r++,e===null)continue;let i=(e[1]??``).length,a=e[2]??"```",o=(e[3]??``).trim();if(a.startsWith("`")&&o.includes("`"))continue;let s=RegExp(`^ {0,3}${a[0]==="`"?"`":`~`}{${a.length},}\\s*$`),c=[];for(;r<t.length&&!s.test(t[r]??``);)c.push(Ii(t[r]??``,i)),r++;r++,o.split(/\s+/)[0]?.toLowerCase()===`suggestion`&&n.push({lines:c})}return n}function Ii(e,t){let n=0;for(;n<t&&e[n]===` `;)n++;return e.slice(n)}function Li(e){let t=e.replace(/\r\n?/g,`
|
|
29
|
-
`);return t.length===0?[]:t.replace(/\n$/,``).split(`
|
|
30
|
-
`)}function Ri(e){return e.map(e=>`${e}\n`).join(``)}function zi(e){let t=0;for(let n of e){let e=/^ {0,3}(`{3,})/.exec(n)?.[1]?.length??0;t=Math.max(t,e)}let n="`".repeat(Math.max(3,t+1)),r=`${n}suggestion\n`,i=e.join(`
|
|
31
|
-
`);return{text:`${r}${i}\n${n}`,innerStart:r.length,innerEnd:r.length+i.length}}function Bi(e,t){return[...e.map(e=>({kind:`removed`,text:e})),...t.map(e=>({kind:`added`,text:e}))]}var Vi=[239,187,191];function Hi(e){if(e.includes(0))return{ok:!1,reason:`not-text`};let t=Vi.every((t,n)=>e[n]===t),n;try{n=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}).decode(t?e.subarray(3):e)}catch{return{ok:!1,reason:`not-text`}}let r=n.match(/\r\n/g)?.length??0,i=(n.match(/\n/g)?.length??0)-r,a=r>0&&r>=i?`\r
|
|
32
|
-
`:`
|
|
33
|
-
`,o=n.endsWith(`
|
|
34
|
-
`),s=o?n.replace(/\r?\n$/,``):n;return{ok:!0,file:{lines:n.length===0?[]:s.split(/\r?\n/),bom:t,eol:a,finalNewline:o}}}function Ui(e){let t=e.lines.length===0?``:`${e.lines.join(e.eol)}${e.finalNewline?e.eol:``}`,n=new TextEncoder().encode(t);if(!e.bom)return n;let r=new Uint8Array(n.length+3);return r.set(Vi,0),r.set(n,3),r}function Wi(e,t,n,r){let i=Hi(e);if(!i.ok)return i;let{file:a}=i;if(!Number.isInteger(t)||!Number.isInteger(n)||t<1||n<t||n>a.lines.length)return{ok:!1,reason:`out-of-range`};let o=Li(r),s=[...a.lines.slice(0,t-1),...o,...a.lines.slice(n)];return{ok:!0,bytes:Ui({...a,lines:s})}}function Gi(e,t,n){return t<1||n<t||n>e.lines.length?null:e.lines.slice(t-1,n)}function Ki(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function qi(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function Ji(e){return`Apply suggestion from ${e.reviewer}\n\nPull request #${e.pullRequestId}, thread ${e.threadId}`}var Yi={all:e=>[`pr-conflicts`,`list`,e.organization.toLowerCase(),e.repositoryId,e.pullRequestId],list:(e,t,n)=>[...Yi.all(e),t,n],blob:(e,t)=>[`pr-conflicts`,`blob`,e.organization.toLowerCase(),e.repositoryId,t]};function Xi(e,t,n=!0){return N({queryKey:Yi.list(e,t.lastMergeSourceCommit,t.lastMergeTargetCommit),queryFn:({signal:t})=>p(O(e.organization),{project:e.project,repositoryId:e.repositoryId,pullRequestId:e.pullRequestId,signal:t}),enabled:n&&t.status===`active`,retry:j})}function Zi(e){if(e.byteLength>8388608)return{kind:`too-large`,size:e.byteLength};let t=Hi(e);return t.ok?{kind:`text`,file:t.file,bytes:e}:{kind:`not-text`,size:e.byteLength}}function Qi(e,t){return{queryKey:Yi.blob(e,t),queryFn:async({signal:n})=>{let{bytes:r}=await Ue(O(e.organization),{project:e.project,repositoryId:e.repositoryId,objectId:t,signal:n});return Zi(new Uint8Array(r))},staleTime:1/0}}function $i(e,t){return N({...Qi(e,t??``),enabled:t!==null,gcTime:18e5,retry:j})}function ea(e){let t=e.filter(e=>e.kind!==`unsupported`),n=t.filter(e=>e.resolutionStatus===`resolved`),r=e.filter(e=>e.kind===`unsupported`&&e.resolutionStatus!==`resolved`);return{total:e.length,resolved:n.length+(e.length-t.length-r.length),unresolved:e.filter(e=>e.resolutionStatus!==`resolved`).length,unsupported:r.length,done:e.every(e=>e.resolutionStatus===`resolved`),anyResolved:e.some(e=>e.resolutionStatus===`resolved`)}}function ta(e){let t=new Set(e.split(`,`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0));return t.has(`delete`)&&!t.has(`undelete`)?`deleted`:t.has(`add`)||t.has(`undelete`)?`added`:t.has(`rename`)||t.has(`sourcerename`)||t.has(`targetrename`)?`renamed`:`modified`}function na(e){return e.replace(/^\/+/,``)}function ra(e){return e.startsWith(`/`)?e:`/${e}`}function ia(e){let t=na(e.path);if(t.length===0)return null;let n=ta(e.changeType),r=e.originalPath===null?null:na(e.originalPath);n===`renamed`&&(r===null||r===t)&&(n=`modified`);let i={path:t,change:n,changeTrackingId:e.changeTrackingId};if(n===`renamed`&&r!==null&&(i.originalPath=r),n===`deleted`){let t=e.originalObjectId??e.objectId;return t!==null&&(i.originalObjectId=t),i}if(e.objectId!==null)i.objectId=e.objectId;else return null;return n!==`added`&&e.originalObjectId!==null&&(i.originalObjectId=e.originalObjectId),i}function aa({baseCommit:e,targetCommit:t,entries:n}){let r=new Map;for(let e of n){let t=ia(e);t!==null&&!r.has(t.path)&&r.set(t.path,t)}return{baseCommit:e,targetCommit:t,files:[...r.values()].sort((e,t)=>la(e.path,t.path))}}function oa(e){return e.match(/\d+|\D+/g)?.map(e=>/^\d/.test(e)?Number(e):e)??[``]}function sa(e,t){let n=oa(e.toLowerCase()),r=oa(t.toLowerCase());for(let e=0;e<Math.min(n.length,r.length);e++){let t=n[e],i=r[e];if(t!==i)return typeof t==`number`&&typeof i==`number`?t<i?-1:1:String(t)<String(i)?-1:1}if(n.length!==r.length)return n.length<r.length?-1:1;let i=e.toLowerCase(),a=t.toLowerCase();return i===a?e===t?0:e<t?-1:1:i<a?-1:1}function ca(e,t){return e.isDirectory===t.isDirectory?sa(e.name,t.name):e.isDirectory?-1:1}function la(e,t){let n=e.split(`/`),r=t.split(`/`),i=Math.min(n.length,r.length);for(let e=0;e<i;e++){let t=n[e]??``,i=r[e]??``;if(t!==i)return ca({name:t,isDirectory:e<n.length-1},{name:i,isDirectory:e<r.length-1})}return n.length-r.length}var ua=e=>[e.organization.toLowerCase(),e.repositoryId,e.pullRequestId],da={iterations:e=>[`pr-files`,`iterations`,...ua(e)],changes:(e,t,n)=>[`pr-files`,`changes`,...ua(e),t,n],threads:(e,t,n)=>[`pr-files`,`threads`,...ua(e),t,n],allThreads:e=>[`pr-files`,`threads`,...ua(e)],content:(e,t)=>[`pr-files`,`content`,e.organization.toLowerCase(),e.repositoryId,t]};function fa(e,t){return{project:e.project,repositoryId:e.repositoryId,pullRequestId:e.pullRequestId,signal:t}}function pa(e){return N({queryKey:e===null?[`pr-files`,`iterations`,`none`]:da.iterations(e),queryFn:({signal:t})=>fe(O(e?.organization??null),fa(e,t)),enabled:e!==null,retry:j})}function ma(e){return e.since===null?e.iteration.commonCommit:e.since.sourceCommit}function ha(e,t){let n=t?.since?.id??0,r=t?.iteration.id??0;return N({queryKey:e===null||t===null?[`pr-files`,`changes`,`none`]:da.changes(e,r,n),queryFn:async({signal:i})=>{let a=t,o=await le(O(e.organization),{...fa(e,i),iterationId:r,compareTo:n});return aa({baseCommit:ma(a),targetCommit:a.iteration.sourceCommit,entries:o})},enabled:e!==null&&t!==null,staleTime:1/0,retry:j})}var ga=6e4;function _a(e,t){let n=t?.since?.id??0,r=t?.iteration.id??0;return N({queryKey:e===null||t===null?[`pr-files`,`threads`,`none`]:da.threads(e,r,n),queryFn:({signal:t})=>Ne(O(e.organization),{...fa(e,t),iteration:r,...n>0?{baseIteration:n}:{}}),enabled:e!==null&&t!==null,refetchOnWindowFocus:`always`,refetchInterval:ga,refetchIntervalInBackground:!1,retry:j})}var va=`Your token may be missing Code: Read & write.`;function ya(e,t){if(xe(e)||M(e,`unauthorized`))return{kind:`sign-in`};if(M(e,`forbidden`)){let e=`Your account does not have permission to do this in ${t.repository}.`;return{kind:`message`,message:t.method===`pat`?`${e} ${va}`:e}}return M(e,`rate-limited`)?{kind:`message`,message:`Azure DevOps is throttling requests. Your text is kept; try again in a moment.`}:M(e,`network`)?{kind:`message`,message:`Could not reach Azure DevOps. Your text is kept; try again.`}:M(e,`not-found`)?{kind:`message`,message:`Azure DevOps no longer has this (it may have been deleted). Reload to see the latest.`}:{kind:`message`,message:`Azure DevOps refused this: ${e instanceof Error?e.message:`Unknown error`}`}}var ba={detail:e=>[`pull-request`,e.organization.toLowerCase(),e.project,e.pullRequestId]},xa=6e4;function Sa(e){return N({queryKey:ba.detail(e),queryFn:({signal:t})=>v(O(e.organization),{project:e.project,pullRequestId:e.pullRequestId,signal:t}),refetchOnWindowFocus:`always`,refetchInterval:xa,refetchIntervalInBackground:!1,retry:j})}var Z=`/$organization/$project/_git/$repository/pullrequest/$pullRequestId`,Q=`/$organization/_git/$repository/pullrequest/$pullRequestId`,Ca={long:{overview:Z,discussion:Z,files:`${Z}/files`,commits:`${Z}/commits`,commit:`${Z}/commits/$commitId`,conflicts:`${Z}/conflicts`,"files-commits":`${Z}/files`},short:{overview:Q,discussion:Q,files:`${Q}/files`,commits:`${Q}/commits`,commit:`${Q}/commits/$commitId`,conflicts:`${Q}/conflicts`,"files-commits":`${Q}/files`}};function wa(e){return e.tab===`discussion`?{section:`discussion`}:e.tab===`files-commits`?{panel:`commits`}:e.tab===`conflicts`&&e.file!==void 0?{file:e.file}:{}}function Ta(e,t,n){let r=t?Ca.short:Ca.long,i={organization:e.organization,project:e.project,repository:e.repository,pullRequestId:e.pullRequestId,...n.tab===`commit`?{commitId:n.commitId}:{}};return{to:r[n.tab],params:i,search:wa(n)}}function Ea({location:e,shortForm:t,page:n,className:r,children:i,activeExact:a=!1,keepSearch:o=!1,onClick:s,testId:c,current:l,title:u}){let{to:d,params:f,search:p}=Ta(e,t,n);return(0,X.jsx)(_,{to:d,params:f,search:o?e=>e:p,...r===void 0?{}:{className:r},...s===void 0?{}:{onClick:s},...c===void 0?{}:{"data-testid":c},...u===void 0?{}:{title:u},...l===void 0?{activeOptions:{exact:a,includeSearch:!1},activeProps:{"aria-current":`page`}}:{activeOptions:{exact:!0},...l?{"aria-current":`page`}:{}},children:i})}function Da(e,t){let n=te(),{organization:r,project:i,repository:a,pullRequestId:o}=e;return(0,P.useCallback)(e=>{let{to:s,params:c,search:l}=Ta({organization:r,project:i,repository:a,pullRequestId:o},t,e);n({to:s,params:c,search:l})},[n,r,i,a,o,t])}function Oa({href:e,children:t,className:n=`text-accent hover:underline`}){return(0,X.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer noopener`,className:n,children:t})}var ka=e=>[e.organization.toLowerCase(),e.repositoryId,e.pullRequestId],Aa={list:e=>[`pr-commits`,`list`,...ka(e)],diff:(e,t)=>[`pr-commits`,`diff`,e.organization.toLowerCase(),e.repositoryId,t]};function ja(e){return He({queryKey:e===null?[`pr-commits`,`list`,`none`]:Aa.list(e),queryFn:({signal:t,pageParam:n})=>{let r=e;return ue(O(r.organization),{project:r.project,repositoryId:r.repositoryId,pullRequestId:r.pullRequestId,top:50,continuationToken:n,signal:t})},initialPageParam:null,getNextPageParam:e=>e.continuationToken??void 0,enabled:e!==null,retry:j})}function Ma(e,t){return N({queryKey:Aa.diff(e,t),queryFn:async({signal:n})=>{let r=O(e.organization),i={project:e.project,repositoryId:e.repositoryId,signal:n},[a,o]=await Promise.all([Oe(r,{...i,commitId:t}),h(r,{...i,commitId:t})]),s=a.parents[0]??null;return{commit:a,changeSet:aa({baseCommit:s,targetCommit:a.commitId,entries:s===null?o.map(e=>/delete/i.test(e.changeType)?e:{...e,changeType:`add`}):o})}},staleTime:1/0,retry:j})}function Na(e){return e.split(`
|
|
35
|
-
`).find(e=>e.trim().length>0)?.trim()??``}function Pa(e){return e.slice(0,7)}var Fa=[{keys:`j / k`,description:`Next / previous file`},{keys:`n / p`,description:`Next / previous comment thread`},{keys:`c`,description:`Comment on the selected lines (or the first change of the current file)`},{keys:`v`,description:`Mark the current file viewed (collapses it), or not`},{keys:`x`,description:`Collapse / expand the current file`},{keys:`s`,description:`Split / unified layout`},{keys:`w`,description:`Wrap / scroll long lines`},{keys:`t`,description:`Filter files`},{keys:`⌘F / Ctrl+F`,description:`Search in the diff`},{keys:`⌘K / Ctrl+K`,description:`Go to another pull request`},{keys:`g o / g f / g c`,description:`Overview / review changes / commits`},{keys:`g x`,description:`Conflicts (when the pull request has any)`},{keys:`?`,description:`Show these shortcuts`}],Ia=[{keys:`j / k`,description:`Next / previous file`},{keys:`n / p`,description:`Next / previous conflict`},{keys:`c`,description:`Combine both changes (when they touch different lines)`},{keys:`1 / 2 / 3`,description:`Use this pull request / the target / both`},{keys:`space`,description:`Pick the focused line`},{keys:`e`,description:`Edit the result of the conflict`},{keys:`o`,description:`Show / hide the original lines`},{keys:`⌘↵ / Ctrl+↵`,description:`Mark the file resolved`},{keys:`⌘Z / Ctrl+Z`,description:`Undo the last choice`},{keys:`g o / g f / g x`,description:`Overview / review changes / conflicts`},{keys:`?`,description:`Show these shortcuts`}];function La(e){let t=e.composedPath()[0]??e.target;if(!(t instanceof HTMLElement))return!1;if(t.isContentEditable)return!0;let n=t.tagName;if(n===`TEXTAREA`||n===`SELECT`)return!0;if(n!==`INPUT`)return!1;let r=t.type;return![`checkbox`,`radio`,`button`,`submit`,`reset`,`range`,`color`].includes(r)}function Ra(e,t=!0){let n=(0,P.useRef)(e);n.current=e,(0,P.useEffect)(()=>{if(!t)return;let e=e=>{if(e.defaultPrevented||e.repeat&&e.key===`?`||e.ctrlKey||e.metaKey||e.altKey||La(e))return;let t=n.current[e.key];t!==void 0&&(e.preventDefault(),t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function za(e){return Array.from(e?.querySelectorAll(`[data-menu-item]`)??[])}function Ba(e,t,n){let r=(0,P.useRef)(n);r.current=n,(0,P.useEffect)(()=>{if(!e)return;let n=e=>{let n=e.target;t.some(e=>e.current?.contains(n))||r.current()};return document.addEventListener(`pointerdown`,n),()=>document.removeEventListener(`pointerdown`,n)},[e,t])}var Va=`flex w-full items-center gap-2 rounded-[6px] px-2 py-1.5 text-left text-[13px] text-fg outline-none hover:bg-hover focus:bg-hover focus-visible:outline-none aria-disabled:cursor-not-allowed aria-disabled:text-muted aria-disabled:hover:bg-transparent`;function Ha({label:e,entries:t,align:n=`end`,trigger:r,onOpenChange:i}){let[a,o]=(0,P.useState)(!1),s=(0,P.useRef)(null),c=(0,P.useRef)(null),l=(0,P.useId)(),u=e=>{o(e),i?.(e)};Ba(a,[s,c],()=>u(!1));let d=()=>za(c.current);(0,P.useEffect)(()=>{if(!a)return;let e=za(c.current),t=e.find(e=>e.getAttribute(`aria-checked`)===`true`),n=e.find(e=>e.getAttribute(`aria-disabled`)!==`true`);(t??n??e[0])?.focus()},[a]);let f=e=>{u(!1),e&&s.current?.focus()};return(0,X.jsxs)(`div`,{className:`relative inline-flex`,children:[r({ref:s,"aria-haspopup":`menu`,"aria-expanded":a,"aria-controls":a?l:void 0,onClick:()=>u(!a),onKeyDown:e=>{e.key!==`ArrowDown`&&e.key!==`ArrowUp`||a||(e.preventDefault(),u(!0))}}),a&&(0,X.jsx)(`div`,{ref:c,id:l,role:`menu`,"aria-label":e,tabIndex:-1,onKeyDown:e=>{let t=d(),n=t.indexOf(document.activeElement),r=null;if(e.key===`ArrowDown`)r=(n+1)%t.length;else if(e.key===`ArrowUp`)r=(n-1+t.length)%t.length;else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),f(!0);return}else if(e.key===`Tab`){f(!1);return}r!==null&&(e.preventDefault(),t[r]?.focus())},className:`absolute top-[calc(100%+6px)] ${n===`end`?`right-0`:`left-0`} z-50 min-w-48 rounded-[10px] border border-border bg-surface p-1 shadow-[var(--azd-shadow)]`,children:t.map((e,t)=>{let n=`${t}`;if(e.kind===`separator`)return(0,X.jsx)(`hr`,{className:`my-1 border-border`},n);if(e.kind===`heading`)return(0,X.jsx)(`p`,{className:`px-2 pt-1.5 pb-1 text-xs text-muted`,"aria-hidden":`true`,children:e.label},n);let r=e.disabled===!0,i=()=>{r||(f(!0),e.onSelect())};return e.kind===`radio`?(0,X.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.checked,"aria-disabled":r,tabIndex:-1,"data-menu-item":``,onClick:i,className:Va,...e.testId===void 0?{}:{"data-testid":e.testId},children:[(0,X.jsx)(`span`,{className:`flex w-4 justify-center text-fg`,children:e.checked&&(0,X.jsx)(je,{className:`size-3.5`})}),e.label]},n):(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-disabled":r,tabIndex:-1,"data-menu-item":``,onClick:i,className:`${Va} ${e.danger===!0?`text-danger`:``}`,...e.testId===void 0?{}:{"data-testid":e.testId},children:[e.icon!==void 0&&(0,X.jsx)(`span`,{className:`flex w-4 justify-center text-muted`,children:e.icon}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint!==void 0&&(0,X.jsx)(`span`,{className:`text-xs text-muted`,children:e.hint})]},n)})})]})}function Ua({label:e,trigger:t,children:n,align:r=`end`,testId:i}){let[a,o]=(0,P.useState)(!1),s=(0,P.useRef)(null),c=(0,P.useRef)(null),l=(0,P.useId)();return Ba(a,[s,c],()=>o(!1)),(0,P.useEffect)(()=>{a&&(c.current?.querySelector(`input:not([disabled]), select:not([disabled]), button:not([disabled])[tabindex="0"], button:not([disabled]):not([tabindex])`))?.focus()},[a]),(0,X.jsxs)(`div`,{className:`relative inline-flex`,children:[t({ref:s,"aria-expanded":a,"aria-controls":a?l:void 0,"aria-haspopup":`dialog`,onClick:()=>o(e=>!e)}),a&&(0,X.jsx)(`div`,{ref:c,id:l,role:`dialog`,"aria-label":e,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),o(!1),s.current?.focus())},className:`absolute top-[calc(100%+6px)] ${r===`end`?`right-0`:`left-0`} z-50 w-72 rounded-[10px] border border-border bg-surface p-3 shadow-[var(--azd-shadow)]`,...i===void 0?{}:{"data-testid":i},children:n})]})}var Wa=2e3,Ga={conflicts:`The merge has conflicts with the target branch.`,failure:`Azure DevOps could not merge the pull request.`,rejectedByPolicy:`A branch policy rejected the merge.`};function Ka(e){if(e.status===`completed`)return{kind:`merged`};if(e.status===`abandoned`)return{kind:`failed`,reason:`The pull request was abandoned.`};let t=Ga[e.mergeStatus];return t===void 0?{kind:`pending`}:{kind:`failed`,reason:e.mergeFailureMessage===null?t:`${t} ${e.mergeFailureMessage}`}}var qa=`New changes were pushed. Review them, then complete.`;function Ja(e){return e.slice(0,7)}var Ya={"resolve-conflicts":`Resolve conflicts`,complete:`Complete`,"set-auto-complete":`Set auto-complete`,"cancel-auto-complete":`Cancel auto-complete`,abandon:`Abandon`,reactivate:`Reactivate`},Xa=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase();function Za(e){return e.filter(e=>e.blocking&&e.state!==`passed`)}function Qa({pullRequest:e,checks:t,currentUserId:n,conflictCount:r=null}){if(e.status===`completed`)return{primary:null,secondary:[]};if(e.status===`abandoned`)return{primary:`reactivate`,secondary:[]};if(e.isDraft)return{primary:null,secondary:[`abandon`],explanation:`This is a draft. Publish it in Azure DevOps before completing it.`};let i=e.autoCompleteSetBy;if(i!==null)return{primary:`cancel-auto-complete`,secondary:[`abandon`],explanation:`Auto-complete set by ${Xa(i.id,n)?`you`:i.displayName.length>0?i.displayName:`someone else`}. It completes once every required check passes.`};if(e.mergeStatus===`conflicts`){let t=e.targetBranch;return{primary:`resolve-conflicts`,secondary:[`abandon`],explanation:r===null||r===0?`This pull request conflicts with ${t}.`:`${r} ${r===1?`file conflicts`:`files conflict`} with ${t}.`}}let a=Za(t);if(a.length>0){let e=a.filter(e=>e.state===`failed`).length,t=a.length-e;return{primary:`set-auto-complete`,secondary:[`abandon`],explanation:`Required checks: ${[e>0?`${e} failing`:null,t>0?`${t} not finished`:null].filter(e=>e!==null).join(`, `)}. Auto-complete merges once they pass.`}}return{primary:`complete`,secondary:[`set-auto-complete`,`abandon`]}}var $a=`require a merge strategy`,eo={noFastForward:`Merge (no fast-forward)`,squash:`Squash commit`,rebase:`Rebase and fast-forward`,rebaseMerge:`Semi-linear merge`},to={noFastForward:`a merge commit (no fast-forward)`,squash:`a squash commit`,rebase:`rebase and fast-forward`,rebaseMerge:`a semi-linear merge`},no={noFastForward:`allowNoFastForward`,squash:`allowSquash`,rebase:`allowRebase`,rebaseMerge:`allowRebaseMerge`};function ro(e){let{type:t,isEnabled:n,isDeleted:r}=e.configuration;return!n||r?!1:t.id.toLowerCase()===`fa4e907d-c16b-4a4c-9dfa-4916e5d171ab`||t.displayName.trim().toLowerCase()===$a}function io(e){let t=ce.map(t=>e[no[t]]);if(t.some(e=>typeof e==`boolean`)){if(t.some(e=>e!==void 0&&typeof e!=`boolean`))return null;let e=ce.filter((e,n)=>t[n]===!0);return e.length>0?e:null}return e.useSquashMerge===!0?[`squash`]:null}function ao(e){let t=[...ce];if(e==null)return t;let n=null;for(let r of e){if(!ro(r))continue;let e=io(r.configuration.settings);if(e===null)return t;n=n===null?e:n.filter(t=>e.includes(t))}return n===null||n.length===0?t:n}function oo(e,t){return t!==null&&e.includes(t)?t:e.includes(`noFastForward`)?`noFastForward`:e[0]??`noFastForward`}var so=[`noFastForward`,`squash`];function co(e,t){return t?e.filter(e=>so.includes(e)):[...e]}function lo({titleId:e,busy:t,onClose:n,testId:r,children:i}){let a=(0,P.useRef)(null);return(0,P.useEffect)(()=>{let e=a.current;return e!==null&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]),(0,X.jsx)(`dialog`,{ref:a,"aria-labelledby":e,onKeyDown:de,onCancel:e=>{e.preventDefault(),t||n()},className:`m-auto w-[min(30rem,calc(100vw-2rem))] rounded-[12px] border border-border bg-surface p-5 text-[14px] text-fg shadow-[var(--azd-shadow)] backdrop:bg-black/50 backdrop:backdrop-blur-[2px]`,"data-testid":r,children:i})}var uo=`azdiffs.merge.deleteSourceBranch:`;function fo(e){try{return window.localStorage.getItem(`${uo}${e}`)===`1`}catch{return!1}}function po(e,t){try{window.localStorage.setItem(`${uo}${e}`,t?`1`:`0`)}catch{}}function mo({mode:e,pullRequest:t,commitId:n,allowed:r,policyRestricts:i,resolutionsRestrict:a=!1,hasWorkItems:o,busy:s,onConfirm:c,onClose:l}){let u=(0,P.useId)(),d=(0,P.useId)(),[p,m]=(0,P.useState)(()=>oo(r,t.completionOptions?.mergeStrategy??null)),[h,_]=(0,P.useState)(()=>fo(t.repository.id)),[v,y]=(0,P.useState)(!1),[b,x]=(0,P.useState)(()=>f(t.pullRequestId,t.title)),S=e===`complete`,C=S&&n===null,w=S&&n!==null&&t.lastMergeSourceCommit!==n,T=r.length===0,ee=t.sourceBranch,E=t.targetBranch,te=e=>{e.preventDefault(),s||w||C||T||(po(t.repository.id,h),c({mergeStrategy:p,deleteSourceBranch:h,transitionWorkItems:o&&v,mergeCommitMessage:g(p)?b:null}))},D=`Merge ${ee} into ${E} with ${to[p]}.`;return(0,X.jsx)(lo,{titleId:u,busy:s,onClose:l,testId:S?`complete-dialog`:`auto-complete-dialog`,children:(0,X.jsxs)(`form`,{onSubmit:te,className:`space-y-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{id:u,className:`text-[16px] font-semibold text-fg-strong`,children:S?`Complete pull request`:`Set auto-complete`}),(0,X.jsx)(`p`,{className:`mt-1 text-[13px] text-muted`,children:S?`Merging cannot be undone.`:`Azure DevOps completes the pull request once every required check passes.`})]}),(0,X.jsxs)(`fieldset`,{className:`space-y-1.5`,children:[(0,X.jsx)(`legend`,{className:`mb-1.5 text-xs font-medium text-muted`,children:`Merge type`}),r.map(e=>(0,X.jsxs)(`label`,{className:`flex h-9 items-center gap-2.5 rounded-[8px] border border-border px-3 text-[13px] text-fg hover:bg-hover has-[:checked]:border-border-strong has-[:checked]:bg-[var(--azd-selected)]`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`merge-strategy`,value:e,checked:p===e,onChange:()=>m(e),className:`accent-[var(--azd-accent)]`}),eo[e]]},e)),a&&!T&&(0,X.jsx)(`p`,{className:`pt-0.5 text-xs text-muted`,"data-testid":`strategy-resolutions-note`,children:`Rebase can't keep conflict resolutions, so it isn't offered.`}),T&&(0,X.jsxs)(`p`,{role:`alert`,className:`text-[13px] text-danger`,"data-testid":`strategy-none`,children:[`The branch policy for `,E,` allows only rebase, which can't keep conflict resolutions. Complete this pull request in Azure DevOps or resolve the conflicts in a branch instead.`]}),i&&!T&&(0,X.jsxs)(`p`,{className:`pt-0.5 text-xs text-muted`,"data-testid":`strategy-policy-note`,children:[`The branch policy for `,E,` allows`,` `,r.length===1?`only this merge type`:`only these merge types`,`.`]})]}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`label`,{className:`flex items-start gap-2.5 text-[13px] text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>_(e.target.checked),className:`mt-0.5 accent-[var(--azd-accent)]`}),(0,X.jsxs)(`span`,{children:[`Delete `,(0,X.jsx)(`span`,{className:`font-mono`,children:ee}),` after merging`]})]}),o&&(0,X.jsxs)(`label`,{className:`flex items-start gap-2.5 text-[13px] text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:v,onChange:e=>y(e.target.checked),className:`mt-0.5 accent-[var(--azd-accent)]`}),`Complete linked work items after merging`]})]}),g(p)&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`label`,{htmlFor:d,className:`block text-xs font-medium text-muted`,children:`Commit message`}),(0,X.jsx)(`textarea`,{id:d,value:b,onChange:e=>x(e.target.value),rows:3,className:`w-full resize-y rounded-[8px] border border-border bg-canvas px-2.5 py-2 font-mono text-xs text-fg focus:border-[var(--azd-focus)] focus:outline-none`})]}),(0,X.jsx)(`p`,{className:`rounded-[8px] bg-raised px-3 py-2 text-[13px] text-fg`,"data-testid":`completion-summary`,children:D}),S&&n!==null&&(0,X.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Source commit`,` `,(0,X.jsx)(`span`,{className:`font-mono text-fg`,"data-testid":`completion-commit`,children:Ja(n)})]}),C&&(0,X.jsx)(`p`,{role:`alert`,className:`text-[13px] text-danger`,children:`Azure DevOps has not reported the source commit yet. Close this, wait a moment, and try again.`}),w&&(0,X.jsx)(`p`,{role:`alert`,className:`text-[13px] text-danger`,"data-testid":`completion-stale`,children:`New changes were pushed. Review them, then complete.`}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:l,disabled:s,className:Ae,children:`Cancel`}),(0,X.jsx)(`button`,{type:`submit`,disabled:s||w||C||T,className:pe,"data-testid":`completion-confirm`,children:s?S?`Completing…`:`Setting…`:S?`Complete merge`:`Set auto-complete`})]})]})})}var ho=(0,P.createContext)(null);function go(){return(0,P.useContext)(ho)}function _o({location:e,scope:t,pullRequest:n,checks:r,checksPending:i,evaluations:a,hasWorkItems:s,conflicts:c=null,onResolveConflicts:l=()=>{},children:u}){let f=x(),p=we(e.organization),h=ba.detail(e),[g,_]=(0,P.useState)(null),[y,b]=(0,P.useState)({kind:`idle`}),[S,C]=(0,P.useState)(null),w=(0,P.useRef)(null),T=(0,P.useRef)(!1),E={project:t.project,repositoryId:t.repositoryId,pullRequestId:t.pullRequestId},te=(0,P.useCallback)(e=>{e!==null&&f.setQueryData(h,e),f.invalidateQueries({queryKey:h})},[f,h]),D=(0,P.useCallback)(()=>{_(null);let e=w.current;window.setTimeout(()=>{e?.isConnected&&e.focus()},0)},[]),ne=Ve({retry:!1,mutationFn:t=>{let n=O(e.organization);switch(t.action){case`complete`:return m(n,{...E,lastMergeSourceCommit:t.commitId,options:t.choices});case`set-auto-complete`:return o(n,{...E,userId:t.userId,options:t.choices});case`cancel-auto-complete`:return d(n,E);case`abandon`:return ee(n,E);case`reactivate`:return Ie(n,E)}},onSettled:()=>{T.current=!1}}),re=t=>{let r=ya(t,{repository:n.repository.name,method:Ee(e.organization)});return r.kind===`sign-in`?`Azure DevOps did not accept the sign-in; nothing was changed. Reload to sign in again.`:r.message},ie=(e,t)=>{T.current||(T.current=!0,C(null),ne.mutate(e,t))},ae=(e,t,n)=>{if(e===`complete`){if(t===null)return;ie({action:`complete`,commitId:t,choices:n},{onSuccess:e=>{D(),e!==null&&f.setQueryData(h,e),e?.status===`completed`?b({kind:`merged`}):b({kind:`completing`,since:Date.now()})},onError:e=>{D(),oe(e,t)}});return}let r=p.data?.id;r!==void 0&&ie({action:`set-auto-complete`,userId:r,choices:n},{onSuccess:e=>{D(),te(e)},onError:e=>{D(),C({tone:`error`,text:re(e)})}})},oe=async(t,n)=>{let r=null;try{r=await v(O(e.organization),{project:e.project,pullRequestId:e.pullRequestId}),f.setQueryData(h,r)}catch{}r!==null&&r.lastMergeSourceCommit!==n?C({tone:`error`,text:qa}):C({tone:`error`,text:re(t)})},se=e=>{ie({action:e},{onSuccess:t=>{e===`abandon`&&D(),b({kind:`idle`}),te(t)},onError:t=>{e===`abandon`&&D(),C({tone:`error`,text:re(t)})}})};xo(y,e,h,b,C);let ce=i&&n.status===`active`?null:Qa({pullRequest:n,checks:r,currentUserId:p.data?.id??null,conflictCount:c?.unresolved??null}),le=ne.isPending,ue=ao(a),de=c?.anyResolved===!0,fe=co(ue,de),pe=ue.length<4,me={actions:ce,busy:le,phase:y,notice:S,run:(e,t)=>{if(!(le||T.current))switch(w.current=t,C(null),e){case`resolve-conflicts`:l();return;case`complete`:_({kind:`complete`,commitId:n.lastMergeSourceCommit});return;case`set-auto-complete`:_({kind:`auto-complete`,commitId:n.lastMergeSourceCommit});return;case`abandon`:_({kind:`abandon`});return;case`cancel-auto-complete`:case`reactivate`:se(e);return}},targetBranch:n.targetBranch};return(0,X.jsxs)(ho.Provider,{value:me,children:[u,g!==null&&g.kind!==`abandon`&&(0,X.jsx)(mo,{mode:g.kind,pullRequest:n,commitId:g.commitId,allowed:fe,policyRestricts:pe,resolutionsRestrict:de&&fe.length<ue.length,hasWorkItems:s,busy:le,onConfirm:e=>ae(g.kind,g.commitId,e),onClose:D}),g?.kind===`abandon`&&(0,X.jsx)(bo,{pullRequestId:n.pullRequestId,busy:le,onConfirm:()=>se(`abandon`),onClose:D})]})}function vo(){let e=go();if(e===null||e.actions===null)return null;let{actions:t,phase:n,notice:r}=e,i=n.kind===`idle`;return(0,X.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`merge-controls`,children:[n.kind===`completing`&&(0,X.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-[13px] text-fg`,"data-testid":`merge-progress`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`azd-pulse size-2 rounded-full bg-accent`}),`Completing…`]}),n.kind===`merged`&&(0,X.jsxs)(`p`,{role:`status`,className:`text-[13px] font-medium text-added`,"data-testid":`merge-progress`,children:[`Merged into `,e.targetBranch]}),n.kind===`timed-out`&&(0,X.jsx)(`p`,{role:`status`,className:`text-[13px] text-muted`,"data-testid":`merge-progress`,children:`Still completing — refresh to check.`}),i&&t.explanation!==void 0&&(0,X.jsx)(`p`,{className:`text-[13px] leading-snug text-muted`,"data-testid":`merge-explanation`,children:t.explanation}),r!==null&&(0,X.jsx)(`p`,{role:`alert`,className:`text-[13px] leading-snug ${r.tone===`error`?`text-danger`:`text-muted`}`,"data-testid":`merge-notice`,children:r.text})]})}function yo({showNotice:e=!1}){let t=go();if(t===null||t.actions===null)return null;let{actions:n,busy:r,phase:i,notice:a,run:o}=t;if(i.kind===`completing`)return(0,X.jsxs)(`span`,{className:`${Ae} pointer-events-none gap-2`,"data-testid":`merge-button-progress`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`azd-pulse size-2 rounded-full bg-accent`}),`Completing…`]});if(i.kind===`merged`||i.kind===`timed-out`)return null;let{primary:s,secondary:c}=n;if(s===null&&c.length===0)return null;let l=c.map(e=>({label:Ya[e],onSelect:()=>{let t=document.querySelector(`[data-testid="merge-menu-button"]`);t!==null&&o(e,t)},disabled:r,danger:e===`abandon`,testId:`merge-action-${e}`}));return(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e&&a!==null&&(0,X.jsx)(`p`,{role:`alert`,className:`max-w-xs truncate text-xs text-danger`,title:a.text,"data-testid":`merge-notice`,children:a.text}),(0,X.jsxs)(`div`,{className:`flex items-center`,"data-testid":`merge-button`,children:[s!==null&&(0,X.jsxs)(`button`,{type:`button`,disabled:r,onClick:e=>o(s,e.currentTarget),className:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-8 px-3 bg-primary text-primary-fg hover:opacity-90 ${c.length>0?`rounded-r-none`:``}`,"data-testid":`merge-action-${s}`,"data-kind":`primary`,children:[s===`resolve-conflicts`?(0,X.jsx)(y,{className:`size-3.5`}):(0,X.jsx)(ae,{className:`size-3.5`}),Ya[s]]}),c.length>0&&(0,X.jsx)(Ha,{label:`Merge actions`,entries:l,trigger:e=>(0,X.jsxs)(`button`,{type:`button`,...e,ref:e.ref,"aria-label":s===null?void 0:`More merge actions`,title:s===null?n.explanation:`More merge actions`,className:s===null?`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-8 px-3 border border-border bg-raised text-fg hover:border-border-strong hover:bg-hover gap-1.5`:`inline-flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] text-[13px] font-medium whitespace-nowrap transition-colors disabled:cursor-not-allowed disabled:opacity-50 h-8 px-3 bg-primary text-primary-fg hover:opacity-90 rounded-l-none border-l border-[color-mix(in_srgb,var(--azd-primary-fg)_18%,transparent)] px-2`,"data-testid":`merge-menu-button`,children:[s===null&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ae,{className:`size-3.5`}),`Merge`]}),(0,X.jsx)(re,{className:`size-3.5`})]})})]})]})}function bo({pullRequestId:e,busy:t,onConfirm:n,onClose:r}){let i=(0,P.useId)();return(0,X.jsx)(lo,{titleId:i,busy:t,onClose:r,testId:`abandon-dialog`,children:(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),t||n()},className:`space-y-3`,children:[(0,X.jsxs)(`h2`,{id:i,className:`text-[16px] font-semibold text-fg-strong`,children:[`Abandon pull request #`,e,`?`]}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted`,children:`It closes without merging. You can reactivate it later.`}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:r,disabled:t,className:Ae,children:`Cancel`}),(0,X.jsx)(`button`,{type:`submit`,disabled:t,className:ve,"data-testid":`abandon-confirm`,children:t?`Abandoning…`:`Abandon`})]})]})})}function xo(e,t,n,r,i){let a=x(),o=e.kind===`completing`?e.since:null,{organization:s,project:c,pullRequestId:l}=t;(0,P.useEffect)(()=>{if(o===null)return;let e=new AbortController,t,u=async()=>{if(Date.now()-o>=12e4)r({kind:`timed-out`});else{try{let t=await v(O(s),{project:c,pullRequestId:l,signal:e.signal});if(e.signal.aborted)return;a.setQueryData(n,t);let o=Ka(t);if(o.kind===`merged`){r({kind:`merged`});return}if(o.kind===`failed`){r({kind:`idle`}),i({tone:`error`,text:o.reason});return}}catch{if(e.signal.aborted)return}t=window.setTimeout(()=>void u(),Wa)}};return t=window.setTimeout(()=>void u(),Wa),()=>{e.abort(),window.clearTimeout(t)}},[o,s,c,l,a])}var So={rejected:`failed`,broken:`failed`,running:`running`,queued:`pending`,approved:`passed`},Co={failed:`failed`,error:`failed`,pending:`pending`,notSet:`pending`,succeeded:`passed`};function wo(e){let t=e.configuration.settings.displayName;if(typeof t==`string`&&t.trim().length>0)return t.trim();let n=e.configuration.type.displayName.trim();return n.length>0?n:`Policy`}function To(e){let{genre:t,name:n}=e.context,r=n.trim().length>0?n.trim():`Status`;return t.trim().length>0?`${t.trim()}/${r}`:r}function Eo(e){if(e!=null)try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`?t.href:void 0}catch{return}}function Do(e,t){let n=e.context?.buildId;if(!(typeof n!=`number`||!Number.isSafeInteger(n)||n<=0))return`https://dev.azure.com/${encodeURIComponent(t.organization)}/${encodeURIComponent(t.project)}/_build/results?buildId=${n}`}function Oo(e,t){let n=[];for(let r of e){let e=r.configuration;if(!e.isEnabled||e.isDeleted)continue;let i=So[r.status];if(i===void 0)continue;let a={id:`policy:${r.evaluationId||e.id}`,name:wo(r),state:i,blocking:e.isBlocking,source:`policy`},o=Do(r,t);o!==void 0&&(a.url=o),r.context?.isExpired===!0&&(a.detail=`Expired`),n.push(a)}return n}function ko(e){let t=new Map;for(let n of e){let e=`${n.context.genre.toLowerCase()}/${n.context.name.toLowerCase()}`,r=t.get(e);(r===void 0||Ao(n,r))&&t.set(e,n)}let n=[];for(let e of t.values()){let t=Co[e.state];if(t===void 0)continue;let r={id:`status:${e.context.genre}/${e.context.name}`,name:To(e),state:t,blocking:!1,source:`status`},i=Eo(e.targetUrl);i!==void 0&&(r.url=i),e.description.trim().length>0&&(r.detail=e.description.trim()),n.push(r)}return n}function Ao(e,t){let n=e=>Date.parse(e.updatedDate??e.creationDate??``)||0;return n(e)===n(t)?e.id>t.id:n(e)>n(t)}var jo={failed:0,running:1,pending:2,passed:3};function Mo(e,t){return jo[e.state]-jo[t.state]||Number(t.blocking)-Number(e.blocking)||e.name.localeCompare(t.name)}function No(e){return[...e].sort(Mo)}function Po(e){let t=e.filter(e=>e.blocking),n=t.filter(e=>e.state!==`passed`).length,r=e.filter(e=>e.state===`failed`).length,i;return i=e.length===0?`No checks`:t.length===0?`No required checks`:n===0?`All required checks passed`:`${n} of ${t.length} required ${t.length===1?`check`:`checks`} not passed`,{required:t.length,requiredNotPassed:n,failed:r,text:i}}function Fo(e){return e.some(e=>e.state===`running`||e.state===`pending`)}var Io={failed:`Failed`,running:`Running`,pending:`Waiting`,passed:`Passed`},Lo=e=>[e.organization.toLowerCase(),e.repositoryId,e.pullRequestId],$={threads:e=>[...da.allThreads(e),`overview`],evaluations:e=>[`pr-overview`,`evaluations`,...Lo(e)],statuses:e=>[`pr-overview`,`statuses`,...Lo(e)],workItems:e=>[`pr-overview`,`work-items`,...Lo(e)]},Ro=6e4,zo=15e3,Bo=(e,t)=>({project:e.project,repositoryId:e.repositoryId,pullRequestId:e.pullRequestId,signal:t});function Vo(e){return N({queryKey:$.threads(e),queryFn:({signal:t})=>Ne(O(e.organization),Bo(e,t)),refetchOnWindowFocus:`always`,refetchInterval:ga,refetchIntervalInBackground:!1,retry:j})}function Ho(e,t,n){return No([...Oo(e??[],n),...ko(t??[])])}function Uo(e){let t=x(),n={refetchOnWindowFocus:`always`,refetchInterval:Fo(Ho(t.getQueryData($.evaluations(e)),t.getQueryData($.statuses(e)),e))?zo:Ro,refetchIntervalInBackground:!1,retry:j},r=N({queryKey:$.evaluations(e),queryFn:({signal:t})=>oe(O(e.organization),{project:e.project,projectId:e.projectId,pullRequestId:e.pullRequestId,signal:t}),...n}),i=N({queryKey:$.statuses(e),queryFn:({signal:t})=>w(O(e.organization),Bo(e,t)),...n}),{organization:a,project:o}=e;return{checks:(0,P.useMemo)(()=>Ho(r.data,i.data,{organization:a,project:o}),[r.data,i.data,a,o]),pending:r.isPending&&i.isPending,evaluationsError:r.error,statusesError:i.error,evaluations:r.data,retry:()=>{r.isError&&r.refetch(),i.isError&&i.refetch()}}}function Wo(e){return M(e,`forbidden`)||M(e,`unauthorized`)||M(e,`network`)}function Go(e){return N({queryKey:$.workItems(e),queryFn:async({signal:t})=>{let n=O(e.organization),r=(await me(n,Bo(e,t))).map(e=>e.id);if(r.length===0)return{ids:r,details:new Map,detailsProblem:null};try{let n=await ye(O(e.organization,{keepSessionOnUnauthorized:!0}),{ids:r,signal:t});return{ids:r,details:new Map(n.map(e=>[e.id,e])),detailsProblem:null}}catch(e){if(t.aborted)throw e;return{ids:r,details:null,detailsProblem:Wo(e)?`access`:`failed`}}},staleTime:3e5,retry:j})}var Ko=[{vote:k.approved,action:`Approve`,state:`Approved`,tone:`text-[var(--azd-added)]`},{vote:k.approvedWithSuggestions,action:`Approve with suggestions`,state:`Approved with suggestions`,tone:`text-[var(--azd-added)]`},{vote:k.waitingForAuthor,action:`Wait for author`,state:`Waiting for author`,tone:`text-[var(--azd-modified)]`},{vote:k.rejected,action:`Reject`,state:`Rejected`,tone:`text-danger`},{vote:k.none,action:`Reset feedback`,state:`No vote`,tone:`text-muted`}];function qo(e){return Ko.find(t=>t.vote===e)}var Jo=(e,t)=>e.toLowerCase()===t.toLowerCase();function Yo(e,t,n){let r=e.reviewers.find(e=>Jo(e.id,t.id)),i=r?e.reviewers.map(e=>e===r?{...e,vote:n}:e):[...e.reviewers,{isRequired:!1,hasDeclined:!1,...t,vote:n}];return{...e,reviewers:i}}var Xo=Ko.filter(e=>e.vote!==k.none),Zo=`flex w-full items-center gap-2 rounded-[6px] px-2 py-1.5 text-left text-[13px] text-fg outline-none hover:bg-hover focus:bg-hover aria-disabled:cursor-not-allowed aria-disabled:text-muted`,Qo=`flex h-8 items-center border border-border bg-raised px-2.5 text-[13px] font-medium text-fg hover:border-border-strong hover:bg-hover focus-visible:z-10 disabled:cursor-not-allowed disabled:opacity-50`;function $o({location:e,pullRequest:t}){let n=we(e.organization),r=x(),[a,o]=(0,P.useState)(!1),[s,c]=(0,P.useState)(null),l=(0,P.useRef)(null),u=(0,P.useRef)(null),d=(0,P.useRef)([]),f=(0,P.useId)(),p=ba.detail(e),m=Ve({retry:!1,mutationFn:({vote:r})=>i(O(e.organization),{project:e.project,repositoryId:t.repository.id,pullRequestId:t.pullRequestId,reviewerId:n.data.id,vote:r}),onMutate:async({vote:e,previous:t})=>{c(null),await r.cancelQueries({queryKey:p});let i=n.data;return i!==void 0&&r.setQueryData(p,t=>t===void 0?t:Yo(t,i,e)),{previous:t}},onSuccess:e=>{r.setQueryData(p,t=>t===void 0?t:Yo(t,e,e.vote))},onError:(i,a,o)=>{let s=n.data;s!==void 0&&o!==void 0&&r.setQueryData(p,e=>e===void 0?e:Yo(e,s,o.previous));let l=ya(i,{repository:t.repository.name,method:Ee(e.organization)});c(l.kind===`sign-in`?`Azure DevOps did not accept the sign-in; your vote was not saved. Reload to sign in again.`:l.message)}}),h=n.data,g=h===void 0?0:t.reviewers.find(e=>Jo(e.id,h.id))?.vote??0,_=qo(g),v=h===void 0,y=m.isPending,b=e=>{o(!1),l.current?.focus(),v||y||e===g||m.mutate({vote:e,previous:g})};(0,P.useEffect)(()=>{if(!a)return;let e=Math.max(0,Xo.findIndex(e=>e.vote===g));d.current[e]?.focus();let t=e=>{let t=e.target;!u.current?.contains(t)&&!l.current?.contains(t)&&o(!1)};return document.addEventListener(`pointerdown`,t),()=>document.removeEventListener(`pointerdown`,t)},[a,g]);let S=e=>{let t=d.current.filter(e=>e!==null),n=t.indexOf(document.activeElement),r=null;if(e.key===`ArrowDown`)r=(n+1)%t.length;else if(e.key===`ArrowUp`)r=(n-1+t.length)%t.length;else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else if(e.key===`Escape`){e.preventDefault(),o(!1),l.current?.focus();return}else if(e.key===`Tab`){o(!1);return}r!==null&&(e.preventDefault(),t[r]?.focus())},C=g===k.approved,w=g!==k.none&&!C;return(0,X.jsxs)(`div`,{className:`relative flex items-center gap-2`,"data-testid":`vote-control`,children:[s!==null&&(0,X.jsx)(`p`,{role:`alert`,className:`max-w-[16rem] truncate text-xs text-danger`,title:s,children:s}),(0,X.jsxs)(`div`,{className:`flex items-center`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`${Qo} gap-1.5 rounded-l-[7px] ${C?`text-added`:``}`,"aria-pressed":C,"aria-disabled":y,disabled:v,onClick:()=>b(k.approved),"data-testid":`vote-approve`,children:[(0,X.jsx)(je,{className:`size-3.5`}),C?`Approved`:`Approve`]}),(0,X.jsxs)(`button`,{ref:l,type:`button`,className:`${Qo} -ml-px gap-1 rounded-r-[7px] px-1.5`,"aria-haspopup":`menu`,"aria-expanded":a,"aria-controls":a?f:void 0,"aria-label":w&&_!==void 0?`Your vote: ${_.state}. Other votes`:`Other votes`,disabled:v,onClick:()=>o(e=>!e),onKeyDown:e=>{e.key===`ArrowDown`&&!a&&(e.preventDefault(),o(!0))},"data-testid":`vote-menu-button`,children:[w&&_!==void 0&&(0,X.jsx)(`span`,{className:_.tone,"data-testid":`vote-state`,children:_.state}),(0,X.jsx)(re,{className:`size-3.5 text-muted`})]})]}),a&&(0,X.jsxs)(`div`,{ref:u,id:f,role:`menu`,"aria-label":`Vote`,tabIndex:-1,onKeyDown:S,className:`absolute top-[calc(100%+6px)] right-0 w-60 z-50 min-w-48 rounded-[10px] border border-border bg-surface p-1 shadow-[var(--azd-shadow)]`,children:[Xo.map((e,t)=>(0,X.jsxs)(`button`,{ref:e=>{d.current[t]=e},type:`button`,role:`menuitemradio`,"aria-checked":e.vote===g,tabIndex:-1,onClick:()=>b(e.vote),className:Zo,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`flex w-4 justify-center text-fg`,children:e.vote===g&&(0,X.jsx)(je,{className:`size-3.5`})}),e.action]},e.vote)),(0,X.jsx)(`hr`,{className:`my-1 border-border`}),(0,X.jsxs)(`button`,{ref:e=>{d.current[Xo.length]=e},type:`button`,role:`menuitem`,"aria-disabled":g===k.none,tabIndex:-1,onClick:()=>b(k.none),className:Zo,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`w-4`}),`Reset feedback`]})]})]})}function es({status:e,className:t=`size-4`}){switch(e){case`draft`:return(0,X.jsx)(T,{className:t});case`completed`:return(0,X.jsx)(ae,{className:t});case`abandoned`:return(0,X.jsx)(S,{className:t});default:return(0,X.jsx)(se,{className:t})}}var ts=(0,P.createContext)(null);function ns(){let e=(0,P.useContext)(ts);if(e===null)throw Error(`usePullRequestPage outside a pull request page`);return e}function rs({location:e,shortForm:t,children:n}){return(0,X.jsx)(Ni,{children:(0,X.jsx)(os,{location:e,shortForm:t,children:n})})}function is({location:e,children:t}){return(0,X.jsx)(n,{sidebarLabel:`Inbox`,sidebar:(0,X.jsx)(as,{location:e,quietProblems:!0}),topBar:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(ke,{children:[(0,X.jsx)(`span`,{className:`truncate text-muted`,children:e.repository}),(0,X.jsx)(_e,{}),(0,X.jsxs)(`span`,{className:`text-fg tabular-nums`,children:[`#`,e.pullRequestId]})]}),(0,X.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:(0,X.jsx)(Te,{})})]}),children:(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:t})})}function as({location:e,quietProblems:t=!1}){let n=N(he()),r=ge(n.data,e.organization),i=n.isPending?[]:[{name:r?.name??e.organization,project:r?.project??null}];return(0,X.jsx)(Re,{organizations:i,linkOrganizations:!0,current:{organization:e.organization,pullRequestId:e.pullRequestId},quietProblems:t})}function os({location:e,shortForm:t,children:n}){let r=we(e.organization);return r.isPending?(0,X.jsx)(is,{location:e,children:(0,X.jsx)(E,{})}):r.isError?(0,X.jsx)(is,{location:e,children:(0,X.jsx)(Le,{error:r.error,organization:e.organization,onRetry:()=>void r.refetch()})}):(0,X.jsx)(ss,{location:e,shortForm:t,children:n})}function ss({location:e,shortForm:t,children:n}){let r=Sa(e);return r.isPending?(0,X.jsx)(is,{location:e,children:(0,X.jsx)(E,{})}):r.data===void 0?M(r.error,`not-found`)?(0,X.jsx)(is,{location:e,children:(0,X.jsxs)(De,{title:`Pull request not found`,children:[(0,X.jsxs)(`p`,{children:[e.organization,` / `,e.project,` has no pull request !`,e.pullRequestId,`, or this account cannot see it. Azure DevOps does not say which.`]}),(0,X.jsx)(Oa,{href:Pe(D(e)),children:`Open in Azure DevOps`})]})}):(0,X.jsx)(is,{location:e,children:(0,X.jsx)(Le,{error:r.error,organization:e.organization,onRetry:()=>void r.refetch()})}):(0,X.jsx)(cs,{location:e,shortForm:t,pullRequest:r.data,children:n})}function cs({location:e,shortForm:t,pullRequest:n,children:r}){let i=(0,P.useMemo)(()=>({organization:e.organization,project:e.project,projectId:n.repository.projectId,repositoryId:n.repository.id,pullRequestId:e.pullRequestId}),[e.organization,e.project,e.pullRequestId,n.repository.id,n.repository.projectId]),a=hs(i,n),o=Da(e,t),s=Uo(i),c=Go(i);vs(e,t);let l=(0,P.useMemo)(()=>({location:e,shortForm:t,pullRequest:n,scope:i,counts:a}),[e,t,n,i,a]);return(0,X.jsx)(ts.Provider,{value:l,children:(0,X.jsx)(_o,{location:e,scope:i,pullRequest:n,checks:s.checks,checksPending:s.pending,evaluations:s.evaluations,hasWorkItems:(c.data?.ids.length??0)>0,conflicts:a.conflicts,onResolveConflicts:()=>o({tab:`conflicts`}),children:r},`${n.repository.id}:${n.pullRequestId}`)})}function ls(e){let{projectName:t,name:n}=e.repository;return t===n?n:`${t}/${n}`}function us({mode:e,lead:t,title:n,tools:r,merge:i=!0}){let{location:a,shortForm:o,pullRequest:s}=ns();return(0,X.jsxs)(X.Fragment,{children:[t,(0,X.jsxs)(ke,{children:[(0,X.jsx)(`span`,{className:`truncate text-muted ${e===`review`?`max-w-[11rem] shrink-0 max-[1100px]:hidden`:``}`,title:`${a.organization} / ${ls(s)}`,children:ls(s)}),(0,X.jsx)(`span`,{className:e===`review`?`max-[1100px]:hidden`:``,children:(0,X.jsx)(_e,{})}),e===`overview`?(0,X.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-fg`,children:[(0,X.jsx)(ds,{pullRequest:s}),(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[`#`,s.pullRequestId]})]}):(0,X.jsxs)(`span`,{className:`flex min-w-[8rem] items-center gap-1.5`,children:[(0,X.jsx)(ds,{pullRequest:s}),(0,X.jsx)(Ea,{location:a,shortForm:o,page:{tab:`overview`},className:`min-w-0 truncate font-medium text-fg hover:underline`,children:(0,X.jsxs)(`h1`,{className:`inline`,title:s.title,children:[s.title,` `,(0,X.jsxs)(`span`,{className:`font-normal text-muted tabular-nums`,children:[`#`,s.pullRequestId]})]})}),n]})]}),(0,X.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[r,(0,X.jsx)(Te,{}),(0,X.jsx)(be,{href:Pe(D(a)),label:`Open in Azure DevOps`,framed:!0,children:(0,X.jsx)(u,{})}),s.status===`active`&&(0,X.jsx)($o,{location:a,pullRequest:s}),i&&(0,X.jsx)(yo,{showNotice:e===`review`})]})]})}function ds({pullRequest:e}){let t=fs(e);return(0,X.jsxs)(`span`,{title:ps[t],className:ms[t],children:[(0,X.jsx)(es,{status:t}),(0,X.jsx)(`span`,{className:`sr-only`,children:ps[t]})]})}function fs(e){return e.status===`active`?e.isDraft?`draft`:`active`:e.status===`completed`?`completed`:e.status===`abandoned`?`abandoned`:`active`}var ps={active:`Active`,draft:`Draft`,completed:`Completed`,abandoned:`Abandoned`},ms={active:`text-added`,draft:`text-muted`,completed:`text-renamed`,abandoned:`text-deleted`};function hs(e,t){let n=pa(t.supportsIterations?e:null),r=n.data?.at(-1),i=(0,P.useMemo)(()=>r===void 0?null:{iteration:r,since:null},[r]),a=ha(t.supportsIterations?e:null,i),o=ja(e),s=Xi(e,t).data,c=s===void 0||s.length===0||t.status!==`active`?null:ea(s),l=c?.total??null,u=c?.unresolved??null,d=c?.anyResolved??!1,f=(0,P.useMemo)(()=>l===null||u===null?null:{total:l,unresolved:u,anyResolved:d},[l,u,d]),p=o.data?.pages.reduce((e,t)=>e+t.commits.length,0),m=a.data===void 0?n.data?.length===0?`0`:null:String(a.data.files.length),h=p===void 0?null:`${p}${o.hasNextPage?`+`:``}`;return(0,P.useMemo)(()=>({files:m,commits:h,conflicts:f}),[m,h,f])}var gs=1500,_s={o:{tab:`overview`},f:{tab:`files`},c:{tab:`commits`},x:{tab:`conflicts`}};function vs(e,t){let n=Da(e,t);(0,P.useEffect)(()=>{let e=null,t=()=>{e!==null&&window.clearTimeout(e),e=null},r=r=>{if(r.ctrlKey||r.metaKey||r.altKey||La(r))t();else if(e!==null){let e=_s[r.key];if(t(),e===void 0)return;r.preventDefault(),r.stopPropagation(),n(e)}else r.key===`g`&&!r.repeat&&(r.preventDefault(),e=window.setTimeout(t,gs))};return window.addEventListener(`keydown`,r,!0),()=>{t(),window.removeEventListener(`keydown`,r,!0)}},[n])}export{Bi as $,qt as $t,Da as A,ht as An,qn as At,Qi as B,Ue as Bn,An as Bt,Ra as C,ft as Cn,fr as Ct,ja as D,ot as Dn,cr as Dt,Ma as E,lt as En,lr as Et,ha as F,Xe as Fn,K as Ft,Wi as G,gn as Gt,ea as H,Ve as Hn,Dn as Ht,pa as I,Ye as In,jn as It,Hi as J,H as Jt,Fi as K,U as Kt,_a as L,qe as Ln,In as Lt,Sa as M,Ke as Mn,Pn as Mt,ya as N,Ze as Nn,Nn as Nt,Oa as O,rt as On,sr as Ot,da as P,Qe as Pn,Mn as Pt,Li as Q,z as Qt,na as R,tt as Rn,G as Rt,La as S,mt as Sn,_r as St,Pa as T,st as Tn,ur as Tt,$i as U,Tn as Ut,Yi as V,We as Vn,On as Vt,Xi as W,En as Wt,Ji as X,Zt as Xt,Ki as Y,Qt as Yt,zi as Z,Xt as Zt,lo as _,$e as _n,Sr as _t,ms as a,Et as an,wi as at,Ia as b,pt as bn,hr as bt,es as c,wt as cn,Wr as ct,Vo as d,Ct as dn,xr as dt,Yt as en,Ri as et,Go as f,I as fn,Mr as ft,go as g,it as gn,Nr as gt,vo as h,at as hn,Tr as ht,ps as i,kt as in,Ai as it,ba as j,Je as jn,Un as jt,Ea as k,Ge as kn,$n as kt,$ as l,yt as ln,Hr as lt,Po as m,gt as mn,wr as mt,rs as n,Wt as nn,Ui as nt,fs as o,Dt as on,ni as ot,Io as p,_t as pn,Dr as pt,Gi as q,rn as qt,us as r,L as rn,ki as rt,ns as s,Ot as sn,Zr as st,as as t,Gt as tn,qi as tt,Uo as u,St as un,Cr as ut,Ha as v,ut as vn,Er as vt,Na as w,et as wn,dr as wt,Fa as x,ct as xn,mr as xt,Ua as y,dt as yn,pr as yt,ra as z,nt as zn,Fn as zt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{bt as e,f as t,vt as n,zn as r}from"./index-B297yCgq.js";import{n as i}from"./home-page-Y5jGxOav.js";var a=r();function o(){let r=t.useNavigate();return(0,a.jsx)(i,{onOpen:t=>{let i=n(t);return i!==null&&(r({href:e(i)}),!0)}})}export{o as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Vt as e,an as t,cn as n,in as r,nn as i,sn as a,st as o}from"./pull-request-layout-DsDKURcq.js";import{n as s,r as c,t as l}from"./stream-tokenizer-B5Ok5N3S.js";import{n as u}from"./utils-Tkdy0sOA.js";import{n as d,t as f}from"./lineChanges-Dw4ZXwVU.js";import{createCssVariablesTheme as p,createHighlighterCore as m,n as h,r as g}from"./core-DfsS1UI1.js";import{p as _}from"./index-B297yCgq.js";function v(e,t){let n=Array.isArray(e)?e:[e];if(n.length>1&&t.name!==`highlights`){for(let e of n){let n=y(e);t.attachLanguages([n]),r.add(n.name)}return}let i=n.map(y);t.attachLanguages(i);for(let e of i)r.add(e.name)}function y(e){let t=e.highlights==null?n:a;return t.get(e.name)??(t.set(e.name,e),e)}var b=0,x=1,S=0,C=class{backend;#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=!1;#u=[{state:g,brackets:void 0}];#d=[];#f=-1;#p=!1;#m=0;#h=++S;#g=!1;#_=u(async e=>{if(!this.#l){if(this.#t==null&&!T(this.#i.languageId)){if(await this.backend?.loadLanguages([this.#i.languageId]),this.#l)return;this.#t=this.#e.getLanguage(this.#i.languageId)}this.#D(),this.#f=Math.max(this.#f,e),this.#b()}},500);#v=({data:e})=>{if(typeof e!=`object`||!e)return;let{type:t,tokenizerId:n,jobId:r}=e;t===`tokenize`&&n===this.#h&&r===this.#m&&this.#y()};constructor(e,t,n){this.backend=n,this.#e=e,this.#i=t.textDocument,this.#n=t.theme,this.#r=[],this.#a=t.tokenizeMaxLineLength??1e3,this.#o=t.onDeferTokenize,this.#s=t.matchBrackets!==!1,this.#c=t.__debug??!1,this.#O(),this.#D()}applyChange(e,t){if(this.#O(),this.#D(),this.#t==null&&!T(this.#i.languageId))throw Error(`Grammar for language "${this.#i.languageId}" not loaded`);let n=f(e);this.#u=d(this.#u,n,()=>void 0).entries,this.#C(n),this.#S(e.changedLineRanges??[[e.startLine,e.endLine]]),this.#p=!1;let r=t==null?this.#i.lineCount:t[1],i=this.advance(r,t==null?void 0:x);return this.#b(),i}flush(e){this.#O(),this.#D();let t=this.advance(e);return this.#b(),t}prime(e){this.#O(),this.#_(e[1])}bracketIgnoredRanges(e){if(this.#O(),this.#t==null)return null;if(this.#u[e]?.brackets===void 0){let t=this.#A(e,this.#T(e));this.#u[e+1]??this.#E(e+1,t)}return this.#u[e]?.brackets??null}setTheme(e){this.#n!==e&&(this.#n=e,this.#D(),this.#S([[0,this.#i.lineCount-1]]),this.#b())}pause(){this.#p||(this.#p=!0,this.#m++)}resume(){this.#p&&(this.#p=!1,this.#b())}dispose(){this.#l=!0,this.#m++,this.#d=[],this.#f=-1,this.#x()}advance(e,t){let n=new Map;if(this.#t==null&&!T(this.#i.languageId))return n;let r=t==null?0:performance.now(),i=Math.min(e,this.#i.lineCount);for(;this.#d.length>0;){let e=this.#d[0],a=e[0];if(a>=i)break;let o=this.#T(a),s=!1;for(;a<i;){let i=this.#u[a+1]?.state,c=this.#k(a,o);if(n.set(a,c.resolvedTokens),o=c.state,this.#E(a+1,o),a++,a>e[1]&&i!=null&&o.equals(i)){s=!0;break}if(t!=null&&performance.now()-r>t)break}if(s||a>=this.#i.lineCount){for(this.#d.shift();this.#d.length>0&&this.#d[0][1]<a;)this.#d.shift();this.#d.length>0&&this.#d[0][0]<a&&(this.#d[0][0]=a)}else{e[0]=a,e[1]<a&&(e[1]=a);break}}return n}#y(){if(this.#p||this.#l)return;this.#D();let e=performance.now(),t=this.advance(this.#i.lineCount,x);if(t.size>0&&this.#o(t),this.#d.length===0&&this.#f>=0){let t=Math.min(this.#f,this.#i.lineCount),n=this.#w(),r=this.#u[n]?.state??g;for(;n<t&&(r=this.#A(n,r),n++,this.#E(n,r),!(performance.now()-e>x)););n>=t&&(this.#f=-1)}this.#b()}#b(){if(this.#p||this.#l||this.#d.length===0&&this.#f<0||T(this.#i.languageId)){this.#x();return}let e=++this.#m;this.#g||=(globalThis.addEventListener(`message`,this.#v),!0),globalThis.postMessage({type:`tokenize`,tokenizerId:this.#h,jobId:e})}#x(){this.#g&&=(globalThis.removeEventListener(`message`,this.#v),!1)}#S(e){let t=[],n=0,r=0;for(;n<this.#d.length||r<e.length;){let i=this.#d[n],a=e[r],o;if(a==null||i!=null&&i[0]<=a[0]?(o=i,n++):(o=a,r++),o[1]<o[0])continue;let s=t[t.length-1];s!=null&&o[0]<=s[1]+1?s[1]=Math.max(s[1],o[1]):t.push([o[0],o[1]])}this.#d=t}#C(e){for(let[t,n,r]of e){let e=n-r;for(let i of this.#d)i[1]<t||(i[0]>e?(i[0]+=r,i[1]+=r):(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1]+r,n)))}}#w(){let e=Math.min(this.#u.length-1,this.#i.lineCount);for(;e>0&&this.#u[e]==null;)e--;return e}#T(e){let t=this.#u[e]?.state;if(t!=null)return t;let n=this.#w();if(n>e)for(n=e;n>0&&this.#u[n]==null;)n--;let r=this.#u[n]?.state??g;for(;n<e;n++)r=this.#A(n,r),this.#E(n+1,r);return r}#E(e,t){let n=this.#u[e];n==null?this.#u[e]={state:t,brackets:void 0}:n.state=t}#D(){if(this.#n===``)return;this.backend?.getTheme(this.#n);let{colorMap:e}=this.#e.setTheme(this.#n);this.#r=e}#O(){this.#t==null&&!T(this.#i.languageId)&&this.#e.getLoadedLanguages().includes(this.#i.languageId)&&(this.#t=this.#e.getLanguage(this.#i.languageId))}#k(e,t){let n=this.#i.getLineText(e);if(n.length>=this.#a)return console.warn(`[diffs] Line(${e}) too long to tokenize: ${n.length}`),this.#j(e,null),{resolvedTokens:[[0,``,n]],state:t};if(this.#t==null||n===``||n.trim()===``)return this.#j(e,null),{resolvedTokens:[[0,``,n]],state:t};let r=w(this.#t,this.#r,n,t,b,this.#s);return this.#j(e,r.bracketIgnoredRanges),{resolvedTokens:r.resolvedTokens,state:r.ruleStack}}#A(e,t){let n=this.#i.getLineText(e);if(this.#t==null||n.length>=this.#a||n===``||n.trim()===``)return this.#j(e,null),t;let r=w(this.#t,this.#r,n,t,b,this.#s,!1);return this.#j(e,r.bracketIgnoredRanges),r.ruleStack}#j(e,t){if(!this.#s)return;let n=this.#u[e];if(n==null)throw Error(`ShikiEditorTokenizer: line ${e} has no record`);n.brackets=t}};function w(e,t,n,r,i,a=!0,o=!0){let s=e.tokenizeLine2(n,r,i);s.stoppedEarly&&console.warn(`[diffs] Time limit reached when tokenizing line: ${n.substring(0,100)}`);let c=s.tokens,l=c.length/2,u=[],d=[];if(!o&&!a)return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d};for(let e=0;e<l;e++){let r=c[2*e],i=e+1<l?c[2*e+2]:n.length;if(r===i)continue;let s=c[2*e+1];if(o){let e=h.getForeground(s);u.push([r,t[e],n.slice(r,i)])}a&&h.getTokenType(s)>0&&d.push([r,i])}return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d}}function T(e){return e===`text`||e===`ansi`}var E=class t extends l{highlighter;options;#e=``;#t;constructor(e,t){super(),this.highlighter=e,this.options=t}tokenizeChunk(t,n){let r=(this.#e+t).split(/(\r\n|\r|\n)/),i=[];for(let t=0;t<r.length;t+=2){let a=r[t],o=this.highlighter.codeToTokens(a,{...this.options,grammarState:this.#t}),s=o.tokens[0].map(e=>({...e,offset:e.offset+this.stableOffset}));t+1<r.length?(e(n,s),this.pushLineBreak(n,a.length,r[t+1]),this.#t=o.grammarState):(i=s,this.#e=a)}return{unstable:i,tailLength:this.#e.length}}clone(){this.assertActive();let e=new t(this.highlighter,this.options);return this.copyStateTo(e),e.#e=this.#e,e.#t=this.#t,e}resetSource(){this.#e=``,this.#t=void 0}releaseSource(){this.resetSource()}},D=class e extends s{raw;loadedThemes=new Map;attachedLanguages=new Set([`text`,`ansi`]);static async create(t){let n=t===`shiki-wasm`?(await _(async()=>{let{createOnigurumaEngine:e}=await import(`./engine-oniguruma-D--T0LcV.js`);return{createOnigurumaEngine:e}},[])).createOnigurumaEngine(_(()=>import(`./wasm-C7N7kd8H.js`),[])):(await _(async()=>{let{createJavaScriptRegexEngine:e}=await import(`./engine-javascript-C4Jk_eU2.js`);return{createJavaScriptRegexEngine:e}},[])).createJavaScriptRegexEngine(),r=await m({themes:[],langs:[],engine:n});return new e(t,r)}constructor(e,t){super(e,i(e)),this.raw=t}getTheme(e){this.assertNotDisposed();let t=this.loadedThemes.get(e),n=this.themeResolver.getResolvedTheme(e)??t;if(n==null)throw Error(`Theme "${e}" has not been resolved`);if(t!==n){let t=n.textmate??(n.cssVariables==null?void 0:p(n.cssVariables));if(t==null)throw Error(`Theme "${e}" does not support Shiki`);this.raw.setTheme({...t,name:e}),this.loadedThemes.set(e,n)}return n}codeToTokens(e,t){return this.raw.codeToTokens(e,this.resolveOptions(t))}createEditorTokenizer(e){return new c(new C(this.raw,e,this),e)}createStreamTokenizer(e){return new E(this.raw,this.resolveOptions(e))}async loadLanguages(e){this.assertNotDisposed();let t=e.filter(e=>!this.attachedLanguages.has(e));v(await o(t),this)}hasLoadedLanguages(e){if(this.disposed)return!1;let n;return e.every(e=>this.attachedLanguages.has(e)?!0:!t.has(e)&&(n??=this.raw.getLoadedLanguages(),n.includes(e)))}attachLanguages(e){this.assertNotDisposed();for(let t of e){if(this.attachedLanguages.has(t.name))continue;let e=t.data.find(e=>e.name===t.name||e.aliases?.includes(t.name)===!0);if(e==null)throw Error(`attachResolvedLanguages: No returned grammar declares "${t.name}" as its name or an alias.`);this.raw.loadLanguageSync(t.data);try{this.raw.getLanguage(t.name)}catch{throw Error(`attachResolvedLanguages: "${e.name}" is already loaded without alias "${t.name}". Load the alias first or give the grammar a unique name.`)}this.attachedLanguages.add(t.name)}}releaseResources(){this.loadedThemes.clear(),this.attachedLanguages.clear(),this.raw.dispose()}resolveOptions({theme:e,themes:t,...n}){if(this.assertNotDisposed(),e!=null)return this.getTheme(e),{...n,theme:e};if(t==null)throw Error(`A theme or themes option is required`);for(let e of Object.values(t))this.getTheme(e);return{...n,themes:t}}};export{D as ShikiHighlighter};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-BLXQ4ufn.js";import{Bn as t,D as n,G as r,I as i,M as a,S as o,T as s,bn as c,j as l,rt as u,vn as d,w as f,zn as p}from"./index-B297yCgq.js";import{A as m,k as h,s as g,x as _}from"./pull-request-layout-DsDKURcq.js";import{t as v}from"./commits-view-B_TQ6AnD.js";var y=e(t(),1),b=p(),x=!0;function S({filesCount:e,filter:t,onFilterChange:n,filterRef:i,tree:a,totals:s,currentCommit:c,panel:l,onPanelChange:d}){let{location:f,shortForm:p,scope:m}=g(),_=(0,y.useId)();return(0,b.jsxs)(u,{top:(0,b.jsxs)(h,{location:f,shortForm:p,page:{tab:`overview`},className:`flex h-8 items-center gap-1.5 rounded-[7px] px-2 text-[13px] text-muted hover:bg-hover hover:text-fg`,testId:`back-to-overview`,children:[(0,b.jsx)(o,{className:`size-3.5`}),`Back`]}),children:[(0,b.jsxs)(`div`,{className:`shrink-0 space-y-2 px-3 pb-2`,children:[(0,b.jsx)(C,{value:l,onChange:d,filesCount:e}),l===`files`&&(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`label`,{className:`sr-only`,htmlFor:_,children:`Filter files`}),(0,b.jsx)(r,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted`}),(0,b.jsx)(`input`,{id:_,ref:i,type:`search`,value:t,onChange:e=>n(e.currentTarget.value),onKeyDown:e=>{e.key===`Escape`&&(n(``),e.currentTarget.blur())},placeholder:`Filter files…`,autoComplete:`off`,spellCheck:!1,"aria-keyshortcuts":`t`,className:`h-8 w-full rounded-[7px] border border-border bg-surface pr-7 pl-8 text-[13px] text-fg placeholder:text-muted hover:border-border-strong focus:border-[var(--azd-focus)] focus:outline-none`}),(0,b.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 rounded border border-border px-1 font-mono text-[10px] leading-4 text-muted`,children:`t`})]})]}),l===`files`?(0,b.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-1`,children:a}):(0,b.jsx)(`div`,{className:`azd-scrollbar min-h-0 flex-1 overflow-y-auto pb-3`,children:(0,b.jsx)(v,{location:f,shortForm:p,scope:m,variant:`sidebar`,currentCommit:c})}),s!==null&&(0,b.jsx)(w,{totals:s})]})}function C({value:e,onChange:t,filesCount:n}){let{location:r,shortForm:o,counts:s}=g(),u=m(r,o),d=s.conflicts,p=[{value:`files`,name:`Files${n===null?``:` ${n}`}`,testId:`sidebar-files`,label:(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(i,{className:`size-3.5`}),`Files`,n!==null&&(0,b.jsx)(`span`,{className:`font-normal tabular-nums text-muted`,children:n})]})},{value:`commits`,name:`Commits${s.commits===null?``:` ${s.commits}`}`,testId:`sidebar-commits`,label:(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(l,{className:`size-3.5`}),(0,b.jsx)(`span`,{className:d===null?``:`sr-only`,children:`Commits`}),s.commits!==null&&(0,b.jsx)(`span`,{className:`font-normal tabular-nums text-muted`,children:s.commits})]})}];return d!==null&&p.push({value:`conflicts`,name:d.unresolved===0?`Conflicts, all resolved`:`Conflicts ${d.unresolved}`,testId:`sidebar-conflicts`,label:(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,b.jsx)(a,{className:`size-3.5`}),`Conflicts`,d.unresolved===0?(0,b.jsx)(f,{className:`size-3 text-added`}):(0,b.jsx)(`span`,{className:`font-normal tabular-nums text-muted`,children:d.unresolved})]})}),(0,b.jsx)(c,{label:`Review`,value:e,onChange:e=>{e===`conflicts`?u({tab:`conflicts`}):t(e)},size:`lg`,stretch:!0,choices:p})}function w({totals:e}){let[t,r]=(0,y.useState)(x),i=e=>{x=e,r(e)},a=(0,y.useId)(),o=e.ready<e.files;return(0,b.jsxs)(`section`,{"aria-label":`Diff stats`,className:`shrink-0 border-t border-border px-3 py-1.5 text-[13px]`,"data-testid":`diff-totals`,"data-partial":o?`true`:`false`,children:[(0,b.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":a,onClick:()=>i(!t),className:`flex h-7 w-full items-center gap-2 rounded-md px-1 text-muted hover:text-fg`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:`Diff stats`}),o&&(0,b.jsxs)(`span`,{className:`text-xs tabular-nums`,children:[e.ready,` of `,e.files,` files counted`]}),(0,b.jsx)(`span`,{className:`ml-auto`,children:t?(0,b.jsx)(s,{className:`size-3.5`}):(0,b.jsx)(n,{className:`size-3.5`})})]}),t&&(0,b.jsxs)(`dl`,{id:a,className:`space-y-1 px-1 pt-0.5 pb-1 tabular-nums`,children:[(0,b.jsx)(T,{label:`Files`,value:e.files.toLocaleString(`en-US`)}),(0,b.jsx)(T,{label:`Additions`,value:`+${e.additions.toLocaleString(`en-US`)}`,tone:`text-added`}),(0,b.jsx)(T,{label:`Deletions`,value:`−${e.deletions.toLocaleString(`en-US`)}`,tone:`text-deleted`})]})]})}function T({label:e,value:t,tone:n=`text-fg`}){return(0,b.jsxs)(`div`,{className:`flex items-center justify-between text-[13px]`,children:[(0,b.jsx)(`dt`,{className:`text-muted`,children:e}),(0,b.jsx)(`dd`,{className:`font-mono text-xs ${n}`,children:t})]})}function E({open:e,onClose:t,shortcuts:n=_}){let r=(0,y.useRef)(null);return(0,y.useEffect)(()=>{let t=r.current;t!==null&&(e&&!t.open&&t.showModal(),!e&&t.open&&t.close())},[e]),(0,b.jsxs)(`dialog`,{ref:r,onClose:t,"aria-labelledby":`azd-shortcuts-title`,className:`m-auto w-[22rem] rounded-[12px] border border-border bg-surface p-5 text-fg shadow-[var(--azd-shadow)] backdrop:bg-black/50`,children:[(0,b.jsx)(`h2`,{id:`azd-shortcuts-title`,className:`mb-4 text-[15px] font-semibold text-fg-strong`,children:`Keyboard shortcuts`}),(0,b.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] items-center gap-x-4 gap-y-2 text-[13px]`,children:n.map(e=>(0,b.jsxs)(`div`,{className:`contents`,children:[(0,b.jsx)(`dt`,{children:(0,b.jsx)(`kbd`,{className:`inline-flex h-6 items-center rounded-md border border-border bg-raised px-1.5 font-mono text-xs text-fg`,children:e.keys})}),(0,b.jsx)(`dd`,{className:`text-muted`,children:e.description})]},e.keys))}),(0,b.jsx)(`p`,{className:`mt-4 text-xs text-muted`,children:`Shortcuts are off while typing in a field.`}),(0,b.jsx)(`form`,{method:`dialog`,className:`mt-3 text-right`,children:(0,b.jsx)(`button`,{type:`submit`,className:d,children:`Close`})})]})}export{S as n,C as r,E as t};
|