import{s as e}from"./chunk-Bj-mKKzh.js";import{li as t}from"./src-BOCweS1p.js";import{n,t as r}from"./jsx-runtime-CiQ1k8xo.js";import{t as i}from"./clsx-BcPLHiun.js";import{lt as a}from"./vscode-api-DjORcpSo.js";import{t as o}from"./data-url-from-svg-CpQT-mD6.js";import{a as s}from"./browser-sidebar-comment-light-dismiss-CLd6tLoE.js";var c=a(),l=e(n(),1),u=[0,.25,.5,.75,1],d=100;function f(e){let t=(0,c.c)(19),{containerRef:n,pageSelector:r,totalPages:i}=e,[a,o]=(0,l.useState)(1),s=(0,l.useRef)(null),f=(0,l.useRef)(null),g=m(a,i),_,v;t[0]!==n||t[1]!==r||t[2]!==i?(_=()=>{let e=n.current;if(e==null||i<1||typeof IntersectionObserver>`u`)return;let t=p(e,r);if(t.length===0)return;let a=new Map,c=new IntersectionObserver(n=>{for(let e of n)a.set(e.target,e.intersectionRatio);let r=h({container:e,pageElements:t,pageVisibilityByElement:a});r!=null&&(s.current!=null&&r!==s.current||(r===s.current&&(s.current=null,f.current?.(),f.current=null),o(r)))},{root:e,threshold:u});for(let e of t)a.set(e,0),c.observe(e);let l=h({container:e,pageElements:t,pageVisibilityByElement:a});return l!=null&&o(l),()=>{c.disconnect(),s.current=null,f.current?.(),f.current=null}},v=[n,r,i],t[0]=n,t[1]=r,t[2]=i,t[3]=_,t[4]=v):(_=t[3],v=t[4]),(0,l.useEffect)(_,v);let y;t[5]!==n||t[6]!==r?(y=e=>{let t=n.current;if(t==null)return;let i=p(t,r).at(e-1);if(i==null)return;f.current?.(),f.current=null,s.current=e;let a=null,c=()=>{a!=null&&(clearTimeout(a),a=null),t.removeEventListener(`scroll`,u)},l=()=>{if(s.current!==e)return;s.current=null,c();let n=h({container:t,pageElements:p(t,r),pageVisibilityByElement:new Map});n!=null&&o(n)},u=()=>{a!=null&&clearTimeout(a),a=setTimeout(l,d)};f.current=c,i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e),u(),t.addEventListener(`scroll`,u)},t[5]=n,t[6]=r,t[7]=y):y=t[7];let b=y,x;t[8]!==g||t[9]!==b?(x=()=>{let e=g-1;e<1||b(e)},t[8]=g,t[9]=b,t[10]=x):x=t[10];let S=x,C;t[11]!==g||t[12]!==b||t[13]!==i?(C=()=>{let e=g+1;e>i||b(e)},t[11]=g,t[12]=b,t[13]=i,t[14]=C):C=t[14];let w=C,T;return t[15]!==g||t[16]!==w||t[17]!==S?(T={currentPage:g,goToNextPage:w,goToPreviousPage:S},t[15]=g,t[16]=w,t[17]=S,t[18]=T):T=t[18],T}function p(e,t){return Array.from(e.querySelectorAll(t))}function m(e,t){return Math.min(Math.max(e,1),Math.max(t,1))}function h({container:e,pageElements:t,pageVisibilityByElement:n}){if(t.length===0)return null;let r=0,i=-1;for(let[e,a]of t.entries()){let t=n.get(a)??0;t>i&&(i=t,r=e)}if(i>0)return r+1;let a=e.getBoundingClientRect().top,o=0,s=1/0;for(let[e,n]of t.entries()){let t=Math.abs(n.getBoundingClientRect().top-a);t<s&&(s=t,o=e)}return o+1}var g=`<svg
  width="26"
  height="25"
  viewBox="0 0 26 25"
  fill="none"
  xmlns="http://www.w3.org/2000/svg"
>
  <path
    d="M12.6504 0.824799C6.21496 0.824799 0.825466 5.77554 0.825195 12.0885C0.825245 14.2375 1.46183 16.2421 2.55176 17.943L2.02148 20.235L1.99316 20.3756C1.77603 21.655 2.78945 22.7791 4.02832 22.7691L4.0791 22.8209L4.53418 22.7047L7.12305 22.0426C8.77593 22.8778 10.6577 23.3531 12.6504 23.3531C19.086 23.3531 24.4754 18.4014 24.4756 12.0885C24.4753 5.77554 19.0858 0.824799 12.6504 0.824799Z"
    fill="currentColor"
    stroke="white"
    stroke-width="1.65"
  />
</svg>
`,_=`#2563eb`,v=o(g.replace(`currentColor`,_)),y=8,b=`top 0.2s cubic-bezier(0.165, 0.88, 0.44, 1), left 0.2s cubic-bezier(0.165, 0.88, 0.44, 1), width 0.2s cubic-bezier(0.165, 0.88, 0.44, 1), height 0.2s cubic-bezier(0.165, 0.88, 0.44, 1)`,x=`var(--color-text-accent, var(--color-accent-blue, ${_}))`,S=`color-mix(in srgb, var(--color-text-accent, var(--color-accent-blue, ${_})) 20%, transparent)`,C=_,w=`url("${v}") 13 12, crosshair`,T=t;function E(e){return e.key.toLowerCase()===`i`&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function D(e){return{x:e.x+e.width,y:e.y}}function ee(e){return{placement:`above`,point:O(e)}}function O(e){return{x:e.x+e.width/2,y:e.y}}function k(e){let t=e.getBoundingClientRect();return{height:e.offsetHeight||t.height,width:e.offsetWidth||t.width}}function A(e,t){e!=null&&(e.style.left=`${t.x}px`,e.style.top=`${t.y}px`)}function j({editorScale:e=1,layer:t,markerPoint:n,pageSize:r}){if(t==null||r.width<=0||r.height<=0)return null;let i=k(t);if(i.width<=0||i.height<=0)return null;let a=n.x/r.width*i.width,o=n.y/r.height*i.height,s=Math.max(e,2**-52),c=N(i.width,s),l=P(i.height,s),u=I(o-44*s/2,16,l),d=a+27,f=a-27-294*s;for(let e of[d,f])if(e>=16&&e<=c)return{x:e,y:F(u,s)};let p=I(a-294*s/2,16,c),m=o+27;return m<=l?{x:p,y:F(m,s)}:{x:p,y:F(I(o-27-120*s,16,l),s)}}function M({editorScale:e=1,layer:t,pageSize:n,rect:r}){if(t==null||n.width<=0||n.height<=0)return null;let i=k(t);if(i.width<=0||i.height<=0)return null;let a=r.y/n.height*i.height,o=(r.x+r.width)/n.width*i.width,s=(r.y+r.height)/n.height*i.height,c=Math.max(e,2**-52),l=N(i.width,c),u=P(i.height,c),d=s+y,f=a-y-120*c,p=d<=u?d:I(f,16,u);return{x:I(o-294*c,16,l),y:F(p,c)}}function N(e,t){return Math.max(16,e-294*t-16)}function P(e,t){return Math.max(16,e-120*t-16)}function F(e,t){let n=(T-120)*t;return e-Math.min(n,Math.max(e-16,0))}function I(e,t,n){return Math.min(Math.max(e,t),n)}var L=r(),R=e=>(0,L.jsx)(`svg`,{width:26,height:25,viewBox:`0 0 26 25`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,L.jsx)(`path`,{d:`M12.6504 0.824799C6.21496 0.824799 0.825466 5.77554 0.825195 12.0885C0.825245 14.2375 1.46183 16.2421 2.55176 17.943L2.02148 20.235L1.99316 20.3756C1.77603 21.655 2.78945 22.7791 4.02832 22.7691L4.0791 22.8209L4.53418 22.7047L7.12305 22.0426C8.77593 22.8778 10.6577 23.3531 12.6504 23.3531C19.086 23.3531 24.4754 18.4014 24.4756 12.0885C24.4753 5.77554 19.0858 0.824799 12.6504 0.824799Z`,fill:`currentColor`,stroke:`white`,strokeWidth:1.65})}),z=32,B=294,V=30,H=`var(--color-token-dropdown-background, var(--color-token-main-surface-primary, white))`,U=`var(--color-token-foreground, var(--color-token-text-primary, rgb(38, 38, 38)))`,W=`var(--color-token-border-default, var(--color-token-border-light, rgba(13, 13, 13, 0.08)))`,G={color:`white`,fontFamily:`var(--font-sans)`},K=`-apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Segoe UI", sans-serif`,q=`pointer-events-none absolute z-50 cursor-auto paged-annotation-editor-enter`;function J(e){let t=(0,c.c)(20),{anchor:n,label:r,onClick:i,pageSize:a,rect:o,testId:s,zoomScale:l}=e,u=l===void 0?1:l,d;t[0]!==n||t[1]!==o?(d=n??ee(o),t[0]=n,t[1]=o,t[2]=d):d=t[2];let f=d,p=f.point.x/a.width*100,m=f.alignment;m??=p<20?`start`:p>80?`end`:`center`;let h=`center`,g=`-50%`;m===`start`?(h=`left`,g=`0`):m===`end`&&(h=`right`,g=`-100%`);let _=1/Math.max(u,2**-52),v=6*_,y=_===1?``:` scale(${_})`,b=`${p}%`,x=`${f.point.y/a.height*100}%`,S=f.placement===`above`?`translate(${g}, calc(-100% - ${v}px))${y}`:`translate(${g}, ${v}px)${y}`,C=`${h} ${f.placement===`above`?`bottom`:`top`}`,w;t[3]!==b||t[4]!==x||t[5]!==S||t[6]!==C?(w={fontFamily:K,left:b,top:x,transform:S,transformOrigin:C},t[3]=b,t[4]=x,t[5]=S,t[6]=C,t[7]=w):w=t[7];let T;t[8]===i?T=t[9]:(T=e=>{e.preventDefault(),e.stopPropagation(),i()},t[8]=i,t[9]=T);let E;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(E={fontFamily:K},t[10]=E):E=t[10];let D;t[11]===r?D=t[12]:(D=(0,L.jsx)(`span`,{className:`inline-flex h-[18px] items-center text-[12px] leading-[18px] font-[400] tracking-[-0.3px]`,"data-paged-annotation-ask-for-edit-label":`true`,style:E,children:r}),t[11]=r,t[12]=D);let O;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex h-[18px] items-center rounded-full bg-[#efefef] px-[6px] text-[12px] leading-[18px] font-[500] tracking-[-0.3px] text-[#6b6b6b]`,"data-paged-annotation-ask-for-edit-shortcut":`true`,style:{fontFamily:K},children:ae()}),t[13]=O):O=t[13];let k;return t[14]!==r||t[15]!==D||t[16]!==w||t[17]!==T||t[18]!==s?(k=(0,L.jsxs)(`button`,{type:`button`,"aria-label":r,className:`pointer-events-auto absolute z-40 inline-flex h-6 min-w-max cursor-interaction items-center gap-2 rounded-full border-0 bg-white py-[3px] pr-[3px] pl-2 text-[12px] leading-[18px] font-normal tracking-[-0.3px] whitespace-nowrap text-black shadow-[0_8px_18px_-6px_rgba(0,0,0,0.55)] ring-[1px] ring-black/10 hover:bg-[color-mix(in_srgb,white_92%,var(--color-token-foreground)_8%)]`,"data-paged-annotation-ask-for-edit":`true`,"data-testid":s,style:w,onPointerDown:Y,onClick:T,children:[D,O]}),t[14]=r,t[15]=D,t[16]=w,t[17]=T,t[18]=s,t[19]=k):k=t[19],k}function Y(e){e.preventDefault(),e.stopPropagation()}function X(e){let t=(0,c.c)(9),{bordered:n,borderWidth:r,paddingPx:i,paddingX:a,paddingY:o,pageSize:s,rect:l,testId:u}=e,d=r===void 0?n!==void 0&&n?1:0:r,f=i===void 0?0:i,p=a===void 0?f:a,m=o===void 0?f:o,h=m===0?`${l.height/s.height*100}%`:`calc(${l.height/s.height*100}% + ${m*2}px)`,g=p===0?`${l.x/s.width*100}%`:`calc(${l.x/s.width*100}% - ${p}px)`,_=m===0?`${l.y/s.height*100}%`:`calc(${l.y/s.height*100}% - ${m}px)`,v=p===0?`${l.width/s.width*100}%`:`calc(${l.width/s.width*100}% + ${p*2}px)`,y;t[0]!==d||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y={backgroundColor:S,borderColor:x,borderStyle:`dashed`,borderWidth:d,height:h,left:g,top:_,transition:b,width:v},t[0]=d,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let C;return t[6]!==y||t[7]!==u?(C=(0,L.jsx)(`div`,{className:`pointer-events-none absolute box-border rounded-[4px]`,"data-testid":u,style:y}),t[6]=y,t[7]=u,t[8]=C):C=t[8],C}function Z(e){let t=(0,c.c)(8),{pageSize:n,rect:r,testId:i}=e,a=`${r.height/n.height*100}%`,o=`${r.x/n.width*100}%`,s=`${r.y/n.height*100}%`,l=`${r.width/n.width*100}%`,u;t[0]!==a||t[1]!==o||t[2]!==s||t[3]!==l?(u={backgroundColor:S,borderColor:x,borderStyle:`dashed`,borderWidth:2,height:a,left:o,top:s,width:l},t[0]=a,t[1]=o,t[2]=s,t[3]=l,t[4]=u):u=t[4];let d;return t[5]!==u||t[6]!==i?(d=(0,L.jsx)(`div`,{className:`pointer-events-none absolute box-border shadow-[inset_0_0_0_1px_rgba(255,255,255,0.28)]`,"data-testid":i,style:u}),t[5]=u,t[6]=i,t[7]=d):d=t[7],d}function Q(e){let t=(0,c.c)(23),{ariaLabel:n,draft:r,draftTestId:a,isSelected:o,label:s,onClick:l,onPreviewHide:u,onPreviewShow:d,pageSize:f,point:p,testId:m}=e,h=r===void 0?!1:r,g=o===void 0?!1:o,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,L.jsx)(R,{className:`absolute inset-0 size-full`}),t[0]=_):_=t[0];let v;t[1]===s?v=t[2]:(v=(0,L.jsxs)(L.Fragment,{children:[_,(0,L.jsx)(`span`,{className:`pointer-events-none relative z-10 -translate-x-px -translate-y-px font-sans text-[10px] leading-none font-bold text-white`,style:G,children:s})]}),t[1]=s,t[2]=v);let y=v,b=`${p.x/f.width*100}%`,S=`${p.y/f.height*100}%`,C;t[3]!==b||t[4]!==S?(C={color:x,height:30,left:b,top:S,width:30},t[3]=b,t[4]=S,t[5]=C):C=t[5];let w=C;if(!h&&d!=null&&u!=null){let e=g&&`scale-105`,r;t[6]===e?r=t[7]:(r=i(`pointer-events-auto absolute flex -translate-x-1/2 -translate-y-1/2 cursor-interaction items-center justify-center border-0 bg-transparent p-0 focus-visible:ring-2 focus-visible:ring-token-focus-border focus-visible:outline-none`,`font-sans`,e),t[6]=e,t[7]=r);let a;t[8]===l?a=t[9]:(a=e=>{e.preventDefault(),e.stopPropagation(),l?.()},t[8]=l,t[9]=a);let o;return t[10]!==n||t[11]!==y||t[12]!==u||t[13]!==d||t[14]!==w||t[15]!==a||t[16]!==r||t[17]!==m?(o=(0,L.jsx)(`button`,{type:`button`,"aria-label":n,className:r,"data-testid":m,style:w,onPointerDown:te,onMouseEnter:d,onMouseLeave:u,onFocus:d,onBlur:u,onClick:a,children:y}),t[10]=n,t[11]=y,t[12]=u,t[13]=d,t[14]=w,t[15]=a,t[16]=r,t[17]=m,t[18]=o):o=t[18],o}let T=h?a:void 0,E;return t[19]!==y||t[20]!==w||t[21]!==T?(E=(0,L.jsx)(`div`,{className:`pointer-events-none absolute flex -translate-x-1/2 -translate-y-1/2 items-center justify-center border-0 bg-transparent p-0 font-sans`,"data-testid":T,style:w,children:y}),t[19]=y,t[20]=w,t[21]=T,t[22]=E):E=t[22],E}function te(e){return e.stopPropagation()}function ne(e){let t=(0,c.c)(16),{body:n,layer:r,pageSize:i,point:a,testId:o}=e,[s,u]=(0,l.useState)(0),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=e=>{if(e==null)return;let t=e.offsetWidth;u(e=>e===t?e:t)},t[0]=d):d=t[0];let f=d,p;t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==s?(p=re({layer:r,pageSize:i,point:a,previewWidth:s}),t[1]=r,t[2]=i,t[3]=a,t[4]=s,t[5]=p):p=t[5];let m=p;if(m==null)return null;let h;t[6]===m?h=t[7]:(h={...m,backgroundColor:H,borderColor:W,color:U,height:z,width:`fit-content`,backdropFilter:`blur(8px)`,WebkitBackdropFilter:`blur(8px)`},t[6]=m,t[7]=h);let g;t[8]===n?g=t[9]:(g=ie(n),t[8]=n,t[9]=g);let _;t[10]===g?_=t[11]:(_=(0,L.jsx)(`div`,{className:`min-w-0 overflow-hidden leading-5 text-ellipsis whitespace-nowrap text-inherit`,children:g}),t[10]=g,t[11]=_);let v;return t[12]!==h||t[13]!==_||t[14]!==o?(v=(0,L.jsx)(`div`,{ref:f,className:`pointer-events-none absolute z-[5] flex items-center overflow-hidden rounded-lg border px-2 py-1 font-sans text-sm shadow-lg select-none`,"data-testid":o,style:h,children:_}),t[12]=h,t[13]=_,t[14]=o,t[15]=v):v=t[15],v}function re({layer:e,pageSize:t,point:n,previewWidth:r}){if(e==null||t.width<=0||t.height<=0)return null;let{height:i,width:a}=k(e),o=n.x/t.width*a,s=n.y/t.height*i,c=Math.min(B,Math.max(1,a-32)),l=V/2+12,u=(r===0?c:Math.min(r,c))/2,d=$(o,16+u,Math.max(16+u,a-16-u)),f=s-l-z;if(f>=16)return{left:d,maxWidth:c,top:f,transform:`translateX(-50%)`};let p=s+l;return p+z<=i-16?{left:d,maxWidth:c,top:p,transform:`translateX(-50%)`}:{left:d,maxWidth:c,top:$(f,16,Math.max(16,i-z-16)),transform:`translateX(-50%)`}}function ie(e){return s(e).map((e,t)=>{switch(e.type){case`text`:return e.text;case`mention`:return(0,L.jsx)(`strong`,{className:`font-semibold`,children:e.label},`paged-annotation-comment-preview-mention-${t}`)}})}function $(e,t,n){return Math.min(Math.max(e,t),n)}function ae(){return typeof navigator<`u`&&/Win|Linux/.test(navigator.platform)?`Ctrl I`:`⌘I`}export{Q as a,w as c,M as d,j as f,f as h,X as i,T as l,E as m,J as n,Z as o,D as p,ne as r,C as s,q as t,A as u};
//# sourceMappingURL=paged-annotation-comment-ui-BDYzLpKr.js.map