/* esm.sh - @embedpdf/plugin-selection@2.15.1/react */
import{createPluginPackage as T}from"../../../core@2.15.1/X-ZHJlYWN0LWRvbUAxOS4zLjEscmVhY3RAMTkuMy4x/es2022/core.mjs";import{SelectionPlugin as C,SelectionPluginPackage as $}from"./plugin-selection.mjs";export*from"./plugin-selection.mjs";import{jsxs as R,Fragment as E,jsx as b}from"../../../../react@19.3.1/es2022/jsx-runtime.mjs";import{useState as P,useEffect as m,useMemo as x,Fragment as F}from"../../../../react@19.3.1/es2022/react.mjs";import{useCapability as j,usePlugin as _,useDocumentState as z}from"../../../core@2.15.1/X-ZHJlYWN0LWRvbUAxOS4zLjEscmVhY3RAMTkuMy4x/es2022/react.mjs";import{CounterRotate as D}from"../../../utils@2.15.1/X-ZHJlYWN0LWRvbUAxOS4zLjEscmVhY3RAMTkuMy4x/es2022/react.mjs";var L=()=>j(C.id),k=()=>_(C.id);function N({documentId:t,pageIndex:n,scale:s,rotation:g,background:f="rgba(33,150,243)",selectionMenu:d}){var l,p;let{plugin:u}=k(),o=z(t),c=(p=(l=o?.document)==null?void 0:l.pages)==null?void 0:p[n],[h,y]=P([]),[a,S]=P(null),[i,w]=P(null);m(()=>{if(!(!u||!t))return u.registerSelectionOnPage({documentId:t,pageIndex:n,onRectsChange:({rects:r,boundingRect:v})=>{y(r),S(v)}})},[u,t,n]),m(()=>{if(!(!u||!t))return u.onMenuPlacement(t,r=>{w(r)})},[u,t]);let e=x(()=>s!==void 0?s:o?.scale??1,[s,o?.scale]),M=x(()=>{if(g!==void 0)return g;let r=c?.rotation??0,v=o?.rotation??0;return(r+v)%4},[g,c?.rotation,o?.rotation]),B=d&&i&&i.pageIndex===n&&i.isVisible;return a?R(E,{children:[b("div",{style:{position:"absolute",left:a.origin.x*e,top:a.origin.y*e,width:a.size.width*e,height:a.size.height*e,mixBlendMode:"multiply",isolation:"isolate",pointerEvents:"none"},children:h.map((r,v)=>b("div",{style:{position:"absolute",left:(r.origin.x-a.origin.x)*e,top:(r.origin.y-a.origin.y)*e,width:r.size.width*e,height:r.size.height*e,background:f}},v))}),B&&b(D,{rect:{origin:{x:i.rect.origin.x*e,y:i.rect.origin.y*e},size:{width:i.rect.size.width*e,height:i.rect.size.height*e}},rotation:M,children:r=>d({...r,context:{type:"selection",pageIndex:n},selected:!0,placement:i})})]}):null}var U=({documentId:t,pageIndex:n,scale:s,className:g,background:f,borderColor:d,borderStyle:l="dashed",stroke:p,fill:u})=>{let{plugin:o}=k(),c=z(t),[h,y]=P(null),a=d??p??"rgba(0,122,204,0.8)",S=f??u??"rgba(0,122,204,0.15)",i=x(()=>s!==void 0?s:c?.scale??1,[s,c?.scale]);return m(()=>{if(!(!o||!t))return o.registerMarqueeOnPage({documentId:t,pageIndex:n,scale:i,onRectChange:y})},[o,t,n,i]),h?b("div",{style:{position:"absolute",pointerEvents:"none",left:h.origin.x*i,top:h.origin.y*i,width:h.size.width*i,height:h.size.height*i,border:`1px ${l} ${a}`,background:S,boxSizing:"border-box",zIndex:1e3},className:g}):null};function W({documentId:t,pageIndex:n,scale:s,rotation:g,background:f,textStyle:d,marqueeStyle:l,marqueeClassName:p,selectionMenu:u}){return R(F,{children:[b(N,{documentId:t,pageIndex:n,scale:s,rotation:g,background:d?.background??f,selectionMenu:u}),b(U,{documentId:t,pageIndex:n,scale:s,background:l?.background,borderColor:l?.borderColor,borderStyle:l?.borderStyle,className:p})]})}function V(){let{provides:t}=L();return m(()=>{if(t)return t.onCopyToClipboard(({text:n})=>{navigator.clipboard.writeText(n)})},[t]),null}var X=T($).addUtility(V).build();export{V as CopyToClipboard,U as MarqueeSelection,W as SelectionLayer,X as SelectionPluginPackage,N as TextSelection,L as useSelectionCapability,k as useSelectionPlugin};
//# sourceMappingURL=react.mjs.map