(()=>{var a={};a.id=227,a.ids=[227],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},1421:a=>{"use strict";a.exports=require("node:child_process")},1799:(a,b,c)=>{"use strict";c.d(b,{bE:()=>m,sA:()=>k});var d=c(3873),e=c.n(d),f=c(1820),g=c.n(f),h=c(9021),i=c.n(h);let j=e().join(g().homedir(),".idea-manager","data");function k(){return e().join((i().existsSync(j)||i().mkdirSync(j,{recursive:!0}),j),"im.db")}let l=e().join(g().homedir(),".idea-manager","sync");function m(){return i().existsSync(l)||i().mkdirSync(l,{recursive:!0}),l}},1820:a=>{"use strict";a.exports=require("os")},3033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3873:a=>{"use strict";a.exports=require("path")},4870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},5440:(a,b,c)=>{"use strict";c.d(b,{t:()=>r,L:()=>s});var d=c(9021),e=c.n(d),f=c(3873),g=c.n(f),h=c(1799),i=c(1421);let j=!1,k=null,l="";async function m(){let a=new Date,b=a.getHours(),c=`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}-${String(a.getDate()).padStart(2,"0")}`;if(9===b&&l!==c)try{await r();let a=s(),b=a.prepare("SELECT t.title, t.status, p.name as project_name FROM tasks t JOIN projects p ON t.project_id = p.id WHERE t.is_today = 1 AND t.status != 'done'").all(),d=a.prepare("SELECT COUNT(*) as count FROM tasks WHERE status IN ('submitted', 'testing')").get(),e=a.prepare("SELECT COUNT(*) as count FROM tasks WHERE status = 'problem'").get(),f=[];if(b.length>0){for(let a of(f.push(`Today: ${b.length}개`),b.slice(0,5)))f.push(`  - ${a.title}`);b.length>5&&f.push(`  ... +${b.length-5}개`)}else f.push("Today 태스크가 없습니다.");d.count>0&&f.push(`진행 중: ${d.count}개`),e.count>0&&f.push(`문제: ${e.count}개`),function(a,b){if("darwin"!==process.platform)return console.log(`[${a}] ${b}`);let c=b.replace(/"/g,'\\"').replace(/\n/g,"\\n"),d=`display notification "${c}" with title "${a}"`;(0,i.exec)(`osascript -e '${d}'`,a=>{a&&console.error("[Scheduler] notification error:",a.message)})}("IM - 오늘의 할 일",f.join("\n")),l=c}catch(a){console.error("[Scheduler] error:",a)}}class n{constructor(a,b){this.dirty=!1,this.inTransaction=!1,this.db=a,this.dbPath=b}save(){if(!this.dirty)return;let a=this.db.export(),b=`${this.dbPath}.tmp-${process.pid}`;try{e().writeFileSync(b,Buffer.from(a)),e().renameSync(b,this.dbPath)}catch(a){try{e().unlinkSync(b)}catch{}throw a}this.dirty=!1}immediatelySave(){this.dirty=!0,this.inTransaction||this.save()}rowsToObjects(a,b){return b.map(b=>{let c={};return a.forEach((a,d)=>{c[a]=b[d]}),c})}prepare(a){let b=this,c=/^\s*(INSERT|UPDATE|DELETE|CREATE|ALTER|DROP)/i.test(a);return{all(...c){let d=b.db.prepare(a);c.length>0&&d.bind(c);let e=d.getColumnNames(),f=[];for(;d.step();)f.push(d.get());return d.free(),b.rowsToObjects(e,f)},get(...c){let d,e=b.db.prepare(a);if(c.length>0&&e.bind(c),e.step()){let a=e.getColumnNames(),b=e.get(),c={};a.forEach((a,d)=>{c[a]=b[d]}),d=c}return e.free(),d},run:(...d)=>(b.db.run(a,d),c&&b.immediatelySave(),{changes:b.db.getRowsModified()})}}exec(a){this.db.exec(a),/^\s*(INSERT|UPDATE|DELETE|CREATE|ALTER|DROP)/im.test(a)&&this.immediatelySave()}pragma(a){if(a.startsWith("table_info(")){let b=a.match(/table_info\((\w+)\)/)?.[1];if(!b)return[];let c=this.db.exec(`PRAGMA table_info(${b})`);return c.length?this.rowsToObjects(c[0].columns,c[0].values):[]}if(a.includes("journal_mode")||a.includes("wal_checkpoint"))return this.immediatelySave(),"memory";if(a.includes("foreign_keys")){try{this.db.run(`PRAGMA ${a}`)}catch{}return}try{let b=this.db.exec(`PRAGMA ${a}`);if(b.length>0&&b[0].values.length>0)return b[0].values[0][0]}catch{}}transaction(a){let b=this;return()=>{b.inTransaction=!0,b.db.run("BEGIN");try{let c=a();return b.db.run("COMMIT"),b.inTransaction=!1,b.immediatelySave(),c}catch(a){b.inTransaction=!1;try{b.db.run("ROLLBACK")}catch{}throw a}}}close(){this.immediatelySave(),this.db.close()}}let o=null,p=null;async function q(){let a,b;if(o)return o;let d=c(9661);try{a=g().dirname(9661)}catch{a=""}let f=await d(a?{locateFile:b=>g().join(a,b)}:void 0),i=(0,h.sA)(),l=g().dirname(i);if(e().existsSync(l)||e().mkdirSync(l,{recursive:!0}),e().existsSync(i)){let a=e().readFileSync(i);b=new f.Database(a)}else b=new f.Database;return!function(a){a.exec(`
    CREATE TABLE IF NOT EXISTS projects (
      id TEXT PRIMARY KEY,
      name TEXT NOT NULL,
      description TEXT NOT NULL DEFAULT '',
      project_path TEXT,
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      updated_at TEXT NOT NULL DEFAULT (datetime('now'))
    );

    CREATE TABLE IF NOT EXISTS brainstorms (
      id TEXT PRIMARY KEY,
      project_id TEXT NOT NULL,
      content TEXT NOT NULL DEFAULT '',
      version INTEGER NOT NULL DEFAULT 1,
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      updated_at TEXT NOT NULL DEFAULT (datetime('now')),
      FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
    );

  `);let b=a.prepare("PRAGMA table_info(projects)").all();b.some(a=>"project_path"===a.name)||a.exec("ALTER TABLE projects ADD COLUMN project_path TEXT"),b.some(a=>"ai_context"===a.name)||a.exec("ALTER TABLE projects ADD COLUMN ai_context TEXT NOT NULL DEFAULT ''"),b.some(a=>"watch_enabled"===a.name)||a.exec("ALTER TABLE projects ADD COLUMN watch_enabled INTEGER NOT NULL DEFAULT 0"),b.some(a=>"agent_type"===a.name)||a.exec("ALTER TABLE projects ADD COLUMN agent_type TEXT NOT NULL DEFAULT 'claude'"),a.exec(`
    CREATE TABLE IF NOT EXISTS sub_projects (
      id TEXT PRIMARY KEY,
      project_id TEXT NOT NULL,
      name TEXT NOT NULL,
      description TEXT NOT NULL DEFAULT '',
      folder_path TEXT,
      sort_order INTEGER NOT NULL DEFAULT 0,
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      updated_at TEXT NOT NULL DEFAULT (datetime('now')),
      FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
    );

    CREATE TABLE IF NOT EXISTS tasks (
      id TEXT PRIMARY KEY,
      project_id TEXT NOT NULL,
      sub_project_id TEXT NOT NULL,
      title TEXT NOT NULL,
      description TEXT NOT NULL DEFAULT '',
      status TEXT NOT NULL DEFAULT 'idea'
        CHECK(status IN ('idea','doing','writing','submitted','testing','done','problem')),
      priority TEXT NOT NULL DEFAULT 'medium'
        CHECK(priority IN ('high','medium','low')),
      is_today INTEGER NOT NULL DEFAULT 0,
      sort_order INTEGER NOT NULL DEFAULT 0,
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      updated_at TEXT NOT NULL DEFAULT (datetime('now')),
      FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
      FOREIGN KEY (sub_project_id) REFERENCES sub_projects(id) ON DELETE CASCADE
    );

    CREATE TABLE IF NOT EXISTS task_prompts (
      id TEXT PRIMARY KEY,
      task_id TEXT NOT NULL UNIQUE,
      content TEXT NOT NULL DEFAULT '',
      prompt_type TEXT NOT NULL DEFAULT 'manual'
        CHECK(prompt_type IN ('manual','ai_assisted')),
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      updated_at TEXT NOT NULL DEFAULT (datetime('now')),
      FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE
    );

    CREATE TABLE IF NOT EXISTS global_memos (
      id TEXT PRIMARY KEY,
      content TEXT NOT NULL DEFAULT '',
      updated_at TEXT NOT NULL DEFAULT (datetime('now'))
    );

    CREATE TABLE IF NOT EXISTS task_conversations (
      id TEXT PRIMARY KEY,
      task_id TEXT NOT NULL,
      role TEXT NOT NULL CHECK(role IN ('assistant','user')),
      content TEXT NOT NULL,
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE
    );
  `),a.exec(`
    CREATE TABLE IF NOT EXISTS distribution_history (
      id TEXT PRIMARY KEY,
      project_id TEXT NOT NULL,
      source TEXT NOT NULL DEFAULT 'auto-distribute',
      created_sub_project_ids TEXT NOT NULL DEFAULT '[]',
      created_task_ids TEXT NOT NULL DEFAULT '[]',
      summary TEXT NOT NULL DEFAULT '',
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      rolled_back_at TEXT,
      FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
    );
  `),a.exec(`
    CREATE TABLE IF NOT EXISTS global_conversations (
      id TEXT PRIMARY KEY,
      project_id TEXT NOT NULL DEFAULT '__global__',
      role TEXT NOT NULL CHECK(role IN ('assistant','user','system')),
      content TEXT NOT NULL,
      created_at TEXT NOT NULL DEFAULT (datetime('now'))
    );

    CREATE TABLE IF NOT EXISTS project_conversations (
      id TEXT PRIMARY KEY,
      project_id TEXT NOT NULL,
      role TEXT NOT NULL CHECK(role IN ('assistant','user','system')),
      content TEXT NOT NULL,
      created_at TEXT NOT NULL DEFAULT (datetime('now')),
      FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
    );
  `);let c=a.prepare("PRAGMA table_info(tasks)").all();c.some(a=>"is_archived"===a.name)||a.exec("ALTER TABLE tasks ADD COLUMN is_archived INTEGER NOT NULL DEFAULT 0"),c.some(a=>"tags"===a.name)||a.exec("ALTER TABLE tasks ADD COLUMN tags TEXT NOT NULL DEFAULT '[]'");let d="\x3c!-- legacy-prompt --\x3e",e=a.prepare(`
    SELECT tp.task_id AS task_id, tp.content AS content, t.description AS description
    FROM task_prompts tp
    JOIN tasks t ON t.id = tp.task_id
    WHERE tp.content IS NOT NULL AND TRIM(tp.content) <> ''
      AND (t.description IS NULL OR t.description NOT LIKE '%${d}%')
  `).all();if(e.length>0){let b=a.prepare("UPDATE tasks SET description = ? WHERE id = ?");for(let a of e){let c=(a.description??"").trimEnd(),e=[c,c?"":null,c?"---":null,`${d}`,"**Legacy Prompt**","",a.content.trim()].filter(a=>null!==a).join("\n");b.run(e,a.task_id)}}let f=a.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='tasks'").get();f&&!f.sql.includes("'doing'")&&a.exec(`
      CREATE TABLE tasks_new (
        id TEXT PRIMARY KEY,
        project_id TEXT NOT NULL,
        sub_project_id TEXT NOT NULL,
        title TEXT NOT NULL,
        description TEXT NOT NULL DEFAULT '',
        status TEXT NOT NULL DEFAULT 'idea'
          CHECK(status IN ('idea','doing','writing','submitted','testing','done','problem')),
        priority TEXT NOT NULL DEFAULT 'medium'
          CHECK(priority IN ('high','medium','low')),
        is_today INTEGER NOT NULL DEFAULT 0,
        sort_order INTEGER NOT NULL DEFAULT 0,
        created_at TEXT NOT NULL DEFAULT (datetime('now')),
        updated_at TEXT NOT NULL DEFAULT (datetime('now')),
        is_archived INTEGER NOT NULL DEFAULT 0,
        tags TEXT NOT NULL DEFAULT '[]',
        FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
        FOREIGN KEY (sub_project_id) REFERENCES sub_projects(id) ON DELETE CASCADE
      );
      INSERT INTO tasks_new (id, project_id, sub_project_id, title, description, status, priority, is_today, sort_order, created_at, updated_at, is_archived, tags)
        SELECT id, project_id, sub_project_id, title, description, status, priority, is_today, sort_order, created_at, updated_at, is_archived, tags FROM tasks;
      DROP TABLE tasks;
      ALTER TABLE tasks_new RENAME TO tasks;
    `)}(o=new n(b,i)),process.on("exit",()=>o?.close()),j||(j=!0,k=setInterval(m,6e4),k.unref?.(),m(),console.log("[Scheduler] Morning notification scheduler started")),o}async function r(){return o||(p||(p=q()),p)}function s(){if(!o)throw Error("Database not initialized. Call await ensureDb() first.");return o}},6439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},6487:()=>{},8335:()=>{},9021:a=>{"use strict";a.exports=require("fs")},9294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},9616:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>D,patchFetch:()=>C,routeModule:()=>y,serverHooks:()=>B,workAsyncStorage:()=>z,workUnitAsyncStorage:()=>A});var d={};c.r(d),c.d(d,{POST:()=>x});var e=c(9225),f=c(4006),g=c(8317),h=c(9373),i=c(4775),j=c(4235),k=c(261),l=c(4365),m=c(771),n=c(3461),o=c(7798),p=c(2280),q=c(2018),r=c(5696),s=c(7929),t=c(6439),u=c(7527),v=c(5592),w=c(5440);async function x(a,{params:b}){await (0,w.t)(),await b;let c=await a.json();if(!Array.isArray(c.orderedIds)||0===c.orderedIds.length)return v.NextResponse.json({error:"orderedIds array required"},{status:400});let d=(0,w.L)(),e=new Date().toISOString(),f=d.prepare("UPDATE tasks SET sort_order = ?, updated_at = ? WHERE id = ?");for(let a=0;a<c.orderedIds.length;a++)f.run(a,e,c.orderedIds[a]);return v.NextResponse.json({ok:!0})}let y=new e.AppRouteRouteModule({definition:{kind:f.RouteKind.APP_ROUTE,page:"/api/projects/[id]/sub-projects/[subId]/tasks/reorder/route",pathname:"/api/projects/[id]/sub-projects/[subId]/tasks/reorder",filename:"route",bundlePath:"app/api/projects/[id]/sub-projects/[subId]/tasks/reorder/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/Users/young/Toy/idea-manager/src/app/api/projects/[id]/sub-projects/[subId]/tasks/reorder/route.ts",nextConfigOutput:"standalone",userland:d}),{workAsyncStorage:z,workUnitAsyncStorage:A,serverHooks:B}=y;function C(){return(0,g.patchFetch)({workAsyncStorage:z,workUnitAsyncStorage:A})}async function D(a,b,c){y.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/projects/[id]/sub-projects/[subId]/tasks/reorder/route";"/index"===d&&(d="/");let e=await y.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!e)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:g,params:v,nextConfig:w,parsedUrl:x,isDraftMode:z,prerenderManifest:A,routerServerContext:B,isOnDemandRevalidate:C,revalidateOnlyGenerated:D,resolvedPathname:E,clientReferenceManifest:F,serverActionsManifest:G}=e,H=(0,k.normalizeAppPath)(d),I=!!(A.dynamicRoutes[H]||A.routes[E]),J=async()=>((null==B?void 0:B.render404)?await B.render404(a,b,x,!1):b.end("This page could not be found"),null);if(I&&!z){let a=!!A.routes[E],b=A.dynamicRoutes[H];if(b&&!1===b.fallback&&!a){if(w.experimental.adapterPath)return await J();throw new t.NoFallbackError}}let K=null;!I||y.isDev||z||(K="/index"===(K=E)?"/":K);let L=!0===y.isDev||!I,M=I&&!L;G&&F&&(0,j.setManifestsSingleton)({page:d,clientReferenceManifest:F,serverActionsManifest:G});let N=a.method||"GET",O=(0,i.getTracer)(),P=O.getActiveScopeSpan(),Q={params:v,prerenderManifest:A,renderOpts:{experimental:{authInterrupts:!!w.experimental.authInterrupts},cacheComponents:!!w.cacheComponents,supportsDynamicResponse:L,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:w.cacheLife,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>y.onRequestError(a,b,d,e,B)},sharedContext:{buildId:g}},R=new l.NodeNextRequest(a),S=new l.NodeNextResponse(b),T=m.NextRequestAdapter.fromNodeNextRequest(R,(0,m.signalFromNodeResponse)(b));try{let e=async a=>y.handle(T,Q).finally(()=>{if(!a)return;a.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let c=O.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==n.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route");if(e){let b=`${N} ${e}`;a.setAttributes({"next.route":e,"http.route":e,"next.span_name":b}),a.updateName(b)}else a.updateName(`${N} ${d}`)}),g=!!(0,h.getRequestMeta)(a,"minimalMode"),j=async h=>{var i,j;let k=async({previousCacheEntry:f})=>{try{if(!g&&C&&D&&!f)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await e(h);a.fetchMetrics=Q.renderOpts.fetchMetrics;let i=Q.renderOpts.pendingWaitUntil;i&&c.waitUntil&&(c.waitUntil(i),i=void 0);let j=Q.renderOpts.collectedTags;if(!I)return await (0,p.I)(R,S,d,Q.renderOpts.pendingWaitUntil),null;{let a=await d.blob(),b=(0,q.toNodeOutgoingHttpHeaders)(d.headers);j&&(b[s.NEXT_CACHE_TAGS_HEADER]=j),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==Q.renderOpts.collectedRevalidate&&!(Q.renderOpts.collectedRevalidate>=s.INFINITE_CACHE)&&Q.renderOpts.collectedRevalidate,e=void 0===Q.renderOpts.collectedExpire||Q.renderOpts.collectedExpire>=s.INFINITE_CACHE?void 0:Q.renderOpts.collectedExpire;return{value:{kind:u.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==f?void 0:f.isStale)&&await y.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,o.c)({isStaticGeneration:M,isOnDemandRevalidate:C})},!1,B),b}},l=await y.handleResponse({req:a,nextConfig:w,cacheKey:K,routeKind:f.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:A,isRoutePPREnabled:!1,isOnDemandRevalidate:C,revalidateOnlyGenerated:D,responseGenerator:k,waitUntil:c.waitUntil,isMinimalMode:g});if(!I)return null;if((null==l||null==(i=l.value)?void 0:i.kind)!==u.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(j=l.value)?void 0:j.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});g||b.setHeader("x-nextjs-cache",C?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),z&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,q.fromNodeOutgoingHttpHeaders)(l.value.headers);return g&&I||m.delete(s.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||b.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,r.getCacheControlHeader)(l.cacheControl)),await (0,p.I)(R,S,new Response(l.value.body,{headers:m,status:l.value.status||200})),null};P?await j(P):await O.withPropagatedContext(a.headers,()=>O.trace(n.BaseServerSpan.handleRequest,{spanName:`${N} ${d}`,kind:i.SpanKind.SERVER,attributes:{"http.method":N,"http.target":a.url}},j))}catch(b){if(b instanceof t.NoFallbackError||await y.onRequestError(a,b,{routerKind:"App Router",routePath:H,routeType:"route",revalidateReason:(0,o.c)({isStaticGeneration:M,isOnDemandRevalidate:C})},!1,B),I)throw b;return await (0,p.I)(R,S,new Response(null,{status:500})),null}}},9661:a=>{"use strict";a.exports=require("sql.js/dist/sql-wasm.js")}};var b=require("../../../../../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[445,813],()=>b(b.s=9616));module.exports=c})();