"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[12768],{36579:function(e,t,n){n.d(t,{Z:function(){return _}});var a=n(42122),r=n.n(a),i=n(17061),c=n.n(i),l=n(17156),o=n.n(l),s=n(27424),u=n.n(s),d=n(67294),p={wrp:"wrp___dq7YK",bgBlack:"bgBlack___ARIUV",monaco:"monaco___VnZC3",darkBlue:"darkBlue___UprA9",close:"close___LKoWu",embed:"embed___hvpEJ"},f=n(71577),h=n(77171),v=n(8691),m=n(83062),g=n(29427),x=n(51412),y=n(82982),w=n(59758),b=n(85893),_=function(e){var t,n,a,i,l,s,_,k=e.editOffice,j=void 0===k?"view":k,E=e.data,C=(e.theme,e.type),S=e.filename,N=e.monacoEditor,R=e.className,Z=e.style,O=e.close,P=e.onClose,T=e.hasMask,L=e.disabledDownload,I=e.onImgDimensions,A=e.showNodata,M=(0,d.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),W=u()(M,2),F=(W[0],W[1],(0,d.useState)("")),H=u()(F,2),V=(H[0],H[1]),B=(0,d.useState)(),z=u()(B,2),D=z[0],U=z[1],$="build"===window.ENV?"/react/build":"",q=location.host.startsWith("localhost")?w.Z.PROXY_SERVER:w.Z.API_SERVER,J=(0,d.useRef)();null!==(t=E)&&void 0!==t&&t.startsWith("/api")&&"txt"!==C&&(E=w.Z.API_SERVER+E),S&&(N.filename=S),(0,d.useEffect)((function(){var e,t,n=null===(e=document.cookie)||void 0===e||null===(t=e.replace(/\s/g,""))||void 0===t?void 0:t.split(";");null==n||n.map((function(e){var t=e.split("=");"_educoder_session"===t[0]&&V(t[1])}))}),[]),(0,d.useEffect)((function(){"office"===C&&X()}),[C,E]);var X=function(){var e=o()(c()().mark((function e(){var t,n,a;return c()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=E,E.startsWith("http")||(t=location.origin+t),n=new URL(t).pathname.split("/").pop(),e.next=5,(0,x.gJ)({attachment_id:n});case 5:a=e.sent,U(a);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),K=function(){Y()},Y=function(){(0,g.Nd)(S||"educoder",decodeURIComponent(E))};return(0,b.jsxs)("div",{style:r()({},Z||{}),className:"".concat(T&&p.bgBlack," ").concat(C?p.wrp:"hide"),children:[O&&(0,b.jsxs)("div",{className:p.close,ref:J,children:[!!I&&(0,b.jsx)(m.Z,{title:"点击对图片进行批注",getPopupContainer:function(){return J.current},children:(0,b.jsx)("span",{onClick:function(){P(),I()},children:(0,b.jsx)("i",{className:"icon-yulanpizhu"})})}),!L&&(0,b.jsx)(m.Z,{title:"点击下载此文件",getPopupContainer:function(){return J.current},children:(0,b.jsx)("span",{onClick:Y,children:(0,b.jsx)("i",{className:"icon-quxiaozhiding"})})}),(0,b.jsx)(m.Z,{title:"关闭",getPopupContainer:function(){return J.current},children:(0,b.jsx)("span",{className:"",onClick:P,children:(0,b.jsx)("i",{className:"icon-guanbi1"})})})]}),(0,b.jsx)("div",{className:"".concat(p[R]," ").concat(R," ").concat(p.monaco," ").concat("txt"===C?"show":"hide"),children:"txt"===C&&(0,b.jsx)(v.ZP,r()({},N))}),"audio"===C&&(0,b.jsx)("audio",{src:(null===(n=E)||void 0===n?void 0:n.indexOf("http"))>-1||null!==(a=E)&&void 0!==a&&a.startsWith("/api")?E:"data:image/png;base64,".concat(E),autoPlay:!0}),"video"===C&&(0,b.jsx)(b.Fragment,{children:(null===(i=E)||void 0===i?void 0:i.indexOf("http"))>-1||null!==(l=E)&&void 0!==l&&l.startsWith("/api")?(0,b.jsx)("video",{controls:!0,src:"".concat(E),autoPlay:!0}):(0,b.jsx)("video",{controls:!0,src:"data:video/mp4;base64,".concat(E),autoPlay:!0})}),"office"===C&&D&&(0,b.jsx)("iframe",{src:"".concat($,"/office.html?key=").concat(D.key,"&url=").concat(q+D.url,"&callbackUrl=").concat(q+D.callbackUrl,"&fileType=").concat(D.fileType,"&title=").concat(D.title,"&model=").concat(j,"&officeServer=").concat(w.Z.ONLYOFFICE,"&disabledDownload=").concat(!!L)}),"html"===C&&(0,b.jsx)("iframe",{src:E+"&disposition=inline"}),"pdf"===C&&(0,b.jsx)("iframe",{src:"".concat($,"/js/pdfview/index.html?url=").concat(E,"&disabledDownload=").concat(!!L)}),"image"===C&&(0,b.jsx)("img",{src:(null===(s=E)||void 0===s?void 0:s.indexOf("http"))>-1||null!==(_=E)&&void 0!==_&&_.startsWith("/api")?E:"data:image/png;base64,".concat(E)}),("other"===C||"download"===C)&&(0,b.jsx)(b.Fragment,{children:A?(0,b.jsx)(y.Z,{customText:"当前文件不支持预览,可点击下载查看",ButtonTwo:(0,b.jsx)(f.ZP,{icon:(0,b.jsx)("i",{className:"iconfont icon-xiazai4 font14"}),type:"primary",size:"middle",onClick:K,children:"下载"})}):(0,b.jsxs)(f.ZP,{type:"primary",size:"middle",onClick:K,children:[(0,b.jsx)(h.Z,{}),"点击下载"]})})]})}},12768:function(e,t,n){n.d(t,{Z:function(){return D}});var a=n(42122),r=n.n(a),i=n(861),c=n.n(i),l=n(74704),o=n.n(l),s=n(27424),u=n.n(s),d=n(67294),p=(n(81897),n(47084)),f=n.n(p),h=n(90621);var v=[],m=["
".concat(e,"
"):'').concat(n?e:(0,h.escape)(e,!0),"\n"):''+(n?e:(0,h.escape)(e,!0))+""},g.heading=function(e,t,n){var a=this.options.headerPrefix+n.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return v.push({anchor:a,level:t,text:e}),"]*>/g;var D=function(e){var t=e.value,n=void 0===t?"":t,a=e.className,i=e.showTextOnly,l=e.showLines,s=e.style,p=void 0===s?{}:s,f=e.stylesPrev,h=void 0===f?{}:f,v=e.highlightKeywords,m=e.showProgramFill,g=(e.isProgramFill,e.disabledFill),x=void 0!==g&&g,b=e.programFillValue,k=e.onFillChange,j=void 0===k?function(e){}:k,E=e.onFillBlur,C=void 0===E?function(){}:E,S=String(n),Z=(0,d.useState)(""),O=u()(Z,2),P=O[0],T=O[1],I=(0,d.useState)("office"),D=u()(I,2),U=D[0],$=D[1],q=(0,d.useState)([]),J=u()(q,2),X=J[0],K=J[1],Y=(0,d.useRef)("a"+(0,F.Z)()),G={},Q=function(e){return e.replace(/([\s\S]+?)<\/style>/gim,(function(e,t){var n=t.replace(/(\n|\r)/g,"").split("}"),a=[];return n.map((function(e){""!=e&&a.push(".".concat(Y.current," ").concat(e))})),"")}))},ee=(0,d.useMemo)((function(){try{S=S.replace(/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,"("+M.Z.API_SERVER+"/api/attachments/").replace(/\"\/api\/attachments\/|\"\/attachments\/download\//g,'"'+M.Z.API_SERVER+"/api/attachments/").replace(/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g,'"'+M.Z.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,"\n")}catch(e){}if(m){var e=-1;return S=S.replaceAll("<","<").replaceAll(">",">").replace(/(@▁▁@|@▁@)/g,(function(t,n,a){return function(e,t){var n=document.createElement(e===B?"input":"textarea");n.style.width="100%",n.style.height=e===B?"40px":"151px",n.rows=5,n.spellcheck=!1,n.name="edu-program-fill",n.placeholder="请输入",n.dataset.id=t;var a=Object.keys(G).length;return G[a]=n,'').concat(n.outerHTML,'')}(t,++e)})),''.concat(Q(S||""),"
")}var t=L(S);t=Q(t);var n=N();S.match(/\[TOC\]/)&&(t=t.replace("[TOC]
",_()),y()),t=t.replace(/(__special_katext_id_\d+__)/g,(function(e,t){var a=n[t],r=a.type,i=a.expression;return(0,W.renderToString)(function(e){var t=document.createElement("div");return t.innerHTML=e,0===t.childNodes.length?"":t.childNodes[0].nodeValue}(i)||"",{displayMode:"block"===r,throwOnError:!1,output:"html"})})),t=t.replace(/▁/g,"▁▁▁"),R();var a=document.createElement("div");return a.innerHTML=t,v?(ae(a,v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),a.innerHTML):i?a.innerText:(setTimeout((function(){return ce()}),500),a.innerHTML)}),[S,v]);(0,d.useEffect)((function(){re.current&&re.current.querySelectorAll(["input","textarea"]).forEach((function(e){e.oninput=te,e.onblur=ne}))}),[X]),(0,d.useEffect)((function(){if(null!=b&&b.length){var e,t=re.current.querySelectorAll(".edu-program-fill-score"),n=re.current.querySelectorAll('[name="edu-program-fill"]'),a=o()(n.entries());try{for(a.s();!(e=a.n()).done;){var r,i=u()(e.value,2),c=i[0],l=i[1];l.value=null===(r=b[c])||void 0===r?void 0:r.value,"warning"===b[c].type?l.className="program-fill-warning":"success"===b[c].type?l.className="program-fill-success":l.className=""}}catch(e){a.e(e)}finally{a.f()}var s,d=o()(t.entries());try{for(d.s();!(s=d.n()).done;){var p,f,h=u()(s.value,2),v=h[0];h[1].innerHTML=null!==(p=b[v])&&void 0!==p&&p.score?"".concat(null===(f=b[v])||void 0===f?void 0:f.score,"分"):""}}catch(e){d.e(e)}finally{d.f()}K(b)}}),[b]);var te=function(e){X[e.target.dataset.id]=X[e.target.dataset.id]||{},X[e.target.dataset.id].value=e.target.value,K(c()(X)),j(X,e.target.dataset.id)},ne=function(e){X[e.target.dataset.id]=X[e.target.dataset.id]||{},X[e.target.dataset.id].value=e.target.value,K(c()(X)),C(X,e.target.dataset.id)};function ae(e,t){return e.childNodes.forEach((function(e){if(e.childNodes.length>0)ae(e,t);else if("IMG"!==e.nodeName)if(e.innerHTML){var n;e.innerHTML=null===(n=e.innerHTML)||void 0===n?void 0:n.replace(new RegExp(t,"gi"),'$&')}else{var a=document.createElement("span");a.innerHTML=e.textContent.replace(new RegExp(t,"gi"),'$&'),e.replaceWith(a)}}))}var re=(0,d.useRef)();function ie(e){var t=e.target;if("A"===t.tagName.toUpperCase()){var n=t.getAttribute("href");if(n.indexOf("office")>-1)e.preventDefault(),T(n),$("office");else if(n.indexOf("application/pdf")>-1)e.preventDefault(),T(n),$("pdf");else if(n.indexOf("text/html")>-1)e.preventDefault(),T(n),$("html");else if(n.startsWith("#")){e.preventDefault();var a=document.getElementById(n.replace("#",""));a&&a.scrollIntoView(!0)}}}w.WebkitLineClamp=l,l&&(p=r()(r()({},p),w));var ce=function(){var e,t=null===(e=re.current)||void 0===e?void 0:e.querySelectorAll("video");null==t||t.forEach((function(e){if(e.oncontextmenu=function(){return!1},e.src.indexOf(".m3u8")>-1)if(e.canPlayType("application/vnd.apple.mpegurl"));else if(A().isSupported()){var t=new(A());t.loadSource(e.src),t.attachMedia(e)}}))};return(0,d.useEffect)((function(){if(re.current&&ee&&ee.match(z)&&window.PR.prettyPrint(),re.current)return re.current.addEventListener("click",ie),function(){var e;null===(e=re.current)||void 0===e||e.removeEventListener("click",ie),R(),y()}}),[ee,re.current,ie]),(0,V.jsxs)(V.Fragment,{children:[i&&(0,V.jsx)("div",{ref:re,children:ee}),!i&&(0,V.jsx)("div",{ref:re,style:r()({},p),className:"".concat(a||""," ").concat(x?"disabled-fill":""," markdown-body ").concat(Y.current),dangerouslySetInnerHTML:{__html:ee}}),(0,V.jsx)(H.Z,{close:!0,data:P,type:null!=P&&P.length?U:"",style:r()({},h),onClose:function(){return T("")}})]})}}}]);