@bendyline/gezel-service 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NOTICE.md +3 -3
- package/dist/bin/gezeld.js +8471 -5311
- package/dist/handboek-content/technical/building-connected-apps-with-gezel-app-sdk.md +78 -0
- package/dist/handboek-content/whats-new/{1.26250.md → 1.26251.md} +5 -5
- package/dist/index-store/static-index-worker.js +160 -51
- package/dist/index.d.ts +416 -71
- package/dist/index.js +8465 -5305
- package/dist/memory/embed-worker.js +132 -4
- package/dist/memory/image-embed-worker.js +14 -5
- package/dist/providers/mlx/python/cache_persist.py +52 -8
- package/dist/providers/mlx/python/gezel_mlx_server.py +44 -1
- package/dist/providers/mlx/python/qwen4_ple.py +159 -0
- package/dist/providers/mlx/python/spec_decode.py +73 -31
- package/dist/providers/mlx/python/tool_call_stream.py +10 -2
- package/dist/providers/mlx/python/tool_grammar.py +16 -0
- package/dist/ui/assets/{AmbientDashboardCard-DcVHxEdC.js → AmbientDashboardCard-_xnAQGnk.js} +1 -1
- package/dist/ui/assets/{AudioEngineSettings-BFM2S1mm.js → AudioEngineSettings-CgXgbX0i.js} +1 -1
- package/dist/ui/assets/{BenchmarksView-84-YeULA.js → BenchmarksView-BlExZpYA.js} +1 -1
- package/dist/ui/assets/CatalogBrowser-DYXUZQ_t.js +1 -0
- package/dist/ui/assets/{ChannelsSettings-7NAVUk4k.js → ChannelsSettings-EH27HcqZ.js} +1 -1
- package/dist/ui/assets/ChatTimelineView-Dn1TNyVn.js +7 -0
- package/dist/ui/assets/{ConnectedAppsPanel-CIgF4Q3R.js → ConnectedAppsPanel-BROry-Y0.js} +1 -1
- package/dist/ui/assets/CraftbookEditor-B2RNJnFf.js +1 -0
- package/dist/ui/assets/{CraftbookScriptEditorView-Ck5tzj3Y.js → CraftbookScriptEditorView-B-vySmHP.js} +1 -1
- package/dist/ui/assets/{CraftbookTabContent-BWg7FhK_.js → CraftbookTabContent-BW_2KC89.js} +1 -1
- package/dist/ui/assets/{CraftbookToolsetSetup-EuFOiUzR.js → CraftbookToolsetSetup-J7rEa835.js} +1 -1
- package/dist/ui/assets/{CraftbooksView-BIzQ1VVn.js → CraftbooksView-BjBUWPGF.js} +1 -1
- package/dist/ui/assets/DiffpackReviewView-CD4qJmgT.js +1 -0
- package/dist/ui/assets/DocumentDetail-SYozruTJ.js +1 -0
- package/dist/ui/assets/DocumentsView-DE7eL49Z.js +1 -0
- package/dist/ui/assets/{Ds4Settings-9soZCSeO.js → Ds4Settings-DGzc7JcD.js} +1 -1
- package/dist/ui/assets/{EmbeddedChat-Cce7nxXT.js → EmbeddedChat-D92TaJQ8.js} +1 -1
- package/dist/ui/assets/{FaceRecognitionCard-BVZyOwB8.js → FaceRecognitionCard-CB1Dt9X4.js} +1 -1
- package/dist/ui/assets/FileMapView-kVBG22FU.js +1 -0
- package/dist/ui/assets/FoldersSettings-BWFQU5B4.js +1 -0
- package/dist/ui/assets/GezelDetail-Br4v42Nv.js +1 -0
- package/dist/ui/assets/{GezelJsonEditor-DXXt165-.js → GezelJsonEditor-B9XEiW5Y.js} +1 -1
- package/dist/ui/assets/GezellenView-DheEBAy4.js +1 -0
- package/dist/ui/assets/{GildeUpdatesCard-CtY8mUTA.js → GildeUpdatesCard-BeIYv09f.js} +1 -1
- package/dist/ui/assets/{GithubSignInChip-DT3l6E0Q.js → GithubSignInChip-eEGCe9ar.js} +1 -1
- package/dist/ui/assets/{HandboekMediaProvider-ByJ4NAzz.js → HandboekMediaProvider-D0zcbbpf.js} +1 -1
- package/dist/ui/assets/HandboekView-p0BZT1rH.js +1 -0
- package/dist/ui/assets/{HistoryView-CkinzFEC.js → HistoryView-CKWcWW-Y.js} +1 -1
- package/dist/ui/assets/{HomeView-DNBrQnwy.js → HomeView-b_TT5oV3.js} +1 -1
- package/dist/ui/assets/{ImageEngineSettings-BfM9HSd_.js → ImageEngineSettings-CJfk4OJ4.js} +1 -1
- package/dist/ui/assets/{ImageRecognitionSettings-CaSQu5Br.js → ImageRecognitionSettings-DzbvZk5S.js} +1 -1
- package/dist/ui/assets/{IncompleteDownloads-C36lTCMG.js → IncompleteDownloads-C8_XyP8O.js} +1 -1
- package/dist/ui/assets/{KnowledgeCatalogsCard-CK9bqdf6.js → KnowledgeCatalogsCard-CHopG_j-.js} +1 -1
- package/dist/ui/assets/KnowledgeView-CXNKZUJq.js +1 -0
- package/dist/ui/assets/{LlamaCppSettings-CdNMHBbp.js → LlamaCppSettings-ohcM7kes.js} +1 -1
- package/dist/ui/assets/{MarkdownField-Dugmfr_e.js → MarkdownField-BX0qsaFq.js} +1 -1
- package/dist/ui/assets/{MemoriesTree-CgFqUNEr.js → MemoriesTree-BPj5Rod8.js} +1 -1
- package/dist/ui/assets/{MicrophoneSettings-DzDe9y1q.js → MicrophoneSettings-CWjeYnfI.js} +1 -1
- package/dist/ui/assets/MlxSettings-Dq6dRpcl.js +1 -0
- package/dist/ui/assets/{ModelPicker-BVkJhNAH.js → ModelPicker-0Ue-eEKj.js} +1 -1
- package/dist/ui/assets/NewPathDialog-BhAZm9dp.js +1 -0
- package/dist/ui/assets/{NewScriptDialog-TEAd0KLl.js → NewScriptDialog-DuryIe50.js} +1 -1
- package/dist/ui/assets/NewTaskDialog-BX24flMY.js +2 -0
- package/dist/ui/assets/{OllamaSettings-CPy2vxyZ.js → OllamaSettings-Boj8Nd1G.js} +1 -1
- package/dist/ui/assets/ProjectChat-Dhw_M5bq.js +5 -0
- package/dist/ui/assets/ProjectConnectionsTab-BwpMQNrg.js +1 -0
- package/dist/ui/assets/{ProjectGitStatusBar-BgHZ2ijN.js → ProjectGitStatusBar-BORGYx5l.js} +1 -1
- package/dist/ui/assets/{ProjectGithubView-BV2uTNU0.js → ProjectGithubView-CTP1BOMv.js} +1 -1
- package/dist/ui/assets/{ProjectMailTab-DLtJdXSL.js → ProjectMailTab-qFmAeV3M.js} +1 -1
- package/dist/ui/assets/{ProjectOverviewView-ZMs9nL5N.js → ProjectOverviewView-Cq1FsoaT.js} +1 -1
- package/dist/ui/assets/{ProjectTimeline-CTPcn4Kc.js → ProjectTimeline-Cqae2Z92.js} +1 -1
- package/dist/ui/assets/ProjectsView-D0uJjUB-.js +7 -0
- package/dist/ui/assets/{RecommendedBadge-iUoisQBi.js → RecommendedBadge-CN1jEmSn.js} +1 -1
- package/dist/ui/assets/{RemoteServersPanel-CTVJ0IRh.js → RemoteServersPanel-CMakvCCM.js} +1 -1
- package/dist/ui/assets/{ScriptEditorTabs-CCDFZjdC.js → ScriptEditorTabs-st6dJePd.js} +2 -2
- package/dist/ui/assets/{ScriptEditorView-CergLqKj.js → ScriptEditorView-BkySh57_.js} +2 -2
- package/dist/ui/assets/{ScriptsView-v7ckdhDi.js → ScriptsView-7uPKwjDB.js} +1 -1
- package/dist/ui/assets/{SecurityComplianceSettings-Bd0-66Gs.js → SecurityComplianceSettings-Tsv_pXfy.js} +1 -1
- package/dist/ui/assets/SessionSwitcher-D0fSeeHO.js +1 -0
- package/dist/ui/assets/SettingsView-cli_z8ZW.js +3 -0
- package/dist/ui/assets/{SquisqIntegration-C5l_OPvD.js → SquisqIntegration-BTZ1kBlg.js} +1 -1
- package/dist/ui/assets/{StorageCleanupDialog-3kv9-2mT.js → StorageCleanupDialog-CDBjl8JQ.js} +1 -1
- package/dist/ui/assets/{StorageUsageCard-7sWTrZFa.js → StorageUsageCard-DXY1j0dZ.js} +1 -1
- package/dist/ui/assets/TaskTabContent-C0P681SL.js +1 -0
- package/dist/ui/assets/TasksView-Ddwz10ri.js +1 -0
- package/dist/ui/assets/{TerminalCodeEditor-ChmdzmCz.js → TerminalCodeEditor-BkNQ6QoQ.js} +2 -2
- package/dist/ui/assets/ToolsetsEditor-KVigemfL.js +8 -0
- package/dist/ui/assets/{TransformToolbarButton-gzIxUBH7.js → TransformToolbarButton-8wfJR1bO.js} +2 -2
- package/dist/ui/assets/{UnrecognizedModels-0hptopv6.js → UnrecognizedModels-BzdU1clO.js} +1 -1
- package/dist/ui/assets/{VideoEngineSettings-BdNzCEdR.js → VideoEngineSettings-f79ff57u.js} +1 -1
- package/dist/ui/assets/{WorkspaceIndexPane-DnsOO916.js → WorkspaceIndexPane-fu5V6o1W.js} +1 -1
- package/dist/ui/assets/{api-C0I7spBl.js → api-CmrgM5Rf.js} +1 -1
- package/dist/ui/assets/chat-thread-memory-8MCtb17Q.js +1 -0
- package/dist/ui/assets/{chunk-6ECMNUIP-BvCy0HUI.js → chunk-6ECMNUIP-D5AA6ozp.js} +1 -1
- package/dist/ui/assets/{chunk-A6N6IN3I-ofeM4l8g.js → chunk-A6N6IN3I-BpxihS5H.js} +1 -1
- package/dist/ui/assets/{chunk-ATWVNF7D-CYuW1Yc6.js → chunk-ATWVNF7D-CKIWh7bN.js} +1 -1
- package/dist/ui/assets/{chunk-UBFT2CDQ-FexGDigd.js → chunk-CW24CH7I-BD0FIooX.js} +1 -1
- package/dist/ui/assets/{chunk-DXYWKZ52-zxe8pjH4.js → chunk-DXYWKZ52-DMKPZnpo.js} +1 -1
- package/dist/ui/assets/chunk-IIQYS2YH-BtDJt4Xr.js +1 -0
- package/dist/ui/assets/{chunk-KGWT454C-v5-l6U5m.js → chunk-KGWT454C-DsQOBuLg.js} +1 -1
- package/dist/ui/assets/{chunk-Q77KNJIN-BLuPdsQF.js → chunk-Q77KNJIN-BdWizq9s.js} +1 -1
- package/dist/ui/assets/{chunk-USU6HTKB-B_p-YcDp.js → chunk-USU6HTKB-DyGZplh4.js} +1 -1
- package/dist/ui/assets/{chunk-UXEANVBI-Bt0kX-0Z.js → chunk-UXEANVBI-BUBXvqyE.js} +1 -1
- package/dist/ui/assets/{chunk-O7JILDEF-CqcO1qaI.js → chunk-X7BNDUNI-D14WIvlD.js} +2 -2
- package/dist/ui/assets/{chunk-AE3IUKMM-mZjzzO8Z.js → chunk-ZSU5DJLX-CrjQf-vs.js} +1 -1
- package/dist/ui/assets/{container-BI8hxN1N.js → container-iFj1r6Hk.js} +1 -1
- package/dist/ui/assets/csv-Di411Mv-.js +1 -0
- package/dist/ui/assets/data-Q05qqAp4.js +1 -0
- package/dist/ui/assets/{dist-APSIK7H3.js → dist-1FNFiksd.js} +3 -3
- package/dist/ui/assets/dist-BMZhqfv7.js +2 -0
- package/dist/ui/assets/dist-CE5CbmDb.js +225 -0
- package/dist/ui/assets/doc-BHcGsJZd.js +587 -0
- package/dist/ui/assets/{document-import-DPK4r8Am.js → document-import-B2Ya6sbf.js} +1 -1
- package/dist/ui/assets/{docx-DRLuCTaC.js → docx-B8Pwz5Ih.js} +1 -1
- package/dist/ui/assets/{epub-a0p2Xb1b.js → epub-BQ4g8Q9j.js} +1 -1
- package/dist/ui/assets/{export-options-BqYFyzWx.js → export-options-Dylv69b3.js} +1 -1
- package/dist/ui/assets/file-browser-BLOPfnS0.js +5 -0
- package/dist/ui/assets/{html-BbQNmJ5X.js → html-BnA7qFwq.js} +1 -1
- package/dist/ui/assets/icons-CyM7Cg4E.js +1 -0
- package/dist/ui/assets/index-DW6qHqhU.css +1 -0
- package/dist/ui/assets/index-DivKnJyx.js +36 -0
- package/dist/ui/assets/{mail-link-CWfsP5Aq.js → mail-link-NtlcX5OE.js} +1 -1
- package/dist/ui/assets/{markdown-ryKA_OmY.js → markdown-CLKH_zzl.js} +1 -1
- package/dist/ui/assets/markdown-baseline-0dqv9qbV.js +1 -0
- package/dist/ui/assets/materialize-G4WC5UG3-xq2dcwS8.js +1 -0
- package/dist/ui/assets/{monaco-base-C0VTMpv-.js → monaco-base-BSvdAweA.js} +1 -1
- package/dist/ui/assets/{monaco-setup-CX8q88c5.js → monaco-setup-CT7LZ0o_.js} +1 -1
- package/dist/ui/assets/{new-project-meta-ZmDPGYzC.js → new-project-meta-5Y9Blozr.js} +1 -1
- package/dist/ui/assets/outside-in-Msmhxf_U.js +3 -0
- package/dist/ui/assets/{pdf-BHrygJa5.js → pdf-C4BhW3zg.js} +1 -1
- package/dist/ui/assets/{pending-drafts-27ujtQxX.js → pending-drafts-BD227X9H.js} +1 -1
- package/dist/ui/assets/{poppetje-CfaAvFkE.js → poppetje-DvCJO36y.js} +3 -3
- package/dist/ui/assets/{pptx-nDW64jAN.js → pptx-B6uaM2s7.js} +3 -3
- package/dist/ui/assets/{run-export-86KzLZ7R.js → run-export-TscWwR6y.js} +2 -2
- package/dist/ui/assets/{standalone-source-7QdiNsDW.js → standalone-source-Cw9SF7Zk.js} +1 -1
- package/dist/ui/assets/storage-Cmhlwx70.js +1 -0
- package/dist/ui/assets/styles-BjDaWeMA.css +1 -0
- package/dist/ui/assets/styles-CqO-rmOt.js +554 -0
- package/dist/ui/assets/{terminal-monaco-setup-Bar-sYKd.js → terminal-monaco-setup-me523-j-.js} +1 -1
- package/dist/ui/assets/{transform-CmAXy0Ck.js → transform-DxJCwK68.js} +1 -1
- package/dist/ui/assets/{use-local-model-manager-D1yiurrC.js → use-local-model-manager-8wvk-I-y.js} +1 -1
- package/dist/ui/assets/{useCompactLayout-BDtPQcDh.js → useCompactLayout-cm4E9Vja.js} +0 -0
- package/dist/ui/assets/{useCopilotAvailability-BHOfHrfT.js → useCopilotAvailability-D9hglSH_.js} +1 -1
- package/dist/ui/assets/{useDiffpacks-B0kYhlWQ.js → useDiffpacks-1BN2XJWg.js} +1 -1
- package/dist/ui/assets/{useGitSync-DOt-ODiw.js → useGitSync-7m9YA7h5.js} +1 -1
- package/dist/ui/assets/{useShowWorkInProgressFeatures-BtpredG7.js → useShowWorkInProgressFeatures-D6QOaTUT.js} +1 -1
- package/dist/ui/assets/{useTotalRamBytes-B8NFM27w.js → useTotalRamBytes-Durk383U.js} +1 -1
- package/dist/ui/assets/{xlsx-B_pu1ZvY.js → xlsx-BbHA9bxA.js} +1 -1
- package/dist/ui/index.html +15 -15
- package/package.json +12 -11
- package/dist/ui/assets/CatalogBrowser-7_jHy5Q3.js +0 -1
- package/dist/ui/assets/ChatTimelineView-Cg_kLK_U.js +0 -7
- package/dist/ui/assets/CraftbookEditor-BKAIsnXv.js +0 -1
- package/dist/ui/assets/DiffpackReviewView-B2a3zgE-.js +0 -1
- package/dist/ui/assets/DocumentDetail-GCYhwQqV.js +0 -1
- package/dist/ui/assets/DocumentsView-Cm3RaQ5N.js +0 -1
- package/dist/ui/assets/FileMapView-BKJovLcL.js +0 -1
- package/dist/ui/assets/FoldersSettings-CuJd2JdE.js +0 -1
- package/dist/ui/assets/GezelDetail-D_KIPDhQ.js +0 -1
- package/dist/ui/assets/GezellenView-BOOW1QQU.js +0 -1
- package/dist/ui/assets/HandboekView-gRzJcIbJ.js +0 -1
- package/dist/ui/assets/KnowledgeView-DJ3cJVHA.js +0 -1
- package/dist/ui/assets/MlxSettings-45mBFHbA.js +0 -1
- package/dist/ui/assets/NewTaskDialog-CIXVunZn.js +0 -2
- package/dist/ui/assets/ProjectChat-BiJRweob.js +0 -5
- package/dist/ui/assets/ProjectConnectionsTab-CQgaIzuv.js +0 -1
- package/dist/ui/assets/ProjectsView-BUdR76n6.js +0 -7
- package/dist/ui/assets/SessionSwitcher-BgZqyiRn.js +0 -1
- package/dist/ui/assets/SettingsView-DLhOYiR5.js +0 -3
- package/dist/ui/assets/TaskTabContent-CG2KmfwV.js +0 -1
- package/dist/ui/assets/TasksView-Dy5Ue4zS.js +0 -1
- package/dist/ui/assets/ToolsetsEditor-J9XxQ5Ms.js +0 -8
- package/dist/ui/assets/chat-thread-memory-CI2-giEq.js +0 -1
- package/dist/ui/assets/chunk-IIQYS2YH-DEkyBlHg.js +0 -1
- package/dist/ui/assets/csv-B0D9jJG2.js +0 -1
- package/dist/ui/assets/data-BIL84EaT.js +0 -1
- package/dist/ui/assets/dist-CJqyWK6E.js +0 -2
- package/dist/ui/assets/dist-DOqbRmFj.js +0 -225
- package/dist/ui/assets/doc-C2Ph2FWI.js +0 -584
- package/dist/ui/assets/document-companion-aDThLOwl.js +0 -1
- package/dist/ui/assets/file-browser-DVyWN0LD.js +0 -5
- package/dist/ui/assets/icons-DWaUNQbT.js +0 -1
- package/dist/ui/assets/index-DDu8nyO6.js +0 -34
- package/dist/ui/assets/index-DEDUSiCx.css +0 -1
- package/dist/ui/assets/markdown-baseline-9B52XlX2.js +0 -1
- package/dist/ui/assets/materialize-G4WC5UG3-BlZQe-88.js +0 -1
- package/dist/ui/assets/outside-in-BmIIeMid.js +0 -3
- package/dist/ui/assets/storage-B-vhjyV2.js +0 -1
- package/dist/ui/assets/styles-BvkZd-EV.js +0 -550
- package/dist/ui/assets/styles-IQ4adxWr.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{G as r,K as i,L as a,N as o,Tt as s,Zt as c,bt as l,gt as u,lt as d}from"./dist-DOqbRmFj.js";import{t as f}from"./api-C0I7spBl.js";import{t as p}from"./model-context-DBqdK0PS.js";import{r as m}from"./model-memory-copy-Ds9w1uJE.js";import{t as h}from"./ConfirmDialog-Dt1ed4Fh.js";import{wt as g}from"./index-DDu8nyO6.js";import{t as _}from"./CatalogBrowser-7_jHy5Q3.js";import{n as ee,r as v,t as y}from"./InstallProgressRow-DyKOI4MU.js";import{t as b}from"./IncompleteDownloads-C36lTCMG.js";import{t as x}from"./LicenseButton-D3VmcVG1.js";import{a as S,i as C,n as w,o as T,r as E,t as te}from"./UnrecognizedModels-0hptopv6.js";import{t as D}from"./local-engine-label-BR-PGVFE.js";import{a as O,i as k,n as A,o as ne,t as re}from"./use-local-model-manager-D1yiurrC.js";var j=e(t(),1),M=n();function N(e){return{usableBytes:e.usableBytes,totalRamBytes:e.totalRamBytes,gpuVramBytes:e.gpuMemoryKind===`integrated`?null:e.gpuVramBytes,...e.budgetBytes===void 0?{}:{admissibleBytes:e.budgetBytes}}}function P(e,t){let{totalRamBytes:n,gpuVramBytes:r}=N(t);return i(e,{ctxTokens:s({totalRamBytes:n,gpuVramBytes:r})})}function F(e,t){return a({residentBytes:r(e.llamaCpp.approxSizeBytes,{mmprojBytes:e.llamaCpp.mmproj?.sizeBytes})+P(e,t),isMoE:u(e.tags),...N(t)})}function I(e){return{platform:e.source===`darwin-unified`?`darwin`:`other`,gpuVramBytes:e.gpuVramBytes,...e.gpuMemoryKind?{gpuMemoryKind:e.gpuMemoryKind}:{},totalRamBytes:e.totalRamBytes,usableBytes:e.usableBytes,...e.budgetBytes===void 0?{}:{budgetBytes:e.budgetBytes}}}function L(e){return`~${m(e)}`}function R(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`})}function z(e){return e.kind!==`chat-model`||!e.llamaCpp?null:e}var ie={"mix of experts":`Only a fraction of the model's parameters run per token, so it's faster than a dense model of the same nominal size.`,vision:`Can accept images alongside text.`,tools:`Supports function/tool calling via the API.`,multimodal:`Handles multiple input types (text + images).`,large:`Heavy model — needs a lot of memory and runs more slowly.`,small:`Compact model — runs quickly on modest hardware.`};function B({onModelsChanged:e,compact:t=!1}){let{modelsLoading:n,models:i,modelsError:s,incomplete:m,unrecognized:y,installs:D,installWarning:O,setInstallWarning:ne,installError:B,setInstallError:H,installMismatch:U,setInstallMismatch:W,toDelete:G,setToDelete:K,fitness:q,probing:J,refreshFitness:Y,refresh:X,deleteOne:ae,startInstall:Z,retryInstall:oe,cancelInstall:se,downloadAnyway:ce}=re(A,e),[Q,le]=(0,j.useState)(null),[$,ue]=(0,j.useState)(!1),[de,fe]=(0,j.useState)(null),[pe,me]=(0,j.useState)(null),[he,ge]=(0,j.useState)(!1),[_e,ve]=(0,j.useState)([]),ye=(0,j.useCallback)(async(e,t)=>{me(e);try{let n=await f.getConfig();await f.updateConfig({nativeVision:{...n.nativeVision??{},[e]:t}}),await X()}catch{}finally{me(null)}},[X]);(0,j.useEffect)(()=>{f.getMemoryProfile().then(e=>le(e)).catch(()=>{}),f.getModelContextOverrides(`llama-cpp`).then(()=>ge(!0)).catch(()=>ge(!1))},[]);let be=(0,j.useMemo)(()=>new Set(i.map(e=>e.id)),[i]),xe=(0,j.useMemo)(()=>new Set(y.map(e=>e.id)),[y]),Se=(0,j.useMemo)(()=>{let e=new Map;for(let t of _e){let n=z(t.manifest);n&&e.set(n.id,n)}return e},[_e]);return(0,M.jsxs)(`div`,{className:`ollama-model-manager`,children:[D.size>0&&(0,M.jsxs)(`div`,{className:`ollama-section`,children:[(0,M.jsx)(`h4`,{children:`Downloading…`}),(0,M.jsx)(`div`,{className:`ollama-pull-list`,children:Array.from(D.values()).map(e=>(0,M.jsx)(V,{inst:e,onCancel:()=>se(e.catalogId),onRetry:()=>oe(e.catalogId)},e.catalogId))})]}),(0,M.jsx)(te,{items:y.filter(e=>!D.has(e.id)),onUpdate:e=>Z(e),onRemove:e=>K(e)}),(0,M.jsx)(b,{items:m.filter(e=>!D.has(e.id)),onResume:e=>Z(e),onDelete:e=>K(e)}),U&&(0,M.jsxs)(`div`,{className:`ollama-section`,children:[(0,M.jsxs)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginBottom:`0.5rem`},children:[`⚠ `,(0,M.jsx)(`code`,{children:U.catalogId}),` is newer on Hugging Face than the version Gezel knows about`]}),(0,M.jsxs)(`p`,{style:{marginBottom:`0.5rem`},children:[`The file `,(0,M.jsx)(`code`,{children:U.file}),` changed upstream, so its checksum no longer matches what this version of Gezel pinned. This is almost always a harmless upstream fix — model authors routinely re-publish chat templates and tokenizer configs — but we can't verify it automatically. You can download the current version now, or wait for a Gezel update with a refreshed catalog.`]}),(0,M.jsxs)(`div`,{style:{display:`flex`,gap:`0.75rem`},children:[(0,M.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>ce(U.catalogId),children:`Download anyway`}),(0,M.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>W(null),children:`Dismiss`})]})]}),B&&(0,M.jsx)(`div`,{className:`ollama-section`,children:(0,M.jsx)(`p`,{className:`error`,style:{marginBottom:`0.5rem`},children:B})}),O&&(0,M.jsx)(`div`,{className:`ollama-section`,children:(0,M.jsxs)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginBottom:`0.5rem`},children:[`⚠ `,O.id,`: `,O.message]})}),!t&&(0,M.jsx)(w,{engine:`llama-cpp`,onModelsChanged:e}),(n||i.length>0||s)&&(0,M.jsxs)(`div`,{className:`ollama-section`,children:[(0,M.jsx)(`h4`,{children:t?`Models on this device`:`Local models`}),n&&i.length===0&&!s&&(0,M.jsx)(`p`,{className:`muted small`,"aria-live":`polite`,children:`Checking shared models… Large models can take a few minutes the first time; later starts use the local verification cache.`}),s&&(0,M.jsx)(`p`,{className:`error`,children:s}),i.length>0&&(0,M.jsx)(`div`,{className:`ollama-model-table-wrap`,children:(0,M.jsxs)(`table`,{className:`ollama-model-table`,children:[(0,M.jsxs)(`colgroup`,{children:[(0,M.jsx)(`col`,{className:`model-name-column`}),(0,M.jsx)(`col`,{}),(0,M.jsx)(`col`,{}),(0,M.jsx)(`col`,{}),(0,M.jsx)(`col`,{}),(0,M.jsx)(`col`,{})]}),(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{children:[(0,M.jsx)(`th`,{children:`Name`}),(0,M.jsx)(`th`,{children:`Size`}),(0,M.jsx)(`th`,{children:`Quant`}),(0,M.jsx)(`th`,{title:`Effective per-turn context size after Gezel's settings and memory limits`,children:`Context size`}),(0,M.jsx)(`th`,{title:`Representative startup and decode speed with an approximately 20K-token prompt`,children:`Fitness`}),(0,M.jsx)(`th`,{})]})}),(0,M.jsx)(`tbody`,{children:i.map(e=>{let t=D.has(e.id),n=`llama-cpp:${e.id}`,i=q.get(n),s=Se.get(e.id),l=e.predictedResidentBytes??r(e.approxSizeBytes,{mmprojBytes:e.mmprojSizeBytes}),m=Q?a({residentBytes:l,isMoE:u(s?.tags),...N(Q)}):void 0,h=Q&&s?d(I(Q),{isMoE:u(s.tags),fitTier:m?.tier??`fits`,residentBytes:l}):null;return(0,M.jsxs)(j.Fragment,{children:[(0,M.jsxs)(`tr`,{children:[(0,M.jsx)(`td`,{className:`model-name-table-cell`,children:(0,M.jsxs)(`div`,{className:`model-name-cell`,children:[(0,M.jsx)(`code`,{children:e.id}),(0,M.jsxs)(`div`,{className:`model-name-meta`,children:[h&&(0,M.jsx)(`span`,{className:`gz-status-pill${h.kind===`moe-good-match`?` gz-status-pill--ok`:``}`,title:h.detail,children:h.label}),e.updateAvailable&&(0,M.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:e.updateReason??(e.availableVersion?`A newer build is available in the catalog (→ v${e.availableVersion}). Updating downloads only the files that differ.`:`A newer build is available in the catalog.`),children:`update available`})]})]})}),(0,M.jsx)(k,{model:e}),(0,M.jsx)(`td`,{title:c(e.quantization,e.ggufQuantization),children:o(e.quantization,e.ggufQuantization)}),(0,M.jsx)(`td`,{title:e.effectiveContextWindow?e.overrideContextTokens===void 0?`Gezel will grant up to ${e.effectiveContextWindow.toLocaleString()} tokens per turn${e.contextWindow?`; the model advertises ${e.contextWindow.toLocaleString()} tokens`:``}. The effective size accounts for model tuning, settings, concurrency, and available memory — Adaptive grows it past 64K when fast memory has room.`:`You've set this model to ${e.overrideContextTokens.toLocaleString()} tokens per turn; Gezel grants up to what memory allows (currently ${e.effectiveContextWindow.toLocaleString()}).`:e.contextSizingStatus===`restart-required`?`This model is running with a different context window than the current sizing settings resolve to. Restart the local engine (or let it go idle) so Gezel can re-admit it — no memory change needed.`:e.contextSizingStatus===`insufficient-memory`?`The selected context sizing policy needs${e.contextWindow?` this model's full advertised ${e.contextWindow.toLocaleString()}-token window`:` more context`}, which does not fit in memory safely. Choose Adaptive, unload another model, or free memory before trying again.`:`The effective context size is unavailable.`,children:e.contextSizingStatus===`restart-required`?`Restart needed`:e.contextSizingStatus===`insufficient-memory`?`Won't fit`:(0,M.jsxs)(M.Fragment,{children:[p(e.effectiveContextWindow),e.overrideContextTokens!==void 0&&(0,M.jsx)(`span`,{className:`gz-budget-tag gz-budget-tag-custom model-context-custom-tag`,children:`custom`})]})}),(0,M.jsx)(E,{entry:i,probing:J.includes(n)}),(0,M.jsx)(`td`,{className:`model-actions-table-cell`,children:(0,M.jsxs)(`div`,{className:`model-actions-cell`,children:[(0,M.jsx)(`div`,{className:`model-action-status`,children:e.readOnly&&(0,M.jsx)(`span`,{className:`muted small`,title:`Provided by the machine-wide install (shared asset store). It can't be removed from here — manage it with the machine installer, or install a user-owned copy to shadow it.`,children:`Machine model`})}),(0,M.jsx)(`div`,{className:`model-action-links`,children:(0,M.jsx)(S,{engine:`llama-cpp`,model:e,updating:t,contextSupported:he,contextEditorOpen:de===e.id,onToggleContextEditor:()=>fe(t=>t===e.id?null:e.id),...e.nativeVisionEnabled===void 0?{}:{visionAction:{enabled:e.nativeVisionEnabled,busy:pe===e.id,onToggle:()=>void ye(e.id,!e.nativeVisionEnabled)}},fitnessAction:C(i,J.includes(n),()=>{f.runModelFitnessProbe(`llama-cpp`,e.id).then(()=>Y()).catch(()=>{})}),onUpdate:()=>Z(e.id),onDelete:()=>K(e.id)})})]})})]}),de===e.id&&(0,M.jsx)(`tr`,{className:`model-context-editor-row`,children:(0,M.jsx)(`td`,{colSpan:6,children:(0,M.jsx)(T,{engine:`llama-cpp`,model:e,onSaved:X})})})]},e.id)})})]})})]}),(0,M.jsxs)(`div`,{className:`ollama-section ollama-section--flat ollama-section--download`,children:[(0,M.jsx)(`h4`,{children:`Download a model`}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`Models are hosted by`,` `,(0,M.jsx)(`a`,{href:`https://huggingface.co`,target:`_blank`,rel:`noreferrer`,style:{color:`inherit`},children:`Hugging Face`}),`, a community library of open, freely available AI models. Your device downloads them directly.`]}),(0,M.jsxs)(`p`,{className:`muted small`,children:[Q?`Models that may not fit this machine, and retired models, are hidden by default. `:`Retired models are hidden by default. `,(0,M.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>ue(e=>!e),style:{padding:0},children:$?Q?`Hide retired and oversized models`:`Hide retired models`:`Show all models`})]}),(0,M.jsx)(_,{kind:`chat-model`,emptyMessage:`No on-device models in the catalog yet.`,onItemsLoaded:ve,tagTooltips:ie,filter:e=>{let t=z(e.manifest);return!(!t||!$&&l(t)||!$&&Q&&!F(t,Q).runnable)},action:e=>{let t=z(e.manifest);if(!t)return null;let n=be.has(t.id),i=xe.has(t.id),a=D.get(t.id),o=a&&a.totalBytes>0?Math.min(100,Math.round(a.bytesWritten/a.totalBytes*100)):null,s=Q?F(t,Q):null;return(0,M.jsxs)(`div`,{className:`catalog-ollama-action`,children:[(0,M.jsxs)(`div`,{className:`catalog-ollama-meta`,children:[(0,M.jsxs)(`div`,{className:`catalog-ollama-specs muted small`,children:[(0,M.jsx)(ee,{repo:t.llamaCpp.huggingfaceRepo}),(0,M.jsx)(`span`,{children:`·`}),(0,M.jsx)(`span`,{children:t.parameterSize}),(0,M.jsx)(`span`,{children:`·`}),(0,M.jsx)(`span`,{children:L(t.llamaCpp.approxSizeBytes)}),R(t.releasedAt)&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{children:`·`}),(0,M.jsx)(`span`,{children:R(t.releasedAt)})]})]}),(0,M.jsxs)(`div`,{className:`catalog-ollama-pills`,children:[(0,M.jsx)(x,{manifest:t,fallbackHref:v(t.llamaCpp.huggingfaceRepo)}),s&&s.tier!==`fits`&&(0,M.jsx)(`span`,{className:`gz-status-pill ${s.tier===`fits-offload`?`gz-status-pill--ok`:`gz-status-pill--warn`}`,title:s.detail,children:s.label}),(()=>{let n=Q&&s?d(I(Q),{isMoE:u(e.manifest.tags),fitTier:s.tier,residentBytes:r(t.llamaCpp.approxSizeBytes)+P(t,Q)}):null;return n?(0,M.jsx)(`span`,{className:`gz-status-pill${n.kind===`moe-good-match`?` gz-status-pill--ok`:``}`,title:n.detail,children:n.label}):null})()]})]}),(0,M.jsx)(`button`,{type:`button`,disabled:n||i||!!a,onClick:()=>Z(t.id),children:n?`On device`:a?a.phase===`downloading`?o===null?`Downloading…`:`Downloading… ${o}%`:a.phase===`verifying`?`Verifying…`:`Reading metadata…`:i?`Needs attention above`:`Download`})]})}})]}),(0,M.jsxs)(`div`,{className:`ollama-section ollama-section--flat`,children:[(0,M.jsx)(g,{}),(0,M.jsx)(`span`,{className:`muted small`,style:{marginLeft:`0.75rem`},children:`Import from a gezel local model package`})]}),(0,M.jsx)(h,{open:G!==null,title:`Delete ${G??``}?`,message:`This removes the downloaded model from your device. It stays available in the catalog — you can download it again any time.`,confirmLabel:`Delete`,danger:!0,onConfirm:ae,onCancel:()=>K(null)})]})}function V({inst:e,onCancel:t,onRetry:n}){let r=e.totalBytes>0,i=r?Math.min(100,Math.round(e.bytesWritten/e.totalBytes*100)):0,a;if(e.error)a=e.error;else if(e.retrying){let t=Math.max(1,Math.round(e.retrying.delayMs/1e3));a=`${e.retrying.reason} — retrying in ${t}s (attempt ${e.retrying.attempt}/${e.retrying.maxAttempts})`}else a=e.phase===`downloading`?r?`Downloading ${m(e.bytesWritten)} of ${m(e.totalBytes)} (${i}%)`:e.bytesWritten>0?`Downloading ${m(e.bytesWritten)}…`:`Preparing download…`:e.phase===`verifying`?`Checking download…`:`Reading model info…`;let o=e.phase!==`downloading`||!r;return(0,M.jsx)(y,{title:(0,M.jsx)(`code`,{children:e.catalogId}),status:a,percent:o?null:i,tone:e.error?`error`:e.retrying?`warning`:`normal`,onCancel:t,onRetry:n})}var H=80,U=40,W=95,G=5;function K(e){return e===`win32`||e===`linux`}function q({config:e,onConfigChanged:t,platform:n}){let r=e?.deviceSafety?.mode??`observe`,i=e?.deviceSafety?.maxStartTemperatureC??H,[a,o]=(0,j.useState)(String(i)),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(null);(0,j.useEffect)(()=>{o(String(i))},[i]);let d=(0,j.useCallback)(async n=>{if(!s){c(!0),u(null);try{t(await f.updateConfig({deviceSafety:{...e?.deviceSafety??{},...n}}))}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}}},[e?.deviceSafety,t,s]),p=(0,j.useCallback)(e=>{r!==e&&d({mode:e})},[r,d]),m=(0,j.useCallback)(()=>{let e=Number(a);if(!Number.isInteger(e)||e<U||e>W){u(`Enter a whole number from ${U} to ${W}°C.`);return}if(e===i){u(null);return}d({maxStartTemperatureC:e,resumeTemperatureC:e-G})},[i,d,a]);if(!K(n))return null;let h=Number(a),g=(Math.min(W,Math.max(U,h))-U)/(W-U)*100;return(0,M.jsxs)(`section`,{className:`machine-health-settings`,"aria-labelledby":`machine-health-heading`,children:[(0,M.jsx)(`h4`,{id:`machine-health-heading`,children:`Machine health`}),(0,M.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`Choose whether Gezel only reports accelerator health or also waits for the machine to cool before starting new on-device work.`}),(0,M.jsxs)(`fieldset`,{className:`gz-tray machine-health-mode`,children:[(0,M.jsx)(`legend`,{className:`sr-only`,children:`Machine health mode`}),(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":r===`observe`,className:`gz-key gz-key--stacked${r===`observe`?` gz-key-active`:``}`,disabled:s,onClick:()=>p(`observe`),children:[(0,M.jsx)(`span`,{children:`Observe`}),(0,M.jsx)(`small`,{children:`Report only`})]}),(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":r===`guard`,className:`gz-key gz-key--stacked${r===`guard`?` gz-key-active`:``}`,disabled:s,onClick:()=>p(`guard`),children:[(0,M.jsx)(`span`,{children:`Manage`}),(0,M.jsx)(`small`,{children:`Pause new work`})]})]}),r===`off`&&(0,M.jsx)(`p`,{className:`muted small machine-health-off-note`,children:`Machine health is disabled by an advanced configuration override. Choose Observe or Manage to turn it back on.`}),(0,M.jsxs)(`div`,{className:`machine-health-temperature-row`,children:[(0,M.jsx)(`label`,{htmlFor:`machine-health-temperature`,children:`Manage temperature`}),(0,M.jsxs)(`div`,{className:`machine-health-temperature-control`,children:[(0,M.jsxs)(`div`,{className:`machine-health-temperature-slider-wrap`,children:[(0,M.jsx)(`input`,{id:`machine-health-temperature`,className:`machine-health-temperature-slider`,type:`range`,min:U,max:W,step:1,value:a,disabled:s,"aria-describedby":`machine-health-temperature-help`,"aria-valuetext":`${a} degrees Celsius`,style:{"--machine-health-temperature-progress":`${g}%`},onChange:e=>o(e.target.value),onPointerUp:e=>e.currentTarget.blur(),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}}),(0,M.jsxs)(`div`,{className:`machine-health-temperature-scale`,"aria-hidden":`true`,children:[(0,M.jsxs)(`span`,{children:[U,`°`]}),(0,M.jsxs)(`span`,{className:`machine-health-temperature-default`,children:[H,`° default`]}),(0,M.jsxs)(`span`,{children:[W,`°`]})]})]}),(0,M.jsxs)(`output`,{className:`machine-health-temperature-value`,htmlFor:`machine-health-temperature`,"aria-label":`Manage temperature: ${a} degrees Celsius`,children:[(0,M.jsx)(`span`,{className:`machine-health-temperature-value-number`,children:a}),(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`°C`})]})]})]}),(0,M.jsxs)(`p`,{id:`machine-health-temperature-help`,className:`muted small machine-health-temperature-help`,children:[`In Manage mode, new accelerator work waits above this temperature and resumes after a 5°C cooldown. The default is 80°C. Both modes retain the `,105,`°C emergency cutoff.`]}),s&&(0,M.jsx)(`output`,{className:`muted small machine-health-save-state`,children:`Saving…`}),l&&(0,M.jsx)(`p`,{className:`error small machine-health-save-state`,role:`alert`,children:l})]})}function J(e){return e===!0?`on`:e===!1?`off`:`auto`}function Y(e,t){return e===`darwin`?[`metal`]:t===`cuda`?[`cuda`,`vulkan`,`cpu`]:t===`vulkan`?[`vulkan`,`cpu`]:t===`cpu`?[`cpu`]:[`cuda`,`vulkan`,`cpu`]}function X(e){return e===`cuda`?`CUDA (Nvidia GPU)`:e===`vulkan`?`Vulkan (any GPU)`:e===`metal`?`Metal (Apple GPU)`:`CPU only`}function ae(e){return e===`amd`?`, AMD GPU detected`:e===`nvidia`?`, Nvidia GPU detected`:e===`intel`?`, Intel GPU detected`:``}function Z(e,t){if(!t?.llamaCppBackend)return!1;let n=t.llamaCppBackend,r=e?.llamaCppBackendOverride&&e.llamaCppBackendOverride!==`auto`?e.llamaCppBackendOverride:t.llamaCppDetectedBackend??n;return!t.llamaCppQuarantinedBackends?.includes(r)&&r!==n}function oe({config:e,onConfigChanged:t,health:n,title:r}){let[i,a]=(0,j.useState)(e?.llamaCppBaseUrl??``),[o,s]=(0,j.useState)(e?.llamaCppModelPath??``),[c,l]=(0,j.useState)(e?.llamaCppNCpuFfn===void 0?``:String(e.llamaCppNCpuFfn)),[u,d]=(0,j.useState)([]),[p,m]=(0,j.useState)(`idle`),[h,g]=(0,j.useState)(`adaptive`),[_,ee]=(0,j.useState)(!0),v=(0,j.useRef)(null),y=(0,j.useRef)(!0),b=(0,j.useCallback)(()=>{v.current!==null&&(window.clearTimeout(v.current),v.current=null)},[]);(0,j.useEffect)(()=>(y.current=!0,()=>{y.current=!1,b()}),[b]);let x=(0,j.useCallback)(e=>{y.current&&(b(),m(e))},[b]),S=(0,j.useCallback)(()=>{y.current&&(b(),m(`saved`),v.current=window.setTimeout(()=>{v.current=null,y.current&&m(`idle`)},1200))},[b]);(0,j.useEffect)(()=>{a(e?.llamaCppBaseUrl??``)},[e?.llamaCppBaseUrl]),(0,j.useEffect)(()=>{s(e?.llamaCppModelPath??``)},[e?.llamaCppModelPath]),(0,j.useEffect)(()=>{l(e?.llamaCppNCpuFfn===void 0?``:String(e.llamaCppNCpuFfn))},[e?.llamaCppNCpuFfn]);let C=(0,j.useCallback)(async()=>{try{let e=await f.listLlamaCppModels();d(e.models)}catch{}},[]);(0,j.useEffect)(()=>{C()},[C]),(0,j.useEffect)(()=>{let e=!1;return f.getLlamaCppContextSizing().then(t=>{e||g(t.policy)}).catch(()=>{}).finally(()=>{e||ee(!1)}),()=>{e=!0}},[]);let w=(0,j.useCallback)(async()=>{let e=i.trim();x(`saving`);try{let n=await f.updateConfig({llamaCppBaseUrl:e===``?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[i,t,S,x]),T=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppBackendOverride:e===`auto`?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),E=(0,j.useCallback)(async e=>{x(`saving`);try{let t=await f.updateLlamaCppContextSizing(e);if(!y.current)return;g(t.policy),S()}catch{x(`idle`)}},[S,x]),te=(0,j.useCallback)(async()=>{let e=o.trim();x(`saving`);try{let n=await f.updateConfig({llamaCppModelPath:e===``?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[o,t,S,x]),k=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppKvCacheType:e===`q8_0`?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),A=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppFlashAttn:e===`auto`?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),re=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppCpuMoe:e===`auto`?null:e===`on`});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),N=(0,j.useCallback)(async()=>{let e=c.trim(),n=e===``?null:Number(e);if(!(n!==null&&(!Number.isInteger(n)||n<0))){x(`saving`);try{let e=await f.updateConfig({llamaCppNCpuFfn:n});if(!y.current)return;t(e),S()}catch{x(`idle`)}}},[c,t,S,x]),P=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppLoadMode:e===`auto`?null:e,llamaCppMlock:null});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),F=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppLazyMode:e===`auto`?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),I=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppReasoningPreserve:e?!0:null});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),L=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppSwaFull:e===`auto`?null:e===`on`});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),R=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppSpecType:e===`auto`?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),z=(0,j.useCallback)(async n=>{x(`saving`);try{let r=await f.updateConfig({defaultModel:{...e?.defaultModel,"llama-cpp":n??void 0}});if(!y.current)return;t(r),S()}catch{x(`idle`)}},[e?.defaultModel,t,S,x]),ie=e?.defaultModel?.[`llama-cpp`],V=!!e?.llamaCppBaseUrl;return(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,M.jsx)(`h3`,{children:r??D(`llama-cpp`,n?.platform)}),(0,M.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`Run AI models directly on this device using the llama.cpp engine, making the best use of the hardware you already have. Your conversations stay on your computer — no account to set up, no data sent to the cloud.`}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`span`,{className:`muted small`,children:`Status:`}),(0,M.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:`ready`}),V&&(0,M.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:`Using an external engine at: ${e?.llamaCppBaseUrl}`,children:`using external engine`}),p===`saved`&&(0,M.jsx)(`span`,{className:`muted small`,children:`saved ✓`})]})]}),u.length>1&&(0,M.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,M.jsx)(`h4`,{children:`Default model`}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Which local model new chat sessions use when a gezel doesn't pin one.`}),(0,M.jsx)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`},children:(0,M.jsxs)(`select`,{value:ie??``,onChange:e=>void z(e.target.value||void 0),children:[(0,M.jsx)(`option`,{value:``,children:`First local model`}),u.map(e=>(0,M.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.id,`)`]},e.id))]})})]}),(0,M.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,M.jsx)(`h4`,{children:`Models`}),(0,M.jsx)(B,{onModelsChanged:C},h)]}),(0,M.jsx)(ne,{provider:`llama-cpp`}),(0,M.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,M.jsx)(`h4`,{style:{marginBottom:`0.5rem`},children:`Concurrent replicas`}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Run multiple copies of the same model so unrelated sessions don't queue behind each other. Weights are shared by the OS via mmap so disk cost stays at one model file; resident memory grows because each clone keeps its own KV cache and activations.`}),(0,M.jsx)(O,{provider:`llama-cpp`,modelId:e?.defaultModel?.[`llama-cpp`]??null,config:e,onConfigChanged:t})]}),(0,M.jsx)(q,{config:e,onConfigChanged:t,platform:window.__GEZEL__?.platform??n?.platform}),(0,M.jsxs)(`details`,{className:`llama-advanced-settings`,children:[(0,M.jsxs)(`summary`,{className:`llama-advanced-summary`,children:[(0,M.jsx)(`span`,{className:`llama-advanced-caret`,"aria-hidden":`true`,children:`›`}),(0,M.jsx)(`h4`,{children:`Advanced`})]}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.75rem`},children:`Tune how the managed on-device engine starts, or override how Gezel connects to it. Most users don't need any of these — the supervised engine handles everything. Set them only when you need a different context policy, are running your own engine process, point at a weights file that isn't in the catalog, or downgrade the accelerator.`}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{htmlFor:`llama-cpp-context-sizing`,className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Context sizing`}),(0,M.jsxs)(`select`,{id:`llama-cpp-context-sizing`,value:h,disabled:_||p===`saving`||V,onChange:e=>void E(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`adaptive`,children:`Adaptive (recommended)`}),(0,M.jsx)(`option`,{value:`model-max`,children:`Model maximum (strict)`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[(0,M.jsx)(`em`,{children:`Adaptive`}),` starts from model tuning (64K by default), reduces concurrency before it shortens a larger tuned window, and grows the window toward the model's maximum when fast memory has room to spare — consolidating down to two concurrent chats when that buys a meaningfully longer window, never fewer. Each model can also be pinned to a specific size from its row in the list below. `,(0,M.jsx)(`em`,{children:`Model maximum`}),` requests the model's full advertised window; if one engine slot cannot hold it safely, the model will not start. This is a machine-wide managed-engine setting. Changing it restarts idle local engines right away; a model that is mid-conversation finishes its current turn first.`,V?` External engine URLs manage their own context size.`:``]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{htmlFor:`llama-cpp-engine-backend`,className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Engine backend`}),(0,M.jsxs)(`select`,{id:`llama-cpp-engine-backend`,value:e?.llamaCppBackendOverride??`auto`,onChange:e=>void T(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsxs)(`option`,{value:`auto`,children:[`Auto-detect`,n?.llamaCppDetectedBackend?` (machine supports: ${n.llamaCppDetectedBackend}${ae(n.llamaCppDetectedVendor)})`:``]}),Y(n?.platform,n?.llamaCppDetectedBackend).map(e=>(0,M.jsx)(`option`,{value:e,children:X(e)},e))]}),(0,M.jsx)(`span`,{className:`muted`,style:{fontSize:`0.85rem`},children:Z(e,n)?`Restart the app to apply`:``})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Auto-detect picks the fastest backend your machine supports; the other options are downgrades you can pin if the faster path is misbehaving. Switching `,(0,M.jsx)(`em`,{children:`back`}),` to Auto-detect from a pinned override also requires a restart.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`KV cache quantization`}),(0,M.jsxs)(`select`,{value:e?.llamaCppKvCacheType??`q8_0`,onChange:e=>void k(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`f16`,children:`f16 — full precision (most memory)`}),(0,M.jsx)(`option`,{value:`q8_0`,children:`q8_0 — balanced (default)`}),(0,M.jsx)(`option`,{value:`q4_0`,children:`q4_0 — smallest (most savings)`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Sets `,(0,M.jsx)(`code`,{children:`--cache-type-k`}),` / `,(0,M.jsx)(`code`,{children:`--cache-type-v`}),` for llama-server. Quantizing the KV cache frees RAM for longer contexts and more concurrent sessions: q8_0 is near-lossless at ~50% savings vs. f16, while q4_0 saves the most but can dent quality on attention-sensitive models. Takes effect the next time the engine starts — restart the app to apply now.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Flash attention`}),(0,M.jsxs)(`select`,{value:typeof e?.llamaCppFlashAttn==`string`?e.llamaCppFlashAttn:e?.llamaCppFlashAttn===!0?`on`:`auto`,onChange:e=>void A(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto (recommended)`}),(0,M.jsx)(`option`,{value:`on`,children:`On`}),(0,M.jsx)(`option`,{value:`off`,children:`Off`})]})]}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:`Faster attention on modern GPUs, and effectively required for the fast path under a quantized KV cache (the default). Auto lets llama-server decide; the engine forces it on when the KV cache is quantized. Takes effect the next time the engine starts.`}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Speculative decoding`}),(0,M.jsxs)(`select`,{value:e?.llamaCppSpecType??`auto`,onChange:e=>void R(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto — MTP when the model supports it (recommended)`}),(0,M.jsx)(`option`,{value:`none`,children:`Off`}),(0,M.jsx)(`option`,{value:`ngram-mod`,children:`N-gram lookup (no draft model)`}),(0,M.jsx)(`option`,{value:`draft-mtp`,children:`Model MTP head (force when compatible)`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Drafts several tokens per step and verifies them against the target model. `,(0,M.jsx)(`em`,{children:`Auto`}),` `,`enables MTP only when the installed weights confirm a compatible prediction head; otherwise speculative decoding stays off. `,(0,M.jsx)(`em`,{children:`N-gram`}),` needs no extra model and helps most on repetitive or structured output. Takes effect the next time the engine starts.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Reasoning history`}),(0,M.jsxs)(`select`,{value:e?.llamaCppReasoningPreserve===!0?`on`:`off`,onChange:e=>void I(e.target.value===`on`),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`off`,children:`Don't retain private reasoning (default)`}),(0,M.jsx)(`option`,{value:`on`,children:`Retain across turns`})]})]}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:`Replays a model's private reasoning into later turns when its chat template supports it. This can improve continuity in long tool loops, but consumes more context and can make a model cling to an earlier approach. Gezel explicitly keeps both the engine template and replay policy in sync. Takes effect the next time the engine starts.`}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{htmlFor:`llama-cpp-n-cpu-ffn`,className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Dense FFN offload`}),(0,M.jsx)(`input`,{id:`llama-cpp-n-cpu-ffn`,type:`number`,min:0,step:1,placeholder:`Auto`,value:c,onChange:e=>l(e.target.value),style:{flex:1,maxWidth:`20rem`}}),(0,M.jsx)(`button`,{type:`button`,disabled:p===`saving`||!/^(?:|0|[1-9]\d*)$/.test(c.trim())||c.trim()===(e?.llamaCppNCpuFfn===void 0?``:String(e.llamaCppNCpuFfn)),onClick:()=>void N(),children:`Save`})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Leave blank for Auto: when a dense model narrowly exceeds discrete GPU memory, Gezel keeps attention on the GPU and moves only the smallest useful prefix of feed-forward layers to safe system RAM. This avoids the larger speed loss of moving whole layers. Enter 0 to disable the planner, or a positive layer count to pin `,(0,M.jsx)(`code`,{children:`--n-cpu-ffn`}),`. Takes effect the next time the engine starts.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`MoE expert offload`}),(0,M.jsxs)(`select`,{value:J(e?.llamaCppCpuMoe),onChange:e=>void re(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto — detect when offload is needed (default)`}),(0,M.jsx)(`option`,{value:`on`,children:`On — always offload experts (--cpu-moe)`}),(0,M.jsx)(`option`,{value:`off`,children:`Off — keep experts on the GPU`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`For big Mixture-of-Experts models on a small GPU: run attention on the GPU while streaming the sparse expert weights from system RAM — lets a model that wouldn't fit in VRAM run anyway. `,(0,M.jsx)(`em`,{children:`Auto`}),` turns this on only for a MoE model that won't fit in VRAM (and sizes a partial split when it can), and leaves dense models and UMA machines alone. Takes effect the next time the engine starts.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Full SWA cache`}),(0,M.jsxs)(`select`,{value:J(e?.llamaCppSwaFull),onChange:e=>void L(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto — full only when it fits fast memory`}),(0,M.jsx)(`option`,{value:`on`,children:`On — always full cache (--swa-full)`}),(0,M.jsx)(`option`,{value:`off`,children:`Off — memory-efficient windowed cache`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`For sliding-window models (the Gemma family): retain old KV entries that the memory-efficient windowed cache normally discards. This can enable prompt reuse and other cache operations where the engine supports them, but its memory cost grows with context.`,` `,(0,M.jsx)(`em`,{children:`Auto`}),` uses the full cache only when the model weights and full KV cache fit in fast memory — VRAM on a discrete GPU — and otherwise keeps the windowed cache. Takes effect the next time the engine starts.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Model loading`}),(0,M.jsxs)(`select`,{value:e?.llamaCppLoadMode??(e?.llamaCppMlock?`mlock`:`auto`),onChange:e=>void P(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto (recommended)`}),(0,M.jsx)(`option`,{value:`mmap`,children:`Memory mapped`}),(0,M.jsx)(`option`,{value:`none`,children:`Read into memory`}),(0,M.jsx)(`option`,{value:`mlock`,children:`Locked in memory`}),(0,M.jsx)(`option`,{value:`mmap+mlock`,children:`Memory mapped + locked`}),(0,M.jsx)(`option`,{value:`dio`,children:`Direct I/O`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Controls how model files enter memory. Auto normally uses memory mapping and is the best general choice. Locked modes resist swapping but hold RAM away from other apps; Direct I/O is for storage and platform troubleshooting. Existing `,(0,M.jsx)(`code`,{children:`llamaCppMlock`}),` settings are translated to the new v0.4.0 load mode without a deprecation warning.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Lazy tensor loading`}),(0,M.jsxs)(`select`,{value:e?.llamaCppLazyMode??`auto`,onChange:e=>void F(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto — tensors above 4 GiB (recommended)`}),(0,M.jsx)(`option`,{value:`on`,children:`On — always load eligible rows on demand`}),(0,M.jsx)(`option`,{value:`off`,children:`Off — keep eligible tensors resident`})]})]}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:`Loads rows from very large eligible tensors only when they are used. Auto follows llama.cpp's 4 GiB threshold; this is what lets models such as Qwen 3.8 Flash Next leave their large engram embedding table on fast storage instead of holding all of it in RAM. Forcing On can cut resident memory for smaller eligible embeddings but trades decode speed for storage reads. The engine memory-maps lazy ranges independently of the general loading choice above. Takes effect the next time the engine starts.`}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.5rem`,marginLeft:`10rem`},children:[`More engine flags (an explicit GPU-layer count, partial expert split, prompt-reuse size, threads, and a raw-flag escape hatch) live in `,(0,M.jsx)(`code`,{children:`config.json`}),` under the`,` `,(0,M.jsx)(`code`,{children:`llamaCpp*`}),` keys.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`External engine URL`}),(0,M.jsx)(`input`,{type:`text`,placeholder:`e.g. http://127.0.0.1:8080 (leave blank to use the supervised engine)`,value:i,onChange:e=>a(e.target.value),style:{flex:1}}),(0,M.jsx)(`button`,{type:`button`,disabled:p===`saving`||i===(e?.llamaCppBaseUrl??``),onClick:()=>void w(),children:`Save`})]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Override model path`}),(0,M.jsx)(`input`,{type:`text`,placeholder:`Absolute path to a .gguf file (overrides the local-models default)`,value:o,onChange:e=>s(e.target.value),style:{flex:1}}),(0,M.jsx)(`button`,{type:`button`,disabled:p===`saving`||o===(e?.llamaCppModelPath??``),onClick:()=>void te(),children:`Save`})]}),(0,M.jsx)(se,{})]})]})}function se(){let[e,t]=(0,j.useState)({kind:`idle`}),n=(0,j.useCallback)(async()=>{t({kind:`loading`});try{let e=await f.getLlamaCppLog(4096);t({kind:`loaded`,path:e.path,tail:e.tail})}catch(e){t({kind:`error`,message:e instanceof Error?e.message:String(e)})}},[]);return(0,M.jsxs)(`details`,{style:{marginTop:`1rem`},children:[(0,M.jsxs)(`summary`,{style:{cursor:`pointer`,userSelect:`none`},children:[`Engine log`,` `,(0,M.jsx)(`span`,{className:`muted small`,children:`— technical output from llama-server. Useful for bug reports.`})]}),(0,M.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,M.jsxs)(`div`,{className:`new-row`,style:{alignItems:`center`,gap:`0.5rem`},children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>void n(),disabled:e.kind===`loading`,children:e.kind===`loading`?`Loading…`:`Refresh`}),e.kind===`loaded`&&e.path&&(0,M.jsx)(`span`,{className:`muted small`,title:e.path,children:e.path}),e.kind===`loaded`&&!e.path&&(0,M.jsx)(`span`,{className:`muted small`,children:`No supervised engine running.`})]}),e.kind===`error`&&(0,M.jsxs)(`div`,{className:`muted small`,style:{marginTop:`0.5rem`,color:`#ff9b9b`},children:[`Couldn't load log: `,e.message]}),e.kind===`loaded`&&e.tail&&(0,M.jsx)(`pre`,{style:{marginTop:`0.5rem`,padding:`0.5rem`,background:`rgba(255,255,255,0.04)`,border:`1px solid rgba(255,255,255,0.1)`,borderRadius:4,maxHeight:`18rem`,overflow:`auto`,fontSize:`0.75rem`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:e.tail}),e.kind===`loaded`&&!e.tail&&e.path&&(0,M.jsx)(`div`,{className:`muted small`,style:{marginTop:`0.5rem`},children:`Log is empty. (Engine may not have started yet — try chatting with an on-device gezel first.)`})]})]})}export{oe as LlamaCppSettings};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{Et as r,G as i,K as a,L as o,N as s,Qt as c,_t as l,ut as u,xt as d}from"./dist-CE5CbmDb.js";import{t as f}from"./api-CmrgM5Rf.js";import{t as p}from"./model-context-DBqdK0PS.js";import{r as m}from"./model-memory-copy-Ds9w1uJE.js";import{t as h}from"./ConfirmDialog-Dt1ed4Fh.js";import{Mt as g}from"./index-DivKnJyx.js";import{t as _}from"./CatalogBrowser-DYXUZQ_t.js";import{n as ee,r as v,t as y}from"./InstallProgressRow-DyKOI4MU.js";import{t as b}from"./IncompleteDownloads-C8_XyP8O.js";import{t as x}from"./LicenseButton-D3VmcVG1.js";import{a as S,i as C,n as w,o as T,r as E,t as te}from"./UnrecognizedModels-BzdU1clO.js";import{t as D}from"./local-engine-label-BR-PGVFE.js";import{a as O,i as k,n as A,o as ne,t as re}from"./use-local-model-manager-8wvk-I-y.js";var j=e(t(),1),M=n();function N(e){return{usableBytes:e.usableBytes,totalRamBytes:e.totalRamBytes,gpuVramBytes:e.gpuMemoryKind===`integrated`?null:e.gpuVramBytes,...e.budgetBytes===void 0?{}:{admissibleBytes:e.budgetBytes}}}function P(e,t){let{totalRamBytes:n,gpuVramBytes:i}=N(t);return a(e,{ctxTokens:r({totalRamBytes:n,gpuVramBytes:i})})}function F(e,t){return o({residentBytes:i(e.llamaCpp.approxSizeBytes,{mmprojBytes:e.llamaCpp.mmproj?.sizeBytes})+P(e,t),isMoE:l(e.tags),...N(t)})}function I(e){return{platform:e.source===`darwin-unified`?`darwin`:`other`,gpuVramBytes:e.gpuVramBytes,...e.gpuMemoryKind?{gpuMemoryKind:e.gpuMemoryKind}:{},totalRamBytes:e.totalRamBytes,usableBytes:e.usableBytes,...e.budgetBytes===void 0?{}:{budgetBytes:e.budgetBytes}}}function L(e){return`~${m(e)}`}function R(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`})}function z(e){return e.kind!==`chat-model`||!e.llamaCpp?null:e}var ie={"mix of experts":`Only a fraction of the model's parameters run per token, so it's faster than a dense model of the same nominal size.`,vision:`Can accept images alongside text.`,tools:`Supports function/tool calling via the API.`,multimodal:`Handles multiple input types (text + images).`,large:`Heavy model — needs a lot of memory and runs more slowly.`,small:`Compact model — runs quickly on modest hardware.`};function B({onModelsChanged:e,compact:t=!1}){let{modelsLoading:n,models:r,modelsError:a,incomplete:m,unrecognized:y,installs:D,installWarning:O,setInstallWarning:ne,installError:B,setInstallError:H,installMismatch:U,setInstallMismatch:W,toDelete:G,setToDelete:K,fitness:q,probing:J,refreshFitness:Y,refresh:X,deleteOne:ae,startInstall:Z,retryInstall:oe,cancelInstall:se,downloadAnyway:ce}=re(A,e),[Q,le]=(0,j.useState)(null),[$,ue]=(0,j.useState)(!1),[de,fe]=(0,j.useState)(null),[pe,me]=(0,j.useState)(null),[he,ge]=(0,j.useState)(!1),[_e,ve]=(0,j.useState)([]),ye=(0,j.useCallback)(async(e,t)=>{me(e);try{let n=await f.getConfig();await f.updateConfig({nativeVision:{...n.nativeVision??{},[e]:t}}),await X()}catch{}finally{me(null)}},[X]);(0,j.useEffect)(()=>{f.getMemoryProfile().then(e=>le(e)).catch(()=>{}),f.getModelContextOverrides(`llama-cpp`).then(()=>ge(!0)).catch(()=>ge(!1))},[]);let be=(0,j.useMemo)(()=>new Set(r.map(e=>e.id)),[r]),xe=(0,j.useMemo)(()=>new Set(y.map(e=>e.id)),[y]),Se=(0,j.useMemo)(()=>{let e=new Map;for(let t of _e){let n=z(t.manifest);n&&e.set(n.id,n)}return e},[_e]);return(0,M.jsxs)(`div`,{className:`ollama-model-manager`,children:[D.size>0&&(0,M.jsxs)(`div`,{className:`ollama-section`,children:[(0,M.jsx)(`h4`,{children:`Downloading…`}),(0,M.jsx)(`div`,{className:`ollama-pull-list`,children:Array.from(D.values()).map(e=>(0,M.jsx)(V,{inst:e,onCancel:()=>se(e.catalogId),onRetry:()=>oe(e.catalogId)},e.catalogId))})]}),(0,M.jsx)(te,{items:y.filter(e=>!D.has(e.id)),onUpdate:e=>Z(e),onRemove:e=>K(e)}),(0,M.jsx)(b,{items:m.filter(e=>!D.has(e.id)),onResume:e=>Z(e),onDelete:e=>K(e)}),U&&(0,M.jsxs)(`div`,{className:`ollama-section`,children:[(0,M.jsxs)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginBottom:`0.5rem`},children:[`⚠ `,(0,M.jsx)(`code`,{children:U.catalogId}),` is newer on Hugging Face than the version Gezel knows about`]}),(0,M.jsxs)(`p`,{style:{marginBottom:`0.5rem`},children:[`The file `,(0,M.jsx)(`code`,{children:U.file}),` changed upstream, so its checksum no longer matches what this version of Gezel pinned. This is almost always a harmless upstream fix — model authors routinely re-publish chat templates and tokenizer configs — but we can't verify it automatically. You can download the current version now, or wait for a Gezel update with a refreshed catalog.`]}),(0,M.jsxs)(`div`,{style:{display:`flex`,gap:`0.75rem`},children:[(0,M.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>ce(U.catalogId),children:`Download anyway`}),(0,M.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>W(null),children:`Dismiss`})]})]}),B&&(0,M.jsx)(`div`,{className:`ollama-section`,children:(0,M.jsx)(`p`,{className:`error`,style:{marginBottom:`0.5rem`},children:B})}),O&&(0,M.jsx)(`div`,{className:`ollama-section`,children:(0,M.jsxs)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginBottom:`0.5rem`},children:[`⚠ `,O.id,`: `,O.message]})}),!t&&(0,M.jsx)(w,{engine:`llama-cpp`,onModelsChanged:e}),(n||r.length>0||a)&&(0,M.jsxs)(`div`,{className:`ollama-section`,children:[(0,M.jsx)(`h4`,{children:t?`Models on this device`:`Local models`}),n&&r.length===0&&!a&&(0,M.jsx)(`p`,{className:`muted small`,"aria-live":`polite`,children:`Checking shared models… Large models can take a few minutes the first time; later starts use the local verification cache.`}),a&&(0,M.jsx)(`p`,{className:`error`,children:a}),r.length>0&&(0,M.jsx)(`div`,{className:`ollama-model-table-wrap`,children:(0,M.jsxs)(`table`,{className:`ollama-model-table`,children:[(0,M.jsxs)(`colgroup`,{children:[(0,M.jsx)(`col`,{className:`model-name-column`}),(0,M.jsx)(`col`,{}),(0,M.jsx)(`col`,{}),(0,M.jsx)(`col`,{}),(0,M.jsx)(`col`,{}),(0,M.jsx)(`col`,{})]}),(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{children:[(0,M.jsx)(`th`,{children:`Name`}),(0,M.jsx)(`th`,{children:`Size`}),(0,M.jsx)(`th`,{children:`Quant`}),(0,M.jsx)(`th`,{title:`Effective per-turn context size after Gezel's settings and memory limits`,children:`Context size`}),(0,M.jsx)(`th`,{title:`Representative startup and decode speed with an approximately 20K-token prompt`,children:`Fitness`}),(0,M.jsx)(`th`,{})]})}),(0,M.jsx)(`tbody`,{children:r.map(e=>{let t=D.has(e.id),n=`llama-cpp:${e.id}`,r=q.get(n),a=Se.get(e.id),d=e.predictedResidentBytes??i(e.approxSizeBytes,{mmprojBytes:e.mmprojSizeBytes}),m=Q?o({residentBytes:d,isMoE:l(a?.tags),...N(Q)}):void 0,h=Q&&a?u(I(Q),{isMoE:l(a.tags),fitTier:m?.tier??`fits`,residentBytes:d}):null;return(0,M.jsxs)(j.Fragment,{children:[(0,M.jsxs)(`tr`,{children:[(0,M.jsx)(`td`,{className:`model-name-table-cell`,children:(0,M.jsxs)(`div`,{className:`model-name-cell`,children:[(0,M.jsx)(`code`,{children:e.id}),(0,M.jsxs)(`div`,{className:`model-name-meta`,children:[h&&(0,M.jsx)(`span`,{className:`gz-status-pill${h.kind===`moe-good-match`?` gz-status-pill--ok`:``}`,title:h.detail,children:h.label}),e.updateAvailable&&(0,M.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:e.updateReason??(e.availableVersion?`A newer build is available in the catalog (→ v${e.availableVersion}). Updating downloads only the files that differ.`:`A newer build is available in the catalog.`),children:`update available`})]})]})}),(0,M.jsx)(k,{model:e}),(0,M.jsx)(`td`,{title:c(e.quantization,e.ggufQuantization),children:s(e.quantization,e.ggufQuantization)}),(0,M.jsx)(`td`,{title:e.effectiveContextWindow?e.overrideContextTokens===void 0?`Gezel will grant up to ${e.effectiveContextWindow.toLocaleString()} tokens per turn${e.contextWindow?`; the model advertises ${e.contextWindow.toLocaleString()} tokens`:``}. The effective size accounts for model tuning, settings, concurrency, and available memory — Adaptive grows it past 64K when fast memory has room.`:`You've set this model to ${e.overrideContextTokens.toLocaleString()} tokens per turn; Gezel grants up to what memory allows (currently ${e.effectiveContextWindow.toLocaleString()}).`:e.contextSizingStatus===`restart-required`?`This model is running with a different context window than the current sizing settings resolve to. Restart the local engine (or let it go idle) so Gezel can re-admit it — no memory change needed.`:e.contextSizingStatus===`insufficient-memory`?`The selected context sizing policy needs${e.contextWindow?` this model's full advertised ${e.contextWindow.toLocaleString()}-token window`:` more context`}, which does not fit in memory safely. Choose Adaptive, unload another model, or free memory before trying again.`:`The effective context size is unavailable.`,children:e.contextSizingStatus===`restart-required`?`Restart needed`:e.contextSizingStatus===`insufficient-memory`?`Won't fit`:(0,M.jsxs)(M.Fragment,{children:[p(e.effectiveContextWindow),e.overrideContextTokens!==void 0&&(0,M.jsx)(`span`,{className:`gz-budget-tag gz-budget-tag-custom model-context-custom-tag`,children:`custom`})]})}),(0,M.jsx)(E,{entry:r,probing:J.includes(n)}),(0,M.jsx)(`td`,{className:`model-actions-table-cell`,children:(0,M.jsxs)(`div`,{className:`model-actions-cell`,children:[(0,M.jsx)(`div`,{className:`model-action-status`,children:e.readOnly&&(0,M.jsx)(`span`,{className:`muted small`,title:`Provided by the machine-wide install (shared asset store). It can't be removed from here — manage it with the machine installer, or install a user-owned copy to shadow it.`,children:`Machine model`})}),(0,M.jsx)(`div`,{className:`model-action-links`,children:(0,M.jsx)(S,{engine:`llama-cpp`,model:e,updating:t,contextSupported:he,contextEditorOpen:de===e.id,onToggleContextEditor:()=>fe(t=>t===e.id?null:e.id),...e.nativeVisionEnabled===void 0?{}:{visionAction:{enabled:e.nativeVisionEnabled,busy:pe===e.id,onToggle:()=>void ye(e.id,!e.nativeVisionEnabled)}},fitnessAction:C(r,J.includes(n),()=>{f.runModelFitnessProbe(`llama-cpp`,e.id).then(()=>Y()).catch(()=>{})}),onUpdate:()=>Z(e.id),onDelete:()=>K(e.id)})})]})})]}),de===e.id&&(0,M.jsx)(`tr`,{className:`model-context-editor-row`,children:(0,M.jsx)(`td`,{colSpan:6,children:(0,M.jsx)(T,{engine:`llama-cpp`,model:e,onSaved:X})})})]},e.id)})})]})})]}),(0,M.jsxs)(`div`,{className:`ollama-section ollama-section--flat ollama-section--download`,children:[(0,M.jsx)(`h4`,{children:`Download a model`}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`Models are hosted by`,` `,(0,M.jsx)(`a`,{href:`https://huggingface.co`,target:`_blank`,rel:`noreferrer`,style:{color:`inherit`},children:`Hugging Face`}),`, a community library of open, freely available AI models. Your device downloads them directly.`]}),(0,M.jsxs)(`p`,{className:`muted small`,children:[Q?`Models that may not fit this machine, and retired models, are hidden by default. `:`Retired models are hidden by default. `,(0,M.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>ue(e=>!e),style:{padding:0},children:$?Q?`Hide retired and oversized models`:`Hide retired models`:`Show all models`})]}),(0,M.jsx)(_,{kind:`chat-model`,emptyMessage:`No on-device models in the catalog yet.`,onItemsLoaded:ve,tagTooltips:ie,filter:e=>{let t=z(e.manifest);return!(!t||!$&&d(t)||!$&&Q&&!F(t,Q).runnable)},action:e=>{let t=z(e.manifest);if(!t)return null;let n=be.has(t.id),r=xe.has(t.id),a=D.get(t.id),o=a&&a.totalBytes>0?Math.min(100,Math.round(a.bytesWritten/a.totalBytes*100)):null,s=Q?F(t,Q):null;return(0,M.jsxs)(`div`,{className:`catalog-ollama-action`,children:[(0,M.jsxs)(`div`,{className:`catalog-ollama-meta`,children:[(0,M.jsxs)(`div`,{className:`catalog-ollama-specs muted small`,children:[(0,M.jsx)(ee,{repo:t.llamaCpp.huggingfaceRepo}),(0,M.jsx)(`span`,{children:`·`}),(0,M.jsx)(`span`,{children:t.parameterSize}),(0,M.jsx)(`span`,{children:`·`}),(0,M.jsx)(`span`,{children:L(t.llamaCpp.approxSizeBytes)}),R(t.releasedAt)&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{children:`·`}),(0,M.jsx)(`span`,{children:R(t.releasedAt)})]})]}),(0,M.jsxs)(`div`,{className:`catalog-ollama-pills`,children:[(0,M.jsx)(x,{manifest:t,fallbackHref:v(t.llamaCpp.huggingfaceRepo)}),s&&s.tier!==`fits`&&(0,M.jsx)(`span`,{className:`gz-status-pill ${s.tier===`fits-offload`?`gz-status-pill--ok`:`gz-status-pill--warn`}`,title:s.detail,children:s.label}),(()=>{let n=Q&&s?u(I(Q),{isMoE:l(e.manifest.tags),fitTier:s.tier,residentBytes:i(t.llamaCpp.approxSizeBytes)+P(t,Q)}):null;return n?(0,M.jsx)(`span`,{className:`gz-status-pill${n.kind===`moe-good-match`?` gz-status-pill--ok`:``}`,title:n.detail,children:n.label}):null})()]})]}),(0,M.jsx)(`button`,{type:`button`,disabled:n||r||!!a,onClick:()=>Z(t.id),children:n?`On device`:a?a.phase===`downloading`?o===null?`Downloading…`:`Downloading… ${o}%`:a.phase===`verifying`?`Verifying…`:`Reading metadata…`:r?`Needs attention above`:`Download`})]})}})]}),(0,M.jsxs)(`div`,{className:`ollama-section ollama-section--flat`,children:[(0,M.jsx)(g,{}),(0,M.jsx)(`span`,{className:`muted small`,style:{marginLeft:`0.75rem`},children:`Import from a gezel local model package`})]}),(0,M.jsx)(h,{open:G!==null,title:`Delete ${G??``}?`,message:`This removes the downloaded model from your device. It stays available in the catalog — you can download it again any time.`,confirmLabel:`Delete`,danger:!0,onConfirm:ae,onCancel:()=>K(null)})]})}function V({inst:e,onCancel:t,onRetry:n}){let r=e.totalBytes>0,i=r?Math.min(100,Math.round(e.bytesWritten/e.totalBytes*100)):0,a;if(e.error)a=e.error;else if(e.retrying){let t=Math.max(1,Math.round(e.retrying.delayMs/1e3));a=`${e.retrying.reason} — retrying in ${t}s (attempt ${e.retrying.attempt}/${e.retrying.maxAttempts})`}else a=e.phase===`downloading`?r?`Downloading ${m(e.bytesWritten)} of ${m(e.totalBytes)} (${i}%)`:e.bytesWritten>0?`Downloading ${m(e.bytesWritten)}…`:`Preparing download…`:e.phase===`verifying`?`Checking download…`:`Reading model info…`;let o=e.phase!==`downloading`||!r;return(0,M.jsx)(y,{title:(0,M.jsx)(`code`,{children:e.catalogId}),status:a,percent:o?null:i,tone:e.error?`error`:e.retrying?`warning`:`normal`,onCancel:t,onRetry:n})}var H=80,U=40,W=95,G=5;function K(e){return e===`win32`||e===`linux`}function q({config:e,onConfigChanged:t,platform:n}){let r=e?.deviceSafety?.mode??`observe`,i=e?.deviceSafety?.maxStartTemperatureC??H,[a,o]=(0,j.useState)(String(i)),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(null);(0,j.useEffect)(()=>{o(String(i))},[i]);let d=(0,j.useCallback)(async n=>{if(!s){c(!0),u(null);try{t(await f.updateConfig({deviceSafety:{...e?.deviceSafety??{},...n}}))}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}}},[e?.deviceSafety,t,s]),p=(0,j.useCallback)(e=>{r!==e&&d({mode:e})},[r,d]),m=(0,j.useCallback)(()=>{let e=Number(a);if(!Number.isInteger(e)||e<U||e>W){u(`Enter a whole number from ${U} to ${W}°C.`);return}if(e===i){u(null);return}d({maxStartTemperatureC:e,resumeTemperatureC:e-G})},[i,d,a]);if(!K(n))return null;let h=Number(a),g=(Math.min(W,Math.max(U,h))-U)/(W-U)*100;return(0,M.jsxs)(`section`,{className:`machine-health-settings`,"aria-labelledby":`machine-health-heading`,children:[(0,M.jsx)(`h4`,{id:`machine-health-heading`,children:`Machine health`}),(0,M.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`Choose whether Gezel only reports accelerator health or also waits for the machine to cool before starting new on-device work.`}),(0,M.jsxs)(`fieldset`,{className:`gz-tray machine-health-mode`,children:[(0,M.jsx)(`legend`,{className:`sr-only`,children:`Machine health mode`}),(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":r===`observe`,className:`gz-key gz-key--stacked${r===`observe`?` gz-key-active`:``}`,disabled:s,onClick:()=>p(`observe`),children:[(0,M.jsx)(`span`,{children:`Observe`}),(0,M.jsx)(`small`,{children:`Report only`})]}),(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":r===`guard`,className:`gz-key gz-key--stacked${r===`guard`?` gz-key-active`:``}`,disabled:s,onClick:()=>p(`guard`),children:[(0,M.jsx)(`span`,{children:`Manage`}),(0,M.jsx)(`small`,{children:`Pause new work`})]})]}),r===`off`&&(0,M.jsx)(`p`,{className:`muted small machine-health-off-note`,children:`Machine health is disabled by an advanced configuration override. Choose Observe or Manage to turn it back on.`}),(0,M.jsxs)(`div`,{className:`machine-health-temperature-row`,children:[(0,M.jsx)(`label`,{htmlFor:`machine-health-temperature`,children:`Manage temperature`}),(0,M.jsxs)(`div`,{className:`machine-health-temperature-control`,children:[(0,M.jsxs)(`div`,{className:`machine-health-temperature-slider-wrap`,children:[(0,M.jsx)(`input`,{id:`machine-health-temperature`,className:`machine-health-temperature-slider`,type:`range`,min:U,max:W,step:1,value:a,disabled:s,"aria-describedby":`machine-health-temperature-help`,"aria-valuetext":`${a} degrees Celsius`,style:{"--machine-health-temperature-progress":`${g}%`},onChange:e=>o(e.target.value),onPointerUp:e=>e.currentTarget.blur(),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}}),(0,M.jsxs)(`div`,{className:`machine-health-temperature-scale`,"aria-hidden":`true`,children:[(0,M.jsxs)(`span`,{children:[U,`°`]}),(0,M.jsxs)(`span`,{className:`machine-health-temperature-default`,children:[H,`° default`]}),(0,M.jsxs)(`span`,{children:[W,`°`]})]})]}),(0,M.jsxs)(`output`,{className:`machine-health-temperature-value`,htmlFor:`machine-health-temperature`,"aria-label":`Manage temperature: ${a} degrees Celsius`,children:[(0,M.jsx)(`span`,{className:`machine-health-temperature-value-number`,children:a}),(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`°C`})]})]})]}),(0,M.jsxs)(`p`,{id:`machine-health-temperature-help`,className:`muted small machine-health-temperature-help`,children:[`In Manage mode, new accelerator work waits above this temperature and resumes after a 5°C cooldown. The default is 80°C. Both modes retain the `,105,`°C emergency cutoff.`]}),s&&(0,M.jsx)(`output`,{className:`muted small machine-health-save-state`,children:`Saving…`}),l&&(0,M.jsx)(`p`,{className:`error small machine-health-save-state`,role:`alert`,children:l})]})}function J(e){return e===!0?`on`:e===!1?`off`:`auto`}function Y(e,t){return e===`darwin`?[`metal`]:t===`cuda`?[`cuda`,`vulkan`,`cpu`]:t===`vulkan`?[`vulkan`,`cpu`]:t===`cpu`?[`cpu`]:[`cuda`,`vulkan`,`cpu`]}function X(e){return e===`cuda`?`CUDA (Nvidia GPU)`:e===`vulkan`?`Vulkan (any GPU)`:e===`metal`?`Metal (Apple GPU)`:`CPU only`}function ae(e){return e===`amd`?`, AMD GPU detected`:e===`nvidia`?`, Nvidia GPU detected`:e===`intel`?`, Intel GPU detected`:``}function Z(e,t){if(!t?.llamaCppBackend)return!1;let n=t.llamaCppBackend,r=e?.llamaCppBackendOverride&&e.llamaCppBackendOverride!==`auto`?e.llamaCppBackendOverride:t.llamaCppDetectedBackend??n;return!t.llamaCppQuarantinedBackends?.includes(r)&&r!==n}function oe({config:e,onConfigChanged:t,health:n,title:r}){let[i,a]=(0,j.useState)(e?.llamaCppBaseUrl??``),[o,s]=(0,j.useState)(e?.llamaCppModelPath??``),[c,l]=(0,j.useState)(e?.llamaCppNCpuFfn===void 0?``:String(e.llamaCppNCpuFfn)),[u,d]=(0,j.useState)([]),[p,m]=(0,j.useState)(`idle`),[h,g]=(0,j.useState)(`adaptive`),[_,ee]=(0,j.useState)(!0),v=(0,j.useRef)(null),y=(0,j.useRef)(!0),b=(0,j.useCallback)(()=>{v.current!==null&&(window.clearTimeout(v.current),v.current=null)},[]);(0,j.useEffect)(()=>(y.current=!0,()=>{y.current=!1,b()}),[b]);let x=(0,j.useCallback)(e=>{y.current&&(b(),m(e))},[b]),S=(0,j.useCallback)(()=>{y.current&&(b(),m(`saved`),v.current=window.setTimeout(()=>{v.current=null,y.current&&m(`idle`)},1200))},[b]);(0,j.useEffect)(()=>{a(e?.llamaCppBaseUrl??``)},[e?.llamaCppBaseUrl]),(0,j.useEffect)(()=>{s(e?.llamaCppModelPath??``)},[e?.llamaCppModelPath]),(0,j.useEffect)(()=>{l(e?.llamaCppNCpuFfn===void 0?``:String(e.llamaCppNCpuFfn))},[e?.llamaCppNCpuFfn]);let C=(0,j.useCallback)(async()=>{try{let e=await f.listLlamaCppModels();d(e.models)}catch{}},[]);(0,j.useEffect)(()=>{C()},[C]),(0,j.useEffect)(()=>{let e=!1;return f.getLlamaCppContextSizing().then(t=>{e||g(t.policy)}).catch(()=>{}).finally(()=>{e||ee(!1)}),()=>{e=!0}},[]);let w=(0,j.useCallback)(async()=>{let e=i.trim();x(`saving`);try{let n=await f.updateConfig({llamaCppBaseUrl:e===``?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[i,t,S,x]),T=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppBackendOverride:e===`auto`?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),E=(0,j.useCallback)(async e=>{x(`saving`);try{let t=await f.updateLlamaCppContextSizing(e);if(!y.current)return;g(t.policy),S()}catch{x(`idle`)}},[S,x]),te=(0,j.useCallback)(async()=>{let e=o.trim();x(`saving`);try{let n=await f.updateConfig({llamaCppModelPath:e===``?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[o,t,S,x]),k=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppKvCacheType:e===`q8_0`?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),A=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppFlashAttn:e===`auto`?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),re=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppCpuMoe:e===`auto`?null:e===`on`});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),N=(0,j.useCallback)(async()=>{let e=c.trim(),n=e===``?null:Number(e);if(!(n!==null&&(!Number.isInteger(n)||n<0))){x(`saving`);try{let e=await f.updateConfig({llamaCppNCpuFfn:n});if(!y.current)return;t(e),S()}catch{x(`idle`)}}},[c,t,S,x]),P=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppLoadMode:e===`auto`?null:e,llamaCppMlock:null});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),F=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppLazyMode:e===`auto`?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),I=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppReasoningPreserve:e?!0:null});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),L=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppSwaFull:e===`auto`?null:e===`on`});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),R=(0,j.useCallback)(async e=>{x(`saving`);try{let n=await f.updateConfig({llamaCppSpecType:e===`auto`?null:e});if(!y.current)return;t(n),S()}catch{x(`idle`)}},[t,S,x]),z=(0,j.useCallback)(async n=>{x(`saving`);try{let r=await f.updateConfig({defaultModel:{...e?.defaultModel,"llama-cpp":n??void 0}});if(!y.current)return;t(r),S()}catch{x(`idle`)}},[e?.defaultModel,t,S,x]),ie=e?.defaultModel?.[`llama-cpp`],V=!!e?.llamaCppBaseUrl;return(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,M.jsx)(`h3`,{children:r??D(`llama-cpp`,n?.platform)}),(0,M.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`Run AI models directly on this device using the llama.cpp engine, making the best use of the hardware you already have. Your conversations stay on your computer — no account to set up, no data sent to the cloud.`}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`span`,{className:`muted small`,children:`Status:`}),(0,M.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:`ready`}),V&&(0,M.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:`Using an external engine at: ${e?.llamaCppBaseUrl}`,children:`using external engine`}),p===`saved`&&(0,M.jsx)(`span`,{className:`muted small`,children:`saved ✓`})]})]}),u.length>1&&(0,M.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,M.jsx)(`h4`,{children:`Default model`}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Which local model new chat sessions use when a gezel doesn't pin one.`}),(0,M.jsx)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`},children:(0,M.jsxs)(`select`,{value:ie??``,onChange:e=>void z(e.target.value||void 0),children:[(0,M.jsx)(`option`,{value:``,children:`First local model`}),u.map(e=>(0,M.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.id,`)`]},e.id))]})})]}),(0,M.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,M.jsx)(`h4`,{children:`Models`}),(0,M.jsx)(B,{onModelsChanged:C},h)]}),(0,M.jsx)(ne,{provider:`llama-cpp`}),(0,M.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,M.jsx)(`h4`,{style:{marginBottom:`0.5rem`},children:`Concurrent replicas`}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Run multiple copies of the same model so unrelated sessions don't queue behind each other. Weights are shared by the OS via mmap so disk cost stays at one model file; resident memory grows because each clone keeps its own KV cache and activations.`}),(0,M.jsx)(O,{provider:`llama-cpp`,modelId:e?.defaultModel?.[`llama-cpp`]??null,config:e,onConfigChanged:t})]}),(0,M.jsx)(q,{config:e,onConfigChanged:t,platform:window.__GEZEL__?.platform??n?.platform}),(0,M.jsxs)(`details`,{className:`llama-advanced-settings`,children:[(0,M.jsxs)(`summary`,{className:`llama-advanced-summary`,children:[(0,M.jsx)(`span`,{className:`llama-advanced-caret`,"aria-hidden":`true`,children:`›`}),(0,M.jsx)(`h4`,{children:`Advanced`})]}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.75rem`},children:`Tune how the managed on-device engine starts, or override how Gezel connects to it. Most users don't need any of these — the supervised engine handles everything. Set them only when you need a different context policy, are running your own engine process, point at a weights file that isn't in the catalog, or downgrade the accelerator.`}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{htmlFor:`llama-cpp-context-sizing`,className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Context sizing`}),(0,M.jsxs)(`select`,{id:`llama-cpp-context-sizing`,value:h,disabled:_||p===`saving`||V,onChange:e=>void E(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`adaptive`,children:`Adaptive (recommended)`}),(0,M.jsx)(`option`,{value:`model-max`,children:`Model maximum (strict)`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[(0,M.jsx)(`em`,{children:`Adaptive`}),` starts from model tuning (64K by default), reduces concurrency before it shortens a larger tuned window, and grows the window toward the model's maximum when fast memory has room to spare — consolidating down to two concurrent chats when that buys a meaningfully longer window, never fewer. Each model can also be pinned to a specific size from its row in the list below. `,(0,M.jsx)(`em`,{children:`Model maximum`}),` requests the model's full advertised window; if one engine slot cannot hold it safely, the model will not start. This is a machine-wide managed-engine setting. Changing it restarts idle local engines right away; a model that is mid-conversation finishes its current turn first.`,V?` External engine URLs manage their own context size.`:``]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{htmlFor:`llama-cpp-engine-backend`,className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Engine backend`}),(0,M.jsxs)(`select`,{id:`llama-cpp-engine-backend`,value:e?.llamaCppBackendOverride??`auto`,onChange:e=>void T(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsxs)(`option`,{value:`auto`,children:[`Auto-detect`,n?.llamaCppDetectedBackend?` (machine supports: ${n.llamaCppDetectedBackend}${ae(n.llamaCppDetectedVendor)})`:``]}),Y(n?.platform,n?.llamaCppDetectedBackend).map(e=>(0,M.jsx)(`option`,{value:e,children:X(e)},e))]}),(0,M.jsx)(`span`,{className:`muted`,style:{fontSize:`0.85rem`},children:Z(e,n)?`Restart the app to apply`:``})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Auto-detect picks the fastest backend your machine supports; the other options are downgrades you can pin if the faster path is misbehaving. Switching `,(0,M.jsx)(`em`,{children:`back`}),` to Auto-detect from a pinned override also requires a restart.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`KV cache quantization`}),(0,M.jsxs)(`select`,{value:e?.llamaCppKvCacheType??`q8_0`,onChange:e=>void k(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`f16`,children:`f16 — full precision (most memory)`}),(0,M.jsx)(`option`,{value:`q8_0`,children:`q8_0 — balanced (default)`}),(0,M.jsx)(`option`,{value:`q4_0`,children:`q4_0 — smallest (most savings)`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Sets `,(0,M.jsx)(`code`,{children:`--cache-type-k`}),` / `,(0,M.jsx)(`code`,{children:`--cache-type-v`}),` for llama-server. Quantizing the KV cache frees RAM for longer contexts and more concurrent sessions: q8_0 is near-lossless at ~50% savings vs. f16, while q4_0 saves the most but can dent quality on attention-sensitive models. Takes effect the next time the engine starts — restart the app to apply now.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Flash attention`}),(0,M.jsxs)(`select`,{value:typeof e?.llamaCppFlashAttn==`string`?e.llamaCppFlashAttn:e?.llamaCppFlashAttn===!0?`on`:`auto`,onChange:e=>void A(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto (recommended)`}),(0,M.jsx)(`option`,{value:`on`,children:`On`}),(0,M.jsx)(`option`,{value:`off`,children:`Off`})]})]}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:`Faster attention on modern GPUs, and effectively required for the fast path under a quantized KV cache (the default). Auto lets llama-server decide; the engine forces it on when the KV cache is quantized. Takes effect the next time the engine starts.`}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Speculative decoding`}),(0,M.jsxs)(`select`,{value:e?.llamaCppSpecType??`auto`,onChange:e=>void R(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto — MTP when the model supports it (recommended)`}),(0,M.jsx)(`option`,{value:`none`,children:`Off`}),(0,M.jsx)(`option`,{value:`ngram-mod`,children:`N-gram lookup (no draft model)`}),(0,M.jsx)(`option`,{value:`draft-mtp`,children:`Model MTP head (force when compatible)`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Drafts several tokens per step and verifies them against the target model. `,(0,M.jsx)(`em`,{children:`Auto`}),` `,`enables MTP only when the installed weights confirm a compatible prediction head; otherwise speculative decoding stays off. `,(0,M.jsx)(`em`,{children:`N-gram`}),` needs no extra model and helps most on repetitive or structured output. Takes effect the next time the engine starts.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Reasoning history`}),(0,M.jsxs)(`select`,{value:e?.llamaCppReasoningPreserve===!0?`on`:`off`,onChange:e=>void I(e.target.value===`on`),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`off`,children:`Don't retain private reasoning (default)`}),(0,M.jsx)(`option`,{value:`on`,children:`Retain across turns`})]})]}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:`Replays a model's private reasoning into later turns when its chat template supports it. This can improve continuity in long tool loops, but consumes more context and can make a model cling to an earlier approach. Gezel explicitly keeps both the engine template and replay policy in sync. Takes effect the next time the engine starts.`}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{htmlFor:`llama-cpp-n-cpu-ffn`,className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Dense FFN offload`}),(0,M.jsx)(`input`,{id:`llama-cpp-n-cpu-ffn`,type:`number`,min:0,step:1,placeholder:`Auto`,value:c,onChange:e=>l(e.target.value),style:{flex:1,maxWidth:`20rem`}}),(0,M.jsx)(`button`,{type:`button`,disabled:p===`saving`||!/^(?:|0|[1-9]\d*)$/.test(c.trim())||c.trim()===(e?.llamaCppNCpuFfn===void 0?``:String(e.llamaCppNCpuFfn)),onClick:()=>void N(),children:`Save`})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Leave blank for Auto: when a dense model narrowly exceeds discrete GPU memory, Gezel keeps attention on the GPU and moves only the smallest useful prefix of feed-forward layers to safe system RAM. This avoids the larger speed loss of moving whole layers. Enter 0 to disable the planner, or a positive layer count to pin `,(0,M.jsx)(`code`,{children:`--n-cpu-ffn`}),`. Takes effect the next time the engine starts.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`MoE expert offload`}),(0,M.jsxs)(`select`,{value:J(e?.llamaCppCpuMoe),onChange:e=>void re(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto — detect when offload is needed (default)`}),(0,M.jsx)(`option`,{value:`on`,children:`On — always offload experts (--cpu-moe)`}),(0,M.jsx)(`option`,{value:`off`,children:`Off — keep experts on the GPU`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`For big Mixture-of-Experts models on a small GPU: run attention on the GPU while streaming the sparse expert weights from system RAM — lets a model that wouldn't fit in VRAM run anyway. `,(0,M.jsx)(`em`,{children:`Auto`}),` turns this on only for a MoE model that won't fit in VRAM (and sizes a partial split when it can), and leaves dense models and UMA machines alone. Takes effect the next time the engine starts.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Full SWA cache`}),(0,M.jsxs)(`select`,{value:J(e?.llamaCppSwaFull),onChange:e=>void L(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto — full only when it fits fast memory`}),(0,M.jsx)(`option`,{value:`on`,children:`On — always full cache (--swa-full)`}),(0,M.jsx)(`option`,{value:`off`,children:`Off — memory-efficient windowed cache`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`For sliding-window models (the Gemma family): retain old KV entries that the memory-efficient windowed cache normally discards. This can enable prompt reuse and other cache operations where the engine supports them, but its memory cost grows with context.`,` `,(0,M.jsx)(`em`,{children:`Auto`}),` uses the full cache only when the model weights and full KV cache fit in fast memory — VRAM on a discrete GPU — and otherwise keeps the windowed cache. Takes effect the next time the engine starts.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Model loading`}),(0,M.jsxs)(`select`,{value:e?.llamaCppLoadMode??(e?.llamaCppMlock?`mlock`:`auto`),onChange:e=>void P(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto (recommended)`}),(0,M.jsx)(`option`,{value:`mmap`,children:`Memory mapped`}),(0,M.jsx)(`option`,{value:`none`,children:`Read into memory`}),(0,M.jsx)(`option`,{value:`mlock`,children:`Locked in memory`}),(0,M.jsx)(`option`,{value:`mmap+mlock`,children:`Memory mapped + locked`}),(0,M.jsx)(`option`,{value:`dio`,children:`Direct I/O`})]})]}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Controls how model files enter memory. Auto normally uses memory mapping and is the best general choice. Locked modes resist swapping but hold RAM away from other apps; Direct I/O is for storage and platform troubleshooting. Existing `,(0,M.jsx)(`code`,{children:`llamaCppMlock`}),` settings are translated to the new v0.4.0 load mode without a deprecation warning.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Lazy tensor loading`}),(0,M.jsxs)(`select`,{value:e?.llamaCppLazyMode??`auto`,onChange:e=>void F(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,M.jsx)(`option`,{value:`auto`,children:`Auto — tensors above 4 GiB (recommended)`}),(0,M.jsx)(`option`,{value:`on`,children:`On — always load eligible rows on demand`}),(0,M.jsx)(`option`,{value:`off`,children:`Off — keep eligible tensors resident`})]})]}),(0,M.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:`Loads rows from very large eligible tensors only when they are used. Auto follows llama.cpp's 4 GiB threshold; this is what lets models such as Qwen 3.8 Flash Next leave their large engram embedding table on fast storage instead of holding all of it in RAM. Forcing On can cut resident memory for smaller eligible embeddings but trades decode speed for storage reads. The engine memory-maps lazy ranges independently of the general loading choice above. Takes effect the next time the engine starts.`}),(0,M.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.5rem`,marginLeft:`10rem`},children:[`More engine flags (an explicit GPU-layer count, partial expert split, prompt-reuse size, threads, and a raw-flag escape hatch) live in `,(0,M.jsx)(`code`,{children:`config.json`}),` under the`,` `,(0,M.jsx)(`code`,{children:`llamaCpp*`}),` keys.`]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`External engine URL`}),(0,M.jsx)(`input`,{type:`text`,placeholder:`e.g. http://127.0.0.1:8080 (leave blank to use the supervised engine)`,value:i,onChange:e=>a(e.target.value),style:{flex:1}}),(0,M.jsx)(`button`,{type:`button`,disabled:p===`saving`||i===(e?.llamaCppBaseUrl??``),onClick:()=>void w(),children:`Save`})]}),(0,M.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`,alignItems:`center`},children:[(0,M.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Override model path`}),(0,M.jsx)(`input`,{type:`text`,placeholder:`Absolute path to a .gguf file (overrides the local-models default)`,value:o,onChange:e=>s(e.target.value),style:{flex:1}}),(0,M.jsx)(`button`,{type:`button`,disabled:p===`saving`||o===(e?.llamaCppModelPath??``),onClick:()=>void te(),children:`Save`})]}),(0,M.jsx)(se,{})]})]})}function se(){let[e,t]=(0,j.useState)({kind:`idle`}),n=(0,j.useCallback)(async()=>{t({kind:`loading`});try{let e=await f.getLlamaCppLog(4096);t({kind:`loaded`,path:e.path,tail:e.tail})}catch(e){t({kind:`error`,message:e instanceof Error?e.message:String(e)})}},[]);return(0,M.jsxs)(`details`,{style:{marginTop:`1rem`},children:[(0,M.jsxs)(`summary`,{style:{cursor:`pointer`,userSelect:`none`},children:[`Engine log`,` `,(0,M.jsx)(`span`,{className:`muted small`,children:`— technical output from llama-server. Useful for bug reports.`})]}),(0,M.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,M.jsxs)(`div`,{className:`new-row`,style:{alignItems:`center`,gap:`0.5rem`},children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>void n(),disabled:e.kind===`loading`,children:e.kind===`loading`?`Loading…`:`Refresh`}),e.kind===`loaded`&&e.path&&(0,M.jsx)(`span`,{className:`muted small`,title:e.path,children:e.path}),e.kind===`loaded`&&!e.path&&(0,M.jsx)(`span`,{className:`muted small`,children:`No supervised engine running.`})]}),e.kind===`error`&&(0,M.jsxs)(`div`,{className:`muted small`,style:{marginTop:`0.5rem`,color:`#ff9b9b`},children:[`Couldn't load log: `,e.message]}),e.kind===`loaded`&&e.tail&&(0,M.jsx)(`pre`,{style:{marginTop:`0.5rem`,padding:`0.5rem`,background:`rgba(255,255,255,0.04)`,border:`1px solid rgba(255,255,255,0.1)`,borderRadius:4,maxHeight:`18rem`,overflow:`auto`,fontSize:`0.75rem`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:e.tail}),e.kind===`loaded`&&!e.tail&&e.path&&(0,M.jsx)(`div`,{className:`muted small`,style:{marginTop:`0.5rem`},children:`Log is empty. (Engine may not have started yet — try chatting with an on-device gezel first.)`})]})]})}export{oe as LlamaCppSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./styles-CqO-rmOt.js";import{Ct as i}from"./index-DivKnJyx.js";var a=e(t(),1),o=n();function s({value:e,readOnly:t,placeholder:n,minHeight:s=`80px`,maxHeight:c=`40vh`,onCommit:l}){let u=i(),d=(0,a.useRef)(e),f=(0,a.useRef)(e),p=(0,a.useCallback)(e=>{d.current=e},[]),m=(0,a.useCallback)(()=>{t||d.current!==f.current&&(f.current=d.current,l(d.current))},[t,l]),h=(0,a.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||m()},[m]),g=(0,a.useRef)(m);return g.current=m,(0,a.useEffect)(()=>()=>g.current(),[]),(0,o.jsx)(`div`,{className:`markdown-field`,onBlur:h,children:(0,o.jsx)(r,{initialMarkdown:e,initialView:`wysiwyg`,onChange:p,readOnly:t??!1,colorScheme:u,uxFont:`var(--font-ui)`,...n?{placeholder:n}:{},minHeight:s,maxHeight:c,showPlayTab:!1,showStatusBar:!1,showFilesToggle:!1,fullWidth:!0,thinMargins:!0})})}export{s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-CmrgM5Rf.js";import{O as i}from"./index-DivKnJyx.js";import{c as a}from"./SquisqIntegration-BTZ1kBlg.js";var o=e(t(),1),s=n();function c({gezelId:e,gezelName:t}){let[n,i]=(0,o.useState)(null),[a,c]=(0,o.useState)(null),[u,f]=(0,o.useState)({loading:!1,content:null,error:null});(0,o.useEffect)(()=>{let t=!1;return i(null),c(null),(async()=>{let[n,a,o]=await Promise.all([r.listMemoryDays(`gezel`,e).then(e=>e.days).catch(()=>[]),r.readMemorySummary(`gezel`,e).then(e=>e.content).catch(()=>``),r.readMemoryLessons(e).then(e=>e.content).catch(()=>``)]);t||i({days:n,summary:a||null,lessons:o||null,expanded:!0})})(),()=>{t=!0}},[e]),(0,o.useEffect)(()=>{if(!a){f({loading:!1,content:null,error:null});return}let t=!1;return f({loading:!0,content:null,error:null}),(async()=>{try{let n=a.kind===`summary`?await r.readMemorySummary(`gezel`,e):a.kind===`lessons`?await r.readMemoryLessons(e):await r.readMemoryDay(`gezel`,e,a.day);t||f({loading:!1,content:n.content,error:null})}catch(e){t||f({loading:!1,content:null,error:e instanceof Error?e.message:String(e)})}})(),()=>{t=!0}},[e,a]);let p=(0,o.useCallback)(()=>{i(e=>e&&{...e,expanded:!e.expanded})},[]);return n===null?(0,s.jsx)(`p`,{className:`muted small`,children:`Loading memories…`}):n.days.length===0&&!n.summary&&!n.lessons?(0,s.jsx)(`p`,{className:`placeholder`,children:`No memories yet. This gezel will build an individual memory over time as you work together.`}):(0,s.jsxs)(`div`,{className:`memories-pane`,"data-testid":`memories-tree`,children:[(0,s.jsxs)(`div`,{className:`memories-tree`,role:`tree`,children:[(0,s.jsxs)(`p`,{className:`memories-tree-total muted small`,children:[n.days.length,` day`,n.days.length===1?``:`s`,` of individual memories.`]}),(0,s.jsx)(l,{gezelName:t,tree:n,onToggle:p,onSelect:c,selected:a})]}),(0,s.jsx)(d,{selected:a,preview:u})]})}function l({gezelName:e,tree:t,onToggle:n,onSelect:r,selected:i}){return(0,s.jsxs)(`div`,{className:`memories-tree-scope`,role:`treeitem`,"aria-expanded":t.expanded,children:[(0,s.jsxs)(`button`,{type:`button`,className:`memories-tree-scope-header`,onClick:n,children:[(0,s.jsx)(`span`,{className:`memories-tree-caret`,"aria-hidden":!0,children:t.expanded?`▾`:`▸`}),(0,s.jsx)(`span`,{className:`memories-tree-scope-label`,children:e}),(0,s.jsxs)(`span`,{className:`muted small`,children:[t.days.length,` day`,t.days.length===1?``:`s`,t.lessons?` + lessons`:``,t.summary?` + summary`:``]})]}),t.expanded&&(0,s.jsxs)(`ul`,{className:`memories-tree-children`,children:[t.lessons&&(0,s.jsx)(u,{active:i?.kind===`lessons`,label:`lessons`,onClick:()=>r({kind:`lessons`,label:`${e} · lessons`})}),t.summary&&(0,s.jsx)(u,{active:i?.kind===`summary`,label:`summary`,onClick:()=>r({kind:`summary`,label:`${e} · summary`})}),t.days.map(t=>(0,s.jsx)(u,{active:i?.kind===`day`&&i.day===t,label:t,onClick:()=>r({kind:`day`,day:t,label:`${e} · ${t}`})},t))]})]})}function u({active:e,label:t,onClick:n}){return(0,s.jsx)(`li`,{children:(0,s.jsx)(`button`,{type:`button`,className:`memories-tree-leaf${e?` memories-tree-leaf-active`:``}`,onClick:n,children:t})})}function d({selected:e,preview:t}){return(0,s.jsx)(`div`,{className:`memories-preview`,children:e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`header`,{className:`memories-preview-header`,children:(0,s.jsx)(`code`,{children:e.label})}),t.loading&&(0,s.jsx)(`p`,{className:`muted small`,children:`Loading…`}),t.error&&(0,s.jsx)(`p`,{className:`error`,children:t.error}),t.content!==null&&!t.loading&&!t.error&&(0,s.jsx)(`pre`,{className:`memories-preview-body`,children:t.content||`(empty)`})]}):(0,s.jsx)(`p`,{className:`placeholder`,children:`Select a day or lesson on the left to view its contents.`})})}function f({projectId:e,projectName:t}){let[n,i]=(0,o.useState)(null),[a,c]=(0,o.useState)(null),[l,d]=(0,o.useState)(null),[f,m]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let t=!1;return i(null),c(null),d(null),m(null),r.listMemoryDays(`project`,e).then(e=>{t||(i(e.days),d(e.days[0]??null))}).catch(e=>{t||(i([]),c(e instanceof Error?e.message:String(e)))}),()=>{t=!0}},[e]),(0,o.useEffect)(()=>{if(!l){m(null);return}let t=!1,n=l;return m({day:n,loading:!0,content:null,error:null}),r.readMemoryDay(`project`,e,n).then(e=>{t||m({day:n,loading:!1,content:e.content,error:null})}).catch(e=>{t||m({day:n,loading:!1,content:null,error:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e,l]),(0,s.jsxs)(`section`,{id:`project-about-memories`,className:`project-about-section project-about-anchor`,children:[(0,s.jsx)(`h3`,{className:`project-about-section-title`,children:`Project memories`}),(0,s.jsx)(`p`,{className:`muted small project-memories-hint`,children:`Notes shared by every gezel working in this project. Changes are saved to the project’s memory files and used in future recall.`}),n===null?(0,s.jsx)(`p`,{className:`muted small`,children:`Loading memories…`}):a?(0,s.jsx)(`p`,{className:`error`,children:a}):n.length===0?(0,s.jsx)(`p`,{className:`placeholder`,children:`No project memories yet. Gezels add shared notes here as work progresses.`}):(0,s.jsxs)(`div`,{className:`project-memories-browser`,children:[(0,s.jsxs)(`div`,{className:`memories-tree project-memories-days`,children:[(0,s.jsxs)(`p`,{className:`memories-tree-total muted small`,children:[n.length,` day`,n.length===1?``:`s`]}),(0,s.jsx)(`ul`,{className:`memories-tree-children project-memories-day-list`,children:n.map(e=>(0,s.jsx)(u,{active:l===e,label:e,onClick:()=>d(e)},e))})]}),(0,s.jsxs)(`div`,{className:`project-memory-editor`,children:[f?.loading&&(0,s.jsx)(`p`,{className:`muted small`,children:`Loading…`}),f?.error&&(0,s.jsx)(`p`,{className:`error`,children:f.error}),f?.content!==null&&f&&!f.loading&&!f.error&&(0,s.jsx)(p,{projectId:e,projectName:t,day:f.day,initial:f.content},`${e}:${f.day}`)]})]})]})}function p({projectId:e,projectName:t,day:n,initial:o}){let c=i({resourceKey:`project:${e}:memory:${n}`,initialValue:o,save:t=>r.updateMemoryDay(`project`,e,n,t)});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`project-memory-editor-heading`,children:(0,s.jsxs)(`code`,{children:[t,` · `,n]})}),(0,s.jsxs)(`div`,{className:`project-memory-source-editor`,children:[(0,s.jsx)(`textarea`,{className:`project-memory-source`,"aria-label":`${t} memory for ${n}`,value:c.desiredValue(),onChange:e=>c.update(e.target.value),spellCheck:!1}),(0,s.jsxs)(`div`,{className:`project-memory-source-status`,children:[(0,s.jsx)(`span`,{children:`Memory markdown`}),(0,s.jsx)(a,{autosave:c})]})]})]})}export{f as n,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-CmrgM5Rf.js";import{n as i,t as a}from"./microphone-input-5gqW_NKf.js";var o=e(t(),1),s=n();function c(){let[e,t]=(0,o.useState)([]),[n,i]=(0,o.useState)(``),[c,d]=(0,o.useState)(``),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(null);(0,o.useEffect)(()=>{r.getConfig().then(e=>{i(e.microphoneDeviceId??``),d(e.microphoneDeviceLabel??``)}).catch(e=>h(u(e)))},[]);let g=(0,o.useCallback)(async(e=!1)=>{if(!navigator.mediaDevices?.enumerateDevices){h(`Microphone selection is unavailable in this browser.`);return}let n;try{e&&(n=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1})),t(await a()),h(null)}catch(e){h(u(e))}finally{for(let e of n?.getTracks()??[])e.stop()}},[]);(0,o.useEffect)(()=>{g();let e=navigator.mediaDevices;if(!e?.addEventListener)return;let t=()=>void g();return e.addEventListener(`devicechange`,t),()=>e.removeEventListener(`devicechange`,t)},[g]);let _=(0,o.useCallback)(async t=>{let a=n,o=c,s=e.find(e=>e.deviceId===t)?.label??``;i(t),d(s),p(!0);try{let e=await r.updateConfig({microphoneDeviceId:t||null,microphoneDeviceLabel:s||null});i(e.microphoneDeviceId??``),d(e.microphoneDeviceLabel??``),window.dispatchEvent(new CustomEvent(`gezel:config-updated`,{detail:e})),h(null)}catch(e){i(a),d(o),h(u(e))}finally{p(!1)}},[n,c,e]),v=e.length===0||e.every(e=>!e.label);return(0,s.jsxs)(`section`,{style:{marginTop:`2rem`},children:[(0,s.jsx)(`h3`,{children:`Microphone`}),(0,s.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`Choose the input used by the Narrate button in chat.`}),(0,s.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,alignItems:`center`,flexWrap:`wrap`},children:[(0,s.jsxs)(`label`,{className:`provider-row`,children:[(0,s.jsx)(`span`,{children:`Input`}),(0,s.jsxs)(`select`,{"aria-label":`Microphone input`,value:l(e,n,c),disabled:f,onChange:e=>void _(e.target.value),children:[(0,s.jsx)(`option`,{value:``,children:`System default`}),e.map((e,t)=>(0,s.jsx)(`option`,{value:e.deviceId,children:e.label||`Microphone ${t+1}`},e.deviceId)),n&&!e.some(e=>e.deviceId===n)&&!e.some(e=>c&&e.label===c)&&(0,s.jsxs)(`option`,{value:n,children:[c||`Saved microphone`,` (not currently available)`]})]})]}),(0,s.jsx)(`button`,{type:`button`,onClick:()=>void g(v),children:v?`Identify microphones`:`Refresh`})]}),(0,s.jsx)(`p`,{className:`muted small`,children:`Choose System default to follow your operating system's input selection.`}),m&&(0,s.jsx)(`p`,{className:`error`,children:m})]})}function l(e,t,n){return i(e,{...t?{deviceId:t}:{},...n?{label:n}:{}})?.deviceId??t}function u(e){return e instanceof Error?e.message:String(e)}export{c as MicrophoneSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{N as r,Qt as i,q as a,xt as o}from"./dist-CE5CbmDb.js";import{t as s}from"./api-CmrgM5Rf.js";import{t as c}from"./model-context-DBqdK0PS.js";import{r as l}from"./model-memory-copy-Ds9w1uJE.js";import{t as u}from"./ConfirmDialog-Dt1ed4Fh.js";import{Ht as d,Mt as f}from"./index-DivKnJyx.js";import{t as p}from"./CatalogBrowser-DYXUZQ_t.js";import{n as m,r as h,t as g}from"./InstallProgressRow-DyKOI4MU.js";import{t as _}from"./IncompleteDownloads-C8_XyP8O.js";import{t as v}from"./LicenseButton-D3VmcVG1.js";import{a as y,i as b,n as x,o as S,r as C,t as w}from"./UnrecognizedModels-BzdU1clO.js";import{a as T,i as E,o as D,r as O,t as k}from"./use-local-model-manager-8wvk-I-y.js";var A=e(t(),1),j=n(),M=5e3,N=1024*1024,P=512,F=32*1024,I=4*1024,L=256;function R(e){if(e<1024)return`${Math.round(e)} MB`;let t=e/1024;return`${Number.isInteger(t)?t:t.toFixed(1)} GB`}function z({providerName:e,label:t,configuredBudgetMb:n}){let[r,i]=(0,A.useState)(null),[a,o]=(0,A.useState)(n??null),[c,l]=(0,A.useState)(!1),[u,f]=(0,A.useState)(!1),[p,m]=(0,A.useState)(null),h=(0,A.useCallback)(async()=>{try{let t=(await s.getCacheStats()).providers.find(t=>t.providerName===e)??null;i(t)}catch{}},[e]);(0,A.useEffect)(()=>{h();let e=setInterval(()=>void h(),M);return()=>clearInterval(e)},[h]),(0,A.useEffect)(()=>{o(n??null)},[n]);let g=(0,A.useCallback)(async t=>{l(!0),m(null);try{await s.updateConfig({cacheBudgetMb:{[e]:t}}),m(t===void 0?`Reset to auto`:`Saved`),await h()}catch(e){m(`Failed to save: ${e instanceof Error?e.message:String(e)}`)}finally{l(!1)}},[e,h]),_=(0,A.useCallback)(async()=>{f(!0),m(null);try{await s.clearProviderCache(e),m(`Cleared all caches`),await h()}catch(e){m(`Failed to clear: ${e instanceof Error?e.message:String(e)}`)}finally{f(!1)}},[e,h]),v=r?Math.round(r.totalBytes/N):0,y=r?Math.round(r.budgetBytes/N):0,b=d(r?.sessions,r?.warmSessionCount??0),x=r?.defaultBudgetBytes?Math.round(r.defaultBudgetBytes/N):y||2048,S=Math.min(P,x),C=r?.systemRamBytes?Math.max(x,Math.round(r.systemRamBytes/N)-I):Math.max(F,x*2),w=Math.min(Math.max(a??x,S),C),T=a===null||Math.abs(a-x)<=L,E=n!==void 0,D=(a??x)!==(n??x),O=(x-S)/Math.max(1,C-S)*100;return(0,j.jsxs)(`div`,{className:`cache-controls-panel`,children:[(0,j.jsx)(`h4`,{children:`Memory budget`}),(0,j.jsxs)(`p`,{className:`muted small`,children:[`The most memory `,t,` keeps for chat and shared-prefix context before older entries are released.`]}),r&&b.totalCount>0?(0,j.jsxs)(`p`,{className:`muted small`,children:[b.label,` · `,R(v),` used of `,R(y),r.recentHitRate>0&&(0,j.jsxs)(j.Fragment,{children:[` · `,Math.round(r.recentHitRate*100),`% hit rate (last 50 turns)`]})]}):(0,j.jsx)(`p`,{className:`muted small`,children:`No warm cache entries yet — they populate after the first turn.`}),(0,j.jsxs)(`div`,{className:`gz-budget-slider`,children:[(0,j.jsxs)(`div`,{className:`gz-budget-slider-head`,children:[(0,j.jsx)(`strong`,{children:R(w)}),T?(0,j.jsx)(`span`,{className:`gz-budget-tag`,children:`Auto (RAM-aware)`}):(0,j.jsx)(`span`,{className:`gz-budget-tag gz-budget-tag-custom`,children:`Custom`})]}),(0,j.jsxs)(`div`,{className:`gz-budget-track`,children:[(0,j.jsx)(`input`,{type:`range`,min:S,max:C,step:256,value:w,"aria-label":`Memory budget for ${t}`,onChange:e=>o(Number.parseInt(e.target.value,10))}),(0,j.jsxs)(`div`,{className:`gz-budget-marker`,style:{left:`${O}%`},title:`Suggested for this Mac: ${R(x)}`,"aria-hidden":`true`,children:[(0,j.jsx)(`span`,{className:`gz-budget-marker-arrow`,children:`▲`}),(0,j.jsxs)(`span`,{className:`gz-budget-marker-label`,children:[`Auto · `,R(x)]})]})]}),(0,j.jsxs)(`div`,{className:`gz-budget-scale muted small`,children:[(0,j.jsx)(`span`,{children:R(S)}),(0,j.jsx)(`span`,{children:R(C)})]})]}),(0,j.jsxs)(`div`,{className:`cache-budget-actions`,style:{marginTop:`0.75rem`},children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>void g(T?void 0:w),disabled:c||!D,children:c?`Saving…`:`Save`}),E&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>void g(void 0),disabled:c,style:{marginLeft:`0.5rem`},children:`Reset to auto`})]}),(0,j.jsx)(`div`,{style:{marginTop:`0.75rem`},children:(0,j.jsx)(`button`,{type:`button`,onClick:()=>void _(),disabled:u||!r||b.totalCount===0,children:u?`Clearing…`:`Clear all caches`})}),p&&(0,j.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.5rem`},children:p})]})}function B(e){return e.residentBytes??a(e.approxSizeBytes)}function V(e,t){return B(e)<=t}function H(e){return`~${l(e)}`}function U(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`})}function W(e){return e.kind!==`chat-model`||!e.mlx||e.mlx.disabledReason?null:e}var ee={"mix of experts":`Only a fraction of the model's parameters run per token, so it's faster than a dense model of the same nominal size.`,vision:`Can accept images alongside text.`,tools:`Supports function/tool calling via the API.`,multimodal:`Handles multiple input types (text + images).`,large:`Heavy model — needs a lot of memory and runs more slowly.`,small:`Compact model — runs quickly on modest hardware.`};function G({onModelsChanged:e,compact:t=!1}){let{models:n,modelsError:a,incomplete:l,unrecognized:d,installs:g,installWarning:T,setInstallWarning:D,installError:M,setInstallError:N,installMismatch:P,setInstallMismatch:F,toDelete:I,setToDelete:L,fitness:R,probing:z,refreshFitness:B,refresh:G,deleteOne:K,startInstall:q,retryInstall:ne,cancelInstall:re,downloadAnyway:ie}=k(O,e),[J,ae]=(0,A.useState)(null),[Y,oe]=(0,A.useState)(!1),[X,se]=(0,A.useState)(`all`),[Z,ce]=(0,A.useState)(null),[le,Q]=(0,A.useState)(!1),[$,ue]=(0,A.useState)([]);(0,A.useEffect)(()=>{s.getMemoryProfile().then(e=>ae(e)).catch(()=>{}),s.getModelContextOverrides(`mlx`).then(()=>Q(!0)).catch(()=>Q(!1))},[]);let de=(0,A.useMemo)(()=>new Set(n.map(e=>e.id)),[n]),fe=(0,A.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),pe=(0,A.useMemo)(()=>{let e=new Set;for(let t of $){let n=W(t.manifest);n&&e.add(n.category??`general`)}return[`all`,...[`general`,`coding`,`reasoning`,`vision`,`embedding`].filter(t=>e.has(t))]},[$]);return(0,j.jsxs)(`div`,{className:`ollama-model-manager`,children:[g.size>0&&(0,j.jsxs)(`div`,{className:`ollama-section`,children:[(0,j.jsx)(`h4`,{children:`Downloading…`}),(0,j.jsx)(`div`,{className:`ollama-pull-list`,children:Array.from(g.values()).map(e=>(0,j.jsx)(te,{inst:e,onCancel:()=>re(e.catalogId),onRetry:()=>ne(e.catalogId)},e.catalogId))})]}),(0,j.jsx)(w,{items:d.filter(e=>!g.has(e.id)),onUpdate:e=>q(e),onRemove:e=>L(e)}),(0,j.jsx)(_,{items:l.filter(e=>!g.has(e.id)),onResume:e=>q(e),onDelete:e=>L(e)}),P&&(0,j.jsxs)(`div`,{className:`ollama-section`,children:[(0,j.jsxs)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginBottom:`0.5rem`},children:[`⚠ `,(0,j.jsx)(`code`,{children:P.catalogId}),` is newer on Hugging Face than the version Gezel knows about`]}),(0,j.jsxs)(`p`,{style:{marginBottom:`0.5rem`},children:[`The file `,(0,j.jsx)(`code`,{children:P.file}),` changed upstream, so its checksum no longer matches what this version of Gezel pinned. This is almost always a harmless upstream fix — model authors routinely re-publish chat templates and tokenizer configs — but we can't verify it automatically. You can download the current version now, or wait for a Gezel update with a refreshed catalog.`]}),(0,j.jsxs)(`div`,{style:{display:`flex`,gap:`0.75rem`},children:[(0,j.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>ie(P.catalogId),children:`Download anyway`}),(0,j.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>F(null),children:`Dismiss`})]})]}),M&&(0,j.jsx)(`div`,{className:`ollama-section`,children:(0,j.jsx)(`p`,{className:`error`,style:{marginBottom:`0.5rem`},children:M})}),T&&(0,j.jsx)(`div`,{className:`ollama-section`,children:(0,j.jsxs)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginBottom:`0.5rem`},children:[`⚠ `,T.id,`: `,T.message]})}),!t&&(0,j.jsx)(x,{engine:`mlx`,onModelsChanged:e}),(n.length>0||a)&&(0,j.jsxs)(`div`,{className:`ollama-section`,children:[(0,j.jsx)(`h4`,{children:t?`Models on this device`:`Local models`}),a&&(0,j.jsx)(`p`,{className:`error`,children:a}),n.length>0&&(0,j.jsx)(`div`,{className:`ollama-model-table-wrap`,children:(0,j.jsxs)(`table`,{className:`ollama-model-table`,children:[(0,j.jsxs)(`colgroup`,{children:[(0,j.jsx)(`col`,{className:`model-name-column`}),(0,j.jsx)(`col`,{}),(0,j.jsx)(`col`,{}),(0,j.jsx)(`col`,{}),(0,j.jsx)(`col`,{}),(0,j.jsx)(`col`,{})]}),(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{children:`Name`}),(0,j.jsx)(`th`,{children:`Size`}),(0,j.jsx)(`th`,{children:`Quant`}),(0,j.jsx)(`th`,{title:`Effective per-turn context size after Gezel's configured limit`,children:`Context size`}),(0,j.jsx)(`th`,{title:`Representative startup and decode speed with an approximately 20K-token prompt`,children:`Fitness`}),(0,j.jsx)(`th`,{})]})}),(0,j.jsx)(`tbody`,{children:n.map(e=>{let t=e.updateAvailable===!0,n=!!g.get(e.id),a=`mlx:${e.id}`,o=R.get(a);return(0,j.jsxs)(A.Fragment,{children:[(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{className:`model-name-table-cell`,children:(0,j.jsxs)(`div`,{className:`model-name-cell`,children:[(0,j.jsx)(`code`,{children:e.id}),(0,j.jsx)(`div`,{className:`model-name-meta`,children:t&&(0,j.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:e.updateReason??`The catalog ships different model files than the copy on disk. Update to pick them up.`,children:`out of date`})})]})}),(0,j.jsx)(E,{model:e}),(0,j.jsx)(`td`,{title:i(e.quantization),children:r(e.quantization)}),(0,j.jsx)(`td`,{title:e.effectiveContextWindow?e.overrideContextTokens===void 0?`Gezel will grant up to ${e.effectiveContextWindow.toLocaleString()} tokens per turn${e.contextWindow?`; the model advertises ${e.contextWindow.toLocaleString()} tokens`:``}.`:`You've set this model to ${e.overrideContextTokens.toLocaleString()} tokens per turn; Gezel grants up to what memory allows (currently ${e.effectiveContextWindow.toLocaleString()}).`:e.contextSizingStatus===`restart-required`?`This model is running with a different context window than the current sizing settings resolve to. Restart the local engine (or let it go idle) so Gezel can re-admit it — no memory change needed.`:e.contextSizingStatus===`insufficient-memory`?`The requested context window does not fit in memory safely. Unload another model or free memory before trying again.`:`The effective context size is unavailable.`,children:e.contextSizingStatus===`restart-required`?`Restart needed`:e.contextSizingStatus===`insufficient-memory`?`Won't fit`:(0,j.jsxs)(j.Fragment,{children:[c(e.effectiveContextWindow),e.overrideContextTokens!==void 0&&(0,j.jsx)(`span`,{className:`gz-budget-tag gz-budget-tag-custom model-context-custom-tag`,children:`custom`})]})}),(0,j.jsx)(C,{entry:o,probing:z.includes(a)}),(0,j.jsx)(`td`,{className:`model-actions-table-cell`,children:(0,j.jsxs)(`div`,{className:`model-actions-cell`,children:[(0,j.jsx)(`div`,{className:`model-action-status`,children:e.readOnly&&(0,j.jsx)(`span`,{className:`muted small`,title:`Provided by the machine-wide install (shared asset store). It can't be removed from here — manage it with the machine installer, or install a user-owned copy to shadow it.`,children:`Machine model`})}),(0,j.jsx)(`div`,{className:`model-action-links`,children:(0,j.jsx)(y,{engine:`mlx`,model:{...e,updateAvailable:t},updating:n,contextSupported:le,contextEditorOpen:Z===e.id,onToggleContextEditor:()=>ce(t=>t===e.id?null:e.id),fitnessAction:b(o,z.includes(a),()=>{s.runModelFitnessProbe(`mlx`,e.id).then(()=>B()).catch(()=>{})}),onUpdate:()=>q(e.id),updateLabel:{idle:`Download again`,busy:`Downloading…`},onDelete:()=>L(e.id)})})]})})]}),Z===e.id&&(0,j.jsx)(`tr`,{className:`model-context-editor-row`,children:(0,j.jsx)(`td`,{colSpan:6,children:(0,j.jsx)(S,{engine:`mlx`,model:e,onSaved:G})})})]},e.id)})})]})})]}),(0,j.jsxs)(`div`,{className:`ollama-section ollama-section--flat ollama-section--download`,children:[(0,j.jsx)(`h4`,{children:`Download a model`}),(0,j.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`Models are hosted by`,` `,(0,j.jsx)(`a`,{href:`https://huggingface.co`,target:`_blank`,rel:`noreferrer`,style:{color:`inherit`},children:`Hugging Face`}),`, a community library of open, freely available AI models. Your device downloads them directly.`]}),(0,j.jsxs)(`p`,{className:`muted small`,children:[J?`Models that may not fit this machine, and retired models, are hidden by default. `:`Retired models are hidden by default. `,(0,j.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>oe(e=>!e),style:{padding:0},children:Y?J?`Hide retired and oversized models`:`Hide retired models`:`Show all models`})]}),(0,j.jsx)(`div`,{className:`provider-switch`,style:{marginBottom:`0.5rem`},children:pe.map(e=>(0,j.jsx)(`button`,{type:`button`,className:`provider-pill${X===e?` provider-pill-active`:``}`,onClick:()=>se(e),children:e===`all`?`All`:e[0]?.toUpperCase()+e.slice(1)},e))}),(0,j.jsx)(p,{kind:`chat-model`,emptyMessage:`No MLX-format entries in the catalog yet.`,onItemsLoaded:ue,tagTooltips:ee,filter:e=>{let t=W(e.manifest);return!(!t||!Y&&o(t)||X!==`all`&&(t.category??`general`)!==X||!Y&&J&&!V(t.mlx,J.usableBytes))},action:e=>{let t=W(e.manifest);if(!t)return null;let n=de.has(t.id),r=fe.has(t.id),i=g.get(t.id),a=i&&i.totalBytes>0?Math.min(100,Math.round(i.bytesWritten/i.totalBytes*100)):null,o=J?!V(t.mlx,J.usableBytes):!1;return(0,j.jsxs)(`div`,{className:`catalog-ollama-action`,children:[(0,j.jsxs)(`div`,{className:`catalog-ollama-meta`,children:[(0,j.jsxs)(`div`,{className:`catalog-ollama-specs muted small`,children:[(0,j.jsx)(m,{repo:t.mlx.huggingfaceRepo}),(0,j.jsx)(`span`,{children:`·`}),(0,j.jsx)(`span`,{children:t.parameterSize}),(0,j.jsx)(`span`,{children:`·`}),(0,j.jsx)(`span`,{children:H(t.mlx.approxSizeBytes)}),U(t.releasedAt)&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{children:`·`}),(0,j.jsx)(`span`,{children:U(t.releasedAt)})]})]}),(0,j.jsxs)(`div`,{className:`catalog-ollama-pills`,children:[(0,j.jsx)(v,{manifest:t,fallbackHref:h(t.mlx.huggingfaceRepo)}),o&&(0,j.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:`Larger than your estimated inference budget — may run slowly or fail.`,children:`may not fit`})]})]}),(0,j.jsx)(`button`,{type:`button`,disabled:n||r||!!i,onClick:()=>q(t.id),children:n?`On device`:i?i.phase===`downloading`?a===null?`Downloading…`:`Downloading… ${a}%`:i.phase===`verifying`?`Verifying…`:`Reading metadata…`:r?`Needs attention above`:`Download`})]})}})]}),(0,j.jsxs)(`div`,{className:`ollama-section ollama-section--flat`,children:[(0,j.jsx)(f,{}),(0,j.jsx)(`span`,{className:`muted small`,style:{marginLeft:`0.75rem`},children:`Import from a gezel local model package`})]}),(0,j.jsx)(u,{open:I!==null,title:`Delete ${I??``}?`,message:`This removes the downloaded model from your device. It stays available in the catalog — you can download it again any time.`,confirmLabel:`Delete`,danger:!0,onConfirm:K,onCancel:()=>L(null)})]})}function te({inst:e,onCancel:t,onRetry:n}){let r=e.totalBytes>0,i=r?Math.min(100,Math.round(e.bytesWritten/e.totalBytes*100)):0,a;if(e.error)a=e.error;else if(e.retrying){let t=Math.max(1,Math.round(e.retrying.delayMs/1e3)),n=e.fileCount>1?` on shard ${e.fileIndex}/${e.fileCount}`:``;a=`${e.retrying.reason}${n} — retrying in ${t}s (attempt ${e.retrying.attempt}/${e.retrying.maxAttempts})`}else a=e.phase===`downloading`?r?`Downloading ${l(e.bytesWritten)} of ${l(e.totalBytes)} (${i}%)`:e.bytesWritten>0?`Downloading ${l(e.bytesWritten)}…`:`Preparing download…`:e.phase===`verifying`?`Checking download${e.file?` (${e.file})`:`…`}`:`Reading model info…`;let o=e.phase!==`downloading`||!r;return(0,j.jsx)(g,{title:(0,j.jsx)(`code`,{children:e.catalogId}),status:a,percent:o?null:i,tone:e.error?`error`:e.retrying?`warning`:`normal`,onCancel:t,onRetry:n})}var K=typeof navigator<`u`&&/Mac/.test(navigator.platform)&&(navigator.userAgentData?.architecture===`arm`||/Mac.*Apple/i.test(navigator.userAgent));function q({config:e,onConfigChanged:t}){let[n,r]=(0,A.useState)(e?.mlxBaseUrl??``),[i,a]=(0,A.useState)(e?.mlxModelPath??``),[o,c]=(0,A.useState)(e?.mlxPackageSpec??``),[l,u]=(0,A.useState)(null),[d,f]=(0,A.useState)([]),[p,m]=(0,A.useState)(`idle`),[h,g]=(0,A.useState)(null),[_,v]=(0,A.useState)(`idle`);(0,A.useEffect)(()=>{r(e?.mlxBaseUrl??``)},[e?.mlxBaseUrl]),(0,A.useEffect)(()=>{a(e?.mlxModelPath??``)},[e?.mlxModelPath]),(0,A.useEffect)(()=>{c(e?.mlxPackageSpec??``)},[e?.mlxPackageSpec]);let y=(0,A.useCallback)(async()=>{try{let e=await s.getMlxRuntime();u(e)}catch{u(null)}},[]);(0,A.useEffect)(()=>{y()},[y]);let b=(0,A.useCallback)(async()=>{try{let e=await s.listMlxModels();f(e.models)}catch{}},[]);(0,A.useEffect)(()=>{b()},[b]);let x=(0,A.useCallback)(()=>{b(),y()},[b,y]),S=(0,A.useCallback)(async()=>{v(`resetting`);try{await s.resetMlxRuntime(),v(`done`),setTimeout(()=>v(`idle`),3e3),y()}catch(e){v(`idle`),g(e instanceof Error?e.message:String(e))}},[y]),C=(0,A.useCallback)(async()=>{let e=n.trim();m(`saving`);try{t(await s.updateConfig({mlxBaseUrl:e===``?null:e})),m(`saved`),setTimeout(()=>m(`idle`),1200)}catch{m(`idle`)}},[n,t]),w=(0,A.useCallback)(async()=>{let e=i.trim();m(`saving`);try{t(await s.updateConfig({mlxModelPath:e===``?null:e})),m(`saved`),setTimeout(()=>m(`idle`),1200)}catch{m(`idle`)}},[i,t]),E=(0,A.useCallback)(async()=>{let e=o.trim();m(`saving`);try{t(await s.updateConfig({mlxPackageSpec:e===``?null:e})),m(`saved`),setTimeout(()=>m(`idle`),1200)}catch{m(`idle`)}},[o,t]),O=(0,A.useCallback)(async e=>{m(`saving`);try{t(await s.updateConfig({mlxKvBits:e===0?null:e})),m(`saved`),setTimeout(()=>m(`idle`),1200)}catch{m(`idle`)}},[t]),k=(0,A.useCallback)(async n=>{m(`saving`);try{t(await s.updateConfig({defaultModel:{...e?.defaultModel,mlx:n??void 0}})),m(`saved`),setTimeout(()=>m(`idle`),1200)}catch{m(`idle`)}},[e?.defaultModel,t]),M=!!e?.mlxBaseUrl;return(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,j.jsx)(`h3`,{children:`This Mac (Apple MLX)`}),(0,j.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`On-device AI powered by Apple's MLX framework, making the best use of the hardware you already have — in many cases the best choice of engine for your Mac. Your conversations stay on your computer: no account to set up, no data sent to the cloud.`}),(0,j.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,j.jsx)(`span`,{className:`muted small`,children:`Status:`}),(0,j.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:`ready`})]}),!K&&(0,j.jsx)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginTop:`0.5rem`,display:`inline-block`},children:`This machine doesn't look like Apple Silicon — chat turns routed to MLX will error out at send time.`}),M&&(0,j.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`},children:[(0,j.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:`External engine: ${e?.mlxBaseUrl}`,children:`using external engine`}),p===`saved`&&(0,j.jsx)(`span`,{className:`muted small`,children:`saved ✓`})]})]}),d.length>1&&(0,j.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,j.jsx)(`h4`,{children:`Default model`}),(0,j.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Which local model new chat sessions use when a gezel doesn't pin one.`}),(0,j.jsx)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`},children:(0,j.jsxs)(`select`,{"aria-label":`Default model`,value:e?.defaultModel?.mlx??``,onChange:e=>void k(e.target.value||void 0),children:[(0,j.jsx)(`option`,{value:``,children:`First local model`}),d.map(e=>(0,j.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.id,`)`]},e.id))]})})]}),(0,j.jsx)(`section`,{style:{marginBottom:`2rem`},children:(0,j.jsx)(G,{onModelsChanged:x})}),(0,j.jsx)(D,{provider:`mlx`}),(0,j.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,j.jsx)(`h4`,{style:{marginBottom:`0.5rem`},children:`Concurrent replicas`}),(0,j.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Run multiple copies of the same model so unrelated sessions don't queue behind each other. Weights are shared by the OS via mmap so disk cost stays at one model file; resident memory grows because each clone keeps its own KV cache and activations.`}),(0,j.jsx)(T,{provider:`mlx`,modelId:e?.defaultModel?.mlx??null,config:e,onConfigChanged:t})]}),h&&(0,j.jsxs)(`div`,{className:`muted small`,style:{color:`#ff9b9b`,marginTop:`1rem`},role:`alert`,children:[h,` `,(0,j.jsx)(`button`,{type:`button`,onClick:()=>g(null),children:`dismiss`})]}),(0,j.jsx)(`section`,{style:{marginTop:`2rem`},children:(0,j.jsx)(z,{providerName:`mlx`,label:`This Mac AI`,configuredBudgetMb:e?.cacheBudgetMb?.mlx})}),(0,j.jsxs)(`details`,{className:`mlx-advanced`,style:{marginTop:`2rem`},children:[(0,j.jsx)(`summary`,{style:{cursor:`pointer`},children:(0,j.jsx)(`strong`,{children:`Advanced`})}),(0,j.jsxs)(`section`,{style:{marginTop:`1.25rem`},children:[(0,j.jsx)(`h4`,{style:{marginBottom:`0.35rem`},children:`Python runtime`}),l?(0,j.jsx)(`div`,{className:`muted small`,style:{marginTop:`0.25rem`},children:l.source===null?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`strong`,{children:`No Python runtime available.`}),` `,l.reason??`Install Python 3.11 or wait for a packaged build that bundles uv.`]}):(0,j.jsxs)(j.Fragment,{children:[`Source: `,(0,j.jsx)(`code`,{children:l.source}),l.uvVersion&&(0,j.jsxs)(j.Fragment,{children:[` `,`· uv `,(0,j.jsx)(`code`,{children:l.uvVersion})]}),l.pythonVersion&&(0,j.jsxs)(j.Fragment,{children:[` `,`· Python `,(0,j.jsx)(`code`,{children:l.pythonVersion})]}),l.installerPath&&(0,j.jsxs)(j.Fragment,{children:[` `,`· `,(0,j.jsx)(`span`,{title:l.installerPath,children:`installer at path`})]})]})}):(0,j.jsx)(`div`,{className:`muted small`,children:`Probing…`}),(0,j.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`,alignItems:`center`},children:[(0,j.jsx)(`button`,{type:`button`,onClick:()=>void S(),disabled:_===`resetting`,children:_===`resetting`?`Resetting…`:`Reset gezel Python environment`}),_===`done`?(0,j.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:`venv was reset ✓`}):(0,j.jsx)(`span`,{className:`muted small`,children:"Deletes the `mlx` venv; the next chat turn re-provisions it."})]})]}),(0,j.jsxs)(`section`,{style:{marginTop:`1.25rem`},children:[(0,j.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,j.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`12rem`},children:`External mlx_lm.server URL`}),(0,j.jsx)(`input`,{type:`text`,placeholder:`e.g. http://127.0.0.1:8000 (leave blank for supervised)`,value:n,onChange:e=>r(e.target.value),style:{flex:1}}),(0,j.jsx)(`button`,{type:`button`,disabled:p===`saving`||n===(e?.mlxBaseUrl??``),onClick:()=>void C(),children:`Save`})]}),(0,j.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`,alignItems:`center`},children:[(0,j.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`12rem`},children:`Override model directory`}),(0,j.jsx)(`input`,{type:`text`,placeholder:`Absolute path to an MLX model dir`,value:i,onChange:e=>a(e.target.value),style:{flex:1}}),(0,j.jsx)(`button`,{type:`button`,disabled:p===`saving`||i===(e?.mlxModelPath??``),onClick:()=>void w(),children:`Save`})]}),(0,j.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`,alignItems:`center`},children:[(0,j.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`12rem`},children:`mlx-lm package spec`}),(0,j.jsx)(`input`,{type:`text`,placeholder:`e.g. mlx-lm==0.25.3 (blank → latest)`,value:o,onChange:e=>c(e.target.value),style:{flex:1}}),(0,j.jsx)(`button`,{type:`button`,disabled:p===`saving`||o===(e?.mlxPackageSpec??``),onClick:()=>void E(),children:`Save`})]}),(0,j.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`,alignItems:`center`},children:[(0,j.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`12rem`},children:`KV cache quantization`}),(0,j.jsxs)(`select`,{value:String(e?.mlxKvBits??0),onChange:e=>void O(Number(e.target.value)),style:{flex:1},children:[(0,j.jsx)(`option`,{value:`0`,children:`Off — full precision (default)`}),(0,j.jsx)(`option`,{value:`8`,children:`8-bit — about half the memory, near-lossless`}),(0,j.jsx)(`option`,{value:`6`,children:`6-bit — smaller still`}),(0,j.jsx)(`option`,{value:`4`,children:`4-bit — smallest, some quality loss`})]})]}),(0,j.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.35rem`},children:`Compresses the conversation history the model keeps in memory. That history is the biggest cost in a long chat — on a large model with a 256K context it can outweigh the model itself — and 8-bit roughly halves it at close to no quality cost. Only applies while the engine serves one chat at a time; when it is set up to handle several at once, the history stays at full precision. Takes effect the next time the engine starts.`})]})]})]})}export{q as MlxSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{I as r,i,on as a,pt as o}from"./dist-DOqbRmFj.js";import{t as s}from"./api-C0I7spBl.js";import{d as c,l,m as u,p as d,s as f}from"./primitives-CWrGZpPI.js";import{a as p,o as m,t as h}from"./model-inventory-ykSm_IT5.js";import{t as g}from"./GezelJsonEditor-DXXt165-.js";var _=e(t(),1),v={type:`number`,title:`Temperature`,description:`How adventurous the model is when picking words. Low values (0–0.3) make replies steady and repeatable — good for code, math, structured output. Mid values (0.5–0.9) feel like a thoughtful conversation. High values (1.0+) get creative but can drift off-topic or start rambling. 0 picks the single most likely word every time.`,minimum:0,maximum:2,multipleOf:.05},y={type:`number`,title:`top_p (nucleus)`,description:`Trims the long tail of unlikely word choices. 0.95 keeps the model honest while letting it surprise you — the modern default. Lower values (0.7–0.85) make replies more predictable and stay in the safe zone. Higher values (close to 1) let weirder picks through. Usually tune temperature first, top_p second.`,minimum:0,maximum:1,multipleOf:.01},b={type:`integer`,title:`top_k`,description:`A hard ceiling on how many word choices the model considers at each step. 20 is what Qwen recommends for thinking mode. 64 is Gemma's default. 1 means 'always pick the single most likely word' — deterministic but flat. Lower top_k = more predictable; higher = more variety.`,minimum:0,maximum:1e3},x={type:`number`,title:`min_p`,description:`A floor on word probability — filters out the really unlikely tokens regardless of top_k. 0 disables. 0.05 is a mild filter that prevents the model from grabbing genuinely rare tokens. Most users leave this at 0 and tune temperature + top_p instead.`,minimum:0,maximum:1,multipleOf:.01},S={type:`integer`,title:`Max reply length (tokens)`,description:`Hard ceiling on how long one reply can be. Counts every word, punctuation mark, and reasoning token. Most chat turns fit in 2k–8k. Reasoning models that 'think out loud' need 16k+ to leave room for the actual answer after the thinking trace. Hitting this cap mid-reply cuts the model off.`,minimum:1,maximum:131072},C={type:`integer`,title:`Seed`,description:`Lock in a specific run. Same seed + same prompt = (usually) the same reply, so you can A/B test prompt changes or reproduce a bug. Leave blank for random. Cloud providers honor seed on a best-effort basis; local engines are stricter.`},w={type:`number`,title:`Repetition penalty`,description:`Punishes the model for re-using words it just said. 1.0 = off (the model is allowed to repeat freely). 1.1 = mild — catches 'I will… I'll… I will…' loops. Push above 1.2 and the model starts dodging legitimate repeats (the word 'the' starts feeling rare), and replies feel oddly stilted.`,minimum:0,maximum:3,multipleOf:.05},T={type:`integer`,title:`Repetition window (tokens)`,description:`How far back the repetition penalty looks. 20–64 catches recent loops without affecting older context. Larger windows (256+) penalize re-using words from much earlier in the chat — usually too aggressive for conversation.`,minimum:1,maximum:8192},E={type:`number`,title:`Frequency penalty`,description:`Penalty that scales with how often a word has already appeared in this reply. Positive values (0.3–0.8) discourage repeating common words; negative values encourage repetition. -2 to 2; usually 0.`,minimum:-2,maximum:2,multipleOf:.05},D={type:`number`,title:`Presence penalty`,description:`Penalty applied once any word has appeared at all in this reply (not scaled by count). Positive values (0.3–0.8) push the model toward new vocabulary; useful for brainstorming. -2 to 2; usually 0.`,minimum:-2,maximum:2,multipleOf:.05},O={type:`object`,title:`DRY anti-repetition (llama only)`,description:`Don't-Repeat-Yourself: catches longer phrase loops that simple repetition penalty misses. Helpful for small local models that get stuck repeating whole sentences. Set multiplier to 0 to disable.`,properties:{multiplier:{type:`number`,title:`Strength`,description:`How hard to penalize repeats. 0 = off. 0.8 is a reasonable starting point — strong enough to break loops without hurting normal repetition.`,minimum:0,maximum:5,multipleOf:.05},base:{type:`number`,title:`Penalty curve`,description:`How fast the penalty grows for longer repeated sequences. Higher = more aggressive on long repeats. 1.75 is the upstream default.`,minimum:0,maximum:5,multipleOf:.05},allowedLength:{type:`integer`,title:`Free length`,description:`Repeats shorter than this don't get penalized. 2 = allow 2-token repeats (small phrases), penalize anything longer.`,minimum:0,maximum:64}}},k={type:`object`,title:`XTC sampler (llama only)`,description:`Exclude-Top-Choices: occasionally throws away the most likely word and picks from the rest. Adds personality and surprise to creative writing. Skip this if you want consistency.`,properties:{probability:{type:`number`,title:`Trigger rate`,description:`How often XTC fires. 0 = never. 0.5 = half the time. Higher values make replies less predictable.`,minimum:0,maximum:1,multipleOf:.01},threshold:{type:`number`,title:`Activation threshold`,description:`Only fires when the top word is more likely than this. 0.1 = activate when the model is fairly sure (most of the time); higher values restrict XTC to high-confidence moments.`,minimum:0,maximum:1,multipleOf:.01}}},A={type:`object`,title:`Reasoning`,description:`Controls how much the model 'thinks out loud' before answering.`,properties:{effort:{type:`string`,enum:[`low`,`medium`,`high`],title:`Reasoning effort`,description:`How hard the model works before replying. Low = quick takes (fast, cheap). Medium = balanced (most common default). High = deep deliberation (slower, more thorough — best for math, code, complex planning). Maps to OpenAI's reasoning.effort and Anthropic's thinking.budget_tokens behind the scenes.`,squisq:{control:`segmented`}},thinkingBudget:{type:`integer`,title:`Thinking budget (tokens)`,description:`Explicit cap on how many tokens the model can spend thinking before it has to answer. Anthropic Claude and Nemotron use this directly. Wins over 'effort' when both are set. Typical values: 2k for quick, 8k for medium, 24k+ for deep reasoning.`,minimum:1,maximum:65536},enableThinking:{type:`boolean`,title:`Show reasoning`,description:`On = the model writes out its thinking before the final answer (often visible as a collapsible 'thinking' block). Off = the model goes straight to the answer. Mainly affects dual-mode local models like Qwen3 and Nemotron Nano/Super — cloud thinking models infer from the reasoning effort/budget.`}}},j={type:`object`,title:`Structured output`,description:`Force the model to produce machine-readable output instead of prose.`,properties:{responseFormat:{type:`string`,enum:[`text`,`json_object`],title:`Output format`,description:`Text = normal prose (default). JSON = the model must emit syntactically-valid JSON. Combine with a JSON Schema below to pin the exact shape.`,squisq:{control:`segmented`,enumLabels:{text:`Text`,json_object:`JSON`}}}}},M={type:`string`,enum:[`auto`,`required`,`none`],title:`Tool calling`,description:`Auto = the model decides whether to call a tool (normal). Required = the model MUST call a tool this turn (good for forcing structured handoffs). None = tools are hidden from the model — pure chat.`,squisq:{control:`segmented`}},N={type:`object`,title:`Reasoning prompt tags`,description:`Markers a user can include in a message to flip reasoning on/off for just that turn. Qwen recognizes /think and /no_think by default.`,properties:{enableThinkingTag:{type:`string`,title:`Enable tag`,description:"Example: `/think`. Adding this to your message turns thinking ON for that turn."},disableThinkingTag:{type:`string`,title:`Disable tag`,description:"Example: `/no_think`. Adding this to your message turns thinking OFF for that turn."}}};function P(e){return{type:`object`,title:`When thinking is on, use these instead`,description:`Some models like Qwen3 and Nemotron Nano want different sampling when reasoning. Only fill in the fields you want to change for thinking mode — the rest fall through to your main Sampling values above.`,properties:e,squisq:{hidden:{field:`reasoning.enableThinking`,truthy:!1}}}}var F={temperature:v,topP:y,topK:b,maxTokens:S,seed:C,frequencyPenalty:E,presencePenalty:D},I={type:`object`,title:`Structured output`,properties:{responseFormat:j.properties.responseFormat,jsonSchema:{type:`object`,title:`JSON Schema`,description:`OpenAI strict mode. Leave empty for free-form JSON.`,additionalProperties:!0}}},L={type:`object`,title:`Advanced tuning (cloud)`,description:`Per-turn sampling, structured output, and reasoning controls. Empty fields fall through to the catalog default. Fields the active provider doesn't support are silently dropped at request build.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:F},samplingWhenThinking:P(F),reasoning:A,output:I,toolChoice:M}},R={temperature:v,topP:y,topK:b,minP:x,maxTokens:S,seed:C,repetitionPenalty:w,repetitionContext:T,frequencyPenalty:E,presencePenalty:D,dry:O,xtc:k},ee={...A,properties:{enableThinking:A.properties.enableThinking}},te={type:`object`,title:`Structured output`,properties:{responseFormat:j.properties.responseFormat,jsonSchema:{type:`object`,title:`JSON Schema`,description:"Pin output to a JSON Schema. Drives llama `--json-schema`. Leave empty for free-form JSON.",additionalProperties:!0},grammar:{type:`string`,title:`GBNF grammar`,description:`Last-resort structured-output knob. llama-only. Multi-line GBNF source.`,maxLength:4096,squisq:{control:`multiline`}}}},ne={type:`object`,title:`Advanced tuning (llama)`,description:`Per-turn sampling, structured output, and reasoning controls. Empty fields fall through to the catalog default.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:R},samplingWhenThinking:P(R),reasoning:ee,output:te,toolChoice:M,promptTags:N}},z={temperature:v,topP:y,topK:b,minP:x,maxTokens:S,seed:C,repetitionPenalty:w,repetitionContext:T},re={...A,properties:{enableThinking:A.properties.enableThinking}},ie={type:`object`,title:`Advanced tuning (MLX)`,description:`Per-turn sampling and reasoning controls. Empty fields fall through to the catalog default.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:z},samplingWhenThinking:P(z),reasoning:re,output:j,toolChoice:M,promptTags:N}},B={temperature:v,topP:y,topK:b,minP:x,maxTokens:S,seed:C,repetitionPenalty:w,repetitionContext:T,frequencyPenalty:E,presencePenalty:D},ae={...A,properties:{enableThinking:A.properties.enableThinking}},oe={type:`object`,title:`Structured output`,properties:{responseFormat:j.properties.responseFormat,jsonSchema:{type:`object`,title:`JSON Schema`,description:"Pin output to a JSON Schema. Maps to Ollama 0.5+ `format: <schema>`. Leave empty for free-form JSON.",additionalProperties:!0}}},se={type:`object`,title:`Advanced tuning (Ollama)`,description:`Per-turn sampling, structured output, and reasoning controls. Empty fields fall through to the catalog default.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:B},samplingWhenThinking:P(B),reasoning:ae,output:oe,promptTags:N}};function ce(e){switch(e){case`llama-cpp`:case`ds4`:return ne;case`mlx`:return ie;case`ollama`:return se;case`openai`:case`anthropic`:case`anthropic-cli`:case`codex-cli`:case`copilot`:return L;case`remote`:return L;default:return e}}var V=n();function le({provider:e,override:t,inherited:n,onSave:r,scopeLabel:s=`this scope`,disabled:c,tuningProfileId:l}){let u=(0,_.useMemo)(()=>ce(e),[e]),d=(0,_.useMemo)(()=>pe(u,n??{}),[u,n]),f=(0,_.useMemo)(()=>ue(n??{},t??{}),[n,t]),[p,m]=(0,_.useState)(f),[h,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null);(0,_.useEffect)(()=>{m(f)},[f]);let x=(0,_.useCallback)(e=>{m(e??{})},[]),S=(0,_.useMemo)(()=>de(p,n??{}),[p,n]),C=S!==null,w=(0,_.useMemo)(()=>S?W(S):`(none)`,[S]),T=(0,_.useMemo)(()=>W(p)||`(provider defaults)`,[p]),E=(0,_.useMemo)(()=>W(n??{})||`(provider defaults)`,[n]),D=(0,_.useMemo)(()=>{if(l)return a(l,Object.keys(n?.profiles??{}))},[l,n]),O=(0,_.useMemo)(()=>{if(!l)return null;if(D){let e=o(D)?i[D].label:D,t=D!==l,n=o(l)?i[l].label:l;return t?`${e} (fallback from ${n} — model doesn't define it)`:e}return`${l} (not defined on this model — base tuning applies)`},[l,D]),k=(0,_.useCallback)(async()=>{v(!0),b(null);try{await r(S)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[S,r]),A=(0,_.useCallback)(async()=>{v(!0),b(null);try{await r(null),m(n??{})}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[n,r]);return(0,V.jsxs)(`div`,{className:`tuning-panel`,children:[(0,V.jsxs)(`div`,{className:`tuning-panel-summary small`,style:{display:`flex`,flexDirection:`column`,gap:`0.25rem`,marginBottom:`0.5rem`},children:[O&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`strong`,{children:`Active voice:`}),` `,(0,V.jsx)(`span`,{className:`muted`,children:O})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`strong`,{children:`Effective now:`}),` `,(0,V.jsx)(`span`,{className:`muted`,children:T})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`strong`,{children:`Inherited default:`}),` `,(0,V.jsx)(`span`,{className:`muted`,children:E})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`strong`,{children:[`Your override for `,s,`:`]}),` `,(0,V.jsx)(`span`,{className:C?``:`muted`,children:w})]})]}),(0,V.jsx)(g,{schema:d,value:p,onChange:x,density:`compact`}),(0,V.jsxs)(`div`,{className:`tuning-panel-actions`,style:{marginTop:`0.5rem`},children:[(0,V.jsx)(`button`,{type:`button`,onClick:k,disabled:c||h,children:h?`Saving…`:C?`Save override for ${s}`:`Save (no override)`}),t&&Object.keys(t).length>0&&(0,V.jsx)(`button`,{type:`button`,onClick:A,disabled:c||h,className:`muted`,style:{marginLeft:`0.5rem`},children:`Reset to inherited defaults`})]}),y&&(0,V.jsx)(`div`,{className:`tuning-panel-error small error`,style:{marginTop:`0.25rem`},children:y})]})}function ue(e,t){let n={...e};for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];t&&typeof t==`object`&&!Array.isArray(t)&&r&&typeof r==`object`&&!Array.isArray(r)?n[e]=ue(t,r):n[e]=r}return n}function de(e,t){let n=fe(e,t);return n===null?null:n}function fe(e,t){let n={},r=!1;for(let[i,a]of Object.entries(e)){let e=t[i];if(a!=null)if(typeof a==`object`&&!Array.isArray(a)&&typeof e==`object`&&e&&!Array.isArray(e)){let t=fe(a,e);t!==null&&(n[i]=t,r=!0)}else H(a,e)||(n[i]=a,r=!0)}return r?n:null}function H(e,t){return e===t?!0:typeof e==typeof t?Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>H(e,t[n])):JSON.stringify(e)===JSON.stringify(t):!1}function pe(e,t){return U(e,t)}function U(e,t){let n={...e};if(n.properties){let e={};for(let[r,i]of Object.entries(n.properties))e[r]=U(i,t&&typeof t==`object`?t[r]:void 0);n.properties=e}if(n.type!==`object`&&t!=null){let e=me(t);if(e!==null){let t=n.description??``;n.description=t?`${t}\n\nDefault: ${e}`:`Default: ${e}`}}return n}function me(e){return typeof e==`number`?String(e):typeof e==`boolean`?e?`on`:`off`:typeof e==`string`?e:null}function W(e){let t=[];if(e.sampling){let n=e.sampling,r=[];n.temperature!==void 0&&r.push(`temp ${n.temperature}`),n.topP!==void 0&&r.push(`top_p ${n.topP}`),n.topK!==void 0&&r.push(`top_k ${n.topK}`),n.minP!==void 0&&r.push(`min_p ${n.minP}`),n.maxTokens!==void 0&&r.push(`max ${n.maxTokens}`),n.seed!==void 0&&r.push(`seed ${n.seed}`),n.repetitionPenalty!==void 0&&r.push(`rep ${n.repetitionPenalty}`),n.frequencyPenalty!==void 0&&r.push(`freq ${n.frequencyPenalty}`),n.presencePenalty!==void 0&&r.push(`pres ${n.presencePenalty}`),r.length>0&&t.push(r.join(`, `))}if(e.reasoning){let n=e.reasoning;n.effort&&t.push(`effort ${n.effort}`),n.thinkingBudget!==void 0&&t.push(`budget ${n.thinkingBudget}`),n.enableThinking===!0&&t.push(`thinking on`),n.enableThinking===!1&&t.push(`thinking off`)}return e.output?.responseFormat&&e.output.responseFormat!==`text`&&t.push(`format ${e.output.responseFormat}`),e.toolChoice&&t.push(`tools ${e.toolChoice}`),e.samplingWhenThinking&&Object.keys(e.samplingWhenThinking).length>0&&t.push(`+thinking sampling`),e.promptTags?.enableThinkingTag&&t.push(`tag ${e.promptTags.enableThinkingTag}`),t.join(` · `)}var G=new Map,K=new Map,q=new Map;function J(e){q.set(e,(q.get(e)??0)+1),K.delete(e),G.delete(e)}async function Y(e,t=!1){if(t&&J(e),!t){let t=K.get(e);if(t)return t;let n=G.get(e);if(n)return n}let n=q.get(e)??0,r=(e===`remote`?he():s.listProviderModels(e,t?{refresh:!0}:void 0).then(e=>e.models)).then(t=>((q.get(e)??0)===n&&K.set(e,t),t)).finally(()=>{G.get(e)===r&&G.delete(e)});return G.set(e,r),r}async function he(){let{remotes:e}=await s.listRemotes(),t=[];for(let n of e)try{let{models:e}=await s.listRemoteModels(n.remoteId);for(let r of e)t.push({id:r.id,name:`${n.displayName} · ${r.name}`,...r.supportsTools===void 0?{}:{supportsTools:r.supportsTools},...r.supportsReasoning===void 0?{}:{supportsReasoning:r.supportsReasoning},...r.contextWindow?{contextWindow:r.contextWindow}:{},...r.parameterSize?{parameterSize:r.parameterSize}:{}})}catch{}return t}function X(e){return e===`mlx`||e===`llama-cpp`}function ge(e){return e===`mlx`||e===`llama-cpp`||e===`ds4`}var Z=null,Q=null;async function _e(){return Z||Q||(Q=s.listModelFitness().then(e=>(Z=new Map(e.records.map(e=>[e.key,e])),Z)).finally(()=>{Q=null}),Q)}async function ve(e){let[t,n]=await Promise.all([e===`mlx`?s.listMlxModels():s.listLlamaCppModels(),e===`mlx`?s.listMlxActiveInstalls():s.listLlamaCppActiveInstalls()]);return t.models.length===0?{activeInstallsCount:n.installs.length}:null}function ye({provider:e,value:t,onChange:n,placeholder:i=`Provider default`}){let[a,o]=(0,_.useState)(K.get(e)??null),[s,g]=(0,_.useState)(!K.has(e)),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(t??``),[E,D]=(0,_.useState)(Z),[O,k]=(0,_.useState)(0),A=(0,_.useRef)(null);(0,_.useEffect)(()=>{let t=t=>{let n=p(t);n===e&&(A.current=n,J(e),k(e=>e+1))};return window.addEventListener(h,t),()=>window.removeEventListener(h,t)},[e]),(0,_.useEffect)(()=>{if(e!==`llama-cpp`&&e!==`ds4`)return;let t=!1;return _e().then(e=>{t||D(e)}).catch(()=>{}),()=>{t=!0}},[e]),(0,_.useEffect)(()=>{g(!K.has(e)),o(K.get(e)??null),y(null),x(null),C(!1);let t=!1;return Y(e,ge(e)&&(A.current===e&&O>0||m(e)>0)).then(async n=>{if(!t){if(X(e))try{let n=await ve(e);if(t)return;if(n){x(n),g(!1);return}}catch{}o(n),g(!1)}}).catch(async n=>{if(!t){if(X(e))try{let n=await ve(e);if(t)return;if(n){x(n),g(!1);return}}catch{}y(n.message),g(!1)}}),()=>{t=!0}},[e,O]),(0,_.useEffect)(()=>{T(t??``)},[t]);let j=(0,_.useMemo)(()=>!t||!a?!1:!a.some(e=>e.id===t),[t,a]),M=(0,_.useCallback)(e=>{if(e===`__OTHER__`){C(!0),T(t??``);return}e!==`__CUSTOM__`&&n(e===`__DEFAULT__`?void 0:e)},[n,t]),N=(0,_.useCallback)(()=>{n(w.trim()||void 0),C(!1)},[w,n]);if(s)return(0,V.jsx)(`span`,{className:`muted small`,children:`loading models…`});if(b){let e=b.activeInstallsCount;return(0,V.jsx)(`span`,{className:`muted small`,children:e>0?`No models downloaded; ${e} download${e===1?``:`s`} in progress`:`No models downloaded`})}if(v)return(0,V.jsx)(`span`,{className:`error small`,title:v,children:`failed to load`});if(S)return(0,V.jsxs)(`span`,{className:`model-picker-other`,children:[(0,V.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:`Model ID`}),(0,V.jsx)(`button`,{type:`button`,onClick:N,children:`Save`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),T(t??``)},children:`Cancel`})]});let P=j?`__CUSTOM__`:t||`__DEFAULT__`,F=t?a?.find(e=>e.id===t):void 0,I=F&&F.supportsTools===!1,L=t&&(e===`llama-cpp`||e===`ds4`)?E?.get(`${e}:${t}`):void 0,R=L&&!L.stale&&L.record.status===`probed`?r({fitness:{record:L.record,stale:L.stale,hardwareChanged:L.hardwareChanged}}):null;return(0,V.jsxs)(`span`,{className:`model-picker-wrap`,children:[(0,V.jsxs)(c,{value:P,onValueChange:M,children:[(0,V.jsx)(d,{children:(0,V.jsx)(u,{placeholder:i})}),(0,V.jsxs)(f,{children:[(0,V.jsx)(l,{value:`__DEFAULT__`,children:i}),a?.map(e=>(0,V.jsxs)(l,{value:e.id,children:[e.name,e.supportsReasoning?` · reasoning`:``]},e.id)),j&&(0,V.jsxs)(l,{value:`__CUSTOM__`,children:[t,` (custom)`]}),(0,V.jsx)(l,{value:`__OTHER__`,children:`Other…`})]})]}),I&&(0,V.jsx)(`span`,{className:`model-picker-warn`,title:`This model doesn't support structured tool calls, so gezellen on it can't use MCP tools (read/write files, create tasks, etc.). Pick a tool-capable model (llama3.1+, qwen2.5+, mistral, gpt-oss, etc.) if you need tool use.`,children:`no tools`}),R?.tier===`warn`&&(0,V.jsxs)(`span`,{className:`model-picker-warn`,title:R.detail,children:[`fitness: `,R.label]})]})}function $(e,t=!0){let[n,r]=(0,_.useState)(t?K.get(e)??null:null);return(0,_.useEffect)(()=>{if(!t)return;let n=!1;return Y(e).then(e=>{n||r(e)}).catch(()=>{}),()=>{n=!0}},[e,t]),t?n:null}function be(e,t,n,r=!0){let i=$(e,r);if(!i)return null;let a=t??n;return a?i.find(e=>e.id===a)?.supportsReasoning===!0:!1}function xe({provider:e,model:t,value:n,onChange:r}){let i=$(e);if(!t||!i)return null;let a=i.find(e=>e.id===t);if(!a?.supportsReasoning)return null;let o=a.reasoningEfforts??[`low`,`medium`,`high`],s=a.defaultReasoningEffort?`Default (${a.defaultReasoningEffort})`:`Default`;return(0,V.jsxs)(c,{value:n||`__DEFAULT__`,onValueChange:e=>r(e===`__DEFAULT__`?void 0:e),children:[(0,V.jsx)(d,{"aria-label":`Reasoning effort`,children:(0,V.jsx)(u,{})}),(0,V.jsxs)(f,{children:[(0,V.jsx)(l,{value:`__DEFAULT__`,children:s}),o.map(e=>(0,V.jsx)(l,{value:e,children:e},e))]})]})}var Se={minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Maximum`,ultra:`Ultra`};function Ce({provider:e,model:t,defaultModel:n,value:r,onChange:i}){let a=$(e);if(!a)return(0,V.jsx)(`span`,{className:`muted small`,children:`loading effort levels…`});let o=a.find(e=>e.id===(t??n));if(!o?.supportsReasoning)return null;let s=o.reasoningEfforts??[`low`,`medium`,`high`];return(0,V.jsx)(`div`,{className:`gz-tray reasoning-effort-tray`,role:`radiogroup`,"aria-label":`Reasoning effort`,children:[[void 0,o.defaultReasoningEffort?`Model default (${Se[o.defaultReasoningEffort]??o.defaultReasoningEffort})`:`Model default`],...s.map(e=>[e,Se[e]??e])].map(([e,t])=>{let n=r===e||!r&&e===void 0;return(0,V.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,className:`gz-key${n?` gz-key-active`:``}`,onClick:()=>i(e),children:t},e??`__DEFAULT__`)})})}export{le as a,be as i,Ce as n,ye as r,xe as t};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{I as r,i,mt as a,sn as o}from"./dist-CE5CbmDb.js";import{t as s}from"./api-CmrgM5Rf.js";import{d as c,l,m as u,p as d,s as f}from"./primitives-CWrGZpPI.js";import{a as p,o as m,t as h}from"./model-inventory-ykSm_IT5.js";import{t as g}from"./GezelJsonEditor-B9XEiW5Y.js";var _=e(t(),1),v={type:`number`,title:`Temperature`,description:`How adventurous the model is when picking words. Low values (0–0.3) make replies steady and repeatable — good for code, math, structured output. Mid values (0.5–0.9) feel like a thoughtful conversation. High values (1.0+) get creative but can drift off-topic or start rambling. 0 picks the single most likely word every time.`,minimum:0,maximum:2,multipleOf:.05},y={type:`number`,title:`top_p (nucleus)`,description:`Trims the long tail of unlikely word choices. 0.95 keeps the model honest while letting it surprise you — the modern default. Lower values (0.7–0.85) make replies more predictable and stay in the safe zone. Higher values (close to 1) let weirder picks through. Usually tune temperature first, top_p second.`,minimum:0,maximum:1,multipleOf:.01},b={type:`integer`,title:`top_k`,description:`A hard ceiling on how many word choices the model considers at each step. 20 is what Qwen recommends for thinking mode. 64 is Gemma's default. 1 means 'always pick the single most likely word' — deterministic but flat. Lower top_k = more predictable; higher = more variety.`,minimum:0,maximum:1e3},x={type:`number`,title:`min_p`,description:`A floor on word probability — filters out the really unlikely tokens regardless of top_k. 0 disables. 0.05 is a mild filter that prevents the model from grabbing genuinely rare tokens. Most users leave this at 0 and tune temperature + top_p instead.`,minimum:0,maximum:1,multipleOf:.01},S={type:`integer`,title:`Max reply length (tokens)`,description:`Hard ceiling on how long one reply can be. Counts every word, punctuation mark, and reasoning token. Most chat turns fit in 2k–8k. Reasoning models that 'think out loud' need 16k+ to leave room for the actual answer after the thinking trace. Hitting this cap mid-reply cuts the model off.`,minimum:1,maximum:131072},C={type:`integer`,title:`Seed`,description:`Lock in a specific run. Same seed + same prompt = (usually) the same reply, so you can A/B test prompt changes or reproduce a bug. Leave blank for random. Cloud providers honor seed on a best-effort basis; local engines are stricter.`},w={type:`number`,title:`Repetition penalty`,description:`Punishes the model for re-using words it just said. 1.0 = off (the model is allowed to repeat freely). 1.1 = mild — catches 'I will… I'll… I will…' loops. Push above 1.2 and the model starts dodging legitimate repeats (the word 'the' starts feeling rare), and replies feel oddly stilted.`,minimum:0,maximum:3,multipleOf:.05},T={type:`integer`,title:`Repetition window (tokens)`,description:`How far back the repetition penalty looks. 20–64 catches recent loops without affecting older context. Larger windows (256+) penalize re-using words from much earlier in the chat — usually too aggressive for conversation.`,minimum:1,maximum:8192},E={type:`number`,title:`Frequency penalty`,description:`Penalty that scales with how often a word has already appeared in this reply. Positive values (0.3–0.8) discourage repeating common words; negative values encourage repetition. -2 to 2; usually 0.`,minimum:-2,maximum:2,multipleOf:.05},D={type:`number`,title:`Presence penalty`,description:`Penalty applied once any word has appeared at all in this reply (not scaled by count). Positive values (0.3–0.8) push the model toward new vocabulary; useful for brainstorming. -2 to 2; usually 0.`,minimum:-2,maximum:2,multipleOf:.05},O={type:`object`,title:`DRY anti-repetition (llama only)`,description:`Don't-Repeat-Yourself: catches longer phrase loops that simple repetition penalty misses. Helpful for small local models that get stuck repeating whole sentences. Set multiplier to 0 to disable.`,properties:{multiplier:{type:`number`,title:`Strength`,description:`How hard to penalize repeats. 0 = off. 0.8 is a reasonable starting point — strong enough to break loops without hurting normal repetition.`,minimum:0,maximum:5,multipleOf:.05},base:{type:`number`,title:`Penalty curve`,description:`How fast the penalty grows for longer repeated sequences. Higher = more aggressive on long repeats. 1.75 is the upstream default.`,minimum:0,maximum:5,multipleOf:.05},allowedLength:{type:`integer`,title:`Free length`,description:`Repeats shorter than this don't get penalized. 2 = allow 2-token repeats (small phrases), penalize anything longer.`,minimum:0,maximum:64}}},k={type:`object`,title:`XTC sampler (llama only)`,description:`Exclude-Top-Choices: occasionally throws away the most likely word and picks from the rest. Adds personality and surprise to creative writing. Skip this if you want consistency.`,properties:{probability:{type:`number`,title:`Trigger rate`,description:`How often XTC fires. 0 = never. 0.5 = half the time. Higher values make replies less predictable.`,minimum:0,maximum:1,multipleOf:.01},threshold:{type:`number`,title:`Activation threshold`,description:`Only fires when the top word is more likely than this. 0.1 = activate when the model is fairly sure (most of the time); higher values restrict XTC to high-confidence moments.`,minimum:0,maximum:1,multipleOf:.01}}},A={type:`object`,title:`Reasoning`,description:`Controls how much the model 'thinks out loud' before answering.`,properties:{effort:{type:`string`,enum:[`low`,`medium`,`high`],title:`Reasoning effort`,description:`How hard the model works before replying. Low = quick takes (fast, cheap). Medium = balanced (most common default). High = deep deliberation (slower, more thorough — best for math, code, complex planning). Maps to OpenAI's reasoning.effort and Anthropic's thinking.budget_tokens behind the scenes.`,squisq:{control:`segmented`}},thinkingBudget:{type:`integer`,title:`Thinking budget (tokens)`,description:`Explicit cap on how many tokens the model can spend thinking before it has to answer. Anthropic Claude and Nemotron use this directly. Wins over 'effort' when both are set. Typical values: 2k for quick, 8k for medium, 24k+ for deep reasoning.`,minimum:1,maximum:65536},enableThinking:{type:`boolean`,title:`Show reasoning`,description:`On = the model writes out its thinking before the final answer (often visible as a collapsible 'thinking' block). Off = the model goes straight to the answer. Mainly affects dual-mode local models like Qwen3 and Nemotron Nano/Super — cloud thinking models infer from the reasoning effort/budget.`}}},j={type:`object`,title:`Structured output`,description:`Force the model to produce machine-readable output instead of prose.`,properties:{responseFormat:{type:`string`,enum:[`text`,`json_object`],title:`Output format`,description:`Text = normal prose (default). JSON = the model must emit syntactically-valid JSON. Combine with a JSON Schema below to pin the exact shape.`,squisq:{control:`segmented`,enumLabels:{text:`Text`,json_object:`JSON`}}}}},M={type:`string`,enum:[`auto`,`required`,`none`],title:`Tool calling`,description:`Auto = the model decides whether to call a tool (normal). Required = the model MUST call a tool this turn (good for forcing structured handoffs). None = tools are hidden from the model — pure chat.`,squisq:{control:`segmented`}},N={type:`object`,title:`Reasoning prompt tags`,description:`Markers a user can include in a message to flip reasoning on/off for just that turn. Qwen recognizes /think and /no_think by default.`,properties:{enableThinkingTag:{type:`string`,title:`Enable tag`,description:"Example: `/think`. Adding this to your message turns thinking ON for that turn."},disableThinkingTag:{type:`string`,title:`Disable tag`,description:"Example: `/no_think`. Adding this to your message turns thinking OFF for that turn."}}};function P(e){return{type:`object`,title:`When thinking is on, use these instead`,description:`Some models like Qwen3 and Nemotron Nano want different sampling when reasoning. Only fill in the fields you want to change for thinking mode — the rest fall through to your main Sampling values above.`,properties:e,squisq:{hidden:{field:`reasoning.enableThinking`,truthy:!1}}}}var F={temperature:v,topP:y,topK:b,maxTokens:S,seed:C,frequencyPenalty:E,presencePenalty:D},I={type:`object`,title:`Structured output`,properties:{responseFormat:j.properties.responseFormat,jsonSchema:{type:`object`,title:`JSON Schema`,description:`OpenAI strict mode. Leave empty for free-form JSON.`,additionalProperties:!0}}},L={type:`object`,title:`Advanced tuning (cloud)`,description:`Per-turn sampling, structured output, and reasoning controls. Empty fields fall through to the catalog default. Fields the active provider doesn't support are silently dropped at request build.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:F},samplingWhenThinking:P(F),reasoning:A,output:I,toolChoice:M}},R={temperature:v,topP:y,topK:b,minP:x,maxTokens:S,seed:C,repetitionPenalty:w,repetitionContext:T,frequencyPenalty:E,presencePenalty:D,dry:O,xtc:k},ee={...A,properties:{enableThinking:A.properties.enableThinking}},te={type:`object`,title:`Structured output`,properties:{responseFormat:j.properties.responseFormat,jsonSchema:{type:`object`,title:`JSON Schema`,description:"Pin output to a JSON Schema. Drives llama `--json-schema`. Leave empty for free-form JSON.",additionalProperties:!0},grammar:{type:`string`,title:`GBNF grammar`,description:`Last-resort structured-output knob. llama-only. Multi-line GBNF source.`,maxLength:4096,squisq:{control:`multiline`}}}},ne={type:`object`,title:`Advanced tuning (llama)`,description:`Per-turn sampling, structured output, and reasoning controls. Empty fields fall through to the catalog default.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:R},samplingWhenThinking:P(R),reasoning:ee,output:te,toolChoice:M,promptTags:N}},z={temperature:v,topP:y,topK:b,minP:x,maxTokens:S,seed:C,repetitionPenalty:w,repetitionContext:T},re={...A,properties:{enableThinking:A.properties.enableThinking}},ie={type:`object`,title:`Advanced tuning (MLX)`,description:`Per-turn sampling and reasoning controls. Empty fields fall through to the catalog default.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:z},samplingWhenThinking:P(z),reasoning:re,output:j,toolChoice:M,promptTags:N}},B={temperature:v,topP:y,topK:b,minP:x,maxTokens:S,seed:C,repetitionPenalty:w,repetitionContext:T,frequencyPenalty:E,presencePenalty:D},ae={...A,properties:{enableThinking:A.properties.enableThinking}},oe={type:`object`,title:`Structured output`,properties:{responseFormat:j.properties.responseFormat,jsonSchema:{type:`object`,title:`JSON Schema`,description:"Pin output to a JSON Schema. Maps to Ollama 0.5+ `format: <schema>`. Leave empty for free-form JSON.",additionalProperties:!0}}},se={type:`object`,title:`Advanced tuning (Ollama)`,description:`Per-turn sampling, structured output, and reasoning controls. Empty fields fall through to the catalog default.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:B},samplingWhenThinking:P(B),reasoning:ae,output:oe,promptTags:N}};function ce(e){switch(e){case`llama-cpp`:case`ds4`:return ne;case`mlx`:return ie;case`ollama`:return se;case`openai`:case`anthropic`:case`anthropic-cli`:case`codex-cli`:case`copilot`:return L;case`remote`:return L;default:return e}}var V=n();function le({provider:e,override:t,inherited:n,onSave:r,scopeLabel:s=`this scope`,disabled:c,tuningProfileId:l}){let u=(0,_.useMemo)(()=>ce(e),[e]),d=(0,_.useMemo)(()=>pe(u,n??{}),[u,n]),f=(0,_.useMemo)(()=>ue(n??{},t??{}),[n,t]),[p,m]=(0,_.useState)(f),[h,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null);(0,_.useEffect)(()=>{m(f)},[f]);let x=(0,_.useCallback)(e=>{m(e??{})},[]),S=(0,_.useMemo)(()=>de(p,n??{}),[p,n]),C=S!==null,w=(0,_.useMemo)(()=>S?W(S):`(none)`,[S]),T=(0,_.useMemo)(()=>W(p)||`(provider defaults)`,[p]),E=(0,_.useMemo)(()=>W(n??{})||`(provider defaults)`,[n]),D=(0,_.useMemo)(()=>{if(l)return o(l,Object.keys(n?.profiles??{}))},[l,n]),O=(0,_.useMemo)(()=>{if(!l)return null;if(D){let e=a(D)?i[D].label:D,t=D!==l,n=a(l)?i[l].label:l;return t?`${e} (fallback from ${n} — model doesn't define it)`:e}return`${l} (not defined on this model — base tuning applies)`},[l,D]),k=(0,_.useCallback)(async()=>{v(!0),b(null);try{await r(S)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[S,r]),A=(0,_.useCallback)(async()=>{v(!0),b(null);try{await r(null),m(n??{})}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[n,r]);return(0,V.jsxs)(`div`,{className:`tuning-panel`,children:[(0,V.jsxs)(`div`,{className:`tuning-panel-summary small`,style:{display:`flex`,flexDirection:`column`,gap:`0.25rem`,marginBottom:`0.5rem`},children:[O&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`strong`,{children:`Active voice:`}),` `,(0,V.jsx)(`span`,{className:`muted`,children:O})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`strong`,{children:`Effective now:`}),` `,(0,V.jsx)(`span`,{className:`muted`,children:T})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`strong`,{children:`Inherited default:`}),` `,(0,V.jsx)(`span`,{className:`muted`,children:E})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`strong`,{children:[`Your override for `,s,`:`]}),` `,(0,V.jsx)(`span`,{className:C?``:`muted`,children:w})]})]}),(0,V.jsx)(g,{schema:d,value:p,onChange:x,density:`compact`}),(0,V.jsxs)(`div`,{className:`tuning-panel-actions`,style:{marginTop:`0.5rem`},children:[(0,V.jsx)(`button`,{type:`button`,onClick:k,disabled:c||h,children:h?`Saving…`:C?`Save override for ${s}`:`Save (no override)`}),t&&Object.keys(t).length>0&&(0,V.jsx)(`button`,{type:`button`,onClick:A,disabled:c||h,className:`muted`,style:{marginLeft:`0.5rem`},children:`Reset to inherited defaults`})]}),y&&(0,V.jsx)(`div`,{className:`tuning-panel-error small error`,style:{marginTop:`0.25rem`},children:y})]})}function ue(e,t){let n={...e};for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];t&&typeof t==`object`&&!Array.isArray(t)&&r&&typeof r==`object`&&!Array.isArray(r)?n[e]=ue(t,r):n[e]=r}return n}function de(e,t){let n=fe(e,t);return n===null?null:n}function fe(e,t){let n={},r=!1;for(let[i,a]of Object.entries(e)){let e=t[i];if(a!=null)if(typeof a==`object`&&!Array.isArray(a)&&typeof e==`object`&&e&&!Array.isArray(e)){let t=fe(a,e);t!==null&&(n[i]=t,r=!0)}else H(a,e)||(n[i]=a,r=!0)}return r?n:null}function H(e,t){return e===t?!0:typeof e==typeof t?Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>H(e,t[n])):JSON.stringify(e)===JSON.stringify(t):!1}function pe(e,t){return U(e,t)}function U(e,t){let n={...e};if(n.properties){let e={};for(let[r,i]of Object.entries(n.properties))e[r]=U(i,t&&typeof t==`object`?t[r]:void 0);n.properties=e}if(n.type!==`object`&&t!=null){let e=me(t);if(e!==null){let t=n.description??``;n.description=t?`${t}\n\nDefault: ${e}`:`Default: ${e}`}}return n}function me(e){return typeof e==`number`?String(e):typeof e==`boolean`?e?`on`:`off`:typeof e==`string`?e:null}function W(e){let t=[];if(e.sampling){let n=e.sampling,r=[];n.temperature!==void 0&&r.push(`temp ${n.temperature}`),n.topP!==void 0&&r.push(`top_p ${n.topP}`),n.topK!==void 0&&r.push(`top_k ${n.topK}`),n.minP!==void 0&&r.push(`min_p ${n.minP}`),n.maxTokens!==void 0&&r.push(`max ${n.maxTokens}`),n.seed!==void 0&&r.push(`seed ${n.seed}`),n.repetitionPenalty!==void 0&&r.push(`rep ${n.repetitionPenalty}`),n.frequencyPenalty!==void 0&&r.push(`freq ${n.frequencyPenalty}`),n.presencePenalty!==void 0&&r.push(`pres ${n.presencePenalty}`),r.length>0&&t.push(r.join(`, `))}if(e.reasoning){let n=e.reasoning;n.effort&&t.push(`effort ${n.effort}`),n.thinkingBudget!==void 0&&t.push(`budget ${n.thinkingBudget}`),n.enableThinking===!0&&t.push(`thinking on`),n.enableThinking===!1&&t.push(`thinking off`)}return e.output?.responseFormat&&e.output.responseFormat!==`text`&&t.push(`format ${e.output.responseFormat}`),e.toolChoice&&t.push(`tools ${e.toolChoice}`),e.samplingWhenThinking&&Object.keys(e.samplingWhenThinking).length>0&&t.push(`+thinking sampling`),e.promptTags?.enableThinkingTag&&t.push(`tag ${e.promptTags.enableThinkingTag}`),t.join(` · `)}var G=new Map,K=new Map,q=new Map;function J(e){q.set(e,(q.get(e)??0)+1),K.delete(e),G.delete(e)}async function Y(e,t=!1){if(t&&J(e),!t){let t=K.get(e);if(t)return t;let n=G.get(e);if(n)return n}let n=q.get(e)??0,r=(e===`remote`?he():s.listProviderModels(e,t?{refresh:!0}:void 0).then(e=>e.models)).then(t=>((q.get(e)??0)===n&&K.set(e,t),t)).finally(()=>{G.get(e)===r&&G.delete(e)});return G.set(e,r),r}async function he(){let{remotes:e}=await s.listRemotes(),t=[];for(let n of e)try{let{models:e}=await s.listRemoteModels(n.remoteId);for(let r of e)t.push({id:r.id,name:`${n.displayName} · ${r.name}`,...r.supportsTools===void 0?{}:{supportsTools:r.supportsTools},...r.supportsReasoning===void 0?{}:{supportsReasoning:r.supportsReasoning},...r.contextWindow?{contextWindow:r.contextWindow}:{},...r.parameterSize?{parameterSize:r.parameterSize}:{}})}catch{}return t}function X(e){return e===`mlx`||e===`llama-cpp`}function ge(e){return e===`mlx`||e===`llama-cpp`||e===`ds4`}var Z=null,Q=null;async function _e(){return Z||Q||(Q=s.listModelFitness().then(e=>(Z=new Map(e.records.map(e=>[e.key,e])),Z)).finally(()=>{Q=null}),Q)}async function ve(e){let[t,n]=await Promise.all([e===`mlx`?s.listMlxModels():s.listLlamaCppModels(),e===`mlx`?s.listMlxActiveInstalls():s.listLlamaCppActiveInstalls()]);return t.models.length===0?{activeInstallsCount:n.installs.length}:null}function ye({provider:e,value:t,onChange:n,placeholder:i=`Provider default`}){let[a,o]=(0,_.useState)(K.get(e)??null),[s,g]=(0,_.useState)(!K.has(e)),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(t??``),[E,D]=(0,_.useState)(Z),[O,k]=(0,_.useState)(0),A=(0,_.useRef)(null);(0,_.useEffect)(()=>{let t=t=>{let n=p(t);n===e&&(A.current=n,J(e),k(e=>e+1))};return window.addEventListener(h,t),()=>window.removeEventListener(h,t)},[e]),(0,_.useEffect)(()=>{if(e!==`llama-cpp`&&e!==`ds4`)return;let t=!1;return _e().then(e=>{t||D(e)}).catch(()=>{}),()=>{t=!0}},[e]),(0,_.useEffect)(()=>{g(!K.has(e)),o(K.get(e)??null),y(null),x(null),C(!1);let t=!1;return Y(e,ge(e)&&(A.current===e&&O>0||m(e)>0)).then(async n=>{if(!t){if(X(e))try{let n=await ve(e);if(t)return;if(n){x(n),g(!1);return}}catch{}o(n),g(!1)}}).catch(async n=>{if(!t){if(X(e))try{let n=await ve(e);if(t)return;if(n){x(n),g(!1);return}}catch{}y(n.message),g(!1)}}),()=>{t=!0}},[e,O]),(0,_.useEffect)(()=>{T(t??``)},[t]);let j=(0,_.useMemo)(()=>!t||!a?!1:!a.some(e=>e.id===t),[t,a]),M=(0,_.useCallback)(e=>{if(e===`__OTHER__`){C(!0),T(t??``);return}e!==`__CUSTOM__`&&n(e===`__DEFAULT__`?void 0:e)},[n,t]),N=(0,_.useCallback)(()=>{n(w.trim()||void 0),C(!1)},[w,n]);if(s)return(0,V.jsx)(`span`,{className:`muted small`,children:`loading models…`});if(b){let e=b.activeInstallsCount;return(0,V.jsx)(`span`,{className:`muted small`,children:e>0?`No models downloaded; ${e} download${e===1?``:`s`} in progress`:`No models downloaded`})}if(v)return(0,V.jsx)(`span`,{className:`error small`,title:v,children:`failed to load`});if(S)return(0,V.jsxs)(`span`,{className:`model-picker-other`,children:[(0,V.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:`Model ID`}),(0,V.jsx)(`button`,{type:`button`,onClick:N,children:`Save`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),T(t??``)},children:`Cancel`})]});let P=j?`__CUSTOM__`:t||`__DEFAULT__`,F=t?a?.find(e=>e.id===t):void 0,I=F&&F.supportsTools===!1,L=t&&(e===`llama-cpp`||e===`ds4`)?E?.get(`${e}:${t}`):void 0,R=L&&!L.stale&&L.record.status===`probed`?r({fitness:{record:L.record,stale:L.stale,hardwareChanged:L.hardwareChanged}}):null;return(0,V.jsxs)(`span`,{className:`model-picker-wrap`,children:[(0,V.jsxs)(c,{value:P,onValueChange:M,children:[(0,V.jsx)(d,{children:(0,V.jsx)(u,{placeholder:i})}),(0,V.jsxs)(f,{children:[(0,V.jsx)(l,{value:`__DEFAULT__`,children:i}),a?.map(e=>(0,V.jsxs)(l,{value:e.id,children:[e.name,e.supportsReasoning?` · reasoning`:``]},e.id)),j&&(0,V.jsxs)(l,{value:`__CUSTOM__`,children:[t,` (custom)`]}),(0,V.jsx)(l,{value:`__OTHER__`,children:`Other…`})]})]}),I&&(0,V.jsx)(`span`,{className:`model-picker-warn`,title:`This model doesn't support structured tool calls, so gezellen on it can't use MCP tools (read/write files, create tasks, etc.). Pick a tool-capable model (llama3.1+, qwen2.5+, mistral, gpt-oss, etc.) if you need tool use.`,children:`no tools`}),R?.tier===`warn`&&(0,V.jsxs)(`span`,{className:`model-picker-warn`,title:R.detail,children:[`fitness: `,R.label]})]})}function $(e,t=!0){let[n,r]=(0,_.useState)(t?K.get(e)??null:null);return(0,_.useEffect)(()=>{if(!t)return;let n=!1;return Y(e).then(e=>{n||r(e)}).catch(()=>{}),()=>{n=!0}},[e,t]),t?n:null}function be(e,t,n,r=!0){let i=$(e,r);if(!i)return null;let a=t??n;return a?i.find(e=>e.id===a)?.supportsReasoning===!0:!1}function xe({provider:e,model:t,value:n,onChange:r}){let i=$(e);if(!t||!i)return null;let a=i.find(e=>e.id===t);if(!a?.supportsReasoning)return null;let o=a.reasoningEfforts??[`low`,`medium`,`high`],s=a.defaultReasoningEffort?`Default (${a.defaultReasoningEffort})`:`Default`;return(0,V.jsxs)(c,{value:n||`__DEFAULT__`,onValueChange:e=>r(e===`__DEFAULT__`?void 0:e),children:[(0,V.jsx)(d,{"aria-label":`Reasoning effort`,children:(0,V.jsx)(u,{})}),(0,V.jsxs)(f,{children:[(0,V.jsx)(l,{value:`__DEFAULT__`,children:s}),o.map(e=>(0,V.jsx)(l,{value:e,children:e},e))]})]})}var Se={minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Maximum`,ultra:`Ultra`};function Ce({provider:e,model:t,defaultModel:n,value:r,onChange:i}){let a=$(e);if(!a)return(0,V.jsx)(`span`,{className:`muted small`,children:`loading effort levels…`});let o=a.find(e=>e.id===(t??n));if(!o?.supportsReasoning)return null;let s=o.reasoningEfforts??[`low`,`medium`,`high`];return(0,V.jsx)(`div`,{className:`gz-tray reasoning-effort-tray`,role:`radiogroup`,"aria-label":`Reasoning effort`,children:[[void 0,o.defaultReasoningEffort?`Model default (${Se[o.defaultReasoningEffort]??o.defaultReasoningEffort})`:`Model default`],...s.map(e=>[e,Se[e]??e])].map(([e,t])=>{let n=r===e||!r&&e===void 0;return(0,V.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,className:`gz-key${n?` gz-key-active`:``}`,onClick:()=>i(e),children:t},e??`__DEFAULT__`)})})}export{le as a,be as i,Ce as n,ye as r,xe as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./react-dom-OL4w_gzs.js";import{A as i,D as a,E as o,H as s,J as c,K as l,M as u,O as d,T as f,W as p,X as m,Y as h,Z as g,j as _,k as v,q as y,w as b}from"./primitives-CWrGZpPI.js";import{c as x,l as ee,n as te,o as S,r as C,s as w}from"./DropdownMenu-DlrvEmoV.js";import{n as T}from"./relative-time-B2kBaekd.js";import{t as E}from"./FileTypeIcon-Cwzl1GkZ.js";var D=e(t(),1),O=Object.defineProperty,k=(e,t)=>O(e,`name`,{value:t,configurable:!0}),A=!!(typeof window<`u`&&window.document&&window.document.createElement);function j(e,t,{checkForDefaultPrevented:n=!0}={}){return k(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}k(j,`composeEventHandlers`);function M(e){if(!A)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}k(M,`getOwnerWindow`);function N(e){if(!A)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}k(N,`getOwnerDocument`);function ne(e,t=!1){let{activeElement:n}=N(e);if(!n?.nodeName)return null;if(P(n)&&n.contentDocument)return ne(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=N(n).getElementById(e);if(t)return t}}return n}k(ne,`getActiveElement`);function P(e){return e.tagName===`IFRAME`}k(P,`isFrame`);var F=n(),re=Object.defineProperty,I=(e,t)=>re(e,`name`,{value:t,configurable:!0});function ie(e,t){let n=D.createContext(t);n.displayName=e+`Context`;let r=I(e=>{let{children:t,...r}=e,i=D.useMemo(()=>r,Object.values(r));return(0,F.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=D.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return I(i,`useContext`),[r,i]}I(ie,`createContext`);function L(e,t=[]){let n=[];function r(t,r){let i=D.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=I(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=D.useMemo(()=>o,Object.values(o));return(0,F.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=D.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return I(s,`useContext`),[o,s]}I(r,`createContext`);let i=I(()=>{let t=n.map(e=>D.createContext(e));return I(function(n){let r=n?.[e]||t;return D.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,ae(i,...t)]}I(L,`createContextScope`);function ae(...e){let t=e[0];if(e.length===1)return t;let n=I(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return I(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return D.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}I(ae,`composeContextScopes`);var oe=e(r(),1),R=Object.defineProperty,se=(e,t)=>R(e,`name`,{value:t,configurable:!0});function ce(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}se(ce,`setRef`);function le(...e){return t=>{let n=!1,r=e.map(e=>{let r=ce(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():ce(e[t],null)}}}}se(le,`composeRefs`);function z(...e){return D.useCallback(le(...e),e)}se(z,`useComposedRefs`);var ue=Object.defineProperty,B=(e,t)=>ue(e,`name`,{value:t,configurable:!0});function V(e){let t=D.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];ve(r)&&typeof Se==`function`&&(r=Se(r._payload)),D.Children.forEach(r,e=>{if(ge(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;ve(n)&&typeof Se==`function`&&(n=Se(n._payload)),a=pe(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=D.cloneElement(a,void 0,s):!o&&D.Children.count(r)===1&&D.isValidElement(r)&&(a=r);let c=a?he(a):void 0,l=z(n,c);if(!a){if(r||r===0)throw Error(o?xe(e):be(e));return r}let u=me(i,a.props??{});return a.type!==D.Fragment&&(u.ref=n?l:c),D.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}B(V,`createSlot`);var de=Symbol.for(`radix.slottable`);function fe(e){let t=B(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=de,t}B(fe,`createSlottable`);var pe=B((e,t)=>{if(`child`in e.props){let t=e.props.child;return D.isValidElement(t)?D.cloneElement(t,void 0,e.props.children(t.props.children)):null}return D.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function me(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}}B(me,`mergeProps`);function he(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)}B(he,`getElementRef`);function ge(e){return D.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===de}B(ge,`isSlottable`);var _e=Symbol.for(`react.lazy`);function ve(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===_e&&`_payload`in e&&ye(e._payload)}B(ve,`isLazyComponent`);function ye(e){return typeof e==`object`&&!!e&&`then`in e}B(ye,`isPromiseLike`);var be=B(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),xe=B(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),Se=D.use,Ce=Object.defineProperty,we=(e,t)=>Ce(e,`name`,{value:t,configurable:!0}),H=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=V(`Primitive.${t}`),r=D.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,F.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Te(e,t){e&&oe.flushSync(()=>e.dispatchEvent(t))}we(Te,`dispatchDiscreteCustomEvent`);var Ee=Object.defineProperty,U=(e,t)=>Ee(e,`name`,{value:t,configurable:!0});function De(e){let t=e+`CollectionProvider`,[n,r]=L(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=U(e=>{let{scope:t,children:n}=e,r=D.useRef(null),a=D.useRef(new Map).current;return(0,F.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=V(s),l=D.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=z(t,a(s,n).collectionRef);return(0,F.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=V(u),p=D.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=D.useRef(null),s=z(t,o),c=a(u,n);return D.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,F.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return D.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return U(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}U(De,`createCollection`);var Oe=new WeakMap,ke=class e extends Map{static{U(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Oe.set(this,!0)}set(e,t){return Oe.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=Me(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=Ae(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=Ae(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Ae(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function Ae(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=je(e,t);return n===-1?void 0:e[n]}U(Ae,`at`);function je(e,t){let n=e.length,r=Me(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}U(je,`toSafeIndex`);function Me(e){return e!==e||e===0?0:Math.trunc(e)}U(Me,`toSafeInteger`);function Ne(e){let t=e+`CollectionProvider`,[n,r]=L(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new ke,setItemMap:U(()=>void 0,`setItemMap`)}),o=U(({state:e,...t})=>e?(0,F.jsx)(c,{...t,state:e}):(0,F.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=U(e=>{let t=h();return(0,F.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=U(e=>{let{scope:t,children:n,state:r}=e,a=D.useRef(null),[o,s]=D.useState(null),c=z(a,s),[l,u]=r;return D.useEffect(()=>{if(!o)return;let e=Le(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,F.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=V(l),d=D.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=z(t,a(l,n).collectionRef);return(0,F.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=V(f),m=D.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=D.useRef(null),[s,c]=D.useState(null),l=z(t,o,c),{setItemMap:u}=a(f,n),d=D.useRef(i);Pe(d.current,i)||(d.current=i);let m=d.current;return D.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(Ie):(t.set(s,{...e,element:s}),t.toSorted(Ie)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new ke(e)))}},[s,m,u]),(0,F.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return D.useState(new ke)}U(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return U(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}U(Ne,`createCollection`);function Pe(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}U(Pe,`shallowEqual`);function Fe(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}U(Fe,`isElementPreceding`);function Ie(e,t){return!e[1].element||!t[1].element?0:Fe(e[1].element,t[1].element)?-1:1}U(Ie,`sortByDocumentPosition`);function Le(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}U(Le,`getChildListObserver`);var Re=Object.defineProperty,ze=(e,t)=>Re(e,`name`,{value:t,configurable:!0}),Be=D.createContext(void 0);function Ve(e){let t=D.useContext(Be);return e||t||`ltr`}ze(Ve,`useDirection`);var He=Object.defineProperty,Ue=(e,t)=>He(e,`name`,{value:t,configurable:!0});function W(e){let t=D.useRef(e);return D.useEffect(()=>{t.current=e}),D.useMemo(()=>((...e)=>t.current?.(...e)),[])}Ue(W,`useCallbackRef`);var We=Object.defineProperty,G=(e,t)=>We(e,`name`,{value:t,configurable:!0}),Ge=`dismissableLayer.update`,Ke=`dismissableLayer.pointerDownOutside`,qe=`dismissableLayer.focusOutside`,Je,Ye=D.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Xe=D.forwardRef(G(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=D.useContext(Ye),[d,f]=D.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=D.useState({}),h=z(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,ee=D.useRef(!1),te=$e(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:ee,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:D.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),S=et(e=>{if(r&&ee.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),C=d?y===g.length-1:!1,w=W(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return D.useEffect(()=>{if(C)return p.addEventListener(`keydown`,w,{capture:!0}),()=>p.removeEventListener(`keydown`,w,{capture:!0})},[p,C,w]),D.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Je=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),tt(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Je))}},[d,p,n,u]),D.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),tt())},[d,u]),D.useEffect(()=>{let e=G(()=>m({}),`handleUpdate`);return document.addEventListener(Ge,e),()=>document.removeEventListener(Ge,e)},[]),(0,F.jsx)(H.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:j(e.onFocusCapture,S.onFocusCapture),onBlurCapture:j(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:j(e.onPointerDownCapture,te.onPointerDownCapture)})},`DismissableLayer`));function Ze(){let e=D.useContext(Ye),[t,n]=D.useState(null);return D.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}G(Ze,`useDismissableLayerSurface`);var Qe=G(()=>!0,`IS_TRUE`);function $e(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Qe}=t,s=W(e),c=D.useRef(!1),l=D.useRef(!1),u=D.useRef(new Map),d=D.useRef(()=>{});return D.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}G(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}G(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}G(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}G(p,`handleInteractionBubble`);let m=G(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||nt(Ke,s,p,{discrete:!0})};if(G(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:G(()=>c.current=!0,`onPointerDownCapture`)}}G($e,`usePointerDownOutside`);function et(e,t=globalThis?.document){let n=W(e),r=D.useRef(!1);return D.useEffect(()=>{let e=G(e=>{e.target&&!r.current&&nt(qe,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:G(()=>r.current=!0,`onFocusCapture`),onBlurCapture:G(()=>r.current=!1,`onBlurCapture`)}}G(et,`useFocusOutside`);function tt(){let e=new CustomEvent(Ge);document.dispatchEvent(e)}G(tt,`dispatchUpdate`);function nt(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?Te(i,a):i.dispatchEvent(a)}G(nt,`handleAndDispatchCustomEvent`);var rt=Object.defineProperty,it=(e,t)=>rt(e,`name`,{value:t,configurable:!0}),at=0,ot=null;function st(e){return ct(),e.children}it(st,`FocusGuards`);function ct(){D.useEffect(()=>{ot||={start:lt(),end:lt()};let{start:e,end:t}=ot;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),at++,()=>{at===1&&(ot?.start.remove(),ot?.end.remove(),ot=null),at=Math.max(0,at-1)}},[])}it(ct,`useFocusGuards`);function lt(){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}it(lt,`createFocusGuard`);var ut=Object.defineProperty,K=(e,t)=>ut(e,`name`,{value:t,configurable:!0}),dt=`focusScope.autoFocusOnMount`,ft=`focusScope.autoFocusOnUnmount`,pt={bubbles:!1,cancelable:!0},mt=D.forwardRef(K(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=D.useState(null),l=W(i),u=W(a),d=D.useRef(null),f=z(t,c),p=D.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;D.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:q(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||q(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&q(s)};K(e,`handleFocusIn`),K(t,`handleFocusOut`),K(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),D.useEffect(()=>{if(s){xt.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(dt,pt);s.addEventListener(dt,l),s.dispatchEvent(t),t.defaultPrevented||(ht(wt(_t(s)),{select:!0}),document.activeElement===e&&q(s))}return()=>{s.removeEventListener(dt,l),setTimeout(()=>{let t=new CustomEvent(ft,pt);s.addEventListener(ft,u),s.dispatchEvent(t),t.defaultPrevented||q(e??document.body,{select:!0}),s.removeEventListener(ft,u),xt.remove(p)},0)}}},[s,l,u,p]);let m=D.useCallback(e=>{if(!n&&!r||p.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]=gt(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&q(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&q(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,F.jsx)(H.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})},`FocusScope`));function ht(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(q(r,{select:t}),document.activeElement!==n)return}K(ht,`focusFirst`);function gt(e){let t=_t(e);return[vt(t,e),vt(t.reverse(),e)]}K(gt,`getTabbableEdges`);function _t(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:K(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},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}K(_t,`getTabbableCandidates`);function vt(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):yt(r,{upTo:t})))return r}K(vt,`findVisible`);function yt(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}K(yt,`isHidden`);function bt(e){return e instanceof HTMLInputElement&&`select`in e}K(bt,`isSelectableInput`);function q(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&bt(e)&&t&&e.select()}}K(q,`focus`);var xt=St();function St(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Ct(e,t),e.unshift(t)},remove(t){e=Ct(e,t),e[0]?.resume()}}}K(St,`createFocusScopesStack`);function Ct(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}K(Ct,`arrayRemove`);function wt(e){return e.filter(e=>e.tagName!==`A`)}K(wt,`removeLinks`);var J=globalThis?.document?D.useLayoutEffect:()=>{},Tt=Object.defineProperty,Et=(e,t)=>Tt(e,`name`,{value:t,configurable:!0}),Dt=D.useId||(()=>void 0),Ot=0;function kt(e){let[t,n]=D.useState(Dt());return J(()=>{e||n(e=>e??String(Ot++))},[e]),e||(t?`radix-${t}`:``)}Et(kt,`useId`);var At=Object.defineProperty,jt=(e,t)=>At(e,`name`,{value:t,configurable:!0});function Mt(e){let[t,n]=D.useState(void 0);return J(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}jt(Mt,`useSize`);var Nt=Object.defineProperty,Y=(e,t)=>Nt(e,`name`,{value:t,configurable:!0}),Pt=`Popper`,[Ft,It]=L(Pt),[Lt,Rt]=Ft(Pt),zt=Y(e=>{let{__scopePopper:t,children:n}=e,[r,i]=D.useState(null),[a,o]=D.useState(void 0);return(0,F.jsx)(Lt,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Bt=`PopperAnchor`,Vt=D.forwardRef(Y(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Rt(Bt,n),o=D.useRef(null),s=a.onAnchorChange,c=z(t,D.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=D.useRef(null);D.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&Jt(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,F.jsx)(H.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),Ht=`PopperContent`,[Ut,Wt]=Ft(Ht),Gt=D.forwardRef(Y(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:s=0,align:c=`center`,alignOffset:l=0,arrowPadding:p=0,avoidCollisions:m=!0,collisionBoundary:h=[],collisionPadding:g=0,sticky:y=`partial`,hideWhenDetached:x=!1,updatePositionStrategy:ee=`optimized`,onPlaced:te,...S}=e,C=Rt(Ht,n),[w,T]=D.useState(null),E=z(t,T),[O,k]=D.useState(null),A=Mt(O),j=A?.width??0,M=A?.height??0,N=r+(c===`center`?``:`-`+c),ne=typeof g==`number`?g:{top:0,right:0,bottom:0,left:0,...g},P=Array.isArray(h)?h:[h],re=P.length>0,I={padding:ne,boundary:P.filter(Kt),altBoundary:re},{refs:ie,floatingStyles:L,placement:ae,isPositioned:oe,middlewareData:R}=_({strategy:`fixed`,placement:N,whileElementsMounted:Y((...e)=>u(...e,{animationFrame:ee===`always`}),`whileElementsMounted`),elements:{reference:C.anchor},middleware:[d({mainAxis:s+M,alignmentAxis:l}),m&&v({mainAxis:!0,crossAxis:!1,limiter:y===`partial`?a():void 0,...I}),m&&f({...I}),i({...I,apply:Y(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),O&&b({element:O,padding:p}),qt({arrowWidth:j,arrowHeight:M}),x&&o({strategy:`referenceHidden`,...I,boundary:re?I.boundary:void 0})]}),se=C.setPlacementState;J(()=>(se(ae),()=>{se(void 0)}),[ae,se]);let[ce,le]=Jt(ae),ue=W(te);J(()=>{oe&&ue?.()},[oe,ue]);let B=R.arrow?.x,V=R.arrow?.y,de=R.arrow?.centerOffset!==0,[fe,pe]=D.useState();return J(()=>{w&&pe(window.getComputedStyle(w).zIndex)},[w]),(0,F.jsx)(`div`,{ref:ie.setFloating,"data-radix-popper-content-wrapper":``,style:{...L,transform:oe?L.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:fe,"--radix-popper-transform-origin":[R.transformOrigin?.x,R.transformOrigin?.y].join(` `),...R.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,F.jsx)(Ut,{scope:n,placedSide:ce,placedAlign:le,onArrowChange:k,arrowX:B,arrowY:V,shouldHideArrow:de,children:(0,F.jsx)(H.div,{"data-side":ce,"data-align":le,...S,ref:E,style:{...S.style,animation:oe?S.style?.animation:`none`}})})})},`PopperContent`));function Kt(e){return e!==null}Y(Kt,`isNotNull`);var qt=Y(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Jt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Jt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Y(Jt,`getSideAndAlignFromPlacement`);var Yt=zt,Xt=Vt,Zt=Gt,Qt=Object.defineProperty,$t=D.forwardRef(((e,t)=>Qt(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=D.useState(!1);J(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?oe.createPortal((0,F.jsx)(H.div,{...r,ref:t}),o):null},`Portal`)),en=Object.defineProperty,X=(e,t)=>en(e,`name`,{value:t,configurable:!0});function tn(e,t){return D.useReducer((e,n)=>t[e][n]??e,e)}X(tn,`useStateMachine`);var nn=X(e=>{let{present:t,children:n}=e,r=rn(t),i=typeof n==`function`?n({present:r.isPresent}):D.Children.only(n),a=on(r.ref,cn(i));return typeof n==`function`||r.isPresent?D.cloneElement(i,{ref:a}):null},`Presence`);function rn(e){let[t,n]=D.useState(),r=D.useRef(null),i=D.useRef(e),a=D.useRef(`none`),o=D.useRef(void 0),[s,c]=tn(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return D.useEffect(()=>{s===`mounted`?(a.current=o.current??sn(r.current),o.current=void 0):a.current=`none`},[s]),J(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=sn(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),J(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=X(a=>{let o=sn(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=X(e=>{e.target===t&&(a.current=sn(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:D.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=sn(t)}else r.current=null;n(e)},[])}}X(rn,`usePresence`);function an(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}X(an,`setRef`);function on(...e){let t=D.useRef(e);return t.current=e,D.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=an(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():an(n[e],null)}}},[])}X(on,`useStableComposedRefs`);function sn(e){return e?.animationName||`none`}X(sn,`getAnimationName`);function cn(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)}X(cn,`getElementRef`);var ln=Object.defineProperty,un=(e,t)=>ln(e,`name`,{value:t,configurable:!0}),dn=D.useEffectEvent,fn=D.useInsertionEffect;function pn(e){if(typeof dn==`function`)return dn(e);let t=D.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof fn==`function`?fn(()=>{t.current=e}):J(()=>{t.current=e}),D.useMemo(()=>((...e)=>t.current?.(...e)),[])}un(pn,`useEffectEvent`);var mn=Object.defineProperty,hn=(e,t)=>mn(e,`name`,{value:t,configurable:!0}),gn=D.useInsertionEffect||J;function _n({prop:e,defaultProp:t,onChange:n=hn(()=>{},`onChange`),caller:r}){let[i,a,o]=vn({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,D.useCallback(t=>{if(s){let n=yn(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}hn(_n,`useControllableState`);function vn({defaultProp:e,onChange:t}){let[n,r]=D.useState(e),i=D.useRef(n),a=D.useRef(t);return gn(()=>{a.current=t},[t]),D.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}hn(vn,`useUncontrolledState`);function yn(e){return typeof e==`function`}hn(yn,`isFunction`);var bn=Symbol(`RADIX:SYNC_STATE`);function xn(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=pn(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=D.useReducer((t,n)=>{if(n.type===bn)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=D.useRef(p);D.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=D.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return D.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:bn,state:i})},[i,d.state,c]),[h,f]}hn(xn,`useControllableStateReducer`);var Sn=Object.defineProperty,Cn=(e,t)=>Sn(e,`name`,{value:t,configurable:!0}),wn=!1;function Tn(){let[e,t]=D.useState(wn);return D.useEffect(()=>{wn||(wn=!0,t(!0))},[]),e}Cn(Tn,`useIsHydrated`);var En=D.useSyncExternalStore;function Dn(){return()=>{}}Cn(Dn,`subscribe`);function On(){return En(Dn,()=>!0,()=>!1)}Cn(On,`useIsHydratedModern`);var kn=typeof En==`function`?On:Tn,An=Object.defineProperty,jn=(e,t)=>An(e,`name`,{value:t,configurable:!0}),Mn=`rovingFocusGroup.onEntryFocus`,Nn={bubbles:!1,cancelable:!0},Pn=`RovingFocusGroup`,[Fn,In,Ln]=De(Pn),[Rn,zn]=L(Pn,[Ln]),[Bn,Vn]=Rn(Pn),Hn=D.forwardRef(jn(function(e,t){return(0,F.jsx)(Fn.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(Fn.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(Un,{...e,ref:t})})})},`RovingFocusGroup`)),Un=D.forwardRef(jn(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=D.useRef(null),p=z(t,f),m=Ve(a),[h,g]=_n({prop:o,defaultProp:s??null,onChange:c,caller:Pn}),[_,v]=D.useState(!1),y=W(l),b=In(n),x=D.useRef(!1),[ee,te]=D.useState(0);return D.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Mn,y),()=>e.removeEventListener(Mn,y)},[y]),(0,F.jsx)(Bn,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:D.useCallback(e=>g(e),[g]),onItemShiftTab:D.useCallback(()=>v(!0),[]),onFocusableItemAdd:D.useCallback(()=>te(e=>e+1),[]),onFocusableItemRemove:D.useCallback(()=>te(e=>e-1),[]),children:(0,F.jsx)(H.div,{tabIndex:_||ee===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:j(e.onMouseDown,()=>{x.current=!0}),onFocus:j(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Mn,Nn);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Yn([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:j(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),Wn=`RovingFocusGroupItem`,Gn=D.forwardRef(jn(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=kt(),l=a||c,u=Vn(Wn,n),d=u.currentTabStopId===l,f=In(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=kn();return J(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),D.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,F.jsx)(Fn.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,F.jsx)(H.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:j(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:j(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:j(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Jn(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Xn(n,r+1):n.slice(r+1)}setTimeout(()=>Yn(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),Kn={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function qn(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}jn(qn,`getDirectionAwareKey`);function Jn(e,t,n){let r=qn(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Kn[r]}jn(Jn,`getFocusIntent`);function Yn(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}jn(Yn,`focusFirst`);function Xn(e,t){return e.map((n,r)=>e[(t+r)%e.length])}jn(Xn,`wrapArray`);var Zn=Hn,Qn=Gn,$n=Object.defineProperty,Z=(e,t)=>$n(e,`name`,{value:t,configurable:!0}),er=[`Enter`,` `],tr=[`ArrowDown`,`PageUp`,`Home`],nr=[`ArrowUp`,`PageDown`,`End`],rr=[...tr,...nr];[...er],[...er];var ir=`Menu`,[ar,or,sr]=De(ir),[cr,lr]=L(ir,[sr,It,zn]),ur=It(),dr=zn(),[fr,pr]=cr(ir),[mr,hr]=cr(ir),gr=Z(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=ur(t),[c,l]=D.useState(null),u=D.useRef(!1),d=W(a),f=Ve(i);return D.useEffect(()=>{let e=Z(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=Z(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),D.useEffect(()=>{if(!n)return;let e=Z(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,F.jsx)(Yt,{...s,children:(0,F.jsx)(fr,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,F.jsx)(mr,{scope:t,onClose:D.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),_r=D.forwardRef(Z(function(e,t){let{__scopeMenu:n,...r}=e,i=ur(n);return(0,F.jsx)(Xt,{...i,...r,ref:t})},`MenuAnchor`)),vr=`MenuPortal`,[yr,br]=cr(vr,{forceMount:void 0}),xr=Z(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=pr(vr,t);return(0,F.jsx)(yr,{scope:t,forceMount:n,children:(0,F.jsx)(nn,{present:n||a.open,children:(0,F.jsx)($t,{asChild:!0,container:i,children:r})})})},`MenuPortal`),Q=`MenuContent`,[Sr,Cr]=cr(Q),wr=D.forwardRef(Z(function(e,t){let n=br(Q,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=pr(Q,e.__scopeMenu),o=hr(Q,e.__scopeMenu);return(0,F.jsx)(ar.Provider,{scope:e.__scopeMenu,children:(0,F.jsx)(nn,{present:r||a.open,children:(0,F.jsx)(ar.Slot,{scope:e.__scopeMenu,children:o.modal?(0,F.jsx)(Tr,{...i,ref:t}):(0,F.jsx)(Er,{...i,ref:t})})})})},`MenuContent`)),Tr=D.forwardRef(Z(function(e,t){let n=pr(Q,e.__scopeMenu),r=D.useRef(null),i=z(t,r);return D.useEffect(()=>{let e=r.current;if(e)return m(e)},[]),(0,F.jsx)(Or,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:j(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Er=D.forwardRef(Z(function(e,t){let n=pr(Q,e.__scopeMenu);return(0,F.jsx)(Or,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Dr=V(`MenuContent.ScrollLock`),Or=D.forwardRef(Z(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,_=pr(Q,n),v=hr(Q,n),y=ur(n),b=dr(n),x=or(n),[ee,te]=D.useState(null),S=D.useRef(null),C=z(t,S,_.onContentChange),w=D.useRef(0),T=D.useRef(``),E=D.useRef(0),O=D.useRef(null),k=D.useRef(`right`),A=D.useRef(0),M=m?g:D.Fragment,N=m?{as:Dr,allowPinchZoom:!0}:void 0,ne=Z(e=>{let t=T.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Gr(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;Z((function e(t){T.current=t,window.clearTimeout(w.current),t!==``&&(w.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);D.useEffect(()=>()=>window.clearTimeout(w.current),[]),ct();let P=D.useCallback(e=>k.current===O.current?.side&&qr(e,O.current?.area),[]);return(0,F.jsx)(Sr,{scope:n,searchRef:T,onItemEnter:D.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:D.useCallback(e=>{P(e)||(S.current?.focus(),te(null))},[P]),onTriggerLeave:D.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:E,onPointerGraceIntentChange:D.useCallback(e=>{O.current=e},[]),children:(0,F.jsx)(M,{...N,children:(0,F.jsx)(mt,{asChild:!0,trapped:i,onMountAutoFocus:j(a,e=>{e.preventDefault(),S.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,F.jsx)(Xe,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,F.jsx)(Zn,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:ee,onCurrentTabStopIdChange:te,onEntryFocus:j(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,F.jsx)(Zt,{role:`menu`,"aria-orientation":`vertical`,"data-state":Br(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...h,ref:C,style:{outline:`none`,...h.style},onKeyDown:j(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ne(e.key));let i=S.current;if(e.target!==i||!rr.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);nr.includes(e.key)&&a.reverse(),Ur(a)}),onBlur:j(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(w.current),T.current=``)}),onPointerMove:j(e.onPointerMove,Jr(e=>{let t=e.target,n=A.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>A.current?`right`:`left`;k.current=t,A.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),kr=`MenuItem`,Ar=`menu.itemSelect`,jr=D.forwardRef(Z(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=D.useRef(null),o=hr(kr,e.__scopeMenu),s=Cr(kr,e.__scopeMenu),c=z(t,a),l=D.useRef(!1),u=Z(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Ar,{bubbles:!0,cancelable:!0});e.addEventListener(Ar,e=>r?.(e),{once:!0}),Te(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,F.jsx)(Mr,{...i,ref:c,disabled:n,onClick:j(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:j(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:j(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||er.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),Mr=D.forwardRef(Z(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Cr(kr,n),s=dr(n),c=D.useRef(null),l=z(t,c),[u,d]=D.useState(!1),[f,p]=D.useState(``);return D.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,F.jsx)(ar.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,F.jsx)(Qn,{asChild:!0,...s,focusable:!r,children:(0,F.jsx)(H.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:j(e.onPointerMove,Jr(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:j(e.onPointerLeave,Jr(e=>o.onItemLeave(e))),onFocus:j(e.onFocus,()=>d(!0)),onBlur:j(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[Nr,Pr]=cr(`MenuRadioGroup`,{value:void 0,onValueChange:Z(()=>{},`onValueChange`)}),[Fr,Ir]=cr(`MenuItemIndicator`,{checked:!1}),Lr=D.forwardRef(Z(function(e,t){let{__scopeMenu:n,...r}=e;return(0,F.jsx)(H.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[Rr,zr]=cr(`MenuSub`);function Br(e){return e?`open`:`closed`}Z(Br,`getOpenState`);function Vr(e){return e===`indeterminate`}Z(Vr,`isIndeterminate`);function Hr(e){return Vr(e)?`indeterminate`:e?`checked`:`unchecked`}Z(Hr,`getCheckedState`);function Ur(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Z(Ur,`focusFirst`);function Wr(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Z(Wr,`wrapArray`);function Gr(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Wr(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}Z(Gr,`getNextMatch`);function Kr(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Z(Kr,`isPointInPolygon`);function qr(e,t){return t?Kr({x:e.clientX,y:e.clientY},t):!1}Z(qr,`isPointerInGraceArea`);function Jr(e){return t=>t.pointerType===`mouse`?e(t):void 0}Z(Jr,`whenMouse`);var Yr=gr,Xr=_r,Zr=xr,Qr=wr,$r=jr,ei=Lr,ti=Object.defineProperty,$=(e,t)=>ti(e,`name`,{value:t,configurable:!0}),ni=`ContextMenu`,[ri,ii]=L(ni,[lr]),ai=lr(),[oi,si]=ri(ni),ci=$(e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,dir:a,modal:o=!0}=e,s=D.useRef(!1),[c,l]=_n({prop:i,defaultProp:!1,onChange:r,caller:ni}),u=ai(t);return(0,F.jsx)(oi,{scope:t,open:c,onOpenChange:l,modal:o,hasInteractedRef:s,children:(0,F.jsx)(Yr,{...u,dir:a,open:c,onOpenChange:l,modal:o,children:n})})},`ContextMenu`),li=`ContextMenuTrigger`,ui=D.forwardRef($(function(e,t){let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=si(li,n),o=ai(n),[s,c]=D.useState({x:0,y:0}),l=D.useMemo(()=>({current:{getBoundingClientRect:$(()=>DOMRect.fromRect({width:0,height:0,...s}),`getBoundingClientRect`)}}),[s]),u=D.useRef(0),d=D.useCallback(()=>window.clearTimeout(u.current),[]),f=$(e=>{a.hasInteractedRef.current=!0,c({x:e.clientX,y:e.clientY}),a.onOpenChange(!0)},`handleOpen`);return D.useEffect(()=>d,[d]),D.useEffect(()=>void(r&&d()),[r,d]),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Xr,{...o,virtualRef:l}),(0,F.jsx)(H.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:j(e.onContextMenu,e=>{d(),f(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:j(e.onPointerDown,gi(e=>{d(),a.open&&a.onOpenChange(!1),u.current=window.setTimeout(()=>f(e),700)})),onPointerMove:r?e.onPointerMove:j(e.onPointerMove,gi(d)),onPointerCancel:r?e.onPointerCancel:j(e.onPointerCancel,gi(d)),onPointerUp:r?e.onPointerUp:j(e.onPointerUp,gi(d))})]})},`ContextMenuTrigger`)),di=$(e=>{let{__scopeContextMenu:t,...n}=e,r=ai(t);return(0,F.jsx)(Zr,{...r,...n})},`ContextMenuPortal`),fi=`ContextMenuContent`,pi=D.forwardRef($(function(e,t){let{__scopeContextMenu:n,...r}=e,i=si(fi,n),a=ai(n),o=D.useRef(!1);return(0,F.jsx)(Qr,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`ContextMenuContent`)),mi=D.forwardRef($(function(e,t){let{__scopeContextMenu:n,...r}=e,i=ai(n);return(0,F.jsx)($r,{...i,...r,ref:t})},`ContextMenuItem`)),hi=D.forwardRef($(function(e,t){let{__scopeContextMenu:n,...r}=e,i=ai(n);return(0,F.jsx)(ei,{...i,...r,ref:t})},`ContextMenuSeparator`));function gi(e){return t=>t.pointerType===`mouse`?void 0:e(t)}$(gi,`whenTouchOrPen`);var _i=ci,vi=ui,yi=di,bi=pi,xi=mi,Si=hi,Ci=_i,wi=vi,Ti=yi,Ei=bi,Di=xi,Oi=Si,ki=[`tree-alpha`,`tree-modified`,`flat-modified`,`flat-issues`,`flat-criticality`],Ai=[`tree-alpha`,`tree-modified`,`flat-modified`],ji=Ai;function Mi(e){return T(e,{seconds:!0,fallback:e})}function Ni(e){if(!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} ${e===1?`byte`:`bytes`}`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n.toFixed(1)} ${t[r]}`}function Pi(e,t){return e.localeCompare(t)}function Fi(e,t){let n=e.mtimeMs,r=t.mtimeMs;return n!==void 0&&r!==void 0&&n!==r?r-n:n!==void 0&&r===void 0?-1:n===void 0&&r!==void 0?1:Pi(e.name,t.name)}function Ii(e,t){let n=e.map(e=>e.children.length>0?{...e,children:Ii(e.children,t)}:e);return n.sort((e,n)=>e.isDirectory===n.isDirectory?e.isDirectory||t===`alpha`?Pi(e.name,n.name):Fi(e,n):e.isDirectory?-1:1),n}var Li={major:10,minor:3,info:1};function Ri(e){let t=new Map;for(let n of e){let e=t.get(n.path);e||(e={path:n.path,total:0,bySeverity:{major:0,minor:0,info:0},score:0},t.set(n.path,e)),e.total+=1,e.bySeverity[n.severity]+=1,e.score+=Li[n.severity]}return[...t.values()]}function zi(e,t){return[...e].sort((e,n)=>{let r=t===`count`?n.total-e.total:n.score-e.score;return r===0?e.path.localeCompare(n.path):r})}function Bi(e){let t=[];for(let n of[`major`,`minor`,`info`]){let r=e[n];r>0&&t.push(`${r} ${n}`)}return t.join(` · `)}function Vi(e,t){return`gezel.projectFilesView:${e}:${t}`}function Hi(e,t){return`gezel.projectFilesHidden:${e}:${t}`}function Ui(e,t){return(t===`workspace`?ki:Ai).includes(e)?e:`tree-alpha`}var Wi=`gezel.documentsFilesView`,Gi=`gezel.documentsFilesHidden`;function Ki(e,t){let n=e.lastIndexOf(`/`);return{name:n>=0?e.slice(n+1):e,path:e,isDirectory:!1,...t===void 0?{}:{mtimeMs:t}}}function qi(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t):``}function Ji(e){let t=[],n=new Map;for(let t of e)n.set(t.path,{name:t.name,path:t.path,isDirectory:t.isDirectory,...t.mtimeMs===void 0?{}:{mtimeMs:t.mtimeMs},children:[]});for(let r of e){let e=n.get(r.path);if(!e)continue;let i=r.path.includes(`/`)?r.path.slice(0,r.path.lastIndexOf(`/`)):``,a=i?n.get(i):void 0;a?a.children.push(e):t.push(e)}return t}function Yi(e){return e.isDirectory?(0,F.jsx)(`i`,{className:`tree-icon tree-icon-folder fa-regular fa-folder fa-fw`,"aria-hidden":`true`}):(0,F.jsx)(E,{name:e.name,className:`tree-icon`})}function Xi(e){return e.name}function Zi({entries:e,selectedPath:t,onSelect:n,onIntent:r,onRename:i,onDelete:a,onMove:o,actionsForEntry:s,trailingForEntry:c,defaultExpandedDepth:l=2,iconFor:u=Yi,labelFor:d=Xi,selectableFolders:f=!1,sortMode:p=`none`}){let[m,h]=(0,D.useState)(null),[g,_]=(0,D.useState)(null);return(0,F.jsx)(F.Fragment,{children:(0,D.useMemo)(()=>p===`none`?Ji(e):Ii(Ji(e),p),[e,p]).map(e=>(0,F.jsx)($i,{node:e,depth:0,selectedPath:t,onSelect:n,onIntent:r,onRename:i,onDelete:a,onMove:o,actionsForEntry:s,trailingForEntry:c,defaultExpandedDepth:l,iconFor:u,labelFor:d,selectableFolders:f,draggedEntry:m,dropTargetPath:g,onDragStart:(e,t)=>{h(e),_(null),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`application/x-gezel-file-path`,e.path),t.dataTransfer.setData(`text/plain`,e.path)},onDragEnd:()=>{h(null),_(null)},onDropTargetChange:_},e.path))})}function Qi(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function $i({node:e,depth:t,selectedPath:n,onSelect:r,onIntent:i,onRename:a,onDelete:o,onMove:s,actionsForEntry:c,trailingForEntry:l,defaultExpandedDepth:u,iconFor:d,labelFor:f,selectableFolders:p,draggedEntry:m,dropTargetPath:h,onDragStart:g,onDragEnd:_,onDropTargetChange:v}){let[y,b]=(0,D.useState)(t<u),T={name:e.name,path:e.path,isDirectory:e.isDirectory,...e.mtimeMs===void 0?{}:{mtimeMs:e.mtimeMs}},E=f(T),O=c?.(T)??[],k=l?.(T),A=!!(a||o||O.length>0),j=e.isDirectory&&e.children.length>0,M=!!(s&&!T.isDirectory),N=!!(s&&T.isDirectory&&m&&m.path!==T.path&&Qi(m.path)!==T.path),ne=m?.path===T.path,P=N&&h===T.path,re=(0,F.jsxs)(`div`,{className:`tree-row${n===e.path?` tree-row-selected`:``}${M?` tree-row-draggable`:``}${ne?` tree-row-dragging`:``}${P?` tree-row-drop-target`:``}`,style:{paddingLeft:`${t*12+2}px`},draggable:M,onPointerEnter:()=>i?.(T),onFocus:()=>i?.(T),onPointerDown:()=>i?.(T),onDragStart:e=>{M&&g(T,e)},onDragEnd:_,onDragEnter:e=>{N&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`move`,v(T.path))},onDragOver:e=>{N&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`move`,h!==T.path&&v(T.path))},onDragLeave:e=>{if(!P)return;let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||v(null)},onDrop:e=>{if(!N||!m||!s)return;e.preventDefault(),e.stopPropagation();let t=m;v(null),b(!0),_(),s(t,T)},children:[j?(0,F.jsx)(`button`,{type:`button`,className:`tree-toggle`,onClick:()=>b(!y),"aria-expanded":y,"aria-label":y?`Collapse ${E}`:`Expand ${E}`,children:(0,F.jsx)(`span`,{className:`tree-toggle-caret${y?` expanded`:``}`,"aria-hidden":`true`,children:(0,F.jsx)(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2.2,strokeLinecap:`round`,strokeLinejoin:`round`,focusable:`false`,"aria-hidden":`true`,children:(0,F.jsx)(`polyline`,{points:`9 6 15 12 9 18`})})})}):(0,F.jsx)(`span`,{className:`tree-toggle-spacer`}),(0,F.jsxs)(`button`,{type:`button`,className:`tree-label`,onClick:()=>{!e.isDirectory||p?r(T):b(!y)},children:[d(T),E]}),k&&(0,F.jsx)(`span`,{className:`tree-row-trailing`,children:k}),A&&(0,F.jsxs)(w,{children:[(0,F.jsx)(ee,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,className:`tree-actions-trigger`,"aria-label":`Actions for ${E}`,title:`Actions for ${E}`,children:(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`⋯`})})}),(0,F.jsx)(S,{children:(0,F.jsxs)(te,{className:`app-nav-menu tree-actions-menu`,sideOffset:4,align:`end`,children:[a&&(0,F.jsx)(C,{className:`app-nav-menu-item`,onSelect:()=>a(T),children:`Rename…`}),o&&(0,F.jsx)(C,{className:`app-nav-menu-item danger`,onSelect:()=>o(T),children:`Delete…`}),O.length>0&&(a||o)&&(0,F.jsx)(x,{className:`app-nav-menu-separator`}),O.map(e=>(0,F.jsx)(C,{className:`app-nav-menu-item`,disabled:e.disabled,onSelect:()=>void e.onSelect(T),children:e.label},e.label))]})})]})]});return(0,F.jsxs)(`div`,{children:[A?(0,F.jsxs)(Ci,{children:[(0,F.jsx)(wi,{asChild:!0,children:re}),(0,F.jsx)(Ti,{children:(0,F.jsxs)(Ei,{className:`app-nav-menu tree-actions-menu`,children:[a&&(0,F.jsx)(Di,{className:`app-nav-menu-item`,onSelect:()=>a(T),children:`Rename…`}),o&&(0,F.jsx)(Di,{className:`app-nav-menu-item danger`,onSelect:()=>o(T),children:`Delete…`}),O.length>0&&(a||o)&&(0,F.jsx)(Oi,{className:`app-nav-menu-separator`}),O.map(e=>(0,F.jsx)(Di,{className:`app-nav-menu-item`,disabled:e.disabled,onSelect:()=>void e.onSelect(T),children:e.label},e.label))]})})]}):re,j&&y&&(0,F.jsx)(`div`,{children:e.children.map(e=>(0,F.jsx)($i,{node:e,depth:t+1,selectedPath:n,onSelect:r,onIntent:i,onRename:a,onDelete:o,onMove:s,actionsForEntry:c,trailingForEntry:l,defaultExpandedDepth:u,iconFor:d,labelFor:f,selectableFolders:p,draggedEntry:m,dropTargetPath:h,onDragStart:g,onDragEnd:_,onDropTargetChange:v},e.path))})]})}function ea(e,t){return!t||!e.toLowerCase().endsWith(t.toLowerCase())?e:e.slice(0,-t.length)}function ta(e,t){let n=e?.replace(/[\\/]+$/,``);return n?`${n}/${t}`:t}function na({open:e,title:t,placeholder:n,submitLabel:r,onSubmit:i,onCancel:a,initialValue:o=``,suffix:u,parentPath:d,fieldLabel:f=`Path`,error:m}){let[g,_]=(0,D.useState)(()=>ea(o,u));(0,D.useEffect)(()=>{e&&_(ea(o,u))},[e,o,u]);let v=d!==void 0&&/[\\/]/.test(g)?`Enter a file name without folders.`:null,b=m??v;return(0,F.jsx)(c,{open:e,onOpenChange:e=>{e||a()},children:(0,F.jsxs)(y,{children:[(0,F.jsx)(l,{}),(0,F.jsx)(p,{children:(0,F.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),!(!g.trim()||v)&&i(ta(d,`${ea(g.trim(),u)}${u??``}`))},style:{display:`contents`},children:[(0,F.jsx)(h,{asChild:!0,children:(0,F.jsx)(`h3`,{children:t})}),(0,F.jsxs)(`label`,{children:[f,(0,F.jsxs)(`span`,{className:u?`new-path-input-row`:void 0,children:[(0,F.jsx)(`input`,{value:g,onChange:e=>_(ea(e.target.value,u)),placeholder:n}),u&&(0,F.jsx)(`span`,{className:`new-path-input-suffix`,"aria-hidden":`true`,children:u})]})]}),b&&(0,F.jsx)(`p`,{className:`gz-dialog-error`,role:`alert`,children:b}),(0,F.jsxs)(s,{children:[(0,F.jsx)(`button`,{type:`button`,onClick:a,children:`Cancel`}),(0,F.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!g.trim()||v!==null,children:r})]})]})})]})})}export{Ci as C,Ti as S,Mi as _,Gi as a,Ei as b,ki as c,Fi as d,Bi as f,Ni as g,Vi as h,Ai as i,Ri as l,Hi as m,Zi as n,Wi as o,Ki as p,Yi as r,ji as s,na as t,Ui as u,qi as v,wi as w,Di as x,zi as y};
|