const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/cloudWorkspaceReports-DVFEojKb.js","assets/norm-CeclA1Tu.js","assets/appConfig-CuVl6yRs.js","assets/chunk-B3pr0VN8.js","assets/cloudWorkspaceClient-CMlIQBWi.js","assets/preload-helper-Dd-HcVz_.js","assets/authSession-CrP9lMPq.js"])))=>i.map(i=>d[i]);
import{t as e}from"./preload-helper-Dd-HcVz_.js";import{r as t}from"./norm-CeclA1Tu.js";var n=`offer_lens_report_session_v1_`,r=1800*1e3,i=async e=>new Promise(t=>{try{let n=chrome?.storage?.session;if(!n?.get)return t(null);n.get({[e]:null},n=>t(n?.[e]??null))}catch{t(null)}}),a=async(e,t)=>new Promise(n=>{try{let r=chrome?.storage?.session;if(!r?.set)return n();r.set({[e]:t},()=>n())}catch{n()}}),o=()=>Date.now(),s=(e,n=o())=>{let i=e&&typeof e==`object`?{...e}:null;if(!i||i.type!==`compare_jobs`||!Array.isArray(i.ids))return{session:null,stale:!1};let a=Number(i.updatedAt||i.heartbeatAt||i.createdAt||0)||0,s=Number(i.heartbeatAt||a||0)||0;i.updatedAt=a||n,s&&(i.heartbeatAt=s);let c=i.status===`running`&&s>0&&n-s>r;if(c){let e=!!(i.fullOut||i.quickOut);i.status=e?`done`:`failed`,e?i.progress=Math.max(100,Number(i.progress||0)):(i.error=t(i.error)||`后台任务已中断，请重新生成`,i.progress=0),i.updatedAt=n,i.heartbeatAt=n}return{session:i,stale:c}},c=async e=>{let r=t(e);if(!r)return null;let o=`${n}${r}`,c=s(await i(o));return c.session?(c.stale&&await a(o,c.session),c.session):null},l=async(r,c)=>{let l=t(r);if(!l)return;let u=`${n}${l}`,d=s(await i(u)).session,f=c&&typeof c==`object`?c:{},p=String(f?.status||d?.status||``).trim(),m={...d&&typeof d==`object`?d:{},...f,updatedAt:o()};(p===`running`||p===`done`||p===`failed`)&&(m.heartbeatAt=o()),await a(u,m);try{let t=d?.status;if(p===`done`||p===`failed`||p&&p!==t){let{cloudWorkspaceUpsertReport:t}=await e(async()=>{let{cloudWorkspaceUpsertReport:e}=await import(`./cloudWorkspaceReports-DVFEojKb.js`);return{cloudWorkspaceUpsertReport:e}},__vite__mapDeps([0,1,2,3,4,5,6]));t({id:l,reportType:`compare_jobs`,title:`岗位对比报告`,jobIds:Array.isArray(m?.ids)?m.ids:[],status:p,progress:m?.progress,error:m?.error})}}catch{}};export{l as n,c as t};