(()=>{var e={};e.id=335,e.ids=[335],e.modules={10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},12412:e=>{"use strict";e.exports=require("assert")},55511:e=>{"use strict";e.exports=require("crypto")},94735:e=>{"use strict";e.exports=require("events")},29021:e=>{"use strict";e.exports=require("fs")},81630:e=>{"use strict";e.exports=require("http")},73496:e=>{"use strict";e.exports=require("http2")},55591:e=>{"use strict";e.exports=require("https")},21820:e=>{"use strict";e.exports=require("os")},33873:e=>{"use strict";e.exports=require("path")},27910:e=>{"use strict";e.exports=require("stream")},83997:e=>{"use strict";e.exports=require("tty")},79551:e=>{"use strict";e.exports=require("url")},28354:e=>{"use strict";e.exports=require("util")},74075:e=>{"use strict";e.exports=require("zlib")},25430:(e,t,r)=>{"use strict";r.r(t),r.d(t,{patchFetch:()=>v,routeModule:()=>d,serverHooks:()=>x,workAsyncStorage:()=>m,workUnitAsyncStorage:()=>h});var s={};r.r(s),r.d(s,{POST:()=>l});var i=r(42706),o=r(28203),n=r(45994),a=r(93292),p=r(39187),u=r(54911);let c=process.env.YOUTUBE_API_KEY;async function l(e){try{let t;let{videoId:r,channelTitle:s,videoTitle:i}=await e.json();if(!r)return p.NextResponse.json({error:"Missing videoId"},{status:400});let o=((await a.A.get("https://www.googleapis.com/youtube/v3/commentThreads",{params:{part:"snippet",videoId:r,maxResults:100,order:"relevance",key:c}})).data.items||[]).map(e=>{let t=e.snippet.topLevelComment.snippet;return{text:t.textDisplay,likes:t.likeCount||0,author:t.authorDisplayName}});if(0===o.length)return p.NextResponse.json({error:"No comments found or comments are disabled for this video."},{status:404});let n=o.sort((e,t)=>t.likes-e.likes).slice(0,50),l=n.map(e=>`[${e.likes} likes] ${e.text}`).join("\n"),d=`You are a YouTube content strategist. Analyze the following comments from a YouTube video.

Channel: "${s}"
Video: "${i}"

Top ${n.length} comments (sorted by likes):
${l}

Respond with ONLY a valid JSON object (no markdown, no code blocks):
{
  "sentiment": "<one of: Very Positive | Positive | Neutral | Mixed | Negative>",
  "sentimentScore": <number 0-100, where 100 is most positive>,

  "painPoints": [
    "<specific pain point or frustration mentioned>",
    "<specific pain point or frustration mentioned>",
    "<specific pain point or frustration mentioned>"
  ],

  "commonQuestions": [
    "<exact question viewers are asking>",
    "<exact question viewers are asking>",
    "<exact question viewers are asking>"
  ],

  "videoIdeas": [
    { "title": "<specific video title idea>", "reason": "<why this would perform well>" },
    { "title": "<specific video title idea>", "reason": "<why this would perform well>" },
    { "title": "<specific video title idea>", "reason": "<why this would perform well>" },
    { "title": "<specific video title idea>", "reason": "<why this would perform well>" }
  ],

  "audienceProfile": "<2-3 sentences describing who is watching: their demographics, motivations, and level of expertise>",

  "topInsight": "<The single most actionable insight for a new creator entering this niche, based on what the audience is asking for>"
}`,m=(await (0,u.e)(d)).replace(/```json\n?/g,"").replace(/```\n?/g,"").trim();try{t=JSON.parse(m)}catch{let e=m.match(/\{[\s\S]*\}/);t=e?JSON.parse(e[0]):{error:"Failed to parse AI response"}}return p.NextResponse.json({videoId:r,videoTitle:i,commentCount:o.length,...t})}catch(r){let e=r?.response?.data?.error?.errors?.[0]?.reason==="commentsDisabled",t=e?"Comments are disabled on this video.":r?.response?.data?.error?.message||r.message;return console.error("Comments analyze error:",t),p.NextResponse.json({error:t},{status:e?403:500})}}let d=new i.AppRouteRouteModule({definition:{kind:o.RouteKind.APP_ROUTE,page:"/api/analyze/comments/route",pathname:"/api/analyze/comments",filename:"route",bundlePath:"app/api/analyze/comments/route"},resolvedPagePath:"C:\\Users\\HP\\Desktop\\youtubenichefinder\\src\\app\\api\\analyze\\comments\\route.ts",nextConfigOutput:"",userland:s}),{workAsyncStorage:m,workUnitAsyncStorage:h,serverHooks:x}=d;function v(){return(0,n.patchFetch)({workAsyncStorage:m,workUnitAsyncStorage:h})}},96487:()=>{},78335:()=>{},54911:(e,t,r)=>{"use strict";r.d(t,{e:()=>n});var s=r(36858);let i=process.env.GEMINI_API_KEY||"",o=new s.ij(i);async function n(e){if(!i||"your_gemini_api_key_here"===i)throw Error("GEMINI_API_KEY is not configured in your .env file.");let t=function(e="gemini-2.5-flash-lite"){return o.getGenerativeModel({model:e})}();return(await t.generateContent(e)).response.text()}}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[638,452,292,858],()=>r(25430));module.exports=s})();