import{onMounted as d,createElementBlock as w,openBlock as u,watchEffect as m}from"/vue.js";import{u as _,n as y}from"./nc-main.DEgIQeOo.js";import"./service-worker.DGZzV4eE.js";const b={id:"pdfjs-viewer-iframe",allowfullscreen:"true",mozallowfullscreen:"true",webkitallowfullscreen:"true"},h=Object.assign({name:"NcPdfViewer"},{__name:"nc-pdf-viewer",props:{src:{type:[String,Object],default:void 0},name:{type:String,default:void 0},passwordCallback:{type:Function,default:()=>{}}},setup(c){const n=c;let r=null,t=!1,s=!1;function i(){let o;if(typeof n.src=="object"?o=n.src.data:o=n.src,!o||!(n.src.viewer_show_type==="fullpage"||n.src.viewer_show_type==="preview-full"))t&&(r.close(),t=!1);else{if(typeof o=="string"){const e=y.base64ToBinary(o,"application/pdf");r.open(e)}else r.open(o);t=!0,setTimeout(()=>{const e=r.pdfLoadingTask;if(!e){console.warn("PDFViewer.pdfLoadingTask does not exist");return}const p=e.onPassword;e.onPassword=(a,l)=>{if(typeof n.passwordCallback=="function"){const f=n.passwordCallback(l);f&&a(f)}else p(a,l)}},0)}}return d(function(){function o(){const e=document.getElementById("pdfjs-viewer-iframe");if(!e){console.error("PDFViewer iframe was not found");return}e.onload=function(){r=e.contentWindow.PDFViewerApplication,r?s&&(s=!1,i()):console.error("PDFViewer could not be opened (/pdf-viewer/web/viewer-nc.html)")},e.src=_()+"/pdf-viewer/web/viewer-nc.html",m(()=>{r?i():n.src&&(s=!0)})}o()}),(o,e)=>(u(),w("iframe",b))}});export{h as default};
