(self.webpackChunknocode_component=self.webpackChunknocode_component||[]).push([[3684],{34880:function(e,t,n){"use strict";n.r(t),n.d(t,{ErrDom:function(){return _},Loading:function(){return Y},default:function(){return x}});var r=n(72048),c=(n(87912),n(97308),n(65984)),u=n.n(c),a=n(71252),o=n.n(a),s=n(22008),i=n(95352),l="Dbjhp+Pg_btn-div",f="+vDwVRk-_base-btn",d="Gs00UDNh_wait-load-data",m="in+HDDWR_errtext",p="X0Q+Yl5G_pdf-viewer-container",v="C9sM7hEL_pdf-viewer-wrapper",h="DjOTL3dY_pdf-viewer",g=n(16896),w=n(76548),E=n.n(w),b=n(760),y=n.n(b),L=n(60644);var D=function(e,t,n,r){var c,u=0,a=0,o=0,s=1,i=0,l=function(e){e.touches.length>1?(u=(e.touches[0].pageX+e.touches[1].pageX)/2,a=(e.touches[0].pageY+e.touches[1].pageY)/2,o=E()(e.touches[1].pageX-e.touches[0].pageX,e.touches[1].pageY-e.touches[0].pageY)):o=0},f=function(t){if(!(o<=0||t.touches.length<2)){1===t.scale&&2!==t.touches.length||t.preventDefault();var r=E()(t.touches[1].pageX-t.touches[0].pageX,t.touches[1].pageY-t.touches[0].pageY);Math.abs(r-i)<50||(i=r,c&&window.cancelAnimationFrame(c),c=window.requestAnimationFrame((function(){var t,c=u+n.scrollLeft,i=a+n.scrollTop;s=r/o,e.style.transform="translate3d(0, 0, 0) scale(".concat(s,")"),e.style.transformOrigin=y()(t="".concat(c,"px ")).call(t,i,"px")})))}},d=(0,L.debounce)((function(){if(!(o<=0)&&isFinite(s)){var c=e.getBoundingClientRect(),i=c.top,l=c.left;e.style.transform="none",e.style.transformOrigin="unset";var f=t.currentScale*s;f<=r&&(f=r),t.currentScale=f,window.requestAnimationFrame((function(){n.scrollTop=-1*i,n.scrollLeft=-1*l})),u=0,a=0,o=0,s=1}}),300);return document.addEventListener("touchstart",l,!0),document.addEventListener("touchmove",f,{passive:!1,capture:!0}),document.addEventListener("touchend",d,!0),function(){document.removeEventListener("touchstart",l,!0),document.removeEventListener("touchmove",f,!0),document.removeEventListener("touchend",d,!0)}},k=n(63548),R=n(9401),N=n(14020);i.GlobalWorkerOptions.workerSrc=("undefined"!=typeof window?window:{}).pdfjsWorker=n(20908);var Y=function(e){switch(e.loadingType){case 1:return u().createElement(g.c,{text:"文件正在转换，请稍候"});case 2:return u().createElement(g.c,{text:"预览页面正在加载，请稍候"});case 3:return u().createElement(g.c,{text:"文件正在加载，请稍候"})}},_=function(e){return u().createElement("div",{className:d},u().createElement("span",{className:m},"该文件暂不支持预览，请下载查看。"))},x=function(e){var t=(0,c.useState)(!1),n=(0,r.c)(t,2),a=n[0],d=n[1],m=(0,c.useRef)(null),g=(0,c.useRef)(null),w=(0,c.useRef)(.4),E=(0,c.useRef)(null),b=(0,c.useRef)(null),y=(0,c.useState)(!1),L=(0,r.c)(y,2),x=L[0],S=L[1],X=e.url;(0,R.c)(),(0,c.useEffect)((function(){if(m.current){var e=new s.EventBus;g.current=new s.PDFViewer({container:m.current,eventBus:e,useOnlyCssZoom:!0});var t=new window.MutationObserver(F),n=E.current;t.observe(n,{childList:!0,subtree:!0,attributeFilter:["style"],attributes:!0});var r=D(m.current,g.current,b.current,.4);return function(){t.disconnect(),r()}}}),[]);var C=(0,c.useMemo)((function(){return(0,N.Yt)()}),[]);(0,c.useEffect)((function(){d(!0);var e={url:X,cMapUrl:"".concat(C,"public/thirdjs/cmaps/"),cMapPacked:!0,isEvalSupported:!1};i.getDocument(e).promise.then((function(e){g.current.setDocument(e),g.current.currentScale=w.current,d(!1),S(!1)}),(function(e){d(!1),S(!0)}))}),[X]);var F=function(e,t){e.forEach((function(e){if("attributes"===e.type&&"style"===e.attributeName){var t=E.current.scrollWidth,n=E.current.offsetWidth;E.current.style.alignItems=t<=n?"center":"flex-start"}}))},M=function(){var e=g.current.pagesRotation+90;g.current.pagesRotation=360===e?0:e};return u().createElement("div",{className:p,ref:b},a&&u().createElement(Y,{loadingType:3}),u().createElement("div",{className:o()(v),ref:m},u().createElement("div",{className:o()(h),id:"pdfList",ref:E})),!a&&!x&&u().createElement("div",{className:l},u().createElement(k.Icon,{className:f,type:"spin",onClick:M})),x&&!a&&u().createElement(_,null))}},39624:function(){},20180:function(){},33460:function(){},23284:function(){},39648:function(){}}]);