1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-zgw1O4mp.js","assets/vendor-react-C_xdI0Ng.js","assets/linear-icon-BS_Bu1OG.js","assets/vendor-icons-CmfhFn4k.js","assets/noto-sans-cyrillic-700-normal-B3rv6UnQ.js","assets/noto-sans-latin-400-normal-DZbyGt1h.js","assets/noto-sans-latin-ext-400-normal-ChgRUxkZ.js","assets/noto-sans-cyrillic-400-normal-C2Ud1djk.js","assets/index-BrAtxoyJ.js","assets/fontkit.es-MhQaB983.js","assets/vendor-pdflib-BC_rCeQu.js","assets/index-C6qiWGiQ.js","assets/index-DP6dzoqN.js","assets/index-c5kNuCbE.js","assets/index-Br3UiRUP.js","assets/pdf-engine-DB2KmPOe.js","assets/index-By3-B_tX.js","assets/index-C0UgJX5y.js","assets/qpdf-engine-CRfM6CvT.js","assets/qpdf-errors-DkY-DiA5.js","assets/index-7K0eYXQ0.js","assets/index-CxoqP-FV.js","assets/index-LvmBQmPO.js","assets/pdf-image-extractor-mhmZcOq9.js","assets/index-DFNlP0DC.js","assets/index-BUcAkoSU.js","assets/index-Coag7aJj.js","assets/index-CykOVW0V.js","assets/pdf-rasterizer-CXotTZT5.js","assets/pdf-content-stream-parser-DVMg55u3.js","assets/index-DMPIk2lq.js","assets/preview-service-CUDLI67J.js","assets/index-Ddq1D-Gc.js","assets/studio-text-edit-applier-B4vNKf7T.js","assets/infer-source-text-style-CB_Q6F8k.js","assets/feature-flag-QAeryYXU.js","assets/index-DZ589PEf.js","assets/pdf-info-client-CO7HLkbQ.js","assets/index-B3QPX3DA.js","assets/index-Duh6ox2M.js","assets/index-BU_9hLTi.js","assets/index-_GxNNZpf.js","assets/index-DbfrR-Li.js","assets/protect-error-messages-BH7xE7XP.js","assets/protect-errors-CmaV3kPR.js","assets/index-CBESyuai.js","assets/index-D2VU6-JJ.js","assets/index-Dsw1hied.js","assets/index-Bl7JxPa-.js","assets/index-B6aI-4Ib.js","assets/index-BU-5NrEo.js","assets/index-Cp7oKUoZ.js","assets/index-qvDU5HiG.js","assets/index-U464jI_5.js","assets/worker-runtime-BVBu-yi6.js","assets/WizardShell-BWt57YAP.js","assets/canvas-tools-D-8v7jH3.js","assets/StudioShell-Brt3Q-jV.js","assets/vendor-konva-ZjxRZeak.js","assets/history-store-Bah29A3T.js","assets/StudioDialog-Bz_0GjSD.js","assets/StudioEditWorkspace-Bw-PfBMm.js","assets/StudioConvertWorkspace-dZysDiVu.js","assets/ocr-pdf-test-page-BNsxRCwp.js","assets/mobile-share-downloader-CT3DsSbj.js"])))=>i.map(i=>d[i]); 2var gn=Object.defineProperty;var hn=(t,e,n)=>e in t?gn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var N=(t,e,n)=>hn(t,typeof e!="symbol"?e+"":e,n);import{r as v,j as c,e as yn,f as ne,N as Qe,R as Le,g as _n,B as En,u as wn,h as Sn}from"./vendor-react-C_xdI0Ng.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();var Tn=()=>{window.va||(window.va=function(...e){window.vaq||(window.vaq=[]),window.vaq.push(e)})},bn="@vercel/analytics",Cn="2.0.1";function Nr(){return typeof window<"u"}function Ur(){try{const t="production"}catch{}return"production"}function An(t="auto"){if(t==="auto"){window.vam=Ur();return}window.vam=t}function Rn(){return(Nr()?window.vam:Ur())||"production"}function xt(){return Rn()==="development"}function Pn(t){return t.scriptSrc?he(t.scriptSrc):xt()?"https://va.vercel-scripts.com/v1/script.debug.js":t.basePath?he(`${t.basePath}/insights/script.js`):"/_vercel/insights/script.js"}function In(t,e){var n;let r=t;if(e)try{r={...(n=JSON.parse(e))==null?void 0:n.analytics,...t}}catch{}An(r.mode);const o={sdkn:bn+(r.framework?`/${r.framework}`:""),sdkv:Cn};return r.disableAutoTrack&&(o.disableAutoTrack="1"),r.viewEndpoint&&(o.viewEndpoint=he(r.viewEndpoint)),r.eventEndpoint&&(o.eventEndpoint=he(r.eventEndpoint)),r.sessionEndpoint&&(o.sessionEndpoint=he(r.sessionEndpoint)),xt()&&r.debug===!1&&(o.debug="false"),r.dsn&&(o.dsn=r.dsn),r.endpoint?o.endpoint=r.endpoint:r.basePath&&(o.endpoint=he(`${r.basePath}/insights`)),{beforeSend:r.beforeSend,src:Pn(r),dataset:o}}function he(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")?t:`/${t}`}function Dn(t={debug:!0},e){var n;if(!Nr())return;const{beforeSend:r,src:o,dataset:i}=In(t,e);if(Tn(),r&&((n=window.va)==null||n.call(window,"beforeSend",r)),document.head.querySelector(`script[src*="${o}"]`))return;const s=document.createElement("script");s.src=o;for(const[a,l]of Object.entries(i))s.dataset[a]=l;s.defer=!0,s.onerror=()=>{const a=xt()?"Please check if any ad blockers are enabled and try again.":"Be sure to enable Web Analytics for your project and deploy again. See https://vercel.com/docs/analytics/quickstart for more information.";console.log(`[Vercel Web Analytics] Failed to load script from ${o}. ${a}`)},document.head.appendChild(s)}const kn=new Set(["rotate-pdf","split-pdf","delete-pages-pdf","pdf-info"]);function Mr(t){return kn.has(t)}function vn(t){return t.list().filter(e=>!Mr(e.id)).map(e=>{var n;return{toolId:e.id,label:e.name,href:`/${e.id}`,requiredEntitlements:e.entitlements??[],requiresPro:((n=e.limits)==null?void 0:n.featureTier)==="pro"}})}const xn="modulepreload",Ln=function(t){return"/app/"+t},Vt={}
2,L=function(e,n,r){let o=Promise.resolve();if(n&&n.length>0){let s=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));o=s(n.map(u=>{if(u=Ln(u),u in Vt)return;Vt[u]=!0;const d=u.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${p}`))return;const f=document.createElement("link");if(f.rel=d?"stylesheet":xn,d||(f.as="script"),f.crossOrigin="",f.href=u,l&&f.setAttribute("nonce",l),document.head.appendChild(f),d)return new Promise((m,h)=>{f.addEventListener("load",m),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return o.then(s=>{for(const a of s||[])a.status==="rejected"&&i(a.reason);return e().catch(i)})};class Oe{constructor(e,n,r){this.id=e,this.blob=n,this.name=r}getBlob(){return Promise.resolve(this.blob)}getText(){return this.blob.text()}getName(){return this.name}getSize(){return Promise.resolve(this.blob.size)}getType(){return Promise.resolve(this.blob.type)}}const te=class te{constructor(){N(this,"memoryFallback",new Map);N(this,"pins",new Map);N(this,"dbPromise",null)}async pin(e){const n=this.pins.get(e)??0;this.pins.set(e,n+1)}async unpin(e){const n=this.pins.get(e)??0;n<=1?this.pins.delete(e):this.pins.set(e,n-1)}async write(e){const n=crypto.randomUUID(),r={id:n,blob:e,name:e instanceof File&&e.name?e.name:`file-${n}`};if(!this.isIndexedDbAvailable())return this.memoryFallback.set(n,r),new Oe(n,r.blob,r.name);const o=await this.getDb();return await this.withStore(o,"readwrite",i=>i.put(r)),new Oe(n,r.blob,r.name)}async read(e){if(!this.isIndexedDbAvailable()){const i=this.memoryFallback.get(e);if(!i)throw new Error(`File not found: ${e}`);return new Oe(i.id,i.blob,i.name)}const n=await this.getDb(),r=await this.withStore(n,"readonly",i=>i.get(e));if(!r||typeof r!="object")throw new Error(`File not found: ${e}`);const o=r;return new Oe(o.id,o.blob,o.name)}async delete(e){if((this.pins.get(e)??0)>0){const{FilePinnedError:r}=await L(async()=>{const{FilePinnedError:o}=await Promise.resolve().then(()=>Ao);return{FilePinnedError:o}},void 0);throw new r(e)}if(!this.isIndexedDbAvailable()){this.memoryFallback.delete(e);return}const n=await this.getDb();await this.withStore(n,"readwrite",r=>r.delete(e))}isIndexedDbAvailable(){return typeof indexedDB<"u"}getDb(){return this.dbPromise||(this.dbPromise=new Promise((e,n)=>{const r=indexedDB.open(te.DB_NAME,1);r.onupgradeneeded=()=>{const o=r.result;o.objectStoreNames.contains(te.STORE_NAME)||o.createObjectStore(te.STORE_NAME,{keyPath:"id"})},r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error??new Error("IndexedDB open failed"))})),this.dbPromise}withStore(e,n,r){return new Promise((o,i)=>{const s=e.transaction(te.STORE_NAME,n),a=s.objectStore(te.STORE_NAME),l=r(a);s.oncomplete=()=>{if(!l){o(void 0);return}o(l.result)},s.onerror=()=>i(s.error??new Error("IndexedDB transaction failed")),s.onabort=()=>i(s.error??new Error("IndexedDB transaction aborted"))})}};N(te,"DB_NAME","localpdf-v6"),N(te,"STORE_NAME","files");let It=te;const On={id:"auto-toc",name:"Auto-TOC & Bookmarks",description:"Automatically detect headings in your PDF and generate an interactive table of contents with bookmarks.",entitlements:[],limits:{featureTier:"basic",maxFileSize:{free:50*1024*1024,pro:500*1024*1024}},uiLoader:()=>L(()=>import("./index-zgw1O4mp.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])),logicLoader:()=>L(()=>import("./index-BrAtxoyJ.js"),__vite__mapDeps([8,9,10,1])),layout:"default",premiumVisuals:!0},Nn=Object.freeze(Object.defineProperty({__proto__:null,autoTocDefinition:On},Symbol.toStringTag,{value:"Module"})),Un={id:"compress-pdf",name:"Compress PDF",description:"Reduce the file size of your PDF documents while optimizing for quality.",entitlements:[],limits:{featureTier:"basic",maxFileSize:{free:50*1024*1024,pro:500*1024*1024}},uiLoader:()=>L(()=>import("./index-C6qiWGiQ.js"),__vite__mapDeps([11,1,2,3])),logicLoader:()=>L(()=>import("./index-DP6dzoqN.js"),__vite__mapDeps([12,1])),layout:"split",premiumVisuals:!0},Mn=Object.freeze(Object.defineProperty({__proto__:null,compressPdfDefinition:Un},Symbol.toStringTag,{value:"Module"})),Bn={id:"delete-pages-pdf",name:"Delete Pages",description:"Remove specific pages from your PDF document.",entitlements:["pdf.delete_pages"],limits:{featureTier:"basic",maxFileSize:{free:50*1024*1024,pro:500*1024*1024}},uiLoader:()=>L(()=>
2import("./index-c5kNuCbE.js"),__vite__mapDeps([13,1])),logicLoader:()=>L(()=>import("./index-Br3UiRUP.js"),__vite__mapDeps([14,15,1]))},Fn=Object.freeze(Object.defineProperty({__proto__:null,deletePagesPdfDefinition:Bn},Symbol.toStringTag,{value:"Module"})),jn={id:"encrypt-pdf",name:"Encrypt PDF",description:"Protect PDF files with password-based encryption.",entitlements:["pdf.protect.encrypt"],limits:{featureTier:"basic",maxFileSize:{free:25*1024*1024,pro:200*1024*1024},maxPagesPerFile:{free:300,pro:3e3}},uiLoader:()=>L(()=>import("./index-By3-B_tX.js"),__vite__mapDeps([16,1])),logicLoader:()=>L(()=>import("./index-C0UgJX5y.js"),__vite__mapDeps([17,18,19]))},Kn=Object.freeze(Object.defineProperty({__proto__:null,encryptPdfDefinition:jn},Symbol.toStringTag,{value:"Module"})),Vn={id:"excel-to-pdf",name:"Excel to PDF",description:"Convert Microsoft Excel spreadsheets (.xlsx) to PDF format.",entitlements:["office.convert"],limits:{featureTier:"basic",maxFileSize:{free:10*1024*1024,pro:100*1024*1024}},uiLoader:()=>L(()=>import("./index-7K0eYXQ0.js"),__vite__mapDeps([20,1,2,3])),logicLoader:()=>L(()=>import("./index-CxoqP-FV.js"),__vite__mapDeps([21,9,10,1]))},zn=Object.freeze(Object.defineProperty({__proto__:null,excelToPdfDefinition:Vn},Symbol.toStringTag,{value:"Module"})),$n={id:"extract-images",name:"Extract Images",description:"Extract embedded images from PDF pages into standalone image files.",entitlements:[],limits:{featureTier:"basic",maxFileSize:{free:50*1024*1024,pro:500*1024*1024},maxPagesPerFile:{free:100,pro:1e3}},uiLoader:()=>L(()=>import("./index-CSxRPO1x.js"),[]),logicLoader:()=>L(()=>import("./index-LvmBQmPO.js"),__vite__mapDeps([22,23,1]))},Gn=Object.freeze(Object.defineProperty({__proto__:null,extractImagesDefinition:$n},Symbol.toStringTag,{value:"Module"})),Hn={id:"merge-pdf",name:"Merge PDF",description:"Combine several PDF files into one document.",entitlements:["pdf.merge"],limits:{featureTier:"basic",maxFileSize:{free:25*1024*1024,pro:200*1024*1024},maxPagesPerFile:{free:200,pro:2e3}},uiLoader:()=>L(()=>import("./index-DFNlP0DC.js"),__vite__mapDeps([24,1,2,3])),logicLoader:()=>L(()=>import("./index-BUcAkoSU.js"),__vite__mapDeps([25,15,1]))},qn=Object.freeze(Object.defineProperty({__proto__:null,mergePdfDefinition:Hn},Symbol.toStringTag,{value:"Module"})),Wn={id:"ocr-pdf",name:"OCR PDF",description:"Recognize text in PDFs, scans, and document photos.",entitlements:[],limits:{maxFileSize:{free:10*1024*1024,pro:150*1024*1024},maxPagesPerFile:{free:50,pro:1e3}},uiLoader:()=>L(()=>import("./index-Coag7aJj.js"),__vite__mapDeps([26,1,2,3])),logicLoader:()=>L(()=>import("./index-CykOVW0V.js"),__vite__mapDeps([27,9,10,1,28,29]))},Yn=Object.freeze(Object.defineProperty({__proto__:null,ocrPdfDefinition:Wn},Symbol.toStringTag,{value:"Module"})),Jn={id:"pdf-editor",name:"PDF Editor",description:"Edit visible text directly in the PDF preview and export an updated file.",entitlements:["pdf.edit"],limits:{featureTier:"pro",maxFileSize:{free:50*1024*1024,pro:500*1024*1024},maxPagesPerFile:{free:300,pro:3e3}},uiLoader:()=>L(()=>import("./index-DMPIk2lq.js"),__vite__mapDeps([30,1,31,2,3])),logicLoader:()=>L(()=>import("./index-Ddq1D-Gc.js"),__vite__mapDeps([32,33,10,1,9,29,34,35]))},Qn=Object.freeze(Object.defineProperty({__proto__:null,pdfEditorDefinition:Jn},Symbol.toStringTag,{value:"Module"})),Xn={id:"pdf-info",name:"PDF Info",description:"Inspect PDF structure locally â pages, version, encryption, fonts, and metadata.",entitlements:[],limits:{featureTier:"basic",maxFileSize:{free:50*1024*1024,pro:500*1024*1024},maxPagesPerFile:{free:500,pro:5e3}},uiLoader:()=>L(()=>import("./index-DZ589PEf.js"),__vite__mapDeps([36,1,37])),logicLoader:()=>L(()=>import("./index-B3QPX3DA.js"),__vite__mapDeps([38,1]))},Zn=Object.freeze(Object.defineProperty({__proto__:null,pdfInfoDefinition:Xn},Symbol.toStringTag,{value:"Module"})),eo={id:"pdf-to-jpg",name:"PDF to JPG",description:"Convert each page of a PDF document into a high-quality JPG image.",entitlements:[],limits:{featureTier:"basic",maxFileSize:{free:50*1024*1024,pro:500*1024*1024}},uiLoader:()=>L(()=>import("./index-Duh6ox2M.js"),__vite__mapDeps([39,1,2,3,31])),logicLoader:()=>L(()=>import("./index-BU_9hLTi.js"),__vite__mapDeps([40,28,1]))},to=Object.freeze(Object.defineProperty({__proto__:null,pdfToJpgDefinition:eo},Symbol.toStringTag,{value:"Module"})),ro={id:"protect-pdf",name:"Protect PDF",description:"Protect PDF files with passwords and access restrictions.",entitlements:["pdf.protect.encrypt"],limits:{featureTier:"basic",maxFileSize:{free:25*1024*1024,pro:200*1024*1024},maxPagesPerFile:{free:300,pro:3e3}},uiLoader:()=>L(()=>import("./index-_GxNNZpf.js"),__vite__mapDeps([41,1])),logicLoader:()=>L(()=>import("./index-DbfrR-Li.js"),__vite__mapDeps([42,18,19,43,44,1]))},no=Object.freeze(Object.defineProperty({__proto__:null,protectPdfDefinition:ro},Symbol.toStringTag,{value:"Module"})),oo={id:"rotate-pdf",name:"Rotate PDF",description:"Rotate all pages in your PDF document by a specific angle.",entitlements:["pdf.rotate"],limits:{featureTier:"basic",maxFileSize:{free:50*1024*1024,pro:500*1024*1024}},uiLoader:()=>L(()=>import("./index-CBESyuai.js"),__vite__mapDeps([45,1])),logicLoader:()=>L(()=>import("./index-D2VU6-JJ.js"),__vite__mapDeps([46,15,1]))},io=Object.freeze(Object.defineProperty({__proto__:null,rotatePdfDefinition:oo},Symbol.toStringTag,{value:"Module"})),so={id:"share-pdf",name:"Share to Phone",description:"Securely send your PDF to a mobile phone using a temporary end-to-e
2nd encrypted QR-code.",entitlements:["pdf.protect.unlock"],limits:{featureTier:"basic",maxFileSize:{free:50*1024*1024,pro:500*1024*1024}},uiLoader:()=>L(()=>import("./index-Dsw1hied.js"),__vite__mapDeps([47,1])),logicLoader:()=>L(()=>import("./index-oga1POoz.js"),[])},ao=Object.freeze(Object.defineProperty({__proto__:null,sharePdfDefinition:so},Symbol.toStringTag,{value:"Module"})),lo={id:"split-pdf",name:"Split PDF",description:"Split a PDF into multiple output documents.",entitlements:["pdf.split"],limits:{featureTier:"basic",maxFileSize:{free:25*1024*1024,pro:200*1024*1024},maxPagesPerFile:{free:200,pro:2e3}},uiLoader:()=>L(()=>import("./index-Bl7JxPa-.js"),__vite__mapDeps([48,1])),logicLoader:()=>L(()=>import("./index-B6aI-4Ib.js"),__vite__mapDeps([49,15,1]))},co=Object.freeze(Object.defineProperty({__proto__:null,splitPdfDefinition:lo},Symbol.toStringTag,{value:"Module"})),uo={id:"unlock-pdf",name:"Unlock PDF",description:"Remove password protection from PDF files.",entitlements:["pdf.protect.unlock"],limits:{featureTier:"basic",maxFileSize:{free:25*1024*1024,pro:200*1024*1024},maxPagesPerFile:{free:300,pro:3e3}},uiLoader:()=>L(()=>import("./index-BU-5NrEo.js"),__vite__mapDeps([50,1])),logicLoader:()=>L(()=>import("./index-Cp7oKUoZ.js"),__vite__mapDeps([51,18,19]))},fo=Object.freeze(Object.defineProperty({__proto__:null,unlockPdfDefinition:uo},Symbol.toStringTag,{value:"Module"})),po={id:"word-to-pdf",name:"Word to PDF",description:"Convert Microsoft Word documents (.docx) to PDF format.",entitlements:["office.convert"],limits:{featureTier:"basic",maxFileSize:{free:10*1024*1024,pro:100*1024*1024}},uiLoader:()=>L(()=>import("./index-qvDU5HiG.js"),__vite__mapDeps([52,1,2,3])),logicLoader:()=>L(()=>import("./index-U464jI_5.js"),__vite__mapDeps([53,18,19,9,10,1]))},mo=Object.freeze(Object.defineProperty({__proto__:null,wordToPdfDefinition:po},Symbol.toStringTag,{value:"Module"}));class go{constructor(){N(this,"tools",new Map)}register(e){if(this.tools.has(e.id))throw new Error(`Tool already registered: ${e.id}`);this.tools.set(e.id,e)}get(e){const n=this.tools.get(e);if(!n)throw new Error(`Tool not found: ${e}`);return n}list(){return Array.from(this.tools.values())}}function ho(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.id=="string"&&typeof e.name=="string"&&typeof e.description=="string"&&typeof e.uiLoader=="function"&&typeof e.logicLoader=="function"}function yo(t){const e=[];for(const n of Object.keys(t)){const r=t[n];for(const o of Object.keys(r)){const i=r[o];ho(i)&&e.push(i)}}return e}function _o(){return yo(Object.assign({"../../plugins/auto-toc/definition.ts":Nn,"../../plugins/compress-pdf/definition.ts":Mn,"../../plugins/delete-pages-pdf/definition.ts":Fn,"../../plugins/encrypt-pdf/definition.ts":Kn,"../../plugins/excel-to-pdf/definition.ts":zn,"../../plugins/extract-images/definition.ts":Gn,"../../plugins/merge-pdf/definition.ts":qn,"../../plugins/ocr-pdf/definition.ts":Yn,"../../plugins/pdf-editor/definition.ts":Qn,"../../plugins/pdf-info/definition.ts":Zn,"../../plugins/pdf-to-jpg/definition.ts":to,"../../plugins/protect-pdf/definition.ts":no,"../../plugins/rotate-pdf/definition.ts":io,"../../plugins/share-pdf/definition.ts":ao,"../../plugins/split-pdf/definition.ts":co,"../../plugins/unlock-pdf/definition.ts":fo,"../../plugins/word-to-pdf/definition.ts":mo}))}function Eo(t=_o()){const e=new go;for(const n of t)e.register(n);return e}let Xe=null;function wo(){return Xe||(Xe=L(()=>import("./vendor-pdflib-BC_rCeQu.js").then(t=>t.c),__vite__mapDeps([10,1]))),Xe}async function zt(t,e){if(e&&e!=="application/pdf")return 1;const{PDFDocument:n}=await wo();return(await n.load(t)).getPageCount()}class Br{track(){}}class So{constructor(e=500){N(this,"listeners",new Set);N(this,"events",[]);this.maxEvents=e}track(e){this.events.push(e),this.events.length>this.maxEvents&&this.events.shift();for(const n of this.listeners)n(e)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}snapshot(){return[...this.events]}clear(){this.events.length=0}}class To{track(e){console.info("[telemetry]",JSON.stringify(e))}}class bo{constructor(e){this.sinks=e}track(e){for(const n of this.sinks)n.track(e)}}class Co{constructor(e,n,r,o=new Br,i){N(this,"pageCountTimeoutMs");N(this,"firstPageCountTimeoutMs");N(this,"pageCountChecksPerformed",0);N(this,"pageCountFallbackMode");this.registry=e,this.workerOrchestrator=n,this.fileSystem=r,this.telemetry=o,this.pageCountTimeoutMs=(i==null?void 0:i.pageCountTimeoutMs)??5e3,this.firstPageCountTimeoutMs=(i==null?void 0:i.firstPageCountTimeoutMs)??(i==null?void 0:i.pageCountTimeoutMs)??1e4,this.pageCountFallbackMode=(i==null?void 0:i.pageCountFallbackMode)??"limited"}async execute(e,n,r,o,i){let s=0;try{for(const f of n.inputIds){const m=await this.fileSystem.read(f);s+=await m.getSize()}}catch{}let a;try{a=await this.validateAccess(e,n.inputIds,r,s)}catch(f){const m=f instanceof Error?f.message:"Access check failed",h=f,g=typeof h.code=="string"?h.code:"ACCESS_CHECK_FAILED",T=`access-check-${crypto.randomUUID()}`;
2return this.telemetry.track({type:"TOOL_RUN_ERROR",runId:T,toolId:e,durationMs:0,code:g,message:m}),this.publishErrorToast(T,e,m),{type:"TOOL_ERROR",message:m,code:g}}if(a)return a;const l=crypto.randomUUID(),u=Date.now(),d={id:crypto.randomUUID(),type:"COMMAND",payload:{type:"PROCESS_TOOL",payload:{toolId:e,inputIds:n.inputIds,options:n.options}}};let p;try{p=await this.workerOrchestrator.dispatch(d,f=>{if(f.payload.type==="PROGRESS"){const{progress:m,detail:h}=f.payload.payload;this.telemetry.track({type:"TOOL_RUN_PROGRESS",runId:l,toolId:e,progress:m}),o==null||o({type:"TOOL_PROGRESS",progress:m,detail:h})}},i)}catch(f){const m=f instanceof Error?f.message:"Unexpected worker dispatch failure";return this.telemetry.track({type:"TOOL_RUN_ERROR",runId:l,toolId:e,durationMs:Date.now()-u,code:"WORKER_DISPATCH_FAILED",message:m}),this.publishErrorToast(l,e,m),{type:"TOOL_ERROR",message:m,code:"WORKER_DISPATCH_FAILED"}}return p.payload.type==="RESULT"?(this.telemetry.track({type:"TOOL_RUN_RESULT",runId:l,toolId:e,durationMs:Date.now()-u,outputCount:p.payload.payload.outputIds.length,totalInputSize:s}),{type:"TOOL_RESULT",outputIds:p.payload.payload.outputIds}):p.payload.type==="ERROR"?(this.telemetry.track({type:"TOOL_RUN_ERROR",runId:l,toolId:e,durationMs:Date.now()-u,code:p.payload.payload.code,message:p.payload.payload.message}),this.publishErrorToast(l,e,p.payload.payload.message),{type:"TOOL_ERROR",message:p.payload.payload.message,code:p.payload.payload.code}):(this.telemetry.track({type:"TOOL_RUN_ERROR",runId:l,toolId:e,durationMs:Date.now()-u,code:"INVALID_WORKER_EVENT",message:"Unexpected worker event type"}),this.publishErrorToast(l,e,"Unexpected worker event type"),{type:"TOOL_ERROR",message:"Unexpected worker event type",code:"INVALID_WORKER_EVENT"})}publishErrorToast(e,n,r){this.telemetry.track({type:"UI_TOAST_SHOWN",runId:e,toolId:n,message:r,level:"error"})}publishUpsell(e,n,r){this.telemetry.track({type:"UI_UPSELL_SHOWN",runId:e,toolId:n,reason:r})}async validateAccess(e,n,r,o){var d;const i=this.registry.get(e),s=`access-check-${crypto.randomUUID()}`;this.telemetry.track({type:"TOOL_RUN_STARTED",runId:s,toolId:e,inputCount:n.length,totalInputSize:o});const a=this.checkEntitlements(i.entitlements,r.entitlements);if(a)return this.telemetry.track({type:"TOOL_RUN_DENIED",runId:s,toolId:e,reason:a.reason}),this.publishUpsell(s,e,a.details??a.reason),a;const l=this.checkFeatureTier((d=i.limits)==null?void 0:d.featureTier,r.plan);if(l)return this.telemetry.track({type:"TOOL_RUN_DENIED",runId:s,toolId:e,reason:l.reason}),this.publishUpsell(s,e,l.details??l.reason),l;this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:s,toolId:e,stage:"CHECK_FILE_LIMITS_START"});const u=await this.checkFileLimits(n,i.limits,r.plan,s,e);return this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:s,toolId:e,stage:"CHECK_FILE_LIMITS_DONE"}),u?(this.telemetry.track({type:"TOOL_RUN_DENIED",runId:s,toolId:e,reason:u.reason}),this.publishUpsell(s,e,u.details??u.reason),u):null}checkEntitlements(e,n){if(!e||e.length===0)return null;const r=e.filter(o=>!n.includes(o));return r.length>0?{type:"TOOL_ACCESS_DENIED",reason:"ENTITLEMENT_REQUIRED",details:`Missing entitlements: ${r.join(", ")}`}:null}checkFeatureTier(e,n){return e&&e==="pro"&&n!=="pro"?{type:"TOOL_ACCESS_DENIED",reason:"LIMIT_EXCEEDED",details:"This tool requires PRO tier"}:null}async checkFileLimits(e,n,r,o,i){if(!n)return null;const s=n.maxFileSize?r==="pro"?n.maxFileSize.pro:n.maxFileSize.free:null,a=n.maxPagesPerFile?r==="pro"?n.maxPagesPerFile.pro:n.maxPagesPerFile.free:null;for(const l of e){if(s!==null){const u=Date.now();this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:o,toolId:i,fileId:l,stage:"MAX_FILE_SIZE_READ_START"});const p=await(await this.fileSystem.read(l)).getSize();if(this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:o,toolId:i,fileId:l,stage:"MAX_FILE_SIZE_READ_DONE",durationMs:Date.now()-u}),p>s)return{type:"TOOL_ACCESS_DENIED",reason:"LIMIT_EXCEEDED",details:`File ${l} exceeds maxFileSize`}}if(a!==null){this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:o,toolId:i,fileId:l,stage:"PAGE_COUNT_CHECK_START"});const u=await this.getPdfPageCount(l,o,i);if(this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:o,toolId:i,fileId:l,stage:"PAGE_COUNT_CHECK_DONE"}),u>a)return{type:"TOOL_ACCESS_DENIED",reason:"LIMIT_EXCEEDED",details:`File ${l} exceeds maxPagesPerFile`}}}return null}async getPdfPageCount(e,n,r){const o=Date.now();this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:n,toolId:r,fileId:e,stage:"READ_FILE_FOR_PAGE_COUNT_START"});const i=await this.fileSystem.read(e);this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:n,toolId:r,fileId:e,stage:"READ_FILE_FOR_PAGE_COUNT_DONE",durationMs:Date.now()-o});const s=await i.getType();if(s!=="application/pdf")return this.telemetry.track({type:"PAGE_COUNT_CHECK_RESULT",runId:n,toolId:r,fileId:e,pageCount:1,durationMs:Date.now()-o}),1;this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:n,toolId:r,fileId:e,stage:"READ_BLOB_FOR_PAGE_COUNT_START"});const a=await i.getBlob(),l=new Uint8Array(await a.arrayBuffer());this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:n,toolId:r,fileId:e,stage:"READ_BLOB_FOR_PAGE_COUNT_DONE",durationMs:Date.now()-o});const u={id:crypto.randomUUID(),type:"COMMAND",payload:{type:"GET_PDF_PAGE_COUNT",payload:{fileId:e,bytes:l,mimeType:s}}};let d;const p=this.pageCountChecksPerformed===0?this.firstPageCountTimeoutMs:this.pageCountTimeoutMs;this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:n,toolId:r,fileId:e,stage:"PAGE_COUNT_DISPATCH_START"});const f=new AbortController;try{d=await new Promise((m,h)=>{const g=setTimeout(()=>{f.abort(),h(this.createCodedError("PAGE_COUNT_CHECK_TIMEOUT","Page-count precheck timed out"))},p);this.workerOrchestrator.dispatch(u,T=>{T.payload.type==="DIAGNOSTIC"&&T.payload.payload.channel==="PAGE_COUNT"&&this.telemetry.track({type:"PAGE_COUNT_WORKER_STAGE",runId:n,toolId:r,fileId:e,stage:T.payload.payload.stage,durationMs:T.payload.payload.durationMs,note:T.payload.payload.note})},f.signal).then(T=>{clearTimeout(g),m(T)},T=>{clearTimeout(g),h(T)})})}catch(m){const h=m,g=typeof h.code=="string"?h.code:"PAGE_COUNT_QUERY_FAILED",T=m instanceof Error?m.message:"Page-count precheck failed";if(this.canFallbackToMainThread(g,p)){this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:n,toolId:r,fileId:e,stage:"PAGE_COUNT_MAIN_THREAD_FALLBACK_START"});try{const D=await zt(l,s);return this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:n,toolId:r,fileId:e,stage:"PAGE_COUNT_MAIN_THREAD_FALLBACK_DONE",durationMs:Date.now()-o}),this.telemetry.track({type:"PAGE_COUNT_CHECK_RESULT",runId:n,toolId:r,fileId:e,pageCount:D,durationMs:Date.now()-o}),D}catch(D){const C=D instanceof Error?D.message:"Main-thread fallback failed";throw this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:n,toolId:r,fileId:e,stage:"PAGE_COUNT_MAIN_THREAD_FALLBACK_FAILED",durationMs:Date.now()-o}),this.telemetry.track({type:"PAGE_COUNT_CHECK_ERROR",runId:n,toolId:r,fileId:e,code:"PAGE_COUNT_MAIN_THREAD_FALLBACK_FAILED",message:C,durationMs:Date.now()-o}),this.createCodedError("PAGE_COUNT_MAIN_THREAD_FALLBACK_FAILED",C)}}throw this.telemetry.track({type:"PAGE_COUNT_CHECK_ERROR",runId:n,toolId:r,fileId:e,code:g,message:T,durationMs:Date.now()-o}),this.createCodedError(g,T)}finally{this.pageCountChecksPerformed+=1}if(d.payload.type==="PAGE_COUNT_RESULT")return this.telemetry.track({type:"PAGE_COUNT_CHECK_RESULT",runId:n,toolId:r,fileId:e,pageCount:d.payload.payload.pageCount,durationMs:Date.now()-o}),d.payload.payload.pageCount;if(d.payload.type==="ERROR"){const m=d.payload.payload.code??"PAGE_COUNT_QUERY_FAILED";if(this.canFallbackToMainThread(m,p)){this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:n,toolId:r,fileId:e,stage:"PAGE_COUNT_MAIN_THREAD_FALLBACK_START"});try{const g=await zt(l,s);return this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:n,toolId:r,fileId:e,stage:"PAGE_COUNT_MAIN_THREAD_FALLBACK_DONE",durationMs:Date.now()-o}),this.telemetry.track({type:"PAGE_COUNT_CHECK_RESULT",runId:n,toolId:r,fileId:e,pageCount:g,durationMs:Date.now()-o}),g}catch(g){const T=g instanceof Error?g.message:"Main-thread fallback failed";throw this.telemetry.track({type:"ACCESS_CHECK_STAGE",runId:n,toolId:r,fileId:e,stage:"PAGE_COUNT_MAIN_THREAD_FALLBACK_FAILED",durationMs:Date.now()-o}),this.telemetry.track({type:"PAGE_COUNT_CHECK_ERROR",runId:n,toolId:r,fileId:e,code:"PAGE_COUNT_MAIN_THREAD_FALLBACK_FAILED",message:T,durationMs:Date.now()-o}),this.createCodedError("PAGE_COUNT_MAIN_THREAD_FALLBACK_FAILED",T)}
2}throw this.telemetry.track({type:"PAGE_COUNT_CHECK_ERROR",runId:n,toolId:r,fileId:e,code:m,message:d.payload.payload.message,durationMs:Date.now()-o}),this.createCodedError(m,`${m}: ${d.payload.payload.message}`)}throw this.telemetry.track({type:"PAGE_COUNT_CHECK_ERROR",runId:n,toolId:r,fileId:e,code:"PAGE_COUNT_QUERY_INVALID_EVENT",message:`Unexpected worker event type: ${d.payload.type}`,durationMs:Date.now()-o}),this.createCodedError("PAGE_COUNT_QUERY_INVALID_EVENT",`PAGE_COUNT_QUERY_INVALID_EVENT: ${d.payload.type}`)}createCodedError(e,n){const r=new Error(n);return r.code=e,r}canFallbackToMainThread(e,n){return this.pageCountFallbackMode==="off"?!1:this.pageCountFallbackMode==="on"?n>=1e3:n>=1e3&&(e==="WORKER_TIMEOUT"||e==="WORKER_CRASH")}}class Fr extends Error{constructor(n){super(`Cannot delete pinned file: ${n}`);N(this,"code","FILE_PINNED")}}const Ao=Object.freeze(Object.defineProperty({__proto__:null,FilePinnedError:Fr},Symbol.toStringTag,{value:"Module"}));class $t extends Error{constructor(){super(...arguments);N(this,"code","VFS_QUOTA_EXCEEDED")}}class Ro{constructor(e,n={}){N(this,"tempByScope",new Map);N(this,"fileSizes",new Map);N(this,"tempFileIds",new Set);N(this,"totalBytes",0);N(this,"tempBytes",0);this.fs=e,this.quota=n}async write(e){this.ensureQuota(e.size,!1);const n=await this.fs.write(e);return this.registerFile(n.id,e.size,!1),n}async writeTemp(e,n){this.ensureQuota(n.size,!0);const r=await this.fs.write(n);this.registerFile(r.id,n.size,!0);const o=this.tempByScope.get(e)??new Set;return o.add(r.id),this.tempByScope.set(e,o),r}read(e){return this.fs.read(e)}async pin(e){await this.fs.pin(e)}async unpin(e){await this.fs.unpin(e)}async delete(e){try{await this.fs.delete(e),this.unregisterFile(e)}catch(n){if(n instanceof Fr)return;throw n}}async cleanupScope(e){const n=this.tempByScope.get(e);if(n){for(const r of n)await this.delete(r);this.tempByScope.delete(e)}}getQuotaUsage(){return{totalBytes:this.totalBytes,tempBytes:this.tempBytes}}ensureQuota(e,n){if(this.quota.maxTotalBytes!==void 0&&this.totalBytes+e>this.quota.maxTotalBytes)throw new $t("VFS total quota exceeded");if(n&&this.quota.maxTempBytes!==void 0&&this.tempBytes+e>this.quota.maxTempBytes)throw new $t("VFS temp quota exceeded")}registerFile(e,n,r){this.fileSizes.set(e,n),this.totalBytes+=n,r&&(this.tempFileIds.add(e),this.tempBytes+=n)}unregisterFile(e){const n=this.fileSizes.get(e);n!==void 0&&(this.totalBytes-=n,this.tempFileIds.has(e)&&(this.tempFileIds.delete(e),this.tempBytes-=n),this.fileSizes.delete(e))}}class Po{constructor(e,n=18e4){N(this,"worker",null);N(this,"inFlight",new Map);this.createWorker=e,this.timeoutMs=n}ensureWorker(){if(this.worker)return this.worker;const e=this.createWorker();return e.onmessage=n=>{var i;const r=n.data,o=this.inFlight.get(r.id);o&&(clearTimeout(o.timeoutId),o.timeoutId=setTimeout(()=>{this.settle(r.id,{id:r.id,type:"EVENT",payload:{type:"ERROR",payload:{message:"Worker timeout exceeded",code:"WORKER_TIMEOUT"}}})},this.timeoutMs),(i=o.onEvent)==null||i.call(o,r),(r.payload.type==="RESULT"||r.payload.type==="PAGE_COUNT_RESULT"||r.payload.type==="TEXT_LAYER_RESULT"||r.payload.type==="IMAGE_CANDIDATES_RESULT"||r.payload.type==="STUDIO_TEXT_EDITS_APPLIED"||r.payload.type==="ERROR")&&this.settle(r.id,r))},e.onerror=n=>{const r=Array.from(this.inFlight.keys());for(const o of r)this.settle(o,{id:o,type:"EVENT",payload:{type:"ERROR",payload:{message:n.message??"Worker crashed",code:"WORKER_CRASH"}}});e.terminate(),this.worker=null},this.worker=e,e}settle(e,n){var o;const r=this.inFlight.get(e);r&&(this.inFlight.delete(e),clearTimeout(r.timeoutId),(o=r.signal)==null||o.removeEventListener("abort",r.onAbort),r.resolve(n))}terminateForTest(){var n;const e=Array.from(this.inFlight.keys());for(const r of e)this.settle(r,{id:r,type:"EVENT",payload:{type:"ERROR",payload:{message:"Worker terminated for test",code:"WORKER_CRASH"}}});(n=this.worker)==null||n.terminate(),this.worker=null}dispatch(e,n,r){if(r!=null&&r.aborted)return Promise.resolve({id:e.id,type:"EVENT",payload:{type:"ERROR",payload:{message:"Worker execution aborted",code:"WORKER_ABORTED"}}});const o=this.ensureWorker();return new Promise(i=>{const s=()=>{this.settle(e.id,{id:e.id,type:"EVENT",payload:{type:"ERROR",payload:{message:"Worker execution aborted",code:"WORKER_ABORTED"}}})},a=setTimeout(()=>{this.settle(e.id,{id:e.id,type:"EVENT",payload:{type:"ERROR",payload:{message:"Worker timeout exceeded",code:"WORKER_TIMEOUT"}}})},this.timeoutMs);this.inFlight.set(e.id,{resolve:i,onEvent:n,timeoutId:a,signal:r,onAbort:s}),r==null||r.addEventListener("abort",s,{once:!0}),this.inFlight.has(e.id)&&o.postMessage(e)})}}class Io{constructor(e=async n=>({id:n.id,type:"EVENT",payload:{type:"ERROR",payload:{message:"Worker handler not configured",code:"NOT_IMPLEMENT
2ED"}}})){this.handler=e}async dispatch(e,n,r){if(r!=null&&r.aborted)return{id:e.id,type:"EVENT",payload:{type:"ERROR",payload:{message:"Worker execution aborted",code:"WORKER_ABORTED"}}};const o=await this.handler(e);return n==null||n(o),o}}function Do(t){return new Po(()=>new Worker(new URL("/app/assets/worker-entrypoint-Cpi_3YOf.js",import.meta.url),{type:"module"}),t)}class ko{track(e){if(!(typeof window>"u")&&(e.type==="TOOL_RUN_STARTED"?this.trackGA4("tool_start",{tool_id:e.toolId,input_count:e.inputCount,total_input_size:e.totalInputSize}):e.type==="TOOL_RUN_RESULT"?this.trackGA4("tool_success",{tool_id:e.toolId,duration_ms:e.durationMs,output_count:e.outputCount,total_input_size:e.totalInputSize}):e.type==="TOOL_RUN_ERROR"&&this.trackGA4("tool_error",{tool_id:e.toolId,error_code:e.code}),window.posthog))switch(e.type){case"APP_SESSION_ATTRIBUTED":window.posthog.capture("app_session_attributed",{flow_id:e.flowId,entry_url:e.entryUrl,entry_path:e.entryPath,referrer:e.referrer,referring_domain:e.referringDomain,utm_source:e.utmSource,utm_medium:e.utmMedium,utm_campaign:e.utmCampaign});break;case"APP_FILE_UPLOADED":window.posthog.capture("app_file_uploaded",{flow_id:e.flowId,tool_id:e.toolId,file_count:e.fileCount,mime_category:e.mimeCategory,total_bytes:e.totalBytes,source:e.source});break;case"OUTPUT_DOWNLOADED":window.posthog.capture("app_output_downloaded",{flow_id:e.flowId,run_id:e.runId,tool_id:e.toolId,output_count:e.outputCount,surface:e.surface});break;case"TOOL_RUN_ABANDONED":window.posthog.capture("app_tool_run_abandoned",{flow_id:e.flowId,run_id:e.runId,tool_id:e.toolId,reason:e.reason});break;case"TOOL_RUN_STARTED":window.posthog.capture("app_tool_run_started",{tool_id:e.toolId,input_count:e.inputCount,total_input_size:e.totalInputSize});break;case"TOOL_RUN_RESULT":window.posthog.capture("app_tool_run_success",{tool_id:e.toolId,duration_ms:e.durationMs,output_count:e.outputCount,total_input_size:e.totalInputSize});break;case"TOOL_RUN_ERROR":window.posthog.capture("app_tool_run_error",{tool_id:e.toolId,error_code:e.code,message:e.message});break;case"UI_UPSELL_SHOWN":window.posthog.capture("app_upsell_shown",{tool_id:e.toolId,reason:e.reason});break;case"STUDIO_EDIT_SAVE_ACTION":window.posthog.capture("app_studio_save",{tool_id:e.toolId,action:e.action,pages_total:e.pagesTotal,pages_succeeded:e.pagesSucceeded});break;
2case"STUDIO_EMPTY_STATE_CTA":window.posthog.capture("studio_empty_state_cta",{run_id:e.runId,action:e.action});break;case"STUDIO_MERGE_COMPLETED":window.posthog.capture("studio_merge_completed",{run_id:e.runId,source_doc_id:e.sourceDocId,target_doc_id:e.targetDocId,page_count:e.pageCount,method:e.method});break;case"STUDIO_SPLIT_COMPLETED":window.posthog.capture("studio_split_completed",{run_id:e.runId,source_doc_id:e.sourceDocId,new_doc_id:e.newDocId,page_count:e.pageCount,method:e.method});break;case"STUDIO_DELETE_PAGES":window.posthog.capture("studio_delete_pages",{run_id:e.runId,page_count:e.pageCount,workspace_count:e.workspaceCount,method:e.method});break}}trackGA4(e,n){window.gtag&&window.gtag("event",e,n)}}const Lt=["pdf.merge","pdf.split","pdf.compress"],Ot=[...Lt,"pdf.ocr","pdf.rotate","pdf.delete_pages","pdf.edit","pdf.to_image","office.convert","pdf.protect.encrypt","pdf.protect.unlock","pdf.redact.verify"],vo=[...Ot],xo=new Set(vo);function Lo(t,e){const n=Array.isArray(t)?t:[],o=Array.from(new Set(n.filter(s=>typeof s=="string"))).filter(s=>xo.has(s)),i=e==="pro"||e==="trial"?new Set(Ot):new Set(Lt);return o.filter(s=>i.has(s))}function Ve(t){return[...t==="pro"||t==="trial"?Ot:Lt]}function Oo(t){return t==="pro"?"pro":t==="trial"?"trial":"basic"}function No(t,e){return t==="free"?e==="basic"?"free":null:t==="pro_monthly"||t==="pro_yearly"||t==="pro_lifetime"?e==="pro"||e==="trial"?t:null:t==null||t===""?Uo(e):null}function Uo(t){return t==="pro"||t==="trial"?"pro_monthly":"free"}const ue="localpdf_trial_start",Re="localpdf_trial_state",ze="localpdf_trial_used",Ze=4320*60*1e3,Mo=3600*1e3;let X=null,be=null;const Bo="localpdf_db",_e="trial_store",je="trial_start_time";async function jr(){return new Promise((t,e)=>{if(typeof indexedDB>"u")return e(new Error("IndexedDB is not supported"));const n=indexedDB.open(Bo,1);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(_e)||r.createObjectStore(_e)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)})}async function Fo(t){try{const e=await jr();return new Promise((n,r)=>{const s=e.transaction(_e,"readonly").objectStore(_e).get(t);s.onsuccess=()=>n(s.result),s.onerror=()=>r(s.error)})}catch{return null}}async function Nt(t,e){try{const n=await jr();return new Promise((r,o)=>{const a=n.transaction(_e,"readwrite").objectStore(_e).put(e,t);a.onsuccess=()=>r(),a.onerror=()=>o(a.error)})}catch{}}async function jo(){if(typeof window>"u"||!window.indexedDB)return;const t=localStorage.getItem(ue),e=await Fo(je);if(e===-1){t&&(localStorage.removeItem(ue),localStorage.removeItem(Re)),localStorage.setItem(ze,"true");return}t&&!e?await Nt(je,Number(t)):!t&&e&&localStorage.setItem(ue,String(e))}function F(){if(typeof localStorage>"u")return{isActive:!1,startedAt:null,endsAt:null,daysRemaining:0,hoursRemaining:0,isExpiredButNotTracked:!1,trialAvailable:!0};const t=localStorage.getItem(ze)==="true",e=localStorage.getItem(Re),n=localStorage.getItem(ue);if(t)return{isActive:!1,startedAt:n?Number(n):null,endsAt:n?Number(n)+Ze:null,daysRemaining:0,hoursRemaining:0,isExpiredButNotTracked:!1,trialAvailable:!1};if(e==="expired")return{isActive:!1,startedAt:n?Number(n):null,endsAt:n?Number(n)+Ze:null,daysRemaining:0,hoursRemaining:0,isExpiredButNotTracked:!0,trialAvailable:!1};if(!n)return{isActive:!1,startedAt:null,endsAt:null,daysRemaining:0,hoursRemaining:0,isExpiredButNotTracked:!1,trialAvailable:!0};const r=Number(n);if(Number.isNaN(r))return localStorage.removeItem(ue),{isActive:!1,startedAt:null,endsAt:null,daysRemaining:0,hoursRemaining:0,isExpiredButNotTracked:!1,trialAvailable:!0};const o=r+Ze,i=Date.now();if(i>=o)return localStorage.setItem(Re,"expired"),{isActive:!1,startedAt:r,endsAt:o,daysRemaining:0,hoursRemaining:0,isExpiredButNotTracked:!0,trialAvailable:!1};const s=o-i;return{isActive:!0,startedAt:r,endsAt:o,daysRemaining:Math.floor(s/(1440*60*1e3)),hoursRemaining:Math.floor(s%(1440*60*1e3)/(3600*1e3)),isExpiredButNotTracked:!1,trialAvailable:!1}}function Ko(t){X=t,Pe()}function Pe(){if(typeof window>"u")return;be!==null&&(clearTimeout(be),be=null);const t=F();if(t.isExpiredButNotTracked){X==null||X();return}if(!t.isActive||t.endsAt===null)return;const e=t.endsAt-Date.now();if(e<=0){F().isExpiredButNotTracked&&(X==null||X());return}be=setTimeout(()=>{if(be=null,F().isExpiredButNotTracked){X==null||X();return}Pe()},Math.min(e+250,Mo))}function Vo(){if(typeof localStorage<"u"&&localStorage.getItem(ze)==="true")return F();const t=Date.now();localStorage.setItem(ue,String(t)),localStorage.removeItem(Re),Nt
2(je,t).catch(()=>{});const e=F();return Pe(),e}function Ne(){localStorage.removeItem(ue),localStorage.removeItem(Re),localStorage.setItem(ze,"true"),Nt(je,-1).catch(()=>{})}function zo(t){const e=t.route??(typeof window<"u"?window.location.pathname:void 0);return{...t,route:e}}function Y(t,e={}){if(typeof window>"u")return;const n=zo(e);window.posthog&&window.posthog.capture(t,n),window.gtag&&window.gtag("event",t,n)}function Kr(t={}){const e=t.toolId??"studio",n=t.trigger??"upsell_guardrail",r=`localpdf_paywall_seen:${e}:${n}`;let o=!1;if(typeof window<"u")try{o=window.sessionStorage.getItem(r)==="1",o||window.sessionStorage.setItem(r,"1")}catch{}return o?!1:(Y("paywall_shown",t),!0)}const Dt="localpdf_dev_pro_override";function $o(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(Dt)==="1"}catch{return!1}}function Go(t){if(!(typeof localStorage>"u"))try{t?localStorage.setItem(Dt,"1"):localStorage.removeItem(Dt)}catch{}}const me={userId:"local-user",plan:"basic",entitlements:Ve("basic")},Gt={userId:"local-user",plan:"pro",entitlements:Ve("pro")};function Ue(){return{userId:"local-user",plan:"pro",entitlements:Ve("trial")}}function kt(t,e=!1){const n=e?t:t.replace(/-/g,"+").replace(/_/g,"/"),r=n.padEnd(n.length+(4-n.length%4)%4,"=");return typeof Buffer<"u"?Buffer.from(r,"base64").toString("binary"):atob(r)}function et(t){const e=kt(t);if(typeof Buffer<"u")return Buffer.from(e,"binary").toString("utf8");const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return new TextDecoder().decode(n)}class Ho{constructor(e,n,r={}){N(this,"currentContext",me);N(this,"realContext",me);N(this,"listeners",new Set);this.storageKey=e,this.jwtPublicKeyPem=n,this.options=r}getContext(){return this.currentContext}isLocalProAvailable(){return this.options.allowLocalPro===!0}isLocalProEnabled(){return this.isLocalProAvailable()&&$o()}setLocalPro(e){return this.isLocalProAvailable()?(Go(e),this.currentContext=this.isLocalProEnabled()?Gt:this.realContext,this.notify(),this.isLocalProEnabled()):!1}setContext(e){this.realContext=e,this.currentContext=this.isLocalProEnabled()?Gt:e,this.notify()}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){for(const e of this.listeners)e(this.currentContext)}async initialize(){typeof localStorage<"u"&&await jo(),Ko(()=>{F().isExpiredButNotTracked&&(Y("trial_expired",{source:"trial_watch"}),Ne(),typeof localStorage<"u"&&!localStorage.getItem(this.storageKey)&&this.setContext(me))}),Pe();let e=F();e.isExpiredButNotTracked&&(Y("trial_expired",{source:"billing_init"}),Ne(),e=F());const n=typeof localStorage<"u"?localStorage.getItem(this.storageKey):null;if(!n){this.setContext(e.isActive?Ue():me);return}let r=n,o=await this.verifyToken(r);if(!o){const s=await this.refreshBillingToken(r).catch(()=>null);s&&(o=await this.verifyToken(s),o&&(r=s,typeof localStorage<"u"&&localStorage.setItem(this.storageKey,r)))}if(!o){typeof localStorage<"u"&&localStorage.removeItem(this.storageKey),this.setContext(e.isActive?Ue():me);return}const i={userId:"local-user",plan:o.plan,entitlements:o.entitlements};(e.isActive||e.isExpiredButNotTracked)&&(Y("trial_convert",{trialDaysRemaining:e.daysRemaining,source:"token_verified_init"}),Ne()),this.setContext(i);try{const s=r.split("."),a=JSON.parse(et(s[1])),l=Math.floor(Date.now()/1e3);typeof a.exp=="number"&&a.exp-l<7200*60&&this.refreshBillingToken(r).then(async u=>{u&&await this.saveToken(u)}).catch(()=>{})}catch{}}async saveToken(e){const n=await this.verifyToken(e);if(!n)return!1;const r=F(),o=r.isActive||r.isExpiredButNotTracked;return typeof localStorage<"u"&&(localStorage.setItem(this.storageKey,e),o&&(Y("trial_convert",{trialDaysRemaining:r.daysRemaining,source:"manual_save"}),Ne())),this.setContext({userId:"local-user",plan:n.plan,entitlements:n.entitlements}),!0}getStoredToken(){return typeof localStorage<"u"?localStorage.getItem(this.storageKey):null}clearToken(){typeof localStorage<"u"&&localStorage.removeItem(this.storageKey);const e=F();this.setContext(e.isActive?Ue():me)}startTrial(){Vo(),this.setContext(Ue())}async refreshBillingToken(e){try{const n=await fetch("/api/billing/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e})});if(!n.ok)return null;const r=await n.json();if(r.success&&typeof r.token=="string")return r.token}catch(n){console.error("Error in refreshBillingToken:",n)}return null}async verifyToken(e){var n;try{if(!((n=this.jwtPublicKeyPem)!=null&&n.trim()))return null;const r=e.split(".");if(r.length!==3)return null;const o=JSON.parse(et(r[0])),i=JSON.parse(et(r[1])),s=Uint8Array.from(kt(r[2]),C=>C.charCodeAt(0));if(o.alg!=="RS256"||o.typ!=="JWT")return null;const a=Math.floor(Date.now()/1e3);if(typeof i.exp!="number"||i.exp<=a||typeof i.iat!="number"||i.iat>a+300||i.nbf!==void 0&&(typeof i.nbf!="number"||i.nbf>a+300)||i.iss!=="localpdf-billing"||i.aud!=="localpdf-v6"||typeof i.sub!="string"||i.sub.trim().length===0)return null;
2const u=this.jwtPublicKeyPem.replace(/\\n/g,` 3`).replace(/-----BEGIN PUBLIC KEY-----|-----END PUBLIC KEY-----|\s+/g,"");if(!u)return null;const d=Uint8Array.from(kt(u,!0),C=>C.charCodeAt(0)),p=globalThis.crypto;if(!(p!=null&&p.subtle))return null;const f=await p.subtle.importKey("spki",d,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]),m=new TextEncoder().encode(`${r[0]}.${r[1]}`);if(!await p.subtle.verify("RSASSA-PKCS1-v1_5",f,s,m))return null;const g=Oo(i.plan);if(g==="trial"||!No(i.tier,g))return null;const R=Lo(i.entitlements,g),D=Ve(g);return{plan:g,entitlements:R.length>0?R:D}}catch{return null}}}const Be={};var tt={};const qo={maxTotalBytes:512*1024*1024,maxTempBytes:256*1024*1024};function Wo(){const t=Be==null?void 0:Be.VITE_V6_PAGE_COUNT_FALLBACK_MODE,e=typeof process<"u"?tt==null?void 0:tt.V6_PAGE_COUNT_FALLBACK_MODE:void 0,n=(t??e??"limited").toLowerCase();return n==="off"||n==="limited"||n==="on"?n:"limited"}function Yo(t="browser-worker",e,n){const r=Eo(e),o=new It,i=new Ro(o,qo),s=new So,a=new ko;s.subscribe(f=>a.track(f));const l=new bo([s,t==="browser-worker"?new To:new Br]),u=t==="browser-worker"?Do():new Io(async f=>{const{executeWorkerCommand:m}=await L(async()=>{const{executeWorkerCommand:h}=await import("./worker-runtime-BVBu-yi6.js");return{executeWorkerCommand:h}},__vite__mapDeps([54,23,33,10,1,9,29,34,35,43,19,44]));return m(f,{registry:r,fs:o})}),d=new Co(r,u,o,l,{pageCountFallbackMode:Wo()}),p=new Ho("v6_subscription_jwt",`-----BEGIN PUBLIC KEY----- 4MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5xPX8DuQ2LNTRswlSiYh 5OFJhnzUdnxKz6twJ5uen63ol36kmfHphA6RDrDuFbNl5/zHj6mDHwRCquMHIk5LJ 6ddZQrfl8JxL4eWi1yBvGxpUUDvixmyg+KQSSiwAjI7tiui41tXQyEimLgl5MJtez 7rMBurruU3dfBtcwg2TsoILKl/oA8rymudPCSl3KzJBhnpbunSiuDVU1wVDfvUwkj 8BiFv96QT6N2rYNV0J7E/kkK0ZP3uTibDn8EXtesdnV9LPQkLlXlib+zMvYqk8+1/ 9LS0P1vLRU+fX5y0fY5XvQA236JlnaQgNSrBSdS4ZCIp/ct/DoJksG9W2FHX0z/gf 10gwIDAQAB 11-----END PUBLIC KEY-----`,{allowLocalPro:typeof Be<"u"&&!1});return{mode:t,registry:r,vfs:i,runner:d,workerOrchestrator:u,telemetry:s,billing:p}}function Jo(t){return t.list().filter(e=>!Mr(e.id)).map(e=>({toolId:e.id,path:`/${e.id}`,title:e.name,loadUi:e.uiLoader}))}function Qo(t="browser-worker",e){const n=Yo(t,e),r=Jo(n.registry),o=vn(n.registry);return{runtime:n,routes:r,menu:o}}const ce=3,Vr="localpdf_daily_files";function Xo(){return new Date().toISOString().slice(0,10)}function rt(t){return{date:t,processed:0,downloaded:0}}function zr(){var e;const t=Xo();try{const n=(e=globalThis.localStorage)==null?void 0:e.getItem(Vr);if(!n)return rt(t);const r=JSON.parse(n);return r.date!==t?rt(t):{date:t,processed:Number.isFinite(r.processed)?Number(r.processed):0,downloaded:Number.isFinite(r.downloaded)?Number(r.downloaded):0}}catch{return rt(t)}}function Zo(t){var e;try{(e=globalThis.localStorage)==null||e.setItem(Vr,JSON.stringify(t))}catch{}}function ei(t){return zr()[t]}function Ut(t,e=1){const n=ei(t),r=Math.max(0,ce-n);return{allowed:e>0&&n+e<=ce,kind:t,limit:ce,used:n,requested:e,remaining:r}}function $r(t,e=1){if(e<=0)return;const n=zr();n[t]+=e,Zo(n)}function Gr(t,e=1){const r=Ut(t,e).remaining,o=r===1?"1 file":`${r} files`;return t==="processed"?r===0?`Free includes ${ce} files per day and you have added all of them today. Upgrade to Pro for unlimited files.`:`Free includes ${ce} files per day â ${o} left today. Upgrade to Pro for unlimited files.`:r===0?`Free includes ${ce} downloads per day and you have used all of them today. Upgrade to Pro for unlimited downloads.`:`Free includes ${ce} downloads per day â ${o} left today. Upgrade to Pro for unlimited downloads.`}const ye={};function Hr(t,e,n,r={}){const o=crypto.randomUUID(),i=F(),s=r.toolId??"studio",a=r.trigger??"upsell_guardrail",l=i.isActive?`Trial: ${i.daysRemaining}d ${i.hoursRemaining}h remaining`:e;return t.track({type:"UI_UPSELL_SHOWN",runId:o,toolId:s,reason:l}),Kr({source:"studio_paywall",toolId:s,trigger:i.isActive?"trial_countdown":a,reason:l,userState:"local",hadPriorSuccessfulRun:!1,flowId:o}),o}function ti(t,e,n,r=1){return e!=="basic"?!0:Ut(n,r).allowed?($r(n,r),!0):(Hr(t,Gr(n,r),ye==null?void 0:ye.VITE_BILLING_URL,{toolId:"studio",trigger:"daily_files_downloaded"}),!1)}function vs(t,e,n=1){return e!=="basic"||Ut("processed",n).allowed?!0:(Hr(t,Gr("processed",n),ye==null?void 0:ye.VITE_BILLING_URL,{toolId:"studio",trigger:"daily_files_processed"}),!1)}function xs(t=1){$r("processed",t)}const Ht="localpdf.flow_id",qt="localpdf.entry_url",Wt="localpdf.entry_path",Yt="localpdf.entry_referrer",Jt="localpdf.entry_referring_domain",Qt="localpdf.entry_utm_source",Xt="localpdf.entry_utm_medium",Zt="localpdf.entry_utm_campaign";function qr(){if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}}function ri(t){const e=t.replace(/^#/,"").trim();return e?e.startsWith("/")?e:`/${e}`:""}function Wr(t,e=""){return t==="/app"&&e?`/app${ri(e)}`:t||"/"}function vt(){const t=qr(),e=t==null?void 0:t.getItem(Ht);if(e)return e;const n=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`flow_${Math.random().toString(36).slice(2,10)}`;return t==null||t.setItem(Ht,n),n}function ni(){if(typeof window>"u")return null;const t=qr();if(!t)return null;const e=new URL(window.location.href),n=t.getItem(qt)??e.href,r=t.getItem(Wt)??Wr(e.pathname,e.hash),o=t.getItem(Yt)??document.referrer??"$direct",i=t.getItem(Jt)??(()=>{try{return o&&o!=="$direct"?new URL(o).origin:"$direct"}catch{return"$direct"}}
11)(),s=t.getItem(Qt)??e.searchParams.get("utm_source")??"",a=t.getItem(Xt)??e.searchParams.get("utm_medium")??"",l=t.getItem(Zt)??e.searchParams.get("utm_campaign")??"";return t.setItem(qt,n),t.setItem(Wt,r),t.setItem(Yt,o||"$direct"),t.setItem(Jt,i||"$direct"),s&&t.setItem(Qt,s),a&&t.setItem(Xt,a),l&&t.setItem(Zt,l),{entryUrl:n,entryPath:r,referrer:o||"$direct",referringDomain:i||"$direct",utmSource:s,utmMedium:a,utmCampaign:l}}function oi(){if(typeof window>"u")return{};const t=new URL(window.location.href),e=ni();return{flow_id:vt(),current_url:t.href,current_pathname:t.pathname,canonical_path:Wr(t.pathname,t.hash),route_hash:t.hash||"",is_hash_route:!!t.hash,entry_url:(e==null?void 0:e.entryUrl)??null,entry_path:(e==null?void 0:e.entryPath)??null,entry_referrer:(e==null?void 0:e.referrer)??"$direct",entry_referring_domain:(e==null?void 0:e.referringDomain)??"$direct",entry_utm_source:(e==null?void 0:e.utmSource)??null,entry_utm_medium:(e==null?void 0:e.utmMedium)??null,entry_utm_campaign:(e==null?void 0:e.utmCampaign)??null}}function ii(){const t=oi();return{type:"APP_SESSION_ATTRIBUTED",flowId:String(t.flow_id||""),entryUrl:String(t.entry_url||""),entryPath:String(t.entry_path||""),referrer:String(t.entry_referrer||"$direct"),referringDomain:String(t.entry_referring_domain||"$direct"),utmSource:typeof t.entry_utm_source=="string"?t.entry_utm_source:void 0,utmMedium:typeof t.entry_utm_medium=="string"?t.entry_utm_medium:void 0,utmCampaign:typeof t.entry_utm_campaign=="string"?t.entry_utm_campaign:void 0}}const Yr=v.createContext(null);function si({children:t}){const e=v.useMemo(()=>Qo("browser-worker"),[]);return v.useEffect(()=>{if(e.runtime.billing.initialize().catch(console.error),e.runtime.telemetry.track(ii()),typeof window>"u")return;if(typeof window<"u"&&window.__PLAYWRIGHT_TEST__){const r=e.runtime.workerOrchestrator,o=r.dispatch.bind(r);let i=0,s=!1,a=!1;const l=async(u,d,p)=>{var f,m,h,g,T;return a&&((f=u==null?void 0:u.payload)==null?void 0:f.type)==="GET_PDF_PAGE_COUNT"?(a=!1,(m=r.terminateForTest)==null||m.call(r),{id:u.id,type:"EVENT",payload:{type:"ERROR",payload:{message:"Injected page-count crash (e2e)",code:"WORKER_CRASH"}}}):s&&((h=u==null?void 0:u.payload)==null?void 0:h.type)==="PROCESS_TOOL"?(s=!1,(g=r.terminateForTest)==null||g.call(r),{id:u.id,type:"EVENT",payload:{type:"ERROR",payload:{message:"Injected worker crash (e2e)",code:"WORKER_CRASH"}}}):(i>0&&((T=u==null?void 0:u.payload)==null?void 0:T.type)==="GET_PDF_PAGE_COUNT"&&await new Promise(R=>{setTimeout(R,i)}),o(u,d,p))};return r.dispatch=l,window.__LOCALPDF_V6_TEST_API={trackTelemetry:u=>
11e.runtime.telemetry.track(u),getTelemetrySnapshot:()=>e.runtime.telemetry.snapshot(),clearTelemetry:()=>e.runtime.telemetry.clear(),setPageCountDelayMs:u=>{i=Math.max(0,Math.floor(u))},setPageCountTimeoutMs:u=>{const d=Math.max(1,Math.floor(u));e.runtime.runner.pageCountTimeoutMs=d,e.runtime.runner.firstPageCountTimeoutMs=d},setPageCountFallbackMode:u=>{e.runtime.runner.pageCountFallbackMode=u},injectProcessToolCrashOnce:()=>{s=!0},injectPageCountCrashOnce:()=>{a=!0},resetWorkerTestHooks:()=>{i=0,s=!1,a=!1,e.runtime.runner.pageCountTimeoutMs=5e3,e.runtime.runner.firstPageCountTimeoutMs=1e4,e.runtime.runner.pageCountFallbackMode="limited"},extractPdfText:async u=>{var d;try{const p={id:crypto.randomUUID(),type:"COMMAND",payload:{type:"GET_PDF_TEXT_LAYER",payload:{fileId:u,pageNumber:1}}},f=await r.dispatch(p);return((d=f==null?void 0:f.payload)==null?void 0:d.type)!=="TEXT_LAYER_RESULT"?"":f.payload.payload.spans.map(g=>g.text).join(" ").replace(/\s+/gu," ").trim()}catch{return""}},readFileBase64:async u=>{const p=await(await e.runtime.vfs.read(u)).getBlob(),f=new Uint8Array(await p.arrayBuffer());let m="";const h=32768;for(let g=0;g<f.length;g+=h){const T=f.subarray(g,g+h);m+=String.fromCharCode(...T)}return btoa(m)}},()=>{r.dispatch=o,delete window.__LOCALPDF_V6_TEST_API}}},[e.runtime.telemetry]),c.jsx(Yr.Provider,{value:e,children:t})}function $e(){const t=v.useContext(Yr);if(!t)throw new Error("PlatformProvider is not mounted");return t}const ai=v.lazy(async()=>({default:(await L(()=>import("./WizardShell-BWt57YAP.js"),__vite__mapDeps([55,1,2,3,56,31]))).WizardShell})),li=v.lazy(async()=>({default:(await L(()=>import("./StudioShell-Brt3Q-jV.js"),__vite__mapDeps([57,1,56,58,59,2,3,60,34,31]))).StudioShell})),ci=v.lazy(async()=>({default:(await L(()=>import("./StudioEditWorkspace-Bw-PfBMm.js"),__vite__mapDeps([61,1,60,2,3,34,44,31,59,35]))).StudioEditWorkspace})),ui=v.lazy(async()=>({default:(await L(()=>import("./StudioConvertWorkspace-dZysDiVu.js"),__vite__mapDeps([62,1,2,3,31,59]))).StudioConvertWorkspace})),di=v.lazy(async()=>({default:(await L(()=>import("./ocr-pdf-test-page-BNsxRCwp.js"),__vite__mapDeps([63,1]))).OcrPdfTestPage})),fi=v.lazy(async()=>({default:(await L(()=>import("./mobile-share-downloader-CT3DsSbj.js"),__vite__mapDeps([64,1]))).MobileShareDownloader}));function pi(){return c.jsx("div",{children:"Loading tool..."})}function mi(){return c.jsx("div",{children:"No tools are registered."})}function gi(){const{routes:t}=$e();return t.length===0?c.jsx(mi,{}):c.jsx(v.Suspense,{fallback:c.jsx(pi,{}),children:c.jsxs(yn,{children:[c.jsx(ne,{path:"/",element:c.jsx(Qe,{to:"/studio",replace:!0})}),t.map(e=>c.jsx(ne,{path:e.path,element:e.toolId==="ocr-pdf"?c.jsx(di,{}):c.jsx(ai,{toolId:e.toolId},e.toolId)},e.toolId)),c.jsx(ne,{path:"/studio",element:c.jsx(li,{})}),c.jsx(ne,{path:"/studio/edit",element:c.jsx(ci,{})}),c.jsx(ne,{path:"/studio/convert",element:c.jsx(ui,{})}),c.jsx(ne,{path:"/ocr-pdf-test",element:c.jsx(Qe,{to:"/ocr-pdf",replace:!0})}),c.jsx(ne,{path:"/share",element:c.jsx(fi,{})}),c.jsx(ne,{path:"*",element:c.jsx(Qe,{to:"/studio",replace:!0})})]})})}const hi="/pricing";function Jr(t){return/^https?:\/\//i.test(t)}function yi(t){return hi}function _i(t){const e=t==null?void 0:t.trim();return e&&Jr(e)?e:null}function er(t){const e=yi();return typeof window>"u"?e:Jr(e)?(window.open(e,"_blank","noopener,noreferrer"),e):(window.location.assign(e),e)}function Qr(t,e){if(typeof window>"u")return;const n=_i(t);if(!n)return;Y("checkout_opened",{source:(e==null?void 0:e.source)??"billing",trigger:e==null?void 0:e.trigger,checkoutUrl:n,destination:n,plan:e==null?void 0:e.plan,variant:e==null?void 0:e.variant,userState:(e==null?void 0:e.userState)??"local",hadPriorSuccessfulRun:e==null?void 0:e.hadPriorSuccessfulRun,flowId:e==null?void 0:e.flowId});const r=window.LemonSqueezy;if(r&&r.Url&&typeof r.Url.Open=="function"){r.Url.Open(n);return}window.open(n,"_blank","noopener,noreferrer")}const nt={BASE_URL:"/app/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_LS_CHECKOUT_URL_PRO_MONTHLY:"https://localpdf.lemonsqueezy.com/checkout/buy/df6ab354-b1fa-48e2
11-858b-b2601c0c759c?enabled=1442622",VITE_LS_CHECKOUT_URL_PRO_YEARLY:"https://localpdf.lemonsqueezy.com/checkout/buy/fe9368a5-c232-4f35-a33f-2b75cea5aa85?enabled=1442621",VITE_PUBLIC_JWT_KEY:`-----BEGIN PUBLIC KEY----- 12MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5xPX8DuQ2LNTRswlSiYh 13OFJhnzUdnxKz6twJ5uen63ol36kmfHphA6RDrDuFbNl5/zHj6mDHwRCquMHIk5LJ 14ddZQrfl8JxL4eWi1yBvGxpUUDvixmyg+KQSSiwAjI7tiui41tXQyEimLgl5MJtez 15rMBurruU3dfBtcwg2TsoILKl/oA8rymudPCSl3KzJBhnpbunSiuDVU1wVDfvUwkj 16BiFv96QT6N2rYNV0J7E/kkK0ZP3uTibDn8EXtesdnV9LPQkLlXlib+zMvYqk8+1/ 17LS0P1vLRU+fX5y0fY5XvQA236JlnaQgNSrBSdS4ZCIp/ct/DoJksG9W2FHX0z/gf 18gwIDAQAB 19-----END PUBLIC KEY-----`,VITE_VERCEL_OBSERVABILITY_CLIENT_CONFIG:'{"analytics":{"scriptSrc":"262e58d8b324ee43/script.js","viewEndpoint":"262e58d8b324ee43/view","eventEndpoint":"262e58d8b324ee43/event","sessionEndpoint":"262e58d8b324ee43/session"},"speedInsights":{"scriptSrc":"6f8e7e2587a6b8de/script.js","endpoint":"6f8e7e2587a6b8de/vitals"}}'},Ei=19,wi=39.99,Si="https://localpdf.lemonsqueezy.com/checkout/buy/e42c57ec-d7a3-4bd9-9595-3f38f6f2a8f5",Ti="https://localpdf.lemonsqueezy.com/checkout/buy/fe9368a5-c232-4f35-a33f-2b75cea5aa85?enabled=1442621";function Xr(t){const e=nt==null?void 0:nt[t],n=typeof e=="string"?e.trim():"";return/^https?:\/\//i.test(n)?n:""}function bi(){return Xr("VITE_LS_CHECKOUT_URL_PRO_LIFETIME")||Si}function Ci(){return Xr("VITE_LS_CHECKOUT_URL_PRO_YEARLY")||Ti}function Ai(t,e){const n=typeof t=="string"?t.trim():"";if(n)return{url:n,variant:"lifetime",label:`Get Pro Lifetime â $${Ei} once`};const r=typeof e=="string"?e.trim():"";return r?{url:r,variant:"yearly",label:`Upgrade to Pro â $${wi}/year`}:null}function Ke(){return Ai(bi(),Ci())}const Zr=4e3,tr=4;function Ri(t,e,n){return`${t}|${e}|${n.trim().toLowerCase()}`}function Pi(t,e,n=Zr){return t===void 0?!0:e-t>=n}function Ii(t){return t.type==="UI_TOAST_SHOWN"}function Di(t){return t.type==="UI_UPSELL_SHOWN"}const ki={"ocr-pdf":"OCR is a Pro feature","pdf-to-jpg":"PDF to JPG is a Pro feature","extract-images":"Download all images requires Pro"};function vi(t,e){return ki[t]??e}function xi(t){var n,r;if(typeof window>"u")return t;const e=(r=(n=window.posthog)==null?void 0:n.get_distinct_id)==null?void 0:r.call(n);return e?`${t}${t.includes("?")?"&":"?"}checkout[custom][distinct_id]=${e}`:t}function Li(){var u;const{runtime:t}=$e(),[e,n]=v.useState([]),[r,o]=v.useState(null),[i,s]=v.useState(F()),a=v.useRef(new Map),l=v.useRef(new Map);return v.useEffect(()=>{const d=setInterval(()=>{s(F())},6e4);return()=>clearInterval(d)},[]),v.useEffect(()=>t.telemetry.subscribe(d=>{if(Ii(d)){const p=Date.now(),f=Ri(d.toolId,d.level,d.message),m=a.current.get(f);if(!Pi(m,p)){const g=(l.current.get(f)??0)+1;l.current.set(f,g),t.telemetry.track({type:"UI_TOAST_DEDUPED",runId:d.runId,toolId:d.toolId,key:f,suppressedCount:g});return}a.current.set(f,p),l.current.delete(f);for(const[g,T]of a.current)p-T>Zr*2&&a.current.delete(g);const h=`${d.runId}-${Date.now()}`;n(g=>{const T=[...g,{id:h,message:d.message,level:d.level}];return T.length<=tr?T:T.slice(T.length-tr)}),setTimeout(()=>{n(g=>g.filter(T=>T.id!==h))},5e3);return}Di(d)&&o({runId:d.runId,toolId:d.toolId,reason:d.reason})}),[t.telemetry]),c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"ux-toast-stack",children:e.map(d=>c.jsxs("div",{"data-testid":"ux-toast-item",className:`ux-toast-item${d.level==="error"?" error":""}`,children:[d.message,c.jsx("button",{type:"button",className:"ux-toast-close","aria-label":"Dismiss",onClick:()=>n(p=>p.filter(f=>f.id!==d.id)),children:"â"}),c.jsx("div",{className:"ux-toast-progress"})]},d.id))}),r&&c.jsx("div",{className:"ux-upsell-overlay",role:"presentation",onClick:()=>o(null),children:c.jsxs("div",{className:"ux-upsell-modal",role:"dialog","aria-modal":"true",onClick:d=>d.stopPropagation(),children:[c.jsxs("div",{className:"ux-upsell-header",children:[c.jsx("div",{className:"ux-upsell-icon",children:"â¡"}),c.jsxs("div",{className:"ux-upsell-body",children:[c.jsx("h3",{className:"ux-upsell-title",children:i.isActive?`Trial active â ${i.daysRemaining}d ${i.hoursRemaining}h left`:vi(r.toolId,r.reason)}),c.jsx("p",{className:"ux-upsell-sub",children:i.isActive?"You have full Pro access during your trial. Buy once to keep it after the trial ends.":"One payment, no subscription â unlock unlimited pages and every Pro tool for good."})]})]}),c.jsxs("div",{className:"ux-upsell-actions",children:[c.jsx("button",{className:"ux-upsell-btn-ghost",onClick:()=>o(null),children:i.isActive?"Continue trial":"Not now"}),c.jsx("button",{className:"ux-upsell-btn-primary",onClick:()=>{const d=Ke();if(d){const p=xi(d.url);t.telemetry.track({type:"UI_UPSELL_CTA_CLICKED",runId:r.runId,toolId:r.toolId,destination:p}
19),Y("paywall_cta_clicked",{source:"upsell_overlay",toolId:r.toolId,trigger:"upgrade_pro",destination:p,variant:d.variant,userState:"local",hadPriorSuccessfulRun:!0,flowId:r.runId}),Qr(p,{source:"upsell_overlay",trigger:"upgrade_pro",plan:"pro",variant:d.variant,userState:"local",hadPriorSuccessfulRun:!0,flowId:r.runId})}o(null)},children:((u=Ke())==null?void 0:u.label)??"Upgrade to Pro"})]})]})})]})}function Oi(t=200){const{runtime:e}=$e(),[n,r]=v.useState(()=>e.telemetry.snapshot().slice(-t));return v.useEffect(()=>e.telemetry.subscribe(o=>{r(i=>{const s=[...i,o];return s.length<=t?s:s.slice(s.length-t)})}),[t,e.telemetry]),n}function Ni(t){switch(t.type){case"TOOL_RUN_ERROR":return`${t.type} ${t.toolId} code=${t.code??"n/a"} msg=${t.message}`;case"PAGE_COUNT_CHECK_RESULT":return`${t.type} ${t.toolId} file=${t.fileId} pages=${t.pageCount} ms=${t.durationMs}`;case"PAGE_COUNT_CHECK_ERROR":return`${t.type} ${t.toolId} file=${t.fileId} code=${t.code??"n/a"} ms=${t.durationMs} msg=${t.message}`;case"ACCESS_CHECK_STAGE":return`${t.type} ${t.toolId} stage=${t.stage}${t.fileId?` file=${t.fileId}`:""}${t.durationMs!==void 0?` ms=${t.durationMs}`:""}`;case"PAGE_COUNT_WORKER_STAGE":return`${t.type} ${t.toolId} stage=${t.stage} file=${t.fileId}${t.durationMs!==void 0?` ms=${t.durationMs}`:""}${t.note?` note=${t.note}`:""}`;case"UI_TOAST_SHOWN":return`${t.type} ${t.toolId} level=${t.level} msg=${t.message}`;case"UI_UPSELL_SHOWN":return`${t.type} ${t.toolId} reason=${t.reason}`;case"UI_TOAST_DEDUPED":return`${t.type} ${t.toolId} suppressed=${t.suppressedCount} key=${t.key}`;case"UI_UPSELL_CTA_CLICKED":return`${t.type} ${t.toolId} dest=${t.destination}`;case"UI_PREVIEW_RENDERED":return`${t.type} ${t.toolId} file=${t.fileId} ms=${t.durationMs}${t.pageCount!==void 0?` pages=${t.pageCount}`:""}`;case"UI_PREVIEW_ERROR":return`${t.type} ${t.toolId} file=${t.fileId} msg=${t.message}`;case"STUDIO_EDIT_GUARDRAIL":return`${t.type} ${t.toolId} file=${t.fileId} page=${t.pageIndex} code=${t.code??"n/a"} msg=${t.message}`;case"STUDIO_EDIT_SAVE_ACTION":return`${t.type} ${t.toolId} action=${t.action} scope=${t.scope} ok=${t.pagesSucceeded}/${t.pagesTotal} failed=${t.pagesFailed}${t.overflowCount!==void 0?` overflow=${t.overflowCount}`:""}${t.message?` msg=${t.message}`:""}`;case"APP_SESSION_ATTRIBUTED":return`${t.type} flow=${t.flowId} entry=${t.entryPath}`;case"APP_FILE_UPLOADED":return`${t.type} ${t.toolId} files=${t.fileCount} source=${t.source} bytes=${t.totalBytes}`;case"TOOL_RUN_ABANDONED":return`${t.type} ${t.toolId} run=${t.runId??"n/a"} reason=${t.reason}`;case"OUTPUT_DOWNLOADED":return`${t.type} ${t.toolId} run=${t.runId??"n/a"} outputs=${t.outputCount??0} surface=${t.surface}`;default:return`${t.type} ${"toolId"in t?t.toolId:"app"}`}}function Ui(){const t=Oi(80),[e,n]=v.useState(!1);return c.jsxs("div",{className:"telemetry-section",children:[c.jsxs("div",{className:"telemetry-header",children:[c.jsx("span",{children:"Live Telemetry"}),c.jsxs("label",{className:"telemetry-toggle",children:[c.jsx("input",{type:"checkbox",checked:e,onChange:r=>n(r.target.checked)}),c.jsx("span",{className:"telemetry-toggle-label",children:"Show"})]})]}),e&&c.jsx("div",{className:"telemetry-log animate-fade-in",children:t.length===0?c.jsx("div",{className:"telemetry-empty",children:"Awaiting local events..."}):t.map((r,o)=>{const i="runId"in r&&typeof r.runId=="string"?r.runId:"app";return c.jsxs("div",{className:"telemetry-event",children:[c.jsxs("span",{className:"telemetry-id",children:["[",i.slice(0,8),"]"]})," ",Ni(r)]},`${i}-${r.type}-${o}`)})})]})}const rr=t=>{let e;const n=new Set,r=(u,d)=>{const p=typeof u=="function"?u(e):u;if(!Object.is(p,e)){const f=e;e=d??(typeof p!="object"||p===null)?p:Object.assign({},e,p),n.forEach(m=>m(e,f))}},o=()=>e,a={setState:r,getState:o,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=e=t(r,o,a);return a},Mi=(t=>t?rr(t):rr),Bi=t=>t;function en(t,e=Bi){const n=Le.useSyncExternalStore(t.subscribe,Le.useCallback(()=>e(t.getState()),[t,e]),Le.useCallback(()=>e(t.getInitialState()),[t,e]));return Le.useDebugValue(n),n}const nr=t=>{const e=Mi(t),n=r=>en(e,r);return Object.assign(n,e),n},Mt=(t=>t?nr(t):nr);function Fi(){return typeof window>"u"?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}}const se=Mt(t=>({selection:[],requestedInlineTool:null,isDraggingFile:!1,activeDocumentId:null,interactionMode:null,activeEditPageId:null,operationScope:"selection",studioViewScale:1,studioViewPosition:{x:0,y:0},gridColumns:5,viewportSize:Fi(),whiteoutColor:"#ffffff",isHistoryOpen:!1,renamingDocId:null,
19setSelection:e=>t(n=>({selection:e,requestedInlineTool:e.length===0?null:n.requestedInlineTool})),requestInlineTool:e=>t({requestedInlineTool:e}),setDraggingFile:e=>t({isDraggingFile:e}),setActiveDocument:e=>t({activeDocumentId:e}),setInteractionMode:e=>t({interactionMode:e}),setActiveEditPageId:e=>t({activeEditPageId:e}),setOperationScope:e=>t({operationScope:e}),setStudioViewport:(e,n,r)=>t(o=>({studioViewScale:e,studioViewPosition:n,viewportSize:r??o.viewportSize})),setGridColumns:e=>t({gridColumns:e}),setWhiteoutColor:e=>t({whiteoutColor:e}),setHistoryOpen:e=>t({isHistoryOpen:e}),setRenamingDocId:e=>t({renamingDocId:e}),clearUI:()=>t({selection:[],requestedInlineTool:null,activeDocumentId:null,interactionMode:null,activeEditPageId:null,operationScope:"selection",studioViewScale:1,studioViewPosition:{x:0,y:0}})})),Fe=Mt(t=>({editSession:null,saveUndoStack:[],saveRedoStack:[],commandUndoStack:[],commandRedoStack:[],startEditSession:({docId:e,pageId:n,pageIndex:r,fileId:o,initialTool:i=null})=>t({editSession:{docId:e,pageId:n,pageIndex:r,sourceFileId:o,workingFileId:o,activeTool:i,startedAt:Date.now()}}),updateEditSessionTool:e=>t(n=>n.editSession?{editSession:{...n.editSession,activeTool:e}}:n),syncEditSessionTarget:e=>t(n=>n.editSession?{editSession:{...n.editSession,docId:e.docId,pageId:e.pageId,pageIndex:e.pageIndex,workingFileId:e.workingFileId}}:n),clearEditSession:()=>t({editSession:null}),pushSaveUndo:e=>t(n=>({saveUndoStack:[...n.saveUndoStack,e],saveRedoStack:[]})),popSaveUndo:()=>{let e=null;return t(n=>{if(n.saveUndoStack.length===0)return n;const r=[...n.saveUndoStack];return e=r.pop()??null,{saveUndoStack:r}}),e},pushSaveRedo:e=>t(n=>({saveRedoStack:[...n.saveRedoStack,e]})),popSaveRedo:()=>{let e=null;return t(n=>{if(n.saveRedoStack.length===0)return n;const r=[...n.saveRedoStack];return e=r.pop()??null,{saveRedoStack:r}}),e},pushCommandUndo:e=>t(n=>({commandUndoStack:[...n.commandUndoStack,e],commandRedoStack:[]})),popCommandUndo:()=>{let e=null;return t(n=>{if(n.commandUndoStack.length===0)return n;const r=[...n.commandUndoStack];return e=r.pop()??null,{commandUndoStack:r}}),e},pushCommandRedo:e=>t(n=>({commandRedoStack:[...n.commandRedoStack,e]})),popCommandRedo:()=>{let e=null;return t(n=>{if(n.commandRedoStack.length===0)return n;const r=[...n.commandRedoStack];return e=r.pop()??null,{commandRedoStack:r}}),e},clearSaveStacks:()=>t({saveUndoStack:[],saveRedoStack:[],commandUndoStack:[],commandRedoStack:[]}),clearSession:()=>t({editSession:null,saveUndoStack:[],saveRedoStack:[],commandUndoStack:[],commandRedoStack:[]})}));function ji(t,e=null){var d;const n=se.getState(),r=Fe.getState();let o=n.activeDocumentId;e!==null&&(o=e);const i=t.filter(p=>p.pages.length>0||p.allowEmpty),s=i.some(p=>p.id===o)?o:((d=i[0])==null?void 0:d.id)??null,a=new Set(i.flatMap(p=>p.pages.map(f=>f.id))),l=n.selection.filter(p=>a.has(p.pageId));l.length!==n.selection.length&&n.setSelection(l),s!==n.activeDocumentId&&n.setActiveDocument(s);const u=r.editSession;u&&!a.has(u.pageId)&&r.clearEditSession()}function J(t,e,n,r){return ji(e,r),{...t,documents:e,...n,workspaceVersion:t.workspaceVersion+1}}const ot=Mt(t=>({documents:[],detachedPages:[],workspaceVersion:0,lastExportedVersion:0,addDocument:e=>t(n=>{const o=se.getState().activeDocumentId??e.id;return J(n,[...n.documents,e],{},o)}),updateDocument:(e,n)=>t(r=>J(r,r.documents.map(o=>o.id===e?{...o,...n}:o))),removeDocument:e=>t(n=>{let o=se.getState().activeDocumentId;return o===e&&(o=null),J(n,n.documents.filter(i=>i.id!==e),{},o)}),setDocuments:e=>t(n=>J(n,e)),updatePage:(e,n,r)=>t(o=>{const i=o.documents.map(s=>s.id===e?{...s,isModified:!0,pages:s.pages.map(a=>a.id===n?{...a,...r}:a)}:s);return J(o,i)}),movePage:(e,n,r,o)=>t(i=>{const s=i.documents.find(f=>f.id===e),a=i.documents.find(f=>f.id===r);if(!s||!a)return i;const l=s.pages.find(f=>f.id===n);if(!l)return i;let u=s.pages.filter(f=>f.id!==n),d,p;return e===r?(d=[...u],typeof o=="number"?d.splice(o,0,l):d.push(l),p=i.documents.map(f=>f.id===e?{...f,pages:d,isModified:!0}:f)):(d=[...a.pages],typeof o=="number"?d.splice(o,0,l):d.push(l),p=i.documents.slice().map(f=>f.id===e?{...f,pages:u,isModified:!0}:f.id===r?{...f,pages:d,isModified:!0}:f)),J(i,p)}),detachPage:(e,n,r,o)=>t(i=>{const s=i.documents.find(d=>d.id===e),a=s==null?void 0:s.pages.find(d=>d.id===n);if(!s||!a)return i;const l=i.documents.map(d=>d.id!==e?d:{...d,isModified:!0,pages:d.pages.filter(p=>p.id!==n)}),u=se.getState();return u.setSelection(u.selection.filter(d=>d.pageId!==n)),J(i,l,{detachedPages:[...i.detachedPages,{...a,x:r,y:o}]})}),attachDetachedPage:(e,n,r)=>t(o=>{const i=o.detachedPages.find(u=>u.id===e),s=o.documents.find(u=>u.id===n);if(!i||!s)return o;const a={id:i.id,fileId:i.fileId,pageIndex:i.pageIndex,thumbnailUrl:i.thumbnailUrl,rotation:i.rotation},l=o.documents.map(u=>{if(u.id!==n)return u;const d=[...u.pages];return typeof r=="number"?d.splice(r,0,a):d.push(a),{...u,isModified:!0,pages:d}});return J(o,l,{detachedPages:o.detachedPages.filter(u=>u.id!==e)})}),moveDetachedPage:(e,n,r)=>t(o=>({detachedPages:o.detachedPages.map(i=>i.id===e?{...i,x:n,y:r}:i)})),removeDetachedPage:e=>t(n=>({detachedPages:n.detachedPages.filter(r=>r.id!==e)})),removePage:(e,n)=>t(r=>{const o=r.documents.map(s=>s.id!==e?s:{...s,isModified:!0,pages:s.pages.filter(a=>a.id!==n)}),i=se.getState();return i.setSelection(i.selection.filter(s=>s.pageId!==n)),J(r,o)}),recountWorkspacePages:()=>t(e=>J(e,e.documents)),markWorkspaceExported:()=>t(e=>({lastExportedVersion:e.workspaceVersion})),clearDocs:()=>t({documents:[],detachedPages:[],workspaceVersion:0,lastExportedVersion:0})}
19)),Ae={getState:()=>({...ot.getState(),...se.getState(),...Fe.getState(),clear:()=>{ot.getState().clearDocs(),se.getState().clearUI(),Fe.getState().clearSession()}}),setState:()=>{},getInitialState:()=>Ae.getState(),subscribe:t=>{let e=Ae.getState();const n=()=>{const s=Ae.getState();t(s,e),e=s},r=ot.subscribe(n),o=se.subscribe(n),i=Fe.subscribe(n);return()=>{r(),o(),i()}}},ie=(t=>en(Ae,t));Object.assign(ie,Ae);var Or;typeof window<"u"&&((Or=window.navigator)!=null&&Or.webdriver)&&(window.__LOCALPDF_STUDIO_STORE__=ie);class or{constructor(e){this.vfs=e}async execute(e){const n=[];for(const r of e.inputs){const s=await(await(await this.vfs.read(r)).getBlob()).arrayBuffer();n.push({id:r,buffer:new Uint8Array(s)})}return new Promise((r,o)=>{const i=new Worker(new URL("/app/assets/pipeline.worker-C_t75e_f.js",import.meta.url),{type:"module"});i.onmessage=a=>{a.data.type==="SUCCESS"?r({buffer:a.data.buffer,fileName:a.data.fileName}):o(new Error(a.data.error||"Pipeline execution failed")),i.terminate()},i.onerror=a=>{o(a),i.terminate()};const s=n.map(a=>a.buffer.buffer);i.postMessage({recipe:e,files:n},s)})}}function Ki(t){return t==="pass"?"#2b8a3e":t==="skip"?"var(--text-muted)":"var(--red, #c92a2a)"}function Vi({isOpen:t,fileName:e,onClose:n,onDownload:r,onShare:o,redactVerify:i=null,canDownloadCertificate:s=!1,onDownloadCertificate:a,onCertificatePaywall:l}){const u=v.useRef(null),[d,p]=v.useState("input"),[f,m]=v.useState(""),[h,g]=v.useState(null),[T,R]=v.useState(""),[D,C]=v.useState(!1),[k,U]=v.useState(""),S=(i==null?void 0:i.checks.filter(_=>_.result==="pass").length)??0,P=(i==null?void 0:i.checks.length)??0;if(v.useEffect(()=>{t&&(p("input"),g(null),R(""),U(""),C(!1),window.requestAnimationFrame(()=>{var _,b;(_=u.current)==null||_.focus(),(b=u.current)==null||b.select()}))},[t,e]),!t)return null;const A=_=>{var E;_.preventDefault();const b=((E=u.current)==null?void 0:E.value)??e;r(b),n()},w=async()=>{var b;const _=((b=u.current)==null?void 0:b.value)??e;p("processing");try{const E=await o(_,x=>{m(x)});g(E.qrCodeUrl),R(E.shareLink),p("ready")}catch(E){console.error(E),U((E==null?void 0:E.message)||"Failed to securely share document."),p("error")}},I=async()=>{try{await navigator.clipboard.writeText(T),C(!0),setTimeout(()=>C(!1),2e3)}catch(_){console.error("Failed to copy link:",_)}};return c.jsxs("div",{className:"studio-download-modal-backdrop",role:"presentation",onClick:n,children:[c.jsxs("div",{className:"studio-download-modal-card",role:"dialog","aria-modal":"true","aria-label":"Export document",onClick:_=>{_.stopPropagation()},style:{minWidth:"350px"},children:[d==="input"&&c.jsxs("form",{className:"studio-download-modal-form",onSubmit:A,children:[c.jsx("label",{className:"studio-download-modal-label",htmlFor:"studio-download-file-name",children:"Export Document"}),c.jsx("input",{ref:u,id:"studio-download-file-name",className:"studio-download-modal-input",type:"text",defaultValue:e,autoComplete:"off",spellCheck:!1}),i&&c.jsxs("div",{className:"studio-redact-verify-panel","data-testid":"studio-redact-verify-panel",children:[c.jsx("div",{className:"studio-redact-verify-title",children:i.passed?`Redaction verified · ${S}/${P||4} checks`:`Redaction not fully verified · ${S}/${P||4} checks`}),!i.passed&&c.jsx("p",{className:"studio-redact-verify-hint",children:"Text may still be extractable under the whiteout. You can download the PDF; a verification certificate is only available when all checks pass."}),c.jsx("ul",{className:"studio-redact-verify-list",children:i.checks.map(_=>c.jsxs("li",{style:{color:Ki(_.result)},children:[c.jsx("span",{children:_.label}),c.jsx("span",{children:_.result})]},_.id))}),i.passed&&i.certificateJson&&c.jsx("div",{className:"studio-redact-verify-cert-row",children:s?c.jsx("button",{type:"button",className:"studio-download-modal-ghost",onClick:a,"data-testid":"studio-redact-cert-download",children:"Download certificate.json"}):c.jsx("button",{type:"button",className:"studio-download-modal-ghost",onClick:l,"data-testid":"studio-redact-cert-paywall",style:{borderColor:"var(--accent)",color:"var(--accent)"},children:"Certificate â Upgrade to Pro"})})]}),c.jsxs("div",{className:"studio-download-modal-actions",style:{display:"flex",gap:"8px",marginTop:"8px"},children:[c.jsx("button",{type:"button",className:"studio-download-modal-ghost",onClick:n,children:"Cancel"}),c.jsxs("button",{type:"button",className:"studio-download-modal-ghost",onClick:()=>{w()},style:{marginRight:"auto",display:"flex",alignItems:"center",gap:"6px",borderColor:"#ced4da"},children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[c.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),c.jsx("line",{x1:"12",y1:"18",x2:"12.01",y2:"18"})]}),"Share to Phone"]}),c.jsx("button",{type:"submit",className:"studio-download-modal-primary","data-testid":"studio-download-submit",children:"Download"})]})]}),d==="processing"&&c.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",padding:"10px 0"},children:[c.jsx("div",{className:"wz-spinner",style:{width:"32px",height:"32px",border:"3px solid var(--border)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"spin 1s linear infinite"}}),c.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"var(--text)"},children:f})]}),d==="error"&&c.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",color:"var(--red)",padding:"10px 0"},children:[c.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[c.jsx("circle",{cx:"12",cy:"12",r:"10"}),c.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),c.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),c.jsx("div",{style:{fontSize:"13px",fontWeight:600},children:k}),c.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px",width:"100%",justifyContent:"center"},children:[c.jsx("button",{type:"button",className:"studio-download-modal-ghost",onClick:()=>p("input"),children:"Back"}),c.jsx("button",{type:"button",className:"studio-download-modal-ghost",onClick:n,children:"Close"})]})]}),d==="ready"&&h&&c.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",padding:"5px 0"},children:[c.jsx("div",{style:{fontSize:"14px",fontWeight:700,marginBottom:"12px",color:"var(--text)"},children:"Scan to Download"}),c.jsx("div",{style:{background:"#ffffff",padding:"8px",borderRadius:"8px",border:"1px solid var(--border)",marginBottom:"12px"},children:c.jsx("img",{src:h,alt:"QR Code",style:{width:"180px",height:"180px",display:"block"}})}),c.jsxs("div",{style:{fontSize:"12px",color:"#2b8a3e",fontWeight:600,display:"flex",alignItems:"center",gap:"4px",marginBottom:"4px"},children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:c.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),"E2EE Secure Link"]}),c.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",marginBottom:"16
19px"},children:"Expires in 60 minutes · Auto-destructs after download"}),c.jsxs("div",{style:{display:"flex",gap:"8px",width:"100%"},children:[c.jsx("button",{type:"button",onClick:()=>{I()},className:"studio-download-modal-ghost",style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",fontSize:"12px"},children:D?c.jsxs(c.Fragment,{children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#2b8a3e",strokeWidth:"2.5",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}),c.jsx("span",{style:{color:"#2b8a3e"},children:"Copied!"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[c.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),c.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),"Copy Link"]})}),c.jsx("button",{type:"button",className:"studio-download-modal-primary",onClick:n,style:{flex:1,fontSize:"12px"},children:"Close"})]})]})]}),c.jsx("style",{children:` 20 @keyframes spin { 21 to { transform: rotate(360deg); } 22 } 23 `})]})}function zi(t){var n,r;if(typeof window>"u")return t;const e=(r=(n=window.posthog)==null?void 0:n.get_distinct_id)==null?void 0:r.call(n);return e?`${t}${t.includes("?")?"&":"?"}checkout[custom][distinct_id]=${e}`:t}function $i(){const[t,e]=v.useState(F());if(v.useEffect(()=>{const o=setInterval(()=>{e(F())},6e4);return Pe(),()=>clearInterval(o)},[]),!t.isActive)return null;const n=Ke();if(!n)return null;const r=zi(n.url);return c.jsxs("div",{className:"trial-banner",children:[c.jsxs("span",{children:["⡠Pro Trial: ",c.jsxs("strong",{children:[t.daysRemaining,"d ",t.hoursRemaining,"h remaining"]})]}),c.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"trial-banner-link",children:n.label})]})}var ge={},it,ir;function Gi(){return ir||(ir=1,it=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),it}var st={},oe={},sr;function de(){if(sr)return oe;sr=1;let t;const e=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return oe.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},oe.getSymbolTotalCodewords=function(r){return e[r]},oe.getBCHDigit=function(n){let r=0;for(;n!==0;)r++,n>>>=1;return r},oe.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},oe.isKanjiModeEnabled=function(){return typeof t<"u"},oe.toSJIS=function(r){return t(r)},oe}var at={},ar;function Bt(){return ar||(ar=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function e(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,o){if(t.isValid(r))return r;try{return e(r)}catch{return o}}})(at)),at}var lt,lr;function Hi(){if(lr)return lt;lr=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(e){const n=Math.floor(e/8);return(this.buffer[n]>>>7-e%8&1)===1},put:function(e,n){for(let r=0;r<n;r++)this.putBit((e>>>n-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),e&&(this.buffer[n]|=128>>>this.length%8),this.length++}},lt=t,lt}var ct,cr;function qi(){if(cr)return ct;cr=1;function t(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return t.prototype.set=function(e,n,r,o){const i=e*this.size+n;this.data[i]=r,o&&(this.reservedBit[i]=!0)},t.prototype.get=function(e,n){return this.data[e*this.size+n]},t.prototype.xor=function(e,n,r){this.data[e*this.size+n]^=r},t.prototype.isReserved=function(e,n){return this.reservedBit[e*this.size+n]},ct=t,ct}var ut={},ur;function Wi(){return ur||(ur=1,(function(t){const e=de().getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const o=Math.floor(r/7)+2,i=e(r),s=i===145?26:Math.ceil((i-13)/(2*o-2))*2,a=[i-7];for(let l=1;l<o-1;
vendor: 18,766 bytes, lines 23-29
23l++)a[l]=a[l-1]-s;return a.push(6),a.reverse()},t.getPositions=function(r){const o=[],i=t.getRowColCoords(r),s=i.length;for(let a=0;a<s;a++)for(let l=0;l<s;l++)a===0&&l===0||a===0&&l===s-1||a===s-1&&l===0||o.push([i[a],i[l]]);return o}})(ut)),ut}var dt={},dr;function Yi(){if(dr)return dt;dr=1;const t=de().getSymbolSize,e=7;return dt.getPositions=function(r){const o=t(r);return[[0,0],[o-e,0],[0,o-e]]},dt}var ft={},fr;function Ji(){return fr||(fr=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};t.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},t.from=function(o){return t.isValid(o)?parseInt(o,10):void 0},t.getPenaltyN1=function(o){const i=o.size;let s=0,a=0,l=0,u=null,d=null;for(let p=0;p<i;p++){a=l=0,u=d=null;for(let f=0;f<i;f++){let m=o.get(p,f);m===u?a++:(a>=5&&(s+=e.N1+(a-5)),u=m,a=1),m=o.get(f,p),m===d?l++:(l>=5&&(s+=e.N1+(l-5)),d=m,l=1)}a>=5&&(s+=e.N1+(a-5)),l>=5&&(s+=e.N1+(l-5))}return s},t.getPenaltyN2=function(o){const i=o.size;let s=0;for(let a=0;a<i-1;a++)for(let l=0;l<i-1;l++){const u=o.get(a,l)+o.get(a,l+1)+o.get(a+1,l)+o.get(a+1,l+1);(u===4||u===0)&&s++}return s*e.N2},t.getPenaltyN3=function(o){const i=o.size;let s=0,a=0,l=0;for(let u=0;u<i;u++){a=l=0;for(let d=0;d<i;d++)a=a<<1&2047|o.get(u,d),d>=10&&(a===1488||a===93)&&s++,l=l<<1&2047|o.get(d,u),d>=10&&(l===1488||l===93)&&s++}return s*e.N3},t.getPenaltyN4=function(o){let i=0;const s=o.data.length;for(let l=0;l<s;l++)i+=o.data[l];return Math.abs(Math.ceil(i*100/s/5)-10)*e.N4};function n(r,o,i){switch(r){case t.Patterns.PATTERN000:return(o+i)%2===0;case t.Patterns.PATTERN001:return o%2===0;case t.Patterns.PATTERN010:return i%3===0;case t.Patterns.PATTERN011:return(o+i)%3===0;case t.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(i/3))%2===0;case t.Patterns.PATTERN101:return o*i%2+o*i%3===0;case t.Patterns.PATTERN110:return(o*i%2+o*i%3)%2===0;case t.Patterns.PATTERN111:return(o*i%3+(o+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(o,i){const s=i.size;for(let a=0;a<s;a++)for(let l=0;l<s;l++)i.isReserved(l,a)||i.xor(l,a,n(o,l,a))},t.getBestMask=function(o,i){const s=Object.keys(t.Patterns).length;let a=0,l=1/0;for(let u=0;u<s;u++){i(u),t.applyMask(u,o);const d=t.getPenaltyN1(o)+t.getPenaltyN2(o)+t.getPenaltyN3(o)+t.getPenaltyN4(o);t.applyMask(u,o),d<l&&(l=d,a=u)}return a}})(ft)),ft}var Me={},pr;function tn(){if(pr)return Me;pr=1;const t=Bt(),e=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Me.getBlocksCount=function(o,i){switch(i){case t.L:return e[(o-1)*4+0];case t.M:return e[(o-1)*4+1];case t.Q:return e[(o-1)*4+2];case t.H:return e[(o-1)*4+3];default:return}},Me.getTotalCodewordsCount=function(o,i){switch(i){case t.L:return n[(o-1)*4+0];case t.M:return n[(o-1)*4+1];case t.Q:return n[(o-1)*4+2];case t.H:return n[(o-1)*4+3];default:return}},Me}var pt={},Ce={},mr;function Qi(){if(mr)return Ce;mr=1;const t=new Uint8Array(512),e=new Uint8Array(256);return(function(){let r=1;for(let o=0;o<255;o++)t[o]=r,e[r]=o,r<<=1,r&256&&(r^=285);for(let o=255;o<512;o++)t[o]=t[o-255]})(),Ce.log=function(r){if(r<1)throw new Error("log("+r+")");return e[r]},Ce.exp=function(r){return t[r]},Ce.mul=function(r,o){return r===0||o===0?0:t[e[r]+e[o]]},Ce}var gr;function Xi(){return gr||(gr=1,(function(t){const e=Qi();t.mul=function(r,o){const i=new Uint8Array(r.length+o.length-1);for(let s=0;s<r.length;s++)for(let a=0;a<o.length;a++)i[s+a]^=e.mul(r[s],o[a]);return i},t.mod=function(r,o){let i=new Uint8Array(r);for(;i.length-o.length>=0;){const s=i[0];for(let l=0;l<o.length;l++)i[l]^=e.mul(o[l],s);let a=0;for(;a<i.length&&i[a]===0;)a++;i=i.slice(a)}return i},t.generateECPolynomial=function(r){let o=new Uint8Array([1]);for(let i=0;i<r;i++)o=t.mul(o,new Uint8Array([1,e.exp(i)]));return o}})(pt)),pt}var mt,hr;function Zi(){if(hr)return mt;hr=1;const t=Xi();function e(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return e.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},e.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(r.length+this.degree);o.set(r);const i=t.mod(o,this.genPoly),s=this.degree-i.length;if(s>0){const a=new Uint8Array(this.degree);return a.set(i,s),a}return i},mt=e,mt}var gt={},ht={},yt={},yr;function rn(){return yr||(yr=1,yt.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),yt}var Q={},_r;function nn(){if(_r)return Q;_r=1;const t="[0-9]+",e="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r 24]))+`;Q.KANJI=new RegExp(n,"g"),Q.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Q.BYTE=new RegExp(r,"g"),Q.NUMERIC=new RegExp(t,"g"),Q.ALPHANUMERIC=new RegExp(e,"g");const o=new RegExp("^"+n+"$"),i=new RegExp("^"+t+"$"),s=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Q.testKanji=function(l){return o.test(l)},Q.testNumeric=function(l){return i.test(l)},Q.testAlphanumeric=function(l){return s.test(l)},Q}var Er;function fe(){return Er||(Er=1,(function(t){const e=rn(),n=nn();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(i,s){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!e.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?i.ccBits[0]:s<27?i.ccBits[1]:i.ccBits[2]},t.getBestModeForData=function(i){return n.testNumeric(i)?t.NUMERIC:n.testAlphanumeric(i)?t.ALPHANUMERIC:n.testKanji(i)?t.KANJI:t.BYTE},t.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},t.isValid=function(i){return i&&i.bit&&i.ccBits};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+o)}}t.from=function(i,s){if(t.isValid(i))return i;try{return r(i)}catch{return s}}})(ht)),ht}var wr;function es(){return wr||(wr=1,(function(t){const e=de(),n=tn(),r=Bt(),o=fe(),i=rn(),s=7973,a=e.getBCHDigit(s);function l(f,m,h){for(let g=1;g<=40;g++)if(m<=t.getCapacity(g,h,f))return g}function u(f,m){return o.getCharCountIndicator(f,m)+4}function d(f,m){let h=0;return f.forEach(function(g){const T=u(g.mode,m);h+=T+g.getBitsLength()}),h}function p(f,m){for(let h=1;h<=40;h++)if(d(f,h)<=t.getCapacity(h,m,o.MIXED))return h}t.from=function(m,h){return i.isValid(m)?parseInt(m,10):h},t.getCapacity=function(m,h,g){if(!i.isValid(m))throw new Error("Invalid QR Code version");typeof g>"u"&&(g=o.BYTE);const T=e.getSymbolTotalCodewords(m),R=n.getTotalCodewordsCount(m,h),D=(T-R)*8;if(g===o.MIXED)return D;const C=D-u(g,m);switch(g){case o.NUMERIC:return Math.floor(C/10*3);case o.ALPHANUMERIC:return Math.floor(C/11*2);case o.KANJI:return Math.floor(C/13);case o.BYTE:default:return Math.floor(C/8)}},t.getBestVersionForData=function(m,h){let g;const T=r.from(h,r.M);if(Array.isArray(m)){if(m.length>1)return p(m,T);if(m.length===0)return 1;g=m[0]}else g=m;return l(g.mode,g.getLength(),T)},t.getEncodedBits=function(m){if(!i.isValid(m)||m<7)throw new Error("Invalid QR Code version");let h=m<<12;for(;e.getBCHDigit(h)-a>=0;)h^=s<<e.getBCHDigit(h)-a;return m<<12|h}})(gt)),gt}var _t={},Sr;function ts(){if(Sr)return _t;Sr=1;const t=de(),e=1335,n=21522,r=t.getBCHDigit(e);return _t.getEncodedBits=function(i,s){const a=i.bit<<3|s;let l=a<<10;for(;t.getBCHDigit(l)-r>=0;)l^=e<<t.getBCHDigit(l)-r;return(a<<10|l)^n},_t}var Et={},wt,Tr;function rs(){if(Tr)return wt;Tr=1;const t=fe();function e(n){this.mode=t.NUMERIC,this.data=n.toString()}return e.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(r){let o,i,s;for(o=0;o+3<=this.data.length;o+=3)i=this.data.substr(o,3),s=parseInt(i,10),r.put(s,10);const a=this.data.length-o;a>0&&(i=this.data.substr(o),s=parseInt(i,10),r.put(s,a*3+1))},wt=e,wt}var St,br;function ns(){if(br)return St;br=1;const t=fe(),e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(r){this.mode=t.ALPHANUMERIC,this.data=r}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let i;for(i=0;i+2<=this.data.length;i+=2){let s=e.indexOf(this.data[i])*45;s+=e.indexOf(this.data[i+1]),o.put(s,11)}this.data.length%2&&o.put(e.indexOf(this.data[i]),6)},St=n,St}var Tt,Cr;function os(){if(Cr)return Tt;Cr=1;const t=fe();function e(n){this.mode=t.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return e.getBitsLength=function(r){return r*8},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(n){for(let r=0,o=this.data.length;r<o;r++)n.put(this.data[r],8)},Tt=e,Tt}var bt,Ar;function is(){if(Ar)return bt;Ar=1;const t=fe(),e=de();function n(r){this.mode=t.KANJI,this.data=r}return n.getBitsLength=function(o){return o*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let o;for(o=0;o<this.data.length;o++){let i=e.toSJIS(this.data[o]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+` 25Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},bt=n,bt}var Ct={exports:{}},Rr;function ss(){return Rr||(Rr=1,(function(t){var e={single_source_shortest_paths:function(n,r,o){var i={},s={};s[r]=0;var a=e.PriorityQueue.make();a.push(r,0);for(var l,u,d,p,f,m,h,g,T;!a.empty();){l=a.pop(),u=l.value,p=l.cost,f=n[u]||{};for(d in f)f.hasOwnProperty(d)&&(m=f[d],h=p+m,g=s[d],T=typeof s[d]>"u",(T||g>h)&&(s[d]=h,a.push(d,h),i[d]=u))}if(typeof o<"u"&&typeof s[o]>"u"){var R=["Could not find a path from ",r," to ",o,"."].join("");throw new Error(R)}return i},extract_shortest_path_from_predecessor_list:function(n,r){for(var o=[],i=r;i;)o.push(i),n[i],i=n[i];return o.reverse(),o},find_path:function(n,r,o){var i=e.single_source_shortest_paths(n,r,o);return e.extract_shortest_path_from_predecessor_list(i,o)},PriorityQueue:{make:function(n){var r=e.PriorityQueue,o={},i;n=n||{};for(i in r)r.hasOwnProperty(i)&&(o[i]=r[i]);return o.queue=[],o.sorter=n.sorter||r.default_sorter,o},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var o={value:n,cost:r};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=e})(Ct)),Ct.exports}var Pr;function as(){return Pr||(Pr=1,(function(t){const e=fe(),n=rs(),r=ns(),o=os(),i=is(),s=nn(),a=de(),l=ss();function u(R){return unescape(encodeURIComponent(R)).length}function d(R,D,C){const k=[];let U;for(;(U=R.exec(C))!==null;)k.push({data:U[0],index:U.index,mode:D,length:U[0].length});return k}function p(R){const D=d(s.NUMERIC,e.NUMERIC,R),C=d(s.ALPHANUMERIC,e.ALPHANUMERIC,R);let k,U;return a.isKanjiModeEnabled()?(k=d(s.BYTE,e.BYTE,R),U=d(s.KANJI,e.KANJI,R)):(k=d(s.BYTE_KANJI,e.BYTE,R),U=[]),D.concat(C,k,U).sort(function(P,A){return P.index-A.index}).map(function(P){return{data:P.data,mode:P.mode,length:P.length}})}function f(R,D){switch(D){case e.NUMERIC:return n.getBitsLength(R);case e.ALPHANUMERIC:return r.getBitsLength(R);case e.KANJI:return i.getBitsLength(R);case e.BYTE:return o.getBitsLength(R)}}function m(R){return R.reduce(function(D,C){const k=D.length-1>=0?D[D.length-1]:null;return k&&k.mode===C.mode?(D[D.length-1].data+=C.data,D):(D.push(C),D)},[])}function h(R){const D=[];for(let C=0;C<R.length;C++){const k=R[C];switch(k.mode){case e.NUMERIC:D.push([k,{data:k.data,mode:e.ALPHANUMERIC,length:k.length},{data:k.data,mode:e.BYTE,length:k.length}]);break;case e.ALPHANUMERIC:D.push([k,{data:k.data,mode:e.BYTE,length:k.length}]);break;case e.KANJI:D.push([k,{data:k.data,mode:e.BYTE,length:u(k.data)}]);break;case e.BYTE:D.push([{data:k.data,mode:e.BYTE,length:u(k.data)}])}}return D}function g(R,D){const C={},k={start:{}};let U=["start"];for(let S=0;S<R.length;S++){const P=R[S],A=[];for(let w=0;w<P.length;w++){const I=P[w],_=""+S+w;A.push(_),C[_]={node:I,lastCount:0},k[_]={};for(let b=0;b<U.length;b++){const E=U[b];C[E]&&C[E].node.mode===I.mode?(k[E][_]=f(C[E].lastCount+I.length,I.mode)-f(C[E].lastCount,I.mode),C[E].lastCount+=I.length):(C[E]&&(C[E].lastCount=I.length),k[E][_]=f(I.length,I.mode)+4+e.getCharCountIndicator(I.mode,D))}}U=A}for(let S=0;S<U.length;S++)k[U[S]].end=0;return{map:k,table:C}}function T(R,D){let C;const k=e.getBestModeForData(R);if(C=e.from(D,k),C!==e.BYTE&&C.bit<k.bit)throw new Error('"'+R+'" cannot be encoded with mode '+e.toString(C)+`. 26 Suggested mode is: `+e.toString(k));switch(C===e.KANJI&&!a.isKanjiModeEnabled()&&(C=e.BYTE),C){case e.NUMERIC:return new n(R);case e.ALPHANUMERIC:return new r(R);case e.KANJI:return new i(R);case e.BYTE:return new o(R)}}t.fromArray=function(D){return D.reduce(function(C,k){return typeof k=="string"?C.push(T(k,null)):k.data&&C.push(T(k.data,k.mode)),C},[])},t.fromString=function(D,C){const k=p(D,a.isKanjiModeEnabled()),U=h(k),S=g(U,C),P=l.find_path(S.map,"start","end"),A=[];for(let w=1;w<P.length-1;w++)A.push(S.table[P[w]].node);return t.fromArray(m(A))},t.rawSplit=function(D){return t.fromArray(p(D,a.isKanjiModeEnabled()))}})(Et)),Et}var Ir;function ls(){if(Ir)return st;Ir=1;const t=de(),e=Bt(),n=Hi(),r=qi(),o=Wi(),i=Yi(),s=Ji(),a=tn(),l=Zi(),u=es(),d=ts(),p=fe(),f=as();function m(S,P){const A=S.size,w=i.getPositions(P);for(let I=0;I<w.length;I++){const _=w[I][0],b=w[I][1];for(let E=-1;E<=7;E++)if(!(_+E<=-1||A<=_+E))for(let x=-1;x<=7;x++)b+x<=-1||A<=b+x||(E>=0&&E<=6&&(x===0||x===6)||x>=0&&x<=6&&(E===0||E===6)||E>=2&&E<=4&&x>=2&&x<=4?S.set(_+E,b+x,!0,!0):S.set(_+E,b+x,!1,!0))}}function h(S){const P=S.size;for(let A=8;A<P-8;A++){const w=A%2===0;S.set(A,6,w,!0),S.set(6,A,w,!0)}}function g(S,P){const A=o.getPositions(P);for(let w=0;w<A.length;w++){const I=A[w][0],_=A[w][1];for(let b=-2;b<=2;b++)for(let E=-2;E<=2;E++)b===-2||b===2||E===-2||E===2||b===0&&E===0?S.set(I+b,_+E,!0,!0):S.set(I+b,_+E,!1,!0)}}function T(S,P){const A=S.size,w=u.getEncodedBits(P);let I,_,b;for(let E=0;E<18;E++)I=Math.floor(E/3),_=E%3+A-8-3,b=(w>>E&1)===1,S.set(I,_,b,!0),S.set(_,I,b,!0)}function R(S,P,A){const w=S.size,I=d.getEncodedBits(P,A);let _,b;for(_=0;_<15;_++)b=(I>>_&1)===1,_<6?S.set(_,8,b,!0):_<8?S.set(_+1,8,b,!0):S.set(w-15+_,8,b,!0),_<8?S.set(8,w-_-1,b,!0):_<9?S.set(8,15-_-1+1,b,!0):S.set(8,15-_-1,b,!0);S.set(w-8,8,1,!0)}function D(S,P){const A=S.size;let w=-1,I=A-1,_=7,b=0;for(let E=A-1;E>0;E-=2)for(E===6&&E--;;){for(let x=0;x<2;x++)if(!S.isReserved(I,E-x)){let G=!1;b<P.length&&(G=(P[b]>>>_&1)===1),S.set(I,E-x,G),_--,_===-1&&(b++,_=7)}if(I+=w,I<0||A<=I){I-=w,w=-w;break}}}function C(S,P,A){const w=new n;A.forEach(function(x){w.put(x.mode.bit,4),w.put(x.getLength(),p.getCharCountIndicator(x.mode,S)),x.write(w)});const I=t.getSymbolTotalCodewords(S),_=a.getTotalCodewordsCount(S,P),b=(I-_)*8;for(w.getLengthInBits()+4<=b&&w.put(0,4);w.getLengthInBits()%8!==0;)w.putBit(0);const E=(b-w.getLengthInBits())/8;for(let x=0;x<E;x++)w.put(x%2?17:236,8);return k(w,S,P)}function k(S,P,A){const w=t.getSymbolTotalCodewords(P),I=a.getTotalCodewordsCount(P,A),_=w-I,b=a.getBlocksCount(P,A),E=w%b,x=b-E,G=Math.floor(w/b),K=Math.floor(_/b),Ee=K+1,Ie=G-K,Ge=new l(Ie);let we=0;const ae=new Array(b),j=new Array(b);let pe=0;const He=new Uint8Array(S.buffer);for(let $=0;$<b;$++){const V=$<x?K:Ee;ae[$]=He.slice(we,we+V),j[$]=Ge.encode(ae[$]),we+=V,pe=Math.max(pe,V)}const Se=new Uint8Array(w);let De=0,H,q;for(H=0;H<pe;H++)for(q=0;q<b;q++)H<ae[q].length&&(Se[De++]=ae[q][H]);for(H=0;H<Ie;H++)for(q=0;q<b;q++)Se[De++]=j[q][H];return Se}function U(S,P,A,w){let I;if(Array.isArray(S))I=f.fromArray(S);else if(typeof S=="string"){let G=P;if(!G){const K=f.rawSplit(S);G=u.getBestVersionForData(K,A)}I=f.fromString(S,G||40)}else throw new Error("Invalid data");const _=u.getBestVersionForData(I,A);if(!_)throw new Error("The amount of data is too big to be stored in a QR Code");if(!P)P=_;else if(P<_)throw new Error(` 27The chosen QR Code version cannot contain this amount of data. 28Minimum version required to store current data is: `+_+`. 29`);const b=C(P,A,I),E=t.getSymbolSize(P),x=new r(E);return m(x,P),h(x),g(x,P),R(x,A,0),P>=7&&T(x,P),D(x,b),isNaN(w)&&(w=s.getBestMask(x,R.bind(null,x,A))),s.applyMask(w,x),R(x,A,w),{modules:x,version:P,errorCorrectionLevel:A,maskPattern:w,segments:I}}return st.create=function(P,A){if(typeof P>"u"||P==="")throw new Error("No input text");let w=e.M,I,_;return typeof A<"u"&&(w=e.from(A.errorCorrectionLevel,e.M),I=u.from(A.version),_=s.from(A.maskPattern),A.toSJISFunc&&t.setToSJISFunction(A.toSJISFunc)),U(P,I,w,_)},st}var At={},Rt={},Dr;function on(){return Dr||(Dr=1,(function(t){function e(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="str
29ing")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(i){return[i,i]}))),r.length===6&&r.push("F","F");const o=parseInt(r.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const o=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,i=r.width&&r.width>=21?r.width:void 0,s=r.scale||4;return{width:i,scale:i?4:s,margin:o,color:{dark:e(r.color.dark||"#000000ff"),light:e(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,o){return o.width&&o.width>=r+o.margin*2?o.width/(r+o.margin*2):o.scale},t.getImageWidth=function(r,o){const i=t.getScale(r,o);return Math.floor((r+o.margin*2)*i)},t.qrToImageData=function(r,o,i){const s=o.modules.size,a=o.modules.data,l=t.getScale(s,i),u=Math.floor((s+i.margin*2)*l),d=i.margin*l,p=[i.color.light,i.color.dark];for(let f=0;f<u;f++)for(let m=0;m<u;m++){let h=(f*u+m)*4,g=i.color.light;if(f>=d&&m>=d&&f<u-d&&m<u-d){const T=Math.floor((f-d)/l),R=Math.floor((m-d)/l);g=p[a[T*s+R]?1:0]}r[h++]=g.r,r[h++]=g.g,r[h++]=g.b,r[h]=g.a}}})(Rt)),Rt}var kr;function cs(){return kr||(kr=1,(function(t){const e=on();function n(o,i,s){o.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=s,i.width=s,i.style.height=s+"px",i.style.width=s+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(i,s,a){let l=a,u=s;typeof l>"u"&&(!s||!s.getContext)&&(l=s,s=void 0),s||(u=r()),l=e.getOptions(l);const d=e.getImageWidth(i.modules.size,l),p=u.getContext("2d"),f=p.createImageData(d,d);return e.qrToImageData(f.data,i,l),n(p,u,d),p.putImageData(f,0,0),u},t.renderToDataURL=function(i,s,a){let l=a;typeof l>"u"&&(!s||!s.getContext)&&(l=s,s=void 0),l||(l={});const u=t.render(i,s,l),d=l.type||"image/png",p=l.rendererOpts||{};return u.toDataURL(d,p.quality)}})(At)),At}var Pt={},vr;function us(){if(vr)return Pt;vr=1;const t=on();function e(o,i){const s=o.a/255,a=i+'="'+o.hex+'"';return s<1?a+" "+i+'-opacity="'+s.toFixed(2).slice(1)+'"':a}function n(o,i,s){let a=o+i;return typeof s<"u"&&(a+=" "+s),a}function r(o,i,s){let a="",l=0,u=!1,d=0;for(let p=0;p<o.length;p++){const f=Math.floor(p%i),m=Math.floor(p/i);!f&&!u&&(u=!0),o[p]?(d++,p>0&&f>0&&o[p-1]||(a+=u?n("M",f+s,.5+m+s):n("m",l,0),l=0,u=!1),f+1<i&&o[p+1]||(a+=n("h",d),d=0)):l++}return a}return Pt.render=function(i,s,a){const l=t.getOptions(s),u=i.modules.size,d=i.modules.data,p=u+l.margin*2,f=l.color.light.a?"<path "+e(l.color.light,"fill")+' d="M0 0h'+p+"v"+p+'H0z"/>':"",m="<path "+e(l.color.dark,"stroke")+' d="'+r(d,u,l.margin)+'"/>',h='viewBox="0 0 '+p+" "+p+'"',T='<svg xmlns="http://www.w3.org/2000/svg" '+(l.width?'width="'+l.width+'" height="'+l.width+'" ':"")+h+' shape-rendering="crispEdges">'+f+m+`</svg> 30`;return typeof a=="function"&&a(null,T),T},Pt}var xr;function ds(){if(xr)return ge;xr=1;const t=Gi(),e=ls(),n=cs(),r=us();function o(i,s,a,l,u){const d=[].slice.call(arguments,1),p=d.length,f=typeof d[p-1]=="function";if(!f&&!t())throw new Error("Callback required as last argument");if(f){if(p<2)throw new Error("Too few arguments provided");p===2?(u=a,a=s,s=l=void 0):p===3&&(s.getContext&&typeof u>"u"?(u=l,l=void 0):(u=l,l=a,a=s,s=void 0))}else{if(p<1)throw new Error("Too few arguments provided");return p===1?(a=s,s=l=void 0):p===2&&!s.getContext&&(l=a,a=s,s=void 0),new Promise(function(m,h){try{const g=e.create(a,l);m(i(g,s,l))}catch(g){h(g)}})}try{const m=e.create(a,l);u(null,i(m,s,l))}catch(m){u(m)}}return ge.create=e.create,ge.toCanvas=o.bind(null,n.render),ge.toDataURL=o.bind(null,n.renderToDataURL),ge.toString=o.bind(null,function(i,s,a){return r.render(i,a)}),ge}var fs=ds();const ps=_n(fs),sn="/app",ms={text_extract:"Text extract",metadata_xmp:"Metadata / XMP",annotations:"Annotations",raw_bytes:"Raw bytes",error:"Verify engine"};function gs(t){return t==="pass"||t==="fail"||t==="skip"||t==="error"?t:"error"}function Ls(t,e){const n=t.checks.map(r=>{const o=r.indexOf(":"),i=o>=0?r.slice(0,o):r,s=o>=0?r.slice(o+1):"error";return{id:i,result:gs(s),label:ms[i]??i}});return{runId:e,passed:t.passed,checks:n,certificateJson:t.certificateJson,updatedAt:Date.now()}}function Os(t,e,n="studio.edit.redact"){const r=e.checks.filter(o=>o.result==="fail"||o.result==="error").length;t.track({type:"REDACT_VERIFY_RUN",runId:e.runId,toolId:n,passed:e.passed,checkCount:e.checks.length,failCount:r});for(const o of e.checks)(o.result==="fail"||o.result==="error")&&t.track({type:"REDACT_VERIFY_FAIL",runId:e.runId,toolId:n,checkId:o.id,message:`${o.label}: ${o.result}`})}function hs(t,e){const n=e.replace(/\.pdf$/i,"").replace(/[<>:"/\\|?*]/g,"_").slice(0,64)||"document",r=new Blob([t],{type:"application/json"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`${n}-localpdf-certificate.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function Ns(t,e){return!t||!e.passed||t.passed&&e.updatedAt>=t.updatedAt?e:t}const Lr="localpdf_device_id";function ys(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function _s(){const t=ys();if(!t)return"unknown-device";const e=t.getItem(Lr);if(e&&e.trim())return e.trim();const n=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`dev-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;try{t.setItem(Lr,n)}catch{}return n}function Es(t){const e=/Edg\//.test(t)?"Edge":/OPR\//.test(t)?"Opera":/Chrome\//.test(t)?"Chrome":/Firefox\//.test(t)?"Firefox":/Safari\//.test(t)?"Safari":"Browser",n=/Android/.test(t)?"Android":/iPhone|iPad|iPod/.test(t)?"iOS":/Mac OS X|Macintosh/.test(t)?"macOS":/Windows/.test(t)?"Windows":/Linux/.test(t)?"Linux":"Unknown OS";return{browser:e,platform:n}}function ws(){const t=typeof navigator>"u"?"":navigator.userAgent,{browser:e,platform:n}=Es(t);return`LocalPDF · ${e} on ${n} · ${_s().slice(0,6)}`}function Ss(t,e=22){if(t.length<=e)return t;const n=t.lastIndexOf(".");return n>0&&t.length-n<=5?t.slice(0,e-3-(t.length-n))+"â¦"+t.slice(n):t.slice(0,e-1)+"â¦"}function Ts(t){if(t.length===0)return null;const e=t[0].fileId;for(let n=0;n<t.length;n+=1){const r=t[n];if(r.fileId!==e||r.rotation%360!==0||r.pageIndex!==n)return null}return{fileId:e}}function bs({telemetryEnabled:t,onToggleTelemetry:e,telemetryOpen:n}){const{runtime:r}=$e(),[o,i]=v.useState(!1),[s,a]=v.useState(""),[l,u]=v.useState(null),[d,p]=v.useState(!1),[f,m]=v.useState(""),[h,g]=v.useState("idle"),[T,R]=v.useState([]),[D,C]=v.useState({usage:null,limit:null}),[k,U]=v.useState(""),[S,P]=v.useState(""),[A,w]=v.useState(()=>r.billing.getContext()),[I,_]=v.useState(()=>r.billing.isLocalProEnabled()),b=r.billing.isLocalProAvailable();v.useEffect(()=>r.billing.subscribe(y=>{w(y),_(r.billing.isLocalProEnabled())}),[r.billing]);const E=async(y={})=>{const O=y.token??r.billing.getStoredToken(),M=y.licenseKey??"";if(!(!O&&!M))try{const B=await(await fetch("/api/billing/devices",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:O||void 0,licenseKey:M||void 0,action:"list"})})).json();B!=null&&B.success&&(R(Array.isArray(B.devices)?B.devices:[]),C({usage:B.usage??null,limit:B.limit??null}))}catch{}},x=async y=>{const O=r.billing.getStoredToken(),M=O?"":S;if(!(!O&&!M||!y)){U(y);try{const B=await(await fetch("/api/billing/devices",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:O||void 0,licenseKey:M||void 0,action:"deactivate",instanceId:y})})).json();if(B!=null&&B.success){if(Y("billing_device_deactivated",{source:"activate_modal",status:B.wasCurrentDevice?"current_device":"other_device"}),B.wasCurrentDevice){r.billing.clearToken(),R([]),p(!1),g("idle");return}await E({token:O,licenseKey:M||void 0}),g("idle")}}catch{g("error")}finally{U("")}}},G=async()=>{const y=f.trim();if(!y)return;g("loading");const O=y.includes("-")||!y.includes(".");let M;if(O)try{const z=await(await fetch("/api/billing/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({licenseKey:y,instanceName:ws()})})).json();if(z.success)M=z.token;else{if((z==null?void 0:z.error)==="activation_limit_reached"){C({usage:z.usage??null,limit:z.limit??null}),P(y),g("limit"),Y("billing_device_limit_reached",{source:"activate_modal",reason:"activation_limit_reached"}),E({licenseKey:y});return}g("error");return}}catch{{g("error");return}}else M=y;await r.billing.saveToken(M)?(p(!1),m(""),g("idle"),Y("billing_device_activated",{source:"activate_modal",plan:"pro",status:"registered"}),E()):g("error")},K=ie(y=>y.documents),Ee=ie(y=>y.activeDocumentId),Ie=ie(y=>y.setActiveDocument),Ge=ie(y=>y.removeDocument),we=ie(y=>y.addDocument),ae=ie(y=>y.markWorkspaceExported),j=v.useMemo(()=>K.find(y=>y.id===Ee)??null,[Ee,K]),pe=((j==null?void 0:j.pages.length)??0)>0,He="/",Se=async(y,O)=>{const M=Ts(y.pages);if(M){const We=await(await r.vfs.read(M.fileId)).getBlob(),xe=URL.createObjectURL(We),le=document.createElement("a");le.href=xe,le.download=O,document.body.appendChild(le),le.click(),document.body.removeChild(le),URL.revokeObjectURL(xe),ae();return}const Z=y.pages.map(ee=>({sourceFileId:ee.fileId,pageIndex:ee.pageIndex,rotation:ee.rotation}));if(Z.length===0)return;const B={inputs:Array.from(new Set(Z.map(ee=>ee.sourceFileId))),operations:[{type:"reorder",sequence:Z}],outputName:O},ke=await new or(r.vfs).execute(B),qe=new ArrayBuffer(ke.buffer.byteLength);new Uint8Array(qe).set(ke.buffer);const ve=new Blob([qe],{type:"application/pdf"}),Te=URL.createObjectURL(ve),re=document.createElement("a");re.href=Te,re.download=O,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(Te),ae()},De=()=>{if(!j||j.pages.length===0)return;u(j.id),a(j.name),i(!0);const y=j.lastRedactVerify,O=A.entitlements.includes("pdf.redact.verify");if(y!=null&&y.passed&&y.certificateJson&&!O){const M=y.runId||crypto.randomUUID();r.telemetry.track({type:"REDACT_CERT_PAYWALL",runId:M,toolId:"studio.edit.redact",action:"shown"}),Kr({source:"redact_certificate",toolId:"studio.edit.redact",trigger:"cert_download",userState:"local",hadPriorSuccessfulRun:!0,flowId:M})}},H=async(y,O)=>{var Kt;
30const M=l?K.find(W=>W.id===l)??null:j;if(!M||M.pages.length===0)throw new Error("No pages in workspace to share.");const B=(y.trim()||M.name).replace(/[<>:"/\\|?*]/g,"_").slice(0,64)||"Workspace";O("Compiling PDF document...");const z=M.pages.map(W=>({sourceFileId:W.fileId,pageIndex:W.pageIndex,rotation:W.rotation})),ke={inputs:Array.from(new Set(z.map(W=>W.sourceFileId))),operations:[{type:"reorder",sequence:z}],outputName:`${B}.pdf`},ve=await new or(r.vfs).execute(ke),Te=new ArrayBuffer(ve.buffer.byteLength);new Uint8Array(Te).set(ve.buffer),O("Encrypting document locally...");const re=await window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),ee=window.crypto.getRandomValues(new Uint8Array(12)),We=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:ee},re,Te),xe=await window.crypto.subtle.exportKey("raw",re),le=Array.from(new Uint8Array(xe)).map(W=>W.toString(16).padStart(2,"0")).join(""),dn=Array.from(ee).map(W=>W.toString(16).padStart(2,"0")).join("");O("Uploading encrypted payload...");const fn=new Blob([We],{type:"application/octet-stream"}),Ft=new FormData;Ft.append("file",fn,"secured_workspace.pdf");const Ye=await fetch("https://tmpfiles.org/api/v1/upload",{method:"POST",body:Ft});if(!Ye.ok)throw new Error(`Upload server responded with code ${Ye.status}`);const Je=await Ye.json();if(Je.status!=="success"||!((Kt=Je.data)!=null&&Kt.url))throw new Error("Upload failed to return a valid sharing URL");const pn=Je.data.url.replace("https://tmpfiles.org/","https://tmpfiles.org/dl/"),jt=`${`${window.location.origin}${sn}/share`}#url=${encodeURIComponent(pn)}&key=${le}&iv=${dn}`;O("Generating QR code...");const mn=await ps.toDataURL(jt,{width:200,margin:1,color:{dark:"#142028",light:"#ffffff"}});return r.telemetry.track({type:"OUTPUT_DOWNLOADED",flowId:vt(),toolId:"studio-share",outputCount:1,surface:"studio"}),{qrCodeUrl:mn,shareLink:jt}},q=async y=>{const O=l?K.find(B=>B.id===l)??null:j;if(!O||O.pages.length===0)return;const Z=(y.trim()||O.name).replace(/[<>:"/\\|?*]/g,"_").slice(0,64)||"Workspace";if(ti(r.telemetry,A.plan,"downloaded",1))try{await Se(O,`${Z}.pdf`),r.telemetry.track({type:"OUTPUT_DOWNLOADED",flowId:vt(),toolId:"studio",outputCount:1,surface:"studio"})}catch(B){const z=B instanceof Error?B.message:"Export failed";console.error(z)}finally{i(!1),u(null)}},$=v.useMemo(()=>l?K.find(y=>y.id===l)??null:j,[j,K,l]),V=($==null?void 0:$.lastRedactVerify)??null,ln=A.entitlements.includes("pdf.redact.verify"),cn=()=>{!(V!=null&&V.certificateJson)||!$||(hs(V.certificateJson,$.name),r.telemetry.track({type:"REDACT_CERT_DOWNLOAD",runId:V.runId||crypto.randomUUID(),toolId:"studio.edit.redact"}))},un=()=>{const y=(V==null?void 0:V.runId)||crypto.randomUUID();r.telemetry.track({type:"REDACT_CERT_PAYWALL",runId:y,toolId:"studio.edit.redact",action:"cta_clicked"}),Y("paywall_cta_clicked",{source:"redact_certificate",toolId:"studio.edit.redact",trigger:"cert_download",userState:"local",hadPriorSuccessfulRun:!0,flowId:y});const O=Ke();O&&Qr(O.url,{source:"redact_certificate",trigger:"cert_download",variant:O.variant,flowId:y})};return c.jsxs("div",{className:"studio-top-nav-container",children:[c.jsx($i,{}),c.jsxs("header",{className:"studio-top-nav","aria-label":"Studio top navigation",children:[c.jsxs("a",{href:He,className:"studio-logo",style:{flexShrink:0},children:[c.jsx("div",{className:"studio-nav-logo-icon",children:"L"}),c.jsx("span",{className:"studio-logo-title",children:"LocalPDF"})]}),c.jsx("span",{className:"studio-nav-sep",children:"/"}),c.jsxs("div",{className:"studio-nav-tabs",role:"tablist","aria-label":"Open workspaces",children:[K.map(y=>{const O=y.id===Ee;return c.jsxs("div",{role:"tab","aria-selected":O,className:`studio-nav-tab${O?" active":""}`,onClick:()=>{Ie(y.id)},title:y.name,children:[c.jsx("span",{className:`studio-nav-tab-dot${y.isModified?"":" saved"}`}),c.jsx("span",{className:"studio-nav-tab-name",children:Ss(y.name)}),c.jsx("span",{className:"studio-nav-tab-close","aria-label":"Close workspace",onClick:M=>{M.stopPropagation(),Ge(y.id)},children:"â"})]},y.id)}
30),c.jsx("div",{className:"studio-nav-tab-add",title:"New workspace",onClick:()=>{const y=crypto.randomUUID();we({id:y,name:`Workspace ${K.length+1}`,x:100,y:100,pages:[],allowEmpty:!0,includeInExport:!0,isModified:!0})},children:"+"})]}),c.jsxs("div",{className:"studio-nav-actions",children:[c.jsxs("button",{type:"button",className:"studio-nav-btn",onClick:De,disabled:!pe,title:pe?"Download active workspace":"No pages in active workspace",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),c.jsx("polyline",{points:"7 10 12 15 17 10"}),c.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),c.jsx("span",{className:"studio-nav-btn-label",children:"Download"})]}),b&&c.jsx("button",{type:"button",className:`studio-dev-pro-btn${I?" studio-dev-pro-btn--on":""}`,"aria-pressed":I,title:I?"Developer Pro is ON â this is not a purchase. Click to switch back to Free.":"Enable Developer Pro (dev builds only) to test Pro features",onClick:()=>{_(r.billing.setLocalPro(!I))},children:I?"DEV PRO":"DEV"}),A.plan==="pro"&&!F().isActive?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"studio-badge-pro",children:"PRO"}),c.jsx("button",{type:"button",className:"studio-activate-btn",onClick:()=>{p(!0),E()},title:"Devices activated with this license",children:c.jsx("span",{className:"studio-nav-btn-label",children:"Devices"})})]}):F().isActive?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"studio-badge-trial",children:"TRIAL"}),c.jsx("button",{type:"button",className:"studio-activate-btn",onClick:()=>{p(!0)},title:"Enter license key after purchase",children:c.jsx("span",{className:"studio-nav-btn-label",children:"Activate"})}),c.jsx("button",{type:"button",className:"studio-upgrade-btn",onClick:()=>{er()},children:c.jsx("span",{className:"studio-nav-btn-label",children:"Upgrade"})})]}):c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"studio-activate-btn",onClick:()=>{p(!0)},title:"Enter license key after purchase",children:c.jsx("span",{className:"studio-nav-btn-label",children:"Activate"})}),c.jsx("button",{type:"button",className:"studio-upgrade-btn",onClick:()=>{er()},children:c.jsx("span",{className:"studio-nav-btn-label",children:"Upgrade"})})]}),d&&c.jsx("div",{className:"studio-activate-overlay",role:"presentation",onClick:()=>{p(!1),g("idle")},children:c.jsxs("div",{className:"studio-activate-modal",role:"dialog","aria-modal":"true","aria-label":"Activate license",onClick:y=>y.stopPropagation(),children:[c.jsx("h3",{className:"studio-activate-title",children:"Activate Pro license"}),c.jsx("p",{className:"studio-activate-sub",children:"Paste the license key from your purchase email."}),c.jsx("input",{className:"studio-activate-input",type:"text",placeholder:"eyJ...",value:f,onChange:y=>{m(y.target.value),g("idle")},onKeyDown:y=>{y.key==="Enter"&&G()},autoFocus:!0,spellCheck:!1}),h==="error"&&c.jsx("p",{className:"studio-activate-error",children:"Invalid or expired license key. Check your email and try again."}),h==="limit"&&c.jsxs("p",{className:"studio-activate-error",children:["All ",D.limit??3," device slots for this license are in use. Deactivate one below to free a slot."]}),T.length>0&&c.jsxs("div",{className:"studio-device-list",children:[c.jsxs("p",{className:"studio-device-title",children:["Devices",D.usage!=null&&D.limit!=null?` (${D.usage} of ${D.limit})`:""]}),T.map(y=>c.jsxs("div",{className:"studio-device-row",children:[c.jsx("span",{className:"studio-device-name",children:y.name}),c.jsx("button",{type:"button",className:"studio-device-deactivate",disabled:k===y.id,onClick:()=>{x(y.id)},children:k===y.id?"â¦":"Deactivate"})]},y.id))]}),c.jsxs("div",{className:"studio-activate-actions",children:[c.jsx("button",{type:"button",className:"studio-activate-btn-ghost",onClick:()=>{p(!1),g("idle")},children:"Cancel"}),c.jsx("button",{type:"button",className:"studio-activate-btn-primary",disabled:!f.trim()||h==="loading",onClick:()=>{G()},children:h==="loading"?"Verifyingâ¦":"Activate"})]})]})})]}),c.jsx(Vi,{isOpen:o,fileName:s,redactVerify:V,canDownloadCertificate:ln,onDownloadCertificate:cn,onCertificatePaywall:un,onClose:()=>{i(!1),u(null)},onDownload:y=>{q(y)},onShare:H})]})]})}function Cs(){const{pathname:t,search:e}=wn();return v.useEffect(()=>{window.posthog&&window.posthog.capture("$pageview")},[t,e]),null}function As(){const[t,e]=v.useState(!1),n=new URLSearchParams(window.location.search).get("debug")==="1";return c.jsxs(En,{basename:sn,future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:[c.jsx(Cs,{}),c.jsxs(si,{children:[c.jsx(Li,{}),c.jsxs("div",{className:"studio-app-layout",children:[c.jsx(bs,{telemetryEnabled:n,telemetryOpen:t,onToggleTelemetry:()=>e(r=>!r)}),n&&t&&c.jsx("section",{className:"studio-telemetry-panel","aria-label":"Telemetry panel",children:c.jsx(Ui,{})}),c.jsx("main",{className:"studio-main-shell",children:c.jsx(gi,{})})]})]})]})}function Rs(){return c.jsx(As,{})}Dn();const an=document.getElementById("root");
30if(!an)throw new Error("Missing #root element");Sn.createRoot(an).render(c.jsx(v.StrictMode,{children:c.jsx(Rs,{})}));export{sn as A,or as P,ps as Q,L as _,ie as a,Ke as b,vs as c,Y as d,ot as e,se as f,vt as g,ti as h,Kr as i,Mt as j,Fe as k,zt as l,Ns as m,Qr as o,Ls as p,xs as r,Hr as s,Os as t,$e as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.