1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,581866,e=>{"use strict";let t=(0,e.i(456420).default)("file-x",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);e.s(["FileX",0,t],581866)},343558,e=>{"use strict";var t=e.i(271645);let r=(e,t,r)=>Math.min(r,Math.max(t,e));e.s(["APPROVAL_BAR_OFFSET_PX",0,80,"useZoomPan",0,function(e){let n=e?.wheelMode??"always",i=e?.autoRefitOnResize??!0,[o,a]=(0,t.useState)({scale:1,translateX:0,translateY:0}),l=(0,t.useRef)(!1),s=(0,t.useRef)({x:0,y:0}),c=(0,t.useRef)(!1),u=(0,t.useRef)(null),d=(0,t.useRef)(null),h=(0,t.useRef)(void 0),m=(0,t.useRef)(null),x=(0,t.useRef)(null),p=(0,t.useRef)(new Map),f=(0,t.useRef)({scale:1,translateX:0,translateY:0}),w=(0,t.useRef)(null),b=(0,t.useRef)(null),g=(0,t.useRef)(null),y=(0,t.useRef)(null),v=(0,t.useRef)(!1),k=(0,t.useRef)([]),j=(0,t.useRef)(0),C=(0,t.useRef)(0),N=(0,t.useRef)(null),M=(0,t.useRef)(!1),E=(0,t.useRef)(1),P=(0,t.useRef)(e);(0,t.useEffect)(()=>{P.current=e});let R=(0,t.useCallback)(()=>{let e=w.current;if(!e)return void a(e=>{let t=f.current;return e.scale===t.scale&&e.translateX===t.translateX&&e.translateY===t.translateY?e:{...t}});let t=f.current;e.style.transform=`translate3d(${t.translateX}px, ${t.translateY}px, 0) scale(${t.scale})`,E.current!==t.scale&&(E.current=t.scale,a(e=>e.scale===t.scale?e:{...e,scale:t.scale}))},[]),$=(0,t.useCallback)(()=>{j.current||(j.current=requestAnimationFrame(()=>{j.current=0,R()}))},[R]),L=(0,t.useCallback)(()=>{M.current=!1,a(e=>{let t=f.current;return e.scale===t.scale&&e.translateX===t.translateX&&e.translateY===t.translateY?e:{...t}})},[]),S=(0,t.useCallback)(()=>{C.current&&(cancelAnimationFrame(C.current),C.current=0)},[]);(0,t.useLayoutEffect)(()=>{M.current||(f.current={...o})},[o]),(0,t.useLayoutEffect)(()=>{M.current&&R()}),(0,t.useEffect)(()=>()=>{j.current&&cancelAnimationFrame(j.current),C.current&&cancelAnimationFrame(C.current)},[]);let T=(0,t.useCallback)(e=>{if(m.current&&(m.current(),m.current=null),u.current=e,!e)return;let t=t=>{let r=(4&t.buttons)!=0,i=t.ctrlKey||t.metaKey||r;if("ctrl-only"!==n||i)if(t.preventDefault(),i){let r=t.deltaY>0?-.1:.1;a(n=>{let i=Math.min(10,Math.max(.1,n.scale+r*n.scale)),o=e.getBoundingClientRect(),a=t.clientX-o.left,l=t.clientY-o.top,s=i/n.scale;return{scale:i,translateX:a-(a-n.translateX)*s,translateY:l-(l-n.translateY)*s}})}else a(e=>({...e,translateX:e.translateX-t.deltaX,translateY:e.translateY-t.deltaY}))};e.addEventListener("wheel",t,{passive:!1});let r=null;if(window.matchMedia?.("(max-width: 768px), (orientation: landscape) and (max-height: 500px)").matches&&i&&"u">typeof ResizeObserver){let t={w:0,h:0};(r=new ResizeObserver(()=>{let r=e.getBoundingClientRect(),n=Math.round(r.width),i=Math.round(r.height);if(n===t.w&&i===t.h||(t={w:n,h:i},n<80||i<80))return;let o=d.current;o&&x.current?.(o.width,o.height,h.current)})).observe(e)}let o=t=>{1===t.button&&"mouse"===t.pointerType&&(t.preventDefault(),S(),M.current&&L(),l.current=!0,c.current=!0,s.current={x:t.clientX,y:t.clientY},e.setPointerCapture(t.pointerId))};e.addEventListener("pointerdown",o,{capture:!0});let p=e=>{if(1!==e.button)return;let t=e.target;t&&"function"==typeof t.closest&&t.closest("a[href]")||e.preventDefault()};e.addEventListener("auxclick",p),m.current=()=>{e.removeEventListener("wheel",t),e.removeEventListener("pointerdown",o,{capture:!0}),e.removeEventListener("auxclick",p),r?.disconnect()}},[n,i,S,L]),A=(0,t.useCallback)(e=>{w.current=e},[]),z=(0,t.useCallback)(e=>{if("mouse"!==e.pointerType){S();let t=(P.current?.touchAction??"none")==="none"&&(P.current?.singlePointerPan?.()??!0);if(p.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),1===p.current.size)v.current=!1,b.current=u.current?.getBoundingClientRect()??null,y.current=t?{x:e.clientX,y:e.clientY}:null,k.current=t?[{x:e.clientX,y:e.clientY,t:performance.now()}]:[];else if(2===p.current.size){v.current=!0,b.current||(b.current=u.current?.getBoundingClientRect()??null);let[e,t]=[...p.current.values()];g.current={dist:Math.hypot(e.x-t.x,e.y-t.y),cx:(e.x+t.x)/2,cy:(e.y+t.y)/2},y.current=null,k.current=[],M.current=!0}return}1!==e.button&&(P.current?.singlePointerPan?.()??!0)&&0===e.button&&(l.current=!0,s.current={x:e.clientX,y:e.clientY},e.currentTarget.setPointerCapture(e.pointerId))},[S]),I=(0,t.useCallback)(e=>{if("mouse"!==e.pointerType){let t=p.current;if(!t.has(e.pointerId))return;t.set(e.pointerId,{x:e.clientX,y:e.clientY});let n=b.current;if(t.size>=2&&n){let[e,i]=[...t.values()],o=Math.hypot(e.x-i.x,e.y-i.y),a=(e.x+i.x)/2,l=(e.y+i.y)/2,s=g.current;if(!s||s.dist<=0||o<=0){g.current={dist:o,cx:a,cy:l};return}let c=f.current,u=r(o/s.dist,.5,2),d=r(c.scale*u,.1,10),h=d/c.scale,m=a-n.left,x=l-n.top,p=s.cx-n.left,w=s.cy-n.top;f.current={scale:d,translateX:m-(m-c.translateX)*h+(m-p),translateY:x-(x-c.translateY)*h+(x-w)},g.current={dist:o,cx:a,cy:l},M.current=!0,$();return}let i=y.current;if(!i)return;let o=f.current;f.current={scale:o.scale,translateX:o.translateX+(e.clientX-i.x),translateY:o.translateY+(e.clientY-i.y)},y.current={x:e.clientX,y:e.clientY};let a=performance.now();k.current.push({x:e.clientX,y:e.clientY,t:a}),k.current.length>8&&k.current.shift(),M.current=!0,$();return}if(c.current&&"number"==typeof e.buttons&&(4&e.buttons)==0){c.current=!1,l.current=!1;return}if(!l.current)return;let t=e.clientX-s.current.x,n=e.clientY-s.current.y;s.current={x:e.clientX,y:e.clientY},a(e=>({...e,translateX:e.translateX+t,translateY:e.translateY+n}))},[$]),F=(0,t.useCallback)(()=>
1{if(v.current||window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let e=k.current;if(e.length<2)return;let t=e[e.length-1],r=e.find(e=>t.t-e.t<=100)??e[0],n=t.t-r.t;if(n<=0)return;let i=(t.x-r.x)/n,o=(t.y-r.y)/n;if(.05>Math.hypot(i,o))return;M.current=!0;let a=()=>{if(i*=.94,o*=.94,.02>Math.hypot(i,o)){C.current=0,L();return}let e=f.current;f.current={scale:e.scale,translateX:e.translateX+16*i,translateY:e.translateY+16*o},R(),C.current=requestAnimationFrame(a)};C.current=requestAnimationFrame(a)},[R,L]),D=(0,t.useCallback)((e,t)=>{let n,i,o,a=b.current??u.current?.getBoundingClientRect();if(!a)return;let l=f.current,s=d.current,c=s?(n=h.current?.bottomOffset??0,i=Math.max(1,a.width-32),o=Math.max(1,a.height-32-n),Math.min(i/s.width,o/s.height,1)):1,m=r(l.scale<=1.05*c?2*c:c,.1,10),x=m/l.scale,p=e-a.left,w=t-a.top;f.current={scale:m,translateX:p-(p-l.translateX)*x,translateY:w-(w-l.translateY)*x},M.current=!0,R(),L()},[R,L]),X=(0,t.useCallback)(e=>{if(e&&"mouse"!==e.pointerType){let t=p.current;if(!t.delete(e.pointerId))return;if(t.size<2&&(g.current=null),1===t.size){let[e]=[...t.values()];y.current=(P.current?.touchAction??"none")==="none"&&(P.current?.singlePointerPan?.()??!0)?{...e}:null,k.current=[];return}if(0===t.size){let t=performance.now(),r=k.current,n=r.length>=2?Math.hypot(r[r.length-1].x-r[0].x,r[r.length-1].y-r[0].y):0,i=(P.current?.doubleTapZoom??!0)&&(P.current?.singlePointerPan?.()??!0)&&!v.current&&n<24,o=N.current;if(i&&o&&t-o.t<300&&24>Math.hypot(e.clientX-o.x,e.clientY-o.y)){N.current=null,D(e.clientX,e.clientY);return}N.current=i?{t:t,x:e.clientX,y:e.clientY}:null,F(),C.current||L(),y.current=null,b.current=null}return}l.current=!1,c.current=!1},[F,L,D]),U=(0,t.useCallback)(e=>{if("mouse"===e.pointerType){l.current=!1,c.current=!1;return}p.current.delete(e.pointerId),p.current.size<2&&(g.current=null),0===p.current.size&&(y.current=null,k.current=[],b.current=null,N.current=null,L())},[L]),Y={touchAction:e?.touchAction??"none"},B=(0,t.useCallback)(e=>{let t=u.current?.getBoundingClientRect();a(n=>{let i=r(n.scale*e,.1,10);if(!t)return{...n,scale:i};let o=i/n.scale,a=t.width/2,l=t.height/2;return{scale:i,translateX:a-(a-n.translateX)*o,translateY:l-(l-n.translateY)*o}})},[]),H=(0,t.useCallback)((e,t,r)=>{let n=u.current;if(!n||e<=0||t<=0)return;let i=n.getBoundingClientRect();if(0===i.width||0===i.height)return;let o=r?.bottomOffset??0,l=Math.min(Math.max(1,i.width-32)/e,Math.max(1,i.height-32-o)/t,1),s=e*l,c=t*l;a({scale:l,translateX:(i.width-s)/2,translateY:(i.height-o-c)/2}),d.current={width:e,height:t},h.current=r},[]);(0,t.useEffect)(()=>{x.current=H},[H]);let O=(0,t.useCallback)((e,t,r,n)=>{if(!r||e<=0||t<=0)return;let i=r.getBoundingClientRect();if(0===i.width||0===i.height)return;let o=n?.bottomOffset??0,l=Math.min(Math.max(1,i.width-32)/e,Math.max(1,i.height-32-o)/t,1),s=e*l,c=t*l;a({scale:l,translateX:(i.width-s)/2,translateY:(i.height-o-c)/2}),d.current={width:e,height:t},h.current=n},[]),W=(0,t.useCallback)(()=>{let e=d.current;e?H(e.width,e.height,h.current):a({scale:1,translateX:0,translateY:0})},[H]),_=(0,t.useCallback)((e,t,r,n,i)=>{let o=i?.getBoundingClientRect();if(!o||o.width<=0||o.height<=0||e<=0||t<=0)return;let l=Math.min(1,Math.max(o.width/e,o.height/t));a({scale:l,translateX:o.width/2-e*r/100*l,translateY:o.height/2-t*n/100*l}),d.current={width:e,height:t}},[]);return{...o,transform:`translate(${o.translateX}px, ${o.translateY}px) scale(${o.scale})`,wheelRef:T,contentRef:A,containerStyle:Y,onPointerDown:z,onPointerMove:I,onPointerUp:X,onPointerCancel:U,zoomBy:B,resetView:W,fitToViewport:H,fitToViewportWith:O,focusPointWith:_}}])},112175,e=>{"use strict";var t=e.i(843476);e.s(["GhostSuggestion",0,function({suggestion:e,strokeWidth:r=.3}){return e?"pin"===e.type?(0,t.jsx)("div",{className:"absolute rounded-full pointer-events-none animate-[fadeIn_0.2s_ease-out]",style:{left:`${e.position.x}%`,top:`${e.position.y}%`,transform:"translate(-50%, -50%)",width:36,height:36,border:`2px dashed ${e.color}`,backgroundColor:`${e.color}30`,boxShadow:`0 0 0 4px ${e.color}15`}}):"rect"===e.type&&e.rect?(0,t.jsx)("div",{className:"absolute pointer-events-none animate-[fadeIn_0.2s_ease-out]",style:{left:`${e.rect.x}%`,top:`${e.rect.y}%`,width:`${e.rect.width}%`,height:`${e.rect.height}%`,border:`2px dashed ${e.color}`,backgroundColor:`${e.color}20`,boxShadow:`0 0 0 4px ${e.color}15`}}):"arrow"===e.type&&e.arrowEnd?(0,t.jsxs)("svg",{className:"absolute inset-0 w-full h-full pointer-events-none animate-[fadeIn_0.2s_ease-out]",children:[(0,t.jsx)("defs",{children:(0,t.jsx)("marker",{id:"ai-preview-arrowhead-ghost",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",children:(0,t.jsx)("polygon",{points:"0 0, 10 3.5, 0 7",fill:e.color,opacity:.7})})}),(0,t.jsx)("line",{x1:`${e.position.x}%`,y1:`${e.position.y}%`,x2:`${e.arrowEnd.x}%`,y2:`${e.arrowEnd.y}%`,stroke:e.color,strokeWidth:6*r,strokeDasharray:"6,4",opacity:.7,markerEnd:"url(#ai-preview-arrowhead-ghost)"})]}):"freehand"===e.type&&e.strokePath?(0,t.jsx)("svg",{className:"absolute inset-0 w-full h-full pointer-events-none animate-[fadeIn_0.2s_ease-out]",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:(0,t.jsx)("path",{d:e.strokePath,fill:"none",stroke:e.color,strokeWidth:1.2*r,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"2,1",opacity:.7})}):null:null}])},719478,998668,852156,672445,742604,e=>{"use strict";var t=e.i(843476);let r={onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation()};e.s(["stopZoomCapture",0,r],998668);var n=e.i(457229);function i({annotation:e,currentVersionId:r,versionNumberMap:o,variant:a="overlay",position:l}){let{t:s}=(0,n.useTranslation)();if(e.versionId===r)return null;
1let c=o.get(e.versionId),u=void 0!==c?`v${c}`:"v?",d="text-[9px] font-mono leading-none px-1 py-0.5 rounded shadow-sm pointer-events-none select-none bg-brown-200/90 text-brown-800 dark:bg-brown-700/90 dark:text-brown-100 wire:bg-transparent wire:border wire:border-white/40 wire:text-white/80";return"overlay"===a?(0,t.jsx)("span",{className:`absolute -top-1.5 -right-2 z-10 ${d}`,title:s("annotations.pastVersionBadge.title",{version:u}),children:u}):l?(0,t.jsx)("span",{className:`absolute -translate-y-full -translate-x-1/2 z-10 ${d}`,style:{left:`${l.x}%`,top:`${l.y}%`},title:s("annotations.pastVersionBadge.title",{version:u}),children:u}):null}e.s(["PinMarker",0,function({annotation:e,index:n,selected:o,onClick:a,onDragStart:l,onTouchDragStart:s,onContextMenu:c,bouncing:u,currentVersionId:d,versionNumberMap:h,zoomScale:m=1}){let x=!!e.pinIcon,p=!!d&&e.versionId!==d,f=e.resolved&&p?"opacity-30":e.resolved?"opacity-50":p?"opacity-60":"";return(0,t.jsx)("div",{className:"absolute pointer-events-none",style:{left:`${e.position.x}%`,top:`${e.position.y}%`,transform:`translate(-50%, -50%) scale(${m>0?1/m:1})`,transformOrigin:"center"},children:(0,t.jsxs)("button",{...r,onClick:e=>{e.stopPropagation(),a()},onMouseDown:l,onPointerDown:s,onContextMenu:c,className:`relative pointer-events-auto flex items-center justify-center shadow-lg cursor-pointer ${u?"transition-[opacity,box-shadow] animate-annotation-bounce":"transition-[transform,opacity,box-shadow] hover:scale-125 hover:shadow-xl"} ${x?"w-9 h-9 rounded-lg":"w-8 h-8 rounded-full text-white text-xs font-bold"} ${o?"ring-2 ring-accent ring-offset-2 ring-offset-transparent scale-110":""} ${f}`,style:{backgroundColor:x?`${e.color}30`:e.color,borderColor:e.color,borderWidth:2*!!x,boxShadow:`0 2px 8px ${e.color}60`},title:`#${n+1} â ${e.createdByName}`,children:[x?(0,t.jsx)("span",{className:"text-lg leading-none select-none",children:e.pinIcon}):n+1,p&&h&&d&&(0,t.jsx)(i,{annotation:e,currentVersionId:d,versionNumberMap:h,variant:"overlay"})]},u?`b-${e.id}`:`s-${e.id}`)})}],719478);var o=e.i(271645);function a({index:e,color:r,bouncing:n,position:i,pointerEvents:o="none",size:l="sm"}){return(0,t.jsx)("span",{className:`absolute -translate-x-1/2 -translate-y-1/2 z-10 rounded-full flex items-center justify-center font-bold text-white shadow-md ring-2 ring-white/80 dark:ring-brown-900/80 wire:ring-black/80 ${"md"===l?"w-7 h-7 text-xs":"w-5 h-5 text-[10px]"} ${n?"animate-annotation-bounce":"transition-transform duration-150 group-hover:scale-125 hover:scale-125"}`,style:{left:`${i.x}%`,top:`${i.y}%`,backgroundColor:r,pointerEvents:o,boxShadow:`0 2px 6px ${r}80`},"aria-label":`#${e+1}`,children:e+1},n?`b-${e}`:`s-${e}`)}let l={nw:{className:"top-0 left-0 -translate-x-1/2 -translate-y-1/2",cursor:"nw-resize"},n:{className:"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2",cursor:"n-resize"},ne:{className:"top-0 right-0 translate-x-1/2 -translate-y-1/2",cursor:"ne-resize"},e:{className:"top-1/2 right-0 translate-x-1/2 -translate-y-1/2",cursor:"e-resize"},se:{className:"bottom-0 right-0 translate-x-1/2 translate-y-1/2",cursor:"se-resize"},s:{className:"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2",cursor:"s-resize"},sw:{className:"bottom-0 left-0 -translate-x-1/2 translate-y-1/2",cursor:"sw-resize"},w:{className:"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2",cursor:"w-resize"}};e.s(["RectOverlay",0,function({annotation:e,index:n,selected:s,onClick:c,onDragStart:u,onTouchDragStart:d,onResize:h,onContextMenu:m,bouncing:x,currentVersionId:p,versionNumberMap:f}){let[,w]=(0,o.useState)(null),b=(0,o.useRef)(null),g=(0,o.useRef)(e),y=(0,o.useRef)(h);(0,o.useEffect)(()=>{g.current=e,y.current=h});let v=(0,o.useCallback)((e,t,r="mouse")=>{if(e.stopPropagation(),e.preventDefault(),!g.current.rect||null!==b.current)return;let n=e.currentTarget.closest("div[data-annotation-layer]");if(!n)return;let i=n.getBoundingClientRect();b.current={x:(e.clientX-i.left)/i.width*100,y:(e.clientY-i.top)/i.height*100,rect:{...g.current.rect}},w(t);let o=e=>{if(!b.current)return;let r=n.getBoundingClientRect(),i=(e.clientX-r.left)/r.width*100,o=(e.clientY-r.top)/r.height*100,a=i-b.current.x,l=o-b.current.y,s={...b.current.rect};switch(t){case"nw":s.x=Math.max(0,b.current.rect.x+a),s.y=Math.max(0,b.current.rect.y+l),s.width=b.current.rect.width-a,s.height=b.current.rect.height-l;break;case"n":s.y=Math.max(0,b.current.rect.y+l),s.height=b.current.rect.height-l;break;case"ne":s.y=Math.max(0,b.current.rect.y+l),s.width=b.current.rect.width+a,s.height=b.current.rect.height-l;break;case"e":s.width=b.current.rect.width+a;break;case"se":s.width=b.current.rect.width+a,s.height=b.current.rect.height+l;break;case"s":s.height=b.current.rect.height+l;break;case"sw":s.x=Math.max(0,b.current.rect.x+a),s.width=b.current.rect.width-a,s.height=b.current.rect.height+l;break;case"w":s.x=Math.max(0,b.current.rect.x+a),s.width=b.current.rect.width-a}s.width<2&&(s.width=2),s.height<2&&(s.height=2),s.x+s.width>100&&(s.width=100-s.x),s.y+s.height>100&&(s.height=100-s.y),y.current?.(s)},a="pointer"===r?"pointermove":"mousemove",l="pointer"===r?"pointerup":"mouseup",s=()=>{document.removeEventListener(a,o),document.removeEventListener(l,s),"pointer"===r&&document.removeEventListener("pointercancel",s),w(null),b.current=null};document.addEventListener(a,o),document.addEventListener(l,s),"pointer"===r&&document.addEventListener("pointercancel",s)},[]);if(!e.rect)return null;let k=!!p&&e.versionId!==p,j=e.resolved&&k?"opacity-25":e.resolved?"opacity-40":k?"opacity-60":"";return(0,t.jsxs)("div",{...r,className:`group absolute border-2 transition-[opacity,background-color] ${s?"ring-2 ring-accent ring-offset-1 ring-offset-transparent":""} ${j}`,style:{left:`${e.rect.x}%`,top:`${e.rect.y}%`,width:`${e.rect.width}%`,height:`${e.rect.height}%`,borderColor:e.color,backgroundColor:s?`${e.color}55`:`${e.color}14`},children:[(0,t.jsx)("button",{...r,onClick:e=>{e.stopPropagation(),c()},onMouseDown:u,onPointerDown:d,onContextMenu:m,className:"absolute inset-0 cursor-pointer hover:brightness-110 pointer-events-auto"}),s&&h&&(0,t.jsx)(t.Fragment,{children:Object.keys(l).map(n=>(0,t.jsx)("button",{...r,onMouseDown:e=>v(e,n,"mouse"),onPointerDown:e=>{e.stopPropagation(),"mouse"!==e.pointerType&&v(e,n,"pointer")},className:`absolute w-2 h-2 border-2 rounded-full hover:brightness-125 transition-all pointer-events-auto ${l[n].className}`,style:{borderColor:e.color,backgroundColor:`${e.color}66`,cursor:l[n].cursor},"aria-label":`Resize ${n}`},n))}),(0,t.jsx)(a,{index:n,color:e.color,bouncing:x,position:{x:0,y:0},size:"md"}),k&&f&&p&&(0,t.jsx)(i,{annotation:e,currentVersionId:p,versionNumberMap:f,variant:"overlay"})]})}],852156),e.s(["ArrowLine",0,function({annotation:e,index:n,selected:o,onClick:l,onDragStart:s,onTouchDragStart:c,onContextMenu:u,bouncing:d,currentVersionId:h,versionNumberMap:m}){if(!e.arrowEnd)return null;let{x:x,y:p}=e.position,{x:f,y:w}=e.arrowEnd,b=!!h&&e.versionId!==h,g=e.resolved&&b?"opacity-25":e.resolved?"opacity-40":b?"opacity-60":"";return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{className:`absolute inset-0 w-full h-full pointer-events-none ${g}`,style:{overflow:"visible"},children:[(0,t.jsx)("defs",{children:(0,t.jsx)("marker",{id:`arrowhead-${e.id}`,markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",children:(0,t.jsx)("polygon",{points:"0 0, 10 3.5, 0 7",fill:e.color})})}),(0,t.jsx)("line",{x1:`${x}%`,y1:`${p}%`,x2:`${f}%`,y2:`${w}%`,stroke:"transparent",strokeWidth:16,className:"cursor-pointer pointer-events-auto",...r,onClick:e=>{e.stopPropagation(),l()},onMouseDown:s,onPointerDown:c,onContextMenu:u}),(0,t.jsx)("line",{x1:`${x}%`,y1:`${p}%`,x2:`${f}%`,y2:`${w}%`,stroke:e.color,strokeWidth:o?(e.strokeWidth??2)*1.4:e.strokeWidth??2,markerEnd:`url(#arrowhead-${e.id})`,className:"pointer-events-none"})]}),(0,t.jsx)("div",{className:g,children:(0,t.jsx)(a,{index:n,color:e.color,bouncing:d,position:{x:x,y:p},size:"md"})}),b&&m&&h&&(0,t.jsx)(i,{annotation:e,currentVersionId:h,versionNumberMap:m,variant:"absolute",position:{x:x,y:p}})]})}],672445),e.s(["FreehandPath",0,function({annotation:e,index:n,selected:o,onClick:l,onDragStart:s,onTouchDragStart:c,onContextMenu:u,bouncing:d,currentVersionId:h,versionNumberMap:m}){let x;if(!e.strokePath)return null;let p=(x=e.strokePath.match(/M\s*([\d.]+)[,\s]+([\d.]+)/))?{x:parseFloat(x[1]),y:parseFloat(x[2])}:null,f=!!h&&e.versionId!==h,w=e.resolved&&f?"opacity-25":e.resolved?"opacity-40":f?"opacity-60":"";return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{className:`absolute inset-0 w-full h-full pointer-events-none ${w}`,viewBox:"0 0 100 100",preserveAspectRatio:"none",children:[(0,t.jsx)("path",{d:e.strokePath,fill:"none",stroke:"transparent",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"cursor-pointer pointer-events-auto",...r,onClick:e=>{e.stopPropagation(),l()},onMouseDown:s,onPointerDown:c,onContextMenu:u}),(0,t.jsx)("path",{d:e.strokePath,fill:"none",stroke:e.color,strokeWidth:o?(e.strokeWidth??.3)*1.4:e.strokeWidth??.3,strokeLinecap:"round",strokeLinejoin:"round",className:"pointer-events-none"})]}),p&&(0,t.jsx)("div",{className:w,children:(0,t.jsx)(a,{index:n,color:e.color,bouncing:d,position:p,size:"md"})}),p&&f&&m&&h&&(0,t.jsx)(i,{annotation:e,currentVersionId:h,versionNumberMap:m,variant:"absolute",position:p})]})}],742604)},849487,634236,827427,103819,148077,e=>{"use strict";let t=(0,e.i(456420).default)("highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);e.s(["Highlighter",0,t],849487);var r=e.i(10552),n=(e,t=0)=>{let r=[];return!e.children.length||t>
120||Array.from(e.children).forEach(e=>{"SPAN"===e.tagName?r.push(e):e.children.length&&r.push(...n(e,t+1))}),r},i=r.Mark.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{},mergeNestedSpanStyles:!0}),parseHTML(){return[{tag:"span",consuming:!1,getAttrs:e=>{var t;return!!e.hasAttribute("style")&&(this.options.mergeNestedSpanStyles&&(t=e).children.length&&n(t).forEach(e=>{var t,r;let n=e.getAttribute("style"),i=null==(r=null==(t=e.parentElement)?void 0:t.closest("span"))?void 0:r.getAttribute("style");e.setAttribute("style",`${i};${n}`)}),{})}}]},renderHTML({HTMLAttributes:e}){return["span",(0,r.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{let{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(e=>e.type===this.type).some(e=>Object.values(e.attrs).some(e=>!!e))||e.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),o=r.Extension.create({name:"backgroundColor",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{var t;let n=null!=(t=(0,r.getStyleProperty)(e,"background-color"))?t:e.style.backgroundColor;return null==n?void 0:n.replace(/['"]+/g,"")},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands:()=>({setBackgroundColor:e=>({chain:t})=>t().setMark("textStyle",{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()})}),a=r.Extension.create({name:"color",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;let n=null!=(t=(0,r.getStyleProperty)(e,"color"))?t:e.style.color;return null==n?void 0:n.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands:()=>({setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()})}),l=r.Extension.create({name:"fontFamily",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>{var t;return null!=(t=(0,r.getStyleProperty)(e,"font-family"))?t:e.style.fontFamily},renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands:()=>({setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()})}),s=r.Extension.create({name:"fontSize",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>{var t;return null!=(t=(0,r.getStyleProperty)(e,"font-size"))?t:e.style.fontSize},renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands:()=>({setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()})}),c=r.Extension.create({name:"lineHeight",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>{var t;return null!=(t=(0,r.getStyleProperty)(e,"line-height"))?t:e.style.lineHeight},renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands:()=>({setLineHeight:e=>({chain:t})=>t().setMark("textStyle",{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()})});r.Extension.create({name:"textStyleKit",addExtensions(){let e=[];return!1!==this.options.backgroundColor&&e.push(o.configure(this.options.backgroundColor)),!1!==this.options.color&&e.push(a.configure(this.options.color)),!1!==this.options.fontFamily&&e.push(l.configure(this.options.fontFamily)),!1!==this.options.fontSize&&e.push(s.configure(this.options.fontSize)),!1!==this.options.lineHeight&&e.push(c.configure(this.options.lineHeight)),!1!==this.options.textStyle&&e.push(i.configure(this.options.textStyle)),e}}),e.s(["Color",0,a,"TextStyle",0,i],634236),e.s([],827427);var u=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,d=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,h=r.Mark.create({name:"highlight",addOptions:()=>({multicolor:!1,HTMLAttributes:{}}),addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||(0,r.getStyleProperty)(e,"background-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML:()=>[{tag:"mark"}],renderHTML({HTMLAttributes:e}){return["mark",(0,r.mergeAttributes)(this.options.HTMLAttributes,e),0]},renderMarkdown:(e,t)=>`==${t.renderChildren(e)}==`,parseMarkdown:(e,t)=>t.applyMark("highlight",t.parseInline(e.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:e=>e.indexOf("=="),tokenize(e,t,r){let n=/^(==)([^=]+)(==)/.exec(e);if(n){let e=n[2].trim(),t=r.inlineTokens(e);return{type:"highlight",raw:n[0],text:e,tokens:t}}}},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}}
1,addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[(0,r.markInputRule)({find:u,type:this.type})]},addPasteRules(){return[(0,r.markPasteRule)({find:d,type:this.type})]}});e.s(["Highlight",0,h],103819),e.s(["nanoid",0,(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&r[e]];return t}],148077)},168633,e=>{"use strict";var t=e.i(308668);let r=(0,t.typesForChannel)("ui"),n=new Set(r.flatMap(e=>[e.mime,...e.aliasMimes])),i=(0,t.acceptAttribute)(r);function o(e){let r=(0,t.normalizeMime)(e);return!!r&&n.has(r)}e.s(["ATTACHMENT_ACCEPT",0,i,"ATTACHMENT_MAX_COUNT",0,10,"isPreviewableAttachmentMime",0,function(e){let r=(0,t.resolveType)(e);return!!r&&!!o(e)&&(0,t.isInlineViewable)(r)},"validateAttachmentFile",0,function(e){var r;let n;if(0===e.size)return{ok:!1,reason:"ãã¡ã¤ã«ã空ã§ãï¼0 ãã¤ãï¼"};if(!o(e.type))return{ok:!1,reason:"対å¿ãã¦ããªããã¡ã¤ã«å½¢å¼ã§ã"};let{limit:i,label:a}=(r=e.type,{limit:n=Math.min((0,t.maxBytesFor)(r),0x1400000),label:(0,t.maxBytesLabel)(n)});return e.size>i?{ok:!1,reason:`ãã¡ã¤ã«ãµã¤ãºãä¸éï¼${a}ï¼ãè¶
ãã¦ãã¾ã`}:{ok:!0}}])},829600,575780,e=>{"use strict";var t=e.i(456420);let r=(0,t.default)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]);e.s(["File",0,r],829600);let n=(0,t.default)("file-image",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);e.s(["FileImage",0,n],575780)},405121,e=>{"use strict";e.s(["AttachmentChip",()=>b,"AttachmentList",()=>y]);var t=e.i(843476),r=e.i(271645),n=e.i(829600),i=e.i(226091),o=e.i(575780),a=e.i(632781),l=e.i(741120),s=e.i(263676),c=e.i(998668),u=e.i(959141),d=e.i(168633),h=e.i(308668),m=e.i(505973),x=e.i(457229);function p(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}let f="w-3.5 h-3.5 shrink-0 text-brown-500 dark:text-brown-300 wire:text-white/60";function w(e){return e.startsWith("image/")?(0,t.jsx)(o.FileImage,{className:f}):(0,h.isPdfMime)(e)||e.startsWith("text/")?(0,t.jsx)(i.FileText,{className:f}):(0,t.jsx)(n.File,{className:f})}function b({attachment:e,onRemove:r,onRetry:n,previewUrl:i}){let{t:u}=(0,x.useTranslation)(),d=e.mimeType.startsWith("image/"),h=w(e.mimeType),m="error"===e.status,f="uploading"===e.status;return d?(0,t.jsxs)("div",{...c.stopZoomCapture,className:`relative w-12 h-12 shrink-0 rounded-lg border overflow-hidden group ${m?"border-red-400 wire:border-red-300":"border-brown-200 dark:border-brown-700 wire:border-white/20"}`,children:[i?(0,t.jsx)("img",{src:i,alt:e.fileName,className:"w-full h-full object-cover"}):(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center bg-brown-50 dark:bg-brown-800 wire:bg-white/5",children:(0,t.jsx)(o.FileImage,{className:"w-5 h-5 text-brown-400 dark:text-brown-500 wire:text-white/40"})}),f&&(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:(0,t.jsx)(a.Loader2,{className:"w-4 h-4 text-white animate-spin"})}),m&&n&&(0,t.jsx)("button",{type:"button",...c.stopZoomCapture,onClick:e=>{e.stopPropagation(),n()},className:"absolute inset-0 flex items-center justify-center bg-red-500/40 text-white",title:e.error||u("comments.attachment.retry"),children:(0,t.jsx)(l.RefreshCw,{className:"w-4 h-4"})}),r&&!f&&(0,t.jsx)("button",{type:"button",...c.stopZoomCapture,onClick:e=>{e.stopPropagation(),r()},className:"absolute top-0 right-0 w-4 h-4 rounded-bl-md bg-black/60 hover:bg-red-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity","aria-label":u("comments.attachment.removeNamed",{name:e.fileName}),children:(0,t.jsx)(s.X,{className:"w-3 h-3"})})]}):(0,t.jsxs)("div",{...c.stopZoomCapture,className:`flex items-center gap-1.5 px-2 py-1 rounded-lg border text-[11px] max-w-[180px] group ${m?"border-red-400 bg-red-50 dark:bg-red-900/20 wire:bg-red-500/10 wire:border-red-300":"border-brown-200 dark:border-brown-700 wire:border-white/20 bg-brown-100 dark:bg-brown-800 wire:bg-white/10"}`,children:[h,(0,t.jsxs)("div",{className:"flex flex-col min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"truncate text-brown-800 dark:text-brown-100 wire:text-white",title:e.fileName,children:e.fileName}),(0,t.jsx)("span",{className:"text-[10px] text-brown-400 dark:text-brown-500 wire:text-white/40",children:f?`${e.progress}%`:m?e.error||u("comments.attachment.error"):p(e.fileSize)})]}),f&&(0,t.jsx)(a.Loader2,{className:"w-3 h-3 shrink-0 text-brown-500 wire:text-white/60 animate-spin"}),m&&n&&(0,t.jsx)("button",{type:"button",...c.stopZoomCapture,onClick:e=>{e.stopPropagation(),n()},className:"p-0.5 rounded hover:bg-red-100 dark:hover:bg-red-900/40 wire:hover:bg-red-500/20","aria-label":u("comments.attachment.retry"),children:(0,t.jsx)(l.RefreshCw,{className:"w-3 h-3 text-red-500"})}),r&&!f&&(0,t.jsx)("button",{type:"button",...c.stopZoomCapture,onClick:e=>{e.stopPropagation(),r()},className:"p-0.5 rounded hover:bg-red-100 dark:hover:bg-red-900/40 wire:hover:bg-red-500/20","aria-label":u("common.delete"),children:(0,t.jsx)(s.X,{className:"w-3 h-3 text-brown-500 dark:text-brown-300 wire:text-white/60"})})]})}function g(e){return"string"==typeof e&&e.startsWith("r2://")&&!e.includes("..")}function y({attachments:e,sessionId:n}){let{t:i}=(0,x.useTranslation)(),o=(0,r.useMemo)(()=>e.map((e,t)=>({att:e,originalIndex:t})).filter(({att:e})=>(0,d.isPreviewableAttachmentMime)(e.mimeType)&&g(e.fileURL)),[e]),[a,l]=(0,r.useState)(new Map),s=(0,r.useMemo)(()=>o.filter(({att:e})=>e.mimeType.startsWith("image/")).map(({att:e})=>e.fileURL).join("|"),[o]);(0,r.useEffect)(()=>{let e=!1;return o.filter(({att:e})=>
1e.mimeType.startsWith("image/")).forEach(({att:t})=>{l(e=>(e.has(t.fileURL),e)),k(t.fileURL,n).then(r=>{e||l(e=>{if(e.has(t.fileURL))return e;let n=new Map(e);return n.set(t.fileURL,r),n})}).catch(()=>{e||l(e=>{if(e.has(t.fileURL))return e;let r=new Map(e);return r.set(t.fileURL,null),r})})}),()=>{e=!0}},[s,n]);let c=(0,m.useLightbox)(),u=(0,r.useCallback)(e=>{let t=o.map(({att:e})=>{if(e.mimeType.startsWith("image/")){let t=a.get(e.fileURL);if(void 0!==t)return{signedUrl:t,fileName:e.fileName,mimeType:e.mimeType,error:null==t?i("comments.attachment.imageFetchFailed"):null}}return{signedUrl:null,fileName:e.fileName,mimeType:e.mimeType}}),r=c.open(t,e);t.forEach((e,t)=>{if(null!==e.signedUrl||e.error)return;let a=o[t].att;k(a.fileURL,n).then(e=>{c.patchItem(r,t,{signedUrl:e}),a.mimeType.startsWith("image/")&&l(t=>{if(t.has(a.fileURL))return t;let r=new Map(t);return r.set(a.fileURL,e),r})}).catch(()=>{c.patchItem(r,t,{error:i("comments.attachment.previewFetchFailed")})})})},[o,a,n,i,c]);return(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:e.map(e=>{let r=o.findIndex(t=>t.att.fileURL===e.fileURL),i=r>=0,l=e.mimeType.startsWith("image/")?a.get(e.fileURL)??null:null;return(0,t.jsx)(v,{attachment:e,sessionId:n,isPreviewable:i,preSignedUrl:l,onPreviewClick:i?()=>u(r):void 0},e.fileURL)})})}function v({attachment:e,sessionId:n,isPreviewable:i,preSignedUrl:l,onPreviewClick:s}){let{t:u}=(0,x.useTranslation)(),d=e.mimeType.startsWith("image/"),h=g(e.fileURL),m=d&&h&&i&&null==l,f=(0,r.useCallback)(async()=>{if(h)try{let t=await k(e.fileURL,n);window.open(t,"_blank","noopener,noreferrer")}catch(e){console.error("[AttachmentDisplay] signed-read åå¾å¤±æ:",e)}},[e.fileURL,h,n]),b=(0,r.useCallback)(e=>{e.stopPropagation(),i&&s?s():f()},[f,i,s]);if(!h)return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-lg border border-red-300 bg-red-50 dark:bg-red-900/20 wire:bg-red-500/10 text-[11px] text-red-700 dark:text-red-300 wire:text-red-300",children:["â ",u("comments.attachment.invalid",{name:e.fileName})]});if(d)return(0,t.jsx)("button",{type:"button",...c.stopZoomCapture,onClick:b,className:"block w-20 h-20 rounded-lg overflow-hidden border border-brown-200 dark:border-brown-700 wire:border-white/20 hover:ring-2 hover:ring-accent transition-all",title:e.fileName,children:l?(0,t.jsx)("img",{src:l,alt:e.fileName,className:"w-full h-full object-cover"}):(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center bg-brown-50 dark:bg-brown-800 wire:bg-white/5",children:m?(0,t.jsx)(a.Loader2,{className:"w-4 h-4 text-brown-400 wire:text-white/40 animate-spin"}):(0,t.jsx)(o.FileImage,{className:"w-5 h-5 text-brown-400 wire:text-white/40"})})});let y=w(e.mimeType);return(0,t.jsxs)("button",{type:"button",...c.stopZoomCapture,onClick:b,className:"flex items-center gap-1.5 px-2 py-1 rounded-lg border border-brown-200 dark:border-brown-700 wire:border-white/20 bg-brown-100 dark:bg-brown-800 wire:bg-white/10 hover:bg-brown-200 dark:hover:bg-brown-700 wire:hover:bg-white/20 text-[11px] max-w-[200px] transition-colors",title:e.fileName,children:[y,(0,t.jsx)("span",{className:"truncate text-brown-800 dark:text-brown-100 wire:text-white",children:e.fileName}),(0,t.jsx)("span",{className:"text-[10px] text-brown-400 dark:text-brown-500 wire:text-white/40 shrink-0",children:p(e.fileSize)})]})}async function k(e,t){if(t){let r=await fetch(`/api/guest/signed-read?sessionId=${encodeURIComponent(t)}&path=${encodeURIComponent(e)}`);
1if(!r.ok)throw Error("signed-read 失æ");return(await r.json()).url}let r=await u.auth.currentUser?.getIdToken();if(!r)throw Error("ãã°ã¤ã³ãå¿
è¦ã§ã");let n=await fetch(`/api/storage/signed-read?path=${encodeURIComponent(e)}`,{headers:{Authorization:`Bearer ${r}`}});if(!n.ok)throw Error("signed-read 失æ");return(await n.json()).url}},990677,316972,129755,e=>{"use strict";e.s(["RichCommentInput",()=>v],990677);var t=e.i(843476),r=e.i(271645),n=e.i(849487),i=e.i(64801),o=e.i(77071),a=e.i(494499),l=e.i(256378),s=e.i(76399),c=e.i(963612),u=e.i(555841),d=e.i(634236);e.i(827427);var h=e.i(103819),m=e.i(148077),x=e.i(998668),p=e.i(457229),f=e.i(168633),w=e.i(377638),b=e.i(405121);let g=["#000000","#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#ec4899","#6b7280"],y=["#fef08a","#fed7aa","#fecaca","#bbf7d0","#bfdbfe","#ddd6fe","#fbcfe8","#e5e7eb"];function v({onSubmit:e,placeholder:C,disabled:N,autoFocus:M,submitLabel:E,onCancel:P,initialValue:R,projectId:$,proofId:L,isGuest:S,guestSessionId:T,enableAttachments:A=!1,initialAttachments:z}){let{t:I}=(0,p.useTranslation)(),F=C??I("comments.input.placeholder"),D=E??I("comments.input.add"),X=(0,r.useRef)(()=>{}),[U,Y]=(0,r.useState)(null),[B,H]=(0,r.useState)(!0),[O,W]=(0,r.useState)(()=>(z??[]).map(e=>({id:(0,m.nanoid)(),fileURL:e.fileURL,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,status:"completed",progress:100}))),_=(0,r.useRef)(null),V=(0,r.useRef)(new Map),Z=(0,r.useRef)(new Map),q=(0,a.useEditor)({immediatelyRender:!1,content:R||"",extensions:[l.default.configure({heading:{levels:[1,2,3]},codeBlock:!1,link:!1,underline:!1}),s.default,d.TextStyle,d.Color,h.Highlight.configure({multicolor:!0}),c.default.configure({openOnClick:!1,autolink:!0,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),u.default.configure({placeholder:F})],editorProps:{attributes:{class:"rich-comment-content max-w-none text-sm leading-relaxed text-brown-800 dark:text-brown-100 wire:text-white focus:outline-none min-h-[10rem] px-4 py-3","aria-label":F},handleKeyDown:(e,t)=>"Enter"===t.key&&(!!t.metaKey||!!t.ctrlKey)&&(X.current(),!0)},autofocus:M,editable:!N,onUpdate:({editor:e})=>{H(!e.getText().trim())}}),K=O.some(e=>"uploading"===e.status),G=O.some(e=>"error"===e.status),Q=O.filter(e=>"completed"===e.status),J=(!B||Q.length>0)&&!K&&!G,ee=void 0!==z,et=(0,r.useCallback)(()=>{if(!q||!J||!q.getText().trim()&&0===Q.length)return;let t=Q.map(e=>({fileURL:e.fileURL,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType})),r=ee||t.length>0?t:void 0;e(q.getHTML(),r),q.commands.clearContent(),W([]),Z.current.clear(),V.current.clear()},[q,e,J,Q,ee]);X.current=et,(0,r.useEffect)(()=>{q&&void 0!==R&&q.commands.setContent(R)},[q,R]),(0,r.useEffect)(()=>{let e=V.current;return()=>{for(let t of e.values())t.abort();e.clear()}},[]);let er=(0,r.useCallback)(async(e,t)=>{if(!L||S&&!T||!S&&!$)return;let r=new AbortController;V.current.set(e,r);try{let n=await (0,w.prepareSvgForUpload)(t),{storagePath:i,uploadUrl:o}=S?await (0,w.getGuestCommentAttachmentUploadUrl)(T,L,n):await (0,w.getCommentAttachmentUploadUrl)($,L,n);await (0,w.uploadWithSignedUrl)(o,n,t=>{W(r=>r.map(r=>r.id===e?{...r,progress:t}:r))},r.signal),W(t=>t.map(t=>t.id===e?{...t,status:"completed",progress:100,fileURL:i,error:void 0}:t))}catch(r){if(r?.name==="AbortError")return;let t=r instanceof Error?r.message:I("comments.attachment.uploadFailed");W(r=>r.map(r=>r.id===e?{...r,status:"error",error:t}:r))}finally{V.current.delete(e)}},[$,L,S,T,I]),en=(0,r.useCallback)(e=>{e&&0!==e.length&&L&&(S||$)&&(!S||T)&&W(t=>{let r=f.ATTACHMENT_MAX_COUNT-t.length,n=[...t],i=[];for(let t of Array.from(e).slice(0,Math.max(0,r))){let e=(0,f.validateAttachmentFile)(t),r=(0,m.nanoid)();if(!e.ok){n.push({id:r,fileURL:"",fileName:t.name,fileSize:t.size,mimeType:t.type||"application/octet-stream",status:"error",progress:0,error:e.reason});continue}n.push({id:r,fileURL:"",fileName:t.name,fileSize:t.size,mimeType:t.type||"application/octet-stream",status:"uploading",progress:0}),Z.current.set(r,t),i.push({id:r,file:t})}return queueMicrotask(()=>{for(let{id:e,file:t}of i)er(e,t)}),n})},[$,L,S,T,er]),ei=(0,r.useCallback)(e=>
1{V.current.get(e)?.abort(),V.current.delete(e),Z.current.delete(e),W(t=>t.filter(t=>t.id!==e))},[]),eo=(0,r.useCallback)(e=>{let t=Z.current.get(e);t&&(W(t=>t.map(t=>t.id===e?{...t,status:"uploading",progress:0,error:void 0}:t)),er(e,t))},[er]),ea=(0,r.useCallback)(()=>{_.current?.click()},[]);return(0,t.jsxs)("div",{onClick:()=>Y(null),children:[q&&(0,t.jsxs)("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-brown-200 dark:border-brown-700 wire:border-white/20",children:[(0,t.jsx)(j,{active:q.isActive("bold"),onClick:()=>q.chain().focus().toggleBold().run(),title:I("comments.toolbar.bold"),children:(0,t.jsx)("strong",{children:"B"})}),(0,t.jsx)(j,{active:q.isActive("strike"),onClick:()=>q.chain().focus().toggleStrike().run(),title:I("comments.toolbar.strike"),children:(0,t.jsx)("span",{className:"line-through",children:"S"})}),(0,t.jsx)(j,{active:q.isActive("underline"),onClick:()=>q.chain().focus().toggleUnderline().run(),title:I("comments.toolbar.underline"),children:(0,t.jsx)("span",{className:"underline",children:"U"})}),(0,t.jsx)("div",{className:"w-px h-4 bg-brown-200 dark:bg-brown-600 wire:bg-white/20 mx-0.5"}),(0,t.jsx)("div",{className:"relative",children:(0,t.jsx)(j,{active:"text"===U,onClick:e=>{e.stopPropagation(),Y("text"===U?null:"text")},title:I("comments.toolbar.textColor"),children:(0,t.jsx)("span",{className:"font-bold border-b-[3px] pb-px",style:{borderColor:q.getAttributes("textStyle").color||"#ef4444"},children:"A"})})}),(0,t.jsx)("div",{className:"relative",children:(0,t.jsx)(j,{active:"highlight"===U,onClick:e=>{e.stopPropagation(),Y("highlight"===U?null:"highlight")},title:I("comments.toolbar.highlightColor"),children:(0,t.jsx)(n.Highlighter,{className:"w-3.5 h-3.5",style:{color:q.getAttributes("highlight").color||void 0}})})}),A&&L&&(S&&T||!S&&$)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"w-px h-4 bg-brown-200 dark:bg-brown-600 wire:bg-white/20 mx-0.5"}),(0,t.jsx)(j,{active:!1,onClick:e=>{e.stopPropagation(),ea()},title:I("comments.attachment.attach"),children:(0,t.jsx)(i.Paperclip,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("input",{ref:_,type:"file",multiple:!0,hidden:!0,accept:f.ATTACHMENT_ACCEPT,onChange:e=>{en(e.target.files),e.target.value=""}})]})]}),q&&U&&(0,t.jsx)(k,{colors:"text"===U?g:y,label:I("text"===U?"comments.toolbar.textColor":"comments.toolbar.highlightColor"),selected:"text"===U?q.getAttributes("textStyle").color:q.getAttributes("highlight").color,onSelect:e=>{"text"===U?q.commands.setColor(e):q.commands.setHighlight({color:e})},onReset:()=>{"text"===U?q.commands.unsetColor():q.commands.unsetHighlight()},onDismiss:()=>{Y(null),q.commands.focus()}},U),(0,t.jsx)("p",{className:"px-4 pt-3 text-xs font-medium text-brown-600 dark:text-brown-300 wire:text-white/70",children:F}),(0,t.jsx)("div",{className:"max-h-[min(45dvh,28rem)] overflow-y-auto overscroll-contain border-b border-brown-200/80 focus-within:ring-2 focus-within:ring-inset focus-within:ring-accent/60 dark:border-brown-700 wire:border-white/20 wire:focus-within:ring-white/70",children:(0,t.jsx)(a.EditorContent,{editor:q})}),O.length>0&&(0,t.jsx)("div",{...x.stopZoomCapture,className:"flex flex-wrap gap-1.5 px-2 pt-1.5 pb-0.5",children:O.map(e=>(0,t.jsx)(b.AttachmentChip,{attachment:e,onRemove:()=>ei(e.id),onRetry:()=>eo(e.id)},e.id))}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5 px-2 pt-1 pb-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-[10px] text-brown-400 dark:text-brown-500 wire:text-white/30",children:K?I("comments.uploading"):I("comments.input.sendHint")}),P&&(0,t.jsx)("button",{onClick:P,className:"px-2 py-0.5 text-[11px] text-brown-500 dark:text-brown-400 wire:text-white/40 hover:text-brown-900 dark:hover:text-white wire:hover:text-white transition-colors",children:I("common.cancel")})]}),(0,t.jsxs)("button",{onClick:et,disabled:!J||N,className:"w-full px-4 py-2.5 bg-accent hover:bg-accent-dark text-white text-sm font-bold rounded-xl shadow-lg shadow-accent/30 wire:shadow-none flex items-center justify-center gap-1.5 transition-all hover:shadow-xl hover:shadow-accent/40 disabled:opacity-40 disabled:cursor-not-allowed disabled:shadow-none",children:[(0,t.jsx)(o.Plus,{className:"w-4 h-4",strokeWidth:2.5}),D]})]})]})}function k({colors:e,label:n,selected:i,onSelect:o,onReset:a,onDismiss:l}){let{t:s}=(0,p.useTranslation)(),c=(0,r.useId)(),[u,d]=(0,r.useState)(i?.toLowerCase()??"");return(0,t.jsxs)("fieldset",{className:"border-b border-brown-200 bg-brown-50/70 px-3 py-3 dark:border-brown-700 dark:bg-brown-800/70 wire:border-white/20 wire:bg-transparent",onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),l())},children:[(0,t.jsx)("legend",{className:"px-1 text-xs font-semibold text-brown-700 dark:text-brown-200 wire:text-white",children:n}),(0,t.jsxs)("div",{className:"mt-1 grid grid-cols-4 gap-2 sm:grid-cols-5",children:[e.map(e=>(0,t.jsxs)("label",{className:`relative flex min-h-14 cursor-pointer flex-col items-center justify-center gap-1 rounded-lg border px-1 py-1 text-[10px] font-semibold ${u===e?"border-accent bg-accent/10 text-brown-900 ring-2 ring-accent/50 dark:text-white wire:border-white wire:bg-white/10 wire:text-white wire:ring-white/70":"border-brown-200 bg-canvas text-brown-600 hover:border-brown-400 dark:border-brown-600 dark:bg-brown-900 dark:text-brown-200 dark:hover:border-brown-400 wire:border-white/30 wire:bg-transparent wire:text-white/80 wire:hover:border-white"}`,children:[(0,t.jsx)("input",{className:"peer sr-only",type:"radio",name:c,value:e,checked:u===e,onChange:()=>{d(e),o(e)},"aria-label":`${n} ${e}`}),(0,t.jsx)("span",{className:"pointer-events-none absolute inset-0 rounded-lg peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-accent wire:peer-focus-visible:outline-white","aria-hidden":"true"}),(0,t.jsx)("span",{className:"size-5 rounded border border-black/20 ring-1 ring-white/70",style:{backgroundColor:e},"aria-hidden":"true"}),(0,t.jsxs)("span",{className:"whitespace-nowrap",children:[e,u===e?" â":""]})]},e)),(0,t.jsxs)("label",{className:`relative flex min-h-14 cursor-pointer flex-col items-center justify-center gap-1 rounded-lg border px-1 py-1 text-[10px] font-semibold ${""===u?"border-accent bg-accent/10 text-brown-900 ring-2 ring-accent/50 dark:text-white wire:border-white wire:bg-white/10 wire:text-white wire:ring-white/70":"border-brown-200 bg-canvas text-brown-600 hover:border-brown-400 dark:border-brown-600 dark:bg-brown-900 dark:text-brown-200 dark:hover:border-brown-400 wire:border-white/30 wire:bg-transparent wire:text-white/80 wire:hover:border-white"}`,children:[(0,t.jsx)("input",{className:"peer sr-only",type:"radio",name:c,value:"",checked:""===u,onChange:()=>{d(""),a()},"aria-label":`${n} ${s("comments.toolbar.reset")}`}),(0,t.jsx)("span",{className:"pointer-events-none absolute inset-0 rounded-lg peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-accent wire:peer-focus-visible:outline-white","aria-hidden":"true"}),(0,t.jsx)("span",{className:"flex size-5 items-center justify-center rounded border border-brown-300 text-sm dark:border-brown-500 wire:border-white/50","aria-hidden":"true",children:"Ã"}),(0,t.jsxs)("span",{children:[s("comments.toolbar.reset"),""===u?" â":""]})]})]}),u&&!e.some(e=>e===u)&&(0,t.jsxs)("p",{className:"mt-2 flex items-center gap-2 text-xs text-brown-600 dark:text-brown-300 wire:text-white/70",children:[(0,t.jsx)("span",{className:"size-4 border border-brown-300 dark:border-brown-600 wire:border-white/50",style:{backgroundColor:u},"aria-hidden":"true"}),s("comments.toolbar.currentColor"),": ",u]})]})}function j({active:e,onClick:r,title:n,children:i}){return(0,t.jsx)("button",{onClick:r,title:n,className:`w-7 h-7 rounded flex items-center justify-center text-xs transition-colors ${e?"bg-accent/30 text-accent-light":"text-brown-500 dark:text-brown-400 wire:text-white/40 hover:bg-brown-100 dark:hover:bg-brown-700 wire:hover:bg-white/10 hover:text-brown-900 dark:hover:text-white wire:hover:text-white"}`,children:i})}let C=[["#ef4444","annotations.colorLabel.important"],["#f97316","annotations.colorLabel.default"],["#eab308","annotations.colorLabel.question"],["#22c55e","annotations.colorLabel.approve"],["#3b82f6","annotations.colorLabel.suggestion"],["#8b5cf6","annotations.colorLabel.decoration"],["#ec4899","annotations.colorLabel.emphasis"],["#1e293b","annotations.colorLabel.general"]];function N(e){return e<0?0:e>100?100:e}
1e.s(["AnnotationColorPicker",0,function({value:e,onChange:n}){let i=(0,r.useId)(),{t:o,locale:a}=(0,p.useTranslation)(),l=e.toLowerCase(),s=C.some(([e])=>e===l);return(0,t.jsxs)("fieldset",{className:"border-b border-brown-200/80 px-4 pb-4 pt-3 dark:border-brown-700 wire:border-white/20",children:[(0,t.jsx)("legend",{className:"px-0 pt-1 text-xs font-semibold text-brown-700 dark:text-brown-200 wire:text-white",children:"ja"===a?"ææã®è²":"Annotation color"}),(0,t.jsx)("div",{className:"mt-2 grid grid-cols-4 gap-2",children:C.map(([e,r])=>(0,t.jsxs)("label",{className:`relative flex min-h-14 cursor-pointer flex-col items-center justify-center gap-1 rounded-lg border px-1 py-1 text-center text-[10px] font-semibold leading-tight transition-colors ${l===e?"border-accent bg-accent/10 text-brown-900 ring-2 ring-accent/60 dark:text-white wire:border-white wire:bg-white/10 wire:text-white wire:ring-white/60":"border-brown-200 bg-white/60 text-brown-600 hover:border-brown-400 hover:bg-brown-100 dark:border-brown-700 dark:bg-brown-800 dark:text-brown-200 dark:hover:bg-brown-700 wire:border-white/30 wire:bg-transparent wire:text-white/80 wire:hover:bg-white/10"}`,children:[(0,t.jsx)("input",{className:"peer sr-only",type:"radio",name:i,value:e,checked:l===e,onChange:()=>n(e),"aria-label":o(r)}),(0,t.jsx)("span",{className:"absolute inset-0 rounded-lg peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-accent wire:peer-focus-visible:outline-white","aria-hidden":"true"}),(0,t.jsx)("span",{className:"relative size-5 shrink-0 rounded-full border border-black/20 ring-1 ring-white/80",style:{backgroundColor:e},"aria-hidden":"true"}),(0,t.jsxs)("span",{className:"relative",children:[o(r),l===e?" â":""]})]},e))}),!s&&(0,t.jsxs)("p",{className:"mt-2 flex items-center gap-2 text-xs text-brown-600 dark:text-brown-200 wire:text-white/80",children:[(0,t.jsx)("span",{className:"size-4 border border-brown-300 dark:border-brown-500 wire:border-white/50",style:{backgroundColor:e},"aria-hidden":"true"}),"ja"===a?"ç¾å¨ã®è²":"Current color",": ",e]})]})}],316972),e.s(["pixelDistance",0,function(e,t,r){return Math.hypot((t.x-e.x)/100*r.width,(t.y-e.y)/100*r.height)},"snapAngleEnd",0,function(e,t,r,n=45){let{width:i,height:o}=r;if(i<=0||o<=0)return t;let a=(t.x-e.x)/100*i,l=(t.y-e.y)/100*o,s=Math.hypot(a,l);if(0===s)return t;let c=n*Math.PI/180,u=Math.round(Math.atan2(l,a)/c)*c;return{x:N(e.x+Math.cos(u)*s/i*100),y:N(e.y+Math.sin(u)*s/o*100)}}],129755)},60649,e=>{"use strict";var t=e.i(271645);e.s(["useMediaQuery",0,function(){let[e,r]=(0,t.useState)(!1),[n,i]=(0,t.useState)(1024),[o,a]=(0,t.useState)(!1);(0,t.useEffect)(()=>{let e=window.matchMedia("(max-width: 768px)"),t=window.matchMedia("(orientation: landscape) and (max-height: 500px)"),n=window.screen?.orientation,o=()=>{let n;r(e.matches||t.matches),i(window.innerWidth),a("string"==typeof(n=window.screen?.orientation?.type)?n.startsWith("portrait"):window.matchMedia("(orientation: portrait)").matches)};return o(),e.addEventListener("change",o),t.addEventListener("change",o),window.addEventListener("resize",o),n?.addEventListener("change",o),()=>{e.removeEventListener("change",o),t.removeEventListener("change",o),window.removeEventListener("resize",o),n?.removeEventListener("change",o)}},[]);let l=!e&&n<=1024;return{isMobile:e,isTablet:l,isDesktop:!e&&!l,isPortrait:o}}])},243965,e=>{"use strict";e.s(["AnnotationLayer",()=>b]);var t=e.i(843476),r=e.i(271645),n=e.i(174080),i=e.i(263676),o=e.i(719478),a=e.i(852156),l=e.i(672445),s=e.i(742604),c=e.i(112175),u=e.i(990677),d=e.i(316972),h=e.i(998668),m=e.i(129755),x=e.i(457229),p=e.i(60649);let f={maxHeight:"85svh",paddingBottom:"env(safe-area-inset-bottom)"},w=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#ec4899","#1e293b"];function b({annotations:e,selectedId:g,onSelect:y,onCreate:v,onMove:k,onUpdate:j,onDelete:C,toolMode:N,pinIcon:M,strokeWidth:E,replyAnnotation:P,replyInitialValue:R,replyInitialAttachments:$,onReplySubmit:L,onReplyCancel:S,previewSuggestion:T,bouncingAnnotationId:A,projectId:z,proofId:I,isGuest:F,guestSessionId:D,attachmentsDisabled:X=!1,visibleFilter:U,
1currentVersionId:Y,versionNumberMap:B,readOnly:H=!1,existingReadOnly:O=!1,zoomScale:W=1}){let{t:_}=(0,x.useTranslation)(),{isMobile:V}=(0,p.useMediaQuery)(),Z=(0,r.useRef)(null),[q,K]=(0,r.useState)(null),[G,Q]=(0,r.useState)("#ef4444"),[J,ee]=(0,r.useState)(null),et=(0,r.useRef)(null),[er,en]=(0,r.useState)(null),[ei,eo]=(0,r.useState)(null),ea=(0,r.useRef)(!1),el=(0,r.useRef)(k);(0,r.useEffect)(()=>{el.current=k});let es=(0,r.useRef)({width:1,height:1}),[ec,eu]=(0,r.useState)([]),ed=(0,r.useRef)(!1),eh=(0,r.useRef)(0),em=(0,r.useRef)(null),ex=(0,r.useRef)(null),ep=(0,r.useRef)(!1);(0,r.useEffect)(()=>()=>{eh.current&&cancelAnimationFrame(eh.current)},[]);let[ef,ew]=(0,r.useState)(N);N!==ef&&(ew(N),K(null));let eb=!!q,eg=!!P;(0,r.useEffect)(()=>{if(!eb&&!eg)return;let e=e=>{"Escape"!==e.key||e.isComposing||(e.preventDefault(),eb?K(null):S?.())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[eb,eg,S]),(0,r.useEffect)(()=>{let e=e=>{if("Delete"!==e.key&&"Backspace"!==e.key||e.isComposing)return;let t=e.target.tagName;"INPUT"===t||"TEXTAREA"===t||e.target.isContentEditable||!g||H||O||(e.preventDefault(),C?.(g),y(null))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[g,C,y,H,O]);let ey=(0,r.useCallback)(e=>{let t=e.currentTarget.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width*100,y:(e.clientY-t.top)/t.height*100}},[]),ev=(0,r.useRef)(null),ek=(0,r.useRef)(null),ej=(0,r.useCallback)(()=>{ev.current=null,ed.current=!1,ea.current=!1,eh.current&&(cancelAnimationFrame(eh.current),eh.current=0),em.current=null,ex.current=null,ep.current=!1,eu([]),en(null),eo(null)},[]),eC=(0,r.useCallback)(e=>{if("mouse"===e.pointerType||H)return;if(null!==ev.current)return void ej();if(!N||"pin"===N||"ruler"===N||"physical_ruler"===N||"magnifier"===N||"eyedropper"===N||q)return;ev.current=e.pointerId;let t=ey(e),r=e.currentTarget.getBoundingClientRect();es.current={width:r.width,height:r.height},"freehand"===N?(ed.current=!0,ex.current=t,ep.current=!1,eu([t])):(ea.current=!0,en(t),eo(t))},[N,ey,q,H,ej]),eN=(0,r.useCallback)(e=>{if("mouse"!==e.pointerType&&ev.current===e.pointerId)if("freehand"===N&&ed.current){let t=ey(e);if(ex.current&&.5>Math.sqrt((t.x-ex.current.x)**2+(t.y-ex.current.y)**2))return;ex.current=t,em.current=t,eh.current||(eh.current=requestAnimationFrame(()=>{em.current&&eu(e=>[...e,em.current]),eh.current=0}))}else ea.current&&eo(ey(e))},[N,ey]),eM=(0,r.useCallback)(e=>{if("mouse"!==e.pointerType&&ev.current===e.pointerId){if(ev.current=null,"pointercancel"===e.type)return void ej();ek.current?.()}},[ej]),eE=(0,r.useCallback)(e=>{H||"pin"!==N||q||K({type:"pin",position:ey(e)})},[N,ey,q,H]),eP=(0,r.useCallback)((e,t)=>{q&&(v({...q,color:G,comment:e,commentAttachments:t,..."pin"===q.type&&M?{pinIcon:M}:{},..."freehand"===q.type&&E?{strokeWidth:E}:{},..."arrow"===q.type&&E?{strokeWidth:6*E}:{}}),K(null))},[q,G,v,M,E]),eR=(0,r.useCallback)(()=>{K(null)},[]),e$=(0,r.useCallback)((e,t)=>{H||O||(t.preventDefault(),t.stopPropagation(),ee({annotationId:e,x:t.clientX,y:t.clientY}))},[H,O]),eL=(0,r.useCallback)(e=>{if(0!==e.button)return;e.stopPropagation(),e.preventDefault();let t=Z.current?.getBoundingClientRect();if(!t)return;let r={x:(e.clientX-t.left)/t.width*100,y:(e.clientY-t.top)/t.height*100},n=null,i=null,o=e=>{n=e,null===i&&(i=requestAnimationFrame(()=>{if(i=null,!n)return;let e=n;n=null;let o={x:(e.clientX-t.left)/t.width*100,y:(e.clientY-t.top)/t.height*100},a=o.x-r.x,l=o.y-r.y;r=o,K(e=>e?{...e,position:{x:e.position.x+a,y:e.position.y+l},...e.rect?{rect:{...e.rect,x:e.rect.x+a,y:e.rect.y+l}}:{},...e.arrowEnd?{arrowEnd:{x:e.arrowEnd.x+a,y:e.arrowEnd.y+l}}:{},...e.strokePath?{strokePath:e.strokePath.replace(/([ML])(-?\d+\.?\d*)\s+(-?\d+\.?\d*)/g,(e,t,r,n)=>`${t}${(parseFloat(r)+a).toFixed(2)} ${(parseFloat(n)+l).toFixed(2)}`)}:{}}:e)}))};document.addEventListener("mousemove",o),document.addEventListener("mouseup",()=>{document.removeEventListener("mousemove",o),null!==i&&cancelAnimationFrame(i)},{once:!0})},[]),eS=(0,r.useCallback)(e=>{if(0!==e.button||H||!N||"pin"===N||"ruler"===N||"physical_ruler"===N||"magnifier"===N||"eyedropper"===N||q)return;e.preventDefault();let t=ey(e),r=e.currentTarget.getBoundingClientRect();es.current={width:r.width,height:r.height},"freehand"===N?(ed.current=!0,ex.current=t,ep.current=!1,eu([t])):(ea.current=!0,en(t),eo(t))},[N,ey,q,H]),eT=(0,r.useCallback)(e=>{if("freehand"===N&&ed.current){let t=ey(e);if(e.shiftKey){ep.current=!0,em.current=t,ex.current=t,eh.current||(eh.current=requestAnimationFrame(()=>{em.current&&eu(e=>[e[0]??em.current,em.current]),eh.current=0}));return}!(ex.current&&.5>Math.sqrt((t.x-ex.current.x)**2+(t.y-ex.current.y)**2))&&(ex.current=t,em.current=t,eh.current||(eh.current=requestAnimationFrame(()=>{em.current&&eu(e=>[...e,em.current]),eh.current=0})))}else if(ea.current){let t=ey(e);eo(e.shiftKey&&"arrow"===N&&er?(0,m.snapAngleEnd)(er,t,es.current):t)}},[N,ey,er]),eA=(0,r.useCallback)(()=>
1{if("freehand"===N&&ed.current){if(ed.current=!1,eh.current&&(cancelAnimationFrame(eh.current),eh.current=0),em.current=null,ex.current=null,ec.length>2||ep.current&&2===ec.length&&(0,m.pixelDistance)(ec[0],ec[1],es.current)>6){let e=ec;if(e.length>2e3){let t=Math.ceil(e.length/2e3);e=e.filter((r,n)=>0===n||n===e.length-1||n%t==0)}let t=e.map((e,t)=>`${0===t?"M":"L"}${e.x.toFixed(2)} ${e.y.toFixed(2)}`).join(" ");K({type:"freehand",position:ec[0],strokePath:t})}eu([]),ep.current=!1}else if(ea.current&&er&&ei){if(ea.current=!1,"rect"===N){let e={x:Math.min(er.x,ei.x),y:Math.min(er.y,ei.y),width:Math.abs(ei.x-er.x),height:Math.abs(ei.y-er.y)},t=e.width/100*es.current.width,r=e.height/100*es.current.height;t>4&&r>4&&K({type:"rect",position:{x:e.x,y:e.y},rect:e})}else"arrow"===N&&(0,m.pixelDistance)(er,ei,es.current)>6&&K({type:"arrow",position:er,arrowEnd:ei});en(null),eo(null)}},[N,er,ei,ec]);(0,r.useEffect)(()=>{ek.current=eA});let ez=(0,r.useRef)(null),[eI,eF]=(0,r.useState)(0),[eD,eX]=(0,r.useState)(null),eU=e=>{if(!eD)return{left:0,top:0};let t=e.position.x,r=e.position.y;"rect"===e.type&&e.rect?(t=e.rect.x+e.rect.width/2,r=e.rect.y+e.rect.height):"arrow"===e.type&&e.arrowEnd&&(t=Math.max(e.position.x,e.arrowEnd.x),r=Math.max(e.position.y,e.arrowEnd.y));let n=eD.left+eD.width*t/100,i=eD.top+eD.height*r/100+24;return{left:Math.max(8,Math.min(n,window.innerWidth-Math.min(416,window.innerWidth-16)-8)),top:Math.max(8,Math.min(i,Math.max(8,window.innerHeight-(eI||320)-8)))}},eY=(0,r.useCallback)(()=>{let e=Z.current;if(!e)return;let t=e.getBoundingClientRect();eX(e=>e&&e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height?e:{left:t.left,top:t.top,width:t.width,height:t.height})},[]);(0,r.useLayoutEffect)(()=>{(q||P)&&eY()}),(0,r.useLayoutEffect)(()=>{if(!q&&!P)return;let e=Z.current;if(!e)return;eY(),window.addEventListener("scroll",eY,!0),window.addEventListener("resize",eY);let t=new ResizeObserver(eY);return t.observe(e),()=>{window.removeEventListener("scroll",eY,!0),window.removeEventListener("resize",eY),t.disconnect()}},[q,P,eY]);let[eB,eH]=(0,r.useState)(()=>P?.color??"#ef4444"),[eO,eW]=(0,r.useState)(P?.id);P?.id!==eO&&(eW(P?.id),P&&eH(P.color));let e_=!!q,eV=!!P&&!q;(0,r.useLayoutEffect)(()=>{let e=ez.current;if(!e)return;let t=()=>eF(e.getBoundingClientRect().height);t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[e_,eV]),(0,r.useEffect)(()=>{if(e_||eV)return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e);function e(e){let t=e.target;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable)||e.metaKey||e.ctrlKey||e.altKey)return;let r=parseInt(e.key,10)-1;Number.isNaN(r)||r<0||r>=w.length||(e.preventDefault(),eV?eH(w[r]):Q(w[r]))}},[e_,eV]);let eZ="ruler"===N||"physical_ruler"===N||"magnifier"===N||"eyedropper"===N,eq=N&&!eZ?"cursor-crosshair":"";return(0,t.jsxs)("div",{ref:Z,"data-annotation-layer":!0,className:`absolute inset-0 ${eq} ${eZ?"pointer-events-none":""}`,onClick:eE,onMouseDown:eS,onMouseMove:eT,onMouseUp:eA,onMouseLeave:eA,onPointerDown:eC,onPointerMove:eN,onPointerUp:eM,onPointerCancel:eM,style:{touchAction:N&&!eZ?"none":void 0},children:[e.map((e,r)=>{if(U&&!U(e))return null;let n=A===e.id,i={annotation:e,index:r,selected:e.id===g,onClick:()=>y(e.id===g?null:e.id),onDragStart:O?void 0:t=>((e,t)=>{if(O||H||0!==t.button)return;t.stopPropagation(),t.preventDefault();let r=Z.current?.getBoundingClientRect();if(!r)return;let n={x:(t.clientX-r.left)/r.width*100,y:(t.clientY-r.top)/r.height*100},i=null,o=null,a=t=>{i=t,null===o&&(o=requestAnimationFrame(()=>{if(o=null,!i)return;let t=i;i=null;let a={x:(t.clientX-r.left)/r.width*100,y:(t.clientY-r.top)/r.height*100};el.current?.(e,{x:a.x-n.x,y:a.y-n.y}),n=a}))};document.addEventListener("mousemove",a),document.addEventListener("mouseup",()=>{document.removeEventListener("mousemove",a),null!==o&&cancelAnimationFrame(o)},{once:!0})})(e.id,t),onTouchDragStart:O?void 0:t=>((e,t)=>{if(t.stopPropagation(),O||"mouse"===t.pointerType||H)return;let r=Z.current?.getBoundingClientRect();if(!r)return;let n={x:t.clientX,y:t.clientY},i=t.pointerId,o=!1,a={x:(t.clientX-r.left)/r.width*100,y:(t.clientY-r.top)/r.height*100},l=null,s=null,c=window.setTimeout(()=>{o=!0},350),u=()=>{if(s=null,!l)return;let t=l;l=null;let n={x:(t.clientX-r.left)/r.width*100,y:(t.clientY-r.top)/r.height*100};el.current?.(e,{x:n.x-a.x,y:n.y-a.y}),a=n},d=e=>{if(e.pointerId===i){if(!o){if(8>Math.hypot(e.clientX-n.x,e.clientY-n.y))return;o=!0,a={x:(e.clientX-r.left)/r.width*100,y:(e.clientY-r.top)/r.height*100};return}l=e,null===s&&(s=requestAnimationFrame(u))}},h=()=>{window.clearTimeout(c),document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",m),document.removeEventListener("pointercancel",m),document.removeEventListener("pointerdown",x),null!==s&&cancelAnimationFrame(s)},m=e=>{e.pointerId===i&&h()},x=e=>{e.pointerId!==i&&h()};document.addEventListener("pointermove",d),document.addEventListener("pointerup",m),document.addEventListener("pointercancel",m),document.addEventListener("pointerdown",x)})(e.id,t),onContextMenu:O?void 0:t=>e$(e.id,t),bouncing:n,currentVersionId:Y,versionNumberMap:B};switch(e.type){case"pin":return(0,t.jsx)(o.PinMarker,{...i,zoomScale:W},e.id);
1case"rect":return(0,t.jsx)(a.RectOverlay,{...i,onResize:O?void 0:t=>{j?.(e.id,{rect:t})}},e.id);case"arrow":return(0,t.jsx)(l.ArrowLine,{...i},e.id);case"freehand":return(0,t.jsx)(s.FreehandPath,{...i},e.id);default:return null}}),"rect"===N&&er&&ei&&(0,t.jsx)("div",{className:"absolute border-2 pointer-events-none",style:{left:`${Math.min(er.x,ei.x)}%`,top:`${Math.min(er.y,ei.y)}%`,width:`${Math.abs(ei.x-er.x)}%`,height:`${Math.abs(ei.y-er.y)}%`,borderColor:G,backgroundColor:`${G}20`}}),"arrow"===N&&er&&ei&&(0,t.jsxs)("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",children:[(0,t.jsx)("defs",{children:(0,t.jsx)("marker",{id:"arrow-preview-drag",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",children:(0,t.jsx)("polygon",{points:"0 0, 10 3.5, 0 7",fill:G})})}),(0,t.jsx)("line",{x1:`${er.x}%`,y1:`${er.y}%`,x2:`${ei.x}%`,y2:`${ei.y}%`,stroke:G,strokeWidth:(E??.3)*6,strokeDasharray:"5,5",markerEnd:"url(#arrow-preview-drag)"})]}),(0,t.jsx)(c.GhostSuggestion,{suggestion:T??null,strokeWidth:E}),"freehand"===N&&ec.length>1&&(0,t.jsx)("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:(0,t.jsx)("path",{d:ec.map((e,t)=>`${0===t?"M":"L"}${e.x.toFixed(2)} ${e.y.toFixed(2)}`).join(" "),fill:"none",stroke:G,strokeWidth:E??.3,strokeLinecap:"round"})}),q?.type==="pin"&&(0,t.jsx)("div",{...h.stopZoomCapture,onMouseDown:eL,className:`absolute -translate-x-1/2 -translate-y-1/2 flex items-center justify-center shadow-lg animate-pulse ring-2 ring-white cursor-move ${M?"w-9 h-9 rounded-lg":"w-8 h-8 rounded-full text-white text-xs font-bold"}`,style:{left:`${q.position.x}%`,top:`${q.position.y}%`,backgroundColor:M?`${G}30`:G,borderColor:M?G:void 0,borderWidth:2*!!M},children:M?(0,t.jsx)("span",{className:"text-lg",children:M}):"+"}
1),q?.type==="rect"&&q.rect&&(0,t.jsx)("div",{...h.stopZoomCapture,onMouseDown:eL,className:"absolute border-2 cursor-move",style:{left:`${q.rect.x}%`,top:`${q.rect.y}%`,width:`${q.rect.width}%`,height:`${q.rect.height}%`,borderColor:G,backgroundColor:`${G}20`}}),q?.type==="arrow"&&q.arrowEnd&&(0,t.jsxs)("svg",{className:"absolute inset-0 w-full h-full cursor-move",...h.stopZoomCapture,onMouseDown:eL,children:[(0,t.jsx)("defs",{children:(0,t.jsx)("marker",{id:"arrow-preview-pending",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",children:(0,t.jsx)("polygon",{points:"0 0, 10 3.5, 0 7",fill:G})})}),(0,t.jsx)("line",{x1:`${q.position.x}%`,y1:`${q.position.y}%`,x2:`${q.arrowEnd.x}%`,y2:`${q.arrowEnd.y}%`,stroke:G,strokeWidth:(E??.3)*6,markerEnd:"url(#arrow-preview-pending)"})]}),q?.type==="freehand"&&q.strokePath&&(0,t.jsx)("svg",{className:"absolute inset-0 w-full h-full cursor-move",viewBox:"0 0 100 100",preserveAspectRatio:"none",...h.stopZoomCapture,onMouseDown:eL,children:(0,t.jsx)("path",{d:q.strokePath,fill:"none",stroke:G,strokeWidth:E??.3,strokeLinecap:"round"})}),e_&&q&&(0,n.createPortal)((0,t.jsx)("div",{ref:ez,className:V?"fixed z-[9999] inset-x-0 bottom-0 w-full":"fixed z-[9999] w-[min(26rem,calc(100vw-1rem))]",style:V?f:eU(q),...h.stopZoomCapture,children:(0,t.jsxs)("div",{className:`relative bg-canvas dark:bg-brown-900 wire:bg-black shadow-[0_18px_48px_rgba(61,43,31,0.22)] dark:shadow-[0_18px_48px_rgba(0,0,0,0.55)] wire:shadow-none border border-t-4 border-brown-200 border-t-accent dark:border-brown-600 dark:border-t-accent wire:border-white/50 wire:border-t-white ${V?"rounded-t-2xl border-b-0 overflow-y-auto max-h-[85svh]":"rounded-xl overflow-y-auto max-h-[calc(100svh-1rem)]"}`,children:[(0,t.jsx)("button",{type:"button",...h.stopZoomCapture,onClick:e=>{e.stopPropagation(),eR()},className:"absolute top-1 right-1 z-10 w-10 h-10 rounded-full bg-canvas dark:bg-brown-900 wire:bg-black hover:bg-brown-100 dark:hover:bg-brown-700 wire:hover:bg-white/10 flex items-center justify-center text-brown-600 dark:text-brown-200 wire:text-white hover:text-brown-900 dark:hover:text-white wire:hover:text-white focus-visible:outline-2 focus-visible:outline-accent wire:focus-visible:outline-white transition-colors",title:_("common.close"),children:(0,t.jsx)(i.X,{className:"w-4 h-4"})}),(0,t.jsx)(d.AnnotationColorPicker,{value:G,onChange:Q}),(0,t.jsx)(u.RichCommentInput,{onSubmit:eP,onCancel:eR,submitLabel:_("comments.input.add"),autoFocus:!0,placeholder:_("comments.input.placeholder"),projectId:z,proofId:I,isGuest:F,guestSessionId:D,enableAttachments:!!z&&!!I&&!X})]})}),document.body),eV&&P&&(0,n.createPortal)((0,t.jsx)("div",{ref:ez,className:V?"fixed z-[9999] inset-x-0 bottom-0 w-full":"fixed z-[9999] w-[min(26rem,calc(100vw-1rem))]",style:V?f:eU(P),...h.stopZoomCapture,children:(0,t.jsxs)("div",{className:`relative bg-canvas dark:bg-brown-900 wire:bg-black shadow-[0_18px_48px_rgba(61,43,31,0.22)] dark:shadow-[0_18px_48px_rgba(0,0,0,0.55)] wire:shadow-none border border-t-4 border-brown-200 border-t-accent dark:border-brown-600 dark:border-t-accent wire:border-white/50 wire:border-t-white ${V?"rounded-t-2xl border-b-0 overflow-y-auto max-h-[85svh]":"rounded-xl overflow-y-auto max-h-[calc(100svh-1rem)]"}`,children:[(0,t.jsx)("button",{type:"button",...h.stopZoomCapture,onClick:e=>{e.stopPropagation(),S?.()},className:"absolute top-1 right-1 z-10 w-10 h-10 rounded-full bg-canvas dark:bg-brown-900 wire:bg-black hover:bg-brown-100 dark:hover:bg-brown-700 wire:hover:bg-white/10 flex items-center justify-center text-brown-600 dark:text-brown-200 wire:text-white hover:text-brown-900 dark:hover:text-white wire:hover:text-white focus-visible:outline-2 focus-visible:outline-accent wire:focus-visible:outline-white transition-colors",title:_("common.close"),children:(0,t.jsx)(i.X,{className:"w-4 h-4"})}),(0,t.jsx)(d.AnnotationColorPicker,{value:eB,onChange:eH}),(0,t.jsx)(u.RichCommentInput,{onSubmit:(e,t)=>L?.(e,eB!==P.color?eB:void 0,t),onCancel:S,submitLabel:_(R?"comments.input.update":"comments.input.reply"),autoFocus:!0,placeholder:_(R?"comments.input.editPlaceholder":"comments.input.replyPlaceholder"),initialValue:R,initialAttachments:$,projectId:z,proofId:I,isGuest:F,guestSessionId:D,enableAttachments:!!z&&!!I&&!X})]})}),document.body),J&&(0,n.createPortal)((0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"fixed inset-0 z-[9998]",onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>{e.stopPropagation(),ee(null)},onClick:e=>e.stopPropagation()}),(0,t.jsx)("div",{ref:et,className:"fixed z-[9999] bg-white dark:bg-brown-800 wire:bg-black border border-brown-200 dark:border-brown-700 wire:border-white/20 rounded-lg shadow-xl py-1 min-w-[120px]",style:{left:J.x,top:J.y},children:(0,t.jsx)("button",{className:"w-full px-3 py-2 text-sm text-left text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 wire:hover:bg-white/10 transition-colors",onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>{e.stopPropagation(),e.preventDefault(),C?.(J.annotationId),g===J.annotationId&&y(null),ee(null)},children:_("common.delete")})})]}),document.body)]})}},123837,116078,622133,298342,661430,166901,907466,346155,e=>{"use strict";e.s(["PdfViewer",()=>M],123837);var t=e.i(843476),r=e.i(271645),n=e.i(343558),i=e.i(112175),o=e.i(243965);function a({active:e,sourceUrl:n,size:i=200,magnification:o=2,zoomScale:l=1}){let s,c,u,d,h,m,[x,p]=(0,r.useState)(null);(0,r.useEffect)(()=>{e||p(null)},[e]),(0,r.useEffect)(()=>
1{if(!e)return;let t=e=>{"Escape"!==e.key||e.isComposing||p(null)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]);let f=(0,r.useCallback)(e=>{let t=e.currentTarget.getBoundingClientRect(),r=1/l;p({pos:{x:(e.clientX-t.left)*r,y:(e.clientY-t.top)*r},rect:{w:t.width*r,h:t.height*r}})},[l]),w=(0,r.useCallback)(()=>{p(null)},[]);if(!e)return null;let b=null!==x&&null!==n&&x.rect.w>0&&x.rect.h>0;return(0,t.jsx)("div",{className:"absolute inset-0",style:{zIndex:5,pointerEvents:"auto",cursor:"zoom-in"},onPointerMove:f,onPointerLeave:w,children:b&&x&&(c=i*(s=1/l),u=x.rect.w*o,d=x.rect.h*o,h=-(x.pos.x*o-c/2),m=-(x.pos.y*o-c/2),(0,t.jsx)("div",{style:{position:"absolute",left:x.pos.x-c/2,top:x.pos.y-c/2,width:c,height:c,clipPath:"circle(50%)",backgroundImage:`url(${n})`,backgroundSize:`${u}px ${d}px`,backgroundPosition:`${h}px ${m}px`,backgroundRepeat:"no-repeat",border:`${2*s}px solid rgba(255,255,255,0.9)`,boxShadow:`0 ${8*s}px ${28*s}px rgba(0,0,0,0.35), 0 0 0 ${+s}px rgba(0,0,0,0.2)`,pointerEvents:"none"}}))})}function l({active:e,unit:n,conversion:i,zoomScale:o,resetSignal:a}){let s=(0,r.useRef)(null),[c,u]=(0,r.useState)([]),[d,h]=(0,r.useState)(null),[m,x]=(0,r.useState)({w:0,h:0});(0,r.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();x({w:t.width,h:t.height})};t();let r=new ResizeObserver(t);return r.observe(e),window.addEventListener("resize",t),()=>{r.disconnect(),window.removeEventListener("resize",t)}},[e]),(0,r.useEffect)(()=>{e||(u([]),h(null))},[e]),(0,r.useEffect)(()=>{void 0!==a&&(u([]),h(null))},[a]),(0,r.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"!==e.key||e.isComposing||(u([]),h(null))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]);let p=(0,r.useCallback)(e=>{let t=e.currentTarget.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width,y:(e.clientY-t.top)/t.height}},[]),f=(0,r.useCallback)(t=>{if(!e||0!==t.button)return;t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId);let r=p(t);h({id:`${Date.now()}`,x1f:r.x,y1f:r.y,x2f:r.x,y2f:r.y})},[e,p]),w=(0,r.useCallback)(e=>{if(!d)return;let t=p(e);h({...d,x2f:t.x,y2f:t.y})},[d,p]),b=(0,r.useCallback)(e=>{if(!d)return;e.currentTarget.releasePointerCapture(e.pointerId);let t=e.currentTarget.getBoundingClientRect();Math.hypot((d.x2f-d.x1f)*t.width,(d.y2f-d.y1f)*t.height)>=5&&u(e=>[...e,d]),h(null)},[d]),g=(0,r.useCallback)((e,t)=>{t.stopPropagation(),u(t=>t.filter(t=>t.id!==e))},[]),y=(0,r.useCallback)(e=>0===m.w||0===m.h?0:Math.hypot((e.x2f-e.x1f)*m.w,(e.y2f-e.y1f)*m.h)/o,[m.w,m.h,o]),v=d?[...c,d]:c,k=12/o,j=3/o;return(0,t.jsx)("svg",{ref:s,className:`absolute inset-0 w-full h-full ${e?"pointer-events-auto":"pointer-events-none"}`,style:{zIndex:4,cursor:e?"crosshair":"default"},onPointerDown:f,onPointerMove:w,onPointerUp:b,onPointerCancel:b,children:v.map(e=>{let r=y(e),a=i.formatDistance(r,n),l=(e.x1f+e.x2f)/2*100,s=(e.y1f+e.y2f)/2*100,c=e.id===d?.id;return(0,t.jsxs)("g",{children:[(0,t.jsx)("line",{x1:`${100*e.x1f}%`,y1:`${100*e.y1f}%`,x2:`${100*e.x2f}%`,y2:`${100*e.y2f}%`,stroke:"#e86c00",strokeWidth:"2",vectorEffect:"non-scaling-stroke",style:{cursor:c?"crosshair":"pointer"},onClick:c?void 0:t=>g(e.id,t)}),(0,t.jsx)("circle",{cx:`${100*e.x1f}%`,cy:`${100*e.y1f}%`,r:j,fill:"#e86c00"}),(0,t.jsx)("circle",{cx:`${100*e.x2f}%`,cy:`${100*e.y2f}%`,r:j,fill:"#e86c00"}),(0,t.jsxs)("g",{transform:`translate(0, ${-(1.2*k)})`,style:{pointerEvents:"none"},children:[(0,t.jsx)("rect",{x:`${l}%`,y:`${s}%`,width:a.length*k*.65,height:1.4*k,rx:3/o,fill:"#e86c00",transform:`translate(${-a.length*k*.32}, ${-(.7*k)})`}),(0,t.jsx)("text",{x:`${l}%`,y:`${s}%`,fontSize:k,fontFamily:"monospace",textAnchor:"middle",fill:"#fff",style:{userSelect:"none"},children:a})]})]},e.id)})})}e.s(["MagnifierOverlay",0,a],116078),e.s(["RulerOverlay",0,l],622133);var s=e.i(573474),c=e.i(456420);let u=(0,c.default)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);var d=e.i(457229);function h({active:e,unit:n,conversion:i,zoomScale:o,resetSignal:a}){let l,c,m,x,{t:p}=(0,d.useTranslation)(),f=(0,r.useRef)(null),[w,b]=(0,r.useState)([]),[g,y]=(0,r.useState)(null),[v,k]=(0,r.useState)({w:0,h:0}),j=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=f.current?.parentElement;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();k({w:t.width,h:t.height})};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[e,o]),(0,r.useEffect)(()=>{e||y(null)},[e]),(0,r.useEffect)(()=>{void 0!==a&&(b([]),y(null))},[a]),(0,r.useEffect)(()=>
1{if(!e)return;let t=e=>{!e.isComposing&&("Escape"===e.key?(b([]),y(null)):("Delete"===e.key||"Backspace"===e.key)&&g&&(b(e=>e.filter(e=>e.id!==g)),y(null)))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,g]);let C=(0,r.useCallback)(t=>{if(!e||t.target!==t.currentTarget)return;let r=t.currentTarget.getBoundingClientRect(),n=(t.clientX-r.left)/r.width,i=(t.clientY-r.top)/r.height,a=r.width/o,l={id:`${Date.now()}`,cxFraction:n,cyFraction:i,lengthPx:Math.min(300,.5*a),angleDeg:0};b([l]),y(l.id)},[e,o]),[N,M]=(0,r.useState)(()=>e&&0===w.length?{cx:.5,cy:.5}:null),E=(0,r.useCallback)(t=>{if(!e||w.length>0||t.target!==t.currentTarget)return;let r=t.currentTarget.getBoundingClientRect();M({cx:(t.clientX-r.left)/r.width,cy:(t.clientY-r.top)/r.height})},[e,w.length]),P=e&&0===w.length,[R,$]=(0,r.useState)(P);P!==R&&($(P),M(P?{cx:.5,cy:.5}:null)),(0,r.useEffect)(()=>{let e=e=>{let t=j.current;if(!t)return;let r=f.current?.parentElement;if(!r)return;let n=r.getBoundingClientRect(),i=e.clientX-t.startClientX,a=e.clientY-t.startClientY;b(e=>e.map(e=>{if(e.id!==t.rulerId)return e;if("move"===t.mode){let r=i/n.width,o=a/n.height;return{...e,cxFraction:Math.max(0,Math.min(1,t.startRuler.cxFraction+r)),cyFraction:Math.max(0,Math.min(1,t.startRuler.cyFraction+o))}}let r=t.startRuler.angleDeg*Math.PI/180,l=Math.cos(r),s=Math.sin(r),c=i/o,u=a/o,d="resize-right"===t.mode?1:-1,h=Math.max(40,t.startRuler.lengthPx+(c*l+u*s)*d*2);return{...e,lengthPx:h}}))},t=()=>{j.current=null};return document.addEventListener("pointermove",e),document.addEventListener("pointerup",t),document.addEventListener("pointercancel",t),()=>{document.removeEventListener("pointermove",e),document.removeEventListener("pointerup",t),document.removeEventListener("pointercancel",t)}},[o]);let L=(0,r.useCallback)((e,t,r)=>{r.stopPropagation(),r.preventDefault();let n=w.find(t=>t.id===e);n&&(j.current={rulerId:e,mode:t,startClientX:r.clientX,startClientY:r.clientY,startRuler:{...n}},y(e))},[w]),S=(0,r.useCallback)(e=>{b(t=>t.map(t=>t.id===e?{...t,angleDeg:(t.angleDeg+90)%180}:t))},[]),T=(0,r.useCallback)(e=>{b(t=>t.filter(t=>t.id!==e)),g===e&&y(null)},[g]);if(!e&&0===w.length)return null;let A="cm"===n?{minorPx:i.cmToPx(.1),majorEvery:10,labelEvery:10,suffix:"cm"}:{minorPx:10,majorEvery:5,labelEvery:10,suffix:"px"},z=1/o,I=v.w*z,F=v.h*z;return(0,t.jsxs)("div",{ref:f,className:`absolute inset-0 ${P?"pointer-events-auto":"pointer-events-none"}`,style:{zIndex:6,cursor:P?"crosshair":"default"},onMouseDown:C,onMouseMove:E,onMouseLeave:()=>M(null),children:[P&&N&&(c=(l={id:"__preview",cxFraction:N.cx,cyFraction:N.cy,lengthPx:Math.min(300,.5*I),angleDeg:0}).cxFraction*I,m=l.cyFraction*F,x=l.lengthPx,(0,t.jsx)("div",{className:"absolute pointer-events-none",style:{left:c-x/2,top:m-18,width:x,height:36,opacity:.7},children:(0,t.jsx)("div",{className:"absolute inset-0 rounded-sm shadow-md",style:{background:"linear-gradient(to bottom, #f0f0f0 0%, #ffffff 30%, #d8d8d8 50%, #ffffff 70%, #c0c0c0 100%)",border:"1px dashed rgba(232, 108, 0, 0.8)"}})})),w.map(r=>{let o=r.cxFraction*I,a=r.cyFraction*F,l=r.lengthPx,c=o-l/2,d=g===r.id,h=Math.floor(r.lengthPx/A.minorPx),m=[];for(let e=0;e<=h;e++){let t,r=e*A.minorPx,o=e%A.majorEvery==0;e%A.labelEvery==0&&e>0&&(t="cm"===n?`${Math.round(r/i.cmToPx(1)*10)/10}`:`${Math.round(r)}`),m.push({x:r,major:o,label:t})}return(0,t.jsxs)("div",{className:"absolute",style:{left:c,top:a-18,width:l,height:36,transform:`rotate(${r.angleDeg}deg)`,transformOrigin:"center",pointerEvents:e?"auto":"none",cursor:e?"grab":"default",touchAction:e?"none":"auto"},onPointerDown:e?e=>L(r.id,"move",e):void 0,children:[(0,t.jsx)("div",{className:"absolute inset-0 rounded-sm shadow-md",style:{background:"linear-gradient(to bottom, #f0f0f0 0%, #ffffff 30%, #d8d8d8 50%, #ffffff 70%, #c0c0c0 100%)",border:"1px solid rgba(0,0,0,0.25)",outline:d?"2px solid #e86c00":"none",outlineOffset:"2px",pointerEvents:"none"},children:(0,t.jsx)("svg",{width:l,height:36,style:{display:"block",pointerEvents:"none"},children:m.map((e,r)=>(0,t.jsxs)("g",{children:[(0,t.jsx)("line",{x1:e.x,y1:0,x2:e.x,y2:e.major?18:9,stroke:"#222",strokeWidth:e.major?1:.5}),e.label&&(0,t.jsx)("text",{x:e.x,y:30.599999999999998,fontSize:11,fontFamily:"monospace",textAnchor:"middle",fill:"#222",children:e.label})]},r))})}),(0,t.jsxs)("div",{className:"absolute flex items-center gap-1",style:{left:"50%",top:44,transform:"translateX(-50%)",pointerEvents:"auto"},onPointerDown:e=>e.stopPropagation(),children:[(0,t.jsx)("button",{type:"button",onClick:e=>
1{e.stopPropagation(),S(r.id)},className:"bg-brown-800 dark:bg-brown-100 wire:bg-black/80 text-white dark:text-brown-900 wire:text-white border border-brown-900 dark:border-brown-300 wire:border-white/60 rounded-md p-1.5 shadow-md hover:bg-brown-900 dark:hover:bg-white wire:hover:bg-black focus:outline-none focus-visible:ring-2 focus-visible:ring-accent backdrop-blur-sm",title:p("viewer.physicalRuler.rotate"),children:(0,t.jsx)(u,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),T(r.id)},className:"bg-red-600 dark:bg-red-500 wire:bg-red-500/90 text-white wire:text-white border border-red-700 dark:border-red-600 wire:border-red-300/60 rounded-md p-1.5 shadow-md hover:bg-red-700 dark:hover:bg-red-600 wire:hover:bg-red-500 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent backdrop-blur-sm",title:p("viewer.physicalRuler.delete"),children:(0,t.jsx)(s.Trash2,{className:"w-3.5 h-3.5"})})]})]},r.id)})]})}e.s(["PhysicalRulerOverlay",0,h],298342);var m=e.i(174080),x=e.i(846932),p=e.i(88653),f=e.i(689664);let w=(0,c.default)("pipette",[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12",key:"1y3wsu"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z",key:"110lr1"}],["path",{d:"m2 22 .414-.414",key:"jhxm08"}]]);function b({active:e,reader:n,readerVersion:i=0,zoomScale:o=1,disabledReason:a}){let{t:l}=(0,d.useTranslation)(),[s,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),m=(0,r.useRef)(null),[x,f]=(0,r.useState)(null),[w,v]=(0,r.useState)(e);e!==w&&(v(e),e||(c(null),h(null))),(0,r.useEffect)(()=>{e||(m.current=null)},[e]),(0,r.useEffect)(()=>{if(!e)return;let t=m.current;if(!t)return;let r=n(t.xf,t.yf);r&&c(r)},[i,e,n]),(0,r.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"!==e.key||e.isComposing||(c(null),h(null))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]);let k=(0,r.useCallback)(e=>{let t=e.currentTarget.getBoundingClientRect(),r=(e.clientX-t.left)/t.width,i=(e.clientY-t.top)/t.height;c(n(r,i)),h({x:e.clientX,y:e.clientY}),m.current={xf:r,yf:i}},[n]),j=(0,r.useCallback)(()=>{c(null),h(null),m.current=null},[]),C=(0,r.useCallback)(async e=>{if(e.stopPropagation(),s)try{await navigator.clipboard.writeText(s),f(s),window.setTimeout(()=>f(null),1800)}catch{}},[s]);return e?a?(0,t.jsx)("div",{className:"absolute inset-0 z-30 flex items-center justify-center pointer-events-auto bg-black/30",children:(0,t.jsx)("div",{className:"bg-white dark:bg-brown-800 wire:bg-black border border-brown-200 dark:border-brown-600 wire:border-white/20 rounded-xl px-4 py-3 shadow-2xl text-sm text-brown-700 dark:text-brown-200 wire:text-white/70",children:l("viewer.eyedropper.unsupported",{reason:a??""})})}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"absolute inset-0",style:{zIndex:7,pointerEvents:"auto",cursor:"crosshair"},onPointerMove:k,onPointerLeave:j,onClick:C}),(0,t.jsx)(p.AnimatePresence,{children:s&&u&&(0,t.jsx)(g,{hex:s,cursorX:u.x,cursorY:u.y})}),(0,t.jsx)(p.AnimatePresence,{children:x&&(0,t.jsx)(y,{hex:x})})]}):(0,t.jsx)(p.AnimatePresence,{children:x&&(0,t.jsx)(y,{hex:x})})}function g({hex:e,cursorX:r,cursorY:n}){if("u"<typeof document)return null;let i=Math.min(window.innerWidth-124-4,r+16),o=Math.min(window.innerHeight-44-4,n+16);return(0,m.createPortal)((0,t.jsx)(x.motion.div,{className:"fixed z-[60] pointer-events-none",style:{left:i,top:o},initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.1},children:(0,t.jsxs)("div",{className:"bg-white dark:bg-brown-800 wire:bg-black border border-brown-200 dark:border-brown-600 wire:border-white/30 rounded-xl shadow-2xl shadow-black/30 px-2 py-1.5 flex items-center gap-2",children:[(0,t.jsx)(w,{className:"w-3 h-3 text-brown-400 dark:text-brown-500 wire:text-white/40 shrink-0"}),(0,t.jsx)("div",{className:"w-7 h-7 rounded-md ring-1 ring-black/15 dark:ring-white/30 wire:ring-white/40 shrink-0",style:{backgroundColor:e}}),(0,t.jsx)("div",{className:"font-mono text-sm text-brown-800 dark:text-white wire:text-white tracking-wider up
1percase",children:e})]})}),document.body)}function y({hex:e}){let{t:r}=(0,d.useTranslation)();return"u"<typeof document?null:(0,m.createPortal)((0,t.jsx)(x.motion.div,{className:"fixed bottom-8 left-1/2 z-[70] pointer-events-none",initial:{opacity:0,y:12,x:"-50%"},animate:{opacity:1,y:0,x:"-50%"},exit:{opacity:0,y:8,x:"-50%"},transition:{duration:.18},children:(0,t.jsxs)("div",{className:"bg-brown-900 dark:bg-brown-100 wire:bg-transparent wire:border wire:border-white/40 text-white dark:text-brown-900 wire:text-white px-4 py-2.5 rounded-full shadow-2xl shadow-black/30 flex items-center gap-2.5",children:[(0,t.jsx)("div",{className:"bg-accent rounded-full w-5 h-5 flex items-center justify-center",children:(0,t.jsx)(f.Check,{className:"w-3 h-3 text-white"})}),(0,t.jsxs)("span",{className:"text-sm",children:[r("viewer.eyedropper.copiedBefore"),(0,t.jsx)("span",{className:"font-mono uppercase",children:e}),r("viewer.eyedropper.copiedAfter")]})]})}),document.body)}function v({active:e,unit:n,conversion:i,zoomScale:o,resetSignal:a}){let l=(0,r.useRef)(null),[s,c]=(0,r.useState)([]),[u,d]=(0,r.useState)(null),[h,m]=(0,r.useState)({w:0,h:0});(0,r.useEffect)(()=>{let e=l.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();m({w:t.width,h:t.height})};t();let r=new ResizeObserver(t);return r.observe(e),window.addEventListener("resize",t),()=>{r.disconnect(),window.removeEventListener("resize",t)}},[e]),(0,r.useEffect)(()=>{e||(c([]),d(null))},[e]),(0,r.useEffect)(()=>{void 0!==a&&(c([]),d(null))},[a]),(0,r.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"!==e.key||e.isComposing||(c([]),d(null))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]);let x=(0,r.useCallback)(e=>{let t=e.currentTarget.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width,y:(e.clientY-t.top)/t.height}},[]),p=(0,r.useCallback)(t=>{if(!e||0!==t.button)return;t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId);let r=x(t);d({id:`${Date.now()}`,x1f:r.x,y1f:r.y,x2f:r.x,y2f:r.y})},[e,x]),f=(0,r.useCallback)(e=>{if(!u)return;let t=x(e);d({...u,x2f:t.x,y2f:t.y})},[u,x]),w=(0,r.useCallback)(e=>{if(!u)return;e.currentTarget.releasePointerCapture(e.pointerId);let t=e.currentTarget.getBoundingClientRect(),r=Math.abs(u.x2f-u.x1f)*t.width,n=Math.abs(u.y2f-u.y1f)*t.height;r>=5&&n>=5&&c(e=>{let t=[...e,u];return t.length>10?t.slice(t.length-10):t}),d(null)},[u]),b=(0,r.useCallback)((e,t)=>{t.stopPropagation(),c(t=>t.filter(t=>t.id!==e))},[]),g=(0,r.useCallback)(e=>0===h.w||0===h.h?{widthPx:0,heightPx:0}:{widthPx:Math.abs(e.x2f-e.x1f)*h.w/o,heightPx:Math.abs(e.y2f-e.y1f)*h.h/o},[h.w,h.h,o]),y=u?[...s,u]:s,k=12/o,j=2/o;return(0,t.jsx)("svg",{ref:l,className:`absolute inset-0 w-full h-full ${e?"pointer-events-auto":"pointer-events-none"}`,style:{zIndex:4,cursor:e?"crosshair":"default"},onPointerDown:p,onPointerMove:f,onPointerUp:w,onPointerCancel:w,children:y.map(e=>{let{widthPx:r,heightPx:a}=g(e),l=function(e,t,r,n){if("px"===r)return`${Math.round(e)} \xd7 ${Math.round(t)} px`;let i=n.pxToCm(e).toFixed(1),o=n.pxToCm(t).toFixed(1);return`${i} \xd7 ${o} cm`}(r,a,n,i),s=e.id===u?.id,c=Math.min(e.x1f,e.x2f),d=Math.min(e.y1f,e.y2f),h=Math.abs(e.x2f-e.x1f),m=Math.abs(e.y2f-e.y1f),x=(c+h/2)*100,p=(d+m/2)*100,f=l.length*k*.65,w=1.4*k;return(0,t.jsxs)("g",{children:[(0,t.jsx)("rect",{x:`${100*c}%`,y:`${100*d}%`,width:`${100*h}%`,height:`${100*m}%`,fill:"rgba(232, 108, 0, 0.08)",stroke:"#e86c00",strokeWidth:j,vectorEffect:"non-scaling-stroke",style:{cursor:s?"crosshair":"pointer"},onClick:s?void 0:t=>b(e.id,t)}),(0,t.jsxs)("g",{style:{pointerEvents:"none"},children:[(0,t.jsx)("rect",{x:`${x}%`,y:`${p}%`,width:f,height:w,rx:3/o,fill:"#e86c00",transform:`translate(${-f/2}, ${-w/2})`}),(0,t.jsx)("text",{x:`${x}%`,y:`${p}%`,fontSize:k,fontFamily:"monospace",textAnchor:"middle",dominantBaseline:"central",fill:"#fff",style:{userSelect:"none"},children:l})]})]},e.id)})})}function k(e,t=0){return{reader:(0,r.useCallback)((t,r)=>{let n=e.current;if(!n||0===n.width)return null;let i=n.getContext("2d",{willReadFrequently:!0});if(!i)return null;try{let e=Math.max(0,Math.min(n.width-1,Math.floor(t*n.width))),o=Math.max(0,Math.min(n.height-1,Math.floor(r*n.height))),a=i.getImageData(e,o,1,1).data;return j(a[0],a[1],a[2])}catch{return null}},[e]),version:t}}function j(e,t,r){return"#"+[e,t,r].map(e=>e.toString(16).padStart(2,"0")).join("")}
1e.s(["Pipette",0,w],661430),e.s(["EyedropperOverlay",0,b],166901),e.s(["RectMeasureOverlay",0,v],907466),e.s(["useCanvasPixelReader",0,k,"useImagePixelReader",0,function(e){let t=(0,r.useRef)(null),n=(0,r.useRef)({w:0,h:0}),i=(0,r.useRef)(null),[o,a]=(0,r.useState)(0);return(0,r.useEffect)(()=>{if(!e||e===i.current)return;i.current=e;let r=new Image;r.crossOrigin="anonymous",r.onload=()=>{let e=document.createElement("canvas");e.width=r.naturalWidth,e.height=r.naturalHeight;let i=e.getContext("2d",{willReadFrequently:!0});if(i){try{i.drawImage(r,0,0)}catch{return}t.current=i,n.current={w:r.naturalWidth,h:r.naturalHeight},a(e=>e+1)}},r.onerror=()=>{t.current=null,n.current={w:0,h:0},a(e=>e+1)},r.src=e},[e]),{reader:(0,r.useCallback)((e,r)=>{let i=t.current,{w:o,h:a}=n.current;if(!i||0===o)return null;try{let t=Math.max(0,Math.min(o-1,Math.floor(e*o))),n=Math.max(0,Math.min(a-1,Math.floor(r*a))),l=i.getImageData(t,n,1,1).data;return j(l[0],l[1],l[2])}catch{return null}},[]),version:o}}],346155);let C=null;async function N(){return C||((C=await e.A(825834)).GlobalWorkerOptions.workerSrc="/pdf.worker.min.mjs"),C}let M=(0,r.forwardRef)(function({src:e,maxPages:s=1/0,planName:c="Free",previewSuggestion:u,annotations:m,selectedAnnotationId:x,onSelectAnnotation:p,onCreateAnnotation:f,onMoveAnnotation:w,onUpdateAnnotation:g,onDeleteAnnotation:y,toolMode:j,pinIcon:C,strokeWidth:M,replyAnnotation:E,replyInitialValue:P,replyInitialAttachments:R,onReplySubmit:$,onReplyCancel:L,bouncingAnnotationId:S,projectId:T,proofId:A,isGuest:z,guestSessionId:I,externalZoom:F,onFirstRender:D,currentVersionId:X,versionNumberMap:U,toolsOverlay:Y,magnifierActive:B,rulerActive:H,rulerUnit:O,rulerConversion:W,physicalRulerActive:_,eyedropperActive:V,rectMeasureActive:Z,readOnly:q,existingReadOnly:K,attachmentsDisabled:G},Q){let{t:J}=(0,d.useTranslation)(),ee=(0,r.useRef)(null),[et,er]=(0,r.useState)(1),[en,ei]=(0,r.useState)(0),[eo,ea]=(0,r.useState)(!0),el=(0,r.useRef)(null),[es,ec]=(0,r.useState)(0),{reader:eu,version:ed}=k(ee,es),eh=(0,n.useZoomPan)({singlePointerPan:()=>!j}),em=F??eh,{scale:ex,transform:ep,wheelRef:ef,contentRef:ew,containerStyle:eb,onPointerDown:eg,onPointerMove:ey,onPointerUp:ev,onPointerCancel:ek,resetView:ej}=em,eC=(0,r.useRef)(!1);(0,r.useEffect)(()=>{eC.current=!1},[e]);let eN=(0,r.useRef)(em);(0,r.useEffect)(()=>{eN.current=em},[em]);let eM=(0,r.useRef)(!!F);(0,r.useEffect)(()=>{eM.current=!!F},[F]);let eE=(0,r.useRef)(D);(0,r.useEffect)(()=>{eE.current=D},[D]),(0,r.useEffect)(()=>{let t=!1;return(async()=>{ea(!0);let r=await N(),n=e;if(e.startsWith("data:")){let t=atob(e.split(",")[1]),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);n={data:r}}let i=r.getDocument({..."string"==typeof n?{url:n}:n,cMapUrl:"/cmaps/",cMapPacked:!0,standardFontDataUrl:"/standard_fonts/"}),o=await i.promise;t||(el.current=o,ei(o.numPages),er(1),ea(!1))})().catch(e=>{console.error("[PdfViewer] PDFèªã¿è¾¼ã¿ã¨ã©ã¼:",e),ea(!1)}),()=>{t=!0}},[e]);let eP=(0,r.useRef)(null),[eR,e$]=(0,r.useState)(null),eL=(0,r.useRef)(B);(0,r.useEffect)(()=>{eL.current=B},[B]);let eS=(0,r.useCallback)(async e=>{let t=el.current,r=ee.current;if(!t||!r)return;if(eP.current){try{eP.current.cancel()}catch{}eP.current=null}let i=await t.getPage(e),o=i.getViewport({scale:1}),a=Math.max(o.width,o.height),l=2;!eM.current&&a*l<1600&&(l=1600/a);let s=i.getViewport({scale:l});r.width=s.width,r.height=s.height;let c=r.getContext("2d");if(!c)return;let u=i.render({canvas:r,canvasContext:c,viewport:s});eP.current=u;try{if(await u.promise,eL.current)try{e$(r.toDataURL("image/jpeg",.85))}catch{e$(null)}ec(e=>e+1),eM.current||eC.current||(eN.current.fitToViewport(r.width,r.height,{bottomOffset:n.APPROVAL_BAR_OFFSET_PX}),eC.current=!0),eE.current?.(r.width,r.height)}catch(e){if(e instanceof Error&&"RenderingCancelledException"===e.name)return;console.error("[PdfViewer] ã¬ã³ããªã³ã°ã¨ã©ã¼:",e)}},[]);(0,r.useEffect)(()=>{if(!B)return void e$(null);let e=ee.current;if(e&&e.width>0)try{e$(e.toDataURL("image/jpeg",.85))}catch{e$(null)}},[B,et]),(0,r.useEffect)(()=>{en>0&&eS(et)},[et,en,eS]),(0,r.useEffect)(()=>
1{if(!x||!m||0===en)return;let e=m.find(e=>e.id===x);if(!e)return;let t=e.page??1;t!==et&&t>=1&&t<=en&&er(t)},[x,m,en]),(0,r.useImperativeHandle)(Q,()=>({getCurrentPageImage:()=>{let e=ee.current;if(!e)return null;try{return e.toDataURL("image/jpeg",.85).split(",")[1]??null}catch{return null}},getCurrentMediaType:()=>"image/jpeg",getCurrentPageNumber:()=>et,getTotalPages:()=>en,gotoPage:e=>{er(Math.min(en,Math.max(1,e)))},getAllPagesImages:async e=>{let t=el.current,r=ee.current;if(!t||!r)return[];if(eP.current){try{eP.current.cancel()}catch{}eP.current=null}let n=Math.min(t.numPages,e??t.numPages),i=[{scale:2,quality:.85},{scale:1.5,quality:.7},{scale:1.2,quality:.6},{scale:1,quality:.5}],o=async(e,i)=>{let o=[];for(let a=1;a<=n;a++){let n=await t.getPage(a),l=n.getViewport({scale:e});r.width=l.width,r.height=l.height;let s=r.getContext("2d");if(!s)continue;let c=n.render({canvas:r,canvasContext:s,viewport:l});eP.current=c;try{await c.promise}catch(e){if("RenderingCancelledException"===e?.name)continue;throw e}try{let e=r.toDataURL("image/jpeg",i).split(",")[1];e&&o.push({page:a,base64:e})}catch(e){console.warn("[PdfViewer] toDataURL failed for page",a,e)}}return o};try{let e=[];for(let t=0;t<i.length;t++){let{scale:r,quality:a}=i[t],l=(e=await o(r,a)).reduce((e,t)=>e+t.base64.length,0);if(l<=38e5||t===i.length-1){l>38e5&&console.warn(`[PdfViewer] ${n}ãã¼ã¸ãæå°å質ã§ã ${(l/1e6).toFixed(1)}MBï¼äºç® 3.8MB è¶
éï¼`);break}console.info(`[PdfViewer] ç»ååè¨ ${(l/1e6).toFixed(1)}MB ãäºç®è¶
é â scale/quality ãä¸ãã¦åçæï¼${t+2}/${i.length} 段ï¼`)}return e}finally{eP.current=null,et>=1&&et<=t.numPages&&await eS(et).catch(()=>{})}}}),[et,en,eS]);let eT=Math.min(en,s>0?s:1/0),eA=s>0&&s<en,ez=(0,r.useCallback)(e=>{let t=Math.min(eT,Math.max(1,e));if(er(t),x&&m){let e=m.find(e=>e.id===x);e&&(e.page??1)!==t&&p?.(null)}},[eT,x,m,p]);return eo?(0,t.jsx)("div",{className:"flex items-center justify-center h-full bg-brown-50 dark:bg-brown-900 wire:bg-black",children:(0,t.jsx)("div",{className:"animate-pulse text-accent-light",children:J("viewer.pdf.loading")})}):(0,t.jsxs)("div",{className:"relative w-full h-full flex flex-col bg-brown-50 dark:bg-brown-900 wire:bg-black",children:[(0,t.jsxs)("div",{className:"shrink-0 h-10 bg-white dark:bg-brown-800 wire:bg-black border-b border-brown-200 dark:border-brown-700 wire:border-white/20 flex items-center justify-center gap-3 px-4",children:[(0,t.jsxs)("button",{onClick:()=>ez(et-1),disabled:et<=1,className:"px-2 py-1 text-sm text-brown-600 dark:text-brown-300 wire:text-white/60 hover:text-brown-900 dark:hover:text-white wire:hover:text-white disabled:text-brown-300 dark:disabled:text-brown-600 wire:disabled:text-white/20 disabled:cursor-not-allowed transition-colors",children:["â ",J("viewer.pdf.prev")]}),(0,t.jsxs)("span",{className:"text-sm text-brown-600 dark:text-brown-300 wire:text-white/60",children:[(0,t.jsx)("input",{type:"number",value:et,onChange:e=>ez(Number(e.target.value)),min:1,max:eT,className:"w-12 text-center bg-brown-100 dark:bg-brown-700 wire:bg-black text-brown-900 dark:text-white wire:text-white rounded px-1 py-0.5 text-sm [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none"}),(0,t.jsxs)("span",{className:"ml-1",children:["/ ",eA?J("viewer.pdf.pageCountLimited",{max:eT,total:en}):en]})]}),(0,t.jsxs)("button",{onClick:()=>ez(et+1),disabled:et>=eT,className:"px-2 py-1 text-sm text-brown-600 dark:text-brown-300 wire:text-white/60 hover:text-brown-900 dark:hover:text-white wire:hover:text-white disabled:text-brown-300 dark:disabled:text-brown-600 wire:disabled:text-white/20 disabled:cursor-not-allowed transition-colors",children:[J("viewer.pdf.next")," â"]}),eA&&(0,t.jsx)("span",{className:"text-[10px] text-amber-400 ml-2",children:J("viewer.pdf.planPageLimit",{plan:c,max:s})})]}),(0,t.jsx)("div",{className:`flex-1 overflow-hidden select-none relative ${j?"cursor-crosshair":F?"":"cursor-grab active:cursor-grabbing"}`,ref:F?void 0:ef,style:F?void 0:eb,onPointerDown:F?void 0:eg,onPointerMove:F?void 0:ey,onPointerUp:F?void 0:ev,onPointerCancel:F?void 0:ek,onDoubleClick:F||j?void 0:ej,children:(0,t.jsxs)("div",{ref:F?void 0:e
1w,className:"absolute inset-0",style:{transform:ep,transformOrigin:"0 0",willChange:"transform"},children:[(0,t.jsxs)("div",{className:"relative inline-block",children:[(0,t.jsx)("canvas",{ref:ee,className:"max-w-none shadow-2xl block",style:{maxHeight:"none"}}),Y,H&&W&&O&&(0,t.jsx)(l,{active:!0,unit:O,conversion:W,zoomScale:ex}),(0,t.jsx)(a,{active:!!B,sourceUrl:eR,zoomScale:ex}),_&&W&&O&&(0,t.jsx)(h,{active:!0,unit:O,conversion:W,zoomScale:ex}),(0,t.jsx)(b,{active:!!V,reader:eu,readerVersion:ed,zoomScale:ex}),Z&&W&&O&&(0,t.jsx)(v,{active:!0,unit:O,conversion:W,zoomScale:ex}),u&&(void 0===u.page||u.page===et)&&(0,t.jsx)(i.GhostSuggestion,{suggestion:u}),f&&(0,t.jsx)("div",{className:"absolute inset-0",children:(0,t.jsx)(o.AnnotationLayer,{annotations:m??[],visibleFilter:e=>(e.page??1)===et,selectedId:x??null,onSelect:p??(()=>{}),onCreate:e=>f({...e,page:et}),onMove:w,onUpdate:g,onDelete:y,toolMode:j??null,pinIcon:C,strokeWidth:M,replyAnnotation:E,replyInitialValue:P,replyInitialAttachments:R,onReplySubmit:$,onReplyCancel:L,bouncingAnnotationId:S,projectId:T,proofId:A,isGuest:z,guestSessionId:I,currentVersionId:X,versionNumberMap:U,readOnly:q,existingReadOnly:K,attachmentsDisabled:G,zoomScale:ex})})]}),eA&&et>=eT&&(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-brown-100/80 dark:bg-brown-900/70 wire:bg-black/80 backdrop-blur-sm",children:(0,t.jsxs)("div",{className:"bg-white dark:bg-brown-800 wire:bg-black border border-brown-200 dark:border-brown-600 wire:border-white/30 rounded-2xl p-8 max-w-sm text-center shadow-2xl",children:[(0,t.jsx)("div",{className:"text-3xl mb-3",children:"ð"}),(0,t.jsx)("h3",{className:"text-lg font-bold text-brown-900 dark:text-white wire:text-white mb-2",children:J("viewer.pdf.limitReachedTitle")}),(0,t.jsxs)("p",{className:"text-sm text-brown-600 dark:text-brown-400 wire:text-white/50 mb-4",children:[J("viewer.pdf.limitReachedLine1",{plan:c,max:s}),(0,t.jsx)("br",{}),J("viewer.pdf.limitReachedLine2",{total:en})]}),(0,t.jsx)("button",{className:"px-6 py-2.5 bg-accent hover:bg-accent-dark text-white text-sm font-semibold rounded-xl transition-colors",children:J("viewer.pdf.upgrade")})]})})]})}),!F&&(0,t.jsxs)("div",{className:"absolute bottom-4 right-4 px-3 py-1.5 bg-black/60 backdrop-blur-sm rounded-lg text-xs text-white font-mono",children:[Math.round(100*ex),"%"]})]})})},505973,639938,356982,e=>{"use strict";e.s(["LightboxProvider",()=>E,"useLightbox",()=>M],505973);var t=e.i(843476),r=e.i(271645),n=e.i(174080),i=e.i(88653),o=e.i(846932),a=e.i(24071),l=e.i(867927),s=e.i(762368),c=e.i(581866),u=e.i(632781),d=e.i(263676);e.s(["OfficeViewer",()=>w],356982);var h=e.i(959141),m=e.i(457229),x=e.i(123837);let p=["viewer.conversion.step.received","viewer.conversion.step.parsing","viewer.conversion.step.rendering","viewer.conversion.step.saving"];function f({fileName:e,proofType:n,estimatedSeconds:i,pageCount:o}){let a,{t:l}=(0,m.useTranslation)(),[s,c]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=Date.now(),t=setInterval(()=>{c(Math.floor((Date.now()-e)/1e3))},250);return()=>clearInterval(t)},[]);let u=i??30,{activeStep:d}=(a=Math.max(8,u),s<2?{activeStep:0,completedSteps:0}:s<5?{activeStep:1,completedSteps:1}:s<Math.max(6,a-3)?{activeStep:2,completedSteps:2}:{activeStep:3,completedSteps:3}),h=s>u+5,x=l(function(e){switch(e){case"slide":return"viewer.conversion.type.slide";case"document":return"viewer.conversion.type.document";case"sheet":return"viewer.conversion.type.sheet";case"design":return"viewer.conversion.type.design";default:return"viewer.conversion.type.file"}}(n)),w=l(function(e){switch(e){case"slide":default:return"viewer.conversion.unit.slide";case"document":return"viewer.conversion.unit.document";case"sheet":return"viewer.conversion.unit.sheet"}}(n)),b=o&&o>1?l("viewer.conversion.subTitleWithCount",{type:x,count:o,unit:w}):l("viewer.conversion.subTitle",{type:x});return(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center p-8",children:(0,t.jsxs)("div",{className:"w-full max-w-md flex flex-col gap-5 p-7 bg-white/70 backdrop-blur-xl border border-brown-200 rounded-2xl shadow-xl dark:bg-brown-900/60 dark:border-brown-700/60 wire:bg-transparent wire:border wire:border-white/20 wire:backdrop-blur-none wire:shadow-none",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-brown-700 dark:text-brown-200 wire:text-white truncate",title:e,children:e}),(0,t.jsx)("p",{className:"text-xs text-brown-500 dark:text-brown-400 wire:text-white/60",children:b})]}),(0,t.jsx)("ol",{className:"flex flex-col gap-3",children:p.map((e,r)=>{let n=r<d,i=r===d,a=r>d,c=l(e);return(0,t.jsxs)("li",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{"aria-hidden":!0,
1className:["inline-flex items-center justify-center w-6 h-6 rounded-full text-xs font-bold flex-shrink-0","transition-all duration-300",n&&"bg-accent text-white wire:bg-transparent wire:border wire:border-white wire:text-white",i&&"bg-accent/20 text-accent ring-2 ring-accent/40 animate-pulse dark:bg-accent/30 dark:text-accent dark:ring-accent/50 wire:bg-transparent wire:border wire:border-white wire:text-white wire:ring-0",a&&"bg-brown-100 text-brown-400 dark:bg-brown-800 dark:text-brown-500 wire:bg-transparent wire:border wire:border-white/30 wire:text-white/30"].filter(Boolean).join(" "),children:n?"â":i?"â":"â"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex items-baseline justify-between gap-2",children:[(0,t.jsxs)("span",{className:["text-sm transition-colors duration-300",n&&"text-brown-700 dark:text-brown-200 wire:text-white",i&&"text-brown-900 dark:text-brown-100 wire:text-white font-medium",a&&"text-brown-400 dark:text-brown-500 wire:text-white/40"].filter(Boolean).join(" "),children:[c,1===r&&n&&o&&o>1&&(0,t.jsxs)("span",{className:"ml-1.5 text-xs text-brown-500 dark:text-brown-400 wire:text-white/60",children:["(",o," ",w,")"]})]}),i&&(0,t.jsxs)("span",{className:"text-xs tabular-nums text-brown-500 dark:text-brown-400 wire:text-white/60 flex-shrink-0",children:[s,"s",!h&&(0,t.jsxs)(t.Fragment,{children:[" / ç´ ",u,"s"]})]})]})]},e)})}),(0,t.jsxs)("div",{className:"flex items-start gap-2 pt-4 border-t border-brown-200 dark:border-brown-700/60 wire:border-white/15",children:[(0,t.jsx)("span",{"aria-hidden":!0,className:"text-base leading-none flex-shrink-0 mt-0.5",children:"â¡"}),(0,t.jsxs)("p",{className:"text-xs leading-relaxed text-brown-600 dark:text-brown-300 wire:text-white/60",children:[l("viewer.conversion.footerLine1"),(0,t.jsx)("br",{}),l("viewer.conversion.footerLine2")]})]})]})})}e.s(["ConversionProgress",0,f],639938);let w=(0,r.forwardRef)(function({fileURL:e,fileName:n,previewSuggestion:i,annotations:o,selectedAnnotationId:a,onSelectAnnotation:l,onCreateAnnotation:c,onMoveAnnotation:u,onUpdateAnnotation:d,onDeleteAnnotation:p,toolMode:w,pinIcon:b,strokeWidth:g,replyAnnotation:y,replyInitialValue:v,replyInitialAttachments:k,onReplySubmit:j,onReplyCancel:C,bouncingAnnotationId:N,projectId:M,proofId:E,isGuest:P,guestSessionId:R,externalZoom:$,onFirstRender:L,currentVersionId:S,versionNumberMap:T,toolsOverlay:A,magnifierActive:z,rulerActive:I,rulerUnit:F,rulerConversion:D,physicalRulerActive:X,eyedropperActive:U,rectMeasureActive:Y,readOnly:B,existingReadOnly:H,attachmentsDisabled:O,convertedURL:W,conversionStatus:_,conversionPageCount:V,conversionEstimatedSeconds:Z,proofType:q,maxPages:K=1/0,planName:G=""},Q){let{t:J}=(0,m.useTranslation)(),[ee,et]=(0,r.useState)(null),[er,en]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(et(null),en(null),!W)return;let e=!1;return(async()=>{try{let t=await h.auth.currentUser?.getIdToken();if(e||!t)return;let r=await fetch(`/api/storage/signed-read?path=${encodeURIComponent(W)}`,{headers:{Authorization:`Bearer ${t}`}}),n=await r.json().catch(()=>({}));if(e)return;if(!r.ok||!n?.url)return void en(n?.error||`Signed URL åå¾å¤±æ (HTTP ${r.status})`);et(n.url)}catch(t){e||en(t instanceof Error?t.message:"Signed URL åå¾å¤±æ")}})(),()=>{e=!0}},[W]);let[ei,eo]=(0,r.useState)(null),[ea,el]=(0,r.useState)(!1),[es,ec]=(0,r.useState)(null),eu=!W&&("failed"===_||void 0===_);if((0,r.useEffect)(()=>{if(!eu){eo(null),el(!1),ec(null);return}let t=!1;return el(!0),ec(null),(async()=>{try{let r=await fetch("/api/convert-office",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileUrl:e,fileName:n})});if(t)return;if(!r.ok){let e=await r.json();throw Error(e.error||"夿ã«å¤±æãã¾ãã")}let i=await r.json();t||eo(i.pdf)}catch(e){t||ec(e instanceof Error?e.message:"夿ã«å¤±æãã¾ãã")}finally{t||el(!1)}})(),()=>{t=!0}},[eu,e,n]),"pending"===_||"processing"===_)return(0,t.jsx)(f,{fileName:n,proofType:q??"slide",estimatedSeconds:Z,pageCount:V});if(ea)return(0,t.jsxs)("div",{className:"w-full h-full flex flex-col items-center justify-center gap-4",children:[(0,t.jsx)("div",{className:"w-8 h-8 border-2 border-accent border-t-transparent roun
1ded-full animate-spin"}),(0,t.jsx)("p",{className:"text-sm text-brown-500 dark:text-brown-400 wire:text-white/40",children:J("viewer.office.converting")})]});if(W&&!ee&&!er)return(0,t.jsxs)("div",{className:"w-full h-full flex flex-col items-center justify-center gap-3",children:[(0,t.jsx)("div",{className:"w-6 h-6 border-2 border-accent border-t-transparent rounded-full animate-spin"}),(0,t.jsx)("p",{className:"text-xs text-brown-500 dark:text-brown-400 wire:text-white/40",children:J("viewer.office.loading")})]});let ed=ee??ei;return(er??es)||!ed?(0,t.jsxs)("div",{className:"w-full h-full flex flex-col items-center justify-center gap-4 text-brown-500 dark:text-brown-400 wire:text-white/40 px-6 text-center",children:[(0,t.jsx)("div",{className:"text-3xl",children:"ð"}),(0,t.jsx)("p",{className:"text-sm font-semibold text-brown-700 dark:text-brown-200 wire:text-white",children:J("viewer.office.unsupportedTitle")}),(0,t.jsxs)("ul",{className:"text-xs text-brown-500 dark:text-brown-400 wire:text-white/60 max-w-md space-y-1 list-disc list-inside text-left",children:[(0,t.jsx)("li",{children:J("viewer.office.unsupportedReason1")}),(0,t.jsx)("li",{children:J("viewer.office.unsupportedReason2")}),(0,t.jsx)("li",{children:J("viewer.office.unsupportedReason3")})]}),(0,t.jsx)("p",{className:"text-xs text-brown-500 dark:text-brown-400 wire:text-white/60 max-w-md",children:J("viewer.office.unsupportedHint")}),(0,t.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-5 py-2.5 bg-accent hover:bg-accent-dark wire:bg-transparent wire:border wire:border-white wire:hover:bg-white/10 text-white text-sm font-semibold rounded-xl transition-colors",children:[(0,t.jsx)(s.Download,{className:"w-4 h-4"})," ",J("viewer.office.downloadFile")]})]}):(0,t.jsx)(x.PdfViewer,{ref:Q,src:ed,maxPages:K,planName:G,previewSuggestion:i,annotations:o,selectedAnnotationId:a,onSelectAnnotation:l,onCreateAnnotation:c,onMoveAnnotation:u,onUpdateAnnotation:d,onDeleteAnnotation:p,toolMode:w,pinIcon:b,strokeWidth:g,replyAnnotation:y,replyInitialValue:v,replyInitialAttachments:k,onReplySubmit:j,onReplyCancel:C,bouncingAnnotationId:N,projectId:M,proofId:E,isGuest:P,guestSessionId:R,externalZoom:$,onFirstRender:L,currentVersionId:S,versionNumberMap:T,toolsOverlay:A,magnifierActive:z,rulerActive:I,rulerUnit:F,rulerConversion:D,physicalRulerActive:X,eyedropperActive:U,rectMeasureActive:Y,readOnly:B,existingReadOnly:H,attachmentsDisabled:O})});w.displayName="OfficeViewer";let b=/^application\/(msword|vnd\.ms-excel|vnd\.ms-powerpoint|vnd\.openxmlformats-officedocument\..+)$/;function g({items:e,initialIndex:c,onClose:u}){let{t:h}=(0,m.useTranslation)(),x=(0,r.useMemo)(()=>0===e.length?0:Math.max(0,Math.min(c,e.length-1)),[c,e.length]),[p,f]=(0,r.useState)(x),[w,b]=(0,r.useState)(!1);(0,r.useEffect)(()=>{b(!0)},[]),(0,r.useEffect)(()=>{f(x)},[x]);let v=(0,r.useCallback)(()=>{f(t=>(t-1+e.length)%e.length)},[e.length]),k=(0,r.useCallback)(()=>{f(t=>(t+1)%e.length)},[e.length]);(0,r.useEffect)(()=>{let t=t=>{"Escape"===t.key?(t.stopImmediatePropagation(),t.preventDefault(),u()):"ArrowLeft"===t.key&&e.length>1?(t.stopImmediatePropagation(),v()):"ArrowRight"===t.key&&e.length>1&&(t.stopImmediatePropagation(),k())};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[k,v,e.length,u]),(0,r.useEffect)(()=>{let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[]);let j=e[p],C=(0,r.useCallback)(()=>{if(!j?.signedUrl)return;let e=document.createElement("a");e.href=j.signedUrl,e.download=j.fileName,e.target="_blank",e.rel="noopener noreferrer",document.body.appendChild(e),e.click(),document.body.removeChild(e)},[j]),N=(0,r.useCallback)(e=>{e.target===e.currentTarget&&u()},[u]);if(!w||0===e.length||!j)return null;let M=e.length>1;return(0,n.createPortal)((0,t.jsxs)(i.AnimatePresence,{children:[(0,t.jsx)(o.motion.div,{className:"dark fixed inset-0 z-[100] bg-black/90",initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},onMouseDown:N,onPointerDown:e=>{"mouse"!==e.pointerType&&N(e)},"aria-hidden":"true"},"lightbox-backdrop"),(0,t.jsxs)(o.motion.div,{role:"dialog","aria-modal":"true","aria-label":h("comments.lightbox.title"),className:"dark fixed inset-x-4 top-12 bottom-12 max-w-6xl mx-auto z-[101] bg-zinc-900 border border-white/10 rounded-2xl flex flex-col overflow-hidden",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/10 shrink-0",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"text-base font-semibold text-white truncate",children:j.fileName}),(0,t.jsx)("p",{className:"text-xs text-white/50 mt-0.5 truncate",children:j.mimeType})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 ml-3 shrink-0",children:[j.signedUrl&&(0,t.jsxs)("button",{type:"button",onClick:C,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-white/10 hover:bg-white/20 text-white transition-colors",children:[(0,t.jsx)(s.Download,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:h("comments.lightbox.download")})]}),(0,t.jsx)("button",{type:"button",onClick:u,className:"p-2 rounded-lg text-white/60 hover:text-white hover:bg-white/10 transition-colors","aria-label":h("common.close"),children:(0,t.jsx)(d.X,{className:"w-5 h-5"})})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-hidden flex items-center justify-center bg-black relative",children:[(0,t.jsx)(y,{item:j},`${p}-${j.signedUrl??"pending"}`),M&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:v,"aria-label":h("comments.lightbox.prev"),className:"absolute left-4 top-1/2 -translate-y-1/2 z-10 p-3 rounded-full bg-white/10 hover:bg-white/20 text-white transition-colors",children:(0,t.jsx)(a.ChevronLeft,{className:"w-5 h-5"})}),(0,t.jsx)("button",{type:"button",onClick:k,"aria-label":h("comments.lightbox.next"),className:"absolute right-4 top-1/2 -translate-y-1/2 z-10 p-3 rounded-full bg-white/10 hover:bg-white/20 text-white transition-colors",children:(0,t.jsx)(l.ChevronRight,{className:"w-5 h-5"})})]})]}),M&&(0,t.jsxs)("div",{className:"px-5 py-2 border-t border-white/10 flex items-center justify-center text-sm text-white/70 shrink-0",children:[p+1," / ",e.length]})]},"lightbox-modal")]}),document.body)}function y({item:e}){var r;return e.error?(0,t.jsx)(j,{message:e.error,fileName:e.fileName}):null==e.signedUrl?(0,t.jsx)(k,{}):e.mimeType.startsWith("image/")?(0,t.jsx)(v,{signedUrl:e.signedUrl,fileName:e.fileName}):"application/pdf"===e.mimeType?(0,t.jsx)("div",{className:"w-full h-full",children:(0,t.jsx)(x.PdfViewer,{src:e.signedUrl})}):(r=e.mimeType,b.test(r))?(0,t.jsx)("div",{className:"w-full h-full",children:(0,t.jsx)(w,{fileURL:e.signedUrl,fileName:e.fileName})}):(0,t.jsx)(C,{fileName:e.fileName})}function v({signedUrl:e,fileName:n}){let{t:i}=(0,m.useTranslation)(),[o,a]=(0,r.useState)(!1);return o?(0,t.jsx)(j,{message:i("comments.lightbox.imageError"),fileName:n}):(0,t.jsx)("img",{src:e,alt:n,className:"max-w-full max-h-full object-contain",onError:()=>a(!0)})}function k(){let{t:e}=(0,m.useTranslation)();return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 text-white/70",children:[(0,t.jsx)(u.Loader2,{className:"w-8 h-8 animate-spin text-accent"}),(0,t.jsx)("p",{className:"text-sm",children:e("common.loading")})]})}function j({message:e,fileName:r}){return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 text-white/70 px-6",children:[(0,t.jsx)(c.FileX,{className:"w-12 h-12 text-red-400"}),(0,t.jsx)("p",{className:"text-sm font-medium text-red-300",children:e}),(0,t.jsx)("p",{className:"text-xs text-white/50 truncate max-w-md",children:r})]})}function C({fileName:e}){let{t:r}=(0,m.useTranslation)();return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 text-white/70 px-6",children:[(0,t.jsx)(c.FileX,{className:"w-12 h-12 text-amber-400"}),(0,t.jsx)("p",{className:"text-sm font-medium",children:r("comments.lightbox.unsupported")}),(0,t.jsx)("p",{className:"text-xs text-white/50 truncate max-w-md",children:e})]})}let N=(0,r.createContext)(null);function M(){let e=(0,r.useContext)(N);if(!e)throw Error("useLightbox 㯠LightboxProvider ã®å
å´ã§ä½¿ãå¿
è¦ãããã¾ã");return e}function E({children:e}){let[n,i]=(0,r.useState)([]),[o,a]=(0,r.useState)(null),l=(0,r.useRef)(0),[s,c]=(0,r.useState)(0),u=(0,r.useCallback)((e,t)=>(l.current+=1,c(l.current),i(e),a(t),l.current),[]),d=(0,r.useCallback)(()=>{a(null),i([])},[]),h=(0,r.useCallback)((e,t,r)=>{e===l.current&&i(e=>{if(t<0||t>=e.length)return e;let n=[...e];return n[t]={...n[t],...r},n})},[]),m=(0,r.useMemo)(()=>({open:u,close:d,patchItem:h}),[u,d,h]);return(0,t.jsxs)(N.Provider,{value:m,children:[e,null!==o&&n.length>0&&(0,t.jsx)(g,{items:n,initialIndex:o,onClose:d},s)]})}}]);
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.