1import{i as e}from"./chunk-aKtaBQYM.js";import{t}from"./react-C0UHVLsY.js";import{l as n,p as r,r as i,t as a}from"./api-BkRdTjYa.js";import{t as o}from"./jsx-runtime-BqYSgJeI.js";import{t as s}from"./button-BcCvYob3.js";import{t as c}from"./cn-DTl-8woF.js";import{t as l}from"./createLucideIcon-lmsWWbrx.js";import{S as u,_ as d,a as f,b as p,c as m,d as h,f as g,g as _,h as v,i as y,l as b,m as x,n as S,p as C,r as w,s as T,t as E,u as D,v as O}from"./format-rate-limit-errors-dxEI2873.js";import{t as ee}from"./link-2-BZmV7lXP.js";import{i as k,t as A}from"./landing-page-DETO0tF3.js";import{t as j}from"./x-BTL0hRJr.js";import{$ as M,An as N,Bt as te,F as P,Fn as F,G as I,Gt as L,Jt as R,Kt as z,Ln as B,M as V,N as H,On as U,Ot as W,P as ne,Pn as re,Un as ie,Vn as ae,Vt as G,W as oe,Wt as se,Yt as ce,at as K,bn as le,cn as q,it as J,j as ue,kn as de,ln as fe,mn as pe,nt as me,q as he,qt as ge,tt as Y,v as X,xn as _e,zn as ve,zt as ye}from"./index-Jdeyut1s.js";import{n as be,t as Z}from"./capture-DAkTeZT5.js";var xe=l(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Se=l(`puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),Q=e(t(),1),$=o(),Ce=`detailed-note:study-guard-promo-dismissed`,we=`https://chromewebstore.google.com/detail/detailed-note-study-guard/cjafkjikmackabcphoefdfcokgocpdie`,Te=`https://www.youtube-nocookie.com/embed/mXIUVbFrDbQ?autoplay=1&rel=0`,Ee=()=>{try{return window.localStorage.getItem(Ce)===`true`}catch{return!1}};function De({open:e}){return(0,$.jsx)(`div`,{className:`aspect-video w-full shrink-0 bg-black`,children:e?(0,$.jsx)(`iframe`,{className:`size-full`,src:Te,title:`GoodScores Study Guard demo`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share`,referrerPolicy:`strict-origin-when-cross-origin`,allowFullScreen:!0}):null})}function Oe({mobile:e=!1}){return(0,$.jsxs)(`div`,{className:e?`grid shrink-0 gap-3 px-4 pt-4 pb-[calc(env(safe-area-inset-bottom)+1rem)]`:`flex items-center justify-between gap-4 p-5 pt-1`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Free with a GoodScores account.`}),(0,$.jsxs)(`a`,{className:e?`inline-flex h-11 w-full items-center justify-center gap-1.5 rounded-full bg-foreground px-4 font-medium text-background text-sm hover:opacity-85`:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-foreground px-4 font-medium text-background text-xs hover:opacity-85`,href:we,target:`_blank`,rel:`noreferrer`,children:[`Add to Chrome`,(0,$.jsx)(N,{className:`size-3.5`})]})]})}function ke(){let[e,t]=(0,Q.useState)(null),[n,r]=(0,Q.useState)(!1),i=W();return(0,Q.useEffect)(()=>{t(Ee())},[]),e===!1?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`aside`,{className:`fixed inset-x-4 bottom-[calc(env(safe-area-inset-bottom)+1rem)] z-40 max-h-[calc(100dvh-env(safe-area-inset-top)-5rem)] overflow-y-auto rounded-2xl border bg-background p-3.5 text-left shadow-xl md:right-5 md:bottom-5 md:left-auto md:w-[340px] md:p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`grid size-10 shrink-0 place-items-center rounded-xl bg-foreground text-background`,children:(0,$.jsx)(Se,{className:`size-4`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-semibold text-sm`,children:`Meet Study Guard`}),(0,$.jsx)(`p`,{className:`mt-0.5 text-muted-foreground text-xs`,children:`A free Chrome extension from GoodScores`})]}),(0,$.jsx)(`button`,{type:`button`,className:`-mr-2 -mt-2 grid size-11 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground md:-mr-1 md:-mt-1 md:size-7`,onClick:()=>{try{window.localStorage.setItem(Ce,`true`)}finally{t(!0)}},"aria-label":`Dismiss Study Guard promotion`,children:(0,$.jsx)(j,{className:`size-3.5`})})]}),(0,$.jsx)(`p`,{className:`mt-3 text-sm leading-5`,children:`Block distracting sites during study sessions and capture useful sources without leaving your browser.`}),(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex h-11 min-w-30 flex-1 items-center justify-center gap-2 whitespace-nowrap rounded-full border px-3 font-medium text-sm hover:bg-muted md:h-9 md:px-4 md:text-xs`,onClick:()=>r(!0),children:[(0,$.jsx)(k,{className:`size-3.5 fill-current`}),`Watch demo`]}),(0,$.jsxs)(`a`,{className:`inline-flex h-11 min-w-30 flex-1 items-center justify-center gap-1.5 whitespace-nowrap rounded-full bg-foreground px-3 font-medium text-background text-sm hover:opacity-85 md:h-9 md:px-4 md:text-xs`,href:we,target:`_blank`,rel:`noreferrer`,children:[`Add to Chrome`,(0,$.jsx)(N,{className:`size-3.5`})]})]})]})]})}),i?(0,$.jsx)(L,{open:n,onOpenChange:r,children:(0,$.jsxs)(z,{className:`flex max-h-[90dvh] flex-col overflow-hidden`,children:[(0,$.jsxs)(R,{className:`shrink-0 px-4 pb-3`,children:[(0,$.jsx)(ce,{children:`See Study Guard in action`}),(0,$.jsx)(ge,{children:`Block distractions and send useful sources to GoodScores.`})]}),(0,$.jsx)(De,{open:n}),(0,$.jsx)(Oe,{mobile:!0})]})}):(0,$.jsx)(M,{open:n,onOpenChange:r,children:(0,$.jsxs)(Y,{className:`overflow-hidden p-0 sm:max-w-3xl`,children:[(0,$.jsxs)(J,{className:`p-5 pb-0`,children:[(0,$.jsx)(K,{children:`See Study Guard in action`}),(0,$.jsx)(me,{children:`Block distractions, run a focus session, and send useful sources to GoodScores.`})]}),(0,$.jsx)(De,{open:n}),(0,$.jsx)(Oe,{})]})})]}):null}var Ae=()=>{let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(0),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)([]),h=(0,Q.useRef)(null),g=(0,Q.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});f.current=e;
1let n=new AudioContext,i=n.createMediaStreamSource(e),o=n.createAnalyser();o.fftSize=256,i.connect(o),d.current=n,l(o);let c=new MediaRecorder(e);u.current=c,c.ondataavailable=e=>{e.data.size>0&&m.current.push(e.data)},c.onstop=()=>{let e=new Blob(m.current,{type:`audio/webm`});a(e),h.current&&=(h.current(e),null)},c.start(),t(!0),r(!1),s(0),p.current=setInterval(()=>{s(e=>e+1)},1e3)}catch(e){console.error(`Error starting recording:`,e)}},[]),_=(0,Q.useCallback)(n=>{u.current&&e&&(n&&(h.current=n),u.current.stop(),t(!1),r(!1),p.current&&=(clearInterval(p.current),null),f.current&&=(f.current.getTracks().forEach(e=>e.stop()),null),d.current&&=(d.current.close(),null),l(null))},[e]);return{recording:e,paused:n,audioBlob:i,analyserNode:c,duration:o,startRecording:g,stopRecording:_,pauseRecording:(0,Q.useCallback)(()=>{u.current&&e&&!n&&(u.current.pause(),r(!0),p.current&&=(clearInterval(p.current),null))},[e,n]),resumeRecording:(0,Q.useCallback)(()=>{u.current&&e&&n&&(u.current.resume(),r(!1),p.current=setInterval(()=>{s(e=>e+1)},1e3))},[e,n]),resetRecording:(0,Q.useCallback)(()=>{e&&_(),a(null),s(0),r(!1)},[e,_])}};function je({analyserNode:e,isPaused:t}){let n=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!e||!n.current)return;let r=n.current,i=r.getContext(`2d`);if(!i)return;let a=e.frequencyBinCount,o=new Uint8Array(a),s=0,c=()=>{if(t)return;e.getByteFrequencyData(o),i.clearRect(0,0,r.width,r.height);let n=r.width/a*2.5,l,u=0;for(let e=0;e<a;e++)l=o[e]/255*r.height,i.fillStyle=`rgba(156, 163, 175, 0.6)`,i.fillRect(u,r.height-l/2,n,l/2),u+=n+1;s=requestAnimationFrame(c)};return c(),()=>{cancelAnimationFrame(s)}},[e,t]),(0,$.jsx)(`canvas`,{ref:n,width:300,height:40,className:`h-full w-full`})}function Me({analyserNode:e,paused:t,onPause:n,onResume:r,onStop:i}){return(0,$.jsxs)(`div`,{className:`flex w-full items-center gap-4 px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,style:{height:`44px`},children:(0,$.jsx)(je,{analyserNode:e,isPaused:t})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>{t?r():n()},className:`rounded-lg bg-primary p-2 text-primary-foreground transition-colors hover:bg-primary/90`,"aria-label":t?`Resume recording`:`Pause recording`,children:t?(0,$.jsx)(k,{className:`h-4 w-4 fill-primary-foreground text-primary-foreground`}):(0,$.jsx)(xe,{className:`h-4 w-4 text-primary-foreground`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{i()},className:`rounded-lg bg-destructive p-2 text-destructive-foreground transition-colors hover:bg-destructive/90`,"aria-label":`Stop recording`,children:(0,$.jsx)(p,{className:`h-4 w-4 fill-white text-white`})})]})]})}function Ne({state:e,isDragActive:t,recording:n,paused:r,analyserNode:i,isSubmitting:a,textareaRef:o,fileInputRef:l,getItemLabel:d,onInputChange:f,onPaste:p,onKeyDown:m,onRemoveItem:h,onStartRecording:g,onStopRecording:_,onPauseRecording:v,onResumeRecording:y,onToggleResearchMode:b,onOpenYoutube:S,onOpenWebSource:C,folders:w,folderId:T,onFolderChange:E,onSubmit:D,onCancelSubmit:k}){let A=e.itemsToUpload.some(e=>e.type===`recording`);return(0,$.jsxs)(`div`,{className:c(`relative overflow-hidden rounded-3xl border border-border bg-muted/30 shadow-xs transition-colors`,t&&`border-primary bg-primary/5`),children:[A&&n&&(0,$.jsx)(Me,{analyserNode:i,paused:r,onPause:v,onResume:y,onStop:_}),e.itemsToUpload.length>0&&!n&&(0,$.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2 p-3 pb-2`,children:e.itemsToUpload.map(e=>(0,$.jsx)(x,{type:e.type,label:d(e),onRemove:()=>h(e.id),className:`max-w-[calc(100%-0.5rem)]`},e.id))}),!n&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 px-4 py-3`,children:[(0,$.jsx)(fe,{autoFocus:!0,ref:o,value:e.input,onChange:f,onPaste:p,onKeyDown:m,placeholder:e.itemsToUpload.length>0?`Add a prompt (optional)`:`Add a source first, then type your prompt here`,disabled:a||n,className:c(`field-sizing-content max-h-[200px] min-h-[64px] flex-1 resize-none overflow-auto border-none bg-transparent text-base shadow-none outline-none focus-visible:ring-0 focus-visible:ring-offset-0`,`[scrollbar-color:oklch(0.552_0.016_285.938/0.3)_transparent] [scrollbar-width:thin] hover:[scrollbar-color:oklch(0.552_0.016_285.938/0.5)_transparent]`,`dark:[scrollbar-color:oklch(0.705_0.015_286.067/0.3)_transparent] dark:hover:[scrollbar-color:oklch(0.705_0.015_286.067/0.5)_transparent]`,`[&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2`,`[&::-webkit-scrollbar-track]:bg-transparent`,`[&::-webkit-scrollbar-thumb]:rounded [&::-webkit-scrollbar-thumb]:bg-[oklch(0.552_0.016_285.938/0.3)] [&::-webkit-scrollbar-thumb]:transition-colors`,`dark:[&::-webkit-scrollbar-thumb]:bg-[oklch(0.705_0.015_286.067/0.3)] dark:hover:[&::-webkit-scrollbar-thumb]:bg-[oklch(0.705_0.015_286.067/0.5)]`,`hover:[&::-webkit-scrollbar-thumb]:bg-[oklch(0.552_0.016_285.938/0.5)]`,e.itemsToUpload.length>0&&`pt-2`),style:{fieldSizing:`content`}}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(ye,{children:[(0,$.jsx)(se,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:e=>e.stopPropagation(),disabled:a,className:`flex h-10 items-center gap-2 rounded-full px-3 text-sm font-medium transition-colors hover:bg-muted disabled:opacity-50`,"aria-label":`Add source`,children:[(0,$.jsx)(pe,{className:`size-4`}),(0,$.jsx)(`span`,{children:`Add source`})]})}),(0,$.jsxs)(te,{align:`start`,className:`w-56`,children:[(0,$.jsxs)(G,{onClick:e=>{e.stopPropagation(),l.current?.click()},children:[(0,$.jsx)(_e,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:`Upload files`})]}),(0,$.jsxs)(G,{onClick:e=>{e.stopPropagation(),g()},children:[(0,$.jsx)(u,{className:`mr-2 size-4`}),(0,$.jsx)(`span`,{children:`Record audio`})]}),(0,$.jsxs)(G,{onClick:e=>{e.stopPropagation(),S()},children:[(0,$.jsx)(O,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:`YouTube video`})]}),(0,$.jsxs)(G,{onClick:e=>{e.stopPropagation(),C()},children:[(0,$.jsx)(ee,{className:`mr-2 size-4`}),(0,$.jsx)(`span`,{children:`Web page or search`})]})]})]}),(0,$.jsxs)(ue,{value:T??`unfiled`,onValueChange:e=>E(e===`unfiled`?void 0:e),disabled:a,children:[(0,$.jsxs)(ne,{className:`w-auto max-w-44 rounded-full border-0 bg-transparent shadow-none hover:bg-muted`,"aria-label":`Choose folder`,children:[(0,$.jsx)(le,{className:`size-4`}),(0,$.jsx)(P,{placeholder:`No folder`})]}),(0,$.jsxs)(V,{align:`start`,children:[(0,$.jsx)(H,{value:`unfiled`,children:`No folder`}),w.map(e=>(0,$.jsx)(H,{value:e._id,children:e.name},e._id))]})]}),(0,$.jsx)(s,{type:`button`,title:e.researchMode?`Disable research mode`:`Enable research mode`,onClick:e=>{e.stopPropagation(),b()},className:c(`size-10 rounded-full p-2 text-xs`,e.researchMode?`bg-primary text-primary-foreground hover:bg-primary/90`:`hover:bg-accent hover:text-accent-foreground`),variant:e.researchMode?`default`:`outline`,"aria-label":`Toggle research mode`,children:(0,$.jsx)(U,{className:`size-4`})}),(0,$.jsxs)(oe,{children:[(0,$.jsx)(he,{asChild:!0,children:(0,$.jsx)(`span`,{className:`ml-auto inline-flex`,children:(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a?k():D()},disabled:!a&&e.itemsToUpload.length===0,className:c(`rounded-full bg-primary p-2 text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,e.itemsToUpload.length===0&&`opacity-50`),"aria-label":a?`Cancel upload`:`Submit`,children:a?(0,$.jsx)(j,{className:`size-4`}):(0,$.jsx)(de,{className:`size-4`})})})}),e.itemsToUpload.length===0&&(0,$.jsx)(I,{children:`Upload a source first`})]})]})]})]})}var Pe={input:``,itemsToUpload:[],isDragActive:!1,youtubeModalOpen:!1,researchMode:!1};function Fe(e,t){switch(t.type){case`set_input`:return{...e,input:t.value};case`set_items`:return{...e,itemsToUpload:t.value};case`update_items`:return{...e,itemsToUpload:t.updater(e.itemsToUpload)};case`set_drag_active`:return{...e,isDragActive:t.value};case`set_youtube_modal_open`:return{...e,youtubeModalOpen:t.value};case`toggle_research_mode`:return{...e,researchMode:!e.researchMode};case`clear_items`:return{...e,itemsToUpload:[]};default:return e}}function Ie(e,t,i,o,s,c,l,u){let d=ve(),[p,m]=(0,Q.useState)(!1),h=(0,Q.useRef)(0),g=(0,Q.useRef)(null),{processingState:_,processAndUploadFile:v,cancelProcessing:x}=T(),{uploadFile:S,cancelUploads:C}
1=y(),{mutateAsync:w}=ae({mutationFn:n(a.source.data.createChat)}),D=(0,Q.useCallback)(async({sources:e,prompt:n,hasRecording:a,signal:s})=>{try{let r=await w({sources:e,prompt:n||void 0,researchMode:l,folderId:u});if(s.aborted)return;i([]),t(``),a&&o(),B.success(`Processing begins now...`),d({to:`/chat/$id`,params:{id:r.chatId}})}catch(e){if(Z(`study_creation_failed`,{stage:`chat_creation`,error_name:q(e)}),be(e,`chat_creation`),re(e)){F(e);return}else e instanceof r&&e.data.kind===`RateLimited`?B.error(E(e.data)):(B.error(`Failed to create chat`),console.error(e))}},[w,l,u,i,t,o,d]),O=(0,Q.useCallback)(async(e,t)=>{if(e.type===`recording`){let n=new File([e.recordingBlob],`recording.wav`,{type:e.recordingBlob.type||`audio/webm`}),{compressedAudioBlob:r}=await B.promise(b.compressAudio(n,void 0,t),{loading:`Compressing recorded audio for Whisper...`,success:`Recording optimized for Whisper`,error:`Failed to compress recorded audio`}).unwrap();return t.throwIfAborted(),{type:`audio`,storageIds:[await S(new File([r],`recording.ogg`,{type:`audio/ogg`}),`audio/ogg`)],language:s,durationSeconds:e.duration||0}}return f(e,{uploadFile:S,processAndUploadFile:v,language:s})},[s,S,v]);return{handleSubmit:(0,Q.useCallback)(async t=>{if(t.length===0)return;Z(`study_creation_started`,{source_count:t.length,source_types:[...new Set(t.map(e=>e.type))].sort(),research_mode:l});let n=e.trim(),r=++h.current;g.current?.abort();let i=new AbortController;g.current=i,m(!0);try{let e=[];for(let n of t){if(i.signal.aborted||r!==h.current)return;let t=await O(n,i.signal);t&&e.push(t)}if(e.length===0){i.signal.aborted||(Z(`study_creation_failed`,{stage:`source_processing`,error_name:`NoSourcesProcessed`}),B.error(`Failed to process any uploads`));return}if(i.signal.aborted||r!==h.current)return;await D({sources:e,prompt:n,hasRecording:t.some(e=>e.type===`recording`),signal:i.signal})}catch(e){if(!i.signal.aborted&&r===h.current){if(F(e))return;console.error(`Submission error:`,e),Z(`study_creation_failed`,{stage:`source_processing`,error_name:q(e)}),be(e,`source_processing`),B.error(e instanceof DOMException&&e.name===`TimeoutError`?`Upload timed out`:`Failed to process upload`)}}finally{r===h.current&&(m(!1),g.current=null)}},[e,O,l,D]),promptTextRef:c,processingState:_,isSubmitting:p,cancelSubmission:(0,Q.useCallback)(()=>{h.current+=1,g.current?.abort(),g.current=null,x(),C(),m(!1),B.info(`Upload cancelled`)},[x,C])}}var Le=`auto`;function Re({folderId:e}){let t=ve({from:`/`}),{data:n=[]}=ie(i(a.folders.data.list,{})),[r,o]=(0,Q.useReducer)(Fe,Pe),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)(null),f=(0,Q.useRef)(``),{recording:p,paused:y,analyserNode:b,duration:x,startRecording:T,stopRecording:E,pauseRecording:O,resumeRecording:ee,resetRecording:k}=Ae(),A=(0,Q.useCallback)(e=>{o(typeof e==`function`?{type:`update_items`,updater:e}:{type:`set_items`,value:e})},[]),j=(0,Q.useCallback)(e=>{o({type:`set_input`,value:e})},[]),{handleFileDrop:N,handlePaste:te}=w(p,E,k,A),{handleSubmit:P,processingState:F,isSubmitting:I,cancelSubmission:L}=Ie(r.input,j,A,k,Le,f,r.researchMode,e),R=()=>{o({type:`clear_items`}),T(),o({type:`set_items`,value:[{type:`recording`,id:`recording-${d()}`,label:`Recording in progress...`,recordingBlob:new Blob,duration:0}]})},z=(0,Q.useCallback)(e=>{o({type:`update_items`,updater:t=>t.map(t=>t.id===e?(t.type===`recording`&&k(),null):t).filter(e=>e!==null)})},[k]),V=(0,Q.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),r.itemsToUpload.length>0&&P(r.itemsToUpload))},[P,r.itemsToUpload]),H=F.status!==`idle`,U=(0,Q.useCallback)(e=>{!e&&F.status!==`idle`&&B.warning(`Processing in progress`,{description:`Closing now will interrupt the process.`})},[F.status]),W=(0,Q.useCallback)(e=>e.type===`recording`&&e.duration!==void 0?`Recording (${m(x)})`:e.label,[x]);return(0,$.jsxs)(`div`,{className:`flex w-full max-w-[688px] flex-col gap-4`,children:[(0,$.jsx)(`input`,{ref:u,type:`file`,multiple:!0,accept:D,className:`hidden`,"aria-label":`Upload source files`,onChange:e=>{let t=e.target.files;t&&t.length>0&&(N(Array.from(t)),e.target.value=``)}}),(0,$.jsx)(v,{multiple:!0,accept:h,maxSize:g,onDrop:N,onDragEnter:()=>o({type:`set_drag_active`,value:!0}),onDragLeave:()=>o({type:`set_drag_active`,value:!1}),onDropAccepted:()=>o({type:`set_drag_active`,value:!1}),onDropRejected:()=>{o({type:`set_drag_active`,value:!1}),B.error(`Unsupported file type or file too large`)},disabled:I||p,children:({getRootProps:i,getInputProps:a})=>{let{onClick:s,...d}=i();return(0,$.jsxs)(`div`,{...d,className:`relative w-full`,children:[(0,$.jsx)(`input`,{...a()}),(0,$.jsx)(Ne,{state:r,isDragActive:r.isDragActive,recording:p,paused:y,analyserNode:b,isSubmitting:I,textareaRef:l,fileInputRef:u,getItemLabel:W,onInputChange:e=>o({type:`set_input`,value:e.target.value}),onPaste:te,onKeyDown:V,onRemoveItem:z,onStartRecording:R,onStopRecording:()=>{E(e=>{o({type:`update_items`,updater:t=>t.map(t=>
1t.type===`recording`?{type:`recording`,id:t.id,label:`Recorded`,recordingBlob:e,duration:x}:t)})})},onPauseRecording:O,onResumeRecording:ee,onToggleResearchMode:()=>o({type:`toggle_research_mode`}),onOpenYoutube:()=>o({type:`set_youtube_modal_open`,value:!0}),onOpenWebSource:()=>c(!0),folders:n,folderId:e,onFolderChange:e=>void t({to:`/`,search:{folderId:e}}),onSubmit:()=>void P(r.itemsToUpload),onCancelSubmit:L})]})}}),(0,$.jsx)(C,{open:s,onOpenChange:c,onSelect:e=>A(t=>[...t,e])}),(0,$.jsx)(S,{open:r.youtubeModalOpen,setOpen:e=>o({type:`set_youtube_modal_open`,value:typeof e==`function`?e(r.youtubeModalOpen):e}),onValidated:e=>{o({type:`update_items`,updater:t=>[...t,{type:`youtube`,id:`youtube-${d()}`,label:e.length>50?`${e.substring(0,50)}...`:e,youtubeUrl:e}]})}}),(0,$.jsx)(M,{open:H,onOpenChange:U,children:(0,$.jsxs)(Y,{className:`!max-w-[392px] !p-0 gap-0 overflow-hidden rounded-xl border border-border bg-background`,children:[(0,$.jsx)(J,{className:`p-0`,children:(0,$.jsx)(K,{className:`sr-only`,children:`Processing Audio/Video`})}),(0,$.jsx)(_,{currentStep:F.currentStep,totalSteps:F.totalSteps,completedSteps:F.completedSteps,currentStepProgress:F.currentStepProgress,currentStepName:F.currentStepName,currentSubstep:F.currentSubstep,uploadStats:F.uploadStats,onCancel:L})]})})]})}function ze({folderId:e}){return(0,$.jsxs)(`div`,{className:`flex min-h-[calc(100dvh-4rem)] flex-col items-center gap-y-5`,children:[(0,$.jsx)(`div`,{className:`flex w-full max-w-3xl grow flex-col gap-y-4 px-5 sm:px-8`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[727px] flex-col items-center justify-center pt-[18dvh] pb-12 text-center`,children:[(0,$.jsx)(`h2`,{className:`mb-2 font-medium text-foreground text-2xl tracking-tight sm:text-3xl`,children:`What do you want to learn?`}),(0,$.jsx)(`p`,{className:`mb-6 text-balance text-center text-sm text-muted-foreground`,children:`Upload a recording, video, document, YouTube link, or web page`}),(0,$.jsx)(Re,{folderId:e})]})}),(0,$.jsx)(ke,{})]})}var Be=()=>{let{isAuthenticated:e}=X.useRouteContext(),{folderId:t}=X.useSearch();return e?(0,$.jsx)(ze,{folderId:t}):(0,$.jsx)(A,{})};export{Be as component};
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.