(()=>{var e={};e.id=956,e.ids=[956],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")},36428:(e,t,r)=>{"use strict";r.r(t),r.d(t,{patchFetch:()=>f,routeModule:()=>d,serverHooks:()=>y,workAsyncStorage:()=>h,workUnitAsyncStorage:()=>m});var n={};r.r(n),r.d(n,{POST:()=>p});var i=r(42706),a=r(28203),s=r(45994),o=r(39187),c=r(54911);process.env.YOUTUBE_API_KEY;let l=new Set(["US","GB","CA","AU","NZ","IE","DE","NL","SE","NO","DK","CH","AT","BE","FR"]),u=new Set(["JP","KR","SG","HK","TW","IT","ES","PL","CZ","PT","FI","MX","BR","AR"]);async function p(e){try{let t;let{keyword:r,channels:n}=await e.json();if(!r||!n?.length)return o.NextResponse.json({error:"Missing keyword or channels"},{status:400});let i=n.map(e=>e.country).filter(Boolean),a=function(e){let t=e.filter(e=>l.has(e)).length,r=e.filter(e=>u.has(e)).length,n=e.length||1;return t/n>=.5?{tier:"1",label:"\uD83D\uDFE2 Tier 1 — High RPM",color:"#22c55e",countries:e}:(t+r)/n>=.4?{tier:"2",label:"\uD83D\uDFE1 Tier 2 — Medium RPM",color:"#eab308",countries:e}:{tier:"3",label:"\uD83D\uDD34 Tier 3 — Lower RPM",color:"#ef4444",countries:e}}(i),s=n.slice(0,15).map(e=>`Channel: "${e.title}" | Subs: ${e.subscriberCount} | Views: ${e.viewCount}
Description: ${e.description?.slice(0,300)||"N/A"}`).join("\n\n---\n\n"),p=`You are a YouTube niche research analyst. Analyze this niche: "${r}"

Here are the top channels in this niche:

${s}

Respond with ONLY a valid JSON object (no markdown, no code blocks) with exactly this structure:
{
  "facelessScore": <number 0-100, where 100 = completely faceless/automatable, 0 = requires on-camera personality>,
  "facelessReasoning": "<2-3 sentences explaining why>",
  "facelessLabel": "<one of: Fully Automatable | Mostly Faceless | Mixed | Personality-Driven>",

  "evergreen": <true/false, true if consistent year-round demand>,
  "evergreenLabel": "<one of: Evergreen | Seasonal | Trend-Based | Mixed>",
  "evergreenReasoning": "<2 sentences explaining>",

  "uploadFrequency": "<e.g. '3-5x per week' or '1-2x per month'>",
  "effortLevel": "<one of: Very High | High | Medium | Low>",
  "effortReasoning": "<1-2 sentences>",

  "titlePatterns": [
    "<title framework pattern 1>",
    "<title framework pattern 2>",
    "<title framework pattern 3>"
  ],

  "microNiches": [
    { "name": "<sub-niche name>", "description": "<1 sentence>", "opportunity": "<High|Medium|Low>" },
    { "name": "<sub-niche name>", "description": "<1 sentence>", "opportunity": "<High|Medium|Low>" },
    { "name": "<sub-niche name>", "description": "<1 sentence>", "opportunity": "<High|Medium|Low>" },
    { "name": "<sub-niche name>", "description": "<1 sentence>", "opportunity": "<High|Medium|Low>" }
  ],

  "missingVideoIdentifier": {
    "summary": "<2 sentences: what broad subtopic area is clearly demanded but severely underserved in this niche>",
    "makeThisFirst": {
      "title": "<the single most impactful video title a new creator should make first to capture uncontested demand>",
      "why": "<2 sentences: why this specific video would win — what gap it fills and what search intent it captures>",
      "searchabilityScore": <number 0-100, estimate of how searchable/discoverable this video would be>
    },
    "gaps": [
      { "topic": "<specific underserved subtopic>", "demand": "<High|Medium>", "competition": "<Low|Medium>", "videoIdea": "<specific video title>", "searchabilityScore": <number 0-100> },
      { "topic": "<specific underserved subtopic>", "demand": "<High|Medium>", "competition": "<Low|Medium>", "videoIdea": "<specific video title>", "searchabilityScore": <number 0-100> },
      { "topic": "<specific underserved subtopic>", "demand": "<High|Medium>", "competition": "<Low|Medium>", "videoIdea": "<specific video title>", "searchabilityScore": <number 0-100> }
    ]
  },

  "titleThumbnailClusters": [
    {
      "cluster": "<pattern cluster name, e.g. 'Number + Curiosity Gap'>",
      "titlePattern": "<fill-in-the-blank template, e.g. '[Number] Things Nobody Tells You About [X]'>",
      "thumbnailStyle": "<describe the visual approach: e.g. 'Face with shocked expression + bold red text overlay' or 'No face, product close-up + minimal text'>",
      "performanceMultiplier": "<e.g. '2.4x avg views' — estimated outperformance vs typical video in this niche>",
      "exampleTitle": "<a concrete example title using this pattern for the ${r} niche>"
    },
    {
      "cluster": "<pattern cluster name>",
      "titlePattern": "<fill-in-the-blank template>",
      "thumbnailStyle": "<describe the visual approach>",
      "performanceMultiplier": "<estimated multiplier>",
      "exampleTitle": "<concrete example>"
    },
    {
      "cluster": "<pattern cluster name>",
      "titlePattern": "<fill-in-the-blank template>",
      "thumbnailStyle": "<describe the visual approach>",
      "performanceMultiplier": "<estimated multiplier>",
      "exampleTitle": "<concrete example>"
    }
  ],

  "replicationDifficulty": {
    "score": <number 0-100, where 100 = nearly impossible to replicate, 0 = anyone can copy it tonight>,
    "label": "<one of: Very Easy | Easy | Moderate | Hard | Very Hard>",
    "dimensions": {
      "onCameraRequired": <true/false>,
      "equipmentLevel": "<one of: Smartphone only | Basic setup ($200-500) | Intermediate ($500-2000) | Professional ($2000+)>",
      "specializedKnowledge": "<one of: None | Basic | Intermediate | Expert>",
      "uniqueVoiceRequired": <true/false>,
      "editingComplexity": "<one of: None | Simple cuts | Moderate | Advanced | Cinematic>"
    },
    "newCreatorPath": "<2-3 sentences: the realistic lowest-effort path a new creator could take to enter this niche and compete>"
  },

  "uploadFrequencyCorrelation": {
    "optimalFrequency": "<e.g. '2-3x per week' — the sweet spot based on top performers>",
    "insight": "<2 sentences: do daily posters outperform weekly ones in this niche? What does the data suggest?>",
    "fastGrowthStrategy": "<1-2 sentences: what posting strategy would give the fastest traction for a new channel?>"
  },

  "seasonality": {
    "pattern": "<one of: Year-Round | Monthly Cycle | Quarterly Peaks | Holiday-Driven | Event-Driven | Academic Calendar>",
    "peakMonths": ["<month name>", "<month name>"],
    "lowMonths": ["<month name>"],
    "externalTriggers": ["<external event that causes spikes>"],
    "recommendation": "<1-2 sentences on best time to launch or scale in this niche>"
  },

  "competitorNetwork": {
    "archetypes": [
      { "type": "<channel archetype>", "description": "<1 sentence>", "saturated": <true/false> },
      { "type": "<channel archetype>", "description": "<1 sentence>", "saturated": <true/false> },
      { "type": "<channel archetype>", "description": "<1 sentence>", "saturated": <true/false> }
    ],
    "collaborationLikelihood": "<High|Medium|Low>",
    "audienceOverlapClusters": ["<related niche>", "<related niche>", "<related niche>"],
    "blueOceanArchetype": "<channel type that doesn't exist yet but the audience clearly wants>"
  },

  "nicheSummary": "<3-4 sentences summarizing this niche, its audience, and the biggest opportunity for a new creator>"
}`,d=(await (0,c.e)(p)).replace(/```json\n?/g,"").replace(/```\n?/g,"").trim();try{t=JSON.parse(d)}catch{let e=d.match(/\{[\s\S]*\}/);t=e?JSON.parse(e[0]):{error:"Failed to parse AI response",raw:d.slice(0,500)}}return o.NextResponse.json({geography:a,...t})}catch(t){let e=t?.message||"AI analysis failed";return console.error("Niche analyze error:",e),o.NextResponse.json({error:e},{status:500})}}let d=new i.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/analyze/niche/route",pathname:"/api/analyze/niche",filename:"route",bundlePath:"app/api/analyze/niche/route"},resolvedPagePath:"C:\\Users\\HP\\Desktop\\youtubenichefinder\\src\\app\\api\\analyze\\niche\\route.ts",nextConfigOutput:"",userland:n}),{workAsyncStorage:h,workUnitAsyncStorage:m,serverHooks:y}=d;function f(){return(0,s.patchFetch)({workAsyncStorage:h,workUnitAsyncStorage:m})}},96487:()=>{},78335:()=>{},54911:(e,t,r)=>{"use strict";r.d(t,{e:()=>s});var n=r(36858);let i=process.env.GEMINI_API_KEY||"",a=new n.ij(i);async function s(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 a.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),n=t.X(0,[638,452,858],()=>r(36428));module.exports=n})();