@simoncomputing/mui-bueno-v2 0.25.12 → 0.25.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
- Minor increment --> singlular/minor changes. Minimal breaking changes.
|
|
12
12
|
- Patch increment --> singlular/minor changes. Zero breaking changes.
|
|
13
13
|
|
|
14
|
+
## [0.25.13] - 2026-02-20
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- `DiffTable`, `DiffCitationTable`
|
|
19
|
+
- Fixed deletions being labeled as additions
|
|
20
|
+
|
|
14
21
|
## [0.25.12] - 2026-02-19
|
|
15
22
|
|
|
16
23
|
### Added
|
package/dist/index.cjs.js
CHANGED
|
@@ -404,4 +404,4 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
|
|
|
404
404
|
3. "-" cannot repeat`);Wt.customSchemes.push([t,e])}function Lce(){Wt.scanner=_ce(Wt.customSchemes);for(let t=0;t<Wt.tokenQueue.length;t++)Wt.tokenQueue[t][1]({scanner:Wt.scanner});Wt.parser=Dce(Wt.scanner.tokens);for(let t=0;t<Wt.pluginQueue.length;t++)Wt.pluginQueue[t][1]({scanner:Wt.scanner,parser:Wt.parser});return Wt.initialized=!0,Wt}function wx(t){return Wt.initialized||Lce(),Ace(Wt.parser.start,t,jD(Wt.scanner.start,t))}wx.scan=jD;function FD(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new xx(n),o=wx(t),i=[];for(let s=0;s<o.length;s++){const a=o[s];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}const Sx="[\0- -\u2029 ]",jce=new RegExp(Sx),Bce=new RegExp(`${Sx}$`),Fce=new RegExp(Sx,"g");function Vce(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function zce(t){return new rn({key:new On("autolink"),appendTransaction:(e,n,r)=>{const o=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),i=e.some(u=>u.getMeta("preventAutolink"));if(!o||i)return;const{tr:s}=r,a=s7(n.doc,[...e]);if(f7(a).forEach(({newRange:u})=>{const f=l7(r.doc,u,g=>g.isTextblock);let p,m;if(f.length>1)p=f[0],m=r.doc.textBetween(p.pos,p.pos+p.node.nodeSize,void 0," ");else if(f.length){const g=r.doc.textBetween(u.from,u.to," "," ");if(!Bce.test(g))return;p=f[0],m=r.doc.textBetween(p.pos,u.to,void 0," ")}if(p&&m){const g=m.split(jce).filter(Boolean);if(g.length<=0)return!1;const v=g[g.length-1],y=p.pos+m.lastIndexOf(v);if(!v)return!1;const x=wx(v).map(S=>S.toObject(t.defaultProtocol));if(!Vce(x))return!1;x.filter(S=>S.isLink).map(S=>({...S,from:y+S.start+1,to:y+S.end+1})).filter(S=>r.schema.marks.code?!r.doc.rangeHasMark(S.from,S.to,r.schema.marks.code):!0).filter(S=>t.validate(S.value)).filter(S=>t.shouldAutoLink(S.value)).forEach(S=>{ov(S.from,S.to,r.doc).some(k=>k.mark.type===t.type)||s.addMark(S.from,S.to,t.type.create({href:S.href}))})}}),!!s.steps.length)return s}})}function Hce(t){return new rn({key:new On("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let s=r.target;const a=[];for(;s.nodeName!=="DIV";)a.push(s),s=s.parentNode;if(!a.find(m=>m.nodeName==="A"))return!1;const l=rv(e.state,t.type.name),u=r.target,f=(o=u==null?void 0:u.href)!==null&&o!==void 0?o:l.href,p=(i=u==null?void 0:u.target)!==null&&i!==void 0?i:l.target;return u&&f?(window.open(f,p),!0):!1}}})}function Wce(t){return new rn({key:new On("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:o}=e,{selection:i}=o,{empty:s}=i;if(s)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const l=FD(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!l?!1:t.editor.commands.setMark(t.type,{href:l.href})}}})}function qs(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace(Fce,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Uce=Or.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){VE(t);return}VE(t.scheme,t.optionalSlashes)})},onDestroy(){$ce()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!qs(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!qs(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!qs(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",St(this.options.HTMLAttributes,t),0]:["a",St(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!qs(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!qs(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Cs({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,o=FD(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!qs(s,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(zce({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!qs(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(Hce({type:this.type})),this.options.linkOnPaste&&t.push(Wce({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}});function qce(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:a}=t,l=r&&!o,u=K7(n),f=new RegExp(`\\s${u}$`),p=s?"^":"",m=o?"":u,g=l?new RegExp(`${p}${u}.*?(?=\\s${m}|$)`,"gm"):new RegExp(`${p}(?:^)?${u}[^\\s${m}]*`,"gm"),v=((e=a.nodeBefore)===null||e===void 0?void 0:e.isText)&&a.nodeBefore.text;if(!v)return null;const y=a.pos-v.length,x=Array.from(v.matchAll(g)).pop();if(!x||x.input===void 0||x.index===void 0)return null;const S=x.input.slice(Math.max(0,x.index-1),x.index),k=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(S);if(i!==null&&!k)return null;const T=y+x.index;let C=T+x[0].length;return l&&f.test(v.slice(C-1,C+1))&&(x[0]+=" ",C+=1),T<a.pos&&C>=a.pos?{range:{from:T,to:C},query:x[0].slice(n.length),text:x[0]}:null}const Kce=new On("suggestion");function Yce({pluginKey:t=Kce,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:u="",decorationEmptyClass:f="is-empty",command:p=()=>null,items:m=()=>[],render:g=()=>({}),allow:v=()=>!0,findSuggestionMatch:y=qce}){let x;const S=g==null?void 0:g(),k=new rn({key:t,view(){return{update:async(T,C)=>{var O,R,P,N,V,M,j;const F=(O=this.key)===null||O===void 0?void 0:O.getState(C),L=(R=this.key)===null||R===void 0?void 0:R.getState(T.state),A=F.active&&L.active&&F.range.from!==L.range.from,_=!F.active&&L.active,I=F.active&&!L.active,B=!_&&!I&&F.query!==L.query,W=_||A&&B,K=B||A,U=I||A&&B;if(!W&&!K&&!U)return;const Y=U&&!W?F:L,oe=T.dom.querySelector(`[data-decoration-id="${Y.decorationId}"]`);x={editor:e,range:Y.range,query:Y.query,text:Y.text,items:[],command:fe=>p({editor:e,range:Y.range,props:fe}),decorationNode:oe,clientRect:oe?()=>{var fe;const{decorationId:he}=(fe=this.key)===null||fe===void 0?void 0:fe.getState(e.state),G=T.dom.querySelector(`[data-decoration-id="${he}"]`);return(G==null?void 0:G.getBoundingClientRect())||null}:null},W&&((P=S==null?void 0:S.onBeforeStart)===null||P===void 0||P.call(S,x)),K&&((N=S==null?void 0:S.onBeforeUpdate)===null||N===void 0||N.call(S,x)),(K||W)&&(x.items=await m({editor:e,query:Y.query})),U&&((V=S==null?void 0:S.onExit)===null||V===void 0||V.call(S,x)),K&&((M=S==null?void 0:S.onUpdate)===null||M===void 0||M.call(S,x)),W&&((j=S==null?void 0:S.onStart)===null||j===void 0||j.call(S,x))},destroy:()=>{var T;x&&((T=S==null?void 0:S.onExit)===null||T===void 0||T.call(S,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(T,C,O,R){const{isEditable:P}=e,{composing:N}=e.view,{selection:V}=T,{empty:M,from:j}=V,F={...C};if(F.composing=N,P&&(M||e.view.composing)){(j<C.range.from||j>C.range.to)&&!N&&!C.composing&&(F.active=!1);const L=y({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:V.$from}),A=`id_${Math.floor(Math.random()*4294967295)}`;L&&v({editor:e,state:R,range:L.range,isActive:C.active})?(F.active=!0,F.decorationId=C.decorationId?C.decorationId:A,F.range=L.range,F.query=L.query,F.text=L.text):F.active=!1}else F.active=!1;return F.active||(F.decorationId=null,F.range={from:0,to:0},F.query=null,F.text=null),F}},props:{handleKeyDown(T,C){var O;const{active:R,range:P}=k.getState(T.state);return R&&((O=S==null?void 0:S.onKeyDown)===null||O===void 0?void 0:O.call(S,{view:T,event:C,range:P}))||!1},decorations(T){const{active:C,range:O,decorationId:R,query:P}=k.getState(T);if(!C)return null;const N=!(P!=null&&P.length),V=[l];return N&&V.push(f),Xt.create(T.doc,[Qn.inline(O.from,O.to,{nodeName:a,class:V.join(" "),"data-decoration-id":R,"data-decoration-content":u})])}}});return k}function Gce({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const o=new On;return{editor:t,char:r,pluginKey:o,command:({editor:i,range:s,props:a})=>{var l,u,f;const p=i.view.state.selection.$to.nodeAfter;((l=p==null?void 0:p.text)===null||l===void 0?void 0:l.startsWith(" "))&&(s.to+=1),i.chain().focus().insertContentAt(s,[{type:n,attrs:{...a,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(f=(u=i.view.dom.ownerDocument.defaultView)===null||u===void 0?void 0:u.getSelection())===null||f===void 0||f.collapseToEnd()},allow:({state:i,range:s})=>{const a=i.doc.resolve(s.from),l=i.schema.nodes[n];return!!a.parent.type.contentMatch.matchType(l)},...e}}function VD(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>Gce({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function zE(t,e){const n=VD(t),r=n.find(o=>o.char===e);return r||(n.length?n[0]:null)}const Jce=nn.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,r;return`${(n=e==null?void 0:e.char)!==null&&n!==void 0?n:"@"}${(r=t.attrs.label)!==null&&r!==void 0?r:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var r,o;return["span",St(this.HTMLAttributes,t.HTMLAttributes),`${(r=n==null?void 0:n.char)!==null&&r!==void 0?r:"@"}${(o=e.attrs.label)!==null&&o!==void 0?o:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:t=>t.getAttribute("data-mention-suggestion-char"),renderHTML:t=>({"data-mention-suggestion-char":t.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){const n=zE(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",St({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=St({"data-type":this.name},this.options.HTMLAttributes,e);const o=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof o=="string"?["span",St({"data-type":this.name},this.options.HTMLAttributes,e),o]:o},renderText({node:t}){const e={options:this.options,node:t,suggestion:zE(this,t.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1;const{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;e.doc.nodesBetween(i-1,i,(l,u)=>{if(l.type.name===this.name)return n=!0,t.insertText(this.options.deleteTriggerWithBackspace?"":this.options.suggestion.char||"",u,u+l.nodeSize),!1});let s=new _i,a=0;return e.doc.nodesBetween(i-1,i,(l,u)=>{if(l.type.name===this.name)return n=!0,s=l,a=u,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":s.attrs.mentionSuggestionChar,a,a+s.nodeSize),n})}},addProseMirrorPlugins(){return VD(this).map(Yce)}}),zD=mn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new rn({key:new On("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((s,a)=>{const l=r>=a&&r<=a+s.nodeSize,u=!s.isLeaf&&Rh(s);if((l||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const p=Qn.node(a,a+s.nodeSize,{class:f.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:a,hasAnchor:l}):this.options.placeholder});o.push(p)}return this.options.includeChildren}),Xt.create(t,o)}}})]}}),Xce=Or.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",St(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Zce=nn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",St(this.options.HTMLAttributes,t),0]}}),Qce=nn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",St(this.options.HTMLAttributes,t),0]}}),eue=nn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",St(this.options.HTMLAttributes,t),0]}}),tue=/^\s*(\[([( |x])?\])\s$/,nue=nn.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",St(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),u=()=>{var f,p;a.ariaLabel=((p=(f=this.options.a11y)===null||f===void 0?void 0:f.checkboxLabel)===null||p===void 0?void 0:p.call(f,t,a.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};return u(),i.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",f=>f.preventDefault()),a.addEventListener("change",f=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:p}=f.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const g=n();if(typeof g!="number")return!1;const v=m.doc.nodeAt(g);return m.setNodeMarkup(g,void 0,{...v==null?void 0:v.attrs,checked:p}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,p)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([f,p])=>{o.setAttribute(f,p)}),o.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,i.append(a,s),o.append(i,l),Object.entries(e).forEach(([f,p])=>{o.setAttribute(f,p)}),{dom:o,contentDOM:l,update:f=>f.type!==this.type?!1:(o.dataset.checked=f.attrs.checked,a.checked=f.attrs.checked,u(),!0)}}},addInputRules(){return[Dl({find:tue,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),rue=nn.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",St(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),oue=mn.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),HD=Z.forwardRef((t,e)=>{const[n,r]=Z.useState(0),o=l=>{if(l>=t.items.length)return;const u=t.items[l],f={id:u.id,label:u.mentionLabel};t.command(f)},i=()=>{r((n+t.items.length-1)%t.items.length)},s=()=>{r((n+1)%t.items.length)},a=()=>{o(n)};return Z.useEffect(()=>r(0),[t.items]),Z.useImperativeHandle(e,()=>({onKeyDown:({event:l})=>l.key==="ArrowUp"?(i(),!0):l.key==="ArrowDown"?(s(),!0):l.key==="Enter"?(a(),!0):!1})),t.items.length>0?b.jsx(z.Paper,{elevation:5,children:b.jsx(z.List,{dense:!0,sx:{overflow:"hidden"},children:t.items.map((l,u)=>b.jsx(z.ListItem,{disablePadding:!0,children:b.jsx(z.ListItemButton,{selected:u===n,onClick:()=>o(u),children:l.mentionLabel})},l.id))})}):null});HD.displayName="SuggestionList";const HE={bottom:0,height:0,left:0,right:0,top:0,width:0,x:0,y:0,toJSON(){return{}}},iue={items:async({query:t})=>Promise.resolve(["Lea Thompson","Cyndi Lauper","Tom Cruise","Madonna","Jerry Hall","Joan Collins","Winona Ryder","Christina Applegate","Alyssa Milano","Molly Ringwald","Ally Sheedy","Debbie Harry","Olivia Newton-John","Elton John","Michael J. Fox","Axl Rose","Emilio Estevez","Ralph Macchio","Rob Lowe","Jennifer Grey","Mickey Rourke","John Cusack","Matthew Broderick","Justine Bateman","Lisa Bonet","Benicio Monserrate Rafael del Toro Sánchez"].map((e,n)=>({mentionLabel:e,id:n.toString()})).filter(e=>e.mentionLabel.toLowerCase().startsWith(t.toLowerCase())).slice(0,5)),render:()=>{let t,e;return{onStart:n=>{t=new J2(HD,{props:n,editor:n.editor}),e=Uu("body",{getReferenceClientRect:()=>{var r;return((r=n.clientRect)==null?void 0:r.call(n))??HE},appendTo:()=>document.body,content:t.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})[0]},onUpdate(n){t==null||t.updateProps(n),e==null||e.setProps({getReferenceClientRect:()=>{var r;return((r=n.clientRect)==null?void 0:r.call(n))??HE}})},onKeyDown(n){return n.event.key==="Escape"?(e==null||e.hide(),!0):t!=null&&t.ref?t.ref.onKeyDown(n):!1},onExit(){e==null||e.destroy(),t==null||t.destroy(),e=void 0,t=void 0}}}},sue=Uce.extend({inclusive:!1}),aue=Xce.extend({excludes:"superscript"}),lue=wI.extend({excludes:"subscript"});function cue({placeholder:t}={}){return Z.useMemo(()=>[Jee.configure({resizable:!0}),eue,Qce,Zce,dR,pR,hR,bR,OR,MR,_R,aue,lue,IR,uR,cR,fR,ER,xI,RR,sue.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1}),AQ,yR,IQ,oue.configure({types:["heading","paragraph","image"]}),bce,vce,xce,OZ,AR.configure({multicolor:!0}),kR,YQ,mR,rue,nue.configure({nested:!0}),Jce.configure({suggestion:iue}),zD.configure({placeholder:t}),TR],[t])}function WE(t){return Array.from(t).filter(e=>(e.type||"").toLowerCase().startsWith("image/"))}const uue=t=>{const e=cue({placeholder:"Add your own content here..."});if(t.renderContentOnly)return b.jsx(bI,{content:t.renderContentOnly,extensions:e});const{name:n,label:r,labelProps:o={fontSize:"0.9em",color:"#808080",fontWeight:"400"},onUploadFiles:i,readOnly:s=!1}=t,[a,l,u]=Ut.useField({name:n}),{setValue:f}=u,{value:p}=a;Z.useEffect(()=>{var S,k,T;(T=(k=(S=m==null?void 0:m.current)==null?void 0:S.editor)==null?void 0:k.commands)==null||T.setContent(p)},[p]);const m=Z.useRef(null),g=Z.useCallback((S,k)=>{var C;const T=(C=m.current)==null?void 0:C.editor;if(!(!T||!i))if(i instanceof Promise)i(S).then(O=>{Xb({images:O,editor:T,position:k})});else{const O=i(S);Xb({images:O,editor:T,position:k})}},[]),v=Z.useCallback((S,k,T,C)=>{var R;if(!(k instanceof DragEvent)||!k.dataTransfer)return!1;const O=WE(k.dataTransfer.files);if(O.length>0){const P=(R=S.posAtCoords({left:k.clientX,top:k.clientY}))==null?void 0:R.pos;return g(O,P),k.preventDefault(),!0}return!1},[g]),y=Z.useCallback((S,k,T)=>{if(!k.clipboardData)return!1;const C=WE(k.clipboardData.files);return C.length>0?(g(C),!0):!1},[g]),x=b.jsx(z.Box,{sx:{"& .ProseMirror":{"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:s?0:50}}},children:b.jsx(yI,{ref:m,extensions:e,content:p,editable:!s,editorProps:{handleDrop:v,handlePaste:y},renderControls:s?void 0:()=>b.jsx(gce,{onUploadFiles:i}),onBlur:()=>{var S,k;return f(((k=(S=m.current)==null?void 0:S.editor)==null?void 0:k.getHTML())??"")},RichTextFieldProps:{variant:"outlined",MenuBarProps:{hide:s}},children:()=>b.jsxs(b.Fragment,{children:[b.jsx(yte,{}),b.jsx(Ite,{})]})})});return b.jsxs(z.Box,{display:"flex",flexDirection:"column",children:[r&&b.jsx(z.Typography,{...o,children:r}),x]})},w0=t=>{const{title:e="Loading...",message:n}=t;return b.jsxs(z.Box,{className:"loading-page",sx:{gap:2},"data-testid":"loading-page",children:[b.jsxs(z.Box,{className:"text-content",children:[b.jsx(z.Typography,{variant:"h1","data-testid":"title",children:e}),n&&b.jsx(z.Typography,{"data-testid":"message",children:n})]}),b.jsx(z.CircularProgress,{size:75,"data-testid":"loading-spinner"})]})},UE=t=>{const{colSpan:e,isExpanded:n,renderExpand:r,obj:o,asMobileCard:i=!1,reRenderExpand:s=!1}=t,[a,l]=Z.useState(!1),[u,f]=Z.useState(void 0);Z.useEffect(()=>{n&&(!a||s)&&(l(!0),f(r(o)))},[n,o]);const p={"&:last-child td":{borderBottom:"unset"}};return i?b.jsx(z.Collapse,{in:n,children:u}):b.jsx(z.TableRow,{sx:p,children:b.jsx(z.TableCell,{sx:{paddingBottom:0,paddingTop:0},colSpan:e,children:b.jsx(z.Collapse,{in:n,children:u})})})},Cx=t=>{const{id:e,getRowKey:n=X=>"id"in X&&(typeof X.id=="string"||typeof X.id=="number")?X.id:(console.warn(`Table: "id: string | number" not found in ${JSON.stringify(X)}. Please implement the Table.getRowKey prop so Table knows how to uniquely identify this row.`),JSON.stringify(X)),columns:r,data:o=[],onRowClick:i,onRowClickObj:s,renderExpand:a,hideColumnsOnMobile:l=[],sortField:u,sortOrder:f,onSortChange:p,allowSortCols:m,fixedLayout:g=!1,className:v,emptyTableMsg:y="No items to display",errorTableMsg:x,retryCallback:S,isLoading:k=!1,disableMobileCards:T=!1,highlightSelectedRow:C=!1,headerRowStyle:O={},stickyHeader:R,reRenderExpand:P=!1,expandOnRowClick:N=!1,tooltipColor:V,...M}=t,{palette:j}=z.useTheme(),[F,L]=Z.useState(void 0),[A,_]=Z.useState(void 0);due(t);const I=X=>{X!==u?p&&p(X,"asc"):p&&p(u,f==="asc"?"desc":"asc")},B=X=>u===X?f:null,W=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),K=W&&l?r.filter(X=>!(l.includes(xn(X))||X.hideCol)):r.filter(X=>!X.hideCol);a&&!W&&K.unshift({key:"MBv2_Expandable_Column",fieldName:"id",label:"",render:X=>{const le=F===X;return b.jsx(z.IconButton,{"data-testid":"expand-collapse-btn","aria-label":le?"collapse row":"expand row",size:"small",onClick:()=>re(X),children:le?b.jsx($f,{"data-testid":"collapse-up"}):b.jsx(tb,{"data-testid":"expand-down"})})}});const U=p!==void 0,Y=X=>U?m?m.includes(X):!0:!1,oe=b.jsxs(z.Box,{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"row",children:[b.jsx(_ne,{})," ",y]}),fe=b.jsxs(z.Box,{"data-testid":"table-fetch-error-msg",display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"row",children:[b.jsx(yM,{color:"error"})," ",x,S&&b.jsx(z.Button,{variant:"text",onClick:S,children:"Retry?"})]}),he=()=>{if(k)return b.jsx(z.TableRow,{children:b.jsx(z.TableCell,{colSpan:r.length,align:"center",children:b.jsx(z.Box,{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"row",children:b.jsx(w0,{})})})});if(x)return b.jsx(z.TableRow,{children:b.jsx(z.TableCell,{colSpan:r.length,align:"center",children:fe})});if(o.length===0)return b.jsx(z.TableRow,{children:b.jsx(z.TableCell,{colSpan:r.length,align:"center",children:oe})})},G=()=>{if(k)return b.jsx(w0,{});if(x)return fe;if(o.length===0)return oe},te=X=>{C&&_(X)},ue=X=>{const le=n(X);if((i||s)&&(i==null||i(le),s==null||s(X),te(le)),a&&N){const xe=F===le?void 0:le;L(xe),te(xe)}},re=X=>{const le=F===X?void 0:X;L(le),te(le)},ie=X=>{if(!a)return;const le=F===n(X);return b.jsxs(b.Fragment,{children:[b.jsxs(z.Button,{"data-testid":"show-more-less-btn",variant:"text",onClick:()=>re(n(X)),children:[le?b.jsx($f,{}):b.jsx(tb,{})," Show"," ",le?"Less":"More"]}),b.jsx(UE,{colSpan:r.length,isExpanded:n(X)===F,obj:X,renderExpand:xe=>a(xe),asMobileCard:!0})]})},de=typeof C=="string"?C:j.grey[j.mode=="dark"?600:50],ye=X=>{const le=A===n(X)?de:"inherit";return{cursor:i||N?"pointer":"default",backgroundColor:le,...a?{"& > td":{borderBottom:"unset"}}:{"&:last-child td":{borderBottom:"unset"}},...i&&{"&:hover":{backgroundColor:le===de?Xie(le,.1):de}}}},ee=j.grey[j.mode==="dark"?600:400],ce=X=>X&&b.jsx(z.Tooltip,{title:X,children:b.jsx(Mne,{"data-testid":"MBv2_table-tooltip",fontSize:"small",sx:{color:V??ee,marginLeft:"2px"}})});return W&&!T?b.jsxs("div",{...e?{id:`mobile-table-${e}`}:{},className:v,"data-testid":"mui-table-mobile",children:[U&&b.jsxs(b.Fragment,{children:[b.jsxs(z.Box,{display:"flex",className:"MBv2_Table_Stack_Sort",children:[b.jsx(z.TextField,{select:!0,sx:{flexGrow:1},id:"demo-simple-select",size:"small",value:u??"",label:"Sort By...",onChange:X=>I(X.target.value),fullWidth:!0,children:K.map(X=>{if(Y(xn(X)))return b.jsx(z.MenuItem,{value:xn(X),children:X.label??Fn(xn(X))},`rowHeader-${xn(X)}`)})}),b.jsx(z.IconButton,{onClick:()=>{u&&I(u)},children:b.jsx($ne,{className:`sort-icon-${f}`})})]}),b.jsx(z.Divider,{sx:{margin:"10px 0"}})]}),G()??o.map(X=>b.jsxs(z.Card,{className:"MBv2_Table_Stack_Container",sx:{margin:"5px 0",padding:"5px",overflowX:"auto",...ye(X)},onClick:()=>ue(X),"data-testid":`card-${n(X)}`,children:[b.jsx("table",{className:"MBv2_Table_Stack",children:b.jsx("tbody",{className:"MBv2_Table_Stack_Body",children:K.map(le=>b.jsxs("tr",{className:"MBv2_Table_Stack_Row",children:[b.jsxs("td",{className:`MBv2_Table_Stack_Cell_Label MBv2_Table_Stack_Col_${xn(le)}`,style:{textWrap:"nowrap"},children:[le.label??Fn(xn(le)),ce(le.tooltip)]}),b.jsx("td",{className:`MBv2_Table_Stack_Cell_Value MBv2_Table_Stack_Val_${xn(le)}`,style:{paddingLeft:"10px"},children:Mu(le,X,W)})]},`row-${n(X)}-${xn(le)}`))})}),ie(X)]},n(X)))]}):b.jsx(z.TableContainer,{component:z.Card,"data-testid":"mui-table",...e?{id:`table-${e}`}:{},className:v,style:R?{maxHeight:R,overflow:"auto"}:{},children:b.jsxs(z.Table,{stickyHeader:R!=="undefined",style:{tableLayout:g?"fixed":"auto"},className:"MBv2_Table",sx:O?{"& .MuiTableCell-head":{...O}}:{},...M,children:[b.jsx(z.TableHead,{className:"MBv2_Table_Head",children:b.jsx(z.TableRow,{className:"MBv2_Table_Head_Row",children:K.map((X,le)=>{const xe=Y(xn(X));return b.jsx(z.TableCell,{width:Array.isArray(g)?g[le]:"auto",sx:X.tableCellSx??{},children:b.jsx(z.Box,{style:{display:"flex",alignItems:"center"},children:b.jsxs(z.Box,{sx:[xe&&{"&:hover":{cursor:"pointer",backgroundColor:j.mode==="dark"?"#222222":"#ededed",borderRadius:2}}],style:{display:"flex",alignItems:"center",padding:"5px",paddingLeft:"6px",marginLeft:"-6px"},onClick:xe?()=>I(xn(X)):void 0,children:[b.jsx("strong",{className:"MBv2_Table_Col_Label",style:{wordBreak:"normal"},"data-testid":"column-title",children:X.label??Fn(xn(X))}),ce(X.tooltip),xe&&B(xn(X))==="asc"&&b.jsx($f,{style:{marginLeft:"5px"}}),xe&&B(xn(X))==="desc"&&b.jsx(tb,{style:{marginLeft:"5px"}}),xe&&B(xn(X))!=="asc"&&B(xn(X))!=="desc"&&b.jsx(Pne,{style:{marginLeft:"5px"}})]})})},`rowHeader-${xn(X)}`)})})}),b.jsx(z.TableBody,{className:"MBv2_Table_Body",children:he()??o.map(X=>b.jsxs(Z.Fragment,{children:[b.jsx(z.TableRow,{"data-testid":`row-${n(X)}`,className:"MBv2_Table_Body_Row",onClick:()=>ue(X),sx:ye(X),children:K.map(le=>b.jsx(z.TableCell,{className:`MBv2_Table_Body_Cell MBv2_Table_Body_Col_${xn(le)}`,children:Mu(le,X,W)},`row-${n(X)}-${xn(le)}`))}),a&&b.jsx(UE,{colSpan:K.length,isExpanded:n(X)===F,obj:X,renderExpand:le=>a(le),reRenderExpand:P})]},n(X)))})]})})},due=t=>{const{fixedLayout:e,renderExpand:n,columns:r,expandOnRowClick:o,onRowClick:i,onRowClickObj:s}=t,a="Table component:";Array.isArray(e)&&(!n&&e.length!==r.length&&console.warn(`${a} Length of "fixedLayout" is not equal to the length of "columns".`),n&&e.length!==r.length+1&&console.warn(`${a} Length of "fixedLayout" is not equal to the length of "columns"+1. Make sure you're including a percentage for the expand/collapse column AND each column in "columns".`)),o&&!n&&console.warn(`${a} renderExpand should be defined when expandOnRowClick is defined`),i&&s&&console.warn(`${a} 'onRowClick' and 'onRowClickObj' are both defined. Only one should be defined.`)},xn=t=>t.key??t.fieldName,fue=(t,e)=>e.split(".").reduce((n,r)=>{if(n&&typeof n=="object")return n[r]},t),Mu=(t,e,n=!1)=>{const r=fue(e,t.fieldName);return t.render?t.render(r,e,n):r},WD=t=>{const{paginationState:e,onPageChange:n,onRowsPerPageChange:r,hidePaginationControls:o=!1,rowsPerPageOptions:i=[5,10,25],...s}=t,{pageNo:a,pageSize:l,totalCount:u,sortField:f,sortOrder:p}=e,m=x=>{n(x)},g=x=>{r(parseInt(x.target.value,10))},v=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),y=!t.data||t.data&&t.data.length===0;return b.jsxs(z.Box,{children:[b.jsx(Cx,{sortOrder:p,sortField:f,...s}),!o&&!y&&b.jsx(z.TablePagination,{"data-testid":"pagination-controls",component:"div",rowsPerPageOptions:v?[]:i,count:u,rowsPerPage:l,page:a,onPageChange:(x,S)=>m(S),onRowsPerPageChange:g,sx:{flexGrow:1,marginRight:{xs:0,md:15}}})]})},qE=()=>({height:window.innerHeight,width:window.innerWidth}),UD=()=>{const[t,e]=Z.useState(qE());return Z.useEffect(()=>{const n=()=>{e(qE())};return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},ao=t=>{const{name:e="button",color:n="primary",fullWidthOnMobile:r=!0,type:o="button",variant:i="contained"}=t,{width:s}=UD(),a=["locationInBar","closeDialog","fullWidthOnMobile"],l=r&&s<600;return b.jsx(z.Button,{role:"button",name:e,color:n,variant:i,type:o,fullWidth:t.fullWidth?!0:l,...hr({...t},a)})},pue=t=>{const{citation:e,anchorEl:n,onClose:r}=t;return b.jsx(z.Popper,{open:e!==null,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},children:e&&b.jsxs(z.Box,{component:z.Paper,p:1,display:"flex",gap:1,boxShadow:9,"data-testid":`citation-table_launch-link-prompt-${e.id}`,flexDirection:"column",alignItems:"end",children:[b.jsxs(z.Typography,{variant:"body2",sx:{wordBreak:"break-all",maxWidth:"350px"},children:["Are you sure you want to go to ",b.jsx("br",{}),b.jsx("b",{children:e.url}),"?"]}),b.jsxs(z.Box,{display:"flex",flexDirection:"row",children:[b.jsx(ao,{size:"small",variant:"text",onClick:r,"data-testid":`citation-table_launch-prompt-${e.id}-noBtn`,children:"No"}),b.jsx(ao,{size:"small",startIcon:b.jsx(d0,{}),onClick:()=>{window.open(e.url,"_blank","noopener,noreferrer"),r()},"data-testid":`citation-table_launch-prompt-${e.id}-yesBtn`,children:"Yes"})]})]})})},hue=t=>{const{citation:e,anchorEl:n,onDeleteCitation:r,onClose:o}=t;if(r)return b.jsx(z.Popper,{open:e!==null,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},children:e&&b.jsxs(z.Box,{component:z.Paper,p:1,display:"flex",gap:1,boxShadow:9,"data-testid":`citation-table_delete-prompt-${e.id}`,children:[b.jsxs(z.Typography,{variant:"body2",children:["Are you sure you want to delete this ",e.fileName?"attachment":"citation","?"]}),b.jsxs(z.Box,{display:"flex",flexDirection:"row",children:[b.jsx(ao,{size:"small",variant:"text",onClick:o,"data-testid":`citation-table_delete-prompt-${e.id}-noBtn`,children:"No"}),b.jsx(ao,{size:"small",color:"error",startIcon:b.jsx(Gv,{}),onClick:()=>r(e.id).finally(o),"data-testid":`citation-table_delete-prompt-${e.id}-yesBtn`,children:"Yes"})]})]})})},mue=t=>{const{refreshKey:e,title:n,onCancel:r,onNewCitation:o,onNewAttachment:i,onEditCitation:s,onEditAttachment:a,onDeleteCitation:l,onDownloadAttachment:u,onViewAttachment:f,onSelect:p,getCitationsPaginated:m,selectedIds:g,setSelectedIds:v,onError:y=()=>{},condenseTable:x=!1,canSelect:S=!1,canLaunchUrl:k,addlActions:T,readOnly:C=!1,showCloseBtn:O=!1}=t,R=!!t.canCreate&&!C,P=!!t.canEdit&&!C,N=!!t.canDelete&&!C,{palette:V}=z.useTheme(),[M,j]=Z.useState([]),[F,L]=Z.useState(!1),[A,_]=Z.useState(!0),[I,B]=Z.useState(null),[W,K]=Z.useState(null),[U,Y]=Z.useState(null),[oe,fe]=Z.useState({pageNo:0,pageSize:x?5:10,totalCount:0}),he=()=>{L(!1),_(!0),m({pageNo:oe.pageNo,pageSize:oe.pageSize}).then(le=>(j(le.data),fe({...oe,totalCount:le.totalCount}),le)).catch(le=>{y(le),L(!0),j([])}).finally(()=>_(!1))};Z.useEffect(he,[oe.pageNo,oe.pageSize,e]);const G=()=>{K(null),Y(null),B(null)},te=b.jsx(ao,{variant:S?"outlined":"contained",size:S?"small":"medium",onClick:o,startIcon:b.jsx(Hh,{}),children:"Add Citation"}),ue=b.jsx(ao,{variant:S?"outlined":"contained",size:S?"small":"medium",onClick:i,startIcon:b.jsx(RI,{}),children:"Add Attachment"}),re=le=>{if(!(!P&&!C)&&!(C&&!x))return b.jsx(z.Tooltip,{title:C?"View":"Edit",children:b.jsx(z.IconButton,{color:"primary",onClick:()=>le.fileName?a(le):s(le),"data-testid":`citation-table_edit-btn-${le.id}`,children:C?b.jsx(Lne,{}):b.jsx(One,{})})})},ie=le=>{if(!(!N||C))return b.jsx(z.Tooltip,{title:"Delete",children:b.jsx(z.IconButton,{color:"error",onClick:xe=>{K(le),B(xe.currentTarget)},"data-testid":`citation-table_delete-btn-${le.id}`,children:b.jsx(Gv,{})})})},de=le=>{if(!k)return;if(!le.fileName)return b.jsx(z.Tooltip,{title:"Open URL",children:b.jsx(z.IconButton,{color:"primary",onClick:_e=>{B(_e.currentTarget),Y(le)},"data-testid":`citation-table_launch-link-btn-${le.id}`,sx:{visibility:k!=null&&k(le)?"visible":"hidden"},children:b.jsx(d0,{})})})},ye=le=>{if(!f||!le.fileName)return;const xe=["pdf","png","jpg","jpeg","gif","bmp","svg","webp","mp3","wav","mp4","webm","html","htm","txt","xml","json","csv"],_e=le.fileName.split(".").pop();if(!(!_e||!xe.includes(_e)))return b.jsx(z.Tooltip,{title:"View File",children:b.jsx(z.IconButton,{color:"primary",onClick:()=>f==null?void 0:f(le),"data-testid":`citation-table_view-file-btn-${le.id}`,children:b.jsx(d0,{})})})},ee=le=>{if(!u)return;if(!!le.fileName)return b.jsx(z.Tooltip,{title:"Download",children:b.jsx(z.IconButton,{color:"primary",onClick:()=>u==null?void 0:u(le),"data-testid":`citation-table_download-btn-${le.id}`,children:b.jsx(Ene,{})})})},ce=C||P||N||k||f||u||T,X=[{fieldName:"id",key:"select",label:"",hideCol:!S,render:(le,xe)=>b.jsx(z.Checkbox,{"data-testid":`citation-table_checkbox-${le}`,onChange:()=>{const _e=g.includes(xe.id);v(_e?g.filter(Me=>Me!==xe.id):[...g,xe.id])},checked:g.includes(le),disabled:C})},...qD(V,x),{fieldName:"id",key:"Action",label:"Action",hideCol:!ce,render:(le,xe)=>b.jsxs(z.Box,{display:"flex",flexDirection:"row-reverse",children:[T==null?void 0:T(xe),ie(xe),re(xe),ye(xe),de(xe),ee(xe)]})}];return b.jsxs(b.Fragment,{children:[b.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"10px",children:[b.jsx(z.Typography,{variant:x?"h6":"h2",children:n}),!S&&R&&b.jsxs(z.Box,{display:"flex",flexDirection:"row",gap:1,children:[te,ue]}),O&&b.jsx(z.IconButton,{onClick:r,children:b.jsx(Xh,{})})]}),b.jsx(WD,{"data-testid":"citation-table",size:x?"x-small":"medium",isLoading:A,columns:X,data:M,paginationState:oe,onPageChange:le=>fe({...oe,pageNo:le}),onRowsPerPageChange:le=>fe({...oe,pageSize:le,pageNo:0}),errorTableMsg:F?"Failed to load citations.":void 0,retryCallback:he}),S&&b.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",marginTop:"20px",children:[b.jsx(z.Box,{display:"flex",flexDirection:"row",gap:".25rem",children:R&&b.jsxs(b.Fragment,{children:[te,ue]})}),!C&&b.jsxs(z.Box,{display:"flex",flexDirection:"row",gap:".25rem",children:[b.jsx(ao,{variant:"outlined",size:"small",onClick:r,children:"Cancel"}),b.jsxs(ao,{variant:"contained",size:"small",onClick:()=>p(g),children:["Select",g.length>0&&` (${g.length})`]})]})]}),b.jsx(pue,{citation:U,anchorEl:I,onClose:G}),b.jsx(hue,{citation:W,anchorEl:I,onDeleteCitation:l,onClose:G})]})},qD=(t,e=!1)=>[{fieldName:"fileName",key:"CitationOrAttachment",label:"Type",render:(n,r)=>b.jsx(z.Tooltip,{title:n?"Attachment":"URL",children:n?b.jsx(RI,{sx:{color:t.grey[500],marginTop:"4px"},"data-testid":`attachment-icon-${r.id}`}):b.jsx(Hh,{sx:{color:t.grey[500],marginTop:"6px"},"data-testid":`url-icon-${r.id}`})}),ignoreDiff:!0},{fieldName:"title",tableCellSx:{width:e?"100%":"auto"},render:n=>e?ka.truncate(n,{length:40,omission:"..."}):n},{fieldName:"fileName",key:"URL/File Name",label:"URL/File Name",hideCol:e,render:(n,r)=>b.jsx("span",{style:{wordBreak:"break-all"},children:n||r.url}),isEqual:(n,r)=>n.fileName&&r.fileName?n.fileName===r.fileName:n.url===r.url},{fieldName:"source",hideCol:e},{fieldName:"accessedAt",hideCol:e,render:(n,r)=>{if(!r.fileName)return(n==null?void 0:n.slice(0,10))??""}},{fieldName:"classification",hideCol:e}],Tx=t=>{const{loading:e=!1,type:n="submit",size:r="medium",...o}=t,s={small:16,medium:20,large:24}[r];return b.jsx(ao,{type:n,disabled:e,size:r,startIcon:e?b.jsx(z.CircularProgress,{size:s,color:"inherit"}):null,...o})};var ub,KE;function gue(){if(KE)return ub;KE=1;function t(S){this._maxSize=S,this.clear()}t.prototype.clear=function(){this._size=0,this._values=Object.create(null)},t.prototype.get=function(S){return this._values[S]},t.prototype.set=function(S,k){return this._size>=this._maxSize&&this.clear(),S in this._values||this._size++,this._values[S]=k};var e=/[^.^\]^[]+|(?=\[\]|\.\.)/g,n=/^\d+$/,r=/^\d/,o=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,i=/^\s*(['"]?)(.*?)(\1)\s*$/,s=512,a=new t(s),l=new t(s),u=new t(s);ub={Cache:t,split:p,normalizePath:f,setter:function(S){var k=f(S);return l.get(S)||l.set(S,function(C,O){for(var R=0,P=k.length,N=C;R<P-1;){var V=k[R];if(V==="__proto__"||V==="constructor"||V==="prototype")return C;N=N[k[R++]]}N[k[R]]=O})},getter:function(S,k){var T=f(S);return u.get(S)||u.set(S,function(O){for(var R=0,P=T.length;R<P;)if(O!=null||!k)O=O[T[R++]];else return;return O})},join:function(S){return S.reduce(function(k,T){return k+(g(T)||n.test(T)?"["+T+"]":(k?".":"")+T)},"")},forEach:function(S,k,T){m(Array.isArray(S)?S:p(S),k,T)}};function f(S){return a.get(S)||a.set(S,p(S).map(function(k){return k.replace(i,"$2")}))}function p(S){return S.match(e)||[""]}function m(S,k,T){var C=S.length,O,R,P,N;for(R=0;R<C;R++)O=S[R],O&&(x(O)&&(O='"'+O+'"'),N=g(O),P=!N&&/^\d+$/.test(O),k.call(T,O,N,P,R,S))}function g(S){return typeof S=="string"&&S&&["'",'"'].indexOf(S.charAt(0))!==-1}function v(S){return S.match(r)&&!S.match(n)}function y(S){return o.test(S)}function x(S){return!g(S)&&(v(S)||y(S))}return ub}var ha=gue(),db,YE;function yue(){if(YE)return db;YE=1;const t=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,e=f=>f.match(t)||[],n=f=>f[0].toUpperCase()+f.slice(1),r=(f,p)=>e(f).join(p).toLowerCase(),o=f=>e(f).reduce((p,m)=>`${p}${p?m[0].toUpperCase()+m.slice(1).toLowerCase():m.toLowerCase()}`,"");return db={words:e,upperFirst:n,camelCase:o,pascalCase:f=>n(o(f)),snakeCase:f=>r(f,"_"),kebabCase:f=>r(f,"-"),sentenceCase:f=>n(r(f," ")),titleCase:f=>e(f).map(n).join(" ")},db}var fb=yue(),Cf={exports:{}},GE;function bue(){if(GE)return Cf.exports;GE=1,Cf.exports=function(o){return t(e(o),o)},Cf.exports.array=t;function t(o,i){var s=o.length,a=new Array(s),l={},u=s,f=n(i),p=r(o);for(i.forEach(function(g){if(!p.has(g[0])||!p.has(g[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});u--;)l[u]||m(o[u],u,new Set);return a;function m(g,v,y){if(y.has(g)){var x;try{x=", node was:"+JSON.stringify(g)}catch{x=""}throw new Error("Cyclic dependency"+x)}if(!p.has(g))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(g));if(!l[v]){l[v]=!0;var S=f.get(g)||new Set;if(S=Array.from(S),v=S.length){y.add(g);do{var k=S[--v];m(k,p.get(k),y)}while(v);y.delete(g)}a[--s]=g}}}function e(o){for(var i=new Set,s=0,a=o.length;s<a;s++){var l=o[s];i.add(l[0]),i.add(l[1])}return Array.from(i)}function n(o){for(var i=new Map,s=0,a=o.length;s<a;s++){var l=o[s];i.has(l[0])||i.set(l[0],new Set),i.has(l[1])||i.set(l[1],new Set),i.get(l[0]).add(l[1])}return i}function r(o){for(var i=new Map,s=0,a=o.length;s<a;s++)i.set(o[s],s);return i}return Cf.exports}var vue=bue();const xue=sr(vue),wue=Object.prototype.toString,Sue=Error.prototype.toString,Cue=RegExp.prototype.toString,Tue=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",kue=/^Symbol\((.*)\)(.*)$/;function Eue(t){return t!=+t?"NaN":t===0&&1/t<0?"-0":""+t}function JE(t,e=!1){if(t==null||t===!0||t===!1)return""+t;const n=typeof t;if(n==="number")return Eue(t);if(n==="string")return e?`"${t}"`:t;if(n==="function")return"[Function "+(t.name||"anonymous")+"]";if(n==="symbol")return Tue.call(t).replace(kue,"Symbol($1)");const r=wue.call(t).slice(8,-1);return r==="Date"?isNaN(t.getTime())?""+t:t.toISOString(t):r==="Error"||t instanceof Error?"["+Sue.call(t)+"]":r==="RegExp"?Cue.call(t):null}function ws(t,e){let n=JE(t,e);return n!==null?n:JSON.stringify(t,function(r,o){let i=JE(this[r],e);return i!==null?i:o},2)}function KD(t){return t==null?[]:[].concat(t)}let YD,GD,JD,Oue=/\$\{\s*(\w+)\s*\}/g;YD=Symbol.toStringTag;class XE{constructor(e,n,r,o){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[YD]="Error",this.name="ValidationError",this.value=n,this.path=r,this.type=o,this.errors=[],this.inner=[],KD(e).forEach(i=>{if(pr.isError(i)){this.errors.push(...i.errors);const s=i.inner.length?i.inner:[i];this.inner.push(...s)}else this.errors.push(i)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}GD=Symbol.hasInstance;JD=Symbol.toStringTag;class pr extends Error{static formatError(e,n){const r=n.label||n.path||"this";return n=Object.assign({},n,{path:r,originalPath:n.path}),typeof e=="string"?e.replace(Oue,(o,i)=>ws(n[i])):typeof e=="function"?e(n):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,n,r,o,i){const s=new XE(e,n,r,o);if(i)return s;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[JD]="Error",this.name=s.name,this.message=s.message,this.type=s.type,this.value=s.value,this.path=s.path,this.errors=s.errors,this.inner=s.inner,Error.captureStackTrace&&Error.captureStackTrace(this,pr)}static[GD](e){return XE[Symbol.hasInstance](e)||super[Symbol.hasInstance](e)}}let Vo={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:t,type:e,value:n,originalValue:r})=>{const o=r!=null&&r!==n?` (cast from the value \`${ws(r,!0)}\`).`:".";return e!=="mixed"?`${t} must be a \`${e}\` type, but the final value was: \`${ws(n,!0)}\``+o:`${t} must match the configured type. The validated value was: \`${ws(n,!0)}\``+o}},wr={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},Mue={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},S0={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},_ue={isValue:"${path} field must be ${value}"},Uf={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"},Rue={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},Iue={notType:t=>{const{path:e,value:n,spec:r}=t,o=r.types.length;if(Array.isArray(n)){if(n.length<o)return`${e} tuple value has too few items, expected a length of ${o} but got ${n.length} for value: \`${ws(n,!0)}\``;if(n.length>o)return`${e} tuple value has too many items, expected a length of ${o} but got ${n.length} for value: \`${ws(n,!0)}\``}return pr.formatError(Vo.notType,t)}};Object.assign(Object.create(null),{mixed:Vo,string:wr,number:Mue,date:S0,object:Uf,array:Rue,boolean:_ue,tuple:Iue});const kx=t=>t&&t.__isYupSchema__;class th{static fromOptions(e,n){if(!n.then&&!n.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:r,then:o,otherwise:i}=n,s=typeof r=="function"?r:(...a)=>a.every(l=>l===r);return new th(e,(a,l)=>{var u;let f=s(...a)?o:i;return(u=f==null?void 0:f(l))!=null?u:l})}constructor(e,n){this.fn=void 0,this.refs=e,this.refs=e,this.fn=n}resolve(e,n){let r=this.refs.map(i=>i.getValue(n==null?void 0:n.value,n==null?void 0:n.parent,n==null?void 0:n.context)),o=this.fn(r,e,n);if(o===void 0||o===e)return e;if(!kx(o))throw new TypeError("conditions must return a schema object");return o.resolve(n)}}const Tf={context:"$",value:"."};class Na{constructor(e,n={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===Tf.context,this.isValue=this.key[0]===Tf.value,this.isSibling=!this.isContext&&!this.isValue;let r=this.isContext?Tf.context:this.isValue?Tf.value:"";this.path=this.key.slice(r.length),this.getter=this.path&&ha.getter(this.path,!0),this.map=n.map}getValue(e,n,r){let o=this.isContext?r:this.isValue?e:n;return this.getter&&(o=this.getter(o||{})),this.map&&(o=this.map(o)),o}cast(e,n){return this.getValue(e,n==null?void 0:n.parent,n==null?void 0:n.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}Na.prototype.__isYupRef=!0;const sa=t=>t==null;function al(t){function e({value:n,path:r="",options:o,originalValue:i,schema:s},a,l){const{name:u,test:f,params:p,message:m,skipAbsent:g}=t;let{parent:v,context:y,abortEarly:x=s.spec.abortEarly,disableStackTrace:S=s.spec.disableStackTrace}=o;const k={value:n,parent:v,context:y};function T(j={}){const F=XD(Object.assign({value:n,originalValue:i,label:s.spec.label,path:j.path||r,spec:s.spec,disableStackTrace:j.disableStackTrace||S},p,j.params),k),L=new pr(pr.formatError(j.message||m,F),n,F.path,j.type||u,F.disableStackTrace);return L.params=F,L}const C=x?a:l;let O={path:r,parent:v,type:u,from:o.from,createError:T,resolve(j){return ZD(j,k)},options:o,originalValue:i,schema:s};const R=j=>{pr.isError(j)?C(j):j?l(null):C(T())},P=j=>{pr.isError(j)?C(j):a(j)};if(g&&sa(n))return R(!0);let V;try{var M;if(V=f.call(O,n,O),typeof((M=V)==null?void 0:M.then)=="function"){if(o.sync)throw new Error(`Validation test of type: "${O.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(V).then(R,P)}}catch(j){P(j);return}R(V)}return e.OPTIONS=t,e}function XD(t,e){if(!t)return t;for(const n of Object.keys(t))t[n]=ZD(t[n],e);return t}function ZD(t,e){return Na.isRef(t)?t.getValue(e.value,e.parent,e.context):t}function Due(t,e,n,r=n){let o,i,s;return e?(ha.forEach(e,(a,l,u)=>{let f=l?a.slice(1,a.length-1):a;t=t.resolve({context:r,parent:o,value:n});let p=t.type==="tuple",m=u?parseInt(f,10):0;if(t.innerType||p){if(p&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${s}" must contain an index to the tuple element, e.g. "${s}[0]"`);if(n&&m>=n.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${e}. because there is no value at that index. `);o=n,n=n&&n[m],t=p?t.spec.types[m]:t.innerType}if(!u){if(!t.fields||!t.fields[f])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${s} which is a type: "${t.type}")`);o=n,n=n&&n[f],t=t.fields[f]}i=f,s=l?"["+a+"]":"."+a}),{schema:t,parent:o,parentPath:i}):{parent:o,parentPath:e,schema:t}}class nh extends Set{describe(){const e=[];for(const n of this.values())e.push(Na.isRef(n)?n.describe():n);return e}resolveAll(e){let n=[];for(const r of this.values())n.push(e(r));return n}clone(){return new nh(this.values())}merge(e,n){const r=this.clone();return e.forEach(o=>r.add(o)),n.forEach(o=>r.delete(o)),r}}function yl(t,e=new Map){if(kx(t)||!t||typeof t!="object")return t;if(e.has(t))return e.get(t);let n;if(t instanceof Date)n=new Date(t.getTime()),e.set(t,n);else if(t instanceof RegExp)n=new RegExp(t),e.set(t,n);else if(Array.isArray(t)){n=new Array(t.length),e.set(t,n);for(let r=0;r<t.length;r++)n[r]=yl(t[r],e)}else if(t instanceof Map){n=new Map,e.set(t,n);for(const[r,o]of t.entries())n.set(r,yl(o,e))}else if(t instanceof Set){n=new Set,e.set(t,n);for(const r of t)n.add(yl(r,e))}else if(t instanceof Object){n={},e.set(t,n);for(const[r,o]of Object.entries(t))n[r]=yl(o,e)}else throw Error(`Unable to clone ${t}`);return n}function Aue(t){if(!(t!=null&&t.length))return;const e=[];let n="",r=!1,o=!1;for(let i=0;i<t.length;i++){const s=t[i];if(s==="["&&!o){n&&(e.push(...n.split(".").filter(Boolean)),n=""),r=!0;continue}if(s==="]"&&!o){n&&(/^\d+$/.test(n)?e.push(n):e.push(n.replace(/^"|"$/g,"")),n=""),r=!1;continue}if(s==='"'){o=!o;continue}if(s==="."&&!r&&!o){n&&(e.push(n),n="");continue}n+=s}return n&&e.push(...n.split(".").filter(Boolean)),e}function Pue(t,e){const n=e?`${e}.${t.path}`:t.path;return t.errors.map(r=>({message:r,path:Aue(n)}))}function QD(t,e){var n;if(!((n=t.inner)!=null&&n.length)&&t.errors.length)return Pue(t,e);const r=e?`${e}.${t.path}`:t.path;return t.inner.flatMap(o=>QD(o,r))}class ti{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new nh,this._blacklist=new nh,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(Vo.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},e==null?void 0:e.spec),this.withMutation(n=>{n.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const n=Object.create(Object.getPrototypeOf(this));return n.type=this.type,n._typeCheck=this._typeCheck,n._whitelist=this._whitelist.clone(),n._blacklist=this._blacklist.clone(),n.internalTests=Object.assign({},this.internalTests),n.exclusiveTests=Object.assign({},this.exclusiveTests),n.deps=[...this.deps],n.conditions=[...this.conditions],n.tests=[...this.tests],n.transforms=[...this.transforms],n.spec=yl(Object.assign({},this.spec,e)),n}label(e){let n=this.clone();return n.spec.label=e,n}meta(...e){if(e.length===0)return this.spec.meta;let n=this.clone();return n.spec.meta=Object.assign(n.spec.meta||{},e[0]),n}withMutation(e){let n=this._mutate;this._mutate=!0;let r=e(this);return this._mutate=n,r}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let n=this,r=e.clone();const o=Object.assign({},n.spec,r.spec);return r.spec=o,r.internalTests=Object.assign({},n.internalTests,r.internalTests),r._whitelist=n._whitelist.merge(e._whitelist,e._blacklist),r._blacklist=n._blacklist.merge(e._blacklist,e._whitelist),r.tests=n.tests,r.exclusiveTests=n.exclusiveTests,r.withMutation(i=>{e.tests.forEach(s=>{i.test(s.OPTIONS)})}),r.transforms=[...n.transforms,...r.transforms],r}isType(e){return e==null?!!(this.spec.nullable&&e===null||this.spec.optional&&e===void 0):this._typeCheck(e)}resolve(e){let n=this;if(n.conditions.length){let r=n.conditions;n=n.clone(),n.conditions=[],n=r.reduce((o,i)=>i.resolve(o,e),n),n=n.resolve(e)}return n}resolveOptions(e){var n,r,o,i;return Object.assign({},e,{from:e.from||[],strict:(n=e.strict)!=null?n:this.spec.strict,abortEarly:(r=e.abortEarly)!=null?r:this.spec.abortEarly,recursive:(o=e.recursive)!=null?o:this.spec.recursive,disableStackTrace:(i=e.disableStackTrace)!=null?i:this.spec.disableStackTrace})}cast(e,n={}){let r=this.resolve(Object.assign({},n,{value:e})),o=n.assert==="ignore-optionality",i=r._cast(e,n);if(n.assert!==!1&&!r.isType(i)){if(o&&sa(i))return i;let s=ws(e),a=ws(i);throw new TypeError(`The value of ${n.path||"field"} could not be cast to a value that satisfies the schema type: "${r.type}".
|
|
405
405
|
|
|
406
406
|
attempted value: ${s}
|
|
407
|
-
`+(a!==s?`result of cast: ${a}`:""))}return i}_cast(e,n){let r=e===void 0?e:this.transforms.reduce((o,i)=>i.call(this,o,e,this,n),e);return r===void 0&&(r=this.getDefault(n)),r}_validate(e,n={},r,o){let{path:i,originalValue:s=e,strict:a=this.spec.strict}=n,l=e;a||(l=this._cast(l,Object.assign({assert:!1},n)));let u=[];for(let f of Object.values(this.internalTests))f&&u.push(f);this.runTests({path:i,value:l,originalValue:s,options:n,tests:u},r,f=>{if(f.length)return o(f,l);this.runTests({path:i,value:l,originalValue:s,options:n,tests:this.tests},r,o)})}runTests(e,n,r){let o=!1,{tests:i,value:s,originalValue:a,path:l,options:u}=e,f=y=>{o||(o=!0,n(y,s))},p=y=>{o||(o=!0,r(y,s))},m=i.length,g=[];if(!m)return p([]);let v={value:s,originalValue:a,path:l,options:u,schema:this};for(let y=0;y<i.length;y++){const x=i[y];x(v,f,function(k){k&&(Array.isArray(k)?g.push(...k):g.push(k)),--m<=0&&p(g)})}}asNestedTest({key:e,index:n,parent:r,parentPath:o,originalParent:i,options:s}){const a=e??n;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const l=typeof a=="number";let u=r[a];const f=Object.assign({},s,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[l?"index":"key"]:a,path:l||a.includes(".")?`${o||""}[${l?a:`"${a}"`}]`:(o?`${o}.`:"")+e});return(p,m,g)=>this.resolve(f)._validate(u,f,m,g)}validate(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return new Promise((s,a)=>o._validate(e,n,(l,u)=>{pr.isError(l)&&(l.value=u),a(l)},(l,u)=>{l.length?a(new pr(l,u,void 0,void 0,i)):s(u)}))}validateSync(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i,s=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return o._validate(e,Object.assign({},n,{sync:!0}),(a,l)=>{throw pr.isError(a)&&(a.value=l),a},(a,l)=>{if(a.length)throw new pr(a,e,void 0,void 0,s);i=l}),i}isValid(e,n){return this.validate(e,n).then(()=>!0,r=>{if(pr.isError(r))return!1;throw r})}isValidSync(e,n){try{return this.validateSync(e,n),!0}catch(r){if(pr.isError(r))return!1;throw r}}_getDefault(e){let n=this.spec.default;return n==null?n:typeof n=="function"?n.call(this,e):yl(n)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,n){const r=this.clone({nullable:e});return r.internalTests.nullable=al({message:n,name:"nullable",test(o){return o===null?this.schema.spec.nullable:!0}}),r}optionality(e,n){const r=this.clone({optional:e});return r.internalTests.optionality=al({message:n,name:"optionality",test(o){return o===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=Vo.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=Vo.notNull){return this.nullability(!1,e)}required(e=Vo.required){return this.clone().withMutation(n=>n.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let n=this.clone();return n.transforms.push(e),n}test(...e){let n;if(e.length===1?typeof e[0]=="function"?n={test:e[0]}:n=e[0]:e.length===2?n={name:e[0],test:e[1]}:n={name:e[0],message:e[1],test:e[2]},n.message===void 0&&(n.message=Vo.default),typeof n.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),o=al(n),i=n.exclusive||n.name&&r.exclusiveTests[n.name]===!0;if(n.exclusive&&!n.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return n.name&&(r.exclusiveTests[n.name]=!!n.exclusive),r.tests=r.tests.filter(s=>!(s.OPTIONS.name===n.name&&(i||s.OPTIONS.test===o.OPTIONS.test))),r.tests.push(o),r}when(e,n){!Array.isArray(e)&&typeof e!="string"&&(n=e,e=".");let r=this.clone(),o=KD(e).map(i=>new Na(i));return o.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof n=="function"?new th(o,n):th.fromOptions(o,n)),r}typeError(e){let n=this.clone();return n.internalTests.typeError=al({message:e,name:"typeError",skipAbsent:!0,test(r){return this.schema._typeCheck(r)?!0:this.createError({params:{type:this.schema.type}})}}),n}oneOf(e,n=Vo.oneOf){let r=this.clone();return e.forEach(o=>{r._whitelist.add(o),r._blacklist.delete(o)}),r.internalTests.whiteList=al({message:n,name:"oneOf",skipAbsent:!0,test(o){let i=this.schema._whitelist,s=i.resolveAll(this.resolve);return s.includes(o)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:s}})}}),r}notOneOf(e,n=Vo.notOneOf){let r=this.clone();return e.forEach(o=>{r._blacklist.add(o),r._whitelist.delete(o)}),r.internalTests.blacklist=al({message:n,name:"notOneOf",test(o){let i=this.schema._blacklist,s=i.resolveAll(this.resolve);return s.includes(o)?this.createError({params:{values:Array.from(i).join(", "),resolved:s}}):!0}}),r}strip(e=!0){let n=this.clone();return n.spec.strip=e,n}describe(e){const n=(e?this.resolve(e):this).clone(),{label:r,meta:o,optional:i,nullable:s}=n.spec;return{meta:o,label:r,optional:i,nullable:s,default:n.getDefault(e),type:n.type,oneOf:n._whitelist.describe(),notOneOf:n._blacklist.describe(),tests:n.tests.filter((l,u,f)=>f.findIndex(p=>p.OPTIONS.name===l.OPTIONS.name)===u).map(l=>{const u=l.OPTIONS.params&&e?XD(Object.assign({},l.OPTIONS.params),e):l.OPTIONS.params;return{name:l.OPTIONS.name,params:u}})}}get"~standard"(){const e=this;return{version:1,vendor:"yup",async validate(r){try{return{value:await e.validate(r,{abortEarly:!1})}}catch(o){if(o instanceof pr)return{issues:QD(o)};throw o}}}}}ti.prototype.__isYupSchema__=!0;for(const t of["validate","validateSync"])ti.prototype[`${t}At`]=function(e,n,r={}){const{parent:o,parentPath:i,schema:s}=Due(this,e,n,r.context);return s[t](o&&o[i],Object.assign({},r,{parent:o,path:e}))};for(const t of["equals","is"])ti.prototype[t]=ti.prototype.oneOf;for(const t of["not","nope"])ti.prototype[t]=ti.prototype.notOneOf;const Nue=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function $ue(t){const e=C0(t);if(!e)return Date.parse?Date.parse(t):Number.NaN;if(e.z===void 0&&e.plusMinus===void 0)return new Date(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond).valueOf();let n=0;return e.z!=="Z"&&e.plusMinus!==void 0&&(n=e.hourOffset*60+e.minuteOffset,e.plusMinus==="+"&&(n=0-n)),Date.UTC(e.year,e.month,e.day,e.hour,e.minute+n,e.second,e.millisecond)}function C0(t){var e,n;const r=Nue.exec(t);return r?{year:xi(r[1]),month:xi(r[2],1)-1,day:xi(r[3],1),hour:xi(r[4]),minute:xi(r[5]),second:xi(r[6]),millisecond:r[7]?xi(r[7].substring(0,3)):0,precision:(e=(n=r[7])==null?void 0:n.length)!=null?e:void 0,z:r[8]||void 0,plusMinus:r[9]||void 0,hourOffset:xi(r[10]),minuteOffset:xi(r[11])}:null}function xi(t,e=0){return Number(t)||e}let Lue=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,jue=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,Bue=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Fue="^\\d{4}-\\d{2}-\\d{2}",Vue="\\d{2}:\\d{2}:\\d{2}",zue="(([+-]\\d{2}(:?\\d{2})?)|Z)",Hue=new RegExp(`${Fue}T${Vue}(\\.\\d+)?${zue}$`),Wue=t=>sa(t)||t===t.trim(),Uue={}.toString();function aa(){return new eA}class eA extends ti{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,n)=>{if(!this.spec.coerce||this.isType(e)||Array.isArray(e))return e;const r=e!=null&&e.toString?e.toString():e;return r===Uue?e:r})})}required(e){return super.required(e).withMutation(n=>n.test({message:e||Vo.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(n=>n.OPTIONS.name!=="required"),e))}length(e,n=wr.length){return this.test({message:n,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,n=wr.min){return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,n=wr.max){return this.test({name:"max",exclusive:!0,message:n,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,n){let r=!1,o,i;return n&&(typeof n=="object"?{excludeEmptyString:r=!1,message:o,name:i}=n:o=n),this.test({name:i||"matches",message:o||wr.matches,params:{regex:e},skipAbsent:!0,test:s=>s===""&&r||s.search(e)!==-1})}email(e=wr.email){return this.matches(Lue,{name:"email",message:e,excludeEmptyString:!0})}url(e=wr.url){return this.matches(jue,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=wr.uuid){return this.matches(Bue,{name:"uuid",message:e,excludeEmptyString:!1})}datetime(e){let n="",r,o;return e&&(typeof e=="object"?{message:n="",allowOffset:r=!1,precision:o=void 0}=e:n=e),this.matches(Hue,{name:"datetime",message:n||wr.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:n||wr.datetime_offset,params:{allowOffset:r},skipAbsent:!0,test:i=>{if(!i||r)return!0;const s=C0(i);return s?!!s.z:!1}}).test({name:"datetime_precision",message:n||wr.datetime_precision,params:{precision:o},skipAbsent:!0,test:i=>{if(!i||o==null)return!0;const s=C0(i);return s?s.precision===o:!1}})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=wr.trim){return this.transform(n=>n!=null?n.trim():n).test({message:e,name:"trim",test:Wue})}lowercase(e=wr.lowercase){return this.transform(n=>sa(n)?n:n.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>sa(n)||n===n.toLowerCase()})}uppercase(e=wr.uppercase){return this.transform(n=>sa(n)?n:n.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>sa(n)||n===n.toUpperCase()})}}aa.prototype=eA.prototype;let tA=new Date(""),que=t=>Object.prototype.toString.call(t)==="[object Date]";function Ex(){return new Xu}class Xu extends ti{constructor(){super({type:"date",check(e){return que(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,n)=>!this.spec.coerce||this.isType(e)||e===null?e:(e=$ue(e),isNaN(e)?Xu.INVALID_DATE:new Date(e)))})}prepareParam(e,n){let r;if(Na.isRef(e))r=e;else{let o=this.cast(e);if(!this._typeCheck(o))throw new TypeError(`\`${n}\` must be a Date or a value that can be \`cast()\` to a Date`);r=o}return r}min(e,n=S0.min){let r=this.prepareParam(e,"min");return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(o){return o>=this.resolve(r)}})}max(e,n=S0.max){let r=this.prepareParam(e,"max");return this.test({message:n,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(o){return o<=this.resolve(r)}})}}Xu.INVALID_DATE=tA;Ex.prototype=Xu.prototype;Ex.INVALID_DATE=tA;function Kue(t,e=[]){let n=[],r=new Set,o=new Set(e.map(([s,a])=>`${s}-${a}`));function i(s,a){let l=ha.split(s)[0];r.add(l),o.has(`${a}-${l}`)||n.push([a,l])}for(const s of Object.keys(t)){let a=t[s];r.add(s),Na.isRef(a)&&a.isSibling?i(a.path,s):kx(a)&&"deps"in a&&a.deps.forEach(l=>i(l,s))}return xue.array(Array.from(r),n).reverse()}function ZE(t,e){let n=1/0;return t.some((r,o)=>{var i;if((i=e.path)!=null&&i.includes(r))return n=o,!0}),n}function nA(t){return(e,n)=>ZE(t,e)-ZE(t,n)}const Yue=(t,e,n)=>{if(typeof t!="string")return t;let r=t;try{r=JSON.parse(t)}catch{}return n.isType(r)?r:t};function qf(t){if("fields"in t){const e={};for(const[n,r]of Object.entries(t.fields))e[n]=qf(r);return t.setFields(e)}if(t.type==="array"){const e=t.optional();return e.innerType&&(e.innerType=qf(e.innerType)),e}return t.type==="tuple"?t.optional().clone({types:t.spec.types.map(qf)}):"optional"in t?t.optional():t}const Gue=(t,e)=>{const n=[...ha.normalizePath(e)];if(n.length===1)return n[0]in t;let r=n.pop(),o=ha.getter(ha.join(n),!0)(t);return!!(o&&r in o)};let QE=t=>Object.prototype.toString.call(t)==="[object Object]";function eO(t,e){let n=Object.keys(t.fields);return Object.keys(e).filter(r=>n.indexOf(r)===-1)}const Jue=nA([]);function Ox(t){return new rA(t)}class rA extends ti{constructor(e){super({type:"object",check(n){return QE(n)||typeof n=="function"}}),this.fields=Object.create(null),this._sortErrors=Jue,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,n={}){var r;let o=super._cast(e,n);if(o===void 0)return this.getDefault(n);if(!this._typeCheck(o))return o;let i=this.fields,s=(r=n.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(o).filter(p=>!this._nodes.includes(p))),l={},u=Object.assign({},n,{parent:l,__validating:n.__validating||!1}),f=!1;for(const p of a){let m=i[p],g=p in o,v=o[p];if(m){let y;u.path=(n.path?`${n.path}.`:"")+p,m=m.resolve({value:v,context:n.context,parent:l});let x=m instanceof ti?m.spec:void 0,S=x==null?void 0:x.strict;if(x!=null&&x.strip){f=f||p in o;continue}y=!n.__validating||!S?m.cast(v,u):v,y!==void 0&&(l[p]=y)}else g&&!s&&(l[p]=v);(g!==p in l||l[p]!==v)&&(f=!0)}return f?l:o}_validate(e,n={},r,o){let{from:i=[],originalValue:s=e,recursive:a=this.spec.recursive}=n;n.from=[{schema:this,value:s},...i],n.__validating=!0,n.originalValue=s,super._validate(e,n,r,(l,u)=>{if(!a||!QE(u)){o(l,u);return}s=s||u;let f=[];for(let p of this._nodes){let m=this.fields[p];!m||Na.isRef(m)||f.push(m.asNestedTest({options:n,key:p,parent:u,parentPath:n.path,originalParent:s}))}this.runTests({tests:f,value:u,originalValue:s,options:n},r,p=>{o(p.sort(this._sortErrors).concat(l),u)})})}clone(e){const n=super.clone(e);return n.fields=Object.assign({},this.fields),n._nodes=this._nodes,n._excludedEdges=this._excludedEdges,n._sortErrors=this._sortErrors,n}concat(e){let n=super.concat(e),r=n.fields;for(let[o,i]of Object.entries(this.fields)){const s=r[o];r[o]=s===void 0?i:s}return n.withMutation(o=>o.setFields(r,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let n={};return this._nodes.forEach(r=>{var o;const i=this.fields[r];let s=e;(o=s)!=null&&o.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[r]})),n[r]=i&&"getDefault"in i?i.getDefault(s):void 0}),n}setFields(e,n){let r=this.clone();return r.fields=e,r._nodes=Kue(e,n),r._sortErrors=nA(Object.keys(e)),n&&(r._excludedEdges=n),r}shape(e,n=[]){return this.clone().withMutation(r=>{let o=r._excludedEdges;return n.length&&(Array.isArray(n[0])||(n=[n]),o=[...r._excludedEdges,...n]),r.setFields(Object.assign(r.fields,e),o)})}partial(){const e={};for(const[n,r]of Object.entries(this.fields))e[n]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return qf(this)}pick(e){const n={};for(const r of e)this.fields[r]&&(n[r]=this.fields[r]);return this.setFields(n,this._excludedEdges.filter(([r,o])=>e.includes(r)&&e.includes(o)))}omit(e){const n=[];for(const r of Object.keys(this.fields))e.includes(r)||n.push(r);return this.pick(n)}from(e,n,r){let o=ha.getter(e,!0);return this.transform(i=>{if(!i)return i;let s=i;return Gue(i,e)&&(s=Object.assign({},i),r||delete s[e],s[n]=o(i)),s})}json(){return this.transform(Yue)}exact(e){return this.test({name:"exact",exclusive:!0,message:e||Uf.exact,test(n){if(n==null)return!0;const r=eO(this.schema,n);return r.length===0||this.createError({params:{properties:r.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(e=!0,n=Uf.noUnknown){typeof e!="boolean"&&(n=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:n,test(o){if(o==null)return!0;const i=eO(this.schema,o);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,n=Uf.noUnknown){return this.noUnknown(!e,n)}transformKeys(e){return this.transform(n=>{if(!n)return n;const r={};for(const o of Object.keys(n))r[e(o)]=n[o];return r})}camelCase(){return this.transformKeys(fb.camelCase)}snakeCase(){return this.transformKeys(fb.snakeCase)}constantCase(){return this.transformKeys(e=>fb.snakeCase(e).toUpperCase())}describe(e){const n=(e?this.resolve(e):this).clone(),r=super.describe(e);r.fields={};for(const[i,s]of Object.entries(n.fields)){var o;let a=e;(o=a)!=null&&o.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[i]})),r.fields[i]=s.describe(a)}return r}}Ox.prototype=rA.prototype;const Xue=t=>{const{title:e,onSave:n,onCancel:r,onClose:o,modifyCitation:i,readOnly:s=!1,showCloseBtn:a=!1}=t,l=Z.useRef(null),[u,f]=Z.useState(!1),[p,m]=Z.useState(!1),[g,v]=Z.useState({type:"Url",source:"",title:"",accessedAt:null,url:"",classification:""});return Z.useEffect(()=>{i&&v({...i,type:"Url"})},[]),b.jsxs(b.Fragment,{children:[b.jsxs(z.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[b.jsx(z.Typography,{variant:"h6",margin:"10px 0",children:e}),a&&b.jsx(z.IconButton,{onClick:o,children:b.jsx(Xh,{})})]}),b.jsx(Ut.Formik,{innerRef:l,enableReinitialize:!0,initialValues:g,onSubmit:async y=>{f(!0),n(y).catch(x=>{throw f(!1),x}).finally(()=>f(!1))},validationSchema:Ox({source:aa().required("Source is required"),title:aa().required("Title is required"),accessedAt:Ex().required("Accessed At is required"),url:aa().required("URL is required"),classification:aa().required("Classification is required")}),validateOnBlur:p,validateOnChange:p,children:({handleSubmit:y})=>b.jsxs(Ut.Form,{autoComplete:"off",children:[b.jsxs(z.Box,{display:"flex",flexDirection:"column",gap:s?1:0,children:[b.jsx(xs,{name:"source",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(xs,{name:"title",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(Op,{name:"accessedAt",disabled:u,required:!0,margin:"none",isDatePicker:!0,readOnly:s}),b.jsx(xs,{name:"url",label:"URL",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(MI,{row:!0,name:"classification",required:!0,radios:[{label:"Public Source",value:"Public Source",helperText:"URL is accessible to anyone from any location without special permissions. You can safely access this URL on any computer, including public or shared devices."},{label:"Proprietary Source",value:"Proprietary Source",helperText:"For private, sensitive, or access-controlled content. Use a VPN, or take extra precautions, when accessing to protect your privacy."}],margin:"none",readOnly:s})]}),b.jsx(z.DialogActions,{sx:{px:0},children:s?b.jsx(z.Button,{onClick:r,size:"small",variant:"contained",children:"Back to Table"}):b.jsxs(b.Fragment,{children:[b.jsx(z.Button,{onClick:r,variant:"outlined",size:"small",children:"Cancel"}),b.jsx(Tx,{size:"small",loading:u,type:"button",onClick:()=>{m(!0),y()},children:i?"Update Citation":"Add New Citation"})]})})]})})]})},oA=t=>{const{gap:e=1,alignItems:n="center",...r}=t;return b.jsx(z.Box,{display:"flex",flexDirection:"row",gap:e,alignItems:n,...r})},Zue=t=>{const{title:e,onSave:n,onCancel:r,onClose:o,disableFileUpload:i=!1,modifyCitation:s,readOnly:a=!1,showCloseBtn:l=!1}=t,u=Z.useRef(null),[f,p]=Z.useState(!1),[m,g]=Z.useState(!1),[v,y]=Z.useState({type:"Attachment",title:"",file:void 0,fileName:""});return Z.useEffect(()=>{s&&y({...s,type:"Attachment",file:void 0})},[]),b.jsxs(b.Fragment,{children:[b.jsxs(z.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[b.jsx(z.Typography,{variant:"h6",margin:"10px 0",children:e}),l&&b.jsx(z.IconButton,{onClick:o,children:b.jsx(Xh,{})})]}),b.jsx(Ut.Formik,{innerRef:u,enableReinitialize:!0,initialValues:v,validationSchema:Ox().shape({title:aa().required("Title is required"),fileName:aa().required("A file is required")}),validateOnBlur:m,validateOnChange:m,onSubmit:async x=>{p(!0),n(x).catch(S=>{throw p(!1),S}).finally(()=>p(!1))},children:({values:x,setFieldValue:S,handleSubmit:k})=>{var T;return Z.useEffect(()=>{var C,O;(C=x.file)!=null&&C.name&&S("fileName",(O=x.file)==null?void 0:O.name)},[(T=x.file)==null?void 0:T.name]),b.jsxs(Ut.Form,{autoComplete:"off",children:[b.jsx(xs,{name:"title",disabled:f,required:!0,margin:"none",readOnly:a}),b.jsxs(z.Box,{marginTop:i||a?0:1,children:[b.jsxs(oA,{alignItems:"flex-start",children:[!i&&!a&&b.jsx(kI,{name:"file",errorMode:"hidden"}),b.jsx(xs,{readOnly:!0,name:"fileName",label:a||i?"File Name":""})]}),b.jsx(Mr,{name:"fileName"})]}),b.jsx(z.DialogActions,{sx:{px:0},children:a?b.jsx(z.Button,{onClick:r,size:"small",variant:"contained",children:"Back to Table"}):b.jsxs(b.Fragment,{children:[b.jsx(z.Button,{onClick:r,variant:"outlined",size:"small",children:"Cancel"}),b.jsx(Tx,{size:"small",loading:f,type:"button",onClick:()=>{g(!0),k()},children:s?"Update Attachment":"Upload Attachment"})]})})]})}})]})},Zu=t=>{const{open:e=!1,onClose:n,title:r,children:o,actions:i,closeBtnLabel:s,closeButtonPosition:a,closeButtonProps:l={},disableDismiss:u=!1,...f}=t;if(!e)return null;const p=a==="bottom"||a==="top-and-bottom",m=a==="top"||a==="top-and-bottom",g=()=>{if(s&&p)return b.jsx(z.Button,{className:"MBv2_Modal_Close",onClick:t.onClose,...l,children:s})},v=()=>{if(i)return b.jsx(z.DialogActions,{className:"MBv2_Modal_Actions",children:b.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",gap:"0.25rem",children:[b.jsx(z.Box,{children:g()}),b.jsxs(z.Box,{display:"flex",gap:".25rem",children:[...i]})]})});if(s&&p)return b.jsx(z.DialogActions,{className:"MBv2_Modal_Actions",children:b.jsx(z.Box,{children:g()})})};return b.jsxs(z.Dialog,{className:"MBv2_Modal",open:e,onClose:()=>{u||n==null||n()},...f,children:[typeof r=="string"?b.jsx(z.DialogTitle,{className:"MBv2_Modal_Title",children:b.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[r,m&&b.jsx(z.IconButton,{"data-testid":"modal-header-close-btn",onClick:n,children:b.jsx(Xh,{})})]})}):r,o&&(typeof o=="string"?b.jsx(z.DialogContent,{className:"MBv2_Modal_Content",children:b.jsx(z.DialogContentText,{className:"MBv2_Modal_Content_Text",children:o})}):o),v()]})};function Que(t){return We("MuiAlert",t)}const tO=Ve("MuiAlert",["root","action","icon","message","filled","colorSuccess","colorInfo","colorWarning","colorError","filledSuccess","filledInfo","filledWarning","filledError","outlined","outlinedSuccess","outlinedInfo","outlinedWarning","outlinedError","standard","standardSuccess","standardInfo","standardWarning","standardError"]),ede=De(b.jsx("path",{d:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"}),"SuccessOutlined"),tde=De(b.jsx("path",{d:"M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),nde=De(b.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutline"),rde=De(b.jsx("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"}),"InfoOutlined"),ode=De(b.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close"),ide=t=>{const{variant:e,color:n,severity:r,classes:o}=t,i={root:["root",`color${Ie(n||r)}`,`${e}${Ie(n||r)}`,`${e}`],icon:["icon"],message:["message"],action:["action"]};return He(i,Que,o)},sde=ne(Ms,{name:"MuiAlert",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.variant],e[`${n.variant}${Ie(n.color||n.severity)}`]]}})(yt(({theme:t})=>{const e=t.palette.mode==="light"?ya:Ol,n=t.palette.mode==="light"?Ol:ya;return{...t.typography.body2,backgroundColor:"transparent",display:"flex",padding:"6px 16px",variants:[...Object.entries(t.palette).filter(jn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"standard"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),backgroundColor:t.vars?t.vars.palette.Alert[`${r}StandardBg`]:n(t.palette[r].light,.9),[`& .${tO.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(jn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"outlined"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),border:`1px solid ${(t.vars||t).palette[r].light}`,[`& .${tO.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(jn(["dark"])).map(([r])=>({props:{colorSeverity:r,variant:"filled"},style:{fontWeight:t.typography.fontWeightMedium,...t.vars?{color:t.vars.palette.Alert[`${r}FilledColor`],backgroundColor:t.vars.palette.Alert[`${r}FilledBg`]}:{backgroundColor:t.palette.mode==="dark"?t.palette[r].dark:t.palette[r].main,color:t.palette.getContrastText(t.palette[r].main)}}}))]}})),ade=ne("div",{name:"MuiAlert",slot:"Icon",overridesResolver:(t,e)=>e.icon})({marginRight:12,padding:"7px 0",display:"flex",fontSize:22,opacity:.9}),lde=ne("div",{name:"MuiAlert",slot:"Message",overridesResolver:(t,e)=>e.message})({padding:"8px 0",minWidth:0,overflow:"auto"}),cde=ne("div",{name:"MuiAlert",slot:"Action",overridesResolver:(t,e)=>e.action})({display:"flex",alignItems:"flex-start",padding:"4px 0 0 16px",marginLeft:"auto",marginRight:-8}),nO={success:b.jsx(ede,{fontSize:"inherit"}),warning:b.jsx(tde,{fontSize:"inherit"}),error:b.jsx(nde,{fontSize:"inherit"}),info:b.jsx(rde,{fontSize:"inherit"})},iA=D.forwardRef(function(e,n){const r=ht({props:e,name:"MuiAlert"}),{action:o,children:i,className:s,closeText:a="Close",color:l,components:u={},componentsProps:f={},icon:p,iconMapping:m=nO,onClose:g,role:v="alert",severity:y="success",slotProps:x={},slots:S={},variant:k="standard",...T}=r,C={...r,color:l,severity:y,variant:k,colorSeverity:l||y},O=ide(C),R={slots:{closeButton:u.CloseButton,closeIcon:u.CloseIcon,...S},slotProps:{...f,...x}},[P,N]=Et("root",{ref:n,shouldForwardComponentProp:!0,className:ge(O.root,s),elementType:sde,externalForwardedProps:{...R,...T},ownerState:C,additionalProps:{role:v,elevation:0}}),[V,M]=Et("icon",{className:O.icon,elementType:ade,externalForwardedProps:R,ownerState:C}),[j,F]=Et("message",{className:O.message,elementType:lde,externalForwardedProps:R,ownerState:C}),[L,A]=Et("action",{className:O.action,elementType:cde,externalForwardedProps:R,ownerState:C}),[_,I]=Et("closeButton",{elementType:Jl,externalForwardedProps:R,ownerState:C}),[B,W]=Et("closeIcon",{elementType:ode,externalForwardedProps:R,ownerState:C});return b.jsxs(P,{...N,children:[p!==!1?b.jsx(V,{...M,children:p||m[y]||nO[y]}):null,b.jsx(j,{...F,children:i}),o!=null?b.jsx(L,{...A,children:o}):null,o==null&&g?b.jsx(L,{...A,children:b.jsx(_,{size:"small","aria-label":a,title:a,color:"inherit",onClick:g,...I,children:b.jsx(B,{fontSize:"small",...W})})}):null]})});process.env.NODE_ENV!=="production"&&(iA.propTypes={action:c.node,children:c.node,classes:c.object,className:c.string,closeText:c.string,color:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),components:c.shape({CloseButton:c.elementType,CloseIcon:c.elementType}),componentsProps:c.shape({closeButton:c.object,closeIcon:c.object}),icon:c.node,iconMapping:c.shape({error:c.node,info:c.node,success:c.node,warning:c.node}),onClose:c.func,role:c.string,severity:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),slotProps:c.shape({action:c.oneOfType([c.func,c.object]),closeButton:c.oneOfType([c.func,c.object]),closeIcon:c.oneOfType([c.func,c.object]),icon:c.oneOfType([c.func,c.object]),message:c.oneOfType([c.func,c.object]),root:c.oneOfType([c.func,c.object])}),slots:c.shape({action:c.elementType,closeButton:c.elementType,closeIcon:c.elementType,icon:c.elementType,message:c.elementType,root:c.elementType}),sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),variant:c.oneOfType([c.oneOf(["filled","outlined","standard"]),c.string])});const Qu=t=>{var g;const{noIcon:e=!1,children:n,severity:r="success",variant:o="leftBorder",sx:i,title:s,...a}=t,{palette:l}=z.useTheme(),u=e?{icon:!1}:{},f=o==="leftBorder"?"standard":o,p=o==="leftBorder"?{...i,borderLeft:`4px solid ${(g=l[r])==null?void 0:g.main}`}:i,m=s?{icon:{sx:{mt:"6px"}}}:{};return b.jsxs(iA,{severity:r,variant:f,sx:p,slotProps:m,...u,...a,children:[s&&b.jsx(z.Typography,{variant:"h3",children:s}),n]})},sA=t=>b.jsx(Qu,{severity:"error",...t}),aA=t=>b.jsx(Qu,{severity:"success",...t}),ude=t=>{const{alert:e,setAlert:n}=t,r=()=>n(void 0);return b.jsxs(b.Fragment,{children:[(e==null?void 0:e.type)==="Error"&&b.jsx(sA,{"data-testid":"citation-menu-error",onClose:r,title:e.title,children:e.message.toString()}),(e==null?void 0:e.type)==="Success"&&b.jsx(aA,{"data-testid":"citation-menu-success",onClose:r,children:e.message})]})};function lA({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,onSelectCitations:a,onCancel:l,initialSelectedIds:u=[],onContentChange:f,onError:p=()=>{},renderAsSelectablePopup:m=!1,addlActions:g,canLaunchUrl:v,readOnly:y}){const[x,S]=Z.useState("Insert Citation/Attachment(s)"),[k,T]=Z.useState(u),[C,O]=Z.useState(void 0),[R,P]=Z.useState(void 0),N=G=>{P(void 0),S(G)},[V,M]=Z.useState(0);Z.useEffect(()=>{f==null||f()},[x,R,f]);const j=(G=!1)=>{(!m||G)&&M(te=>te+1)},F=(G,te)=>{var de;const ue=typeof((de=te.response)==null?void 0:de.data)=="string"&&te.response.data,re=typeof te.message=="string"&&te.message;P({type:"Error",title:G,message:ue??re}),p(te)},L=G=>P({type:"Success",title:"",message:G}),A=async G=>{if(x==="Insert Citation/Attachment(s)")throw Error("onSave called with invalid state");if(x==="Edit Citation"||x==="Edit Attachment"){if(G.id===void 0)throw Error("Failed to update citation. Citation is missing id");await(n==null?void 0:n(G).then(()=>{N("Insert Citation/Attachment(s)"),j()}).catch(ue=>{F("Failed to update",ue)}))}else await(e==null?void 0:e(G).then(ue=>{T([...k,ue.id]),N("Insert Citation/Attachment(s)"),j()}).catch(ue=>{F("Failed to create",ue)}))},_=r&&(async G=>r(G).then(()=>{j(!0),T(k.filter(te=>te!==G)),L("Successfully deleted")}).catch(te=>F("Failed to delete",te))),I=(G,te)=>{o(G.id).then(ue=>{O(ue),N(te)}).catch(ue=>{F("Failed to load",ue)})},B=i&&(async G=>i(G).catch(te=>{F(`Failed to download ${G.fileName}`,te)})),W=s&&(async G=>s(G).catch(te=>{F(`Failed to view ${G.fileName}`,te)})),K=b.jsx(mue,{refreshKey:V,getCitationsPaginated:G=>t(G).then(te=>(f==null||f(),te)),onCancel:l,onNewCitation:()=>{O(void 0),N("Add Citation")},onNewAttachment:()=>{O(void 0),N("Add Attachment")},onEditCitation:G=>I(G,y?"View Citation":"Edit Citation"),onEditAttachment:G=>I(G,y?"View Attachment":"Edit Attachment"),onDeleteCitation:_,onDownloadAttachment:B,onViewAttachment:W,onSelect:a,setSelectedIds:T,selectedIds:k,onError:p,condenseTable:m,canSelect:m,title:m&&!y?x:"Attachments & Citations",addlActions:g,canCreate:!!e,canEdit:!!n,canDelete:!!_,canLaunchUrl:v,readOnly:y,showCloseBtn:m}),U=b.jsx(Xue,{modifyCitation:C,onSave:A,onCancel:()=>N("Insert Citation/Attachment(s)"),onClose:l,title:x,readOnly:x==="View Citation",showCloseBtn:m}),Y=b.jsx(Zue,{onSave:A,onCancel:()=>N("Insert Citation/Attachment(s)"),onClose:l,modifyCitation:C,disableFileUpload:x==="Edit Attachment",title:x,readOnly:x==="View Attachment",showCloseBtn:m}),oe=b.jsx(ude,{alert:R,setAlert:P}),fe=x==="Add Citation"||x==="Edit Citation"||x==="View Citation",he=x==="Add Attachment"||x==="Edit Attachment"||x==="View Attachment";if(m){let G=null;return!m||x==="Insert Citation/Attachment(s)"?G=K:fe?G=U:he&&(G=Y),b.jsxs(z.Box,{width:"500px",children:[oe,b.jsx(z.Box,{paddingTop:"8px",children:G})]})}return b.jsxs(z.Box,{width:"100%",children:[x==="Insert Citation/Attachment(s)"&&oe,b.jsx(z.Box,{paddingTop:"8px",children:K}),b.jsx(Zu,{open:fe||he,children:b.jsxs(z.Box,{padding:"10px 20px",minWidth:"400px","data-testid":"citation-form-modal",children:[oe,fe?U:Y]})})]})}function cA({...t}){return b.jsx(lA,{renderAsSelectablePopup:!0,...t})}const dde=z.styled("div",{name:"CitationBubbleMenu",slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>{const e=t.palette.mode==="dark";return{padding:t.spacing(1.5,2,.5),backgroundColor:e?"#101010":"#f9f9f9",border:`1px solid ${t.palette.grey[e?700:200]}`}});function fde({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,canLaunchUrl:a,readOnly:l,...u}){const f=Ct();if(f&&!("citationBubbleMenuHandler"in(f==null?void 0:f.storage)))throw new Error("You must add the CitationBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const p=f==null?void 0:f.storage.citationBubbleMenuHandler,m=p.isOpen,g=p.selectedIds,v=p.selectedNodePos,y=T=>{f&&(T.length===0?f.commands.deleteCitation(v):g.length===0?f.commands.insertCitation({ids:T}):f.commands.updateCitation({ids:T},v))},x=T=>{y(T),f==null||f.commands.closeCitationBubbleMenu()},S=()=>{y(g),f==null||f.commands.closeCitationBubbleMenu()},k=Z.useCallback(()=>{requestAnimationFrame(()=>{f!=null&&f.view&&f.view.dispatch(f.view.state.tr)})},[f]);return f?b.jsx(bv,{editor:f,open:m,...p.bubbleMenuOptions,...u,children:b.jsx(dde,{children:b.jsx(cA,{getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,onSelectCitations:x,onCancel:S,initialSelectedIds:g,onContentChange:k,canLaunchUrl:a,readOnly:l})})}):null}const pde=()=>mn.create({name:"citationBubbleMenuHandler",addStorage(){return{isOpen:!1,selectedIds:[],bubbleMenuOptions:void 0,selectedNodePos:0}},addCommands(){return{openCitationBubbleMenu:(t={},e)=>({editor:n,dispatch:r})=>{var a;const{doc:o}=n.state,i=o.nodeAt(e??0),s=((a=i==null?void 0:i.attrs)==null?void 0:a.ids)??[];return r&&(this.storage.isOpen=!0,this.storage.selectedIds=s,this.storage.bubbleMenuOptions=t,this.storage.selectedNodePos=e??0),!0},closeCitationBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.isOpen?(t.focus(),e&&(this.storage.isOpen=!1,this.storage.selectedIds=[],this.storage.selectedNodePos=0),!0):!1}},onSelectionUpdate(){this.storage.isOpen&&!this.editor.isActive("citation")&&this.editor.commands.closeCitationBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-c":()=>(this.editor.commands.openCitationBubbleMenu(),!0)}}});function hde(t){const e=Ct(),n=Z.useRef(null);return b.jsx(wt,{buttonRef:n,tooltipLabel:"Insert Citation/Attachment",tooltipShortcutKeys:["mod","Shift","C"],disabled:!(e!=null&&e.isEditable),onClick:()=>e==null?void 0:e.commands.openCitationBubbleMenu({anchorEl:n.current,placement:"bottom"}),...t,children:b.jsxs(z.Box,{display:"flex",flexDirection:"row",gap:"4px",alignItems:"center",children:[b.jsx(Cne,{fontSize:"small"}),b.jsx(z.Typography,{variant:"body2",children:"Insert Citation/Attachment"})]})})}const uA=Z.createContext(void 0),dA=()=>{const t=Z.useContext(uA);if(!t)throw new Error("useSync must be used inside CitationFieldProvider");return t},mde=({node:t,HTMLAttributes:e,selected:n,extension:r,updateAttributes:o,deleteNode:i})=>{const s=t.attrs.ids||[],{citations:a,isLoaded:l}=dA(),[u,f]=Z.useState(s?String(s):""),[p,m]=Z.useState([]),g=r.options.citationMaxLength;if(Z.useEffect(()=>{if(!l)return;const v=a.filter(S=>s.includes(S.id)),y=v.map(S=>ka.truncate(S.title,{length:g,omission:"..."})).join(", ");f(y),m(v);const x=v.map(S=>S.id);x.length===0?setTimeout(i,0):x.length!==s.length&&setTimeout(()=>o({ids:v.map(S=>S.id)}),0)},[a,s,l]),p.length!==0)return b.jsx(zv,{as:"span",...e,"data-testid":"citation-node-component",children:b.jsx(z.Tooltip,{title:b.jsx(z.Box,{className:"citation-tooltip",children:p.map((v,y)=>{var S;const x=[v.source,v.title,v.fileName,v.url,(S=v.accessedAt)==null?void 0:S.slice(0,10),v.classification];return b.jsxs(z.Typography,{variant:"subtitle2",children:[x.filter(Boolean).join(" | "),y<p.length-1&&b.jsx(z.Divider,{className:"citation-tooltip-divider"})]},v.id)})}),slotProps:{tooltip:{sx:{maxWidth:500}}},children:b.jsx("a",{href:"#",onClick:v=>{v.preventDefault(),v.stopPropagation()},className:n?"selected-citation-link":"citation-link",children:u})})})},gde=nn.create({name:"citation",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes(){return{ids:{default:[],parseHTML:t=>{const e=t.getAttribute("ids");return e?e.split(",").map(n=>parseInt(n.trim(),10)).filter(n=>!isNaN(n)):[]},renderHTML:t=>({ids:Array.isArray(t.ids)?t.ids.join(","):""})}}},parseHTML(){return[{tag:"citation"}]},renderHTML({HTMLAttributes:t}){return["citation",St(t)]},addNodeView(){return Hv(mde)},addProseMirrorPlugins(){return[new rn({props:{handleClickOn:(t,e,n,r,o,i)=>n&&n.type.name==="citation"?(this.editor.commands.openCitationBubbleMenu({},r),!0):!1}})]},addCommands(){return{insertCitation:t=>({commands:e})=>e.insertContent({type:"citation",attrs:t}),updateCitation:(t,e)=>({state:n,dispatch:r,tr:o})=>{const i=n.doc.nodeAt(e);return!i||i.type.name!=="citation"?!1:(o.setNodeMarkup(e,void 0,t),r&&r(o),!0)},deleteCitation:t=>({tr:e,dispatch:n})=>{if(typeof t!="number")return!1;const r=t,o=t+1;return n&&n(e.delete(r,o)),!0}}}}),fA=t=>b.jsx(TI,{name:t.name,label:"Not Applicable",errorMode:"hidden"}),yde=t=>{const{name:e,label:n=Fn(e),hideLabel:r=!1,required:o=!1,readOnly:i,margin:s="dense",citationMaxLength:a=24,getCitationsPaginated:l,onCreateCitation:u,onUpdateCitation:f,onDeleteCitation:p,getCitationById:m,onDownloadAttachment:g,onViewAttachment:v,onError:y=()=>{},placeholder:x="Start typing here...",notApplicableName:S,errorMode:k="normal",canLaunchUrl:T}=t,C=[DR,zD.configure({placeholder:x}),pde(),gde.configure({citationMaxLength:a})],[O,R,P]=Ut.useField({name:e}),{setValue:N}=P,{value:V}=O,{addUpdateCitation:M,deleteCitation:j,batchUpdate:F,citations:L}=dA();Z.useEffect(()=>{var he;const oe=(he=A==null?void 0:A.current)==null?void 0:he.editor;if(!oe)return;oe.getHTML()!==V&&setTimeout(()=>{oe.commands.setContent(V)},0)},[V]);const A=Z.useRef(null),_={normal:{marginTop:"16px",marginBottom:"8px"},dense:{marginTop:"8px",marginBottom:"4px"},none:{margin:0}},I=(oe=void 0)=>{var G,te;const fe=((te=(G=A.current)==null?void 0:G.editor)==null?void 0:te.getHTML())??"",he=!fe.replace(/<\/?p>|<br>/g,"").trim();N(he?"":fe,oe)},B=Z.useMemo(()=>ka.debounce(()=>I(!1),500),[N]),W=_a(),{showDiff:K,getPreviousValue:U}=Ra(),Y=i??W;if(K){const oe=U(e)??"",fe=V,he=/<citation\s+ids="([^"]*)"><\/citation>/g,G=(re,ie)=>{const de=ie.split(",").map(Number);return`<sup>${L.filter(ye=>de.includes(ye.id)).map(ye=>ye.title)}</sup>`},te=oe.replace(he,G),ue=fe.replace(he,G);return b.jsx(Aa,{label:n,value:ue,showDiff:!0,diffSnapshot:te,mode:"html"})}return b.jsxs(z.Box,{id:`citation-field_${e}`,sx:{"& .ProseMirror":{"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:Y?0:50}},".MuiTiptap-RichTextContent-readonly ":{padding:0}},..._[s],display:"flex",flexDirection:"column",width:"100%",children:[b.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[!r&&b.jsx(z.InputLabel,{htmlFor:`citation-field_${e}`,required:o,children:n}),S&&b.jsx(fA,{name:S})]}),b.jsx(yI,{ref:A,extensions:C,content:V,editable:!Y,renderControls:Y?void 0:()=>b.jsx(Lv,{children:b.jsx(hde,{})}),onBlur:()=>I(),onUpdate:B,RichTextFieldProps:{variant:Y?"standard":"outlined",MenuBarProps:{hide:Y}},children:()=>b.jsx(fde,{getCitationsPaginated:oe=>l(oe).then(fe=>(F(fe.data),fe)),onCreateCitation:u&&(oe=>u(oe).then(fe=>(M(fe),fe))),onUpdateCitation:f&&(oe=>f(oe).then(fe=>(M(fe),fe))),onDeleteCitation:p&&(oe=>p(oe).then(()=>j(oe))),getCitationById:m,onDownloadAttachment:g,onViewAttachment:v,onError:y,canLaunchUrl:T,readOnly:Y})}),b.jsx(Mr,{name:e,id:`${e}-err`,errorMode:k})]})},bde=t=>{const{name:e="submit"}=t;return b.jsx(ao,{name:e,type:"submit",...t})},vde=t=>{const{label:e="Return to Top",icon:n=$f,scrollThresholdPx:r=100}=t,o=z.useScrollTrigger({threshold:r}),i=Z.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"})},[]);return b.jsx(z.Zoom,{in:o,children:b.jsx(z.Box,{sx:{position:"fixed",bottom:32,right:32,zIndex:1},children:b.jsxs(z.Fab,{onClick:i,color:"primary",size:"small",variant:"extended","aria-label":"Scroll back to top",children:[b.jsx(n,{fontSize:"medium"}),e]})})})},pA=t=>{const{label:e,menuOptions:n=[],icon:r}=t,o=ko.useNavigate(),[i,s]=D.useState(null),a=!!i,l=p=>{s(p.currentTarget)},u=()=>{s(null)};if(n.length===0)return null;const f=r&&!e;return b.jsxs(b.Fragment,{children:[b.jsx(z.Button,{startIcon:f?void 0:r,variant:"outlined",color:"inherit",sx:{minWidth:0,...f&&{paddingLeft:"6px",paddingRight:"6px"}},onClick:l,children:f?r:e}),b.jsx(z.Menu,{anchorEl:i,open:a,onClick:u,children:n.map(p=>b.jsxs(z.MenuItem,{..._u(p,o),children:[p.icon&&b.jsx(z.ListItemIcon,{children:p.icon}),b.jsx(z.ListItemText,{primary:p.label})]},p.label))})]})},xde=()=>{const{values:t,errors:e,status:n}=Ut.useFormikContext(),{palette:r}=z.useTheme();return b.jsx(z.Paper,{style:{backgroundColor:r.mode==="dark"?"#303030":"#f0f0f0",margin:"10px 0"},children:b.jsxs(z.List,{children:[b.jsxs(z.ListItem,{children:[b.jsx(z.Typography,{display:"block",variant:"h6",children:"Values"}),b.jsx("br",{}),b.jsx(z.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(t,null,2)})]}),b.jsx(z.Divider,{variant:"inset",component:"li"}),b.jsxs(z.ListItem,{id:"testing",children:[b.jsx(z.Typography,{display:"block",variant:"h6",children:"Errors"}),b.jsx("br",{}),b.jsx(z.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(e,null,2)})]}),b.jsxs(z.ListItem,{children:[b.jsx(z.Typography,{display:"block",variant:"h6",children:"Status"}),b.jsx("br",{}),b.jsx(z.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(n,null,2)})]})]})})},wde=t=>{const{steps:e,orientation:n,inlineLabel:r=n=="vertical",isResponsive:o=!1}=t,{width:i}=UD();let s=!r,a=n;o&&(n&&console.warn("Stepper: Ignoring orientation. isResponsive is set to true, so the orientation is determined automatically based on the window size."),a=i<600?"vertical":"horizontal",a=="vertical"?s=!1:s=!r),n=="vertical"&&!r&&(console.warn("Stepper: ignoring inlineLabel={false}. Must use inline labels when orientation is vertical"),s=!1);const l=["steps","inlineLabel","orientation","isResponsive"],u={alternativeLabel:s,orientation:a,...hr({...t},l)};return b.jsx(z.Stepper,{...u,children:e.map(f=>b.jsx(z.Step,{children:b.jsx(z.StepLabel,{children:f})},f))})},Sde=t=>{const{name:e,label:n=Fn(e),labelProps:r={fontSize:"1.1em",color:"#808080",fontWeight:"600"},initialState:o,renderFormGroup:i,addButtonContent:s="Add Another",removeButtonContent:a=t.removePosition==="right"?b.jsx(DI,{}):"Remove",variant:l="card",addButtonSx:u,removeButtonSx:f,allowRemoveAll:p=!1,readOnly:m=!1,emptyListMsg:g="None",showDivider:v=!1,removePosition:y="bottom"}=t,[x]=Ut.useField({name:e}),{value:S}=x,k=T=>({display:"flex",flexDirection:T==="bottom"?"column":"row",alignItems:T==="bottom"?"flex-start":"center"});return b.jsxs(z.FormControl,{fullWidth:!0,children:[b.jsx(z.Typography,{...r,children:n}),m&&x.value.length===0?b.jsx(z.Typography,{children:g}):b.jsx(Ut.FieldArray,{name:e,render:T=>b.jsxs("div",{children:[S.map((C,O)=>b.jsx(Z.Fragment,{children:b.jsx(Cde,{variant:l,content:b.jsxs(z.Box,{"data-testid":"form-group-container",sx:typeof y=="string"?k(y):{...y},children:[b.jsxs(z.Box,{width:"100%",children:[i(`${e}.${O}`,O),v&&O!==S.length-1&&b.jsx(z.Divider,{"data-testid":"divider"})]}),!m&&S.length>(p?0:1)&&b.jsx(z.Button,{"data-testid":"repeatable-form-group_remove-btn",sx:f,onClick:()=>T.remove(O),children:a})]})})},`${e}-${O}`)),!m&&b.jsx(z.Button,{"data-testid":"repeatable-form-group_add-btn",onClick:()=>T.push(o),sx:u,children:s})]})})]})},Cde=({variant:t,content:e})=>{switch(t){case"card":return b.jsx(z.Card,{"data-testid":"repeatable-form-group_card",sx:{padding:"8px",marginBottom:"8px"},children:b.jsx(z.CardContent,{children:e})});case"elevatedCard":return b.jsx(z.Card,{"data-testid":"repeatable-form-group_elevated-card",elevation:4,sx:{border:"unset",padding:"8px",marginBottom:"8px"},children:b.jsx(z.CardContent,{children:e})});case"none":return e}},Tde=t=>{const{confirmBtnLabel:e,onConfirm:n,confirmButtonProps:r={color:"primary",variant:"contained"},closeBtnLabel:o="Cancel",closeButtonPosition:i="bottom",...s}=t;return b.jsx(Zu,{actions:[b.jsx(z.Button,{className:"MBv2_ConfirmationModal_ConfirmBtn",onClick:n,...r,children:e})],closeBtnLabel:o,closeButtonPosition:i,...s})},kde=t=>{const{closeBtnLabel:e="OK",closeButtonPosition:n="bottom",closeButtonProps:r={color:"primary",variant:"contained"},...o}=t;return b.jsx(Zu,{closeBtnLabel:e,closeButtonPosition:n,closeButtonProps:r,...o})},Ede=t=>{const{primaryBtnLabel:e,onPrimaryAction:n,primaryActionProps:r={color:"primary",variant:"contained"},secondaryBtnLabel:o,onSecondaryAction:i,secondaryActionProps:s={color:"primary",variant:"outlined"},closeBtnLabel:a="Cancel",closeButtonPosition:l="bottom",...u}=t;return b.jsx(Zu,{actions:[b.jsx(z.Button,{className:"MBv2_DecisionModal_SecondaryAction",onClick:i,...s,children:o}),b.jsx(z.Button,{className:"MBv2_DecisionModal_PrimaryAction",onClick:n,...r,children:e})],closeBtnLabel:a,closeButtonPosition:l,...u})},Ode={added:{icon:wne,label:"Added",color:"success"},deleted:{icon:DI,label:"Deleted",color:"error"},modified:{icon:Tne,label:"Modified",color:"info"}},hA=t=>{const{beforeData:e,afterData:n,emptyTableMsg:r="No changes to display",columns:o,isEqual:i,size:s}=t;t.renderExpand!=null&&t.isEqual==null&&console.warn("DiffTable: isEqual prop should be provided when renderExpand is provided");const a=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),{dataDiff:l,unmodifiedCount:u}=Z.useMemo(()=>Rde(o,e,n,a,i),[e,n,o,a,i]),f=o.map(p=>({...p,render:(m,g)=>{var v;return((v=g.modifiedDiff)==null?void 0:v[xn(p)])??Mu(p,g,a)}}));return b.jsxs(z.Box,{children:[b.jsx(Cx,{columns:[{fieldName:"changeType",render:p=>{const m=Ode[p];return b.jsx(z.Chip,{color:m.color,size:s=="medium"?"medium":"small",label:b.jsxs(z.Typography,{children:[b.jsx(I0,{icon:m.icon}),m.label]})})}},...f],data:l,emptyTableMsg:r,renderExpand:t.renderExpand?p=>{const m=e.find(g=>g.id===p.id);return b.jsx(wM,{previousSnapshot:m,currentSnapshot:p,showDiff:p.changeType==="modified",children:t.renderExpand(p)})}:void 0,size:s}),u>0&&b.jsx(z.Box,{children:b.jsxs(z.Typography,{fontStyle:"italic",children:["+",u," unmodified rows"]})})]})},Mde=(t,e)=>b.jsxs(b.Fragment,{children:[b.jsx(z.Box,{"data-testid":"diff-table-cell-removed",sx:{backgroundColor:wp},children:b.jsx("s",{children:t})}),b.jsx(z.Box,{"data-testid":"diff-table-cell-added",sx:{backgroundColor:xp},children:b.jsx("u",{children:e})})]}),_de=(t,e,n,r=!1)=>{var i;let o={};for(const s of t)if(!s.ignoreDiff){const a=Mu(s,e,r),l=Mu(s,n,r);(((i=s.isEqual)==null?void 0:i.call(s,e,n))??ka.isEqual(a,l))||(o[xn(s)]=Mde(a,l))}return o},Rde=(t,e,n,r=!1,o)=>{const i=[];let s=0,a=0,l=0;for(e.sort((u,f)=>u.id-f.id),n.sort((u,f)=>u.id-f.id);s<e.length&&a<n.length;){const u=e[s],f=n[a];if(u.id===f.id){const p=_de(t,u,f,r);(o==null?void 0:o(u,f))??Object.keys(p).length===0?l++:i.push({...f,changeType:"modified",modifiedDiff:p}),s++,a++}else u.id<f.id?(i.push({...u,changeType:"deleted"}),s++):(i.push({...f,changeType:"added"}),a++)}for(;s<e.length;)i.push({...e[s],changeType:"added"}),s++;for(;a<n.length;)i.push({...n[a],changeType:"added"}),a++;return{dataDiff:i,unmodifiedCount:l}},Ide=t=>{const{beforeCitations:e,afterCitations:n,condenseTable:r=!1}=t,{palette:o}=z.useTheme(),i=qD(o,r);return b.jsxs(z.Box,{children:[!r&&b.jsx(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"10px",children:b.jsx(z.Typography,{variant:"h2",children:" Attachments & Citations"})}),b.jsx(hA,{columns:i,beforeData:e,afterData:n,size:r?"x-small":"medium"})]})},Dde=t=>{const{featureMenuOptions:e=[],copyright:n,logo:r,sx:o={},fontColor:i="primary"}=t,{palette:s}=z.useTheme(),a=ko.useNavigate();return b.jsxs(z.Box,{className:"MBv2_Footer",sx:{backgroundColor:s.mode==="dark"?"#222222":"#ededed",padding:"25px 30px",...o},children:[b.jsx(z.Box,{className:"MBv2_Footer_Logo",sx:{display:"flex",gap:2,alignItems:"center",paddingBottom:1},children:typeof r=="string"?b.jsx("img",{draggable:"false",src:r,style:{width:"200px"},alt:"logo"}):r}),b.jsxs(z.Box,{display:"flex",justifyContent:"space-between",flexWrap:"wrap",className:"MBv2_Footer_Nav_Links_Container",gap:2,children:[b.jsx(z.Box,{sx:{flexGrow:1},className:"MBv2_Footer_Nav_Links",display:"flex",flexDirection:"row",justifyContent:"flex-start",gap:3,children:e==null?void 0:e.map(l=>b.jsx(z.Link,{"data-testid":l.label,sx:{cursor:"pointer",fontSize:15},color:i,..._u(l,a),children:l.label},l.label))}),n&&b.jsx(z.Typography,{style:{fontSize:15},"data-testid":"copyright",className:"MBv2_Footer_Copyright",color:i,children:n})]})]})},mA=t=>{const{menuOptionLists:e,anchor:n="left",children:r}=t,{pathname:o}=ko.useLocation(),i=ko.useNavigate(),[s,a]=Z.useState(!1),l=(m,g)=>b.jsx(z.MenuList,{children:m.map(v=>b.jsxs(z.MenuItem,{..._u(v,i,()=>a(!1)),children:[v.icon&&b.jsx(z.ListItemIcon,{children:v.icon}),b.jsx(z.ListItemText,{primary:v.label})]},`mobile-drawer-group-${g}-item-${v.path}`))}),f=(()=>{if(e){const m=e.filter(g=>g&&g.length>0);return m.length===0?null:m.map((g,v)=>b.jsxs(Z.Fragment,{children:[l(g,v),v<m.length-1&&b.jsx(z.Divider,{})]},`mobile-drawer-group-${v}`))}return r?b.jsx(z.Box,{role:"presentation",onClick:()=>a(!1),children:r}):null})(),p=f??!1;return Z.useEffect(()=>{a(!1)},[o]),p&&b.jsxs(b.Fragment,{children:[b.jsx(z.IconButton,{onClick:()=>a(!0),color:"inherit",title:"Menu",children:b.jsx(Ine,{})}),b.jsx(z.Drawer,{"data-testid":"mobile-drawer",anchor:n,open:s,onClose:()=>a(!1),children:b.jsx(z.Box,{sx:{width:300},display:"flex",flexDirection:"column",justifyContent:"space-between",children:b.jsx(z.Box,{display:"flex",justifyContent:"start",flexDirection:"column",children:f})})})]})},gA=t=>{const{env:e,isProd:n}=t;return n?null:b.jsx(z.Paper,{sx:{borderRadius:0,display:"flex",alignItems:"center",justifyContent:"center"},children:b.jsxs(z.Typography,{variant:"h6",color:"error",children:[e," Environment - Test Data Only"]})})},yA=t=>{const{displayName:e,userMenuOptions:n}=t;return b.jsx(pA,{label:e,menuOptions:n,icon:b.jsx(Ane,{})})},mm=t=>{const{menuOptions:e,orientation:n="horizontal",activeTabIdx:r,sx:o=n=="vertical"?{"& .MuiTabs-indicator":{left:0}}:void 0,slotProps:i={indicator:{sx:n=="horizontal"?{height:4}:{width:4}}}}=t,{palette:s}=z.useTheme(),a=ko.useNavigate();return b.jsx(z.Tabs,{orientation:n,value:r??!1,sx:o,slotProps:i,children:e.map((l,u)=>b.jsx(z.Tab,{icon:l.icon,label:l.label,value:u,..._u(l,a),sx:{alignItems:n=="vertical"?"flex-start":void 0,borderBottom:n=="vertical"?"1px solid":void 0,borderColor:"divider","&.Mui-selected":{backgroundColor:n=="vertical"?s.grey[s.mode=="dark"?800:50]:void 0,color:"inherit"}}},l.label))})},bA=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t;return e.length>0&&b.jsx(z.Paper,{sx:{pl:4,pr:4,borderRadius:0},"data-testid":"navBar",children:b.jsx(mm,{menuOptions:e,activeTabIdx:n,sx:r})})},vA=t=>{const{onToggle:e}=t,{palette:n}=z.useTheme(),r=n.mode==="dark";return b.jsx(z.IconButton,{onClick:e,color:"inherit",title:"Dark Mode Toggle",children:r?b.jsx(II,{}):b.jsx(_I,{})})},Ade=t=>{const{envInfo:e,headerRef:n,logo:r,featureMenuOptions:o=[],userMenuOptions:i=[],onToggleDarkMode:s,quickLinks:a=[],displayName:l,banner:u,position:f="fixed",children:p,sx:m,navBarSx:g}=t,v=ko.useNavigate(),y=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),{palette:x}=z.useTheme(),{pathname:S}=ko.useLocation(),k=x.mode==="dark",[T,C]=D.useState(void 0);D.useEffect(()=>{const P=o.findIndex(N=>N.path&&S.startsWith(N.path));C(P>=0?P:void 0)},[S,o]);const O=s&&b.jsx(vA,{onToggle:s}),R=s&&(y||!y&&l)?[{icon:k?b.jsx(II,{}):b.jsx(_I,{}),label:`Switch to ${k?"Light":"Dark"} mode`,onClick:s},...i]:i;return b.jsxs(z.AppBar,{ref:n,position:f,sx:m,elevation:4,children:[e&&b.jsx(gA,{...e}),u,b.jsxs(z.Toolbar,{sx:{color:"white",display:"flex",justifyContent:"space-between",gap:2},children:[b.jsx(z.Button,{disableRipple:!0,component:ko.Link,to:"/",children:r&&typeof r=="string"?b.jsx("img",{draggable:"false",src:r,style:{width:"200px",filter:"brightness(0) invert(1)"},alt:"logo"}):r}),b.jsxs(z.Box,{display:"flex",gap:2,alignItems:"center",children:[!l&&!y&&O,y&&b.jsx(mA,{menuOptionLists:[o,a,R],anchor:"right"}),!y&&b.jsxs(b.Fragment,{children:[b.jsx(z.Box,{display:"flex",gap:0,children:a==null?void 0:a.map((P,N)=>b.jsxs(z.Box,{display:"flex",alignItems:"center",children:[N>0&&b.jsx(z.Typography,{className:"quickLink-divider",color:x.primary.contrastText,children:"|"}),b.jsx(z.Button,{variant:"text",sx:{color:"white"},..._u(P,v),children:b.jsxs(z.Box,{display:"flex",gap:"3px",alignItems:"center",children:[P.icon,P.label]})})]},P.label))}),p,l&&b.jsx(yA,{displayName:l,userMenuOptions:R})]})]})]}),!y&&b.jsx(bA,{featureMenuOptions:o,activeTabIdx:T,sx:g})]})},Pde=t=>{const{sx:e,menuOptions:n=[]}=t,{pathname:r}=ko.useLocation(),o=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),[i,s]=Z.useState(void 0);return Z.useEffect(()=>{const a=n.findIndex(l=>l.path&&r.startsWith(l.path))??-1;s(a>=0?a:void 0)},[r,n]),!o&&n.length>0&&b.jsx(z.Box,{sx:e,children:b.jsx(z.Card,{sx:{height:"100%",width:200},children:b.jsx(mm,{orientation:"vertical",menuOptions:n,activeTabIdx:i})})})},Nde=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t,{palette:o}=z.useTheme();return e.length>0&&b.jsx(mm,{menuOptions:e,activeTabIdx:n,sx:{margin:"8px",backgroundColor:o.primary.dark,borderRadius:"8px","& .MuiTab-root":{color:o.secondary.light,flexDirection:"row",gap:"2px","& .MuiTab-icon":{marginBottom:"unset"},minHeight:"58px"},"& .MuiTab-root.Mui-selected":{color:o.primary.contrastText,fontSize:"120%"},"& .MuiTabs-indicator":{display:"none"},...r}})},$de=t=>{const{gap:e=1,...n}=t;return b.jsx(z.Box,{display:"flex",flexDirection:"column",gap:e,...n})},Lde=({children:t,getCitations:e})=>{const[n,r]=Z.useState([]),[o,i]=Z.useState(!1);Z.useEffect(()=>{(async()=>e().then(f=>{r(p=>{const m=new Set(p.map(v=>v.id));return[...p.filter(v=>!m.has(v.id)),...f]}),i(!0)}).catch(f=>{console.error(`Error fetching citations: ${f==null?void 0:f.toString()}`)}))()},[]);const s=Z.useCallback(u=>{r(f=>{const p=f.map(v=>{const y=u.find(x=>x.id===v.id);return y||v}),m=new Set(f.map(v=>v.id)),g=u.filter(v=>!m.has(v.id));return[...p,...g]})},[]),a=Z.useCallback(u=>{const f=n.findIndex(p=>p.id===u.id);r(f!==-1?p=>{const m=[...p];return m[f]=u,m}:[...n,u])},[n]),l=Z.useCallback(u=>r(n.filter(f=>f.id!==u)),[n]);return b.jsx(uA.Provider,{value:{citations:n,isLoaded:o,addUpdateCitation:a,deleteCitation:l,batchUpdate:s},children:t})},jde=t=>b.jsx(Qu,{severity:"info",...t}),Bde=t=>b.jsx(Qu,{severity:"warning",...t}),xA=t=>{const{crumbInfo:e}=t,n=ko.useNavigate();return b.jsx(z.Breadcrumbs,{"aria-label":"breadcrumb",separator:b.jsx(Dne,{color:"primary"}),sx:{marginBottom:2},children:e.map(({label:r,path:o},i)=>o&&i<e.length-1?b.jsx(z.Link,{color:"primary",sx:{cursor:"pointer"},onClick:()=>n(o),children:r},r):b.jsx(z.Typography,{color:"primary",children:r},r))})},Fde=t=>{const{title:e,message:n,type:r,onClose:o,autoHideDuration:i,variant:s="leftBorder",elevation:a=6}=t,l=Vde(r);return b.jsx(z.Snackbar,{"data-testid":"message-snackbar",anchorOrigin:{vertical:"bottom",horizontal:"right"},open:!0,onClose:u=>{u==null&&o()},autoHideDuration:i,children:b.jsx(Qu,{"data-testid":"message-snackbar-alert",severity:l,iconMapping:{info:rO(r),warning:rO(r)},onClose:o,elevation:a,variant:s,children:n?b.jsxs(b.Fragment,{children:[b.jsx(z.AlertTitle,{"data-testid":"alertTitle",sx:{fontWeight:"bold"},children:e}),n]}):e})})},Vde=t=>t=="logout"?"info":t=="timeout"?"warning":t,rO=t=>{if(t=="timeout")return b.jsx(xne,{});if(t=="logout")return b.jsx(Rne,{})},zde=t=>{Hde(t);const{title:e,createButtonLabel:n="Add Item",showAddButton:r=!1,onAdd:o=()=>alert("Not implemented yet"),breadcrumbs:i=[],children:s,sx:a={},bottomGutter:l=!1}=t,u=z.useMediaQuery(z.useTheme().breakpoints.down("sm"));return!e&&(!r||!n)?null:b.jsxs(z.Box,{"data-testid":"MBv2-Page-Header",sx:{...a,...l&&{marginBottom:"4px"}},children:[i.length>0&&b.jsx(xA,{crumbInfo:i}),b.jsxs(z.Box,{className:"MBv2_PageHeader_Header",display:"flex",flexDirection:u?"column":"row",justifyContent:"space-between",alignItems:"center",gap:1,children:[b.jsxs(z.Box,{className:"MBv2_PageHeader_TitleAndCreateBtn",display:"flex",flexDirection:"row",justifyContent:u||!s?"space-between":"start",alignItems:"center",width:"100%",gap:1,children:[typeof e=="string"?b.jsx(z.Typography,{className:"MBv2_PageHeader_Title",variant:"h2",children:e}):e,r&&b.jsxs(ao,{className:"MBv2_PageHeader_CreateBtn",onClick:()=>o(),children:[b.jsx(Sne,{style:{marginRight:"0.5rem"}}),n]})]}),s&&b.jsx(z.Box,{width:u?"100%":"50%",children:s})]})]})},Hde=t=>{const{showAddButton:e,onAdd:n,createButtonLabel:r}=t,o="PageHeader component:";e&&!n&&console.warn(`${o} "showAddButton" is true but "onAdd" is not defined.`),e&&!r&&console.warn(`${o} "showAddButton" is true but "createButtonLabel" is not defined`)},Wde=t=>{const{title:e,titleIcon:n,fullWidthIcon:r=!1,children:o,actionLabel:i,action:s,sx:a}=t,l=z.useMediaQuery(z.useTheme().breakpoints.down("sm"));return b.jsxs(z.Card,{sx:a||{padding:"30px 40px",display:"flex",flexDirection:"column",gap:"1rem"},children:[n&&b.jsx(z.Box,{className:"MBv2_SingleActionCard_Img",sx:[r?{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"20px",marginBottom:"10px"}:{display:"inline"}],children:n}),b.jsx(z.Typography,{variant:"h1",display:"inline",fontSize:"calc(20px + .9vw)",className:"MBv2_SingleActionCard_Title",children:e}),o,b.jsx(z.Button,{variant:"contained",color:"primary",onClick:s,fullWidth:l,className:"MBv2_SingleActionCard_ActionButton",children:i})]})};function Ude({...t}){return b.jsx(lA,{onSelectCitations:()=>{},onCancel:()=>{},renderAsSelectablePopup:!1,...t})}const qde=t=>{const{size:e="small"}=t;let n=`${e}px`;switch(e){case"x-small":n="6px";break;case"small":n="10px";break;case"medium":n="14px";break;case"large":n="18px";break;case"x-large":n="22px";break}return b.jsx(z.Box,{height:n})};exports.AlertModal=kde;exports.Autocomplete=CI;exports.Breadcrumbs=xA;exports.Button=ao;exports.Checkbox=TI;exports.CheckboxGroup=Wte;exports.CitationField=yde;exports.CitationFieldProvider=Lde;exports.CitationManager=Ude;exports.Column=$de;exports.ConfirmationModal=Tde;exports.DarkModeToggle=vA;exports.DateField=Op;exports.DateRangeField=mce;exports.DecisionModal=Ede;exports.Diff=SI;exports.DiffCitationTable=Ide;exports.DiffProvider=wM;exports.DiffTable=hA;exports.Drawer=mA;exports.DynamicAutocomplete=zte;exports.EnvironmentBanner=gA;exports.ErrorAlert=sA;exports.FileList=Kte;exports.FileUpload=kI;exports.FloatingNavBar=Nde;exports.Footer=Dde;exports.FormDebugger=xde;exports.Header=Ade;exports.InfoAlert=jde;exports.LoadingButton=Tx;exports.LoadingIndicator=w0;exports.Location=mne;exports.MenuButton=pA;exports.Modal=Zu;exports.MultiAutocomplete=Hte;exports.NavBar=bA;exports.NotApplicableCheckbox=fA;exports.PageHeader=zde;exports.PaginatedTable=WD;exports.ProfileMenu=yA;exports.RadioGroup=MI;exports.RangeSlider=gne;exports.ReadOnly=Aa;exports.ReadOnlyProvider=vM;exports.RepeatableFormGroup=Sde;exports.RichTextField=uue;exports.Row=oA;exports.ScrollToTop=vde;exports.SearchField=jne;exports.Select=yne;exports.SelectableCitationManager=cA;exports.Sidebar=Pde;exports.SingleActionCard=Wde;exports.Snackbar=Fde;exports.Spacer=qde;exports.Stepper=wde;exports.Submit=bde;exports.SuccessAlert=aA;exports.Switch=bne;exports.Table=Cx;exports.Tabs=mm;exports.TextArea=vne;exports.TextField=xs;exports.TextIcon=I0;exports.ValidationError=Mr;exports.WarningAlert=Bde;exports.commonTheme=In;exports.darkTheme=ZV;exports.lightTheme=XV;exports.useDiff=Ra;exports.useReadOnly=_a;
|
|
407
|
+
`+(a!==s?`result of cast: ${a}`:""))}return i}_cast(e,n){let r=e===void 0?e:this.transforms.reduce((o,i)=>i.call(this,o,e,this,n),e);return r===void 0&&(r=this.getDefault(n)),r}_validate(e,n={},r,o){let{path:i,originalValue:s=e,strict:a=this.spec.strict}=n,l=e;a||(l=this._cast(l,Object.assign({assert:!1},n)));let u=[];for(let f of Object.values(this.internalTests))f&&u.push(f);this.runTests({path:i,value:l,originalValue:s,options:n,tests:u},r,f=>{if(f.length)return o(f,l);this.runTests({path:i,value:l,originalValue:s,options:n,tests:this.tests},r,o)})}runTests(e,n,r){let o=!1,{tests:i,value:s,originalValue:a,path:l,options:u}=e,f=y=>{o||(o=!0,n(y,s))},p=y=>{o||(o=!0,r(y,s))},m=i.length,g=[];if(!m)return p([]);let v={value:s,originalValue:a,path:l,options:u,schema:this};for(let y=0;y<i.length;y++){const x=i[y];x(v,f,function(k){k&&(Array.isArray(k)?g.push(...k):g.push(k)),--m<=0&&p(g)})}}asNestedTest({key:e,index:n,parent:r,parentPath:o,originalParent:i,options:s}){const a=e??n;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const l=typeof a=="number";let u=r[a];const f=Object.assign({},s,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[l?"index":"key"]:a,path:l||a.includes(".")?`${o||""}[${l?a:`"${a}"`}]`:(o?`${o}.`:"")+e});return(p,m,g)=>this.resolve(f)._validate(u,f,m,g)}validate(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return new Promise((s,a)=>o._validate(e,n,(l,u)=>{pr.isError(l)&&(l.value=u),a(l)},(l,u)=>{l.length?a(new pr(l,u,void 0,void 0,i)):s(u)}))}validateSync(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i,s=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return o._validate(e,Object.assign({},n,{sync:!0}),(a,l)=>{throw pr.isError(a)&&(a.value=l),a},(a,l)=>{if(a.length)throw new pr(a,e,void 0,void 0,s);i=l}),i}isValid(e,n){return this.validate(e,n).then(()=>!0,r=>{if(pr.isError(r))return!1;throw r})}isValidSync(e,n){try{return this.validateSync(e,n),!0}catch(r){if(pr.isError(r))return!1;throw r}}_getDefault(e){let n=this.spec.default;return n==null?n:typeof n=="function"?n.call(this,e):yl(n)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,n){const r=this.clone({nullable:e});return r.internalTests.nullable=al({message:n,name:"nullable",test(o){return o===null?this.schema.spec.nullable:!0}}),r}optionality(e,n){const r=this.clone({optional:e});return r.internalTests.optionality=al({message:n,name:"optionality",test(o){return o===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=Vo.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=Vo.notNull){return this.nullability(!1,e)}required(e=Vo.required){return this.clone().withMutation(n=>n.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let n=this.clone();return n.transforms.push(e),n}test(...e){let n;if(e.length===1?typeof e[0]=="function"?n={test:e[0]}:n=e[0]:e.length===2?n={name:e[0],test:e[1]}:n={name:e[0],message:e[1],test:e[2]},n.message===void 0&&(n.message=Vo.default),typeof n.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),o=al(n),i=n.exclusive||n.name&&r.exclusiveTests[n.name]===!0;if(n.exclusive&&!n.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return n.name&&(r.exclusiveTests[n.name]=!!n.exclusive),r.tests=r.tests.filter(s=>!(s.OPTIONS.name===n.name&&(i||s.OPTIONS.test===o.OPTIONS.test))),r.tests.push(o),r}when(e,n){!Array.isArray(e)&&typeof e!="string"&&(n=e,e=".");let r=this.clone(),o=KD(e).map(i=>new Na(i));return o.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof n=="function"?new th(o,n):th.fromOptions(o,n)),r}typeError(e){let n=this.clone();return n.internalTests.typeError=al({message:e,name:"typeError",skipAbsent:!0,test(r){return this.schema._typeCheck(r)?!0:this.createError({params:{type:this.schema.type}})}}),n}oneOf(e,n=Vo.oneOf){let r=this.clone();return e.forEach(o=>{r._whitelist.add(o),r._blacklist.delete(o)}),r.internalTests.whiteList=al({message:n,name:"oneOf",skipAbsent:!0,test(o){let i=this.schema._whitelist,s=i.resolveAll(this.resolve);return s.includes(o)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:s}})}}),r}notOneOf(e,n=Vo.notOneOf){let r=this.clone();return e.forEach(o=>{r._blacklist.add(o),r._whitelist.delete(o)}),r.internalTests.blacklist=al({message:n,name:"notOneOf",test(o){let i=this.schema._blacklist,s=i.resolveAll(this.resolve);return s.includes(o)?this.createError({params:{values:Array.from(i).join(", "),resolved:s}}):!0}}),r}strip(e=!0){let n=this.clone();return n.spec.strip=e,n}describe(e){const n=(e?this.resolve(e):this).clone(),{label:r,meta:o,optional:i,nullable:s}=n.spec;return{meta:o,label:r,optional:i,nullable:s,default:n.getDefault(e),type:n.type,oneOf:n._whitelist.describe(),notOneOf:n._blacklist.describe(),tests:n.tests.filter((l,u,f)=>f.findIndex(p=>p.OPTIONS.name===l.OPTIONS.name)===u).map(l=>{const u=l.OPTIONS.params&&e?XD(Object.assign({},l.OPTIONS.params),e):l.OPTIONS.params;return{name:l.OPTIONS.name,params:u}})}}get"~standard"(){const e=this;return{version:1,vendor:"yup",async validate(r){try{return{value:await e.validate(r,{abortEarly:!1})}}catch(o){if(o instanceof pr)return{issues:QD(o)};throw o}}}}}ti.prototype.__isYupSchema__=!0;for(const t of["validate","validateSync"])ti.prototype[`${t}At`]=function(e,n,r={}){const{parent:o,parentPath:i,schema:s}=Due(this,e,n,r.context);return s[t](o&&o[i],Object.assign({},r,{parent:o,path:e}))};for(const t of["equals","is"])ti.prototype[t]=ti.prototype.oneOf;for(const t of["not","nope"])ti.prototype[t]=ti.prototype.notOneOf;const Nue=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function $ue(t){const e=C0(t);if(!e)return Date.parse?Date.parse(t):Number.NaN;if(e.z===void 0&&e.plusMinus===void 0)return new Date(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond).valueOf();let n=0;return e.z!=="Z"&&e.plusMinus!==void 0&&(n=e.hourOffset*60+e.minuteOffset,e.plusMinus==="+"&&(n=0-n)),Date.UTC(e.year,e.month,e.day,e.hour,e.minute+n,e.second,e.millisecond)}function C0(t){var e,n;const r=Nue.exec(t);return r?{year:xi(r[1]),month:xi(r[2],1)-1,day:xi(r[3],1),hour:xi(r[4]),minute:xi(r[5]),second:xi(r[6]),millisecond:r[7]?xi(r[7].substring(0,3)):0,precision:(e=(n=r[7])==null?void 0:n.length)!=null?e:void 0,z:r[8]||void 0,plusMinus:r[9]||void 0,hourOffset:xi(r[10]),minuteOffset:xi(r[11])}:null}function xi(t,e=0){return Number(t)||e}let Lue=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,jue=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,Bue=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Fue="^\\d{4}-\\d{2}-\\d{2}",Vue="\\d{2}:\\d{2}:\\d{2}",zue="(([+-]\\d{2}(:?\\d{2})?)|Z)",Hue=new RegExp(`${Fue}T${Vue}(\\.\\d+)?${zue}$`),Wue=t=>sa(t)||t===t.trim(),Uue={}.toString();function aa(){return new eA}class eA extends ti{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,n)=>{if(!this.spec.coerce||this.isType(e)||Array.isArray(e))return e;const r=e!=null&&e.toString?e.toString():e;return r===Uue?e:r})})}required(e){return super.required(e).withMutation(n=>n.test({message:e||Vo.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(n=>n.OPTIONS.name!=="required"),e))}length(e,n=wr.length){return this.test({message:n,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,n=wr.min){return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,n=wr.max){return this.test({name:"max",exclusive:!0,message:n,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,n){let r=!1,o,i;return n&&(typeof n=="object"?{excludeEmptyString:r=!1,message:o,name:i}=n:o=n),this.test({name:i||"matches",message:o||wr.matches,params:{regex:e},skipAbsent:!0,test:s=>s===""&&r||s.search(e)!==-1})}email(e=wr.email){return this.matches(Lue,{name:"email",message:e,excludeEmptyString:!0})}url(e=wr.url){return this.matches(jue,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=wr.uuid){return this.matches(Bue,{name:"uuid",message:e,excludeEmptyString:!1})}datetime(e){let n="",r,o;return e&&(typeof e=="object"?{message:n="",allowOffset:r=!1,precision:o=void 0}=e:n=e),this.matches(Hue,{name:"datetime",message:n||wr.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:n||wr.datetime_offset,params:{allowOffset:r},skipAbsent:!0,test:i=>{if(!i||r)return!0;const s=C0(i);return s?!!s.z:!1}}).test({name:"datetime_precision",message:n||wr.datetime_precision,params:{precision:o},skipAbsent:!0,test:i=>{if(!i||o==null)return!0;const s=C0(i);return s?s.precision===o:!1}})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=wr.trim){return this.transform(n=>n!=null?n.trim():n).test({message:e,name:"trim",test:Wue})}lowercase(e=wr.lowercase){return this.transform(n=>sa(n)?n:n.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>sa(n)||n===n.toLowerCase()})}uppercase(e=wr.uppercase){return this.transform(n=>sa(n)?n:n.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>sa(n)||n===n.toUpperCase()})}}aa.prototype=eA.prototype;let tA=new Date(""),que=t=>Object.prototype.toString.call(t)==="[object Date]";function Ex(){return new Xu}class Xu extends ti{constructor(){super({type:"date",check(e){return que(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,n)=>!this.spec.coerce||this.isType(e)||e===null?e:(e=$ue(e),isNaN(e)?Xu.INVALID_DATE:new Date(e)))})}prepareParam(e,n){let r;if(Na.isRef(e))r=e;else{let o=this.cast(e);if(!this._typeCheck(o))throw new TypeError(`\`${n}\` must be a Date or a value that can be \`cast()\` to a Date`);r=o}return r}min(e,n=S0.min){let r=this.prepareParam(e,"min");return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(o){return o>=this.resolve(r)}})}max(e,n=S0.max){let r=this.prepareParam(e,"max");return this.test({message:n,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(o){return o<=this.resolve(r)}})}}Xu.INVALID_DATE=tA;Ex.prototype=Xu.prototype;Ex.INVALID_DATE=tA;function Kue(t,e=[]){let n=[],r=new Set,o=new Set(e.map(([s,a])=>`${s}-${a}`));function i(s,a){let l=ha.split(s)[0];r.add(l),o.has(`${a}-${l}`)||n.push([a,l])}for(const s of Object.keys(t)){let a=t[s];r.add(s),Na.isRef(a)&&a.isSibling?i(a.path,s):kx(a)&&"deps"in a&&a.deps.forEach(l=>i(l,s))}return xue.array(Array.from(r),n).reverse()}function ZE(t,e){let n=1/0;return t.some((r,o)=>{var i;if((i=e.path)!=null&&i.includes(r))return n=o,!0}),n}function nA(t){return(e,n)=>ZE(t,e)-ZE(t,n)}const Yue=(t,e,n)=>{if(typeof t!="string")return t;let r=t;try{r=JSON.parse(t)}catch{}return n.isType(r)?r:t};function qf(t){if("fields"in t){const e={};for(const[n,r]of Object.entries(t.fields))e[n]=qf(r);return t.setFields(e)}if(t.type==="array"){const e=t.optional();return e.innerType&&(e.innerType=qf(e.innerType)),e}return t.type==="tuple"?t.optional().clone({types:t.spec.types.map(qf)}):"optional"in t?t.optional():t}const Gue=(t,e)=>{const n=[...ha.normalizePath(e)];if(n.length===1)return n[0]in t;let r=n.pop(),o=ha.getter(ha.join(n),!0)(t);return!!(o&&r in o)};let QE=t=>Object.prototype.toString.call(t)==="[object Object]";function eO(t,e){let n=Object.keys(t.fields);return Object.keys(e).filter(r=>n.indexOf(r)===-1)}const Jue=nA([]);function Ox(t){return new rA(t)}class rA extends ti{constructor(e){super({type:"object",check(n){return QE(n)||typeof n=="function"}}),this.fields=Object.create(null),this._sortErrors=Jue,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,n={}){var r;let o=super._cast(e,n);if(o===void 0)return this.getDefault(n);if(!this._typeCheck(o))return o;let i=this.fields,s=(r=n.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(o).filter(p=>!this._nodes.includes(p))),l={},u=Object.assign({},n,{parent:l,__validating:n.__validating||!1}),f=!1;for(const p of a){let m=i[p],g=p in o,v=o[p];if(m){let y;u.path=(n.path?`${n.path}.`:"")+p,m=m.resolve({value:v,context:n.context,parent:l});let x=m instanceof ti?m.spec:void 0,S=x==null?void 0:x.strict;if(x!=null&&x.strip){f=f||p in o;continue}y=!n.__validating||!S?m.cast(v,u):v,y!==void 0&&(l[p]=y)}else g&&!s&&(l[p]=v);(g!==p in l||l[p]!==v)&&(f=!0)}return f?l:o}_validate(e,n={},r,o){let{from:i=[],originalValue:s=e,recursive:a=this.spec.recursive}=n;n.from=[{schema:this,value:s},...i],n.__validating=!0,n.originalValue=s,super._validate(e,n,r,(l,u)=>{if(!a||!QE(u)){o(l,u);return}s=s||u;let f=[];for(let p of this._nodes){let m=this.fields[p];!m||Na.isRef(m)||f.push(m.asNestedTest({options:n,key:p,parent:u,parentPath:n.path,originalParent:s}))}this.runTests({tests:f,value:u,originalValue:s,options:n},r,p=>{o(p.sort(this._sortErrors).concat(l),u)})})}clone(e){const n=super.clone(e);return n.fields=Object.assign({},this.fields),n._nodes=this._nodes,n._excludedEdges=this._excludedEdges,n._sortErrors=this._sortErrors,n}concat(e){let n=super.concat(e),r=n.fields;for(let[o,i]of Object.entries(this.fields)){const s=r[o];r[o]=s===void 0?i:s}return n.withMutation(o=>o.setFields(r,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let n={};return this._nodes.forEach(r=>{var o;const i=this.fields[r];let s=e;(o=s)!=null&&o.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[r]})),n[r]=i&&"getDefault"in i?i.getDefault(s):void 0}),n}setFields(e,n){let r=this.clone();return r.fields=e,r._nodes=Kue(e,n),r._sortErrors=nA(Object.keys(e)),n&&(r._excludedEdges=n),r}shape(e,n=[]){return this.clone().withMutation(r=>{let o=r._excludedEdges;return n.length&&(Array.isArray(n[0])||(n=[n]),o=[...r._excludedEdges,...n]),r.setFields(Object.assign(r.fields,e),o)})}partial(){const e={};for(const[n,r]of Object.entries(this.fields))e[n]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return qf(this)}pick(e){const n={};for(const r of e)this.fields[r]&&(n[r]=this.fields[r]);return this.setFields(n,this._excludedEdges.filter(([r,o])=>e.includes(r)&&e.includes(o)))}omit(e){const n=[];for(const r of Object.keys(this.fields))e.includes(r)||n.push(r);return this.pick(n)}from(e,n,r){let o=ha.getter(e,!0);return this.transform(i=>{if(!i)return i;let s=i;return Gue(i,e)&&(s=Object.assign({},i),r||delete s[e],s[n]=o(i)),s})}json(){return this.transform(Yue)}exact(e){return this.test({name:"exact",exclusive:!0,message:e||Uf.exact,test(n){if(n==null)return!0;const r=eO(this.schema,n);return r.length===0||this.createError({params:{properties:r.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(e=!0,n=Uf.noUnknown){typeof e!="boolean"&&(n=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:n,test(o){if(o==null)return!0;const i=eO(this.schema,o);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,n=Uf.noUnknown){return this.noUnknown(!e,n)}transformKeys(e){return this.transform(n=>{if(!n)return n;const r={};for(const o of Object.keys(n))r[e(o)]=n[o];return r})}camelCase(){return this.transformKeys(fb.camelCase)}snakeCase(){return this.transformKeys(fb.snakeCase)}constantCase(){return this.transformKeys(e=>fb.snakeCase(e).toUpperCase())}describe(e){const n=(e?this.resolve(e):this).clone(),r=super.describe(e);r.fields={};for(const[i,s]of Object.entries(n.fields)){var o;let a=e;(o=a)!=null&&o.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[i]})),r.fields[i]=s.describe(a)}return r}}Ox.prototype=rA.prototype;const Xue=t=>{const{title:e,onSave:n,onCancel:r,onClose:o,modifyCitation:i,readOnly:s=!1,showCloseBtn:a=!1}=t,l=Z.useRef(null),[u,f]=Z.useState(!1),[p,m]=Z.useState(!1),[g,v]=Z.useState({type:"Url",source:"",title:"",accessedAt:null,url:"",classification:""});return Z.useEffect(()=>{i&&v({...i,type:"Url"})},[]),b.jsxs(b.Fragment,{children:[b.jsxs(z.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[b.jsx(z.Typography,{variant:"h6",margin:"10px 0",children:e}),a&&b.jsx(z.IconButton,{onClick:o,children:b.jsx(Xh,{})})]}),b.jsx(Ut.Formik,{innerRef:l,enableReinitialize:!0,initialValues:g,onSubmit:async y=>{f(!0),n(y).catch(x=>{throw f(!1),x}).finally(()=>f(!1))},validationSchema:Ox({source:aa().required("Source is required"),title:aa().required("Title is required"),accessedAt:Ex().required("Accessed At is required"),url:aa().required("URL is required"),classification:aa().required("Classification is required")}),validateOnBlur:p,validateOnChange:p,children:({handleSubmit:y})=>b.jsxs(Ut.Form,{autoComplete:"off",children:[b.jsxs(z.Box,{display:"flex",flexDirection:"column",gap:s?1:0,children:[b.jsx(xs,{name:"source",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(xs,{name:"title",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(Op,{name:"accessedAt",disabled:u,required:!0,margin:"none",isDatePicker:!0,readOnly:s}),b.jsx(xs,{name:"url",label:"URL",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(MI,{row:!0,name:"classification",required:!0,radios:[{label:"Public Source",value:"Public Source",helperText:"URL is accessible to anyone from any location without special permissions. You can safely access this URL on any computer, including public or shared devices."},{label:"Proprietary Source",value:"Proprietary Source",helperText:"For private, sensitive, or access-controlled content. Use a VPN, or take extra precautions, when accessing to protect your privacy."}],margin:"none",readOnly:s})]}),b.jsx(z.DialogActions,{sx:{px:0},children:s?b.jsx(z.Button,{onClick:r,size:"small",variant:"contained",children:"Back to Table"}):b.jsxs(b.Fragment,{children:[b.jsx(z.Button,{onClick:r,variant:"outlined",size:"small",children:"Cancel"}),b.jsx(Tx,{size:"small",loading:u,type:"button",onClick:()=>{m(!0),y()},children:i?"Update Citation":"Add New Citation"})]})})]})})]})},oA=t=>{const{gap:e=1,alignItems:n="center",...r}=t;return b.jsx(z.Box,{display:"flex",flexDirection:"row",gap:e,alignItems:n,...r})},Zue=t=>{const{title:e,onSave:n,onCancel:r,onClose:o,disableFileUpload:i=!1,modifyCitation:s,readOnly:a=!1,showCloseBtn:l=!1}=t,u=Z.useRef(null),[f,p]=Z.useState(!1),[m,g]=Z.useState(!1),[v,y]=Z.useState({type:"Attachment",title:"",file:void 0,fileName:""});return Z.useEffect(()=>{s&&y({...s,type:"Attachment",file:void 0})},[]),b.jsxs(b.Fragment,{children:[b.jsxs(z.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[b.jsx(z.Typography,{variant:"h6",margin:"10px 0",children:e}),l&&b.jsx(z.IconButton,{onClick:o,children:b.jsx(Xh,{})})]}),b.jsx(Ut.Formik,{innerRef:u,enableReinitialize:!0,initialValues:v,validationSchema:Ox().shape({title:aa().required("Title is required"),fileName:aa().required("A file is required")}),validateOnBlur:m,validateOnChange:m,onSubmit:async x=>{p(!0),n(x).catch(S=>{throw p(!1),S}).finally(()=>p(!1))},children:({values:x,setFieldValue:S,handleSubmit:k})=>{var T;return Z.useEffect(()=>{var C,O;(C=x.file)!=null&&C.name&&S("fileName",(O=x.file)==null?void 0:O.name)},[(T=x.file)==null?void 0:T.name]),b.jsxs(Ut.Form,{autoComplete:"off",children:[b.jsx(xs,{name:"title",disabled:f,required:!0,margin:"none",readOnly:a}),b.jsxs(z.Box,{marginTop:i||a?0:1,children:[b.jsxs(oA,{alignItems:"flex-start",children:[!i&&!a&&b.jsx(kI,{name:"file",errorMode:"hidden"}),b.jsx(xs,{readOnly:!0,name:"fileName",label:a||i?"File Name":""})]}),b.jsx(Mr,{name:"fileName"})]}),b.jsx(z.DialogActions,{sx:{px:0},children:a?b.jsx(z.Button,{onClick:r,size:"small",variant:"contained",children:"Back to Table"}):b.jsxs(b.Fragment,{children:[b.jsx(z.Button,{onClick:r,variant:"outlined",size:"small",children:"Cancel"}),b.jsx(Tx,{size:"small",loading:f,type:"button",onClick:()=>{g(!0),k()},children:s?"Update Attachment":"Upload Attachment"})]})})]})}})]})},Zu=t=>{const{open:e=!1,onClose:n,title:r,children:o,actions:i,closeBtnLabel:s,closeButtonPosition:a,closeButtonProps:l={},disableDismiss:u=!1,...f}=t;if(!e)return null;const p=a==="bottom"||a==="top-and-bottom",m=a==="top"||a==="top-and-bottom",g=()=>{if(s&&p)return b.jsx(z.Button,{className:"MBv2_Modal_Close",onClick:t.onClose,...l,children:s})},v=()=>{if(i)return b.jsx(z.DialogActions,{className:"MBv2_Modal_Actions",children:b.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",gap:"0.25rem",children:[b.jsx(z.Box,{children:g()}),b.jsxs(z.Box,{display:"flex",gap:".25rem",children:[...i]})]})});if(s&&p)return b.jsx(z.DialogActions,{className:"MBv2_Modal_Actions",children:b.jsx(z.Box,{children:g()})})};return b.jsxs(z.Dialog,{className:"MBv2_Modal",open:e,onClose:()=>{u||n==null||n()},...f,children:[typeof r=="string"?b.jsx(z.DialogTitle,{className:"MBv2_Modal_Title",children:b.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[r,m&&b.jsx(z.IconButton,{"data-testid":"modal-header-close-btn",onClick:n,children:b.jsx(Xh,{})})]})}):r,o&&(typeof o=="string"?b.jsx(z.DialogContent,{className:"MBv2_Modal_Content",children:b.jsx(z.DialogContentText,{className:"MBv2_Modal_Content_Text",children:o})}):o),v()]})};function Que(t){return We("MuiAlert",t)}const tO=Ve("MuiAlert",["root","action","icon","message","filled","colorSuccess","colorInfo","colorWarning","colorError","filledSuccess","filledInfo","filledWarning","filledError","outlined","outlinedSuccess","outlinedInfo","outlinedWarning","outlinedError","standard","standardSuccess","standardInfo","standardWarning","standardError"]),ede=De(b.jsx("path",{d:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"}),"SuccessOutlined"),tde=De(b.jsx("path",{d:"M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),nde=De(b.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutline"),rde=De(b.jsx("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"}),"InfoOutlined"),ode=De(b.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close"),ide=t=>{const{variant:e,color:n,severity:r,classes:o}=t,i={root:["root",`color${Ie(n||r)}`,`${e}${Ie(n||r)}`,`${e}`],icon:["icon"],message:["message"],action:["action"]};return He(i,Que,o)},sde=ne(Ms,{name:"MuiAlert",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.variant],e[`${n.variant}${Ie(n.color||n.severity)}`]]}})(yt(({theme:t})=>{const e=t.palette.mode==="light"?ya:Ol,n=t.palette.mode==="light"?Ol:ya;return{...t.typography.body2,backgroundColor:"transparent",display:"flex",padding:"6px 16px",variants:[...Object.entries(t.palette).filter(jn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"standard"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),backgroundColor:t.vars?t.vars.palette.Alert[`${r}StandardBg`]:n(t.palette[r].light,.9),[`& .${tO.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(jn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"outlined"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),border:`1px solid ${(t.vars||t).palette[r].light}`,[`& .${tO.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(jn(["dark"])).map(([r])=>({props:{colorSeverity:r,variant:"filled"},style:{fontWeight:t.typography.fontWeightMedium,...t.vars?{color:t.vars.palette.Alert[`${r}FilledColor`],backgroundColor:t.vars.palette.Alert[`${r}FilledBg`]}:{backgroundColor:t.palette.mode==="dark"?t.palette[r].dark:t.palette[r].main,color:t.palette.getContrastText(t.palette[r].main)}}}))]}})),ade=ne("div",{name:"MuiAlert",slot:"Icon",overridesResolver:(t,e)=>e.icon})({marginRight:12,padding:"7px 0",display:"flex",fontSize:22,opacity:.9}),lde=ne("div",{name:"MuiAlert",slot:"Message",overridesResolver:(t,e)=>e.message})({padding:"8px 0",minWidth:0,overflow:"auto"}),cde=ne("div",{name:"MuiAlert",slot:"Action",overridesResolver:(t,e)=>e.action})({display:"flex",alignItems:"flex-start",padding:"4px 0 0 16px",marginLeft:"auto",marginRight:-8}),nO={success:b.jsx(ede,{fontSize:"inherit"}),warning:b.jsx(tde,{fontSize:"inherit"}),error:b.jsx(nde,{fontSize:"inherit"}),info:b.jsx(rde,{fontSize:"inherit"})},iA=D.forwardRef(function(e,n){const r=ht({props:e,name:"MuiAlert"}),{action:o,children:i,className:s,closeText:a="Close",color:l,components:u={},componentsProps:f={},icon:p,iconMapping:m=nO,onClose:g,role:v="alert",severity:y="success",slotProps:x={},slots:S={},variant:k="standard",...T}=r,C={...r,color:l,severity:y,variant:k,colorSeverity:l||y},O=ide(C),R={slots:{closeButton:u.CloseButton,closeIcon:u.CloseIcon,...S},slotProps:{...f,...x}},[P,N]=Et("root",{ref:n,shouldForwardComponentProp:!0,className:ge(O.root,s),elementType:sde,externalForwardedProps:{...R,...T},ownerState:C,additionalProps:{role:v,elevation:0}}),[V,M]=Et("icon",{className:O.icon,elementType:ade,externalForwardedProps:R,ownerState:C}),[j,F]=Et("message",{className:O.message,elementType:lde,externalForwardedProps:R,ownerState:C}),[L,A]=Et("action",{className:O.action,elementType:cde,externalForwardedProps:R,ownerState:C}),[_,I]=Et("closeButton",{elementType:Jl,externalForwardedProps:R,ownerState:C}),[B,W]=Et("closeIcon",{elementType:ode,externalForwardedProps:R,ownerState:C});return b.jsxs(P,{...N,children:[p!==!1?b.jsx(V,{...M,children:p||m[y]||nO[y]}):null,b.jsx(j,{...F,children:i}),o!=null?b.jsx(L,{...A,children:o}):null,o==null&&g?b.jsx(L,{...A,children:b.jsx(_,{size:"small","aria-label":a,title:a,color:"inherit",onClick:g,...I,children:b.jsx(B,{fontSize:"small",...W})})}):null]})});process.env.NODE_ENV!=="production"&&(iA.propTypes={action:c.node,children:c.node,classes:c.object,className:c.string,closeText:c.string,color:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),components:c.shape({CloseButton:c.elementType,CloseIcon:c.elementType}),componentsProps:c.shape({closeButton:c.object,closeIcon:c.object}),icon:c.node,iconMapping:c.shape({error:c.node,info:c.node,success:c.node,warning:c.node}),onClose:c.func,role:c.string,severity:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),slotProps:c.shape({action:c.oneOfType([c.func,c.object]),closeButton:c.oneOfType([c.func,c.object]),closeIcon:c.oneOfType([c.func,c.object]),icon:c.oneOfType([c.func,c.object]),message:c.oneOfType([c.func,c.object]),root:c.oneOfType([c.func,c.object])}),slots:c.shape({action:c.elementType,closeButton:c.elementType,closeIcon:c.elementType,icon:c.elementType,message:c.elementType,root:c.elementType}),sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),variant:c.oneOfType([c.oneOf(["filled","outlined","standard"]),c.string])});const Qu=t=>{var g;const{noIcon:e=!1,children:n,severity:r="success",variant:o="leftBorder",sx:i,title:s,...a}=t,{palette:l}=z.useTheme(),u=e?{icon:!1}:{},f=o==="leftBorder"?"standard":o,p=o==="leftBorder"?{...i,borderLeft:`4px solid ${(g=l[r])==null?void 0:g.main}`}:i,m=s?{icon:{sx:{mt:"6px"}}}:{};return b.jsxs(iA,{severity:r,variant:f,sx:p,slotProps:m,...u,...a,children:[s&&b.jsx(z.Typography,{variant:"h3",children:s}),n]})},sA=t=>b.jsx(Qu,{severity:"error",...t}),aA=t=>b.jsx(Qu,{severity:"success",...t}),ude=t=>{const{alert:e,setAlert:n}=t,r=()=>n(void 0);return b.jsxs(b.Fragment,{children:[(e==null?void 0:e.type)==="Error"&&b.jsx(sA,{"data-testid":"citation-menu-error",onClose:r,title:e.title,children:e.message.toString()}),(e==null?void 0:e.type)==="Success"&&b.jsx(aA,{"data-testid":"citation-menu-success",onClose:r,children:e.message})]})};function lA({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,onSelectCitations:a,onCancel:l,initialSelectedIds:u=[],onContentChange:f,onError:p=()=>{},renderAsSelectablePopup:m=!1,addlActions:g,canLaunchUrl:v,readOnly:y}){const[x,S]=Z.useState("Insert Citation/Attachment(s)"),[k,T]=Z.useState(u),[C,O]=Z.useState(void 0),[R,P]=Z.useState(void 0),N=G=>{P(void 0),S(G)},[V,M]=Z.useState(0);Z.useEffect(()=>{f==null||f()},[x,R,f]);const j=(G=!1)=>{(!m||G)&&M(te=>te+1)},F=(G,te)=>{var de;const ue=typeof((de=te.response)==null?void 0:de.data)=="string"&&te.response.data,re=typeof te.message=="string"&&te.message;P({type:"Error",title:G,message:ue??re}),p(te)},L=G=>P({type:"Success",title:"",message:G}),A=async G=>{if(x==="Insert Citation/Attachment(s)")throw Error("onSave called with invalid state");if(x==="Edit Citation"||x==="Edit Attachment"){if(G.id===void 0)throw Error("Failed to update citation. Citation is missing id");await(n==null?void 0:n(G).then(()=>{N("Insert Citation/Attachment(s)"),j()}).catch(ue=>{F("Failed to update",ue)}))}else await(e==null?void 0:e(G).then(ue=>{T([...k,ue.id]),N("Insert Citation/Attachment(s)"),j()}).catch(ue=>{F("Failed to create",ue)}))},_=r&&(async G=>r(G).then(()=>{j(!0),T(k.filter(te=>te!==G)),L("Successfully deleted")}).catch(te=>F("Failed to delete",te))),I=(G,te)=>{o(G.id).then(ue=>{O(ue),N(te)}).catch(ue=>{F("Failed to load",ue)})},B=i&&(async G=>i(G).catch(te=>{F(`Failed to download ${G.fileName}`,te)})),W=s&&(async G=>s(G).catch(te=>{F(`Failed to view ${G.fileName}`,te)})),K=b.jsx(mue,{refreshKey:V,getCitationsPaginated:G=>t(G).then(te=>(f==null||f(),te)),onCancel:l,onNewCitation:()=>{O(void 0),N("Add Citation")},onNewAttachment:()=>{O(void 0),N("Add Attachment")},onEditCitation:G=>I(G,y?"View Citation":"Edit Citation"),onEditAttachment:G=>I(G,y?"View Attachment":"Edit Attachment"),onDeleteCitation:_,onDownloadAttachment:B,onViewAttachment:W,onSelect:a,setSelectedIds:T,selectedIds:k,onError:p,condenseTable:m,canSelect:m,title:m&&!y?x:"Attachments & Citations",addlActions:g,canCreate:!!e,canEdit:!!n,canDelete:!!_,canLaunchUrl:v,readOnly:y,showCloseBtn:m}),U=b.jsx(Xue,{modifyCitation:C,onSave:A,onCancel:()=>N("Insert Citation/Attachment(s)"),onClose:l,title:x,readOnly:x==="View Citation",showCloseBtn:m}),Y=b.jsx(Zue,{onSave:A,onCancel:()=>N("Insert Citation/Attachment(s)"),onClose:l,modifyCitation:C,disableFileUpload:x==="Edit Attachment",title:x,readOnly:x==="View Attachment",showCloseBtn:m}),oe=b.jsx(ude,{alert:R,setAlert:P}),fe=x==="Add Citation"||x==="Edit Citation"||x==="View Citation",he=x==="Add Attachment"||x==="Edit Attachment"||x==="View Attachment";if(m){let G=null;return!m||x==="Insert Citation/Attachment(s)"?G=K:fe?G=U:he&&(G=Y),b.jsxs(z.Box,{width:"500px",children:[oe,b.jsx(z.Box,{paddingTop:"8px",children:G})]})}return b.jsxs(z.Box,{width:"100%",children:[x==="Insert Citation/Attachment(s)"&&oe,b.jsx(z.Box,{paddingTop:"8px",children:K}),b.jsx(Zu,{open:fe||he,children:b.jsxs(z.Box,{padding:"10px 20px",minWidth:"400px","data-testid":"citation-form-modal",children:[oe,fe?U:Y]})})]})}function cA({...t}){return b.jsx(lA,{renderAsSelectablePopup:!0,...t})}const dde=z.styled("div",{name:"CitationBubbleMenu",slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>{const e=t.palette.mode==="dark";return{padding:t.spacing(1.5,2,.5),backgroundColor:e?"#101010":"#f9f9f9",border:`1px solid ${t.palette.grey[e?700:200]}`}});function fde({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,canLaunchUrl:a,readOnly:l,...u}){const f=Ct();if(f&&!("citationBubbleMenuHandler"in(f==null?void 0:f.storage)))throw new Error("You must add the CitationBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const p=f==null?void 0:f.storage.citationBubbleMenuHandler,m=p.isOpen,g=p.selectedIds,v=p.selectedNodePos,y=T=>{f&&(T.length===0?f.commands.deleteCitation(v):g.length===0?f.commands.insertCitation({ids:T}):f.commands.updateCitation({ids:T},v))},x=T=>{y(T),f==null||f.commands.closeCitationBubbleMenu()},S=()=>{y(g),f==null||f.commands.closeCitationBubbleMenu()},k=Z.useCallback(()=>{requestAnimationFrame(()=>{f!=null&&f.view&&f.view.dispatch(f.view.state.tr)})},[f]);return f?b.jsx(bv,{editor:f,open:m,...p.bubbleMenuOptions,...u,children:b.jsx(dde,{children:b.jsx(cA,{getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,onSelectCitations:x,onCancel:S,initialSelectedIds:g,onContentChange:k,canLaunchUrl:a,readOnly:l})})}):null}const pde=()=>mn.create({name:"citationBubbleMenuHandler",addStorage(){return{isOpen:!1,selectedIds:[],bubbleMenuOptions:void 0,selectedNodePos:0}},addCommands(){return{openCitationBubbleMenu:(t={},e)=>({editor:n,dispatch:r})=>{var a;const{doc:o}=n.state,i=o.nodeAt(e??0),s=((a=i==null?void 0:i.attrs)==null?void 0:a.ids)??[];return r&&(this.storage.isOpen=!0,this.storage.selectedIds=s,this.storage.bubbleMenuOptions=t,this.storage.selectedNodePos=e??0),!0},closeCitationBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.isOpen?(t.focus(),e&&(this.storage.isOpen=!1,this.storage.selectedIds=[],this.storage.selectedNodePos=0),!0):!1}},onSelectionUpdate(){this.storage.isOpen&&!this.editor.isActive("citation")&&this.editor.commands.closeCitationBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-c":()=>(this.editor.commands.openCitationBubbleMenu(),!0)}}});function hde(t){const e=Ct(),n=Z.useRef(null);return b.jsx(wt,{buttonRef:n,tooltipLabel:"Insert Citation/Attachment",tooltipShortcutKeys:["mod","Shift","C"],disabled:!(e!=null&&e.isEditable),onClick:()=>e==null?void 0:e.commands.openCitationBubbleMenu({anchorEl:n.current,placement:"bottom"}),...t,children:b.jsxs(z.Box,{display:"flex",flexDirection:"row",gap:"4px",alignItems:"center",children:[b.jsx(Cne,{fontSize:"small"}),b.jsx(z.Typography,{variant:"body2",children:"Insert Citation/Attachment"})]})})}const uA=Z.createContext(void 0),dA=()=>{const t=Z.useContext(uA);if(!t)throw new Error("useSync must be used inside CitationFieldProvider");return t},mde=({node:t,HTMLAttributes:e,selected:n,extension:r,updateAttributes:o,deleteNode:i})=>{const s=t.attrs.ids||[],{citations:a,isLoaded:l}=dA(),[u,f]=Z.useState(s?String(s):""),[p,m]=Z.useState([]),g=r.options.citationMaxLength;if(Z.useEffect(()=>{if(!l)return;const v=a.filter(S=>s.includes(S.id)),y=v.map(S=>ka.truncate(S.title,{length:g,omission:"..."})).join(", ");f(y),m(v);const x=v.map(S=>S.id);x.length===0?setTimeout(i,0):x.length!==s.length&&setTimeout(()=>o({ids:v.map(S=>S.id)}),0)},[a,s,l]),p.length!==0)return b.jsx(zv,{as:"span",...e,"data-testid":"citation-node-component",children:b.jsx(z.Tooltip,{title:b.jsx(z.Box,{className:"citation-tooltip",children:p.map((v,y)=>{var S;const x=[v.source,v.title,v.fileName,v.url,(S=v.accessedAt)==null?void 0:S.slice(0,10),v.classification];return b.jsxs(z.Typography,{variant:"subtitle2",children:[x.filter(Boolean).join(" | "),y<p.length-1&&b.jsx(z.Divider,{className:"citation-tooltip-divider"})]},v.id)})}),slotProps:{tooltip:{sx:{maxWidth:500}}},children:b.jsx("a",{href:"#",onClick:v=>{v.preventDefault(),v.stopPropagation()},className:n?"selected-citation-link":"citation-link",children:u})})})},gde=nn.create({name:"citation",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes(){return{ids:{default:[],parseHTML:t=>{const e=t.getAttribute("ids");return e?e.split(",").map(n=>parseInt(n.trim(),10)).filter(n=>!isNaN(n)):[]},renderHTML:t=>({ids:Array.isArray(t.ids)?t.ids.join(","):""})}}},parseHTML(){return[{tag:"citation"}]},renderHTML({HTMLAttributes:t}){return["citation",St(t)]},addNodeView(){return Hv(mde)},addProseMirrorPlugins(){return[new rn({props:{handleClickOn:(t,e,n,r,o,i)=>n&&n.type.name==="citation"?(this.editor.commands.openCitationBubbleMenu({},r),!0):!1}})]},addCommands(){return{insertCitation:t=>({commands:e})=>e.insertContent({type:"citation",attrs:t}),updateCitation:(t,e)=>({state:n,dispatch:r,tr:o})=>{const i=n.doc.nodeAt(e);return!i||i.type.name!=="citation"?!1:(o.setNodeMarkup(e,void 0,t),r&&r(o),!0)},deleteCitation:t=>({tr:e,dispatch:n})=>{if(typeof t!="number")return!1;const r=t,o=t+1;return n&&n(e.delete(r,o)),!0}}}}),fA=t=>b.jsx(TI,{name:t.name,label:"Not Applicable",errorMode:"hidden"}),yde=t=>{const{name:e,label:n=Fn(e),hideLabel:r=!1,required:o=!1,readOnly:i,margin:s="dense",citationMaxLength:a=24,getCitationsPaginated:l,onCreateCitation:u,onUpdateCitation:f,onDeleteCitation:p,getCitationById:m,onDownloadAttachment:g,onViewAttachment:v,onError:y=()=>{},placeholder:x="Start typing here...",notApplicableName:S,errorMode:k="normal",canLaunchUrl:T}=t,C=[DR,zD.configure({placeholder:x}),pde(),gde.configure({citationMaxLength:a})],[O,R,P]=Ut.useField({name:e}),{setValue:N}=P,{value:V}=O,{addUpdateCitation:M,deleteCitation:j,batchUpdate:F,citations:L}=dA();Z.useEffect(()=>{var he;const oe=(he=A==null?void 0:A.current)==null?void 0:he.editor;if(!oe)return;oe.getHTML()!==V&&setTimeout(()=>{oe.commands.setContent(V)},0)},[V]);const A=Z.useRef(null),_={normal:{marginTop:"16px",marginBottom:"8px"},dense:{marginTop:"8px",marginBottom:"4px"},none:{margin:0}},I=(oe=void 0)=>{var G,te;const fe=((te=(G=A.current)==null?void 0:G.editor)==null?void 0:te.getHTML())??"",he=!fe.replace(/<\/?p>|<br>/g,"").trim();N(he?"":fe,oe)},B=Z.useMemo(()=>ka.debounce(()=>I(!1),500),[N]),W=_a(),{showDiff:K,getPreviousValue:U}=Ra(),Y=i??W;if(K){const oe=U(e)??"",fe=V,he=/<citation\s+ids="([^"]*)"><\/citation>/g,G=(re,ie)=>{const de=ie.split(",").map(Number);return`<sup>${L.filter(ye=>de.includes(ye.id)).map(ye=>ye.title)}</sup>`},te=oe.replace(he,G),ue=fe.replace(he,G);return b.jsx(Aa,{label:n,value:ue,showDiff:!0,diffSnapshot:te,mode:"html"})}return b.jsxs(z.Box,{id:`citation-field_${e}`,sx:{"& .ProseMirror":{"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:Y?0:50}},".MuiTiptap-RichTextContent-readonly ":{padding:0}},..._[s],display:"flex",flexDirection:"column",width:"100%",children:[b.jsxs(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[!r&&b.jsx(z.InputLabel,{htmlFor:`citation-field_${e}`,required:o,children:n}),S&&b.jsx(fA,{name:S})]}),b.jsx(yI,{ref:A,extensions:C,content:V,editable:!Y,renderControls:Y?void 0:()=>b.jsx(Lv,{children:b.jsx(hde,{})}),onBlur:()=>I(),onUpdate:B,RichTextFieldProps:{variant:Y?"standard":"outlined",MenuBarProps:{hide:Y}},children:()=>b.jsx(fde,{getCitationsPaginated:oe=>l(oe).then(fe=>(F(fe.data),fe)),onCreateCitation:u&&(oe=>u(oe).then(fe=>(M(fe),fe))),onUpdateCitation:f&&(oe=>f(oe).then(fe=>(M(fe),fe))),onDeleteCitation:p&&(oe=>p(oe).then(()=>j(oe))),getCitationById:m,onDownloadAttachment:g,onViewAttachment:v,onError:y,canLaunchUrl:T,readOnly:Y})}),b.jsx(Mr,{name:e,id:`${e}-err`,errorMode:k})]})},bde=t=>{const{name:e="submit"}=t;return b.jsx(ao,{name:e,type:"submit",...t})},vde=t=>{const{label:e="Return to Top",icon:n=$f,scrollThresholdPx:r=100}=t,o=z.useScrollTrigger({threshold:r}),i=Z.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"})},[]);return b.jsx(z.Zoom,{in:o,children:b.jsx(z.Box,{sx:{position:"fixed",bottom:32,right:32,zIndex:1},children:b.jsxs(z.Fab,{onClick:i,color:"primary",size:"small",variant:"extended","aria-label":"Scroll back to top",children:[b.jsx(n,{fontSize:"medium"}),e]})})})},pA=t=>{const{label:e,menuOptions:n=[],icon:r}=t,o=ko.useNavigate(),[i,s]=D.useState(null),a=!!i,l=p=>{s(p.currentTarget)},u=()=>{s(null)};if(n.length===0)return null;const f=r&&!e;return b.jsxs(b.Fragment,{children:[b.jsx(z.Button,{startIcon:f?void 0:r,variant:"outlined",color:"inherit",sx:{minWidth:0,...f&&{paddingLeft:"6px",paddingRight:"6px"}},onClick:l,children:f?r:e}),b.jsx(z.Menu,{anchorEl:i,open:a,onClick:u,children:n.map(p=>b.jsxs(z.MenuItem,{..._u(p,o),children:[p.icon&&b.jsx(z.ListItemIcon,{children:p.icon}),b.jsx(z.ListItemText,{primary:p.label})]},p.label))})]})},xde=()=>{const{values:t,errors:e,status:n}=Ut.useFormikContext(),{palette:r}=z.useTheme();return b.jsx(z.Paper,{style:{backgroundColor:r.mode==="dark"?"#303030":"#f0f0f0",margin:"10px 0"},children:b.jsxs(z.List,{children:[b.jsxs(z.ListItem,{children:[b.jsx(z.Typography,{display:"block",variant:"h6",children:"Values"}),b.jsx("br",{}),b.jsx(z.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(t,null,2)})]}),b.jsx(z.Divider,{variant:"inset",component:"li"}),b.jsxs(z.ListItem,{id:"testing",children:[b.jsx(z.Typography,{display:"block",variant:"h6",children:"Errors"}),b.jsx("br",{}),b.jsx(z.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(e,null,2)})]}),b.jsxs(z.ListItem,{children:[b.jsx(z.Typography,{display:"block",variant:"h6",children:"Status"}),b.jsx("br",{}),b.jsx(z.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(n,null,2)})]})]})})},wde=t=>{const{steps:e,orientation:n,inlineLabel:r=n=="vertical",isResponsive:o=!1}=t,{width:i}=UD();let s=!r,a=n;o&&(n&&console.warn("Stepper: Ignoring orientation. isResponsive is set to true, so the orientation is determined automatically based on the window size."),a=i<600?"vertical":"horizontal",a=="vertical"?s=!1:s=!r),n=="vertical"&&!r&&(console.warn("Stepper: ignoring inlineLabel={false}. Must use inline labels when orientation is vertical"),s=!1);const l=["steps","inlineLabel","orientation","isResponsive"],u={alternativeLabel:s,orientation:a,...hr({...t},l)};return b.jsx(z.Stepper,{...u,children:e.map(f=>b.jsx(z.Step,{children:b.jsx(z.StepLabel,{children:f})},f))})},Sde=t=>{const{name:e,label:n=Fn(e),labelProps:r={fontSize:"1.1em",color:"#808080",fontWeight:"600"},initialState:o,renderFormGroup:i,addButtonContent:s="Add Another",removeButtonContent:a=t.removePosition==="right"?b.jsx(DI,{}):"Remove",variant:l="card",addButtonSx:u,removeButtonSx:f,allowRemoveAll:p=!1,readOnly:m=!1,emptyListMsg:g="None",showDivider:v=!1,removePosition:y="bottom"}=t,[x]=Ut.useField({name:e}),{value:S}=x,k=T=>({display:"flex",flexDirection:T==="bottom"?"column":"row",alignItems:T==="bottom"?"flex-start":"center"});return b.jsxs(z.FormControl,{fullWidth:!0,children:[b.jsx(z.Typography,{...r,children:n}),m&&x.value.length===0?b.jsx(z.Typography,{children:g}):b.jsx(Ut.FieldArray,{name:e,render:T=>b.jsxs("div",{children:[S.map((C,O)=>b.jsx(Z.Fragment,{children:b.jsx(Cde,{variant:l,content:b.jsxs(z.Box,{"data-testid":"form-group-container",sx:typeof y=="string"?k(y):{...y},children:[b.jsxs(z.Box,{width:"100%",children:[i(`${e}.${O}`,O),v&&O!==S.length-1&&b.jsx(z.Divider,{"data-testid":"divider"})]}),!m&&S.length>(p?0:1)&&b.jsx(z.Button,{"data-testid":"repeatable-form-group_remove-btn",sx:f,onClick:()=>T.remove(O),children:a})]})})},`${e}-${O}`)),!m&&b.jsx(z.Button,{"data-testid":"repeatable-form-group_add-btn",onClick:()=>T.push(o),sx:u,children:s})]})})]})},Cde=({variant:t,content:e})=>{switch(t){case"card":return b.jsx(z.Card,{"data-testid":"repeatable-form-group_card",sx:{padding:"8px",marginBottom:"8px"},children:b.jsx(z.CardContent,{children:e})});case"elevatedCard":return b.jsx(z.Card,{"data-testid":"repeatable-form-group_elevated-card",elevation:4,sx:{border:"unset",padding:"8px",marginBottom:"8px"},children:b.jsx(z.CardContent,{children:e})});case"none":return e}},Tde=t=>{const{confirmBtnLabel:e,onConfirm:n,confirmButtonProps:r={color:"primary",variant:"contained"},closeBtnLabel:o="Cancel",closeButtonPosition:i="bottom",...s}=t;return b.jsx(Zu,{actions:[b.jsx(z.Button,{className:"MBv2_ConfirmationModal_ConfirmBtn",onClick:n,...r,children:e})],closeBtnLabel:o,closeButtonPosition:i,...s})},kde=t=>{const{closeBtnLabel:e="OK",closeButtonPosition:n="bottom",closeButtonProps:r={color:"primary",variant:"contained"},...o}=t;return b.jsx(Zu,{closeBtnLabel:e,closeButtonPosition:n,closeButtonProps:r,...o})},Ede=t=>{const{primaryBtnLabel:e,onPrimaryAction:n,primaryActionProps:r={color:"primary",variant:"contained"},secondaryBtnLabel:o,onSecondaryAction:i,secondaryActionProps:s={color:"primary",variant:"outlined"},closeBtnLabel:a="Cancel",closeButtonPosition:l="bottom",...u}=t;return b.jsx(Zu,{actions:[b.jsx(z.Button,{className:"MBv2_DecisionModal_SecondaryAction",onClick:i,...s,children:o}),b.jsx(z.Button,{className:"MBv2_DecisionModal_PrimaryAction",onClick:n,...r,children:e})],closeBtnLabel:a,closeButtonPosition:l,...u})},Ode={added:{icon:wne,label:"Added",color:"success"},deleted:{icon:DI,label:"Deleted",color:"error"},modified:{icon:Tne,label:"Modified",color:"info"}},hA=t=>{const{beforeData:e,afterData:n,emptyTableMsg:r="No changes to display",columns:o,isEqual:i,size:s}=t;t.renderExpand!=null&&t.isEqual==null&&console.warn("DiffTable: isEqual prop should be provided when renderExpand is provided");const a=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),{dataDiff:l,unmodifiedCount:u}=Z.useMemo(()=>Rde(o,e,n,a,i),[e,n,o,a,i]),f=o.map(p=>({...p,render:(m,g)=>{var v;return((v=g.modifiedDiff)==null?void 0:v[xn(p)])??Mu(p,g,a)}}));return b.jsxs(z.Box,{children:[b.jsx(Cx,{columns:[{fieldName:"changeType",render:p=>{const m=Ode[p];return b.jsx(z.Chip,{color:m.color,size:s=="medium"?"medium":"small",label:b.jsxs(z.Typography,{children:[b.jsx(I0,{icon:m.icon}),m.label]})})}},...f],data:l,emptyTableMsg:r,renderExpand:t.renderExpand?p=>{const m=e.find(g=>g.id===p.id);return b.jsx(wM,{previousSnapshot:m,currentSnapshot:p,showDiff:p.changeType==="modified",children:t.renderExpand(p)})}:void 0,size:s}),u>0&&b.jsx(z.Box,{children:b.jsxs(z.Typography,{fontStyle:"italic",children:["+",u," unmodified rows"]})})]})},Mde=(t,e)=>b.jsxs(b.Fragment,{children:[b.jsx(z.Box,{"data-testid":"diff-table-cell-removed",sx:{backgroundColor:wp},children:b.jsx("s",{children:t})}),b.jsx(z.Box,{"data-testid":"diff-table-cell-added",sx:{backgroundColor:xp},children:b.jsx("u",{children:e})})]}),_de=(t,e,n,r=!1)=>{var i;let o={};for(const s of t)if(!s.ignoreDiff){const a=Mu(s,e,r),l=Mu(s,n,r);(((i=s.isEqual)==null?void 0:i.call(s,e,n))??ka.isEqual(a,l))||(o[xn(s)]=Mde(a,l))}return o},Rde=(t,e,n,r=!1,o)=>{const i=[];let s=0,a=0,l=0;for(e.sort((u,f)=>u.id-f.id),n.sort((u,f)=>u.id-f.id);s<e.length&&a<n.length;){const u=e[s],f=n[a];if(u.id===f.id){const p=_de(t,u,f,r);(o==null?void 0:o(u,f))??Object.keys(p).length===0?l++:i.push({...f,changeType:"modified",modifiedDiff:p}),s++,a++}else u.id<f.id?(i.push({...u,changeType:"deleted"}),s++):(i.push({...f,changeType:"added"}),a++)}for(;s<e.length;)i.push({...e[s],changeType:"deleted"}),s++;for(;a<n.length;)i.push({...n[a],changeType:"added"}),a++;return{dataDiff:i,unmodifiedCount:l}},Ide=t=>{const{beforeCitations:e,afterCitations:n,condenseTable:r=!1}=t,{palette:o}=z.useTheme(),i=qD(o,r);return b.jsxs(z.Box,{children:[!r&&b.jsx(z.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"10px",children:b.jsx(z.Typography,{variant:"h2",children:" Attachments & Citations"})}),b.jsx(hA,{columns:i,beforeData:e,afterData:n,size:r?"x-small":"medium"})]})},Dde=t=>{const{featureMenuOptions:e=[],copyright:n,logo:r,sx:o={},fontColor:i="primary"}=t,{palette:s}=z.useTheme(),a=ko.useNavigate();return b.jsxs(z.Box,{className:"MBv2_Footer",sx:{backgroundColor:s.mode==="dark"?"#222222":"#ededed",padding:"25px 30px",...o},children:[b.jsx(z.Box,{className:"MBv2_Footer_Logo",sx:{display:"flex",gap:2,alignItems:"center",paddingBottom:1},children:typeof r=="string"?b.jsx("img",{draggable:"false",src:r,style:{width:"200px"},alt:"logo"}):r}),b.jsxs(z.Box,{display:"flex",justifyContent:"space-between",flexWrap:"wrap",className:"MBv2_Footer_Nav_Links_Container",gap:2,children:[b.jsx(z.Box,{sx:{flexGrow:1},className:"MBv2_Footer_Nav_Links",display:"flex",flexDirection:"row",justifyContent:"flex-start",gap:3,children:e==null?void 0:e.map(l=>b.jsx(z.Link,{"data-testid":l.label,sx:{cursor:"pointer",fontSize:15},color:i,..._u(l,a),children:l.label},l.label))}),n&&b.jsx(z.Typography,{style:{fontSize:15},"data-testid":"copyright",className:"MBv2_Footer_Copyright",color:i,children:n})]})]})},mA=t=>{const{menuOptionLists:e,anchor:n="left",children:r}=t,{pathname:o}=ko.useLocation(),i=ko.useNavigate(),[s,a]=Z.useState(!1),l=(m,g)=>b.jsx(z.MenuList,{children:m.map(v=>b.jsxs(z.MenuItem,{..._u(v,i,()=>a(!1)),children:[v.icon&&b.jsx(z.ListItemIcon,{children:v.icon}),b.jsx(z.ListItemText,{primary:v.label})]},`mobile-drawer-group-${g}-item-${v.path}`))}),f=(()=>{if(e){const m=e.filter(g=>g&&g.length>0);return m.length===0?null:m.map((g,v)=>b.jsxs(Z.Fragment,{children:[l(g,v),v<m.length-1&&b.jsx(z.Divider,{})]},`mobile-drawer-group-${v}`))}return r?b.jsx(z.Box,{role:"presentation",onClick:()=>a(!1),children:r}):null})(),p=f??!1;return Z.useEffect(()=>{a(!1)},[o]),p&&b.jsxs(b.Fragment,{children:[b.jsx(z.IconButton,{onClick:()=>a(!0),color:"inherit",title:"Menu",children:b.jsx(Ine,{})}),b.jsx(z.Drawer,{"data-testid":"mobile-drawer",anchor:n,open:s,onClose:()=>a(!1),children:b.jsx(z.Box,{sx:{width:300},display:"flex",flexDirection:"column",justifyContent:"space-between",children:b.jsx(z.Box,{display:"flex",justifyContent:"start",flexDirection:"column",children:f})})})]})},gA=t=>{const{env:e,isProd:n}=t;return n?null:b.jsx(z.Paper,{sx:{borderRadius:0,display:"flex",alignItems:"center",justifyContent:"center"},children:b.jsxs(z.Typography,{variant:"h6",color:"error",children:[e," Environment - Test Data Only"]})})},yA=t=>{const{displayName:e,userMenuOptions:n}=t;return b.jsx(pA,{label:e,menuOptions:n,icon:b.jsx(Ane,{})})},mm=t=>{const{menuOptions:e,orientation:n="horizontal",activeTabIdx:r,sx:o=n=="vertical"?{"& .MuiTabs-indicator":{left:0}}:void 0,slotProps:i={indicator:{sx:n=="horizontal"?{height:4}:{width:4}}}}=t,{palette:s}=z.useTheme(),a=ko.useNavigate();return b.jsx(z.Tabs,{orientation:n,value:r??!1,sx:o,slotProps:i,children:e.map((l,u)=>b.jsx(z.Tab,{icon:l.icon,label:l.label,value:u,..._u(l,a),sx:{alignItems:n=="vertical"?"flex-start":void 0,borderBottom:n=="vertical"?"1px solid":void 0,borderColor:"divider","&.Mui-selected":{backgroundColor:n=="vertical"?s.grey[s.mode=="dark"?800:50]:void 0,color:"inherit"}}},l.label))})},bA=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t;return e.length>0&&b.jsx(z.Paper,{sx:{pl:4,pr:4,borderRadius:0},"data-testid":"navBar",children:b.jsx(mm,{menuOptions:e,activeTabIdx:n,sx:r})})},vA=t=>{const{onToggle:e}=t,{palette:n}=z.useTheme(),r=n.mode==="dark";return b.jsx(z.IconButton,{onClick:e,color:"inherit",title:"Dark Mode Toggle",children:r?b.jsx(II,{}):b.jsx(_I,{})})},Ade=t=>{const{envInfo:e,headerRef:n,logo:r,featureMenuOptions:o=[],userMenuOptions:i=[],onToggleDarkMode:s,quickLinks:a=[],displayName:l,banner:u,position:f="fixed",children:p,sx:m,navBarSx:g}=t,v=ko.useNavigate(),y=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),{palette:x}=z.useTheme(),{pathname:S}=ko.useLocation(),k=x.mode==="dark",[T,C]=D.useState(void 0);D.useEffect(()=>{const P=o.findIndex(N=>N.path&&S.startsWith(N.path));C(P>=0?P:void 0)},[S,o]);const O=s&&b.jsx(vA,{onToggle:s}),R=s&&(y||!y&&l)?[{icon:k?b.jsx(II,{}):b.jsx(_I,{}),label:`Switch to ${k?"Light":"Dark"} mode`,onClick:s},...i]:i;return b.jsxs(z.AppBar,{ref:n,position:f,sx:m,elevation:4,children:[e&&b.jsx(gA,{...e}),u,b.jsxs(z.Toolbar,{sx:{color:"white",display:"flex",justifyContent:"space-between",gap:2},children:[b.jsx(z.Button,{disableRipple:!0,component:ko.Link,to:"/",children:r&&typeof r=="string"?b.jsx("img",{draggable:"false",src:r,style:{width:"200px",filter:"brightness(0) invert(1)"},alt:"logo"}):r}),b.jsxs(z.Box,{display:"flex",gap:2,alignItems:"center",children:[!l&&!y&&O,y&&b.jsx(mA,{menuOptionLists:[o,a,R],anchor:"right"}),!y&&b.jsxs(b.Fragment,{children:[b.jsx(z.Box,{display:"flex",gap:0,children:a==null?void 0:a.map((P,N)=>b.jsxs(z.Box,{display:"flex",alignItems:"center",children:[N>0&&b.jsx(z.Typography,{className:"quickLink-divider",color:x.primary.contrastText,children:"|"}),b.jsx(z.Button,{variant:"text",sx:{color:"white"},..._u(P,v),children:b.jsxs(z.Box,{display:"flex",gap:"3px",alignItems:"center",children:[P.icon,P.label]})})]},P.label))}),p,l&&b.jsx(yA,{displayName:l,userMenuOptions:R})]})]})]}),!y&&b.jsx(bA,{featureMenuOptions:o,activeTabIdx:T,sx:g})]})},Pde=t=>{const{sx:e,menuOptions:n=[]}=t,{pathname:r}=ko.useLocation(),o=z.useMediaQuery(z.useTheme().breakpoints.down("sm")),[i,s]=Z.useState(void 0);return Z.useEffect(()=>{const a=n.findIndex(l=>l.path&&r.startsWith(l.path))??-1;s(a>=0?a:void 0)},[r,n]),!o&&n.length>0&&b.jsx(z.Box,{sx:e,children:b.jsx(z.Card,{sx:{height:"100%",width:200},children:b.jsx(mm,{orientation:"vertical",menuOptions:n,activeTabIdx:i})})})},Nde=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t,{palette:o}=z.useTheme();return e.length>0&&b.jsx(mm,{menuOptions:e,activeTabIdx:n,sx:{margin:"8px",backgroundColor:o.primary.dark,borderRadius:"8px","& .MuiTab-root":{color:o.secondary.light,flexDirection:"row",gap:"2px","& .MuiTab-icon":{marginBottom:"unset"},minHeight:"58px"},"& .MuiTab-root.Mui-selected":{color:o.primary.contrastText,fontSize:"120%"},"& .MuiTabs-indicator":{display:"none"},...r}})},$de=t=>{const{gap:e=1,...n}=t;return b.jsx(z.Box,{display:"flex",flexDirection:"column",gap:e,...n})},Lde=({children:t,getCitations:e})=>{const[n,r]=Z.useState([]),[o,i]=Z.useState(!1);Z.useEffect(()=>{(async()=>e().then(f=>{r(p=>{const m=new Set(p.map(v=>v.id));return[...p.filter(v=>!m.has(v.id)),...f]}),i(!0)}).catch(f=>{console.error(`Error fetching citations: ${f==null?void 0:f.toString()}`)}))()},[]);const s=Z.useCallback(u=>{r(f=>{const p=f.map(v=>{const y=u.find(x=>x.id===v.id);return y||v}),m=new Set(f.map(v=>v.id)),g=u.filter(v=>!m.has(v.id));return[...p,...g]})},[]),a=Z.useCallback(u=>{const f=n.findIndex(p=>p.id===u.id);r(f!==-1?p=>{const m=[...p];return m[f]=u,m}:[...n,u])},[n]),l=Z.useCallback(u=>r(n.filter(f=>f.id!==u)),[n]);return b.jsx(uA.Provider,{value:{citations:n,isLoaded:o,addUpdateCitation:a,deleteCitation:l,batchUpdate:s},children:t})},jde=t=>b.jsx(Qu,{severity:"info",...t}),Bde=t=>b.jsx(Qu,{severity:"warning",...t}),xA=t=>{const{crumbInfo:e}=t,n=ko.useNavigate();return b.jsx(z.Breadcrumbs,{"aria-label":"breadcrumb",separator:b.jsx(Dne,{color:"primary"}),sx:{marginBottom:2},children:e.map(({label:r,path:o},i)=>o&&i<e.length-1?b.jsx(z.Link,{color:"primary",sx:{cursor:"pointer"},onClick:()=>n(o),children:r},r):b.jsx(z.Typography,{color:"primary",children:r},r))})},Fde=t=>{const{title:e,message:n,type:r,onClose:o,autoHideDuration:i,variant:s="leftBorder",elevation:a=6}=t,l=Vde(r);return b.jsx(z.Snackbar,{"data-testid":"message-snackbar",anchorOrigin:{vertical:"bottom",horizontal:"right"},open:!0,onClose:u=>{u==null&&o()},autoHideDuration:i,children:b.jsx(Qu,{"data-testid":"message-snackbar-alert",severity:l,iconMapping:{info:rO(r),warning:rO(r)},onClose:o,elevation:a,variant:s,children:n?b.jsxs(b.Fragment,{children:[b.jsx(z.AlertTitle,{"data-testid":"alertTitle",sx:{fontWeight:"bold"},children:e}),n]}):e})})},Vde=t=>t=="logout"?"info":t=="timeout"?"warning":t,rO=t=>{if(t=="timeout")return b.jsx(xne,{});if(t=="logout")return b.jsx(Rne,{})},zde=t=>{Hde(t);const{title:e,createButtonLabel:n="Add Item",showAddButton:r=!1,onAdd:o=()=>alert("Not implemented yet"),breadcrumbs:i=[],children:s,sx:a={},bottomGutter:l=!1}=t,u=z.useMediaQuery(z.useTheme().breakpoints.down("sm"));return!e&&(!r||!n)?null:b.jsxs(z.Box,{"data-testid":"MBv2-Page-Header",sx:{...a,...l&&{marginBottom:"4px"}},children:[i.length>0&&b.jsx(xA,{crumbInfo:i}),b.jsxs(z.Box,{className:"MBv2_PageHeader_Header",display:"flex",flexDirection:u?"column":"row",justifyContent:"space-between",alignItems:"center",gap:1,children:[b.jsxs(z.Box,{className:"MBv2_PageHeader_TitleAndCreateBtn",display:"flex",flexDirection:"row",justifyContent:u||!s?"space-between":"start",alignItems:"center",width:"100%",gap:1,children:[typeof e=="string"?b.jsx(z.Typography,{className:"MBv2_PageHeader_Title",variant:"h2",children:e}):e,r&&b.jsxs(ao,{className:"MBv2_PageHeader_CreateBtn",onClick:()=>o(),children:[b.jsx(Sne,{style:{marginRight:"0.5rem"}}),n]})]}),s&&b.jsx(z.Box,{width:u?"100%":"50%",children:s})]})]})},Hde=t=>{const{showAddButton:e,onAdd:n,createButtonLabel:r}=t,o="PageHeader component:";e&&!n&&console.warn(`${o} "showAddButton" is true but "onAdd" is not defined.`),e&&!r&&console.warn(`${o} "showAddButton" is true but "createButtonLabel" is not defined`)},Wde=t=>{const{title:e,titleIcon:n,fullWidthIcon:r=!1,children:o,actionLabel:i,action:s,sx:a}=t,l=z.useMediaQuery(z.useTheme().breakpoints.down("sm"));return b.jsxs(z.Card,{sx:a||{padding:"30px 40px",display:"flex",flexDirection:"column",gap:"1rem"},children:[n&&b.jsx(z.Box,{className:"MBv2_SingleActionCard_Img",sx:[r?{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"20px",marginBottom:"10px"}:{display:"inline"}],children:n}),b.jsx(z.Typography,{variant:"h1",display:"inline",fontSize:"calc(20px + .9vw)",className:"MBv2_SingleActionCard_Title",children:e}),o,b.jsx(z.Button,{variant:"contained",color:"primary",onClick:s,fullWidth:l,className:"MBv2_SingleActionCard_ActionButton",children:i})]})};function Ude({...t}){return b.jsx(lA,{onSelectCitations:()=>{},onCancel:()=>{},renderAsSelectablePopup:!1,...t})}const qde=t=>{const{size:e="small"}=t;let n=`${e}px`;switch(e){case"x-small":n="6px";break;case"small":n="10px";break;case"medium":n="14px";break;case"large":n="18px";break;case"x-large":n="22px";break}return b.jsx(z.Box,{height:n})};exports.AlertModal=kde;exports.Autocomplete=CI;exports.Breadcrumbs=xA;exports.Button=ao;exports.Checkbox=TI;exports.CheckboxGroup=Wte;exports.CitationField=yde;exports.CitationFieldProvider=Lde;exports.CitationManager=Ude;exports.Column=$de;exports.ConfirmationModal=Tde;exports.DarkModeToggle=vA;exports.DateField=Op;exports.DateRangeField=mce;exports.DecisionModal=Ede;exports.Diff=SI;exports.DiffCitationTable=Ide;exports.DiffProvider=wM;exports.DiffTable=hA;exports.Drawer=mA;exports.DynamicAutocomplete=zte;exports.EnvironmentBanner=gA;exports.ErrorAlert=sA;exports.FileList=Kte;exports.FileUpload=kI;exports.FloatingNavBar=Nde;exports.Footer=Dde;exports.FormDebugger=xde;exports.Header=Ade;exports.InfoAlert=jde;exports.LoadingButton=Tx;exports.LoadingIndicator=w0;exports.Location=mne;exports.MenuButton=pA;exports.Modal=Zu;exports.MultiAutocomplete=Hte;exports.NavBar=bA;exports.NotApplicableCheckbox=fA;exports.PageHeader=zde;exports.PaginatedTable=WD;exports.ProfileMenu=yA;exports.RadioGroup=MI;exports.RangeSlider=gne;exports.ReadOnly=Aa;exports.ReadOnlyProvider=vM;exports.RepeatableFormGroup=Sde;exports.RichTextField=uue;exports.Row=oA;exports.ScrollToTop=vde;exports.SearchField=jne;exports.Select=yne;exports.SelectableCitationManager=cA;exports.Sidebar=Pde;exports.SingleActionCard=Wde;exports.Snackbar=Fde;exports.Spacer=qde;exports.Stepper=wde;exports.Submit=bde;exports.SuccessAlert=aA;exports.Switch=bne;exports.Table=Cx;exports.Tabs=mm;exports.TextArea=vne;exports.TextField=xs;exports.TextIcon=I0;exports.ValidationError=Mr;exports.WarningAlert=Bde;exports.commonTheme=In;exports.darkTheme=ZV;exports.lightTheme=XV;exports.useDiff=Ra;exports.useReadOnly=_a;
|
package/dist/index.es.js
CHANGED
|
@@ -63412,7 +63412,7 @@ const JD = tc(void 0), XD = () => {
|
|
|
63412
63412
|
} else u.id < f.id ? (i.push({ ...u, changeType: "deleted" }), s++) : (i.push({ ...f, changeType: "added" }), a++);
|
|
63413
63413
|
}
|
|
63414
63414
|
for (; s < e.length; )
|
|
63415
|
-
i.push({ ...e[s], changeType: "
|
|
63415
|
+
i.push({ ...e[s], changeType: "deleted" }), s++;
|
|
63416
63416
|
for (; a < n.length; )
|
|
63417
63417
|
i.push({ ...n[a], changeType: "added" }), a++;
|
|
63418
63418
|
return { dataDiff: i, unmodifiedCount: l };
|
package/dist/index.umd.js
CHANGED
|
@@ -405,4 +405,4 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
|
|
|
405
405
|
3. "-" cannot repeat`);Kt.customSchemes.push([t,e])}function JZ(){Kt.scanner=HZ(Kt.customSchemes);for(let t=0;t<Kt.tokenQueue.length;t++)Kt.tokenQueue[t][1]({scanner:Kt.scanner});Kt.parser=UZ(Kt.scanner.tokens);for(let t=0;t<Kt.pluginQueue.length;t++)Kt.pluginQueue[t][1]({scanner:Kt.scanner,parser:Kt.parser});return Kt.initialized=!0,Kt}function nv(t){return Kt.initialized||JZ(),qZ(Kt.parser.start,t,w2(Kt.scanner.start,t))}nv.scan=w2;function M2(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new ev(n),o=nv(t),i=[];for(let s=0;s<o.length;s++){const a=o[s];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}const rv="[\0- -\u2029 ]",XZ=new RegExp(rv),ZZ=new RegExp(`${rv}$`),QZ=new RegExp(rv,"g");function eQ(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function tQ(t){return new en({key:new On("autolink"),appendTransaction:(e,n,r)=>{const o=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),i=e.some(u=>u.getMeta("preventAutolink"));if(!o||i)return;const{tr:s}=r,a=AR(n.doc,[...e]);if(BR(a).forEach(({newRange:u})=>{const f=PR(r.doc,u,g=>g.isTextblock);let p,m;if(f.length>1)p=f[0],m=r.doc.textBetween(p.pos,p.pos+p.node.nodeSize,void 0," ");else if(f.length){const g=r.doc.textBetween(u.from,u.to," "," ");if(!ZZ.test(g))return;p=f[0],m=r.doc.textBetween(p.pos,u.to,void 0," ")}if(p&&m){const g=m.split(XZ).filter(Boolean);if(g.length<=0)return!1;const v=g[g.length-1],y=p.pos+m.lastIndexOf(v);if(!v)return!1;const x=nv(v).map(S=>S.toObject(t.defaultProtocol));if(!eQ(x))return!1;x.filter(S=>S.isLink).map(S=>({...S,from:y+S.start+1,to:y+S.end+1})).filter(S=>r.schema.marks.code?!r.doc.rangeHasMark(S.from,S.to,r.schema.marks.code):!0).filter(S=>t.validate(S.value)).filter(S=>t.shouldAutoLink(S.value)).forEach(S=>{Ug(S.from,S.to,r.doc).some(k=>k.mark.type===t.type)||s.addMark(S.from,S.to,t.type.create({href:S.href}))})}}),!!s.steps.length)return s}})}function nQ(t){return new en({key:new On("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let s=r.target;const a=[];for(;s.nodeName!=="DIV";)a.push(s),s=s.parentNode;if(!a.find(m=>m.nodeName==="A"))return!1;const l=jg(e.state,t.type.name),u=r.target,f=(o=u==null?void 0:u.href)!==null&&o!==void 0?o:l.href,p=(i=u==null?void 0:u.target)!==null&&i!==void 0?i:l.target;return u&&f?(window.open(f,p),!0):!1}}})}function rQ(t){return new en({key:new On("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:o}=e,{selection:i}=o,{empty:s}=i;if(s)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const l=M2(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!l?!1:t.editor.commands.setMark(t.type,{href:l.href})}}})}function Sa(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace(QZ,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const oQ=xr.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){O2(t);return}O2(t.scheme,t.optionalSlashes)})},onDestroy(){GZ()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Sa(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Sa(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Sa(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",xt(this.options.HTMLAttributes,t),0]:["a",xt(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Sa(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Sa(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[as({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,o=M2(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!Sa(s,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(tQ({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Sa(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(nQ({type:this.type})),this.options.linkOnPaste&&t.push(rQ({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}});function iQ(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:a}=t,l=r&&!o,u=l3(n),f=new RegExp(`\\s${u}$`),p=s?"^":"",m=o?"":u,g=l?new RegExp(`${p}${u}.*?(?=\\s${m}|$)`,"gm"):new RegExp(`${p}(?:^)?${u}[^\\s${m}]*`,"gm"),v=((e=a.nodeBefore)===null||e===void 0?void 0:e.isText)&&a.nodeBefore.text;if(!v)return null;const y=a.pos-v.length,x=Array.from(v.matchAll(g)).pop();if(!x||x.input===void 0||x.index===void 0)return null;const S=x.input.slice(Math.max(0,x.index-1),x.index),k=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(S);if(i!==null&&!k)return null;const T=y+x.index;let C=T+x[0].length;return l&&f.test(v.slice(C-1,C+1))&&(x[0]+=" ",C+=1),T<a.pos&&C>=a.pos?{range:{from:T,to:C},query:x[0].slice(n.length),text:x[0]}:null}const sQ=new On("suggestion");function aQ({pluginKey:t=sQ,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:u="",decorationEmptyClass:f="is-empty",command:p=()=>null,items:m=()=>[],render:g=()=>({}),allow:v=()=>!0,findSuggestionMatch:y=iQ}){let x;const S=g==null?void 0:g(),k=new en({key:t,view(){return{update:async(T,C)=>{var O,I,N,$,H,M,F;const z=(O=this.key)===null||O===void 0?void 0:O.getState(C),B=(I=this.key)===null||I===void 0?void 0:I.getState(T.state),P=z.active&&B.active&&z.range.from!==B.range.from,_=!z.active&&B.active,A=z.active&&!B.active,R=!_&&!A&&z.query!==B.query,j=_||P&&R,K=R||P,U=A||P&&R;if(!j&&!K&&!U)return;const Y=U&&!j?z:B,oe=T.dom.querySelector(`[data-decoration-id="${Y.decorationId}"]`);x={editor:e,range:Y.range,query:Y.query,text:Y.text,items:[],command:fe=>p({editor:e,range:Y.range,props:fe}),decorationNode:oe,clientRect:oe?()=>{var fe;const{decorationId:me}=(fe=this.key)===null||fe===void 0?void 0:fe.getState(e.state),G=T.dom.querySelector(`[data-decoration-id="${me}"]`);return(G==null?void 0:G.getBoundingClientRect())||null}:null},j&&((N=S==null?void 0:S.onBeforeStart)===null||N===void 0||N.call(S,x)),K&&(($=S==null?void 0:S.onBeforeUpdate)===null||$===void 0||$.call(S,x)),(K||j)&&(x.items=await m({editor:e,query:Y.query})),U&&((H=S==null?void 0:S.onExit)===null||H===void 0||H.call(S,x)),K&&((M=S==null?void 0:S.onUpdate)===null||M===void 0||M.call(S,x)),j&&((F=S==null?void 0:S.onStart)===null||F===void 0||F.call(S,x))},destroy:()=>{var T;x&&((T=S==null?void 0:S.onExit)===null||T===void 0||T.call(S,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(T,C,O,I){const{isEditable:N}=e,{composing:$}=e.view,{selection:H}=T,{empty:M,from:F}=H,z={...C};if(z.composing=$,N&&(M||e.view.composing)){(F<C.range.from||F>C.range.to)&&!$&&!C.composing&&(z.active=!1);const B=y({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:H.$from}),P=`id_${Math.floor(Math.random()*4294967295)}`;B&&v({editor:e,state:I,range:B.range,isActive:C.active})?(z.active=!0,z.decorationId=C.decorationId?C.decorationId:P,z.range=B.range,z.query=B.query,z.text=B.text):z.active=!1}else z.active=!1;return z.active||(z.decorationId=null,z.range={from:0,to:0},z.query=null,z.text=null),z}},props:{handleKeyDown(T,C){var O;const{active:I,range:N}=k.getState(T.state);return I&&((O=S==null?void 0:S.onKeyDown)===null||O===void 0?void 0:O.call(S,{view:T,event:C,range:N}))||!1},decorations(T){const{active:C,range:O,decorationId:I,query:N}=k.getState(T);if(!C)return null;const $=!(N!=null&&N.length),H=[l];return $&&H.push(f),Jt.create(T.doc,[Kn.inline(O.from,O.to,{nodeName:a,class:H.join(" "),"data-decoration-id":I,"data-decoration-content":u})])}}});return k}function lQ({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const o=new On;return{editor:t,char:r,pluginKey:o,command:({editor:i,range:s,props:a})=>{var l,u,f;const p=i.view.state.selection.$to.nodeAfter;((l=p==null?void 0:p.text)===null||l===void 0?void 0:l.startsWith(" "))&&(s.to+=1),i.chain().focus().insertContentAt(s,[{type:n,attrs:{...a,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(f=(u=i.view.dom.ownerDocument.defaultView)===null||u===void 0?void 0:u.getSelection())===null||f===void 0||f.collapseToEnd()},allow:({state:i,range:s})=>{const a=i.doc.resolve(s.from),l=i.schema.nodes[n];return!!a.parent.type.contentMatch.matchType(l)},...e}}function _2(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>lQ({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function I2(t,e){const n=_2(t),r=n.find(o=>o.char===e);return r||(n.length?n[0]:null)}const cQ=tn.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,r;return`${(n=e==null?void 0:e.char)!==null&&n!==void 0?n:"@"}${(r=t.attrs.label)!==null&&r!==void 0?r:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var r,o;return["span",xt(this.HTMLAttributes,t.HTMLAttributes),`${(r=n==null?void 0:n.char)!==null&&r!==void 0?r:"@"}${(o=e.attrs.label)!==null&&o!==void 0?o:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:t=>t.getAttribute("data-mention-suggestion-char"),renderHTML:t=>({"data-mention-suggestion-char":t.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){const n=I2(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",xt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=xt({"data-type":this.name},this.options.HTMLAttributes,e);const o=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof o=="string"?["span",xt({"data-type":this.name},this.options.HTMLAttributes,e),o]:o},renderText({node:t}){const e={options:this.options,node:t,suggestion:I2(this,t.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1;const{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;e.doc.nodesBetween(i-1,i,(l,u)=>{if(l.type.name===this.name)return n=!0,t.insertText(this.options.deleteTriggerWithBackspace?"":this.options.suggestion.char||"",u,u+l.nodeSize),!1});let s=new fi,a=0;return e.doc.nodesBetween(i-1,i,(l,u)=>{if(l.type.name===this.name)return n=!0,s=l,a=u,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":s.attrs.mentionSuggestionChar,a,a+s.nodeSize),n})}},addProseMirrorPlugins(){return _2(this).map(aQ)}}),A2=ln.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new en({key:new On("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((s,a)=>{const l=r>=a&&r<=a+s.nodeSize,u=!s.isLeaf&&af(s);if((l||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const p=Kn.node(a,a+s.nodeSize,{class:f.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:a,hasAnchor:l}):this.options.placeholder});o.push(p)}return this.options.includeChildren}),Jt.create(t,o)}}})]}}),uQ=xr.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",xt(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),dQ=tn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",xt(this.options.HTMLAttributes,t),0]}}),fQ=tn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",xt(this.options.HTMLAttributes,t),0]}}),pQ=tn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",xt(this.options.HTMLAttributes,t),0]}}),hQ=/^\s*(\[([( |x])?\])\s$/,mQ=tn.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",xt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),u=()=>{var f,p;a.ariaLabel=((p=(f=this.options.a11y)===null||f===void 0?void 0:f.checkboxLabel)===null||p===void 0?void 0:p.call(f,t,a.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};return u(),i.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",f=>f.preventDefault()),a.addEventListener("change",f=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:p}=f.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const g=n();if(typeof g!="number")return!1;const v=m.doc.nodeAt(g);return m.setNodeMarkup(g,void 0,{...v==null?void 0:v.attrs,checked:p}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,p)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([f,p])=>{o.setAttribute(f,p)}),o.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,i.append(a,s),o.append(i,l),Object.entries(e).forEach(([f,p])=>{o.setAttribute(f,p)}),{dom:o,contentDOM:l,update:f=>f.type!==this.type?!1:(o.dataset.checked=f.attrs.checked,a.checked=f.attrs.checked,u(),!0)}}},addInputRules(){return[al({find:hQ,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),gQ=tn.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",xt(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),yQ=ln.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),D2=Z.forwardRef((t,e)=>{const[n,r]=Z.useState(0),o=l=>{if(l>=t.items.length)return;const u=t.items[l],f={id:u.id,label:u.mentionLabel};t.command(f)},i=()=>{r((n+t.items.length-1)%t.items.length)},s=()=>{r((n+1)%t.items.length)},a=()=>{o(n)};return Z.useEffect(()=>r(0),[t.items]),Z.useImperativeHandle(e,()=>({onKeyDown:({event:l})=>l.key==="ArrowUp"?(i(),!0):l.key==="ArrowDown"?(s(),!0):l.key==="Enter"?(a(),!0):!1})),t.items.length>0?b.jsx(V.Paper,{elevation:5,children:b.jsx(V.List,{dense:!0,sx:{overflow:"hidden"},children:t.items.map((l,u)=>b.jsx(V.ListItem,{disablePadding:!0,children:b.jsx(V.ListItemButton,{selected:u===n,onClick:()=>o(u),children:l.mentionLabel})},l.id))})}):null});D2.displayName="SuggestionList";const P2={bottom:0,height:0,left:0,right:0,top:0,width:0,x:0,y:0,toJSON(){return{}}},bQ={items:async({query:t})=>Promise.resolve(["Lea Thompson","Cyndi Lauper","Tom Cruise","Madonna","Jerry Hall","Joan Collins","Winona Ryder","Christina Applegate","Alyssa Milano","Molly Ringwald","Ally Sheedy","Debbie Harry","Olivia Newton-John","Elton John","Michael J. Fox","Axl Rose","Emilio Estevez","Ralph Macchio","Rob Lowe","Jennifer Grey","Mickey Rourke","John Cusack","Matthew Broderick","Justine Bateman","Lisa Bonet","Benicio Monserrate Rafael del Toro Sánchez"].map((e,n)=>({mentionLabel:e,id:n.toString()})).filter(e=>e.mentionLabel.toLowerCase().startsWith(t.toLowerCase())).slice(0,5)),render:()=>{let t,e;return{onStart:n=>{t=new pO(D2,{props:n,editor:n.editor}),e=su("body",{getReferenceClientRect:()=>{var r;return((r=n.clientRect)==null?void 0:r.call(n))??P2},appendTo:()=>document.body,content:t.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})[0]},onUpdate(n){t==null||t.updateProps(n),e==null||e.setProps({getReferenceClientRect:()=>{var r;return((r=n.clientRect)==null?void 0:r.call(n))??P2}})},onKeyDown(n){return n.event.key==="Escape"?(e==null||e.hide(),!0):t!=null&&t.ref?t.ref.onKeyDown(n):!1},onExit(){e==null||e.destroy(),t==null||t.destroy(),e=void 0,t=void 0}}}},vQ=oQ.extend({inclusive:!1}),xQ=uQ.extend({excludes:"superscript"}),wQ=oM.extend({excludes:"subscript"});function SQ({placeholder:t}={}){return Z.useMemo(()=>[c7.configure({resizable:!0}),pQ,fQ,dQ,lT,uT,dT,mT,ET,_T,IT,xQ,wQ,DT,iT,oT,cT,kT,rM,AT,vQ.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1}),K9,hT,U9,yQ.configure({types:["heading","paragraph","image"]}),AZ,DZ,PZ,Hj,RT.configure({multicolor:!0}),TT,l8,fT,gQ,mQ.configure({nested:!0}),cQ.configure({suggestion:bQ}),A2.configure({placeholder:t}),CT],[t])}function N2(t){return Array.from(t).filter(e=>(e.type||"").toLowerCase().startsWith("image/"))}const CQ=t=>{const e=SQ({placeholder:"Add your own content here..."});if(t.renderContentOnly)return b.jsx(tM,{content:t.renderContentOnly,extensions:e});const{name:n,label:r,labelProps:o={fontSize:"0.9em",color:"#808080",fontWeight:"400"},onUploadFiles:i,readOnly:s=!1}=t,[a,l,u]=jt.useField({name:n}),{setValue:f}=u,{value:p}=a;Z.useEffect(()=>{var S,k,T;(T=(k=(S=m==null?void 0:m.current)==null?void 0:S.editor)==null?void 0:k.commands)==null||T.setContent(p)},[p]);const m=Z.useRef(null),g=Z.useCallback((S,k)=>{var C;const T=(C=m.current)==null?void 0:C.editor;if(!(!T||!i))if(i instanceof Promise)i(S).then(O=>{tb({images:O,editor:T,position:k})});else{const O=i(S);tb({images:O,editor:T,position:k})}},[]),v=Z.useCallback((S,k,T,C)=>{var I;if(!(k instanceof DragEvent)||!k.dataTransfer)return!1;const O=N2(k.dataTransfer.files);if(O.length>0){const N=(I=S.posAtCoords({left:k.clientX,top:k.clientY}))==null?void 0:I.pos;return g(O,N),k.preventDefault(),!0}return!1},[g]),y=Z.useCallback((S,k,T)=>{if(!k.clipboardData)return!1;const C=N2(k.clipboardData.files);return C.length>0?(g(C),!0):!1},[g]),x=b.jsx(V.Box,{sx:{"& .ProseMirror":{"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:s?0:50}}},children:b.jsx(eM,{ref:m,extensions:e,content:p,editable:!s,editorProps:{handleDrop:v,handlePaste:y},renderControls:s?void 0:()=>b.jsx(_Z,{onUploadFiles:i}),onBlur:()=>{var S,k;return f(((k=(S=m.current)==null?void 0:S.editor)==null?void 0:k.getHTML())??"")},RichTextFieldProps:{variant:"outlined",MenuBarProps:{hide:s}},children:()=>b.jsxs(b.Fragment,{children:[b.jsx(I7,{}),b.jsx(j7,{})]})})});return b.jsxs(V.Box,{display:"flex",flexDirection:"column",children:[r&&b.jsx(V.Typography,{...o,children:r}),x]})},ov=t=>{const{title:e="Loading...",message:n}=t;return b.jsxs(V.Box,{className:"loading-page",sx:{gap:2},"data-testid":"loading-page",children:[b.jsxs(V.Box,{className:"text-content",children:[b.jsx(V.Typography,{variant:"h1","data-testid":"title",children:e}),n&&b.jsx(V.Typography,{"data-testid":"message",children:n})]}),b.jsx(V.CircularProgress,{size:75,"data-testid":"loading-spinner"})]})},$2=t=>{const{colSpan:e,isExpanded:n,renderExpand:r,obj:o,asMobileCard:i=!1,reRenderExpand:s=!1}=t,[a,l]=Z.useState(!1),[u,f]=Z.useState(void 0);Z.useEffect(()=>{n&&(!a||s)&&(l(!0),f(r(o)))},[n,o]);const p={"&:last-child td":{borderBottom:"unset"}};return i?b.jsx(V.Collapse,{in:n,children:u}):b.jsx(V.TableRow,{sx:p,children:b.jsx(V.TableCell,{sx:{paddingBottom:0,paddingTop:0},colSpan:e,children:b.jsx(V.Collapse,{in:n,children:u})})})},iv=t=>{const{id:e,getRowKey:n=X=>"id"in X&&(typeof X.id=="string"||typeof X.id=="number")?X.id:(console.warn(`Table: "id: string | number" not found in ${JSON.stringify(X)}. Please implement the Table.getRowKey prop so Table knows how to uniquely identify this row.`),JSON.stringify(X)),columns:r,data:o=[],onRowClick:i,onRowClickObj:s,renderExpand:a,hideColumnsOnMobile:l=[],sortField:u,sortOrder:f,onSortChange:p,allowSortCols:m,fixedLayout:g=!1,className:v,emptyTableMsg:y="No items to display",errorTableMsg:x,retryCallback:S,isLoading:k=!1,disableMobileCards:T=!1,highlightSelectedRow:C=!1,headerRowStyle:O={},stickyHeader:I,reRenderExpand:N=!1,expandOnRowClick:$=!1,tooltipColor:H,...M}=t,{palette:F}=V.useTheme(),[z,B]=Z.useState(void 0),[P,_]=Z.useState(void 0);TQ(t);const A=X=>{X!==u?p&&p(X,"asc"):p&&p(u,f==="asc"?"desc":"asc")},R=X=>u===X?f:null,j=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),K=j&&l?r.filter(X=>!(l.includes(xn(X))||X.hideCol)):r.filter(X=>!X.hideCol);a&&!j&&K.unshift({key:"MBv2_Expandable_Column",fieldName:"id",label:"",render:X=>{const le=z===X;return b.jsx(V.IconButton,{"data-testid":"expand-collapse-btn","aria-label":le?"collapse row":"expand row",size:"small",onClick:()=>re(X),children:le?b.jsx(dp,{"data-testid":"collapse-up"}):b.jsx(p0,{"data-testid":"expand-down"})})}});const U=p!==void 0,Y=X=>U?m?m.includes(X):!0:!1,oe=b.jsxs(V.Box,{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"row",children:[b.jsx(HU,{})," ",y]}),fe=b.jsxs(V.Box,{"data-testid":"table-fetch-error-msg",display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"row",children:[b.jsx(sw,{color:"error"})," ",x,S&&b.jsx(V.Button,{variant:"text",onClick:S,children:"Retry?"})]}),me=()=>{if(k)return b.jsx(V.TableRow,{children:b.jsx(V.TableCell,{colSpan:r.length,align:"center",children:b.jsx(V.Box,{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"row",children:b.jsx(ov,{})})})});if(x)return b.jsx(V.TableRow,{children:b.jsx(V.TableCell,{colSpan:r.length,align:"center",children:fe})});if(o.length===0)return b.jsx(V.TableRow,{children:b.jsx(V.TableCell,{colSpan:r.length,align:"center",children:oe})})},G=()=>{if(k)return b.jsx(ov,{});if(x)return fe;if(o.length===0)return oe},te=X=>{C&&_(X)},ue=X=>{const le=n(X);if((i||s)&&(i==null||i(le),s==null||s(X),te(le)),a&&$){const xe=z===le?void 0:le;B(xe),te(xe)}},re=X=>{const le=z===X?void 0:X;B(le),te(le)},ie=X=>{if(!a)return;const le=z===n(X);return b.jsxs(b.Fragment,{children:[b.jsxs(V.Button,{"data-testid":"show-more-less-btn",variant:"text",onClick:()=>re(n(X)),children:[le?b.jsx(dp,{}):b.jsx(p0,{})," Show"," ",le?"Less":"More"]}),b.jsx($2,{colSpan:r.length,isExpanded:n(X)===z,obj:X,renderExpand:xe=>a(xe),asMobileCard:!0})]})},de=typeof C=="string"?C:F.grey[F.mode=="dark"?600:50],ye=X=>{const le=P===n(X)?de:"inherit";return{cursor:i||$?"pointer":"default",backgroundColor:le,...a?{"& > td":{borderBottom:"unset"}}:{"&:last-child td":{borderBottom:"unset"}},...i&&{"&:hover":{backgroundColor:le===de?uG(le,.1):de}}}},ee=F.grey[F.mode==="dark"?600:400],ce=X=>X&&b.jsx(V.Tooltip,{title:X,children:b.jsx(VU,{"data-testid":"MBv2_table-tooltip",fontSize:"small",sx:{color:H??ee,marginLeft:"2px"}})});return j&&!T?b.jsxs("div",{...e?{id:`mobile-table-${e}`}:{},className:v,"data-testid":"mui-table-mobile",children:[U&&b.jsxs(b.Fragment,{children:[b.jsxs(V.Box,{display:"flex",className:"MBv2_Table_Stack_Sort",children:[b.jsx(V.TextField,{select:!0,sx:{flexGrow:1},id:"demo-simple-select",size:"small",value:u??"",label:"Sort By...",onChange:X=>A(X.target.value),fullWidth:!0,children:K.map(X=>{if(Y(xn(X)))return b.jsx(V.MenuItem,{value:xn(X),children:X.label??Ln(xn(X))},`rowHeader-${xn(X)}`)})}),b.jsx(V.IconButton,{onClick:()=>{u&&A(u)},children:b.jsx(GU,{className:`sort-icon-${f}`})})]}),b.jsx(V.Divider,{sx:{margin:"10px 0"}})]}),G()??o.map(X=>b.jsxs(V.Card,{className:"MBv2_Table_Stack_Container",sx:{margin:"5px 0",padding:"5px",overflowX:"auto",...ye(X)},onClick:()=>ue(X),"data-testid":`card-${n(X)}`,children:[b.jsx("table",{className:"MBv2_Table_Stack",children:b.jsx("tbody",{className:"MBv2_Table_Stack_Body",children:K.map(le=>b.jsxs("tr",{className:"MBv2_Table_Stack_Row",children:[b.jsxs("td",{className:`MBv2_Table_Stack_Cell_Label MBv2_Table_Stack_Col_${xn(le)}`,style:{textWrap:"nowrap"},children:[le.label??Ln(xn(le)),ce(le.tooltip)]}),b.jsx("td",{className:`MBv2_Table_Stack_Cell_Value MBv2_Table_Stack_Val_${xn(le)}`,style:{paddingLeft:"10px"},children:$u(le,X,j)})]},`row-${n(X)}-${xn(le)}`))})}),ie(X)]},n(X)))]}):b.jsx(V.TableContainer,{component:V.Card,"data-testid":"mui-table",...e?{id:`table-${e}`}:{},className:v,style:I?{maxHeight:I,overflow:"auto"}:{},children:b.jsxs(V.Table,{stickyHeader:I!=="undefined",style:{tableLayout:g?"fixed":"auto"},className:"MBv2_Table",sx:O?{"& .MuiTableCell-head":{...O}}:{},...M,children:[b.jsx(V.TableHead,{className:"MBv2_Table_Head",children:b.jsx(V.TableRow,{className:"MBv2_Table_Head_Row",children:K.map((X,le)=>{const xe=Y(xn(X));return b.jsx(V.TableCell,{width:Array.isArray(g)?g[le]:"auto",sx:X.tableCellSx??{},children:b.jsx(V.Box,{style:{display:"flex",alignItems:"center"},children:b.jsxs(V.Box,{sx:[xe&&{"&:hover":{cursor:"pointer",backgroundColor:F.mode==="dark"?"#222222":"#ededed",borderRadius:2}}],style:{display:"flex",alignItems:"center",padding:"5px",paddingLeft:"6px",marginLeft:"-6px"},onClick:xe?()=>A(xn(X)):void 0,children:[b.jsx("strong",{className:"MBv2_Table_Col_Label",style:{wordBreak:"normal"},"data-testid":"column-title",children:X.label??Ln(xn(X))}),ce(X.tooltip),xe&&R(xn(X))==="asc"&&b.jsx(dp,{style:{marginLeft:"5px"}}),xe&&R(xn(X))==="desc"&&b.jsx(p0,{style:{marginLeft:"5px"}}),xe&&R(xn(X))!=="asc"&&R(xn(X))!=="desc"&&b.jsx(KU,{style:{marginLeft:"5px"}})]})})},`rowHeader-${xn(X)}`)})})}),b.jsx(V.TableBody,{className:"MBv2_Table_Body",children:me()??o.map(X=>b.jsxs(Z.Fragment,{children:[b.jsx(V.TableRow,{"data-testid":`row-${n(X)}`,className:"MBv2_Table_Body_Row",onClick:()=>ue(X),sx:ye(X),children:K.map(le=>b.jsx(V.TableCell,{className:`MBv2_Table_Body_Cell MBv2_Table_Body_Col_${xn(le)}`,children:$u(le,X,j)},`row-${n(X)}-${xn(le)}`))}),a&&b.jsx($2,{colSpan:K.length,isExpanded:n(X)===z,obj:X,renderExpand:le=>a(le),reRenderExpand:N})]},n(X)))})]})})},TQ=t=>{const{fixedLayout:e,renderExpand:n,columns:r,expandOnRowClick:o,onRowClick:i,onRowClickObj:s}=t,a="Table component:";Array.isArray(e)&&(!n&&e.length!==r.length&&console.warn(`${a} Length of "fixedLayout" is not equal to the length of "columns".`),n&&e.length!==r.length+1&&console.warn(`${a} Length of "fixedLayout" is not equal to the length of "columns"+1. Make sure you're including a percentage for the expand/collapse column AND each column in "columns".`)),o&&!n&&console.warn(`${a} renderExpand should be defined when expandOnRowClick is defined`),i&&s&&console.warn(`${a} 'onRowClick' and 'onRowClickObj' are both defined. Only one should be defined.`)},xn=t=>t.key??t.fieldName,kQ=(t,e)=>e.split(".").reduce((n,r)=>{if(n&&typeof n=="object")return n[r]},t),$u=(t,e,n=!1)=>{const r=kQ(e,t.fieldName);return t.render?t.render(r,e,n):r},L2=t=>{const{paginationState:e,onPageChange:n,onRowsPerPageChange:r,hidePaginationControls:o=!1,rowsPerPageOptions:i=[5,10,25],...s}=t,{pageNo:a,pageSize:l,totalCount:u,sortField:f,sortOrder:p}=e,m=x=>{n(x)},g=x=>{r(parseInt(x.target.value,10))},v=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),y=!t.data||t.data&&t.data.length===0;return b.jsxs(V.Box,{children:[b.jsx(iv,{sortOrder:p,sortField:f,...s}),!o&&!y&&b.jsx(V.TablePagination,{"data-testid":"pagination-controls",component:"div",rowsPerPageOptions:v?[]:i,count:u,rowsPerPage:l,page:a,onPageChange:(x,S)=>m(S),onRowsPerPageChange:g,sx:{flexGrow:1,marginRight:{xs:0,md:15}}})]})},B2=()=>({height:window.innerHeight,width:window.innerWidth}),F2=()=>{const[t,e]=Z.useState(B2());return Z.useEffect(()=>{const n=()=>{e(B2())};return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},co=t=>{const{name:e="button",color:n="primary",fullWidthOnMobile:r=!0,type:o="button",variant:i="contained"}=t,{width:s}=F2(),a=["locationInBar","closeDialog","fullWidthOnMobile"],l=r&&s<600;return b.jsx(V.Button,{role:"button",name:e,color:n,variant:i,type:o,fullWidth:t.fullWidth?!0:l,...cr({...t},a)})},EQ=t=>{const{citation:e,anchorEl:n,onClose:r}=t;return b.jsx(V.Popper,{open:e!==null,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},children:e&&b.jsxs(V.Box,{component:V.Paper,p:1,display:"flex",gap:1,boxShadow:9,"data-testid":`citation-table_launch-link-prompt-${e.id}`,flexDirection:"column",alignItems:"end",children:[b.jsxs(V.Typography,{variant:"body2",sx:{wordBreak:"break-all",maxWidth:"350px"},children:["Are you sure you want to go to ",b.jsx("br",{}),b.jsx("b",{children:e.url}),"?"]}),b.jsxs(V.Box,{display:"flex",flexDirection:"row",children:[b.jsx(co,{size:"small",variant:"text",onClick:r,"data-testid":`citation-table_launch-prompt-${e.id}-noBtn`,children:"No"}),b.jsx(co,{size:"small",startIcon:b.jsx(h0,{}),onClick:()=>{window.open(e.url,"_blank","noopener,noreferrer"),r()},"data-testid":`citation-table_launch-prompt-${e.id}-yesBtn`,children:"Yes"})]})]})})},OQ=t=>{const{citation:e,anchorEl:n,onDeleteCitation:r,onClose:o}=t;if(r)return b.jsx(V.Popper,{open:e!==null,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},children:e&&b.jsxs(V.Box,{component:V.Paper,p:1,display:"flex",gap:1,boxShadow:9,"data-testid":`citation-table_delete-prompt-${e.id}`,children:[b.jsxs(V.Typography,{variant:"body2",children:["Are you sure you want to delete this ",e.fileName?"attachment":"citation","?"]}),b.jsxs(V.Box,{display:"flex",flexDirection:"row",children:[b.jsx(co,{size:"small",variant:"text",onClick:o,"data-testid":`citation-table_delete-prompt-${e.id}-noBtn`,children:"No"}),b.jsx(co,{size:"small",color:"error",startIcon:b.jsx(Jb,{}),onClick:()=>r(e.id).finally(o),"data-testid":`citation-table_delete-prompt-${e.id}-yesBtn`,children:"Yes"})]})]})})},MQ=t=>{const{refreshKey:e,title:n,onCancel:r,onNewCitation:o,onNewAttachment:i,onEditCitation:s,onEditAttachment:a,onDeleteCitation:l,onDownloadAttachment:u,onViewAttachment:f,onSelect:p,getCitationsPaginated:m,selectedIds:g,setSelectedIds:v,onError:y=()=>{},condenseTable:x=!1,canSelect:S=!1,canLaunchUrl:k,addlActions:T,readOnly:C=!1,showCloseBtn:O=!1}=t,I=!!t.canCreate&&!C,N=!!t.canEdit&&!C,$=!!t.canDelete&&!C,{palette:H}=V.useTheme(),[M,F]=Z.useState([]),[z,B]=Z.useState(!1),[P,_]=Z.useState(!0),[A,R]=Z.useState(null),[j,K]=Z.useState(null),[U,Y]=Z.useState(null),[oe,fe]=Z.useState({pageNo:0,pageSize:x?5:10,totalCount:0}),me=()=>{B(!1),_(!0),m({pageNo:oe.pageNo,pageSize:oe.pageSize}).then(le=>(F(le.data),fe({...oe,totalCount:le.totalCount}),le)).catch(le=>{y(le),B(!0),F([])}).finally(()=>_(!1))};Z.useEffect(me,[oe.pageNo,oe.pageSize,e]);const G=()=>{K(null),Y(null),R(null)},te=b.jsx(co,{variant:S?"outlined":"contained",size:S?"small":"medium",onClick:o,startIcon:b.jsx(Vf,{}),children:"Add Citation"}),ue=b.jsx(co,{variant:S?"outlined":"contained",size:S?"small":"medium",onClick:i,startIcon:b.jsx(PM,{}),children:"Add Attachment"}),re=le=>{if(!(!N&&!C)&&!(C&&!x))return b.jsx(V.Tooltip,{title:C?"View":"Edit",children:b.jsx(V.IconButton,{color:"primary",onClick:()=>le.fileName?a(le):s(le),"data-testid":`citation-table_edit-btn-${le.id}`,children:C?b.jsx(JU,{}):b.jsx(zU,{})})})},ie=le=>{if(!(!$||C))return b.jsx(V.Tooltip,{title:"Delete",children:b.jsx(V.IconButton,{color:"error",onClick:xe=>{K(le),R(xe.currentTarget)},"data-testid":`citation-table_delete-btn-${le.id}`,children:b.jsx(Jb,{})})})},de=le=>{if(!k)return;if(!le.fileName)return b.jsx(V.Tooltip,{title:"Open URL",children:b.jsx(V.IconButton,{color:"primary",onClick:_e=>{R(_e.currentTarget),Y(le)},"data-testid":`citation-table_launch-link-btn-${le.id}`,sx:{visibility:k!=null&&k(le)?"visible":"hidden"},children:b.jsx(h0,{})})})},ye=le=>{if(!f||!le.fileName)return;const xe=["pdf","png","jpg","jpeg","gif","bmp","svg","webp","mp3","wav","mp4","webm","html","htm","txt","xml","json","csv"],_e=le.fileName.split(".").pop();if(!(!_e||!xe.includes(_e)))return b.jsx(V.Tooltip,{title:"View File",children:b.jsx(V.IconButton,{color:"primary",onClick:()=>f==null?void 0:f(le),"data-testid":`citation-table_view-file-btn-${le.id}`,children:b.jsx(h0,{})})})},ee=le=>{if(!u)return;if(!!le.fileName)return b.jsx(V.Tooltip,{title:"Download",children:b.jsx(V.IconButton,{color:"primary",onClick:()=>u==null?void 0:u(le),"data-testid":`citation-table_download-btn-${le.id}`,children:b.jsx(RU,{})})})},ce=C||N||$||k||f||u||T,X=[{fieldName:"id",key:"select",label:"",hideCol:!S,render:(le,xe)=>b.jsx(V.Checkbox,{"data-testid":`citation-table_checkbox-${le}`,onChange:()=>{const _e=g.includes(xe.id);v(_e?g.filter(Me=>Me!==xe.id):[...g,xe.id])},checked:g.includes(le),disabled:C})},...R2(H,x),{fieldName:"id",key:"Action",label:"Action",hideCol:!ce,render:(le,xe)=>b.jsxs(V.Box,{display:"flex",flexDirection:"row-reverse",children:[T==null?void 0:T(xe),ie(xe),re(xe),ye(xe),de(xe),ee(xe)]})}];return b.jsxs(b.Fragment,{children:[b.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"10px",children:[b.jsx(V.Typography,{variant:x?"h6":"h2",children:n}),!S&&I&&b.jsxs(V.Box,{display:"flex",flexDirection:"row",gap:1,children:[te,ue]}),O&&b.jsx(V.IconButton,{onClick:r,children:b.jsx(up,{})})]}),b.jsx(L2,{"data-testid":"citation-table",size:x?"x-small":"medium",isLoading:P,columns:X,data:M,paginationState:oe,onPageChange:le=>fe({...oe,pageNo:le}),onRowsPerPageChange:le=>fe({...oe,pageSize:le,pageNo:0}),errorTableMsg:z?"Failed to load citations.":void 0,retryCallback:me}),S&&b.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",marginTop:"20px",children:[b.jsx(V.Box,{display:"flex",flexDirection:"row",gap:".25rem",children:I&&b.jsxs(b.Fragment,{children:[te,ue]})}),!C&&b.jsxs(V.Box,{display:"flex",flexDirection:"row",gap:".25rem",children:[b.jsx(co,{variant:"outlined",size:"small",onClick:r,children:"Cancel"}),b.jsxs(co,{variant:"contained",size:"small",onClick:()=>p(g),children:["Select",g.length>0&&` (${g.length})`]})]})]}),b.jsx(EQ,{citation:U,anchorEl:A,onClose:G}),b.jsx(OQ,{citation:j,anchorEl:A,onDeleteCitation:l,onClose:G})]})},R2=(t,e=!1)=>[{fieldName:"fileName",key:"CitationOrAttachment",label:"Type",render:(n,r)=>b.jsx(V.Tooltip,{title:n?"Attachment":"URL",children:n?b.jsx(PM,{sx:{color:t.grey[500],marginTop:"4px"},"data-testid":`attachment-icon-${r.id}`}):b.jsx(Vf,{sx:{color:t.grey[500],marginTop:"6px"},"data-testid":`url-icon-${r.id}`})}),ignoreDiff:!0},{fieldName:"title",tableCellSx:{width:e?"100%":"auto"},render:n=>e?ma.truncate(n,{length:40,omission:"..."}):n},{fieldName:"fileName",key:"URL/File Name",label:"URL/File Name",hideCol:e,render:(n,r)=>b.jsx("span",{style:{wordBreak:"break-all"},children:n||r.url}),isEqual:(n,r)=>n.fileName&&r.fileName?n.fileName===r.fileName:n.url===r.url},{fieldName:"source",hideCol:e},{fieldName:"accessedAt",hideCol:e,render:(n,r)=>{if(!r.fileName)return(n==null?void 0:n.slice(0,10))??""}},{fieldName:"classification",hideCol:e}],sv=t=>{const{loading:e=!1,type:n="submit",size:r="medium",...o}=t,s={small:16,medium:20,large:24}[r];return b.jsx(co,{type:n,disabled:e,size:r,startIcon:e?b.jsx(V.CircularProgress,{size:s,color:"inherit"}):null,...o})};var av,z2;function _Q(){if(z2)return av;z2=1;function t(S){this._maxSize=S,this.clear()}t.prototype.clear=function(){this._size=0,this._values=Object.create(null)},t.prototype.get=function(S){return this._values[S]},t.prototype.set=function(S,k){return this._size>=this._maxSize&&this.clear(),S in this._values||this._size++,this._values[S]=k};var e=/[^.^\]^[]+|(?=\[\]|\.\.)/g,n=/^\d+$/,r=/^\d/,o=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,i=/^\s*(['"]?)(.*?)(\1)\s*$/,s=512,a=new t(s),l=new t(s),u=new t(s);av={Cache:t,split:p,normalizePath:f,setter:function(S){var k=f(S);return l.get(S)||l.set(S,function(C,O){for(var I=0,N=k.length,$=C;I<N-1;){var H=k[I];if(H==="__proto__"||H==="constructor"||H==="prototype")return C;$=$[k[I++]]}$[k[I]]=O})},getter:function(S,k){var T=f(S);return u.get(S)||u.set(S,function(O){for(var I=0,N=T.length;I<N;)if(O!=null||!k)O=O[T[I++]];else return;return O})},join:function(S){return S.reduce(function(k,T){return k+(g(T)||n.test(T)?"["+T+"]":(k?".":"")+T)},"")},forEach:function(S,k,T){m(Array.isArray(S)?S:p(S),k,T)}};function f(S){return a.get(S)||a.set(S,p(S).map(function(k){return k.replace(i,"$2")}))}function p(S){return S.match(e)||[""]}function m(S,k,T){var C=S.length,O,I,N,$;for(I=0;I<C;I++)O=S[I],O&&(x(O)&&(O='"'+O+'"'),$=g(O),N=!$&&/^\d+$/.test(O),k.call(T,O,$,N,I,S))}function g(S){return typeof S=="string"&&S&&["'",'"'].indexOf(S.charAt(0))!==-1}function v(S){return S.match(r)&&!S.match(n)}function y(S){return o.test(S)}function x(S){return!g(S)&&(v(S)||y(S))}return av}var Ca=_Q(),lv,V2;function IQ(){if(V2)return lv;V2=1;const t=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,e=f=>f.match(t)||[],n=f=>f[0].toUpperCase()+f.slice(1),r=(f,p)=>e(f).join(p).toLowerCase(),o=f=>e(f).reduce((p,m)=>`${p}${p?m[0].toUpperCase()+m.slice(1).toLowerCase():m.toLowerCase()}`,"");return lv={words:e,upperFirst:n,camelCase:o,pascalCase:f=>n(o(f)),snakeCase:f=>r(f,"_"),kebabCase:f=>r(f,"-"),sentenceCase:f=>n(r(f," ")),titleCase:f=>e(f).map(n).join(" ")},lv}var cv=IQ(),wh={exports:{}},H2;function AQ(){if(H2)return wh.exports;H2=1,wh.exports=function(o){return t(e(o),o)},wh.exports.array=t;function t(o,i){var s=o.length,a=new Array(s),l={},u=s,f=n(i),p=r(o);for(i.forEach(function(g){if(!p.has(g[0])||!p.has(g[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});u--;)l[u]||m(o[u],u,new Set);return a;function m(g,v,y){if(y.has(g)){var x;try{x=", node was:"+JSON.stringify(g)}catch{x=""}throw new Error("Cyclic dependency"+x)}if(!p.has(g))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(g));if(!l[v]){l[v]=!0;var S=f.get(g)||new Set;if(S=Array.from(S),v=S.length){y.add(g);do{var k=S[--v];m(k,p.get(k),y)}while(v);y.delete(g)}a[--s]=g}}}function e(o){for(var i=new Set,s=0,a=o.length;s<a;s++){var l=o[s];i.add(l[0]),i.add(l[1])}return Array.from(i)}function n(o){for(var i=new Map,s=0,a=o.length;s<a;s++){var l=o[s];i.has(l[0])||i.set(l[0],new Set),i.has(l[1])||i.set(l[1],new Set),i.get(l[0]).add(l[1])}return i}function r(o){for(var i=new Map,s=0,a=o.length;s<a;s++)i.set(o[s],s);return i}return wh.exports}var DQ=AQ();const PQ=tr(DQ),NQ=Object.prototype.toString,$Q=Error.prototype.toString,LQ=RegExp.prototype.toString,BQ=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",FQ=/^Symbol\((.*)\)(.*)$/;function RQ(t){return t!=+t?"NaN":t===0&&1/t<0?"-0":""+t}function W2(t,e=!1){if(t==null||t===!0||t===!1)return""+t;const n=typeof t;if(n==="number")return RQ(t);if(n==="string")return e?`"${t}"`:t;if(n==="function")return"[Function "+(t.name||"anonymous")+"]";if(n==="symbol")return BQ.call(t).replace(FQ,"Symbol($1)");const r=NQ.call(t).slice(8,-1);return r==="Date"?isNaN(t.getTime())?""+t:t.toISOString(t):r==="Error"||t instanceof Error?"["+$Q.call(t)+"]":r==="RegExp"?LQ.call(t):null}function ws(t,e){let n=W2(t,e);return n!==null?n:JSON.stringify(t,function(r,o){let i=W2(this[r],e);return i!==null?i:o},2)}function j2(t){return t==null?[]:[].concat(t)}let U2,q2,K2,zQ=/\$\{\s*(\w+)\s*\}/g;U2=Symbol.toStringTag;class Y2{constructor(e,n,r,o){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[U2]="Error",this.name="ValidationError",this.value=n,this.path=r,this.type=o,this.errors=[],this.inner=[],j2(e).forEach(i=>{if(hr.isError(i)){this.errors.push(...i.errors);const s=i.inner.length?i.inner:[i];this.inner.push(...s)}else this.errors.push(i)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}q2=Symbol.hasInstance,K2=Symbol.toStringTag;class hr extends Error{static formatError(e,n){const r=n.label||n.path||"this";return n=Object.assign({},n,{path:r,originalPath:n.path}),typeof e=="string"?e.replace(zQ,(o,i)=>ws(n[i])):typeof e=="function"?e(n):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,n,r,o,i){const s=new Y2(e,n,r,o);if(i)return s;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[K2]="Error",this.name=s.name,this.message=s.message,this.type=s.type,this.value=s.value,this.path=s.path,this.errors=s.errors,this.inner=s.inner,Error.captureStackTrace&&Error.captureStackTrace(this,hr)}static[q2](e){return Y2[Symbol.hasInstance](e)||super[Symbol.hasInstance](e)}}let ei={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:t,type:e,value:n,originalValue:r})=>{const o=r!=null&&r!==n?` (cast from the value \`${ws(r,!0)}\`).`:".";return e!=="mixed"?`${t} must be a \`${e}\` type, but the final value was: \`${ws(n,!0)}\``+o:`${t} must match the configured type. The validated value was: \`${ws(n,!0)}\``+o}},kr={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},VQ={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},uv={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},HQ={isValue:"${path} field must be ${value}"},Sh={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"};Object.assign(Object.create(null),{mixed:ei,string:kr,number:VQ,date:uv,object:Sh,array:{min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},boolean:HQ,tuple:{notType:t=>{const{path:e,value:n,spec:r}=t,o=r.types.length;if(Array.isArray(n)){if(n.length<o)return`${e} tuple value has too few items, expected a length of ${o} but got ${n.length} for value: \`${ws(n,!0)}\``;if(n.length>o)return`${e} tuple value has too many items, expected a length of ${o} but got ${n.length} for value: \`${ws(n,!0)}\``}return hr.formatError(ei.notType,t)}}});const dv=t=>t&&t.__isYupSchema__;class Ch{static fromOptions(e,n){if(!n.then&&!n.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:r,then:o,otherwise:i}=n,s=typeof r=="function"?r:(...a)=>a.every(l=>l===r);return new Ch(e,(a,l)=>{var u;let f=s(...a)?o:i;return(u=f==null?void 0:f(l))!=null?u:l})}constructor(e,n){this.fn=void 0,this.refs=e,this.refs=e,this.fn=n}resolve(e,n){let r=this.refs.map(i=>i.getValue(n==null?void 0:n.value,n==null?void 0:n.parent,n==null?void 0:n.context)),o=this.fn(r,e,n);if(o===void 0||o===e)return e;if(!dv(o))throw new TypeError("conditions must return a schema object");return o.resolve(n)}}const Th={context:"$",value:"."};class Ta{constructor(e,n={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===Th.context,this.isValue=this.key[0]===Th.value,this.isSibling=!this.isContext&&!this.isValue;let r=this.isContext?Th.context:this.isValue?Th.value:"";this.path=this.key.slice(r.length),this.getter=this.path&&Ca.getter(this.path,!0),this.map=n.map}getValue(e,n,r){let o=this.isContext?r:this.isValue?e:n;return this.getter&&(o=this.getter(o||{})),this.map&&(o=this.map(o)),o}cast(e,n){return this.getValue(e,n==null?void 0:n.parent,n==null?void 0:n.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}Ta.prototype.__isYupRef=!0;const ka=t=>t==null;function Ll(t){function e({value:n,path:r="",options:o,originalValue:i,schema:s},a,l){const{name:u,test:f,params:p,message:m,skipAbsent:g}=t;let{parent:v,context:y,abortEarly:x=s.spec.abortEarly,disableStackTrace:S=s.spec.disableStackTrace}=o;const k={value:n,parent:v,context:y};function T(F={}){const z=G2(Object.assign({value:n,originalValue:i,label:s.spec.label,path:F.path||r,spec:s.spec,disableStackTrace:F.disableStackTrace||S},p,F.params),k),B=new hr(hr.formatError(F.message||m,z),n,z.path,F.type||u,z.disableStackTrace);return B.params=z,B}const C=x?a:l;let O={path:r,parent:v,type:u,from:o.from,createError:T,resolve(F){return J2(F,k)},options:o,originalValue:i,schema:s};const I=F=>{hr.isError(F)?C(F):F?l(null):C(T())},N=F=>{hr.isError(F)?C(F):a(F)};if(g&&ka(n))return I(!0);let H;try{var M;if(H=f.call(O,n,O),typeof((M=H)==null?void 0:M.then)=="function"){if(o.sync)throw new Error(`Validation test of type: "${O.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(H).then(I,N)}}catch(F){N(F);return}I(H)}return e.OPTIONS=t,e}function G2(t,e){if(!t)return t;for(const n of Object.keys(t))t[n]=J2(t[n],e);return t}function J2(t,e){return Ta.isRef(t)?t.getValue(e.value,e.parent,e.context):t}function WQ(t,e,n,r=n){let o,i,s;return e?(Ca.forEach(e,(a,l,u)=>{let f=l?a.slice(1,a.length-1):a;t=t.resolve({context:r,parent:o,value:n});let p=t.type==="tuple",m=u?parseInt(f,10):0;if(t.innerType||p){if(p&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${s}" must contain an index to the tuple element, e.g. "${s}[0]"`);if(n&&m>=n.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${e}. because there is no value at that index. `);o=n,n=n&&n[m],t=p?t.spec.types[m]:t.innerType}if(!u){if(!t.fields||!t.fields[f])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${s} which is a type: "${t.type}")`);o=n,n=n&&n[f],t=t.fields[f]}i=f,s=l?"["+a+"]":"."+a}),{schema:t,parent:o,parentPath:i}):{parent:o,parentPath:e,schema:t}}class kh extends Set{describe(){const e=[];for(const n of this.values())e.push(Ta.isRef(n)?n.describe():n);return e}resolveAll(e){let n=[];for(const r of this.values())n.push(e(r));return n}clone(){return new kh(this.values())}merge(e,n){const r=this.clone();return e.forEach(o=>r.add(o)),n.forEach(o=>r.delete(o)),r}}function Bl(t,e=new Map){if(dv(t)||!t||typeof t!="object")return t;if(e.has(t))return e.get(t);let n;if(t instanceof Date)n=new Date(t.getTime()),e.set(t,n);else if(t instanceof RegExp)n=new RegExp(t),e.set(t,n);else if(Array.isArray(t)){n=new Array(t.length),e.set(t,n);for(let r=0;r<t.length;r++)n[r]=Bl(t[r],e)}else if(t instanceof Map){n=new Map,e.set(t,n);for(const[r,o]of t.entries())n.set(r,Bl(o,e))}else if(t instanceof Set){n=new Set,e.set(t,n);for(const r of t)n.add(Bl(r,e))}else if(t instanceof Object){n={},e.set(t,n);for(const[r,o]of Object.entries(t))n[r]=Bl(o,e)}else throw Error(`Unable to clone ${t}`);return n}function jQ(t){if(!(t!=null&&t.length))return;const e=[];let n="",r=!1,o=!1;for(let i=0;i<t.length;i++){const s=t[i];if(s==="["&&!o){n&&(e.push(...n.split(".").filter(Boolean)),n=""),r=!0;continue}if(s==="]"&&!o){n&&(/^\d+$/.test(n)?e.push(n):e.push(n.replace(/^"|"$/g,"")),n=""),r=!1;continue}if(s==='"'){o=!o;continue}if(s==="."&&!r&&!o){n&&(e.push(n),n="");continue}n+=s}return n&&e.push(...n.split(".").filter(Boolean)),e}function UQ(t,e){const n=e?`${e}.${t.path}`:t.path;return t.errors.map(r=>({message:r,path:jQ(n)}))}function X2(t,e){var n;if(!((n=t.inner)!=null&&n.length)&&t.errors.length)return UQ(t,e);const r=e?`${e}.${t.path}`:t.path;return t.inner.flatMap(o=>X2(o,r))}class ti{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new kh,this._blacklist=new kh,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(ei.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},e==null?void 0:e.spec),this.withMutation(n=>{n.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const n=Object.create(Object.getPrototypeOf(this));return n.type=this.type,n._typeCheck=this._typeCheck,n._whitelist=this._whitelist.clone(),n._blacklist=this._blacklist.clone(),n.internalTests=Object.assign({},this.internalTests),n.exclusiveTests=Object.assign({},this.exclusiveTests),n.deps=[...this.deps],n.conditions=[...this.conditions],n.tests=[...this.tests],n.transforms=[...this.transforms],n.spec=Bl(Object.assign({},this.spec,e)),n}label(e){let n=this.clone();return n.spec.label=e,n}meta(...e){if(e.length===0)return this.spec.meta;let n=this.clone();return n.spec.meta=Object.assign(n.spec.meta||{},e[0]),n}withMutation(e){let n=this._mutate;this._mutate=!0;let r=e(this);return this._mutate=n,r}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let n=this,r=e.clone();const o=Object.assign({},n.spec,r.spec);return r.spec=o,r.internalTests=Object.assign({},n.internalTests,r.internalTests),r._whitelist=n._whitelist.merge(e._whitelist,e._blacklist),r._blacklist=n._blacklist.merge(e._blacklist,e._whitelist),r.tests=n.tests,r.exclusiveTests=n.exclusiveTests,r.withMutation(i=>{e.tests.forEach(s=>{i.test(s.OPTIONS)})}),r.transforms=[...n.transforms,...r.transforms],r}isType(e){return e==null?!!(this.spec.nullable&&e===null||this.spec.optional&&e===void 0):this._typeCheck(e)}resolve(e){let n=this;if(n.conditions.length){let r=n.conditions;n=n.clone(),n.conditions=[],n=r.reduce((o,i)=>i.resolve(o,e),n),n=n.resolve(e)}return n}resolveOptions(e){var n,r,o,i;return Object.assign({},e,{from:e.from||[],strict:(n=e.strict)!=null?n:this.spec.strict,abortEarly:(r=e.abortEarly)!=null?r:this.spec.abortEarly,recursive:(o=e.recursive)!=null?o:this.spec.recursive,disableStackTrace:(i=e.disableStackTrace)!=null?i:this.spec.disableStackTrace})}cast(e,n={}){let r=this.resolve(Object.assign({},n,{value:e})),o=n.assert==="ignore-optionality",i=r._cast(e,n);if(n.assert!==!1&&!r.isType(i)){if(o&&ka(i))return i;let s=ws(e),a=ws(i);throw new TypeError(`The value of ${n.path||"field"} could not be cast to a value that satisfies the schema type: "${r.type}".
|
|
406
406
|
|
|
407
407
|
attempted value: ${s}
|
|
408
|
-
`+(a!==s?`result of cast: ${a}`:""))}return i}_cast(e,n){let r=e===void 0?e:this.transforms.reduce((o,i)=>i.call(this,o,e,this,n),e);return r===void 0&&(r=this.getDefault(n)),r}_validate(e,n={},r,o){let{path:i,originalValue:s=e,strict:a=this.spec.strict}=n,l=e;a||(l=this._cast(l,Object.assign({assert:!1},n)));let u=[];for(let f of Object.values(this.internalTests))f&&u.push(f);this.runTests({path:i,value:l,originalValue:s,options:n,tests:u},r,f=>{if(f.length)return o(f,l);this.runTests({path:i,value:l,originalValue:s,options:n,tests:this.tests},r,o)})}runTests(e,n,r){let o=!1,{tests:i,value:s,originalValue:a,path:l,options:u}=e,f=y=>{o||(o=!0,n(y,s))},p=y=>{o||(o=!0,r(y,s))},m=i.length,g=[];if(!m)return p([]);let v={value:s,originalValue:a,path:l,options:u,schema:this};for(let y=0;y<i.length;y++){const x=i[y];x(v,f,function(k){k&&(Array.isArray(k)?g.push(...k):g.push(k)),--m<=0&&p(g)})}}asNestedTest({key:e,index:n,parent:r,parentPath:o,originalParent:i,options:s}){const a=e??n;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const l=typeof a=="number";let u=r[a];const f=Object.assign({},s,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[l?"index":"key"]:a,path:l||a.includes(".")?`${o||""}[${l?a:`"${a}"`}]`:(o?`${o}.`:"")+e});return(p,m,g)=>this.resolve(f)._validate(u,f,m,g)}validate(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return new Promise((s,a)=>o._validate(e,n,(l,u)=>{hr.isError(l)&&(l.value=u),a(l)},(l,u)=>{l.length?a(new hr(l,u,void 0,void 0,i)):s(u)}))}validateSync(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i,s=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return o._validate(e,Object.assign({},n,{sync:!0}),(a,l)=>{throw hr.isError(a)&&(a.value=l),a},(a,l)=>{if(a.length)throw new hr(a,e,void 0,void 0,s);i=l}),i}isValid(e,n){return this.validate(e,n).then(()=>!0,r=>{if(hr.isError(r))return!1;throw r})}isValidSync(e,n){try{return this.validateSync(e,n),!0}catch(r){if(hr.isError(r))return!1;throw r}}_getDefault(e){let n=this.spec.default;return n==null?n:typeof n=="function"?n.call(this,e):Bl(n)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,n){const r=this.clone({nullable:e});return r.internalTests.nullable=Ll({message:n,name:"nullable",test(o){return o===null?this.schema.spec.nullable:!0}}),r}optionality(e,n){const r=this.clone({optional:e});return r.internalTests.optionality=Ll({message:n,name:"optionality",test(o){return o===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=ei.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=ei.notNull){return this.nullability(!1,e)}required(e=ei.required){return this.clone().withMutation(n=>n.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let n=this.clone();return n.transforms.push(e),n}test(...e){let n;if(e.length===1?typeof e[0]=="function"?n={test:e[0]}:n=e[0]:e.length===2?n={name:e[0],test:e[1]}:n={name:e[0],message:e[1],test:e[2]},n.message===void 0&&(n.message=ei.default),typeof n.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),o=Ll(n),i=n.exclusive||n.name&&r.exclusiveTests[n.name]===!0;if(n.exclusive&&!n.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return n.name&&(r.exclusiveTests[n.name]=!!n.exclusive),r.tests=r.tests.filter(s=>!(s.OPTIONS.name===n.name&&(i||s.OPTIONS.test===o.OPTIONS.test))),r.tests.push(o),r}when(e,n){!Array.isArray(e)&&typeof e!="string"&&(n=e,e=".");let r=this.clone(),o=j2(e).map(i=>new Ta(i));return o.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof n=="function"?new Ch(o,n):Ch.fromOptions(o,n)),r}typeError(e){let n=this.clone();return n.internalTests.typeError=Ll({message:e,name:"typeError",skipAbsent:!0,test(r){return this.schema._typeCheck(r)?!0:this.createError({params:{type:this.schema.type}})}}),n}oneOf(e,n=ei.oneOf){let r=this.clone();return e.forEach(o=>{r._whitelist.add(o),r._blacklist.delete(o)}),r.internalTests.whiteList=Ll({message:n,name:"oneOf",skipAbsent:!0,test(o){let i=this.schema._whitelist,s=i.resolveAll(this.resolve);return s.includes(o)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:s}})}}),r}notOneOf(e,n=ei.notOneOf){let r=this.clone();return e.forEach(o=>{r._blacklist.add(o),r._whitelist.delete(o)}),r.internalTests.blacklist=Ll({message:n,name:"notOneOf",test(o){let i=this.schema._blacklist,s=i.resolveAll(this.resolve);return s.includes(o)?this.createError({params:{values:Array.from(i).join(", "),resolved:s}}):!0}}),r}strip(e=!0){let n=this.clone();return n.spec.strip=e,n}describe(e){const n=(e?this.resolve(e):this).clone(),{label:r,meta:o,optional:i,nullable:s}=n.spec;return{meta:o,label:r,optional:i,nullable:s,default:n.getDefault(e),type:n.type,oneOf:n._whitelist.describe(),notOneOf:n._blacklist.describe(),tests:n.tests.filter((l,u,f)=>f.findIndex(p=>p.OPTIONS.name===l.OPTIONS.name)===u).map(l=>{const u=l.OPTIONS.params&&e?G2(Object.assign({},l.OPTIONS.params),e):l.OPTIONS.params;return{name:l.OPTIONS.name,params:u}})}}get"~standard"(){const e=this;return{version:1,vendor:"yup",async validate(r){try{return{value:await e.validate(r,{abortEarly:!1})}}catch(o){if(o instanceof hr)return{issues:X2(o)};throw o}}}}}ti.prototype.__isYupSchema__=!0;for(const t of["validate","validateSync"])ti.prototype[`${t}At`]=function(e,n,r={}){const{parent:o,parentPath:i,schema:s}=WQ(this,e,n,r.context);return s[t](o&&o[i],Object.assign({},r,{parent:o,path:e}))};for(const t of["equals","is"])ti.prototype[t]=ti.prototype.oneOf;for(const t of["not","nope"])ti.prototype[t]=ti.prototype.notOneOf;const qQ=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function KQ(t){const e=fv(t);if(!e)return Date.parse?Date.parse(t):Number.NaN;if(e.z===void 0&&e.plusMinus===void 0)return new Date(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond).valueOf();let n=0;return e.z!=="Z"&&e.plusMinus!==void 0&&(n=e.hourOffset*60+e.minuteOffset,e.plusMinus==="+"&&(n=0-n)),Date.UTC(e.year,e.month,e.day,e.hour,e.minute+n,e.second,e.millisecond)}function fv(t){var e,n;const r=qQ.exec(t);return r?{year:Ii(r[1]),month:Ii(r[2],1)-1,day:Ii(r[3],1),hour:Ii(r[4]),minute:Ii(r[5]),second:Ii(r[6]),millisecond:r[7]?Ii(r[7].substring(0,3)):0,precision:(e=(n=r[7])==null?void 0:n.length)!=null?e:void 0,z:r[8]||void 0,plusMinus:r[9]||void 0,hourOffset:Ii(r[10]),minuteOffset:Ii(r[11])}:null}function Ii(t,e=0){return Number(t)||e}let YQ=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,GQ=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,JQ=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,XQ="^\\d{4}-\\d{2}-\\d{2}",ZQ="\\d{2}:\\d{2}:\\d{2}",QQ="(([+-]\\d{2}(:?\\d{2})?)|Z)",eee=new RegExp(`${XQ}T${ZQ}(\\.\\d+)?${QQ}$`),tee=t=>ka(t)||t===t.trim(),nee={}.toString();function Ea(){return new Z2}class Z2 extends ti{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,n)=>{if(!this.spec.coerce||this.isType(e)||Array.isArray(e))return e;const r=e!=null&&e.toString?e.toString():e;return r===nee?e:r})})}required(e){return super.required(e).withMutation(n=>n.test({message:e||ei.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(n=>n.OPTIONS.name!=="required"),e))}length(e,n=kr.length){return this.test({message:n,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,n=kr.min){return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,n=kr.max){return this.test({name:"max",exclusive:!0,message:n,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,n){let r=!1,o,i;return n&&(typeof n=="object"?{excludeEmptyString:r=!1,message:o,name:i}=n:o=n),this.test({name:i||"matches",message:o||kr.matches,params:{regex:e},skipAbsent:!0,test:s=>s===""&&r||s.search(e)!==-1})}email(e=kr.email){return this.matches(YQ,{name:"email",message:e,excludeEmptyString:!0})}url(e=kr.url){return this.matches(GQ,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=kr.uuid){return this.matches(JQ,{name:"uuid",message:e,excludeEmptyString:!1})}datetime(e){let n="",r,o;return e&&(typeof e=="object"?{message:n="",allowOffset:r=!1,precision:o=void 0}=e:n=e),this.matches(eee,{name:"datetime",message:n||kr.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:n||kr.datetime_offset,params:{allowOffset:r},skipAbsent:!0,test:i=>{if(!i||r)return!0;const s=fv(i);return s?!!s.z:!1}}).test({name:"datetime_precision",message:n||kr.datetime_precision,params:{precision:o},skipAbsent:!0,test:i=>{if(!i||o==null)return!0;const s=fv(i);return s?s.precision===o:!1}})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=kr.trim){return this.transform(n=>n!=null?n.trim():n).test({message:e,name:"trim",test:tee})}lowercase(e=kr.lowercase){return this.transform(n=>ka(n)?n:n.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>ka(n)||n===n.toLowerCase()})}uppercase(e=kr.uppercase){return this.transform(n=>ka(n)?n:n.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>ka(n)||n===n.toUpperCase()})}}Ea.prototype=Z2.prototype;let Q2=new Date(""),ree=t=>Object.prototype.toString.call(t)==="[object Date]";function pv(){return new Lu}class Lu extends ti{constructor(){super({type:"date",check(e){return ree(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,n)=>!this.spec.coerce||this.isType(e)||e===null?e:(e=KQ(e),isNaN(e)?Lu.INVALID_DATE:new Date(e)))})}prepareParam(e,n){let r;if(Ta.isRef(e))r=e;else{let o=this.cast(e);if(!this._typeCheck(o))throw new TypeError(`\`${n}\` must be a Date or a value that can be \`cast()\` to a Date`);r=o}return r}min(e,n=uv.min){let r=this.prepareParam(e,"min");return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(o){return o>=this.resolve(r)}})}max(e,n=uv.max){let r=this.prepareParam(e,"max");return this.test({message:n,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(o){return o<=this.resolve(r)}})}}Lu.INVALID_DATE=Q2,pv.prototype=Lu.prototype,pv.INVALID_DATE=Q2;function oee(t,e=[]){let n=[],r=new Set,o=new Set(e.map(([s,a])=>`${s}-${a}`));function i(s,a){let l=Ca.split(s)[0];r.add(l),o.has(`${a}-${l}`)||n.push([a,l])}for(const s of Object.keys(t)){let a=t[s];r.add(s),Ta.isRef(a)&&a.isSibling?i(a.path,s):dv(a)&&"deps"in a&&a.deps.forEach(l=>i(l,s))}return PQ.array(Array.from(r),n).reverse()}function eI(t,e){let n=1/0;return t.some((r,o)=>{var i;if((i=e.path)!=null&&i.includes(r))return n=o,!0}),n}function tI(t){return(e,n)=>eI(t,e)-eI(t,n)}const iee=(t,e,n)=>{if(typeof t!="string")return t;let r=t;try{r=JSON.parse(t)}catch{}return n.isType(r)?r:t};function Eh(t){if("fields"in t){const e={};for(const[n,r]of Object.entries(t.fields))e[n]=Eh(r);return t.setFields(e)}if(t.type==="array"){const e=t.optional();return e.innerType&&(e.innerType=Eh(e.innerType)),e}return t.type==="tuple"?t.optional().clone({types:t.spec.types.map(Eh)}):"optional"in t?t.optional():t}const see=(t,e)=>{const n=[...Ca.normalizePath(e)];if(n.length===1)return n[0]in t;let r=n.pop(),o=Ca.getter(Ca.join(n),!0)(t);return!!(o&&r in o)};let nI=t=>Object.prototype.toString.call(t)==="[object Object]";function rI(t,e){let n=Object.keys(t.fields);return Object.keys(e).filter(r=>n.indexOf(r)===-1)}const aee=tI([]);function hv(t){return new oI(t)}class oI extends ti{constructor(e){super({type:"object",check(n){return nI(n)||typeof n=="function"}}),this.fields=Object.create(null),this._sortErrors=aee,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,n={}){var r;let o=super._cast(e,n);if(o===void 0)return this.getDefault(n);if(!this._typeCheck(o))return o;let i=this.fields,s=(r=n.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(o).filter(p=>!this._nodes.includes(p))),l={},u=Object.assign({},n,{parent:l,__validating:n.__validating||!1}),f=!1;for(const p of a){let m=i[p],g=p in o,v=o[p];if(m){let y;u.path=(n.path?`${n.path}.`:"")+p,m=m.resolve({value:v,context:n.context,parent:l});let x=m instanceof ti?m.spec:void 0,S=x==null?void 0:x.strict;if(x!=null&&x.strip){f=f||p in o;continue}y=!n.__validating||!S?m.cast(v,u):v,y!==void 0&&(l[p]=y)}else g&&!s&&(l[p]=v);(g!==p in l||l[p]!==v)&&(f=!0)}return f?l:o}_validate(e,n={},r,o){let{from:i=[],originalValue:s=e,recursive:a=this.spec.recursive}=n;n.from=[{schema:this,value:s},...i],n.__validating=!0,n.originalValue=s,super._validate(e,n,r,(l,u)=>{if(!a||!nI(u)){o(l,u);return}s=s||u;let f=[];for(let p of this._nodes){let m=this.fields[p];!m||Ta.isRef(m)||f.push(m.asNestedTest({options:n,key:p,parent:u,parentPath:n.path,originalParent:s}))}this.runTests({tests:f,value:u,originalValue:s,options:n},r,p=>{o(p.sort(this._sortErrors).concat(l),u)})})}clone(e){const n=super.clone(e);return n.fields=Object.assign({},this.fields),n._nodes=this._nodes,n._excludedEdges=this._excludedEdges,n._sortErrors=this._sortErrors,n}concat(e){let n=super.concat(e),r=n.fields;for(let[o,i]of Object.entries(this.fields)){const s=r[o];r[o]=s===void 0?i:s}return n.withMutation(o=>o.setFields(r,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let n={};return this._nodes.forEach(r=>{var o;const i=this.fields[r];let s=e;(o=s)!=null&&o.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[r]})),n[r]=i&&"getDefault"in i?i.getDefault(s):void 0}),n}setFields(e,n){let r=this.clone();return r.fields=e,r._nodes=oee(e,n),r._sortErrors=tI(Object.keys(e)),n&&(r._excludedEdges=n),r}shape(e,n=[]){return this.clone().withMutation(r=>{let o=r._excludedEdges;return n.length&&(Array.isArray(n[0])||(n=[n]),o=[...r._excludedEdges,...n]),r.setFields(Object.assign(r.fields,e),o)})}partial(){const e={};for(const[n,r]of Object.entries(this.fields))e[n]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return Eh(this)}pick(e){const n={};for(const r of e)this.fields[r]&&(n[r]=this.fields[r]);return this.setFields(n,this._excludedEdges.filter(([r,o])=>e.includes(r)&&e.includes(o)))}omit(e){const n=[];for(const r of Object.keys(this.fields))e.includes(r)||n.push(r);return this.pick(n)}from(e,n,r){let o=Ca.getter(e,!0);return this.transform(i=>{if(!i)return i;let s=i;return see(i,e)&&(s=Object.assign({},i),r||delete s[e],s[n]=o(i)),s})}json(){return this.transform(iee)}exact(e){return this.test({name:"exact",exclusive:!0,message:e||Sh.exact,test(n){if(n==null)return!0;const r=rI(this.schema,n);return r.length===0||this.createError({params:{properties:r.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(e=!0,n=Sh.noUnknown){typeof e!="boolean"&&(n=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:n,test(o){if(o==null)return!0;const i=rI(this.schema,o);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,n=Sh.noUnknown){return this.noUnknown(!e,n)}transformKeys(e){return this.transform(n=>{if(!n)return n;const r={};for(const o of Object.keys(n))r[e(o)]=n[o];return r})}camelCase(){return this.transformKeys(cv.camelCase)}snakeCase(){return this.transformKeys(cv.snakeCase)}constantCase(){return this.transformKeys(e=>cv.snakeCase(e).toUpperCase())}describe(e){const n=(e?this.resolve(e):this).clone(),r=super.describe(e);r.fields={};for(const[i,s]of Object.entries(n.fields)){var o;let a=e;(o=a)!=null&&o.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[i]})),r.fields[i]=s.describe(a)}return r}}hv.prototype=oI.prototype;const lee=t=>{const{title:e,onSave:n,onCancel:r,onClose:o,modifyCitation:i,readOnly:s=!1,showCloseBtn:a=!1}=t,l=Z.useRef(null),[u,f]=Z.useState(!1),[p,m]=Z.useState(!1),[g,v]=Z.useState({type:"Url",source:"",title:"",accessedAt:null,url:"",classification:""});return Z.useEffect(()=>{i&&v({...i,type:"Url"})},[]),b.jsxs(b.Fragment,{children:[b.jsxs(V.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[b.jsx(V.Typography,{variant:"h6",margin:"10px 0",children:e}),a&&b.jsx(V.IconButton,{onClick:o,children:b.jsx(up,{})})]}),b.jsx(jt.Formik,{innerRef:l,enableReinitialize:!0,initialValues:g,onSubmit:async y=>{f(!0),n(y).catch(x=>{throw f(!1),x}).finally(()=>f(!1))},validationSchema:hv({source:Ea().required("Source is required"),title:Ea().required("Title is required"),accessedAt:pv().required("Accessed At is required"),url:Ea().required("URL is required"),classification:Ea().required("Classification is required")}),validateOnBlur:p,validateOnChange:p,children:({handleSubmit:y})=>b.jsxs(jt.Form,{autoComplete:"off",children:[b.jsxs(V.Box,{display:"flex",flexDirection:"column",gap:s?1:0,children:[b.jsx(gs,{name:"source",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(gs,{name:"title",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(Hp,{name:"accessedAt",disabled:u,required:!0,margin:"none",isDatePicker:!0,readOnly:s}),b.jsx(gs,{name:"url",label:"URL",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(AM,{row:!0,name:"classification",required:!0,radios:[{label:"Public Source",value:"Public Source",helperText:"URL is accessible to anyone from any location without special permissions. You can safely access this URL on any computer, including public or shared devices."},{label:"Proprietary Source",value:"Proprietary Source",helperText:"For private, sensitive, or access-controlled content. Use a VPN, or take extra precautions, when accessing to protect your privacy."}],margin:"none",readOnly:s})]}),b.jsx(V.DialogActions,{sx:{px:0},children:s?b.jsx(V.Button,{onClick:r,size:"small",variant:"contained",children:"Back to Table"}):b.jsxs(b.Fragment,{children:[b.jsx(V.Button,{onClick:r,variant:"outlined",size:"small",children:"Cancel"}),b.jsx(sv,{size:"small",loading:u,type:"button",onClick:()=>{m(!0),y()},children:i?"Update Citation":"Add New Citation"})]})})]})})]})},iI=t=>{const{gap:e=1,alignItems:n="center",...r}=t;return b.jsx(V.Box,{display:"flex",flexDirection:"row",gap:e,alignItems:n,...r})},cee=t=>{const{title:e,onSave:n,onCancel:r,onClose:o,disableFileUpload:i=!1,modifyCitation:s,readOnly:a=!1,showCloseBtn:l=!1}=t,u=Z.useRef(null),[f,p]=Z.useState(!1),[m,g]=Z.useState(!1),[v,y]=Z.useState({type:"Attachment",title:"",file:void 0,fileName:""});return Z.useEffect(()=>{s&&y({...s,type:"Attachment",file:void 0})},[]),b.jsxs(b.Fragment,{children:[b.jsxs(V.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[b.jsx(V.Typography,{variant:"h6",margin:"10px 0",children:e}),l&&b.jsx(V.IconButton,{onClick:o,children:b.jsx(up,{})})]}),b.jsx(jt.Formik,{innerRef:u,enableReinitialize:!0,initialValues:v,validationSchema:hv().shape({title:Ea().required("Title is required"),fileName:Ea().required("A file is required")}),validateOnBlur:m,validateOnChange:m,onSubmit:async x=>{p(!0),n(x).catch(S=>{throw p(!1),S}).finally(()=>p(!1))},children:({values:x,setFieldValue:S,handleSubmit:k})=>{var T;return Z.useEffect(()=>{var C,O;(C=x.file)!=null&&C.name&&S("fileName",(O=x.file)==null?void 0:O.name)},[(T=x.file)==null?void 0:T.name]),b.jsxs(jt.Form,{autoComplete:"off",children:[b.jsx(gs,{name:"title",disabled:f,required:!0,margin:"none",readOnly:a}),b.jsxs(V.Box,{marginTop:i||a?0:1,children:[b.jsxs(iI,{alignItems:"flex-start",children:[!i&&!a&&b.jsx(fM,{name:"file",errorMode:"hidden"}),b.jsx(gs,{readOnly:!0,name:"fileName",label:a||i?"File Name":""})]}),b.jsx(br,{name:"fileName"})]}),b.jsx(V.DialogActions,{sx:{px:0},children:a?b.jsx(V.Button,{onClick:r,size:"small",variant:"contained",children:"Back to Table"}):b.jsxs(b.Fragment,{children:[b.jsx(V.Button,{onClick:r,variant:"outlined",size:"small",children:"Cancel"}),b.jsx(sv,{size:"small",loading:f,type:"button",onClick:()=>{g(!0),k()},children:s?"Update Attachment":"Upload Attachment"})]})})]})}})]})},Bu=t=>{const{open:e=!1,onClose:n,title:r,children:o,actions:i,closeBtnLabel:s,closeButtonPosition:a,closeButtonProps:l={},disableDismiss:u=!1,...f}=t;if(!e)return null;const p=a==="bottom"||a==="top-and-bottom",m=a==="top"||a==="top-and-bottom",g=()=>{if(s&&p)return b.jsx(V.Button,{className:"MBv2_Modal_Close",onClick:t.onClose,...l,children:s})},v=()=>{if(i)return b.jsx(V.DialogActions,{className:"MBv2_Modal_Actions",children:b.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",gap:"0.25rem",children:[b.jsx(V.Box,{children:g()}),b.jsxs(V.Box,{display:"flex",gap:".25rem",children:[...i]})]})});if(s&&p)return b.jsx(V.DialogActions,{className:"MBv2_Modal_Actions",children:b.jsx(V.Box,{children:g()})})};return b.jsxs(V.Dialog,{className:"MBv2_Modal",open:e,onClose:()=>{u||n==null||n()},...f,children:[typeof r=="string"?b.jsx(V.DialogTitle,{className:"MBv2_Modal_Title",children:b.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[r,m&&b.jsx(V.IconButton,{"data-testid":"modal-header-close-btn",onClick:n,children:b.jsx(up,{})})]})}):r,o&&(typeof o=="string"?b.jsx(V.DialogContent,{className:"MBv2_Modal_Content",children:b.jsx(V.DialogContentText,{className:"MBv2_Modal_Content_Text",children:o})}):o),v()]})};function uee(t){return Ue("MuiAlert",t)}const sI=He("MuiAlert",["root","action","icon","message","filled","colorSuccess","colorInfo","colorWarning","colorError","filledSuccess","filledInfo","filledWarning","filledError","outlined","outlinedSuccess","outlinedInfo","outlinedWarning","outlinedError","standard","standardSuccess","standardInfo","standardWarning","standardError"]),dee=Pe(b.jsx("path",{d:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"}),"SuccessOutlined"),fee=Pe(b.jsx("path",{d:"M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),pee=Pe(b.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutline"),hee=Pe(b.jsx("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"}),"InfoOutlined"),mee=Pe(b.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close"),gee=t=>{const{variant:e,color:n,severity:r,classes:o}=t,i={root:["root",`color${Ie(n||r)}`,`${e}${Ie(n||r)}`,`${e}`],icon:["icon"],message:["message"],action:["action"]};return je(i,uee,o)},yee=ne(us,{name:"MuiAlert",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.variant],e[`${n.variant}${Ie(n.color||n.severity)}`]]}})(gt(({theme:t})=>{const e=t.palette.mode==="light"?Rs:Va,n=t.palette.mode==="light"?Va:Rs;return{...t.typography.body2,backgroundColor:"transparent",display:"flex",padding:"6px 16px",variants:[...Object.entries(t.palette).filter(Hn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"standard"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),backgroundColor:t.vars?t.vars.palette.Alert[`${r}StandardBg`]:n(t.palette[r].light,.9),[`& .${sI.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Hn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"outlined"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),border:`1px solid ${(t.vars||t).palette[r].light}`,[`& .${sI.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Hn(["dark"])).map(([r])=>({props:{colorSeverity:r,variant:"filled"},style:{fontWeight:t.typography.fontWeightMedium,...t.vars?{color:t.vars.palette.Alert[`${r}FilledColor`],backgroundColor:t.vars.palette.Alert[`${r}FilledBg`]}:{backgroundColor:t.palette.mode==="dark"?t.palette[r].dark:t.palette[r].main,color:t.palette.getContrastText(t.palette[r].main)}}}))]}})),bee=ne("div",{name:"MuiAlert",slot:"Icon",overridesResolver:(t,e)=>e.icon})({marginRight:12,padding:"7px 0",display:"flex",fontSize:22,opacity:.9}),vee=ne("div",{name:"MuiAlert",slot:"Message",overridesResolver:(t,e)=>e.message})({padding:"8px 0",minWidth:0,overflow:"auto"}),xee=ne("div",{name:"MuiAlert",slot:"Action",overridesResolver:(t,e)=>e.action})({display:"flex",alignItems:"flex-start",padding:"4px 0 0 16px",marginLeft:"auto",marginRight:-8}),aI={success:b.jsx(dee,{fontSize:"inherit"}),warning:b.jsx(fee,{fontSize:"inherit"}),error:b.jsx(pee,{fontSize:"inherit"}),info:b.jsx(hee,{fontSize:"inherit"})},lI=D.forwardRef(function(e,n){const r=ht({props:e,name:"MuiAlert"}),{action:o,children:i,className:s,closeText:a="Close",color:l,components:u={},componentsProps:f={},icon:p,iconMapping:m=aI,onClose:g,role:v="alert",severity:y="success",slotProps:x={},slots:S={},variant:k="standard",...T}=r,C={...r,color:l,severity:y,variant:k,colorSeverity:l||y},O=gee(C),I={slots:{closeButton:u.CloseButton,closeIcon:u.CloseIcon,...S},slotProps:{...f,...x}},[N,$]=Ot("root",{ref:n,shouldForwardComponentProp:!0,className:ge(O.root,s),elementType:yee,externalForwardedProps:{...I,...T},ownerState:C,additionalProps:{role:v,elevation:0}}),[H,M]=Ot("icon",{className:O.icon,elementType:bee,externalForwardedProps:I,ownerState:C}),[F,z]=Ot("message",{className:O.message,elementType:vee,externalForwardedProps:I,ownerState:C}),[B,P]=Ot("action",{className:O.action,elementType:xee,externalForwardedProps:I,ownerState:C}),[_,A]=Ot("closeButton",{elementType:_l,externalForwardedProps:I,ownerState:C}),[R,j]=Ot("closeIcon",{elementType:mee,externalForwardedProps:I,ownerState:C});return b.jsxs(N,{...$,children:[p!==!1?b.jsx(H,{...M,children:p||m[y]||aI[y]}):null,b.jsx(F,{...z,children:i}),o!=null?b.jsx(B,{...P,children:o}):null,o==null&&g?b.jsx(B,{...P,children:b.jsx(_,{size:"small","aria-label":a,title:a,color:"inherit",onClick:g,...A,children:b.jsx(R,{fontSize:"small",...j})})}):null]})});process.env.NODE_ENV!=="production"&&(lI.propTypes={action:c.node,children:c.node,classes:c.object,className:c.string,closeText:c.string,color:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),components:c.shape({CloseButton:c.elementType,CloseIcon:c.elementType}),componentsProps:c.shape({closeButton:c.object,closeIcon:c.object}),icon:c.node,iconMapping:c.shape({error:c.node,info:c.node,success:c.node,warning:c.node}),onClose:c.func,role:c.string,severity:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),slotProps:c.shape({action:c.oneOfType([c.func,c.object]),closeButton:c.oneOfType([c.func,c.object]),closeIcon:c.oneOfType([c.func,c.object]),icon:c.oneOfType([c.func,c.object]),message:c.oneOfType([c.func,c.object]),root:c.oneOfType([c.func,c.object])}),slots:c.shape({action:c.elementType,closeButton:c.elementType,closeIcon:c.elementType,icon:c.elementType,message:c.elementType,root:c.elementType}),sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),variant:c.oneOfType([c.oneOf(["filled","outlined","standard"]),c.string])});const Fu=t=>{var g;const{noIcon:e=!1,children:n,severity:r="success",variant:o="leftBorder",sx:i,title:s,...a}=t,{palette:l}=V.useTheme(),u=e?{icon:!1}:{},f=o==="leftBorder"?"standard":o,p=o==="leftBorder"?{...i,borderLeft:`4px solid ${(g=l[r])==null?void 0:g.main}`}:i,m=s?{icon:{sx:{mt:"6px"}}}:{};return b.jsxs(lI,{severity:r,variant:f,sx:p,slotProps:m,...u,...a,children:[s&&b.jsx(V.Typography,{variant:"h3",children:s}),n]})},cI=t=>b.jsx(Fu,{severity:"error",...t}),uI=t=>b.jsx(Fu,{severity:"success",...t}),wee=t=>{const{alert:e,setAlert:n}=t,r=()=>n(void 0);return b.jsxs(b.Fragment,{children:[(e==null?void 0:e.type)==="Error"&&b.jsx(cI,{"data-testid":"citation-menu-error",onClose:r,title:e.title,children:e.message.toString()}),(e==null?void 0:e.type)==="Success"&&b.jsx(uI,{"data-testid":"citation-menu-success",onClose:r,children:e.message})]})};function dI({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,onSelectCitations:a,onCancel:l,initialSelectedIds:u=[],onContentChange:f,onError:p=()=>{},renderAsSelectablePopup:m=!1,addlActions:g,canLaunchUrl:v,readOnly:y}){const[x,S]=Z.useState("Insert Citation/Attachment(s)"),[k,T]=Z.useState(u),[C,O]=Z.useState(void 0),[I,N]=Z.useState(void 0),$=G=>{N(void 0),S(G)},[H,M]=Z.useState(0);Z.useEffect(()=>{f==null||f()},[x,I,f]);const F=(G=!1)=>{(!m||G)&&M(te=>te+1)},z=(G,te)=>{var de;const ue=typeof((de=te.response)==null?void 0:de.data)=="string"&&te.response.data,re=typeof te.message=="string"&&te.message;N({type:"Error",title:G,message:ue??re}),p(te)},B=G=>N({type:"Success",title:"",message:G}),P=async G=>{if(x==="Insert Citation/Attachment(s)")throw Error("onSave called with invalid state");if(x==="Edit Citation"||x==="Edit Attachment"){if(G.id===void 0)throw Error("Failed to update citation. Citation is missing id");await(n==null?void 0:n(G).then(()=>{$("Insert Citation/Attachment(s)"),F()}).catch(ue=>{z("Failed to update",ue)}))}else await(e==null?void 0:e(G).then(ue=>{T([...k,ue.id]),$("Insert Citation/Attachment(s)"),F()}).catch(ue=>{z("Failed to create",ue)}))},_=r&&(async G=>r(G).then(()=>{F(!0),T(k.filter(te=>te!==G)),B("Successfully deleted")}).catch(te=>z("Failed to delete",te))),A=(G,te)=>{o(G.id).then(ue=>{O(ue),$(te)}).catch(ue=>{z("Failed to load",ue)})},R=i&&(async G=>i(G).catch(te=>{z(`Failed to download ${G.fileName}`,te)})),j=s&&(async G=>s(G).catch(te=>{z(`Failed to view ${G.fileName}`,te)})),K=b.jsx(MQ,{refreshKey:H,getCitationsPaginated:G=>t(G).then(te=>(f==null||f(),te)),onCancel:l,onNewCitation:()=>{O(void 0),$("Add Citation")},onNewAttachment:()=>{O(void 0),$("Add Attachment")},onEditCitation:G=>A(G,y?"View Citation":"Edit Citation"),onEditAttachment:G=>A(G,y?"View Attachment":"Edit Attachment"),onDeleteCitation:_,onDownloadAttachment:R,onViewAttachment:j,onSelect:a,setSelectedIds:T,selectedIds:k,onError:p,condenseTable:m,canSelect:m,title:m&&!y?x:"Attachments & Citations",addlActions:g,canCreate:!!e,canEdit:!!n,canDelete:!!_,canLaunchUrl:v,readOnly:y,showCloseBtn:m}),U=b.jsx(lee,{modifyCitation:C,onSave:P,onCancel:()=>$("Insert Citation/Attachment(s)"),onClose:l,title:x,readOnly:x==="View Citation",showCloseBtn:m}),Y=b.jsx(cee,{onSave:P,onCancel:()=>$("Insert Citation/Attachment(s)"),onClose:l,modifyCitation:C,disableFileUpload:x==="Edit Attachment",title:x,readOnly:x==="View Attachment",showCloseBtn:m}),oe=b.jsx(wee,{alert:I,setAlert:N}),fe=x==="Add Citation"||x==="Edit Citation"||x==="View Citation",me=x==="Add Attachment"||x==="Edit Attachment"||x==="View Attachment";if(m){let G=null;return!m||x==="Insert Citation/Attachment(s)"?G=K:fe?G=U:me&&(G=Y),b.jsxs(V.Box,{width:"500px",children:[oe,b.jsx(V.Box,{paddingTop:"8px",children:G})]})}return b.jsxs(V.Box,{width:"100%",children:[x==="Insert Citation/Attachment(s)"&&oe,b.jsx(V.Box,{paddingTop:"8px",children:K}),b.jsx(Bu,{open:fe||me,children:b.jsxs(V.Box,{padding:"10px 20px",minWidth:"400px","data-testid":"citation-form-modal",children:[oe,fe?U:Y]})})]})}function fI({...t}){return b.jsx(dI,{renderAsSelectablePopup:!0,...t})}const See=V.styled("div",{name:"CitationBubbleMenu",slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>{const e=t.palette.mode==="dark";return{padding:t.spacing(1.5,2,.5),backgroundColor:e?"#101010":"#f9f9f9",border:`1px solid ${t.palette.grey[e?700:200]}`}});function Cee({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,canLaunchUrl:a,readOnly:l,...u}){const f=wt();if(f&&!("citationBubbleMenuHandler"in(f==null?void 0:f.storage)))throw new Error("You must add the CitationBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const p=f==null?void 0:f.storage.citationBubbleMenuHandler,m=p.isOpen,g=p.selectedIds,v=p.selectedNodePos,y=T=>{f&&(T.length===0?f.commands.deleteCitation(v):g.length===0?f.commands.insertCitation({ids:T}):f.commands.updateCitation({ids:T},v))},x=T=>{y(T),f==null||f.commands.closeCitationBubbleMenu()},S=()=>{y(g),f==null||f.commands.closeCitationBubbleMenu()},k=Z.useCallback(()=>{requestAnimationFrame(()=>{f!=null&&f.view&&f.view.dispatch(f.view.state.tr)})},[f]);return f?b.jsx(by,{editor:f,open:m,...p.bubbleMenuOptions,...u,children:b.jsx(See,{children:b.jsx(fI,{getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,onSelectCitations:x,onCancel:S,initialSelectedIds:g,onContentChange:k,canLaunchUrl:a,readOnly:l})})}):null}const Tee=()=>ln.create({name:"citationBubbleMenuHandler",addStorage(){return{isOpen:!1,selectedIds:[],bubbleMenuOptions:void 0,selectedNodePos:0}},addCommands(){return{openCitationBubbleMenu:(t={},e)=>({editor:n,dispatch:r})=>{var a;const{doc:o}=n.state,i=o.nodeAt(e??0),s=((a=i==null?void 0:i.attrs)==null?void 0:a.ids)??[];return r&&(this.storage.isOpen=!0,this.storage.selectedIds=s,this.storage.bubbleMenuOptions=t,this.storage.selectedNodePos=e??0),!0},closeCitationBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.isOpen?(t.focus(),e&&(this.storage.isOpen=!1,this.storage.selectedIds=[],this.storage.selectedNodePos=0),!0):!1}},onSelectionUpdate(){this.storage.isOpen&&!this.editor.isActive("citation")&&this.editor.commands.closeCitationBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-c":()=>(this.editor.commands.openCitationBubbleMenu(),!0)}}});function kee(t){const e=wt(),n=Z.useRef(null);return b.jsx(St,{buttonRef:n,tooltipLabel:"Insert Citation/Attachment",tooltipShortcutKeys:["mod","Shift","C"],disabled:!(e!=null&&e.isEditable),onClick:()=>e==null?void 0:e.commands.openCitationBubbleMenu({anchorEl:n.current,placement:"bottom"}),...t,children:b.jsxs(V.Box,{display:"flex",flexDirection:"row",gap:"4px",alignItems:"center",children:[b.jsx(LU,{fontSize:"small"}),b.jsx(V.Typography,{variant:"body2",children:"Insert Citation/Attachment"})]})})}const pI=Z.createContext(void 0),hI=()=>{const t=Z.useContext(pI);if(!t)throw new Error("useSync must be used inside CitationFieldProvider");return t},Eee=({node:t,HTMLAttributes:e,selected:n,extension:r,updateAttributes:o,deleteNode:i})=>{const s=t.attrs.ids||[],{citations:a,isLoaded:l}=hI(),[u,f]=Z.useState(s?String(s):""),[p,m]=Z.useState([]),g=r.options.citationMaxLength;if(Z.useEffect(()=>{if(!l)return;const v=a.filter(S=>s.includes(S.id)),y=v.map(S=>ma.truncate(S.title,{length:g,omission:"..."})).join(", ");f(y),m(v);const x=v.map(S=>S.id);x.length===0?setTimeout(i,0):x.length!==s.length&&setTimeout(()=>o({ids:v.map(S=>S.id)}),0)},[a,s,l]),p.length!==0)return b.jsx(Eb,{as:"span",...e,"data-testid":"citation-node-component",children:b.jsx(V.Tooltip,{title:b.jsx(V.Box,{className:"citation-tooltip",children:p.map((v,y)=>{var S;const x=[v.source,v.title,v.fileName,v.url,(S=v.accessedAt)==null?void 0:S.slice(0,10),v.classification];return b.jsxs(V.Typography,{variant:"subtitle2",children:[x.filter(Boolean).join(" | "),y<p.length-1&&b.jsx(V.Divider,{className:"citation-tooltip-divider"})]},v.id)})}),slotProps:{tooltip:{sx:{maxWidth:500}}},children:b.jsx("a",{href:"#",onClick:v=>{v.preventDefault(),v.stopPropagation()},className:n?"selected-citation-link":"citation-link",children:u})})})},Oee=tn.create({name:"citation",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes(){return{ids:{default:[],parseHTML:t=>{const e=t.getAttribute("ids");return e?e.split(",").map(n=>parseInt(n.trim(),10)).filter(n=>!isNaN(n)):[]},renderHTML:t=>({ids:Array.isArray(t.ids)?t.ids.join(","):""})}}},parseHTML(){return[{tag:"citation"}]},renderHTML({HTMLAttributes:t}){return["citation",xt(t)]},addNodeView(){return Ob(Eee)},addProseMirrorPlugins(){return[new en({props:{handleClickOn:(t,e,n,r,o,i)=>n&&n.type.name==="citation"?(this.editor.commands.openCitationBubbleMenu({},r),!0):!1}})]},addCommands(){return{insertCitation:t=>({commands:e})=>e.insertContent({type:"citation",attrs:t}),updateCitation:(t,e)=>({state:n,dispatch:r,tr:o})=>{const i=n.doc.nodeAt(e);return!i||i.type.name!=="citation"?!1:(o.setNodeMarkup(e,void 0,t),r&&r(o),!0)},deleteCitation:t=>({tr:e,dispatch:n})=>{if(typeof t!="number")return!1;const r=t,o=t+1;return n&&n(e.delete(r,o)),!0}}}}),mI=t=>b.jsx(uM,{name:t.name,label:"Not Applicable",errorMode:"hidden"}),Mee=t=>{const{name:e,label:n=Ln(e),hideLabel:r=!1,required:o=!1,readOnly:i,margin:s="dense",citationMaxLength:a=24,getCitationsPaginated:l,onCreateCitation:u,onUpdateCitation:f,onDeleteCitation:p,getCitationById:m,onDownloadAttachment:g,onViewAttachment:v,onError:y=()=>{},placeholder:x="Start typing here...",notApplicableName:S,errorMode:k="normal",canLaunchUrl:T}=t,C=[PT,A2.configure({placeholder:x}),Tee(),Oee.configure({citationMaxLength:a})],[O,I,N]=jt.useField({name:e}),{setValue:$}=N,{value:H}=O,{addUpdateCitation:M,deleteCitation:F,batchUpdate:z,citations:B}=hI();Z.useEffect(()=>{var me;const oe=(me=P==null?void 0:P.current)==null?void 0:me.editor;if(!oe)return;oe.getHTML()!==H&&setTimeout(()=>{oe.commands.setContent(H)},0)},[H]);const P=Z.useRef(null),_={normal:{marginTop:"16px",marginBottom:"8px"},dense:{marginTop:"8px",marginBottom:"4px"},none:{margin:0}},A=(oe=void 0)=>{var G,te;const fe=((te=(G=P.current)==null?void 0:G.editor)==null?void 0:te.getHTML())??"",me=!fe.replace(/<\/?p>|<br>/g,"").trim();$(me?"":fe,oe)},R=Z.useMemo(()=>ma.debounce(()=>A(!1),500),[$]),j=zs(),{showDiff:K,getPreviousValue:U}=Vs(),Y=i??j;if(K){const oe=U(e)??"",fe=H,me=/<citation\s+ids="([^"]*)"><\/citation>/g,G=(re,ie)=>{const de=ie.split(",").map(Number);return`<sup>${B.filter(ye=>de.includes(ye.id)).map(ye=>ye.title)}</sup>`},te=oe.replace(me,G),ue=fe.replace(me,G);return b.jsx(ha,{label:n,value:ue,showDiff:!0,diffSnapshot:te,mode:"html"})}return b.jsxs(V.Box,{id:`citation-field_${e}`,sx:{"& .ProseMirror":{"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:Y?0:50}},".MuiTiptap-RichTextContent-readonly ":{padding:0}},..._[s],display:"flex",flexDirection:"column",width:"100%",children:[b.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[!r&&b.jsx(V.InputLabel,{htmlFor:`citation-field_${e}`,required:o,children:n}),S&&b.jsx(mI,{name:S})]}),b.jsx(eM,{ref:P,extensions:C,content:H,editable:!Y,renderControls:Y?void 0:()=>b.jsx(ob,{children:b.jsx(kee,{})}),onBlur:()=>A(),onUpdate:R,RichTextFieldProps:{variant:Y?"standard":"outlined",MenuBarProps:{hide:Y}},children:()=>b.jsx(Cee,{getCitationsPaginated:oe=>l(oe).then(fe=>(z(fe.data),fe)),onCreateCitation:u&&(oe=>u(oe).then(fe=>(M(fe),fe))),onUpdateCitation:f&&(oe=>f(oe).then(fe=>(M(fe),fe))),onDeleteCitation:p&&(oe=>p(oe).then(()=>F(oe))),getCitationById:m,onDownloadAttachment:g,onViewAttachment:v,onError:y,canLaunchUrl:T,readOnly:Y})}),b.jsx(br,{name:e,id:`${e}-err`,errorMode:k})]})},_ee=t=>{const{name:e="submit"}=t;return b.jsx(co,{name:e,type:"submit",...t})},Iee=t=>{const{label:e="Return to Top",icon:n=dp,scrollThresholdPx:r=100}=t,o=V.useScrollTrigger({threshold:r}),i=Z.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"})},[]);return b.jsx(V.Zoom,{in:o,children:b.jsx(V.Box,{sx:{position:"fixed",bottom:32,right:32,zIndex:1},children:b.jsxs(V.Fab,{onClick:i,color:"primary",size:"small",variant:"extended","aria-label":"Scroll back to top",children:[b.jsx(n,{fontSize:"medium"}),e]})})})},gI=t=>{const{label:e,menuOptions:n=[],icon:r}=t,o=vo.useNavigate(),[i,s]=D.useState(null),a=!!i,l=p=>{s(p.currentTarget)},u=()=>{s(null)};if(n.length===0)return null;const f=r&&!e;return b.jsxs(b.Fragment,{children:[b.jsx(V.Button,{startIcon:f?void 0:r,variant:"outlined",color:"inherit",sx:{minWidth:0,...f&&{paddingLeft:"6px",paddingRight:"6px"}},onClick:l,children:f?r:e}),b.jsx(V.Menu,{anchorEl:i,open:a,onClick:u,children:n.map(p=>b.jsxs(V.MenuItem,{...Zl(p,o),children:[p.icon&&b.jsx(V.ListItemIcon,{children:p.icon}),b.jsx(V.ListItemText,{primary:p.label})]},p.label))})]})},Aee=()=>{const{values:t,errors:e,status:n}=jt.useFormikContext(),{palette:r}=V.useTheme();return b.jsx(V.Paper,{style:{backgroundColor:r.mode==="dark"?"#303030":"#f0f0f0",margin:"10px 0"},children:b.jsxs(V.List,{children:[b.jsxs(V.ListItem,{children:[b.jsx(V.Typography,{display:"block",variant:"h6",children:"Values"}),b.jsx("br",{}),b.jsx(V.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(t,null,2)})]}),b.jsx(V.Divider,{variant:"inset",component:"li"}),b.jsxs(V.ListItem,{id:"testing",children:[b.jsx(V.Typography,{display:"block",variant:"h6",children:"Errors"}),b.jsx("br",{}),b.jsx(V.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(e,null,2)})]}),b.jsxs(V.ListItem,{children:[b.jsx(V.Typography,{display:"block",variant:"h6",children:"Status"}),b.jsx("br",{}),b.jsx(V.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(n,null,2)})]})]})})},Dee=t=>{const{steps:e,orientation:n,inlineLabel:r=n=="vertical",isResponsive:o=!1}=t,{width:i}=F2();let s=!r,a=n;o&&(n&&console.warn("Stepper: Ignoring orientation. isResponsive is set to true, so the orientation is determined automatically based on the window size."),a=i<600?"vertical":"horizontal",a=="vertical"?s=!1:s=!r),n=="vertical"&&!r&&(console.warn("Stepper: ignoring inlineLabel={false}. Must use inline labels when orientation is vertical"),s=!1);const l=["steps","inlineLabel","orientation","isResponsive"],u={alternativeLabel:s,orientation:a,...cr({...t},l)};return b.jsx(V.Stepper,{...u,children:e.map(f=>b.jsx(V.Step,{children:b.jsx(V.StepLabel,{children:f})},f))})},Pee=t=>{const{name:e,label:n=Ln(e),labelProps:r={fontSize:"1.1em",color:"#808080",fontWeight:"600"},initialState:o,renderFormGroup:i,addButtonContent:s="Add Another",removeButtonContent:a=t.removePosition==="right"?b.jsx($M,{}):"Remove",variant:l="card",addButtonSx:u,removeButtonSx:f,allowRemoveAll:p=!1,readOnly:m=!1,emptyListMsg:g="None",showDivider:v=!1,removePosition:y="bottom"}=t,[x]=jt.useField({name:e}),{value:S}=x,k=T=>({display:"flex",flexDirection:T==="bottom"?"column":"row",alignItems:T==="bottom"?"flex-start":"center"});return b.jsxs(V.FormControl,{fullWidth:!0,children:[b.jsx(V.Typography,{...r,children:n}),m&&x.value.length===0?b.jsx(V.Typography,{children:g}):b.jsx(jt.FieldArray,{name:e,render:T=>b.jsxs("div",{children:[S.map((C,O)=>b.jsx(Z.Fragment,{children:b.jsx(Nee,{variant:l,content:b.jsxs(V.Box,{"data-testid":"form-group-container",sx:typeof y=="string"?k(y):{...y},children:[b.jsxs(V.Box,{width:"100%",children:[i(`${e}.${O}`,O),v&&O!==S.length-1&&b.jsx(V.Divider,{"data-testid":"divider"})]}),!m&&S.length>(p?0:1)&&b.jsx(V.Button,{"data-testid":"repeatable-form-group_remove-btn",sx:f,onClick:()=>T.remove(O),children:a})]})})},`${e}-${O}`)),!m&&b.jsx(V.Button,{"data-testid":"repeatable-form-group_add-btn",onClick:()=>T.push(o),sx:u,children:s})]})})]})},Nee=({variant:t,content:e})=>{switch(t){case"card":return b.jsx(V.Card,{"data-testid":"repeatable-form-group_card",sx:{padding:"8px",marginBottom:"8px"},children:b.jsx(V.CardContent,{children:e})});case"elevatedCard":return b.jsx(V.Card,{"data-testid":"repeatable-form-group_elevated-card",elevation:4,sx:{border:"unset",padding:"8px",marginBottom:"8px"},children:b.jsx(V.CardContent,{children:e})});case"none":return e}},$ee=t=>{const{confirmBtnLabel:e,onConfirm:n,confirmButtonProps:r={color:"primary",variant:"contained"},closeBtnLabel:o="Cancel",closeButtonPosition:i="bottom",...s}=t;return b.jsx(Bu,{actions:[b.jsx(V.Button,{className:"MBv2_ConfirmationModal_ConfirmBtn",onClick:n,...r,children:e})],closeBtnLabel:o,closeButtonPosition:i,...s})},Lee=t=>{const{closeBtnLabel:e="OK",closeButtonPosition:n="bottom",closeButtonProps:r={color:"primary",variant:"contained"},...o}=t;return b.jsx(Bu,{closeBtnLabel:e,closeButtonPosition:n,closeButtonProps:r,...o})},Bee=t=>{const{primaryBtnLabel:e,onPrimaryAction:n,primaryActionProps:r={color:"primary",variant:"contained"},secondaryBtnLabel:o,onSecondaryAction:i,secondaryActionProps:s={color:"primary",variant:"outlined"},closeBtnLabel:a="Cancel",closeButtonPosition:l="bottom",...u}=t;return b.jsx(Bu,{actions:[b.jsx(V.Button,{className:"MBv2_DecisionModal_SecondaryAction",onClick:i,...s,children:o}),b.jsx(V.Button,{className:"MBv2_DecisionModal_PrimaryAction",onClick:n,...r,children:e})],closeBtnLabel:a,closeButtonPosition:l,...u})},Fee={added:{icon:NU,label:"Added",color:"success"},deleted:{icon:$M,label:"Deleted",color:"error"},modified:{icon:BU,label:"Modified",color:"info"}},yI=t=>{const{beforeData:e,afterData:n,emptyTableMsg:r="No changes to display",columns:o,isEqual:i,size:s}=t;t.renderExpand!=null&&t.isEqual==null&&console.warn("DiffTable: isEqual prop should be provided when renderExpand is provided");const a=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),{dataDiff:l,unmodifiedCount:u}=Z.useMemo(()=>Vee(o,e,n,a,i),[e,n,o,a,i]),f=o.map(p=>({...p,render:(m,g)=>{var v;return((v=g.modifiedDiff)==null?void 0:v[xn(p)])??$u(p,g,a)}}));return b.jsxs(V.Box,{children:[b.jsx(iv,{columns:[{fieldName:"changeType",render:p=>{const m=Fee[p];return b.jsx(V.Chip,{color:m.color,size:s=="medium"?"medium":"small",label:b.jsxs(V.Typography,{children:[b.jsx(Vm,{icon:m.icon}),m.label]})})}},...f],data:l,emptyTableMsg:r,renderExpand:t.renderExpand?p=>{const m=e.find(g=>g.id===p.id);return b.jsx(uw,{previousSnapshot:m,currentSnapshot:p,showDiff:p.changeType==="modified",children:t.renderExpand(p)})}:void 0,size:s}),u>0&&b.jsx(V.Box,{children:b.jsxs(V.Typography,{fontStyle:"italic",children:["+",u," unmodified rows"]})})]})},Ree=(t,e)=>b.jsxs(b.Fragment,{children:[b.jsx(V.Box,{"data-testid":"diff-table-cell-removed",sx:{backgroundColor:lp},children:b.jsx("s",{children:t})}),b.jsx(V.Box,{"data-testid":"diff-table-cell-added",sx:{backgroundColor:ap},children:b.jsx("u",{children:e})})]}),zee=(t,e,n,r=!1)=>{var i;let o={};for(const s of t)if(!s.ignoreDiff){const a=$u(s,e,r),l=$u(s,n,r);(((i=s.isEqual)==null?void 0:i.call(s,e,n))??ma.isEqual(a,l))||(o[xn(s)]=Ree(a,l))}return o},Vee=(t,e,n,r=!1,o)=>{const i=[];let s=0,a=0,l=0;for(e.sort((u,f)=>u.id-f.id),n.sort((u,f)=>u.id-f.id);s<e.length&&a<n.length;){const u=e[s],f=n[a];if(u.id===f.id){const p=zee(t,u,f,r);(o==null?void 0:o(u,f))??Object.keys(p).length===0?l++:i.push({...f,changeType:"modified",modifiedDiff:p}),s++,a++}else u.id<f.id?(i.push({...u,changeType:"deleted"}),s++):(i.push({...f,changeType:"added"}),a++)}for(;s<e.length;)i.push({...e[s],changeType:"added"}),s++;for(;a<n.length;)i.push({...n[a],changeType:"added"}),a++;return{dataDiff:i,unmodifiedCount:l}},Hee=t=>{const{beforeCitations:e,afterCitations:n,condenseTable:r=!1}=t,{palette:o}=V.useTheme(),i=R2(o,r);return b.jsxs(V.Box,{children:[!r&&b.jsx(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"10px",children:b.jsx(V.Typography,{variant:"h2",children:" Attachments & Citations"})}),b.jsx(yI,{columns:i,beforeData:e,afterData:n,size:r?"x-small":"medium"})]})},Wee=t=>{const{featureMenuOptions:e=[],copyright:n,logo:r,sx:o={},fontColor:i="primary"}=t,{palette:s}=V.useTheme(),a=vo.useNavigate();return b.jsxs(V.Box,{className:"MBv2_Footer",sx:{backgroundColor:s.mode==="dark"?"#222222":"#ededed",padding:"25px 30px",...o},children:[b.jsx(V.Box,{className:"MBv2_Footer_Logo",sx:{display:"flex",gap:2,alignItems:"center",paddingBottom:1},children:typeof r=="string"?b.jsx("img",{draggable:"false",src:r,style:{width:"200px"},alt:"logo"}):r}),b.jsxs(V.Box,{display:"flex",justifyContent:"space-between",flexWrap:"wrap",className:"MBv2_Footer_Nav_Links_Container",gap:2,children:[b.jsx(V.Box,{sx:{flexGrow:1},className:"MBv2_Footer_Nav_Links",display:"flex",flexDirection:"row",justifyContent:"flex-start",gap:3,children:e==null?void 0:e.map(l=>b.jsx(V.Link,{"data-testid":l.label,sx:{cursor:"pointer",fontSize:15},color:i,...Zl(l,a),children:l.label},l.label))}),n&&b.jsx(V.Typography,{style:{fontSize:15},"data-testid":"copyright",className:"MBv2_Footer_Copyright",color:i,children:n})]})]})},bI=t=>{const{menuOptionLists:e,anchor:n="left",children:r}=t,{pathname:o}=vo.useLocation(),i=vo.useNavigate(),[s,a]=Z.useState(!1),l=(m,g)=>b.jsx(V.MenuList,{children:m.map(v=>b.jsxs(V.MenuItem,{...Zl(v,i,()=>a(!1)),children:[v.icon&&b.jsx(V.ListItemIcon,{children:v.icon}),b.jsx(V.ListItemText,{primary:v.label})]},`mobile-drawer-group-${g}-item-${v.path}`))}),f=(()=>{if(e){const m=e.filter(g=>g&&g.length>0);return m.length===0?null:m.map((g,v)=>b.jsxs(Z.Fragment,{children:[l(g,v),v<m.length-1&&b.jsx(V.Divider,{})]},`mobile-drawer-group-${v}`))}return r?b.jsx(V.Box,{role:"presentation",onClick:()=>a(!1),children:r}):null})(),p=f??!1;return Z.useEffect(()=>{a(!1)},[o]),p&&b.jsxs(b.Fragment,{children:[b.jsx(V.IconButton,{onClick:()=>a(!0),color:"inherit",title:"Menu",children:b.jsx(jU,{})}),b.jsx(V.Drawer,{"data-testid":"mobile-drawer",anchor:n,open:s,onClose:()=>a(!1),children:b.jsx(V.Box,{sx:{width:300},display:"flex",flexDirection:"column",justifyContent:"space-between",children:b.jsx(V.Box,{display:"flex",justifyContent:"start",flexDirection:"column",children:f})})})]})},vI=t=>{const{env:e,isProd:n}=t;return n?null:b.jsx(V.Paper,{sx:{borderRadius:0,display:"flex",alignItems:"center",justifyContent:"center"},children:b.jsxs(V.Typography,{variant:"h6",color:"error",children:[e," Environment - Test Data Only"]})})},xI=t=>{const{displayName:e,userMenuOptions:n}=t;return b.jsx(gI,{label:e,menuOptions:n,icon:b.jsx(qU,{})})},Oh=t=>{const{menuOptions:e,orientation:n="horizontal",activeTabIdx:r,sx:o=n=="vertical"?{"& .MuiTabs-indicator":{left:0}}:void 0,slotProps:i={indicator:{sx:n=="horizontal"?{height:4}:{width:4}}}}=t,{palette:s}=V.useTheme(),a=vo.useNavigate();return b.jsx(V.Tabs,{orientation:n,value:r??!1,sx:o,slotProps:i,children:e.map((l,u)=>b.jsx(V.Tab,{icon:l.icon,label:l.label,value:u,...Zl(l,a),sx:{alignItems:n=="vertical"?"flex-start":void 0,borderBottom:n=="vertical"?"1px solid":void 0,borderColor:"divider","&.Mui-selected":{backgroundColor:n=="vertical"?s.grey[s.mode=="dark"?800:50]:void 0,color:"inherit"}}},l.label))})},wI=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t;return e.length>0&&b.jsx(V.Paper,{sx:{pl:4,pr:4,borderRadius:0},"data-testid":"navBar",children:b.jsx(Oh,{menuOptions:e,activeTabIdx:n,sx:r})})},SI=t=>{const{onToggle:e}=t,{palette:n}=V.useTheme(),r=n.mode==="dark";return b.jsx(V.IconButton,{onClick:e,color:"inherit",title:"Dark Mode Toggle",children:r?b.jsx(NM,{}):b.jsx(DM,{})})},jee=t=>{const{envInfo:e,headerRef:n,logo:r,featureMenuOptions:o=[],userMenuOptions:i=[],onToggleDarkMode:s,quickLinks:a=[],displayName:l,banner:u,position:f="fixed",children:p,sx:m,navBarSx:g}=t,v=vo.useNavigate(),y=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),{palette:x}=V.useTheme(),{pathname:S}=vo.useLocation(),k=x.mode==="dark",[T,C]=D.useState(void 0);D.useEffect(()=>{const N=o.findIndex($=>$.path&&S.startsWith($.path));C(N>=0?N:void 0)},[S,o]);const O=s&&b.jsx(SI,{onToggle:s}),I=s&&(y||!y&&l)?[{icon:k?b.jsx(NM,{}):b.jsx(DM,{}),label:`Switch to ${k?"Light":"Dark"} mode`,onClick:s},...i]:i;return b.jsxs(V.AppBar,{ref:n,position:f,sx:m,elevation:4,children:[e&&b.jsx(vI,{...e}),u,b.jsxs(V.Toolbar,{sx:{color:"white",display:"flex",justifyContent:"space-between",gap:2},children:[b.jsx(V.Button,{disableRipple:!0,component:vo.Link,to:"/",children:r&&typeof r=="string"?b.jsx("img",{draggable:"false",src:r,style:{width:"200px",filter:"brightness(0) invert(1)"},alt:"logo"}):r}),b.jsxs(V.Box,{display:"flex",gap:2,alignItems:"center",children:[!l&&!y&&O,y&&b.jsx(bI,{menuOptionLists:[o,a,I],anchor:"right"}),!y&&b.jsxs(b.Fragment,{children:[b.jsx(V.Box,{display:"flex",gap:0,children:a==null?void 0:a.map((N,$)=>b.jsxs(V.Box,{display:"flex",alignItems:"center",children:[$>0&&b.jsx(V.Typography,{className:"quickLink-divider",color:x.primary.contrastText,children:"|"}),b.jsx(V.Button,{variant:"text",sx:{color:"white"},...Zl(N,v),children:b.jsxs(V.Box,{display:"flex",gap:"3px",alignItems:"center",children:[N.icon,N.label]})})]},N.label))}),p,l&&b.jsx(xI,{displayName:l,userMenuOptions:I})]})]})]}),!y&&b.jsx(wI,{featureMenuOptions:o,activeTabIdx:T,sx:g})]})},Uee=t=>{const{sx:e,menuOptions:n=[]}=t,{pathname:r}=vo.useLocation(),o=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),[i,s]=Z.useState(void 0);return Z.useEffect(()=>{const a=n.findIndex(l=>l.path&&r.startsWith(l.path))??-1;s(a>=0?a:void 0)},[r,n]),!o&&n.length>0&&b.jsx(V.Box,{sx:e,children:b.jsx(V.Card,{sx:{height:"100%",width:200},children:b.jsx(Oh,{orientation:"vertical",menuOptions:n,activeTabIdx:i})})})},qee=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t,{palette:o}=V.useTheme();return e.length>0&&b.jsx(Oh,{menuOptions:e,activeTabIdx:n,sx:{margin:"8px",backgroundColor:o.primary.dark,borderRadius:"8px","& .MuiTab-root":{color:o.secondary.light,flexDirection:"row",gap:"2px","& .MuiTab-icon":{marginBottom:"unset"},minHeight:"58px"},"& .MuiTab-root.Mui-selected":{color:o.primary.contrastText,fontSize:"120%"},"& .MuiTabs-indicator":{display:"none"},...r}})},Kee=t=>{const{gap:e=1,...n}=t;return b.jsx(V.Box,{display:"flex",flexDirection:"column",gap:e,...n})},Yee=({children:t,getCitations:e})=>{const[n,r]=Z.useState([]),[o,i]=Z.useState(!1);Z.useEffect(()=>{(async()=>e().then(f=>{r(p=>{const m=new Set(p.map(v=>v.id));return[...p.filter(v=>!m.has(v.id)),...f]}),i(!0)}).catch(f=>{console.error(`Error fetching citations: ${f==null?void 0:f.toString()}`)}))()},[]);const s=Z.useCallback(u=>{r(f=>{const p=f.map(v=>{const y=u.find(x=>x.id===v.id);return y||v}),m=new Set(f.map(v=>v.id)),g=u.filter(v=>!m.has(v.id));return[...p,...g]})},[]),a=Z.useCallback(u=>{const f=n.findIndex(p=>p.id===u.id);r(f!==-1?p=>{const m=[...p];return m[f]=u,m}:[...n,u])},[n]),l=Z.useCallback(u=>r(n.filter(f=>f.id!==u)),[n]);return b.jsx(pI.Provider,{value:{citations:n,isLoaded:o,addUpdateCitation:a,deleteCitation:l,batchUpdate:s},children:t})},Gee=t=>b.jsx(Fu,{severity:"info",...t}),Jee=t=>b.jsx(Fu,{severity:"warning",...t}),CI=t=>{const{crumbInfo:e}=t,n=vo.useNavigate();return b.jsx(V.Breadcrumbs,{"aria-label":"breadcrumb",separator:b.jsx(UU,{color:"primary"}),sx:{marginBottom:2},children:e.map(({label:r,path:o},i)=>o&&i<e.length-1?b.jsx(V.Link,{color:"primary",sx:{cursor:"pointer"},onClick:()=>n(o),children:r},r):b.jsx(V.Typography,{color:"primary",children:r},r))})},Xee=t=>{const{title:e,message:n,type:r,onClose:o,autoHideDuration:i,variant:s="leftBorder",elevation:a=6}=t,l=Zee(r);return b.jsx(V.Snackbar,{"data-testid":"message-snackbar",anchorOrigin:{vertical:"bottom",horizontal:"right"},open:!0,onClose:u=>{u==null&&o()},autoHideDuration:i,children:b.jsx(Fu,{"data-testid":"message-snackbar-alert",severity:l,iconMapping:{info:TI(r),warning:TI(r)},onClose:o,elevation:a,variant:s,children:n?b.jsxs(b.Fragment,{children:[b.jsx(V.AlertTitle,{"data-testid":"alertTitle",sx:{fontWeight:"bold"},children:e}),n]}):e})})},Zee=t=>t=="logout"?"info":t=="timeout"?"warning":t,TI=t=>{if(t=="timeout")return b.jsx(PU,{});if(t=="logout")return b.jsx(WU,{})},Qee=t=>{ete(t);const{title:e,createButtonLabel:n="Add Item",showAddButton:r=!1,onAdd:o=()=>alert("Not implemented yet"),breadcrumbs:i=[],children:s,sx:a={},bottomGutter:l=!1}=t,u=V.useMediaQuery(V.useTheme().breakpoints.down("sm"));return!e&&(!r||!n)?null:b.jsxs(V.Box,{"data-testid":"MBv2-Page-Header",sx:{...a,...l&&{marginBottom:"4px"}},children:[i.length>0&&b.jsx(CI,{crumbInfo:i}),b.jsxs(V.Box,{className:"MBv2_PageHeader_Header",display:"flex",flexDirection:u?"column":"row",justifyContent:"space-between",alignItems:"center",gap:1,children:[b.jsxs(V.Box,{className:"MBv2_PageHeader_TitleAndCreateBtn",display:"flex",flexDirection:"row",justifyContent:u||!s?"space-between":"start",alignItems:"center",width:"100%",gap:1,children:[typeof e=="string"?b.jsx(V.Typography,{className:"MBv2_PageHeader_Title",variant:"h2",children:e}):e,r&&b.jsxs(co,{className:"MBv2_PageHeader_CreateBtn",onClick:()=>o(),children:[b.jsx($U,{style:{marginRight:"0.5rem"}}),n]})]}),s&&b.jsx(V.Box,{width:u?"100%":"50%",children:s})]})]})},ete=t=>{const{showAddButton:e,onAdd:n,createButtonLabel:r}=t,o="PageHeader component:";e&&!n&&console.warn(`${o} "showAddButton" is true but "onAdd" is not defined.`),e&&!r&&console.warn(`${o} "showAddButton" is true but "createButtonLabel" is not defined`)},tte=t=>{const{title:e,titleIcon:n,fullWidthIcon:r=!1,children:o,actionLabel:i,action:s,sx:a}=t,l=V.useMediaQuery(V.useTheme().breakpoints.down("sm"));return b.jsxs(V.Card,{sx:a||{padding:"30px 40px",display:"flex",flexDirection:"column",gap:"1rem"},children:[n&&b.jsx(V.Box,{className:"MBv2_SingleActionCard_Img",sx:[r?{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"20px",marginBottom:"10px"}:{display:"inline"}],children:n}),b.jsx(V.Typography,{variant:"h1",display:"inline",fontSize:"calc(20px + .9vw)",className:"MBv2_SingleActionCard_Title",children:e}),o,b.jsx(V.Button,{variant:"contained",color:"primary",onClick:s,fullWidth:l,className:"MBv2_SingleActionCard_ActionButton",children:i})]})};function nte({...t}){return b.jsx(dI,{onSelectCitations:()=>{},onCancel:()=>{},renderAsSelectablePopup:!1,...t})}const rte=t=>{const{size:e="small"}=t;let n=`${e}px`;switch(e){case"x-small":n="6px";break;case"small":n="10px";break;case"medium":n="14px";break;case"large":n="18px";break;case"x-large":n="22px";break}return b.jsx(V.Box,{height:n})};De.AlertModal=Lee,De.Autocomplete=lM,De.Breadcrumbs=CI,De.Button=co,De.Checkbox=uM,De.CheckboxGroup=rU,De.CitationField=Mee,De.CitationFieldProvider=Yee,De.CitationManager=nte,De.Column=Kee,De.ConfirmationModal=$ee,De.DarkModeToggle=SI,De.DateField=Hp,De.DateRangeField=MZ,De.DecisionModal=Bee,De.Diff=sM,De.DiffCitationTable=Hee,De.DiffProvider=uw,De.DiffTable=yI,De.Drawer=bI,De.DynamicAutocomplete=tU,De.EnvironmentBanner=vI,De.ErrorAlert=cI,De.FileList=sU,De.FileUpload=fM,De.FloatingNavBar=qee,De.Footer=Wee,De.FormDebugger=Aee,De.Header=jee,De.InfoAlert=Gee,De.LoadingButton=sv,De.LoadingIndicator=ov,De.Location=MU,De.MenuButton=gI,De.Modal=Bu,De.MultiAutocomplete=nU,De.NavBar=wI,De.NotApplicableCheckbox=mI,De.PageHeader=Qee,De.PaginatedTable=L2,De.ProfileMenu=xI,De.RadioGroup=AM,De.RangeSlider=_U,De.ReadOnly=ha,De.ReadOnlyProvider=lw,De.RepeatableFormGroup=Pee,De.RichTextField=CQ,De.Row=iI,De.ScrollToTop=Iee,De.SearchField=XU,De.Select=IU,De.SelectableCitationManager=fI,De.Sidebar=Uee,De.SingleActionCard=tte,De.Snackbar=Xee,De.Spacer=rte,De.Stepper=Dee,De.Submit=_ee,De.SuccessAlert=uI,De.Switch=AU,De.Table=iv,De.Tabs=Oh,De.TextArea=DU,De.TextField=gs,De.TextIcon=Vm,De.ValidationError=br,De.WarningAlert=Jee,De.commonTheme=_n,De.darkTheme=EP,De.lightTheme=kP,De.useDiff=Vs,De.useReadOnly=zs,Object.defineProperty(De,Symbol.toStringTag,{value:"Module"})}));
|
|
408
|
+
`+(a!==s?`result of cast: ${a}`:""))}return i}_cast(e,n){let r=e===void 0?e:this.transforms.reduce((o,i)=>i.call(this,o,e,this,n),e);return r===void 0&&(r=this.getDefault(n)),r}_validate(e,n={},r,o){let{path:i,originalValue:s=e,strict:a=this.spec.strict}=n,l=e;a||(l=this._cast(l,Object.assign({assert:!1},n)));let u=[];for(let f of Object.values(this.internalTests))f&&u.push(f);this.runTests({path:i,value:l,originalValue:s,options:n,tests:u},r,f=>{if(f.length)return o(f,l);this.runTests({path:i,value:l,originalValue:s,options:n,tests:this.tests},r,o)})}runTests(e,n,r){let o=!1,{tests:i,value:s,originalValue:a,path:l,options:u}=e,f=y=>{o||(o=!0,n(y,s))},p=y=>{o||(o=!0,r(y,s))},m=i.length,g=[];if(!m)return p([]);let v={value:s,originalValue:a,path:l,options:u,schema:this};for(let y=0;y<i.length;y++){const x=i[y];x(v,f,function(k){k&&(Array.isArray(k)?g.push(...k):g.push(k)),--m<=0&&p(g)})}}asNestedTest({key:e,index:n,parent:r,parentPath:o,originalParent:i,options:s}){const a=e??n;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const l=typeof a=="number";let u=r[a];const f=Object.assign({},s,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[l?"index":"key"]:a,path:l||a.includes(".")?`${o||""}[${l?a:`"${a}"`}]`:(o?`${o}.`:"")+e});return(p,m,g)=>this.resolve(f)._validate(u,f,m,g)}validate(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return new Promise((s,a)=>o._validate(e,n,(l,u)=>{hr.isError(l)&&(l.value=u),a(l)},(l,u)=>{l.length?a(new hr(l,u,void 0,void 0,i)):s(u)}))}validateSync(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i,s=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return o._validate(e,Object.assign({},n,{sync:!0}),(a,l)=>{throw hr.isError(a)&&(a.value=l),a},(a,l)=>{if(a.length)throw new hr(a,e,void 0,void 0,s);i=l}),i}isValid(e,n){return this.validate(e,n).then(()=>!0,r=>{if(hr.isError(r))return!1;throw r})}isValidSync(e,n){try{return this.validateSync(e,n),!0}catch(r){if(hr.isError(r))return!1;throw r}}_getDefault(e){let n=this.spec.default;return n==null?n:typeof n=="function"?n.call(this,e):Bl(n)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,n){const r=this.clone({nullable:e});return r.internalTests.nullable=Ll({message:n,name:"nullable",test(o){return o===null?this.schema.spec.nullable:!0}}),r}optionality(e,n){const r=this.clone({optional:e});return r.internalTests.optionality=Ll({message:n,name:"optionality",test(o){return o===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=ei.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=ei.notNull){return this.nullability(!1,e)}required(e=ei.required){return this.clone().withMutation(n=>n.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let n=this.clone();return n.transforms.push(e),n}test(...e){let n;if(e.length===1?typeof e[0]=="function"?n={test:e[0]}:n=e[0]:e.length===2?n={name:e[0],test:e[1]}:n={name:e[0],message:e[1],test:e[2]},n.message===void 0&&(n.message=ei.default),typeof n.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),o=Ll(n),i=n.exclusive||n.name&&r.exclusiveTests[n.name]===!0;if(n.exclusive&&!n.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return n.name&&(r.exclusiveTests[n.name]=!!n.exclusive),r.tests=r.tests.filter(s=>!(s.OPTIONS.name===n.name&&(i||s.OPTIONS.test===o.OPTIONS.test))),r.tests.push(o),r}when(e,n){!Array.isArray(e)&&typeof e!="string"&&(n=e,e=".");let r=this.clone(),o=j2(e).map(i=>new Ta(i));return o.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof n=="function"?new Ch(o,n):Ch.fromOptions(o,n)),r}typeError(e){let n=this.clone();return n.internalTests.typeError=Ll({message:e,name:"typeError",skipAbsent:!0,test(r){return this.schema._typeCheck(r)?!0:this.createError({params:{type:this.schema.type}})}}),n}oneOf(e,n=ei.oneOf){let r=this.clone();return e.forEach(o=>{r._whitelist.add(o),r._blacklist.delete(o)}),r.internalTests.whiteList=Ll({message:n,name:"oneOf",skipAbsent:!0,test(o){let i=this.schema._whitelist,s=i.resolveAll(this.resolve);return s.includes(o)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:s}})}}),r}notOneOf(e,n=ei.notOneOf){let r=this.clone();return e.forEach(o=>{r._blacklist.add(o),r._whitelist.delete(o)}),r.internalTests.blacklist=Ll({message:n,name:"notOneOf",test(o){let i=this.schema._blacklist,s=i.resolveAll(this.resolve);return s.includes(o)?this.createError({params:{values:Array.from(i).join(", "),resolved:s}}):!0}}),r}strip(e=!0){let n=this.clone();return n.spec.strip=e,n}describe(e){const n=(e?this.resolve(e):this).clone(),{label:r,meta:o,optional:i,nullable:s}=n.spec;return{meta:o,label:r,optional:i,nullable:s,default:n.getDefault(e),type:n.type,oneOf:n._whitelist.describe(),notOneOf:n._blacklist.describe(),tests:n.tests.filter((l,u,f)=>f.findIndex(p=>p.OPTIONS.name===l.OPTIONS.name)===u).map(l=>{const u=l.OPTIONS.params&&e?G2(Object.assign({},l.OPTIONS.params),e):l.OPTIONS.params;return{name:l.OPTIONS.name,params:u}})}}get"~standard"(){const e=this;return{version:1,vendor:"yup",async validate(r){try{return{value:await e.validate(r,{abortEarly:!1})}}catch(o){if(o instanceof hr)return{issues:X2(o)};throw o}}}}}ti.prototype.__isYupSchema__=!0;for(const t of["validate","validateSync"])ti.prototype[`${t}At`]=function(e,n,r={}){const{parent:o,parentPath:i,schema:s}=WQ(this,e,n,r.context);return s[t](o&&o[i],Object.assign({},r,{parent:o,path:e}))};for(const t of["equals","is"])ti.prototype[t]=ti.prototype.oneOf;for(const t of["not","nope"])ti.prototype[t]=ti.prototype.notOneOf;const qQ=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function KQ(t){const e=fv(t);if(!e)return Date.parse?Date.parse(t):Number.NaN;if(e.z===void 0&&e.plusMinus===void 0)return new Date(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond).valueOf();let n=0;return e.z!=="Z"&&e.plusMinus!==void 0&&(n=e.hourOffset*60+e.minuteOffset,e.plusMinus==="+"&&(n=0-n)),Date.UTC(e.year,e.month,e.day,e.hour,e.minute+n,e.second,e.millisecond)}function fv(t){var e,n;const r=qQ.exec(t);return r?{year:Ii(r[1]),month:Ii(r[2],1)-1,day:Ii(r[3],1),hour:Ii(r[4]),minute:Ii(r[5]),second:Ii(r[6]),millisecond:r[7]?Ii(r[7].substring(0,3)):0,precision:(e=(n=r[7])==null?void 0:n.length)!=null?e:void 0,z:r[8]||void 0,plusMinus:r[9]||void 0,hourOffset:Ii(r[10]),minuteOffset:Ii(r[11])}:null}function Ii(t,e=0){return Number(t)||e}let YQ=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,GQ=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,JQ=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,XQ="^\\d{4}-\\d{2}-\\d{2}",ZQ="\\d{2}:\\d{2}:\\d{2}",QQ="(([+-]\\d{2}(:?\\d{2})?)|Z)",eee=new RegExp(`${XQ}T${ZQ}(\\.\\d+)?${QQ}$`),tee=t=>ka(t)||t===t.trim(),nee={}.toString();function Ea(){return new Z2}class Z2 extends ti{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,n)=>{if(!this.spec.coerce||this.isType(e)||Array.isArray(e))return e;const r=e!=null&&e.toString?e.toString():e;return r===nee?e:r})})}required(e){return super.required(e).withMutation(n=>n.test({message:e||ei.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(n=>n.OPTIONS.name!=="required"),e))}length(e,n=kr.length){return this.test({message:n,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,n=kr.min){return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,n=kr.max){return this.test({name:"max",exclusive:!0,message:n,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,n){let r=!1,o,i;return n&&(typeof n=="object"?{excludeEmptyString:r=!1,message:o,name:i}=n:o=n),this.test({name:i||"matches",message:o||kr.matches,params:{regex:e},skipAbsent:!0,test:s=>s===""&&r||s.search(e)!==-1})}email(e=kr.email){return this.matches(YQ,{name:"email",message:e,excludeEmptyString:!0})}url(e=kr.url){return this.matches(GQ,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=kr.uuid){return this.matches(JQ,{name:"uuid",message:e,excludeEmptyString:!1})}datetime(e){let n="",r,o;return e&&(typeof e=="object"?{message:n="",allowOffset:r=!1,precision:o=void 0}=e:n=e),this.matches(eee,{name:"datetime",message:n||kr.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:n||kr.datetime_offset,params:{allowOffset:r},skipAbsent:!0,test:i=>{if(!i||r)return!0;const s=fv(i);return s?!!s.z:!1}}).test({name:"datetime_precision",message:n||kr.datetime_precision,params:{precision:o},skipAbsent:!0,test:i=>{if(!i||o==null)return!0;const s=fv(i);return s?s.precision===o:!1}})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=kr.trim){return this.transform(n=>n!=null?n.trim():n).test({message:e,name:"trim",test:tee})}lowercase(e=kr.lowercase){return this.transform(n=>ka(n)?n:n.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>ka(n)||n===n.toLowerCase()})}uppercase(e=kr.uppercase){return this.transform(n=>ka(n)?n:n.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>ka(n)||n===n.toUpperCase()})}}Ea.prototype=Z2.prototype;let Q2=new Date(""),ree=t=>Object.prototype.toString.call(t)==="[object Date]";function pv(){return new Lu}class Lu extends ti{constructor(){super({type:"date",check(e){return ree(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,n)=>!this.spec.coerce||this.isType(e)||e===null?e:(e=KQ(e),isNaN(e)?Lu.INVALID_DATE:new Date(e)))})}prepareParam(e,n){let r;if(Ta.isRef(e))r=e;else{let o=this.cast(e);if(!this._typeCheck(o))throw new TypeError(`\`${n}\` must be a Date or a value that can be \`cast()\` to a Date`);r=o}return r}min(e,n=uv.min){let r=this.prepareParam(e,"min");return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(o){return o>=this.resolve(r)}})}max(e,n=uv.max){let r=this.prepareParam(e,"max");return this.test({message:n,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(o){return o<=this.resolve(r)}})}}Lu.INVALID_DATE=Q2,pv.prototype=Lu.prototype,pv.INVALID_DATE=Q2;function oee(t,e=[]){let n=[],r=new Set,o=new Set(e.map(([s,a])=>`${s}-${a}`));function i(s,a){let l=Ca.split(s)[0];r.add(l),o.has(`${a}-${l}`)||n.push([a,l])}for(const s of Object.keys(t)){let a=t[s];r.add(s),Ta.isRef(a)&&a.isSibling?i(a.path,s):dv(a)&&"deps"in a&&a.deps.forEach(l=>i(l,s))}return PQ.array(Array.from(r),n).reverse()}function eI(t,e){let n=1/0;return t.some((r,o)=>{var i;if((i=e.path)!=null&&i.includes(r))return n=o,!0}),n}function tI(t){return(e,n)=>eI(t,e)-eI(t,n)}const iee=(t,e,n)=>{if(typeof t!="string")return t;let r=t;try{r=JSON.parse(t)}catch{}return n.isType(r)?r:t};function Eh(t){if("fields"in t){const e={};for(const[n,r]of Object.entries(t.fields))e[n]=Eh(r);return t.setFields(e)}if(t.type==="array"){const e=t.optional();return e.innerType&&(e.innerType=Eh(e.innerType)),e}return t.type==="tuple"?t.optional().clone({types:t.spec.types.map(Eh)}):"optional"in t?t.optional():t}const see=(t,e)=>{const n=[...Ca.normalizePath(e)];if(n.length===1)return n[0]in t;let r=n.pop(),o=Ca.getter(Ca.join(n),!0)(t);return!!(o&&r in o)};let nI=t=>Object.prototype.toString.call(t)==="[object Object]";function rI(t,e){let n=Object.keys(t.fields);return Object.keys(e).filter(r=>n.indexOf(r)===-1)}const aee=tI([]);function hv(t){return new oI(t)}class oI extends ti{constructor(e){super({type:"object",check(n){return nI(n)||typeof n=="function"}}),this.fields=Object.create(null),this._sortErrors=aee,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,n={}){var r;let o=super._cast(e,n);if(o===void 0)return this.getDefault(n);if(!this._typeCheck(o))return o;let i=this.fields,s=(r=n.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(o).filter(p=>!this._nodes.includes(p))),l={},u=Object.assign({},n,{parent:l,__validating:n.__validating||!1}),f=!1;for(const p of a){let m=i[p],g=p in o,v=o[p];if(m){let y;u.path=(n.path?`${n.path}.`:"")+p,m=m.resolve({value:v,context:n.context,parent:l});let x=m instanceof ti?m.spec:void 0,S=x==null?void 0:x.strict;if(x!=null&&x.strip){f=f||p in o;continue}y=!n.__validating||!S?m.cast(v,u):v,y!==void 0&&(l[p]=y)}else g&&!s&&(l[p]=v);(g!==p in l||l[p]!==v)&&(f=!0)}return f?l:o}_validate(e,n={},r,o){let{from:i=[],originalValue:s=e,recursive:a=this.spec.recursive}=n;n.from=[{schema:this,value:s},...i],n.__validating=!0,n.originalValue=s,super._validate(e,n,r,(l,u)=>{if(!a||!nI(u)){o(l,u);return}s=s||u;let f=[];for(let p of this._nodes){let m=this.fields[p];!m||Ta.isRef(m)||f.push(m.asNestedTest({options:n,key:p,parent:u,parentPath:n.path,originalParent:s}))}this.runTests({tests:f,value:u,originalValue:s,options:n},r,p=>{o(p.sort(this._sortErrors).concat(l),u)})})}clone(e){const n=super.clone(e);return n.fields=Object.assign({},this.fields),n._nodes=this._nodes,n._excludedEdges=this._excludedEdges,n._sortErrors=this._sortErrors,n}concat(e){let n=super.concat(e),r=n.fields;for(let[o,i]of Object.entries(this.fields)){const s=r[o];r[o]=s===void 0?i:s}return n.withMutation(o=>o.setFields(r,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let n={};return this._nodes.forEach(r=>{var o;const i=this.fields[r];let s=e;(o=s)!=null&&o.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[r]})),n[r]=i&&"getDefault"in i?i.getDefault(s):void 0}),n}setFields(e,n){let r=this.clone();return r.fields=e,r._nodes=oee(e,n),r._sortErrors=tI(Object.keys(e)),n&&(r._excludedEdges=n),r}shape(e,n=[]){return this.clone().withMutation(r=>{let o=r._excludedEdges;return n.length&&(Array.isArray(n[0])||(n=[n]),o=[...r._excludedEdges,...n]),r.setFields(Object.assign(r.fields,e),o)})}partial(){const e={};for(const[n,r]of Object.entries(this.fields))e[n]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return Eh(this)}pick(e){const n={};for(const r of e)this.fields[r]&&(n[r]=this.fields[r]);return this.setFields(n,this._excludedEdges.filter(([r,o])=>e.includes(r)&&e.includes(o)))}omit(e){const n=[];for(const r of Object.keys(this.fields))e.includes(r)||n.push(r);return this.pick(n)}from(e,n,r){let o=Ca.getter(e,!0);return this.transform(i=>{if(!i)return i;let s=i;return see(i,e)&&(s=Object.assign({},i),r||delete s[e],s[n]=o(i)),s})}json(){return this.transform(iee)}exact(e){return this.test({name:"exact",exclusive:!0,message:e||Sh.exact,test(n){if(n==null)return!0;const r=rI(this.schema,n);return r.length===0||this.createError({params:{properties:r.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(e=!0,n=Sh.noUnknown){typeof e!="boolean"&&(n=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:n,test(o){if(o==null)return!0;const i=rI(this.schema,o);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,n=Sh.noUnknown){return this.noUnknown(!e,n)}transformKeys(e){return this.transform(n=>{if(!n)return n;const r={};for(const o of Object.keys(n))r[e(o)]=n[o];return r})}camelCase(){return this.transformKeys(cv.camelCase)}snakeCase(){return this.transformKeys(cv.snakeCase)}constantCase(){return this.transformKeys(e=>cv.snakeCase(e).toUpperCase())}describe(e){const n=(e?this.resolve(e):this).clone(),r=super.describe(e);r.fields={};for(const[i,s]of Object.entries(n.fields)){var o;let a=e;(o=a)!=null&&o.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[i]})),r.fields[i]=s.describe(a)}return r}}hv.prototype=oI.prototype;const lee=t=>{const{title:e,onSave:n,onCancel:r,onClose:o,modifyCitation:i,readOnly:s=!1,showCloseBtn:a=!1}=t,l=Z.useRef(null),[u,f]=Z.useState(!1),[p,m]=Z.useState(!1),[g,v]=Z.useState({type:"Url",source:"",title:"",accessedAt:null,url:"",classification:""});return Z.useEffect(()=>{i&&v({...i,type:"Url"})},[]),b.jsxs(b.Fragment,{children:[b.jsxs(V.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[b.jsx(V.Typography,{variant:"h6",margin:"10px 0",children:e}),a&&b.jsx(V.IconButton,{onClick:o,children:b.jsx(up,{})})]}),b.jsx(jt.Formik,{innerRef:l,enableReinitialize:!0,initialValues:g,onSubmit:async y=>{f(!0),n(y).catch(x=>{throw f(!1),x}).finally(()=>f(!1))},validationSchema:hv({source:Ea().required("Source is required"),title:Ea().required("Title is required"),accessedAt:pv().required("Accessed At is required"),url:Ea().required("URL is required"),classification:Ea().required("Classification is required")}),validateOnBlur:p,validateOnChange:p,children:({handleSubmit:y})=>b.jsxs(jt.Form,{autoComplete:"off",children:[b.jsxs(V.Box,{display:"flex",flexDirection:"column",gap:s?1:0,children:[b.jsx(gs,{name:"source",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(gs,{name:"title",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(Hp,{name:"accessedAt",disabled:u,required:!0,margin:"none",isDatePicker:!0,readOnly:s}),b.jsx(gs,{name:"url",label:"URL",disabled:u,required:!0,margin:"none",readOnly:s}),b.jsx(AM,{row:!0,name:"classification",required:!0,radios:[{label:"Public Source",value:"Public Source",helperText:"URL is accessible to anyone from any location without special permissions. You can safely access this URL on any computer, including public or shared devices."},{label:"Proprietary Source",value:"Proprietary Source",helperText:"For private, sensitive, or access-controlled content. Use a VPN, or take extra precautions, when accessing to protect your privacy."}],margin:"none",readOnly:s})]}),b.jsx(V.DialogActions,{sx:{px:0},children:s?b.jsx(V.Button,{onClick:r,size:"small",variant:"contained",children:"Back to Table"}):b.jsxs(b.Fragment,{children:[b.jsx(V.Button,{onClick:r,variant:"outlined",size:"small",children:"Cancel"}),b.jsx(sv,{size:"small",loading:u,type:"button",onClick:()=>{m(!0),y()},children:i?"Update Citation":"Add New Citation"})]})})]})})]})},iI=t=>{const{gap:e=1,alignItems:n="center",...r}=t;return b.jsx(V.Box,{display:"flex",flexDirection:"row",gap:e,alignItems:n,...r})},cee=t=>{const{title:e,onSave:n,onCancel:r,onClose:o,disableFileUpload:i=!1,modifyCitation:s,readOnly:a=!1,showCloseBtn:l=!1}=t,u=Z.useRef(null),[f,p]=Z.useState(!1),[m,g]=Z.useState(!1),[v,y]=Z.useState({type:"Attachment",title:"",file:void 0,fileName:""});return Z.useEffect(()=>{s&&y({...s,type:"Attachment",file:void 0})},[]),b.jsxs(b.Fragment,{children:[b.jsxs(V.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[b.jsx(V.Typography,{variant:"h6",margin:"10px 0",children:e}),l&&b.jsx(V.IconButton,{onClick:o,children:b.jsx(up,{})})]}),b.jsx(jt.Formik,{innerRef:u,enableReinitialize:!0,initialValues:v,validationSchema:hv().shape({title:Ea().required("Title is required"),fileName:Ea().required("A file is required")}),validateOnBlur:m,validateOnChange:m,onSubmit:async x=>{p(!0),n(x).catch(S=>{throw p(!1),S}).finally(()=>p(!1))},children:({values:x,setFieldValue:S,handleSubmit:k})=>{var T;return Z.useEffect(()=>{var C,O;(C=x.file)!=null&&C.name&&S("fileName",(O=x.file)==null?void 0:O.name)},[(T=x.file)==null?void 0:T.name]),b.jsxs(jt.Form,{autoComplete:"off",children:[b.jsx(gs,{name:"title",disabled:f,required:!0,margin:"none",readOnly:a}),b.jsxs(V.Box,{marginTop:i||a?0:1,children:[b.jsxs(iI,{alignItems:"flex-start",children:[!i&&!a&&b.jsx(fM,{name:"file",errorMode:"hidden"}),b.jsx(gs,{readOnly:!0,name:"fileName",label:a||i?"File Name":""})]}),b.jsx(br,{name:"fileName"})]}),b.jsx(V.DialogActions,{sx:{px:0},children:a?b.jsx(V.Button,{onClick:r,size:"small",variant:"contained",children:"Back to Table"}):b.jsxs(b.Fragment,{children:[b.jsx(V.Button,{onClick:r,variant:"outlined",size:"small",children:"Cancel"}),b.jsx(sv,{size:"small",loading:f,type:"button",onClick:()=>{g(!0),k()},children:s?"Update Attachment":"Upload Attachment"})]})})]})}})]})},Bu=t=>{const{open:e=!1,onClose:n,title:r,children:o,actions:i,closeBtnLabel:s,closeButtonPosition:a,closeButtonProps:l={},disableDismiss:u=!1,...f}=t;if(!e)return null;const p=a==="bottom"||a==="top-and-bottom",m=a==="top"||a==="top-and-bottom",g=()=>{if(s&&p)return b.jsx(V.Button,{className:"MBv2_Modal_Close",onClick:t.onClose,...l,children:s})},v=()=>{if(i)return b.jsx(V.DialogActions,{className:"MBv2_Modal_Actions",children:b.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",gap:"0.25rem",children:[b.jsx(V.Box,{children:g()}),b.jsxs(V.Box,{display:"flex",gap:".25rem",children:[...i]})]})});if(s&&p)return b.jsx(V.DialogActions,{className:"MBv2_Modal_Actions",children:b.jsx(V.Box,{children:g()})})};return b.jsxs(V.Dialog,{className:"MBv2_Modal",open:e,onClose:()=>{u||n==null||n()},...f,children:[typeof r=="string"?b.jsx(V.DialogTitle,{className:"MBv2_Modal_Title",children:b.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[r,m&&b.jsx(V.IconButton,{"data-testid":"modal-header-close-btn",onClick:n,children:b.jsx(up,{})})]})}):r,o&&(typeof o=="string"?b.jsx(V.DialogContent,{className:"MBv2_Modal_Content",children:b.jsx(V.DialogContentText,{className:"MBv2_Modal_Content_Text",children:o})}):o),v()]})};function uee(t){return Ue("MuiAlert",t)}const sI=He("MuiAlert",["root","action","icon","message","filled","colorSuccess","colorInfo","colorWarning","colorError","filledSuccess","filledInfo","filledWarning","filledError","outlined","outlinedSuccess","outlinedInfo","outlinedWarning","outlinedError","standard","standardSuccess","standardInfo","standardWarning","standardError"]),dee=Pe(b.jsx("path",{d:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"}),"SuccessOutlined"),fee=Pe(b.jsx("path",{d:"M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),pee=Pe(b.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutline"),hee=Pe(b.jsx("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"}),"InfoOutlined"),mee=Pe(b.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close"),gee=t=>{const{variant:e,color:n,severity:r,classes:o}=t,i={root:["root",`color${Ie(n||r)}`,`${e}${Ie(n||r)}`,`${e}`],icon:["icon"],message:["message"],action:["action"]};return je(i,uee,o)},yee=ne(us,{name:"MuiAlert",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.variant],e[`${n.variant}${Ie(n.color||n.severity)}`]]}})(gt(({theme:t})=>{const e=t.palette.mode==="light"?Rs:Va,n=t.palette.mode==="light"?Va:Rs;return{...t.typography.body2,backgroundColor:"transparent",display:"flex",padding:"6px 16px",variants:[...Object.entries(t.palette).filter(Hn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"standard"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),backgroundColor:t.vars?t.vars.palette.Alert[`${r}StandardBg`]:n(t.palette[r].light,.9),[`& .${sI.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Hn(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"outlined"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),border:`1px solid ${(t.vars||t).palette[r].light}`,[`& .${sI.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Hn(["dark"])).map(([r])=>({props:{colorSeverity:r,variant:"filled"},style:{fontWeight:t.typography.fontWeightMedium,...t.vars?{color:t.vars.palette.Alert[`${r}FilledColor`],backgroundColor:t.vars.palette.Alert[`${r}FilledBg`]}:{backgroundColor:t.palette.mode==="dark"?t.palette[r].dark:t.palette[r].main,color:t.palette.getContrastText(t.palette[r].main)}}}))]}})),bee=ne("div",{name:"MuiAlert",slot:"Icon",overridesResolver:(t,e)=>e.icon})({marginRight:12,padding:"7px 0",display:"flex",fontSize:22,opacity:.9}),vee=ne("div",{name:"MuiAlert",slot:"Message",overridesResolver:(t,e)=>e.message})({padding:"8px 0",minWidth:0,overflow:"auto"}),xee=ne("div",{name:"MuiAlert",slot:"Action",overridesResolver:(t,e)=>e.action})({display:"flex",alignItems:"flex-start",padding:"4px 0 0 16px",marginLeft:"auto",marginRight:-8}),aI={success:b.jsx(dee,{fontSize:"inherit"}),warning:b.jsx(fee,{fontSize:"inherit"}),error:b.jsx(pee,{fontSize:"inherit"}),info:b.jsx(hee,{fontSize:"inherit"})},lI=D.forwardRef(function(e,n){const r=ht({props:e,name:"MuiAlert"}),{action:o,children:i,className:s,closeText:a="Close",color:l,components:u={},componentsProps:f={},icon:p,iconMapping:m=aI,onClose:g,role:v="alert",severity:y="success",slotProps:x={},slots:S={},variant:k="standard",...T}=r,C={...r,color:l,severity:y,variant:k,colorSeverity:l||y},O=gee(C),I={slots:{closeButton:u.CloseButton,closeIcon:u.CloseIcon,...S},slotProps:{...f,...x}},[N,$]=Ot("root",{ref:n,shouldForwardComponentProp:!0,className:ge(O.root,s),elementType:yee,externalForwardedProps:{...I,...T},ownerState:C,additionalProps:{role:v,elevation:0}}),[H,M]=Ot("icon",{className:O.icon,elementType:bee,externalForwardedProps:I,ownerState:C}),[F,z]=Ot("message",{className:O.message,elementType:vee,externalForwardedProps:I,ownerState:C}),[B,P]=Ot("action",{className:O.action,elementType:xee,externalForwardedProps:I,ownerState:C}),[_,A]=Ot("closeButton",{elementType:_l,externalForwardedProps:I,ownerState:C}),[R,j]=Ot("closeIcon",{elementType:mee,externalForwardedProps:I,ownerState:C});return b.jsxs(N,{...$,children:[p!==!1?b.jsx(H,{...M,children:p||m[y]||aI[y]}):null,b.jsx(F,{...z,children:i}),o!=null?b.jsx(B,{...P,children:o}):null,o==null&&g?b.jsx(B,{...P,children:b.jsx(_,{size:"small","aria-label":a,title:a,color:"inherit",onClick:g,...A,children:b.jsx(R,{fontSize:"small",...j})})}):null]})});process.env.NODE_ENV!=="production"&&(lI.propTypes={action:c.node,children:c.node,classes:c.object,className:c.string,closeText:c.string,color:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),components:c.shape({CloseButton:c.elementType,CloseIcon:c.elementType}),componentsProps:c.shape({closeButton:c.object,closeIcon:c.object}),icon:c.node,iconMapping:c.shape({error:c.node,info:c.node,success:c.node,warning:c.node}),onClose:c.func,role:c.string,severity:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),slotProps:c.shape({action:c.oneOfType([c.func,c.object]),closeButton:c.oneOfType([c.func,c.object]),closeIcon:c.oneOfType([c.func,c.object]),icon:c.oneOfType([c.func,c.object]),message:c.oneOfType([c.func,c.object]),root:c.oneOfType([c.func,c.object])}),slots:c.shape({action:c.elementType,closeButton:c.elementType,closeIcon:c.elementType,icon:c.elementType,message:c.elementType,root:c.elementType}),sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),variant:c.oneOfType([c.oneOf(["filled","outlined","standard"]),c.string])});const Fu=t=>{var g;const{noIcon:e=!1,children:n,severity:r="success",variant:o="leftBorder",sx:i,title:s,...a}=t,{palette:l}=V.useTheme(),u=e?{icon:!1}:{},f=o==="leftBorder"?"standard":o,p=o==="leftBorder"?{...i,borderLeft:`4px solid ${(g=l[r])==null?void 0:g.main}`}:i,m=s?{icon:{sx:{mt:"6px"}}}:{};return b.jsxs(lI,{severity:r,variant:f,sx:p,slotProps:m,...u,...a,children:[s&&b.jsx(V.Typography,{variant:"h3",children:s}),n]})},cI=t=>b.jsx(Fu,{severity:"error",...t}),uI=t=>b.jsx(Fu,{severity:"success",...t}),wee=t=>{const{alert:e,setAlert:n}=t,r=()=>n(void 0);return b.jsxs(b.Fragment,{children:[(e==null?void 0:e.type)==="Error"&&b.jsx(cI,{"data-testid":"citation-menu-error",onClose:r,title:e.title,children:e.message.toString()}),(e==null?void 0:e.type)==="Success"&&b.jsx(uI,{"data-testid":"citation-menu-success",onClose:r,children:e.message})]})};function dI({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,onSelectCitations:a,onCancel:l,initialSelectedIds:u=[],onContentChange:f,onError:p=()=>{},renderAsSelectablePopup:m=!1,addlActions:g,canLaunchUrl:v,readOnly:y}){const[x,S]=Z.useState("Insert Citation/Attachment(s)"),[k,T]=Z.useState(u),[C,O]=Z.useState(void 0),[I,N]=Z.useState(void 0),$=G=>{N(void 0),S(G)},[H,M]=Z.useState(0);Z.useEffect(()=>{f==null||f()},[x,I,f]);const F=(G=!1)=>{(!m||G)&&M(te=>te+1)},z=(G,te)=>{var de;const ue=typeof((de=te.response)==null?void 0:de.data)=="string"&&te.response.data,re=typeof te.message=="string"&&te.message;N({type:"Error",title:G,message:ue??re}),p(te)},B=G=>N({type:"Success",title:"",message:G}),P=async G=>{if(x==="Insert Citation/Attachment(s)")throw Error("onSave called with invalid state");if(x==="Edit Citation"||x==="Edit Attachment"){if(G.id===void 0)throw Error("Failed to update citation. Citation is missing id");await(n==null?void 0:n(G).then(()=>{$("Insert Citation/Attachment(s)"),F()}).catch(ue=>{z("Failed to update",ue)}))}else await(e==null?void 0:e(G).then(ue=>{T([...k,ue.id]),$("Insert Citation/Attachment(s)"),F()}).catch(ue=>{z("Failed to create",ue)}))},_=r&&(async G=>r(G).then(()=>{F(!0),T(k.filter(te=>te!==G)),B("Successfully deleted")}).catch(te=>z("Failed to delete",te))),A=(G,te)=>{o(G.id).then(ue=>{O(ue),$(te)}).catch(ue=>{z("Failed to load",ue)})},R=i&&(async G=>i(G).catch(te=>{z(`Failed to download ${G.fileName}`,te)})),j=s&&(async G=>s(G).catch(te=>{z(`Failed to view ${G.fileName}`,te)})),K=b.jsx(MQ,{refreshKey:H,getCitationsPaginated:G=>t(G).then(te=>(f==null||f(),te)),onCancel:l,onNewCitation:()=>{O(void 0),$("Add Citation")},onNewAttachment:()=>{O(void 0),$("Add Attachment")},onEditCitation:G=>A(G,y?"View Citation":"Edit Citation"),onEditAttachment:G=>A(G,y?"View Attachment":"Edit Attachment"),onDeleteCitation:_,onDownloadAttachment:R,onViewAttachment:j,onSelect:a,setSelectedIds:T,selectedIds:k,onError:p,condenseTable:m,canSelect:m,title:m&&!y?x:"Attachments & Citations",addlActions:g,canCreate:!!e,canEdit:!!n,canDelete:!!_,canLaunchUrl:v,readOnly:y,showCloseBtn:m}),U=b.jsx(lee,{modifyCitation:C,onSave:P,onCancel:()=>$("Insert Citation/Attachment(s)"),onClose:l,title:x,readOnly:x==="View Citation",showCloseBtn:m}),Y=b.jsx(cee,{onSave:P,onCancel:()=>$("Insert Citation/Attachment(s)"),onClose:l,modifyCitation:C,disableFileUpload:x==="Edit Attachment",title:x,readOnly:x==="View Attachment",showCloseBtn:m}),oe=b.jsx(wee,{alert:I,setAlert:N}),fe=x==="Add Citation"||x==="Edit Citation"||x==="View Citation",me=x==="Add Attachment"||x==="Edit Attachment"||x==="View Attachment";if(m){let G=null;return!m||x==="Insert Citation/Attachment(s)"?G=K:fe?G=U:me&&(G=Y),b.jsxs(V.Box,{width:"500px",children:[oe,b.jsx(V.Box,{paddingTop:"8px",children:G})]})}return b.jsxs(V.Box,{width:"100%",children:[x==="Insert Citation/Attachment(s)"&&oe,b.jsx(V.Box,{paddingTop:"8px",children:K}),b.jsx(Bu,{open:fe||me,children:b.jsxs(V.Box,{padding:"10px 20px",minWidth:"400px","data-testid":"citation-form-modal",children:[oe,fe?U:Y]})})]})}function fI({...t}){return b.jsx(dI,{renderAsSelectablePopup:!0,...t})}const See=V.styled("div",{name:"CitationBubbleMenu",slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>{const e=t.palette.mode==="dark";return{padding:t.spacing(1.5,2,.5),backgroundColor:e?"#101010":"#f9f9f9",border:`1px solid ${t.palette.grey[e?700:200]}`}});function Cee({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,canLaunchUrl:a,readOnly:l,...u}){const f=wt();if(f&&!("citationBubbleMenuHandler"in(f==null?void 0:f.storage)))throw new Error("You must add the CitationBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const p=f==null?void 0:f.storage.citationBubbleMenuHandler,m=p.isOpen,g=p.selectedIds,v=p.selectedNodePos,y=T=>{f&&(T.length===0?f.commands.deleteCitation(v):g.length===0?f.commands.insertCitation({ids:T}):f.commands.updateCitation({ids:T},v))},x=T=>{y(T),f==null||f.commands.closeCitationBubbleMenu()},S=()=>{y(g),f==null||f.commands.closeCitationBubbleMenu()},k=Z.useCallback(()=>{requestAnimationFrame(()=>{f!=null&&f.view&&f.view.dispatch(f.view.state.tr)})},[f]);return f?b.jsx(by,{editor:f,open:m,...p.bubbleMenuOptions,...u,children:b.jsx(See,{children:b.jsx(fI,{getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onViewAttachment:s,onSelectCitations:x,onCancel:S,initialSelectedIds:g,onContentChange:k,canLaunchUrl:a,readOnly:l})})}):null}const Tee=()=>ln.create({name:"citationBubbleMenuHandler",addStorage(){return{isOpen:!1,selectedIds:[],bubbleMenuOptions:void 0,selectedNodePos:0}},addCommands(){return{openCitationBubbleMenu:(t={},e)=>({editor:n,dispatch:r})=>{var a;const{doc:o}=n.state,i=o.nodeAt(e??0),s=((a=i==null?void 0:i.attrs)==null?void 0:a.ids)??[];return r&&(this.storage.isOpen=!0,this.storage.selectedIds=s,this.storage.bubbleMenuOptions=t,this.storage.selectedNodePos=e??0),!0},closeCitationBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.isOpen?(t.focus(),e&&(this.storage.isOpen=!1,this.storage.selectedIds=[],this.storage.selectedNodePos=0),!0):!1}},onSelectionUpdate(){this.storage.isOpen&&!this.editor.isActive("citation")&&this.editor.commands.closeCitationBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-c":()=>(this.editor.commands.openCitationBubbleMenu(),!0)}}});function kee(t){const e=wt(),n=Z.useRef(null);return b.jsx(St,{buttonRef:n,tooltipLabel:"Insert Citation/Attachment",tooltipShortcutKeys:["mod","Shift","C"],disabled:!(e!=null&&e.isEditable),onClick:()=>e==null?void 0:e.commands.openCitationBubbleMenu({anchorEl:n.current,placement:"bottom"}),...t,children:b.jsxs(V.Box,{display:"flex",flexDirection:"row",gap:"4px",alignItems:"center",children:[b.jsx(LU,{fontSize:"small"}),b.jsx(V.Typography,{variant:"body2",children:"Insert Citation/Attachment"})]})})}const pI=Z.createContext(void 0),hI=()=>{const t=Z.useContext(pI);if(!t)throw new Error("useSync must be used inside CitationFieldProvider");return t},Eee=({node:t,HTMLAttributes:e,selected:n,extension:r,updateAttributes:o,deleteNode:i})=>{const s=t.attrs.ids||[],{citations:a,isLoaded:l}=hI(),[u,f]=Z.useState(s?String(s):""),[p,m]=Z.useState([]),g=r.options.citationMaxLength;if(Z.useEffect(()=>{if(!l)return;const v=a.filter(S=>s.includes(S.id)),y=v.map(S=>ma.truncate(S.title,{length:g,omission:"..."})).join(", ");f(y),m(v);const x=v.map(S=>S.id);x.length===0?setTimeout(i,0):x.length!==s.length&&setTimeout(()=>o({ids:v.map(S=>S.id)}),0)},[a,s,l]),p.length!==0)return b.jsx(Eb,{as:"span",...e,"data-testid":"citation-node-component",children:b.jsx(V.Tooltip,{title:b.jsx(V.Box,{className:"citation-tooltip",children:p.map((v,y)=>{var S;const x=[v.source,v.title,v.fileName,v.url,(S=v.accessedAt)==null?void 0:S.slice(0,10),v.classification];return b.jsxs(V.Typography,{variant:"subtitle2",children:[x.filter(Boolean).join(" | "),y<p.length-1&&b.jsx(V.Divider,{className:"citation-tooltip-divider"})]},v.id)})}),slotProps:{tooltip:{sx:{maxWidth:500}}},children:b.jsx("a",{href:"#",onClick:v=>{v.preventDefault(),v.stopPropagation()},className:n?"selected-citation-link":"citation-link",children:u})})})},Oee=tn.create({name:"citation",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes(){return{ids:{default:[],parseHTML:t=>{const e=t.getAttribute("ids");return e?e.split(",").map(n=>parseInt(n.trim(),10)).filter(n=>!isNaN(n)):[]},renderHTML:t=>({ids:Array.isArray(t.ids)?t.ids.join(","):""})}}},parseHTML(){return[{tag:"citation"}]},renderHTML({HTMLAttributes:t}){return["citation",xt(t)]},addNodeView(){return Ob(Eee)},addProseMirrorPlugins(){return[new en({props:{handleClickOn:(t,e,n,r,o,i)=>n&&n.type.name==="citation"?(this.editor.commands.openCitationBubbleMenu({},r),!0):!1}})]},addCommands(){return{insertCitation:t=>({commands:e})=>e.insertContent({type:"citation",attrs:t}),updateCitation:(t,e)=>({state:n,dispatch:r,tr:o})=>{const i=n.doc.nodeAt(e);return!i||i.type.name!=="citation"?!1:(o.setNodeMarkup(e,void 0,t),r&&r(o),!0)},deleteCitation:t=>({tr:e,dispatch:n})=>{if(typeof t!="number")return!1;const r=t,o=t+1;return n&&n(e.delete(r,o)),!0}}}}),mI=t=>b.jsx(uM,{name:t.name,label:"Not Applicable",errorMode:"hidden"}),Mee=t=>{const{name:e,label:n=Ln(e),hideLabel:r=!1,required:o=!1,readOnly:i,margin:s="dense",citationMaxLength:a=24,getCitationsPaginated:l,onCreateCitation:u,onUpdateCitation:f,onDeleteCitation:p,getCitationById:m,onDownloadAttachment:g,onViewAttachment:v,onError:y=()=>{},placeholder:x="Start typing here...",notApplicableName:S,errorMode:k="normal",canLaunchUrl:T}=t,C=[PT,A2.configure({placeholder:x}),Tee(),Oee.configure({citationMaxLength:a})],[O,I,N]=jt.useField({name:e}),{setValue:$}=N,{value:H}=O,{addUpdateCitation:M,deleteCitation:F,batchUpdate:z,citations:B}=hI();Z.useEffect(()=>{var me;const oe=(me=P==null?void 0:P.current)==null?void 0:me.editor;if(!oe)return;oe.getHTML()!==H&&setTimeout(()=>{oe.commands.setContent(H)},0)},[H]);const P=Z.useRef(null),_={normal:{marginTop:"16px",marginBottom:"8px"},dense:{marginTop:"8px",marginBottom:"4px"},none:{margin:0}},A=(oe=void 0)=>{var G,te;const fe=((te=(G=P.current)==null?void 0:G.editor)==null?void 0:te.getHTML())??"",me=!fe.replace(/<\/?p>|<br>/g,"").trim();$(me?"":fe,oe)},R=Z.useMemo(()=>ma.debounce(()=>A(!1),500),[$]),j=zs(),{showDiff:K,getPreviousValue:U}=Vs(),Y=i??j;if(K){const oe=U(e)??"",fe=H,me=/<citation\s+ids="([^"]*)"><\/citation>/g,G=(re,ie)=>{const de=ie.split(",").map(Number);return`<sup>${B.filter(ye=>de.includes(ye.id)).map(ye=>ye.title)}</sup>`},te=oe.replace(me,G),ue=fe.replace(me,G);return b.jsx(ha,{label:n,value:ue,showDiff:!0,diffSnapshot:te,mode:"html"})}return b.jsxs(V.Box,{id:`citation-field_${e}`,sx:{"& .ProseMirror":{"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:Y?0:50}},".MuiTiptap-RichTextContent-readonly ":{padding:0}},..._[s],display:"flex",flexDirection:"column",width:"100%",children:[b.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[!r&&b.jsx(V.InputLabel,{htmlFor:`citation-field_${e}`,required:o,children:n}),S&&b.jsx(mI,{name:S})]}),b.jsx(eM,{ref:P,extensions:C,content:H,editable:!Y,renderControls:Y?void 0:()=>b.jsx(ob,{children:b.jsx(kee,{})}),onBlur:()=>A(),onUpdate:R,RichTextFieldProps:{variant:Y?"standard":"outlined",MenuBarProps:{hide:Y}},children:()=>b.jsx(Cee,{getCitationsPaginated:oe=>l(oe).then(fe=>(z(fe.data),fe)),onCreateCitation:u&&(oe=>u(oe).then(fe=>(M(fe),fe))),onUpdateCitation:f&&(oe=>f(oe).then(fe=>(M(fe),fe))),onDeleteCitation:p&&(oe=>p(oe).then(()=>F(oe))),getCitationById:m,onDownloadAttachment:g,onViewAttachment:v,onError:y,canLaunchUrl:T,readOnly:Y})}),b.jsx(br,{name:e,id:`${e}-err`,errorMode:k})]})},_ee=t=>{const{name:e="submit"}=t;return b.jsx(co,{name:e,type:"submit",...t})},Iee=t=>{const{label:e="Return to Top",icon:n=dp,scrollThresholdPx:r=100}=t,o=V.useScrollTrigger({threshold:r}),i=Z.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"})},[]);return b.jsx(V.Zoom,{in:o,children:b.jsx(V.Box,{sx:{position:"fixed",bottom:32,right:32,zIndex:1},children:b.jsxs(V.Fab,{onClick:i,color:"primary",size:"small",variant:"extended","aria-label":"Scroll back to top",children:[b.jsx(n,{fontSize:"medium"}),e]})})})},gI=t=>{const{label:e,menuOptions:n=[],icon:r}=t,o=vo.useNavigate(),[i,s]=D.useState(null),a=!!i,l=p=>{s(p.currentTarget)},u=()=>{s(null)};if(n.length===0)return null;const f=r&&!e;return b.jsxs(b.Fragment,{children:[b.jsx(V.Button,{startIcon:f?void 0:r,variant:"outlined",color:"inherit",sx:{minWidth:0,...f&&{paddingLeft:"6px",paddingRight:"6px"}},onClick:l,children:f?r:e}),b.jsx(V.Menu,{anchorEl:i,open:a,onClick:u,children:n.map(p=>b.jsxs(V.MenuItem,{...Zl(p,o),children:[p.icon&&b.jsx(V.ListItemIcon,{children:p.icon}),b.jsx(V.ListItemText,{primary:p.label})]},p.label))})]})},Aee=()=>{const{values:t,errors:e,status:n}=jt.useFormikContext(),{palette:r}=V.useTheme();return b.jsx(V.Paper,{style:{backgroundColor:r.mode==="dark"?"#303030":"#f0f0f0",margin:"10px 0"},children:b.jsxs(V.List,{children:[b.jsxs(V.ListItem,{children:[b.jsx(V.Typography,{display:"block",variant:"h6",children:"Values"}),b.jsx("br",{}),b.jsx(V.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(t,null,2)})]}),b.jsx(V.Divider,{variant:"inset",component:"li"}),b.jsxs(V.ListItem,{id:"testing",children:[b.jsx(V.Typography,{display:"block",variant:"h6",children:"Errors"}),b.jsx("br",{}),b.jsx(V.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(e,null,2)})]}),b.jsxs(V.ListItem,{children:[b.jsx(V.Typography,{display:"block",variant:"h6",children:"Status"}),b.jsx("br",{}),b.jsx(V.Divider,{variant:"inset"}),b.jsx("pre",{children:JSON.stringify(n,null,2)})]})]})})},Dee=t=>{const{steps:e,orientation:n,inlineLabel:r=n=="vertical",isResponsive:o=!1}=t,{width:i}=F2();let s=!r,a=n;o&&(n&&console.warn("Stepper: Ignoring orientation. isResponsive is set to true, so the orientation is determined automatically based on the window size."),a=i<600?"vertical":"horizontal",a=="vertical"?s=!1:s=!r),n=="vertical"&&!r&&(console.warn("Stepper: ignoring inlineLabel={false}. Must use inline labels when orientation is vertical"),s=!1);const l=["steps","inlineLabel","orientation","isResponsive"],u={alternativeLabel:s,orientation:a,...cr({...t},l)};return b.jsx(V.Stepper,{...u,children:e.map(f=>b.jsx(V.Step,{children:b.jsx(V.StepLabel,{children:f})},f))})},Pee=t=>{const{name:e,label:n=Ln(e),labelProps:r={fontSize:"1.1em",color:"#808080",fontWeight:"600"},initialState:o,renderFormGroup:i,addButtonContent:s="Add Another",removeButtonContent:a=t.removePosition==="right"?b.jsx($M,{}):"Remove",variant:l="card",addButtonSx:u,removeButtonSx:f,allowRemoveAll:p=!1,readOnly:m=!1,emptyListMsg:g="None",showDivider:v=!1,removePosition:y="bottom"}=t,[x]=jt.useField({name:e}),{value:S}=x,k=T=>({display:"flex",flexDirection:T==="bottom"?"column":"row",alignItems:T==="bottom"?"flex-start":"center"});return b.jsxs(V.FormControl,{fullWidth:!0,children:[b.jsx(V.Typography,{...r,children:n}),m&&x.value.length===0?b.jsx(V.Typography,{children:g}):b.jsx(jt.FieldArray,{name:e,render:T=>b.jsxs("div",{children:[S.map((C,O)=>b.jsx(Z.Fragment,{children:b.jsx(Nee,{variant:l,content:b.jsxs(V.Box,{"data-testid":"form-group-container",sx:typeof y=="string"?k(y):{...y},children:[b.jsxs(V.Box,{width:"100%",children:[i(`${e}.${O}`,O),v&&O!==S.length-1&&b.jsx(V.Divider,{"data-testid":"divider"})]}),!m&&S.length>(p?0:1)&&b.jsx(V.Button,{"data-testid":"repeatable-form-group_remove-btn",sx:f,onClick:()=>T.remove(O),children:a})]})})},`${e}-${O}`)),!m&&b.jsx(V.Button,{"data-testid":"repeatable-form-group_add-btn",onClick:()=>T.push(o),sx:u,children:s})]})})]})},Nee=({variant:t,content:e})=>{switch(t){case"card":return b.jsx(V.Card,{"data-testid":"repeatable-form-group_card",sx:{padding:"8px",marginBottom:"8px"},children:b.jsx(V.CardContent,{children:e})});case"elevatedCard":return b.jsx(V.Card,{"data-testid":"repeatable-form-group_elevated-card",elevation:4,sx:{border:"unset",padding:"8px",marginBottom:"8px"},children:b.jsx(V.CardContent,{children:e})});case"none":return e}},$ee=t=>{const{confirmBtnLabel:e,onConfirm:n,confirmButtonProps:r={color:"primary",variant:"contained"},closeBtnLabel:o="Cancel",closeButtonPosition:i="bottom",...s}=t;return b.jsx(Bu,{actions:[b.jsx(V.Button,{className:"MBv2_ConfirmationModal_ConfirmBtn",onClick:n,...r,children:e})],closeBtnLabel:o,closeButtonPosition:i,...s})},Lee=t=>{const{closeBtnLabel:e="OK",closeButtonPosition:n="bottom",closeButtonProps:r={color:"primary",variant:"contained"},...o}=t;return b.jsx(Bu,{closeBtnLabel:e,closeButtonPosition:n,closeButtonProps:r,...o})},Bee=t=>{const{primaryBtnLabel:e,onPrimaryAction:n,primaryActionProps:r={color:"primary",variant:"contained"},secondaryBtnLabel:o,onSecondaryAction:i,secondaryActionProps:s={color:"primary",variant:"outlined"},closeBtnLabel:a="Cancel",closeButtonPosition:l="bottom",...u}=t;return b.jsx(Bu,{actions:[b.jsx(V.Button,{className:"MBv2_DecisionModal_SecondaryAction",onClick:i,...s,children:o}),b.jsx(V.Button,{className:"MBv2_DecisionModal_PrimaryAction",onClick:n,...r,children:e})],closeBtnLabel:a,closeButtonPosition:l,...u})},Fee={added:{icon:NU,label:"Added",color:"success"},deleted:{icon:$M,label:"Deleted",color:"error"},modified:{icon:BU,label:"Modified",color:"info"}},yI=t=>{const{beforeData:e,afterData:n,emptyTableMsg:r="No changes to display",columns:o,isEqual:i,size:s}=t;t.renderExpand!=null&&t.isEqual==null&&console.warn("DiffTable: isEqual prop should be provided when renderExpand is provided");const a=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),{dataDiff:l,unmodifiedCount:u}=Z.useMemo(()=>Vee(o,e,n,a,i),[e,n,o,a,i]),f=o.map(p=>({...p,render:(m,g)=>{var v;return((v=g.modifiedDiff)==null?void 0:v[xn(p)])??$u(p,g,a)}}));return b.jsxs(V.Box,{children:[b.jsx(iv,{columns:[{fieldName:"changeType",render:p=>{const m=Fee[p];return b.jsx(V.Chip,{color:m.color,size:s=="medium"?"medium":"small",label:b.jsxs(V.Typography,{children:[b.jsx(Vm,{icon:m.icon}),m.label]})})}},...f],data:l,emptyTableMsg:r,renderExpand:t.renderExpand?p=>{const m=e.find(g=>g.id===p.id);return b.jsx(uw,{previousSnapshot:m,currentSnapshot:p,showDiff:p.changeType==="modified",children:t.renderExpand(p)})}:void 0,size:s}),u>0&&b.jsx(V.Box,{children:b.jsxs(V.Typography,{fontStyle:"italic",children:["+",u," unmodified rows"]})})]})},Ree=(t,e)=>b.jsxs(b.Fragment,{children:[b.jsx(V.Box,{"data-testid":"diff-table-cell-removed",sx:{backgroundColor:lp},children:b.jsx("s",{children:t})}),b.jsx(V.Box,{"data-testid":"diff-table-cell-added",sx:{backgroundColor:ap},children:b.jsx("u",{children:e})})]}),zee=(t,e,n,r=!1)=>{var i;let o={};for(const s of t)if(!s.ignoreDiff){const a=$u(s,e,r),l=$u(s,n,r);(((i=s.isEqual)==null?void 0:i.call(s,e,n))??ma.isEqual(a,l))||(o[xn(s)]=Ree(a,l))}return o},Vee=(t,e,n,r=!1,o)=>{const i=[];let s=0,a=0,l=0;for(e.sort((u,f)=>u.id-f.id),n.sort((u,f)=>u.id-f.id);s<e.length&&a<n.length;){const u=e[s],f=n[a];if(u.id===f.id){const p=zee(t,u,f,r);(o==null?void 0:o(u,f))??Object.keys(p).length===0?l++:i.push({...f,changeType:"modified",modifiedDiff:p}),s++,a++}else u.id<f.id?(i.push({...u,changeType:"deleted"}),s++):(i.push({...f,changeType:"added"}),a++)}for(;s<e.length;)i.push({...e[s],changeType:"deleted"}),s++;for(;a<n.length;)i.push({...n[a],changeType:"added"}),a++;return{dataDiff:i,unmodifiedCount:l}},Hee=t=>{const{beforeCitations:e,afterCitations:n,condenseTable:r=!1}=t,{palette:o}=V.useTheme(),i=R2(o,r);return b.jsxs(V.Box,{children:[!r&&b.jsx(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"10px",children:b.jsx(V.Typography,{variant:"h2",children:" Attachments & Citations"})}),b.jsx(yI,{columns:i,beforeData:e,afterData:n,size:r?"x-small":"medium"})]})},Wee=t=>{const{featureMenuOptions:e=[],copyright:n,logo:r,sx:o={},fontColor:i="primary"}=t,{palette:s}=V.useTheme(),a=vo.useNavigate();return b.jsxs(V.Box,{className:"MBv2_Footer",sx:{backgroundColor:s.mode==="dark"?"#222222":"#ededed",padding:"25px 30px",...o},children:[b.jsx(V.Box,{className:"MBv2_Footer_Logo",sx:{display:"flex",gap:2,alignItems:"center",paddingBottom:1},children:typeof r=="string"?b.jsx("img",{draggable:"false",src:r,style:{width:"200px"},alt:"logo"}):r}),b.jsxs(V.Box,{display:"flex",justifyContent:"space-between",flexWrap:"wrap",className:"MBv2_Footer_Nav_Links_Container",gap:2,children:[b.jsx(V.Box,{sx:{flexGrow:1},className:"MBv2_Footer_Nav_Links",display:"flex",flexDirection:"row",justifyContent:"flex-start",gap:3,children:e==null?void 0:e.map(l=>b.jsx(V.Link,{"data-testid":l.label,sx:{cursor:"pointer",fontSize:15},color:i,...Zl(l,a),children:l.label},l.label))}),n&&b.jsx(V.Typography,{style:{fontSize:15},"data-testid":"copyright",className:"MBv2_Footer_Copyright",color:i,children:n})]})]})},bI=t=>{const{menuOptionLists:e,anchor:n="left",children:r}=t,{pathname:o}=vo.useLocation(),i=vo.useNavigate(),[s,a]=Z.useState(!1),l=(m,g)=>b.jsx(V.MenuList,{children:m.map(v=>b.jsxs(V.MenuItem,{...Zl(v,i,()=>a(!1)),children:[v.icon&&b.jsx(V.ListItemIcon,{children:v.icon}),b.jsx(V.ListItemText,{primary:v.label})]},`mobile-drawer-group-${g}-item-${v.path}`))}),f=(()=>{if(e){const m=e.filter(g=>g&&g.length>0);return m.length===0?null:m.map((g,v)=>b.jsxs(Z.Fragment,{children:[l(g,v),v<m.length-1&&b.jsx(V.Divider,{})]},`mobile-drawer-group-${v}`))}return r?b.jsx(V.Box,{role:"presentation",onClick:()=>a(!1),children:r}):null})(),p=f??!1;return Z.useEffect(()=>{a(!1)},[o]),p&&b.jsxs(b.Fragment,{children:[b.jsx(V.IconButton,{onClick:()=>a(!0),color:"inherit",title:"Menu",children:b.jsx(jU,{})}),b.jsx(V.Drawer,{"data-testid":"mobile-drawer",anchor:n,open:s,onClose:()=>a(!1),children:b.jsx(V.Box,{sx:{width:300},display:"flex",flexDirection:"column",justifyContent:"space-between",children:b.jsx(V.Box,{display:"flex",justifyContent:"start",flexDirection:"column",children:f})})})]})},vI=t=>{const{env:e,isProd:n}=t;return n?null:b.jsx(V.Paper,{sx:{borderRadius:0,display:"flex",alignItems:"center",justifyContent:"center"},children:b.jsxs(V.Typography,{variant:"h6",color:"error",children:[e," Environment - Test Data Only"]})})},xI=t=>{const{displayName:e,userMenuOptions:n}=t;return b.jsx(gI,{label:e,menuOptions:n,icon:b.jsx(qU,{})})},Oh=t=>{const{menuOptions:e,orientation:n="horizontal",activeTabIdx:r,sx:o=n=="vertical"?{"& .MuiTabs-indicator":{left:0}}:void 0,slotProps:i={indicator:{sx:n=="horizontal"?{height:4}:{width:4}}}}=t,{palette:s}=V.useTheme(),a=vo.useNavigate();return b.jsx(V.Tabs,{orientation:n,value:r??!1,sx:o,slotProps:i,children:e.map((l,u)=>b.jsx(V.Tab,{icon:l.icon,label:l.label,value:u,...Zl(l,a),sx:{alignItems:n=="vertical"?"flex-start":void 0,borderBottom:n=="vertical"?"1px solid":void 0,borderColor:"divider","&.Mui-selected":{backgroundColor:n=="vertical"?s.grey[s.mode=="dark"?800:50]:void 0,color:"inherit"}}},l.label))})},wI=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t;return e.length>0&&b.jsx(V.Paper,{sx:{pl:4,pr:4,borderRadius:0},"data-testid":"navBar",children:b.jsx(Oh,{menuOptions:e,activeTabIdx:n,sx:r})})},SI=t=>{const{onToggle:e}=t,{palette:n}=V.useTheme(),r=n.mode==="dark";return b.jsx(V.IconButton,{onClick:e,color:"inherit",title:"Dark Mode Toggle",children:r?b.jsx(NM,{}):b.jsx(DM,{})})},jee=t=>{const{envInfo:e,headerRef:n,logo:r,featureMenuOptions:o=[],userMenuOptions:i=[],onToggleDarkMode:s,quickLinks:a=[],displayName:l,banner:u,position:f="fixed",children:p,sx:m,navBarSx:g}=t,v=vo.useNavigate(),y=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),{palette:x}=V.useTheme(),{pathname:S}=vo.useLocation(),k=x.mode==="dark",[T,C]=D.useState(void 0);D.useEffect(()=>{const N=o.findIndex($=>$.path&&S.startsWith($.path));C(N>=0?N:void 0)},[S,o]);const O=s&&b.jsx(SI,{onToggle:s}),I=s&&(y||!y&&l)?[{icon:k?b.jsx(NM,{}):b.jsx(DM,{}),label:`Switch to ${k?"Light":"Dark"} mode`,onClick:s},...i]:i;return b.jsxs(V.AppBar,{ref:n,position:f,sx:m,elevation:4,children:[e&&b.jsx(vI,{...e}),u,b.jsxs(V.Toolbar,{sx:{color:"white",display:"flex",justifyContent:"space-between",gap:2},children:[b.jsx(V.Button,{disableRipple:!0,component:vo.Link,to:"/",children:r&&typeof r=="string"?b.jsx("img",{draggable:"false",src:r,style:{width:"200px",filter:"brightness(0) invert(1)"},alt:"logo"}):r}),b.jsxs(V.Box,{display:"flex",gap:2,alignItems:"center",children:[!l&&!y&&O,y&&b.jsx(bI,{menuOptionLists:[o,a,I],anchor:"right"}),!y&&b.jsxs(b.Fragment,{children:[b.jsx(V.Box,{display:"flex",gap:0,children:a==null?void 0:a.map((N,$)=>b.jsxs(V.Box,{display:"flex",alignItems:"center",children:[$>0&&b.jsx(V.Typography,{className:"quickLink-divider",color:x.primary.contrastText,children:"|"}),b.jsx(V.Button,{variant:"text",sx:{color:"white"},...Zl(N,v),children:b.jsxs(V.Box,{display:"flex",gap:"3px",alignItems:"center",children:[N.icon,N.label]})})]},N.label))}),p,l&&b.jsx(xI,{displayName:l,userMenuOptions:I})]})]})]}),!y&&b.jsx(wI,{featureMenuOptions:o,activeTabIdx:T,sx:g})]})},Uee=t=>{const{sx:e,menuOptions:n=[]}=t,{pathname:r}=vo.useLocation(),o=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),[i,s]=Z.useState(void 0);return Z.useEffect(()=>{const a=n.findIndex(l=>l.path&&r.startsWith(l.path))??-1;s(a>=0?a:void 0)},[r,n]),!o&&n.length>0&&b.jsx(V.Box,{sx:e,children:b.jsx(V.Card,{sx:{height:"100%",width:200},children:b.jsx(Oh,{orientation:"vertical",menuOptions:n,activeTabIdx:i})})})},qee=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t,{palette:o}=V.useTheme();return e.length>0&&b.jsx(Oh,{menuOptions:e,activeTabIdx:n,sx:{margin:"8px",backgroundColor:o.primary.dark,borderRadius:"8px","& .MuiTab-root":{color:o.secondary.light,flexDirection:"row",gap:"2px","& .MuiTab-icon":{marginBottom:"unset"},minHeight:"58px"},"& .MuiTab-root.Mui-selected":{color:o.primary.contrastText,fontSize:"120%"},"& .MuiTabs-indicator":{display:"none"},...r}})},Kee=t=>{const{gap:e=1,...n}=t;return b.jsx(V.Box,{display:"flex",flexDirection:"column",gap:e,...n})},Yee=({children:t,getCitations:e})=>{const[n,r]=Z.useState([]),[o,i]=Z.useState(!1);Z.useEffect(()=>{(async()=>e().then(f=>{r(p=>{const m=new Set(p.map(v=>v.id));return[...p.filter(v=>!m.has(v.id)),...f]}),i(!0)}).catch(f=>{console.error(`Error fetching citations: ${f==null?void 0:f.toString()}`)}))()},[]);const s=Z.useCallback(u=>{r(f=>{const p=f.map(v=>{const y=u.find(x=>x.id===v.id);return y||v}),m=new Set(f.map(v=>v.id)),g=u.filter(v=>!m.has(v.id));return[...p,...g]})},[]),a=Z.useCallback(u=>{const f=n.findIndex(p=>p.id===u.id);r(f!==-1?p=>{const m=[...p];return m[f]=u,m}:[...n,u])},[n]),l=Z.useCallback(u=>r(n.filter(f=>f.id!==u)),[n]);return b.jsx(pI.Provider,{value:{citations:n,isLoaded:o,addUpdateCitation:a,deleteCitation:l,batchUpdate:s},children:t})},Gee=t=>b.jsx(Fu,{severity:"info",...t}),Jee=t=>b.jsx(Fu,{severity:"warning",...t}),CI=t=>{const{crumbInfo:e}=t,n=vo.useNavigate();return b.jsx(V.Breadcrumbs,{"aria-label":"breadcrumb",separator:b.jsx(UU,{color:"primary"}),sx:{marginBottom:2},children:e.map(({label:r,path:o},i)=>o&&i<e.length-1?b.jsx(V.Link,{color:"primary",sx:{cursor:"pointer"},onClick:()=>n(o),children:r},r):b.jsx(V.Typography,{color:"primary",children:r},r))})},Xee=t=>{const{title:e,message:n,type:r,onClose:o,autoHideDuration:i,variant:s="leftBorder",elevation:a=6}=t,l=Zee(r);return b.jsx(V.Snackbar,{"data-testid":"message-snackbar",anchorOrigin:{vertical:"bottom",horizontal:"right"},open:!0,onClose:u=>{u==null&&o()},autoHideDuration:i,children:b.jsx(Fu,{"data-testid":"message-snackbar-alert",severity:l,iconMapping:{info:TI(r),warning:TI(r)},onClose:o,elevation:a,variant:s,children:n?b.jsxs(b.Fragment,{children:[b.jsx(V.AlertTitle,{"data-testid":"alertTitle",sx:{fontWeight:"bold"},children:e}),n]}):e})})},Zee=t=>t=="logout"?"info":t=="timeout"?"warning":t,TI=t=>{if(t=="timeout")return b.jsx(PU,{});if(t=="logout")return b.jsx(WU,{})},Qee=t=>{ete(t);const{title:e,createButtonLabel:n="Add Item",showAddButton:r=!1,onAdd:o=()=>alert("Not implemented yet"),breadcrumbs:i=[],children:s,sx:a={},bottomGutter:l=!1}=t,u=V.useMediaQuery(V.useTheme().breakpoints.down("sm"));return!e&&(!r||!n)?null:b.jsxs(V.Box,{"data-testid":"MBv2-Page-Header",sx:{...a,...l&&{marginBottom:"4px"}},children:[i.length>0&&b.jsx(CI,{crumbInfo:i}),b.jsxs(V.Box,{className:"MBv2_PageHeader_Header",display:"flex",flexDirection:u?"column":"row",justifyContent:"space-between",alignItems:"center",gap:1,children:[b.jsxs(V.Box,{className:"MBv2_PageHeader_TitleAndCreateBtn",display:"flex",flexDirection:"row",justifyContent:u||!s?"space-between":"start",alignItems:"center",width:"100%",gap:1,children:[typeof e=="string"?b.jsx(V.Typography,{className:"MBv2_PageHeader_Title",variant:"h2",children:e}):e,r&&b.jsxs(co,{className:"MBv2_PageHeader_CreateBtn",onClick:()=>o(),children:[b.jsx($U,{style:{marginRight:"0.5rem"}}),n]})]}),s&&b.jsx(V.Box,{width:u?"100%":"50%",children:s})]})]})},ete=t=>{const{showAddButton:e,onAdd:n,createButtonLabel:r}=t,o="PageHeader component:";e&&!n&&console.warn(`${o} "showAddButton" is true but "onAdd" is not defined.`),e&&!r&&console.warn(`${o} "showAddButton" is true but "createButtonLabel" is not defined`)},tte=t=>{const{title:e,titleIcon:n,fullWidthIcon:r=!1,children:o,actionLabel:i,action:s,sx:a}=t,l=V.useMediaQuery(V.useTheme().breakpoints.down("sm"));return b.jsxs(V.Card,{sx:a||{padding:"30px 40px",display:"flex",flexDirection:"column",gap:"1rem"},children:[n&&b.jsx(V.Box,{className:"MBv2_SingleActionCard_Img",sx:[r?{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"20px",marginBottom:"10px"}:{display:"inline"}],children:n}),b.jsx(V.Typography,{variant:"h1",display:"inline",fontSize:"calc(20px + .9vw)",className:"MBv2_SingleActionCard_Title",children:e}),o,b.jsx(V.Button,{variant:"contained",color:"primary",onClick:s,fullWidth:l,className:"MBv2_SingleActionCard_ActionButton",children:i})]})};function nte({...t}){return b.jsx(dI,{onSelectCitations:()=>{},onCancel:()=>{},renderAsSelectablePopup:!1,...t})}const rte=t=>{const{size:e="small"}=t;let n=`${e}px`;switch(e){case"x-small":n="6px";break;case"small":n="10px";break;case"medium":n="14px";break;case"large":n="18px";break;case"x-large":n="22px";break}return b.jsx(V.Box,{height:n})};De.AlertModal=Lee,De.Autocomplete=lM,De.Breadcrumbs=CI,De.Button=co,De.Checkbox=uM,De.CheckboxGroup=rU,De.CitationField=Mee,De.CitationFieldProvider=Yee,De.CitationManager=nte,De.Column=Kee,De.ConfirmationModal=$ee,De.DarkModeToggle=SI,De.DateField=Hp,De.DateRangeField=MZ,De.DecisionModal=Bee,De.Diff=sM,De.DiffCitationTable=Hee,De.DiffProvider=uw,De.DiffTable=yI,De.Drawer=bI,De.DynamicAutocomplete=tU,De.EnvironmentBanner=vI,De.ErrorAlert=cI,De.FileList=sU,De.FileUpload=fM,De.FloatingNavBar=qee,De.Footer=Wee,De.FormDebugger=Aee,De.Header=jee,De.InfoAlert=Gee,De.LoadingButton=sv,De.LoadingIndicator=ov,De.Location=MU,De.MenuButton=gI,De.Modal=Bu,De.MultiAutocomplete=nU,De.NavBar=wI,De.NotApplicableCheckbox=mI,De.PageHeader=Qee,De.PaginatedTable=L2,De.ProfileMenu=xI,De.RadioGroup=AM,De.RangeSlider=_U,De.ReadOnly=ha,De.ReadOnlyProvider=lw,De.RepeatableFormGroup=Pee,De.RichTextField=CQ,De.Row=iI,De.ScrollToTop=Iee,De.SearchField=XU,De.Select=IU,De.SelectableCitationManager=fI,De.Sidebar=Uee,De.SingleActionCard=tte,De.Snackbar=Xee,De.Spacer=rte,De.Stepper=Dee,De.Submit=_ee,De.SuccessAlert=uI,De.Switch=AU,De.Table=iv,De.Tabs=Oh,De.TextArea=DU,De.TextField=gs,De.TextIcon=Vm,De.ValidationError=br,De.WarningAlert=Jee,De.commonTheme=_n,De.darkTheme=EP,De.lightTheme=kP,De.useDiff=Vs,De.useReadOnly=zs,Object.defineProperty(De,Symbol.toStringTag,{value:"Module"})}));
|