1"use strict";(self.webpackChunk_overleaf_web=self.webpackChunk_overleaf_web||[]).push([[6473],{59378:(e,t,n)=>{n.r(t),n.d(t,{default:()=>qe});var r=n(43144),s=n(8005),o=n(14041),a=n(53373),i=n.n(a),c=n(22160),l=n(97434),d=n(88355),u=n(31085);const m=()=>{const e=(0,d.oQ)(),{setView:t}=(0,d.Jc)(),{t:n}=(0,l.Bd)();return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("button",{role:"tab","aria-selected":"cur_file"===e,"aria-controls":"review-panel-current-file",id:"review-panel-tab-button-current-file",className:i()("review-panel-tab",{"review-panel-tab-active":"cur_file"===e}),onClick:()=>t("cur_file"),children:[(0,u.jsx)(c.A,{type:"description"}),n("current_file")]}),(0,u.jsxs)("button",{role:"tab","aria-selected":"overview"===e,"aria-controls":"review-panel-overview",id:"review-panel-tab-button-overview",className:i()("review-panel-tab",{"review-panel-tab-active":"overview"===e}),onClick:()=>t("overview"),children:[(0,u.jsx)(c.A,{type:"list"}),n("overview")]})]})},p=(0,o.memo)(m);var h=n(7798),v=(n(82438),n(50020),n(57195)),g=n(90201),w=n(2997),f=n(68915),x=n(69051),_=n(6689),b=n(15501),y=n(45250),j=n.n(y);const k=(0,y.debounce)(((e,t,n,r)=>{const s=Array.from(e.querySelectorAll(".review-panel-entry"));if(s.sort(((e,t)=>Number(e.dataset.pos)-Number(t.dataset.pos))),!s.length)return;let o=s.findIndex((e=>e.classList.contains("review-panel-entry-selected")));-1===o&&(o=s.findIndex((e=>e.classList.contains("review-panel-entry-highlighted")))),-1===o&&(o=t||0);const a=s[o];if(!a)return;const i=C(a,0===o,r),c=[];c.push([a,i]);let l=i;for(let e=o-1;e>=0;e--){const t=s[e],n=t.offsetHeight;let o=C(t,0===e,r);o+n>l&&(o=l-n-4),c.push([t,o]),l=o}let d=i+a.offsetHeight;for(let e=o+1;e<s.length;e++){const t=s[e],n=t.offsetHeight;let o=C(t,!1,r);o<d&&(o=d+4),c.push([t,o]),d=o+n}for(const[e,t]of c)e.style.top=`${t}px`,e.style.visibility="visible";return{docId:n,activeItemIndex:o}}),100,{leading:!1,trailing:!0,maxWait:1e3});function C(e,t,n){const r=t?0:70;return n?Math.max(r,Number(e.dataset.top)):Math.max(42+r,Number(e.dataset.top))}var M=n(14233);const N=(0,o.memo)((function(e){let{handleMouseEnter:t,handleMouseLeave:n,handleMouseDown:r,type:s}=e;return(0,u.jsx)("div",{className:"review-panel-entry-indicator",onMouseEnter:t,onMouseLeave:n,onMouseDown:r,role:"button",tabIndex:0,children:(0,u.jsx)(c.A,{type:s,className:"review-panel-entry-icon"})})}));var A=n(83173);const I=e=>{let{children:t,position:n,top:r,op:a,className:c,selectLineOnFocus:l=!0,docId:d,hoverRanges:m=!0,disabled:p,handleEnter:h,handleLeave:g,entryIndicator:w}=e;const f=(0,s.Q_)(),y=(0,s.u9)(),{openDocWithId:j,getCurrentDocumentId:k}=(0,b.TS)(),[C,I]=(0,o.useState)(!1),[E,L]=(0,o.useState)(!1),[T,R]=(0,o.useState)(!1),{openReviewPanel:B}=(0,M.A)(),O=(0,x.H)(a,f.selection.main),S=(0,o.useRef)(null),P=(0,o.useRef)(!1),D=(0,o.useCallback)((e=>{if(L(!0),e.target instanceof HTMLTextAreaElement){if((S.current?.offsetTop||0)+(S.current?.offsetHeight||0)>70)return void R(!0)}P.current||(I(!0),l&&(k()!==d?j(d,{gotoOffset:n,keepCurrentView:!0}):setTimeout((()=>{const e=v.OF.cursor(n);if(n<y.viewport.from||y.viewport.to<n)return void y.dispatch({selection:e,effects:A.Lz.scrollIntoView(e,{y:"center"})});y.dispatch({selection:e});const t=y.lineBlockAt(n),r=y.coordsAtPos(n),s=y.coordsAtPos(t.from);let o=0;null!==r&&null!==s&&(o=r.top-s.top);const a=y.scrollDOM.getBoundingClientRect().height;y.scrollDOM.scrollTo({top:t.top-a/2+y.defaultLineHeight+o,behavior:"smooth"})}))))}),[k,d,l,y,n,j]);return(0,o.useEffect)((()=>()=>{m&&setTimeout((()=>{y.dispatch((0,_.uo)(a))}))}),[]),(0,u.jsxs)("div",{ref:S,onMouseDown:()=>{P.current=!0},onMouseUp:e=>{P.current=!1;Boolean(window.getSelection()?.toString())||C||D(e)},onFocus:D,onBlur:()=>{P.current=!1,I(!1),L(!1),R(!1)},onMouseEnter:()=>{m&&y.dispatch((0,_.jv)(a))},onMouseLeave:()=>{m&&y.dispatch((0,_.uo)(a))},role:"button",tabIndex:n+1,className:i()("review-panel-entry",{"review-panel-entry-selected":C,"review-panel-entry-focused":E,"review-panel-entry-highlighted":O,"review-panel-entry-textarea-focused":T,"review-panel-entry-disabled":p}
1,c),"data-top":r,"data-pos":n,style:{position:void 0===r?"relative":"absolute",visibility:void 0===r?"visible":"hidden",transition:"top .3s, left .1s, right .1s"},children:[w&&(0,u.jsx)(N,{type:w,handleMouseEnter:h,handleMouseLeave:g,handleMouseDown:B}),t]})};var E=n(89464),L=n(4454),T=n(60225),R=n(81670);const B=(0,o.memo)((function(e){let{from:t,to:n,threadId:r,top:a,docId:i}=e;const{t:c}=(0,l.Bd)(),d=(0,s.u9)(),m=(0,s.Q_)(),{addComment:p}=(0,g.v0)(),[h,x]=(0,o.useState)(!1),{showGenericMessageModal:_}=(0,E.T)(),[b,y]=(0,o.useState)(""),j=(0,o.useCallback)((()=>{d.dispatch({effects:w.if.of(r)})}),[d,r]),k=(0,o.useCallback)((async()=>{if(0===b.trim().length)return;x(!0);const e=d.state.sliceDoc(t,n);try{await p(t,e,b),j(),d.dispatch({selection:v.OF.cursor(d.state.selection.main.anchor)})}catch(e){L.$.error(e),_(c("add_comment_error_title"),c("add_comment_error_message"))}x(!1)}),[b,d,t,n,p,j,_,c]),C=(0,o.useCallback)((e=>{(0,R.l)(e)&&(e.preventDefault(),k())}),[k]),M=(0,o.useCallback)((e=>{y(e.target.value)}),[]),N=(0,o.useCallback)((()=>{""===b&&window.setTimeout((()=>{j()}))}),[b,j]),A=(0,o.useCallback)((e=>{e.preventDefault(),k()}),[k]),B=(0,o.useRef)(!1),O=(0,o.useCallback)((e=>{if(!B.current)for(const t of e){const e=t.target;if(e.style.top){const t=e.getElementsByTagName("textarea")[0];t&&(t.focus(),B.current=!0)}}}),[]),S=(0,o.useRef)(null),P=(0,o.useCallback)((e=>{if(e){e.dispatchEvent(new Event("review-panel:position")),S.current=new MutationObserver(O);const t=e.closest(".review-panel-entry");t&&S.current.observe(t,{attributes:!0,attributeFilter:["style"]})}else S.current&&S.current.disconnect()}),[O]);return(0,u.jsx)(I,{docId:i,top:a,position:t,op:{p:t,c:m.sliceDoc(t,n),t:r},selectLineOnFocus:!1,disabled:h,children:(0,u.jsxs)("form",{className:"review-panel-entry-content",onBlur:N,onSubmit:A,ref:P,children:[(0,u.jsx)(f.A,{name:"message",className:"review-panel-add-comment-textarea",onChange:M,onKeyPress:C,placeholder:c("add_your_comment_here"),value:b,disabled:h}),(0,u.jsxs)("div",{className:"review-panel-add-comment-buttons",children:[(0,u.jsx)(T.A,{variant:"ghost",size:"sm",className:"review-panel-add-comment-cancel-button",disabled:h,onClick:j,children:c("cancel")}),(0,u.jsx)(T.A,{type:"submit",variant:"primary",size:"sm",disabled:""===b||h,children:c("comment")})]})]})})}));var O=n(62533),S=n(9097),P=n(46220),D=n(81446),F=n(86806);const $=(0,o.memo)((e=>{let{change:t}=e;const n=(0,D.G1)(),r=t.metadata?.user_id,s=(0,o.useMemo)((()=>r?n?.get(r):void 0),[n,r]);return(0,u.jsx)(F.A,{user:s})}));$.displayName="ReviewPanelChangeUser";var H=n(95017),q=n(87962),z=n(88930),G=n(26180);const Q={overlayProps:{placement:"bottom"},tooltipProps:{className:"review-panel-tooltip"}},V=(0,o.memo)((function(e){let{id:t,label:n,type:r,handleClick:s}=e;return(0,u.jsx)(G.d,{children:(0,u.jsx)(z.A,{id:t,description:n,...Q,children:(0,u.jsx)("button",{type:"button",className:"btn",onClick:s,tabIndex:0,children:(0,u.jsx)(c.A,{type:r,className:"review-panel-entry-actions-icon",accessibilityLabel:n})})})})})),U=(0,o.memo)((function(){return(0,u.jsx)(c.A,{className:"review-panel-entry-icon review-panel-entry-change-icon review-panel-entry-icon-accept",type:"add_circle"})})),W=(0,o.memo)((function(){return(0,u.jsx)(c.A,{className:"review-panel-entry-icon review-panel-entry-change-icon review-panel-entry-icon-reject",type:"delete"})})),J=(0,o.memo)((function(){return(0,u.jsx)(c.A,{className:"review-panel-entry-icon review-panel-entry-change-icon review-panel-entry-icon-changed",type:"edit"})})),Y=(0,o.memo)((e=>{let{change:t,aggregate:n,top:r,docId:s,hoverRanges:a,editable:c=!0,hovered:d,handleEnter:m,handleLeave:p}=e;const{t:h}=(0,l.Bd)(),{acceptChanges:v,rejectChanges:g}=(0,O.OQ)(),w=(0,S.Tg)(),f=(0,D.G1)(),{showGenericMessageModal:x}=(0,E.T)(),_=(0,q.ur)(),[b,y]=(0,o.useState)(!1),j=(0,o.useCallback)((async()=>{y(!0);try{n?await v(t,n):await v(t)}catch(e){x(h("accept_change_error_title"),h("accept_change_error_description"))}finally{y(!1)}}),[v,n,t,x,h]),k=(0,o.useCallback)((async()=>{n?await g(t,n):await g(t)}),[n,t,g]),C=(0,o.useMemo)((()=>({accept_change:h("accept_change"),reject_change:h("reject_change"),aggregate_changed:h("aggregate_changed"),aggregate_to:h("aggregate_to"),tracked_change_added:h("tracked_change_added"),tracked_change_deleted:h("tracked_change_deleted")})),[h]),{handleMouseEnter:M,handleMouseLeave:N}=(0,o.useMemo)((()=>({handleMouseEnter:m&&(()=>m(t.id)),handleMouseLeave:p&&(()=>p())})),[t.id,m,p]);if(!f)return null;const A=t.metadata?.user_id===_.id,L=n&&/\S/.test(n.op.d);return(0,u.jsx)(I,{className:i()("review-panel-entry-change",{"review-panel-entry-insert":"i"in t.op,"review-panel-entry-delete":"d"in t.op,"review-panel-entry-hover":d}),top:r,op:t.op,position:t.op.p,docId:s,hoverRanges:a,disabled:b,handleEnter:M,handleLeave:N,entryIndicator:"edit",children:(0,u.jsxs)("div",{className:"review-panel-entry-content",onMouseEnter:M,onMouseLeave:N,children:[(0,u.jsxs)("div",{className:"review-panel-entry-header",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)($,{change:t}),t.metadata?.ts&&(0,u.jsx)("div",{className:"review-panel-entry-time",children:(0,u.jsx)(P.Y,{date:t.metadata.ts})})]}),c&&(0,u.jsxs)("div",{className:"review-panel-entry-actions",children:[w.write&&(0,u.jsx)(V,{id:"accept-change",label:C.accept_change,type:"check",handleClick:j}),(w.write||w.trackedWrite&&A)&&(0,u.jsx)(V,{id:"reject-change",label:C.reject_change,type:"close",handleClick:k})]})]}),(0,u.jsxs)("div",{className:"review-panel-change-body",children:["i"in t.op&&(0,u.jsxs)(u.Fragment,{children:[L?(0,u.jsx)(J,{}):(0,u.jsx)(U,{}),L?(0,u.jsxs)("span",{children:[C.aggregate_changed,":"," ",(0,u.jsx)("del",{className:"review-panel-content-highlight",children:(0,u.jsx)(H.M,{inline:!0,content:n.op.d,checkNewLines:!1})})," ",C.aggregate_to," ",(0,u.jsx)(H.M,{inline:!0,content:t.op.i,checkNewLines:!1})]}):(0,u.jsxs)("span",{children:[C.tracked_change_added,":Â ",(0,u.jsx)("ins",{className:"review-panel-content-highlight",children:(0,u.jsx)(H.M,{content:t.op.i,checkNewLines:!1})})]})]}),"d"in t.op&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(W,{}),(0,u.jsxs)("span",{children:[C.tracked_change_deleted,":Â ",(0,u.jsx)("del",{className:"review-panel-content-highlight",children:(0,u.jsx)(H.M,{content:t.op.d,checkNewLines:!1})})]})]})]})]})})}));Y.displayName="ReviewPanelChange";var K=n(12699);const X=(0,o.memo)((e=>{let{comment:t,top:n,hovered:r,handleEnter:s,handleLeave:a,docId:c,hoverRanges:d}=e;const m=(0,g.wP)(),{resolveThread:p,editMessage:h,deleteMessage:v,deleteO
1wnMessage:w,deleteThread:f,addMessage:x}=(0,g.v0)(),{showGenericMessageModal:_}=(0,E.T)(),{t:b}=(0,l.Bd)(),y=(0,S.Tg)(),[j,k]=(0,o.useState)(!1),C=(0,o.useCallback)((async()=>{k(!0);try{await p(t.op.t)}catch(e){L.$.error(e),_(b("resolve_comment_error_title"),b("resolve_comment_error_message"))}finally{k(!1)}}),[t.op.t,p,_,b]),M=(0,o.useCallback)((async(e,n)=>{k(!0);try{await h(t.op.t,e,n)}catch(e){L.$.error(e),_(b("edit_comment_error_title"),b("edit_comment_error_message"))}finally{k(!1)}}),[t.op.t,h,_,b]),N=(0,o.useCallback)((async e=>{k(!0);try{y.resolveAllComments?await v(t.op.t,e):y.resolveOwnComments&&await w(t.op.t,e)}catch(e){L.$.error(e),_(b("delete_comment_error_title"),b("delete_comment_error_message"))}finally{k(!1)}}),[t.op.t,v,w,_,b,y.resolveOwnComments,y.resolveAllComments]),A=(0,o.useCallback)((async e=>{k(!0);try{await f(e)}catch(e){L.$.error(e),_(b("delete_comment_error_title"),b("delete_comment_error_message"))}finally{k(!1)}}),[f,_,b]),T=(0,o.useCallback)((async e=>{k(!0);try{await x(t.op.t,e)}catch(e){throw L.$.error(e),_(b("add_comment_error_title"),b("add_comment_error_message")),e}finally{k(!1)}}),[x,t.op.t,_,b]),{handleMouseEnter:R,handleMouseLeave:B}=(0,o.useMemo)((()=>({handleMouseEnter:s&&(()=>s(t.id)),handleMouseLeave:a&&(()=>a(t.id))})),[t.id,s,a]),O=m?.[t.op.t];return!O||O.resolved||0===O.messages.length?null:(0,u.jsx)(I,{className:i()("review-panel-entry-comment",{"review-panel-entry-loaded":!!m?.[t.op.t],"review-panel-entry-hover":r}),docId:c,top:n,op:t.op,position:t.op.p,hoverRanges:d,disabled:j,handleEnter:R,handleLeave:B,entryIndicator:"comment",children:(0,u.jsx)(K.v,{comment:t,isResolved:!1,onLeave:B,onEnter:R,onResolve:C,onEdit:M,onDeleteMessage:N,onDeleteThread:A,onReply:T})})}));X.displayName="ReviewPanelComment";var Z=n(72314),ee=n(86366);const te=function(){const{t:e}=(0,l.Bd)();return(0,u.jsx)("div",{className:"review-panel-empty-state",children:(0,u.jsxs)("div",{className:"review-panel-empty-state-inner",children:[(0,u.jsx)("div",{className:"review-panel-empty-state-comment-icon",children:(0,u.jsx)(c.A,{type:"question_answer"})}),(0,u.jsx)("p",{children:(0,u.jsx)("strong",{children:e("no_comments_or_suggestions")})}),(0,u.jsx)("p",{children:e("no_one_has_commented_or_left_any_suggestions_yet")})]})})};var ne=n(14112),re=n(39389);const se=e=>{let{onClick:t,direction:n}=e;const{t:r}=(0,l.Bd)();return(0,u.jsx)("div",{className:i()("review-panel-more-comments-button-container",{downwards:"downward"===n,upwards:"upward"===n}),children:(0,u.jsxs)(T.A,{variant:"secondary",size:"sm",onClick:t,children:[(0,u.jsx)(c.A,{type:`arrow_${n}_alt`}),r("more_comments")]})})},oe=(0,o.memo)(se);var ae=n(40433);const ie=(e,t,n)=>{const r=(0,ae.useCodeMirrorViewContext)(),{showPanel:s,mini:a}=(0,M.A)(),i=s&&!a,[c,l]=(0,o.useState)(null),[d,u]=(0,o.useState)(null),m=(0,o.useMemo)((()=>j().debounce((()=>r.requestMeasure({key:"review-panel-more-comments",read(r){const s=r.scrollDOM;if(!s||!i)return{positionAbove:null,positionBelow:null};const o=s.scrollTop,a=o+s.clientHeight;for(const e of s.querySelectorAll(".review-panel-entry")){const t=e?.offsetTop??0;if(t+(e?.offsetHeight??0)>o&&t<a)return{positionAbove:null,positionBelow:null}}const c=r.lineBlockAtHeight(o).from,l=r.lineBlockAtHeight(a).to;let d=null,u=null;const m=e=>{(null===c||e<c)&&(d=Math.max(d??0,e)),(null===l||e>l)&&(u=Math.min(u??Number.MAX_VALUE,e))};for(const n of[...e,...t])m(n.op.p);const p=n.iter();for(;p.value;)m(p.from),p.next();return{positionAbove:d,positionBelow:u}},write(e){let{positionAbove:t,positionBelow:n}=e;l(t),u(n)}})),200)),[e,t,n,r,i]);(0,o.useEffect)((()=>{const e=document.getElementsByClassName("cm-scroller")[0];if(e)return e.addEventListener("scroll",m),()=>{e.removeEventListener("scroll",m)}}),[m]);const p=(0,o.useCallback)((e=>{r.dispatch({effects:A.Lz.scrollIntoView(e,{y:"center"}),selection:v.OF.cursor(e)})}),[r]),h=(0,o.useCallback)((()=>{null!==c&&p(c)}),[c,p]),g=(0,o.useCallback)((()=>{null!==d&&p(d)}),[d,p]);return{onEntriesPositioned:m,onMoreCommentsAboveClick:null!==c?h:null,onMoreCommentsBelowClick:null!==d?g:null}};var ce=n(47241);const le=()=>{const e=(0,s.u9)(),t=(0,O.Hx)(),n=(0,g.wP)(),r=(0,s.Q_)(),[a,i]=(0,o.useState)(null),c=(0,ce.Gq)(),l=(0,o.useRef)(0),d=(0,o.useCallback)((e=>{clearTimeout(l.current),i(e)}),[]),m=(0,o.useCallback)((()=>{clearTimeout(l.current),l.current=window.setTimeout((()=>{i(null)}),100)}),[]),[p,h]=(0,o.useState)(),v=(0,o.useRef)(null),f=(0,o.useRef)(new Map),x=(0,o.useCallback)((()=>
1{if(t){const e={aggregates:new Map,changes:[],comments:[]};let r=null;for(const n of t.changes)r&&(0,Z.YL)(r)&&(0,Z.sm)(n)&&(0,ee.M)(n,r)?e.aggregates.set(r.id,n):e.changes.push(n),r=n;if(n)for(const r of t.comments)r.resolved||!n[r.op.t]||n[r.op.t]?.resolved||e.comments.push(r);h(e)}}),[n,t]);(0,o.useEffect)((()=>{x()}),[x]),(0,ne.A)("editor:viewport-changed",x);const[_,b]=(0,o.useState)(new Map),j=(0,o.useRef)(new Map),C=r.field(w.BH,!1)?.addCommentRanges,M=(0,o.useMemo)((()=>(0,y.debounce)((()=>{b(new Map(j.current)),window.setTimeout((()=>{v.current?.dispatchEvent(new Event("review-panel:position"))}))}),50)),[]),N=(0,o.useCallback)((()=>{p&&e.requestMeasure({key:"review-panel-position",read(e){const t=e.contentDOM.getBoundingClientRect(),n=e.state.doc.length,r=r=>{const s=Math.min(r,n),o=e.coordsAtPos(s);return o?Math.round(o.top-t.top):void 0};for(const e of p.changes){const t=r(e.op.p);t&&j.current.set(e.id,t)}for(const e of p.comments){const t=r(e.op.p);t&&j.current.set(e.id,t)}if(!C)return;const s=C.iter();for(;s.value;){const{from:e}=s,t=r(e);t&&j.current.set(`new-comment-${s.value.spec.id}`,t),s.next()}},write(){M()}})}),[e,p,C,M]);(0,o.useEffect)(N,[N]),(0,ne.A)("editor:geometry-change",N);const I=(0,o.useMemo)((()=>!1===(0,re.c)(t,n)),[t,n]),E=(0,o.useMemo)((()=>{if(!C)return[];const e=C.iter(),t=[];for(;e.value;){const n=`new-comment-${e.value.spec.id}`;if(!_.has(n)){e.next();continue}const{from:r,to:s,value:o}=e;t.push({id:n,from:r,to:s,threadId:o.spec.id,top:_.get(n)}),e.next()}return t}),[C,_]),{onEntriesPositioned:L,onMoreCommentsAboveClick:T,onMoreCommentsBelowClick:R}=ie(p?.changes??[],p?.comments??[],C??A.NZ.none),S=(0,o.useCallback)((()=>{const e=t?.docId;if(v.current&&e){const t=k(v.current,f.current.get(e),e,c);L(),t&&f.current.set(t.docId,t.activeItemIndex)}}),[t?.docId,L,c]);(0,o.useEffect)((()=>{const e=window.setTimeout((()=>{S()}),50);return()=>{window.clearTimeout(e)}}),[r,S]);const P=(0,o.useCallback)((e=>{v.current=e,v.current&&v.current.addEventListener("review-panel:position",S)}),[S]);return(0,o.useEffect)((()=>()=>{v.current&&v.current.removeEventListener("review-panel:position",S)}),[S]),p?(0,u.jsxs)("div",{role:"tabpanel",id:"review-panel-current-file","aria-labelledby":"review-panel-tab-button-current-file",children:[I&&(0,u.jsx)(te,{}),T&&(0,u.jsx)(oe,{onClick:T,direction:"upward"}),(0,u.jsxs)("div",{ref:P,children:[E.map((e=>{const{id:n,from:r,to:s,threadId:o,top:a}=e;return(0,u.jsx)(B,{docId:t.docId,from:r,to:s,threadId:o,top:a},n)})),p.changes.map((e=>_.has(e.id)&&(0,u.jsx)(Y,{docId:t.docId,change:e,top:_.get(e.id),aggregate:p.aggregates.get(e.id),hovered:a===e.id,handleEnter:d,handleLeave:m},e.id))),p.comments.map((e=>_.has(e.id)&&(0,u.jsx)(X,{docId:t.docId,comment:e,top:_.get(e.id),hovered:a===e.id,handleEnter:d,handleLeave:m},e.id)))]}),R&&(0,u.jsx)(oe,{onClick:R,direction:"downward"})]}):null},de=(0,o.memo)(le);var ue=n(66326),me=(n(12266),n(64727),n(82738),n(44215)),pe=n(91720);const he=e=>{try{return JSON.stringify(e)}catch(e){return L.$.error("double stringify exception",e),""}},ve=e=>{try{return JSON.parse(e)}catch(e){return L.$.error("double parse exception",e),null}};var ge=n(98428);const we=e=>{let{doc:t,ranges:n}=e;const{collapsed:r,toggleCollapsed:s}=function(e){const{projectId:t}=(0,me.Om)(),[n,r]=(0,pe.A)(`docs_collapsed_state:${t}`,{},{converter:{fromPersisted:ve,toPersisted:he}}),s=(0,o.useCallback)((()=>{r((t=>({...t,[e]:!t[e]})))}),[e,r]);return{collapsed:n[e],toggleCollapsed:s}}(t.doc.id),a=(0,g.wP)(),{aggregates:i,changes:c}=(0,o.useMemo)((()=>{const e=[],t=new Map;let r=null;for(const s of n.changes)r&&(0,Z.YL)(r)&&(0,Z.sm)(s)&&(0,ee.M)(s,r)?t.set(r.id,s):e.push(s),r=s;return{aggregates:t,changes:e}}),[n]),l=(0,o.useMemo)((()=>{const e=n.comments.filter((e=>{if(e.resolved)return!1;const t=a?.[e.op.t];return t&&t.messages.length>0&&!t.resolved}));return[...c,...e].sort(((e,t)=>e.op.p-t.op.p))}),[c,n.comments,a]);return 0===l.length?null:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{children:[(0,u.jsx)(ge.m,{name:t.doc.name,count:l.length,collapsed:r,toggleCollapsed:s}),!r&&(0,u.jsx)("div",{className:"review-panel-overview-file-entries",children:l.map((e=>(0,Z.H8)(e.op)?(0,u.jsx)(X,{comment:e,docId:t.doc.id,hoverRanges:!1},e.id):(0,u.jsx)(Y,{change:e,aggregate:i.get(e.id),editable:!1,docId:t.doc.id,hoverRanges:!1},e.id)))})]}),(0,u.jsx)("div",{className:"review-panel-overfile-divider"})]})};var fe=n(92431),xe=n(12461);const _e=()=>{const{t:e}=(0,l.Bd)(),{docs:t}=(0,ue.Qq)(),n=(0,O.Hx)(),{projectRanges:r,error:s}=(0,fe.A)(),a=(0,o.useMemo)((()=>
1{if(t&&n&&r){const e=new Map,s=(0,xe.A)("ol-otMigrationStage");for(const o of t){const t=o.doc.id===n.docId?n:r.get(1===s?o.path:o.doc.id);t&&e.set(o.doc.id,t)}return e}}),[n,t,r]),i=(0,o.useMemo)((()=>{if(!a)return!1;for(const e of a.values())if(e.changes.length>0||e.comments.length>0)return!1;return!0}),[a]);return(0,u.jsxs)("div",{className:"review-panel-overview",id:"review-panel-overview","aria-labelledby":"review-panel-tab-button-overview",children:[s&&(0,u.jsx)("div",{children:e("something_went_wrong")}),i&&(0,u.jsx)(te,{}),t&&a&&(0,u.jsx)("div",{children:t.map((e=>{const t=a.get(e.doc.id);return t&&(0,u.jsx)(we,{doc:e,ranges:t})}))})]})},be=e=>{let{mini:t=!1}=e;const n=(0,d.oQ)(),r=(0,ce.Gq)(),a=(0,o.useMemo)((()=>t?"cur_file":n),[n,t]),c=(()=>{const e=(0,s.u9)(),[t,n]=(0,o.useState)({"--review-panel-header-height":"36px"}),r=(0,o.useCallback)((e=>{const{top:t,bottom:r}=e.getBoundingClientRect();n((e=>({...e,"--review-panel-top":`${t}px`,"--review-panel-bottom":`${r}px`})))}),[]),a=(0,o.useCallback)((e=>{const{height:t}=e.getBoundingClientRect();n((e=>({...e,"--review-panel-height":`${t}px`})))}),[]);return(0,o.useEffect)((()=>{if("ResizeObserver"in window){const t=new window.ResizeObserver((e=>r(e[0]?.target)));t.observe(e.scrollDOM);const n=new window.ResizeObserver((e=>a(e[0]?.target)));return n.observe(e.contentDOM),()=>{t.disconnect(),n.disconnect()}}}),[e,r,a]),t})(),l=i()("review-panel-container",{"review-panel-mini":t,"review-panel-subview-overview":"overview"===a});return(0,u.jsx)("div",{className:l,style:c,"data-testid":"review-panel",children:(0,u.jsxs)("div",{id:"review-panel-inner",className:"review-panel-inner",children:[!r&&!t&&(0,u.jsx)(h.A,{}),"cur_file"===a&&(0,u.jsx)(de,{}),"overview"===a&&(0,u.jsx)(_e,{}),(0,u.jsx)("div",{className:"review-panel-footer",id:"review-panel-tabs",role:"tablist",children:(0,u.jsx)(p,{})})]})})},ye=(0,o.memo)(be);var je=n(25148),ke=n(68938),Ce=n(69471),Me=n(29515),Ne=n(49604);const Ae=n.p+"images/teaser-track-changes-02be42eaf3016b9301cc.mp4",Ie=n.p+"images/teaser-track-changes-a8525c218d21fb73affc.gif";var Ee=n(91678),Le=n(485),Te=n(79885),Re=n(80963);function Be(e){let{show:t,setShow:n}=e;const{t:r}=(0,l.Bd)(),{project:s}=(0,me.Om)(),o=(0,q.ur)();return(0,u.jsxs)(Le.Li,{show:t,onHide:()=>n(!1),children:[(0,u.jsx)(Le.IK,{children:(0,u.jsx)(Le.rA,{children:r("upgrade_to_review")})}),(0,u.jsxs)(Le.$8,{className:"upgrade-track-changes-modal",children:[(0,u.jsx)("div",{className:"teaser-video-container",children:(0,u.jsxs)("video",{className:"teaser-video",autoPlay:!0,loop:!0,children:[(0,u.jsx)("source",{src:Ae,type:"video/mp4"}),(0,u.jsx)("img",{src:Ie,alt:r("demonstrating_track_changes_feature")})]})}),(0,u.jsx)("h4",{className:"teaser-title",children:r("get_real_time_track_changes")}),(0,u.jsx)(Te.A,{children:(0,u.jsx)(Re.A,{lg:{span:10,offset:1},children:(0,u.jsx)("ul",{className:"list-unstyled",children:[r("see_suggestions_from_collaborators"),r("accept_or_reject_individual_edits"),r("access_all_premium_features")].map((e=>(0,u.jsxs)("li",{children:[(0,u.jsx)(c.A,{type:"check",className:"check-icon"}),(0,u.jsx)("span",{children:e})]},e)))})})}),Boolean(s?.owner)&&(0,u.jsx)("div",{className:"text-center",children:s?.owner._id===o.id?o.allowedFreeTrial?(0,u.jsx)(T.A,{variant:"premium",onClick:()=>(0,Ee.x)("track-changes"),children:r("try_it_for_free")}):(0,u.jsx)(T.A,{variant:"premium",onClick:()=>(0,Ee.k)("project-sharing"),children:r("upgrade")}):(0,u.jsx)("p",{children:(0,u.jsx)("strong",{children:r("please_ask_the_project_owner_to_upgrade_to_track_changes")})})})]}),(0,u.jsx)(Le.E9,{children:(0,u.jsx)(T.A,{variant:"secondary",onClick:()=>n(!1),children:r("close")})})]})}const Oe=(0,o.memo)(Be),Se=()=>{const e=(0,Ce._I)(),t=(0,q.ur)(),n=e?.onForEveryone||t?.id&&e?.onForMembers[t.id]||!t?.id&&e?.onForGuests,{permissionsLevel:r}=(0,Ne.yn)();return"readOnly"===r?"view":"review"===r||n?"review":"edit"};function Pe(){const{t:e}=(0,l.Bd)(),t=(0,q.ur)(),{saveTrackChangesForCurrentUser:n,saveTrackChanges:r}=(0,Ce.F7)(),a=Se(),{permissionsLevel:i}=(0,Ne.yn)(),{write:c,trackedWrite:d}=(0,S.Tg)(),{features:m}=(0,me.Om)(),[p,h]=(0,o.useState)(!1),v="readOnly"===i,g=(0,s.u9)();return(0,u.jsxs)("div",{className:"review-mode-switcher-container",children:[(0,u.jsxs)(je.ms,{className:"review-mode-switcher",align:"end",children:[(0,u.jsx)(je.C,{as:De,id:"review-mode-switcher"}),(0,u.jsxs)(je.rI,{flip:!1,children:[(0,u.jsx)(ke.A,{disabled:!c,onClick:()=>{"edit"!==a?((0,Me._)("editing-mode-change",{role:i,previousMode:a,newMode:"edit"}),t?.id?n(!1):r({on_for_guests:!1}
1),g.focus()):g.focus()},description:e("edit_content_directly"),leadingIcon:"edit",active:c&&"edit"===a,children:e("editing")}),(0,u.jsx)(ke.A,{disabled:"readOnly"===i,onClick:()=>{"review"!==a?m.trackChanges?((0,Me._)("editing-mode-change",{role:i,previousMode:a,newMode:"review"}),t?.id?n(!0):r({on_for_guests:!0}),g.focus()):h(!0):g.focus()},description:e("review"!==i||d?"edits_become_suggestions":"comment_only"),leadingIcon:"rate_review",active:d&&"review"===a,children:e("reviewing")}),v&&(0,u.jsx)(ke.A,{description:e("can_view_content"),leadingIcon:"visibility",active:"view"===a,children:e("viewing")})]})]}),(0,u.jsx)(Oe,{show:p,setShow:h})]})}const De=(0,o.forwardRef)(((e,t)=>{let{onClick:n,"aria-expanded":r}=e;const{t:s}=(0,l.Bd)(),o=Se();return"edit"===o?(0,u.jsx)(Fe,{ref:t,onClick:n,className:"editing",iconType:"edit",label:s("editing"),ariaExpanded:r}):"review"===o?(0,u.jsx)(Fe,{ref:t,onClick:n,className:"reviewing",iconType:"rate_review",label:s("reviewing"),ariaExpanded:r}):(0,u.jsx)(Fe,{ref:t,onClick:n,className:"viewing",iconType:"visibility",label:s("viewing"),ariaExpanded:r})})),Fe=(0,o.forwardRef)(((e,t)=>{let{onClick:n,className:r,iconType:s,label:o,ariaExpanded:a}=e;const[l,d]=(0,pe.A)("modeSwitcherFirstTimeUsed",!0);return(0,u.jsxs)("button",{className:i()("review-mode-switcher-toggle-button",r,{"review-mode-switcher-toggle-button-expanded":l}),ref:t,onClick:e=>{d(!1),n(e)},"aria-expanded":a,children:[(0,u.jsx)(c.A,{className:"material-symbols-outlined",type:s}),(0,u.jsx)("div",{className:"review-mode-switcher-toggle-label","aria-label":o,children:o}),(0,u.jsx)(c.A,{type:"keyboard_arrow_down"})]})}));De.displayName="ModeSwitcherToggleButton",Fe.displayName="ModeSwitcherToggleButtonContent";const $e=(0,o.memo)(Pe);function He(){const e=(0,s.u9)(),{showPanel:t,mini:n}=(0,M.A)();return e?r.createPortal((0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)($e,{}),t&&(0,u.jsx)(ye,{mini:n})]}),e.scrollDOM):null}const qe=(0,o.memo)(He)},98428:(e,t,n)=>{n.d(t,{m:()=>o});var r=n(22160),s=n(31085);const o=e=>{let{name:t,count:n,collapsed:o,toggleCollapsed:a}=e;return(0,s.jsxs)("button",{type:"button",className:"collapsible-file-header",onClick:a,translate:"no",children:[(0,s.jsx)(r.A,{type:o?"keyboard_arrow_right":"keyboard_arrow_down"}),t,(0,s.jsx)("div",{className:"collapsible-file-header-count",children:n})]})}}}]);
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.