@hienlh/ppm 0.9.0-beta.8 → 0.9.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.
- package/CHANGELOG.md +238 -0
- package/bun.lock +17 -0
- package/dist/web/assets/api-settings-BUvk6Saw.js +1 -0
- package/dist/web/assets/arrow-up-BYhx9ckd.js +1 -0
- package/dist/web/assets/browser-tab-CrkhFCaw.js +1 -0
- package/dist/web/assets/chat-tab-C6jpiwh7.js +8 -0
- package/dist/web/assets/chevron-right-5HgK6l7K.js +1 -0
- package/dist/web/assets/code-editor-CBIPzlP2.js +2 -0
- package/dist/web/assets/columns-2-cEVJHYd7.js +1 -0
- package/dist/web/assets/createLucideIcon-PuMiQgHl.js +1 -0
- package/dist/web/assets/{csv-preview-DLqYtXxt.js → csv-preview-ncSOnJSC.js} +2 -2
- package/dist/web/assets/database-viewer-BqOJR_zi.js +1 -0
- package/dist/web/assets/diff-viewer-CcLyp4eY.js +4 -0
- package/dist/web/assets/{dist-CALwEtco.js → dist-DIV6WgAG.js} +1 -1
- package/dist/web/assets/{dist-DGDPTxs1.js → dist-ovWkrgO-.js} +1 -1
- package/dist/web/assets/extension-webview-NiZ7Ybvv.js +3 -0
- package/dist/web/assets/git-graph-CoTvMrIo.js +1 -0
- package/dist/web/assets/index-C8byznLO.js +37 -0
- package/dist/web/assets/index-KwC2YrG4.css +2 -0
- package/dist/web/assets/jsx-runtime-kMwlnEGE.js +1 -0
- package/dist/web/assets/keybindings-store-DPYzBe_M.js +1 -0
- package/dist/web/assets/{markdown-renderer-DklUd_Gv.js → markdown-renderer-DPLdR9xc.js} +4 -4
- package/dist/web/assets/postgres-viewer-BeiK4lCa.js +1 -0
- package/dist/web/assets/settings-tab-D3AvU4lu.js +1 -0
- package/dist/web/assets/sqlite-viewer-nA2sD4Yv.js +1 -0
- package/dist/web/assets/tab-store-BOgTrqRr.js +1 -0
- package/dist/web/assets/table-DFevCOMd.js +1 -0
- package/dist/web/assets/tag-CXMT0QB6.js +1 -0
- package/dist/web/assets/{terminal-tab-CqRuiIFn.js → terminal-tab-BBi0pEji.js} +2 -2
- package/dist/web/assets/{use-monaco-theme-Dcz3aLAE.js → use-monaco-theme-B5pG2d1w.js} +1 -1
- package/dist/web/index.html +8 -8
- package/dist/web/monacoeditorwork/css.worker.bundle.js +122 -122
- package/dist/web/monacoeditorwork/editor.worker.bundle.js +78 -78
- package/dist/web/monacoeditorwork/html.worker.bundle.js +110 -110
- package/dist/web/monacoeditorwork/json.worker.bundle.js +108 -108
- package/dist/web/monacoeditorwork/ts.worker.bundle.js +81 -81
- package/dist/web/sw.js +1 -1
- package/docs/code-standards.md +128 -1
- package/docs/codebase-summary.md +79 -12
- package/docs/extension-development-guide.md +532 -0
- package/docs/project-changelog.md +51 -1
- package/docs/project-roadmap.md +9 -3
- package/docs/streaming-input-guide.md +267 -0
- package/docs/system-architecture.md +432 -3
- package/package.json +6 -3
- package/packages/ext-database/package.json +41 -0
- package/packages/ext-database/src/connection-tree.ts +142 -0
- package/packages/ext-database/src/extension.ts +346 -0
- package/packages/ext-database/src/query-panel.ts +120 -0
- package/packages/ext-database/src/table-viewer-panel.ts +410 -0
- package/packages/ext-database/tsconfig.json +8 -0
- package/packages/vscode-compat/package.json +16 -0
- package/packages/vscode-compat/src/commands.ts +39 -0
- package/packages/vscode-compat/src/context.ts +65 -0
- package/packages/vscode-compat/src/disposable.ts +21 -0
- package/packages/vscode-compat/src/env.ts +20 -0
- package/packages/vscode-compat/src/event-emitter.ts +28 -0
- package/packages/vscode-compat/src/index.ts +93 -0
- package/packages/vscode-compat/src/not-supported.ts +15 -0
- package/packages/vscode-compat/src/types.ts +167 -0
- package/packages/vscode-compat/src/uri.ts +65 -0
- package/packages/vscode-compat/src/window.ts +229 -0
- package/packages/vscode-compat/src/workspace.ts +76 -0
- package/packages/vscode-compat/tsconfig.json +10 -0
- package/snapshot-state.md +1526 -0
- package/src/cli/commands/autostart.ts +1 -1
- package/src/cli/commands/ext-cmd.ts +121 -0
- package/src/cli/commands/restart.ts +9 -1
- package/src/cli/commands/status.ts +19 -0
- package/src/index.ts +5 -3
- package/src/providers/claude-agent-sdk.ts +221 -17
- package/src/providers/cli-provider-base.ts +6 -0
- package/src/server/index.ts +55 -155
- package/src/server/routes/chat.ts +81 -11
- package/src/server/routes/extensions.ts +81 -0
- package/src/server/routes/project-scoped.ts +2 -0
- package/src/server/routes/settings.ts +27 -0
- package/src/server/routes/workspace.ts +35 -0
- package/src/server/ws/chat.ts +9 -3
- package/src/server/ws/extensions.ts +175 -0
- package/src/services/account-selector.service.ts +14 -5
- package/src/services/account.service.ts +20 -15
- package/src/services/claude-usage.service.ts +29 -24
- package/src/services/cloud-ws.service.ts +228 -0
- package/src/services/cloud.service.ts +11 -6
- package/src/services/contribution-registry.ts +110 -0
- package/src/services/db.service.ts +181 -4
- package/src/services/extension-host-worker.ts +160 -0
- package/src/services/extension-installer.ts +112 -0
- package/src/services/extension-manifest.ts +65 -0
- package/src/services/extension-rpc-handlers.ts +235 -0
- package/src/services/extension-rpc.ts +105 -0
- package/src/services/extension.service.ts +228 -0
- package/src/services/mcp-config.service.ts +15 -6
- package/src/services/supervisor.ts +271 -25
- package/src/types/api.ts +1 -0
- package/src/types/chat.ts +4 -0
- package/src/types/extension-messages.ts +64 -0
- package/src/types/extension.ts +131 -0
- package/src/web/app.tsx +69 -48
- package/src/web/components/chat/account-rotation-settings.tsx +163 -0
- package/src/web/components/chat/chat-history-bar.tsx +106 -10
- package/src/web/components/chat/chat-tab.tsx +15 -10
- package/src/web/components/chat/chat-welcome.tsx +148 -0
- package/src/web/components/chat/message-list.tsx +19 -6
- package/src/web/components/chat/session-picker.tsx +80 -32
- package/src/web/components/chat/usage-badge.tsx +68 -8
- package/src/web/components/editor/editor-breadcrumb.tsx +20 -29
- package/src/web/components/extensions/extension-inputbox.tsx +92 -0
- package/src/web/components/extensions/extension-quickpick.tsx +194 -0
- package/src/web/components/extensions/extension-tree-view.tsx +240 -0
- package/src/web/components/extensions/extension-webview.tsx +83 -0
- package/src/web/components/layout/command-palette.tsx +22 -2
- package/src/web/components/layout/editor-panel.tsx +163 -18
- package/src/web/components/layout/mobile-nav.tsx +2 -1
- package/src/web/components/layout/sidebar.tsx +21 -3
- package/src/web/components/layout/status-bar.tsx +64 -0
- package/src/web/components/layout/tab-bar.tsx +2 -0
- package/src/web/components/layout/tab-content.tsx +5 -0
- package/src/web/components/layout/upgrade-banner.tsx +15 -5
- package/src/web/components/settings/change-password-section.tsx +128 -0
- package/src/web/components/settings/extension-manager-section.tsx +214 -0
- package/src/web/components/settings/settings-tab.tsx +9 -2
- package/src/web/components/shared/connection-lost-overlay.tsx +89 -0
- package/src/web/hooks/use-chat.ts +28 -0
- package/src/web/hooks/use-extension-ws.ts +181 -0
- package/src/web/hooks/use-global-keybindings.ts +18 -2
- package/src/web/hooks/use-server-reload.ts +9 -0
- package/src/web/hooks/use-url-sync.ts +173 -21
- package/src/web/stores/connection-store.ts +39 -0
- package/src/web/stores/extension-store.ts +204 -0
- package/src/web/stores/panel-store.ts +63 -9
- package/src/web/stores/panel-utils.ts +145 -3
- package/src/web/stores/settings-store.ts +7 -2
- package/src/web/stores/tab-store.ts +2 -1
- package/test-session-ops.mjs +444 -0
- package/test-tokens.mjs +212 -0
- package/tsconfig.json +3 -1
- package/dist/web/assets/api-settings-D21InCnR.js +0 -1
- package/dist/web/assets/arrow-up--LjUXLEt.js +0 -1
- package/dist/web/assets/browser-tab-BEe89aSD.js +0 -1
- package/dist/web/assets/chat-tab-9lqvWozA.js +0 -7
- package/dist/web/assets/chevron-right-CHnjJt4E.js +0 -1
- package/dist/web/assets/code-editor-COAIZx-B.js +0 -2
- package/dist/web/assets/columns-2-DbesTfa7.js +0 -1
- package/dist/web/assets/database-viewer-aRR9n_Ui.js +0 -1
- package/dist/web/assets/diff-viewer-C4KMvpHr.js +0 -4
- package/dist/web/assets/dist-CVTST7Gc.js +0 -1
- package/dist/web/assets/git-graph-CfJjl4E3.js +0 -1
- package/dist/web/assets/index-Db8uky1a.css +0 -2
- package/dist/web/assets/index-DxZuwBDe.js +0 -37
- package/dist/web/assets/jsx-runtime-BRW_vwa9.js +0 -1
- package/dist/web/assets/keybindings-store-_uWVCZMv.js +0 -1
- package/dist/web/assets/postgres-viewer-DEAvAyaX.js +0 -1
- package/dist/web/assets/settings-tab-BQedc-No.js +0 -1
- package/dist/web/assets/sqlite-viewer-BPA5idzT.js +0 -1
- package/dist/web/assets/tab-store-DhK6EpBT.js +0 -1
- package/dist/web/assets/table-CQVQM2SB.js +0 -1
- package/dist/web/assets/tag-Q2dZiSPX.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/csv-preview-ncSOnJSC.js","assets/chunk-CFjPhJqf.js","assets/lib-BQ34Db2e.js","assets/react-nm2Ru1Pt.js","assets/createLucideIcon-PuMiQgHl.js","assets/arrow-up-BYhx9ckd.js","assets/react-dom-Bpkvzu3U.js","assets/jsx-runtime-kMwlnEGE.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import"./react-dom-Bpkvzu3U.js";import{t as n}from"./createLucideIcon-PuMiQgHl.js";import{t as r}from"./chevron-right-5HgK6l7K.js";import{n as i,t as a}from"./markdown-renderer-DPLdR9xc.js";import{l as o,t as s}from"./tab-store-BOgTrqRr.js";import{t as c}from"./table-DFevCOMd.js";import{i as l,n as u,t as d}from"./use-monaco-theme-B5pG2d1w.js";import{t as f}from"./preload-helper-Bf_JiD2A.js";import{t as p}from"./jsx-runtime-kMwlnEGE.js";import"./dist-DIV6WgAG.js";import{t as m}from"./utils-BNytJOb1.js";import{i as h,r as g,t as _}from"./api-client-BfBM3I7n.js";import{G as v,I as y,S as b,_ as x,b as S,dt as C,ft as w,g as T,gt as E,ht as D,mt as O,pt as k,st as A,ut as j,v as M,x as N,y as P}from"./index-C8byznLO.js";import"./chunk-GEFDOKGD-D-pKjlVd.js";import"./src-BqX54PbV.js";import"./chunk-7R4GIKGN-Dv-4cAYn.js";import"./chunk-HHEYEP7N-C7vxA5i9.js";import"./dist-CSJdAyA9.js";import"./chunk-PU5JKC2W-ek7k4QVB.js";import"./chunk-MX3YWQON-BpS_PtKp.js";import"./chunk-YBOYWFTD-rQG3QH5s.js";import"./chunk-PQ6SQG4A-TF58UVMU.js";import"./chunk-KYZI473N-Bb0MCaIO.js";import"./chunk-O4XLMI2P-nDhi_cVu.js";import"./chunk-GLR3WWYH-DKikpoJM.js";import"./chunk-XPW4576I-BPQQBakK.js";var F=n(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),I=e(t(),1),L=p(),R={ts:O,tsx:O,js:O,jsx:O,py:O,rs:O,go:O,html:O,css:O,scss:O,json:D,md:k,txt:k,yaml:w,yml:w};function z(e,t){return t?j:R[e.split(`.`).pop()?.toLowerCase()??``]??C}function B(e,t){let n=[],r=e;for(let e=0;e<t.length;e++){let i=t[e],a=t.slice(0,e+1).join(`/`),o=r.find(e=>e.name===i);if(n.push({name:i,fullPath:a,node:o??null,siblings:r}),o?.children)r=o.children;else{for(let r=e+1;r<t.length;r++)n.push({name:t[r],fullPath:t.slice(0,r+1).join(`/`),node:null,siblings:[]});break}}return n}function V(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function H({filePath:e,projectName:t,tabId:n,className:i}){let a=y(e=>e.tree),{updateTab:o,openTab:c}=s(),l=(0,I.useRef)(null),u=(0,I.useMemo)(()=>B(a,e.split(`/`).filter(Boolean)),[a,e]);(0,I.useEffect)(()=>{l.current&&(l.current.scrollLeft=l.current.scrollWidth)},[u]);function d(e,r){let i=m(e);r.metaKey||r.ctrlKey?c({type:`editor`,title:i,metadata:{filePath:e,projectName:t},projectId:t,closable:!0}):o(n,{title:i,metadata:{filePath:e,projectName:t}})}return(0,L.jsx)(`div`,{ref:l,className:i,children:u.map((e,n)=>(0,L.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[n>0&&(0,L.jsx)(r,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),e.siblings.length>0?(0,L.jsx)(U,{segment:e,isLast:n===u.length-1,projectName:t,onFileClick:d}):(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground px-1 py-0.5`,children:e.name})]},e.fullPath))})}function U({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=(0,I.useMemo)(()=>V(e.siblings),[e.siblings]);return(0,L.jsxs)(T,{children:[(0,L.jsx)(b,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`text-xs px-1 py-0.5 rounded hover:bg-muted transition-colors truncate max-w-[120px] ${t?`text-foreground font-medium`:`text-muted-foreground`}`,children:e.name})}),(0,L.jsx)(x,{align:`start`,className:`max-h-[300px] p-1`,children:i.map(t=>(0,L.jsx)(W,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function W({node:e,projectName:t,activePath:n,onFileClick:r}){let i=z(e.name,e.type===`directory`),a=e.path===n;return e.type===`directory`&&e.children&&e.children.length>0?(0,L.jsxs)(P,{children:[(0,L.jsxs)(N,{className:`text-xs gap-1.5 ${a?`bg-muted`:``}`,children:[(0,L.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,L.jsx)(S,{className:`max-h-[300px] overflow-y-auto p-1`,children:V(e.children).map(e=>(0,L.jsx)(W,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]}):(0,L.jsxs)(M,{className:`text-xs gap-1.5 cursor-pointer ${a?`bg-muted`:``}`,onSelect:e=>{},onClick:t=>{e.type!==`directory`&&r(e.path,t)},children:[(0,L.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]})}function G({active:e,onClick:t,icon:n,label:r}){return(0,L.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,L.jsx)(n,{className:`size-3`}),(0,L.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function K({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:a,wordWrap:o,onToggleWordWrap:s,className:u}){return(0,L.jsxs)(`div`,{className:u,children:[(e===`md`||e===`mdx`)&&n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G,{active:t===`edit`,onClick:()=>n(`edit`),icon:i,label:`Edit`}),(0,L.jsx)(G,{active:t===`preview`,onClick:()=>n(`preview`),icon:E,label:`Preview`})]}),e===`csv`&&a&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G,{active:r===`table`,onClick:()=>a(`table`),icon:c,label:`Table`}),(0,L.jsx)(G,{active:r===`raw`,onClick:()=>a(`raw`),icon:i,label:`Raw`})]}),(0,L.jsx)(G,{active:o,onClick:s,icon:l,label:`Wrap`})]})}var q=(0,I.lazy)(()=>f(()=>import(`./csv-preview-ncSOnJSC.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([0,1,2,3,4,5,6,7]))),J=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),Y=new Set([`db`,`sqlite`,`sqlite3`]);function X(e){return e.split(`.`).pop()?.toLowerCase()??``}function ee(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`}[X(e)]??`plaintext`}function Z({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,[i,a]=(0,I.useState)(null),[o,c]=(0,I.useState)(`utf-8`),[l,f]=(0,I.useState)(!0),[p,g]=(0,I.useState)(null),[y,b]=(0,I.useState)(!1),x=(0,I.useRef)(null),S=(0,I.useRef)(``),C=(0,I.useRef)(null),{tabs:w,updateTab:T}=s(),{wordWrap:E,toggleWordWrap:D}=v(),O=d(),k=w.find(e=>e.id===t),j=n?X(n):``,M=J.has(j),N=j===`pdf`,P=Y.has(j),R=j===`md`||j===`mdx`,z=j===`csv`,[B,V]=(0,I.useState)(`preview`),[U,W]=(0,I.useState)(`table`);(0,I.useEffect)(()=>{P&&t&&T(t,{type:`sqlite`})},[P,t,T]);let G=n?/^(\/|[A-Za-z]:[/\\])/.test(n):!1;(0,I.useEffect)(()=>{if(!n||!G&&!r)return;if(M||N){f(!1);return}f(!0),g(null);let e=G?`/api/fs/read?path=${encodeURIComponent(n)}`:`${h(r)}/files/read?path=${encodeURIComponent(n)}`;return _.get(e).then(e=>{a(e.content),e.encoding&&c(e.encoding),S.current=e.content,f(!1)}).catch(e=>{g(e instanceof Error?e.message:`Failed to load file`),f(!1)}),()=>{x.current&&clearTimeout(x.current)}},[n,r,M,N,G]),(0,I.useEffect)(()=>{if(!k)return;let e=n?m(n):`Untitled`,t=y?`${e} \u25CF`:e;k.title!==t&&T(k.id,{title:t})},[y]);let Z=(0,I.useCallback)(async e=>{if(n&&!(!G&&!r))try{G?await _.put(`/api/fs/write`,{path:n,content:e}):await _.put(`${h(r)}/files/write`,{path:n,content:e}),b(!1)}catch{}},[n,r,G]);function Q(e){let t=e??``;a(t),S.current=t,b(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>Z(S.current),1e3)}let $=e?.lineNumber,ie=(0,I.useCallback)((e,t)=>{C.current=e,$&&$>0&&setTimeout(()=>{e.revealLineInCenter($),e.setPosition({lineNumber:$,column:1}),e.focus()},100),e.addCommand(t.KeyMod.Alt|t.KeyCode.KeyZ,()=>v.getState().toggleWordWrap()),t.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),t.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0})},[]);return!n||!G&&!r?(0,L.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No file selected.`}):l?(0,L.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,L.jsx)(A,{className:`size-5 animate-spin`}),(0,L.jsx)(`span`,{className:`text-sm`,children:`Loading file...`})]}):p?(0,L.jsx)(`div`,{className:`flex items-center justify-center h-full text-error text-sm`,children:p}):M?(0,L.jsx)(ne,{filePath:n,projectName:r}):N?(0,L.jsx)(re,{filePath:n,projectName:r}):o===`base64`?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,L.jsx)(F,{className:`size-10 text-text-subtle`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`This file is a binary format and cannot be displayed.`}),(0,L.jsx)(`p`,{className:`text-xs text-text-subtle`,children:n})]}):(0,L.jsxs)(`div`,{className:`flex flex-col h-full w-full overflow-hidden`,children:[n&&r&&t&&(0,L.jsxs)(`div`,{className:`hidden md:flex items-center h-7 border-b border-border bg-background shrink-0`,children:[(0,L.jsx)(H,{filePath:n,projectName:r,tabId:t,className:`flex items-center flex-1 min-w-0 overflow-x-auto scrollbar-none px-2 gap-0.5`}),(0,L.jsx)(K,{ext:j,mdMode:B,onMdModeChange:V,csvMode:U,onCsvModeChange:W,wordWrap:E,onToggleWordWrap:D,className:`shrink-0 flex items-center gap-1 px-2`})]}),z&&U===`table`?(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,L.jsx)(A,{className:`size-5 animate-spin text-text-subtle`})}),children:(0,L.jsx)(q,{content:i??``,onContentChange:Q,wordWrap:E})}):R&&B===`preview`?(0,L.jsx)(te,{content:i??``}):(0,L.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,L.jsx)(u,{height:`100%`,language:ee(n),value:i??``,onChange:Q,onMount:ie,theme:O,options:{fontSize:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:E?`on`:`off`,minimap:{enabled:!1},scrollBeyondLastLine:!1,automaticLayout:!0,lineNumbers:`on`,folding:!0,bracketPairColorization:{enabled:!0}},loading:(0,L.jsx)(A,{className:`size-5 animate-spin text-text-subtle`})})})]})}function te({content:e}){return(0,L.jsx)(a,{content:e,className:`flex-1 overflow-auto p-4`})}function ne({filePath:e,projectName:t}){let[n,r]=(0,I.useState)(null),[i,a]=(0,I.useState)(!1);return(0,I.useEffect)(()=>{let n,i=`${h(t)}/files/raw?path=${encodeURIComponent(e)}`,o=g();return fetch(i,{headers:o?{Authorization:`Bearer ${o}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(e=>{let t=URL.createObjectURL(e);n=t,r(t)}).catch(()=>a(!0)),()=>{n&&URL.revokeObjectURL(n)}},[e,t]),i?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,L.jsx)(F,{className:`size-10 text-text-subtle`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`Failed to load image.`})]}):n?(0,L.jsx)(`div`,{className:`flex items-center justify-center h-full p-4 bg-surface overflow-auto`,children:(0,L.jsx)(`img`,{src:n,alt:e,className:`max-w-full max-h-full object-contain`})}):(0,L.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,L.jsx)(A,{className:`size-5 animate-spin text-text-subtle`})})}function re({filePath:e,projectName:t}){let[n,r]=(0,I.useState)(null),[i,a]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let n,i=`${h(t)}/files/raw?path=${encodeURIComponent(e)}`,o=g();return fetch(i,{headers:o?{Authorization:`Bearer ${o}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(e=>{let t=URL.createObjectURL(new Blob([e],{type:`application/pdf`}));n=t,r(t)}).catch(()=>a(!0)),()=>{n&&URL.revokeObjectURL(n)}},[e,t]);let s=(0,I.useCallback)(()=>{n&&window.open(n,`_blank`)},[n]);return i?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,L.jsx)(F,{className:`size-10 text-text-subtle`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`Failed to load PDF.`})]}):n?(0,L.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,L.jsx)(`span`,{className:`text-xs text-text-secondary truncate`,children:e}),(0,L.jsxs)(`button`,{onClick:s,className:`flex items-center gap-1 text-xs text-text-secondary hover:text-text-primary transition-colors`,children:[(0,L.jsx)(o,{className:`size-3`}),` Open in new tab`]})]}),(0,L.jsx)(`iframe`,{src:n,title:e,className:`flex-1 w-full border-none`})]}):(0,L.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,L.jsx)(A,{className:`size-5 animate-spin text-text-subtle`})})}export{Z as CodeEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./createLucideIcon-PuMiQgHl.js";var t=e(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";var n=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),r=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),i=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),a=e=>{let t=i(e);return t.charAt(0).toUpperCase()+t.slice(1)},o={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},s=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},c=e(t()),l=(0,c.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:r=2,absoluteStrokeWidth:i,className:a=``,children:l,iconNode:u,...d},f)=>(0,c.createElement)(`svg`,{ref:f,...o,width:t,height:t,stroke:e,strokeWidth:i?Number(r)*24/Number(t):r,className:n(`lucide`,a),...!l&&!s(d)&&{"aria-hidden":`true`},...d},[...u.map(([e,t])=>(0,c.createElement)(e,t)),...Array.isArray(l)?l:[l]])),u=(e,t)=>{let i=(0,c.forwardRef)(({className:i,...o},s)=>(0,c.createElement)(l,{ref:s,iconNode:t,className:n(`lucide-${r(a(e))}`,`lucide-${e}`,i),...o}));return i.displayName=a(e),i};export{u as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import{t as n}from"./react-dom-Bpkvzu3U.js";import{
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import{t as n}from"./react-dom-Bpkvzu3U.js";import{t as r}from"./createLucideIcon-PuMiQgHl.js";import{t as i}from"./arrow-up-BYhx9ckd.js";import{t as a}from"./jsx-runtime-kMwlnEGE.js";import{i as o,n as s,r as c,t as l}from"./lib-BQ34Db2e.js";var u=r(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),d=e(n(),1),f=e(t(),1);function p(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
2
2
|
font-size: .6rem;
|
|
3
3
|
font-weight: bold;
|
|
4
4
|
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function m(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var h=(e,t)=>Math.abs(e-t)<1.01,g=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},_=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},v=e=>e,y=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},b=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(_(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(_(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},x={passive:!0},S=typeof window>`u`?!0:`onscrollend`in window,C=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&S?()=>void 0:g(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,x);let l=e.options.useScrollendEvent&&S;return l&&n.addEventListener(`scrollend`,c,x),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},w=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},T=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},E=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:v,rangeExtractor:y,onChange:()=>{},measureElement:w,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=p(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=p(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=p(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=p(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?O({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=p(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=p(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return m(t[D(0,t.length-1,e=>m(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&h(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},D=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function O({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=D(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var k=typeof document<`u`?f.useLayoutEffect:f.useEffect;function A({useFlushSync:e=!0,...t}){let n=f.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,d.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=f.useState(()=>new E(r));return i.setOptions(r),k(()=>i._didMount(),[]),k(()=>i._willUpdate()),i}function j(e){return A({observeElementRect:b,observeElementOffset:C,scrollToFn:T,...e})}var M=function(e){return e[e.FIELD_START=0]=`FIELD_START`,e[e.UNQUOTED=1]=`UNQUOTED`,e[e.QUOTED=2]=`QUOTED`,e[e.QUOTE_IN_QUOTED=3]=`QUOTE_IN_QUOTED`,e}(M||{});function N(e){let t=[],n=[],r=``,i=M.FIELD_START;for(let a=0;a<e.length;a++){let o=e[a];switch(i){case M.FIELD_START:o===`"`?i=M.QUOTED:o===`,`?(n.push(r),r=``):o===`\r`||(o===`
|
|
@@ -6,5 +6,5 @@ import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";impor
|
|
|
6
6
|
`?(n.push(r),r=``,t.push(n),n=[],i=M.FIELD_START):r+=o);break;case M.QUOTED:o===`"`?i=M.QUOTE_IN_QUOTED:r+=o;break;case M.QUOTE_IN_QUOTED:o===`"`?(r+=`"`,i=M.QUOTED):o===`,`?(n.push(r),r=``,i=M.FIELD_START):o===`\r`||(o===`
|
|
7
7
|
`?(n.push(r),r=``,t.push(n),n=[],i=M.FIELD_START):(r+=o,i=M.UNQUOTED));break}}if((r||n.length>0)&&(n.push(r),t.push(n)),t.length===0)return{headers:[],rows:[]};let a=t[0],o=t.slice(1),s=a.length;for(let e=0;e<o.length;e++){let t=o[e];if(t.length<s)for(;t.length<s;)t.push(``);else t.length>s&&(o[e]=t.slice(0,s))}return{headers:a,rows:o}}function P(e,t){let n=e=>e.includes(`,`)||e.includes(`"`)||e.includes(`
|
|
8
8
|
`)?`"${e.replace(/"/g,`""`)}"`:e,r=[e.map(n).join(`,`)];for(let e of t)r.push(e.map(n).join(`,`));return r.join(`
|
|
9
|
-
`)}var F=
|
|
9
|
+
`)}var F=a();function I({content:e,onContentChange:t,wordWrap:n}){let r=(0,f.useMemo)(()=>N(e),[e]),[a,d]=(0,f.useState)(()=>r.rows),[p,m]=(0,f.useState)([]),h=(0,f.useRef)(null),g=(0,f.useRef)(!1);(0,f.useEffect)(()=>{if(g.current){g.current=!1;return}d(r.rows)},[r.rows]);let _=r.headers,v=(0,f.useCallback)((e,n,r)=>{d(i=>{let a=i.map((t,n)=>n===e?[...t]:t);return a[e][n]=r,g.current=!0,t(P(_,a)),a})},[_,t]),y=s({data:a,columns:(0,f.useMemo)(()=>_.map((e,t)=>({id:`col-${t}`,header:e||`Column ${t+1}`,accessorFn:e=>e[t]??``,cell:({row:e,getValue:r})=>(0,F.jsx)(L,{value:r(),onSave:n=>v(e.index,t,n),wordWrap:n}),size:150,minSize:80})),[_,v,n]),state:{sorting:p},onSortingChange:m,getCoreRowModel:c(),getSortedRowModel:o(),enableColumnResizing:!0,columnResizeMode:`onChange`}),{rows:b}=y.getRowModel(),x=j({count:b.length,getScrollElement:()=>h.current,estimateSize:()=>32,overscan:20});return _.length===0?(0,F.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`Empty CSV file`}):(0,F.jsx)(`div`,{ref:h,className:`flex-1 overflow-auto`,children:(0,F.jsxs)(`table`,{className:`w-full text-xs font-mono border-collapse`,children:[(0,F.jsx)(`thead`,{className:`sticky top-0 bg-background z-10 border-b border-border block`,children:y.getHeaderGroups().map(e=>(0,F.jsx)(`tr`,{className:`flex w-full`,children:e.headers.map(e=>(0,F.jsxs)(`th`,{className:`relative text-left px-2 py-1.5 font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/50 border-r border-border last:border-r-0`,style:{width:e.getSize(),minWidth:e.getSize()},onClick:e.column.getToggleSortingHandler(),children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`truncate`,children:l(e.column.columnDef.header,e.getContext())}),e.column.getIsSorted()===`asc`&&(0,F.jsx)(i,{className:`size-3 shrink-0`}),e.column.getIsSorted()===`desc`&&(0,F.jsx)(u,{className:`size-3 shrink-0`})]}),(0,F.jsx)(`div`,{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onClick:e=>e.stopPropagation(),className:`absolute right-0 top-0 h-full w-1 cursor-col-resize hover:bg-primary/50 active:bg-primary`})]},e.id))},e.id))}),(0,F.jsx)(`tbody`,{style:{height:x.getTotalSize(),position:`relative`,display:`block`},children:x.getVirtualItems().map(e=>{let t=b[e.index];return(0,F.jsx)(`tr`,{"data-index":e.index,ref:e=>x.measureElement(e),style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`,display:`flex`},children:t.getVisibleCells().map(e=>(0,F.jsx)(`td`,{className:`px-2 py-1 border-b border-border/50 border-r border-r-border/30 last:border-r-0 ${n?`whitespace-pre-wrap break-words`:`truncate`}`,style:{width:e.column.getSize(),minWidth:e.column.getSize()},children:l(e.column.columnDef.cell,e.getContext())},e.id))},t.id)})})]})})}function L({value:e,onSave:t,wordWrap:n}){let[r,i]=(0,f.useState)(!1),[a,o]=(0,f.useState)(e),s=(0,f.useRef)(null),c=(0,f.useCallback)(e=>{e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[]);return(0,f.useEffect)(()=>{r&&s.current&&(s.current.focus(),c(s.current))},[r,c]),r?(0,F.jsx)(`textarea`,{ref:s,className:`w-full bg-transparent outline-none border border-primary/50 rounded text-xs font-mono resize-none p-0.5`,style:{minHeight:a.includes(`
|
|
10
10
|
`)?48:20},rows:1,value:a,onChange:e=>{o(e.target.value),c(e.target)},onBlur:()=>{i(!1),a!==e&&t(a)},onKeyDown:n=>{n.key===`Enter`&&!n.shiftKey?(n.preventDefault(),i(!1),a!==e&&t(a)):n.key===`Escape`&&(i(!1),o(e))}}):(0,F.jsx)(`span`,{className:`block cursor-text ${n?`whitespace-pre-wrap break-words`:`truncate`}`,onClick:()=>{o(e),i(!0)},children:e||`\xA0`})}export{I as CsvPreview};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import{t as n}from"./chevron-right-5HgK6l7K.js";import{a as r,i,n as a,r as o,t as s}from"./dist-ovWkrgO-.js";import{t as c}from"./jsx-runtime-kMwlnEGE.js";import{t as l}from"./api-client-BfBM3I7n.js";import{$ as u,Tt as d,st as f,vt as p}from"./index-C8byznLO.js";import{n as m,r as h,t as g}from"./lib-BQ34Db2e.js";var _=e(t(),1);function v(e,t,n,r){return`ppm-db-${e}-${n}.${t}-p${r}`}function y(e,t,n,r){try{let i=sessionStorage.getItem(v(e,t,n,r));return i?JSON.parse(i):null}catch{return null}}function b(e,t,n,r,i,a){try{sessionStorage.setItem(v(e,t,n,r),JSON.stringify({data:i,cols:a}))}catch{}}function x(e){let t=`/api/db/connections/${e}`,[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(`public`),[o,s]=(0,_.useState)(null),[c,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(1),[v,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(!1),E=(0,_.useCallback)(async(r,a,o)=>{let c=r??n,d=a??i;if(c){f(!0);try{let[n,r]=await Promise.all([l.get(`${t}/data?table=${encodeURIComponent(c)}&schema=${d}&page=${o??h}&limit=100`),l.get(`${t}/schema?table=${encodeURIComponent(c)}&schema=${d}`)]);s(n),u(r),b(e,c,d,o??h,n,r)}catch(e){m(e.message)}finally{f(!1)}}},[t,e,n,i,h]);return{selectedTable:n,selectTable:(0,_.useCallback)((t,n=`public`)=>{r(t),a(n),g(1),x(null);let i=y(e,t,n,1);i?(s(i.data),u(i.cols),f(!1),E(t,n,1)):E(t,n,1)},[e,E]),tableData:o,schema:c,loading:d,error:p,page:h,setPage:(0,_.useCallback)(e=>{g(e),E(void 0,void 0,e)},[E]),queryResult:v,queryError:S,queryLoading:w,executeQuery:(0,_.useCallback)(async e=>{T(!0),C(null);try{let r=await l.post(`${t}/query`,{sql:e});x(r),r.changeType===`modify`&&E(n??void 0,i)}catch(e){C(e.message)}finally{T(!1)}},[t,n,i,E]),updateCell:(0,_.useCallback)(async(e,r,a,o)=>{if(!n)return;let s=n,c=i;try{await l.put(`${t}/cell`,{table:s,schema:c,pkColumn:e,pkValue:r,column:a,value:o}),E(s,c)}catch(e){m(e.message)}},[t,n,i,E]),refreshData:E}}var S=c(),C={postgres:s,sqlite:a};function w({metadata:e}){let t=e?.connectionId,n=e?.connectionName,r=e?.dbType??`postgres`,i=e?.tableName,a=e?.schemaName??`public`,o=x(t),[c,l]=(0,_.useState)(!1),d=(0,_.useRef)(!1);return(0,_.useEffect)(()=>{!i||d.current||(d.current=!0,o.selectTable(i,a))},[i,a]),(0,S.jsx)(`div`,{className:`flex h-full w-full overflow-hidden`,children:(0,S.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,S.jsx)(p,{className:`size-3.5 text-muted-foreground`}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:n??`Database`}),o.selectedTable&&(0,S.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,o.selectedTable]}),(0,S.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>o.refreshData(),title:`Reload data`,className:`p-1 rounded text-muted-foreground hover:text-foreground transition-colors`,children:(0,S.jsx)(u,{className:`size-3 ${o.loading?`animate-spin`:``}`})}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`px-2 py-1 rounded text-xs transition-colors ${c?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:`SQL`})]})]}),(0,S.jsx)(`div`,{className:`flex-1 overflow-hidden ${c?`max-h-[60%]`:``}`,children:(0,S.jsx)(T,{tableData:o.tableData,schema:o.schema,loading:o.loading,page:o.page,onPageChange:o.setPage,onCellUpdate:o.updateCell})}),c&&(0,S.jsx)(`div`,{className:`border-t border-border h-[40%] shrink-0`,children:(0,S.jsx)(E,{dialect:C[r]??s,onExecute:o.executeQuery,result:o.queryResult,error:o.queryError,loading:o.queryLoading})})]})})}function T({tableData:e,schema:t,loading:r,page:i,onPageChange:a,onCellUpdate:o}){let[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(``),p=(0,_.useMemo)(()=>t.find(e=>e.pk)?.name??null,[t]),v=(0,_.useCallback)((e,t,n)=>{c({rowIdx:e,col:t}),u(n==null?``:String(n))},[]),y=(0,_.useCallback)(()=>{if(!s||!e||!p)return;let t=e.rows[s.rowIdx];if(!t)return;let n=t[s.col];String(n??``)!==l&&o(p,t[p],s.col,l===``?null:l),c(null)},[s,l,e,p,o]),b=(0,_.useCallback)(()=>c(null),[]),x=(0,_.useMemo)(()=>(e?.columns??[]).map(e=>({id:e,accessorFn:t=>t[e],header:()=>(0,S.jsx)(`span`,{className:t.find(t=>t.name===e)?.pk?`font-bold`:``,children:e}),cell:({row:t,getValue:n})=>{let r=s?.rowIdx===t.index&&s?.col===e,i=n();return r?(0,S.jsx)(`input`,{autoFocus:!0,className:`w-full bg-transparent border border-primary/50 rounded px-1 py-0 text-xs outline-none`,value:l,onChange:e=>u(e.target.value),onBlur:y,onKeyDown:e=>{e.key===`Enter`&&y(),e.key===`Escape`&&b()}}):(0,S.jsx)(`span`,{className:`cursor-pointer truncate block ${i==null?`text-muted-foreground/40 italic`:``}`,onDoubleClick:()=>p&&v(t.index,e,i),title:i==null?`NULL`:String(i),children:i==null?`NULL`:String(i)})}})),[e?.columns,t,s,l,y,b,v,p]),C=m({data:e?.rows??[],columns:x,getCoreRowModel:h()});if(!e)return(0,S.jsx)(`div`,{className:`flex items-center justify-center h-full text-xs text-muted-foreground`,children:r?(0,S.jsx)(f,{className:`size-4 animate-spin`}):`Select a table`});let w=Math.ceil(e.total/e.limit)||1;return(0,S.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,S.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-xs border-collapse`,children:[(0,S.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted`,children:C.getHeaderGroups().map(e=>(0,S.jsx)(`tr`,{children:e.headers.map(e=>(0,S.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:g(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,S.jsxs)(`tbody`,{children:[C.getRowModel().rows.map(e=>(0,S.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:e.getVisibleCells().map(e=>(0,S.jsx)(`td`,{className:`px-2 py-1 max-w-[300px]`,children:g(e.column.columnDef.cell,e.getContext())},e.id))},e.id)),e.rows.length===0&&(0,S.jsx)(`tr`,{children:(0,S.jsx)(`td`,{colSpan:e.columns.length,className:`px-2 py-8 text-center text-muted-foreground`,children:`No data`})})]})]})}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-t border-border bg-background shrink-0 text-xs text-muted-foreground`,children:[(0,S.jsxs)(`span`,{children:[e.total.toLocaleString(),` rows`]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,disabled:i<=1,onClick:()=>a(i-1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,S.jsx)(d,{className:`size-3.5`})}),(0,S.jsxs)(`span`,{children:[i,` / `,w]}),(0,S.jsx)(`button`,{type:`button`,disabled:i>=w,onClick:()=>a(i+1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,S.jsx)(n,{className:`size-3.5`})})]})]})]})}function E({dialect:e,onExecute:t,result:n,error:a,loading:s}){let[c,l]=(0,_.useState)(`SELECT * FROM `),u=(0,_.useCallback)(()=>{let e=c.trim();e&&t(e)},[c,t]);return(0,S.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`flex items-start gap-1 border-b border-border bg-background`,onKeyDown:(0,_.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),u())},[u]),children:[(0,S.jsx)(`div`,{className:`flex-1 max-h-[120px] overflow-auto`,children:(0,S.jsx)(i,{value:c,onChange:l,extensions:[o({dialect:e})],basicSetup:{lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1},className:`text-xs [&_.cm-editor]:!outline-none [&_.cm-scroller]:!overflow-auto`})}),(0,S.jsx)(`button`,{type:`button`,onClick:u,disabled:s,title:`Execute (Cmd+Enter)`,className:`shrink-0 m-1 p-1.5 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:s?(0,S.jsx)(f,{className:`size-3.5 animate-spin`}):(0,S.jsx)(r,{className:`size-3.5`})})]}),(0,S.jsxs)(`div`,{className:`flex-1 overflow-auto text-xs`,children:[a&&(0,S.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5`,children:a}),n?.changeType===`modify`&&(0,S.jsxs)(`div`,{className:`px-3 py-2 text-green-500`,children:[`Query executed. `,n.rowsAffected,` row(s) affected.`]}),n?.changeType===`select`&&n.rows.length>0&&(0,S.jsxs)(`table`,{className:`w-full border-collapse`,children:[(0,S.jsx)(`thead`,{className:`sticky top-0 bg-muted`,children:(0,S.jsx)(`tr`,{children:n.columns.map(e=>(0,S.jsx)(`th`,{className:`px-2 py-1 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:e},e))})}),(0,S.jsx)(`tbody`,{children:n.rows.map((e,t)=>(0,S.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:n.columns.map(t=>(0,S.jsx)(`td`,{className:`px-2 py-1 max-w-[300px] truncate`,title:e[t]==null?`NULL`:String(e[t]),children:e[t]==null?(0,S.jsx)(`span`,{className:`text-muted-foreground/40 italic`,children:`NULL`}):String(e[t])},t))},t))})]}),n?.changeType===`select`&&n.rows.length===0&&(0,S.jsx)(`div`,{className:`px-3 py-2 text-muted-foreground`,children:`No results`})]})]})}export{w as DatabaseViewer};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import{t as n}from"./createLucideIcon-PuMiQgHl.js";import{t as r}from"./columns-2-cEVJHYd7.js";import{i,r as a,t as o}from"./use-monaco-theme-B5pG2d1w.js";import{t as s}from"./jsx-runtime-kMwlnEGE.js";import{i as c,t as l}from"./api-client-BfBM3I7n.js";import{G as u,it as d,mt as f,st as p}from"./index-C8byznLO.js";var m=n(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),h=e(t(),1),g=s();function _(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function v({metadata:e}){let t=e?.filePath,n=e?.projectName,s=e?.ref1,v=e?.ref2,b=e?.file1,x=e?.file2,S=e?.original,C=e?.modified,w=S!=null||C!=null,T=!!(b&&x),[E,D]=(0,h.useState)(null),[O,k]=(0,h.useState)(null),[A,j]=(0,h.useState)(!w),[M,N]=(0,h.useState)(null),[P,F]=(0,h.useState)(`both`),{wordWrap:I,toggleWordWrap:L}=u(),R=o(),z=(0,h.useRef)(null),[B,V]=(0,h.useState)();(0,h.useEffect)(()=>{let e=z.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&V(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[A,M]),(0,h.useEffect)(()=>{if(w||!n)return;if(j(!0),N(null),b&&x){let e=new URLSearchParams({file1:b,file2:x});l.get(`${c(n)}/files/compare?${e}`).then(e=>{k(e),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to compare files`),j(!1)});return}let e;if(t){let r=new URLSearchParams({file:t});s&&r.set(`ref`,s),e=`${c(n)}/git/file-diff?${r}`}else if(s||v){let t=new URLSearchParams;s&&t.set(`ref1`,s),v&&t.set(`ref2`,v),e=`${c(n)}/git/diff?${t}`}else e=`${c(n)}/git/diff`;l.get(e).then(e=>{D(e.diff),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to load diff`),j(!1)})},[t,n,s,v,b,x,w]);let{original:H,modified:U}=(0,h.useMemo)(()=>w?{original:S??``,modified:C??``}:T&&O?O:E?y(E):{original:``,modified:``},[E,w,S,C,T,O]),W=(0,h.useMemo)(()=>{let e=t??x??b;return e?_(e):`plaintext`},[t,b,x]),G=typeof window<`u`&&window.innerWidth<768,K=!G&&P===`both`;return!n&&!w?(0,g.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`}):A?(0,g.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,g.jsx)(p,{className:`size-5 animate-spin`}),(0,g.jsx)(`span`,{className:`text-sm`,children:`Loading diff...`})]}):M?(0,g.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive text-sm`,children:M}):!w&&!T&&!H&&!U?(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,g.jsx)(f,{className:`size-8`}),(0,g.jsx)(`p`,{className:`text-sm`,children:`No content changes`}),t&&(0,g.jsx)(`p`,{className:`text-xs font-mono`,children:t})]}):(0,g.jsxs)(`div`,{className:`flex flex-col h-full`,children:[!G&&(0,g.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5 px-2 py-0.5 border-b border-border shrink-0`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:()=>F(P===`left`?`both`:`left`),className:`p-1 rounded hover:bg-muted transition-colors ${P===`left`?`bg-muted text-foreground`:``}`,title:`Expand original`,children:(0,g.jsx)(d,{className:`size-3.5`})}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>F(`both`),className:`p-1 rounded hover:bg-muted transition-colors ${P===`both`?`bg-muted text-foreground`:``}`,title:`Side by side`,children:(0,g.jsx)(r,{className:`size-3.5`})}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>F(P===`right`?`both`:`right`),className:`p-1 rounded hover:bg-muted transition-colors ${P===`right`?`bg-muted text-foreground`:``}`,title:`Expand modified`,children:(0,g.jsx)(m,{className:`size-3.5`})}),(0,g.jsx)(`div`,{className:`w-px h-3.5 bg-border mx-0.5 shrink-0`}),(0,g.jsx)(`button`,{type:`button`,onClick:L,title:`Toggle word wrap`,className:`p-1 rounded hover:bg-muted transition-colors ${I?`bg-muted text-foreground`:``}`,children:(0,g.jsx)(i,{className:`size-3.5`})})]}),(0,g.jsx)(`div`,{ref:z,className:`flex-1 overflow-hidden`,children:B&&B>0?(0,g.jsx)(a,{height:B,language:W,original:H,modified:U,theme:R,options:{fontSize:G?11:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:G||I?`on`:`off`,renderSideBySide:K,readOnly:!0,automaticLayout:!0,scrollBeyondLastLine:!1},loading:(0,g.jsx)(p,{className:`size-5 animate-spin text-muted-foreground`})}):(0,g.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,g.jsx)(p,{className:`size-5 animate-spin text-muted-foreground`})})})]})}function y(e){let t=e.split(`
|
|
2
|
+
`),n=[],r=[],i=!1;for(let e of t)if(!(e.startsWith(`diff --git`)||e.startsWith(`diff --no-index`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`---`)||e.startsWith(`+++`)||e.startsWith(`Binary files`)||e.startsWith(`\\ No newline`))){if(e.startsWith(`@@`)){i=!0;continue}if(i)if(e.startsWith(`-`))n.push(e.slice(1));else if(e.startsWith(`+`))r.push(e.slice(1));else{let t=e.startsWith(` `)?e.slice(1):e;n.push(t),r.push(t)}}return{original:n.join(`
|
|
3
|
+
`),modified:r.join(`
|
|
4
|
+
`)}}export{v as DiffViewer};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import{t as n}from"./react-dom-Bpkvzu3U.js";import{t as r}from"./jsx-runtime-BRW_vwa9.js";var i=e(t(),1);function a(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function o(...e){return t=>{let n=!1,r=e.map(e=>{let r=a(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():a(e[t],null)}}}}function s(...e){return i.useCallback(o(...e),e)}var c=r();function l(e){let t=d(e),n=i.forwardRef((e,n)=>{let{children:r,...a}=e,o=i.Children.toArray(r),s=o.find(m);if(s){let e=s.props.children,r=o.map(t=>t===s?i.Children.count(e)>1?i.Children.only(null):i.isValidElement(e)?e.props.children:null:t);return(0,c.jsx)(t,{...a,ref:n,children:i.isValidElement(e)?i.cloneElement(e,void 0,r):null})}return(0,c.jsx)(t,{...a,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var u=l(`Slot`);function d(e){let t=i.forwardRef((e,t)=>{let{children:n,...r}=e;if(i.isValidElement(n)){let e=g(n),a=h(r,n.props);return n.type!==i.Fragment&&(a.ref=t?o(t,e):e),i.cloneElement(n,a)}return i.Children.count(n)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var f=Symbol(`radix.slottable`);function p(e){let t=({children:e})=>(0,c.jsx)(c.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=f,t}function m(e){return i.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===f}function h(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function g(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var _=e(n(),1),v=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=l(`Primitive.${t}`),r=i.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,c.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function y(e,t){e&&_.flushSync(()=>e.dispatchEvent(t))}function b(e,t){let n=i.createContext(t),r=e=>{let{children:t,...r}=e,a=i.useMemo(()=>r,Object.values(r));return(0,c.jsx)(n.Provider,{value:a,children:t})};r.displayName=e+`Provider`;function a(r){let a=i.useContext(n);if(a)return a;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,a]}function x(e,t=[]){let n=[];function r(t,r){let a=i.createContext(r),o=n.length;n=[...n,r];let s=t=>{let{scope:n,children:r,...s}=t,l=n?.[e]?.[o]||a,u=i.useMemo(()=>s,Object.values(s));return(0,c.jsx)(l.Provider,{value:u,children:r})};s.displayName=t+`Provider`;function l(n,s){let c=s?.[e]?.[o]||a,l=i.useContext(c);if(l)return l;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[s,l]}let a=()=>{let t=n.map(e=>i.createContext(e));return function(n){let r=n?.[e]||t;return i.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return a.scopeName=e,[r,S(a,...t)]}function S(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function C(e){let t=e+`CollectionProvider`,[n,r]=x(t),[a,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),u=e=>{let{scope:t,children:n}=e,r=i.useRef(null),o=i.useRef(new Map).current;return(0,c.jsx)(a,{scope:t,itemMap:o,collectionRef:r,children:n})};u.displayName=t;let d=e+`CollectionSlot`,f=l(d),p=i.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,c.jsx)(f,{ref:s(t,o(d,n).collectionRef),children:r})});p.displayName=d;let m=e+`CollectionItemSlot`,h=`data-radix-collection-item`,g=l(m),_=i.forwardRef((e,t)=>{let{scope:n,children:r,...a}=e,l=i.useRef(null),u=s(t,l),d=o(m,n);return i.useEffect(()=>(d.itemMap.set(l,{ref:l,...a}),()=>void d.itemMap.delete(l))),(0,c.jsx)(g,{[h]:``,ref:u,children:r})});_.displayName=m;function v(t){let n=o(e+`CollectionConsumer`,t);return i.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:u,Slot:p,ItemSlot:_},v,r]}typeof window<`u`&&window.document&&window.document.createElement;function w(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var T=globalThis?.document?i.useLayoutEffect:()=>{},E=i.useInsertionEffect||T;function D({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[a,o,s]=O({defaultProp:t,onChange:n}),c=e!==void 0,l=c?e:a;{let t=i.useRef(e!==void 0);i.useEffect(()=>{let e=t.current;if(e!==c){let t=e?`controlled`:`uncontrolled`,n=c?`controlled`:`uncontrolled`;console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=c},[c,r])}return[l,i.useCallback(t=>{if(c){let n=k(t)?t(e):t;n!==e&&s.current?.(n)}else o(t)},[c,e,o,s])]}function O({defaultProp:e,onChange:t}){let[n,r]=i.useState(e),a=i.useRef(n),o=i.useRef(t);return E(()=>{o.current=t},[t]),i.useEffect(()=>{a.current!==n&&(o.current?.(n),a.current=n)},[n,a]),[n,r,o]}function k(e){return typeof e==`function`}function A(e,t){return i.useReducer((e,n)=>t[e][n]??e,e)}var j=e=>{let{present:t,children:n}=e,r=M(t),a=typeof n==`function`?n({present:r.isPresent}):i.Children.only(n),o=s(r.ref,P(a));return typeof n==`function`||r.isPresent?i.cloneElement(a,{ref:o}):null};j.displayName=`Presence`;function M(e){let[t,n]=i.useState(),r=i.useRef(null),a=i.useRef(e),o=i.useRef(`none`),[s,c]=A(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return i.useEffect(()=>{let e=N(r.current);o.current=s===`mounted`?e:`none`},[s]),T(()=>{let t=r.current,n=a.current;if(n!==e){let r=o.current,i=N(t);e?c(`MOUNT`):i===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==i?`ANIMATION_OUT`:`UNMOUNT`),a.current=e}},[e,c]),T(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,i=i=>{let o=N(r.current).includes(CSS.escape(i.animationName));if(i.target===t&&o&&(c(`ANIMATION_END`),!a.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(o.current=N(r.current))};return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,i),t.addEventListener(`animationend`,i),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,i),t.removeEventListener(`animationend`,i)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:i.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function N(e){return e?.animationName||`none`}function P(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ee=i.useId||(()=>void 0),te=0;function ne(e){let[t,n]=i.useState(ee());return T(()=>{e||n(e=>e??String(te++))},[e]),e||(t?`radix-${t}`:``)}var re=i.createContext(void 0);function F(e){let t=i.useContext(re);return e||t||`ltr`}function I(e){let t=i.useRef(e);return i.useEffect(()=>{t.current=e}),i.useMemo(()=>(...e)=>t.current?.(...e),[])}function ie(e,t=globalThis?.document){let n=I(e);i.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var ae=`DismissableLayer`,oe=`dismissableLayer.update`,se=`dismissableLayer.pointerDownOutside`,ce=`dismissableLayer.focusOutside`,le,ue=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),de=i.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:u,...d}=e,f=i.useContext(ue),[p,m]=i.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=i.useState({}),_=s(t,e=>m(e)),y=Array.from(f.layers),[b]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),x=y.indexOf(b),S=p?y.indexOf(p):-1,C=f.layersWithOutsidePointerEventsDisabled.size>0,T=S>=x,E=me(e=>{let t=e.target,n=[...f.branches].some(e=>e.contains(t));!T||n||(a?.(e),l?.(e),e.defaultPrevented||u?.())},h),D=he(e=>{let t=e.target;[...f.branches].some(e=>e.contains(t))||(o?.(e),l?.(e),e.defaultPrevented||u?.())},h);return ie(e=>{S===f.layers.size-1&&(r?.(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))},h),i.useEffect(()=>{if(p)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(le=h.body.style.pointerEvents,h.body.style.pointerEvents=`none`),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),ge(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=le)}},[p,h,n,f]),i.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),ge())},[p,f]),i.useEffect(()=>{let e=()=>g({});return document.addEventListener(oe,e),()=>document.removeEventListener(oe,e)},[]),(0,c.jsx)(v.div,{...d,ref:_,style:{pointerEvents:C?T?`auto`:`none`:void 0,...e.style},onFocusCapture:w(e.onFocusCapture,D.onFocusCapture),onBlurCapture:w(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:w(e.onPointerDownCapture,E.onPointerDownCapture)})});de.displayName=ae;var fe=`DismissableLayerBranch`,pe=i.forwardRef((e,t)=>{let n=i.useContext(ue),r=i.useRef(null),a=s(t,r);return i.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,c.jsx)(v.div,{...e,ref:a})});pe.displayName=fe;function me(e,t=globalThis?.document){let n=I(e),r=i.useRef(!1),a=i.useRef(()=>{});return i.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){_e(se,n,i,{discrete:!0})},i={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,a.current),a.current=r,t.addEventListener(`click`,a.current,{once:!0})):r()}else t.removeEventListener(`click`,a.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(i),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,a.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function he(e,t=globalThis?.document){let n=I(e),r=i.useRef(!1);return i.useEffect(()=>{let e=e=>{e.target&&!r.current&&_e(ce,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ge(){let e=new CustomEvent(oe);document.dispatchEvent(e)}function _e(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?y(i,a):i.dispatchEvent(a)}var ve=`focusScope.autoFocusOnMount`,ye=`focusScope.autoFocusOnUnmount`,be={bubbles:!1,cancelable:!0},xe=`FocusScope`,Se=i.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=e,[u,d]=i.useState(null),f=I(a),p=I(o),m=i.useRef(null),h=s(t,e=>d(e)),g=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(r){let e=function(e){if(g.paused||!u)return;let t=e.target;u.contains(t)?m.current=t:L(m.current,{select:!0})},t=function(e){if(g.paused||!u)return;let t=e.relatedTarget;t!==null&&(u.contains(t)||L(m.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&L(u)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return u&&r.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,u,g.paused]),i.useEffect(()=>{if(u){ke.add(g);let e=document.activeElement;if(!u.contains(e)){let t=new CustomEvent(ve,be);u.addEventListener(ve,f),u.dispatchEvent(t),t.defaultPrevented||(Ce(Me(Te(u)),{select:!0}),document.activeElement===e&&L(u))}return()=>{u.removeEventListener(ve,f),setTimeout(()=>{let t=new CustomEvent(ye,be);u.addEventListener(ye,p),u.dispatchEvent(t),t.defaultPrevented||L(e??document.body,{select:!0}),u.removeEventListener(ye,p),ke.remove(g)},0)}}},[u,f,p,g]);let _=i.useCallback(e=>{if(!n&&!r||g.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=we(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&L(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&L(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,g.paused]);return(0,c.jsx)(v.div,{tabIndex:-1,...l,ref:h,onKeyDown:_})});Se.displayName=xe;function Ce(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(L(r,{select:t}),document.activeElement!==n)return}function we(e){let t=Te(e);return[Ee(t,e),Ee(t.reverse(),e)]}function Te(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ee(e,t){for(let n of e)if(!De(n,{upTo:t}))return n}function De(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Oe(e){return e instanceof HTMLInputElement&&`select`in e}function L(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Oe(e)&&t&&e.select()}}var ke=Ae();function Ae(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=je(e,t),e.unshift(t)},remove(t){e=je(e,t),e[0]?.resume()}}}function je(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Me(e){return e.filter(e=>e.tagName!==`A`)}var Ne=`Portal`,Pe=i.forwardRef((e,t)=>{let{container:n,...r}=e,[a,o]=i.useState(!1);T(()=>o(!0),[]);let s=n||a&&globalThis?.document?.body;return s?_.createPortal((0,c.jsx)(v.div,{...r,ref:t}),s):null});Pe.displayName=Ne;var Fe=0;function Ie(){i.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Le()),document.body.insertAdjacentElement(`beforeend`,e[1]??Le()),Fe++,()=>{Fe===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Fe--}},[])}function Le(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var R=function(){return R=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},R.apply(this,arguments)};function Re(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function ze(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Be=`right-scroll-bar-position`,Ve=`width-before-scroll-bar`,He=`with-scroll-bars-hidden`,Ue=`--removed-body-scroll-bar-size`;function We(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Ge(e,t){var n=(0,i.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Ke=typeof window<`u`?i.useLayoutEffect:i.useEffect,qe=new WeakMap;function Je(e,t){var n=Ge(t||null,function(t){return e.forEach(function(e){return We(e,t)})});return Ke(function(){var t=qe.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||We(e,null)}),i.forEach(function(e){r.has(e)||We(e,a)})}qe.set(n,e)},[e]),n}function Ye(e){return e}function Xe(e,t){t===void 0&&(t=Ye);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Ze(e){e===void 0&&(e={});var t=Xe(null);return t.options=R({async:!0,ssr:!1},e),t}var Qe=function(e){var t=e.sideCar,n=Re(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return i.createElement(r,R({},n))};Qe.isSideCarExport=!0;function $e(e,t){return e.useMedium(t),Qe}var et=Ze(),tt=function(){},nt=i.forwardRef(function(e,t){var n=i.useRef(null),r=i.useState({onScrollCapture:tt,onWheelCapture:tt,onTouchMoveCapture:tt}),a=r[0],o=r[1],s=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=Re(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=Je([n,t]),w=R(R({},x),a);return i.createElement(i.Fragment,null,d&&i.createElement(S,{sideCar:et,removeScrollBar:u,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:o,allowPinchZoom:!!_,lockRef:n,gapMode:b}),s?i.cloneElement(i.Children.only(c),R(R({},w),{ref:C})):i.createElement(y,R({},w,{className:l,ref:C}),c))});nt.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},nt.classNames={fullWidth:Ve,zeroRight:Be};var rt,it=function(){if(rt)return rt;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function at(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=it();return t&&e.setAttribute(`nonce`,t),e}function ot(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function st(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var ct=function(){var e=0,t=null;return{add:function(n){e==0&&(t=at())&&(ot(t,n),st(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},lt=function(){var e=ct();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ut=function(){var e=lt();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},dt={left:0,top:0,right:0,gap:0},ft=function(e){return parseInt(e||``,10)||0},pt=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[ft(n),ft(r),ft(i)]},mt=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return dt;var t=pt(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ht=ut(),gt=`data-scroll-locked`,_t=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import{t as n}from"./react-dom-Bpkvzu3U.js";import{t as r}from"./jsx-runtime-kMwlnEGE.js";var i=e(t(),1);function a(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function o(...e){return t=>{let n=!1,r=e.map(e=>{let r=a(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():a(e[t],null)}}}}function s(...e){return i.useCallback(o(...e),e)}var c=r();function l(e){let t=d(e),n=i.forwardRef((e,n)=>{let{children:r,...a}=e,o=i.Children.toArray(r),s=o.find(m);if(s){let e=s.props.children,r=o.map(t=>t===s?i.Children.count(e)>1?i.Children.only(null):i.isValidElement(e)?e.props.children:null:t);return(0,c.jsx)(t,{...a,ref:n,children:i.isValidElement(e)?i.cloneElement(e,void 0,r):null})}return(0,c.jsx)(t,{...a,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var u=l(`Slot`);function d(e){let t=i.forwardRef((e,t)=>{let{children:n,...r}=e;if(i.isValidElement(n)){let e=g(n),a=h(r,n.props);return n.type!==i.Fragment&&(a.ref=t?o(t,e):e),i.cloneElement(n,a)}return i.Children.count(n)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var f=Symbol(`radix.slottable`);function p(e){let t=({children:e})=>(0,c.jsx)(c.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=f,t}function m(e){return i.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===f}function h(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function g(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var _=e(n(),1),v=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=l(`Primitive.${t}`),r=i.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,c.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function y(e,t){e&&_.flushSync(()=>e.dispatchEvent(t))}function b(e,t){let n=i.createContext(t),r=e=>{let{children:t,...r}=e,a=i.useMemo(()=>r,Object.values(r));return(0,c.jsx)(n.Provider,{value:a,children:t})};r.displayName=e+`Provider`;function a(r){let a=i.useContext(n);if(a)return a;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,a]}function x(e,t=[]){let n=[];function r(t,r){let a=i.createContext(r),o=n.length;n=[...n,r];let s=t=>{let{scope:n,children:r,...s}=t,l=n?.[e]?.[o]||a,u=i.useMemo(()=>s,Object.values(s));return(0,c.jsx)(l.Provider,{value:u,children:r})};s.displayName=t+`Provider`;function l(n,s){let c=s?.[e]?.[o]||a,l=i.useContext(c);if(l)return l;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[s,l]}let a=()=>{let t=n.map(e=>i.createContext(e));return function(n){let r=n?.[e]||t;return i.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return a.scopeName=e,[r,S(a,...t)]}function S(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function C(e){let t=e+`CollectionProvider`,[n,r]=x(t),[a,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),u=e=>{let{scope:t,children:n}=e,r=i.useRef(null),o=i.useRef(new Map).current;return(0,c.jsx)(a,{scope:t,itemMap:o,collectionRef:r,children:n})};u.displayName=t;let d=e+`CollectionSlot`,f=l(d),p=i.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,c.jsx)(f,{ref:s(t,o(d,n).collectionRef),children:r})});p.displayName=d;let m=e+`CollectionItemSlot`,h=`data-radix-collection-item`,g=l(m),_=i.forwardRef((e,t)=>{let{scope:n,children:r,...a}=e,l=i.useRef(null),u=s(t,l),d=o(m,n);return i.useEffect(()=>(d.itemMap.set(l,{ref:l,...a}),()=>void d.itemMap.delete(l))),(0,c.jsx)(g,{[h]:``,ref:u,children:r})});_.displayName=m;function v(t){let n=o(e+`CollectionConsumer`,t);return i.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${h}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:u,Slot:p,ItemSlot:_},v,r]}typeof window<`u`&&window.document&&window.document.createElement;function w(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var T=globalThis?.document?i.useLayoutEffect:()=>{},E=i.useInsertionEffect||T;function D({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[a,o,s]=O({defaultProp:t,onChange:n}),c=e!==void 0,l=c?e:a;{let t=i.useRef(e!==void 0);i.useEffect(()=>{let e=t.current;if(e!==c){let t=e?`controlled`:`uncontrolled`,n=c?`controlled`:`uncontrolled`;console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=c},[c,r])}return[l,i.useCallback(t=>{if(c){let n=k(t)?t(e):t;n!==e&&s.current?.(n)}else o(t)},[c,e,o,s])]}function O({defaultProp:e,onChange:t}){let[n,r]=i.useState(e),a=i.useRef(n),o=i.useRef(t);return E(()=>{o.current=t},[t]),i.useEffect(()=>{a.current!==n&&(o.current?.(n),a.current=n)},[n,a]),[n,r,o]}function k(e){return typeof e==`function`}function A(e,t){return i.useReducer((e,n)=>t[e][n]??e,e)}var j=e=>{let{present:t,children:n}=e,r=M(t),a=typeof n==`function`?n({present:r.isPresent}):i.Children.only(n),o=s(r.ref,P(a));return typeof n==`function`||r.isPresent?i.cloneElement(a,{ref:o}):null};j.displayName=`Presence`;function M(e){let[t,n]=i.useState(),r=i.useRef(null),a=i.useRef(e),o=i.useRef(`none`),[s,c]=A(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return i.useEffect(()=>{let e=N(r.current);o.current=s===`mounted`?e:`none`},[s]),T(()=>{let t=r.current,n=a.current;if(n!==e){let r=o.current,i=N(t);e?c(`MOUNT`):i===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==i?`ANIMATION_OUT`:`UNMOUNT`),a.current=e}},[e,c]),T(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,i=i=>{let o=N(r.current).includes(CSS.escape(i.animationName));if(i.target===t&&o&&(c(`ANIMATION_END`),!a.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(o.current=N(r.current))};return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,i),t.addEventListener(`animationend`,i),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,i),t.removeEventListener(`animationend`,i)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:i.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function N(e){return e?.animationName||`none`}function P(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ee=i.useId||(()=>void 0),te=0;function ne(e){let[t,n]=i.useState(ee());return T(()=>{e||n(e=>e??String(te++))},[e]),e||(t?`radix-${t}`:``)}var re=i.createContext(void 0);function F(e){let t=i.useContext(re);return e||t||`ltr`}function I(e){let t=i.useRef(e);return i.useEffect(()=>{t.current=e}),i.useMemo(()=>(...e)=>t.current?.(...e),[])}function ie(e,t=globalThis?.document){let n=I(e);i.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var ae=`DismissableLayer`,oe=`dismissableLayer.update`,se=`dismissableLayer.pointerDownOutside`,ce=`dismissableLayer.focusOutside`,le,ue=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),de=i.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:u,...d}=e,f=i.useContext(ue),[p,m]=i.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=i.useState({}),_=s(t,e=>m(e)),y=Array.from(f.layers),[b]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),x=y.indexOf(b),S=p?y.indexOf(p):-1,C=f.layersWithOutsidePointerEventsDisabled.size>0,T=S>=x,E=me(e=>{let t=e.target,n=[...f.branches].some(e=>e.contains(t));!T||n||(a?.(e),l?.(e),e.defaultPrevented||u?.())},h),D=he(e=>{let t=e.target;[...f.branches].some(e=>e.contains(t))||(o?.(e),l?.(e),e.defaultPrevented||u?.())},h);return ie(e=>{S===f.layers.size-1&&(r?.(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))},h),i.useEffect(()=>{if(p)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(le=h.body.style.pointerEvents,h.body.style.pointerEvents=`none`),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),ge(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=le)}},[p,h,n,f]),i.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),ge())},[p,f]),i.useEffect(()=>{let e=()=>g({});return document.addEventListener(oe,e),()=>document.removeEventListener(oe,e)},[]),(0,c.jsx)(v.div,{...d,ref:_,style:{pointerEvents:C?T?`auto`:`none`:void 0,...e.style},onFocusCapture:w(e.onFocusCapture,D.onFocusCapture),onBlurCapture:w(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:w(e.onPointerDownCapture,E.onPointerDownCapture)})});de.displayName=ae;var fe=`DismissableLayerBranch`,pe=i.forwardRef((e,t)=>{let n=i.useContext(ue),r=i.useRef(null),a=s(t,r);return i.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,c.jsx)(v.div,{...e,ref:a})});pe.displayName=fe;function me(e,t=globalThis?.document){let n=I(e),r=i.useRef(!1),a=i.useRef(()=>{});return i.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){_e(se,n,i,{discrete:!0})},i={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,a.current),a.current=r,t.addEventListener(`click`,a.current,{once:!0})):r()}else t.removeEventListener(`click`,a.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(i),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,a.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function he(e,t=globalThis?.document){let n=I(e),r=i.useRef(!1);return i.useEffect(()=>{let e=e=>{e.target&&!r.current&&_e(ce,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ge(){let e=new CustomEvent(oe);document.dispatchEvent(e)}function _e(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?y(i,a):i.dispatchEvent(a)}var ve=`focusScope.autoFocusOnMount`,ye=`focusScope.autoFocusOnUnmount`,be={bubbles:!1,cancelable:!0},xe=`FocusScope`,Se=i.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=e,[u,d]=i.useState(null),f=I(a),p=I(o),m=i.useRef(null),h=s(t,e=>d(e)),g=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(r){let e=function(e){if(g.paused||!u)return;let t=e.target;u.contains(t)?m.current=t:L(m.current,{select:!0})},t=function(e){if(g.paused||!u)return;let t=e.relatedTarget;t!==null&&(u.contains(t)||L(m.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&L(u)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return u&&r.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,u,g.paused]),i.useEffect(()=>{if(u){ke.add(g);let e=document.activeElement;if(!u.contains(e)){let t=new CustomEvent(ve,be);u.addEventListener(ve,f),u.dispatchEvent(t),t.defaultPrevented||(Ce(Me(Te(u)),{select:!0}),document.activeElement===e&&L(u))}return()=>{u.removeEventListener(ve,f),setTimeout(()=>{let t=new CustomEvent(ye,be);u.addEventListener(ye,p),u.dispatchEvent(t),t.defaultPrevented||L(e??document.body,{select:!0}),u.removeEventListener(ye,p),ke.remove(g)},0)}}},[u,f,p,g]);let _=i.useCallback(e=>{if(!n&&!r||g.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=we(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&L(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&L(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,g.paused]);return(0,c.jsx)(v.div,{tabIndex:-1,...l,ref:h,onKeyDown:_})});Se.displayName=xe;function Ce(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(L(r,{select:t}),document.activeElement!==n)return}function we(e){let t=Te(e);return[Ee(t,e),Ee(t.reverse(),e)]}function Te(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ee(e,t){for(let n of e)if(!De(n,{upTo:t}))return n}function De(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Oe(e){return e instanceof HTMLInputElement&&`select`in e}function L(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Oe(e)&&t&&e.select()}}var ke=Ae();function Ae(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=je(e,t),e.unshift(t)},remove(t){e=je(e,t),e[0]?.resume()}}}function je(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Me(e){return e.filter(e=>e.tagName!==`A`)}var Ne=`Portal`,Pe=i.forwardRef((e,t)=>{let{container:n,...r}=e,[a,o]=i.useState(!1);T(()=>o(!0),[]);let s=n||a&&globalThis?.document?.body;return s?_.createPortal((0,c.jsx)(v.div,{...r,ref:t}),s):null});Pe.displayName=Ne;var Fe=0;function Ie(){i.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Le()),document.body.insertAdjacentElement(`beforeend`,e[1]??Le()),Fe++,()=>{Fe===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Fe--}},[])}function Le(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var R=function(){return R=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},R.apply(this,arguments)};function Re(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function ze(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Be=`right-scroll-bar-position`,Ve=`width-before-scroll-bar`,He=`with-scroll-bars-hidden`,Ue=`--removed-body-scroll-bar-size`;function We(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Ge(e,t){var n=(0,i.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Ke=typeof window<`u`?i.useLayoutEffect:i.useEffect,qe=new WeakMap;function Je(e,t){var n=Ge(t||null,function(t){return e.forEach(function(e){return We(e,t)})});return Ke(function(){var t=qe.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||We(e,null)}),i.forEach(function(e){r.has(e)||We(e,a)})}qe.set(n,e)},[e]),n}function Ye(e){return e}function Xe(e,t){t===void 0&&(t=Ye);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Ze(e){e===void 0&&(e={});var t=Xe(null);return t.options=R({async:!0,ssr:!1},e),t}var Qe=function(e){var t=e.sideCar,n=Re(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return i.createElement(r,R({},n))};Qe.isSideCarExport=!0;function $e(e,t){return e.useMedium(t),Qe}var et=Ze(),tt=function(){},nt=i.forwardRef(function(e,t){var n=i.useRef(null),r=i.useState({onScrollCapture:tt,onWheelCapture:tt,onTouchMoveCapture:tt}),a=r[0],o=r[1],s=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=Re(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=Je([n,t]),w=R(R({},x),a);return i.createElement(i.Fragment,null,d&&i.createElement(S,{sideCar:et,removeScrollBar:u,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:o,allowPinchZoom:!!_,lockRef:n,gapMode:b}),s?i.cloneElement(i.Children.only(c),R(R({},w),{ref:C})):i.createElement(y,R({},w,{className:l,ref:C}),c))});nt.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},nt.classNames={fullWidth:Ve,zeroRight:Be};var rt,it=function(){if(rt)return rt;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function at(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=it();return t&&e.setAttribute(`nonce`,t),e}function ot(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function st(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var ct=function(){var e=0,t=null;return{add:function(n){e==0&&(t=at())&&(ot(t,n),st(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},lt=function(){var e=ct();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ut=function(){var e=lt();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},dt={left:0,top:0,right:0,gap:0},ft=function(e){return parseInt(e||``,10)||0},pt=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[ft(n),ft(r),ft(i)]},mt=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return dt;var t=pt(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ht=ut(),gt=`data-scroll-locked`,_t=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
2
2
|
.${He} {
|
|
3
3
|
overflow: hidden ${r};
|
|
4
4
|
padding-right: ${s}px ${r};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import{n
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import{t as n}from"./createLucideIcon-PuMiQgHl.js";import{t as r}from"./jsx-runtime-kMwlnEGE.js";var i=n(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]);function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a.apply(null,arguments)}function o(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var s=[],c=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?c:s).push(n+=e[t])})();function l(e){if(e<768)return!1;for(let t=0,n=s.length;;){let r=t+n>>1;if(e<s[r])n=r;else if(e>=c[r])t=r+1;else return!0;if(t==n)return!1}}function u(e){return e>=127462&&e<=127487}var d=8205;function f(e,t,n=!0,r=!0){return(n?p:m)(e,t,r)}function p(e,t,n){if(t==e.length)return t;t&&g(e.charCodeAt(t))&&_(e.charCodeAt(t-1))&&t--;let r=h(e,t);for(t+=v(r);t<e.length;){let i=h(e,t);if(r==d||i==d||n&&l(i))t+=v(i),r=i;else if(u(i)){let n=0,r=t-2;for(;r>=0&&u(h(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function m(e,t,n){for(;t>0;){let r=p(e,t-2,n);if(r<t)return r;t--}return 0}function h(e,t){let n=e.charCodeAt(t);if(!_(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return g(r)?(n-55296<<10)+(r-56320)+65536:n}function g(e){return e>=56320&&e<57344}function _(e){return e>=55296&&e<56320}function v(e){return e<65536?1:2}var y=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=T(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),x.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=T(this,e,t);let n=[];return this.decompose(e,t,n,0),x.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new w(this),i=new w(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new w(this,e)}iterRange(e,t=this.length){return new te(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ne(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new b(t):x.from(b.split(t,[]))}},b=class e extends y{constructor(e,t=S(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new re(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(ee(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=C(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=T(this,t,n);let i=C(this.text,C(r.text,ee(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):x.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
2
2
|
`){[e,t]=T(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},x=class e extends y{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&((a<=e?1:0)|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=T(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
3
3
|
`){[e,t]=T(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new b(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof b&&c&&(n=u[u.length-1])instanceof b&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new b(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};y.empty=new b([``],0);function S(e){let t=-1;for(let n of e)t+=n.length+1;return t}function C(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function ee(e,t,n){return C(e,[``],t,n)}var w=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof b?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof b?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
4
4
|
`,this;e--}else if(r instanceof b){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof b?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},te=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new w(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},ne=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(y.prototype[Symbol.iterator]=function(){return this.iter()},w.prototype[Symbol.iterator]=te.prototype[Symbol.iterator]=ne.prototype[Symbol.iterator]=function(){return this});var re=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function T(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function E(e,t,n=!0,r=!0){return f(e,t,n,r)}function ie(e){return e>=56320&&e<57344}function ae(e){return e>=55296&&e<56320}function oe(e,t){let n=e.charCodeAt(t);if(!ae(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ie(r)?(n-55296<<10)+(r-56320)+65536:n}function se(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function ce(e){return e<65536?1:2}var le=/\r\n?|\n/,ue=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(ue||={}),de=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){me(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:ge(this,e)}mapDesc(e,t=!1){return e.empty?this:he(this,e,t)}mapPos(e,t=-1,n=ue.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=ue.Simple&&c>=e&&(n==ue.TrackDel&&r<e&&c>e||n==ue.TrackBefore&&r<e||n==ue.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},fe=class e extends de{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return me(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return he(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(y.empty);r.push(a?t.slice(i,i+a):y.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:ge(this,e,!0)}map(e,t=!1){return e.empty?this:he(this,e,t,!0)}iterChanges(e,t=!1){me(this,e,t)}get desc(){return de.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new _e(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);D(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;D(n,e,t),t>0&&pe(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);D(n,e,-1),D(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:de.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&D(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?y.of(l.split(r||le)):l:y.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&D(i,e-o,-1),D(i,s-e,d),pe(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(y.empty);r[e]=y.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function D(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function pe(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(y.empty);e.push(n)}}function me(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=y.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function he(e,t,n,r=!1){let i=[],a=r?[]:null,o=new _e(e),s=new _e(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);D(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(D(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(D(i,0,o.ins),a&&pe(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;D(i,t,e<o.i?o.ins:0),a&&e<o.i&&pe(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?fe.createSet(i,a):de.create(i);else throw Error(`Mismatched change set lengths`)}function ge(e,t,n=!1){let r=[],i=n?[]:null,a=new _e(e),o=new _e(t);for(let e=!1;;)if(a.done&&o.done)return i?fe.createSet(r,i):de.create(r);else if(a.ins==0)D(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)D(r,0,o.ins,e),i&&pe(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;D(r,t,n,e),i&&n&&pe(i,r,o.text)}else o.ins==-1?(D(r,a.off?0:a.len,t,e),i&&pe(i,r,a.textBit(t))):(D(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&pe(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var _e=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?y.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?y.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},ve=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return O.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return O.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return O.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},O=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>ve.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return ve.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?ve.create(t,e,48|a):ve.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function ye(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var be=0,k=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=be++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:xe),!!t.static,t.enables)}of(e){return new Se([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Se(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Se(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function xe(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var Se=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=be++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||we(e,c)){let r=t(e);if(a?!Ce(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=Le(o,c);if(this.dependencies.every(t=>t instanceof k?o.facet(t)===e.facet(t):t instanceof De?o.field(t,!1)==e.field(t,!1):!0)||(a?Ce(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function Ce(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function we(e,t){let n=!1;for(let r of t)Ie(e,r)&1&&(n=!0);return n}function Te(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=Le(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)Ie(e,t);return e.values[o]=s(e),1},update(e,n){if(!we(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=we(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&xe(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var Ee=k.define({static:!0}),De=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(be++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(Ee).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(Ee),i=n.facet(Ee),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,Ee.of({field:this,create:e})]}get extension(){return this}},Oe={lowest:4,low:3,default:2,high:1,highest:0};function ke(e){return t=>new je(t,e)}var Ae={highest:ke(Oe.highest),high:ke(Oe.high),default:ke(Oe.default),low:ke(Oe.low),lowest:ke(Oe.lowest)},je=class{constructor(e,t){this.inner=e,this.prec=t}},Me=class e{of(e){return new Ne(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},Ne=class{constructor(e,t){this.compartment=e,this.inner=t}},Pe=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of Fe(t,n,o))e instanceof De?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,xe(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>Te(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function Fe(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof Ne&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof Ne){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof je)a(e.inner,e.prec);else if(e instanceof De)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof Se)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Oe.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,Oe.default),r.reduce((e,t)=>e.concat(t))}function Ie(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Le(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var Re=k.define(),ze=k.define({combine:e=>e.some(e=>e),static:!0}),Be=k.define({combine:e=>e.length?e[0]:void 0,static:!0}),Ve=k.define(),He=k.define(),Ue=k.define(),We=k.define({combine:e=>e.length?e[0]:!1}),Ge=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Ke}},Ke=class{of(e){return new Ge(this,e)}},qe=class{constructor(e){this.map=e}of(e){return new A(this,e)}},A=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new qe(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};A.reconfigure=A.define(),A.appendConfig=A.define();var Je=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&ye(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};Je.time=Ge.define(),Je.userEvent=Ge.define(),Je.addToHistory=Ge.define(),Je.remote=Ge.define();function Ye(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function Xe(e,t,n){let r,i,a;return n?(r=t.changes,i=fe.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:A.mapEffects(e.effects,r).concat(A.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Ze(e,t,n){let r=t.selection,i=nt(t.annotations);return t.userEvent&&(i=i.concat(Je.userEvent.of(t.userEvent))),{changes:t.changes instanceof fe?t.changes:fe.of(t.changes||[],n,e.facet(Be)),selection:r&&(r instanceof O?r:O.single(r.anchor,r.head)),effects:nt(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function Qe(e,t,n){let r=Ze(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=Xe(r,Ze(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=Je.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return et(n?$e(i):i)}function $e(e){let t=e.startState,n=!0;for(let r of t.facet(Ve)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:Ye(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=fe.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=Je.create(t,r,e.selection&&e.selection.map(i),A.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(He);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof Je?i:Array.isArray(i)&&i.length==1&&i[0]instanceof Je?i[0]:Qe(t,nt(i),!1)}return e}function et(e){let t=e.startState,n=t.facet(Ue),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=Xe(r,Ze(t,a,e.changes.newLength),!0))}return r==e?e:Je.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var tt=[];function nt(e){return e==null?tt:Array.isArray(e)?e:[e]}var j=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(j||={}),rt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,it;try{it=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function at(e){if(it)return it.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||rt.test(n)))return!0}return!1}function ot(e){return t=>{if(!/\S/.test(t))return j.Space;if(at(t))return j.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return j.Word;return j.Other}}var M=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Ie(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return Ie(this,n),Le(this,n)}update(...e){return Qe(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(Me.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(A.reconfigure)?(n=null,r=e.value):e.is(A.appendConfig)&&(n=null,r=nt(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Pe.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(ze)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:O.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=nt(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=A.mapEffects(a,c).concat(A.mapEffects(nt(o.effects),l))}return{changes:r,selection:O.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof fe?t:fe.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return y.of(t.split(this.facet(e.lineSeparator)||le))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ie(this,t),Le(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof De&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:O.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Pe.resolve(t.extensions||[],new Map),r=t.doc instanceof y?t.doc:y.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||le)),i=t.selection?t.selection instanceof O?t.selection:O.single(t.selection.anchor,t.selection.head):O.single(0);return ye(i,r.length),n.staticFacet(ze)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import{t as n}from"./jsx-runtime-kMwlnEGE.js";import{L as r}from"./index-C8byznLO.js";var i=e(t(),1),a=n(),o=`<script>
|
|
2
|
+
function acquireVsCodeApi(){return{postMessage:function(m){window.parent.postMessage(m,"*")},getState:function(){try{return JSON.parse(sessionStorage.getItem("vscode-state")||"null")}catch{return null}},setState:function(s){sessionStorage.setItem("vscode-state",JSON.stringify(s));return s}}}
|
|
3
|
+
<\/script>`;function s(e){if(!e)return e;let t=e.indexOf(`<head>`);return t===-1?o+e:e.slice(0,t+6)+o+e.slice(t+6)}function c({metadata:e}){let t=e?.panelId,n=r(e=>t?e.webviewPanels[t]:void 0),o=(0,i.useRef)(null),c=s(n?.html??``);return(0,i.useEffect)(()=>{let e=e=>{o.current&&e.source===o.current.contentWindow&&window.dispatchEvent(new CustomEvent(`ext:webview:send`,{detail:{panelId:t,message:e.data}}))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[t]),(0,i.useEffect)(()=>{let e=e=>{let{panelId:n,message:r}=e.detail;n===t&&o.current?.contentWindow?.postMessage(r,`*`)};return window.addEventListener(`ext:webview:message`,e),()=>window.removeEventListener(`ext:webview:message`,e)},[t]),n?(0,a.jsx)(`div`,{className:`h-full w-full relative`,children:(0,a.jsx)(`iframe`,{ref:o,srcDoc:c,sandbox:`allow-scripts`,className:`w-full h-full border-0 bg-white dark:bg-zinc-900`,title:n.title})}):(0,a.jsx)(`div`,{className:`flex items-center justify-center h-full text-sm text-text-subtle`,children:`Webview panel not found`})}export{c as ExtensionWebview};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import"./react-dom-Bpkvzu3U.js";import{t as n}from"./createLucideIcon-PuMiQgHl.js";import{l as r,t as i}from"./tab-store-BOgTrqRr.js";import{t as a}from"./tag-CXMT0QB6.js";import{t as o}from"./jsx-runtime-kMwlnEGE.js";import"./dist-DIV6WgAG.js";import{t as s}from"./utils-BNytJOb1.js";import{i as c,t as l}from"./api-client-BfBM3I7n.js";import{$ as u,A as d,C as f,D as p,Dt as m,Et as h,F as g,J as _,K as v,M as y,N as b,O as x,P as S,Q as C,T as w,X as T,Z as E,_t as ee,j as D,jt as O,k,lt as A,st as j,w as M,yt as N}from"./index-C8byznLO.js";var P=n(`cherry`,[[`path`,{d:`M2 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z`,key:`cvxqlc`}],[`path`,{d:`M12 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z`,key:`1ostrc`}],[`path`,{d:`M7 14c3.22-2.91 4.29-8.75 5-12 1.66 2.38 4.94 9 5 12`,key:`hqx58h`}],[`path`,{d:`M22 9c-4.29 0-7.14-2.33-10-7 5.71 0 10 4.67 10 7Z`,key:`eykp1o`}]]),F=n(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),I=e(t(),1),L=[`#0085d9`,`#d73a49`,`#6f42c1`,`#2cbe4e`,`#e36209`,`#005cc5`,`#b31d28`,`#5a32a3`,`#22863a`,`#cb2431`];function te(e){let t=new Map;if(!e)return t;let n=new Set;for(let t of e.branches)if(!t.remote)for(let e of t.remotes)n.add(`remotes/${e}/${t.name}`);for(let r of e.branches)if(r.remote){if(n.has(r.name))continue;let e=t.get(r.commitHash)??[],i=r.name.replace(/^remotes\//,``);e.push({name:i,type:`branch`,remotes:[],current:!1}),t.set(r.commitHash,e)}else{let e=t.get(r.commitHash)??[];e.push({name:r.name,type:`branch`,remotes:r.remotes,current:r.current}),t.set(r.commitHash,e)}for(let n of e.commits)for(let e of n.refs)if(e.startsWith(`tag: `)){let r=e.replace(`tag: `,``),i=t.get(n.hash)??[];i.push({name:r,type:`tag`,remotes:[],current:!1}),t.set(n.hash,i)}return t}function ne(e){let t=new Map;if(!e)return{laneMap:t,maxLane:0,unloadedParentLanes:new Map};let n=0,r=0,i=new Map,a=new Set(e.commits.map(e=>e.hash)),o=[],s=()=>o.length>0?(o.sort((e,t)=>e-t),o.shift()):n++;for(let n of e.commits){let e=i.get(n.hash);e===void 0&&(e=s()),t.set(n.hash,e),e>r&&(r=e),i.delete(n.hash);let a=!1;for(let t=0;t<n.parents.length;t++){let o=n.parents[t];if(!i.has(o))if(t===0)i.set(o,e),a=!0;else{let e=s();i.set(o,e),e>r&&(r=e)}}a||o.push(e)}let c=new Map;for(let[e,t]of i)a.has(e)||c.set(e,t);return{laneMap:t,maxLane:r,unloadedParentLanes:c}}function re(e,t,n,r){if(!e)return[];let i=[],a=new Set(e.commits.map(e=>e.hash));for(let o=0;o<e.commits.length;o++){let s=e.commits[o],c=t.get(s.hash)??0,l=L[c%L.length];for(let u of s.parents){let d=e.commits.findIndex(e=>e.hash===u);if(d>=0){let e=t.get(u)??0,n=L[e%L.length],r=c*16+16/2,a=o*24+24/2,f=e*16+16/2,p=d*24+24/2,m,h=s.parents.indexOf(u)>0;if(r===f)m=`M ${r} ${a} L ${f} ${p}`;else if(h){let e=a+24;m=`M ${r} ${a} C ${r} ${e} ${f} ${a} ${f} ${e} L ${f} ${p}`}else{let e=p-24;m=`M ${r} ${a} L ${r} ${e} C ${r} ${p} ${f} ${e} ${f} ${p}`}let g=s.parents.indexOf(u)===0?l:n;i.push({d:m,color:g})}else if(!a.has(u)){let e=n.get(u)??c,t=L[e%L.length],a=c*16+16/2,s=o*24+24/2,d=e*16+16/2;if(a===d)i.push({d:`M ${a} ${s} L ${a} ${r}`,color:l});else{let e=s+24,n=`M ${a} ${s} C ${a} ${e} ${d} ${s} ${d} ${e} L ${d} ${r}`;i.push({d:n,color:t})}}}}return i}function R(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(o/12)}y ago`}var z=200;function B(e){let[t,n]=(0,I.useState)(null),[r,a]=(0,I.useState)(!0),[o,s]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!0),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)([]),[b,x]=(0,I.useState)(!1),[S,C]=(0,I.useState)(`__all__`),[w,T]=(0,I.useState)(``),[E,ee]=(0,I.useState)(!1),{openTab:D}=i(),O=(0,I.useRef)(0),k=(0,I.useCallback)(async()=>{if(e)try{a(!0);let t=Math.max(z,O.current),r=await l.get(`${c(e)}/git/graph?max=${t}`);n(r),O.current=r.commits.length,d(r.commits.length>=t),p(null)}catch(e){p(e instanceof Error?e.message:`Failed to fetch graph`)}finally{a(!1)}},[e]),A=(0,I.useCallback)(async()=>{if(!(!e||o||!u))try{s(!0);let t=O.current,r=await l.get(`${c(e)}/git/graph?max=${z}&skip=${t}`);if(r.commits.length===0){d(!1);return}n(e=>{if(!e)return r;let t=new Set(e.commits.map(e=>e.hash)),n=r.commits.filter(e=>!t.has(e.hash)),i=new Set(e.branches.map(e=>e.name)),a=r.branches.filter(e=>!i.has(e.name));return{commits:[...e.commits,...n],branches:[...e.branches,...a],head:e.head}}),O.current=t+r.commits.length,d(r.commits.length>=z)}catch(e){p(e instanceof Error?e.message:`Failed to load more`)}finally{s(!1)}},[e,o,u]);(0,I.useEffect)(()=>{k();let e=setInterval(k,1e4);return()=>clearInterval(e)},[k]);let j=async(t,n)=>{if(e){h(!0);try{await l.post(`${c(e)}${t}`,n),await k()}catch(e){p(e instanceof Error?e.message:`Action failed`)}finally{h(!1)}}},M=()=>j(`/git/fetch`,{}),N=e=>j(`/git/checkout`,{ref:e}),P=e=>j(`/git/cherry-pick`,{hash:e}),F=e=>j(`/git/revert`,{hash:e}),L=e=>j(`/git/merge`,{source:e}),R=e=>j(`/git/branch/delete`,{name:e}),B=e=>j(`/git/push`,{branch:e}),V=(e,t)=>j(`/git/tag`,{name:e,hash:t}),H=e=>navigator.clipboard.writeText(e),U=async(e,n)=>{if(t?.branches.some(t=>t.name===e||t.name.endsWith(`/${e}`))){if(!window.confirm(`Branch "${e}" already exists.\nDelete and recreate from this commit?`))return;await j(`/git/branch/delete`,{name:e})}await j(`/git/branch/create`,{name:e,from:n})},W=async t=>{if(e)try{let n=await l.get(`${c(e)}/git/pr-url?branch=${encodeURIComponent(t)}`);n.url&&window.open(n.url,`_blank`)}catch{}},G=async t=>{if(g?.hash===t.hash){_(null);return}_(t),x(!0);try{let n=t.parents[0]??``,r=n?`ref1=${encodeURIComponent(n)}&`:``,i=await l.get(`${c(e)}/git/diff-stat?${r}ref2=${encodeURIComponent(t.hash)}`);y(Array.isArray(i)?i:[])}catch{y([])}finally{x(!1)}},K=t=>D({type:`git-diff`,title:`Diff ${t.abbreviatedHash}`,closable:!0,metadata:{projectName:e,ref1:t.parents[0]??void 0,ref2:t.hash},projectId:e??null}),q=(0,I.useMemo)(()=>te(t),[t]),J=t?.branches.find(e=>e.current),Y=t?.head??``,X=(0,I.useMemo)(()=>{if(!t)return[];let e=t.commits;if(S!==`__all__`){let n=t.branches.find(e=>e.name===S);if(n){let r=new Set,i=[n.commitHash];for(;i.length>0;){let e=i.pop();if(r.has(e))continue;r.add(e);let n=t.commits.find(t=>t.hash===e);n&&i.push(...n.parents)}e=e.filter(e=>r.has(e.hash))}}if(w.trim()){let t=w.toLowerCase();e=e.filter(e=>e.subject.toLowerCase().includes(t)||e.authorName.toLowerCase().includes(t)||e.abbreviatedHash.includes(t)||e.hash.includes(t))}return e},[t,S,w]),Z=(0,I.useMemo)(()=>t?{...t,commits:X}:null,[t,X]),Q=(0,I.useMemo)(()=>ne(Z),[Z]),$=X.length*24+48;return{data:t,loading:r,loadingMore:o,hasMore:u,error:f,acting:m,selectedCommit:g,setSelectedCommit:_,commitFiles:v,loadingDetail:b,branchFilter:S,setBranchFilter:C,searchQuery:w,setSearchQuery:T,showSearch:E,setShowSearch:ee,fetchGraph:k,fetchFromRemotes:M,loadMore:A,handleCheckout:N,handleCherryPick:P,handleRevert:F,handleMerge:L,handleDeleteBranch:R,handlePushBranch:B,handleCreateBranch:U,handleCreateTag:V,handleCreatePr:W,copyHash:H,selectCommit:G,openDiffForCommit:K,commitLabels:q,currentBranch:J,headHash:Y,filteredCommits:X,filteredLanes:Q,svgHeight:$,svgPaths:(0,I.useMemo)(()=>re(Z,Q.laneMap,Q.unloadedParentLanes,$),[Z,Q.laneMap,Q.unloadedParentLanes,$])}}function V(e){let[t,n]=(0,I.useState)(e),r=(0,I.useRef)(e);r.current=t;let i=(0,I.useRef)(!1);return{widths:t,startResize:(e,t)=>{i.current=!0;let a=r.current[e]??80,o=r=>{if(!i.current)return;let o=`touches`in r?r.touches[0].clientX:r.clientX,s=Math.max(40,a+o-t);n(t=>({...t,[e]:s}))},s=()=>{i.current=!1,window.removeEventListener(`mousemove`,o),window.removeEventListener(`mouseup`,s),window.removeEventListener(`touchmove`,o),window.removeEventListener(`touchend`,s)};window.addEventListener(`mousemove`,o),window.addEventListener(`mouseup`,s),window.addEventListener(`touchmove`,o,{passive:!1}),window.addEventListener(`touchend`,s)}}}var H=o();function U({branches:e,branchFilter:t,onBranchFilterChange:n,searchQuery:r,onSearchQueryChange:i,showSearch:a,onToggleSearch:o,onFetch:s,onRefresh:c,onOpenSettings:l,loading:p,acting:m,projectName:g}){let _=e.filter(e=>!e.remote),[y,b]=(0,I.useState)(!1),[x,S]=(0,I.useState)(``),C=(0,I.useRef)(null);(0,I.useEffect)(()=>{if(!y)return;let e=e=>{C.current&&!C.current.contains(e.target)&&(b(!1),S(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[y]);let w=x?_.filter(e=>e.name.toLowerCase().includes(x.toLowerCase())):_,D=t===`__all__`?`Show All`:_.find(e=>e.name===t)?.name??`Show All`;return(0,H.jsx)(`div`,{className:`border-b bg-background`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground shrink-0`,children:[(0,H.jsx)(`span`,{className:`font-semibold`,children:`Repo:`}),(0,H.jsx)(`span`,{className:`font-medium text-foreground truncate max-w-[120px]`,children:g??`—`})]}),(0,H.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`}),(0,H.jsxs)(`div`,{className:`relative shrink-0`,ref:C,children:[(0,H.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 h-6 px-2 text-xs border rounded-md bg-transparent hover:bg-muted/50`,onClick:()=>{b(e=>!e),S(``)},children:[(0,H.jsx)(`span`,{className:`font-semibold text-muted-foreground`,children:`Branches:`}),(0,H.jsx)(`span`,{className:`max-w-[100px] truncate`,children:D}),(0,H.jsx)(h,{className:`size-3 opacity-50`})]}),y&&(0,H.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 z-50 w-[220px] rounded-md border bg-popover shadow-md`,children:[(0,H.jsx)(`div`,{className:`p-1.5`,children:(0,H.jsx)(f,{className:`h-6 text-xs px-2`,placeholder:`Filter branches...`,value:x,onChange:e=>S(e.target.value),autoFocus:!0})}),(0,H.jsxs)(`div`,{className:`max-h-[200px] overflow-y-auto p-1`,children:[(0,H.jsx)(W,{label:`Show All`,selected:t===`__all__`,onClick:()=>{n(`__all__`),b(!1)}}),w.map(e=>(0,H.jsx)(W,{label:e.name,current:e.current,selected:t===e.name,onClick:()=>{n(e.name),b(!1)}},e.name)),w.length===0&&x&&(0,H.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`})]})]})]}),(0,H.jsx)(`div`,{className:`flex-1`}),a&&(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(f,{className:`h-6 text-xs w-[160px] px-2`,placeholder:`Search commits...`,value:r,onChange:e=>i(e.target.value),autoFocus:!0}),(0,H.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:o,children:(0,H.jsx)(v,{className:`size-3`})})]}),!a&&(0,H.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:o,title:`Find`,children:(0,H.jsx)(E,{className:`size-3.5`})}),(0,H.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:l,title:`Settings`,children:(0,H.jsx)(T,{className:`size-3.5`})}),(0,H.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:s,disabled:m,title:`Fetch`,children:(0,H.jsx)(ee,{className:`size-3.5`})}),(0,H.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:c,disabled:m,title:`Refresh`,children:(0,H.jsx)(u,{className:`size-3.5 ${p?`animate-spin`:``}`})})]})})}function W({label:e,selected:t,current:n,onClick:r}){return(0,H.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full px-2 py-1 text-xs rounded-sm hover:bg-accent hover:text-accent-foreground text-left`,onClick:r,children:[(0,H.jsx)(m,{className:`size-3 shrink-0 ${t?`opacity-100`:`opacity-0`}`}),(0,H.jsx)(`span`,{className:`truncate flex-1`,children:e}),n&&(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground italic`,children:`current`})]})}function G({commits:e,laneMap:t,svgPaths:n,width:r,height:i,headHash:a}){return(0,H.jsxs)(`svg`,{width:r,height:i,children:[n.map((e,t)=>(0,H.jsx)(`path`,{d:e.d,stroke:e.color,strokeWidth:2,fill:`none`},t)),e.map((e,n)=>{let r=t.get(e.hash)??0,i=r*16+16/2,o=n*24+24/2,s=L[r%L.length],c=e.hash===a;return(0,H.jsx)(`circle`,{cx:i,cy:o,r:c?5:4,fill:s,stroke:c?`#000`:`none`,strokeWidth:c?2:0},e.hash)})]})}function K({name:e,type:t,remotes:n,isCurrent:i,color:o,currentBranch:s,onCheckout:c,onMerge:l,onPush:u,onCreatePr:d,onDelete:f}){return t===`tag`?(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 bg-amber-500/20 text-amber-500 border border-amber-500/30`,children:[(0,H.jsx)(a,{className:`size-2.5`}),e]}):(0,H.jsxs)(D,{children:[(0,H.jsx)(g,{asChild:!0,children:(0,H.jsxs)(`span`,{className:`inline-flex items-center rounded text-[10px] font-medium shrink-0 cursor-context-menu overflow-hidden`,style:{border:i?`1.5px solid ${o}`:`1px solid ${o}50`},children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5`,style:{backgroundColor:i?o:`${o}30`,color:i?`#fff`:o},children:[(0,H.jsx)(A,{className:`size-2.5`}),e]}),n.map(e=>(0,H.jsx)(`span`,{className:`px-1.5 py-0.5 italic opacity-70`,style:{borderLeft:`1px solid ${o}40`,color:o,backgroundColor:`${o}15`},children:e},e))]})}),(0,H.jsxs)(y,{children:[(0,H.jsx)(b,{onClick:()=>c(e),children:`Checkout`}),(0,H.jsxs)(b,{onClick:()=>l(e),disabled:e===s?.name,children:[(0,H.jsx)(F,{className:`size-3`}),`Merge into current`]}),(0,H.jsx)(S,{}),(0,H.jsxs)(b,{onClick:()=>u(e),children:[(0,H.jsx)(O,{className:`size-3`}),`Push`]}),(0,H.jsxs)(b,{onClick:()=>d(e),children:[(0,H.jsx)(r,{className:`size-3`}),`Create PR`]}),(0,H.jsx)(S,{}),(0,H.jsxs)(b,{variant:`destructive`,onClick:()=>f(e),disabled:e===s?.name,children:[(0,H.jsx)(_,{className:`size-3`}),`Delete`]})]})]})}function q({commit:e,lane:t,isSelected:n,isHead:r,labels:i,currentBranch:o,onSelect:s,onCheckout:c,onCherryPick:l,onRevert:u,onMerge:d,onDeleteBranch:f,onPushBranch:p,onCreatePr:m,onOpenCreateBranch:h,onOpenCreateTag:_,onOpenDiff:v,onCopyHash:x}){let w=L[t%L.length],T=i.filter(e=>e.type===`branch`),E=i.filter(e=>e.type===`tag`);return(0,H.jsxs)(D,{children:[(0,H.jsx)(g,{asChild:!0,children:(0,H.jsxs)(`tr`,{className:`hover:bg-muted/50 cursor-pointer border-b border-border/20 ${n?`bg-primary/10`:``} ${r?`font-medium`:``}`,style:{height:`24px`},onClick:s,children:[(0,H.jsx)(`td`,{className:`px-2 truncate max-w-0`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[T.map(e=>(0,H.jsx)(K,{name:e.name,type:`branch`,remotes:e.remotes,isCurrent:e.current,color:w,currentBranch:o,onCheckout:c,onMerge:d,onPush:p,onCreatePr:m,onDelete:f},`branch-${e.name}`)),E.map(e=>(0,H.jsx)(K,{name:e.name,type:`tag`,remotes:[],isCurrent:!1,color:w,currentBranch:o,onCheckout:c,onMerge:d,onPush:p,onCreatePr:m,onDelete:f},`tag-${e.name}`)),(0,H.jsx)(`span`,{className:`truncate text-xs`,children:e.subject})]})}),(0,H.jsx)(`td`,{className:`px-2 text-xs text-muted-foreground whitespace-nowrap shrink-0`,children:R(e.authorDate)}),(0,H.jsx)(`td`,{className:`px-2 text-xs text-muted-foreground truncate max-w-[120px]`,children:e.authorName}),(0,H.jsx)(`td`,{className:`px-2 text-xs text-muted-foreground font-mono whitespace-nowrap`,children:e.abbreviatedHash})]})}),(0,H.jsxs)(y,{children:[(0,H.jsx)(b,{onClick:()=>c(e.hash),children:`Checkout`}),(0,H.jsxs)(b,{onClick:()=>h(e.hash),children:[(0,H.jsx)(A,{className:`size-3`}),`Create Branch...`]}),(0,H.jsx)(S,{}),(0,H.jsxs)(b,{onClick:()=>l(e.hash),children:[(0,H.jsx)(P,{className:`size-3`}),`Cherry Pick`]}),(0,H.jsxs)(b,{onClick:()=>u(e.hash),children:[(0,H.jsx)(C,{className:`size-3`}),`Revert`]}),(0,H.jsxs)(b,{onClick:()=>_(e.hash),children:[(0,H.jsx)(a,{className:`size-3`}),`Create Tag...`]}),(0,H.jsx)(S,{}),(0,H.jsx)(b,{onClick:v,children:`View Diff`}),(0,H.jsxs)(b,{onClick:x,children:[(0,H.jsx)(N,{className:`size-3`}),`Copy Hash`]})]})]})}function J({commit:e,files:t,loadingDetail:n,projectName:r,onClose:a,copyHash:o}){let{openTab:c}=i();return(0,H.jsxs)(`div`,{className:`border-t bg-muted/30 max-h-[40%] overflow-auto`,children:[(0,H.jsxs)(`div`,{className:`px-3 py-2 border-b flex items-center justify-between`,children:[(0,H.jsxs)(`span`,{className:`text-sm font-medium truncate`,children:[e.abbreviatedHash,` — `,e.subject]}),(0,H.jsx)(d,{variant:`ghost`,size:`icon-xs`,onClick:a,children:`✕`})]}),(0,H.jsxs)(`div`,{className:`px-3 py-2 text-xs space-y-1`,children:[(0,H.jsxs)(`div`,{className:`flex gap-4`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground w-12 shrink-0`,children:`Author`}),(0,H.jsxs)(`span`,{children:[e.authorName,` <`,e.authorEmail,`>`]})]}),(0,H.jsxs)(`div`,{className:`flex gap-4`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground w-12 shrink-0`,children:`Date`}),(0,H.jsx)(`span`,{children:new Date(e.authorDate).toLocaleString()})]}),(0,H.jsxs)(`div`,{className:`flex gap-4`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground w-12 shrink-0`,children:`Hash`}),(0,H.jsx)(`span`,{className:`font-mono cursor-pointer hover:text-primary`,onClick:()=>o(e.hash),children:e.hash})]}),e.parents.length>0&&(0,H.jsxs)(`div`,{className:`flex gap-4`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground w-12 shrink-0`,children:`Parents`}),(0,H.jsx)(`span`,{className:`font-mono`,children:e.parents.map(e=>e.slice(0,7)).join(`, `)})]}),e.body&&(0,H.jsx)(`div`,{className:`mt-2 p-2 bg-background rounded text-xs whitespace-pre-wrap`,children:e.body})]}),(0,H.jsxs)(`div`,{className:`px-3 py-1 border-t`,children:[(0,H.jsx)(`div`,{className:`text-xs text-muted-foreground py-1`,children:n?`Loading files...`:`${t.length} file${t.length===1?``:`s`} changed`}),t.map(t=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-xs hover:bg-muted/50 rounded px-1 cursor-pointer`,onClick:()=>c({type:`git-diff`,title:`Diff ${s(t.path)}`,closable:!0,metadata:{projectName:r,ref1:e.parents[0]??void 0,ref2:e.hash,filePath:t.path},projectId:r}),children:[(0,H.jsx)(`span`,{className:`flex-1 truncate font-mono`,children:t.path}),t.additions>0&&(0,H.jsxs)(`span`,{className:`text-green-500`,children:[`+`,t.additions]}),t.deletions>0&&(0,H.jsxs)(`span`,{className:`text-red-500`,children:[`-`,t.deletions]})]},t.path))]})]})}function Y({type:e,hash:t,onClose:n,onCreateBranch:r,onCreateTag:i}){let[a,o]=(0,I.useState)(``),s=()=>{a.trim()&&(e===`branch`?r(a.trim(),t):i(a.trim(),t),n())};return(0,H.jsx)(M,{open:e!==null,onOpenChange:e=>{e||n()},children:(0,H.jsxs)(w,{children:[(0,H.jsx)(x,{children:(0,H.jsx)(k,{children:e===`branch`?`Create Branch`:`Create Tag`})}),(0,H.jsx)(f,{placeholder:e===`branch`?`Branch name`:`Tag name`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s()},autoFocus:!0}),(0,H.jsxs)(p,{children:[(0,H.jsx)(d,{variant:`outline`,onClick:n,children:`Cancel`}),(0,H.jsx)(d,{disabled:!a.trim(),onClick:s,children:`Create`})]})]})})}function X({open:e,onClose:t,projectName:n,branches:r}){let i=r.filter(e=>!e.remote),a=r.filter(e=>e.remote),o=new Map;for(let e of a){let t=e.name.replace(/^remotes\//,``),n=t.indexOf(`/`);if(n<0)continue;let r=t.slice(0,n),i=t.slice(n+1),a=o.get(r)??[];a.push(i),o.set(r,a)}return(0,H.jsx)(M,{open:e,onOpenChange:e=>{e||t()},children:(0,H.jsxs)(w,{className:`max-w-md`,children:[(0,H.jsx)(x,{children:(0,H.jsx)(k,{children:`Repository Settings`})}),(0,H.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,H.jsxs)(Z,{title:`General`,children:[(0,H.jsx)(Q,{label:`Name`,value:n}),(0,H.jsx)(Q,{label:`Branches`,value:`${i.length} local, ${a.length} remote`})]}),(0,H.jsx)(Z,{title:`Local Branches`,children:i.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5`,children:[(0,H.jsx)(`span`,{className:`text-xs ${e.current?`font-semibold text-primary`:`text-foreground`}`,children:e.name}),e.current&&(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground italic`,children:`HEAD`}),e.remotes.length>0&&(0,H.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,e.remotes.join(`, `),`)`]})]},e.name))}),(0,H.jsxs)(Z,{title:`Remotes`,children:[[...o.entries()].map(([e,t])=>(0,H.jsxs)(`div`,{className:`py-0.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,H.jsxs)(`span`,{className:`text-[10px] text-muted-foreground ml-2`,children:[t.length,` branch`,t.length===1?``:`es`]})]},e)),o.size===0&&(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`No remotes configured`})]})]})]})})}function Z({title:e,children:t}){return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1.5`,children:e}),(0,H.jsx)(`div`,{className:`pl-1`,children:t})]})}function Q({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`flex items-center gap-3 py-0.5`,children:[(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground w-16 shrink-0`,children:e}),(0,H.jsx)(`span`,{className:`text-xs`,children:t})]})}function $({metadata:e}){let t=e?.projectName,n=B(t),[r,i]=(0,I.useState)({type:null}),[a,o]=(0,I.useState)(!1),s=(typeof window<`u`&&window.innerWidth<768?6:10)*16+16,[c,l]=(0,I.useState)(s),u=(0,I.useRef)(s);u.current=c;let d=(0,I.useRef)(!1),f=e=>{d.current=!0;let t=u.current,n=n=>{if(!d.current)return;let r=`touches`in n?n.touches[0].clientX:n.clientX;l(Math.max(40,t+r-e))},r=()=>{d.current=!1,window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r),window.removeEventListener(`touchmove`,n),window.removeEventListener(`touchend`,r)};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r),window.addEventListener(`touchmove`,n,{passive:!1}),window.addEventListener(`touchend`,r)},{widths:p,startResize:m}=V({date:80,author:120,commit:70}),h=(0,I.useRef)(n.loadMore);h.current=n.loadMore;let g=(0,I.useCallback)(e=>{let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<200&&h.current()},[]);return t?n.loading&&!n.data?(0,H.jsx)(oe,{}):n.error&&!n.data?(0,H.jsx)(se,{error:n.error,onRetry:n.fetchGraph}):(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(U,{branches:n.data?.branches??[],branchFilter:n.branchFilter,onBranchFilterChange:n.setBranchFilter,searchQuery:n.searchQuery,onSearchQueryChange:n.setSearchQuery,showSearch:n.showSearch,onToggleSearch:()=>n.setShowSearch(!n.showSearch),onFetch:n.fetchFromRemotes,onRefresh:n.fetchGraph,onOpenSettings:()=>o(!0),loading:n.loading,acting:n.acting,projectName:t}),n.error&&(0,H.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10`,children:n.error}),(0,H.jsx)(`div`,{className:`flex-1 overflow-auto`,onScroll:g,children:(0,H.jsxs)(`div`,{className:`flex min-w-max md:min-w-0`,children:[(0,H.jsxs)(`div`,{className:`sticky left-0 z-10 shrink-0 bg-background relative overflow-hidden`,style:{width:`${c}px`},children:[(0,H.jsx)(`div`,{className:`text-[11px] font-semibold text-muted-foreground px-2 border-b bg-background sticky top-0 z-20`,style:{height:`24px`,lineHeight:`24px`},children:`Graph`}),(0,H.jsx)(G,{commits:n.filteredCommits,laneMap:n.filteredLanes.laneMap,svgPaths:n.svgPaths,width:(n.filteredLanes.maxLane+2)*16,height:n.svgHeight,headHash:n.headHash}),(0,H.jsx)(`div`,{className:`absolute top-0 right-0 w-1.5 h-full cursor-col-resize hover:bg-primary/30`,onMouseDown:e=>{e.preventDefault(),f(e.clientX)},onTouchStart:e=>f(e.touches[0].clientX)})]}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-[400px]`,children:[(0,H.jsxs)(`table`,{className:`w-full border-collapse text-xs`,style:{tableLayout:`fixed`},children:[(0,H.jsxs)(`colgroup`,{children:[(0,H.jsx)(`col`,{}),(0,H.jsx)(`col`,{style:{width:`${p.date}px`}}),(0,H.jsx)(`col`,{style:{width:`${p.author}px`}}),(0,H.jsx)(`col`,{style:{width:`${p.commit}px`}})]}),(0,H.jsx)(`thead`,{className:`sticky top-0 z-10 bg-background`,children:(0,H.jsxs)(`tr`,{className:`border-b text-[11px] font-semibold text-muted-foreground`,style:{height:`24px`},children:[(0,H.jsx)(`th`,{className:`text-left px-2 font-semibold`,children:`Description`}),(0,H.jsx)(ie,{label:`Date`,colKey:`date`,onStartResize:m}),(0,H.jsx)(ie,{label:`Author`,colKey:`author`,onStartResize:m}),(0,H.jsx)(`th`,{className:`text-left px-2 font-semibold`,children:`Commit`})]})}),(0,H.jsx)(`tbody`,{children:n.filteredCommits.map(e=>(0,H.jsx)(q,{commit:e,lane:n.filteredLanes.laneMap.get(e.hash)??0,isSelected:n.selectedCommit?.hash===e.hash,isHead:e.hash===n.headHash,labels:n.commitLabels.get(e.hash)??[],currentBranch:n.currentBranch,onSelect:()=>n.selectCommit(e),onCheckout:n.handleCheckout,onCherryPick:n.handleCherryPick,onRevert:n.handleRevert,onMerge:n.handleMerge,onDeleteBranch:n.handleDeleteBranch,onPushBranch:n.handlePushBranch,onCreatePr:n.handleCreatePr,onOpenCreateBranch:e=>i({type:`branch`,hash:e}),onOpenCreateTag:e=>i({type:`tag`,hash:e}),onOpenDiff:()=>n.openDiffForCommit(e),onCopyHash:()=>n.copyHash(e.hash)},e.hash))})]}),n.loadingMore&&(0,H.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-3 text-xs text-muted-foreground`,children:[(0,H.jsx)(j,{className:`size-3.5 animate-spin`}),` Loading more commits...`]}),!n.hasMore&&n.data&&n.data.commits.length>0&&(0,H.jsxs)(`div`,{className:`text-center py-2 text-xs text-muted-foreground`,children:[n.data.commits.length,` commits loaded`]})]})]})}),n.selectedCommit&&t&&(0,H.jsx)(J,{commit:n.selectedCommit,files:n.commitFiles,loadingDetail:n.loadingDetail,projectName:t,onClose:()=>n.setSelectedCommit(null),copyHash:n.copyHash}),(0,H.jsx)(Y,{type:r.type,hash:r.hash,onClose:()=>i({type:null}),onCreateBranch:n.handleCreateBranch,onCreateTag:n.handleCreateTag}),(0,H.jsx)(X,{open:a,onClose:()=>o(!1),projectName:t,branches:n.data?.branches??[]})]}):(0,H.jsx)(ae,{msg:`No project selected.`})}function ie({label:e,colKey:t,onStartResize:n}){return(0,H.jsxs)(`th`,{className:`text-left px-2 font-semibold relative`,children:[e,(0,H.jsx)(`div`,{className:`absolute top-0 right-0 w-1.5 h-full cursor-col-resize hover:bg-primary/30`,onMouseDown:e=>{e.preventDefault(),n(t,e.clientX)},onTouchStart:e=>n(t,e.touches[0].clientX)})]})}function ae({msg:e}){return(0,H.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e})}function oe(){return(0,H.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,H.jsx)(j,{className:`size-5 animate-spin`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Loading git graph...`})]})}function se({error:e,onRetry:t}){return(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-destructive text-sm`,children:[(0,H.jsx)(`p`,{children:e}),(0,H.jsx)(d,{variant:`outline`,size:`sm`,onClick:t,children:`Retry`})]})}export{$ as GitGraph};
|