/* esm.sh - @embedpdf/utils@2.15.1/react */
import{jsx as T}from"../../../../react@19.3.1/es2022/jsx-runtime.mjs";import{getCounterRotation as B}from"./utils.mjs";import{useRef as A,useEffect as D,Fragment as F,useCallback as P,useMemo as U}from"../../../../react@19.3.1/es2022/react.mjs";import{rotatePointAround as b,calculateRotatedRectAABB as O,normalizeAngle as I}from"../../../models?target=es2022";var X="onDoubleClick";function lt({children:l,...t}){let{rect:n,rotation:o}=t,{matrix:s,width:r,height:i}=B(n,o),e=A(null);D(()=>{let c=e.current;if(!c)return;let h=m=>{m.stopPropagation()},g=m=>{m.stopPropagation()};return c.addEventListener("pointerdown",h,{capture:!0}),c.addEventListener("touchstart",g,{capture:!0,passive:!0}),()=>{c.removeEventListener("pointerdown",h,{capture:!0}),c.removeEventListener("touchstart",g,{capture:!0})}},[]);let d={style:{position:"absolute",left:n.origin.x,top:n.origin.y,transform:s,transformOrigin:"0 0",width:r,height:i,pointerEvents:"none",zIndex:3},ref:c=>{e.current=c}};return T(F,{children:l({menuWrapperProps:d,matrix:s,rect:{origin:{x:n.origin.x,y:n.origin.y},size:{width:r,height:i}}})})}function Y(l){return{x:l.includes("e")?"left":l.includes("w")?"right":"center",y:l.includes("s")?"top":l.includes("n")?"bottom":"center"}}function N(l,t){let n=t.x==="left"?l.origin.x:t.x==="right"?l.origin.x+l.size.width:l.origin.x+l.size.width/2,o=t.y==="top"?l.origin.y:t.y==="bottom"?l.origin.y+l.size.height:l.origin.y+l.size.height/2;return{x:n,y:o}}function $(l,t,n){let o=l.origin.x,s=l.origin.y,r=l.size.width,i=l.size.height;return n.x==="left"?r+=t.x:n.x==="right"&&(o+=t.x,r-=t.x),n.y==="top"?i+=t.y:n.y==="bottom"&&(s+=t.y,i-=t.y),{origin:{x:o,y:s},size:{width:r,height:i}}}function k(l,t,n,o){let{x:s,y:r}=l.origin,{width:i,height:e}=l.size;if(n.x==="center"||n.y==="center")n.y==="center"?(e=i/o,r=t.origin.y+(t.size.height-e)/2):(i=e*o,s=t.origin.x+(t.size.width-i)/2);else{let d=Math.abs(i-t.size.width),c=Math.abs(e-t.size.height),h=d+c;if(h===0)i=t.size.width,e=t.size.height;else{let g=d/h,m=c/h,v=i,x=i/o,y=e*o,u=e;i=g*v+m*y,e=g*x+m*u}}return n.x==="right"&&(s=t.origin.x+t.size.width-i),n.y==="bottom"&&(r=t.origin.y+t.size.height-e),{origin:{x:s,y:r},size:{width:i,height:e}}}function G(l,t,n,o,s){if(!o)return l;let{x:r,y:i}=l.origin,{width:e,height:a}=l.size;e=Math.max(1,e),a=Math.max(1,a);let d=n.x==="left"?t.origin.x:t.origin.x+t.size.width,c=n.y==="top"?t.origin.y:t.origin.y+t.size.height,h=n.x==="left"?o.width-d:n.x==="right"?d:Math.min(t.origin.x,o.width-t.origin.x-t.size.width)*2+t.size.width,g=n.y==="top"?o.height-c:n.y==="bottom"?c:Math.min(t.origin.y,o.height-t.origin.y-t.size.height)*2+t.size.height;if(s){let m=e>h?h/e:1,v=a>g?g/a:1,x=Math.min(m,v);x<1&&(e*=x,a*=x)}else e=Math.min(e,h),a=Math.min(a,g);return n.x==="left"?r=d:n.x==="right"?r=d-e:r=t.origin.x+(t.size.width-e)/2,n.y==="top"?i=c:n.y==="bottom"?i=c-a:i=t.origin.y+(t.size.height-a)/2,r=Math.max(0,Math.min(r,o.width-e)),i=Math.max(0,Math.min(i,o.height-a)),{origin:{x:r,y:i},size:{width:e,height:a}}}function j(l,t,n){let o,s;return n.x==="left"?o=t.origin.x:n.x==="right"?o=t.origin.x+t.size.width-l.size.width:o=t.origin.x+(t.size.width-l.size.width)/2,n.y==="top"?s=t.origin.y:n.y==="bottom"?s=t.origin.y+t.size.height-l.size.height:s=t.origin.y+(t.size.height-l.size.height)/2,{origin:{x:o,y:s},size:l.size}}function L(l,t,n,o=!1){if(!t)return l;let{origin:{x:s,y:r},size:{width:i,height:e}}=l,a=t.minWidth??1,d=t.minHeight??1,c=t.maxWidth,h=t.maxHeight;if(n&&i>0&&e>0){let g=i/e;i<a&&(i=a,e=i/g),e<d&&(e=d,i=e*g),c!==void 0&&i>c&&(i=c,e=i/g),h!==void 0&&e>h&&(e=h,i=e*g)}else i=Math.max(a,i),e=Math.max(d,e),c!==void 0&&(i=Math.min(c,i)),h!==void 0&&(e=Math.min(h,e));return t.boundingBox&&!o&&(s=Math.max(0,Math.min(s,t.boundingBox.width-i)),r=Math.max(0,Math.min(r,t.boundingBox.height-e))),{origin:{x:s,y:r},size:{width:i,height:e}}}function H(l,t,n){let s=O(l,t);return s.origin.x>=-1e-6&&s.origin.y>=-1e-6&&s.origin.x+s.size.width<=n.width+1e-6&&s.origin.y+s.size.height<=n.height+1e-6}function S(l,t,n,o,s){let{startRect:r,maintainAspectRatio:i=!1,annotationRotation:e=0,constraints:a}=n,d=Y(t),c=r.size.width/r.size.height||1,h=$(r,l,d);if(i&&(h=k(h,r,d,c)),o&&(h=G(h,r,d,a?.boundingBox,i)),h=L(h,a,i,s),s&&(h=j(h,r,d)),e!==0){let g=N(r,d),m={x:r.origin.x+r.size.width/2,y:r.origin.y+r.size.height/2},v={x:h.origin.x+h.size.width/2,y:h.origin.y+h.size.height/2},x=b(g,m,e),y=b(g,v,e);h={origin:{x:h.origin.x+(x.x-y.x),y:h.origin.y+(x.y-y.y)},size:h.size}}return h}function q(l,t,n){let{annotationRotation:o=0,constraints:s}=n,r=s?.boundingBox;if(o!==0&&r){let i=S(l,t,n,!1,!0);if(H(i,o,r))return i;let e=S({x:0,y:0},t,n,!1,!0),a=0,d=1;for(let c=0;c<20;c+=1){let h=(a+d)/2,g=S({x:l.x*h,y:l.y*h},t,n,!1,!0);H(g,o,r)?(e=g,a=h):d=h}return e}return S(l,t,n,!0,!1)}var W=35,K={n:0,ne:45,e:90,se:135,s:180,sw:225,w:270,nw:315},Q=["ns-resize","nesw-resize","ew-resize","nwse-resize","ns-resize","nesw-resize","ew-resize","nwse-resize"];function J(l,t,n=0){let o=t*90,r=((K[l]+o+n)%360+360)%360,i=Math.round(r/45)%8;return Q[i]}function Z(l,t,n){let o=-l/2;return n==="center"?o:n==="outside"?o-t:o+t}function tt(l,t={}){let{handleSize:n=8,spacing:o=1,offsetMode:s="outside",includeSides:r=!1,zIndex:i=3,rotationAwareCursor:e=!0}=t,a=(l.pageRotation??0)%4,d=l.annotationRotation??0,c=v=>({[v]:Z(n,o,s)+"px"}),h=[["nw",{...c("top"),...c("left")}],["ne",{...c("top"),...c("right")}],["sw",{...c("bottom"),...c("left")}],["se",{...c("bottom"),...c("right")}]],g=r?[["n",{...c("top"),left:`calc(50% - ${n/2}px)`}],["s",{...c("bottom"),left:`calc(50% - ${n/2}px)`}],["w",{...c("left"),top:`calc(50% - ${n/2}px)`}],["e",{...c("right"),top:`calc(50% - ${n/2}px)`}]]:[];return[...h,...g].map(([v,x])=>({handle:v,style:{position:"absolute",width:n+"px",height:n+"px",borderRadius:"50%",zIndex:i,cursor:e?J(v,a,d):"default",pointerEvents:"auto",touchAction:"none",...x},attrs:{"data-epdf-handle":v}}))}function et(l,t={},n){let{vertexSize:o=12,zIndex:s=4}=t,r=l.element,i=l.scale??1;return(n??l.vertices??[]).map((a,d)=>{let c=(a.x-r.origin.x)*i-o/2,h=(a.y-r.origin.y)*i-o/2;return{handle:"nw",style:{position:"absolute",left:c+"px",top:h+"px",width:o+"px",height:o+"px",borderRadius:"50%",cursor:"pointer",zIndex:s,pointerEvents:"auto",touchAction:"none"},attrs:{"data-epdf-vertex":d}}})}function nt(l,t={},n=0){let{handleSize:o=16,zIndex:s=5,showConnector:r=!0,connectorWidth:i=1}=t,e=l.scale??1,a=l.element,d=l.rotationElement??a,c=l.rotationCenter??{x:a.origin.x+a.size.width/2,y:a.origin.y+a.size.height/2};d.size.width*e,d.size.height*e;let h=(c.x-d.origin.x)*e,g=(c.y-d.origin.y)*e,m=n*Math.PI/180,v=t.margin??W,x=a.size.height*e/2+v,y=h+x*Math.sin(m),u=g-x*Math.cos(m),p=y-o/2,f=u-o/2;return{handleStyle:{position:"absolute",left:p+"px",top:f+"px",width:o+"px",height:o+"px",borderRadius:"50%",cursor:"grab",zIndex:s,pointerEvents:"auto",touchAction:"none"},connectorStyle:r?{position:"absolute",left:h-i/2+"px",top:g-x+"px",width:i+"px",height:x+"px",transformOrigin:"center bottom",transform:`rotate(${n}deg)`,zIndex:s-1,pointerEvents:"none"}:{},radius:x,attrs:{"data-epdf-rotation-handle":!0}}}var _=class{constructor(t,n){this.config=t,this.onUpdate=n,this.state="idle",this.startPoint=null,this.startElement=null,this.startRotationElement=null,this.gestureRotationCenter=null,this.activeHandle=null,this.currentPosition=null,this.activeVertexIndex=null,this.startVertices=[],this.currentVertices=[],this.rotationCenter=null,this.centerScreen=null,this.initialRotation=0,this.lastComputedRotation=0,this.rotationDelta=0,this.rotationSnappedAngle=null,this.currentVertices=t.vertices||[]}updateConfig(t){this.config={...this.config,...t},this.state!=="vertex-editing"&&(this.currentVertices=t.vertices||[])}startDrag(t,n){this.state="dragging",this.startPoint={x:t,y:n},this.startElement={...this.config.element},this.startRotationElement=this.config.rotationElement?{...this.config.rotationElement}:null,this.currentPosition={...this.config.element},this.onUpdate({state:"start",transformData:{type:"move",changes:{rect:this.startElement}}})}startResize(t,n,o){this.state="resizing",this.activeHandle=t,this.startPoint={x:n,y:o},this.startElement={...this.config.element},this.currentPosition={...this.config.element},this.onUpdate({state:"start",transformData:{type:"resize",changes:{rect:this.startElement},metadata:{handle:this.activeHandle,maintainAspectRatio:this.config.maintainAspectRatio}}})}startVertexEdit(t,n,o){this.currentVertices=[...this.config.vertices??this.currentVertices],!(t<0||t>=this.currentVertices.length)&&(this.state="vertex-editing",this.activeVertexIndex=t,this.startPoint={x:n,y:o},this.startVertices=[...this.currentVertices],this.gestureRotationCenter=this.config.rotationCenter??{x:this.config.element.origin.x+this.config.element.size.width/2,y:this.config.element.origin.y+this.config.element.size.height/2},this.onUpdate({state:"start",transformData:{type:"vertex-edit",changes:{vertices:this.startVertices},metadata:{vertexIndex:t}}}))}startRotation(t,n,o=0,s){this.state="rotating",this.startPoint={x:t,y:n},this.startElement={...this.config.element},this.rotationCenter=this.config.rotationCenter??{x:this.config.element.origin.x+this.config.element.size.width/2,y:this.config.element.origin.y+this.config.element.size.height/2};let{scale:r=1}=this.config,i=this.config.rotationElement??this.config.element,e=i.size.width*r,a=i.size.height*r,d=s??Math.max(e,a)/2+W,c=(this.config.pageRotation??0)*90,h=(o+c)*Math.PI/180;this.centerScreen={x:t-d*Math.sin(h),y:n+d*Math.cos(h)},this.initialRotation=o,this.lastComputedRotation=o,this.rotationDelta=0,this.rotationSnappedAngle=null,this.onUpdate({state:"start",transformData:{type:"rotate",changes:{rotation:o},metadata:{rotationAngle:o,rotationDelta:0,rotationCenter:this.rotationCenter,isSnapped:!1}}})}move(t,n,o,s){if(!(this.state==="idle"||!this.startPoint)){if(o!==void 0&&o===0){this.end();return}if(this.state==="dragging"&&this.startElement){let r=this.calculateDelta(t,n),i=this.calculateDragPosition(r);this.currentPosition=i,this.onUpdate({state:"move",transformData:{type:"move",changes:{rect:i}}})}else if(this.state==="resizing"&&this.activeHandle&&this.startElement){let r=this.calculateLocalDelta(t,n),i=q(r,this.activeHandle,{startRect:this.startElement,maintainAspectRatio:this.config.maintainAspectRatio||!!s,annotationRotation:this.config.annotationRotation,constraints:this.config.constraints});this.currentPosition=i,this.onUpdate({state:"move",transformData:{type:"resize",changes:{rect:i},metadata:{handle:this.activeHandle,maintainAspectRatio:this.config.maintainAspectRatio||!!s}}})}else if(this.state==="vertex-editing"&&this.activeVertexIndex!==null){let r=this.calculateVertexPosition(t,n);this.currentVertices=r,this.onUpdate({state:"move",transformData:{type:"vertex-edit",changes:{vertices:r},metadata:{vertexIndex:this.activeVertexIndex}}})}else if(this.state==="rotating"&&this.rotationCenter){let r=this.calculateAngleFromMouse(t,n),i=this.applyRotationSnapping(r),e=I(i.angle),a=this.lastComputedRotation,d=e-a,c=d>180?d-360:d<-180?d+360:d;this.rotationDelta+=c,this.lastComputedRotation=e,this.rotationSnappedAngle=i.isSnapped?e:null,this.onUpdate({state:"move",transformData:{type:"rotate",changes:{rotation:e},metadata:{rotationAngle:e,rotationDelta:this.rotationDelta,rotationCenter:this.rotationCenter,isSnapped:i.isSnapped,snappedAngle:this.rotationSnappedAngle??void 0,cursorPosition:{clientX:t,clientY:n}}}})}}}end(){if(this.state==="idle")return;let t=this.state,n=this.activeHandle,o=this.activeVertexIndex;if(t==="vertex-editing")this.onUpdate({state:"end",transformData:{type:"vertex-edit",changes:{vertices:this.currentVertices},metadata:{vertexIndex:o||void 0}}});else if(t==="rotating")this.onUpdate({state:"end",transformData:{type:"rotate",changes:{rotation:this.lastComputedRotation},metadata:{rotationAngle:this.lastComputedRotation,rotationDelta:this.rotationDelta,rotationCenter:this.rotationCenter||void 0,isSnapped:this.rotationSnappedAngle!==null,snappedAngle:this.rotationSnappedAngle??void 0}}});else{let s=this.currentPosition||this.config.element;this.onUpdate({state:"end",transformData:{type:t==="dragging"?"move":"resize",changes:{rect:s},metadata:t==="dragging"?void 0:{handle:n||void 0,maintainAspectRatio:this.config.maintainAspectRatio}}})}this.reset()}cancel(){this.state!=="idle"&&(this.state==="vertex-editing"?this.onUpdate({state:"end",transformData:{type:"vertex-edit",changes:{vertices:this.startVertices},metadata:{vertexIndex:this.activeVertexIndex||void 0}}}):this.state==="rotating"?this.onUpdate({state:"end",transformData:{type:"rotate",changes:{rotation:this.initialRotation},metadata:{rotationAngle:this.initialRotation,rotationDelta:0,rotationCenter:this.rotationCenter||void 0,isSnapped:!1}}}):this.startElement&&this.onUpdate({state:"end",transformData:{type:this.state==="dragging"?"move":"resize",changes:{rect:this.startElement},metadata:this.state==="dragging"?void 0:{handle:this.activeHandle||void 0,maintainAspectRatio:this.config.maintainAspectRatio}}}),this.reset())}reset(){this.state="idle",this.startPoint=null,this.startElement=null,this.startRotationElement=null,this.gestureRotationCenter=null,this.activeHandle=null,this.currentPosition=null,this.activeVertexIndex=null,this.startVertices=[],this.rotationCenter=null,this.centerScreen=null,this.initialRotation=0,this.lastComputedRotation=0,this.rotationDelta=0,this.rotationSnappedAngle=null}calculateDelta(t,n){if(!this.startPoint)return{x:0,y:0};let o={x:t-this.startPoint.x,y:n-this.startPoint.y};return this.transformDelta(o)}transformDelta(t){let{pageRotation:n=0,scale:o=1}=this.config,s=n*Math.PI/2,r=Math.cos(s),i=Math.sin(s),e=t.x/o,a=t.y/o;return{x:r*e+i*a,y:-i*e+r*a}}calculateLocalDelta(t,n){let o=this.calculateDelta(t,n),{annotationRotation:s=0}=this.config;if(s===0)return o;let r=s*Math.PI/180,i=Math.cos(r),e=Math.sin(r);return{x:i*o.x+e*o.y,y:-e*o.x+i*o.y}}clampPoint(t){var n;let o=(n=this.config.constraints)==null?void 0:n.boundingBox;if(!o)return t;let{annotationRotation:s=0}=this.config;if(s===0)return{x:Math.max(0,Math.min(t.x,o.width)),y:Math.max(0,Math.min(t.y,o.height))};let r=this.gestureRotationCenter??this.config.rotationCenter??{x:this.config.element.origin.x+this.config.element.size.width/2,y:this.config.element.origin.y+this.config.element.size.height/2},i=b(t,r,s),e=Math.max(0,Math.min(i.x,o.width)),a=Math.max(0,Math.min(i.y,o.height));return e===i.x&&a===i.y?t:b({x:e,y:a},r,-s)}calculateVertexPosition(t,n){if(this.activeVertexIndex===null)return this.startVertices;let o=this.calculateLocalDelta(t,n),s=[...this.startVertices],r=s[this.activeVertexIndex],i={x:r.x+o.x,y:r.y+o.y};return s[this.activeVertexIndex]=this.clampPoint(i),s}calculateDragPosition(t){if(!this.startElement)return this.config.element;let n={origin:{x:this.startElement.origin.x+t.x,y:this.startElement.origin.y+t.y},size:{width:this.startElement.size.width,height:this.startElement.size.height}},{annotationRotation:o=0,constraints:s}=this.config,r=s?.boundingBox;if(o!==0&&r){let i,e,a,d;if(this.startRotationElement)i=this.startRotationElement.size.width,e=this.startRotationElement.size.height,a=this.startRotationElement.origin.x-this.startElement.origin.x,d=this.startRotationElement.origin.y-this.startElement.origin.y;else{let g=Math.abs(o*Math.PI/180),m=Math.abs(Math.cos(g)),v=Math.abs(Math.sin(g)),x=n.size.width,y=n.size.height;i=x*m+y*v,e=x*v+y*m,a=(x-i)/2,d=(y-e)/2}let{x:c,y:h}=n.origin;return c=Math.max(-a,Math.min(c,r.width-i-a)),h=Math.max(-d,Math.min(h,r.height-e-d)),{origin:{x:c,y:h},size:n.size}}return L(n,s,this.config.maintainAspectRatio??!1)}calculateAngleFromMouse(t,n){if(!this.centerScreen)return this.initialRotation;let o=t-this.centerScreen.x,s=n-this.centerScreen.y;if(Math.sqrt(o*o+s*s)<10)return this.lastComputedRotation;let i=(this.config.pageRotation??0)*90,e=Math.atan2(s,o)*(180/Math.PI)+90-i;return I(Math.round(e))}applyRotationSnapping(t){let n=this.config.rotationSnapAngles??[0,90,180,270],o=this.config.rotationSnapThreshold??4,s=I(t);for(let r of n){let i=I(r),e=Math.abs(s-i);if(Math.min(e,360-e)<=o)return{angle:i,isSnapped:!0,snapTarget:i}}return{angle:s,isSnapped:!1}}};function it(l){let{onUpdate:t,enabled:n=!0,...o}=l,s=A(null),r=A(t),i=A(null),e=A(null);D(()=>{r.current=t},[t]),D(()=>{s.current?s.current.updateConfig(o):s.current=new _(o,u=>{var p;return(p=r.current)==null?void 0:p.call(r,u)})},[o.element,o.rotationCenter,o.rotationElement,o.constraints,o.maintainAspectRatio,o.pageRotation,o.annotationRotation,o.scale,o.vertices]);let a=P(u=>{var p,f;let w=i.current,z=e.current,M=u??w;if(z&&M!==null)try{(p=z.hasPointerCapture)!=null&&p.call(z,M)&&((f=z.releasePointerCapture)==null||f.call(z,M))}catch{}i.current=null,e.current=null},[]),d=P(u=>{var p;i.current!==null&&i.current!==u.pointerId&&((p=s.current)==null||p.end(),a(i.current));let f=u.currentTarget;i.current=u.pointerId,e.current=f;try{f.setPointerCapture(u.pointerId)}catch{}},[a]);D(()=>{let u=globalThis,p=w=>{var z;let M=i.current;M===null||w.pointerId!==M||((z=s.current)==null||z.end(),a(w.pointerId))},f=()=>{var w;i.current!==null&&((w=s.current)==null||w.end(),a())};return u.addEventListener("pointerup",p,!0),u.addEventListener("pointercancel",p,!0),u.addEventListener("blur",f,!0),()=>{u.removeEventListener("pointerup",p,!0),u.removeEventListener("pointercancel",p,!0),u.removeEventListener("blur",f,!0)}},[a]),D(()=>()=>{var u;i.current!==null&&((u=s.current)==null||u.end(),a())},[a]);let c=P(u=>{var p;n&&(u.preventDefault(),u.stopPropagation(),(p=s.current)==null||p.startDrag(u.clientX,u.clientY),d(u))},[n,d]),h=P(u=>{var p;u.preventDefault(),u.stopPropagation();let f=i.current;f!==null&&u.pointerId!==f||((p=s.current)==null||p.move(u.clientX,u.clientY,u.buttons,u.shiftKey),i.current===u.pointerId&&u.buttons===0&&a(u.pointerId))},[a]),g=P(u=>{var p;u.preventDefault(),u.stopPropagation();let f=i.current;f!==null&&u.pointerId!==f||((p=s.current)==null||p.end(),a(u.pointerId))},[a]),m=P(u=>{var p;let f=i.current;f===null||u.pointerId!==f||((p=s.current)==null||p.end(),a(u.pointerId))},[a]),v=P(u=>({onPointerDown:p=>{var f;n&&(p.preventDefault(),p.stopPropagation(),(f=s.current)==null||f.startResize(u,p.clientX,p.clientY),d(p))},onPointerMove:h,onPointerUp:g,onPointerCancel:g,onLostPointerCapture:m}),[n,h,g,m,d]),x=P(u=>({onPointerDown:p=>{var f;n&&(p.preventDefault(),p.stopPropagation(),(f=s.current)==null||f.startVertexEdit(u,p.clientX,p.clientY),d(p))},onPointerMove:h,onPointerUp:g,onPointerCancel:g,onLostPointerCapture:m}),[n,h,g,m,d]),y=P((u=0,p)=>({onPointerDown:f=>{var w;if(!n)return;f.preventDefault(),f.stopPropagation();let z=f.currentTarget.getBoundingClientRect(),M=z.left+z.width/2,V=z.top+z.height/2;(w=s.current)==null||w.startRotation(M,V,u,p),d(f)},onPointerMove:h,onPointerUp:g,onPointerCancel:g,onLostPointerCapture:m}),[n,h,g,m,d]);return{dragProps:n?{onPointerDown:c,onPointerMove:h,onPointerUp:g,onPointerCancel:g,onLostPointerCapture:m}:{},createResizeProps:v,createVertexProps:x,createRotationProps:y}}function ct(l){var t,n,o,s,r,i;let{controller:e,resizeUI:a,vertexUI:d,rotationUI:c,includeVertices:h=!1,includeRotation:g=!1,currentRotation:m=0,handleAttrs:v,vertexAttrs:x,rotationAttrs:y}=l,{dragProps:u,createResizeProps:p,createVertexProps:f,createRotationProps:w}=it(e),z=U(()=>tt(e,a).map(C=>{var R;return{key:(R=C.attrs)==null?void 0:R["data-epdf-handle"],style:C.style,...p(C.handle),...C.attrs??{},...v?.(C.handle)??{}}}),[e.element.origin.x,e.element.origin.y,e.element.size.width,e.element.size.height,e.scale,e.pageRotation,e.annotationRotation,e.maintainAspectRatio,a?.handleSize,a?.spacing,a?.offsetMode,a?.includeSides,a?.zIndex,a?.rotationAwareCursor,p,v]),M=U(()=>h?et(e,d,e.vertices).map((C,R)=>({key:R,style:C.style,...f(R),...C.attrs??{},...x?.(R)??{}})):[],[h,e.element.origin.x,e.element.origin.y,e.element.size.width,e.element.size.height,e.scale,e.vertices,d?.vertexSize,d?.zIndex,f,x]),V=U(()=>{if(!g)return null;let E=nt(e,c,m);return{handle:{style:E.handleStyle,...w(m,E.radius),...E.attrs??{},...y?.()??{}},connector:{style:E.connectorStyle,"data-epdf-rotation-connector":!0}}},[g,e.element.origin.x,e.element.origin.y,e.element.size.width,e.element.size.height,(t=e.rotationCenter)==null?void 0:t.x,(n=e.rotationCenter)==null?void 0:n.y,(o=e.rotationElement)==null?void 0:o.origin.x,(s=e.rotationElement)==null?void 0:s.origin.y,(r=e.rotationElement)==null?void 0:r.size.width,(i=e.rotationElement)==null?void 0:i.size.height,e.scale,m,c?.handleSize,c?.margin,c?.zIndex,c?.showConnector,c?.connectorWidth,w,y]);return{dragProps:u,resize:z,vertices:M,rotation:V}}function ht(l,{delay:t=300,tolerancePx:n=18}={}){let o=A({t:0,x:0,y:0}),s=P(i=>{if(!l||i.pointerType==="mouse"||i.isPrimary===!1)return;let e=performance.now(),a=i.clientX,d=i.clientY,c=e-o.current.t<=t,h=a-o.current.x,g=d-o.current.y,m=h*h+g*g<=n*n;c&&m&&l?.(i),o.current={t:e,x:a,y:d}},[l,t,n]),r=P(i=>{l?.(i)},[l]);return l?{[X]:r,onPointerUpCapture:s}:{}}export{lt as CounterRotate,ht as useDoublePressProps,it as useDragResize,ct as useInteractionHandles};
//# sourceMappingURL=react.mjs.map