"use strict";exports.id=269,exports.ids=[269],exports.modules={30269:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{refreshUtilityCard:()=>k});var e=c(56149),f=c(53905),g=c(8118),h=c(49556),i=c(69509),j=a([h]);h=(j.then?(await j)():j)[0];let l=e.Ik({kind:e.k5(["markdown","news-list","link-list","kpi","checklist","quote","kb-pinned","progress","image","stat-table","map","action-list"]),title:e.Yj().optional(),description:e.Yj().optional(),data:e.g1(e.Yj(),e.L5()).default({})});async function k(a,b){try{let c=await (0,f.getRoot)(a);if(!c)return{ok:!1,error:"Root not found"};let d=await (0,i.readWidget)(c.path,b);if(!d||"utility-card"!==d.kind)return{ok:!1,error:"Not a utility-card widget"};let e=d.data,j=await (0,g.getUtility)(e.utilityScope,e.utilityId,"project"===e.utilityScope?a:void 0);if(!j)return{ok:!1,error:"Utility not installed"};let k=j.manifest.card,m=k?.action;if(!m)return{ok:!0,noop:!0};if(!j.manifest.permissions.workers?.enabled)return{ok:!1,error:`${e.utilityId}: card.action needs permissions.workers.enabled`};let n=j.manifest.serverActions.find(a=>a.name===m);if(!n)return{ok:!1,error:`card.action "${m}" not in serverActions`};let o=await (0,h.runServerAction)({utility:j,action:n,args:{}}),p=function(a){if(!a||"object"!=typeof a)return null;let b="snapshot"in a?a.snapshot:a,c=l.safeParse(b);return c.success?c.data:null}(o);if(!p){let a=await (0,i.readWidget)(c.path,b),d=a?.data?.inner;return d?{ok:!0,inner:d}:{ok:!0,noop:!0}}let q={kind:p.kind,data:p.data,...p.title?{title:p.title}:{},...p.description?{description:p.description}:{}},r={...d,data:{...e,inner:q},updatedAt:new Date().toISOString(),lastRefreshAt:new Date().toISOString()};return await (0,i.writeWidget)(c.path,r),{ok:!0,inner:q}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}d()}catch(a){d(a)}})}};