1import{j as e,P as Ee,M as We,t as F,H as Ne,r as m,Y as G,a as Te,bp as Ye,J as Ue,d as Le,fd as be,l as Je}from"./index-C_WF_BJq.js";import{u as Xe,an as Pe,s as Ze,ao as _e,E as Ge,M as et,ap as tt,P as st,S as at,a as nt,b as it,c as lt,d as rt}from"./index-CIwrb30O.js";import{bm as ot,e0 as ct,j as Me,ck as dt,i as we,cl as mt,ct as ut,d as Oe,e1 as Fe,e as me,a as $e,c as ht}from"./DataProviderContext-CBDYCNcF.js";import{u as xt}from"./index-tMgwUWAz.js";import{S as pt}from"./SliderSwitch-DWN-GRZW.js";import{e as ft}from"./letter_default_logo-D0yRycS6.js";import{a as qe}from"./school-hooks-6EUkEa-d.js";import{a as ue}from"./utils-CzBtCSbB.js";import{T as Be}from"./trash-2-B9CykmCo.js";import{P as ye}from"./plus-CjQuaDVv.js";import{L as ve,C as gt,a as je}from"./loader-circle-Ck1hktYW.js";import{C as de}from"./ColumnFilter-D47RXuKy.js";import{H as Ce}from"./HighlightMatch-B1ruIgsH.js";import{X as vt,A as bt}from"./Avatar-DtGDmkuP.js";import{B as yt}from"./Badge-C7v4vPvS.js";import{S as jt}from"./SearchInput-5freF5RO.js";import{T as St}from"./TablePagination-CxHcKAFU.js";import{R as Nt}from"./RemoveConfirmDialog-C-a7kgbK.js";import{T as wt}from"./Tooltip-D5Yeo7Y3.js";import{S as Ct}from"./school_picker-BKL7oPma.js";import{U as At}from"./users-BgQSeBqf.js";import{S as kt}from"./send-DKdqONAF.js";import{T as Dt,a as It,b as Rt}from"./Tabs-BjO_Tr6U.js";import"./object-geCv8b2G.js";import"./Link-17SPgqEk.js";import"./sart-B3jih3T5.js";import"./createLucideIcon-07Q-ETyz.js";import"./tslib.es6-CMwweBXX.js";import"./common-DrIemzIo.js";import"./standards-D-5mjPXc.js";/* empty css */import"./prep_levels-DAO8iQsN.js";import"./arrow-left-DoUYf9FM.js";import"./circle-alert--qStYFqi.js";import"./AssignmentAdder-BQZqYLhc.js";import"./ai-Z_mVEYdG.js";import"./assignment-Bb2_O5Dm.js";import"./bluebonnet-5UhW2wPy.js";import"./communications-CPr3N3PG.js";import"./ContactForm-nFJhnAqW.js";import"./curriculum-Cz49gruj.js";import"./district-CMgaN5Nj.js";import"./it_onboarding-Duk6QZuq.js";import"./pd-DscbDIKQ.js";import"./problems-DEq45IZ7.js";import"./sart-CWW28Bvf.js";import"./subjects-D-MrSF8L.js";import"./search-Ce6BxiQo.js";import"./SearchBar-Co8iaTuY.js";import"./Icon-DVT53fS0.js";import"./district_scope-FATnlT4N.js";import"./index-DgoKnyni.js";import"./chevron-left-C-8LR_lP.js";import"./chevron-right-QdD5Q5Xj.js";const Et=Object.values(ct).map(t=>({value:t.state,label:t.displayName})).sort((t,s)=>t.label.localeCompare(s.label)),Tt=[{value:"district_admin",label:"District Admin",description:"Full access"},{value:"school_admin",label:"School Admin",description:"All data, no district settings"},{value:"academic_coach",label:"Academic Coach",description:"Academics + math + interventions"},{value:"attendance_specialist",label:"Attendance Specialist",description:"Attendance + interventions"},{value:"behavior_interventionist",label:"Behavior Interventionist",description:"Behavior + interventions"},{value:"counselor",label:"Counselor",description:"All student data, no admin"}],Lt=[{value:"sis_live",label:"SIS · Live",description:"PowerSchool is connected and all data is ready."},{value:"sis_access_blocked",label:"SIS · Access blocked",description:"Credentials and required PowerSchool permissions need work."},{value:"sis_file_errors",label:"SIS · File errors",description:"Synergy is the primary SIS; configured data files contain fixable errors."},{value:"sftp_live",label:"SFTP · Live",description:"Every required file has arrived and validated."},{value:"sftp_file_errors",label:"SFTP · File errors",description:"The latest attendance file contains rejected rows."},{value:"sftp_missing_files",label:"SFTP · Files missing",description:"No required files have arrived yet."},{value:"sftp_validating",label:"SFTP · Validating",description:"A newly received file is still processing."}];function Pt(){const{isMock:t,mockRole:s,setMockRole:i,mockState:n,setMockState:a,mockIntegrationScenario:r,setMockIntegrationScenario:d}=ot();return e.jsx("div",{className:"px-8 py-8 max-w-[900px] mx-auto",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Mock Role"}),e.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"Switch roles to test different permission levels."}),e.jsx("select",{value:s,onChange:l=>i(l.target.value),className:"input",children:Tt.map(l=>
1e.jsxs("option",{value:l.value,children:[l.label," â ",l.description]},l.value))})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Integrations"}),e.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"Preview the main SIS and SFTP setup, validation, and error states on the Integrations page."}),e.jsx("select",{value:r,onChange:l=>d(l.target.value),className:"input",children:Lt.map(l=>e.jsxs("option",{value:l.value,children:[l.label," â ",l.description]},l.value))})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 mb-2",children:"State"}),e.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"Override the demo district's state to preview each state's attendance-intervention process (SART/SARB and equivalents)."}),e.jsxs("select",{value:n??"",onChange:l=>a(l.target.value||null),className:"input",children:[e.jsx("option",{value:"",children:"Default (demo district)"}),Et.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))]})]})]})})}function _t(){const{user:{teacher:{uuid:t,emailPrefs:s}},set:i}=Ee(),{trigger:n,isMutating:a}=xt("updateTeacher",async(d,{arg:{emailPrefs:l}})=>await We(t,{emailPrefs:l}),{onSuccess:d=>i(d),onError:d=>F(d)}),r=[{id:"newSuggestedInterventions",label:"New suggested interventions",description:"Get notified when the system suggests a new intervention."},{id:"newInterventionsAssignedToMe",label:"New interventions assigned to me",description:"Get notified when an intervention is assigned to you."}];return e.jsxs("div",{className:"px-8 py-8 max-w-[900px] mx-auto",children:[e.jsx(Ne,{children:e.jsx("title",{children:"Edia | Notification Settings"})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700",children:"Email notifications"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Choose which email notifications you receive."})]}),e.jsx("div",{className:"card divide-y divide-gray-100 overflow-hidden",children:r.map(({id:d,label:l,description:g})=>e.jsxs("div",{className:"flex items-center justify-between px-4 py-3.5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900",children:l}),e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:g})]}),e.jsx(pt,{value:s[d],disabled:a,onChange:p=>{n({emailPrefs:{...s,[d]:p}})}})]},d))})]})}function H(t){const[s,i]=m.useState(t),[n,a]=m.useState(!1),r=m.useRef(t);r.current=t;const d=m.useCallback(g=>{i(g),a(!0)},[i]),l=m.useCallback(()=>{i(r.current),a(!1)},[]);return[s,d,l,n]}const Ve={2:"Semester",3:"Trimester",4:"Quarter"},Mt={1:"Year",...Ve},Ot=[{label:"2 semesters",portion:2,labels:["S1","S2"]},{label:"3 trimesters",portion:3,labels:["T1","T2","T3"]},{label:"4 quarters",portion:4,labels:["Q1","Q2","Q3","Q4"]}];function Ft(t){return`${t}â${t+1}`}function $t(t){return{portion:t.portion??4,label:t.label??"",firstDay:t.firstDay??"",lastDay:t.lastDay??""}}function qt(t){const s=new Set;for(const n of t){if(!n.label.trim())return"Every term needs a label.";if(!n.firstDay||!n.lastDay)return`Term "${n.label}" needs both a start and end date.`;if(n.firstDay>n.lastDay)return`Term "${n.label}": start date must be on or before end date.`;if(s.has(n.label.trim()))return`Duplicate term label "${n.label}".`;s.add(n.label.trim())}const i=new Map;for(const n of t)i.set(n.portion,[...i.get(n.portion)??[],n]);for(const n of i.values()){const a=[...n].sort((r,d)=>r.firstDay<d.firstDay?-1:1);for(let r=1;r<a.length;r++)if(a[r].firstDay<=a[r-1].lastDay)return`Terms "${a[r-1].label}" and "${a[r].label}" overlap.`}return null}function Bt({terms:t,dormantManualCount:s,onClearDormant:i,disabled:n}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"These terms come from your student information system and can't be edited here. To change them, update the term dates in your SIS."}),e.jsxs("table",{className:"text-sm border-separate border-spacing-0 w-full max-w-[560px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500",children:[e.jsx("th",{className:"py-1 pr-4 font-medium",children:"Term"}),e.jsx("th",{className:"py-1 pr-4 font-medium",children:"Type"}),e.jsx("th",{className:"py-1 pr-4 font-medium",children:"Start"}),e.jsx("th",{className:"py-1 font-medium",children:"End"})]})}),e.jsx("tbody",{children:t.map(a=>e.jsxs("tr",{className:"border-t border-gray-100",children:[e.jsx("td",{className:"py-1.5 pr-4 text-gray-900",children:a.label}),e.jsx("td",{className:"py-1.5 pr-4 text-gray-600",children:a.portion!=null?Mt[a.portion]??"â":"â"}),e.jsx("td",{className:"py-1.5 pr-4 text-gray-600",children:a.firstDay??"â"}),e.jsx("td",{className:"py-1.5 text-gray-600",children:a.lastDay??"â"})]},a.termId))})]}),s>0&&e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 pt-1",children:[e.jsxs("span",{children:[s," manually-entered"," ",s===1?"term is":"terms are"," no longer in use now that your SIS provides this year's terms."]}),e.jsx("button",{type:"button",onClick:i,disabled:n,className:"text-blue-600 hover:text-blue-700 cursor-pointer disabled:opacity-50",children:"Clear them"})]})]})}function Vt({schoolYear:t,readOnly:s,terms:i,onChange:n,sisTerms:a,dormantManualCount:r,onClearDormant:d,disabled:l}){const g=o=>n(o.labels.map(f=>({portion:o.portion,label:f,firstDay:"",lastDay:""}))),p=(o,f)=>n(i.map((u,w)=>w===o?{...u,...f}:u)),h=o=>n(i.filter((f,u)=>u!==o)),v=()=>{var o;return n([...i,{portion:((o=i[i.length-1])==null?void 0:o.portion)??4,label:"",firstDay:"",lastDay:""}])};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"max-w-[560px]",children:[e.jsxs("h4",{className:"text-sm font-semibold text-gray-900",children:["Term dates · ",Ft(t)]}),e.jsx("p",{className:"text-xs text-gray-500",children:"Used to resolve âthis quarterâ / âthis semesterâ windows in attendance automations."})]}),s?e.jsx(Bt,{terms:a,dormantManualCount:r,onClearDormant:d,disabled:l}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-gray-500 max-w-[560px]",children:"Enter your grading-period terms. The full school-year span comes from your school
1calendar â enter only the semesters, trimesters, or quarters below. Start from a template:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Ot.map(o=>e.jsx("button",{type:"button",onClick:()=>g(o),disabled:l,className:"btn btn-sm btn-secondary",children:o.label},o.label))}),i.length===0?e.jsx("p",{className:"text-sm text-gray-400 py-4",children:"No terms yet. Pick a template above or add a term."}):e.jsx("div",{className:"space-y-2",children:i.map((o,f)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("select",{value:o.portion,onChange:u=>p(f,{portion:Number(u.target.value)}),disabled:l,className:"input w-32",children:Object.entries(Ve).map(([u,w])=>e.jsx("option",{value:u,children:w},u))}),e.jsx("input",{type:"text","aria-label":"Term label",placeholder:"Label (e.g. Q1)",value:o.label,onChange:u=>p(f,{label:u.target.value}),disabled:l,className:"input w-28"}),e.jsx("input",{type:"date","aria-label":"Start date",value:o.firstDay,onChange:u=>p(f,{firstDay:u.target.value}),disabled:l,className:"input"}),e.jsx("span",{className:"text-gray-400",children:"â"}),e.jsx("input",{type:"date","aria-label":"End date",value:o.lastDay,onChange:u=>p(f,{lastDay:u.target.value}),disabled:l,className:"input"}),e.jsx("button",{type:"button",onClick:()=>h(f),disabled:l,"aria-label":"Remove term",className:"text-gray-400 hover:text-red-600 cursor-pointer p-1",children:e.jsx(Be,{className:"w-4 h-4"})})]},f))}),e.jsxs("button",{type:"button",onClick:v,disabled:l,className:"flex items-center gap-1 text-sm text-blue-600 hover:text-blue-700 cursor-pointer",children:[e.jsx(ye,{className:"w-4 h-4"})," Add term"]})]})]})}function Q({title:t,description:s,children:i}){return e.jsxs("div",{className:"max-w-[560px]",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900",children:t}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:s}),i]})}const zt=5*1024*1024;function Kt(t){return/^(https?:|blob:|data:)/.test(t)?t:`https://edia.app${t}`}function Ht({schoolId:t,logoUrl:s,setLogoUrl:i,disabled:n,uploadLogo:a,deleteLogo:r}){const d=m.useRef(null),[l,g]=m.useState(!1),p=async o=>{var u;const f=(u=o.target.files)==null?void 0:u[0];if(f){if(o.target.value="",f.size>zt){F("Logo must be under 5MB");return}g(!0);try{const{logoUrl:w}=await a(t,f);i(w),G("Logo uploaded")}catch(w){F(w)}finally{g(!1)}}},h=async()=>{g(!0);try{await r(t),i(null),G("Logo removed")}catch(o){F(o)}finally{g(!1)}},v=n||l;return e.jsxs(Q,{title:"School logo",description:s?"Used on letterhead for formal letters. Recommended: 200x200px or larger.":"Used on letterhead for formal letters. Recommended: 200x200px or larger. Until you upload one, letters carry the default mark shown here.",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[s?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:Kt(s),alt:"School logo",className:"w-16 h-16 object-contain rounded-lg border border-gray-200 bg-white"}),e.jsx("button",{type:"button",onClick:h,disabled:v,className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-gray-800 text-white rounded-full flex items-center justify-center text-xs opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:"Ã"})]}):e.jsx("button",{type:"button",onClick:()=>{var o;return(o=d.current)==null?void 0:o.click()},disabled:v,className:"w-16 h-16 rounded-lg border border-dashed border-gray-300 flex items-center justify-center bg-white text-gray-400 hover:border-gray-400 hover:text-gray-500 transition-colors cursor-pointer",children:l?e.jsx(ve,{className:"w-5 h-5 animate-spin"}):e.jsx("img",{src:ft,alt:"Default letterhead mark",className:"w-9 h-9 object-contain"})}),e.jsx("button",{type:"button",onClick:()=>{var o;return(o=d.current)==null?void 0:o.click()},disabled:v,className:"text-sm text-blue-600 hover:text-blue-700 cursor-pointer",children:l?"Uploading...":s?"Change logo":"Upload logo"})]}),e.jsx("input",{ref:d,type:"file",accept:"image/png,image/jpeg,image/svg+xml,image/webp,image/gif",className:"hidden",onChange:p})]})}function Qt({school:t}){const{data:s,isLoading:i,mutate:n}=dt(t.id),{schoolYearStartDate:a}=we();return i||!s?e.jsx(ve,{className:"w-5 h-5 animate-spin text-gray-400"}):e.jsx(Wt,{school:t,termsData:s,mutateTerms:n,schoolYear:mt(a)})}function Wt({school:t,termsData:s,mutateTerms:i,schoolYear:n}){const{updateSettings:a,updateDistrictSettings:r,updateTerms:d,uploadLogo:l,deleteLogo:g}=ut(),{data:p,mutate:h}
1=Oe(),v=Xe(),o=Pe(),{isSuperView:f,superLevel:u}=Ze(),w=f?u>=3:o,[A,k]=m.useState(!1),[W,Y,P,B]=H(t.displayName??t.name??""),[C,$,ee,U]=H(t.displayAddress??t.address??""),[_,te,q,ne]=H(t.officePhone??""),[D,se,I,ie]=H(t.principalName??""),[E,le,V,b]=H(t.designatedAttendanceStaff??""),[S,J]=m.useState(t.logoUrl??null),[re,he,oe,xe]=H(t.emailSignature??""),[ce,X,z,K]=H((p==null?void 0:p.emailSignature)??""),R=s.years.find(y=>y.schoolYear===n),c=(R==null?void 0:R.readOnly)??!1,j=((R==null?void 0:R.terms)??[]).filter(y=>y.source==="sis"),T=c?((R==null?void 0:R.terms)??[]).filter(y=>y.source==="manual").length:0,[x,N,M,ae]=H(c?[]:((R==null?void 0:R.terms)??[]).map($t)),O=B||U||ne||ie||b||xe,Z=!c&&ae,pe=O||Z||K,L=!w||A,Ke=m.useCallback(()=>{P(),ee(),q(),I(),V(),oe(),z(),M()},[P,ee,q,I,V,oe,z,M]);async function He(){if(!L){if(_&&!/^[\d\s()+\-./]+$/.test(_)){F("Invalid phone number format");return}if(Z){const y=qt(x);if(y){F(y);return}}k(!0);try{const y=[];O&&y.push(a(t.id,{displayName:W,displayAddress:C,officePhone:_,principalName:D,designatedAttendanceStaff:E,emailSignature:re})),v&&K&&y.push(r({emailSignature:ce})),Z&&y.push(d(t.id,n,x.map(fe=>({portion:fe.portion,label:fe.label.trim(),firstDay:fe.firstDay,lastDay:fe.lastDay})))),await Promise.all(y),await Promise.all([h(),i()]),G("School settings saved")}catch{F("Failed to save")}finally{k(!1)}}}async function Qe(){if(!L){k(!0);try{await d(t.id,n,[]),await i(),G("Cleared your manually-entered terms")}catch{F("Failed to clear terms")}finally{k(!1)}}}return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ht,{schoolId:t.id,logoUrl:S,setLogoUrl:J,disabled:L,uploadLogo:l,deleteLogo:g}),e.jsx(Q,{title:"School name",description:"The display name used across the platform.",children:e.jsx("input",{type:"text",placeholder:"e.g. Northstar High School",value:W,onChange:y=>Y(y.target.value),disabled:L,className:"input"})}),e.jsx(Q,{title:"School address",description:"Used on formal letters and letterhead.",children:e.jsx("input",{type:"text",placeholder:"e.g. 1234 Education Way, Springfield, CA 90210",value:C,onChange:y=>$(y.target.value),disabled:L,className:"input"})}),e.jsx(Q,{title:"School phone number",description:"Used in outreach messages and letterhead.",children:e.jsx("input",{type:"tel",placeholder:"(555) 555-5555",value:_,onChange:y=>te(y.target.value),disabled:L,className:"input"})}),e.jsx(Q,{title:"School principal name",description:"Available as a merge field in formal letters.",children:e.jsx("input",{type:"text",placeholder:"e.g. Dr. Alicia Reyes",value:D,onChange:y=>se(y.target.value),disabled:L,className:"input"})}),e.jsx(Q,{title:"Designated attendance staff",description:"Name and title used as the attendance contact in formal letters.",children:e.jsx("input",{type:"text",placeholder:"e.g. Jordan Lee, Attendance Specialist",value:E,onChange:y=>le(y.target.value),disabled:L,className:"input"})}),e.jsx(Q,{title:"Email signature",description:"Signs off emails this school sends to families. Leave it blank to use the default shown, built from the details above. Sent as written â it is not translated with the message.",children:e.jsx("textarea",{rows:4,placeholder:t.defaultEmailSignature??"",value:re,onChange:y=>he(y.target.value),disabled:L,maxLength:1e3,className:"input resize-y"})}),v&&e.jsx("div",{className:"border-t border-gray-200 pt-6",children:e.jsx(Q,{title:"District email signature",description:"Signs off emails sent to the whole district, and stands in for a school that has not set one of its own. Leave it blank to use the default shown.",children:e.jsx("textarea",{rows:4,placeholder:(p==null?void 0:p.defaultEmailSignature)??"",value:ce,onChange:y=>X(y.target.value),disabled:L,maxLength:1e3,className:"input resize-y"})})}),e.jsx("div",{className:"border-t border-gray-200 pt-6",children:e.jsx(Vt,{schoolYear:n,readOnly:c,terms:x,onChange:N,sisTerms:j,dormantManualCount:T,onClearDormant:Qe,disabled:L})}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs("button",{onClick:He,disabled:!pe||L,className:ue("btn btn-md inline-flex items-center gap-1.5",pe&&!A?"btn-primary":"btn-secondary opacity-50"),children:[A&&e.jsx(ve,{className:"w-4 h-4 animate-spin"}),"Save changes"]}),e.jsx("button",{onClick:Ke,disabled:!pe||L,className:ue("btn btn-md btn-secondary",(!pe||A)&&"opacity-50"),children:"Revert"})]})]})}function Yt(){var a;
1const t=qe(),[s]=Me(),i=s??((a=t[0])==null?void 0:a.id)??null,n=t.find(r=>r.id===i);return e.jsx("div",{className:"px-8 py-8 max-w-[900px] mx-auto",children:n?e.jsx(Qt,{school:n},n.id):e.jsx("p",{className:"text-sm text-gray-500",children:"No schools found."})})}function ze(t){return t.isInvite?"This invitation includes schools you donât manage. Ask a district admin to change it.":"This user has access to schools you donât manage. Ask a district admin to remove them."}function Se({reason:t,children:s}){return t?e.jsx("span",{onClick:i=>i.stopPropagation(),children:e.jsx(wt,{content:t,position:"left",children:s})}):e.jsx(e.Fragment,{children:s})}function Ut({value:t,onChange:s,disabled:i}){const[n,a]=m.useState(!1),r=m.useRef(null),d=m.useRef(null),[l,g]=m.useState({top:0,left:0,width:0});m.useEffect(()=>{if(!n)return;function h(v){var o,f;(o=r.current)!=null&&o.contains(v.target)||(f=d.current)!=null&&f.contains(v.target)||a(!1)}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n]);function p(){var v;if(n){a(!1);return}const h=(v=r.current)==null?void 0:v.getBoundingClientRect();h&&g({top:h.bottom+4,left:h.left,width:h.width}),a(!0)}return e.jsxs(e.Fragment,{children:[e.jsxs("button",{ref:r,type:"button",onClick:p,disabled:i,className:"flex items-center justify-between w-full bg-white border border-gray-300 rounded-lg px-4 py-2 text-sm text-gray-700 hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-gray-300",children:[e.jsx("span",{className:ue("truncate",!t&&"text-gray-400"),children:t?me[t].label:"Choose role"}),e.jsx(gt,{className:"w-4 h-4 text-gray-400 shrink-0 ml-2"})]}),n&&Te.createPortal(e.jsx("div",{ref:d,className:"fixed bg-white rounded-lg shadow-lg border border-gray-200 z-[2001]",style:{top:l.top,left:l.left,width:l.width},children:e.jsx("div",{className:"py-1 divide-y divide-gray-100",children:Object.entries(me).filter(([h])=>h!=="legacy_school_admin").map(([h,v])=>e.jsx("button",{type:"button",onClick:()=>{s(h),a(!1)},className:ue("w-full px-4 py-2.5 text-left text-sm transition-colors cursor-pointer",h===t?"bg-blue-50 text-blue-700":"text-gray-700 hover:bg-gray-50"),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:v.label}),e.jsx("div",{className:"text-xs text-gray-500",children:v.description})]}),h===t&&e.jsx(je,{className:"w-4 h-4 text-blue-600 shrink-0 ml-2"})]})},h))})}),document.body)]})}const Jt={attendance:"Attendance data",academics:"Academics data",math:"Math data",behavior:"Behavior data",interventions:"Interventions"},Xt=[{key:"canUploadData",label:"Upload data"},{key:"canSetGoals",label:"Set goals"},{key:"canManageTemplates",label:"Manage templates"},{key:"canEditDashboard",label:"Edit dashboard"}];function Zt({role:t}){const s=me[t],i=s.domains.filter(a=>a!=="dashboard"),n=Xt.filter(a=>s[a.key]);return e.jsx("div",{className:"mt-2 rounded-lg bg-gray-50 px-3 py-2.5 text-xs text-gray-600",children:e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:[i.map(a=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(je,{className:"w-3 h-3 text-green-600"}),Jt[a]??a]},a)),n.map(a=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(je,{className:"w-3 h-3 text-green-600"}),a.label]},a.key))]})})}function Ae({updateUser:t,isFullAdmin:s,onClose:i,reloadDistrict:n,onRemove:a,manageableSchoolIds:r}){const{schools:d}=we(),{addAdmin:l,requestStudentAccountReset:g}=Fe(),p=m.useMemo(()=>r?d.filter(b=>r.has(b.id)):d,[d,r]),[h,v]=m.useState(""),[o,f]=m.useState((t==null?void 0:t.role)??""),u=(t==null?void 0:t.perms)??[],w=!!r&&u.some(b=>!b.startsWith("_")&&!r.has(b)),[A,k]=m.useState(r?u.filter(b=>r.has(b)):u.length===0?void 0:u),[W,Y]=m.useState(!1),[P,B]=m.useState(!1),[C,$]=m.useState(""),[ee,U]=m.useState(),[_,te]=m.useState(!1),[q,ne]=m.useState();m.useEffect(()=>{const b=S=>{S.key==="Escape"&&i()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[i]);const D=t?s?"Edit district admin":"Edit school staff":s?"Add district admin":"Add sc
1hool staff",se=s||A===void 0||((A==null?void 0:A.length)??0)>0,I=s||!!o,ie=t?!P&&I&&se:!P&&!!h&&I&&se,E=s?[]:r&&A===void 0?p.map(b=>b.id):A??[];async function le(){var b;B(!0);try{if(t)await l({user:t.uuid},E,s,s?void 0:o||void 0);else{const S=await l({email:h},E,s,s?void 0:o||void 0),J=S.name?S.name:`${h} and sent email`;G(`Added ${J}`)}await n(),i()}catch(S){if(B(!1),Ye.isAxiosError(S)&&((b=S.response)==null?void 0:b.status)===400){const J=S.response.data;U(J.code),$(Ue(S));return}F(S)}}async function V(){const b=h.trim().toLowerCase();te(!0);try{await g(b,E,s,o||void 0),ne(b),G("Your support request has been received.")}catch(S){F(S)}finally{te(!1)}}return Te.createPortal(e.jsx("div",{className:"district2",children:e.jsx("div",{className:"modal-overlay fixed inset-0 flex items-center justify-center z-[2000] backdrop-blur-[6px]",onClick:i,children:e.jsxs("div",{className:"modal-dialog relative flex flex-col w-[480px] max-w-[calc(100vw-48px)] max-h-[calc(100vh-96px)]",onClick:b=>b.stopPropagation(),children:[e.jsx("button",{onClick:i,"aria-label":"Close",className:"absolute top-5 right-6 w-8 h-8 flex items-center justify-center rounded-lg text-gray-500 hover:bg-gray-200 hover:text-gray-700 transition-colors cursor-pointer z-10",children:e.jsx(vt,{className:"w-4 h-4"})}),e.jsxs("div",{className:"px-6 pt-5 pb-3.5 pr-16 flex-shrink-0",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900",children:D}),s&&e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"District admins can view every school's data, manage staff, and change district settings."})]}),e.jsxs("div",{className:"px-6 pr-4 pb-4 space-y-4 overflow-y-auto flex-1 min-h-0",children:[t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Name"}),e.jsx("input",{type:"text",value:t.name,disabled:!0,className:"input opacity-60"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email address"}),e.jsx("input",{type:"email",value:t.email,disabled:!0,className:"input opacity-60"})]})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email address"}),e.jsx("input",{type:"email",value:h,onChange:b=>{$(""),U(void 0),v(b.target.value)},placeholder:"Enter email address",autoComplete:"off",autoFocus:!0,"aria-invalid":!!C,"aria-describedby":C?"staff-email-error":void 0,className:C?"input input-error":"input"}),C&&e.jsx("p",{id:"staff-email-error",className:"text-xs text-red-600 mt-1",children:ee==="student_email_collision"?e.jsxs(e.Fragment,{children:[`${h} is already registered to a student account. `,q===h.trim().toLowerCase()?"A request has been sent to Edia Support to reset this account.":e.jsxs(e.Fragment,{children:["Use a different staff email, or"," ",e.jsx("button",{type:"button",className:"underline font-medium hover:text-red-800 disabled:cursor-wait",onClick:V,disabled:_,children:_?"contacting Edia Supportâ¦":"contact Edia Support"})," ","to reset this user's account."]})]}):C})]}),!s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Role"}),e.jsx(Ut,{value:o,onChange:f,disabled:w}),w&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"This user also has access to schools you donât manage, so only a district admin can change their role."}),o&&e.jsx(Zt,{role:o})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Schools"}),e.jsx(Ct,{schools:p,selectedSchoolIds:A,onChange:b=>{Y(!0),k(b)}}),W&&A!==void 0&&A.length===0&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:"Select at least one school."})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-6 py-5 border-t border-gray-100 flex-shrink-0",children:[t&&a&&e.jsx(Se,{reason:w?ze({isInvite:!1}):void 0,children:e.jsx("button",{onClick:a,disabled:P||w,className:"btn btn-sm btn-danger cursor-pointer disabled:pointer-events-none",children:"Remove"})}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:i,disabled:P,className:"btn btn-sm btn-secondary cursor-pointer",children:"Cancel"}),e.jsx("button",{onClick:le,disabled:!ie,className:"btn btn-sm btn-primary curs
1or-pointer",children:t?"Update":"Add"})]})]})})}),document.body)}const ge=25,ke="__full__";function De(t){return t&&t in me?me[t].label:"School Admin"}function Ie(t,s,i,n){var a;return i?"All schools":n.length===1?((a=t.find(r=>r.id===n[0]))==null?void 0:a.name)??"1 school":`${n.length} schools`}function Re(t,s,i,n){var r;if(i)return-1;let a=1/0;for(const d of n){const l=(r=t.find(p=>p.id===d))==null?void 0:r.level,g=l?be.indexOf(l):-1;a=Math.min(a,g===-1?be.length:g)}return a===1/0?be.length:a}function Gt(t){var a;const s=t.includes("_admin"),i=(a=t.find(r=>r.startsWith("_role:")))==null?void 0:a.slice(6),n=t.filter(r=>!r.startsWith("_"));return{isAdmin:s,role:i,schoolIds:n}}function es(t,s,i){switch(i){case"email":return t.email.localeCompare(s.email);case"access":return t.accessRank-s.accessRank||t.access.localeCompare(s.access);case"roleLabel":return t.roleLabel.localeCompare(s.roleLabel);case"status":return t.status.localeCompare(s.status);case"name":default:return t.sortName.localeCompare(s.sortName)}}function ts(){const{mutate:t}=Oe(),{removeAdmin:s,removeInvitation:i,resendInvitation:n}=Fe(),a=$e(),r=Le(),{schools:d,admins:l,viewers:g,invitations:p,adminInvitations:h,viewerLevel:v}=we(),{data:o}=ht(),f=_e(),{user:{teacher:u}}=Ee(),w=v==="admin",A=f&&!w,k=m.useMemo(()=>A?new Set((o==null?void 0:o.schoolIds)??[]):null,[A,o==null?void 0:o.schoolIds]),[W,Y]=m.useState(null),[P,B]=m.useState(),[C,$]=m.useState(),[ee,U]=m.useState(null),[_,te]=m.useState(""),[q,ne]=m.useState(""),[D,se]=m.useState("name"),[I,ie]=m.useState("asc"),[E,le]=m.useState({}),[V,b]=m.useState(1);m.useEffect(()=>{const c=setTimeout(()=>ne(_),200);return()=>clearTimeout(c)},[_]),m.useEffect(()=>{b(1)},[q,E,D,I]),m.useEffect(()=>{f||r(a,{replace:!0})},[r,f,a]);const S=m.useMemo(()=>{if(!d)return[];const c=[],j=(x,N)=>k?N.some(M=>k.has(M)):!0,T=x=>!!k&&x.some(N=>!k.has(N));if(w){for(const x of l??[])c.push({id:x.uuid,name:x.name,sortName:x.name.toLowerCase(),email:x.email,isAdmin:!0,isInvite:!1,allSchools:!0,schoolIds:[],hasSchoolsOutsideScope:!1,access:"Full district access",accessRank:-1,roleLabel:"District admin",status:"Active",user:x});for(const x of h??[])c.push({id:`invite:${x}`,name:x,sortName:x.toLowerCase(),email:x,isAdmin:!0,isInvite:!0,allSchools:!0,schoolIds:[],hasSchoolsOutsideScope:!1,access:"Full district access",accessRank:-1,roleLabel:"District admin",status:"Invited"})}for(const x of g??[]){if(x.uuid===u.uuid)continue;const N=x.perms.filter(ae=>!ae.startsWith("_")),M=N.length===0;j(!1,N)&&c.push({id:x.uuid,name:x.name,sortName:x.name.toLowerCase(),email:x.email,isAdmin:!1,isInvite:!1,allSchools:M,schoolIds:N,hasSchoolsOutsideScope:T(N),access:Ie(d,!1,M,N),accessRank:Re(d,!1,M,N),roleLabel:De(x.role),status:"Active",user:x})}for(const[x,N]of Object.entries(p??{})){const{isAdmin:M,role:ae,schoolIds:O}=Gt(N);if(M)continue;const Z=O.length===0;j(!1,O)&&c.push({id:`invite:${x}`,name:x,sortName:x.toLowerCase(),email:x,isAdmin:!1,isInvite:!0,allSchools:Z,schoolIds:O,hasSchoolsOutsideScope:T(O),access:Ie(d,!1,Z,O),accessRank:Re(d,!1,Z,O),roleLabel:De(ae),status:"Invited"})}return c},[d,l,g,p,h,w,k,u.uuid]),J=m.useMemo(()=>[{value:ke,label:"Full district access"},...[...d??[]].slice().sort((c,j)=>c.name.localeCompare(j.name)).map(c=>({value:c.id,label:c.name}))],[d]),re=m.useMemo(()=>{const c=q.trim().toLowerCase(),j=E.access,T=E.roleLabel,x=E.status;return S.filter(N=>!(c&&!`${N.name} ${N.email}`.toLowerCase().includes(c)||j&&j.size>0&&!(j.has(ke)&&N.allSchools||N.schoolIds.some(O=>j.has(O)))||T&&T.size>0&&!T.has(N.roleLabel)||x&&x.size>0&&!x.has(N.status)))},[S,q,E]),he=m.useMemo(()=>{const c=I==="asc"?1:-1;return[...re].sort((j,T)=>D==="name"&&j.isInvite!==T.isInvite?j.isInvite?1:-1:es(j,T,D)*c)},[re,D,I]),oe=he.length,xe=Math.max(1,Math.ceil(oe/ge)),ce=he.slice((V-1)*ge,V*ge),X=(c,j)=>{se(c),ie(j)},z=(c,j)=>le(T=>({...T,[c]:j})),K=c=>E[c]||new Set;async function R(c){U(c.email);try{await n(c.email,c.isAdmin),G(`Invitation resent to ${c.email}`)}catch(j){F(j)}finally{U(null)}}return d?e.jsxs("div",{className:"px-6 py-6 max-w-[1100px] mx-auto",children:[e.jsx(Ne,{children:e.jsx("title",{children:"Edia | District Staff"})}),e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(jt,{value:_,onCh
1ange:te,placeholder:"Search by name or email",ariaLabel:"Search staff",className:"max-w-md flex-1"}),e.jsx("div",{className:"flex-1"}),w&&e.jsxs("button",{onClick:()=>Y("admin"),className:"btn btn-sm btn-secondary flex items-center gap-1.5",children:[e.jsx(ye,{className:"w-3.5 h-3.5"}),"Add district admin"]}),e.jsxs("button",{onClick:()=>Y("viewer"),className:"btn btn-sm btn-primary flex items-center gap-1.5",children:[e.jsx(ye,{className:"w-3.5 h-3.5"}),"Add school staff"]})]}),e.jsxs("div",{className:"card overflow-hidden",children:[e.jsx("div",{className:"overflow-x-auto scrollbar-thin",children:e.jsxs("table",{className:"w-full min-w-[820px] table-fixed",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left border-b border-gray-200",children:[e.jsx(de,{label:"Name",columnKey:"name",data:S,sortKey:D,sortDirection:I,onSort:X,selectedValues:K("name"),onFilterChange:z,sortOnly:!0,className:"w-[18%]"}),e.jsx(de,{label:"Email",columnKey:"email",data:S,sortKey:D,sortDirection:I,onSort:X,selectedValues:K("email"),onFilterChange:z,sortOnly:!0,className:"w-[14%]"}),e.jsx(de,{label:"Access",columnKey:"access",data:S,sortKey:D,sortDirection:I,onSort:X,selectedValues:K("access"),onFilterChange:z,filterOptions:J,className:"w-[16%]"}),e.jsx(de,{label:"Role",columnKey:"roleLabel",data:S,sortKey:D,sortDirection:I,onSort:X,selectedValues:K("roleLabel"),onFilterChange:z,className:"w-[14%]"}),e.jsx(de,{label:"Status",columnKey:"status",data:S,sortKey:D,sortDirection:I,onSort:X,selectedValues:K("status"),onFilterChange:z,className:"w-[16%]"}),e.jsx("th",{className:"w-[22%] bg-gray-50"})]})}),e.jsx("tbody",{children:ce.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(Ge,{inline:!0,icon:e.jsx(At,{className:"w-8 h-8"}),title:"No staff found",message:S.length===0?"Add staff to give them access to your district dashboard.":"Try adjusting your search or filters."})})}):ce.map(c=>e.jsx(ss,{row:c,schools:d,query:q,resending:ee===c.email,onEdit:()=>c.user&&B({user:c.user,isAdmin:c.isAdmin}),onResend:()=>{R(c)},onRemove:()=>$({email:c.email,name:c.isInvite?void 0:c.name,isAdmin:c.isAdmin,isInvite:c.isInvite})},c.id))})]})}),xe>1&&e.jsx(St,{page:V,totalPages:xe,total:oe,pageSize:ge,onPageChange:b})]}),W&&e.jsx(Ae,{isFullAdmin:W==="admin",onClose:()=>Y(null),reloadDistrict:t,manageableSchoolIds:k}),P&&e.jsx(Ae,{updateUser:P.user,isFullAdmin:P.isAdmin,onClose:()=>B(void 0),reloadDistrict:t,manageableSchoolIds:k,onRemove:()=>{const{user:c,isAdmin:j}=P;B(void 0),$({email:c.email,name:c.name,isAdmin:j,isInvite:!1})}}),C&&e.jsx(Nt,{title:C.isInvite?"Remove invitation":"Remove user",message:`Remove ${C.name??C.email} from your district dashboard?`,onClose:()=>$(void 0),onConfirm:async()=>{if(C.isInvite)await i(C.email,C.isAdmin);else{const c=[...l??[],...g??[]].find(j=>j.email===C.email);c&&await s(c.uuid,C.isAdmin)}await t(),$(void 0)}})]}):null}function ss({row:t,schools:s,query:i,resending:n,onEdit:a,onResend:r,onRemove:d}){const l=!t.isAdmin&&!t.allSchools&&t.schoolIds.length>1?t.schoolIds.map(h=>{var v;return(v=s.find(o=>o.id===h))==null?void 0:v.name}).filter(Boolean).join(", "):void 0,g=!t.isInvite,p=t.hasSchoolsOutsideScope?ze(t):void 0;return e.jsxs("tr",{onClick:g?a:void 0,className:ue("border-b border-gray-100 last:border-b-0",g&&"hover:bg-gray-50 cursor-pointer"),children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.isInvite?e.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center shrink-0",role:"img","aria-label":"Pending invitation",children:e.jsx(et,{className:"w-4 h-4 text-gray-400"})}):e.jsx(bt,{name:t.name,size:"sm"}),t.isInvite?e.jsx("span",{className:"text-sm italic text-gray-400 truncate",children:"Invitation pending"}):e.jsx("span",{className:"text-sm font-medium text-gray-900 truncate",children:e.jsx(Ce,{text:t.name,query:i})})]})}),e.jsx("td",{className:"px-4 py-2.5 text-sm text-gray-600 truncate",title:t.email,children:e.jsx(Ce,{text:t.email,query:i})}),e.jsx("td",{className:"px-4 py-2.5 text-sm text-gray-700 truncate",title:l??t.access,children:t.access}),e.jsx("td",{className:"px-4 py-2.5 text-sm text-gray-600 truncate",title:t.roleLabel,children:t.roleLabel}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx(yt,{variant:t.status==="Active"?"success":"warning",children:t.status})}),e.jsx("td",{className:"py-2.5 pl-4 pr-5",children:e.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[t.isInvite&&e.jsx(Se,{reason:p,children:e.jsxs("button",{onClick:h=>{h.stopPropagation(),r()},disabled:n||!!p,"aria-label":`Resend invitation to ${t.email}`,className:"btn btn-sm btn-secondary flex items-center gap-1.5 disabled:pointer-events-none",children:[n?e.jsx(ve,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(kt,{className:"w-3.5 h-3.5"}),"Resend"]})}),e.jsx(Se,{reason:p,children:e.jsx("button",{onClick:h=>{h.stopPropagation(),d()},disabled:!!p,"aria-label":t.isInvite?`Remove invitation for ${t.email}`:`Remove ${t.name}`,className:"w-8 h-8 flex items-center justify-center rounded-lg text-gray-400 hover:bg-gray-100 hover:text-red-600 transition-colors cursor-pointer disabled:opacity-40 disabled:pointer-events-none",children:e.jsx(Be,{className:"w-4 h-4"})})})]})})]})}function aa(){var f;const t=Le(),s=$e(),i=s==="/district2",n=Pe(),a=_e();let{tab:r}=Je();const d=tt()&&i,l=qe(),[g,p]=Me(),h=l.length>0,v=[n&&h&&{value:"schools",label:"Schools"},a&&{value:"staff",label:"Staff"},{value:"notifications",label:"Notifications"},d&&{value:"dev",label:"Dev"}].filter(u=>!!u);v.some(u=>u.value===r)||(r=v[0].value);const o=u=>t(`${s}/settings/${u}`,{replace:!0});return e.jsxs("div",{className:"district2 flex flex-col h-full",children:[e.jsx(Ne,{children:e.jsx("title",{children:"Edia | Settings"})}),e.jsxs("div",{className:"sticky top-0 z-10 bg-gray-50",children:[e.jsx("div",{className:"px-6 pt-6",children:e.jsx(st,{title:"Settings",actions:l.length>1?e.jsx("div",{className:r!=="schools"?"hidden":void 0,children:e.jsxs(at,{value:g??((f=l[0])==null?void 0:f.id)??void 0,onValueChange:p,children:[e.jsx(nt,{children:e.jsx(it,{})}),e.jsx(lt,{children:l.map(u=>e.jsx(rt,{value:u.id,children:u.name},u.id))})]})}):null})}),e.jsx(Dt,{value:r,onChange:o,children:e.jsx(It,{className:"px-6 mt-2",children:v.map(u=>e.jsx(Rt,{value:u.value,children:u.label},u.value))})})]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[r==="schools"&&e.jsx(Yt,{}),r==="staff"&&e.jsx(ts,{}),r==="notifications"&&e.jsx(_t,{}),r==="dev"&&e.jsx(Pt,{})]})]})}export{aa as default}; 2//# sourceMappingURL=page-DecX9rkD.js.map
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.