1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,470152,e=>{"use strict";e.s(["clamp",0,function(e,[t,n]){return Math.min(n,Math.max(t,e))}])},75830,e=>{"use strict";var t=e.i(271645),n=e.i(30030),r=e.i(820783),a=e.i(843476);function i(e){var n;let i,s=(n=e,(i=t.forwardRef((e,n)=>{let{children:a,...i}=e;if(t.isValidElement(a)){var s;let e,l,o=(s=a,(l=(e=Object.getOwnPropertyDescriptor(s.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.ref:(l=(e=Object.getOwnPropertyDescriptor(s,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?s.props.ref:s.props.ref||s.ref),c=function(e,t){let n={...t};for(let r in t){let a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...e)=>{let t=i(...e);return a(...e),t}:a&&(n[r]=a):"style"===r?n[r]={...a,...i}:"className"===r&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}(i,a.props);return a.type!==t.Fragment&&(c.ref=n?(0,r.composeRefs)(n,o):o),t.cloneElement(a,c)}return t.Children.count(a)>1?t.Children.only(null):null})).displayName=`${n}.SlotClone`,i),o=t.forwardRef((e,n)=>{let{children:r,...i}=e,o=t.Children.toArray(r),c=o.find(l);if(c){let e=c.props.children,r=o.map(n=>n!==c?n:t.Children.count(e)>1?t.Children.only(null):t.isValidElement(e)?e.props.children:null);return(0,a.jsx)(s,{...i,ref:n,children:t.isValidElement(e)?t.cloneElement(e,void 0,r):null})}return(0,a.jsx)(s,{...i,ref:n,children:r})});return o.displayName=`${e}.Slot`,o}var s=Symbol("radix.slottable");function l(e){return t.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===s}e.s(["createCollection",0,function(e){let s=e+"CollectionProvider",[l,o]=(0,n.createContextScope)(s),[c,d]=l(s,{collectionRef:{current:null},itemMap:new Map}),u=e=>{let{scope:n,children:r}=e,i=t.default.useRef(null),s=t.default.useRef(new Map).current;return(0,a.jsx)(c,{scope:n,itemMap:s,collectionRef:i,children:r})};u.displayName=s;let p=e+"CollectionSlot",f=i(p),h=t.default.forwardRef((e,t)=>{let{scope:n,children:i}=e,s=d(p,n),l=(0,r.useComposedRefs)(t,s.collectionRef);return(0,a.jsx)(f,{ref:l,children:i})});h.displayName=p;let m=e+"CollectionItemSlot",b="data-radix-collection-item",g=i(m),v=t.default.forwardRef((e,n)=>{let{scope:i,children:s,...l}=e,o=t.default.useRef(null),c=(0,r.useComposedRefs)(n,o),u=d(m,i);return t.default.useEffect(()=>(u.itemMap.set(o,{ref:o,...l}),()=>void u.itemMap.delete(o))),(0,a.jsx)(g,{...{[b]:""},ref:c,children:s})});return v.displayName=m,[{Provider:u,Slot:h,ItemSlot:v},function(n){let r=d(e+"CollectionConsumer",n);return t.default.useCallback(()=>{let e=r.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${b}]`));return Array.from(r.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[r.collectionRef,r.itemMap])},o]}],75830)},586318,e=>{"use strict";var t=e.i(271645),n=e.i(843476),r=t.createContext(void 0);e.s(["DirectionProvider",0,e=>{let{dir:t,children:a}=e;return(0,n.jsx)(r.Provider,{value:t,children:a})},"useDirection",0,function(e){let n=t.useContext(r);return e||n||"ltr"}])},999682,e=>{"use strict";var t=e.i(271645);e.s(["usePrevious",0,function(e){let n=t.useRef({value:e,previous:e});return t.useMemo(()=>(n.current.value!==e&&(n.current.previous=n.current.value,n.current.value=e),n.current.previous),[e])}])},635804,e=>{"use strict";var t=e.i(271645),n=e.i(934620);e.s(["useSize",0,function(e){let[r,a]=t.useState(void 0);return(0,n.useLayoutEffect)(()=>{if(e){a({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{let n,r;if(!Array.isArray(t)||!t.length)return;let i=t[0];if("borderBoxSize"in i){let e=i.borderBoxSize,t=Array.isArray(e)?e[0]:e;n=t.inlineSize,r=t.blockSize}else n=e.offsetWidth,r=e.offsetHeight;a({width:n,height:r})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}a(void 0)},[e]),r}])},959411,e=>{"use strict";var t=e.i(271645),n=e.i(248425),r=e.i(843476),a=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),i=t.forwardRef((e,t)=>
1(0,r.jsx)(n.Primitive.span,{...e,ref:t,style:{...a,...e.style}}));i.displayName="VisuallyHidden",e.s(["Root",0,i,"VISUALLY_HIDDEN_STYLES",0,a])},207670,e=>{"use strict";function t(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=function e(t){var n,r,a="";if("string"==typeof t||"number"==typeof t)a+=t;else if("object"==typeof t)if(Array.isArray(t)){var i=t.length;for(n=0;n<i;n++)t[n]&&(r=e(t[n]))&&(a&&(a+=" "),a+=r)}else for(r in t)t[r]&&(a&&(a+=" "),a+=r);return a}(e))&&(r&&(r+=" "),r+=t);return r}e.s(["clsx",0,t,"default",0,t])},425063,e=>{"use strict";let t=(0,e.i(475254).default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);e.s(["ArrowDown",0,t],425063)},975558,e=>{"use strict";let t=(0,e.i(475254).default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);e.s(["ArrowUp",0,t],975558)},678784,e=>{"use strict";var t=e.i(678745);e.s(["CheckIcon",()=>t.default])},399219,e=>{"use strict";let t=(0,e.i(475254).default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);e.s(["default",0,t])},299023,e=>{"use strict";let t=(0,e.i(475254).default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);e.s(["Minus",0,t],299023)},107233,e=>{"use strict";let t=(0,e.i(475254).default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);e.s(["Plus",0,t],107233)},16715,e=>{"use strict";let t=(0,e.i(475254).default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);e.s(["RefreshCw",0,t],16715)},559084,e=>{"use strict";var t=e.i(247167),n=e.i(843476),r=e.i(271645),a=e.i(519455);let i=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,s=["legacy","pending","sending","sent","failed","uncertain"],l=["SEND_REJECTED","SEND_FAILED","SEND_UNCERTAIN","STATUS_UNAVAILABLE"],o=["pending","creating","waiting_profile","ready","failed","uncertain"],c=["NOT_APPROVED","ACCOUNT_NOT_READY","LEGACY_REQUEST_PENDING","ACCOUNT_ALREADY_CONNECTED","LINK_UNAVAILABLE"];class d extends Error{status;uncertain;constructor(e=503,t=!1){super("The pupil invitations could not be checked."),this.status=e,this.uncertain=t}}function u(){throw new d}function p(e){return(!e||"object"!=typeof e||Array.isArray(e))&&u(),e}function f(e){return"string"==typeof e&&36===e.length&&i.test(e)||u(),e}function h(e,t){return("string"!=typeof e||!e.length||e.length>t||e.trim()!==e||/[\u0000-\u001f\u007f-\u009f]/.test(e))&&u(),e}function m(e,t){let n=p(e);return(n.schoolId!==t.schoolId||n.classId!==t.classId)&&u(),n}function b(e){let t=p(e);return(!s.includes(t.status)||null!==t.errorCode&&!l.includes(t.errorCode)||"boolean"!=typeof t.revoked||"boolean"!=typeof t.used||"boolean"!=typeof t.canDispatch||"boolean"!=typeof t.canCancel||"string"!=typeof t.expiresAt||t.expiresAt.length>40||!Number.isFinite(Date.parse(t.expiresAt))||t.canDispatch&&("pending"!==t.status||t.revoked||t.used)||t.revoked&&t.used||t.canCancel&&(t.revoked||t.used)||["legacy","sent","pending","sending"].includes(t.status)&&null!==t.errorCode||["failed","uncertain"].includes(t.status)&&null===t.errorCode)&&u(),{operationId:f(t.operationId),status:t.status,errorCode:t.errorCode,revoked:t.revoked,used:t.used,expiresAt:t.expiresAt,canDispatch:t.canDispatch,canCancel:t.canCancel}}function g(e){let t=p(e);return!1!==t.needsReplacement&&u(),{...b(t),entryId:f(t.entryId),needsReplacement:!1}}function v(e,t){let n=m(e,t);(!Array.isArray(n.pupils)||n.pupils.length>200)&&u();let r=new Set,a=new Set,i=n.pupils.map(e=>{let t=p(e),n=f(t.entryId);!r.has(n)&&"boolean"==typeof t.canSend&&(null===t.issue||c.includes(t.issue))&&(null===t.preparationStatus||o.includes(t.preparationStatus))||u(),r.add(n);let i=null===t.schoolEmail?null:h(t.schoolEmail,254);t.canSend&&("ready"!==t.preparationStatus||!i||null!==t.issue)&&u();let s=null;if(null!==t.latestLink){let e=p(t.latestLink),r=b(e);(a.has(r.operationId)||void 0!==e.entryId&&e.entryId!==n)&&u(),a.add(r.operationId),s={...r,sendId:null===e.sendId?null:f(e.sendId)}}return{entryId:n,schoolDisplayName:h(t.schoolDisplayName,254),schoolEmail:i,preparationStatus:t.preparationStatus,canSend:t.canSe
1nd,issue:t.issue,latestLink:s}});return{...t,pupils:i}}function y(e,t,n,r){let a=m(e,t);a.sendId===n&&Array.isArray(a.results)&&a.results.length&&!(a.results.length>200)||u();let i=a.results.map(g);return(new Set(i.map(e=>e.entryId)).size!==i.length||new Set(i.map(e=>e.operationId)).size!==i.length||i.some(e=>"legacy"===e.status)||r&&(i.length!==r.length||i.some(e=>!r.some(t=>t.entryId===e.entryId))))&&u(),{...t,sendId:n,results:i}}async function x(e,t){(Number(e.headers.get("content-length"))>524288||!e.body)&&(e.body?.cancel().catch(()=>{}),u());let n=e.body.getReader(),r=()=>{n.cancel().catch(()=>{})};t.addEventListener("abort",r,{once:!0});let a=0,i="",s=new TextDecoder;try{for(;;){t.aborted&&u();let e=await n.read();if(t.aborted&&u(),e.done)return i+s.decode();(a+=e.value.byteLength)>524288&&(r(),u()),i+=s.decode(e.value,{stream:!0})}}finally{t.removeEventListener("abort",r),n.releaseLock()}}let w=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,k=[2e3,3e3,5e3,1e4,15e3,15e3,15e3,15e3];function I(e){return!e.revoked&&!e.used&&Date.parse(e.expiresAt)>Date.now()&&["pending","sending","uncertain"].includes(e.status)}function C(e){return I(e)&&["sending","uncertain"].includes(e.status)}function N({identity:e,getToken:i,scope:s,audience:l="teacher",disabled:o=!1,onAccessLost:c,onRefreshBlockedChange:p,onLeavingChange:h,onListChanged:b}){let S=(0,r.useRef)({getToken:i,onAccessLost:c,onRefreshBlockedChange:p,onLeavingChange:h,onListChanged:b});S.current={getToken:i,onAccessLost:c,onRefreshBlockedChange:p,onLeavingChange:h,onListChanged:b};let j=(0,r.useRef)(o);j.current=o;let{userId:E,sessionId:A}=e,L=(0,r.useMemo)(()=>(function(e,n,r="teacher"){let a={...e},i="teacher"===r?"b2b-pupil-invitations":"staff"===r?"b2b-school-invitations":u();async function s(e,r,s,l){let o,c={schoolId:f(e.schoolId),classId:f(e.classId)},p=!["list","readSend"].includes(r.action);"1"===t.default.env.NEXT_PUBLIC_B2B_LOCAL_TEST&&u();let h=new AbortController,m=()=>h.abort(),b=!1,g=()=>new d(503,p&&b);s.addEventListener("abort",m,{once:!0}),s.aborted&&m();let v=setTimeout(m,9e4),y=new Promise((e,t)=>{o=()=>t(g()),h.signal.addEventListener("abort",o,{once:!0}),h.signal.aborted&&o()});try{return await Promise.race([y,(async()=>{if(h.signal.aborted)throw g();let e=await n();if(h.signal.aborted)throw g();if(!e||!function(e,t){try{if(!/^user_[A-Za-z0-9]+$/.test(t.userId)||!/^sess_[A-Za-z0-9]+$/.test(t.sessionId))return!1;let n=e.split(".");if(e.length>8192||3!==n.length||!/^[A-Za-z0-9_-]+$/.test(n[1]))return!1;let r=JSON.parse(atob(n[1].replace(/-/g,"+").replace(/_/g,"/")));return r.sub===t.userId&&r.sid===t.sessionId}catch{return!1}}(e,a))throw new d(401);let t=p?"":`?${new URLSearchParams({...c,..."readSend"===r.action?{sendId:r.sendId}:{}})}`;b=!0;let s=await fetch(`https://mathangel-website-backend.azurewebsites.net/api/${i}${t}`,{method:p?"POST":"GET",headers:{Authorization:`Bearer ${e}`,...p?{"Content-Type":"application/json"}:{}},...p?{body:JSON.stringify({...c,...r})}:{},credentials:"omit",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",signal:h.signal});if(h.signal.aborted)throw s.body?.cancel().catch(()=>{}),g();if(!s.ok)throw s.body?.cancel().catch(()=>{}),new d(s.status,p&&s.status>=500);let o=await x(s,h.signal);if(h.signal.aborted)throw g();return l(JSON.parse(o),c)})()])}catch(e){if(e instanceof d&&(503!==e.status||e.uncertain))throw e;throw g()}finally{clearTimeout(v),s.removeEventListener("abort",m),h.signal.removeEventListener("abort",o),h.abort()}}return{list:(e,t)=>s(e,{action:"list"},t,v),readSend:(e,t,n)=>{let r=f(t);return s(e,{action:"readSend",sendId:r},n,(e,t)=>y(e,t,r))},send:(e,t,n,r)=>{let a=f(t);Array.isArray(n)&&n.length&&!(n.length>200)||u();let i=n.map(e=>({entryId:f(e.entryId),previousLinkId:null===e.previousLinkId?null:f(e.previousLinkId)}));return new Set(i.map(e=>e.entryId)).size!==i.length&&u(),s(e,{action:"send",sendId:a,selections:i},r,(e,t)=>y(e,t,a,i))},dispatch:(e,t,n)=>l(e,"dispatch",t,n),recover:(e,t,n)=>
1l(e,"recover",t,n),cancel:(e,t,n)=>l(e,"cancel",t,n)};function l(e,t,n,r){let a=f(n);return s(e,{action:t,operationId:a},r,(e,n)=>{let r,i=((r=g(m(e,n).result)).operationId!==a&&u(),{...n,result:r});return"cancel"!==t||i.result.revoked||u(),i})}})({userId:E,sessionId:A},()=>S.current.getToken(),l),[E,A,l]),R=(0,r.useMemo)(()=>({schoolId:s.schoolId,classId:s.classId}),[s.schoolId,s.classId]),T=`b2b-invitation-send:${l}:${E}:${A}:${s.schoolId}:${s.classId}`,[_,D]=(0,r.useState)(null),[z,O]=(0,r.useState)([]),[$,B]=(0,r.useState)(null),[P,M]=(0,r.useState)(null),[W,V]=(0,r.useState)(null),[U,H]=(0,r.useState)(""),[F,Y]=(0,r.useState)(!1),[q,G]=(0,r.useState)(!1),[Z,J]=(0,r.useState)(!1),K=(0,r.useRef)(o),Q=(0,r.useRef)(!0),X=(0,r.useRef)(!1),ee=(0,r.useRef)(!1),et=(0,r.useRef)(null),en=(0,r.useRef)(null),er=(0,r.useRef)(null),ea=F||!!P||!!W;function ei(e){en.current=e,M(e);try{e?sessionStorage.setItem(T,e):sessionStorage.removeItem(T)}catch{}}function es(e){er.current=e,B(e),e.results.some(I)||ei(null)}function el(e){D(t=>t&&{...t,pupils:t.pupils.map(t=>t.entryId!==e.entryId?t:{...t,latestLink:{...e,sendId:t.latestLink?.sendId??en.current}})}),er.current?.results.some(t=>t.operationId===e.operationId)&&es({...er.current,results:er.current.results.map(t=>t.operationId===e.operationId?e:t)})}function eo(e,t){if(e instanceof d&&[401,403].includes(e.status)){G(!0),D(null),O([]),B(null),er.current=null,S.current.onAccessLost(e.status);return}e instanceof d&&409===e.status&&J(!0),H(e instanceof d&&409===e.status?"The class list or invitation changed. Reload the list before sending again.":t)}async function ec(e){let t=await L.list(R,e);if(!e.aborted)return D(t),O([]),J(!1),t}async function ed(e){if(ee.current||q)return;ee.current=!0,Y(!0),H("");let t=new AbortController;et.current=t;try{await e(t.signal)}catch(e){t.signal.aborted||eo(e,"We could not finish checking these invitations.")}finally{t.signal.aborted||(ee.current=!1,Y(!1))}}async function eu(e){await ec(e),e.aborted||en.current||S.current.onListChanged?.()}async function ep(e,t){let n=e,r=new AbortController,a=()=>r.abort();t.addEventListener("abort",a,{once:!0}),t.aborted&&a();let i=setTimeout(a,9e4);try{for(let e of k){if(r.signal.aborted||!n.some(C))break;for(let t of(H("Waiting for the email service. Invitation results update automatically."),await function(e,t){return new Promise(n=>{let r=()=>{clearTimeout(a),t.removeEventListener("abort",r),n()},a=setTimeout(r,e);t.addEventListener("abort",r,{once:!0}),t.aborted&&r()})}(e,r.signal),n)){if(r.signal.aborted)return n;if(!C(t))continue;let{result:e}=await L.recover(R,t.operationId,r.signal);if(r.signal.aborted)return n;if(e.entryId!==t.entryId)throw new d(503,!0);el(e),n=n.map(t=>t.operationId===e.operationId?e:t)}}}catch(e){if(!r.signal.aborted)throw e}finally{clearTimeout(i),t.removeEventListener("abort",a),r.abort()}return n}function ef(e){return e.some(C)?"Some email results are still not known. Check again shortly; the same invitations will be checked.":e.some(I)?"Some invitations still need attention.":e.some(e=>"failed"===e.status&&!e.revoked&&!e.used)?"Some emails could not be sent. See the result beside each pupil.":"The selected invitations have been processed."}async function eh(e,t){es(e);let n=[];for(let r of e.results){if(t.aborted)return;let e=r;if(I(r)&&"pending"===r.status&&r.canDispatch&&!j.current)try{e=(await L.dispatch(R,r.operationId,t)).result}catch(e){if(t.aborted)return;eo(e,"We could not confirm one email. Continue below to check the saved invitations.");return}if(t.aborted)return;if(e.entryId!==r.entryId)throw new d(503,!0);el(e),n.push(e)}let r=await ep(n,t);!t.aborted&&(es({...e,results:r}),H(ef(r)),en.current||await eu(t))}if((0,r.useEffect)(()=>{S.current.onRefreshBlockedChange?.(ea),S.current.onLeavingChange?.({dirty:!1,blocked:ea})},[ea]),(0,r.useEffect)(()=>()=>{et.current?.abort(),ee.current=!1,X.current=!1,Q.current=!0,S.current.onRefreshBlockedChange?.(!1),S.current.onLeavingChange?.({dirty:!1,blocked:!1})},[]),(0,r.useEffect)(()=>{try{let e=sessionStorage.getItem(T);e&&w.test(e)?ei(e):e&&sessionStorage.removeItem(T)}catch{}},[L,R,T]),(0,r.useEffect)(()=>
1{if(K.current&&!o&&(Q.current=!0),K.current=o,o||!Q.current||ee.current||X.current&&en.current||W||q)return;Q.current=!1;let e=!X.current;X.current=!0,ed(async t=>{let n=e?en.current:null;try{if(await ec(t),t.aborted||!n)return;let e=await L.readSend(R,n,t);if(t.aborted)return;es(e),H(e.results.some(I)?"An earlier send is unfinished. Continue with the same invitations below.":"The earlier send has been checked.")}catch(e){t.aborted||eo(e,n?"We could not confirm the earlier send. Check its saved result before sending new links.":"We could not load pupil invitations.")}})},[o,F,W,q]),q)return null;let em=_?.pupils.filter(e=>e.canSend)??[],eb=F||!!P||!!W||Z;return(0,n.jsxs)("section",{"aria-label":"Pupil invitations",className:"ph-no-capture space-y-4 rounded-lg border border-slate-200 p-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"font-semibold",children:"Invite pupils"}),(0,n.jsx)("p",{className:"text-sm text-slate-600",children:"Choose pupils and send an invitation to each school email below. The teacher must approve the class list and the pupil accounts must be ready first."}),(0,n.jsx)("p",{className:"mt-1 text-sm text-slate-600",children:"A replacement cancels the pupilâs previous unused link. Cancelling a link keeps the pupil account and any existing class connection."})]}),o&&(0,n.jsx)("p",{className:"text-sm text-slate-600",children:"Finish the class-list changes or account preparation before sending or cancelling invitations."}),F&&(0,n.jsx)("p",{role:"status",className:"text-sm",children:"Checking or sending invitationsâ¦"}),U&&(0,n.jsx)("p",{role:"status",className:"text-sm text-slate-700",children:U}),P&&!F&&!W&&(0,n.jsx)(a.Button,{variant:"outline",onClick:function(){let e=en.current;e&&!W&&ed(async t=>{let n=await L.readSend(R,e,t);t.aborted||await eh(n,t)})},children:o||$&&!$.results.some(e=>I(e)&&e.canDispatch)?"Check email status":"Continue sending"}),W&&!F&&(0,n.jsx)(a.Button,{variant:"outline",onClick:function(){ed(async e=>{let t=await ec(e);if(!t||e.aborted)return;let n=t.pupils.map(e=>e.latestLink).find(e=>e?.operationId===W);if(en.current){let t=await L.readSend(R,en.current,e);if(e.aborted)return;es(t),n=t.results.find(e=>e.operationId===W)}!n||n.revoked||n.used?(V(null),H("The link status has been checked."),S.current.onListChanged?.()):H("The cancellation is not yet confirmed. Check the link status again shortly.")})},children:"Check link status"}),_&&(0,n.jsxs)(n.Fragment,{children:[0===_.pupils.length?(0,n.jsx)("p",{className:"text-sm text-slate-600",children:"No pupils are waiting for an invitation."}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,n.jsx)("input",{type:"checkbox","aria-label":"Select all ready pupils",disabled:o||eb||0===em.length,checked:em.length>0&&z.length===em.length,onChange:e=>O(e.target.checked?em.map(e=>e.entryId):[])}),"Select all ready pupils"]}),(0,n.jsx)("ul",{className:"divide-y divide-slate-200 rounded-md border border-slate-200",children:_.pupils.map(e=>{let t=$?.results.find(t=>t.entryId===e.entryId)??e.latestLink;return(0,n.jsxs)("li",{className:"space-y-2 p-3",children:[(0,n.jsxs)("label",{className:"flex items-start gap-3",children:[(0,n.jsx)("input",{type:"checkbox",className:"mt-1","aria-label":`Select ${e.schoolDisplayName}`,disabled:o||eb||!e.canSend,checked:z.includes(e.entryId),onChange:t=>O(n=>t.target.checked?[...n,e.entryId]:n.filter(t=>t!==e.entryId))}),(0,n.jsxs)("span",{className:"min-w-0",children:[(0,n.jsx)("span",{className:"block break-words font-medium",children:e.schoolDisplayName}),(0,n.jsx)("span",{className:"block break-all text-sm text-slate-600",children:e.schoolEmail??"No school email saved"})]})]}),(0,n.jsx)("p",{className:"text-sm text-slate-700",children:t?t.used?"Invitation accepted":t.revoked?"Link cancelled":Date.parse(t.expiresAt)<=Date.now()?"Link expired":"sent"===t.status?"Email sent":"pending"===t.status?"Ready to send":"sending"===t.status?"Waiting for the email result":"uncertain"===t.status?"Email status is not yet known":"failed"===t.status?"Email could not be sent":"Existing joining link":"No invitation sent"}),!e.canSend&&(0,n.jsx)("p",{className:"text-sm text-slate-600",children:e.schoolEmail?"NOT_APPROVED"===e.issue?"The class list needs approval or account preparation.":"LEGACY_REQUEST_PENDING"===e.issue?"An earlier joining request needs attention.":"ACCOUNT_ALREADY_CONNECTED"===e.issue?"This pupil is already connected.":"LINK_UNAVAILABLE"===e.issue?"The existing link needs attention.":"The approved pupil account is not ready yet.":"Add the school email to the class list first."}
1),e.canSend&&e.latestLink&&!e.latestLink.revoked&&!e.latestLink.used&&(0,n.jsx)("p",{className:"text-sm text-slate-600",children:"Selecting this pupil sends a replacement and cancels the previous unused link."}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[!P&&e.latestLink&&I(e.latestLink)&&(0,n.jsx)(a.Button,{variant:"outline",size:"sm",disabled:eb||o&&e.latestLink.canDispatch,onClick:()=>{let t;(t=e.latestLink)&&(!t.canDispatch||!o)&&!en.current&&!W&&ed(async n=>{if("pending"===t.status&&t.canDispatch&&t.sendId){ei(t.sendId);let e=await L.readSend(R,t.sendId,n);n.aborted||await eh(e,n)}else{let r=await ep([{...t,entryId:e.entryId,needsReplacement:!1}],n);if(n.aborted)return;H(ef(r)),await eu(n)}})},children:e.latestLink.canDispatch?"Continue sending":"Check email status"}),t?.canCancel&&(0,n.jsx)(a.Button,{variant:"outline",size:"sm",disabled:o||F||!!W,onClick:()=>{!o&&t?.canCancel&&!W&&ed(async n=>{V(t.operationId);try{let r=await L.cancel(R,t.operationId,n);if(n.aborted)return;if(r.result.entryId!==e.entryId)throw new d(503,!0);el(r.result),V(null),H("The invitation link is cancelled. The pupil account is unchanged."),await eu(n)}catch(e){if(n.aborted)return;e instanceof d&&!e.uncertain&&V(null),eo(e,"We could not confirm the cancellation. Check the link status before making another change.")}})},children:"Cancel link"})]})]},e.entryId)})}),(0,n.jsx)(a.Button,{disabled:o||eb||0===z.length,onClick:function(){if(o||Z||en.current||W||!_||0===z.length)return;let e=_.pupils.filter(e=>z.includes(e.entryId)&&e.canSend).map(e=>({entryId:e.entryId,previousLinkId:e.latestLink?.operationId??null}));e.length===z.length&&ed(async t=>{let n,r=crypto.randomUUID();ei(r),O([]);try{n=await L.send(R,r,e,t)}catch(e){if(e instanceof d&&!e.uncertain)if(t.aborted)try{sessionStorage.getItem(T)===r&&sessionStorage.removeItem(T)}catch{}else ei(null);if(t.aborted)return;eo(e,"We could not confirm that the send was saved. Continue below to check the same invitations.");return}t.aborted||await eh(n,t)})},children:"Send links"})]}),(0,n.jsx)("p",{className:"text-xs text-slate-500",children:"âEmail sentâ means the email service accepted the invitation. It does not confirm that the email reached the pupilâs inbox."})]}),!F&&!P&&!W&&(0,n.jsx)(a.Button,{disabled:o,variant:"outline",onClick:()=>{o||ed(async e=>{await ec(e),B(null),er.current=null})},children:"Reload invitations"})]})}e.s(["B2bPupilInvitations",0,function(e){return"1"===t.default.env.NEXT_PUBLIC_B2B_LOCAL_TEST?null:(0,n.jsx)(N,{...e},`${e.audience??"teacher"}:${e.identity.userId}:${e.identity.sessionId}:${e.scope.schoolId}:${e.scope.classId}`)}],559084)},582733,e=>{"use strict";var t=e.i(843476),n=e.i(271645);e.s(["StepsReveal",0,function({children:e,tail:r}
1){let a=n.Children.toArray(e),i=a.length,[s,l]=(0,n.useState)(i);(0,n.useEffect)(()=>{i>1&&l(1)},[i]);let o=s>=i;return(0,t.jsxs)("div",{className:"my-6",children:[(0,t.jsx)("ol",{className:"relative",children:a.map((e,n)=>{let r=n<s;return(0,t.jsxs)("li",{className:r?"relative pl-14 pb-8 last:pb-0":"hidden",children:[n<s-1&&(0,t.jsx)("span",{"aria-hidden":!0,className:"absolute left-[17px] top-9 bottom-0 w-px bg-indigo-200"}),(0,t.jsx)("span",{"aria-hidden":!0,className:"absolute left-0 top-0 flex h-9 w-9 items-center justify-center rounded-full bg-indigo-100 text-sm font-bold text-indigo-700 ring-4 ring-[#f9fafb]",children:n+1}),e]},n)})}),!o&&(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-3 pl-14",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>l(e=>Math.min(i,e+1)),className:"inline-flex items-center gap-2 rounded-full border border-indigo-200 px-5 py-2 text-sm font-semibold text-indigo-700 transition-colors hover:border-indigo-300 hover:bg-indigo-50",children:["Next step",(0,t.jsx)("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"h-4 w-4",children:(0,t.jsx)("path",{d:"m5 7.5 5 5 5-5"})})]}),(0,t.jsxs)("span",{className:"text-xs font-medium tabular-nums text-gray-400",children:[s," of ",i]})]}),r&&o&&(0,t.jsx)("div",{className:"mt-10",children:r})]})}])},487486,e=>{"use strict";var t=e.i(843476),n=e.i(991918),r=e.i(225913),a=e.i(819204);let i=(0,r.cva)("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});e.s(["Badge",0,function({className:e,variant:r,asChild:s=!1,...l}){let o=s?n.Slot:"span";return(0,t.jsx)(o,{"data-slot":"badge",className:(0,a.cn)(i({variant:r}),e),...l})}])},519455,991918,225913,e=>{"use strict";var t=e.i(843476),n=e.i(271645),r=e.i(820783),a=Symbol.for("react.lazy"),i=n[" use ".trim().toString()];function s(e){var t;return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===a&&"_payload"in e&&"object"==typeof(t=e._payload)&&null!==t&&"then"in t}function l(e){var a;let l,o=(a=e,(l=n.forwardRef((e,t)=>{let{children:a,...l}=e;if(s(a)&&"function"==typeof i&&(a=i(a._payload)),n.isValidElement(a)){var o;let e,i,s=(o=a,(i=(e=Object.getOwnPropertyDescriptor(o.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?o.ref:(i=(e=Object.getOwnPropertyDescriptor(o,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?o.props.ref:o.props.ref||o.ref),c=function(e,t){let n={...t};for(let r in t){let a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...e)=>{let t=i(...e);return a(...e),t}:a&&(n[r]=a):"style"===r?n[r]={...a,...i}:"className"===r&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}(l,a.props);return a.type!==n.Fragment&&(c.ref=t?(0,r.composeRefs)(t,s):s),n.cloneElement(a,c)}return n.Children.count(a)>1?n.Children.only(null):null})).displayName=`${a}.SlotClone`,l),c=n.forwardRef((e,r)=>{let{children:a,...l}=e;s(a)&&"function"==typeof i&&(a=i(a._payload));let c=n.Children.toArray(a),u=c.find(d);if(u){let e=u.props.children,a=c.map(t=>t!==u?t:n.Children.count(e)>1?n.Children.only(null):n.isValidElement(e)?e.props.children:null);return(0,t.jsx)(o,{...l,ref:r,children:n.isValidElement(e)?n.cloneElement(e,void 0,a):null})}return(0,t.jsx)(o,{...l,ref:r,children:a})});return c.displayName=`${e}.Slot`,c}var o=l("Slot"),c=Symbol("radix.slottable");function d(e){return n.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===c}e.s(["Slot",0,o,"createSlot",0,l],991918);var u=e.i(207670);let p=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,f=u.clsx,h=(e,t)=>n=>{var r;if((null==t?void 0:t.variants)==null)return f(e,null==n?void 0:n.class,null==n?void 0:n.className);let{variants:a,defaultVariants:i}=t,s=Object.keys(a).map(e=>{let t=null==n?void 0:n[e],r=null==i?void 0:i[e];if(null===t)return null;let s=p(t)||p(r);return a[e][s]}),l=n&&Object.entries(n).reduce((e,t)=>
1{let[n,r]=t;return void 0===r||(e[n]=r),e},{});return f(e,s,null==t||null==(r=t.compoundVariants)?void 0:r.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...l}[t]):({...i,...l})[t]===n})?[...e,n,r]:e},[]),null==n?void 0:n.class,null==n?void 0:n.className)};e.s(["cva",0,h],225913);var m=e.i(819204);let b=h("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background text-foreground hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9 rounded-md"}},defaultVariants:{variant:"default",size:"default"}});e.s(["Button",0,function({className:e,variant:n,size:r,asChild:a=!1,...i}){return(0,t.jsx)(a?o:"button",{"data-slot":"button",className:(0,m.cn)(b({variant:n,size:r,className:e})),...i})},"buttonVariants",0,b],519455)},515288,e=>{"use strict";var t=e.i(843476),n=e.i(819204);e.s(["Card",0,function({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"card",className:(0,n.cn)("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",e),...r})},"CardContent",0,function({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,n.cn)("px-6 [&:last-child]:pb-6",e),...r})},"CardDescription",0,function({className:e,...r}){return(0,t.jsx)("p",{"data-slot":"card-description",className:(0,n.cn)("text-muted-foreground",e),...r})},"CardHeader",0,function({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,n.cn)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...r})}])},793479,e=>{"use strict";var t=e.i(843476),n=e.i(819204);e.s(["Input",0,function({className:e,type:r,...a}){return(0,t.jsx)("input",{type:r,"data-slot":"input",className:(0,n.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base bg-input-background transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...a})}])},784774,e=>{"use strict";var t=e.i(843476),n=e.i(819204);e.s(["Table",0,function({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,t.jsx)("table",{"data-slot":"table",className:(0,n.cn)("w-full caption-bottom text-sm",e),...r})})},"TableBody",0,function({className:e,...r}){return(0,t.jsx)("tbody",{"data-slot":"table-body",className:(0,n.cn)("[&_tr:last-child]:border-0",e),...r})},"TableCell",0,function({className:e,...r}){return(0,t.jsx)("td",{"data-slot":"table-cell",className:(0,n.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})},"TableHead",0,function({className:e,...r}){return(0,t.jsx)("th",{"data-slot":"table-head",className:(0,n.cn)("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})},"TableHeader",0,function({className:e,...r}){return(0,t.jsx)("thead",{"data-slot":"table-header",className:(0,n.cn)("[&_tr]:border-b",e),...r})},"TableRow",0,function({className:e,...r}){return(0,t.jsx)("tr",{"data-slot":"table-row",className:(0,n.cn)("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...r})}])},957495,e=>{"use strict";e.s(["normalizeB2bSchoolEmail",0,function(e){if(null==e||""===e)return null;if("string"!=typeof e||/[^\x20-\x7e]/.test(e))throw Error("Check the school email.");let t=e.trim().toLowerCase(),n=t.split("@");if(t.length>254||2!==n.length||n[0].length>64||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/.test(t)||n[0].startsWith(".")||n[0].endsWith(".")||n[0].includes("..")||n[1].split(".").some(e=>e.length>63))throw Error("Check the school email.");return t}])}]);
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.