/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */const R=Symbol("Comlink.proxy"),C=Symbol("Comlink.endpoint"),z=Symbol("Comlink.releaseProxy"),k=Symbol("Comlink.finalizer"),b=Symbol("Comlink.thrown"),L=e=>typeof e=="object"&&e!==null||typeof e=="function",N={canHandle:e=>L(e)&&e[R],serialize(e){const{port1:t,port2:r}=new MessageChannel;return S(e,t),[r,[r]]},deserialize(e){return e.start(),F(e)}},W={canHandle:e=>L(e)&&b in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},A=new Map([["proxy",N],["throw",W]]);function D(e,t){for(const r of e)if(t===r||r==="*"||r instanceof RegExp&&r.test(t))return!0;return!1}function S(e,t=globalThis,r=["*"]){t.addEventListener("message",function o(n){if(!n||!n.data)return;if(!D(r,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:g,type:s,path:c}=Object.assign({path:[]},n.data),u=(n.data.argumentList||[]).map(d);let a;try{const i=c.slice(0,-1).reduce((l,m)=>l[m],e),f=c.reduce((l,m)=>l[m],e);switch(s){case"GET":a=f;break;case"SET":i[c.slice(-1)[0]]=d(n.data.value),a=!0;break;case"APPLY":a=f.apply(i,u);break;case"CONSTRUCT":{const l=new f(...u);a=j(l)}break;case"ENDPOINT":{const{port1:l,port2:m}=new MessageChannel;S(e,m),a=_(l,[l])}break;case"RELEASE":a=void 0;break;default:return}}catch(i){a={value:i,[b]:0}}Promise.resolve(a).catch(i=>({value:i,[b]:0})).then(i=>{const[f,l]=p(i);t.postMessage(Object.assign(Object.assign({},f),{id:g}),l),s==="RELEASE"&&(t.removeEventListener("message",o),M(t),k in e&&typeof e[k]=="function"&&e[k]())}).catch(i=>{const[f,l]=p({value:new TypeError("Unserializable return value"),[b]:0});t.postMessage(Object.assign(Object.assign({},f),{id:g}),l)})}),t.start&&t.start()}function H(e){return e.constructor.name==="MessagePort"}function M(e){H(e)&&e.close()}function F(e,t){return P(e,[],t)}function w(e){if(e)throw new Error("Proxy has been released and is not useable")}function O(e){return y(e,{type:"RELEASE"}).then(()=>{M(e)})}const E=new WeakMap,h="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(E.get(e)||0)-1;E.set(e,t),t===0&&O(e)});function I(e,t){const r=(E.get(t)||0)+1;E.set(t,r),h&&h.register(e,t,e)}function U(e){h&&h.unregister(e)}function P(e,t=[],r=function(){}){let o=!1;const n=new Proxy(r,{get(g,s){if(w(o),s===z)return()=>{U(n),O(e),o=!0};if(s==="then"){if(t.length===0)return{then:()=>n};const c=y(e,{type:"GET",path:t.map(u=>u.toString())}).then(d);return c.then.bind(c)}return P(e,[...t,s])},set(g,s,c){w(o);const[u,a]=p(c);return y(e,{type:"SET",path:[...t,s].map(i=>i.toString()),value:u},a).then(d)},apply(g,s,c){w(o);const u=t[t.length-1];if(u===C)return y(e,{type:"ENDPOINT"}).then(d);if(u==="bind")return P(e,t.slice(0,-1));const[a,i]=x(c);return y(e,{type:"APPLY",path:t.map(f=>f.toString()),argumentList:a},i).then(d)},construct(g,s){w(o);const[c,u]=x(s);return y(e,{type:"CONSTRUCT",path:t.map(a=>a.toString()),argumentList:c},u).then(d)}});return I(n,e),n}function V(e){return Array.prototype.concat.apply([],e)}function x(e){const t=e.map(p);return[t.map(r=>r[0]),V(t.map(r=>r[1]))]}const T=new WeakMap;function _(e,t){return T.set(e,t),e}function j(e){return Object.assign(e,{[R]:!0})}function p(e){for(const[t,r]of A)if(r.canHandle(e)){const[o,n]=r.serialize(e);return[{type:"HANDLER",name:t,value:o},n]}return[{type:"RAW",value:e},T.get(e)||[]]}function d(e){switch(e.type){case"HANDLER":return A.get(e.name).deserialize(e.value);case"RAW":return e.value}}function y(e,t,r){return new Promise(o=>{const n=G();e.addEventListener("message",function g(s){!s.data||!s.data.id||s.data.id!==n||(e.removeEventListener("message",g),o(s.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:n},t),r)})}function G(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}typeof WorkerGlobalScope<"u"&&self instanceof DedicatedWorkerGlobalScope&&(self.global=self,self.window=self);const Y=async e=>{const{renderPDF:t}=await import("./renderPDF-Bxrv9JeO.js").then(function(o){return o.b}),r=await t(e);return URL.createObjectURL(r)};S({renderPDFInWorker:Y});
