function BoosterNoticesView(props) {
  var h=React.createElement, state=React.useState([]),list=state[0],setList=state[1],err=React.useState(''),error=err[0],setError=err[1],busy=React.useState(false),saving=busy[0],setSaving=busy[1],seq=React.useRef(0),page=React.useRef(1),more=React.useState(false),hasMore=more[0],setHasMore=more[1];
  var key=React.useRef(sessionStorage.getItem('nk_booster_notice_batch')||('notice-'+Date.now().toString(36)+'-'+Math.random().toString(36).slice(2,14)));
  async function request(path,body){var token=localStorage.getItem('nk_user_token')||'',r=await fetch('/api/booster/notices'+path,{method:body?'POST':'GET',headers:{Authorization:'Bearer '+token,'Content-Type':'application/json'},body:body?JSON.stringify(body):undefined}),p=await r.json();if(token!==(localStorage.getItem('nk_user_token')||''))throw Error('登录状态已改变');if(!r.ok||p.code!==0)throw Error(p.message||'公告加载失败');return p.data;}
  async function load(append){var version=++seq.current;setError('');try{if(props.popup)sessionStorage.setItem('nk_booster_notice_batch',key.current);var next=append?page.current+1:1,d=await request(props.popup?'/popup':'?page='+next,props.popup?{batchId:key.current}:null);if(version!==seq.current)return;setList(append?list.concat(d.list):d.list);setHasMore(!!d.hasMore);page.current=next;if(props.popup&&!d.list.length)sessionStorage.removeItem('nk_booster_notice_batch');}catch(e){if(version===seq.current&&!props.popup)setError(e.message);}}
  React.useEffect(function(){load(false);return function(){seq.current++;};},[]);
  async function close(){if(saving)return;setSaving(true);setError('');try{await request('/acknowledge',{batchId:key.current,noticeIds:list.map(n=>n.id)});sessionStorage.removeItem('nk_booster_notice_batch');setList([]);}catch(e){setError(e.message);}finally{setSaving(false);}}
  if(props.popup&&!list.length)return null;
  return h('section',{style:props.popup?{position:'fixed',inset:0,background:'rgba(20,28,44,.48)',zIndex:999,display:'flex',alignItems:'center',justifyContent:'center',padding:20}:{padding:16}},h('div',{role:props.popup?'dialog':undefined,style:{background:'#fff',borderRadius:18,padding:20,width:'100%',boxSizing:'border-box',maxWidth:props.popup?440:undefined}},h('h2',{style:{fontSize:20,marginTop:0}},'打手公告'),!props.popup&&h('button',{onClick:props.onBack},'返回'),h('div',{style:props.popup?{maxHeight:'55vh',overflowY:'auto'}:{}},list.map(n=>h('article',{key:n.id,style:{padding:'12px 0',borderBottom:'1px solid #eee'}},h('h3',{style:{fontSize:17}},n.title),h('small',{style:{color:'#8997ab'}},n.publishedAt?new Date(n.publishedAt).toLocaleString('zh-CN'):''),h('p',{style:{whiteSpace:'pre-wrap',lineHeight:1.8,overflowWrap:'anywhere'}},n.content),!props.popup&&!n.read&&h('button',{onClick:async function(){try{await request('/'+n.id+'/read',{});setList(list.map(x=>x.id===n.id?Object.assign({},x,{read:true}):x));}catch(e){setError(e.message);}}},'标记已读')))),error&&h('p',{role:'alert'},error),props.popup?h('button',{onClick:close,disabled:saving,style:{width:'100%',padding:12,marginTop:20,background:'#e8a20c',color:'#fff',border:0,borderRadius:10}},saving?'正在确认…':'我知道了'):h('button',{onClick:()=>load(hasMore)},hasMore?'加载更多':'刷新公告')));
}
