1import{r as i,az as V,j as e,aA as G,aB as Q,A as X,R as J,aC as Z,aD as ee,aE as te,aF as D}from"./index-D5F7Kdo3.js";import{c as se}from"./RmSkeleton-MTCYGxAR.js";import{d as F}from"./rmMeetingRequestErrors-DQ2NtlKg.js";import"./vendor-zip-export-DBlf2rQS.js";import"./vendor-pdf-export-KxAXUJY8.js";const T=50;function v(s){return s.trim().toLowerCase()}function O(s,o){const r=s.trim().split(/\s+/).filter(Boolean);return r.length>=2?(r[0][0]+r[r.length-1][0]).toUpperCase():r.length===1?r[0].slice(0,2).toUpperCase():o.slice(0,2).toUpperCase()||"?"}function ie(s,o){const r=new Set(o.map(v)),d=new Set,h=[],y=[];for(const u of s){const a=(u.email??"").trim();if(!a)continue;const m=v(a);if(d.has(m))continue;d.add(m);const R=(u.name??"").trim()||a,g={key:m,email:a,name:R,initials:O(R,a),inDirectory:!0};r.has(m)?h.push(g):y.push(g)}for(const u of o){const a=u.trim(),m=v(a);!a||d.has(m)||(d.add(m),h.push({key:m,email:a,name:a,initials:O("",a),inDirectory:!1}))}const p=(u,a)=>u.name.localeCompare(a.name);return h.sort(p),y.sort(p),[...h,...y]}function ne({value:s,savedValue:o,onChange:r,disabled:d=!1}){const[h,y]=i.useState([]),[p,u]=i.useState("loading"),[a,m]=i.useState(0),[R,g]=i.useState("");i.useEffect(()=>{let n=!0;return u("loading"),V().then(q=>{n&&(y(q),u("ready"))}).catch(()=>{n&&u("error")}),()=>{n=!1}},[a]);const M=i.useMemo(()=>ie(h,o),[h,o]),f=i.useMemo(()=>new Set(s.map(v)),[s]),_=s.length>0?v(s[0]):null,b=f.size>=T,l=R.trim().toLowerCase(),x=l?M.filter(n=>n.name.toLowerCase().includes(l)||n.email.toLowerCase().includes(l)):M,L=(n,q)=>{const j=s.filter(C=>v(C)!==n.key);r(q?[...j,n.key]:j)},k=f.size===0?"No one is notified yet.":`${f.size} ${f.size===1?"person":"people"} will be notified.${b?` Limit of ${T} reached.`:""}`;return e.jsxs("div",{className:"RmMeetingRequestRecipientPicker",children:[e.jsx("p",{className:"RmMeetingRequestRecipientPicker_summary",children:k}),p==="loading"?e.jsx("p",{className:"RmNotice",role:"status",children:"Loading staff directoryâ¦"}):p==="error"?e.jsxs("div",{className:"RmNotice RmNotice--error",role:"alert",children:[e.jsx("span",{children:"Couldn't load the staff directory."}),e.jsx("button",{type:"button",className:"RmButton RmButton--secondary",onClick:()=>m(n=>n+1),children:"Retry"})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"search",className:"RmMeetingRequestRecipientPicker_filter","aria-label":"Filter staff",placeholder:"Filter staffâ¦",value:R,onChange:n=>g(n.target.value)}),x.length===0?e.jsx("p",{className:"RmNotice",children:"No staff match your search."}):e.jsx("ul",{className:"RmMeetingRequestRecipientPicker_list",children:x.map(n=>{const q=f.has(n.key);return e.jsxs("li",{className:"RmMeetingRequestRecipientPicker_row",children:[e.jsx("span",{className:"RmMeetingRequestRecipientPicker_avatar","aria-hidden":"true",children:n.initials}),e.jsxs("span",{className:"RmMeetingRequestRecipientPicker_identity",children:[e.jsx("span",{className:"RmMeetingRequestRecipientPicker_name",children:n.name}),e.jsx("span",{className:"RmMeetingRequestRecipientPicker_email",children:n.inDirectory?n.email:"Not in the staff directory"})]}),q&&n.key===_&&e.jsx("span",{className:"RmMeetingRequestRecipientPicker_badge",children:"Reply-to"}),e.jsxs("label",{className:"RmMeetingRequestRecipientPicker_switch",children:[e.jsx("input",{type:"checkbox",role:"switch",checked:q,disabled:d||!q&&b,"aria-label":`Notify ${n.name}`,onChange:j=>L(n,j.target.checked)}),e.jsx("span",{className:"RmMeetingRequestRecipientPicker_switchTrack","aria-hidden":"true",children:e.jsx("span",{className:"RmMeetingRequestRecipientPicker_switchThumb"})})]})]},n.key)})})]})]})}const re=120,$=320,Y=98,ae=222,E=ae-Y,U=160,ce=6,oe=320,K=.1,P=(s,o,r)=>Math.min(r,Math.max(o,s));function le(s){return 1+2.70158*Math.pow(s-1,3)+1.70158*Math.pow(s-1,2)}function ue({checked:s,onChange:o,label:r,disabled:d=!1}){const[h,y]=i.useState(s?1:0),[p,u]=i.useState(!1),[a,m]=i.useState(!1),R=i.useRef(h),g=i.useRef(null),M=i.useRef(null),f=i.useRef(null),_=i.useRef(null),b=i.useRef(null),l=t=>{R.current=t,y(t)},x=()=>{M.current!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(M.current),M.current=null};i.useEffect(()=>{var A;if(p)return;const t=s?1:0,c=R.current;if(c===t)return;if(typeof window<"u"&&((A=window.matchMedia)==null?void 0:A.call(window,"(prefers-reduced-motion: reduce)").matches)||typeof requestAnimationFrame!="function"){l(t);return}const w=performance.now(),S=H=>{const B=P((H-w)/oe,0,1);l(c+(t-c)*le(B)),M.current=B<1?requestAnimationFrame(S):null};return M.current=requestAnimationFrame(S),x},[s,p]),i.useEffect(()=>()=>{x(),f.current!==null&&window.clearTimeout(f.current)},[]);const L=()=>{var c;const t=((c=_.current)==null?void 0:c.getBoundingClientRect().height)??0;return t>0?t*E/$:E},k=()=>{m(!0),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>m(!1),450)},n=t=>{var c,N,w;d||g.current||t.pointerType==="mouse"&&t.button!==0||(x(),g.current={pointerId:t.pointerId,startY:t.clientY,startPosition:P(R.current,0,1),moved:!1},(N=(c=t.currentTarget).setPointerCapture)==null||N.call(c,t.pointerId),(w=b.current)==null||w.focus({preventScroll:!0}),u(!0))},q=t=>{const c=g.current;if(!c||t.pointerId!==c.pointerId)return;const N=c.startY-t.clientY;Math.abs(N)>ce&&(c.moved=!0),l(P(c.startPosition+N/L(),0,1))},j=(t,c)=>{var S,A;const N=g.current;if(!N||t.pointerId!==N.pointerId||(g.current=null,(A=(S=t.currentTarget).releasePointerCapture)==null||A.call(S,t.pointerId),u(!1),c))return;if(!N.moved){k();return}const w=R.current>.5;w!==s&&o(w)},C=t=>{d||(t.key==="ArrowUp"||t.key==="Home"?(t.preventDefault(),s||o(!0)):t.key==="ArrowDown"||t.key==="End"?(t.preventDefault(),s&&o(!1)):t.key==="Enter"&&(t.preventDefault(),o(!s)))},I=Y+(1-P(h,-K,1+K))*E,W=["RmMeetingRequestLever",s?"RmMeetingRequestLever--on":"RmMeetingRequestLever--off",p?"RmMeetingRequestLever--dragging":"",d?"RmMeetingRequestLever--disabled":"",a?"RmMeetingRequestLever--nudge":""].filter(
1Boolean).join(" ");return e.jsxs("div",{className:W,"data-testid":"rm-meeting-request-lever",children:[e.jsx("input",{ref:b,type:"checkbox",role:"switch",className:"RmMeetingRequestLever_input",checked:s,disabled:d,"aria-label":r,onChange:t=>o(t.target.checked),onKeyDown:C}),e.jsxs("svg",{ref:_,className:"RmMeetingRequestLever_svg",viewBox:`0 0 ${re} ${$}`,"aria-hidden":"true",focusable:"false",onPointerDown:n,onPointerMove:q,onPointerUp:t=>j(t,!1),onPointerCancel:t=>j(t,!0),children:[e.jsx("text",{className:"RmMeetingRequestLever_label RmMeetingRequestLever_label--on",x:"60",y:"30",textAnchor:"middle",children:"ON"}),e.jsx("rect",{className:"RmMeetingRequestLever_plate",x:"10",y:"44",width:"100",height:"232",rx:"18"}),[[24,58],[96,58],[24,262],[96,262]].map(([t,c])=>e.jsxs("g",{className:"RmMeetingRequestLever_screw",transform:`translate(${t} ${c})`,children:[e.jsx("circle",{r:"4.5"}),e.jsx("line",{x1:"-2.6",y1:"-2.6",x2:"2.6",y2:"2.6"})]},`${t}-${c}`)),e.jsx("rect",{className:"RmMeetingRequestLever_slot",x:"52",y:"72",width:"16",height:"176",rx:"8"}),e.jsx("circle",{className:"RmMeetingRequestLever_pivot",cx:"60",cy:U,r:"9"}),e.jsx("line",{className:"RmMeetingRequestLever_shaft",x1:"60",y1:U,x2:"60",y2:I}),e.jsxs("g",{className:"RmMeetingRequestLever_knob",transform:`translate(60 ${I})`,children:[e.jsx("circle",{className:"RmMeetingRequestLever_knobBall",r:"26"}),e.jsx("ellipse",{className:"RmMeetingRequestLever_knobShine",cx:"-8",cy:"-9",rx:"8",ry:"5"})]}),e.jsx("text",{className:"RmMeetingRequestLever_label RmMeetingRequestLever_label--off",x:"60",y:"304",textAnchor:"middle",children:"OFF"})]})]})}function z(){return typeof window>"u"?`https://response.uniformlaws.org${D}`:new URL(D,window.location.origin).toString()}function he(){const[s,o]=i.useState(null),[r,d]=i.useState(!0),[h,y]=i.useState([]),[p,u]=i.useState(""),[a,m]=i.useState(""),[R,g]=i.useState(!1),[M,f]=i.useState("");i.useEffect(()=>{let l=!0;return G().then(x=>{l&&(o(x),d(x.publicAccessEnabled),y(x.notificationRecipients))}).catch(x=>{l&&u(F(x))}),()=>{l=!1}},[]),i.useEffect(()=>{if(!p&&!a)return;const l=window.setTimeout(()=>{u(""),m("")},6e3);return()=>window.clearTimeout(l)},[p,a]);const _=async()=>{g(!0),u(""),m("");try{const l=await te({publicAccessEnabled:r,notificationRecipients:h});o(l),d(l.publicAccessEnabled),y(l.notificationRecipients),m("Settings saved.")}catch(l){u(F(l))}finally{g(!1)}},b=async()=>{try{await navigator.clipboard.writeText(z()),f("Copied")}catch{f("Copy failed")}window.setTimeout(()=>f(""),2200)};return e.jsxs("div",{className:"RmWorkflowPage RmPageStack RmMeetingRequestAdmin",children:[e.jsxs("a",{className:"RmTextLink",href:Q,children:[e.jsx(X,{size:16,"aria-hidden":"true"}),"Meeting Request"]}),e.jsxs("section",{className:"RmPageHeader","aria-labelledby":"mr-admin-title",children:[e.jsx("h1",{id:"mr-admin-title",children:"Meeting Request settings"}),e.jsx("p",{children:"Control whether the public form accepts requests and who is emailed when one arrives."})]}),e.jsx(J,{error:p,success:a}),!s&&!p?e.jsx(se,{label:"Loading settings",lines:4}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"RmMeetingRequestAdmin_grid",children:[e.jsxs("section",{className:"RmModuleCard RmMeetingRequestAdmin_card","aria-labelledby":"mr-admin-public-title",children:[e.jsx("h2",{id:"mr-admin-public-title",children:"Public form"}),e.jsxs("div",{className:"RmMeetingRequestAdmin_leverRow",children:[e.jsx(ue,{checked:r,disabled:R,label:"Public form is accepting requests",onChange:d}),e.jsxs("div",{className:"RmMeetingRequestAdmin_leverStatus",children:[e.jsx("p",{className:`RmMeetingRequestAdmin_leverState${r?"":" RmMeetingRequestAdmin_leverState--off"}`,"aria-live":"polite",children:r?"Accepting requests":"Closed to
1new requests"}),e.jsx("p",{className:"RmMeetingRequestAdmin_hint",children:'Drag the lever down to close the form or up to reopen it, then save. While closed, the public page shows "This form is not currently accepting requests." and submissions are rejected.'}),s&&r!==s.publicAccessEnabled&&e.jsx("p",{className:"RmMeetingRequestAdmin_unsaved",children:"Not saved yet. Click Save settings to apply."})]})]}),e.jsxs("div",{className:"RmMeetingRequestAdmin_urlRow",children:[e.jsx("code",{className:"RmMeetingRequestAdmin_url",children:z()}),e.jsxs("button",{type:"button",className:"RmButton RmButton--secondary",onClick:b,"aria-label":"Copy Meeting Request public form URL",children:[e.jsx(Z,{size:16,"aria-hidden":"true"}),M||"Copy URL"]})]})]}),e.jsxs("section",{className:"RmModuleCard RmMeetingRequestAdmin_card","aria-labelledby":"mr-admin-recipients-title",children:[e.jsx("h2",{id:"mr-admin-recipients-title",children:"Notifications"}),e.jsxs("p",{className:"RmMeetingRequestAdmin_hint",children:['Switch on each staff member who should receive a "New meeting request" email (up to ',T,"). The first recipient is the reply-to on the requester's receipt."]}),e.jsx(ne,{value:h,savedValue:(s==null?void 0:s.notificationRecipients)??[],onChange:y,disabled:R})]})]}),e.jsxs("section",{className:"RmModuleCard RmMeetingRequestAdmin_card","aria-labelledby":"mr-admin-retention-title",children:[e.jsx("h2",{id:"mr-admin-retention-title",children:"Retention"}),e.jsx("p",{className:"RmMeetingRequestAdmin_hint",children:"Retention: not configured â requests are kept until a future retention policy deletes them."}),(s==null?void 0:s.updatedAt)&&e.jsxs("p",{className:"RmMeetingRequestAdmin_hint",children:["Last saved ",ee(s.updatedAt),s.updatedBy?` by ${s.updatedBy}`:""]})]}),e.jsx("div",{className:"RmActionRow RmMeetingRequestAdmin_actions",children:e.jsx("button",{type:"button",className:"RmButton RmButton--primary",onClick:_,disabled:R,children:R?"Savingâ¦":"Save settings"})})]})]})}export{he 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.