const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./web-Z7bl6-nK.js","./firebase-CqYX5ZBk.js","./rolldown-runtime-QTnfLwEv.js"])))=>i.map(i=>d[i]);
import{R as e,a as t,n}from"./firebase-CqYX5ZBk.js";var r=`openai/gpt-oss-120b`,i=`qwen/qwen3.6-27b`,a=`meta-llama/llama-4-scout-17b-16e-instruct`,o=/gpt-oss/,s=[{id:r,label:`Aalbiro.v2 Pro (reasoning)`},{id:`llama-3.3-70b-versatile`,label:`Aalbiro.v2 Balanced`},{id:`llama-3.1-8b-instant`,label:`Aalbiro.v2 Fast`}],c=`https://api.groq.com/openai/v1/chat/completions`,l=`You are **Aalbiro.v2**, the AI study assistant inside StudySphere.

IDENTITY RULES (follow strictly):
- Your name is Aalbiro.v2. You were created by Aalbiro Technology.
- NEVER say you are Llama, Meta, OpenAI, Groq, or any other model/company. If asked what model or AI you are, simply say: "I'm Aalbiro.v2, the study assistant built by Aalbiro Technology."
- Do not mention model architectures, parameter counts, or providers.

ABOUT STUDYSPHERE (the app you live in):
- StudySphere is an all-in-one study app that helps students focus and study smarter. Website: https://thestudysphere.in
- It is developed by Aalbiro Technology.
- Features: a Focus timer (Pomodoro/stopwatch), Tasks/to-do, Notes (with an AI Note Maker that reads PDFs/photos), Calendar with Google Calendar sync, Question Bank (AI quizzes + flashcards), the Mentor (this AI study coach + tutor), a Library, Track Records (analytics), and gamification (XP, levels, streaks, badges).
- StudyGuard is its focus blocker: it blocks distracting apps and websites during a focus session, on Android and on PC (via a browser extension). It does not use Accessibility, so banking/UPI apps keep working.
- Available as a web app, an Android app, and a PC browser extension.

ABOUT AALBIRO TECHNOLOGY (the company that built StudySphere):
- Aalbiro Technology builds smart digital solutions — AI-first, 100% custom (no templates). Website: https://aalbiro.com · Contact: hello@aalbiro.com
- Founded in 2026, based in India and working remotely worldwide.
- Services: AI Development (chatbots, voice cloning, automation, custom AI tools), Software Services (web, mobile, desktop, SaaS), Creative Tech (video AI, branding), Business Solutions (CRMs, automation, support systems), and 24/7 Technical Support.
- Tagline: "We build the future — technology that thinks with you, not just for you."

When a user asks about StudySphere or Aalbiro Technology, answer warmly and accurately using the facts above, and feel free to point them to thestudysphere.in or aalbiro.com. Otherwise, be a helpful, encouraging study tutor.`;function u(e,t){return{role:`user`,content:[{type:`text`,text:e},...t.map(e=>({type:`image_url`,image_url:{url:e}}))]}}var d=class extends Error{};async function f(e,t,n={}){if(!e)throw new d(`No Groq API key set. Add one in Settings.`);let r=n.model??`openai/gpt-oss-120b`,i={model:r,messages:t,temperature:n.temperature??.7,max_tokens:n.maxTokens??1024,...n.frequencyPenalty==null?{}:{frequency_penalty:n.frequencyPenalty},...n.presencePenalty==null?{}:{presence_penalty:n.presencePenalty},...n.jsonMode?{response_format:{type:`json_object`}}:{}};n.reasoningEffort&&o.test(r)&&(i.reasoning_effort=n.reasoningEffort);let a=await fetch(c,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e}`},body:JSON.stringify(i),signal:n.signal});if(!a.ok)throw a.status===401?new d(`Invalid Groq API key. Check it in Settings.`):a.status===429?new d(`Rate limit reached. Please wait a moment.`):new d(`AI request failed (${a.status}).`);return(await a.json()).choices?.[0]?.message?.content??``}async function p(e,t,n,r,i){let a=(await f(e,[{role:`system`,content:`You are a question generator for students. Respond ONLY with valid JSON: an array of objects {"question": string, "options": [4 strings], "answerIndex": 0-3, "explanation": string}. No markdown, no prose outside the JSON.`},{role:`user`,content:`Generate ${n} ${r} multiple-choice questions about: ${t}.`}],{model:i,temperature:.8,maxTokens:2048})).match(/\[[\s\S]*\]/);if(!a)throw new d(`AI returned an unexpected format. Try again.`);let o;try{o=JSON.parse(a[0])}catch{throw new d(`Could not parse the AI response. Try again.`)}return o.filter(e=>e.question&&Array.isArray(e.options)&&e.options.length>=2).map(e=>({question:e.question,options:e.options.slice(0,4),answerIndex:Math.max(0,Math.min(e.options.length-1,e.answerIndex??0)),explanation:e.explanation??``}))}async function m(e,t,n,r){let i=(await f(e,[{role:`system`,content:`You generate study flashcards. Respond ONLY with valid JSON: an array of {"front": string, "back": string}. No markdown.`},{role:`user`,content:`Generate ${n} flashcards about: ${t}.`}],{model:r,temperature:.7,maxTokens:2048})).match(/\[[\s\S]*\]/);if(!i)throw new d(`AI returned an unexpected format. Try again.`);return JSON.parse(i[0])}var h={summary:`Read the document in these images and write a clear, well-structured summary in Markdown.`,keypoints:`Read the document in these images and extract the key points as a concise Markdown bullet list.`,qa:`Read the document in these images and create a set of question-and-answer pairs (Q: / A:) covering the important content, in Markdown.`,studyguide:`Read the document in these images and produce a thorough study guide in Markdown with headings, key concepts, definitions, and takeaways.`,flashcards:`Read the document in these images and create study flashcards. Respond ONLY with valid JSON: an array of {"front": string, "back": string}. No markdown.`};async function g(e,t,n,r=``){if(!t.length)throw new d(`No pages to read. Add a PDF or image first.`);return f(e,[u(`${h[n]}${r?`\n\nAdditional instructions: ${r}`:``}`,t)],{model:a,temperature:.4,maxTokens:3e3})}var _;(function(e){e[e.Flush=0]=`Flush`,e[e.Add=1]=`Add`})(_||={});var v=t(`TextToSpeech`,{web:()=>e(()=>import(`./web-Z7bl6-nK.js`).then(e=>new e.TextToSpeechWeb),__vite__mapDeps([0,1,2]),import.meta.url)});`speechSynthesis`in window&&window.speechSynthesis;var y=`wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?TrustedClientToken=6A5AA1D4EAFF4E9FB37E23D68491D6F4`,b=`audio-24khz-48kbitrate-mono-mp3`,x=`https://api.groq.com/openai/v1/audio/speech`,S=`canopylabs/orpheus-v1-english`,C={female:`hannah`,male:`troy`},w=``;function T(e){w=e||``}var E={female:{en:`en-IN-NeerjaNeural`,hi:`hi-IN-SwaraNeural`},male:{en:`en-IN-PrabhatNeural`,hi:`hi-IN-MadhurNeural`}},D=[{id:`female`,label:`Neerja / Swara — female`,sample:`Let's get to work. You've got this.`},{id:`male`,label:`Prabhat / Madhur — male`,sample:`Enough excuses. Let's go.`}],O=e=>/[ऀ-ॿ]/.test(e),k=new Map,A=40,j=null,M=!1,N=0,P=()=>n.isNativePlatform();function F(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&apos;`)}function I(){try{return crypto.randomUUID().replace(/-/g,``)}catch{return String(Date.now())+Math.random().toString(16).slice(2)}}function L(e,t){return new Promise((n,r)=>{let i;try{i=new WebSocket(y)}catch(e){return r(e)}i.binaryType=`arraybuffer`;let a=[],o=!1,s=e=>{if(!o){o=!0,clearTimeout(c);try{i.close()}catch{}e?r(e):a.length?n(new Blob(a,{type:`audio/mpeg`})):r(Error(`no audio`))}},c=setTimeout(()=>s(Error(`edge timeout`)),15e3);i.onopen=()=>{let n=new Date().toString();i.send(`X-Timestamp:${n}\r\nContent-Type:application/json; charset=utf-8\r\nPath:speech.config\r\n\r\n{"context":{"synthesis":{"audio":{"metadataoptions":{"sentenceBoundaryEnabled":"false","wordBoundaryEnabled":"false"},"outputFormat":"${b}"}}}}`);let r=`<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='${t.split(`-`).slice(0,2).join(`-`)||`en-US`}'><voice name='${t}'><prosody rate='+0%' pitch='+0Hz'>${F(e)}</prosody></voice></speak>`;i.send(`X-RequestId:${I()}\r\nContent-Type:application/ssml+xml\r\nX-Timestamp:${n}Z\r\nPath:ssml\r\n\r\n${r}`)},i.onmessage=e=>{if(typeof e.data==`string`)e.data.includes(`Path:turn.end`)&&s();else if(e.data instanceof ArrayBuffer){let t=new DataView(e.data).getUint16(0);a.push(new Uint8Array(e.data.slice(2+t)))}},i.onerror=()=>s(Error(`edge ws error`)),i.onclose=()=>s()})}function R(e,t){let n=URL.createObjectURL(t);if(k.set(e,n),k.size>A){let e=k.keys().next().value;if(e){let t=k.get(e);t&&URL.revokeObjectURL(t),k.delete(e)}}return n}async function z(e,t,n){if(!n)return null;let r=C[t],i=`orpheus:${r}:${e}`,a=k.get(i);if(a)return a;try{let t=await fetch(x,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${n}`},body:JSON.stringify({model:S,voice:r,input:e,response_format:`wav`})});if(!t.ok)return null;let a=await t.blob();return a.size?R(i,a):null}catch{return null}}async function B(e,t){let n=`${t}:${e}`,r=k.get(n);if(r)return r;let i=null;if(!i&&!M)try{let n=await L(e,t);n.size&&(i=n)}catch{M=!0}return i?R(n,i):null}function V(e,t){return new Promise((n,r)=>{let i=new Audio(e);j=i;let a=()=>{j===i&&(j=null)};i.onended=()=>{a(),n()},i.onpause=()=>{a(),n()},i.onerror=()=>{a(),r(Error(`audio error`))},t&&t.addEventListener(`abort`,()=>{i.pause(),a(),n()},{once:!0}),i.play().catch(e=>{a(),r(e)})})}async function H(e){let t=window.speechSynthesis,n=t.getVoices();n.length||(await new Promise(e=>{t.onvoiceschanged=()=>e(),setTimeout(e,500)}),n=t.getVoices());let r=e.slice(0,2).toLowerCase(),i=n.filter(e=>e.lang?.toLowerCase().startsWith(r)),a=e=>/natural|neural|google|online|enhanced|premium|wavenet/i.test(e.name),o=e=>/compact|espeak|robo/i.test(e.name);return i.find(a)||i.find(e=>!o(e))||i[0]||n.find(a)||null}async function U(e,t){if(P())try{await v.speak({text:e,lang:t,rate:1,pitch:1});return}catch{}try{let n=new SpeechSynthesisUtterance(e);n.lang=t,n.rate=1,n.pitch=1;let r=await H(t);r&&(n.voice=r),window.speechSynthesis.cancel(),window.speechSynthesis.speak(n)}catch{}}var W=190,G=12;function K(e,t=W){let n=[],r=``,i=()=>{r.trim()&&n.push(r.trim()),r=``};for(let a of e.split(/(?<=[.!?…।])\s+|\n+/))if(a=a.trim(),a){for(;a.length>t;){let e=a.lastIndexOf(` `,t);e<=0&&(e=t),i(),n.push(a.slice(0,e).trim()),a=a.slice(e).trim()}(r?`${r} ${a}`:a).length<=t?r=r?`${r} ${a}`:a:(i(),r=a)}return i(),n.length?n:[e.slice(0,t)]}async function q(e,t={}){let n=(e||``).trim();if(!n)return;J();let r=N,i=t.gender??`female`,a=O(n),o=a?`hi-IN`:`en-IN`,s=t.apiKey||w;if(!a&&s){let e=K(n);if(e.length<=G)try{let n=await Promise.all(e.map(e=>z(e,i,s)));if(n.every(e=>!!e)){for(let e of n){if(r!==N||t.signal?.aborted)return;await V(e,t.signal)}return}}catch{}}if(r!==N)return;let c=a?E[i].hi:E[i].en;try{let e=await B(n,c);if(e){if(r!==N)return;await V(e,t.signal);return}}catch{}await U(n,o)}function J(){if(N++,j){try{j.pause()}catch{}j=null}try{v.stop()}catch{}try{typeof window<`u`&&window.speechSynthesis&&window.speechSynthesis.cancel()}catch{}}export{l as a,r as c,m as d,g as f,J as i,i as l,u as m,T as n,d as o,p,q as r,s,D as t,f as u};