"use strict";exports.id=7188,exports.ids=[1244,7188],exports.modules={7188:(a,b,c)=>{c.d(b,{buildRecord:()=>w,iq:()=>p,listWidgets:()=>m,readLayout:()=>s,readWidget:()=>n,reconcileLayout:()=>u,writeLayout:()=>t,writeWidget:()=>o});var d=c(73024),e=c(76760),f=c.n(e),g=c(13474),h=c(11244);function i(a){return f().join((0,g.FF)(a),"widgets")}function j(a,b){return f().join(i(a),`${l(b)}.json`)}function k(a){return f().join((0,g.FF)(a),"dashboard-layout.json")}function l(a){return a.replace(/[^A-Za-z0-9_-]/g,"-").slice(0,80)}async function m(a){let b,c=i(a);try{b=await d.promises.readdir(c,{withFileTypes:!0})}catch{return[]}let e=[];for(let a of b)if(a.isFile()&&a.name.toLowerCase().endsWith(".json"))try{let b=await d.promises.readFile(f().join(c,a.name),"utf8"),g=JSON.parse(b);v(g)&&e.push(g)}catch{}return e}async function n(a,b){try{let c=await d.promises.readFile(j(a,b),"utf8"),e=JSON.parse(c);return v(e)?e:null}catch{return null}}async function o(a,b){if(!v(b))throw Error(`Invalid widget record (id=${b.id}, kind=${b.kind})`);await d.promises.mkdir(i(a),{recursive:!0}),await d.promises.writeFile(j(a,b.id),JSON.stringify(b,null,2)+"\n","utf8")}async function p(a,b){try{let c=(0,g.FF)(a),e=f().resolve(c,b),h=f().relative(c,e);if(h.startsWith("..")||f().isAbsolute(h))return null;return await d.promises.readFile(e,"utf8")}catch{return null}}let q={order:["sys:active-goals","sys:pending","sys:recent-kb","sys:ai-suggestions"],hidden:[],sizes:{}},r=new Set(["sm","md","wide"]);async function s(a){try{let b=await d.promises.readFile(k(a),"utf8"),c=JSON.parse(b);if(!Array.isArray(c.order)||!Array.isArray(c.hidden))return q;let e={};if(c.sizes&&"object"==typeof c.sizes)for(let[a,b]of Object.entries(c.sizes))"string"==typeof b&&r.has(b)&&(e[a]=b);return{order:c.order.filter(a=>"string"==typeof a),hidden:c.hidden.filter(a=>"string"==typeof a),sizes:e}}catch{return q}}async function t(a,b){await d.promises.mkdir((0,g.FF)(a),{recursive:!0}),await d.promises.writeFile(k(a),JSON.stringify(b,null,2)+"\n","utf8")}function u(a,b,c){let d=new Set([...b,...c]),e=a.order.filter(a=>d.has(a)),f=a.hidden.filter(a=>d.has(a)),g=new Set([...e,...f]);for(let a of[...c,...b])g.has(a)||e.push(a);let h={};if(a.sizes)for(let[b,c]of Object.entries(a.sizes))d.has(b)&&(h[b]=c);return{order:e,hidden:f,sizes:h}}function v(a){return!!a&&"object"==typeof a&&"string"==typeof a.id&&!!a.id&&"string"==typeof a.title&&"string"==typeof a.kind&&!!h.hU.includes(a.kind)&&!!a.data&&"object"==typeof a.data&&"string"==typeof a.createdAt&&"string"==typeof a.updatedAt&&!0}function w(a){let b=new Date().toISOString(),c=l(a.id);if(!c)throw Error("Widget id is empty after sanitization");if(!h.hU.includes(a.payload.kind))throw Error(`Unknown widget kind: ${a.payload.kind}`);let d=a.refresh??a.existing?.refresh,e=a.memory??a.existing?.memory,f=a.memoryFile??a.existing?.memoryFile,g=a.lastRefreshAt??a.existing?.lastRefreshAt;return{id:c,title:a.title||c,...a.description?{description:a.description}:{},...a.sourceTopicId?{sourceTopicId:a.sourceTopicId}:{},kind:a.payload.kind,data:a.payload.data,createdAt:a.existing?.createdAt??b,updatedAt:b,...a.size?{size:a.size}:a.existing?.size?{size:a.existing.size}:{},...d?{refresh:d}:{},...void 0!==e?{memory:e}:{},...f?{memoryFile:f}:{},...g?{lastRefreshAt:g}:{}}}},11244:(a,b,c)=>{c.d(b,{SYSTEM_WIDGET_IDS:()=>e,VQ:()=>d,hU:()=>f});let d={hourly:36e5,daily:864e5,weekly:6048e5},e=["sys:active-goals","sys:pending","sys:recent-kb","sys:ai-suggestions"],f=["markdown","news-list","link-list","kpi","checklist","quote","kb-pinned","progress","image","stat-table","map","action-list","utility-card"]}};