@openchamber/web 2.5.4-canary.20261102.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AboutDialog-BlnajGrT.js → AboutDialog-DBDN-gwQ.js} +1 -1
- package/dist/assets/{AboutLogo-3M1SBBNZ.js → AboutLogo-BP87552a.js} +1 -1
- package/dist/assets/{ArchiveView-CPilj1fC.js → ArchiveView-GN7gU2qK.js} +1 -1
- package/dist/assets/{ChangeRequestDiffUnavailable-BduBYMgG.js → ChangeRequestDiffUnavailable-B28oeUds.js} +1 -1
- package/dist/assets/{ChangedPathLabel-DIy75LK1.js → ChangedPathLabel-DV4XTf6K.js} +1 -1
- package/dist/assets/{CommandPalette-C2nQAx5k.js → CommandPalette-Dvsy8IHV.js} +1 -1
- package/dist/assets/{DiffView-BVTlvbXB.js → DiffView-BXm5iGeW.js} +1 -1
- package/dist/assets/{FilesView-BN8-zteg.js → FilesView-CAXuJLle.js} +1 -1
- package/dist/assets/{GitView-DG6bleRy.js → GitView-D29soKpK.js} +1 -1
- package/dist/assets/{GuestSurfacePane-B90hZ3u8.js → GuestSurfacePane-Dw0Um8RG.js} +1 -1
- package/dist/assets/{HelpDialog-aRFswWNg.js → HelpDialog-DuO4UnZT.js} +1 -1
- package/dist/assets/{IntegrationsCatalogView-C4cPdrsB.js → IntegrationsCatalogView-BrLbP8hQ.js} +1 -1
- package/dist/assets/{JsonTreeView-UaVQcUQZ.js → JsonTreeView-ZZKmvRSL.js} +1 -1
- package/dist/assets/{MarkdownDiffPreview-BC6CVMO-.js → MarkdownDiffPreview-DuH8ODuS.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-UOgKmPXx.js → MarkdownRendererImpl-DNGYmQPH.js} +3 -3
- package/dist/assets/{MemoryDebugPanel-4r-pUuYH.js → MemoryDebugPanel-C7shSvtT.js} +1 -1
- package/dist/assets/{NoteEditor-CrOcUYK6.js → NoteEditor-Ba3KW2rV.js} +1 -1
- package/dist/assets/{OnboardingScreen-BzcxV-Pg.js → OnboardingScreen-CIyOLCq2.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-Cco26DIb.js → OpenCodeStatusDialog-ByN8gJ51.js} +1 -1
- package/dist/assets/{OverviewView-D2CAYo9U.js → OverviewView-B6SMyBTp.js} +1 -1
- package/dist/assets/{PatchDiff-CwCGfs3K.js → PatchDiff-C8jKkgEf.js} +1 -1
- package/dist/assets/{PlanView-B5oRyYG6.js → PlanView-NMKJpsCH.js} +1 -1
- package/dist/assets/{ProjectActionsDialog-D__fK8j6.js → ProjectActionsDialog-Ctr7-_lb.js} +1 -1
- package/dist/assets/{ReplyUiBlock-CevfJFOA.js → ReplyUiBlock-C-C95eJ_.js} +1 -1
- package/dist/assets/{RunOverview-tWVSr7oD.js → RunOverview-DNSvGB7-.js} +1 -1
- package/dist/assets/{ScheduledTasksDialog-DzOKDUcr.js → ScheduledTasksDialog-BNXOjpPY.js} +1 -1
- package/dist/assets/{SettingsView-BrKo0dlB.js → SettingsView-ug8Oinyr.js} +1 -1
- package/dist/assets/{SettingsWindow-Bp2lUZJd.js → SettingsWindow-CKUU5T8p.js} +1 -1
- package/dist/assets/{SidebarSectionsManager-D_zpJXup.js → SidebarSectionsManager-DWJwQwVi.js} +1 -1
- package/dist/assets/{SourceBoardView-DyHe-IJ9.js → SourceBoardView-BQittQF3.js} +1 -1
- package/dist/assets/{SpaceAccessDialog-D9BfvyIU.js → SpaceAccessDialog-CeZrOBod.js} +1 -1
- package/dist/assets/{SpaceApplyDialog-eVW7H9pP.js → SpaceApplyDialog-DurN0_0Z.js} +1 -1
- package/dist/assets/{SpaceRow-D5b9hpb6.js → SpaceRow-BkgNrW0R.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-CSNazSK9.js → SpaceSetupOutput-BDkJcYrl.js} +1 -1
- package/dist/assets/{SpacesView-J3QlOZyh.js → SpacesView-D6UCwVZp.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-DDba6A3F.js → SubmoduleDiffSummary-BK5RTTC4.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DwVHGaT7.js → ToolOutputDialog-CAenoFSA.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-DGVHMbBa.js → ToolPartDiffPreview-CdjYwDyA.js} +1 -1
- package/dist/assets/{UiBlock-BUISMIAx.js → UiBlock-t2ea_iLd.js} +1 -1
- package/dist/assets/{UsageStatsView-DDvD7HrF.js → UsageStatsView-D2AXngeb.js} +1 -1
- package/dist/assets/{Virtualizer-D1iGS21w.js → Virtualizer-V759EvEY.js} +1 -1
- package/dist/assets/{WalkthroughView-D-YJlvdW.js → WalkthroughView-CiQk4Tg_.js} +1 -1
- package/dist/assets/{WorktreesView-Cl1aGit2.js → WorktreesView-Bmnk7eXM.js} +1 -1
- package/dist/assets/{appThemeRegistry-C0l0I3bB.js → appThemeRegistry-D4EuLaGF.js} +1 -1
- package/dist/assets/{ar-BMUyLF4s.js → ar-9I6l4EAU.js} +1 -1
- package/dist/assets/{codeHighlight-D6SsoBS5.js → codeHighlight-DD239VMc.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-ClD-wmbl.js → computeVirtualFileMetrics-BhVDZ-oP.js} +2 -2
- package/dist/assets/{contextFileOpenGuard-xnSVLGTm.js → contextFileOpenGuard-D9Z0ay-I.js} +1 -1
- package/dist/assets/{date-time-C71h4UaZ.js → date-time-DlgUVVwY.js} +1 -1
- package/dist/assets/{de-CQLqnHpw.js → de-CPlTX8kA.js} +1 -1
- package/dist/assets/{es-B3v3FeB5.js → es-BMaNboo9.js} +1 -1
- package/dist/assets/{fileContentPoller-VaU-YZvx.js → fileContentPoller-paKtimZt.js} +1 -1
- package/dist/assets/{flexokiTheme-rJIJ5F0h.js → flexokiTheme-Bv37aHkq.js} +1 -1
- package/dist/assets/{fr-BhSq3naw.js → fr-onOdSl19.js} +1 -1
- package/dist/assets/{he-CP8ZMKnK.js → he-CgCCGzpX.js} +1 -1
- package/dist/assets/{highlights-CMBoVVUU.js → highlights-ByNnuo4t.js} +1 -1
- package/dist/assets/{index-D_HDYLit.js → index-BKnb59RH.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-Dcg_PAzE.js → initializeSharedPreferences-CFrNmgg0.js} +1 -1
- package/dist/assets/{install-Bi-8zdru.js → install-EEjacdUD.js} +1 -1
- package/dist/assets/{isDiffPlainText-un0acoNx.js → isDiffPlainText-DUd8YJX0.js} +1 -1
- package/dist/assets/{isFilePlainText-DDOfZj67.js → isFilePlainText-BqR4iT-Y.js} +1 -1
- package/dist/assets/{ja-C8tOrbJB.js → ja-CYYy1_I8.js} +1 -1
- package/dist/assets/{katex.min-CgNRvQ_w.js → katex.min-BBVkbKQY.js} +4 -4
- package/dist/assets/{ko-CY1yC8a5.js → ko-CupS3Elm.js} +1 -1
- package/dist/assets/{main-B1TR2-UX.js → main-B3MbWk_e.js} +2 -2
- package/dist/assets/{main-JYDeJYln.js → main-Kwo8IqqZ.js} +4 -4
- package/dist/assets/{miniChat-BdSabZ16.js → miniChat-DelNi_yP.js} +2 -2
- package/dist/assets/{mobile-6VDGY-4S.js → mobile-BIso4MdY.js} +2 -2
- package/dist/assets/{nl-CuD--zTY.js → nl-Di3GhSHB.js} +1 -1
- package/dist/assets/{pageTitle-BC5zJMdk.js → pageTitle-BL2yQcTV.js} +1 -1
- package/dist/assets/{parseDiffFromFile-Byzf7qzN.js → parseDiffFromFile-31PZ3lnE.js} +1 -1
- package/dist/assets/{pierreDiffTint-cWVXxsPO.js → pierreDiffTint-igvBfgMB.js} +1 -1
- package/dist/assets/{pl-BXcO7hE0.js → pl-DEy-fwio.js} +1 -1
- package/dist/assets/{pt-BR-DrHl5_ZJ.js → pt-BR-Cqzgn2Hs.js} +1 -1
- package/dist/assets/{relocateRestoredSession-CO5ZxywG.js → relocateRestoredSession-CGvQdGRX.js} +2 -2
- package/dist/assets/{renderElectronMiniChatApp-D9pG0xDR.js → renderElectronMiniChatApp-hBJHkIHQ.js} +2 -2
- package/dist/assets/{renderMarkdownForExport-CLEtE-8l.js → renderMarkdownForExport-DWj11Yob.js} +1 -1
- package/dist/assets/{renderMobileApp-D3MEjWXH.js → renderMobileApp-Bzps4LvM.js} +3 -3
- package/dist/assets/{resolveLanguages-BpEzCAf_.js → resolveLanguages-DHAaVkki.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DUwj747k.js → runtimeEndpointReset-BPYbd6uu.js} +5 -5
- package/dist/assets/{scheduledTasksApi-BHdrsdIS.js → scheduledTasksApi-D6FhT0TU.js} +1 -1
- package/dist/assets/{shiki-ju2dHiNP.js → shiki-y7boL955.js} +1 -1
- package/dist/assets/{space-apply-CJ--MPJt.js → space-apply-9idN6j4k.js} +1 -1
- package/dist/assets/{space-close-DSKwop1P.js → space-close-CjDS5mSo.js} +1 -1
- package/dist/assets/{spaceNetwork-CbJeZ9x4.js → spaceNetwork-DeZE7V6c.js} +1 -1
- package/dist/assets/{stream-tokenizer-Bg2NW8qQ.js → stream-tokenizer-UaU7yP0V.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-108bUvwW.js → textMateThemeFromAppTheme-fsNcE7v2.js} +1 -1
- package/dist/assets/{tr-CV2XAmxp.js → tr-DL0uHNVd.js} +1 -1
- package/dist/assets/{uk-C6Tim3xD.js → uk-qdUsCGYW.js} +1 -1
- package/dist/assets/{useAppFontEffects-DDoHSSlY.js → useAppFontEffects-DpDiWkkc.js} +16 -16
- package/dist/assets/{useBranchPullRequestRequest-BC4V7QMF.js → useBranchPullRequestRequest-Cbky4ZeH.js} +1 -1
- package/dist/assets/{useCallableModelProviders-BB_1v9xa.js → useCallableModelProviders-Y8rZzgJF.js} +1 -1
- package/dist/assets/{useDiffFindSurface-DfL3ULLr.js → useDiffFindSurface-B7KQR8iQ.js} +1 -1
- package/dist/assets/{useGitCleanLine-B2KRxywl.js → useGitCleanLine-D6E5eJm2.js} +1 -1
- package/dist/assets/{useInlineCommentController-NSFEerSF.js → useInlineCommentController-CF8aQO6-.js} +1 -1
- package/dist/assets/{useMarkdownLocalAssets-BWW9xfAF.js → useMarkdownLocalAssets-BXBlTj-y.js} +1 -1
- package/dist/assets/{useRootScrollLock-C2bSfyyH.js → useRootScrollLock-3qp1KaTm.js} +2 -2
- package/dist/assets/{useWalkthroughReview-Dfkwhv3f.js → useWalkthroughReview-BNHJ06yD.js} +1 -1
- package/dist/assets/{useWholeFileComment-BHyRIJhM.js → useWholeFileComment-CisbVgb0.js} +1 -1
- package/dist/assets/{useWorktreeArchiveActions-BCFMfuLI.js → useWorktreeArchiveActions-03WxbHUV.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-Bx5Pax1-.js → vendor-codemirror-language-data-C6MZftZF.js} +2 -2
- package/dist/assets/{zh-CN-CdcXp4lU.js → zh-CN-B3B6hhd4.js} +1 -1
- package/dist/assets/{zh-TW-D8q2c56h.js → zh-TW-CBU98qnu.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as Z,j as S,s as J,k as m,g as Y,l as p,W as k,m as ee,H as te,n as ie,o as R,p as re,q as se,t as ne}from"./computeVirtualFileMetrics-ClD-wmbl.js";import{u as Gr}from"./computeVirtualFileMetrics-ClD-wmbl.js";import{fM as x}from"./useAppFontEffects-DDoHSSlY.js";import{a as I,i as W,r as L}from"./isFilePlainText-DDOfZj67.js";import{a as M,b as A,g as b}from"./getFiletypeFromFileName-BgI9McTw.js";import{b as y,i as K,r as V,c as oe,a as ae}from"./isDiffPlainText-un0acoNx.js";import{r as _}from"./resolveLanguages-BpEzCAf_.js";import{a as P}from"./themeResolver-4dbEkEN5.js";import{L as j}from"./vendor-lru_map--CXJ39nE.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-pierre-theming-D_TRfu0q.js";import"./vendor-react--VO_rL_p.js";import"./vendor-scheduler-7OC5HNn7.js";import"./katex.min-CgNRvQ_w.js";import"./vendor-zustand-C9tWdk0j.js";import"./vendor-zod-Csf1sqWl.js";import"./vendor-opencode-client-CqFY51gT.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-streamdown-BbSYZ3NF.js";import"./vendor-markdown-BTUqNk6W.js";import"./vendor-mdast-util-from-markdown-CZHjOE75.js";import"./vendor-micromark-util-decode-numeric-character-reference-CNs1qBpV.js";import"./vendor-micromark-util-decode-string-fHsnqYdj.js";import"./vendor-decode-named-character-reference-C3-224fz.js";import"./vendor-micromark-util-normalize-identifier-C9ANKk3v.js";import"./vendor-micromark-AWM-NZXP.js";import"./vendor-micromark-util-combine-extensions-d8XJZrgA.js";import"./vendor-micromark-util-chunked-DrRIdSP-.js";import"./vendor-micromark-factory-space-PzSHLgmq.js";import"./vendor-micromark-util-character-CW3Cu1MS.js";import"./vendor-micromark-core-commonmark-kzTLNXAm.js";import"./vendor-micromark-util-classify-character-tcLuZZwM.js";import"./vendor-micromark-util-resolve-all-PQCKh0dx.js";import"./vendor-micromark-util-subtokenize-BF1Jf29a.js";import"./vendor-micromark-factory-destination-Sj0xfi0V.js";import"./vendor-micromark-factory-label-amyP0HdC.js";import"./vendor-micromark-factory-title-khnLkZK6.js";import"./vendor-micromark-factory-whitespace-eIB00uTl.js";import"./vendor-micromark-util-html-tag-name-DbKNfynz.js";import"./vendor-unist-util-stringify-position-Ch_qCilz.js";import"./vendor-mdast-util-to-string-C_aolqmU.js";import"./vendor-unist-util-visit-DhPeCsfG.js";import"./vendor-unist-util-visit-parents-DlviEg7Z.js";import"./vendor-unist-util-is-BPZGFiMU.js";import"./vendor-hast-util-raw-DvvLJg15.js";import"./vendor-ungap-structured-clone--gfxRhYI.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-parse5-DwmzEj2o.js";import"./vendor-entities-wUUgTZDW.js";import"./vendor-web-namespaces-bsVAaBS1.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-unist-util-position-60F3QETU.js";import"./vendor-hast-util-from-parse5-Ba3T6RJI.js";import"./vendor-devlop-0Dp3JUBc.js";import"./vendor-property-information-Boo8Xpef.js";import"./vendor-hastscript-BrPNioaz.js";import"./vendor-comma-separated-tokens-CRUGqg4f.js";import"./vendor-space-separated-tokens-D7QSIrTI.js";import"./vendor-hast-util-parse-selector-TXfch5wI.js";import"./vendor-vfile-location-LfEFwJ2h.js";import"./vendor-hast-util-to-parse5-BoysVIPW.js";import"./vendor-hast-util-sanitize-2aGO5ay8.js";import"./vendor-micromark-extension-gfm-CsfPlnlB.js";import"./vendor-micromark-extension-gfm-autolink-literal-BYug7onl.js";import"./vendor-micromark-extension-gfm-footnote-OFl1FCH2.js";import"./vendor-micromark-extension-gfm-strikethrough-CyFiuwBf.js";import"./vendor-micromark-extension-gfm-table-dgw4LfUw.js";import"./vendor-micromark-extension-gfm-task-list-item-Dnadzr9U.js";import"./vendor-mdast-util-gfm-CroMDYLM.js";import"./vendor-mdast-util-gfm-autolink-literal-CTruMtvI.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-mdast-util-find-and-replace-DB9iC-bx.js";import"./vendor-escape-string-regexp-BaJN9MlJ.js";import"./vendor-mdast-util-gfm-footnote-C-csI7OF.js";import"./vendor-mdast-util-gfm-strikethrough-BcskTdio.js";import"./vendor-mdast-util-gfm-table-DhPwQIyj.js";import"./vendor-markdown-table-DvhhVmnL.js";import"./vendor-mdast-util-to-markdown-Cl3qaiyc.js";import"./vendor-longest-streak-CtXnX3Xp.js";import"./vendor-mdast-util-phrasing-4oVbNLC3.js";import"./vendor-mdast-util-gfm-task-list-item-DMU5mK_M.js";import"./vendor-mdast-util-to-hast-CWnLaQSO.js";import"./vendor-micromark-util-sanitize-uri-BbwQ7CLk.js";import"./vendor-trim-lines-D8znQY54.js";import"./vendor-micromark-extension-cjk-friendly-BzZDGrF5.js";import"./vendor-micromark-extension-cjk-friendly-util-D5lVNoxW.js";import"./vendor-get-east-asian-width-CPhS2cOv.js";import"./vendor-micromark-util-symbol-JJPacVTp.js";import"./vendor-mdast-util-to-markdown-cjk-friendly-BZ3pe_qd.js";import"./vendor-micromark-extension-cjk-friendly-gfm-strikethrough-CqW-Ep4M.js";import"./vendor-mdast-util-to-markdown-cjk-friendly-gfm-strikethrough-BdPDQFO7.js";import"./vendor-hast-util-from-html-isomorphic-B0Kn01s9.js";import"./vendor-hast-util-from-dom-DeNf9aYW.js";import"./vendor-katex-DBqql0K7.js";import"./vendor-hast-util-to-text-0GXLnBvt.js";import"./vendor-hast-util-is-element-CuOmiqQi.js";import"./vendor-unist-util-find-after-CMaZmLxc.js";import"./vendor-micromark-extension-math-BRFoDziv.js";import"./vendor-mdast-util-math-wB-IJCL0.js";import"./vendor-remend-r8cP_t-e.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-marked-DN3zOnEe.js";import"./vendor-hast-util-to-jsx-runtime-Bq6JeJCx.js";import"./vendor-style-to-js-CI2G4dgu.js";import"./vendor-style-to-object-BAv4SQXc.js";import"./vendor-inline-style-parser-BlqBsVO4.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-estree-util-is-identifier-name-BgBfM8ME.js";import"./vendor-vfile-message-DqhD22jI.js";import"./vendor-unified-1CQKw2_w.js";import"./vendor-bail-FqpXQuLt.js";import"./vendor-extend-B94qxKr5.js";import"./vendor-is-plain-obj-C1gvLhAf.js";import"./vendor-trough-B_b8ryxu.js";import"./vendor-vfile-BCWrK60u.js";import"./vendor-html-url-attributes-D46m5wfe.js";import"./vendor-capacitor-core-B4EWRrHz.js";import"./vendor-base-ui-zhBy6TEG.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-Cy8dRGoy.js";import"./vendor-use-sync-external-store-CfLJGVyr.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-dnd-kit-core-Br1Cs7RV.js";import"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import"./vendor-dnd-kit-accessibility-CYclfhtC.js";import"./vendor-dnd-kit-sortable-DpfLEOLv.js";import"./vendor-tanstack-react-virtual-C_IilPt1.js";import"./vendor-tanstack-virtual-core-DsQgKrou.js";import"./vendor-framer-motion-C_wK4GIM.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-CjjsURR-.js";import"./vendor-codemirror-state-Cd8udR5z.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-Ciie9ey-.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-8HZTPOnt.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CZEcqU6G.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-DmqaSK_j.js";import"./vendor-lezer-javascript-CWSwshuO.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BGedy2gC.js";import"./vendor-codemirror-lang-json-DVAYKmoO.js";import"./vendor-lezer-json-Cn1mncjr.js";import"./vendor-codemirror-lang-css-BLpgXfL2.js";import"./vendor-lezer-css-B2Hx_Nps.js";import"./vendor-codemirror-lang-html-S3jxr3Mo.js";import"./vendor-lezer-html-Cr8K5DGw.js";import"./vendor-codemirror-lang-markdown-D1jveRI5.js";import"./vendor-lezer-markdown-TQKzBB8i.js";import"./vendor-codemirror-language-data-Bx5Pax1-.js";import"./vendor-codemirror-lang-python-B-5UC9Ui.js";import"./vendor-lezer-python-BUoImtUb.js";import"./vendor-sonner-Dw26OnzC.js";import"./vendor-cmdk-BtSpU-Io.js";import"./vendor-radix-ui-react-dialog-OIW6VLWw.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D4RvEbuR.js";import"./vendor-radix-ui-react-context-BbFoxCHu.js";import"./vendor-radix-ui-react-id-aGag8i_5.js";import"./vendor-radix-ui-react-use-layout-effect-B1oLzD-j.js";import"./vendor-radix-ui-react-use-controllable-state-BjnNPGHq.js";import"./vendor-radix-ui-react-dismissable-layer-DpT6mMbO.js";import"./vendor-radix-ui-react-primitive-CrN9dRDb.js";import"./vendor-radix-ui-react-slot-BjbalUfz.js";import"./vendor-radix-ui-react-use-callback-ref-CcC_buIU.js";import"./vendor-radix-ui-react-use-escape-keydown-Cp1WWKTC.js";import"./vendor-radix-ui-react-focus-scope-D1noLHmd.js";import"./vendor-radix-ui-react-portal-BlUEzfrF.js";import"./vendor-radix-ui-react-presence-BGqFfiW4.js";import"./vendor-radix-ui-react-focus-guards-CSS2IbZC.js";import"./vendor-react-remove-scroll-Der_cv-1.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-Clwl9llp.js";import"./vendor-react-style-singleton-D_xJlTqU.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-BdLl6ZIw.js";import"./vendor-use-callback-ref-CXJF1lEr.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-DAdshx9l.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-diff-C3JhlQdm.js";function N(e){const t=[];for(const i of e){const r=Z.get(i);if(r==null)throw new Error(`getResolvedLanguages: ${i} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(r)}return t}function Q(e){for(const t of Array.isArray(e)?e:[e])if(!Z.has(t))return!1;return!0}function $(e,t=S()){return P(t).getResolvedThemes(e)}function G(e,t=S()){return P(t).hasResolvedThemes(e)}function U(e,t=S()){return P(t).resolveThemes(e)}const X=0,he=1,le=2,ce=4,ue=5,de=6,fe=[void 0,null,!0,!1];function O(e){if(Array.isArray(e))return e;const{ops:t,offsets:i,strings:r,text:n,extras:s}=e,o=new Array(i.length/2);let a=0,l=0;function c(h){const f=new Array(h);for(let u=0;u<h;u++){const g=t[a++];if(g!==X)if(g===he){const q=l+t[a++];f[u]={type:"text",value:n.slice(l,q)},l=q}else if(g===le){const q=r[t[a++]],E={};for(let z=t[a++];z>0;z--){const H=r[t[a++]],w=t[a++],D=w===ce?r[t[a++]]:w===ue?t[a++]:w===de?s[t[a++]]:fe[w];H==="__proto__"?Object.defineProperty(E,H,{value:D,enumerable:!0,configurable:!0,writable:!0}):E[H]=D}f[u]={type:"element",tagName:q,properties:E,children:c(t[a++])}}else f[u]=s[t[a++]]}return f}for(let h=0;h<o.length;h++)t[i[h*2]]!==X&&J(o,h,()=>(a=i[h*2],l=i[h*2+1],c(1)[0]));return o}const v=Symbol("IGNORE_RESPONSE"),ge=1e4;var pe=class{options;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;terminated=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:i=x,useTokenTransformer:r=!1,lineDiffType:n="word-alt",maxLineDiffLength:s=1e3,tokenizeMaxLineLength:o=1e3,preferredHighlighter:a}){this.options=e,this.preferredHighlighter=S(a),this.renderOptions={theme:i,useTokenTransformer:r,lineDiffType:n,maxLineDiffLength:s,tokenizeMaxLineLength:o},this.fileCache=new j.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new j.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed&&!this.terminated}shouldHighlightOnMainThread(e){const{mainThreadMaxCharacters:t=-1}=this.options;return("contents"in e?e.contents.length:e.deletionCharacterCount+e.additionCharacterCount)<=t}getFileResultCache(e){return e.cacheKey!=null?this.fileCache.get(e.cacheKey):void 0}getDiffResultCache(e){return e.cacheKey!=null?this.diffCache.get(e.cacheKey):void 0}setFileResultCache(e,{result:t,options:i}){return e==null||!I(i,this.getFileRenderOptions())?!1:(this.fileCache.set(e,{result:t,options:i}),this.queueBroadcastStateChanges(),!0)}setDiffResultCache(e,{result:t,options:i}){return e==null||!y(i,this.getDiffRenderOptions())?!1:(this.diffCache.set(e,{result:t,options:i}),this.queueBroadcastStateChanges(),!0)}inspectCaches(){const{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??x,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:i=this.renderOptions.lineDiffType??"word-alt",maxLineDiffLength:r=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:n=this.renderOptions.tokenizeMaxLineLength??1e3}){const{lifecycleGeneration:s}=this,o=++this.renderOptionsRequestVersion,a=()=>this.isCurrentLifecycle(s)&&this.renderOptionsRequestVersion===o;try{const l={theme:e,useTokenTransformer:t,lineDiffType:i,maxLineDiffLength:r,tokenizeMaxLineLength:n};if(!this.isInitialized())try{await this.initialize()}catch(u){if(!this.workersFailed)throw u}if(!a()||y(l,this.renderOptions))return;const c=m(e);let h=[];if(Y(l.theme,this.renderOptions.theme)||(h=G(c,this.preferredHighlighter)?$(c,this.preferredHighlighter):await U(c,this.preferredHighlighter)),!a()||p({theme:e})==null&&(await this.loadSharedHighlighter(c,["text"]),!a()))return;const f=this.setRenderOptionsOnWorkers(l,h);this.renderOptions=l,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(const u of this.themeSubscribers)u.onThemeChange();await f}catch(l){if(l instanceof k||!a())return;throw l}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){const{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:i}=this.renderOptions;return{theme:t,useTokenTransformer:i,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;this.isInitialized()||await this.initialize();const i=[];for(const r of this.workers){if(!r.initialized)throw console.log({managedWorker:r}),new Error("setRenderOptionsOnWorkers: Somehow we have an uninitialized worker");i.push(new Promise((n,s)=>{const o=this.generateRequestId(),a={type:"set-render-options",id:o,request:{type:"set-render-options",id:o,renderOptions:e,resolvedThemes:t},resolve:n,reject:s,requestStart:Date.now()};this.activeTaskById.set(o,a),r.pendingSetupRequestId=o,r.worker.postMessage(a.request)}))}await Promise.all(i)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){this._queuedBroadcast==null&&(this._queuedBroadcast=requestAnimationFrame(this._broadcastStateChanges))}_broadcastStateChanges=()=>{this._queuedBroadcast!=null&&(cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0);const e=this.getStats();for(const t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);const t=this.activeRequestByInstance.get(e);if(t!=null){const i=this.activeTaskById.get(t);d(i)?(this.detachInstanceFromRenderTask(i,e),!i.primeCache&&i.instances.size===0&&this.removeActiveTask(i)):this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized===!0){p({theme:this.renderOptions.theme})==null&&await this.loadSharedHighlighter(m(this.renderOptions.theme),["text",...e]);return}else if(this.initialized===!1){this.terminated=!1;const{lifecycleGeneration:t}=this,i=new Promise((r,n)=>{(async()=>{try{const s=m(this.renderOptions.theme),o=G(s,this.preferredHighlighter)?$(s,this.preferredHighlighter):await U(s,this.preferredHighlighter);if(!this.isCurrentLifecycle(t)){r();return}let a=[];if(this.preferredHighlighter!=="highlights"&&(a=Q(e)?N(e):await _(e)),!this.isCurrentLifecycle(t)){r();return}if(await Promise.all([this.loadSharedHighlighter(s,["text",...e]),this.initializeWorkers(o,a)]),!this.isCurrentLifecycle(t)){this.terminateWorkers(),r();return}this.initialized=!0,this.drainQueue(),this.queueBroadcastStateChanges(),r()}catch(s){if(s instanceof k||!this.isCurrentLifecycle(t)){r();return}this.initialized=!1,this.workersFailed=!0,this.cancelActiveWorkerTasks(),this.terminateWorkers(),this.activeTaskById.clear();for(const o of this.queuedTasks)this.rejectRenderTaskCallbacks(o,F(s));this.queueBroadcastStateChanges(),n(s)}})()});return this.initialized=i,this.queueBroadcastStateChanges(),i}else return this.initialized}async loadSharedHighlighter(e,t){try{await ee({themes:e,langs:t,preferredHighlighter:this.preferredHighlighter})}catch(i){if(!(i instanceof te))throw i}}async initializeWorkers(e,t){this.workersFailed=!1;const i=[],r=A(),n=r>0?M():void 0;this.workers.length>0&&this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){const l=this.options.workerFactory(),c={worker:l,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set(["text",...t.map(({name:h})=>h)]),customExtensionsVersion:0};l.addEventListener("message",h=>{this.handleWorkerMessage(c,h.data)}),l.addEventListener("error",h=>this.handleWorkerError(c,h)),this.workers.push(c),i.push(new Promise((h,f)=>{const u=this.generateRequestId(),g={type:"initialize",id:u,request:{type:"initialize",resultFormat:"hast-ops-v1",id:u,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:n!=null?r:void 0,customExtensionMap:n},resolve(){c.initialized=!0,h()},reject:f,requestStart:Date.now()};c.pendingSetupRequestId=u,this.activeTaskById.set(u,g),this.executeTask(c,g)}))}const s=this.options.workerInitializationTimeout??ge;let o;try{await Promise.race([Promise.all(i),new Promise((a,l)=>{o=setTimeout(()=>{l(new Error(`WorkerPoolManager: worker initialization timed out after ${s}ms`))},s)})])}finally{o!=null&&clearTimeout(o)}}handleWorkerError(e,t){const{onWorkerError:i}=this.options;if(i!=null)try{i(t,e.worker)}catch(o){console.error("WorkerPoolManager: onWorkerError threw:",o)}else console.error("Worker error:",t,e);const{pendingSetupRequestId:r}=e;if(r==null)return;const n=this.activeTaskById.get(r);if(n?.type!=="initialize")return;const s=ke(t);i!=null&&ie(s),n.reject(s),this.cleanWorkerAndTask(e,n)}drainQueue=()=>{if(this._queuedDrain=void 0,!(this.initialized!==!0||this.queuedTasks.length===0)){for(let e=0;e<this.queuedTasks.length;){const t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}const i=B(t.request),r=this.getAvailableWorker(i);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,i)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){const i=this.getFileResultCache(t);W(t)||i!=null&&I(i.options,this.getFileRenderOptions())||this.hasMatchingFileInstanceTask(e,t)||this.submitTask(e,{type:"file",file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(new Error("WorkerPoolManager.primeFileHighlightCache: worker pool is not working"));if(!this.shouldPrimeFileHighlightCache(e))return Promise.resolve();if(this.shouldHighlightOnMainThread(e)){const i=this.getFileRenderOptions();return this.primeHighlightCacheOnMainThread(B({type:"file",file:e}),i.theme,r=>this.setFileResultCache(e.cacheKey,{result:L(e,r,i),options:i}))}const t=this.getOrCreateFileHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}shouldPrimeFileHighlightCache(e){if(e.cacheKey==null)return console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`),!1;const t=this.getFileResultCache(e);return!W(e)&&(t==null||!I(t.options,this.getFileRenderOptions()))}getOrCreateFileHighlightCacheTask(e){const t=this.getFileHighlightKey(e);if(t==null)return;const i=this.getTaskByHighlightKey(t);if(i!=null){if(i.type!=="file")throw new Error("WorkerPoolManager.getOrCreateFileHighlightCacheTask: Invalid task type");return i.primeCache=!0,i}else{const r=this.submitCacheTask({type:"file",file:e},t);if(r.type!=="file")throw new Error("WorkerPoolManager.getOrCreateFileHighlightCacheTask: Invalid task created");return r}}getPlainFileAST(e,t,i,r){const n=p({theme:this.renderOptions.theme});if(n==null){this.queueInitialization();return}return L(e,n,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,lines:r})}highlightDiffAST(e,t){const i=this.getDiffResultCache(t);K(t)||i!=null&&y(i.options,this.getDiffRenderOptions())||this.hasMatchingDiffInstanceTask(e,t)||this.submitTask(e,{type:"diff",diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(new Error("WorkerPoolManager.primeDiffHighlightCache: worker pool is not working"));if(!this.shouldPrimeDiffHighlightCache(e))return Promise.resolve();if(this.shouldHighlightOnMainThread(e)){const i=this.getDiffRenderOptions();return this.primeHighlightCacheOnMainThread(B({type:"diff",diff:e}),i.theme,r=>this.setDiffResultCache(e.cacheKey,{result:V(e,r,i),options:i}))}const t=this.getOrCreateDiffHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}shouldPrimeDiffHighlightCache(e){if(e.cacheKey==null)return console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`),!1;const t=this.getDiffResultCache(e);return!K(e)&&(t==null||!y(t.options,this.getDiffRenderOptions()))}primeHighlightCacheOnMainThread(e,t,i){function r(){const s=p({theme:t,langs:e});return s!=null&&i(s)}if(r())return Promise.resolve();const{lifecycleGeneration:n}=this;return this.loadSharedHighlighter(m(t),["text",...e]).then(()=>{if(!this.isCurrentLifecycle(n))throw new k;if(!r())throw new R})}getOrCreateDiffHighlightCacheTask(e){const t=this.getDiffHighlightKey(e);if(t==null)return;const i=this.getTaskByHighlightKey(t);if(i!=null){if(i.type!=="diff")throw new Error("WorkerPoolManager.getOrCreateDiffHighlightCacheTask: Invalid task type");return i.primeCache=!0,i}else{const r=this.submitCacheTask({type:"diff",diff:e},t);if(r.type!=="diff")throw new Error("WorkerPoolManager.getOrCreateDiffHighlightCacheTask: Invalid task created");return r}}getPlainDiffAST(e,t,i,r,n){const s=p({theme:this.renderOptions.theme});if(s==null){this.queueInitialization();return}return V(e,s,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,expandedHunks:r,collapsedContextThreshold:n})}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();const e=new k;for(const t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.initialized=!1,this.workersFailed=!1,this.terminated=!0,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch(t=>{re(t)||console.error(t)})}cancelActiveWorkerTasks(){const e=new k;for(const t of this.activeTaskById.values())"reject"in t?t.reject(e):d(t)&&this.rejectRenderTaskCallbacks(t,e)}terminateWorkers(){for(const e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:this.initialized===!1?"waiting":this.initialized!==!0?"initializing":"initialized",totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter(e=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){this.initialized===!1&&this.queueInitialization();const i=this.getHighlightKeyForRequest(t),r=i!=null?this.getTaskByHighlightKey(i):void 0;if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);const n=this.generateRequestId(),s=Date.now(),{renderOptionsVersion:o}=this,a=(()=>{switch(t.type){case"file":return{type:"file",id:n,request:{...t,id:n},instances:new Set([e]),primeCache:!1,highlightKey:i,callbacks:new Set,renderOptionsVersion:o,requestStart:s};case"diff":return{type:"diff",id:n,request:{...t,id:n},instances:new Set([e]),primeCache:!1,highlightKey:i,callbacks:new Set,renderOptionsVersion:o,requestStart:s}}})();this.enqueueRenderTask(a,e)}submitCacheTask(e,t){this.initialized===!1&&this.queueInitialization();const i=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:n}=this,s=(()=>{switch(e.type){case"file":return{type:"file",id:i,request:{...e,id:i},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:n,requestStart:r};case"diff":return{type:"diff",id:i,request:{...e,id:i},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:n,requestStart:r}}})();return this.enqueueRenderTask(s),s}enqueueRenderTask(e,t){this.queuedTasks.push(e),t!=null&&this.queuedTaskByInstance.set(t,e),e.highlightKey!=null&&this.taskByHighlightKey.set(e.highlightKey,e),this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,i){try{const r=p(),n=i.filter(o=>r==null||!se(o,r));n.length>0&&this.loadSharedHighlighter(m(this.renderOptions.theme),["text",...n]).catch(o=>{console.error(o)});const s=this.preferredHighlighter==="highlights"?[]:i.filter(o=>!e.langs.has(o));if(s.length>0&&(Q(s)?t.request.resolvedLanguages=N(s):t.request.resolvedLanguages=await _(s)),!this.activeTaskById.has(t.id)){e.requestId===t.id&&(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain());return}this.executeTask(e,t)}catch(r){this.rejectRenderTaskCallbacks(t,F(r)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}}handleWorkerMessage(e,t){const i=this.activeTaskById.get(t.id);try{if(i==null)throw v;if(t.type==="error"){const r=new Error(t.error);if(t.stack&&(r.stack=t.stack),"reject"in i)i.reject(r);else if(d(i))this.notifyHighlightError(i,r),this.rejectRenderTaskCallbacks(i,r);else throw new Error("handleWorkerMessage: unknown task type");throw r}else{if(d(i))for(const{name:r}of i.request.resolvedLanguages??[])e.langs.add(r);switch(t.requestType){case"initialize":if(i.type!=="initialize")throw new Error("handleWorkerMessage: task/response dont match");this.syncCustomExtensionVersion(e,i.request),i.resolve();break;case"set-render-options":if(i.type!=="set-render-options")throw new Error("handleWorkerMessage: task/response dont match");i.resolve();break;case"file":{if(i.type!=="file")throw new Error("handleWorkerMessage: task/response dont match");const{options:r}=t;if(!this.isCurrentRenderTask(i)||!I(r,this.getFileRenderOptions()))throw v;const{request:n}=i,s={...t.result,code:O(t.result.code)};this.syncCustomExtensionVersion(e,n),i.cacheKeyAtDispatch!=null&&this.fileCache.set(i.cacheKeyAtDispatch,{result:s,options:r}),this.resolveRenderTaskCallbacks(i),this.notifyFileInstances(i,s,r);break}case"diff":{if(i.type!=="diff")throw new Error("handleWorkerMessage: task/response dont match");const{options:r}=t;if(!this.isCurrentRenderTask(i)||!y(r,this.getDiffRenderOptions()))throw v;const{request:n}=i,s={...t.result,code:{deletionLines:O(t.result.code.deletionLines),additionLines:O(t.result.code.additionLines)}};this.syncCustomExtensionVersion(e,n),i.cacheKeyAtDispatch!=null&&this.diffCache.set(i.cacheKeyAtDispatch,{result:s,options:r}),this.resolveRenderTaskCallbacks(i),this.notifyDiffInstances(i,s,r);break}}}}catch(r){r!==v&&console.error(r,i,t)}this.cleanWorkerAndTask(e,i,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}_queuedDrain;queueDrain(){this._queuedDrain==null&&(this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges())}assignWorkerToTask(e,t){t.requestId=e.id,d(e)&&(this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e)),this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,i=t?.id){e.requestId===i&&(e.requestId=void 0),e.pendingSetupRequestId===i&&(e.pendingSetupRequestId=void 0),t!=null&&(d(t)&&(this.rejectRenderTaskCallbacks(t,new R),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){me(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);try{t.type==="file"?t.cacheKeyAtDispatch=t.request.file.cacheKey:t.type==="diff"&&(t.cacheKeyAtDispatch=t.request.diff.cacheKey),e.worker.postMessage(t.request)}catch(i){console.error("Failed to post message to worker:",i),d(t)?(this.notifyHighlightError(t,i),this.rejectRenderTaskCallbacks(t,F(i))):"reject"in t&&t.reject(i),this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0&&this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;const i=A();e.customExtensionsVersion>=i||(t.customExtensionsVersion=i,t.customExtensionMap=M())}syncCustomExtensionVersion(e,t){t.customExtensionsVersion!=null&&(e.customExtensionsVersion=t.customExtensionsVersion)}getAvailableWorker(e){let t;for(const i of this.workers){if(i.requestId!=null||i.pendingSetupRequestId!=null||!i.initialized)continue;if(t=i,e.length===0)break;let r=!0;for(const n of e)if(!i.langs.has(n)){r=!1;break}if(r)break}return t}getFileHighlightKey(e){if(e.cacheKey!=null)return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey!=null)return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case"file":return this.getFileHighlightKey(e.file);case"diff":return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(const t of T(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){e.type,e.instances.add(t),this.activeTaskById.has(e.id)?this.activeRequestByInstance.set(t,e.id):this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){const i=this.queuedTaskByInstance.get(e);i==null||i===t||(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(i,e),!i.primeCache&&i.instances.size===0&&this.removeQueuedTask(i))}detachInstanceFromRenderTask(e,t){e.type,e.instances.delete(t)}removeQueuedTask(e){const t=this.queuedTasks.indexOf(e);t!==-1&&this.queuedTasks.splice(t,1),this.rejectRenderTaskCallbacks(e,new R),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new R),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,i)=>{e.callbacks.add({resolve:t,reject:i})})}resolveRenderTaskCallbacks(e){for(const t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(const i of e.callbacks)i.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){const t=this.queuedTasks[e];t.renderOptionsVersion!==this.renderOptionsVersion&&this.removeQueuedTask(t)}for(const e of Array.from(this.activeTaskById.values()))d(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(const t of T(e))this.queuedTaskByInstance.get(t)===e&&this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e&&this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(const t of T(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(const t of T(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,i){for(const r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.file,t,i)}notifyDiffInstances(e,t,i){for(const r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.diff,t,i)}notifyHighlightError(e,t){for(const i of T(e))this.activeRequestByInstance.get(i)===e.id&&i.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(const i of this.iterateRenderTasks())if(i.type==="file"&&this.isCurrentRenderTask(i)&&i.instances.has(e)&&oe(t,i.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(const i of this.iterateRenderTasks())if(i.type==="diff"&&this.isCurrentRenderTask(i)&&i.instances.has(e)&&ae(i.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){const t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(const e of this.queuedTasks)yield e;for(const e of this.activeTaskById.values())d(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function me(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function B(e){const t=new Set;switch(e.type){case"file":t.add(e.file.lang??b(e.file.name));break;case"diff":t.add(e.diff.lang??b(e.diff.name)),t.add(e.diff.lang??b(e.diff.prevName??"-"))}return t.delete("text"),Array.from(t)}function d(e){return e?.type==="file"||e?.type==="diff"}function T(e){return e.instances}function F(e){if(e instanceof Error)return e;if(e!=null&&typeof e=="object"){if("error"in e&&e.error instanceof Error)return e.error;if("message"in e&&typeof e.message=="string")return new Error(e.message)}return new Error(String(e))}function ke(e){const t="error"in e?e.error:void 0,i="message"in e&&typeof e.message=="string"&&e.message!==""?e.message:t instanceof Error?t.message:"the worker script failed to load (the error event carries no message)";return new ne(`WorkerPoolManager: worker failed: ${i}`,t instanceof Error?{cause:t}:void 0)}let C;function jr({poolOptions:e,highlighterOptions:t}){return C??=new pe(e,t),C}function Nr(){C!=null&&(C.terminate(),C=void 0)}export{pe as WorkerPoolManager,R as WorkerPoolTaskCanceledError,k as WorkerPoolTerminatedError,ne as WorkerPoolWorkerError,jr as getOrCreateWorkerPoolSingleton,re as isHandledWorkerPoolError,Gr as isWorkerPoolCancellation,Nr as terminateWorkerPoolSingleton};
|
|
1
|
+
import{b as Z,j as S,s as J,k as m,g as Y,l as p,W as k,m as ee,H as te,n as ie,o as R,p as re,q as se,t as ne}from"./computeVirtualFileMetrics-BhVDZ-oP.js";import{u as Gr}from"./computeVirtualFileMetrics-BhVDZ-oP.js";import{fM as x}from"./useAppFontEffects-DpDiWkkc.js";import{a as I,i as W,r as L}from"./isFilePlainText-BqR4iT-Y.js";import{a as M,b as A,g as b}from"./getFiletypeFromFileName-BgI9McTw.js";import{b as y,i as K,r as V,c as oe,a as ae}from"./isDiffPlainText-DUd8YJX0.js";import{r as _}from"./resolveLanguages-DHAaVkki.js";import{a as P}from"./themeResolver-4dbEkEN5.js";import{L as j}from"./vendor-lru_map--CXJ39nE.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-pierre-theming-D_TRfu0q.js";import"./vendor-react--VO_rL_p.js";import"./vendor-scheduler-7OC5HNn7.js";import"./katex.min-BBVkbKQY.js";import"./vendor-zustand-C9tWdk0j.js";import"./vendor-zod-Csf1sqWl.js";import"./vendor-opencode-client-CqFY51gT.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-streamdown-BbSYZ3NF.js";import"./vendor-markdown-BTUqNk6W.js";import"./vendor-mdast-util-from-markdown-CZHjOE75.js";import"./vendor-micromark-util-decode-numeric-character-reference-CNs1qBpV.js";import"./vendor-micromark-util-decode-string-fHsnqYdj.js";import"./vendor-decode-named-character-reference-C3-224fz.js";import"./vendor-micromark-util-normalize-identifier-C9ANKk3v.js";import"./vendor-micromark-AWM-NZXP.js";import"./vendor-micromark-util-combine-extensions-d8XJZrgA.js";import"./vendor-micromark-util-chunked-DrRIdSP-.js";import"./vendor-micromark-factory-space-PzSHLgmq.js";import"./vendor-micromark-util-character-CW3Cu1MS.js";import"./vendor-micromark-core-commonmark-kzTLNXAm.js";import"./vendor-micromark-util-classify-character-tcLuZZwM.js";import"./vendor-micromark-util-resolve-all-PQCKh0dx.js";import"./vendor-micromark-util-subtokenize-BF1Jf29a.js";import"./vendor-micromark-factory-destination-Sj0xfi0V.js";import"./vendor-micromark-factory-label-amyP0HdC.js";import"./vendor-micromark-factory-title-khnLkZK6.js";import"./vendor-micromark-factory-whitespace-eIB00uTl.js";import"./vendor-micromark-util-html-tag-name-DbKNfynz.js";import"./vendor-unist-util-stringify-position-Ch_qCilz.js";import"./vendor-mdast-util-to-string-C_aolqmU.js";import"./vendor-unist-util-visit-DhPeCsfG.js";import"./vendor-unist-util-visit-parents-DlviEg7Z.js";import"./vendor-unist-util-is-BPZGFiMU.js";import"./vendor-hast-util-raw-DvvLJg15.js";import"./vendor-ungap-structured-clone--gfxRhYI.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-parse5-DwmzEj2o.js";import"./vendor-entities-wUUgTZDW.js";import"./vendor-web-namespaces-bsVAaBS1.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-unist-util-position-60F3QETU.js";import"./vendor-hast-util-from-parse5-Ba3T6RJI.js";import"./vendor-devlop-0Dp3JUBc.js";import"./vendor-property-information-Boo8Xpef.js";import"./vendor-hastscript-BrPNioaz.js";import"./vendor-comma-separated-tokens-CRUGqg4f.js";import"./vendor-space-separated-tokens-D7QSIrTI.js";import"./vendor-hast-util-parse-selector-TXfch5wI.js";import"./vendor-vfile-location-LfEFwJ2h.js";import"./vendor-hast-util-to-parse5-BoysVIPW.js";import"./vendor-hast-util-sanitize-2aGO5ay8.js";import"./vendor-micromark-extension-gfm-CsfPlnlB.js";import"./vendor-micromark-extension-gfm-autolink-literal-BYug7onl.js";import"./vendor-micromark-extension-gfm-footnote-OFl1FCH2.js";import"./vendor-micromark-extension-gfm-strikethrough-CyFiuwBf.js";import"./vendor-micromark-extension-gfm-table-dgw4LfUw.js";import"./vendor-micromark-extension-gfm-task-list-item-Dnadzr9U.js";import"./vendor-mdast-util-gfm-CroMDYLM.js";import"./vendor-mdast-util-gfm-autolink-literal-CTruMtvI.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-mdast-util-find-and-replace-DB9iC-bx.js";import"./vendor-escape-string-regexp-BaJN9MlJ.js";import"./vendor-mdast-util-gfm-footnote-C-csI7OF.js";import"./vendor-mdast-util-gfm-strikethrough-BcskTdio.js";import"./vendor-mdast-util-gfm-table-DhPwQIyj.js";import"./vendor-markdown-table-DvhhVmnL.js";import"./vendor-mdast-util-to-markdown-Cl3qaiyc.js";import"./vendor-longest-streak-CtXnX3Xp.js";import"./vendor-mdast-util-phrasing-4oVbNLC3.js";import"./vendor-mdast-util-gfm-task-list-item-DMU5mK_M.js";import"./vendor-mdast-util-to-hast-CWnLaQSO.js";import"./vendor-micromark-util-sanitize-uri-BbwQ7CLk.js";import"./vendor-trim-lines-D8znQY54.js";import"./vendor-micromark-extension-cjk-friendly-BzZDGrF5.js";import"./vendor-micromark-extension-cjk-friendly-util-D5lVNoxW.js";import"./vendor-get-east-asian-width-CPhS2cOv.js";import"./vendor-micromark-util-symbol-JJPacVTp.js";import"./vendor-mdast-util-to-markdown-cjk-friendly-BZ3pe_qd.js";import"./vendor-micromark-extension-cjk-friendly-gfm-strikethrough-CqW-Ep4M.js";import"./vendor-mdast-util-to-markdown-cjk-friendly-gfm-strikethrough-BdPDQFO7.js";import"./vendor-hast-util-from-html-isomorphic-B0Kn01s9.js";import"./vendor-hast-util-from-dom-DeNf9aYW.js";import"./vendor-katex-DBqql0K7.js";import"./vendor-hast-util-to-text-0GXLnBvt.js";import"./vendor-hast-util-is-element-CuOmiqQi.js";import"./vendor-unist-util-find-after-CMaZmLxc.js";import"./vendor-micromark-extension-math-BRFoDziv.js";import"./vendor-mdast-util-math-wB-IJCL0.js";import"./vendor-remend-r8cP_t-e.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-marked-DN3zOnEe.js";import"./vendor-hast-util-to-jsx-runtime-Bq6JeJCx.js";import"./vendor-style-to-js-CI2G4dgu.js";import"./vendor-style-to-object-BAv4SQXc.js";import"./vendor-inline-style-parser-BlqBsVO4.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-estree-util-is-identifier-name-BgBfM8ME.js";import"./vendor-vfile-message-DqhD22jI.js";import"./vendor-unified-1CQKw2_w.js";import"./vendor-bail-FqpXQuLt.js";import"./vendor-extend-B94qxKr5.js";import"./vendor-is-plain-obj-C1gvLhAf.js";import"./vendor-trough-B_b8ryxu.js";import"./vendor-vfile-BCWrK60u.js";import"./vendor-html-url-attributes-D46m5wfe.js";import"./vendor-capacitor-core-B4EWRrHz.js";import"./vendor-base-ui-zhBy6TEG.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-Cy8dRGoy.js";import"./vendor-use-sync-external-store-CfLJGVyr.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-dnd-kit-core-Br1Cs7RV.js";import"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import"./vendor-dnd-kit-accessibility-CYclfhtC.js";import"./vendor-dnd-kit-sortable-DpfLEOLv.js";import"./vendor-tanstack-react-virtual-C_IilPt1.js";import"./vendor-tanstack-virtual-core-DsQgKrou.js";import"./vendor-framer-motion-C_wK4GIM.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-CjjsURR-.js";import"./vendor-codemirror-state-Cd8udR5z.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-Ciie9ey-.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-8HZTPOnt.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CZEcqU6G.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-DmqaSK_j.js";import"./vendor-lezer-javascript-CWSwshuO.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BGedy2gC.js";import"./vendor-codemirror-lang-json-DVAYKmoO.js";import"./vendor-lezer-json-Cn1mncjr.js";import"./vendor-codemirror-lang-css-BLpgXfL2.js";import"./vendor-lezer-css-B2Hx_Nps.js";import"./vendor-codemirror-lang-html-S3jxr3Mo.js";import"./vendor-lezer-html-Cr8K5DGw.js";import"./vendor-codemirror-lang-markdown-D1jveRI5.js";import"./vendor-lezer-markdown-TQKzBB8i.js";import"./vendor-codemirror-language-data-C6MZftZF.js";import"./vendor-codemirror-lang-python-B-5UC9Ui.js";import"./vendor-lezer-python-BUoImtUb.js";import"./vendor-sonner-Dw26OnzC.js";import"./vendor-cmdk-BtSpU-Io.js";import"./vendor-radix-ui-react-dialog-OIW6VLWw.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D4RvEbuR.js";import"./vendor-radix-ui-react-context-BbFoxCHu.js";import"./vendor-radix-ui-react-id-aGag8i_5.js";import"./vendor-radix-ui-react-use-layout-effect-B1oLzD-j.js";import"./vendor-radix-ui-react-use-controllable-state-BjnNPGHq.js";import"./vendor-radix-ui-react-dismissable-layer-DpT6mMbO.js";import"./vendor-radix-ui-react-primitive-CrN9dRDb.js";import"./vendor-radix-ui-react-slot-BjbalUfz.js";import"./vendor-radix-ui-react-use-callback-ref-CcC_buIU.js";import"./vendor-radix-ui-react-use-escape-keydown-Cp1WWKTC.js";import"./vendor-radix-ui-react-focus-scope-D1noLHmd.js";import"./vendor-radix-ui-react-portal-BlUEzfrF.js";import"./vendor-radix-ui-react-presence-BGqFfiW4.js";import"./vendor-radix-ui-react-focus-guards-CSS2IbZC.js";import"./vendor-react-remove-scroll-Der_cv-1.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-Clwl9llp.js";import"./vendor-react-style-singleton-D_xJlTqU.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-BdLl6ZIw.js";import"./vendor-use-callback-ref-CXJF1lEr.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-DAdshx9l.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-diff-C3JhlQdm.js";function N(e){const t=[];for(const i of e){const r=Z.get(i);if(r==null)throw new Error(`getResolvedLanguages: ${i} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(r)}return t}function Q(e){for(const t of Array.isArray(e)?e:[e])if(!Z.has(t))return!1;return!0}function $(e,t=S()){return P(t).getResolvedThemes(e)}function G(e,t=S()){return P(t).hasResolvedThemes(e)}function U(e,t=S()){return P(t).resolveThemes(e)}const X=0,he=1,le=2,ce=4,ue=5,de=6,fe=[void 0,null,!0,!1];function O(e){if(Array.isArray(e))return e;const{ops:t,offsets:i,strings:r,text:n,extras:s}=e,o=new Array(i.length/2);let a=0,l=0;function c(h){const f=new Array(h);for(let u=0;u<h;u++){const g=t[a++];if(g!==X)if(g===he){const q=l+t[a++];f[u]={type:"text",value:n.slice(l,q)},l=q}else if(g===le){const q=r[t[a++]],E={};for(let z=t[a++];z>0;z--){const H=r[t[a++]],w=t[a++],D=w===ce?r[t[a++]]:w===ue?t[a++]:w===de?s[t[a++]]:fe[w];H==="__proto__"?Object.defineProperty(E,H,{value:D,enumerable:!0,configurable:!0,writable:!0}):E[H]=D}f[u]={type:"element",tagName:q,properties:E,children:c(t[a++])}}else f[u]=s[t[a++]]}return f}for(let h=0;h<o.length;h++)t[i[h*2]]!==X&&J(o,h,()=>(a=i[h*2],l=i[h*2+1],c(1)[0]));return o}const v=Symbol("IGNORE_RESPONSE"),ge=1e4;var pe=class{options;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;terminated=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:i=x,useTokenTransformer:r=!1,lineDiffType:n="word-alt",maxLineDiffLength:s=1e3,tokenizeMaxLineLength:o=1e3,preferredHighlighter:a}){this.options=e,this.preferredHighlighter=S(a),this.renderOptions={theme:i,useTokenTransformer:r,lineDiffType:n,maxLineDiffLength:s,tokenizeMaxLineLength:o},this.fileCache=new j.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new j.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed&&!this.terminated}shouldHighlightOnMainThread(e){const{mainThreadMaxCharacters:t=-1}=this.options;return("contents"in e?e.contents.length:e.deletionCharacterCount+e.additionCharacterCount)<=t}getFileResultCache(e){return e.cacheKey!=null?this.fileCache.get(e.cacheKey):void 0}getDiffResultCache(e){return e.cacheKey!=null?this.diffCache.get(e.cacheKey):void 0}setFileResultCache(e,{result:t,options:i}){return e==null||!I(i,this.getFileRenderOptions())?!1:(this.fileCache.set(e,{result:t,options:i}),this.queueBroadcastStateChanges(),!0)}setDiffResultCache(e,{result:t,options:i}){return e==null||!y(i,this.getDiffRenderOptions())?!1:(this.diffCache.set(e,{result:t,options:i}),this.queueBroadcastStateChanges(),!0)}inspectCaches(){const{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??x,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:i=this.renderOptions.lineDiffType??"word-alt",maxLineDiffLength:r=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:n=this.renderOptions.tokenizeMaxLineLength??1e3}){const{lifecycleGeneration:s}=this,o=++this.renderOptionsRequestVersion,a=()=>this.isCurrentLifecycle(s)&&this.renderOptionsRequestVersion===o;try{const l={theme:e,useTokenTransformer:t,lineDiffType:i,maxLineDiffLength:r,tokenizeMaxLineLength:n};if(!this.isInitialized())try{await this.initialize()}catch(u){if(!this.workersFailed)throw u}if(!a()||y(l,this.renderOptions))return;const c=m(e);let h=[];if(Y(l.theme,this.renderOptions.theme)||(h=G(c,this.preferredHighlighter)?$(c,this.preferredHighlighter):await U(c,this.preferredHighlighter)),!a()||p({theme:e})==null&&(await this.loadSharedHighlighter(c,["text"]),!a()))return;const f=this.setRenderOptionsOnWorkers(l,h);this.renderOptions=l,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(const u of this.themeSubscribers)u.onThemeChange();await f}catch(l){if(l instanceof k||!a())return;throw l}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){const{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:i}=this.renderOptions;return{theme:t,useTokenTransformer:i,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;this.isInitialized()||await this.initialize();const i=[];for(const r of this.workers){if(!r.initialized)throw console.log({managedWorker:r}),new Error("setRenderOptionsOnWorkers: Somehow we have an uninitialized worker");i.push(new Promise((n,s)=>{const o=this.generateRequestId(),a={type:"set-render-options",id:o,request:{type:"set-render-options",id:o,renderOptions:e,resolvedThemes:t},resolve:n,reject:s,requestStart:Date.now()};this.activeTaskById.set(o,a),r.pendingSetupRequestId=o,r.worker.postMessage(a.request)}))}await Promise.all(i)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){this._queuedBroadcast==null&&(this._queuedBroadcast=requestAnimationFrame(this._broadcastStateChanges))}_broadcastStateChanges=()=>{this._queuedBroadcast!=null&&(cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0);const e=this.getStats();for(const t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);const t=this.activeRequestByInstance.get(e);if(t!=null){const i=this.activeTaskById.get(t);d(i)?(this.detachInstanceFromRenderTask(i,e),!i.primeCache&&i.instances.size===0&&this.removeActiveTask(i)):this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized===!0){p({theme:this.renderOptions.theme})==null&&await this.loadSharedHighlighter(m(this.renderOptions.theme),["text",...e]);return}else if(this.initialized===!1){this.terminated=!1;const{lifecycleGeneration:t}=this,i=new Promise((r,n)=>{(async()=>{try{const s=m(this.renderOptions.theme),o=G(s,this.preferredHighlighter)?$(s,this.preferredHighlighter):await U(s,this.preferredHighlighter);if(!this.isCurrentLifecycle(t)){r();return}let a=[];if(this.preferredHighlighter!=="highlights"&&(a=Q(e)?N(e):await _(e)),!this.isCurrentLifecycle(t)){r();return}if(await Promise.all([this.loadSharedHighlighter(s,["text",...e]),this.initializeWorkers(o,a)]),!this.isCurrentLifecycle(t)){this.terminateWorkers(),r();return}this.initialized=!0,this.drainQueue(),this.queueBroadcastStateChanges(),r()}catch(s){if(s instanceof k||!this.isCurrentLifecycle(t)){r();return}this.initialized=!1,this.workersFailed=!0,this.cancelActiveWorkerTasks(),this.terminateWorkers(),this.activeTaskById.clear();for(const o of this.queuedTasks)this.rejectRenderTaskCallbacks(o,F(s));this.queueBroadcastStateChanges(),n(s)}})()});return this.initialized=i,this.queueBroadcastStateChanges(),i}else return this.initialized}async loadSharedHighlighter(e,t){try{await ee({themes:e,langs:t,preferredHighlighter:this.preferredHighlighter})}catch(i){if(!(i instanceof te))throw i}}async initializeWorkers(e,t){this.workersFailed=!1;const i=[],r=A(),n=r>0?M():void 0;this.workers.length>0&&this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){const l=this.options.workerFactory(),c={worker:l,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set(["text",...t.map(({name:h})=>h)]),customExtensionsVersion:0};l.addEventListener("message",h=>{this.handleWorkerMessage(c,h.data)}),l.addEventListener("error",h=>this.handleWorkerError(c,h)),this.workers.push(c),i.push(new Promise((h,f)=>{const u=this.generateRequestId(),g={type:"initialize",id:u,request:{type:"initialize",resultFormat:"hast-ops-v1",id:u,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:n!=null?r:void 0,customExtensionMap:n},resolve(){c.initialized=!0,h()},reject:f,requestStart:Date.now()};c.pendingSetupRequestId=u,this.activeTaskById.set(u,g),this.executeTask(c,g)}))}const s=this.options.workerInitializationTimeout??ge;let o;try{await Promise.race([Promise.all(i),new Promise((a,l)=>{o=setTimeout(()=>{l(new Error(`WorkerPoolManager: worker initialization timed out after ${s}ms`))},s)})])}finally{o!=null&&clearTimeout(o)}}handleWorkerError(e,t){const{onWorkerError:i}=this.options;if(i!=null)try{i(t,e.worker)}catch(o){console.error("WorkerPoolManager: onWorkerError threw:",o)}else console.error("Worker error:",t,e);const{pendingSetupRequestId:r}=e;if(r==null)return;const n=this.activeTaskById.get(r);if(n?.type!=="initialize")return;const s=ke(t);i!=null&&ie(s),n.reject(s),this.cleanWorkerAndTask(e,n)}drainQueue=()=>{if(this._queuedDrain=void 0,!(this.initialized!==!0||this.queuedTasks.length===0)){for(let e=0;e<this.queuedTasks.length;){const t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}const i=B(t.request),r=this.getAvailableWorker(i);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,i)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){const i=this.getFileResultCache(t);W(t)||i!=null&&I(i.options,this.getFileRenderOptions())||this.hasMatchingFileInstanceTask(e,t)||this.submitTask(e,{type:"file",file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(new Error("WorkerPoolManager.primeFileHighlightCache: worker pool is not working"));if(!this.shouldPrimeFileHighlightCache(e))return Promise.resolve();if(this.shouldHighlightOnMainThread(e)){const i=this.getFileRenderOptions();return this.primeHighlightCacheOnMainThread(B({type:"file",file:e}),i.theme,r=>this.setFileResultCache(e.cacheKey,{result:L(e,r,i),options:i}))}const t=this.getOrCreateFileHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}shouldPrimeFileHighlightCache(e){if(e.cacheKey==null)return console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`),!1;const t=this.getFileResultCache(e);return!W(e)&&(t==null||!I(t.options,this.getFileRenderOptions()))}getOrCreateFileHighlightCacheTask(e){const t=this.getFileHighlightKey(e);if(t==null)return;const i=this.getTaskByHighlightKey(t);if(i!=null){if(i.type!=="file")throw new Error("WorkerPoolManager.getOrCreateFileHighlightCacheTask: Invalid task type");return i.primeCache=!0,i}else{const r=this.submitCacheTask({type:"file",file:e},t);if(r.type!=="file")throw new Error("WorkerPoolManager.getOrCreateFileHighlightCacheTask: Invalid task created");return r}}getPlainFileAST(e,t,i,r){const n=p({theme:this.renderOptions.theme});if(n==null){this.queueInitialization();return}return L(e,n,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,lines:r})}highlightDiffAST(e,t){const i=this.getDiffResultCache(t);K(t)||i!=null&&y(i.options,this.getDiffRenderOptions())||this.hasMatchingDiffInstanceTask(e,t)||this.submitTask(e,{type:"diff",diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(new Error("WorkerPoolManager.primeDiffHighlightCache: worker pool is not working"));if(!this.shouldPrimeDiffHighlightCache(e))return Promise.resolve();if(this.shouldHighlightOnMainThread(e)){const i=this.getDiffRenderOptions();return this.primeHighlightCacheOnMainThread(B({type:"diff",diff:e}),i.theme,r=>this.setDiffResultCache(e.cacheKey,{result:V(e,r,i),options:i}))}const t=this.getOrCreateDiffHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}shouldPrimeDiffHighlightCache(e){if(e.cacheKey==null)return console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`),!1;const t=this.getDiffResultCache(e);return!K(e)&&(t==null||!y(t.options,this.getDiffRenderOptions()))}primeHighlightCacheOnMainThread(e,t,i){function r(){const s=p({theme:t,langs:e});return s!=null&&i(s)}if(r())return Promise.resolve();const{lifecycleGeneration:n}=this;return this.loadSharedHighlighter(m(t),["text",...e]).then(()=>{if(!this.isCurrentLifecycle(n))throw new k;if(!r())throw new R})}getOrCreateDiffHighlightCacheTask(e){const t=this.getDiffHighlightKey(e);if(t==null)return;const i=this.getTaskByHighlightKey(t);if(i!=null){if(i.type!=="diff")throw new Error("WorkerPoolManager.getOrCreateDiffHighlightCacheTask: Invalid task type");return i.primeCache=!0,i}else{const r=this.submitCacheTask({type:"diff",diff:e},t);if(r.type!=="diff")throw new Error("WorkerPoolManager.getOrCreateDiffHighlightCacheTask: Invalid task created");return r}}getPlainDiffAST(e,t,i,r,n){const s=p({theme:this.renderOptions.theme});if(s==null){this.queueInitialization();return}return V(e,s,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,expandedHunks:r,collapsedContextThreshold:n})}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();const e=new k;for(const t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.initialized=!1,this.workersFailed=!1,this.terminated=!0,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch(t=>{re(t)||console.error(t)})}cancelActiveWorkerTasks(){const e=new k;for(const t of this.activeTaskById.values())"reject"in t?t.reject(e):d(t)&&this.rejectRenderTaskCallbacks(t,e)}terminateWorkers(){for(const e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:this.initialized===!1?"waiting":this.initialized!==!0?"initializing":"initialized",totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter(e=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){this.initialized===!1&&this.queueInitialization();const i=this.getHighlightKeyForRequest(t),r=i!=null?this.getTaskByHighlightKey(i):void 0;if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);const n=this.generateRequestId(),s=Date.now(),{renderOptionsVersion:o}=this,a=(()=>{switch(t.type){case"file":return{type:"file",id:n,request:{...t,id:n},instances:new Set([e]),primeCache:!1,highlightKey:i,callbacks:new Set,renderOptionsVersion:o,requestStart:s};case"diff":return{type:"diff",id:n,request:{...t,id:n},instances:new Set([e]),primeCache:!1,highlightKey:i,callbacks:new Set,renderOptionsVersion:o,requestStart:s}}})();this.enqueueRenderTask(a,e)}submitCacheTask(e,t){this.initialized===!1&&this.queueInitialization();const i=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:n}=this,s=(()=>{switch(e.type){case"file":return{type:"file",id:i,request:{...e,id:i},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:n,requestStart:r};case"diff":return{type:"diff",id:i,request:{...e,id:i},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:n,requestStart:r}}})();return this.enqueueRenderTask(s),s}enqueueRenderTask(e,t){this.queuedTasks.push(e),t!=null&&this.queuedTaskByInstance.set(t,e),e.highlightKey!=null&&this.taskByHighlightKey.set(e.highlightKey,e),this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,i){try{const r=p(),n=i.filter(o=>r==null||!se(o,r));n.length>0&&this.loadSharedHighlighter(m(this.renderOptions.theme),["text",...n]).catch(o=>{console.error(o)});const s=this.preferredHighlighter==="highlights"?[]:i.filter(o=>!e.langs.has(o));if(s.length>0&&(Q(s)?t.request.resolvedLanguages=N(s):t.request.resolvedLanguages=await _(s)),!this.activeTaskById.has(t.id)){e.requestId===t.id&&(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain());return}this.executeTask(e,t)}catch(r){this.rejectRenderTaskCallbacks(t,F(r)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}}handleWorkerMessage(e,t){const i=this.activeTaskById.get(t.id);try{if(i==null)throw v;if(t.type==="error"){const r=new Error(t.error);if(t.stack&&(r.stack=t.stack),"reject"in i)i.reject(r);else if(d(i))this.notifyHighlightError(i,r),this.rejectRenderTaskCallbacks(i,r);else throw new Error("handleWorkerMessage: unknown task type");throw r}else{if(d(i))for(const{name:r}of i.request.resolvedLanguages??[])e.langs.add(r);switch(t.requestType){case"initialize":if(i.type!=="initialize")throw new Error("handleWorkerMessage: task/response dont match");this.syncCustomExtensionVersion(e,i.request),i.resolve();break;case"set-render-options":if(i.type!=="set-render-options")throw new Error("handleWorkerMessage: task/response dont match");i.resolve();break;case"file":{if(i.type!=="file")throw new Error("handleWorkerMessage: task/response dont match");const{options:r}=t;if(!this.isCurrentRenderTask(i)||!I(r,this.getFileRenderOptions()))throw v;const{request:n}=i,s={...t.result,code:O(t.result.code)};this.syncCustomExtensionVersion(e,n),i.cacheKeyAtDispatch!=null&&this.fileCache.set(i.cacheKeyAtDispatch,{result:s,options:r}),this.resolveRenderTaskCallbacks(i),this.notifyFileInstances(i,s,r);break}case"diff":{if(i.type!=="diff")throw new Error("handleWorkerMessage: task/response dont match");const{options:r}=t;if(!this.isCurrentRenderTask(i)||!y(r,this.getDiffRenderOptions()))throw v;const{request:n}=i,s={...t.result,code:{deletionLines:O(t.result.code.deletionLines),additionLines:O(t.result.code.additionLines)}};this.syncCustomExtensionVersion(e,n),i.cacheKeyAtDispatch!=null&&this.diffCache.set(i.cacheKeyAtDispatch,{result:s,options:r}),this.resolveRenderTaskCallbacks(i),this.notifyDiffInstances(i,s,r);break}}}}catch(r){r!==v&&console.error(r,i,t)}this.cleanWorkerAndTask(e,i,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}_queuedDrain;queueDrain(){this._queuedDrain==null&&(this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges())}assignWorkerToTask(e,t){t.requestId=e.id,d(e)&&(this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e)),this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,i=t?.id){e.requestId===i&&(e.requestId=void 0),e.pendingSetupRequestId===i&&(e.pendingSetupRequestId=void 0),t!=null&&(d(t)&&(this.rejectRenderTaskCallbacks(t,new R),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){me(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);try{t.type==="file"?t.cacheKeyAtDispatch=t.request.file.cacheKey:t.type==="diff"&&(t.cacheKeyAtDispatch=t.request.diff.cacheKey),e.worker.postMessage(t.request)}catch(i){console.error("Failed to post message to worker:",i),d(t)?(this.notifyHighlightError(t,i),this.rejectRenderTaskCallbacks(t,F(i))):"reject"in t&&t.reject(i),this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0&&this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;const i=A();e.customExtensionsVersion>=i||(t.customExtensionsVersion=i,t.customExtensionMap=M())}syncCustomExtensionVersion(e,t){t.customExtensionsVersion!=null&&(e.customExtensionsVersion=t.customExtensionsVersion)}getAvailableWorker(e){let t;for(const i of this.workers){if(i.requestId!=null||i.pendingSetupRequestId!=null||!i.initialized)continue;if(t=i,e.length===0)break;let r=!0;for(const n of e)if(!i.langs.has(n)){r=!1;break}if(r)break}return t}getFileHighlightKey(e){if(e.cacheKey!=null)return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey!=null)return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case"file":return this.getFileHighlightKey(e.file);case"diff":return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(const t of T(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){e.type,e.instances.add(t),this.activeTaskById.has(e.id)?this.activeRequestByInstance.set(t,e.id):this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){const i=this.queuedTaskByInstance.get(e);i==null||i===t||(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(i,e),!i.primeCache&&i.instances.size===0&&this.removeQueuedTask(i))}detachInstanceFromRenderTask(e,t){e.type,e.instances.delete(t)}removeQueuedTask(e){const t=this.queuedTasks.indexOf(e);t!==-1&&this.queuedTasks.splice(t,1),this.rejectRenderTaskCallbacks(e,new R),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new R),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,i)=>{e.callbacks.add({resolve:t,reject:i})})}resolveRenderTaskCallbacks(e){for(const t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(const i of e.callbacks)i.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){const t=this.queuedTasks[e];t.renderOptionsVersion!==this.renderOptionsVersion&&this.removeQueuedTask(t)}for(const e of Array.from(this.activeTaskById.values()))d(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(const t of T(e))this.queuedTaskByInstance.get(t)===e&&this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e&&this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(const t of T(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(const t of T(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,i){for(const r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.file,t,i)}notifyDiffInstances(e,t,i){for(const r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.diff,t,i)}notifyHighlightError(e,t){for(const i of T(e))this.activeRequestByInstance.get(i)===e.id&&i.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(const i of this.iterateRenderTasks())if(i.type==="file"&&this.isCurrentRenderTask(i)&&i.instances.has(e)&&oe(t,i.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(const i of this.iterateRenderTasks())if(i.type==="diff"&&this.isCurrentRenderTask(i)&&i.instances.has(e)&&ae(i.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){const t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(const e of this.queuedTasks)yield e;for(const e of this.activeTaskById.values())d(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function me(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function B(e){const t=new Set;switch(e.type){case"file":t.add(e.file.lang??b(e.file.name));break;case"diff":t.add(e.diff.lang??b(e.diff.name)),t.add(e.diff.lang??b(e.diff.prevName??"-"))}return t.delete("text"),Array.from(t)}function d(e){return e?.type==="file"||e?.type==="diff"}function T(e){return e.instances}function F(e){if(e instanceof Error)return e;if(e!=null&&typeof e=="object"){if("error"in e&&e.error instanceof Error)return e.error;if("message"in e&&typeof e.message=="string")return new Error(e.message)}return new Error(String(e))}function ke(e){const t="error"in e?e.error:void 0,i="message"in e&&typeof e.message=="string"&&e.message!==""?e.message:t instanceof Error?t.message:"the worker script failed to load (the error event carries no message)";return new ne(`WorkerPoolManager: worker failed: ${i}`,t instanceof Error?{cause:t}:void 0)}let C;function jr({poolOptions:e,highlighterOptions:t}){return C??=new pe(e,t),C}function Nr(){C!=null&&(C.terminate(),C=void 0)}export{pe as WorkerPoolManager,R as WorkerPoolTaskCanceledError,k as WorkerPoolTerminatedError,ne as WorkerPoolWorkerError,jr as getOrCreateWorkerPoolSingleton,re as isHandledWorkerPoolError,Gr as isWorkerPoolCancellation,Nr as terminateWorkerPoolSingleton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i,s as t,b as s,c as o}from"./useAppFontEffects-
|
|
1
|
+
import{a as i,s as t,b as s,c as o}from"./useAppFontEffects-DpDiWkkc.js";import"./vendor-react--VO_rL_p.js";import{i as n,a as c,s as p}from"./katex.min-BBVkbKQY.js";const h=({logLabel:a,onAppearanceSettled:r})=>{n(),c().then(()=>{Promise.all([p(),i()]).catch(e=>{console.error(`${a} settings init failed:`,e)}),t(),s(),o()}).catch(e=>{console.error(`${a} appearance init failed:`,e)}).finally(()=>{r?.()})};export{h as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as X,R as y,j as a}from"./vendor-react--VO_rL_p.js";import{u as ee,B as C,dl as G,bo as ue,bp as pe,fN as ge,bq as he,br as fe,bs as te,y as F,fO as me,z as K,Q as ye,b0 as ve,A as M,bJ as xe,fP as ke,fQ as be}from"./useAppFontEffects-DDoHSSlY.js";import{t as V,aG as Ce,j as z}from"./katex.min-CgNRvQ_w.js";import{o as je,s as W,_ as we}from"./vendor-zod-Csf1sqWl.js";const Ne=t=>t.toLowerCase().replace(/[^a-z0-9_-]/g,"-"),Be=t=>Ne(t.trim()).replace(/^[-_]+|[-_]+$/g,""),H={oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:""},Ke=t=>t===!1?{...H,oauthEnabled:!1}:t?{oauthEnabled:!0,oauthClientId:t.client_id??"",oauthClientSecret:t.client_secret??"",oauthScope:t.scope??"",oauthRedirectUri:t.redirect_uri??"",oauthCallbackPort:t.callback_port===void 0?"":String(t.callback_port)}:H,Se=(t,e)=>!!e&&t!=="claude-code",Ie=/[A-Z0-9]{4}-[A-Z0-9]{4,5}/,Ae=t=>Ie.exec(t)?.[0]??void 0,P=t=>t.type!=="external",O=t=>t.title??t.key,Te=(t,e)=>{if(e===void 0)return!1;const s=String(e),n=String(t.value);return t.op==="eq"?s===n:s!==n},Oe=(t,e)=>P(t)?(t.when??[]).every(s=>Te(s,e[s.key])):!0,Z=(t,e)=>{const s={},n=[];for(const d of t){if(!Oe(d,s))continue;n.push(d);const p=e[d.key];P(d)&&p!==void 0&&(s[d.key]=p)}return n},Ee=t=>{const e={};for(const s of t)switch(s.type){case"external":break;case"boolean":e[s.key]=s.default??!1;break;case"number":case"integer":typeof s.default=="number"&&(e[s.key]=s.default);break;case"multiselect":e[s.key]=s.default??[];break;case"string":e[s.key]=s.default??s.options?.[0]?.value??"";break}return e},se=t=>t===void 0?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:!1,Fe=(t,e)=>Z(t,e).find(s=>P(s)&&s.required===!0&&se(e[s.key]))??null,ze=(t,e)=>{const s={};for(const n of Z(t,e)){if(!P(n))continue;const d=e[n.key];se(d)||d===void 0||(s[n.key]=typeof d=="string"?d.trim():d)}return s},Q=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Y=t=>typeof t=="string"&&t.length>0?t:void 0,Pe=(t,e,s)=>{const n=Q(t)?t:{},d=Q(n.data)?n.data:{};switch(n.name){case"IntegrationOauthAttemptMissing":return e("settings.providers.page.auth.oauth.error.sessionExpired");case"IntegrationOauthCodeMissing":return e("settings.providers.page.auth.oauth.error.codeRequired");case"IntegrationOauthFailed":return e("settings.providers.page.auth.oauth.error.declined");case"IntegrationValidationFailed":return Y(d.message)??e("settings.providers.page.auth.oauth.error.invalidInput");default:return Y(n.message)??e(s)}},R="\0typed",De=t=>{const e=X.c(12),{fields:s,values:n,onChange:d}=t,{t:p}=ee();let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=new Set,e[0]=k):k=e[0];const[v,f]=y.useState(k);let l;e[1]!==d||e[2]!==p||e[3]!==v||e[4]!==n?(l=o=>{if(o.type==="external")return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("label",{className:"typography-ui-label text-foreground",children:O(o)}),a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{G(o.url)},children:p("settings.providers.page.actions.open")})]},o.key);const w=n[o.key],S=typeof w=="string"?w:"",j=m=>d(o.key,m),I=o.type==="string"||o.type==="multiselect"?o.options??[]:[],x=o.type==="string"&&o.custom===!0,N=x&&v.has(o.key),A=m=>f(E=>{const T=new Set(E);return m?T.add(o.key):T.delete(o.key),T});return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("label",{className:"typography-ui-label text-foreground",children:O(o)}),o.description&&a.jsx("p",{className:"typography-meta text-muted-foreground",children:o.description}),I.length>0?a.jsxs(a.Fragment,{children:[a.jsxs(ue,{value:N?R:S,onValueChange:m=>{if(m===R){A(!0),j("");return}A(!1),j(m)},children:[a.jsx(pe,{className:ge,children:a.jsx(he,{children:m=>m===R?p("settings.providers.page.auth.field.other"):I.find(E=>E.value===m)?.label??null})}),a.jsxs(fe,{children:[I.map(Re),x?a.jsx(te,{value:R,children:p("settings.providers.page.auth.field.other")}):null]})]}),N?a.jsx(F,{value:S,onChange:m=>j(m.target.value),placeholder:o.placeholder??p("settings.providers.page.auth.field.otherPlaceholder"),"aria-label":O(o),className:"max-w-[24rem] text-xs",autoFocus:!0}):null]}):o.type==="boolean"?a.jsx("input",{type:"checkbox",checked:w===!0,onChange:m=>j(m.target.checked),"aria-label":O(o)}):a.jsx(F,{value:S,onChange:m=>j(m.target.value),placeholder:o.type==="string"?o.placeholder:void 0,"aria-label":O(o),className:"max-w-[24rem] text-xs"})]},o.key)},e[1]=d,e[2]=p,e[3]=v,e[4]=n,e[5]=l):l=e[5];const b=l;let h;e[6]!==s||e[7]!==b||e[8]!==n?(h=Z(s,n).map(b),e[6]=s,e[7]=b,e[8]=n,e[9]=h):h=e[9];let i;return e[10]!==h?(i=a.jsx(a.Fragment,{children:h}),e[10]=h,e[11]=i):i=e[11],i};function Re(t){return a.jsx(te,{value:t.value,children:t.description?`${t.label} · ${t.description}`:t.label},t.value)}const U={phase:"idle"},_e=1500,qe=({integrationId:t,methods:e,onConnected:s,directory:n,className:d,autoStart:p=!1,showMethodLabels:k=!0,connectLabel:v,showStartButton:f=!0})=>{const{t:l}=ee(),b=y.useMemo(()=>n?V.getScopedSdkClient(n):me(),[n]),h=y.useCallback(()=>b,[b]),[i,o]=y.useState(U),[w,S]=y.useState({}),[j,I]=y.useState(""),x=y.useRef(null),N=y.useCallback(r=>{x.current=null,h().integration.oauth.cancel({integrationID:t,attemptID:r}).catch(()=>{})},[t,h]),A=y.useRef(!1);y.useEffect(()=>(A.current=!1,()=>{A.current=!0;const r=x.current;r&&N(r)}),[N]);const m=i.phase==="idle"?null:i.methodID,E=i.phase==="connecting"||i.phase==="waiting"||i.phase==="awaitingCode"&&i.submitting,T=async(r,c,u)=>{const g=await ve(r);if(g.ok){M.success(l(c));return}console.error("Failed to copy OAuth value:",g.error),M.error(l(u))},_=async(r="settings.providers.page.toast.oauthCompleted")=>{x.current=null,o(U),M.success(l(r)),await s()},D=(r,c,u)=>{x.current=null,console.error("OAuth flow failed:",c),o({phase:"failed",methodID:r,message:Pe(c,l,u)})},ie=async(r,c)=>{const u=h();for(;x.current===c;){if(await new Promise(g=>setTimeout(g,_e)),x.current!==c)return;try{const{data:g}=await u.integration.oauth.status({integrationID:t,attemptID:c});if(x.current!==c)return;if(g.status==="complete"){await _();return}if(g.status==="failed"){o({phase:"failed",methodID:r,message:g.message}),x.current=null;return}}catch(g){if(x.current!==c)return;D(r,g,"settings.providers.page.toast.oauthCompleteFailed");return}}},oe=async(r,c)=>{o({phase:"connecting",methodID:r});try{await h().integration.connect.external({integrationID:t,methodID:r,answer:Object.keys(c).length>0?c:void 0})}catch(u){D(r,u,"settings.providers.page.toast.externalConnectFailed");return}await _("settings.providers.page.toast.externalConnected")},$=async(r,c)=>{if(r.type==="external"){await oe(r.id,c);return}o({phase:"connecting",methodID:r.id});let u;try{const{data:g}=await h().integration.oauth.connect({integrationID:t,methodID:r.id,...Object.keys(c).length>0?{answer:c}:{}});u={attemptID:g.attemptID,mode:g.mode,url:g.url,instructions:g.instructions}}catch(g){D(r.id,g,"settings.providers.page.toast.oauthStartFailed");return}if(A.current){N(u.attemptID);return}if(x.current=u.attemptID,Se(t,u.url)&&G(u.url),u.mode==="code"){I(""),o({phase:"awaitingCode",methodID:r.id,attempt:u,submitting:!1});return}o({phase:"waiting",methodID:r.id,attempt:u}),await ie(r.id,u.attemptID)},q=r=>{const c=(r.form??[]).filter(P);if(c.length===0){$(r,{});return}S(Ee(c)),o({phase:"prompting",methodID:r.id,fields:c,error:null})},J=y.useRef(!1);y.useEffect(()=>{!p||J.current||e.length!==1||(J.current=!0,q(e[0]))},[p,e]);const ce=r=>{if(i.phase!=="prompting")return;const c=Fe(i.fields,w);if(c){o({...i,error:l("settings.providers.page.auth.oauth.promptRequired",{field:O(c)})});return}$(r,ze(i.fields,w))},le=async()=>{if(i.phase!=="awaitingCode")return;const r=j.trim();if(!r)return;const{methodID:c,attempt:u}=i;o({...i,submitting:!0});try{await h().integration.oauth.complete({integrationID:t,attemptID:u.attemptID,code:r}),await _()}catch(g){D(c,g,"settings.providers.page.toast.oauthCompleteFailed")}},L=()=>{(i.phase==="waiting"||i.phase==="awaitingCode")&&N(i.attempt.attemptID),o(U)},B=r=>{const c=Ae(r.instructions);return a.jsxs(a.Fragment,{children:[r.instructions&&a.jsx("p",{className:"typography-meta text-[var(--status-info-text)] bg-[var(--status-info-background)] px-2 py-1.5 rounded",children:r.instructions}),c&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(F,{value:c,readOnly:!0,"aria-label":l("settings.providers.page.auth.oauth.deviceCodeLabel"),className:"font-mono text-center tracking-widest"}),a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>{T(c,"settings.providers.page.toast.deviceCodeCopied","settings.providers.page.toast.deviceCodeCopyFailed")},children:l("settings.providers.page.actions.copyCode")})]}),r.url&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(F,{value:r.url,readOnly:!0,"aria-label":l("settings.providers.page.auth.oauth.linkLabel"),className:"text-xs text-muted-foreground"}),a.jsxs("div",{className:"flex gap-1 shrink-0",children:[a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{G(r.url)},children:l("settings.providers.page.actions.open")}),a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{T(r.url,"settings.providers.page.toast.oauthLinkCopied","settings.providers.page.toast.oauthLinkCopyFailed")},children:l("settings.providers.page.actions.copy")})]})]})]})};return a.jsx("div",{className:ye("space-y-4",d),children:e.map(r=>{const c=m===r.id;return a.jsxs("div",{className:"space-y-3",children:[f?a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[k?a.jsx("div",{className:"typography-ui-label text-foreground",children:r.label}):null,a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>q(r),disabled:E,children:v??l("settings.providers.page.actions.connect")})]}):null,c&&i.phase==="prompting"&&a.jsxs("div",{className:"space-y-3",children:[a.jsx(De,{fields:i.fields,values:w,onChange:(u,g)=>S(de=>({...de,[u]:g}))}),i.error&&a.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:i.error}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(C,{size:"xs",className:"!font-normal",onClick:()=>ce(r),children:l("settings.providers.page.actions.continue")}),a.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal",onClick:L,children:l("settings.providers.page.actions.cancel")})]})]}),c&&i.phase==="connecting"&&a.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[a.jsx(K,{className:"h-3.5 w-3.5"}),r.type==="external"?l("settings.providers.page.auth.external.connecting"):l("settings.providers.page.auth.oauth.starting")]}),c&&i.phase==="waiting"&&a.jsxs("div",{className:"space-y-3",children:[B(i.attempt),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[a.jsx(K,{className:"h-3.5 w-3.5"}),l("settings.providers.page.auth.oauth.waiting")]}),a.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:L,children:l("settings.providers.page.actions.cancel")})]}),a.jsx("p",{className:"typography-meta text-muted-foreground",children:l("settings.providers.page.auth.oauth.waitingHint")})]}),c&&i.phase==="awaitingCode"&&a.jsxs("div",{className:"space-y-3",children:[B(i.attempt),a.jsx("p",{className:"typography-meta text-muted-foreground",children:l("settings.providers.page.auth.oauth.codeHint")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(F,{value:j,onChange:u=>I(u.target.value),placeholder:l("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs",disabled:i.submitting}),a.jsx(C,{size:"xs",className:"!font-normal shrink-0",onClick:()=>{le()},disabled:i.submitting||j.trim().length===0,children:i.submitting?l("settings.providers.page.actions.saving"):l("settings.providers.page.actions.complete")}),a.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:L,disabled:i.submitting,children:l("settings.providers.page.actions.cancel")})]})]}),c&&i.phase==="failed"&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:i.message}),f?a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>q(r),children:l("settings.providers.page.actions.tryAgain")}):null]})]},r.id)})})},Le=(t,e)=>t.find(s=>s.id.startsWith("mcp_")&&s.metadata?.source==="mcp"&&s.name===e),ae=t=>(t?.methods??[]).filter(e=>e.type==="oauth"),Me=(t,e,s=!0)=>{const[n,d]=y.useState(null);return y.useEffect(()=>{let p=!1;if(d(null),!s)return;const k=e?V.getScopedSdkClient(e):V.getSdkClient(),v=async(f=0)=>{try{const{data:l}=await k.integration.list();if(p)return;const b=Le(l,t)??null;if(b){d(b);return}f<8&&setTimeout(()=>{v(f+1)},750)}catch(l){if(p)return;console.error("Failed to load MCP integrations:",l),f<8&&setTimeout(()=>{v(f+1)},750)}};return v(),()=>{p=!0}},[e,s,t]),ae(n??void 0).length>0?n:null},We=t=>{const e=X.c(10),{serverName:s,directory:n,onConnected:d,autoStart:p,connectLabel:k,showStartButton:v}=t,f=Me(s,n);if(!f)return null;const l=f.id,b=f.id;let h;e[0]!==f?(h=ae(f),e[0]=f,e[1]=h):h=e[1];let i;return e[2]!==p||e[3]!==k||e[4]!==n||e[5]!==f.id||e[6]!==d||e[7]!==v||e[8]!==h?(i=a.jsx(qe,{integrationId:b,methods:h,directory:n,onConnected:d,autoStart:p,connectLabel:k,showStartButton:v},l),e[2]=p,e[3]=k,e[4]=n,e[5]=f.id,e[6]=d,e[7]=v,e[8]=h,e[9]=i):i=e[9],i},Ue=je({error:we(["invalid-path","invalid-url","not-found","invalid-manifest","id-taken","already-installed","missing-build","host-too-old","bundled","reserved-id","clone-failed","clone-auth-failed","extract-failed","too-large","enterprise-mode"]),required:W().trim().min(1).max(64).optional(),id:W().trim().min(1).max(128).optional()}),Ge=t=>{const e=t.trim();if(!e)return{ok:!1,code:"invalid-path"};if(e.slice(0,8).toLowerCase()==="https://")return{ok:!0,request:{url:e}};if(e.slice(0,6).toLowerCase()==="ssh://"||/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?[A-Za-z0-9][A-Za-z0-9.-]*\.[A-Za-z0-9.-]+:[^\s]+$/.test(e))return{ok:!0,request:{url:e}};const s=/^[a-zA-Z]:[\\/]/.test(e);return/^[a-z][a-z0-9+.-]*:/i.test(e)&&!s?{ok:!1,code:"invalid-url"}:e.startsWith("/")||s||e.startsWith("\\\\")?{ok:!0,request:{path:e}}:{ok:!1,code:"invalid-path"}},re=async t=>{try{const e=Ue.safeParse(JSON.parse(await t.text()));return e.success?e.data.error==="host-too-old"&&e.data.required&&e.data.id?{code:"host-too-old",required:e.data.required,id:e.data.id}:e.data.error==="host-too-old"&&e.data.required?{code:"host-too-old",required:e.data.required}:e.data.id?{code:e.data.error,id:e.data.id}:{code:e.data.error}:{code:"failed"}}catch{return{code:"failed"}}},ne=async(t,e)=>{if(!t.ok)return{ok:!1,...await re(t),diagnostic:{method:"POST",path:e,kind:"http",status:t.status}};const s=await t.text().catch(()=>null),n=s===null?null:be(s);return n==="unreadable"?{ok:!1,code:"unreadable"}:n?{ok:!0,guest:n,replaced:t.status===200}:{ok:!1,code:"failed",diagnostic:{method:"POST",path:e,kind:"invalid-response",status:t.status}}},He=async(t,e={})=>{const s=Ge(t);if(!s.ok)return s;const n={...s.request};e.replace&&(n.replace=!0),"url"in n&&e.gitIdentityId&&(n.gitIdentityId=e.gitIdentityId);try{const d=await z("/api/guests",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});return await ne(d,"/api/guests")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests",kind:"network"}}}},Qe=async(t,e={})=>{try{const s=await z("/api/guests/upload",{method:"POST",query:{replace:e.replace?"true":void 0,name:t.name||void 0},headers:{"Content-Type":"application/octet-stream",Accept:"application/json"},body:t});return await ne(s,"/api/guests/upload")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests/upload",kind:"network"}}}},Ye=async t=>{const e=xe.getState(),s=Ce(),n=e.runtimeKey===s?e.guests.find(d=>d.id===t)?.storageId:void 0;try{const d=await z(`/api/guests/${t}`,{method:"DELETE"});return d.status===204?(n&&globalThis.indexedDB&&await ke({runtimeKey:s,guestId:t,storageId:n}).catch(()=>{console.warn("Could not clear local extension preferences.")}),{ok:!0}):{ok:!1,code:(await re(d)).code}}catch{return{ok:!1,code:"failed"}}},Xe=async(t,e)=>{try{return(await z(`/api/guests/${t}/enabled`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})})).ok}catch{return!1}},et=async(t,e)=>{try{return(await z(`/api/guests/${t}/capabilities`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({granted:e})})).ok}catch{return!1}};export{H as M,De as P,We as a,Me as b,Ne as c,P as d,Ee as e,Fe as f,O as g,ze as h,He as i,qe as j,Qe as k,et as l,Be as n,Ke as r,Xe as s,Ye as u};
|
|
1
|
+
import{f as X,R as y,j as a}from"./vendor-react--VO_rL_p.js";import{u as ee,B as C,dl as G,bo as ue,bp as pe,fN as ge,bq as he,br as fe,bs as te,y as F,fO as me,z as K,Q as ye,b0 as ve,A as M,bJ as xe,fP as ke,fQ as be}from"./useAppFontEffects-DpDiWkkc.js";import{t as V,aG as Ce,j as z}from"./katex.min-BBVkbKQY.js";import{o as je,s as W,_ as we}from"./vendor-zod-Csf1sqWl.js";const Ne=t=>t.toLowerCase().replace(/[^a-z0-9_-]/g,"-"),Be=t=>Ne(t.trim()).replace(/^[-_]+|[-_]+$/g,""),H={oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:""},Ke=t=>t===!1?{...H,oauthEnabled:!1}:t?{oauthEnabled:!0,oauthClientId:t.client_id??"",oauthClientSecret:t.client_secret??"",oauthScope:t.scope??"",oauthRedirectUri:t.redirect_uri??"",oauthCallbackPort:t.callback_port===void 0?"":String(t.callback_port)}:H,Se=(t,e)=>!!e&&t!=="claude-code",Ie=/[A-Z0-9]{4}-[A-Z0-9]{4,5}/,Ae=t=>Ie.exec(t)?.[0]??void 0,P=t=>t.type!=="external",O=t=>t.title??t.key,Te=(t,e)=>{if(e===void 0)return!1;const s=String(e),n=String(t.value);return t.op==="eq"?s===n:s!==n},Oe=(t,e)=>P(t)?(t.when??[]).every(s=>Te(s,e[s.key])):!0,Z=(t,e)=>{const s={},n=[];for(const d of t){if(!Oe(d,s))continue;n.push(d);const p=e[d.key];P(d)&&p!==void 0&&(s[d.key]=p)}return n},Ee=t=>{const e={};for(const s of t)switch(s.type){case"external":break;case"boolean":e[s.key]=s.default??!1;break;case"number":case"integer":typeof s.default=="number"&&(e[s.key]=s.default);break;case"multiselect":e[s.key]=s.default??[];break;case"string":e[s.key]=s.default??s.options?.[0]?.value??"";break}return e},se=t=>t===void 0?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:!1,Fe=(t,e)=>Z(t,e).find(s=>P(s)&&s.required===!0&&se(e[s.key]))??null,ze=(t,e)=>{const s={};for(const n of Z(t,e)){if(!P(n))continue;const d=e[n.key];se(d)||d===void 0||(s[n.key]=typeof d=="string"?d.trim():d)}return s},Q=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Y=t=>typeof t=="string"&&t.length>0?t:void 0,Pe=(t,e,s)=>{const n=Q(t)?t:{},d=Q(n.data)?n.data:{};switch(n.name){case"IntegrationOauthAttemptMissing":return e("settings.providers.page.auth.oauth.error.sessionExpired");case"IntegrationOauthCodeMissing":return e("settings.providers.page.auth.oauth.error.codeRequired");case"IntegrationOauthFailed":return e("settings.providers.page.auth.oauth.error.declined");case"IntegrationValidationFailed":return Y(d.message)??e("settings.providers.page.auth.oauth.error.invalidInput");default:return Y(n.message)??e(s)}},R="\0typed",De=t=>{const e=X.c(12),{fields:s,values:n,onChange:d}=t,{t:p}=ee();let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=new Set,e[0]=k):k=e[0];const[v,f]=y.useState(k);let l;e[1]!==d||e[2]!==p||e[3]!==v||e[4]!==n?(l=o=>{if(o.type==="external")return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("label",{className:"typography-ui-label text-foreground",children:O(o)}),a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{G(o.url)},children:p("settings.providers.page.actions.open")})]},o.key);const w=n[o.key],S=typeof w=="string"?w:"",j=m=>d(o.key,m),I=o.type==="string"||o.type==="multiselect"?o.options??[]:[],x=o.type==="string"&&o.custom===!0,N=x&&v.has(o.key),A=m=>f(E=>{const T=new Set(E);return m?T.add(o.key):T.delete(o.key),T});return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("label",{className:"typography-ui-label text-foreground",children:O(o)}),o.description&&a.jsx("p",{className:"typography-meta text-muted-foreground",children:o.description}),I.length>0?a.jsxs(a.Fragment,{children:[a.jsxs(ue,{value:N?R:S,onValueChange:m=>{if(m===R){A(!0),j("");return}A(!1),j(m)},children:[a.jsx(pe,{className:ge,children:a.jsx(he,{children:m=>m===R?p("settings.providers.page.auth.field.other"):I.find(E=>E.value===m)?.label??null})}),a.jsxs(fe,{children:[I.map(Re),x?a.jsx(te,{value:R,children:p("settings.providers.page.auth.field.other")}):null]})]}),N?a.jsx(F,{value:S,onChange:m=>j(m.target.value),placeholder:o.placeholder??p("settings.providers.page.auth.field.otherPlaceholder"),"aria-label":O(o),className:"max-w-[24rem] text-xs",autoFocus:!0}):null]}):o.type==="boolean"?a.jsx("input",{type:"checkbox",checked:w===!0,onChange:m=>j(m.target.checked),"aria-label":O(o)}):a.jsx(F,{value:S,onChange:m=>j(m.target.value),placeholder:o.type==="string"?o.placeholder:void 0,"aria-label":O(o),className:"max-w-[24rem] text-xs"})]},o.key)},e[1]=d,e[2]=p,e[3]=v,e[4]=n,e[5]=l):l=e[5];const b=l;let h;e[6]!==s||e[7]!==b||e[8]!==n?(h=Z(s,n).map(b),e[6]=s,e[7]=b,e[8]=n,e[9]=h):h=e[9];let i;return e[10]!==h?(i=a.jsx(a.Fragment,{children:h}),e[10]=h,e[11]=i):i=e[11],i};function Re(t){return a.jsx(te,{value:t.value,children:t.description?`${t.label} · ${t.description}`:t.label},t.value)}const U={phase:"idle"},_e=1500,qe=({integrationId:t,methods:e,onConnected:s,directory:n,className:d,autoStart:p=!1,showMethodLabels:k=!0,connectLabel:v,showStartButton:f=!0})=>{const{t:l}=ee(),b=y.useMemo(()=>n?V.getScopedSdkClient(n):me(),[n]),h=y.useCallback(()=>b,[b]),[i,o]=y.useState(U),[w,S]=y.useState({}),[j,I]=y.useState(""),x=y.useRef(null),N=y.useCallback(r=>{x.current=null,h().integration.oauth.cancel({integrationID:t,attemptID:r}).catch(()=>{})},[t,h]),A=y.useRef(!1);y.useEffect(()=>(A.current=!1,()=>{A.current=!0;const r=x.current;r&&N(r)}),[N]);const m=i.phase==="idle"?null:i.methodID,E=i.phase==="connecting"||i.phase==="waiting"||i.phase==="awaitingCode"&&i.submitting,T=async(r,c,u)=>{const g=await ve(r);if(g.ok){M.success(l(c));return}console.error("Failed to copy OAuth value:",g.error),M.error(l(u))},_=async(r="settings.providers.page.toast.oauthCompleted")=>{x.current=null,o(U),M.success(l(r)),await s()},D=(r,c,u)=>{x.current=null,console.error("OAuth flow failed:",c),o({phase:"failed",methodID:r,message:Pe(c,l,u)})},ie=async(r,c)=>{const u=h();for(;x.current===c;){if(await new Promise(g=>setTimeout(g,_e)),x.current!==c)return;try{const{data:g}=await u.integration.oauth.status({integrationID:t,attemptID:c});if(x.current!==c)return;if(g.status==="complete"){await _();return}if(g.status==="failed"){o({phase:"failed",methodID:r,message:g.message}),x.current=null;return}}catch(g){if(x.current!==c)return;D(r,g,"settings.providers.page.toast.oauthCompleteFailed");return}}},oe=async(r,c)=>{o({phase:"connecting",methodID:r});try{await h().integration.connect.external({integrationID:t,methodID:r,answer:Object.keys(c).length>0?c:void 0})}catch(u){D(r,u,"settings.providers.page.toast.externalConnectFailed");return}await _("settings.providers.page.toast.externalConnected")},$=async(r,c)=>{if(r.type==="external"){await oe(r.id,c);return}o({phase:"connecting",methodID:r.id});let u;try{const{data:g}=await h().integration.oauth.connect({integrationID:t,methodID:r.id,...Object.keys(c).length>0?{answer:c}:{}});u={attemptID:g.attemptID,mode:g.mode,url:g.url,instructions:g.instructions}}catch(g){D(r.id,g,"settings.providers.page.toast.oauthStartFailed");return}if(A.current){N(u.attemptID);return}if(x.current=u.attemptID,Se(t,u.url)&&G(u.url),u.mode==="code"){I(""),o({phase:"awaitingCode",methodID:r.id,attempt:u,submitting:!1});return}o({phase:"waiting",methodID:r.id,attempt:u}),await ie(r.id,u.attemptID)},q=r=>{const c=(r.form??[]).filter(P);if(c.length===0){$(r,{});return}S(Ee(c)),o({phase:"prompting",methodID:r.id,fields:c,error:null})},J=y.useRef(!1);y.useEffect(()=>{!p||J.current||e.length!==1||(J.current=!0,q(e[0]))},[p,e]);const ce=r=>{if(i.phase!=="prompting")return;const c=Fe(i.fields,w);if(c){o({...i,error:l("settings.providers.page.auth.oauth.promptRequired",{field:O(c)})});return}$(r,ze(i.fields,w))},le=async()=>{if(i.phase!=="awaitingCode")return;const r=j.trim();if(!r)return;const{methodID:c,attempt:u}=i;o({...i,submitting:!0});try{await h().integration.oauth.complete({integrationID:t,attemptID:u.attemptID,code:r}),await _()}catch(g){D(c,g,"settings.providers.page.toast.oauthCompleteFailed")}},L=()=>{(i.phase==="waiting"||i.phase==="awaitingCode")&&N(i.attempt.attemptID),o(U)},B=r=>{const c=Ae(r.instructions);return a.jsxs(a.Fragment,{children:[r.instructions&&a.jsx("p",{className:"typography-meta text-[var(--status-info-text)] bg-[var(--status-info-background)] px-2 py-1.5 rounded",children:r.instructions}),c&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(F,{value:c,readOnly:!0,"aria-label":l("settings.providers.page.auth.oauth.deviceCodeLabel"),className:"font-mono text-center tracking-widest"}),a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>{T(c,"settings.providers.page.toast.deviceCodeCopied","settings.providers.page.toast.deviceCodeCopyFailed")},children:l("settings.providers.page.actions.copyCode")})]}),r.url&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(F,{value:r.url,readOnly:!0,"aria-label":l("settings.providers.page.auth.oauth.linkLabel"),className:"text-xs text-muted-foreground"}),a.jsxs("div",{className:"flex gap-1 shrink-0",children:[a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{G(r.url)},children:l("settings.providers.page.actions.open")}),a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{T(r.url,"settings.providers.page.toast.oauthLinkCopied","settings.providers.page.toast.oauthLinkCopyFailed")},children:l("settings.providers.page.actions.copy")})]})]})]})};return a.jsx("div",{className:ye("space-y-4",d),children:e.map(r=>{const c=m===r.id;return a.jsxs("div",{className:"space-y-3",children:[f?a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[k?a.jsx("div",{className:"typography-ui-label text-foreground",children:r.label}):null,a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>q(r),disabled:E,children:v??l("settings.providers.page.actions.connect")})]}):null,c&&i.phase==="prompting"&&a.jsxs("div",{className:"space-y-3",children:[a.jsx(De,{fields:i.fields,values:w,onChange:(u,g)=>S(de=>({...de,[u]:g}))}),i.error&&a.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:i.error}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(C,{size:"xs",className:"!font-normal",onClick:()=>ce(r),children:l("settings.providers.page.actions.continue")}),a.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal",onClick:L,children:l("settings.providers.page.actions.cancel")})]})]}),c&&i.phase==="connecting"&&a.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[a.jsx(K,{className:"h-3.5 w-3.5"}),r.type==="external"?l("settings.providers.page.auth.external.connecting"):l("settings.providers.page.auth.oauth.starting")]}),c&&i.phase==="waiting"&&a.jsxs("div",{className:"space-y-3",children:[B(i.attempt),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[a.jsx(K,{className:"h-3.5 w-3.5"}),l("settings.providers.page.auth.oauth.waiting")]}),a.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:L,children:l("settings.providers.page.actions.cancel")})]}),a.jsx("p",{className:"typography-meta text-muted-foreground",children:l("settings.providers.page.auth.oauth.waitingHint")})]}),c&&i.phase==="awaitingCode"&&a.jsxs("div",{className:"space-y-3",children:[B(i.attempt),a.jsx("p",{className:"typography-meta text-muted-foreground",children:l("settings.providers.page.auth.oauth.codeHint")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(F,{value:j,onChange:u=>I(u.target.value),placeholder:l("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs",disabled:i.submitting}),a.jsx(C,{size:"xs",className:"!font-normal shrink-0",onClick:()=>{le()},disabled:i.submitting||j.trim().length===0,children:i.submitting?l("settings.providers.page.actions.saving"):l("settings.providers.page.actions.complete")}),a.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:L,disabled:i.submitting,children:l("settings.providers.page.actions.cancel")})]})]}),c&&i.phase==="failed"&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:i.message}),f?a.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>q(r),children:l("settings.providers.page.actions.tryAgain")}):null]})]},r.id)})})},Le=(t,e)=>t.find(s=>s.id.startsWith("mcp_")&&s.metadata?.source==="mcp"&&s.name===e),ae=t=>(t?.methods??[]).filter(e=>e.type==="oauth"),Me=(t,e,s=!0)=>{const[n,d]=y.useState(null);return y.useEffect(()=>{let p=!1;if(d(null),!s)return;const k=e?V.getScopedSdkClient(e):V.getSdkClient(),v=async(f=0)=>{try{const{data:l}=await k.integration.list();if(p)return;const b=Le(l,t)??null;if(b){d(b);return}f<8&&setTimeout(()=>{v(f+1)},750)}catch(l){if(p)return;console.error("Failed to load MCP integrations:",l),f<8&&setTimeout(()=>{v(f+1)},750)}};return v(),()=>{p=!0}},[e,s,t]),ae(n??void 0).length>0?n:null},We=t=>{const e=X.c(10),{serverName:s,directory:n,onConnected:d,autoStart:p,connectLabel:k,showStartButton:v}=t,f=Me(s,n);if(!f)return null;const l=f.id,b=f.id;let h;e[0]!==f?(h=ae(f),e[0]=f,e[1]=h):h=e[1];let i;return e[2]!==p||e[3]!==k||e[4]!==n||e[5]!==f.id||e[6]!==d||e[7]!==v||e[8]!==h?(i=a.jsx(qe,{integrationId:b,methods:h,directory:n,onConnected:d,autoStart:p,connectLabel:k,showStartButton:v},l),e[2]=p,e[3]=k,e[4]=n,e[5]=f.id,e[6]=d,e[7]=v,e[8]=h,e[9]=i):i=e[9],i},Ue=je({error:we(["invalid-path","invalid-url","not-found","invalid-manifest","id-taken","already-installed","missing-build","host-too-old","bundled","reserved-id","clone-failed","clone-auth-failed","extract-failed","too-large","enterprise-mode"]),required:W().trim().min(1).max(64).optional(),id:W().trim().min(1).max(128).optional()}),Ge=t=>{const e=t.trim();if(!e)return{ok:!1,code:"invalid-path"};if(e.slice(0,8).toLowerCase()==="https://")return{ok:!0,request:{url:e}};if(e.slice(0,6).toLowerCase()==="ssh://"||/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?[A-Za-z0-9][A-Za-z0-9.-]*\.[A-Za-z0-9.-]+:[^\s]+$/.test(e))return{ok:!0,request:{url:e}};const s=/^[a-zA-Z]:[\\/]/.test(e);return/^[a-z][a-z0-9+.-]*:/i.test(e)&&!s?{ok:!1,code:"invalid-url"}:e.startsWith("/")||s||e.startsWith("\\\\")?{ok:!0,request:{path:e}}:{ok:!1,code:"invalid-path"}},re=async t=>{try{const e=Ue.safeParse(JSON.parse(await t.text()));return e.success?e.data.error==="host-too-old"&&e.data.required&&e.data.id?{code:"host-too-old",required:e.data.required,id:e.data.id}:e.data.error==="host-too-old"&&e.data.required?{code:"host-too-old",required:e.data.required}:e.data.id?{code:e.data.error,id:e.data.id}:{code:e.data.error}:{code:"failed"}}catch{return{code:"failed"}}},ne=async(t,e)=>{if(!t.ok)return{ok:!1,...await re(t),diagnostic:{method:"POST",path:e,kind:"http",status:t.status}};const s=await t.text().catch(()=>null),n=s===null?null:be(s);return n==="unreadable"?{ok:!1,code:"unreadable"}:n?{ok:!0,guest:n,replaced:t.status===200}:{ok:!1,code:"failed",diagnostic:{method:"POST",path:e,kind:"invalid-response",status:t.status}}},He=async(t,e={})=>{const s=Ge(t);if(!s.ok)return s;const n={...s.request};e.replace&&(n.replace=!0),"url"in n&&e.gitIdentityId&&(n.gitIdentityId=e.gitIdentityId);try{const d=await z("/api/guests",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});return await ne(d,"/api/guests")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests",kind:"network"}}}},Qe=async(t,e={})=>{try{const s=await z("/api/guests/upload",{method:"POST",query:{replace:e.replace?"true":void 0,name:t.name||void 0},headers:{"Content-Type":"application/octet-stream",Accept:"application/json"},body:t});return await ne(s,"/api/guests/upload")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests/upload",kind:"network"}}}},Ye=async t=>{const e=xe.getState(),s=Ce(),n=e.runtimeKey===s?e.guests.find(d=>d.id===t)?.storageId:void 0;try{const d=await z(`/api/guests/${t}`,{method:"DELETE"});return d.status===204?(n&&globalThis.indexedDB&&await ke({runtimeKey:s,guestId:t,storageId:n}).catch(()=>{console.warn("Could not clear local extension preferences.")}),{ok:!0}):{ok:!1,code:(await re(d)).code}}catch{return{ok:!1,code:"failed"}}},Xe=async(t,e)=>{try{return(await z(`/api/guests/${t}/enabled`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})})).ok}catch{return!1}},et=async(t,e)=>{try{return(await z(`/api/guests/${t}/capabilities`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({granted:e})})).ok}catch{return!1}};export{H as M,De as P,We as a,Me as b,Ne as c,P as d,Ee as e,Fe as f,O as g,ze as h,He as i,qe as j,Qe as k,et as l,Be as n,Ke as r,Xe as s,Ye as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as X,v as Q,h as Y,s as Z,c as y,r as nn,i as en}from"./computeVirtualFileMetrics-ClD-wmbl.js";import{g as U}from"./getFiletypeFromFileName-BgI9McTw.js";import{fR as W,fS as V,fT as q}from"./useAppFontEffects-DDoHSSlY.js";import{d as tn,a as on}from"./vendor-diff-C3JhlQdm.js";function xn(n,e){return n?.cacheKey!=null||e?.cacheKey!=null?n?.cacheKey===e?.cacheKey:n===e}function En(n,e){return n?.cacheKey===e?.cacheKey&&n?.contents===e?.contents&&n?.name===e?.name&&n?.lang===e?.lang}function wn(n,e){return X(n.theme,e.theme)&&n.useTokenTransformer===e.useTokenTransformer&&n.tokenizeMaxLineLength===e.tokenizeMaxLineLength&&n.lineDiffType===e.lineDiffType&&n.maxLineDiffLength===e.maxLineDiffLength}function B({line:n,spanStart:e,spanLength:r}){return{start:{line:n,character:e},end:{line:n,character:e+r},properties:{"data-diff-span":""},alwaysWrap:!0}}function A({item:n,arr:e,enableJoin:r,isNeutral:a=!1,isLastItem:h=!1}){const t=e[e.length-1];if(t==null||h||!r){e.push([a?0:1,n.value]);return}const l=t[0]===0;if(a===l||a&&n.value.length===1&&!l){t[1]+=n.value;return}e.push([a?0:1,n.value])}function _(n){return[V(n.additionStart,n.additionCount)+1,W(n.additionStart,n.additionCount)+1]}function $({isPartial:n,rangeSize:e,expandedHunks:r,hunkIndex:a,collapsedContextThreshold:h}){const t=Math.max(e,0);if(t===0||n)return{fromStart:0,fromEnd:0,rangeSize:t,collapsedLines:t,renderAll:!1};if(r===!0||t<=h)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const l=r?.get(a),u=Math.min(Math.max(l?.fromStart??0,0),t),i=Math.min(Math.max(l?.fromEnd??0,0),t),s=u+i,o=s>=t;return{fromStart:o?t:u,fromEnd:o?0:i,rangeSize:t,collapsedLines:Math.max(t-s,0),renderAll:o}}function Rn(n){const e=n.hunks[n.hunks.length-1];if(e==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return!1;const r=n.additionLines.length-W(e.additionStart,e.additionCount),a=n.deletionLines.length-W(e.deletionStart,e.deletionCount);return r<=0&&a<=0?!1:r!==a}function rn({fileDiff:n,errorPrefix:e}){const r=n.hunks[n.hunks.length-1];if(r==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return 0;const a=n.additionLines.length-W(r.additionStart,r.additionCount),h=n.deletionLines.length-W(r.deletionStart,r.deletionCount);if(a<=0&&h<=0)return 0;if(a!==h)throw new Error(`${e}: trailing context mismatch (additions=${a}, deletions=${h}) for ${n.name}`);return Math.min(a,h)}function K({fileDiff:n,hunkIndex:e,expandedHunks:r,collapsedContextThreshold:a,errorPrefix:h}){if(e!==n.hunks.length-1)return;const t=rn({fileDiff:n,errorPrefix:h});if(t<=0)return;if(r===!0||t<=a)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const l=r?.get(n.hunks.length),u=Math.min(Math.max(l?.fromStart??0,0),t);return{fromStart:u,fromEnd:0,rangeSize:t,collapsedLines:t-u,renderAll:u>=t}}function bn({fileDiff:n,lineNumber:e,expandedHunks:r,collapsedContextThreshold:a}){if(r===!0||n.isPartial)return!0;for(const[u,i]of n.hunks.entries()){const[s,o]=_(i);if(e<s){const d=$({isPartial:n.isPartial,rangeSize:i.collapsedBefore,expandedHunks:r,hunkIndex:u,collapsedContextThreshold:a}),c=s-d.rangeSize;return d.renderAll||e<c+d.fromStart||e>=s-d.fromEnd}if(e<o)return!0}const h=K({fileDiff:n,hunkIndex:n.hunks.length-1,expandedHunks:r,collapsedContextThreshold:a,errorPrefix:"isAdditionLineRenderable"});if(h==null||h.renderAll)return!0;const t=n.hunks[n.hunks.length-1],[,l]=_(t);return e<l+h.fromStart||e>=l+h.rangeSize}function On({fileDiff:n,lineNumber:e,direction:r,expandedHunks:a,collapsedContextThreshold:h}){if(a===!0||n.isPartial)return e;const t=[];let l=1;for(const[i,s]of n.hunks.entries()){const[o,d]=_(s),c=$({isPartial:n.isPartial,rangeSize:s.collapsedBefore,expandedHunks:a,hunkIndex:i,collapsedContextThreshold:h}),f=o-c.rangeSize;c.renderAll?t.push([f,o]):(c.fromStart>0&&t.push([f,f+c.fromStart]),c.fromEnd>0&&t.push([o-c.fromEnd,o])),t.push([o,d]),l=d}const u=K({fileDiff:n,hunkIndex:n.hunks.length-1,expandedHunks:a,collapsedContextThreshold:h,errorPrefix:"getNearestRenderableAdditionLine"});if(u!=null){const i=l;l=i+u.rangeSize,u.renderAll?t.push([i,l]):u.fromStart>0&&t.push([i,i+u.fromStart])}if(e>=l)return e;if(r==="down"){for(const[i,s]of t)if(s>e)return Math.max(i,e);return}for(let i=t.length-1;i>=0;i--){const[s,o]=t[i];if(s<=e)return Math.min(o-1,e)}}function G({type:n,metrics:e}){return e.hunkSeparatorHeight??Q(n)}function J({type:n,metrics:e}){return n==="simple"||n==="metadata"||n==="line-info-basic"?0:e.spacing}function sn({type:n,hunkIndex:e,hunkSpecs:r}){switch(n){case"simple":return e>0;case"metadata":return r!=null;case"line-info":case"line-info-basic":case"custom":return!0}}function an(n){return n!=="simple"&&n!=="metadata"}function Fn({type:n,metrics:e,hunkIndex:r,hunkSpecs:a}){if(!sn({type:n,hunkIndex:r,hunkSpecs:a}))return;const h=G({type:n,metrics:e}),t=J({type:n,metrics:e}),l=r>0?t:0,u=t;return{height:h,gapBefore:l,gapAfter:u,totalHeight:l+h+u}}function Hn({type:n,metrics:e}){if(!an(n))return;const r=G({type:n,metrics:e}),a=J({type:n,metrics:e});return{height:r,gapBefore:a,gapAfter:0,totalHeight:a+r}}function ln({diff:n,diffStyle:e,startingLine:r=0,totalLines:a=1/0,expandedHunks:h,collapsedContextThreshold:t=1,callback:l}){const u=un({diff:n,diffStyle:e,startingLine:r,expandedHunks:h,collapsedContextThreshold:t}),i={viewportStart:r,viewportEnd:r+a,isWindowedHighlight:r>0||a<1/0,splitCount:u.splitCount,unifiedCount:u.unifiedCount,finalHunkIndex:n.hunks.length-1,shouldBreak(){if(!i.isWindowedHighlight)return!1;const s=i.unifiedCount>=r+a,o=i.splitCount>=r+a;return e==="unified"?s:(e==="split"||s)&&o},shouldSkip(s,o){if(!i.isWindowedHighlight)return!1;const d=s>0&&i.unifiedCount+s<=r,c=o>0&&i.splitCount+o<=r;return e==="unified"?d:(e==="split"||d)&&c},incrementCounts(s,o){(e==="unified"||e==="both")&&(i.unifiedCount+=s),(e==="split"||e==="both")&&(i.splitCount+=o)},isInWindow(s,o){if(!i.isWindowedHighlight)return!0;const d=i.isInUnifiedWindow(s),c=i.isInSplitWindow(o);return e==="unified"?d:e==="split"?c:d||c},isInUnifiedWindow(s){return!i.isWindowedHighlight||i.unifiedCount>=r-s&&i.unifiedCount<r+a},isInSplitWindow(s){return!i.isWindowedHighlight||i.splitCount>=r-s&&i.splitCount<r+a},emit(s,o=!1){return o||(e==="unified"?i.incrementCounts(1,0):e==="split"?i.incrementCounts(0,1):i.incrementCounts(1,1)),l(s)??!1}};n:for(let s=u.hunkIndex;s<n.hunks.length;s++){let P=function(g,S){return F==null||F.collapsedLines<=0||F.fromStart+F.fromEnd>0?0:e==="unified"?g===o.unifiedLineStart+o.unifiedLineCount-1?F.collapsedLines:0:S===o.splitLineStart+o.splitLineCount-1?F.collapsedLines:0},I=function(){return z?0:(z=!0,p.collapsedLines)};const o=n.hunks[s];if(o==null)throw new Error("iterateOverDiff: invalid hunk index");if(i.shouldBreak())break;const d=V(o.deletionStart,o.deletionCount),c=V(o.additionStart,o.additionCount),f=!n.isPartial&&o.deletionCount===0?d:o.deletionLineIndex,m=!n.isPartial&&o.additionCount===0?c:o.additionLineIndex,p=$({isPartial:n.isPartial,rangeSize:o.collapsedBefore,expandedHunks:h,hunkIndex:s,collapsedContextThreshold:t}),F=s===i.finalHunkIndex?K({fileDiff:n,hunkIndex:s,expandedHunks:h,collapsedContextThreshold:t,errorPrefix:"iterateOverDiff"}):void 0,H=p.fromStart+p.fromEnd;let z=p.collapsedLines===0;if(i.shouldSkip(H,H))i.incrementCounts(H,H),I();else{let g=o.unifiedLineStart-p.rangeSize,S=o.splitLineStart-p.rangeSize,R=f-p.rangeSize,O=m-p.rangeSize,x=d+1-p.rangeSize,M=c+1-p.rangeSize;if(D(i,p.fromStart,e,w=>i.emit({hunkIndex:s,hunk:o,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:x+w,lineIndex:R+w,noEOFCR:!1,unifiedLineIndex:g+w,splitLineIndex:S+w},additionLine:{unifiedLineIndex:g+w,splitLineIndex:S+w,lineIndex:O+w,lineNumber:M+w,noEOFCR:!1}}))||(g=o.unifiedLineStart-p.fromEnd,S=o.splitLineStart-p.fromEnd,R=f-p.fromEnd,O=m-p.fromEnd,x=d+1-p.fromEnd,M=c+1-p.fromEnd,D(i,p.fromEnd,e,w=>i.emit({hunkIndex:s,hunk:o,collapsedBefore:I(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:x+w,lineIndex:R+w,noEOFCR:!1,unifiedLineIndex:g+w,splitLineIndex:S+w},additionLine:{unifiedLineIndex:g+w,splitLineIndex:S+w,lineIndex:O+w,lineNumber:M+w,noEOFCR:!1}}),()=>{I()})))break n}let C=o.unifiedLineStart,k=o.splitLineStart,v=f,L=m,E=d+1,b=c+1;const T=o.hunkContent.at(-1);for(const g of o.hunkContent){if(i.shouldBreak())break n;const S=g===T;if(g.type==="context"){if(i.shouldSkip(g.lines,g.lines))i.incrementCounts(g.lines,g.lines),I();else if(D(i,g.lines,e,R=>{const O=S&&R===g.lines-1,x=C+R,M=k+R;return i.emit({hunkIndex:s,hunk:o,collapsedBefore:I(),collapsedAfter:P(x,M),type:"context",deletionLine:{lineNumber:E+R,lineIndex:v+R,noEOFCR:O&&o.noEOFCRDeletions,unifiedLineIndex:x,splitLineIndex:M},additionLine:{unifiedLineIndex:x,splitLineIndex:M,lineIndex:L+R,lineNumber:b+R,noEOFCR:O&&o.noEOFCRAdditions}})},()=>{I()}))break n;C+=g.lines,k+=g.lines,v+=g.lines,L+=g.lines,E+=g.lines,b+=g.lines}else{const R=Math.max(g.deletions,g.additions),O=g.deletions+g.additions;if(!i.shouldSkip(O,R)){const x=hn(i,g,e);(x[0]?.[0]??0)>0&&I();for(const[M,w]of x)for(let N=M;N<w;N++){const j=P(C+N,e==="unified"?k+(N<g.deletions?N:N-g.deletions):k+N);if(i.emit(gn({hunkIndex:s,hunk:o,collapsedBefore:I(),collapsedAfter:j,diffStyle:e,index:N,unifiedLineIndex:C,splitLineIndex:k,additionLineIndex:L,deletionLineIndex:v,additionLineNumber:b,deletionLineNumber:E,content:g,isLastContent:S,unifiedCount:O,splitCount:R}),!0))break n}}I(),i.incrementCounts(O,R),C+=O,k+=R,v+=g.deletions,L+=g.additions,E+=g.deletions,b+=g.additions}}if(F!=null){const{collapsedLines:g,fromStart:S,fromEnd:R}=F,O=S+R;if(D(i,O,e,x=>{const M=x===O-1;return i.emit({hunkIndex:n.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:M?g:0,type:"context-expanded",deletionLine:{lineNumber:E+x,lineIndex:v+x,noEOFCR:!1,unifiedLineIndex:C+x,splitLineIndex:k+x},additionLine:{unifiedLineIndex:C+x,splitLineIndex:k+x,lineIndex:L+x,lineNumber:b+x,noEOFCR:!1}})},void 0,()=>i.shouldBreak()))break n}}}function un({diff:n,diffStyle:e,startingLine:r,expandedHunks:a,collapsedContextThreshold:h}){if(r<=0||e==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};const t=dn({diff:n,expandedHunks:a,collapsedContextThreshold:h});let l=0,u=n.hunks.length-1,i=n.hunks.length;for(;l<=u;){const o=l+u>>1,d=t[o+1];if(d==null)throw new Error("iterateOverDiff: invalid hunk prefix index");(e==="unified"?d.unifiedCount:d.splitCount)>r?(i=o,u=o-1):l=o+1}if(i>=n.hunks.length){const o=t[n.hunks.length];if(o==null)throw new Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:n.hunks.length,splitCount:o.splitCount,unifiedCount:o.unifiedCount}}const s=t[i];if(s==null)throw new Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:i,splitCount:s.splitCount,unifiedCount:s.unifiedCount}}function dn({diff:n,expandedHunks:e,collapsedContextThreshold:r}){let a=0,h=0;const t=n.hunks.length-1,l=[{splitCount:0,unifiedCount:0}];for(let u=0;u<n.hunks.length;u++){const i=n.hunks[u];if(i==null)throw new Error("iterateOverDiff: invalid hunk summary index");const s=$({isPartial:n.isPartial,rangeSize:i.collapsedBefore,expandedHunks:e,hunkIndex:u,collapsedContextThreshold:r}),o=s.fromStart+s.fromEnd;a+=o+i.splitLineCount,h+=o+i.unifiedLineCount;const d=u===t?K({fileDiff:n,hunkIndex:u,expandedHunks:e,collapsedContextThreshold:r,errorPrefix:"iterateOverDiff"}):void 0;if(d!=null){const c=d.fromStart+d.fromEnd;a+=c,h+=c}l.push({splitCount:a,unifiedCount:h})}return l}function cn(n,e,r){if(!n.isWindowedHighlight||e<=0)return[0,e];const a=[];function h(u){const i=Math.max(0,n.viewportStart-u),s=Math.min(e,n.viewportEnd-u);s>i&&a.push([i,s])}if(r!=="split"&&h(n.unifiedCount),r!=="unified"&&h(n.splitCount),a.length===0)return[0,0];let t=a[0][0],l=a[0][1];for(let u=1;u<a.length;u++){const i=a[u];t=Math.min(t,i[0]),l=Math.max(l,i[1])}return[t,l]}function D(n,e,r,a,h,t){const[l,u]=cn(n,e,r);l>0&&(n.incrementCounts(l,l),h?.());let i=l;for(;i<e;){if(t?.()===!0)return!0;if(i>=u){n.incrementCounts(e-i,e-i);break}if(n.isInWindow(0,0)){if(a(i)===!0)return!0}else n.incrementCounts(1,1);i++}return!1}function hn(n,e,r){if(!n.isWindowedHighlight)return[[0,r==="unified"?e.deletions+e.additions:Math.max(e.deletions,e.additions)]];const a=r!=="split",h=r!=="unified",t=r==="unified"?"unified":"split",l=[];function u(d,c){if(d+c<=n.viewportStart||d>=n.viewportEnd)return;const f=Math.max(0,n.viewportStart-d),m=Math.min(c,n.viewportEnd-d);return m>f?[f,m]:void 0}function i(d,c){return t==="split"?d:c==="additions"?[d[0]+e.deletions,d[1]+e.deletions]:d}function s(d,c){if(d==null)return;const[f,m]=i(d,c);m>f&&l.push([f,m])}if(a&&(s(u(n.unifiedCount,e.deletions),"deletions"),s(u(n.unifiedCount+e.deletions,e.additions),"additions")),h&&(s(u(n.splitCount,e.deletions),"deletions"),s(u(n.splitCount,e.additions),"additions")),l.length===0)return l;l.sort((d,c)=>d[0]-c[0]);const o=[l[0]];for(const[d,c]of l.slice(1)){const f=o[o.length-1];d<=f[1]?f[1]=Math.max(f[1],c):o.push([d,c])}return o}function gn({hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:a,diffStyle:h,index:t,unifiedLineIndex:l,splitLineIndex:u,additionLineIndex:i,deletionLineIndex:s,additionLineNumber:o,deletionLineNumber:d,content:c,isLastContent:f,unifiedCount:m,splitCount:p}){const F=t<c.deletions?l+t:void 0,H=h==="unified"?t>=c.deletions?l+t:void 0:t<c.additions?l+c.deletions+t:void 0,P=h==="unified"?u+(t<c.deletions?t:t-c.deletions):u+t,z=t<c.deletions?s+t:void 0,I=t<c.deletions?d+t:void 0,C=h==="unified"?t>=c.deletions?i+(t-c.deletions):void 0:t<c.additions?i+t:void 0,k=h==="unified"?t>=c.deletions?o+(t-c.deletions):void 0:t<c.additions?o+t:void 0,v=h==="unified"?f&&t===c.deletions-1&&e.noEOFCRDeletions:f&&t===p-1&&e.noEOFCRDeletions,L=h==="unified"?f&&t===m-1&&e.noEOFCRAdditions:f&&t===p-1&&e.noEOFCRAdditions,E=z!=null&&I!=null&&F!=null?{lineNumber:I,lineIndex:z,noEOFCR:v,unifiedLineIndex:F,splitLineIndex:P}:void 0,b=C!=null&&k!=null&&H!=null?{unifiedLineIndex:H,splitLineIndex:P,lineIndex:C,lineNumber:k,noEOFCR:L}:void 0;if(E==null&&b!=null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:a,deletionLine:void 0,additionLine:b};if(E!=null&&b==null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:a,deletionLine:E,additionLine:void 0};if(E==null||b==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:a,deletionLine:E,additionLine:b}}const fn={forcePlainText:!1};function Mn(n,e,r,{forcePlainText:a,lazyLineAST:h=!1,startingLine:t,totalLines:l,expandedHunks:u,collapsedContextThreshold:i=1}=fn){a?(t??=0,l??=1/0):(t=0,l=1/0);const s=t>0||l<1/0;h&&=!a&&!r.useTokenTransformer;const o=typeof r.theme=="string"?e.getTheme(r.theme).type:void 0,d=Y({theme:r.theme,highlighter:e}),c=a&&!s&&(n.unifiedLineCount>1e3||n.splitLineCount>1e3)?"none":r.lineDiffType,f={deletionLines:[],additionLines:[]},{maxLineDiffLength:m}=r,p=!a&&!n.isPartial,F=a?u:void 0,H=new Map;function P(I){const C=p?0:I,k=H.get(C)??In();return H.set(C,k),k}function z(I,C,k,v){if(s){let L=k.at(-1);(L==null||L.targetIndex+L.count!==C)&&(L={targetIndex:C,originalOffset:v.length,count:0},k.push(L)),L.count++}v.push(I)}ln({diff:n,diffStyle:"both",startingLine:t,totalLines:l,expandedHunks:s?F:!0,collapsedContextThreshold:i,callback:({hunkIndex:I,additionLine:C,deletionLine:k,type:v})=>{const L=P(I),E=C!=null?C.splitLineIndex:k.splitLineIndex;v==="change"&&C!=null&&k!=null&&pn({additionLine:n.additionLines[C.lineIndex],deletionLine:n.deletionLines[k.lineIndex],deletionLineIndex:L.deletionContent.length,additionLineIndex:L.additionContent.length,deletionDecorations:L.deletionDecorations,additionDecorations:L.additionDecorations,lineDiffType:c,maxLineDiffLength:m}),k!=null&&(z(n.deletionLines[k.lineIndex],k.lineIndex,L.deletionSegments,L.deletionContent),L.deletionInfo.push({type:v==="change"?"change-deletion":v,lineNumber:k.lineNumber,altLineNumber:v==="change"?void 0:C.lineNumber??void 0,lineIndex:`${k.unifiedLineIndex},${E}`})),C!=null&&(z(n.additionLines[C.lineIndex],C.lineIndex,L.additionSegments,L.additionContent),L.additionInfo.push({type:v==="change"?"change-addition":v,lineNumber:C.lineNumber,altLineNumber:v==="change"?void 0:k.lineNumber??void 0,lineIndex:`${C.unifiedLineIndex},${E}`}))}});for(const I of H.values()){if(I.deletionContent.length===0&&I.additionContent.length===0)continue;const C={name:n.prevName??n.name,contents:I.deletionContent.value},k={name:n.name,contents:I.additionContent.value},{deletionLines:v,additionLines:L}=Cn({deletionFile:C,deletionInfo:I.deletionInfo,deletionDecorations:I.deletionDecorations,additionFile:k,additionInfo:I.additionInfo,additionDecorations:I.additionDecorations,highlighter:e,options:r,languageOverride:a?"text":n.lang,lazyLineAST:h});if(p){f.deletionLines=v,f.additionLines=L;continue}for(const[E,b,T]of[[f.deletionLines,v,I.deletionSegments],[f.additionLines,L,I.additionSegments]])if(T.length>0)for(const g of T)for(let S=0;S<g.count;S++)E[g.targetIndex+S]=b[g.originalOffset+S];else if(h){const g=E.length;for(let S=0;S<b.length;S++)Z(E,g+S,()=>b[S])}else y(E,b)}return{code:f,themeStyles:d,baseThemeType:o}}function mn(n,{deletionLineIndex:e,additionLineIndex:r,deletionDecorations:a,additionDecorations:h}){let t=0,l=0,u=-1,i=0,s=-1,o=0;for(const{value:d,added:c,removed:f}of n)f?(u===-1&&(u=t),t+=d.length,i=t):c?(s===-1&&(s=l),l+=d.length,o=l):(t+=d.length,l+=d.length);u!==-1&&a.push(B({line:e,spanStart:u,spanLength:i-u})),s!==-1&&h.push(B({line:r,spanStart:s,spanLength:o-s}))}function pn({deletionLine:n,additionLine:e,deletionLineIndex:r,additionLineIndex:a,deletionDecorations:h,additionDecorations:t,lineDiffType:l,maxLineDiffLength:u}){if(n==null||e==null||l==="none"||(n=q(n),e=q(e),n.length>u||e.length>u))return;const i=l==="char"?tn(n,e):on(n,e);if(l==="word-line"){mn(i,{deletionLineIndex:r,additionLineIndex:a,deletionDecorations:h,additionDecorations:t});return}const s=[],o=[],d=l==="word-alt",c=i.at(-1);for(const m of i){const p=m===c;!m.added&&!m.removed?(A({item:m,arr:s,enableJoin:d,isNeutral:!0,isLastItem:p}),A({item:m,arr:o,enableJoin:d,isNeutral:!0,isLastItem:p})):m.removed?A({item:m,arr:s,enableJoin:d,isLastItem:p}):A({item:m,arr:o,enableJoin:d,isLastItem:p})}let f=0;for(const m of s)m[0]===1&&h.push(B({line:r,spanStart:f,spanLength:m[1].length})),f+=m[1].length;f=0;for(const m of o)m[0]===1&&t.push(B({line:a,spanStart:f,spanLength:m[1].length})),f+=m[1].length}function In(){return{deletionContent:{push(n){this.value+=n,this.length++},value:"",length:0},additionContent:{push(n){this.value+=n,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function Cn({lazyLineAST:n,deletionFile:e,additionFile:r,deletionInfo:a,additionInfo:h,highlighter:t,deletionDecorations:l,additionDecorations:u,languageOverride:i,options:{theme:s,useTokenTransformer:o,tokenizeMaxLineLength:d}}){const c=(f,m,p)=>f.contents===""?[]:nn(t.codeToTokens(q(f.contents),en(i??U(f.name),s,d)).tokens,{state:{lineInfo:m},useTokenTransformer:o,decorations:p,lazyLineAST:n,cacheHtmlStyles:t.name==="highlights"});return{deletionLines:c(e,a,l),additionLines:c(r,h,u)}}function zn(n){const e=n.lang??U(n.name),r=n.lang??(n.prevName!=null?U(n.prevName):"text");return e==="text"&&r==="text"}export{xn as a,wn as b,En as c,K as d,ln as e,rn as f,$ as g,Rn as h,zn as i,bn as j,On as k,_ as l,Fn as m,Hn as n,Mn as r};
|
|
1
|
+
import{g as X,v as Q,h as Y,s as Z,c as y,r as nn,i as en}from"./computeVirtualFileMetrics-BhVDZ-oP.js";import{g as U}from"./getFiletypeFromFileName-BgI9McTw.js";import{fR as W,fS as V,fT as q}from"./useAppFontEffects-DpDiWkkc.js";import{d as tn,a as on}from"./vendor-diff-C3JhlQdm.js";function xn(n,e){return n?.cacheKey!=null||e?.cacheKey!=null?n?.cacheKey===e?.cacheKey:n===e}function En(n,e){return n?.cacheKey===e?.cacheKey&&n?.contents===e?.contents&&n?.name===e?.name&&n?.lang===e?.lang}function wn(n,e){return X(n.theme,e.theme)&&n.useTokenTransformer===e.useTokenTransformer&&n.tokenizeMaxLineLength===e.tokenizeMaxLineLength&&n.lineDiffType===e.lineDiffType&&n.maxLineDiffLength===e.maxLineDiffLength}function B({line:n,spanStart:e,spanLength:r}){return{start:{line:n,character:e},end:{line:n,character:e+r},properties:{"data-diff-span":""},alwaysWrap:!0}}function A({item:n,arr:e,enableJoin:r,isNeutral:a=!1,isLastItem:h=!1}){const t=e[e.length-1];if(t==null||h||!r){e.push([a?0:1,n.value]);return}const l=t[0]===0;if(a===l||a&&n.value.length===1&&!l){t[1]+=n.value;return}e.push([a?0:1,n.value])}function _(n){return[V(n.additionStart,n.additionCount)+1,W(n.additionStart,n.additionCount)+1]}function $({isPartial:n,rangeSize:e,expandedHunks:r,hunkIndex:a,collapsedContextThreshold:h}){const t=Math.max(e,0);if(t===0||n)return{fromStart:0,fromEnd:0,rangeSize:t,collapsedLines:t,renderAll:!1};if(r===!0||t<=h)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const l=r?.get(a),u=Math.min(Math.max(l?.fromStart??0,0),t),i=Math.min(Math.max(l?.fromEnd??0,0),t),s=u+i,o=s>=t;return{fromStart:o?t:u,fromEnd:o?0:i,rangeSize:t,collapsedLines:Math.max(t-s,0),renderAll:o}}function Rn(n){const e=n.hunks[n.hunks.length-1];if(e==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return!1;const r=n.additionLines.length-W(e.additionStart,e.additionCount),a=n.deletionLines.length-W(e.deletionStart,e.deletionCount);return r<=0&&a<=0?!1:r!==a}function rn({fileDiff:n,errorPrefix:e}){const r=n.hunks[n.hunks.length-1];if(r==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return 0;const a=n.additionLines.length-W(r.additionStart,r.additionCount),h=n.deletionLines.length-W(r.deletionStart,r.deletionCount);if(a<=0&&h<=0)return 0;if(a!==h)throw new Error(`${e}: trailing context mismatch (additions=${a}, deletions=${h}) for ${n.name}`);return Math.min(a,h)}function K({fileDiff:n,hunkIndex:e,expandedHunks:r,collapsedContextThreshold:a,errorPrefix:h}){if(e!==n.hunks.length-1)return;const t=rn({fileDiff:n,errorPrefix:h});if(t<=0)return;if(r===!0||t<=a)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const l=r?.get(n.hunks.length),u=Math.min(Math.max(l?.fromStart??0,0),t);return{fromStart:u,fromEnd:0,rangeSize:t,collapsedLines:t-u,renderAll:u>=t}}function bn({fileDiff:n,lineNumber:e,expandedHunks:r,collapsedContextThreshold:a}){if(r===!0||n.isPartial)return!0;for(const[u,i]of n.hunks.entries()){const[s,o]=_(i);if(e<s){const d=$({isPartial:n.isPartial,rangeSize:i.collapsedBefore,expandedHunks:r,hunkIndex:u,collapsedContextThreshold:a}),c=s-d.rangeSize;return d.renderAll||e<c+d.fromStart||e>=s-d.fromEnd}if(e<o)return!0}const h=K({fileDiff:n,hunkIndex:n.hunks.length-1,expandedHunks:r,collapsedContextThreshold:a,errorPrefix:"isAdditionLineRenderable"});if(h==null||h.renderAll)return!0;const t=n.hunks[n.hunks.length-1],[,l]=_(t);return e<l+h.fromStart||e>=l+h.rangeSize}function On({fileDiff:n,lineNumber:e,direction:r,expandedHunks:a,collapsedContextThreshold:h}){if(a===!0||n.isPartial)return e;const t=[];let l=1;for(const[i,s]of n.hunks.entries()){const[o,d]=_(s),c=$({isPartial:n.isPartial,rangeSize:s.collapsedBefore,expandedHunks:a,hunkIndex:i,collapsedContextThreshold:h}),f=o-c.rangeSize;c.renderAll?t.push([f,o]):(c.fromStart>0&&t.push([f,f+c.fromStart]),c.fromEnd>0&&t.push([o-c.fromEnd,o])),t.push([o,d]),l=d}const u=K({fileDiff:n,hunkIndex:n.hunks.length-1,expandedHunks:a,collapsedContextThreshold:h,errorPrefix:"getNearestRenderableAdditionLine"});if(u!=null){const i=l;l=i+u.rangeSize,u.renderAll?t.push([i,l]):u.fromStart>0&&t.push([i,i+u.fromStart])}if(e>=l)return e;if(r==="down"){for(const[i,s]of t)if(s>e)return Math.max(i,e);return}for(let i=t.length-1;i>=0;i--){const[s,o]=t[i];if(s<=e)return Math.min(o-1,e)}}function G({type:n,metrics:e}){return e.hunkSeparatorHeight??Q(n)}function J({type:n,metrics:e}){return n==="simple"||n==="metadata"||n==="line-info-basic"?0:e.spacing}function sn({type:n,hunkIndex:e,hunkSpecs:r}){switch(n){case"simple":return e>0;case"metadata":return r!=null;case"line-info":case"line-info-basic":case"custom":return!0}}function an(n){return n!=="simple"&&n!=="metadata"}function Fn({type:n,metrics:e,hunkIndex:r,hunkSpecs:a}){if(!sn({type:n,hunkIndex:r,hunkSpecs:a}))return;const h=G({type:n,metrics:e}),t=J({type:n,metrics:e}),l=r>0?t:0,u=t;return{height:h,gapBefore:l,gapAfter:u,totalHeight:l+h+u}}function Hn({type:n,metrics:e}){if(!an(n))return;const r=G({type:n,metrics:e}),a=J({type:n,metrics:e});return{height:r,gapBefore:a,gapAfter:0,totalHeight:a+r}}function ln({diff:n,diffStyle:e,startingLine:r=0,totalLines:a=1/0,expandedHunks:h,collapsedContextThreshold:t=1,callback:l}){const u=un({diff:n,diffStyle:e,startingLine:r,expandedHunks:h,collapsedContextThreshold:t}),i={viewportStart:r,viewportEnd:r+a,isWindowedHighlight:r>0||a<1/0,splitCount:u.splitCount,unifiedCount:u.unifiedCount,finalHunkIndex:n.hunks.length-1,shouldBreak(){if(!i.isWindowedHighlight)return!1;const s=i.unifiedCount>=r+a,o=i.splitCount>=r+a;return e==="unified"?s:(e==="split"||s)&&o},shouldSkip(s,o){if(!i.isWindowedHighlight)return!1;const d=s>0&&i.unifiedCount+s<=r,c=o>0&&i.splitCount+o<=r;return e==="unified"?d:(e==="split"||d)&&c},incrementCounts(s,o){(e==="unified"||e==="both")&&(i.unifiedCount+=s),(e==="split"||e==="both")&&(i.splitCount+=o)},isInWindow(s,o){if(!i.isWindowedHighlight)return!0;const d=i.isInUnifiedWindow(s),c=i.isInSplitWindow(o);return e==="unified"?d:e==="split"?c:d||c},isInUnifiedWindow(s){return!i.isWindowedHighlight||i.unifiedCount>=r-s&&i.unifiedCount<r+a},isInSplitWindow(s){return!i.isWindowedHighlight||i.splitCount>=r-s&&i.splitCount<r+a},emit(s,o=!1){return o||(e==="unified"?i.incrementCounts(1,0):e==="split"?i.incrementCounts(0,1):i.incrementCounts(1,1)),l(s)??!1}};n:for(let s=u.hunkIndex;s<n.hunks.length;s++){let P=function(g,S){return F==null||F.collapsedLines<=0||F.fromStart+F.fromEnd>0?0:e==="unified"?g===o.unifiedLineStart+o.unifiedLineCount-1?F.collapsedLines:0:S===o.splitLineStart+o.splitLineCount-1?F.collapsedLines:0},I=function(){return z?0:(z=!0,p.collapsedLines)};const o=n.hunks[s];if(o==null)throw new Error("iterateOverDiff: invalid hunk index");if(i.shouldBreak())break;const d=V(o.deletionStart,o.deletionCount),c=V(o.additionStart,o.additionCount),f=!n.isPartial&&o.deletionCount===0?d:o.deletionLineIndex,m=!n.isPartial&&o.additionCount===0?c:o.additionLineIndex,p=$({isPartial:n.isPartial,rangeSize:o.collapsedBefore,expandedHunks:h,hunkIndex:s,collapsedContextThreshold:t}),F=s===i.finalHunkIndex?K({fileDiff:n,hunkIndex:s,expandedHunks:h,collapsedContextThreshold:t,errorPrefix:"iterateOverDiff"}):void 0,H=p.fromStart+p.fromEnd;let z=p.collapsedLines===0;if(i.shouldSkip(H,H))i.incrementCounts(H,H),I();else{let g=o.unifiedLineStart-p.rangeSize,S=o.splitLineStart-p.rangeSize,R=f-p.rangeSize,O=m-p.rangeSize,x=d+1-p.rangeSize,M=c+1-p.rangeSize;if(D(i,p.fromStart,e,w=>i.emit({hunkIndex:s,hunk:o,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:x+w,lineIndex:R+w,noEOFCR:!1,unifiedLineIndex:g+w,splitLineIndex:S+w},additionLine:{unifiedLineIndex:g+w,splitLineIndex:S+w,lineIndex:O+w,lineNumber:M+w,noEOFCR:!1}}))||(g=o.unifiedLineStart-p.fromEnd,S=o.splitLineStart-p.fromEnd,R=f-p.fromEnd,O=m-p.fromEnd,x=d+1-p.fromEnd,M=c+1-p.fromEnd,D(i,p.fromEnd,e,w=>i.emit({hunkIndex:s,hunk:o,collapsedBefore:I(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:x+w,lineIndex:R+w,noEOFCR:!1,unifiedLineIndex:g+w,splitLineIndex:S+w},additionLine:{unifiedLineIndex:g+w,splitLineIndex:S+w,lineIndex:O+w,lineNumber:M+w,noEOFCR:!1}}),()=>{I()})))break n}let C=o.unifiedLineStart,k=o.splitLineStart,v=f,L=m,E=d+1,b=c+1;const T=o.hunkContent.at(-1);for(const g of o.hunkContent){if(i.shouldBreak())break n;const S=g===T;if(g.type==="context"){if(i.shouldSkip(g.lines,g.lines))i.incrementCounts(g.lines,g.lines),I();else if(D(i,g.lines,e,R=>{const O=S&&R===g.lines-1,x=C+R,M=k+R;return i.emit({hunkIndex:s,hunk:o,collapsedBefore:I(),collapsedAfter:P(x,M),type:"context",deletionLine:{lineNumber:E+R,lineIndex:v+R,noEOFCR:O&&o.noEOFCRDeletions,unifiedLineIndex:x,splitLineIndex:M},additionLine:{unifiedLineIndex:x,splitLineIndex:M,lineIndex:L+R,lineNumber:b+R,noEOFCR:O&&o.noEOFCRAdditions}})},()=>{I()}))break n;C+=g.lines,k+=g.lines,v+=g.lines,L+=g.lines,E+=g.lines,b+=g.lines}else{const R=Math.max(g.deletions,g.additions),O=g.deletions+g.additions;if(!i.shouldSkip(O,R)){const x=hn(i,g,e);(x[0]?.[0]??0)>0&&I();for(const[M,w]of x)for(let N=M;N<w;N++){const j=P(C+N,e==="unified"?k+(N<g.deletions?N:N-g.deletions):k+N);if(i.emit(gn({hunkIndex:s,hunk:o,collapsedBefore:I(),collapsedAfter:j,diffStyle:e,index:N,unifiedLineIndex:C,splitLineIndex:k,additionLineIndex:L,deletionLineIndex:v,additionLineNumber:b,deletionLineNumber:E,content:g,isLastContent:S,unifiedCount:O,splitCount:R}),!0))break n}}I(),i.incrementCounts(O,R),C+=O,k+=R,v+=g.deletions,L+=g.additions,E+=g.deletions,b+=g.additions}}if(F!=null){const{collapsedLines:g,fromStart:S,fromEnd:R}=F,O=S+R;if(D(i,O,e,x=>{const M=x===O-1;return i.emit({hunkIndex:n.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:M?g:0,type:"context-expanded",deletionLine:{lineNumber:E+x,lineIndex:v+x,noEOFCR:!1,unifiedLineIndex:C+x,splitLineIndex:k+x},additionLine:{unifiedLineIndex:C+x,splitLineIndex:k+x,lineIndex:L+x,lineNumber:b+x,noEOFCR:!1}})},void 0,()=>i.shouldBreak()))break n}}}function un({diff:n,diffStyle:e,startingLine:r,expandedHunks:a,collapsedContextThreshold:h}){if(r<=0||e==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};const t=dn({diff:n,expandedHunks:a,collapsedContextThreshold:h});let l=0,u=n.hunks.length-1,i=n.hunks.length;for(;l<=u;){const o=l+u>>1,d=t[o+1];if(d==null)throw new Error("iterateOverDiff: invalid hunk prefix index");(e==="unified"?d.unifiedCount:d.splitCount)>r?(i=o,u=o-1):l=o+1}if(i>=n.hunks.length){const o=t[n.hunks.length];if(o==null)throw new Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:n.hunks.length,splitCount:o.splitCount,unifiedCount:o.unifiedCount}}const s=t[i];if(s==null)throw new Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:i,splitCount:s.splitCount,unifiedCount:s.unifiedCount}}function dn({diff:n,expandedHunks:e,collapsedContextThreshold:r}){let a=0,h=0;const t=n.hunks.length-1,l=[{splitCount:0,unifiedCount:0}];for(let u=0;u<n.hunks.length;u++){const i=n.hunks[u];if(i==null)throw new Error("iterateOverDiff: invalid hunk summary index");const s=$({isPartial:n.isPartial,rangeSize:i.collapsedBefore,expandedHunks:e,hunkIndex:u,collapsedContextThreshold:r}),o=s.fromStart+s.fromEnd;a+=o+i.splitLineCount,h+=o+i.unifiedLineCount;const d=u===t?K({fileDiff:n,hunkIndex:u,expandedHunks:e,collapsedContextThreshold:r,errorPrefix:"iterateOverDiff"}):void 0;if(d!=null){const c=d.fromStart+d.fromEnd;a+=c,h+=c}l.push({splitCount:a,unifiedCount:h})}return l}function cn(n,e,r){if(!n.isWindowedHighlight||e<=0)return[0,e];const a=[];function h(u){const i=Math.max(0,n.viewportStart-u),s=Math.min(e,n.viewportEnd-u);s>i&&a.push([i,s])}if(r!=="split"&&h(n.unifiedCount),r!=="unified"&&h(n.splitCount),a.length===0)return[0,0];let t=a[0][0],l=a[0][1];for(let u=1;u<a.length;u++){const i=a[u];t=Math.min(t,i[0]),l=Math.max(l,i[1])}return[t,l]}function D(n,e,r,a,h,t){const[l,u]=cn(n,e,r);l>0&&(n.incrementCounts(l,l),h?.());let i=l;for(;i<e;){if(t?.()===!0)return!0;if(i>=u){n.incrementCounts(e-i,e-i);break}if(n.isInWindow(0,0)){if(a(i)===!0)return!0}else n.incrementCounts(1,1);i++}return!1}function hn(n,e,r){if(!n.isWindowedHighlight)return[[0,r==="unified"?e.deletions+e.additions:Math.max(e.deletions,e.additions)]];const a=r!=="split",h=r!=="unified",t=r==="unified"?"unified":"split",l=[];function u(d,c){if(d+c<=n.viewportStart||d>=n.viewportEnd)return;const f=Math.max(0,n.viewportStart-d),m=Math.min(c,n.viewportEnd-d);return m>f?[f,m]:void 0}function i(d,c){return t==="split"?d:c==="additions"?[d[0]+e.deletions,d[1]+e.deletions]:d}function s(d,c){if(d==null)return;const[f,m]=i(d,c);m>f&&l.push([f,m])}if(a&&(s(u(n.unifiedCount,e.deletions),"deletions"),s(u(n.unifiedCount+e.deletions,e.additions),"additions")),h&&(s(u(n.splitCount,e.deletions),"deletions"),s(u(n.splitCount,e.additions),"additions")),l.length===0)return l;l.sort((d,c)=>d[0]-c[0]);const o=[l[0]];for(const[d,c]of l.slice(1)){const f=o[o.length-1];d<=f[1]?f[1]=Math.max(f[1],c):o.push([d,c])}return o}function gn({hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:a,diffStyle:h,index:t,unifiedLineIndex:l,splitLineIndex:u,additionLineIndex:i,deletionLineIndex:s,additionLineNumber:o,deletionLineNumber:d,content:c,isLastContent:f,unifiedCount:m,splitCount:p}){const F=t<c.deletions?l+t:void 0,H=h==="unified"?t>=c.deletions?l+t:void 0:t<c.additions?l+c.deletions+t:void 0,P=h==="unified"?u+(t<c.deletions?t:t-c.deletions):u+t,z=t<c.deletions?s+t:void 0,I=t<c.deletions?d+t:void 0,C=h==="unified"?t>=c.deletions?i+(t-c.deletions):void 0:t<c.additions?i+t:void 0,k=h==="unified"?t>=c.deletions?o+(t-c.deletions):void 0:t<c.additions?o+t:void 0,v=h==="unified"?f&&t===c.deletions-1&&e.noEOFCRDeletions:f&&t===p-1&&e.noEOFCRDeletions,L=h==="unified"?f&&t===m-1&&e.noEOFCRAdditions:f&&t===p-1&&e.noEOFCRAdditions,E=z!=null&&I!=null&&F!=null?{lineNumber:I,lineIndex:z,noEOFCR:v,unifiedLineIndex:F,splitLineIndex:P}:void 0,b=C!=null&&k!=null&&H!=null?{unifiedLineIndex:H,splitLineIndex:P,lineIndex:C,lineNumber:k,noEOFCR:L}:void 0;if(E==null&&b!=null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:a,deletionLine:void 0,additionLine:b};if(E!=null&&b==null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:a,deletionLine:E,additionLine:void 0};if(E==null||b==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:a,deletionLine:E,additionLine:b}}const fn={forcePlainText:!1};function Mn(n,e,r,{forcePlainText:a,lazyLineAST:h=!1,startingLine:t,totalLines:l,expandedHunks:u,collapsedContextThreshold:i=1}=fn){a?(t??=0,l??=1/0):(t=0,l=1/0);const s=t>0||l<1/0;h&&=!a&&!r.useTokenTransformer;const o=typeof r.theme=="string"?e.getTheme(r.theme).type:void 0,d=Y({theme:r.theme,highlighter:e}),c=a&&!s&&(n.unifiedLineCount>1e3||n.splitLineCount>1e3)?"none":r.lineDiffType,f={deletionLines:[],additionLines:[]},{maxLineDiffLength:m}=r,p=!a&&!n.isPartial,F=a?u:void 0,H=new Map;function P(I){const C=p?0:I,k=H.get(C)??In();return H.set(C,k),k}function z(I,C,k,v){if(s){let L=k.at(-1);(L==null||L.targetIndex+L.count!==C)&&(L={targetIndex:C,originalOffset:v.length,count:0},k.push(L)),L.count++}v.push(I)}ln({diff:n,diffStyle:"both",startingLine:t,totalLines:l,expandedHunks:s?F:!0,collapsedContextThreshold:i,callback:({hunkIndex:I,additionLine:C,deletionLine:k,type:v})=>{const L=P(I),E=C!=null?C.splitLineIndex:k.splitLineIndex;v==="change"&&C!=null&&k!=null&&pn({additionLine:n.additionLines[C.lineIndex],deletionLine:n.deletionLines[k.lineIndex],deletionLineIndex:L.deletionContent.length,additionLineIndex:L.additionContent.length,deletionDecorations:L.deletionDecorations,additionDecorations:L.additionDecorations,lineDiffType:c,maxLineDiffLength:m}),k!=null&&(z(n.deletionLines[k.lineIndex],k.lineIndex,L.deletionSegments,L.deletionContent),L.deletionInfo.push({type:v==="change"?"change-deletion":v,lineNumber:k.lineNumber,altLineNumber:v==="change"?void 0:C.lineNumber??void 0,lineIndex:`${k.unifiedLineIndex},${E}`})),C!=null&&(z(n.additionLines[C.lineIndex],C.lineIndex,L.additionSegments,L.additionContent),L.additionInfo.push({type:v==="change"?"change-addition":v,lineNumber:C.lineNumber,altLineNumber:v==="change"?void 0:k.lineNumber??void 0,lineIndex:`${C.unifiedLineIndex},${E}`}))}});for(const I of H.values()){if(I.deletionContent.length===0&&I.additionContent.length===0)continue;const C={name:n.prevName??n.name,contents:I.deletionContent.value},k={name:n.name,contents:I.additionContent.value},{deletionLines:v,additionLines:L}=Cn({deletionFile:C,deletionInfo:I.deletionInfo,deletionDecorations:I.deletionDecorations,additionFile:k,additionInfo:I.additionInfo,additionDecorations:I.additionDecorations,highlighter:e,options:r,languageOverride:a?"text":n.lang,lazyLineAST:h});if(p){f.deletionLines=v,f.additionLines=L;continue}for(const[E,b,T]of[[f.deletionLines,v,I.deletionSegments],[f.additionLines,L,I.additionSegments]])if(T.length>0)for(const g of T)for(let S=0;S<g.count;S++)E[g.targetIndex+S]=b[g.originalOffset+S];else if(h){const g=E.length;for(let S=0;S<b.length;S++)Z(E,g+S,()=>b[S])}else y(E,b)}return{code:f,themeStyles:d,baseThemeType:o}}function mn(n,{deletionLineIndex:e,additionLineIndex:r,deletionDecorations:a,additionDecorations:h}){let t=0,l=0,u=-1,i=0,s=-1,o=0;for(const{value:d,added:c,removed:f}of n)f?(u===-1&&(u=t),t+=d.length,i=t):c?(s===-1&&(s=l),l+=d.length,o=l):(t+=d.length,l+=d.length);u!==-1&&a.push(B({line:e,spanStart:u,spanLength:i-u})),s!==-1&&h.push(B({line:r,spanStart:s,spanLength:o-s}))}function pn({deletionLine:n,additionLine:e,deletionLineIndex:r,additionLineIndex:a,deletionDecorations:h,additionDecorations:t,lineDiffType:l,maxLineDiffLength:u}){if(n==null||e==null||l==="none"||(n=q(n),e=q(e),n.length>u||e.length>u))return;const i=l==="char"?tn(n,e):on(n,e);if(l==="word-line"){mn(i,{deletionLineIndex:r,additionLineIndex:a,deletionDecorations:h,additionDecorations:t});return}const s=[],o=[],d=l==="word-alt",c=i.at(-1);for(const m of i){const p=m===c;!m.added&&!m.removed?(A({item:m,arr:s,enableJoin:d,isNeutral:!0,isLastItem:p}),A({item:m,arr:o,enableJoin:d,isNeutral:!0,isLastItem:p})):m.removed?A({item:m,arr:s,enableJoin:d,isLastItem:p}):A({item:m,arr:o,enableJoin:d,isLastItem:p})}let f=0;for(const m of s)m[0]===1&&h.push(B({line:r,spanStart:f,spanLength:m[1].length})),f+=m[1].length;f=0;for(const m of o)m[0]===1&&t.push(B({line:a,spanStart:f,spanLength:m[1].length})),f+=m[1].length}function In(){return{deletionContent:{push(n){this.value+=n,this.length++},value:"",length:0},additionContent:{push(n){this.value+=n,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function Cn({lazyLineAST:n,deletionFile:e,additionFile:r,deletionInfo:a,additionInfo:h,highlighter:t,deletionDecorations:l,additionDecorations:u,languageOverride:i,options:{theme:s,useTokenTransformer:o,tokenizeMaxLineLength:d}}){const c=(f,m,p)=>f.contents===""?[]:nn(t.codeToTokens(q(f.contents),en(i??U(f.name),s,d)).tokens,{state:{lineInfo:m},useTokenTransformer:o,decorations:p,lazyLineAST:n,cacheHtmlStyles:t.name==="highlights"});return{deletionLines:c(e,a,l),additionLines:c(r,h,u)}}function zn(n){const e=n.lang??U(n.name),r=n.lang??(n.prevName!=null?U(n.prevName):"text");return e==="text"&&r==="text"}export{xn as a,wn as b,En as c,K as d,ln as e,rn as f,$ as g,Rn as h,zn as i,bn as j,On as k,_ as l,Fn as m,Hn as n,Mn as r};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as O,h as _,r as p,i as F,c as A}from"./computeVirtualFileMetrics-
|
|
1
|
+
import{g as O,h as _,r as p,i as F,c as A}from"./computeVirtualFileMetrics-BhVDZ-oP.js";import{g as E}from"./getFiletypeFromFileName-BgI9McTw.js";function D(e,n){return O(e.theme,n.theme)&&e.useTokenTransformer===n.useTokenTransformer&&e.tokenizeMaxLineLength===n.tokenizeMaxLineLength}const g=10,m=13,N=4,S=40;function k(e){const n=[0];let t=e.indexOf("\r"),r=e.indexOf(`
|
|
2
2
|
`),f=0,l=0;for(;t!==-1||r!==-1;){let o;if(t!==-1&&(r===-1||t<r)?r===t+1?(o=r+1,t=e.indexOf("\r",o),r=e.indexOf(`
|
|
3
3
|
`,o)):(o=t+1,t=e.indexOf("\r",o)):(o=r+1,r=e.indexOf(`
|
|
4
4
|
`,o)),n.push(o),++l===N){if(o-f<=S){for(let i=o;i<e.length;i++){const s=e.charCodeAt(i);(s===g||s===m)&&(s===m&&i+1<e.length&&e.charCodeAt(i+1)===g&&i++,n.push(i+1))}return n}f=o,l=0}}return n}function R(e){const n=k(e);return Array.from({length:n.length},(t,r)=>{const f=n[r],l=n[r+1]??e.length;return e.slice(f,l)})}const C={forcePlainText:!1};function K(e,n,{theme:t,tokenizeMaxLineLength:r,useTokenTransformer:f},{forcePlainText:l,lazyLineAST:o=!1,startingLine:i,totalLines:s,lines:T}=C){l?(i??=0,s??=1/0):(i=0,s=1/0);const a=i>0||s<1/0,c={lineInfo:[]},x=l?"text":e.lang??E(e.name),y=typeof t=="string"?n.getTheme(t).type:void 0,I=_({theme:t,highlighter:n});c.lineInfo=u=>({type:"context",lineIndex:u-1+i,lineNumber:u+i});const h=p(n.codeToTokens(L(a?H(T??R(e.contents),i,s):e.contents),F(x,t,r)).tokens,{state:c,useTokenTransformer:f,lazyLineAST:o&&!l&&!f,cacheHtmlStyles:n.name==="highlights"}),d=a?new Array(i):h;return a&&A(d,h),{code:d,themeStyles:I,baseThemeType:y}}function L(e){return e.replace(/\r(?!\n)/g,`
|