const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/cloudWorkspaceReports-Dmj54Z_p.js","assets/norm-f7iXVy-b.js","assets/appConfig-CDeG57c-.js","assets/jsx-runtime-CutOxEx1.js","assets/cloudWorkspaceClient-CCTm89GG.js","assets/preload-helper-DzyYoeor.js","assets/authSession-Dulxhbeq.js"])))=>i.map(i=>d[i]);
import{t as e}from"./preload-helper-DzyYoeor.js";import{r as t}from"./norm-f7iXVy-b.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-Dmj54Z_p.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};