exports.id=7539,exports.ids=[7539],exports.modules={13075:(a,b,c)=>{"use strict";c.d(b,{H6:()=>p,TT:()=>r,_N:()=>q,cY:()=>s});var d=c(51455),e=c(76760),f=c.n(e),g=c(99417);let h="1"===process.env.COCKPIT_DEBUG,i=null,j=null,k=null,l=0,m=!1;function n(){if(k)return k;let a=(0,g.j_)();return i=f().join(a,"debug.jsonl"),j=f().join(a,"debug.prev.jsonl"),k=(0,d.mkdir)(a,{recursive:!0}).then(()=>{})}function o(a){if(!h||!i)return;let b=JSON.stringify({ts:Date.now(),...a})+"\n";(0,d.appendFile)(i,b).catch(()=>{}),i&&j&&!m&&++l%500==0&&(m=!0,(0,d.stat)(i).then(a=>{if(a.size>0x3200000)return(0,d.rename)(i,j)}).catch(()=>{}).finally(()=>{m=!1}))}function p(a,b){h&&n().then(()=>o({dir:"raw",sessionId:a,raw:b}))}function q(a,b,c){h&&n().then(()=>o({dir:"diag",sessionId:a,label:b,...c}))}function r(){return h}function s(...a){h&&console.log(...a)}},53041:(a,b,c)=>{"use strict";c.d(b,{y:()=>i});var d=c(13075);function e(a,b){if(a)return b?`${b.replace(/\/$/,"")}${a}`:a}async function f(a,b,c){let e;for(let f=1;f<=3;f++){let g=new AbortController,h=setTimeout(()=>g.abort(),1e4),i=!1;try{let d=await fetch(b,{...c,signal:g.signal});if(d.ok)return;let f=await d.text().catch(()=>"");e=Error(`${a} ${d.status}: ${f}`),i=d.status<500&&429!==d.status}catch(a){e=a}finally{clearTimeout(h)}if(i)break;f<3&&((0,d.cY)(`[notifications] ${a} attempt ${f}/3 failed, retrying: ${e instanceof Error?e.message:String(e)}`),await new Promise(a=>{var b;return setTimeout(a,(b=f,process.env.VITEST?0:300*2**(b-1)))}))}throw e instanceof Error?e:Error(`${a}: ${String(e)}`)}c(81002);let g={async send(a,b,c){let d,g,h,i,j=(g=(d="error"===a.priority?"[ERROR]":"warning"===a.priority?"[WARN]":"")?`${d} `:"",i=(h=e(a.url,c))?`

${h}`:"",`${g}${a.title}

${a.body}${i}`),k=`https://api.telegram.org/bot${b.botToken}/sendMessage`;await f("Telegram API",k,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chat_id:b.chatId,text:j,disable_web_page_preview:!0})})}},h={async send(a,b,c){let d=(b.serverUrl||"https://ntfy.sh").replace(/\/$/,""),g=`${d}/${b.topic}`,h=e(a.url,c),i={Title:a.title,Priority:"error"===a.priority?"urgent":"warning"===a.priority?"high":"default"};b.token&&(i.Authorization=`Bearer ${b.token}`),h&&(i.Click=h),await f("ntfy",g,{method:"POST",headers:i,body:a.body})}};async function i(a,b){let c=function(a){switch(a){case"telegram":return g;case"ntfy":return h;default:return null}}(a.type);if(!c)return`Unknown provider type: ${a.type}`;try{return await c.send({title:"Cockpit Test Notification",body:"This is a test notification from Cockpit.",priority:"info",source:"test",url:"/inbox"},a.config,b),"ok"}catch(a){return`Failed: ${a instanceof Error?a.message:String(a)}`}}},74423:(a,b,c)=>{"use strict";let d;c.d(b,{BE:()=>q,Xo:()=>o,dk:()=>t,fQ:()=>p,jw:()=>s});var e=c(77598),f=c.n(e),g=c(73024),h=c(51455),i=c(76760),j=c.n(i),k=c(99417);function l(){return j().join((0,k.j_)(),"password.json")}function m(a,b){return new Promise((c,d)=>{f().scrypt(a,b,64,(a,b)=>{a?d(a):c(b)})})}function n(){return null==d&&(d=function(){if(!(0,g.existsSync)(l()))return null;try{let a=c(73024).readFileSync(l(),"utf-8");if(!a.trim())return console.warn("[auth] password.json exists but is empty (likely corrupted by interrupted write)"),null;let b=JSON.parse(a);if(b.hash&&b.salt)return b;return console.warn("[auth] password.json missing hash/salt fields"),null}catch(a){return console.error("[auth] failed to read password.json:",a),null}}()),d}function o(){return!process.env.COCKPIT_TOKEN&&null===n()}async function p(a){await (0,h.mkdir)((0,k.j_)(),{recursive:!0});let b=f().randomBytes(32),c={hash:(await m(a,b)).toString("hex"),salt:b.toString("hex")},e=l(),g=`${e}.tmp.${process.pid}.${Date.now()}`,i=await (0,h.open)(g,"w");await i.writeFile(JSON.stringify(c),"utf-8"),await i.sync(),await i.close(),await (0,h.rename)(g,e),d=c}async function q(a){let b=n();if(!b)return!1;let c=Buffer.from(b.salt,"hex"),d=await m(a,c),e=Buffer.from(b.hash,"hex");return d.length===e.length&&f().timingSafeEqual(d,e)}function r(){let a=n();return a?.hash??null}function s(){let a=r();if(!a)return"";let b=Date.now().toString(16),c=f().createHmac("sha256",a).update(b).digest("hex");return`${b}.${c}`}function t(a){let b=r();if(!b)return!1;if(process.env.COCKPIT_TOKEN&&a===process.env.COCKPIT_TOKEN)return!0;let c=a.indexOf(".");if(-1===c)return!1;let d=a.slice(0,c),e=a.slice(c+1),g=f().createHmac("sha256",b).update(d).digest("hex");return e.length===g.length&&f().timingSafeEqual(Buffer.from(e,"hex"),Buffer.from(g,"hex"))}},78335:()=>{},81002:(a,b,c)=>{"use strict";c.d(b,{hA:()=>j,vF:()=>i});var d=c(73024),e=c(76760),f=c(99417);function g(){return(0,e.join)((0,f.j_)(),"notifications.json")}let h={providers:[]};function i(){try{return{...h,...JSON.parse((0,d.readFileSync)(g(),"utf-8"))}}catch{return{...h}}}function j(a){try{(0,d.mkdirSync)((0,f.j_)(),{recursive:!0}),(0,d.writeFileSync)(g(),JSON.stringify(a,null,2)+"\n")}catch{}return a}},87293:(a,b,c)=>{"use strict";c.d(b,{$M:()=>m,BE:()=>l,Ip:()=>n,NL:()=>o,St:()=>q,ZC:()=>p});var d=c(73024),e=c(76760),f=c.n(e),g=c(99417);function h(){return(0,g.j_)()}function i(){return f().join(h(),"inbox.jsonl")}function j(){if(!(0,d.existsSync)(i()))return[];let a=(0,d.readFileSync)(i(),"utf-8"),b=[];for(let c of a.split("\n"))if(c.trim())try{b.push(JSON.parse(c))}catch{}return b}function k(a){(0,d.existsSync)(h())||(0,d.mkdirSync)(h(),{recursive:!0}),(0,d.writeFileSync)(i(),a.map(a=>JSON.stringify(a)).join("\n")+"\n")}function l(){return j().sort((a,b)=>b.createdAt-a.createdAt)}function m(){return j().filter(a=>!a.read).length}function n(a,b=!0){let c=j(),d=c.find(b=>b.id===a);return!!d&&(d.read=b,k(c),!0)}function o(a=!0){let b=j();for(let c of b)c.read=a;k(b)}function p(a){let b=j(),c=b.findIndex(b=>b.id===a);return -1!==c&&(b.splice(c,1),k(b),!0)}function q(){k([])}c(53041)},96487:()=>{},99417:(a,b,c)=>{"use strict";c.d(b,{Qo:()=>j,Wc:()=>i,du:()=>h,j_:()=>g});var d=c(48161),e=c(76760),f=c.n(e);function g(){return process.env.COCKPIT_CONFIG_DIR??f().join((0,d.homedir)(),".cockpit")}function h(){return process.env.COCKPIT_CACHE_DIR??f().join((0,d.homedir)(),".cache","cockpit")}function i(){return process.env.CLAUDE_CONFIG_DIR??f().join((0,d.homedir)(),".claude")}function j(){return f().join(process.env.CLAUDE_CONFIG_DIR??(0,d.homedir)(),".claude.json")}}};