const A=Symbol("Comlink.proxy"),O=Symbol("Comlink.endpoint"),z=Symbol("Comlink.releaseProxy"),P=Symbol("Comlink.finalizer"),w=Symbol("Comlink.thrown"),M=e=>typeof e=="object"&&e!==null||typeof e=="function",N={canHandle:e=>M(e)&&e[A],serialize(e){const{port1:t,port2:r}=new MessageChannel;return S(e,t),[r,[r]]},deserialize(e){return e.start(),I(e)}},W={canHandle:e=>M(e)&&w 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}},R=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 l(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:i}=Object.assign({path:[]},n.data),u=(n.data.argumentList||[]).map(d);let a;try{const o=i.slice(0,-1).reduce((c,y)=>c[y],e),f=i.reduce((c,y)=>c[y],e);switch(s){case"GET":a=f;break;case"SET":o[i.slice(-1)[0]]=d(n.data.value),a=!0;break;case"APPLY":a=f.apply(o,u);break;case"CONSTRUCT":{const c=new f(...u);a=G(c)}break;case"ENDPOINT":{const{port1:c,port2:y}=new MessageChannel;S(e,y),a=j(c,[c])}break;case"RELEASE":a=void 0;break;default:return}}catch(o){a={value:o,[w]:0}}Promise.resolve(a).catch(o=>({value:o,[w]:0})).then(o=>{const[f,c]=b(o);t.postMessage(Object.assign(Object.assign({},f),{id:g}),c),s==="RELEASE"&&(t.removeEventListener("message",l),T(t),P in e&&typeof e[P]=="function"&&e[P]())}).catch(o=>{const[f,c]=b({value:new TypeError("Unserializable return value"),[w]:0});t.postMessage(Object.assign(Object.assign({},f),{id:g}),c)})}),t.start&&t.start()}function H(e){return e.constructor.name==="MessagePort"}function T(e){H(e)&&e.close()}function I(e,t){return k(e,[],t)}function p(e){if(e)throw new Error("Proxy has been released and is not useable")}function C(e){return m(e,{type:"RELEASE"}).then(()=>{T(e)})}const h=new WeakMap,E="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(h.get(e)||0)-1;h.set(e,t),t===0&&C(e)});function F(e,t){const r=(h.get(t)||0)+1;h.set(t,r),E&&E.register(e,t,e)}function V(e){E&&E.unregister(e)}function k(e,t=[],r=function(){}){let l=!1;const n=new Proxy(r,{get(g,s){if(p(l),s===z)return()=>{V(n),C(e),l=!0};if(s==="then"){if(t.length===0)return{then:()=>n};const i=m(e,{type:"GET",path:t.map(u=>u.toString())}).then(d);return i.then.bind(i)}return k(e,[...t,s])},set(g,s,i){p(l);const[u,a]=b(i);return m(e,{type:"SET",path:[...t,s].map(o=>o.toString()),value:u},a).then(d)},apply(g,s,i){p(l);const u=t[t.length-1];if(u===O)return m(e,{type:"ENDPOINT"}).then(d);if(u==="bind")return k(e,t.slice(0,-1));const[a,o]=x(i);return m(e,{type:"APPLY",path:t.map(f=>f.toString()),argumentList:a},o).then(d)},construct(g,s){p(l);const[i,u]=x(s);return m(e,{type:"CONSTRUCT",path:t.map(a=>a.toString()),argumentList:i},u).then(d)}});return F(n,e),n}function _(e){return Array.prototype.concat.apply([],e)}function x(e){const t=e.map(b);return[t.map(r=>r[0]),_(t.map(r=>r[1]))]}const L=new WeakMap;function j(e,t){return L.set(e,t),e}function G(e){return Object.assign(e,{[A]:!0})}function b(e){for(const[t,r]of R)if(r.canHandle(e)){const[l,n]=r.serialize(e);return[{type:"HANDLER",name:t,value:l},n]}return[{type:"RAW",value:e},L.get(e)||[]]}function d(e){switch(e.type){case"HANDLER":return R.get(e.name).deserialize(e.value);case"RAW":return e.value}}function m(e,t,r){return new Promise(l=>{const n=U();e.addEventListener("message",function g(s){!s.data||!s.data.id||s.data.id!==n||(e.removeEventListener("message",g),l(s.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:n},t),r)})}function U(){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-a6ZnbiPd.js").then(function(r){return r.b});return t(e)},q=async e=>{const{mergeAndStampPdfs:t}=await import("./mergePdf-CQuiLoQF.js");return t(e)};S({renderPDFInWorker:Y,mergeAndStampPdfsInWorker:q});Promise.resolve().then(()=>{self.postMessage({type:"pdf-render-ready"})});
