PageSourceSearch

https://tidaltasks.app/_next/static/chunks/4309.52a4d101e588bf1c.js

js tidaltasks.app collected 2026-09-24 14:33:09 UTC 42,070 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4309],{10101:(e,t,a)=>{a.d(t,{V:()=>s});var r=a(12115);function s(){let[e,t]=(0,r.useState)(!1),[a,s]=(0,r.useState)(""),i=(0,r.useRef)(null),l=(0,r.useRef)(""),n=(0,r.useRef)("");return(0,r.useEffect)(()=>{let e=window.SpeechRecognition||window.webkitSpeechRecognition;if(!e)return void console.error("Speech recognition not supported in this browser.");let a=new e;a.continuous=!0,a.interimResults=!0,a.lang="en-US",a.onresult=e=>{var t,a,r;for(let t=0;t<e.results.length;++t)e.results[t][0].transcript;let i=Math.max(0,e.results.length-1),o=null!=(r=null==(a=e.results[i])||null==(t=a[0])?void 0:t.transcript)?r:"";n.current=((e,t)=>{if(!t)return e;if(!e)return t;if(t===e)return e;let a=Math.min(e.length,t.length),r=0;for(;r<a&&e[r]===t[r];)r+=1;if(t.length>=e.length&&r>=Math.floor(.6*a)||t.startsWith(e))return t;let s=Math.min(e.length,t.length);for(let a=s;a>0;a--)if(e.slice(-a)===t.slice(0,a))return e+t.slice(a);let i=!e.endsWith(" ")&&!t.startsWith(" ");return e+(i?" ":"")+t})(n.current,o),s(l.current+n.current)},a.onerror=e=>{console.error("Speech recognition error:",e.error)},a.onend=()=>{t(!1)},i.current=a},[]),{isRecording:e,transcript:a,startRecording:a=>{if(i.current&&!e){n.current="";let e=(null!=a?a:"").trim();e.length>0?l.current=e+" ":l.current="";try{i.current.start(),t(!0)}catch(e){console.error("Failed to start speech recognition:",e),t(!1)}}},stopRecording:()=>{i.current&&e&&(i.current.stop(),t(!1))}}}},33090:(e,t,a)=>{a.d(t,{V:()=>l,o:()=>i});var r=a(95155),s=a(9924);function i(e){let{size:t="md",color:a="blue",className:i=""}=e,l={sm:{height:"h-1",width:"w-1",gap:"gap-0.5"},md:{height:"h-1.5",width:"w-1.5",gap:"gap-1"},lg:{height:"h-2",width:"w-2",gap:"gap-1.5"}}[t],n={blue:"bg-blue-500",gray:"bg-gray-400"}[a],o={initial:{scaleY:.3,opacity:.7},animate:{scaleY:[.3,1,.3],opacity:[.7,1,.7]}};return(0,r.jsx)("div",{className:"flex items-center ".concat(l.gap," ").concat(i),children:[0,1,2].map(e=>(0,r.jsx)(s.P.div,{className:"".concat(l.width," ").concat(l.height," ").concat(n," rounded-full"),variants:o,initial:"initial",animate:"animate",transition:{duration:1.2,repeat:1/0,delay:.2*e,ease:"easeInOut"}},e))})}function l(e){let{className:t=""}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-2 ".concat(t),children:[(0,r.jsx)("span",{className:"text-sm text-gray-800 dark:text-slate-100",children:"Kai is thinking"}),(0,r.jsx)(i,{size:"sm",color:"blue"})]})}},34309:(e,t,a)=>{a.r(t),a.d(t,{Chatbar:()=>ee});var r=a(95155),s=a(40674),i=a(12507),l=a(12115),n=a(58186),o=a(85919),d=a(35963),c=a(3998),u=a(31120),m=a(64269),h=a(9924);let p=e=>{let{children:t,className:a,containerClassName:s,animate:i=!0,isError:l=!1}=e,n={initial:{backgroundPosition:"0 50%"},animate:{backgroundPosition:["0, 50%","100% 50%","0 50%"]}},o="bg-[radial-gradient(circle_farthest-side_at_0_100%,#ef4444,transparent),radial-gradient(circle_farthest-side_at_100%_0,#ef4444,transparent),radial-gradient(circle_farthest-side_at_100%_100%,#ef4444,transparent),radial-gradient(circle_farthest-side_at_0_0,#ef4444,#b91c1c)]",d="bg-[radial-gradient(circle_farthest-side_at_0_100%,#3b82f6,transparent),radial-gradient(circle_farthest-side_at_100%_0,#87ceeb,transparent),radial-gradient(circle_farthest-side_at_100%_100%,#1e40af,transparent),radial-gradient(circle_farthest-side_at_0_0,#000000,#111827)]";return(0,r.jsxs)("div",{className:(0,m.cn)("relative p-[4px] group",s),children:[(0,r.jsx)(h.P.div,{variants:i?n:void 0,initial:i?"initial":void 0,animate:i?"animate":void 0,transition:i?{duration:5,repeat:1/0,repeatType:"reverse"}:void 0,style:{backgroundSize:i?"400% 400%":void 0},className:(0,m.cn)("absolute inset-0 rounded-lg z-[1] opacity-70 group-hover:opacity-100 blur-xl transition duration-500 will-change-transform",l?o:d)}),(0,r.jsx)(h.P.div,{variants:i?n:void 0,initial:i?"initial":void 0,animate:i?"animate":void 0,transition:i?{duration:5,repeat:1/0,repeatType:"reverse"}:void 0,style:{backgroundSize:i?"400% 400%":void 0},className:(0,m.cn)("absolute inset-0 rounded-lg z-[1] will-change-transform",l?o:d)}),(0,r.jsx)("div",{className:(0,m.cn)("relative z-10",a),children:t})]})};
1var x=a(14285),g=a(5917),f=a(49745),b=a(52056),v=a(65229),y=a(39142),j=a(79397),k=a(18085),N=a(28446),w=a(16485),E=a(15239),A=a(65380),T=a(26497),S=a(20063),_=a(67763),C=a(2186),D=a(89712),M=a(99099),P=a(61456),R=a(36117),U=a.n(R),Y=a(63961);let K=e=>{let t=parseInt(e,10);return Number.isNaN(t)?60:5*Math.round(Math.max(15,Math.min(600,t))/5)},z=()=>({id:"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2),title:"",resources:"",duration:"60"}),L=e=>{let t=!1;return{value:e.split(/\r?\n/).map(e=>e.length>500?(t=!0,e.slice(0,500)):e).join("\n"),wasTruncated:t}},I=(e,t,a)=>{if(!e)return t;let r=U()(e),s=U()(t),i=U()(a);return r.isBefore(s)?t:r.isAfter(i)?a:e};function F(e){var t,a;let{isOpen:s,onClose:i,onSubmitPrompt:n}=e,o=U()().format("YYYY-MM-DD"),d=U()().add(2,"month").format("YYYY-MM-DD"),[m,p]=(0,l.useState)(""),[x,g]=(0,l.useState)(U()().add(1,"week").format("YYYY-MM-DD")),[f,b]=(0,l.useState)([z()]),[v,y]=(0,l.useState)(null),[j,k]=(0,l.useState)(null!=(a=null==(t=f[0])?void 0:t.id)?a:null),[N,w]=(0,l.useState)(!1),[E,A]=(0,l.useState)(null),[S,R]=(0,l.useState)(null),[F,H]=(0,l.useState)(!1),V=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(s){let e=z();p(""),g(U()().add(1,"week").format("YYYY-MM-DD")),b([e]),k(e.id),y(null),w(!1),A(null),R(null),H(!1)}},[s]);let O=(e,t,a)=>{let r=a;if("title"===t)a.length>200&&(r=a.slice(0,200));else if("resources"===t){let{value:e,wasTruncated:t}=L(a);r=e,t&&H(!0)}b(a=>a.map(a=>a.id===e?{...a,[t]:r}:a))},W=()=>{y(null),b(e=>{if(e.length>=25)return y("You can add up to ".concat(25," topics per study plan.")),e;let t=z();return k(t.id),[...e,t]})},B=(0,l.useCallback)(async e=>{if(e){if(e.size>0xc00000)return void A("That file is larger than 12MB. Please upload a smaller document or split it.");w(!0),A(null),R(null);try{var t,a;let r=new FormData;r.append("file",e),m.trim()&&r.append("subjectHint",m.trim()),x&&r.append("examDateHint",x);let s=await fetch("/api/study-plan/extract",{method:"POST",body:r}),i=await s.json().catch(()=>null);if(!s.ok)throw Error((null==i?void 0:i.error)||"Unable to understand that file. Try a clearer photo or PDF.");let l=Array.isArray(null==i?void 0:i.topics)?i.topics.map(e=>{let t=z(),a="number"==typeof(null==e?void 0:e.durationMinutes)?e.durationMinutes:void 0,r=K(String(null!=a?a:60)),s=(Array.isArray(null==e?void 0:e.resources)?e.resources:[]).filter(e=>"string"==typeof e&&e.trim().length>0);return{...t,title:"string"==typeof(null==e?void 0:e.title)?e.title.trim():"",resources:s.join("\n"),duration:String(r)}}):[],n=l.length?l:[z()];b(n),k(null!=(a=null==(t=n[0])?void 0:t.id)?a:null),"string"==typeof(null==i?void 0:i.subject)&&i.subject.trim()&&p(i.subject.trim()),"string"==typeof(null==i?void 0:i.examDate)&&i.examDate&&g(I(i.examDate,o,d));let c=(e=>{if(!(null==e?void 0:e.warningThreshold)||!e.currentUsage)return null;let t=e.currentUsage;if(t.monthlyLimit&&t.monthlyLimit>0){let e=Math.min(100,Math.round(t.aiTokens/t.monthlyLimit*100));return"Heads up: you've used ".concat(e,"% of your monthly AI plan (").concat(t.aiTokens.toLocaleString()," tokens).")}return"Heads up: you are approaching your monthly AI usage limit."})(null==i?void 0:i.usageInfo);c&&R(c),y(null)}catch(e){A(e instanceof Error?e.message:"Upload failed. Please try again.")}finally{w(!1)}}},[x,d,o,m]),q=()=>{var e;null==(e=V.current)||e.click()},$=f.some(e=>e.title.trim().length>0),G=!!(m.trim()&&x&&$);return s?(0,r.jsx)(T.N,{children:(0,r.jsx)(h.P.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:i,children:(0,r.jsxs)(h.P.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-white rounded-lg shadow-xl w-full max-w-3xl mx-auto dark:bg-slate-900 max-h-[90vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"px-6 py-4 border-b border-gray-100 flex items-center justify-between gap-3 dark:border-slate-800",children:[(0,r.jsxs)("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100",children:[(0,r.jsx)("span",{className:"sm:hidden",children:"Planner"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Kai Study Plan Builder"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)(c.$,{type:"button",variant:"outline",onClick:q,disabled:N,className:"gap-2 whitespace-nowrap lg:hidden",size:"2",children:[(0,r.jsx)(_.A,{className:"h-4 w-4"}),N?"Uploading…":"Upload outline"]}),(0,r.jsx)("input",{ref:V,className:"hidden",type:"file",accept:".pdf,.doc,.docx,image/*",onChange:e=>{var t;let a=null==(t=e.target.files)?void 0:t[0];a&&B(a),e.target.value=""}}),(0,r.jsx)("button",{type:"button",onClick:i,className:"text-gray-400 hover:text-gray-600 dark:text-gray-300 dark:hover:text-gray-100","aria-label":"Close modal",children:(0,r.jsx)(C.A,{className:"h-5 w-5"})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,r.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),y(null),f.length>25)return void y("You can add up to ".concat(25," topics per study plan."));let t=m.trim().slice(0,200);if(m.trim().length>200)return void y("Keep the study plan name under ".concat(200," characters."));for(let e of f){if(e.title.trim().length>200)return void y("Each topic title must be ".concat(200," characters or fewer."));if(e.resources.split(/\r?\n/).some(e=>e.trim().length>500))return void y("Each study resource entry must be ".concat(500," characters or fewer."))}let a=f.slice(0,25).map(e=>({title:e.title.trim().slice(0,200),resources:L(e.resources).value,durationMinutes:K(e.duration)})).filter(e=>e.title.length>0);if(!t)return void y("Add the subject or exam name.");if(0===a.length)return void y("Add at least one topic with its study resources.");let r=I(x,o,d);r!==x&&g(r);let s=U()(r).format("MMMM D, YYYY"),l=a.reduce((e,t)=>e+t.durationMinutes,0),c=a.map((e,t)=>{let a=e.resources?"\n   - Study Resources:\n".concat(e.resources.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>"     • ".concat(e)).join("\n")):"";return"".concat(t+1,". ").concat(e.title,"\n   - Target Minutes: ").concat(e.durationMinutes).concat(a)}).join("\n\n");n(["Subject: ".concat(t),"Exam Date: ".concat(s),"Total Requested Study Time: ".concat(l," minutes"),"\nScheduling Mission:\n- Transform this breakdown into a Kai-grade study plan that hits every requested minute before the exam (spaced out optimally).\n- CRITICAL: Incorporate spaced repetition. Revision sessions must be present throughout the scheduling window, ending with a final review right before the exam date.\n- If total study time is minimal compared to the available time, shift the start date later (closer to the exam) so the material is fresh. Do not finish all studying weeks in advance.\n- The goal is that at the time of the exam, the user is as effectively prepped as possible.\n- Keep each topic at its requested minutes (feel free to split a topic into multiple sessions).\n- Recommend the most relevant study hack(s) for a covered topic in a session using the user’s activated list.\n- Ensure study resources are added to the description of the study session.\n- Ensure the full schedule finishes before the exam date and totals the requested minutes, and each study session has the appropriate deadline (exam date).\n\nTopic Breakdown:",c].join("\n").trim()),i()},className:"p-6 space-y-6 dark:bg-slate-900",children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"space-y-2",children:(0,r.jsx)("input",{type:"text",value:m,onChange:e=>p(e.target.value),placeholder:"Name (e.g. AP Biology Midterm)",className:"w-full text-lg font-semibold bg-transparent border border-gray-200 dark:border-slate-700 rounded-lg px-4 py-3 focus:outline-none focus:ring-2 focus:ring-sky-500 dark:bg-slate-800",maxLength:200,autoFocus:!0})}),N&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-sky-600 dark:text-sky-400",children:[(0,r.jsx)("span",{className:"h-3 w-3 rounded-full border-2 border-sky-500 border-t-transparent animate-spin"}),"Analyzing file…"]}),E&&(0,r.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:E}),S&&(0,r.jsx)("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900 dark:border-amber-400/30 dark:bg-slate-900/60 dark:text-amber-100",children:S}
1),F&&(0,r.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:"Long study resources were shortened to keep your plan within safe limits."})]}),(0,r.jsxs)("div",{className:"-mx-6 px-6 py-3 sm:mx-0 sm:rounded-2xl sm:border sm:border-gray-100 sm:bg-gray-50 sm:px-4 sm:py-3 sm:dark:border-slate-800 sm:dark:bg-slate-950/40",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-2 mb-3",children:[(0,r.jsx)("div",{children:(0,r.jsx)("p",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:"Topics to Study"})}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)(c.$,{type:"button",variant:"outline",onClick:W,className:"gap-2",disabled:f.length>=25,children:[(0,r.jsx)(D.A,{className:"h-4 w-4"}),"Add Topic"]}),(0,r.jsxs)(c.$,{type:"button",variant:"outline",onClick:q,disabled:N,className:"gap-2 hidden lg:inline-flex",children:[(0,r.jsx)(_.A,{className:"h-4 w-4"}),N?"Uploading…":"Upload outline"]})]})]}),(0,r.jsxs)("div",{className:"hidden lg:flex flex-wrap items-center gap-3 text-sm",children:[N&&(0,r.jsxs)("span",{className:"flex items-center gap-2 text-sky-600 dark:text-sky-400",children:[(0,r.jsx)("span",{className:"h-3 w-3 rounded-full border-2 border-sky-500 border-t-transparent animate-spin"}),"Analyzing file…"]}),E&&(0,r.jsx)("span",{className:"text-red-600 dark:text-red-400",children:E})]}),(0,r.jsx)("div",{className:"overflow-y-auto sm:pr-2 sm:-mr-2",style:{maxHeight:"min(330px, 55vh)",scrollbarGutter:"stable"},children:(0,r.jsx)("div",{className:"space-y-3",children:(0,r.jsx)(T.N,{initial:!1,children:f.map((e,t)=>{let a=j===e.id;return(0,r.jsxs)(h.P.div,{className:"rounded-xl border border-gray-200 dark:border-slate-800 bg-white dark:bg-slate-900/70 shadow-sm",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3 px-4 py-3 border-b border-gray-100 dark:border-slate-800",children:[(0,r.jsx)("button",{type:"button",className:"text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-100 transition-transform",onClick:()=>{var t;return t=e.id,void k(e=>e===t?null:t)},children:(0,r.jsx)(M.A,{className:"h-5 w-5 transition-transform ".concat(a?"rotate-180":"")})}),(0,r.jsx)("input",{type:"text",value:e.title,onChange:t=>O(e.id,"title",t.target.value),onKeyDown:t=>((e,t)=>{if("Enter"!==e.key)return;e.preventDefault();let a=f.find(e=>e.id===t);a&&a.title.trim()&&W()})(t,e.id),placeholder:"Topic ".concat(t+1," (e.g., Cellular Respiration)"),className:"flex-1 bg-transparent focus:outline-none text-sm md:text-base",maxLength:200}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void b(e=>{if(1===e.length)return e;let a=e.filter(e=>e.id!==t);return k(e=>{if(e===t){var r,s;return null!=(s=null==(r=a[a.length-1])?void 0:r.id)?s:null}return e}),a})},disabled:1===f.length,className:"p-1 text-red-500 hover:text-red-600 disabled:text-gray-300 disabled:dark:text-slate-600",children:(0,r.jsx)(P.A,{className:"h-4 w-4"})})})]}),(0,r.jsx)(T.N,{initial:!1,children:a&&(0,r.jsx)(h.P.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:"easeInOut"},className:"overflow-hidden origin-top",children:(0,r.jsxs)("div",{className:"p-4 flex flex-col gap-4 md:flex-row",children:[(0,r.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,r.jsx)("label",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Study Resources"}),(0,r.jsx)(u.T,{value:e.resources,onChange:t=>O(e.id,"resources",t.target.value),placeholder:"List names of notes, chapter/textbook references, practice tests, class slides...",className:"min-h-[120px] bg-transparent border-gray-200 dark:border-slate-800 dark:bg-slate-900/80"})]}),(0,r.jsxs)("div",{className:"md:w-48 space-y-2",children:[(0,r.jsx)("label",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Desired minutes"}),(0,r.jsx)("input",{type:"number",value:e.duration,min:15,max:600,step:5,onChange:t=>O(e.id,"duration",t.target.value),onBlur:()=>{var t;return t=e.id,void b(e=>e.map(e=>e.id===t?{...e,duration:String(K(e.duration))}:e))},className:"w-full rounded-lg border border-gray-200 dark:border-slate-800 bg-transparent px-3 py-2 focus:outline-none focus:ring-2 focus:ring-sky-500 dark:bg-slate-900/80"})]})]})})})]},e.id)})})})})]}),(0,r.jsxs)("div",{className:"space-y-4 pt-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:items-end",children:[(0,r.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Exam date / deadline"}),(0,r.jsx)(Y.l,{value:x,onChange:g,min:o,max:d})]}),(0,r.jsx)(c.$,{type:"submit",disabled:!G,className:"w-full md:w-auto md:ml-auto bg-blue-600 hover:bg-blue-700 text-white",children:"Send to Kai"})]}),v&&(0,r.jsx)("p",{className:"text-sm text-red-600",children:v})]})]})})]})})}):null}
1var H=a(10101),V=a(6504),O=a(22133),W=a(61362),B=a(78874),q=a(33090),$=a(55485);function G(e){let{invocation:t}=e,{state:a,type:s,input:i,output:l,errorText:n}=t,o=(null==s?void 0:s.startsWith("tool-"))?s.replace("tool-",""):s,{resolvedTheme:d}=(0,$.D)(),c="dark"===d,u="running",p=null;if("output-available"===a)if(l&&l.ok)u="success";else{var x;u="error",p="string"==typeof(null==l?void 0:l.error)?l.error:(null==l||null==(x=l.error)?void 0:x.message)||"An unknown error occurred."}else"output-error"===a?(u="error",p=n||"An unknown error occurred."):"output-denied"===a?(u="error",p="Tool execution denied."):u="running";let{label:g,details:f}=(()=>{var e,t;let a,r={SEE_SCHEDULE:"Checking schedule",CREATE_EVENT:"Creating event",CREATE_TASK:"Creating task",UPDATE_EVENT:"Updating event",UPDATE_TASK:"Updating task",DELETE_EVENT:"Deleting event",DELETE_TASK:"Deleting task",SEE_TASKS:"Checking tasks",GET_STUDY_RECOMMENDATIONS:"Getting study recommendations"}[o]||"Using ".concat(o),s=null==l?void 0:l.data;switch(o){case"CREATE_EVENT":{let l=(null==s?void 0:s.summary)||(null==i?void 0:i.title);l&&(r='Creating "'.concat(l,'"'));let n=(null==s||null==(e=s.start)?void 0:e.dateTime)||(null==s?void 0:s.start)||(null==i?void 0:i.startTime),o=(null==s||null==(t=s.end)?void 0:t.dateTime)||(null==s?void 0:s.end)||(null==i?void 0:i.endTime),d=(0,m.fU)(n),c=(0,m.fU)(o);d&&c&&(a="".concat(d," – ").concat(c));break}case"UPDATE_EVENT":{let e=(null==s?void 0:s.summary)||(null==i?void 0:i.title);e&&(r='Updating "'.concat(e,'"'));let t=[];if((null==i?void 0:i.title)&&t.push("title"),(null==i?void 0:i.startTime)||(null==i?void 0:i.endTime)){let e=(0,m.fU)(null==i?void 0:i.startTime),a=(0,m.fU)(null==i?void 0:i.endTime);e&&a&&t.push("".concat(e," – ").concat(a))}void 0!==(null==i?void 0:i.flexible)&&t.push("flexibility"),(null==i?void 0:i.priority)&&t.push("priority → ".concat(i.priority)),(null==i?void 0:i.deadline)&&t.push("deadline"),t.length>0&&(a=t.join(", "));break}case"DELETE_EVENT":r="Deleting event";break;case"SEE_SCHEDULE":r="Checking schedule",a=(0,m.tX)(null==i?void 0:i.timeMin,null==i?void 0:i.timeMax);break;case"SEE_TASKS":r="Checking tasks";break;case"CREATE_TASK":{let e=(null==s?void 0:s.title)||(null==i?void 0:i.title);e&&(r='Creating "'.concat(e,'"')),(null==i?void 0:i.due)&&(a="due ".concat((0,m.r6)(i.due)));break}case"UPDATE_TASK":{let e=(null==s?void 0:s.title)||(null==i?void 0:i.title);e&&(r='Updating "'.concat(e,'"'));let t=[];(null==i?void 0:i.title)&&t.push("title"),(null==i?void 0:i.due)&&t.push("due → ".concat((0,m.Yq)(i.due))),(null==i?void 0:i.priority)&&t.push("priority → ".concat(i.priority)),void 0!==(null==i?void 0:i.completed)&&t.push("completed → ".concat(i.completed?"yes":"no")),t.length>0&&(a=t.join(", "));break}case"DELETE_TASK":r="Deleting task",(null==i?void 0:i.taskId)&&(a="- id: ".concat(i.taskId));break;case"GET_STUDY_RECOMMENDATIONS":if(r="Recommending study hacks",(null==i?void 0:i.groups)&&Array.isArray(i.groups)){let e=i.groups.length;if(1===e){let e=i.groups[0],t=(null==e?void 0:e.topic)||"General",r="number"==typeof(null==e?void 0:e.duration)?"".concat(e.duration,"m"):void 0;a=r?"".concat(t,", ").concat(r):t}else e>1&&(a="".concat(e," groups"))}}return{label:r,details:a}})(),b="running"===u?c?"bg-blue-900/30 border border-blue-700":"bg-blue-50 border border-blue-200":"success"===u?c?"bg-green-900/30 border border-green-700":"bg-green-50 border border-green-200":c?"bg-red-900/30 border border-red-700":"bg-red-50 border border-red-200",v="running"===u?c?"text-blue-300":"text-blue-700":"success"===u?c?"text-green-300":"text-green-700":c?"text-red-300":"text-red-700";return(0,r.jsxs)(h.P.div,{variants:{hidden:{opacity:0,y:-10},visible:{opacity:1,y:0}},initial:"hidden",animate:"visible",className:"inline-flex items-start gap-2 px-3 py-2 rounded-full text-sm shadow-sm transition-all ".concat(b),role:"status","aria-live":"polite",children:[(0,r.jsx)("span",{className:"text-sm",children:{SEE_SCHEDULE:"\uD83D\uDD0D",CREATE_EVENT:"\uD83D\uDCC5",CREATE_TASK:"✅",UPDATE_EVENT:"✏️",UPDATE_TASK:"✏️",DELETE_EVENT:"\uD83D\uDDD1️",DELETE_TASK:"\uD83D\uDDD1️",SEE_TASKS:"\uD83D\uDD0D",GET_STUDY_RECOMMENDATIONS:"\uD83D\uDCDA"}[o]||"⚙️"}),(0,r.jsxs)("div",{className:"flex flex-col -mt-0.5",children:[(0,r.jsx)("span",{className:"font-medium ".concat(v),children:g}),f&&(0,r.jsx)("span",{className:"text-[10px] leading-tight text-gray-500 dark:text-gray-400",children:f})]}),"running"===u&&(0,r.jsx)(q.o,{size:"sm",color:"blue",className:"ml-1 self-center"}),"success"===u&&(0,r.jsx)(W.A,{className:"h-3.5 w-3.5 self-center ".concat(c?"text-green-400":"text-green-600")}),"error"===u&&(0,r.jsx)(B.A,{className:"h-3.5 w-3.5 self-center ".concat(c?"text-red-400":"text-red-600")}),"error"===u&&p&&(0,r.jsx)("div",{className:"absolute top-full left-0 mt-1 p-2 rounded text-xs max-w-48 z-10 border ".concat(c?"bg-red-900/50 border-red-700 text-red-300":"bg-red-100 border-red-200 text-red-700"),children:p})]})}var Z=a(30926);let X=(0,Z.createServerReference)("7c46ac590fcc2c6b86e59927c008148ba260c4fe22",Z.callServer,void 0,Z.findSourceMapURL,"logBadResponse");var J=a(85338),Q=a(63455);function ee(){let{user:e,userProfile:t}=(0,A.A)(),a=(0,S.usePathname)(),[m,_]=(0,l.useState)(!1),[C,D]=(0,l.useState)(!1),[M,P]=(0,l.useState)(!1),[R,U]=(0,l.useState)(null),Y=(0,l.useRef)(null),K=(0,l.useRef)(null),z=(0,l.useRef)(null),L=(0,l.useRef)(null),{addTaskToCache:I,updateTaskInCache:W,deleteTaskFromCac
1he:B}=(0,d.l)(),$=(0,l.useRef)(new Set),Z=(0,l.useRef)([]),[ee,et]=(0,l.useState)(new Set),[ea,er]=(0,l.useState)([]),{isRecording:es,transcript:ei,startRecording:el,stopRecording:en}=(0,H.V)(),eo=(0,l.useCallback)(e=>{let t=e.target.files;t&&(Array.from(t).forEach(e=>{let t=e.type.startsWith("image/"),a="application/pdf"===e.type;if(!t&&!a||e.size>0xa00000)return;let r=new FileReader;r.onload=t=>{var a;let r=null==(a=t.target)?void 0:a.result;er(t=>[...t,{type:"file",mediaType:e.type,filename:e.name,url:r}])},r.readAsDataURL(e)}),e.target.value="")},[]),ed=(0,l.useCallback)(e=>{er(t=>t.filter((t,a)=>a!==e))},[]),ec=(0,l.useMemo)(()=>({education:(null==t?void 0:t.education)||[],goalsAndReflections:(null==t?void 0:t.goalsAndReflections)||[],subjectsAndActivities:(null==t?void 0:t.subjectsAndActivities)||[],preferencesAndSchedule:(null==t?void 0:t.preferencesAndSchedule)||{},studyHacks:{activatedHacks:Q.jM.map(e=>e.id),lastUpdated:new Date().toISOString()},aiSettings:(null==t?void 0:t.aiSettings)||{memories:[]}}),[t]),eu=(0,l.useCallback)(()=>({agent:"kai",userProfile:ec,userId:(null==e?void 0:e.uid)||"",currentDateTime:new Date().toString(),userTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone}),[ec,null==e?void 0:e.uid]),{messages:em,status:eh,sendMessage:ep,error:ex,setMessages:eg,regenerate:ef}=(0,s.Y_)({transport:new i.rL({api:"/api/ai",body:eu()}),onFinish:()=>{P(!0)}}),[eb,ev]=(0,l.useState)(""),ey=(0,l.useMemo)(()=>em.filter(e=>"user"===e.role).length,[em])>=10,ej=eb.trim().split(/\s+/).filter(Boolean).length>200,[ek,eN]=(0,l.useState)(!1),ew=(0,l.useRef)(null),eE=(0,l.useCallback)(()=>{let e=K.current;if(!e)return;let t=parseFloat(window.getComputedStyle(e).lineHeight||"20"),a=e.scrollHeight;null==ew.current&&(ew.current=a);let r=Math.round(Math.max(0,a-(ew.current||a))/(t||20)),s=window.innerWidth<=480,i=e.value.trim().length>0;s&&i?!ek&&r>=2?eN(!0):ek&&r<1&&eN(!1):eN(!1)},[ek]),eA=e=>{if((e.preventDefault(),!ey)&&(eb.trim()||0!==ea.length)){if(ej)return void U("Message cannot be longer than ".concat(200," words."));ep({text:eb.trim()||(ea.length>0?"Please analyze this image":""),files:ea.length>0?ea:void 0},{body:eu()}),ev(""),er([])}},eT=e=>{if("Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),!ey)&&(eb.trim()||0!==ea.length)){if(ej)return void U("Message cannot be longer than ".concat(200," words."));ep({text:eb.trim()||(ea.length>0?"Please analyze this image":""),files:ea.length>0?ea:void 0},{body:eu()}),ev(""),er([])}},eS=(0,l.useCallback)(e=>{if(ey)return void P(!0);eg([{id:(0,n.Ak)(),role:"user",parts:[{type:"text",text:e}]}]),ef({body:eu()}),P(!0)},[eg,ef,eu,ey]),e_=(0,l.useCallback)(async(e,t)=>{if(ee.has(e))return;et(t=>new Set(t).add(e));let a=await X(em,t,ec,new Date().toISOString(),Intl.DateTimeFormat().resolvedOptions().timeZone);a.success||(et(t=>{let a=new Set(t);return a.delete(e),a}),console.error("Failed to report message:",a.error))},[em,ee,ec]);(0,l.useEffect)(()=>{if(K.current){let e=K.current;e.style.height="auto",e.style.height="".concat(e.scrollHeight,"px"),requestAnimationFrame(eE)}},[eb,eE]),(0,l.useEffect)(()=>{let e=()=>eE();return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[eE]),(0,l.useEffect)(()=>{ej?U("Message cannot be longer than ".concat(200," words.")):U(null)},[eb,ej]);let eC=(0,l.useCallback)(()=>{eg([]),ev("")},[eg]),eD=(0,l.useCallback)(()=>{P(!1)},[]);(0,l.useEffect)(()=>{let e=e=>{Y.current&&!Y.current.contains(e.target)&&M&&eD()};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[M,eD]);let eM=(0,l.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth",t=z.current;if(!t)return;let a=()=>{try{t.scrollTo({top:t.scrollHeight,behavior:e})}catch(e){t.scrollTop=t.scrollHeight}};requestAnimationFrame(()=>requestAnimationFrame(a))},[]);(0,l.useEffect)(()=>{ei&&ev(ei)},[ei,ev]),(0,l.useEffect)(()=>{if(em.forEach(e=>{e.parts&&e.parts.forEach((t,a)=>{var r,s;let i="".concat(e.id,"-").concat(a);
1if((null==(r=t.type)?void 0:r.startsWith("tool-"))&&"output-available"===t.state&&!$.current.has(i)){let e=t.type.replace("tool-",""),a=t.output;if(a&&a.ok){let t=a.data;switch(e){case"CREATE_EVENT":t&&t.summary&&t.start?o.i.publish("event-created",{event:t}):o.i.publish("ai-event-change");break;case"UPDATE_EVENT":t&&t.summary&&t.start?o.i.publish("event-updated",{event:t}):o.i.publish("ai-event-change");break;case"DELETE_EVENT":o.i.publish("event-deleted",{eventId:(null==(s=a.data)?void 0:s.id)||void 0});break;case"CREATE_TASK":t&&t.title?I(t):o.i.publish("ai-task-change");break;case"UPDATE_TASK":t&&t.id?W(t):o.i.publish("ai-task-change");break;case"DELETE_TASK":t&&t.taskId?B(t.taskId):o.i.publish("ai-task-change")}}$.current.add(i)}})}),Z.current.length>0){let e=new Set;for(let{year:t,month:a}of Z.current){let r="events/".concat(t,"-").concat(a);e.has(r)||(J.P.remove(r),e.add(r))}Z.current=[],o.i.publish("ai-event-change")}},[em,I,W,B]),(0,l.useEffect)(()=>{(em.length>0||"submitted"===eh||"streaming"===eh)&&!M&&P(!0)},[em.length,eh]),(0,l.useEffect)(()=>{0!==em.length&&eM("smooth")},[em,eh,eM]),(0,l.useEffect)(()=>{if(!M)return;let e=setTimeout(()=>eM("auto"),350);return()=>clearTimeout(e)},[M,eM]);let eP=(0,l.useMemo)(()=>{let e=em.flatMap((e,t)=>{let a=[];return e.parts&&Array.isArray(e.parts)&&e.parts.length>0&&a.push(...e.parts.map((a,s)=>{var i,l;let n="".concat(e.id,"-part-").concat(s);if(null==(i=a.type)?void 0:i.startsWith("tool-"))return(0,r.jsx)(h.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"flex items-start gap-3 ml-11",children:(0,r.jsx)(G,{invocation:a})},n);if("file"===a.type)return(0,r.jsx)(h.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"flex items-start gap-3 ".concat("user"===e.role?"justify-end":""),children:(0,r.jsx)("div",{className:"rounded-lg overflow-hidden border border-slate-200 dark:border-slate-600 max-w-xs",children:(null==(l=a.mediaType)?void 0:l.startsWith("image/"))?(0,r.jsx)("img",{src:a.url,alt:a.filename||"Attachment",className:"max-w-full h-auto max-h-48 object-contain"}):(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-slate-800",children:[(0,r.jsx)(x.A,{className:"h-4 w-4 text-gray-500"}),(0,r.jsx)("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:a.filename||"Attachment"})]})})},n);let o="string"==typeof a.text?a.text:"string"==typeof a.content?a.content:void 0;return o&&o.length>0?(0,r.jsxs)(h.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"flex items-start gap-3 ".concat("user"===e.role?"justify-end":""),children:["user"!==e.role&&(0,r.jsx)(E.default,{src:"/kai/kai_happy.svg",alt:"Kai",width:32,height:32,className:"rounded-full flex-shrink-0 mt-1"}),(0,r.jsxs)("div",{className:"flex flex-col gap-1 max-w-md ".concat("user"===e.role?"items-end":"items-start"),children:[(0,r.jsx)("div",{className:"rounded-lg px-4 py-2 ".concat("user"===e.role?"bg-blue-500 text-white":"bg-gray-100 text-gray-800 dark:bg-slate-700 dark:text-slate-100"),children:(0,r.jsx)(V.oz,{remarkPlugins:[O.A],components:{a:e=>{let{href:t,children:a,...s}=e;return(0,r.jsxs)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline font-medium inline-flex items-center gap-1",...s,children:[a,(0,r.jsx)("span",{className:"text-xs",children:"↗"})]})},p:e=>{let{children:t}=e;return(0,r.jsx)("p",{className:"mb-2 last:mb-0 leading-relaxed",children:t})},strong:e=>{let{children:t}=e;return(0,r.jsx)("strong",{className:"font-semibold",children:t})},code:e=>{let{children:t}=e;return(0,r.jsx)("code",{className:"bg-gray-200 dark:bg-gray-700 px-1 py-0.5 rounded text-sm font-mono",children:t})},ul:e=>{let{children:t}=e;return(0,r.jsx)("ul",{className:"list-disc list-inside space-y-1 my-2",children:t})},ol:e=>{let{children:t}=e;return(0,r.jsx)("ol",{className:"list-decimal list-inside space-y-1 my-2",children:t})},li:e=>{let{children:t}=e;return(0,r.jsx)("li",{className:"text-sm",children:t})}},children:o})}),"user"!==e.role&&(0,r.jsx)("button",{onClick:()=>e_(e.id,t),disabled:ee.has(e.id),className:"ml-1 flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide ".concat(ee.has(e.id)?"text-green-600 dark:text-green-400":"text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300"," transition-colors"),title:ee.has(e.id)?"Response reported":"Report bad response",children:ee.has(e.id)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.A,{className:"h-3 w-3"}),(0,r.jsx)("span",{children:"Reported"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(f.A,{className:"h-3 w-3"}),(0,r.jsx)("span",{children:"Bad Response"})]})})]})]},n):(0,r.jsx)("div",{},n)})),a});return("submitted"===eh||"streaming"===eh)&&e.push((0,r.jsxs)(h.P.div,{initial:{opacity:0,y:20}
1,animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"flex items-start gap-3",children:[(0,r.jsx)(E.default,{src:"/kai/kai_happy.svg",alt:"Kai",width:32,height:32,className:"rounded-full flex-shrink-0 mt-1"}),(0,r.jsx)("div",{className:"bg-gray-100 text-gray-800 dark:bg-slate-700 dark:text-slate-100 rounded-lg px-4 py-3 max-w-md",children:(0,r.jsx)(q.V,{})})]},"typing-indicator")),e},[em,eh,e_,ee]);return e&&"/feed"!==a?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed bottom-0 left-1/2 transform -translate-x-1/2 z-50 w-full max-w-4xl px-2 md:px-4","data-dashboard":"chat-bar",children:(0,r.jsxs)("div",{className:"relative w-full p-4",ref:Y,children:[(0,r.jsx)(p,{isError:ej,children:(0,r.jsxs)(h.P.div,{className:"relative rounded-lg shadow-lg flex flex-col overflow-hidden bg-[var(--card)] text-[var(--foreground)] border border-slate-200 dark:border-slate-600",animate:{height:"auto"},transition:{duration:.3,ease:[.25,.46,.45,.94]},children:[(0,r.jsx)(T.N,{children:ex&&(0,r.jsx)(h.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3},className:"border-b border-slate-200 dark:border-slate-600 bg-red-50 dark:bg-red-900/20 px-4 py-3",children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(b.A,{className:"h-5 w-5 text-red-500 mr-3"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("p",{className:"font-medium text-red-800 dark:text-red-200",children:"An error occurred"}),(0,r.jsx)("p",{className:"text-sm text-red-600 dark:text-red-300",children:ex.message})]}),(0,r.jsx)("button",{onClick:()=>eg(em.slice(0,-1)),className:"ml-3 text-red-500 hover:text-red-700 dark:hover:text-red-400",children:(0,r.jsx)(v.A,{className:"h-4 w-4"})})]})})}),(0,r.jsx)(T.N,{children:R&&(0,r.jsx)(h.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3},className:"border-b border-slate-200 dark:border-slate-600 bg-red-50 dark:bg-red-900/20 px-4 py-3",children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(b.A,{className:"h-5 w-5 text-red-500 mr-3"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("p",{className:"font-medium text-red-800 dark:text-red-200",children:"Word Limit Exceeded"}),(0,r.jsx)("p",{className:"text-sm text-red-600 dark:text-red-300",children:R})]}),(0,r.jsx)("button",{onClick:()=>U(null),className:"ml-3 text-red-500 hover:text-red-700 dark:hover:text-red-400",children:(0,r.jsx)(v.A,{className:"h-4 w-4"})})]})})}),(0,r.jsx)(T.N,{children:ey&&(0,r.jsx)(h.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3},className:"border-b border-slate-200 dark:border-slate-600 bg-amber-50 dark:bg-amber-900/20 px-4 py-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(b.A,{className:"h-5 w-5 text-amber-500"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("p",{className:"font-medium text-amber-800 dark:text-amber-200",children:"Chat limit reached"}),(0,r.jsx)("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:"You've reached the 10-message limit for this chat. To prevent large token consumption and keep Kai fast and reliable, please start a new chat."})]}),(0,r.jsx)(c.$,{type:"button",size:"1",variant:"classic",className:"ml-3",onClick:eC,children:"Start new chat"})]})})}),(0,r.jsx)(T.N,{children:M&&(em.length>0||"submitted"===eh||"streaming"===eh)&&(0,r.jsx)(h.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3,ease:[.25,.46,.45,.94]},className:"max-h-80 overflow-y-auto px-4 py-4 space-y-4 border-b border-slate-200 dark:border-slate-600",ref:z,children:eP})}),(()=>{let e=!M&&(em.length>0||"submitted"===eh||"streaming"===eh);return(0,r.jsx)("div",{className:"px-4 ".concat(e?"pt-2":"pt-4"," pb-4"),children:(0,r.jsxs)("form",{onSubmit:eA,className:"relative",children:[(0,r.jsx)(T.N,{children:e&&(0,r.jsx)(h.P.div,{initial:{opacity:0,y:-3}
1,animate:{opacity:1,y:0},exit:{opacity:0,y:-3},transition:{duration:.2},className:"flex justify-center mb-0.5",children:(0,r.jsx)("button",{type:"button",onClick:()=>P(!0),className:"flex items-center justify-center w-12 h-4 rounded-md border border-blue-200 bg-blue-50 hover:bg-blue-100 hover:border-blue-300 transition-colors dark:border-slate-600 dark:bg-slate-700 dark:hover:bg-slate-600 dark:hover:border-slate-500",children:(0,r.jsxs)("div",{className:"flex items-center space-x-0.5",children:[(0,r.jsx)("div",{className:"w-1 h-1 bg-blue-600 dark:bg-blue-400 rounded-full"}),(0,r.jsx)("div",{className:"w-1 h-1 bg-blue-600 dark:bg-blue-400 rounded-full"}),(0,r.jsx)("div",{className:"w-1 h-1 bg-blue-600 dark:bg-blue-400 rounded-full"})]})})},"chat-history-dots")}),(0,r.jsx)(T.N,{children:ea.length>0&&(0,r.jsx)(h.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"flex flex-wrap gap-2 mb-3",children:ea.map((e,t)=>(0,r.jsxs)("div",{className:"relative group rounded-lg overflow-hidden border border-slate-200 dark:border-slate-600",children:[e.mediaType.startsWith("image/")?(0,r.jsx)("img",{src:e.url,alt:e.filename,className:"h-16 w-16 object-cover"}):(0,r.jsx)("div",{className:"h-16 w-16 flex items-center justify-center bg-gray-100 dark:bg-slate-800",children:(0,r.jsx)(x.A,{className:"h-6 w-6 text-gray-400"})}),(0,r.jsx)("button",{type:"button",onClick:()=>ed(t),className:"absolute top-0.5 right-0.5 p-0.5 rounded-full bg-black/60 text-white opacity-0 group-hover:opacity-100 transition-opacity",children:(0,r.jsx)(v.A,{className:"h-3 w-3"})})]},t))})}),(0,r.jsxs)(h.P.div,{className:"flex items-center gap-2",layout:!0,children:[(0,r.jsx)("input",{ref:L,type:"file",accept:"image/*,application/pdf",multiple:!0,onChange:eo,className:"hidden"}),(0,r.jsxs)(h.P.div,{className:"flex items-center gap-1 flex-1 min-w-0 rounded-lg px-1 md:px-2 py-1 border border-slate-200 dark:border-slate-600 overflow-hidden bg-[var(--card)]",layout:!0,children:[(0,r.jsx)("button",{type:"button",onClick:()=>es?en():el(eb),className:"flex-shrink-0 p-1.5 rounded-full hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors",children:(0,r.jsx)(y.A,{className:"h-5 w-5 ".concat(es?"text-red-500":"text-gray-400")})}),(0,r.jsx)(u.T,{ref:K,rows:1,value:eb,onChange:e=>ev(e.target.value),onKeyDown:eT,placeholder:ey?"Chat limit reached — start a new chat to continue.":"submitted"===eh||"streaming"===eh?"Kai is thinking...":"Ask Kai anything...",className:"flex-1 bg-transparent text-[var(--foreground)] placeholder-gray-500 dark:placeholder-gray-400 pl-1 pr-2 md:pl-2 md:pr-3 py-2 resize-none overflow-y-auto focus:outline-none focus:ring-0 focus:border-transparent",disabled:"ready"!==eh||ey,style:{outline:"none !important",boxShadow:"none !important",WebkitAppearance:"none",MozAppearance:"none",border:"none",borderRadius:"0",maxHeight:"120px",scrollbarGutter:"stable"}})]}),(0,r.jsxs)(h.P.div,{className:"flex items-center flex-none ".concat(ek?"flex-col gap-2.5":"gap-1 md:gap-2"),layout:!0,transition:{type:"spring",stiffness:400,damping:40},children:[(0,r.jsx)(c.$,{type:"button",variant:"soft",color:"gray",size:"1",className:"p-2",onClick:()=>D(!0),disabled:ey,children:(0,r.jsx)(j.A,{className:"h-4 w-4"})}),(0,r.jsx)(c.$,{type:"button",variant:"soft",color:ea.length>0?"blue":"gray",size:"1",className:"p-2 hidden md:inline-flex",onClick:()=>{var e;return null==(e=L.current)?void 0:e.click()},disabled:ey,children:(0,r.jsx)(x.A,{className:"h-4 w-4"})}),(0,r.jsx)(c.$,{type:"submit",size:"1",variant:"classic",className:"p-2",disabled:"ready"!==eh||ej||ey||!eb.trim()&&0===ea.length,children:(0,r.jsx)(k.A,{className:"h-4 w-4"})})]})]})]})})})()]})}),(0,r.jsx)(T.N,{children:C&&(0,r.jsx)(h.P.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-10",onClick:()=>D(!1),style:{background:"radial-gradient(circle at center, rgba(0,0,0,0.08) 0%, rgba(0,0,0,0.02) 50%, transparent 100%)",backdropFilter:"blur(1.1px)"},children:(0,r.jsx)(h.P.div,{initial:{y:50,opacity:0},animate:{y:0,opacity:1},exit:{y:50,opacity:0},transition:{type:"spring",stiffness:400,damping:40},className:"absolute bottom-20 right-4 w-64 shadow-xl",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(p,{children:(0,r.jsx)("div",{className:"rounded-lg p-4 border border-slate-200 dark:border-slate-600 bg-[var(--card)] text-[var(--foreground)]",children:(0,r.jsxs)("ul",{className:"space-y-2",children:[(0,r.jsxs)("li",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-[var(--card-hover)] cursor-pointer transition-colors",onClick:()=>{_(!0),D(!1)},children:[(0,r.jsx)(N.A,{className:"h-5 w-5 text-blue-500"}),(0,r.jsx)("span",{className:"font-medium",children:"Exam Planner"})]}),(0,r.jsxs)("li",{className:"flex md:hidden items-center gap-3 p-3 rounded-lg hover:bg-[var(--card-hover)] cursor-pointer transition-colors",onClick:()=>{var e;null==(e=L.current)||e.click(),D(!1)},children:[(0,r.jsx)(x.A,{className:"h-5 w-5 text-gray-500"}),(0,r.jsx)("span",{className:"font-medium",children:"Attach File"})]}),(0,r.jsxs)("li",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-[var(--card-hover)] cursor-pointer transition-colors",onClick:()=>{o.i.publish("open-event-form"),D(!1)},children:[(0,r.jsx)(w.A,{className:"h-5 w-5 text-green-500"}),(0,r.jsx)("span",{className:"font-medium",children:"Add Event"})]}),(0,r.jsxs)("li",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-[var(--card-hover)] cursor-pointer transition-colors",onClick:()=>{o.i.publish("open-task-form"),D(!1)},children:[(0,r.jsx)(g.A,{className:"h-5 w-5 text-purple-500"}),(0,r.jsx)("span",{className:"font-medium",children:"Add Task"})]})]})})})})})})]})}),(0,r.jsx)(F,{isOpen:m,onClose:()=>_(!1),onSubmitPrompt:eS})]}):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.