(()=>{var e={};e.id=8453,e.ids=[8453],e.modules={3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3498:e=>{"use strict";e.exports=require("mysql2/promise")},5069:(e,t,T)=>{"use strict";let r;T.d(t,{A:()=>d});var s=T(3498),i=T.n(s),E=T(29021),a=T.n(E),n=T(33873),o=T.n(n);try{r=T(46293)}catch(e){console.warn("sql.js not installed or failed to load")}let l=null,c=null;try{l=i().createPool({host:process.env.DB_HOST||"localhost",port:Number(process.env.DB_PORT)||3306,user:process.env.DB_USER||"root",password:process.env.DB_PASSWORD||"",database:process.env.DB_NAME||"mobile_insights",charset:"utf8mb4",waitForConnections:!0,connectionLimit:10,connectTimeout:1e3})}catch(e){console.warn("MySQL pool creation failed, using SQLite fallback:",e)}async function u(){if(c)return c;if(!r)throw Error("sql.js is not available");console.log("Initializing in-memory SQLite database...");let e=new(await r()).Database;for(let t of[`CREATE TABLE IF NOT EXISTS brands (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      name TEXT NOT NULL UNIQUE,
      gsmarena_url TEXT NOT NULL,
      device_count INTEGER DEFAULT 0,
      scraped_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )`,`CREATE TABLE IF NOT EXISTS devices (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      brand_id INTEGER NOT NULL,
      name TEXT NOT NULL,
      gsmarena_url TEXT NOT NULL UNIQUE,
      thumbnail_url TEXT DEFAULT NULL,
      summary TEXT DEFAULT NULL,
      scraped_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )`,`CREATE TABLE IF NOT EXISTS device_specs (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      device_id INTEGER NOT NULL UNIQUE,
      announced TEXT, status TEXT, network TEXT, os TEXT,
      chipset TEXT, cpu TEXT, gpu TEXT,
      display_size TEXT, display_type TEXT, display_res TEXT,
      ram TEXT, storage TEXT,
      main_camera TEXT, selfie_camera TEXT,
      battery TEXT, charging TEXT,
      nfc TEXT, usb TEXT, bluetooth TEXT, wlan TEXT,
      colors TEXT, weight TEXT, dimensions TEXT,
      sim TEXT, sensors TEXT, popularity TEXT,
      fans TEXT, rating TEXT, full_specs_json TEXT,
      scraped_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )`,`CREATE TABLE IF NOT EXISTS device_pictures (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      device_id INTEGER NOT NULL,
      url TEXT NOT NULL,
      position INTEGER DEFAULT 0,
      UNIQUE(device_id, url)
    )`,`CREATE TABLE IF NOT EXISTS wishlist (
      user_id INTEGER NOT NULL,
      device_slug TEXT NOT NULL,
      PRIMARY KEY (user_id, device_slug)
    )`,`CREATE TABLE IF NOT EXISTS comparisons_log (
      slug1 TEXT NOT NULL,
      slug2 TEXT NOT NULL,
      count INTEGER DEFAULT 1,
      last_compared TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      PRIMARY KEY (slug1, slug2)
    )`,`CREATE TABLE IF NOT EXISTS users (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      name TEXT NOT NULL,
      email TEXT NOT NULL UNIQUE,
      password_hash TEXT NOT NULL,
      is_admin INTEGER DEFAULT 0,
      avatar_url TEXT,
      wishlist TEXT DEFAULT '[]',
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )`,`CREATE TABLE IF NOT EXISTS seo_meta (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      page_key TEXT NOT NULL UNIQUE,
      title TEXT, description TEXT, keywords TEXT,
      og_title TEXT, og_image TEXT, canonical TEXT,
      json_ld TEXT, noindex INTEGER DEFAULT 0,
      twitter_card TEXT, twitter_title TEXT,
      twitter_description TEXT, twitter_image TEXT,
      schema_type TEXT
    )`,`CREATE TABLE IF NOT EXISTS site_settings (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      key_name TEXT NOT NULL UNIQUE,
      value TEXT
    )`,`CREATE TABLE IF NOT EXISTS news_articles (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      slug TEXT NOT NULL UNIQUE,
      title TEXT NOT NULL,
      excerpt TEXT,
      category TEXT DEFAULT 'news',
      author TEXT DEFAULT 'MobilePhoneCompare',
      thumbnail_url TEXT,
      related_device_slug TEXT,
      related_brand TEXT,
      published_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      is_featured INTEGER DEFAULT 0,
      views INTEGER DEFAULT 0
    )`,`CREATE TABLE IF NOT EXISTS upcoming_phones (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      slug TEXT NOT NULL UNIQUE,
      name TEXT NOT NULL,
      brand TEXT NOT NULL,
      brand_color TEXT DEFAULT '#ff6e14',
      expected_price TEXT,
      launch_quarter TEXT,
      launch_date TEXT,
      status TEXT DEFAULT 'Rumored',
      thumbnail_url TEXT,
      chipset TEXT, ram TEXT, camera TEXT, battery TEXT, display TEXT,
      hype INTEGER DEFAULT 0,
      followers TEXT DEFAULT '0',
      description TEXT,
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )`])try{e.run(t)}catch(e){console.warn("CREATE TABLE warning:",e.message)}try{let t=o().join(process.cwd(),"mobile_insights.sql");if(a().existsSync(t)){console.log("Loading mobile_insights.sql into SQLite...");let T=a().readFileSync(t,"utf8"),r=[],s="",i=!1;for(let e=0;e<T.length;e++){let t=T[e];if("'"===t&&"\\"!==T[e-1]&&(i=!i),";"!==t||i)s+=t;else{let e=s.trim();e&&!e.startsWith("--")&&r.push(e),s=""}}let E=0;for(let t of r)if(t)try{e.run(t),E++}catch(e){t.trimStart().toUpperCase().startsWith("INSERT")||console.warn("SQL init warning:",t.substring(0,80),"|",e.message)}console.log(`Loaded ${E}/${r.length} statements from mobile_insights.sql`)}else console.warn("mobile_insights.sql not found — run: node scripts/csv_to_sql.mjs")}catch(e){console.error("Failed to load mobile_insights.sql:",e)}try{let T=o().join(process.cwd(),"seed.sql");if(a().existsSync(T)){var t;for(let t of a().readFileSync(T,"utf8").replace(/^\s*--.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/START TRANSACTION;/gi,"").replace(/COMMIT;/gi,"").replace(/LOCK TABLES `[^`]+` WRITE;/gi,"").replace(/UNLOCK TABLES;/gi,"").replace(/SET SQL_MODE[\s\S]*?;/gi,"").replace(/SET time_zone[\s\S]*?;/gi,"").replace(/ALTER TABLE `[^`]+`[\s\S]*?;/gi,"").replace(/ON UPDATE current_timestamp\(\)/gi,"").replace(/DEFAULT current_timestamp\(\)/gi,"DEFAULT CURRENT_TIMESTAMP").replace(/\b(?:int|integer|tinyint|smallint|mediumint|bigint)\(\d+\)(?:\s+unsigned)?/gi,"INTEGER").replace(/\b(?:double|decimal\(\d+,\d+\))\b/gi,"REAL").replace(/\bunsigned\b/gi,"").replace(/\bdatetime\b/gi,"TIMESTAMP").replace(/\blongtext\b/gi,"TEXT").replace(/COLLATE \w+/gi,"").replace(/CHARACTER SET \w+/gi,"").replace(/DEFAULT CHARSET=\w+/gi,"").replace(/ENGINE=InnoDB\b[^;]*;?/gi,";").replace(/\\'/g,"''").replace(/\\"/g,'"').replace(/INSERT IGNORE INTO/gi,"INSERT OR IGNORE INTO").split(";"))if(t=t.trim())try{e.run(t)}catch{}}}catch(e){console.error("Failed to load seed.sql:",e)}return c=e,console.log("In-memory SQLite database initialized successfully."),c}let d={execute:async(e,t=[])=>{if(l)try{return await l.execute(e,t)}catch(e){if(!("ECONNREFUSED"===e.code||"PROTOCOL_CONNECTION_LOST"===e.code||"ETIMEDOUT"===e.code||e.message?.includes("connect")))throw e;console.warn("MySQL connection failed. Falling back to SQLite database...")}let T=await u(),r=function(e){let t=e.replace(/\bUNSIGNED\b/gi,"INTEGER");return(t=t.replace(/\bNOW\(\)/gi,"datetime('now')")).replace(/ON DUPLICATE KEY UPDATE[\s\S]*$/gi,"")}(e);if(/^\s*(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|ALTER)/i.test(r)){T.run(r,t);let e=0,s=0;try{let t=T.exec("SELECT last_insert_rowid()");t.length>0&&(e=t[0].values[0][0]);let r=T.exec("SELECT changes()");r.length>0&&(s=r[0].values[0][0])}catch(e){}return[{insertId:e,affectedRows:s},void 0]}{let e=T.exec(r,t);if(0===e.length)return[[],void 0];let s=e[0].columns;return[e[0].values.map(e=>{let t={};return s.forEach((T,r)=>{t[T]=e[r]}),t}),void 0]}}}},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},21891:(e,t,T)=>{"use strict";T.d(t,{Or:()=>o,wZ:()=>a});var r=T(87806),s=T(77412),i=T(44999);let E=new TextEncoder().encode(process.env.JWT_SECRET||"mobilephonecompare-secret-2026-change-in-prod");async function a(e){return new r.P({...e,is_admin:!0}).setProtectedHeader({alg:"HS256"}).setIssuedAt().setExpirationTime("24h").sign(E)}async function n(e){try{let{payload:t}=await (0,s.V)(e,E);if(!t.is_admin)return null;return{sub:t.sub,name:t.name,email:t.email,is_admin:!0}}catch{return null}}async function o(){let e=await (0,i.UL)(),t=e.get("ps_admin_token")?.value;return t?n(t):null}},28127:(e,t,T)=>{"use strict";T.r(t),T.d(t,{patchFetch:()=>L,routeModule:()=>u,serverHooks:()=>N,workAsyncStorage:()=>d,workUnitAsyncStorage:()=>p});var r={};T.r(r),T.d(r,{GET:()=>l,POST:()=>c});var s=T(96559),i=T(48088),E=T(37719),a=T(32190),n=T(5069),o=T(21891);async function l(e){if(!await (0,o.Or)())return a.NextResponse.json({error:"Unauthorized"},{status:401});let t=e.nextUrl.searchParams.get("page_key")||"";try{if(t){let[e]=await n.A.execute("SELECT * FROM seo_meta WHERE page_key=? LIMIT 1",[t]);return a.NextResponse.json({meta:e[0]||null})}let[e]=await n.A.execute("SELECT id, page_key, title, description, keywords, noindex, updated_at FROM seo_meta ORDER BY updated_at DESC");return a.NextResponse.json({metas:e})}catch(e){return console.error("admin seo GET error:",e),a.NextResponse.json({error:"Server error"},{status:500})}}async function c(e){if(!await (0,o.Or)())return a.NextResponse.json({error:"Unauthorized"},{status:401});try{let{page_key:t,title:T,description:r,keywords:s,og_title:i,og_image:E,canonical:o,json_ld:l,noindex:c,twitter_card:u,twitter_title:d,twitter_description:p,twitter_image:N,schema_type:L}=await e.json();if(!t)return a.NextResponse.json({error:"page_key required"},{status:400});return await n.A.execute(`INSERT INTO seo_meta
         (page_key, title, description, keywords, og_title, og_image, canonical, json_ld,
          noindex, twitter_card, twitter_title, twitter_description, twitter_image, schema_type)
       VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)
       ON DUPLICATE KEY UPDATE
         title=VALUES(title), description=VALUES(description), keywords=VALUES(keywords),
         og_title=VALUES(og_title), og_image=VALUES(og_image), canonical=VALUES(canonical),
         json_ld=VALUES(json_ld), noindex=VALUES(noindex), twitter_card=VALUES(twitter_card),
         twitter_title=VALUES(twitter_title), twitter_description=VALUES(twitter_description),
         twitter_image=VALUES(twitter_image), schema_type=VALUES(schema_type)`,[t,T||null,r||null,s||null,i||null,E||null,o||null,l||null,+!!c,u||null,d||null,p||null,N||null,L||null]),a.NextResponse.json({ok:!0})}catch(e){return console.error("admin seo POST error:",e),a.NextResponse.json({error:"Server error"},{status:500})}}let u=new s.AppRouteRouteModule({definition:{kind:i.RouteKind.APP_ROUTE,page:"/api/admin/seo/route",pathname:"/api/admin/seo",filename:"route",bundlePath:"app/api/admin/seo/route"},resolvedPagePath:"C:\\Users\\Taukeer19\\Desktop\\Website\\mobile-site\\mobile-insights-hub\\src\\app\\api\\admin\\seo\\route.ts",nextConfigOutput:"standalone",userland:r}),{workAsyncStorage:d,workUnitAsyncStorage:p,serverHooks:N}=u;function L(){return(0,E.patchFetch)({workAsyncStorage:d,workUnitAsyncStorage:p})}},29021:e=>{"use strict";e.exports=require("fs")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:e=>{"use strict";e.exports=require("path")},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},46293:e=>{"use strict";e.exports=require("sql.js")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},78335:()=>{},96487:()=>{}};var t=require("../../../../webpack-runtime.js");t.C(e);var T=e=>t(t.s=e),r=t.X(0,[4447,580,4999,4553],()=>T(28127));module.exports=r})();