@yuriai/web 0.2.32-beta.2 → 0.2.32-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/assets/{AssistantContactStatus-DKbVOZjo.js → AssistantContactStatus-TjmyQVnm.js} +3 -3
  2. package/dist/assets/{AssistantUnreadBadge-ftPNMymo.js → AssistantUnreadBadge-ByetyaWn.js} +1 -1
  3. package/dist/assets/{AssistantView-CblJ2zy9.js → AssistantView-CHt3RWEC.js} +1 -1
  4. package/dist/assets/{DiagramView-DXqhOl9l.js → DiagramView-DReVW5q9.js} +1 -1
  5. package/dist/assets/{GuiPluginSurface-m-Noj3aa.js → GuiPluginSurface-CIeyIzIp.js} +1 -1
  6. package/dist/assets/{MarkdownRenderer-DoXuuJkV.js → MarkdownRenderer-D-0KHpNl.js} +2 -2
  7. package/dist/assets/{MarkdownRendererImpl-BYuuFNfa.js → MarkdownRendererImpl-BEUnj4i_.js} +1 -1
  8. package/dist/assets/{MarkstreamRendererImpl-IKDf9jte.js → MarkstreamRendererImpl-BufiC_bA.js} +1 -1
  9. package/dist/assets/{MobileDetailNavigation-sEqCaRnY.js → MobileDetailNavigation-32DAi6Mg.js} +1 -1
  10. package/dist/assets/{MobileShareBridge-G3-CumcS.js → MobileShareBridge-DukFTkwu.js} +1 -1
  11. package/dist/assets/{MobileTabPageHeader-C8RbWBKV.js → MobileTabPageHeader-DEXatYlp.js} +1 -1
  12. package/dist/assets/{MultiRunWindow-CDpvE-zO.js → MultiRunWindow-B2e-JjFb.js} +1 -1
  13. package/dist/assets/{SettingsView-Das1IHAu.js → SettingsView-DXhstV_y.js} +15 -15
  14. package/dist/assets/{SettingsWindow-C7rgO3qt.js → SettingsWindow-D1BRJCx_.js} +1 -1
  15. package/dist/assets/{SetupTourDialog-BkbTIz8M.js → SetupTourDialog-CxgLkqcj.js} +1 -1
  16. package/dist/assets/{TerminalView-DsIVQDlk.js → TerminalView-B_jqEx8P.js} +1 -1
  17. package/dist/assets/{ToolOutputDialog-BH3bOjDw.js → ToolOutputDialog-BgwsFo9W.js} +1 -1
  18. package/dist/assets/{VoiceSettings-BlU2CJhd.js → VoiceSettings-DXHfWAgl.js} +1 -1
  19. package/dist/assets/{appThemeRegistry-DMSk1I5B.js → appThemeRegistry-ChXTWoVW.js} +1 -1
  20. package/dist/assets/{capgoAdapter-D8I8oJcn.js → capgoAdapter-BAvjN_Nh.js} +1 -1
  21. package/dist/assets/{gitApi-D92RH8FG.js → gitApi-DtXTuozL.js} +1 -1
  22. package/dist/assets/{insertionBoundaries-tD7rJ-pN.js → insertionBoundaries-DeBppC-3.js} +1 -1
  23. package/dist/assets/{main-2gplybqp.js → main-BEYE305b.js} +2 -2
  24. package/dist/assets/{main-BalwAS4v.js → main-CYlSqUaZ.js} +8 -8
  25. package/dist/assets/{mcpQueries-Bvd8i21K.js → mcpQueries-0BYnsVR6.js} +1 -1
  26. package/dist/assets/{miniChat-CDgmbnvp.js → miniChat-CvclLJoR.js} +2 -2
  27. package/dist/assets/{mobile-B7XDs1Ej.js → mobile-BU75qxb4.js} +2 -2
  28. package/dist/assets/{mobileBackNavigation-AlDzsLZE.js → mobileBackNavigation-C1Ow2avo.js} +1 -1
  29. package/dist/assets/{multirun-Dvx2CH5O.js → multirun-4Pn9maGs.js} +1 -1
  30. package/dist/assets/{native-config-BfwOD9gu.js → native-config-DQIb-3qU.js} +1 -1
  31. package/dist/assets/{projectMeta-CDOI8wVV.js → projectMeta-CSiZ4I85.js} +1 -1
  32. package/dist/assets/pwa-Cm-jO8eR.js +2 -0
  33. package/dist/assets/{queue-abort-optimistic-C-AN4RTx.js → queue-abort-optimistic-CxF6bGXx.js} +1 -1
  34. package/dist/assets/{readiness-CrZ59Om9.js → readiness-CDywb9dh.js} +1 -1
  35. package/dist/assets/{renderElectronMiniChatApp-D9PyhLc-.js → renderElectronMiniChatApp-CiVeccip.js} +2 -2
  36. package/dist/assets/{renderMobileApp-JQguy_5y.js → renderMobileApp-B9-hpVnc.js} +4 -4
  37. package/dist/assets/{runtimeConfig-DfLCc7A9.js → runtimeConfig-Rthccc9z.js} +1 -1
  38. package/dist/assets/{runtimeEndpointReset-B--BY0YO.js → runtimeEndpointReset-CretKGD9.js} +3 -3
  39. package/dist/assets/{sessionLookup-cyEN12a0.js → sessionLookup-BxPSStyI.js} +1 -1
  40. package/dist/assets/{speechSettingsQueries-DHdSg2sh.js → speechSettingsQueries-alV0B1bP.js} +1 -1
  41. package/dist/assets/{src-BqubNQyD.css → src-CFd7QD5V.css} +1 -1
  42. package/dist/assets/{types-DXHiIS-0.js → types-_2Igbjc0.js} +1 -1
  43. package/dist/assets/{useAppFontEffects-DdgYioGO.js → useAppFontEffects-B1n0YPn0.js} +7 -7
  44. package/dist/assets/{useDesktopWindowControlsLayout-CZryTaVG.js → useDesktopWindowControlsLayout-CpYYPIUB.js} +1 -1
  45. package/dist/assets/{useEffectiveDirectory-DkFV660l.js → useEffectiveDirectory-CvDy8Tyu.js} +1 -1
  46. package/dist/assets/{useMobileNavigationStore-BUlbm442.js → useMobileNavigationStore-BHAEAnfr.js} +4 -4
  47. package/dist/assets/{usePluginsStore-cBba-pcU.js → usePluginsStore-DvvZ8a3q.js} +1 -1
  48. package/dist/assets/{useWorkerHighlightedLines-CdxTrkgu.js → useWorkerHighlightedLines-DUpdltuG.js} +1 -1
  49. package/dist/index.html +6 -6
  50. package/dist/mini-chat.html +6 -6
  51. package/dist/mobile.html +6 -6
  52. package/package.json +1 -1
  53. package/dist/assets/pwa-SCu_PpmX.js +0 -2
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{T as t}from"./desktop-BAmoc_34.js";import{at as n,ot as r,st as i}from"./vendor-base-ui-CzHs0bHY.js";import{At as a}from"./gitApiHttp-MWsHNHuo.js";import{at as o,dt as s,ot as c,pt as l,ut as u}from"./bootstrap-C8paoQ0j.js";import{n as d}from"./vendor-react-DlzBev0S.js";import{a as f,n as p}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as m,t as h}from"./platform-sEg2IOLZ.js";import{i as g,m as _}from"./vendor-reactuses-core-DWo5Wn6R.js";import{f as v,r as y,t as b}from"./button-CyJvQsp5.js";import{Ci as x,Oi as S,Qr as C,Yr as w,ii as ee,ni as T}from"./useMobileNavigationStore-BUlbm442.js";import{n as E}from"./Icon-BOYrvHyJ.js";import{r as D}from"./themes-BgDJcxRc.js";import{t as O}from"./MobileResizableSheet-vAenroLZ.js";import{n as te,t as k}from"./useDictation-C-waWdAq.js";import{t as A}from"./LoadingImage-D9r0ukc0.js";import{t as j}from"./textarea-CWQIq-Mn.js";var M=e(i(),1),N=d(),P=r(),ne=e(n(),1),re=f(`YuriMedia`);function F(e){return e.platform===`android`||/Android/i.test(e.userAgent)||e.userAgentDataPlatform===`Android`}function ie(){if(typeof window>`u`)return!1;let e=navigator.userAgentData;return F({platform:h(),userAgent:navigator.userAgent||``,userAgentDataPlatform:e?.platform})}function I(){return m()&&p.getPlatform()===`android`&&p.isPluginAvailable(`YuriMedia`)}async function ae(e){if(!I())return null;let t=await re.pickMedia({limit:e});if(t.cancelled)return[];let n=[];for(let e of t.files){let t=await fetch(p.convertFileSrc(e.path));if(!t.ok)throw Error(`Native media fetch failed (${t.status})`);let r=await t.blob();n.push(new File([r],e.name,{type:e.mimeType}))}return n}var L=`h-auto min-h-12 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 border-b border-[var(--surface-subtle)] last:border-b-0`,oe=e=>{let t=(0,N.c)(38),{id:n,open:r,onOpenChange:i,onPickPhotos:a,onPickFiles:o}=e,{t:s}=v(),c;t[0]===s?c=t[1]:(c=s(`chat.chatInput.actions.addAttachment`),t[0]=s,t[1]=c);let l;t[2]===c?l=t[3]:(l=(0,P.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:c}),t[2]=c,t[3]=l);let u;t[4]===s?u=t[5]:(u=s(`chat.chatInput.actions.addAttachment`),t[4]=s,t[5]=u);let d;t[6]===s?d=t[7]:(d=s(`mobile.surface.closeAria`),t[6]=s,t[7]=d);let f;t[8]===s?f=t[9]:(f=s(`mobile.sessions.sheet.resizeAria`),t[8]=s,t[9]=f);let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,P.jsx)(E,{name:`file-image`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[10]=p):p=t[10];let m;t[11]===s?m=t[12]:(m=s(`chat.chatInput.actions.attachPhotos`),t[11]=s,t[12]=m);let h;t[13]===m?h=t[14]:(h=(0,P.jsx)(`span`,{className:`truncate`,children:m}),t[13]=m,t[14]=h);let g;t[15]!==a||t[16]!==h?(g=(0,P.jsxs)(b,{type:`button`,variant:`ghost`,size:`lg`,className:L,"data-mobile-press-feedback":`none`,onClick:a,children:[p,h]}),t[15]=a,t[16]=h,t[17]=g):g=t[17];let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,P.jsx)(E,{name:`attachment-2`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[18]=_):_=t[18];let y;t[19]===s?y=t[20]:(y=s(`chat.chatInput.actions.attachFiles`),t[19]=s,t[20]=y);let x;t[21]===y?x=t[22]:(x=(0,P.jsx)(`span`,{className:`truncate`,children:y}),t[21]=y,t[22]=x);let S;t[23]!==o||t[24]!==x?(S=(0,P.jsxs)(b,{type:`button`,variant:`ghost`,size:`lg`,className:L,"data-mobile-press-feedback":`none`,onClick:o,children:[_,x]}),t[23]=o,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==S||t[27]!==g?(C=(0,P.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,P.jsxs)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-page-scroll-lock":`true`,children:[g,S]})}),t[26]=S,t[27]=g,t[28]=C):C=t[28];let w;return t[29]!==n||t[30]!==i||t[31]!==r||t[32]!==C||t[33]!==l||t[34]!==u||t[35]!==d||t[36]!==f?(w=(0,P.jsx)(O,{id:n,open:r,onOpenChange:i,title:l,ariaLabel:u,closeAriaLabel:d,resizeAriaLabel:f,fitContent:!0,children:C}),t[29]=n,t[30]=i,t[31]=r,t[32]=C,t[33]=l,t[34]=u,t[35]=d,t[36]=f,t[37]=w):w=t[37],w},R={glyph:`_glyph_1xs2e_1`,lens:`_lens_1xs2e_12`,shape:`_shape_1xs2e_21`,revolve:`_revolve_1xs2e_1`};function se(e){let t=(0,N.c)(18),{decorative:n,size:r}=e,i=n!==void 0&&n,a=r===void 0?20:r,{t:o}=v(),s;t[0]===a?s=t[1]:(s={width:a,height:a},t[0]=a,t[1]=s);let c=i||void 0,l=i?void 0:`img`,u;t[2]!==i||t[3]!==o?(u=i?void 0:o(`common.loading`),t[2]=i,t[3]=o,t[4]=u):u=t[4];let d=`scale(${a/28})`,f;t[5]===d?f=t[6]:(f={transform:d},t[5]=d,t[6]=f);let p,m,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,P.jsx)(`span`,{className:R.shape}),p=(0,P.jsx)(`span`,{className:R.shape}),m=(0,P.jsx)(`span`,{className:R.shape}),t[7]=p,t[8]=m,t[9]=h):(p=t[7],m=t[8],h=t[9]);let g;t[10]===f?g=t[11]:(g=(0,P.jsxs)(`span`,{className:R.lens,style:f,children:[h,p,m]}),t[10]=f,t[11]=g);let _;return t[12]!==g||t[13]!==s||t[14]!==c||t[15]!==l||t[16]!==u?(_=(0,P.jsx)(`span`,{"data-dictation-loading":!0,className:R.glyph,style:s,"aria-hidden":c,role:l,"aria-label":u,children:g}),t[12]=g,t[13]=s,t[14]=c,t[15]=l,t[16]=u,t[17]=_):_=t[17],_}var z=D(!1).colors,ce=`M-50 74.564 A600 600 0 0 1 147.707 22.283 A38 38 0 0 1 154.330 97.994 A524 524 0 0 0 -18.333 143.653 Z`,le=`M450 74.564 A600 600 0 0 0 252.293 22.283 A38 38 0 0 0 245.670 97.994 A524 524 0 0 1 418.333 143.653 Z`,ue={colorScheme:`light`,"--surface-background":z.surface.background,"--surface-foreground":z.surface.foreground,"--primary-base":z.primary.base,"--foreground":z.surface.background,"--interactive-hover":`color-mix(in srgb, var(--surface-background) 12%, transparent)`,"--interactive-active":`color-mix(in srgb, var(--surface-background) 20%, transparent)`,"--ring":z.interactive.focusRing,"--status-error":z.status.error};function de(e){let t=(0,N.c)(85),{containerRef:n,disabled:r,onInsert:i,onSend:a,onRelease:o,onError:s,onHintChange:c}=e,{t:l}=v(),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(!1),[m,h]=(0,M.useState)(`send`),_=(0,M.useRef)(null),y=(0,M.useRef)(null),b=(0,M.useRef)(`insert`),x=(0,M.useRef)(null),S=(0,M.useId)(),C=(0,M.useId)(),w=(0,M.useId)(),T;t[0]!==i||t[1]!==a?(T=e=>b.current===`send`?a(e):i(e),t[0]=i,t[1]=a,t[2]=T):T=t[2];let E;t[3]!==s||t[4]!==T?(E={onTranscript:T,onError:s},t[3]=s,t[4]=T,t[5]=E):E=t[5];let D=k(E),{status:O,isStarting:te,partialTranscript:A,error:j,volume:re}=D,F=g(c),ie=u?m===`cancel`?`cancelling`:m===`edit`?`editing`:`recording`:f?`processing`:null,I,ae;t[6]!==ie||t[7]!==F?(I=()=>{F(ie)},ae=[ie,F],t[6]=ie,t[7]=F,t[8]=I,t[9]=ae):(I=t[8],ae=t[9]),(0,M.useEffect)(I,ae);let L,oe;t[10]===F?(L=t[11],oe=t[12]):(L=()=>()=>F(null),oe=[F],t[10]=F,t[11]=L,t[12]=oe),(0,M.useEffect)(L,oe);let R;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{y.current&&clearTimeout(y.current),y.current=null},t[13]=R):R=t[13];let z=g(R),de;t[14]!==n||t[15]!==r?(de=e=>{if(r||!(e instanceof HTMLElement))return null;let t=n.current?.querySelector(`textarea`);return!t||t.value!==``||t.disabled||t.readOnly||t.ownerDocument.activeElement===t||e!==t&&!e.closest(`[data-yuri-composer-compact-surface]`)||e.closest(`button, [data-composer-action]`)?null:t},t[14]=n,t[15]=r,t[16]=de):de=t[16];let V=g(de),fe;t[17]!==z||t[18]!==D||t[19]!==j||t[20]!==f||t[21]!==O?(fe=()=>{f||(z(),_.current=null,d(!1),h(`send`),O===`failed`||O===`idle`&&j?D.discardFailedDictation():D.cancelDictation())},t[17]=z,t[18]=D,t[19]=j,t[20]=f,t[21]=O,t[22]=fe):fe=t[22];let H=g(fe),pe;t[23]!==D||t[24]!==r||t[25]!==V||t[26]!==f||t[27]!==O?(pe=e=>{let t=e.target;r||f||O!==`idle`||_.current||!e.isPrimary||e.button!==0||!(t instanceof HTMLElement)||V(t)&&(e.preventDefault(),e.stopPropagation(),_.current={pointer:e.pointerId,x:e.clientX,y:e.clientY,intent:`send`,started:!1},y.current=setTimeout(()=>{if(y.current=null,!_.current)return;let e=V(t);if(!e){_.current=null;return}e.blur(),_.current.started=!0,b.current=`insert`,d(!0),h(`send`),D.startDictation()},300))},t[23]=D,t[24]=r,t[25]=V,t[26]=f,t[27]=O,t[28]=pe):pe=t[28];let U=g(pe),me;t[29]===z?me=t[30]:(me=e=>{let t=_.current;if(!t||t.pointer!==e.pointerId)return;e.preventDefault(),e.stopPropagation();let n=e.clientX-t.x,r=x.current?.getBoundingClientRect(),i=r&&r.width>0&&e.clientY>=r.top&&e.clientY<=r.bottom?e.clientX<r.left+r.width/2?`cancel`:`edit`:n<=-64?`cancel`:n>=64?`edit`:`send`;if(!t.started&&Math.hypot(n,t.y-e.clientY)>12){z(),_.current=null;return}t.started&&i!==t.intent&&(t.intent=i,h(i),ee(i===`send`?`light`:`medium`,{bypassCadence:!0}))},t[29]=z,t[30]=me);let W=g(me),he;t[31]!==H||t[32]!==z||t[33]!==n||t[34]!==D||t[35]!==j||t[36]!==o||t[37]!==A||t[38]!==O?(he=e=>{let t=_.current;if(!(!t||t.pointer!==e.pointerId)){if(e.preventDefault(),e.stopPropagation(),z(),j||O===`failed`){H();return}_.current=null,d(!1),t.started?t.intent===`cancel`?D.cancelDictation():(b.current=t.intent===`edit`?`insert`:`send`,o(A),p(!0),Promise.resolve(D.confirmDictation()).finally(()=>{p(!1),D.discardFailedDictation(),t.intent===`edit`&&n.current?.querySelector(`textarea`)?.focus()})):n.current?.querySelector(`textarea`)?.focus()}},t[31]=H,t[32]=z,t[33]=n,t[34]=D,t[35]=j,t[36]=o,t[37]=A,t[38]=O,t[39]=he):he=t[39];let G=g(he),ge;t[40]===H?ge=t[41]:(ge=e=>{_.current?.pointer===e.pointerId&&H()},t[40]=H,t[41]=ge);let _e=g(ge),ve;t[42]===V?ve=t[43]:(ve=e=>{V(e.target)&&e.preventDefault()},t[42]=V,t[43]=ve);let K=g(ve),q,J;t[44]!==H||t[45]!==z||t[46]!==n||t[47]!==U||t[48]!==_e||t[49]!==W||t[50]!==K||t[51]!==G?(q=()=>{let e=n.current;if(!e)return;let t=()=>{document.visibilityState===`hidden`&&H()};return e.addEventListener(`pointerdown`,U,!0),e.addEventListener(`touchstart`,K,{capture:!0,passive:!1}),window.addEventListener(`pointermove`,W,{capture:!0,passive:!1}),window.addEventListener(`pointerup`,G,!0),window.addEventListener(`pointercancel`,_e,!0),e.addEventListener(`contextmenu`,K,!0),e.addEventListener(`selectstart`,K,!0),window.addEventListener(`blur`,H),document.addEventListener(`visibilitychange`,t),()=>{z(),e.removeEventListener(`pointerdown`,U,!0),e.removeEventListener(`touchstart`,K,!0),window.removeEventListener(`pointermove`,W,!0),window.removeEventListener(`pointerup`,G,!0),window.removeEventListener(`pointercancel`,_e,!0),e.removeEventListener(`contextmenu`,K,!0),e.removeEventListener(`selectstart`,K,!0),window.removeEventListener(`blur`,H),document.removeEventListener(`visibilitychange`,t)}},J=[n,U,W,G,_e,H,z,K],t[44]=H,t[45]=z,t[46]=n,t[47]=U,t[48]=_e,t[49]=W,t[50]=K,t[51]=G,t[52]=q,t[53]=J):(q=t[52],J=t[53]),(0,M.useEffect)(q,J);let ye,Y;if(t[54]!==H||t[55]!==r?(ye=()=>{r&&H()},Y=[r,H],t[54]=H,t[55]=r,t[56]=ye,t[57]=Y):(ye=t[56],Y=t[57]),(0,M.useEffect)(ye,Y),!u&&!f)return null;let be=Math.min(1,Math.max(0,re))**.6,X=!!j,xe=j?H:void 0,Se;t[58]===be?Se=t[59]:(Se={...ue,"--speech-energy":be},t[58]=be,t[59]=Se);let Ce=Se,we;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,P.jsx)(`div`,{className:`yuri-speech-light-field`,"aria-hidden":`true`,children:[`ice`,`lilac`,`mint`,`blush`,`mid`,`core`].map(B)}),t[60]=we):we=t[60];let Te=te||f,Z;t[61]!==j||t[62]!==te||t[63]!==A||t[64]!==f||t[65]!==O||t[66]!==l?(Z=j&&!f?(0,P.jsx)(`p`,{role:`alert`,className:`yuri-speech-caption yuri-speech-error`,children:j}):(0,P.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`yuri-speech-caption`,children:te||f?(0,P.jsx)(se,{size:72}):A?(0,P.jsx)(`span`,{className:`yuri-speech-interim`,children:A}):l(O===`uploading`?`chat.dictation.processing`:`chat.dictation.listening`)}),t[61]=j,t[62]=te,t[63]=A,t[64]=f,t[65]=O,t[66]=l,t[67]=Z):Z=t[67];let Q;t[68]!==Te||t[69]!==Z?(Q=(0,P.jsx)(`div`,{className:`yuri-speech-content`,"data-starting":Te,children:Z}),t[68]=Te,t[69]=Z,t[70]=Q):Q=t[70];let $;t[71]!==S||t[72]!==C||t[73]!==w||t[74]!==u||t[75]!==m||t[76]!==l?($=u&&(0,P.jsx)(`div`,{className:`yuri-speech-gesture-stage`,"aria-hidden":`true`,children:(0,P.jsxs)(`div`,{className:`yuri-speech-gesture-surfaces`,children:[(0,P.jsx)(`div`,{className:`yuri-speech-target-glass`,style:{clipPath:`url(#${C})`}}),(0,P.jsx)(`div`,{className:`yuri-speech-target-glass`,style:{clipPath:`url(#${w})`}}),(0,P.jsxs)(`svg`,{className:`yuri-speech-geometry`,viewBox:`0 0 400 226`,focusable:`false`,children:[(0,P.jsxs)(`defs`,{children:[(0,P.jsx)(`clipPath`,{id:C,clipPathUnits:`objectBoundingBox`,children:(0,P.jsx)(`path`,{transform:`scale(0.0025 0.004424778761)`,d:ce})}),(0,P.jsx)(`clipPath`,{id:w,clipPathUnits:`objectBoundingBox`,children:(0,P.jsx)(`path`,{transform:`scale(0.0025 0.004424778761)`,d:le})}),(0,P.jsxs)(`linearGradient`,{id:S,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,P.jsx)(`stop`,{offset:`0%`,className:`yuri-speech-arc-top`}),(0,P.jsx)(`stop`,{offset:`100%`,className:`yuri-speech-arc-bottom`})]})]}),(0,P.jsxs)(`g`,{className:`yuri-speech-targets`,ref:x,children:[(0,P.jsxs)(`g`,{className:`yuri-speech-target yuri-speech-target--cancel`,"data-active":m===`cancel`,children:[(0,P.jsx)(`path`,{d:ce}),(0,P.jsx)(`text`,{x:`95`,y:`68`,textAnchor:`middle`,dominantBaseline:`central`,transform:`rotate(-11 95 68)`,children:l(`chat.dictation.cancelGesture`)})]}),(0,P.jsxs)(`g`,{className:`yuri-speech-target yuri-speech-target--edit`,"data-active":m===`edit`,children:[(0,P.jsx)(`path`,{d:le}),(0,P.jsx)(`text`,{x:`305`,y:`68`,textAnchor:`middle`,dominantBaseline:`central`,transform:`rotate(11 305 68)`,children:l(`chat.dictation.edit`)})]})]}),(0,P.jsx)(`path`,{className:`yuri-speech-hold-arc`,fill:`url(#${S})`,d:`M-50 186.987 A500 500 0 0 1 450 186.987 L450 300 H-50 Z`})]})]})}),t[71]=S,t[72]=C,t[73]=w,t[74]=u,t[75]=m,t[76]=l,t[77]=$):$=t[77];let Ee;return t[78]!==m||t[79]!==X||t[80]!==xe||t[81]!==Ce||t[82]!==Q||t[83]!==$?(Ee=(0,ne.createPortal)((0,P.jsxs)(`div`,{className:`yuri-speech-overlay`,"data-intent":m,"data-error":X,onClick:xe,style:Ce,children:[we,Q,$]}),document.body),t[78]=m,t[79]=X,t[80]=xe,t[81]=Ce,t[82]=Q,t[83]=$,t[84]=Ee):Ee=t[84],Ee}function B(e){return(0,P.jsx)(`div`,{className:`yuri-speech-reactor yuri-speech-reactor--${e}`,children:(0,P.jsx)(`div`,{className:`yuri-speech-light`})},e)}function V(e){let n=(0,N.c)(7),{available:r}=e,i=S(fe),[a,o]=(0,M.useState)(null),s;n[0]!==r||n[1]!==i?(s=r&&i&&!t()&&te(),n[0]=r,n[1]=i,n[2]=s):s=n[2];let c=s,l=c?a:null,u;return n[3]!==c||n[4]!==i||n[5]!==l?(u={globallyEnabled:i,enabled:c,hint:l,onHintChange:o},n[3]=c,n[4]=i,n[5]=l,n[6]=u):u=n[6],u}function fe(e){return e.dictationEnabled}var H=M.createContext(null),pe=e=>{let t=(0,N.c)(3),{actions:n,children:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,P.jsx)(H.Provider,{value:n,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},U=()=>M.useContext(H),me=e=>e.nativeEvent.isComposing||e.nativeEvent.keyCode===229;function W(e){let t=(0,N.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=y(`inline-flex shrink-0 items-center justify-center rounded-full bg-foreground text-background`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,P.jsx)(`span`,{className:a,...i,"aria-hidden":!0,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function he(e){let t=(0,N.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,P.jsx)(`span`,{"data-stop-glyph":`true`,className:`block size-[38%] rounded-[20%] bg-current`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,P.jsx)(W,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function G(e){let t=(0,N.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,spinning:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i,o=a?`loader-4`:`arrow-up`,s=a?`size-[50%] animate-spin`:`size-[56%]`,c;t[4]===s?c=t[5]:(c=y(s),t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,P.jsx)(E,{name:o,weight:`medium`,className:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==n||t[10]!==r||t[11]!==l?(u=(0,P.jsx)(W,{className:n,...r,children:l}),t[9]=n,t[10]=r,t[11]=l,t[12]=u):u=t[12],u}var ge=M.forwardRef((e,t)=>{let n=(0,N.c)(17),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({children:r,className:i,expanded:s,style:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let c=s!==void 0&&s&&`min-h-0 flex-1`,l;n[6]!==i||n[7]!==c?(l=y(`relative flex flex-col overflow-visible border border-[color-mix(in_srgb,var(--interactive-border)_50%,transparent)] dark:border-transparent`,`bg-[var(--surface-background)] shadow-[0_2px_6px_-3px_color-mix(in_srgb,var(--surface-foreground)_4%,transparent),inset_0_1px_0_var(--yuri-mobile-glass-highlight)] transition-colors duration-150 motion-reduce:transition-none`,`dark:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_8%)] dark:shadow-none dark:hover:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)] dark:focus-within:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)]`,c,i),n[6]=i,n[7]=c,n[8]=l):l=n[8];let u;n[9]===o?u=n[10]:(u={borderRadius:`var(--radius-xl)`,...o},n[9]=o,n[10]=u);let d;return n[11]!==r||n[12]!==a||n[13]!==t||n[14]!==l||n[15]!==u?(d=(0,P.jsx)(`div`,{ref:t,className:l,style:u,...a,children:r}),n[11]=r,n[12]=a,n[13]=t,n[14]=l,n[15]=u,n[16]=d):d=n[16],d});ge.displayName=`ChatComposerSurface`;var _e=M.forwardRef((e,t)=>{let n=(0,N.c)(3),r;return n[0]!==e||n[1]!==t?(r=(0,P.jsx)(j,{ref:t,...e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});_e.displayName=`ChatPromptTextarea`;var ve=e=>{let t=(0,N.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=y(`flex shrink-0 items-center gap-2 bg-transparent px-2.5 py-1.5`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,P.jsx)(`div`,{className:a,"data-chat-input-footer":`true`,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o},K=(e,t)=>{typeof e==`function`?e(t):e&&(e.current=t)},q=({value:e,attachments:t=[],disabled:n=!1,pending:r=!1,placeholder:i,isMobile:a=!1,onChange:o,onSubmit:s,onStop:c,onAddFiles:l,onRemoveAttachment:u,addFilesLabel:d,removeAttachmentLabel:f,fileAccept:p=`image/*`,sendLabel:m,stopLabel:h,hint:b,leftControls:x,rightControls:S,footerContent:C,inputHeader:w,attachmentContent:ee,highlightedContent:D,highlightRef:O,inputRef:te,textareaProps:k,textLayoutClassName:j,inputClassName:N,inputOuterClassName:ne,inputStyle:re,footerClassName:F,footerStyle:L,contentClassName:R,inputSectionClassName:se,autoResize:z=!0,disableInputWhilePending:ce=!0,layout:le=`stacked`,children:ue,className:de,expanded:B=!1,...V})=>{let{t:fe}=v(),H=le===`inline`,[pe,U]=M.useState(!1),[W,q]=M.useState(!1),J=ie(),ye=t.length>0||pe,Y=M.useRef(null),be=M.useRef(null),X=M.useRef(null),xe=M.useId().replace(/:/g,``),Se=g(()=>{if(!z||B||k?.fillContainer){H&&U(!1);return}let e=Y.current;if(!e)return;e.style.height=H?`0px`:`auto`;let t=Number.parseFloat(window.getComputedStyle(e).maxHeight),n=H?Math.max(e.scrollHeight,48):e.scrollHeight,r=Number.isFinite(t)?Math.min(n,t):n;e.style.height=`${r}px`,e.style.overflowY=Number.isFinite(t)&&n>t?`auto`:`hidden`;let i=r>48;H&&U(e=>e===i?e:i)});M.useLayoutEffect(()=>{Se()},[z,B,H,k?.fillContainer,e]),_(H&&z&&!B&&!k?.fillContainer?Y:null,Se);let Ce=e=>{k?.onKeyDown?.(e),!(e.defaultPrevented||me(e))&&e.key===`Enter`&&!e.shiftKey&&!a&&(e.preventDefault(),!n&&(!r||!ce)&&s())},we=e=>{l?.(e.target.files),e.target.value=``},Te=g(()=>{Y.current?.blur(),q(!0)}),Z=g(e=>{q(!1),requestAnimationFrame(()=>e?.click())}),Q=g(()=>{q(!1),requestAnimationFrame(()=>{(async()=>{if(!I()){X.current?.click();return}try{let e=await ae(20);if(e===null){X.current?.click();return}e.length>0&&l?.(e)}catch(e){console.error(`Native photo pick failed`,e),T.error(fe(`chat.chatInput.toast.attachFileFailed`))}})()})}),$=e.trim().length>0||t.length>0,Ee=t.filter(e=>e.mime.startsWith(`image/`)),De=t.filter(e=>!e.mime.startsWith(`image/`)),Oe=l?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`input`,{ref:be,type:`file`,accept:p,multiple:!0,className:`hidden`,onChange:we}),J?(0,P.jsx)(`input`,{ref:X,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:we}):null,(0,P.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>J?Te():be.current?.click(),onMouseDown:a?e=>e.preventDefault():void 0,onPointerDownCapture:a?e=>e.preventDefault():void 0,disabled:n||r,"aria-label":d,children:(0,P.jsx)(E,{name:`attachment-2`,className:`size-[18px]`})})]}):null,ke=!n&&!r&&$,Ae=a?`size-6`:`size-full`,je=r&&c?(0,P.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":h,children:(0,P.jsx)(he,{className:Ae})}):(0,P.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":ke?`true`:void 0,className:y(`flex size-8 shrink-0 items-center justify-center outline-none`,ke?`rounded-full hover:opacity-80`:`rounded-md text-primary hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-30`),disabled:n||r||!$,"aria-label":m,children:ke?(0,P.jsx)(G,{className:Ae}):(0,P.jsx)(E,{name:r?`loader-4`:`send-plane-2`,className:y(`size-4`,r&&`animate-spin`)})}),Me=r&&c?(0,P.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":h,children:(0,P.jsx)(he,{className:Ae})}):(0,P.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":`true`,className:y(`flex size-8 shrink-0 items-center justify-center rounded-full outline-none`,ke?`hover:opacity-80`:`cursor-not-allowed opacity-30`),disabled:n||r||!$,"aria-busy":r||void 0,"aria-label":m,onClick:()=>Y.current?.focus({preventScroll:!0}),onMouseDown:e=>e.preventDefault(),onPointerDownCapture:a?e=>e.preventDefault():void 0,children:(0,P.jsx)(G,{className:Ae,spinning:r})}),Ne=H?Me:je,Pe=x===void 0?Oe:x;return(0,P.jsxs)(ge,{className:de,expanded:B,...V,children:[ue,(0,P.jsxs)(`div`,{"data-composer-content":`true`,"data-composer-layout":le,className:y(`relative flex min-h-0`,H?y(`min-h-12 flex-row`,ye?`items-end`:`items-center`):`flex-col`,B&&`flex-1`,R),children:[H&&Pe?(0,P.jsx)(`div`,{className:`flex h-12 shrink-0 items-center pl-1.5`,"data-composer-inline-attach":`true`,children:Pe}):null,(0,P.jsxs)(`div`,{className:y(`overflow-hidden`,H&&`min-w-0 flex-1`,B&&`flex min-h-0 flex-1 flex-col`,se),children:[w,ee,Ee.length>0?(0,P.jsx)(`div`,{className:`flex gap-2 overflow-x-auto px-3 pt-3`,"data-chat-prompt-attachments":`true`,children:Ee.map(e=>(0,P.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,P.jsx)(`span`,{className:`block size-16`,children:(0,P.jsx)(A,{fill:!0,src:e.url,alt:e.name,className:`size-16 rounded-lg border border-border object-cover`})}),u?(0,P.jsx)(`button`,{type:`button`,className:`absolute -right-1 -top-1 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] shadow-sm hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,P.jsx)(E,{name:`close`,className:`size-3`})}):null]},e.id))}):null,De.length>0?(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,"data-chat-prompt-file-attachments":`true`,children:De.map(e=>(0,P.jsxs)(`div`,{className:`relative flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border bg-[var(--surface-elevated)] px-2 py-1`,children:[(0,P.jsx)(E,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,P.jsx)(`span`,{className:`min-w-0 truncate typography-micro`,children:e.name}),u?(0,P.jsx)(`button`,{type:`button`,className:`flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,P.jsx)(E,{name:`close`,className:`size-3`})}):null]},e.id))}):null,(0,P.jsxs)(`div`,{className:y(`relative overflow-hidden`,H&&y(`flex min-h-12`,pe?`items-end`:`items-center`),B&&`flex min-h-0 flex-1 flex-col`),"data-composer-input-shell":`true`,children:[D?(0,P.jsx)(`div`,{ref:O,"aria-hidden":!0,"data-composer-highlight":`true`,className:y(`pointer-events-none absolute inset-0 z-0 rounded-b-none`,j,N),children:D}):null,(0,P.jsx)(_e,{...k,simple:!0,fillContainer:!H&&k?.fillContainer,ref:e=>{Y.current=e,K(te,e)},"data-chat-input":`true`,value:e,onChange:e=>o(e.target.value,e),onKeyDown:Ce,disabled:n||r&&ce,placeholder:i,enterKeyHint:a?`enter`:k?.enterKeyHint,outerClassName:y(`ring-0 bg-transparent shadow-none hover:bg-transparent focus-within:ring-0`,H&&`flex-none`,B&&`min-h-0 flex-1`,ne),className:y(`relative z-10 resize-none overflow-y-hidden appearance-none border-0 bg-transparent typography-markdown hover:border-transparent md:typography-ui-label`,H?`field-sizing-fixed min-h-12 max-h-32 px-3 py-3 leading-6`:`min-h-[52px] max-h-40 rounded-b-none px-3 pb-2 pt-4`,j,N,D&&`text-transparent caret-[var(--surface-foreground)]`),style:re,rows:k?.rows??1})]})]}),H?(0,P.jsx)(`div`,{className:y(`flex h-12 shrink-0 items-center pr-1.5`,F),style:L,"data-composer-inline-send":`true`,children:S??Ne}):(0,P.jsx)(ve,{className:F,style:L,children:C??(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`flex items-center gap-1.5`,children:x??Oe}),b?(0,P.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,children:b}):(0,P.jsx)(`div`,{className:`flex-1`}),(0,P.jsx)(`div`,{className:`flex items-center gap-1.5`,children:S??Ne})]})})]}),J&&l?(0,P.jsx)(oe,{id:`mobile-attach-pick-${xe}`,open:W,onOpenChange:e=>{e||q(!1)},onPickPhotos:Q,onPickFiles:()=>Z(be.current)}):null]})},J={dictation:102,mentionFile:100,mentionAgent:100,mentionSession:100,mentionCommand:100,mentionPaste:100,code:90,codeFence:90,link:80,linkUrl:78,heading:70,blockquote:40,listMarker:35,marker:10},ye={dictation:`text-foreground underline decoration-current underline-offset-4`,mentionFile:`text-[var(--primary)]`,mentionAgent:`text-[var(--primary)]`,mentionSession:`text-[var(--primary)]`,mentionCommand:`text-[var(--primary)]`,mentionPaste:`text-[var(--primary)]`,code:`rounded-[3px] bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,codeFence:`bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,link:`text-[var(--status-info)] underline`,linkUrl:`text-muted-foreground`,heading:`text-[var(--syntax-keyword)]`,blockquote:`text-muted-foreground`,listMarker:`text-[var(--syntax-keyword)]`,marker:`text-muted-foreground`},Y=`text-foreground`;function be(e,t){if(!e||t.length===0)return null;let n=e.length,r=new Set([0,n]);for(let e of t)e.start>0&&e.start<n&&r.add(e.start),e.end>0&&e.end<n&&r.add(e.end);let i=[...r].sort((e,t)=>e-t),a=t.map((e,t)=>({range:e,index:t})).filter(e=>e.range.end>e.range.start).sort((e,t)=>e.range.start-t.range.start),o=[],s=[],c=0;for(let t=0;t<i.length-1;t+=1){let n=i[t],r=i[t+1];if(r<=n)continue;for(;c<a.length&&a[c].range.start<=n;)s.push(a[c]),c+=1;for(let e=s.length-1;e>=0;--e)s[e].range.end<=n&&s.splice(e,1);let u=null,d=-1,f=1/0;for(let{range:e,index:t}of s){let n=e.priority??J[e.style];(n>d||n===d&&t<f)&&(d=n,f=t,u=e)}let p=u?u.className??ye[u.style]:Y,m=e.slice(n,r),h=u?.visual,g=u?.skillName,_=o[o.length-1];_&&_.className===p&&l(_.visual,h)&&_.skillName===g?_.text+=m:o.push({text:m,className:p,visual:h,skillName:g})}return o.length>0?o:null}function X(e,t){let n=new Set(Array.from(t,e=>e.toLowerCase())),r=[];for(let t of[/(^|\s)\/(\u2003)?([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)/gi,/(^|\s)@(\u2003)?([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)(?=$|\s|[),.;:!?])/gi]){let i;for(;(i=t.exec(e))!==null;){let e=i[2]??``,t=i[3]||``;if(!n.has(t.toLowerCase()))continue;let a=i.index+(i[1]?.length??0);r.push({start:a,end:a+1+e.length+t.length,name:t})}}return r}function xe(e,t,n){if(e===t){let t=n.find(t=>e>t.start&&e<t.end);return t?{start:t.start,end:t.end}:null}let r=n.filter(n=>n.start<t&&n.end>e);return r.length===0?null:{start:Math.min(e,...r.map(e=>e.start)),end:Math.max(t,...r.map(e=>e.end))}}function Se(e,t,n){let r=X(e,t),i=Math.max(0,Math.min(n.selectionStart,e.length)),a=Math.max(i,Math.min(n.selectionEnd,e.length)),o=i,s=a;if(i===a)if(n.altKey)if(n.key===`Backspace`){for(;o>0&&/\s/.test(e[o-1]);)--o;for(;o>0&&!/\s/.test(e[o-1]);)--o}else{for(;s<e.length&&/\s/.test(e[s]);)s+=1;for(;s<e.length&&!/\s/.test(e[s]);)s+=1}else n.key===`Backspace`?o=Math.max(0,i-1):s=Math.min(e.length,i+1);if(o===s)return null;let c=r.filter(e=>e.start<s&&e.end>o);if(c.length===0)return null;let l=Math.min(o,...c.map(e=>e.start)),u=Math.max(s,...c.map(e=>e.end));return u<e.length&&/\s/.test(e[u])&&(l===0||/\s/.test(e[l-1]))?u+=1:u===e.length&&l>0&&/\s/.test(e[l-1])&&--l,{text:`${e.slice(0,l)}${e.slice(u)}`,caret:l,removedSkillNames:c.map(e=>e.name)}}function Ce(e){return e.map(e=>({start:e.start,end:e.end,style:e.kind===`file`?`mentionFile`:e.kind===`session`?`mentionSession`:`mentionAgent`,visual:e.kind===`session`&&e.label?s({trigger:`@`,icon:`chat-thread`,label:e.label},u({trigger:`@`,icon:`chat-thread`,label:e.label})):void 0}))}function we(e){let t=(0,N.c)(28),{visual:n,text:r}=e,i=n.trigger.length,a=i+n.label.length,s=a+(n.suffix?.length??0),l;t[0]!==a||t[1]!==i||t[2]!==r?(l=r.slice(i,Math.min(a,r.length)),t[0]=a,t[1]=i,t[2]=r,t[3]=l):l=t[3];let u=l,d;t[4]!==a||t[5]!==s||t[6]!==r?(d=r.slice(a,Math.min(s,r.length)),t[4]=a,t[5]=s,t[6]=r,t[7]=d):d=t[7];let f=d,p;t[8]!==s||t[9]!==r?(p=r.slice(Math.min(s,r.length)),t[8]=s,t[9]=r,t[10]=p):p=t[10];let m=p,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h={left:o,right:o},t[11]=h):h=t[11];let g=n.icon,_;t[12]===g?_=t[13]:(_=(0,P.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 inline-flex items-center justify-center`,style:h,children:(0,P.jsx)(E,{name:g,className:`${c} shrink-0 text-[var(--primary)]`,"aria-hidden":`true`})}),t[12]=g,t[13]=_);let v;t[14]!==_||t[15]!==n.trigger?(v=(0,P.jsxs)(`span`,{className:`relative inline-block align-baseline text-transparent leading-none`,children:[n.trigger,_]}),t[14]=_,t[15]=n.trigger,t[16]=v):v=t[16];let y;t[17]===u?y=t[18]:(y=(0,P.jsx)(`span`,{children:u}),t[17]=u,t[18]=y);let b;t[19]===f?b=t[20]:(b=f?(0,P.jsx)(`span`,{className:`text-transparent`,children:f}):null,t[19]=f,t[20]=b);let x;t[21]===m?x=t[22]:(x=m?(0,P.jsx)(`span`,{className:`text-transparent`,children:m}):null,t[21]=m,t[22]=x);let S;return t[23]!==x||t[24]!==v||t[25]!==y||t[26]!==b?(S=(0,P.jsxs)(P.Fragment,{children:[v,y,b,x]}),t[23]=x,t[24]=v,t[25]=y,t[26]=b,t[27]=S):S=t[27],S}var Te=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return!1;switch(e.key){case`ArrowUp`:case`PageUp`:case`Home`:return!0;default:return!1}},Z=(e,t,n)=>{let r=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;r&&r!==e;){if(r instanceof HTMLElement){let e=r.scrollHeight-r.clientHeight;if(e>1&&(n===`up`?r.scrollTop>0:r.scrollTop<e-1))return!0}r=r.parentElement}return!1},Q=(e,t)=>Z(e,t,`up`),$=(e,t)=>Z(e,t,`down`),Ee=e=>({text:e.text,references:e.references.map(e=>({...e}))}),De=e=>e.map(e=>({...e,range:{...e.range}})),Oe=(e,t)=>e.text===t.text&&JSON.stringify(e.references)===JSON.stringify(t.references),ke=(e,t,n)=>({document:Ee(e),mentions:De(t),selection:{...n}}),Ae=()=>({undo:[],redo:[]}),je=(e,t)=>({undo:[...e.undo,t].slice(-100),redo:[]}),Me=(e,t)=>{let n=e.undo.at(-1);return!n||!Oe(n.after.document,t)?null:{history:{undo:e.undo.slice(0,-1),redo:[...e.redo,n]},snapshot:ke(n.before.document,n.before.mentions,n.before.selection)}},Ne=(e,t)=>{let n=e.redo.at(-1);return!n||!Oe(n.before.document,t)?null:{history:{undo:[...e.undo,n],redo:e.redo.slice(0,-1)},snapshot:ke(n.after.document,n.after.mentions,n.after.selection)}},Pe=e=>{if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.trunc(e);return t>=0?t:void 0},Fe=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.summary;return!t||typeof t!=`object`||Array.isArray(t)?null:t},Ie=e=>{let t=Pe(e);return t!==void 0&&t>0?t:void 0};function Le(e){let t=Fe(e);if(!t)return null;let n=Ie(t.additions),r=Ie(t.deletions),i=Ie(t.files)??Ie(t.diffCount);return n===void 0&&r===void 0&&i===void 0?null:{...n===void 0?{}:{additions:n},...r===void 0?{}:{deletions:r},...i===void 0?{}:{files:i}}}function Re(e){if(!e)return null;let t=[];return e.additions!==void 0&&e.additions>0&&t.push(`+${e.additions}`),e.deletions!==void 0&&e.deletions>0&&t.push(`−${e.deletions}`),t.length>0?t.join(` `):null}function ze(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.providerID==`string`?t.providerID.trim():``,r=typeof t.modelID==`string`?t.modelID.trim():``;if(n&&r)return`${n}/${r}`;let i=t.model;if(typeof i==`string`&&i.trim())return i.trim();if(i&&typeof i==`object`&&!Array.isArray(i)){let e=i,t=typeof e.providerID==`string`?e.providerID.trim():typeof e.provider==`string`?e.provider.trim():``,n=typeof e.modelID==`string`?e.modelID.trim():typeof e.id==`string`?e.id.trim():``;if(t&&n)return`${t}/${n}`}return null}function Be(e){if(!e||e.trim().length===0)return null;let t=C.getState(),n=t.activeSessions.find(t=>t.id===e)??t.archivedSessions.find(t=>t.id===e)??null;if(!n)return null;let r=w(n);return r?{sessionId:e,directory:r,session:n,fromCache:!t.hasLoaded,source:`memory`}:null}function Ve(e){return Be(e)?.directory??null}var He=new Map;async function Ue(e,t){let n=e.trim();if(!n)return null;let r=Be(n);if(r)return r;let i=He.get(n);if(i)return i;let o=(async()=>{let e=Be(n);if(e)return e;let r=await x(n,{signal:t?.signal});if(r?.directory)return{sessionId:r.id,directory:r.directory,session:null,fromCache:!1,source:`session-index`};if(t?.trySessionGet===!1)return null;try{let e=await a.getSession(n),t=typeof e.directory==`string`&&e.directory.trim()||(typeof e.project?.worktree==`string`?e.project.worktree.trim():``)||null;return t?{sessionId:n,directory:t,session:e,fromCache:!1,source:`session-get`}:null}catch{return null}})().finally(()=>{He.get(n)===o&&He.delete(n)});return He.set(n,o),o}export{oe as A,he as C,V as D,U as E,ae as M,ie as N,de as O,G as S,pe as T,X as _,Le as a,Se as b,Ae as c,Me as d,Te as f,be as g,we as h,Re as i,I as j,se as k,je as l,Q as m,Ve as n,ze as o,$ as p,Ue as r,ke as s,Be as t,Ne as u,Ce as v,me as w,q as x,xe as y};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{T as t}from"./desktop-BAmoc_34.js";import{at as n,ot as r,st as i}from"./vendor-base-ui-CzHs0bHY.js";import{At as a}from"./gitApiHttp-MWsHNHuo.js";import{at as o,dt as s,ot as c,pt as l,ut as u}from"./bootstrap-C8paoQ0j.js";import{n as d}from"./vendor-react-DlzBev0S.js";import{a as f,n as p}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as m,t as h}from"./platform-sEg2IOLZ.js";import{i as g,m as _}from"./vendor-reactuses-core-DWo5Wn6R.js";import{f as v,r as y,t as b}from"./button-CyJvQsp5.js";import{Ci as x,Oi as S,Qr as C,Yr as w,ii as ee,ni as T}from"./useMobileNavigationStore-BHAEAnfr.js";import{n as E}from"./Icon-BOYrvHyJ.js";import{r as D}from"./themes-BgDJcxRc.js";import{t as O}from"./MobileResizableSheet-vAenroLZ.js";import{n as te,t as k}from"./useDictation-C-waWdAq.js";import{t as A}from"./LoadingImage-D9r0ukc0.js";import{t as j}from"./textarea-CWQIq-Mn.js";var M=e(i(),1),N=d(),P=r(),ne=e(n(),1),re=f(`YuriMedia`);function F(e){return e.platform===`android`||/Android/i.test(e.userAgent)||e.userAgentDataPlatform===`Android`}function ie(){if(typeof window>`u`)return!1;let e=navigator.userAgentData;return F({platform:h(),userAgent:navigator.userAgent||``,userAgentDataPlatform:e?.platform})}function I(){return m()&&p.getPlatform()===`android`&&p.isPluginAvailable(`YuriMedia`)}async function ae(e){if(!I())return null;let t=await re.pickMedia({limit:e});if(t.cancelled)return[];let n=[];for(let e of t.files){let t=await fetch(p.convertFileSrc(e.path));if(!t.ok)throw Error(`Native media fetch failed (${t.status})`);let r=await t.blob();n.push(new File([r],e.name,{type:e.mimeType}))}return n}var L=`h-auto min-h-12 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 border-b border-[var(--surface-subtle)] last:border-b-0`,oe=e=>{let t=(0,N.c)(38),{id:n,open:r,onOpenChange:i,onPickPhotos:a,onPickFiles:o}=e,{t:s}=v(),c;t[0]===s?c=t[1]:(c=s(`chat.chatInput.actions.addAttachment`),t[0]=s,t[1]=c);let l;t[2]===c?l=t[3]:(l=(0,P.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:c}),t[2]=c,t[3]=l);let u;t[4]===s?u=t[5]:(u=s(`chat.chatInput.actions.addAttachment`),t[4]=s,t[5]=u);let d;t[6]===s?d=t[7]:(d=s(`mobile.surface.closeAria`),t[6]=s,t[7]=d);let f;t[8]===s?f=t[9]:(f=s(`mobile.sessions.sheet.resizeAria`),t[8]=s,t[9]=f);let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,P.jsx)(E,{name:`file-image`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[10]=p):p=t[10];let m;t[11]===s?m=t[12]:(m=s(`chat.chatInput.actions.attachPhotos`),t[11]=s,t[12]=m);let h;t[13]===m?h=t[14]:(h=(0,P.jsx)(`span`,{className:`truncate`,children:m}),t[13]=m,t[14]=h);let g;t[15]!==a||t[16]!==h?(g=(0,P.jsxs)(b,{type:`button`,variant:`ghost`,size:`lg`,className:L,"data-mobile-press-feedback":`none`,onClick:a,children:[p,h]}),t[15]=a,t[16]=h,t[17]=g):g=t[17];let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,P.jsx)(E,{name:`attachment-2`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[18]=_):_=t[18];let y;t[19]===s?y=t[20]:(y=s(`chat.chatInput.actions.attachFiles`),t[19]=s,t[20]=y);let x;t[21]===y?x=t[22]:(x=(0,P.jsx)(`span`,{className:`truncate`,children:y}),t[21]=y,t[22]=x);let S;t[23]!==o||t[24]!==x?(S=(0,P.jsxs)(b,{type:`button`,variant:`ghost`,size:`lg`,className:L,"data-mobile-press-feedback":`none`,onClick:o,children:[_,x]}),t[23]=o,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==S||t[27]!==g?(C=(0,P.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,P.jsxs)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-page-scroll-lock":`true`,children:[g,S]})}),t[26]=S,t[27]=g,t[28]=C):C=t[28];let w;return t[29]!==n||t[30]!==i||t[31]!==r||t[32]!==C||t[33]!==l||t[34]!==u||t[35]!==d||t[36]!==f?(w=(0,P.jsx)(O,{id:n,open:r,onOpenChange:i,title:l,ariaLabel:u,closeAriaLabel:d,resizeAriaLabel:f,fitContent:!0,children:C}),t[29]=n,t[30]=i,t[31]=r,t[32]=C,t[33]=l,t[34]=u,t[35]=d,t[36]=f,t[37]=w):w=t[37],w},R={glyph:`_glyph_1xs2e_1`,lens:`_lens_1xs2e_12`,shape:`_shape_1xs2e_21`,revolve:`_revolve_1xs2e_1`};function se(e){let t=(0,N.c)(18),{decorative:n,size:r}=e,i=n!==void 0&&n,a=r===void 0?20:r,{t:o}=v(),s;t[0]===a?s=t[1]:(s={width:a,height:a},t[0]=a,t[1]=s);let c=i||void 0,l=i?void 0:`img`,u;t[2]!==i||t[3]!==o?(u=i?void 0:o(`common.loading`),t[2]=i,t[3]=o,t[4]=u):u=t[4];let d=`scale(${a/28})`,f;t[5]===d?f=t[6]:(f={transform:d},t[5]=d,t[6]=f);let p,m,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,P.jsx)(`span`,{className:R.shape}),p=(0,P.jsx)(`span`,{className:R.shape}),m=(0,P.jsx)(`span`,{className:R.shape}),t[7]=p,t[8]=m,t[9]=h):(p=t[7],m=t[8],h=t[9]);let g;t[10]===f?g=t[11]:(g=(0,P.jsxs)(`span`,{className:R.lens,style:f,children:[h,p,m]}),t[10]=f,t[11]=g);let _;return t[12]!==g||t[13]!==s||t[14]!==c||t[15]!==l||t[16]!==u?(_=(0,P.jsx)(`span`,{"data-dictation-loading":!0,className:R.glyph,style:s,"aria-hidden":c,role:l,"aria-label":u,children:g}),t[12]=g,t[13]=s,t[14]=c,t[15]=l,t[16]=u,t[17]=_):_=t[17],_}var z=D(!1).colors,ce=`M-50 74.564 A600 600 0 0 1 147.707 22.283 A38 38 0 0 1 154.330 97.994 A524 524 0 0 0 -18.333 143.653 Z`,le=`M450 74.564 A600 600 0 0 0 252.293 22.283 A38 38 0 0 0 245.670 97.994 A524 524 0 0 1 418.333 143.653 Z`,ue={colorScheme:`light`,"--surface-background":z.surface.background,"--surface-foreground":z.surface.foreground,"--primary-base":z.primary.base,"--foreground":z.surface.background,"--interactive-hover":`color-mix(in srgb, var(--surface-background) 12%, transparent)`,"--interactive-active":`color-mix(in srgb, var(--surface-background) 20%, transparent)`,"--ring":z.interactive.focusRing,"--status-error":z.status.error};function de(e){let t=(0,N.c)(85),{containerRef:n,disabled:r,onInsert:i,onSend:a,onRelease:o,onError:s,onHintChange:c}=e,{t:l}=v(),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(!1),[m,h]=(0,M.useState)(`send`),_=(0,M.useRef)(null),y=(0,M.useRef)(null),b=(0,M.useRef)(`insert`),x=(0,M.useRef)(null),S=(0,M.useId)(),C=(0,M.useId)(),w=(0,M.useId)(),T;t[0]!==i||t[1]!==a?(T=e=>b.current===`send`?a(e):i(e),t[0]=i,t[1]=a,t[2]=T):T=t[2];let E;t[3]!==s||t[4]!==T?(E={onTranscript:T,onError:s},t[3]=s,t[4]=T,t[5]=E):E=t[5];let D=k(E),{status:O,isStarting:te,partialTranscript:A,error:j,volume:re}=D,F=g(c),ie=u?m===`cancel`?`cancelling`:m===`edit`?`editing`:`recording`:f?`processing`:null,I,ae;t[6]!==ie||t[7]!==F?(I=()=>{F(ie)},ae=[ie,F],t[6]=ie,t[7]=F,t[8]=I,t[9]=ae):(I=t[8],ae=t[9]),(0,M.useEffect)(I,ae);let L,oe;t[10]===F?(L=t[11],oe=t[12]):(L=()=>()=>F(null),oe=[F],t[10]=F,t[11]=L,t[12]=oe),(0,M.useEffect)(L,oe);let R;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{y.current&&clearTimeout(y.current),y.current=null},t[13]=R):R=t[13];let z=g(R),de;t[14]!==n||t[15]!==r?(de=e=>{if(r||!(e instanceof HTMLElement))return null;let t=n.current?.querySelector(`textarea`);return!t||t.value!==``||t.disabled||t.readOnly||t.ownerDocument.activeElement===t||e!==t&&!e.closest(`[data-yuri-composer-compact-surface]`)||e.closest(`button, [data-composer-action]`)?null:t},t[14]=n,t[15]=r,t[16]=de):de=t[16];let V=g(de),fe;t[17]!==z||t[18]!==D||t[19]!==j||t[20]!==f||t[21]!==O?(fe=()=>{f||(z(),_.current=null,d(!1),h(`send`),O===`failed`||O===`idle`&&j?D.discardFailedDictation():D.cancelDictation())},t[17]=z,t[18]=D,t[19]=j,t[20]=f,t[21]=O,t[22]=fe):fe=t[22];let H=g(fe),pe;t[23]!==D||t[24]!==r||t[25]!==V||t[26]!==f||t[27]!==O?(pe=e=>{let t=e.target;r||f||O!==`idle`||_.current||!e.isPrimary||e.button!==0||!(t instanceof HTMLElement)||V(t)&&(e.preventDefault(),e.stopPropagation(),_.current={pointer:e.pointerId,x:e.clientX,y:e.clientY,intent:`send`,started:!1},y.current=setTimeout(()=>{if(y.current=null,!_.current)return;let e=V(t);if(!e){_.current=null;return}e.blur(),_.current.started=!0,b.current=`insert`,d(!0),h(`send`),D.startDictation()},300))},t[23]=D,t[24]=r,t[25]=V,t[26]=f,t[27]=O,t[28]=pe):pe=t[28];let U=g(pe),me;t[29]===z?me=t[30]:(me=e=>{let t=_.current;if(!t||t.pointer!==e.pointerId)return;e.preventDefault(),e.stopPropagation();let n=e.clientX-t.x,r=x.current?.getBoundingClientRect(),i=r&&r.width>0&&e.clientY>=r.top&&e.clientY<=r.bottom?e.clientX<r.left+r.width/2?`cancel`:`edit`:n<=-64?`cancel`:n>=64?`edit`:`send`;if(!t.started&&Math.hypot(n,t.y-e.clientY)>12){z(),_.current=null;return}t.started&&i!==t.intent&&(t.intent=i,h(i),ee(i===`send`?`light`:`medium`,{bypassCadence:!0}))},t[29]=z,t[30]=me);let W=g(me),he;t[31]!==H||t[32]!==z||t[33]!==n||t[34]!==D||t[35]!==j||t[36]!==o||t[37]!==A||t[38]!==O?(he=e=>{let t=_.current;if(!(!t||t.pointer!==e.pointerId)){if(e.preventDefault(),e.stopPropagation(),z(),j||O===`failed`){H();return}_.current=null,d(!1),t.started?t.intent===`cancel`?D.cancelDictation():(b.current=t.intent===`edit`?`insert`:`send`,o(A),p(!0),Promise.resolve(D.confirmDictation()).finally(()=>{p(!1),D.discardFailedDictation(),t.intent===`edit`&&n.current?.querySelector(`textarea`)?.focus()})):n.current?.querySelector(`textarea`)?.focus()}},t[31]=H,t[32]=z,t[33]=n,t[34]=D,t[35]=j,t[36]=o,t[37]=A,t[38]=O,t[39]=he):he=t[39];let G=g(he),ge;t[40]===H?ge=t[41]:(ge=e=>{_.current?.pointer===e.pointerId&&H()},t[40]=H,t[41]=ge);let _e=g(ge),ve;t[42]===V?ve=t[43]:(ve=e=>{V(e.target)&&e.preventDefault()},t[42]=V,t[43]=ve);let K=g(ve),q,J;t[44]!==H||t[45]!==z||t[46]!==n||t[47]!==U||t[48]!==_e||t[49]!==W||t[50]!==K||t[51]!==G?(q=()=>{let e=n.current;if(!e)return;let t=()=>{document.visibilityState===`hidden`&&H()};return e.addEventListener(`pointerdown`,U,!0),e.addEventListener(`touchstart`,K,{capture:!0,passive:!1}),window.addEventListener(`pointermove`,W,{capture:!0,passive:!1}),window.addEventListener(`pointerup`,G,!0),window.addEventListener(`pointercancel`,_e,!0),e.addEventListener(`contextmenu`,K,!0),e.addEventListener(`selectstart`,K,!0),window.addEventListener(`blur`,H),document.addEventListener(`visibilitychange`,t),()=>{z(),e.removeEventListener(`pointerdown`,U,!0),e.removeEventListener(`touchstart`,K,!0),window.removeEventListener(`pointermove`,W,!0),window.removeEventListener(`pointerup`,G,!0),window.removeEventListener(`pointercancel`,_e,!0),e.removeEventListener(`contextmenu`,K,!0),e.removeEventListener(`selectstart`,K,!0),window.removeEventListener(`blur`,H),document.removeEventListener(`visibilitychange`,t)}},J=[n,U,W,G,_e,H,z,K],t[44]=H,t[45]=z,t[46]=n,t[47]=U,t[48]=_e,t[49]=W,t[50]=K,t[51]=G,t[52]=q,t[53]=J):(q=t[52],J=t[53]),(0,M.useEffect)(q,J);let ye,Y;if(t[54]!==H||t[55]!==r?(ye=()=>{r&&H()},Y=[r,H],t[54]=H,t[55]=r,t[56]=ye,t[57]=Y):(ye=t[56],Y=t[57]),(0,M.useEffect)(ye,Y),!u&&!f)return null;let be=Math.min(1,Math.max(0,re))**.6,X=!!j,xe=j?H:void 0,Se;t[58]===be?Se=t[59]:(Se={...ue,"--speech-energy":be},t[58]=be,t[59]=Se);let Ce=Se,we;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,P.jsx)(`div`,{className:`yuri-speech-light-field`,"aria-hidden":`true`,children:[`ice`,`lilac`,`mint`,`blush`,`mid`,`core`].map(B)}),t[60]=we):we=t[60];let Te=te||f,Z;t[61]!==j||t[62]!==te||t[63]!==A||t[64]!==f||t[65]!==O||t[66]!==l?(Z=j&&!f?(0,P.jsx)(`p`,{role:`alert`,className:`yuri-speech-caption yuri-speech-error`,children:j}):(0,P.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`yuri-speech-caption`,children:te||f?(0,P.jsx)(se,{size:72}):A?(0,P.jsx)(`span`,{className:`yuri-speech-interim`,children:A}):l(O===`uploading`?`chat.dictation.processing`:`chat.dictation.listening`)}),t[61]=j,t[62]=te,t[63]=A,t[64]=f,t[65]=O,t[66]=l,t[67]=Z):Z=t[67];let Q;t[68]!==Te||t[69]!==Z?(Q=(0,P.jsx)(`div`,{className:`yuri-speech-content`,"data-starting":Te,children:Z}),t[68]=Te,t[69]=Z,t[70]=Q):Q=t[70];let $;t[71]!==S||t[72]!==C||t[73]!==w||t[74]!==u||t[75]!==m||t[76]!==l?($=u&&(0,P.jsx)(`div`,{className:`yuri-speech-gesture-stage`,"aria-hidden":`true`,children:(0,P.jsxs)(`div`,{className:`yuri-speech-gesture-surfaces`,children:[(0,P.jsx)(`div`,{className:`yuri-speech-target-glass`,style:{clipPath:`url(#${C})`}}),(0,P.jsx)(`div`,{className:`yuri-speech-target-glass`,style:{clipPath:`url(#${w})`}}),(0,P.jsxs)(`svg`,{className:`yuri-speech-geometry`,viewBox:`0 0 400 226`,focusable:`false`,children:[(0,P.jsxs)(`defs`,{children:[(0,P.jsx)(`clipPath`,{id:C,clipPathUnits:`objectBoundingBox`,children:(0,P.jsx)(`path`,{transform:`scale(0.0025 0.004424778761)`,d:ce})}),(0,P.jsx)(`clipPath`,{id:w,clipPathUnits:`objectBoundingBox`,children:(0,P.jsx)(`path`,{transform:`scale(0.0025 0.004424778761)`,d:le})}),(0,P.jsxs)(`linearGradient`,{id:S,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,P.jsx)(`stop`,{offset:`0%`,className:`yuri-speech-arc-top`}),(0,P.jsx)(`stop`,{offset:`100%`,className:`yuri-speech-arc-bottom`})]})]}),(0,P.jsxs)(`g`,{className:`yuri-speech-targets`,ref:x,children:[(0,P.jsxs)(`g`,{className:`yuri-speech-target yuri-speech-target--cancel`,"data-active":m===`cancel`,children:[(0,P.jsx)(`path`,{d:ce}),(0,P.jsx)(`text`,{x:`95`,y:`68`,textAnchor:`middle`,dominantBaseline:`central`,transform:`rotate(-11 95 68)`,children:l(`chat.dictation.cancelGesture`)})]}),(0,P.jsxs)(`g`,{className:`yuri-speech-target yuri-speech-target--edit`,"data-active":m===`edit`,children:[(0,P.jsx)(`path`,{d:le}),(0,P.jsx)(`text`,{x:`305`,y:`68`,textAnchor:`middle`,dominantBaseline:`central`,transform:`rotate(11 305 68)`,children:l(`chat.dictation.edit`)})]})]}),(0,P.jsx)(`path`,{className:`yuri-speech-hold-arc`,fill:`url(#${S})`,d:`M-50 186.987 A500 500 0 0 1 450 186.987 L450 300 H-50 Z`})]})]})}),t[71]=S,t[72]=C,t[73]=w,t[74]=u,t[75]=m,t[76]=l,t[77]=$):$=t[77];let Ee;return t[78]!==m||t[79]!==X||t[80]!==xe||t[81]!==Ce||t[82]!==Q||t[83]!==$?(Ee=(0,ne.createPortal)((0,P.jsxs)(`div`,{className:`yuri-speech-overlay`,"data-intent":m,"data-error":X,onClick:xe,style:Ce,children:[we,Q,$]}),document.body),t[78]=m,t[79]=X,t[80]=xe,t[81]=Ce,t[82]=Q,t[83]=$,t[84]=Ee):Ee=t[84],Ee}function B(e){return(0,P.jsx)(`div`,{className:`yuri-speech-reactor yuri-speech-reactor--${e}`,children:(0,P.jsx)(`div`,{className:`yuri-speech-light`})},e)}function V(e){let n=(0,N.c)(7),{available:r}=e,i=S(fe),[a,o]=(0,M.useState)(null),s;n[0]!==r||n[1]!==i?(s=r&&i&&!t()&&te(),n[0]=r,n[1]=i,n[2]=s):s=n[2];let c=s,l=c?a:null,u;return n[3]!==c||n[4]!==i||n[5]!==l?(u={globallyEnabled:i,enabled:c,hint:l,onHintChange:o},n[3]=c,n[4]=i,n[5]=l,n[6]=u):u=n[6],u}function fe(e){return e.dictationEnabled}var H=M.createContext(null),pe=e=>{let t=(0,N.c)(3),{actions:n,children:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,P.jsx)(H.Provider,{value:n,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},U=()=>M.useContext(H),me=e=>e.nativeEvent.isComposing||e.nativeEvent.keyCode===229;function W(e){let t=(0,N.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=y(`inline-flex shrink-0 items-center justify-center rounded-full bg-foreground text-background`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,P.jsx)(`span`,{className:a,...i,"aria-hidden":!0,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function he(e){let t=(0,N.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,P.jsx)(`span`,{"data-stop-glyph":`true`,className:`block size-[38%] rounded-[20%] bg-current`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,P.jsx)(W,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function G(e){let t=(0,N.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,spinning:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i,o=a?`loader-4`:`arrow-up`,s=a?`size-[50%] animate-spin`:`size-[56%]`,c;t[4]===s?c=t[5]:(c=y(s),t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,P.jsx)(E,{name:o,weight:`medium`,className:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==n||t[10]!==r||t[11]!==l?(u=(0,P.jsx)(W,{className:n,...r,children:l}),t[9]=n,t[10]=r,t[11]=l,t[12]=u):u=t[12],u}var ge=M.forwardRef((e,t)=>{let n=(0,N.c)(17),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({children:r,className:i,expanded:s,style:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let c=s!==void 0&&s&&`min-h-0 flex-1`,l;n[6]!==i||n[7]!==c?(l=y(`relative flex flex-col overflow-visible border border-[color-mix(in_srgb,var(--interactive-border)_50%,transparent)] dark:border-transparent`,`bg-[var(--surface-background)] shadow-[0_2px_6px_-3px_color-mix(in_srgb,var(--surface-foreground)_4%,transparent),inset_0_1px_0_var(--yuri-mobile-glass-highlight)] transition-colors duration-150 motion-reduce:transition-none`,`dark:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_8%)] dark:shadow-none dark:hover:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)] dark:focus-within:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)]`,c,i),n[6]=i,n[7]=c,n[8]=l):l=n[8];let u;n[9]===o?u=n[10]:(u={borderRadius:`var(--radius-xl)`,...o},n[9]=o,n[10]=u);let d;return n[11]!==r||n[12]!==a||n[13]!==t||n[14]!==l||n[15]!==u?(d=(0,P.jsx)(`div`,{ref:t,className:l,style:u,...a,children:r}),n[11]=r,n[12]=a,n[13]=t,n[14]=l,n[15]=u,n[16]=d):d=n[16],d});ge.displayName=`ChatComposerSurface`;var _e=M.forwardRef((e,t)=>{let n=(0,N.c)(3),r;return n[0]!==e||n[1]!==t?(r=(0,P.jsx)(j,{ref:t,...e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});_e.displayName=`ChatPromptTextarea`;var ve=e=>{let t=(0,N.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=y(`flex shrink-0 items-center gap-2 bg-transparent px-2.5 py-1.5`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,P.jsx)(`div`,{className:a,"data-chat-input-footer":`true`,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o},K=(e,t)=>{typeof e==`function`?e(t):e&&(e.current=t)},q=({value:e,attachments:t=[],disabled:n=!1,pending:r=!1,placeholder:i,isMobile:a=!1,onChange:o,onSubmit:s,onStop:c,onAddFiles:l,onRemoveAttachment:u,addFilesLabel:d,removeAttachmentLabel:f,fileAccept:p=`image/*`,sendLabel:m,stopLabel:h,hint:b,leftControls:x,rightControls:S,footerContent:C,inputHeader:w,attachmentContent:ee,highlightedContent:D,highlightRef:O,inputRef:te,textareaProps:k,textLayoutClassName:j,inputClassName:N,inputOuterClassName:ne,inputStyle:re,footerClassName:F,footerStyle:L,contentClassName:R,inputSectionClassName:se,autoResize:z=!0,disableInputWhilePending:ce=!0,layout:le=`stacked`,children:ue,className:de,expanded:B=!1,...V})=>{let{t:fe}=v(),H=le===`inline`,[pe,U]=M.useState(!1),[W,q]=M.useState(!1),J=ie(),ye=t.length>0||pe,Y=M.useRef(null),be=M.useRef(null),X=M.useRef(null),xe=M.useId().replace(/:/g,``),Se=g(()=>{if(!z||B||k?.fillContainer){H&&U(!1);return}let e=Y.current;if(!e)return;e.style.height=H?`0px`:`auto`;let t=Number.parseFloat(window.getComputedStyle(e).maxHeight),n=H?Math.max(e.scrollHeight,48):e.scrollHeight,r=Number.isFinite(t)?Math.min(n,t):n;e.style.height=`${r}px`,e.style.overflowY=Number.isFinite(t)&&n>t?`auto`:`hidden`;let i=r>48;H&&U(e=>e===i?e:i)});M.useLayoutEffect(()=>{Se()},[z,B,H,k?.fillContainer,e]),_(H&&z&&!B&&!k?.fillContainer?Y:null,Se);let Ce=e=>{k?.onKeyDown?.(e),!(e.defaultPrevented||me(e))&&e.key===`Enter`&&!e.shiftKey&&!a&&(e.preventDefault(),!n&&(!r||!ce)&&s())},we=e=>{l?.(e.target.files),e.target.value=``},Te=g(()=>{Y.current?.blur(),q(!0)}),Z=g(e=>{q(!1),requestAnimationFrame(()=>e?.click())}),Q=g(()=>{q(!1),requestAnimationFrame(()=>{(async()=>{if(!I()){X.current?.click();return}try{let e=await ae(20);if(e===null){X.current?.click();return}e.length>0&&l?.(e)}catch(e){console.error(`Native photo pick failed`,e),T.error(fe(`chat.chatInput.toast.attachFileFailed`))}})()})}),$=e.trim().length>0||t.length>0,Ee=t.filter(e=>e.mime.startsWith(`image/`)),De=t.filter(e=>!e.mime.startsWith(`image/`)),Oe=l?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`input`,{ref:be,type:`file`,accept:p,multiple:!0,className:`hidden`,onChange:we}),J?(0,P.jsx)(`input`,{ref:X,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:we}):null,(0,P.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>J?Te():be.current?.click(),onMouseDown:a?e=>e.preventDefault():void 0,onPointerDownCapture:a?e=>e.preventDefault():void 0,disabled:n||r,"aria-label":d,children:(0,P.jsx)(E,{name:`attachment-2`,className:`size-[18px]`})})]}):null,ke=!n&&!r&&$,Ae=a?`size-6`:`size-full`,je=r&&c?(0,P.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":h,children:(0,P.jsx)(he,{className:Ae})}):(0,P.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":ke?`true`:void 0,className:y(`flex size-8 shrink-0 items-center justify-center outline-none`,ke?`rounded-full hover:opacity-80`:`rounded-md text-primary hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-30`),disabled:n||r||!$,"aria-label":m,children:ke?(0,P.jsx)(G,{className:Ae}):(0,P.jsx)(E,{name:r?`loader-4`:`send-plane-2`,className:y(`size-4`,r&&`animate-spin`)})}),Me=r&&c?(0,P.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:c,"aria-label":h,children:(0,P.jsx)(he,{className:Ae})}):(0,P.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":`true`,className:y(`flex size-8 shrink-0 items-center justify-center rounded-full outline-none`,ke?`hover:opacity-80`:`cursor-not-allowed opacity-30`),disabled:n||r||!$,"aria-busy":r||void 0,"aria-label":m,onClick:()=>Y.current?.focus({preventScroll:!0}),onMouseDown:e=>e.preventDefault(),onPointerDownCapture:a?e=>e.preventDefault():void 0,children:(0,P.jsx)(G,{className:Ae,spinning:r})}),Ne=H?Me:je,Pe=x===void 0?Oe:x;return(0,P.jsxs)(ge,{className:de,expanded:B,...V,children:[ue,(0,P.jsxs)(`div`,{"data-composer-content":`true`,"data-composer-layout":le,className:y(`relative flex min-h-0`,H?y(`min-h-12 flex-row`,ye?`items-end`:`items-center`):`flex-col`,B&&`flex-1`,R),children:[H&&Pe?(0,P.jsx)(`div`,{className:`flex h-12 shrink-0 items-center pl-1.5`,"data-composer-inline-attach":`true`,children:Pe}):null,(0,P.jsxs)(`div`,{className:y(`overflow-hidden`,H&&`min-w-0 flex-1`,B&&`flex min-h-0 flex-1 flex-col`,se),children:[w,ee,Ee.length>0?(0,P.jsx)(`div`,{className:`flex gap-2 overflow-x-auto px-3 pt-3`,"data-chat-prompt-attachments":`true`,children:Ee.map(e=>(0,P.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,P.jsx)(`span`,{className:`block size-16`,children:(0,P.jsx)(A,{fill:!0,src:e.url,alt:e.name,className:`size-16 rounded-lg border border-border object-cover`})}),u?(0,P.jsx)(`button`,{type:`button`,className:`absolute -right-1 -top-1 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] shadow-sm hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,P.jsx)(E,{name:`close`,className:`size-3`})}):null]},e.id))}):null,De.length>0?(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,"data-chat-prompt-file-attachments":`true`,children:De.map(e=>(0,P.jsxs)(`div`,{className:`relative flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border bg-[var(--surface-elevated)] px-2 py-1`,children:[(0,P.jsx)(E,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,P.jsx)(`span`,{className:`min-w-0 truncate typography-micro`,children:e.name}),u?(0,P.jsx)(`button`,{type:`button`,className:`flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-[var(--interactive-hover)]`,onClick:()=>u(e.id),"aria-label":f,children:(0,P.jsx)(E,{name:`close`,className:`size-3`})}):null]},e.id))}):null,(0,P.jsxs)(`div`,{className:y(`relative overflow-hidden`,H&&y(`flex min-h-12`,pe?`items-end`:`items-center`),B&&`flex min-h-0 flex-1 flex-col`),"data-composer-input-shell":`true`,children:[D?(0,P.jsx)(`div`,{ref:O,"aria-hidden":!0,"data-composer-highlight":`true`,className:y(`pointer-events-none absolute inset-0 z-0 rounded-b-none`,j,N),children:D}):null,(0,P.jsx)(_e,{...k,simple:!0,fillContainer:!H&&k?.fillContainer,ref:e=>{Y.current=e,K(te,e)},"data-chat-input":`true`,value:e,onChange:e=>o(e.target.value,e),onKeyDown:Ce,disabled:n||r&&ce,placeholder:i,enterKeyHint:a?`enter`:k?.enterKeyHint,outerClassName:y(`ring-0 bg-transparent shadow-none hover:bg-transparent focus-within:ring-0`,H&&`flex-none`,B&&`min-h-0 flex-1`,ne),className:y(`relative z-10 resize-none overflow-y-hidden appearance-none border-0 bg-transparent typography-markdown hover:border-transparent md:typography-ui-label`,H?`field-sizing-fixed min-h-12 max-h-32 px-3 py-3 leading-6`:`min-h-[52px] max-h-40 rounded-b-none px-3 pb-2 pt-4`,j,N,D&&`text-transparent caret-[var(--surface-foreground)]`),style:re,rows:k?.rows??1})]})]}),H?(0,P.jsx)(`div`,{className:y(`flex h-12 shrink-0 items-center pr-1.5`,F),style:L,"data-composer-inline-send":`true`,children:S??Ne}):(0,P.jsx)(ve,{className:F,style:L,children:C??(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`flex items-center gap-1.5`,children:x??Oe}),b?(0,P.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,children:b}):(0,P.jsx)(`div`,{className:`flex-1`}),(0,P.jsx)(`div`,{className:`flex items-center gap-1.5`,children:S??Ne})]})})]}),J&&l?(0,P.jsx)(oe,{id:`mobile-attach-pick-${xe}`,open:W,onOpenChange:e=>{e||q(!1)},onPickPhotos:Q,onPickFiles:()=>Z(be.current)}):null]})},J={dictation:102,mentionFile:100,mentionAgent:100,mentionSession:100,mentionCommand:100,mentionPaste:100,code:90,codeFence:90,link:80,linkUrl:78,heading:70,blockquote:40,listMarker:35,marker:10},ye={dictation:`text-foreground underline decoration-current underline-offset-4`,mentionFile:`text-[var(--primary)]`,mentionAgent:`text-[var(--primary)]`,mentionSession:`text-[var(--primary)]`,mentionCommand:`text-[var(--primary)]`,mentionPaste:`text-[var(--primary)]`,code:`rounded-[3px] bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,codeFence:`bg-[var(--surface-subtle)] text-[var(--markdown-inline-code)]`,link:`text-[var(--status-info)] underline`,linkUrl:`text-muted-foreground`,heading:`text-[var(--syntax-keyword)]`,blockquote:`text-muted-foreground`,listMarker:`text-[var(--syntax-keyword)]`,marker:`text-muted-foreground`},Y=`text-foreground`;function be(e,t){if(!e||t.length===0)return null;let n=e.length,r=new Set([0,n]);for(let e of t)e.start>0&&e.start<n&&r.add(e.start),e.end>0&&e.end<n&&r.add(e.end);let i=[...r].sort((e,t)=>e-t),a=t.map((e,t)=>({range:e,index:t})).filter(e=>e.range.end>e.range.start).sort((e,t)=>e.range.start-t.range.start),o=[],s=[],c=0;for(let t=0;t<i.length-1;t+=1){let n=i[t],r=i[t+1];if(r<=n)continue;for(;c<a.length&&a[c].range.start<=n;)s.push(a[c]),c+=1;for(let e=s.length-1;e>=0;--e)s[e].range.end<=n&&s.splice(e,1);let u=null,d=-1,f=1/0;for(let{range:e,index:t}of s){let n=e.priority??J[e.style];(n>d||n===d&&t<f)&&(d=n,f=t,u=e)}let p=u?u.className??ye[u.style]:Y,m=e.slice(n,r),h=u?.visual,g=u?.skillName,_=o[o.length-1];_&&_.className===p&&l(_.visual,h)&&_.skillName===g?_.text+=m:o.push({text:m,className:p,visual:h,skillName:g})}return o.length>0?o:null}function X(e,t){let n=new Set(Array.from(t,e=>e.toLowerCase())),r=[];for(let t of[/(^|\s)\/(\u2003)?([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)/gi,/(^|\s)@(\u2003)?([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)(?=$|\s|[),.;:!?])/gi]){let i;for(;(i=t.exec(e))!==null;){let e=i[2]??``,t=i[3]||``;if(!n.has(t.toLowerCase()))continue;let a=i.index+(i[1]?.length??0);r.push({start:a,end:a+1+e.length+t.length,name:t})}}return r}function xe(e,t,n){if(e===t){let t=n.find(t=>e>t.start&&e<t.end);return t?{start:t.start,end:t.end}:null}let r=n.filter(n=>n.start<t&&n.end>e);return r.length===0?null:{start:Math.min(e,...r.map(e=>e.start)),end:Math.max(t,...r.map(e=>e.end))}}function Se(e,t,n){let r=X(e,t),i=Math.max(0,Math.min(n.selectionStart,e.length)),a=Math.max(i,Math.min(n.selectionEnd,e.length)),o=i,s=a;if(i===a)if(n.altKey)if(n.key===`Backspace`){for(;o>0&&/\s/.test(e[o-1]);)--o;for(;o>0&&!/\s/.test(e[o-1]);)--o}else{for(;s<e.length&&/\s/.test(e[s]);)s+=1;for(;s<e.length&&!/\s/.test(e[s]);)s+=1}else n.key===`Backspace`?o=Math.max(0,i-1):s=Math.min(e.length,i+1);if(o===s)return null;let c=r.filter(e=>e.start<s&&e.end>o);if(c.length===0)return null;let l=Math.min(o,...c.map(e=>e.start)),u=Math.max(s,...c.map(e=>e.end));return u<e.length&&/\s/.test(e[u])&&(l===0||/\s/.test(e[l-1]))?u+=1:u===e.length&&l>0&&/\s/.test(e[l-1])&&--l,{text:`${e.slice(0,l)}${e.slice(u)}`,caret:l,removedSkillNames:c.map(e=>e.name)}}function Ce(e){return e.map(e=>({start:e.start,end:e.end,style:e.kind===`file`?`mentionFile`:e.kind===`session`?`mentionSession`:`mentionAgent`,visual:e.kind===`session`&&e.label?s({trigger:`@`,icon:`chat-thread`,label:e.label},u({trigger:`@`,icon:`chat-thread`,label:e.label})):void 0}))}function we(e){let t=(0,N.c)(28),{visual:n,text:r}=e,i=n.trigger.length,a=i+n.label.length,s=a+(n.suffix?.length??0),l;t[0]!==a||t[1]!==i||t[2]!==r?(l=r.slice(i,Math.min(a,r.length)),t[0]=a,t[1]=i,t[2]=r,t[3]=l):l=t[3];let u=l,d;t[4]!==a||t[5]!==s||t[6]!==r?(d=r.slice(a,Math.min(s,r.length)),t[4]=a,t[5]=s,t[6]=r,t[7]=d):d=t[7];let f=d,p;t[8]!==s||t[9]!==r?(p=r.slice(Math.min(s,r.length)),t[8]=s,t[9]=r,t[10]=p):p=t[10];let m=p,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h={left:o,right:o},t[11]=h):h=t[11];let g=n.icon,_;t[12]===g?_=t[13]:(_=(0,P.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 inline-flex items-center justify-center`,style:h,children:(0,P.jsx)(E,{name:g,className:`${c} shrink-0 text-[var(--primary)]`,"aria-hidden":`true`})}),t[12]=g,t[13]=_);let v;t[14]!==_||t[15]!==n.trigger?(v=(0,P.jsxs)(`span`,{className:`relative inline-block align-baseline text-transparent leading-none`,children:[n.trigger,_]}),t[14]=_,t[15]=n.trigger,t[16]=v):v=t[16];let y;t[17]===u?y=t[18]:(y=(0,P.jsx)(`span`,{children:u}),t[17]=u,t[18]=y);let b;t[19]===f?b=t[20]:(b=f?(0,P.jsx)(`span`,{className:`text-transparent`,children:f}):null,t[19]=f,t[20]=b);let x;t[21]===m?x=t[22]:(x=m?(0,P.jsx)(`span`,{className:`text-transparent`,children:m}):null,t[21]=m,t[22]=x);let S;return t[23]!==x||t[24]!==v||t[25]!==y||t[26]!==b?(S=(0,P.jsxs)(P.Fragment,{children:[v,y,b,x]}),t[23]=x,t[24]=v,t[25]=y,t[26]=b,t[27]=S):S=t[27],S}var Te=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return!1;switch(e.key){case`ArrowUp`:case`PageUp`:case`Home`:return!0;default:return!1}},Z=(e,t,n)=>{let r=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;r&&r!==e;){if(r instanceof HTMLElement){let e=r.scrollHeight-r.clientHeight;if(e>1&&(n===`up`?r.scrollTop>0:r.scrollTop<e-1))return!0}r=r.parentElement}return!1},Q=(e,t)=>Z(e,t,`up`),$=(e,t)=>Z(e,t,`down`),Ee=e=>({text:e.text,references:e.references.map(e=>({...e}))}),De=e=>e.map(e=>({...e,range:{...e.range}})),Oe=(e,t)=>e.text===t.text&&JSON.stringify(e.references)===JSON.stringify(t.references),ke=(e,t,n)=>({document:Ee(e),mentions:De(t),selection:{...n}}),Ae=()=>({undo:[],redo:[]}),je=(e,t)=>({undo:[...e.undo,t].slice(-100),redo:[]}),Me=(e,t)=>{let n=e.undo.at(-1);return!n||!Oe(n.after.document,t)?null:{history:{undo:e.undo.slice(0,-1),redo:[...e.redo,n]},snapshot:ke(n.before.document,n.before.mentions,n.before.selection)}},Ne=(e,t)=>{let n=e.redo.at(-1);return!n||!Oe(n.before.document,t)?null:{history:{undo:[...e.undo,n],redo:e.redo.slice(0,-1)},snapshot:ke(n.after.document,n.after.mentions,n.after.selection)}},Pe=e=>{if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.trunc(e);return t>=0?t:void 0},Fe=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.summary;return!t||typeof t!=`object`||Array.isArray(t)?null:t},Ie=e=>{let t=Pe(e);return t!==void 0&&t>0?t:void 0};function Le(e){let t=Fe(e);if(!t)return null;let n=Ie(t.additions),r=Ie(t.deletions),i=Ie(t.files)??Ie(t.diffCount);return n===void 0&&r===void 0&&i===void 0?null:{...n===void 0?{}:{additions:n},...r===void 0?{}:{deletions:r},...i===void 0?{}:{files:i}}}function Re(e){if(!e)return null;let t=[];return e.additions!==void 0&&e.additions>0&&t.push(`+${e.additions}`),e.deletions!==void 0&&e.deletions>0&&t.push(`−${e.deletions}`),t.length>0?t.join(` `):null}function ze(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.providerID==`string`?t.providerID.trim():``,r=typeof t.modelID==`string`?t.modelID.trim():``;if(n&&r)return`${n}/${r}`;let i=t.model;if(typeof i==`string`&&i.trim())return i.trim();if(i&&typeof i==`object`&&!Array.isArray(i)){let e=i,t=typeof e.providerID==`string`?e.providerID.trim():typeof e.provider==`string`?e.provider.trim():``,n=typeof e.modelID==`string`?e.modelID.trim():typeof e.id==`string`?e.id.trim():``;if(t&&n)return`${t}/${n}`}return null}function Be(e){if(!e||e.trim().length===0)return null;let t=C.getState(),n=t.activeSessions.find(t=>t.id===e)??t.archivedSessions.find(t=>t.id===e)??null;if(!n)return null;let r=w(n);return r?{sessionId:e,directory:r,session:n,fromCache:!t.hasLoaded,source:`memory`}:null}function Ve(e){return Be(e)?.directory??null}var He=new Map;async function Ue(e,t){let n=e.trim();if(!n)return null;let r=Be(n);if(r)return r;let i=He.get(n);if(i)return i;let o=(async()=>{let e=Be(n);if(e)return e;let r=await x(n,{signal:t?.signal});if(r?.directory)return{sessionId:r.id,directory:r.directory,session:null,fromCache:!1,source:`session-index`};if(t?.trySessionGet===!1)return null;try{let e=await a.getSession(n),t=typeof e.directory==`string`&&e.directory.trim()||(typeof e.project?.worktree==`string`?e.project.worktree.trim():``)||null;return t?{sessionId:n,directory:t,session:e,fromCache:!1,source:`session-get`}:null}catch{return null}})().finally(()=>{He.get(n)===o&&He.delete(n)});return He.set(n,o),o}export{oe as A,he as C,V as D,U as E,ae as M,ie as N,de as O,G as S,pe as T,X as _,Le as a,Se as b,Ae as c,Me as d,Te as f,be as g,we as h,Re as i,I as j,se as k,je as l,Q as m,Ve as n,ze as o,$ as p,Ue as r,ke as s,Be as t,Ne as u,Ce as v,me as w,q as x,xe as y};
@@ -1,3 +1,3 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r}from"./runtime-switch-DEZ1K7qW.js";import{n as i}from"./runtime-fetch-D0YWp3FJ.js";import{st as a}from"./vendor-base-ui-CzHs0bHY.js";import{d as o}from"./bootstrap-C8paoQ0j.js";import{n as s}from"./vendor-react-DlzBev0S.js";import{s as c}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as l}from"./queryRuntime-2dx7jbt9.js";import{i as u}from"./vendor-reactuses-core-DWo5Wn6R.js";import{Ca as d}from"./useMobileNavigationStore-BUlbm442.js";import{a as f,c as p,d as m,i as h,l as g,o as _,r as v,s as y,u as b}from"./useDictation-C-waWdAq.js";var x=e(a(),1),S=e=>e.replace(/[^\p{L}\p{N}]/gu,``).toLowerCase();function C(e){let t=[],n=``;for(let r=0;r<e.length;){let i=String.fromCodePoint(e.codePointAt(r)),a=S(i);for(let e=0;e<a.length;e++)t.push(r);n+=a,r+=i.length}let r=[],i=0,a=[];return{append(o){if(!o||typeof o!=`object`)throw Error(`Invalid speech subtitle`);let{text:s,words:c}=o;if(typeof s!=`string`||s.length>1e4||!Array.isArray(c)||c.length>1e4)throw Error(`Invalid speech subtitle`);if(!c.length||!s.trim())return;let l=1/0,u=0,d=-1;for(let e of c){if(!e||typeof e!=`object`||typeof e.word!=`string`||!Number.isFinite(e.startTime)||!Number.isFinite(e.endTime)||e.startTime<0||e.endTime<e.startTime||e.endTime>7200||e.startTime<d)throw Error(`Invalid speech subtitle timestamp`);l=Math.min(l,e.startTime),u=Math.max(u,e.endTime),d=e.startTime}if(r.some(e=>e.startTime===l&&e.text===s))return;if(i+=s.length,r.length>=1e3||i>2e4)throw Error(`Speech subtitle limit exceeded`);r.push({text:s,startTime:l,endTime:u}),r.sort((e,t)=>e.startTime-t.startTime);let f=0;a=[];for(let i of r){let r=S(i.text),o=r?n.indexOf(r,f):-1;if(o<0)continue;let s=t[o],c=t[o+r.length-1],l=c+(e.codePointAt(c)>65535?2:1);l+=e.slice(l).match(/^[^\p{L}\p{N}]*/u)[0].length,a.push({...i,start:s,end:l}),f=o+r.length}},at(e){let t=0,n=a.length;for(;t<n;){let r=t+n>>>1;a[r].startTime<=e?t=r+1:n=r}let r=a[t-1];return r&&e<=r.endTime?r:void 0},lastBefore(e){for(let t=a.length-1;t>=0;t--)if(a[t].endTime<=e)return a[t]}}}function w(e){return{chunks:[],samples:0,complete:!1,position:0,timeline:C(e)}}async function T(e,t,n){if(e&&!e.body)throw Error(`Speech response has no stream`);let r=n.cache??w(``),i=e?.body?.getReader(),a=t.createGain();a.gain.value=n.volume,a.connect(t.destination);let o=new Set,s=new Set,c=new Set,l=()=>{for(let e of c)e();c.clear()},u=()=>new Promise(e=>{c.add(e)}),d=new TextDecoder,f=[],p=t.currentTime,m=!1,h=!1,g=!i,_=!i,v,y=-1,b=2**(n.pitch-1),x=i?0:r.position,S=()=>{let e=t.getOutputTimestamp?.().contextTime,i=e!==void 0&&Number.isFinite(e)&&e>=0?e:Math.max(0,t.currentTime-(t.outputLatency||0));for(;f.length&&i>=f[0].at;){h=!0;let e=f[0];if(r.position=e.offset+Math.min(e.duration,(i-e.at)*b),i<e.end)break;f.shift()}let a=r.timeline.at(r.position);a&&a.start>y&&h&&(y=a.start,n.onProgress?.(a))},C=()=>{for(let e of o)e.stop();l()},T=()=>{S(),i?.cancel().catch(()=>void 0),C()};n.signal.addEventListener(`abort`,T,{once:!0});let E=setInterval(S,50),D=()=>{if(n.signal.throwIfAborted(),v)throw v},O=(async()=>{if(!i)return;let e=``,t,a=0,o=e=>{if(!e.trim())return;if(_)throw Error(`Unexpected audio after speech completion`);if(e.length>1048576)throw Error(`Speech frame exceeds the size limit`);let n=JSON.parse(e);if(n.type===`error`)throw Error(`Speech synthesis interrupted or failed`);if(n.type===`done`){_=!0,l();return}if(n.type===`subtitle`){r.timeline.append(n),S();return}if(n.type!==`audio`||typeof n.data!=`string`||n.data.length>12800)throw Error(`Invalid speech audio frame`);let i=atob(n.data),a=new Uint8Array(i.length+(t===void 0?0:1)),o=0;t!==void 0&&(a[o++]=t);for(let e=0;e<i.length;e++)a[o+e]=i.charCodeAt(e);if(t=a.length%2?a[a.length-1]:void 0,a.length>1){if(r.samples*2+a.length>25165824||r.chunks.length>=8192)throw Error(`Speech cache exceeds the size limit`);let e=t===void 0?a:a.slice(0,-1);r.chunks.push(e),r.samples+=e.length/2,l()}};try{for(;;){let t=await i.read();if(n.signal.throwIfAborted(),t.done)break;if(a+=t.value.length,a>33554432)throw Error(`Speech stream exceeds the size limit`);e+=d.decode(t.value,{stream:!0});let r;for(;(r=e.indexOf(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r}from"./runtime-switch-DEZ1K7qW.js";import{n as i}from"./runtime-fetch-D0YWp3FJ.js";import{st as a}from"./vendor-base-ui-CzHs0bHY.js";import{d as o}from"./bootstrap-C8paoQ0j.js";import{n as s}from"./vendor-react-DlzBev0S.js";import{s as c}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{a as l}from"./queryRuntime-2dx7jbt9.js";import{i as u}from"./vendor-reactuses-core-DWo5Wn6R.js";import{Ca as d}from"./useMobileNavigationStore-BHAEAnfr.js";import{a as f,c as p,d as m,i as h,l as g,o as _,r as v,s as y,u as b}from"./useDictation-C-waWdAq.js";var x=e(a(),1),S=e=>e.replace(/[^\p{L}\p{N}]/gu,``).toLowerCase();function C(e){let t=[],n=``;for(let r=0;r<e.length;){let i=String.fromCodePoint(e.codePointAt(r)),a=S(i);for(let e=0;e<a.length;e++)t.push(r);n+=a,r+=i.length}let r=[],i=0,a=[];return{append(o){if(!o||typeof o!=`object`)throw Error(`Invalid speech subtitle`);let{text:s,words:c}=o;if(typeof s!=`string`||s.length>1e4||!Array.isArray(c)||c.length>1e4)throw Error(`Invalid speech subtitle`);if(!c.length||!s.trim())return;let l=1/0,u=0,d=-1;for(let e of c){if(!e||typeof e!=`object`||typeof e.word!=`string`||!Number.isFinite(e.startTime)||!Number.isFinite(e.endTime)||e.startTime<0||e.endTime<e.startTime||e.endTime>7200||e.startTime<d)throw Error(`Invalid speech subtitle timestamp`);l=Math.min(l,e.startTime),u=Math.max(u,e.endTime),d=e.startTime}if(r.some(e=>e.startTime===l&&e.text===s))return;if(i+=s.length,r.length>=1e3||i>2e4)throw Error(`Speech subtitle limit exceeded`);r.push({text:s,startTime:l,endTime:u}),r.sort((e,t)=>e.startTime-t.startTime);let f=0;a=[];for(let i of r){let r=S(i.text),o=r?n.indexOf(r,f):-1;if(o<0)continue;let s=t[o],c=t[o+r.length-1],l=c+(e.codePointAt(c)>65535?2:1);l+=e.slice(l).match(/^[^\p{L}\p{N}]*/u)[0].length,a.push({...i,start:s,end:l}),f=o+r.length}},at(e){let t=0,n=a.length;for(;t<n;){let r=t+n>>>1;a[r].startTime<=e?t=r+1:n=r}let r=a[t-1];return r&&e<=r.endTime?r:void 0},lastBefore(e){for(let t=a.length-1;t>=0;t--)if(a[t].endTime<=e)return a[t]}}}function w(e){return{chunks:[],samples:0,complete:!1,position:0,timeline:C(e)}}async function T(e,t,n){if(e&&!e.body)throw Error(`Speech response has no stream`);let r=n.cache??w(``),i=e?.body?.getReader(),a=t.createGain();a.gain.value=n.volume,a.connect(t.destination);let o=new Set,s=new Set,c=new Set,l=()=>{for(let e of c)e();c.clear()},u=()=>new Promise(e=>{c.add(e)}),d=new TextDecoder,f=[],p=t.currentTime,m=!1,h=!1,g=!i,_=!i,v,y=-1,b=2**(n.pitch-1),x=i?0:r.position,S=()=>{let e=t.getOutputTimestamp?.().contextTime,i=e!==void 0&&Number.isFinite(e)&&e>=0?e:Math.max(0,t.currentTime-(t.outputLatency||0));for(;f.length&&i>=f[0].at;){h=!0;let e=f[0];if(r.position=e.offset+Math.min(e.duration,(i-e.at)*b),i<e.end)break;f.shift()}let a=r.timeline.at(r.position);a&&a.start>y&&h&&(y=a.start,n.onProgress?.(a))},C=()=>{for(let e of o)e.stop();l()},T=()=>{S(),i?.cancel().catch(()=>void 0),C()};n.signal.addEventListener(`abort`,T,{once:!0});let E=setInterval(S,50),D=()=>{if(n.signal.throwIfAborted(),v)throw v},O=(async()=>{if(!i)return;let e=``,t,a=0,o=e=>{if(!e.trim())return;if(_)throw Error(`Unexpected audio after speech completion`);if(e.length>1048576)throw Error(`Speech frame exceeds the size limit`);let n=JSON.parse(e);if(n.type===`error`)throw Error(`Speech synthesis interrupted or failed`);if(n.type===`done`){_=!0,l();return}if(n.type===`subtitle`){r.timeline.append(n),S();return}if(n.type!==`audio`||typeof n.data!=`string`||n.data.length>12800)throw Error(`Invalid speech audio frame`);let i=atob(n.data),a=new Uint8Array(i.length+(t===void 0?0:1)),o=0;t!==void 0&&(a[o++]=t);for(let e=0;e<i.length;e++)a[o+e]=i.charCodeAt(e);if(t=a.length%2?a[a.length-1]:void 0,a.length>1){if(r.samples*2+a.length>25165824||r.chunks.length>=8192)throw Error(`Speech cache exceeds the size limit`);let e=t===void 0?a:a.slice(0,-1);r.chunks.push(e),r.samples+=e.length/2,l()}};try{for(;;){let t=await i.read();if(n.signal.throwIfAborted(),t.done)break;if(a+=t.value.length,a>33554432)throw Error(`Speech stream exceeds the size limit`);e+=d.decode(t.value,{stream:!0});let r;for(;(r=e.indexOf(`
2
2
  `))!==-1;)o(e.slice(0,r)),e=e.slice(r+1);if(e.length>1048576)throw Error(`Speech frame exceeds the size limit`)}if(e+=d.decode(),e.trim()&&o(e),!_||!r.samples||t!==void 0)throw Error(`Incomplete speech audio stream`);r.complete=!0}finally{g=!0,l()}})().catch(e=>{v=e,C()}),k=async(e,r)=>{for(;p-t.currentTime>2&&s.size;)await Promise.race([Promise.race(s),u()]),D();D();let i=Math.min(e.length/2,Math.max(0,Math.round(((n.endAt??1/0)-r)*24e3))),c=Math.max(0,Math.round((x-r)*24e3));if(c>=i)return;let d=t.createBuffer(1,i-c,24e3),h=d.getChannelData(0),g=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let e=c;e<i;e++)h[e-c]=g.getInt16(e*2,!0)/32768;let _=t.createBufferSource();_.buffer=d,_.detune.value=(n.pitch-1)*1200,_.connect(a);let v,y=new Promise(e=>{v=e});s.add(y),o.add(_),_.onended=()=>{S(),o.delete(_),s.delete(y),_.disconnect(),v(),l()};let C=Math.max(p,t.currentTime+.02);p=C+d.duration/b,f.push({at:C,end:p,offset:r+c/24e3,duration:d.duration}),_.start(C),m||(m=!0,n.onStart())};try{D();let e=0,i=0,a=!0;for(;D(),!(i>=(n.endAt??1/0));){if(e>=r.chunks.length){if(g)break;await u();continue}p<t.currentTime+.02&&(a=!0);let n=(r.samples/24e3-Math.max(i,x))/b;if(a&&!_&&n<.4){await u();continue}a=!1;let o=r.chunks[e++];await k(o,i),i+=o.length/48e3}if(await O,D(),!m&&x<Math.min(r.samples/24e3,n.endAt??1/0))throw Error(`Incomplete speech audio stream`);await Promise.all(s),D(),r.position=Math.min(r.samples/24e3,n.endAt??1/0)}finally{S(),clearInterval(E),n.signal.removeEventListener(`abort`,T),await i?.cancel().catch(()=>void 0),await O,i?.releaseLock();for(let e of o)e.onended=null,e.stop(),e.disconnect();a.disconnect()}}async function*E(e,t,n){let r=await y(m(e,`tts`),n),i=crypto.randomUUID(),a=new TextEncoder,o={speaker:e.voice,audio_params:{format:`pcm`,sample_rate:24e3,speech_rate:Math.round((e.speed-1)*100),...[`seed-tts-2.0`,`seed-icl-2.0`].includes(e.resourceId)?{enable_subtitle:!0}:{}},...e.resourceId===`seed-tts-2.0`&&e.voice===`zh_female_vv_uranus_bigtts`?{additions:JSON.stringify({context_texts:[`请用自然、温暖的对话语气朗读,根据文本内容表达恰当的情感,保持清晰自然的停顿与重音,避免夸张的播音腔。`]})}:{}},s=(e,n=!1)=>({user:{uid:`yuri`},namespace:`BidirectionalTTS`,event:e,req_params:{...o,...n?{text:t}:{}}}),c=`connection`,l=0;try{for(r.send(g(1));;){let e=await _(await r.read(),`tts`);if(n.throwIfAborted(),e.event===51||e.event===153||e.event===151)throw Error(`Speech synthesis failed`);if(e.event>=100&&e.sessionId!==i)throw Error(`Unexpected speech session`);if(e.event===50&&c===`connection`)c=`session`,r.send(g(100,i,s(100)));else if(e.event===150&&c===`session`)c=`audio`,r.send(g(200,i,s(200,!0))),r.send(g(102,i));else if(e.event===352&&c===`audio`&&e.type===11){if(l+=e.payload.length,l>33554432)throw Error(`Speech audio exceeds size limit`);for(let t=0;t<e.payload.length;t+=9600){let n=e.payload.subarray(t,t+9600),r=``;for(let e of n)r+=String.fromCharCode(e);yield a.encode(`${JSON.stringify({type:`audio`,data:btoa(r)})}\n`)}}else if(e.event===364&&c===`audio`){let t=p(e.payload);yield a.encode(`${JSON.stringify({type:`subtitle`,text:t.text,words:t.words})}\n`)}else if(e.event===152&&c===`audio`){let t=p(e.payload);if(t.status_code!==void 0&&t.status_code!==0&&t.status_code!==2e7)throw Error(`Speech synthesis failed`);if(!l)throw Error(`Speech returned no audio`);try{r.send(g(2))}catch{}yield a.encode(`{"type":"done"}
3
3
  `);return}else if(e.event!==350&&e.event!==351)throw Error(`Unexpected speech synthesis event`)}}finally{r.close()}}async function D(e,t){if(!e.trim())throw Error(`Speech text is required`);let n=await b(`tts`,t);if(!n)return i(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/x-ndjson, audio/*`},body:JSON.stringify({text:e.trim()}),signal:t});if(e.length>1e4)throw Error(`Speech text must contain 1–10000 characters`);let r=new AbortController,a=E(n,e.trim(),AbortSignal.any([t,r.signal])),o=new ReadableStream({async pull(e){try{let t=await a.next();t.done?e.close():e.enqueue(t.value)}catch(t){e.error(t)}},async cancel(){r.abort(),await a.return(void 0)}});return new Response(o,{headers:{"Content-Type":`application/x-ndjson`,"X-Speech-Pitch":String(n.pitch),"X-Speech-Volume":String(n.volume)}})}var O=3e4,k=new Map,A=new Map;async function j(e){let t=Date.now(),n=k.get(e);if(n&&t-n.checkedAt<O)return n.available;let r=A.get(e);if(r)return r;let a=(async()=>{try{let t=await i(`/api/tts/status`);if(!t.ok)return k.set(e,{available:!1,checkedAt:Date.now()}),!1;let n=!!(await t.json()).available;return k.set(e,{available:n,checkedAt:Date.now()}),n}catch{return k.set(e,{available:!1,checkedAt:Date.now()}),!1}finally{A.delete(e)}})();return A.set(e,a),a}var M=null,N=null;function P(){return h(),N||=new(window.AudioContext||window.webkitAudioContext),N}function F(e={}){let r=e.enabled??!0,[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(null),d=(0,x.useRef)(null),p=(0,x.useRef)(null),m=(0,x.useRef)(0),h=u(async()=>{let e=++m.current,t=n(),i=r=>(e===m.current&&n()===t&&s(r),r);if(!r)return i(!1);try{return i(await j(t))}catch{return i(!1)}});(0,x.useEffect)(()=>{h()},[r,h]),(0,x.useEffect)(()=>t(()=>{h()}),[h]);let g=u(()=>{let e=p.current;if(p.current=null,e?.abort.abort(),d.current){try{d.current.onended=null,d.current.stop()}catch{}d.current=null}a(!1)}),_=u(async()=>{try{let e=P();e.state===`suspended`&&await e.resume();let t=e.createBuffer(1,1,22050),n=e.createBufferSource();n.buffer=t,n.connect(e.destination),n.start(0)}catch(e){console.error(`[useServerTTS] Failed to unlock audio:`,e)}}),v=u(async(e,t)=>{if(g(),!e.trim()){l(`No text to speak`),t?.onError?.(`No text to speak`);return}l(null);let r={abort:new AbortController};p.current=r;try{let i=P();i.state===`suspended`&&await i.resume();let o=i.createBuffer(1,1,22050),s=i.createBufferSource();s.buffer=o,s.connect(i.destination),s.start(0);let c=n(),l=t?.resume&&t.playbackKey&&M?.key===t.playbackKey&&M.identity===c&&M.text===e?M:null,u=Math.max(0,Math.min(e.length,t?.resumeOffset??0)),f=async(e,n,o,s,c,l)=>{await T(e,i,{signal:r.abort.signal,pitch:o,volume:s,cache:n,endAt:l,onStart:()=>{p.current===r&&(a(!0),t?.onStart?.())},onProgress:e=>{p.current===r&&t?.onProgress?.({...e,start:e.start+c,end:e.end+c})}})},m=()=>{p.current===r&&(M?.key===t?.playbackKey&&(M=null),p.current=null,a(!1),t?.onEnd?.())};if(l){if(l.pcm.complete){await f(null,l.pcm,l.pitch,l.volume,l.offset),m();return}let t=l.pcm.timeline.lastBefore(l.pcm.samples/24e3);t&&l.offset+t.end<e.trimEnd().length&&(t.endTime>l.pcm.position&&await f(null,l.pcm,l.pitch,l.volume,l.offset,t.endTime),u=Math.max(u,l.offset+t.end))}if(r.abort.signal.throwIfAborted(),M=null,u+=e.slice(u).match(/^\s*/u)[0].length,u===e.length){m();return}let h=await D(e.slice(u),r.abort.signal);if(p.current!==r){await h.body?.cancel();return}if(!h.ok){let e=await h.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${h.status}`)}let g=Number(h.headers.get(`X-Speech-Pitch`)??1),_=Number(h.headers.get(`X-Speech-Volume`)??1);if(h.headers.get(`content-type`)?.includes(`application/x-ndjson`)){let n=w(e.slice(u));t?.playbackKey&&(M={key:t.playbackKey,identity:c,text:e,offset:u,pcm:n,pitch:g,volume:_}),await f(h,n,g,_,u),m();return}let v=await(await h.blob()).arrayBuffer();if(p.current!==r)return;let y=await i.decodeAudioData(v);if(p.current!==r)return;let b=i.createBufferSource();b.buffer=y,g!==1&&(b.detune.value=(g-1)*1200);let x=i.createGain();if(x.gain.value=_,b.connect(x),x.connect(i.destination),d.current=b,b.onended=()=>{p.current===r&&d.current===b&&(a(!1),d.current=null,p.current=null,t?.onEnd?.())},a(!0),t?.onStart?.(),p.current!==r||d.current!==b)return;b.start(0)}catch(e){if(e.name===`AbortError`||p.current!==r)return;let n=e instanceof Error?e.message:`Failed to speak`;console.error(`[useServerTTS] Error:`,n),l(n),t?.onError?.(n),a(!1),d.current&&=(d.current.onended=null,null),p.current=null}});return(0,x.useEffect)(()=>t(()=>{g(),M=null}),[g]),(0,x.useEffect)(()=>f(g),[g]),(0,x.useEffect)(()=>()=>{g()},[g]),{isPlaying:i,isAvailable:o,error:c,speak:v,stop:g,checkAvailability:h,unlockAudio:_}}var I=60,L=400;function R(e){let t=e.replace(/\s+/g,` `).trim();if(!t)return[];let n=t.match(/[^.!?…]+[.!?…]+["')\]]*\s*|[^.!?…]+$/g)??[t],r=[],i=``;for(let e of n)for(let t=0;t<e.length;t+=L){let n=e.slice(t,t+L);i&&i.length+n.length>L&&(r.push(i.trim()),i=``),i+=n,i.length>=I&&/[.!?…]["')\]]*\s*$/.test(i)&&(r.push(i.trim()),i=``)}if(i.trim()&&r.push(i.trim()),r.length>0&&r[0].length>120){let e=r[0],t=/[,;:]\s/g,n=-1,i;for(;(i=t.exec(e))!==null;){let e=i.index+1;if(!(e<40)){if(e>160)break;n=e;break}}if(n>0){let t=e.slice(0,n).trim(),i=e.slice(n).trim();r.splice(0,1,t,i)}}return r}var z=null;function B(){return h(),z||=new(window.AudioContext||window.webkitAudioContext),z}function V(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(null),a=(0,x.useRef)(null),o=(0,x.useRef)(null),s=(0,x.useCallback)(async()=>{try{let e=B();e.state===`suspended`&&await e.resume();let t=e.createBuffer(1,1,22050),n=e.createBufferSource();n.buffer=t,n.connect(e.destination),n.start(0)}catch{}},[]),c=(0,x.useCallback)(()=>{let e=o.current;if(e&&(e.cancelled=!0,e.abort.abort(),o.current=null),a.current){try{a.current.onended=null,a.current.stop()}catch{}a.current=null}t(!1)},[]),l=(0,x.useCallback)(async(e,n)=>{c();let s=R(e);if(s.length===0){r(`No text to speak`),n?.onError?.(`No text to speak`);return}r(null);let l={cancelled:!1,abort:new AbortController};o.current=l;let u=async e=>{let t=await i(`/api/dictation/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e}),signal:l.abort.signal});if(!t.ok){let e=await t.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${t.status}`)}return(await t.blob()).arrayBuffer()},d=async e=>{let t=B();t.state===`suspended`&&await t.resume();let n=await t.decodeAudioData(e);l.cancelled||await new Promise(e=>{let r=t.createBufferSource();r.buffer=n,r.connect(t.destination),a.current=r,r.onended=()=>{a.current===r&&(a.current=null),e()},r.start(0)})};try{t(!0),n?.onStart?.();let e=u(s[0]);for(let t=0;t<s.length;t+=1){let n=await e;if(l.cancelled||(t+1<s.length&&(e=u(s[t+1])),await d(n),l.cancelled))return}t(!1),n?.onEnd?.()}catch(e){if(e.name===`AbortError`||l.cancelled)return;let i=e instanceof Error?e.message:`Failed to speak`;r(i),n?.onError?.(i),t(!1)}finally{o.current===l&&(o.current=null)}},[c]);return(0,x.useEffect)(()=>f(c),[c]),(0,x.useEffect)(()=>()=>{c()},[c]),{isPlaying:e,error:n,speak:l,stop:c,unlockAudio:s}}var H=new class{recognition=null;isListening=!1;currentLang=`en-US`;onResultCallback=null;onErrorCallback=null;restartOnEnd=!1;conversationMode=!1;isSpeaking=!1;audioContext=null;audioUnlockRequired=!1;speechGeneration=0;isSupported(){let e=`SpeechRecognition`in window||`webkitSpeechRecognition`in window,t=`speechSynthesis`in window;return e&&t}getSupportDetails(){return{recognition:`SpeechRecognition`in window||`webkitSpeechRecognition`in window,synthesis:`speechSynthesis`in window,prefixed:!(`SpeechRecognition`in window)&&`webkitSpeechRecognition`in window,secureContext:window.isSecureContext}}setConversationMode(e){this.conversationMode=e,e||(this.restartOnEnd=!1)}isConversationMode(){return this.conversationMode}pauseListening(){if(this.restartOnEnd=!1,this.recognition)try{this.recognition.stop()}catch{}this.isListening=!1}resumeListening(){if(this.conversationMode,this.onResultCallback,this.isSpeaking,this.currentLang,this.conversationMode&&this.onResultCallback&&!this.isSpeaking)try{this.startListeningSync(this.currentLang,this.onResultCallback,this.onErrorCallback||void 0)}catch(e){console.error(`[BrowserVoiceService] Failed to resume listening:`,e)}}async checkMicrophonePermission(){try{return`permissions`in navigator&&(await navigator.permissions.query({name:`microphone`})).state===`granted`}catch{return!1}}async prepareListening(){if(!this.isSupported())throw Error(`Web Speech API not supported in this browser`);if(typeof navigator>`u`||typeof navigator.mediaDevices?.getUserMedia!=`function`)return!0;try{return v(),(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),!0}catch(e){let t=typeof e==`object`&&e&&`name`in e?String(e.name):``;if(t===`NotAllowedError`)throw Error(`Microphone permission denied`);if(t===`NotFoundError`)throw Error(`No microphone found`);let n=e instanceof Error?e.message:`Unable to access microphone`;throw Error(n)}}startListeningSync(e,t,n){if(!this.isSupported()){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}this.stopListening(),v(),this.isSpeaking=!1;let r=window.SpeechRecognition||window.webkitSpeechRecognition;if(!r){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}let i=new r;this.recognition=i,this.currentLang=e,this.onResultCallback=t,this.onErrorCallback=n||null,i.continuous=!0,i.interimResults=!0,i.lang=e,i.onstart=()=>{this.isListening=!0,this.restartOnEnd=!0},i.onaudiostart=()=>{},i.onsoundstart=()=>{},i.onresult=e=>{e.results.length;let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r];i.isFinal?t+=i[0].transcript:n+=i[0].transcript}n&&this.onResultCallback?.(n,!1),t&&this.onResultCallback?.(t,!0)},i.onerror=e=>{if(e.error===`aborted`)return;let t=this.getErrorMessage(e.error);this.onErrorCallback?.(t),(e.error===`not-allowed`||e.error===`service-not-allowed`||e.error===`network`)&&(this.restartOnEnd=!1,this.isListening=!1)},i.onend=()=>{if(this.isListening=!1,this.restartOnEnd&&this.recognition&&!this.isSpeaking)try{this.recognition.start()}catch{}};try{i.start()}catch(e){let t=e instanceof Error?e.message:`Failed to start speech recognition`;throw n?.(t),Error(t)}}async startListening(e,t,n){this.startListeningSync(e,t,n)}stopListening(){if(this.restartOnEnd=!1,this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}this.isListening=!1}getIsListening(){return this.isListening}getCurrentLang(){return this.currentLang}async resumeAudioContext(){h(),this.audioContext||=new(window.AudioContext||window.webkitAudioContext),this.audioContext.state===`suspended`&&await this.audioContext.resume()}isAudioUnlockRequired(){return this.audioUnlockRequired}async unlockAudio(){h();try{let e=new Audio;if(e.src=`data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA`,e.volume=.01,await e.play(),await this.resumeAudioContext(),this.isMobileDevice()&&`speechSynthesis`in window){let e=new SpeechSynthesisUtterance(``);e.volume=0,window.speechSynthesis.speak(e),window.speechSynthesis.cancel()}return this.audioUnlockRequired=!1,!0}catch(e){return console.error(`[BrowserVoiceService] Failed to unlock audio:`,e),!1}}async speakText(e,t,n,r){if(!(`speechSynthesis`in window))throw Error(`Speech synthesis not supported`);let i=++this.speechGeneration;await this.resumeAudioContext();let a=await this.waitForVoices();if(await new Promise(e=>setTimeout(e,50)),i!==this.speechGeneration)return;this.isSpeaking=!0,this.pauseListening(),window.speechSynthesis.cancel();let o=new SpeechSynthesisUtterance(e);o.lang=t,o.rate=r?.rate??1,o.pitch=r?.pitch??1,o.volume=r?.volume??1;let s=null;return r?.voiceName&&(s=a.find(e=>e.name===r.voiceName)||null,s?`${s.name}${s.lang}`:console.warn(`[BrowserVoiceService] Selected voice "${r.voiceName}" not found, falling back to language match`)),s||(s=this.findBestVoice(a,t),s?`${s.name}${s.lang}`:console.warn(`[BrowserVoiceService] No voice found for language: ${t}, using default`)),s&&(o.voice=s),`${e.length}${t}`,new Promise((e,t)=>{let a=!1;o.onstart=()=>{i===this.speechGeneration&&(a=!0,r?.onStart?.(),e())},o.onend=()=>{i===this.speechGeneration&&(this.isSpeaking=!1,n?.())},o.onerror=e=>{if(i!==this.speechGeneration)return;this.isSpeaking=!1,console.error(`[BrowserVoiceService] Speech synthesis error:`,e.error),(e.error===`not-allowed`||e.error===`interrupted`)&&(this.audioUnlockRequired=!0);let n=`Speech synthesis error: ${e.error||`unknown`}`;e.error===`not-allowed`?n=`Audio blocked by browser autoplay policy. Please interact with the page first.`:e.error===`interrupted`&&(n=`Speech was interrupted. Please try again.`),r?.onError?.(n),t(Error(n))},setTimeout(()=>{a||(console.warn(`[BrowserVoiceService] Speech start timeout - audio may be blocked`),this.audioUnlockRequired=!0)},2e3),window.speechSynthesis.speak(o)})}cancelSpeech(){this.speechGeneration+=1,this.isSpeaking=!1,`speechSynthesis`in window&&window.speechSynthesis.cancel()}getVoices(){return`speechSynthesis`in window?window.speechSynthesis.getVoices():[]}async waitForVoices(){if(!(`speechSynthesis`in window))return[];let e=window.speechSynthesis.getVoices();return e.length>0?e:new Promise(e=>{let t=()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null};window.speechSynthesis.onvoiceschanged=t,setTimeout(()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null},1e3)})}findBestVoice(e,t){let n=e.find(e=>e.lang===t);if(!n){let r=t.split(`-`)[0];n=e.find(e=>e.lang.startsWith(r))}return n||=e.find(e=>e.lang.startsWith(t.split(`-`)[0])&&e.localService),n||null}isMobileDevice(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return/iphone|ipad|ipod|android|mobile|webos|blackberry|iemobile|opera mini/i.test(e)}isIOSSafari(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase(),t=/iphone|ipad|ipod/i.test(e),n=/safari/i.test(e)&&!/chrome|crios|crmo/i.test(e);return t&&n}getErrorMessage(e){let t=this.isMobileDevice(),n=this.isIOSSafari();return{"no-speech":`No speech detected`,aborted:`Speech recognition aborted`,"audio-capture":`No microphone found`,network:`Network error - check connection`,"not-allowed":t?`Microphone permission denied. Check Settings > Safari > Microphone`:`Microphone permission denied`,"service-not-allowed":n?`Speech recognition requires a user gesture. Please tap the microphone button again.`:`Speech recognition service not allowed`,"bad-grammar":`Grammar error`,"language-not-supported":`Language not supported`}[e]||`Speech recognition error: ${e}`}};f(()=>H.cancelSpeech());var U=s(),W=(e=n())=>({queryKey:[e,`speech`,`settings`],queryFn:({signal:e})=>o(e,async e=>{let t=await i(`/api/voice/settings`,{signal:e});if(!t.ok)throw Error(`Unable to load speech settings`);return d(await t.json())}),staleTime:3e4,networkMode:`always`,retry:1,refetchOnWindowFocus:!0}),G=()=>{let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=W(),e[0]=t):t=e[0],c(t)};async function K(e,t=r(),a=n()){let{queryKey:s}=W(a);if(await l.cancelQueries({queryKey:s,exact:!0}),t!==r())throw Error(`Runtime changed`);let c=await o(new AbortController().signal,async t=>{let n=await i(`/api/voice/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t});if(!n.ok)throw Error(`Unable to save speech settings`);return d(await n.json())});if(t!==r()||a!==n()||(await l.cancelQueries({queryKey:s,exact:!0}),t!==r()))throw Error(`Runtime changed`);return l.setQueryData(s,c),c}export{V as a,H as i,W as n,F as o,G as r,K as t};