universalviewer
Version:
The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
14 lines (12 loc) • 4.51 kB
JavaScript
import{c as H}from"./chunk-L67DAW3A.js";var X=H((M,D)=>{(function(v,f){typeof define=="function"&&define.amd?define([],f):typeof D=="object"&&D.exports?D.exports=f():v.PDFObject=f()})(M,function(){"use strict";if(typeof window>"u"||window.navigator===void 0||window.navigator.userAgent===void 0)return!1;let v="2.3.0",f=window,r=f.navigator,F=r.userAgent,L=!1,O=function(){let e=f.chrome!==void 0,n=f.safari!==void 0||r.vendor!==void 0&&/Apple/.test(r.vendor)&&/Safari/.test(F),i=f.Mozilla!==void 0||/irefox/.test(F);return e||n||i},j=function(e){var n=null;try{n=new ActiveXObject(e)}catch{n=null}return!!n},R=function(){return"ActiveXObject"in f&&(j("AcroPDF.PDF")||j("PDF.PdfCtrl"))},P=function(){if(r.platform!==void 0&&r.platform==="MacIntel"&&r.maxTouchPoints!==void 0&&r.maxTouchPoints>1||/Mobi|Tablet|Android|iPad|iPhone/.test(F))return!1;let i=typeof r.pdfViewerEnabled=="boolean";return i&&!r.pdfViewerEnabled?!1:i&&r.pdfViewerEnabled||O()||R()}(),U=function(e){let n="",i,l=[],t="";if((e.comment||e.viewrect||e.highlight)&&(e.page||(e.page=1,g("The comment, viewrect, and highlight parameters require a page parameter, but none was specified. Defaulting to page 1."))),e.page&&(l.push("page="+encodeURIComponent(e.page)),delete e.page),e.fdf&&(t=e.fdf,delete e.fdf),e){for(i in e)e.hasOwnProperty(i)&&l.push(encodeURIComponent(i)+"="+encodeURIComponent(e[i]));t&&l.push("fdf="+encodeURIComponent(t)),n=l.join("&"),n&&(n="#"+n)}return n},g=function(e){return L||console.log("[PDFObject]",e),!1},E=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},I=function(e){let n=document.body;return typeof e=="string"?n=document.querySelector(e):f.jQuery!==void 0&&e instanceof jQuery&&e.length?n=e.get(0):e.nodeType!==void 0&&e.nodeType===1&&(n=e),n},S=function(e,n,i,l){if(window.Blob&&window.URL&&window.URL.createObjectURL){var t=new XMLHttpRequest;t.open("GET",e,!0),t.responseType="blob",t.onload=function(){if(t.status===200){var p=t.response,s=document.createElement("a");s.innerText="Download PDF",s.href=URL.createObjectURL(p),s.setAttribute("download",n),i.innerHTML=l.replace(/\[pdflink\]/g,s.outerHTML)}},t.send()}},T=function(e,n,i,l,t,p,s,m,h,d,b){E(n);let u=i;if(e==="pdfjs"){let a=b.indexOf("?")!==-1?"&":"?";u=b+a+"file="+encodeURIComponent(i)+l}else u+=l;let o=document.createElement("iframe");if(o.className="pdfobject",o.type="application/pdf",o.title=m,o.src=u,o.allow="fullscreen",o.frameborder="0",s&&(o.id=s),!h){let a="border: none;";n!==document.body?a+="width: "+t+"; height: "+p+";":a+="position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%;",o.style.cssText=a}let w=["className","type","title","src","style","id","allow","frameborder"];return d&&d.key&&w.indexOf(d.key)===-1&&o.setAttribute(d.key,typeof d.value<"u"?d.value:""),n.classList.add("pdfobject-container"),n.appendChild(o),n.getElementsByTagName("iframe")[0]},A=function(e,n,i){let l=n||!1,t=i||{};L=typeof t.suppressConsole=="boolean"?t.suppressConsole:!1;let p=typeof t.id=="string"?t.id:"",s=t.page||!1,m=t.pdfOpenParams||{},h=typeof t.fallbackLink=="string"||typeof t.fallbackLink=="boolean"?t.fallbackLink:!0,d=t.width||"100%",b=t.height||"100%",u=t.title||"Embedded PDF",o=typeof t.forcePDFJS=="boolean"?t.forcePDFJS:!1,w=typeof t.omitInlineStyles=="boolean"?t.omitInlineStyles:!1,a=t.PDFJS_URL||!1,c=I(l),y="",k=t.customAttribute||{},C="<p>This browser does not support inline PDFs. Please download the PDF to view it: [pdflink]</p>";if(typeof e!="string")return g("URL is not valid");if(!c)return g("Target element cannot be determined");if(s&&(m.page=s),y=U(m),o&&a)return T("pdfjs",c,e,y,d,b,p,u,w,k,a);if(P)return T("iframe",c,e,y,d,b,p,u,w,k);if(a)return T("pdfjs",c,e,y,d,b,p,u,w,k,a);if(h)if(typeof h=="string")c.innerHTML=h.replace(/\[url\]/g,e);else if(e.indexOf("data:application/pdf;base64")!==-1)S(e,"file.pdf",c,C);else{let x="<a href='"+e+"'>Download PDF</a>";c.innerHTML=C.replace(/\[pdflink\]/g,x)}return g("This browser does not support embedded PDFs")};return{embed:function(e,n,i){return A(e,n,i)},pdfobjectversion:function(){return v}(),supportsPDFs:function(){return P}()}})});export default X();
/*! Bundled license information:
pdfobject/pdfobject.js:
(**
* PDFObject v2.3.0
* https://github.com/pipwerks/PDFObject
* @license
* Copyright (c) 2008-2024 Philip Hutchison
* MIT-style license: http://pipwerks.mit-license.org/
* UMD module pattern from https://github.com/umdjs/umd/blob/master/templates/returnExports.js
*)
*/