@openchambery/web 2.1.6-beta.1 → 2.1.6-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AgentAvatar-Ah1nMt7y.js +1 -0
- package/dist/assets/AssistantView-Dpa4vy55.js +3 -0
- package/dist/assets/{DiagramView-BudqVoj4.js → DiagramView-BxnLZPyY.js} +1 -1
- package/dist/assets/{FadeInOnReveal-C8mIXT_x.js → FadeInOnReveal-BssISEuf.js} +1 -1
- package/dist/assets/{Icon-De3bTfBD.js → Icon-DewMAW7N.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-DVxKuVwD.js → ImageLoadingPlaceholder-D7q71Qgl.js} +1 -1
- package/dist/assets/LoadingImage-BBGT-9VQ.js +1 -0
- package/dist/assets/MarkdownRenderer-DZT-ObQc.js +2 -0
- package/dist/assets/MarkdownRendererImpl-DcSDNoV2.js +10 -0
- package/dist/assets/{MarkstreamRendererImpl-CIylCsD3.js → MarkstreamRendererImpl-AE60MlbM.js} +2 -2
- package/dist/assets/{MobileDetailNavigation-CzOQIbvs.js → MobileDetailNavigation-Bgzkkjqa.js} +1 -1
- package/dist/assets/{MobileShareBridge-B0leJCQr.js → MobileShareBridge-BFgFuhnW.js} +2 -2
- package/dist/assets/MobileTabPageHeader-C8QJsijY.js +2 -0
- package/dist/assets/{MultiRunWindow-CHfg6SYj.js → MultiRunWindow-DRw2Q5qW.js} +1 -1
- package/dist/assets/{OnboardingScreen-WDXH6GyO.js → OnboardingScreen-BjikXNcy.js} +1 -1
- package/dist/assets/{OverlayScrollbar-_xcqpVSN.js → OverlayScrollbar-C24-p2ns.js} +1 -1
- package/dist/assets/{SettingsView-BQ_jhvcz.js → SettingsView-DEC27hDQ.js} +4 -4
- package/dist/assets/{SettingsWindow-DCMtWvxd.js → SettingsWindow-BCRYo0Ry.js} +1 -1
- package/dist/assets/{TerminalView--7RrFsTH.js → TerminalView-lTVWnwxv.js} +1 -1
- package/dist/assets/{ToolOutputDialog-C9bqkmLi.js → ToolOutputDialog-CPLfCLfs.js} +1 -1
- package/dist/assets/{appThemeRegistry-DxQ0uJse.js → appThemeRegistry-D2PNvjdo.js} +1 -1
- package/dist/assets/{assistant-attachment-cache-CPBGM8H7.js → assistant-attachment-cache-Bzewqov4.js} +1 -1
- package/dist/assets/{button-BnPjweDW.js → button-kJNzMb1G.js} +1 -1
- package/dist/assets/{collapsible-C9mIVYPa.js → collapsible-MInYZ7dA.js} +1 -1
- package/dist/assets/{context-menu-C_ImdU3v.js → context-menu-BYq0LM7H.js} +1 -1
- package/dist/assets/{desktopHosts-BfMzjRVt.js → desktopHosts-BKeEWmL5.js} +1 -1
- package/dist/assets/{desktopRelayRestore-ML6japys.js → desktopRelayRestore-FWm2fXr6.js} +1 -1
- package/dist/assets/{diagram-DVV7MmUA.js → diagram-BDSPghN-.js} +1 -1
- package/dist/assets/dropdown-menu.styles-BXvVFEkh.js +1 -0
- package/dist/assets/es-CLTWsqOO.js +15 -0
- package/dist/assets/{fileMentionTouchSelection-CC7g7YFk.js → fileMentionTouchSelection-DYN36NEt.js} +1 -1
- package/dist/assets/{fileQueries-DfHYU8Iq.js → fileQueries-Dhgypzyl.js} +1 -1
- package/dist/assets/fr-BNyfwida.js +13 -0
- package/dist/assets/{gitApi-C4lwqR8Q.js → gitApi-BvFBlh91.js} +1 -1
- package/dist/assets/{image-loading-BzqNA0Jz.css → image-loading-DDV3Ixi1.css} +1 -1
- package/dist/assets/{image-loading-4Touxv4x.js → image-loading-OgMEw4Jq.js} +1 -1
- package/dist/assets/{input-CporeP3S.js → input-02eTmC8w.js} +1 -1
- package/dist/assets/insertionBoundaries-Bh99pFdp.js +1 -0
- package/dist/assets/ja-D7MYkMo9.js +15 -0
- package/dist/assets/ko-CFNLrmLm.js +15 -0
- package/dist/assets/{main-BtR6Gsq0.js → main-CtZ7bXuB.js} +2 -2
- package/dist/assets/{main-6iMM4Nlz.js → main-DrhFSQWG.js} +5 -5
- package/dist/assets/{markdownHeightCache-BMfTZ02N.js → markdownHeightCache-CAVQhVdd.js} +1 -1
- package/dist/assets/{mcpQueries-VE6ohhCb.js → mcpQueries-vmVVwTpL.js} +1 -1
- package/dist/assets/miniChat-BRBfrnmk.js +2 -0
- package/dist/assets/mobile-BUIfaNsP.js +2 -0
- package/dist/assets/{multirun-Ba_1t89r.js → multirun-1GSoWB-H.js} +1 -1
- package/dist/assets/{persistence-CoWdsn8M.js → persistence-DUPZl7Oy.js} +1 -1
- package/dist/assets/pl-aKpW58gt.js +15 -0
- package/dist/assets/{platform-Cl17ZOYo.js → platform-z2erC6Bs.js} +2 -2
- package/dist/assets/{projectMeta-DF-wxcjW.js → projectMeta-D3IGNNQh.js} +1 -1
- package/dist/assets/pt-BR-MliQk6-s.js +15 -0
- package/dist/assets/{rasterizePng-DZNznN7Z.js → rasterizePng-DCmIQQsI.js} +1 -1
- package/dist/assets/{relay-image-stream-BsB_ApBk.js → relay-image-stream-qI2NTXbG.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-DMUg8tvi.js +2 -0
- package/dist/assets/{renderMobileApp-C2YixTLg.js → renderMobileApp-DZaLZ-b9.js} +4 -4
- package/dist/assets/{runtime-fetch-DJVW43Cw.js → runtime-fetch-QCWYlAx0.js} +1 -1
- package/dist/assets/{runtime-switch-Ck0YPsR7.js → runtime-switch-3ad3yzM7.js} +1 -1
- package/dist/assets/runtimeConfig-BJepD3Y0.js +2 -0
- package/dist/assets/{runtimeEndpointReset-Bb0BK0JR.js → runtimeEndpointReset-BGGITu9Y.js} +1 -1
- package/dist/assets/sessionChangeSummary-CR90SDjh.js +2 -0
- package/dist/assets/sessionChangeSummary-vC84qM3v.css +1 -0
- package/dist/assets/{sessionLookup-BP3heiWj.js → sessionLookup-B8rBkNoR.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-CgLj1fIA.js → sortable-tabs-strip-DSGwZHAT.js} +1 -1
- package/dist/assets/{speechSettingsQueries-DgCdTbV5.js → speechSettingsQueries-CVAWg738.js} +2 -2
- package/dist/assets/src-BAWBlgDt.css +2 -0
- package/dist/assets/store-D5OeM4wB.js +15 -0
- package/dist/assets/{terminalApi-B8MBtYf4.js → terminalApi-BnjU_lmF.js} +1 -1
- package/dist/assets/{textarea-DgVlBlA9.js → textarea-yLPH5NYp.js} +1 -1
- package/dist/assets/{tooltip-Cgzp7Xco.js → tooltip-B3eYZnNS.js} +1 -1
- package/dist/assets/uk-8Ovv1FvC.js +15 -0
- package/dist/assets/{url-BmJM1D3o.js → url-DAyfGWPH.js} +1 -1
- package/dist/assets/{useAppFontEffects-C4FL5nAN.js → useAppFontEffects-DJdHyEAP.js} +53 -53
- package/dist/assets/{useAssistantUIStore-Dej-0i1V.js → useAssistantUIStore-Dt0l5AKe.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-CncoTsE8.js → useDesktopWindowControlsLayout-COV-TWix.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BwQn0I5k.js → useEffectiveDirectory-Dzsx_s3D.js} +1 -1
- package/dist/assets/{useFontPreferences-CGnJ_sK3.js → useFontPreferences-B4Cgu3bS.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-2dQHPP2A.js → useMobileNavigationStore-B24J82Xs.js} +8 -8
- package/dist/assets/{useUIStore-CdCyJRb0.js → useUIStore-pl39iO82.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-CO8kP8tW.js → useWorkerHighlightedLines-BrDkvxQW.js} +1 -1
- package/dist/assets/zh-CN-DYC-d6-i.js +15 -0
- package/dist/assets/zh-TW-OPu9_qbz.js +15 -0
- package/dist/index.html +11 -11
- package/dist/mini-chat.html +11 -11
- package/dist/mobile.html +11 -11
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/server/lib/dictation/DOCUMENTATION.md +3 -1
- package/server/lib/dictation/service.js +1 -0
- package/server/lib/dictation/volcengine-session.js +5 -2
- package/server/lib/dictation/volcengine-session.test.js +8 -2
- package/server/lib/tts/DOCUMENTATION.md +11 -0
- package/server/lib/tts/direct-session.js +1 -1
- package/server/lib/tts/direct-session.test.js +21 -0
- package/server/lib/tts/direct-speech.test.js +20 -0
- package/server/lib/tts/settings.js +2 -1
- package/dist/assets/AgentAvatar-BRPyrjhY.js +0 -1
- package/dist/assets/AssistantView-aSdlY38u.js +0 -3
- package/dist/assets/LoadingImage-DZsBpRYx.js +0 -1
- package/dist/assets/MarkdownRenderer-BSrQCSxr.js +0 -2
- package/dist/assets/MarkdownRendererImpl-BmgsCLj8.js +0 -10
- package/dist/assets/MobileTabPageHeader-DcKOtnwN.js +0 -2
- package/dist/assets/dropdown-menu.styles-Dw94PXY7.js +0 -1
- package/dist/assets/es-B7Pk7Sm2.js +0 -15
- package/dist/assets/fr-BcJSt2Bt.js +0 -13
- package/dist/assets/insertionBoundaries-BL9G3wjG.js +0 -1
- package/dist/assets/ja-ex36lpwC.js +0 -15
- package/dist/assets/ko-CgIIQFMh.js +0 -15
- package/dist/assets/miniChat-CamREdRa.js +0 -2
- package/dist/assets/mobile-D9TkJI3N.js +0 -2
- package/dist/assets/pl-CbT2Ag4y.js +0 -15
- package/dist/assets/pt-BR-BqXoXmx6.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-TjqgdRXK.js +0 -2
- package/dist/assets/runtimeConfig-DfKDrWh3.js +0 -2
- package/dist/assets/sessionChangeSummary-B15lUBlz.js +0 -2
- package/dist/assets/sessionChangeSummary-DpXRx1hd.css +0 -1
- package/dist/assets/src-bvi8KvVB.css +0 -2
- package/dist/assets/store-CYW4nz6C.js +0 -15
- package/dist/assets/uk-18wal33L.js +0 -15
- package/dist/assets/zh-CN-LO8acNQg.js +0 -15
- package/dist/assets/zh-TW-yk05f02-.js +0 -15
package/dist/assets/{ImageLoadingPlaceholder-DVxKuVwD.js → ImageLoadingPlaceholder-D7q71Qgl.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{rt as e}from"./vendor-base-ui-CdzJ6My_.js";import{n as t}from"./vendor-react-BP2cRVqX.js";import{f as n,r}from"./button-
|
|
1
|
+
import{rt as e}from"./vendor-base-ui-CdzJ6My_.js";import{n as t}from"./vendor-react-BP2cRVqX.js";import{f as n,r}from"./button-kJNzMb1G.js";import"./image-loading-OgMEw4Jq.js";var i=t(),a=e();function o(e){let t=(0,i.c)(7),{className:o}=e,{t:s}=n(),c;t[0]===o?c=t[1]:(c=r(`oc-image-loading`,o),t[0]=o,t[1]=c);let l;t[2]===s?l=t[3]:(l=s(`chat.fileAttachment.image.loading`),t[2]=s,t[3]=l);let u;return t[4]!==c||t[5]!==l?(u=(0,a.jsx)(`span`,{className:c,role:`status`,"aria-label":l}),t[4]=c,t[5]=l,t[6]=u):u=t[6],u}export{o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{n as r}from"./useUIStore-pl39iO82.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{f as a}from"./button-kJNzMb1G.js";import{t as o}from"./ImageLoadingPlaceholder-D7q71Qgl.js";var s=i(),c=e(t(),1),l=n();function u(e){let t=(0,s.c)(39),n,i,u,f,p,m,h;t[0]===e?(n=t[1],i=t[2],u=t[3],f=t[4],p=t[5],m=t[6],h=t[7]):({resourceError:m,fill:i,contentFrame:n,onLoad:f,onError:u,style:h,...p}=e,t[0]=e,t[1]=n,t[2]=i,t[3]=u,t[4]=f,t[5]=p,t[6]=m,t[7]=h);let g=r(d),{t:_}=a(),v=c.useRef(null),[y,b]=c.useState(`loading`),x=m?`error`:y,S,C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{let e=v.current;e?.complete&&e.naturalWidth>0&&b(`loaded`)},C=[],t[8]=S,t[9]=C):(S=t[8],C=t[9]),c.useLayoutEffect(S,C);let w=i||void 0,T=n?g?`mobile`:`desktop`:void 0,E=x===`loading`,D=p.src||void 0,O;t[10]===x?O=t[11]:(O=x===`loaded`?{}:{opacity:0},t[10]=x,t[11]=O);let k;t[12]!==h||t[13]!==O?(k={...h,...O},t[12]=h,t[13]=O,t[14]=k):k=t[14];let A;t[15]===f?A=t[16]:(A=e=>{b(`loaded`),f?.(e)},t[15]=f,t[16]=A);let j;t[17]!==u||t[18]!==p.src?(j=e=>{p.src&&(b(`error`),u?.(e))},t[17]=u,t[18]=p.src,t[19]=j):j=t[19];let M;t[20]!==p||t[21]!==j||t[22]!==D||t[23]!==k||t[24]!==A?(M=(0,l.jsx)(`img`,{...p,ref:v,src:D,style:k,onLoad:A,onError:j}),t[20]=p,t[21]=j,t[22]=D,t[23]=k,t[24]=A,t[25]=M):M=t[25];let N;t[26]===x?N=t[27]:(N=x===`loading`&&(0,l.jsx)(o,{}),t[26]=x,t[27]=N);let P;t[28]!==x||t[29]!==_?(P=x===`error`&&(0,l.jsx)(`span`,{className:`oc-image-error`,role:`status`,children:_(`chat.fileAttachment.image.loadFailed`)}),t[28]=x,t[29]=_,t[30]=P):P=t[30];let F;return t[31]!==x||t[32]!==M||t[33]!==N||t[34]!==P||t[35]!==w||t[36]!==T||t[37]!==E?(F=(0,l.jsxs)(`span`,{className:`oc-image-frame`,"data-image-state":x,"data-image-fill":w,"data-image-content":T,"aria-busy":E,children:[M,N,P]}),t[31]=x,t[32]=M,t[33]=N,t[34]=P,t[35]=w,t[36]=T,t[37]=E,t[38]=F):F=t[38],F}function d(e){return e.isMobile}var f=c.memo(function(e){let t=(0,s.c)(11),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({resourceError:a,fill:r,contentFrame:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=`${i.src??``}\n${i.srcSet??``}`,c;return t[5]!==n||t[6]!==r||t[7]!==i||t[8]!==a||t[9]!==o?(c=(0,l.jsx)(u,{...i,resourceError:a,fill:r,contentFrame:n},o),t[5]=n,t[6]=r,t[7]=i,t[8]=a,t[9]=o,t[10]=c):c=t[10],c});export{f as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-AE60MlbM.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-pl39iO82.js","assets/runtime-switch-3ad3yzM7.js","assets/runtime-auth-C8w0nlKy.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-markstream-react-Bm0cO70Z.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-kJNzMb1G.js","assets/persistence-DUPZl7Oy.js","assets/runtime-fetch-QCWYlAx0.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/store-D5OeM4wB.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useMobileNavigationStore-B24J82Xs.js","assets/platform-z2erC6Bs.js","assets/vendor-opencode-client-MF2GBrFx.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-sonner-ZS8XIOVl.js","assets/useAssistantUIStore-Dt0l5AKe.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/useThemeSystem-8jhE4Zyk.js","assets/tooltip-B3eYZnNS.js","assets/image-loading-OgMEw4Jq.js","assets/fileQueries-Dhgypzyl.js","assets/useRuntimeAPIs-Cx8S1HLz.js","assets/relay-image-stream-qI2NTXbG.js","assets/image-loading-DDV3Ixi1.css","assets/url-DAyfGWPH.js","assets/useEffectiveDirectory-Dzsx_s3D.js","assets/LoadingImage-BBGT-9VQ.js","assets/ImageLoadingPlaceholder-D7q71Qgl.js","assets/markdownHeightCache-CAVQhVdd.js","assets/dualLimitLru-D8Sphgua.js","assets/MarkdownRendererImpl-DcSDNoV2.js","assets/vendor-katex-DNVSTX6g.js","assets/markdown-worker-DFNZ3KJ_.js","assets/FadeInOnReveal-BssISEuf.js","assets/markdownTheme-CV7_0QAL.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-pele-C1WTNWUm.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js","assets/MarkstreamRendererImpl-DKhVy3nF.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-o69pgTEK.js";import{it as n,rt as r}from"./vendor-base-ui-CdzJ6My_.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as o}from"./button-kJNzMb1G.js";import{i as s,n as c,t as l}from"./markdownHeightCache-CAVQhVdd.js";var u=i(),d=e(n(),1),f=`openchamber:chunk-import-reload`,p=250,m=3e4,h=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function g(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function _(e){let t=g(e);return h.some(e=>e.test(t))}function v(e){return`2.1.6-beta.11:${g(e).slice(0,500)}`}function y(e){if(typeof window>`u`)return;let t=Date.now(),n=v(e),r=null;try{let e=window.sessionStorage.getItem(f);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<m)){try{window.sessionStorage.setItem(f,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:g(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function b(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!_(e)||t>=n)break;await new Promise(e=>setTimeout(e,p*(t+1)))}throw _(r)&&y(r),r}var x=e=>(0,d.lazy)(()=>b(e)),S=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return n?n.getItem(e)===`1`:!1}catch{return!1}},C=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},w=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},T=`oc:legend-timeline`,E=e=>S(T,e),D=`oc:markstream-react`,O=e=>C(D,e),k=t(e=>({legendTimelineEnabled:E(),setLegendTimelineEnabled:t=>{w(T,t),e({legendTimelineEnabled:t})},markstreamReactEnabled:O(),setMarkstreamReactEnabled:t=>{w(D,t),e({markstreamReactEnabled:t})}})),A=null,j=()=>(A??=a(()=>import(`./MarkstreamRendererImpl-AE60MlbM.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65])).catch(e=>{throw A=null,e}),A),M=()=>{j().catch(()=>void 0)},N=null,P=()=>(N??=a(()=>import(`./MarkdownRendererImpl-DcSDNoV2.js`).then(e=>e.n),__vite__mapDeps([45,1,4,5,18,17,6,2,3,7,19,20,25,26,9,46,13,14,15,16,21,22,23,24,27,28,29,30,31,44,32,34,35,36,37,38,39,47,40,48,49,50,51,52,53,54,55,56,57,58,59,43,60,61,62,63,64])).catch(e=>{throw N=null,e}),N),F=()=>{P().catch(()=>void 0),O()&&M()},I=class extends d.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},L=d.createContext(!0),R=()=>d.useContext(L),z=r(),B=x(()=>P().then(e=>({default:e.MarkdownRenderer}))),V=x(()=>j().then(e=>({default:e.MarkstreamRenderer}))),H=x(()=>P().then(e=>({default:e.SimpleMarkdownRenderer}))),U=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,W=e=>{let t=(0,u.c)(15),n=k(q),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?c(l(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let d=a,f;t[5]!==e.className||t[6]!==e.variant?(f=o(`relative break-words w-full min-w-0`,U(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=f):f=t[7];let p;t[8]!==r||t[9]!==e.animated||t[10]!==d?(p=(0,z.jsx)(s,{animated:e.animated,content:r,reservedHeight:d}),t[8]=r,t[9]=e.animated,t[10]=d,t[11]=p):p=t[11];let m;return t[12]!==f||t[13]!==p?(m=(0,z.jsx)(`div`,{className:f,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:p}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m},G=e=>{let t=(0,u.c)(9),n=R(),r=k(J);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(W,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,z.jsx)(d.Suspense,{fallback:(0,z.jsx)(W,{...e,reserveMeasuredHeight:!0}),children:(0,z.jsx)(B,{...e})}),t[2]=e,t[3]=i);let a=i;if(!r)return a;let o;t[4]===e?o=t[5]:(o=(0,z.jsx)(d.Suspense,{fallback:(0,z.jsx)(W,{...e,reserveMeasuredHeight:!0}),children:(0,z.jsx)(V,{...e})}),t[4]=e,t[5]=o);let s;return t[6]!==a||t[7]!==o?(s=(0,z.jsx)(I,{fallback:a,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s},K=e=>{let t=(0,u.c)(4);if(!R()){let n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(W,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,z.jsx)(d.Suspense,{fallback:(0,z.jsx)(W,{...e}),children:(0,z.jsx)(H,{...e})}),t[2]=e,t[3]=n),n};function q(e){return e.markstreamReactEnabled}function J(e){return e.markstreamReactEnabled}export{k as a,F as i,K as n,x as o,L as r,G as t};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n}from"./runtime-switch-3ad3yzM7.js";import{n as r}from"./runtime-fetch-QCWYlAx0.js";import{an as i,hn as a,in as o,ln as s,on as c}from"./persistence-DUPZl7Oy.js";import{it as l,rt as u}from"./vendor-base-ui-CdzJ6My_.js";import{t as d}from"./platform-z2erC6Bs.js";import{n as f}from"./useUIStore-pl39iO82.js";import{n as p}from"./vendor-react-BP2cRVqX.js";import{n as m}from"./vendor-katex-DNVSTX6g.js";import{f as h,n as g,r as _}from"./vendor-reactuses-core-BpfIZ1tg.js";import{d as v,f as y,r as b}from"./button-kJNzMb1G.js";import{i as x,t as S}from"./store-D5OeM4wB.js";import{Pr as C,Ui as w}from"./useMobileNavigationStore-B24J82Xs.js";import{t as T}from"./dualLimitLru-D8Sphgua.js";import{t as E}from"./useThemeSystem-8jhE4Zyk.js";import{a as D,f as O,h as ee,i as k,m as A,o as j,p as M,t as te,u as ne,v as N}from"./image-loading-OgMEw4Jq.js";import{n as re}from"./useRuntimeAPIs-Cx8S1HLz.js";import{a as P,i as F,n as I,r as L}from"./url-DAyfGWPH.js";import{c as ie,d as R,f as z,i as ae,n as B,t as V}from"./markdown-worker-DFNZ3KJ_.js";import{n as oe}from"./useEffectiveDirectory-Dzsx_s3D.js";import{c as H,i as U,l as W,n as se,o as ce,r as le,u as ue}from"./FadeInOnReveal-BssISEuf.js";import{i as de,n as fe,t as pe}from"./markdownTheme-CV7_0QAL.js";import{i as me,r as he,t as ge}from"./markdownHeightCache-CAVQhVdd.js";import{t as _e}from"./vendor-morphdom-BbKiNDAu.js";import{t as G}from"./vendor-dompurify-CeJNOzik.js";import{t as ve}from"./vendor-pele-C1WTNWUm.js";import{t as ye}from"./vendor-marked-WVekxjAN.js";import{t as be}from"./vendor-remend-C3cXc-tf.js";var K=t(l(),1),xe=p(),Se=new T({maxEntries:100,maxBytes:8388608}),Ce=(e,t)=>{let{surface:n,interactive:r,primary:i,status:a}=t.colors,o={bg:n.elevated,fg:n.foreground,muted:n.mutedForeground,line:r.border,surface:n.muted,"surface-alt":n.background,border:r.border,accent:i.base,critical:a.error,error:a.error,"series-1":i.base,"series-2":a.info,"series-3":a.success,"series-4":a.warning,"series-5":a.error,"series-6":i.hover??i.base,"series-7":a.infoForeground,"series-8":a.successForeground},s=JSON.stringify([o,new Date().toDateString(),e]),c=Se.get(s);if(c)return c;let l;try{let{svg:t}=ve(e,{fontFamily:`system-ui, sans-serif`,autoDirection:!1,links:!1,images:!1}),n=G.sanitize(t,{USE_PROFILES:{svg:!0,svgFilters:!0},RETURN_DOM_FRAGMENT:!0}).querySelector(`svg`);if(!n)throw Error(`Missing diagram SVG`);for(let[e,t]of Object.entries(o))n.style.setProperty(`--pele-${e}`,t);l={svg:n.outerHTML}}catch{l={}}return Se.set(s,l,(s.length+(l.svg?.length??0))*2),l},we=`data-md-stream-fence`,Te=`data-md-stream-line`,Ee=`data-md-stream-src`,De=`data-md-stream-applied`,Oe=(e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)if(e[r]!==t[r])return r;return n},ke=e=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-md-stream-line`)),Ae=(e,t)=>{let n=document.createElement(`span`);return n.setAttribute(Te,String(t)),n.className=`line`,n.innerHTML=e,n},je=(e,t)=>{let n=ke(e),r=Oe(n.map(e=>e.innerHTML),t);if(n.length===0&&e.childNodes.length>0&&t.length>0){e.replaceChildren();for(let n=0;n<t.length;n+=1)n>0&&e.appendChild(document.createTextNode(`
|
|
2
|
+
`)),e.appendChild(Ae(t[n]??``,n));return{reused:0,replaced:0,added:t.length,removed:0}}let i=0;if(r<n.length&&r<t.length){let e=n[r];e&&(e.innerHTML=t[r]??``,e.setAttribute(Te,String(r)),i=1)}let a=0;for(let e=n.length-1;e>=r+i;--e){let t=n[e]?.previousSibling;t?.nodeType===Node.TEXT_NODE&&t.remove(),n[e]?.remove(),a+=1}let o=0;for(let n=r+i;n<t.length;n+=1)n>0&&e.appendChild(document.createTextNode(`
|
|
3
|
+
`)),e.appendChild(Ae(t[n]??``,n)),o+=1;return{reused:r,replaced:i,added:o,removed:a}},Me=e=>{if(e.includes(`data-md-stream-fence=`))return e;let t=e.toLowerCase().lastIndexOf(`<pre`);return t<0?e:`${e.slice(0,t)}${e.slice(t).replace(/<pre\b/i,`<pre ${we}="true"`)}`},Ne=(e,t)=>{if(!(e instanceof HTMLElement)||!(t instanceof HTMLElement)||e.getAttribute(`data-md-stream-fence`)!==`true`||t.getAttribute(`data-md-stream-fence`)!==`true`)return!1;let n=e.tagName===`CODE`?e:e.querySelector(`code`),r=t.tagName===`CODE`?t:t.querySelector(`code`);return n instanceof HTMLElement&&r instanceof HTMLElement&&n.setAttribute(Ee,r.textContent??``),!0},Pe=e=>e.getAttribute(`data-md-stream-src`)??e.textContent??``,Fe=e=>{let t=e.querySelectorAll(`pre[${we}="true"]`),n=[];return t.forEach(e=>{let t=e.querySelector(`code`);t instanceof HTMLElement&&n.push(t)}),n},Ie=e=>e.closest(`pre`)?.getAttribute(`data-md-lang`)||e.className.match(/language-([^\s"]+)/)?.[1]||`text`,Le=async(e,t,n)=>{if(n?.signal?.aborted)return;let r=Fe(e);await Promise.all(r.map(async r=>{let i=Pe(r);if(!i||n?.signal?.aborted||r.getAttribute(`data-md-stream-applied`)===i)return;let a=Ie(r);if(a===`mermaid`)return;let o=await t(i,a,n);if(!(n?.signal?.aborted||!e.contains(r)||Pe(r)!==i)){if(!o){let e=ke(r),t=document.createElement(`span`);je(r,i.split(`
|
|
4
|
+
`).map((n,r)=>{let i=e[r];return i?.textContent===n?i.innerHTML:(t.textContent=n,t.innerHTML)}));return}je(r,o),r.setAttribute(De,i),r.removeAttribute(Ee)}}))},Re=`text`,ze=/^(\d+):(\d+):(.+)$/,Be={ts:`typescript`,mts:`typescript`,cts:`typescript`,tsx:`tsx`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jsx:`jsx`,vue:`vue`,svelte:`svelte`,astro:`astro`,json:`json`,jsonc:`jsonc`,json5:`json5`,jsonl:`json`,ndjson:`json`,geojson:`json`,yaml:`yaml`,yml:`yaml`,toml:`toml`,ini:`ini`,cfg:`ini`,conf:`ini`,properties:`properties`,env:`dotenv`,css:`css`,scss:`scss`,sass:`sass`,less:`less`,styl:`stylus`,html:`html`,htm:`html`,xml:`xml`,svg:`xml`,md:`markdown`,markdown:`markdown`,mdown:`markdown`,mkd:`markdown`,mdx:`mdx`,py:`python`,pyw:`python`,pyi:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,kts:`kotlin`,swift:`swift`,scala:`scala`,c:`c`,h:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,m:`objective-c`,mm:`objective-cpp`,cs:`csharp`,fs:`fsharp`,fsx:`fsharp`,vb:`vb`,php:`php`,pl:`perl`,pm:`perl`,lua:`lua`,r:`r`,dart:`dart`,ex:`elixir`,exs:`elixir`,erl:`erlang`,hrl:`erlang`,hs:`haskell`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,groovy:`groovy`,jl:`julia`,ml:`ocaml`,mli:`ocaml`,zig:`zig`,nix:`nix`,sol:`solidity`,prisma:`prisma`,proto:`proto`,graphql:`graphql`,gql:`graphql`,sql:`sql`,sh:`shellscript`,bash:`shellscript`,zsh:`shellscript`,fish:`shellscript`,ps1:`powershell`,psm1:`powershell`,bat:`bat`,cmd:`bat`,tf:`terraform`,tfvars:`terraform`,hcl:`hcl`,diff:`diff`,patch:`diff`,csv:`csv`,tex:`latex`,vim:`viml`,wgsl:`wgsl`,glsl:`glsl`,wat:`wasm`,mermaid:`mermaid`,mmd:`mermaid`},Ve={dockerfile:`docker`,containerfile:`docker`,makefile:`make`,gnumakefile:`make`,"cmakelists.txt":`cmake`,gemfile:`ruby`,rakefile:`ruby`,podfile:`ruby`,".env":`dotenv`,".bashrc":`shellscript`,".zshrc":`shellscript`,".profile":`shellscript`},He=e=>{let t=e.split(/[\\/]/).pop()?.toLowerCase()??``;if(!t)return Re;let n=Ve[t];if(n)return n;let r=t.lastIndexOf(`.`);return r<=0?Re:Be[t.slice(r+1)]??Re},Ue=e=>{let t=e?.trim()??``;if(!t)return{lang:Re,label:Re,reference:!1};let n=ze.exec(t);if(!n){let e=t.toLowerCase();return{lang:e,label:e,reference:!1}}let[,r=``,i=``,a=``]=n,o=r===i?r:`${r}-${i}`;return{lang:He(a),label:`${a}:${o}`,reference:!0}},We=e=>e===` `||e===` `||e===`
|
|
5
|
+
`||e===`\r`,Ge=e=>e!==void 0&&e>=`0`&&e<=`9`,Ke=e=>{for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n>=11904&&n<=40959||n>=12288&&n<=12351||n>=63744&&n<=64255||n>=65280&&n<=65519)return!0}return!1},qe=e=>{for(let t=0;t<e.length;t+=1){let n=e[t];if(n===`"`||n===`'`||We(n))return!0}return!1},Je=e=>{let t=0;for(;t<e.length;){let n=e.indexOf(`$`,t);if(n<0)return;let r=e[n+1];if(r===`$`||r!==void 0&&!We(r))return n;t=n+1}},Ye=e=>{if(e[0]===`$`){if(e[1]===`$`){let t=e.indexOf(`$$`,2);return t<0?void 0:{raw:e.slice(0,t+2),text:e.slice(2,t),display:!0}}if(!(e.length<3||We(e[1])))for(let t=1;t<e.length;t+=1){let n=e[t];if(n===`\\`){t+=1;continue}if(n==="`")return;if(n!==`$`)continue;if(e[t+1]===`$`||We(e[t-1]))return;if(Ge(e[t+1]))continue;if(t===1)return;let r=e.slice(1,t);return Ke(r)||Ge(e[1])&&qe(r)?void 0:{raw:e.slice(0,t+1),text:r,display:!1}}}},q=e=>e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`),Xe=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Ze=e=>`${Xe(e.raw)}:${e.mode}:${+!!e.highlight}`,Qe=e=>/^\[[^\]]+\]:\s+\S+/m.test(e)||/^\[\^[^\]]+\]:\s+/m.test(e),$e=e=>{let t=e.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!t)return!1;let n=t[1];if(!n)return!1;let r=n[0],i=n.length,a=e.trimEnd().split(`
|
|
6
|
+
`).at(-1)?.trim()??``;return!RegExp(`^[\\t ]{0,3}${r}{${i},}[\\t ]*$`).test(a)},et=e=>{try{return be(e,{linkMode:`text-only`})}catch{return e}},tt=(e,t)=>{let n=t?`live`:`full`;if(Qe(e))return[{raw:e,src:et(e),mode:n,highlight:!0}];let r;try{r=ye.lexer(e)}catch{return[{raw:e,src:et(e),mode:n,highlight:!0}]}let i=-1;for(let e=r.length-1;e>=0;--e)if(r[e]?.type!==`space`){i=e;break}if(i<0)return[{raw:e,src:et(e),mode:n,highlight:!0}];let a=[];for(let e=0;e<r.length;e+=1){let t=r[e];if(!t||t.type===`space`)continue;let o=t.raw??``,s=e===i,c=t.type===`code`&&$e(o);a.push({raw:o,src:c?o:et(o),mode:s?n:`full`,highlight:!c})}return a.length===0?[{raw:e,src:et(e),mode:n,highlight:!0}]:a},nt=16,rt=new Map,it=(e,t)=>{let n=`${+!!t}:${e}`,r=rt.get(n);if(r)return rt.delete(n),rt.set(n,r),r;let i=tt(e,t);for(;rt.size>=nt;){let e=rt.keys().next().value;if(typeof e!=`string`)break;rt.delete(e)}return rt.set(n,i),i},at=(e,t,n)=>{try{return m.renderToString(e,{displayMode:n,throwOnError:!1})}catch{return t}},ot=ye.use({gfm:!0,breaks:!1,extensions:[{name:`inlineMath`,level:`inline`,start(e){let t=e.indexOf(`\\(`);return t<0?void 0:t},tokenizer(e){let t=/^\\\(([\s\S]+?)\\\)/.exec(e);if(t)return{type:`inlineMath`,raw:t[0],text:t[1]??``}},renderer(e){let t=e;return at(t.text,t.raw,!1)}},{name:`blockMath`,level:`block`,start(e){let t=e.indexOf(`\\[`);return t<0?void 0:t},tokenizer(e){let t=/^\\\[([\s\S]+?)\\\]/.exec(e);if(t)return{type:`blockMath`,raw:t[0],text:t[1]??``}},renderer(e){let t=e;return at(t.text,t.raw,!0)}},{name:`dollarMath`,level:`inline`,start(e){return Je(e)},tokenizer(e){let t=Ye(e);if(t)return{type:`dollarMath`,raw:t.raw,text:t.text,display:t.display}},renderer(e){let t=e;return at(t.text,t.raw,t.display)}}],renderer:{link({href:e,title:t,text:n}){let r=e??``,i=H(r);if(i)return`<a href="${q(ce(i))}" data-openchamber-agent-mention="true" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">${n}</a>`;let a=W(r);if(a)return`<a href="${q(r)}" data-skill-name="${q(a)}" class="text-primary hover:underline">${n}</a>`;let o=t?` title="${q(t)}"`:``;return`<a href="${q(r)}"${o} class="external-link" target="_blank" rel="noopener noreferrer">${n}</a>`}}}),st=e=>e.replace(/\$\$([\s\S]*?)\$\$/g,(e,t)=>{try{return m.renderToString(t,{displayMode:!0,throwOnError:!1})}catch{return`$$${t}$$`}}),ct=e=>e.indexOf(`$`)===-1?e:e.split(/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi).map((e,t)=>t%2==1?e:st(e)).join(``),lt=e=>ct(ot.parse(e)),ut=e=>{let t=lt(e.src);return e.highlight?t:Me(t)},dt=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,ft=1200,pt=(e,t)=>{let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&++n>t)return!0;return!1},mt=e=>e.replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/&/g,`&`),ht=e=>e.reference?`data-md-lang="${q(e.lang)}" data-md-label="${q(e.label)}"`:`data-md-lang="${q(e.lang)}"`,gt=async(e,t,n)=>{if(n.isCancelled?.())return null;let r=[...e.matchAll(dt)];if(r.length===0)return e;let i=e;for(let e of r){if(n.isCancelled?.())return null;let[r,a,o]=e,s=Ue(a);if(s.lang===`mermaid`&&!s.reference)continue;let c=mt(o??``);if(pt(c,n.lineLimit)){i=i.replace(r,()=>r.replace(`<pre`,`<pre ${ht(s)}`));continue}let l=await t(c,s.lang);if(n.isCancelled?.())return null;if(l){let e=l.replace(/^<pre/,`<pre ${ht(s)}`);i=i.replace(r,()=>e)}}return i},_t=(e,t)=>!t&&e.length<=480&&!e.includes("```"),vt={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:[`svg`,`path`,`g`,`rect`,`line`,`polygon`,`polyline`,`circle`,`ellipse`,`text`,`tspan`,`defs`,`marker`],ADD_ATTR:[`d`,`viewBox`,`preserveAspectRatio`,`xmlns`,`target`,`fill`,`stroke`,`stroke-width`,`transform`,`points`,`x`,`y`,`x1`,`y1`,`x2`,`y2`,`cx`,`cy`,`r`,`rx`,`ry`,`style`],FORBID_TAGS:[`script`],FORBID_CONTENTS:[`script`]},yt=!1,bt=()=>{yt||typeof window>`u`||!G.isSupported||(yt=!0,G.addHook(`uponSanitizeAttribute`,(e,t)=>{if(!(e instanceof HTMLImageElement)||t.attrName!==`src`)return;let n=typeof t.attrValue==`string`?t.attrValue:``;/^file:/i.test(n)&&(e.setAttribute(`data-md-image-source`,n),t.keepAttr=!1)}),G.addHook(`afterSanitizeAttributes`,e=>{e instanceof HTMLAnchorElement&&e.target===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`)}))},xt=e=>G.isSupported?(bt(),G.sanitize(e,vt)):``,St=`data-md-sanitize-block`,Ct=e=>{if(e.length===0)return[];if(e.length===1)return[xt(e[0])];if(!G.isSupported||typeof document>`u`)return e.map(e=>xt(e));let t=e.map((e,t)=>`<div ${St}="${t}">${e}</div>`).join(``),n=document.createElement(`div`);n.innerHTML=xt(t);let r=e.map(()=>``);return n.querySelectorAll(`[${St}]`).forEach(e=>{let t=Number(e.getAttribute(St));Number.isInteger(t)&&t>=0&&t<r.length&&(r[t]=e.innerHTML)}),r},wt=()=>s()?200:ft,Tt=240,Et=16777216,Dt=160,Ot=8388608,kt=new T({maxEntries:Tt,maxBytes:Et}),At=new T({maxEntries:Dt,maxBytes:Ot}),jt=e=>e.length*2,Mt=(e,t)=>{kt.set(e,t,jt(e)+jt(t.hash)+jt(t.html))},Nt=async(e,t,n)=>gt(e,(e,r)=>V(e,r,{signal:t,priority:n}),{lineLimit:wt(),isCancelled:()=>!!t?.aborted}),Pt=async(e,t,n)=>{if(t?.aborted)return null;let r=ut(e);if(t?.aborted)return null;let i=e.highlight?await Nt(r,t,n):r;if(i===null||t?.aborted)return null;let a=xt(i);return t?.aborted?null:a},Ft=e=>`${Xe(e)}:${e.length}`,It=e=>{let t=At.get(Ft(e));return t?.source===e?t.html:void 0},Lt=(e,t)=>{let n=Ft(e);At.set(n,{source:e,html:t},jt(n)+jt(e)+jt(t))},Rt=e=>{if(!e)return[];let t=it(e,!1),n=Array(t.length).fill(``),r=[],i=[];t.forEach((e,t)=>{let a=It(e.src);if(a!==void 0){n[t]=a;return}r.push(t),i.push(ut(e))});let a=Ct(i);return r.forEach((e,r)=>{let i=a[r]??``;n[e]=i;let o=t[e]?.src;o!==void 0&&Lt(o,i)}),n},zt=8,Bt=()=>typeof performance<`u`?performance.now():Date.now(),Vt=e=>e?.aborted?Promise.resolve(!1):new Promise(t=>{let n=!1,r=r=>{n||(n=!0,e?.removeEventListener(`abort`,a),t(r))},i=U(()=>{r(!e?.aborted)},{priority:`visible`}),a=()=>{i(),r(!1)};e?.addEventListener(`abort`,a,{once:!0})}),Ht=(e,t)=>{let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(!i)return null;let a=Xe(i.raw),o=`${t}:${r}:${i.mode}`,s=kt.get(o);if(!s||s.hash!==a)return null;n.push({id:Ze(i),html:s.html})}return n},Ut=(e,t,n)=>{let r=Ct(t.map(e=>e.html));return t.map((t,i)=>{let a=e[i],o=r[i]??``;return a&&Mt(`${n}:${i}:${a.mode}`,{hash:Xe(a.raw),html:o}),{id:t.id,html:o}})},Wt=async(e,t,n,r)=>{let i=n?`visible`:`background`,a=async(e,n)=>{if(r?.aborted)return null;let a=Xe(e.raw),o=Ze(e),s=`${t}:${n}:${e.mode}`,c=kt.get(s);if(c&&c.hash===a)return{id:o,html:c.html};let l=await Pt(e,r,i);return l===null||r?.aborted?null:(Mt(s,{hash:a,html:l}),{id:o,html:l})};if(n)return(await Promise.all(e.map(a))).filter(e=>e!==null);let o=[],s=0;for(let t=0;t<e.length&&!r?.aborted;t+=1){let n=e[t];if(!n)continue;if(Bt()>=s){if(!await Vt(r))break;s=Bt()+zt}let i=await a(n,t);i&&o.push(i)}return o},Gt=async(e,t,n,r)=>{if(!e)return[];let i=it(e,t),a=Ht(i,n);if(a)return a;let o=t?`visible`:`background`,s=[],c=[];for(let e=0;e<i.length;e+=1){let t=i[e];if(!t)continue;let r=kt.get(`${n}:${e}:${t.mode}`);r&&r.hash===Xe(t.raw)||(s.push(t),c.push(e))}if(!_t(e,t)&&s.length>0)try{let e=await ae({streaming:t,highlight:!0,highlightLineLimit:wt(),signal:r,priority:o,blocks:s});if(r?.aborted)return[];if(e&&e.length===s.length)return Ut(i,i.map((t,r)=>{let i=c.indexOf(r);if(i>=0)return e[i]??{id:Ze(t),html:``,highlight:t.highlight};let a=kt.get(`${n}:${r}:${t.mode}`);return{id:Ze(t),html:a?.html??``,highlight:t.highlight}}),n)}catch{}return Wt(i,n,t,r)},J=e=>Number.isFinite(e)&&e>0,Kt=e=>{if(typeof e==`number`)return J(e)?e:null;if(typeof e!=`string`)return null;let t=e.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!t)return null;let n=Number(t[1]);return J(n)?n:null},qt=(e,t,n)=>Math.min(n,Math.max(t,e)),Jt=6,Yt=1.25,Xt=1.0015,Zt=16,Qt=1e3,$t=.5,en=12,tn=400,nn=`[data-markdown="mermaid-block"]`,rn=e=>e.querySelector(nn)!==null,an=e=>[e.x,e.y,e.width,e.height].map(e=>{let t=Number(e.toFixed(Jt));return Object.is(t,-0)?`0`:String(t)}).join(` `),on=e=>{let t=e.viewBox?.trim().split(/[\s,]+/).map(e=>Number.parseFloat(e));if(t?.length===4){let[e,n,r,i]=t;if(Number.isFinite(e)&&Number.isFinite(n)&&J(r)&&J(i))return{x:e,y:n,width:r,height:i}}let n=Kt(e.width),r=Kt(e.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},sn=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},cn=e=>{let t=e.renderMode||`unknown`,n=e.svgMarkup??``;if(!n){let n=[e.viewBox??``,e.width??``,e.height??``];return n.some(e=>e!==``)?`${t}:bounds:${n.join(`:`)}`:`${t}:no-svg`}return[t,sn(n)].join(`:`)},ln=(e,t)=>{if(!J(t.width)||!J(t.height))return e;let n=e.width/e.height,r=t.width/t.height;if(n>r){let t=e.width/r;return{x:e.x,y:e.y-(t-e.height)/2,width:e.width,height:t}}let i=e.height*r;return{x:e.x-(i-e.width)/2,y:e.y,width:i,height:e.height}},un=({currentBox:e,viewport:t,delta:n})=>!J(t.width)||!J(t.height)||!J(e.width)||!J(e.height)?e:{x:e.x-n.x/t.width*e.width,y:e.y-n.y/t.height*e.height,width:e.width,height:e.height},dn=(e,t,n)=>{let r=e*(t===1?Zt:t===2?J(n)?n:0:1);return Number.isFinite(r)?qt(r,-1e3,Qt):0},fn=e=>{let t=null;for(let n of e){if(!t){t=n;continue}return{center:{x:(t.x+n.x)/2,y:(t.y+n.y)/2},distance:Math.hypot(n.x-t.x,n.y-t.y)}}return null},pn=(e,t)=>{let n=t.x-e.x,r=t.y-e.y;return n*n+r*r>9},mn=({currentBox:e,contentBox:t,viewport:n,pointer:r,zoomFactor:i,minScale:a,maxScale:o})=>{if(!J(n.width)||!J(n.height)||!J(i)||!J(e.width)||!J(e.height)||!J(t.width)||!J(t.height)||!J(a)||!J(o))return e;let s=Math.min(a,o),c=Math.max(a,o),l=ln(t,n),u=qt(l.width/e.width*i,s,c),d=l.width/u,f=d/(e.width/e.height),p=qt(r.x/n.width,0,1),m=qt(r.y/n.height,0,1),h=e.x+p*e.width,g=e.y+m*e.height;return{x:h-p*d,y:g-m*f,width:d,height:f}},hn=({currentBox:e,contentBox:t,viewport:n,previousGesture:r,gesture:i,minScale:a,maxScale:o})=>!J(r.distance)||!J(i.distance)?e:mn({currentBox:un({currentBox:e,viewport:n,delta:{x:i.center.x-r.center.x,y:i.center.y-r.center.y}}),contentBox:t,viewport:n,pointer:i.center,zoomFactor:i.distance/r.distance,minScale:a,maxScale:o}),gn=new WeakMap,_n=e=>e instanceof HTMLElement?gn.get(e)??null:null,vn=e=>e.querySelector(`[data-markdown="mermaid-viewport"]`)??e.querySelector(`[data-markdown="mermaid"]`),yn=e=>{let t=e.querySelector(`[data-markdown="mermaid"] svg`),n=e.querySelector(`[data-markdown="mermaid"]`);return cn({renderMode:e.getAttribute(`data-mermaid-render`),svgMarkup:n?.getAttribute(`data-md-original-svg`)??t?.outerHTML??null,viewBox:t?.getAttribute(`viewBox`),width:t?.getAttribute(`width`),height:t?.getAttribute(`height`)})},bn=e=>{let t=e.getBoundingClientRect();return{width:t.width,height:t.height}},xn=(e,t)=>({x:e.clientX-t.left,y:e.clientY-t.top}),Sn=(e,t)=>xn(e,t.getBoundingClientRect()),Cn=e=>e instanceof Element&&!!e.closest(`button, a, [role="button"]`),wn=e=>{let t=vn(e),n=e.querySelector(`[data-markdown="mermaid"] svg`);if(!t||!n)return null;let r=on({viewBox:n.getAttribute(`viewBox`),width:n.getAttribute(`width`),height:n.getAttribute(`height`)});if(!r)return null;let i=r,a=null,o=null,s=null,c=new Map,l=new Set,u=null,d=null,f=e=>{i=e,n.setAttribute(`viewBox`,an(e)),n.removeAttribute(`width`),n.removeAttribute(`height`)},p=()=>{f(ln(r,bn(t)))},m=(e,n)=>{f(mn({currentBox:i,contentBox:r,viewport:bn(t),pointer:e,zoomFactor:n,minScale:$t,maxScale:en}))},h=()=>{let e=bn(t);m({x:e.width/2,y:e.height/2},Yt)},g=()=>{let e=bn(t);m({x:e.width/2,y:e.height/2},1/Yt)},_=e=>{e.preventDefault(),e.stopPropagation();let n=dn(e.deltaY,e.deltaMode,bn(t).height);m(Sn(e,t),Xt**+-n)},v=e=>{try{t.setPointerCapture(e),l.add(e)}catch{}},y=e=>{if(l.delete(e))try{t.hasPointerCapture(e)&&t.releasePointerCapture(e)}catch{}},b=()=>{a=null,o=null,s=null,c.clear(),u=null},x=()=>{b(),e.removeAttribute(`data-mermaid-panning`),e.hasAttribute(`data-mermaid-suppress-click`)&&(d=window.setTimeout(()=>{e.removeAttribute(`data-mermaid-suppress-click`),d=null},tn))},S=n=>{if(n.pointerType!==`touch`&&n.button!==0||Cn(n.target))return;d!==null&&(window.clearTimeout(d),d=null),e.removeAttribute(`data-mermaid-suppress-click`);let r=Sn(n,t);v(n.pointerId),e.setAttribute(`data-mermaid-panning`,`true`),n.pointerType===`touch`?(c.set(n.pointerId,r),c.size>=2?(a=null,o=null,s=null,u=fn(c.values()),e.setAttribute(`data-mermaid-suppress-click`,`true`)):(a=n.pointerId,o=r,s=r)):(a=n.pointerId,o=r,s=r),n.preventDefault()},C=n=>{if(n.pointerType===`touch`){if(!c.has(n.pointerId))return;let a=Sn(n,t);if(c.set(n.pointerId,a),c.size>=2){let a=fn(c.values());u&&a&&f(hn({currentBox:i,contentBox:r,viewport:bn(t),previousGesture:u,gesture:a,minScale:$t,maxScale:en})),u=a,e.setAttribute(`data-mermaid-suppress-click`,`true`),n.preventDefault();return}}if(a!==n.pointerId||!s)return;let l=Sn(n,t);f(un({currentBox:i,viewport:bn(t),delta:{x:l.x-s.x,y:l.y-s.y}})),s=l,o&&pn(o,l)&&e.setAttribute(`data-mermaid-suppress-click`,`true`),n.preventDefault()},w=e=>{if(e.pointerType===`touch`||c.has(e.pointerId)){if(!c.has(e.pointerId))return;if(c.delete(e.pointerId),u=fn(c.values()),c.size>0){for(let[e,t]of c){a=e,o=t,s=t;break}c.size>=2&&(a=null,o=null,s=null),y(e.pointerId);return}x(),y(e.pointerId);return}a===e.pointerId&&(x(),y(e.pointerId))},T=()=>{p()};t.addEventListener(`wheel`,_,{passive:!1}),t.addEventListener(`pointerdown`,S),t.addEventListener(`pointermove`,C),t.addEventListener(`pointerup`,w),t.addEventListener(`pointercancel`,w),t.addEventListener(`lostpointercapture`,w),window.addEventListener(`resize`,T);let E=typeof ResizeObserver>`u`?null:new ResizeObserver(T);return E?.observe(t),p(),{zoomIn:h,zoomOut:g,fit:p,cleanup:()=>{t.removeEventListener(`wheel`,_),t.removeEventListener(`pointerdown`,S),t.removeEventListener(`pointermove`,C),t.removeEventListener(`pointerup`,w),t.removeEventListener(`pointercancel`,w),t.removeEventListener(`lostpointercapture`,w),window.removeEventListener(`resize`,T),E?.disconnect(),d!==null&&window.clearTimeout(d);for(let e of Array.from(l))y(e);b(),e.removeAttribute(`data-mermaid-panning`),e.removeAttribute(`data-mermaid-suppress-click`),gn.delete(e)}}},Tn=e=>{let t=new Map,n=new Map,r=()=>{for(let[r,i]of Array.from(t.entries())){let a=yn(r);(!e.contains(r)||a!==n.get(r))&&(i.cleanup(),t.delete(r),n.delete(r))}for(let r of Array.from(e.querySelectorAll(nn))){if(t.has(r)||r.querySelector(`[data-markdown="mermaid"] svg`)===null)continue;let e=wn(r);e&&(t.set(r,e),n.set(r,yn(r)),gn.set(r,e))}};return r(),{refresh:r,cleanup:()=>{for(let e of t.values())e.cleanup();t.clear(),n.clear()}}},En=new Set([`dockerfile`,`makefile`,`readme`,`license`,`.env`,`.gitignore`,`.npmrc`]),Dn=Array.from(En).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),On=e=>A(e),kn=e=>O(e),An=e=>{if(!e||e.startsWith(`--`)||e.includes(`://`)||/[<>]/.test(e)||/\s{2,}/.test(e))return!1;let t=On(e),n=t.split(`/`).filter(Boolean).pop()??t;if(!n||n===`.`||n===`..`)return!1;let r=n.toLowerCase();return En.has(r)||r.startsWith(`.`)&&r.length>1?!0:!t.includes(`/`)&&/^\d+\.\d+$/.test(n)?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(n)},jn=e=>{let t=(e||``).trim();return t?((t.startsWith("`")&&t.endsWith("`")||t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).trim()),t=t.replace(/[.,;!?]+$/g,``),t.endsWith(`)`)&&!t.includes(`(`)&&(t=t.slice(0,-1)),t.endsWith(`]`)&&!t.includes(`[`)&&(t=t.slice(0,-1)),t):``},Mn=e=>{let t=jn(e);if(!t)return``;let n=t.indexOf(`;`);n>=0&&(t=t.slice(0,n)),t=t.replace(/#.*$/,``);let r=t.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(t=r[1]??t);let i=Dn.length>0?t.match(RegExp(`^(.*(?:/|^)(${Dn})):.*$`,`i`)):null;return i&&(t=i[1]??t),jn(t)},Nn=e=>{let t=jn(e);if(!t)return null;let n=t.indexOf(`;`),r=n>=0?jn(t.slice(0,n)):t;if(!r)return null;let i=r.match(/^(.*?):(\d+)-(\d+)$/);if(i){let e=Mn(i[1]??``),t=Number.parseInt(i[2]??``,10),n=Number.parseInt(i[3]??``,10);return!e||!Number.isFinite(t)||!Number.isFinite(n)||n<t?null:{path:e,line:t,endLine:n}}let a=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(a){let e=Mn(a[1]??``),t=Number.parseInt(a[2]??``,10),n=a[3]?Number.parseInt(a[3],10):void 0;return!e||!Number.isFinite(t)?null:{path:e,line:t,column:Number.isFinite(n??NaN)?n:void 0}}let o=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(o){let e=Mn(o[1]??``),t=Number.parseInt(o[2]??``,10),n=o[3]?Number.parseInt(o[3],10):void 0;return!e||!Number.isFinite(t)?null:{path:e,line:t,column:Number.isFinite(n??NaN)?n:void 0}}let s=Mn(r);return s?{path:s}:null},Pn=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Fn=`(?:(?:[0-9][\\w.@+\\- 一-鿿]*|[一-鿿][\\w.@+\\- 一-鿿]*)|[\\w.@+\\-一-鿿]+)`,In=RegExp(`(?:[A-Za-z]:[\\\\/]|\\.{1,2}\\/|\\/)?(?:${Fn}\\/)+${Fn}\\.[A-Za-z0-9]{1,8}(?::\\d+(?:-\\d+)?(?::\\d+)?)?`,`g`),Ln=`data-openchamber-block-path-token`,Rn=`[${Ln}]`,zn=`data-openchamber-file-link`,Bn=`[${zn}="true"]`,Vn=[zn,`data-openchamber-file-ref`,`data-openchamber-file-path`,`data-openchamber-file-binary`,`title`,`role`,`tabindex`],Hn=`data-openchamber-block-paths-scanned`,Un=`data-openchamber-paragraph-paths-scanned`,Wn=`pre, code, a, script, style, button, [${zn}], ${Rn}`,Gn=2e5,Kn=e=>{let t=Nn(e);return t?An(t.path):!1},qn=e=>{let t=e.trim();return!t||t.startsWith(`#`)||t.startsWith(`?`)||t.startsWith(`//`)?!1:/^[A-Za-z]:[\\/]/.test(t)||/^file:/i.test(t)||Kn(t)&&/:\d+(?:-\d+|:\d+)?$/.test(t)?!0:!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(t)},Jn=(e,t)=>{let n=0;for(let r of e){let e=n+r.data.length;if(t<=e)return{node:r,offset:Math.max(0,t-n)};n=e}let r=e.at(-1);return r?{node:r,offset:r.data.length}:null},Yn=e=>{let t=e.querySelectorAll(`pre code`);if(t.length===0)return;let n=e.ownerDocument;if(n)for(let e of Array.from(t)){if(e.getAttribute(Hn)===`true`)continue;if((e.textContent??``).length>Gn){e.setAttribute(Hn,`true`);continue}let t=n.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=[],i=t.nextNode();for(;i;)r.push(i),i=t.nextNode();let a=e.textContent??``;if(!a.includes(`.`)){e.setAttribute(Hn,`true`);continue}Pn.lastIndex=0;let o=[],s=Pn.exec(a);for(;s;){let e=s[0];e&&Kn(e)&&o.push({start:s.index,end:s.index+e.length,raw:e}),s=Pn.exec(a)}for(let{start:e,end:t,raw:i}of o.reverse()){let a=Jn(r,e),o=Jn(r,t);if(!a||!o)continue;let s=n.createRange();s.setStart(a.node,a.offset),s.setEnd(o.node,o.offset);let c=n.createElement(`span`);c.setAttribute(Ln,`true`),c.textContent=i,s.deleteContents(),s.insertNode(c)}e.setAttribute(Hn,`true`)}},Xn=e=>{let t=e.ownerDocument;if(!t)return;let n=e.querySelectorAll(`p, li, blockquote, h1, h2, h3, h4, h5, h6, td, th`);if(n.length!==0)for(let e of Array.from(n)){if(e.getAttribute(Un)===`true`)continue;if(e.closest(Wn)){e.setAttribute(Un,`true`);continue}let n=t.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>{let t=e.parentElement;return!t||t.closest(Wn)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),r=[],i=n.nextNode();for(;i;)r.push(i),i=n.nextNode();if(r.length===0){e.setAttribute(Un,`true`);continue}let a=r.map(e=>e.data).join(``);if(!a.includes(`/`)||!a.includes(`.`)){e.setAttribute(Un,`true`);continue}In.lastIndex=0;let o=[],s=In.exec(a);for(;s;){let e=s[0];if(!e){s=In.exec(a);continue}let t=s.index>=2?a.slice(s.index-2,s.index):``;if((s.index>=1?a.charAt(s.index-1):``)===`:`||t===`:/`){s=In.exec(a);continue}Kn(e)&&o.push({start:s.index,end:s.index+e.length,raw:e}),s=In.exec(a)}for(let{start:e,end:n,raw:i}of o.reverse()){let a=Jn(r,e),o=Jn(r,n);if(!a||!o)continue;let s=t.createRange();s.setStart(a.node,a.offset),s.setEnd(o.node,o.offset);let c=t.createElement(`span`);c.setAttribute(Ln,`true`),c.textContent=i,s.deleteContents(),s.insertNode(c)}e.setAttribute(Un,`true`)}},Zn=e=>{Yn(e),Xn(e)},Qn=(e,t)=>{if(e.getAttribute(`data-openchamber-file-link`)!==`true`)return;let n=(e.getAttribute(`data-openchamber-file-ref`)||e.textContent||``).trim(),r=(t.textContent||``).trim();if(!(!n||n!==r))for(let n of Vn){let r=e.getAttribute(n);r===null?t.removeAttribute(n):t.setAttribute(n,r)}},Y=(e,t=`size-3.5`)=>`<svg class="oc-icon ${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><use href="#oc-${e}"></use></svg>`,$n={copy:Y(`file-copy`),check:Y(`check`),download:Y(`download`),zoomIn:Y(`add`),zoomOut:Y(`subtract`),fit:Y(`refresh`),textWrap:Y(`text-wrap`),image:Y(`file-image`,`size-10`),imageDownload:Y(`download`,`size-3`),imageLoading:Y(`loader-4`,`size-3.5 animate-spin motion-reduce:animate-none`)},er=`p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]`,tr=(e,t)=>{e.innerHTML=t},X=(e,t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=er,r.setAttribute(`data-md-action`,n),r.setAttribute(`title`,t),r.setAttribute(`aria-label`,t),tr(r,$n[e]),r},nr=(e,t,n)=>{let r=e.querySelector(`[data-md-code-body]`),i=e.querySelector(`pre`),a=e.querySelector(`pre code`),o=e.querySelector(`[data-md-action="toggle-code-wrap"]`);if(e.setAttribute(`data-code-wrap`,t?`true`:`false`),r?.classList.toggle(`overflow-x-auto`,!t),r?.classList.toggle(`overflow-x-hidden`,t),i?.classList.toggle(`whitespace-pre-wrap`,t),i?.classList.toggle(`break-words`,t),a?.classList.toggle(`whitespace-pre-wrap`,t),a?.classList.toggle(`break-words`,t),i&&(i.style.whiteSpace=t?`pre-wrap`:`pre`,i.style.overflowWrap=t?`anywhere`:`normal`),a&&(a.style.whiteSpace=t?`pre-wrap`:`pre`,a.style.overflowWrap=t?`anywhere`:`normal`),o){let e=t?n.disableCodeWrap:n.enableCodeWrap;o.setAttribute(`title`,e),o.setAttribute(`aria-label`,e),o.classList.toggle(`text-foreground`,t),o.classList.toggle(`opacity-100`,t),o.classList.toggle(`text-muted-foreground`,!t),o.classList.toggle(`opacity-65`,!t),o.setAttribute(`aria-pressed`,t?`true`:`false`)}},rr=e=>{let t=document.createElement(`div`);t.setAttribute(`data-md-code-line-numbers`,``),t.setAttribute(`aria-hidden`,`true`),t.className=`min-w-8 shrink-0 select-none border-r border-border/50 pr-3 text-right font-mono text-[13px] text-muted-foreground/45`;let n=e.textContent??``,r=Math.max(1,n.endsWith(`
|
|
7
|
+
`)?n.split(`
|
|
8
|
+
`).length-1:n.split(`
|
|
9
|
+
`).length);for(let e=1;e<=r;e+=1){let n=document.createElement(`div`);n.className=`tabular-nums`,n.textContent=String(e),t.appendChild(n)}return t},ir=e=>{let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=n.nextNode();for(;r;)t.push(r),r=n.nextNode();return t},ar=(e,t)=>{let n=0;for(let r of e){let e=n+r.data.length;if(t<=e)return{node:r,offset:Math.max(0,t-n)};n=e}let r=e.at(-1);return r?{node:r,offset:r.data.length}:null},or=(e,t)=>{let n=1/0,r=-1/0;for(let t=0;t<e.length;t+=1){let i=e[t];!i||i.width===0&&i.height===0||(i.top<n&&(n=i.top),i.bottom>r&&(r=i.bottom))}return!Number.isFinite(n)||r<=n?t:Math.max(t,r-n)},sr=e=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.classList.contains(`line`)),cr=(e,t,n)=>{e.style.height=`${t}px`,e.style.lineHeight=`${n}px`},lr=(e,t,n)=>{let r=document.createRange();r.setStart(e.node,e.offset),r.setEnd(t.node,t.offset);let i=Math.max(or(r.getClientRects(),n),or([r.getBoundingClientRect()],n));return r.detach(),i},ur=e=>{let t=e.querySelectorAll(`[data-component="markdown-code"]`);for(let e of Array.from(t)){let t=e.querySelector(`pre code`),n=e.querySelector(`[data-md-code-line-numbers]`);if(!t||!n)continue;let r=Array.from(n.children),i=window.getComputedStyle(t),a=Number.parseFloat(i.lineHeight)||20;n.style.fontFamily=i.fontFamily,n.style.fontSize=i.fontSize,n.style.lineHeight=`${a}px`;let o=sr(t);if(o.length===r.length){let e=o.map(e=>e.getBoundingClientRect()),t=e=>(e?.textContent??``).length===0;for(let n=0;n<r.length;n+=1){let i=r[n],s=o[n],c=e[n];if(!i||!s||!c)continue;if(t(s)){cr(i,a,a);continue}let l=o[n+1],u=e[n+1],d=u&&!t(l)?u.top:c.bottom;cr(i,or([{top:c.top,bottom:d,width:1,height:d-c.top}],a),a)}continue}let s=t.textContent??``,c=ir(t),l=0;for(let e=0;e<r.length;e+=1){let t=s.indexOf(`
|
|
10
|
+
`,l),n=t===-1?s.length:t,i=r[e];if(!i)continue;let o=ar(c,l),u=ar(c,n);!o||!u||l===n?cr(i,a,a):cr(i,lr(o,u,a),a),l=n+1}}},dr=e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>ur(e))})},fr=(e,t,n)=>{let r=e.querySelectorAll(`[data-component="markdown-code"]`);for(let e of Array.from(r)){let r=e.querySelector(`[data-md-code-body]`),i=e.querySelector(`pre`);r&&i&&!r.querySelector(`[data-md-code-line-numbers]`)&&(r.classList.add(`flex`,`gap-3`),r.insertBefore(rr(i),i)),nr(e,t,n)}dr(e)},pr=(e,t,n,r)=>{tr(e,$n.check),e.setAttribute(`title`,t),e.setAttribute(`aria-label`,t),window.setTimeout(()=>{tr(e,$n[n]),e.setAttribute(`title`,r),e.setAttribute(`aria-label`,r)},2e3)},mr=e=>{let t=e.querySelectorAll(`:not(pre) > code`);for(let e of Array.from(t))e.getAttribute(`data-markdown`)!==`inline-code`&&e.setAttribute(`data-markdown`,`inline-code`)},hr=(e,t)=>{let n=e.querySelectorAll(`pre`);for(let e of Array.from(n)){if(e.querySelector(`code.language-mermaid`))continue;let n=e.parentElement;if(!n||n.closest(`[data-component="markdown-code"]`))continue;let r=e.querySelector(`code`)?.className.match(/language-([^\s"]+)/)?.[1],i=e.getAttribute(`data-md-label`)??e.getAttribute(`data-md-lang`)??Ue(r).label,a=document.createElement(`div`);a.setAttribute(`data-component`,`markdown-code`),a.className=`my-4 group overflow-clip rounded-2xl border border-border/80 bg-[var(--surface-elevated)]`;let o=document.createElement(`div`);o.className=`flex items-center justify-between border-b border-border/70 px-3 py-1.5`;let s=document.createElement(`span`);s.className=`font-mono text-[13px] text-muted-foreground`,s.textContent=i;let c=X(`copy`,t.labels.copy,`copy-code`),l=X(`textWrap`,t.codeBlockLineWrap?t.labels.disableCodeWrap:t.labels.enableCodeWrap,`toggle-code-wrap`);o.appendChild(s);let u=document.createElement(`div`);u.className=`flex items-center gap-1`,u.appendChild(l),u.appendChild(c),o.appendChild(u);let d=document.createElement(`div`);d.setAttribute(`data-md-code-body`,``),d.className=`px-3 py-2.5 overflow-x-auto`,n.replaceChild(a,e),e.style.margin=`0`,e.style.background=`transparent`,e.classList.add(`min-w-0`,`w-full`,`flex-1`),d.appendChild(e),a.appendChild(o),a.appendChild(d),nr(a,t.codeBlockLineWrap,t.labels)}},gr=e=>{let t=e.querySelectorAll(`table`);for(let e of Array.from(t)){if(e.closest(`[data-markdown="table-wrapper"]`))continue;let t=document.createElement(`div`);t.className=`my-4`,t.setAttribute(`data-markdown`,`table-wrapper`);let n=document.createElement(`div`);n.setAttribute(`data-markdown`,`table-scroll`);let r=e.parentElement;if(r){r.replaceChild(t,e),e.setAttribute(`data-markdown`,`table`);for(let t of Array.from(e.querySelectorAll(`tr`)))t.setAttribute(`data-markdown`,`table-row`);for(let t of Array.from(e.querySelectorAll(`th`)))t.setAttribute(`data-markdown`,`table-header-cell`);for(let t of Array.from(e.querySelectorAll(`td`)))t.setAttribute(`data-markdown`,`table-cell`);n.appendChild(e),t.appendChild(n)}}},_r=0,vr=(e,t)=>{let n=e.querySelectorAll(`pre > code.language-mermaid`);for(let e of Array.from(n)){let n=e.parentElement;if(!n)continue;let r=(e.textContent??``).replace(/\s+$/,``),i=t.renderMermaid(r),a=document.createElement(`div`);a.setAttribute(`data-markdown`,`mermaid-block`),a.setAttribute(`data-md-source`,r),a.className=`group relative`;let o=document.createElement(`div`);o.setAttribute(`data-markdown`,`mermaid-scroll`);let s=document.createElement(`div`);if(s.setAttribute(`data-markdown`,`mermaid-toolbar`),s.className=`absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity`,i.svg){a.setAttribute(`data-mermaid-render`,`svg`);let e=document.createElement(`div`);e.setAttribute(`data-markdown`,`mermaid-viewport`);let n=document.createElement(`div`);n.setAttribute(`data-markdown`,`mermaid`),n.setAttribute(`data-md-original-svg`,i.svg),n.innerHTML=i.svg;let c=n.querySelector(`svg`),l=++_r;for(let[e,t]of[[`title[id]`,`aria-labelledby`],[`desc[id]`,`aria-describedby`]]){let n=c?.querySelector(e);n&&(n.id=`oc-mermaid-${l}-${n.localName}`,c?.setAttribute(t,n.id))}if(e.appendChild(n),o.appendChild(e),t.mermaidControls.showPanZoomControls&&(s.appendChild(X(`zoomIn`,t.labels.zoomInDiagram,`mermaid-zoom-in`)),s.appendChild(X(`zoomOut`,t.labels.zoomOutDiagram,`mermaid-zoom-out`)),s.appendChild(X(`fit`,t.labels.resetDiagramView,`mermaid-fit`))),t.mermaidControls.copy){let e=X(`copy`,t.labels.copyDiagram,`mermaid-copy`);e.setAttribute(`data-md-source`,r),s.appendChild(e)}if(t.mermaidControls.download){let e=X(`download`,t.labels.downloadDiagram,`mermaid-download`);e.setAttribute(`data-md-svg`,`1`),s.appendChild(e)}}else{a.setAttribute(`data-mermaid-render`,`source`);let e=document.createElement(`pre`);if(e.setAttribute(`data-markdown`,`mermaid-source`),e.textContent=r,o.appendChild(e),t.mermaidControls.copy){let e=X(`copy`,t.labels.copyDiagram,`mermaid-copy`);e.setAttribute(`data-md-source`,r),s.appendChild(e)}}a.appendChild(o),a.appendChild(s);let c=n.parentElement;c&&c.replaceChild(a,n)}},yr=(e,t)=>{let n=e.querySelectorAll(`a[href]`);for(let e of Array.from(n)){if(e.getAttribute(`data-md-link-decorated`)===`true`||e.getAttribute(`data-openchamber-file-link`)===`true`)continue;let n=e.getAttribute(`href`)??``;if(!L(n))continue;e.setAttribute(`data-md-link-decorated`,`true`);let r=I(n);if(r){let t=document.createElement(`span`);t.className=`mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle`;let n=document.createElement(`img`);n.setAttribute(`data-md-link-favicon`,`true`),n.src=r,n.alt=``,n.setAttribute(`aria-hidden`,`true`),n.loading=`lazy`,n.decoding=`async`,n.className=`size-3.5 rounded-sm`,n.addEventListener(`error`,()=>t.remove(),{once:!0}),t.appendChild(n),e.parentNode?.insertBefore(t,e)}if(t.onPreviewLoopback&&F(n)){let r=document.createElement(`button`);r.type=`button`,r.className=`ml-1 align-middle ${er}`,r.setAttribute(`data-md-action`,`preview-loopback`),r.setAttribute(`data-md-url`,n),r.setAttribute(`title`,t.labels.previewTitle),r.setAttribute(`aria-label`,t.labels.previewLabel),tr(r,$n.download),e.parentNode?.insertBefore(r,e.nextSibling)}}},br=`img:not([data-md-link-favicon="true"])`,xr=`[data-md-image-presentation="true"]`,Sr=`data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="576" height="324" viewBox="0 0 576 324"%3E%3C/svg%3E`,Cr=[`block`,`max-w-full`,`rounded-xl`,`border`,`border-border/80`,`bg-[var(--surface-muted)]`,`transition-colors`,`focus-visible:outline`,`focus-visible:outline-2`,`focus-visible:outline-offset-2`,`focus-visible:outline-[var(--interactive-focus-ring)]`],wr=[`cursor-pointer`,`hover:bg-interactive-hover/60`],Tr=[`object-contain`],Er=e=>{let t=e.parentElement;if(t?.matches(xr))return t;let n=document.createElement(`span`);n.setAttribute(`data-md-image-presentation`,`true`),n.className=`relative my-4 block w-fit max-w-full`;let r=document.createElement(`span`);r.setAttribute(`data-md-image-placeholder-visual`,`true`),r.setAttribute(`aria-hidden`,`true`),r.className=`pointer-events-none absolute inset-0 flex items-center justify-center text-muted-foreground`,r.classList.add(`oc-image-loading`),w()&&n.setAttribute(`data-mobile-image`,`true`);let i=document.createElement(`span`);i.className=`relative flex size-14 items-center justify-center rounded-2xl border border-border/80 bg-[var(--surface-elevated)] shadow-sm`,tr(i,$n.image);let a=document.createElement(`span`);a.setAttribute(`data-md-image-download-badge`,`true`),a.className=`absolute -right-1.5 -bottom-1.5 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] text-foreground shadow-sm`,tr(a,$n.imageDownload);let o=document.createElement(`span`);return o.setAttribute(`data-md-image-loading-badge`,`true`),o.className=`absolute -right-1.5 -bottom-1.5 hidden size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] text-foreground shadow-sm`,tr(o,$n.imageLoading),i.appendChild(a),i.appendChild(o),r.appendChild(i),t?.replaceChild(n,e),n.appendChild(e),n.appendChild(r),n},Dr=e=>{e.src=Sr,e.setAttribute(`data-md-placeholder-source`,Sr),e.setAttribute(`data-md-image-state`,`placeholder`),e.classList.add(...Tr)},Or=e=>{e.removeAttribute(`data-md-image-state`),e.removeAttribute(`data-md-placeholder-source`),e.removeAttribute(`aria-busy`),e.classList.remove(...Tr)},kr=(e,t)=>{if(!t.imagePreviewEnabled)return;let n=e.querySelectorAll(br);for(let e of Array.from(n)){let n=e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,r=j(n,t.imageEffectiveDirectory);if(!k(r)){e.setAttribute(`data-md-image-source`,n),Er(e),e.setAttribute(`data-md-image-state`,e.complete&&e.naturalWidth>0?`loaded`:`loading`);continue}e.classList.add(...Cr,...wr),e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-md-image-source`,n),Er(e),Dr(e)}},Ar=(e,t)=>{mr(e),vr(e,t),hr(e,t),gr(e),yr(e,t),kr(e,t),Zn(e)},jr=(e,t,n)=>{let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},Mr=(e,t)=>{let n=e=>{let n=e.target;if(!(n instanceof Element))return;let r=n.closest(`[data-md-action]`);if(!r)return;let i=r.getAttribute(`data-md-action`)??``;if(i===`copy-code`){let e=r.closest(`[data-component="markdown-code"]`)?.querySelector(`code`)?.textContent??``;e&&v(e).then(()=>pr(r,t.labels.copied,`copy`,t.labels.copy));return}if(i===`toggle-code-wrap`){e.preventDefault(),t.onToggleCodeBlockLineWrap?.();return}if(i===`mermaid-copy`){let e=r.getAttribute(`data-md-source`)??``;e&&v(e).then(()=>pr(r,t.labels.copied,`copy`,t.labels.copyDiagram));return}if(i===`mermaid-zoom-in`||i===`mermaid-zoom-out`||i===`mermaid-fit`){e.preventDefault();let t=_n(r.closest(`[data-markdown="mermaid-block"]`));i===`mermaid-zoom-in`?t?.zoomIn():i===`mermaid-zoom-out`?t?.zoomOut():t?.fit();return}if(i===`mermaid-download`){let e=r.closest(`[data-markdown="mermaid-block"]`)?.querySelector(`[data-markdown="mermaid"]`),t=e?.getAttribute(`data-md-original-svg`)??e?.innerHTML??``;t&&jr(`diagram.svg`,t,`image/svg+xml;charset=utf-8`);return}if(i===`preview-loopback`){e.preventDefault();let n=r.getAttribute(`data-md-url`)??``;n&&t.onPreviewLoopback?.(n);return}};return e.addEventListener(`click`,n),()=>e.removeEventListener(`click`,n)},Nr=`Open file`,Pr=e=>{let{dictionary:t}=x.getState();C.warning(S(t,e))},Fr=4,Ir=1e3,Lr=200,Rr=80,zr=40,Z=new Map,Br=new Map,Vr=(e,t)=>JSON.stringify([n(),t,e]),Hr=0,Ur=[],Wr=()=>s()?Lr:Ir,Gr=()=>s()?zr:Rr,Kr=(e,t)=>{Br.set(e,t)},qr=()=>{let e=Z.keys().next().value;typeof e==`string`&&(Z.delete(e),Br.delete(e))},Jr=(e,t)=>{let n=Wr();for(;Z.size>=n;)qr();Z.set(e,t)},Yr=(e,t=``)=>{let n=On(e);if(n)return Br.get(Vr(n,t))},Xr=e=>{if(e.tagName.toLowerCase()===`a`){let t=e.getAttribute(`href`)?.trim();if(t&&Kn(t))return t}return(e.textContent||``).trim()},Zr=(e,t)=>{let n=Nn(e);if(!n||!An(n.path))return null;let r=kn(n.path)?On(n.path):ee(t,n.path);return r?{...n,resolvedPath:r}:null},Qr=(e,t=``)=>{let n=On(e);if(!n)return Promise.resolve({exists:!1,isBinary:!1});let i=Vr(n,t),a=Z.get(i);if(a)return Z.delete(i),Z.set(i,a),a;let o=new Promise((e,a)=>{let s=()=>{Hr+=1,r(`/api/fs/stat?path=${encodeURIComponent(n)}&optional=true`,{method:`GET`,cache:`no-store`,...t?{query:{directory:t}}:{}}).then(async t=>{if(!t.ok)throw Error(`File reference probe failed (${t.status})`);let n=await t.json();if(!n||typeof n.exists!=`boolean`&&n.isFile!==!0)throw Error(`Invalid file reference probe response`);let r={exists:n.exists!==!1,isBinary:n.isBinary===!0};Kr(i,r),e(r)}).catch(e=>{Z.get(i)===o&&(Z.delete(i),Br.delete(i)),a(e)}).finally(()=>{Hr=Math.max(0,Hr-1),Ur.shift()?.()})};if(Hr<Fr){s();return}Ur.push(s)});return Jr(i,o),o},$r=(e,t)=>{if(!(c()&&i()&&!M(e,t)))return Qr(e,t);let n=On(e);if(!n)return Promise.resolve({exists:!1,isBinary:!1});let r=Vr(n,t),a=Z.get(r);if(a)return Z.delete(r),Z.set(r,a),a;let s=o(e).then(e=>{let t={exists:!0,isBinary:e===!0};return Kr(r,t),t});return Jr(r,s),s},ei=(e,t,n)=>!(!t.exists||n&&t.isBinary&&!z(e)&&!R(e)),ti=(e,t)=>e||ne(e,t),ni=async(e,t,n)=>{let r=Zr(e,n.effectiveDirectory);if(!r)return;let i=r.resolvedPath.toLowerCase().endsWith(`.app`);if((t||i)&&!z(r.resolvedPath)&&!R(r.resolvedPath)){if(await a(r.resolvedPath))return;Pr(`chat.fileReference.notice.binaryExternal`)}if(z(r.resolvedPath)&&n.onShowPopup){let e=r.resolvedPath.split(`/`).filter(Boolean).pop()??r.resolvedPath;n.onShowPopup({open:!0,title:e,content:``,metadata:{tool:`image-preview`,filename:e,mime:ie(r.resolvedPath)},image:{url:r.resolvedPath,filename:e,mimeType:ie(r.resolvedPath)}});return}let o=ti(n.effectiveDirectory,r.resolvedPath),s=R(r.resolvedPath);if(n.preferRuntimeEditor&&n.editor&&!s){n.editor.openFile(r.resolvedPath,Number.isFinite(r.line??NaN)?Math.max(1,Math.trunc(r.line)):void 0,Number.isFinite(r.column??NaN)?Math.max(1,Math.trunc(r.column)):void 0);return}let c=f.getState();if(s){c.openContextFile(o,r.resolvedPath,{viewerMode:`preview`});return}if(Number.isFinite(r.line??NaN)){c.openContextFileAtLine(o,r.resolvedPath,Math.max(1,Math.trunc(r.line)),Number.isFinite(r.column??NaN)?Math.max(1,Math.trunc(r.column)):1);return}c.openContextFile(o,r.resolvedPath)},ri=async(e,t)=>{await ni(e.getAttribute(`data-openchamber-file-ref`)||Xr(e),e.getAttribute(`data-openchamber-file-binary`)===`true`,t)},ii=e({MarkdownRenderer:()=>Oi,SimpleMarkdownRenderer:()=>ki}),Q=u(),ai=()=>{let e=(0,xe.c)(4),t=E(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=N(!1),e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=N(!0),e[1]=i):i=e[1];let a=i,o;return e[2]===t?.currentTheme?o=e[3]:(o=t?.currentTheme??(typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?a:r),e[2]=t?.currentTheme,e[3]=o),o},oi=e=>{let t=(0,xe.c)(4),{containerRef:n,enabled:r,effectiveDirectory:i,openInAppBrowser:a}=e,o;t[0]!==i||t[1]!==r||t[2]!==a?(o=e=>{if(r===!1||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;let t=e.target;if(!(t instanceof Element)||t.closest($))return;let n=t.closest(`a[href]`);if(!(n instanceof HTMLAnchorElement)||n.getAttribute(`data-openchamber-file-link`)===`true`)return;let o=n.getAttribute(`href`)??``;if(qn(o)){e.preventDefault(),e.stopPropagation();return}if(!L(o))return;e.preventDefault(),e.stopPropagation();let s=(i||``).trim();if(!w()&&s&&a){a(s,o);return}P(o)},t[0]=i,t[1]=r,t[2]=a,t[3]=o):o=t[3];let s=g(o);_(`click`,s,n)},$=`img:not([data-md-link-favicon="true"])`,si=e=>e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,ci=({containerRef:e,effectiveDirectory:t,onShowPopup:r})=>{let i=K.useRef(null);i.current??=n();let a=i.current,o=!!r,s=g(e=>r?.(e)),c=K.useRef(()=>{}),l=K.useRef(new Map),u=K.useRef(null),d=K.useMemo(()=>e=>c.current(e),[]);return K.useLayoutEffect(()=>{let n=l.current;if(u.current!==null&&(clearTimeout(u.current),u.current=null),c.current=()=>{},!o){for(let[e,t]of n)t.controller?.abort(),t.objectUrl&&D(t.objectUrl),n.delete(e);return}let r=e.current;if(!r)return;let i=e=>{let t=Array.from(r.querySelectorAll($));if(t.indexOf(e)<0)return;let n=t.map(e=>({url:si(e),filename:e.alt||si(e)||void 0})).filter(e=>e.url),i=si(e),a=n.findIndex(e=>e.url===i),o=e.alt||i;s({open:!0,title:o,content:``,metadata:{tool:`image-preview`,filename:o},previewSource:e,image:{url:i,filename:o,gallery:n,index:Math.max(0,a)}})},d=e=>{let t=n.get(e);t&&(t.controller?.abort(),t.objectUrl&&D(t.objectUrl),n.delete(e))},f=e=>{let n=si(e),r=j(n,t);if(k(r))return`${a}\n${t}\n${n}`},p=e=>{let t=f(e);if(!t){d(e);return}let r=n.get(e);if(r?.key===t)return r;d(e);let i={key:t};return n.set(e,i),i},m=(e,i)=>{if(i.controller||i.objectUrl||!r.contains(e))return;let a=si(e),o=j(a,t);if(!k(o)){d(e);return}let s=new AbortController;i.controller=s,e.setAttribute(`data-md-image-state`,`loading`),e.setAttribute(`aria-busy`,`true`),te(o.path,s.signal).then(t=>{let r=n.get(e);if(!r||r!==i||r.controller!==s||s.signal.aborted){D(t);return}r.controller=void 0,r.objectUrl=t,e.src=t}).catch(()=>{let t=n.get(e);t===i&&(t.controller=void 0,e.removeAttribute(`aria-busy`),e.setAttribute(`data-md-image-state`,`error`))})};c.current=e=>{for(let[t,r]of n)(!e.contains(t)||f(t)!==r.key)&&d(t);for(let t of Array.from(e.querySelectorAll($))){let e=p(t);e&&!e.objectUrl&&m(t,e)}},c.current(r);let h=e=>{let t=p(e);if(t&&!t.objectUrl){m(e,t);return}i(e)},g=e=>{let n=si(e);n&&de({sourceUrl:n,displayUrl:e.currentSrc||e.src||void 0,filename:e.alt||n,effectiveDirectory:t})},_=ue(),v=e=>si(e)||e.src||`markdown-image`,y=e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest($);if(n){if(_.consumeClick(v(n))){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),e.stopPropagation(),h(n)}},b=e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||(e.preventDefault(),e.stopPropagation(),h(t))},x=e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest($);n&&_.start({pointerId:e.pointerId,key:v(n),clientX:e.clientX,clientY:e.clientY,onTrigger:()=>g(n)})},S=e=>{_.move(e.pointerId,e.clientX,e.clientY)},C=e=>{_.end(e.pointerId)},w=e=>{_.cancel(e.pointerId)},T=e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest($);n&&(e.preventDefault(),e.stopPropagation(),_.openFromContextMenu(v(n),()=>g(n)))},E=e=>{let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||t.getAttribute(`src`)!==t.getAttribute(`data-md-placeholder-source`)&&(Or(t),t.setAttribute(`data-md-image-state`,`loaded`))},O=e=>{let t=e.target;!(t instanceof HTMLImageElement)||!t.matches($)||(t.removeAttribute(`aria-busy`),t.setAttribute(`data-md-image-state`,`error`))};return r.addEventListener(`load`,E,!0),r.addEventListener(`error`,O,!0),r.addEventListener(`click`,y),r.addEventListener(`keydown`,b),r.addEventListener(`pointerdown`,x),r.addEventListener(`pointermove`,S),r.addEventListener(`pointerup`,C),r.addEventListener(`pointercancel`,w),r.addEventListener(`contextmenu`,T),()=>{c.current=()=>{},_.reset(),r.removeEventListener(`load`,E,!0),r.removeEventListener(`error`,O,!0),r.removeEventListener(`click`,y),r.removeEventListener(`keydown`,b),r.removeEventListener(`pointerdown`,x),r.removeEventListener(`pointermove`,S),r.removeEventListener(`pointerup`,C),r.removeEventListener(`pointercancel`,w),r.removeEventListener(`contextmenu`,T),u.current=setTimeout(()=>{u.current=null;for(let e of Array.from(n.keys()))r.contains(e)&&Dr(e),d(e)},0)}},[e,t,o,a]),{reconcileMarkdownImageResources:d,transportIdentity:a}},li={download:!0,copy:!0,showPanZoomControls:!0},ui=!0,di=e=>{let t=e.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return t?e.slice(t[0].length):e},fi=160,pi=e=>{let t=(0,xe.c)(8),{containerRef:n,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,enabled:s}=e,c=K.useRef(null),l,u;t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a?(l=()=>{let e=n.current;if(!e)return;let t=!1,l=w(),u=Gr(),d=s,f=Ai,p=()=>{let t=e.querySelectorAll(Bn);for(let e of Array.from(t))f(e)};if(!d){p();return}let m=e=>{let n=e===void 0?0:e;if(c.current!==null&&typeof window<`u`&&window.clearTimeout(c.current),typeof window>`u`){h();return}c.current=window.setTimeout(()=>{c.current=null,window.requestAnimationFrame(()=>{t||h()})},n)},h=()=>{let n=e.querySelectorAll(`[data-markdown="inline-code"], a, ${Rn}`),i=0;for(let a of Array.from(n)){let n=Zr(Xr(a),r);if(!n){f(a);continue}if(i>=u){f(a);continue}i+=1,(a.getAttribute(`data-openchamber-file-link`)!==`true`||a.getAttribute(`data-openchamber-file-path`)!==n.resolvedPath)&&$r(n.resolvedPath,r).then(i=>{if(t||!e.contains(a))return;let o=Xr(a),s=Zr(o,r);if(!(!s||s.resolvedPath!==n.resolvedPath)){if(!ei(s.resolvedPath,i,l)){f(a);return}a.setAttribute(`data-openchamber-file-link`,`true`),a.setAttribute(`data-openchamber-file-ref`,o),a.setAttribute(`data-openchamber-file-path`,s.resolvedPath),a.setAttribute(`data-openchamber-file-binary`,String(i.isBinary)),a.setAttribute(`title`,Nr),a.tagName.toLowerCase()!==`a`&&(a.setAttribute(`role`,`button`),a.setAttribute(`tabindex`,`0`))}}).catch(ji)}},g=e=>ri(e,{effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o}),_=e=>{let t=e.target;if(!(t instanceof Element)||t.closest($))return;let n=t.closest(Bn);n instanceof HTMLElement&&(e.preventDefault(),e.stopPropagation(),g(n))},v=e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target;!(t instanceof HTMLElement)||t.getAttribute(`data-openchamber-file-link`)!==`true`||(e.preventDefault(),e.stopPropagation(),g(t))};m(fi);let y=new MutationObserver(()=>{m(fi)});return y.observe(e,{childList:!0,subtree:!0}),e.addEventListener(`click`,_),e.addEventListener(`keydown`,v),()=>{t=!0,c.current!==null&&typeof window<`u`&&window.clearTimeout(c.current),c.current=null,y.disconnect(),e.removeEventListener(`click`,_),e.removeEventListener(`keydown`,v)}},u=[n,i,r,o,a,s],t[0]=n,t[1]=i,t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=l,t[7]=u):(l=t[6],u=t[7]),K.useEffect(l,u)},mi=({containerRef:e,onShowPopup:t,enableFullscreen:n,enablePanZoom:r,allowMermaidWheelEvents:i})=>{let a=g(e=>t?.(e)),o=!!t,s=g(t=>{if(!n||!o)return;let r=e.current;if(!r)return;let i=t.target;if(!(i instanceof Element)||i.closest(`button, a, [role="button"]`))return;let s=i.closest(nn);if(!s)return;if(s instanceof HTMLElement&&s.hasAttribute(`data-mermaid-suppress-click`)){s.removeAttribute(`data-mermaid-suppress-click`);return}let c=Array.from(r.querySelectorAll(nn)).indexOf(s);if(c<0)return;let l=s instanceof HTMLElement?s.getAttribute(`data-md-source`):null;if(!l||l.trim().length===0)return;let u=`Diagram ${c+1}`;a({open:!0,title:u,content:``,metadata:{tool:`mermaid-preview`,filename:u},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(l)}`,source:l,filename:u},previewSource:s instanceof HTMLElement?s:void 0})}),c=g(e=>{if(i||r)return;let t=e.target;t instanceof Element&&t.closest(`[data-markdown="mermaid-block"]`)&&e.stopPropagation()});_(`click`,s,e),K.useEffect(()=>{let t=e.current;if(t)return t.addEventListener(`wheel`,c,{capture:!0,passive:!0}),()=>{t.removeEventListener(`wheel`,c,!0)}},[e])},hi=24,gi=1,_i=12,vi=/[\s.,!?;:)\]]/,yi=(e,t)=>{let n=e<=12?2:e<=48?4:e<=96?8:Math.min(24,Math.ceil(e/8));return Math.max(1,Math.round(t/hi*n))},bi=(e,t)=>yi(e,t)*(1e3/t),xi=(e,t,n)=>{let r=Math.min(e.length,t+n);for(let t=r;t<Math.min(e.length,r+8);t+=1)if(vi.test(e[t]??``))return t+1;return r},Si=(e,t,n)=>{let[r,i]=K.useState(()=>t?0:e.length),a=K.useRef(r),o=K.useRef(0),s=K.useRef(null);return a.current=r,K.useEffect(()=>{if(!t||typeof window>`u`){o.current=0,s.current=null,i(e.length);return}a.current>e.length&&(a.current=e.length,o.current=0,i(e.length));let r=null,c=t=>{let l=Math.min(a.current,e.length);if(l>=e.length){r=null,s.current=null;return}let u=s.current;if(u===null){s.current=t,r=window.requestAnimationFrame(c);return}let d=Math.min(t-u,100);s.current=t,o.current+=bi(e.length-l,n)*(d/1e3);let f=Math.min(_i,Math.floor(o.current));if(f>=gi){o.current-=f;let t=xi(e,l,f);a.current=t,i(t)}r=window.requestAnimationFrame(c)};return a.current<e.length&&(r=window.requestAnimationFrame(c)),()=>{r!==null&&window.cancelAnimationFrame(r)}},[e,t,n]),t?e.slice(0,Math.min(r,e.length)):e},Ci=(e,t,r,i=li,a=n(),o=``,s=!1)=>{let{t:c}=y(),l=K.useMemo(()=>({copy:c(`markdownRenderer.code.actions.copyTitle`),copied:c(`markdownRenderer.code.actions.copiedTitle`),enableCodeWrap:c(`markdownRenderer.code.actions.enableWrapTitle`),disableCodeWrap:c(`markdownRenderer.code.actions.disableWrapTitle`),copyDiagram:c(`markdownRenderer.mermaid.actions.copySourceTitle`),downloadDiagram:c(`markdownRenderer.mermaid.actions.downloadSvgTitle`),zoomInDiagram:c(`markdownRenderer.mermaid.actions.zoomInTitle`),zoomOutDiagram:c(`markdownRenderer.mermaid.actions.zoomOutTitle`),resetDiagramView:c(`markdownRenderer.mermaid.actions.resetViewTitle`),previewLabel:c(`terminalView.preview.open`),previewTitle:c(`terminalView.preview.openTitle`)}),[c]),u=f(e=>e.codeBlockLineWrap),d=f(e=>e.setCodeBlockLineWrap),p=g(()=>{d(!f.getState().codeBlockLineWrap)});return K.useMemo(()=>({labels:l,mermaidControls:i,codeBlockLineWrap:u,deferCodeLineNumberSync:t,onToggleCodeBlockLineWrap:p,renderMermaid:t=>Ce(t,e),onPreviewLoopback:r,imageTransportIdentity:a,imageEffectiveDirectory:o,imagePreviewEnabled:s}),[e,l,i,u,t,r,a,o,s])},wi=({containerRef:e,text:t,streaming:n,cacheKey:r,syntaxVars:i,ctx:a,reconcileMarkdownImageResources:o,onRichContentReady:s})=>{K.useEffect(()=>{pe()},[]);let c=K.useRef(null),l=g(()=>{s?.()}),u=g(()=>{let t=e.current;if(t){if(!c.current){if(!rn(t))return;c.current=Tn(t);return}c.current.refresh()}});K.useLayoutEffect(()=>{let r=e.current,i=r?.querySelector(`[data-markdown-content]`)??r;if(i&&t&&i.childNodes.length===0){for(let e of Rt(t)){let t=document.createElement(`div`);t.setAttribute(`data-md-block`,``),t.style.display=`contents`,t.innerHTML=e,Ar(t,a),i.appendChild(t)}o(i),n||l()}},[e,a,o,n,t]),K.useEffect(()=>()=>{c.current?.cleanup(),c.current=null},[]),K.useEffect(()=>{let i=e.current;if(!i)return;let s=i.querySelector(`[data-markdown-content]`)??i,c=!0,d=new AbortController,f=()=>{},p=()=>{},m=()=>{if(!c||n||d.signal.aborted)return;s.replaceChildren();let e=document.createElement(`div`);e.setAttribute(`data-md-block`,``),e.setAttribute(`data-md-render-fallback`,`text`),e.style.display=`contents`;let r=document.createElement(`span`);r.style.whiteSpace=`pre-wrap`,r.textContent=t,e.appendChild(r),s.appendChild(e),o(s),l()},h=e=>{if(!c)return;let t=Array.from(s.children);e.forEach((e,n)=>{let r=t[n];if(r||(r=document.createElement(`div`),r.setAttribute(`data-md-block`,``),r.style.display=`contents`,s.appendChild(r)),r.getAttribute(`data-md-id`)===e.id)return;let i=document.createElement(`div`);i.innerHTML=e.html,Ar(i,a);let o=rn(r),c=rn(i);_e(r,i,{childrenOnly:!0,onBeforeElUpdated:(e,t)=>{if(Ne(e,t))return!1;if(Qn(e,t),e instanceof HTMLImageElement&&t instanceof HTMLImageElement){let n=e.getAttribute(`data-md-image-source`);if(n&&n===t.getAttribute(`data-md-image-source`)){let n=e.getAttribute(`src`);n===null?t.removeAttribute(`src`):t.setAttribute(`src`,n),t.className=e.className;for(let n of[`data-md-image-state`,`data-md-placeholder-source`,`aria-busy`]){let r=e.getAttribute(n);r===null?t.removeAttribute(n):t.setAttribute(n,r)}}}return!e.isEqualNode(t)}}),r.setAttribute(`data-md-id`,e.id),(o||c||rn(r))&&u()});let n=rn(s),r=!1;for(let n=t.length-1;n>=e.length;--n){let e=t[n];e&&rn(e)&&(r=!0),e?.remove()}(r||t.length>e.length&&n)&&u(),o(s),a.deferCodeLineNumberSync||fr(s,a.codeBlockLineWrap,a.labels),Le(s,B,{signal:d.signal,priority:`visible`}),l()},g=e=>{try{h(e)}catch{m()}},_=()=>{Gt(t,n,r,d.signal).then(e=>{if(c){if(n){g(e);return}p=U(()=>g(e),{priority:`visible`})}}).catch(m)};return n?_():f=U(_,{priority:`visible`}),()=>{c=!1,d.abort(),f(),p()}},[e,t,n,r,a,o]),K.useEffect(()=>{let t=e.current;if(t)return Mr(t,a)},[e,a]),K.useEffect(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;if(n)for(let[e,t]of Object.entries(i))n.style.setProperty(e,t)},[e,i]),K.useEffect(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;n&&(a.deferCodeLineNumberSync||fr(n,a.codeBlockLineWrap,a.labels))},[e,a.codeBlockLineWrap,a.deferCodeLineNumberSync,a.labels]);let d=K.useRef(null),f=g(()=>{let t=e.current,n=t?.querySelector(`[data-markdown-content]`)??t;n&&(d.current!==null&&window.cancelAnimationFrame(d.current),d.current=window.requestAnimationFrame(()=>{d.current=null,ur(n)}))});h(e,f),K.useEffect(()=>()=>{d.current!==null&&window.cancelAnimationFrame(d.current)},[])},Ti=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,Ei=e=>{let t=(0,xe.c)(4),[n,r]=K.useState(e),i=K.useRef(e),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{i.current||(i.current=!0,r(!0))},t[0]=a):a=t[0];let o=g(a),s;return t[1]!==o||t[2]!==n?(s=[n,o],t[1]=o,t[2]=n,t[3]=s):s=t[3],s},Di=(e,t,n)=>{let r=K.useRef(n);r.current=n;let i=K.useRef(t);i.current=t;let a=g(e=>{if(!r.current)return;let t=e[0];if(!t)return;let n=t.borderBoxSize?.[0],a=n?n.blockSize:t.contentRect.height,o=n?n.inlineSize:t.contentRect.width;he(i.current,a,o)});h(e,a)},Oi=K.memo(e=>{let t=(0,xe.c)(54),{content:n,part:r,messageId:i,isAnimated:a,skipFadeIn:o,className:s,isStreaming:c,disableStreamAnimation:l,variant:u,onShowPopup:f,enableFileReferences:p}=e,m=a===void 0||a,h=o!==void 0&&o,_=c!==void 0&&c,v=l!==void 0&&l,y=u===void 0?`assistant`:u,x=p===void 0||p,S=ai(),{editor:C,runtime:w}=re(),T=K.useRef(null),E=oe()??``,D=g(Mi),O;t[0]!==E||t[1]!==D?(O=e=>{E&&D(E,e)},t[0]=E,t[1]=D,t[2]=O):O=t[2];let ee=g(O),k=_&&!v,A;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(A=le(d()),t[3]=A):A=t[3];let j=Si(n,k,A.markdownPaceMs),[M,te]=Ei(k),ne;t[4]===f?ne=t[5]:(ne={containerRef:T,onShowPopup:f,enableFullscreen:ui,enablePanZoom:li.showPanZoomControls},t[4]=f,t[5]=ne),mi(ne);let N=x&&!_,P;t[6]!==C||t[7]!==E||t[8]!==f||t[9]!==w.isVSCode||t[10]!==N?(P={containerRef:T,effectiveDirectory:E,editor:C,preferRuntimeEditor:w.isVSCode,onShowPopup:f,enabled:N},t[6]=C,t[7]=E,t[8]=f,t[9]=w.isVSCode,t[10]=N,t[11]=P):P=t[11],pi(P);let F;t[12]!==E||t[13]!==D?(F={containerRef:T,effectiveDirectory:E,openInAppBrowser:D},t[12]=E,t[13]=D,t[14]=F):F=t[14],oi(F);let I;t[15]!==E||t[16]!==f?(I={containerRef:T,effectiveDirectory:E,onShowPopup:f},t[15]=E,t[16]=f,t[17]=I):I=t[17];let{reconcileMarkdownImageResources:L,transportIdentity:ie}=ci(I),R;t[18]===S?R=t[19]:(R=fe(S),t[18]=S,t[19]=R);let z=R,ae=Ci(S,k,E?ee:void 0,li,ie,E,!!f),B=`markdown-${r?.id?`part-${r.id}`:`message-${i}`}`,V;t[20]!==B||t[21]!==ae||t[22]!==k||t[23]!==j||t[24]!==L||t[25]!==te||t[26]!==z?(V={containerRef:T,text:j,streaming:k,cacheKey:B,syntaxVars:z,ctx:ae,reconcileMarkdownImageResources:L,onRichContentReady:te},t[20]=B,t[21]=ae,t[22]=k,t[23]=j,t[24]=L,t[25]=te,t[26]=z,t[27]=V):V=t[27],wi(V);let H;t[28]!==n||t[29]!==y?(H=ge(n,y),t[28]=n,t[29]=y,t[30]=H):H=t[30],Di(T,H,M&&!k);let U=!M||void 0,W;t[31]===s?W=t[32]:(W=b(`relative break-words w-full min-w-0`,s),t[31]=s,t[32]=W);let ce=M?`true`:`false`,ue=M?`ready`:`pending`,de;t[33]!==j||t[34]!==M||t[35]!==y?(de=!M&&(0,Q.jsx)(`div`,{className:b(Ti(y),`pointer-events-none absolute inset-0 overflow-clip`),children:(0,Q.jsx)(me,{content:j})}),t[33]=j,t[34]=M,t[35]=y,t[36]=de):de=t[36];let pe=!M||void 0,he;t[37]!==M||t[38]!==y?(he=b(Ti(y),!M&&`invisible`),t[37]=M,t[38]=y,t[39]=he):he=t[39];let _e;t[40]!==pe||t[41]!==he?(_e=(0,Q.jsx)(`div`,{"aria-hidden":pe,className:he,"data-markdown-content":!0}),t[40]=pe,t[41]=he,t[42]=_e):_e=t[42];let G;t[43]!==U||t[44]!==W||t[45]!==ce||t[46]!==ue||t[47]!==de||t[48]!==_e?(G=(0,Q.jsxs)(`div`,{"aria-busy":U,className:W,"data-markdown-ready":ce,"data-markdown-hydration":ue,ref:T,children:[de,_e]}),t[43]=U,t[44]=W,t[45]=ce,t[46]=ue,t[47]=de,t[48]=_e,t[49]=G):G=t[49];let ve=G;if(m){let e;return t[50]!==B||t[51]!==ve||t[52]!==h?(e=(0,Q.jsx)(se,{skipAnimation:h,children:ve},B),t[50]=B,t[51]=ve,t[52]=h,t[53]=e):e=t[53],e}return ve},(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id),ki=K.memo(e=>{let t=(0,xe.c)(48),{content:n,className:r,variant:i,disableLinkSafety:a,stripFrontmatter:o,onShowPopup:s,mermaidControls:c,mermaidTheme:l,allowMermaidWheelEvents:u,enableFileReferences:d}=e,f=i===void 0?`assistant`:i,p=o!==void 0&&o,m=c===void 0?li:c,h=u!==void 0&&u,_=d===void 0||d,{editor:v,runtime:y}=re(),x=ai(),S=K.useRef(null),[C,w]=Ei(!1),T=oe()??``,E;t[0]!==n||t[1]!==p?(E=p?di(n):n,t[0]=n,t[1]=p,t[2]=E):E=t[2];let D=E,O;t[3]!==h||t[4]!==m.showPanZoomControls||t[5]!==s?(O={containerRef:S,onShowPopup:s,enableFullscreen:ui,enablePanZoom:m.showPanZoomControls,allowMermaidWheelEvents:h},t[3]=h,t[4]=m.showPanZoomControls,t[5]=s,t[6]=O):O=t[6],mi(O);let ee=g(Ni),k;t[7]!==v||t[8]!==T||t[9]!==_||t[10]!==s||t[11]!==y.isVSCode?(k={containerRef:S,effectiveDirectory:T,editor:v,preferRuntimeEditor:y.isVSCode,onShowPopup:s,enabled:_},t[7]=v,t[8]=T,t[9]=_,t[10]=s,t[11]=y.isVSCode,t[12]=k):k=t[12],pi(k);let A=!a,j;t[13]!==T||t[14]!==ee||t[15]!==A?(j={containerRef:S,enabled:A,effectiveDirectory:T,openInAppBrowser:ee},t[13]=T,t[14]=ee,t[15]=A,t[16]=j):j=t[16],oi(j);let M;t[17]!==T||t[18]!==s?(M={containerRef:S,effectiveDirectory:T,onShowPopup:s},t[17]=T,t[18]=s,t[19]=M):M=t[19];let{reconcileMarkdownImageResources:te,transportIdentity:ne}=ci(M),N;t[20]===x?N=t[21]:(N=fe(x),t[20]=x,t[21]=N);let P=N,F=Ci(l??x,!1,void 0,m,ne,T,!!s),I=`simple:${f}`,L;t[22]!==F||t[23]!==te||t[24]!==D||t[25]!==w||t[26]!==P||t[27]!==I?(L={containerRef:S,text:D,streaming:!1,cacheKey:I,syntaxVars:P,ctx:F,reconcileMarkdownImageResources:te,onRichContentReady:w},t[22]=F,t[23]=te,t[24]=D,t[25]=w,t[26]=P,t[27]=I,t[28]=L):L=t[28],wi(L);let ie=!C||void 0,R;t[29]===r?R=t[30]:(R=b(`relative break-words w-full min-w-0`,r),t[29]=r,t[30]=R);let z=C?`true`:`false`,ae=C?`ready`:`pending`,B;t[31]!==D||t[32]!==C||t[33]!==f?(B=!C&&(0,Q.jsx)(`div`,{className:b(Ti(f),`pointer-events-none absolute inset-0 overflow-clip`),children:(0,Q.jsx)(me,{content:D})}),t[31]=D,t[32]=C,t[33]=f,t[34]=B):B=t[34];let V=!C||void 0,H;t[35]!==C||t[36]!==f?(H=b(Ti(f),!C&&`invisible`),t[35]=C,t[36]=f,t[37]=H):H=t[37];let U;t[38]!==V||t[39]!==H?(U=(0,Q.jsx)(`div`,{"aria-hidden":V,className:H,"data-markdown-content":!0}),t[38]=V,t[39]=H,t[40]=U):U=t[40];let W;return t[41]!==ie||t[42]!==R||t[43]!==z||t[44]!==ae||t[45]!==B||t[46]!==U?(W=(0,Q.jsxs)(`div`,{"aria-busy":ie,className:R,"data-markdown-ready":z,"data-markdown-hydration":ae,ref:S,children:[B,U]}),t[41]=ie,t[42]=R,t[43]=z,t[44]=ae,t[45]=B,t[46]=U,t[47]=W):W=t[47],W},(e,t)=>{let n=e.mermaidControls??li,r=t.mermaidControls??li;return e.content===t.content&&e.variant===t.variant&&e.className===t.className&&e.disableLinkSafety===t.disableLinkSafety&&e.stripFrontmatter===t.stripFrontmatter&&e.onShowPopup===t.onShowPopup&&n.download===r.download&&n.copy===r.copy&&n.showPanZoomControls===r.showPanZoomControls&&e.mermaidTheme===t.mermaidTheme&&e.allowMermaidWheelEvents===t.allowMermaidWheelEvents&&e.enableFileReferences===t.enableFileReferences});function Ai(e){e.removeAttribute(`data-openchamber-file-link`),e.removeAttribute(`data-openchamber-file-ref`),e.removeAttribute(`data-openchamber-file-path`),e.removeAttribute(`data-openchamber-file-binary`),e.getAttribute(`title`)===`Open file`&&e.removeAttribute(`title`),e.tagName.toLowerCase()!==`a`&&(e.removeAttribute(`role`),e.removeAttribute(`tabindex`))}function ji(){}function Mi(e,t){f.getState().openContextBrowser(e,t)}function Ni(e,t){f.getState().openContextBrowser(e,t)}export{Zr as a,$r as c,Bn as d,Kn as f,Ye as h,Gr as i,ei as l,In as m,ii as n,ri as o,qn as p,Nr as r,Yr as s,Oi as t,zn as u};
|
package/dist/assets/{MarkstreamRendererImpl-CIylCsD3.js → MarkstreamRendererImpl-AE60MlbM.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{n as r}from"./useUIStore-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{n as r}from"./useUIStore-pl39iO82.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./vendor-markstream-react-Bm0cO70Z.js";import{f as d,n as f,r as p}from"./vendor-reactuses-core-BpfIZ1tg.js";import{r as m}from"./button-kJNzMb1G.js";import{Ui as h}from"./useMobileNavigationStore-B24J82Xs.js";import{t as g}from"./useThemeSystem-8jhE4Zyk.js";import{i as _,n as v,t as y}from"./tooltip-B3eYZnNS.js";import{s as b}from"./image-loading-OgMEw4Jq.js";import{n as ee}from"./useRuntimeAPIs-Cx8S1HLz.js";import{a as x,r as S}from"./url-DAyfGWPH.js";import{n as C}from"./useEffectiveDirectory-Dzsx_s3D.js";import{t as w}from"./LoadingImage-BBGT-9VQ.js";import{r as te,t as ne}from"./markdownHeightCache-CAVQhVdd.js";import{a as T,c as E,d as D,f as O,h as k,i as A,l as j,m as M,o as N,p as P,r as F,s as I,t as L}from"./MarkdownRendererImpl-DcSDNoV2.js";var R=e(t(),1),z=`img:not([data-md-link-favicon="true"])`,B=e=>e.getAttribute(`data-md-image-source`)??e.getAttribute(`src`)??``,re=(e,t)=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;let n=e.target;if(!(n instanceof Element))return;let r=n.closest(z);if(r instanceof HTMLImageElement&&t.onShowPopup){let n=e.currentTarget;if(!(n instanceof HTMLElement))return;let i=Array.from(n.querySelectorAll(z)).map(e=>({url:B(e),filename:e.alt||B(e)||void 0})).filter(e=>e.url),a=B(r),o=i.findIndex(e=>e.url===a);if(!a)return;e.preventDefault(),e.stopPropagation(),t.onShowPopup({open:!0,title:r.alt||a,content:``,previewSource:r,image:{url:a,filename:r.alt||a,gallery:i,index:o>=0?o:0}});return}if(t.fileReference){let r=n.closest(D);if(r instanceof HTMLElement){e.preventDefault(),e.stopPropagation(),N(r,t.fileReference);return}}let i=n.closest(`a[href]`);if(!(i instanceof HTMLAnchorElement))return;let a=i.getAttribute(`href`)??``;if(P(a)){e.preventDefault(),e.stopPropagation(),t.fileReference&&O(a)&&N(i,t.fileReference);return}if(!S(a))return;e.preventDefault(),e.stopPropagation();let o=(t.effectiveDirectory||``).trim();if(!h()&&o&&t.openInAppBrowser){t.openInAppBrowser(o,a);return}x(a)},ie=(e,t)=>{if(e.key!==`Enter`&&e.key!==` `||!t.fileReference)return;let n=e.target;if(!(n instanceof Element))return;let r=n.closest(D);!(r instanceof HTMLElement)||r.getAttribute(`data-openchamber-file-link`)!==`true`||(e.preventDefault(),e.stopPropagation(),N(r,t.fileReference))},V=i(),H=(e,t)=>{let n=t>=2?e.slice(t-2,t):``;return(t>=1?e.charAt(t-1):``)===`:`||n===`:/`},U=e=>{if(!e.includes(`/`)||!e.includes(`.`))return[{kind:`text`,value:e}];M.lastIndex=0;let t=[],n=0,r=M.exec(e);for(;r;){let i=r[0];if(!i||H(e,r.index)||!O(i)){r=M.exec(e);continue}r.index>n&&t.push({kind:`text`,value:e.slice(n,r.index)}),t.push({kind:`path`,value:i}),n=r.index+i.length,r=M.exec(e)}return n===0?[{kind:`text`,value:e}]:(n<e.length&&t.push({kind:`text`,value:e.slice(n)}),t)},W=n(),G=R.createContext({enabled:!1,insideLink:!1,isMobileSurface:!1,effectiveDirectory:``,preferRuntimeEditor:!1,slots:{used:0,limit:0}}),K=e=>{let t=(0,V.c)(11),{enabled:n,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,content:s,children:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=h(),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u={used:0,limit:A()},t[1]=u):u=t[1];let d;t[2]!==i||t[3]!==r||t[4]!==n||t[5]!==o||t[6]!==a?(d={enabled:n,insideLink:!1,isMobileSurface:l,effectiveDirectory:r,editor:i,preferRuntimeEditor:a,onShowPopup:o,slots:u},t[2]=i,t[3]=r,t[4]=n,t[5]=o,t[6]=a,t[7]=d):d=t[7];let f=d,p;return t[8]!==c||t[9]!==f?(p=(0,W.jsx)(G.Provider,{value:f,children:c}),t[8]=c,t[9]=f,t[10]=p):p=t[10],p},q=({raw:e,children:t})=>{let n=R.useContext(G),r=T(e,n.effectiveDirectory),i=R.useRef(!1);n.enabled&&r&&!i.current&&n.slots.used<n.slots.limit&&(n.slots.used+=1,i.current=!0);let[a,o]=R.useState(r?I(r.resolvedPath,n.effectiveDirectory)??null:null),s=r?.resolvedPath;if(R.useEffect(()=>{if(!n.enabled||!s||!i.current)return;let e=!1;return E(s,n.effectiveDirectory).then(t=>{e||o(t)}).catch(()=>{}),()=>{e=!0}},[n.enabled,n.effectiveDirectory,s]),!r)return t??e;let c=!!(i.current&&a&&j(r.resolvedPath,a,n.isMobileSurface));return(0,W.jsx)(`span`,{"data-openchamber-block-path-token":`true`,...c?{"data-openchamber-file-link":`true`,"data-openchamber-file-ref":e,"data-openchamber-file-path":r.resolvedPath,"data-openchamber-file-binary":String(a?.isBinary===!0),title:F,...t?{}:{role:`button`,tabIndex:0}}:{},children:t??e})};function J(e){let t=(0,V.c)(12),n=R.useContext(G),r=e.node.content??``;if(!n.enabled||n.insideLink){let n;return t[0]===e?n=t[1]:(n=(0,W.jsx)(l,{...e}),t[0]=e,t[1]=n),n}let i,a;if(t[2]!==r||t[3]!==e){a=Symbol.for(`react.early_return_sentinel`);bb0:{let n=U(r);if(n.length===1&&n[0]?.kind!==`path`){let n;t[6]===e?n=t[7]:(n=(0,W.jsx)(l,{...e}),t[6]=e,t[7]=n),a=n;break bb0}let o;t[8]===e?o=t[9]:(o=(t,n)=>t.kind===`path`?(0,W.jsx)(q,{raw:t.value},`path-${n}-${t.value}`):(0,W.jsx)(l,{...e,node:{...e.node,content:t.value}},`text-${n}`),t[8]=e,t[9]=o),i=n.map(o)}t[2]=r,t[3]=e,t[4]=i,t[5]=a}else i=t[4],a=t[5];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o;return t[10]===i?o=t[11]:(o=(0,W.jsx)(W.Fragment,{children:i}),t[10]=i,t[11]=o),o}function ae(e){let t=(0,V.c)(7),n=R.useContext(G),r=e.node.code??``;if(!n.enabled||!O(r)){let n;return t[0]===e?n=t[1]:(n=(0,W.jsx)(o,{...e}),t[0]=e,t[1]=n),n}let i;t[2]===r?i=t[3]:(i=(0,W.jsx)(q,{raw:r}),t[2]=r,t[3]=i);let a;return t[4]!==e||t[5]!==i?(a=(0,W.jsx)(o,{...e,children:i}),t[4]=e,t[5]=i,t[6]=a):a=t[6],a}function oe(e){let t=(0,V.c)(20),n=R.useContext(G),r=e.node.href??``,i;t[0]!==n.enabled||t[1]!==r?(i=n.enabled&&O(r),t[0]=n.enabled,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===e?o=t[4]:(o=(0,W.jsx)(s,{...e,showTooltip:!1}),t[3]=e,t[4]=o);let c=o,l;t[5]!==n.isMobileSurface||t[6]!==r||t[7]!==c||t[8]!==e.node.title||t[9]!==e.showTooltip?(l=n.isMobileSurface||e.showTooltip===!1?c:(0,W.jsxs)(y,{children:[(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(`span`,{children:c})}),(0,W.jsx)(v,{children:e.node.title||r})]}),t[5]=n.isMobileSurface,t[6]=r,t[7]=c,t[8]=e.node.title,t[9]=e.showTooltip,t[10]=l):l=t[10];let u=l,d;t[11]===n?d=t[12]:(d={...n,insideLink:!0},t[11]=n,t[12]=d);let f;t[13]!==u||t[14]!==a||t[15]!==r?(f=a?(0,W.jsx)(q,{raw:r,children:u}):u,t[13]=u,t[14]=a,t[15]=r,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,W.jsx)(G.Provider,{value:d,children:f}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}var se=/^[ \t]{0,3}(`{3,}|~{3,})/,ce=e=>{if(typeof e!=`string`||e.length===0)return!1;let t=e.split(/\r?\n/,1)[0]??``;return se.test(t)},le=e=>{let t=0,n=0,r=e.match(/[`~]+/g)??[];for(let e of r)e[0]==="`"?t=Math.max(t,e.length):n=Math.max(n,e.length);return t>=3?"`".repeat(Math.max(3,t+1)):n>=3&&t===0?"```":n>=3?`~`.repeat(Math.max(3,n+1)):"```"},ue=e=>{let t=typeof e.raw==`string`?e.raw:``;if(ce(t))return t.endsWith(`
|
|
2
2
|
`)?t:`${t}\n`;let n=(e.language??``).trim(),r=e.code??``,i=le(r),a=r.endsWith(`
|
|
3
|
-
`)?r:`${r}\n`;return e.loading?`${i}${n}\n${a}`:`${i}${n}\n${a}${i}\n`},de=e=>{let t=e.partId?`part-${e.partId}`:`body`,n=e.indexKey!==void 0&&e.indexKey!==null&&String(e.indexKey).length>0?String(e.indexKey):e.language&&e.language.length>0?e.language:`code`;return`${e.messageId}:${t}:code:${n}`},Y=R.createContext({messageId:`markstream`,isStreaming:!1,disableStreamAnimation:!1,variant:`assistant`,enableFileReferences:!0}),X=()=>R.useContext(Y);function fe(e,t){let n=5381;for(let e=0;e<t.length;e+=1)n=Math.imul(n,33)^t.charCodeAt(e);return`${e}:${(n>>>0).toString(36)}:${t.length}`}function Z(e){let t=(0,V.c)(7),n;if(t[0]!==e.indexKey||t[1]!==e.node.code||t[2]!==e.node.language){let r=(e.node.language??``).trim().toLowerCase()||`diagram`;n=e.indexKey??fe(r,e.node.code??``),t[0]=e.indexKey,t[1]=e.node.code,t[2]=e.node.language,t[3]=n}else n=t[3];let r=n,i;return t[4]!==r||t[5]!==e?(i=(0,W.jsx)(Q,{...e,indexKey:r}),t[4]=r,t[5]=e,t[6]=i):i=t[6],i}function Q(e){let t=(0,V.c)(21),n=X(),r=e.node.language??``,i=e.node.code??``,a=e.node.raw??``,o=e.node.loading===!0||e.loading===!0,s;t[0]!==i||t[1]!==r||t[2]!==o||t[3]!==a?(s=ue({type:`code_block`,language:r,code:i,raw:a,loading:o}),t[0]=i,t[1]=r,t[2]=o,t[3]=a,t[4]=s):s=t[4];let c=s,l=n.isStreaming||e.loading===!0||e.node.loading===!0,u=n.part?.id,d;t[5]!==n.messageId||t[6]!==e.indexKey||t[7]!==e.node.language||t[8]!==u?(d=de({messageId:n.messageId,partId:u,indexKey:e.indexKey,language:e.node.language}),t[5]=n.messageId,t[6]=e.indexKey,t[7]=e.node.language,t[8]=u,t[9]=d):d=t[9];let f=d,p=n.enableFileReferences&&!l,m;t[10]!==c||t[11]!==n.disableStreamAnimation||t[12]!==n.onShowPopup||t[13]!==n.variant||t[14]!==f||t[15]!==l||t[16]!==p?(m=(0,W.jsx)(L,{content:c,messageId:f,isAnimated:!1,skipFadeIn:!0,isStreaming:l,disableStreamAnimation:n.disableStreamAnimation,variant:n.variant,onShowPopup:n.onShowPopup,enableFileReferences:p}),t[10]=c,t[11]=n.disableStreamAnimation,t[12]=n.onShowPopup,t[13]=n.variant,t[14]=f,t[15]=l,t[16]=p,t[17]=m):m=t[17];let h;return t[18]!==f||t[19]!==m?(h=(0,W.jsx)(`div`,{className:`oc-markstream-code-host min-w-0 w-full`,"data-oc-markstream-code":`markdown-impl`,"data-oc-markstream-code-id":f,children:m}),t[18]=f,t[19]=m,t[20]=h):h=t[20],h}function pe(e){let t=(0,V.c)(9),{node:n}=e,r=C()??``,i=b(n.src,r),{onShowPopup:a}=X(),o=f(me),s=i.source||void 0,c=n.title??void 0,l=a?`button`:void 0,u=a?0:void 0,d=a?o:void 0,p;return t[0]!==n.alt||t[1]!==n.src||t[2]!==i.error||t[3]!==s||t[4]!==c||t[5]!==l||t[6]!==u||t[7]!==d?(p=(0,W.jsx)(w,{
|
|
3
|
+
`)?r:`${r}\n`;return e.loading?`${i}${n}\n${a}`:`${i}${n}\n${a}${i}\n`},de=e=>{let t=e.partId?`part-${e.partId}`:`body`,n=e.indexKey!==void 0&&e.indexKey!==null&&String(e.indexKey).length>0?String(e.indexKey):e.language&&e.language.length>0?e.language:`code`;return`${e.messageId}:${t}:code:${n}`},Y=R.createContext({messageId:`markstream`,isStreaming:!1,disableStreamAnimation:!1,variant:`assistant`,enableFileReferences:!0}),X=()=>R.useContext(Y);function fe(e,t){let n=5381;for(let e=0;e<t.length;e+=1)n=Math.imul(n,33)^t.charCodeAt(e);return`${e}:${(n>>>0).toString(36)}:${t.length}`}function Z(e){let t=(0,V.c)(7),n;if(t[0]!==e.indexKey||t[1]!==e.node.code||t[2]!==e.node.language){let r=(e.node.language??``).trim().toLowerCase()||`diagram`;n=e.indexKey??fe(r,e.node.code??``),t[0]=e.indexKey,t[1]=e.node.code,t[2]=e.node.language,t[3]=n}else n=t[3];let r=n,i;return t[4]!==r||t[5]!==e?(i=(0,W.jsx)(Q,{...e,indexKey:r}),t[4]=r,t[5]=e,t[6]=i):i=t[6],i}function Q(e){let t=(0,V.c)(21),n=X(),r=e.node.language??``,i=e.node.code??``,a=e.node.raw??``,o=e.node.loading===!0||e.loading===!0,s;t[0]!==i||t[1]!==r||t[2]!==o||t[3]!==a?(s=ue({type:`code_block`,language:r,code:i,raw:a,loading:o}),t[0]=i,t[1]=r,t[2]=o,t[3]=a,t[4]=s):s=t[4];let c=s,l=n.isStreaming||e.loading===!0||e.node.loading===!0,u=n.part?.id,d;t[5]!==n.messageId||t[6]!==e.indexKey||t[7]!==e.node.language||t[8]!==u?(d=de({messageId:n.messageId,partId:u,indexKey:e.indexKey,language:e.node.language}),t[5]=n.messageId,t[6]=e.indexKey,t[7]=e.node.language,t[8]=u,t[9]=d):d=t[9];let f=d,p=n.enableFileReferences&&!l,m;t[10]!==c||t[11]!==n.disableStreamAnimation||t[12]!==n.onShowPopup||t[13]!==n.variant||t[14]!==f||t[15]!==l||t[16]!==p?(m=(0,W.jsx)(L,{content:c,messageId:f,isAnimated:!1,skipFadeIn:!0,isStreaming:l,disableStreamAnimation:n.disableStreamAnimation,variant:n.variant,onShowPopup:n.onShowPopup,enableFileReferences:p}),t[10]=c,t[11]=n.disableStreamAnimation,t[12]=n.onShowPopup,t[13]=n.variant,t[14]=f,t[15]=l,t[16]=p,t[17]=m):m=t[17];let h;return t[18]!==f||t[19]!==m?(h=(0,W.jsx)(`div`,{className:`oc-markstream-code-host min-w-0 w-full`,"data-oc-markstream-code":`markdown-impl`,"data-oc-markstream-code-id":f,children:m}),t[18]=f,t[19]=m,t[20]=h):h=t[20],h}function pe(e){let t=(0,V.c)(9),{node:n}=e,r=C()??``,i=b(n.src,r),{onShowPopup:a}=X(),o=f(me),s=i.source||void 0,c=n.title??void 0,l=a?`button`:void 0,u=a?0:void 0,d=a?o:void 0,p;return t[0]!==n.alt||t[1]!==n.src||t[2]!==i.error||t[3]!==s||t[4]!==c||t[5]!==l||t[6]!==u||t[7]!==d?(p=(0,W.jsx)(w,{contentFrame:!0,src:s,resourceError:i.error,"data-md-image-source":n.src,alt:n.alt,title:c,className:`rounded-lg`,role:l,tabIndex:u,onKeyDown:d}),t[0]=n.alt,t[1]=n.src,t[2]=i.error,t[3]=s,t[4]=c,t[5]=l,t[6]=u,t[7]=d,t[8]=p):p=t[8],p}function me(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.currentTarget.click())}function he(e){let t=(0,V.c)(4);if(e.node.type===`code_block`){let n=e,r;return t[0]===n?r=t[1]:(r=(0,W.jsx)(Q,{...n}),t[0]=n,t[1]=r),r}let n=e,r;return t[2]===n?r=t[3]:(r=(0,W.jsx)(pe,{...n}),t[2]=n,t[3]=r),r}var $=!1;function ge(e){return e.node?.type===`code_block`?R.createElement(Q,e):R.createElement(J,e)}var _e=()=>{$||($=!0,a({text:ge,inline_code:ae,link:oe,image:he,code_block:c(Q,`block`),mermaid:c(Z,`block`),d2:c(Z,`block`),d2lang:c(Z,`block`),infographic:c(Z,`block`)}))},ve={maxLiveNodes:0,liveNodeBuffer:0,batchRendering:!1,deferNodesUntilVisible:!1,viewportPriority:!1,smoothStreaming:!1,typewriter:!1,fade:!1};_e();var ye=e=>(e.inline.ruler.at(`math`,(e,t)=>{let n=e.src.slice(e.pos),r=k(n),i=n.startsWith(`\\(`)?/^\\\(([\s\S]+?)\\\)/.exec(n):null,a=r?.raw??i?.[0],o=r?.text??i?.[1];if(!a||!o)return!1;if(!t){let t=e.push(`math_inline`,`math`,0);t.content=o,t.markup=r?r.display?`$$`:`$`:`\\(\\)`}return e.pos+=a.length,!0}),e),be=e=>e===`tool`?`markdown-content markdown-tool oc-markstream-host`:e===`reasoning`?`markdown-content markdown-reasoning oc-markstream-host`:`markdown-content leading-relaxed oc-markstream-host`,xe=R.memo(({content:e,part:t,messageId:n,className:i,isStreaming:a=!1,disableStreamAnimation:o=!1,variant:s=`assistant`,onShowPopup:c,enableFileReferences:l=!0})=>{let h=g()?.currentTheme.metadata.variant===`dark`,{editor:_,runtime:v}=ee(),y=C()??``,b=R.useRef(null),x=t?.id?`oc-ms-${t.id}`:`oc-ms-${n}`,S=ne(e,`markstream:${s}`),w=!a,T=l&&!a,E=T?{effectiveDirectory:y,editor:_,preferRuntimeEditor:v.isVSCode,onShowPopup:c}:void 0,D=R.useMemo(()=>({messageId:n,part:t,isStreaming:a,disableStreamAnimation:o,variant:s,onShowPopup:c,enableFileReferences:l}),[n,t,a,o,s,c,l]),O=R.useRef(w);O.current=w;let k=R.useRef(S);k.current=S;let A=f(e=>{if(!O.current)return;let t=e[0];if(!t)return;let n=t.borderBoxSize?.[0],r=n?n.blockSize:t.contentRect.height,i=n?n.inlineSize:t.contentRect.width;te(k.current,r,i)});d(b,A);let j=f((e,t)=>{r.getState().openContextBrowser(e,t)}),M=f(e=>{re(e,{onShowPopup:c,fileReference:E,effectiveDirectory:y,openInAppBrowser:j})}),N=f(e=>{ie(e,{fileReference:E})});return p(`click`,M,b),p(`keydown`,N,b),(0,W.jsx)(`div`,{ref:b,className:m(`relative break-words w-full min-w-0`,be(s),i),"data-markdown-ready":`true`,"data-markdown-hydration":`ready`,"data-oc-markdown-engine":`markstream`,"data-oc-markstream-virtual":`off`,children:(0,W.jsx)(Y.Provider,{value:D,children:(0,W.jsx)(K,{enabled:T,effectiveDirectory:y,editor:_,preferRuntimeEditor:v.isVSCode,onShowPopup:c,content:e,children:(0,W.jsx)(u,{content:e,customMarkdownIt:ye,customId:x,final:!a,isDark:h,codeBlockStream:a,...ve})})})})},(e,t)=>e.content===t.content&&e.isStreaming===t.isStreaming&&e.disableStreamAnimation===t.disableStreamAnimation&&e.variant===t.variant&&e.isAnimated===t.isAnimated&&e.skipFadeIn===t.skipFadeIn&&e.className===t.className&&e.messageId===t.messageId&&e.onShowPopup===t.onShowPopup&&e.enableFileReferences===t.enableFileReferences&&e.part?.id===t.part?.id);export{xe as MarkstreamRenderer};
|
package/dist/assets/{MobileDetailNavigation-CzOQIbvs.js → MobileDetailNavigation-Bgzkkjqa.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-Ck0YPsR7.js";import{n as r}from"./runtime-fetch-DJVW43Cw.js";import{m as i}from"./persistence-CoWdsn8M.js";import{it as a,rt as o}from"./vendor-base-ui-CdzJ6My_.js";import{n as s}from"./vendor-react-BP2cRVqX.js";import{s as c}from"./vendor-tanstack-react-query-CdqCAt40.js";import{r as l,t as u}from"./button-BnPjweDW.js";import{i as d}from"./store-CYW4nz6C.js";import{bo as f,yo as p}from"./useMobileNavigationStore-2dQHPP2A.js";import{n as m}from"./Icon-De3bTfBD.js";var h=e(a(),1),g=s(),_=class extends Error{code;status;resource;constructor(e,t,n,r){super(typeof r==`string`&&r.trim()?r.trim():e),this.code=e,this.status=t,this.resource=n}},v=e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return t===`AbortError`||t===`TimeoutError`},y=class extends _{operation;constructor(e,t,n){super(e,t,`share_operation`),this.operation=n}},b=(e,t=200)=>{throw new _(`invalid_${e}_response`,t,e)},x=(e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e:b(t),S=(e,t)=>typeof e==`string`?e:b(t),C=(e,t)=>e===null||typeof e==`string`?e:b(t),w=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:b(t),T=(e,t)=>e===null?null:w(e,t),E=(e,t)=>typeof e==`boolean`?e:b(t),D=(e,t,n)=>t.includes(e)?e:b(n),O=e=>{let t=x(e,`capability`);return{supported:E(t.supported,`capability`),enabled:E(t.enabled,`capability`),revision:w(t.revision,`capability`),serverInstanceID:C(t.serverInstanceID,`capability`),sharingAvailable:t.sharingAvailable!==void 0&&E(t.sharingAvailable,`capability`)}},k=e=>{if(e==null)return null;let t=x(e,`assistant`);return{turnID:S(t.turnID,`assistant`),messageID:S(t.messageID,`assistant`),status:D(t.status,[`queued`,`running`],`assistant`),admittedAt:w(t.admittedAt,`assistant`)}},A=e=>{if(e==null)return null;let t=x(e,`assistant_preview`),n=w(t.ordinal,`assistant_preview`);return!Number.isSafeInteger(n)||n<0?b(`assistant_preview`):{...t.createdAt===void 0?{}:{createdAt:w(t.createdAt,`assistant_preview`)},messageID:S(t.messageID,`assistant_preview`),ordinal:n,role:D(t.role,[`user`,`assistant`],`assistant_preview`),text:S(t.text,`assistant_preview`),fallbackKind:t.fallbackKind===null?null:D(t.fallbackKind,[`image`,`file`,`session`,`assistant`,`schedule`],`assistant_preview`)}},j=e=>{let t=w(e,`assistant_read`);return Number.isSafeInteger(t)&&t>=0?t:b(`assistant_read`)},M=e=>{let t=x(e,`assistant_read`);return{generation:j(t.generation),ordinal:j(t.ordinal),messageID:S(t.messageID,`assistant_read`)}},N=e=>({unreadCount:e.unreadCount===void 0?0:j(e.unreadCount),readWatermark:e.readWatermark==null?null:M(e.readWatermark),readTip:e.readTip==null?null:M(e.readTip)}),P=e=>{let t=x(e,`assistant_read`);return{assistantID:S(t.assistantID,`assistant_read`),changed:E(t.changed,`assistant_read`),unreadCount:j(t.unreadCount),readWatermark:M(t.readWatermark),readTip:M(t.readTip),revision:j(t.revision)}},F=e=>{let t=x(e,`assistant`),n=Array.isArray(t.historySessionIDs)?t.historySessionIDs.map(e=>S(e,`assistant`)):[],r=t.historySessionCount===void 0?n.length:w(t.historySessionCount,`assistant`);if(!Number.isSafeInteger(r)||r<n.length)return b(`assistant`);let i=Array.isArray(t.assignedSessionIDs)?t.assignedSessionIDs.map(e=>S(e,`assistant`)):[],a=t.activeContactTurn===void 0?null:k(t.activeContactTurn),o=t.working===void 0?a!=null:E(t.working,`assistant`);return{...N(t),latestMessagePreview:A(t.latestMessagePreview),id:S(t.id,`assistant`),avatarSeed:S(t.avatarSeed??t.id,`assistant`),revision:w(t.revision,`assistant`),enabled:E(t.enabled,`assistant`),name:S(t.name,`assistant`),defaultPrompt:S(t.defaultPrompt,`assistant`),workspacePath:C(t.workspacePath,`assistant`),effectiveWorkspacePath:S(t.effectiveWorkspacePath,`assistant`),managedWorkspacePath:C(t.managedWorkspacePath??null,`assistant`),providerID:S(t.providerID,`assistant`),modelID:S(t.modelID,`assistant`),agent:C(t.agent,`assistant`),variant:C(t.variant??null,`assistant`),mode:D(t.mode,[`continuous`,`stateless`],`assistant`),sessionID:C(t.sessionID,`assistant`),sessionGeneration:w(t.sessionGeneration,`assistant`),historySessionIDs:n,historySessionCount:r,assignedSessionIDs:i,working:o,activeContactTurn:a,createdAt:T(t.createdAt,`assistant`),updatedAt:w(t.updatedAt,`assistant`),tombstoneAt:T(t.tombstoneAt,`assistant`)}},I=e=>{let t=x(e,`snapshot`);return{revision:w(t.revision,`snapshot`),enabled:E(t.enabled,`snapshot`),assistants:Array.isArray(t.assistants)?t.assistants.map(F):b(`snapshot`)}},L=e=>{let t=x(e,`binding`);return{sessionID:C(t.sessionID,`binding`),directory:S(t.directory,`binding`),sessionGeneration:w(t.sessionGeneration,`binding`)}},ee=e=>{let t=x(e,`message_admission`);if(t.admitted!==!0)return b(`message_admission`);let n=t.revision===void 0||t.revision===null?null:w(t.revision,`message_admission`);return{binding:L(t.binding),messageID:S(t.messageID,`message_admission`),admitted:!0,revision:n,...t.replayed===!0?{replayed:!0}:{}}},te=e=>{let t=x(e,`share_operation`);return{operationID:S(t.operationID,`share_operation`),assistantID:S(t.assistantID,`share_operation`),sessionID:C(t.sessionID,`share_operation`),messageID:C(t.messageID,`share_operation`),state:D(t.state,[`submitting`,`running`,`completed`,`failed`,`unresolved`],`share_operation`),phase:S(t.phase,`share_operation`),attempt:w(t.attempt,`share_operation`),leaseExpiresAt:T(t.leaseExpiresAt,`share_operation`),errorCode:C(t.errorCode,`share_operation`)}},ne=e=>{let t=x(e,`assistant_contact_part`);if(t.type===`text`)return{type:`text`,text:S(t.text,`assistant_contact_part`)};if(t.type===`file`){let e=t.filename===void 0||t.filename===null?void 0:S(t.filename,`assistant_contact_part`),n=S(t.mime,`assistant_contact_part`),r=t.url!==void 0&&t.url!==null,i=t.attachmentID!==void 0&&t.attachmentID!==null;if(r&&i)return b(`assistant_contact_part`);if(i){let r=w(t.size,`assistant_contact_part`);return!Number.isSafeInteger(r)||r<0?b(`assistant_contact_part`):{type:`file`,mime:n,attachmentID:S(t.attachmentID,`assistant_contact_part`),sha256:S(t.sha256,`assistant_contact_part`),size:r,...e?{filename:e}:{}}}return r?{type:`file`,mime:n,url:S(t.url,`assistant_contact_part`),...e?{filename:e}:{}}:b(`assistant_contact_part`)}if(t.type===`card`){let e=D(t.cardType,[`session`,`assistant`,`schedule`],`assistant_contact_part`);return e===`session`?{type:`card`,cardType:`session`,sessionID:S(t.sessionID,`assistant_contact_part`),directory:S(t.directory,`assistant_contact_part`),title:C(t.title??null,`assistant_contact_part`),status:C(t.status??null,`assistant_contact_part`),branch:C(t.branch??null,`assistant_contact_part`)}:e===`assistant`?{type:`card`,cardType:`assistant`,assistantID:S(t.assistantID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),providerID:S(t.providerID,`assistant_contact_part`),modelID:S(t.modelID,`assistant_contact_part`),mode:D(t.mode??`continuous`,[`continuous`,`stateless`],`assistant_contact_part`)}:{type:`card`,cardType:`schedule`,taskID:S(t.taskID,`assistant_contact_part`),projectID:S(t.projectID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),kind:C(t.kind??null,`assistant_contact_part`),time:C(t.time??null,`assistant_contact_part`),timezone:C(t.timezone??null,`assistant_contact_part`),prompt:C(t.prompt??null,`assistant_contact_part`)}}return b(`assistant_contact_part`)},re=e=>{let t=x(e,`assistant_contact`),n=C(t.nextCursor,`assistant_contact`),r=E(t.complete,`assistant_contact`);if(!r&&!n||r&&n||!Array.isArray(t.messages))return b(`assistant_contact`);let i=w(t.generation,`assistant_contact`),a=w(t.revision,`assistant_contact`);return!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<0?b(`assistant_contact`):{messages:t.messages.map(e=>{let t=x(e,`assistant_contact_message`);if(!Array.isArray(t.parts))return b(`assistant_contact_message`);let n=t.parts.map(ne);return{messageID:S(t.messageID,`assistant_contact_message`),assistantID:S(t.assistantID,`assistant_contact_message`),role:D(t.role,[`user`,`assistant`,`peer`],`assistant_contact_message`),turnID:S(t.turnID,`assistant_contact_message`),bubbleIndex:w(t.bubbleIndex,`assistant_contact_message`),createdAt:w(t.createdAt,`assistant_contact_message`),ordinal:w(t.ordinal,`assistant_contact_message`),status:S(t.status,`assistant_contact_message`),fromAssistantID:C(t.fromAssistantID??null,`assistant_contact_message`),fromAssistantName:C(t.fromAssistantName??null,`assistant_contact_message`),parts:n,text:typeof t.text==`string`?t.text:n.filter(e=>e.type===`text`).map(e=>e.text).join(``),cards:n.filter(e=>e.type===`card`)}}),nextCursor:n,complete:r,generation:i,revision:a}},ie=e=>{let t=x(e,`assistant_scheduled_tasks`);return Array.isArray(t.tasks)?{tasks:t.tasks.map(e=>{let t=x(e,`assistant_scheduled_task`),n=t.task===null||t.task===void 0?null:x(t.task,`assistant_scheduled_task_live`);return{assistantID:S(t.assistantID,`assistant_scheduled_task`),projectID:S(t.projectID,`assistant_scheduled_task`),taskID:S(t.taskID,`assistant_scheduled_task`),createdAt:w(t.createdAt,`assistant_scheduled_task`),projectPath:C(t.projectPath??null,`assistant_scheduled_task`),projectLabel:C(t.projectLabel??null,`assistant_scheduled_task`),task:n}})}:b(`assistant_scheduled_tasks`)},R=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim().length>0)return t.error}catch{return t}return t},z=e=>{let t=typeof e==`string`?e.trim():``;if(!t)throw Error(`projectId is required`);return t},B=e=>e===null||typeof e==`string`,ae=e=>e===null||typeof e==`number`&&Number.isFinite(e),oe=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=864e13,se=e=>e===null||oe(e),ce=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.projectId==`string`&&t.projectId.length>0&&typeof t.taskId==`string`&&t.taskId.length>0&&typeof t.taskName==`string`&&(t.trigger===`scheduled`||t.trigger===`manual`)&&(t.status===`running`||t.status===`success`||t.status===`error`)&&B(t.sessionId)&&B(t.directory)&&B(t.error)&&oe(t.startedAt)&&se(t.finishedAt)&&ae(t.durationMs)&&(t.durationMs===null||t.durationMs>=0)},le=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed scheduled task runs response`);let t=e;if(!Array.isArray(t.runs)||!t.runs.every(ce)||!B(t.nextCursor)||typeof t.complete!=`boolean`||t.complete!==(t.nextCursor===null)||t.nextCursor!==null&&t.nextCursor.length===0)throw Error(`Malformed scheduled task runs response`);return{runs:t.runs,nextCursor:t.nextCursor,complete:t.complete}},ue=async(e,t)=>{let n=new URLSearchParams;e.before&&n.set(`before`,e.before);let i=e.limit??20;if(!Number.isInteger(i)||i<1)throw Error(`limit must be a positive integer`);n.set(`limit`,String(i)),e.projectId&&n.set(`projectId`,e.projectId),e.taskId&&n.set(`taskId`,e.taskId);let a=await r(`/api/openchamber/scheduled-task-runs?${n.toString()}`,{signal:t});if(!a.ok)throw Error(await R(a,`Failed to load scheduled task history`));return le(await a.json().catch(()=>null))},de=async({signal:e}={})=>{let t=await r(`/api/openchamber/scheduled-tasks`,{signal:e});if(!t.ok)throw Error(await R(t,`Failed to load schedules`));let n=await t.json().catch(()=>null);if(!n||!Array.isArray(n.tasks))throw Error(`Malformed schedules response`);return{tasks:Array.isArray(n?.tasks)?n.tasks:[],failedProjectIds:Array.isArray(n?.failedProjectIds)?n.failedProjectIds.filter(e=>typeof e==`string`):[]}},fe=async(e,t)=>{let n=z(e),i=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks`,{method:`PUT`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify({task:t})});if(!i.ok)throw Error(await R(i,`Failed to save schedule`));let a=await i.json().catch(()=>null);return!a||!Array.isArray(a.tasks)?[]:a.tasks},pe=async(e,t)=>{let n=z(e),i=z(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}`,{method:`DELETE`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await R(a,`Failed to delete schedule`));let o=await a.json().catch(()=>null);return!o||!Array.isArray(o.tasks)?[]:o.tasks},me=async(e,t)=>{let n=z(e),i=z(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}/run`,{method:`POST`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await R(a,`Failed to run schedule`));let o=await a.json().catch(()=>null);return{sessionId:typeof o?.sessionId==`string`&&o.sessionId.length>0?o.sessionId:void 0}},V=(e,t)=>e.ordinal===t.ordinal?e.messageID<t.messageID?-1:+(e.messageID>t.messageID):e.ordinal-t.ordinal,he=e=>{if(e.type===`file`||e.type===`card`)return!0;if(e.type!==`text`)return!1;let t=typeof e.text==`string`?e.text.trim():``;return!!t&&!t.startsWith(`oc.settle.`)},ge=(e,t)=>{if(!t||!e.readTip||!((e.unreadCount??0)>0))return null;let n=e.readTip;if(t.generation!==n.generation)return null;let r;for(let n=t.messages.length-1;n>=0;--n){let i=t.messages[n];if(i.assistantID===e.id&&(i.status===`complete`||i.status===`error`)&&i.parts.some(he)){r=i;break}}if(!r)return null;let i=e.readWatermark;return i&&(i.generation>t.generation||i.generation===t.generation&&V({ordinal:i.ordinal,messageID:i.messageID},{ordinal:r.ordinal,messageID:r.messageID})>=0)?null:{generation:t.generation,ordinal:r.ordinal,messageID:r.messageID}},_e=()=>({messages:[],generation:-1,revision:0,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}),ve=e=>!!(e&&e.generation>=0),ye=(e,t)=>V({ordinal:e.ordinal,messageID:e.messageID},{ordinal:t.ordinal,messageID:t.messageID}),H=(e,t,n=`incoming`)=>{let r=new Map;for(let t of e)r.set(t.messageID,t);for(let e of t)(n===`incoming`||!r.has(e.messageID))&&r.set(e.messageID,e);return[...r.values()].sort(ye)},be=e=>{let t=1/0;for(let n of e)n.ordinal<t&&(t=n.ordinal);return Number.isFinite(t)?t:null},xe=e=>e.map(e=>e.messageID),Se=(e,t)=>{for(let n of e)if(t.has(n))return!0;return!1},Ce=e=>new Set(e),we=(e,t)=>!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n]),Te=e=>({...e,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null}),Ee=e=>({ordinal:e.ordinal,messageID:e.messageID}),De=(e,t,n)=>{if(n)return[...t];if(t.length===0)return[...e];let r=t[0];return[...e.filter(e=>V(Ee(e),Ee(r))<0),...t]},Oe=(e,t)=>{let n=e??_e(),r=ve(n),i=[...t.messages].sort(ye),a=xe(i);if(r&&t.generation<n.generation)return n;if(r&&t.generation>n.generation)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};if(!r)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};let o=Math.max(n.revision,t.revision),s=t.revision>=n.revision;if(i.length===0)return s&&t.complete?{messages:[],generation:t.generation,revision:o,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}:{...n,generation:t.generation,revision:o,olderCursor:n.olderCursor??t.nextCursor,olderComplete:n.olderComplete&&t.complete,liveWindowIDs:[],hasMessageGap:n.hasMessageGap,gapCursor:n.hasMessageGap?t.nextCursor??n.gapCursor:null,gapRequestIDs:n.hasMessageGap?n.gapRequestIDs:null,gapTargetIDs:n.hasMessageGap?n.gapTargetIDs:null};let c;if(s)c=De(n.messages,i,t.complete);else{let e=be(i);c=H(n.messages.filter(t=>t.ordinal<e),H(n.messages.filter(t=>t.ordinal>=e),i,`existing`),`incoming`)}let l=n.liveWindowIDs,u=Ce(a),d=l.length>0&&Se(l,u),f=n.hasMessageGap,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs;if(!d&&l.length>0&&t.nextCursor){f=!0,p=t.nextCursor;let e=l.filter(e=>!u.has(e));m=e.length>0?e:[...l],h=n.hasMessageGap&&n.gapTargetIDs&&n.gapTargetIDs.length>0?n.gapTargetIDs:m}else n.hasMessageGap?(f=!0,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs):(f=!1,p=null,m=null,h=null);return{messages:c,generation:t.generation,revision:o,olderCursor:n.liveWindowIDs.length===0&&n.messages.length===0?t.complete?null:t.nextCursor:n.olderCursor,olderComplete:!r||n.liveWindowIDs.length===0&&n.messages.length===0?t.complete:n.olderComplete,hasMessageGap:f,gapCursor:f?p:null,gapRequestIDs:f?m:null,gapTargetIDs:f?h:null,liveWindowIDs:a}},ke=(e,t)=>{if(!ve(e)||t.generation!==e.generation)return e;let n=t.revision>=e.revision?`incoming`:`existing`,r=H(e.messages,t.messages,n);return{...e,messages:r,revision:Math.max(e.revision,t.revision),olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete}},Ae=(e,t,n)=>{if(!ve(e)||t.generation!==e.generation)return e;let r=t.revision>=e.revision?`incoming`:`existing`,i=H(e.messages,t.messages,r),a=Math.max(e.revision,t.revision),o=n?.requestIDs??e.gapRequestIDs;if(!(e.hasMessageGap&&o&&e.gapRequestIDs&&we(o,e.gapRequestIDs)))return{...e,messages:i,revision:a};let s=xe(t.messages),c=e.gapTargetIDs??[],l=Ce(c);return c.length>0&&Se(s,l)||t.complete||!t.nextCursor?Te({...e,messages:i,revision:a}):{...e,messages:i,revision:a,hasMessageGap:!0,gapCursor:t.nextCursor??e.gapCursor,gapRequestIDs:e.gapRequestIDs,gapTargetIDs:e.gapTargetIDs}},U={snapshot:(e=t())=>[e,`assistants`,`snapshot`],capability:(e=t())=>[e,`assistants`,`capability`],history:(e,r,i,a=t(),o=n())=>[a,o,`assistants`,`history`,e,r,i],contact:(e,r=t(),i=n())=>[r,i,`assistants`,`contact`,e],scheduledTasks:(e,r=t(),i=n())=>[r,i,`assistants`,`scheduled-tasks`,e],globalScheduledTasks:(e=t())=>[e,`scheduled-tasks`]},W=async(e,t={})=>{let n=await r(e,t),i=await n.json().catch(()=>null);if(!n.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`request_failed`,t=i&&typeof i==`object`&&`message`in i&&typeof i.message==`string`?i.message:void 0;throw new _(e,n.status,void 0,t)}return i},G=(e,t)=>({method:e,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),K=(e,r)=>{if(t()!==e||n()!==r)throw new _(`runtime_stale`,409)},je=(e,t,r)=>{i.setQueryData(U.snapshot(r),n=>n&&{...n,assistants:n.assistants.map(n=>n.id!==e||n.sessionGeneration>t.sessionGeneration?n:{...n,sessionID:t.sessionID,sessionGeneration:t.sessionGeneration,effectiveWorkspacePath:t.directory})}),i.invalidateQueries({queryKey:U.snapshot(r)}),i.invalidateQueries({queryKey:[r,n(),`assistants`,`history`,e]})},Me=(e,t)=>{i.setQueryData(U.snapshot(t),t=>t&&{...t,assistants:t.assistants.some(t=>t.id===e.id)?t.assistants.map(t=>t.id===e.id?e:t):[...t.assistants,e]}),i.invalidateQueries({queryKey:U.snapshot(t)})},Ne=2500,Pe=15e3,Fe=e=>!!e?.assistants.some(e=>e.working||e.activeContactTurn),Ie=(e,t={})=>{if(t.assistantID){let n=e?.assistants.find(e=>e.id===t.assistantID);return n?.working||n?.activeContactTurn?Ne:Pe}return Fe(e)?Ne:Pe},q=(e=t())=>({queryKey:U.snapshot(e),queryFn:async({signal:e})=>I(await W(`/api/openchamber/assistants/snapshot`,{signal:e})),staleTime:0,retry:2,refetchInterval:e=>Ie(e.state.data),refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),J=new Map,Le=e=>{let n=J.get(e);if(n)n.count+=1;else{let n=f(n=>{if(t()!==e)return;let r=i.getQueryData(U.snapshot(e));(n.type===`event-stream-ready`||n.type===`contact-turn-start`||n.type===`contact-turn-end`||n.type===`assistants-changed`&&(!r||n.revision>r.revision))&&i.invalidateQueries({queryKey:U.snapshot(e),exact:!0})});J.set(e,{count:1,dispose:n})}return()=>{let t=J.get(e);t&&--t.count===0&&(t.dispose(),J.delete(e))}},Re=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=c,r=q(i),e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Le(i),s=[i],e[3]=o,e[4]=s):(o=e[3],s=e[4]),h.useEffect(o,s),a},ze=e=>e.enabled?e.assistants.reduce((e,t)=>e+(t.unreadCount??0),0):0,Be=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=c,r={...q(i),select:ze},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Le(i),s=[i],e[3]=o,e[4]=s):(o=e[3],s=e[4]),h.useEffect(o,s),a.data??0},Ve=e=>e.enabled&&Fe(e),He=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=c,r={...q(i),select:Ve},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Le(i),s=[i],e[3]=o,e[4]=s):(o=e[3],s=e[4]),h.useEffect(o,s),a.data??!1},Ue=(e,t={})=>{let n=new URLSearchParams;return n.set(`limit`,String(t.limit??20)),t.before&&n.set(`before`,t.before),t.messageID&&n.set(`messageID`,t.messageID),`/api/openchamber/assistants/${encodeURIComponent(e)}/contact/messages?${n}`},Y=async(e,t,n)=>re(await W(Ue(e,t),n?{signal:n}:{})),We=(e,t)=>e.generation===t.generation&&e.revision===t.revision&&e.olderCursor===t.olderCursor&&e.olderComplete===t.olderComplete&&e.hasMessageGap===t.hasMessageGap&&e.gapCursor===t.gapCursor&&e.messages===t.messages&&e.liveWindowIDs===t.liveWindowIDs&&e.gapRequestIDs===t.gapRequestIDs&&e.gapTargetIDs===t.gapTargetIDs,X=new Map,Z=new Map,Q=e=>e.join(``),Ge=async(e,t,n,r,a)=>{let o=Q(t),s=Z.get(o);if(s)return s;let c=(async()=>{let o=i.getQueryData(t)??n,s=0,c=!1,l=!1,u=o.gapRequestIDs?[...o.gapRequestIDs]:null,d=o.gapCursor;for(;o.hasMessageGap&&o.gapCursor&&s<5&&!a?.aborted;){K(r.transport,r.runtimeGeneration),s+=1;let n=o.gapCursor;try{let s=await Y(e,{limit:20,before:n},a);K(r.transport,r.runtimeGeneration);let l=i.getQueryData(t)??o;if(s.generation!==l.generation){o=l;break}let f=!u||!!(l.hasMessageGap&&l.gapRequestIDs&&l.gapRequestIDs.length===u.length&&l.gapRequestIDs.every((e,t)=>e===u[t]));if(o=Ae(l,s,u?{requestIDs:u,cursor:d}:void 0),i.setQueryData(t,o),!f)break;if(!o.hasMessageGap){c=!0;break}if(o.gapCursor&&o.gapCursor!==n)c=!0;else break}catch(e){if(a?.aborted||v(e))break;l=!0,o=i.getQueryData(t)??o;break}}return{view:i.getQueryData(t)??o,failed:l,progressed:c}})();Z.set(o,c);try{return await c}finally{Z.get(o)===c&&Z.delete(o)}},Ke=(e,r=t(),a=n(),o={})=>({queryKey:U.contact(e,r,a),queryFn:async({signal:t})=>{K(r,a),await p(),K(r,a);let n=U.contact(e,r,a),o=i.getQueryData(n),s=await Y(e,{limit:20},t);K(r,a);let c=Oe(i.getQueryData(n)??o??null,s);i.setQueryData(n,c);let l=Q(n);if(c.hasMessageGap&&c.gapCursor){X.delete(l);let i=await Ge(e,n,c,{transport:r,runtimeGeneration:a},t);c=i.view,(i.failed||i.view.hasMessageGap&&!i.progressed)&&i.view.gapCursor&&X.set(l,i.view.gapCursor)}else X.delete(l);K(r,a);let u=i.getQueryData(n)??c;return o&&We(o,u)?o:u},retry:2,staleTime:0,refetchInterval:()=>o.reconcileInForeground?Ie(i.getQueryData(U.snapshot(r)),{assistantID:e}):!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,structuralSharing:!0}),qe=(e,r=!0)=>{let a=t(),o=n(),[s,l]=h.useState(!1),[u,d]=h.useState(null),[p,m]=h.useState(!1),g=h.useRef(null),_=h.useRef(null),y=h.useRef(null),b=h.useRef(null),x=h.useRef({assistantID:e,transport:a,runtimeGeneration:o,enabled:r});x.current={assistantID:e,transport:a,runtimeGeneration:o,enabled:r};let S=c({...Ke(e,a,o,{reconcileInForeground:!0}),enabled:r&&!!e});h.useEffect(()=>{!r||!e||i.invalidateQueries({queryKey:U.snapshot(a),exact:!0},{cancelRefetch:!1})},[e,r,o,a]),h.useEffect(()=>f(n=>{t()===a&&(n.type===`assistants-changed`||n.type===`event-stream-ready`||n.type===`contact-turn-end`)&&(n.type===`contact-turn-end`&&`assistantID`in n&&n.assistantID!==e||i.invalidateQueries({queryKey:U.contact(e,a,o),exact:!0}))}),[e,o,a]),h.useEffect(()=>{let t=Q(U.contact(e,a,o));return()=>{y.current?.abort(),b.current?.abort(),y.current=null,b.current=null,g.current=null,_.current=null,X.delete(t)}},[e,a,o,r]);let C=S.data,w=U.contact(e,a,o),T=async()=>{if(!e||!r)return;if(g.current)return g.current;let t=i.getQueryData(w)??C;if(!t||t.olderComplete||!t.olderCursor)return;d(null),l(!0);let n=new AbortController;b.current?.abort(),b.current=n;let s={transport:a,runtimeGeneration:o,assistantID:e,cursor:t.olderCursor},c=(async()=>{try{K(s.transport,s.runtimeGeneration);let e=await Y(s.assistantID,{limit:20,before:s.cursor},n.signal);if(n.signal.aborted||(K(s.transport,s.runtimeGeneration),x.current.assistantID!==s.assistantID||x.current.transport!==s.transport||x.current.runtimeGeneration!==s.runtimeGeneration))return;let r=i.getQueryData(w)??t;if(e.generation!==r.generation)return;i.setQueryData(w,ke(r,e))}catch(e){if(n.signal.aborted||v(e))return;let t=e instanceof Error?e:Error(String(e));throw d(t),t}finally{b.current===n&&(b.current=null),l(!1),g.current=null}})();return g.current=c,c},E=async(t=`explicit`)=>{if(!e||!r)return;if(_.current)return _.current;let n=i.getQueryData(w)??C;if(!n?.hasMessageGap||!n.gapCursor)return;let s=Q(w);if(t===`auto`&&X.get(s)===n.gapCursor)return;t===`explicit`&&X.delete(s),m(!0);let c=new AbortController;y.current?.abort(),y.current=c;let l={transport:a,runtimeGeneration:o,assistantID:e,cursor:n.gapCursor},u=(async()=>{try{K(l.transport,l.runtimeGeneration);let e=await Ge(l.assistantID,w,n,{transport:l.transport,runtimeGeneration:l.runtimeGeneration},c.signal);if(c.signal.aborted)return;if(K(l.transport,l.runtimeGeneration),e.failed||!e.progressed){e.view.gapCursor&&X.set(s,e.view.gapCursor);return}e.view.hasMessageGap||X.delete(s)}catch(e){if(c.signal.aborted||v(e))return;throw X.set(s,l.cursor),e}finally{y.current===c&&(y.current=null),m(!1),_.current=null}})();return _.current=u,u};return h.useEffect(()=>{if(!r||!e||!C?.hasMessageGap||!C.gapCursor||S.isFetching||p)return;let t=Q(w);X.get(t)!==C.gapCursor&&E(`auto`).catch(()=>void 0)},[r,e,C?.hasMessageGap,C?.gapCursor,S.isFetching,p,w]),{data:C?{messages:C.messages,generation:C.generation,revision:C.revision,nextCursor:C.olderCursor,complete:C.olderComplete}:void 0,status:S.status,fetchStatus:S.fetchStatus,isError:S.isError,isPending:S.isPending,isFetching:S.isFetching,isSuccess:S.isSuccess,error:S.error instanceof Error?S.error:S.error?Error(String(S.error)):null,refetch:()=>S.refetch(),fetchPreviousPage:T,hasPreviousPage:!!(C&&!C.olderComplete&&C.olderCursor),isFetchingPreviousPage:s,previousPageError:u,hasMessageGap:!!C?.hasMessageGap,isFillingMessageGap:p,retryMessageGap:()=>E(`explicit`)}},Je=async(e,r)=>{let a=t(),o=n();await p(),K(a,o);let s=await Y(e,{messageID:r,limit:1});if(K(a,o),!s.messages.some(e=>e.messageID===r&&e.role===`user`))return null;i.invalidateQueries({queryKey:U.contact(e,a,o),exact:!0}),i.invalidateQueries({queryKey:U.snapshot(a),exact:!0});let c=i.getQueryData(U.snapshot(a));return{admitted:!0,messageID:r,revision:s.revision??c?.revision??null}},Ye=(e,r=t(),i=n())=>({queryKey:U.scheduledTasks(e,r,i),queryFn:async({signal:t})=>{K(r,i);let n=ie(await W(`/api/openchamber/assistants/${encodeURIComponent(e)}/scheduled-tasks`,{signal:t}));return K(r,i),n},refetchOnMount:`always`,retry:(e,t)=>!(t instanceof _&&t.status===404)&&e<2}),Xe=(e,r)=>{let i=(0,g.c)(6),a=r===void 0||r,o,s;if(i[0]!==e){let r=t(),a=n();s=c,o=Ye(e,r,a),i[0]=e,i[1]=o,i[2]=s}else o=i[1],s=i[2];let l=a&&!!e,u;return i[3]!==o||i[4]!==l?(u={...o,enabled:l},i[3]=o,i[4]=l,i[5]=u):u=i[5],s(u)},Ze=(e=t())=>({queryKey:U.globalScheduledTasks(e),queryFn:de,refetchOnMount:`always`}),Qe=e=>{let t=(0,g.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Ze(),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i={...r,enabled:n},t[1]=n,t[2]=i),c(i)},$e=e=>e.tasks.some(({task:e})=>e.state.lastStatus===`running`),et=()=>{let e=(0,g.c)(5),n,r,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=t(),n=c,r={...Ze(a),select:$e,staleTime:0,refetchInterval:xt,refetchIntervalInBackground:!1},e[0]=n,e[1]=r,e[2]=a):(n=e[0],r=e[1],a=e[2]);let o=n(r),s,l;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>f(e=>{t()===a&&(e.type===`scheduled-task-ran`||e.type===`event-stream-ready`)&&i.invalidateQueries({queryKey:Ze(a).queryKey,exact:!0})}),l=[a],e[3]=s,e[4]=l):(s=e[3],l=e[4]),h.useEffect(s,l),o.data===!0},tt=(e,r=t())=>{i.invalidateQueries({queryKey:[r,n(),`assistants`,`contact`,e]})},nt=(e=t())=>({queryKey:U.capability(e),queryFn:()=>vt(),retry:!1}),rt=()=>{let e=(0,g.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=nt(),e[0]=t):t=e[0],c(t)},it=(e=i,n=t())=>e.getQueryData(U.snapshot(n)),at=(e=i,n=t())=>e.fetchQuery(q(n)),ot=async(e=i)=>{let r=t(),a=n();await e.invalidateQueries({queryKey:U.snapshot(r),exact:!0}),K(r,a);let o=await e.fetchQuery(q(r));return K(r,a),o},st=async(e,r)=>{let a=t(),o=n();await W(`/api/openchamber/assistants/${encodeURIComponent(e)}/session/abort`,G(`POST`,{sessionID:r.sessionID,sessionGeneration:r.sessionGeneration})),K(a,o),i.invalidateQueries({queryKey:U.snapshot(a),exact:!0})},ct=15e3,lt=e=>{throw e instanceof _?e:v(e)?new _(`admission_timeout`,408):e},ut=async(e,r,i)=>{let a=t(),o=n(),s=typeof i==`string`?[{type:`text`,text:i}]:Array.isArray(i.parts)&&i.parts.length>0?i.parts:[{type:`text`,text:i.text??``}],c=AbortSignal.timeout(ct);try{let t=ee(await W(`/api/openchamber/assistants/${encodeURIComponent(e)}/messages`,{...G(`POST`,{messageID:r,parts:s,language:d.getState().locale}),signal:c}));return K(a,o),je(e,t.binding,a),tt(e,a),t}catch(e){return lt(e)}},dt=async(e,r,i,a,o)=>{let s=t(),c=n(),l=te(await W(`/api/openchamber/assistants/${encodeURIComponent(e)}/share`,G(`POST`,{operationID:r,payload:{messageID:i,parts:a,source:o}})));return K(s,c),l},ft=async(e,r=t(),i=n())=>{K(r,i);let a=te(await W(`/api/openchamber/assistants/share-operations/${encodeURIComponent(e)}`));return K(r,i),a},pt=async(e,r=t(),i=n())=>{let a=e;for(let e=0;e<60&&(a.state===`running`||a.state===`submitting`);e+=1)K(r,i),await new Promise(e=>setTimeout(e,750)),a=await ft(a.operationID,r,i);if(K(r,i),a.state===`completed`)return a;throw a.state===`failed`?new y(a.errorCode??`share_failed`,400,a):new y(`share_unresolved`,408,a)},mt=async(e,n)=>{await W(`/api/openchamber/assistants/settings`,G(`PUT`,{enabled:e,expectedRevision:n}));let r=t();await Promise.all([i.invalidateQueries({queryKey:U.snapshot(r),exact:!0}),i.invalidateQueries({queryKey:U.capability(r),exact:!0})])},ht=async e=>{let n=t(),r=F(await W(`/api/openchamber/assistants`,G(`POST`,e)));return Me(r,n),r},gt=async(e,r)=>{let i=t(),a=n(),o=F(await W(`/api/openchamber/assistants/${encodeURIComponent(e.id)}`,G(`PATCH`,{...r,expectedRevision:e.revision})));return K(i,a),Me(o,i),o},_t=async e=>{await W(`/api/openchamber/assistants/${encodeURIComponent(e.id)}`,G(`DELETE`,{expectedRevision:e.revision})),await i.invalidateQueries({queryKey:U.snapshot(t())})},vt=async()=>O(await W(`/api/openchamber/assistants/capability`)),yt=async(e,r)=>{let a=t(),o=n(),s=M(r);try{let t=P(await W(`/api/openchamber/assistants/${encodeURIComponent(e)}/contact/read`,{...G(`POST`,s),signal:AbortSignal.timeout(15e3)}));if(K(a,o),t.assistantID!==e)throw new _(`invalid_assistant_read_response`,200);return t}finally{t()===a&&n()===o&&i.invalidateQueries({queryKey:U.snapshot(a),exact:!0})}},bt=async e=>{let r=e.assistants.filter(e=>(e.unreadCount??0)>0&&e.readTip).map(e=>({id:e.id,position:{...e.readTip}})),i=t(),a=n(),o=[];for(let e=0;e<r.length;e+=4)o.push(...await Promise.allSettled(r.slice(e,e+4).map(async e=>(K(i,a),yt(e.id,e.position)))));return{failed:o.filter(e=>e.status===`rejected`).length}};function xt(e){return e.state.data&&$e(e.state.data)?2500:15e3}var $=o();function St(e){let t=(0,g.c)(32),{title:n,subtitle:r,backAriaLabel:i,onBack:a,backDisabled:o,actions:s,trailing:c,sticky:d,overlay:f,elevated:p}=e,h=o!==void 0&&o,_;t[0]===s?_=t[1]:(_=s===void 0?[]:s,t[0]=s,t[1]=_);let v=_,y=d!==void 0&&d,b=f!==void 0&&f,x=p!==void 0&&p,S=Array.isArray(c)?c.filter(Boolean).length:+!!c,C=x||v.some(wt),w=y&&`oc-mobile-detail-navigation-sticky`,T=b&&`absolute inset-x-0 top-0`,E=C?`z-[60]`:b?`z-30`:void 0,D;t[2]!==w||t[3]!==T||t[4]!==E?(D=l(`oc-mobile-detail-navigation relative shrink-0 pt-[max(0.25rem,var(--oc-safe-area-top,0px))]`,w,T,E),t[2]=w,t[3]=T,t[4]=E,t[5]=D):D=t[5];let O=v.length+S>1?`grid-cols-[2.75rem_minmax(0,1fr)_auto]`:`grid-cols-[2.75rem_minmax(0,1fr)_2.75rem]`,k;t[6]===O?k=t[7]:(k=l(`oc-mobile-detail-navigation-content grid items-center gap-1 px-4`,O),t[6]=O,t[7]=k);let A;t[8]!==i||t[9]!==h||t[10]!==a?(A=a?(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`justify-self-start`,onClick:a,disabled:h,"aria-label":i,children:(0,$.jsx)(m,{name:`arrow-left-s`,className:`size-5`})}):(0,$.jsx)(`span`,{"aria-hidden":`true`}),t[8]=i,t[9]=h,t[10]=a,t[11]=A):A=t[11];let j;t[12]===n?j=t[13]:(j=(0,$.jsx)(`div`,{className:`oc-mobile-detail-title w-full truncate typography-ui-label font-medium text-foreground`,children:n}),t[12]=n,t[13]=j);let M;t[14]===r?M=t[15]:(M=r?(0,$.jsx)(`div`,{className:`oc-mobile-detail-subtitle w-full truncate text-muted-foreground`,"aria-live":`polite`,children:r}):null,t[14]=r,t[15]=M);let N;t[16]!==j||t[17]!==M?(N=(0,$.jsxs)(`div`,{className:`flex w-full max-w-72 min-w-0 flex-col items-center justify-center justify-self-center px-1`,children:[j,M]}),t[16]=j,t[17]=M,t[18]=N):N=t[18];let P;t[19]===v?P=t[20]:(P=v.map(Ct),t[19]=v,t[20]=P);let F;t[21]!==P||t[22]!==c?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2`,children:[c,P]}),t[21]=P,t[22]=c,t[23]=F):F=t[23];let I;t[24]!==k||t[25]!==A||t[26]!==N||t[27]!==F?(I=(0,$.jsxs)(`div`,{className:k,children:[A,N,F]}),t[24]=k,t[25]=A,t[26]=N,t[27]=F,t[28]=I):I=t[28];let L;return t[29]!==D||t[30]!==I?(L=(0,$.jsx)(`header`,{className:D,children:I}),t[29]=D,t[30]=I,t[31]=L):L=t[31],L}function Ct(e,t){return(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:l(e.elevated&&`relative z-[60]`),onClick:e.onClick,disabled:e.disabled,"aria-label":e.ariaLabel,"aria-expanded":e.pressed,title:e.title,children:(0,$.jsx)(m,{name:e.icon,className:`size-5`})},`${e.icon}:${t}`)}function wt(e){return e.elevated}export{ue as A,Qe as C,he as D,ge as E,v as F,fe as M,_ as N,pe as O,y as P,He as S,pt as T,rt as _,ht as a,Re as b,vt as c,yt as d,it as f,gt as g,mt as h,Je as i,me as j,de as k,ot as l,dt as m,st as n,_t as o,ut as p,Ke as r,at as s,St as t,bt as u,qe as v,et as w,Be as x,Xe as y};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-3ad3yzM7.js";import{n as r}from"./runtime-fetch-QCWYlAx0.js";import{m as i}from"./persistence-DUPZl7Oy.js";import{it as a,rt as o}from"./vendor-base-ui-CdzJ6My_.js";import{n as s}from"./vendor-react-BP2cRVqX.js";import{s as c}from"./vendor-tanstack-react-query-CdqCAt40.js";import{r as l,t as u}from"./button-kJNzMb1G.js";import{i as d}from"./store-D5OeM4wB.js";import{bo as f,yo as p}from"./useMobileNavigationStore-B24J82Xs.js";import{n as m}from"./Icon-DewMAW7N.js";var h=e(a(),1),g=s(),_=class extends Error{code;status;resource;constructor(e,t,n,r){super(typeof r==`string`&&r.trim()?r.trim():e),this.code=e,this.status=t,this.resource=n}},v=e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return t===`AbortError`||t===`TimeoutError`},y=class extends _{operation;constructor(e,t,n){super(e,t,`share_operation`),this.operation=n}},b=(e,t=200)=>{throw new _(`invalid_${e}_response`,t,e)},x=(e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e:b(t),S=(e,t)=>typeof e==`string`?e:b(t),C=(e,t)=>e===null||typeof e==`string`?e:b(t),w=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:b(t),T=(e,t)=>e===null?null:w(e,t),E=(e,t)=>typeof e==`boolean`?e:b(t),D=(e,t,n)=>t.includes(e)?e:b(n),O=e=>{let t=x(e,`capability`);return{supported:E(t.supported,`capability`),enabled:E(t.enabled,`capability`),revision:w(t.revision,`capability`),serverInstanceID:C(t.serverInstanceID,`capability`),sharingAvailable:t.sharingAvailable!==void 0&&E(t.sharingAvailable,`capability`)}},k=e=>{if(e==null)return null;let t=x(e,`assistant`);return{turnID:S(t.turnID,`assistant`),messageID:S(t.messageID,`assistant`),status:D(t.status,[`queued`,`running`],`assistant`),admittedAt:w(t.admittedAt,`assistant`)}},A=e=>{if(e==null)return null;let t=x(e,`assistant_preview`),n=w(t.ordinal,`assistant_preview`);return!Number.isSafeInteger(n)||n<0?b(`assistant_preview`):{...t.createdAt===void 0?{}:{createdAt:w(t.createdAt,`assistant_preview`)},messageID:S(t.messageID,`assistant_preview`),ordinal:n,role:D(t.role,[`user`,`assistant`],`assistant_preview`),text:S(t.text,`assistant_preview`),fallbackKind:t.fallbackKind===null?null:D(t.fallbackKind,[`image`,`file`,`session`,`assistant`,`schedule`],`assistant_preview`)}},j=e=>{let t=w(e,`assistant_read`);return Number.isSafeInteger(t)&&t>=0?t:b(`assistant_read`)},M=e=>{let t=x(e,`assistant_read`);return{generation:j(t.generation),ordinal:j(t.ordinal),messageID:S(t.messageID,`assistant_read`)}},N=e=>({unreadCount:e.unreadCount===void 0?0:j(e.unreadCount),readWatermark:e.readWatermark==null?null:M(e.readWatermark),readTip:e.readTip==null?null:M(e.readTip)}),P=e=>{let t=x(e,`assistant_read`);return{assistantID:S(t.assistantID,`assistant_read`),changed:E(t.changed,`assistant_read`),unreadCount:j(t.unreadCount),readWatermark:M(t.readWatermark),readTip:M(t.readTip),revision:j(t.revision)}},F=e=>{let t=x(e,`assistant`),n=Array.isArray(t.historySessionIDs)?t.historySessionIDs.map(e=>S(e,`assistant`)):[],r=t.historySessionCount===void 0?n.length:w(t.historySessionCount,`assistant`);if(!Number.isSafeInteger(r)||r<n.length)return b(`assistant`);let i=Array.isArray(t.assignedSessionIDs)?t.assignedSessionIDs.map(e=>S(e,`assistant`)):[],a=t.activeContactTurn===void 0?null:k(t.activeContactTurn),o=t.working===void 0?a!=null:E(t.working,`assistant`);return{...N(t),latestMessagePreview:A(t.latestMessagePreview),id:S(t.id,`assistant`),avatarSeed:S(t.avatarSeed??t.id,`assistant`),revision:w(t.revision,`assistant`),enabled:E(t.enabled,`assistant`),name:S(t.name,`assistant`),defaultPrompt:S(t.defaultPrompt,`assistant`),workspacePath:C(t.workspacePath,`assistant`),effectiveWorkspacePath:S(t.effectiveWorkspacePath,`assistant`),managedWorkspacePath:C(t.managedWorkspacePath??null,`assistant`),providerID:S(t.providerID,`assistant`),modelID:S(t.modelID,`assistant`),agent:C(t.agent,`assistant`),variant:C(t.variant??null,`assistant`),mode:D(t.mode,[`continuous`,`stateless`],`assistant`),sessionID:C(t.sessionID,`assistant`),sessionGeneration:w(t.sessionGeneration,`assistant`),historySessionIDs:n,historySessionCount:r,assignedSessionIDs:i,working:o,activeContactTurn:a,createdAt:T(t.createdAt,`assistant`),updatedAt:w(t.updatedAt,`assistant`),tombstoneAt:T(t.tombstoneAt,`assistant`)}},I=e=>{let t=x(e,`snapshot`);return{revision:w(t.revision,`snapshot`),enabled:E(t.enabled,`snapshot`),assistants:Array.isArray(t.assistants)?t.assistants.map(F):b(`snapshot`)}},L=e=>{let t=x(e,`binding`);return{sessionID:C(t.sessionID,`binding`),directory:S(t.directory,`binding`),sessionGeneration:w(t.sessionGeneration,`binding`)}},ee=e=>{let t=x(e,`message_admission`);if(t.admitted!==!0)return b(`message_admission`);let n=t.revision===void 0||t.revision===null?null:w(t.revision,`message_admission`);return{binding:L(t.binding),messageID:S(t.messageID,`message_admission`),admitted:!0,revision:n,...t.replayed===!0?{replayed:!0}:{}}},te=e=>{let t=x(e,`share_operation`);return{operationID:S(t.operationID,`share_operation`),assistantID:S(t.assistantID,`share_operation`),sessionID:C(t.sessionID,`share_operation`),messageID:C(t.messageID,`share_operation`),state:D(t.state,[`submitting`,`running`,`completed`,`failed`,`unresolved`],`share_operation`),phase:S(t.phase,`share_operation`),attempt:w(t.attempt,`share_operation`),leaseExpiresAt:T(t.leaseExpiresAt,`share_operation`),errorCode:C(t.errorCode,`share_operation`)}},ne=e=>{let t=x(e,`assistant_contact_part`);if(t.type===`text`)return{type:`text`,text:S(t.text,`assistant_contact_part`)};if(t.type===`file`){let e=t.filename===void 0||t.filename===null?void 0:S(t.filename,`assistant_contact_part`),n=S(t.mime,`assistant_contact_part`),r=t.url!==void 0&&t.url!==null,i=t.attachmentID!==void 0&&t.attachmentID!==null;if(r&&i)return b(`assistant_contact_part`);if(i){let r=w(t.size,`assistant_contact_part`);return!Number.isSafeInteger(r)||r<0?b(`assistant_contact_part`):{type:`file`,mime:n,attachmentID:S(t.attachmentID,`assistant_contact_part`),sha256:S(t.sha256,`assistant_contact_part`),size:r,...e?{filename:e}:{}}}return r?{type:`file`,mime:n,url:S(t.url,`assistant_contact_part`),...e?{filename:e}:{}}:b(`assistant_contact_part`)}if(t.type===`card`){let e=D(t.cardType,[`session`,`assistant`,`schedule`],`assistant_contact_part`);return e===`session`?{type:`card`,cardType:`session`,sessionID:S(t.sessionID,`assistant_contact_part`),directory:S(t.directory,`assistant_contact_part`),title:C(t.title??null,`assistant_contact_part`),status:C(t.status??null,`assistant_contact_part`),branch:C(t.branch??null,`assistant_contact_part`)}:e===`assistant`?{type:`card`,cardType:`assistant`,assistantID:S(t.assistantID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),providerID:S(t.providerID,`assistant_contact_part`),modelID:S(t.modelID,`assistant_contact_part`),mode:D(t.mode??`continuous`,[`continuous`,`stateless`],`assistant_contact_part`)}:{type:`card`,cardType:`schedule`,taskID:S(t.taskID,`assistant_contact_part`),projectID:S(t.projectID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),kind:C(t.kind??null,`assistant_contact_part`),time:C(t.time??null,`assistant_contact_part`),timezone:C(t.timezone??null,`assistant_contact_part`),prompt:C(t.prompt??null,`assistant_contact_part`)}}return b(`assistant_contact_part`)},re=e=>{let t=x(e,`assistant_contact`),n=C(t.nextCursor,`assistant_contact`),r=E(t.complete,`assistant_contact`);if(!r&&!n||r&&n||!Array.isArray(t.messages))return b(`assistant_contact`);let i=w(t.generation,`assistant_contact`),a=w(t.revision,`assistant_contact`);return!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<0?b(`assistant_contact`):{messages:t.messages.map(e=>{let t=x(e,`assistant_contact_message`);if(!Array.isArray(t.parts))return b(`assistant_contact_message`);let n=t.parts.map(ne);return{messageID:S(t.messageID,`assistant_contact_message`),assistantID:S(t.assistantID,`assistant_contact_message`),role:D(t.role,[`user`,`assistant`,`peer`],`assistant_contact_message`),turnID:S(t.turnID,`assistant_contact_message`),bubbleIndex:w(t.bubbleIndex,`assistant_contact_message`),createdAt:w(t.createdAt,`assistant_contact_message`),ordinal:w(t.ordinal,`assistant_contact_message`),status:S(t.status,`assistant_contact_message`),fromAssistantID:C(t.fromAssistantID??null,`assistant_contact_message`),fromAssistantName:C(t.fromAssistantName??null,`assistant_contact_message`),parts:n,text:typeof t.text==`string`?t.text:n.filter(e=>e.type===`text`).map(e=>e.text).join(``),cards:n.filter(e=>e.type===`card`)}}),nextCursor:n,complete:r,generation:i,revision:a}},ie=e=>{let t=x(e,`assistant_scheduled_tasks`);return Array.isArray(t.tasks)?{tasks:t.tasks.map(e=>{let t=x(e,`assistant_scheduled_task`),n=t.task===null||t.task===void 0?null:x(t.task,`assistant_scheduled_task_live`);return{assistantID:S(t.assistantID,`assistant_scheduled_task`),projectID:S(t.projectID,`assistant_scheduled_task`),taskID:S(t.taskID,`assistant_scheduled_task`),createdAt:w(t.createdAt,`assistant_scheduled_task`),projectPath:C(t.projectPath??null,`assistant_scheduled_task`),projectLabel:C(t.projectLabel??null,`assistant_scheduled_task`),task:n}})}:b(`assistant_scheduled_tasks`)},R=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim().length>0)return t.error}catch{return t}return t},z=e=>{let t=typeof e==`string`?e.trim():``;if(!t)throw Error(`projectId is required`);return t},B=e=>e===null||typeof e==`string`,ae=e=>e===null||typeof e==`number`&&Number.isFinite(e),oe=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=864e13,se=e=>e===null||oe(e),ce=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.projectId==`string`&&t.projectId.length>0&&typeof t.taskId==`string`&&t.taskId.length>0&&typeof t.taskName==`string`&&(t.trigger===`scheduled`||t.trigger===`manual`)&&(t.status===`running`||t.status===`success`||t.status===`error`)&&B(t.sessionId)&&B(t.directory)&&B(t.error)&&oe(t.startedAt)&&se(t.finishedAt)&&ae(t.durationMs)&&(t.durationMs===null||t.durationMs>=0)},le=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed scheduled task runs response`);let t=e;if(!Array.isArray(t.runs)||!t.runs.every(ce)||!B(t.nextCursor)||typeof t.complete!=`boolean`||t.complete!==(t.nextCursor===null)||t.nextCursor!==null&&t.nextCursor.length===0)throw Error(`Malformed scheduled task runs response`);return{runs:t.runs,nextCursor:t.nextCursor,complete:t.complete}},ue=async(e,t)=>{let n=new URLSearchParams;e.before&&n.set(`before`,e.before);let i=e.limit??20;if(!Number.isInteger(i)||i<1)throw Error(`limit must be a positive integer`);n.set(`limit`,String(i)),e.projectId&&n.set(`projectId`,e.projectId),e.taskId&&n.set(`taskId`,e.taskId);let a=await r(`/api/openchamber/scheduled-task-runs?${n.toString()}`,{signal:t});if(!a.ok)throw Error(await R(a,`Failed to load scheduled task history`));return le(await a.json().catch(()=>null))},de=async({signal:e}={})=>{let t=await r(`/api/openchamber/scheduled-tasks`,{signal:e});if(!t.ok)throw Error(await R(t,`Failed to load schedules`));let n=await t.json().catch(()=>null);if(!n||!Array.isArray(n.tasks))throw Error(`Malformed schedules response`);return{tasks:Array.isArray(n?.tasks)?n.tasks:[],failedProjectIds:Array.isArray(n?.failedProjectIds)?n.failedProjectIds.filter(e=>typeof e==`string`):[]}},fe=async(e,t)=>{let n=z(e),i=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks`,{method:`PUT`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify({task:t})});if(!i.ok)throw Error(await R(i,`Failed to save schedule`));let a=await i.json().catch(()=>null);return!a||!Array.isArray(a.tasks)?[]:a.tasks},pe=async(e,t)=>{let n=z(e),i=z(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}`,{method:`DELETE`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await R(a,`Failed to delete schedule`));let o=await a.json().catch(()=>null);return!o||!Array.isArray(o.tasks)?[]:o.tasks},me=async(e,t)=>{let n=z(e),i=z(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}/run`,{method:`POST`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await R(a,`Failed to run schedule`));let o=await a.json().catch(()=>null);return{sessionId:typeof o?.sessionId==`string`&&o.sessionId.length>0?o.sessionId:void 0}},V=(e,t)=>e.ordinal===t.ordinal?e.messageID<t.messageID?-1:+(e.messageID>t.messageID):e.ordinal-t.ordinal,he=e=>{if(e.type===`file`||e.type===`card`)return!0;if(e.type!==`text`)return!1;let t=typeof e.text==`string`?e.text.trim():``;return!!t&&!t.startsWith(`oc.settle.`)},ge=(e,t)=>{if(!t||!e.readTip||!((e.unreadCount??0)>0))return null;let n=e.readTip;if(t.generation!==n.generation)return null;let r;for(let n=t.messages.length-1;n>=0;--n){let i=t.messages[n];if(i.assistantID===e.id&&(i.status===`complete`||i.status===`error`)&&i.parts.some(he)){r=i;break}}if(!r)return null;let i=e.readWatermark;return i&&(i.generation>t.generation||i.generation===t.generation&&V({ordinal:i.ordinal,messageID:i.messageID},{ordinal:r.ordinal,messageID:r.messageID})>=0)?null:{generation:t.generation,ordinal:r.ordinal,messageID:r.messageID}},_e=()=>({messages:[],generation:-1,revision:0,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}),ve=e=>!!(e&&e.generation>=0),ye=(e,t)=>V({ordinal:e.ordinal,messageID:e.messageID},{ordinal:t.ordinal,messageID:t.messageID}),H=(e,t,n=`incoming`)=>{let r=new Map;for(let t of e)r.set(t.messageID,t);for(let e of t)(n===`incoming`||!r.has(e.messageID))&&r.set(e.messageID,e);return[...r.values()].sort(ye)},be=e=>{let t=1/0;for(let n of e)n.ordinal<t&&(t=n.ordinal);return Number.isFinite(t)?t:null},xe=e=>e.map(e=>e.messageID),Se=(e,t)=>{for(let n of e)if(t.has(n))return!0;return!1},Ce=e=>new Set(e),we=(e,t)=>!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n]),Te=e=>({...e,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null}),Ee=e=>({ordinal:e.ordinal,messageID:e.messageID}),De=(e,t,n)=>{if(n)return[...t];if(t.length===0)return[...e];let r=t[0];return[...e.filter(e=>V(Ee(e),Ee(r))<0),...t]},Oe=(e,t)=>{let n=e??_e(),r=ve(n),i=[...t.messages].sort(ye),a=xe(i);if(r&&t.generation<n.generation)return n;if(r&&t.generation>n.generation)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};if(!r)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};let o=Math.max(n.revision,t.revision),s=t.revision>=n.revision;if(i.length===0)return s&&t.complete?{messages:[],generation:t.generation,revision:o,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}:{...n,generation:t.generation,revision:o,olderCursor:n.olderCursor??t.nextCursor,olderComplete:n.olderComplete&&t.complete,liveWindowIDs:[],hasMessageGap:n.hasMessageGap,gapCursor:n.hasMessageGap?t.nextCursor??n.gapCursor:null,gapRequestIDs:n.hasMessageGap?n.gapRequestIDs:null,gapTargetIDs:n.hasMessageGap?n.gapTargetIDs:null};let c;if(s)c=De(n.messages,i,t.complete);else{let e=be(i);c=H(n.messages.filter(t=>t.ordinal<e),H(n.messages.filter(t=>t.ordinal>=e),i,`existing`),`incoming`)}let l=n.liveWindowIDs,u=Ce(a),d=l.length>0&&Se(l,u),f=n.hasMessageGap,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs;if(!d&&l.length>0&&t.nextCursor){f=!0,p=t.nextCursor;let e=l.filter(e=>!u.has(e));m=e.length>0?e:[...l],h=n.hasMessageGap&&n.gapTargetIDs&&n.gapTargetIDs.length>0?n.gapTargetIDs:m}else n.hasMessageGap?(f=!0,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs):(f=!1,p=null,m=null,h=null);return{messages:c,generation:t.generation,revision:o,olderCursor:n.liveWindowIDs.length===0&&n.messages.length===0?t.complete?null:t.nextCursor:n.olderCursor,olderComplete:!r||n.liveWindowIDs.length===0&&n.messages.length===0?t.complete:n.olderComplete,hasMessageGap:f,gapCursor:f?p:null,gapRequestIDs:f?m:null,gapTargetIDs:f?h:null,liveWindowIDs:a}},ke=(e,t)=>{if(!ve(e)||t.generation!==e.generation)return e;let n=t.revision>=e.revision?`incoming`:`existing`,r=H(e.messages,t.messages,n);return{...e,messages:r,revision:Math.max(e.revision,t.revision),olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete}},Ae=(e,t,n)=>{if(!ve(e)||t.generation!==e.generation)return e;let r=t.revision>=e.revision?`incoming`:`existing`,i=H(e.messages,t.messages,r),a=Math.max(e.revision,t.revision),o=n?.requestIDs??e.gapRequestIDs;if(!(e.hasMessageGap&&o&&e.gapRequestIDs&&we(o,e.gapRequestIDs)))return{...e,messages:i,revision:a};let s=xe(t.messages),c=e.gapTargetIDs??[],l=Ce(c);return c.length>0&&Se(s,l)||t.complete||!t.nextCursor?Te({...e,messages:i,revision:a}):{...e,messages:i,revision:a,hasMessageGap:!0,gapCursor:t.nextCursor??e.gapCursor,gapRequestIDs:e.gapRequestIDs,gapTargetIDs:e.gapTargetIDs}},U={snapshot:(e=t())=>[e,`assistants`,`snapshot`],capability:(e=t())=>[e,`assistants`,`capability`],history:(e,r,i,a=t(),o=n())=>[a,o,`assistants`,`history`,e,r,i],contact:(e,r=t(),i=n())=>[r,i,`assistants`,`contact`,e],scheduledTasks:(e,r=t(),i=n())=>[r,i,`assistants`,`scheduled-tasks`,e],globalScheduledTasks:(e=t())=>[e,`scheduled-tasks`]},W=async(e,t={})=>{let n=await r(e,t),i=await n.json().catch(()=>null);if(!n.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`request_failed`,t=i&&typeof i==`object`&&`message`in i&&typeof i.message==`string`?i.message:void 0;throw new _(e,n.status,void 0,t)}return i},G=(e,t)=>({method:e,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),K=(e,r)=>{if(t()!==e||n()!==r)throw new _(`runtime_stale`,409)},je=(e,t,r)=>{i.setQueryData(U.snapshot(r),n=>n&&{...n,assistants:n.assistants.map(n=>n.id!==e||n.sessionGeneration>t.sessionGeneration?n:{...n,sessionID:t.sessionID,sessionGeneration:t.sessionGeneration,effectiveWorkspacePath:t.directory})}),i.invalidateQueries({queryKey:U.snapshot(r)}),i.invalidateQueries({queryKey:[r,n(),`assistants`,`history`,e]})},Me=(e,t)=>{i.setQueryData(U.snapshot(t),t=>t&&{...t,assistants:t.assistants.some(t=>t.id===e.id)?t.assistants.map(t=>t.id===e.id?e:t):[...t.assistants,e]}),i.invalidateQueries({queryKey:U.snapshot(t)})},Ne=2500,Pe=15e3,Fe=e=>!!e?.assistants.some(e=>e.working||e.activeContactTurn),Ie=(e,t={})=>{if(t.assistantID){let n=e?.assistants.find(e=>e.id===t.assistantID);return n?.working||n?.activeContactTurn?Ne:Pe}return Fe(e)?Ne:Pe},q=(e=t())=>({queryKey:U.snapshot(e),queryFn:async({signal:e})=>I(await W(`/api/openchamber/assistants/snapshot`,{signal:e})),staleTime:0,retry:2,refetchInterval:e=>Ie(e.state.data),refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),J=new Map,Le=e=>{let n=J.get(e);if(n)n.count+=1;else{let n=f(n=>{if(t()!==e)return;let r=i.getQueryData(U.snapshot(e));(n.type===`event-stream-ready`||n.type===`contact-turn-start`||n.type===`contact-turn-end`||n.type===`assistants-changed`&&(!r||n.revision>r.revision))&&i.invalidateQueries({queryKey:U.snapshot(e),exact:!0})});J.set(e,{count:1,dispose:n})}return()=>{let t=J.get(e);t&&--t.count===0&&(t.dispose(),J.delete(e))}},Re=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=c,r=q(i),e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Le(i),s=[i],e[3]=o,e[4]=s):(o=e[3],s=e[4]),h.useEffect(o,s),a},ze=e=>e.enabled?e.assistants.reduce((e,t)=>e+(t.unreadCount??0),0):0,Be=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=c,r={...q(i),select:ze},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Le(i),s=[i],e[3]=o,e[4]=s):(o=e[3],s=e[4]),h.useEffect(o,s),a.data??0},Ve=e=>e.enabled&&Fe(e),He=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=c,r={...q(i),select:Ve},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Le(i),s=[i],e[3]=o,e[4]=s):(o=e[3],s=e[4]),h.useEffect(o,s),a.data??!1},Ue=(e,t={})=>{let n=new URLSearchParams;return n.set(`limit`,String(t.limit??20)),t.before&&n.set(`before`,t.before),t.messageID&&n.set(`messageID`,t.messageID),`/api/openchamber/assistants/${encodeURIComponent(e)}/contact/messages?${n}`},Y=async(e,t,n)=>re(await W(Ue(e,t),n?{signal:n}:{})),We=(e,t)=>e.generation===t.generation&&e.revision===t.revision&&e.olderCursor===t.olderCursor&&e.olderComplete===t.olderComplete&&e.hasMessageGap===t.hasMessageGap&&e.gapCursor===t.gapCursor&&e.messages===t.messages&&e.liveWindowIDs===t.liveWindowIDs&&e.gapRequestIDs===t.gapRequestIDs&&e.gapTargetIDs===t.gapTargetIDs,X=new Map,Z=new Map,Q=e=>e.join(``),Ge=async(e,t,n,r,a)=>{let o=Q(t),s=Z.get(o);if(s)return s;let c=(async()=>{let o=i.getQueryData(t)??n,s=0,c=!1,l=!1,u=o.gapRequestIDs?[...o.gapRequestIDs]:null,d=o.gapCursor;for(;o.hasMessageGap&&o.gapCursor&&s<5&&!a?.aborted;){K(r.transport,r.runtimeGeneration),s+=1;let n=o.gapCursor;try{let s=await Y(e,{limit:20,before:n},a);K(r.transport,r.runtimeGeneration);let l=i.getQueryData(t)??o;if(s.generation!==l.generation){o=l;break}let f=!u||!!(l.hasMessageGap&&l.gapRequestIDs&&l.gapRequestIDs.length===u.length&&l.gapRequestIDs.every((e,t)=>e===u[t]));if(o=Ae(l,s,u?{requestIDs:u,cursor:d}:void 0),i.setQueryData(t,o),!f)break;if(!o.hasMessageGap){c=!0;break}if(o.gapCursor&&o.gapCursor!==n)c=!0;else break}catch(e){if(a?.aborted||v(e))break;l=!0,o=i.getQueryData(t)??o;break}}return{view:i.getQueryData(t)??o,failed:l,progressed:c}})();Z.set(o,c);try{return await c}finally{Z.get(o)===c&&Z.delete(o)}},Ke=(e,r=t(),a=n(),o={})=>({queryKey:U.contact(e,r,a),queryFn:async({signal:t})=>{K(r,a),await p(),K(r,a);let n=U.contact(e,r,a),o=i.getQueryData(n),s=await Y(e,{limit:20},t);K(r,a);let c=Oe(i.getQueryData(n)??o??null,s);i.setQueryData(n,c);let l=Q(n);if(c.hasMessageGap&&c.gapCursor){X.delete(l);let i=await Ge(e,n,c,{transport:r,runtimeGeneration:a},t);c=i.view,(i.failed||i.view.hasMessageGap&&!i.progressed)&&i.view.gapCursor&&X.set(l,i.view.gapCursor)}else X.delete(l);K(r,a);let u=i.getQueryData(n)??c;return o&&We(o,u)?o:u},retry:2,staleTime:0,refetchInterval:()=>o.reconcileInForeground?Ie(i.getQueryData(U.snapshot(r)),{assistantID:e}):!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,structuralSharing:!0}),qe=(e,r=!0)=>{let a=t(),o=n(),[s,l]=h.useState(!1),[u,d]=h.useState(null),[p,m]=h.useState(!1),g=h.useRef(null),_=h.useRef(null),y=h.useRef(null),b=h.useRef(null),x=h.useRef({assistantID:e,transport:a,runtimeGeneration:o,enabled:r});x.current={assistantID:e,transport:a,runtimeGeneration:o,enabled:r};let S=c({...Ke(e,a,o,{reconcileInForeground:!0}),enabled:r&&!!e});h.useEffect(()=>{!r||!e||i.invalidateQueries({queryKey:U.snapshot(a),exact:!0},{cancelRefetch:!1})},[e,r,o,a]),h.useEffect(()=>f(n=>{t()===a&&(n.type===`assistants-changed`||n.type===`event-stream-ready`||n.type===`contact-turn-end`)&&(n.type===`contact-turn-end`&&`assistantID`in n&&n.assistantID!==e||i.invalidateQueries({queryKey:U.contact(e,a,o),exact:!0}))}),[e,o,a]),h.useEffect(()=>{let t=Q(U.contact(e,a,o));return()=>{y.current?.abort(),b.current?.abort(),y.current=null,b.current=null,g.current=null,_.current=null,X.delete(t)}},[e,a,o,r]);let C=S.data,w=U.contact(e,a,o),T=async()=>{if(!e||!r)return;if(g.current)return g.current;let t=i.getQueryData(w)??C;if(!t||t.olderComplete||!t.olderCursor)return;d(null),l(!0);let n=new AbortController;b.current?.abort(),b.current=n;let s={transport:a,runtimeGeneration:o,assistantID:e,cursor:t.olderCursor},c=(async()=>{try{K(s.transport,s.runtimeGeneration);let e=await Y(s.assistantID,{limit:20,before:s.cursor},n.signal);if(n.signal.aborted||(K(s.transport,s.runtimeGeneration),x.current.assistantID!==s.assistantID||x.current.transport!==s.transport||x.current.runtimeGeneration!==s.runtimeGeneration))return;let r=i.getQueryData(w)??t;if(e.generation!==r.generation)return;i.setQueryData(w,ke(r,e))}catch(e){if(n.signal.aborted||v(e))return;let t=e instanceof Error?e:Error(String(e));throw d(t),t}finally{b.current===n&&(b.current=null),l(!1),g.current=null}})();return g.current=c,c},E=async(t=`explicit`)=>{if(!e||!r)return;if(_.current)return _.current;let n=i.getQueryData(w)??C;if(!n?.hasMessageGap||!n.gapCursor)return;let s=Q(w);if(t===`auto`&&X.get(s)===n.gapCursor)return;t===`explicit`&&X.delete(s),m(!0);let c=new AbortController;y.current?.abort(),y.current=c;let l={transport:a,runtimeGeneration:o,assistantID:e,cursor:n.gapCursor},u=(async()=>{try{K(l.transport,l.runtimeGeneration);let e=await Ge(l.assistantID,w,n,{transport:l.transport,runtimeGeneration:l.runtimeGeneration},c.signal);if(c.signal.aborted)return;if(K(l.transport,l.runtimeGeneration),e.failed||!e.progressed){e.view.gapCursor&&X.set(s,e.view.gapCursor);return}e.view.hasMessageGap||X.delete(s)}catch(e){if(c.signal.aborted||v(e))return;throw X.set(s,l.cursor),e}finally{y.current===c&&(y.current=null),m(!1),_.current=null}})();return _.current=u,u};return h.useEffect(()=>{if(!r||!e||!C?.hasMessageGap||!C.gapCursor||S.isFetching||p)return;let t=Q(w);X.get(t)!==C.gapCursor&&E(`auto`).catch(()=>void 0)},[r,e,C?.hasMessageGap,C?.gapCursor,S.isFetching,p,w]),{data:C?{messages:C.messages,generation:C.generation,revision:C.revision,nextCursor:C.olderCursor,complete:C.olderComplete}:void 0,status:S.status,fetchStatus:S.fetchStatus,isError:S.isError,isPending:S.isPending,isFetching:S.isFetching,isSuccess:S.isSuccess,error:S.error instanceof Error?S.error:S.error?Error(String(S.error)):null,refetch:()=>S.refetch(),fetchPreviousPage:T,hasPreviousPage:!!(C&&!C.olderComplete&&C.olderCursor),isFetchingPreviousPage:s,previousPageError:u,hasMessageGap:!!C?.hasMessageGap,isFillingMessageGap:p,retryMessageGap:()=>E(`explicit`)}},Je=async(e,r)=>{let a=t(),o=n();await p(),K(a,o);let s=await Y(e,{messageID:r,limit:1});if(K(a,o),!s.messages.some(e=>e.messageID===r&&e.role===`user`))return null;i.invalidateQueries({queryKey:U.contact(e,a,o),exact:!0}),i.invalidateQueries({queryKey:U.snapshot(a),exact:!0});let c=i.getQueryData(U.snapshot(a));return{admitted:!0,messageID:r,revision:s.revision??c?.revision??null}},Ye=(e,r=t(),i=n())=>({queryKey:U.scheduledTasks(e,r,i),queryFn:async({signal:t})=>{K(r,i);let n=ie(await W(`/api/openchamber/assistants/${encodeURIComponent(e)}/scheduled-tasks`,{signal:t}));return K(r,i),n},refetchOnMount:`always`,retry:(e,t)=>!(t instanceof _&&t.status===404)&&e<2}),Xe=(e,r)=>{let i=(0,g.c)(6),a=r===void 0||r,o,s;if(i[0]!==e){let r=t(),a=n();s=c,o=Ye(e,r,a),i[0]=e,i[1]=o,i[2]=s}else o=i[1],s=i[2];let l=a&&!!e,u;return i[3]!==o||i[4]!==l?(u={...o,enabled:l},i[3]=o,i[4]=l,i[5]=u):u=i[5],s(u)},Ze=(e=t())=>({queryKey:U.globalScheduledTasks(e),queryFn:de,refetchOnMount:`always`}),Qe=e=>{let t=(0,g.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Ze(),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i={...r,enabled:n},t[1]=n,t[2]=i),c(i)},$e=e=>e.tasks.some(({task:e})=>e.state.lastStatus===`running`),et=()=>{let e=(0,g.c)(5),n,r,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=t(),n=c,r={...Ze(a),select:$e,staleTime:0,refetchInterval:xt,refetchIntervalInBackground:!1},e[0]=n,e[1]=r,e[2]=a):(n=e[0],r=e[1],a=e[2]);let o=n(r),s,l;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>f(e=>{t()===a&&(e.type===`scheduled-task-ran`||e.type===`event-stream-ready`)&&i.invalidateQueries({queryKey:Ze(a).queryKey,exact:!0})}),l=[a],e[3]=s,e[4]=l):(s=e[3],l=e[4]),h.useEffect(s,l),o.data===!0},tt=(e,r=t())=>{i.invalidateQueries({queryKey:[r,n(),`assistants`,`contact`,e]})},nt=(e=t())=>({queryKey:U.capability(e),queryFn:()=>vt(),retry:!1}),rt=()=>{let e=(0,g.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=nt(),e[0]=t):t=e[0],c(t)},it=(e=i,n=t())=>e.getQueryData(U.snapshot(n)),at=(e=i,n=t())=>e.fetchQuery(q(n)),ot=async(e=i)=>{let r=t(),a=n();await e.invalidateQueries({queryKey:U.snapshot(r),exact:!0}),K(r,a);let o=await e.fetchQuery(q(r));return K(r,a),o},st=async(e,r)=>{let a=t(),o=n();await W(`/api/openchamber/assistants/${encodeURIComponent(e)}/session/abort`,G(`POST`,{sessionID:r.sessionID,sessionGeneration:r.sessionGeneration})),K(a,o),i.invalidateQueries({queryKey:U.snapshot(a),exact:!0})},ct=15e3,lt=e=>{throw e instanceof _?e:v(e)?new _(`admission_timeout`,408):e},ut=async(e,r,i)=>{let a=t(),o=n(),s=typeof i==`string`?[{type:`text`,text:i}]:Array.isArray(i.parts)&&i.parts.length>0?i.parts:[{type:`text`,text:i.text??``}],c=AbortSignal.timeout(ct);try{let t=ee(await W(`/api/openchamber/assistants/${encodeURIComponent(e)}/messages`,{...G(`POST`,{messageID:r,parts:s,language:d.getState().locale}),signal:c}));return K(a,o),je(e,t.binding,a),tt(e,a),t}catch(e){return lt(e)}},dt=async(e,r,i,a,o)=>{let s=t(),c=n(),l=te(await W(`/api/openchamber/assistants/${encodeURIComponent(e)}/share`,G(`POST`,{operationID:r,payload:{messageID:i,parts:a,source:o}})));return K(s,c),l},ft=async(e,r=t(),i=n())=>{K(r,i);let a=te(await W(`/api/openchamber/assistants/share-operations/${encodeURIComponent(e)}`));return K(r,i),a},pt=async(e,r=t(),i=n())=>{let a=e;for(let e=0;e<60&&(a.state===`running`||a.state===`submitting`);e+=1)K(r,i),await new Promise(e=>setTimeout(e,750)),a=await ft(a.operationID,r,i);if(K(r,i),a.state===`completed`)return a;throw a.state===`failed`?new y(a.errorCode??`share_failed`,400,a):new y(`share_unresolved`,408,a)},mt=async(e,n)=>{await W(`/api/openchamber/assistants/settings`,G(`PUT`,{enabled:e,expectedRevision:n}));let r=t();await Promise.all([i.invalidateQueries({queryKey:U.snapshot(r),exact:!0}),i.invalidateQueries({queryKey:U.capability(r),exact:!0})])},ht=async e=>{let n=t(),r=F(await W(`/api/openchamber/assistants`,G(`POST`,e)));return Me(r,n),r},gt=async(e,r)=>{let i=t(),a=n(),o=F(await W(`/api/openchamber/assistants/${encodeURIComponent(e.id)}`,G(`PATCH`,{...r,expectedRevision:e.revision})));return K(i,a),Me(o,i),o},_t=async e=>{await W(`/api/openchamber/assistants/${encodeURIComponent(e.id)}`,G(`DELETE`,{expectedRevision:e.revision})),await i.invalidateQueries({queryKey:U.snapshot(t())})},vt=async()=>O(await W(`/api/openchamber/assistants/capability`)),yt=async(e,r)=>{let a=t(),o=n(),s=M(r);try{let t=P(await W(`/api/openchamber/assistants/${encodeURIComponent(e)}/contact/read`,{...G(`POST`,s),signal:AbortSignal.timeout(15e3)}));if(K(a,o),t.assistantID!==e)throw new _(`invalid_assistant_read_response`,200);return t}finally{t()===a&&n()===o&&i.invalidateQueries({queryKey:U.snapshot(a),exact:!0})}},bt=async e=>{let r=e.assistants.filter(e=>(e.unreadCount??0)>0&&e.readTip).map(e=>({id:e.id,position:{...e.readTip}})),i=t(),a=n(),o=[];for(let e=0;e<r.length;e+=4)o.push(...await Promise.allSettled(r.slice(e,e+4).map(async e=>(K(i,a),yt(e.id,e.position)))));return{failed:o.filter(e=>e.status===`rejected`).length}};function xt(e){return e.state.data&&$e(e.state.data)?2500:15e3}var $=o();function St(e){let t=(0,g.c)(32),{title:n,subtitle:r,backAriaLabel:i,onBack:a,backDisabled:o,actions:s,trailing:c,sticky:d,overlay:f,elevated:p}=e,h=o!==void 0&&o,_;t[0]===s?_=t[1]:(_=s===void 0?[]:s,t[0]=s,t[1]=_);let v=_,y=d!==void 0&&d,b=f!==void 0&&f,x=p!==void 0&&p,S=Array.isArray(c)?c.filter(Boolean).length:+!!c,C=x||v.some(wt),w=y&&`oc-mobile-detail-navigation-sticky`,T=b&&`absolute inset-x-0 top-0`,E=C?`z-[60]`:b?`z-30`:void 0,D;t[2]!==w||t[3]!==T||t[4]!==E?(D=l(`oc-mobile-detail-navigation relative shrink-0 pt-[max(0.25rem,var(--oc-safe-area-top,0px))]`,w,T,E),t[2]=w,t[3]=T,t[4]=E,t[5]=D):D=t[5];let O=v.length+S>1?`grid-cols-[2.75rem_minmax(0,1fr)_auto]`:`grid-cols-[2.75rem_minmax(0,1fr)_2.75rem]`,k;t[6]===O?k=t[7]:(k=l(`oc-mobile-detail-navigation-content grid items-center gap-1 px-4`,O),t[6]=O,t[7]=k);let A;t[8]!==i||t[9]!==h||t[10]!==a?(A=a?(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`justify-self-start`,onClick:a,disabled:h,"aria-label":i,children:(0,$.jsx)(m,{name:`arrow-left-s`,className:`size-5`})}):(0,$.jsx)(`span`,{"aria-hidden":`true`}),t[8]=i,t[9]=h,t[10]=a,t[11]=A):A=t[11];let j;t[12]===n?j=t[13]:(j=(0,$.jsx)(`div`,{className:`oc-mobile-detail-title w-full truncate typography-ui-label font-medium text-foreground`,children:n}),t[12]=n,t[13]=j);let M;t[14]===r?M=t[15]:(M=r?(0,$.jsx)(`div`,{className:`oc-mobile-detail-subtitle w-full truncate text-muted-foreground`,"aria-live":`polite`,children:r}):null,t[14]=r,t[15]=M);let N;t[16]!==j||t[17]!==M?(N=(0,$.jsxs)(`div`,{className:`flex w-full max-w-72 min-w-0 flex-col items-center justify-center justify-self-center px-1`,children:[j,M]}),t[16]=j,t[17]=M,t[18]=N):N=t[18];let P;t[19]===v?P=t[20]:(P=v.map(Ct),t[19]=v,t[20]=P);let F;t[21]!==P||t[22]!==c?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2`,children:[c,P]}),t[21]=P,t[22]=c,t[23]=F):F=t[23];let I;t[24]!==k||t[25]!==A||t[26]!==N||t[27]!==F?(I=(0,$.jsxs)(`div`,{className:k,children:[A,N,F]}),t[24]=k,t[25]=A,t[26]=N,t[27]=F,t[28]=I):I=t[28];let L;return t[29]!==D||t[30]!==I?(L=(0,$.jsx)(`header`,{className:D,children:I}),t[29]=D,t[30]=I,t[31]=L):L=t[31],L}function Ct(e,t){return(0,$.jsx)(u,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:l(e.elevated&&`relative z-[60]`),onClick:e.onClick,disabled:e.disabled,"aria-label":e.ariaLabel,"aria-expanded":e.pressed,title:e.title,children:(0,$.jsx)(m,{name:e.icon,className:`size-5`})},`${e.icon}:${t}`)}function wt(e){return e.elevated}export{ue as A,Qe as C,he as D,ge as E,v as F,fe as M,_ as N,pe as O,y as P,He as S,pt as T,rt as _,ht as a,Re as b,vt as c,yt as d,it as f,gt as g,mt as h,Je as i,me as j,de as k,ot as l,dt as m,st as n,_t as o,ut as p,Ke as r,at as s,St as t,bt as u,qe as v,et as w,Be as x,Xe as y};
|