UNPKG

@tindtechnologies/universalviewer

Version:

The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎

1 lines 4.01 kB
(self.webpackChunkUV=self.webpackChunkUV||[]).push([[9694],{6659(e,t,n){var o,i,r=n(4692),a=n(4692);void 0===(i="function"==typeof(o=function(){"use strict";if("undefined"==typeof window||void 0===window.navigator||void 0===window.navigator.userAgent)return!1;let e=window,t=e.navigator,n=t.userAgent,o=!1,i=function(e){var t=null;try{t=new ActiveXObject(e)}catch(e){t=null}return!!t},d=function(){if(void 0!==t.platform&&"MacIntel"===t.platform&&void 0!==t.maxTouchPoints&&t.maxTouchPoints>1||/Mobi|Tablet|Android|iPad|iPhone/.test(n))return!1;let o="boolean"==typeof t.pdfViewerEnabled;return!(o&&!t.pdfViewerEnabled)&&(o&&t.pdfViewerEnabled||function(){let o=void 0!==e.chrome,i=void 0!==e.safari||void 0!==t.vendor&&/Apple/.test(t.vendor)&&/Safari/.test(n),r=void 0!==e.Mozilla||/irefox/.test(n);return o||i||r}()||"ActiveXObject"in e&&(i("AcroPDF.PDF")||i("PDF.PdfCtrl")))}(),l=function(e){return o||console.log("[PDFObject]",e),!1},f=function(e,t,n,o,i,r,a,d,l,f,p){!function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}(t);let s=n;if("pdfjs"===e){let e=-1!==p.indexOf("?")?"&":"?";s=p+e+"file="+encodeURIComponent(n)+o}else s+=o;let c=document.createElement("iframe");if(c.className="pdfobject",c.type="application/pdf",c.title=d,c.src=s,c.allow="fullscreen",c.frameborder="0",a&&(c.id=a),!l){let e="border: none;";t!==document.body?e+="width: "+i+"; height: "+r+";":e+="position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%;",c.style.cssText=e}return f&&f.key&&-1===["className","type","title","src","style","id","allow","frameborder"].indexOf(f.key)&&c.setAttribute(f.key,void 0!==f.value?f.value:""),t.classList.add("pdfobject-container"),t.appendChild(c),t.getElementsByTagName("iframe")[0]},p=function(e,t,n){let i=t||!1,p=n||{};o="boolean"==typeof p.suppressConsole&&p.suppressConsole;let s="string"==typeof p.id?p.id:"",c=p.page||!1,u=p.pdfOpenParams||{},b="string"!=typeof p.fallbackLink&&"boolean"!=typeof p.fallbackLink||p.fallbackLink,m=p.width||"100%",h=p.height||"100%",g=p.title||"Embedded PDF",w="boolean"==typeof p.forcePDFJS&&p.forcePDFJS,v="boolean"==typeof p.omitInlineStyles&&p.omitInlineStyles,y=p.PDFJS_URL||!1,P=function(e){let t=document.body;return"string"==typeof e?t=document.querySelector(e):void 0!==r&&e instanceof a&&e.length?t=e.get(0):void 0!==e.nodeType&&1===e.nodeType&&(t=e),t}(i),T="",D=p.customAttribute||{},k="<p>This browser does not support inline PDFs. Please download the PDF to view it: [pdflink]</p>";if("string"!=typeof e)return l("URL is not valid");if(!P)return l("Target element cannot be determined");if(c&&(u.page=c),T=function(e){let t,n="",o=[],i="";if((e.comment||e.viewrect||e.highlight)&&(e.page||(e.page=1,l("The comment, viewrect, and highlight parameters require a page parameter, but none was specified. Defaulting to page 1."))),e.page&&(o.push("page="+encodeURIComponent(e.page)),delete e.page),e.fdf&&(i=e.fdf,delete e.fdf),e){for(t in e)e.hasOwnProperty(t)&&o.push(encodeURIComponent(t)+"="+encodeURIComponent(e[t]));i&&o.push("fdf="+encodeURIComponent(i)),n=o.join("&"),n&&(n="#"+n)}return n}(u),w&&y)return f("pdfjs",P,e,T,m,h,s,g,v,D,y);if(d)return f("iframe",P,e,T,m,h,s,g,v,D);if(y)return f("pdfjs",P,e,T,m,h,s,g,v,D,y);if(b)if("string"==typeof b)P.innerHTML=b.replace(/\[url\]/g,e);else if(-1!==e.indexOf("data:application/pdf;base64"))!function(e,t,n,o){if(window.Blob&&window.URL&&window.URL.createObjectURL){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="blob",i.onload=function(){if(200===i.status){var e=i.response,r=document.createElement("a");r.innerText="Download PDF",r.href=URL.createObjectURL(e),r.setAttribute("download",t),n.innerHTML=o.replace(/\[pdflink\]/g,r.outerHTML)}},i.send()}}(e,"file.pdf",P,k);else{let t="<a href='"+e+"'>Download PDF</a>";P.innerHTML=k.replace(/\[pdflink\]/g,t)}return l("This browser does not support embedded PDFs")};return{embed:function(e,t,n){return p(e,t,n)},pdfobjectversion:"2.3.0",supportsPDFs:d}})?o.apply(t,[]):o)||(e.exports=i)}}]);