1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[40766,61615,92467],{95:(e,t,r)=>{"use strict";r.d(t,{A:()=>f});var n=r(95155),i=r(73572),o=r(6584),a=r(61915),s=r(74051),l=r(52645),u=r(7498),d=r(7138),c=r(47965),m=r(76471),p=r(6829),h=r(12115),g=r(63088);let f=(0,p.PA)(e=>{let{dismissed:t,onDismiss:r}=e,{isReady:p,conversation:f}=(0,c.useStores)(),[v,x]=(0,h.useState)(!1);return!(p&&!0===f.initialized&&!1!==f.isTextModelReady&&f.mode===g.Dp.chat&&m.GC.FREE_MODELS[f.model.text])||(null!=t?t:v)?null:(0,n.jsx)(i.Alert,{color:"blue",variant:"light",radius:"md",styles:{root:{padding:"0.5rem 0.75rem"},message:{textAlign:"center",width:"100%",fontSize:"var(--mantine-font-size-sm)",lineHeight:1.3}},children:(0,n.jsxs)(o.Group,{justify:"center",wrap:"nowrap",gap:6,children:[(0,n.jsxs)(a.Text,{size:"sm",ta:"center",children:["Free model active. ",(0,n.jsx)(s.Anchor,{c:"light-dark(var(--mantine-color-blue-9), var(--mantine-color-blue-3))",fw:600,href:"/balance",underline:"hover",size:"sm",children:"Add balance"})," for top models."]}),(0,n.jsx)(l.Tooltip,{label:"Dismiss",children:(0,n.jsx)(u.ActionIcon,{size:"xs",variant:"subtle","aria-label":"Dismiss free model notice",onClick:()=>{x(!0),null==r||r()},children:(0,n.jsx)(d.A,{size:"0.75rem"})})})]})})})},278:(e,t,r)=>{"use strict";r.d(t,{a:()=>f});var n=r(95155),i=r(73572),o=r(6584),a=r(46460),s=r(61915),l=r(52645),u=r(7498),d=r(7138),c=r(47965),m=r(6829),p=r(12115),h=r(94931),g=r(63088);let f=(0,m.PA)(e=>{let{onDismiss:t}=e,{conversation:r}=(0,c.useStores)(),[m,f]=(0,p.useState)(!1);if(r.mode!==g.Dp.video)return null;let v=r.model.video,x=r.prompt.length,b=(0,h.getVideoPromptLimit)(v);return!b||x<=b||m?null:(0,n.jsx)(i.Alert,{color:"orange",variant:"light",styles:{message:{textAlign:"center",width:"100%"}},children:(0,n.jsxs)(o.Group,{justify:"center",wrap:"nowrap",children:[(0,n.jsx)(a.Box,{children:(0,n.jsxs)(s.Text,{children:["The prompt for ",(0,h.getVideoPromptLimitDisplayName)(v)," video generation is too long (",x,"/",b," characters). Please shorten it to ",b," characters or less."]})}),(0,n.jsx)(l.Tooltip,{label:"Dismiss",children:(0,n.jsx)(u.ActionIcon,{size:"sm",variant:"subtle",onClick:()=>{f(!0),t&&t()},children:(0,n.jsx)(d.A,{size:"70%"})})})]})})})},5297:(e,t,r)=>{"use strict";r.d(t,{f:()=>I});var n=r(95155),i=r(85747),o=r(76270),a=r(31184),s=r(46460),l=r(48303),u=r(47965),d=r(87825),c=r(69619),m=r(6829),p=r(12115),h=r(63088),g=r(93171),f=r(72081),v=r(61915),x=r(22095),b=r(21385),w=r(59124),y=r(6584),S=r(52181),j=r(23070),k=r(50136),T=r(40766);let C=()=>{var e;let[t,r]=(0,p.useState)([]),[i,o]=(0,p.useState)(""),[s,l]=(0,p.useState)(null),[u,d]=(0,p.useState)(null),[c,m]=(0,p.useState)(!1),[h,g]=(0,p.useState)(!1),C=null!=(e=t[0])?e:null;(0,p.useEffect)(()=>{let e=e=>{let t=e.detail;t&&"string"==typeof t.id&&0!==t.id.length&&r(e=>e.some(e=>e.id===t.id)?e:[...e,t])},t=e=>{var t;let n=null==(t=e.detail)?void 0:t.requestId;"string"==typeof n&&0!==n.length&&r(e=>e.filter(e=>e.id!==n&&(0,T.hasPendingProjectFileWriteConfirmation)(e.id)))},n=(0,T.getPendingProjectFileWriteRequests)();return n.length>0&&r(e=>{let t=[...e];for(let e of n)t.some(t=>t.id===e.id)||t.push(e);return t}),window.addEventListener(T.PROJECT_FILE_WRITE_PENDING_EVENT,e),window.addEventListener(T.PROJECT_FILE_WRITE_RESOLVED_EVENT,t),()=>{window.removeEventListener(T.PROJECT_FILE_WRITE_PENDING_EVENT,e),window.removeEventListener(T.PROJECT_FILE_WRITE_RESOLVED_EVENT,t)}},[]),(0,p.useEffect)(()=>{o((null==C?void 0:C.fileName)||""),g(!1),l((null==C?void 0:C.existingFileName)||null),d((null==C?void 0:C.existingFileName)?(0,k.normalizeProjectFileNameForUpload)(C.fileName):null)},[null==C?void 0:C.id,null==C?void 0:C.fileName,null==C?void 0:C.existingFileName,C]),(0,p.useEffect)(()=>{if(!C)return;if(C.edits)return void m(!1);m(!0);let e=!1,t=setTimeout(()=>{let t=(0,k.normalizeProjectFileNameForUpload)(i);(0,k.findProjectFileByName)(C.projectId,t).then(r=>{e||(l((null==r?void 0:r.name)||null),d(r?t:null),m(!1))}).catch(()=>{e||(l(null),d(null),m(!1))})},200);return()=>{e=!0,clearTimeout(t)}},[C,i]);let _=(0,p.useCallback)((e,t)=>{C&&((0,T.resolveProjectFileWriteConfirmation)(C.id,{approved:e,...e&&t?{fileName:t}:{}}),r(e=>e.filter(e=>e.id!==C.id)))},[C]),P=(0,p.useCallback)(()=>{_(!1)},[_]),E=(0,p.useCallback)(async()=>
1{if(c||!C)return;if(C.edits)return void _(!0);let e=(0,k.normalizeProjectFileNameForUpload)(i),t=await (0,k.findProjectFileByName)(C.projectId,e).catch(()=>null);if(t&&u!==e){l(t.name||e),d(e);return}_(!0,i)},[C,_,i,c,u]);if(!C)return null;let D=!!s,A=!!C.edits,M={margin:0,padding:"var(--mantine-spacing-xs)",backgroundColor:"var(--mantine-color-default-hover)",borderRadius:"var(--mantine-radius-sm)",whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace"};return(0,n.jsx)(f.a,{opened:!0,onClose:P,title:A?"Apply edits to project file?":"Save file to project?",size:"lg",children:(0,n.jsxs)(a.Stack,{gap:"sm",children:[(0,n.jsx)(v.Text,{size:"sm",children:A?"The assistant wants to change parts of this file. Review the changes before applying them.":"The assistant wants to save this file to the project files. Review it before saving."}),(0,n.jsx)(x.k,{label:"File name",value:i,readOnly:A,onChange:e=>o(e.currentTarget.value)}),A&&(0,n.jsx)(v.Text,{size:"xs",c:"dimmed",children:"These changes update the same file wherever it is used, including other projects."}),D&&!A&&(0,n.jsxs)(v.Text,{size:"xs",c:"orange",children:["A project file named â",s,"â already exists and will be replaced."]}),A&&(0,n.jsx)(b.S,{label:"Show full file after edits",checked:h,onChange:e=>g(e.currentTarget.checked)}),(0,n.jsx)(w.F.Autosize,{mah:320,type:"auto",children:A&&!h?(0,n.jsx)(a.Stack,{gap:"md",children:C.edits.map((e,t)=>(0,n.jsxs)(a.Stack,{gap:"xs",children:[(0,n.jsxs)(v.Text,{size:"sm",fw:600,children:["Change ",t+1,e.occurrences>1?" (".concat(e.occurrences," occurrences)"):""]}),(0,n.jsx)(v.Text,{size:"xs",c:"dimmed",children:"Before"}),(0,n.jsx)(v.Text,{component:"pre",size:"xs",style:M,children:e.oldText}),(0,n.jsxs)(v.Text,{size:"xs",c:"dimmed",children:["After",""===e.newText?" (deleted)":""]}),(0,n.jsx)(v.Text,{component:"pre",size:"xs",style:M,children:e.newText})]},t))}):(0,n.jsx)(v.Text,{component:"pre",size:"xs",style:M,children:C.content})}),(0,n.jsxs)(y.Group,{justify:"flex-end",gap:"xs",children:[(0,n.jsx)(S.Button,{variant:"default",size:"xs",onClick:P,children:"Don't save"}),(0,n.jsx)(S.Button,{size:"xs",leftSection:(0,n.jsx)(j.A,{size:"1rem"}),onClick:()=>void E(),disabled:c,children:A?"Apply edits":D?"Replace file":"Save file"})]})]})})};var _=r(14848),P=r(49296);let E=e=>{let{opened:t,files:r,selectedFileKeys:i,isAdding:o,onClose:s,onSelectionChange:l,onAddSelected:u}=e,d=i.length;return(0,n.jsx)(f.a,{opened:t,onClose:s,title:(0,n.jsx)(v.Text,{fw:600,size:"lg",children:"Add uploaded files to project?"}),centered:!0,size:"md",closeOnClickOutside:!o,closeOnEscape:!o,children:(0,n.jsxs)(a.Stack,{gap:"md",children:[(0,n.jsx)(v.Text,{size:"sm",c:"dimmed",children:"Select the files you want future chats in this project to use."}),(0,n.jsxs)(y.Group,{gap:"xs",children:[(0,n.jsxs)(P.Badge,{variant:"light",children:[d," selected"]}),(0,n.jsx)(S.Button,{variant:"subtle",size:"xs",onClick:()=>l(r.map(e=>(0,_.QU)(e))),disabled:o||0===r.length,children:"Select all"}),(0,n.jsx)(S.Button,{variant:"subtle",size:"xs",onClick:()=>l([]),disabled:o||0===d,children:"Select none"})]}),(0,n.jsx)(b.S.Group,{value:i,onChange:l,children:(0,n.jsx)(w.F.Autosize,{mah:280,children:(0,n.jsx)(a.Stack,{gap:"xs",pr:"xs",children:r.map(e=>{let t=(0,_.QU)(e);return(0,n.jsx)(b.S,{value:t,label:e.name,disabled:o,styles:{label:{overflowWrap:"anywhere"}}},t)})})})}),(0,n.jsxs)(y.Group,{justify:"flex-end",gap:"sm",children:[(0,n.jsx)(S.Button,{variant:"default",onClick:s,disabled:o,children:"Skip"}),(0,n.jsx)(S.Button,{onClick:u,loading:o,disabled:0===d,children:"Add selected"})]})]})})},D=e=>{let{isProcessingUploads:t,addFilesToProject:r}=e,[i,o]=(0,p.useState)([]),[a,s]=(0,p.useState)([]),[u,d]=(0,p.useState)(!1),c=(0,p.useMemo)(()=>new Set(a),[a]),m=(0,p.useMemo)(()=>i.filter(e=>c.has((0,_.QU)(e))),[i,c]);(0,p.useEffect)(()=>{let e=e=>{let t=(0,_.L8)(e.detail);if(!t)return;let r=(0,_.QU)(t);o(e=>(0,_.kt)(e,t)),s(e=>e.includes(r)?e:[...e,r])};return window.addEventListener(_.PZ,e),()=>{window.removeEventListener(_.PZ,e)}},[]);let h=(0,p.useCallback)(()=>{o([]),s([])},[]),g=(0,p.useCallback)(()=>{u||h()},[h,u]),f=(0,p.useCallback)(async()=>
1{if(0===m.length)return void g();d(!0);try{for(let[e,t]of(0,_.LE)(m))await r(e,t);l.$e.show({title:"Added to project",message:1===m.length?"This file is now available to other chats in the current project.":"".concat(m.length," files are now available to other chats in the current project."),color:"teal",autoClose:3500}),h()}catch(e){console.error("[ProjectUpload] Failed to add uploaded files to project",e),l.$e.show({title:"Unable to add files to project",message:"Please try again from the project files panel.",color:"red",autoClose:5e3})}finally{d(!1)}},[r,h,g,m]);return(0,n.jsx)(E,{opened:i.length>0&&!t,files:i,selectedFileKeys:a,isAdding:u,onClose:g,onSelectionChange:s,onAddSelected:f})},A=async function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(await r.e(9768).then(r.bind(r,9768))).addUploadedFilesToProject(...t)},M=new Set(["txt","md","json","csv","log"]),I=(0,m.PA)(e=>{let{children:t}=e,{ui:m,conversation:f,libraryStore:v}=(0,u.useStores)(),x=(0,o.a)(f),[b,w]=(0,p.useState)(!1),y=(0,p.useCallback)(async e=>{w(!0);try{await e()}finally{w(!1)}},[]),S=(0,p.useCallback)(async e=>{if("undefined"==typeof fetch)return;let t=(e.name.split(".").pop()||"").toLowerCase(),r=String(e.type||"").toLowerCase(),n=r&&t?"".concat(r,";ext=").concat(t):r||(t?"ext/".concat(t):"unknown");try{await fetch("".concat("https://nano-gpt.com/api","/notion/unsupported-filetypes"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filetype:n,filesizemb:e.size/1e6,fileext:t||void 0,mimetype:r||void 0,errorkind:"unsupported_stt_video",mode:f.mode,model:f.activeModel})})}catch(e){}},[f.activeModel,f.mode]),[j,k]=(0,p.useState)(!1),T=(0,p.useCallback)(e=>{e.preventDefault(),Array.from(e.dataTransfer.types).includes("Files")&&(k(!0),e.dataTransfer.dropEffect="copy")},[]),_=(0,p.useCallback)(e=>{e.preventDefault(),k(!1)},[]),P=(0,p.useCallback)(async e=>{let t=(0,i.o)(f);if(0===e.length)return;let{tryFileAdd:n}=await r.e(9768).then(r.bind(r,9768));if(!t())return;let o=f.mode===h.Dp.audio&&"tts"===f.getSetting("audioMode","tts");if(f.mode===h.Dp.audio&&"stt"===f.getSetting("audioMode","tts")){let t=e[0];if(!t)return;let r=(0,d.normalizeSttModel)(f.getAudioSttSetting("sttModel",f.getSetting("sttModel",d.DEFAULT_STT_MODEL))),i=(0,d.normalizeSttModel)(f.getAudioSttSetting("mediaSttModel",r)),o=(0,d.isVoiceCloneModel)(i)?r:i,a=(0,d.sttModelSupportsVideoInput)(o),s=(0,d.sttModelSupportsContainerizedAudioInput)(o),u=String(t.type||"").toLowerCase(),p=(t.name.split(".").pop()||"").toLowerCase(),h=(0,c.Qs)(o),g=new Set(h.audioAttachmentExtensions),x=(0,c.jK)({fileName:t.name,fileType:u}),b=(0,c.xQ)(x),w=(0,c.H7)({extension:x,fileType:u,support:h}),y=u.startsWith("video/")||(0,c.xQ)(p);if(!a&&y&&!(s&&w)){S(t),l.$e.show({title:"Video input not supported here",message:"This STT model is audio-only. We logged the requested file type so we can evaluate demand.",color:"orange",autoClose:4e3});return}let j=h.hasDeclaredFormats&&!!x&&h.supportedFormatExtensions.has(x),k=!a&&s&&b&&u.startsWith("video/")&&w,T=!!h.hasDeclaredFormats&&j&&(!b||!u.startsWith("video/")||a||k),C=g.has(x),_=(0,c.xQ)(x),P=h.hasDeclaredFormats?T:u.startsWith("audio/")||C,E=u.startsWith("video/")||_;if(!P&&!(a&&E))return void l.$e.show({title:"Unsupported file for transcription",message:a?"Please drop an audio file or a supported video file.":"Please drop an audio file for this STT model.",color:"red",autoClose:3500});let D=t;if(!(u.startsWith("audio/")||u.startsWith("video/"))){let e=(0,c.Zs)({extension:x,allowsVideoInput:a,support:h});if(!e)return void l.$e.show({title:"Unsupported file metadata",message:"Please re-export this file so it includes a valid audio/video MIME type before uploading.",color:"red",autoClose:3500});D=new File([t],t.name,{type:e,lastModified:t.lastModified})}let A=[...f.attachments||[]],M=[];for(let e of A)try{let t=await v.getLibraryItem(e),r=String((null==t?void 0:t.fileType)||"").toLowerCase(),n=(0,c.jK)({fileName:null==t?void 0:t.name,fileType:r}),i=g.has(n),o=(0,c.xQ)(n);(r.startsWith("audio/")||r.startsWith("video/")||i||o)&&M.push(e)}catch(e){}await n(D,m,f,v);let I=[...f.attachments||[]],R=new Set(A),L=I.filter(e=>!R.has(e));if(L.length>0){let e=new Set(L);for(let t of M)e.has(t)||f.removeAttachment(t)}return void(e.length>1&&l.$e.show({title:"One file at a time in STT mode",message:"Only the first dropped file was attached for transcription.",color:"yellow",autoClose:3500}))}if(o){var a;let r=e.filter(e=>{let t=String(e.type||"").toLowerCase(),r=(e.name.split(".").pop()||"").toLowerCase();return t.startsWith("text/")||M.has(r)}),i=Math.max(0,20-((null==(a=f.attachments)?void 0:a.length)||0)),o=r.slice(0,i);for(let e of o){if(!t())return;await n(e,m,f,v)}r.length!==e.length&&l.$e.show({title:"Unsupported file for audio TTS",message:"Audio TTS accepts text context files only (.txt, .md, .json, .csv, .log).",color:"yellow",autoClose:3500}),r.length>
1o.length&&l.$e.show({title:"Attachment limit reached",message:"Audio TTS supports up to ".concat(20," text attachments."),color:"yellow",autoClose:3500});return}for(let r of e){if(!t())return;await n(r,m,f,v)}},[m,f,v,S]),E=(0,p.useCallback)(async e=>{e.preventDefault(),k(!1);let t=Array.from(e.dataTransfer.files);await y(()=>P(t))},[P,y]),I={flex:1,flexGrow:1,position:"relative",width:"100%",minWidth:0,overflowY:m.isDesktop?x?"auto":"hidden":"auto",overflowX:"hidden",scrollbarGutter:x?"stable":void 0,paddingBottom:m.isDesktop?0:"env(safe-area-inset-bottom, 0px)",paddingTop:f.isIncognito?m.isDesktop?52:46:void 0,...j?{backgroundColor:"rgba(0,122,255,0.2)",border:"3px dashed #007aff",borderRadius:4}:{}};return(0,n.jsxs)(a.Stack,{onDragOver:T,onDragLeave:_,onDrop:E,style:I,justify:x||f.mode===h.Dp.voice?"flex-start":"flex-end",mah:m.contentWindowMah,gap:0,maw:"100%",children:[j&&(0,n.jsx)(s.Box,{style:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255,255,255,0.6)",display:"flex",alignItems:"center",justifyContent:"center",color:"#007aff",fontSize:"1.2rem",fontWeight:"bold",zIndex:10,pointerEvents:"none"},children:"Drop files here to attach"}),(0,n.jsx)(g.Fx,{}),(0,n.jsx)(D,{isProcessingUploads:b,addFilesToProject:A}),(0,n.jsx)(C,{}),t]})})},5652:(e,t,r)=>{"use strict";r.d(t,{u:()=>x});var n=r(95155),i=r(46460),o=r(57142),a=r(31184),s=r(27982),l=r(31883),u=r(61915),d=r(73572),c=r(52181),m=r(17289),p=r(2054),h=r(42447),g=r(59899),f=r(73321),v=r(12115);let x=e=>{let{conversationUuid:t,beginUnlock:r,markUnlocked:x,endUnlock:b,isDesktop:w,resolvedColorScheme:y,sidebarOpen:S,setSidebarOpen:j}=e,k=(0,f.useRouter)(),[T,C]=(0,v.useState)(!1),[_,P]=(0,v.useState)(null),E=async()=>{if(!T){C(!0),P(null),r(t);try{let e=await (0,g.J)();if(!e.ok)return void P(e);x(t)}finally{b(t),C(!1)}}};return(0,n.jsxs)(i.Box,{pos:"relative",style:{flex:1,display:"flex",flexDirection:"column"},children:[!w&&(0,n.jsx)(o.UnstyledButton,{"aria-label":"Toggle navigation",onClick:()=>j(!S),style:{position:"absolute",top:"var(--mantine-spacing-xs)",left:"var(--mantine-spacing-xs)",zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"dark"===y?"rgba(255, 255, 255, 0.08)":"var(--mantine-color-gray-1)",color:"dark"===y?"var(--mantine-color-gray-0)":"var(--mantine-color-dark-7)",border:"dark"===y?"1px solid rgba(255, 255, 255, 0.08)":"1px solid var(--mantine-color-gray-3)",backdropFilter:"blur(2px)"},children:(0,n.jsx)(m.A,{size:18,stroke:1.8})}),(0,n.jsxs)(a.Stack,{align:"center",justify:"center",gap:"md",p:"xl",style:{flex:1,minHeight:"60vh"},children:[(0,n.jsx)(s.ThemeIcon,{size:64,radius:"xl",variant:"light",children:(0,n.jsx)(p.A,{size:36,stroke:1.5})}),(0,n.jsxs)(a.Stack,{gap:4,align:"center",children:[(0,n.jsx)(l.Title,{order:3,children:"This conversation is locked"}),(0,n.jsx)(u.Text,{size:"sm",c:"dimmed",ta:"center",maw:380,children:"Verify with your passkey to view it. It locks again after this window has been inactive for a few minutes."})]}),_?(0,n.jsx)(d.Alert,{color:"red",variant:"light",maw:380,children:(0,n.jsx)(h.Z,{result:_})}):null,(0,n.jsx)(c.Button,{leftSection:(0,n.jsx)(p.A,{size:18,stroke:1.6}),loading:T,onClick:()=>{E()},children:"Unlock with passkey"}),(0,n.jsx)(c.Button,{variant:"subtle",color:"gray",size:"compact-sm",onClick:()=>k.push("/conversations"),children:"Back to all conversations"})]})]})}},5700:(e,t,r)=>{"use strict";r.d(t,{Ax:()=>a,iJ:()=>i,pZ:()=>o,z6:()=>n}),r(19172);var n="_1i7uhwe0",i="_1i7uhwe1",o="_1i7uhwe3",a="_1i7uhwe2"},7167:(e,t,r)=>{"use strict";r.d(t,{m:()=>l});var n=r(95155),i=r(47965),o=r(18398),a=r(36640),s=r(23830);let l=(0,o.PA)(()=>{var e,t;let{isReady:r,session:o,conversation:l}=(0,i.useStores)(),u=r?o.auth:null,d=(0,s.ix)(null==u||null==(e=u.user)?void 0:e.name,null==u||null==(t=u.user)?void 0:t.email),c=r&&(null==l?void 0:l.mode)==="image"?"What would you like to create?":u&&d?(0,s.BO)(d):void 0;return(0,n.jsx)(a.R,{heading:c})})},7848:(e,t,r)=>{"use strict";r.d(t,{CK:()=>u,gQ:()=>a,hf:()=>l,yN:()=>s});var n=r(12115),i=r(43620),o=r(67181);let a=()=>{let[e,t]=n.useState(()=>(0,o.B2)());return n.useEffect(()=>{let e=()=>
1t((0,o.B2)()),r=t=>{(0,o.k6)(t)&&((0,o.Af)(),e())};return window.addEventListener(i.We,e),window.addEventListener("storage",r),e(),()=>{window.removeEventListener(i.We,e),window.removeEventListener("storage",r)}},[]),e},s=()=>{let[e,t]=n.useState(()=>(0,o.tQ)());return n.useEffect(()=>{let e=()=>t((0,o.tQ)()),r=t=>{(0,o.k6)(t)&&((0,o.Af)(),e())};return window.addEventListener(i.We,e),window.addEventListener("storage",r),e(),()=>{window.removeEventListener(i.We,e),window.removeEventListener("storage",r)}},[]),e},l=()=>n.useSyncExternalStore(e=>{let t=()=>e(),r=e=>{(0,o.k6)(e)&&((0,o.Af)(),t())};return window.addEventListener(i.We,t),window.addEventListener("storage",r),()=>{window.removeEventListener(i.We,t),window.removeEventListener("storage",r)}},o._4,()=>!1),u=()=>{let[e,t]=n.useState(()=>(0,o.Vr)());return n.useEffect(()=>{let e=()=>t((0,o.Vr)()),r=t=>{(0,o.k6)(t)&&((0,o.Af)(),e())};return window.addEventListener(i.We,e),window.addEventListener("storage",r),e(),()=>{window.removeEventListener(i.We,e),window.removeEventListener("storage",r)}},[]),e}},11337:(e,t,r)=>{"use strict";r.d(t,{T:()=>h});var n=r(95155),i=r(73572),o=r(6584),a=r(46460),s=r(61915),l=r(47965),u=r(6829),d=r(63088),c=r(27866),m=r.n(c),p=r(44666);let h=(0,u.PA)(()=>{let{isReady:e,conversation:t,session:r}=(0,l.useStores)(),u=m()().format("YYYY-MM-DD");if(!e||t.mode!==d.Dp.image||t.model.image!==p.pv)return null;let{countToday:c,remaining:h,isOverQuota:g}=(0,p.Dm)(r.metadata,u);if(g)return null;let f="You have ".concat(h," free ").concat(p.K1," generations remaining today (").concat(c,"/").concat(p.Qb," used)."),v="You can generate up to ".concat(p.Qb," images per day for free with ").concat(p.K1,".");return(0,n.jsx)(i.Alert,{color:"blue",variant:"light",styles:{message:{textAlign:"center",width:"100%"}},children:(0,n.jsx)(o.Group,{justify:"center",wrap:"nowrap",children:(0,n.jsx)(a.Box,{children:(0,n.jsx)(s.Text,{size:"sm",children:0===c?v:f})})})})})},14848:(e,t,r)=>{"use strict";r.d(t,{L8:()=>o,LE:()=>s,PZ:()=>n,QU:()=>i,kt:()=>a,qq:()=>l});let n="nanogpt:project-upload-files-pending",i=e=>"".concat(e.projectId,":").concat(e.libraryId),o=e=>{let t=Number(null==e?void 0:e.projectId),r=Number(null==e?void 0:e.libraryId);return!Number.isFinite(t)||t<=0||!Number.isFinite(r)||r<=0?null:{projectId:t,libraryId:r,name:(null==e?void 0:e.name)||"File ".concat(r)}},a=(e,t)=>{let r=i(t);return e.some(e=>i(e)===r)?e:[...e,t]},s=e=>{let t=new Map;for(let n of e){var r;let e=null!=(r=t.get(n.projectId))?r:[];e.push(n.libraryId),t.set(n.projectId,e)}return t},l=(e,t)=>{e.dispatchEvent(new CustomEvent(n,{detail:t}))}},15243:(e,t,r)=>{"use strict";r.d(t,{g$:()=>i,hJ:()=>n,n5:()=>o}),r(8297);var n="_1x61vu50",i="_1x61vu52",o="_1x61vu51"},20240:(e,t,r)=>{"use strict";r.d(t,{X:()=>g});var n=r(95155),i=r(12658),o=r(6584),a=r(61915),s=r(52181),l=r(12115),u=r(18398),d=r(47965),c=r(63088);let m=null,p=null,h=e=>!!e&&!!(e.fileId||e.b64_json||e.runtimeUrl&&e.runtimeUrl.startsWith("data:")||e.url&&e.url.startsWith("data:")),g=(0,u.PA)(()=>{var e,t;let{conversation:u,ui:g}=(0,d.useStores)(),[f,v]=(0,l.useState)(!1),x=u.mode,b=null!=(t=null==(e=u.attachments)?void 0:e.length)?t:0,w=u.messages;if((0,l.useEffect)(()=>{let e=!1;return u.mode!==c.Dp.image?void v(!1):m?void v(m(u.model.image)):((m?Promise.resolve(m):(!p&&(p=Promise.resolve().then(r.bind(r,90437)).then(e=>{let{isImageToImageModel:t}=e;return m=e=>"string"==typeof e&&t(e)})),p)).then(t=>{e||v(t(u.model.image))}).catch(()=>{e||v(!1)}),()=>{e=!0})},[u.mode,u.model.image]),!(0,l.useMemo)(()=>{if(x!==c.Dp.image||!f||b>0)return!1;let e=Array.isArray(w)?w:[];for(let t=e.length-1;t>=0;t--){let r=e[t];if((null==r?void 0:r.role)!=="assistant")continue;let n=Array.isArray(null==r?void 0:r.images)?r.images:[],i=Array.isArray(null==r?void 0:r.splitImages)?r.splitImages:[];if(n.some(h)||i.some(h))return!0}return!1},[b,x,w,f])&&!u.useLastImageFromHistory)return null;let y=g.inputWidth||0,S=window.innerWidth,j=Math.min(y+64,Number.isFinite(S)?S-48:y+64);return(0,n.jsx)(i.Paper,{withBorder:!0,radius:"md",px:"sm",py:8,style:{width:g.isDesktop?j:"100%",maxWidth:"100%"},children:u.useLastImageFromHistory?(0,n.jsxs)(o.Group,{justify:"space-between",wrap:"wrap",gap:"xs",children:[(0,n.jsx)(a.Text,{size:"sm",children:"Using previous image as input image."}),(0,n.jsx)(s.Button,{size:"xs",variant:"subtle",onClick:()=>u.set("useLastImageFromHistory",!1),children:"Remove"})]}):(0,n.jsxs)(o.Group,{justify:"space-between",wrap:"wrap",gap:"xs",children:[(0,n.jsx)(a.Text,{size:"sm",children:"Use previous image as input image?"}),(0,n.jsx)(s.Button,{size:"xs",onClick:()=>u.set("useLastImageFromHistory",!0),children:"Use previous image"})]})})})},26457:(e,t,r)=>{"use strict";r.d(t,{o:()=>l});var n=r(95155),i=r(76270),o=r(46460),a=r(31184),s=r(47965);let l=(0,r(18398).PA)(e=>{let{children:t}=e,{ui:r,conversation:l}
1=(0,s.useStores)();return(0,n.jsx)(o.Box,{pos:"relative",w:"100%",px:r.isDesktop?"xl":"xs",pt:r.isDesktop&&(0,i.a)(l)?"md":0,pb:r.isDesktop?"xl":0,mah:r.isDesktop?"80%":"50vh",style:{overflow:"visible"},children:(0,n.jsx)(a.Stack,{"data-resize-boundary":!0,gap:0,mx:"auto",w:"100%",maw:r.isDesktop?r.conversationWidth:"100%",style:{alignItems:"center"},children:t})})})},35382:(e,t,r)=>{"use strict";r.d(t,{$:()=>i});var n=r(47965);let i=(0,r(6829).PA)(()=>{let{conversation:e}=(0,n.useStores)();return e.isNewConversation,null})},35452:(e,t,r)=>{"use strict";r.d(t,{mG:()=>P,o6:()=>E});var n=r(95155),i=r(73572),o=r(61915),a=r(52645),s=r(7498),l=r(6584),u=r(31184),d=r(74051),c=r(52181),m=r(7138),p=r(12115),h=r(90532),g=r(47965),f=r(23015),v=r(44946),x=r(54998),b=r(22504),w=r(73508),y=r(14143),S=r(6829),j=r(11890);let k=e=>{if("number"==typeof e&&Number.isFinite(e)&&!(e<=0))return Math.round(e)},T=null,C=null,_=e=>"number"==typeof e&&Number.isFinite(e)?e.toLocaleString("en-US"):"",P=(0,S.PA)(()=>{let{conversation:e}=(0,g.useStores)();if("image"!==e.mode||"recraft-v3"!==e.model.image||!e.prompt)return null;let t=e.prompt.length;return t>800?(0,n.jsx)(i.Alert,{color:"blue",variant:"light",styles:{message:{textAlign:"center",width:"100%"}},children:(0,n.jsxs)(o.Text,{size:"sm",children:["Your image prompt is ",t," characters long. The limit is 1000 characters for the Recraft model.",t>950&&" You're very close to the limit!"]})}):null}),E=(0,S.PA)(e=>{var t,r,S,P;let{isProjectMode:E=!1}=e,{isReady:D,conversation:A,session:M,team:I,ui:R}=(0,g.useStores)(),L=(0,p.useMemo)(()=>(0,w.kV)(M.metadata),[M.metadata]),F=(0,h.m)(L),[z,N]=(0,p.useState)(null),[U,B]=(0,p.useState)(),[V,W]=(0,p.useState)(b.uy);(0,p.useEffect)(()=>(0,b.EO)(()=>{W((0,b.uy)())}),[]);let O=(0,p.useRef)(null==(t=A.properties)?void 0:t.slug);(0,p.useEffect)(()=>{var e;let t=null==(e=A.properties)?void 0:e.slug;t!==O.current&&(O.current=t,N(null))},[null==(r=A.properties)?void 0:r.slug]);let q=D&&!0===A.initialized,G=!0===A.isContextMemoryEnabled,$="ok"===A.memoryLastStatus,Y=!0===A.subscriptionActive,H=!0===A.subscriptionShowPaidModels,Q=Y&&!H,K=(0,b.iP)({...V,subscriptionActive:Y,showPaidModels:H}),J=!0===A.subscriptionActive&&!0!==A.subscriptionShowPaidModels,X=A.tokenCount,Z=String((null==(S=A.model)?void 0:S.text)||""),ee=(e=>{var t,r;if(!e||"object"!=typeof e)return;let n=null!=(t=k(e.maxTokens))?t:k(e.max_tokens),i=e.thinking&&"object"==typeof e.thinking?e.thinking:void 0,o=(null==i?void 0:i.type)==="enabled"?k(null!=(r=i.budget_tokens)?r:i.budgetTokens):void 0,a=void 0===o?void 0:o+2e3;return void 0===n?a:void 0===a?n:Math.max(n,a)})("function"==typeof A.getRequestModelSettings?A.getRequestModelSettings(Z):A.modelSetting),et=(null!=(P=null==X?void 0:X.total)?P:0)+(null!=ee?ee:0),er=!!X&&et>X.maxTokens,en=!!X&&q&&!(G&&$)&&(er||et>.9*X.maxTokens),ei=function(e,t){let[r,n]=(0,p.useState)(!1);return(0,p.useEffect)(()=>{if(!e)return void n(!1);let t=window.setTimeout(()=>n(!0),3e3);return()=>window.clearTimeout(t)},[e,3e3]),e&&r}(en,3e3);(0,p.useEffect)(()=>{let e;if(!en)return;let t=!0,r=()=>{(()=>{if(C&&C.expiresAt>Date.now())return Promise.resolve(C.ranks);if(T)return T;let e=new AbortController,t=window.setTimeout(()=>e.abort(),5e3);return T=fetch("/api/models/weekly-usage-ranks",{signal:e.signal}).then(async e=>{if(!e.ok)throw Error("Weekly usage ranks failed with ".concat(e.status));let t=await e.json();return t.ranks&&"object"==typeof t.ranks?Object.fromEntries(Object.entries(t.ranks).flatMap(e=>{let[t,r]=e;return"number"==typeof r&&Number.isInteger(r)&&r>0?[[(0,v.If)(t),r]]:[]})):{}}).then(e=>{window.clearTimeout(t),T=null;let r=Object.keys(e).length>0?e:null;return C={ranks:r,expiresAt:Date.now()+(r?3e5:6e4)},r},()=>(window.clearTimeout(t),T=null,C={ranks:null,expiresAt:Date.now()+6e4},null))})().then(n=>{t&&B(n),t&&(e=window.setTimeout(r,n?3e5:6e4))})};return r(),()=>{t=!1,void 0!==e&&window.clearTimeout(e)}},[en]);let eo=(0,p.useMemo)(()=>U&&X?(e=>{let{catalog:t,visibleModels:r,allowedModels:n,shouldApplyTeamFilter:i,hidePaidModels:o,isSubscriptionEligible:a,showOpenSourceOnly:s,requireToolCalling:l,supportsToolCalling:u,currentModelId:d,currentContextLimit:c,inputTokens:m,requestedOutputTokens:p,weeklyUsageRanks:h,limit:g=3}=e,f=m+(null!=p?p:0),v=i&&n?(0,j.UW)(n):void 0;return Object.entries(t).flatMap(e=>{let[t,n]=e,m=k(null==n?void 0:n.maxInputTokens),g=k(null==n?void 0:n.maxOutputTokens),x=k(h[t]);return n&&t!==d&&!0===r[t]&&(!0!==i||(null==v?void 0:v.has((0,j.b4)(t))))&&(!0!==o||(null==a?void 0:a(t))===!0)&&(!0!==s||!0===n.isOpenSource)&&(!0!==l||(null==u?void 0:u(t))===!0)&&!0===n.visible&&!0!==n.disabled&&!0!==n.apiOnly&&!0!==n.localOnly&&m&&x&&!(m<=c)&&
1!(m<f)&&(void 0===p||g&&!(g<p))?[{id:t,name:n.name,maxInputTokens:m,maxOutputTokens:g,weeklyUsageRank:x}]:[]}).sort((e,t)=>e.weeklyUsageRank-t.weeklyUsageRank||t.maxInputTokens-e.maxInputTokens||e.name.localeCompare(t.name)).slice(0,g)})({catalog:f.textModelLightInfo,visibleModels:F,allowedModels:I.allowedModels,shouldApplyTeamFilter:I.shouldApplyAllowedModelsFilter,hidePaidModels:Q,isSubscriptionEligible:e=>(0,y.isTextEligibleForSubscription)(e,void 0,M.subscription),showOpenSourceOnly:K,requireToolCalling:E,supportsToolCalling:x.dZ,currentModelId:Z,currentContextLimit:X.maxTokens,inputTokens:X.total,requestedOutputTokens:ee,weeklyUsageRanks:U}):[],[U,X,F,I.allowedModels,I.shouldApplyAllowedModelsFilter,Q,M.subscription,K,E,Z,ee]);if(!ei||!X)return null;let ea=G?"memory-pending":er?"over":"approaching";if(z===ea)return null;let es=Math.round(et/X.maxTokens*100),el=_(X.maxTokens),eu=_(X.total),ed=void 0===ee?"provider default (not explicitly set)":"".concat(_(ee)," tokens"),ec=void 0===ee?void 0:_(et),em=eo.length>0?eo.map(e=>"".concat(e.name," (").concat(_(e.maxInputTokens)," tokens)")).join(", "):void 0,ep=void 0===U?"Checking higher-context models with recorded usage in the last seven days. ":null===U?"Recent usage rankings are unavailable, so no model recommendation is shown. ":em?"Higher-context models with recorded usage in the last seven days: ".concat(em,". "):"No visible, enabled higher-context model with recorded usage in the last seven days currently fits both budgets. ",eh=(0,n.jsx)(a.Tooltip,{label:"Dismiss",children:(0,n.jsx)(s.ActionIcon,{size:"xs",variant:"subtle","aria-label":"Dismiss",onClick:()=>N(ea),children:(0,n.jsx)(m.A,{size:"0.75rem"})})});return G?(0,n.jsx)(i.Alert,{color:"blue",variant:"light",radius:"md",styles:{root:{padding:"0.5rem 0.75rem"},message:{textAlign:"center",width:"100%",fontSize:"var(--mantine-font-size-sm)",lineHeight:1.3}},children:(0,n.jsxs)(l.Group,{justify:"center",wrap:"nowrap",gap:6,children:[(0,n.jsx)(o.Text,{size:"sm",children:"Context Memory is enabled. Your conversation will be compressed on your next message."}),eh]})}):(0,n.jsx)(i.Alert,{color:er?"orange":"blue",variant:"light",radius:"md",styles:{root:{padding:"0.5rem 0.75rem"},message:{textAlign:"center",width:"100%",fontSize:"var(--mantine-font-size-sm)",lineHeight:1.3}},children:er?(0,n.jsxs)(l.Group,{justify:"center",wrap:"nowrap",gap:6,children:[(0,n.jsxs)(u.Stack,{gap:2,align:"center",children:[(0,n.jsxs)(o.Text,{size:"sm",ta:"center",children:["This request is over the ",el,"-token context limit (",es,"%)."]}),(0,n.jsxs)(o.Text,{size:"xs",ta:"center",children:["Input context: ",eu," tokens. Requested output budget: ",ed,".",ec?" Combined budget: ".concat(ec," tokens."):""]}),(0,n.jsx)(o.Text,{size:"xs",ta:"center",lineClamp:3,style:{minHeight:"3.9em"},children:ep}),(0,n.jsxs)(o.Text,{size:"xs",ta:"center",children:["Switching only helps if the new model can fit the full conversation and requested output.",J?(0,n.jsx)(n.Fragment,{children:" Shorten the history or lower the output budget."}):(0,n.jsxs)(n.Fragment,{children:[" Try ",(0,n.jsx)(d.Anchor,{href:"/blog/context-memory",target:"_blank",rel:"noopener",children:"Context Memory"}),", shorten the history, or lower the output budget."]})]})]}),!J&&(0,n.jsx)(c.Button,{size:"xs",variant:"light",onClick:()=>R.setShowSystemPromptModal(!0),children:"Enable"}),eh]}):(0,n.jsxs)(l.Group,{justify:"center",wrap:"nowrap",gap:6,children:[(0,n.jsxs)(u.Stack,{gap:2,align:"center",children:[(0,n.jsxs)(o.Text,{size:"sm",ta:"center",children:["Approaching the ",el,"-token context limit (",es,"%)."]}),(0,n.jsxs)(o.Text,{size:"xs",ta:"center",children:["Input context: ",eu," tokens. Requested output budget: ",ed,".",ec?" Combined budget: ".concat(ec," tokens."):""]}),(0,n.jsx)(o.Text,{size:"xs",ta:"center",lineClamp:3,style:{minHeight:"3.9em"},children:ep}),(0,n.jsxs)(o.Text,{size:"xs",ta:"center",children:["A model switch will not fix history that still exceeds the new model's limit.",J?(0,n.jsx)(n.Fragment,{children:" Shorten the history or lower the output budget."}):(0,n.jsxs)(n.Fragment,{children:[" Try ",(0,n.jsx)(d.Anchor,{href:"/blog/context-memory",target:"_blank",rel:"noopener",children:"Context Memory"}),", shorten the history, or lower the output budget."]})]})]}),!J&&(0,n.jsx)(c.Button,{size:"xs",variant:"light",onClick:()=>R.setShowSystemPromptModal(!0),children:"Enable"}),eh]})})})},39525:(e,t,r)=>{"use strict";r.d(t,{s:()=>z});var n=r(95155),i=r(44923),o=r(87256),a=r(39768),s=r(6584),l=r(52645),u=r(7498),d=r(61915),c=r(46460),m=r(29452),p=r(80828),h=r(38595),g=r(7138),f=r(72329),v=r(12115),x=r(47965),b=r(6829),w=r(63088),y=r(76471),S=r(10744),j=r(63781),k=r(37206),T=r(73321);let C=(0,k.default)(()=>
1Promise.all([r.e(32755),r.e(55500)]).then(r.bind(r,55500)).then(e=>e.SelectTextModelParams),{loadableGenerated:{webpack:()=>[55500]},ssr:!1,loading:()=>null}),_=(0,k.default)(()=>Promise.all([r.e(92889),r.e(44205),r.e(53965),r.e(31637),r.e(91553),r.e(63181),r.e(70175),r.e(12361),r.e(18998),r.e(71171),r.e(91970),r.e(74651),r.e(51428),r.e(55316),r.e(28107),r.e(1310)]).then(r.bind(r,28107)).then(e=>e.SelectModelParams),{loadableGenerated:{webpack:()=>[28107]},ssr:!1,loading:()=>null}),P=(0,b.PA)(e=>{let{isReady:t,conversation:r}=(0,x.useStores)();return t&&r.mode!==w.Dp.voice?(0,w.iD)(r.mode)?(0,n.jsx)(C,{...e}):(0,n.jsx)(_,{...e}):null}),E=(0,k.default)(()=>Promise.all([r.e(92889),r.e(85349),r.e(2924)]).then(r.bind(r,2924)).then(e=>e.SelectChatFunction),{loadableGenerated:{webpack:()=>[2924]},ssr:!1,loading:()=>null}),D=(0,k.default)(()=>r.e(627).then(r.bind(r,627)).then(e=>e.ScrollNavigation),{loadableGenerated:{webpack:()=>[627]},ssr:!1,loading:()=>null}),A=(0,k.default)(()=>Promise.all([r.e(35864),r.e(15203)]).then(r.bind(r,15203)).then(e=>e.AddContextMenu),{loadableGenerated:{webpack:()=>[15203]},ssr:!1,loading:()=>null}),M=(0,k.default)(()=>Promise.all([r.e(92889),r.e(44205),r.e(13475)]).then(r.bind(r,13475)).then(e=>e.SelectModelControl),{loadableGenerated:{webpack:()=>[13475]},ssr:!1,loading:()=>null}),I=(0,k.default)(()=>Promise.all([r.e(53965),r.e(38077),r.e(73491),r.e(15592)]).then(r.bind(r,15592)).then(e=>e.SummariseConversationMenu),{loadableGenerated:{webpack:()=>[15592]},ssr:!1,loading:()=>null}),R=(0,k.default)(()=>Promise.all([r.e(93832),r.e(65208),r.e(72386)]).then(r.bind(r,72386)).then(e=>e.ToolSelector),{loadableGenerated:{webpack:()=>[72386]},ssr:!1,loading:()=>null}),L=(0,b.PA)(e=>{let{variant:t="stacked"}=e,{conversation:r,ui:i}=(0,x.useStores)(),o=(0,T.usePathname)(),a=(()=>{let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{if("function"==typeof window.requestIdleCallback){let e=window.requestIdleCallback(()=>t(!0),{timeout:800});return()=>{var t,r;return null==(t=(r=window).cancelIdleCallback)?void 0:t.call(r,e)}}let e=globalThis.setTimeout(()=>t(!0),350);return()=>globalThis.clearTimeout(e)},[]),e})(),l=i.isDesktop?i.inputWidth:"100%",u=!1===i.isDesktop,d=(0,j.Sn)(o),m=(0,S.uW)(r.activeModel||"")===y.VC["nano-gpt-help"]?null:(0,n.jsx)(A,{size:"md"}),p=(0,n.jsx)(I,{isMobile:u}),h=a?(0,n.jsx)(P,{}):null,g=a?(0,n.jsx)(P,{compact:!0,compactSize:"md"}):null;return"inline"===t?(0,n.jsxs)(s.Group,{justify:"space-between",align:"center",gap:6*!u,wrap:"nowrap",w:"100%",children:[(0,n.jsxs)(s.Group,{gap:6*!u,wrap:"wrap",style:{flex:1,minWidth:0,rowGap:u?6:void 0},children:[(0,n.jsx)(E,{size:"md",appearance:"ghost"}),(0,n.jsx)(M,{size:"md",appearance:"ghost"}),(0,n.jsxs)(s.Group,{gap:4*!u,wrap:u?"wrap":"nowrap",style:{paddingLeft:9,minWidth:0,rowGap:u?6:void 0},children:[m,g,d?(0,n.jsx)(R,{size:"md"}):null]})]}),(0,n.jsxs)(s.Group,{gap:4,wrap:"nowrap",children:[p,(0,n.jsx)(D,{size:"lg"})]})]}):(0,n.jsx)(c.Box,{style:{width:l,maxWidth:"100%",marginLeft:"auto",marginRight:"auto"},children:(0,n.jsxs)(s.Group,{justify:"space-between",align:"flex-end",gap:5,children:[(0,n.jsxs)(s.Group,{gap:5,maw:"70dvw",children:[(0,n.jsx)(E,{}),(0,n.jsx)(M,{})]}),(0,n.jsxs)(s.Group,{justify:"flex-end",align:"flex-end",gap:5,wrap:"nowrap",children:[p,h,d?(0,n.jsx)(R,{}):null,(0,n.jsx)(D,{})]})]})})}),F=e=>{let{message:t,isLast:r,onEdit:i,onRemove:c}=e,{attributes:m,listeners:f,setActivatorNodeRef:v,setNodeRef:x,transform:b,transition:w,isDragging:y}=(0,o.gl)({id:t.id});return(0,n.jsxs)(s.Group,{ref:x,gap:"xs",justify:"space-between",wrap:"nowrap",style:{opacity:y?.55:1,transform:a.Ks.Transform.toString(b),transition:w,zIndex:y?1:void 0,minHeight:34,padding:"4px 4px 4px 2px",borderBottom:r?"none":"1px solid color-mix(in srgb, var(--mantine-color-default-border), transparent 45%)"},children:[(0,n.jsxs)(s.Group,{gap:8,wrap:"nowrap",style:{minWidth:0,flex:"1 1 auto"},children:[(0,n.jsx)(l.Tooltip,{label:"Drag to reorder queued message",withArrow:!0,children:(0,n.jsx)(u.ActionIcon,{ref:v,variant:"subtle",size:"sm","aria-label":"Drag to reorder queued message",style:{color:"var(--mantine-color-dimmed)",cursor:y?"grabbing":"grab",flexShrink:0,opacity:.85,touchAction:"none"},...m,...f,children:(0,n.jsx)(p.A,{size:14,color:"currentColor"})})}),(0,n.jsx)(d.Text,{size:"sm",c:"dimmed",style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.prompt||"(attachments only)"})]}),(0,n.jsxs)(s.Group,{gap:4,wrap:"nowrap",style:{flexShrink:0},children:[(0,n.jsx)(l.Tooltip,{label:"Edit queued message",withArrow:!0,children:(0,n.jsx)(u.ActionIcon,{variant:"subtle",size:"sm","aria-label":"Edit queued message",onClick:i,style:{color:"var(--mantine-color-dimmed)"},children:(0,n.jsx)(h.A,{size:14})})}),(0,n.jsx)(l.Tooltip,{label:"Remove queued message",withArrow:!0,children:(0,n.jsx)(u.ActionIcon,{variant:"subtle",color:"red",size:"sm","aria-label":"Remove queued message",onClick:c,children:(0,n.jsx)(g.A,{size:14})})})]})]})},z=(0,b.PA)(e=>{let{variant:t="stacked",showQueue:r=!0,showControls:a=!0}=e,{conversation:l}=(0,x.useStores)(),[p,h]=(0,v.useState)(!1),g=(0,i.FR)((0,i.MS)(i.AN)),b=r&&l.mode===w.Dp.chat&&l.queuedMessages.length>0?(0,n.jsxs)(c.Box,{mb:8,style:{overflow:"hidden",borderRadius:16,border:"1px solid var(--mantine-color-default-border)",backgroundColor:"light-dark(var(--mantine-color-white), color-mix(in srgb, var(--mantine-color-dark-8), transparent 18%))",boxShadow:p?"0 14px 36px color-mix(in srgb, var(--mantine-color-black), transparent 78%)":"none"},children:[(0,n.jsxs)(s.Group,{justify:"space-between",wrap:"nowrap",onClick:()=>h(e=>
1!e),style:{minHeight:42,cursor:"pointer",padding:"0 10px 0 12px"},children:[(0,n.jsx)(d.Text,{size:"sm",c:"dimmed",children:"".concat(l.queuedMessages.length," queued message").concat(1===l.queuedMessages.length?"":"s")}),(0,n.jsx)(u.ActionIcon,{variant:"subtle",size:"sm","aria-label":"Toggle queued items",style:{color:"var(--mantine-color-dimmed)"},children:(0,n.jsx)(f.A,{size:16,style:{transform:p?"rotate(0deg)":"rotate(-90deg)",transition:"transform 120ms ease"}})})]}),(0,n.jsx)(m.S,{in:p,children:(0,n.jsx)(c.Box,{px:8,pb:8,style:{borderTop:"1px solid color-mix(in srgb, var(--mantine-color-default-border), transparent 35%)"},children:(0,n.jsx)(i.Mp,{sensors:g,collisionDetection:i.fp,onDragEnd:e=>{let{active:t,over:r}=e;if(!r||t.id===r.id)return;let n=l.queuedMessages.findIndex(e=>e.id===r.id);n<0||l.reorderQueuedMessage(String(t.id),n)},children:(0,n.jsx)(o.gB,{items:l.queuedMessages.map(e=>e.id),strategy:o._G,children:l.queuedMessages.map((e,t)=>(0,n.jsx)(F,{message:e,isLast:t===l.queuedMessages.length-1,onEdit:()=>l.editQueuedMessage(e.id),onRemove:()=>l.removeQueuedMessage(e.id)},e.id))})})})})]}):null;return a?(0,n.jsxs)(n.Fragment,{children:[b,(0,n.jsx)(L,{variant:t})]}):(0,n.jsx)(n.Fragment,{children:b})})},40766:(e,t,r)=>{"use strict";r.r(t),r.d(t,{PROJECT_FILE_WRITE_CONFIRM_TIMEOUT_MS:()=>o,PROJECT_FILE_WRITE_PENDING_EVENT:()=>n,PROJECT_FILE_WRITE_RESOLVED_EVENT:()=>i,getPendingProjectFileWriteRequests:()=>d,hasPendingProjectFileWriteConfirmation:()=>u,requestProjectFileWriteConfirmation:()=>s,resolveProjectFileWriteConfirmation:()=>l});let n="nanogpt:project-file-write-pending",i="nanogpt:project-file-write-resolved",o=6e5,a=new Map,s=e=>new Promise(t=>{let r=setTimeout(()=>{l(e.id,{approved:!1,timedOut:!0})},o);a.set(e.id,{request:e,resolve:t,timeoutHandle:r}),window.dispatchEvent(new CustomEvent(n,{detail:e}))}),l=(e,t)=>{let r=a.get(e);r&&(a.delete(e),clearTimeout(r.timeoutHandle),r.resolve(t),window.dispatchEvent(new CustomEvent(i,{detail:{requestId:e}})))},u=e=>a.has(e),d=()=>Array.from(a.values(),e=>e.request)},41695:(e,t,r)=>{"use strict";r.d(t,{s:()=>eN});var n=r(95155),i=r(85747),o=r(61915),a=r(31184),s=r(52181),l=r(46460),u=r(6584),d=r(48303),c=r(37206),m=r(36711),p=r(15181),h=r(71023),g=r(90136),f=r(7848),v=r(47965),x=r(38373),b=r(39436),w=r(94931),y=r(80929),S=r(42703),j=r(63088),k=r(6829),T=r(73321),C=r(12115),_=r(15243),P=r(62071),E=r(5257),D=r(1626),A=r(63781),M=r(76044),I=r(81951),R=r(46632),L=r(14314),F=r(47051);let z=e=>{var t;let r=(null==(t=e.isQueuedDraftCarryoverHandoffActive)?void 0:t.call(e))===!0,n=!0===e.isIncognito&&!0===e.isSavingIncognitoConversation;return{isComposerLocked:n||r,composerLockedTooltip:n?"Please wait while this incognito chat is saved.":"Please wait until the queued message starts sending."}};var N=r(84464),U=r(39525),B=r(52645),V=r(7498),W=r(49296),O=r(509),q=r(36968),G=r(91938),$=r(33643),Y=r(52132),H=r(33381),Q=r(93986),K=r(18398),J=r(62069),X=r(62770);let Z=(0,C.forwardRef)((e,t)=>{let{disabled:r,onClick:i,ariaLabel:o,variant:a,c:s,size:l,isBusy:u,isListening:d,isRecording:c,isSpeaking:m,loaderColor:p}=e,[h,g]=(0,C.useState)(!1);return(0,n.jsx)(V.ActionIcon,{ref:t,disabled:r,component:"button",type:"button",variant:a,c:s,size:l,radius:"xl","aria-label":o,onClick:i,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:(d||c)&&!u&&h?(0,n.jsx)($.A,{size:"60%",stroke:1.5}):u||d||c?(0,n.jsx)(J.Loader,{size:m?"xs":"sm",color:p,type:u?"dots":m?"bars":"dots"}):(0,n.jsx)(X.A,{size:"60%",stroke:1.5})})});Z.displayName="SttVoiceButton";var ee=r(72081),et=r(47367),er=r(21385),en=r(95362);let ei=e=>{let{opened:t,onClose:r,choice:i,onChoiceChange:o,remember:u,onRememberChange:d,onStart:c,options:m}=e;return(0,n.jsx)(ee.a,{opened:t,onClose:r,title:"Voice input",centered:!0,size:"md",children:(0,n.jsxs)(a.Stack,{gap:"sm",children:[(0,n.jsx)(l.Box,{pos:"relative",children:(0,n.jsx)(et.l,{label:"Speech recognition",value:i,onChange:e=>{e&&o(e)},data:m,comboboxProps:en.Y})}),(0,n.jsx)(er.S,{checked:u,onChange:e=>d(e.currentTarget.checked),label:"Set as default"}),(0,n.jsx)(s.Button,{onClick:c,children:"Start"})]})})};var eo=r(48788),ea=r(40737),es=r(87825),el=r(77558),eu=r(32989);let ed="input-sm",ec=e=>"boolean"==typeof e.hasVisibleComposerPrompt?e.hasVisibleComposerPrompt:(e.visibleComposerPrompt||"").length>0,em=e=>!!((null==e?void 0:e.privateMode)||(null==e?void 0:e.privateModeProvider)||(null==e?void 0:e.privateModeModel)),ep=(0,K.PA)(()=>{var e;let{isReady:t,conversation:i}=(0,v.useStores)(),{isComposerLocked:o}=z(i),a=(0,C.useRef)(0);return((0,C.useEffect)(()=>()=>{a.current+=1},[i,null==(e=i.properties)?void 0:e.slug,i.mode,i.visibleComposerPrompt,i.state.isPending,o]),!t||ec(i)||"image"!==i.mode||i.state.isPending)?null:(0,n.jsx)(B.Tooltip,{label:"Insert example prompt",withArrow:!0,children:(0,n.jsx)(V.ActionIcon,{variant:"subtle",size:"md",c:"yellow.7","aria-label":"Insert example prompt",disabled:o,onClick:async()=>{let e=++a.current;try{let{pickImageExamplePrompts:t}=await r.e(25124).then(r.bind(r,25124));if(a.current!==e||ec(i)||"image"!==i.mode||i.state.isPending||z(i).isComposerLocked)return;let n=t(1)[0];n&&i.setPrompt(n.prompt,{trackPendingDraft:!0})}catch(e){console.warn("[ExamplePrompt] Failed to load image examples",e)}},children:(0,n.jsx)(O.A,{stroke:.8})})})}),eh=(0,K.PA)(()=>{let{ui:e}=(0,v.useStores)();return!1!==e.online?null:(0,n.jsx)(B.Tooltip,{label:"You are offline. Reconnect to send messages.",withArrow:!0,children:(0,n.jsx)(W.Badge,{size:"sm",variant:"light",color:"red",leftSection:(0,n.jsx)(q.A,{size:14}),children:"Offline"})})}),eg=(0,K.PA)(()=>{let{conversation:e}=(0,v.useStores)(),t=e.visibleComposerScrapedUrls;return 0===t.length?null:(0,n.jsx)(B.Tooltip,{label:"".concat(t.length," URL").concat(t.length>
11?"s":""," will be scraped"),withArrow:!0,children:(0,n.jsx)(W.Badge,{size:"sm",variant:"light",color:"blue",leftSection:(0,n.jsx)(G.A,{size:14}),style:{cursor:"pointer"},onClick:()=>{e.clearScrapedUrls()},children:t.length})})}),ef=(0,K.PA)(e=>{var t;let{isScrapingUrls:r=!1,isSubmitting:i=!1}=e,{ui:o,conversation:a,clientHydrationIssues:s,libraryStore:l,memory:u}=(0,v.useStores)(),d=(0,Q.S)(),[c,m]=(0,C.useState)(!1);if(!(a.state.isPending&&a.mode===j.Dp.chat))return null;let p=!1===o.online,h=null==s||null==(t=s.memory)?void 0:t.kind,g=a.mode===j.Dp.chat&&!a.isIncognito&&(null==u?void 0:u.isHydrated)===!1&&"failed"!==h&&"timed_out"!==h,{isComposerLocked:f,composerLockedTooltip:x}=z(a),b=a.visibleComposerAttachmentIds,w=a.visibleComposerScrapedUrls,y=a.visibleComposerScrapedContent,S="string"==typeof a.draftPromptWhilePending&&(e=>"boolean"==typeof e.hasVisibleComposerText?e.hasVisibleComposerText:(e.visibleComposerPrompt||"").trim().length>0)(a)||b.length>0||w.length>0||y.length>0,k=em(a.pendingMessage),T=async()=>{if(c)return;let e=a.pendingMessage,t=null==e?void 0:e.id,r=null==e?void 0:e.timestamp;if(em(e)){m(!0);try{if(!await d({title:"Stop Private Mode request?",message:"Stopping the response does not guarantee that the private provider stops processing it. Weâll settle the charge from verified usage when available; if usage cannot be verified, the reserved amount may remain charged.",confirmLabel:"Stop anyway",cancelLabel:"Keep generating",danger:!0,appearance:"conversation-context"}))return;let n=a.pendingMessage,i=null!=t&&(null==n?void 0:n.id)!==void 0&&(null==n?void 0:n.id)!==null&&String(n.id)===String(t),o=null!=r&&(null==n?void 0:n.timestamp)!==void 0&&(null==n?void 0:n.timestamp)!==null&&String(n.timestamp)===String(r),s=i||o||null==t&&null==r&&n===e;if(!0!==a.state.isPending||!s)return}finally{m(!1)}}try{a.stopStream()}catch(e){}};if(!S)return(0,n.jsx)(B.Tooltip,{openDelay:500,label:k?"Stopping Private Mode may not stop provider processing, and the reserved amount may remain charged.":"Cancel/abort the current request. This may incur a partial charge for what has been generated so far.",withArrow:!0,children:(0,n.jsx)(V.ActionIcon,{component:"button",type:"button",variant:"filled",size:ed,radius:"xl","aria-label":"Cancel current request",disabled:c,onClick:()=>{T()},children:(0,n.jsx)($.A,{size:"70%",stroke:1.5})})});let _=new Set(b.map(e=>String(e))),P=_.size>0&&Array.isArray(l.pendingFiles)&&l.pendingFiles.some(e=>(null==e?void 0:e.libraryItemId)!==void 0&&(null==e?void 0:e.libraryItemId)!==null&&_.has(String(e.libraryItemId)));return(0,n.jsx)(B.Tooltip,{openDelay:1e3,label:f?x:p?"You are offline. Sending is disabled.":g?"Please wait: saved memory is still loading.":"Send message",withArrow:!0,children:(0,n.jsx)(V.ActionIcon,{loading:r||P||i,disabled:f||p||g||r||P||i,component:"button",type:"submit",variant:"filled",size:ed,radius:"xl","aria-label":"Send message",children:(0,n.jsx)(Y.A,{size:"70%",stroke:1.5})})})}),ev=(0,K.PA)(e=>{let{isScrapingUrls:t=!1,isSubmitting:r=!1}=e,{conversation:i}=(0,v.useStores)();return i.state.isPending?null:(0,n.jsx)(ex,{isScrapingUrls:t,isSubmitting:r})}),ex=(0,K.PA)(e=>{var t;let{isScrapingUrls:r=!1,isSubmitting:i=!1}=e,{ui:o,conversation:a,clientHydrationIssues:s,libraryStore:l,memory:u}=(0,v.useStores)(),c=!1===o.online,m=null==s||null==(t=s.memory)?void 0:t.kind,p=a.mode===j.Dp.chat&&!a.isIncognito&&(null==u?void 0:u.isHydrated)===!1&&"failed"!==m&&"timed_out"!==m,{isComposerLocked:h,composerLockedTooltip:g}=z(a),f=a.mode===j.Dp.audio,x=f&&"stt"===a.getSetting("audioMode","tts"),w=a.mode===j.Dp.image&&(0,b.ZQ)(a.model.image,a.getSetting("customCivitaiAir")),y=(e=>{let{conversation:t,ui:r,libraryStore:n,isScrapingUrls:i,isSubmitting:o}=e,[a,s]=(0,C.useState)(!1),[l,u]=(0,C.useState)("builtin"),[c,m]=(0,C.useState)(!0),[p,h]=(0,C.useState)(!1),[g,f]=(0,C.useState)(!1),[v,x]=(0,C.useState)(!1),[b,w]=(0,C.useState)(null),[y,S]=(0,C.useState)(!1),[j,k]=(0,C.useState)(!1),T=(0,C.useRef)(null),_=(0,C.useRef)(null),P=(0,C.useRef)([]),E=(0,C.useRef)(null),D=(0,C.useRef)(""),A=(0,C.useRef)(""),M=(0,C.useRef)(null),I=(0,C.useRef)(null),R=(0,C.useRef)(null),L=(0,C.useRef)(null),F=(0,C.useRef)(!1),z=(0,C.useRef)(null),[N,U]=(0,C.useState)(!1),B=(0,C.useRef)(null),V=(0,C.useRef)(async()=>{}),W="boolean"==typeof t.hasVisibleComposerText?t.hasVisibleComposerText:(t.visibleComposerPrompt||"").trim().length>0,O=t.visibleComposerAttachmentIds,q=t.visibleComposerScrapedUrls,G=(()=>{try{let e=O||[];if(!e.length)return!1;let t=new Set(e);return n.pendingFiles.some(e=>null!=e.libraryItemId&&t.has(e.libraryItemId))}catch(e){return!1}})(),[$,Y]=(0,C.useState)(!1);(0,C.useEffect)(()=>{let e=window;Y("function"==typeof e.SpeechRecognition||"function"==typeof e.webkitSpeechRecognition)},[]);let H=(0,C.useMemo)(()=>!!r.voiceInputEnabled&&!t.state.isPending&&!i&&!G&&!o&&!(((null==O?void 0:O.length)||0)>0)&&!(((null==q?void 0:q.length)||0)>0)&&!W,[r.voiceInputEnabled,t.state.isPending,i,G,o,null==O?void 0:O.length,null==q?void 0:q.length,W]),Q=(0,C.useMemo)(()=>!!r.voiceInputEnabled&&!!j&&!t.state.isPending&&!i&&!G&&!o&&!(((null==O?void 0:O.length)||0)>0)&&!(((null==q?void 0:q.length)||0)>0)&&W,[r.voiceInputEnabled,j,t.state.isPending,i,G,o,null==O?void 0:O.length,null==q?void 0:q.length,W]),K=()=>{B.current&&(clearTimeout(B.current),B.current=null)},J=(0,C.useMemo)(()=>{let e=b||r.voiceInputDefault||"";if("builtin"===e)return"Built-in Speech Recognition";if("whisper-large-v3"===e)return"Whisper Large V3";if("wizper"===e)return"Wizper";if("elevenlabs"===e)return"ElevenLabs Scribe V1";if("elevenlabs-scribe-v2"===e)return"ElevenLabs Scribe V2";if("xai/speech-to-text/v1"===e)return"Grok Speech-to-Text";if("nvidia/nemotron-asr-multilingual/asr"===e)return"NVIDIA Nemotron ASR";if("string"==typeof e&&e.startsWith("gpt-4o-mini-transcribe")){var t;return(null==(t=es.sttModelInfo[e])?void 0:t.displayName)||"GPT-4o Mini Transcribe"}return""},[b,r.voiceInputDefault]),X=(0,C.useMemo)(()=>J?"Using ".concat(J):"",[J]),Z=(0,C.useMemo)(()=>p?X?"Transcribing... (".concat(X,")"):"Transcribing...":v?X?"Stop dictation (".concat(X,")"):"Stop dictation":g?X?"Stop recording (".concat(X,")"):"Stop recording and transcribe":X||"Start voice input",[p,v,g,X]),ee=(0,C.useMemo)(()=>p?X?"Transcribing... (".concat(X,")"):"Transcribing...":v?X?"Stop dictation (".concat(X,")"):"Stop dictation":g?X?"Stop recording (".concat(X,")"):"Stop recording and transcribe":X||"Voice input",[p,v,g,X]),et=e=>{let t=es.sttModelInfo[e],r=t?(0,el.oZ)(t,{fallbackProfitPercentage:.1}):0;return(null==t?void 0:t.roundBillingDurationToMinute)?"$"+r.toFixed(6)+"/min, rounded up":"$"+(r/60).toFixed(5)+"/s"},er=(0,C.useMemo)(()=>{var e,t,r,n,i;return[{value:"builtin",label:"Built-in Speech Recognition (Free)"},{value:"gpt-4o-mini-transcribe",label:(null==(e=es.sttModelInfo["gpt-4o-mini-transcribe"])?void 0:e.displayName)+" ("+et("gpt-4o-mini-transcribe")+")"},{value:"gpt-4o-mini-transcribe-2025-03-20",label:(null==(t=es.sttModelInfo["gpt-4o-mini-transcribe-2025-03-20"])?void 0:t.displayName)+" ("+et("gpt-4o-mini-transcribe-2025-03-20")+")"},{value:"gpt-4o-mini-transcribe-2025-12-15",label:(null==(r=es.sttModelInfo["gpt-4o-mini-transcribe-2025-12-15"])?void 0:r.displayName)+" ("+et("gpt-4o-mini-transcribe-2025-12-15")+")"},{value:"whisper-large-v3",label:"Whisper Large V3 ("+et("Whisper-Large-V3")+")"},{value:"wizper",label:"Wizper (Optimized Whisper V3) ("+et("Wizper")+")"},{value:"elevenlabs",label:"ElevenLabs Scribe V1 ("+et("Elevenlabs-STT")+")"},{value:"elevenlabs-scribe-v2",label:"ElevenLabs Scribe V2 ("+et("Elevenlabs-Scribe-V2")+")"},{value:"xai/speech-to-text/v1",label:(null==(n=es.sttModelInfo["xai/speech-to-text/v1"])?void 0:n.displayName)+" ("+et("xai/speech-to-text/v1")+")"},{value:"nvidia/nemotron-asr-multilingual/asr",label:(null==(i=es.sttModelInfo["nvidia/nemotron-asr-multilingual/asr"])?void 0:i.displayName)+" ("+et("nvidia/nemotron-asr-multilingual/asr")+")"}]},[]),en=async()=>{var e,t,r;try{null!=L.current&&(cancelAnimationFrame(L.current),L.current=null)}catch(e){}try{null==(e=R.current)||e.disconnect()}catch(e){}try{null==(t=I.current)||t.disconnect()}catch(e){}R.current=null,I.current=null;try{await (null==(r=M.current)?void 0:r.close())}catch(e){}M.current=null,S(!1)},ei=async e=>{await en();try{let t=new(window.AudioContext||window.webkitAudioContext);M.current=t;let r=t.createAnalyser();r.fftSize=1024,r.smoothingTimeConstant=.8,I.current=r;let n=t.createMediaStreamSource(e);
1R.current=n,n.connect(r);let i=new Uint8Array(r.fftSize),o=0,a=()=>{try{r.getByteTimeDomainData(i);let e=0;for(let t=0;t<i.length;t++){let r=(i[t]-128)/128;e+=r*r}let t=Math.sqrt(e/i.length),n=Date.now();t>.03&&(o=n);let a=n-o<250;S(a)}catch(e){}L.current=requestAnimationFrame(a)};L.current=requestAnimationFrame(a)}catch(e){await en()}},ed=async e=>{try{var r,n,i;let o,a;if(h(!0),!((null==(r=t.rootStore.team)?void 0:r.isUsingTeamBalance)||t.rootStore.session.usd_balance>1e-5||t.rootStore.session.nano_balance>1e-5))return void t.rootStore.ui.setShowDepositModal(!0);d.$e.show({id:"voice-transcription-progress",title:"Transcribing",message:"Transcribing audio using ".concat((e=>{if("builtin"===e)return"Built-in Speech Recognition";if("whisper-large-v3"===e)return"Whisper Large V3";if("wizper"===e)return"Wizper";if("elevenlabs"===e)return"ElevenLabs Scribe V1";if("elevenlabs-scribe-v2"===e)return"ElevenLabs Scribe V2";if("xai/speech-to-text/v1"===e)return"Grok Speech-to-Text";if("nvidia/nemotron-asr-multilingual/asr"===e)return"NVIDIA Nemotron ASR";if("string"==typeof e&&e.startsWith("gpt-4o-mini-transcribe")){var t;return(null==(t=es.sttModelInfo[e])?void 0:t.displayName)||"GPT-4o Mini Transcribe"}return""})(e),"..."),color:"blue",loading:!0,autoClose:!1});let s=new Blob(P.current,{type:(null==(n=T.current)?void 0:n.mimeType)||"audio/webm"});if(/audio\/webm/.test(s.type))o=await (0,eo._c)(s,"recording.wav");else if(/audio\/(wav|wave|x-wav|mpeg|mp3|ogg|mp4|x-m4a|m4a|aac)/.test(s.type)){let e=s.type.includes("ogg")?"ogg":s.type.includes("wav")?"wav":s.type.includes("mpeg")||s.type.includes("mp3")?"mp3":s.type.includes("aac")?"aac":s.type.includes("mp4")||s.type.includes("m4a")?"m4a":"wav";o=new File([s],"recording.".concat(e),{type:s.type})}else o=await (0,eo._c)(s,"recording.wav");if(o.size>3145728){let r=await (0,ea.M)(o,t.rootStore.session),n=new FormData;n.append("audioUrl",r.url),n.append("model",e),a=await fetch("/api/transcribe",{method:"POST",body:n,credentials:"include"})}else{let t=new FormData;t.append("audio",o),t.append("model",e),a=await fetch("/api/transcribe",{method:"POST",body:t,credentials:"include"})}if(!a.ok){let e="Transcription failed";try{let t=await a.json().catch(()=>null);if(t){let r="string"==typeof t.error?t.error:"string"==typeof t.message?t.message:e,n="string"==typeof t.details?t.details:Array.isArray(t.details)?t.details.filter(Boolean).join("; "):"";e=n?"".concat(r).concat(r.endsWith(".")?" ":": ").concat(n):r}}catch(e){}throw Error(e)}let l=await a.json();if((null==l?void 0:l.status)==="pending"&&(null==l?void 0:l.runId)){let e=(0,eu.RA)({baseDelayMs:2e3,maxDelayMs:12e3,backoffFactor:1.5,timeoutMs:18e4});for(;;){let r=await (0,eu.h9)();if(e.hasTimedOut()&&0===r)break;let n=await fetch("/api/transcribe/status",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({runId:l.runId,model:l.model,cost:l.cost,paymentSource:l.paymentSource,isApiRequest:l.isApiRequest,fileName:l.fileName,fileSize:l.fileSize,chargedDuration:l.chargedDuration,diarize:l.diarize})}),o=n.headers.get("x-poll-after"),a=await n.json().catch(()=>({}));if((null==a?void 0:a.status)==="completed"&&"string"==typeof(null==a?void 0:a.transcription))return void t.setPrompt(a.transcription,{trackPendingDraft:!0});let s=null==a||null==(i=a.data)?void 0:i.status;if("FAILED"===s||"ERROR"===s||"CRASHED"===s)throw Error("Transcription failed");if(!await e.wait(o)&&!(0,eu.L_)())break}throw Error("Transcription timed out")}let u="string"==typeof(null==l?void 0:l.transcription)?l.transcription:"";if(!u.trim()){if(!(A.current||"").trim())return;throw Error("Empty transcription result")}let c=A.current||"",m=c.trim()?"".concat(c.trim()," ").concat(u.trim()):u.trim();t.setPrompt(m,{trackPendingDraft:!0})}finally{h(!1),P.current=[];try{d.$e.hide("voice-transcription-progress")}catch(e){}}},ec=async()=>{if(N){d.$e.show({title:"Built-in speech recognition unavailable",message:"Please choose a paid speech-to-text model instead.",color:"orange"}),F.current||(F.current=!0,u("gpt-4o-mini-transcribe"),s(!0));return}if(!$){d.$e.show({title:"Built-in speech recognition not available",message:"Your browser does not support built-in speech recognition. Please choose a paid model instead.",color:"orange"}),F.current||(F.current=!0,u("gpt-4o-mini-transcribe"),s(!0));return}try{w("builtin");let e=(t.prompt||"").trim();D.current=e,e||k(!0);let r=window,n=new(r.SpeechRecognition||r.webkitSpeechRecognition);n.continuous=!1,n.interimResults=!0,n.maxAlternatives=1,E.current=n,x(!0),n.onresult=e=>{try{let n="",i="";for(let t=e.resultIndex;t<e.results.length;t++){var r;let o=e.results[t],a=(null==o||null==(r=o[0])?void 0:r.transcript)||"";o.isFinal?i+=a:n+=a}let o=(i||n||"").trim();if(o){let e=D.current||"",r=e.trim()?"".concat(e.trim()," ").concat(o):o;t.setPrompt(r,{trackPendingDraft:!0})}}catch(e){}},n.onerror=e=>{let t="string"==typeof(null==e?void 0:e.error)?e.error:"unknown";if("aborted"!==t&&"no-speech"!==t){if("network"===t){try{var r,n;null==(n=E.current)||null==(r=n.stop)||r.call(n)}catch(e){}x(!1),E.current=null,w(null),S(!1),U(!0),d.$e.show({title:"Built-in speech recognition unavailable",message:"Network error. Please choose a paid speech-to-text model instead.",color:"orange"}),F.current||(F.current=!0,u("gpt-4o-mini-transcribe"),s(!0));return}d.$e.show({title:"Voice input error",message:t,color:"red"})}},n.onspeechstart=()=>{S(!0)},n.onspeechend=()=>{S(!1)},n.onend=()=>{x(!1),E.current=null,w(null),S(!1)},n.start()}catch(e){x(!1),E.current=null,w(null),S(!1),d.$e.show({title:"Voice input error",message:(null==e?void 0:e.message)||"Unable to start dictation",color:"red"})}},em=async()=>{h(!0);try{if(!navigator.mediaDevices)throw Error("Recording not supported in this browser");let e=(t.prompt||"").trim();A.current=e,e||k(!0);let r=await navigator.mediaDevices.getUserMedia({audio:!0});_.current=r,await ei(r);let n="";"undefined"!=typeof MediaRecorder&&"function"==typeof MediaRecorder.isTypeSupp
1orted&&(MediaRecorder.isTypeSupported("audio/ogg;codecs=opus")?n="audio/ogg;codecs=opus":MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?n="audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/webm")&&(n="audio/webm"));let i=n?{mimeType:n}:void 0,o=new MediaRecorder(r,i);T.current=o,P.current=[],o.ondataavailable=e=>{e.data&&e.data.size>0&&P.current.push(e.data)},o.onstop=()=>{f(!1);try{var e;null==(e=_.current)||e.getTracks().forEach(e=>e.stop())}catch(e){}_.current=null,en()},o.start(),f(!0),h(!1)}catch(e){en(),h(!1),d.$e.show({title:"Recording error",message:(null==e?void 0:e.message)||"Unable to access microphone",color:"red"})}},ep=async e=>{try{if(!T.current)return;let t=T.current;h(!0),t.onstop=async()=>{f(!1);try{var t;null==(t=_.current)||t.getTracks().forEach(e=>e.stop())}catch(e){}_.current=null,await en();try{await ed(e)}catch(e){d.$e.show({title:"Transcription error",message:(null==e?void 0:e.message)||"Failed to transcribe audio",color:"red"})}finally{w(null),S(!1)}},t.stop()}catch(e){d.$e.show({title:"Recording error",message:(null==e?void 0:e.message)||"Failed to stop recording",color:"red"}),f(!1),h(!1),w(null),S(!1),en();try{d.$e.hide("voice-transcription-progress")}catch(e){}}};(0,C.useEffect)(()=>{V.current=ep});let eh=async e=>{let t=e;if((0,es.isVoiceCloneModel)(t)&&(d.$e.show({title:"Voice clone not supported here",message:"Voice cloning is available on the Media page. Falling back to Whisper Large V3 for transcription.",color:"orange"}),t="whisper-large-v3"),w(t),"builtin"===t)return void(v?(()=>{try{var e,t;null==(t=E.current)||null==(e=t.stop)||e.call(t)}catch(e){}x(!1),E.current=null,w(null),S(!1)})():await ec());let r=t;g?await ep(r):await em()};return(0,C.useEffect)(()=>!g||p||y?void K():B.current?void 0:(B.current=setTimeout(()=>{B.current=null;try{if(!T.current||"recording"!==T.current.state||p||y||!g)return;let e=b||r.voiceInputDefault||z.current;if(!e||"builtin"===e)return;V.current(e)}catch(e){}},2e3),()=>{B.current&&(clearTimeout(B.current),B.current=null)}),[g,p,y,b,r.voiceInputDefault]),(0,C.useEffect)(()=>{W||p||v||g||(k(!1),D.current="",A.current="")},[W,p,v,g]),(0,C.useEffect)(()=>()=>{try{(e=>{var t,r;null==(r=e.current)||null==(t=r.stop)||t.call(r)})(E)}catch(e){}try{K()}catch(e){}try{(e=>{var t;(null==(t=e.current)?void 0:t.state)==="recording"&&e.current.stop()})(T)}catch(e){}try{(e=>{var t;null==(t=e.current)||t.getTracks().forEach(e=>e.stop())})(_)}catch(e){}try{en()}catch(e){}},[]),{hasPendingAttachments:G,voicePickerOpen:a,voicePickerChoice:l,voicePickerRemember:c,setVoicePickerOpen:s,setVoicePickerChoice:u,setVoicePickerRemember:m,onVoicePickerStart:()=>{z.current=l,c&&r.setVoiceInputDefault(l),s(!1),eh(l)},sttPickerOptions:er,isVoiceBusy:p,isVoiceRecording:g,isVoiceListening:v,isVoiceSpeaking:y,shouldShowVoiceButton:H,shouldShowContinueVoiceButton:Q,usingVoiceLabel:X,startVoiceTooltipLabel:Z,continueVoiceTooltipLabel:ee,onVoiceButtonClick:()=>{if(!p){if(!r.voiceInputDefault)return z.current?void eh(z.current):(u("builtin"),m(!0),void s(!0));eh(r.voiceInputDefault)}}}})({conversation:a,ui:o,libraryStore:l,isScrapingUrls:r,isSubmitting:i}),S=y.hasPendingAttachments,k=h||!0===a.state.isPreparingSubmit||c||p||r||S||i||y.isVoiceBusy,T=(a.mode===j.Dp.chat||a.mode===j.Dp.translate)&&!1===a.isTextModelReady,_=T||k||y.isVoiceListening||y.isVoiceRecording||w,P=r||S||i||y.isVoiceBusy||y.isVoiceListening||y.isVoiceRecording;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ei,{opened:y.voicePickerOpen,onClose:()=>y.setVoicePickerOpen(!1),choice:y.voicePickerChoice,onChoiceChange:y.setVoicePickerChoice,remember:y.voicePickerRemember,onRememberChange:y.setVoicePickerRemember,onStart:y.onVoicePickerStart,options:y.sttPickerOptions}),y.shouldShowVoiceButton&&!x?(0,n.jsx)(B.Tooltip,{openDelay:500,label:h?g:c?"You are offline. Voice input is unavailable.":y.startVoiceTooltipLabel,withArrow:!0,children:(0,n.jsx)(Z,{disabled:k,ariaLabel:"Voice input",variant:"filled",size:ed,isBusy:y.isVoiceBusy,isListening:y.isVoiceListening,isRecording:y.isVoiceRecording,isSpeaking:y.isVoiceSpeaking,loaderColor:"white",onClick:e=>{e.preventDefault(),y.onVoiceButtonClick()}})}):(0,n.jsxs)(n.Fragment,{children:[!x&&y.shouldShowContinueVoiceButton&&(0,n.jsx)(B.Tooltip,{openDelay:500,label:h?g:y.continueVoiceTooltipLabel,withArrow:!0,children:(0,n.jsx)(Z,{disabled:k,ariaLabel:"Voice input",variant:"subtle",c:"dimmed",size:ed,isBusy:y.isVoiceBusy,isListening:y.isVoiceListening,isRecording:y.isVoiceRecording,isSpeaking:y.isVoiceSpeaking,loaderColor:"var(--mantine-color-dimmed)",onClick:e=>{e.preventDefault(),y.onVoiceButtonClick()}})}),(0,n.jsx)(B.Tooltip,{openDelay:1e3,label:h?g:w?"Choose a CivitAI model before generating.":c?"You are offline. Sending is disabled.":T?"Please wait: account and model settings are still loading.":p?"Please wait: saved memory is still loading.":S?"Please wait: processing attached files":f?x?o.enterSendsMessage?"Transcribe audio (Enter)":"Transcribe audio":o.enterSendsMessage?"Generate audio (Enter)":"Generate audio":o.enterSendsMessage?"Send message (Enter)":"Send message",withArrow:!0,children:(0,n.jsx)(V.ActionIcon,{loading:P,disabled:_,component:"button",type:"submit",variant:"filled",size:ed,radius:"xl","aria-description":T?"Account and model settings are still loading.":void 0,"aria-label":f?x?"Transcribe audio":"Generate audio":"Send message",children:f&&!x?(0,n.jsx)(H.A,{size:"70%",stroke:1.5}):(0,n.jsx)(Y.A,{size:"70%",stroke:1.5})})})]})]})}),eb=(0,K.PA)(e=>{let{isScrapingUrls:t=!1,isSubmitting:r=!1}=e,{ui:i}=(0,v.useStores)();return(0,n.jsxs)(l.Box,{style:{display:"flex",alignItems:"center",gap:i.isDesktop?"8px":"4px",height:"100%"},children:[(0,n.jsx)(ep,{}),(0,n.jsx)(eh,{}),(0,n.jsx)(eg,{}),(0,n.jsx)(ef,{isScrapingUrls:t,isSubmitting:r}),(0,n.jsx)(ev,{isScrapingUrls:t,isSubmitting:r})]})});r(5700);var ew=r(51193),ey=r.n(ew);let eS=e=>e.submitPreview&&!0===e.state.isPreparingSubmit?"":e.visibleComposerPrompt,ej={position:"absolute",top:-6,left:0,right:56,height:12,cursor:"ns-resize",zIndex:11},ek={position:"absolute",top:2,bottom:2,left:-6,width:8,cursor:"ew-resize",zIndex:11},eT={position:"absolute",top:2,bottom:2,right:-6,width:8,cursor:"ew-resize",zIndex:20},eC=(0,k.PA)(e=>{let{isReady:t,isScrapingUrls:r,handlePaste:i,onSubmit:o,conversation:a,ui:s,isSubmitting:u,messageHistoryIndex:d,setMessageHistoryIndex:c}=e,m=!0===s.isDesktop||void 0===s.isDesktop?"block":"none",p=(0,N.VO)(s.isDesktop),h=(0,C.useRef)(null),g=(0,C.useRef)(!1),f=(0,C.useRef)(0),v=(0,C.useRef)(0),b=(0,C.useRef)(null),w=(0,C.useRef)(0),y=(0,C.useRef)(0),S=(0,C.useMemo)(()=>Math.max(200,Math.min(800,Math.floor(.75*window.innerHeight))),[]),k=(0,C.useCallback)(e=>{if(g.current){let t=f.current-e.clientY,r=Math.max(40,Math.min(S,v.current+t));s.setInputHeight(r)}if(b.current&&h.current){let t=b.current,r=e.clientX-w.current,n=h.current.closest("[data-resize-boundary]")||h.current.parentElement,i=null==n?void 0:n.getBoundingClientRect(),o=Math.max(320,Math.min(i?Math.floor(Math.max(320,i.width-56)):Math.floor(Math.max(320,window.innerWidth-56)),y.current+("right"===t?r:-r)));s.setInputWidth(o)}},[S,s]),T=(0,C.useCallback)(()=>{g.current=!1,b.current=null,window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",T)},[k]),_=(0,C.useCallback)(e=>{var t;e.preventDefault(),g.current=!0,f.current=e.clientY;let r=null==(t=a.inputRef)?void 0:t.current,n=r?r.offsetHeight:s.inputHeight;s.setInputHeight(n),v.current=n,s.lockInputHeight(),window.addEventListener("mousemove",k),window.addEventListener("mouseup",T)},[s,a.inputRef,k,T]);(0,C.useEffect)(()=>()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",T)},[k,T]),(0,C.useEffect)(()=>
1{if(!0!==a.initialized)return;let e=!1,t=()=>{var t,r,n;if(e)return!0;if("undefined"!=typeof document&&document.querySelector("[data-shell-composer-input]")||(0,R.Sg)())return!1;let i=window.location.pathname.match(/^\/(?:chat|conversation)(?:\/([^/]+))?\/?$/);if(i&&a.lastInitializedSlug){let e;try{e=decodeURIComponent(i[1]||"new")}catch(e){return!1}if(a.lastInitializedSlug!==e||a.initializingSlug)return!1}if((null==(t=a.state)?void 0:t.isPending)||(null==(r=a.state)?void 0:r.isPreparingSubmit)||a.isStreaming)return!1;let o=(0,R.$H)();if(o.value){let e="string"==typeof a.prompt?a.prompt:"";a.setPrompt(o.value+e,{trackPendingDraft:!0}),null==(n=a.flushDraftPersistence)||n.call(a)}return(0,R.wY)(),(0,L.gZ)(),o.focused&&a.requestPromptInputFocus(),!0};if(t())return;let r=window.setInterval(()=>{t()&&window.clearInterval(r)},120);return()=>{e=!0,window.clearInterval(r)}},[a,a.initialized]),(0,C.useEffect)(()=>{if(!a.promptInputFocusRequestId)return;let e=()=>{var e;let t=null==(e=a.inputRef)?void 0:e.current;t&&!t.disabled&&t.focus()};e();let t=window.requestAnimationFrame(e),r=window.setTimeout(e,120);return()=>{window.cancelAnimationFrame(t),window.clearTimeout(r)}},[a,a.inputRef,a.promptInputFocusRequestId]),(0,C.useEffect)(()=>{let e=e=>{var t;if(!0!==e.persisted)return;let r=null==(t=a.inputRef)?void 0:t.current;if(!r)return;let n=eS(a);if(r.value!==n){r.value=n;try{r.setSelectionRange(n.length,n.length)}catch(e){}}};return window.addEventListener("pageshow",e),()=>window.removeEventListener("pageshow",e)},[a]),(0,C.useEffect)(()=>{if(!s.isDesktop){let e=e=>{let t=(0,M.PB)(e);t&&"conversation-input"===t.id&&setTimeout(()=>{var e;(null==(e=a.inputRef)?void 0:e.current)&&(a.inputRef.current.focus(),(0,M.NU)(a.inputRef,"scrollIntoView",{behavior:"smooth",block:"center"}))},50)};return document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("touchstart",e)}}},[s.isDesktop,a.inputRef]);let B=(0,C.useCallback)(()=>{var e;let t=null==(e=h.current)?void 0:e.offsetWidth;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:"number"==typeof s.inputWidth&&Number.isFinite(s.inputWidth)?s.inputWidth:D.a2},[s]),V=(0,C.useCallback)(()=>{var e;return(0,A.Sn)(null==(e=window.location)?void 0:e.pathname)?B():s.inputWidth},[B,s.inputWidth]),W=(0,C.useCallback)(e=>{e.preventDefault(),b.current="left",w.current=e.clientX,y.current=V(),window.addEventListener("mousemove",k),window.addEventListener("mouseup",T)},[V,k,T]),O=a.mode===j.Dp.audio&&"stt"===a.getSetting("audioMode","tts"),q=!0;if(O){var G,$;let e=(0,E.KJ)(null==(G=a.getAudioSttSetting)?void 0:G.call(a,"sttModel",a.getSetting("sttModel",E.eh))),t=(0,E.KJ)(null==($=a.getAudioSttSetting)?void 0:$.call(a,"mediaSttModel",e)),r=(0,E.j0)(t)?e:t;q=(0,E.NE)(r)}let Y=(0,C.useCallback)(e=>{e.preventDefault(),b.current="right",w.current=e.clientX,y.current=V(),window.addEventListener("mousemove",k),window.addEventListener("mouseup",T)},[V,k,T]),H=eS(a),Q=(0,C.useMemo)(()=>"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("field-sizing: content"),[]),[K,J]=(0,C.useState)(null);(0,C.useEffect)(()=>{if(!Q)return;let e=window.matchMedia(F.Sb),t=()=>J(!e.matches),r=()=>{var e;let r=null==(e=a.inputRef)?void 0:e.current;if(r&&document.activeElement===r)return void r.addEventListener("blur",t,{once:!0});t()};return r(),e.addEventListener("change",r),()=>e.removeEventListener("change",r)},[a.inputRef,Q]);let X=Q&&!0===K,Z=H||a.mode!==j.Dp.chat&&a.mode!==j.Dp.translate&&a.mode!==j.Dp.image&&a.mode!==j.Dp.video&&a.mode!==j.Dp.audio?{}:{"--conversation-placeholder-line-height":!1===s.isDesktop?"48px":"number"==typeof s.inputHeight?"".concat(s.inputHeight,"px"):s.inputHeight},{isComposerLocked:ee,composerLockedTooltip:et}=z(a);return(0,n.jsxs)(l.Box,{className:(0,I.cn)(ey().inputShell,ey().inputShellReserved,X&&ey().cssAutosizeShell),style:s.isDesktop?{position:"relative",display:"flex",flexDirection:"column",flex:"0 0 auto",width:s.inputWidth,maxWidth:"100%"}:{position:"relative",display:"flex",flexDirection:"column",flex:"1 1 auto",width:"100%"},ref:h,children:[(0,n.jsx)(l.Box,{"aria-hidden":"true",title:s.inputHeightLocked?"Double-click to reset input height":"Drag to resize input",style:{...ej,display:m},onMouseDown:_,onDoubleClick:()=>s.resetInputHeight()}),(0,n.jsx)(l.Box,{"aria-hidden":"true",title:"Drag to resize input width",style:{...ek,display:m},onMouseDown:W,onDoubleClick:()=>s.resetInputWidth()}),(0,n.jsx)(l.Box,{"aria-hidden":"true",title:"Drag to resize input width",style:{...eT,display:m},onMouseDown:Y,onDoubleClick:()=>s.resetInputWidth()}),(0,n.jsxs)(l.Box,{className:ey().inputMainRow,children:[(0,n.jsx)(P.T,{"data-conversation-composer-input":!0,id:"conversation-input",autoComplete:"off",autoCorrect:"on",autoCapitalize:"sentences",spell
1Check:!0,onPaste:e=>{if(!0===a.state.isPreparingSubmit)return void e.preventDefault();i(e)},pb:void 0,readOnly:!0===a.state.isPreparingSubmit,disabled:r||ee||!s.online||O&&!q||"image"===a.mode&&(0,x.t7)(a.model.image),ref:a.inputRef,onKeyDownCapture:e=>{var t,r,n,i,l;if(!e.nativeEvent.isComposing&&229!==e.keyCode){if(ee||!0===a.state.isPreparingSubmit){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.stopPropagation());return}if("Enter"===e.key&&!e.shiftKey&&p&&!s.enterSendsMessage){e.preventDefault(),e.stopPropagation();let i=null==(t=a.inputRef)?void 0:t.current,o=null!=(r=null==i?void 0:i.selectionStart)?r:H.length,s=null!=(n=null==i?void 0:i.selectionEnd)?n:H.length,l=H.slice(0,o)+"\n"+H.slice(s);a.setPrompt(l,{trackPendingDraft:!0}),requestAnimationFrame(()=>{try{if(!i)return;let e=o+1;i.selectionStart=e,i.selectionEnd=e}catch(e){}});return}if("Enter"===e.key&&!e.shiftKey&&p&&s.enterSendsMessage)if(a.state.isPending)a.mode===j.Dp.chat&&(e.preventDefault(),e.stopPropagation(),o(e));else{if(u){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),e.stopPropagation(),o(e);return}if("ArrowUp"===e.key&&""===H){let e=null==(i=a.messages)?void 0:i.filter(e=>"user"===e.role);if(e&&e.length>0){let t=void 0===d?e.length:d,r=t-1<0?e.length:t-1;a.setPrompt((null==(l=e[r])?void 0:l.prompt)||"",{trackPendingDraft:!0}),c(r)}}}},style:{flex:"1 1 auto",minWidth:0},...a.getInputProps(),autosize:!X&&(!s.inputHeightLocked||!s.isDesktop),rows:1,minRows:1,maxRows:!0===s.isDesktop||void 0===s.isDesktop?s.inputHeightLocked?void 0:8:4,size:"lg",radius:"xl",autoFocus:s.isDesktop,classNames:{input:X?(0,I.cn)(ey().placeholderSmall,ey().cssAutosizeInput):ey().placeholderSmall},styles:{input:{height:(!0===s.isDesktop||void 0===s.isDesktop)&&s.inputHeightLocked?s.inputHeight:void 0,overflowY:"auto",resize:"none",...Z}},placeholder:t?ee?et:"image"===a.mode?(0,x.t7)(a.model.image)?"No text input needed":"Describe what to create":"audio"===a.mode?"stt"===a.getSetting("audioMode","tts")?"Record or upload file":"Enter text to generate audio":"chat"===a.mode?"Ask anything":"translate"===a.mode?"Enter text to translate":s.isDesktop?"Describe what to create":"":void 0,value:H}),(0,n.jsx)(l.Box,{className:ey().inputRightSection,children:(0,n.jsx)(eb,{isScrapingUrls:r,isSubmitting:!!u})})]}),(0,n.jsx)(l.Box,{className:"".concat(ey().inputMetaRow," ").concat(ey().inputMetaRowReserved),children:(0,n.jsx)(U.s,{variant:"inline",showQueue:!1})})]})});var e_=r(76728);let eP=(0,c.default)(()=>r.e(75983).then(r.bind(r,75983)).then(e=>e.URLScrapingModal),{loadableGenerated:{webpack:()=>[75983]},ssr:!1,loading:()=>null}),eE=(0,c.default)(()=>r.e(98745).then(r.bind(r,98745)).then(e=>e.URLToolEnableModal),{loadableGenerated:{webpack:()=>[98745]},ssr:!1,loading:()=>null}),eD=(0,c.default)(()=>r.e(91706).then(r.bind(r,91706)).then(e=>e.YouTubeTranscriptModal),{loadableGenerated:{webpack:()=>[91706]},ssr:!1,loading:()=>null}),eA=e=>(0,g.$$)({mode:j.Dp.image,imageModel:e,prompt:""})||"",eM=(0,k.PA)(()=>{let{conversation:e}=(0,v.useStores)(),t=(0,C.useRef)(""),r=(0,C.useRef)(!1),n=(0,C.useRef)(void 0),i=(0,C.useRef)(""),o=e.mode,a=o===j.Dp.image?e.model.image:void 0,s=(!!a&&(0,x.t7)(a)||r.current)&&e.prompt||"";return(0,C.useEffect)(()=>{if(o===j.Dp.image&&a&&(0,x.t7)(a)){let o=r.current,l=n.current,u=eA(a),d=eA(l),c=!!s&&(s===u||s===d);r.current=!0,n.current=a,!o&&s?(t.current=s,i.current="",e.setPrompt("",{clearPendingDraft:!0})):o&&l&&l!==a&&s?(c?i.current=s:(t.current=s,i.current=""),e.setPrompt("",{clearPendingDraft:!0})):o&&c?i.current=s:o&&s&&(t.current=s,i.current="",e.setPrompt("",{clearPendingDraft:!0}));return}if(r.current){r.current=!1,n.current=void 0;let o=i.current;if(i.current="",t.current){if(s&&s!==o){t.current="";return}let r=t.current;t.current="",e.setPrompt(r,{trackPendingDraft:!0});return}if(s&&s===o)return void e.setPrompt("",{clearPendingDraft:!0});t.current=""}r.current=!1},[e,o,a,s]),null}),eI=(0,k.PA)(()=>{let{conversation:e}=(0,v.useStores)();if(e.mode===j.Dp.video){let t=e.model.video,r=(0,w.getVideoPromptLimit)(t);if(!r)return null;let i=e.prompt.length,a=i>r,s=(0,w.getVideoPromptLimitDisplayName)(t);return(0,n.jsx)(o.Text,{size:"sm",c:a?"red":"dimmed",mt:"xs",ta:"right",children:a?(0,n.jsxs)(n.Fragment,{children:["Warning: ",s," has a maximum prompt length of ",r," characters. Current: ",i,"/",r," characters. Please shorten your prompt by ",i-r," characters."]}):(0,n.jsxs)(n.Fragment,{children:["Character count: ",i,"/",r]})})}if(e.mode===j.Dp.image){let t=e.model.image,r=(0,x.jR)(t);if(!r)return null;let i=e.prompt.length,a=i>r,s=(0,x.o4)(t);return(0,n.jsx)(o.Text,{size:"sm",c:a?"red":"dimmed",mt:"xs",ta:"right",children:a?(0,n.jsxs)(n.Fragment,{children:["Warning: ",s," has a maximum prompt length of ",r," characters. Current: ",i,"/",r," characters. Please shorten your prompt by ",i-r," characters."]}):(0,n.jsxs)(n.Fragment,{children:["Character count: ",i,"/",r]})})}return null}),eR=null,eL=()=>(null!=eR||(eR=r.e(9768).then(r.bind(r,9768)).then(e=>{let{tryFileAdd:t}=e;return t})),eR),eF=async(e,t,r,n)=>{let o=(0,i.o)(r),a=await eL();if(o())for(let i of e){if(r.visibleComposerAttachmentIds.length>=5)break;a(i,t,r,n)}},ez=async e=>{let t,{composerContextVersion:r,composerVisibleEditVersion:l,textFile:u,fallbackPrompt:c,filename:m,pastedText:p,ui:h,conversation:g,libraryStore:f}=e,v=(0,i.o)(g),x=await eL();if(!v())return;let b=await x(u,h,g,f,e=>{t=e});if(!v())return;if(!b){g.draftPromptContextVersion===r&&g.composerVisibleEditVersion===l&&g.setPrompt(c,{trackPendingDraft:!0});return}if(void 0===t||g.draftPromptContextVersion!==r)return;let w=t,y=!1,S="large-paste-".concat(w);d.$e.show({id:S,title:"Pasted text attached",color:"blue",autoClose:!1,message:(0,n.jsxs)(a.Stack,{gap:"xs",children:[(0,n.jsxs)(o.Text,{size:"sm",children:["We've attached the pasted text as ",m,". The content is unchanged."]}),(0,n.jsx)(s.Button,{size:"xs",variant:"outline",onClick:()=>{var e,t;if(y)return;if(g.draftPromptContextVersion!==r||!g.visibleComposerAttachmentIds.includes(w))return void d.$e.hide(S);y=!0;let n=g.visibleComposerPrompt,i=g.composerVisibleEditVersion===l?c:"".concat(n).concat(n?"\n\n":"").concat(p);g.removeAttachment(w),g.setPrompt(i,{trackPendingDraft:!0}),d.$e.hide(S),null==(t=g.inputRef)||null==(e=t.current)||e.focus(),f.deleteLibraryItem(w).catch(e=>{console.error("Error deleting pasted text library item",e)})},children:"Show in text field"})]})})},eN=(0,k.PA)(()=>{var e,t,i,c,g;let x=(0,T.useRouter)(),w=(0,T.usePathname)(),{isReady:k,ui:P,conversation:E,clientHydrationIssues:D,libraryStore:A,memory:M,nanoStore:I,scratchpad:R,session:L,team:F}=(0,v.useStores)(),z=E.properties||{},N=(0,e_.DX)(z.id),U=(0,e_.xO)(z.id),B=(0,f.yN)(),V=E.activeModel||(null==(e=E.model)?void 0:e.text),W=(0,p.iS)({activeTextModel:V,isFusionMode:E.isFusionMode,isMultiModelMode:E.isMultiModelMode,localAutoModelMode:B,localAutoPreferThinking:(null==(i=E.getRequestModelSettings)||null==(t=i.call(E,V))?void 0:t.thinking)===!0,messageSchemaVersion:z.messageSchemaVersion,nanoBalance:null==L?void 0:L.nano_balance,pathname:w,privateModeEnabled:P.privateModeEnabled,projectStatus:N,projectIsolationStatus:U,recommendedTier:E.recommendedTier,selectedTextModels:E.selectedTextModels,slug:z.slug,subscriptionActive:E.subscriptionActive,subscriptionShowPaidModels:E.subscriptionShowPaidModels,usdBalance:null==L?void 0:L.usd_balance}),O=(0,h.jx)({conversationEnabledTools:z.enabledTools,defaultEnabledTools:P.defaultEnabledTools}).filter(e=>e!==h.Yv||!0===z.githubRepositoryAccessAllowed),q=O.includes(h.ob),G=W&&O.includes(h.Yv),$=W&&O.includes(h.Am),Y=W&&q,[H,Q]=(0,C.useState)(0),[K,J]=(0,C.useState)(!1),X=(0,C.useRef)(!1),Z=(0,C.useRef)(!1);(0,C.useEffect)(()=>(Z.current=!1,()=>{Z.current=!0}),[]);let[ee,et]=(0,C.useState)(!1),[er,en]=(0,C.useState)([]),[ei,eo]=(0,C.useState)(!1),[ea,es]=(0,C.useState)(!1),[el,eu]=(0,C.useState)(!1),[ed,ec]=(0,C.useState)(null),em=(0,C.useRef)(0),ep=(0,C.useRef)(null),[eh,eg]=(0,C.useState)(!1),[ef,ev]=(0,C.useState)(null),[ex,eb]=(0,C.useState)(null),[ew,ey]=(0,C.useState)([]),[eS,ej]=(0,C.useState)(!1),[ek,eT]=(0,C.useState)(!1),[eA,eR]=(0,C.useState)(null),eL=!0===E.hasDeferredRemoteUpdateForActiveConversation,eN=!0===E.canPullLatestDeferredRemoteUpdateForActiveConversation,eU=(0,C.useCallback)(e=>{X.current=e,J(e)},[]),eB=(0,C.useCallback)((e,t)=>{var r;let n=Number(null!=e?e:0),i=Number(null!=t?t:0),o=Number(null!=(r=null==I?void 0:I.currentNanoPr
1ice)?r:0);return Math.max(Number.isFinite(n)?n:0,Number.isFinite(i)?i*(Number.isFinite(o)?o:0):0)},[null==I?void 0:I.currentNanoPrice]),eV=(null==F?void 0:F.isUsingTeamBalance)===!0?ex:eB(null==L?void 0:L.usd_balance,null==L?void 0:L.nano_balance),eW=(0,C.useCallback)((e,t)=>null!==e&&e<t?"Not available - balance too low":null,[]),eO=(0,m.S7)(null!=(g=P.effectiveUrlScrapingProvider)?g:P.urlScrapingProvider),eq=(0,C.useCallback)(e=>Math.max(.1,e*eO),[eO]),eG=(0,C.useCallback)(e=>eW(eV,eq(e)),[eV,eW,eq]),e$=(0,C.useCallback)(async function(){var e,t,r,n,i;let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.1;if((null==F?void 0:F.isUsingTeamBalance)===!0&&F.selectedTeamId){let i=F.selectedTeamId;try{let a=await F.fetchTeamDetails(i,{force:!0});if(!(null==a||null==(e=a.team)?void 0:e.balances))return F.selectedTeamId===i&&eb(null),{unavailableReason:null,teamId:i};let s=null==a||null==(t=a.team)?void 0:t.balances,l=Number(null!=(r=null==s?void 0:s.nano_balance)?r:0);Number.isFinite(l)&&l>0&&await (null==(n=I.updateCurrentNanoPrice)?void 0:n.call(I,{force:!0}));let u=eB(null==s?void 0:s.usd_balance,null==s?void 0:s.nano_balance);return F.selectedTeamId===i&&eb(u),{unavailableReason:eW(u,o),teamId:i}}catch(e){return console.error("[ConversationInput] Failed to refresh team balance before URL scraping:",e),F.selectedTeamId===i&&eb(null),{unavailableReason:null,teamId:i}}}try{await (null==L||null==(i=L.refresh)?void 0:i.call(L,{reason:"url-scraping-balance-check",force:!0}))}catch(e){console.error("[ConversationInput] Failed to refresh balance before URL scraping:",e)}return{unavailableReason:eW(eB(null==L?void 0:L.usd_balance,null==L?void 0:L.nano_balance),o),teamId:null}},[eW,eB,I,L,F]);(0,C.useEffect)(()=>{K&&E.state.isPending&&eU(!1)},[K,E.state.isPending,eU]);let eY=(0,C.useCallback)(e=>{let t=e.clipboardData.getData("text/plain"),r=((e,t,r)=>{if(t<=0)return[];let n=[],i=new Set,o=e=>{if(!e||n.length>=t||!(e=>e.type.startsWith("image/")||/\.(jpg|jpeg|png|webp|gif|bmp|tiff|tif|heic|heif)$/i.test(e.name))(e)&&r.mode!==j.Dp.chat)return;let o="".concat(e.name,":").concat(e.size,":").concat(e.type,":").concat(e.lastModified);i.has(o)||(i.add(o),n.push(e))},a=e.clipboardData.items;if(a)for(let e of a){if(n.length>=t)break;"file"===e.kind&&o(e.getAsFile())}let s=e.clipboardData.files;if(0===n.length&&s)for(let e of s){if(n.length>=t)break;o(e)}return n})(e,Math.max(0,5-E.visibleComposerAttachmentIds.length),E);if(r.length>0)return void eF(r,P,E,A);if(t&&t.length>1e4){var n,i;if(!P.largeTextPasteToFile)return;e.preventDefault();let r=e.currentTarget.value,o=null!=(n=e.currentTarget.selectionStart)?n:r.length,a=null!=(i=e.currentTarget.selectionEnd)?i:o,s="".concat(r.slice(0,o)).concat(t).concat(r.slice(a)),l=E.draftPromptContextVersion,u=E.composerVisibleEditVersion,d=H+1,c="pasted_text_".concat(d,".txt");ez({composerContextVersion:l,composerVisibleEditVersion:u,textFile:new File([new Blob([t],{type:"text/plain"})],c,{type:"text/plain"}),fallbackPrompt:s,filename:c,pastedText:t,ui:P,conversation:E,libraryStore:A}),Q(d);return}},[P,E,A,H]),eH=(0,C.useCallback)(async function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i="string"==typeof E.draftPromptWhilePending?E.draftPromptWhilePending:E.prompt,o=(0,y.mc)(i),a=(0,y.tH)(o).filter(e=>!(0,y.HL)(e)),s=e?[]:a.filter(e=>!r||!(0,h.D2)(e)),l=(0,y.EO)(o),u=new Set;if(l.length>0&&n||(l.length>0&&"never"===P.urlScrapingPreference?E.markSkipYouTubeTranscripts():l.length>0&&l.forEach(e=>u.add(e))),s.length>0&&"always"===P.urlScrapingPreference){let e=await e$(s.length*eO);e.unavailableReason?d.$e.show({title:"URL Scraping Unavailable",message:e.unavailableReason,color:"orange"}):s.forEach(e=>u.add(e))}null==(t=E.clearScrapedUrls)||t.call(E),u.size>0&&E.setScrapedUrls(Array.from(u)),E.queueCurrentInput({deferredReadUrlUrls:e?a:[],allowLegacyScrapingForDeferredReadUrls:"always"===P.urlScrapingPreference,...n&&l.length>0?{deferredYouTubeTranscriptUrls:l,allowLegacyScrapingForDeferredYouTubeUrls:"always"===P.urlScrapingPreference}:{}})},[E,e$,P.urlScrapingPreference,eO]),eQ=(0,C.useCallback)(async(e,t)=>{var r,n,i,o,a,s,l,u,c,m,p;let h=e.filter(e=>!(0,y.HL)(e));if(0===h.length){eo(!1),en([]),await E.submit();return}let g=null!=(r=null==t?void 0:t.availability)?r:await e$(eq(h.length));if(g.unavailableReason){ev(g.unavailableReason),d.$e.show({title:"URL Scraping Unavailable",message:g.unavailableReason,color:"orange"});return}eg(!0),ev(null);let f=d.$e.show({title:"Scraping URLs",message:"Scraping ".concat(h.length," URL").concat(h.length>
11?"s":"","..."),color:"blue",loading:!0,autoClose:!1});try{let e=await fetch("/api/scrape-urls",{method:"POST",headers:{"Content-Type":"application/json",...g.teamId?{"x-team-id":String(g.teamId)}:{}},body:JSON.stringify({urls:h,mode:"conversation",provider:null!=(o=P.effectiveUrlScrapingProvider)?o:P.urlScrapingProvider})}),t=await e.json().catch(()=>null),r=(0,S.c)(t);if(!e.ok&&!r){let e="string"==typeof(null==t?void 0:t.error)?t.error:"string"==typeof(null==t||null==(a=t.error)?void 0:a.message)?t.error.message:"string"==typeof(null==t?void 0:t.message)?t.message:"Failed to scrape URLs";throw Error(e)}if(!r)throw Error("Scraping returned an invalid response");d.$e.hide(f);let v=(null==(n=t.results)?void 0:n.filter(e=>e.success))||[],x=(null==(i=t.results)?void 0:i.filter(e=>!e.success))||[],b=v.map(e=>e.url).filter(e=>"string"==typeof e&&e.length>0);if(v.length>0){for(let e of(E.setScrapedUrls(b),E.setScrapedContent(v.map(e=>({url:e.url,title:e.title,content:e.markdown||e.content,contextProof:e.contextProof}))),v)){let t="**Web Page Content**\n\nURL: ".concat(e.url,"\n").concat(e.title?"Title: ".concat(e.title,"\n"):"","\n**Content:**\n").concat(e.markdown||e.content);!P.scratchpadOpened&&P.isDesktop&&P.setScratchpadOpened(!0),R.addEntry(t,"note",null==(u=E.properties)?void 0:u.slug)}let e=" (Cost: $".concat((null!=(c=t.summary.actualCost)?c:0).toFixed(4),")");d.$e.show({title:"URLs Scraped Successfully",message:"Successfully scraped ".concat((null==(s=t.summary)?void 0:s.successful)||v.length," of ").concat((null==(l=t.summary)?void 0:l.requested)||h.length," URLs").concat(e,". Content added to context and scratchpad."),color:"green"})}else{let e=x.map(e=>null==e?void 0:e.error).find(e=>"string"==typeof e&&e.trim().length>0),r=x.map(e=>null==e?void 0:e.error).find(e=>"string"==typeof e&&e.toLowerCase().includes("unsupported file type")),n=null==(m=x.find(e=>"string"==typeof(null==e?void 0:e.unsupportedService)||"string"==typeof(null==e?void 0:e.error)&&e.error.toLowerCase().includes("currently unsupported")))?void 0:m.error,i=r||n||e,o=null!=(p=t.summary.refundCost)?p:0,a=o>0?t.summary.refundProcessed?" A $".concat(o.toFixed(4)," refund was processed."):" A $".concat(o.toFixed(4)," refund is pending."):"",s=(x.length>0?r||n||"Scraping did not return usable page content. Review the failed URLs below or skip scraping.":"Scraping completed but returned no usable page content. You can skip scraping and continue.")+a;ev(s),d.$e.show({title:"No Scraped Content Added",message:s,color:"red"}),x.length>0&&d.$e.show({title:"Some URLs Failed",message:r||n?"Failed to scrape ".concat(x.length," URL(s): ").concat(i):"Failed to scrape ".concat(x.length," URL(s): ").concat(x.map(e=>e.url).join(", ")),color:"orange"});return}x.length>0&&d.$e.show({title:"Some URLs Failed",message:"Failed to scrape ".concat(x.length," URL(s): ").concat(x.map(e=>e.url).join(", ")),color:"orange"}),eo(!1),en([]),await E.submit()}catch(e){console.error("Error scraping URLs:",e),ev(e instanceof Error?e.message:"Failed to scrape URLs"),d.$e.hide(f),d.$e.show({title:"Scraping Failed",message:e instanceof Error?e.message:"Failed to scrape URLs",color:"red"})}finally{eg(!1)}},[E,eq,e$,R,P]),eK=(0,C.useCallback)(()=>{em.current+=1,ep.current=null,es(!1),en([]),ec(null),eu(!1)},[]),eJ=(0,C.useCallback)(async()=>{var e,t,n,i,o,a,s,l;let u=em.current+1;em.current=u;let c=ep.current,m=null!=(a=null!=(n=null==(e=E.properties)?void 0:e.slug)?n:null==(t=E.properties)?void 0:t.uuid)?a:"draft:".concat(null!=(o=null!=(i=E.draftPromptContextVersion)?i:E.storeId)?o:"unknown"),p=()=>!(()=>{var e,t,r,n,i,o;let a=null!=(o=null!=(r=null==(e=E.properties)?void 0:e.slug)?r:null==(t=E.properties)?void 0:t.uuid)?o:"draft:".concat(null!=(i=null!=(n=E.draftPromptContextVersion)?n:E.storeId)?i:"unknown");return!Z.current&&em.current===u&&a===m})()&&(Z.current||em.current!==u||(em.current+=1,es(!1),en([]),ec(null),eu(!1)),!0);eu(!0),ec(null);try{let e={conversationEnabledTools:null==(s=E.properties)?void 0:s.enabledTools,defaultEnabledTools:P.defaultEnabledTools},t=(0,h.jx)(e),n=t.includes(h.ob)?t:[...t,h.ob],i=(0,h.OU)(n,(0,h.U1)(e)),{writeConversationEnabledTools:o}=await Promise.resolve().then(r.bind(r,11353));if(p())return;await o(E,i)}catch(e){if(p())return;if(console.error("[ConversationInput] Failed to enable the URL reader:",e),!(0,h.jx)({conversationEnabledTools:null==(l=E.properties)?void 0:l.enabledTools,defaultEnabledTools:P.defaultEnabledTools}).includes(h.ob)){ec("The URL reader could not be enabled. Please try again or send without it."),eu(!1);return}d.$e.show({title:"URL reader enabled for this message",message:"The tool is available now, but its setting could not be saved for later messages.",color:"orange"})}p()||(ep.current=null,es(!1),en([]),eu(!1),c?await c(!0):await E.submit())},[E,P.defaultEnabledTools]),eX=(0,C.useCallback)(async()=>{let e=ep.current;em.current+=1,ep.current=null,es(!1),en([]),ec(null),eu(!1),e?await e(!1):await E.submit()},[E]),eZ=(0,C.useCallback)(async e=>{eT(!0),eR(null);let t=d.$e.show({title:"Fetching YouTube Transcripts",message:"Fetching transcripts for ".concat(e.length," video").concat(e.length>
11?"s":"","..."),color:"blue",loading:!0,autoClose:!1});try{let n=await fetch("/api/youtube-transcript",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({urls:e})});if(!n.ok){let e=await n.json();throw Error(e.error||"Failed to fetch YouTube transcripts")}let i=(await n.json()).transcripts;d.$e.hide(t);let o=i.filter(e=>e.success),a=i.filter(e=>!e.success);if(o.length>0){let t=o.map(e=>({url:e.url,title:e.title||"YouTube Video (".concat(e.videoId,")"),content:"YouTube Video Transcript:\n\n".concat(e.transcript)}));for(let n of(E.setScrapedUrls(e),E.setScrapedContent(t),o)){var r;let e="**YouTube Video Transcript**\n\nURL: ".concat(n.url,"\n").concat(n.title?"Title: ".concat(n.title,"\n"):"","\n**Transcript:**\n").concat(n.transcript);!P.scratchpadOpened&&P.isDesktop&&P.setScratchpadOpened(!0),R.addEntry(e,"note",null==(r=E.properties)?void 0:r.slug)}d.$e.show({title:"Transcripts Fetched Successfully",message:"Successfully fetched ".concat(o.length," of ").concat(i.length," transcripts. Content added to context and scratchpad."),color:"green"})}a.length>0&&d.$e.show({title:"Some Transcripts Failed",message:"Failed to fetch ".concat(a.length," transcript(s): ").concat(a.map(e=>e.error||"Unknown error").join(", ")),color:"orange"}),ej(!1),ey([]),await E.submit()}catch(e){console.error("Error fetching YouTube transcripts:",e),eR(e instanceof Error?e.message:"Failed to fetch transcripts"),d.$e.hide(t),d.$e.show({title:"Transcript Fetching Failed",message:e instanceof Error?e.message:"Failed to fetch transcripts",color:"red"})}finally{eT(!1)}},[E,P,R]),e0=(0,C.useCallback)(async()=>{if(!ee){et(!0);try{var e,t,r;let n=null==(e=E.properties)?void 0:e.uuid,i=await (null==(t=E.pullLatestDeferredActiveConversation)?void 0:t.call(E));"conflict"===i&&n&&(null==(r=E.properties)?void 0:r.uuid)===n&&E.confirmNavigationAway()&&x.push("/sync-conflict/".concat(encodeURIComponent(n)))}finally{et(!1)}}},[E,ee,x]),e1=(0,C.useCallback)(async e=>{var t,r,n,i,o,a,s,l,u,c,m;if(null==e||e.preventDefault(),!1===E.isTextModelReady&&(E.mode===j.Dp.chat||E.mode===j.Dp.translate)||X.current||K)return;if(E.isIncognito&&E.isSavingIncognitoConversation)return void d.$e.show({id:"incognito-save-in-progress",title:"Saving incognito chat",message:"Please wait for the save to finish before sending another message.",color:"blue"});if(E.mode===j.Dp.image&&(0,b.ZQ)(E.model.image,E.getSetting("customCivitaiAir"))){d.$e.show({title:"Custom model not set",message:b.zU,color:"red"}),(0,b.wd)();return}let p=null==D||null==(t=D.memory)?void 0:t.kind;if(E.mode===j.Dp.chat&&!E.isIncognito&&(null==M?void 0:M.isHydrated)===!1&&"failed"!==p&&"timed_out"!==p)return void d.$e.show({id:"memory-hydration-submit-blocked",title:"Memory is still loading",message:"Please wait a moment before sending so saved memory can be included.",color:"blue"});if(eU(!0),E.isQueuedDraftCarryoverHandoffActive())return void eU(!1);let g=null!=(l=null!=(s=null!=(a=null==(r=E.properties)?void 0:r.slug)?a:null==(n=E.properties)?void 0:n.uuid)?s:E.storeId)?l:null;await new Promise(e=>{let t,r,n=()=>{clearTimeout(i),void 0!==r&&clearTimeout(r),void 0!==t&&cancelAnimationFrame(t),e()},i=setTimeout(n,100);if("function"==typeof requestAnimationFrame){t=requestAnimationFrame(()=>{r=setTimeout(n,0)});return}r=setTimeout(n,0)});let f=null!=(m=null!=(c=null!=(u=null==(i=E.properties)?void 0:i.slug)?u:null==(o=E.properties)?void 0:o.uuid)?c:E.storeId)?m:null;if(Z.current||f!==g){X.current=!1,Z.current||J(!1);return}try{let e=(E.prompt||"").trim().toLowerCase();if("/voice"===e){E.setPrompt(""),E.set("mode",j.Dp.voice),x.push("/voice"),eU(!1);return}try{let e=E.state.isPending&&E.mode===j.Dp.chat&&Array.isArray(E.draftAttachmentIdsWhilePending)?E.draftAttachmentIdsWhilePending:[],t=E.visibleComposerAttachmentIds,r=new Set([...t,...e].map(e=>String(e)));if(r.size>0&&A.pendingFiles.some(e=>null!=e.libraryItemId&&r.has(String(e.libraryItemId)))){d.$e.show({title:"Please wait",message:"Attachment processing is still in progress. Try again in a moment.",color:"orange"}),eU(!1);return}}catch(e){}let t=async e=>{if(e.length>0){if($){E.markSkipYouTubeTranscripts(),await E.submit();return}ey(e),ej(!0);return}await E.submit()};if(E.state.isPending&&E.mode===j.Dp.chat){try{let e="string"==typeof E.draftPromptWhilePending?E.draftPromptWhilePending:E.prompt,r=(0,y.mc)(e),n=(0,y.tH)(r).filter(e=>!(0,y.HL)(e)).filter(e=>!G||!(0,h.D2)(e)),i=(0,y.EO)(r);if(n.length>0&&W&&!q&&"ask"===P.urlScrapingPreference){en(n),ec(null),ep.current=async e=>{if(E.state.isPending)return void await eH(e,G,$);await t(i)},es(!0),eU(!1);return}await eH(Y,G,$)}catch(e){console.error("[ConversationInput] Failed to queue message:",e)}eU(!1);return}let r=(0,y.mc)(E.prompt),n=(0,y.EO)(r),i=(0,y.tH)(r).filter(e=>!(0,y.HL)(e)),o=i.filter(e=>!G||!(0,h.D2)(e));if((n.length>0||i.length>0)&&"chat"===E.mode){if(o.length>0&&W&&!q&&"ask"===P.urlScrapingPreference){en(o),ec(null),ep.current=()=>t(n),es(!0),eU(!1);return}if(n.length>0)if($)E.markSkipYouTubeTranscripts();else if("always"===P.urlScrapingPreference){await eZ(n),E.state.isPending||eU(!1);return}else if("ask"===P.urlScrapingPreference){ey(n),ej(!0),eU(!1);return}else"never"===P.urlScrapingPreference&&E.markSkipYouTubeTranscripts();if(o.length>0&&!Y){if("always"===P.urlScrapingPreference){let e=await e$(eq(o.length));if(e.unavailableReason){d.$e.show({title:"URL Scraping Unavailable",message:e.unavailableReason,color:"orange"});try{await E.submit()}finally{E.state.isPending||eU(!1)}return}await eQ(o,{availability:e}),E.state.isPending||eU(!1);return}else if("ask"===P.urlScrapingPreference){await e$(eq(o.length)),en(o),eo(!0),eU(!1);return}}}try{await E.submit()}finally{E.state.isPending||eU(!1)}}catch(e){throw E.state.isPending||eU(!1),e}},[null==D||null==(c=D.memory)?void 0:c.kind,E,eq,G,eQ,eZ,K,A,null==M?void 0:M.isHydrated,eH,W,q,Y,e$,x,eU,P,$]),[e4,e5]=(0,C.useState)(void 0);return(0,n.jsxs)(a.Stack,{style:{flexGrow:1,position:"relative"},gap:5,children:[eL&&(0,n.jsx)(l.Box,{className:"".concat(_.hJ," ").concat(_.n5),"data-conversation-banner-slot":"deferred-remote-update",children:(0,n.jsx)(l.Box,{style:{border:"1px solid var(--mantine-color-yellow-4)",background:"var(--mantine-color-yellow-0)",borderRadius:"var(--mantine-radius-lg)",padding:"12px 14px"},children:(0,n.jsxs)(u.Group,{justify:"space-between",align:"center",gap:"sm",wrap:"wrap",children:[(0,n.jsxs)(a.Stack,{gap:2,style:{flex:1,minWidth:240},children:[(0,n.jsx)(o.Text,{fw:600,size:"sm",children:"Cloud sync needs attention"}),(0,n.jsx)(o.Text,{size:"sm",c:"dimmed",children:"You can keep chatting. New messages are saved in this browser until sync is resolved."})]}),(0,n.jsx)(s.Button,{size:"xs",variant:"light",onClick:()=>{e0()},loading:ee||E.cloudSyncRunning,disabled:!eN||ee,children:"Pull latest"}),(0,n.jsx)(s.Button,{size:"xs",variant:"subtle",onClick:()=>{var e;let t=null==(e=E.properties)?void 0:e.uuid;t&&E.confirmNavigationAway()&&x.push("/sync-conflict/".concat(encodeURIComponent(t)))},children:"Compare versions"})]})})}),(0,n.jsxs)("form",{onSubmit:e1,id:"conversation-form",autoComplete:"off",children:[(0,n.jsx)(eM,{}),(0,n.jsx)(eC,{isReady:k,isScrapingUrls:eh,handlePaste:eY,onSubmit:e1,conversation:E,ui:P,isSubmitting:K,messageHistoryIndex:e4,setMessageHistoryIndex:e5})]}),(0,n.jsx)(eI,{}),ea?(0,n.jsx)(eE,{opened:ea,urls:er,onClose:eK,onEnable:()=>{eJ()},onSendWithout:()=>{eX()},isEnabling:el,error:ed}):null,ei?(0,n.jsx)(eP,{provider:P.effectiveUrlScrapingProvider,opened:ei,onClose:()=>{eo(!1),en([]),ev(null)},urls:er,onScrape:eQ,onSkip:async()=>{await E.submit()},isLoading:eh,error:ef,getScrapeUnavailableReason:eG}):null,eS?(0,n.jsx)(eD,{opened:eS,onClose:()=>{ej(!1),ey([]),eR(null)}
1,urls:ew,onFetchTranscripts:eZ,onSkip:async()=>{E.markSkipYouTubeTranscripts(),await E.submit()},isLoading:ek,error:eA}):null]})})},42703:(e,t,r)=>{"use strict";function n(e){if(!e||"object"!=typeof e)return!1;let t=e.summary;return Array.isArray(e.results)&&!!t&&"object"==typeof t&&"number"==typeof t.successful&&"number"==typeof t.failed}r.d(t,{c:()=>n})},44043:(e,t,r)=>{"use strict";r.d(t,{j:()=>s});var n=r(95155),i=r(47650),o=r(88267);r(63592);let a=e=>{let{ariaLabel:t="Preparing message"}=e;return(0,n.jsx)("div",{"aria-label":t,className:"_1odnq9k1","data-testid":"submit-preparation-bar",role:"progressbar"})},s=e=>{let{ariaLabel:t}=e;return(0,o.DE)()?(0,i.createPortal)((0,n.jsx)(a,{ariaLabel:t}),document.body):null}},46536:(e,t,r)=>{"use strict";r.d(t,{W2:()=>l});var n=r(95155),i=r(12115),o=r(46460);r(40290);var a="nyrokk5",s="nyrokk1";let l=e=>{let{left:t,right:r,defaultSplit:l=50,minSplit:u=20,maxSplit:d=80,onSplitChange:c,split:m,disabled:p=!1}=e,[h,g]=i.useState(l),[f,v]=i.useState(!1),x=i.useRef(null),b=null!=m?m:h,w=i.useCallback(e=>{if(!f||!x.current||p)return;let t=x.current.getBoundingClientRect(),r=Math.max(u,Math.min(d,(e.clientX-t.left)/t.width*100));c?c(r):g(r)},[f,u,d,c,p]),y=i.useCallback(e=>{if(!f||!x.current||p||!e.touches[0])return;let t=x.current.getBoundingClientRect(),r=Math.max(u,Math.min(d,(e.touches[0].clientX-t.left)/t.width*100));c?c(r):g(r)},[f,u,d,c,p]),S=i.useCallback(()=>{v(!1)},[]),j=i.useCallback(()=>{v(!1)},[]);return i.useEffect(()=>{if(f)return document.addEventListener("mousemove",w),document.addEventListener("mouseup",S),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",j,{passive:!0}),document.body.style.cursor="ew-resize",document.body.style.userSelect="none",document.body.style.webkitUserSelect="none",()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",S),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",j),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.webkitUserSelect=""}},[f,w,S,y,j]),(0,n.jsxs)(o.Box,{ref:x,className:"nyrokk0",children:[(0,n.jsx)(o.Box,{className:s,style:{flex:"0 0 ".concat(b,"%"),transition:f?"none":"flex-basis 0.3s ease"},children:t}),!p&&(0,n.jsxs)(o.Box,{className:"nyrokk2",onMouseDown:e=>{p||(e.preventDefault(),v(!0))},onTouchStart:e=>{p||(e.preventDefault(),v(!0))},children:[(0,n.jsx)(o.Box,{className:"nyrokk3"}),(0,n.jsxs)(o.Box,{className:"nyrokk4",children:[(0,n.jsx)(o.Box,{className:a}),(0,n.jsx)(o.Box,{className:a}),(0,n.jsx)(o.Box,{className:a})]})]}),(0,n.jsx)(o.Box,{className:s,style:{flex:"0 0 ".concat(100-b,"%"),transition:f?"none":"flex-basis 0.3s ease"},children:r})]})};r(69034)},48622:(e,t,r)=>{"use strict";r.d(t,{w:()=>E});var n=r(95155),i=r(46460),o=r(6584),a=r(52645),s=r(57142),l=r(61915),u=r(29452),d=r(31184),c=r(46559),m=r(49257),p=r(509),h=r(23070),g=r(92377),f=r(13662),v=r(42021),x=r(38443),b=r(32994),w=r(84933),y=r(55322),S=r(59379),j=r(7138),k=r(88267),T=r(98500),C=r.n(T),_=r(70670);let P=[{icon:m.A,title:"Privacy First",description:"Your chats are stored locally. We don't train on your data."},{icon:p.A,title:"Auto Model Selection",description:"Let our Auto Model feature pick the best AI for your task, or choose a model yourself.",textConversationQuery:"?model=auto-model"},{icon:h.A,title:"Pay As You Go",description:"No subscriptions required. Only pay for what you use.",link:"/pricing"},{icon:g.A,title:"Chat with AI",description:"Access ChatGPT, Claude, Gemini, and all top AI models in one place.",textConversationQuery:""},{icon:f.A,title:"Generate Images",description:"Create stunning images with DALL-E, Flux, and more.",link:"/conversation/new?mode=image"},{icon:v.A,title:"Create Videos",description:"Generate AI videos with Runway, Kling, and other video models.",link:"/conversation/new?mode=video"}];function E(){let{textConversationHref:e="/conversation/new"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[t,{toggle:r,close:m}]=(0,c.j)(!1),p=(0,k.Ud)(),h=t?"".concat(_.hP," ").concat(_.bR):_.hP;return(0,n.jsxs)(i.Box,{className:_.fc,children:[!t&&(0,n.jsxs)(o.Group,{gap:"sm",wrap:"wrap",justify:"center",children:[(0,n.jsxs)(o.Group,{gap:"sm",wrap:"nowrap",children:[(0,n.jsx)(a.Tooltip,{label:"See some tips and tricks",position:"top",withArrow:!0,children:(0,n.jsxs)(s.UnstyledButton,{className:h,onClick:r,children:[(0,n.jsx)(x.A,{size:16}),(0,n.jsx)(l.Text,{size:"xs",fw:500,children:"Learn"})]})}),(0,n.jsx)(a.Tooltip,{label:"Visit our media creation page (".concat(p?"â¥M":"Alt+M",")"),position:"top",withArrow:!0,children:(0,n.jsxs)(s.UnstyledButton,{className:_.hP,component:C(),href:"/media",children:[(0,n.jsx)(b.A,{size:16}),(0,n.jsx)(l.Text,{size:"xs",fw:500,children:"Create"})]})}),(0,n.jsx)(a.Tooltip,{label:"Start a new audio conversation",position:"top",withArrow:!0,children:(0,n.jsxs)(s.UnstyledButton,{className:_.hP,component:C(),href:"/conversation/ne
1w?mode=audio",children:[(0,n.jsx)(w.A,{size:16}),(0,n.jsx)(l.Text,{size:"xs",fw:500,children:"Audio"})]})})]}),(0,n.jsxs)(o.Group,{gap:"sm",wrap:"nowrap",children:[(0,n.jsx)(a.Tooltip,{label:"Explore all our models",position:"top",withArrow:!0,children:(0,n.jsxs)(s.UnstyledButton,{className:_.hP,component:C(),href:"/models",children:[(0,n.jsx)(y.A,{size:16}),(0,n.jsx)(l.Text,{size:"xs",fw:500,children:"Explore"})]})}),(0,n.jsx)(a.Tooltip,{label:"Create an API key and get started",position:"top",withArrow:!0,children:(0,n.jsxs)(s.UnstyledButton,{className:_.hP,component:C(),href:"/api",children:[(0,n.jsx)(S.A,{size:16}),(0,n.jsx)(l.Text,{size:"xs",fw:500,children:"API"})]})})]})]}),(0,n.jsx)(u.S,{in:t,style:{width:"100%"},children:(0,n.jsxs)(i.Box,{className:_.T7,children:[(0,n.jsxs)(s.UnstyledButton,{className:_.ol,onClick:m,"aria-label":"Close learn panel",children:[(0,n.jsxs)(i.Box,{className:_.Kb,children:[(0,n.jsx)(x.A,{size:14}),(0,n.jsx)(l.Text,{size:"xs",fw:500,children:"Learn"})]}),(0,n.jsx)(i.Box,{className:_.yU,"aria-hidden":"true",children:(0,n.jsx)(j.A,{size:14})})]}),(0,n.jsx)(d.Stack,{gap:0,className:_.Z,children:P.map(t=>{let r=t.icon,o=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Box,{className:_.jq,children:(0,n.jsx)(r,{size:16})}),(0,n.jsxs)(d.Stack,{gap:2,style:{flex:1},children:[(0,n.jsx)(l.Text,{fw:600,size:"sm",children:t.title}),(0,n.jsx)(l.Text,{size:"xs",c:"dimmed",lh:1.3,children:t.description})]})]}),a="textConversationQuery"in t?"".concat(e).concat(t.textConversationQuery):t.link;return a?(0,n.jsx)(s.UnstyledButton,{component:C(),href:a,className:_._9,children:o},t.title):(0,n.jsx)(i.Box,{className:_.cV,children:o},t.title)})})]})})]})}},48788:(e,t,r)=>{"use strict";function n(e,t,r){for(let n=0;n<r.length;n++)e.setUint8(t+n,r.charCodeAt(n));return t+r.length}async function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"recording.wav",r=await e.arrayBuffer(),i=new(function(){let e=window.AudioContext||window.webkitAudioContext;if(!e)throw Error("AudioContext is not supported in this browser");return e}());try{let e=await i.decodeAudioData(r),o=e.numberOfChannels,a=e.sampleRate,s=e.length,l=new ArrayBuffer(44+s*o*2),u=new DataView(l),d=0;d=n(u,d,"RIFF"),u.setUint32(d,36+s*o*2,!0),d+=4,d=n(u,d,"WAVE"),d=n(u,d,"fmt "),u.setUint32(d,16,!0),d+=4,u.setUint16(d,1,!0),d+=2,u.setUint16(d,o,!0),d+=2,u.setUint32(d,a,!0),d+=4,u.setUint32(d,a*o*2,!0),d+=4,u.setUint16(d,2*o,!0),d+=2,u.setUint16(d,16,!0),d+=2,d=n(u,d,"data"),u.setUint32(d,s*o*2,!0),d+=4;let c=[];for(let t=0;t<o;t++)c.push(e.getChannelData(t));let m=0;for(let e=0;e<s;e++)for(let t=0;t<o;t++){let r=Math.max(-1,Math.min(1,c[t][e]));u.setInt16(d+m,r<0?32768*r:32767*r,!0),m+=2}let p=new Blob([l],{type:"audio/wav"});return new File([p],t,{type:"audio/wav"})}finally{try{await i.close()}catch(e){}}}function o(e,t){e.getByteTimeDomainData(t);let r=0;for(let e=0;e<t.length;e++){let n=(t[e]-128)/128;r+=n*n}return Math.min(1,Math.max(0,2*Math.sqrt(r/t.length)))}r.d(t,{$h:()=>o,_c:()=>i})},50136:(e,t,r)=>{"use strict";r.r(t),r.d(t,{DEFAULT_PROJECT_FILE_BASE_NAME:()=>c,MAX_PROJECT_FILE_CONTENT_CHARS:()=>l.g,MAX_PROJECT_FILE_NAME_LENGTH:()=>d,createProjectTextFile:()=>x,findProjectFileByName:()=>f,getProjectFileExtensionForCodeLanguage:()=>p,normalizeProjectFileNameForUpload:()=>h,sanitizeProjectFileName:()=>g});var n=r(26550),i=r(98095),o=r(51757),a=r(3395),s=r(47965),l=r(85567),u=r(86499);let d=128,c="snippet",m=new Set([...o.lq,"svg"]),p=e=>{let t=(0,i.QC)(e||"");return m.has(t)?t:"txt"},h=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"txt",r=g(e,t),n=(0,a.D)(r);return n&&m.has(n)?r:"".concat(r,".txt")},g=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"txt",r=String(null!=e?e:"").replace(/[\\/]+/g," ").replace(/[\u0000-\u001f\u007f]+/g,"").replace(/\s+/g," ").trim().replace(/^\.+(?=[^.]*\.)/,"").slice(0,d).trim().replace(/\.+$/,""),n=r.length>0?r:c;return/^\.[^.]+$/.test(n)||/[^.]\.[^.]+$/.test(n)?n:"".concat(n,".").concat(t)},f=async(e,t)=>{var r;if(!Number.isFinite(e)||e<=0)return null;let i=t.trim().toLowerCase();if(!i)return null;let o=(await n.projectLibraryTable.where("projectId").equals(e).toArray()).map(e=>e.libraryId).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===o.length?null:null!=(r=(await n.libraryTable.where("id").anyOf(o).toArray()).find(e=>String(e.name||"").trim().toLowerCase()===i))?r:null},v=async(e,t)=>{await n.default.transaction("rw",n.projectLibraryTable,n.projectSemanticChunksTable,n.projectSemanticIndexesTable,n.projectsTable,async()=>{await n.projectLibraryTable.where("[projectId+libraryId]").equals([e,t]).delete(),await n.projectSemanticChunksTable.
1where("[projectId+libraryId]").equals([e,t]).delete();let r=await n.projectSemanticChunksTable.where("projectId").equals(e).toArray(),i=Array.from(new Set(r.map(e=>Number(null==e?void 0:e.libraryId)).filter(e=>Number.isFinite(e)&&e>0))),o=await n.projectSemanticIndexesTable.get(e);o&&await n.projectSemanticIndexesTable.put({...o,projectId:e,selectedLibraryIds:Array.isArray(o.selectedLibraryIds)?o.selectedLibraryIds.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e!==t):o.selectedLibraryIds,chunkCount:r.length,indexedFileCount:i.length,updatedAt:Date.now()}),await n.projectsTable.update(e,{updatedAt:Date.now()})})},x=async e=>{var t;let i=Number(e.projectId);if(!Number.isFinite(i)||i<=0)throw Error("No active project to save this file to.");let o=String(null!=(t=e.content)?t:"");if(0===o.length)throw Error("Cannot save an empty file.");if(o.length>l.g)throw Error("File content is too large (limit ".concat(l.g.toLocaleString()," characters)."));let a=h(e.fileName),d=!1===e.replaceExisting?null:await f(i,a),c=new File([o],a,{type:"text/plain"}),m=await s.rootStore.libraryStore.addLibraryItem(c);if("number"!=typeof m||!Number.isFinite(m))throw Error("Unable to store the file in the library.");if(await (0,u.y)({projectId:i,libraryIds:[m],projectLibraryTable:n.projectLibraryTable,syncProjectSemanticIndexForAddedFiles:async()=>{}}),await n.projectsTable.update(i,{updatedAt:Date.now()}).catch(()=>{}),d&&"number"==typeof d.id&&d.id!==m)try{await v(i,d.id)}catch(e){console.warn("[ProjectFileCreate] Failed to unlink replaced project file",{projectId:i,replacedLibraryId:d.id,error:e})}return Promise.all([r.e(9768),r.e(92467)]).then(r.bind(r,9768)).then(e=>{let{syncProjectSemanticIndexForAddedFiles:t}=e;return t(i,[m])}).catch(e=>{console.warn("[ProjectFileCreate] Failed to sync semantic index for saved project file",{projectId:i,libraryId:m,error:e})}),{libraryId:m,fileName:a,replacedExisting:!!d}}},51193:e=>{e.exports={inputShell:"ResizableTextarea_inputShell__XW7WF",cssAutosizeShell:"ResizableTextarea_cssAutosizeShell__KxgR6",inputShellReserved:"ResizableTextarea_inputShellReserved__Beudt",inputMainRow:"ResizableTextarea_inputMainRow__bYU1C",inputRightSection:"ResizableTextarea_inputRightSection__ADss9",inputMetaRow:"ResizableTextarea_inputMetaRow__u0Yde",inputMetaRowReserved:"ResizableTextarea_inputMetaRowReserved__vXUHv",placeholderSmall:"ResizableTextarea_placeholderSmall__ANAPf",cssAutosizeInput:"ResizableTextarea_cssAutosizeInput____y__"}},52240:(e,t,r)=>{"use strict";r.d(t,{A:()=>u});var n=r(95155),i=r(61915),o=r(73572),a=r(6584),s=r(52181),l=r(47965);let u=(0,r(6829).PA)(()=>{let{session:e,conversation:t}=(0,l.useStores)();if(!1!==t.isTextModelReady)return null;if(!(null==e?void 0:e.initialRefreshFailed)){var r;return(null==(r=t.prompt)?void 0:r.trim())?(0,n.jsxs)(i.Text,{size:"sm",c:"dimmed",role:"status",children:[(null==e?void 0:e.initialized)===!0?"Loading your saved settingsâ¦":"Checking your accountâ¦"," Your message has not been sent yet."]}):null}return(0,n.jsx)(o.Alert,{color:"orange",variant:"light",radius:"md",role:"alert",children:(0,n.jsxs)(a.Group,{gap:"xs",justify:"center",children:[(0,n.jsx)(i.Text,{size:"sm",children:"Your account could not be loaded. Your draft is still here."}),(0,n.jsx)(s.Button,{size:"compact-sm",variant:"light",loading:e.isRefreshing,onClick:()=>{e.refresh({reason:"composer-account-retry",force:!0,waitForQueue:!0}).catch(()=>{})},children:"Retry account loading"})]})})})},52927:(e,t,r)=>{"use strict";r.d(t,{N:()=>i});var n=r(12115);function i(e){(0,n.useEffect)(()=>{if(!e||"undefined"==typeof navigator||"undefined"==typeof document)return;let t=navigator.wakeLock;if(!t)return;let r=!1,n=!1,i=null,o=()=>{i=null},a=()=>{let e=i;i=null,e&&(e.removeEventListener("release",o),e.release().catch(()=>{}))},s=async()=>{if(!r&&!n&&!i&&"visible"===document.visibilityState){n=!0;try{let e=await t.request("screen");if(r||"visible"!==document.visibilityState)return void e.release().catch(()=>{});i=e,e.addEventListener("release",o)}catch(e){}finally{n=!1}}},l=()=>{"visible"===document.visibilityState?s():a()};return document.addEventListener("visibilitychange",l),s(),()=>{r=!0,document.removeEventListener("visibilitychange",l),a()}},[e])}},53986:(e,t,r)=>{"use strict";r.d(t,{Y:()=>a});var n=r(47965),i=r(51008),o=r(12115);let a=e=>{let{slug:t}
1=e,{conversation:r,ui:a}=(0,n.useStores)(),s=(0,o.useRef)(r);return(0,o.useEffect)(()=>{if(s.current.initialize({slug:t}).catch(e=>{(0,i.F)(e)}),a.trackConversationVisit(t),a.isDesktop){let e=setTimeout(()=>{a.focusInput()},100);return()=>{clearTimeout(e)}}},[t,a]),(0,o.useEffect)(()=>{if(t)try{var e,r;let n=null==(e=window.sessionStorage)?void 0:e.getItem("therapist:enableMemory:".concat(t)),i=null==(r=window.sessionStorage)?void 0:r.getItem("therapist:targetModel:".concat(t));if("1"===n){try{i&&s.current.setTextModel(i,!1)}catch(e){}s.current.setContextMemoryEnabled(!0),void 0===s.current.contextMemoryExpirationDays&&s.current.setContextMemoryExpirationDays(30)}}catch(e){}},[t]),(0,o.useEffect)(()=>{if(t)try{var e,r,n,i;let o=null==(e=window.sessionStorage)?void 0:e.getItem("therapist:enableMemory:".concat(t)),a=null==(r=window.sessionStorage)?void 0:r.getItem("therapist:targetModel:".concat(t));if("1"===o){try{a&&s.current.model.text!==a&&s.current.setTextModel(a,!1)}catch(e){}s.current.setContextMemoryEnabled(!0),void 0===s.current.contextMemoryExpirationDays&&s.current.setContextMemoryExpirationDays(30);try{!0===s.current.isContextMemoryEnabled&&(null==(n=window.sessionStorage)||n.removeItem("therapist:enableMemory:".concat(t)),a&&(null==(i=window.sessionStorage)||i.removeItem("therapist:targetModel:".concat(t))))}catch(e){}}}catch(e){}},[t,r.model.text]),null}},57527:(e,t,r)=>{"use strict";r.d(t,{gk:()=>i,pl:()=>n});let n=5e3;function i(e){let t=0;for(let r of e)t+=1;return t}},69742:(e,t,r)=>{"use strict";r.d(t,{K:()=>b});var n=r(95155),i=r(73572),o=r(6584),a=r(61915),s=r(52181),l=r(52645),u=r(7498),d=r(48303),c=r(55654),m=r(7138),p=r(47965),h=r(6829),g=r(73321),f=r(12115),v=r(63088),x=r(96296);let b=(0,h.PA)(e=>{var t;let{canShow:r}=e,h=(0,g.useRouter)(),{isReady:b,conversation:w}=(0,p.useStores)(),[y,S]=(0,f.useState)(!1),[j,k]=(0,f.useState)(!1),T=(0,x.wF)(w.attachments||[]),C=T.length,_=Number(null==(t=w.properties)?void 0:t.id),P=Number.isFinite(_)&&_>0?_:null;if((0,f.useEffect)(()=>{S(!1)},[P]),!b||!r||y||w.mode!==v.Dp.chat||w.isIncognito||!P||C<=3)return null;let E=async()=>{k(!0);try{var e;let t=await (0,x.dO)({conversationId:P,conversationName:null==(e=w.properties)?void 0:e.name,conversationPrompt:w.prompt,attachmentIds:T});h.push("/workspace/project/".concat(encodeURIComponent(t)))}catch(e){k(!1),d.$e.show({color:"red",title:"Unable to create project",message:e instanceof Error?e.message:"Please try again."})}};return(0,n.jsx)(i.Alert,{color:"teal",variant:"light",radius:"md",icon:(0,n.jsx)(c.A,{size:"1rem"}),styles:{root:{padding:"0.5rem 0.75rem"},message:{width:"100%"}},children:(0,n.jsxs)(o.Group,{justify:"space-between",gap:"xs",wrap:"nowrap",children:[(0,n.jsx)(a.Text,{size:"sm",lh:1.3,children:"Working with several files? Turn this conversation into a project."}),(0,n.jsxs)(o.Group,{gap:4,wrap:"nowrap",children:[(0,n.jsx)(s.Button,{size:"compact-xs",variant:"light",color:"teal",onClick:E,loading:j,children:"Create project"}),(0,n.jsx)(l.Tooltip,{label:"Dismiss",children:(0,n.jsx)(u.ActionIcon,{size:"xs",variant:"subtle",color:"teal",onClick:()=>S(!0),"aria-label":"Dismiss project suggestion",children:(0,n.jsx)(m.A,{size:"0.75rem"})})})]})]})})})},70670:(e,t,r)=>{"use strict";r.d(t,{$L:()=>tp,$Q:()=>h,$R:()=>tO,$c:()=>tw,A5:()=>eE,Ag:()=>Z,Al:()=>b,Bg:()=>el,Bm:()=>e4,Bp:()=>eg,C8:()=>eM,CJ:()=>ts,CR:()=>th,Cl:()=>tS,Dx:()=>L,E6:()=>eU,F9:()=>m,FL:()=>et,FW:()=>eb,FY:()=>tU,Fu:()=>P,GA:()=>ey,GN:()=>A,GY:()=>I,GZ:()=>ep,Gc:()=>tA,Gr:()=>y,Gt:()=>eH,H8:()=>e$,HD:()=>e_,HG:()=>_,HI:()=>W,I3:()=>p,IJ:()=>t$,Iz:()=>ex,JK:()=>tV,JL:()=>ec,KM:()=>e5,Kb:()=>e8,L0:()=>eP,L3:()=>ee,LU:()=>$,LZ:()=>tf,Le:()=>td,M:()=>x,MF:()=>ti,MR:()=>N,MY:()=>s,N$:()=>tq,N5:()=>eD,NB:()=>K,No:()=>eJ,Nw:()=>eX,O3:()=>J,OB:()=>l,OC:()=>ef,PY:()=>R,Ps:()=>tD,Px:()=>T,Q$:()=>tW,Q7:()=>eF,QZ:()=>eZ,Qf:()=>eq,R9:()=>v,RP:()=>tT,S8:()=>D,SF:()=>ta,SS:()=>tu,SX:()=>ej,SZ:()=>tF,Sp:()=>tC,T7:()=>e2,TS:()=>c,VC:()=>eT,VV:()=>eR,Vx:()=>tj,W5:()=>eL,WC:()=>tm,WE:()=>tl,WQ:()=>tR,WT:()=>eK,Xe:()=>G,Xr:()=>ei,Xx:()=>ew,YL:()=>eI,YQ:()=>F,Yi:()=>z,Yq:()=>es,Z:()=>tt,_9:()=>e7,_M:()=>tL,_m:()=>eC,a5:()=>tN,a9:()=>eo,ag:()=>tP,bR:()=>i,c5:()=>eA,cL:()=>eO,cV:()=>te,c_:()=>eQ,ch:()=>eW,cu:()=>tz,d5:()=>eS,eJ:()=>Q,f3:()=>eV,fc:()=>o,fg:()=>H,g:()=>tv,gS:()=>tn,gm:()=>tk,gp:()=>g,h8:()=>j,hI:()=>S,hP:()=>n,hg:()=>t_,ho:()=>d,i1:()=>eB,i5:()=>eu,iK:()=>eh,ib:()=>E,ik:()=>eY,iy:()=>tx,jg:()=>ea,jm:()=>f,jq:()=>e9,kr:()=>u,lJ:()=>e0,mK:()=>C,mZ:()=>ty,nC:()=>tc,nU:()=>tM,o9:()=>O,oP:()=>V,ol:()=>e3,px:()=>ev,qE:()=>ek,r8:()=>X,sM:()=>ed,se:()=>tE,sw:()=>to,sz:()=>tg,t$:()=>tI,t4:()=>e1,tu:()=>tG,u9:()=>M,uU:()=>U,vA:()=>eG,vy:()=>er,wT:()=>B,wq:()=>Y,ww:()=>em,xC:()=>tB,yB:()=>tb,yD:()=>
1tr,yR:()=>k,yU:()=>e6,yo:()=>w,yt:()=>eN,zI:()=>a,zL:()=>q,zj:()=>ez,zv:()=>en}),r(74944),r(49373),r(54962),r(37758);var n="_14d4mrs2",i="_14d4mrs3",o="_14d4mrs4",a="_14d4mrso",s="_14d4mrsp",l="_14d4mrsr",u="_14d4mrsq",d="_14d4mrsz",c="_14d4mrs10",m="_14d4mrs11",p="_14d4mrsj",h="_14d4mrs1p",g="_14d4mrs1n",f="_14d4mrs1o",v="_14d4mrs1i",x="_14d4mrs1m",b="_14d4mrs1r",w="_14d4mrs1j",y="_14d4mrs1s",S="_14d4mrs1q",j="_14d4mrs1h",k="_14d4mrs1l",T="_14d4mrs1t",C="_14d4mrs1k",_="_14d4mrs4b",P="_14d4mrs4f",E="_14d4mrs4d",D="_14d4mrs4e _14d4mrs4d",A="_14d4mrs4a",M="_14d4mrs4c",I="_14d4mrs4h",R="_14d4mrs4i",L="_14d4mrs4m",F="_14d4mrs4l",z="_14d4mrs4v _14d4mrs4t",N="_14d4mrs4u _14d4mrs4t",U="_14d4mrs45",B="_14d4mrs46",V="_14d4mrs47",W="_14d4mrs49",O="_14d4mrs3z _14d4mrs3y",q="_14d4mrs40 _14d4mrs3y",G="_14d4mrs3v",$="_14d4mrs3f",Y="_14d4mrs3l",H="_14d4mrs3g",Q="_14d4mrs3k",K="_14d4mrs3j",J="_14d4mrs3o",X="_14d4mrs3t",Z="_14d4mrs3s",ee="_14d4mrs3u",et="_14d4mrs3r",er="_14d4mrs3m",en="_14d4mrs3i",ei="_14d4mrs3h",eo="_14d4mrs4j",ea="_14d4mrs4k",es="_14d4mrs51 _14d4mrs4z",el="_14d4mrs52 _14d4mrs4z",eu="_14d4mrs50 _14d4mrs4z",ed="_14d4mrs4y",ec="_14d4mrs3x",em="_14d4mrs3w",ep="_14d4mrs4n",eh="_14d4mrs4r _14d4mrs4p",eg="_14d4mrs4s _14d4mrs4p",ef="_14d4mrs4q _14d4mrs4p",ev="_14d4mrs4o",ex="_14d4mrs3n",eb="_14d4mrs3e",ew="_14d4mrs4g",ey="_14d4mrs3p",eS="_14d4mrs3q",ej="_14d4mrs4x",ek="_14d4mrs4w",eT="_14d4mrs48",eC="_14d4mrsu",e_="_14d4mrss",eP="_14d4mrsn",eE="_14d4mrst",eD="_14d4mrs2v",eA="_14d4mrs2u",eM="_14d4mrs2t",eI="_14d4mrs2s",eR="_14d4mrs2m",eL="_14d4mrs2r",eF="_14d4mrs2n",ez="_14d4mrs2l",eN="_14d4mrs2q",eU="_14d4mrs2o",eB="_14d4mrs34",eV="_14d4mrs37",eW="_14d4mrs35",eO="_14d4mrs38",eq="_14d4mrs3b",eG="_14d4mrs39",e$="_14d4mrs3a",eY="_14d4mrs3c",eH="_14d4mrs53",eQ="_14d4mrs3d",eK="_14d4mrs2x",eJ="_14d4mrs32",eX="_14d4mrs2y",eZ="_14d4mrs2w",e0="_14d4mrs33",e1="_14d4mrs30",e4="_14d4mrs2z",e5="_14d4mrs31",e2="_14d4mrs5",e3="_14d4mrs6",e6="_14d4mrs8",e8="_14d4mrs7 _14d4mrs2",e7="_14d4mrsb _14d4mrsa",e9="_14d4mrsd",te="_14d4mrsc _14d4mrsa",tt="_14d4mrs9",tr="_14d4mrsl",tn="_14d4mrsk",ti="_14d4mrsm",to="_14d4mrs23",ta="_14d4mrs22",ts="_14d4mrs21",tl="_14d4mrs24",tu="_14d4mrs20",td="_14d4mrs1v",tc="_14d4mrs1z",tm="_14d4mrs1w",tp="_14d4mrs1u",th="_14d4mrs1y",tg="_14d4mrs1x",tf="_14d4mrsx",tv="_14d4mrsy",tx="_14d4mrsw",tb="_14d4mrsf",tw="_14d4mrse",ty="_14d4mrsg",tS="_14d4mrsh",tj="_14d4mrsi",tk="_14d4mrs2f",tT="_14d4mrs2e",tC="_14d4mrs2d",t_="_14d4mrs27",tP="_14d4mrs2c",tE="_14d4mrs28",tD="_14d4mrs2g",tA="_14d4mrs2h",tM="_14d4mrs26",tI="_14d4mrs2j",tR="_14d4mrs2i",tL="_14d4mrs2b",tF="_14d4mrs29",tz="_14d4mrs1e",tN="_14d4mrs1a",tU="_14d4mrs1d",tB="_14d4mrs1c",tV="_14d4mrs16",tW="_14d4mrs19",tO="_14d4mrs1b",tq="_14d4mrs15",tG="_14d4mrs17",t$="_14d4mrs18"},76728:(e,t,r)=>{"use strict";r.d(t,{DX:()=>s,xO:()=>l});var n=r(26550),i=r(8643),o=r(73321),a=r(12115);let s=e=>{let t=(0,o.useSearchParams)(),r=(0,i.iS)(null==t?void 0:t.toString()),s=Number(e),l=Number.isFinite(s)&&s>0?s:null,[u,d]=(0,a.useState)({conversationRowId:null,isProjectChat:!1});return((0,a.useEffect)(()=>{let e=!1;return null!==r?void d({conversationRowId:null,isProjectChat:!1}):null===l?void d({conversationRowId:l,isProjectChat:!1}):(n.projectConversationsTable.where("conversationId").equals(l).first().then(t=>{e||d({conversationRowId:l,isProjectChat:!!t})}).catch(()=>{e||d({conversationRowId:null,isProjectChat:!1})}),()=>{e=!0})},[l,r]),null!==r)?"project":null===l?"non-project":u.conversationRowId!==l?"resolving":u.isProjectChat?"project":"non-project"},l=e=>{let t=(0,o.useSearchParams)(),r=(0,i.iS)(null==t?void 0:t.toString()),s=Number(e),l=Number.isFinite(s)&&s>0?s:null,u=null!==r?"project:".concat(r):null!==l?"conversation:".concat(l):null,[d,c]=(0,a.useState)({lookupKey:null,status:"not-isolated"});return((0,a.useEffect)(()=>{let e=!1;return null===u?void c({lookupKey:null,status:"not-isolated"}):((async()=>{try{let t=r;if(null===t&&null!==l){let r=await n.projectConversationsTable.where("conversationId").equals(l).first(),i=Number(null==r?void 0:r.projectId);if(!Number.isFinite(i)||i<=0){e||c({lookupKey:u,status:"not-isolated"});return}t=i}if(null===t){e||c({lookupKey:u,status:"not-isolated"});return}let i=await n.projectsTable.get(t),o=Number.isFinite(Number(null==i?void 0:i.id));e||c({lookupKey:u,status:o&&(null==i?void 0:i.isolationMode)===!1?"not-isolated":"isolated"})}
1catch(t){e||c({lookupKey:null,status:"not-isolated"})}})(),()=>{e=!0})},[l,u,r]),null===u)?"not-isolated":d.lookupKey!==u?"resolving":d.status}},77558:(e,t,r)=>{"use strict";r.d(t,{Gq:()=>_,Lj:()=>v,QO:()=>w,XF:()=>E,oZ:()=>k,p_:()=>P,rM:()=>D,tB:()=>g,uz:()=>C,vf:()=>y,wB:()=>T});var n=r(37607),i=r(93541),o=r(23251),a=r(28357),s=r(57348),l=r(53839),u=r(42097),d=r(9716),c=r(57527),m=r(52507),p=r(20695),h=r(87358);[...n.vi,n.YW,m.ui,p.Hd,s.kw,u.HC,u.De,...d.oY,...o.xo,a.qU,...i.Dp,...l.WAVESPEED_MUREKA_MODEL_CONFIGS.map(e=>e.id)];let g={[n.UA]:{rate:.01,min:0,minDuration:5,maxDuration:300},[n.Bf]:{rate:.0125,min:.75,minDuration:3,maxDuration:600,billingIntervalSeconds:60,billingIntervalLabel:"started minute"},[n.II]:{rate:.0125,min:.75,minDuration:3,maxDuration:600,billingIntervalSeconds:60,billingIntervalLabel:"started minute"},[n.YW]:{rate:.002,min:0,minDuration:.5,maxDuration:22},"ACE-Step-v1.5-Base":{rate:15e-5,min:0,minDuration:1,maxDuration:300},"ACE-Step-v1.5-Turbo":{rate:1e-4,min:0,minDuration:1,maxDuration:300},"Minimax-Music-02":{rate:0,min:.05,minDuration:10,maxDuration:300},"Minimax-Music-2.5":{rate:0,min:.15,minDuration:10,maxDuration:300},"Minimax-Music-2.6":{rate:0,min:.15,minDuration:10,maxDuration:300},[m.ui]:{rate:0,min:m.oh,minDuration:0,maxDuration:0,fixedPrice:!0,fixedLabel:"run",fixedDecimals:2},"minimax/music-cover":{rate:0,min:.15,minDuration:6,maxDuration:360},"Wavespeed-ACE-Step":{rate:4e-4,min:.05,minDuration:5,maxDuration:240},"ACE-Step-1.5":{rate:4e-4,min:.05,minDuration:5,maxDuration:240},"Wavespeed-HeartMuLa":{rate:0,min:.1,minDuration:10,maxDuration:300},"google/lyria-3-pro/music":{rate:0,min:.08,minDuration:10,maxDuration:300},[p.Hd]:{rate:0,min:p.MS,minDuration:0,maxDuration:0,fixedPrice:!0,fixedLabel:"run",fixedDecimals:2},[s.kw]:{rate:0,min:s.Vc,minDuration:0,maxDuration:0,fixedLabel:"300-char block"},[u.HC]:{rate:u.KQ,min:u.KQ,minDuration:u.lx,maxDuration:u.Rw},[u.De]:{rate:u.Id,min:u.Id,minDuration:u.lx,maxDuration:u.Rw},[d.p8]:{rate:0,min:d.OZ,minDuration:0,maxDuration:0,fixedPrice:!0,fixedLabel:"run",fixedDecimals:2},[d.RM]:{rate:0,min:d._n,minDuration:0,maxDuration:0,fixedPrice:!0,fixedLabel:"run",fixedDecimals:2},[a.qU]:{rate:a.nC,min:a.nC,minDuration:1,maxDuration:a.uO},[i.Ew]:{rate:i.Fj,min:i.Fj,minDuration:i.kf,maxDuration:i.Uq,outputMultiplierParam:"num_samples",outputMultiplierMin:1,outputMultiplierMax:i.nM},[i.$G]:{rate:i.Fj,min:i.Fj,minDuration:i.kf,maxDuration:i.jj,outputMultiplierParam:"num_samples",outputMultiplierMin:1,outputMultiplierMax:i.nM},[i.Um]:{rate:i.Fj,min:i.Fj,minDuration:i.kf,maxDuration:i.h_,outputMultiplierParam:"num_samples",outputMultiplierMin:1,outputMultiplierMax:i.nM},...Object.fromEntries(o.xo.map(e=>[e,{rate:0,min:o.Lk[e],minDuration:0,maxDuration:0,fixedPrice:!0,fixedLabel:"audio",fixedDecimals:4}])),...Object.fromEntries(l.WAVESPEED_MUREKA_MODEL_CONFIGS.map(e=>{var t;return[e.id,{rate:0,min:e.basePriceUsd,minDuration:0,maxDuration:0,fixedPrice:!0,fixedLabel:e.priceMultiplierParam?"item":"run",fixedDecimals:null!=(t=e.fixedDecimals)?t:e.basePriceUsd<.01?3:2,...e.priceMultiplierParam?{countParam:e.priceMultiplierParam}:{}}]}))},f=new Set(["Minimax-Music-02","Minimax-Music-2.5","Minimax-Music-2.6",m.ui,"minimax/music-cover","Wavespeed-HeartMuLa","google/lyria-3-pro/music",p.Hd,s.kw,...d.oY,...o.xo,...l.WAVESPEED_MUREKA_MODEL_CONFIGS.map(e=>e.id)]);function v(e){let t=Number(e);return Number.isFinite(t)?Math.min(3,Math.max(1,Math.floor(t))):1}function x(e){let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function b(e,t,r){return Math.min(r,Math.max(t,e))}function w(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:g[e],o=arguments.length>3?arguments[3]:void 0;if(!r)return null;if(e===s.kw){var d,c;let e=Number(null!=(c=null!=(d=null==o?void 0:o.promptCharCount)?d:(e=>{for(let t of["prompt","text","input"]){let r=e[t];if("string"==typeof r)return r.length}return null})(t))?c:1);return Math.ceil((Number.isFinite(e)?Math.max(1,Math.floor(e)):1)/s.lE)*s.Vc}let m=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:g[e],n=l.WAVESPEED_MUREKA_MODEL_CONFIG_BY_ID[e];if(n){let r=function(e,t){var r;let n=null==(r=g[e])?void 0:r.countParam;return n?v(t[n]):1}(e,t);return n.basePriceUsd*r}return(null==r?void 0:r.fixedPrice)?r.min:null}(e,t,r);if("number"==typeof m)return m;let p=function(e,t){var r,o,a,s,l,u,d,c,m,p;if((0,n.bt)(e))return(0,n.ao)(e,t);if(e===i.Ew)return null!=(r=x(t.duration))?r:i.R9;if(e===i.$G)return null!=(s=x(null!=(a=null!=(o=t.append_duration)?o:t.appendDuration)?a:t.duration))?s:i.R9;if(e===i.Um){let e=null!=(u=null!=(l=t.start_s)?l:t.start_time)?u:t.startTime,r=null!=(c=null!=(d=t.end_s)?d:t.end_time)?c:t.endTime,n=b(null!=(m=x(e))?m:i.jg,0,10);return Math.max(0,b(null!=(p=x(r))?p:i.ud,0,10)-n)}return t.duration}(e,t),h=function(e,t,r){if((0,n.bt)(e))return(0,n.ao)(e,{duration:t});let o=f.has(e)?r.minDuration:t;if(e===u.HC||e===u.De||e===a.qU||(0,i.BS)(e)){let e=Number(null!=o?o:r.minDuration);return Math.min(r.maxDuration,Math.max(r.minDuration,Math.ceil(Number.isFinite(e)?e:r.minDuration)))}let s=Number(null!=o?o:r.minDuration);return Math.min(r.maxDuration,Math.max(r.minDuration,Math.floor(Number.isFinite(s)?s:r.minDuration)))}(e,p,r),w=r.billingIntervalSeconds?Math.ceil(h/r.billingIntervalSeconds)*r.billingIntervalSeconds:h,y=function(e,t){var r;if(!(0,i.BS)(e))return 1;let n=Number(null!=(r=t.num_samples)?r:t.numSamples);return Number.isFinite(n)?Math.min(i.nM,Math.max(1,Math.floor(n))):1}(e,t);return Math.max(r.min,w*r.rate)*y}let y=13,S={"gemini-2.5-flash-preview-tts":{inputRatePerThousand:5e-4,outputRatePerThousand:.01},"gemini-2.5-pro-preview-tts":{inputRatePerThousand:.001,outputRatePerThousand:.02},"gemini-3.1-flash-tts-preview":{inputRatePerThousand:.001,outputRatePerThousand:.02}};function j(e){let t=e?Number(e):NaN;return Number.isFinite(t)&&t>0?t:null}function k(e,t){var r,n;return r=e.costPerMinute,n={alreadyIncludesProfit:e.costIncludesProfit,fallbackProfitPercentage:null==t?void 0:t.fallbackProfitPercentage},!Number.isFinite(r)||r<0?0:(null==n?void 0:n.alreadyIncludesProfit)?r:r*(1+function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.7,t=parseFloat("0.7");return Number.isFinite(t)?t:e}(null==n?void 0:n.fallbackProfitPercentage))}function T(e,t){var r,n,i,o;let a=null!=(r=null==t?void 0:t.visibility)?r:"public";return"qwen-voice-clone"===e?null!=(n="server"===a?j(h.env.QWEN_VOICE_CLONE_COST_USD):j(h.env.NEXT_PUBLIC_QWEN_VOICE_CLONE_COST_USD))?n:.25:"inworld-voice-clone"===e?null!=(i="server"===a?j(h.env.INWORLD_VOICE_CLONE_COST_USD):j(h.env.NEXT_PUBLIC_INWORLD_VOICE_CLONE_COST_USD))?i:1:"omnivoice-voice-clone"===e&&null!=(o="server"===a?j(h.env.OMNIVOICE_VOICE_CLONE_COST_USD):j(h.env.NEXT_PUBLIC_OMNIVOICE_VOICE_CLONE_COST_USD))?o:1}function C(e){return e.startsWith("gpt-4o-mini-tts")}function _(e){return e in S}function P(e){return _(e)?S[e]:null}function E(e,t){let r="string"==typeof t?t.trim():"";return r?e+(0,c.gk)(r)+2:e}function D(e){let t=e>0?Math.max(1,Math.ceil(e/4)):0;return{inputTokens:t,outputTokens:12*t}}},84464:(e,t,r)=>{"use strict";r.d(t,{VO:()=>
1o});var n=r(12115),i=r(12395);let o=e=>{let t=(0,i.U)("(hover: hover) and (pointer: fine)",!1,{getInitialValueInEffect:!0}),r=(0,i.U)("(pointer: coarse)",!1,{getInitialValueInEffect:!0}),o=(()=>{let[e,t]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let e=window.visualViewport,r=()=>t((()=>{let e=window.visualViewport;return!!e&&!(e.scale>1.02)&&window.innerHeight-e.height>120})());if(r(),e)return e.addEventListener("resize",r),e.addEventListener("scroll",r),()=>{e.removeEventListener("resize",r),e.removeEventListener("scroll",r)}},[]),e})();return!0!==r&&!o&&(!0===t||!0===e)}},85567:(e,t,r)=>{"use strict";r.d(t,{g:()=>n});let n=2e6},86499:(e,t,r)=>{"use strict";r.d(t,{y:()=>n});let n=async e=>{let{projectId:t,libraryIds:r,projectLibraryTable:n,syncProjectSemanticIndexForAddedFiles:i,logger:o=console}=e,a=Array.from(new Set(r.filter(e=>Number.isFinite(e)&&e>0)));return!Number.isFinite(t)||t<=0||0===a.length?[]:(await n.where("[projectId+libraryId]").anyOf(a.map(e=>[t,e])).delete(),await n.bulkAdd(a.map(e=>({projectId:t,libraryId:e}))),i(t,a).catch(e=>{o.warn("[ProjectUpload] Failed to sync semantic index for uploaded project files",{projectId:t,libraryIds:a,error:e})}),a)}},89869:(e,t,r)=>{"use strict";r.d(t,{z:()=>d});var n=r(12115),i=r(65579);let o="data:image/svg+xml,".concat(encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none"><circle cx="32" cy="32" r="30" fill="'.concat("#6e84a3",'"/><path d="M18 33.5L27.5 43L46 24.5" stroke="white" stroke-width="7" stroke-linecap="round" stroke-linejoin="round"/></svg>'))),a=null,s=new Map,l=(e,t)=>void 0!==e.id?String(e.id):void 0!==e.timestamp?"ts-".concat(e.timestamp):"idx-".concat(t),u=e=>{if(!e||"assistant"!==e.role||e.hasError)return null;if(e.videoStatus){if("completed"!==e.videoStatus)return null;let t=e.videoUrl||e.videoUrls&&e.videoUrls[0]||"";return{key:"video:".concat(e.videoStatus,":").concat(t),type:"video"}}if(e.videoUrls&&e.videoUrls.length>0||e.videoUrl){let t=e.videoUrl||e.videoUrls&&e.videoUrls[0]||"";return{key:"video:ready:".concat(t),type:"video"}}let t=e.images&&e.images.length||0;if(t>0)return{key:"image:".concat(t),type:"image"};if(e.audioUrls&&e.audioUrls.length>0||e.audioUrl){var r;let t=(null==(r=e.audioUrls)?void 0:r.join(","))||e.audioUrl||"";return{key:"audio:".concat(t),type:"audio"}}let n="string"==typeof e.prompt&&e.prompt.trim().length>0?e.prompt:"string"==typeof e.content?e.content:"";if(n&&n.trim().length>0){let e=n.trim();return{key:"text:".concat(e.length,":").concat(e.slice(0,40)),type:"text"}}return null},d=(e,t)=>{let{notificationsEnabled:r,hapticFeedbackEnabled:d=!0,completionSound:c,completionSoundVolume:m,conversationSlug:p,isStreaming:h,isPending:g}=t,f=(0,n.useRef)(new Map),v=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{v.current!==p&&(f.current.clear(),v.current=p)},[p]);let x=(0,n.useCallback)((e,t)=>{if((()=>{if("undefined"==typeof document)return;let e=Array.from(document.querySelectorAll('link[rel*="icon"]'));0!==e.length&&(e.forEach(e=>{s.has(e)||s.set(e,e.href),e.href=o}),a&&clearTimeout(a),a=setTimeout(()=>{s.forEach((e,t)=>{t.isConnected&&(t.href=e)}),s.clear(),a=null},3e3))})(),d&&"vibrate"in window.navigator)try{window.navigator.vibrate(35)}catch(e){}let n="undefined"!=typeof document&&("visible"!==document.visibilityState||"function"==typeof document.hasFocus&&!document.hasFocus());if(n&&c&&"off"!==c&&(0,i.n$)(c,m),!r||!n||!("Notification"in window))return;let l="string"==typeof e.prompt?e.prompt:"",u="string"==typeof e.content?e.content:"",p=(e=>e?e.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,120):"")(l||u),h="Response ready",g=p||"Your AI response is ready.";switch(t){case"image":h="Images ready",p||(g="Your generated images are ready to view.");break;case"video":h="Video ready",p||(g="Your generated video is ready to review.");break;case"audio":h="Audio ready",p||(g="Your generated audio is ready.");break;default:h="Response ready",p||(g="Your AI response is ready.")}let f=void 0!==e.id?"conversation-response-".concat(e.id):void 0!==e.timestamp?"conversation-response-ts-".concat(e.timestamp):"conversation-response-".concat(Date.now()),v=()=>{let e={body:g,icon:"/icons/icon-192x192.png",badge:"/icons/icon-192x192.png",tag:f,renotify:!1,silent:!0,data:{url:window.location.href}},t=!1,r=()=>{if(!t){t=!0;try{let t=new Notification(h,e);
1t.onclick=e=>{e.preventDefault();try{window.focus()}catch(e){}try{t.close()}catch(e){}}}catch(e){}}},n="serviceWorker"in navigator?navigator.serviceWorker:void 0;if(!n||!n.controller)return void r();(async()=>{try{let t=await n.getRegistration();if(!t||"function"!=typeof t.showNotification)return!1;return await t.showNotification(h,e),!0}catch(e){return!1}})().then(e=>{if(e){t=!0;return}r()}).catch(()=>{r()})};"granted"===Notification.permission?v():"default"===Notification.permission&&Notification.requestPermission().then(e=>{"granted"===e&&v()}).catch(()=>{})},[c,m,d,r]);(0,n.useEffect)(()=>{let t=f.current;if(0===e.length)return void t.clear();if(h||g)return;let r=null;for(let[o,a]of e.entries()){var n,i;let e=u(a),s=l(a,o);if(!e){t.delete(s);continue}t.get(s)!==e.key&&(t.set(s,e.key),(!r||(null!=(n=a.timestamp)?n:0)>=(null!=(i=r.message.timestamp)?i:0))&&(r={message:a,completionType:e.type}))}r&&x(r.message,r.completionType)},[g,h,e,x])}},90532:(e,t,r)=>{"use strict";r.d(t,{m:()=>a});var n=r(12115),i=r(85286),o=r(73508);function a(e){let[t,r]=(0,n.useState)(null);return(0,n.useEffect)(()=>{let e=()=>{r((0,o.Z6)())};e();let t=t=>{t.key===i.LocalStorageKeys.conversation_visibleModels&&e()};return window.addEventListener("storage",t),window.addEventListener("nanogpt:user-data-changed",e),()=>{window.removeEventListener("storage",t),window.removeEventListener("nanogpt:user-data-changed",e)}},[]),(0,n.useMemo)(()=>(0,o.ZY)(e,t),[t,e])}},93541:(e,t,r)=>{"use strict";r.d(t,{$G:()=>i,BS:()=>v,Dp:()=>g,Ew:()=>n,Fj:()=>a,R9:()=>s,Um:()=>o,Uq:()=>u,h_:()=>p,jg:()=>c,jj:()=>d,kf:()=>l,nM:()=>h,ud:()=>m});let n="mirelo-ai/sfx1.6/text-to-audio",i="mirelo-ai/sfx1.6/extend-audio",o="mirelo-ai/sfx1.6/inpaint-audio",a=.01,s=10,l=1,u=60,d=57,c=2,m=6,p=8,h=4,g=[n,i,o],f=new Set(g);function v(e){return"string"==typeof e&&f.has(e)}},94870:(e,t,r)=>{"use strict";r.d(t,{T:()=>d});var n=r(95155),i=r(46460),o=r(6584),a=r(37206),s=r(47965),l=r(6829);let u=(0,a.default)(()=>Promise.all([r.e(25430),r.e(3138),r.e(91121)]).then(r.bind(r,3138)).then(e=>e.AttachmentPreview),{loadableGenerated:{webpack:()=>[3138]},ssr:!1,loading:()=>null}),d=(0,l.PA)(()=>{let{conversation:e,ui:t}=(0,s.useStores)(),r=e.visibleComposerAttachmentIds;return r&&0!==r.length?(0,n.jsx)(i.Box,{mt:0,style:{width:t.isDesktop?t.inputWidth:"100%",maxWidth:"100%"},children:(0,n.jsx)(i.Box,{style:{overflowX:"auto",overflowY:"hidden"},children:(0,n.jsx)(o.Group,{justify:"flex-start",gap:"xs",wrap:"nowrap",w:"100%",px:12,py:4,children:r.map(e=>(0,n.jsx)(u,{attachmentId:e},String(e)))})})}):null})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.