1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/StudioEditWorkspace-CDw6sP0i.js","assets/vendor-react-C_xdI0Ng.js","assets/StudioDialog-Bz_0GjSD.js","assets/linear-icon-BS_Bu1OG.js","assets/vendor-icons-CmfhFn4k.js","assets/infer-source-text-style-CB_Q6F8k.js","assets/index-BLFiW9lJ.js","assets/index-Ce2rXghS.css","assets/protect-errors-CmaV3kPR.js","assets/preview-service-CXJMbUqg.js","assets/history-store-CgRrFfE0.js","assets/feature-flag-QAeryYXU.js","assets/StudioConvertWorkspace-Cm16-rys.js","assets/studio-paywall-QasKfe8-.js","assets/AutoTocStudioPanel-BIqpsFXe.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/PdfInfoStudioPanel-DHnIMAV0.js","assets/pdf-info-client-CO7HLkbQ.js"])))=>i.map(i=>d[i]); 2var qt=Object.defineProperty;var Jt=(t,n,s)=>n in t?qt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var Qe=(t,n,s)=>Jt(t,typeof n!="symbol"?n+"":n,s);import{u as it,b as g,p as Zt,t as Qt,c as eo,d as to,o as oo,g as no,_ as rt}from"./index-BLFiW9lJ.js";import{r as d,R as Be,j as e,k as _t,u as so,i as ao}from"./vendor-react-C_xdI0Ng.js";import{a as nt,g as io,i as Ct}from"./pdf-loader-XNuiZneC.js";import{u as Tt,G as Ce,R as ne,I as Mt,T as Oe,C as ro,S as lo,L as co}from"./vendor-konva-ZjxRZeak.js";import{s as me}from"./studio-paywall-QasKfe8-.js";import{u as Ee}from"./history-store-CgRrFfE0.js";import{L as je}from"./linear-icon-BS_Bu1OG.js";import{c as ut,g as uo,n as po,S as ho,a as go}from"./StudioDialog-Bz_0GjSD.js";import{d as fo}from"./preview-service-CXJMbUqg.js";import"./vendor-icons-CmfhFn4k.js";import"./infer-source-text-style-CB_Q6F8k.js";const mo={maxWorkspaces:3,maxPagesPerDocument:Number.POSITIVE_INFINITY},xo={maxWorkspaces:Number.POSITIVE_INFINITY,maxPagesPerDocument:Number.POSITIVE_INFINITY};function Rt(t){return Number.isFinite(t)?Math.max(0,Math.floor(t)):Number.POSITIVE_INFINITY}function At(t){return t==="pro"||t==="trial"?xo:mo}function gt(t,n){const s=At(t.plan),a=Rt(n);return Number.isFinite(s.maxWorkspaces)?a<s.maxWorkspaces?{allowed:!0,current:a,limit:s.maxWorkspaces}:{allowed:!1,reason:"workspace_limit",current:a,limit:s.maxWorkspaces}:{allowed:!0,current:a,limit:s.maxWorkspaces}}function Le(t,n){const s=At(t.plan),a=Rt(n);return Number.isFinite(s.maxPagesPerDocument)?a<=s.maxPagesPerDocument?{allowed:!0,current:a,limit:s.maxPagesPerDocument}:{allowed:!1,reason:"page_limit",current:a,limit:s.maxPagesPerDocument}:{allowed:!0,current:a,limit:s.maxPagesPerDocument}}function jt(t,n,s){const a=gt(t,n);return a.allowed?Le(t,s):a}const yo=16,Pe=[];function wo(){const t=document.createElement("canvas"),n=t.getContext("2d");return{canvas:t,ctx:n}}function bo(t,n){for(const i of Pe)if(!i.inUse&&i.width>=t&&i.height>=n)return i.inUse=!0,i.canvas.width=t,i.canvas.height=n,{canvas:i.canvas,ctx:i.ctx,width:t,height:n};for(const i of Pe)if(!i.inUse)return i.inUse=!0,i.width=t,i.height=n,i.canvas.width=t,i.canvas.height=n,{canvas:i.canvas,ctx:i.ctx,width:t,height:n};const{canvas:s,ctx:a}=wo();if(s.width=t,s.height=n,Pe.push({canvas:s,ctx:a,inUse:!0,width:t,height:n}),Pe.length>yo){const i=Pe.find(f=>!f.inUse);i&&Pe.splice(Pe.indexOf(i),1)}return{canvas:s,ctx:a,width:t,height:n}}function mt(t){for(const n of Pe)if(n.canvas===t){n.inUse=!1,n.ctx.clearRect(0,0,n.width,n.height);return}}const ot=new Set;let pt=!1,et=null;const vo=1500,Io=2500,Po=5e3;function Co(){if(typeof performance>"u"||!("memory"in performance))return null;const t=performance.memory;return t&&typeof t.usedJSHeapSize=="number"?t.usedJSHeapSize/(1024*1024):null}function jo(){const t=Co();if(t!==null&&(t>Io||t>vo))for(const n of ot)n()}function So(t){return ot.add(t),pt||(pt=!0,et=setInterval(jo,Po)),()=>{ot.delete(t),ot.size===0&&et&&(clearInterval(et),et=null,pt=!1)}}const Do=30,ko=10,ce=new Map;function No(t){const n=ce.get(t);return n&&(ce.delete(t),ce.set(t,n)),n}function Eo(t,n){if(ce.size>=Do){const s=ce.keys().next().value;if(s){const a=ce.get(s);a&&mt(a),ce.delete(s)}}ce.set(t,n)}function _o(t){for(;ce.size>t;){const n=ce.keys().next().value;if(!n)break;const s=ce.get(n);s&&mt(s),ce.delete(n)}}let St=null;function To(){St||(St=So(()=>{_o(ko),Ao()}))}const Mo=5,he=new Map;
2async function Ro(t,n){const s=he.get(t);if(s)return he.delete(t),he.set(t,s),s;const a=(async()=>{try{const i=await nt(),m=await(await(await n.vfs.read(t)).getBlob()).arrayBuffer();return await i.getDocument({data:new Uint8Array(m)}).promise}catch(i){throw he.delete(t),i}})();if(he.size>=Mo){const i=he.keys().next().value;if(i){const f=he.get(i);if(he.delete(i),f)try{await(await f).destroy()}catch(I){console.error("Failed to destroy cached pdf document:",I)}}}return he.set(t,a),a}async function Ao(){const t=Array.from(he.values());he.clear();for(const n of t)try{await(await n).destroy()}catch{}}const Fo=({page:t,docId:n,x:s,y:a,currentIndex:i,shouldPrefetchOnly:f=!1})=>{const I=d.useRef(null),{runtime:m}=it(),y=Ee(l=>l.createCheckpoint),[O]=Tt(t.thumbnailUrl),[u,k]=Be.useState(null),[v,V]=Be.useState(!1),L=g(l=>l.documents),Y=g(l=>l.gridColumns),E=g(l=>l.studioViewScale),M=g(l=>l.detachPage),J=g(l=>l.selection),h=g(l=>l.setSelection),R=g(l=>l.setActiveDocument),Z=J.some(l=>l.pageId===t.id),Q=g(l=>l.movePage),U=Be.useMemo(()=>f?2:Z?E>=1.35?3:2.5:E>=1.35?3:2,[Z,f,E]),P=l=>{l.cancelBubble=!0},$=l=>{l.cancelBubble=!0,l.target.moveToTop()},se=l=>{l.cancelBubble=!0;const _=l.target,N=_.getStage();if(!N)return;const H=N.getPointerPosition();if(!H)return;const A=N.getAbsoluteTransform().copy().invert(),T=A.point(H);let F=null,K=null;const de=200,ue=280,Se=20,_e=30,B=de+Se,G=ue+_e,De=N.scaleX()||1,Ue=_.absolutePosition(),Ye={x:Ue.x+100*De,y:Ue.y+140*De},z=N.find(".document");for(const te of z){const pe=te.id(),xe=L.find(qe=>qe.id===pe);if(!xe)continue;const ke=te.getAbsoluteTransform().copy().invert().point(Ye),Me=Math.min(xe.pages.length||1,Y),Re=Math.ceil(xe.pages.length/Me)||1,ve=Math.max(B,Me*B),Ke=Math.max(G,Re*G);if(ke.x>=-30&&ke.x<=ve+30&&ke.y>=-50&&ke.y<=Ke+50){F=pe,K=te;break}}const ee=L.find(te=>te.id===n);let ge=B,Te=G;if(ee){const te=Math.min(ee.pages.length||1,Y),pe=Math.ceil(ee.pages.length/te)||1;ge=Math.max(B,te*B),Te=Math.max(G,pe*G)}const Ve=((ee==null?void 0:ee.x)??0)-30,Xe=((ee==null?void 0:ee.x)??0)+ge+30,we=((ee==null?void 0:ee.y)??0)-50,be=((ee==null?void 0:ee.y)??0)+Te+50,$e=!ee||T.x<Ve||T.x>Xe||T.y<we||T.y>be;if(F&&K&&!(F===n&&$e)){const te=L.find(Re=>Re.id===F);if(te&&F!==n&&!Le(m.billing.getContext(),te.pages.length+1).allowed){me(m.telemetry,"Free supports documents up to 25 pages. Upgrade to Pro to keep adding pages.",void 0,{toolId:"studio",trigger:"page_limit_25"});return}const xe=K.getAbsoluteTransform().copy().invert().point(Ye),Ge=Math.max(0,Math.min(Y-1,Math.round(xe.x/B))),Me=Math.max(0,Math.round(xe.y/G))*Y+Ge;Q(n,t.id,F,Me),y(m.vfs,"move_page",F===n?"Moved page within workspace":"Moved page to another workspace")}else{const te=_.absolutePosition(),pe=A.point(te);M(n,t.id,pe.x,pe.y),y(m.vfs,"move_page","Detached page")}},j=l=>{var A,T;l.cancelBubble=!0,R(n);const _=g.getState().selection,N=l.evt.shiftKey||l.evt.altKey||((T=(A=l.evt).getModifierState)==null?void 0:T.call(A,"Alt")),H=_.some(F=>F.pageId===t.id);h(N?H?_.filter(F=>F.pageId!==t.id):[..._,{docId:n,pageId:t.id}]:[{docId:n,pageId:t.id}])};if(Be.useEffect(()=>{To();let l=!0;const _=`${t.fileId}_${t.pageIndex}_${U}`,N=No(_);if(N){k(N);return}const H=async()=>{if(v)return;V(!0);let T=null;try{const F=await Ro(t.fileId,m);if(!l)return;const K=await F.getPage(t.pageIndex+1),de=K.getViewport({scale:U});T=bo(de.width,de.height),await K.render({canvasContext:T.ctx,viewport:de,canvas:T.canvas}).promise,l&&(Eo(_,T.canvas),k(T.canvas))}catch(F){console.error("Failed to render high-res page:",F),T&&mt(T.canvas)}finally{l&&V(!1)}},A=setTimeout(()=>{H()},150);return()=>{l=!1,clearTimeout(A)}},[U,t.fileId,t.pageIndex,m.vfs]),f)return null;const c=180,S=250;return e.jsxs(Ce,{ref:I,id:t.id,name:"page-object",x:s,y:a,draggable:!0,onMouseDown:P,onTouchStart:P,onDragStart:$,onDragEnd:se,onClick:j,rotation:t.rotation,children:[e.jsx(ne,{width:c,height:S,fill:"#ffffff",stroke:"#e9e9e7",strokeWidth:1,shadowColor:"#000000",shadowBlur:16,shadowOpacity:.1,shadowOffset:{x:0,y:4},cornerRadius:4}),(u||O)&&(()=>{const l=u||O;if(!l)return null;const _=l.width/l.height,N=c/S;let H=c,A=S,T=0,F=0;return _>N?(H=c,A=c/_,F=(S-A)/2):(A=S,H=S*_,T=(c-H)/2),e.jsx(Mt,{image:l,width:H,height:A,x:T,y:
2F,imageSmoothingEnabled:!u,cornerRadius:4})})(),e.jsxs(Ce,{x:c-24,y:S-24,children:[e.jsx(ne,{width:20,height:20,fill:"#f1f1ef",stroke:"#e9e9e7",strokeWidth:1,cornerRadius:4}),e.jsx(Oe,{text:`${i+1}`,fill:"#b3b3af",fontSize:10,x:5,y:5,align:"center"})]}),e.jsx(ne,{width:c,height:S,fill:"transparent",stroke:Z?"#2383e2":"transparent",strokeWidth:2,cornerRadius:4,shadowColor:Z?"#2383e2":"transparent",shadowBlur:Z?8:0,shadowOpacity:.3,listening:!1})]})},Oo=({doc:t})=>{const[n,s]=Be.useState(!1),a=g(j=>j.updateDocument),i=g(j=>j.setRenamingDocId),f=g(j=>j.activeDocumentId),I=g(j=>j.setActiveDocument),m=g(j=>j.selection),y=g(j=>j.setSelection),O=g(j=>j.gridColumns),u=g(j=>j.viewportSize),k=g(j=>j.studioViewPosition),v=g(j=>j.studioViewScale),V=j=>{j.target.name()==="document"&&a(t.id,{x:j.target.x(),y:j.target.y()})},L=200,Y=280,E=20,M=30,J=4,h=54,R=10,Z=Math.min(t.pages.length||1,O),Q=Math.ceil(t.pages.length/Z)||1,U=Math.max(L+E,Z*(L+E)),P=Q*(Y+M),$=Math.max(120,U-h),se=f===t.id&&m.length===0;return e.jsxs(Ce,{x:t.x,y:t.y,draggable:!0,onDragStart:j=>{j.cancelBubble=!0},onDragEnd:V,onMouseDown:()=>{I(t.id),y([])},name:"document",id:t.id,onDragEnter:()=>s(!0),onDragLeave:()=>s(!1),onDrop:()=>s(!1),children:[e.jsx(ne,{width:U+R*2,height:P+R*2+10+32,x:-R,y:-32,fill:"#e8e8e6",stroke:"transparent",cornerRadius:6,shadowColor:"#000000",shadowBlur:40,shadowOpacity:.12,shadowOffset:{x:0,y:8},listening:!1}),e.jsx(ne,{width:U+R*2,height:P+R*2+10+32,x:-R,y:-32,fill:"transparent",stroke:"transparent",cornerRadius:6,shadowColor:"#000000",shadowBlur:10,shadowOpacity:.08,shadowOffset:{x:0,y:2},listening:!1}),e.jsx(ne,{width:U+R*2,height:30,x:-R,y:-32,fill:"#ffffff",stroke:n?"#2383e2":"#e9e9e7",strokeWidth:1,cornerRadius:[6,6,0,0]}),e.jsx(ne,{width:U+R*2,height:1,x:-R,y:-2,fill:"#e9e9e7",listening:!1}),e.jsx(ne,{width:U+R*2,height:P+R*2+10,x:-R,y:-1,fill:"#ffffff",stroke:n?"#2383e2":"#e9e9e7",strokeWidth:1,cornerRadius:[0,0,6,6]}),se&&e.jsx(ne,{width:U+R*2,height:P+R*2+10+32,x:-R,y:-32,fill:"transparent",stroke:"#2383e2",strokeWidth:2,cornerRadius:6,listening:!1}),e.jsxs(Ce,{y:-32,onClick:j=>{j.cancelBubble=!0,i(t.id)},style:{cursor:"pointer"},children:[e.jsx(ro,{x:4,y:15,radius:J,fill:t.isModified?"#dfab01":"#0f7b6c"}),e.jsx(Oe,{text:t.name,x:15,y:7,fill:"#1a1a18",fontSize:12,fontStyle:"500",width:$-60,wrap:"none",ellipsis:!0}),e.jsx(Oe,{text:`${t.pages.length} page${t.pages.length===1?"":"s"}`,x:$-50,y:7,fill:"#b3b3af",fontSize:11,align:"right",width:50})]}),t.pages.length===0&&e.jsxs(Ce,{x:R,y:R,children:[e.jsx(ne,{width:L,height:Y,fillLinearGradientStartPoint:{x:10,y:10},fillLinearGradientEndPoint:{x:L+10,y:Y+10},fillLinearGradientColorStops:[0,"#ffffff",1,"#f1f1ef"],stroke:"#e9e9e7",strokeWidth:1.5,dash:[8,6],cornerRadius:12}),e.jsx(Oe,{text:"Drop pages here",fill:"#b3b3af",fontSize:14,fontStyle:"bold",align:"center",verticalAlign:"middle",width:L,height:Y})]}),t.pages.map((j,c)=>{const S=c%O,l=Math.floor(c/O),_=R+S*(L+E),N=R+l*(Y+M),H=(t.x+_)*v+k.x,A=(t.y+N)*v+k.y,T=L*v,F=Y*v,K=u.width*.5,de=u.height*.5,ue=u.width*1.5,Se=u.height*1.5,_e=H+T+K>=0&&H-K<=u.width&&A+F+de>=0&&A-de<=u.height,B=H+T+ue>=0&&H-ue<=u.width&&A+F+Se>=0&&A-Se<=u.height;if(!_e&&!B)return null;const G=!_e&&B;return e.jsx(Fo,{page:j,docId:t.id,x:_,y:N,currentIndex:c,shouldPrefetchOnly:G},j.id)})]})},Lo=({page:t})=>{const{runtime:n}=it(),[s]=Tt(t.thumbnailUrl),a=Ee(u=>u.createCheckpoint),i=g(u=>u.attachDetachedPage),f=g(u=>u.moveDetachedPage),I=g(u=>u.removeDetachedPage),m=g(u=>u.activeDocumentId),y=g(u=>u.gridColumns),O=u=>{u.cancelBubble=!0;
2const k=u.target,v=k.getStage();if(!v||!v.getPointerPosition())return;let L=null,Y=null;const E=200,M=280,J=20,h=30,R=E+J,Z=M+h,Q=v.scaleX()||1,U=k.absolutePosition(),P={x:U.x+90*Q,y:U.y+125*Q},$=v.find(".document");for(const c of $){const S=c.id(),l=g.getState().documents.find(K=>K.id===S);if(!l)continue;const N=c.getAbsoluteTransform().copy().invert().point(P),H=Math.min(l.pages.length||1,y),A=Math.ceil(l.pages.length/H)||1,T=Math.max(R,H*R),F=Math.max(Z,A*Z);if(N.x>=-30&&N.x<=T+30&&N.y>=-50&&N.y<=F+50){L=S,Y=c;break}}if(L&&Y){const c=g.getState().documents.find(A=>A.id===L);if(c&&!Le(n.billing.getContext(),c.pages.length+1).allowed){me(n.telemetry,"Free supports documents up to 25 pages. Upgrade to Pro to keep adding pages.",void 0,{toolId:"studio",trigger:"page_limit_25"});return}const l=Y.getAbsoluteTransform().copy().invert().point(P),_=Math.max(0,Math.min(y-1,Math.round(l.x/R))),H=Math.max(0,Math.round(l.y/Z))*y+_;i(t.id,L,H),a(n.vfs,"move_page","Attached page to workspace");return}const j=v.getAbsoluteTransform().copy().invert().point(U);f(t.id,j.x,j.y),a(n.vfs,"move_page","Moved detached page")};return e.jsxs(Ce,{id:`detached-${t.id}`,name:"detached-page-object",x:t.x,y:t.y,draggable:!0,onClick:u=>{if(u.cancelBubble=!0,!m)return;const k=g.getState().documents.find(v=>v.id===m);if(k&&!Le(n.billing.getContext(),k.pages.length+1).allowed){me(n.telemetry,"Free supports documents up to 25 pages. Upgrade to Pro to keep adding pages.",void 0,{toolId:"studio",trigger:"page_limit_25"});return}i(t.id,m),a(n.vfs,"move_page","Attached page to active workspace")},onDragStart:u=>{u.cancelBubble=!0,u.target.moveToTop()},onDragEnd:O,rotation:t.rotation,children:[e.jsx(ne,{width:180,height:250,fill:"white",shadowBlur:10,shadowOpacity:.3,cornerRadius:4}),s&&(()=>{const u=s.width/s.height,k=180/250;let v=180,V=250,L=0,Y=0;return u>k?(v=180,V=180/u,Y=(250-V)/2):(V=250,v=250*u,L=(180-v)/2),e.jsx(Mt,{image:s,width:v,height:V,x:L,y:Y,imageSmoothingEnabled:!1,cornerRadius:4})})(),e.jsxs(Ce,{x:0,y:-24,children:[e.jsx(ne,{width:180,height:20,fill:"rgba(15, 23, 42, 0.75)",cornerRadius:4}),e.jsx(Oe,{text:"Detached page",fill:"#dbeafe",fontSize:11,x:8,y:4})]}),e.jsxs(Ce,{x:162,y:-8,onClick:u=>{u.cancelBubble=!0,I(t.id),a(n.vfs,"delete_page","Deleted detached page")},onMouseEnter:u=>{var v;const k=(v=u.target.getStage())==null?void 0:v.container();k&&(k.style.cursor="pointer")},onMouseLeave:u=>{var v;const k=(v=u.target.getStage())==null?void 0:v.container();k&&(k.style.cursor="default")},children:[e.jsx(ne,{width:24,height:24,fill:"#ef4444",cornerRadius:12,shadowBlur:4,shadowOpacity:.3,x:-12,y:-12}),e.jsx(Oe,{text:"â",fill:"white",fontSize:14,fontStyle:"bold",x:-6,y:-7})]}),e.jsx(ne,{width:180,height:250,fill:"transparent",stroke:"rgba(147, 197, 253, 0.8)",strokeWidth:1.5,dash:[7,5],cornerRadius:4})]})},Uo=[{tool:"text",icon:"text",label:"Text",description:"Add and edit text elements on PDF pages"},{tool:"annotate",icon:"highlighter",label:"Annotate",description:"Highlight text, draw shapes, and add notes"},{tool:"sign",icon:"signature",label:"Sign",description:"Draw, type, or upload your signature to sign PDF"},{tool:"whiteout",icon:"eraser",label:"Whiteout",description:"Permanently erase sensitive content from PDF"},{tool:"watermark",icon:"stamp",label:"Watermark",description:"Add text or image watermarks to all pages"},{tool:"forms",icon:"file-input",label:"Forms",description:"Add fillable fields like text boxes, checkboxes, and dropdowns"},{tool:"protect",icon:"lock",label:"Protect",description:"Encrypt PDF with passwords and restrict permissions"}],Wo=[{tool:"ocr-pdf",icon:"ocr",label:"OCR",description:"Recognize text in scanned PDFs and make them searchable"},{tool:"auto-toc",icon:"edit",label:"TOC",description:"Auto-detect headings and generate an interactive table of contents with bookmarks"},{tool:"pdf-to-jpg",icon:"image",label:"PDF to JPG",description:"Convert PDF pages to JPEG images"},{tool:"compress-pdf",icon:"compress",label:"Compress",description:"Reduce PDF file size while maintaining quality"},{tool:"extract-images",icon:"image",label:"Extract Images",description:"Extract all embedded images from PDF document"}],Ho=[{tool:"pdf-info",icon:"file-input",label:"PDF Info",description:"Inspect pages, PDF version, encryption, fonts, and metadata locally"}];function ht({tool:t,icon:n,label:s,description:a,activeTool:i,disabled:f,onClick:I}){const m=i===t;return e.jsxs("button",{type:"button",className:`studio-tool-rail-btn${m?" active":""}`,onClick:I,disabled:f,"aria-pressed":m,title:a||s,children:[e.jsx(je,{name:n,size:20}),e.jsx("span",{className:"studio-tool-rail-collapsible-text",children:s}),t==="auto-toc"&&e.jsx("span",{className:"studio-tool-rail-badge-new studio-tool-rail-collapsible-text",children:"NEW"})]})}function Bo({activeTool:t,onToolClick:n,onUpload:s,hasFiles:a,onNewSpace:i,onHistoryToggle:f,isHistoryOpen:I,plan:m}){return e.jsx("div",{className:"studio-tool-rail-anchor",children:e.jsxs("aside",{className:"studio-tool-rail","aria-label":"Studio tools",children:[e.jsxs("button",{type:"button",className:"studio-tool-rail-btn studio-tool-rail-upload-btn",onClick:s,title:"Upload files",children:[e.jsx(je,{name:"upload",size:20}),e.jsx("span",{className:"studio-tool-rail-collapsible-text",children:"Upload"})]}),e.jsxs("div",{className:"studio-tool-rail-section",children:[e.jsx("div",{className:"studio-tool-rail-section-label studio-tool-rail-collapsible-text",children:"EDIT"}),Uo.map(y=>e.jsx(ht,{tool:y.tool,icon:y.icon,label:y.label,description:y.description,activeTool:t,disabled:!a,onClick:()=>{n(y.tool)}},y.tool))]}),e.jsxs("div",{className:"studio-tool-rail-section",children:[e.jsx("div",{className:"studio-tool-rail-section-label studio-tool-rail-collapsible-text",children:"CONVERT"}),Wo.map(y=>e.jsx(ht,{tool:y.tool,icon:y.icon,label:y.label,description:y.description,activeTool:t,disabled:!a,onClick:()=>{n(y.tool)}},y.tool))]}),e.jsxs("div",{className:"studio-tool-rail-section",children:[e.jsx("div",{className:"studio-tool-rail-section-label studio-tool-rail-collapsible-text",children:"INSPECT"}),Ho.map(y=>e.jsx(ht,{tool:y.tool,icon:y.icon,label:y.label,description:y.description,activeTool:t,disabled:!a,onClick:()=>{n(y.tool)}},y.tool))]}),e.jsx("div",{className:"studio-tool-rail-divider"}),e.jsx("div",{className:"studio-tool-rail-ext-section",children:e.jsxs("a",{href:"https://chromewebstore.google.com/detail/localpdf-private-pdf-comp/mjidkeobnlijdjmioniboflmoelmckfl",target:"_blank",rel:"noopener noreferrer",className:"studio-tool-rail-btn studio-tool-rail-ext-link",title:"Install Chrome extension for one-click PDF editing",children:[e.jsx(je,{name:"download",size:20}),e.jsx("span",{className:"studio-tool-rail-collapsible-text",children:"Get Chrome Extension"})]})}),e.jsx("div",{className:"studio-tool-rail-divider"}),e.jsxs("div",{className:"studio-tool-rail-bottom",children:[e.jsxs("button",{type:"button",className:`studio-tool-rail-btn${I?" active":""}`,onClick:f,disabled:!f,"aria-pressed":!!I,title:I?"Hide history":"Show history",children:[e.jsx(je,{name:"history",size:20}),e.jsx("span",{className:"studio-tool-rail-collapsible-text",children:"History"})]}),m==="pro"?e.jsx("div",{className:"studio-rail-plan-badge studio-rail-plan-badge--pro studio-tool-rail-collapsible-text",children:"Pro"}):e.jsx("div",{className:"studio-rail-plan-badge studio-rail-plan-badge--free studio-tool-rail-collapsible-text",children:"Free"})]})]})})}const ye=class ye{static createCanvasFactory(){return{create:(n,s)=>{const a=document.createElement("canvas");a.width=n,a.height=s;const i=a.getContext("2d");if(!i)throw new Error("Canvas factory failed to get 2d context");return{canvas:a,context:i}},reset:(n,s,a)=>{n.canvas.width=s,n.canvas.height=a},destroy:n=>{n.canvas.width=0,n.canvas.height=0}}}static async generateThumbnail(n,s){var O;const a=await nt(),i=((O=a.VerbosityLevel)==null?void 0:O.ERRORS)??0,I=await a.getDocument({data:new Uint8Array(n.slice(0)),verbosity:i}).promise,m=await I.getPage(s+1),y=await this.generateThumbnailFromPage(m);return await I.destroy(),y}static async generateThumbnailFromPage(n){const s=n.getViewport({scale:1}),a=ye.MIN_THUMBNAIL_WIDTH_PX/Math.max(1,s.width),i=Math.min(ye.MAX_RENDER_SCALE,Math.max(ye.MIN_RENDER_SCALE,a)),f=n.getViewport({scale:i}),I=document.createElement("canvas"),m=I.getContext("2d");if(I.height=f.height,I.width=f.width,m)return m.imageSmoothingEnabled=!0,m.imageSmoothingQuality="high",await n.render({canvasContext:m,viewport:f,canvas:I,annotationMode:0,canvasFactory:ye.createCanvasFactory()}).promise,I.toDataURL("image/png");throw new Error("Canvas context not available")}};Qe(ye,"MIN_THUMBNAIL_WIDTH_PX",1400),Qe(ye,"MIN_RENDER_SCALE",1),Qe(ye,"MAX_RENDER_SCALE",4);let st=ye;function zo(t){const n=Math.max(0,Date.now()-t),s=Math.floor(n/1e3),a=Math.floor(s/60),i=Math.floor(a/60),f=Math.floor(i/24);return f>0?`${f} day${f>1?"s":""} ago`:i>0?`${i} hour${i>1?"s":""} ago`:a>0?`${a} minute${a>
21?"s":""} ago`:"Just now"}function Yo(){const t=Ee(i=>i.timeline),n=Ee(i=>i.historyIndex),s=Ee(i=>i.restoreCheckpoint),a=d.useRef(null);return d.useEffect(()=>{a.current&&(a.current.scrollTop=a.current.scrollHeight)},[t.length]),t.length===0?e.jsxs("div",{className:"studio-timeline empty",children:[e.jsx(je,{name:"history",className:"linear-icon-large opacity-50 mb-4"}),e.jsx("p",{children:"History is empty."}),e.jsx("span",{className:"text-xs opacity-60",children:"Actions will appear here."})]}):e.jsxs("div",{className:"studio-timeline-container",ref:a,children:[e.jsx("div",{className:"studio-timeline-header",children:e.jsx("h3",{children:"Version History"})}),e.jsx("div",{className:"studio-timeline-list",children:t.map((i,f)=>{const I=f===n,m=f>n,y=!!i.snapshot;return e.jsxs("div",{className:`timeline-item ${I?"current":""} ${m?"future":""} ${y?"checkpoint":"event"}`,children:[e.jsxs("div",{className:"timeline-marker",children:[e.jsx("div",{className:"timeline-dot"}),f<t.length-1&&e.jsx("div",{className:"timeline-line"})]}),e.jsxs("div",{className:"timeline-content",children:[e.jsxs("div",{className:"timeline-label",children:[e.jsx("span",{className:"timeline-type",children:i.type.replace("_"," ").toUpperCase()}),e.jsx("span",{className:"timeline-text",children:i.label}),i.isManualVersion&&e.jsx("span",{className:"timeline-version-badge",children:"Version"})]}),e.jsx("div",{className:"timeline-meta",children:zo(i.timestamp)}),y&&!I&&e.jsx("button",{type:"button",className:"timeline-restore-btn",onClick:()=>s(f),children:"Restore"})]})]},i.id)})})]})}function Vo({element:t,onUpdate:n,onDelete:s,onDuplicate:a,onDeselect:i,onActivateMove:f,bgColor:I,onBgColorChange:m}){const y=d.useRef(null),O=t.type==="text",[u,k]=d.useState(()=>({x:Math.max(20,window.innerWidth/2-200),y:Math.max(20,window.innerHeight-120)})),v=d.useRef(!1),V=d.useRef({x:0,y:0});d.useEffect(()=>{if(!O)return;let E=0;const M=()=>{const J=`[data-editor-element-id="${t.id}"]`,h=document.querySelector(J),R=y.current;if(h&&R){const Z=h.getBoundingClientRect(),Q=R.getBoundingClientRect(),U=Math.min(Math.max(12,Z.left+Z.width/2-Q.width/2),Math.max(12,window.innerWidth-Q.width-12)),P=Math.max(12,Z.top-Q.height-10);k({x:U,y:P})}E=window.requestAnimationFrame(M)};return E=window.requestAnimationFrame(M),()=>{window.cancelAnimationFrame(E)}},[t.id,O]),d.useEffect(()=>{const E=J=>{v.current&&(k(h=>({x:h.x+(J.clientX-V.current.x),y:h.y+(J.clientY-V.current.y)})),V.current={x:J.clientX,y:J.clientY})},M=()=>{v.current=!1};return window.addEventListener("pointermove",E),window.addEventListener("pointerup",M),()=>{window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",M)}},[]);const L=E=>{if(!O&&!E.target.closest("button, input, select")){E.stopPropagation(),v.current=!0,V.current={x:E.clientX,y:E.clientY};try{E.currentTarget.setPointerCapture(E.pointerId)}catch{}}},Y=()=>{if(t.type!=="text")return e.jsx("div",{ref:y,className:"studio-floating-properties-panel",style:{left:u.x,top:u.y,cursor:"grab"},onPointerDown:L,children:s&&e.jsx("button",{type:"button",className:"studio-floating-btn delete",onClick:s,title:"Delete",children:e.jsx(je,{name:"x"})})});const E=t;return e.jsxs("div",{ref:y,className:"studio-floating-properties-panel",style:{left:u.x,top:u.y,cursor:O?"default":"grab"},onPointerDown:L,children:[e.jsxs("div",{className:"studio-floating-group",children:[e.jsx("button",{type:"button",className:`studio-floating-btn ${E.fontWeight==="bold"?"active":""}`,onClick:()=>n({fontWeight:E.fontWeight==="bold"?"normal":"bold"}),title:"Bold",children:e.jsx("span",{className:"font-icon-b",style:{fontWeight:700},children:"B"})}),e.jsx("button",{type:"button",className:`studio-floating-btn ${E.fontStyle==="italic"?"active":""}`,onClick:()=>n({fontStyle:E.fontStyle==="italic"?"normal":"italic"}),title:"Italic",children:e.jsx("span",{className:"font-icon-i",style:{fontStyle:"italic"},children:"I"})})]}),e.jsx("div",{className:"studio-floating-divider"}),e.jsxs("div",{className:"studio-floating-group",children:[e.jsxs("select",{className:"studio-floating-select font-family","aria-label":"Font family",title:"Font family",value:E.fontFamily,onChange:M=>n({fontFamily:M.target.value}),children:[e.jsx("option",{value:"roboto",style:{fontWeight:600},children:"Roboto (Latin/Cyrillic)"}),e.jsx("option",{value:"noto",children:"Noto Sans (International)"}),e.jsx("option",{value:"noto-arabic",children:"Noto Sans Arabic"}),e.jsx("option",{value:"noto-cjk",children:"Noto Sans CJK"}),e.jsx("option",{value:"noto-devanagari",children:"Noto Sans Devanagari"}),e.jsx("option",{value:"sora",children:"Helvetica"}),e.jsx("option",{value:"times",children:"Times New Roman"}),e.jsx("option",{value:"mono",children:"Courier"})]}),e.jsx("div",{className:"studio-floating-input-wrap",children:e.jsx("input",{type:"number",className:"studio-floating-input","data-testid":"studio-floating-font-size","aria-label":"Font size",title:"Font size",value:E.fontSize,min:8,max:96,onChange:M=>n({fontSize:ut(Number(M.target.value)||16,8,96)})})}),e.jsx("div",{className:"studio-floating-input-wrap",children:e.jsx("input",{type:"number",className:"studio-floating-input","data-testid":"studio-floating-line-height","aria-label":"Line height",value:E.lineHeight,min:.8,max:3,step:.05,title:"Line height",onCh
2ange:M=>n({lineHeight:ut(Number(M.target.value)||1.2,.8,3)})})}),e.jsx("div",{className:"studio-floating-input-wrap",children:e.jsx("input",{type:"number",className:"studio-floating-input","data-testid":"studio-floating-letter-spacing","aria-label":"Letter spacing",value:E.letterSpacing,min:-2,max:20,step:.2,title:"Letter spacing",onChange:M=>n({letterSpacing:ut(Number(M.target.value)||0,-2,20)})})})]}),e.jsx("div",{className:"studio-floating-divider"}),e.jsxs("div",{className:"studio-floating-group",children:[e.jsx("div",{className:"studio-floating-color-wrap",children:e.jsx("input",{type:"color",className:"studio-floating-color",value:E.color,onChange:M=>n({color:M.target.value}),title:"Text Color"})}),m&&e.jsx("div",{className:"studio-floating-color-wrap",children:e.jsx("input",{type:"color",className:"studio-floating-color",value:I||"#ffffff",onChange:M=>m(M.target.value),title:"Background Color"})})]}),e.jsx("div",{className:"studio-floating-divider"}),e.jsx("div",{className:"studio-floating-group",children:e.jsx("button",{type:"button",className:"studio-floating-btn",onClick:()=>{if(f){f();return}i==null||i()},title:"Move text",children:e.jsx(je,{name:"move-horizontal",size:18})})})]})};return _t.createPortal(Y(),document.body)}function Xo({stageRef:t}){const{runtime:n}=it(),s=g(c=>c.activeEditPageId),a=g(c=>c.editSession),i=g(c=>c.documents),f=g(c=>c.updatePage),I=g(c=>c.updateDocument),m=g(c=>c.clearEditSession),y=g(c=>c.setActiveEditPageId),O=Ee(c=>c.createCheckpoint),[u,k]=d.useState([]),[v,V]=d.useState(null),[L,Y]=d.useState(!1),[E,M]=d.useState(null),[J,h]=d.useState([]),[R,Z]=d.useState(!1),[Q,U]=d.useState(null),P=d.useMemo(()=>uo(),[]),$=d.useMemo(()=>{if(!s)return null;for(const c of i){const S=c.pages.find(l=>l.id===s);if(S)return S}return null},[s,i]);d.useEffect(()=>{if(!s||!t.current)return;let c;const S=()=>{const l=t.current;if(!l)return;const _=l.find("#"+s)[0];if(!_)return;const N=_.getClientRect(),H=l.scaleX();V(A=>A&&Math.abs(A.x-N.x)<.5&&Math.abs(A.y-N.y)<.5&&Math.abs(A.w-N.width)<.5&&Math.abs(A.h-N.height)<.5&&Math.abs(A.scale-H)<.005?A:{x:N.x,y:N.y,w:N.width,h:N.height,scale:H}),c=requestAnimationFrame(S)};return c=requestAnimationFrame(S),()=>cancelAnimationFrame(c)},[s,t]),d.useEffect(()=>{if(!$)return;const c=new AbortController;return(async()=>{try{const S={id:crypto.randomUUID(),type:"COMMAND",payload:{type:"GET_PDF_TEXT_LAYER",payload:{fileId:$.fileId,pageNumber:$.pageIndex+1}}},l=await n.workerOrchestrator.dispatch(S,void 0,c.signal);l.payload.type==="TEXT_LAYER_RESULT"&&h(po(l.payload.payload.spans))}catch{}})(),()=>c.abort()},[$,n]);const se=async()=>{if(!(!$||L)){Y(!0);try{const c={id:crypto.randomUUID(),type:"COMMAND",payload:{type:"APPLY_STUDIO_TEXT_EDITS",payload:{fileId:$.fileId,pageIndex:$.pageIndex,elements:u}}},S=await n.workerOrchestrator.dispatch(c);if(S.payload.type==="STUDIO_TEXT_EDITS_APPLIED"){const l=S.payload.payload.redactVerify;if(l&&a){const N=Zt(l,crypto.randomUUID());Qt(n.telemetry,N),I(a.docId,{lastRedactVerify:N}),N.passed||M("Redaction checks incomplete â PDF download allowed, certificate only when all pass.")}else a&&I(a.docId,{lastRedactVerify:void 0});const _=await fo.getPdfPagePreview(n,S.payload.payload.outputId,$.pageIndex+1,{scale:2});f(a.docId,$.id,{fileId:S.payload.payload.outputId,thumbnailUrl:(_==null?void 0:_.thumbnailUrl)??$.thumbnailUrl}),await O(n.vfs,"edit_save","Saved inline edits"),j()}}catch{M(P.saveFailed)}finally{Y(!1)}}},j=()=>{y(null),m()};return!s||!v||!$?null:e.jsxs("div",{className:"studio-inplace-editor-overlay",style:{position:"fixed",left:v.x,top:v.y,width:v.w,height:v.h,zIndex:1e3,pointerEvents:"none"},children:[e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",pointerEvents:"auto"},children:[e.jsx(ho,{page:$,width:v.w,height:v.h,activeTool:(a==null?void 0:a.activeTool)??null,onActiveToolChange:c=>{},isSelectMode:R,setIsSelectMode:Z,textLayerSpans:J,elements:u,onElementsChange:k,selectedElementId:Q,onSelectedElementIdChange:U,onFinish:se,onDiscard:j}),Q&&u.find(c=>c.id===Q)&&e.jsx(Vo,{element:u.find(c=>c.id===Q),onUpdate:c=>{k(S=>S.map(l=>l.id===Q?{...l,...c}:l))},onDelete:()=>{k(c=>c.filter(S=>S.id!==Q)),U(null)},onDuplicate:()=>{const c=u.find(N=>N.id===Q);if(!c)return;const S=crypto.randomUUID(),l="x"in c?c.x+.05:.05,_="y"in c?c.y+.05:.05;k(N=>
2[...N,{...c,id:S,x:l,y:_}]),U(S)},onDeselect:()=>U(null)}),E&&e.jsx("div",{className:"studio-inplace-error",children:E})]}),e.jsx("div",{style:{position:"fixed",inset:0,zIndex:-1,pointerEvents:"auto"},onPointerDown:c=>{c.target===c.currentTarget&&j()}})]})}const $o=["OCR PDF â text recognition in scans and images","PDF Editor â modify text, images, and annotations","Password protection & encryption","Convert to/from Word, Excel, JPG","Delete, rotate, and reorder pages","Extract images from PDFs","Up to 500 MB per file","No ads, no daily limits"];function Go({toolId:t,toolName:n,reason:s,details:a,onClose:i}){const f=eo(),I=()=>{f&&(to("paywall_cta_clicked",{source:"paywall_modal",toolId:t,trigger:s,destination:f.url,plan:"pro",variant:f.variant,userState:"local",hadPriorSuccessfulRun:!0}),oo(f.url,{source:"paywall_modal",trigger:s,plan:"pro",variant:f.variant,userState:"local",hadPriorSuccessfulRun:!0}))};return e.jsx("div",{className:"paywall-overlay",onClick:i,children:e.jsxs("div",{className:"paywall-modal",onClick:m=>m.stopPropagation(),children:[e.jsx("button",{className:"paywall-close",onClick:i,"aria-label":"Close",children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),e.jsx("div",{className:"paywall-lock-icon",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}),e.jsx("h2",{className:"paywall-title",children:n}),e.jsxs("p",{className:"paywall-subtitle",children:["This feature requires ",e.jsx("strong",{children:"LocalPDF Pro"})]}),a&&e.jsx("p",{className:"paywall-details",children:a}),e.jsx("div",{className:"paywall-divider"}),e.jsxs("div",{className:"paywall-features",children:[e.jsx("p",{className:"paywall-features-title",children:"With Pro you get:"}),e.jsx("ul",{className:"paywall-feature-list",children:$o.map(m=>e.jsxs("li",{className:"paywall-feature-item",children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2.5",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),e.jsx("span",{children:m})]},m))})]}),e.jsx("button",{className:"btn-primary paywall-cta",onClick:I,children:e.jsxs("span",{className:"btn-inline",children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),f?f.label:"Upgrade to Pro"]})}),e.jsx("p",{className:"paywall-note",children:"One-time payment â no subscription, no renewal"})]})})}const Ft="localpdf_usage_";function Ot(t){try{const n=`${Ft}${t}`,s=localStorage.getItem(n);if(!s)return 0;const{date:a,count:i}=JSON.parse(s),f=new Date().toISOString().slice(0,10);return a===f?i:0}catch{return 0}}function Ko(t){try{const n=`${Ft}${t}`,s=new Date().toISOString().slice(0,10);localStorage.setItem(n,JSON.stringify({date:s,count:Ot(t)+1}))}catch{}}const Dt={"compress-pdf":3,"pdf-to-jpg":3,"extract-images":3,text:3,annotate:3,sign:3,whiteout:3,watermark:3,forms:3,protect:3,"auto-toc":3},qo=d.lazy(async()=>({default:(await rt(()=>import("./StudioEditWorkspace-CDw6sP0i.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).StudioEditWorkspace})),Jo=d.lazy(async()=>({default:(await rt(()=>import("./StudioConvertWorkspace-Cm16-rys.js"),__vite__mapDeps([12,1,3,4,6,7,9,13,10]))).StudioConvertWorkspace})),Zo=d.lazy(async()=>({default:(await rt(()=>import("./AutoTocStudioPanel-BIqpsFXe.js"),__vite__mapDeps([14,1,3,4,15,6,7,16,17,18]))).AutoTocStudioPanel})),Qo=d.lazy(async()=>({default:(await rt(()=>import("./PdfInfoStudioPanel-DHnIMAV0.js"),__vite__mapDeps([19,1,3,4,20,6,7]))).PdfInfoStudioPanel})),en=52,Lt=200,Ut=280,xt=20,kt=80,tn=80,ft=48,Nt=56,on=Ut+xt+40,nn=.35,sn=6,Et=1.2;function an(t){const n=t.trim(),s=n.toLowerCase();return s.endsWith("(protected)")||s.endsWith("(protected).pdf")?n:s.endsWith(".pdf")?`${n.slice(0,-4)} (protected).pdf`:`${n} (protected)`}function rn(t){if(!t||typeof t!="object")return!1;const n=t,s=typeof n.name=="string"?n.name.toLowerCase():"",a=typeof n.code=="number"?n.code:null,i=typeof n.message=="string"?n.message.toLowerCase():"";return s.includes("passwordexception")||i.includes("passwordexception")||i.includes("encrypted")||a===1||a===2}function tt(t){return Math.min(sn,Math.max(nn,t))}async function ln(t){if(!t.type.startsWith("image/"))return t;const n=t.type==="image/png"?"image/png":"image/jpeg";if(typeof createImageBitmap!="function"||typeof document>"u")return t;try{const s=await createImageBitmap(t);try{const a=document.createElement("canvas");a.width=s.width,a.height=s.height;const i=a.getContext("2d");if(!i)return t;i.drawImage(s,0,0);const f=await new Promise(y=>a.toBlob(y,n,.92));if(!f)return t;const I=n==="image/png"?"png":"jpg",m=t.name.replace(/\.[^.]+$/u,"");return new File([f],`${m||"image"}.${I}`,{type:n})}finally{s.close()}}catch{return t}}function at(t,n){const s=Math.min(t||1,n);return Math.max(240,s*(Lt+xt)+20)}function ze(t,n){const s=Math.min(t||1,n),a=Math.ceil(t/s)||1;return Math.max(on,a*(Ut+xt)+60)}function cn(t,n,s,a){if(n.length===0)return[];const i=kt,f=Math.max(tn,...t.map(k=>k.y+ze(k.pages.length,a)+Nt)),I=Math.max(420,s-kt*2),m=[];let y=i,O=f,u=0;for(const k of n){const v=at(k.pages.length,a),V=ze(k.pages.length,a);y!==i&&y-i+v>I&&(y=i,O+=u+Nt,u=0),m.push({...k,x:y,y:O}),y+=v+ft,u=Math.max(u,V)}return m}function dn(t,n){let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,f=Number.NEGATIVE_INFINITY;for(const I of t){const m=at(I.pages.length,n),y=ze(I.pages.length,n);s=Math.min(s,I.x-20),a=Math.min(a,I.y-40),i=Math.max(i,I.x+m+20),f=Math.max(f,I.y+y+20)}return{minX:s,minY:a,maxX:i,maxY:f}}function Cn({onFilesDropped:t}){var yt,wt;const n=d.useRef(crypto.randomUUID()),[s,a]=d.useState({width:window.innerWidth,height:window.innerHeight}),i=g(o=>o.studioViewScale),f=g(o=>o.studioViewPosition),I=g(o=>o.setStudioViewport),m=g(o=>o.gridColumns),y=g(o=>o.setGridColumns),[O,u]=d.useState(i),[k,v]=d.useState(f),V=d.useRef(null),L=d.useRef(null),Y=d.useRef(null),E=Math.max(1,Math.ceil(window.devicePixelRatio||1)),M=so(),J=ao(),{runtime:h}=it(),[R,Z]=d.useState(()=>h.billing.getContext());d.useEffect(()=>h.billing.subscribe(o=>{Z(o)}),[h.billing]);const Q=g(o=>o.isDraggingFile),U=g(o=>o.setDraggingFile),P=g(o=>o.documents),$=g(o=>o.detachedPages),se=g(o=>o.addDocument),j=g(o=>o.setDocuments),c=g(o=>
2o.setActiveDocument),S=g(o=>o.activeDocumentId),l=Ee(o=>o.createCheckpoint),_=g(o=>o.isHistoryOpen),N=g(o=>o.setHistoryOpen),H=g(o=>o.renamingDocId),A=g(o=>o.setRenamingDocId),T=g(o=>o.selection),F=g(o=>o.setSelection),K=g(o=>o.setInteractionMode),de=g(o=>o.startEditSession);g(o=>o.setActiveEditPageId);const ue=g(o=>o.editSession),Se=g(o=>o.clearEditSession),_e=g(o=>o.updateDocument),B=d.useMemo(()=>P.find(o=>o.id===S)??null,[S,P]),G=P.length>0||$.length>0,De=d.useRef([]),[Ue,Ye]=d.useState(!1),z=d.useMemo(()=>({width:Math.max(0,s.width-en),height:s.height}),[s.height,s.width]),ee=d.useMemo(()=>{const r=document.createElement("canvas");r.width=20,r.height=20;const p=r.getContext("2d");return p&&(p.fillStyle="#f0efed",p.fillRect(0,0,20,20),p.fillStyle="#b4b4b0",p.beginPath(),p.arc(20/2,20/2,1,0,Math.PI*2),p.fill()),r},[]),[ge,Te]=d.useState(null),[Ve,Xe]=d.useState(null);d.useEffect(()=>{I(O,k,z)},[z,I,k,O]);const we=d.useCallback(o=>{h.telemetry.track({type:"UI_TOAST_SHOWN",runId:n.current,toolId:"studio",message:o,level:"error"})},[h.telemetry]),be=d.useCallback(o=>{if(o.length===0){u(1),v({x:0,y:0});return}const r=dn(o,m),p=Math.max(1,r.maxX-r.minX),w=Math.max(1,r.maxY-r.minY),b=56,C=tt(Math.min((z.width-b*2)/p,(z.height-b*2)/w)),x=p*C,W=w*C,q=(z.width-x)/2-r.minX*C,D=(z.height-W)/2-r.minY*C;u(C),v({x:q,y:D})},[z.height,z.width,m]),$e=d.useCallback(()=>{const o=T.length>=1?(()=>{const b=T[0],C=P.find(W=>W.id===b.docId)??null,x=(C==null?void 0:C.pages.find(W=>W.id===b.pageId))??null;return C&&x?{doc:C,page:x}:null})():null,r=B!=null&&B.pages[0]?{doc:B,page:B.pages[0]}:null,p=P.find(b=>b.pages[0])??null,w=(p==null?void 0:p.pages[0])??null;return o??r??(p&&w?{doc:p,page:w}:null)},[B,P,T]);d.useCallback(o=>{if(O>=1.4)return;const p=at(o.pages.length,m),w=ze(o.pages.length,m),b=56,C=tt(Math.min((z.width-b*2)/p,(z.height-b*2)/w)),x=Math.max(1.4,C),W=p*x,q=w*x,D=(z.width-W)/2-o.x*x,ae=(z.height-q)/2-o.y*x;u(x),v({x:D,y:ae})},[z.height,z.width,m,O]);const te=d.useCallback(()=>{Te(null),Se(),K(null)},[Se,K]),pe=d.useCallback(o=>{const r=$e();r&&(de({docId:r.doc.id,pageId:r.page.id,pageIndex:r.page.pageIndex,fileId:r.page.fileId,initialTool:o}),F([{docId:r.doc.id,pageId:r.page.id}]),K("edit"),Te("edit"))},[$e,de,F,K]),xe=d.useCallback(o=>{G&&(K("convert"),Te(o))},[G,K]),Ge=d.useCallback(o=>{const r=h.billing.getContext(),p=["text","annotate","sign","whiteout","watermark","forms","protect"],w=Dt[o];if(w!==void 0&&r.plan==="basic"&&o!=="ocr-pdf"&&Ot(o)>=w){me(h.telemetry,`You've used all ${w} free ${o} runs today. Upgrade to Pro for unlimited use.`,void 0,{toolId:o,trigger:"daily_limit"}),Xe(`You've used all ${w} free uses today. Upgrade to Pro for unlimited use.`);return}p.includes(o)?pe(o):xe(o),Dt[o]!==void 0&&r.plan==="basic"&&Ko(o)},[pe,xe,h.billing,h.telemetry]),ke=d.useCallback(()=>{N(!_)},[_,N]),Me=d.useCallback(()=>{const o=h.billing.getContext(),r=jt(o,P.length,0);if(!r.allowed){me(h.telemetry,r.reason==="workspace_limit"?"Free includes up to 3 workspaces. Upgrade to Pro for unlimited workspaces.":"Free supports documents up to 25 pages. Upgrade to Pro to open larger PDFs.",void 0,{toolId:"studio",trigger:r.reason==="workspace_limit"?"workspace_limit_3":"page_limit_25"});return}const p=P.reduce((b,C)=>Math.max(b,C.y+120),80),w=crypto.randomUUID();se({id:w,name:`Workspace ${P.length+1}`,x:100,y:G?p+40:100,pages:[],allowEmpty:!0,includeInExport:!0,isModified:!0}),c(w),l(h.vfs,"system","Created Workspace")},[se,l,P,G,h.billing,h.telemetry,h.vfs,c]),Re=ge==="edit"?(ue==null?void 0:ue.activeTool)??null:ge??(ue==null?void 0:ue.activeTool)??null,ve=d.useCallback((o,r)=>{const p=O,w=r==="in"?Et:1/Et,b=tt(p*w);if(Math.abs(b-p)<1e-4)return;const C=(o.x-k.x)/p,x=(o.y-k.y)/p,W=o.x-C*b,q=o.y-x*b;u(b),v({x:W,y:q})},[k.x,k.y,O]),Ke=d.useCallback(async o=>{const r=await nt(),p=await h.vfs.read(o),b=await(await p.getBlob()).arrayBuffer(),x=await r.getDocument({data:new Uint8Array(b)}).promise,W=x.numPages,q=[];for(let D=0;D<W;D++){const ae=await x.getPage(D+1),le=await st.generateThumbnailFromPage(ae);q.push({id:crypto.randomUUID(),fileId:o,pageIndex:D,thumbnailUrl:le,rotation:0})}return await x.destroy(),{name:p.getName(),pages:q}},[h.vfs]),qe=d.useCallback(async(o,r)=>{const p=await h.vfs.read(o),w=r.pages.map(b=>({id:crypto.randomUUID(),fileId:o,pageIndex:b.pageIndex,thumbnailUrl:b.thumbnailUrl,rotation:b.rotation}));return{name:p.getName(),pages:w}},[h.vfs]),lt=d.useCallback(o=>{o&&(c(o.activeDocumentId),F(o.selection),K(o.interactionMode),u(tt(o.viewScale)),v(o.viewPosition))},[c,K,F]);d.useEffect(()=>{const o=()=>{V.current&&a({width:V.current.offsetWidth,height:V.current.offsetHeight})};return window.addEventListener("resize",o),o(),()=>window.removeEventListener("resize",o)},[]);const Wt=d.useCallback(o=>{o.preventDefault(),U(!0)},[U]),Ht=d.useCallback(o=>{o.preventDefault(),U(!1)},[U]),Ne=d.useCallback(async(o,r)=>{var x,W,q;const p=[],w=[];if(o.length===0)return;r&&(t==null||t(o));const b=h.billing.getContext();for(let D of o){let ae=null;try{if(!gt(b,P.length+p.length).allowed){me(h.telemetry,"Free includes up to 3 workspaces. Upgrade to Pro for unlimited workspaces.",void 0,{toolId:"studio",trigger:"workspace_limit_3"});break}if(D.type.startsWith("image/")){const re=await ln(D),{PDFDocument:Je}=await io(),Fe=await Je.create(),vt=await re.arrayBuffer();let Ze;if(re.type==="image/jpeg"||re.type==="image/jpg"||re.type==="image/webp")Ze=await Fe.embedJpg(vt);else if(re.type==="image/png")Ze=await Fe.embedPng(vt);else throw new Error(`Unsupported image type: ${re.type}`);const{width:It,height:Pt}=Ze.scale(1);Fe.addPage([It,Pt]).drawImage(Ze,{x:0,y:0,width:It,height:Pt});const Gt=await Fe.save(),Kt=D.name.substring(0,D.name.lastIndexOf("."))||D.name;D=new File([Gt],`${Kt}.pdf`,{type:"application/pdf"})}const ie=await nt(),Ie=await h.vfs.write(D);ae=Ie.id;const X=await D.arrayBuffer(),fe=await ie.getDocument({data:new Uint8Array(X)}).promise,He=fe.numPages;if(!jt(b,P.length+p.length,He).allowed){me(h.telemetry,`This document has ${He} pages. Free plan supports up to 25 â upgrade to Pro for unlimited.`,void 0,{toolId:"studio",trigger:"page_limit_25"}),await fe.destroy(),await h.vfs.delete(Ie.id).catch(()=>{}),ae=null;continue}const Ae=[];for(let re=0;re<He;re++){const Je=await fe.getPage(re+1),Fe=await st.generateThumbnailFromPage(Je);Ae.push({id:crypto.randomUUID(),fileId:Ie.id,pageIndex:re,thumbnailUrl:Fe,rotation:0})}await fe.destroy(),w.push(D),p.push({id:crypto.randomUUID(),name:D.name,pages:Ae,isModified:!1})}catch(le){if(ae&&await h.vfs.delete(ae).catch(()=>{}),console.error("Failed to load file into Studio:",le),Ct(le))we("Storage quota exceeded.
2Close some documents or clear the workspace and try again.");else{const ie=le instanceof Error?le.message:"Failed to load file into Studio.";we(ie)}}}const C=cn(P,p,z.width,m);for(const D of C)se(D);C.length>0&&(h.telemetry.track({type:"APP_FILE_UPLOADED",flowId:no(),toolId:"studio",fileCount:w.length,mimeCategory:(x=w[0])!=null&&x.type.startsWith("image/")?"image":((W=w[0])==null?void 0:W.type)==="application/pdf"?"pdf":((q=w[0])==null?void 0:q.type.split("/")[0])||"unknown",totalBytes:w.reduce((D,ae)=>D+ae.size,0),source:"studio"}),be([...P,...C]),l(h.vfs,"upload",`Uploaded ${C.length} ${C.length===1?"file":"files"}`))},[se,z.width,l,P,be,we,t,h.telemetry,h.vfs,m]),Bt=d.useCallback(async o=>{o.preventDefault(),U(!1),await Ne(Array.from(o.dataTransfer.files),!0)},[Ne,U]),zt=d.useCallback(async o=>{const r=Array.from(o.target.files??[]);await Ne(r,!1),o.target.value=""},[Ne]),We=d.useCallback(()=>{var o;(o=L.current)==null||o.click()},[]),Yt=d.useCallback(()=>{h.telemetry.track({type:"STUDIO_EMPTY_STATE_CTA",runId:n.current,action:"upload"}),We()},[We,h.telemetry]),ct=d.useCallback(()=>{if(T.length===0)return!1;const o=new Set(T.map(p=>p.pageId)),r=[];for(const p of P)for(const w of p.pages)o.has(w.id)&&r.push(w);return r.length===0?!1:(De.current=r,Ye(!0),!0)},[P,T]),dt=d.useCallback(()=>{if(!S||De.current.length===0)return!1;const o=P.find(x=>x.id===S);if(!o)return!1;const r=h.billing.getContext(),p=o.pages.length+De.current.length;if(!Le(r,p).allowed)return me(h.telemetry,"Free supports documents up to 25 pages. Upgrade to Pro to keep adding pages.",void 0,{toolId:"studio",trigger:"page_limit_25"}),!1;const b=De.current.map(x=>({...x,id:crypto.randomUUID()})),C=P.map(x=>x.id!==S?x:{...x,pages:[...x.pages,...b],isModified:!0});return j(C),F(b.map(x=>({docId:S,pageId:x.id}))),!0},[S,P,h.telemetry,h.billing,j,F]);d.useEffect(()=>{const o=r=>{const p=r.target;if(p&&(p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.isContentEditable))return;const b=r.key.toLowerCase(),C=r.ctrlKey||r.metaKey,x=(r.ctrlKey||r.metaKey)&&b==="o",W=!r.ctrlKey&&!r.metaKey&&!r.altKey&&b==="u",q=C&&!r.shiftKey&&!r.altKey&&b==="c",D=C&&!r.shiftKey&&!r.altKey&&b==="v";if(q){ct()&&r.preventDefault();return}if(D){dt()&&r.preventDefault();return}!x&&!W||(r.preventDefault(),We())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[ct,We,dt]);const Vt=d.useCallback(o=>{const r=o.target,p=!!(r!=null&&r.findAncestor(".document",!0)),w=!!(r!=null&&r.findAncestor(".page-object",!0)),b=!!(r!=null&&r.findAncestor(".detached-page-object",!0));if(!p&&!w&&!b)return;o.evt.preventDefault();const C=Y.current;if(!C)return;const x=C.getPointerPosition();x&&ve(x,o.evt.deltaY>0?"out":"in")},[ve]),Xt=d.useCallback(()=>{ve({x:z.width/2,y:z.height/2},"in")},[z.height,z.width,ve]),$t=d.useCallback(()=>{ve({x:z.width/2,y:z.height/2},"out")},[z.height,z.width,ve]);return d.useEffect(()=>{const o=M.state??null,r=o==null?void 0:o.studioToolResult,p=o==null?void 0:o.studioReturnContext;if(!r||r.outputIds.length===0){(o==null?void 0:o.source)==="studio"&&p&&(lt(p),J("/studio",{replace:!0,state:null}));return}let w=!1;return(async()=>{var C;const b=[];try{const{outputIds:x,studioContext:W}=r,q=(W==null?void 0:W.documentId)??((C=W==null?void 0:W.selectedPages[0])==null?void 0:C.docId)??null,D=q?P.find(X=>X.id===q)??null:null,ae=p!=null&&p.activeDocumentId?P.find(X=>X.id===p.activeDocumentId)??null:null,le=D??ae,ie=[],Ie=h.billing.getContext();for(let X=0;X<x.length;X+=1){let oe;try{oe=await Ke(x[X])}catch(Ae){const re=rn(Ae);if(r.toolId==="protect-pdf"&&re&&le)oe=await qe(x[X],le);else throw b.push(x[X]),Ae}if(w)break;if(D&&r.toolId==="protect-pdf"&&X>0){b.push(x[X]);continue}if((!D||r.toolId!=="protect-pdf")&&!gt(Ie,P.length+ie.length).allowed){me(h.telemetry,"Free includes up to 3 workspaces. Upgrade to Pro for unlimited workspaces.",void 0,{toolId:"studio",trigger:"workspace_limit_3"}),b.push(...x.slice(X));break}if(!Le(Ie,oe.pages.length).allowed){me(h.telemetry,"Free supports documents up to 25 pages. Upgrade to Pro to open larger PDFs.",void 0,{toolId:"studio",trigger:"page_limit_25"}),b.push(x[X]);continue}const He=D?D.x+at(D.pages.length,m)+ft+X*(Lt+ft):100,bt=D?D.y:100+X*(ze(oe.pages.length,m)+50);ie.push({id:crypto.randomUUID(),name:oe.name,x:He,y:bt,pages:oe.pages,isModified:!0})}if(ie.length>0){if(r.toolId==="protect-pdf"&&D){const X=ie[0],oe=P.map(fe=>fe.id!==D.id?fe:{...fe,name:an(fe.name),pages:X.pages,isModified:!0});j(oe),c(D.id)}else if(D){const X=P.findIndex(oe=>oe.id===D.id);if(X>=0){const oe=[...P];oe.splice(X+1,0,...ie),j(oe)}else for(const oe of ie)se(oe)}else for(const X of ie)se(X);await l(h.vfs,"convert",`Executed ${r.toolId}`)}F([])}
2catch(x){if(!w)if(console.error("Failed to apply tool result in Studio:",x),Ct(x))we("Storage quota exceeded. Close some documents or clear the workspace and try again.");else{const W=x instanceof Error?x.message:"Failed to apply tool result in Studio.";we(W)}}finally{for(const x of b)await h.vfs.delete(x).catch(()=>{});w||(lt(p),J("/studio",{replace:!0,state:null}))}})(),()=>{w=!0}},[se,lt,Ke,qe,l,P,be,M.state,J,j,c,K,F,m,we,h.billing,h.telemetry]),d.useEffect(()=>{if(P.length===0){u(1),v({x:0,y:0});return}be(P)},[P.length,be]),d.useEffect(()=>{const o=async()=>{let p=!1;try{p=await new Promise(w=>{const b=indexedDB.open("localpdf-transfer",1);b.onupgradeneeded=()=>{const C=b.result;C.objectStoreNames.contains("transfer-files")||C.createObjectStore("transfer-files",{keyPath:"id"})},b.onsuccess=()=>{const C=b.result;if(!C.objectStoreNames.contains("transfer-files")){C.close(),w(!1);return}const x=C.transaction("transfer-files","readwrite"),W=x.objectStore("transfer-files"),q=W.get("pending");q.onsuccess=()=>{const D=q.result;if(D){const{blob:ae,name:le,type:ie}=D,Ie=new File([ae],le,{type:ie});W.delete("pending"),Ne([Ie],!0),w(!0)}else w(!1)},x.oncomplete=()=>{C.close()},x.onerror=()=>{C.close(),w(!1)}},b.onerror=()=>{w(!1)}})}catch(w){console.error("Failed to retrieve file from IndexedDB transfer",w)}if(p)return!0;try{const w=window.sessionStorage.getItem("localpdf_transfer_file");if(w){const{name:b,type:C,dataUrl:x}=JSON.parse(w);window.sessionStorage.removeItem("localpdf_transfer_file");const q=await(await fetch(x)).blob(),D=new File([q],b,{type:C});return Ne([D],!0),!0}}catch(w){console.error("Failed to retrieve file from sessionStorage transfer",w)}return!1};(async()=>{var b;const p=await o();new URLSearchParams(window.location.search).get("upload")==="1"&&(p||(b=L.current)==null||b.click(),J("/studio",{replace:!0,state:M.state}))})()},[Ne,J,M.state]),e.jsxs("div",{ref:V,className:`studio-shell-container ${Q?"dragging":""}`,onDragOver:Wt,onDragLeave:Ht,onDrop:Bt,children:[e.jsxs("div",{className:"studio-shell-workspace",children:[e.jsx(Bo,{activeTool:Re,onToolClick:Ge,onUpload:We,hasFiles:G,onNewSpace:Me,onHistoryToggle:ke,isHistoryOpen:_,plan:R.plan}),e.jsxs("div",{className:"studio-shell-canvas",children:[e.jsx(lo,{ref:Y,width:z.width,height:z.height,pixelRatio:E,draggable:G,x:k.x,y:k.y,scaleX:O,scaleY:O,onWheel:Vt,onDragEnd:o=>{o.target===o.currentTarget&&v({x:o.currentTarget.x(),y:o.currentTarget.y()})},children:e.jsxs(co,{children:[e.jsx(ne,{x:-5e3,y:-5e3,width:1e4,height:1e4,fillPatternImage:ee,fillPatternRepeat:"repeat"}),G&&e.jsxs(e.Fragment,{children:[P.map(o=>e.jsx(Oo,{doc:o},o.id)),$.map(o=>e.jsx(Lo,{page:o},o.id))]})]})}),!G&&e.jsxs("div",{className:"studio-empty-state","aria-live":"polite",children:[e.jsx("div",{className:"studio-empty-state-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsx("h2",{className:"studio-empty-state-title",children:"Drop a PDF to get started"}),e.jsxs("p",{className:"studio-empty-state-copy",children:["All processing happens locally.",e.jsx("br",{}),"Your files never leave your device."]}),e.jsx("div",{className:"studio-empty-state-actions",children:e.jsxs("button",{type:"button",className:"studio-upload-btn studio-empty-state-upload-btn",onClick:Yt,children:[e.jsx(je,{name:"upload",size:18}),"Upload PDF"]})}),e.jsxs("div",{className:"studio-empty-state-hints","aria-label":"Studio shortcuts",children:[e.jsx("span",{className:"studio-empty-state-hint",children:"U"}),e.jsx("span",{className:"studio-empty-state-hint-sep",children:"upload"}),e.jsx("span",{className:"studio-empty-state-hint-sep",children:"·"}),e.jsx("span",{className:"studio-empty-state-hint",children:"âO"}),e.jsx("span",{className:"studio-empty-state-hint-sep",children:"open"}),e.jsx("span",{className:"studio-empty-state-hint-sep",children:"·"}),e.jsx("span",{className:"studio-empty-state-hint",children:"drag & drop"})]})]}
2),e.jsxs("div",{className:"studio-viewport-controls animate-fade-in",children:[e.jsx("button",{className:"studio-viewport-btn",onClick:$t,title:"Zoom out",disabled:!G,children:"â"}),e.jsxs("span",{className:"studio-viewport-scale",children:[Math.round(O*100),"%"]}),e.jsx("button",{className:"studio-viewport-btn",onClick:Xt,title:"Zoom in",disabled:!G,children:"+"}),e.jsx("button",{className:"studio-viewport-btn studio-viewport-btn-fit",onClick:()=>be(P),title:"Fit to screen",disabled:!G,children:"Fit"}),e.jsx("span",{className:"studio-viewport-bar-divider"}),e.jsx("button",{className:`studio-viewport-btn ${m===3?"active":""}`,onClick:()=>y(3),title:"Grid: 3 columns",disabled:!G,children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7"})]})}),e.jsx("button",{className:`studio-viewport-btn ${m===5?"active":""}`,onClick:()=>y(5),title:"Grid: 5 columns overview",disabled:!G,children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),e.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"}),e.jsx("line",{x1:"15",y1:"3",x2:"15",y2:"21"})]})}),e.jsx("span",{className:"studio-viewport-bar-divider"}),e.jsx("button",{className:"studio-viewport-btn",onClick:()=>{ct()},title:"Copy selected pages (Ctrl/Cmd+C)",disabled:T.length===0,style:T.length===0?{opacity:.4}:void 0,children:"Copy"}),e.jsx("button",{className:"studio-viewport-btn",onClick:()=>{dt()},title:"Paste copied pages (Ctrl/Cmd+V)",disabled:T.length===0||!S||!Ue,style:!Ue||T.length===0?{opacity:.4}:void 0,children:"Paste"}),e.jsx("span",{className:"studio-viewport-spacer"}),T.length>0&&e.jsxs("span",{className:"studio-viewport-selection-count",title:`${T.length} selected pages`,children:[T.length," selected"]}),e.jsx("button",{className:`studio-viewport-btn ${_?"active":""}`,onClick:()=>N(!_),title:_?"Hide history":"Show history",children:"History"})]})]})]}),e.jsx("input",{ref:L,type:"file",accept:"application/pdf,image/png,image/jpeg,image/webp",multiple:!0,className:"hidden",onChange:zt}),_&&e.jsx(Yo,{}),e.jsx(Xo,{stageRef:Y}),ge&&_t.createPortal(e.jsx("div",{className:"studio-tool-overlay",children:e.jsx(d.Suspense,{fallback:null,children:ge==="edit"?e.jsx(qo,{onClose:te}):ge==="auto-toc"?e.jsx(Zo,{onClose:te,inputFileId:((yt=B==null?void 0:B.pages[0])==null?void 0:yt.fileId)??"",fileName:(B==null?void 0:B.name)??"document.pdf",runtime:h}):ge==="pdf-info"?e.jsx(Qo,{onClose:te,inputFileId:((wt=B==null?void 0:B.pages[0])==null?void 0:wt.fileId)??"",fileName:(B==null?void 0:B.name)??"document.pdf",runtime:h}):e.jsx(Jo,{onClose:te,initialTool:ge})})}),document.body),Ve&&e.jsx(Go,{toolId:"studio",toolName:"Studio Tool",reason:"PRO_REQUIRED",details:Ve,onClose:()=>Xe(null)}),H&&(()=>{const o=P.find(r=>r.id===H);return o?e.jsx(go,{type:"prompt",title:"Rename workspace",defaultValue:o.name,onConfirm:r=>{_e(H,{name:r}),l(h.vfs,"space_rename",`Renamed to ${r}`),A(null)},onCancel:()=>A(null)}):null})()]})}export{Cn as StudioShell};
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.