@vantran-se/openchamber-web 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/assets/{AboutDialog-Dh2Z6Rpo.js → AboutDialog-BItSBkkK.js} +1 -1
  2. package/dist/assets/{ArchiveView-31PVMzC2.js → ArchiveView-CEGi3y1V.js} +1 -1
  3. package/dist/assets/{ChangedPathLabel-CbXts83B.js → ChangedPathLabel-CQNGnF-T.js} +1 -1
  4. package/dist/assets/{CommandPalette-DzOIUvyX.js → CommandPalette-DWX1HV4m.js} +1 -1
  5. package/dist/assets/{DiffView-C6UN20mH.js → DiffView-Be1Xoy_F.js} +1 -1
  6. package/dist/assets/{FilesView-V9SCRZ9-.js → FilesView-DONPk8-K.js} +1 -1
  7. package/dist/assets/{GitView-RJHLEROE.js → GitView-D10y-u46.js} +1 -1
  8. package/dist/assets/{GuestSurfacePane-C9dmI3Di.js → GuestSurfacePane-Cot0OO7x.js} +1 -1
  9. package/dist/assets/{HelpDialog-DyGX9_8h.js → HelpDialog-Bw836_tH.js} +1 -1
  10. package/dist/assets/{InProgressOperationBanner-B3oEOw3O.js → InProgressOperationBanner-saAihIub.js} +1 -1
  11. package/dist/assets/{IntegrationsCatalogView-CwBk0nb-.js → IntegrationsCatalogView-BtdMeTHf.js} +1 -1
  12. package/dist/assets/{JsonTreeView-BnV3bUfi.js → JsonTreeView-BOQC0uTM.js} +1 -1
  13. package/dist/assets/{MarkdownRendererImpl-DwFPVpAe.js → MarkdownRendererImpl-CuZntPVf.js} +1 -1
  14. package/dist/assets/{MemoryDebugPanel-DwNkGEQI.js → MemoryDebugPanel-BZgSuf-z.js} +1 -1
  15. package/dist/assets/{OnboardingScreen-CLGQ5tGv.js → OnboardingScreen-Bx2h2w69.js} +1 -1
  16. package/dist/assets/{OpenCodeStatusDialog-D7ZnJOuR.js → OpenCodeStatusDialog-N9JgIC1p.js} +1 -1
  17. package/dist/assets/{PatchDiff-BriSysUP.js → PatchDiff-Ca_Ci2CX.js} +1 -1
  18. package/dist/assets/{PierreDiffViewer-ToKfUZsI.js → PierreDiffViewer-Ck0P8Q2W.js} +1 -1
  19. package/dist/assets/{PlanView-YOnwcP8k.js → PlanView-dx70wKWR.js} +1 -1
  20. package/dist/assets/{ProjectActionsDialog-C3u320eT.js → ProjectActionsDialog-BS20dYCJ.js} +1 -1
  21. package/dist/assets/{PullRequestComparisonSelector-Cvng5foj.js → PullRequestComparisonSelector-DOW9_VlK.js} +1 -1
  22. package/dist/assets/{RunOverview-CX4EWbX4.js → RunOverview-DtxjzGnX.js} +1 -1
  23. package/dist/assets/{ScheduledTasksDialog-Cg0llpjw.js → ScheduledTasksDialog-HcypGtky.js} +1 -1
  24. package/dist/assets/{SettingsView-C5MS7v4D.js → SettingsView-IBrGwDoM.js} +1 -1
  25. package/dist/assets/{SettingsWindow-ZCLlBZBD.js → SettingsWindow-Bugr9Hmx.js} +1 -1
  26. package/dist/assets/{SourceBoardView-DeQ_gjii.js → SourceBoardView-BD5rmib8.js} +1 -1
  27. package/dist/assets/{SpaceAccessDialog-MzV-zdo9.js → SpaceAccessDialog-BYhp5gfB.js} +1 -1
  28. package/dist/assets/{SpaceApplyDialog-DDxyMT0_.js → SpaceApplyDialog-CC0axZal.js} +1 -1
  29. package/dist/assets/{SpaceRow-sK_fpiHu.js → SpaceRow-DDWTQgfP.js} +1 -1
  30. package/dist/assets/{SpaceSetupOutput-DXkmiL2Y.js → SpaceSetupOutput-BqurG7V4.js} +1 -1
  31. package/dist/assets/{SpacesView-DZNEvbJ7.js → SpacesView-Bcbb9aXY.js} +1 -1
  32. package/dist/assets/{SubmoduleDiffSummary-E0GcoYiO.js → SubmoduleDiffSummary-BS1PSa4l.js} +1 -1
  33. package/dist/assets/{ToolOutputDialog-CKl9iGaM.js → ToolOutputDialog-DXWQ17Fv.js} +1 -1
  34. package/dist/assets/{ToolPartDiffPreview-CRANc7sQ.js → ToolPartDiffPreview-DXRs6cSg.js} +1 -1
  35. package/dist/assets/{UsageStatsView-np-Qgyn0.js → UsageStatsView-DFVydqMY.js} +1 -1
  36. package/dist/assets/{Virtualizer-CgLU97RO.js → Virtualizer-B8rX50qD.js} +1 -1
  37. package/dist/assets/{WalkthroughView-oJlQ42QA.js → WalkthroughView-CECS5lDs.js} +1 -1
  38. package/dist/assets/{WorktreesView-XC8e1Gxk.js → WorktreesView-FH0uzPQG.js} +1 -1
  39. package/dist/assets/{appThemeRegistry-DsBAd3cG.js → appThemeRegistry-CnS_OWEL.js} +1 -1
  40. package/dist/assets/{computeVirtualFileMetrics-tFBUWYu1.js → computeVirtualFileMetrics-rZJ-MSfY.js} +1 -1
  41. package/dist/assets/{decorate-N1FIdwTF.js → decorate-Bbbyq0tX.js} +1 -1
  42. package/dist/assets/{flexokiTheme-qbTuJgIP.js → flexokiTheme-DECIbITo.js} +1 -1
  43. package/dist/assets/{index-DppcIt7q.js → index-DElZNtel.js} +1 -1
  44. package/dist/assets/{initializeSharedPreferences-Cfgz92Al.js → initializeSharedPreferences-C5qncsHs.js} +1 -1
  45. package/dist/assets/{install-iZ64WEBd.js → install-D-H6uk7D.js} +1 -1
  46. package/dist/assets/{isDiffPlainText-DxiX2X7Q.js → isDiffPlainText-DMFSMXcK.js} +1 -1
  47. package/dist/assets/{isFilePlainText-y0Pch-hF.js → isFilePlainText-BQGSJxcX.js} +1 -1
  48. package/dist/assets/{main-BggWUmia.js → main-CcnDurk6.js} +4 -4
  49. package/dist/assets/{main-CcAbEyCv.js → main-DMdUGpFx.js} +2 -2
  50. package/dist/assets/{markdownCore-P3Pd8JpY.js → markdownCore-BwFkWhmZ.js} +1 -1
  51. package/dist/assets/{miniChat-iJHNCDmk.js → miniChat-B8DW3cmv.js} +2 -2
  52. package/dist/assets/{mobile-C1tleU1e.js → mobile-Caqsx1Op.js} +2 -2
  53. package/dist/assets/{moveWorkspacePath-CUn1SV66.js → moveWorkspacePath-By4gjwmW.js} +1 -1
  54. package/dist/assets/{parseDiffFromFile-Phw3Q2Mh.js → parseDiffFromFile-C9ASoy7R.js} +1 -1
  55. package/dist/assets/{pierreDiffTint-J7FoDbyq.js → pierreDiffTint-IfgQ6oty.js} +1 -1
  56. package/dist/assets/{relocateRestoredSession-Ch0D1a0g.js → relocateRestoredSession-DBWTClOj.js} +1 -1
  57. package/dist/assets/{renderElectronMiniChatApp-QPvTS_hc.js → renderElectronMiniChatApp-C5irgP-w.js} +2 -2
  58. package/dist/assets/{renderMobileApp-Ci_S1TJm.js → renderMobileApp-DnyN_ARh.js} +3 -3
  59. package/dist/assets/{restartOpenCode-BE2HLPm1.js → restartOpenCode-VU-OEAvZ.js} +1 -1
  60. package/dist/assets/{runtimeEndpointReset-DcZoNIpr.js → runtimeEndpointReset-BJUtkqal.js} +3 -3
  61. package/dist/assets/{selectionMarkdown-Dw3ME6dV.js → selectionMarkdown-DV_HvvmZ.js} +1 -1
  62. package/dist/assets/{shikiHighlight-3Hs_1ia3.js → shikiHighlight-BKmAuapa.js} +1 -1
  63. package/dist/assets/{space-apply-CvoK3fqX.js → space-apply-Br_BRuH8.js} +1 -1
  64. package/dist/assets/{space-close-B_kflt9L.js → space-close-D_1iLJrX.js} +1 -1
  65. package/dist/assets/{spaceNetwork-ClSGQtiE.js → spaceNetwork-Dcj-qJy-.js} +1 -1
  66. package/dist/assets/{textMateThemeFromAppTheme-kAREvDjp.js → textMateThemeFromAppTheme-Bye_bpEL.js} +1 -1
  67. package/dist/assets/{useAppFontEffects-BZrjCfFw.js → useAppFontEffects-d9vsRNKm.js} +13 -13
  68. package/dist/assets/{useCallableModelProviders-CpxZpJTR.js → useCallableModelProviders-8CrUkERW.js} +1 -1
  69. package/dist/assets/{useDiffFindSurface-D6svD0Z1.js → useDiffFindSurface-sw5jZ-9V.js} +1 -1
  70. package/dist/assets/{useInlineCommentController-CV8dwlO7.js → useInlineCommentController-Cw5IRM5Y.js} +1 -1
  71. package/dist/assets/{useMarkdownLocalAssets-D0S_fJEu.js → useMarkdownLocalAssets-D3a1j44d.js} +1 -1
  72. package/dist/assets/{useRootScrollLock-5OfQ_8IH.js → useRootScrollLock-BWsNuapq.js} +2 -2
  73. package/dist/assets/{useWalkthroughReview-CxCd3Z0I.js → useWalkthroughReview-D7I1H6_J.js} +1 -1
  74. package/dist/assets/{vendor-codemirror-language-data-DsRKCbVv.js → vendor-codemirror-language-data-DP_Bh3S8.js} +2 -2
  75. package/dist/index.html +1 -1
  76. package/dist/mini-chat.html +1 -1
  77. package/dist/mobile.html +1 -1
  78. package/package.json +1 -1
  79. package/server/index.js +2 -1
  80. package/server/lib/guests/service-registry.js +3 -0
@@ -1 +1 @@
1
- import{r as d,b as g}from"./textMateThemeFromAppTheme-kAREvDjp.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./useAppFontEffects-BZrjCfFw.js";import"./vendor-react-BUCujlKS.js";import"./vendor-scheduler-7OC5HNn7.js";import"./katex.min-u4DtE8E5.js";import"./vendor-zod-DDir2TeQ.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-h8RufjAw.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DsRKCbVv.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";const u=t=>/^#[0-9a-fA-F]{8}$/.test(t),n=t=>u(t)?t.slice(0,7):t;function l(t,r){return Object.defineProperty(t,"toString",{value:()=>r,enumerable:!1,configurable:!0}),Object.defineProperty(t,Symbol.toPrimitive,{value:()=>r,enumerable:!1,configurable:!0}),t}const f=40,i=new Map,s=new Map,c=t=>JSON.stringify(t),b=(t,r)=>{const o=t.colors?.["editor.background"],m=t.colors?.["editor.foreground"],e=o?n(o):void 0,p=m?n(m):void 0;if(!e||!p)throw new Error(`Theme "${r}" is missing editor.background/editor.foreground`);const a=t.tokenColors??[];return l({...t,name:r,fg:p,bg:e,settings:a},r)},T=t=>g(t),h=t=>{const r=c(t),o=i.get(r);if(o)return i.delete(r),i.set(r,o),o;const m=T(t),e=b(m,t.metadata.id);for(i.set(r,e);i.size>f;){const p=i.keys().next().value;if(p===void 0)break;i.delete(p)}return e},ar=t=>{const r=t.metadata.id,o=c(t);if(s.get(r)===o)return;const m=h(t);d(r,async()=>m),s.set(r,o)};export{ar as ensurePierreThemeRegistered,h as getResolvedShikiTheme,c as getThemeContentSignature};
1
+ import{r as d,b as g}from"./textMateThemeFromAppTheme-Bye_bpEL.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./useAppFontEffects-d9vsRNKm.js";import"./vendor-react-BUCujlKS.js";import"./vendor-scheduler-7OC5HNn7.js";import"./katex.min-u4DtE8E5.js";import"./vendor-zod-DDir2TeQ.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-h8RufjAw.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DP_Bh3S8.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";const u=t=>/^#[0-9a-fA-F]{8}$/.test(t),n=t=>u(t)?t.slice(0,7):t;function l(t,r){return Object.defineProperty(t,"toString",{value:()=>r,enumerable:!1,configurable:!0}),Object.defineProperty(t,Symbol.toPrimitive,{value:()=>r,enumerable:!1,configurable:!0}),t}const f=40,i=new Map,s=new Map,c=t=>JSON.stringify(t),b=(t,r)=>{const o=t.colors?.["editor.background"],m=t.colors?.["editor.foreground"],e=o?n(o):void 0,p=m?n(m):void 0;if(!e||!p)throw new Error(`Theme "${r}" is missing editor.background/editor.foreground`);const a=t.tokenColors??[];return l({...t,name:r,fg:p,bg:e,settings:a},r)},T=t=>g(t),h=t=>{const r=c(t),o=i.get(r);if(o)return i.delete(r),i.set(r,o),o;const m=T(t),e=b(m,t.metadata.id);for(i.set(r,e);i.size>f;){const p=i.keys().next().value;if(p===void 0)break;i.delete(p)}return e},ar=t=>{const r=t.metadata.id,o=c(t);if(s.get(r)===o)return;const m=h(t);d(r,async()=>m),s.set(r,o)};export{ar as ensurePierreThemeRegistered,h as getResolvedShikiTheme,c as getThemeContentSignature};
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js"])))=>i.map(i=>d[i]);
2
- import{_ as W}from"./vendor-vite-runtime-DD1OZmLC.js";import{b as E,c as M}from"./vendor-shiki-Bbf2GEcE.js";import{et as S,f8 as A}from"./useAppFontEffects-BZrjCfFw.js";import{t as f}from"./themeResolver-yJ9XpNMI.js";import{s as F,p as P,n as v}from"./vendor-pierre-theming-Dgp7B_O4.js";import{c as z}from"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import{c as N}from"./vendor-shikijs-engine-javascript-Cme4830A.js";import{t as H}from"./vendor-shikijs-transformers-CZWsLLKm.js";const g=new Map,k=new Map,G=new Map,T=new Set;function V(e){for(const t of Array.isArray(e)?e:[e])if(!(t==="text"||t==="ansi")&&!T.has(t))return!1;return!0}function R(e,t){e=Array.isArray(e)?e:[e];for(const r of e){if(T.has(r.name))continue;let n=g.get(r.name);n==null&&(n=r,g.set(r.name,n));const o=n.data.find(s=>s.name===n.name||s.aliases?.includes(n.name)===!0);if(o==null)throw new Error(`attachResolvedLanguages: No returned grammar declares "${n.name}" as its name or an alias.`);t.loadLanguageSync(n.data);try{t.getLanguage(n.name)}catch{throw new Error(`attachResolvedLanguages: "${o.name}" is already loaded without alias "${n.name}". Load the alias first or give the grammar a unique name.`)}T.add(n.name)}}function q(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}async function D(e){if(q())throw new Error(`resolveLanguage("${e}") cannot be called from a worker context. Languages must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);const t=k.get(e);if(t!=null)return t;try{let r=G.get(e);if(r==null&&Object.prototype.hasOwnProperty.call(E,e)&&(r=E[e]),r==null)throw new Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);const n=r().then(({default:o})=>{const s={name:e,data:o};return g.has(e)||g.set(e,s),s});return k.set(e,n),await n}finally{k.delete(e)}}function U(e){return g.get(e)??D(e)}function B(e=S){const t=[];return typeof e=="string"?t.push(e):(t.push(e.dark),t.push(e.light)),t}const j=new Set;function K(e){for(const t of B(e))if(!j.has(t))return!1;return!0}function $(e,t){e=Array.isArray(e)?e:[e];for(let r of e){let n;if(typeof r=="string"){if(n=f.getResolvedTheme(r),n==null)throw new Error(`loadResolvedThemes: ${r} is not resolved, you must resolve it before calling loadResolvedThemes`)}else n=r,r=r.name,f.getResolvedTheme(r)==null&&f.seedResolvedTheme(r,n);j.has(r)||(j.add(r),t.loadThemeSync(n))}}function X(e){if(q())throw new Error(`Theme "${e}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);if(f.hasRegisteredTheme(e))return;const t=F.getTheme(e);if(t!=null){f.registerThemeIfAbsent(t.name,t.load);return}throw new Error(`No valid theme loader registered for "${e}"`)}function J(e,t){if(t.name!==e)throw new Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function Q(e){X(e);const t=await f.resolveTheme(e);return J(e,t),t}function Y(e){return f.getResolvedTheme(e)??Q(e)}let c;async function ke({themes:e,langs:t,preferredHighlighter:r="shiki-js"}){c??=M({themes:[],langs:["text"],engine:r==="shiki-wasm"?z(W(()=>import("./vendor-shiki-Bbf2GEcE.js").then(l=>l.w),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]))):N()});const n=Z(c)?await c:c;c=n;const o=[];for(const l of Array.from(new Set(t))){if(l==="text"||l==="ansi")continue;const i=U(l);"then"in i?o.push(i):R(i,n)}const s=[];for(const l of e){const i=Y(l);"then"in i?s.push(i):$(i,c)}return(o.length>0||s.length>0)&&await Promise.all([Promise.all(o).then(l=>{R(l,n)}),Promise.all(s).then(l=>{$(l,n)})]),n}function we(e){if(!(c==null||"then"in c)&&!(e!=null&&(!K(e.theme)||!V(e.lang))))return c}function Z(e=c){return e!=null&&"then"in e}for(const e of P.getThemes())f.registerThemeIfAbsent(e.name,e.load);function xe(e,t){return e==null||t==null||typeof e=="string"||typeof t=="string"?e===t:e.dark===t.dark&&e.light===t.light}function _(e){return{type:"text",value:e}}function m({tagName:e,children:t=[],properties:r={}}){return{type:"element",tagName:e,properties:r,children:t}}function Te({name:e,width:t=16,height:r=16,properties:n}){return m({tagName:"svg",properties:{width:t,height:r,viewBox:"0 0 16 16",...n},children:[m({tagName:"use",properties:{href:`#${e.replace(/^#/,"")}`}})]})}function ee(e){let t=e.children[0];for(;t!=null;){if(t.type==="element"&&t.tagName==="code")return t;"children"in t?t=t.children[0]:t=null}}function je(e){return m({tagName:"div",properties:{"data-gutter":""},children:e})}function Ee(e,t,r,n={}){return m({tagName:"div",properties:{"data-line-type":e,"data-column-number":t,"data-line-index":r,...n},children:t!=null?[m({tagName:"span",properties:{"data-line-number-content":""},children:[_(`${t}`)]})]:void 0})}function Re(e,t,r){return m({tagName:"div",properties:{"data-gutter-buffer":t,"data-buffer-size":r,"data-line-type":t==="annotation"?void 0:e,style:t==="annotation"?`grid-row: span ${r};`:`grid-row: span ${r};min-height:calc(${r} * 1lh);`}})}const d=new Map;let te=0;const h={"1c":"1c",abap:"abap",as:"actionscript-3",ada:"ada",adb:"ada",ads:"ada",adoc:"asciidoc",asciidoc:"asciidoc","component.html":"angular-html","component.ts":"angular-ts",conf:"nginx",htaccess:"apache",cls:"tex",trigger:"apex",apl:"apl",applescript:"applescript",scpt:"applescript",ara:"ara",asm:"asm",s:"riscv",astro:"astro",awk:"awk",bal:"ballerina",sh:"zsh",bash:"zsh",bat:"cmd",cmd:"cmd",be:"berry",beancount:"beancount",bib:"bibtex",bicep:"bicep","blade.php":"blade",bsl:"bsl",c:"c",h:"objective-cpp",cs:"csharp",cpp:"cpp",hpp:"cpp",cc:"cpp",cxx:"cpp",hh:"cpp",cdc:"cdc",cairo:"cairo",clar:"clarity",clj:"clojure",cljs:"clojure",cljc:"clojure",soy:"soy",cmake:"cmake","CMakeLists.txt":"cmake",cob:"cobol",cbl:"cobol",cobol:"cobol",CODEOWNERS:"codeowners",ql:"ql",coffee:"coffeescript",lisp:"lisp",cl:"lisp",lsp:"lisp",log:"log",v:"verilog",cql:"cql",cr:"crystal",css:"css",csv:"csv",cue:"cue",cypher:"cypher",cyp:"cypher",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",patch:"diff",Dockerfile:"dockerfile",dockerfile:"dockerfile",env:"dotenv",dm:"dream-maker",edge:"edge",el:"emacs-lisp",ex:"elixir",exs:"elixir",elm:"elm",erb:"erb",erl:"erlang",hrl:"erlang",f:"fortran-fixed-form",for:"fortran-fixed-form",fs:"fsharp",fsi:"fsharp",fsx:"fsharp",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"fortran-free-form",f95:"fortran-free-form",fnl:"fennel",fish:"fish",ftl:"ftl",tres:"gdresource",res:"gdresource",gd:"gdscript",gdshader:"gdshader",gs:"genie",feature:"gherkin",COMMIT_EDITMSG:"git-commit","git-rebase-todo":"git-rebase",gjs:"glimmer-js",gleam:"gleam",gts:"glimmer-ts",glsl:"glsl",vert:"glsl",frag:"glsl",shader:"shaderlab",gp:"gnuplot",plt:"gnuplot",gnuplot:"gnuplot",go:"go",graphql:"graphql",gql:"graphql",groovy:"groovy",gvy:"groovy",hack:"hack",haml:"haml",hbs:"handlebars",handlebars:"handlebars",hs:"haskell",lhs:"haskell",hx:"haxe",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",fx:"hlsl",html:"html",htm:"html",http:"http",rest:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",cfg:"ini",jade:"pug",pug:"pug",java:"java",js:"javascript",mjs:"javascript",cjs:"javascript",jinja:"jinja",jinja2:"jinja",j2:"jinja",jison:"jison",jl:"julia",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",libsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",kt:"kotlin",kts:"kts",kql:"kusto",tex:"tex",ltx:"tex",lean:"lean4",less:"less",liquid:"liquid",lit:"lit",ll:"llvm",logo:"logo",lua:"lua",luau:"luau",Makefile:"makefile",mk:"makefile",makefile:"makefile",md:"markdown",markdown:"markdown",marko:"marko",m:"wolfram",mat:"matlab",mdc:"mdc",mdx:"mdx",wiki:"wikitext",mediawiki:"wikitext",mmd:"mermaid",mermaid:"mermaid",mips:"mipsasm",mojo:"mojo","🔥":"mojo",move:"move",nar:"narrat",nf:"nextflow",nim:"nim",nims:"nim",nimble:"nim",nix:"nix",nu:"nushell",mm:"objective-cpp",ml:"ocaml",mli:"ocaml",mll:"ocaml",mly:"ocaml",odin:"odin",pas:"pascal",p:"pascal",pl:"prolog",pm:"perl",t:"perl",raku:"raku",p6:"raku",pl6:"raku",php:"php",phtml:"php",pls:"plsql",sql:"sql",po:"po",polar:"polar",pcss:"postcss",pot:"pot",potx:"potx",pq:"powerquery",pqm:"powerquery",ps1:"powershell",psm1:"powershell",psd1:"powershell",prisma:"prisma",pro:"prolog",P:"prolog",properties:"properties",proto:"protobuf",pp:"puppet",purs:"purescript",py:"python",pyw:"python",pyi:"python",BUCK:"python",BUILD:"python",PACKAGE:"python",WORKSPACE:"python",Tiltfile:"python",bazel:"python",bxl:"python",bzl:"python",bzlmod:"python",star:"python",sky:"python",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",R:"r",rkt:"racket",rktl:"racket",razor:"razor",cshtml:"razor",rb:"ruby",rbw:"ruby",reg:"reg",regex:"regexp",rel:"rel",rs:"rust",rst:"rst",rake:"ruby",gemspec:"ruby",jbuilder:"ruby",builder:"ruby",rabl:"ruby",arb:"ruby",ru:"ruby",podspec:"ruby",Gemfile:"ruby",Rakefile:"ruby",Guardfile:"ruby",Capfile:"ruby",Berksfile:"ruby",Brewfile:"ruby",Vagrantfile:"ruby",Thorfile:"ruby",Appraisals:"ruby",Dangerfile:"ruby",sas:"sas",sass:"sass",scala:"scala",sc:"scala",scm:"scheme",ss:"scheme",sld:"scheme",scss:"scss",sdbl:"sdbl",shadergraph:"shader",st:"smalltalk",sol:"solidity",sparql:"sparql",rq:"sparql",spl:"splunk",config:"ssh-config",do:"stata",ado:"stata",dta:"stata",styl:"stylus",stylus:"stylus",svelte:"svelte",swift:"swift",sv:"system-verilog",svh:"system-verilog",service:"systemd",socket:"systemd",device:"systemd",timer:"systemd",talon:"talonscript",tasl:"tasl",tcl:"tcl",templ:"templ",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"typescript",mts:"typescript",cts:"typescript",tsp:"typespec",tsv:"tsv",tsx:"tsx",ttl:"turtle",twig:"twig",typ:"typst",vv:"v",vala:"vala",vapi:"vala",vb:"vb",vbs:"vb",bas:"vb",vh:"verilog",vhd:"vhdl",vhdl:"vhdl",vim:"vimscript",vue:"vue","vine.ts":"vue-vine",vy:"vyper",wasm:"wasm",wat:"wasm",wy:"文言",wgsl:"wgsl",wit:"wit",wl:"wolfram",nb:"wolfram",xml:"xml",xsl:"xsl",xslt:"xsl",yaml:"yaml",yml:"yml",zs:"zenscript",zig:"zig",zsh:"zsh",sty:"tex"};function $e(e){const t=C(e);if(t!=null)return t;const r=e.split(/[/\\]/).pop()??e;return r===e?"text":C(r)??"text"}function C(e){if(d.has(e))return d.get(e)??"text";if(Object.hasOwn(h,e))return h[e]??null;const t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(d.has(t[1]))return d.get(t[1])??"text";if(Object.hasOwn(h,t[1]))return h[t[1]]??"text"}const r=e.match(/\.([^.]+)$/)?.[1]??"";return d.has(r)?d.get(r)??"text":Object.hasOwn(h,r)?h[r]??"text":null}function Ce(){return te}function Le(){return Object.fromEntries(d)}function re(e,t,r){const n=typeof r.lineInfo=="function"?r.lineInfo(t):r.lineInfo[t-1];if(n==null){const o=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(o,{node:e,line:t,state:r}),new Error(o)}return e.tagName="div",e.properties["data-line"]=n.lineNumber,e.properties["data-alt-line"]=n.altLineNumber,e.properties["data-line-type"]=n.type,e.properties["data-line-index"]=n.lineIndex,e.children.length===0&&e.children.push(_(`
2
+ import{_ as W}from"./vendor-vite-runtime-DD1OZmLC.js";import{b as E,c as M}from"./vendor-shiki-Bbf2GEcE.js";import{et as S,f8 as A}from"./useAppFontEffects-d9vsRNKm.js";import{t as f}from"./themeResolver-yJ9XpNMI.js";import{s as F,p as P,n as v}from"./vendor-pierre-theming-Dgp7B_O4.js";import{c as z}from"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import{c as N}from"./vendor-shikijs-engine-javascript-Cme4830A.js";import{t as H}from"./vendor-shikijs-transformers-CZWsLLKm.js";const g=new Map,k=new Map,G=new Map,T=new Set;function V(e){for(const t of Array.isArray(e)?e:[e])if(!(t==="text"||t==="ansi")&&!T.has(t))return!1;return!0}function R(e,t){e=Array.isArray(e)?e:[e];for(const r of e){if(T.has(r.name))continue;let n=g.get(r.name);n==null&&(n=r,g.set(r.name,n));const o=n.data.find(s=>s.name===n.name||s.aliases?.includes(n.name)===!0);if(o==null)throw new Error(`attachResolvedLanguages: No returned grammar declares "${n.name}" as its name or an alias.`);t.loadLanguageSync(n.data);try{t.getLanguage(n.name)}catch{throw new Error(`attachResolvedLanguages: "${o.name}" is already loaded without alias "${n.name}". Load the alias first or give the grammar a unique name.`)}T.add(n.name)}}function q(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}async function D(e){if(q())throw new Error(`resolveLanguage("${e}") cannot be called from a worker context. Languages must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);const t=k.get(e);if(t!=null)return t;try{let r=G.get(e);if(r==null&&Object.prototype.hasOwnProperty.call(E,e)&&(r=E[e]),r==null)throw new Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);const n=r().then(({default:o})=>{const s={name:e,data:o};return g.has(e)||g.set(e,s),s});return k.set(e,n),await n}finally{k.delete(e)}}function U(e){return g.get(e)??D(e)}function B(e=S){const t=[];return typeof e=="string"?t.push(e):(t.push(e.dark),t.push(e.light)),t}const j=new Set;function K(e){for(const t of B(e))if(!j.has(t))return!1;return!0}function $(e,t){e=Array.isArray(e)?e:[e];for(let r of e){let n;if(typeof r=="string"){if(n=f.getResolvedTheme(r),n==null)throw new Error(`loadResolvedThemes: ${r} is not resolved, you must resolve it before calling loadResolvedThemes`)}else n=r,r=r.name,f.getResolvedTheme(r)==null&&f.seedResolvedTheme(r,n);j.has(r)||(j.add(r),t.loadThemeSync(n))}}function X(e){if(q())throw new Error(`Theme "${e}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);if(f.hasRegisteredTheme(e))return;const t=F.getTheme(e);if(t!=null){f.registerThemeIfAbsent(t.name,t.load);return}throw new Error(`No valid theme loader registered for "${e}"`)}function J(e,t){if(t.name!==e)throw new Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function Q(e){X(e);const t=await f.resolveTheme(e);return J(e,t),t}function Y(e){return f.getResolvedTheme(e)??Q(e)}let c;async function ke({themes:e,langs:t,preferredHighlighter:r="shiki-js"}){c??=M({themes:[],langs:["text"],engine:r==="shiki-wasm"?z(W(()=>import("./vendor-shiki-Bbf2GEcE.js").then(l=>l.w),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]))):N()});const n=Z(c)?await c:c;c=n;const o=[];for(const l of Array.from(new Set(t))){if(l==="text"||l==="ansi")continue;const i=U(l);"then"in i?o.push(i):R(i,n)}const s=[];for(const l of e){const i=Y(l);"then"in i?s.push(i):$(i,c)}return(o.length>0||s.length>0)&&await Promise.all([Promise.all(o).then(l=>{R(l,n)}),Promise.all(s).then(l=>{$(l,n)})]),n}function we(e){if(!(c==null||"then"in c)&&!(e!=null&&(!K(e.theme)||!V(e.lang))))return c}function Z(e=c){return e!=null&&"then"in e}for(const e of P.getThemes())f.registerThemeIfAbsent(e.name,e.load);function xe(e,t){return e==null||t==null||typeof e=="string"||typeof t=="string"?e===t:e.dark===t.dark&&e.light===t.light}function _(e){return{type:"text",value:e}}function m({tagName:e,children:t=[],properties:r={}}){return{type:"element",tagName:e,properties:r,children:t}}function Te({name:e,width:t=16,height:r=16,properties:n}){return m({tagName:"svg",properties:{width:t,height:r,viewBox:"0 0 16 16",...n},children:[m({tagName:"use",properties:{href:`#${e.replace(/^#/,"")}`}})]})}function ee(e){let t=e.children[0];for(;t!=null;){if(t.type==="element"&&t.tagName==="code")return t;"children"in t?t=t.children[0]:t=null}}function je(e){return m({tagName:"div",properties:{"data-gutter":""},children:e})}function Ee(e,t,r,n={}){return m({tagName:"div",properties:{"data-line-type":e,"data-column-number":t,"data-line-index":r,...n},children:t!=null?[m({tagName:"span",properties:{"data-line-number-content":""},children:[_(`${t}`)]})]:void 0})}function Re(e,t,r){return m({tagName:"div",properties:{"data-gutter-buffer":t,"data-buffer-size":r,"data-line-type":t==="annotation"?void 0:e,style:t==="annotation"?`grid-row: span ${r};`:`grid-row: span ${r};min-height:calc(${r} * 1lh);`}})}const d=new Map;let te=0;const h={"1c":"1c",abap:"abap",as:"actionscript-3",ada:"ada",adb:"ada",ads:"ada",adoc:"asciidoc",asciidoc:"asciidoc","component.html":"angular-html","component.ts":"angular-ts",conf:"nginx",htaccess:"apache",cls:"tex",trigger:"apex",apl:"apl",applescript:"applescript",scpt:"applescript",ara:"ara",asm:"asm",s:"riscv",astro:"astro",awk:"awk",bal:"ballerina",sh:"zsh",bash:"zsh",bat:"cmd",cmd:"cmd",be:"berry",beancount:"beancount",bib:"bibtex",bicep:"bicep","blade.php":"blade",bsl:"bsl",c:"c",h:"objective-cpp",cs:"csharp",cpp:"cpp",hpp:"cpp",cc:"cpp",cxx:"cpp",hh:"cpp",cdc:"cdc",cairo:"cairo",clar:"clarity",clj:"clojure",cljs:"clojure",cljc:"clojure",soy:"soy",cmake:"cmake","CMakeLists.txt":"cmake",cob:"cobol",cbl:"cobol",cobol:"cobol",CODEOWNERS:"codeowners",ql:"ql",coffee:"coffeescript",lisp:"lisp",cl:"lisp",lsp:"lisp",log:"log",v:"verilog",cql:"cql",cr:"crystal",css:"css",csv:"csv",cue:"cue",cypher:"cypher",cyp:"cypher",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",patch:"diff",Dockerfile:"dockerfile",dockerfile:"dockerfile",env:"dotenv",dm:"dream-maker",edge:"edge",el:"emacs-lisp",ex:"elixir",exs:"elixir",elm:"elm",erb:"erb",erl:"erlang",hrl:"erlang",f:"fortran-fixed-form",for:"fortran-fixed-form",fs:"fsharp",fsi:"fsharp",fsx:"fsharp",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"fortran-free-form",f95:"fortran-free-form",fnl:"fennel",fish:"fish",ftl:"ftl",tres:"gdresource",res:"gdresource",gd:"gdscript",gdshader:"gdshader",gs:"genie",feature:"gherkin",COMMIT_EDITMSG:"git-commit","git-rebase-todo":"git-rebase",gjs:"glimmer-js",gleam:"gleam",gts:"glimmer-ts",glsl:"glsl",vert:"glsl",frag:"glsl",shader:"shaderlab",gp:"gnuplot",plt:"gnuplot",gnuplot:"gnuplot",go:"go",graphql:"graphql",gql:"graphql",groovy:"groovy",gvy:"groovy",hack:"hack",haml:"haml",hbs:"handlebars",handlebars:"handlebars",hs:"haskell",lhs:"haskell",hx:"haxe",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",fx:"hlsl",html:"html",htm:"html",http:"http",rest:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",cfg:"ini",jade:"pug",pug:"pug",java:"java",js:"javascript",mjs:"javascript",cjs:"javascript",jinja:"jinja",jinja2:"jinja",j2:"jinja",jison:"jison",jl:"julia",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",libsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",kt:"kotlin",kts:"kts",kql:"kusto",tex:"tex",ltx:"tex",lean:"lean4",less:"less",liquid:"liquid",lit:"lit",ll:"llvm",logo:"logo",lua:"lua",luau:"luau",Makefile:"makefile",mk:"makefile",makefile:"makefile",md:"markdown",markdown:"markdown",marko:"marko",m:"wolfram",mat:"matlab",mdc:"mdc",mdx:"mdx",wiki:"wikitext",mediawiki:"wikitext",mmd:"mermaid",mermaid:"mermaid",mips:"mipsasm",mojo:"mojo","🔥":"mojo",move:"move",nar:"narrat",nf:"nextflow",nim:"nim",nims:"nim",nimble:"nim",nix:"nix",nu:"nushell",mm:"objective-cpp",ml:"ocaml",mli:"ocaml",mll:"ocaml",mly:"ocaml",odin:"odin",pas:"pascal",p:"pascal",pl:"prolog",pm:"perl",t:"perl",raku:"raku",p6:"raku",pl6:"raku",php:"php",phtml:"php",pls:"plsql",sql:"sql",po:"po",polar:"polar",pcss:"postcss",pot:"pot",potx:"potx",pq:"powerquery",pqm:"powerquery",ps1:"powershell",psm1:"powershell",psd1:"powershell",prisma:"prisma",pro:"prolog",P:"prolog",properties:"properties",proto:"protobuf",pp:"puppet",purs:"purescript",py:"python",pyw:"python",pyi:"python",BUCK:"python",BUILD:"python",PACKAGE:"python",WORKSPACE:"python",Tiltfile:"python",bazel:"python",bxl:"python",bzl:"python",bzlmod:"python",star:"python",sky:"python",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",R:"r",rkt:"racket",rktl:"racket",razor:"razor",cshtml:"razor",rb:"ruby",rbw:"ruby",reg:"reg",regex:"regexp",rel:"rel",rs:"rust",rst:"rst",rake:"ruby",gemspec:"ruby",jbuilder:"ruby",builder:"ruby",rabl:"ruby",arb:"ruby",ru:"ruby",podspec:"ruby",Gemfile:"ruby",Rakefile:"ruby",Guardfile:"ruby",Capfile:"ruby",Berksfile:"ruby",Brewfile:"ruby",Vagrantfile:"ruby",Thorfile:"ruby",Appraisals:"ruby",Dangerfile:"ruby",sas:"sas",sass:"sass",scala:"scala",sc:"scala",scm:"scheme",ss:"scheme",sld:"scheme",scss:"scss",sdbl:"sdbl",shadergraph:"shader",st:"smalltalk",sol:"solidity",sparql:"sparql",rq:"sparql",spl:"splunk",config:"ssh-config",do:"stata",ado:"stata",dta:"stata",styl:"stylus",stylus:"stylus",svelte:"svelte",swift:"swift",sv:"system-verilog",svh:"system-verilog",service:"systemd",socket:"systemd",device:"systemd",timer:"systemd",talon:"talonscript",tasl:"tasl",tcl:"tcl",templ:"templ",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"typescript",mts:"typescript",cts:"typescript",tsp:"typespec",tsv:"tsv",tsx:"tsx",ttl:"turtle",twig:"twig",typ:"typst",vv:"v",vala:"vala",vapi:"vala",vb:"vb",vbs:"vb",bas:"vb",vh:"verilog",vhd:"vhdl",vhdl:"vhdl",vim:"vimscript",vue:"vue","vine.ts":"vue-vine",vy:"vyper",wasm:"wasm",wat:"wasm",wy:"文言",wgsl:"wgsl",wit:"wit",wl:"wolfram",nb:"wolfram",xml:"xml",xsl:"xsl",xslt:"xsl",yaml:"yaml",yml:"yml",zs:"zenscript",zig:"zig",zsh:"zsh",sty:"tex"};function $e(e){const t=C(e);if(t!=null)return t;const r=e.split(/[/\\]/).pop()??e;return r===e?"text":C(r)??"text"}function C(e){if(d.has(e))return d.get(e)??"text";if(Object.hasOwn(h,e))return h[e]??null;const t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(d.has(t[1]))return d.get(t[1])??"text";if(Object.hasOwn(h,t[1]))return h[t[1]]??"text"}const r=e.match(/\.([^.]+)$/)?.[1]??"";return d.has(r)?d.get(r)??"text":Object.hasOwn(h,r)?h[r]??"text":null}function Ce(){return te}function Le(){return Object.fromEntries(d)}function re(e,t,r){const n=typeof r.lineInfo=="function"?r.lineInfo(t):r.lineInfo[t-1];if(n==null){const o=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(o,{node:e,line:t,state:r}),new Error(o)}return e.tagName="div",e.properties["data-line"]=n.lineNumber,e.properties["data-alt-line"]=n.altLineNumber,e.properties["data-line-type"]=n.type,e.properties["data-line-index"]=n.lineIndex,e.children.length===0&&e.children.push(_(`
3
3
  `)),e}const y=Symbol("no-token"),w=Symbol("multiple-tokens");function O(e){const t=ne(e);if(t!=null)return t;let r=y;const n=[];let o=[],s;const l=()=>{if(o.length===0||s==null){o=[],s=void 0;return}if(o.length===1){const a=o[0];if(a?.type==="element"){oe(a,s);for(const p of a.children)b(p)}else b(a);n.push(a),o=[],s=void 0;return}for(const a of o)b(a);n.push(m({tagName:"span",properties:{"data-char":s},children:o})),o=[],s=void 0},i=a=>{if(a!==y){if(a===w){r=w;return}if(r===y){r=a;return}r!==a&&(r=w)}};for(const a of e.children){const p=a.type==="element"?O(a):y;if(i(p),typeof p!="number"){l(),n.push(a);continue}s!=null&&s!==p&&l(),s??=p,o.push(a)}return l(),e.children=n,r}function ne(e){const t=e.properties["data-char"];if(typeof t=="number")return t}function b(e){if(e.type==="element"){e.properties["data-char"]=void 0;for(const t of e.children)b(t)}}function oe(e,t){e.properties["data-char"]=t}function Se(e=!1,t=!1){const r={lineInfo:[]},n=[{line(o){return delete o.properties.class,o},pre(o){const s=ee(o),l=[];if(s!=null){let i=1;for(const a of s.children)a.type==="element"&&(e&&O(a),l.push(re(a,i,r)),i++);s.children=l}return o},...e?{tokens(o){for(const s of o){let l=0;for(const i of s){const a=i;a.__lineChar??=l,l+=i.content.length}}},preprocess(o,s){s.mergeWhitespaces="never"},span(o,s,l,i,a){if(a?.offset!=null&&a.content!=null){const p=a.__lineChar;return p!=null&&(o.properties["data-char"]=p),o}return o}}:null}];return t&&n.push(se,L),e&&n.push({line:o=>(o.type==="element"&&o.children.length===0&&o.children.push({type:"element",tagName:"br",properties:{},children:[]}),o)}),{state:r,transformers:n,toClass:L}}const L=H({classPrefix:"hl-"}),se={name:"token-style-normalizer",tokens(e){for(const t of e)for(const r of t){if(r.htmlStyle!=null)continue;const n={};r.color!=null&&(n.color=r.color),r.bgColor!=null&&(n["background-color"]=r.bgColor),r.fontStyle!=null&&r.fontStyle!==0&&((r.fontStyle&1)!==0&&(n["font-style"]="italic"),(r.fontStyle&2)!==0&&(n["font-weight"]="bold"),(r.fontStyle&4)!==0&&(n["text-decoration"]="underline")),Object.keys(n).length>0&&(r.htmlStyle=n)}}};function u(e){return`--${e==="token"?"diffs-token":"diffs"}-`}function qe({theme:e=S,highlighter:t,prefix:r}){let n="";if(typeof e=="string"){const o=t.getTheme(e),s=v(o);n+=`color:${s.fg};`,n+=`background-color:${s.bg};`,n+=`${u("global")}fg:${s.fg};`,n+=`${u("global")}bg:${s.bg};`,n+=x(o,r)}else{let o=t.getTheme(e.dark),s=v(o);n+=`${u("global")}dark:${s.fg};`,n+=`${u("global")}dark-bg:${s.bg};`,n+=x(o,"dark"),o=t.getTheme(e.light),s=v(o),n+=`${u("global")}light:${s.fg};`,n+=`${u("global")}light-bg:${s.bg};`,n+=x(o,"light")}return n}function x(e,t){t=t!=null?`${t}-`:"";let r="";const n=e.colors?.["gitDecoration.addedResourceForeground"]??e.colors?.["terminal.ansiGreen"];n!=null&&(r+=`${u("global")}${t}addition-color:${n};`);const o=e.colors?.["gitDecoration.deletedResourceForeground"]??e.colors?.["terminal.ansiRed"];o!=null&&(r+=`${u("global")}${t}deletion-color:${o};`);const s=e.colors?.["gitDecoration.modifiedResourceForeground"]??e.colors?.["terminal.ansiBlue"];return s!=null&&(r+=`${u("global")}${t}modified-color:${s};`),r}function _e(e){let t=e.children[0];for(;t!=null;){if(t.type==="element"&&t.tagName==="code")return t.children;"children"in t?t=t.children[0]:t=null}throw console.error(e),new Error("getLineNodes: Unable to find children")}function Oe(e,t){for(const r of t)e.push(r)}var ae=class extends Error{constructor(){super("WorkerPoolManager: operation canceled because the pool terminated"),this.name="WorkerPoolTerminatedError"}},le=class extends Error{constructor(){super("WorkerPoolManager: operation canceled before the task completed"),this.name="WorkerPoolTaskCanceledError"}},ie=class extends Error{constructor(e,t){super(e,t),this.name="WorkerPoolWorkerError"}};const I=new WeakSet;function Ie(e){I.add(e)}function ce(e){return e instanceof ae||e instanceof le}function We(e){return ce(e)||e instanceof ie&&I.has(e)}function Me(e){return{...A,...e}}function Ae(e,t){return pe(e,t)+ue(e,t)}function pe(e,t){return t?0:e.diffHeaderHeight}function ue(e,t){return e.paddingTop??(t?e.spacing:0)}function Fe(e){return e.paddingBottom??e.spacing}function Pe(e){switch(e){case"simple":return 4;case"metadata":case"line-info":case"line-info-basic":case"custom":return 32}}export{Ee as A,m as B,je as C,Me as D,pe as E,Ae as F,Fe as G,_ as H,Te as I,g as R,ae as W,xe as a,qe as b,Se as c,_e as d,Oe as e,u as f,$e as g,U as h,B as i,$ as j,ke as k,We as l,Ie as m,V as n,le as o,X as p,Le as q,D as r,Ce as s,ie as t,ce as u,J as v,Pe as w,K as x,we as y,Re as z};
@@ -1,4 +1,4 @@
1
- import{a3 as de,aZ as Ee,a_ as ke,a$ as Le,aA as z,b0 as xe,b1 as Me,b2 as Te}from"./useAppFontEffects-BZrjCfFw.js";import{e as Ne}from"./openFenceIncremental-7wgnc2ZL.js";import{getMarkdownSelectionText as De}from"./selectionMarkdown-Dw3ME6dV.js";const b=e=>Number.isFinite(e)&&e>0,X=e=>{if(e==null)return null;const t=String(e).trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;const r=Number(t[1]);return b(r)?r:null},H=(e,t,r)=>Math.min(r,Math.max(t,e)),qe=6,Y=1.25,Re=1.0015,We=.5,Ie=12,K=3,_e=400,me='[data-markdown="mermaid-block"]',xt=e=>e.querySelector(me)!==null,Pe=e=>[e.x,e.y,e.width,e.height].map(t=>{const r=Number(t.toFixed(qe));return Object.is(r,-0)?"0":String(r)}).join(" "),ze=e=>{const t=e.viewBox?.trim().split(/[\s,]+/).map(n=>Number.parseFloat(n));if(t?.length===4){const[n,s,i,a]=t;if(Number.isFinite(n)&&Number.isFinite(s)&&b(i)&&b(a))return{x:n,y:s,width:i,height:a}}const r=X(e.width),o=X(e.height);return r===null||o===null?null:{x:0,y:0,width:r,height:o}},Oe=e=>{let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)},He=e=>{const t=e.renderMode||"unknown",r=e.svgMarkup??"";if(!r){const o=[e.viewBox??"",e.width??"",e.height??""];return o.some(n=>n!=="")?`${t}:bounds:${o.join(":")}`:`${t}:no-svg`}return[t,Oe(r)].join(":")},ue=(e,t)=>{if(!b(t.width)||!b(t.height))return e;const r=e.width/e.height,o=t.width/t.height;if(r>o){const s=e.width/o;return{x:e.x,y:e.y-(s-e.height)/2,width:e.width,height:s}}const n=e.height*o;return{x:e.x-(n-e.width)/2,y:e.y,width:n,height:e.height}},Ve=({currentBox:e,viewport:t,delta:r})=>!b(t.width)||!b(t.height)||!b(e.width)||!b(e.height)?e:{x:e.x-r.x/t.width*e.width,y:e.y-r.y/t.height*e.height,width:e.width,height:e.height},$e=(e,t)=>{const r=t.x-e.x,o=t.y-e.y;return r*r+o*o>K*K},V=e=>{const[t,r]=e;return!t||!r?null:{distance:Math.hypot(r.x-t.x,r.y-t.y),center:{x:(t.x+r.x)/2,y:(t.y+r.y)/2}}},Be=({currentBox:e,contentBox:t,viewport:r,pointer:o,zoomFactor:n,minScale:s,maxScale:i})=>{if(!b(r.width)||!b(r.height)||!b(n)||!b(e.width)||!b(e.height)||!b(t.width)||!b(t.height)||!b(s)||!b(i))return e;const a=Math.min(s,i),c=Math.max(s,i),l=ue(t,r),u=l.width/e.width,h=H(u*n,a,c),p=l.width/h,g=p/(e.width/e.height),E=H(o.x/r.width,0,1),m=H(o.y/r.height,0,1),f=e.x+E*e.width,w=e.y+m*e.height;return{x:f-E*p,y:w-m*g,width:p,height:g}},O=new WeakMap,F=new WeakMap,T=new Set,I=new Set;let M=null,R=null,D=null;const Fe=e=>e.querySelector('[data-markdown="mermaid-viewport"]')??e.querySelector('[data-markdown="mermaid"]'),pe=e=>{const t=e.querySelector('[data-markdown="mermaid"] svg'),r=e.querySelector('[data-markdown="mermaid"]');return He({renderMode:e.getAttribute("data-mermaid-render"),svgMarkup:r?.getAttribute("data-md-original-svg")??t?.outerHTML??null,viewBox:t?.getAttribute("viewBox"),width:t?.getAttribute("width"),height:t?.getAttribute("height")})},N=e=>{const t=e.getBoundingClientRect();return{width:t.width,height:t.height}},G=(e,t)=>{const r=t.getBoundingClientRect();return{x:e.clientX-r.left,y:e.clientY-r.top}},je=e=>e instanceof Element&&!!e.closest('button, a, [role="button"]'),fe=e=>{const t=e.map(r=>N(r.viewport));e.forEach((r,o)=>{const n=t[o];n&&r.fitToViewport(n)})},he=()=>{D!==null||T.size===0||(D=window.requestAnimationFrame(()=>{D=null,fe(Array.from(T))}))},Ue=()=>{if(M)return M;const e=globalThis.ResizeObserver;return e?(M=new e(t=>{for(const r of t)r.target instanceof HTMLElement&&F.get(r.target)?.fitToViewport({width:r.contentRect.width,height:r.contentRect.height})}),M):null},Xe=e=>{if(T.has(e))return;const t=T.size===0;T.add(e),F.set(e.viewport,e),Ue()?.observe(e.viewport),t&&window.addEventListener("resize",he)},Ye=e=>{T.delete(e)&&(M?.unobserve(e.viewport),F.delete(e.viewport),!(T.size>0)&&(M?.disconnect(),M=null,window.removeEventListener("resize",he),D!==null&&(window.cancelAnimationFrame(D),D=null)))},Ke=e=>{const t=Fe(e),r=e.querySelector('[data-markdown="mermaid"] svg');if(!t||!r)return null;const o=ze({viewBox:r.getAttribute("viewBox"),width:r.getAttribute("width"),height:r.getAttribute("height")});if(!o)return null;let n=o,s=null,i=null,a=null,c=null;const l=new Map;let u=null;const h=d=>{n=d,r.setAttribute("viewBox",Pe(d)),r.removeAttribute("width"),r.removeAttribute("height")},p=d=>{h(ue(o,d))},g=()=>{p(N(t))},E=(d,S)=>{h(Be({currentBox:n,contentBox:o,viewport:N(t),pointer:d,zoomFactor:S,minScale:We,maxScale:Ie}))},m=()=>{const d=N(t);E({x:d.width/2,y:d.height/2},Y)},f=()=>{const d=N(t);E({x:d.width/2,y:d.height/2},1/Y)},w=d=>{!d.ctrlKey&&!d.metaKey||(d.preventDefault(),d.stopPropagation(),E(G(d,t),Math.pow(Re,-d.deltaY)))},A=d=>{if(!(d.button!==0||je(d.target))){if(d.isPrimary&&(l.clear(),u=null),l.set(d.pointerId,{x:d.clientX,y:d.clientY}),l.size>1){s=null,u=V(Array.from(l.values()))?.distance??null,t.setPointerCapture?.(d.pointerId),e.setAttribute("data-mermaid-suppress-click","true"),d.preventDefault();return}s=d.pointerId,i={x:d.clientX,y:d.clientY},a=i,c!==null&&(window.clearTimeout(c),c=null),e.removeAttribute("data-mermaid-suppress-click"),t.setPointerCapture?.(d.pointerId),e.setAttribute("data-mermaid-panning","true"),d.preventDefault()}},k=d=>{const S={x:d.clientX,y:d.clientY};if(u!==null&&l.has(d.pointerId)){l.set(d.pointerId,S);const L=V(Array.from(l.values()));if(L){const _=G({clientX:L.center.x,clientY:L.center.y},t);E(_,L.distance/u),u=L.distance}d.preventDefault();return}s!==d.pointerId||!a||(h(Ve({currentBox:n,viewport:N(t),delta:{x:S.x-a.x,y:S.y-a.y}})),a=S,i&&$e(i,S)&&e.setAttribute("data-mermaid-suppress-click","true"),d.preventDefault())},C=d=>{if(l.delete(d.pointerId)){if(t.releasePointerCapture?.(d.pointerId),l.size>0){s=null,u=l.size>1?V(Array.from(l.values()))?.distance??null:null;return}u=null,s=null,i=null,a=null,e.removeAttribute("data-mermaid-panning"),e.hasAttribute("data-mermaid-suppress-click")&&(c=window.setTimeout(()=>{e.removeAttribute("data-mermaid-suppress-click"),c=null},_e))}};t.addEventListener("wheel",w,{passive:!1}),t.addEventListener("pointerdown",A),t.addEventListener("pointermove",k),t.addEventListener("pointerup",C),t.addEventListener("pointercancel",C);const y={viewport:t,zoomIn:m,zoomOut:f,fit:g,fitToViewport:p,cleanup:()=>{Ye(y),t.removeEventListener("wheel",w),t.removeEventListener("pointerdown",A),t.removeEventListener("pointermove",k),t.removeEventListener("pointerup",C),t.removeEventListener("pointercancel",C),c!==null&&window.clearTimeout(c),l.clear(),e.removeAttribute("data-mermaid-panning"),e.removeAttribute("data-mermaid-suppress-click"),O.delete(e)}};return y},ge=e=>{for(const[t,r]of e.controllers){const o=pe(t);(!e.container.contains(t)||o!==e.signatures.get(t))&&(r.cleanup(),e.controllers.delete(t),e.signatures.delete(t))}},Ge=e=>{if(e.disposed)return[];const t=[];for(const r of Array.from(e.container.querySelectorAll(me))){if(e.controllers.has(r)||r.querySelector('[data-markdown="mermaid"] svg')===null)continue;const o=Ke(r);o&&(e.controllers.set(r,o),e.signatures.set(r,pe(r)),O.set(r,o),t.push(o))}return t},we=()=>{const e=Array.from(I);I.clear();const t=[];for(const r of e)r.disposed||(ge(r),t.push(...Ge(r)));fe(t);for(const r of t)Xe(r)},Ze=()=>{R===null&&(R=window.requestAnimationFrame(()=>{R=null,R=window.requestAnimationFrame(()=>{R=null,we()})}))},Je=e=>{e.disposed||(ge(e),I.add(e),Ze())},Qe=e=>{if(!(e instanceof HTMLElement))return null;const t=O.get(e);if(t)return t;for(const r of I)if(r.container.contains(e))return we(),O.get(e)??null;return null},Mt=e=>{const t={container:e,controllers:new Map,signatures:new Map,disposed:!1},r=()=>Je(t),o=()=>{t.disposed=!0,I.delete(t);for(const n of t.controllers.values())n.cleanup();t.controllers.clear(),t.signatures.clear()};return r(),{refresh:r,cleanup:o}},et={copy:"file-copy",check:"check",download:"download",zoomIn:"add",zoomOut:"subtract",fit:"refresh",textWrap:"text-wrap",image:"file-image",disclosure:"arrow-right-s",browser:"global"},be="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",q=(e,t)=>{const r=et[t],o=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("class","remixicon size-3.5"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("aria-hidden","true");const n=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","use");n.setAttribute("href",`#oc-${r}`),o.appendChild(n),e.replaceChildren(o)},tt=e=>{for(const t of Array.from(e.querySelectorAll('[data-openchamber-markdown-image-label="true"]'))){if(t.querySelector("[data-openchamber-markdown-image-label-icon]"))continue;const r=document.createElement("span");r.className="inline-flex shrink-0",r.setAttribute("aria-hidden","true"),r.setAttribute("data-openchamber-markdown-image-label-icon","true"),q(r,"image"),t.prepend(r)}},Z=(e,t)=>{if(e.querySelector("svg"))return;const r=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","block size-[1.1em] shrink-0"),r.setAttribute("aria-hidden","true"),r.setAttribute("focusable","false");const o=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","use");o.setAttribute("href",t),r.appendChild(o),e.prepend(r)},rt=e=>{for(const t of Array.from(e.querySelectorAll("[data-attachment-citation]"))){const r=t.getAttribute("data-attachment-citation")??"";r&&Z(t,`#${r}`)}for(const t of Array.from(e.querySelectorAll("a[data-skill-name]")))Z(t,Te)},ot=e=>{for(const t of e.querySelectorAll("details[data-md-details] > summary")){if(t.querySelector("[data-md-disclosure-icon]"))continue;const r=document.createElement("span");r.append(...Array.from(t.childNodes));const o=document.createElement("span");o.setAttribute("data-md-disclosure-icon",""),o.setAttribute("aria-hidden","true"),q(o,"disclosure"),t.append(o,r)}},v=(e,t,r)=>{const o=document.createElement("button");return o.type="button",o.className=be,o.setAttribute("data-md-action",r),o.setAttribute("title",t),o.setAttribute("aria-label",t),q(o,e),o},ye=(e,t,r,o)=>{const n=t?o:r;e.setAttribute("title",n),e.setAttribute("aria-label",n),e.classList.toggle("text-foreground",t),e.classList.toggle("opacity-100",t),e.classList.toggle("text-muted-foreground",!t),e.classList.toggle("opacity-65",!t),e.setAttribute("aria-pressed",t?"true":"false")},Ae=(e,t,r)=>{const o=e.querySelector("[data-md-code-body]"),n=e.querySelector("pre"),s=e.querySelector("pre code"),i=e.querySelector('[data-md-action="toggle-code-wrap"]');e.setAttribute("data-code-wrap",t?"true":"false"),o?.classList.toggle("overflow-x-auto",!t),o?.classList.toggle("overflow-x-hidden",t),n?.classList.toggle("whitespace-pre-wrap",t),n?.classList.toggle("break-words",t),s?.classList.toggle("whitespace-pre-wrap",t),s?.classList.toggle("break-words",t),n&&(n.style.whiteSpace=t?"pre-wrap":"pre",n.style.overflowWrap=t?"anywhere":"normal"),s&&(s.style.whiteSpace=t?"pre-wrap":"pre",s.style.overflowWrap=t?"anywhere":"normal"),i&&ye(i,t,r.enableCodeWrap,r.disableCodeWrap)},$="data-md-code-lines",nt=e=>{const t=Array.from(e.children).find(n=>n.tagName==="CODE");if(!t||t.hasAttribute($))return;if(t.setAttribute($,""),Array.from(t.children).some(n=>n.classList.contains("line"))){Ne(t);return}const r=t.ownerDocument,o=r.createDocumentFragment();(t.textContent??"").split(`
1
+ import{a3 as de,aZ as Ee,a_ as ke,a$ as Le,aA as z,b0 as xe,b1 as Me,b2 as Te}from"./useAppFontEffects-d9vsRNKm.js";import{e as Ne}from"./openFenceIncremental-7wgnc2ZL.js";import{getMarkdownSelectionText as De}from"./selectionMarkdown-DV_HvvmZ.js";const b=e=>Number.isFinite(e)&&e>0,X=e=>{if(e==null)return null;const t=String(e).trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;const r=Number(t[1]);return b(r)?r:null},H=(e,t,r)=>Math.min(r,Math.max(t,e)),qe=6,Y=1.25,Re=1.0015,We=.5,Ie=12,K=3,_e=400,me='[data-markdown="mermaid-block"]',xt=e=>e.querySelector(me)!==null,Pe=e=>[e.x,e.y,e.width,e.height].map(t=>{const r=Number(t.toFixed(qe));return Object.is(r,-0)?"0":String(r)}).join(" "),ze=e=>{const t=e.viewBox?.trim().split(/[\s,]+/).map(n=>Number.parseFloat(n));if(t?.length===4){const[n,s,i,a]=t;if(Number.isFinite(n)&&Number.isFinite(s)&&b(i)&&b(a))return{x:n,y:s,width:i,height:a}}const r=X(e.width),o=X(e.height);return r===null||o===null?null:{x:0,y:0,width:r,height:o}},Oe=e=>{let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)},He=e=>{const t=e.renderMode||"unknown",r=e.svgMarkup??"";if(!r){const o=[e.viewBox??"",e.width??"",e.height??""];return o.some(n=>n!=="")?`${t}:bounds:${o.join(":")}`:`${t}:no-svg`}return[t,Oe(r)].join(":")},ue=(e,t)=>{if(!b(t.width)||!b(t.height))return e;const r=e.width/e.height,o=t.width/t.height;if(r>o){const s=e.width/o;return{x:e.x,y:e.y-(s-e.height)/2,width:e.width,height:s}}const n=e.height*o;return{x:e.x-(n-e.width)/2,y:e.y,width:n,height:e.height}},Ve=({currentBox:e,viewport:t,delta:r})=>!b(t.width)||!b(t.height)||!b(e.width)||!b(e.height)?e:{x:e.x-r.x/t.width*e.width,y:e.y-r.y/t.height*e.height,width:e.width,height:e.height},$e=(e,t)=>{const r=t.x-e.x,o=t.y-e.y;return r*r+o*o>K*K},V=e=>{const[t,r]=e;return!t||!r?null:{distance:Math.hypot(r.x-t.x,r.y-t.y),center:{x:(t.x+r.x)/2,y:(t.y+r.y)/2}}},Be=({currentBox:e,contentBox:t,viewport:r,pointer:o,zoomFactor:n,minScale:s,maxScale:i})=>{if(!b(r.width)||!b(r.height)||!b(n)||!b(e.width)||!b(e.height)||!b(t.width)||!b(t.height)||!b(s)||!b(i))return e;const a=Math.min(s,i),c=Math.max(s,i),l=ue(t,r),u=l.width/e.width,h=H(u*n,a,c),p=l.width/h,g=p/(e.width/e.height),E=H(o.x/r.width,0,1),m=H(o.y/r.height,0,1),f=e.x+E*e.width,w=e.y+m*e.height;return{x:f-E*p,y:w-m*g,width:p,height:g}},O=new WeakMap,F=new WeakMap,T=new Set,I=new Set;let M=null,R=null,D=null;const Fe=e=>e.querySelector('[data-markdown="mermaid-viewport"]')??e.querySelector('[data-markdown="mermaid"]'),pe=e=>{const t=e.querySelector('[data-markdown="mermaid"] svg'),r=e.querySelector('[data-markdown="mermaid"]');return He({renderMode:e.getAttribute("data-mermaid-render"),svgMarkup:r?.getAttribute("data-md-original-svg")??t?.outerHTML??null,viewBox:t?.getAttribute("viewBox"),width:t?.getAttribute("width"),height:t?.getAttribute("height")})},N=e=>{const t=e.getBoundingClientRect();return{width:t.width,height:t.height}},G=(e,t)=>{const r=t.getBoundingClientRect();return{x:e.clientX-r.left,y:e.clientY-r.top}},je=e=>e instanceof Element&&!!e.closest('button, a, [role="button"]'),fe=e=>{const t=e.map(r=>N(r.viewport));e.forEach((r,o)=>{const n=t[o];n&&r.fitToViewport(n)})},he=()=>{D!==null||T.size===0||(D=window.requestAnimationFrame(()=>{D=null,fe(Array.from(T))}))},Ue=()=>{if(M)return M;const e=globalThis.ResizeObserver;return e?(M=new e(t=>{for(const r of t)r.target instanceof HTMLElement&&F.get(r.target)?.fitToViewport({width:r.contentRect.width,height:r.contentRect.height})}),M):null},Xe=e=>{if(T.has(e))return;const t=T.size===0;T.add(e),F.set(e.viewport,e),Ue()?.observe(e.viewport),t&&window.addEventListener("resize",he)},Ye=e=>{T.delete(e)&&(M?.unobserve(e.viewport),F.delete(e.viewport),!(T.size>0)&&(M?.disconnect(),M=null,window.removeEventListener("resize",he),D!==null&&(window.cancelAnimationFrame(D),D=null)))},Ke=e=>{const t=Fe(e),r=e.querySelector('[data-markdown="mermaid"] svg');if(!t||!r)return null;const o=ze({viewBox:r.getAttribute("viewBox"),width:r.getAttribute("width"),height:r.getAttribute("height")});if(!o)return null;let n=o,s=null,i=null,a=null,c=null;const l=new Map;let u=null;const h=d=>{n=d,r.setAttribute("viewBox",Pe(d)),r.removeAttribute("width"),r.removeAttribute("height")},p=d=>{h(ue(o,d))},g=()=>{p(N(t))},E=(d,S)=>{h(Be({currentBox:n,contentBox:o,viewport:N(t),pointer:d,zoomFactor:S,minScale:We,maxScale:Ie}))},m=()=>{const d=N(t);E({x:d.width/2,y:d.height/2},Y)},f=()=>{const d=N(t);E({x:d.width/2,y:d.height/2},1/Y)},w=d=>{!d.ctrlKey&&!d.metaKey||(d.preventDefault(),d.stopPropagation(),E(G(d,t),Math.pow(Re,-d.deltaY)))},A=d=>{if(!(d.button!==0||je(d.target))){if(d.isPrimary&&(l.clear(),u=null),l.set(d.pointerId,{x:d.clientX,y:d.clientY}),l.size>1){s=null,u=V(Array.from(l.values()))?.distance??null,t.setPointerCapture?.(d.pointerId),e.setAttribute("data-mermaid-suppress-click","true"),d.preventDefault();return}s=d.pointerId,i={x:d.clientX,y:d.clientY},a=i,c!==null&&(window.clearTimeout(c),c=null),e.removeAttribute("data-mermaid-suppress-click"),t.setPointerCapture?.(d.pointerId),e.setAttribute("data-mermaid-panning","true"),d.preventDefault()}},k=d=>{const S={x:d.clientX,y:d.clientY};if(u!==null&&l.has(d.pointerId)){l.set(d.pointerId,S);const L=V(Array.from(l.values()));if(L){const _=G({clientX:L.center.x,clientY:L.center.y},t);E(_,L.distance/u),u=L.distance}d.preventDefault();return}s!==d.pointerId||!a||(h(Ve({currentBox:n,viewport:N(t),delta:{x:S.x-a.x,y:S.y-a.y}})),a=S,i&&$e(i,S)&&e.setAttribute("data-mermaid-suppress-click","true"),d.preventDefault())},C=d=>{if(l.delete(d.pointerId)){if(t.releasePointerCapture?.(d.pointerId),l.size>0){s=null,u=l.size>1?V(Array.from(l.values()))?.distance??null:null;return}u=null,s=null,i=null,a=null,e.removeAttribute("data-mermaid-panning"),e.hasAttribute("data-mermaid-suppress-click")&&(c=window.setTimeout(()=>{e.removeAttribute("data-mermaid-suppress-click"),c=null},_e))}};t.addEventListener("wheel",w,{passive:!1}),t.addEventListener("pointerdown",A),t.addEventListener("pointermove",k),t.addEventListener("pointerup",C),t.addEventListener("pointercancel",C);const y={viewport:t,zoomIn:m,zoomOut:f,fit:g,fitToViewport:p,cleanup:()=>{Ye(y),t.removeEventListener("wheel",w),t.removeEventListener("pointerdown",A),t.removeEventListener("pointermove",k),t.removeEventListener("pointerup",C),t.removeEventListener("pointercancel",C),c!==null&&window.clearTimeout(c),l.clear(),e.removeAttribute("data-mermaid-panning"),e.removeAttribute("data-mermaid-suppress-click"),O.delete(e)}};return y},ge=e=>{for(const[t,r]of e.controllers){const o=pe(t);(!e.container.contains(t)||o!==e.signatures.get(t))&&(r.cleanup(),e.controllers.delete(t),e.signatures.delete(t))}},Ge=e=>{if(e.disposed)return[];const t=[];for(const r of Array.from(e.container.querySelectorAll(me))){if(e.controllers.has(r)||r.querySelector('[data-markdown="mermaid"] svg')===null)continue;const o=Ke(r);o&&(e.controllers.set(r,o),e.signatures.set(r,pe(r)),O.set(r,o),t.push(o))}return t},we=()=>{const e=Array.from(I);I.clear();const t=[];for(const r of e)r.disposed||(ge(r),t.push(...Ge(r)));fe(t);for(const r of t)Xe(r)},Ze=()=>{R===null&&(R=window.requestAnimationFrame(()=>{R=null,R=window.requestAnimationFrame(()=>{R=null,we()})}))},Je=e=>{e.disposed||(ge(e),I.add(e),Ze())},Qe=e=>{if(!(e instanceof HTMLElement))return null;const t=O.get(e);if(t)return t;for(const r of I)if(r.container.contains(e))return we(),O.get(e)??null;return null},Mt=e=>{const t={container:e,controllers:new Map,signatures:new Map,disposed:!1},r=()=>Je(t),o=()=>{t.disposed=!0,I.delete(t);for(const n of t.controllers.values())n.cleanup();t.controllers.clear(),t.signatures.clear()};return r(),{refresh:r,cleanup:o}},et={copy:"file-copy",check:"check",download:"download",zoomIn:"add",zoomOut:"subtract",fit:"refresh",textWrap:"text-wrap",image:"file-image",disclosure:"arrow-right-s",browser:"global"},be="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",q=(e,t)=>{const r=et[t],o=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("class","remixicon size-3.5"),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("aria-hidden","true");const n=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","use");n.setAttribute("href",`#oc-${r}`),o.appendChild(n),e.replaceChildren(o)},tt=e=>{for(const t of Array.from(e.querySelectorAll('[data-openchamber-markdown-image-label="true"]'))){if(t.querySelector("[data-openchamber-markdown-image-label-icon]"))continue;const r=document.createElement("span");r.className="inline-flex shrink-0",r.setAttribute("aria-hidden","true"),r.setAttribute("data-openchamber-markdown-image-label-icon","true"),q(r,"image"),t.prepend(r)}},Z=(e,t)=>{if(e.querySelector("svg"))return;const r=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","block size-[1.1em] shrink-0"),r.setAttribute("aria-hidden","true"),r.setAttribute("focusable","false");const o=e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","use");o.setAttribute("href",t),r.appendChild(o),e.prepend(r)},rt=e=>{for(const t of Array.from(e.querySelectorAll("[data-attachment-citation]"))){const r=t.getAttribute("data-attachment-citation")??"";r&&Z(t,`#${r}`)}for(const t of Array.from(e.querySelectorAll("a[data-skill-name]")))Z(t,Te)},ot=e=>{for(const t of e.querySelectorAll("details[data-md-details] > summary")){if(t.querySelector("[data-md-disclosure-icon]"))continue;const r=document.createElement("span");r.append(...Array.from(t.childNodes));const o=document.createElement("span");o.setAttribute("data-md-disclosure-icon",""),o.setAttribute("aria-hidden","true"),q(o,"disclosure"),t.append(o,r)}},v=(e,t,r)=>{const o=document.createElement("button");return o.type="button",o.className=be,o.setAttribute("data-md-action",r),o.setAttribute("title",t),o.setAttribute("aria-label",t),q(o,e),o},ye=(e,t,r,o)=>{const n=t?o:r;e.setAttribute("title",n),e.setAttribute("aria-label",n),e.classList.toggle("text-foreground",t),e.classList.toggle("opacity-100",t),e.classList.toggle("text-muted-foreground",!t),e.classList.toggle("opacity-65",!t),e.setAttribute("aria-pressed",t?"true":"false")},Ae=(e,t,r)=>{const o=e.querySelector("[data-md-code-body]"),n=e.querySelector("pre"),s=e.querySelector("pre code"),i=e.querySelector('[data-md-action="toggle-code-wrap"]');e.setAttribute("data-code-wrap",t?"true":"false"),o?.classList.toggle("overflow-x-auto",!t),o?.classList.toggle("overflow-x-hidden",t),n?.classList.toggle("whitespace-pre-wrap",t),n?.classList.toggle("break-words",t),s?.classList.toggle("whitespace-pre-wrap",t),s?.classList.toggle("break-words",t),n&&(n.style.whiteSpace=t?"pre-wrap":"pre",n.style.overflowWrap=t?"anywhere":"normal"),s&&(s.style.whiteSpace=t?"pre-wrap":"pre",s.style.overflowWrap=t?"anywhere":"normal"),i&&ye(i,t,r.enableCodeWrap,r.disableCodeWrap)},$="data-md-code-lines",nt=e=>{const t=Array.from(e.children).find(n=>n.tagName==="CODE");if(!t||t.hasAttribute($))return;if(t.setAttribute($,""),Array.from(t.children).some(n=>n.classList.contains("line"))){Ne(t);return}const r=t.ownerDocument,o=r.createDocumentFragment();(t.textContent??"").split(`
2
2
  `).forEach((n,s)=>{s>0&&o.appendChild(r.createTextNode(`
3
3
  `));const i=r.createElement("span");i.className="line",n&&(i.textContent=n),o.appendChild(i)}),t.replaceChildren(o)},at=(e,t,r)=>{const o=e.querySelectorAll('[data-component="markdown-code"]');for(const n of Array.from(o))Ae(n,t,r)},J=(e,t,r,o)=>{q(e,"check"),e.setAttribute("title",t),e.setAttribute("aria-label",t),window.setTimeout(()=>{q(e,r),e.setAttribute("title",o),e.setAttribute("aria-label",o)},2e3)},it=e=>{const t=e.querySelectorAll(":not(pre) > code");for(const r of Array.from(t))r.getAttribute("data-markdown")!=="inline-code"&&r.setAttribute("data-markdown","inline-code"),r.getAttribute("dir")!=="ltr"&&r.setAttribute("dir","ltr"),r.closest("table")&&r.classList.add("whitespace-nowrap")},st=(e,t)=>{const r=e.querySelectorAll("pre");for(const o of Array.from(r)){if(o.querySelector("code.language-mermaid"))continue;const n=o.parentElement;if(!n||n.closest('[data-component="markdown-code"]'))continue;const s=o.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1]?.toLowerCase(),i=o.getAttribute("data-md-lang")??s??"text",a=document.createElement("div");a.setAttribute("data-component","markdown-code"),a.setAttribute("dir","ltr"),a.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const c=document.createElement("div");c.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const l=document.createElement("span");l.className="font-mono text-[13px] text-muted-foreground",l.textContent=i;const u=v("copy",t.labels.copy,"copy-code"),h=v("textWrap",t.codeBlockLineWrap?t.labels.disableCodeWrap:t.labels.enableCodeWrap,"toggle-code-wrap");c.appendChild(l);const p=document.createElement("div");p.className="flex items-center gap-1",p.setAttribute("data-md-code-actions",""),p.appendChild(h),p.appendChild(u),c.appendChild(p);const g=document.createElement("div");g.setAttribute("data-md-code-body",""),g.className="px-3 py-2.5 overflow-x-auto",n.replaceChild(a,o),o.style.margin="0",o.style.background="transparent",o.classList.add("min-w-0","w-full","flex-1"),nt(o),g.appendChild(o),a.appendChild(c),a.appendChild(g),Ae(a,t.codeBlockLineWrap,t.labels)}},Q=e=>e.replace(/\\/g,"\\\\").replace(/\|/g,"\\|"),lt=(e,t)=>{const r=o=>{if(!(o instanceof Element)){const n=o.textContent??"";return t?Q(n):n}if(o.tagName==="A"){const n=o.getAttribute("href");if(n){const s=n.replace(/ /g,"%20");if(!t)return s;const i=Q(o.textContent??"").replace(/\[/g,"\\[").replace(/\]/g,"\\]"),a=s.replace(/\|/g,"%7C"),c=/[()]/.test(a)?`<${a.replace(/</g,"%3C").replace(/>/g,"%3E")}>`:a;return`[${i}](${c})`}}return Array.from(o.childNodes).map(r).join("")};return Array.from(e.childNodes).map(r).join("")},ee=(e,t)=>{const r=t==="markdown",o=c=>lt(c,r).trim(),n=[],s=[],i=e.querySelectorAll("thead th");for(const c of Array.from(i))n.push(o(c));const a=e.querySelectorAll("tbody tr");for(const c of Array.from(a)){const l=Array.from(c.querySelectorAll("td")).map(o);l.length>0&&s.push(l)}return{headers:n,rows:s}},ct=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,te=({headers:e,rows:t})=>[e,...t].map(r=>r.map(ct).join(",")).join(`
4
4
  `),dt=({headers:e,rows:t})=>[e,...t].map(r=>r.join(" ")).join(`
@@ -1 +1 @@
1
- import{R as p,j as y,c as Pe,f as Fe}from"./vendor-react-BUCujlKS.js";import{i as Se,S as Oe,E as qe,o as R,l as Ce}from"./vendor-codemirror-state-Dek9sMtw.js";import{E as S,V as ke,s as Te,f as ze,h as We,i as ee,k as L,D as Ne,W as Ae}from"./vendor-codemirror-view-B66jUSmE.js";import{h as Be,l as $e,j as Le,k as _e}from"./vendor-codemirror-commands-dar6chwA.js";import{b as He,x as je,H as te,w as q,y as De}from"./vendor-codemirror-language-DyL0aCoH.js";import{a as N,g as z,b as re,c as oe,o as Ve,d as Ie}from"./vendor-codemirror-search-BKAwkhkm.js";import{v as Ke,g as Ge,V as _}from"./vendor-replit-codemirror-vim-CKWqK1yR.js";import{ef as Ue,N as Xe,I as ne,W as Qe,B as Ye,X as Je,V as Ze,aY as et}from"./useAppFontEffects-BZrjCfFw.js";import{a as t,c as tt}from"./vendor-lezer-highlight-CDMHUZ74.js";const Re=Oe.define(),rt=4,T=Se.define({create:()=>0,update(e,r){if(!N(r.state))return 0;for(const o of r.effects)o.is(Re)&&(e=o.value);return e},provide:e=>S.contentAttributes.from(e,r=>r>0?{style:`padding-top: ${r}px`}:{})}),ae=e=>parseFloat(getComputedStyle(e.contentDOM).paddingTop)||0,ot=ke.fromClass(class{constructor(e){this.view=e,e.requestMeasure({read:ae,write:r=>{this.padding=r}}),this.trackPanel()}observer=null;panel=null;padding=0;update(e){N(e.startState)!==N(e.state)&&this.trackPanel(),e.state.field(T)!==e.startState.field(T)&&this.view.requestMeasure({read:r=>({scrollTop:r.scrollDOM.scrollTop,padding:ae(r)}),write:({scrollTop:r,padding:o},a)=>{const c=o-this.padding;this.padding=o,r!==0&&(a.scrollDOM.scrollTop=c>0&&r<c?0:r+c)}})}destroy(){this.observer?.disconnect()}trackPanel(){this.view.requestMeasure({read:e=>N(e.state)?e.dom.querySelector(".cm-panels-top"):null,write:e=>{e!==this.panel&&(this.observer?.disconnect(),this.observer=null,this.panel=e,e&&(this.observer=new ResizeObserver(()=>this.syncSpace()),this.observer.observe(e)))}})}syncSpace(){const{panel:e,view:r}=this;if(!e||!N(r.state))return;const o=Math.ceil(e.getBoundingClientRect().bottom-r.scrollDOM.getBoundingClientRect().top)+rt;o!==r.state.field(T)&&r.dispatch({effects:Re.of(o)})}});function ce(){return[T,ot]}const se=["normal","visual","operatorPending"],nt=new Map([["map",{contexts:se,recursive:!0}],["noremap",{contexts:se,recursive:!1}],["nmap",{contexts:["normal"],recursive:!0}],["nnoremap",{contexts:["normal"],recursive:!1}],["imap",{contexts:["insert"],recursive:!0}],["inoremap",{contexts:["insert"],recursive:!1}],["vmap",{contexts:["visual"],recursive:!0}],["vnoremap",{contexts:["visual"],recursive:!1}],["xmap",{contexts:["visual"],recursive:!0}],["xnoremap",{contexts:["visual"],recursive:!1}],["omap",{contexts:["operatorPending"],recursive:!0}],["onoremap",{contexts:["operatorPending"],recursive:!1}]]),at=new Set(["<silent>","<nowait>","<buffer>","<unique>"]),ct=/^(\S+)((?:\s+<[a-z]+>)*)\s+(\S+)\s+(.+)$/i;function st(e){const r=[],o=[];return e.split(/\r?\n/).forEach((a,c)=>{const n=a.trim();if(!n||n.startsWith('"'))return;const i=ct.exec(n),l=i?nt.get(i[1]):void 0,g=i?i[2].trim().split(/\s+/).filter(Boolean).every(f=>at.has(f.toLowerCase())):!1;if(!i||!l||!g||i[3].startsWith(":")){o.push(c+1);return}for(const f of l.contexts)r.push({context:f,lhs:i[3],rhs:i[4].trim(),recursive:l.recursive})}),{mappings:r,invalidLines:o}}const it=e=>e!==null&&typeof e=="object"&&"updateStatus"in e&&typeof e.updateStatus=="function",lt=e=>{const r=document.createElement("div");r.className="cm-vim-panel";const o=Ge(e);if(!o)return{top:!1,dom:r};o.state.statusbar=r;const a=o.state.vimPlugin;return it(a)&&a.updateStatus(),{top:!1,dom:r,destroy(){o.state.statusbar===r&&(o.state.statusbar=null)}}};function ie(e){return e?[Ke(),Te.of(lt),ze(),Ue()]:[]}let le=null,ue=[];function Mt(e){if(e===le)return;for(const o of ue)_.unmap(o.lhs,o.context);const{mappings:r}=st(e);for(const o of r)o.recursive?_.map(o.lhs,o.rhs,o.context):_.noremap(o.lhs,o.rhs,o.context);ue=r,le=e}const ut={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},dt={case:"Match case",re:"Regular expression",word:"Match whole word"};function pt(e){const r=e.querySelector(".cm-search");if(r){for(const[o,a]of Object.entries(ut)){const c=r.querySelector(`button[name="${o}"]`);c&&!c.title&&(c.title=a)}for(const[o,a]of Object.entries(dt)){const n=r.querySelector(`input[name="${o}"]`)?.parentElement;n&&!n.title&&(n.title=a)}}}const H=new WeakMap;function mt(e,r){const o=z(e.state);if(!o.valid)return H.delete(e),0;const a=H.get(e);if(!r&&a?.doc===e.state.doc&&a.query.eq(o))return a.total;const c=o.getCursor(e.state);let n=0;for(let i=c.next();!i.done;i=c.next())n+=1;return H.set(e,{query:o,doc:e.state.doc,total:n}),n}function ft(e){const r=z(e.state);if(!r.valid)return 0;const o=e.state.selection.main,a=r.getCursor(e.state);let c=0,n=0;for(let i=a.next();!i.done;i=a.next()){const l=i.value;if(c+=1,n===0&&(n=c),o.from===l.from&&o.to===l.to||o.from<l.to&&o.to>l.from||l.from>=o.head)return c}return n}function de(e,r,o=!1){const a=e.querySelector(".cm-search");if(!a)return;let c=a.querySelector(".cm-search-message");if(!c){c=document.createElement("span"),c.className="cm-search-message",c.setAttribute("aria-live","polite");const l=a.querySelector('button[name="next"]'),g=l?.parentNode===a?l:a.firstChild;a.insertBefore(c,g)}const n=mt(r,o),i=n===0?0:ft(r);c.textContent=n===0?"":`${i}/${n}`}const gt={},pe=new R,me=new R,fe=new R,ge=new R,be=new R,xe=new R,he=new R,ve=e=>e,j=je,bt=Ve,xt=Ie;class ht extends Ae{constructor(r,o){super(),this.id=r,this.containerMap=o}toDOM(){let r=this.containerMap.get(this.id);return r||(r=document.createElement("div"),r.className="oc-block-widget",r.dataset.widgetId=this.id,this.containerMap.set(this.id,r)),r}eq(r){return r.id===this.id}destroy(){}}const ye=(e,r)=>!e||e.length===0?[]:Se.define({create(o){const a=new Ce,c=[...e].sort((n,i)=>n.afterLine-i.afterLine);for(const n of c){const i=o.doc.lines;if(n.afterLine>i)continue;const l=o.doc.line(n.afterLine);a.add(l.to,l.to,Ne.widget({widget:new ht(n.id,r),block:!0,side:1}))}return a.finish()},update(o,a){return o.map(a.changes)},provide:o=>S.decorations.from(o)}),we=e=>{if(!e)return[];const r=Math.max(1,e.start),o=Math.max(r,e.end);return ke.fromClass(class{decorations;constructor(a){this.decorations=this.build(a)}update(a){(a.docChanged||a.viewportChanged)&&(this.decorations=this.build(a.view))}build(a){const c=new Ce;for(let n=r;n<=o&&n<=a.state.doc.lines;n+=1){const i=a.state.doc.line(n);c.add(i.from,i.from,Ne.line({class:"oc-cm-selected-line"}))}return c.finish()}},{decorations:a=>a.decorations})};function Pt({value:e,onChange:r,extensions:o,className:a,readOnly:c,lineNumbersConfig:n,highlightLines:i,onViewReady:l,onViewDestroy:g,blockWidgets:f,enableSearch:h,searchOpen:D,onSearchOpenChange:W,vimMode:C,detached:O=!1}){const E=p.useRef(null),b=p.useRef(null),V=p.useRef(O),P=p.useRef(null),A=p.useRef(e),I=p.useRef(r),K=p.useRef(l),G=p.useRef(g),U=p.useRef(W),M=p.useRef(f),B=p.useRef(C),$=p.useRef(new Map),[Ee,X]=p.useState([]),w=p.useCallback(s=>{const m=(s??[]).map(u=>{const x=$.current.get(u.id);return x?{id:u.id,content:u.content,container:x}:null}).filter(u=>u!==null);X(u=>u.length===m.length&&u.every((x,d)=>{const v=m[d];return x.id===v.id&&x.content===v.content&&x.container===v.container})?u:m)},[]),Q=p.useRef(null),k=p.useCallback(s=>{const m=s??b.current;!E.current||!m||m.requestMeasure({key:gt,read:u=>{const x=u.dom.querySelector(".cm-gutters");return x instanceof HTMLElement?x.isConnected&&x.offsetParent!==null?x.getBoundingClientRect().width:null:0},write:u=>{const x=E.current;if(!x||u===null)return;const d=`${u}px`;Q.current!==d&&(Q.current=d,x.style.setProperty("--oc-editor-gutter-width",d))}})},[]);p.useEffect(()=>{A.current=e},[e]),p.useEffect(()=>{I.current=r},[r]),p.useEffect(()=>{K.current=l,G.current=g},[l,g]),p.useEffect(()=>{U.current=W},[W]),p.useEffect(()=>{M.current=f,w(f)},[f,w]),p.useEffect(()=>{if(!E.current)return;const s=(()=>{if(typeof document>"u")return null;const d=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(d)return d;const v=window.__OPENCHAMBER_CSP_NONCE__;return typeof v=="string"&&v.length>0?v:null})(),m=qe.create({doc:A.current,extensions:[...s?[S.cspNonce.of(s)]:[],We({fixed:!0}),pe.of(ee(n)),Be(),He.of(" "),he.of(ie(C)),L.of([$e,...Le,..._e]),S.updateListener.of(d=>{d.docChanged&&P.current&&(P.current=P.current.map(d.changes)??null),(d.docChanged||d.geometryChanged||d.viewportChanged||d.transactions.some(Me=>Me.reconfigured))&&k(d.view),(d.viewportChanged||d.geometryChanged)&&w(M.current);const v=N(d.startState),F=N(d.state);v!==F&&U.current?.(F);const J=!z(d.startState).eq(z(d.state));if(F&&(v!==F||J||d.docChanged||d.selectionSet)&&de(d.view.dom,d.view,v!==F||J||d.docChanged),!d.docChanged)return;const Z=d.state.doc.toString();A.current=Z,I.current(Z),w(M.current)}),me.of(S.editable.of(!c)),fe.of(o??[]),ge.of(we(i)),be.of(ye(f,$.current)),xe.of(h?[re({top:!0}),ce(),L.of(ve(oe))]:[])]});b.current=new S({state:m,parent:E.current}),V.current&&b.current.dom.remove();const u=b.current,x=()=>{P.current=u.scrollSnapshot()};return u.scrollDOM.addEventListener("scroll",x,{passive:!0}),j(b.current,b.current.state.doc.length,200),b.current.requestMeasure(),requestAnimationFrame(()=>{k(b.current),w(M.current)}),b.current&&K.current?.(b.current),()=>{u.scrollDOM.removeEventListener("scroll",x),G.current?.(),b.current?.destroy(),b.current=null,X([])}},[M,k,w]);const Y=p.useRef({lineNumbersConfig:n,readOnly:c,extensions:o,highlightLines:i,blockWidgets:f,enableSearch:h});return p.useEffect(()=>{const s=b.current;if(!s)return;const m=Y.current;Y.current={lineNumbersConfig:n,readOnly:c,extensions:o,highlightLines:i,blockWidgets:f,enableSearch:h};const u=[];m.lineNumbersConfig!==n&&u.push(pe.reconfigure(ee(n))),m.readOnly!==c&&u.push(me.reconfigure(S.editable.of(!c))),m.extensions!==o&&u.push(fe.reconfigure(o??[])),(m.highlightLines?.start!==i?.start||m.highlightLines?.end!==i?.end)&&u.push(ge.reconfigure(we(i))),m.blockWidgets!==f&&u.push(be.reconfigure(ye(f,$.current))),m.enableSearch!==h&&u.push(xe.reconfigure(h?[re({top:!0}),ce(),L.of(ve(oe))]:[])),u.length!==0&&(s.dispatch({effects:u}),j(s,s.state.doc.length,200),s.requestMeasure(),requestAnimationFrame(()=>{k(s),w(M.current)}))},[o,i,n,c,f,h,k,w]),p.useLayoutEffect(()=>{V.current=O;const s=E.current,m=b.current;if(!s||!m)return;if(O){m.dom.parentNode===s&&m.dom.remove();return}if(m.dom.parentNode===s)return;s.appendChild(m.dom);const u=P.current;u?m.dispatch({effects:u}):m.requestMeasure()},[O]),p.useEffect(()=>{const s=b.current;if(!s){B.current=C;return}B.current!==C&&(B.current=C,s.dispatch({effects:he.reconfigure(ie(C))}))},[C]),p.useEffect(()=>{const s=b.current;!s||h===!1||(D?(bt(s),requestAnimationFrame(()=>{pt(s.dom),de(s.dom,s,!0)})):xt(s))},[D,h]),p.useEffect(()=>{const s=b.current;if(!s)return;const m=s.state.doc.toString();m!==e&&(s.dispatch({changes:{from:0,to:m.length,insert:e}}),j(s,s.state.doc.length,300),s.requestMeasure(),requestAnimationFrame(()=>k(s)))},[e,k]),y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:E,dir:"ltr",className:Xe("oc-surface-code h-full w-full","[&_.cm-editor]:h-full [&_.cm-editor]:w-full","[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6",a)}),Ee.map(s=>Pe.createPortal(s.content,s.container,s.id))]})}const Ft=e=>{const r=Fe.c(11),{currentMode:o,onToggle:a}=e,c=o==="preview",n=c?"Switch to edit mode":"Switch to preview mode",i=c?"Edit":"Preview";let l;r[0]!==c?(l=c?y.jsx(ne,{name:"eye",className:"size-4","aria-hidden":"true"}):y.jsx(ne,{name:"eye-off",className:"size-4","aria-hidden":"true"}),r[0]=c,r[1]=l):l=r[1];let g;r[2]!==n||r[3]!==a||r[4]!==l?(g=y.jsx(Qe,{asChild:!0,children:y.jsx(Ye,{variant:"ghost",size:"sm",onClick:a,"aria-label":n,className:"h-5 w-5 p-0",children:l})}),r[2]=n,r[3]=a,r[4]=l,r[5]=g):g=r[5];let f;r[6]!==i?(f=y.jsx(Je,{sideOffset:8,children:i}),r[6]=i,r[7]=f):f=r[7];let h;return r[8]!==g||r[9]!==f?(h=y.jsxs(Ze,{children:[g,f]}),r[8]=g,r[9]=f,r[10]=h):h=r[10],h};function Ot(e,r){const o=e.metadata.variant==="dark",a=e.config?.fonts?.mono||"monospace",c=e.colors.syntax.highlights||{},n=et(e.colors.syntax),i=r?.fontSize?`${r.fontSize}px`:"var(--text-code)",l=e.colors.syntax.base.background,g=S.theme({"&":{backgroundColor:l,color:e.colors.syntax.base.foreground,fontSize:i,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:`var(--font-mono, ${a})`,backgroundColor:l},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:n.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:n.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:n.boolean||e.colors.syntax.base.number},".cm-builtin":{color:n.functionCall||e.colors.syntax.base.function},".cm-def":{color:n.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:n.variableOther||n.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:n.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:n.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:n.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:n.tag||e.colors.syntax.base.keyword},".cm-link":{color:n.url||e.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:l,color:c.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:"sticky",paddingRight:"8px",left:0,zIndex:2,boxShadow:`0 0 0 ${l}`},".cm-gutter":{backgroundColor:l},".cm-gutterElement":{backgroundColor:l},".cm-lineNumbers":{backgroundColor:l},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px",minWidth:"42px"},".cm-activeLineGutter":{color:c.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:`color-mix(in srgb, ${e.colors.syntax.base.foreground} 5%, transparent)`},".cm-panels":{backgroundColor:"transparent",color:e.colors.surface.elevatedForeground,position:"absolute",top:"0",right:"0",left:"auto",width:"auto",zIndex:10,pointerEvents:"none"},".cm-panels-top":{borderBottom:"none",position:"absolute",top:"6px",right:"14px",left:"auto",width:"auto"},".cm-panels-bottom":{position:"static",width:"100%",pointerEvents:"auto"},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:"var(--font-mono)",fontSize:"12px",minHeight:"22px",padding:"2px 8px"},".cm-panel.cm-search":{pointerEvents:"auto",padding:"4px",backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:e.colors.surface.elevatedForeground,fontFamily:"inherit",fontSize:"13px",lineHeight:"1"},".cm-search br":{display:"none"},".cm-search .cm-textfield":{appearance:"none",height:"26px",margin:0,padding:"0 8px",borderRadius:"6px !important",border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.elevatedForeground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.interactive.borderFocus},'.cm-search .cm-textfield[name="search"]':{order:1,flex:"1 1 120px",maxWidth:"calc(100% - 142px)",minWidth:"100px"},".cm-search label":{order:2,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"1px solid transparent",backgroundColor:"transparent",color:"transparent",cursor:"pointer",userSelect:"none",fontSize:"1px",lineHeight:"0",overflow:"hidden",position:"relative",transition:"background-color 120ms ease, border-color 120ms ease"},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:"none",WebkitAppearance:"none",width:"0",height:"0",margin:"0",padding:"0",border:"none",position:"absolute",opacity:"0",pointerEvents:"none"},".cm-search label::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"13px",fontWeight:"600",lineHeight:"1",fontFamily:"inherit",color:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:e.colors.surface.elevatedForeground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.elevatedForeground},'.cm-search label:has(input[name="case"])::after':{content:'"Aa"',fontSize:"12px",letterSpacing:"-0.5px"},'.cm-search label:has(input[name="re"])::after':{content:'".*"',fontSize:"13px",fontFamily:"monospace"},'.cm-search label:has(input[name="word"])::after':{content:'"ab"',fontSize:"12px",textDecoration:"underline",textUnderlineOffset:"2px"},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:"transparent",border:"none",borderRadius:"0",padding:"0 6px",fontSize:"11px",whiteSpace:"nowrap",lineHeight:"26px"},".cm-search .cm-button":{appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:"transparent",cursor:"pointer",fontSize:"1px",fontWeight:"400",lineHeight:"0",overflow:"hidden",position:"relative",boxShadow:"none",transition:"background-color 120ms ease"},".cm-search .cm-button::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"15px",lineHeight:"1",color:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.elevatedForeground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:"default",pointerEvents:"none"},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:"2px"},'.cm-search .cm-button[name="prev"]::after':{content:'"↑"'},'.cm-search .cm-button[name="next"]':{order:22,marginTop:"2px"},'.cm-search .cm-button[name="next"]::after':{content:'"↓"'},'.cm-search .cm-button[name="select"]':{order:23,marginTop:"2px"},'.cm-search .cm-button[name="select"]::after':{content:'"≡"',fontSize:"17px"},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:"0 0 0 auto",padding:"0",borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:e.colors.surface.mutedForeground,cursor:"pointer",fontSize:"16px",lineHeight:"1",boxShadow:"none",position:"relative",overflow:"visible",transition:"background-color 120ms ease, color 120ms ease"},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.elevatedForeground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:"2px"},'.cm-search .cm-button[name="replace"]::after':{content:'"⇄"'},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:"2px"},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:'"⇉"'},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:"1 1 100%",maxWidth:"calc(100% - 142px)",minWidth:"80px",marginTop:"2px"},".cm-searchMatch":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.border}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},".cm-selectionMatch":{backgroundColor:e.colors.interactive.selection,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.border}`,borderRadius:"2px"},".cm-selectionMatch-main":{backgroundColor:"transparent"},"&.cm-focused":{outline:"none"}},{dark:o}),f=te.define([{tag:[t.comment,t.docComment,t.meta,t.documentMeta],class:"cm-comment"},{tag:[t.keyword,t.controlKeyword,t.moduleKeyword,t.definitionKeyword,t.modifier],class:"cm-keyword"},{tag:[t.operatorKeyword,t.operator,t.derefOperator,t.updateOperator,t.definitionOperator,t.typeOperator,t.controlOperator,t.logicOperator,t.bitwiseOperator,t.arithmeticOperator,t.compareOperator],class:"cm-operator"},{tag:[t.punctuation,t.separator,t.bracket,t.paren,t.brace,t.squareBracket,t.angleBracket],class:"cm-punctuation"},{tag:[t.string,t.regexp,t.attributeValue,t.special(t.string),t.monospace],class:"cm-string"},{tag:t.escape,class:"cm-string-2"},{tag:[t.number,t.bool,t.atom,t.null,t.self],class:"cm-number"},{tag:[t.function(t.variableName),t.function(t.definition(t.variableName)),t.function(t.propertyName),t.standard(t.variableName),t.special(t.variableName)],class:"cm-builtin"},{tag:t.definition(t.variableName),class:"cm-def"},{tag:[t.variableName,t.local(t.variableName),t.constant(t.variableName),t.literal],class:"cm-variable"},{tag:t.propertyName,class:"cm-property"},{tag:t.attributeName,class:"cm-attribute"},{tag:[t.className,t.typeName,t.namespace],class:"cm-variable-3"},{tag:[t.tagName,t.labelName,t.annotation,t.macroName],class:"cm-tag"},{tag:t.link,class:"cm-link"},{tag:[t.heading,t.heading1,t.heading2,t.heading3,t.heading4,t.heading5,t.heading6],class:"cm-keyword"}]),h=te.define([{tag:[t.comment,t.docComment,t.meta,t.documentMeta],color:e.colors.syntax.base.comment},{tag:[t.keyword,t.controlKeyword,t.moduleKeyword,t.definitionKeyword,t.modifier],color:e.colors.syntax.base.keyword},{tag:[t.operatorKeyword,t.operator,t.derefOperator,t.updateOperator,t.definitionOperator,t.typeOperator,t.controlOperator,t.logicOperator,t.bitwiseOperator,t.arithmeticOperator,t.compareOperator],color:e.colors.syntax.base.operator},{tag:[t.string,t.regexp,t.attributeValue,t.special(t.string),t.monospace],color:e.colors.syntax.base.string},{tag:t.escape,color:n.stringEscape||e.colors.syntax.base.string},{tag:[t.number,t.bool,t.atom,t.null,t.self],color:e.colors.syntax.base.number},{tag:[t.function(t.variableName),t.function(t.definition(t.variableName)),t.function(t.propertyName),t.standard(t.variableName),t.special(t.variableName)],color:e.colors.syntax.base.function},{tag:t.definition(t.variableName),color:n.variableGlobal||e.colors.syntax.base.variable},{tag:[t.variableName,t.local(t.variableName),t.constant(t.variableName),t.literal],color:e.colors.syntax.base.variable},{tag:t.propertyName,color:n.variableProperty||e.colors.syntax.base.variable},{tag:t.attributeName,color:n.variableOther||e.colors.syntax.base.variable},{tag:[t.className,t.typeName,t.namespace],color:e.colors.syntax.base.type},{tag:[t.tagName,t.labelName,t.annotation,t.macroName],color:n.tag||e.colors.syntax.base.keyword},{tag:t.link,color:n.url||e.colors.syntax.base.function,textDecoration:"underline"},{tag:[t.punctuation,t.separator,t.bracket,t.paren,t.brace,t.squareBracket,t.angleBracket],color:n.punctuation||e.colors.syntax.base.comment}]);return r?.syntaxColors===!1?[g]:[g,q(De,{fallback:!0}),q(tt),q(f),q(h)]}export{Pt as C,Ft as P,Ot as c,st as p,Mt as s};
1
+ import{R as p,j as y,c as Pe,f as Fe}from"./vendor-react-BUCujlKS.js";import{i as Se,S as Oe,E as qe,o as R,l as Ce}from"./vendor-codemirror-state-Dek9sMtw.js";import{E as S,V as ke,s as Te,f as ze,h as We,i as ee,k as L,D as Ne,W as Ae}from"./vendor-codemirror-view-B66jUSmE.js";import{h as Be,l as $e,j as Le,k as _e}from"./vendor-codemirror-commands-dar6chwA.js";import{b as He,x as je,H as te,w as q,y as De}from"./vendor-codemirror-language-DyL0aCoH.js";import{a as N,g as z,b as re,c as oe,o as Ve,d as Ie}from"./vendor-codemirror-search-BKAwkhkm.js";import{v as Ke,g as Ge,V as _}from"./vendor-replit-codemirror-vim-CKWqK1yR.js";import{ef as Ue,N as Xe,I as ne,W as Qe,B as Ye,X as Je,V as Ze,aY as et}from"./useAppFontEffects-d9vsRNKm.js";import{a as t,c as tt}from"./vendor-lezer-highlight-CDMHUZ74.js";const Re=Oe.define(),rt=4,T=Se.define({create:()=>0,update(e,r){if(!N(r.state))return 0;for(const o of r.effects)o.is(Re)&&(e=o.value);return e},provide:e=>S.contentAttributes.from(e,r=>r>0?{style:`padding-top: ${r}px`}:{})}),ae=e=>parseFloat(getComputedStyle(e.contentDOM).paddingTop)||0,ot=ke.fromClass(class{constructor(e){this.view=e,e.requestMeasure({read:ae,write:r=>{this.padding=r}}),this.trackPanel()}observer=null;panel=null;padding=0;update(e){N(e.startState)!==N(e.state)&&this.trackPanel(),e.state.field(T)!==e.startState.field(T)&&this.view.requestMeasure({read:r=>({scrollTop:r.scrollDOM.scrollTop,padding:ae(r)}),write:({scrollTop:r,padding:o},a)=>{const c=o-this.padding;this.padding=o,r!==0&&(a.scrollDOM.scrollTop=c>0&&r<c?0:r+c)}})}destroy(){this.observer?.disconnect()}trackPanel(){this.view.requestMeasure({read:e=>N(e.state)?e.dom.querySelector(".cm-panels-top"):null,write:e=>{e!==this.panel&&(this.observer?.disconnect(),this.observer=null,this.panel=e,e&&(this.observer=new ResizeObserver(()=>this.syncSpace()),this.observer.observe(e)))}})}syncSpace(){const{panel:e,view:r}=this;if(!e||!N(r.state))return;const o=Math.ceil(e.getBoundingClientRect().bottom-r.scrollDOM.getBoundingClientRect().top)+rt;o!==r.state.field(T)&&r.dispatch({effects:Re.of(o)})}});function ce(){return[T,ot]}const se=["normal","visual","operatorPending"],nt=new Map([["map",{contexts:se,recursive:!0}],["noremap",{contexts:se,recursive:!1}],["nmap",{contexts:["normal"],recursive:!0}],["nnoremap",{contexts:["normal"],recursive:!1}],["imap",{contexts:["insert"],recursive:!0}],["inoremap",{contexts:["insert"],recursive:!1}],["vmap",{contexts:["visual"],recursive:!0}],["vnoremap",{contexts:["visual"],recursive:!1}],["xmap",{contexts:["visual"],recursive:!0}],["xnoremap",{contexts:["visual"],recursive:!1}],["omap",{contexts:["operatorPending"],recursive:!0}],["onoremap",{contexts:["operatorPending"],recursive:!1}]]),at=new Set(["<silent>","<nowait>","<buffer>","<unique>"]),ct=/^(\S+)((?:\s+<[a-z]+>)*)\s+(\S+)\s+(.+)$/i;function st(e){const r=[],o=[];return e.split(/\r?\n/).forEach((a,c)=>{const n=a.trim();if(!n||n.startsWith('"'))return;const i=ct.exec(n),l=i?nt.get(i[1]):void 0,g=i?i[2].trim().split(/\s+/).filter(Boolean).every(f=>at.has(f.toLowerCase())):!1;if(!i||!l||!g||i[3].startsWith(":")){o.push(c+1);return}for(const f of l.contexts)r.push({context:f,lhs:i[3],rhs:i[4].trim(),recursive:l.recursive})}),{mappings:r,invalidLines:o}}const it=e=>e!==null&&typeof e=="object"&&"updateStatus"in e&&typeof e.updateStatus=="function",lt=e=>{const r=document.createElement("div");r.className="cm-vim-panel";const o=Ge(e);if(!o)return{top:!1,dom:r};o.state.statusbar=r;const a=o.state.vimPlugin;return it(a)&&a.updateStatus(),{top:!1,dom:r,destroy(){o.state.statusbar===r&&(o.state.statusbar=null)}}};function ie(e){return e?[Ke(),Te.of(lt),ze(),Ue()]:[]}let le=null,ue=[];function Mt(e){if(e===le)return;for(const o of ue)_.unmap(o.lhs,o.context);const{mappings:r}=st(e);for(const o of r)o.recursive?_.map(o.lhs,o.rhs,o.context):_.noremap(o.lhs,o.rhs,o.context);ue=r,le=e}const ut={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},dt={case:"Match case",re:"Regular expression",word:"Match whole word"};function pt(e){const r=e.querySelector(".cm-search");if(r){for(const[o,a]of Object.entries(ut)){const c=r.querySelector(`button[name="${o}"]`);c&&!c.title&&(c.title=a)}for(const[o,a]of Object.entries(dt)){const n=r.querySelector(`input[name="${o}"]`)?.parentElement;n&&!n.title&&(n.title=a)}}}const H=new WeakMap;function mt(e,r){const o=z(e.state);if(!o.valid)return H.delete(e),0;const a=H.get(e);if(!r&&a?.doc===e.state.doc&&a.query.eq(o))return a.total;const c=o.getCursor(e.state);let n=0;for(let i=c.next();!i.done;i=c.next())n+=1;return H.set(e,{query:o,doc:e.state.doc,total:n}),n}function ft(e){const r=z(e.state);if(!r.valid)return 0;const o=e.state.selection.main,a=r.getCursor(e.state);let c=0,n=0;for(let i=a.next();!i.done;i=a.next()){const l=i.value;if(c+=1,n===0&&(n=c),o.from===l.from&&o.to===l.to||o.from<l.to&&o.to>l.from||l.from>=o.head)return c}return n}function de(e,r,o=!1){const a=e.querySelector(".cm-search");if(!a)return;let c=a.querySelector(".cm-search-message");if(!c){c=document.createElement("span"),c.className="cm-search-message",c.setAttribute("aria-live","polite");const l=a.querySelector('button[name="next"]'),g=l?.parentNode===a?l:a.firstChild;a.insertBefore(c,g)}const n=mt(r,o),i=n===0?0:ft(r);c.textContent=n===0?"":`${i}/${n}`}const gt={},pe=new R,me=new R,fe=new R,ge=new R,be=new R,xe=new R,he=new R,ve=e=>e,j=je,bt=Ve,xt=Ie;class ht extends Ae{constructor(r,o){super(),this.id=r,this.containerMap=o}toDOM(){let r=this.containerMap.get(this.id);return r||(r=document.createElement("div"),r.className="oc-block-widget",r.dataset.widgetId=this.id,this.containerMap.set(this.id,r)),r}eq(r){return r.id===this.id}destroy(){}}const ye=(e,r)=>!e||e.length===0?[]:Se.define({create(o){const a=new Ce,c=[...e].sort((n,i)=>n.afterLine-i.afterLine);for(const n of c){const i=o.doc.lines;if(n.afterLine>i)continue;const l=o.doc.line(n.afterLine);a.add(l.to,l.to,Ne.widget({widget:new ht(n.id,r),block:!0,side:1}))}return a.finish()},update(o,a){return o.map(a.changes)},provide:o=>S.decorations.from(o)}),we=e=>{if(!e)return[];const r=Math.max(1,e.start),o=Math.max(r,e.end);return ke.fromClass(class{decorations;constructor(a){this.decorations=this.build(a)}update(a){(a.docChanged||a.viewportChanged)&&(this.decorations=this.build(a.view))}build(a){const c=new Ce;for(let n=r;n<=o&&n<=a.state.doc.lines;n+=1){const i=a.state.doc.line(n);c.add(i.from,i.from,Ne.line({class:"oc-cm-selected-line"}))}return c.finish()}},{decorations:a=>a.decorations})};function Pt({value:e,onChange:r,extensions:o,className:a,readOnly:c,lineNumbersConfig:n,highlightLines:i,onViewReady:l,onViewDestroy:g,blockWidgets:f,enableSearch:h,searchOpen:D,onSearchOpenChange:W,vimMode:C,detached:O=!1}){const E=p.useRef(null),b=p.useRef(null),V=p.useRef(O),P=p.useRef(null),A=p.useRef(e),I=p.useRef(r),K=p.useRef(l),G=p.useRef(g),U=p.useRef(W),M=p.useRef(f),B=p.useRef(C),$=p.useRef(new Map),[Ee,X]=p.useState([]),w=p.useCallback(s=>{const m=(s??[]).map(u=>{const x=$.current.get(u.id);return x?{id:u.id,content:u.content,container:x}:null}).filter(u=>u!==null);X(u=>u.length===m.length&&u.every((x,d)=>{const v=m[d];return x.id===v.id&&x.content===v.content&&x.container===v.container})?u:m)},[]),Q=p.useRef(null),k=p.useCallback(s=>{const m=s??b.current;!E.current||!m||m.requestMeasure({key:gt,read:u=>{const x=u.dom.querySelector(".cm-gutters");return x instanceof HTMLElement?x.isConnected&&x.offsetParent!==null?x.getBoundingClientRect().width:null:0},write:u=>{const x=E.current;if(!x||u===null)return;const d=`${u}px`;Q.current!==d&&(Q.current=d,x.style.setProperty("--oc-editor-gutter-width",d))}})},[]);p.useEffect(()=>{A.current=e},[e]),p.useEffect(()=>{I.current=r},[r]),p.useEffect(()=>{K.current=l,G.current=g},[l,g]),p.useEffect(()=>{U.current=W},[W]),p.useEffect(()=>{M.current=f,w(f)},[f,w]),p.useEffect(()=>{if(!E.current)return;const s=(()=>{if(typeof document>"u")return null;const d=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(d)return d;const v=window.__OPENCHAMBER_CSP_NONCE__;return typeof v=="string"&&v.length>0?v:null})(),m=qe.create({doc:A.current,extensions:[...s?[S.cspNonce.of(s)]:[],We({fixed:!0}),pe.of(ee(n)),Be(),He.of(" "),he.of(ie(C)),L.of([$e,...Le,..._e]),S.updateListener.of(d=>{d.docChanged&&P.current&&(P.current=P.current.map(d.changes)??null),(d.docChanged||d.geometryChanged||d.viewportChanged||d.transactions.some(Me=>Me.reconfigured))&&k(d.view),(d.viewportChanged||d.geometryChanged)&&w(M.current);const v=N(d.startState),F=N(d.state);v!==F&&U.current?.(F);const J=!z(d.startState).eq(z(d.state));if(F&&(v!==F||J||d.docChanged||d.selectionSet)&&de(d.view.dom,d.view,v!==F||J||d.docChanged),!d.docChanged)return;const Z=d.state.doc.toString();A.current=Z,I.current(Z),w(M.current)}),me.of(S.editable.of(!c)),fe.of(o??[]),ge.of(we(i)),be.of(ye(f,$.current)),xe.of(h?[re({top:!0}),ce(),L.of(ve(oe))]:[])]});b.current=new S({state:m,parent:E.current}),V.current&&b.current.dom.remove();const u=b.current,x=()=>{P.current=u.scrollSnapshot()};return u.scrollDOM.addEventListener("scroll",x,{passive:!0}),j(b.current,b.current.state.doc.length,200),b.current.requestMeasure(),requestAnimationFrame(()=>{k(b.current),w(M.current)}),b.current&&K.current?.(b.current),()=>{u.scrollDOM.removeEventListener("scroll",x),G.current?.(),b.current?.destroy(),b.current=null,X([])}},[M,k,w]);const Y=p.useRef({lineNumbersConfig:n,readOnly:c,extensions:o,highlightLines:i,blockWidgets:f,enableSearch:h});return p.useEffect(()=>{const s=b.current;if(!s)return;const m=Y.current;Y.current={lineNumbersConfig:n,readOnly:c,extensions:o,highlightLines:i,blockWidgets:f,enableSearch:h};const u=[];m.lineNumbersConfig!==n&&u.push(pe.reconfigure(ee(n))),m.readOnly!==c&&u.push(me.reconfigure(S.editable.of(!c))),m.extensions!==o&&u.push(fe.reconfigure(o??[])),(m.highlightLines?.start!==i?.start||m.highlightLines?.end!==i?.end)&&u.push(ge.reconfigure(we(i))),m.blockWidgets!==f&&u.push(be.reconfigure(ye(f,$.current))),m.enableSearch!==h&&u.push(xe.reconfigure(h?[re({top:!0}),ce(),L.of(ve(oe))]:[])),u.length!==0&&(s.dispatch({effects:u}),j(s,s.state.doc.length,200),s.requestMeasure(),requestAnimationFrame(()=>{k(s),w(M.current)}))},[o,i,n,c,f,h,k,w]),p.useLayoutEffect(()=>{V.current=O;const s=E.current,m=b.current;if(!s||!m)return;if(O){m.dom.parentNode===s&&m.dom.remove();return}if(m.dom.parentNode===s)return;s.appendChild(m.dom);const u=P.current;u?m.dispatch({effects:u}):m.requestMeasure()},[O]),p.useEffect(()=>{const s=b.current;if(!s){B.current=C;return}B.current!==C&&(B.current=C,s.dispatch({effects:he.reconfigure(ie(C))}))},[C]),p.useEffect(()=>{const s=b.current;!s||h===!1||(D?(bt(s),requestAnimationFrame(()=>{pt(s.dom),de(s.dom,s,!0)})):xt(s))},[D,h]),p.useEffect(()=>{const s=b.current;if(!s)return;const m=s.state.doc.toString();m!==e&&(s.dispatch({changes:{from:0,to:m.length,insert:e}}),j(s,s.state.doc.length,300),s.requestMeasure(),requestAnimationFrame(()=>k(s)))},[e,k]),y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:E,dir:"ltr",className:Xe("oc-surface-code h-full w-full","[&_.cm-editor]:h-full [&_.cm-editor]:w-full","[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6",a)}),Ee.map(s=>Pe.createPortal(s.content,s.container,s.id))]})}const Ft=e=>{const r=Fe.c(11),{currentMode:o,onToggle:a}=e,c=o==="preview",n=c?"Switch to edit mode":"Switch to preview mode",i=c?"Edit":"Preview";let l;r[0]!==c?(l=c?y.jsx(ne,{name:"eye",className:"size-4","aria-hidden":"true"}):y.jsx(ne,{name:"eye-off",className:"size-4","aria-hidden":"true"}),r[0]=c,r[1]=l):l=r[1];let g;r[2]!==n||r[3]!==a||r[4]!==l?(g=y.jsx(Qe,{asChild:!0,children:y.jsx(Ye,{variant:"ghost",size:"sm",onClick:a,"aria-label":n,className:"h-5 w-5 p-0",children:l})}),r[2]=n,r[3]=a,r[4]=l,r[5]=g):g=r[5];let f;r[6]!==i?(f=y.jsx(Je,{sideOffset:8,children:i}),r[6]=i,r[7]=f):f=r[7];let h;return r[8]!==g||r[9]!==f?(h=y.jsxs(Ze,{children:[g,f]}),r[8]=g,r[9]=f,r[10]=h):h=r[10],h};function Ot(e,r){const o=e.metadata.variant==="dark",a=e.config?.fonts?.mono||"monospace",c=e.colors.syntax.highlights||{},n=et(e.colors.syntax),i=r?.fontSize?`${r.fontSize}px`:"var(--text-code)",l=e.colors.syntax.base.background,g=S.theme({"&":{backgroundColor:l,color:e.colors.syntax.base.foreground,fontSize:i,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:`var(--font-mono, ${a})`,backgroundColor:l},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:n.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:n.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:n.boolean||e.colors.syntax.base.number},".cm-builtin":{color:n.functionCall||e.colors.syntax.base.function},".cm-def":{color:n.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:n.variableOther||n.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:n.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:n.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:n.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:n.tag||e.colors.syntax.base.keyword},".cm-link":{color:n.url||e.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:l,color:c.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:"sticky",paddingRight:"8px",left:0,zIndex:2,boxShadow:`0 0 0 ${l}`},".cm-gutter":{backgroundColor:l},".cm-gutterElement":{backgroundColor:l},".cm-lineNumbers":{backgroundColor:l},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px",minWidth:"42px"},".cm-activeLineGutter":{color:c.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:`color-mix(in srgb, ${e.colors.syntax.base.foreground} 5%, transparent)`},".cm-panels":{backgroundColor:"transparent",color:e.colors.surface.elevatedForeground,position:"absolute",top:"0",right:"0",left:"auto",width:"auto",zIndex:10,pointerEvents:"none"},".cm-panels-top":{borderBottom:"none",position:"absolute",top:"6px",right:"14px",left:"auto",width:"auto"},".cm-panels-bottom":{position:"static",width:"100%",pointerEvents:"auto"},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:"var(--font-mono)",fontSize:"12px",minHeight:"22px",padding:"2px 8px"},".cm-panel.cm-search":{pointerEvents:"auto",padding:"4px",backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:e.colors.surface.elevatedForeground,fontFamily:"inherit",fontSize:"13px",lineHeight:"1"},".cm-search br":{display:"none"},".cm-search .cm-textfield":{appearance:"none",height:"26px",margin:0,padding:"0 8px",borderRadius:"6px !important",border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.elevatedForeground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.interactive.borderFocus},'.cm-search .cm-textfield[name="search"]':{order:1,flex:"1 1 120px",maxWidth:"calc(100% - 142px)",minWidth:"100px"},".cm-search label":{order:2,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"1px solid transparent",backgroundColor:"transparent",color:"transparent",cursor:"pointer",userSelect:"none",fontSize:"1px",lineHeight:"0",overflow:"hidden",position:"relative",transition:"background-color 120ms ease, border-color 120ms ease"},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:"none",WebkitAppearance:"none",width:"0",height:"0",margin:"0",padding:"0",border:"none",position:"absolute",opacity:"0",pointerEvents:"none"},".cm-search label::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"13px",fontWeight:"600",lineHeight:"1",fontFamily:"inherit",color:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:e.colors.surface.elevatedForeground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.elevatedForeground},'.cm-search label:has(input[name="case"])::after':{content:'"Aa"',fontSize:"12px",letterSpacing:"-0.5px"},'.cm-search label:has(input[name="re"])::after':{content:'".*"',fontSize:"13px",fontFamily:"monospace"},'.cm-search label:has(input[name="word"])::after':{content:'"ab"',fontSize:"12px",textDecoration:"underline",textUnderlineOffset:"2px"},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:"transparent",border:"none",borderRadius:"0",padding:"0 6px",fontSize:"11px",whiteSpace:"nowrap",lineHeight:"26px"},".cm-search .cm-button":{appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:"transparent",cursor:"pointer",fontSize:"1px",fontWeight:"400",lineHeight:"0",overflow:"hidden",position:"relative",boxShadow:"none",transition:"background-color 120ms ease"},".cm-search .cm-button::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"15px",lineHeight:"1",color:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.elevatedForeground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:"default",pointerEvents:"none"},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:"2px"},'.cm-search .cm-button[name="prev"]::after':{content:'"↑"'},'.cm-search .cm-button[name="next"]':{order:22,marginTop:"2px"},'.cm-search .cm-button[name="next"]::after':{content:'"↓"'},'.cm-search .cm-button[name="select"]':{order:23,marginTop:"2px"},'.cm-search .cm-button[name="select"]::after':{content:'"≡"',fontSize:"17px"},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:"0 0 0 auto",padding:"0",borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:e.colors.surface.mutedForeground,cursor:"pointer",fontSize:"16px",lineHeight:"1",boxShadow:"none",position:"relative",overflow:"visible",transition:"background-color 120ms ease, color 120ms ease"},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.elevatedForeground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:"2px"},'.cm-search .cm-button[name="replace"]::after':{content:'"⇄"'},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:"2px"},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:'"⇉"'},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:"1 1 100%",maxWidth:"calc(100% - 142px)",minWidth:"80px",marginTop:"2px"},".cm-searchMatch":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.border}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},".cm-selectionMatch":{backgroundColor:e.colors.interactive.selection,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.border}`,borderRadius:"2px"},".cm-selectionMatch-main":{backgroundColor:"transparent"},"&.cm-focused":{outline:"none"}},{dark:o}),f=te.define([{tag:[t.comment,t.docComment,t.meta,t.documentMeta],class:"cm-comment"},{tag:[t.keyword,t.controlKeyword,t.moduleKeyword,t.definitionKeyword,t.modifier],class:"cm-keyword"},{tag:[t.operatorKeyword,t.operator,t.derefOperator,t.updateOperator,t.definitionOperator,t.typeOperator,t.controlOperator,t.logicOperator,t.bitwiseOperator,t.arithmeticOperator,t.compareOperator],class:"cm-operator"},{tag:[t.punctuation,t.separator,t.bracket,t.paren,t.brace,t.squareBracket,t.angleBracket],class:"cm-punctuation"},{tag:[t.string,t.regexp,t.attributeValue,t.special(t.string),t.monospace],class:"cm-string"},{tag:t.escape,class:"cm-string-2"},{tag:[t.number,t.bool,t.atom,t.null,t.self],class:"cm-number"},{tag:[t.function(t.variableName),t.function(t.definition(t.variableName)),t.function(t.propertyName),t.standard(t.variableName),t.special(t.variableName)],class:"cm-builtin"},{tag:t.definition(t.variableName),class:"cm-def"},{tag:[t.variableName,t.local(t.variableName),t.constant(t.variableName),t.literal],class:"cm-variable"},{tag:t.propertyName,class:"cm-property"},{tag:t.attributeName,class:"cm-attribute"},{tag:[t.className,t.typeName,t.namespace],class:"cm-variable-3"},{tag:[t.tagName,t.labelName,t.annotation,t.macroName],class:"cm-tag"},{tag:t.link,class:"cm-link"},{tag:[t.heading,t.heading1,t.heading2,t.heading3,t.heading4,t.heading5,t.heading6],class:"cm-keyword"}]),h=te.define([{tag:[t.comment,t.docComment,t.meta,t.documentMeta],color:e.colors.syntax.base.comment},{tag:[t.keyword,t.controlKeyword,t.moduleKeyword,t.definitionKeyword,t.modifier],color:e.colors.syntax.base.keyword},{tag:[t.operatorKeyword,t.operator,t.derefOperator,t.updateOperator,t.definitionOperator,t.typeOperator,t.controlOperator,t.logicOperator,t.bitwiseOperator,t.arithmeticOperator,t.compareOperator],color:e.colors.syntax.base.operator},{tag:[t.string,t.regexp,t.attributeValue,t.special(t.string),t.monospace],color:e.colors.syntax.base.string},{tag:t.escape,color:n.stringEscape||e.colors.syntax.base.string},{tag:[t.number,t.bool,t.atom,t.null,t.self],color:e.colors.syntax.base.number},{tag:[t.function(t.variableName),t.function(t.definition(t.variableName)),t.function(t.propertyName),t.standard(t.variableName),t.special(t.variableName)],color:e.colors.syntax.base.function},{tag:t.definition(t.variableName),color:n.variableGlobal||e.colors.syntax.base.variable},{tag:[t.variableName,t.local(t.variableName),t.constant(t.variableName),t.literal],color:e.colors.syntax.base.variable},{tag:t.propertyName,color:n.variableProperty||e.colors.syntax.base.variable},{tag:t.attributeName,color:n.variableOther||e.colors.syntax.base.variable},{tag:[t.className,t.typeName,t.namespace],color:e.colors.syntax.base.type},{tag:[t.tagName,t.labelName,t.annotation,t.macroName],color:n.tag||e.colors.syntax.base.keyword},{tag:t.link,color:n.url||e.colors.syntax.base.function,textDecoration:"underline"},{tag:[t.punctuation,t.separator,t.bracket,t.paren,t.brace,t.squareBracket,t.angleBracket],color:n.punctuation||e.colors.syntax.base.comment}]);return r?.syntaxColors===!1?[g]:[g,q(De,{fallback:!0}),q(tt),q(f),q(h)]}export{Pt as C,Ft as P,Ot as c,st as p,Mt as s};
@@ -1 +1 @@
1
- import{R as D,h as x,r as L,p as P,v as A,i as T,a as M,j as V,k as q,W as m,m as j,l as _,n as Q,o as R,q as N,s as $,t as U,g as w}from"./computeVirtualFileMetrics-tFBUWYu1.js";import{u as di}from"./computeVirtualFileMetrics-tFBUWYu1.js";import{et as I}from"./useAppFontEffects-BZrjCfFw.js";import{h as S,i as b,a as C,r as G}from"./isFilePlainText-y0Pch-hF.js";import{b as k,i as E,r as Z,c as J,a as X}from"./isDiffPlainText-DxiX2X7Q.js";import{t as K}from"./themeResolver-yJ9XpNMI.js";import{L as B}from"./vendor-lru_map-Tstukz9J.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./vendor-react-BUCujlKS.js";import"./vendor-scheduler-7OC5HNn7.js";import"./katex.min-u4DtE8E5.js";import"./vendor-zod-DDir2TeQ.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-h8RufjAw.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DsRKCbVv.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-diff-C3JhlQdm.js";function O(e){const t=[];for(const i of e){const s=D.get(i);if(s==null)throw new Error(`getResolvedLanguages: ${i} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(s)}return t}function z(e){for(const t of Array.isArray(e)?e:[e])if(!D.has(t))return!1;return!0}async function F(e){const t=[],i=[];for(const s of e){if(s==="text"||s==="ansi")continue;const r=x(s)??L(s);"then"in r?i.push(r):t.push(r)}return i.length>0&&await Promise.all(i).then(s=>{for(const r of s){if(r==null)throw new Error("resolvedLanguages: unable to resolve language");t.push(r)}}),t}function H(e){return K.getResolvedThemes(e)}async function W(e){for(const i of e)P(i);const t=await K.resolveThemes(e);for(let i=0;i<e.length;i++)A(e[i],t[i]);return t}const y=Symbol("IGNORE_RESPONSE"),Y=1e4;var ee=class{options;highlighter;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;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:i=I,useTokenTransformer:s=!1,lineDiffType:r="word-alt",maxLineDiffLength:n=1e3,tokenizeMaxLineLength:a=1e3,preferredHighlighter:o="shiki-js"}){this.options=e,this.preferredHighlighter=o,this.renderOptions={theme:i,useTokenTransformer:s,lineDiffType:r,maxLineDiffLength:n,tokenizeMaxLineLength:a},this.fileCache=new B.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new B.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}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}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??I,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:i=this.renderOptions.lineDiffType??"word-alt",maxLineDiffLength:s=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:r=this.renderOptions.tokenizeMaxLineLength??1e3}){const{lifecycleGeneration:n}=this,a=++this.renderOptionsRequestVersion,o=()=>this.isCurrentLifecycle(n)&&this.renderOptionsRequestVersion===a;try{const h={theme:e,useTokenTransformer:t,lineDiffType:i,maxLineDiffLength:s,tokenizeMaxLineLength:r};if(this.isInitialized()||await this.initialize(),!o()||k(h,this.renderOptions))return;const l=T(e);let u=[];if(M(h.theme,this.renderOptions.theme)||(S(l)?u=H(l):u=await W(l)),!o())return;if(this.highlighter!=null)V(u,this.highlighter);else{const f=await q({themes:l,langs:["text"],preferredHighlighter:this.preferredHighlighter});if(!o())return;this.highlighter=f}const d=this.setRenderOptionsOnWorkers(h,u);this.renderOptions=h,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(const f of this.themeSubscribers)f.onThemeChange();await d}catch(h){if(h instanceof m||!o())return;throw h}}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 s of this.workers){if(!s.initialized)throw console.log({managedWorker:s}),new Error("setRenderOptionsOnWorkers: Somehow we have an uninitialized worker");i.push(new Promise((r,n)=>{const a=this.generateRequestId(),o={type:"set-render-options",id:a,request:{type:"set-render-options",id:a,renderOptions:e,resolvedThemes:t},resolve:r,reject:n,requestStart:Date.now()};this.activeTaskById.set(a,o),s.pendingSetupRequestId=a,s.worker.postMessage(o.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);c(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)if(this.initialized===!1){const{lifecycleGeneration:t}=this,i=new Promise((s,r)=>{(async()=>{try{const n=T(this.renderOptions.theme);let a=[];if(S(n)?a=H(n):a=await W(n),!this.isCurrentLifecycle(t)){s();return}let o=[];if(z(e)?o=O(e):o=await F(e),!this.isCurrentLifecycle(t)){s();return}const[h]=await Promise.all([q({themes:n,langs:["text",...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(a,o)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),s();return}this.highlighter=h,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),s()}catch(n){if(n instanceof m||!this.isCurrentLifecycle(t)){s();return}this.initialized=!1,this.workersFailed=!0,this.cancelActiveWorkerTasks(),this.terminateWorkers(),this.activeTaskById.clear();for(const a of this.queuedTasks)this.rejectRenderTaskCallbacks(a,v(n));this.queueBroadcastStateChanges(),r(n)}})()});return this.initialized=i,this.queueBroadcastStateChanges(),i}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;const i=[],s=void 0;this.workers.length>0&&this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){const o=this.options.workerFactory(),h={worker:o,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set(["text",...t.map(({name:l})=>l)]),customExtensionsVersion:0};o.addEventListener("message",l=>{this.handleWorkerMessage(h,l.data)}),o.addEventListener("error",l=>this.handleWorkerError(h,l)),this.workers.push(h),i.push(new Promise((l,u)=>{const d=this.generateRequestId(),f={type:"initialize",id:d,request:{type:"initialize",id:d,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:void 0,customExtensionMap:s},resolve(){h.initialized=!0,l()},reject:u,requestStart:Date.now()};h.pendingSetupRequestId=d,this.activeTaskById.set(d,f),this.executeTask(h,f)}))}const r=this.options.workerInitializationTimeout??Y;let n;try{await Promise.race([Promise.all(i),new Promise((a,o)=>{n=setTimeout(()=>{o(new Error(`WorkerPoolManager: worker initialization timed out after ${r}ms`))},r)})])}finally{n!=null&&clearTimeout(n)}}handleWorkerError(e,t){const{onWorkerError:i}=this.options;if(i!=null)try{i(t,e.worker)}catch(a){console.error("WorkerPoolManager: onWorkerError threw:",a)}else console.error("Worker error:",t,e);const{pendingSetupRequestId:s}=e;if(s==null)return;const r=this.activeTaskById.get(s);if(r?.type!=="initialize")return;const n=se(t);i!=null&&j(n),r.reject(n),this.cleanWorkerAndTask(e,r)}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=ie(t),s=this.getAvailableWorker(i);if(s==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,s),this.resolveLanguagesAndExecuteTask(s,t,i)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){const i=this.getFileResultCache(t);b(t)||i!=null&&C(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"));const t=this.getOrCreateFileHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateFileHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}const t=this.getFileResultCache(e),i=this.getFileHighlightKey(e);if(i==null||b(e)||t!=null&&C(t.options,this.getFileRenderOptions()))return;const s=this.getTaskByHighlightKey(i);if(s!=null)return s.primeCache=!0,s.type==="file"?s:void 0;{const r=this.submitCacheTask({type:"file",file:e},i);return r.type==="file"?r:void 0}}getPlainFileAST(e,t,i,s){if(this.highlighter==null){this.queueInitialization();return}return G(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,lines:s})}highlightDiffAST(e,t){const i=this.getDiffResultCache(t);E(t)||i!=null&&k(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"));const t=this.getOrCreateDiffHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateDiffHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}const t=this.getDiffResultCache(e),i=this.getDiffHighlightKey(e);if(i==null||E(e)||t!=null&&k(t.options,this.getDiffRenderOptions()))return;const s=this.getTaskByHighlightKey(i);if(s!=null)return s.primeCache=!0,s.type==="diff"?s:void 0;{const r=this.submitCacheTask({type:"diff",diff:e},i);return r.type==="diff"?r:void 0}}getPlainDiffAST(e,t,i,s,r){return this.highlighter!=null?Z(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,expandedHunks:s,collapsedContextThreshold:r}):void 0}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();const e=new m;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.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch(t=>{_(t)||console.error(t)})}cancelActiveWorkerTasks(){const e=new m;for(const t of this.activeTaskById.values())"reject"in t?t.reject(e):c(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),s=i!=null?this.getTaskByHighlightKey(i):void 0;if(s!=null){this.detachInstanceFromQueuedTasks(e,s),this.addInstanceToTask(s,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);const r=this.generateRequestId(),n=Date.now(),{renderOptionsVersion:a}=this,o=(()=>{switch(t.type){case"file":return{type:"file",id:r,request:{...t,id:r},instances:new Set([e]),primeCache:!1,highlightKey:i,callbacks:new Set,renderOptionsVersion:a,requestStart:n};case"diff":return{type:"diff",id:r,request:{...t,id:r},instances:new Set([e]),primeCache:!1,highlightKey:i,callbacks:new Set,renderOptionsVersion:a,requestStart:n}}})();this.enqueueRenderTask(o,e)}submitCacheTask(e,t){this.initialized===!1&&this.queueInitialization();const i=this.generateRequestId(),s=Date.now(),{renderOptionsVersion:r}=this,n=(()=>{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:r,requestStart:s};case"diff":return{type:"diff",id:i,request:{...e,id:i},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:r,requestStart:s}}})();return this.enqueueRenderTask(n),n}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 s=i.filter(n=>!Q(n));s.length>0&&q({themes:T(this.renderOptions.theme),langs:["text",...s],preferredHighlighter:this.preferredHighlighter}).catch(n=>{console.error(n)});const r=i.filter(n=>!e.langs.has(n));if(r.length>0&&(z(r)?t.request.resolvedLanguages=O(r):t.request.resolvedLanguages=await F(r)),!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(s){this.rejectRenderTaskCallbacks(t,v(s)),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 y;if(t.type==="error"){const s=new Error(t.error);if(t.stack&&(s.stack=t.stack),"reject"in i)i.reject(s);else if(c(i))this.notifyHighlightError(i,s),this.rejectRenderTaskCallbacks(i,s);else throw new Error("handleWorkerMessage: unknown task type");throw s}else{if(c(i))for(const{name:s}of i.request.resolvedLanguages??[])e.langs.add(s);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{result:s,options:r}=t;if(!this.isCurrentRenderTask(i)||!C(r,this.getFileRenderOptions()))throw y;const{request:n}=i;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{result:s,options:r}=t;if(!this.isCurrentRenderTask(i)||!k(r,this.getDiffRenderOptions()))throw y;const{request:n}=i;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(s){s!==y&&console.error(s,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,c(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&&(c(t)&&(this.rejectRenderTaskCallbacks(t,new R),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){te(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),c(t)?(this.notifyHighlightError(t,i),this.rejectRenderTaskCallbacks(t,v(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=$();e.customExtensionsVersion>=i||(t.customExtensionsVersion=i,t.customExtensionMap=N())}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 s=!0;for(const r of e)if(!i.langs.has(r)){s=!1;break}if(s)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 g(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()))c(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(const t of g(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 g(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(const t of g(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,i){for(const s of e.instances)this.activeRequestByInstance.get(s)===e.id&&s.onHighlightSuccess(e.request.file,t,i)}notifyDiffInstances(e,t,i){for(const s of e.instances)this.activeRequestByInstance.get(s)===e.id&&s.onHighlightSuccess(e.request.diff,t,i)}notifyHighlightError(e,t){for(const i of g(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)&&J(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)&&X(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())c(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function te(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function ie(e){const t=new Set;if(e.type==="initialize"||e.type==="set-render-options")return[];switch(e.type){case"file":t.add(e.request.file.lang??w(e.request.file.name));break;case"diff":t.add(e.request.diff.lang??w(e.request.diff.name)),t.add(e.request.diff.lang??w(e.request.diff.prevName??"-"))}return t.delete("text"),Array.from(t)}function c(e){return e?.type==="file"||e?.type==="diff"}function g(e){return e.instances}function v(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 se(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 U(`WorkerPoolManager: worker failed: ${i}`,t instanceof Error?{cause:t}:void 0)}let p;function hi({poolOptions:e,highlighterOptions:t}){return p??=new ee(e,t),p}function li(){p!=null&&(p.terminate(),p=void 0)}export{ee as WorkerPoolManager,R as WorkerPoolTaskCanceledError,m as WorkerPoolTerminatedError,U as WorkerPoolWorkerError,hi as getOrCreateWorkerPoolSingleton,_ as isHandledWorkerPoolError,di as isWorkerPoolCancellation,li as terminateWorkerPoolSingleton};
1
+ import{R as D,h as x,r as L,p as P,v as A,i as T,a as M,j as V,k as q,W as m,m as j,l as _,n as Q,o as R,q as N,s as $,t as U,g as w}from"./computeVirtualFileMetrics-rZJ-MSfY.js";import{u as di}from"./computeVirtualFileMetrics-rZJ-MSfY.js";import{et as I}from"./useAppFontEffects-d9vsRNKm.js";import{h as S,i as b,a as C,r as G}from"./isFilePlainText-BQGSJxcX.js";import{b as k,i as E,r as Z,c as J,a as X}from"./isDiffPlainText-DMFSMXcK.js";import{t as K}from"./themeResolver-yJ9XpNMI.js";import{L as B}from"./vendor-lru_map-Tstukz9J.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./vendor-react-BUCujlKS.js";import"./vendor-scheduler-7OC5HNn7.js";import"./katex.min-u4DtE8E5.js";import"./vendor-zod-DDir2TeQ.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-h8RufjAw.js";import"./vendor-base-ui-CPKyhvxM.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-tanstack-react-virtual-Bmi0tTrf.js";import"./vendor-tanstack-virtual-core-CdGDGrnp.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-dar6chwA.js";import"./vendor-codemirror-state-Dek9sMtw.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-B66jUSmE.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-language-DyL0aCoH.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-streamparser-CmlTsbN2.js";import"./vendor-codemirror-lang-javascript-Cem6LjJ8.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-CIqXJolH.js";import"./vendor-codemirror-lang-json-C9rLLO0q.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-9qjxcVkg.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-D7VQUxeE.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-Cikh4w2I.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DP_Bh3S8.js";import"./vendor-codemirror-lang-python-DVl8-2Op.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-D2O6oUGf.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-diff-C3JhlQdm.js";function O(e){const t=[];for(const i of e){const s=D.get(i);if(s==null)throw new Error(`getResolvedLanguages: ${i} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(s)}return t}function z(e){for(const t of Array.isArray(e)?e:[e])if(!D.has(t))return!1;return!0}async function F(e){const t=[],i=[];for(const s of e){if(s==="text"||s==="ansi")continue;const r=x(s)??L(s);"then"in r?i.push(r):t.push(r)}return i.length>0&&await Promise.all(i).then(s=>{for(const r of s){if(r==null)throw new Error("resolvedLanguages: unable to resolve language");t.push(r)}}),t}function H(e){return K.getResolvedThemes(e)}async function W(e){for(const i of e)P(i);const t=await K.resolveThemes(e);for(let i=0;i<e.length;i++)A(e[i],t[i]);return t}const y=Symbol("IGNORE_RESPONSE"),Y=1e4;var ee=class{options;highlighter;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;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:i=I,useTokenTransformer:s=!1,lineDiffType:r="word-alt",maxLineDiffLength:n=1e3,tokenizeMaxLineLength:a=1e3,preferredHighlighter:o="shiki-js"}){this.options=e,this.preferredHighlighter=o,this.renderOptions={theme:i,useTokenTransformer:s,lineDiffType:r,maxLineDiffLength:n,tokenizeMaxLineLength:a},this.fileCache=new B.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new B.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}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}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??I,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:i=this.renderOptions.lineDiffType??"word-alt",maxLineDiffLength:s=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:r=this.renderOptions.tokenizeMaxLineLength??1e3}){const{lifecycleGeneration:n}=this,a=++this.renderOptionsRequestVersion,o=()=>this.isCurrentLifecycle(n)&&this.renderOptionsRequestVersion===a;try{const h={theme:e,useTokenTransformer:t,lineDiffType:i,maxLineDiffLength:s,tokenizeMaxLineLength:r};if(this.isInitialized()||await this.initialize(),!o()||k(h,this.renderOptions))return;const l=T(e);let u=[];if(M(h.theme,this.renderOptions.theme)||(S(l)?u=H(l):u=await W(l)),!o())return;if(this.highlighter!=null)V(u,this.highlighter);else{const f=await q({themes:l,langs:["text"],preferredHighlighter:this.preferredHighlighter});if(!o())return;this.highlighter=f}const d=this.setRenderOptionsOnWorkers(h,u);this.renderOptions=h,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(const f of this.themeSubscribers)f.onThemeChange();await d}catch(h){if(h instanceof m||!o())return;throw h}}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 s of this.workers){if(!s.initialized)throw console.log({managedWorker:s}),new Error("setRenderOptionsOnWorkers: Somehow we have an uninitialized worker");i.push(new Promise((r,n)=>{const a=this.generateRequestId(),o={type:"set-render-options",id:a,request:{type:"set-render-options",id:a,renderOptions:e,resolvedThemes:t},resolve:r,reject:n,requestStart:Date.now()};this.activeTaskById.set(a,o),s.pendingSetupRequestId=a,s.worker.postMessage(o.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);c(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)if(this.initialized===!1){const{lifecycleGeneration:t}=this,i=new Promise((s,r)=>{(async()=>{try{const n=T(this.renderOptions.theme);let a=[];if(S(n)?a=H(n):a=await W(n),!this.isCurrentLifecycle(t)){s();return}let o=[];if(z(e)?o=O(e):o=await F(e),!this.isCurrentLifecycle(t)){s();return}const[h]=await Promise.all([q({themes:n,langs:["text",...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(a,o)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),s();return}this.highlighter=h,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),s()}catch(n){if(n instanceof m||!this.isCurrentLifecycle(t)){s();return}this.initialized=!1,this.workersFailed=!0,this.cancelActiveWorkerTasks(),this.terminateWorkers(),this.activeTaskById.clear();for(const a of this.queuedTasks)this.rejectRenderTaskCallbacks(a,v(n));this.queueBroadcastStateChanges(),r(n)}})()});return this.initialized=i,this.queueBroadcastStateChanges(),i}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;const i=[],s=void 0;this.workers.length>0&&this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){const o=this.options.workerFactory(),h={worker:o,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set(["text",...t.map(({name:l})=>l)]),customExtensionsVersion:0};o.addEventListener("message",l=>{this.handleWorkerMessage(h,l.data)}),o.addEventListener("error",l=>this.handleWorkerError(h,l)),this.workers.push(h),i.push(new Promise((l,u)=>{const d=this.generateRequestId(),f={type:"initialize",id:d,request:{type:"initialize",id:d,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:void 0,customExtensionMap:s},resolve(){h.initialized=!0,l()},reject:u,requestStart:Date.now()};h.pendingSetupRequestId=d,this.activeTaskById.set(d,f),this.executeTask(h,f)}))}const r=this.options.workerInitializationTimeout??Y;let n;try{await Promise.race([Promise.all(i),new Promise((a,o)=>{n=setTimeout(()=>{o(new Error(`WorkerPoolManager: worker initialization timed out after ${r}ms`))},r)})])}finally{n!=null&&clearTimeout(n)}}handleWorkerError(e,t){const{onWorkerError:i}=this.options;if(i!=null)try{i(t,e.worker)}catch(a){console.error("WorkerPoolManager: onWorkerError threw:",a)}else console.error("Worker error:",t,e);const{pendingSetupRequestId:s}=e;if(s==null)return;const r=this.activeTaskById.get(s);if(r?.type!=="initialize")return;const n=se(t);i!=null&&j(n),r.reject(n),this.cleanWorkerAndTask(e,r)}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=ie(t),s=this.getAvailableWorker(i);if(s==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,s),this.resolveLanguagesAndExecuteTask(s,t,i)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){const i=this.getFileResultCache(t);b(t)||i!=null&&C(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"));const t=this.getOrCreateFileHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateFileHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}const t=this.getFileResultCache(e),i=this.getFileHighlightKey(e);if(i==null||b(e)||t!=null&&C(t.options,this.getFileRenderOptions()))return;const s=this.getTaskByHighlightKey(i);if(s!=null)return s.primeCache=!0,s.type==="file"?s:void 0;{const r=this.submitCacheTask({type:"file",file:e},i);return r.type==="file"?r:void 0}}getPlainFileAST(e,t,i,s){if(this.highlighter==null){this.queueInitialization();return}return G(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,lines:s})}highlightDiffAST(e,t){const i=this.getDiffResultCache(t);E(t)||i!=null&&k(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"));const t=this.getOrCreateDiffHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateDiffHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}const t=this.getDiffResultCache(e),i=this.getDiffHighlightKey(e);if(i==null||E(e)||t!=null&&k(t.options,this.getDiffRenderOptions()))return;const s=this.getTaskByHighlightKey(i);if(s!=null)return s.primeCache=!0,s.type==="diff"?s:void 0;{const r=this.submitCacheTask({type:"diff",diff:e},i);return r.type==="diff"?r:void 0}}getPlainDiffAST(e,t,i,s,r){return this.highlighter!=null?Z(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,expandedHunks:s,collapsedContextThreshold:r}):void 0}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();const e=new m;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.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch(t=>{_(t)||console.error(t)})}cancelActiveWorkerTasks(){const e=new m;for(const t of this.activeTaskById.values())"reject"in t?t.reject(e):c(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),s=i!=null?this.getTaskByHighlightKey(i):void 0;if(s!=null){this.detachInstanceFromQueuedTasks(e,s),this.addInstanceToTask(s,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);const r=this.generateRequestId(),n=Date.now(),{renderOptionsVersion:a}=this,o=(()=>{switch(t.type){case"file":return{type:"file",id:r,request:{...t,id:r},instances:new Set([e]),primeCache:!1,highlightKey:i,callbacks:new Set,renderOptionsVersion:a,requestStart:n};case"diff":return{type:"diff",id:r,request:{...t,id:r},instances:new Set([e]),primeCache:!1,highlightKey:i,callbacks:new Set,renderOptionsVersion:a,requestStart:n}}})();this.enqueueRenderTask(o,e)}submitCacheTask(e,t){this.initialized===!1&&this.queueInitialization();const i=this.generateRequestId(),s=Date.now(),{renderOptionsVersion:r}=this,n=(()=>{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:r,requestStart:s};case"diff":return{type:"diff",id:i,request:{...e,id:i},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:r,requestStart:s}}})();return this.enqueueRenderTask(n),n}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 s=i.filter(n=>!Q(n));s.length>0&&q({themes:T(this.renderOptions.theme),langs:["text",...s],preferredHighlighter:this.preferredHighlighter}).catch(n=>{console.error(n)});const r=i.filter(n=>!e.langs.has(n));if(r.length>0&&(z(r)?t.request.resolvedLanguages=O(r):t.request.resolvedLanguages=await F(r)),!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(s){this.rejectRenderTaskCallbacks(t,v(s)),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 y;if(t.type==="error"){const s=new Error(t.error);if(t.stack&&(s.stack=t.stack),"reject"in i)i.reject(s);else if(c(i))this.notifyHighlightError(i,s),this.rejectRenderTaskCallbacks(i,s);else throw new Error("handleWorkerMessage: unknown task type");throw s}else{if(c(i))for(const{name:s}of i.request.resolvedLanguages??[])e.langs.add(s);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{result:s,options:r}=t;if(!this.isCurrentRenderTask(i)||!C(r,this.getFileRenderOptions()))throw y;const{request:n}=i;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{result:s,options:r}=t;if(!this.isCurrentRenderTask(i)||!k(r,this.getDiffRenderOptions()))throw y;const{request:n}=i;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(s){s!==y&&console.error(s,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,c(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&&(c(t)&&(this.rejectRenderTaskCallbacks(t,new R),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){te(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),c(t)?(this.notifyHighlightError(t,i),this.rejectRenderTaskCallbacks(t,v(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=$();e.customExtensionsVersion>=i||(t.customExtensionsVersion=i,t.customExtensionMap=N())}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 s=!0;for(const r of e)if(!i.langs.has(r)){s=!1;break}if(s)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 g(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()))c(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(const t of g(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 g(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(const t of g(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,i){for(const s of e.instances)this.activeRequestByInstance.get(s)===e.id&&s.onHighlightSuccess(e.request.file,t,i)}notifyDiffInstances(e,t,i){for(const s of e.instances)this.activeRequestByInstance.get(s)===e.id&&s.onHighlightSuccess(e.request.diff,t,i)}notifyHighlightError(e,t){for(const i of g(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)&&J(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)&&X(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())c(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function te(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function ie(e){const t=new Set;if(e.type==="initialize"||e.type==="set-render-options")return[];switch(e.type){case"file":t.add(e.request.file.lang??w(e.request.file.name));break;case"diff":t.add(e.request.diff.lang??w(e.request.diff.name)),t.add(e.request.diff.lang??w(e.request.diff.prevName??"-"))}return t.delete("text"),Array.from(t)}function c(e){return e?.type==="file"||e?.type==="diff"}function g(e){return e.instances}function v(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 se(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 U(`WorkerPoolManager: worker failed: ${i}`,t instanceof Error?{cause:t}:void 0)}let p;function hi({poolOptions:e,highlighterOptions:t}){return p??=new ee(e,t),p}function li(){p!=null&&(p.terminate(),p=void 0)}export{ee as WorkerPoolManager,R as WorkerPoolTaskCanceledError,m as WorkerPoolTerminatedError,U as WorkerPoolWorkerError,hi as getOrCreateWorkerPoolSingleton,_ as isHandledWorkerPoolError,di as isWorkerPoolCancellation,li as terminateWorkerPoolSingleton};
@@ -1 +1 @@
1
- import{a as i,s as t,b as s,c as o}from"./useAppFontEffects-BZrjCfFw.js";import"./vendor-react-BUCujlKS.js";import{i as n,a as c,s as p}from"./katex.min-u4DtE8E5.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
+ import{a as i,s as t,b as s,c as o}from"./useAppFontEffects-d9vsRNKm.js";import"./vendor-react-BUCujlKS.js";import{i as n,a as c,s as p}from"./katex.min-u4DtE8E5.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 re,R as k,j as s}from"./vendor-react-BUCujlKS.js";import{t as D,a5 as ne,k as z}from"./katex.min-u4DtE8E5.js";import{u as H,B as C,cx as U,cc as ie,ca as oe,eu as ce,c9 as le,cb as de,c3 as Y,y as O,z as $,N as ue,aA as pe,A as L,bl as ge,ev as he,ew as me}from"./useAppFontEffects-BZrjCfFw.js";import{o as fe,s as B,_ as ye}from"./vendor-zod-DDir2TeQ.js";const ve=t=>t.toLowerCase().replace(/[^a-z0-9_-]/g,"-"),Me=t=>ve(t.trim()).replace(/^[-_]+|[-_]+$/g,""),J={oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:""},Ue=t=>t===!1?{...J,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)}:J,xe=(t,e)=>!!e&&t!=="claude-code",ke=/[A-Z0-9]{4}-[A-Z0-9]{4,5}/,be=t=>ke.exec(t)?.[0]??void 0,P=t=>t.type!=="external",A=t=>t.title??t.key,Ce=(t,e)=>{if(e===void 0)return!1;const a=String(e),n=String(t.value);return t.op==="eq"?a===n:a!==n},je=(t,e)=>P(t)?(t.when??[]).every(a=>Ce(a,e[a.key])):!0,V=(t,e)=>{const a={},n=[];for(const c of t){if(!je(c,a))continue;n.push(c);const m=e[c.key];P(c)&&m!==void 0&&(a[c.key]=m)}return n},we=t=>{const e={};for(const a of t)switch(a.type){case"external":break;case"boolean":e[a.key]=a.default??!1;break;case"number":case"integer":typeof a.default=="number"&&(e[a.key]=a.default);break;case"multiselect":e[a.key]=a.default??[];break;case"string":e[a.key]=a.default??a.options?.[0]?.value??"";break}return e},Q=t=>t===void 0?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:!1,Ne=(t,e)=>V(t,e).find(a=>P(a)&&a.required===!0&&Q(e[a.key]))??null,Se=(t,e)=>{const a={};for(const n of V(t,e)){if(!P(n))continue;const c=e[n.key];Q(c)||c===void 0||(a[n.key]=typeof c=="string"?c.trim():c)}return a},K=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),W=t=>typeof t=="string"&&t.length>0?t:void 0,Ie=(t,e,a)=>{const n=K(t)?t:{},c=K(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 W(c.message)??e("settings.providers.page.auth.oauth.error.invalidInput");default:return W(n.message)??e(a)}},_="\0typed",Ae=t=>{const e=re.c(12),{fields:a,values:n,onChange:c}=t,{t:m}=H();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=new Set,e[0]=l):l=e[0];const[f,o]=k.useState(l);let g;e[1]!==c||e[2]!==m||e[3]!==f||e[4]!==n?(g=d=>{if(d.type==="external")return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:A(d)}),s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{U(d.url)},children:m("settings.providers.page.actions.open")})]},d.key);const y=n[d.key],j=typeof y=="string"?y:"",w=h=>c(d.key,h),T=d.type==="string"||d.type==="multiselect"?d.options??[]:[],E=d.type==="string"&&d.custom===!0,S=E&&f.has(d.key),N=h=>o(F=>{const I=new Set(F);return h?I.add(d.key):I.delete(d.key),I});return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:A(d)}),d.description&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:d.description}),T.length>0?s.jsxs(s.Fragment,{children:[s.jsxs(ie,{value:S?_:j,onValueChange:h=>{if(h===_){N(!0),w("");return}N(!1),w(h)},children:[s.jsx(oe,{className:ce,children:s.jsx(le,{children:h=>h===_?m("settings.providers.page.auth.field.other"):T.find(F=>F.value===h)?.label??null})}),s.jsxs(de,{children:[T.map(Te),E?s.jsx(Y,{value:_,children:m("settings.providers.page.auth.field.other")}):null]})]}),S?s.jsx(O,{value:j,onChange:h=>w(h.target.value),placeholder:d.placeholder??m("settings.providers.page.auth.field.otherPlaceholder"),"aria-label":A(d),className:"max-w-[24rem] text-xs",autoFocus:!0}):null]}):d.type==="boolean"?s.jsx("input",{type:"checkbox",checked:y===!0,onChange:h=>w(h.target.checked),"aria-label":A(d)}):s.jsx(O,{value:j,onChange:h=>w(h.target.value),placeholder:d.type==="string"?d.placeholder:void 0,"aria-label":A(d),className:"max-w-[24rem] text-xs"})]},d.key)},e[1]=c,e[2]=m,e[3]=f,e[4]=n,e[5]=g):g=e[5];const x=g;let v;e[6]!==a||e[7]!==x||e[8]!==n?(v=V(a,n).map(x),e[6]=a,e[7]=x,e[8]=n,e[9]=v):v=e[9];let b;return e[10]!==v?(b=s.jsx(s.Fragment,{children:v}),e[10]=v,e[11]=b):b=e[11],b};function Te(t){return s.jsx(Y,{value:t.value,children:t.description?`${t.label} · ${t.description}`:t.label},t.value)}const M={phase:"idle"},Ee=1500,Fe=({integrationId:t,methods:e,onConnected:a,directory:n,className:c,autoStart:m=!1})=>{const{t:l}=H(),f=k.useCallback(()=>n?D.getScopedSdkClient(n):D.getSdkClient(),[n]),[o,g]=k.useState(M),[x,v]=k.useState({}),[b,d]=k.useState(""),y=k.useRef(null),j=k.useCallback(r=>{y.current=null,f().integration.oauth.cancel({integrationID:t,attemptID:r}).catch(()=>{})},[t,f]);k.useEffect(()=>()=>{const r=y.current;r&&j(r)},[j]);const w=o.phase==="idle"?null:o.methodID,T=o.phase==="connecting"||o.phase==="waiting"||o.phase==="awaitingCode"&&o.submitting,E=async(r,i,u)=>{const p=await pe(r);if(p.ok){L.success(l(i));return}console.error("Failed to copy OAuth value:",p.error),L.error(l(u))},S=async(r="settings.providers.page.toast.oauthCompleted")=>{y.current=null,g(M),L.success(l(r)),await a()},N=(r,i,u)=>{y.current=null,console.error("OAuth flow failed:",i),g({phase:"failed",methodID:r,message:Ie(i,l,u)})},h=async(r,i)=>{const u=f();for(;y.current===i;){if(await new Promise(p=>setTimeout(p,Ee)),y.current!==i)return;try{const{data:p}=await u.integration.oauth.status({integrationID:t,attemptID:i});if(y.current!==i)return;if(p.status==="complete"){await S();return}if(p.status==="failed"){g({phase:"failed",methodID:r,message:p.message}),y.current=null;return}}catch(p){if(y.current!==i)return;N(r,p,"settings.providers.page.toast.oauthCompleteFailed");return}}},F=async(r,i)=>{g({phase:"connecting",methodID:r});try{await f().integration.connect.external({integrationID:t,methodID:r,answer:Object.keys(i).length>0?i:void 0})}catch(u){N(r,u,"settings.providers.page.toast.externalConnectFailed");return}await S("settings.providers.page.toast.externalConnected")},I=async(r,i)=>{if(r.type==="external"){await F(r.id,i);return}g({phase:"connecting",methodID:r.id});let u;try{const{data:p}=await f().integration.oauth.connect({integrationID:t,methodID:r.id,...Object.keys(i).length>0?{answer:i}:{}});u={attemptID:p.attemptID,mode:p.mode,url:p.url,instructions:p.instructions}}catch(p){N(r.id,p,"settings.providers.page.toast.oauthStartFailed");return}if(y.current=u.attemptID,xe(t,u.url)&&U(u.url),u.mode==="code"){d(""),g({phase:"awaitingCode",methodID:r.id,attempt:u,submitting:!1});return}g({phase:"waiting",methodID:r.id,attempt:u}),await h(r.id,u.attemptID)},R=r=>{const i=(r.form??[]).filter(P);if(i.length===0){I(r,{});return}v(we(i)),g({phase:"prompting",methodID:r.id,fields:i,error:null})},G=k.useRef(!1);k.useEffect(()=>{!m||G.current||e.length!==1||(G.current=!0,R(e[0]))},[m,e]);const te=r=>{if(o.phase!=="prompting")return;const i=Ne(o.fields,x);if(i){g({...o,error:l("settings.providers.page.auth.oauth.promptRequired",{field:A(i)})});return}I(r,Se(o.fields,x))},se=async()=>{if(o.phase!=="awaitingCode")return;const r=b.trim();if(!r)return;const{methodID:i,attempt:u}=o;g({...o,submitting:!0});try{await f().integration.oauth.complete({integrationID:t,attemptID:u.attemptID,code:r}),await S()}catch(p){N(i,p,"settings.providers.page.toast.oauthCompleteFailed")}},q=()=>{(o.phase==="waiting"||o.phase==="awaitingCode")&&j(o.attempt.attemptID),g(M)},Z=r=>{const i=be(r.instructions);return s.jsxs(s.Fragment,{children:[r.instructions&&s.jsx("p",{className:"typography-meta text-[var(--status-info-text)] bg-[var(--status-info-background)] px-2 py-1.5 rounded",children:r.instructions}),i&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(O,{value:i,readOnly:!0,"aria-label":l("settings.providers.page.auth.oauth.deviceCodeLabel"),className:"font-mono text-center tracking-widest"}),s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>{E(i,"settings.providers.page.toast.deviceCodeCopied","settings.providers.page.toast.deviceCodeCopyFailed")},children:l("settings.providers.page.actions.copyCode")})]}),r.url&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(O,{value:r.url,readOnly:!0,"aria-label":l("settings.providers.page.auth.oauth.linkLabel"),className:"text-xs text-muted-foreground"}),s.jsxs("div",{className:"flex gap-1 shrink-0",children:[s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{U(r.url)},children:l("settings.providers.page.actions.open")}),s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{E(r.url,"settings.providers.page.toast.oauthLinkCopied","settings.providers.page.toast.oauthLinkCopyFailed")},children:l("settings.providers.page.actions.copy")})]})]})]})};return s.jsx("div",{className:ue("space-y-4",c),children:e.map(r=>{const i=w===r.id;return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:r.label}),s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>R(r),disabled:T,children:l("settings.providers.page.actions.connect")})]}),i&&o.phase==="prompting"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(Ae,{fields:o.fields,values:x,onChange:(u,p)=>v(ae=>({...ae,[u]:p}))}),o.error&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:o.error}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(C,{size:"xs",className:"!font-normal",onClick:()=>te(r),children:l("settings.providers.page.actions.continue")}),s.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal",onClick:q,children:l("settings.providers.page.actions.cancel")})]})]}),i&&o.phase==="connecting"&&s.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[s.jsx($,{className:"h-3.5 w-3.5"}),r.type==="external"?l("settings.providers.page.auth.external.connecting"):l("settings.providers.page.auth.oauth.starting")]}),i&&o.phase==="waiting"&&s.jsxs("div",{className:"space-y-3",children:[Z(o.attempt),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[s.jsx($,{className:"h-3.5 w-3.5"}),l("settings.providers.page.auth.oauth.waiting")]}),s.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:q,children:l("settings.providers.page.actions.cancel")})]}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:l("settings.providers.page.auth.oauth.waitingHint")})]}),i&&o.phase==="awaitingCode"&&s.jsxs("div",{className:"space-y-3",children:[Z(o.attempt),s.jsx("p",{className:"typography-meta text-muted-foreground",children:l("settings.providers.page.auth.oauth.codeHint")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(O,{value:b,onChange:u=>d(u.target.value),placeholder:l("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs",disabled:o.submitting}),s.jsx(C,{size:"xs",className:"!font-normal shrink-0",onClick:()=>{se()},disabled:o.submitting||b.trim().length===0,children:o.submitting?l("settings.providers.page.actions.saving"):l("settings.providers.page.actions.complete")}),s.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:q,disabled:o.submitting,children:l("settings.providers.page.actions.cancel")})]})]}),i&&o.phase==="failed"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:o.message}),s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>R(r),children:l("settings.providers.page.actions.tryAgain")})]})]},r.id)})})},Oe=(t,e)=>t.find(a=>a.id.startsWith("mcp_")&&a.metadata?.source==="mcp"&&a.name===e),ze=t=>(t?.methods??[]).filter(e=>e.type==="oauth"),Ve=({serverName:t,directory:e,onConnected:a,autoStart:n})=>{const[c,m]=k.useState(null);k.useEffect(()=>{let f=!1;m(null);const o=e?D.getScopedSdkClient(e):D.getSdkClient(),g=async(x=0)=>{try{const{data:v}=await o.integration.list();if(f)return;const b=Oe(v,t)??null;if(b){m(b);return}x<8&&setTimeout(()=>{g(x+1)},750)}catch(v){if(f)return;console.error("Failed to load MCP integrations:",v),x<8&&setTimeout(()=>{g(x+1)},750)}};return g(),()=>{f=!0}},[e,t]);const l=ze(c??void 0);return!c||l.length===0?null:s.jsx(Fe,{integrationId:c.id,methods:l,directory:e,onConnected:a,autoStart:n},c.id)},Pe=fe({error:ye(["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:B().trim().min(1).max(64).optional(),id:B().trim().min(1).max(128).optional()}),_e=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 a=/^[a-zA-Z]:[\\/]/.test(e);return/^[a-z][a-z0-9+.-]*:/i.test(e)&&!a?{ok:!1,code:"invalid-url"}:e.startsWith("/")||a||e.startsWith("\\\\")?{ok:!0,request:{path:e}}:{ok:!1,code:"invalid-path"}},X=async t=>{try{const e=Pe.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"}}},ee=async(t,e)=>{if(!t.ok)return{ok:!1,...await X(t),diagnostic:{method:"POST",path:e,kind:"http",status:t.status}};const a=await t.text().catch(()=>null),n=a===null?null:me(a);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}}},Ge=async(t,e={})=>{const a=_e(t);if(!a.ok)return a;const n={...a.request};e.replace&&(n.replace=!0),"url"in n&&e.gitIdentityId&&(n.gitIdentityId=e.gitIdentityId);try{const c=await z("/api/guests",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});return await ee(c,"/api/guests")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests",kind:"network"}}}},Ze=async(t,e={})=>{try{const a=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 ee(a,"/api/guests/upload")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests/upload",kind:"network"}}}},$e=async t=>{const e=ge.getState(),a=ne(),n=e.runtimeKey===a?e.guests.find(c=>c.id===t)?.storageId:void 0;try{const c=await z(`/api/guests/${t}`,{method:"DELETE"});return c.status===204?(n&&globalThis.indexedDB&&await he({runtimeKey:a,guestId:t,storageId:n}).catch(()=>{console.warn("Could not clear local extension preferences.")}),{ok:!0}):{ok:!1,code:(await X(c)).code}}catch{return{ok:!1,code:"failed"}}},Be=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}},Je=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{J as M,Ae as P,Ve as a,ve as b,P as c,we as d,A as e,Ne as f,Se as g,Fe as h,Ge as i,Ze as j,Je as k,Me as n,Ue as r,Be as s,$e as u};
1
+ import{f as re,R as k,j as s}from"./vendor-react-BUCujlKS.js";import{t as D,a5 as ne,k as z}from"./katex.min-u4DtE8E5.js";import{u as H,B as C,cx as U,cc as ie,ca as oe,eu as ce,c9 as le,cb as de,c3 as Y,y as O,z as $,N as ue,aA as pe,A as L,bl as ge,ev as he,ew as me}from"./useAppFontEffects-d9vsRNKm.js";import{o as fe,s as B,_ as ye}from"./vendor-zod-DDir2TeQ.js";const ve=t=>t.toLowerCase().replace(/[^a-z0-9_-]/g,"-"),Me=t=>ve(t.trim()).replace(/^[-_]+|[-_]+$/g,""),J={oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:""},Ue=t=>t===!1?{...J,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)}:J,xe=(t,e)=>!!e&&t!=="claude-code",ke=/[A-Z0-9]{4}-[A-Z0-9]{4,5}/,be=t=>ke.exec(t)?.[0]??void 0,P=t=>t.type!=="external",A=t=>t.title??t.key,Ce=(t,e)=>{if(e===void 0)return!1;const a=String(e),n=String(t.value);return t.op==="eq"?a===n:a!==n},je=(t,e)=>P(t)?(t.when??[]).every(a=>Ce(a,e[a.key])):!0,V=(t,e)=>{const a={},n=[];for(const c of t){if(!je(c,a))continue;n.push(c);const m=e[c.key];P(c)&&m!==void 0&&(a[c.key]=m)}return n},we=t=>{const e={};for(const a of t)switch(a.type){case"external":break;case"boolean":e[a.key]=a.default??!1;break;case"number":case"integer":typeof a.default=="number"&&(e[a.key]=a.default);break;case"multiselect":e[a.key]=a.default??[];break;case"string":e[a.key]=a.default??a.options?.[0]?.value??"";break}return e},Q=t=>t===void 0?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:!1,Ne=(t,e)=>V(t,e).find(a=>P(a)&&a.required===!0&&Q(e[a.key]))??null,Se=(t,e)=>{const a={};for(const n of V(t,e)){if(!P(n))continue;const c=e[n.key];Q(c)||c===void 0||(a[n.key]=typeof c=="string"?c.trim():c)}return a},K=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),W=t=>typeof t=="string"&&t.length>0?t:void 0,Ie=(t,e,a)=>{const n=K(t)?t:{},c=K(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 W(c.message)??e("settings.providers.page.auth.oauth.error.invalidInput");default:return W(n.message)??e(a)}},_="\0typed",Ae=t=>{const e=re.c(12),{fields:a,values:n,onChange:c}=t,{t:m}=H();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=new Set,e[0]=l):l=e[0];const[f,o]=k.useState(l);let g;e[1]!==c||e[2]!==m||e[3]!==f||e[4]!==n?(g=d=>{if(d.type==="external")return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:A(d)}),s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{U(d.url)},children:m("settings.providers.page.actions.open")})]},d.key);const y=n[d.key],j=typeof y=="string"?y:"",w=h=>c(d.key,h),T=d.type==="string"||d.type==="multiselect"?d.options??[]:[],E=d.type==="string"&&d.custom===!0,S=E&&f.has(d.key),N=h=>o(F=>{const I=new Set(F);return h?I.add(d.key):I.delete(d.key),I});return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:A(d)}),d.description&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:d.description}),T.length>0?s.jsxs(s.Fragment,{children:[s.jsxs(ie,{value:S?_:j,onValueChange:h=>{if(h===_){N(!0),w("");return}N(!1),w(h)},children:[s.jsx(oe,{className:ce,children:s.jsx(le,{children:h=>h===_?m("settings.providers.page.auth.field.other"):T.find(F=>F.value===h)?.label??null})}),s.jsxs(de,{children:[T.map(Te),E?s.jsx(Y,{value:_,children:m("settings.providers.page.auth.field.other")}):null]})]}),S?s.jsx(O,{value:j,onChange:h=>w(h.target.value),placeholder:d.placeholder??m("settings.providers.page.auth.field.otherPlaceholder"),"aria-label":A(d),className:"max-w-[24rem] text-xs",autoFocus:!0}):null]}):d.type==="boolean"?s.jsx("input",{type:"checkbox",checked:y===!0,onChange:h=>w(h.target.checked),"aria-label":A(d)}):s.jsx(O,{value:j,onChange:h=>w(h.target.value),placeholder:d.type==="string"?d.placeholder:void 0,"aria-label":A(d),className:"max-w-[24rem] text-xs"})]},d.key)},e[1]=c,e[2]=m,e[3]=f,e[4]=n,e[5]=g):g=e[5];const x=g;let v;e[6]!==a||e[7]!==x||e[8]!==n?(v=V(a,n).map(x),e[6]=a,e[7]=x,e[8]=n,e[9]=v):v=e[9];let b;return e[10]!==v?(b=s.jsx(s.Fragment,{children:v}),e[10]=v,e[11]=b):b=e[11],b};function Te(t){return s.jsx(Y,{value:t.value,children:t.description?`${t.label} · ${t.description}`:t.label},t.value)}const M={phase:"idle"},Ee=1500,Fe=({integrationId:t,methods:e,onConnected:a,directory:n,className:c,autoStart:m=!1})=>{const{t:l}=H(),f=k.useCallback(()=>n?D.getScopedSdkClient(n):D.getSdkClient(),[n]),[o,g]=k.useState(M),[x,v]=k.useState({}),[b,d]=k.useState(""),y=k.useRef(null),j=k.useCallback(r=>{y.current=null,f().integration.oauth.cancel({integrationID:t,attemptID:r}).catch(()=>{})},[t,f]);k.useEffect(()=>()=>{const r=y.current;r&&j(r)},[j]);const w=o.phase==="idle"?null:o.methodID,T=o.phase==="connecting"||o.phase==="waiting"||o.phase==="awaitingCode"&&o.submitting,E=async(r,i,u)=>{const p=await pe(r);if(p.ok){L.success(l(i));return}console.error("Failed to copy OAuth value:",p.error),L.error(l(u))},S=async(r="settings.providers.page.toast.oauthCompleted")=>{y.current=null,g(M),L.success(l(r)),await a()},N=(r,i,u)=>{y.current=null,console.error("OAuth flow failed:",i),g({phase:"failed",methodID:r,message:Ie(i,l,u)})},h=async(r,i)=>{const u=f();for(;y.current===i;){if(await new Promise(p=>setTimeout(p,Ee)),y.current!==i)return;try{const{data:p}=await u.integration.oauth.status({integrationID:t,attemptID:i});if(y.current!==i)return;if(p.status==="complete"){await S();return}if(p.status==="failed"){g({phase:"failed",methodID:r,message:p.message}),y.current=null;return}}catch(p){if(y.current!==i)return;N(r,p,"settings.providers.page.toast.oauthCompleteFailed");return}}},F=async(r,i)=>{g({phase:"connecting",methodID:r});try{await f().integration.connect.external({integrationID:t,methodID:r,answer:Object.keys(i).length>0?i:void 0})}catch(u){N(r,u,"settings.providers.page.toast.externalConnectFailed");return}await S("settings.providers.page.toast.externalConnected")},I=async(r,i)=>{if(r.type==="external"){await F(r.id,i);return}g({phase:"connecting",methodID:r.id});let u;try{const{data:p}=await f().integration.oauth.connect({integrationID:t,methodID:r.id,...Object.keys(i).length>0?{answer:i}:{}});u={attemptID:p.attemptID,mode:p.mode,url:p.url,instructions:p.instructions}}catch(p){N(r.id,p,"settings.providers.page.toast.oauthStartFailed");return}if(y.current=u.attemptID,xe(t,u.url)&&U(u.url),u.mode==="code"){d(""),g({phase:"awaitingCode",methodID:r.id,attempt:u,submitting:!1});return}g({phase:"waiting",methodID:r.id,attempt:u}),await h(r.id,u.attemptID)},R=r=>{const i=(r.form??[]).filter(P);if(i.length===0){I(r,{});return}v(we(i)),g({phase:"prompting",methodID:r.id,fields:i,error:null})},G=k.useRef(!1);k.useEffect(()=>{!m||G.current||e.length!==1||(G.current=!0,R(e[0]))},[m,e]);const te=r=>{if(o.phase!=="prompting")return;const i=Ne(o.fields,x);if(i){g({...o,error:l("settings.providers.page.auth.oauth.promptRequired",{field:A(i)})});return}I(r,Se(o.fields,x))},se=async()=>{if(o.phase!=="awaitingCode")return;const r=b.trim();if(!r)return;const{methodID:i,attempt:u}=o;g({...o,submitting:!0});try{await f().integration.oauth.complete({integrationID:t,attemptID:u.attemptID,code:r}),await S()}catch(p){N(i,p,"settings.providers.page.toast.oauthCompleteFailed")}},q=()=>{(o.phase==="waiting"||o.phase==="awaitingCode")&&j(o.attempt.attemptID),g(M)},Z=r=>{const i=be(r.instructions);return s.jsxs(s.Fragment,{children:[r.instructions&&s.jsx("p",{className:"typography-meta text-[var(--status-info-text)] bg-[var(--status-info-background)] px-2 py-1.5 rounded",children:r.instructions}),i&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(O,{value:i,readOnly:!0,"aria-label":l("settings.providers.page.auth.oauth.deviceCodeLabel"),className:"font-mono text-center tracking-widest"}),s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>{E(i,"settings.providers.page.toast.deviceCodeCopied","settings.providers.page.toast.deviceCodeCopyFailed")},children:l("settings.providers.page.actions.copyCode")})]}),r.url&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(O,{value:r.url,readOnly:!0,"aria-label":l("settings.providers.page.auth.oauth.linkLabel"),className:"text-xs text-muted-foreground"}),s.jsxs("div",{className:"flex gap-1 shrink-0",children:[s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{U(r.url)},children:l("settings.providers.page.actions.open")}),s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{E(r.url,"settings.providers.page.toast.oauthLinkCopied","settings.providers.page.toast.oauthLinkCopyFailed")},children:l("settings.providers.page.actions.copy")})]})]})]})};return s.jsx("div",{className:ue("space-y-4",c),children:e.map(r=>{const i=w===r.id;return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:r.label}),s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>R(r),disabled:T,children:l("settings.providers.page.actions.connect")})]}),i&&o.phase==="prompting"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(Ae,{fields:o.fields,values:x,onChange:(u,p)=>v(ae=>({...ae,[u]:p}))}),o.error&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:o.error}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(C,{size:"xs",className:"!font-normal",onClick:()=>te(r),children:l("settings.providers.page.actions.continue")}),s.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal",onClick:q,children:l("settings.providers.page.actions.cancel")})]})]}),i&&o.phase==="connecting"&&s.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[s.jsx($,{className:"h-3.5 w-3.5"}),r.type==="external"?l("settings.providers.page.auth.external.connecting"):l("settings.providers.page.auth.oauth.starting")]}),i&&o.phase==="waiting"&&s.jsxs("div",{className:"space-y-3",children:[Z(o.attempt),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[s.jsx($,{className:"h-3.5 w-3.5"}),l("settings.providers.page.auth.oauth.waiting")]}),s.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:q,children:l("settings.providers.page.actions.cancel")})]}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:l("settings.providers.page.auth.oauth.waitingHint")})]}),i&&o.phase==="awaitingCode"&&s.jsxs("div",{className:"space-y-3",children:[Z(o.attempt),s.jsx("p",{className:"typography-meta text-muted-foreground",children:l("settings.providers.page.auth.oauth.codeHint")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(O,{value:b,onChange:u=>d(u.target.value),placeholder:l("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs",disabled:o.submitting}),s.jsx(C,{size:"xs",className:"!font-normal shrink-0",onClick:()=>{se()},disabled:o.submitting||b.trim().length===0,children:o.submitting?l("settings.providers.page.actions.saving"):l("settings.providers.page.actions.complete")}),s.jsx(C,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:q,disabled:o.submitting,children:l("settings.providers.page.actions.cancel")})]})]}),i&&o.phase==="failed"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:o.message}),s.jsx(C,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>R(r),children:l("settings.providers.page.actions.tryAgain")})]})]},r.id)})})},Oe=(t,e)=>t.find(a=>a.id.startsWith("mcp_")&&a.metadata?.source==="mcp"&&a.name===e),ze=t=>(t?.methods??[]).filter(e=>e.type==="oauth"),Ve=({serverName:t,directory:e,onConnected:a,autoStart:n})=>{const[c,m]=k.useState(null);k.useEffect(()=>{let f=!1;m(null);const o=e?D.getScopedSdkClient(e):D.getSdkClient(),g=async(x=0)=>{try{const{data:v}=await o.integration.list();if(f)return;const b=Oe(v,t)??null;if(b){m(b);return}x<8&&setTimeout(()=>{g(x+1)},750)}catch(v){if(f)return;console.error("Failed to load MCP integrations:",v),x<8&&setTimeout(()=>{g(x+1)},750)}};return g(),()=>{f=!0}},[e,t]);const l=ze(c??void 0);return!c||l.length===0?null:s.jsx(Fe,{integrationId:c.id,methods:l,directory:e,onConnected:a,autoStart:n},c.id)},Pe=fe({error:ye(["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:B().trim().min(1).max(64).optional(),id:B().trim().min(1).max(128).optional()}),_e=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 a=/^[a-zA-Z]:[\\/]/.test(e);return/^[a-z][a-z0-9+.-]*:/i.test(e)&&!a?{ok:!1,code:"invalid-url"}:e.startsWith("/")||a||e.startsWith("\\\\")?{ok:!0,request:{path:e}}:{ok:!1,code:"invalid-path"}},X=async t=>{try{const e=Pe.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"}}},ee=async(t,e)=>{if(!t.ok)return{ok:!1,...await X(t),diagnostic:{method:"POST",path:e,kind:"http",status:t.status}};const a=await t.text().catch(()=>null),n=a===null?null:me(a);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}}},Ge=async(t,e={})=>{const a=_e(t);if(!a.ok)return a;const n={...a.request};e.replace&&(n.replace=!0),"url"in n&&e.gitIdentityId&&(n.gitIdentityId=e.gitIdentityId);try{const c=await z("/api/guests",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});return await ee(c,"/api/guests")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests",kind:"network"}}}},Ze=async(t,e={})=>{try{const a=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 ee(a,"/api/guests/upload")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests/upload",kind:"network"}}}},$e=async t=>{const e=ge.getState(),a=ne(),n=e.runtimeKey===a?e.guests.find(c=>c.id===t)?.storageId:void 0;try{const c=await z(`/api/guests/${t}`,{method:"DELETE"});return c.status===204?(n&&globalThis.indexedDB&&await he({runtimeKey:a,guestId:t,storageId:n}).catch(()=>{console.warn("Could not clear local extension preferences.")}),{ok:!0}):{ok:!1,code:(await X(c)).code}}catch{return{ok:!1,code:"failed"}}},Be=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}},Je=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{J as M,Ae as P,Ve as a,ve as b,P as c,we as d,A as e,Ne as f,Se as g,Fe as h,Ge as i,Ze as j,Je as k,Me as n,Ue as r,Be as s,$e as u};