Jonathan Jenne 538a257848 27-09-2023
2023-09-27 14:50:52 +02:00

13 lines
11 KiB
JavaScript

/*!
* PSPDFKit for Web 2023.5.0-3f96296 (https://pspdfkit.com/web)
*
* Copyright (c) 2016-2023 PSPDFKit GmbH. All rights reserved.
*
* THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
* AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
* UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
* This notice may not be removed from this file.
*
* PSPDFKit uses several open source third-party components: https://pspdfkit.com/acknowledgements/web/
*/
(self.webpackChunkPSPDFKit=self.webpackChunkPSPDFKit||[]).push([[9859],{49859:(t,e,r)=>{"use strict";r.r(e),r.d(e,{Conformance:()=>f,GdPicture:()=>h,GdPictureClientNative:()=>P,GdPictureWorker:()=>S,getBrowserSpawner:()=>E});var n=r(84121),o=r(47347),s=r(72852);const a="pspdfkit-lib/",i=`${a}gdpicture-2255489f40d33d76b4ed1c4fa1925c8a5a50ab31/jit`,c=`${i}/initDotnet.js`,l=`${a}gdpicture-2255489f40d33d76b4ed1c4fa1925c8a5a50ab31/aot`,d=`${l}/initDotnet.js`;let f;function u(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?u(Object(r),!0).forEach((function(e){(0,n.Z)(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}!function(t){t[t.pdf_a_1a=0]="pdf_a_1a",t[t.pdf_a_1b=1]="pdf_a_1b",t[t.pdf_a_2a=2]="pdf_a_2a",t[t.pdf_a_2u=3]="pdf_a_2u",t[t.pdf_a_2b=4]="pdf_a_2b",t[t.pdf_a_3a=5]="pdf_a_3a",t[t.pdf_a_3u=6]="pdf_a_3u",t[t.pdf_a_3b=7]="pdf_a_3b",t[t.pdf_a_4=8]="pdf_a_4",t[t.pdf_a_4e=9]="pdf_a_4e",t[t.pdf_a_4f=10]="pdf_a_4f"}(f||(f={}));const b="/create.pdf",m="/save.pdf",y="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;let _=null,g=null;function w(t){let e;(0,o.kG)(g,"GdPicture WebAssembly is not loaded.");for(var r=arguments.length,n=new Array(r>1?r-1:0),s=1;s<r;s++)n[s-1]=arguments[s];for(const t of n)e=Object.assign(n[0],t);const a=JSON.stringify(p({type:t},e)),i=JSON.parse(g.CommandHandler(a));if(!i.success)throw new Error(i.errorReason+": "+i.errorMessage+"\n"+i.error);return i}class h{_mountCustomFonts(t,e){(0,o.kG)(_,"WebAssembly module not loaded."),_.FS.mkdir(e);{const r=y?_.FS.filesystems.WORKERFS:_.FS.filesystems.MEMFS;_.FS.mount(r,{blobs:t},e)}}async loadModule(t,e,r,n,o,a){const{Assemblies:f,Module:u}=await async function(t,e){let r,n,o;const s="string"==typeof t?t:t.baseUrl;return e?(n=`${t}${d}`,o=`${s}${l}`):(n=`${t}${c}`,o=`${s}${i}`),({initDotnet:r}="string"==typeof t?await import(n):await import(baseCoreUrlOrWasmBinary.wasmLoaderModule)),r(o)}(t,e);g=f.GdPictureWasm.API,_=u,w("gdpicture/setLicense",{origin:r},{licenseKey:n||"DEMO_PSPDFKIT_WEB"});const p=o?"/fonts":"";if(o&&!_.FS.analyzePath(p).exists&&(this._mountCustomFonts(o,p),w("gdpicture/setFonts",{fontPaths:[p]})),a){const t=await(0,s.S)(a);w("gdpicture/setDynamicFontLoading",{baseUrl:a.split("/").slice(0,-1).join("/"),allowedFonts:t.availableFonts,v:1})}}toPdf(t,e){_.FS.writeFile(b,new Uint8Array(t));const r={file:m};e&&e in f&&(r.conformance=e);try{return w("gdpicture/process",{input:{file:b},output:r}),_.FS.readFile(m).buffer}finally{try{_.FS.unlink(m)}catch(t){}}}}const S=class{constructor(t){let{baseUrl:e,aot:r,mainThreadOrigin:s,licenseKey:a,customFonts:i,dynamicFonts:c,workerSpawner:l,wasmLoaderPath:d}=t;(0,n.Z)(this,"requests",new Map),(0,n.Z)(this,"nextRequestId",1),(0,n.Z)(this,"handleMessage",(t=>{const e=t.data,r=this.requests.get(e.id);(0,o.kG)(r,`No request was made for id ${e.id}.`);const{resolve:n,reject:s}=r;if(this.requests.delete(e.id),e.error){const t=new o.p2(e.error);t.callArgs=e.callArgs,s(t)}else n(e.result)})),this.workerSpawner=l,this.workerSpawner.setMessageHandler(this.handleMessage),this.moduleLoadPromise=this.sendRequest("loadModule",[d?{baseUrl:e,wasmLoaderPath:d}:e,r,s,a,i,c])}toPdf(t,e){let r;return e&&(r=e.replace("pdf","pdf_").replaceAll("-","_")),this.sendRequest("toPdf",[t,r])}destroy(){var t;null===(t=this.workerSpawner)||void 0===t||t.terminate(),this.workerSpawner=null}async sendRequest(t,e){(0,o.kG)(this.workerSpawner,"GdPictureClient has been destroyed"),this.moduleLoadPromise&&await this.moduleLoadPromise;const r=this.workerSpawner;return new Promise(((n,o)=>{const s=this.assignId(),a=[...e].filter((t=>t instanceof ArrayBuffer));r.postMessage({id:s,action:t,args:e},a),this.requests=this.requests.set(s,{resolve:n,reject:o})}))}assignId(){const t=this.nextRequestId;return this.nextRequestId=this.nextRequestId+1,t}};const P=class{constructor(t){let{baseUrl:e,aot:r,mainThreadOrigin:n,licenseKey:o,customFonts:s,dynamicFonts:a}=t;this.gdPicture=new h,this.moduleLoadPromise=this.gdPicture.loadModule(e,r,n,o,s,a)}async toPdf(t,e){let r;return this.moduleLoadPromise&&await this.moduleLoadPromise,e&&(r=e.replace("pdf","pdf_").replaceAll("-","_")),this.gdPicture.toPdf(t,r)}destroy(){}};var O=r(59817),F=r.n(O);const E=async function(){let t=new(F());return{setMessageHandler(e){(0,o.kG)(t,"Worker is null"),t.onmessage=e},postMessage(e,r){var n;null===(n=t)||void 0===n||n.postMessage(e,r)},terminate(){var e;null===(e=t)||void 0===e||e.terminate(),t=null}}}},59817:(t,e,r)=>{t.exports=function(){return r(69855)('/*!\n * PSPDFKit for Web 2023.5.0-3f96296 (https://pspdfkit.com/web)\n *\n * Copyright (c) 2016-2023 PSPDFKit GmbH. All rights reserved.\n *\n * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW\n * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.\n * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.\n * This notice may not be removed from this file.\n *\n * PSPDFKit uses several open source third-party components: https://pspdfkit.com/acknowledgements/web/\n */(()=>{"use strict";const t=function t(e){let r;return r=e instanceof Error?e:new Error(e),Object.setPrototypeOf(r,t.prototype),r};t.prototype=Object.create(Error.prototype,{name:{value:"PSPDFKitError",enumerable:!1}});const e=t;function r(t,r){if(!t)throw new e(`Assertion failed: ${r||"Condition not met"}\\n\\nFor further assistance, please go to: https://pspdfkit.com/support/request`)}function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===n(e)?e:String(e)}function a(t,e,r){return(e=o(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",\'[tabindex]:not([tabindex^="-"])\'].join(",");new WeakMap;const i="pspdfkit-lib/",s=`${i}gdpicture-2255489f40d33d76b4ed1c4fa1925c8a5a50ab31/jit`,c=`${s}/initDotnet.js`,f=`${i}gdpicture-2255489f40d33d76b4ed1c4fa1925c8a5a50ab31/aot`,l=`${f}/initDotnet.js`;let u;function d(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?d(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}!function(t){t[t.pdf_a_1a=0]="pdf_a_1a",t[t.pdf_a_1b=1]="pdf_a_1b",t[t.pdf_a_2a=2]="pdf_a_2a",t[t.pdf_a_2u=3]="pdf_a_2u",t[t.pdf_a_2b=4]="pdf_a_2b",t[t.pdf_a_3a=5]="pdf_a_3a",t[t.pdf_a_3u=6]="pdf_a_3u",t[t.pdf_a_3b=7]="pdf_a_3b",t[t.pdf_a_4=8]="pdf_a_4",t[t.pdf_a_4e=9]="pdf_a_4e",t[t.pdf_a_4f=10]="pdf_a_4f"}(u||(u={}));const b="/create.pdf",y="/save.pdf",m="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;let _=null,g=null;function w(t){let e;r(g,"GdPicture WebAssembly is not loaded.");for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];for(const t of o)e=Object.assign(o[0],t);const i=JSON.stringify(p({type:t},e)),s=JSON.parse(g.CommandHandler(i));if(!s.success)throw new Error(s.errorReason+": "+s.errorMessage+"\\n"+s.error);return s}const h=new class{_mountCustomFonts(t,e){r(_,"WebAssembly module not loaded."),_.FS.mkdir(e);{const r=m?_.FS.filesystems.WORKERFS:_.FS.filesystems.MEMFS;_.FS.mount(r,{blobs:t},e)}}async loadModule(t,r,n,o,a,i){const{Assemblies:u,Module:d}=await async function(t,e){let r,n,o;const a="string"==typeof t?t:t.baseUrl;return e?(n=`${t}${l}`,o=`${a}${f}`):(n=`${t}${c}`,o=`${a}${s}`),({initDotnet:r}="string"==typeof t?await import(n):await import(baseCoreUrlOrWasmBinary.wasmLoaderModule)),r(o)}(t,r);g=u.GdPictureWasm.API,_=d,w("gdpicture/setLicense",{origin:n},{licenseKey:o||"DEMO_PSPDFKIT_WEB"});const p=a?"/fonts":"";if(a&&!_.FS.analyzePath(p).exists&&(this._mountCustomFonts(a,p),w("gdpicture/setFonts",{fontPaths:[p]})),i){const t=await async function(t){try{const r=await fetch(t).catch((r=>{throw new e(`Error fetching dynamic fonts file ${t}. ${r}`)}));if(200!==r.status)throw new e(`Error fetching dynamic fonts file ${t}. Status code: ${r.status}`);const n=await r.json().catch((r=>{throw new e(`Error parsing dynamic fonts file ${t}. ${r}`)}));return n}catch(t){throw t}}(i);w("gdpicture/setDynamicFontLoading",{baseUrl:i.split("/").slice(0,-1).join("/"),allowedFonts:t.availableFonts,v:1})}}toPdf(t,e){_.FS.writeFile(b,new Uint8Array(t));const r={file:y};e&&e in u&&(r.conformance=e);try{return w("gdpicture/process",{input:{file:b},output:r}),_.FS.readFile(y).buffer}finally{try{_.FS.unlink(y)}catch(t){}}}},S=self;S.global=S,S.module={},S.onmessage=async t=>{let e,r,{data:n}=t;try{const t=await h[n.action](...n.args);if(e={id:n.id,result:t},Array.isArray(t)){const e=t.filter((t=>t instanceof ArrayBuffer));e.length>0&&(r=e)}t instanceof ArrayBuffer&&(r=[t])}catch(t){const o=[...n.args].filter((t=>t instanceof ArrayBuffer));o.length>0&&(r=o),e={id:n.id,error:t.message||t.toString(),callArgs:n.args}}S.postMessage(e,r)}})();',null)}}}]);