@xras/ui 0.11.0 → 0.11.1
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/dist/xras-ui.cjs +1 -1
- package/dist/xras-ui.js +24 -11
- package/package.json +1 -1
package/dist/xras-ui.cjs
CHANGED
|
@@ -286,7 +286,7 @@ object-assign
|
|
|
286
286
|
(c) Sindre Sorhus
|
|
287
287
|
@license MIT
|
|
288
288
|
*/var UE,FI;function RH(){if(FI)return UE;FI=1;var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;function l(f){if(f==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(f)}function u(){try{if(!Object.assign)return!1;var f=new String("abc");if(f[5]="de",Object.getOwnPropertyNames(f)[0]==="5")return!1;for(var v={},h=0;h<10;h++)v["_"+String.fromCharCode(h)]=h;var y=Object.getOwnPropertyNames(v).map(function(C){return v[C]});if(y.join("")!=="0123456789")return!1;var x={};return"abcdefghijklmnopqrst".split("").forEach(function(C){x[C]=C}),Object.keys(Object.assign({},x)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return UE=u()?Object.assign:function(f,v){for(var h,y=l(f),x,C=1;C<arguments.length;C++){h=Object(arguments[C]);for(var w in h)r.call(h,w)&&(y[w]=h[w]);if(t){x=t(h);for(var R=0;R<x.length;R++)i.call(h,x[R])&&(y[x[R]]=h[x[R]])}}return y},UE}var HE,VI;function bR(){if(VI)return HE;VI=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return HE=t,HE}var GE,BI;function lO(){return BI||(BI=1,GE=Function.call.bind(Object.prototype.hasOwnProperty)),GE}var WE,zI;function _H(){if(zI)return WE;zI=1;var t={},r=function(){};if(t.NODE_ENV!=="production"){var i=bR(),l={},u=lO();r=function(v){var h="Warning: "+v;typeof console<"u"&&console.error(h);try{throw new Error(h)}catch{}}}function f(v,h,y,x,C){if(t.NODE_ENV!=="production"){for(var w in v)if(u(v,w)){var R;try{if(typeof v[w]!="function"){var j=Error((x||"React class")+": "+y+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof v[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw j.name="Invariant Violation",j}R=v[w](h,w,x,y,null,i)}catch(T){R=T}if(R&&!(R instanceof Error)&&r((x||"React class")+": type specification of "+y+" `"+w+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof R+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),R instanceof Error&&!(R.message in l)){l[R.message]=!0;var N=C?C():"";r("Failed "+y+" type: "+R.message+(N??""))}}}}return f.resetWarningCache=function(){t.NODE_ENV!=="production"&&(l={})},WE=f,WE}var XE,$I;function TH(){if($I)return XE;$I=1;var t={},r=yR(),i=RH(),l=bR(),u=lO(),f=_H(),v=function(){};t.NODE_ENV!=="production"&&(v=function(y){var x="Warning: "+y;typeof console<"u"&&console.error(x);try{throw new Error(x)}catch{}});function h(){return null}return XE=function(y,x){var C=typeof Symbol=="function"&&Symbol.iterator,w="@@iterator";function R(Z){var re=Z&&(C&&Z[C]||Z[w]);if(typeof re=="function")return re}var j="<<anonymous>>",N={array:P("array"),bigint:P("bigint"),bool:P("boolean"),func:P("function"),number:P("number"),object:P("object"),string:P("string"),symbol:P("symbol"),any:V(),arrayOf:U,element:F(),elementType:z(),instanceOf:X,node:ge(),objectOf:pe,oneOf:Y,oneOfType:ie,shape:Re,exact:be};function T(Z,re){return Z===re?Z!==0||1/Z===1/re:Z!==Z&&re!==re}function I(Z,re){this.message=Z,this.data=re&&typeof re=="object"?re:{},this.stack=""}I.prototype=Error.prototype;function M(Z){if(t.NODE_ENV!=="production")var re={},Ce=0;function we(Ie,ue,de,Be,Ge,tt,ot){if(Be=Be||j,tt=tt||de,ot!==l){if(x){var je=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw je.name="Invariant Violation",je}else if(t.NODE_ENV!=="production"&&typeof console<"u"){var Rt=Be+":"+de;!re[Rt]&&Ce<3&&(v("You are manually calling a React.PropTypes validation function for the `"+tt+"` prop on `"+Be+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),re[Rt]=!0,Ce++)}}return ue[de]==null?Ie?ue[de]===null?new I("The "+Ge+" `"+tt+"` is marked as required "+("in `"+Be+"`, but its value is `null`.")):new I("The "+Ge+" `"+tt+"` is marked as required in "+("`"+Be+"`, but its value is `undefined`.")):null:Z(ue,de,Be,Ge,tt)}var Te=we.bind(null,!1);return Te.isRequired=we.bind(null,!0),Te}function P(Z){function re(Ce,we,Te,Ie,ue,de){var Be=Ce[we],Ge=Le(Be);if(Ge!==Z){var tt=ne(Be);return new I("Invalid "+Ie+" `"+ue+"` of type "+("`"+tt+"` supplied to `"+Te+"`, expected ")+("`"+Z+"`."),{expectedType:Z})}return null}return M(re)}function V(){return M(h)}function U(Z){function re(Ce,we,Te,Ie,ue){if(typeof Z!="function")return new I("Property `"+ue+"` of component `"+Te+"` has invalid PropType notation inside arrayOf.");var de=Ce[we];if(!Array.isArray(de)){var Be=Le(de);return new I("Invalid "+Ie+" `"+ue+"` of type "+("`"+Be+"` supplied to `"+Te+"`, expected an array."))}for(var Ge=0;Ge<de.length;Ge++){var tt=Z(de,Ge,Te,Ie,ue+"["+Ge+"]",l);if(tt instanceof Error)return tt}return null}return M(re)}function F(){function Z(re,Ce,we,Te,Ie){var ue=re[Ce];if(!y(ue)){var de=Le(ue);return new I("Invalid "+Te+" `"+Ie+"` of type "+("`"+de+"` supplied to `"+we+"`, expected a single ReactElement."))}return null}return M(Z)}function z(){function Z(re,Ce,we,Te,Ie){var ue=re[Ce];if(!r.isValidElementType(ue)){var de=Le(ue);return new I("Invalid "+Te+" `"+Ie+"` of type "+("`"+de+"` supplied to `"+we+"`, expected a single ReactElement type."))}return null}return M(Z)}function X(Z){function re(Ce,we,Te,Ie,ue){if(!(Ce[we]instanceof Z)){var de=Z.name||j,Be=G(Ce[we]);return new I("Invalid "+Ie+" `"+ue+"` of type "+("`"+Be+"` supplied to `"+Te+"`, expected ")+("instance of `"+de+"`."))}return null}return M(re)}function Y(Z){if(!Array.isArray(Z))return t.NODE_ENV!=="production"&&(arguments.length>1?v("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):v("Invalid argument supplied to oneOf, expected an array.")),h;function re(Ce,we,Te,Ie,ue){for(var de=Ce[we],Be=0;Be<Z.length;Be++)if(T(de,Z[Be]))return null;var Ge=JSON.stringify(Z,function(ot,je){var Rt=ne(je);return Rt==="symbol"?String(je):je});return new I("Invalid "+Ie+" `"+ue+"` of value `"+String(de)+"` "+("supplied to `"+Te+"`, expected one of "+Ge+"."))}return M(re)}function pe(Z){function re(Ce,we,Te,Ie,ue){if(typeof Z!="function")return new I("Property `"+ue+"` of component `"+Te+"` has invalid PropType notation inside objectOf.");var de=Ce[we],Be=Le(de);if(Be!=="object")return new I("Invalid "+Ie+" `"+ue+"` of type "+("`"+Be+"` supplied to `"+Te+"`, expected an object."));for(var Ge in de)if(u(de,Ge)){var tt=Z(de,Ge,Te,Ie,ue+"."+Ge,l);if(tt instanceof Error)return tt}return null}return M(re)}function ie(Z){if(!Array.isArray(Z))return t.NODE_ENV!=="production"&&v("Invalid argument supplied to oneOfType, expected an instance of array."),h;for(var re=0;re<Z.length;re++){var Ce=Z[re];if(typeof Ce!="function")return v("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Oe(Ce)+" at index "+re+"."),h}function we(Te,Ie,ue,de,Be){for(var Ge=[],tt=0;tt<Z.length;tt++){var ot=Z[tt],je=ot(Te,Ie,ue,de,Be,l);if(je==null)return null;je.data&&u(je.data,"expectedType")&&Ge.push(je.data.expectedType)}var Rt=Ge.length>0?", expected one of type ["+Ge.join(", ")+"]":"";return new I("Invalid "+de+" `"+Be+"` supplied to "+("`"+ue+"`"+Rt+"."))}return M(we)}function ge(){function Z(re,Ce,we,Te,Ie){return xe(re[Ce])?null:new I("Invalid "+Te+" `"+Ie+"` supplied to "+("`"+we+"`, expected a ReactNode."))}return M(Z)}function ae(Z,re,Ce,we,Te){return new I((Z||"React class")+": "+re+" type `"+Ce+"."+we+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+Te+"`.")}function Re(Z){function re(Ce,we,Te,Ie,ue){var de=Ce[we],Be=Le(de);if(Be!=="object")return new I("Invalid "+Ie+" `"+ue+"` of type `"+Be+"` "+("supplied to `"+Te+"`, expected `object`."));for(var Ge in Z){var tt=Z[Ge];if(typeof tt!="function")return ae(Te,Ie,ue,Ge,ne(tt));var ot=tt(de,Ge,Te,Ie,ue+"."+Ge,l);if(ot)return ot}return null}return M(re)}function be(Z){function re(Ce,we,Te,Ie,ue){var de=Ce[we],Be=Le(de);if(Be!=="object")return new I("Invalid "+Ie+" `"+ue+"` of type `"+Be+"` "+("supplied to `"+Te+"`, expected `object`."));var Ge=i({},Ce[we],Z);for(var tt in Ge){var ot=Z[tt];if(u(Z,tt)&&typeof ot!="function")return ae(Te,Ie,ue,tt,ne(ot));if(!ot)return new I("Invalid "+Ie+" `"+ue+"` key `"+tt+"` supplied to `"+Te+"`.\nBad object: "+JSON.stringify(Ce[we],null," ")+`
|
|
289
|
-
Valid keys: `+JSON.stringify(Object.keys(Z),null," "));var je=ot(de,tt,Te,Ie,ue+"."+tt,l);if(je)return je}return null}return M(re)}function xe(Z){switch(typeof Z){case"number":case"string":case"undefined":return!0;case"boolean":return!Z;case"object":if(Array.isArray(Z))return Z.every(xe);if(Z===null||y(Z))return!0;var re=R(Z);if(re){var Ce=re.call(Z),we;if(re!==Z.entries){for(;!(we=Ce.next()).done;)if(!xe(we.value))return!1}else for(;!(we=Ce.next()).done;){var Te=we.value;if(Te&&!xe(Te[1]))return!1}}else return!1;return!0;default:return!1}}function Ae(Z,re){return Z==="symbol"?!0:re?re["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&re instanceof Symbol:!1}function Le(Z){var re=typeof Z;return Array.isArray(Z)?"array":Z instanceof RegExp?"object":Ae(re,Z)?"symbol":re}function ne(Z){if(typeof Z>"u"||Z===null)return""+Z;var re=Le(Z);if(re==="object"){if(Z instanceof Date)return"date";if(Z instanceof RegExp)return"regexp"}return re}function Oe(Z){var re=ne(Z);switch(re){case"array":case"object":return"an "+re;case"boolean":case"date":case"regexp":return"a "+re;default:return re}}function G(Z){return!Z.constructor||!Z.constructor.name?j:Z.constructor.name}return N.checkPropTypes=f,N.resetWarningCache=f.resetWarningCache,N.PropTypes=N,N},XE}var YE,UI;function NH(){if(UI)return YE;UI=1;var t=bR();function r(){}function i(){}return i.resetWarningCache=r,YE=function(){function l(v,h,y,x,C,w){if(w!==t){var R=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw R.name="Invariant Violation",R}}l.isRequired=l;function u(){return l}var f={array:l,bigint:l,bool:l,func:l,number:l,object:l,string:l,symbol:l,any:l,arrayOf:u,element:l,elementType:l,instanceOf:u,node:l,objectOf:u,oneOf:u,oneOfType:u,shape:u,exact:u,checkPropTypes:i,resetWarningCache:r};return f.PropTypes=f,f},YE}var IH={};if(IH.NODE_ENV!=="production"){var AH=yR(),jH=!0;Tw.exports=TH()(AH.isElement,jH)}else Tw.exports=NH()();var OH=Tw.exports;const Pe=eh(OH),DH=(t,r)=>{switch(r.type){case"SET_RESOURCE_DATA":return{...t,resourceData:r.payload,loading:!1};case"SET_LOADING":return{...t,loading:r.payload};case"SET_SUCCESS_MESSAGE":return{...t,successMessage:r.payload};case"SET_ERRORS":return{...t,errors:Array.isArray(r.payload)?r.payload:[r.payload],loading:!1};case"UPDATE_RESOURCE_FIELD":return{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,[r.field]:r.value}}};case"UPDATE_ALLOCATION":return{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,allocation_types:t.resourceData.resource_details.allocation_types.map(i=>i.allocation_type_id===r.payload.allocationTypeId?{...i,...r.payload.updates}:i)}}};case"UPDATE_BASE_RATE":return console.log("Reducer: Updating base rate to:",r.payload),{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,exchange_rates:{...t.resourceData.resource_details.exchange_rates,base_rate:r.payload}}}};case"UPDATE_EXCHANGE_RATE":return{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,exchange_rates:{...t.resourceData.resource_details.exchange_rates,discount_rates:t.resourceData.resource_details.exchange_rates.discount_rates.map(i=>i.id===r.payload.rateId?{...i,...r.payload.changes}:i)}}}};case"ADD_EXCHANGE_RATE":return console.log("Reducer: Adding new discount rate:",r.payload),{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,exchange_rates:{...t.resourceData.resource_details.exchange_rates,discount_rates:[...t.resourceData.resource_details.exchange_rates.discount_rates||[],r.payload]}}}};case"DELETE_EXCHANGE_RATE":return{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,exchange_rates:{...t.resourceData.resource_details.exchange_rates,discount_rates:t.resourceData.resource_details.exchange_rates.discount_rates.filter(i=>i.id!==r.payload)}}}};default:return t}},Nw=t=>({type:"SET_RESOURCE_DATA",payload:t}),kH=t=>({type:"SET_LOADING",payload:t}),HI=(t,r)=>({type:"SET_SUCCESS_MESSAGE",payload:{message:t,color:r}}),lm=(t,r)=>({type:"UPDATE_RESOURCE_FIELD",field:t,value:r}),ZE=(t,r)=>({type:"UPDATE_ALLOCATION",payload:{allocationTypeId:t,updates:r}}),MH=async(t,r)=>await(await fetch(`${r}/resources/${t}.json`)).json(),LH=async(t,r,i,l)=>(console.log("update resource",i),await fetch(`${r}/resources/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json","X-CSRF-Token":document.querySelector('meta[name="csrf-token"]').content},body:JSON.stringify({resource:i,required_resources:l})})),PH=(t,r)=>{const[i,l]=k.useReducer(DH,{resourceData:null,loading:!0,errors:[],successMessage:{message:"",color:""}}),u=k.useCallback(async(v,h)=>{let y=[h];try{const x=await v.json();x.errors?y=x.errors:x.message&&(y=[x.message])}catch(x){console.error("Error parsing error response:",x)}l({type:"SET_ERRORS",payload:y})},[]),f=k.useCallback(async()=>{l(kH(!0));try{const v=await MH(t,r);l(Nw(v))}catch(v){console.error("Failed to fetch resource data:",v),l({type:"SET_ERRORS",payload:"Failed to fetch resource data. Please try again later."})}},[t,r]);return k.useEffect(()=>{f()},[f]),{state:i,dispatch:l,handleError:u,fetchData:f}},xR=t=>{var r,i,l;return{allowedActionsOptions:((r=t==null?void 0:t.resource_state_types_available)==null?void 0:r.map(u=>({value:u.resource_state_type_id,label:u.display_resource_state_type,additionalInfo:u.action_types.map(f=>f.display_action_type).join(", ")})))||[],resourceTypesOptions:((i=t==null?void 0:t.resource_types_available)==null?void 0:i.map(u=>({value:u.resource_type_id,label:u.display_resource_type})))||[],unitTypesOptions:((l=t==null?void 0:t.unit_types_available)==null?void 0:l.map(u=>({value:u.unit_type_id,label:u.display_unit_type})))||[],availableResources:(t==null?void 0:t.required_resources_available)||[],availableAllocationTypes:(t==null?void 0:t.unassigned_allocation_types)||[]}},FH=(t,r,i,l,u,f,v)=>{const y=(()=>{var R;if(!t)return[];const w=new Set;return(R=t.allocation_types)==null||R.forEach(j=>{var N;(N=j.required_resources)==null||N.forEach(T=>{w.add(T.resource_name)})}),Array.from(w).sort((j,N)=>j.localeCompare(N)).map(j=>({key:j,name:`Require ${j}`,width:150,type:"checkbox"}))})();return{allocationColumns:[{key:"display_name",name:"Allocation Type",width:200},{key:"allowed_actions",name:"Allowed Actions",width:200,type:"select"},{key:"comment",name:"Descriptive Text",width:200,type:"input",tooltip:"Appears below the resource name and allocations description in the form when making a new request"},...y],allocationRows:t!=null&&t.allocation_types?t.allocation_types.map(w=>{var R;return{display_name:w.display_name,allocation_type_id:w.allocation_type_id,allowed_actions:{options:l,value:((R=w.allowed_action)==null?void 0:R.resource_state_type_id)||"",onChange:j=>u(w.allocation_type_id,j)},comment:{value:w.comment||"",onChange:j=>f(w.allocation_type_id,j)},...Object.fromEntries(y.map(j=>{var N;return[j.key,{checked:((N=w.required_resources)==null?void 0:N.some(T=>T.resource_name===j.key))||!1,onChange:T=>v(w.allocation_type_id,j.key,T,w)}]}))}}):[],requiredResourcesColumns:y}},VH=(t,r,i)=>{const{availableResources:l,availableAllocationTypes:u,allowedActionsOptions:f}=xR(t),[v,h]=k.useState(!1),[y,x]=k.useState(!1),[C,w]=k.useState([]),[R,j]=k.useState(""),N=k.useCallback((F,z)=>{i(ZE(F,{allowed_action:{resource_state_type_id:z}}))},[i]),T=k.useCallback((F,z)=>{i(ZE(F,{comment:z}))},[i]),I=k.useCallback((F,z,X,Y)=>{const pe=X?[...Y.required_resources||[],{resource_name:z,required_resource_id:t.required_resources_available.find(ie=>ie.resource_name===z).resource_id}]:(Y.required_resources||[]).filter(ie=>ie.resource_name!==z);i(ZE(F,{required_resources:pe}))},[t,i]);k.useEffect(()=>{if(v&&r){const F=r.allocation_types.flatMap(z=>z.required_resources||[]).map(z=>z.required_resource_id);w(F)}},[v,r]);const M=k.useCallback((F,z)=>{w(X=>z?[...X,F]:X.filter(Y=>Y!==F))},[]),P=k.useCallback(()=>{const F=r.allocation_types.flatMap(pe=>pe.required_resources||[]).map(pe=>pe.required_resource_id),z=C.filter(pe=>!F.includes(pe)),X=F.filter(pe=>!C.includes(pe)),Y=r.allocation_types.map(pe=>{const ie=pe.required_resources||[],ge=z.map(Re=>{const be=l.find(xe=>xe.resource_id===Re);return{resource_name:be.resource_name,required_resource_id:be.resource_id}}),ae=ie.filter(Re=>!X.includes(Re.required_resource_id)).concat(ge.filter(Re=>!ie.some(be=>be.required_resource_id===Re.required_resource_id)));return{...pe,required_resources:ae}});i(Nw({...t,resource_details:{...r,allocation_types:Y}})),w([]),h(!1)},[C,l,r,t,i]),V=k.useCallback(F=>{const z=F.target.value;j(z)},[]),U=k.useCallback(()=>{var X,Y;if(!R)return;const F=u.find(pe=>pe.allocation_type_id.toString()===R),z=(X=r.allocation_types)==null?void 0:X.some(pe=>pe.allocation_type_id===F.allocation_type_id);if(F&&!z){const pe=(Y=f[0])==null?void 0:Y.value,ie=[...r.allocation_types||[],{allocation_type_id:F.allocation_type_id,display_name:F.display_name,allowed_action:{resource_state_type_id:pe},comment:"",required_resources:[]}];i(Nw({...t,resource_details:{...r,allocation_types:ie}})),x(!1)}},[R,u,r,t,i,f]);return{showAddResourceModal:v,setShowAddResourceModal:h,showAddAllocationTypeModal:y,setShowAddAllocationTypeModal:x,selectedNewResource:C,handleSelectNewResource:M,handleSaveResources:P,selectedNewAllocationType:R,handleSelectNewAllocationType:V,handleSaveAllocationType:U,handleAllowedActionChange:N,handleCommentChange:T,handleRequiredResourceChange:I}},BH=(t,r,i,l,u,f)=>k.useCallback(async()=>{var y,x,C;if(!t)return;const v={resource_name:t.resource_name,description:t.description,resource_type_id:t.resource_type_id,unit_type_id:t.unit_type_id,dollar_value:t.dollar_value,allocation_types:t.allocation_types.map(w=>{var R;return{allocation_type_id:w.allocation_type_id,allowed_action:{resource_state_type_id:(R=w.allowed_action)==null?void 0:R.resource_state_type_id},comment:w.comment||""}}),exchange_rates:{base_rate:(y=t.exchange_rates)==null?void 0:y.base_rate,discount_rates:(C=(x=t.exchange_rates)==null?void 0:x.discount_rates)==null?void 0:C.map(w=>({id:w.id,exchange_rate:w.exchange_rate,begin_date:w.begin_date,end_date:w.end_date}))}},h={};t.allocation_types.forEach(w=>{w.required_resources.forEach(R=>{h[R.required_resource_id]||(h[R.required_resource_id]=[]),h[R.required_resource_id].push(w.allocation_type_id)})});try{const w=await LH(r,i,v,h);if(w.ok){const R=await w.json();return f(HI(R.message||"Resource updated successfully!","success")),await l(),!0}else return await u(w,"Failed to update resource"),!1}catch{return f(HI("Error updating resource. Please try again later.","danger")),!1}},[t,r,i,l,u]),zH=(t=!1)=>{const[r,i]=k.useState(t);return{isEditing:r,handleEditingChange:u=>{i(u)}}},$H={"form-wrapper":"_form-wrapper_mu0yh_1"},b0=({show:t,onClose:r,title:i,children:l,onSave:u,buttonText:f,cancelText:v="Cancel",canSave:h=!0})=>t?m.jsx("div",{style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.8)",display:"flex",alignItems:"center",zIndex:1050},children:m.jsx("div",{className:"modal fade in",tabIndex:"-1",role:"dialog","aria-hidden":"true",style:{width:"90%",maxWidth:"600px",maxHeight:"90%",overflow:"auto",backgroundColor:"white",position:"relative"},children:m.jsx("div",{className:"modal-dialog",role:"document",children:m.jsxs("div",{className:"modal-content",children:[m.jsxs("div",{className:"modal-header",children:[m.jsx("button",{type:"button",className:"close","data-dismiss":"modal",onClick:r,"aria-label":"Close",children:m.jsx("h3",{"aria-hidden":"true",className:"text-danger",children:"×"})}),m.jsx("h3",{className:"modal-title",children:i})]}),m.jsx("div",{className:"modal-body",children:l}),m.jsxs("div",{className:"modal-footer",style:{padding:"15px",textAlign:"right",borderTop:"1px solid #e5e5e5",backgroundColor:"#f8f9fa"},children:[m.jsx("button",{className:"btn btn-danger",onClick:r,children:v}),m.jsx("button",{className:"btn btn-success",onClick:u,disabled:!h,children:f})]})]})})})}):null;b0.propTypes={show:Pe.bool.isRequired,onClose:Pe.func.isRequired,title:Pe.string.isRequired,children:Pe.node.isRequired,onSave:Pe.func.isRequired,buttonText:Pe.string,cancelText:Pe.string,canSave:Pe.bool};const yr=({children:t,color:r,dismissable:i=!1})=>m.jsxs("div",{className:`alert alert-${r} mt-3 alert-dismissible show`,role:"alert",children:[t,i&&m.jsx("button",{type:"button",className:"close","data-dismiss":"alert","aria-label":"Close",children:m.jsx("span",{"aria-hidden":"true",children:"×"})})]}),Wp=({label:t,options:r,value:i,onChange:l,...u})=>m.jsxs("div",{className:"form-group",children:[t&&m.jsx("label",{children:t}),m.jsx("select",{className:"form-control",value:i,onChange:l,...u,children:r.map(f=>m.jsxs("option",{value:f.value,children:[f.label,f.additionalInfo&&` - ${f.additionalInfo}`]},f.value))})]});Wp.propTypes={label:Pe.string,options:Pe.arrayOf(Pe.shape({value:Pe.oneOfType([Pe.string,Pe.number]).isRequired,label:Pe.string.isRequired,additionalInfo:Pe.string})).isRequired,value:Pe.oneOfType([Pe.string,Pe.number]),onChange:Pe.func.isRequired};function ym({label:t,type:r="text",value:i,onChange:l,disabled:u=!1,infoText:f="",style:v,inputClassName:h,inputAddon:y}){return m.jsxs(m.Fragment,{children:[t&&m.jsx("label",{children:t}),f&&m.jsx("small",{className:"form-text help-block",children:f}),r==="textarea"?m.jsx("textarea",{className:`form-control ${h||""}`,value:i,onChange:l,disabled:u,rows:"6"}):y?m.jsxs("div",{className:"input-prepend",children:[m.jsx("span",{className:"add-on",children:y}),m.jsx("input",{type:r,className:`form-control ${h||""}`,style:v,value:i,onChange:l,disabled:u})]}):m.jsx("input",{type:r,className:`form-control ${h||""}`,style:v,value:i,onChange:l,disabled:u})]})}const UH="_blurred_16xcy_16",ql={"advanced-settings":"_advanced-settings_16xcy_1","header-wrapper":"_header-wrapper_16xcy_5","content-container":"_content-container_16xcy_11",blurred:UH,"warning-banner":"_warning-banner_16xcy_21","alt-warning-banner":"_alt-warning-banner_16xcy_40 _warning-banner_16xcy_21"},CR=({headerText:t,header:r,children:i,isEditing:l=!1,onEditingChange:u,warningMessage:f=""})=>{const v=t&&t.type==="label";return m.jsxs("div",{className:ql["advanced-settings"],children:[(t||r)&&m.jsxs("div",{className:ql["header-wrapper"],children:[t,r&&m.jsx("div",{className:`${ql["header-buttons-container"]} ${l?"":ql.blurred}`,children:r})]}),m.jsxs("div",{style:{width:"100%"},children:[!l&&m.jsxs("div",{className:v?`${ql["alt-warning-banner"]}`:ql["warning-banner"],children:[m.jsxs("span",{className:ql["warning-text"],children:[m.jsx("strong",{children:"CAUTION! "})," ",f]}),m.jsx("button",{className:"btn btn-danger",onClick:()=>u(!0),children:"I understand the risks"})]}),m.jsx("div",{className:`${ql["content-container"]} ${l?"":ql.blurred}`,children:i})]})]})};CR.propTypes={headerText:Pe.node,header:Pe.node,children:Pe.node.isRequired,isEditing:Pe.bool,onEditingChange:Pe.func.isRequired,warningMessage:Pe.string};const SR=pr.memo(function({resourceDetails:r,resourceTypesOptions:i,unitTypesOptions:l,dispatch:u,isDollarValueEditing:f,onDollarValueEditingChange:v,showDollarValue:h=!0,showResourceId:y=!0,useAdvancedSettings:x=!0}){const C="Dollar Value per SUs",w=h?m.jsx(ym,{label:x?null:C,value:r.dollar_value,onChange:R=>u(lm("dollar_value",R.target.value)),type:"number",inputAddon:"$",inputClassName:"span4"}):null;return m.jsxs(m.Fragment,{children:[m.jsx(ym,{label:"Resource Name",value:r.resource_name,onChange:R=>u(lm("resource_name",R.target.value)),inputClassName:"span8"}),y&&m.jsx(ym,{label:"Resource ID",value:r.resource_id,disabled:!0,inputClassName:"span8"}),x&&h?m.jsx(CR,{headerText:m.jsx("label",{children:C}),isEditing:f,onEditingChange:v,warningMessage:"Dollar value is for reporting and should only be modified if the SU rate changes.",children:w}):w,m.jsx(ym,{label:"Allocations Description",type:"textarea",value:r.description,infoText:"Appears below the resource name in the form when making a new request, as well as under the header Allocations Description in resource catalogs",onChange:R=>u(lm("description",R.target.value)),inputClassName:"span8"}),m.jsx(Wp,{label:"Resource Type",options:i,value:r.resource_type_id,onChange:R=>u(lm("resource_type_id",R.target.value)),className:"span8"}),m.jsx(Wp,{label:"Unit Type",options:l,value:r.unit_type_id,onChange:R=>u(lm("unit_type_id",R.target.value)),className:"span8"})]})});SR.propTypes={resourceDetails:Pe.object.isRequired,resourceTypesOptions:Pe.array.isRequired,unitTypesOptions:Pe.array.isRequired,dispatch:Pe.func.isRequired,isDollarValueEditing:Pe.bool,onDollarValueEditingChange:Pe.func,showDollarValue:Pe.bool,showResourceId:Pe.bool,useAdvancedSettings:Pe.bool};function uO({onClose:t}){const[r,i]=k.useState(!0),[l,u]=k.useState([]),[f,v]=k.useState(null),[h,y]=k.useState(-1),[x,C]=k.useState(null),w=xR(x);w.resourceTypesOptions.unshift({value:0,label:"Select a resource type..."}),w.unitTypesOptions.unshift({value:0,label:"Select a unit type..."}),k.useEffect(()=>{(async()=>{const P=await fetch("/resources/addable.json");i(!1),P.status==200?u(await P.json()):v("Error retrieving resource list.")})()},[]),k.useEffect(()=>{if(h===-1)return C(null);(async()=>{const P=await fetch(`/resources/addable/${h}.json`);P.status==200?C(await P.json()):v("Error retrieving resource details.")})()},[h]);let R=null;r?R=m.jsx("p",{children:"Loading…"}):f!==null?R=m.jsx(yr,{color:"danger",children:f}):l.length==0&&(R=m.jsx(yr,{children:"There are currently no resources available to add."}));const j=[{value:-1,label:"Select a resource..."}].concat(l.map(P=>({value:P.xras_cider_resource_id,label:P.resource_descriptive_name}))),N=x?x.resource_details:null,T=!f&&N&&N.resource_name.length>0&&N.resource_type_id>0&&N.unit_type_id>0,I=P=>{P.type=="UPDATE_RESOURCE_FIELD"&&C({...x,resource_details:{...x.resource_details,[P.field]:P.value}})},M=()=>{(async()=>{const P=await fetch("/resources",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-Token":document.querySelector('meta[name="csrf-token"]').content},body:JSON.stringify({...N,resource_repository_key:h})});if(P.status==200){const V=await P.json();window.location=`/resources/${V.resource_id}`}else v("Error saving resource.")})()};return R===null&&(R=m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:"Select a Resource to Add"}),m.jsx(Wp,{options:j,onChange:P=>y(parseInt(P.target.value))}),!x&&h!==-1?m.jsx("p",{children:"Loading…"}):null,x&&m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:"Resource Properties"}),m.jsx("p",{style:{fontStyle:"italic",fontWeight:"bold"},children:"Any modifications to these resource properties will be applied globally and impact resources on other all allocations process"}),m.jsx("div",{className:$H["form-wrapper"],children:m.jsx(SR,{resourceDetails:N,resourceTypesOptions:w.resourceTypesOptions,unitTypesOptions:w.unitTypesOptions,showResourceId:!1,showDollarValue:!1,dispatch:I})})]})]})),m.jsx(b0,{show:!0,onClose:t,title:"Add a Resource from CIDeR",onSave:M,buttonText:"Save",canSave:T,children:R})}uO.propTypes={onClose:Pe.func.isRequired};function HH({availableResources:t,canAdd:r=!1,relativeUrlRoot:i}){const l=k.useMemo(()=>CH(t),[t]),[u,f]=k.useState(l),[v,h]=k.useState(!1),y=k.useRef(null),x=k.useRef(null);k.useEffect(()=>{f(l)},[l]);const C=(j,N)=>{y.current=N},w=(j,N)=>{if(j.preventDefault(),y.current===N)return;const T=[...u],I=T[y.current];T.splice(y.current,1),T.splice(N,0,I),y.current=N,f(T);const{clientY:M}=j,P=130;M<P?kI(-1,x):window.innerHeight-M<P?kI(1,x):$E(x)},R=()=>{y.current=null,$E(x),xH(i,u)};return k.useEffect(()=>()=>$E(x),[]),m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:ls["resources-container"],children:[r&&m.jsx("button",{className:"btn btn-primary pull-right",onClick:()=>h(!0),children:"Add a Resource from CIDeR"}),m.jsx("h2",{children:"Select a resource from the list to modify"}),m.jsx("p",{className:ls["drag-instruction"],children:"Drag items to reorder the list."}),m.jsxs("div",{className:ls["resources-list"],children:[m.jsxs("div",{className:ls["resources-header"],children:[m.jsx("span",{className:ls["header-name"],children:"Resource Name"}),m.jsx("span",{className:ls["header-repo"],children:"Repository Key"})]}),u.map((j,N)=>m.jsxs("div",{className:`${ls["resources-item"]}`,draggable:!0,onDragStart:T=>C(T,N),onDragOver:T=>w(T,N),onDrop:R,children:[m.jsx("span",{className:ls["drag-handle"]}),m.jsx("span",{className:ls["resource-name"],children:m.jsx("a",{href:`${i}/resources/${j.resource_id}`,className:ls["resource-link"],children:j.display_resource_name})}),m.jsx("span",{className:ls["resource-repo"],children:j.resource_repository_key||"N/A"})]},j.resource_id))]})]}),v&&m.jsx(uO,{onClose:()=>h(!1)})]})}function nh(){return m.jsx("div",{className:"spinner-border",role:"status",children:m.jsx("span",{className:"visually-hidden",children:"Loading..."})})}const GH="_grid_afccc_1",WH="_important_afccc_30",XH="_input_afccc_34",YH="_edited_afccc_38",ZH="_disabled_afccc_46",qH="_scroll_afccc_59",Gd={grid:GH,important:WH,input:XH,edited:YH,disabled:ZH,scroll:qH};function JH({column:t,row:r,style:i={}}){const l=t.format?t.format(r[t.key],r):r[t.key],u=["cell"];return t.class&&u.push(t.class),t.rowClass&&u.push(t.rowClass(r)),m.jsx("td",{className:u.join(" "),style:i,children:l})}const ER=({title:t,placement:r,children:i})=>(k.useEffect(()=>($('[data-toggle="tooltip"]').tooltip(),()=>{$('[data-toggle="tooltip"]').tooltip("destroy")}),[]),m.jsx("span",{"data-toggle":"tooltip","data-placement":r,title:t,style:{margin:"10px"},children:i}));ER.propTypes={title:Pe.string.isRequired,placement:Pe.oneOf(["top","bottom","left","right"]),children:Pe.node.isRequired};ER.defaultProps={placement:"top"};const QH="_datepicker_19wnv_1",KH="_error_19wnv_1",GI={datepicker:QH,error:KH},eG=({value:t,onChange:r,disabled:i=!1,style:l,className:u="",minDate:f="",maxDate:v="",error:h=""})=>{const y=h;return m.jsx("div",{className:`w-full ${u}`,children:m.jsx("input",{type:"date",style:l,className:`${GI.datepicker} ${y?GI.error:""}`,value:t||"",onChange:x=>r(x.target.value),disabled:i,min:f||"1900-01-01",max:v||"2100-12-31"})})},um=(t,r,i)=>{if(r.onChange){r.onChange(i,t);return}const l=t[r.key];l!=null&&l.onChange&&l.onChange(i)},tG={text:JH,select:({column:t,row:r,style:i})=>m.jsx("td",{style:i,children:m.jsx(Wp,{label:"",options:r[t.key].options,value:r[t.key].value,onChange:l=>um(r,t,l.target.value),style:{width:"100%",margin:0}})}),input:({column:t,row:r,style:i})=>m.jsx("td",{style:i,children:m.jsx(ym,{label:"",type:"text",disabled:r[t.key].disabled,value:r[t.key].value,onChange:l=>um(r,t,l.target.value),style:{width:"92%",margin:0}})}),checkbox:({column:t,row:r,style:i})=>m.jsx("td",{style:i,children:m.jsx("input",{type:"checkbox",checked:r[t.key].checked,onChange:l=>um(r,t,l.target.checked)})}),date:({column:t,row:r,style:i})=>{const l=r[t.key];return!(l!=null&&l.value)&&typeof l!="object"?m.jsx("td",{style:i,children:l||""}):m.jsx("td",{style:i,children:m.jsx(eG,{value:l.value,onChange:u=>um(r,t,u),disabled:l.disabled,style:{width:"92%",margin:0},minDate:t.minDate,maxDate:t.maxDate,error:l.error})})},action:({column:t,row:r,style:i})=>m.jsx("td",{style:i,children:r.rate_type==="Discount"&&m.jsx("button",{className:"btn btn-link text-danger",onClick:()=>{var l;return um(r,t,(l=r[t.key])==null?void 0:l.id)},children:m.jsx("i",{className:"fa fa-trash"})})})};function su({columns:t,rows:r,classes:i,frozenColumns:l=0,minWidth:u,rowClasses:f=[],scroll:v=!0,scrollBehavior:h="smooth",scrollRowIndex:y=0}){const x=k.useRef();k.useLayoutEffect(()=>{if(!v||!x.current)return;const T=x.current.querySelector(`tbody tr:nth-child(${y+1})`);T&&T.scrollIntoView({behavior:h,block:"nearest",inline:"nearest"})},[v,y,h]);const C=[0];for(let T=0;T<l;T++)C[T+1]=C[T]+(t[T].width||100);const w=(T,I)=>T<l?{position:"sticky",left:`${C[T]}px`,minWidth:`${t[T].width||100}px`,width:`${t[T].width||100}px`,zIndex:I||1}:{},R=t.map((T,I)=>m.jsxs("th",{className:T.headerClass||T.class||"",style:w(I,100),children:[T.formatHeader?T.formatHeader(T.name,T):T.name,T.tooltip&&m.jsx(ER,{title:T.tooltip,placement:"bottom",children:m.jsx("i",{className:"icon-info-sign"})})]},T.key)),j=r.map((T,I)=>{const M=t.map((P,V)=>{const U=tG[P.type||"text"];return m.jsx(U,{column:P,row:T,style:w(V)},P.key)});return m.jsx("tr",{className:f[I]||"",children:M},I)}),N={};return u&&(N.minWidth=u),m.jsx("div",{className:`${Gd.grid} ${v?Gd.scroll:""} ${i||""}`,ref:x,children:m.jsxs("table",{className:"table table-bordered",style:N,children:[m.jsx("thead",{children:m.jsx("tr",{children:R})}),m.jsx("tbody",{children:j})]})})}const Iw={"header-buttons":"_header-buttons_15oxx_1","allocation-types-grid":"_allocation-types-grid_15oxx_6","vertical-align-center":"_vertical-align-center_15oxx_10"},cO=({onAddAllocationType:t,onAddRequiredResource:r})=>m.jsxs("div",{className:Iw["header-buttons"],children:[m.jsxs("button",{className:"btn btn-primary",onClick:t,children:[m.jsx("i",{className:"fa fa-plus"})," Add Allocation Type"]}),m.jsxs("button",{className:"btn btn-primary",onClick:r,children:[m.jsx("i",{className:"fa fa-plus"})," Add Required Resource"]})]});cO.propTypes={headerText:Pe.node,onAddAllocationType:Pe.func.isRequired,onAddRequiredResource:Pe.func.isRequired};const dO=pr.memo(function({columns:r,rows:i}){return m.jsx("div",{className:Iw["allocation-types-grid"],children:m.jsx(su,{columns:r,rows:i,rowClasses:Array(i.length).fill(Iw["vertical-align-center"]),scroll:!1})})});dO.propTypes={columns:Pe.array.isRequired,rows:Pe.array.isRequired};const Pp={"exchange-rates-grid":"_exchange-rates-grid_5qkd5_1","header-container":"_header-container_5qkd5_5","header-buttons":"_header-buttons_5qkd5_11","vertical-align-center":"_vertical-align-center_5qkd5_18","error-summary":"_error-summary_5qkd5_35"},fO=pr.memo(function({columns:r,rows:i,onAddDiscountRate:l,dateErrors:u=[]}){return m.jsxs("div",{className:Pp["exchange-rates-grid"],children:[m.jsxs("div",{className:Pp["header-container"],children:[m.jsx("h2",{className:Pp["header-title"],children:"Exchange Rates"}),m.jsx("div",{className:Pp["header-buttons"],children:m.jsxs("button",{className:"btn btn-primary",onClick:l,children:[m.jsx("i",{className:"fa fa-plus"})," Add Discount Rate"]})})]}),m.jsx(su,{columns:r,rows:i,rowClasses:Array(i.length).fill(Pp["vertical-align-center"]),scroll:!1}),u.length>0&&m.jsx("div",{className:Pp["error-summary"],children:m.jsx("ul",{children:u.map((f,v)=>m.jsx("li",{children:f},v))})})]})});fO.propTypes={columns:Pe.array.isRequired,rows:Pe.array.isRequired,onAddDiscountRate:Pe.func.isRequired,dateErrors:Pe.array};const nG=(t,r)=>{const i=k.useCallback(j=>{var T,I;r({type:"DELETE_EXCHANGE_RATE",payload:j}),(((I=(T=t==null?void 0:t.resource_details)==null?void 0:T.exchange_rates)==null?void 0:I.discount_rates.filter(M=>M.id!==j))||[]).forEach(M=>{M.begin_date&&M.end_date&&r({type:"UPDATE_EXCHANGE_RATE",payload:{rateId:M.id,changes:{start_date_error:"",end_date_error:""}}})})},[r,t]),l=[{key:"rate_type",name:"Rate Type",width:150},{key:"rate",name:"Exchange Rate",width:100,type:"input",tooltip:"Exchange rate is the cost in ACCESS Credits of one resource unit. ACCESS Credits / exchange rate = resource units"},{key:"conversion",name:"Resource Units per ACCESS Credit",width:150},{key:"start_date",name:"Start Date",width:150,type:"date",minDate:new Date().toISOString().split("T")[0]},{key:"end_date",name:"End Date",width:150,type:"date",minDate:new Date().toISOString().split("T")[0]},{key:"actions",name:"",width:80,type:"action",onChange:i}],u=j=>{r({type:"UPDATE_BASE_RATE",payload:j})},f=(j,N)=>{const T={exchange_rate:N},I={};N?I.rate_error="":I.rate_error="Exchange Rate cannot be empty",r({type:"UPDATE_EXCHANGE_RATE",payload:{rateId:j,changes:{...T,...I}}})},v=()=>{var T,I;const j=[];return(((I=(T=t==null?void 0:t.resource_details)==null?void 0:T.exchange_rates)==null?void 0:I.discount_rates)||[]).forEach(M=>{M.start_date_error&&j.push(M.start_date_error),M.end_date_error&&j.push(M.end_date_error),M.rate_error&&j.push(M.rate_error)}),j.filter((M,P)=>M&&M!==""&&(!M.includes("overlaps")||j.indexOf(M)===P))},h=j=>{const N=new Date(j);return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",month:"numeric",day:"numeric",year:"numeric"}).format(N)},y=(j,N,T,I)=>{const M=new Date(j).getTime(),P=new Date(N).getTime(),V=new Date(T).getTime(),U=new Date(I).getTime();return M<=U&&V<=P},x=(j,N)=>{let T="";if(j.begin_date&&j.end_date){const I=N.filter(M=>M.id!==j.id);for(const M of I)if(M.begin_date&&M.end_date&&y(j.begin_date,j.end_date,M.begin_date,M.end_date)){T=`The selected date range (${h(j.begin_date)} to ${h(j.end_date)}) overlaps with an existing discount rate (${h(M.begin_date)} to ${h(M.end_date)})`;break}}return T},C=(j,N,T)=>{var ie,ge;const I={start_date:"begin_date",end_date:"end_date"},M=ae=>{const Re=new Date(ae);return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",month:"numeric",day:"numeric",year:"numeric"}).format(Re)},P=((ge=(ie=t==null?void 0:t.resource_details)==null?void 0:ie.exchange_rates)==null?void 0:ge.discount_rates)||[],V=P.find(ae=>ae.id===j);if(!V)return;const U={[I[N]]:T},F={},z=N==="end_date",X=()=>{if(!T)return F[`${N}_error`]="Date cannot be empty or invalid",!1;const ae=l.find(Ae=>Ae.key===N),Re=(ae==null?void 0:ae.minDate)||"1900-01-01",be=(ae==null?void 0:ae.maxDate)||"2100-12-31",xe=z&&V.begin_date?V.begin_date:Re;return T<xe?(F[`${N}_error`]=`${N.replace("_"," ")} ${M(T)} cannot be before ${M(xe)}`,!1):T>be?(F[`${N}_error`]=`${N.replace("_"," ")} cannot be after ${M(be)}`,!1):(F[`${N}_error`]="",!0)},Y=()=>{const ae=N==="end_date"?T:V.end_date;if(N==="start_date"&&ae){if(T>ae)return F.end_date_error=`end date ${M(ae)} cannot be before ${M(T)}`,!1;F.end_date_error=F.end_date_error||""}return!0},pe=()=>{console.log("validating overlaps");const ae=N==="start_date"?T:V.begin_date,Re=N==="end_date"?T:V.end_date;if(ae&&Re){const be=x({...V,begin_date:ae,end_date:Re},P);return F.start_date_error=be,F.end_date_error=be,!be}return!0};if(!X()){r({type:"UPDATE_EXCHANGE_RATE",payload:{rateId:j,changes:{...U,...F}}});return}Y(),pe(),z&&!V.begin_date?F.start_date_error="Date cannot be empty or invalid":!z&&!V.end_date&&(F.end_date_error="Date cannot be empty or invalid"),r({type:"UPDATE_EXCHANGE_RATE",payload:{rateId:j,changes:{...U,...F}}})},w=()=>{var F,z;const j=((z=(F=t==null?void 0:t.resource_details)==null?void 0:F.exchange_rates)==null?void 0:z.discount_rates)||[];let T=new Date;j.forEach(X=>{if(X.end_date){const Y=new Date(X.end_date);Y>T&&(T=Y)}});const I=new Date(T);I.setDate(I.getDate()+1);const M=I.toISOString().split("T")[0],P=new Date(I);P.setDate(P.getDate()+15);const V=P.toISOString().split("T")[0],U={id:Date.now(),exchange_rate:"1.0",begin_date:M,end_date:V,is_new:!0};r({type:"ADD_EXCHANGE_RATE",payload:U})};return{exchangeRateColumns:l,exchangeRateRows:(()=>{var V,U;const j=(V=t==null?void 0:t.resource_details)==null?void 0:V.exchange_rates,N=(j==null?void 0:j.base_rate)??"",T=(j==null?void 0:j.discount_rates)||[],I=new Date().toISOString().split("T")[0],M=((U=t==null?void 0:t.resource_details)==null?void 0:U.unit_type)||"Resource Units",P=F=>!F||Number(F)===0?"-":`${(1/Number(F)).toFixed(2)} ${M}`;return[{rate_type:"Base Rate",rate:{value:N.toString(),onChange:F=>u(F)},conversion:P(N)},...T.map(F=>{var pe;const z=F.is_new||F.begin_date>I,X=z||F.begin_date==="",Y=F.is_new||F.end_date>=I||F.end_date==="";return{rate_type:"Discount",rate:{value:((pe=F.exchange_rate)==null?void 0:pe.toString())||"",onChange:z?ie=>f(F.id,ie):null,disabled:!z},conversion:P(F.exchange_rate),start_date:{value:F.begin_date||"",onChange:ie=>C(F.id,"start_date",ie),error:F.start_date_error,disabled:!X},end_date:{value:F.end_date||"",onChange:ie=>C(F.id,"end_date",ie),error:F.end_date_error,disabled:!Y},actions:{id:F.id}}})]})(),handleAddDiscountRate:w,handleDeleteRate:i,dateErrors:v()}};function pO({resourceId:t,relativeUrlRoot:r,setExternalSubmit:i}){const{state:l,dispatch:u,handleError:f,fetchData:v}=PH(t,r),{isEditing:h,handleEditingChange:y}=zH(),{resourceData:x,loading:C,errors:w,successMessage:R}=l,j=x==null?void 0:x.resource_details,N=x==null?void 0:x.uses_exchange_rates,{allowedActionsOptions:T,resourceTypesOptions:I,unitTypesOptions:M,availableResources:P,availableAllocationTypes:V}=xR(x),{showAddResourceModal:U,setShowAddResourceModal:F,showAddAllocationTypeModal:z,setShowAddAllocationTypeModal:X,selectedNewResource:Y,handleSelectNewResource:pe,handleSaveResources:ie,selectedNewAllocationType:ge,handleSelectNewAllocationType:ae,handleSaveAllocationType:Re,handleAllowedActionChange:be,handleCommentChange:xe,handleRequiredResourceChange:Ae}=VH(x,j,u),{exchangeRateColumns:Le,exchangeRateRows:ne,handleAddDiscountRate:Oe,dateErrors:G}=nG(x,u),Z=BH(j,t,r,v,f,u);k.useEffect(()=>{i&&G.length==0?i(Z):i(null)},[Z,i,G]);const{allocationColumns:re,allocationRows:Ce}=FH(j,P,Y,T,be,xe,Ae),[we,Te]=k.useState(!1);return C?m.jsx(nh,{}):w.length>0?m.jsx("div",{children:w.map((Ie,ue)=>m.jsx(yr,{color:"danger",dismissable:!0,children:Ie},ue))}):x?m.jsxs("div",{className:"edit-resource",children:[R.message&&m.jsx(yr,{color:R.color,dismissable:!0,children:R.message}),m.jsxs("div",{children:[m.jsx("h2",{children:"Resource Propeties"}),m.jsx("div",{style:{marginBottom:"0.75rem"},children:m.jsx("p",{style:{margin:"0",fontStyle:"italic",fontWeight:"bold"},children:"Any modifications to these resource properties will be applied globally and impact resources on other all allocations process"})}),m.jsx(SR,{resourceDetails:j,resourceTypesOptions:I,unitTypesOptions:M,dispatch:u,isDollarValueEditing:we,onDollarValueEditingChange:Te})]}),N&&m.jsx(fO,{columns:Le,rows:ne,onAddDiscountRate:Oe,dateErrors:G}),m.jsx(CR,{headerText:m.jsx("h2",{children:"Allocation Types"}),header:m.jsx(cO,{onAddAllocationType:()=>h&&X(!0),onAddRequiredResource:()=>h&&F(!0)}),isEditing:h,onEditingChange:y,warningMessage:`Incorrect allocations
|
|
289
|
+
Valid keys: `+JSON.stringify(Object.keys(Z),null," "));var je=ot(de,tt,Te,Ie,ue+"."+tt,l);if(je)return je}return null}return M(re)}function xe(Z){switch(typeof Z){case"number":case"string":case"undefined":return!0;case"boolean":return!Z;case"object":if(Array.isArray(Z))return Z.every(xe);if(Z===null||y(Z))return!0;var re=R(Z);if(re){var Ce=re.call(Z),we;if(re!==Z.entries){for(;!(we=Ce.next()).done;)if(!xe(we.value))return!1}else for(;!(we=Ce.next()).done;){var Te=we.value;if(Te&&!xe(Te[1]))return!1}}else return!1;return!0;default:return!1}}function Ae(Z,re){return Z==="symbol"?!0:re?re["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&re instanceof Symbol:!1}function Le(Z){var re=typeof Z;return Array.isArray(Z)?"array":Z instanceof RegExp?"object":Ae(re,Z)?"symbol":re}function ne(Z){if(typeof Z>"u"||Z===null)return""+Z;var re=Le(Z);if(re==="object"){if(Z instanceof Date)return"date";if(Z instanceof RegExp)return"regexp"}return re}function Oe(Z){var re=ne(Z);switch(re){case"array":case"object":return"an "+re;case"boolean":case"date":case"regexp":return"a "+re;default:return re}}function G(Z){return!Z.constructor||!Z.constructor.name?j:Z.constructor.name}return N.checkPropTypes=f,N.resetWarningCache=f.resetWarningCache,N.PropTypes=N,N},XE}var YE,UI;function NH(){if(UI)return YE;UI=1;var t=bR();function r(){}function i(){}return i.resetWarningCache=r,YE=function(){function l(v,h,y,x,C,w){if(w!==t){var R=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw R.name="Invariant Violation",R}}l.isRequired=l;function u(){return l}var f={array:l,bigint:l,bool:l,func:l,number:l,object:l,string:l,symbol:l,any:l,arrayOf:u,element:l,elementType:l,instanceOf:u,node:l,objectOf:u,oneOf:u,oneOfType:u,shape:u,exact:u,checkPropTypes:i,resetWarningCache:r};return f.PropTypes=f,f},YE}var IH={};if(IH.NODE_ENV!=="production"){var AH=yR(),jH=!0;Tw.exports=TH()(AH.isElement,jH)}else Tw.exports=NH()();var OH=Tw.exports;const Pe=eh(OH),DH=(t,r)=>{switch(r.type){case"SET_RESOURCE_DATA":return{...t,resourceData:r.payload,loading:!1};case"SET_LOADING":return{...t,loading:r.payload};case"SET_SUCCESS_MESSAGE":return{...t,successMessage:r.payload};case"SET_ERRORS":return{...t,errors:Array.isArray(r.payload)?r.payload:[r.payload],loading:!1};case"UPDATE_RESOURCE_FIELD":return{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,[r.field]:r.value}}};case"UPDATE_ALLOCATION":return{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,allocation_types:t.resourceData.resource_details.allocation_types.map(i=>i.allocation_type_id===r.payload.allocationTypeId?{...i,...r.payload.updates}:i)}}};case"UPDATE_BASE_RATE":return console.log("Reducer: Updating base rate to:",r.payload),{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,exchange_rates:{...t.resourceData.resource_details.exchange_rates,base_rate:r.payload}}}};case"UPDATE_EXCHANGE_RATE":return{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,exchange_rates:{...t.resourceData.resource_details.exchange_rates,discount_rates:t.resourceData.resource_details.exchange_rates.discount_rates.map(i=>i.id===r.payload.rateId?{...i,...r.payload.changes}:i)}}}};case"ADD_EXCHANGE_RATE":return console.log("Reducer: Adding new discount rate:",r.payload),{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,exchange_rates:{...t.resourceData.resource_details.exchange_rates,discount_rates:[...t.resourceData.resource_details.exchange_rates.discount_rates||[],r.payload]}}}};case"DELETE_EXCHANGE_RATE":return{...t,resourceData:{...t.resourceData,resource_details:{...t.resourceData.resource_details,exchange_rates:{...t.resourceData.resource_details.exchange_rates,discount_rates:t.resourceData.resource_details.exchange_rates.discount_rates.filter(i=>i.id!==r.payload)}}}};default:return t}},Nw=t=>({type:"SET_RESOURCE_DATA",payload:t}),kH=t=>({type:"SET_LOADING",payload:t}),HI=(t,r)=>({type:"SET_SUCCESS_MESSAGE",payload:{message:t,color:r}}),lm=(t,r)=>({type:"UPDATE_RESOURCE_FIELD",field:t,value:r}),ZE=(t,r)=>({type:"UPDATE_ALLOCATION",payload:{allocationTypeId:t,updates:r}}),MH=async(t,r)=>await(await fetch(`${r}/resources/${t}.json`)).json(),LH=async(t,r,i,l)=>(console.log("update resource",i),await fetch(`${r}/resources/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json","X-CSRF-Token":document.querySelector('meta[name="csrf-token"]').content},body:JSON.stringify({resource:i,required_resources:l})})),PH=(t,r)=>{const[i,l]=k.useReducer(DH,{resourceData:null,loading:!0,errors:[],successMessage:{message:"",color:""}}),u=k.useCallback(async(v,h)=>{let y=[h];try{const x=await v.json();x.errors?y=x.errors:x.message&&(y=[x.message])}catch(x){console.error("Error parsing error response:",x)}l({type:"SET_ERRORS",payload:y})},[]),f=k.useCallback(async()=>{l(kH(!0));try{const v=await MH(t,r);l(Nw(v))}catch(v){console.error("Failed to fetch resource data:",v),l({type:"SET_ERRORS",payload:"Failed to fetch resource data. Please try again later."})}},[t,r]);return k.useEffect(()=>{f()},[f]),{state:i,dispatch:l,handleError:u,fetchData:f}},xR=t=>{var r,i,l;return{allowedActionsOptions:((r=t==null?void 0:t.resource_state_types_available)==null?void 0:r.map(u=>({value:u.resource_state_type_id,label:u.display_resource_state_type,additionalInfo:u.action_types.map(f=>f.display_action_type).join(", ")})))||[],resourceTypesOptions:((i=t==null?void 0:t.resource_types_available)==null?void 0:i.map(u=>({value:u.resource_type_id,label:u.display_resource_type})))||[],unitTypesOptions:((l=t==null?void 0:t.unit_types_available)==null?void 0:l.map(u=>({value:u.unit_type_id,label:u.display_unit_type})))||[],availableResources:(t==null?void 0:t.required_resources_available)||[],availableAllocationTypes:(t==null?void 0:t.unassigned_allocation_types)||[]}},FH=(t,r,i,l,u,f,v)=>{const y=(()=>{var R;if(!t)return[];const w=new Set;return(R=t.allocation_types)==null||R.forEach(j=>{var N;(N=j.required_resources)==null||N.forEach(T=>{w.add(T.resource_name)})}),Array.from(w).sort((j,N)=>j.localeCompare(N)).map(j=>({key:j,name:`Require ${j}`,width:150,type:"checkbox"}))})();return{allocationColumns:[{key:"display_name",name:"Allocation Type",width:200},{key:"allowed_actions",name:"Allowed Actions",width:200,type:"select"},{key:"comment",name:"Descriptive Text",width:200,type:"input",tooltip:"Appears below the resource name and allocations description in the form when making a new request"},...y],allocationRows:t!=null&&t.allocation_types?t.allocation_types.map(w=>{var R;return{display_name:w.display_name,allocation_type_id:w.allocation_type_id,allowed_actions:{options:l,value:((R=w.allowed_action)==null?void 0:R.resource_state_type_id)||"",onChange:j=>u(w.allocation_type_id,j)},comment:{value:w.comment||"",onChange:j=>f(w.allocation_type_id,j)},...Object.fromEntries(y.map(j=>{var N;return[j.key,{checked:((N=w.required_resources)==null?void 0:N.some(T=>T.resource_name===j.key))||!1,onChange:T=>v(w.allocation_type_id,j.key,T,w)}]}))}}):[],requiredResourcesColumns:y}},VH=(t,r,i)=>{const{availableResources:l,availableAllocationTypes:u,allowedActionsOptions:f}=xR(t),[v,h]=k.useState(!1),[y,x]=k.useState(!1),[C,w]=k.useState([]),[R,j]=k.useState(""),N=k.useCallback((F,z)=>{i(ZE(F,{allowed_action:{resource_state_type_id:z}}))},[i]),T=k.useCallback((F,z)=>{i(ZE(F,{comment:z}))},[i]),I=k.useCallback((F,z,X,Y)=>{const pe=X?[...Y.required_resources||[],{resource_name:z,required_resource_id:t.required_resources_available.find(ie=>ie.resource_name===z).resource_id}]:(Y.required_resources||[]).filter(ie=>ie.resource_name!==z);i(ZE(F,{required_resources:pe}))},[t,i]);k.useEffect(()=>{if(v&&r){const F=r.allocation_types.flatMap(z=>z.required_resources||[]).map(z=>z.required_resource_id);w(F)}},[v,r]);const M=k.useCallback((F,z)=>{w(X=>z?[...X,F]:X.filter(Y=>Y!==F))},[]),P=k.useCallback(()=>{const F=r.allocation_types.flatMap(pe=>pe.required_resources||[]).map(pe=>pe.required_resource_id),z=C.filter(pe=>!F.includes(pe)),X=F.filter(pe=>!C.includes(pe)),Y=r.allocation_types.map(pe=>{const ie=pe.required_resources||[],ge=z.map(Re=>{const be=l.find(xe=>xe.resource_id===Re);return{resource_name:be.resource_name,required_resource_id:be.resource_id}}),ae=ie.filter(Re=>!X.includes(Re.required_resource_id)).concat(ge.filter(Re=>!ie.some(be=>be.required_resource_id===Re.required_resource_id)));return{...pe,required_resources:ae}});i(Nw({...t,resource_details:{...r,allocation_types:Y}})),w([]),h(!1)},[C,l,r,t,i]),V=k.useCallback(F=>{const z=F.target.value;j(z)},[]),U=k.useCallback(()=>{var X,Y;if(!R)return;const F=u.find(pe=>pe.allocation_type_id.toString()===R),z=(X=r.allocation_types)==null?void 0:X.some(pe=>pe.allocation_type_id===F.allocation_type_id);if(F&&!z){const pe=(Y=f[0])==null?void 0:Y.value,ie=[...r.allocation_types||[],{allocation_type_id:F.allocation_type_id,display_name:F.display_name,allowed_action:{resource_state_type_id:pe},comment:"",required_resources:[]}];i(Nw({...t,resource_details:{...r,allocation_types:ie}})),x(!1)}},[R,u,r,t,i,f]);return{showAddResourceModal:v,setShowAddResourceModal:h,showAddAllocationTypeModal:y,setShowAddAllocationTypeModal:x,selectedNewResource:C,handleSelectNewResource:M,handleSaveResources:P,selectedNewAllocationType:R,handleSelectNewAllocationType:V,handleSaveAllocationType:U,handleAllowedActionChange:N,handleCommentChange:T,handleRequiredResourceChange:I}},BH=(t,r,i,l,u,f)=>k.useCallback(async()=>{var y,x,C;if(!t)return;const v={resource_name:t.resource_name,description:t.description,resource_type_id:t.resource_type_id,unit_type_id:t.unit_type_id,dollar_value:t.dollar_value,allocation_types:t.allocation_types.map(w=>{var R;return{allocation_type_id:w.allocation_type_id,allowed_action:{resource_state_type_id:(R=w.allowed_action)==null?void 0:R.resource_state_type_id},comment:w.comment||""}}),exchange_rates:{base_rate:(y=t.exchange_rates)==null?void 0:y.base_rate,discount_rates:(C=(x=t.exchange_rates)==null?void 0:x.discount_rates)==null?void 0:C.map(w=>({id:w.id,exchange_rate:w.exchange_rate,begin_date:w.begin_date,end_date:w.end_date}))}},h={};t.allocation_types.forEach(w=>{w.required_resources.forEach(R=>{h[R.required_resource_id]||(h[R.required_resource_id]=[]),h[R.required_resource_id].push(w.allocation_type_id)})});try{const w=await LH(r,i,v,h);if(w.ok){const R=await w.json();return f(HI(R.message||"Resource updated successfully!","success")),await l(),!0}else return await u(w,"Failed to update resource"),!1}catch{return f(HI("Error updating resource. Please try again later.","danger")),!1}},[t,r,i,l,u]),zH=(t=!1)=>{const[r,i]=k.useState(t);return{isEditing:r,handleEditingChange:u=>{i(u)}}},$H={"form-wrapper":"_form-wrapper_mu0yh_1"},b0=({show:t,onClose:r,title:i,children:l,onSave:u,buttonText:f,cancelText:v="Cancel",canSave:h=!0})=>t?m.jsx("div",{style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.8)",display:"flex",alignItems:"center",zIndex:1050},children:m.jsx("div",{className:"modal fade in",tabIndex:"-1",role:"dialog","aria-hidden":"true",style:{width:"90%",maxWidth:"600px",maxHeight:"90%",overflow:"auto",backgroundColor:"white",position:"relative"},children:m.jsx("div",{className:"modal-dialog",role:"document",children:m.jsxs("div",{className:"modal-content",children:[m.jsxs("div",{className:"modal-header",children:[m.jsx("button",{type:"button",className:"close","data-dismiss":"modal",onClick:r,"aria-label":"Close",children:m.jsx("h3",{"aria-hidden":"true",className:"text-danger",children:"×"})}),m.jsx("h3",{className:"modal-title",children:i})]}),m.jsx("div",{className:"modal-body",children:l}),m.jsxs("div",{className:"modal-footer",style:{padding:"15px",textAlign:"right",borderTop:"1px solid #e5e5e5",backgroundColor:"#f8f9fa"},children:[m.jsx("button",{className:"btn btn-danger",onClick:r,children:v}),m.jsx("button",{className:"btn btn-success",onClick:u,disabled:!h,children:f})]})]})})})}):null;b0.propTypes={show:Pe.bool.isRequired,onClose:Pe.func.isRequired,title:Pe.string.isRequired,children:Pe.node.isRequired,onSave:Pe.func.isRequired,buttonText:Pe.string,cancelText:Pe.string,canSave:Pe.bool};const yr=({children:t,color:r,dismissable:i=!1})=>m.jsxs("div",{className:`alert alert-${r} mt-3 alert-dismissible show`,role:"alert",children:[t,i&&m.jsx("button",{type:"button",className:"close","data-dismiss":"alert","aria-label":"Close",children:m.jsx("span",{"aria-hidden":"true",children:"×"})})]}),Wp=({label:t,options:r,value:i,onChange:l,...u})=>m.jsxs("div",{className:"form-group",children:[t&&m.jsx("label",{children:t}),m.jsx("select",{className:"form-control",value:i,onChange:l,...u,children:r.map(f=>m.jsxs("option",{value:f.value,children:[f.label,f.additionalInfo&&` - ${f.additionalInfo}`]},f.value))})]});Wp.propTypes={label:Pe.string,options:Pe.arrayOf(Pe.shape({value:Pe.oneOfType([Pe.string,Pe.number]).isRequired,label:Pe.string.isRequired,additionalInfo:Pe.string})).isRequired,value:Pe.oneOfType([Pe.string,Pe.number]),onChange:Pe.func.isRequired};function ym({label:t,type:r="text",value:i,onChange:l,disabled:u=!1,infoText:f="",style:v,inputClassName:h,inputAddon:y}){return m.jsxs(m.Fragment,{children:[t&&m.jsx("label",{children:t}),f&&m.jsx("small",{className:"form-text help-block",children:f}),r==="textarea"?m.jsx("textarea",{className:`form-control ${h||""}`,value:i,onChange:l,disabled:u,rows:"6"}):y?m.jsxs("div",{className:"input-prepend",children:[m.jsx("span",{className:"add-on",children:y}),m.jsx("input",{type:r,className:`form-control ${h||""}`,style:v,value:i,onChange:l,disabled:u})]}):m.jsx("input",{type:r,className:`form-control ${h||""}`,style:v,value:i,onChange:l,disabled:u})]})}const UH="_blurred_16xcy_16",ql={"advanced-settings":"_advanced-settings_16xcy_1","header-wrapper":"_header-wrapper_16xcy_5","content-container":"_content-container_16xcy_11",blurred:UH,"warning-banner":"_warning-banner_16xcy_21","alt-warning-banner":"_alt-warning-banner_16xcy_40 _warning-banner_16xcy_21"},CR=({headerText:t,header:r,children:i,isEditing:l=!1,onEditingChange:u,warningMessage:f=""})=>{const v=t&&t.type==="label";return m.jsxs("div",{className:ql["advanced-settings"],children:[(t||r)&&m.jsxs("div",{className:ql["header-wrapper"],children:[t,r&&m.jsx("div",{className:`${ql["header-buttons-container"]} ${l?"":ql.blurred}`,children:r})]}),m.jsxs("div",{style:{width:"100%"},children:[!l&&m.jsxs("div",{className:v?`${ql["alt-warning-banner"]}`:ql["warning-banner"],children:[m.jsxs("span",{className:ql["warning-text"],children:[m.jsx("strong",{children:"CAUTION! "})," ",f]}),m.jsx("button",{className:"btn btn-danger",onClick:()=>u(!0),children:"I understand the risks"})]}),m.jsx("div",{className:`${ql["content-container"]} ${l?"":ql.blurred}`,children:i})]})]})};CR.propTypes={headerText:Pe.node,header:Pe.node,children:Pe.node.isRequired,isEditing:Pe.bool,onEditingChange:Pe.func.isRequired,warningMessage:Pe.string};const SR=pr.memo(function({resourceDetails:r,resourceTypesOptions:i,unitTypesOptions:l,dispatch:u,isDollarValueEditing:f,onDollarValueEditingChange:v,showDollarValue:h=!0,showResourceId:y=!0,useAdvancedSettings:x=!0}){const C="Dollar Value per SUs",w=h?m.jsx(ym,{label:x?null:C,value:r.dollar_value,onChange:R=>u(lm("dollar_value",R.target.value)),type:"number",inputAddon:"$",inputClassName:"span4"}):null;return m.jsxs(m.Fragment,{children:[m.jsx(ym,{label:"Resource Name",value:r.resource_name,onChange:R=>u(lm("resource_name",R.target.value)),inputClassName:"span8"}),y&&m.jsx(ym,{label:"Resource Repository Key",value:r.resource_repository_key,disabled:!0,inputClassName:"span8"}),x&&h?m.jsx(CR,{headerText:m.jsx("label",{children:C}),isEditing:f,onEditingChange:v,warningMessage:"Dollar value is for reporting and should only be modified if the SU rate changes.",children:w}):w,m.jsx(ym,{label:"Allocations Description",type:"textarea",value:r.description,infoText:"Appears below the resource name in the form when making a new request, as well as under the header Allocations Description in resource catalogs",onChange:R=>u(lm("description",R.target.value)),inputClassName:"span8"}),m.jsx(Wp,{label:"Resource Type",options:i,value:r.resource_type_id,onChange:R=>u(lm("resource_type_id",R.target.value)),className:"span8"}),m.jsx(Wp,{label:"Unit Type",options:l,value:r.unit_type_id,onChange:R=>u(lm("unit_type_id",R.target.value)),className:"span8"})]})});SR.propTypes={resourceDetails:Pe.object.isRequired,resourceTypesOptions:Pe.array.isRequired,unitTypesOptions:Pe.array.isRequired,dispatch:Pe.func.isRequired,isDollarValueEditing:Pe.bool,onDollarValueEditingChange:Pe.func,showDollarValue:Pe.bool,showResourceId:Pe.bool,useAdvancedSettings:Pe.bool};function uO({onClose:t}){const[r,i]=k.useState(!0),[l,u]=k.useState([]),[f,v]=k.useState(null),[h,y]=k.useState(-1),[x,C]=k.useState(null),w=xR(x);w.resourceTypesOptions.unshift({value:0,label:"Select a resource type..."}),w.unitTypesOptions.unshift({value:0,label:"Select a unit type..."}),k.useEffect(()=>{(async()=>{const P=await fetch("/resources/addable.json");i(!1),P.status==200?u(await P.json()):v("Error retrieving resource list.")})()},[]),k.useEffect(()=>{if(h===-1)return C(null);(async()=>{const P=await fetch(`/resources/addable/${h}.json`);P.status==200?C(await P.json()):v("Error retrieving resource details.")})()},[h]);let R=null;r?R=m.jsx("p",{children:"Loading…"}):f!==null?R=m.jsx(yr,{color:"danger",children:f}):l.length==0&&(R=m.jsx(yr,{children:"There are currently no resources available to add."}));const j=[{value:-1,label:"Select a resource..."}].concat(l.map(P=>({value:P.xras_cider_resource_id,label:P.resource_descriptive_name}))),N=x?x.resource_details:null,T=!f&&N&&N.resource_name.length>0&&N.resource_type_id>0&&N.unit_type_id>0,I=P=>{P.type=="UPDATE_RESOURCE_FIELD"&&C({...x,resource_details:{...x.resource_details,[P.field]:P.value}})},M=()=>{(async()=>{const P=await fetch("/resources",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-Token":document.querySelector('meta[name="csrf-token"]').content},body:JSON.stringify({...N,resource_repository_key:h})});if(P.status==200){const V=await P.json();window.location=`/resources/${V.resource_id}`}else v("Error saving resource.")})()};return R===null&&(R=m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:"Select a Resource to Add"}),m.jsx(Wp,{options:j,onChange:P=>y(parseInt(P.target.value))}),!x&&h!==-1?m.jsx("p",{children:"Loading…"}):null,x&&m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:"Resource Properties"}),m.jsx("p",{style:{fontStyle:"italic",fontWeight:"bold"},children:"Any modifications to these resource properties will be applied globally and impact resources on other all allocations process"}),m.jsx("div",{className:$H["form-wrapper"],children:m.jsx(SR,{resourceDetails:N,resourceTypesOptions:w.resourceTypesOptions,unitTypesOptions:w.unitTypesOptions,showResourceId:!1,showDollarValue:!1,dispatch:I})})]})]})),m.jsx(b0,{show:!0,onClose:t,title:"Add a Resource from CIDeR",onSave:M,buttonText:"Save",canSave:T,children:R})}uO.propTypes={onClose:Pe.func.isRequired};function HH({availableResources:t,canAdd:r=!1,relativeUrlRoot:i}){const l=k.useMemo(()=>CH(t),[t]),[u,f]=k.useState(l),[v,h]=k.useState(!1),y=k.useRef(null),x=k.useRef(null);k.useEffect(()=>{f(l)},[l]);const C=(j,N)=>{y.current=N},w=(j,N)=>{if(j.preventDefault(),y.current===N)return;const T=[...u],I=T[y.current];T.splice(y.current,1),T.splice(N,0,I),y.current=N,f(T);const{clientY:M}=j,P=130;M<P?kI(-1,x):window.innerHeight-M<P?kI(1,x):$E(x)},R=()=>{y.current=null,$E(x),xH(i,u)};return k.useEffect(()=>()=>$E(x),[]),m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:ls["resources-container"],children:[r&&m.jsx("button",{className:"btn btn-primary pull-right",onClick:()=>h(!0),children:"Add a Resource from CIDeR"}),m.jsx("h2",{children:"Select a resource from the list to modify"}),m.jsx("p",{className:ls["drag-instruction"],children:"Drag items to reorder the list."}),m.jsxs("div",{className:ls["resources-list"],children:[m.jsxs("div",{className:ls["resources-header"],children:[m.jsx("span",{className:ls["header-name"],children:"Resource Name"}),m.jsx("span",{className:ls["header-repo"],children:"Repository Key"})]}),u.map((j,N)=>m.jsxs("div",{className:`${ls["resources-item"]}`,draggable:!0,onDragStart:T=>C(T,N),onDragOver:T=>w(T,N),onDrop:R,children:[m.jsx("span",{className:ls["drag-handle"]}),m.jsx("span",{className:ls["resource-name"],children:m.jsx("a",{href:`${i}/resources/${j.resource_id}`,className:ls["resource-link"],children:j.display_resource_name})}),m.jsx("span",{className:ls["resource-repo"],children:j.resource_repository_key||"N/A"})]},j.resource_id))]})]}),v&&m.jsx(uO,{onClose:()=>h(!1)})]})}function nh(){return m.jsx("div",{className:"spinner-border",role:"status",children:m.jsx("span",{className:"visually-hidden",children:"Loading..."})})}const GH="_grid_afccc_1",WH="_important_afccc_30",XH="_input_afccc_34",YH="_edited_afccc_38",ZH="_disabled_afccc_46",qH="_scroll_afccc_59",Gd={grid:GH,important:WH,input:XH,edited:YH,disabled:ZH,scroll:qH};function JH({column:t,row:r,style:i={}}){const l=t.format?t.format(r[t.key],r):r[t.key],u=["cell"];return t.class&&u.push(t.class),t.rowClass&&u.push(t.rowClass(r)),m.jsx("td",{className:u.join(" "),style:i,children:l})}const ER=({title:t,placement:r,children:i})=>(k.useEffect(()=>($('[data-toggle="tooltip"]').tooltip(),()=>{$('[data-toggle="tooltip"]').tooltip("destroy")}),[]),m.jsx("span",{"data-toggle":"tooltip","data-placement":r,title:t,style:{margin:"10px"},children:i}));ER.propTypes={title:Pe.string.isRequired,placement:Pe.oneOf(["top","bottom","left","right"]),children:Pe.node.isRequired};ER.defaultProps={placement:"top"};const QH="_datepicker_19wnv_1",KH="_error_19wnv_1",GI={datepicker:QH,error:KH},eG=({value:t,onChange:r,disabled:i=!1,style:l,className:u="",minDate:f="",maxDate:v="",error:h=""})=>{const y=h;return m.jsx("div",{className:`w-full ${u}`,children:m.jsx("input",{type:"date",style:l,className:`${GI.datepicker} ${y?GI.error:""}`,value:t||"",onChange:x=>r(x.target.value),disabled:i,min:f||"1900-01-01",max:v||"2100-12-31"})})},um=(t,r,i)=>{if(r.onChange){r.onChange(i,t);return}const l=t[r.key];l!=null&&l.onChange&&l.onChange(i)},tG={text:JH,select:({column:t,row:r,style:i})=>m.jsx("td",{style:i,children:m.jsx(Wp,{label:"",options:r[t.key].options,value:r[t.key].value,onChange:l=>um(r,t,l.target.value),style:{width:"100%",margin:0}})}),input:({column:t,row:r,style:i})=>m.jsx("td",{style:i,children:m.jsx(ym,{label:"",type:"text",disabled:r[t.key].disabled,value:r[t.key].value,onChange:l=>um(r,t,l.target.value),style:{width:"92%",margin:0}})}),checkbox:({column:t,row:r,style:i})=>m.jsx("td",{style:i,children:m.jsx("input",{type:"checkbox",checked:r[t.key].checked,onChange:l=>um(r,t,l.target.checked)})}),date:({column:t,row:r,style:i})=>{const l=r[t.key];return!(l!=null&&l.value)&&typeof l!="object"?m.jsx("td",{style:i,children:l||""}):m.jsx("td",{style:i,children:m.jsx(eG,{value:l.value,onChange:u=>um(r,t,u),disabled:l.disabled,style:{width:"92%",margin:0},minDate:t.minDate,maxDate:t.maxDate,error:l.error})})},action:({column:t,row:r,style:i})=>m.jsx("td",{style:i,children:r.rate_type==="Discount"&&m.jsx("button",{className:"btn btn-link text-danger",onClick:()=>{var l;return um(r,t,(l=r[t.key])==null?void 0:l.id)},children:m.jsx("i",{className:"fa fa-trash"})})})};function su({columns:t,rows:r,classes:i,frozenColumns:l=0,minWidth:u,rowClasses:f=[],scroll:v=!0,scrollBehavior:h="smooth",scrollRowIndex:y=0}){const x=k.useRef();k.useLayoutEffect(()=>{if(!v||!x.current)return;const T=x.current.querySelector(`tbody tr:nth-child(${y+1})`);T&&T.scrollIntoView({behavior:h,block:"nearest",inline:"nearest"})},[v,y,h]);const C=[0];for(let T=0;T<l;T++)C[T+1]=C[T]+(t[T].width||100);const w=(T,I)=>T<l?{position:"sticky",left:`${C[T]}px`,minWidth:`${t[T].width||100}px`,width:`${t[T].width||100}px`,zIndex:I||1}:{},R=t.map((T,I)=>m.jsxs("th",{className:T.headerClass||T.class||"",style:w(I,100),children:[T.formatHeader?T.formatHeader(T.name,T):T.name,T.tooltip&&m.jsx(ER,{title:T.tooltip,placement:"bottom",children:m.jsx("i",{className:"icon-info-sign"})})]},T.key)),j=r.map((T,I)=>{const M=t.map((P,V)=>{const U=tG[P.type||"text"];return m.jsx(U,{column:P,row:T,style:w(V)},P.key)});return m.jsx("tr",{className:f[I]||"",children:M},I)}),N={};return u&&(N.minWidth=u),m.jsx("div",{className:`${Gd.grid} ${v?Gd.scroll:""} ${i||""}`,ref:x,children:m.jsxs("table",{className:"table table-bordered",style:N,children:[m.jsx("thead",{children:m.jsx("tr",{children:R})}),m.jsx("tbody",{children:j})]})})}const Iw={"header-buttons":"_header-buttons_15oxx_1","allocation-types-grid":"_allocation-types-grid_15oxx_6","vertical-align-center":"_vertical-align-center_15oxx_10"},cO=({onAddAllocationType:t,onAddRequiredResource:r})=>m.jsxs("div",{className:Iw["header-buttons"],children:[m.jsxs("button",{className:"btn btn-primary",onClick:t,children:[m.jsx("i",{className:"fa fa-plus"})," Add Allocation Type"]}),m.jsxs("button",{className:"btn btn-primary",onClick:r,children:[m.jsx("i",{className:"fa fa-plus"})," Add Required Resource"]})]});cO.propTypes={headerText:Pe.node,onAddAllocationType:Pe.func.isRequired,onAddRequiredResource:Pe.func.isRequired};const dO=pr.memo(function({columns:r,rows:i}){return m.jsxs("div",{className:Iw["allocation-types-grid"],children:[m.jsx(su,{columns:r,rows:i,rowClasses:Array(i.length).fill(Iw["vertical-align-center"]),scroll:!1}),m.jsx("p",{style:{margin:"0",fontStyle:"italic",fontWeight:"bold"},children:"Note: You may need to contact your Allocations Coordinator if you have added this resource to an allocation type."})]})});dO.propTypes={columns:Pe.array.isRequired,rows:Pe.array.isRequired};const Pp={"exchange-rates-grid":"_exchange-rates-grid_5qkd5_1","header-container":"_header-container_5qkd5_5","header-buttons":"_header-buttons_5qkd5_11","vertical-align-center":"_vertical-align-center_5qkd5_18","error-summary":"_error-summary_5qkd5_35"},fO=pr.memo(function({columns:r,rows:i,onAddDiscountRate:l,dateErrors:u=[]}){return m.jsxs("div",{className:Pp["exchange-rates-grid"],children:[m.jsxs("div",{className:Pp["header-container"],children:[m.jsx("h2",{className:Pp["header-title"],children:"Exchange Rates"}),m.jsx("div",{className:Pp["header-buttons"],children:m.jsxs("button",{className:"btn btn-primary",onClick:l,children:[m.jsx("i",{className:"fa fa-plus"})," Add Discount Rate"]})})]}),m.jsx(su,{columns:r,rows:i,rowClasses:Array(i.length).fill(Pp["vertical-align-center"]),scroll:!1}),u.length>0&&m.jsx("div",{className:Pp["error-summary"],children:m.jsx("ul",{children:u.map((f,v)=>m.jsx("li",{children:f},v))})})]})});fO.propTypes={columns:Pe.array.isRequired,rows:Pe.array.isRequired,onAddDiscountRate:Pe.func.isRequired,dateErrors:Pe.array};const nG=(t,r)=>{const i=k.useCallback(j=>{var T,I;r({type:"DELETE_EXCHANGE_RATE",payload:j}),(((I=(T=t==null?void 0:t.resource_details)==null?void 0:T.exchange_rates)==null?void 0:I.discount_rates.filter(M=>M.id!==j))||[]).forEach(M=>{M.begin_date&&M.end_date&&r({type:"UPDATE_EXCHANGE_RATE",payload:{rateId:M.id,changes:{start_date_error:"",end_date_error:""}}})})},[r,t]),l=[{key:"rate_type",name:"Rate Type",width:150},{key:"rate",name:"Exchange Rate",width:100,type:"input",tooltip:"Exchange rate is the cost in ACCESS Credits of one resource unit. ACCESS Credits / exchange rate = resource units"},{key:"conversion",name:"Resource Units per ACCESS Credit",width:150},{key:"start_date",name:"Start Date",width:150,type:"date",minDate:new Date().toISOString().split("T")[0]},{key:"end_date",name:"End Date",width:150,type:"date",minDate:new Date().toISOString().split("T")[0]},{key:"actions",name:"",width:80,type:"action",onChange:i}],u=j=>{r({type:"UPDATE_BASE_RATE",payload:j})},f=(j,N)=>{const T={exchange_rate:N},I={};N?I.rate_error="":I.rate_error="Exchange Rate cannot be empty",r({type:"UPDATE_EXCHANGE_RATE",payload:{rateId:j,changes:{...T,...I}}})},v=()=>{var T,I;const j=[];return(((I=(T=t==null?void 0:t.resource_details)==null?void 0:T.exchange_rates)==null?void 0:I.discount_rates)||[]).forEach(M=>{M.start_date_error&&j.push(M.start_date_error),M.end_date_error&&j.push(M.end_date_error),M.rate_error&&j.push(M.rate_error)}),j.filter((M,P)=>M&&M!==""&&(!M.includes("overlaps")||j.indexOf(M)===P))},h=j=>{const N=new Date(j);return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",month:"numeric",day:"numeric",year:"numeric"}).format(N)},y=(j,N,T,I)=>{const M=new Date(j).getTime(),P=new Date(N).getTime(),V=new Date(T).getTime(),U=new Date(I).getTime();return M<=U&&V<=P},x=(j,N)=>{let T="";if(j.begin_date&&j.end_date){const I=N.filter(M=>M.id!==j.id);for(const M of I)if(M.begin_date&&M.end_date&&y(j.begin_date,j.end_date,M.begin_date,M.end_date)){T=`The selected date range (${h(j.begin_date)} to ${h(j.end_date)}) overlaps with an existing discount rate (${h(M.begin_date)} to ${h(M.end_date)})`;break}}return T},C=(j,N,T)=>{var ie,ge;const I={start_date:"begin_date",end_date:"end_date"},M=ae=>{const Re=new Date(ae);return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",month:"numeric",day:"numeric",year:"numeric"}).format(Re)},P=((ge=(ie=t==null?void 0:t.resource_details)==null?void 0:ie.exchange_rates)==null?void 0:ge.discount_rates)||[],V=P.find(ae=>ae.id===j);if(!V)return;const U={[I[N]]:T},F={},z=N==="end_date",X=()=>{if(!T)return F[`${N}_error`]="Date cannot be empty or invalid",!1;const ae=l.find(Ae=>Ae.key===N),Re=(ae==null?void 0:ae.minDate)||"1900-01-01",be=(ae==null?void 0:ae.maxDate)||"2100-12-31",xe=z&&V.begin_date?V.begin_date:Re;return T<xe?(F[`${N}_error`]=`${N.replace("_"," ")} ${M(T)} cannot be before ${M(xe)}`,!1):T>be?(F[`${N}_error`]=`${N.replace("_"," ")} cannot be after ${M(be)}`,!1):(F[`${N}_error`]="",!0)},Y=()=>{const ae=N==="end_date"?T:V.end_date;if(N==="start_date"&&ae){if(T>ae)return F.end_date_error=`end date ${M(ae)} cannot be before ${M(T)}`,!1;F.end_date_error=F.end_date_error||""}return!0},pe=()=>{console.log("validating overlaps");const ae=N==="start_date"?T:V.begin_date,Re=N==="end_date"?T:V.end_date;if(ae&&Re){const be=x({...V,begin_date:ae,end_date:Re},P);return F.start_date_error=be,F.end_date_error=be,!be}return!0};if(!X()){r({type:"UPDATE_EXCHANGE_RATE",payload:{rateId:j,changes:{...U,...F}}});return}Y(),pe(),z&&!V.begin_date?F.start_date_error="Date cannot be empty or invalid":!z&&!V.end_date&&(F.end_date_error="Date cannot be empty or invalid"),r({type:"UPDATE_EXCHANGE_RATE",payload:{rateId:j,changes:{...U,...F}}})},w=()=>{var F,z;const j=((z=(F=t==null?void 0:t.resource_details)==null?void 0:F.exchange_rates)==null?void 0:z.discount_rates)||[];let T=new Date;j.forEach(X=>{if(X.end_date){const Y=new Date(X.end_date);Y>T&&(T=Y)}});const I=new Date(T);I.setDate(I.getDate()+1);const M=I.toISOString().split("T")[0],P=new Date(I);P.setDate(P.getDate()+15);const V=P.toISOString().split("T")[0],U={id:Date.now(),exchange_rate:"1.0",begin_date:M,end_date:V,is_new:!0};r({type:"ADD_EXCHANGE_RATE",payload:U})};return{exchangeRateColumns:l,exchangeRateRows:(()=>{var V,U;const j=(V=t==null?void 0:t.resource_details)==null?void 0:V.exchange_rates,N=(j==null?void 0:j.base_rate)??"",T=(j==null?void 0:j.discount_rates)||[],I=new Date().toISOString().split("T")[0],M=((U=t==null?void 0:t.resource_details)==null?void 0:U.unit_type)||"Resource Units",P=F=>!F||Number(F)===0?"-":`${(1/Number(F)).toFixed(2)} ${M}`;return[{rate_type:"Base Rate",rate:{value:N.toString(),onChange:F=>u(F)},conversion:P(N)},...T.map(F=>{var pe;const z=F.is_new||F.begin_date>I,X=z||F.begin_date==="",Y=F.is_new||F.end_date>=I||F.end_date==="";return{rate_type:"Discount",rate:{value:((pe=F.exchange_rate)==null?void 0:pe.toString())||"",onChange:z?ie=>f(F.id,ie):null,disabled:!z},conversion:P(F.exchange_rate),start_date:{value:F.begin_date||"",onChange:ie=>C(F.id,"start_date",ie),error:F.start_date_error,disabled:!X},end_date:{value:F.end_date||"",onChange:ie=>C(F.id,"end_date",ie),error:F.end_date_error,disabled:!Y},actions:{id:F.id}}})]})(),handleAddDiscountRate:w,handleDeleteRate:i,dateErrors:v()}};function pO({resourceId:t,relativeUrlRoot:r,setExternalSubmit:i}){const{state:l,dispatch:u,handleError:f,fetchData:v}=PH(t,r),{isEditing:h,handleEditingChange:y}=zH(),{resourceData:x,loading:C,errors:w,successMessage:R}=l,j=x==null?void 0:x.resource_details,N=x==null?void 0:x.uses_exchange_rates,{allowedActionsOptions:T,resourceTypesOptions:I,unitTypesOptions:M,availableResources:P,availableAllocationTypes:V}=xR(x),{showAddResourceModal:U,setShowAddResourceModal:F,showAddAllocationTypeModal:z,setShowAddAllocationTypeModal:X,selectedNewResource:Y,handleSelectNewResource:pe,handleSaveResources:ie,selectedNewAllocationType:ge,handleSelectNewAllocationType:ae,handleSaveAllocationType:Re,handleAllowedActionChange:be,handleCommentChange:xe,handleRequiredResourceChange:Ae}=VH(x,j,u),{exchangeRateColumns:Le,exchangeRateRows:ne,handleAddDiscountRate:Oe,dateErrors:G}=nG(x,u),Z=BH(j,t,r,v,f,u);k.useEffect(()=>{i&&G.length==0?i(Z):i(null)},[Z,i,G]);const{allocationColumns:re,allocationRows:Ce}=FH(j,P,Y,T,be,xe,Ae),[we,Te]=k.useState(!1);return C?m.jsx(nh,{}):w.length>0?m.jsx("div",{children:w.map((Ie,ue)=>m.jsx(yr,{color:"danger",dismissable:!0,children:Ie},ue))}):x?m.jsxs("div",{className:"edit-resource",children:[R.message&&m.jsx(yr,{color:R.color,dismissable:!0,children:R.message}),m.jsxs("div",{children:[m.jsx("h2",{children:"Resource Propeties"}),m.jsx("div",{style:{marginBottom:"0.75rem"},children:m.jsx("p",{style:{margin:"0",fontStyle:"italic",fontWeight:"bold"},children:"Any modifications to these resource properties will be applied globally and impact resources on other all allocations process"})}),m.jsx(SR,{resourceDetails:j,resourceTypesOptions:I,unitTypesOptions:M,dispatch:u,isDollarValueEditing:we,onDollarValueEditingChange:Te})]}),N&&m.jsx(fO,{columns:Le,rows:ne,onAddDiscountRate:Oe,dateErrors:G}),m.jsx(CR,{headerText:m.jsx("h2",{children:"Allocation Types"}),header:m.jsx(cO,{onAddAllocationType:()=>h&&X(!0),onAddRequiredResource:()=>h&&F(!0)}),isEditing:h,onEditingChange:y,warningMessage:`Incorrect allocations
|
|
290
290
|
process settings can make a resource unavailable for allocation.
|
|
291
291
|
Please proceed with caution.`,children:m.jsx(dO,{columns:re,rows:Ce})}),m.jsx(b0,{show:U,onClose:()=>F(!1),title:"Add Required Resource",onSave:ie,buttonText:"Save",children:m.jsx("div",{children:P.map(Ie=>m.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[m.jsx("input",{type:"checkbox",style:{margin:0},checked:Y.includes(Ie.resource_id),onChange:ue=>pe(Ie.resource_id,ue.target.checked)}),Ie.resource_name]},Ie.resource_id))})}),m.jsx(b0,{show:z,onClose:()=>X(!1),title:"Add Allocation Type",onSave:Re,buttonText:"Save",children:m.jsx(Wp,{label:"Select Allocation Type",options:[{value:"",label:"Select an allocation type to add",disabled:!0},...V.map(Ie=>({value:Ie.allocation_type_id,label:Ie.display_name}))],value:ge,onChange:ae})})]}):m.jsx("div",{children:"No resource data available."})}pO.propTypes={resourceId:Pe.number.isRequired,relativeUrlRoot:Pe.string.isRequired,setExternalSubmit:Pe.func};const ta={error:"error",pending:"pending",success:"success"},x0=t=>t.endDate||t.startDate||(t.actions[0]||{}).entryDate,WI=t=>`${{pi:"01",co_pi:"02",allocation_manager:"03"}[t.role]||"04"} ${t.lastName}, ${t.firstName}`,rG=(t,{grantNumber:r,projectManager:i,requestMasterId:l,requests:u,title:f,users:v},h)=>{r=r||l,u.sort((C,w)=>x0(C)>x0(w)?-1:1);const y=u.find(C=>C.timeStatus=="current"),x=y?y.requestId:null;t.projects[r]={currentRequestId:x,grantNumber:r,isManager:i,requestsList:u.map(C=>{const{actions:w,allocationType:R,endDate:j,requestId:N,startDate:T,status:I}=C,M=w.map(({entryDate:P})=>P).sort()[0].split("T")[0];return aG(t,C,{entryDate:M,grantNumber:r}),{allocationType:R,endDate:j,entryDate:M,requestId:N,startDate:T,status:I}}),selectedRequestId:x||u[0].requestId,status:h,tab:"overview",title:f,users:v.map(({email:C,firstName:w,lastName:R,organization:j,resources:N,role:T,username:I})=>{const M=N.filter(z=>z.userAccountState=="active"&&z.unitType!="ACCESS Credits"),P=M.map(z=>z.xrasResourceId),V=M.filter(z=>z.resourceProviderState=="pending-active").map(z=>z.xrasResourceId),U=N.filter(z=>z.userAccountState!="active").map(z=>z.xrasResourceId),F={};for(let z of M)F[z.xrasResourceId]=z.resourceUsername;return{email:C,firstName:w,initialResourceIds:[...P],initialRole:T,lastName:R,organization:j,resourceAccountPendingIds:V,resourceAccountInactiveIds:U,resourceIds:P,resourceUsernames:F,role:T,username:I}}).sort((C,w)=>WI(C)<WI(w)?-1:1),usersNewRowIndex:0,usersStatus:null},t.projects[r].currentUser=t.projects[r].users.find(({username:C})=>C==t.username)},aG=(t,{actions:r,allocationType:i,allowedActions:l,endDate:u,requestId:f,requestType:v,resources:h,startDate:y,status:x,timeStatus:C},{entryDate:w,grantNumber:R})=>{h=h||[];const j={actions:r.map(({actionId:I,actionStatusType:M,actionType:P,allowedOperations:V,approvedStartDate:U,detailAvailable:F,entryDate:z,isRequest:X,requestedStartDate:Y,resources:pe})=>({actionId:I,allowedOperations:V,detailAvailable:F,date:(z||U||Y).split("T")[0],deleteStatus:null,isRequest:X,resources:pe.map(Aw).sort(g0),showDeleteModal:!1,status:M,type:P})),allocationType:i,allowedActions:iG(l),endDate:u,entryDate:w,exchangeActionId:null,exchangeStatus:null,grantNumber:R,isMaximize:i=="Maximize",requestId:f,resources:h.map(Aw).filter(I=>I.isCredit||I.allocated>0).sort(g0),resourcesReason:"",returnedForCorrections:!!r.find(I=>I.returnedForCorrections),returnedForCorrectionsNotes:r.map(I=>I.adminComments).join(","),showActionsModal:!1,showConfirmModal:!1,showResourcesModal:!1,startDate:y,status:x,timeStatus:C,type:v,usageDetail:null,usageDetailStatus:null,usesCredits:["Explore","Discover","Accelerate"].includes(i)};let N={};for(let I of j.actions)if(["Exchange","Transfer"].includes(I.type)&&["Submitted","Under Review"].includes(I.status)){j.exchangeActionId=I.actionId;for(let M of I.resources)N[M.resourceId]=M;for(let M of j.resources)M.resourceId in N&&(M.requested+=N[M.resourceId].requested,delete N[M.resourceId]);j.resources.push(...Object.values(N).map(M=>({...M,isNew:!0})));break}const T=j.allowedActions.Exchange||j.allowedActions.Transfer;if(T){N={};for(let I of T.resources)N[I.resourceId]=I;for(let I of j.resources)I.resourceId in N&&(I.questions=N[I.resourceId].questions||[])}!j.usesCredits&&h.length&&j.resources.push({allocated:0,decimalPlaces:0,exchangeRates:{base:{type:"base",unitCost:1},current:{type:"base",unitCost:1}},icon:"credit",isActive:!0,isBoolean:!1,isCredit:!0,isFake:!0,name:"Credit Equivalents",requested:0,requires:[],resourceId:0,unit:"Credit Equivalents",used:0}),t.requests[f]=j},iG=t=>{const r={};for(let{actionType:i,allowedResources:l,opportunityId:u,opportunityName:f}of t){let v={name:i,resources:l.map(Aw).sort(g0),opportunityId:u,opportunityName:f};i in r?(Array.isArray(r[i])||(r[i]=[r[i]]),r[i].push(v)):r[i]=v}return"Transfer"in r&&!("Exchange"in r)&&(r.Exchange=r.Transfer),r},XI=(t,r)=>t.relativeOrder<r.relativeOrder?-1:1,Aw=({allocationState:t,amountAllocated:r,amountApproved:i,amountRequested:l,amountUsed:u,attributeSets:f,baseExchangeRate:v,currentExchangeRate:h,currentExchangeRateEndDate:y,currentExchangeRateType:x,dependentResourceXrasIds:C,displayResourceName:w,endDate:R,exchangeRate:j,organizationId:N,organizationFaviconUrl:T,organizationName:I,resourceRepositoryKey:M,resourceType:P,startDate:V,unitType:U,userGuideUrl:F,xrasResourceId:z})=>{const X=U=="[Yes = 1, No = 0]",Y=U=="ACCESS Credits";return{allocated:$p(II(r,i)||0,0,"floor"),decimalPlaces:0,endDate:R,exchangeRates:{base:{type:"base",unitCost:X?0:v||j},current:{endDate:y,type:(x||"base").toLowerCase(),unitCost:X?0:h||j}},icon:Y?"credit":P.toLowerCase(),isActive:t=="active",isBoolean:X,isCredit:Y,isFake:!1,isUnderReview:!1,isNew:!1,name:w.trim(),questions:(f||[]).filter(({isActive:pe})=>pe).sort(XI).map(pe=>({attributeSetId:pe.attributeSetId,attributes:pe.attributes.sort(XI).map(ie=>({required:ie.isRequired,resourceAttributeId:ie.resourceAttributeId,label:ie.attributeName})),fieldType:pe.attributeSetRelationType,label:pe.attributeSetName,resourceId:z,values:[]})),resourceProvider:{organizationId:N,name:I,favicon:T},requested:$p(II(l,r)||0,0,"floor"),requires:C||[],resourceId:z,resourceRepositoryKey:M,startDate:V,type:P,unit:U,used:$p(u||0,0,"ceil"),userGuideUrl:F}},hO=(t,r)=>(t=[...t].sort(),r=[...r].sort(),t.length===r.length&&t.every((i,l)=>i===r[l])),Vb=(t,r)=>{const i=ea(t,r);for(let l of i.actions)if(l.actionId==r.payload.actionId)return l},Ks=(t,r)=>t.projects[r.payload.grantNumber],ea=(t,r)=>t.requests[r.payload.requestId],oG=(t,r)=>Ks(t,r).users.find(({username:i})=>i==r.payload.username),jw=({allocated:t,isActive:r,isCredit:i})=>t>0&&r&&!i,YI=t=>t.hasChanges=t.isNew||t.role!=t.initialRole||!hO(t.resourceIds,t.initialResourceIds),vO=()=>document.querySelector("meta[name=csrf-token]").content,sG=async t=>{const r=new URLSearchParams({q:t});return(await(await fetch(`${Jt.routes.search_people_path()}?${r}`)).json()).map(({email:l,first_name:u,last_name:f,username:v,organization:h})=>({email:l,firstName:u,lastName:f,username:v,organization:h}))},Kb=Di("api/fetchProjectsList",async(t,{rejectWithValue:r})=>{const i=await fetch(`${Jt.routes.projects_path()}.json`);return i.status==200?{username:t,projectsList:(await i.json()).result}:r({})}),mO=Di("api/fetchProjectDetail",async({grantNumber:t},{rejectWithValue:r})=>r({grantNumber:t})),gO=Di("api/fetchRequestDetail",async({grantNumber:t,requestId:r},{rejectWithValue:i})=>i({grantNumber:t,requestId:r})),e0=Di("api/fetchUsageDetail",async({grantNumber:t,requestId:r,resourceRepositoryKey:i},{rejectWithValue:l})=>{const u=await fetch(`${Jt.routes.usage_detail_path(t,i)}.json`);return u.status==200?{grantNumber:t,requestId:r,resourceRepositoryKey:i,usageDetail:(await u.json()).usage}:l({grantNumber:t,requestId:r,resourceRepositoryKey:i})}),t0=Di("api/deleteAction",async({actionId:t,requestId:r},{getState:i,rejectWithValue:l})=>{const u=i().api.requests[r],f=u.actions.find(x=>x.actionId==t);if(!f||!f.allowedOperations||!f.allowedOperations.includes("Delete"))return l({actionId:t,requestId:r});const v=Jt.routes.request_action_path(u.requestId,f.actionId),h={_method:"delete",authenticity_token:vO()};return(await fetch(v,{body:Object.keys(h).map(x=>`${encodeURIComponent(x)}=${encodeURIComponent(h[x])}`).join("&"),headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},method:"POST"})).status==200?{actionId:t,requestId:r}:l({actionId:t,requestId:r})}),n0=Di("api/saveResources",async({requestId:t},{getState:r,rejectWithValue:i})=>{const l=r().api.requests[t],u={},f={};for(let{allocated:x,isFake:C,questions:w,requested:R,resourceId:j}of l.resources)if(R!=x&&!C){u[j]={resource_id:j,requested:1,amount:R-x};for(let{attributes:N,values:T,fieldType:I}of w)if(T.length){let M=N[0].resourceAttributeId,P=["drop_down","single_sel","multi_sel"].includes(I),U={resource_attribute_id:I=="multi_sel"?T:P?T[0]:M};P||(U.attribute_value=T[0]),f[M]=U}}const v={authenticity_token:vO(),request_action:{action_type:l.allowedActions.Exchange.name,user_comments:l.resourcesReason,resource_attributes:f},requested_resources:u},h=l.exchangeActionId?Jt.routes.request_action_path(l.requestId,l.exchangeActionId):Jt.routes.request_actions_path(l.requestId),y=await fetch(`${h}.json`,{body:JSON.stringify(v),headers:{"Content-Type":"application/json"},method:l.exchangeActionId?"PUT":"POST"});if(y.status==200){const x=parseInt(y.url.split("/").pop(),10);return{requestId:t,exchangeActionId:x}}return i({requestId:t})}),r0=Di("api/saveUsers",async({grantNumber:t},{getState:r,rejectWithValue:i})=>{const u=r().api.projects[t].users,f=u.filter(x=>!hO(x.resourceIds,x.initialResourceIds)||x.isNew).length==0?[]:u.map(x=>({username:x.username,resources:x.resourceIds})),v=u.filter(x=>x.role!=x.initialRole).map(x=>({username:x.username,role:Ew[x.role],initialRole:Ew[x.initialRole]})),h={grantNumber:t,resourceChanges:f,roleChanges:v,authenticity_token:document.querySelector("meta[name=csrf-token]").content};return(await fetch(Jt.routes.projects_save_users_path(),{method:"POST",body:JSON.stringify(h),headers:{"Content-Type":"application/json"}})).status==200?{grantNumber:t}:i({grantNumber:t})}),yO=$0({name:"api",initialState:{error:null,projectsList:[],projectListLoading:!1,projects:{},requests:{},username:null},reducers:{addResource:(t,r)=>{const{resourceId:i}=r.payload,l=ea(t,r),u=l.allowedActions.Exchange;if(!u)return;const f={};for(let y of u.resources)f[y.resourceId]=y;const v=l.resources.map(y=>y.resourceId),h=[i,...f[i].requires||[]].filter(y=>y in f&&!v.includes(y));l.resources.push(...h.map(y=>({...f[y],allocated:0,isNew:!0,used:0,requested:0})))},addUser:(t,r)=>{const i=Ks(t,r),l=t.requests[i.currentRequestId],{user:u}=r.payload;i.users.map(({username:f})=>f).includes(u.username)||(i.users.push({...u,resourceIds:l.resources.filter(jw).map(f=>f.resourceId),role:"user",initialResourceIds:[],initialRole:"user",hasChanges:!0,isNew:!0}),i.usersNewRowIndex=i.users.length-1)},closeUsageDetailModal:(t,r)=>{const i=ea(t,r);i.usageDetail=null,i.usageDetailStatus=null},resetResources:(t,r)=>{const i=ea(t,r);i.resourcesReason="",i.resources=i.resources.filter(l=>l.isCredit||l.allocated).map(l=>({...l,requested:l.allocated}))},resetUsers:(t,r)=>{const i=Ks(t,r);i.users=i.users.filter(({isNew:l})=>!l).map(l=>({...l,resourceIds:[...l.initialResourceIds],role:l.initialRole,hasChanges:!1}))},setRequest:(t,r)=>{const i=Ks(t,r);i&&(i.selectedRequestId=r.payload.requestId,i.tab=="users"&&i.currentRequestId!=i.selectedRequestId&&(i.tab="overview"))},setResourceQuestionValues:(t,r)=>{const{attributeSetId:i,resourceId:l,values:u}=r.payload,f=ea(t,r);for(let v of f.resources)if(v.resourceId==l){for(let h of v.questions)if(h.attributeSetId==i){h.values=u;break}break}},setResourceRequest:(t,r)=>{const{resourceId:i,requested:l}=r.payload,u=ea(t,r);let f,v=0;for(let h of u.resources)h.resourceId==i&&(h.requested=l),h.isCredit?(f=h,v+=h.allocated*h.exchangeRates.base.unitCost):v-=Rw(h,"difference");f&&(f.requested=$p(v,f.decimalPlaces,"floor"))},setResourcesReason:(t,r)=>{const i=ea(t,r);i.resourcesReason=r.payload.reason},setTab:(t,r)=>{const i=Ks(t,r);i&&(i.tab=r.payload.tab)},setUserRole:(t,r)=>{const i=oG(t,r);i.role=r.payload.role,YI(i)},toggleActionsModal:(t,r)=>{const i=ea(t,r);i.showActionsModal=!i.showActionsModal},toggleConfirmModal:(t,r)=>{const i=ea(t,r);i.showConfirmModal=!i.showConfirmModal},toggleDeleteModal:(t,r)=>{const i=Vb(t,r);i.showDeleteModal=!i.showDeleteModal},toggleResourcesModal:(t,r)=>{const i=ea(t,r);i.showResourcesModal=!i.showResourcesModal},toggleUsersResources:(t,r)=>{const i=Ks(t,r),l=t.requests[i.currentRequestId],{username:u,resourceId:f,checked:v}=r.payload,h=u?[i.users.find(y=>y.username==u)]:i.users;for(let y of h){if(f){let x=y.resourceIds.indexOf(f);v&&x==-1?y.resourceIds.push(f):!v&&x>=0&&y.resourceIds.splice(x,1)}else y.resourceIds=v?l.resources.filter(jw).map(({resourceId:x})=>x):[];YI(y)}}},extraReducers:t=>{t.addCase(Kb.pending,r=>{r.projectListLoading=!0}).addCase(Kb.fulfilled,(r,i)=>{i.payload.projectsList.sort((l,u)=>x0(l.requests[0])>x0(u.requests[0])?-1:1),r.username=i.payload.username,r.projectsList=i.payload.projectsList.map(l=>{const{grantNumber:u,requestMasterId:f,requests:v,status:h,title:y}=l,C=l.requests.filter(w=>w.actions.filter(R=>R.returnedForCorrections).length>0).length>0?"Returned for Corrections":h||v&&(v.find(({timeStatus:w})=>w=="current")?"Active":v[0].timeStatus=="past"?"Inactive":v[0].status);return v&&rG(r,l,C),{grantNumber:u||f,status:C,title:y}}),r.projectListLoading=!1}).addCase(Kb.rejected,r=>{r.error="Failed to load project list.",r.projectListLoading=!1}).addCase(mO.rejected,(r,i)=>{const{grantNumber:l}=i.payload;r.projects[l]={error:"Failed to load project data."}}).addCase(gO.rejected,(r,i)=>{const{requestId:l}=i.payload;r.requests[l]={error:"Failed to load request data."}}).addCase(e0.pending,(r,i)=>{const l=ea(r,{payload:i.meta.arg});l.usageDetailStatus=ta.pending}).addCase(e0.fulfilled,(r,i)=>{const l=ea(r,i);l.usageDetail=i.payload.usageDetail,l.usageDetailStatus=ta.success}).addCase(e0.rejected,(r,i)=>{const l=ea(r,i);l.usageDetailStatus=ta.error}).addCase(t0.pending,(r,i)=>{const l=Vb(r,{payload:i.meta.arg});l.deleteStatus=ta.pending}).addCase(t0.fulfilled,(r,i)=>{const l=ea(r,i),u=Vb(r,i);u.isRequest?(l.error="This request has been deleted.",u.allowedOperations=[]):l.actions=l.actions.filter(f=>f.actionId!=u.actionId),u.deleteStatus=ta.success,u.showDeleteModal=!1}).addCase(t0.rejected,(r,i)=>{const l=Vb(r,i);l.deleteStatus=ta.error}).addCase(n0.pending,(r,i)=>{const l=ea(r,{payload:i.meta.arg});l.exchangeStatus=ta.pending,l.showResourcesModal=!1}).addCase(n0.fulfilled,(r,i)=>{const l=ea(r,i);l.exchangeActionId=i.payload.exchangeActionId,l.exchangeStatus=ta.success}).addCase(n0.rejected,(r,i)=>{const l=ea(r,i);l.exchangeStatus=ta.error}).addCase(r0.pending,(r,i)=>{const l=Ks(r,{payload:i.meta.arg});l.usersStatus=ta.pending}).addCase(r0.fulfilled,(r,i)=>{const l=Ks(r,i);l.users=l.users.map(u=>({...u,initialResourceIds:[...u.resourceIds],initialRole:u.role,hasChanges:!1,isNew:!1})),l.usersStatus=ta.success}).addCase(r0.rejected,(r,i)=>{const l=Ks(r,i);l.usersStatus=ta.error})}}),lG=t=>t.api.error,uG=t=>t.api.projectsList,cG=t=>t.api.projectListLoading,dG=(t,r)=>Ks(t.api,{payload:{grantNumber:r}}),fG=(t,r)=>ea(t.api,{payload:{requestId:r}}),pG=t=>t.api.username,{addResource:hG,addUser:vG,closeUsageDetailModal:mG,hideAlert:Xq,resetResources:gG,resetUsers:yG,setRequest:bG,setResourceQuestionValues:xG,setResourceRequest:CG,setResourcesReason:SG,setTab:EG,setUserRole:wG,toggleActionsModal:RG,toggleConfirmModal:_G,toggleDeleteModal:TG,toggleResourcesModal:NG,toggleUsersResources:IG}=yO.actions,AG=yO.reducer,jG=t=>{const r=Jn(lG),i=Jn(cG),l=Jn(uG),u=No();return k.useEffect(()=>{u(Kb(t))},[]),{error:r,loading:i,projects:l}},Ji=(t,r)=>{const i=Jn(f=>dG(f,t)),l=Jn(pG),u=No();return k.useEffect(()=>{!i&&!r&&u(mO({grantNumber:t}))},[r]),{project:i,addUser:f=>u(vG({grantNumber:t,user:f})),resetUsers:()=>u(yG({grantNumber:t})),saveUsers:()=>u(r0({grantNumber:t})),setRequest:f=>u(bG({grantNumber:t,requestId:f})),setTab:f=>u(EG({grantNumber:t,tab:f})),setUserRole:(f,v)=>u(wG({grantNumber:t,username:f,role:v})),statuses:ta,toggleUsersResources:(f,v,h)=>u(IG({grantNumber:t,username:v,resourceId:h,checked:f})),username:l}},ri=(t,r)=>{const i=Jn(u=>fG(u,t)),l=No();return k.useEffect(()=>{i||l(gO({grantNumber:r,requestId:t}))},[r,t]),{request:i,addResource:u=>l(hG({requestId:t,resourceId:u})),closeUsageDetailModal:()=>l(mG({requestId:t})),deleteAction:u=>l(t0({actionId:u,requestId:t})),openUsageDetailModal:u=>l(e0({grantNumber:i.grantNumber,requestId:t,resourceRepositoryKey:u})),resetResources:()=>l(gG({requestId:t})),saveResources:()=>l(n0({requestId:t})),setResourceQuestionValues:(u,f,v)=>l(xG({requestId:t,resourceId:u,attributeSetId:f,values:v})),setResourceRequest:(u,f)=>l(CG({requestId:t,resourceId:u,requested:f})),setResourcesReason:u=>l(SG({requestId:t,reason:u})),statuses:ta,toggleActionsModal:()=>l(RG({requestId:t})),toggleConfirmModal:()=>l(_G({requestId:t})),toggleDeleteModal:u=>l(TG({requestId:t,actionId:u})),toggleResourcesModal:()=>l(NG({requestId:t}))}},OG="_project_qqnbz_1",DG="_expand_qqnbz_5",ZI={project:OG,expand:DG},kG="_returnedForCorrectionsNotes_jujbd_1",MG={returnedForCorrectionsNotes:kG};function bO(t,r,i){const l=k.useRef(t!==void 0),[u,f]=k.useState(r),v=t!==void 0,h=l.current;return l.current=v,!v&&h&&u!==r&&f(r),[v?t:u,k.useCallback((...y)=>{const[x,...C]=y;let w=i==null?void 0:i(x,...C);return f(x),w},[i])]}var xO={};const C0={prefix:String(Math.round(Math.random()*1e10)),current:0},CO=pr.createContext(C0),LG=pr.createContext(!1);let PG=!!(typeof window<"u"&&window.document&&window.document.createElement),qE=new WeakMap;function FG(t=!1){let r=k.useContext(CO),i=k.useRef(null);if(i.current===null&&!t){var l,u;let f=(u=pr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED)===null||u===void 0||(l=u.ReactCurrentOwner)===null||l===void 0?void 0:l.current;if(f){let v=qE.get(f);v==null?qE.set(f,{id:r.current,state:f.memoizedState}):f.memoizedState!==v.state&&(r.current=v.id,qE.delete(f))}i.current=++r.current}return i.current}function VG(t){let r=k.useContext(CO);r===C0&&!PG&&console.warn("When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.");let i=FG(!!t),l=r===C0&&xO.NODE_ENV==="test"?"react-aria":`react-aria${r.prefix}`;return t||`${l}-${i}`}function BG(t){let r=pr.useId(),[i]=k.useState(HG()),l=i||xO.NODE_ENV==="test"?"react-aria":`react-aria${C0.prefix}`;return t||`${l}-${r}`}const SO=typeof pr.useId=="function"?BG:VG;function zG(){return!1}function $G(){return!0}function UG(t){return()=>{}}function HG(){return typeof pr.useSyncExternalStore=="function"?pr.useSyncExternalStore(UG,zG,$G):k.useContext(LG)}const GG=k.createContext(null),rh=GG,WG=k.createContext(null),qd=(t,r=null)=>t!=null?String(t):r||null,iu=WG;function XG(t){const r=k.useRef(t);return k.useEffect(()=>{r.current=t},[t]),r}function br(t){const r=XG(t);return k.useCallback(function(...i){return r.current&&r.current(...i)},[r])}const qI=t=>!t||typeof t=="function"?t:r=>{t.current=r};function YG(t,r){const i=qI(t),l=qI(r);return u=>{i&&i(u),l&&l(u)}}function hs(t,r){return k.useMemo(()=>YG(t,r),[t,r])}function wR({children:t,in:r,onExited:i,mountOnEnter:l,unmountOnExit:u}){const f=k.useRef(null),v=k.useRef(r),h=br(i);k.useEffect(()=>{r?v.current=!0:h(f.current)},[r,h]);const y=hs(f,t.ref),x=k.cloneElement(t,{ref:y});return r?x:u||!v.current&&l?null:x}const ZG=["active","eventKey","mountOnEnter","transition","unmountOnExit","role","onEnter","onEntering","onEntered","onExit","onExiting","onExited"],qG=["activeKey","getControlledId","getControllerId"],JG=["as"];function Ow(t,r){if(t==null)return{};var i={},l=Object.keys(t),u,f;for(f=0;f<l.length;f++)u=l[f],!(r.indexOf(u)>=0)&&(i[u]=t[u]);return i}function EO(t){let{active:r,eventKey:i,mountOnEnter:l,transition:u,unmountOnExit:f,role:v="tabpanel",onEnter:h,onEntering:y,onEntered:x,onExit:C,onExiting:w,onExited:R}=t,j=Ow(t,ZG);const N=k.useContext(rh);if(!N)return[Object.assign({},j,{role:v}),{eventKey:i,isActive:r,mountOnEnter:l,transition:u,unmountOnExit:f,onEnter:h,onEntering:y,onEntered:x,onExit:C,onExiting:w,onExited:R}];const{activeKey:T,getControlledId:I,getControllerId:M}=N,P=Ow(N,qG),V=qd(i);return[Object.assign({},j,{role:v,id:I(i),"aria-labelledby":M(i)}),{eventKey:i,isActive:r==null&&V!=null?qd(T)===V:r,transition:u||P.transition,mountOnEnter:l??P.mountOnEnter,unmountOnExit:f??P.unmountOnExit,onEnter:h,onEntering:y,onEntered:x,onExit:C,onExiting:w,onExited:R}]}const wO=k.forwardRef((t,r)=>{let{as:i="div"}=t,l=Ow(t,JG);const[u,{isActive:f,onEnter:v,onEntering:h,onEntered:y,onExit:x,onExiting:C,onExited:w,mountOnEnter:R,unmountOnExit:j,transition:N=wR}]=EO(l);return m.jsx(rh.Provider,{value:null,children:m.jsx(iu.Provider,{value:null,children:m.jsx(N,{in:f,onEnter:v,onEntering:h,onEntered:y,onExit:x,onExiting:C,onExited:w,mountOnEnter:R,unmountOnExit:j,children:m.jsx(i,Object.assign({},u,{ref:r,hidden:!f,"aria-hidden":!f}))})})})});wO.displayName="TabPanel";const RO=t=>{const{id:r,generateChildId:i,onSelect:l,activeKey:u,defaultActiveKey:f,transition:v,mountOnEnter:h,unmountOnExit:y,children:x}=t,[C,w]=bO(u,f,l),R=SO(r),j=k.useMemo(()=>i||((T,I)=>R?`${R}-${I}-${T}`:null),[R,i]),N=k.useMemo(()=>({onSelect:w,activeKey:C,transition:v,mountOnEnter:h||!1,unmountOnExit:y||!1,getControlledId:T=>j(T,"tabpane"),getControllerId:T=>j(T,"tab")}),[w,C,v,h,y,j]);return m.jsx(rh.Provider,{value:N,children:m.jsx(iu.Provider,{value:w||null,children:x})})};RO.Panel=wO;const _O=RO;var TO={exports:{}};/*!
|
|
292
292
|
Copyright (c) 2018 Jed Watson.
|
package/dist/xras-ui.js
CHANGED
|
@@ -26506,8 +26506,8 @@ const SR = pr.memo(function({
|
|
|
26506
26506
|
y && /* @__PURE__ */ m.jsx(
|
|
26507
26507
|
ym,
|
|
26508
26508
|
{
|
|
26509
|
-
label: "Resource
|
|
26510
|
-
value: r.
|
|
26509
|
+
label: "Resource Repository Key",
|
|
26510
|
+
value: r.resource_repository_key,
|
|
26511
26511
|
disabled: !0,
|
|
26512
26512
|
inputClassName: "span8"
|
|
26513
26513
|
}
|
|
@@ -26959,15 +26959,28 @@ const cO = pr.memo(function({
|
|
|
26959
26959
|
columns: r,
|
|
26960
26960
|
rows: i
|
|
26961
26961
|
}) {
|
|
26962
|
-
return /* @__PURE__ */ m.
|
|
26963
|
-
|
|
26964
|
-
|
|
26965
|
-
|
|
26966
|
-
|
|
26967
|
-
|
|
26968
|
-
|
|
26969
|
-
|
|
26970
|
-
|
|
26962
|
+
return /* @__PURE__ */ m.jsxs("div", { className: Iw["allocation-types-grid"], children: [
|
|
26963
|
+
/* @__PURE__ */ m.jsx(
|
|
26964
|
+
su,
|
|
26965
|
+
{
|
|
26966
|
+
columns: r,
|
|
26967
|
+
rows: i,
|
|
26968
|
+
rowClasses: Array(i.length).fill(Iw["vertical-align-center"]),
|
|
26969
|
+
scroll: !1
|
|
26970
|
+
}
|
|
26971
|
+
),
|
|
26972
|
+
/* @__PURE__ */ m.jsx(
|
|
26973
|
+
"p",
|
|
26974
|
+
{
|
|
26975
|
+
style: {
|
|
26976
|
+
margin: "0",
|
|
26977
|
+
fontStyle: "italic",
|
|
26978
|
+
fontWeight: "bold"
|
|
26979
|
+
},
|
|
26980
|
+
children: "Note: You may need to contact your Allocations Coordinator if you have added this resource to an allocation type."
|
|
26981
|
+
}
|
|
26982
|
+
)
|
|
26983
|
+
] });
|
|
26971
26984
|
});
|
|
26972
26985
|
cO.propTypes = {
|
|
26973
26986
|
columns: Pe.array.isRequired,
|