exports.id=166,exports.ids=[166],exports.modules={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}},5359:(a,b,c)=>{"use strict";let d,e;c.d(b,{$:()=>g});var f=c(7598);function g(){return function(a=21){var b;b=a|=0,!d||d.length<b?(d=Buffer.allocUnsafe(128*b),f.webcrypto.getRandomValues(d),e=0):e+b>d.length&&(f.webcrypto.getRandomValues(d),e=0),e+=b;let c="";for(let b=e-a;b<e;b++)c+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&d[b]];return c}(16)}},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}},6487:()=>{},8335:()=>{}};