getborg 0.0.118 → 0.0.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/bin.mjs +251 -79
  2. package/dist/client/.vite/manifest.json +171 -171
  3. package/dist/client/assets/{ChatMarkdown-BhfpBJaq.js → ChatMarkdown-6kh9qKYW.js} +2 -2
  4. package/dist/client/assets/{DesignWorkspace-okkekyBu.js → DesignWorkspace-DPuyt5mw.js} +2 -2
  5. package/dist/client/assets/{DiffPanel-Dn_Or9fx.js → DiffPanel-DzRhendL.js} +2 -2
  6. package/dist/client/assets/{DiffWorkerPoolProvider-Hp3trMBG.js → DiffWorkerPoolProvider-BU7l1oGv.js} +2 -2
  7. package/dist/client/assets/{DocxPreview-DHnzhQMX.js → DocxPreview-B7-febv_.js} +4 -4
  8. package/dist/client/assets/{FilePreviewPanel-KOVwBhPe.js → FilePreviewPanel-B3x43muL.js} +4 -4
  9. package/dist/client/assets/{HtmlPreview-I3xV5YgS.js → HtmlPreview-DY3PT2FT.js} +2 -2
  10. package/dist/client/assets/{PdfPreview-CjWrZkCM.js → PdfPreview-W5mTp32l.js} +3 -3
  11. package/dist/client/assets/{PptxPreview-D4YsFq_s.js → PptxPreview-B02U0OAE.js} +3 -3
  12. package/dist/client/assets/{PreviewPanel-CKieJ-9L.js → PreviewPanel-DhzZlEWJ.js} +2 -2
  13. package/dist/client/assets/{PullRequestCodeTab-DbUx3FWB.js → PullRequestCodeTab-CoB5ByAD.js} +2 -2
  14. package/dist/client/assets/{PullRequestReactions-BSI_Qt4L.js → PullRequestReactions-DVg6Hz1F.js} +2 -2
  15. package/dist/client/assets/{VirtualizedFile-VSzhLWFM.js → VirtualizedFile-Bz5fGbNr.js} +2 -2
  16. package/dist/client/assets/{XlsxPreview-BnnrdNes.js → XlsxPreview-8ACeuCsx.js} +3 -3
  17. package/dist/client/assets/{assetUrls-C2vkiSgX.js → assetUrls-CbeTQh3H.js} +2 -2
  18. package/dist/client/assets/{browserHistoryStore-CIr_OQCq.js → browserHistoryStore-DLbnuO9R.js} +2 -2
  19. package/dist/client/assets/{browserRecording-BmG6q-H4.js → browserRecording-DpmNgRt_.js} +2 -2
  20. package/dist/client/assets/{combobox-uXzVxkLc.js → combobox-CByZwSML.js} +2 -2
  21. package/dist/client/assets/{composerMentionDrag-DTGN7WcV.js → composerMentionDrag-1fGsNlV_.js} +2 -2
  22. package/dist/client/assets/{designCanvas.logic-DtK3Ht6X.js → designCanvas.logic-BaQE_ItM.js} +2 -2
  23. package/dist/client/assets/{designOpenFileContext-DCJpUleA.js → designOpenFileContext-CCL9VKvQ.js} +2 -2
  24. package/dist/client/assets/{diffFileContents-CFjzWK4l.js → diffFileContents-CgDa-z2d.js} +2 -2
  25. package/dist/client/assets/{empty-tcpR9LH8.js → empty-CLS3rXBc.js} +2 -2
  26. package/dist/client/assets/{entities-Da-AvwsX.js → entities-DPi_gbtI.js} +2 -2
  27. package/dist/client/assets/{index-DraeEDbf.js → index-DnoL7z0M.js} +3 -3
  28. package/dist/client/assets/{input-BRLXkmUH.js → input-BbliVf4z.js} +2 -2
  29. package/dist/client/assets/{lib-ay4Y8Jpt.js → lib-CySB76JU.js} +2 -2
  30. package/dist/client/assets/{main-Bn8Ylf8R.js → main-Ck7oK5At.js} +5 -5
  31. package/dist/client/assets/{pdf-BH4RlEy2.js → pdf-CdULDwXT.js} +2 -2
  32. package/dist/client/assets/{popover-DTprsoPQ.js → popover-CFDsW-_z.js} +2 -2
  33. package/dist/client/assets/{pptxDocument-ifTk53yH.js → pptxDocument-Dh-M0DL5.js} +2 -2
  34. package/dist/client/assets/{projectFilesQueryState-CD_JXBj5.js → projectFilesQueryState-CmtzaSrb.js} +2 -2
  35. package/dist/client/assets/{queries-D1AwaR_5.js → queries-DRotn4pk.js} +2 -2
  36. package/dist/client/assets/{scroll-area-j6QV0udq.js → scroll-area-BW5o0Izf.js} +2 -2
  37. package/dist/client/assets/{session-BaysTZDD.js → session-D3Szkrpk.js} +2 -2
  38. package/dist/client/assets/{textarea-BB3euU4O.js → textarea-5SMJbr7K.js} +2 -2
  39. package/dist/client/assets/{xlsxDocument-DwhEMpfP.js → xlsxDocument-BMNJtufK.js} +2 -2
  40. package/dist/client/index.html +1 -1
  41. package/dist/service-launcher.mjs +1 -1
  42. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{v as t,y as n}from"./accountData-C4ZvicpJ.js";import{Bo as r,dn as i}from"./utils-DgzD4MA_.js";import{t as a}from"./textarea-BB3euU4O.js";import{A as o,At as s,C as c,Ct as l,D as u,Dt as d,E as f,Et as p,F as m,I as h,L as g,M as _,Mr as v,N as y,Nt as b,O as x,P as S,Pt as C,R as w,S as T,St as E,T as D,Tt as O,U as k,W as A,_ as j,_r as M,b as N,bt as P,c as F,cr as I,d as L,dt as R,fr as z,ft as B,g as ee,gr as te,h as V,hr as ne,ht as re,ir as H,j as ie,jt as ae,k as U,l as oe,m as se,mt as W,ot as G,p as ce,pt as le,s as ue,st as K,u as de,ur as q,v as fe,vr as pe,w as me,wt as he,x as ge,xt as J,y as _e}from"./scroll-area-j6QV0udq.js";import{i as ve}from"./toggle-DwBa6pBo.js";import{t as Y}from"./lib-BpnzBIoA.js";var ye=e(n(),1),be=t();function X(e,t,n){return!n&&(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&t.trim().length>0}var Z=r();function xe(e){let t=(0,be.c)(43),{kind:n,rangeLabel:r,text:o,onTextChange:s,onCancel:c,onComment:l,onDelete:u,placeholder:d,submitLabel:f,pending:p,secondaryAction:m}=e,h=d===void 0?`Add a comment…`:d,g=f===void 0?`Comment`:f,_=p===void 0?!1:p,[y,b]=(0,ye.useState)(``),x=n===`draft`&&!s?y:o,S;t[0]===x?S=t[1]:(S=x.trim(),t[0]=x,t[1]=S);let C=S;if(n===`comment`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ve,{className:`mt-0.5 size-3.5 shrink-0 text-primary/70`,"aria-hidden":`true`}),t[2]=e):e=t[2];let n;t[3]===x?n=t[4]:(n=(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap text-[13px] leading-5`,children:x}),t[3]=x,t[4]=n);let r;t[5]===u?r=t[6]:(r=u?(0,Z.jsx)(i,{className:`-my-1 -mr-1 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/comment:opacity-100 focus-visible:opacity-100 max-sm:opacity-100`,variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:u,children:(0,Z.jsx)(v,{className:`size-3`})}):null,t[5]=u,t[6]=r);let a;return t[7]!==n||t[8]!==r?(a=(0,Z.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`group/comment flex min-w-0 items-start gap-2.5 bg-selection px-3 py-2.5 font-sans text-foreground`,contentEditable:!1,onPointerDown:we,children:[e,n,r]}),t[7]=n,t[8]=r,t[9]=a):a=t[9],a}let w=`Comment on lines ${r}`,T;t[10]===s?T=t[11]:(T=e=>(s??b)(e.target.value),t[10]=s,t[11]=T);let E;t[12]!==c||t[13]!==l||t[14]!==_||t[15]!==C?(E=e=>{e.key===`Escape`&&(e.preventDefault(),c()),X(e,C,_)&&(e.preventDefault(),l(C))},t[12]=c,t[13]=l,t[14]=_,t[15]=C,t[16]=E):E=t[16];let D;t[17]!==x||t[18]!==h||t[19]!==w||t[20]!==T||t[21]!==E?(D=(0,Z.jsx)(a,{autoFocus:!0,unstyled:!0,className:`relative inline-flex w-full rounded-md border border-border/50 bg-background/20 font-sans text-foreground transition-colors focus-within:border-border/70 [&_[data-slot=textarea]]:min-h-12 [&_[data-slot=textarea]]:cursor-text [&_[data-slot=textarea]]:px-2.5 [&_[data-slot=textarea]]:py-1.5 [&_[data-slot=textarea]]:font-sans [&_[data-slot=textarea]]:text-xs [&_[data-slot=textarea]]:leading-5 max-sm:[&_[data-slot=textarea]]:min-h-12`,size:`sm`,value:x,placeholder:h,"aria-label":w,onChange:T,onFocus:Se,onKeyDown:E}),t[17]=x,t[18]=h,t[19]=w,t[20]=T,t[21]=E,t[22]=D):D=t[22];let O;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground/70`,children:`⌘/Ctrl Enter to send`}),t[23]=O):O=t[23];let k;t[24]===c?k=t[25]:(k=(0,Z.jsx)(i,{className:`text-muted-foreground hover:text-foreground`,variant:`ghost`,size:`xs`,onClick:c,children:`Cancel`}),t[24]=c,t[25]=k);let A;t[26]!==m||t[27]!==C?(A=m?(0,Z.jsxs)(i,{size:`xs`,variant:`outline`,disabled:!m.allowEmpty&&!C,onClick:()=>m.onAction(C),children:[m.icon,m.label]}):null,t[26]=m,t[27]=C,t[28]=A):A=t[28];let j=_||!C,M;t[29]!==l||t[30]!==C?(M=()=>l(C),t[29]=l,t[30]=C,t[31]=M):M=t[31];let N;t[32]!==g||t[33]!==j||t[34]!==M?(N=(0,Z.jsx)(i,{size:`xs`,disabled:j,onClick:M,children:g}),t[32]=g,t[33]=j,t[34]=M,t[35]=N):N=t[35];let P;t[36]!==k||t[37]!==A||t[38]!==N?(P=(0,Z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1`,children:[O,k,A,N]}),t[36]=k,t[37]=A,t[38]=N,t[39]=P):P=t[39];let F;return t[40]!==P||t[41]!==D?(F=(0,Z.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`px-3 py-2 font-sans text-foreground`,contentEditable:!1,onPointerDown:Ce,children:[D,P]}),t[40]=P,t[41]=D,t[42]=F):F=t[42],F}function Se(e){let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)}function Ce(e){return e.stopPropagation()}function we(e){return e.stopPropagation()}function Te({file:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,lineAnnotations:o,renderGutterUtility:s,getHoveredLine:c}){let l=t?.(e),u=n?.(e),d=r?.(e),f=i?.(e);return(0,Z.jsxs)(Z.Fragment,{children:[l==null?(0,Z.jsxs)(Z.Fragment,{children:[u!=null&&(0,Z.jsx)(`div`,{slot:`header-prefix`,children:u}),d!=null&&(0,Z.jsx)(`div`,{slot:`header-filename-suffix`,children:d}),f!=null&&(0,Z.jsx)(`div`,{slot:`header-metadata`,children:f})]}):(0,Z.jsx)(`div`,{slot:H,children:l}),a!=null&&o?.map((e,t)=>(0,Z.jsx)(`div`,{slot:b(e),children:a(e)},t)),s!=null&&(0,Z.jsx)(`div`,{slot:`gutter-utility-slot`,style:C,children:s(c)})]})}function Q(e,t){return t.cacheKey==null?e.file===t&&e.sourceContents===t.contents:e.cacheKey===t.cacheKey}var Ee=-1,De=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++Ee}`;highlighter;renderCache;computedLang=`text`;lineAnnotations={};lineCache;textDocumentCache=new WeakMap;constructor(e={theme:q},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=x(e.theme??q)?p():void 0)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setLineAnnotations(e){this.lineAnnotations={};for(let t of e){let e=this.lineAnnotations[t.lineNumber]??[];this.lineAnnotations[t.lineNumber]=e,e.push(t)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.textDocumentCache=new WeakMap}syncEditedContentsToFile(){let{renderCache:e,lineCache:t}=this;e?.isDirty!==!0||t==null||!Q(t,e.file)||(e.file.contents=t.lines.join(``))}hasUnkeyedFileContentsChanged(e){let{lineCache:t}=this;return e.cacheKey==null&&t!=null&&t.file===e&&t.sourceContents!==e.contents}invalidateChangedUnkeyedFile(e){this.hasUnkeyedFileContentsChanged(e)&&(this.workerManager?.cleanUpTasks(this),this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap)}clearRenderCache(){this.syncEditedContentsToFile();let e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(e.file.cacheKey)}hydrate(e){let{options:t}=this.getRenderOptions(e),n=$(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength()),r=this.workerManager?.getFileResultCache(e);r!=null&&!l(t,r.options)&&(r=void 0),this.renderCache??={file:e,options:t,highlighted:!n&&!J(e),result:n?void 0:r?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightFileAST(this,e):this.highlighter??(this.computedLang=e.lang??E(e.name),this.initializeHighlighter())}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getFileRenderOptions();let{theme:e=q,tokenizeMaxLineLength:t=1e3}=this.options;return{theme:e,useTokenTransformer:ge(this.options),tokenizeMaxLineLength:t}})(),{renderCache:n}=this;return n?.result==null||!s(e,n.file)||!l(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getOrCreateLineCache(e){this.invalidateChangedUnkeyedFile(e);let{lineCache:t}=this;return(t==null||!Q(t,e))&&(t={cacheKey:e.cacheKey,file:e,sourceContents:e.contents,lines:P(e.contents)}),this.lineCache=t,t.lines}getLineCount(e){let t=this.getOrCreateLineCache(e);return this.textDocumentCache.get(e)?.lineCount??t.length}updateRenderCache(e,t){if(this.renderCache==null)return;let{file:n,result:r}=this.renderCache;if(r==null)return;let i=this.lineCache!=null&&Q(this.lineCache,n)?this.lineCache:void 0;for(let[t,n]of e){if(i!=null&&t<i.lines.length){let e=n.map(e=>e[2]).join(``);i.lines[t]=u(i.lines[t]??``,e)}r.code[t]={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})}}r.baseThemeType=t,this.renderCache.isDirty=!0}applyDocumentChange(e){if(this.renderCache==null)return;let{file:t,result:n}=this.renderCache;if(n!=null){if(n.code.length!==e.lineCount){n.code.length=Math.min(n.code.length,e.lineCount);for(let t=n.code.length;t<e.lineCount;t++)n.code.push({type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:e.getLineText(t)}]}]});this.renderCache.isDirty=!0}this.lineCache={cacheKey:t.cacheKey,file:t,sourceContents:t.contents,lines:P(e.getText())},this.textDocumentCache.set(t,e)}}renderFile(e=this.renderCache?.file,t=I){if(e==null)return;this.invalidateChangedUnkeyedFile(e),this.renderCache?.isDirty===!0&&!s(e,this.renderCache.file)&&(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap);let{options:n,forceHighlight:r}=this.getRenderOptions(e),i=this.getMatchingWorkerResultCache(e,n);i!=null&&!this.hasHighlightedRenderCache(e,n)&&(this.renderCache={file:e,highlighted:!0,renderRange:void 0,...i},r=!1),this.renderCache??={file:e,highlighted:!1,options:n,result:void 0,renderRange:void 0};let a=this.getOrCreateLineCache(e),c=e.contents.length>0,l=!c||J(e)||$(a.length,this.getTokenizeMaxLength()),u=!s(e,this.renderCache.file),d=!o(this.renderCache.renderRange,t);if(this.workerManager?.isWorkingPool()===!0)(l||this.renderCache.result==null||!this.renderCache.highlighted&&(u||d))&&(this.renderCache.file=e,this.renderCache.options=n,this.renderCache.highlighted=!1,(this.renderCache.result==null||u||d||r)&&(this.renderCache.result=this.workerManager.getPlainFileAST(e,t.startingLine,t.totalLines,a)),this.renderCache.renderRange=t),!l&&c&&(!this.renderCache.highlighted||r)&&this.workerManager.highlightFileAST(this,e);else{this.computedLang=e.lang??E(e.name);let t=this.highlighter!=null&&x(n.theme),i=this.highlighter!=null&&U(this.computedLang),a=!l&&i;if(this.highlighter!=null&&t&&(r||l||!this.renderCache.highlighted&&a||this.renderCache.result==null)){let{result:t,options:n}=this.renderFileWithHighlighter(e,this.highlighter,l||!i);this.renderCache={file:e,options:n,highlighted:a,result:t,renderRange:void 0}}(!t||!l&&!i)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(e,t,n,!l)})}return this.renderCache.result==null?void 0:this.processFileResult(this.renderCache.file,t,this.renderCache.result)}async asyncRender(e,t=I){let{result:n}=await this.asyncHighlight(e);return this.processFileResult(e,t,n)}async asyncHighlight(e){let t=$(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??E(e.name);let n=this.highlighter!=null&&he(O(this.options.theme)),r=t||this.highlighter!=null&&U(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(e,this.highlighter,t)}renderFileWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e);return{result:R(e,t,r,{forcePlainText:n}),options:r}}processFileResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let a=this.getLineCount(e),{disableFileHeader:o=!1}=this.options,s=[],c=W(),l=Math.min(t.startingLine+t.totalLines,a),u=0,d=g(t)?m(this.lineAnnotations):void 0;d!=null&&(c.children.push(B(`context`,`annotation`,1)),s.push(f({type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:d.map(e=>b(e))})),u++);for(let r=t.startingLine;r<l;r++){let t=r+1,i=n[r];if(i==null){let n=`FileRenderer.processFileResult: Line doesnt exist`;throw console.error(n,{name:e.name,lineIndex:r,lineNumber:t}),Error(n)}c.children.push(le(`context`,t,`${r}`)),s.push(i),u++;let a=this.lineAnnotations[t];a!=null&&(c.children.push(B(`context`,`annotation`,1)),s.push(f({type:`annotation`,hunkIndex:0,lineIndex:t,annotations:a.map(e=>b(e))})),u++)}return c.properties.style=`grid-row: span ${u}`,{gutterAST:c.children??[],contentAST:s,preAST:this.createPreElement(a),headerAST:o?void 0:this.renderHeader(e),totalLines:a,rowCount:u,themeStyles:r,baseThemeType:i,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderHeader(e){let{headerRenderMode:t=`default`,stickyHeader:n=!1}=this.options;return me({fileOrDiff:e,mode:t,stickyHeader:n})}renderFullHTML(e){return Y(this.renderFullAST(e))}renderFullAST(e,t=[]){return t.push(re({tagName:`code`,children:this.renderCodeAST(e),properties:{"data-code":``}})),{...e.preAST,children:t}}renderCodeAST(e){let t=W();return t.children=e.gutterAST,t.properties.style=`grid-row: span ${e.rowCount}`,[t,D(e.contentAST,e.rowCount)]}renderPartialHTML(e,t=!1){return Y(t?re({tagName:`code`,children:e,properties:{"data-code":``}}):e)}async initializeHighlighter(){return this.highlighter=await d(T(this.computedLang,this.options)),this.highlighter}onHighlightSuccess(e,t,n,r=!0){if(this.renderCache==null)return;let i=!s(e,this.renderCache.file)||!this.renderCache.highlighted||!l(n,this.renderCache.options);this.renderCache={file:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){let n=this.workerManager?.getFileResultCache(e);if(!(n==null||!l(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&s(e,n.file)&&l(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(e){let{disableLineNumbers:t=!1,overflow:n=`scroll`}=this.options;return c({type:`file`,diffIndicators:`none`,disableBackground:!0,disableLineNumbers:t,overflow:n,split:!1,totalLines:e})}};function $(e,t){return e>t}function Oe(e,t){return e.lineNumber===t.lineNumber&&e.metadata===t.metadata}function ke(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:e?.useTokenTransformer,tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}var Ae=[``],je=-1,Me=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++je}`;type=`file`;fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:q},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new De(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new ie,this.interactionManager=new _(`file`,y(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}__getCurrentFile(){return this.file}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(y(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!ae(this.appliedThemeCSS.theme,this.options.theme??q)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{overflow:e=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e===`wrap`,columnVariables:this.shouldApplyColumnVariables(e)?`apply`:`measure`}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e===`scroll`&&this.lineAnnotations.length>0}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.unsafeCSSStyle=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1,this.editor?.cleanUp(e),this.editor=void 0}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:a}=e;if(!this.enabled)throw Error(`File.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`File.hydrate: hydrate can only be called before the instance has rendered or hydrated`);this.hydrateElements(t,n),Ne(this.pre,i,this.options.collapsed)||Pe(this.headerElement,i,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:i,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),F(e,t);for(let t of Array.from(e.shadowRoot?.children??[])){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t,this.appliedPreAttributes=void 0;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}if(`diffsHeader`in t.dataset){this.headerElement=t,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(ke(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e==null?Ae:this.fileRenderer.getOrCreateLineCache(e)}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){let e=this.editor,t=this.fileContainer,n=this.file,r=this.lineAnnotations,i=this.renderRange;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(a=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.file!==n||e.__syncRenderView(a,t,n,r,i)})}attachEditor(e){this.editor?.cleanUp(),this.editor=e,this.interactionManager.setEditorAttached(!0);let t=this.file==null?void 0:e.__prepareFile?.(this.file);return t!==void 0&&t!==this.file?this.renderPreparedFile({file:t,forceRender:!0,preventEmit:!0,renderRange:this.renderRange}):this.syncRenderViewToEditor(),()=>{this.editor=void 0,this.interactionManager.setEditorAttached(!1)}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t){this.fileRenderer.updateRenderCache(e,t)}render(e){if(!this.enabled)throw Error(`File.render: attempting to call render after cleaned up`);let t=this.editor?.__prepareFile?.(e.file)??e.file;return this.renderPreparedFile(t===e.file?e:{...e,file:t})}renderPreparedFile({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:i,deferManagers:a=!1,lineAnnotations:c,renderRange:l}){this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:u=!1,themeType:d=`system`}=this.options,f=u?void 0:l,p=this.renderRange,m=this.hasThemeChanged(),h=c!=null&&(c.length>0||this.lineAnnotations.length>0)?c!==this.lineAnnotations:!1,g=!s(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);if(!u&&!n&&o(f,this.renderRange)&&!g&&!h&&!m)return this.applyCachedThemeState(d);this.renderRange=f,g&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(ke(this.options)),this.syncInteractionOptions(),c!=null&&this.setLineAnnotations(c),this.fileRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:_=!1,disableFileHeader:v=!1}=this.options;if(v&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(d),u){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let n=this.fileRenderer.renderFile(e,ne);n!=null&&this.applyThemeState(t,n.themeStyles,d,n.baseThemeType),n?.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.injectUnsafeCSS()}catch(e){if(_)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}try{let r=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,h,g||m)||!this.applyPartialRender(p,f)){let n=this.fileRenderer.renderFile(e,f);if(n==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,n.themeStyles,d,n.baseThemeType),n.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.applyFullRender(n,r)}this.applyBuffers(r,f),this.injectUnsafeCSS(),this.managersDirty=!0,a||this.flushManagers(),this.renderAnnotations(),this.renderGutterUtility(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(_)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}primeHighlightCache(){let{file:e,workerManager:t}=this;e==null||e.cacheKey==null||t==null||J(e)||this.fileRenderer.getOrCreateLineCache(e).length>(this.options.tokenizeMaxLength??1e5)||t.primeFileHighlightCache(e).catch(()=>void 0)}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.gutterUtilityContent?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${b(r)}`,a=this.annotationCache.get(i);if(a==null||!Oe(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:fe(b(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=j();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=ee(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=se(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??q,s=typeof o==`string`?o:{...o},c=V(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=oe({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:ce(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=L(this.themeCSSStyle.textContent??``,V(e)))}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e),this.code=de({code:this.code});let n=this.fileRenderer.renderCodeAST(e);if(this.code.childElementCount>=2)for(let e=0;e<2;e++){let t=this.code.children[e],r=n[e];t.innerHTML=Y(r.children),t.style.cssText=r.properties.style}else this.code.innerHTML=Y(n);t.contains(this.code)||t.replaceChildren(this.code),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;let{file:n,code:r}=this,i=r==null?void 0:this.getColumns(r);if(n==null||r==null||i==null)return!1;let a=e.startingLine,o=t.startingLine,s=e.totalLines===1/0?1/0:a+e.totalLines,c=t.totalLines===1/0?1/0:o+t.totalLines,l=Math.max(a,o),u=Math.min(s,c);if(u<=l||!this.trimDOMToOverlap(i.gutter,l,u)||!this.trimDOMToOverlap(i.content,l,u))return!1;let{length:d}=i.content.children,f=(e,t)=>{if(!(t<=0))return this.fileRenderer.renderFile(n,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},p=o<l?f(o,l-o):void 0;if(p===void 0&&o<l)return!1;let m=c===1/0?1/0:Math.max(0,c-u),h=c>u?f(u,m):void 0;return h===void 0&&c>u?!1:(this.cleanupErrorWrapper(),p!=null&&(i.gutter.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.gutterAST)),i.content.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.contentAST)),d+=p.rowCount),h!=null&&(i.gutter.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.contentAST)),d+=h.rowCount),this.lastRowCount!==d&&(i.gutter.style.setProperty(`grid-row`,`span ${d}`),i.content.style.setProperty(`grid-row`,`span ${d}`),this.lastRowCount=d),!0)}getColumns(e){let t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(i>a)return!1;for(let t=e.children.length-1;t>=a;--t)e.children[t]?.remove();for(let t=i-1;t>=0;--t)e.children[t]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((e,t)=>e-t),r=new Map;if(n.length===0)return r;let i=0,a=n[i],{children:o}=e;a===0&&(r.set(0,0),i+=1,a=n[i]);for(let e=0;e<o.length;e+=1){let t=o[e];if(!(t instanceof HTMLElement))continue;let s=this.getLineIndexFromDOMNode(t);if(s!=null){for(;a!=null&&s>=a;)r.set(a,e),i+=1,a=n[i];if(i>=n.length)break}}for(let e of n)r.has(e)||r.set(e,o.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){let{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let r=this.cachedHeaderHTML??Y(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;let{renderHeaderPrefix:i,renderHeaderFilenameSuffix:a,renderCustomHeader:o,renderHeaderMetadata:s}=this.options;if(o!=null){let e=o(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,H,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{let e=i?.(n)??void 0,r=a?.(n)??void 0,o=s?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,pe,e),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,te,r),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,M,o),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:w(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):w(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=N;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute(`data-code`)){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n=`scroll`,disableLineNumbers:r=!1}=this.options,i={type:`file`,split:!1,overflow:n,disableLineNumbers:r,diffIndicators:`none`,disableBackground:!0,totalLines:t};_e(i,this.appliedPreAttributes)||(ue(e,i),this.appliedPreAttributes=i)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Ne(e,t,n=!1){return!n&&e==null&&t!=null}function Pe(e,t,n=!1){return e==null&&t!=null&&!n}var Fe=5e3,Ie=-1;function Le(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var Re=class extends Me{virtualizer;metrics;__id=`virtualized-file:${++Ie}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=z,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){!t&&A(this.metrics,e)||(this.metrics=e,this.resetLayoutCache())}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache()}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}hasLineAnnotations(){return this.lineAnnotations.some(e=>e.lineNumber>0)}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!k(t,e),r=Le(t,e);super.setOptions(e),r&&this.resetLayoutCache(!0),n&&(this.forceRenderOverride=!0),n&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache(e=!1,t=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&t&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(e=!0),this.height=0,e;let{overflow:t=`scroll`}=this.options;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return e;let n=this.code.children[1];if(!(n instanceof HTMLElement))return e;let r=h(this.lineAnnotations);if(this.renderRange!=null&&r&&g(this.renderRange)){let t=ze(n)??0;t!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=t,e=!0)}else!r&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,e=!0);for(let t of n.children){if(!(t instanceof HTMLElement))continue;let n=t.dataset.lineIndex;if(n==null)continue;let r=Number(n),i=t.getBoundingClientRect().height,a=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(a=!0),i+=t.nextElementSibling.getBoundingClientRect().height);let o=this.getLineHeight(r,a);i!==o&&(e=!0,i===this.metrics.lineHeight*(a?2:1)?this.cache.heights.delete(r):this.cache.heights.set(r,i))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(e,t,n,r){let i=this.syncLineAnnotations(r),a=this.fileRenderer.hasUnkeyedFileContentsChanged(e),o=n?.resetFileLayoutCache===!0||i||a;n?.metrics!=null&&(this.metrics=n.metrics,o=!0);let{collapsed:s=!1}=this.options;return this.currentCollapsed!==s&&(this.currentCollapsed=s,o=!0),o&&this.resetLayoutCache(),this.file!==e&&(this.layoutDirty=!0),this.file=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e){if(this.file==null||e<1)return;let{disableFileHeader:t=!1,collapsed:n=!1}=this.options,r=this.fileRenderer.getLineCount(this.file)-1,i=G(this.metrics,t);if(n||r<0)return{top:i,height:0};let a=Math.min(Math.max(e-1,0),r),{overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics;if(i+=this.cache.fileAnnotationHeight,o===`scroll`&&!this.hasLineAnnotations())return{top:i+a*s,height:s};let c=this.getLayoutCheckpointBeforeLineIndex(a);i=c?.top??i;for(let e=c?.lineIndex??0;e<a;e++)i+=this.getLineHeight(e,!1);return{top:i,height:this.getLineHeight(a,!1)}}getScrollContainer(){let e=this.getSimpleVirtualizer()?.getRoot();return e instanceof HTMLElement?e:e?.documentElement}getNumericScrollAnchor(e){if(this.file==null||this.renderRange==null)return;let{disableFileHeader:t=!1,collapsed:n=!1,overflow:r=`scroll`}=this.options;if(n||this.renderRange.totalLines<=0)return;let i=this.fileRenderer.getLineCount(this.file)-1;if(i<0)return;let a=G(this.metrics,t),o=Math.min(this.renderRange.startingLine,i),s=Math.min(o+this.renderRange.totalLines-1,i);if(s<o)return;let{fileAnnotationHeight:c}=this.cache;if(r===`scroll`&&!this.hasLineAnnotations()){let{lineHeight:t}=this.metrics,n=a+(o===0?c:this.renderRange.bufferBefore),r=o+Math.max(Math.ceil((e-n)/t),0);return r>s?void 0:{lineNumber:r+1,top:a+c+r*t}}let l=a+(o===0?c:this.renderRange.bufferBefore);for(let t=o;t<=s;t++){if(l>=e)return{lineNumber:t+1,top:l};l+=this.getLineHeight(t)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.file,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(e)}computeApproximateSize(e=!1){let t=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!t)return;let n=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.file==null){this.layoutDirty=!1;return}let{disableFileHeader:r=!1,collapsed:i=!1,overflow:a=`scroll`}=this.options,{lineHeight:o}=this.metrics,s=this.fileRenderer.getLineCount(this.file),c=G(this.metrics,r),l=K(this.metrics);if(this.height+=c,i){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,a===`scroll`&&!this.hasLineAnnotations())this.height+=s*o;else for(let e=0;e<s;e++)this.addLayoutCheckpoint(e,this.height),this.height+=this.getLineHeight(e,!1);if(s>0&&(this.height+=l),this.fileContainer!=null&&t&&!n){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFile.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFile.computeApproximateSize: computed height doesnt match`,{name:this.file.name,elementHeight:e.height,computedHeight:this.height})}this.layoutDirty=!1}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){let r=this.renderRange;if(super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1),n&&r!==void 0&&this.file!==void 0){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(this.file,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}}renderPreparedFile({fileContainer:e,file:t,forceRender:n=!1,lineAnnotations:r,...i}){let a=this.file==null||!s(this.file,t)||this.fileRenderer.hasUnkeyedFileContentsChanged(t),{forceRenderOverride:o,isSetup:c}=this;this.forceRenderOverride=void 0;let l=this.syncLineAnnotations(r);if(l&&this.resetLayoutCache(),this.file=t,e=this.getOrCreateFileContainerNode(e),this.file==null)return console.error(`VirtualizedFile.render: attempting to virtually render when we dont have file`),!1;if(c)this.top??=this.getVirtualizedTop(),a&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!0));else{this.computeApproximateSize();let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFile.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);let u=this.virtualizer.getWindowSpecs(),d=this.top??0,f=this.computeRenderRangeFromWindow(this.file,d,u),p=super.renderPreparedFile({file:this.file,fileContainer:e,renderRange:f,lineAnnotations:r,forceRender:(o??n)||l,...i});return this.isSimpleMode()&&p&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),p}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}addLayoutCheckpoint(e,t){e%Fe===0&&this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFile: invalid checkpoint index`);if(n.lineIndex%t===0)return n}}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,overflow:a=`scroll`}=this.options,{hunkLineCount:o,lineHeight:s}=this.metrics,c=this.fileRenderer.getLineCount(e),l=this.height,u=G(this.metrics,i),d=c>0?K(this.metrics):0,{fileAnnotationHeight:f}=this.cache,p=u+f,m=Math.max(0,l-u-f-d),g=h(this.lineAnnotations),_=t+u,v=f>0&&g&&_<r&&_+f>n;if(t<n-l||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};if(c<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};let y=Math.ceil(Math.max(r-n,0)/s),b=Math.ceil(y/o)*o+o*2,x=b/o,S=(n+r)/2;if(a===`scroll`&&!this.hasLineAnnotations()){let e=t+p,i=e+m;if(!v&&!(e<r&&i>n))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};let a=Math.floor(v&&S<t+p?0:(S-(t+p))/s),h=Math.floor(a/o)-Math.floor(x/2),g=Math.ceil(c/o),_=Math.max(0,Math.min(h,g))*o,y=h<0?b+h*o:b,C=_===0?0:f+_*s,w=Math.min(y,c-_);return{startingLine:_,totalLines:y,bufferBefore:C,bufferAfter:Math.max(0,(c-_-w)*s)}}let C=x,w=[],T=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-b*s*2),o),E=t+(T?.top??p),D=T?.lineIndex??0,O,k,A,j=T?.lineIndex??0;for(let e=j;e<c;e++){let i=D%o===0,a=Math.floor(D/o);if(i&&(w[a]=E-(t+p),A!=null)){if(A<=0)break;A--}let s=this.getLineHeight(e,!1);E>n-s&&E<r&&(O??=a),E+s>S&&(k??=a),A==null&&E>=r&&i&&(A=C),D++,E+=s}if(O==null)if(v)O=0,k=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};k??=O;let M=Math.round(k-x/2),N=Math.max(0,Math.ceil(c/o)-x),P=Math.max(0,Math.min(M,N)),F=P*o,I=M<0?b+M*o:b,L=w[P]??0,R=F===0?0:f+L,z=P+I/o,B=z<w.length?m-w[z]:m-(E-t-p);return{startingLine:F,totalLines:I,bufferBefore:R,bufferAfter:Math.max(0,B)}}};function ze(e){let t;for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===S&&(t=Math.max(t??0,n.getBoundingClientRect().height));return t}export{X as a,xe as i,Me as n,Te as r,Re as t};
2
- //# sourceMappingURL=VirtualizedFile-VSzhLWFM.js.map
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{v as t,y as n}from"./accountData-C4ZvicpJ.js";import{Bo as r,dn as i}from"./utils-DgzD4MA_.js";import{t as a}from"./textarea-5SMJbr7K.js";import{A as o,At as s,C as c,Ct as l,D as u,Dt as d,E as f,Et as p,F as m,I as h,L as g,M as _,Mr as v,N as y,Nt as b,O as x,P as S,Pt as C,R as w,S as T,St as E,T as D,Tt as O,U as k,W as A,_ as j,_r as M,b as N,bt as P,c as F,cr as I,d as L,dt as R,fr as z,ft as B,g as ee,gr as te,h as V,hr as ne,ht as re,ir as H,j as ie,jt as ae,k as U,l as oe,m as se,mt as W,ot as G,p as ce,pt as le,s as ue,st as K,u as de,ur as q,v as fe,vr as pe,w as me,wt as he,x as ge,xt as J,y as _e}from"./scroll-area-BW5o0Izf.js";import{i as ve}from"./toggle-DwBa6pBo.js";import{t as Y}from"./lib-BpnzBIoA.js";var ye=e(n(),1),be=t();function X(e,t,n){return!n&&(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&t.trim().length>0}var Z=r();function xe(e){let t=(0,be.c)(43),{kind:n,rangeLabel:r,text:o,onTextChange:s,onCancel:c,onComment:l,onDelete:u,placeholder:d,submitLabel:f,pending:p,secondaryAction:m}=e,h=d===void 0?`Add a comment…`:d,g=f===void 0?`Comment`:f,_=p===void 0?!1:p,[y,b]=(0,ye.useState)(``),x=n===`draft`&&!s?y:o,S;t[0]===x?S=t[1]:(S=x.trim(),t[0]=x,t[1]=S);let C=S;if(n===`comment`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ve,{className:`mt-0.5 size-3.5 shrink-0 text-primary/70`,"aria-hidden":`true`}),t[2]=e):e=t[2];let n;t[3]===x?n=t[4]:(n=(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap text-[13px] leading-5`,children:x}),t[3]=x,t[4]=n);let r;t[5]===u?r=t[6]:(r=u?(0,Z.jsx)(i,{className:`-my-1 -mr-1 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/comment:opacity-100 focus-visible:opacity-100 max-sm:opacity-100`,variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:u,children:(0,Z.jsx)(v,{className:`size-3`})}):null,t[5]=u,t[6]=r);let a;return t[7]!==n||t[8]!==r?(a=(0,Z.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`group/comment flex min-w-0 items-start gap-2.5 bg-selection px-3 py-2.5 font-sans text-foreground`,contentEditable:!1,onPointerDown:we,children:[e,n,r]}),t[7]=n,t[8]=r,t[9]=a):a=t[9],a}let w=`Comment on lines ${r}`,T;t[10]===s?T=t[11]:(T=e=>(s??b)(e.target.value),t[10]=s,t[11]=T);let E;t[12]!==c||t[13]!==l||t[14]!==_||t[15]!==C?(E=e=>{e.key===`Escape`&&(e.preventDefault(),c()),X(e,C,_)&&(e.preventDefault(),l(C))},t[12]=c,t[13]=l,t[14]=_,t[15]=C,t[16]=E):E=t[16];let D;t[17]!==x||t[18]!==h||t[19]!==w||t[20]!==T||t[21]!==E?(D=(0,Z.jsx)(a,{autoFocus:!0,unstyled:!0,className:`relative inline-flex w-full rounded-md border border-border/50 bg-background/20 font-sans text-foreground transition-colors focus-within:border-border/70 [&_[data-slot=textarea]]:min-h-12 [&_[data-slot=textarea]]:cursor-text [&_[data-slot=textarea]]:px-2.5 [&_[data-slot=textarea]]:py-1.5 [&_[data-slot=textarea]]:font-sans [&_[data-slot=textarea]]:text-xs [&_[data-slot=textarea]]:leading-5 max-sm:[&_[data-slot=textarea]]:min-h-12`,size:`sm`,value:x,placeholder:h,"aria-label":w,onChange:T,onFocus:Se,onKeyDown:E}),t[17]=x,t[18]=h,t[19]=w,t[20]=T,t[21]=E,t[22]=D):D=t[22];let O;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground/70`,children:`⌘/Ctrl Enter to send`}),t[23]=O):O=t[23];let k;t[24]===c?k=t[25]:(k=(0,Z.jsx)(i,{className:`text-muted-foreground hover:text-foreground`,variant:`ghost`,size:`xs`,onClick:c,children:`Cancel`}),t[24]=c,t[25]=k);let A;t[26]!==m||t[27]!==C?(A=m?(0,Z.jsxs)(i,{size:`xs`,variant:`outline`,disabled:!m.allowEmpty&&!C,onClick:()=>m.onAction(C),children:[m.icon,m.label]}):null,t[26]=m,t[27]=C,t[28]=A):A=t[28];let j=_||!C,M;t[29]!==l||t[30]!==C?(M=()=>l(C),t[29]=l,t[30]=C,t[31]=M):M=t[31];let N;t[32]!==g||t[33]!==j||t[34]!==M?(N=(0,Z.jsx)(i,{size:`xs`,disabled:j,onClick:M,children:g}),t[32]=g,t[33]=j,t[34]=M,t[35]=N):N=t[35];let P;t[36]!==k||t[37]!==A||t[38]!==N?(P=(0,Z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1`,children:[O,k,A,N]}),t[36]=k,t[37]=A,t[38]=N,t[39]=P):P=t[39];let F;return t[40]!==P||t[41]!==D?(F=(0,Z.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`px-3 py-2 font-sans text-foreground`,contentEditable:!1,onPointerDown:Ce,children:[D,P]}),t[40]=P,t[41]=D,t[42]=F):F=t[42],F}function Se(e){let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)}function Ce(e){return e.stopPropagation()}function we(e){return e.stopPropagation()}function Te({file:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,lineAnnotations:o,renderGutterUtility:s,getHoveredLine:c}){let l=t?.(e),u=n?.(e),d=r?.(e),f=i?.(e);return(0,Z.jsxs)(Z.Fragment,{children:[l==null?(0,Z.jsxs)(Z.Fragment,{children:[u!=null&&(0,Z.jsx)(`div`,{slot:`header-prefix`,children:u}),d!=null&&(0,Z.jsx)(`div`,{slot:`header-filename-suffix`,children:d}),f!=null&&(0,Z.jsx)(`div`,{slot:`header-metadata`,children:f})]}):(0,Z.jsx)(`div`,{slot:H,children:l}),a!=null&&o?.map((e,t)=>(0,Z.jsx)(`div`,{slot:b(e),children:a(e)},t)),s!=null&&(0,Z.jsx)(`div`,{slot:`gutter-utility-slot`,style:C,children:s(c)})]})}function Q(e,t){return t.cacheKey==null?e.file===t&&e.sourceContents===t.contents:e.cacheKey===t.cacheKey}var Ee=-1,De=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++Ee}`;highlighter;renderCache;computedLang=`text`;lineAnnotations={};lineCache;textDocumentCache=new WeakMap;constructor(e={theme:q},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=x(e.theme??q)?p():void 0)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setLineAnnotations(e){this.lineAnnotations={};for(let t of e){let e=this.lineAnnotations[t.lineNumber]??[];this.lineAnnotations[t.lineNumber]=e,e.push(t)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.textDocumentCache=new WeakMap}syncEditedContentsToFile(){let{renderCache:e,lineCache:t}=this;e?.isDirty!==!0||t==null||!Q(t,e.file)||(e.file.contents=t.lines.join(``))}hasUnkeyedFileContentsChanged(e){let{lineCache:t}=this;return e.cacheKey==null&&t!=null&&t.file===e&&t.sourceContents!==e.contents}invalidateChangedUnkeyedFile(e){this.hasUnkeyedFileContentsChanged(e)&&(this.workerManager?.cleanUpTasks(this),this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap)}clearRenderCache(){this.syncEditedContentsToFile();let e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(e.file.cacheKey)}hydrate(e){let{options:t}=this.getRenderOptions(e),n=$(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength()),r=this.workerManager?.getFileResultCache(e);r!=null&&!l(t,r.options)&&(r=void 0),this.renderCache??={file:e,options:t,highlighted:!n&&!J(e),result:n?void 0:r?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightFileAST(this,e):this.highlighter??(this.computedLang=e.lang??E(e.name),this.initializeHighlighter())}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getFileRenderOptions();let{theme:e=q,tokenizeMaxLineLength:t=1e3}=this.options;return{theme:e,useTokenTransformer:ge(this.options),tokenizeMaxLineLength:t}})(),{renderCache:n}=this;return n?.result==null||!s(e,n.file)||!l(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getOrCreateLineCache(e){this.invalidateChangedUnkeyedFile(e);let{lineCache:t}=this;return(t==null||!Q(t,e))&&(t={cacheKey:e.cacheKey,file:e,sourceContents:e.contents,lines:P(e.contents)}),this.lineCache=t,t.lines}getLineCount(e){let t=this.getOrCreateLineCache(e);return this.textDocumentCache.get(e)?.lineCount??t.length}updateRenderCache(e,t){if(this.renderCache==null)return;let{file:n,result:r}=this.renderCache;if(r==null)return;let i=this.lineCache!=null&&Q(this.lineCache,n)?this.lineCache:void 0;for(let[t,n]of e){if(i!=null&&t<i.lines.length){let e=n.map(e=>e[2]).join(``);i.lines[t]=u(i.lines[t]??``,e)}r.code[t]={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})}}r.baseThemeType=t,this.renderCache.isDirty=!0}applyDocumentChange(e){if(this.renderCache==null)return;let{file:t,result:n}=this.renderCache;if(n!=null){if(n.code.length!==e.lineCount){n.code.length=Math.min(n.code.length,e.lineCount);for(let t=n.code.length;t<e.lineCount;t++)n.code.push({type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:e.getLineText(t)}]}]});this.renderCache.isDirty=!0}this.lineCache={cacheKey:t.cacheKey,file:t,sourceContents:t.contents,lines:P(e.getText())},this.textDocumentCache.set(t,e)}}renderFile(e=this.renderCache?.file,t=I){if(e==null)return;this.invalidateChangedUnkeyedFile(e),this.renderCache?.isDirty===!0&&!s(e,this.renderCache.file)&&(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap);let{options:n,forceHighlight:r}=this.getRenderOptions(e),i=this.getMatchingWorkerResultCache(e,n);i!=null&&!this.hasHighlightedRenderCache(e,n)&&(this.renderCache={file:e,highlighted:!0,renderRange:void 0,...i},r=!1),this.renderCache??={file:e,highlighted:!1,options:n,result:void 0,renderRange:void 0};let a=this.getOrCreateLineCache(e),c=e.contents.length>0,l=!c||J(e)||$(a.length,this.getTokenizeMaxLength()),u=!s(e,this.renderCache.file),d=!o(this.renderCache.renderRange,t);if(this.workerManager?.isWorkingPool()===!0)(l||this.renderCache.result==null||!this.renderCache.highlighted&&(u||d))&&(this.renderCache.file=e,this.renderCache.options=n,this.renderCache.highlighted=!1,(this.renderCache.result==null||u||d||r)&&(this.renderCache.result=this.workerManager.getPlainFileAST(e,t.startingLine,t.totalLines,a)),this.renderCache.renderRange=t),!l&&c&&(!this.renderCache.highlighted||r)&&this.workerManager.highlightFileAST(this,e);else{this.computedLang=e.lang??E(e.name);let t=this.highlighter!=null&&x(n.theme),i=this.highlighter!=null&&U(this.computedLang),a=!l&&i;if(this.highlighter!=null&&t&&(r||l||!this.renderCache.highlighted&&a||this.renderCache.result==null)){let{result:t,options:n}=this.renderFileWithHighlighter(e,this.highlighter,l||!i);this.renderCache={file:e,options:n,highlighted:a,result:t,renderRange:void 0}}(!t||!l&&!i)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(e,t,n,!l)})}return this.renderCache.result==null?void 0:this.processFileResult(this.renderCache.file,t,this.renderCache.result)}async asyncRender(e,t=I){let{result:n}=await this.asyncHighlight(e);return this.processFileResult(e,t,n)}async asyncHighlight(e){let t=$(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??E(e.name);let n=this.highlighter!=null&&he(O(this.options.theme)),r=t||this.highlighter!=null&&U(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(e,this.highlighter,t)}renderFileWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e);return{result:R(e,t,r,{forcePlainText:n}),options:r}}processFileResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let a=this.getLineCount(e),{disableFileHeader:o=!1}=this.options,s=[],c=W(),l=Math.min(t.startingLine+t.totalLines,a),u=0,d=g(t)?m(this.lineAnnotations):void 0;d!=null&&(c.children.push(B(`context`,`annotation`,1)),s.push(f({type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:d.map(e=>b(e))})),u++);for(let r=t.startingLine;r<l;r++){let t=r+1,i=n[r];if(i==null){let n=`FileRenderer.processFileResult: Line doesnt exist`;throw console.error(n,{name:e.name,lineIndex:r,lineNumber:t}),Error(n)}c.children.push(le(`context`,t,`${r}`)),s.push(i),u++;let a=this.lineAnnotations[t];a!=null&&(c.children.push(B(`context`,`annotation`,1)),s.push(f({type:`annotation`,hunkIndex:0,lineIndex:t,annotations:a.map(e=>b(e))})),u++)}return c.properties.style=`grid-row: span ${u}`,{gutterAST:c.children??[],contentAST:s,preAST:this.createPreElement(a),headerAST:o?void 0:this.renderHeader(e),totalLines:a,rowCount:u,themeStyles:r,baseThemeType:i,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderHeader(e){let{headerRenderMode:t=`default`,stickyHeader:n=!1}=this.options;return me({fileOrDiff:e,mode:t,stickyHeader:n})}renderFullHTML(e){return Y(this.renderFullAST(e))}renderFullAST(e,t=[]){return t.push(re({tagName:`code`,children:this.renderCodeAST(e),properties:{"data-code":``}})),{...e.preAST,children:t}}renderCodeAST(e){let t=W();return t.children=e.gutterAST,t.properties.style=`grid-row: span ${e.rowCount}`,[t,D(e.contentAST,e.rowCount)]}renderPartialHTML(e,t=!1){return Y(t?re({tagName:`code`,children:e,properties:{"data-code":``}}):e)}async initializeHighlighter(){return this.highlighter=await d(T(this.computedLang,this.options)),this.highlighter}onHighlightSuccess(e,t,n,r=!0){if(this.renderCache==null)return;let i=!s(e,this.renderCache.file)||!this.renderCache.highlighted||!l(n,this.renderCache.options);this.renderCache={file:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){let n=this.workerManager?.getFileResultCache(e);if(!(n==null||!l(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&s(e,n.file)&&l(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(e){let{disableLineNumbers:t=!1,overflow:n=`scroll`}=this.options;return c({type:`file`,diffIndicators:`none`,disableBackground:!0,disableLineNumbers:t,overflow:n,split:!1,totalLines:e})}};function $(e,t){return e>t}function Oe(e,t){return e.lineNumber===t.lineNumber&&e.metadata===t.metadata}function ke(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:e?.useTokenTransformer,tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}var Ae=[``],je=-1,Me=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++je}`;type=`file`;fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:q},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new De(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new ie,this.interactionManager=new _(`file`,y(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}__getCurrentFile(){return this.file}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(y(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!ae(this.appliedThemeCSS.theme,this.options.theme??q)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{overflow:e=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e===`wrap`,columnVariables:this.shouldApplyColumnVariables(e)?`apply`:`measure`}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e===`scroll`&&this.lineAnnotations.length>0}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.unsafeCSSStyle=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1,this.editor?.cleanUp(e),this.editor=void 0}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:a}=e;if(!this.enabled)throw Error(`File.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`File.hydrate: hydrate can only be called before the instance has rendered or hydrated`);this.hydrateElements(t,n),Ne(this.pre,i,this.options.collapsed)||Pe(this.headerElement,i,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:i,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),F(e,t);for(let t of Array.from(e.shadowRoot?.children??[])){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t,this.appliedPreAttributes=void 0;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}if(`diffsHeader`in t.dataset){this.headerElement=t,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(ke(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e==null?Ae:this.fileRenderer.getOrCreateLineCache(e)}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){let e=this.editor,t=this.fileContainer,n=this.file,r=this.lineAnnotations,i=this.renderRange;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(a=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.file!==n||e.__syncRenderView(a,t,n,r,i)})}attachEditor(e){this.editor?.cleanUp(),this.editor=e,this.interactionManager.setEditorAttached(!0);let t=this.file==null?void 0:e.__prepareFile?.(this.file);return t!==void 0&&t!==this.file?this.renderPreparedFile({file:t,forceRender:!0,preventEmit:!0,renderRange:this.renderRange}):this.syncRenderViewToEditor(),()=>{this.editor=void 0,this.interactionManager.setEditorAttached(!1)}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t){this.fileRenderer.updateRenderCache(e,t)}render(e){if(!this.enabled)throw Error(`File.render: attempting to call render after cleaned up`);let t=this.editor?.__prepareFile?.(e.file)??e.file;return this.renderPreparedFile(t===e.file?e:{...e,file:t})}renderPreparedFile({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:i,deferManagers:a=!1,lineAnnotations:c,renderRange:l}){this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:u=!1,themeType:d=`system`}=this.options,f=u?void 0:l,p=this.renderRange,m=this.hasThemeChanged(),h=c!=null&&(c.length>0||this.lineAnnotations.length>0)?c!==this.lineAnnotations:!1,g=!s(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);if(!u&&!n&&o(f,this.renderRange)&&!g&&!h&&!m)return this.applyCachedThemeState(d);this.renderRange=f,g&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(ke(this.options)),this.syncInteractionOptions(),c!=null&&this.setLineAnnotations(c),this.fileRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:_=!1,disableFileHeader:v=!1}=this.options;if(v&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(d),u){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let n=this.fileRenderer.renderFile(e,ne);n!=null&&this.applyThemeState(t,n.themeStyles,d,n.baseThemeType),n?.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.injectUnsafeCSS()}catch(e){if(_)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}try{let r=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,h,g||m)||!this.applyPartialRender(p,f)){let n=this.fileRenderer.renderFile(e,f);if(n==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,n.themeStyles,d,n.baseThemeType),n.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.applyFullRender(n,r)}this.applyBuffers(r,f),this.injectUnsafeCSS(),this.managersDirty=!0,a||this.flushManagers(),this.renderAnnotations(),this.renderGutterUtility(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(_)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}primeHighlightCache(){let{file:e,workerManager:t}=this;e==null||e.cacheKey==null||t==null||J(e)||this.fileRenderer.getOrCreateLineCache(e).length>(this.options.tokenizeMaxLength??1e5)||t.primeFileHighlightCache(e).catch(()=>void 0)}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.gutterUtilityContent?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${b(r)}`,a=this.annotationCache.get(i);if(a==null||!Oe(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:fe(b(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=j();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=ee(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=se(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??q,s=typeof o==`string`?o:{...o},c=V(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=oe({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:ce(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=L(this.themeCSSStyle.textContent??``,V(e)))}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e),this.code=de({code:this.code});let n=this.fileRenderer.renderCodeAST(e);if(this.code.childElementCount>=2)for(let e=0;e<2;e++){let t=this.code.children[e],r=n[e];t.innerHTML=Y(r.children),t.style.cssText=r.properties.style}else this.code.innerHTML=Y(n);t.contains(this.code)||t.replaceChildren(this.code),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;let{file:n,code:r}=this,i=r==null?void 0:this.getColumns(r);if(n==null||r==null||i==null)return!1;let a=e.startingLine,o=t.startingLine,s=e.totalLines===1/0?1/0:a+e.totalLines,c=t.totalLines===1/0?1/0:o+t.totalLines,l=Math.max(a,o),u=Math.min(s,c);if(u<=l||!this.trimDOMToOverlap(i.gutter,l,u)||!this.trimDOMToOverlap(i.content,l,u))return!1;let{length:d}=i.content.children,f=(e,t)=>{if(!(t<=0))return this.fileRenderer.renderFile(n,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},p=o<l?f(o,l-o):void 0;if(p===void 0&&o<l)return!1;let m=c===1/0?1/0:Math.max(0,c-u),h=c>u?f(u,m):void 0;return h===void 0&&c>u?!1:(this.cleanupErrorWrapper(),p!=null&&(i.gutter.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.gutterAST)),i.content.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.contentAST)),d+=p.rowCount),h!=null&&(i.gutter.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.contentAST)),d+=h.rowCount),this.lastRowCount!==d&&(i.gutter.style.setProperty(`grid-row`,`span ${d}`),i.content.style.setProperty(`grid-row`,`span ${d}`),this.lastRowCount=d),!0)}getColumns(e){let t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(i>a)return!1;for(let t=e.children.length-1;t>=a;--t)e.children[t]?.remove();for(let t=i-1;t>=0;--t)e.children[t]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((e,t)=>e-t),r=new Map;if(n.length===0)return r;let i=0,a=n[i],{children:o}=e;a===0&&(r.set(0,0),i+=1,a=n[i]);for(let e=0;e<o.length;e+=1){let t=o[e];if(!(t instanceof HTMLElement))continue;let s=this.getLineIndexFromDOMNode(t);if(s!=null){for(;a!=null&&s>=a;)r.set(a,e),i+=1,a=n[i];if(i>=n.length)break}}for(let e of n)r.has(e)||r.set(e,o.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){let{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let r=this.cachedHeaderHTML??Y(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;let{renderHeaderPrefix:i,renderHeaderFilenameSuffix:a,renderCustomHeader:o,renderHeaderMetadata:s}=this.options;if(o!=null){let e=o(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,H,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{let e=i?.(n)??void 0,r=a?.(n)??void 0,o=s?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,pe,e),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,te,r),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,M,o),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:w(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):w(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=N;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute(`data-code`)){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n=`scroll`,disableLineNumbers:r=!1}=this.options,i={type:`file`,split:!1,overflow:n,disableLineNumbers:r,diffIndicators:`none`,disableBackground:!0,totalLines:t};_e(i,this.appliedPreAttributes)||(ue(e,i),this.appliedPreAttributes=i)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Ne(e,t,n=!1){return!n&&e==null&&t!=null}function Pe(e,t,n=!1){return e==null&&t!=null&&!n}var Fe=5e3,Ie=-1;function Le(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var Re=class extends Me{virtualizer;metrics;__id=`virtualized-file:${++Ie}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=z,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){!t&&A(this.metrics,e)||(this.metrics=e,this.resetLayoutCache())}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache()}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}hasLineAnnotations(){return this.lineAnnotations.some(e=>e.lineNumber>0)}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!k(t,e),r=Le(t,e);super.setOptions(e),r&&this.resetLayoutCache(!0),n&&(this.forceRenderOverride=!0),n&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache(e=!1,t=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&t&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(e=!0),this.height=0,e;let{overflow:t=`scroll`}=this.options;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return e;let n=this.code.children[1];if(!(n instanceof HTMLElement))return e;let r=h(this.lineAnnotations);if(this.renderRange!=null&&r&&g(this.renderRange)){let t=ze(n)??0;t!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=t,e=!0)}else!r&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,e=!0);for(let t of n.children){if(!(t instanceof HTMLElement))continue;let n=t.dataset.lineIndex;if(n==null)continue;let r=Number(n),i=t.getBoundingClientRect().height,a=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(a=!0),i+=t.nextElementSibling.getBoundingClientRect().height);let o=this.getLineHeight(r,a);i!==o&&(e=!0,i===this.metrics.lineHeight*(a?2:1)?this.cache.heights.delete(r):this.cache.heights.set(r,i))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(e,t,n,r){let i=this.syncLineAnnotations(r),a=this.fileRenderer.hasUnkeyedFileContentsChanged(e),o=n?.resetFileLayoutCache===!0||i||a;n?.metrics!=null&&(this.metrics=n.metrics,o=!0);let{collapsed:s=!1}=this.options;return this.currentCollapsed!==s&&(this.currentCollapsed=s,o=!0),o&&this.resetLayoutCache(),this.file!==e&&(this.layoutDirty=!0),this.file=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e){if(this.file==null||e<1)return;let{disableFileHeader:t=!1,collapsed:n=!1}=this.options,r=this.fileRenderer.getLineCount(this.file)-1,i=G(this.metrics,t);if(n||r<0)return{top:i,height:0};let a=Math.min(Math.max(e-1,0),r),{overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics;if(i+=this.cache.fileAnnotationHeight,o===`scroll`&&!this.hasLineAnnotations())return{top:i+a*s,height:s};let c=this.getLayoutCheckpointBeforeLineIndex(a);i=c?.top??i;for(let e=c?.lineIndex??0;e<a;e++)i+=this.getLineHeight(e,!1);return{top:i,height:this.getLineHeight(a,!1)}}getScrollContainer(){let e=this.getSimpleVirtualizer()?.getRoot();return e instanceof HTMLElement?e:e?.documentElement}getNumericScrollAnchor(e){if(this.file==null||this.renderRange==null)return;let{disableFileHeader:t=!1,collapsed:n=!1,overflow:r=`scroll`}=this.options;if(n||this.renderRange.totalLines<=0)return;let i=this.fileRenderer.getLineCount(this.file)-1;if(i<0)return;let a=G(this.metrics,t),o=Math.min(this.renderRange.startingLine,i),s=Math.min(o+this.renderRange.totalLines-1,i);if(s<o)return;let{fileAnnotationHeight:c}=this.cache;if(r===`scroll`&&!this.hasLineAnnotations()){let{lineHeight:t}=this.metrics,n=a+(o===0?c:this.renderRange.bufferBefore),r=o+Math.max(Math.ceil((e-n)/t),0);return r>s?void 0:{lineNumber:r+1,top:a+c+r*t}}let l=a+(o===0?c:this.renderRange.bufferBefore);for(let t=o;t<=s;t++){if(l>=e)return{lineNumber:t+1,top:l};l+=this.getLineHeight(t)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.file,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(e)}computeApproximateSize(e=!1){let t=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!t)return;let n=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.file==null){this.layoutDirty=!1;return}let{disableFileHeader:r=!1,collapsed:i=!1,overflow:a=`scroll`}=this.options,{lineHeight:o}=this.metrics,s=this.fileRenderer.getLineCount(this.file),c=G(this.metrics,r),l=K(this.metrics);if(this.height+=c,i){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,a===`scroll`&&!this.hasLineAnnotations())this.height+=s*o;else for(let e=0;e<s;e++)this.addLayoutCheckpoint(e,this.height),this.height+=this.getLineHeight(e,!1);if(s>0&&(this.height+=l),this.fileContainer!=null&&t&&!n){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFile.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFile.computeApproximateSize: computed height doesnt match`,{name:this.file.name,elementHeight:e.height,computedHeight:this.height})}this.layoutDirty=!1}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){let r=this.renderRange;if(super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1),n&&r!==void 0&&this.file!==void 0){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(this.file,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}}renderPreparedFile({fileContainer:e,file:t,forceRender:n=!1,lineAnnotations:r,...i}){let a=this.file==null||!s(this.file,t)||this.fileRenderer.hasUnkeyedFileContentsChanged(t),{forceRenderOverride:o,isSetup:c}=this;this.forceRenderOverride=void 0;let l=this.syncLineAnnotations(r);if(l&&this.resetLayoutCache(),this.file=t,e=this.getOrCreateFileContainerNode(e),this.file==null)return console.error(`VirtualizedFile.render: attempting to virtually render when we dont have file`),!1;if(c)this.top??=this.getVirtualizedTop(),a&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!0));else{this.computeApproximateSize();let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFile.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);let u=this.virtualizer.getWindowSpecs(),d=this.top??0,f=this.computeRenderRangeFromWindow(this.file,d,u),p=super.renderPreparedFile({file:this.file,fileContainer:e,renderRange:f,lineAnnotations:r,forceRender:(o??n)||l,...i});return this.isSimpleMode()&&p&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),p}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}addLayoutCheckpoint(e,t){e%Fe===0&&this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFile: invalid checkpoint index`);if(n.lineIndex%t===0)return n}}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,overflow:a=`scroll`}=this.options,{hunkLineCount:o,lineHeight:s}=this.metrics,c=this.fileRenderer.getLineCount(e),l=this.height,u=G(this.metrics,i),d=c>0?K(this.metrics):0,{fileAnnotationHeight:f}=this.cache,p=u+f,m=Math.max(0,l-u-f-d),g=h(this.lineAnnotations),_=t+u,v=f>0&&g&&_<r&&_+f>n;if(t<n-l||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};if(c<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};let y=Math.ceil(Math.max(r-n,0)/s),b=Math.ceil(y/o)*o+o*2,x=b/o,S=(n+r)/2;if(a===`scroll`&&!this.hasLineAnnotations()){let e=t+p,i=e+m;if(!v&&!(e<r&&i>n))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};let a=Math.floor(v&&S<t+p?0:(S-(t+p))/s),h=Math.floor(a/o)-Math.floor(x/2),g=Math.ceil(c/o),_=Math.max(0,Math.min(h,g))*o,y=h<0?b+h*o:b,C=_===0?0:f+_*s,w=Math.min(y,c-_);return{startingLine:_,totalLines:y,bufferBefore:C,bufferAfter:Math.max(0,(c-_-w)*s)}}let C=x,w=[],T=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-b*s*2),o),E=t+(T?.top??p),D=T?.lineIndex??0,O,k,A,j=T?.lineIndex??0;for(let e=j;e<c;e++){let i=D%o===0,a=Math.floor(D/o);if(i&&(w[a]=E-(t+p),A!=null)){if(A<=0)break;A--}let s=this.getLineHeight(e,!1);E>n-s&&E<r&&(O??=a),E+s>S&&(k??=a),A==null&&E>=r&&i&&(A=C),D++,E+=s}if(O==null)if(v)O=0,k=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};k??=O;let M=Math.round(k-x/2),N=Math.max(0,Math.ceil(c/o)-x),P=Math.max(0,Math.min(M,N)),F=P*o,I=M<0?b+M*o:b,L=w[P]??0,R=F===0?0:f+L,z=P+I/o,B=z<w.length?m-w[z]:m-(E-t-p);return{startingLine:F,totalLines:I,bufferBefore:R,bufferAfter:Math.max(0,B)}}};function ze(e){let t;for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===S&&(t=Math.max(t??0,n.getBoundingClientRect().height));return t}export{X as a,xe as i,Me as n,Te as r,Re as t};
2
+ //# sourceMappingURL=VirtualizedFile-Bz5fGbNr.js.map
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/xlsxDocument-DwhEMpfP.js","assets/rolldown-runtime-DAXXjFlN.js","assets/main-Bn8Ylf8R.js","assets/index-DraeEDbf.js","assets/index-DZprGaeP.css","assets/accountData-C4ZvicpJ.js","assets/utils-DgzD4MA_.js","assets/session-BaysTZDD.js","assets/queries-D1AwaR_5.js","assets/textarea-BB3euU4O.js","assets/clientPersistenceStorage-BlYjZvCd.js","assets/designOpenFileContext-DCJpUleA.js","assets/empty-tcpR9LH8.js","assets/input-BRLXkmUH.js","assets/browserRecording-BmG6q-H4.js","assets/RightPanelResizeHandle-DBci-Ee2.js","assets/browserHistoryStore-CIr_OQCq.js","assets/entities-Da-AvwsX.js","assets/env-71Gq9H0m.js","assets/ArrowRight-CgvCTAzu.js","assets/ArrowSquareOut-C1CwJQ7R.js","assets/scroll-area-j6QV0udq.js","assets/lib-BpnzBIoA.js","assets/ArrowsClockwise-CBwAQTtQ.js","assets/ChatMarkdown-BhfpBJaq.js","assets/assetUrls-C2vkiSgX.js","assets/lib-CCiVGdun.js","assets/designCanvas.logic-DtK3Ht6X.js","assets/designCanvas-CfWhq9nr.css","assets/CaretLeft-Bk0n02vc.js","assets/toggle-DwBa6pBo.js","assets/PullRequestReactions-BSI_Qt4L.js","assets/popover-DTprsoPQ.js","assets/composerMentionDrag-DTGN7WcV.js","assets/combobox-uXzVxkLc.js","assets/useWorkspaceMutationRefresh-DLI4brDf.js","assets/DiffWorkerPoolProvider-Hp3trMBG.js","assets/toggle-group-BU7-0DcW.js","assets/projectFilesQueryState-CD_JXBj5.js","assets/spinner-DHhZaoFg.js","assets/zipGuard-BHHl8sLU.js","assets/main-YscGsfgO.css"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./index-DraeEDbf.js";import{y as n}from"./accountData-C4ZvicpJ.js";import{Bo as r,t as i}from"./utils-DgzD4MA_.js";import{t as a}from"./spinner-DHhZaoFg.js";import{t as o}from"./documentBytes-CS3KpytE.js";var s=e(n(),1),c=r();function l(e){let[n,r]=(0,s.useState)({status:`loading`}),[l,u]=(0,s.useState)(0);if((0,s.useEffect)(()=>{let n=new AbortController;return(async()=>{r({status:`loading`}),u(0);let i=await o(e.url,n.signal);if(n.signal.aborted)return;let{readWorkbook:a}=await t(async()=>{let{readWorkbook:e}=await import(`./xlsxDocument-DwhEMpfP.js`);return{readWorkbook:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41])),s=await a(i);if(!n.signal.aborted){if(s.length===0)throw Error(`This workbook has no readable sheets.`);r({status:`ready`,sheets:s})}})().catch(e=>{n.signal.aborted||r({status:`failed`,message:e instanceof Error?e.message:`This workbook could not be opened.`})}),()=>n.abort()},[e.url]),n.status===`failed`)return(0,c.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:n.message});if(n.status===`loading`)return(0,c.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,c.jsx)(a,{className:`size-5`})});let d=n.sheets[l]??n.sheets[0],f=d.rows.map((e,t)=>({key:`${d.name}!${t+1}`,cells:e.map((e,n)=>({key:`${d.name}!${n+1}:${t+1}`,value:e}))}));return(0,c.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[n.sheets.length>1?(0,c.jsx)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto border-b border-border/60 px-2 py-1.5`,children:n.sheets.map((e,t)=>(0,c.jsx)(`button`,{className:i(`shrink-0 rounded px-2 py-1 text-xs`,t===l?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),onClick:()=>u(t),type:`button`,children:e.name},e.name))}):null,(0,c.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-background`,children:(0,c.jsx)(`table`,{className:`w-max border-collapse text-xs text-foreground`,children:(0,c.jsx)(`tbody`,{children:f.map(e=>(0,c.jsx)(`tr`,{children:e.cells.map(e=>(0,c.jsx)(`td`,{className:`border border-border/60 px-2 py-1 whitespace-nowrap`,children:e.value},e.key))},e.key))})})}),d.truncated?(0,c.jsx)(`p`,{className:`shrink-0 border-t border-warning/20 bg-warning-surface px-3 py-1.5 text-[11px] text-warning-foreground`,children:`This sheet is larger than the preview shows.`}):null]})}export{l as XlsxPreview,l as default};
3
- //# sourceMappingURL=XlsxPreview-BnnrdNes.js.map
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/xlsxDocument-BMNJtufK.js","assets/rolldown-runtime-DAXXjFlN.js","assets/main-Ck7oK5At.js","assets/index-DnoL7z0M.js","assets/index-DZprGaeP.css","assets/accountData-C4ZvicpJ.js","assets/utils-DgzD4MA_.js","assets/session-D3Szkrpk.js","assets/queries-DRotn4pk.js","assets/textarea-5SMJbr7K.js","assets/clientPersistenceStorage-BlYjZvCd.js","assets/designOpenFileContext-CCL9VKvQ.js","assets/empty-CLS3rXBc.js","assets/input-BbliVf4z.js","assets/browserRecording-DpmNgRt_.js","assets/RightPanelResizeHandle-DBci-Ee2.js","assets/browserHistoryStore-DLbnuO9R.js","assets/entities-DPi_gbtI.js","assets/env-71Gq9H0m.js","assets/ArrowRight-CgvCTAzu.js","assets/ArrowSquareOut-C1CwJQ7R.js","assets/scroll-area-BW5o0Izf.js","assets/lib-BpnzBIoA.js","assets/ArrowsClockwise-CBwAQTtQ.js","assets/ChatMarkdown-6kh9qKYW.js","assets/assetUrls-CbeTQh3H.js","assets/lib-CCiVGdun.js","assets/designCanvas.logic-BaQE_ItM.js","assets/designCanvas-CfWhq9nr.css","assets/CaretLeft-Bk0n02vc.js","assets/toggle-DwBa6pBo.js","assets/PullRequestReactions-DVg6Hz1F.js","assets/popover-CFDsW-_z.js","assets/composerMentionDrag-1fGsNlV_.js","assets/combobox-CByZwSML.js","assets/useWorkspaceMutationRefresh-DLI4brDf.js","assets/DiffWorkerPoolProvider-BU7l1oGv.js","assets/toggle-group-BU7-0DcW.js","assets/projectFilesQueryState-CmtzaSrb.js","assets/spinner-DHhZaoFg.js","assets/zipGuard-BHHl8sLU.js","assets/main-YscGsfgO.css"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./index-DnoL7z0M.js";import{y as n}from"./accountData-C4ZvicpJ.js";import{Bo as r,t as i}from"./utils-DgzD4MA_.js";import{t as a}from"./spinner-DHhZaoFg.js";import{t as o}from"./documentBytes-CS3KpytE.js";var s=e(n(),1),c=r();function l(e){let[n,r]=(0,s.useState)({status:`loading`}),[l,u]=(0,s.useState)(0);if((0,s.useEffect)(()=>{let n=new AbortController;return(async()=>{r({status:`loading`}),u(0);let i=await o(e.url,n.signal);if(n.signal.aborted)return;let{readWorkbook:a}=await t(async()=>{let{readWorkbook:e}=await import(`./xlsxDocument-BMNJtufK.js`);return{readWorkbook:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41])),s=await a(i);if(!n.signal.aborted){if(s.length===0)throw Error(`This workbook has no readable sheets.`);r({status:`ready`,sheets:s})}})().catch(e=>{n.signal.aborted||r({status:`failed`,message:e instanceof Error?e.message:`This workbook could not be opened.`})}),()=>n.abort()},[e.url]),n.status===`failed`)return(0,c.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:n.message});if(n.status===`loading`)return(0,c.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,c.jsx)(a,{className:`size-5`})});let d=n.sheets[l]??n.sheets[0],f=d.rows.map((e,t)=>({key:`${d.name}!${t+1}`,cells:e.map((e,n)=>({key:`${d.name}!${n+1}:${t+1}`,value:e}))}));return(0,c.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[n.sheets.length>1?(0,c.jsx)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto border-b border-border/60 px-2 py-1.5`,children:n.sheets.map((e,t)=>(0,c.jsx)(`button`,{className:i(`shrink-0 rounded px-2 py-1 text-xs`,t===l?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/50`),onClick:()=>u(t),type:`button`,children:e.name},e.name))}):null,(0,c.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-background`,children:(0,c.jsx)(`table`,{className:`w-max border-collapse text-xs text-foreground`,children:(0,c.jsx)(`tbody`,{children:f.map(e=>(0,c.jsx)(`tr`,{children:e.cells.map(e=>(0,c.jsx)(`td`,{className:`border border-border/60 px-2 py-1 whitespace-nowrap`,children:e.value},e.key))},e.key))})})}),d.truncated?(0,c.jsx)(`p`,{className:`shrink-0 border-t border-warning/20 bg-warning-surface px-3 py-1.5 text-[11px] text-warning-foreground`,children:`This sheet is larger than the preview shows.`}):null]})}export{l as XlsxPreview,l as default};
3
+ //# sourceMappingURL=XlsxPreview-8ACeuCsx.js.map
@@ -1,2 +1,2 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{Fa as t,Ga as n,M as r,Va as i,ao as a,b as o,oo as s,to as c,v as l,xo as u,y as d}from"./accountData-C4ZvicpJ.js";import{No as f}from"./utils-DgzD4MA_.js";import{En as p,Ht as m,On as h,Rt as g,Sn as _,_n as v,bn as y,hn as b,i as x,mn as S,n as C,r as w,yn as T}from"./session-BaysTZDD.js";var E=l(),D=30*6e4,O=5*6e4,k=60*6e4,A=class extends a()(`InvalidAssetCollectionKeyError`,{key:c,cause:n()}){get message(){return`Invalid asset collection atom key: ${JSON.stringify(this.key)}.`}},j=u(s([t,i(r)]));function M(e){try{return j(JSON.parse(e))}catch(t){throw new A({key:e,cause:t})}}function N(e,t){try{return f(e,t)}catch{return null}}function P(e){let t=g(e,{label:`environment-data:assets:create-url`,tag:o.assetsCreateUrl,staleTimeMs:O,idleTtlMs:k,refreshIntervalMs:D}),n=v(e=>{let[n,r]=M(e);return T(e=>r.map(r=>e(t({environmentId:n,input:{resource:r}})))).pipe(y(k),_(`environment-data:assets:create-urls:${e}`))});return{createUrl:t,createUrls:e=>n(JSON.stringify([e.environmentId,e.resources]))}}var F=P(x),I=e(d(),1);function L(e,t){let n=(0,E.c)(7),r=(0,I.useContext)(b),i=typeof t==`string`?t:t?.label,a=typeof t==`string`?!0:t?.reportFailure??!0,o=typeof t==`string`?!0:t?.reportDefect??!0,s=typeof t==`string`?!1:t?.refresh??!1,c;return n[0]!==i||n[1]!==e||n[2]!==s||n[3]!==r||n[4]!==o||n[5]!==a?(c=t=>{let n=e(t);return m(r,n,{label:i??n.label?.[0]??`atom query`,reportFailure:a,reportDefect:o,refresh:s})},n[0]=i,n[1]=e,n[2]=s,n[3]=r,n[4]=o,n[5]=a,n[6]=c):c=n[6],c}var R=T(p()).pipe(_(`web-asset-url:idle`));function z(e,t){let n=(0,E.c)(12),r=w(e),i;n[0]!==e||n[1]!==t?(i=e===null?R:F.createUrl({environmentId:e,input:{resource:t}}),n[0]=e,n[1]=t,n[2]=i):i=n[2];let a=S(i);if(a._tag===`Failure`){let e;return n[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={_tag:`Failure`},n[3]=e):e=n[3],e}if(r._tag===`None`||a._tag!==`Success`){let e;return n[4]===Symbol.for(`react.memo_cache_sentinel`)?(e={_tag:`Loading`},n[4]=e):e=n[4],e}let o;n[5]!==r.value.httpBaseUrl||n[6]!==a.value.relativeUrl?(o=N(r.value.httpBaseUrl,a.value.relativeUrl),n[5]=r.value.httpBaseUrl,n[6]=a.value.relativeUrl,n[7]=o):o=n[7];let s=o,c;return n[8]!==a.value.expiresAt||n[9]!==a.value.sourcePath||n[10]!==s?(c=s===null?{_tag:`Failure`}:{_tag:`Success`,url:s,expiresAt:a.value.expiresAt,...a.value.sourcePath===void 0?{}:{sourcePath:a.value.sourcePath}},n[8]=a.value.expiresAt,n[9]=a.value.sourcePath,n[10]=s,n[11]=c):c=n[11],c}function B(e,t){let n=(0,E.c)(5),r;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={reportFailure:!1,refresh:!0},n[0]=r):r=n[0];let i=L(F.createUrl,r),a;return n[1]!==i||n[2]!==e||n[3]!==t?(a=async()=>{let n=await i({environmentId:e,input:{resource:t}}),r=C(e);return n._tag===`Failure`||r===null?null:N(r.httpBaseUrl,n.value.relativeUrl)},n[1]=i,n[2]=e,n[3]=t,n[4]=a):a=n[4],a}function V(e){let t=(0,E.c)(4),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={reportFailure:!1,refresh:!0},t[0]=n):n=t[0];let r=L(F.createUrl,n),i;return t[1]!==r||t[2]!==e?(i=async t=>{let n=await r({environmentId:e,input:{resource:t}}),i=C(e);if(n._tag===`Failure`||i===null)return null;let a=N(i.httpBaseUrl,n.value.relativeUrl);if(a===null)return null;let o=await fetch(a);return o.ok?o.blob():null},t[1]=r,t[2]=e,t[3]=i):i=t[3],i}function H(e,t){let n=(0,E.c)(8),r=w(e),i;n[0]!==e||n[1]!==t?(i=F.createUrls({environmentId:e,resources:t}),n[0]=e,n[1]=t,n[2]=i):i=n[2];let a=S(i),o;return n[3]!==r._tag||n[4]!==r.value||n[5]!==t||n[6]!==a?(o=r._tag===`None`?t.map(U):a.map(e=>h(e)?N(r.value.httpBaseUrl,e.value.relativeUrl):null),n[3]=r._tag,n[4]=r.value,n[5]=t,n[6]=a,n[7]=o):o=n[7],o}function U(){return null}export{L as a,H as i,B as n,F as o,z as r,N as s,V as t};
2
- //# sourceMappingURL=assetUrls-C2vkiSgX.js.map
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{Fa as t,Ga as n,M as r,Va as i,ao as a,b as o,oo as s,to as c,v as l,xo as u,y as d}from"./accountData-C4ZvicpJ.js";import{No as f}from"./utils-DgzD4MA_.js";import{En as p,Ht as m,On as h,Rt as g,Sn as _,_n as v,bn as y,hn as b,i as x,mn as S,n as C,r as w,yn as T}from"./session-D3Szkrpk.js";var E=l(),D=30*6e4,O=5*6e4,k=60*6e4,A=class extends a()(`InvalidAssetCollectionKeyError`,{key:c,cause:n()}){get message(){return`Invalid asset collection atom key: ${JSON.stringify(this.key)}.`}},j=u(s([t,i(r)]));function M(e){try{return j(JSON.parse(e))}catch(t){throw new A({key:e,cause:t})}}function N(e,t){try{return f(e,t)}catch{return null}}function P(e){let t=g(e,{label:`environment-data:assets:create-url`,tag:o.assetsCreateUrl,staleTimeMs:O,idleTtlMs:k,refreshIntervalMs:D}),n=v(e=>{let[n,r]=M(e);return T(e=>r.map(r=>e(t({environmentId:n,input:{resource:r}})))).pipe(y(k),_(`environment-data:assets:create-urls:${e}`))});return{createUrl:t,createUrls:e=>n(JSON.stringify([e.environmentId,e.resources]))}}var F=P(x),I=e(d(),1);function L(e,t){let n=(0,E.c)(7),r=(0,I.useContext)(b),i=typeof t==`string`?t:t?.label,a=typeof t==`string`?!0:t?.reportFailure??!0,o=typeof t==`string`?!0:t?.reportDefect??!0,s=typeof t==`string`?!1:t?.refresh??!1,c;return n[0]!==i||n[1]!==e||n[2]!==s||n[3]!==r||n[4]!==o||n[5]!==a?(c=t=>{let n=e(t);return m(r,n,{label:i??n.label?.[0]??`atom query`,reportFailure:a,reportDefect:o,refresh:s})},n[0]=i,n[1]=e,n[2]=s,n[3]=r,n[4]=o,n[5]=a,n[6]=c):c=n[6],c}var R=T(p()).pipe(_(`web-asset-url:idle`));function z(e,t){let n=(0,E.c)(12),r=w(e),i;n[0]!==e||n[1]!==t?(i=e===null?R:F.createUrl({environmentId:e,input:{resource:t}}),n[0]=e,n[1]=t,n[2]=i):i=n[2];let a=S(i);if(a._tag===`Failure`){let e;return n[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={_tag:`Failure`},n[3]=e):e=n[3],e}if(r._tag===`None`||a._tag!==`Success`){let e;return n[4]===Symbol.for(`react.memo_cache_sentinel`)?(e={_tag:`Loading`},n[4]=e):e=n[4],e}let o;n[5]!==r.value.httpBaseUrl||n[6]!==a.value.relativeUrl?(o=N(r.value.httpBaseUrl,a.value.relativeUrl),n[5]=r.value.httpBaseUrl,n[6]=a.value.relativeUrl,n[7]=o):o=n[7];let s=o,c;return n[8]!==a.value.expiresAt||n[9]!==a.value.sourcePath||n[10]!==s?(c=s===null?{_tag:`Failure`}:{_tag:`Success`,url:s,expiresAt:a.value.expiresAt,...a.value.sourcePath===void 0?{}:{sourcePath:a.value.sourcePath}},n[8]=a.value.expiresAt,n[9]=a.value.sourcePath,n[10]=s,n[11]=c):c=n[11],c}function B(e,t){let n=(0,E.c)(5),r;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={reportFailure:!1,refresh:!0},n[0]=r):r=n[0];let i=L(F.createUrl,r),a;return n[1]!==i||n[2]!==e||n[3]!==t?(a=async()=>{let n=await i({environmentId:e,input:{resource:t}}),r=C(e);return n._tag===`Failure`||r===null?null:N(r.httpBaseUrl,n.value.relativeUrl)},n[1]=i,n[2]=e,n[3]=t,n[4]=a):a=n[4],a}function V(e){let t=(0,E.c)(4),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={reportFailure:!1,refresh:!0},t[0]=n):n=t[0];let r=L(F.createUrl,n),i;return t[1]!==r||t[2]!==e?(i=async t=>{let n=await r({environmentId:e,input:{resource:t}}),i=C(e);if(n._tag===`Failure`||i===null)return null;let a=N(i.httpBaseUrl,n.value.relativeUrl);if(a===null)return null;let o=await fetch(a);return o.ok?o.blob():null},t[1]=r,t[2]=e,t[3]=i):i=t[3],i}function H(e,t){let n=(0,E.c)(8),r=w(e),i;n[0]!==e||n[1]!==t?(i=F.createUrls({environmentId:e,resources:t}),n[0]=e,n[1]=t,n[2]=i):i=n[2];let a=S(i),o;return n[3]!==r._tag||n[4]!==r.value||n[5]!==t||n[6]!==a?(o=r._tag===`None`?t.map(U):a.map(e=>h(e)?N(r.value.httpBaseUrl,e.value.relativeUrl):null),n[3]=r._tag,n[4]=r.value,n[5]=t,n[6]=a,n[7]=o):o=n[7],o}function U(){return null}export{L as a,H as i,B as n,F as o,z as r,N as s,V as t};
2
+ //# sourceMappingURL=assetUrls-CbeTQh3H.js.map
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{$a as t,Do as n,Ga as r,Xa as i,ao as a,b as o,i as s,jo as c,to as l,v as u,y as d}from"./accountData-C4ZvicpJ.js";import{Dt as ee,dt as te,ft as ne,go as f,jt as re,lt as ie,mt as ae,pt as oe,wo as se}from"./utils-DgzD4MA_.js";import{Ft as p,Lt as m,Rt as ce,Sn as h,_n as le,i as ue,mn as g,n as _,p as v,vn as y,yn as b,zt as x}from"./session-BaysTZDD.js";var S=e(d(),1),de=new Map([[`bold`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,187a113.4,113.4,0,0,1-20.39-35h40.82a116.94,116.94,0,0,1-10,20.77A108.61,108.61,0,0,1,128,207Zm-26.49-59a135.42,135.42,0,0,1,0-40h53a135.42,135.42,0,0,1,0,40ZM44,128a83.49,83.49,0,0,1,2.43-20H77.25a160.63,160.63,0,0,0,0,40H46.43A83.49,83.49,0,0,1,44,128Zm84-79a113.4,113.4,0,0,1,20.39,35H107.59a116.94,116.94,0,0,1,10-20.77A108.61,108.61,0,0,1,128,49Zm50.73,59h30.82a83.52,83.52,0,0,1,0,40H178.75a160.63,160.63,0,0,0,0-40Zm20.77-24H173.71a140.82,140.82,0,0,0-15.5-34.36A84.51,84.51,0,0,1,199.52,84ZM97.79,49.64A140.82,140.82,0,0,0,82.29,84H56.48A84.51,84.51,0,0,1,97.79,49.64ZM56.48,172H82.29a140.82,140.82,0,0,0,15.5,34.36A84.51,84.51,0,0,1,56.48,172Zm101.73,34.36A140.82,140.82,0,0,0,173.71,172h25.81A84.51,84.51,0,0,1,158.21,206.36Z`}))],[`duotone`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),S.createElement(`path`,{d:`M128,24h0A104,104,0,1,0,232,128,104.12,104.12,0,0,0,128,24Zm88,104a87.61,87.61,0,0,1-3.33,24H174.16a157.44,157.44,0,0,0,0-48h38.51A87.61,87.61,0,0,1,216,128ZM102,168H154a115.11,115.11,0,0,1-26,45A115.27,115.27,0,0,1,102,168Zm-3.9-16a140.84,140.84,0,0,1,0-48h59.88a140.84,140.84,0,0,1,0,48ZM40,128a87.61,87.61,0,0,1,3.33-24H81.84a157.44,157.44,0,0,0,0,48H43.33A87.61,87.61,0,0,1,40,128ZM154,88H102a115.11,115.11,0,0,1,26-45A115.27,115.27,0,0,1,154,88Zm52.33,0H170.71a135.28,135.28,0,0,0-22.3-45.6A88.29,88.29,0,0,1,206.37,88ZM107.59,42.4A135.28,135.28,0,0,0,85.29,88H49.63A88.29,88.29,0,0,1,107.59,42.4ZM49.63,168H85.29a135.28,135.28,0,0,0,22.3,45.6A88.29,88.29,0,0,1,49.63,168Zm98.78,45.6a135.28,135.28,0,0,0,22.3-45.6h35.66A88.29,88.29,0,0,1,148.41,213.6Z`}))],[`fill`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M128,24h0A104,104,0,1,0,232,128,104.12,104.12,0,0,0,128,24Zm78.36,64H170.71a135.28,135.28,0,0,0-22.3-45.6A88.29,88.29,0,0,1,206.37,88ZM216,128a87.61,87.61,0,0,1-3.33,24H174.16a157.44,157.44,0,0,0,0-48h38.51A87.61,87.61,0,0,1,216,128ZM128,43a115.27,115.27,0,0,1,26,45H102A115.11,115.11,0,0,1,128,43ZM102,168H154a115.11,115.11,0,0,1-26,45A115.27,115.27,0,0,1,102,168Zm-3.9-16a140.84,140.84,0,0,1,0-48h59.88a140.84,140.84,0,0,1,0,48Zm50.35,61.6a135.28,135.28,0,0,0,22.3-45.6h35.66A88.29,88.29,0,0,1,148.41,213.6Z`}))],[`light`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm81.57,64H169.19a132.58,132.58,0,0,0-25.73-50.67A90.29,90.29,0,0,1,209.57,90ZM218,128a89.7,89.7,0,0,1-3.83,26H171.81a155.43,155.43,0,0,0,0-52h42.36A89.7,89.7,0,0,1,218,128Zm-90,87.83a110,110,0,0,1-15.19-19.45A124.24,124.24,0,0,1,99.35,166h57.3a124.24,124.24,0,0,1-13.46,30.38A110,110,0,0,1,128,215.83ZM96.45,154a139.18,139.18,0,0,1,0-52h63.1a139.18,139.18,0,0,1,0,52ZM38,128a89.7,89.7,0,0,1,3.83-26H84.19a155.43,155.43,0,0,0,0,52H41.83A89.7,89.7,0,0,1,38,128Zm90-87.83a110,110,0,0,1,15.19,19.45A124.24,124.24,0,0,1,156.65,90H99.35a124.24,124.24,0,0,1,13.46-30.38A110,110,0,0,1,128,40.17Zm-15.46-.84A132.58,132.58,0,0,0,86.81,90H46.43A90.29,90.29,0,0,1,112.54,39.33ZM46.43,166H86.81a132.58,132.58,0,0,0,25.73,50.67A90.29,90.29,0,0,1,46.43,166Zm97,50.67A132.58,132.58,0,0,0,169.19,166h40.38A90.29,90.29,0,0,1,143.46,216.67Z`}))],[`regular`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M128,24h0A104,104,0,1,0,232,128,104.12,104.12,0,0,0,128,24Zm88,104a87.61,87.61,0,0,1-3.33,24H174.16a157.44,157.44,0,0,0,0-48h38.51A87.61,87.61,0,0,1,216,128ZM102,168H154a115.11,115.11,0,0,1-26,45A115.27,115.27,0,0,1,102,168Zm-3.9-16a140.84,140.84,0,0,1,0-48h59.88a140.84,140.84,0,0,1,0,48ZM40,128a87.61,87.61,0,0,1,3.33-24H81.84a157.44,157.44,0,0,0,0,48H43.33A87.61,87.61,0,0,1,40,128ZM154,88H102a115.11,115.11,0,0,1,26-45A115.27,115.27,0,0,1,154,88Zm52.33,0H170.71a135.28,135.28,0,0,0-22.3-45.6A88.29,88.29,0,0,1,206.37,88ZM107.59,42.4A135.28,135.28,0,0,0,85.29,88H49.63A88.29,88.29,0,0,1,107.59,42.4ZM49.63,168H85.29a135.28,135.28,0,0,0,22.3,45.6A88.29,88.29,0,0,1,49.63,168Zm98.78,45.6a135.28,135.28,0,0,0,22.3-45.6h35.66A88.29,88.29,0,0,1,148.41,213.6Z`}))],[`thin`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M128,28h0A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,190.61c-6.33-6.09-23-24.41-31.27-54.61h62.54C151,194.2,134.33,212.52,128,218.61ZM94.82,156a140.42,140.42,0,0,1,0-56h66.36a140.42,140.42,0,0,1,0,56ZM128,37.39c6.33,6.09,23,24.41,31.27,54.61H96.73C105,61.8,121.67,43.48,128,37.39ZM169.41,100h46.23a92.09,92.09,0,0,1,0,56H169.41a152.65,152.65,0,0,0,0-56Zm43.25-8h-45a129.39,129.39,0,0,0-29.19-55.4A92.25,92.25,0,0,1,212.66,92ZM117.54,36.6A129.39,129.39,0,0,0,88.35,92h-45A92.25,92.25,0,0,1,117.54,36.6ZM40.36,100H86.59a152.65,152.65,0,0,0,0,56H40.36a92.09,92.09,0,0,1,0-56Zm3,64h45a129.39,129.39,0,0,0,29.19,55.4A92.25,92.25,0,0,1,43.34,164Zm95.12,55.4A129.39,129.39,0,0,0,167.65,164h45A92.25,92.25,0,0,1,138.46,219.4Z`}))]]),fe=Object.defineProperty,pe=Object.defineProperties,me=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,_e=(e,t,n)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ve=(e,t)=>{for(var n in t||={})he.call(t,n)&&_e(e,n,t[n]);if(C)for(var n of C(t))ge.call(t,n)&&_e(e,n,t[n]);return e},ye=(e,t)=>pe(e,me(t)),w=(0,S.forwardRef)((e,t)=>S.createElement(se,ye(ve({ref:t},e),{weights:de})));w.displayName=`Globe`;var T=u(),be=Object.freeze({ERR_NAME_NOT_RESOLVED:`DNS address could not be found`,ERR_NAME_RESOLUTION_FAILED:`DNS address could not be found`,ERR_CONNECTION_REFUSED:`Connection refused`,ERR_CONNECTION_RESET:`Connection was reset`,ERR_CONNECTION_CLOSED:`Connection was closed`,ERR_CONNECTION_TIMED_OUT:`Connection timed out`,ERR_INTERNET_DISCONNECTED:`No internet connection`,ERR_TIMED_OUT:`Connection timed out`,ERR_CERT_AUTHORITY_INVALID:`Certificate authority is not trusted`,ERR_CERT_COMMON_NAME_INVALID:`Certificate hostname mismatch`,ERR_CERT_DATE_INVALID:`Certificate is expired or not yet valid`,ERR_TOO_MANY_REDIRECTS:`Too many redirects`}),E=Object.freeze({snapshot:null,sessions:{},suppressedTabIds:new Set,activeTabId:null,desktopOverlay:null,desktopByTabId:{},recentlySeenUrls:[],serverEpoch:null,serverRevision:0}),xe=b(E).pipe(h(`preview:empty-thread`)),D=le(e=>b(E).pipe(y,h(`preview:thread:${e}`))),O=b({keys:new Set}).pipe(y,h(`preview:active-thread-keys`)),Se=b(e=>{let t={};for(let n of e(O).keys){let r=e(D(n));Object.keys(r.sessions).length>0&&(t[n]=r)}return t}).pipe(h(`preview:active-sessions`)),k=new Set;function A(e,t){let n=Object.keys(t.sessions).length>0;v.update(O,t=>{if(t.keys.has(e)===n)return t;let r=new Set(t.keys);return n?r.add(e):r.delete(e),{keys:r}})}function j(e,t){let n=f(e),r=D(n),i=v.get(r);v.modify(r,e=>(i=t(e),[i!==e,i]))&&(k.add(n),A(n,i))}var M=(e,t)=>[t,...e.filter(e=>e!==t)].slice(0,10),N=(e,t)=>t.navStatus._tag===`Idle`?e:M(e,t.navStatus.url),P=e=>Object.values(e).toSorted((e,t)=>e.updatedAt.localeCompare(t.updatedAt)).at(-1)??null,F=(e,t)=>{if(!e.sessions[t])return e;let{[t]:n,...r}=e.sessions,{[t]:i,...a}=e.desktopByTabId,o=P(r),s=e.activeTabId===t?o?.tabId??null:e.activeTabId,c=s?r[s]??o:o;return{...e,sessions:r,desktopByTabId:a,activeTabId:c?.tabId??null,snapshot:c,desktopOverlay:c?a[c.tabId]??null:null}};function Ce(e){let t=(0,T.c)(2),n;return t[0]===e?n=t[1]:(n=e?D(f(e)):xe,t[0]=e,t[1]=n),g(n)}function we(){return g(Se)}function Te(e){return v.get(D(f(e)))}function Ee(e,t){j(e,e=>{if(e.serverEpoch!==null&&t.serverEpoch!==e.serverEpoch||t.revision<e.serverRevision)return e;let n=(()=>{switch(t.type){case`opened`:case`navigated`:case`resized`:{let n=t.snapshot;if(e.suppressedTabIds.has(n.tabId))return e;let r=n.navStatus._tag===`Idle`?e.recentlySeenUrls:M(e.recentlySeenUrls,n.navStatus.url),i={...e.sessions,[n.tabId]:n},a=t.type===`opened`?n.tabId:e.activeTabId,o=i[a??n.tabId]??n;return{...e,sessions:i,activeTabId:a??n.tabId,snapshot:o,desktopOverlay:e.desktopByTabId[o.tabId]??null,recentlySeenUrls:r}}case`failed`:{let n=e.sessions[t.tabId];if(!n)return e;let r={...n,navStatus:{_tag:`LoadFailed`,url:t.url,title:t.title,code:t.code,description:t.description},updatedAt:t.createdAt},i={...e.sessions,[t.tabId]:r};return{...e,sessions:i,snapshot:e.activeTabId===t.tabId?r:e.snapshot}}case`closed`:{let n=F(e,t.tabId);if(!n.suppressedTabIds.has(t.tabId))return n;let r=new Set(n.suppressedTabIds);return r.delete(t.tabId),{...n,suppressedTabIds:r}}}})();return n.serverRevision===t.revision&&n.serverEpoch===t.serverEpoch?n:{...n,serverEpoch:t.serverEpoch,serverRevision:t.revision}})}function De(e,t){j(e,e=>{if(!t&&e.snapshot===null)return e;if(!t)return{...e,snapshot:null,sessions:{},activeTabId:null,desktopOverlay:null,desktopByTabId:{}};if(e.suppressedTabIds.has(t.tabId))return e;let n=e.sessions[t.tabId];if(n&&n.updatedAt>t.updatedAt)return e;let r=N(e.recentlySeenUrls,t);return{...e,snapshot:t,sessions:{...e.sessions,[t.tabId]:t},activeTabId:t.tabId,desktopOverlay:e.desktopByTabId[t.tabId]??null,recentlySeenUrls:r}})}function Oe(e,t){j(e,e=>{if(e.suppressedTabIds.has(t.tabId))return e;let n=e.sessions[t.tabId];if(n&&n.updatedAt>t.updatedAt)return e;let r={...e.sessions,[t.tabId]:t},i=e.activeTabId&&r[e.activeTabId]?e.activeTabId:t.tabId,a=r[i]??t;return{...e,sessions:r,activeTabId:i,snapshot:a,desktopOverlay:e.desktopByTabId[i]??null,recentlySeenUrls:N(e.recentlySeenUrls,t)}})}function ke(e,t){j(e,e=>{let n=e.serverEpoch===t.serverEpoch;if(n&&t.revision<e.serverRevision)return e;let r=t.sessions,i={},a=n?e.suppressedTabIds:new Set,o=e.recentlySeenUrls;for(let t of r){if(a.has(t.tabId))continue;let r=n?e.sessions[t.tabId]:void 0,s=r&&r.updatedAt>t.updatedAt?r:t;i[s.tabId]=s,o=N(o,s)}let s=P(i),c=e.activeTabId&&i[e.activeTabId]?e.activeTabId:s?.tabId??null,l=c?i[c]??null:null,u=n?Object.fromEntries(Object.entries(e.desktopByTabId).filter(([e])=>i[e]!==void 0)):{},d=new Set([...a].filter(e=>r.some(t=>t.tabId===e)));return{...e,sessions:i,suppressedTabIds:d,activeTabId:c,snapshot:l,desktopByTabId:u,desktopOverlay:c?u[c]??null:null,recentlySeenUrls:o,serverEpoch:t.serverEpoch,serverRevision:t.revision}})}function Ae(e,t){return e===t||e!==null&&t!==null&&e.hasWebContents===t.hasWebContents&&e.canGoBack===t.canGoBack&&e.canGoForward===t.canGoForward&&e.loading===t.loading&&e.zoomFactor===t.zoomFactor&&e.pictureInPicture===t.pictureInPicture&&e.colorScheme===t.colorScheme&&e.audioMuted===t.audioMuted&&e.audible===t.audible&&e.controller===t.controller&&e.favicon?.dataUrl===t.favicon?.dataUrl&&e.favicon?.pageUrl===t.favicon?.pageUrl&&e.favicon?.capturedAt===t.favicon?.capturedAt}function je(e,t,n){j(e,e=>{if(Ae(e.desktopByTabId[t]??null,n))return e;let r={...e.desktopByTabId};return n?r[t]=n:delete r[t],{...e,desktopByTabId:r,desktopOverlay:e.activeTabId===t?n:e.desktopOverlay}})}function Me(e,t){j(e,e=>{let n=new Set(e.suppressedTabIds);return n.add(t),{...F(e,t),suppressedTabIds:n}})}function Ne(e,t,n){j(e,e=>{if(!e.suppressedTabIds.has(n))return e;let r=new Set(e.suppressedTabIds);if(r.delete(n),!t)return{...e,suppressedTabIds:r};let i=t.navStatus._tag===`Idle`?e.recentlySeenUrls:M(e.recentlySeenUrls,t.navStatus.url);return{...e,snapshot:t,sessions:{...e.sessions,[t.tabId]:t},suppressedTabIds:r,activeTabId:t.tabId,desktopOverlay:e.desktopByTabId[t.tabId]??null,recentlySeenUrls:i}})}function Pe(e,t){j(e,e=>{let n=e.sessions[t];return!n||e.activeTabId===t?e:{...e,activeTabId:t,snapshot:n,desktopOverlay:e.desktopByTabId[t]??null}})}function Fe(e,t){t.trim().length!==0&&j(e,e=>({...e,recentlySeenUrls:M(e.recentlySeenUrls,t)}))}function Ie(e){let t=f(e);v.set(D(t),E),A(t,E),k.delete(t)}function Le(){return typeof window>`u`?!1:!!window.desktopBridge?.preview}var Re=e=>JSON.stringify([e.environmentId,e.input.clientId,e.input.connectionId]);function ze(e){let t=p(),n=p(),r=p(),i={mode:`serial`,key:({environmentId:e,input:t})=>JSON.stringify([e,t.threadId])};return{list:ce(e,{label:`environment-data:preview:list`,tag:o.previewList,staleTimeMs:5e3}),events:x(e,{label:`environment-data:preview:events`,tag:o.subscribePreviewEvents}),discoveredServers:x(e,{label:`environment-data:preview:discovered-servers`,tag:o.subscribeDiscoveredLocalServers,idleTtlMs:0}),automationRequests:x(e,{label:`environment-data:preview:automation-requests`,tag:o.previewAutomationConnect,idleTtlMs:0}),open:m(e,{label:`environment-data:preview:open`,tag:o.previewOpen,scheduler:t,concurrency:i}),navigate:m(e,{label:`environment-data:preview:navigate`,tag:o.previewNavigate,scheduler:t,concurrency:i}),resize:m(e,{label:`environment-data:preview:resize`,tag:o.previewResize,scheduler:t,concurrency:i}),refresh:m(e,{label:`environment-data:preview:refresh`,tag:o.previewRefresh,scheduler:t,concurrency:i}),close:m(e,{label:`environment-data:preview:close`,tag:o.previewClose,scheduler:t,concurrency:i}),reportStatus:m(e,{label:`environment-data:preview:report-status`,tag:o.previewReportStatus,scheduler:n,concurrency:{mode:`latest`,key:({environmentId:e,input:t})=>JSON.stringify([e,t.threadId,t.tabId])}}),respondToAutomation:m(e,{label:`environment-data:preview:automation-respond`,tag:o.previewAutomationRespond,scheduler:r,concurrency:{mode:`singleFlight`,key:({environmentId:e,input:t})=>JSON.stringify([e,t.connectionId,t.requestId])}}),focusAutomationHost:m(e,{label:`environment-data:preview:automation-focus-host`,tag:o.previewAutomationFocusHost,scheduler:r,concurrency:{mode:`latest`,key:Re}})}}var Be=ze(ue),Ve=/\n*<preview_annotation>\n((?:(?!<preview_annotation>)[\s\S])*)\n<\/preview_annotation>\s*$/,I=e=>e.replace(/\s*[\r\n]+\s*/g,` `);function He(e){let t=[`Preview annotation:`];t.push(`Id: ${I(e.id)}`);let n=e.pageTitle?.trim()||e.pageUrl.trim()||`Preview`;t.push(`Page: ${I(n)}`),e.comment.trim()&&t.push(`Comment: ${e.comment.trim()}`);let r=[];if(e.elements.length>0&&r.push(`${e.elements.length} selected element${e.elements.length===1?``:`s`}`),e.regions.length>0&&r.push(`${e.regions.length} marked region${e.regions.length===1?``:`s`}`),e.strokes.length>0&&r.push(`${e.strokes.length} drawing${e.strokes.length===1?``:`s`}`),r.length>0&&t.push(`Targets: ${r.join(`, `)}.`),e.styleChanges.length>0){t.push(`Requested visual changes:`);for(let n of e.styleChanges)t.push(`- ${I(n.property)}: ${I(n.previousValue||`(unset)`)} → ${I(n.value)}`)}e.screenshot&&t.push(`The attached screenshot is the annotated preview crop.`);let i=ee(e.elements.map(e=>re(e.element)).filter(e=>e!==null));return i&&t.push(i),`<preview_annotation>\n${t.join(`
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{$a as t,Do as n,Ga as r,Xa as i,ao as a,b as o,i as s,jo as c,to as l,v as u,y as d}from"./accountData-C4ZvicpJ.js";import{Dt as ee,dt as te,ft as ne,go as f,jt as re,lt as ie,mt as ae,pt as oe,wo as se}from"./utils-DgzD4MA_.js";import{Ft as p,Lt as m,Rt as ce,Sn as h,_n as le,i as ue,mn as g,n as _,p as v,vn as y,yn as b,zt as x}from"./session-D3Szkrpk.js";var S=e(d(),1),de=new Map([[`bold`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,187a113.4,113.4,0,0,1-20.39-35h40.82a116.94,116.94,0,0,1-10,20.77A108.61,108.61,0,0,1,128,207Zm-26.49-59a135.42,135.42,0,0,1,0-40h53a135.42,135.42,0,0,1,0,40ZM44,128a83.49,83.49,0,0,1,2.43-20H77.25a160.63,160.63,0,0,0,0,40H46.43A83.49,83.49,0,0,1,44,128Zm84-79a113.4,113.4,0,0,1,20.39,35H107.59a116.94,116.94,0,0,1,10-20.77A108.61,108.61,0,0,1,128,49Zm50.73,59h30.82a83.52,83.52,0,0,1,0,40H178.75a160.63,160.63,0,0,0,0-40Zm20.77-24H173.71a140.82,140.82,0,0,0-15.5-34.36A84.51,84.51,0,0,1,199.52,84ZM97.79,49.64A140.82,140.82,0,0,0,82.29,84H56.48A84.51,84.51,0,0,1,97.79,49.64ZM56.48,172H82.29a140.82,140.82,0,0,0,15.5,34.36A84.51,84.51,0,0,1,56.48,172Zm101.73,34.36A140.82,140.82,0,0,0,173.71,172h25.81A84.51,84.51,0,0,1,158.21,206.36Z`}))],[`duotone`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),S.createElement(`path`,{d:`M128,24h0A104,104,0,1,0,232,128,104.12,104.12,0,0,0,128,24Zm88,104a87.61,87.61,0,0,1-3.33,24H174.16a157.44,157.44,0,0,0,0-48h38.51A87.61,87.61,0,0,1,216,128ZM102,168H154a115.11,115.11,0,0,1-26,45A115.27,115.27,0,0,1,102,168Zm-3.9-16a140.84,140.84,0,0,1,0-48h59.88a140.84,140.84,0,0,1,0,48ZM40,128a87.61,87.61,0,0,1,3.33-24H81.84a157.44,157.44,0,0,0,0,48H43.33A87.61,87.61,0,0,1,40,128ZM154,88H102a115.11,115.11,0,0,1,26-45A115.27,115.27,0,0,1,154,88Zm52.33,0H170.71a135.28,135.28,0,0,0-22.3-45.6A88.29,88.29,0,0,1,206.37,88ZM107.59,42.4A135.28,135.28,0,0,0,85.29,88H49.63A88.29,88.29,0,0,1,107.59,42.4ZM49.63,168H85.29a135.28,135.28,0,0,0,22.3,45.6A88.29,88.29,0,0,1,49.63,168Zm98.78,45.6a135.28,135.28,0,0,0,22.3-45.6h35.66A88.29,88.29,0,0,1,148.41,213.6Z`}))],[`fill`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M128,24h0A104,104,0,1,0,232,128,104.12,104.12,0,0,0,128,24Zm78.36,64H170.71a135.28,135.28,0,0,0-22.3-45.6A88.29,88.29,0,0,1,206.37,88ZM216,128a87.61,87.61,0,0,1-3.33,24H174.16a157.44,157.44,0,0,0,0-48h38.51A87.61,87.61,0,0,1,216,128ZM128,43a115.27,115.27,0,0,1,26,45H102A115.11,115.11,0,0,1,128,43ZM102,168H154a115.11,115.11,0,0,1-26,45A115.27,115.27,0,0,1,102,168Zm-3.9-16a140.84,140.84,0,0,1,0-48h59.88a140.84,140.84,0,0,1,0,48Zm50.35,61.6a135.28,135.28,0,0,0,22.3-45.6h35.66A88.29,88.29,0,0,1,148.41,213.6Z`}))],[`light`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm81.57,64H169.19a132.58,132.58,0,0,0-25.73-50.67A90.29,90.29,0,0,1,209.57,90ZM218,128a89.7,89.7,0,0,1-3.83,26H171.81a155.43,155.43,0,0,0,0-52h42.36A89.7,89.7,0,0,1,218,128Zm-90,87.83a110,110,0,0,1-15.19-19.45A124.24,124.24,0,0,1,99.35,166h57.3a124.24,124.24,0,0,1-13.46,30.38A110,110,0,0,1,128,215.83ZM96.45,154a139.18,139.18,0,0,1,0-52h63.1a139.18,139.18,0,0,1,0,52ZM38,128a89.7,89.7,0,0,1,3.83-26H84.19a155.43,155.43,0,0,0,0,52H41.83A89.7,89.7,0,0,1,38,128Zm90-87.83a110,110,0,0,1,15.19,19.45A124.24,124.24,0,0,1,156.65,90H99.35a124.24,124.24,0,0,1,13.46-30.38A110,110,0,0,1,128,40.17Zm-15.46-.84A132.58,132.58,0,0,0,86.81,90H46.43A90.29,90.29,0,0,1,112.54,39.33ZM46.43,166H86.81a132.58,132.58,0,0,0,25.73,50.67A90.29,90.29,0,0,1,46.43,166Zm97,50.67A132.58,132.58,0,0,0,169.19,166h40.38A90.29,90.29,0,0,1,143.46,216.67Z`}))],[`regular`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M128,24h0A104,104,0,1,0,232,128,104.12,104.12,0,0,0,128,24Zm88,104a87.61,87.61,0,0,1-3.33,24H174.16a157.44,157.44,0,0,0,0-48h38.51A87.61,87.61,0,0,1,216,128ZM102,168H154a115.11,115.11,0,0,1-26,45A115.27,115.27,0,0,1,102,168Zm-3.9-16a140.84,140.84,0,0,1,0-48h59.88a140.84,140.84,0,0,1,0,48ZM40,128a87.61,87.61,0,0,1,3.33-24H81.84a157.44,157.44,0,0,0,0,48H43.33A87.61,87.61,0,0,1,40,128ZM154,88H102a115.11,115.11,0,0,1,26-45A115.27,115.27,0,0,1,154,88Zm52.33,0H170.71a135.28,135.28,0,0,0-22.3-45.6A88.29,88.29,0,0,1,206.37,88ZM107.59,42.4A135.28,135.28,0,0,0,85.29,88H49.63A88.29,88.29,0,0,1,107.59,42.4ZM49.63,168H85.29a135.28,135.28,0,0,0,22.3,45.6A88.29,88.29,0,0,1,49.63,168Zm98.78,45.6a135.28,135.28,0,0,0,22.3-45.6h35.66A88.29,88.29,0,0,1,148.41,213.6Z`}))],[`thin`,S.createElement(S.Fragment,null,S.createElement(`path`,{d:`M128,28h0A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,190.61c-6.33-6.09-23-24.41-31.27-54.61h62.54C151,194.2,134.33,212.52,128,218.61ZM94.82,156a140.42,140.42,0,0,1,0-56h66.36a140.42,140.42,0,0,1,0,56ZM128,37.39c6.33,6.09,23,24.41,31.27,54.61H96.73C105,61.8,121.67,43.48,128,37.39ZM169.41,100h46.23a92.09,92.09,0,0,1,0,56H169.41a152.65,152.65,0,0,0,0-56Zm43.25-8h-45a129.39,129.39,0,0,0-29.19-55.4A92.25,92.25,0,0,1,212.66,92ZM117.54,36.6A129.39,129.39,0,0,0,88.35,92h-45A92.25,92.25,0,0,1,117.54,36.6ZM40.36,100H86.59a152.65,152.65,0,0,0,0,56H40.36a92.09,92.09,0,0,1,0-56Zm3,64h45a129.39,129.39,0,0,0,29.19,55.4A92.25,92.25,0,0,1,43.34,164Zm95.12,55.4A129.39,129.39,0,0,0,167.65,164h45A92.25,92.25,0,0,1,138.46,219.4Z`}))]]),fe=Object.defineProperty,pe=Object.defineProperties,me=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,_e=(e,t,n)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ve=(e,t)=>{for(var n in t||={})he.call(t,n)&&_e(e,n,t[n]);if(C)for(var n of C(t))ge.call(t,n)&&_e(e,n,t[n]);return e},ye=(e,t)=>pe(e,me(t)),w=(0,S.forwardRef)((e,t)=>S.createElement(se,ye(ve({ref:t},e),{weights:de})));w.displayName=`Globe`;var T=u(),be=Object.freeze({ERR_NAME_NOT_RESOLVED:`DNS address could not be found`,ERR_NAME_RESOLUTION_FAILED:`DNS address could not be found`,ERR_CONNECTION_REFUSED:`Connection refused`,ERR_CONNECTION_RESET:`Connection was reset`,ERR_CONNECTION_CLOSED:`Connection was closed`,ERR_CONNECTION_TIMED_OUT:`Connection timed out`,ERR_INTERNET_DISCONNECTED:`No internet connection`,ERR_TIMED_OUT:`Connection timed out`,ERR_CERT_AUTHORITY_INVALID:`Certificate authority is not trusted`,ERR_CERT_COMMON_NAME_INVALID:`Certificate hostname mismatch`,ERR_CERT_DATE_INVALID:`Certificate is expired or not yet valid`,ERR_TOO_MANY_REDIRECTS:`Too many redirects`}),E=Object.freeze({snapshot:null,sessions:{},suppressedTabIds:new Set,activeTabId:null,desktopOverlay:null,desktopByTabId:{},recentlySeenUrls:[],serverEpoch:null,serverRevision:0}),xe=b(E).pipe(h(`preview:empty-thread`)),D=le(e=>b(E).pipe(y,h(`preview:thread:${e}`))),O=b({keys:new Set}).pipe(y,h(`preview:active-thread-keys`)),Se=b(e=>{let t={};for(let n of e(O).keys){let r=e(D(n));Object.keys(r.sessions).length>0&&(t[n]=r)}return t}).pipe(h(`preview:active-sessions`)),k=new Set;function A(e,t){let n=Object.keys(t.sessions).length>0;v.update(O,t=>{if(t.keys.has(e)===n)return t;let r=new Set(t.keys);return n?r.add(e):r.delete(e),{keys:r}})}function j(e,t){let n=f(e),r=D(n),i=v.get(r);v.modify(r,e=>(i=t(e),[i!==e,i]))&&(k.add(n),A(n,i))}var M=(e,t)=>[t,...e.filter(e=>e!==t)].slice(0,10),N=(e,t)=>t.navStatus._tag===`Idle`?e:M(e,t.navStatus.url),P=e=>Object.values(e).toSorted((e,t)=>e.updatedAt.localeCompare(t.updatedAt)).at(-1)??null,F=(e,t)=>{if(!e.sessions[t])return e;let{[t]:n,...r}=e.sessions,{[t]:i,...a}=e.desktopByTabId,o=P(r),s=e.activeTabId===t?o?.tabId??null:e.activeTabId,c=s?r[s]??o:o;return{...e,sessions:r,desktopByTabId:a,activeTabId:c?.tabId??null,snapshot:c,desktopOverlay:c?a[c.tabId]??null:null}};function Ce(e){let t=(0,T.c)(2),n;return t[0]===e?n=t[1]:(n=e?D(f(e)):xe,t[0]=e,t[1]=n),g(n)}function we(){return g(Se)}function Te(e){return v.get(D(f(e)))}function Ee(e,t){j(e,e=>{if(e.serverEpoch!==null&&t.serverEpoch!==e.serverEpoch||t.revision<e.serverRevision)return e;let n=(()=>{switch(t.type){case`opened`:case`navigated`:case`resized`:{let n=t.snapshot;if(e.suppressedTabIds.has(n.tabId))return e;let r=n.navStatus._tag===`Idle`?e.recentlySeenUrls:M(e.recentlySeenUrls,n.navStatus.url),i={...e.sessions,[n.tabId]:n},a=t.type===`opened`?n.tabId:e.activeTabId,o=i[a??n.tabId]??n;return{...e,sessions:i,activeTabId:a??n.tabId,snapshot:o,desktopOverlay:e.desktopByTabId[o.tabId]??null,recentlySeenUrls:r}}case`failed`:{let n=e.sessions[t.tabId];if(!n)return e;let r={...n,navStatus:{_tag:`LoadFailed`,url:t.url,title:t.title,code:t.code,description:t.description},updatedAt:t.createdAt},i={...e.sessions,[t.tabId]:r};return{...e,sessions:i,snapshot:e.activeTabId===t.tabId?r:e.snapshot}}case`closed`:{let n=F(e,t.tabId);if(!n.suppressedTabIds.has(t.tabId))return n;let r=new Set(n.suppressedTabIds);return r.delete(t.tabId),{...n,suppressedTabIds:r}}}})();return n.serverRevision===t.revision&&n.serverEpoch===t.serverEpoch?n:{...n,serverEpoch:t.serverEpoch,serverRevision:t.revision}})}function De(e,t){j(e,e=>{if(!t&&e.snapshot===null)return e;if(!t)return{...e,snapshot:null,sessions:{},activeTabId:null,desktopOverlay:null,desktopByTabId:{}};if(e.suppressedTabIds.has(t.tabId))return e;let n=e.sessions[t.tabId];if(n&&n.updatedAt>t.updatedAt)return e;let r=N(e.recentlySeenUrls,t);return{...e,snapshot:t,sessions:{...e.sessions,[t.tabId]:t},activeTabId:t.tabId,desktopOverlay:e.desktopByTabId[t.tabId]??null,recentlySeenUrls:r}})}function Oe(e,t){j(e,e=>{if(e.suppressedTabIds.has(t.tabId))return e;let n=e.sessions[t.tabId];if(n&&n.updatedAt>t.updatedAt)return e;let r={...e.sessions,[t.tabId]:t},i=e.activeTabId&&r[e.activeTabId]?e.activeTabId:t.tabId,a=r[i]??t;return{...e,sessions:r,activeTabId:i,snapshot:a,desktopOverlay:e.desktopByTabId[i]??null,recentlySeenUrls:N(e.recentlySeenUrls,t)}})}function ke(e,t){j(e,e=>{let n=e.serverEpoch===t.serverEpoch;if(n&&t.revision<e.serverRevision)return e;let r=t.sessions,i={},a=n?e.suppressedTabIds:new Set,o=e.recentlySeenUrls;for(let t of r){if(a.has(t.tabId))continue;let r=n?e.sessions[t.tabId]:void 0,s=r&&r.updatedAt>t.updatedAt?r:t;i[s.tabId]=s,o=N(o,s)}let s=P(i),c=e.activeTabId&&i[e.activeTabId]?e.activeTabId:s?.tabId??null,l=c?i[c]??null:null,u=n?Object.fromEntries(Object.entries(e.desktopByTabId).filter(([e])=>i[e]!==void 0)):{},d=new Set([...a].filter(e=>r.some(t=>t.tabId===e)));return{...e,sessions:i,suppressedTabIds:d,activeTabId:c,snapshot:l,desktopByTabId:u,desktopOverlay:c?u[c]??null:null,recentlySeenUrls:o,serverEpoch:t.serverEpoch,serverRevision:t.revision}})}function Ae(e,t){return e===t||e!==null&&t!==null&&e.hasWebContents===t.hasWebContents&&e.canGoBack===t.canGoBack&&e.canGoForward===t.canGoForward&&e.loading===t.loading&&e.zoomFactor===t.zoomFactor&&e.pictureInPicture===t.pictureInPicture&&e.colorScheme===t.colorScheme&&e.audioMuted===t.audioMuted&&e.audible===t.audible&&e.controller===t.controller&&e.favicon?.dataUrl===t.favicon?.dataUrl&&e.favicon?.pageUrl===t.favicon?.pageUrl&&e.favicon?.capturedAt===t.favicon?.capturedAt}function je(e,t,n){j(e,e=>{if(Ae(e.desktopByTabId[t]??null,n))return e;let r={...e.desktopByTabId};return n?r[t]=n:delete r[t],{...e,desktopByTabId:r,desktopOverlay:e.activeTabId===t?n:e.desktopOverlay}})}function Me(e,t){j(e,e=>{let n=new Set(e.suppressedTabIds);return n.add(t),{...F(e,t),suppressedTabIds:n}})}function Ne(e,t,n){j(e,e=>{if(!e.suppressedTabIds.has(n))return e;let r=new Set(e.suppressedTabIds);if(r.delete(n),!t)return{...e,suppressedTabIds:r};let i=t.navStatus._tag===`Idle`?e.recentlySeenUrls:M(e.recentlySeenUrls,t.navStatus.url);return{...e,snapshot:t,sessions:{...e.sessions,[t.tabId]:t},suppressedTabIds:r,activeTabId:t.tabId,desktopOverlay:e.desktopByTabId[t.tabId]??null,recentlySeenUrls:i}})}function Pe(e,t){j(e,e=>{let n=e.sessions[t];return!n||e.activeTabId===t?e:{...e,activeTabId:t,snapshot:n,desktopOverlay:e.desktopByTabId[t]??null}})}function Fe(e,t){t.trim().length!==0&&j(e,e=>({...e,recentlySeenUrls:M(e.recentlySeenUrls,t)}))}function Ie(e){let t=f(e);v.set(D(t),E),A(t,E),k.delete(t)}function Le(){return typeof window>`u`?!1:!!window.desktopBridge?.preview}var Re=e=>JSON.stringify([e.environmentId,e.input.clientId,e.input.connectionId]);function ze(e){let t=p(),n=p(),r=p(),i={mode:`serial`,key:({environmentId:e,input:t})=>JSON.stringify([e,t.threadId])};return{list:ce(e,{label:`environment-data:preview:list`,tag:o.previewList,staleTimeMs:5e3}),events:x(e,{label:`environment-data:preview:events`,tag:o.subscribePreviewEvents}),discoveredServers:x(e,{label:`environment-data:preview:discovered-servers`,tag:o.subscribeDiscoveredLocalServers,idleTtlMs:0}),automationRequests:x(e,{label:`environment-data:preview:automation-requests`,tag:o.previewAutomationConnect,idleTtlMs:0}),open:m(e,{label:`environment-data:preview:open`,tag:o.previewOpen,scheduler:t,concurrency:i}),navigate:m(e,{label:`environment-data:preview:navigate`,tag:o.previewNavigate,scheduler:t,concurrency:i}),resize:m(e,{label:`environment-data:preview:resize`,tag:o.previewResize,scheduler:t,concurrency:i}),refresh:m(e,{label:`environment-data:preview:refresh`,tag:o.previewRefresh,scheduler:t,concurrency:i}),close:m(e,{label:`environment-data:preview:close`,tag:o.previewClose,scheduler:t,concurrency:i}),reportStatus:m(e,{label:`environment-data:preview:report-status`,tag:o.previewReportStatus,scheduler:n,concurrency:{mode:`latest`,key:({environmentId:e,input:t})=>JSON.stringify([e,t.threadId,t.tabId])}}),respondToAutomation:m(e,{label:`environment-data:preview:automation-respond`,tag:o.previewAutomationRespond,scheduler:r,concurrency:{mode:`singleFlight`,key:({environmentId:e,input:t})=>JSON.stringify([e,t.connectionId,t.requestId])}}),focusAutomationHost:m(e,{label:`environment-data:preview:automation-focus-host`,tag:o.previewAutomationFocusHost,scheduler:r,concurrency:{mode:`latest`,key:Re}})}}var Be=ze(ue),Ve=/\n*<preview_annotation>\n((?:(?!<preview_annotation>)[\s\S])*)\n<\/preview_annotation>\s*$/,I=e=>e.replace(/\s*[\r\n]+\s*/g,` `);function He(e){let t=[`Preview annotation:`];t.push(`Id: ${I(e.id)}`);let n=e.pageTitle?.trim()||e.pageUrl.trim()||`Preview`;t.push(`Page: ${I(n)}`),e.comment.trim()&&t.push(`Comment: ${e.comment.trim()}`);let r=[];if(e.elements.length>0&&r.push(`${e.elements.length} selected element${e.elements.length===1?``:`s`}`),e.regions.length>0&&r.push(`${e.regions.length} marked region${e.regions.length===1?``:`s`}`),e.strokes.length>0&&r.push(`${e.strokes.length} drawing${e.strokes.length===1?``:`s`}`),r.length>0&&t.push(`Targets: ${r.join(`, `)}.`),e.styleChanges.length>0){t.push(`Requested visual changes:`);for(let n of e.styleChanges)t.push(`- ${I(n.property)}: ${I(n.previousValue||`(unset)`)} → ${I(n.value)}`)}e.screenshot&&t.push(`The attached screenshot is the annotated preview crop.`);let i=ee(e.elements.map(e=>re(e.element)).filter(e=>e!==null));return i&&t.push(i),`<preview_annotation>\n${t.join(`
2
2
  `).replace(/<(\/?)preview_annotation/gi,`&lt;$1preview_annotation`)}\n</preview_annotation>`}function Ue(e,t){let n=He(t),r=e.trim();return r?`${r}\n\n${n}`:n}function We(e){let t=Ve.exec(e);if(!t)return{promptText:e,annotation:null};let n=t[1]??``,r=n.split(`
3
3
  `),i=r.find(e=>e.startsWith(`Page: `)),a=r.find(e=>e.startsWith(`Id: `)),o=r.find(e=>e.startsWith(`Comment: `)),s=r.find(e=>e.startsWith(`Targets: `)),c=r.indexOf(`Requested visual changes:`),l=r.slice(c+1),u=l.indexOf(`<element_context>`),d=c<0?[]:l.slice(0,u<0?void 0:u).filter(e=>e.startsWith(`- `)).map(e=>e.slice(2));return{promptText:e.slice(0,t.index).replace(/\n+$/,``),annotation:{id:a?.slice(4).trim()||`${t.index}`,title:i?.slice(6).trim()||`Preview annotation`,comment:o?.slice(9).trim()||``,targetSummary:s?.slice(9).trim()||``,styleChanges:d,hasScreenshot:n.includes(`The attached screenshot is the annotated preview crop.`)}}}async function Ge(e){if(!e.screenshot)return null;let t=await(await fetch(e.screenshot.dataUrl)).blob();return new File([t],`preview-annotation-${e.id}.png`,{type:t.type||`image/png`})}function Ke(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}function qe(e){return e===`darwin`?`Reveal in Finder`:e===`windows`?`Reveal in File Explorer`:`Reveal in Files`}function Je(e){return e===`finder`?`Reveal in Finder`:e===`file-explorer`?`Reveal in File Explorer`:`Reveal in Files`}var L=new Set([`localhost`,`127.0.0.1`,`0.0.0.0`,`::1`]);[...L];var Ye=/^(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1?\])(?::|\/|$)/i;function R(e){return!!(L.has(e)||e===`[::1]`)}function Xe(e){try{let t=new URL(e);return t.protocol!==`http:`&&t.protocol!==`https:`?!1:R(t.hostname)}catch{return!1}}var z=class extends a()(`PreviewUrlNormalizationError`,{inputLength:t,reason:i([`empty`,`parse`,`unsupported-protocol`]),protocol:c(l),cause:c(r())}){get message(){let e=this.protocol===void 0?``:`: ${this.protocol}`;return`Invalid preview URL (${this.reason}${e}; input length ${this.inputLength}).`}};n(z);function Ze(e){return/^([A-Za-z][A-Za-z\d+.-]*):/.exec(e)?.[1]?.toLowerCase().concat(`:`)}function B(e){let t=e.trim();if(t.length===0)throw new z({inputLength:e.length,reason:`empty`});let n=Ye.test(t),r=t.includes(`://`)?t:`${n?`http`:`https`}://${t}`,i;try{i=new URL(r)}catch(t){throw new z({inputLength:e.length,reason:`parse`,protocol:Ze(r),cause:t})}if(i.protocol!==`http:`&&i.protocol!==`https:`)throw new z({inputLength:e.length,reason:`unsupported-protocol`,protocol:i.protocol});return i.href}var V=e=>e.toLowerCase().replace(/^\[|\]$/g,``).replace(/\.+$/u,``),H=e=>{let t=V(e).split(`.`).map(Number);return t.length===4&&t.every(e=>Number.isInteger(e)&&e>=0&&e<=255)?t:null},U=e=>{let t=V(e);if(!t.startsWith(`::ffff:`))return null;let n=t.slice(7),r=H(n);if(r)return r;let i=n.split(`:`);if(i.length!==2||i.some(e=>!/^[\da-f]{1,4}$/u.test(e)))return null;let a=Number.parseInt(i[0],16),o=Number.parseInt(i[1],16);return[a>>>8,a&255,o>>>8,o&255]},Qe=e=>{let t=V(e);if(!t.includes(`:`))return null;let n=t.split(`::`);if(n.length>2)return null;let r=n[0]?n[0].split(`:`):[],i=n[1]?n[1].split(`:`):[];if([...r,...i].some(e=>!/^[\da-f]{1,4}$/u.test(e)))return null;let a=8-r.length-i.length;return n.length===1&&a!==0||n.length===2&&a<1?null:[...r,...Array.from({length:a},()=>`0`),...i].map(e=>Number.parseInt(e,16))},W=(e,t,n)=>{let r=Math.floor(n/16);if(e.slice(0,r).some((e,n)=>e!==t[n]))return!1;let i=n%16;if(i===0)return!0;let a=65535<<16-i&65535;return(e[r]&a)===(t[r]&a)},G=e=>e[0]===0||e[0]===10||e[0]===127||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&e[1]===168||e[0]===169&&e[1]===254||e[0]===198&&e[1]>=18&&e[1]<=19,K=e=>G(e)||e[0]>=224||e[0]===192&&e[1]===0&&e[2]===0||e[0]===192&&e[1]===0&&e[2]===2||e[0]===192&&e[1]===88&&e[2]===99||e[0]===198&&e[1]===51&&e[2]===100||e[0]===203&&e[1]===0&&e[2]===113,q=e=>{let t=V(e);return t===`localhost`||t===`::1`?!0:H(t)?.[0]===127},J=e=>{let t=V(e);if(t===`::`||q(t)||t.endsWith(`.localhost`)||t.endsWith(`.local`)||t===`home.arpa`||t.endsWith(`.home.arpa`)||!t.includes(`.`)&&!t.includes(`:`)||t.endsWith(`.ts.net`))return!0;let n=H(t)??U(t);if(n)return G(n);let r=t.split(`:`,1)[0]??``;if(!t.includes(`:`)||!/^[\da-f]{1,4}$/u.test(r))return!1;let i=Number.parseInt(r,16);return Number.isInteger(i)&&((i&65024)==64512||(i&65472)==65152)},$e=e=>{if(e.endsWith(`..`))return!1;let t=V(e);if(J(t)||[`.alt`,`.example`,`.internal`,`.invalid`,`.onion`,`.test`].some(e=>t===e.slice(1)||t.endsWith(e)))return!1;let n=H(t)??U(t);if(n)return!K(n);if(!t.includes(`:`))return!0;let r=Qe(t);if(!r)return!1;if(W(r,[100,65435,0,0,0,0,0,0],96))return!K([r[6]>>>8,r[6]&255,r[7]>>>8,r[7]&255]);let i=r[0];return(i&57344)==8192?W(r,[8193,0,0,0,0,0,0,0],23)?r[1]===1&&r.slice(2,7).every(e=>e===0)&&[1,2,3].includes(r[7])||W(r,[8193,3,0,0,0,0,0,0],32)||W(r,[8193,4,274,0,0,0,0,0],48)||W(r,[8193,32,0,0,0,0,0,0],28)||W(r,[8193,48,0,0,0,0,0,0],28):!(W(r,[8193,3512,0,0,0,0,0,0],32)||W(r,[8194,0,0,0,0,0,0,0],16)||i===16383&&!(r[1]&61440)):!1},Y=e=>{let t=_(e);if(!t)throw Error(`Environment ${e} is not connected.`);return new URL(t.httpBaseUrl)},et=(e,t,n,r,i)=>{if(!J(n.hostname))throw Error(`This environment port needs the planned authenticated preview gateway; its server address is not directly private-network reachable.`);let a=t.protocol??`http`,o=t.path?.startsWith(`/`)?t.path:`/${t.path??``}`,s=n.hostname.replace(/^\[|\]$/g,``),c=q(s)?`localhost`:s.includes(`:`)?`[${s}]`:s,l=i?new URL(i):new URL(o,`${a}://${c}:${t.port}`);return i&&(l.hostname=c,l.port=String(t.port)),{requestedUrl:r??`${a}://localhost:${t.port}${o}`,resolvedUrl:l.toString(),resolutionKind:q(s)?`direct`:`direct-private-network`,environmentId:e}};function tt(e,t){if(t.kind===`url`){let n=null;try{n=new URL(B(t.url))}catch{}if(n&&R(n.hostname)){let r=Y(e);if(n.hostname===`0.0.0.0`||!q(r.hostname))return et(e,{kind:`environment-port`,port:Number(n.port||(n.protocol===`https:`?443:80)),protocol:n.protocol===`https:`?`https`:`http`,path:`${n.pathname}${n.search}${n.hash}`},r,t.url,n)}return{requestedUrl:t.url,resolvedUrl:t.url,resolutionKind:`direct`,environmentId:e}}return et(e,t,Y(e))}function nt(e,t){try{return tt(e,{kind:`url`,url:B(t)}).resolvedUrl}catch{return t}}var rt=864e13;function it(e){return typeof e==`number`&&Number.isFinite(e)&&Math.abs(e)<=rt}function X(e){let t;try{t=new URL(B(e))}catch{return null}return t.username=t.password=``,t.href.length>2048?null:t.href}function at(e,t){let n=new URL(Z(e,t));return n.pathname!==`/`&&n.pathname.endsWith(`/`)&&(n.pathname=n.pathname.slice(0,-1)),n.href}function Z(e,t){let n=new URL(e),r=V(n.hostname),i=t&&V(t);return(q(r)||r===`0.0.0.0`||r===i)&&(n.hostname=`local`),n.href}function Q(e){let t=V(new URL(e).hostname);return q(t)||t===`0.0.0.0`}function ot(e,t,n,r){let i=Z(t,r?.environmentHostname),a=e.find(e=>Z(e.url,r?.environmentHostname)===i),o=e.filter(e=>Z(e.url,r?.environmentHostname)!==i),s=r?.insertOrdered&&a&&a.lastVisitedAt>n?a.lastVisitedAt:n,c=a&&(Q(a.url)||!Q(t))?a.url:t,l=a?{...a,url:c,lastVisitedAt:s}:{url:t,lastVisitedAt:s};if(!r?.insertOrdered)return[l,...o].slice(0,50);let u=o.findIndex(e=>e.lastVisitedAt<l.lastVisitedAt);return(u===-1?[...o,l]:o.toSpliced(u,0,l)).slice(0,50)}function st(e){let t=Object.keys(e);if(t.length<=20)return e;let n=t.toSorted((t,n)=>(e[n]?.[0]?.lastVisitedAt??0)-(e[t]?.[0]?.lastVisitedAt??0)).slice(0,20);return Object.fromEntries(n.map(t=>[t,e[t]??[]]))}function ct(e){if(!e||typeof e!=`object`)return{byProjectKey:{}};let t=e.byProjectKey;if(!t||typeof t!=`object`||Array.isArray(t))return{byProjectKey:{}};let n={};for(let[e,r]of Object.entries(t)){if(!Array.isArray(r))continue;let t=new Set,i=r.flatMap(e=>{if(!e||typeof e!=`object`)return[];let{url:t,lastVisitedAt:n,title:r}=e;if(typeof t!=`string`)return[];let i=X(t);return!i||!it(n)?[]:[{url:i,lastVisitedAt:n,...typeof r==`string`&&r.length>0?{title:r.slice(0,512)}:{}}]}).toSorted((e,t)=>t.lastVisitedAt-e.lastVisitedAt).filter(e=>{let n=Z(e.url);return t.has(n)?!1:(t.add(n),!0)}).slice(0,50);i.length>0&&(n[e]=i)}return{byProjectKey:st(n)}}var lt=s(`borgcode:browser-history:v1`),ut=20;function dt(e,t,n){let r=e[t]??[],i={...e};i[t]=[...r,n].slice(-10);let a=Object.keys(i);if(a.length>ut){let e=a[0];e!==void 0&&e!==t&&delete i[e]}return i}var $=ae()(oe((e,t)=>({byProjectKey:{},projectKeyByThreadKey:{},pendingVisitsByThreadKey:{},pendingTitlesByThreadKey:{},recordVisit:(t,n,r,i)=>{let a=X(n);a&&e(e=>({byProjectKey:st({...e.byProjectKey,[t]:ot(e.byProjectKey[t]??[],a,r,i)})}))},setTitleForUrl:(n,r,i,a)=>{let o=X(r),s=t(),c=s.byProjectKey[n],l=i.trim().slice(0,512);if(!o||!c||l.length===0)return;let u=at(o,a),d=c.findIndex(e=>at(e.url,a)===u);d===-1||c[d]?.title===l||e({byProjectKey:{...s.byProjectKey,[n]:c.map((e,t)=>t===d?{...e,title:l}:e)}})},removeUrl:(n,r)=>{let i=X(r),a=t(),o=a.byProjectKey[n];if(!i||!o)return;let s=o.filter(e=>e.url!==i);if(s.length!==o.length){if(s.length===0){let{[n]:t,...r}=a.byProjectKey;e({byProjectKey:r});return}e({byProjectKey:{...a.byProjectKey,[n]:s}})}},registerThreadProject:(n,r)=>{let i=f(n),a=t(),o=a.pendingVisitsByThreadKey[i],s=a.pendingTitlesByThreadKey[i];if(a.projectKeyByThreadKey[i]===r&&!o&&!s)return;let c={...a.pendingVisitsByThreadKey},l={...a.pendingTitlesByThreadKey};delete c[i],delete l[i],e({projectKeyByThreadKey:{...a.projectKeyByThreadKey,[i]:r},pendingVisitsByThreadKey:c,pendingTitlesByThreadKey:l});for(let e of o??[])t().recordVisit(r,e.url,e.at,{insertOrdered:!0,environmentHostname:e.environmentHostname});for(let e of s??[])t().setTitleForUrl(r,e.url,e.title,e.environmentHostname)}}),{name:lt,version:1,storage:ne(()=>ie(typeof window<`u`?window.localStorage:void 0)),partialize:e=>({byProjectKey:e.byProjectKey,projectKeyByThreadKey:e.projectKeyByThreadKey}),migrate:ct,merge:ft}));function ft(e,t){let n=ct(e);return{...t,...n,projectKeyByThreadKey:pt(e,n.byProjectKey),pendingVisitsByThreadKey:{},pendingTitlesByThreadKey:{}}}function pt(e,t){if(!e||typeof e!=`object`)return{};let n=e.projectKeyByThreadKey;return!n||typeof n!=`object`||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(e=>typeof e[1]==`string`&&e[1]in t).slice(-100))}function mt(e,t,n){let r=f(e),i=$.getState(),a=i.projectKeyByThreadKey[r],o=n??Date.now(),s=_(e.environmentId),c=s?new URL(s.httpBaseUrl).hostname:null;if(!a){$.setState({pendingVisitsByThreadKey:dt(i.pendingVisitsByThreadKey,r,{url:t,at:o,environmentHostname:c})});return}i.recordVisit(a,t,o,{environmentHostname:c})}function ht(e,t,n,r){let i=f(e),a=$.getState(),o=a.projectKeyByThreadKey[i];if(!o){$.setState({pendingTitlesByThreadKey:dt(a.pendingTitlesByThreadKey,i,{url:t,title:n,environmentHostname:r})});return}a.setTitleForUrl(o,t,n,r)}function gt(e,t){let n=$.getState(),r=n.projectKeyByThreadKey[f(e)];r&&n.removeUrl(r,t)}var _t=[];function vt(e,t){let n=(0,T.c)(3),r;return n[0]!==t||n[1]!==e?(r=n=>{let r=n.projectKeyByThreadKey[f(e)],i=r?n.byProjectKey[r]:void 0;return i&&i.length>0?i.slice(0,t):_t},n[0]=t,n[1]=e,n[2]=r):r=n[2],$(te(r))}export{Fe as A,Ee as C,Le as D,Ne as E,Ce as F,be as I,w as L,Pe as M,Oe as N,Te as O,we as P,je as S,Me as T,qe as _,$ as a,Ge as b,$e as c,nt as d,R as f,Je as g,Ke as h,ht as i,Ie as j,ke as k,V as l,B as m,mt as n,vt as o,Xe as p,gt as r,q as s,it as t,tt as u,Ue as v,De as w,Be as x,We as y};
4
- //# sourceMappingURL=browserHistoryStore-CIr_OQCq.js.map
4
+ //# sourceMappingURL=browserHistoryStore-DLbnuO9R.js.map