1import{E as Q,u as v,j as e,a as Y,H as J,Q as X,n as F,B as l,J as H,a2 as Z,F as ee,aD as se}from"./index-Cue0MFt4.js";import{r as o}from"./vendor-charts-DxavT5gT.js";import{u as te,a as I,D as ie,c as ae,S as re,v as ne,d as de,C as le,s as ce,K as oe,P as he,b as B}from"./sortable.esm-BwK8Ct7x.js";import{A as me}from"./AppHeader-D3crkVLP.js";import{M as xe}from"./MobileBottomNav-D9zHtluo.js";import{u as fe}from"./useRequireSubscription-Dn3zrMY7.js";import{C as U,d as $}from"./card-DYYQPyc7.js";import{S as ue}from"./switch-DNeGTjJE.js";import{A as b,b as y,a as N}from"./alert-BM-v2Qvj.js";import{S as pe,a as ve,b as je,c as ge,d as be}from"./select-D79MHEnl.js";import{A as ye,b as Ne,c as we,d as Ce,e as Se,f as Ae,g as De,h as Ee}from"./alert-dialog-BD0KhccE.js";import{l as Re,a as ke,b as L,s as Te,c as Le,d as Oe,f as _e}from"./exhibitSync-DWnzGml2.js";import{possibleDuplicateRecords as Me,FLAG_LABEL as ze,qualityFlags as Ke}from"./packetReview-VquRxIz4.js";import{L as Ie}from"./list-ordered-DixycI9q.js";import{S as Be}from"./save-BHyvriPc.js";import{R as Fe}from"./rotate-ccw-BREvknRl.js";import{T as w}from"./triangle-alert-D8v6CJq1.js";import{A as He}from"./arrow-down-DYbEal2I.js";import{f as Ue}from"./format-xUIS418J.js";import"./vendor-docs-B92Njgx_.js";import"./index-CYoL9OOK.js";import"./circle-CeJQ5E3_.js";import"./upload-CMCAfVV7.js";import"./shield-CEnIpotW.js";import"./index-CU2XJOxq.js";import"./timelineEvidence-B7KR6IM6.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const $e=Q("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),C=r=>{try{return Ue(new Date(r),"MMM d, yyyy · h:mm a")}catch{return r}};function We({rec:r,number:t,citedIn:S,flags:d,onToggle:h,onUp:j,onDown:m,first:c,last:x}){const{attributes:f,listeners:g,setNodeRef:D,transform:E,transition:R,isDragging:u}=de({id:r.key});return e.jsx("li",{ref:D,style:{transform:le.Transform.toString(E),transition:R},className:u?"relative z-10 opacity-80":void 0,children:e.jsx(U,{children:e.jsxs($,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[e.jsx("button",{type:"button",...f,...g,"aria-label":`Drag to reorder exhibit ${t}`,className:"h-9 w-9 -ml-1 flex items-center justify-center rounded-md text-muted-foreground hover:bg-muted cursor-grab touch-none",children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-semibold",children:["Exhibit ",t]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[C(r.date)," · ",r.sourceLabel,r.pattern?` · ${r.pattern}`:""]}),r.fileName&&e.jsxs("p",{className:"text-xs flex items-center gap-1 mt-0.5",children:[e.jsx(ee,{className:"h-3 w-3"}),r.fileName]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(l,{size:"icon",variant:"ghost",onClick:j,disabled:c,"aria-label":"Move up",children:e.jsx(se,{className:"h-4 w-4"})}),e.jsx(l,{size:"icon",variant:"ghost",onClick:m,disabled:x,"aria-label":"Move down",children:e.jsx(He,{className:"h-4 w-4"})})]})]}),d.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.map(n=>e.jsxs(F,{variant:"outline",className:"border-destructive/50 text-destructive",children:[e.jsx(w,{className:"h-3 w-3 mr-1"}),ze[n]]},n)),d.includes("empty")&&e.jsx(H,{to:"/evidence",className:"text-xs underline text-primary",children:"Add a description"})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap break-words",children:r.content||"(No description yet)"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:S.length?`Cited in affidavit: ${S.join(", ")}`:"Not cited in the affidavit"}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ue,{checked:!0,onCheckedChange:h,"aria-label":`Include exhibit ${t} in packet`}),"Include in packet"]})]})]})})})}function vs(){const{isReady:r}
6=fe(),[t,S]=o.useState(null),[d,h]=o.useState([]),[j,m]=o.useState(!1),[c,x]=o.useState(!1),[f,g]=o.useState(null),[D,E]=o.useState(!1),R=te(I(he,{activationConstraint:{distance:6}}),I(oe,{coordinateGetter:ce})),u=o.useCallback(async()=>{try{const s=await Re();S(s),h(s.resolved.included),m(!1)}catch(s){console.error("[exhibit-review]",s),v.error("We couldn't load your exhibits",{description:s.message})}},[]);o.useEffect(()=>{r&&u()},[r,u]);const n=t?.records,k=o.useMemo(()=>{if(!t)return[];const s=new Set(t.config.excluded);return ke([...t.records.values()],t.resolved.cited).filter(i=>!s.has(i))},[t]),T=d.some((s,i)=>k[i]!==s),W=o.useMemo(()=>t?Me([...t.records.values()]):new Set,[t]),G=s=>{const i=t?.records.get(s);return i?Ke(i,{hasDate:!!i.date,duplicate:W.has(s)}):[]},O=t?t.resolved.excluded.filter(s=>t.resolved.cited.includes(s)):[],p=async(s,i)=>{if(t){x(!0);try{await Te(t.uid,{...t.config,...s}),i&&v.success(i),await u()}catch(a){console.error("[exhibit-review] save",a),v.error("We couldn't save that change",{description:a.message})}finally{x(!1)}}},V=()=>p({exhibit_order:d,is_custom:T,affidavit_signature:L(t.resolved.cited)},T?"Custom exhibit order saved":"Exhibit order saved (matches the affidavit)"),_=()=>p({exhibit_order:[],is_custom:!1,affidavit_signature:L(t.resolved.cited)},"Exhibits ordered by affidavit references"),q=async s=>{if(!t)return;const i=t.config.excluded;await p({excluded:[...new Set([...i,s])],exhibit_order:j?d:t.config.exhibit_order}),v("Removed from packet",{description:"The original record is still saved in Clarity Case.",action:{label:"Undo",onClick:()=>p({excluded:i})}})},M=s=>p({excluded:t.config.excluded.filter(i=>i!==s)},"Exhibit restored to the packet"),z=async(s,i)=>{if(t){x(!0);try{await Le(t,t.sections.map(a=>({...a,content:s(a.content)}))),v.success(i),await u()}catch(a){v.error("We couldn't update the affidavit",{description:a.message})}finally{x(!1)}}},K=(s,i)=>{h(a=>B(a,s,s+i)),m(!0)},P=s=>{!s.over||s.active.id===s.over.id||(h(i=>B(i,i.indexOf(String(s.active.id)),i.indexOf(String(s.over.id)))),m(!0))};return!r||!t||!n?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(Y,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"min-h-screen bg-background pb-24 md:pb-8",children:[e.jsx(J,{children:e.jsx("title",{children:"Exhibit Review | Clarity Case"})}),e.jsx(me,{}),e.jsx(X,{}),e.jsxs("main",{className:"container mx-auto px-4 py-6 max-w-4xl space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Exhibit review & organization"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose what goes in your packet and in what order. Exhibit numbers here are used in the affidavit, timeline, exhibit index and attached pages. Excluding an item never deletes it from Clarity Case."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(F,{variant:t.config.is_custom?"default":"secondary",children:t.config.is_custom?"Custom exhibit order":"Affidavit order"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[d.length," included · ",t.resolved.excluded.length," excluded"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(l,{variant:"outline",onClick:()=>{h(k),m(!0)},disabled:c,children:[e.jsx(Ie,{className:"h-4 w-4 mr-2"}),"Order exhibits by affidavit references"]}),e.jsxs(l,{onClick:V,disabled:c||!j,children:[e.jsx(Be,{className:"h-4 w-4 mr-2"}),"Save exhibit order"]}),e.jsxs(l,{variant:"outline",onClick:_,disabled:c||!t.config.is_custom&&!j,children:[e.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Reset to affidavit order"]})]}),!t.sections.length&&e.jsxs(b,{children:[e.jsx(y,{children:"No affidavit yet"}),e.jsxs(N,{children:["Exhibits are numbered by date until you ",e.jsx(H,{to:"/affidavit",className:"underline",children:"generate your affidavit"}),". After that, they follow the order evidence is first cited."]})]}),T&&t.sections.length>0&&e.jsxs(b,{children:[e.jsx(w,{className:"h-4 w-4"}),e.jsx(y,{children:"Order differs from the affidavit"}),e.jsx(N,{children:"This order doesn't match the order evidence is first cited in your affidavit. That's allowed â the affidavit will be renumbered to match when you save."})]}),t.resolved.affidavitChanged&&e.jsxs(b,{className:"border-destructive/40",children:[e.jsx(w,{className:"h-4 w-4"}),e.jsx(y,{children:"Your affidavit has changed"}),e.jsxs(N,{className:"space-y-3",children:[e.jsx("p",{children:"The affidavit now cites evidence differently than when you saved your custom order. What would you like to do?"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{size:"sm",variant:"outline",disabled:c,onClick:()=>p({affidavit_signature:L(t.resolved.cited)},"Keeping your custom order"),children:"Keep my custom order"}),e.jsx(l,{size:"sm",disabled:c,onClick:_,children:"Reorder by the updated affidavit"}),e.jsx(l,{size:"sm",variant:"ghost",onClick:()=>E(s=>!s),children:"Review the changes first"})]}),D&&e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium mb-1",children:"Your saved order"}),e.jsx("ol",{className:"list-decimal pl-4 space-y-0.5",children:d.slice(0,15).map(s=>e.jsxs("li",{children:[n.get(s)?.sourceLabel," · ",C(n.get(s)?.date||"")]},s))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium mb-1",children:"Order in updated affidavit"}),e.jsx("ol",{className:"list-decimal pl-4 space-y-0.5",children:k.slice(0,15).map(s=>e.jsxs("li",{children:[n.get(s)?.sourceLabel," · ",C(n.get(s)?.date||"")]},s))})]})]})]})]}),O.length>0&&e.jsxs(b,{className:"border-destructive/40",children:[e.jsx(w,{className:"h-4 w-4"}),e.jsx(y,{children:"Affidavit cites excluded evidence"}),e.jsx(N,{className:"space-y-3",children:O.map(s=>{const i=t.resolved.numberOf.get(s);return e.jsxs("div",{className:"space-y-2 rounded-md border p-2",children:[e.jsxs("p",{children:["Exhibit ",i," (",n.get(s)?.sourceLabel,", ",C(n.get(s)?.date||""),") is cited in: ",(t.citedIn.get(s)||[]).join(", ")||"the affidavit"]}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx(l,{size:"sm",variant:"outline",disabled:c,onClick:()=>z(a=>Oe(a,t.map,s),"Reference removed from the affidavit"),children:"Remove the reference"}),e.jsxs(pe,{onValueChange:a=>z(A=>_e(A,t.map,s,Number(a)),"Reference replaced"),children:[e.jsx(ve,{className:"h-9 w-[220px]",children:e.jsx(je,{placeholder:"Replace with another exhibit"})}),e.jsx(ge,{children:t.resolved.included.map(a=>{const A=t.resolved.numberOf.get(a);return e.jsxs(be,{value:String(A),children:["Exhibit ",A," · ",n.get(a)?.sourceLabel]},a)})})]}),e.jsx(l,{size:"sm",disabled:c,onClick:()=>M(s),children:"Restore the exhibit"})]})]},s)})})]}),t.unmatched.length>0&&e.jsxs(b,{children:[e.jsx(w,{className:"h-4 w-4"}),e.jsx(y,{children:"Citations that don't match any evidence"}),e.jsxs(N,{children:["The affidavit mentions exhibit",t.unmatched.length===1?"":"s"," ",t.unmatched.join(", "),", which ",t.unmatched.length===1?"doesn't":"don't"," match a record. This usually happens with affidavits drafted before exhibit linking â regenerate the affidavit or edit those references."]})]}),e.jsxs("section",{"aria-labelledby":"included-h",className:"space-y-3",children:[e.jsx("h2",{id:"included-h",className:"text-lg font-semibold",children:"Included exhibits"}),e.jsx(ie,{sensors:R,collisionDetection:ae,onDragEnd:P,children:e.jsx(re,{items:d,strategy:ne,children:e.jsx("ol",{className:"space-y-3",children:d.map((s,i)=>n.get(s)&&e.jsx(We,{rec:n.get(s),number:i+1,citedIn:t.citedIn.get(s)||[],flags:G(s),onToggle:()=>g(s),onUp:()=>K(i,-1),onDown:()=>K(i,1),first:i===0,last:i===d.length-1},s))})})})]}),e.jsxs("section",{"aria-labelledby":"excluded-h",className:"space-y-3",children:[e.jsx("h2",{id:"excluded-h",className:"text-lg font-semibold",children:"Excluded items"}),t.resolved.excluded.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing excluded."}):e.jsx("ul",{className:"space-y-2",children:t.resolved.excluded.map(s=>{const i=n.get(s);return e.jsx("li",{children:e.jsx(U,{children:e.jsxs($,{className:"p-3 flex flex-wrap items-start gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[C(i.date)," · ",i.sourceLabel,i.fileName?` · ${i.fileName}`:""]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap break-words line-clamp-3",children:i.content}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Left out of the packet, exhibit index, timeline and attached pages. Still saved in Clarity Case."})]}),e.jsxs(l,{size:"sm",variant:"outline",onClick:()=>
6M(s),disabled:c,children:[e.jsx($e,{className:"h-4 w-4 mr-1"}),"Restore"]})]})})},s)})})]})]}),e.jsx(ye,{open:!!f,onOpenChange:s=>!s&&g(null),children:e.jsxs(Ne,{children:[e.jsxs(we,{children:[e.jsx(Ce,{children:"Remove this item from the packet?"}),e.jsxs(Se,{children:["It will be left out of the court packet, exhibit index, timeline and attached exhibit pages. The original record stays saved in Clarity Case, and you can restore it anytime.",f&&t.resolved.cited.includes(f)&&" This item is cited in your affidavit â you'll be asked how to fix that reference."]})]}),e.jsxs(Ae,{children:[e.jsx(De,{children:"Keep it"}),e.jsx(Ee,{onClick:()=>{const s=f;g(null),q(s)},children:"Remove from packet"})]})]})}),e.jsx(xe,{})]})}export{vs as default};
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.