import{d as K,P as S,x as T,e as b,y as B,a as o,W as M,a7 as q,C as v,V as L,D as m}from"./index-7945cc5d.js";import{M as x}from"./index-264ec3df.js";import{s as u}from"./index.module-eee8096f.js";import{a as E,u as H}from"./index-ce5f9846.js";const O=K({name:"unit-detail",setup(){const D=S(),{x:N,y:I}=E(),e=T({detailId:D.query.detailId,loading:!1,background:"transparent",color:"transparent",dataInfo:{},title:" ",listKnowledge:[],prevDetailId:"",nextDetailId:""}),p=async()=>{e.loading=!0;try{const{data:a}=await m.get("/edu-app/lessonCoursewareKnowledgeDetail/detail/"+e.detailId);e.dataInfo=a,e.title=a.name}catch(a){}e.loading=!1},k=async()=>{try{const a={lessonCoursewareId:D.query.lessonCoursewareId};L().ios&&(a.platform="iOS-STUDENT",a.verson=D.query.verson||"1.0.8");const{data:n}=await m.post("/edu-app/lessonCoursewareDetail/listKnowledge",{data:a});e.listKnowledge=n||[]}catch(a){}},h=b(()=>{var f,w,g;const a=e.listKnowledge||[];let n=a.findIndex(t=>{var s;return t.id===((s=e.dataInfo)==null?void 0:s.lessonCoursewareDetailId)});const l=a.find(t=>{var s;return t.id===((s=e.dataInfo)==null?void 0:s.lessonCoursewareDetailId)});if(!l)return!0;let d=(f=l==null?void 0:l.lessonCoursewareDetailKnowledgeDetailList)==null?void 0:f.findIndex(t=>t.id==e.detailId),c=!1,r="";for(;d>=0;){if(d--,d>=0){const t=(w=l==null?void 0:l.lessonCoursewareDetailKnowledgeDetailList)==null?void 0:w[d];t.id&&(c=!0,r=t.id)}if(c)break}if(c)return e.prevDetailId=r,!1;let i=!1;for(;n>=0;){n--;const t=((g=a[n])==null?void 0:g.lessonCoursewareDetailKnowledgeDetailList)||[];let s=t.length;for(;s>0&&(t[s-1]&&(i=!0,r=t[s-1].id),s--,!i););if(i)break}return i&&(e.prevDetailId=r),!i}),y=b(()=>{var f,w,g;const a=e.listKnowledge||[];let n=a.findIndex(t=>{var s;return t.id===((s=e.dataInfo)==null?void 0:s.lessonCoursewareDetailId)});const l=a.find(t=>{var s;return t.id===((s=e.dataInfo)==null?void 0:s.lessonCoursewareDetailId)});if(!l)return!0;let d=(f=l==null?void 0:l.lessonCoursewareDetailKnowledgeDetailList)==null?void 0:f.findIndex(t=>t.id==e.detailId),c=!1,r="";for(;d<(l==null?void 0:l.lessonCoursewareDetailKnowledgeDetailList.length)-1;){if(d++,d>=0){const t=(w=l==null?void 0:l.lessonCoursewareDetailKnowledgeDetailList)==null?void 0:w[d];t.id&&(c=!0,r=t.id)}if(c)break}if(c)return e.nextDetailId=r,!1;let i=!1;for(;n<=a.length-1;){n++;const t=((g=a[n])==null?void 0:g.lessonCoursewareDetailKnowledgeDetailList)||[];let s=0;for(;s<=t.length-1&&(t[s]&&(i=!0,r=t[s].id),s++,!i););if(i)break}return i&&(e.nextDetailId=r),!i}),C=async a=>{I.value=0,window.scrollTo(0,0),a==="up"?(e.detailId=e.prevDetailId,await p()):a==="down"&&(e.detailId=e.nextDetailId,await p())};return B(async()=>{H(document,"scroll",()=>{I.value>52?(e.background="#fff",e.color="#323333"):(e.background="transparent",e.color="transparent")}),await p(),await k()}),()=>{var a,n;return o("div",{class:[u.knowledgeLibrary,L().isTablet?u.knowledgeLibraryTablet:""]},[o(x,{position:"top"},{default:()=>[o(M,{border:!1,background:e.background,color:e.color,title:e.title},null)]}),o("div",{class:[u.containerSection,u.woringSection]},[((a=e.dataInfo)==null?void 0:a.desc)&&o("div",{class:u.woringContent,innerHTML:e.dataInfo.desc},null),!((n=e.dataInfo)!=null&&n.desc)&&!e.loading&&o("div",{class:u.woringContent},[o(q,{description:"暂无内容",style:{paddingTop:"40px"}},null)])]),o(x,{position:"bottom"},{default:()=>[o("div",{class:[u.stickBtnGroup]},[o(v,{round:!0,class:u.prevBtn,disabled:h.value,onClick:()=>C("up")},null),o(v,{round:!0,disabled:y.value,class:u.nextBtn,onClick:()=>C("down")},null)])]})])}}});export{O as default};
