"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6618],{96618:(e,s,a)=>{a.d(s,{useTaskStore:()=>l});var t=a(1934),d=a(28515);let l=(0,t.v)((e,s)=>({tasks:[],selectedTaskId:null,filter:"all",showCompleted:!1,isLoading:!1,error:null,setTasks:s=>e({tasks:s}),setSelectedTaskId:s=>e({selectedTaskId:s}),setFilter:s=>e({filter:s}),setShowCompleted:s=>e({showCompleted:s}),fetchTasks:async(s,a)=>{d.Y.log("tasks","TaskStore/fetchTasks start",{calendarIds:a||"all"}),e({isLoading:!0,error:null});try{let t=await s.getCalendarTasks(a);d.Y.log("tasks","TaskStore/fetchTasks received",t.length,"tasks"),t.forEach((e,s)=>{d.Y.log("tasks",`TaskStore/fetchTasks [${s}]`,{id:e.id,uid:e.uid,"@type":e["@type"],title:e.title,due:e.due,progress:e.progress,showWithoutTime:e.showWithoutTime,calendarIds:e.calendarIds})}),e({tasks:t,isLoading:!1})}catch(s){d.Y.error("TaskStore/fetchTasks failed",s),e({isLoading:!1,error:"Failed to fetch tasks"})}},createTask:async(a,t)=>{d.Y.log("tasks","TaskStore/createTask",t);let l=await a.createCalendarTask(t);return d.Y.log("tasks","TaskStore/createTask result",{id:l.id,uid:l.uid,title:l.title}),e({tasks:[...s().tasks,l]}),l},updateTask:async(a,t,d)=>{await a.updateCalendarTask(t,d),e({tasks:s().tasks.map(e=>e.id===t?{...e,...d,updated:new Date().toISOString()}:e)})},deleteTask:async(a,t)=>{await a.deleteCalendarTask(t),e({tasks:s().tasks.filter(e=>e.id!==t),selectedTaskId:s().selectedTaskId===t?null:s().selectedTaskId})},toggleTaskComplete:async(a,t)=>{let d={progress:"completed"===t.progress?"needs-action":"completed",progressUpdated:new Date().toISOString()};await a.updateCalendarTask(t.id,d),e({tasks:s().tasks.map(e=>e.id===t.id?{...e,...d,updated:new Date().toISOString()}:e)})},clearTasks:()=>e({tasks:[],selectedTaskId:null,error:null})}))}}]);