import{l as e,n as t,o as n}from"./index-B63M33Tt.js";var r=e(n(),1),i=t();function a({content:e}){let t=(0,r.useRef)(null),[n,a]=(0,r.useState)(1),[o,s]=(0,r.useState)({x:0,y:0}),[c,l]=(0,r.useState)(!1),u=(0,r.useRef)({x:0,y:0}),d=(0,r.useRef)({x:0,y:0}),f=(0,r.useCallback)(()=>{if(!t.current)return;let e=t.current,n=e.querySelector(`svg`);if(!n)return;let r=parseFloat(n.getAttribute(`width`)??`0`)||n.viewBox?.baseVal?.width||800,i=parseFloat(n.getAttribute(`height`)??`0`)||n.viewBox?.baseVal?.height||600,o=e.clientWidth-32,c=e.clientHeight-32;a(Math.min(o/r,c/i,1)),s({x:0,y:0})},[]);(0,r.useEffect)(()=>{f()},[e,f]),(0,r.useEffect)(()=>{let e=new ResizeObserver(()=>f());return t.current&&e.observe(t.current),()=>e.disconnect()},[f]);let p=(0,r.useCallback)(e=>{e.preventDefault();let t=e.deltaY>0?.9:1.1;a(e=>Math.min(Math.max(e*t,.05),5))},[]),m=(0,r.useCallback)(e=>{e.button===0&&(l(!0),u.current={x:e.clientX,y:e.clientY},d.current={...o})},[o]),h=(0,r.useCallback)(e=>{c&&s({x:d.current.x+(e.clientX-u.current.x),y:d.current.y+(e.clientY-u.current.y)})},[c]),g=(0,r.useCallback)(()=>l(!1),[]);return(0,i.jsxs)(`div`,{className:`relative w-full h-full overflow-hidden bg-white`,ref:t,children:[(0,i.jsxs)(`div`,{className:`absolute top-3 right-3 z-10 flex gap-1 bg-[var(--bg)] border border-[var(--border)] rounded-lg shadow-sm p-1`,children:[(0,i.jsx)(`button`,{onClick:()=>a(e=>Math.min(e*1.3,5)),className:`px-2 py-1 text-xs hover:bg-[var(--bg-alt)] rounded`,title:`Zoom in`,children:`+`}),(0,i.jsx)(`button`,{onClick:()=>a(e=>Math.max(e/1.3,.05)),className:`px-2 py-1 text-xs hover:bg-[var(--bg-alt)] rounded`,title:`Zoom out`,children:`−`}),(0,i.jsx)(`button`,{onClick:f,className:`px-2 py-1 text-xs hover:bg-[var(--bg-alt)] rounded`,title:`Fit`,children:`Fit`}),(0,i.jsxs)(`span`,{className:`px-2 py-1 text-[10px] text-[var(--text-muted)]`,children:[Math.round(n*100),`%`]})]}),(0,i.jsx)(`div`,{className:`w-full h-full cursor-grab active:cursor-grabbing`,onWheel:p,onMouseDown:m,onMouseMove:h,onMouseUp:g,onMouseLeave:g,children:(0,i.jsx)(`div`,{className:`origin-top-left [&>svg]:max-w-none [&>svg]:h-auto`,style:{transform:`translate(${o.x}px, ${o.y}px) scale(${n})`},dangerouslySetInnerHTML:{__html:e}})})]})}export{a as default};