libre-webui 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/backend/dist/services/agentCliService.d.ts.map +1 -1
- package/backend/dist/services/agentCliService.js +1 -0
- package/backend/dist/services/agentCliService.js.map +1 -1
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +12 -9
- package/backend/dist/services/pluginService.js.map +1 -1
- package/backend/dist/services/workAgentHostLogins.d.ts.map +1 -1
- package/backend/dist/services/workAgentHostLogins.js +4 -0
- package/backend/dist/services/workAgentHostLogins.js.map +1 -1
- package/backend/dist/services/workModelProviderService.d.ts.map +1 -1
- package/backend/dist/services/workModelProviderService.js +13 -1
- package/backend/dist/services/workModelProviderService.js.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.d.ts +15 -1
- package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.js +53 -5
- package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.d.ts.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.js +5 -3
- package/backend/dist/utils/pluginDefinitionTrust.js.map +1 -1
- package/backend/dist/utils/pluginModelCatalog.d.ts +10 -0
- package/backend/dist/utils/pluginModelCatalog.d.ts.map +1 -1
- package/backend/dist/utils/pluginModelCatalog.js +24 -0
- package/backend/dist/utils/pluginModelCatalog.js.map +1 -1
- package/backend/package.json +2 -2
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/artifact-runtime/babel.js +179 -173
- package/frontend/dist/artifact-runtime/chart.js +1 -1
- package/frontend/dist/artifact-runtime/d3.js +4 -4
- package/frontend/dist/artifact-runtime/framer-motion.js +2 -10
- package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
- package/frontend/dist/artifact-runtime/mathjs.js +1 -1
- package/frontend/dist/artifact-runtime/mermaid.js +368 -368
- package/frontend/dist/artifact-runtime/plotly.js +59 -59
- package/frontend/dist/artifact-runtime/recharts.js +45 -45
- package/frontend/dist/artifact-runtime/tailwind.js +18 -18
- package/frontend/dist/artifact-runtime/three.js +419 -397
- package/frontend/dist/artifact-runtime/tone.js +1 -1
- package/frontend/dist/assets/index-BM0txgxR.css +2 -0
- package/frontend/dist/assets/index-CekTqSoE.js +67 -0
- package/frontend/dist/assets/{markdown-math-Ngnvt50Q.css → markdown-math-Bv5fr4tV.css} +1 -1
- package/frontend/dist/index.html +30 -30
- package/frontend/dist/js/{ArtifactContainer-C0R4kYVM.js → ArtifactContainer-C7EEweSP.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-BQmbCyat.js → ArtifactDemoPage-B3yjn6Dw.js} +2 -2
- package/frontend/dist/js/{ArtifactSandboxFrame-CkDkrHpg.js → ArtifactSandboxFrame-DGC1hgTq.js} +6 -6
- package/frontend/dist/js/ArtifactSlideOutPanel-xamxqotB.js +1 -0
- package/frontend/dist/js/{AutomationModal-Cx1e_4df.js → AutomationModal-Dj0E2mSl.js} +1 -1
- package/frontend/dist/js/AutomationsPage-MTqU8Ap9.js +1 -0
- package/frontend/dist/js/{AvatarUpload-DGRQC20B.js → AvatarUpload-CrNLFoIi.js} +1 -1
- package/frontend/dist/js/{Button-DwZ26Lqc.js → Button-BGE6ZJv5.js} +1 -1
- package/frontend/dist/js/CalendarPage-BciFDr0S.js +1 -0
- package/frontend/dist/js/ChannelsPage-De96Q63V.js +1 -0
- package/frontend/dist/js/ChatPage-CTRKLQly.js +14 -0
- package/frontend/dist/js/ConnectModels-BPwpeVsJ.js +1 -0
- package/frontend/dist/js/EvaluationsPage-CT7EAYaj.js +2 -0
- package/frontend/dist/js/FirstTimeSetup-BXkaFkvk.js +1 -0
- package/frontend/dist/js/GalleryPage-BPUY12kj.js +1 -0
- package/frontend/dist/js/HomePage-16KFuUir.js +1 -0
- package/frontend/dist/js/{LanguageSwitcher-CASJ8p5d.js → LanguageSwitcher-MlITAZf6.js} +1 -1
- package/frontend/dist/js/{Logo-C-qwuy58.js → Logo-GlNrhpKp.js} +1 -1
- package/frontend/dist/js/{LogoMark-zP-mitdI.js → LogoMark-rgOHhWo-.js} +1 -1
- package/frontend/dist/js/{ModelManagerModals-BYhFWv22.js → ModelManagerModals-inYMmqa4.js} +1 -1
- package/frontend/dist/js/NotesPage-kYFIBBCu.js +3 -0
- package/frontend/dist/js/{PasswordStrengthMeter-Dow8ZeTs.js → PasswordStrengthMeter-ppDWQU9P.js} +1 -1
- package/frontend/dist/js/PersonasPage-mzAft_NC.js +13 -0
- package/frontend/dist/js/PluginUsagePage-DQvsXxpI.js +1 -0
- package/frontend/dist/js/{RichMessageContent-DJTLGpws.js → RichMessageContent-BW9UvzYw.js} +1 -1
- package/frontend/dist/js/{RichMessageContent-Bwpg3rfV.js → RichMessageContent-BraVuu1Q.js} +3 -3
- package/frontend/dist/js/SettingsModal-B-5JP50i.js +19 -0
- package/frontend/dist/js/SettingsToggle-BT6cbOnw.js +1 -0
- package/frontend/dist/js/{ShareDialog-DYwyeyaI.js → ShareDialog-CmgHPnKg.js} +1 -1
- package/frontend/dist/js/StrandsPage-Dg55juWQ.js +1 -0
- package/frontend/dist/js/{SystemPage-B4qFsAsb.js → SystemPage-PZhbWJCh.js} +1 -1
- package/frontend/dist/js/{TurnstileWidget-xx9lQV0b.js → TurnstileWidget-B_dl1YjT.js} +1 -1
- package/frontend/dist/js/{UserManagementPage-DhMRuhqj.js → UserManagementPage-BrogyZDQ.js} +1 -1
- package/frontend/dist/js/UserManagementPanel-DBwIOSOw.js +1 -0
- package/frontend/dist/js/{WhatsNewModal-DfR7W93-.js → WhatsNewModal-DunfwUe9.js} +1 -1
- package/frontend/dist/js/WorkPage-DQlsa18h.js +7 -0
- package/frontend/dist/js/api-DG2AKSTU.js +16 -0
- package/frontend/dist/js/api-DdDgFM-F.js +1 -0
- package/frontend/dist/js/{appNavigation-BifMRN3D.js → appNavigation-DXonlffV.js} +1 -1
- package/frontend/dist/js/{appStore-B6pAGo3p.js → appStore-DMmgXb-0.js} +2 -2
- package/frontend/dist/js/appVersion-Bl_QXi35.js +1 -0
- package/frontend/dist/js/authStore-ByVF8A2u.js +1 -0
- package/frontend/dist/js/{authStore-DdIb6km_.js → authStore-C89vePrB.js} +3 -3
- package/frontend/dist/js/chatStore-BooPA4cg.js +3 -0
- package/frontend/dist/js/{client-D_F_0LqX.js → client-D05vqJPO.js} +2 -2
- package/frontend/dist/js/{config-CHUQTU6j.js → config-DCQ2-rvE.js} +1 -1
- package/frontend/dist/js/{evaluationsApi-C0FKNJua.js → evaluationsApi-oCNxDBZ4.js} +1 -1
- package/frontend/dist/js/logger-DAQsBb8I.js +1 -0
- package/frontend/dist/js/markdown-html-DRL6swKb.js +2 -0
- package/frontend/dist/js/{markdown-math-BzLEmswF.js → markdown-math-CCWDDhWR.js} +3 -3
- package/frontend/dist/js/{markdownHtml-B1Ll_Qgp.js → markdownHtml-DpKMtcCu.js} +1 -1
- package/frontend/dist/js/markdownMath-CKB9Q-yN.js +1 -0
- package/frontend/dist/js/{messageCodeStyles-DVYyK8wm.js → messageCodeStyles-tSFFCV6k.js} +1 -1
- package/frontend/dist/js/rfb-xHgMEWMb.js +5 -0
- package/frontend/dist/js/router-vendor-DLHZHk4K.js +1 -0
- package/frontend/dist/js/{strandsApi-CeJLezXW.js → strandsApi-Fs6zV4CA.js} +1 -1
- package/frontend/dist/js/{teamEventStream-DOMyufrH.js → teamEventStream-DD_ASSs5.js} +1 -1
- package/frontend/dist/js/ui-DATtlADq.js +2 -0
- package/frontend/dist/js/ui-vendor-WdvBNwsu.js +1 -0
- package/frontend/dist/js/useChat-RXTiCFz0.js +13 -0
- package/frontend/dist/js/useDictation-YyALwnw6.js +1 -0
- package/frontend/dist/js/useQuery-DCqz3UJt.js +1 -0
- package/frontend/dist/js/{useTranslation-D9EScZXH.js → useTranslation-D-_KTORQ.js} +1 -1
- package/frontend/dist/js/utils-DsCVr_wG.js +1 -0
- package/frontend/dist/js/workApi-CbFQfwRZ.js +5 -0
- package/frontend/dist/js/workApi-CmH9c1xh.js +1 -0
- package/package.json +3 -3
- package/plugins/baseten.json +68 -0
- package/plugins/codex-oauth.json +1 -0
- package/plugins/modal.json +82 -0
- package/plugins/openai.json +2 -1
- package/plugins/openrouter.json +1 -0
- package/frontend/dist/assets/index-BnbO3eTY.js +0 -83
- package/frontend/dist/assets/index-CYKYBgsy.css +0 -2
- package/frontend/dist/js/ArtifactSlideOutPanel-DZnVzC0c.js +0 -1
- package/frontend/dist/js/AutomationsPage-D7UtYZ_0.js +0 -1
- package/frontend/dist/js/CalendarPage-WmA1i7MQ.js +0 -1
- package/frontend/dist/js/ChannelsPage-Bq4JQPR_.js +0 -1
- package/frontend/dist/js/ChatPage-Cd3fxx-N.js +0 -14
- package/frontend/dist/js/ConnectModels-BYul-veF.js +0 -1
- package/frontend/dist/js/EvaluationsPage-CV_Terzn.js +0 -2
- package/frontend/dist/js/FirstTimeSetup-CFhGy9a8.js +0 -1
- package/frontend/dist/js/GalleryPage-BRKZyq1w.js +0 -1
- package/frontend/dist/js/HomePage-DdpnBu-Z.js +0 -1
- package/frontend/dist/js/NotesPage-CmvVoWcH.js +0 -3
- package/frontend/dist/js/PersonasPage-BYKtoKWl.js +0 -13
- package/frontend/dist/js/PluginUsagePage-BVTOCxoE.js +0 -1
- package/frontend/dist/js/SettingsModal-CGyVfxOz.js +0 -19
- package/frontend/dist/js/SettingsToggle-BpD6NSri.js +0 -1
- package/frontend/dist/js/StrandsPage-CvXeYOYR.js +0 -1
- package/frontend/dist/js/UserManagementPanel-BVLSvRwa.js +0 -1
- package/frontend/dist/js/WorkPage-DSKBQEW0.js +0 -7
- package/frontend/dist/js/api-C5ps_CWQ.js +0 -1
- package/frontend/dist/js/api-D6IF0v9_.js +0 -16
- package/frontend/dist/js/appVersion-9UMn7b1T.js +0 -1
- package/frontend/dist/js/authStore-CDo5Co2D.js +0 -1
- package/frontend/dist/js/chatStore-hzQyRM9H.js +0 -3
- package/frontend/dist/js/logger-rEW7uQ8m.js +0 -1
- package/frontend/dist/js/markdown-html-BdYVneHE.js +0 -2
- package/frontend/dist/js/markdownMath-aI8uDQmz.js +0 -1
- package/frontend/dist/js/rfb-IV07oQgM.js +0 -5
- package/frontend/dist/js/router-vendor-qltZAWoz.js +0 -1
- package/frontend/dist/js/ui-D4Ytvr6d.js +0 -2
- package/frontend/dist/js/ui-vendor-BTcw5yZ6.js +0 -1
- package/frontend/dist/js/useChat-BEbNywiP.js +0 -13
- package/frontend/dist/js/useDictation-jTaorrHm.js +0 -1
- package/frontend/dist/js/useQuery-2_pQiHbl.js +0 -1
- package/frontend/dist/js/utils-BvvV-Cka.js +0 -1
- package/frontend/dist/js/workApi-CGvfDTRY.js +0 -1
- package/frontend/dist/js/workApi-_0oxRyak.js +0 -5
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,r as n,t as r}from"./react-vendor-C1iE8mnY.js";import{t as i}from"./useQuery-2_pQiHbl.js";import{d as a}from"./router-vendor-qltZAWoz.js";import{t as o}from"./utils-BvvV-Cka.js";import{t as s}from"./useTranslation-D9EScZXH.js";import{h as c,s as l,t as u}from"./chatStore-hzQyRM9H.js";import{t as d}from"./logger-rEW7uQ8m.js";import{$n as f,$t as p,An as m,Dn as h,G as g,Jt as _,Lt as v,M as ee,Mn as te,Or as y,Q as b,S as x,Zn as S,Zt as ne,c as C,dr as w,n as T,sr as E,t as D,tr as O,tt as re,zn as ie}from"./ui-vendor-BTcw5yZ6.js";import{t as ae}from"./Button-DwZ26Lqc.js";import"./ui-D4Ytvr6d.js";import{S as oe,g as se,t as k,y as A}from"./api-D6IF0v9_.js";import{t as ce}from"./authStore-DdIb6km_.js";import{i as j,n as M,r as N,t as P}from"./thinking-DwlkTfPX.js";var F=e(t(),1),le=n(),ue=` · `,de=`strands:plugin:`,fe=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});function pe(e){return e.agentId||e.name.split(`:`)[0]||e.name}function me(e){return/embed/i.test(e.name)?!0:[e.details?.family,...e.details?.families??[]].filter(e=>!!e).some(e=>/bert$/i.test(e))}function I(e){return!!(e.isAgent&&e.agentId&&e.name===e.agentId)}function L(e,t){let n=e.find(I);if(n?.agentName)return n.agentName;for(let t of e){let e=t.agentName??``,n=e.indexOf(ue);if(n>0)return e.slice(0,n)}return t}function he(e,t){let n=e.agentName||e.name;if(I(e))return{title:n,isDefault:!0};let r=`${t}${ue}`,i=n.startsWith(r)?n.slice(r.length):n,a;if(e.name.startsWith(de)){let e=/^(.*\S)\s+\(([^()]+)\)$/.exec(i);e&&(i=e[1],a=e[2])}return{title:i,...a?{provider:a}:{},isDefault:!1}}function ge(e,t){return[...e].sort((e,n)=>{let r=I(e);return r===I(n)?fe.compare(t(e),t(n)):r?-1:1})}function _e(e,t){let n=[],r=[],i=[],a=[],o=new Map,s=new Map;for(let t of e)if(t.isLegacySelection)n.push(t);else if(t.isUnavailable)r.push(t);else if(t.isPersona)i.push(t);else if(t.isAgent){let e=pe(t);s.set(e,[...s.get(e)??[],t])}else if(t.isPlugin){let e=t.pluginId||t.pluginName||``;o.set(e,[...o.get(e)??[],t])}else c(t)&&!me(t)&&a.push(t);let l=[{key:`legacy`,kind:`legacy`,label:t.legacy,models:n},{key:`unavailable`,kind:`unavailable`,label:t.unavailable,models:r},{key:`personas`,kind:`personas`,label:t.personas,models:i},{key:`ollama`,kind:`ollama`,label:t.ollama,models:a}];for(let[e,n]of o)l.push({key:`plugin:${e}`,kind:`plugin`,label:n[0]?.pluginName||e||t.plugins,models:ge(n,e=>e.name)});for(let[e,n]of s){let r=L(n,e||t.agents);l.push({key:`agent:${e}`,kind:`agent`,label:r,models:ge(n,e=>he(e,r).title)})}return l.filter(e=>e.models.length>0)}function R(e){return e.toLowerCase().replace(/[\s\-_./:·()[\],]+/g,` `).trim()}function ve(e,t,n,r=``){let i=R(n).split(` `).filter(Boolean);if(i.length===0)return!0;let a=R([e.name,r,e.personaName,e.pluginName,e.agentName,t.label].filter(Boolean).join(` `)),o=a.replace(/ /g,``);return i.every(e=>a.includes(e)||o.includes(e))}function ye(e){let t=-1;for(let n of e.matchAll(/(?<![\d.])(\d{1,2})(?:[.-](\d{1,2}))?(?!\d|\.\d|b\b)/gi)){let e=Number(n[1])*100+Number(n[2]??0);e>t&&(t=e)}return t}function be(e,t,n={}){if(e.length<=8)return{visible:e,hidden:0};let r;if(n.newestFirst){let t=e.filter(I),n=e.filter(e=>!I(e)).map((e,t)=>({model:e,index:t,rank:ye(e.name)})).sort((e,t)=>t.rank-e.rank||e.index-t.index).map(e=>e.model);r=[...t,...n].slice(0,5)}else r=e.slice(0,5);if(!r.some(t)){let n=e.find(t);n&&(r[r.length-1]=n)}let i=new Set(r),a=e.filter(e=>i.has(e));return{visible:a,hidden:e.length-a.length}}var xe={ai:`AI`,api:`API`,awq:`AWQ`,bf16:`BF16`,chatgpt:`ChatGPT`,deepseek:`DeepSeek`,fp16:`FP16`,fp8:`FP8`,glm:`GLM`,gpt:`GPT`,gptq:`GPTQ`,hd:`HD`,lfm:`LFM`,llm:`LLM`,minimax:`MiniMax`,mlx:`MLX`,ml:`ML`,moe:`MoE`,openai:`OpenAI`,oss:`OSS`,qwq:`QwQ`,tts:`TTS`,vl:`VL`,xl:`XL`},Se={"meta-llama":`Meta`,"x-ai":`xAI`,"z-ai":`Z.ai`,amazon:`Amazon`,anthropic:`Anthropic`,cohere:`Cohere`,deepseek:`DeepSeek`,google:`Google`,liquid:`Liquid AI`,meta:`Meta`,microsoft:`Microsoft`,minimax:`MiniMax`,mistralai:`Mistral`,moonshotai:`Moonshot AI`,nvidia:`NVIDIA`,openai:`OpenAI`,perplexity:`Perplexity`,qwen:`Qwen`},z=/^(?:hf\.co|huggingface\.co)\//i,B=new Set([`gguf`]);function V(e){let t=e.toLowerCase();return xe[t]?xe[t]:e!==t||/^o\d/.test(e)?e:/^\d+(?:\.\d+)?[bkmt]$/.test(e)||/^[a-z]\d+(?:\.\d+)?[a-z]?$/.test(e)?e.toUpperCase():/^\d/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1)}function H(e){let t=e.split(/[-_\s]+/).filter(Boolean),n=t.length>1?t.filter(e=>!B.has(e.toLowerCase())):t,r=[];for(let e of n){let t=r[r.length-1];t&&/^\d{1,2}$/.test(e)&&/^\d{1,2}$/.test(t)&&r.length>1&&!/^\d/.test(r[r.length-2])?r[r.length-1]=`${t}.${e}`:r.push(V(e))}return r.join(` `)||e}function Ce(e){let t=e.toLowerCase();return Se[t]?Se[t]:e===t?H(e):e}function we(e,t={}){let n=e.trim(),r=n.startsWith(`~`),i=(r?n.slice(1):n).replace(z,``).split(`/`).filter(Boolean);if(!(t.prettify??i.length>1)||i.length===0)return{name:n};let a=i[i.length-1],o,s=a.lastIndexOf(`:`);s>0&&(o=a.slice(s+1)||void 0,a=a.slice(0,s)),r&&/[-_]latest$/i.test(a)&&(a=a.replace(/[-_]latest$/i,``),o??=`latest`),o===`latest`&&!r&&(o=void 0);let c=i.length>1?Ce(i[i.length-2]):void 0;return{name:H(a),...c?{vendor:c}:{},...o?{tag:o}:{}}}function Te(e){if(!Number.isFinite(e)||e<=0)return``;if(e>=1e6){let t=e%1048576==0?e/1048576:e/1e6;return`${Number(t.toFixed(1))}M`}if(e>=1e3){let t=e%1024==0?e/1024:e/1e3;return`${Math.round(t)}K`}return String(e)}function Ee(e){if(!Number.isFinite(e)||e<=0)return``;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1e3&&r<t.length-1;)n/=1e3,r+=1;return`${n>=10||r===0?Math.round(n):n.toFixed(1)} ${t[r]}`}var U=r(),De=[`bg-amber-500/15 text-amber-700 dark:text-amber-300`,`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,`bg-sky-500/15 text-sky-700 dark:text-sky-300`,`bg-violet-500/15 text-violet-700 dark:text-violet-300`,`bg-rose-500/15 text-rose-700 dark:text-rose-300`,`bg-indigo-500/15 text-indigo-700 dark:text-indigo-300`,`bg-teal-500/15 text-teal-700 dark:text-teal-300`,`bg-orange-500/15 text-orange-700 dark:text-orange-300`];function Oe(e){let t=0;for(let n of e.toLowerCase())t=t*31+n.charCodeAt(0)>>>0;return De[t%De.length]}function ke({seed:e,size:t=`sm`,className:n}){let r=(/[\p{L}\p{N}]/u.exec(e)?.[0]??`?`).toUpperCase();return(0,U.jsx)(`span`,{"aria-hidden":`true`,className:o(`inline-flex shrink-0 select-none items-center justify-center font-semibold leading-none`,t===`md`?`h-6 w-6 rounded-md text-[11px]`:`h-4 w-4 rounded-sm text-[9px]`,Oe(e),n),children:r})}function W(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Ae({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:a,hfGgufFiles:c,loadingGguf:l,pullingModel:u,pullProgress:d,setHfTask:p,setHfSort:g,onToggleHfModel:_,onPullHfGguf:ee,onCancelPull:te,onRefreshHfModels:y}){let{t:x}=s();return(0,U.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 shrink-0 space-y-2`,children:(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsxs)(`select`,{value:e,onChange:e=>p(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`flex-1 px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,U.jsx)(`option`,{value:`text-generation`,children:x(`modelManager.huggingface.taskTextGeneration`)}),(0,U.jsx)(`option`,{value:`text-to-speech`,children:x(`modelManager.huggingface.taskTextToSpeech`)}),(0,U.jsx)(`option`,{value:`text-to-image`,children:x(`modelManager.huggingface.taskTextToImage`)}),(0,U.jsx)(`option`,{value:`automatic-speech-recognition`,children:x(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,U.jsxs)(`select`,{value:t,onChange:e=>g(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,U.jsx)(`option`,{value:`downloads`,children:x(`modelManager.huggingface.sortDownloads`)}),(0,U.jsx)(`option`,{value:`likes`,children:x(`modelManager.huggingface.sortLikes`)}),(0,U.jsx)(`option`,{value:`lastModified`,children:x(`modelManager.huggingface.sortRecent`)})]})]})}),(0,U.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,U.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:x(`modelSelector.pullRestricted`)}),r?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,U.jsx)(v,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,U.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,U.jsx)(D,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,U.jsx)(`p`,{className:`text-sm`,children:x(`modelManager.huggingface.noModelsFound`)})]}):(0,U.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=a===e.id,r=c[e.id]||[],i=l===e.id;return(0,U.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,U.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),_(e.id)},children:(0,U.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,U.jsx)(`div`,{className:`shrink-0 rounded-lg bg-yellow-500/20 p-2 dark:bg-yellow-900/30`,children:(0,U.jsx)(D,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,U.jsx)(`span`,{className:`rounded-sm bg-yellow-500/20 px-1.5 py-0.5 text-xs text-ink dark:bg-yellow-900/30`,children:`Gated`})]}),(0,U.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(m,{className:`h-3 w-3`}),W(e.downloads)]}),(0,U.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(ne,{className:`h-3 w-3`}),W(e.likes)]}),e.pipeline_tag&&(0,U.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-sm bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,U.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,U.jsx)(h,{className:`h-4 w-4 text-gray-400`})}),(0,U.jsx)(f,{className:o(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,U.jsx)(`div`,{className:`px-3 pb-3 pt-1 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-200`,children:i?(0,U.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,U.jsx)(v,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,U.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:x(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,U.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:x(`modelManager.huggingface.noGgufAvailable`)}):(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:x(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=u===e.ollamaCommand;return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300`,children:[(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,U.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,U.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-sm bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:d?.percent===void 0?`...`:`${d.percent}%`}),(0,U.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),te()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,U.jsx)(T,{className:`h-4 w-4`})})]}):n?(0,U.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),ee(e.ollamaCommand,e.filename)},disabled:!!u,className:o(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,U.jsx)(m,{className:`h-3 w-3 inline mr-1`}),x(`models.pull`)]}):(0,U.jsx)(`span`,{className:`rounded-sm bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:x(`modelSelector.adminOnlyPull`)})]},e.filename)}),u?.startsWith(`hf.co/`)&&u.includes(e.id)&&d?.percent!==void 0&&(0,U.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,U.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${d.percent}%`}})})]})})]},e.id)})})]}),(0,U.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between shrink-0`,children:[(0,U.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,U.jsx)(h,{className:`h-3 w-3`}),x(`modelManager.huggingface.browseAllLink`)]}),(0,U.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),y()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,U.jsx)(b,{className:o(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var je=`[data-testid="model-selector-option"], [data-testid="model-selector-show-all"]`;function Me(e,t){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let n=Array.from(e.currentTarget.querySelectorAll(je)),r=n.indexOf(document.activeElement);if(r===-1)return;e.preventDefault();let i=r+(e.key===`ArrowDown`?1:-1);i<0?t():n[Math.min(i,n.length-1)]?.focus()}function Ne({groups:e,selectedModel:t,showImageGen:n,getModelValue:r,getModelIcon:i,getModelLabel:a,getModelTag:c,getModelSubLabel:l,onModelSelect:u,onShowAll:d,onOpenGallery:f,onExitTop:p}){let{t:m}=s();return(0,U.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400`,onKeyDown:e=>Me(e,p),children:[e.length>0?e.map(e=>(0,U.jsxs)(`div`,{"data-testid":`model-selector-group`,children:[e.showHeader&&(0,U.jsxs)(`div`,{className:`sticky top-0 z-1 flex items-center gap-2 border-b border-gray-200 bg-gray-100 px-3 py-2 text-xs font-semibold text-gray-500 dark:border-dark-400 dark:bg-dark-300 dark:text-gray-400`,children:[e.icon,(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:e.label}),(0,U.jsx)(`span`,{className:`font-normal tabular-nums text-gray-400 dark:text-dark-500`,children:e.total})]}),e.models.map(n=>{let s=r(n),d=l(n,e),f=c(n,e);return(0,U.jsx)(`button`,{type:`button`,"data-testid":`model-selector-option`,"data-model-value":s,"aria-pressed":t===s,title:n.isPersona?void 0:n.name,onClick:()=>u(s),className:o(`block w-full cursor-pointer border-b border-gray-100 px-3 py-2 text-start last:border-b-0 dark:border-dark-200`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`bg-white dark:bg-dark-100 transition-colors`,`focus-visible:relative focus-visible:z-10 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/50`,t===s&&`bg-primary-50 dark:bg-primary-900/30`),children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i(n),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`span`,{dir:n.isPersona?`auto`:`ltr`,className:`min-w-0 truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:a(n,e)}),f&&(0,U.jsx)(`span`,{dir:`ltr`,className:`shrink-0 rounded-sm border border-black/8 px-1 py-px font-mono text-[10px] leading-4 text-gray-500 dark:border-white/10 dark:text-dark-600`,children:f})]}),d&&(0,U.jsx)(`div`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:d})]}),t===s&&(0,U.jsx)(O,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 shrink-0`})]})},s)}),e.hidden>0&&(0,U.jsxs)(`button`,{type:`button`,"data-testid":`model-selector-show-all`,onClick:()=>d(e.key),className:o(`flex w-full items-center justify-between gap-2 border-b border-gray-100 bg-white px-3 py-2 text-start text-xs font-medium text-primary-600 dark:border-dark-200 dark:bg-dark-100 dark:text-primary-400`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`focus-visible:relative focus-visible:z-10 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/50`),children:[(0,U.jsx)(`span`,{className:`truncate`,children:m(`modelSelector.showAll`,{total:e.total})}),(0,U.jsx)(S,{className:`h-3.5 w-3.5 shrink-0 rtl:rotate-180`})]})]},e.key)):(0,U.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,U.jsx)(te,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,U.jsx)(`p`,{className:`text-sm`,children:m(`models.noModelsFound`)})]}),n&&(0,U.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,U.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(re,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),m(`modelSelector.actions`)]})}),(0,U.jsx)(`div`,{onMouseDown:e=>{e.preventDefault(),f()},className:`px-3 py-3 cursor-pointer hover:bg-blue-50 dark:hover:bg-blue-900/20 bg-white dark:bg-dark-100`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(_,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,U.jsxs)(`div`,{className:`flex-1`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`gallery.generate`)}),(0,U.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m(`gallery.generateDescription`)})]})]})})]})]})}function Pe({sources:e,active:t,onChange:n}){let{t:r}=s(),i=(0,F.useRef)([]),a=e.reduce((e,t)=>e+t.count,0),c=[{key:`all`,label:r(`common.all`),count:a},...e],l=(e,t)=>{let r=getComputedStyle(e.currentTarget).direction===`rtl`,a=r?`ArrowLeft`:`ArrowRight`,o=r?`ArrowRight`:`ArrowLeft`,s=null;e.key===a?s=(t+1)%c.length:e.key===o?s=(t-1+c.length)%c.length:e.key===`Home`?s=0:e.key===`End`&&(s=c.length-1),s!==null&&(e.preventDefault(),n(c[s].key),i.current[s]?.focus())};return(0,U.jsx)(`div`,{role:`radiogroup`,"aria-label":r(`modelSelector.sources`),"data-testid":`model-selector-sources`,className:`flex gap-1.5 overflow-x-auto px-4 pb-3 sm:px-5 scrollbar-none [&::-webkit-scrollbar]:hidden`,children:c.map((e,r)=>{let a=e.key===t;return(0,U.jsxs)(`button`,{ref:e=>{i.current[r]=e},type:`button`,role:`radio`,"aria-checked":a,tabIndex:a?0:-1,"data-source-key":e.key,onClick:()=>n(e.key),onKeyDown:e=>l(e,r),className:o(`flex shrink-0 items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-medium transition-colors`,`focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/50`,a?`border-transparent bg-gray-900 text-white dark:bg-dark-900 dark:text-dark-25`:`border-black/8 text-gray-600 hover:bg-gray-100 dark:border-white/9 dark:text-dark-600 dark:hover:bg-dark-200`,e.count===0&&!a&&`opacity-50`),children:[(0,U.jsx)(`span`,{className:`whitespace-nowrap`,children:e.label}),(0,U.jsx)(`span`,{className:o(`tabular-nums`,a?`text-white/70 dark:text-dark-25/70`:`text-gray-400 dark:text-dark-500`),children:e.count})]},e.key)})})}function Fe({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:a,pullProgress:c,setLibraryCategory:l,isModelInstalled:u,onModelSelect:d,onPullModel:f,onCancelPull:p,onRefreshLibrary:g}){let{t:_}=s();return(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,U.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 shrink-0`,children:(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,U.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:o(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,t===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,U.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,U.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:_(`modelSelector.pullRestricted`)}),r?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,U.jsx)(v,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,U.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,U.jsx)(ie,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,U.jsx)(`p`,{className:`text-sm`,children:_(`models.noModelsFound`)})]}):(0,U.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=u(e.name),r=a===e.name;return(0,U.jsxs)(`div`,{className:o(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,U.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,U.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 shrink-0`,children:(0,U.jsx)(ie,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,U.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-sm text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`,children:_(`modelSelector.installed`)}),(e.category===`cloud`||e.tags?.includes(`cloud`))&&(0,U.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded-sm text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 flex items-center gap-1`,children:[(0,U.jsx)(ie,{className:`h-3 w-3`}),`Cloud`]})]}),(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,U.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-sm text-xs bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:e},e)),e.pulls&&(0,U.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,U.jsx)(m,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,U.jsx)(`div`,{className:`shrink-0`,children:r?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:c?.percent===void 0?`...`:`${c.percent}%`}),(0,U.jsx)(`button`,{onClick:p,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,U.jsx)(T,{className:`h-4 w-4`})})]}):t?(0,U.jsx)(`button`,{onClick:()=>d(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/50`,children:_(`modelSelector.use`)}):n?(0,U.jsxs)(`button`,{onClick:()=>f(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50`,children:[(0,U.jsx)(m,{className:`h-3 w-3 inline mr-1`}),_(`modelSelector.pull`)]}):(0,U.jsx)(`span`,{className:`rounded-sm bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:_(`modelSelector.adminOnlyPull`)})})]}),r&&c?.percent!==void 0&&(0,U.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,U.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${c.percent}%`}})})]},e.name)})})]}),(0,U.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between shrink-0`,children:[(0,U.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,U.jsx)(h,{className:`h-3 w-3`}),_(`modelManager.huggingface.browseAllLink`)]}),(0,U.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),g()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,U.jsx)(b,{className:o(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var Ie=d(`components:model-selector`),Le=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:d,disabled:m=!1,compact:h=!1,showImageGen:_=!1,onModelsRefresh:v,getModelValue:te,getModelId:b,getModelLabel:S,getModelTitle:ne,triggerRef:O,triggerTestId:re,selectTestId:ae,ariaLabel:k})=>{let{t:j}=s(),[M,N]=(0,F.useState)(!1),[P,ue]=(0,F.useState)(``),[de,fe]=(0,F.useState)(`installed`),[pe,me]=(0,F.useState)(`all`),I=(0,F.useRef)(null),L=(0,F.useRef)(null),ge=(0,F.useRef)(null),R=(0,F.useRef)(null),ye=a(),{user:xe,systemInfo:Se}=ce(),z=xe?.role===`admin`||Se?.requiresAuth===!1,B=Se?.ollamaEnabled!==!1,V=B?de:`installed`,[H,Ce]=(0,F.useState)(`all`),[De,Oe]=(0,F.useState)(``),[W,je]=(0,F.useState)(`text-generation`),[Me,Le]=(0,F.useState)(`downloads`),[Re,ze]=(0,F.useState)(``),[G,Be]=(0,F.useState)(null),[Ve,He]=(0,F.useState)({}),[Ue,We]=(0,F.useState)(null),[K,q]=(0,F.useState)(null),[Ge,J]=(0,F.useState)(null),[Ke,Y]=(0,F.useState)(null),qe=[`all`,`general`,`coding`,`reasoning`,`vision`,`embedding`,`cloud`],Je=(0,F.useMemo)(()=>_e(e,{legacy:j(`modelSelector.providerNotRecorded`,`Provider not recorded`),unavailable:j(`modelSelector.unavailableSelections`,`Unavailable selections`),personas:j(`modelSelector.personas`),ollama:`Ollama`,plugins:j(`modelSelector.pluginModels`),agents:j(`modelSelector.agentModels`,`Agents`)}),[e,j]),Ye=e=>{let t=`h-4 w-4 shrink-0 text-gray-500 dark:text-dark-600`;switch(e.kind){case`legacy`:return(0,U.jsx)(E,{className:t});case`unavailable`:return(0,U.jsx)(T,{className:t});case`personas`:return(0,U.jsx)(C,{className:t});case`agent`:return(0,U.jsx)(x,{className:t});default:return(0,U.jsx)(ke,{seed:e.label})}},X=e=>te?.(e)??e.name,Xe=e=>we(b?.(e)??e.name,e.isPlugin?{prettify:!0}:{}),Ze=e=>{let t=Xe(e);return t.tag?`${t.name} ${t.tag}`:t.name},Qe=u(e=>e.modelMetadata),$e=u(e=>e.personas),Z=e.find(e=>X(e)===t),et=e=>{if(!e.name.startsWith(`persona:`))return;let t=e.name.slice(8),n=t;try{n=decodeURIComponent(t)}catch{}let r=$e[t]??$e[n];if(r?.name)return r.name;if(e.personaName&&e.personaName!==t)return e.personaName},tt=e=>{if(!e.name.startsWith(`persona:`))return;let t=e.name.slice(8),n=t;try{n=decodeURIComponent(t)}catch{}return $e[t]??$e[n]};(0,F.useImperativeHandle)(O,()=>ge.current);let Q=(0,F.useCallback)((e=!0)=>{N(!1),ue(``),e&&window.requestAnimationFrame(()=>ge.current?.focus())},[]),{data:nt=[],isLoading:rt,refetch:it}=i({queryKey:[`ollama-library-selector`,De,H===`cloud`?`cloud`:`all`],queryFn:async()=>{let e=await A.getLibraryModels({search:De||void 0,sort:`popular`,category:H===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:M&&V===`ollama`}),{data:at=[],isLoading:ot,refetch:st}=i({queryKey:[`hf-models-selector`,W,Re,Me],queryFn:async()=>{let e=await oe.getModels({task:W,search:Re||void 0,sort:Me,limit:30});return e.success&&e.data?e.data:[]},enabled:M&&V===`huggingface`}),ct=nt.filter(e=>{let t=!P||e.name.toLowerCase().includes(P.toLowerCase())||e.description.toLowerCase().includes(P.toLowerCase()),n=H===`all`||e.category===H;return t&&n}),lt=(0,F.useCallback)(async e=>{let[t,n]=e.split(`/`);if(t&&n){We(e);try{let r=await oe.getGgufFiles(t,n);r.success&&r.data&&He(t=>({...t,[e]:r.data}))}catch(e){Ie.error(`Failed to load GGUF files:`,e)}finally{We(null)}}},[]),ut=(0,F.useCallback)(e=>{G===e?Be(null):(Be(e),Ve[e]||lt(e))},[G,Ve,lt]),dt=(0,F.useCallback)((e,t)=>{if(!z)y.error(j(`modelSelector.pullRestricted`));else if(!K){q(e),J({status:`starting`});try{let n=A.pullModelStream(e,e=>{J(e)},()=>{J(null),q(null),Y(null),y.success(j(`modelDownload.success`,{name:t})),v?.()},e=>{J(null),q(null),Y(null),y.error(j(`modelDownload.failed`,{error:e}))});Y(()=>n)}catch{J(null),q(null),y.error(j(`modelDownload.startFailed`))}}},[z,v,K,j]);(0,F.useEffect)(()=>{let e=setTimeout(()=>{V===`huggingface`?ze(P):V===`ollama`&&Oe(P)},300);return()=>clearTimeout(e)},[P,V]),(0,F.useEffect)(()=>{if(!M)return;let e=e=>{if(e.key===`Escape`)e.preventDefault(),Q();else if(e.key===`Tab`&&L.current){let t=Array.from(L.current.querySelectorAll(`button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1];if(!n||!r)return;e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Q,M]),(0,F.useEffect)(()=>{M&&R.current&&R.current.focus()},[M]);let ft=async t=>{let r=e.find(e=>X(e)===t)??e.find(e=>!e.isPlugin&&!e.isPersona&&e.name===t),i=r?X(r):t,a=r?.name??t;if(Q(),!B)n({target:{value:i}});else{try{let e=await A.listRunningModels();if(e.success&&e.data){let t=e.data;t.length>0&&(r?.isPlugin!==!0&&t.some(e=>e.name===a||a.startsWith(`persona:`))||await A.unloadAllModels())}}catch(e){Ie.warn(`Failed to unload models before switch:`,e)}n({target:{value:i}})}},pt=async e=>{if(!z)y.error(j(`modelSelector.pullRestricted`));else if(!K){q(e),J({status:`starting`});try{let t=A.pullModelStream(e,e=>{J(e)},()=>{J(null),q(null),Y(null),y.success(j(`modelDownload.success`,{name:e})),v?.()},e=>{J(null),q(null),Y(null),y.error(j(`modelDownload.failed`,{error:e}))});Y(()=>t)}catch{J(null),q(null),y.error(j(`modelDownload.startFailed`))}}},mt=()=>{Ke&&(Ke(),Y(null),q(null),J(null),y.success(j(`modelDownload.cancelled`)))},ht=t=>e.some(e=>c(e)&&(e.name===t||e.name.startsWith(t+`:`))),gt=(e,t=`sm`)=>{let n=t===`md`?`h-6 w-6 rounded-md`:`h-4 w-4 rounded-sm`,r=Qe[l(e)]?.avatar;if(r&&!e.isPersona)return(0,U.jsx)(`img`,{src:r,alt:``,className:o(n,`shrink-0 rounded-full object-cover`)});if(e.isPersona||e.isLegacySelection){let t=tt(e);if(t)return(0,U.jsx)(`img`,{src:se(t,64),alt:``,className:o(n,`shrink-0 object-cover`)})}if(e.isLegacySelection||e.isPersona||e.isAgent){let r=e.isLegacySelection?E:e.isPersona?C:x,i=(0,U.jsx)(r,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-dark-600`});return t===`md`?(0,U.jsx)(`span`,{className:o(n,`flex shrink-0 items-center justify-center bg-gray-100 dark:bg-dark-200`),children:i}):i}let i=Xe(e),a=e.isPlugin?i.vendor||e.pluginName||e.pluginId||i.name:i.vendor||i.name;return(0,U.jsx)(ke,{seed:a,size:t})},$=e=>{let t=Qe[l(e)]?.label;if(t&&!e.isPersona)return t;if(S)return S(e);if(e.isLegacySelection)return`${et(e)??e.name} (${j(`modelSelector.legacyProvider`,`provider not recorded`)})`;if(e.isPersona)return et(e)||e.personaName||e.name;if(e.isAgent)return e.isUnavailable?`${e.agentName||e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.agentName||e.name;let n=Ze(e);return e.isUnavailable?`${n} (${j(`modelSelector.unavailable`,`unavailable`)})`:n},_t=e=>e.isLegacySelection?e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):j(`modelSelector.reselectProvider`,`reselect a provider to pin this model`):e.isPersona?j(`modelSelector.via`,{provider:e.model}):e.isAgent&&e.isUnavailable?e.unavailableReason??j(`modelSelector.unavailable`,`unavailable`):e.isPlugin?e.isUnavailable?`${j(`modelSelector.via`,{provider:e.pluginName||e.pluginId})} · ${j(`modelSelector.providerUnavailable`,`provider unavailable`)}`:j(`modelSelector.via`,{provider:e.pluginName}):e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):null,vt=e=>e.kind===`plugin`||e.kind===`ollama`,yt=e=>{let t=Xe(e);if(e.isPlugin||t.vendor||t.tag)return t;let n=t.name.lastIndexOf(`:`);if(n<=0)return t;let r=t.name.slice(n+1);return{name:t.name.slice(0,n),...r&&r!==`latest`?{tag:r}:{}}},bt=e=>!!Qe[l(e)]?.label,xt=(e,t)=>S||bt(e)?$(e):vt(t)?yt(e).name:t.kind===`agent`?he(e,t.label).title:$(e),St=(e,t)=>!vt(t)||S||bt(e)?null:yt(e).tag??null,Ct=(e,t)=>{if(t.kind===`agent`){let n=he(e,t.label);return n.isDefault?j(`modelSelector.defaultModel`):n.provider?j(`modelSelector.via`,{provider:n.provider}):null}if(!vt(t))return _t(e);let n=yt(e),r=e.details??{},i=/(^|[-:])cloud$/i.test(e.name),a=[n.vendor,e.isPlugin?void 0:r.parameter_size,e.isPlugin||r.quantization_level===n.tag?void 0:r.quantization_level,e.contextLength?j(`modelSelector.contextSize`,{size:Te(e.contextLength),defaultValue:`{{size}} context`}):void 0,e.isPlugin||i?void 0:Ee(e.size)].filter(e=>!!e);return a.length>0?a.join(` · `):null},wt=e=>X(e)===t,Tt=Je.map(e=>({source:e,matches:e.models.filter(t=>ve(t,e,P,$(t)))})),Et=Je.length>1,Dt=Et&&Je.some(e=>e.key===pe)?pe:`all`,Ot=Dt===`all`,kt=Tt.filter(({source:e})=>Ot||e.key===Dt).map(({source:e,matches:t})=>{let n=Ot&&Et?be(t,wt,{newestFirst:e.kind===`plugin`||e.kind===`agent`}):{visible:t,hidden:0};return{key:e.key,kind:e.kind,label:e.label,icon:Ye(e),models:n.visible,total:t.length,hidden:n.hidden,showHeader:Ot}}).filter(e=>e.models.length>0),At=Tt.map(({source:e,matches:t})=>({key:e.key,label:e.label,count:t.length}));return(0,U.jsxs)(`div`,{className:o(`relative min-w-0`,d),ref:I,children:[(0,U.jsxs)(`button`,{ref:ge,"data-testid":re,type:`button`,onClick:()=>!m&&N(!M),disabled:m,"aria-haspopup":`dialog`,"aria-expanded":M,"aria-label":k&&Z?`${k}: ${$(Z)}`:k,className:o(h?`flex h-9 w-full min-w-0 items-center justify-between gap-2 px-2.5 text-start`:`w-full flex items-center justify-between gap-2 px-3 py-2.5 text-start`,`rounded-xl border border-line bg-surface-subtle text-sm text-ink hover:bg-hover-solid`,`transition-colors duration-150 focus:outline-hidden focus:ring-2 focus:ring-primary-500/30 focus:border-primary-500`,m?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:h?Z?ne?.(Z)??$(Z):j(`modelSelector.selectModel`):void 0,children:[(()=>{if(!Z)return h?(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,U.jsx)(w,{className:`h-4 w-4 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate text-xs font-medium text-ink-subtle`,children:j(`modelSelector.selectModel`)})]}):j(`modelSelector.selectModel`);if(h){let e=$(Z);return(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0`,children:gt(Z)}),(0,U.jsx)(`span`,{dir:Z.isPersona?`auto`:`ltr`,className:`truncate text-xs font-medium text-ink`,children:e})]})}let e=$(Z),t=_t(Z);return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[gt(Z),(0,U.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,U.jsx)(`span`,{dir:Z.isPersona?`auto`:`ltr`,className:`text-sm font-medium truncate`,children:e}),t&&(0,U.jsx)(`span`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),Z.isPersona&&r&&(0,U.jsxs)(`div`,{className:`flex items-center gap-1 ms-auto`,children:[(0,U.jsx)(E,{className:`h-3 w-3 text-gray-500 dark:text-dark-600`}),r.embedding_model&&(0,U.jsx)(ee,{className:`h-3 w-3 text-gray-400 dark:text-dark-500`})]})]})})(),(0,U.jsx)(f,{className:o(h?`h-3 w-3`:`h-4 w-4`,`shrink-0 text-ink-subtle transition-transform duration-150 motion-reduce:transition-none`,M&&`rotate-180`)})]}),M&&(0,le.createPortal)((0,U.jsxs)(`div`,{className:`fixed inset-0 z-999999 flex items-center justify-center p-3 sm:p-6`,children:[(0,U.jsx)(`div`,{className:`absolute inset-0 bg-gray-950/55 backdrop-blur-md`,onClick:()=>Q()}),(0,U.jsxs)(`div`,{ref:L,role:`dialog`,"aria-modal":`true`,"aria-label":j(`modelSelector.selectModel`),className:o(`relative flex w-full max-w-xl flex-col overflow-hidden bg-white/98 dark:bg-dark-25/98`,`h-[min(620px,88vh)] rounded-3xl border border-black/8 dark:border-white/9`,`shadow-[0_30px_100px_rgba(0,0,0,0.28)] backdrop-blur-xl animate-scale-in`),onClick:e=>e.stopPropagation(),children:[(0,U.jsxs)(`div`,{className:`shrink-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4 sm:px-5 sm:pt-5`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-medium tracking-tight text-gray-950 dark:text-dark-950 rtl:tracking-normal`,children:j(`modelSelector.selectModel`)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>Q(),className:`flex h-9 w-9 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-950 dark:text-dark-500 dark:hover:bg-dark-200 dark:hover:text-dark-950`,title:j(`common.close`),"aria-label":j(`common.close`),children:(0,U.jsx)(T,{className:`h-4 w-4`})})]}),(0,U.jsx)(`div`,{className:`px-4 pb-3 sm:px-5`,children:(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(g,{className:`absolute inset-s-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,U.jsx)(`input`,{ref:R,type:`text`,placeholder:j(V===`installed`?B?`modelSelector.searchInstalled`:`modelSelector.searchModels`:V===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:P,onChange:e=>ue(e.target.value),onKeyDown:e=>{if(V!==`installed`)return;let t=L.current?.querySelector(`[data-testid="model-selector-option"]`);e.key===`ArrowDown`&&t?(e.preventDefault(),t.focus()):e.key===`Enter`&&P.trim()&&t&&(e.preventDefault(),t.click())},className:o(`w-full rounded-xl border border-black/[0.07] bg-gray-100/70 py-2.5 ps-10 pe-4 text-sm dark:border-white/[0.07] dark:bg-dark-200/70`,`focus:outline-hidden focus:border-primary-500 focus:ring-2 focus:ring-primary-500/30`,`text-gray-900 dark:text-dark-900 placeholder:text-gray-400 dark:placeholder:text-dark-500`)})]})}),B&&(0,U.jsxs)(`div`,{className:`mx-4 mb-3 flex rounded-xl bg-gray-100/70 p-1 dark:bg-dark-200/70 sm:mx-5`,children:[(0,U.jsxs)(`button`,{onClick:()=>{fe(`installed`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,V===`installed`?`bg-white text-gray-950 shadow-xs dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":V===`installed`,children:[(0,U.jsx)(p,{className:`h-4 w-4 inline me-1.5`}),j(`modelSelector.installed`)]}),(0,U.jsxs)(`button`,{onClick:()=>{fe(`ollama`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,V===`ollama`?`bg-white text-gray-950 shadow-xs dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":V===`ollama`,children:[(0,U.jsx)(ie,{className:`h-4 w-4 inline me-1.5`}),`Ollama`]}),(0,U.jsxs)(`button`,{onClick:()=>{fe(`huggingface`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,V===`huggingface`?`bg-white text-gray-950 shadow-xs dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":V===`huggingface`,children:[(0,U.jsx)(D,{className:`h-4 w-4 inline me-1.5`}),`HuggingFace`]})]}),V===`installed`&&Et&&(0,U.jsx)(Pe,{sources:At,active:Dt,onChange:me})]}),V===`installed`&&(0,U.jsx)(Ne,{groups:kt,selectedModel:t,showImageGen:_&&Ot,getModelValue:X,getModelIcon:e=>gt(e,`md`),getModelLabel:xt,getModelTag:St,getModelSubLabel:Ct,onExitTop:()=>R.current?.focus(),onModelSelect:ft,onShowAll:e=>{me(e),R.current?.focus()},onOpenGallery:()=>{Q(!1),ye(`/gallery`)}},Dt),V===`ollama`&&(0,U.jsx)(Fe,{libraryCategories:qe,libraryCategory:H,canInstallModels:z,loadingLibrary:rt,filteredLibraryModels:ct,pullingModel:K,pullProgress:Ge,setLibraryCategory:Ce,isModelInstalled:ht,onModelSelect:ft,onPullModel:pt,onCancelPull:mt,onRefreshLibrary:()=>{it()}}),V===`huggingface`&&(0,U.jsx)(Ae,{hfTask:W,hfSort:Me,canInstallModels:z,loadingHf:ot,hfModels:at,expandedHfModel:G,hfGgufFiles:Ve,loadingGguf:Ue,pullingModel:K,pullProgress:Ge,setHfTask:je,setHfSort:Le,onToggleHfModel:ut,onPullHfGguf:dt,onCancelPull:mt,onRefreshHfModels:()=>{st()}})]})]}),document.body),(0,U.jsx)(`select`,{"data-testid":ae,"aria-label":k,"aria-hidden":`true`,dir:`ltr`,value:t,onChange:n,className:`hidden`,tabIndex:-1,children:e.map(e=>(0,U.jsx)(`option`,{value:X(e),children:$(e)},`${e.isLegacySelection?`legacy`:e.isPersona?`persona`:e.isPlugin?`plugin`:`ollama`}:${e.pluginId||``}:${X(e)}`))})]})},Re=({value:e,inheritedValue:t,onChange:n})=>{let{t:r}=s(),[i,a]=(0,F.useState)(!1),c=(0,F.useRef)(null),l=e??t,u=M(l),d=N(l),f=N(e),p=t==null?void 0:N(t),m=(0,F.useRef)(null),h=u?r(`chat.input.thinkingOn`,{level:r(`settings.generation.thinkingLevels.${d}`)}):r(`chat.input.thinkingOff`),g=()=>c.current?.querySelector(`button`)?.focus();return(0,F.useEffect)(()=>{if(!i)return;let e=m.current?.querySelectorAll(`[role="menuitemradio"]`);(Array.from(e??[]).find(e=>e.getAttribute(`aria-checked`)===`true`)??e?.[0])?.focus()},[i]),(0,F.useEffect)(()=>{if(!i)return;let e=e=>{c.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&(a(!1),g())};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[i]),(0,U.jsxs)(`div`,{ref:c,className:`relative shrink-0`,children:[(0,U.jsxs)(ae,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(e=>!e),className:o(`h-9 rounded-full p-0 flex items-center justify-center gap-1 touch-manipulation transition-colors duration-150`,u?`w-auto px-2.5`:`w-9`,`text-ink-muted hover:bg-interactive-hover hover:text-ink`,u&&`bg-primary-50 text-primary-600 dark:bg-primary-900/25 dark:text-primary-400`),title:h,"aria-label":h,"aria-haspopup":`menu`,"aria-expanded":i,"aria-pressed":u,children:[(0,U.jsx)(E,{className:`h-4 w-4`}),u&&(0,U.jsx)(`span`,{className:`text-[11px] font-medium`,children:r(`settings.generation.thinkingLevels.${d}`)})]}),i&&(0,U.jsxs)(`div`,{ref:m,role:`menu`,"aria-label":r(`chat.controls.thinking`),onKeyDown:e=>{if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;let t=Array.from(e.currentTarget.querySelectorAll(`[role="menuitemradio"]`));if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowDown`?(n+1)%t.length:(n-1+t.length)%t.length].focus()},className:`absolute bottom-full inset-e-0 z-30 mb-2 w-48 rounded-2xl border border-black/8 bg-surface/95 p-1.5 shadow-[0_16px_48px_rgba(15,23,42,0.16)] backdrop-blur-xl animate-scale-in dark:border-white/9 dark:bg-dark-100/95`,children:[(0,U.jsx)(`p`,{className:`mb-1 px-2 pt-1 text-[11px] font-medium text-ink-muted`,children:r(`chat.controls.thinking`)}),P.map(e=>{let t=e===f;return(0,U.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":t,tabIndex:-1,onClick:()=>{n(j(e)),a(!1),g()},className:o(`flex w-full items-center justify-between gap-2 rounded-xl px-2.5 py-2 text-start text-[13px] text-gray-700 hover:bg-gray-100 dark:text-dark-800 dark:hover:bg-dark-200`,t&&`text-primary-600 dark:text-primary-400`),children:[(0,U.jsx)(`span`,{className:`truncate`,children:e==="default"&&p!==void 0?r(`settings.generation.thinkingLevels.defaultWith`,{level:r(`settings.generation.thinkingLevels.${p}`)}):r(`settings.generation.thinkingLevels.${e}`)}),t&&(0,U.jsx)(O,{className:`h-3.5 w-3.5 shrink-0`})]},e)})]})]})},ze=d(`hooks:dictation`),G=()=>{if(typeof window>`u`)return;let e=window;return e.SpeechRecognition||e.webkitSpeechRecognition},Be=[{mimeType:`audio/webm;codecs=opus`,format:`webm`}],Ve=300,He=.25,Ue=e=>`${encodeURIComponent(e.plugin)}:${encodeURIComponent(e.model)}`;function We(e){if(typeof MediaRecorder>`u`)return;let t=new Set((e.config?.formats||[]).map(e=>e.toLowerCase()));return Be.find(e=>(t.size===0||t.has(e.format))&&(typeof MediaRecorder.isTypeSupported!=`function`||MediaRecorder.isTypeSupported(e.mimeType)))?.mimeType}function K({onStart:e,onText:t,ownerKey:n}){let{t:r,i18n:i}=s(),[a,o]=(0,F.useState)(`idle`),[c,l]=(0,F.useState)([]),u=(0,F.useRef)(null),d=(0,F.useRef)(null),f=(0,F.useRef)(null),p=(0,F.useRef)(null),m=(0,F.useRef)(null),h=(0,F.useRef)(0),g=(0,F.useRef)(`idle`),_=(0,F.useRef)(void 0),v=(0,F.useRef)(e),ee=(0,F.useRef)(t);(0,F.useEffect)(()=>{v.current=e,ee.current=t},[e,t]),(0,F.useEffect)(()=>{let e=!1;return k.getModels().then(t=>{!e&&t.success&&t.data&&l(t.data)}).catch(()=>{e||l([])}),()=>{e=!0}},[]);let te=(0,F.useMemo)(()=>typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices&&!!G(),[]),b=typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia,x=(0,F.useMemo)(()=>[...te?[{key:`browser`,kind:`browser`}]:[],...b?c.filter(e=>!!We(e)).map(e=>({key:Ue(e),kind:`provider`,model:e})):[]],[te,b,c]),[S,ne]=(0,F.useState)(``),C=(0,F.useMemo)(()=>x.find(e=>e.key===S)??x[0],[S,x]),w=C?.kind===`provider`?C.model:void 0,T=x.length>0,E=(0,F.useCallback)(()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},[]),D=(0,F.useCallback)(e=>{g.current=e,o(e)},[]),O=(0,F.useCallback)(()=>{h.current+=1,E(),u.current?.stop(),u.current=null,p.current?.abort(),p.current=null;let e=d.current;d.current=null,e&&(e.ondataavailable=null,e.onerror=null,e.onstop=null,e.state===`recording`&&e.stop()),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,D(`idle`)},[E,D]);return(0,F.useEffect)(()=>(_.current=n,O),[O,n]),{supported:T,phase:a,toggle:(0,F.useCallback)(async()=>{let e=g.current;if(e===`starting`||e===`transcribing`){O();return}if(e===`recording`){d.current?.state===`recording`?(D(`transcribing`),d.current.stop()):O();return}if(w){let e=h.current+1;h.current=e;let t=_.current;v.current(),D(`starting`);try{let n=await navigator.mediaDevices.getUserMedia({audio:!0});if(h.current!==e||_.current!==t){n.getTracks().forEach(e=>e.stop());return}f.current=n;let a=We(w),o=a?new MediaRecorder(n,{mimeType:a}):new MediaRecorder(n),s=[];o.ondataavailable=e=>{e.data.size>0&&s.push(e.data)},o.onerror=()=>{n.getTracks().forEach(e=>e.stop()),E(),h.current===e&&(d.current=null,f.current=null,D(`idle`),y.error(r(`voiceMode.transcriptionFailed`)))},o.onstop=()=>{if(n.getTracks().forEach(e=>e.stop()),E(),h.current!==e||_.current!==t)return;if(d.current=null,f.current=null,s.length===0){D(`idle`);return}let a=new Blob(s,{type:o.mimeType||s[0].type||`audio/webm`}),c=new AbortController;p.current=c,D(`transcribing`),k.transcribe(a,w,{language:i.language,signal:c.signal,fallbackMessage:r(`voiceMode.transcriptionFailed`)}).then(n=>{h.current!==e||_.current!==t||c.signal.aborted||ee.current(n.text.trim())}).catch(e=>{c.signal.aborted||(ze.error(`Provider transcription failed:`,e),y.error(e instanceof Error?e.message:r(`voiceMode.transcriptionFailed`)))}).finally(()=>{p.current===c&&h.current===e&&(p.current=null,D(`idle`))})},d.current=o,o.start(250);let c=w.config?.max_duration_seconds,l=typeof c==`number`&&c>0?Math.min(c,Ve):Ve;m.current=window.setTimeout(()=>{h.current===e&&o.state===`recording`&&o.stop()},Math.max(.1,l-He)*1e3),D(`recording`);return}catch(t){if(h.current!==e)return;ze.error(`Failed to start provider dictation:`,t),E(),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,d.current=null,D(`idle`),y.error(r(`voiceMode.transcriptionFailed`));return}}let t=G();if(!t)return;let n=h.current+1;h.current=n;let a=_.current,o=new t;o.lang=i.language,o.continuous=!0,o.interimResults=!0,v.current(),o.onresult=e=>{if(h.current!==n||_.current!==a||u.current!==o)return;let t=``;for(let n=0;n<e.results.length;n++)t+=e.results[n][0]?.transcript??``;ee.current(t.trim())},o.onend=()=>{h.current===n&&(u.current=null,D(`idle`))},o.onerror=()=>{h.current===n&&(u.current=null,D(`idle`))},u.current=o,D(`recording`);try{o.start()}catch(e){ze.error(`Failed to start dictation:`,e),u.current=null,D(`idle`)}},[O,E,i.language,w,D,r]),cancel:O,sources:x,activeSourceKey:C?.key??``,setSourceKey:ne,providerModel:w}}export{Re as n,Le as r,K as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-vendor-C1iE8mnY.js";var r=e(t(),1),i=n(),a=r.createContext(void 0),o=e=>{let t=r.useContext(a);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},s=({client:e,children:t})=>(r.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,i.jsx)(a.Provider,{value:e,children:t})),c={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},l=new class{#e=c;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function u(e){setTimeout(e,0)}var d=typeof window>`u`||`Deno`in globalThis;function f(){}function p(e,t){return typeof e==`function`?e(t):e}function m(e){return typeof e==`number`&&e>=0&&e!==1/0}function h(e,t){return Math.max(e+(t||0)-Date.now(),0)}function g(e,t){return typeof e==`function`?e(t):e}function _(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==y(o,t.options))return!1}else if(!x(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function v(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(b(t.options.mutationKey)!==b(a))return!1}else if(!x(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function y(e,t){return(t?.queryKeyHashFn||b)(e)}function b(e){return JSON.stringify(e,(e,t)=>T(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function x(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!x(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!x(e[r],t[r]))return!1;return!0}return!1}var ee=Object.prototype.hasOwnProperty;function S(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=w(e)&&w(t);if(!r&&!(T(e)&&T(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:ee.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=S(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function C(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function w(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function T(e){if(!E(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!E(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function E(e){return Object.prototype.toString.call(e)===`[object Object]`}function te(e){return new Promise(t=>{l.setTimeout(t,e)})}function D(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:S(e,t)}function ne(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function re(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var O=Symbol();function k(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===O?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function A(e,t){return typeof e==`function`?e(...t):!!e}function ie(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r||(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0})),i)}),e}var ae=()=>d,j=()=>ae(),M=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},N=new class extends M{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},oe=u;function se(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=oe,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var P=se(),F=new class extends M{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function ce(e){return Math.min(1e3*2**e,3e4)}function I(e){return(e??`online`)!==`online`||F.isOnline()}var L=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function R(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(f);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new L(t);g(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},p=()=>N.isFocused()&&(e.networkMode===`always`||F.isOnline())&&e.canRun(),m=()=>I(e.networkMode)&&e.canRun(),h=e=>{c()||(r?.(),i=`resolved`,a(e))},g=e=>{c()||(r?.(),i=`rejected`,o(e))},_=t=>new Promise(n=>{r=e=>{(c()||t())&&n(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),v=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(h).catch(r=>{if(c())return;let i=e.retry??(j()?0:3),a=e.retryDelay??ce,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);t||!s?g(r):(n++,e.onFail?.(n,r),te(o).then(()=>p()?void 0:_(p)).then(()=>{t?g(r):v()}))})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:m,start:()=>(m()?v():_(m).then(v),s)}}var z=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),m(this.gcTime)&&(this.#e=l.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(j()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(l.clearTimeout(this.#e),this.#e=void 0)}};function le(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ie(e,()=>t.signal,()=>n=!0)},u=k(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?re:ne;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?V:B,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]===void 0?r.initialPageParam:o[0]:B(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function B(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function V(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function ue(e,t){return t?B(e,t)!=null:!1}function H(e,t){return!t||!e.getPreviousPageParam?!1:V(e,t)!=null}var de=class extends z{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=G(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=G(this.options);e.data!==void 0&&(this.setState(W(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=D(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(f).catch(f):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>g(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===O||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>g(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!h(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=k(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?le(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=R({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof L&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof L){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...U(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...W(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),P.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function U(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:I(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function W(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function G(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var K=class extends M{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),q(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return J(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return J(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof g(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!C(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Y(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||g(this.options.enabled,this.#t)!==g(t.enabled,this.#t)||g(this.options.staleTime,this.#t)!==g(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||g(this.options.enabled,this.#t)!==g(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return C(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch(t).then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(f)),t}#h(e){return!j()&&g(this.options.enabled,this.#t)!==!1&&m(e)}#g(){this.#b();let e=g(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=h(this.#r.dataUpdatedAt,e)+1;this.#u=l.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return g(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=l.setInterval(()=>{(this.options.refetchIntervalInBackground||N.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(l.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(l.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&q(e,t),o=i&&Y(e,n,t,r);(a||o)&&(l={...l,...U(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=D(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=D(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let _=l.fetchStatus===`fetching`,v=m===`pending`,y=m===`error`,b=v&&_,x=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:v,isSuccess:m===`success`,isError:y,isInitialLoading:b,isLoading:b,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:_,isRefetching:_&&!v,isLoadingError:y&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:y&&x,isStale:X(e,t),refetch:this.refetch,isEnabled:g(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),C(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();P.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function fe(e,t){return g(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||g(t.retryOnMount,e)!==!1)}function q(e,t){return fe(e,t)||e.state.data!==void 0&&J(e,t,t.refetchOnMount)}function J(e,t,n){if(g(t.enabled,e)!==!1&&g(t.staleTime,e)!==`static`){let r=g(n,e);return r===`always`||r!==!1&&X(e,t)}return!1}function Y(e,t,n,r){return(e!==t||g(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&X(e,n)}function X(e,t){return g(t.enabled,e)!==!1&&e.isStaleByTime(g(t.staleTime,e))}var Z=r.createContext(!1),pe=()=>r.useContext(Z);Z.Provider;function me(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var he=r.createContext(me()),ge=()=>r.useContext(he),_e=(e,t,n)=>{let r=n?.state.status===`error`&&typeof e.throwOnError==`function`?A(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},Q=e=>{r.useEffect(()=>{e.clearReset()},[e])},ve=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||A(n,[e.error,r])),ye=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},be=(e,t)=>e?.suspense&&t.isPending,xe=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function $(e,t,n){let i=pe(),a=ge(),s=o(n),c=s.defaultQueryOptions(e),l=s.getQueryCache().get(c.queryHash),u=e.subscribed!==!1;c._optimisticResults=i?`isRestoring`:u?`optimistic`:void 0,ye(c),_e(c,a,l),Q(a);let[d]=r.useState(()=>new t(s,c)),p=d.getOptimisticResult(c),m=!i&&u;if(r.useSyncExternalStore(r.useCallback(e=>{let t=m?d.subscribe(P.batchCalls(e)):f;return d.updateResult(),t},[d,m]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),r.useEffect(()=>{d.setOptions(c)},[c,d]),be(c,p))throw xe(c,d,a);if(ve({result:p,errorResetBoundary:a,throwOnError:c.throwOnError,query:l,suspense:c.suspense}))throw p.error;return c.notifyOnChangeProps?p:d.trackResult(p)}function Se(e,t){return $(e,K,t)}export{o as C,s as S,_,ue as a,g as b,R as c,N as d,M as f,v as g,y as h,de as i,F as l,b as m,$ as n,H as o,p,K as r,z as s,Se as t,P as u,f as v,O as x,x as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,r as t}from"./utils-vendor-CsC5rH1J.js";var n=e=>typeof e==`string`,r=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},i=e=>e==null?``:String(e),a=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},o=/###/g,s=e=>e&&e.includes(`###`)?e.replace(o,`.`):e,c=e=>!e||n(e),l=(e,t,r)=>{let i=n(t)?t.split(`.`):t,a=0;for(;a<i.length-1;){if(c(e))return{};let t=s(i[a]);!e[t]&&r&&(e[t]=new r),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++a}return c(e)?{}:{obj:e,k:s(i[a])}},u=(e,t,n)=>{let{obj:r,k:i}=l(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=l(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=l(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},d=(e,t,n,r)=>{let{obj:i,k:a}=l(e,t,Object);i[a]=i[a]||[],i[a].push(n)},f=(e,t)=>{let{obj:n,k:r}=l(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},p=(e,t,n)=>{let r=f(e,n);return r===void 0?f(t,n):r},m=(e,t,r)=>{for(let i in t)i!==`__proto__`&&i!==`constructor`&&(Object.prototype.hasOwnProperty.call(e,i)?n(e[i])||e[i]instanceof String||n(t[i])||t[i]instanceof String?r&&(e[i]=t[i]):m(e[i],t[i],r):e[i]=t[i]);return e},h=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),g={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`,"/":`/`},_=e=>n(e)?e.replace(/[&<>"'\/]/g,e=>g[e]):e,v=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},y=[` `,`,`,`?`,`!`,`;`],b=new v(20),x=(e,t,n)=>{t||=``,n||=``;let r=y.filter(e=>!t.includes(e)&&!n.includes(e));if(r.length===0)return!0;let i=b.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},S=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].includes(typeof t)&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},C=e=>e?.replace(/_/g,`-`),w={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},T=new class e{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||w,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,r,i){return i&&!this.debug?null:(e=e.map(e=>n(e)?e.replace(/[\r\n\x00-\x1F\x7F]/g,` `):e),n(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t||=this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},E=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(([n,r])=>{for(let i=0;i<r;i++)n(e,...t)})}},D=new WeakSet,O=class extends E{constructor(e,t={ns:[`translation`],defaultNS:`translation`}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,r,i={}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=i.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:i.ignoreJSONStructure,s;e.includes(`.`)?s=e.split(`.`):(s=[e,t],r&&(Array.isArray(r)?s.push(...r):n(r)&&a?s.push(...r.split(a)):s.push(r)));let c=f(this.data,s);return!c&&!t&&!r&&e.includes(`.`)&&(e=s[0],t=s[1],r=s.slice(2).join(`.`)),c||!o||!n(r)?c:S(this.data?.[e]?.[t],r,a)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.includes(`.`)&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),u(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,r,i={silent:!1}){for(let i in r)(n(r[i])||Array.isArray(r[i]))&&this.addResource(e,t,i,r[i],{silent:!0});i.silent||this.emit(`added`,e,t,r)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.includes(`.`)&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=f(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?m(s,n,i):s={...s,...n},u(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>{let n=t[e];return D.has(n)?!0:!n||Object.keys(n).length===0?!1:(typeof n==`object`&&D.add(n),!0)})}toJSON(){return this.data}},k={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},A=Symbol(`i18next/PATH_KEY`);function ee(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===A?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function j(e,t){let{[A]:n}=e(ee()),r=t?.keySeparator??`.`,i=t?.nsSeparator??`:`,a=t?.enableSelector===`strict`;if(n.length>1&&i){let e=t?.ns,o=a?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(o&&(a?o:o.length>1?o.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}var M=e=>!n(e)&&typeof e!=`boolean`&&typeof e!=`number`,N=class e extends E{constructor(e,t={}){super(),a([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=T.create(`translator`),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=M(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(e,t){let r=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;r===void 0&&(r=`:`);let i=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,a=t.ns||this.options.defaultNS||[],o=r&&e.includes(r),s=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!x(e,r,i);if(o&&!s){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:n(a)?[a]:a};let o=e.split(r);(r!==i||r===i&&this.options.ns.includes(o[0]))&&(a=o.shift()),e=o.join(i)}return{key:e,namespaces:n(a)?[a]:a}}translate(t,r,i){let a=typeof r==`object`?{...r}:r;if(typeof a!=`object`&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a==`object`&&(a={...a}),a||={},t==null)return``;typeof t==`function`&&(t=j(t,{...this.options,...a})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>typeof e==`function`?j(e,{...this.options,...a}):String(e));let o=a.returnDetails===void 0?this.options.returnDetails:a.returnDetails,s=a.keySeparator===void 0?this.options.keySeparator:a.keySeparator,{key:c,namespaces:l}=this.extractFromKey(t[t.length-1],a),u=l[l.length-1],d=a.nsSeparator===void 0?this.options.nsSeparator:a.nsSeparator;d===void 0&&(d=`:`);let f=a.lng||this.language,p=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()===`cimode`)return p?o?{res:`${u}${d}${c}`,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(a)}:`${u}${d}${c}`:o?{res:c,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(a)}:c;let m=this.resolve(t,a),h=m?.res,g=m?.usedKey||c,_=m?.exactUsedKey||c,v=[`[object Number]`,`[object Function]`,`[object RegExp]`],y=a.joinArrays===void 0?this.options.joinArrays:a.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,x=a.count!==void 0&&!n(a.count),S=e.hasDefaultValue(a),C=x?this.pluralResolver.getSuffix(f,a.count,a):``,w=a.ordinal&&x?this.pluralResolver.getSuffix(f,a.count,{ordinal:!1}):``,T=x&&!a.ordinal&&a.count===0,E=T&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${C}`]||a[`defaultValue${w}`]||a.defaultValue,D=h;b&&!h&&S&&(D=E);let O=M(D),k=Object.prototype.toString.apply(D);if(b&&D&&O&&!v.includes(k)&&!(n(y)&&Array.isArray(D))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,D,{...a,ns:l}):`key '${c} (${this.language})' returned an object instead of string.`;return o?(m.res=e,m.usedParams=this.getUsedParamsDetails(a),m):e}if(s){let e=Array.isArray(D),t=e?[]:{},n=e?_:g;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let r=`${n}${s}${e}`;t[e]=S&&!h?this.translate(r,{...a,defaultValue:M(E)?E[e]:void 0,joinArrays:!1,ns:l}):this.translate(r,{...a,joinArrays:!1,ns:l}),t[e]===r&&(t[e]=D[e])}h=t}}else if(b&&n(y)&&Array.isArray(h))h=h.join(y),h&&=this.extendTranslation(h,t,a,i);else{let e=!1,n=!1;!this.isValidLookup(h)&&S&&(e=!0,h=E),this.isValidLookup(h)||(n=!0,h=c);let r=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:h,o=S&&E!==h&&this.options.updateMissing;if(n||e||o){if(this.logger.log(o?`updateKey`:`missingKey`,f,u,x&&!o?`${c}${this.pluralResolver.getSuffix(f,a.count,a)}`:c,o?E:h),s){let e=this.resolve(c,{...a,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(a.lng||this.language):e.push(a.lng||this.language);let n=(e,t,n)=>{let i=S&&n!==h?n:r;this.options.missingKeyHandler?this.options.missingKeyHandler(e,u,t,i,o,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,u,t,i,o,a),this.emit(`missingKey`,e,u,t,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&x?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,a);T&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],c+t,a[`defaultValue${t}`]||E)})}):n(e,c,E))}h=this.extendTranslation(h,t,a,m,i),n&&h===c&&this.options.appendNamespaceToMissingKey&&(h=`${u}${d}${c}`),(n||e)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${c}`:c,e?h:void 0,a))}return o?(m.res=h,m.usedParams=this.getUsedParamsDetails(a),m):h}extendTranslation(e,t,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});let o=n(e)&&(r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables),s;if(o){let t=e.match(this.interpolator.nestingRegexp);s=t&&t.length}let c=r.replace&&!n(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),e=this.interpolator.interpolate(e,c,r.lng||this.language||i.usedLng,r),o){let t=e.match(this.interpolator.nestingRegexp),n=t&&t.length;s<n&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...e)=>a?.[0]===e[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):this.translate(...e,t),r)),r.interpolation&&this.interpolator.reset()}let o=r.postProcess||this.options.postProcess,s=n(o)?[o]:o;return e!=null&&s?.length&&r.applyPostProcessor!==!1&&(e=k.handle(s,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,t={}){let r,i,a,o,s;return n(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(e=>typeof e==`function`?j(e,{...this.options,...t}):e)),e.forEach(e=>{if(this.isValidLookup(r))return;let c=this.extractFromKey(e,t),l=c.key;i=l;let u=c.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let d=t.count!==void 0&&!n(t.count),f=d&&!t.ordinal&&t.count===0,p=t.context!==void 0&&(n(t.context)||typeof t.context==`number`)&&t.context!==``,m=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(s=e,!this.checkedLoadedFor[`${m[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(s)&&(this.checkedLoadedFor[`${m[0]}-${e}`]=!0,this.logger.warn(`key "${i}" for languages "${m.join(`, `)}" won't get resolved as namespace "${s}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),m.forEach(n=>{if(this.isValidLookup(r))return;o=n;let i=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(i,l,n,e,t);else{let e;d&&(e=this.pluralResolver.getSuffix(n,t.count,t));let r=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(t.ordinal&&e.startsWith(a)&&i.push(l+e.replace(a,this.options.pluralSeparator)),i.push(l+e),f&&i.push(l+r)),p){let n=`${l}${this.options.contextSeparator||`_`}${t.context}`;i.push(n),d&&(t.ordinal&&e.startsWith(a)&&i.push(n+e.replace(a,this.options.pluralSeparator)),i.push(n+e),f&&i.push(n+r))}}let s;for(;s=i.pop();)this.isValidLookup(r)||(a=s,r=this.getResource(n,e,s,t))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:o,usedNS:s}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],r=e.replace&&!n(e.replace),i=r?e.replace:e;if(r&&e.count!==void 0&&(i={...i,count:e.count}),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(let e of t)delete i[e]}return i}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith(`defaultValue`)&&e[t]!==void 0)return!0;return!1}},P=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=T.create(`languageUtils`),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(e=C(e),!e||!e.includes(`-`))return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=C(e),!e||!e.includes(`-`))return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(n(e)&&e.includes(`-`)){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?!0:!e.includes(`-`)&&!r.includes(`-`)?!1:!!(e.includes(`-`)&&!r.includes(`-`)&&e.slice(0,e.indexOf(`-`))===r||e.startsWith(r)&&r.length>1))}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),n(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let r=e[t];return r||=e[this.getScriptPartFromCode(t)],r||=e[this.formatLanguageCode(t)],r||=e[this.getLanguagePartFromCode(t)],r||=e.default,r||[]}toResolveHierarchy(e,t){let r=this.options.fallbackLng,i=Array.isArray(r)?r.join(`|`):r;i!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=i);let a=t===void 0||t===!1||n(t),o=t===void 0&&typeof this.options.fallbackLng==`function`,s=n(e)&&a&&!o,c=null;if(s){let n;n=t===void 0?`undefined`:t===!1?`boolean:false`:`string:${t}`,c=`${e.length}:${e}|${n}`}if(c!==null){let e=this.resolveHierarchyCache[c];if(e!==void 0)return e.slice()}let l=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),u=[],d=e=>{e&&(this.isSupportedCode(e)?u.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return n(e)&&(e.includes(`-`)||e.includes(`_`))?(this.options.load!==`languageOnly`&&d(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&d(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&d(this.getLanguagePartFromCode(e))):n(e)&&d(this.formatLanguageCode(e)),l.forEach(e=>{let t=this.formatLanguageCode(e);u.includes(t)||d(t)}),c===null?u:(this.resolveHierarchyCache[c]=u,u.slice())}},F={zero:0,one:1,two:2,few:3,many:4,other:5},I={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},te=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=T.create(`pluralResolver`),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=C(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(typeof Intl>`u`)return this.logger.error(`No Intl support, please use an Intl polyfill!`),I;if(!e.match(/-|_/))return I;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>F[e]-F[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},L=(e,t,r,i=`.`,a=!0)=>{let o=p(e,t,r);return!o&&a&&n(r)&&(o=S(e,r,i),o===void 0&&(o=S(t,r,i))),o},R=class{constructor(e={}){this.logger=T.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:g,maxReplaces:v,alwaysFormat:y}=e.interpolation;this.escape=t===void 0?_:t,this.escapeValue=n===void 0||n,this.useRawValueToEscape=r!==void 0&&r,this.prefix=i?h(i):a||`{{`,this.suffix=o?h(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u?h(u):`-`,this.unescapeSuffix=this.unescapePrefix?``:l?h(l):``,this.nestingPrefix=d?h(d):f||h(`$t(`),this.nestingSuffix=p?h(p):m||h(`)`),this.nestingOptionsSeparator=g||`,`,this.maxReplaces=v||1e3,this.alwaysFormat=y!==void 0&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']|"[^"]*"|'[^']*'|\\((?:[^()"']|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,r,a){let o,s,c,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=e=>{if(!e.includes(this.formatSeparator)){let n=L(t,l,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(n,void 0,r,{...a,...t,interpolationkey:e}):n}let n=e.split(this.formatSeparator),i=n.shift().trim(),o=n.join(this.formatSeparator).trim();return this.format(L(t,l,i,this.options.keySeparator,this.options.ignoreJSONStructure),o,r,{...a,...t,interpolationkey:i})};this.resetRegExp(),!this.escapeValue&&typeof e==`string`&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn(`nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.`);let d=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=a?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:a.interpolation.skipOnVariables,p=[{regex:this.regexpUnescape,safeValue:e=>e},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e):e}],m=[],h=0;return p.forEach(t=>{for(c=0;o=t.regex.exec(e);){let r=o.index-h,l=m.find(([e,t])=>r>=e&&r<t);if(l){t.regex.lastIndex=l[1]+h;continue}let p=o[1].trim();if(s=u(p),s===void 0){if(typeof d==`function`){let t=d(e,o,a);s=n(t)?t:``}else if(a&&Object.prototype.hasOwnProperty.call(a,p))s=``;else if(f){s=o[0];continue}else this.logger.warn(`missed to pass in variable ${p} for interpolating ${e}`),s=``}else!n(s)&&!this.useRawValueToEscape&&(s=i(s));let g=i(t.safeValue(s));if(e=e.slice(0,o.index)+g+e.slice(o.index+o[0].length),f?(t.regex===this.regexpUnescape?m.push([o.index,o.index+g.length]):h+=g.length-o[0].length,t.regex.lastIndex+=g.length,t.regex.lastIndex-=o[0].length):t.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,t,r={}){let a,o,s,c=(e,t)=>{let n=this.nestingOptionsSeparator;if(!e.includes(n))return e;let r=e.split(RegExp(`${h(n)}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,s);let a=i.match(/'/g),o=i.match(/"/g);((a?.length??0)%2==0&&!o||(o?.length??0)%2!=0)&&(i=i.replace(/'/g,`"`));try{s=JSON.parse(i),t&&(s={...t,...s})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return s.defaultValue&&s.defaultValue.includes(this.prefix)&&delete s.defaultValue,e},l=new RegExp(this.nestingRegexp),u=``,d=0;for(;a=l.exec(e);){let f=[];s={...r},s=s.replace&&!n(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;let p=/{.*}/s.test(a[1])?a[1].lastIndexOf(`}`)+1:a[1].indexOf(this.formatSeparator);if(p!==-1&&(f=a[1].slice(p).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),a[1]=a[1].slice(0,p)),o=t(c.call(this,a[1].trim(),s),s),o&&a[0]===e&&!n(o))return o;n(o)||(o=i(o)),o||=(this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`),``),f.length&&(o=f.reduce((e,t)=>this.format(e,t,r.lng,{...r,interpolationkey:a[1].trim()}),o.trim())),u+=e.slice(d,a.index)+i(o),d=l.lastIndex,this.regexp.lastIndex=0}return d?u+e.slice(d):e}},ne=e=>{let t=e.toLowerCase().trim(),n={};if(e.includes(`(`)){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].slice(0,-1);t===`currency`&&!i.includes(`:`)?n.currency||=i.trim():t===`relativetime`&&!i.includes(`:`)?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},z=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(C(r),i),t[o]=s),s(n)}},B=e=>(t,n,r)=>e(C(n),r)(t),re=class{constructor(e={}){this.logger=T.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?z:B;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=z(t)}format(e,t,n,r={}){if(!t||e==null)return e;let i=t.split(this.formatSeparator),a=[];for(let e=0;e<i.length;e++){let t=i[e];for(;t.indexOf(`(`)>-1&&!t.includes(`)`)&&e+1<i.length;)t=`${t}${this.formatSeparator}${i[++e]}`;a.push(t)}return a.reduce((e,t)=>{let{formatName:i,formatOptions:a}=ne(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e},e)}},ie=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},ae=class extends E{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=T.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{d(n.loaded,[i],a),ie(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}o&&s&&r<this.maxRetries?setTimeout(()=>{this.read(e,t,n,r+1,i*2,a)},i):a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2)try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}else return s(e,t,o)}prepareLoading(e,t,r={},i){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),i&&i();n(e)&&(e=this.languageUtils.toResolveHierarchy(e)),n(t)&&(t=[t]);let a=this.queueLoad(e,t,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);else if(n!=null&&n!==``){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}},V=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),n(e[1])&&(t.defaultValue=e[1]),n(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),H=e=>(n(e.ns)&&(e.ns=[e.ns]),n(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),n(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes(`cimode`)&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),e),U=()=>{},oe=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},W=class e extends E{constructor(e={},t){if(super(),this.options=H(e),this.services={},this.logger=T,this.modules={external:[]},oe(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e==`function`&&(t=e,e={}),e.defaultNS==null&&e.ns&&(n(e.ns)?e.defaultNS=e.ns:e.ns.includes(`translation`)||(e.defaultNS=e.ns[0]));let i=V();this.options={...i,...this.options,...H(e)},this.options.interpolation={...i.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!=`function`&&(this.options.overloadTranslationOptionHandler=i.overloadTranslationOptionHandler);let a=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?T.init(a(this.modules.logger),this.options):T.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:re;let t=new P(this.options);this.store=new O(this.options.resources,this.options);let n=this.services;n.logger=T,n.resourceStore=this.store,n.languageUtils=t,n.pluralResolver=new te(t,{prepend:this.options.pluralSeparator}),e&&(n.formatter=a(e),n.formatter.init&&n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new R(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new ae(a(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(n.languageDetector=a(this.modules.languageDetector),n.languageDetector.init&&n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=a(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new N(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||=U,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let o=r(),s=()=>{let e=(e,n)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),o.resolve(n),t(e,n)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?s():setTimeout(s,0),o}loadResources(e,t=U){let r=t,i=n(e)?e:this.language;if(typeof e==`function`&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return r();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&(e.includes(t)||e.push(t))})};i?t(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(e)})}else r(null)}reloadResources(e,t,n){let i=r();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||=this.languages,t||=this.options.ns,n||=U,this.services.backendConnector.reload(e,t,e=>{i.resolve(),n(e)}),i}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&k.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&![`cimode`,`dev`].includes(e)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(![`cimode`,`dev`].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let i=r();this.emit(`languageChanging`,e);let a=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(n,r)=>{r?this.isLanguageChangingTo===e&&(a(r),this.translator.changeLanguage(r),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,r),this.logger.log(`languageChanged`,r)):this.isLanguageChangingTo=void 0,i.resolve((...e)=>this.t(...e)),t&&t(n,(...e)=>this.t(...e))},s=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let r=n(t)?t:t&&t[0],i=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(n(t)?[t]:t);i&&(this.language||a(i),this.translator.language||this.translator.changeLanguage(i),this.services.languageDetector?.cacheUserLanguage?.(i)),this.loadResources(i,e=>{o(e,i)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e),i}getFixedT(e,t,r,i){let a=i?.scopeNs,o=(e,t,...n)=>{let i;i=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(n)),i.lng=i.lng||o.lng,i.lngs=i.lngs||o.lngs;let s=i.ns!==void 0&&i.ns!==null;i.ns=i.ns||o.ns,i.keyPrefix!==``&&(i.keyPrefix=i.keyPrefix||r||o.keyPrefix);let c={...this.options,...i};Array.isArray(a)&&!s&&(c.ns=a),typeof i.keyPrefix==`function`&&(i.keyPrefix=j(i.keyPrefix,c));let l=this.options.keySeparator||`.`,u;return i.keyPrefix&&Array.isArray(e)?u=e.map(e=>(typeof e==`function`&&(e=j(e,c)),`${i.keyPrefix}${l}${e}`)):(typeof e==`function`&&(e=j(e,c)),u=i.keyPrefix?`${i.keyPrefix}${l}${e}`:e),this.t(u,i)};return n(e)?o.lng=e:o.lngs=e,o.ns=t,o.keyPrefix=r,o}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}if(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages)return!0;let{languageUtils:o}=this.services,s=t.lng?o.isSupportedCode(n)&&o.toResolveHierarchy(n,!1)[0]:n;return!(s&&!a(s,e)||r&&!a(i,e))}loadNamespaces(e,t){let i=r();return this.options.ns?(n(e)&&(e=[e]),e.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{i.resolve(),t&&t(e)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){let i=r();n(e)&&(e=[e]);let a=this.options.preload||[],o=e.filter(e=>!a.includes(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=a.concat(o),this.loadResources(e=>{i.resolve(),t&&t(e)}),i):(t&&t(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new P(V());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.includes(n.getLanguagePartFromCode(e))||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(t={},n){let r=new e(t,n);return r.createInstance=e.createInstance,r}cloneInstance(t={},n=U){let r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,preload:!1,...t,isClone:!0},a=new e(i);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){let e=t=>{let n=Array.isArray(t)?[...t]:{...t};return Object.keys(n).forEach(t=>{n[t]&&typeof n[t]==`object`&&(n[t]=e(n[t]))}),n};a.store=new O(e(this.store.data),i),a.services.resourceStore=a.store}if(t.interpolation){let e={...V().interpolation,...this.options.interpolation,...t.interpolation},n={...i,interpolation:e};a.services.interpolator=new R(n)}return a.translator=new N(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance();W.createInstance,W.dir,W.init,W.loadResources,W.reloadResources,W.use,W.changeLanguage,W.getFixedT,W.t,W.exists,W.setDefaultNamespace,W.hasLoadedNamespace,W.loadNamespaces,W.loadLanguages;var G=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,K={"&":`&`,"&":`&`,"<":`<`,"<":`<`,">":`>`,">":`>`,"'":`'`,"'":`'`,""":`"`,""":`"`," ":`\xA0`," ":`\xA0`,"©":`©`,"©":`©`,"®":`®`,"®":`®`,"…":`…`,"…":`…`,"/":`/`,"/":`/`},se=e=>K[e],q={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(G,se),transDefaultProps:void 0},ce=(e={})=>{q={...q,...e}},le=()=>q,J,ue=e=>{J=e},de=()=>J;function fe(...n){return t(e(n))}function pe(){return typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)}var Y=new Map,X=new Map,Z=e=>{let t=Y.get(e);return t||(t=new Intl.RelativeTimeFormat(e,{numeric:`auto`,style:`narrow`}),Y.set(e,t)),t},Q=e=>{let t=X.get(e);return t||(t=new Intl.DateTimeFormat(e),X.set(e,t)),t};function me(e,t=`en`){let n=new Date(e),r=Math.max(0,new Date().getTime()-n.getTime()),i=Math.floor(r/6e4),a=Math.floor(r/36e5),o=Math.floor(r/864e5);if(t.toLowerCase().split(`-`)[0]===`en`)return i<1?`Just now`:i<60?`${i}m ago`:a<24?`${a}h ago`:o<7?`${o}d ago`:Q(t).format(n);let s=Z(t);return i<1?s.format(0,`second`):i<60?s.format(-i,`minute`):a<24?s.format(-a,`hour`):o<7?s.format(-o,`day`):Q(t).format(n)}function he(e,t=`en`,n=Date.now()){let r=Math.round((e-n)/1e3),i=Math.abs(r),a=Z(t);return i<60?a.format(r,`second`):i<3600?a.format(Math.round(r/60),`minute`):i<86400?a.format(Math.round(r/3600),`hour`):a.format(Math.round(r/86400),`day`)}function ge(e){let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n.toFixed(1)} ${t[r]}`}function $(e=12){let t=new Uint8Array(e);globalThis.crypto.getRandomValues(t);let n=``;for(let e of t)n+=`0123456789abcdefghijklmnopqrstuvwxyz`[e%36];return n}function _e(){return $(11)+Date.now().toString(36)}function ve(e,t){return e.length<=t?e:e.substring(0,t)+`...`}function ye(e){for(let t of[/^\[Thinking:\s*([\s\S]*?)\]\s*/i,/^<thinking>([\s\S]*?)<\/thinking>\s*/i,/^<think>([\s\S]*?)<\/think>\s*/i]){let n=e.match(t);if(n)return{thinking:n[1].trim(),content:e.slice(n[0].length).trim(),thinkingComplete:!0}}for(let[t,n]of[[/^\[Thinking:\s*/i,`]`],[/^<thinking>\s*/i,`</thinking>`],[/^<think>\s*/i,`</think>`]]){let r=e.match(t);if(r&&!e.toLowerCase().includes(n))return{thinking:e.slice(r[0].length).trim()||null,content:``,thinkingComplete:!1}}return{thinking:null,content:e,thinkingComplete:!0}}export{_e as a,$ as c,ue as d,le as f,j as h,me as i,ve as l,W as m,ge as n,pe as o,ce as p,he as r,ye as s,fe as t,de as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as workApi}from"./workApi-_0oxRyak.js";
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./config-CHUQTU6j.js";import{t}from"./client-D_F_0LqX.js";var n=new Set([`snapshot`,`run_state`,`reasoning_delta`,`assistant_delta`,`tool_call`,`tool_result`,`approval`,`usage`,`skill_loaded`,`error`,`done`]),r=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,i=e=>{if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`){let t=Number(e);if(Number.isFinite(t))return t;let n=Date.parse(e);if(Number.isFinite(n))return n}return Date.now()},a=(e,t,a,o,s)=>{let c=r(e);if(!c)return;let l=Number(c.id??t),u=String(c.type??a??``),d=String(c.taskId??o),f=String(c.runId??s);if(!Number.isSafeInteger(l)||l<0||!n.has(u)||d!==o||f!==s)return;let p=c.data;return{id:l,type:u,taskId:d,runId:f,timestamp:i(c.timestamp),data:r(p)||(p===void 0?{}:{content:p})}},o=(e,t,n)=>{let r,i,o=[];for(let t of e.split(`
|
|
2
|
-
`)){if(!t||t.startsWith(`:`))continue;let e=t.indexOf(`:`),n=e===-1?t:t.slice(0,e),a=e===-1?``:t.slice(e+1),s=a.startsWith(` `)?a.slice(1):a;n===`id`&&(r=s),n===`event`&&(i=s),n===`data`&&o.push(s)}if(o.length===0)return;let s=o.join(`
|
|
3
|
-
`);if(s===`[DONE]`)return a({id:r,type:`done`,taskId:t,runId:n,timestamp:Date.now(),data:{}},r,i,t,n);try{return a(JSON.parse(s),r,i,t,n)}catch{return}},s=class{taskId;runId;onEvent;buffer=``;constructor(e,t,n){this.taskId=e,this.runId=t,this.onEvent=n}push(e){e&&(this.buffer+=e,this.drain())}finish(e=``){if(this.buffer+=e,this.drain(),!this.buffer.trim()){this.buffer=``;return}let t=o(this.buffer.replace(/\r\n?/g,`
|
|
4
|
-
`),this.taskId,this.runId);this.buffer=``,t&&this.onEvent(t)}drain(){let e=/\r?\n\r?\n/.exec(this.buffer);for(;e?.index!==void 0;){let t=this.buffer.slice(0,e.index).replace(/\r\n?/g,`
|
|
5
|
-
`);this.buffer=this.buffer.slice(e.index+e[0].length);let n=o(t,this.taskId,this.runId);n&&this.onEvent(n),e=/\r?\n\r?\n/.exec(this.buffer)}}},c=async e=>{try{let t=await e.json(),n=typeof t.error==`string`?t.error:typeof t.message==`string`?t.message:void 0;if(n)return Error(n)}catch{}return Error(`Work event stream failed with status ${e.status}.`)},l=async({taskId:t,runId:n,after:r,signal:i,onEvent:a})=>{let o=localStorage.getItem(`auth-token`),l=new URL(`${e}/work/tasks/${encodeURIComponent(t)}/runs/${encodeURIComponent(n)}/events`,window.location.origin);l.searchParams.set(`after`,String(Math.max(0,Math.trunc(r))));let u=await fetch(l,{method:`GET`,headers:{Accept:`text/event-stream`,...o?{Authorization:`Bearer ${o}`}:{}},cache:`no-store`,credentials:`same-origin`,signal:i});if(!u.ok)throw await c(u);if(!u.body)throw Error(`Work event stream has no response body.`);let d=u.body.getReader(),f=new TextDecoder,p=new s(t,n,a);try{for(;!i.aborted;){let{done:e,value:t}=await d.read();if(e)break;p.push(f.decode(t,{stream:!0}))}p.finish(f.decode())}finally{d.releaseLock()}},u=e=>`/work/tasks/${encodeURIComponent(e)}`,d={access:()=>t.get(`/work/access`).then(e=>e.data),setAccess:e=>t.put(`/work/access`,{mode:e}).then(e=>e.data),agents:()=>t.get(`/work/agents`).then(e=>e.data),agentAccess:()=>t.get(`/work/agents/access`).then(e=>e.data),setAgentAccess:e=>t.put(`/work/agents/access`,{mode:e}).then(e=>e.data),adminOverview:()=>t.get(`/work/admin/overview`).then(e=>e.data),adminRecovery:()=>t.get(`/work/admin/recovery`).then(e=>e.data),retryAdminRecovery:()=>t.post(`/work/admin/recovery/retry`).then(e=>e.data),listPolicies:()=>t.get(`/work/policies`).then(e=>e.data),sendRunMessage:(e,n)=>t.post(`/work/tasks/${encodeURIComponent(e)}/messages`,{message:n}).then(e=>e.data),getComputerSetup:()=>t.get(`/work/computer/setup`).then(e=>e.data),startComputerSetup:()=>t.post(`/work/computer/setup`).then(e=>e.data),createPolicy:e=>t.post(`/work/policies`,e).then(e=>e.data),updatePolicy:(e,n)=>t.put(`/work/policies/${encodeURIComponent(e)}`,n).then(e=>e.data),deletePolicy:e=>t.delete(`/work/policies/${encodeURIComponent(e)}`).then(e=>e.data),capabilities:()=>t.get(`/work/capabilities`).then(e=>e.data),listRuns:(e,n)=>t.get(`${u(e)}/runs${n?`?limit=${encodeURIComponent(n)}`:``}`).then(e=>e.data),getRun:(e,n)=>t.get(`${u(e)}/runs/${encodeURIComponent(n)}`).then(e=>e.data),markTaskSeen:e=>t.post(`/work/tasks/${encodeURIComponent(e)}/seen`).then(e=>e.data),getApprovals:e=>t.get(`${u(e)}/approvals`).then(e=>e.data),setApprovalsEnabled:(e,n)=>t.put(`${u(e)}/approvals`,{enabled:n}).then(e=>e.data),decideApproval:(e,n,r,i=`once`)=>t.post(`${u(e)}/approvals/${encodeURIComponent(n)}`,{approve:r,scope:i}).then(e=>e.data),deleteApprovalRule:(e,n)=>t.delete(`${u(e)}/approval-rules/${encodeURIComponent(n)}`).then(e=>e.data),listTasks:()=>t.get(`/work/tasks`).then(e=>e.data),createTask:e=>t.post(`/work/tasks`,e).then(e=>e.data),getTask:e=>t.get(u(e)).then(e=>e.data),getMessages:(e,n,r=200)=>t.get(`${u(e)}/messages`,{params:{before:n,limit:r}}).then(e=>e.data),updateTask:(e,n)=>t.patch(u(e),n).then(e=>e.data),deleteTask:e=>t.delete(u(e)).then(e=>e.data),startRun:(e,n)=>t.post(`${u(e)}/runs`,n).then(e=>e.data),cancelRun:e=>t.post(`${u(e)}/cancel`).then(e=>e.data),streamRunEvents:e=>l(e),listFiles:(e,n=``)=>t.get(`${u(e)}/files`,{params:{path:n}}).then(e=>{let t=e.data;return t.data&&!Array.isArray(t.data)?{...t,data:t.data.entries}:t}),getFile:(e,n)=>t.get(`${u(e)}/file`,{params:{path:n}}).then(e=>e.data),saveFile:(e,n,r,i)=>t.put(`${u(e)}/file`,{content:r,expectedUpdatedAt:i},{params:{path:n}}).then(e=>e.data),getGitStatus:e=>t.get(`${u(e)}/git`).then(e=>e.data),getGitDiff:(e,n)=>t.get(`${u(e)}/git/diff`,{params:n?{path:n}:void 0}).then(e=>e.data),initializeGit:e=>t.post(`${u(e)}/git/init`).then(e=>e.data),stageGitPaths:(e,n)=>t.post(`${u(e)}/git/stage`,{paths:n}).then(e=>e.data),commitGit:(e,n)=>t.post(`${u(e)}/git/commit`,{message:n}).then(e=>e.data),createGitBranch:(e,n)=>t.post(`${u(e)}/git/branches`,{name:n}).then(e=>e.data),switchGitBranch:(e,n)=>t.post(`${u(e)}/git/switch`,{name:n}).then(e=>e.data),startPreview:(e,n,r={})=>t.post(`${u(e)}/preview/start`,{...n?{command:n}:{},...r.reopen?{reopen:!0}:{}}).then(e=>e.data),stopPreview:e=>t.post(`${u(e)}/preview/stop`).then(e=>e.data)};export{d as t};
|