@jield/solodb-react-components 1.1.2 → 1.1.3
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -17
- package/dist/index.js.map +1 -1
- package/dist/src/modules/run/components/shared/parts_table/element/partActionsButtons.d.ts +1 -1
- package/dist/src/modules/run/components/shared/parts_table/element/partActionsDropdown.d.ts +1 -1
- package/dist/src/modules/run/hooks/run/parts/usePartActions.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -33,7 +33,7 @@ Arguments: `+Array.prototype.slice.call(r).join(``)+`
|
|
|
33
33
|
`},i)),a}function VN(e,t){return e&&`run`in e?async function(n,r){let i=BN(n,{file:r,...t});await e.run(i,r)}:function(n,r){return BN(n,{file:r,...e||t})}}function HN(e){if(e)throw e}var UN=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function WN(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function GN(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?KN(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function KN(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var qN={basename:JN,dirname:YN,extname:XN,join:ZN,sep:`/`};function JN(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);eP(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function YN(e){if(eP(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function XN(e){eP(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function ZN(...e){let t=-1,n;for(;++t<e.length;)eP(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:QN(n)}function QN(e){eP(e);let t=e.codePointAt(0)===47,n=$N(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function $N(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function eP(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var tP={cwd:nP};function nP(){return`/`}function rP(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function iP(e){if(typeof e==`string`)e=new URL(e);else if(!rP(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return aP(e)}function aP(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var oP=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],sP=class{constructor(e){let t;t=e?rP(e)?{path:e}:typeof e==`string`||dP(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:tP.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<oP.length;){let e=oP[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)oP.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?qN.basename(this.path):void 0}set basename(e){lP(e,`basename`),cP(e,`basename`),this.path=qN.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?qN.dirname(this.path):void 0}set dirname(e){uP(this.basename,`dirname`),this.path=qN.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?qN.extname(this.path):void 0}set extname(e){if(cP(e,`extname`),uP(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=qN.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){rP(e)&&(e=iP(e)),lP(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?qN.basename(this.path,this.extname):void 0}set stem(e){lP(e,`stem`),cP(e,`stem`),this.path=qN.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new XO(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function cP(e,t){if(e&&e.includes(qN.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+qN.sep+"`")}function lP(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function uP(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function dP(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var fP=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),pP=l(UN(),1),mP={}.hasOwnProperty,hP=new class e extends fP{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=GN()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,pP.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(vP(`data`,this.frozen),this.namespace[e]=t,this):mP.call(this.namespace,e)&&this.namespace[e]||void 0:e?(vP(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=xP(e),n=this.parser||this.Parser;return gP(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),gP(`process`,this.parser||this.Parser),_P(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=xP(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);CP(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),gP(`processSync`,this.parser||this.Parser),_P(`processSync`,this.compiler||this.Compiler),this.process(e,r),bP(`processSync`,`process`,t),n;function r(e,r){t=!0,HN(e),n=r}}run(e,t,n){yP(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=xP(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),bP(`runSync`,`run`,n),r;function i(e,t){HN(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=xP(t),r=this.compiler||this.Compiler;return _P(`stringify`,r),yP(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(vP(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,pP.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];WN(o)&&WN(r)&&(r=(0,pP.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function gP(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function _P(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function vP(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function yP(e){if(!WN(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function bP(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function xP(e){return SP(e)?e:new sP(e)}function SP(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function CP(e){return typeof e==`string`||wP(e)}function wP(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var TP=[],EP={allowDangerousHtml:!0},DP=/^(https?|ircs?|mailto|xmpp)$/i,OP=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function kP(e){let t=AP(e),n=jP(e);return MP(t.runSync(t.parse(n),n),e)}function AP(e){let t=e.rehypePlugins||TP,n=e.remarkPlugins||TP,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...EP}:EP;return hP().use(DM).use(n).use(VN,r).use(t)}function jP(e){let t=e.children||``,n=new sP;return typeof t==`string`?n.value=t:``+t,n}function MP(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||NP;for(let e of OP)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return jN(e,l),ik(e,{Fragment:p.Fragment,components:i,ignoreInvalidStyle:!0,jsx:p.jsx,jsxs:p.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in Ek)if(Object.hasOwn(Ek,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Ek[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function NP(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||DP.test(e.slice(0,t))?e:``}function PP({ecn:e,equipment:t,ecnAttachments:n,reloadQueryFn:r,expanded:i=!0}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(e),[f,m]=(0,d.useState)(i),h=e=>{r([`ecn`,`attachment`,`status_mail`]),u({...l,...e})},g=()=>n.filter(t=>t.ecn.id===e.id);return(0,p.jsxs)(`div`,{className:`p-3 mb-4 border-bottom`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-2`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(yr,{bg:`dark`,children:`ECN`}),(0,p.jsx)(`h4`,{className:l.date_closed?`text-danger mb-0`:`mb-0`,children:l.date_closed?(0,p.jsx)(`s`,{children:l.ecn}):l.ecn})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(B,{variant:`outline-primary`,size:`sm`,onClick:()=>m(e=>!e),"aria-label":`Toggle Details`,children:f?`Hide Details`:`Show Details`}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{o((0,p.jsx)(Gb,{equipment:t,showModal:!0,onClose:e=>{c(!1),e&&(r([`ecn`,`attachment`,`status_mail`]),h(e))},ecn:l,attachments:g()})),c(!0)},"aria-label":`Edit ECN`,children:`Edit`})]})]}),f&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`mb-3`,children:(0,p.jsx)(kP,{children:l.description})}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap text-muted`,children:[(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Creator`}),(0,p.jsx)(`div`,{className:`text-body`,children:l.owner.full_name})]}),(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Created`}),(0,p.jsx)(`div`,{className:`text-body`,children:q(l.date_created).format(`DD MMMM YYYY`)})]}),l.date_closed&&(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Closed`}),(0,p.jsx)(`div`,{className:`text-danger`,children:q(l.date_closed).format(`DD MMMM YYYY`)})]}),(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Attachments`}),(0,p.jsx)(`div`,{className:`text-body`,children:l.attachments})]}),l.updated_by&&(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update By`}),(0,p.jsx)(`div`,{className:`text-body`,children:l.updated_by.full_name})]}),l.last_update&&(0,p.jsxs)(`div`,{className:`flex-fill pe-3 mb-2`,children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update`}),(0,p.jsx)(`div`,{className:`text-body`,children:q(l.last_update).format(`DD MMMM YYYY`)})]})]})]}),s&&a]})}var FP=({equipment:e,showModal:t,onClose:n,issue:r,attachments:i})=>{let[a,o]=(0,d.useState)([]),[s,c]=(0,d.useState)([]),{user:l}=(0,d.useContext)(v),[u,m]=(0,d.useState)(i),{register:h,handleSubmit:g,reset:_,control:y}=Ed({defaultValues:{issue:r?.issue||``,description:r?.description||``,issue_type:r?.issue_type||it.DEFAULT,status:r?.status||at.ACTIVE,forecast_up:r?.forecast_up?new Date(r?.forecast_up).toISOString().split(`T`)[0]:``,actions:r?.actions||``,owner:r?.owner||{}}});(0,d.useEffect)(()=>{r&&_({issue:r?.issue||``,description:r?.description||``,issue_type:r?.issue_type||it.DEFAULT,status:r?.status||at.ACTIVE,forecast_up:r?.forecast_up?new Date(r?.forecast_up).toISOString().split(`T`)[0]:``,actions:r?.actions||``,owner:r?.owner||{}})},[r,_]);let{getRootProps:b,getInputProps:x,isDragActive:S}=Ib({accept:{"application/*":[],"image/*":[]},onDrop:e=>{o(t=>[...t,...e])}});(0,d.useEffect)(()=>{t&&(async()=>{if(e?.id)try{c((await oe({equipment:e})).items||[])}catch(e){console.error(`Error fetching modules:`,e)}})()},[e,t]);async function w(){await f.default.delete(`/delete/equipment/module/issue/${r?.id}`),n({...r,date_closed:new Date().toISOString(),last_update:new Date().toISOString(),updated_by:l?.full_name})}let T=e=>{o(t=>t.filter((t,n)=>n!==e))},E=e=>{u&&m(t=>t?.filter((t,n)=>n!==e))},D=(e,t)=>new Promise(async(n,r)=>{try{if(u&&i&&i!=u)for(let e=0;e<i.length;e++){let t=i[e].id,n=!1;for(let e=0;e<u.length;e++)if(t==u[e].id){n=!0;break}n||await f.default.delete(`/delete/equipment/module/issue/attachment/${i[e].id}`)}e.length>0&&t&&await Promise.all(e.map(async e=>{let n=await C(e),r={issue_id:t,filename:e.name,type:e.type,content:n};await f.default.post(`/create/equipment/module/issue/attachment`,r)})),n()}catch(e){r(e)}});return(0,d.useEffect)(()=>{t&&(async()=>{if(e?.id)try{c((await oe({equipment:e})).items||[])}catch(e){console.error(`Error fetching modules:`,e)}})()},[e,t]),(0,p.jsx)(U,{show:t,size:`lg`,centered:!0,onHide:()=>n(r),children:(0,p.jsxs)(H,{onSubmit:g(async e=>{try{let t,i={module_id:e.module_id,issue:e.issue,description:e.description,owner:e?.owner.value||r?.owner,status:e.status,issue_type:e.issue_type,actions:e.actions,forecast_up:e.forecast_up};r?(await D(a,r.id),t=(await f.default.patch(`/update/equipment/module/issue/${r?.id}`,i)).data):(t=(await f.default.post(`/create/equipment/module/issue`,i)).data,D(a,t.id),t.attachments=a.length),n(t)}catch(e){console.error(`Error submitting the form:`,e)}}),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:r?`Edit Issue for ${e.name}`:`Create new Issue for ${e.name}`})}),(0,p.jsxs)(U.Body,{children:[!r&&(0,p.jsxs)(H.Group,{controlId:`module`,className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Module`}),(0,p.jsxs)(H.Select,{...h(`module_id`,{required:`Module is required`}),children:[(0,p.jsx)(`option`,{value:``,children:`— Select a module`}),s.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,p.jsxs)(H.Group,{controlId:`issue`,children:[(0,p.jsx)(H.Label,{children:`Issue`}),(0,p.jsx)(H.Control,{type:`text`,...h(`issue`,{required:`Issue content is required`}),autoFocus:!0})]}),(0,p.jsxs)(H.Group,{controlId:`description`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Description`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:3,...h(`description`,{required:`Description is required`})})]}),(0,p.jsxs)(H.Group,{controlId:`issueType`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Issue`}),(0,p.jsxs)(H.Control,{as:`select`,...h(`issue_type`,{required:`Issue type is required`}),children:[(0,p.jsx)(`option`,{value:it.DEFAULT,children:`Default`}),(0,p.jsx)(`option`,{value:it.PRIORITY,children:`Priority`}),(0,p.jsx)(`option`,{value:it.ESCALATION,children:`Escalation`})]})]}),(0,p.jsxs)(H.Group,{controlId:`status`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Status`}),(0,p.jsxs)(H.Control,{as:`select`,...h(`status`,{required:`Status is required`}),children:[(0,p.jsx)(`option`,{value:at.ACTIVE,children:`Active`}),(0,p.jsx)(`option`,{value:at.CLOSED,children:`Closed`})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Wb,{control:y,...h(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{controlId:`forecastUp`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Forecast Up`}),(0,p.jsx)(H.Control,{type:`date`,...h(`forecast_up`,{required:`Forecast Up date is required`})})]}),(0,p.jsxs)(H.Group,{controlId:`actions`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Actions`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:5,...h(`actions`,{required:!1})})]}),(0,p.jsxs)(H.Group,{children:[(0,p.jsx)(H.Label,{children:`Attachments`}),(0,p.jsxs)(`div`,{...b({className:`dropzone ${S?`active`:``}`,style:{border:`2px dashed #007bff`,padding:`10px`,textAlign:`center`}}),children:[(0,p.jsx)(`input`,{...x()}),S?(0,p.jsx)(`p`,{children:`Drop the files here...`}):(0,p.jsx)(`p`,{children:`Drag & drop files here, or click to select files`})]}),a.length>0&&(0,p.jsx)(`ul`,{children:a.map((e,t)=>(0,p.jsxs)(`li`,{children:[e.name,` `,(0,p.jsx)(B,{variant:`secondary`,onClick:()=>T(t),children:`cancel`})]},t))})]}),u&&u.length>0&&(0,p.jsxs)(H.Group,{controlId:`uploaded_files`,className:`mt-3`,children:[(0,p.jsx)(H.Label,{children:`Uploaded files`}),(0,p.jsx)(`ul`,{children:u.map((e,t)=>(0,p.jsxs)(`li`,{children:[e.filename,` `,(0,p.jsx)(B,{variant:`secondary`,onClick:()=>E(t),children:`delete`})]},t))})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{variant:`secondary`,onClick:()=>n(r),children:`Cancel`}),(0,p.jsx)(B,{variant:`primary`,type:`submit`,children:r?`Update Issue`:`Create Issue`}),r&&(0,p.jsx)(B,{variant:`danger`,onClick:()=>w(),children:`Close Issue`})]})]})})},IP=l(o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):n.moment=r()})(e,(function(){"use strict";var e;function n(){return e.apply(null,arguments)}function r(t){e=t}function i(e){return e instanceof Array||Object.prototype.toString.call(e)===`[object Array]`}function a(e){return e!=null&&Object.prototype.toString.call(e)===`[object Object]`}function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s(e){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(e).length===0;for(var t in e)if(o(e,t))return!1;return!0}function c(e){return e===void 0}function l(e){return typeof e==`number`||Object.prototype.toString.call(e)===`[object Number]`}function u(e){return e instanceof Date||Object.prototype.toString.call(e)===`[object Date]`}function d(e,t){var n=[],r,i=e.length;for(r=0;r<i;++r)n.push(t(e[r],r));return n}function f(e,t){for(var n in t)o(t,n)&&(e[n]=t[n]);return o(t,`toString`)&&(e.toString=t.toString),o(t,`valueOf`)&&(e.valueOf=t.valueOf),e}function p(e,t,n,r){return cr(e,t,n,r,!0).utc()}function m(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function h(e){return e._pf??(e._pf=m()),e._pf}var g=Array.prototype.some?Array.prototype.some:function(e){var t=Object(this),n=t.length>>>0,r;for(r=0;r<n;r++)if(r in t&&e.call(this,t[r],r,t))return!0;return!1};function _(e){var t=null,n=!1,r=e._d&&!isNaN(e._d.getTime());if(r&&(t=h(e),n=g.call(t.parsedDateParts,function(e){return e!=null}),r=t.overflow<0&&!t.empty&&!t.invalidEra&&!t.invalidMonth&&!t.invalidWeekday&&!t.weekdayMismatch&&!t.nullInput&&!t.invalidFormat&&!t.userInvalidated&&(!t.meridiem||t.meridiem&&n),e._strict&&(r=r&&t.charsLeftOver===0&&t.unusedTokens.length===0&&t.bigHour===void 0)),Object.isFrozen==null||!Object.isFrozen(e))e._isValid=r;else return r;return e._isValid}function v(e){var t=p(NaN);return e==null?h(t).userInvalidated=!0:f(h(t),e),t}var y=n.momentProperties=[],b=!1;function x(e,t){var n,r,i,a=y.length;if(c(t._isAMomentObject)||(e._isAMomentObject=t._isAMomentObject),c(t._i)||(e._i=t._i),c(t._f)||(e._f=t._f),c(t._l)||(e._l=t._l),c(t._strict)||(e._strict=t._strict),c(t._tzm)||(e._tzm=t._tzm),c(t._isUTC)||(e._isUTC=t._isUTC),c(t._offset)||(e._offset=t._offset),c(t._pf)||(e._pf=h(t)),c(t._locale)||(e._locale=t._locale),a>0)for(n=0;n<a;n++)r=y[n],i=t[r],c(i)||(e[r]=i);return e}function S(e){x(this,e),this._d=new Date(e._d==null?NaN:e._d.getTime()),this.isValid()||(this._d=new Date(NaN)),b===!1&&(b=!0,n.updateOffset(this),b=!1)}function C(e){return e instanceof S||e!=null&&e._isAMomentObject!=null}function w(e){n.suppressDeprecationWarnings===!1&&typeof console<`u`&&console.warn&&console.warn(`Deprecation warning: `+e)}function T(e,t){var r=!0;return f(function(){if(n.deprecationHandler!=null&&n.deprecationHandler(null,e),r){var i=[],a,s,c,l=arguments.length;for(s=0;s<l;s++){if(a=``,typeof arguments[s]==`object`){for(c in a+=`
|
|
34
34
|
[`+s+`] `,arguments[0])o(arguments[0],c)&&(a+=c+`: `+arguments[0][c]+`, `);a=a.slice(0,-2)}else a=arguments[s];i.push(a)}w(e+`
|
|
35
35
|
Arguments: `+Array.prototype.slice.call(i).join(``)+`
|
|
36
|
-
`+Error().stack),r=!1}return t.apply(this,arguments)},t)}var E={};function D(e,t){n.deprecationHandler!=null&&n.deprecationHandler(e,t),E[e]||(w(t),E[e]=!0)}n.suppressDeprecationWarnings=!1,n.deprecationHandler=null;function O(e){return typeof Function<`u`&&e instanceof Function||Object.prototype.toString.call(e)===`[object Function]`}function k(e){var t,n;for(n in e)o(e,n)&&(t=e[n],O(t)?this[n]=t:this[`_`+n]=t);this._config=e,this._dayOfMonthOrdinalParseLenient=RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+`|\\d{1,2}`)}function A(e,t){var n=f({},e),r;for(r in t)o(t,r)&&(a(e[r])&&a(t[r])?(n[r]={},f(n[r],e[r]),f(n[r],t[r])):t[r]==null?delete n[r]:n[r]=t[r]);for(r in e)o(e,r)&&!o(t,r)&&a(e[r])&&(n[r]=f({},n[r]));return n}function j(e){e!=null&&this.set(e)}var M=Object.keys?Object.keys:function(e){var t,n=[];for(t in e)o(e,t)&&n.push(t);return n},ee={sameDay:`[Today at] LT`,nextDay:`[Tomorrow at] LT`,nextWeek:`dddd [at] LT`,lastDay:`[Yesterday at] LT`,lastWeek:`[Last] dddd [at] LT`,sameElse:`L`};function te(e,t,n){var r=this._calendar[e]||this._calendar.sameElse;return O(r)?r.call(t,n):r}function N(e,t,n){var r=``+Math.abs(e),i=t-r.length;return(e>=0?n?`+`:``:`-`)+(10**Math.max(0,i)).toString().substr(1)+r}var ne=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,re=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,ie={},ae={};function P(e,t,n,r){var i=r;typeof r==`string`&&(i=function(){return this[r]()}),e&&(ae[e]=i),t&&(ae[t[0]]=function(){return N(i.apply(this,arguments),t[1],t[2])}),n&&(ae[n]=function(){return this.localeData().ordinal(i.apply(this,arguments),e)})}function oe(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,``):e.replace(/\\/g,``)}function se(e){var t=e.match(ne),n,r;for(n=0,r=t.length;n<r;n++)ae[t[n]]?t[n]=ae[t[n]]:t[n]=oe(t[n]);return function(n){var i=``,a;for(a=0;a<r;a++)i+=O(t[a])?t[a].call(n,e):t[a];return i}}function ce(e,t){return e.isValid()?(t=le(t,e.localeData()),ie[t]=ie[t]||se(t),ie[t](e)):e.localeData().invalidDate()}function le(e,t){var n=5;function r(e){return t.longDateFormat(e)||e}for(re.lastIndex=0;n>=0&&re.test(e);)e=e.replace(re,r),re.lastIndex=0,--n;return e}var ue={LTS:`h:mm:ss A`,LT:`h:mm A`,L:`MM/DD/YYYY`,LL:`MMMM D, YYYY`,LLL:`MMMM D, YYYY h:mm A`,LLLL:`dddd, MMMM D, YYYY h:mm A`};function de(e){var t=this._longDateFormat[e],n=this._longDateFormat[e.toUpperCase()];return t||!n?t:(this._longDateFormat[e]=n.match(ne).map(function(e){return e===`MMMM`||e===`MM`||e===`DD`||e===`dddd`?e.slice(1):e}).join(``),this._longDateFormat[e])}var fe=`Invalid date`;function pe(){return this._invalidDate}var me=`%d`,he=/\d{1,2}/;function ge(e){return this._ordinal.replace(`%d`,e)}var _e={future:`in %s`,past:`%s ago`,s:`a few seconds`,ss:`%d seconds`,m:`a minute`,mm:`%d minutes`,h:`an hour`,hh:`%d hours`,d:`a day`,dd:`%d days`,w:`a week`,ww:`%d weeks`,M:`a month`,MM:`%d months`,y:`a year`,yy:`%d years`};function ve(e,t,n,r){var i=this._relativeTime[n];return O(i)?i(e,t,n,r):i.replace(/%d/i,e)}function ye(e,t){var n=this._relativeTime[e>0?`future`:`past`];return O(n)?n(t):n.replace(/%s/i,t)}var be={D:`date`,dates:`date`,date:`date`,d:`day`,days:`day`,day:`day`,e:`weekday`,weekdays:`weekday`,weekday:`weekday`,E:`isoWeekday`,isoweekdays:`isoWeekday`,isoweekday:`isoWeekday`,DDD:`dayOfYear`,dayofyears:`dayOfYear`,dayofyear:`dayOfYear`,h:`hour`,hours:`hour`,hour:`hour`,ms:`millisecond`,milliseconds:`millisecond`,millisecond:`millisecond`,m:`minute`,minutes:`minute`,minute:`minute`,M:`month`,months:`month`,month:`month`,Q:`quarter`,quarters:`quarter`,quarter:`quarter`,s:`second`,seconds:`second`,second:`second`,gg:`weekYear`,weekyears:`weekYear`,weekyear:`weekYear`,GG:`isoWeekYear`,isoweekyears:`isoWeekYear`,isoweekyear:`isoWeekYear`,w:`week`,weeks:`week`,week:`week`,W:`isoWeek`,isoweeks:`isoWeek`,isoweek:`isoWeek`,y:`year`,years:`year`,year:`year`};function xe(e){return typeof e==`string`?be[e]||be[e.toLowerCase()]:void 0}function Se(e){var t={},n,r;for(r in e)o(e,r)&&(n=xe(r),n&&(t[n]=e[r]));return t}var Ce={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function we(e){var t=[],n;for(n in e)o(e,n)&&t.push({unit:n,priority:Ce[n]});return t.sort(function(e,t){return e.priority-t.priority}),t}var Te=/\d/,Ee=/\d\d/,De=/\d{3}/,Oe=/\d{4}/,ke=/[+-]?\d{6}/,Ae=/\d\d?/,je=/\d\d\d\d?/,Me=/\d\d\d\d\d\d?/,Ne=/\d{1,3}/,Pe=/\d{1,4}/,Fe=/[+-]?\d{1,6}/,Ie=/\d+/,Le=/[+-]?\d+/,Re=/Z|[+-]\d\d:?\d\d/gi,ze=/Z|[+-]\d\d(?::?\d\d)?/gi,Be=/[+-]?\d+(\.\d{1,3})?/,Ve=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,He=/^[1-9]\d?/,Ue=/^([1-9]\d|\d)/,We={};function F(e,t,n){We[e]=O(t)?t:function(e,r){return e&&n?n:t}}function Ge(e,t){return o(We,e)?We[e](t._strict,t._locale):new RegExp(Ke(e))}function Ke(e){return qe(e.replace(`\\`,``).replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,t,n,r,i){return t||n||r||i}))}function qe(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,`\\$&`)}function Je(e){return e<0?Math.ceil(e)||0:Math.floor(e)}function Ye(e){var t=+e,n=0;return t!==0&&isFinite(t)&&(n=Je(t)),n}var Xe={};function Ze(e,t){var n,r=t,i;for(typeof e==`string`&&(e=[e]),l(t)&&(r=function(e,n){n[t]=Ye(e)}),i=e.length,n=0;n<i;n++)Xe[e[n]]=r}function Qe(e,t){Ze(e,function(e,n,r,i){r._w=r._w||{},t(e,r._w,r,i)})}function $e(e,t,n){t!=null&&o(Xe,e)&&Xe[e](t,n._a,n,e)}function et(e){return e%4==0&&e%100!=0||e%400==0}var tt=0,nt=1,rt=2,it=3,at=4,ot=5,st=6,ct=7,lt=8;P(`Y`,0,0,function(){var e=this.year();return e<=9999?N(e,4):`+`+e}),P(0,[`YY`,2],0,function(){return this.year()%100}),P(0,[`YYYY`,4],0,`year`),P(0,[`YYYYY`,5],0,`year`),P(0,[`YYYYYY`,6,!0],0,`year`),F(`Y`,Le),F(`YY`,Ae,Ee),F(`YYYY`,Pe,Oe),F(`YYYYY`,Fe,ke),F(`YYYYYY`,Fe,ke),Ze([`YYYYY`,`YYYYYY`],tt),Ze(`YYYY`,function(e,t){t[tt]=e.length===2?n.parseTwoDigitYear(e):Ye(e)}),Ze(`YY`,function(e,t){t[tt]=n.parseTwoDigitYear(e)}),Ze(`Y`,function(e,t){t[tt]=parseInt(e,10)});function ut(e){return et(e)?366:365}n.parseTwoDigitYear=function(e){return Ye(e)+(Ye(e)>68?1900:2e3)};var dt=pt(`FullYear`,!0);function ft(){return et(this.year())}function pt(e,t){return function(r){return r==null?mt(this,e):(ht(this,e,r),n.updateOffset(this,t),this)}}function mt(e,t){if(!e.isValid())return NaN;var n=e._d,r=e._isUTC;switch(t){case`Milliseconds`:return r?n.getUTCMilliseconds():n.getMilliseconds();case`Seconds`:return r?n.getUTCSeconds():n.getSeconds();case`Minutes`:return r?n.getUTCMinutes():n.getMinutes();case`Hours`:return r?n.getUTCHours():n.getHours();case`Date`:return r?n.getUTCDate():n.getDate();case`Day`:return r?n.getUTCDay():n.getDay();case`Month`:return r?n.getUTCMonth():n.getMonth();case`FullYear`:return r?n.getUTCFullYear():n.getFullYear();default:return NaN}}function ht(e,t,n){var r,i,a,o,s;if(!(!e.isValid()||isNaN(n))){switch(r=e._d,i=e._isUTC,t){case`Milliseconds`:i?r.setUTCMilliseconds(n):r.setMilliseconds(n);return;case`Seconds`:i?r.setUTCSeconds(n):r.setSeconds(n);return;case`Minutes`:i?r.setUTCMinutes(n):r.setMinutes(n);return;case`Hours`:i?r.setUTCHours(n):r.setHours(n);return;case`Date`:i?r.setUTCDate(n):r.setDate(n);return;case`FullYear`:break;default:return}a=n,o=e.month(),s=e.date(),s=s===29&&o===1&&!et(a)?28:s,i?r.setUTCFullYear(a,o,s):r.setFullYear(a,o,s)}}function gt(e){return e=xe(e),O(this[e])?this[e]():this}function _t(e,t){if(typeof e==`object`){e=Se(e);var n=we(e),r,i=n.length;for(r=0;r<i;r++)this[n[r].unit](e[n[r].unit])}else if(e=xe(e),O(this[e]))return this[e](t);return this}function vt(e,t){return(e%t+t)%t}var yt=Array.prototype.indexOf?Array.prototype.indexOf:function(e){var t;for(t=0;t<this.length;++t)if(this[t]===e)return t;return-1};function bt(e,t){if(isNaN(e)||isNaN(t))return NaN;var n=vt(t,12);return e+=(t-n)/12,n===1?et(e)?29:28:31-n%7%2}P(`M`,[`MM`,2],`Mo`,function(){return this.month()+1}),P(`MMM`,0,0,function(e){return this.localeData().monthsShort(this,e)}),P(`MMMM`,0,0,function(e){return this.localeData().months(this,e)}),F(`M`,Ae,He),F(`MM`,Ae,Ee),F(`MMM`,function(e,t){return t.monthsShortRegex(e)}),F(`MMMM`,function(e,t){return t.monthsRegex(e)}),Ze([`M`,`MM`],function(e,t){t[nt]=Ye(e)-1}),Ze([`MMM`,`MMMM`],function(e,t,n,r){var i=n._locale.monthsParse(e,r,n._strict);i==null?h(n).invalidMonth=e:t[nt]=i});var xt=`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),St=`Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec`.split(`_`),Ct=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,wt=Ve,Tt=Ve;function I(e,t){return e?i(this._months)?this._months[e.month()]:this._months[(this._months.isFormat||Ct).test(t)?`format`:`standalone`][e.month()]:i(this._months)?this._months:this._months.standalone}function Et(e,t){return e?i(this._monthsShort)?this._monthsShort[e.month()]:this._monthsShort[Ct.test(t)?`format`:`standalone`][e.month()]:i(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Dt(e,t,n){var r,i,a,o=e.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],r=0;r<12;++r)a=p([2e3,r]),this._shortMonthsParse[r]=this.monthsShort(a,``).toLocaleLowerCase(),this._longMonthsParse[r]=this.months(a,``).toLocaleLowerCase();return n?t===`MMM`?(i=yt.call(this._shortMonthsParse,o),i===-1?null:i):(i=yt.call(this._longMonthsParse,o),i===-1?null:i):t===`MMM`?(i=yt.call(this._shortMonthsParse,o),i===-1?(i=yt.call(this._longMonthsParse,o),i===-1?null:i):i):(i=yt.call(this._longMonthsParse,o),i===-1?(i=yt.call(this._shortMonthsParse,o),i===-1?null:i):i)}function Ot(e,t,n){var r,i,a;if(this._monthsParseExact)return Dt.call(this,e,t,n);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),r=0;r<12;r++)if(i=p([2e3,r]),n&&!this._longMonthsParse[r]&&(this._longMonthsParse[r]=RegExp(`^`+this.months(i,``).replace(`.`,``)+`$`,`i`),this._shortMonthsParse[r]=RegExp(`^`+this.monthsShort(i,``).replace(`.`,``)+`$`,`i`)),!n&&!this._monthsParse[r]&&(a=`^`+this.months(i,``)+`|^`+this.monthsShort(i,``),this._monthsParse[r]=new RegExp(a.replace(`.`,``),`i`)),n&&t===`MMMM`&&this._longMonthsParse[r].test(e)||n&&t===`MMM`&&this._shortMonthsParse[r].test(e)||!n&&this._monthsParse[r].test(e))return r}function kt(e,t){if(!e.isValid())return e;if(typeof t==`string`){if(/^\d+$/.test(t))t=Ye(t);else if(t=e.localeData().monthsParse(t),!l(t))return e}var n=t,r=e.date();return r=r<29?r:Math.min(r,bt(e.year(),n)),e._isUTC?e._d.setUTCMonth(n,r):e._d.setMonth(n,r),e}function At(e){return e==null?mt(this,`Month`):(kt(this,e),n.updateOffset(this,!0),this)}function jt(){return bt(this.year(),this.month())}function Mt(e){return this._monthsParseExact?(o(this,`_monthsRegex`)||Pt.call(this),e?this._monthsShortStrictRegex:this._monthsShortRegex):(o(this,`_monthsShortRegex`)||(this._monthsShortRegex=wt),this._monthsShortStrictRegex&&e?this._monthsShortStrictRegex:this._monthsShortRegex)}function Nt(e){return this._monthsParseExact?(o(this,`_monthsRegex`)||Pt.call(this),e?this._monthsStrictRegex:this._monthsRegex):(o(this,`_monthsRegex`)||(this._monthsRegex=Tt),this._monthsStrictRegex&&e?this._monthsStrictRegex:this._monthsRegex)}function Pt(){function e(e,t){return t.length-e.length}var t=[],n=[],r=[],i,a,o,s;for(i=0;i<12;i++)a=p([2e3,i]),o=qe(this.monthsShort(a,``)),s=qe(this.months(a,``)),t.push(o),n.push(s),r.push(s),r.push(o);t.sort(e),n.sort(e),r.sort(e),this._monthsRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`),this._monthsShortStrictRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`)}function Ft(e,t,n,r,i,a,o){var s;return e<100&&e>=0?(s=new Date(e+400,t,n,r,i,a,o),isFinite(s.getFullYear())&&s.setFullYear(e)):s=new Date(e,t,n,r,i,a,o),s}function It(e){var t,n;return e<100&&e>=0?(n=Array.prototype.slice.call(arguments),n[0]=e+400,t=new Date(Date.UTC.apply(null,n)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(e)):t=new Date(Date.UTC.apply(null,arguments)),t}function Lt(e,t,n){var r=7+t-n;return-((7+It(e,0,r).getUTCDay()-t)%7)+r-1}function L(e,t,n,r,i){var a=(7+n-r)%7,o=Lt(e,r,i),s=1+7*(t-1)+a+o,c,l;return s<=0?(c=e-1,l=ut(c)+s):s>ut(e)?(c=e+1,l=s-ut(e)):(c=e,l=s),{year:c,dayOfYear:l}}function Rt(e,t,n){var r=Lt(e.year(),t,n),i=Math.floor((e.dayOfYear()-r-1)/7)+1,a,o;return i<1?(o=e.year()-1,a=i+zt(o,t,n)):i>zt(e.year(),t,n)?(a=i-zt(e.year(),t,n),o=e.year()+1):(o=e.year(),a=i),{week:a,year:o}}function zt(e,t,n){var r=Lt(e,t,n),i=Lt(e+1,t,n);return(ut(e)-r+i)/7}P(`w`,[`ww`,2],`wo`,`week`),P(`W`,[`WW`,2],`Wo`,`isoWeek`),F(`w`,Ae,He),F(`ww`,Ae,Ee),F(`W`,Ae,He),F(`WW`,Ae,Ee),Qe([`w`,`ww`,`W`,`WW`],function(e,t,n,r){t[r.substr(0,1)]=Ye(e)});function Bt(e){return Rt(e,this._week.dow,this._week.doy).week}var R={dow:0,doy:6};function Vt(){return this._week.dow}function Ht(){return this._week.doy}function Ut(e){var t=this.localeData().week(this);return e==null?t:this.add((e-t)*7,`d`)}function Wt(e){var t=Rt(this,1,4).week;return e==null?t:this.add((e-t)*7,`d`)}P(`d`,0,`do`,`day`),P(`dd`,0,0,function(e){return this.localeData().weekdaysMin(this,e)}),P(`ddd`,0,0,function(e){return this.localeData().weekdaysShort(this,e)}),P(`dddd`,0,0,function(e){return this.localeData().weekdays(this,e)}),P(`e`,0,0,`weekday`),P(`E`,0,0,`isoWeekday`),F(`d`,Ae),F(`e`,Ae),F(`E`,Ae),F(`dd`,function(e,t){return t.weekdaysMinRegex(e)}),F(`ddd`,function(e,t){return t.weekdaysShortRegex(e)}),F(`dddd`,function(e,t){return t.weekdaysRegex(e)}),Qe([`dd`,`ddd`,`dddd`],function(e,t,n,r){var i=n._locale.weekdaysParse(e,r,n._strict);i==null?h(n).invalidWeekday=e:t.d=i}),Qe([`d`,`e`,`E`],function(e,t,n,r){t[r]=Ye(e)});function Gt(e,t){return typeof e==`string`?isNaN(e)?(e=t.weekdaysParse(e),typeof e==`number`?e:null):parseInt(e,10):e}function Kt(e,t){return typeof e==`string`?t.weekdaysParse(e)%7||7:isNaN(e)?null:e}function qt(e,t){return e.slice(t,7).concat(e.slice(0,t))}var Jt=`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),Yt=`Sun_Mon_Tue_Wed_Thu_Fri_Sat`.split(`_`),Xt=`Su_Mo_Tu_We_Th_Fr_Sa`.split(`_`),Zt=Ve,Qt=Ve,$t=Ve;function en(e,t){var n=i(this._weekdays)?this._weekdays:this._weekdays[e&&e!==!0&&this._weekdays.isFormat.test(t)?`format`:`standalone`];return e===!0?qt(n,this._week.dow):e?n[e.day()]:n}function tn(e){return e===!0?qt(this._weekdaysShort,this._week.dow):e?this._weekdaysShort[e.day()]:this._weekdaysShort}function nn(e){return e===!0?qt(this._weekdaysMin,this._week.dow):e?this._weekdaysMin[e.day()]:this._weekdaysMin}function rn(e,t,n){var r,i,a,o=e.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],r=0;r<7;++r)a=p([2e3,1]).day(r),this._minWeekdaysParse[r]=this.weekdaysMin(a,``).toLocaleLowerCase(),this._shortWeekdaysParse[r]=this.weekdaysShort(a,``).toLocaleLowerCase(),this._weekdaysParse[r]=this.weekdays(a,``).toLocaleLowerCase();return n?t===`dddd`?(i=yt.call(this._weekdaysParse,o),i===-1?null:i):t===`ddd`?(i=yt.call(this._shortWeekdaysParse,o),i===-1?null:i):(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i):t===`dddd`?(i=yt.call(this._weekdaysParse,o),i!==-1||(i=yt.call(this._shortWeekdaysParse,o),i!==-1)?i:(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i)):t===`ddd`?(i=yt.call(this._shortWeekdaysParse,o),i!==-1||(i=yt.call(this._weekdaysParse,o),i!==-1)?i:(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i)):(i=yt.call(this._minWeekdaysParse,o),i!==-1||(i=yt.call(this._weekdaysParse,o),i!==-1)?i:(i=yt.call(this._shortWeekdaysParse,o),i===-1?null:i))}function an(e,t,n){var r,i,a;if(this._weekdaysParseExact)return rn.call(this,e,t,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),r=0;r<7;r++)if(i=p([2e3,1]).day(r),n&&!this._fullWeekdaysParse[r]&&(this._fullWeekdaysParse[r]=RegExp(`^`+this.weekdays(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._shortWeekdaysParse[r]=RegExp(`^`+this.weekdaysShort(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._minWeekdaysParse[r]=RegExp(`^`+this.weekdaysMin(i,``).replace(`.`,`\\.?`)+`$`,`i`)),this._weekdaysParse[r]||(a=`^`+this.weekdays(i,``)+`|^`+this.weekdaysShort(i,``)+`|^`+this.weekdaysMin(i,``),this._weekdaysParse[r]=new RegExp(a.replace(`.`,``),`i`)),n&&t===`dddd`&&this._fullWeekdaysParse[r].test(e)||n&&t===`ddd`&&this._shortWeekdaysParse[r].test(e)||n&&t===`dd`&&this._minWeekdaysParse[r].test(e)||!n&&this._weekdaysParse[r].test(e))return r}function on(e){if(!this.isValid())return e==null?NaN:this;var t=mt(this,`Day`);return e==null?t:(e=Gt(e,this.localeData()),this.add(e-t,`d`))}function sn(e){if(!this.isValid())return e==null?NaN:this;var t=(this.day()+7-this.localeData()._week.dow)%7;return e==null?t:this.add(e-t,`d`)}function cn(e){if(!this.isValid())return e==null?NaN:this;if(e!=null){var t=Kt(e,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function ln(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||z.call(this),e?this._weekdaysStrictRegex:this._weekdaysRegex):(o(this,`_weekdaysRegex`)||(this._weekdaysRegex=Zt),this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex)}function un(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||z.call(this),e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(o(this,`_weekdaysShortRegex`)||(this._weekdaysShortRegex=Qt),this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function dn(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||z.call(this),e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(o(this,`_weekdaysMinRegex`)||(this._weekdaysMinRegex=$t),this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function z(){function e(e,t){return t.length-e.length}var t=[],n=[],r=[],i=[],a,o,s,c,l;for(a=0;a<7;a++)o=p([2e3,1]).day(a),s=qe(this.weekdaysMin(o,``)),c=qe(this.weekdaysShort(o,``)),l=qe(this.weekdays(o,``)),t.push(s),n.push(c),r.push(l),i.push(s),i.push(c),i.push(l);t.sort(e),n.sort(e),r.sort(e),i.sort(e),this._weekdaysRegex=RegExp(`^(`+i.join(`|`)+`)`,`i`),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._weekdaysShortStrictRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`),this._weekdaysMinStrictRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`)}function fn(){return this.hours()%12||12}function pn(){return this.hours()||24}P(`H`,[`HH`,2],0,`hour`),P(`h`,[`hh`,2],0,fn),P(`k`,[`kk`,2],0,pn),P(`hmm`,0,0,function(){return``+fn.apply(this)+N(this.minutes(),2)}),P(`hmmss`,0,0,function(){return``+fn.apply(this)+N(this.minutes(),2)+N(this.seconds(),2)}),P(`Hmm`,0,0,function(){return``+this.hours()+N(this.minutes(),2)}),P(`Hmmss`,0,0,function(){return``+this.hours()+N(this.minutes(),2)+N(this.seconds(),2)});function mn(e,t){P(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}mn(`a`,!0),mn(`A`,!1);function hn(e,t){return t._meridiemParse}F(`a`,hn),F(`A`,hn),F(`H`,Ae,Ue),F(`h`,Ae,He),F(`k`,Ae,He),F(`HH`,Ae,Ee),F(`hh`,Ae,Ee),F(`kk`,Ae,Ee),F(`hmm`,je),F(`hmmss`,Me),F(`Hmm`,je),F(`Hmmss`,Me),Ze([`H`,`HH`],it),Ze([`k`,`kk`],function(e,t,n){var r=Ye(e);t[it]=r===24?0:r}),Ze([`a`,`A`],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),Ze([`h`,`hh`],function(e,t,n){t[it]=Ye(e),h(n).bigHour=!0}),Ze(`hmm`,function(e,t,n){var r=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r)),h(n).bigHour=!0}),Ze(`hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r,2)),t[ot]=Ye(e.substr(i)),h(n).bigHour=!0}),Ze(`Hmm`,function(e,t,n){var r=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r))}),Ze(`Hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r,2)),t[ot]=Ye(e.substr(i))});function gn(e){return(e+``).toLowerCase().charAt(0)===`p`}var _n=/[ap]\.?m?\.?/i,vn=pt(`Hours`,!0);function yn(e,t,n){return e>11?n?`pm`:`PM`:n?`am`:`AM`}var bn={calendar:ee,longDateFormat:ue,invalidDate:fe,ordinal:me,dayOfMonthOrdinalParse:he,relativeTime:_e,months:xt,monthsShort:St,week:R,weekdays:Jt,weekdaysMin:Xt,weekdaysShort:Yt,meridiemParse:_n},xn={},Sn={},Cn;function wn(e,t){var n,r=Math.min(e.length,t.length);for(n=0;n<r;n+=1)if(e[n]!==t[n])return n;return r}function Tn(e){return e&&e.toLowerCase().replace(`_`,`-`)}function En(e){for(var t=0,n,r,i,a;t<e.length;){for(a=Tn(e[t]).split(`-`),n=a.length,r=Tn(e[t+1]),r=r?r.split(`-`):null;n>0;){if(i=On(a.slice(0,n).join(`-`)),i)return i;if(r&&r.length>=n&&wn(a,r)>=n-1)break;n--}t++}return Cn}function Dn(e){return!!(e&&e.match(`^[^/\\\\]*$`))}function On(e){var n=null,r;if(xn[e]===void 0&&t!==void 0&&t&&t.exports&&Dn(e))try{n=Cn._abbr,r=require,r(`./locale/`+e),kn(n)}catch{xn[e]=null}return xn[e]}function kn(e,t){var n;return e&&(n=c(t)?Mn(e):An(e,t),n?Cn=n:typeof console<`u`&&console.warn&&console.warn(`Locale `+e+` not found. Did you forget to load it?`)),Cn._abbr}function An(e,t){if(t!==null){var n,r=bn;if(t.abbr=e,xn[e]!=null)D(`defineLocaleOverride`,`use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info.`),r=xn[e]._config;else if(t.parentLocale!=null)if(xn[t.parentLocale]!=null)r=xn[t.parentLocale]._config;else if(n=On(t.parentLocale),n!=null)r=n._config;else return Sn[t.parentLocale]||(Sn[t.parentLocale]=[]),Sn[t.parentLocale].push({name:e,config:t}),null;return xn[e]=new j(A(r,t)),Sn[e]&&Sn[e].forEach(function(e){An(e.name,e.config)}),kn(e),xn[e]}else return delete xn[e],null}function jn(e,t){if(t!=null){var n,r,i=bn;xn[e]!=null&&xn[e].parentLocale!=null?xn[e].set(A(xn[e]._config,t)):(r=On(e),r!=null&&(i=r._config),t=A(i,t),r??(t.abbr=e),n=new j(t),n.parentLocale=xn[e],xn[e]=n),kn(e)}else xn[e]!=null&&(xn[e].parentLocale==null?xn[e]!=null&&delete xn[e]:(xn[e]=xn[e].parentLocale,e===kn()&&kn(e)));return xn[e]}function Mn(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return Cn;if(!i(e)){if(t=On(e),t)return t;e=[e]}return En(e)}function Nn(){return M(xn)}function Pn(e){var t,n=e._a;return n&&h(e).overflow===-2&&(t=n[nt]<0||n[nt]>11?nt:n[rt]<1||n[rt]>bt(n[tt],n[nt])?rt:n[it]<0||n[it]>24||n[it]===24&&(n[at]!==0||n[ot]!==0||n[st]!==0)?it:n[at]<0||n[at]>59?at:n[ot]<0||n[ot]>59?ot:n[st]<0||n[st]>999?st:-1,h(e)._overflowDayOfYear&&(t<tt||t>rt)&&(t=rt),h(e)._overflowWeeks&&t===-1&&(t=ct),h(e)._overflowWeekday&&t===-1&&(t=lt),h(e).overflow=t),e}var Fn=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,In=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ln=/Z|[+-]\d\d(?::?\d\d)?/,Rn=[[`YYYYYY-MM-DD`,/[+-]\d{6}-\d\d-\d\d/],[`YYYY-MM-DD`,/\d{4}-\d\d-\d\d/],[`GGGG-[W]WW-E`,/\d{4}-W\d\d-\d/],[`GGGG-[W]WW`,/\d{4}-W\d\d/,!1],[`YYYY-DDD`,/\d{4}-\d{3}/],[`YYYY-MM`,/\d{4}-\d\d/,!1],[`YYYYYYMMDD`,/[+-]\d{10}/],[`YYYYMMDD`,/\d{8}/],[`GGGG[W]WWE`,/\d{4}W\d{3}/],[`GGGG[W]WW`,/\d{4}W\d{2}/,!1],[`YYYYDDD`,/\d{7}/],[`YYYYMM`,/\d{6}/,!1],[`YYYY`,/\d{4}/,!1]],zn=[[`HH:mm:ss.SSSS`,/\d\d:\d\d:\d\d\.\d+/],[`HH:mm:ss,SSSS`,/\d\d:\d\d:\d\d,\d+/],[`HH:mm:ss`,/\d\d:\d\d:\d\d/],[`HH:mm`,/\d\d:\d\d/],[`HHmmss.SSSS`,/\d\d\d\d\d\d\.\d+/],[`HHmmss,SSSS`,/\d\d\d\d\d\d,\d+/],[`HHmmss`,/\d\d\d\d\d\d/],[`HHmm`,/\d\d\d\d/],[`HH`,/\d\d/]],Bn=/^\/?Date\((-?\d+)/i,Vn=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,Hn={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Un(e){var t,n,r=e._i,i=Fn.exec(r)||In.exec(r),a,o,s,c,l=Rn.length,u=zn.length;if(i){for(h(e).iso=!0,t=0,n=l;t<n;t++)if(Rn[t][1].exec(i[1])){o=Rn[t][0],a=Rn[t][2]!==!1;break}if(o==null){e._isValid=!1;return}if(i[3]){for(t=0,n=u;t<n;t++)if(zn[t][1].exec(i[3])){s=(i[2]||` `)+zn[t][0];break}if(s==null){e._isValid=!1;return}}if(!a&&s!=null){e._isValid=!1;return}if(i[4])if(Ln.exec(i[4]))c=`Z`;else{e._isValid=!1;return}e._f=o+(s||``)+(c||``),tr(e)}else e._isValid=!1}function Wn(e,t,n,r,i,a){var o=[Gn(e),St.indexOf(t),parseInt(n,10),parseInt(r,10),parseInt(i,10)];return a&&o.push(parseInt(a,10)),o}function Gn(e){var t=parseInt(e,10);return t<=49?2e3+t:t<=999?1900+t:t}function Kn(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).replace(/^\s\s*/,``).replace(/\s\s*$/,``)}function qn(e,t,n){return e&&Yt.indexOf(e)!==new Date(t[0],t[1],t[2]).getDay()?(h(n).weekdayMismatch=!0,n._isValid=!1,!1):!0}function Jn(e,t,n){if(e)return Hn[e];if(t)return 0;var r=parseInt(n,10),i=r%100;return(r-i)/100*60+i}function Yn(e){var t=Vn.exec(Kn(e._i)),n;if(t){if(n=Wn(t[4],t[3],t[2],t[5],t[6],t[7]),!qn(t[1],n,e))return;e._a=n,e._tzm=Jn(t[8],t[9],t[10]),e._d=It.apply(null,e._a),e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),h(e).rfc2822=!0}else e._isValid=!1}function Xn(e){var t=Bn.exec(e._i);if(t!==null){e._d=new Date(+t[1]);return}if(Un(e),e._isValid===!1)delete e._isValid;else return;if(Yn(e),e._isValid===!1)delete e._isValid;else return;e._strict?e._isValid=!1:n.createFromInputFallback(e)}n.createFromInputFallback=T(`value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.`,function(e){e._d=new Date(e._i+(e._useUTC?` UTC`:``))});function Zn(e,t,n){return e??t??n}function Qn(e){var t=new Date(n.now());return e._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function $n(e){var t,n,r=[],i,a,o;if(!e._d){for(i=Qn(e),e._w&&e._a[rt]==null&&e._a[nt]==null&&er(e),e._dayOfYear!=null&&(o=Zn(e._a[tt],i[tt]),(e._dayOfYear>ut(o)||e._dayOfYear===0)&&(h(e)._overflowDayOfYear=!0),n=It(o,0,e._dayOfYear),e._a[nt]=n.getUTCMonth(),e._a[rt]=n.getUTCDate()),t=0;t<3&&e._a[t]==null;++t)e._a[t]=r[t]=i[t];for(;t<7;t++)e._a[t]=r[t]=e._a[t]==null?+(t===2):e._a[t];e._a[it]===24&&e._a[at]===0&&e._a[ot]===0&&e._a[st]===0&&(e._nextDay=!0,e._a[it]=0),e._d=(e._useUTC?It:Ft).apply(null,r),a=e._useUTC?e._d.getUTCDay():e._d.getDay(),e._tzm!=null&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[it]=24),e._w&&e._w.d!==void 0&&e._w.d!==a&&(h(e).weekdayMismatch=!0)}}function er(e){var t=e._w,n,r,i,a,o,s,c,l;t.GG!=null||t.W!=null||t.E!=null?(a=1,o=4,n=Zn(t.GG,e._a[tt],Rt(lr(),1,4).year),r=Zn(t.W,1),i=Zn(t.E,1),(i<1||i>7)&&(c=!0)):(a=e._locale._week.dow,o=e._locale._week.doy,l=Rt(lr(),a,o),n=Zn(t.gg,e._a[tt],l.year),r=Zn(t.w,l.week),t.d==null?t.e==null?i=a:(i=t.e+a,(t.e<0||t.e>6)&&(c=!0)):(i=t.d,(i<0||i>6)&&(c=!0))),r<1||r>zt(n,a,o)?h(e)._overflowWeeks=!0:c==null?(s=L(n,r,i,a,o),e._a[tt]=s.year,e._dayOfYear=s.dayOfYear):h(e)._overflowWeekday=!0}n.ISO_8601=function(){},n.RFC_2822=function(){};function tr(e){if(e._f===n.ISO_8601){Un(e);return}if(e._f===n.RFC_2822){Yn(e);return}e._a=[],h(e).empty=!0;var t=``+e._i,r,i,a,o,s,c=t.length,l=0,u,d;for(a=le(e._f,e._locale).match(ne)||[],d=a.length,r=0;r<d;r++)o=a[r],i=(t.match(Ge(o,e))||[])[0],i&&(s=t.substr(0,t.indexOf(i)),s.length>0&&h(e).unusedInput.push(s),t=t.slice(t.indexOf(i)+i.length),l+=i.length),ae[o]?(i?h(e).empty=!1:h(e).unusedTokens.push(o),$e(o,i,e)):e._strict&&!i&&h(e).unusedTokens.push(o);h(e).charsLeftOver=c-l,t.length>0&&h(e).unusedInput.push(t),e._a[it]<=12&&h(e).bigHour===!0&&e._a[it]>0&&(h(e).bigHour=void 0),h(e).parsedDateParts=e._a.slice(0),h(e).meridiem=e._meridiem,e._a[it]=nr(e._locale,e._a[it],e._meridiem),u=h(e).era,u!==null&&(e._a[tt]=e._locale.erasConvertYear(u,e._a[tt])),$n(e),Pn(e)}function nr(e,t,n){var r;return n==null?t:e.meridiemHour==null?e.isPM==null?t:(r=e.isPM(n),r&&t<12&&(t+=12),!r&&t===12&&(t=0),t):e.meridiemHour(t,n)}function rr(e){var t,n,r,i,a,o,s=!1,c=e._f.length;if(c===0){h(e).invalidFormat=!0,e._d=new Date(NaN);return}for(i=0;i<c;i++)a=0,o=!1,t=x({},e),e._useUTC!=null&&(t._useUTC=e._useUTC),t._f=e._f[i],tr(t),_(t)&&(o=!0),a+=h(t).charsLeftOver,a+=h(t).unusedTokens.length*10,h(t).score=a,s?a<r&&(r=a,n=t):(r==null||a<r||o)&&(r=a,n=t,o&&(s=!0));f(e,n||t)}function ir(e){if(!e._d){var t=Se(e._i),n=t.day===void 0?t.date:t.day;e._a=d([t.year,t.month,n,t.hour,t.minute,t.second,t.millisecond],function(e){return e&&parseInt(e,10)}),$n(e)}}function ar(e){var t=new S(Pn(or(e)));return t._nextDay&&(t.add(1,`d`),t._nextDay=void 0),t}function or(e){var t=e._i,n=e._f;return e._locale=e._locale||Mn(e._l),t===null||n===void 0&&t===``?v({nullInput:!0}):(typeof t==`string`&&(e._i=t=e._locale.preparse(t)),C(t)?new S(Pn(t)):(u(t)?e._d=t:i(n)?rr(e):n?tr(e):sr(e),_(e)||(e._d=null),e))}function sr(e){var t=e._i;c(t)?e._d=new Date(n.now()):u(t)?e._d=new Date(t.valueOf()):typeof t==`string`?Xn(e):i(t)?(e._a=d(t.slice(0),function(e){return parseInt(e,10)}),$n(e)):a(t)?ir(e):l(t)?e._d=new Date(t):n.createFromInputFallback(e)}function cr(e,t,n,r,o){var c={};return(t===!0||t===!1)&&(r=t,t=void 0),(n===!0||n===!1)&&(r=n,n=void 0),(a(e)&&s(e)||i(e)&&e.length===0)&&(e=void 0),c._isAMomentObject=!0,c._useUTC=c._isUTC=o,c._l=n,c._i=e,c._f=t,c._strict=r,ar(c)}function lr(e,t,n,r){return cr(e,t,n,r,!1)}var ur=T(`moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/`,function(){var e=lr.apply(null,arguments);return this.isValid()&&e.isValid()?e<this?this:e:v()}),dr=T(`moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/`,function(){var e=lr.apply(null,arguments);return this.isValid()&&e.isValid()?e>this?this:e:v()});function fr(e,t){var n,r;if(t.length===1&&i(t[0])&&(t=t[0]),!t.length)return lr();for(n=t[0],r=1;r<t.length;++r)(!t[r].isValid()||t[r][e](n))&&(n=t[r]);return n}function pr(){return fr(`isBefore`,[].slice.call(arguments,0))}function mr(){return fr(`isAfter`,[].slice.call(arguments,0))}var hr=function(){return Date.now?Date.now():+new Date},gr=[`year`,`quarter`,`month`,`week`,`day`,`hour`,`minute`,`second`,`millisecond`];function _r(e){var t,n=!1,r,i=gr.length;for(t in e)if(o(e,t)&&!(yt.call(gr,t)!==-1&&(e[t]==null||!isNaN(e[t]))))return!1;for(r=0;r<i;++r)if(e[gr[r]]){if(n)return!1;parseFloat(e[gr[r]])!==Ye(e[gr[r]])&&(n=!0)}return!0}function vr(){return this._isValid}function yr(){return Vr(NaN)}function B(e){var t=Se(e),n=t.year||0,r=t.quarter||0,i=t.month||0,a=t.week||t.isoWeek||0,o=t.day||0,s=t.hour||0,c=t.minute||0,l=t.second||0,u=t.millisecond||0;this._isValid=_r(t),this._milliseconds=+u+l*1e3+c*6e4+s*1e3*60*60,this._days=+o+a*7,this._months=+i+r*3+n*12,this._data={},this._locale=Mn(),this._bubble()}function br(e){return e instanceof B}function xr(e){return e<0?Math.round(-1*e)*-1:Math.round(e)}function Sr(e,t,n){var r=Math.min(e.length,t.length),i=Math.abs(e.length-t.length),a=0,o;for(o=0;o<r;o++)(n&&e[o]!==t[o]||!n&&Ye(e[o])!==Ye(t[o]))&&a++;return a+i}function Cr(e,t){P(e,0,0,function(){var e=this.utcOffset(),n=`+`;return e<0&&(e=-e,n=`-`),n+N(~~(e/60),2)+t+N(~~e%60,2)})}Cr(`Z`,`:`),Cr(`ZZ`,``),F(`Z`,ze),F(`ZZ`,ze),Ze([`Z`,`ZZ`],function(e,t,n){n._useUTC=!0,n._tzm=Tr(ze,e)});var wr=/([\+\-]|\d\d)/gi;function Tr(e,t){var n=(t||``).match(e),r,i,a;return n===null?null:(r=n[n.length-1]||[],i=(r+``).match(wr)||[`-`,0,0],a=+(i[1]*60)+Ye(i[2]),a===0?0:i[0]===`+`?a:-a)}function Er(e,t){var r,i;return t._isUTC?(r=t.clone(),i=(C(e)||u(e)?e.valueOf():lr(e).valueOf())-r.valueOf(),r._d.setTime(r._d.valueOf()+i),n.updateOffset(r,!1),r):lr(e).local()}function Dr(e){return-Math.round(e._d.getTimezoneOffset())}n.updateOffset=function(){};function Or(e,t,r){var i=this._offset||0,a;if(!this.isValid())return e==null?NaN:this;if(e!=null){if(typeof e==`string`){if(e=Tr(ze,e),e===null)return this}else Math.abs(e)<16&&!r&&(e*=60);return!this._isUTC&&t&&(a=Dr(this)),this._offset=e,this._isUTC=!0,a!=null&&this.add(a,`m`),i!==e&&(!t||this._changeInProgress?Kr(this,Vr(e-i,`m`),1,!1):this._changeInProgress||(this._changeInProgress=!0,n.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?i:Dr(this)}function kr(e,t){return e==null?-this.utcOffset():(typeof e!=`string`&&(e=-e),this.utcOffset(e,t),this)}function Ar(e){return this.utcOffset(0,e)}function jr(e){return this._isUTC&&(this.utcOffset(0,e),this._isUTC=!1,e&&this.subtract(Dr(this),`m`)),this}function Mr(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i==`string`){var e=Tr(Re,this._i);e==null?this.utcOffset(0,!0):this.utcOffset(e)}return this}function Nr(e){return this.isValid()?(e=e?lr(e).utcOffset():0,(this.utcOffset()-e)%60==0):!1}function Pr(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Fr(){if(!c(this._isDSTShifted))return this._isDSTShifted;var e={},t;return x(e,this),e=or(e),e._a?(t=e._isUTC?p(e._a):lr(e._a),this._isDSTShifted=this.isValid()&&Sr(e._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function Ir(){return this.isValid()?!this._isUTC:!1}function Lr(){return this.isValid()?this._isUTC:!1}function Rr(){return this.isValid()?this._isUTC&&this._offset===0:!1}var zr=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,Br=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Vr(e,t){var n=e,r=null,i,a,s;return br(e)?n={ms:e._milliseconds,d:e._days,M:e._months}:l(e)||!isNaN(+e)?(n={},t?n[t]=+e:n.milliseconds=+e):(r=zr.exec(e))?(i=r[1]===`-`?-1:1,n={y:0,d:Ye(r[rt])*i,h:Ye(r[it])*i,m:Ye(r[at])*i,s:Ye(r[ot])*i,ms:Ye(xr(r[st]*1e3))*i}):(r=Br.exec(e))?(i=r[1]===`-`?-1:1,n={y:Hr(r[2],i),M:Hr(r[3],i),w:Hr(r[4],i),d:Hr(r[5],i),h:Hr(r[6],i),m:Hr(r[7],i),s:Hr(r[8],i)}):n==null?n={}:typeof n==`object`&&(`from`in n||`to`in n)&&(s=Wr(lr(n.from),lr(n.to)),n={},n.ms=s.milliseconds,n.M=s.months),a=new B(n),br(e)&&o(e,`_locale`)&&(a._locale=e._locale),br(e)&&o(e,`_isValid`)&&(a._isValid=e._isValid),a}Vr.fn=B.prototype,Vr.invalid=yr;function Hr(e,t){var n=e&&parseFloat(e.replace(`,`,`.`));return(isNaN(n)?0:n)*t}function Ur(e,t){var n={};return n.months=t.month()-e.month()+(t.year()-e.year())*12,e.clone().add(n.months,`M`).isAfter(t)&&--n.months,n.milliseconds=t-+e.clone().add(n.months,`M`),n}function Wr(e,t){var n;return e.isValid()&&t.isValid()?(t=Er(t,e),e.isBefore(t)?n=Ur(e,t):(n=Ur(t,e),n.milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}function Gr(e,t){return function(n,r){var i,a;return r!==null&&!isNaN(+r)&&(D(t,`moment().`+t+`(period, number) is deprecated. Please use moment().`+t+`(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.`),a=n,n=r,r=a),i=Vr(n,r),Kr(this,i,e),this}}function Kr(e,t,r,i){var a=t._milliseconds,o=xr(t._days),s=xr(t._months);e.isValid()&&(i=i??!0,s&&kt(e,mt(e,`Month`)+s*r),o&&ht(e,`Date`,mt(e,`Date`)+o*r),a&&e._d.setTime(e._d.valueOf()+a*r),i&&n.updateOffset(e,o||s))}var qr=Gr(1,`add`),Jr=Gr(-1,`subtract`);function Yr(e){return typeof e==`string`||e instanceof String}function Xr(e){return C(e)||u(e)||Yr(e)||l(e)||Qr(e)||Zr(e)||e==null}function Zr(e){var t=a(e)&&!s(e),n=!1,r=[`years`,`year`,`y`,`months`,`month`,`M`,`days`,`day`,`d`,`dates`,`date`,`D`,`hours`,`hour`,`h`,`minutes`,`minute`,`m`,`seconds`,`second`,`s`,`milliseconds`,`millisecond`,`ms`],i,c,l=r.length;for(i=0;i<l;i+=1)c=r[i],n=n||o(e,c);return t&&n}function Qr(e){var t=i(e),n=!1;return t&&(n=e.filter(function(t){return!l(t)&&Yr(e)}).length===0),t&&n}function $r(e){var t=a(e)&&!s(e),n=!1,r=[`sameDay`,`nextDay`,`lastDay`,`nextWeek`,`lastWeek`,`sameElse`],i,c;for(i=0;i<r.length;i+=1)c=r[i],n=n||o(e,c);return t&&n}function ei(e,t){var n=e.diff(t,`days`,!0);return n<-6?`sameElse`:n<-1?`lastWeek`:n<0?`lastDay`:n<1?`sameDay`:n<2?`nextDay`:n<7?`nextWeek`:`sameElse`}function ti(e,t){arguments.length===1&&(arguments[0]?Xr(arguments[0])?(e=arguments[0],t=void 0):$r(arguments[0])&&(t=arguments[0],e=void 0):(e=void 0,t=void 0));var r=e||lr(),i=Er(r,this).startOf(`day`),a=n.calendarFormat(this,i)||`sameElse`,o=t&&(O(t[a])?t[a].call(this,r):t[a]);return this.format(o||this.localeData().calendar(a,this,lr(r)))}function ni(){return new S(this)}function ri(e,t){var n=C(e)?e:lr(e);return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()>n.valueOf():n.valueOf()<this.clone().startOf(t).valueOf()):!1}function ii(e,t){var n=C(e)?e:lr(e);return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()<n.valueOf():this.clone().endOf(t).valueOf()<n.valueOf()):!1}function ai(e,t,n,r){var i=C(e)?e:lr(e),a=C(t)?t:lr(t);return this.isValid()&&i.isValid()&&a.isValid()?(r=r||`()`,(r[0]===`(`?this.isAfter(i,n):!this.isBefore(i,n))&&(r[1]===`)`?this.isBefore(a,n):!this.isAfter(a,n))):!1}function oi(e,t){var n=C(e)?e:lr(e),r;return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()===n.valueOf():(r=n.valueOf(),this.clone().startOf(t).valueOf()<=r&&r<=this.clone().endOf(t).valueOf())):!1}function si(e,t){return this.isSame(e,t)||this.isAfter(e,t)}function ci(e,t){return this.isSame(e,t)||this.isBefore(e,t)}function li(e,t,n){var r,i,a;if(!this.isValid()||(r=Er(e,this),!r.isValid()))return NaN;switch(i=(r.utcOffset()-this.utcOffset())*6e4,t=xe(t),t){case`year`:a=ui(this,r)/12;break;case`month`:a=ui(this,r);break;case`quarter`:a=ui(this,r)/3;break;case`second`:a=(this-r)/1e3;break;case`minute`:a=(this-r)/6e4;break;case`hour`:a=(this-r)/36e5;break;case`day`:a=(this-r-i)/864e5;break;case`week`:a=(this-r-i)/6048e5;break;default:a=this-r}return n?a:Je(a)}function ui(e,t){if(e.date()<t.date())return-ui(t,e);var n=(t.year()-e.year())*12+(t.month()-e.month()),r=e.clone().add(n,`months`),i,a;return t-r<0?(i=e.clone().add(n-1,`months`),a=(t-r)/(r-i)):(i=e.clone().add(n+1,`months`),a=(t-r)/(i-r)),-(n+a)||0}n.defaultFormat=`YYYY-MM-DDTHH:mm:ssZ`,n.defaultFormatUtc=`YYYY-MM-DDTHH:mm:ss[Z]`;function di(){return this.clone().locale(`en`).format(`ddd MMM DD YYYY HH:mm:ss [GMT]ZZ`)}function fi(e){if(!this.isValid())return null;var t=e!==!0,n=t?this.clone().utc():this;return n.year()<0||n.year()>9999?ce(n,t?`YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYYYY-MM-DD[T]HH:mm:ss.SSSZ`):O(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace(`Z`,ce(n,`Z`)):ce(n,t?`YYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYY-MM-DD[T]HH:mm:ss.SSSZ`)}function pi(){if(!this.isValid())return`moment.invalid(/* `+this._i+` */)`;var e=`moment`,t=``,n,r,i,a;return this.isLocal()||(e=this.utcOffset()===0?`moment.utc`:`moment.parseZone`,t=`Z`),n=`[`+e+`("]`,r=0<=this.year()&&this.year()<=9999?`YYYY`:`YYYYYY`,i=`-MM-DD[T]HH:mm:ss.SSS`,a=t+`[")]`,this.format(n+r+i+a)}function mi(e){e||(e=this.isUtc()?n.defaultFormatUtc:n.defaultFormat);var t=ce(this,e);return this.localeData().postformat(t)}function hi(e,t){return this.isValid()&&(C(e)&&e.isValid()||lr(e).isValid())?Vr({to:this,from:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function gi(e){return this.from(lr(),e)}function _i(e,t){return this.isValid()&&(C(e)&&e.isValid()||lr(e).isValid())?Vr({from:this,to:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function vi(e){return this.to(lr(),e)}function yi(e){var t;return e===void 0?this._locale._abbr:(t=Mn(e),t!=null&&(this._locale=t),this)}var bi=T(`moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.`,function(e){return e===void 0?this.localeData():this.locale(e)});function xi(){return this._locale}var Si=1e3,Ci=60*Si,wi=60*Ci,Ti=146097*24*wi;function Ei(e,t){return(e%t+t)%t}function Di(e,t,n){return e<100&&e>=0?new Date(e+400,t,n)-Ti:new Date(e,t,n).valueOf()}function Oi(e,t,n){return e<100&&e>=0?Date.UTC(e+400,t,n)-Ti:Date.UTC(e,t,n)}function ki(e){var t,r;if(e=xe(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(r=this._isUTC?Oi:Di,e){case`year`:t=r(this.year(),0,1);break;case`quarter`:t=r(this.year(),this.month()-this.month()%3,1);break;case`month`:t=r(this.year(),this.month(),1);break;case`week`:t=r(this.year(),this.month(),this.date()-this.weekday());break;case`isoWeek`:t=r(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case`day`:case`date`:t=r(this.year(),this.month(),this.date());break;case`hour`:t=this._d.valueOf(),t-=Ei(t+(this._isUTC?0:this.utcOffset()*Ci),wi);break;case`minute`:t=this._d.valueOf(),t-=Ei(t,Ci);break;case`second`:t=this._d.valueOf(),t-=Ei(t,Si);break}return this._d.setTime(t),n.updateOffset(this,!0),this}function Ai(e){var t,r;if(e=xe(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(r=this._isUTC?Oi:Di,e){case`year`:t=r(this.year()+1,0,1)-1;break;case`quarter`:t=r(this.year(),this.month()-this.month()%3+3,1)-1;break;case`month`:t=r(this.year(),this.month()+1,1)-1;break;case`week`:t=r(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case`isoWeek`:t=r(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case`day`:case`date`:t=r(this.year(),this.month(),this.date()+1)-1;break;case`hour`:t=this._d.valueOf(),t+=wi-Ei(t+(this._isUTC?0:this.utcOffset()*Ci),wi)-1;break;case`minute`:t=this._d.valueOf(),t+=Ci-Ei(t,Ci)-1;break;case`second`:t=this._d.valueOf(),t+=Si-Ei(t,Si)-1;break}return this._d.setTime(t),n.updateOffset(this,!0),this}function ji(){return this._d.valueOf()-(this._offset||0)*6e4}function Mi(){return Math.floor(this.valueOf()/1e3)}function Ni(){return new Date(this.valueOf())}function Pi(){var e=this;return[e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second(),e.millisecond()]}function Fi(){var e=this;return{years:e.year(),months:e.month(),date:e.date(),hours:e.hours(),minutes:e.minutes(),seconds:e.seconds(),milliseconds:e.milliseconds()}}function Ii(){return this.isValid()?this.toISOString():null}function Li(){return _(this)}function Ri(){return f({},h(this))}function zi(){return h(this).overflow}function Bi(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}P(`N`,0,0,`eraAbbr`),P(`NN`,0,0,`eraAbbr`),P(`NNN`,0,0,`eraAbbr`),P(`NNNN`,0,0,`eraName`),P(`NNNNN`,0,0,`eraNarrow`),P(`y`,[`y`,1],`yo`,`eraYear`),P(`y`,[`yy`,2],0,`eraYear`),P(`y`,[`yyy`,3],0,`eraYear`),P(`y`,[`yyyy`,4],0,`eraYear`),F(`N`,Zi),F(`NN`,Zi),F(`NNN`,Zi),F(`NNNN`,Qi),F(`NNNNN`,$i),Ze([`N`,`NN`,`NNN`,`NNNN`,`NNNNN`],function(e,t,n,r){var i=n._locale.erasParse(e,r,n._strict);i?h(n).era=i:h(n).invalidEra=e}),F(`y`,Ie),F(`yy`,Ie),F(`yyy`,Ie),F(`yyyy`,Ie),F(`yo`,ea),Ze([`y`,`yy`,`yyy`,`yyyy`],tt),Ze([`yo`],function(e,t,n,r){var i;n._locale._eraYearOrdinalRegex&&(i=e.match(n._locale._eraYearOrdinalRegex)),n._locale.eraYearOrdinalParse?t[tt]=n._locale.eraYearOrdinalParse(e,i):t[tt]=parseInt(e,10)});function Vi(e,t){var r,i,a,o=this._eras||Mn(`en`)._eras;for(r=0,i=o.length;r<i;++r){switch(typeof o[r].since){case`string`:a=n(o[r].since).startOf(`day`),o[r].since=a.valueOf();break}switch(typeof o[r].until){case`undefined`:o[r].until=1/0;break;case`string`:a=n(o[r].until).startOf(`day`).valueOf(),o[r].until=a.valueOf();break}}return o}function Hi(e,t,n){var r,i,a=this.eras(),o,s,c;for(e=e.toUpperCase(),r=0,i=a.length;r<i;++r)if(o=a[r].name.toUpperCase(),s=a[r].abbr.toUpperCase(),c=a[r].narrow.toUpperCase(),n)switch(t){case`N`:case`NN`:case`NNN`:if(s===e)return a[r];break;case`NNNN`:if(o===e)return a[r];break;case`NNNNN`:if(c===e)return a[r];break}else if([o,s,c].indexOf(e)>=0)return a[r]}function Ui(e,t){var r=e.since<=e.until?1:-1;return t===void 0?n(e.since).year():n(e.since).year()+(t-e.offset)*r}function Wi(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].name;return``}function Gi(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].narrow;return``}function Ki(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].abbr;return``}function qi(){var e,t,r,i,a=this.localeData().eras();for(e=0,t=a.length;e<t;++e)if(r=a[e].since<=a[e].until?1:-1,i=this.clone().startOf(`day`).valueOf(),a[e].since<=i&&i<=a[e].until||a[e].until<=i&&i<=a[e].since)return(this.year()-n(a[e].since).year())*r+a[e].offset;return this.year()}function Ji(e){return o(this,`_erasNameRegex`)||ta.call(this),e?this._erasNameRegex:this._erasRegex}function Yi(e){return o(this,`_erasAbbrRegex`)||ta.call(this),e?this._erasAbbrRegex:this._erasRegex}function Xi(e){return o(this,`_erasNarrowRegex`)||ta.call(this),e?this._erasNarrowRegex:this._erasRegex}function Zi(e,t){return t.erasAbbrRegex(e)}function Qi(e,t){return t.erasNameRegex(e)}function $i(e,t){return t.erasNarrowRegex(e)}function ea(e,t){return t._eraYearOrdinalRegex||Ie}function ta(){var e=[],t=[],n=[],r=[],i,a,o,s,c,l=this.eras();for(i=0,a=l.length;i<a;++i)o=qe(l[i].name),s=qe(l[i].abbr),c=qe(l[i].narrow),t.push(o),e.push(s),n.push(c),r.push(o),r.push(s),r.push(c);this._erasRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._erasNameRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`),this._erasAbbrRegex=RegExp(`^(`+e.join(`|`)+`)`,`i`),this._erasNarrowRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`)}P(0,[`gg`,2],0,function(){return this.weekYear()%100}),P(0,[`GG`,2],0,function(){return this.isoWeekYear()%100});function na(e,t){P(0,[e,e.length],0,t)}na(`gggg`,`weekYear`),na(`ggggg`,`weekYear`),na(`GGGG`,`isoWeekYear`),na(`GGGGG`,`isoWeekYear`),F(`G`,Le),F(`g`,Le),F(`GG`,Ae,Ee),F(`gg`,Ae,Ee),F(`GGGG`,Pe,Oe),F(`gggg`,Pe,Oe),F(`GGGGG`,Fe,ke),F(`ggggg`,Fe,ke),Qe([`gggg`,`ggggg`,`GGGG`,`GGGGG`],function(e,t,n,r){t[r.substr(0,2)]=Ye(e)}),Qe([`gg`,`GG`],function(e,t,r,i){t[i]=n.parseTwoDigitYear(e)});function ra(e){return la.call(this,e,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function ia(e){return la.call(this,e,this.isoWeek(),this.isoWeekday(),1,4)}function aa(){return zt(this.year(),1,4)}function oa(){return zt(this.isoWeekYear(),1,4)}function sa(){var e=this.localeData()._week;return zt(this.year(),e.dow,e.doy)}function ca(){var e=this.localeData()._week;return zt(this.weekYear(),e.dow,e.doy)}function la(e,t,n,r,i){var a;return e==null?Rt(this,r,i).year:(a=zt(e,r,i),t>a&&(t=a),ua.call(this,e,t,n,r,i))}function ua(e,t,n,r,i){var a=L(e,t,n,r,i),o=It(a.year,0,a.dayOfYear);return this.year(o.getUTCFullYear()),this.month(o.getUTCMonth()),this.date(o.getUTCDate()),this}P(`Q`,0,`Qo`,`quarter`),F(`Q`,Te),Ze(`Q`,function(e,t){t[nt]=(Ye(e)-1)*3});function da(e){return e==null?Math.ceil((this.month()+1)/3):this.month((e-1)*3+this.month()%3)}P(`D`,[`DD`,2],`Do`,`date`),F(`D`,Ae,He),F(`DD`,Ae,Ee),F(`Do`,function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),Ze([`D`,`DD`],rt),Ze(`Do`,function(e,t){t[rt]=Ye(e.match(Ae)[0])});var fa=pt(`Date`,!0);P(`DDD`,[`DDDD`,3],`DDDo`,`dayOfYear`),F(`DDD`,Ne),F(`DDDD`,De),Ze([`DDD`,`DDDD`],function(e,t,n){n._dayOfYear=Ye(e)});function pa(e){var t=Math.round((this.clone().startOf(`day`)-this.clone().startOf(`year`))/864e5)+1;return e==null?t:this.add(e-t,`d`)}P(`m`,[`mm`,2],0,`minute`),F(`m`,Ae,Ue),F(`mm`,Ae,Ee),Ze([`m`,`mm`],at);var ma=pt(`Minutes`,!1);P(`s`,[`ss`,2],0,`second`),F(`s`,Ae,Ue),F(`ss`,Ae,Ee),Ze([`s`,`ss`],ot);var ha=pt(`Seconds`,!1);P(`S`,0,0,function(){return~~(this.millisecond()/100)}),P(0,[`SS`,2],0,function(){return~~(this.millisecond()/10)}),P(0,[`SSS`,3],0,`millisecond`),P(0,[`SSSS`,4],0,function(){return this.millisecond()*10}),P(0,[`SSSSS`,5],0,function(){return this.millisecond()*100}),P(0,[`SSSSSS`,6],0,function(){return this.millisecond()*1e3}),P(0,[`SSSSSSS`,7],0,function(){return this.millisecond()*1e4}),P(0,[`SSSSSSSS`,8],0,function(){return this.millisecond()*1e5}),P(0,[`SSSSSSSSS`,9],0,function(){return this.millisecond()*1e6}),F(`S`,Ne,Te),F(`SS`,Ne,Ee),F(`SSS`,Ne,De);var ga,_a;for(ga=`SSSS`;ga.length<=9;ga+=`S`)F(ga,Ie);function va(e,t){t[st]=Ye((`0.`+e)*1e3)}for(ga=`S`;ga.length<=9;ga+=`S`)Ze(ga,va);_a=pt(`Milliseconds`,!1),P(`z`,0,0,`zoneAbbr`),P(`zz`,0,0,`zoneName`);function ya(){return this._isUTC?`UTC`:``}function ba(){return this._isUTC?`Coordinated Universal Time`:``}var V=S.prototype;V.add=qr,V.calendar=ti,V.clone=ni,V.diff=li,V.endOf=Ai,V.format=mi,V.from=hi,V.fromNow=gi,V.to=_i,V.toNow=vi,V.get=gt,V.invalidAt=zi,V.isAfter=ri,V.isBefore=ii,V.isBetween=ai,V.isSame=oi,V.isSameOrAfter=si,V.isSameOrBefore=ci,V.isValid=Li,V.lang=bi,V.locale=yi,V.localeData=xi,V.max=dr,V.min=ur,V.parsingFlags=Ri,V.set=_t,V.startOf=ki,V.subtract=Jr,V.toArray=Pi,V.toObject=Fi,V.toDate=Ni,V.toISOString=fi,V.inspect=pi,typeof Symbol<`u`&&Symbol.for!=null&&(V[Symbol.for(`nodejs.util.inspect.custom`)]=function(){return`Moment<`+this.format()+`>`}),V.toJSON=Ii,V.toString=di,V.unix=Mi,V.valueOf=ji,V.creationData=Bi,V.eraName=Wi,V.eraNarrow=Gi,V.eraAbbr=Ki,V.eraYear=qi,V.year=dt,V.isLeapYear=ft,V.weekYear=ra,V.isoWeekYear=ia,V.quarter=V.quarters=da,V.month=At,V.daysInMonth=jt,V.week=V.weeks=Ut,V.isoWeek=V.isoWeeks=Wt,V.weeksInYear=sa,V.weeksInWeekYear=ca,V.isoWeeksInYear=aa,V.isoWeeksInISOWeekYear=oa,V.date=fa,V.day=V.days=on,V.weekday=sn,V.isoWeekday=cn,V.dayOfYear=pa,V.hour=V.hours=vn,V.minute=V.minutes=ma,V.second=V.seconds=ha,V.millisecond=V.milliseconds=_a,V.utcOffset=Or,V.utc=Ar,V.local=jr,V.parseZone=Mr,V.hasAlignedHourOffset=Nr,V.isDST=Pr,V.isLocal=Ir,V.isUtcOffset=Lr,V.isUtc=Rr,V.isUTC=Rr,V.zoneAbbr=ya,V.zoneName=ba,V.dates=T(`dates accessor is deprecated. Use date instead.`,fa),V.months=T(`months accessor is deprecated. Use month instead`,At),V.years=T(`years accessor is deprecated. Use year instead`,dt),V.zone=T(`moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/`,kr),V.isDSTShifted=T(`isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information`,Fr);function xa(e){return lr(e*1e3)}function Sa(){return lr.apply(null,arguments).parseZone()}function Ca(e){return e}var wa=j.prototype;wa.calendar=te,wa.longDateFormat=de,wa.invalidDate=pe,wa.ordinal=ge,wa.preparse=Ca,wa.postformat=Ca,wa.relativeTime=ve,wa.pastFuture=ye,wa.set=k,wa.eras=Vi,wa.erasParse=Hi,wa.erasConvertYear=Ui,wa.erasAbbrRegex=Yi,wa.erasNameRegex=Ji,wa.erasNarrowRegex=Xi,wa.months=I,wa.monthsShort=Et,wa.monthsParse=Ot,wa.monthsRegex=Nt,wa.monthsShortRegex=Mt,wa.week=Bt,wa.firstDayOfYear=Ht,wa.firstDayOfWeek=Vt,wa.weekdays=en,wa.weekdaysMin=nn,wa.weekdaysShort=tn,wa.weekdaysParse=an,wa.weekdaysRegex=ln,wa.weekdaysShortRegex=un,wa.weekdaysMinRegex=dn,wa.isPM=gn,wa.meridiem=yn;function Ta(e,t,n,r){var i=Mn(),a=p().set(r,t);return i[n](a,e)}function Ea(e,t,n){if(l(e)&&(t=e,e=void 0),e=e||``,t!=null)return Ta(e,t,n,`month`);var r,i=[];for(r=0;r<12;r++)i[r]=Ta(e,r,n,`month`);return i}function Da(e,t,n,r){typeof e==`boolean`?(l(t)&&(n=t,t=void 0),t=t||``):(t=e,n=t,e=!1,l(t)&&(n=t,t=void 0),t=t||``);var i=Mn(),a=e?i._week.dow:0,o,s=[];if(n!=null)return Ta(t,(n+a)%7,r,`day`);for(o=0;o<7;o++)s[o]=Ta(t,(o+a)%7,r,`day`);return s}function Oa(e,t){return Ea(e,t,`months`)}function ka(e,t){return Ea(e,t,`monthsShort`)}function Aa(e,t,n){return Da(e,t,n,`weekdays`)}function ja(e,t,n){return Da(e,t,n,`weekdaysShort`)}function Ma(e,t,n){return Da(e,t,n,`weekdaysMin`)}kn(`en`,{eras:[{since:`0001-01-01`,until:1/0,offset:1,name:`Anno Domini`,narrow:`AD`,abbr:`AD`},{since:`0000-12-31`,until:-1/0,offset:1,name:`Before Christ`,narrow:`BC`,abbr:`BC`}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var t=e%10;return e+(Ye(e%100/10)===1?`th`:t===1?`st`:t===2?`nd`:t===3?`rd`:`th`)}}),n.lang=T(`moment.lang is deprecated. Use moment.locale instead.`,kn),n.langData=T(`moment.langData is deprecated. Use moment.localeData instead.`,Mn);var Na=Math.abs;function Pa(){var e=this._data;return this._milliseconds=Na(this._milliseconds),this._days=Na(this._days),this._months=Na(this._months),e.milliseconds=Na(e.milliseconds),e.seconds=Na(e.seconds),e.minutes=Na(e.minutes),e.hours=Na(e.hours),e.months=Na(e.months),e.years=Na(e.years),this}function Fa(e,t,n,r){var i=Vr(t,n);return e._milliseconds+=r*i._milliseconds,e._days+=r*i._days,e._months+=r*i._months,e._bubble()}function Ia(e,t){return Fa(this,e,t,1)}function La(e,t){return Fa(this,e,t,-1)}function Ra(e){return e<0?Math.floor(e):Math.ceil(e)}function za(){var e=this._milliseconds,t=this._days,n=this._months,r=this._data,i,a,o,s,c;return e>=0&&t>=0&&n>=0||e<=0&&t<=0&&n<=0||(e+=Ra(Va(n)+t)*864e5,t=0,n=0),r.milliseconds=e%1e3,i=Je(e/1e3),r.seconds=i%60,a=Je(i/60),r.minutes=a%60,o=Je(a/60),r.hours=o%24,t+=Je(o/24),c=Je(Ba(t)),n+=c,t-=Ra(Va(c)),s=Je(n/12),n%=12,r.days=t,r.months=n,r.years=s,this}function Ba(e){return e*4800/146097}function Va(e){return e*146097/4800}function Ha(e){if(!this.isValid())return NaN;var t,n,r=this._milliseconds;if(e=xe(e),e===`month`||e===`quarter`||e===`year`)switch(t=this._days+r/864e5,n=this._months+Ba(t),e){case`month`:return n;case`quarter`:return n/3;case`year`:return n/12}else switch(t=this._days+Math.round(Va(this._months)),e){case`week`:return t/7+r/6048e5;case`day`:return t+r/864e5;case`hour`:return t*24+r/36e5;case`minute`:return t*1440+r/6e4;case`second`:return t*86400+r/1e3;case`millisecond`:return Math.floor(t*864e5)+r;default:throw Error(`Unknown unit `+e)}}function Ua(e){return function(){return this.as(e)}}var Wa=Ua(`ms`),Ga=Ua(`s`),Ka=Ua(`m`),qa=Ua(`h`),Ja=Ua(`d`),Ya=Ua(`w`),Xa=Ua(`M`),Za=Ua(`Q`),Qa=Ua(`y`),$a=Wa;function eo(){return Vr(this)}function to(e){return e=xe(e),this.isValid()?this[e+`s`]():NaN}function no(e){return function(){return this.isValid()?this._data[e]:NaN}}var ro=no(`milliseconds`),io=no(`seconds`),ao=no(`minutes`),oo=no(`hours`),so=no(`days`),co=no(`months`),lo=no(`years`);function uo(){return Je(this.days()/7)}var fo=Math.round,po={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function mo(e,t,n,r,i){return i.relativeTime(t||1,!!n,e,r)}function ho(e,t,n,r){var i=Vr(e).abs(),a=fo(i.as(`s`)),o=fo(i.as(`m`)),s=fo(i.as(`h`)),c=fo(i.as(`d`)),l=fo(i.as(`M`)),u=fo(i.as(`w`)),d=fo(i.as(`y`)),f=a<=n.ss&&[`s`,a]||a<n.s&&[`ss`,a]||o<=1&&[`m`]||o<n.m&&[`mm`,o]||s<=1&&[`h`]||s<n.h&&[`hh`,s]||c<=1&&[`d`]||c<n.d&&[`dd`,c];return n.w!=null&&(f=f||u<=1&&[`w`]||u<n.w&&[`ww`,u]),f=f||l<=1&&[`M`]||l<n.M&&[`MM`,l]||d<=1&&[`y`]||[`yy`,d],f[2]=t,f[3]=+e>0,f[4]=r,mo.apply(null,f)}function go(e){return e===void 0?fo:typeof e==`function`?(fo=e,!0):!1}function _o(e,t){return po[e]===void 0?!1:t===void 0?po[e]:(po[e]=t,e===`s`&&(po.ss=t-1),!0)}function vo(e,t){if(!this.isValid())return this.localeData().invalidDate();var n=!1,r=po,i,a;return typeof e==`object`&&(t=e,e=!1),typeof e==`boolean`&&(n=e),typeof t==`object`&&(r=Object.assign({},po,t),t.s!=null&&t.ss==null&&(r.ss=t.s-1)),i=this.localeData(),a=ho(this,!n,r,i),n&&(a=i.pastFuture(+this,a)),i.postformat(a)}var yo=Math.abs;function bo(e){return(e>0)-(e<0)||+e}function xo(){if(!this.isValid())return this.localeData().invalidDate();var e=yo(this._milliseconds)/1e3,t=yo(this._days),n=yo(this._months),r,i,a,o,s=this.asSeconds(),c,l,u,d;return s?(r=Je(e/60),i=Je(r/60),e%=60,r%=60,a=Je(n/12),n%=12,o=e?e.toFixed(3).replace(/\.?0+$/,``):``,c=s<0?`-`:``,l=bo(this._months)===bo(s)?``:`-`,u=bo(this._days)===bo(s)?``:`-`,d=bo(this._milliseconds)===bo(s)?``:`-`,c+`P`+(a?l+a+`Y`:``)+(n?l+n+`M`:``)+(t?u+t+`D`:``)+(i||r||e?`T`:``)+(i?d+i+`H`:``)+(r?d+r+`M`:``)+(e?d+o+`S`:``)):`P0D`}var So=B.prototype;return So.isValid=vr,So.abs=Pa,So.add=Ia,So.subtract=La,So.as=Ha,So.asMilliseconds=Wa,So.asSeconds=Ga,So.asMinutes=Ka,So.asHours=qa,So.asDays=Ja,So.asWeeks=Ya,So.asMonths=Xa,So.asQuarters=Za,So.asYears=Qa,So.valueOf=$a,So._bubble=za,So.clone=eo,So.get=to,So.milliseconds=ro,So.seconds=io,So.minutes=ao,So.hours=oo,So.days=so,So.weeks=uo,So.months=co,So.years=lo,So.humanize=vo,So.toISOString=xo,So.toString=xo,So.toJSON=xo,So.locale=yi,So.localeData=xi,So.toIsoString=T(`toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)`,xo),So.lang=bi,P(`X`,0,0,`unix`),P(`x`,0,0,`valueOf`),F(`x`,Le),F(`X`,Be),Ze(`X`,function(e,t,n){n._d=new Date(parseFloat(e)*1e3)}),Ze(`x`,function(e,t,n){n._d=new Date(Ye(e))}),n.version=`2.30.1`,r(lr),n.fn=V,n.min=pr,n.max=mr,n.now=hr,n.utc=p,n.unix=xa,n.months=Oa,n.isDate=u,n.locale=kn,n.invalid=v,n.duration=Vr,n.isMoment=C,n.weekdays=Aa,n.parseZone=Sa,n.localeData=Mn,n.isDuration=br,n.monthsShort=ka,n.weekdaysMin=Ma,n.defineLocale=An,n.updateLocale=jn,n.locales=Nn,n.weekdaysShort=ja,n.normalizeUnits=xe,n.relativeTimeRounding=go,n.relativeTimeThreshold=_o,n.calendarFormat=ei,n.prototype=V,n.HTML5_FMT={DATETIME_LOCAL:`YYYY-MM-DDTHH:mm`,DATETIME_LOCAL_SECONDS:`YYYY-MM-DDTHH:mm:ss`,DATETIME_LOCAL_MS:`YYYY-MM-DDTHH:mm:ss.SSS`,DATE:`YYYY-MM-DD`,TIME:`HH:mm`,TIME_SECONDS:`HH:mm:ss`,TIME_MS:`HH:mm:ss.SSS`,WEEK:`GGGG-[W]WW`,MONTH:`YYYY-MM`},n}))}))(),1);function LP({issue:e,equipment:t,issueAttachments:n,reloadQueryFn:r,expanded:i=!0}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(i),f=e=>{r([`issue`,`attachment`,`status_mail`]),r([`issue`,`status_mail`])},m=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(`div`,{className:`p-3 mb-4 border-bottom`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-2`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(yr,{bg:`dark`,children:`Issue`}),(0,p.jsx)(`h4`,{className:e.date_closed?`text-danger mb-0`:`mb-0`,children:e.date_closed?(0,p.jsx)(`s`,{children:e.issue}):e.issue})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(B,{variant:`outline-primary`,size:`sm`,onClick:()=>u(e=>!e),"aria-label":`Toggle Details`,children:l?`Hide Details`:`Show Details`}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{o((0,p.jsx)(FP,{equipment:t,showModal:!0,onClose:e=>{c(!1),e&&f(e)},issue:e,attachments:m()})),c(!0)},"aria-label":`Edit Issue`,children:`Edit`})]})]}),l&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`mb-2`,children:(0,p.jsx)(kP,{children:e.description})}),(0,p.jsx)(`p`,{className:`mb-3`,children:e.actions}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-4 text-muted`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Creator`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.owner.full_name})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Created`}),(0,p.jsx)(`div`,{className:`text-body`,children:(0,IP.default)(e.date_created).format(`DD MMMM YYYY`)})]}),e.date_closed&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Closed`}),(0,p.jsx)(`div`,{className:`text-body`,children:(0,IP.default)(e.date_closed).format(`DD MMMM YYYY`)})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Forecast Up`}),(0,p.jsx)(`div`,{className:`text-body`,children:(0,IP.default)(e.forecast_up).format(`DD MMMM YYYY`)})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Issue Type`}),(0,p.jsxs)(`div`,{className:`text-body`,children:[e.issue_type===it.DEFAULT&&`Issue`,e.issue_type===it.ESCALATION&&`Escalation`,e.issue_type===it.PRIORITY&&`Priority`]})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Attachments`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.attachments})]}),e.updated_by&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update By`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.updated_by.full_name})]}),e.last_update&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update`}),(0,p.jsx)(`div`,{className:`text-body`,children:(0,IP.default)(e.last_update).format(`DD MMMM YYYY`)})]})]})]}),s&&a]})}function RP({reservations:e}){if(!e||e.length<1)return(0,p.jsx)(p.Fragment,{});let t=e[0];return(0,p.jsx)(pl,{placement:`top`,overlay:(0,p.jsxs)(sl,{id:`tooltip-${t.id}`,children:[(0,p.jsx)(`h5`,{children:t.title}),(0,p.jsx)(`p`,{children:e[0].active?`Currently active`:`Upcoming in: ${q(e[0].start).format(`DD MMMM YYYY`)}`}),(0,p.jsx)(`p`,{children:e[1]?`Next upcoming reservation in: ${q(e[1].start).format(`DD MMMM YYYY`)}`:`No next upcoming reservations`})]}),children:(0,p.jsxs)(yr,{bg:e[0].active?`info`:`dark`,children:[`Reserved by: `,e[0].user.full_name]})})}function zP({equipment:e,modules:t,issues:n,issueAttachments:r,ecnNotes:i,ecnAttachments:a,reloadQueryFn:o,showIssues:s,reservations:c}){let[l,u]=(0,d.useState)(null),[f,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)([]),[x,S]=(0,d.useState)(void 0),[C,w]=(0,d.useState)([]),[T,E]=(0,d.useState)([]),D=e=>{o([`ecn`,`attachment`,`status_mail`]),w([...C,e])},O=e=>{o([`issue`,`status_mail`]),o([`issue`,`attachment`,`status_mail`]),E([...T,e])};(0,d.useEffect)(()=>{w(i),E(n),b(t.filter(t=>t.equipment.id===e.id&&!t.type.is_main_tool)),S(t.findLast(t=>t.equipment.id===e.id&&t.type.is_main_tool))},[i,n,e,t]);let k=e=>C.filter(t=>t.module_id===e),A=e=>T.filter(t=>t.module_id===e);return(0,p.jsxs)(`div`,{className:`card mb-4`,children:[(0,p.jsxs)(`div`,{className:`card-header d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsxs)(`h4`,{className:`mb-0`,children:[e.number,` - `,e.name]}),x&&(0,p.jsx)(Dd,{module:x}),x&&(0,p.jsx)(RP,{reservations:c.filter(e=>e.modules.some(e=>e.id===x.id))})]}),(0,p.jsxs)(ls,{as:br,title:`Action`,id:`bg-nested-dropdown`,children:[(0,p.jsx)(ss.Item,{eventKey:`1`,onClick:()=>{g((0,p.jsx)(Gb,{equipment:e,showModal:!0,onClose:e=>{v(!1),e&&D(e)}})),v(!0)},children:`New ECN`}),s!==1&&(0,p.jsx)(ss.Item,{eventKey:`1`,onClick:()=>{u((0,p.jsx)(FP,{equipment:e,showModal:!0,onClose:e=>{m(!1),e&&O(e)}})),m(!0)},children:`New Issue`})]})]}),(0,p.jsx)(`div`,{className:`card-body`,children:(0,p.jsxs)(Dl,{children:[x&&(0,p.jsx)(Ur,{xs:12,md:y.length>0?6:12,children:(0,p.jsx)(Pr,{className:`mb-3`,children:(0,p.jsxs)(Pr.Body,{children:[(0,p.jsxs)(Pr.Title,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{children:`Main module`}),(0,p.jsx)(`div`,{className:`ms-2`})]}),(0,p.jsxs)(`div`,{className:`mt-3`,children:[k(x.id).map((t,n)=>(0,p.jsx)(PP,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},n)),s!==1&&A(x.id).map((t,n)=>(0,p.jsx)(LP,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},n))]})]})})}),y.length>0&&(0,p.jsx)(Ur,{xs:12,md:x?6:12,children:y.map((t,n)=>(0,p.jsx)(Pr,{className:`mb-3`,children:(0,p.jsxs)(Pr.Body,{children:[(0,p.jsx)(Pr.Title,{className:`d-flex align-items-center`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(`span`,{children:t.name}),(0,p.jsx)(Dd,{module:t}),(0,p.jsx)(RP,{reservations:c.filter(e=>e.modules.some(e=>e.id===t.id))})]})}),(0,p.jsxs)(`div`,{className:`mt-3`,children:[k(t.id).map((t,n)=>(0,p.jsx)(PP,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},n)),s!==1&&A(t.id).map((t,n)=>(0,p.jsx)(LP,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},n))]})]})},n))})]})}),_&&h,f&&l]})}var BP=({showModal:e,onClose:t,message:n})=>{let{register:r,handleSubmit:i,setValue:a,reset:o,control:s}=Ed({defaultValues:{title:n?.title,description:n?.description,rooms:n?.rooms,type:n?.type,owner:n?.owner}}),[c,l]=(0,d.useState)([]),[u,m]=(0,d.useState)([]),[h,g]=(0,d.useState)(``),_=()=>document.documentElement.getAttribute(`data-bs-theme`)===`dark`,v={control:e=>({...e,backgroundColor:_()?`#212529`:e.backgroundColor,borderColor:_()?`#495057`:e.borderColor,color:_()?`#fff`:e.color}),menu:e=>({...e,backgroundColor:_()?`#212529`:e.backgroundColor}),option:(e,t)=>({...e,backgroundColor:_()?t.isSelected?`#0d6efd`:t.isFocused?`#343a40`:`#212529`:e.backgroundColor,color:_()?`#fff`:e.color}),singleValue:e=>({...e,color:_()?`#fff`:e.color}),multiValue:e=>({...e,backgroundColor:_()?`#343a40`:e.backgroundColor}),multiValueLabel:e=>({...e,color:_()?`#fff`:e.color}),input:e=>({...e,color:_()?`#fff`:e.color})},{statusMail:y}=(0,d.useContext)(iy);(0,d.useEffect)(()=>{f.default.get(`/list/room`).then(e=>{l((e.data._embedded.items||[]).map(e=>({value:e,label:e.name})))}).catch(e=>{console.error(`Error fetching rooms:`,e),g(`Error fetching rooms:`+e)}),f.default.get(`/list/location/message/type`).then(e=>{let t=y.filter.messageType,r=(e.data._embedded.items||[]).filter(e=>t.includes(e.id.toString())).map(e=>({value:e,label:e.type}));m(r),a(`type`,n?.type||r[0].value)}).catch(e=>{console.error(`Error fetching message types:`,e),g(`Error fetching message types:`+e)})},[]);let b=e=>e.title?e?.owner.value===void 0&&n?.owner===void 0?`owner`:e.rooms===void 0||e.rooms.map(e=>e.id).length<=0?`room`:e.type?``:`type`:`title`;return(0,p.jsx)(U,{show:e,size:`lg`,centered:!0,onHide:()=>t(n),children:(0,p.jsxs)(H,{onSubmit:i(async e=>{let r=b(e);if(r!==``){g(`Please fill: `+r);return}try{let r={title:e.title,description:e.description,owner:e?.owner.value||n?.owner.id,type:e.type.id,rooms:e.rooms.map(e=>e.id)},i;if(i=n?await f.default.patch(`/update/location/message/${n.id}`,r):await f.default.post(`/create/location/message`,r),i){t(i?.data),o();return}console.error(`No response received`),g(`No response received`)}catch(e){console.error(`Error submitting the form:`,e),g(`Error submitting the form:`+e)}}),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Edit status mail message`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Title`}),(0,p.jsx)(H.Control,{type:`text`,placeholder:`Enter the title`,...r(`title`)})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Message`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:3,placeholder:`Give the message`,...r(`description`)})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Wb,{control:s,...r(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Rooms`}),(0,p.jsx)(vu,{name:`rooms`,control:s,render:({field:e})=>(0,p.jsx)(cv,{isMulti:!0,options:c,classNamePrefix:`react-select`,placeholder:`Select one or more rooms`,value:c.filter(t=>e.value?.some(e=>e.id===t.value.id)),onChange:t=>e.onChange(t.map(e=>e.value)),styles:v})})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Type`}),(0,p.jsx)(vu,{name:`type`,control:s,render:({field:e})=>(0,p.jsx)(cv,{options:u,classNamePrefix:`react-select`,placeholder:`Select a message type`,value:u.find(t=>t.value.id===e.value?.id)||null,onChange:t=>e.onChange(t?.value),styles:v})})]})]}),(0,p.jsxs)(U.Footer,{children:[h!=``&&(0,p.jsx)(`span`,{className:`text-danger`,children:h}),(0,p.jsx)(B,{variant:`secondary`,onClick:()=>t(n),children:`Cancel`}),(0,p.jsx)(B,{variant:`primary`,type:`submit`,children:n?`Update Message`:`Create Message`})]})]})})};function VP({message:e}){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(e),s=e=>{o({...a,...e})};return(0,p.jsxs)(`div`,{className:`card mb-4`,children:[(0,p.jsxs)(`div`,{className:`card-header d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(yr,{bg:`dark`,children:a.type.type}),(0,p.jsx)(`h5`,{className:`mb-0`,children:a.title})]}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{n((0,p.jsx)(BP,{showModal:!0,onClose:e=>{i(!1),e&&s(e)},message:a})),i(!0)},children:`Edit`})]}),(0,p.jsx)(`div`,{className:`card-body`,children:(0,p.jsx)(kP,{children:a.description})}),(0,p.jsx)(`div`,{className:`card-footer bg-transparent`,children:(0,p.jsxs)(`small`,{className:`text-muted d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`span`,{children:[`Created: `,q(a.date_created).format(`DD MMM YYYY`)]}),a.last_update&&(0,p.jsxs)(`span`,{children:[`Updated: `,q(a.last_update).format(`DD MMM YYYY`)]}),a.rooms.length>0&&(0,p.jsxs)(`span`,{children:[`Rooms:`,` `,a.rooms.map((e,t)=>(0,p.jsxs)(d.default.Fragment,{children:[t>0&&`, `,e.name]},e.id))]}),(0,p.jsxs)(`span`,{children:[`Owner: `,a.owner.full_name]})]})}),r&&t]})}function HP({messageList:e,refetchFn:t}){let[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex gap-3`,children:[(0,p.jsx)(`h2`,{children:`Messages`}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`secondary`,onClick:()=>{r((0,p.jsx)(BP,{showModal:!0,onClose:e=>{a(!1),t()}})),a(!0)},children:`New message`})})]}),e.map((e,t)=>(0,p.jsx)(`div`,{children:(0,p.jsx)(VP,{message:e})},e.id)),i&&n]})}function UP({issue:e,moduleName:t,issueAttachments:n,equipment:r,reloadQueryFn:i}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),l=e=>{i([`issue`,`status_mail`]),i([`issue`,`attachment`,`status_mail`])},u=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{className:`align-middle`,children:[(0,p.jsx)(`td`,{className:`text-nowrap`,children:t??`-`}),(0,p.jsx)(`td`,{children:e.issue}),(0,p.jsx)(`td`,{children:(0,p.jsx)(kP,{children:e.description})}),(0,p.jsx)(`td`,{className:`text-nowrap`,children:q(e.forecast_up).format(`DD MMMM YYYY`)}),(0,p.jsx)(`td`,{className:`text-nowrap`,children:e.owner.full_name}),(0,p.jsx)(`td`,{className:`text-center`,children:(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-outline-light`,onClick:()=>{if(!r){console.error(`equipment is null in the table`);return}c(!0),o((0,p.jsx)(FP,{equipment:r,showModal:!0,onClose:e=>{c(!1),e&&l(e)},issue:e,attachments:u()}))},children:`Edit`})})]},e.id),s&&a]})}function WP({issues:e,modules:t,issueAttachments:n,reloadQueryFn:r}){return(0,p.jsx)(`div`,{className:`table-responsive`,children:(0,p.jsxs)(`table`,{className:`table table-hover table-striped table-bordered table-sm`,children:[(0,p.jsx)(`thead`,{className:`bg-primary text-white`,children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{scope:`col`,children:`Module`}),(0,p.jsx)(`th`,{scope:`col`,children:`Issue`}),(0,p.jsx)(`th`,{scope:`col`,children:`Description`}),(0,p.jsx)(`th`,{scope:`col`,children:`Forecast Up`}),(0,p.jsx)(`th`,{scope:`col`,children:`Owner`}),(0,p.jsx)(`th`,{scope:`col`,className:`text-center`,children:`Actions`})]})}),(0,p.jsx)(`tbody`,{children:e.map(e=>(0,p.jsx)(UP,{issue:e,moduleName:t.find(t=>t.id===e.module_id)?.name,issueAttachments:n,equipment:t.find(t=>t.id===e.module_id)?.equipment,reloadQueryFn:r},e.id))})]})})}function GP({statusMail:e}){let[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(!1);return(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:async()=>{try{if(n(!0),!e.id||e.id<=0)throw Error(`Status Mail ID is not correctly set`);let t={status_mail:e.id};await f.default.post(`/send/status-mail`,t),i(!0)}catch(e){console.error(`Error sending status mail:`,e),alert(`Error sending status mail. Please try again.`)}finally{n(!1)}},disabled:t,"aria-label":`Toggle Details`,children:t?`Sending...`:r?`Sending successful`:`Send Status Mail`})}function KP(){let{statusMail:e}=(0,d.useContext)(iy),[t,n]=(0,d.useState)([]),r=(0,m.useQueryClient)(),i=(0,m.useQueries)({queries:[{queryKey:[`equipment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ee({statusMail:e})},{queryKey:[`module`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>oe({statusMail:e})},{queryKey:[`ecn`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ie({statusMail:e})},{queryKey:[`issue`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>P({statusMail:e})},{queryKey:[`messages`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ce({statusMail:e})},{queryKey:[`ecn`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>N({statusMail:e})},{queryKey:[`issue`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>re({statusMail:e})},{queryKey:[`reservation`,`active`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>se({which:`active`})},{queryKey:[`reservation`,`upcoming`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>se({which:`upcoming`})}]}),a=t=>{let n=t;n.push(JSON.stringify(e.filter)),r.refetchQueries({queryKey:n})},[o,s,c,l,u,f,h,g,_]=i,v=i.some(e=>e.isLoading),y=i.some(e=>e.isError),b=i.every(e=>e.isSuccess);return(0,d.useEffect)(()=>{b&&n(o.data.items)},[b]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[`Status mail `,e.name]}),(0,p.jsx)(`div`,{children:(0,p.jsx)(GP,{statusMail:e})})]}),(0,p.jsx)(`p`,{children:e.subject}),v&&(0,p.jsx)(vr,{variant:`info`,children:`Loading status mail`}),y&&(0,p.jsx)(vr,{variant:`danger`,children:`Error loading status mail`}),b&&e.show_issues_with_priority&&(()=>{let e=l.data.items.filter(e=>e.issue_type===2);return e.length===0?(0,p.jsx)(p.Fragment,{}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{children:`Issues with priority`}),(0,p.jsx)(WP,{issues:e,modules:s.data.items,issueAttachments:h.data.items,reloadQueryFn:a})]})})(),b&&u.data&&(0,p.jsx)(HP,{messageList:u.data.items,refetchFn:u.refetch}),b&&(()=>{if(!t.length)return(0,p.jsx)(`p`,{children:`No equipment available.`});t.sort((t,n)=>e.classification===ct.ROOM?t.room.name.localeCompare(n.room.name):t.area&&n.area&&e.classification===ct.AREA?t.area.title.localeCompare(n.area.title):t.area&&n.area&&e.classification===ct.AREA_PER_FACILITY?t.area.facility.title.localeCompare(n.area.facility.title)||t.area.title.localeCompare(n.area.title):0);let n,r=null,i=``;return t.map((t,o)=>{let u=[];return e.classification===ct.ROOM?t.room.name!==i&&(u.push((0,p.jsxs)(`h2`,{children:[`Room: `,t.room.name]},`room-${t.room.name}`)),i=t.room.name):e.classification===ct.AREA?t.area&&t.area!==r&&(u.push((0,p.jsxs)(`h2`,{children:[`Area: `,t.area.title]},`area-${t.area.id}`)),r=t.area):e.classification===ct.AREA_PER_FACILITY&&(t.area&&t.area.facility!==n&&(u.push((0,p.jsxs)(`h2`,{children:[`Facility: `,t.area.facility.title]},`facility-${t.area.facility.id}`)),n=t.area.facility),t.area&&t.area!==r&&(u.push((0,p.jsxs)(`h4`,{children:[`Area: `,t.area.title]},`area-${t.area.id}`)),r=t.area)),u.push((0,p.jsx)(zP,{equipment:t,modules:s.data.items,issues:l.data.items,issueAttachments:h.data.items,ecnNotes:c.data.items,ecnAttachments:f.data.items,reloadQueryFn:a,showIssues:e.show_issues,reservations:e.show_reservations?g.data.items.concat(_.data.items):[]},o)),u})})()]})}function qP(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;let t=new Date(e);return isNaN(t.getTime())?null:t}function JP(e,t){let n=qP(e);if(!n)return``;let r=e=>e.toString().padStart(2,`0`),i={YYYY:n.getFullYear().toString(),YY:n.getFullYear().toString().slice(-2),MM:r(n.getMonth()+1),DD:r(n.getDate()),HH:r(n.getHours()),mm:r(n.getMinutes()),H:n.getHours().toString(),m:n.getMinutes().toString()},a=t;return Object.keys(i).sort((e,t)=>t.length-e.length).forEach(e=>{a=a.replace(new RegExp(e,`g`),i[e])}),a}function YP(e,t=`DD-MM-YY HH:mm`){return JP(e,t)}function XP({monitor:e}){let{environment:t}=(0,g.useParams)(),[n]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,e],queryFn:()=>me({monitorId:e.id})}]});return n.isLoading?(0,p.jsx)(`div`,{children:`Loading requirements...`}):n.data?.items.map((n,r)=>{let i=`bg-secondary-subtle`;if(n.latest_result)for(let e=0;e<n.latest_result.values.length;e++){if(n.latest_result.values[e].value_is_valid===!1){i=`bg-danger-subtle`;break}if(n.latest_result.values[e].value_is_valid===!0){i=`bg-success-subtle`;break}}return(0,p.jsx)(Pr,{className:`mb-2 me-2`,children:(0,p.jsxs)(Pr.Body,{className:i,children:[(0,p.jsx)(Pr.Title,{children:(0,p.jsx)(g.Link,{to:`/${t}/operator/monitor/`+e.id,children:e.name})}),(0,p.jsxs)(Pr.Text,{children:[n.title,n.latest_result&&(0,p.jsxs)(p.Fragment,{children:[`Latest measurement: `,YP(n.latest_result.date_created,`DD-MM-YY HH:mm`)]})]})]})},r)})}var ZP=({moduleId:e,size:t})=>{let[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(``);function c(){f.default.create().post(`create/equipment/module/changelog`,{module:e,changelog:o}).finally(()=>{r(!1),a(!0),s(``)})}let l=e=>{s(e.target.value)};function u(){return(0,p.jsx)(Rl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Il,{onClose:()=>a(!1),show:i,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Il.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Assist logged`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Il.Body,{children:`Assist was logged successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,size:t,onClick:()=>r(!0),children:`Log assist`}),(0,p.jsxs)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Log assist`})}),(0,p.jsx)(U.Body,{children:(0,p.jsx)(H,{children:(0,p.jsxs)(H.Group,{className:`mb-3`,controlId:`modal.ControlTextarea1`,children:[(0,p.jsx)(H.Label,{children:`Describe the assist`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:3,value:o,onChange:e=>l(e)})]})})}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:()=>c(),children:`Log assist`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{r(!1)},children:`Close`})]})]}),(0,p.jsx)(u,{})]})},QP=(0,d.createContext)({equipment:{},reloadEquipment:()=>{}});function $P({issue:e,equipment:t,issueAttachments:n,reloadQueryFn:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(e),u=e=>{r([`issue`,t.name]),r([`issue`,`attachment`,t.name]),l({...c,...e})},f=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(Pr,{className:`my-2`,children:[(0,p.jsxs)(Pr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(Pr.Title,{children:[(0,p.jsx)(yr,{bg:`dark`,children:`Issue`}),` `,c.issue]}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{a((0,p.jsx)(FP,{equipment:t,showModal:!0,onClose:e=>{s(!1),e&&u(e)},issue:c,attachments:f()})),s(!0)},children:`Edit`})]}),(0,p.jsx)(Pr.Text,{children:(0,p.jsx)(kP,{children:c.description})})]}),(0,p.jsxs)(Zs,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Created:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:YP(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Owner:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.owner.full_name})]}),c.updated_by&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Updated:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.updated_by.full_name}),(0,p.jsxs)(`span`,{className:`ms-1`,children:[`(`,YP(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},c.module_id),o&&i]})}function eF({ecn:e,equipment:t,ecnAttachments:n,reloadQueryFn:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(e),u=e=>{r([`ecn`,t.name]),r([`ecn`,`attachment`,t.name]),l({...c,...e})},f=()=>n.filter(t=>t.ecn.id===e.id);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(Pr,{className:`my-2`,children:[(0,p.jsxs)(Pr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(Pr.Title,{children:[(0,p.jsx)(yr,{bg:`dark`,children:`ECN`}),` `,e.ecn]}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{a((0,p.jsx)(Gb,{equipment:t,showModal:!0,onClose:e=>{s(!1),e&&u(e)},ecn:c,attachments:f()})),s(!0)},children:`Edit`})]}),(0,p.jsx)(Pr.Text,{children:(0,p.jsx)(kP,{children:e.description})})]}),(0,p.jsxs)(Zs,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Created:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:YP(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Owner:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.owner.full_name})]}),c.updated_by&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Updated:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.updated_by.full_name}),(0,p.jsxs)(`span`,{className:`ms-1`,children:[`(`,YP(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},e.module_id),o&&i]})}function tF(){let{id:e}=(0,g.useParams)(),[t,n]=(0,d.useState)([]),r=(0,m.useQueries)({queries:[{queryKey:[`service`,`equipment`,e],queryFn:()=>Ve({equipmentId:Number(e)})}]}),[i]=r,a=r.some(e=>e.isLoading),o=r.some(e=>e.isError),s=r.every(e=>e.isSuccess);if((0,d.useEffect)(()=>{s&&n(i.data.items)},[s,i.data]),a)return(0,p.jsx)(`div`,{children:`Loading...`});if(o)return(0,p.jsx)(`div`,{children:`Error loading services.`});let c=e=>{if(e<60)return`${e} min`;let t=Math.floor(e/60),n=e%60;return`${t}h ${n>0?`${n}min`:``}`.trim()};return i.data.items.length===0?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsx)(vr,{variant:`info`,children:`No services found`})]}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsxs)(kl,{striped:!0,bordered:!0,hover:!0,responsive:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Id`}),(0,p.jsx)(`th`,{children:`Name`}),(0,p.jsx)(`th`,{children:`Type`}),(0,p.jsx)(`th`,{children:`Team`}),(0,p.jsx)(`th`,{children:`Department`}),(0,p.jsx)(`th`,{children:`Duration`}),(0,p.jsx)(`th`,{children:`Report2`})]})}),(0,p.jsx)(`tbody`,{children:t.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.id}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${window.location.pathname.split(`/`)[1]}/service/details/${e.id}/general.html`,children:e.name})}),(0,p.jsx)(`td`,{children:e.type?.name||`N/A`}),(0,p.jsx)(`td`,{children:e.team?.name||`N/A`}),(0,p.jsx)(`td`,{children:e.department?.name||`N/A`}),(0,p.jsx)(`td`,{children:c(e.minutes_needed_for_service)}),(0,p.jsx)(`td`,{children:e.latest_event_report_id&&(0,p.jsx)(`a`,{className:`btn btn-primary btn-sm`,href:`/${window.location.pathname.split(`/`)[1]}/service/event/report/${e.latest_event_report_id}/results`,children:`View Report`})})]},e.id))})]})]})}function nF(){let{environment:e}=(0,g.useParams)(),{equipment:t}=(0,d.useContext)(QP),n=(0,m.useQueryClient)(),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(!1),[f,h,_,v,y,b,x]=(0,m.useQueries)({queries:[{queryKey:[`runs`,t.name,e],queryFn:()=>De({firstUnfinishedStepEquipment:t,environment:e})},{queryKey:[`monitors`,t.name],queryFn:()=>he({equipment:t})},{queryKey:[`ecn`,t.name],queryFn:()=>ie({equipment:t})},{queryKey:[`issue`,t.name],queryFn:()=>P({equipment:t})},{queryKey:[`module`,t.name],queryFn:()=>oe({equipment:t})},{queryKey:[`ecn`,`attachment`,t.name],queryFn:()=>N({equipment:t})},{queryKey:[`issue`,`attachment`,t.name],queryFn:()=>re({equipment:t})}]}),S=e=>{n.invalidateQueries({queryKey:e})},C=e=>e?_.data?.items.filter(t=>t.module_id===e):[],w=e=>e?v.data?.items.filter(t=>t.module_id===e):[],T=()=>{c((0,p.jsx)(Gb,{equipment:t,showModal:!0,onClose:()=>{u(!1),setTimeout(()=>{S([`ecn`,t.name]),S([`ecn`,`attachment`,t.name])},100)}})),u(!0)},E=()=>{i((0,p.jsx)(FP,{equipment:t,showModal:!0,onClose:()=>{o(!1),setTimeout(()=>{S([`issue`,t.name]),S([`issue`,`attachment`,t.name])},100)}})),o(!0)};return(0,p.jsxs)(Wr,{fluid:!0,children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-left`,children:h.data?.items&&h.data.items.map((e,t)=>(0,p.jsx)(XP,{monitor:e},t))}),(0,p.jsxs)(Dl,{children:[(0,p.jsxs)(Ur,{md:8,children:[(0,p.jsx)(`h2`,{children:`Runs`}),f.isLoading&&(0,p.jsx)(`div`,{children:`Loading...`}),` `,f.isError&&(0,p.jsx)(`div`,{children:`Error...`}),f.isFetched&&f.data&&f.data?.items.length===0&&(0,p.jsx)(vr,{variant:`info`,children:`No runs found`}),f.isFetched&&f.data&&f.data?.items.length>0&&(0,p.jsxs)(kl,{striped:!0,bordered:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Run`}),(0,p.jsx)(`th`,{children:`Priority`}),(0,p.jsx)(`th`,{children:`Hold Code`}),(0,p.jsx)(`th`,{children:`Batch Card`}),(0,p.jsx)(`th`,{children:`Project`})]})}),(0,p.jsx)(`tbody`,{children:f.data?.items.map((t,n)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsxs)(`td`,{children:[t.first_unfinished_step&&(0,p.jsx)(g.Link,{to:`/${e}/operator/run/step/${t.first_unfinished_step.id}`,children:t.name}),t.first_unfinished_step===void 0&&t.last_finished_step&&(0,p.jsx)(g.Link,{to:`/${e}/operator/run/step/${t.last_finished_step.id}`,children:t.name})]}),(0,p.jsxs)(`td`,{children:[t.priority&&(0,p.jsx)(`span`,{className:`badge`,style:{backgroundColor:t.priority.priority.back_color,color:t.priority.priority.front_color},children:t.priority.priority.code}),!t.priority&&(0,p.jsx)(`span`,{className:`badge bg-info`,children:`NORMAL`})]}),(0,p.jsx)(`td`,{children:t.hold_code&&(0,p.jsx)(`span`,{className:`badge handle`,style:{backgroundColor:t.hold_code.hold_code.back_color,color:t.hold_code.hold_code.front_color},children:t.hold_code.hold_code.code})}),(0,p.jsx)(`td`,{children:t.batch_card&&t.batch_card.content&&(0,p.jsx)(`span`,{className:`text-danger`,children:t.batch_card.content})}),(0,p.jsx)(`td`,{children:t.project.name})]},n))})]}),(0,p.jsx)(tF,{})]}),(0,p.jsxs)(Ur,{md:4,children:[(0,p.jsx)(`h2`,{children:`Assistance`}),y.data?.items.map((e,n)=>(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`h3`,{children:e.type.is_main_tool?`Main tool`:e.name}),(0,p.jsx)(`div`,{children:(0,p.jsx)(Dd,{module:e})})]}),(0,p.jsxs)(`div`,{className:`pb-lg-5`,children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-between`,children:(0,p.jsxs)(`div`,{className:`d-flex gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:E,children:`New Issue`})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:T,children:`New ECN`})}),(0,p.jsx)(`div`,{children:e.type.is_main_tool&&(0,p.jsx)(ZP,{size:`sm`,moduleId:e.id})})]})}),C(e.id)?.map((e,r)=>(0,p.jsx)(eF,{ecn:e,equipment:t,ecnAttachments:b.data?.items??[],reloadQueryFn:S},`ecn-${n}-${r}`)),w(e.id)?.map((e,r)=>(0,p.jsx)($P,{issue:e,equipment:t,issueAttachments:x.data?.items??[],reloadQueryFn:S},`issue-${n}-${r}`))]})]},n))]})]}),l&&s,a&&r]})}var rF=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{e===null&&k({id:parseInt(n)}).then(t)},[n,e]);function r(){k({id:parseInt(n)}).then(t)}return{equipment:e,setEquipment:t,reloadEquipment:r}};function iF({children:e}){let{equipment:t,reloadEquipment:n}=rF();return t===null?(0,p.jsx)(Ct,{children:(0,p.jsx)(vt,{message:`Loading equipment...`})}):(0,p.jsx)(Ct,{children:(0,p.jsx)(QP.Provider,{value:{equipment:t,reloadEquipment:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading...`}),children:e})})})}function aF(){let{equipment:e}=(0,d.useContext)(QP),t=(0,m.useQueries)({queries:[{queryKey:[`activeReservationQuery`,e],queryFn:()=>se({equipment:e,which:`active`})},{queryKey:[`upcomingReservationQuery`,e],queryFn:()=>se({equipment:e,which:`upcoming`})},{queryKey:[`modules`,e],queryFn:()=>oe({equipment:e})}]}),[n,r,i]=t,a=t.some(e=>e.isLoading);t.some(e=>e.isError);let o=t.every(e=>e.isSuccess);return a?(0,p.jsx)(`div`,{children:`Loading...`}):(i.data?.items.findLast(e=>e.type.is_main_tool),o&&(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between mb-3`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[e.name,` Operator Dashboard`]}),(0,p.jsxs)(`div`,{children:[n.data?.items.map((e,t)=>(0,p.jsxs)(`div`,{className:`mx-2 p-2 rounded border-danger`,style:{backgroundColor:e.color},children:[(0,p.jsx)(`i`,{className:`fa fa-calendar-o text-white pe-2`,"aria-hidden":`true`}),`Active reservation`,(0,p.jsx)(`br`,{}),`Until `,YP(e.end,`DD-MM-YY HH:mm`),` by `,e.user.full_name]},t)),r.data?.items.map((e,t)=>(0,p.jsxs)(`div`,{className:`mx-2 p-2 rounded border-success border-2`,style:{backgroundColor:e.color},children:[(0,p.jsx)(`i`,{className:`fa fa-calendar-o text-white pe-2`,"aria-hidden":`true`}),`Next reservation`,(0,p.jsx)(`br`,{}),YP(e.start,`DD-MM-YY HH:mm`),(0,p.jsx)(`br`,{}),e.user.full_name]},t))]})]}))}function oF(){return(0,p.jsxs)(iF,{children:[(0,p.jsx)(aF,{}),(0,p.jsx)(g.Outlet,{})]})}function sF({children:e}){let{id:t}=(0,g.useParams)(),n=(0,m.useQuery)({queryKey:[`statusMail`,t],queryFn:()=>j({id:parseInt(t)}),enabled:!!t});return n.isLoading||n.isFetching?(0,p.jsx)(Ct,{children:(0,p.jsx)(vt,{message:`Loading status mail...`})}):(0,p.jsx)(Ct,{children:(0,p.jsx)(iy.Provider,{value:{statusMail:n.data},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading...`}),children:e})})})}var cF=()=>ht(),lF,uF;function dF(e){let[t,n]=(0,d.useState)(!0),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),s=()=>{n(!1),o(!0)};return(0,d.useEffect)(()=>{if(!document){i(Error(`[ScriptLoadingError] document not defined when attempting to load ${e}`));return}let t=document.querySelector(`script[src="${e}"]`);if(t?.dataset.loaded){s();return}let n=t||document.createElement(`script`);t||(n.src=e),n.addEventListener(`load`,()=>{n.dataset.loaded=`1`,s()}),n.addEventListener(`error`,t=>{console.error(`Failed to load script:`,e,t),i(Error(`[ScriptLoadingError] Failed to load script: ${e}`))}),t||document.head.append(n)},[]),{isLoading:t,error:r,isSuccess:a}}var fF=e=>e&&e.charts,pF=(e,t)=>{let{controls:n,toolbarItems:r,getChartEditor:i}=e;return t&&t.charts&&t.visualization&&t.visualization.ChartWrapper&&t.visualization.Dashboard&&(!n||t.visualization.ChartWrapper)&&(!i||t.visualization.ChartEditor)&&(!r||t.visualization.drawToolbar)},mF=e=>window.google;function hF(e){let{chartVersion:t=`current`,chartPackages:n=[`corechart`,`controls`],chartLanguage:r=`en`,mapsApiKey:i}=e,[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),{isLoading:f,error:p,isSuccess:m}=dF(e.chartLoaderScriptUrl||`https://www.gstatic.com/charts/loader.js`);return(0,d.useEffect)(()=>{if(!m)return;let a=mF();if(!fF(a)){c(Error(`[ScriptInitializationError] Script loaded but Google not attached to window.`));return}if(pF(e,a)){o(a);return}a.charts.load(t,{packages:n,language:r,mapsApiKey:i}),a.charts.setOnLoadCallback(()=>{if(!pF(e,a)){let e=Error(`[GoogleChartsInitializationError] Google Charts not ready after load callback.`);console.error(e),u(e);return}o(a)})},[m]),{error:p||s||l,isLoading:f,google:a}}var gF={legend_toggle:!1,options:{},legendToggle:!1,getChartWrapper:()=>{},spreadSheetQueryParameters:{headers:1,gid:1},rootProps:{},chartWrapperParams:{},chartLoaderScriptUrl:`https://www.gstatic.com/charts/loader.js`},_F=e=>{let{isReady:t,chartControls:n,filter:r}=e;return!t||!n||!n?.length?null:d.default.createElement(d.default.Fragment,null,n.filter(e=>{let{controlProp:t,control:n}=e;return r?r({control:n,controlProp:t}):!0}).map(e=>{let{control:t}=e;return d.default.createElement(`div`,{key:t.getContainerId(),id:t.getContainerId()})}))},vF=0,yF=()=>(vF+=1,`reactgooglegraph-${vF}`),bF=class{};lF=bF,St(bF,`initializeControls`,e=>{for(let t=0;t<e.length;t+=1){let{controlType:n,options:r,controlWrapperParams:i}=e[t].controlProp;i&&`state`in i&&e[t].control.setState(i.state),e[t].control.setOptions(r),e[t].control.setControlType(n)}}),St(bF,`listenToControlEvents`,(e,t)=>{let{google:n}=t;return e.flatMap(e=>{let{control:r,controlProp:i}=e,{controlEvents:a=[]}=i;return a.map(e=>{let{callback:i,eventName:a}=e;return n.visualization.events.addListener(r,a,function(){for(var e=arguments.length,a=Array(e),o=0;o<e;o++)a[o]=arguments[o];i({chartWrapper:null,controlWrapper:r,props:t,google:n,eventArgs:a})})})})}),St(bF,`createControlId`,e=>{let t;return t=e===void 0?`googlechart-control-${yF()}`:e,t}),St(bF,`createChartControls`,e=>{let{controls:t,google:n}=e;return t?t.map((e,t)=>{let{controlID:r,controlType:i,options:a,controlWrapperParams:o}=e,s=lF.createControlId(r);return{controlProp:e,control:new n.visualization.ControlWrapper({containerId:s,controlType:i,options:a,...o})}}):null}),St(bF,`addControls`,e=>{let{chartWrapper:t,chartDashboard:n}=e,r=lF.createChartControls(e);return!r||!n||!t?null:(n.bind(r.map(e=>{let{control:t}=e;return t}),t),lF.initializeControls(r),r)});var xF=e=>{let[t,n]=d.useState(null);return[d.useMemo(()=>!t||!e?null:e.map((e,n)=>{let r=t[n];return r?{controlProp:e,control:r}:void 0}).flatMap(e=>e?[e]:[]),[t,e]),n]},SF=(e,t)=>{d.useEffect(()=>{let n=bF.listenToControlEvents(e??[],t);return()=>{n.forEach(e=>{t.google.visualization.events.removeListener(e)})}},[e,t])},CF=e=>{let[t,n]=xF(e.controls);return SF(t??[],e),{addControls:e=>{n(bF.addControls(e)?.map(e=>e.control)??null)},renderControl:n=>{let{chartWrapper:r,chartDashboard:i}=e;return d.createElement(_F,{...e,isReady:!!(r&&i),chartControls:t,filter:n})}}},wF=e=>{let t=d.useRef(null);return{chartId:(()=>{let{graphID:n,graph_id:r}=e,i=n||r,a;return a=i||t.current||yF(),t.current=a,t.current})()}},TF=[`#3366CC`,`#DC3912`,`#FF9900`,`#109618`,`#990099`,`#3B3EAC`,`#0099C6`,`#DD4477`,`#66AA00`,`#B82E2E`,`#316395`,`#994499`,`#22AA99`,`#AAAA11`,`#6633CC`,`#E67300`,`#8B0707`,`#329262`,`#5574A6`,`#3B3EAC`],EF=async function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return new Promise((r,i)=>{let a=`${n.headers?`headers=${n.headers}`:`headers=0`}`,o=`${n.query?`&tq=${encodeURIComponent(n.query)}`:``}`,s=`${t}/gviz/tq?${`${a}${`${n.gid?`&gid=${n.gid}`:``}`}${`${n.sheet?`&sheet=${n.sheet}`:``}`}${o}${`${n.access_token?`&access_token=${n.access_token}`:``}`}`}`;new e.visualization.Query(s).send(e=>{e.isError()?i(`Error in query: ${e.getMessage()} ${e.getDetailedMessage()}`):r(e.getDataTable())})})},DF=`#CCCCCC`,OF=class{};uF=OF,St(OF,`grayOutHiddenColumnsLabel`,(e,t)=>{let{googleChartWrapper:n,options:r}=e;if(!n){console.error(`googleChartWrapper is not defined`);return}let i=n.getDataTable();if(!i)return;let a=i.getNumberOfColumns();if(!(t.length>0))return;let o=Array.from({length:a-1}).map((e,n)=>{let a=uF.getColumnId(i,n+1);return t.includes(a)?DF:r&&r.colors?r.colors[n]:TF[n]});n.setOptions({...r,colors:o}),n.draw()}),St(OF,`listenToLegendToggle`,(e,t)=>{let[n,r]=t,{google:i,googleChartWrapper:a}=e;if(!a){console.error(`googleChartWrapper is not defined`);return}return i.visualization.events.addListener(a,`select`,()=>{let e=a.getChart().getSelection(),t=a.getDataTable();if(e.length===0||e[0].row!==null||!t)return;let i=e[0].column,o=uF.getColumnId(t,i);n?.includes(o)?r(e=>[...e.filter(e=>e!==o)]):r(e=>[...e,o])})}),St(OF,`draw`,async e=>{let{data:t,diffdata:n,rows:r,columns:i,options:a,chartType:o,formatters:s,spreadSheetUrl:c,spreadSheetQueryParameters:l,googleChartDashboard:u,googleChartWrapper:d,google:f,hiddenColumns:p,legendToggle:m,legend_toggle:h}=e;if(!d){console.error(`draw was called with googleChartWrapper = null`);return}let g,_=null;if(n){let e=f.visualization.arrayToDataTable(n.old),t=f.visualization.arrayToDataTable(n.new);_=f.visualization[o].prototype.computeDiff(e,t)}g=t?t instanceof f.visualization.DataTable?t:Array.isArray(t)?f.visualization.arrayToDataTable(t):new f.visualization.DataTable(t):r&&i?f.visualization.arrayToDataTable([i,...r]):c?await EF(f,c,l):f.visualization.arrayToDataTable([]);let v=g.getNumberOfColumns(),y=Array(v).fill(0).map((e,t)=>{let n=uF.getColumnId(g,t);return p.includes(n)?{label:g.getColumnLabel(t),type:g.getColumnType(t),calc:()=>null}:t}),b=d.getChart();d.getChartType()===`Timeline`&&b&&b.clearChart(),d.setChartType(o),d.setOptions(a||{});let x=new f.visualization.DataView(g);x.setColumns(y),d.setDataTable(x),d.draw(),u&&u.draw(g),_&&(d.setDataTable(_),d.draw()),s&&(uF.applyFormatters({dataTable:g,formatters:s,google:f}),d.setDataTable(g),d.draw()),(m===!0||h===!0)&&uF.grayOutHiddenColumnsLabel(e,p)}),St(OF,`getColumnId`,(e,t)=>e.getColumnId(t)||e.getColumnLabel(t)),St(OF,`applyFormatters`,e=>{let{dataTable:t,formatters:n,google:r}=e;for(let e of n)switch(e.type){case`ArrowFormat`:new r.visualization.ArrowFormat(e.options).format(t,e.column);return;case`BarFormat`:new r.visualization.BarFormat(e.options).format(t,e.column);return;case`ColorFormat`:{let n=new r.visualization.ColorFormat(e.options),{ranges:i}=e;if(i)for(let e of i)n.addRange(...e);n.format(t,e.column);return}case`DateFormat`:new r.visualization.DateFormat(e.options).format(t,e.column);return;case`NumberFormat`:new r.visualization.NumberFormat(e.options).format(t,e.column);return;case`PatternFormat`:new r.visualization.PatternFormat(e.options).format(t,e.column);return;default:console.warn(`Unknown formatter type: ${e.type}`);return}});var kF=e=>{let{google:t,googleChartWrapper:n,googleChartDashboard:r}=e,[i,a]=d.useState([]);d.useEffect(()=>{n&&OF.draw({...e,hiddenColumns:i,googleChartWrapper:n,googleChartDashboard:r,google:t})},[i,e.data,e.rows,e.columns,e.options,e.chartLoaderScriptUrl,e.chartType,e.formatters,e.spreadSheetUrl,e.spreadSheetQueryParameters,e.legendToggle,e.legend_toggle]);let o=()=>{let{googleChartWrapper:t}=e;t&&t.draw()},s=n=>{let s=[],{legendToggle:c,legend_toggle:l}=e;if(OF.draw({...e,hiddenColumns:i,googleChartWrapper:n,googleChartDashboard:r,google:t}),window.addEventListener(`resize`,o),l||c){let t=OF.listenToLegendToggle(e,[i,a]);t&&s.push(t)}return s},c=(e,n)=>{window.removeEventListener(`resize`,o),n.forEach(e=>{t.visualization.events.removeListener(e)}),e.getChartType()===`Timeline`&&e.getChart()&&e.getChart().clearChart()};d.useEffect(()=>{if(!n)return;let e=s(n);return()=>{c(n,e)}},[n,s,c])},AF=e=>{let{chartEvents:t,google:n,googleChartWrapper:r}=e;if(t){if(!r){console.warn(`listenToEvents was called before chart wrapper ready.`);return}return t.map(t=>{let{eventName:i,callback:a}=t;return n.visualization.events.addListener(r,i,function(){for(var t=arguments.length,i=Array(t),o=0;o<t;o++)i[o]=arguments[o];a({chartWrapper:r,props:e,google:n,eventArgs:i})})})}},jF=e=>{(0,d.useEffect)(()=>{if(!e.googleChartWrapper)return;let t=AF(e);return()=>{t?.forEach(t=>{e.google.visualization.events.removeListener(t)})}},[e])},MF=e=>{let[t,n]=d.useState(null),[r,i]=d.useState(null),{addControls:a,renderControl:o}=CF({...e,chartDashboard:r,chartWrapper:t});jF({...e,googleChartWrapper:t});let{chartId:s}=wF(e),c=d.useRef(null),l=d.useRef(null);d.useEffect(()=>{let{options:t,google:r,chartType:o,chartWrapperParams:u,toolbarItems:d,getChartEditor:f,getChartWrapper:p,onLoad:m}=e,h={chartType:o,options:t,containerId:s,...u},g=new r.visualization.ChartWrapper(h);g.setOptions(t||{}),p?.(g,r);let _=new r.visualization.Dashboard(c.current);d&&r.visualization.drawToolbar(l.current,d);let v=null;f&&(v=new r.visualization.ChartEditor,f({chartEditor:v,chartWrapper:g,google:r})),a({...e,chartDashboard:_,chartWrapper:g}),n(g),i(_),m?.(r,{google:r,chartWrapper:g,chartEditor:v,chartDashboard:_})},[]),kF({...e,googleChartWrapper:t,googleChartDashboard:r});let u=()=>{let{width:t,height:n,options:r,style:i,className:a,rootProps:o,google:c}=e,l={height:n||r&&r.height,width:t||r&&r.width,...i};return d.createElement(`div`,{id:s,style:l,className:a,...o})},f=()=>e.toolbarItems?d.createElement(`div`,{ref:l}):null,{width:p,height:m,options:h,style:g}=e,_={height:m||h&&h.height,width:p||h&&h.width,...g};return e.render?d.createElement(`div`,{ref:c,style:_},d.createElement(`div`,{ref:l,id:`toolbar`}),e.render({renderChart:u,renderControl:o,renderToolbar:f})):d.createElement(`div`,{ref:c,style:_},o(e=>{let{controlProp:t}=e;return t.controlPosition!==`bottom`}),u(),o(e=>{let{controlProp:t}=e;return t.controlPosition===`bottom`}),f())},NF=d.createContext(gF),PF=e=>{let{children:t,value:n}=e;return d.createElement(NF.Provider,{value:n},t)},FF=e=>{let{google:t,isLoading:n,error:r}=hF(e);return n?e.loader??null:r?e.errorElement??null:t?d.default.createElement(MF,{google:t,...e}):null},IF=e=>{let t={...gF,...e};return d.default.createElement(PF,{value:t},d.default.createElement(FF,t))},LF;(function(e){e.annotation=`annotation`,e.annotationText=`annotationText`,e.certainty=`certainty`,e.emphasis=`emphasis`,e.interval=`interval`,e.scope=`scope`,e.style=`style`,e.tooltip=`tooltip`,e.domain=`domain`})(LF||(LF={}));function RF({target:e,results:t}){let n={title:e.logging_parameter.name,curveType:`function`,series:{0:{pointSize:10},1:{},2:{},3:{}},legend:{position:`bottom`}},r=[[{type:`date`,label:`Date`},`Value`]],i=1;return e.target&&(r[0].push(`Target`),n.series[i]={color:`#38e22c`,lineWidth:2,pointShape:{type:`square`}},i++),e.min_value&&(r[0].push(`Min`),n.series[i]={color:`#e2431e`,lineWidth:2,pointShape:{type:`triangle`},pointSize:10},i++),e.max_value&&(r[0].push(`Max`),n.series[i]={color:`#e2431e`,lineWidth:2,pointShape:{type:`triangle`,rotation:180},pointSize:10}),t.forEach(t=>{t.values.filter(t=>t.logging_parameter.id===e.logging_parameter.id).filter(e=>e.float_value!==0).forEach(n=>{let i=new Date(t.date_created);r.push([i,n.float_value]),e.target&&r[r.length-1].push(e.target),e.min_value&&r[r.length-1].push(e.min_value),e.max_value&&r[r.length-1].push(e.max_value)})}),r.length===1?(0,p.jsx)(`div`,{className:`text-center`,children:`No data available`}):(0,p.jsx)(IF,{chartType:`ScatterChart`,width:`100%`,height:`400px`,data:r,options:n})}var zF=({data:e,setPage:t,setPageSize:n,pageSize:r,isPlaceholderData:i})=>{if(e===void 0||i)return(0,p.jsx)(p.Fragment,{});let a=[];for(let n=1;n<=e.amountOfPages;n++)a.push((0,p.jsx)(Sl.Item,{active:n===e.currentPage,onClick:()=>t(e=>n),children:n},n));return(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(`div`,{className:`d-flex gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{size:`sm`,onClick:()=>t(e=>Math.max(e-1,0)),disabled:e.currentPage===1,children:`Previous Page`})}),(0,p.jsx)(Sl,{size:`sm`,children:a.map((e,t)=>(0,p.jsx)(`div`,{children:e},t))}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{size:`sm`,onClick:()=>{!i&&e.hasMore&&t(e=>e+1)},disabled:i||!e.hasMore,children:`Next Page`})})]}),n===void 0?null:(0,p.jsx)(`div`,{children:(0,p.jsxs)(H.Select,{onChange:e=>{n(t=>parseInt(e.target.value))},value:r,size:`sm`,children:[(0,p.jsx)(`option`,{value:10,children:`10`}),(0,p.jsx)(`option`,{value:25,children:`25`}),(0,p.jsx)(`option`,{value:50,children:`50`}),(0,p.jsx)(`option`,{value:100,children:`100`})]})})]})},BF=new Date().toISOString().split(`T`)[0],VF=({requirement:e,targets:t,refetchResults:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1),{control:l,register:u,handleSubmit:m,reset:h,watch:g,formState:{errors:_,isValid:v}}=Ed({defaultValues:{date:BF}}),{fields:y,append:b,remove:x}=Td({control:l,name:`results`,rules:{required:!0}});(0,d.useEffect)(()=>{x(),t.forEach(e=>{b({id:e.id,label:e.logging_parameter.name,logging_parameter_id:e.logging_parameter.id,value:``})})},[t]),(0,d.useEffect)(()=>{c(v)},[g(),v]);async function S(t){await f.default.post(`create/monitor/requirement/result`,{requirement:e.id,date:t.date,values:t.results}),o(!0),i(!1),n(),h()}function C(){return(0,p.jsx)(Rl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Il,{onClose:()=>o(!1),show:a,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Il.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Il.Body,{children:`Measurement results were saved successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,onClick:()=>i(!0),children:`Add manual result`}),(0,p.jsx)(U,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(H,{onSubmit:m(e=>S(e)),validated:s,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add manual result`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`date`,placeholder:`Date`,required:!0,...u(`date`,{required:`This field is required`})},`date`),_.date&&(0,p.jsx)(H.Control.Feedback,{children:_.date.message})]}),y.map((e,t)=>(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:e.label}),(0,p.jsxs)(Ps,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{type:`number`,step:.01,placeholder:e.label,required:!0,...u(`results.${t}.value`,{required:`This field is required`})},e.id),_?.results?.[t]?.value&&(0,p.jsx)(H.Control.Feedback,{children:_.results[t].value.message})]})]},t))]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{h(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(C,{})]})},HF=({requirement:e,result:t,refetchMonitorStepParameterValues:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)([]),{control:m,register:h,handleSubmit:g,reset:_,watch:v,formState:{errors:y,isValid:b}}=Ed({defaultValues:{}});(0,d.useEffect)(()=>{async function n(){let n=await _e({result:t}),r=await be({requirement:e}),i=await ae({module:e.step.process_module.module});r.items=r.items.filter(e=>!n.items.map(e=>e.step_parameter.id).includes(e.id)),r.items=r.items.filter(e=>i.items.map(e=>e.parameter.id).includes(e.parameter.id)),u(r.items)}r&&n()},[r]),(0,d.useEffect)(()=>{c(b)},[v(),b]);async function x(e){await f.default.post(`create/monitor/requirement/result/step-parameter-value`,{result:t.id,step_parameter:e.module_step_parameter_id,value:e.value}),o(!0),i(!1),n(),_()}function S(){return(0,p.jsx)(Rl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Il,{onClose:()=>o(!1),show:a,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Il.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Il.Body,{children:`Measurement results were saved successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:()=>i(!0),children:`+`}),(0,p.jsx)(U,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(H,{onSubmit:g(e=>x(e)),validated:s,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add process parameter`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`text`,value:t.date_created,readOnly:!0})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Module Step Parameter`}),(0,p.jsxs)(H.Select,{...h(`module_step_parameter_id`,{required:!0}),children:[(0,p.jsx)(`option`,{value:``,children:`— Select a parameter`}),l.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.parameter.name},e.id))]}),(0,p.jsx)(H.Text,{className:`text-muted`,children:`Only parameters are shown here which are active on the Equipment Module and in the monitor step. In case parameters are missing you should replace the process in the monitor with the same process from the process library to reload the parameters`})]}),(0,p.jsxs)(Ps,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{type:`number`,step:.01,required:!0,...h(`value`,{required:`This field is required`})}),y?.value&&(0,p.jsx)(H.Control.Feedback,{children:y.value.message})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{_(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(S,{})]})},UF=({monitorResultStepParameterValue:e,refetchMonitorStepParameterValues:t})=>{let[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(!1),{control:c,register:l,handleSubmit:u,reset:m,watch:h,formState:{errors:g,isValid:_}}=Ed({defaultValues:{value:e.value.toString()}});(0,d.useEffect)(()=>{s(_)},[h(),_]);async function v(n){await f.default.patch(`update/monitor/requirement/result/step-parameter-value/`+e.id,{value:n.value}),a(!0),r(!1),t(),m()}async function y(){await f.default.delete(`delete/monitor/requirement/result/step-parameter-value/`+e.id,{}),a(!0),r(!1),t(),m()}function b(){return(0,p.jsx)(Rl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Il,{onClose:()=>a(!1),show:i,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Il.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Il.Body,{children:`Measurement results were saved successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{onClick:()=>r(!0),children:e.value}),(0,p.jsx)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:(0,p.jsxs)(H,{onSubmit:u(e=>v(e)),validated:o,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add process parameter`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`text`,value:e.date_created,readOnly:!0})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Module Step Parameter`}),(0,p.jsx)(H.Control,{type:`text`,value:e.step_parameter.parameter.name,readOnly:!0})]}),(0,p.jsxs)(Ps,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{type:`number`,step:.01,required:!0,...l(`value`,{required:`This field is required`})}),g?.value&&(0,p.jsx)(H.Control.Feedback,{children:g.value.message})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Update value`}),(0,p.jsx)(B,{className:`float-end`,variant:`danger`,onClick:()=>y(),children:`Delete value`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{m(),r(!1)},children:`Close`})]})]})}),(0,p.jsx)(b,{})]})};function WF({requirement:e}){let[t,n]=(0,d.useState)([]),[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(1),[s,c]=(0,d.useState)(15),[l,u]=(0,d.useState)([]),[h,g,_,v]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`files`,e.step,11],queryFn:()=>ye({step:e.step,pageSize:11,order:`date-created`,direction:`desc`})},{queryKey:[`requirement`,`target`,e],queryFn:()=>ve({requirement:e})},{queryKey:[`requirement`,`results`,e,a,s],queryFn:()=>ge({requirement:e,pageSize:s,order:`date-created`,direction:`desc`,page:a}),placeholderData:m.keepPreviousData},{queryKey:[`requirement`,`monitor_step_parameters`,e,a,s],queryFn:()=>_e({requirement:e,pageSize:s,order:`date-created`,direction:`desc`,page:a}),placeholderData:m.keepPreviousData}]});(0,d.useEffect)(()=>{n([]),!h.isLoading&&h.data.items.forEach(e=>{n(t=>[...t,e])})},[h.isLoading]),(0,d.useEffect)(()=>{v.data&&u(Array.from(new Map(v.data.items.map(e=>[e.step_parameter.id,e.step_parameter])).values()))},[v.isLoading,v.data]);let{getRootProps:y,getInputProps:b,isDragActive:x,isDragAccept:S,isDragReject:C}=Ib({onDrop:(0,d.useCallback)(t=>{t.forEach(t=>{let n=new FileReader;n.onload=async()=>{let r=n.result;try{await f.default.create().post(`update/monitor/requirement/upload-file/`+e.id,{content:r,filename:t.name,type:t.type})}catch(e){i(`Upload failed due to: `+e.response.data.detail)}await h.refetch(),await _.refetch()},n.readAsDataURL(t)})},[e.id,h,_])}),w=(0,d.useMemo)(()=>({...x?{borderColor:`#83afee`}:{},...S?{borderColor:`#00e676`}:{},...C?{borderColor:`#ff1744`}:{}}),[S,C,x]);return g.isLoading||g.isFetching?(0,p.jsx)(vr,{variant:`info`,children:`Loading targets...`}):_.isLoading||_.isFetching?(0,p.jsx)(vr,{variant:`info`,children:`Loading results...`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`h1`,{className:`display-5`,children:[`Requirement: `,e.title]}),(0,p.jsx)(`p`,{className:`lead`,children:e.definition}),(0,p.jsx)(Dl,{className:`my-3`,children:(0,p.jsxs)(Ur,{children:[(0,p.jsx)(`h2`,{children:`Charts`}),(0,p.jsx)(`div`,{className:`d-flex`,children:g.data?.items.map((e,t)=>(0,p.jsx)(RF,{target:e,results:_.data.items},t))})]})}),(0,p.jsxs)(Dl,{children:[(0,p.jsxs)(Ur,{md:8,children:[e.method&&e.method!==`-`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{children:`Method`}),(0,p.jsx)(`p`,{children:e.method})]}),g.data?.items.length===0&&(0,p.jsx)(vr,{variant:`danger`,children:`No targets found`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`h2`,{children:`Results`}),(0,p.jsx)(`div`,{children:(0,p.jsx)(VF,{requirement:e,targets:g.data.items,refetchResults:_.refetch})})]}),(0,p.jsxs)(kl,{size:`sm`,striped:!0,bordered:!0,hover:!0,children:[(0,p.jsxs)(`thead`,{children:[(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`Date`}),g.data?.items.map((e,t)=>(0,p.jsx)(`th`,{children:e.logging_parameter.name},t)),l.map((e,t)=>(0,p.jsx)(`th`,{children:e.parameter.name},t)),(0,p.jsx)(`th`,{children:`+`})]}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2}),g.data?.items.map((e,t)=>(0,p.jsxs)(`td`,{children:[e.min_value,e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`≤`}),!e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`<`}),e.target??`X`,e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`≥`}),!e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`>`}),e.max_value]},t)),l.map((e,t)=>(0,p.jsx)(`th`,{className:`table-secondary`},t)),(0,p.jsx)(`th`,{})]})]}),(0,p.jsx)(`tbody`,{children:_.data?.items.map((t,n)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:t.id})},n),(0,p.jsx)(`td`,{children:YP(t.date_created,`DD-MM-YY HH:mm`)}),g.data?.items.map((e,n)=>(0,p.jsx)(`td`,{children:t.values.filter(t=>t.logging_parameter.id===e.logging_parameter.id).map((e,t)=>(0,p.jsx)(`span`,{className:e.value_is_valid?`text-success`:`text-danger`,children:e.float_value},t))},n)),l.map((e,n)=>(0,p.jsx)(`td`,{className:`table-secondary`,children:v.data?.items.filter(n=>n.step_parameter.id===e.id&&n.result.id===t.id).map((e,t)=>(0,p.jsx)(UF,{monitorResultStepParameterValue:e,refetchMonitorStepParameterValues:v.refetch},t))},n)),(0,p.jsx)(`td`,{children:(0,p.jsx)(HF,{result:t,requirement:e,refetchMonitorStepParameterValues:v.refetch})})]},n))})]}),(0,p.jsx)(zF,{data:_.data,setPage:o,setPageSize:c,pageSize:s,isPlaceholderData:_.isPlaceholderData})]}),(0,p.jsxs)(Ur,{md:4,children:[(0,p.jsx)(`h2`,{children:`Upload new results`}),(0,p.jsx)(`p`,{children:`Drop your results file here`}),(0,p.jsxs)(`div`,{...y({style:w,className:`dropzone`}),children:[(0,p.jsx)(`input`,{...b()}),x?(0,p.jsx)(`p`,{children:`Drop file(s) here ...`}):(0,p.jsx)(`p`,{children:`Drag and drop file(s) here, or click to select files`}),(0,p.jsx)(`p`,{children:r})]}),t.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{className:`mt-2`,children:`Uploaded files`}),(0,p.jsxs)(`p`,{children:[`Last `,11,` uploaded files`]}),(0,p.jsx)(`ul`,{className:`list-group`,children:t.map((e,t)=>(0,p.jsxs)(`li`,{className:`list-group-item`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(`span`,{children:[t+1,` `,(0,p.jsx)(`a`,{href:cF()+e.url,children:e.name}),e.has_monitor_step_loggings&&(0,p.jsx)(yr,{className:`ms-1 bg-primary`,children:`Logging`})]}),(0,p.jsxs)(`span`,{children:[Math.round(e.size/1024),`kiB`]})]}),(0,p.jsx)(`small`,{className:`text-muted`,children:YP(e.date_created,`DD-MM-YY HH:mm`)})]},t))})]})]})]})]})}function GF(){let{id:e}=(0,g.useParams)(),[t,n]=(0,m.useQueries)({queries:[{queryKey:[`monitor`,e],queryFn:()=>pe({id:parseInt(e)})},{queryKey:[`requirements`,e],queryFn:()=>me({monitorId:parseInt(e)})}]});return t.isLoading?(0,p.jsx)(`div`,{children:`Loading...`}):(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[`SPC Test `,t.data?.name]}),n.data?.items.map((e,t)=>(0,p.jsx)(`div`,{className:`border border-1 p-3 my-3`,children:(0,p.jsx)(WF,{requirement:e})},t))]})}function KF(){return(0,p.jsx)(Wr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}var qF=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{e===null&&pe({id:parseInt(n)}).then(t)},[n,e]);function r(){pe({id:parseInt(n)}).then(t)}return{monitor:e,setMonitor:t,reloadMonitor:r}},JF=(0,d.createContext)({monitor:{},reloadMonitor:()=>{}});function YF({children:e}){let{monitor:t,reloadMonitor:n}=qF();return t===null?(0,p.jsx)(Ct,{children:(0,p.jsx)(vt,{message:`Loading monitor...`})}):(0,p.jsx)(Ct,{children:(0,p.jsx)(JF.Provider,{value:{monitor:t,reloadMonitor:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading...`}),children:e})})})}var XF=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{(e===null||n!==e.id.toString())&&xe({id:parseInt(n)}).then(t)},[n,e]);function r(){xe({id:parseInt(n)}).then(t)}return{run:e,reloadRun:r}},ZF=(0,d.createContext)({run:{},reloadRun:()=>{}});function QF({children:e}){let{run:t,reloadRun:n}=XF();return t===null?(0,p.jsx)(vt,{message:`Loading run...`}):(0,p.jsx)(Ct,{children:(0,p.jsx)(ZF.Provider,{value:{run:t,reloadRun:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading rest of run...`}),children:e})})})}function $F({text:e}){if(!e)return null;let t=e.split(/\r\n|\n|\r/);return(0,p.jsx)(p.Fragment,{children:t.map((e,n)=>(0,p.jsxs)(d.default.Fragment,{children:[e,n<t.length-1&&(0,p.jsx)(`br`,{})]},n))})}var eI=({children:e,format:t=`d-M-Y`})=>(0,p.jsx)(p.Fragment,{children:q(Date.parse(e)).format(t)}),tI=({run:e})=>{let[t,n]=(0,d.useState)(e.batch_card),[r,i]=(0,d.useState)(!1),{register:a,handleSubmit:o,formState:s,resetField:c}=Ed({defaultValues:{content:t?.content}}),{isSubmitting:l,errors:u}=s,m=async t=>{await f.default.create().patch(`update/run/batch-card/`+e.id,{content:t.content}),i(!1),n((await f.default.get(`view/run/`+e.id)).data.batch_card)},h=async()=>{await f.default.create().delete(`delete/run/batch-card/`+e.id),i(!1),n(void 0),c(`content`)};return r?(0,p.jsxs)(H,{onSubmit:o(m),className:`mb-3`,children:[(0,p.jsxs)(Ps,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:6,...a(`content`,{required:!0}),isInvalid:u.content!==void 0}),u.content&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:`This field is required`})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-md-row gap-2 justify-content-between mt-2`,children:[(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-2`,children:[(0,p.jsxs)(B,{variant:`primary`,type:`submit`,disabled:l,className:`text-nowrap`,children:[l&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Save batch card`]}),(0,p.jsx)(B,{variant:`secondary`,onClick:()=>i(!1),children:`Cancel`})]}),t&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`outline-danger`,className:`text-nowrap`,onClick:h,children:`Delete batch card`})})]})]}):t?t&&(0,p.jsxs)(Pr,{className:`rounded my-4 shadow-sm border-0`,children:[(0,p.jsxs)(Pr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-start justify-content-between gap-3`,children:[(0,p.jsx)(Pr.Title,{className:`text-danger mb-0`,children:`Batch card`}),(0,p.jsx)(B,{variant:`outline-primary`,size:`sm`,className:`text-nowrap`,onClick:()=>i(!0),children:`Update batch card`})]}),(0,p.jsx)(Pr.Text,{className:`mt-3 mb-2 fs-5 text-body`,children:t&&(0,p.jsx)($F,{text:t.content})})]}),(0,p.jsx)(Pr.Footer,{className:`bg-transparent border-0 pt-0 pb-3`,children:(0,p.jsxs)(`div`,{className:`text-muted small`,children:[`Created `,(0,p.jsx)(eI,{format:`DD-MM-YY`,children:t.date_created}),` by`,` `,t.user.first_name,` `,t.user.last_name,t.last_update&&(0,p.jsxs)(`span`,{children:[` (`,`Updated `,(0,p.jsx)(eI,{format:`DD-MM-YY H:m`,children:t.last_update}),`)`]})]})})]}):(0,p.jsx)(B,{variant:`outline-primary`,className:`mb-4`,onClick:()=>i(!0),children:`Create Batch Card`})};function nI(){let{run:e}=(0,d.useContext)(ZF);return(0,p.jsxs)(p.Fragment,{children:[e.run_type===ut.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),e.run_type===ut.PRODUCTION&&(0,p.jsx)(`small`,{children:`Production run`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:(0,p.jsxs)(`h1`,{className:`display-4`,children:[e.name,` (`,e.project.name,`)`]})}),(0,p.jsx)(tI,{run:e})]})}function rI(e){let{run:t,reloadRun:n}=(0,d.useContext)(ZF),{environment:r}=(0,g.useParams)(),i=window.location.pathname,a=[{title:`Information`,link:`/${r}/operator/run/details/${t.id}/information`}];return a.push({title:`Steps`,link:`/${r}/operator/run/details/${t.id}/steps`}),(0,p.jsx)(Jc,{variant:`tabs`,className:e.className,defaultActiveKey:`/home`,activeKey:i,children:a.map((e,t)=>(0,p.jsx)(Jc.Item,{children:(0,p.jsx)(g.Link,{to:e.link,className:`nav-link `+(e.link===i?`active`:``),children:e.title})},t))})}function iI(){return(0,p.jsx)(QF,{children:(0,p.jsxs)(Wr,{fluid:!0,children:[(0,p.jsx)(nI,{}),(0,p.jsx)(rI,{className:`mb-4`}),(0,p.jsx)(g.Outlet,{})]})})}var aI=(0,d.createContext)({showOnlyEmphasizedParameters:!1,setShowOnlyEmphasizedParameters:()=>{}}),oI=({parameter:e,value:t,refetchFn:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(t.value),s=async r=>{let a={value:r};try{t.id===void 0?(a.parameter=e.id,await f.default.post(`/create/run/step/parameter/value`,a)):await f.default.patch(`/update/run/step/parameter/value/${t.id}`,a)}catch(e){console.error(`Failed to update parameter value with error: `,e)}n(),i(!1)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{style:{cursor:`pointer`,borderBottom:`1px dashed #999`,display:r?`none`:``},className:t.value==``||t.value==null?`text-muted`:``,onClick:()=>{i(!r)},children:t.value!==``&&t.value!==null?t.value:`edit`}),(0,p.jsxs)(`div`,{style:{display:r?``:`none`},className:`btn-group`,children:[(0,p.jsx)(`input`,{type:`text`,value:a??``,className:`form-control`,onChange:e=>o(e.target.value)}),(0,p.jsx)(`button`,{onClick:()=>{s(a)},className:`btn btn-success btn-sm`,children:(0,p.jsx)(`i`,{className:`fa fa-check`})}),(0,p.jsx)(`button`,{onClick:()=>{i(!1)},className:`btn btn-danger btn-sm`,children:(0,p.jsx)(`i`,{className:`fa fa-times`})})]})]})},sI=({runStep:e,showOnlyEmphasizedParameters:t,editableParameters:n=!0,refetchFn:r})=>{let{data:i,isLoading:a}=(0,m.useQuery)({queryKey:[`runStepParameters`,e.id],queryFn:()=>Me({runStep:e})}),o=(0,m.useQueryClient)(),s=()=>{o.refetchQueries({queryKey:[`runStepParameters`,e.id]}),r&&r()},c=i?.items??[],l=t?c.filter(e=>e.emphasize):c;return a?(0,p.jsxs)(kl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Pos`}),(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:Array.from({length:2}).map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:3})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:7})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:4})})})]},t))})]}):c.length===0?(0,p.jsx)(vr,{variant:`info`,children:`No parameters found`}):(0,p.jsxs)(kl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Pos`}),(0,p.jsx)(`th`,{children:`Parameter`}),c[0].values.map((e,t)=>(0,p.jsx)(`th`,{children:`Value`},t)),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:l.length>0?l.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:e.sequence})}),(0,p.jsx)(`td`,{children:e.parameter.name}),e.values.map((t,r)=>(0,p.jsx)(`td`,{children:n?(0,p.jsx)(oI,{parameter:e,refetchFn:s,value:t}):(0,p.jsx)(`span`,{children:t.value})},r)),(0,p.jsx)(`td`,{children:e.unit?.abbr??``})]},e.id)):(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:3+c[0].values.length,children:`No emphasized parameters found.`})})})]})},cI=e=>{if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**+r).toFixed(2))} ${n[r]}`};function lI({runStep:e,refetchFn:t}){let[n,r]=(0,d.useState)([]),[i,a]=(0,d.useState)(``),{data:o,isLoading:s}=(0,m.useQuery)({queryKey:[`files`,e.id],queryFn:()=>je({step:e})}),c=(0,m.useQueryClient)(),l=()=>{c.refetchQueries({queryKey:[`files`,e.id]}),t&&t()},u=o?.items??[],h=async e=>{if(confirm(`Are you sure you want to delete ${e.name}? You can not undo this action`))try{await f.default.delete(`delete/run/step/file/${e.id}`),l()}catch(e){console.error(e)}},{getRootProps:g,getInputProps:_,isDragActive:v,isDragAccept:y,isDragReject:b}=Ib({onDrop:e=>{r(t=>[...t,...e]),a(`${e.length} file(s) selected`)}}),x=(0,d.useMemo)(()=>({...v?{borderColor:`#83afee`}:{},...y?{borderColor:`#00e676`}:{},...b?{borderColor:`#ff1744`}:{}}),[y,b,v]),S=()=>{n.forEach(t=>{let n=new FileReader;n.onload=async()=>{let i=n.result;try{await f.default.create().post(`update/run/step/upload-file/`+e.id,{content:i,filename:t.name,type:t.type})}catch(e){a(`Upload failed due to: `+e.response.data.detail)}try{l(),a(`Files uploaded succesfully`),r([])}catch(e){a(`Error refetching file data`),console.error(e)}},n.readAsDataURL(t)})};return s?(0,p.jsx)(`div`,{children:`Loading...`}):(0,p.jsxs)(`div`,{children:[u&&u.length>0&&(0,p.jsxs)(kl,{hover:!0,striped:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`No`}),(0,p.jsx)(`th`,{children:`File`}),(0,p.jsx)(`th`,{children:`Size`}),(0,p.jsx)(`th`,{children:`Date`})]})}),(0,p.jsx)(`tbody`,{children:u.map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:t+1})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(`a`,{href:`${cF()}${e.url}`,children:e.name}),e.has_run_step_loggings&&(0,p.jsx)(yr,{className:`ms-1 bg-primary`,children:`Logging`})]}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(`i`,{className:`fa fa-trash-o remove-file handle`,style:{cursor:`pointer`},onClick:()=>h(e)}),` `,cI(e.size)]}),(0,p.jsx)(`td`,{children:YP(e.date_created,`DD-MM-YY HH:mm`)})]},t))})]}),(0,p.jsxs)(`div`,{...g({style:x,className:`dropzone bg-secondary-subtle border rounded dz-clickable`}),children:[(0,p.jsx)(`input`,{..._()}),v?(0,p.jsx)(`p`,{children:`Drop files here...`}):(0,p.jsx)(`p`,{children:`Drag and drop files here or click to select`})]}),n.length>0&&(0,p.jsx)(Zs,{className:`mt-3`,children:n.map((e,t)=>(0,p.jsx)(Zs.Item,{children:e.name},t))}),(0,p.jsxs)(`div`,{className:`text-start`,children:[(0,p.jsx)(B,{className:`mt-3`,onClick:S,disabled:n.length===0,children:`Upload Selected Files`}),(0,p.jsx)(`p`,{className:`mt-2 text-muted`,children:i})]})]})}var uI=({runStepPart:e,setRunStepPart:t,editable:n=!0})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(e.comment),{register:s,handleSubmit:c,formState:l,resetField:u}=Ed({defaultValues:{comment:a}}),{isSubmitting:m,errors:h}=l;return n?r?(0,p.jsxs)(H,{onSubmit:c(async n=>{await f.default.create().patch(`update/run/step/part/`+e.id,{comment:n.comment}).then(n=>{t({...e,comment:n.data.comment}),o(n.data.comment),i(!1)})}),children:[(0,p.jsx)(H.Group,{className:`mb-3`,controlId:`formBasicEmail`,children:(0,p.jsx)(H.Control,{as:`textarea`,...s(`comment`)})}),(0,p.jsx)(B,{size:`sm`,type:`submit`,disabled:m,children:`Save`}),(0,p.jsx)(B,{variant:`warning`,size:`sm`,className:`ms-2`,onClick:()=>i(!1),children:`Cancel`})]}):a===null?(0,p.jsx)(B,{variant:`link`,size:`sm`,className:`p-0 text-muted`,onClick:()=>i(!0),children:`Add comment`}):(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`div`,{className:`text-break`,children:a}),(0,p.jsx)(B,{variant:`link`,size:`sm`,className:`p-0 text-muted`,onClick:()=>i(!0),children:`Edit`})]}):(0,p.jsx)(`div`,{children:a})},dI=({runStepPart:e,setRunStepPartAction:t,createRunStepPart:n})=>(0,p.jsxs)(ss,{align:`end`,children:[(0,p.jsx)(ss.Toggle,{size:`sm`,variant:`outline-secondary`,children:`Actions`}),(0,p.jsxs)(ss.Menu,{children:[e.available_actions.map(({id:n,name:r})=>(0,p.jsx)(ss.Item,{onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n)),(0,p.jsx)(ss.Item,{onClick:()=>n(),children:`Init`})]})]}),fI={[Ie.START]:`btn-primary`,[Ie.FINISH]:`btn-success`,[Ie.FAIL]:`btn-danger`,[Ie.REWORK]:`btn-info`,[Ie.SET_REPAIR]:`btn-warning`,[Ie.CLEAR_REPAIR]:`btn-warning`,[Ie.SET_TESTING]:`btn-dark`,[Ie.CLEAR_TESTING]:`btn-dark`},pI=({runStepPart:e,setRunStepPartAction:t})=>e.available_actions.length===0?null:(0,p.jsx)(p.Fragment,{children:e.available_actions.map(({id:n,name:r})=>(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm me-2 ${fI[n]}`,onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n))}),mI=(e,t)=>{let{status:n,processed:r,failed:i,started:a,available_actions:o}=t.updated_run_step_part_state;return{...e,status:n,processed:r,failed:i,started:a,available_actions:o}},hI=(e,t)=>e&&(Array.isArray(e.pages)?{...e,pages:e.pages.map(e=>!e||!Array.isArray(e.items)?e:{...e,items:t(e.items)})}:Array.isArray(e.items)?{...e,items:t(e.items)}:e),gI=(e,t)=>{let{runStepPart:n,latestAction:r}=t;return hI(e,e=>e.map(e=>e.id===n.id?mI(e,r):e))},_I=(e,t)=>hI(e,e=>e.map(e=>t.get(e.id)??e)),vI=e=>Array.isArray(e)?e:Array.isArray(e.items)?e.items:[],yI=(e,t)=>{let n=vI(t);if(n.length===0)return e;let r=new Map(n.map(e=>[e.updated_run_step_part_state.run_step_part_id,e])),i=new Map(n.map(e=>[e.updated_run_step_part_state.run_part_id,e]));return hI(e,e=>e.map(e=>{let t=r.get(e.id)??i.get(e.part_id);return t?mI(e,t):e}))},bI=(e,t)=>{if(!e)return e;if(Array.isArray(e.pages)){let n=e.pages;if(n.some(e=>Array.isArray(e?.items)&&e.items.some(e=>e.id===t.id)))return hI(e,e=>e.map(e=>e.id===t.id?t:e));if(n.length>0){let r=n.length-1;return{...e,pages:n.map((e,n)=>n!==r||!e||!Array.isArray(e.items)?e:{...e,items:[...e.items,t]})}}return e}if(Array.isArray(e.items)){let n=e.items,r=n.some(e=>e.id===t.id);return{...e,items:r?n.map(e=>e.id===t.id?t:e):[...n,t]}}return e},xI=async(e,t)=>{if(t.length===0)return;let n=Array.from(new Set(t.map(e=>e.part_id))).map(e=>({id:e}));if(n.length===0)return;let r=await Ne({runPart:n}),i=new Map(r.items.map(e=>[e.id,e]));i.size!==0&&e.setQueriesData({queryKey:[`runStepParts`]},e=>_I(e,i))},SI=(e,t)=>{e.setQueriesData({queryKey:[`runStepParts`]},e=>gI(e,t)),xI(e,[t.runStepPart]).catch(e=>{console.error(`Failed to refresh run step part cache from run part.`,e)})},CI=(e,t)=>{SI(e,t)},wI=(e,t,n)=>{if(`latestActions`in n){e.setQueriesData({predicate:e=>Array.isArray(e.queryKey)&&e.queryKey[0]===`runStepParts`&&(e.queryKey.length===1||e.queryKey[1]===t.id)},e=>yI(e,n.latestActions)),xI(e,vI(n.latestActions).map(e=>({id:e.updated_run_step_part_state.run_step_part_id,part_id:e.updated_run_step_part_state.run_part_id}))).catch(e=>{console.error(`Failed to refresh run step part cache from run parts.`,e)});return}SI(e,n)},TI=(e,t,n)=>{e.setQueriesData({queryKey:[`runStepParts`]},e=>bI(e,n))};function EI(e){return!0}var DI=e=>!!e.closest(`button, a, input, textarea, select, option, label`),OI=({runPart:e,partIsSelected:t,setPartAsSelected:n,runStepParts:r,canInit:i,runStep:a,dropdown:o})=>{let[s,c]=(0,d.useState)(),l=(0,m.useQueryClient)();(0,d.useEffect)(()=>{c(r.find(t=>t.part_id===e.id))},[r,e.id]);let u=t=>{if(!n)return;let r=t.target;if(DI(r))return;let i=s?s.part_id:e.id;i!==void 0&&n(i)},h=()=>{i||f.default.post(`/create/run/step/part`,{run_part_id:e.id,run_step_id:a.id}).then(e=>{let t={...e.data};c(t),TI(l,a,t)})},g=async({runStepPart:e,runStepPartAction:t})=>{let n=await Pe({runStepPart:e,runStepPartAction:t});c(e=>{if(!e)return e;let{status:t,processed:r,failed:i,started:a,available_actions:o}=n.updated_run_step_part_state;return{...e,status:t,processed:r,failed:i,started:a,available_actions:o}}),wI(l,a,{runStepPart:e,latestAction:n})};return s?(0,p.jsxs)(`tr`,{onClick:u,style:n?{cursor:`pointer`}:void 0,children:[(0,p.jsx)(`td`,{children:n&&EI(a)&&(0,p.jsx)(`input`,{type:`checkbox`,id:`part-select-${s.part_id}`,name:`tomato`,className:`form-check-input`,checked:t,onChange:()=>n?.(s.part_id)})}),(0,p.jsx)(`td`,{children:e.scanner_label}),(0,p.jsx)(`td`,{children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-1`,children:[(0,p.jsx)(`span`,{className:`badge ${s.status.class??``}`.trim(),children:s.status.key}),(0,p.jsx)(`small`,{className:`text-muted`,children:s.status.text})]})}),EI(a)&&(0,p.jsx)(`td`,{children:o?(0,p.jsx)(dI,{runStepPart:s,setRunStepPartAction:g,createRunStepPart:h}):(0,p.jsx)(pI,{runStepPart:s,setRunStepPartAction:g})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(uI,{runStepPart:s,setRunStepPart:c})})]}):null},kI=(0,d.createContext)({lastlyReadedKeys:``,addCallbackFn:()=>{},removeCallbackFn:()=>{},addReadingCallbackFn:()=>{},removeReadingCallbackFn:()=>{}}),AI=()=>{let e=(0,d.useContext)(kI);if(e===void 0)throw Error(`useScannerContext must be used within a ScannerProvider`);return e},jI=function(e){return e[e.SELECT=0]=`SELECT`,e[e.PERFORM_ACTION=1]=`PERFORM_ACTION`,e}({});function MI(e){return e.startsWith(`_qr`)?jI.PERFORM_ACTION:jI.SELECT}function NI({parts:e}){let[t,n]=(0,d.useState)(new Map),r=(0,d.useCallback)(e=>{n(t=>{let n=new Map(t);return n.set(e,!(t.get(e)??!1)),n})},[]),{lastlyReadedKeys:i,addCallbackFn:a,removeCallbackFn:o}=AI(),s=(0,d.useId)(),c=(0,d.useRef)(new Set),l=(0,d.useCallback)(t=>{if(MI(t)!=jI.SELECT)return;let n=t.replace(/_/g,`-`).toUpperCase();if(!n)return;if(e.length==0){if(c.current.size>=15){let e=c.current.values().next().value;e!==void 0&&c.current.delete(e)}c.current.add(n);return}let i=e.find(e=>n.includes(e.scanner_label.toUpperCase()));i&&r(i.id)},[e,r]);return(0,d.useEffect)(()=>(o(jI.SELECT,s),l(i),a(jI.SELECT,s,l),()=>{o(jI.SELECT,s)}),[e]),(0,d.useEffect)(()=>{let r=new Map;for(let n of e){let e=n.id;r.set(e,t.get(e)??!1)}r.size!==t.size&&n(()=>r),e.length>0&&(c.current.forEach(e=>{l(e)}),c.current.clear())},[e,t,r]),{selectedParts:t,setPartAsSelected:r,setPartsSelection:(0,d.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return e.forEach(e=>{r.set(e,t)}),r})},[]),selectAllParts:(0,d.useCallback)(()=>{n(e=>new Map([...e.keys()].map(e=>[e,!0])))},[]),selectNoneParts:(0,d.useCallback)(()=>{n(e=>new Map([...e.keys()].map(e=>[e,!1])))},[]),hasSelectedParts:Array.from(t.values()).some(e=>e)}}var PI=null;function FI(e){if(!PI){console.warn(`notification() called before NotificationProvider is mounted`);return}PI(e)}function II({children:e}){let[t,n]=(0,d.useState)([]),r=(0,d.useRef)(0),i=(0,d.useCallback)(e=>{let t=++r.current;n(n=>[...n,{...e,id:t}])},[]);(0,d.useEffect)(()=>(PI=i,()=>{PI=null}),[i]);let a=(0,d.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,p.jsxs)(p.Fragment,{children:[e,(0,p.jsx)(Rl,{containerPosition:`fixed`,position:`top-end`,children:t.map(({id:e,notificationHeader:t,notificationBody:n,notificationType:r})=>(0,p.jsxs)(Il,{show:!0,delay:3e3+(r==`danger`?150:0),autohide:!0,bg:r,onClose:()=>a(e),className:`m-5`,children:[(0,p.jsx)(Il.Header,{children:(0,p.jsx)(`span`,{className:`me-auto`,children:t})}),(0,p.jsx)(Il.Body,{children:n})]},e))})]})}var LI=e=>`step_id`in e&&`part_id`in e;function RI({runStep:e,parts:t,selectedParts:n,getRunPart:r,getRunStepPart:i,actionsFromScanner:a=!0}){let o=(0,m.useQueryClient)(),{addCallbackFn:s,removeCallbackFn:c}=AI(),l=(0,d.useId)(),u=(0,d.useCallback)(()=>t.length===0?[]:LI(t[0])?t.filter(e=>{let t=r?r(e):e.part_id;return n.get(t)}):t.filter(e=>n.get(e.id)).map(e=>i?i(e):void 0).filter(e=>e!==void 0),[t,n,r,i]),f=(0,d.useCallback)(t=>{let n=u();if(n.length===0)return;let r=n.filter(e=>e.available_actions.some(({id:e})=>e===t));if(r.length!==0){if(r.length===1){let e=r[0];Pe({runStepPart:e,runStepPartAction:t}).then(t=>{CI(o,{runStepPart:e,latestAction:t})});return}Fe({runStepPartActions:r.map(e=>({runStepPart:e,runStepPartAction:t}))}).then(t=>{wI(o,e,{latestActions:t})})}},[u,o,e]),p=(0,d.useCallback)(e=>{if(!e||!zI(e))return;let t=Re(e.split(`/`)[1]);if(!t){FI({notificationHeader:`Part scanner`,notificationBody:`Non valid action found in the scanned text`,notificationType:`danger`});return}FI({notificationHeader:`Part scanner`,notificationBody:`Performing action ${Le(t)} on selected parts`,notificationType:`success`}),f(t)},[f]);return(0,d.useEffect)(()=>{if(a)return c(jI.PERFORM_ACTION,l),s(jI.PERFORM_ACTION,l,p),()=>{c(jI.PERFORM_ACTION,l)}},[a,p,s,c,l]),{performActionToSelectedParts:f,getAvailableActionsForSelection:(0,d.useCallback)(()=>{let e=new Map;for(let t of u())for(let{id:n,name:r}of t.available_actions)e.has(n)||e.set(n,r);return Array.from(e.entries()).map(([e,t])=>({id:e,name:t}))},[u])}}function zI(e){return RegExp(`^_qr/.+`).test(e)}var BI=({onSelectAll:e,onSelectNone:t,hasSelectedParts:n,actionsDropdown:r,traySelections:i,onToggleTray:a})=>{let o=(i??[]).length>0;return(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`div`,{className:`btn-group btn-group-sm`,role:`group`,"aria-label":`Part selection controls`,children:[(0,p.jsx)(`button`,{className:`part-check-all btn btn-outline-secondary`,onClick:e,children:`All`}),(0,p.jsx)(`button`,{className:`part-check-none btn btn-outline-secondary`,onClick:t,children:`None`})]}),o&&(0,p.jsx)(`div`,{className:`btn-group btn-group-sm`,role:`group`,"aria-label":`Tray selection controls`,children:i?.map(e=>{let t=e.allSelected;return(0,p.jsx)(`button`,{type:`button`,className:`btn ${t?`btn-secondary`:`btn-outline-secondary`}`,"aria-pressed":t,onClick:()=>a?.(e.partIds,!t),children:e.label},e.id)})}),n&&r]})},VI=({availableActions:e,onActionSelected:t})=>e.length===0?null:(0,p.jsx)(p.Fragment,{children:e.map(({id:e,name:n})=>(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm ${fI[e]}`,onClick:()=>t(e),children:n},e))}),HI=({run:e,runStep:t})=>{let n=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Te({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Ne({step:t})}]}),[r,i]=n,a=n.some(e=>e.isLoading),o=n.some(e=>e.isError),s=(0,d.useMemo)(()=>r.data?.items??[],[r.data]),c=(0,d.useMemo)(()=>i.data?.items??[],[i.data]),l=(0,d.useMemo)(()=>s.filter(e=>e.part_level===t.part_level),[s,t.part_level]),[u,f]=(0,d.useState)(!1),{selectedParts:h,selectAllParts:g}=NI({parts:l});GI({runStepParts:c,runParts:l});let _=(0,d.useMemo)(()=>l.filter(e=>h.get(e.id)&&(u||!UI(c,e))),[l,c,h,u]);return o?(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run parts.`}):(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsxs)(kl,{size:`sm`,striped:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2,children:`Part`}),(0,p.jsx)(`th`,{children:`Status`}),(0,p.jsx)(`th`,{children:`Actions`}),(0,p.jsx)(`th`,{children:`Comment`})]})}),(0,p.jsxs)(`tbody`,{children:[a&&Array.from({length:1}).map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{colSpan:2,children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:6})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:4})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:7})})})]},`placeholder-${t}`)),!a&&_.map((e,n)=>(0,p.jsx)(OI,{runStep:t,runPart:e,runStepParts:c,canInit:!1,partIsSelected:h.get(e.id)??!1,dropdown:!1},`${e.parsed_label}${n}`))]})]}),(0,p.jsx)(WI,{runStepParts:c,selectedPartsLength:_.length,totalParts:l.length,onSelectAll:g,toggleShowCompletedParts:()=>{f(!u)}})]})},UI=(e,t)=>{let n=e.find(e=>e.part_id==t.id);return n==null?!1:n.processed},WI=({runStepParts:e,selectedPartsLength:t,totalParts:n,onSelectAll:r,toggleShowCompletedParts:i})=>{let a=(0,d.useMemo)(()=>{let t=0;return e.forEach(e=>e.processed?t++:null),t},[e]);return(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-sm-row flex-wrap gap-2 mt-2`,children:[(0,p.jsxs)(`span`,{className:`badge rounded-pill bg-warning-subtle text-warning-emphasis border border-warning-subtle px-3 py-2 fw-semibold`,role:`button`,title:`Show all the parts`,onClick:r,style:{cursor:`pointer`},children:[`This step has `,(0,d.useMemo)(()=>n-t,[n,t]),` more parts`]}),(0,p.jsxs)(`span`,{className:`badge rounded-pill bg-info-subtle text-info-emphasis border border-info-subtle px-3 py-2 fw-semibold`,children:[`This step has `,t,` scanned parts`]}),(0,p.jsxs)(`span`,{title:`Show all the parts`,style:{cursor:`pointer`},onClick:i,className:`badge rounded-pill bg-success-subtle text-success-emphasis border border-success-subtle px-3 py-2 fw-semibold`,children:[`This step has `,a,` finished parts`]})]})};function GI({runStepParts:e,runParts:t}){let{addCallbackFn:n,removeCallbackFn:r}=AI(),i=(0,d.useId)(),a=(0,d.useCallback)(n=>{let r=n.replace(/_/g,`-`).toUpperCase();if(!r)return;let i=t.find(e=>r.includes(e.scanner_label.toUpperCase()));if(i){if(UI(e,i)){FI({notificationHeader:`Run parts table`,notificationBody:`Part ${i.parsed_label??i.scanner_label} is already completed`,notificationType:`danger`});return}FI({notificationHeader:`Part scanner`,notificationBody:`Found part: ${i.scanner_label}`,notificationType:`success`})}},[t,e]);(0,d.useEffect)(()=>(r(jI.SELECT,i),n(jI.SELECT,i,a),()=>{r(jI.SELECT,i)}),[t,e])}var KI=!1,qI=({run:e,runStep:t})=>{let n=(0,m.useQueryClient)(),r=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Te({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Ne({step:t})}]}),[i,a]=r,o=r.some(e=>e.isLoading),s=r.some(e=>e.isError),c=(0,d.useMemo)(()=>i.data?.items??[],[i.data]),l=(0,d.useMemo)(()=>a.data?.items??[],[a.data]),{selectedParts:u,setPartAsSelected:f,setPartsSelection:h,selectAllParts:g,selectNoneParts:_,hasSelectedParts:v}=NI({parts:c});GI({runStepParts:l,runParts:c}),(0,d.useEffect)(()=>{let e=Array.from(u.entries()).filter(([,e])=>e).map(([e])=>e);n.setQueryData([`runPartSelection`,t.id],e)},[n,t.id,u]);let{performActionToSelectedParts:y,getAvailableActionsForSelection:b}=RI({runStep:t,parts:c,selectedParts:u,getRunPart:void 0,getRunStepPart:e=>l.find(t=>t.part_id===e.id)}),x=(0,d.useMemo)(()=>b(),[b]),S=(0,d.useMemo)(()=>{let t=new Map;if(l.forEach(e=>{let n=c.find(t=>t.id===e.part_id)?.tray;if(!n)return;let r=t.get(n.id)??{id:n.id,label:n.name??n.label??`Tray ${n.id}`,partIds:[]};r.partIds.push(e.part_id),t.set(n.id,r)}),t.size===0)return[];let n=[...e.run_trays??[]].sort((e,t)=>e.sequence-t.sequence);return(n.length>0?n.filter(e=>t.has(e.id)).map(e=>{let n=t.get(e.id);return{...n,label:e.name??e.label??n.label}}):Array.from(t.values()).sort((e,t)=>e.label.localeCompare(t.label))).map(e=>({...e,allSelected:e.partIds.every(e=>u.get(e))}))},[e.run_trays,u,l]);if(o)return(0,p.jsx)(vt,{message:`Loading run parts`});if(s)return(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run parts.`});if(c.length===0)return(0,p.jsx)(vr,{variant:`warning`,children:`No parts found for this run step.`});if(l.length===0)return(0,p.jsx)(vr,{variant:`warning`,children:`No step parts found for this run step.`});let C=EI(t);return(0,p.jsx)(d.Fragment,{children:c&&c.length>0&&(0,p.jsxs)(p.Fragment,{children:[!C&&(0,p.jsxs)(vr,{variant:`warning`,className:`py-2 mb-2`,children:[(0,p.jsx)(`strong`,{children:`Step locked.`}),` Finish the previous step before processing these parts.`]}),(0,p.jsxs)(kl,{size:`sm`,striped:!0,hover:!0,className:C?void 0:`text-muted`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2,children:`Part`}),(0,p.jsx)(`th`,{children:`Status`}),C&&(0,p.jsx)(`th`,{children:`Actions`}),(0,p.jsx)(`th`,{children:`Comment`})]})}),(0,p.jsx)(`tbody`,{children:c.map((n,r)=>{let i=u.get(n.id)??!1;return(0,p.jsx)(OI,{runStep:t,runPart:n,runStepParts:l,canInit:e.run_type===ut.PRODUCTION,partIsSelected:i,setPartAsSelected:C?f:void 0,dropdown:KI},`key-${r}-${n.id}`)})})]}),C&&(0,p.jsx)(BI,{onSelectAll:g,onSelectNone:_,hasSelectedParts:v,traySelections:S,onToggleTray:(e,t)=>h(e,t),actionsDropdown:(0,p.jsx)(VI,{availableActions:x,onActionSelected:y})})]})})};function JI({run:e,step:t,refetchFn:n=()=>null}){let{run:r}=(0,d.useContext)(ZF),{showOnlyEmphasizedParameters:i}=(0,d.useContext)(aI),a=e??r;return a?(0,p.jsx)(Pr,{className:`p-4 my-3`,children:(0,p.jsx)(Pr.Body,{children:(0,p.jsxs)(Dl,{children:[(0,p.jsxs)(Ur,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Experimental split`}),(0,p.jsx)(qI,{run:a,runStep:t}),t.has_remark&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{children:`Remark`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.remark}})]})]}),(0,p.jsxs)(Ur,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Parameters`}),(0,p.jsx)(sI,{runStep:t,showOnlyEmphasizedParameters:i,refetchFn:()=>{n([JSON.stringify(t),`parameters`])}}),(0,p.jsx)(`h4`,{children:`Files`}),(0,p.jsx)(lI,{runStep:t,refetchFn:()=>{n([`runSteps`])}})]})]})})}):null}var YI=({runPart:e,statusClass:t,withTrayCell:n=!1,allowCreate:r=!1,hasStepPart:i=!1,isSelected:a=!1,runStep:o})=>{let s=(0,m.useQueryClient)(),c=!i||!e?null:r&&!i?(0,p.jsxs)(B,{size:`sm`,variant:`outline-secondary`,className:`tray-grid__badge tray-grid__badge--init`,onClick:()=>{!e||!o||f.default.post(`/create/run/step/part`,{run_part_id:e.id,run_step_id:o.id}).then(e=>{TI(s,o,{...e.data})})},children:[`Init `,e.scanner_label]}):(0,p.jsx)(`span`,{className:`tray-grid__badge ${t??`step-part-inactive`}${a?` step-part-selected`:``}`,children:e.scanner_label});return n?(0,p.jsx)(`div`,{className:`tray-grid__cell${e?``:` tray-grid__cell--empty`}`,children:c}):c},XI=({step:e,parts:t,stepParts:n,run:r})=>{let i=t.filter(t=>t.part_level===e.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),a=new Map(n.filter(t=>t.step_id===e.id).map(e=>[e.part_id,e])),o=[...r.run_trays??[]].sort((e,t)=>e.sequence-t.sequence),s=i.reduce((e,t)=>{if(!t.tray)return e;let n=e.get(t.tray.id)??[];return n.push(t),e.set(t.tray.id,n),e},new Map),c=r.run_type===ut.PRODUCTION,l=e.part_level>0,{data:u=[]}=(0,m.useQuery)({queryKey:[`runPartSelection`,e.id],queryFn:async()=>[],initialData:[],enabled:!1}),d=e=>{let t=a.get(e.id);return t?t.status.class:`step-part-inactive`},f=(t,n)=>(0,p.jsx)(`div`,{className:`tray-grid__cell${t.length?``:` tray-grid__cell--empty`}${t.length>1?` tray-grid__cell--multi`:``}`,children:t.map(t=>(0,p.jsx)(YI,{runPart:t,statusClass:d(t),allowCreate:c,hasStepPart:a.has(t.id),isSelected:u.includes(t.id),runStep:e},t.id))},n);if(o.length===0){let t=Math.max(i.length,i.reduce((e,t)=>Math.max(e,t.left??0),0)),n=Math.max(1,Math.ceil(t/12)),r={"--tray-columns":12,"--tray-rows":n},o=Array.from({length:n*12},()=>[]),s=[];return i.forEach(e=>{let t=e.left,n=t>=1&&t<=o.length?t-1:null;if(n!==null){if(l){o[n].push(e);return}if(!o[n].length){o[n].push(e);return}s.push(e)}else s.push(e)}),s.forEach(e=>{if(l){let t=o.reduce((e,t,n)=>e===-1||t.length<o[e].length?n:e,-1);t!==-1&&o[t].push(e);return}let t=o.findIndex(e=>e.length===0);t!==-1&&o[t].push(e)}),(0,p.jsx)(`div`,{className:`tray-grid`,"data-orientation":`ltr`,style:r,children:o.map((t,n)=>{if(l)return f(t,`slot-no-tray-${n}`);let r=t[0]??null;return(0,p.jsx)(YI,{runPart:r,statusClass:r?d(r):void 0,withTrayCell:!0,allowCreate:c,hasStepPart:r?a.has(r.id):!1,isSelected:r?u.includes(r.id):!1,runStep:e},`slot-no-tray-${n}`)})})}let h=(e,t,n)=>!t||!n||t<1||n<1||t>e.rows||n>e.columns?null:e.orientation===`ttb`?(n-1)*e.rows+(t-1):(t-1)*e.columns+(n-1);return(0,p.jsx)(`div`,{className:`tray-grid-group`,children:o.map(t=>{let n=t.tray_type;if(!n?.rows||!n?.columns){let n=s.get(t.id)??[];return(0,p.jsxs)(`div`,{className:`tray-grid-wrapper`,children:[(0,p.jsx)(`div`,{className:`tray-grid__label`,children:t.name??t.label}),(0,p.jsx)(`div`,{className:`d-flex flex-wrap gap-2`,children:n.map(t=>(0,p.jsx)(YI,{runPart:t,statusClass:d(t),allowCreate:c,hasStepPart:a.has(t.id),isSelected:u.includes(t.id),runStep:e},t.id))})]},`tray-${t.id}`)}let r=n.rows*n.columns,i=n.orientation===`ttb`?`ttb`:`ltr`,o={"--tray-columns":n.columns,"--tray-rows":n.rows},m=Array.from({length:r},()=>[]);return(s.get(t.id)??[]).forEach(e=>{let t=h(n,e.tray_row,e.tray_column);if(t!==null){if(l){m[t].push(e);return}m[t].length||m[t].push(e)}}),(0,p.jsxs)(`div`,{className:`tray-grid-wrapper`,children:[(0,p.jsx)(`div`,{className:`tray-grid__label`,children:t.name??t.label}),(0,p.jsx)(`div`,{className:`tray-grid`,"data-orientation":i,style:o,children:m.map((n,r)=>{if(l)return f(n,`slot-${t.id}-${r}`);let i=n[0]??null;return(0,p.jsx)(YI,{runPart:i,statusClass:i?d(i):void 0,withTrayCell:!0,allowCreate:c,hasStepPart:i?a.has(i.id):!1,isSelected:i?u.includes(i.id):!1,runStep:e},`slot-${t.id}-${r}`)})})]},`tray-${t.id}`)})})};function ZI({run:e,step:t,parts:n,monitoredBy:r,refetchFn:i}){let{environment:a}=(0,g.useParams)(),[o,s]=(0,d.useState)(!1),c=()=>{s(!o)},[l,u]=(0,d.useState)(t.process_module.module);(0,d.useEffect)(()=>{u(t.process_module.module)},[t.process_module.module]);let[f]=(0,m.useQueries)({queries:[{queryKey:[`runStepParts`,t.id],queryFn:()=>Ne({step:t}),placeholderData:m.keepPreviousData}]}),h=(0,d.useMemo)(()=>f.data?.items??[],[f.data?.items]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`i`,{className:`fa ms-2 `+(o?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:c})}),(0,p.jsx)(`td`,{className:l.latest_module_status&&l.latest_module_status.status.is_down_status?`table-danger`:``,children:f.isLoading?(0,p.jsx)(El,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(El,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(XI,{step:t,parts:n,stepParts:h,run:e})}),(0,p.jsxs)(`td`,{children:[r&&(0,p.jsx)(pl,{placement:`top`,overlay:(0,p.jsx)(sl,{id:`tooltip-${r.id}`,children:`Monitored by step: ${r.step.number}`}),children:(0,p.jsx)(`i`,{className:`fa fa-search me-2`})}),t.amount_of_files>0&&(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-paperclip`}),` `,t.amount_of_files]}),t.has_remark&&(0,p.jsx)(`i`,{className:`fa fa-comment-o text-warning me-3`}),t.is_finished&&(0,p.jsx)(`i`,{className:`fa fa-check text-success me-3`})]}),(0,p.jsxs)(`td`,{className:t.has_step_group?`ps-4`:``,children:[t.number,` - `,(0,p.jsx)(g.Link,{to:`/${a}/operator/run/step/${t.id}`,children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.name}})}),` `]}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(g.Link,{to:`/${a}/operator/equipment/${l.equipment.id}`,className:`me-2`,children:l.equipment.name}),(0,p.jsx)(Dd,{module:l,refetchFn:()=>{i([`runSteps`])}})]})]}),o&&(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:n.length+6,children:(0,p.jsx)(JI,{step:t,refetchFn:i})})})]})}var QI=({requirement:e,result:t,show:n,setShow:r,refetchFn:i,part:a,stepPart:o})=>{let[s,c]=(0,d.useState)({}),[l,u]=(0,d.useState)(!1),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(Object.keys(s).length>0)return;let n={};for(let r of e.targets){let e=``;t!==void 0&&(e=t.values.find(e=>e.logging_parameter.id==r.logging_parameter.id)?.string_value??``),n[r.logging_parameter.id]=e}c(n)},[e]),(0,d.useEffect)(()=>{_(!1),h(null),u(!1)},[n]);let v=async()=>{try{h(null),_(!1),u(!0),await f.default.delete(`/delete/run/measurement/result/${t?.id??0}`),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}},y=async()=>{try{h(null),_(!1),u(!0);let n=Object.entries(s).map(async([e,n])=>{let r=Number.parseInt(e),i={value:n},a=t?.values.find(e=>e.logging_parameter.id===r)?.id;await f.default.patch(`/update/run/measurement/result/value/${a??0}`,i)});await Promise.all(n),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}},b=async()=>{let t={measurement:e.measurement.id,values:Object.entries(s).flatMap(e=>({logging_parameter:Number.parseInt(e[0]),value:e[1]}))};o&&(t.step_part=o?.id??0,t.part=a?.id??0,t.step=e.step.id??0);try{h(null),_(!1),u(!0),await f.default.post(`/create/run/measurement/result`,t),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}};return(0,p.jsxs)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:t?(0,p.jsx)(p.Fragment,{children:`Update results`}):(0,p.jsx)(p.Fragment,{children:`Create result`})})}),(0,p.jsxs)(H,{onSubmit:e=>{e.preventDefault(),t?y():b()},children:[(0,p.jsxs)(U.Body,{children:[m&&(0,p.jsx)(vr,{variant:`danger`,children:m}),g&&(0,p.jsx)(vr,{variant:`success`,children:`Results have been updated successfully`}),e.targets.map(e=>(t?.values.find(t=>t.logging_parameter.id===e.logging_parameter.id)?.string_value,(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:e.logging_parameter.name}),(0,p.jsx)(H.Control,{type:`number`,step:`any`,placeholder:`Thickness`,value:s[e.logging_parameter.id]??``,onChange:t=>c(n=>({...n,[e.logging_parameter.id]:t.target.value}))})]},e.id)))]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{variant:`warning`,onClick:()=>r(!1),children:`Close`}),l?(0,p.jsxs)(B,{type:`submit`,variant:`info`,disabled:l,children:[(0,p.jsx)(Ol,{animation:`border`,size:`sm`,className:`me-2`}),` Updating results...`]}):t?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`danger`,disabled:l,onClick:v,children:`Delete result`}),(0,p.jsx)(B,{type:`submit`,variant:`info`,disabled:l,children:`Update result`})]}):(0,p.jsx)(B,{type:`submit`,variant:`info`,disabled:l,children:`Create result`})]})]})]})},$I=(0,d.createContext)({runStep:{},setRunStep:e=>{},reloadRunStep:()=>{},run:{},modalProperties:{},setModalProperties:e=>{}});function eL({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a,editOnly:o=!1}){let{run:s}=(0,d.useContext)($I),[c,l]=(0,d.useState)(r??[]),[u,f]=(0,d.useState)(n??[]),[h,g]=(0,d.useState)(i??[]),_=(0,m.useQueryClient)(),v=(0,m.useQueries)({queries:[{queryKey:[`runParts`,`${s?.id??`unknown`}`],queryFn:async()=>await Te({run:s}),enabled:!r||r.length===0,retry:1},{queryKey:[`runStepParts`,`${t?.run_id??`unknown`}`,`${t?.id??`unknown`}`],queryFn:async()=>await Ne({step:e.requirement_for_step??e.step}),enabled:!n||n.length===0,retry:1},{queryKey:[`requirement`,`measurementResults`,e.measurement.id],queryFn:async()=>await Oe({measurement:e.measurement}),enabled:!i||i.length===0,retry:1}]}),y=()=>{_.refetchQueries({queryKey:[`requirement`,`measurementResults`,e.measurement.id]})},[b,x,S]=v;(0,d.useEffect)(()=>{r&&r.length>0?l(r):b?.data&&l(b.data.items)},[r,b?.data]),(0,d.useEffect)(()=>{n&&n.length>0?f(n):x?.data&&f(x.data.items)},[n,x?.data]),(0,d.useEffect)(()=>{i&&i.length>0?g(i):S?.data&&g(S.data.items)},[i,S?.data]);let[C,w]=(0,d.useState)(null),T=r&&r.length>0?r:c,E=((n&&n.length>0?n:u)??[]).filter(e=>(T??[]).find(n=>n.id===e.part_id&&n.part_level===t.part_level)!==void 0),D=!r||r.length===0,O=!n||n.length===0,k=!i||i.length===0,A=D&&b?.isLoading||O&&x?.isLoading||k&&S?.isLoading,j=D&&b?.isError||O&&x?.isError||k&&S?.isError;if(A&&E.length===0)return(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(Ol,{animation:`border`,size:`sm`}),` `,(0,p.jsx)(`span`,{children:`Loading data…`})]});if(j&&E.length===0)return(0,p.jsxs)(vr,{variant:`danger`,className:`d-flex justify-content-between align-items-center`,children:[(0,p.jsx)(`div`,{children:`Failed to load required data. Please try again.`}),(0,p.jsxs)(`div`,{children:[D&&b?.isError&&(0,p.jsx)(B,{size:`sm`,variant:`outline-light`,onClick:()=>b.refetch(),children:`Retry parts`}),` `,O&&x?.isError&&(0,p.jsx)(B,{size:`sm`,variant:`outline-light`,onClick:()=>x.refetch(),children:`Retry step parts`}),` `,k&&S?.isError&&(0,p.jsx)(B,{size:`sm`,variant:`outline-light`,onClick:()=>S.refetch(),children:`Retry results`})]})]});let M=t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return``;let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id===t.logging_parameter.id);return r?(r.inclusive?!(r.min_value<=n&&r.max_value>=n):!(r.min_value<n&&r.max_value>n))?`table-danger`:`table-success`:``};return(0,p.jsx)(p.Fragment,{children:E.length>0?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(kl,{size:`sm`,striped:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{style:{width:`26%`},children:`Part`}),(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`}),!o&&(0,p.jsx)(`th`,{style:{width:`1%`}})]})}),(0,p.jsx)(`tbody`,{children:E.map(t=>{let n=h.find(e=>e.values.some(e=>e.step_part_id===t.id)),r=(n?.values??[]).filter(e=>e.step_part_id===t.id),i=e.targets.length;return e.targets.map((e,a)=>{let s=r.find(t=>t.logging_parameter.id===e.logging_parameter.id)??null;return(0,p.jsxs)(`tr`,{className:s?M(s):``,children:[a===0&&(0,p.jsxs)(`td`,{rowSpan:i,children:[T.find(e=>e.id===t.part_id)?.short_label??t.part_id,` `,(0,p.jsxs)(`small`,{className:`text-muted`,children:[`(`,t.id,`)`]})]}),(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{children:s?s.string_value:(0,p.jsx)(`span`,{className:`text-muted`,children:`not set`})}),(0,p.jsx)(`td`,{children:e.logging_parameter.unit?.abbr??``}),!o&&a===0&&(0,p.jsx)(`td`,{rowSpan:i,className:`align-middle text-nowrap`,children:(0,p.jsxs)(B,{size:`sm`,variant:n?`outline-primary`:`outline-success`,onClick:()=>w(String(t.id)),children:[(0,p.jsx)(`i`,{className:`fa fa-edit`}),` `,n?`Edit values`:`Add values`]})})]},`${t.id}:${e.logging_parameter.id}`)})})})]}),!o&&E.map(t=>{let n=h.find(e=>e.values.some(e=>e.step_part_id===t.id));return(0,p.jsx)(QI,{requirement:e,...n?{result:n}:{part:T.find(e=>e.id===t.part_id),stepPart:t},show:C===String(t.id),setShow:e=>{e||w(null)},refetchFn:a??y},`modal:${t.id}`)})]}):(0,p.jsx)(vr,{variant:`secondary`,className:`mb-0`,children:`No selected parts`})})}function tL({requirement:e,measurementResults:t,refetchFn:n,editOnly:r=!1}){let[i,a]=(0,d.useState)(t??[]),o=(0,m.useQueryClient)(),s=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,e.measurement.id],queryFn:async()=>await Oe({measurement:e.measurement}),enabled:!t||t.length===0,retry:1}]}),c=()=>{o.refetchQueries({queryKey:[`requirement`,`measurementResults`,e.measurement.id]})},[l]=s;(0,d.useEffect)(()=>{t&&t.length>0?a(t.filter(e=>e.values.some(e=>!e.step_part_id))):l?.data&&a(l.data.items.filter(e=>e.values.some(e=>!e.step_part_id)))},[t,l?.data]);let[u,f]=(0,d.useState)(null),[h,g]=(0,d.useState)(!1),_=s.some(e=>e.isLoading);if(s.some(e=>e.isError))return s.filter(e=>e.isError).forEach((e,t)=>{console.error(`StepDashboard query error`,{index:t,error:e.error})}),(0,p.jsx)(p.Fragment,{children:`Error fetching data`});if(_)return(0,p.jsx)(`div`,{children:`Loading...`});let v=t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return``;let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id===t.logging_parameter.id);return r&&(r.inclusive?!(r.min_value<=n&&r.max_value>=n):!(r.min_value<n&&r.max_value>n))?`table-danger text-light`:``};return(0,p.jsxs)(`div`,{className:`d-flex flex-column gap-4`,children:[i.map(t=>(0,p.jsxs)(`div`,{className:`border rounded p-3 shadow-sm`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:[(0,p.jsxs)(`h6`,{className:`mb-0`,children:[`Result `,(0,p.jsxs)(`small`,{className:`text-muted`,children:[`#`,t.id]})]}),!r&&(0,p.jsxs)(B,{size:`sm`,variant:`outline-primary`,onClick:()=>f(t.id),children:[(0,p.jsx)(`i`,{className:`fa fa-edit`}),` Update value`]})]}),(0,p.jsxs)(`table`,{className:`table table-striped table-sm mb-0`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:t.values.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{className:e?v(e):``,children:e.string_value}),(0,p.jsx)(`td`,{children:e.logging_parameter.unit?.abbr??``})]},`value:${e.id}`))})]}),(0,p.jsx)(QI,{requirement:e,result:t,show:u===t.id,setShow:e=>{e||f(null)},refetchFn:n??c})]},t.id)),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(B,{size:`sm`,onClick:()=>g(!h),children:[(0,p.jsx)(`i`,{className:`fa fa-plus`}),` Add results`]})}),(0,p.jsx)(QI,{requirement:e,show:h,setShow:e=>{e||g(!1)},refetchFn:n??c})]})}function nL({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}){let{environment:o}=(0,g.useParams)();return(0,p.jsx)(Pr,{className:`p-4 my-3`,children:(0,p.jsx)(Pr.Body,{children:(0,p.jsxs)(Dl,{children:[(0,p.jsxs)(Ur,{md:`7`,children:[(0,p.jsx)(`h4`,{children:`Measurements by part`}),(0,p.jsx)(eL,{requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(tL,{requirement:e,measurementResults:i,refetchFn:a})]}),(0,p.jsxs)(Ur,{md:`5`,children:[(0,p.jsx)(`h4`,{children:`Monitored Step`}),(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${e.requirement_for_step?.id??e.step.id}`,children:(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-search`}),` `,e.requirement_for_step?.name??e.step.name]})}),(0,p.jsx)(`h4`,{children:`Definition`}),(0,p.jsx)(`span`,{children:e.definition}),(0,p.jsx)(`h4`,{children:`Targets`}),(0,p.jsxs)(kl,{size:`sm`,striped:!1,bordered:!1,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`parameter`}),(0,p.jsx)(`th`,{children:`min value`}),(0,p.jsx)(`th`,{children:`max value`}),(0,p.jsx)(`th`,{children:`inclusive`})]})}),(0,p.jsx)(`tbody`,{children:e.targets.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{children:e.min_value}),(0,p.jsx)(`td`,{children:e.max_value}),(0,p.jsx)(`td`,{children:e.inclusive?`yes`:`no`})]},e.id))})]}),(0,p.jsx)(`h4`,{children:`Files`}),(0,p.jsx)(lI,{runStep:t,refetchFn:()=>{a([`requirements`])}})]})]})})})}var rL=({requirement:e,step:t,measurementResults:n,parts:r,stepParts:i})=>{let a=r.filter(e=>e.part_level===t.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),o=a.reduce((e,t)=>{let n=t.root_id??t.id;return e[n]||(e[n]=[]),e[n].push(t),e},{}),s=t=>{let r=i.find(e=>e.part_id===t.id);if(!r)return`badge-inactive`;let a=n.find(e=>e.values.some(e=>e.step_part_id===r.id));if(!a)return``;for(let t of a.values){let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id==t.logging_parameter.id);if(r){if(r.inclusive){if(!(r.min_value<=n&&r.max_value>=n))return`badge-failed`}else if(!(r.min_value<n&&r.max_value>n))return`badge-failed`}}return`badge-processed`},c=e=>(0,p.jsx)(pl,{placement:`top`,overlay:(0,p.jsx)(sl,{id:`tooltip-${e.id}`,children:`Level: ${e.part_level}${e.parent?`, Parent: ${e.parent.short_label}`:``}`}),children:(0,p.jsx)(`span`,{className:`badge badge-level-${e.part_level} ${s(e)} me-1`,children:e.short_label},e.id)},e.id);return(0,p.jsxs)(`div`,{children:[a[0].parent?Object.entries(o).map(([e,t])=>(0,p.jsxs)(`div`,{className:`mb-2`,children:[(0,p.jsxs)(`label`,{className:`text-muted me-1`,children:[t[0].parent?.short_label,`:`]}),` `,t.map(e=>c(e))]},e)):a.map(e=>c(e)),(0,p.jsx)(`label`,{children:`(measurements)`})]})};function iL({requirement:e,step:t,parts:n,refetchFn:r}){let{environment:i}=(0,g.useParams)(),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(t.process_module.module);(0,d.useEffect)(()=>{c(t.process_module.module)},[t.process_module.module]);let l=()=>{o(!a)},u=(0,m.useQueryClient)(),f=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)],queryFn:()=>Oe({measurement:e.measurement})},{queryKey:[`runStepParts`,e.requirement_for_step?.id??e.step.id],queryFn:()=>Ne({step:e.requirement_for_step??e.step}),placeholderData:m.keepPreviousData}]}),h=e=>{e[0]===`requirement`&&u.refetchQueries({queryKey:e}),r(e)},[_,v]=f,y=f.some(e=>e.isLoading),b=(0,d.useMemo)(()=>v.data?.items??[],[v.data?.items]),x=(0,d.useMemo)(()=>_.data?.items??[],[_.data?.items]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{className:(t=>{if(t.length==0)return y?``:`table-info`;let n=!1;for(let r of t)if(r.values.some(t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return!1;let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id==t.logging_parameter.id);return r?r.inclusive?!(r.min_value<=n&&r.max_value>=n):!(r.min_value<n&&r.max_value>n):!1})){n=!0;break}return n?`table-danger`:``})(x),children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`i`,{className:`fa ms-2 `+(a?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:l})}),(0,p.jsx)(`td`,{children:y?(0,p.jsx)(El,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(El,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(rL,{requirement:e,step:t,measurementResults:x,parts:n,stepParts:b})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(yr,{bg:`info`,children:`requirement`}),t.amount_of_files>0&&(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-paperclip`}),` `,t.amount_of_files]}),t.has_remark&&(0,p.jsx)(`i`,{className:`fa fa-comment-o text-warning`})]}),(0,p.jsx)(`td`,{className:t.has_step_group?`ps-4`:``,children:(0,p.jsxs)(`div`,{children:[`(`,t.number,`)`,` `,(0,p.jsx)(g.Link,{to:`/${i}/operator/run/step/${t.id}`,children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.name}})}),` `]})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(g.Link,{to:`/${i}/operator/equipment/${s.equipment.id}`,className:`me-2`,children:s.equipment.name}),(0,p.jsx)(Dd,{module:s,refetchFn:()=>{r([`runSteps`])}})]})]}),a&&(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:n.length+5,children:y?`Loading...`:(0,p.jsx)(nL,{requirement:e,step:t,stepParts:b,parts:n,measurementResults:x,refetchFn:h})})})]})}function aL(){let{run:e}=(0,d.useContext)(ZF),{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n}=(0,d.useContext)(aI),[r,i]=(0,d.useState)(1),[a]=(0,d.useState)(25),[o,s]=(0,d.useState)(new Map),c=(0,m.useQueryClient)(),l=(0,m.useQueries)({queries:[{queryKey:[`runSteps`,JSON.stringify(e),r],queryFn:()=>Ee({run:e,page:r,pageSize:a}),placeholderData:m.keepPreviousData},{queryKey:[`runParts`,JSON.stringify(e)],queryFn:()=>Te({run:e})},{queryKey:[`requirements`,JSON.stringify(e)],queryFn:()=>Ce({run:e})}]}),u=t=>{let n=[...t,JSON.stringify(e)];t[0]===`runSteps`&&n.push(r),c.refetchQueries({queryKey:n})},[f,h,g]=l,_=l.some(e=>e.isLoading),v=l.some(e=>e.isError);v&&l.filter(e=>e.isError).forEach((t,n)=>{console.error(`RunStepsElement query error`,{index:n,error:t.error,run:e})});let y=(0,d.useMemo)(()=>f.data?.items??[],[f.data?.items]),b=(0,d.useMemo)(()=>h.data?.items??[],[h.data?.items]),x=(0,d.useMemo)(()=>g.data?.items??[],[g.data?.items]);if((0,d.useEffect)(()=>{s(e=>{let t=new Map(e);return y.forEach(e=>{let n=e.label?.id;n!==void 0&&!t.has(n)&&t.set(n,!0)}),t})},[y]),_)return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center`,children:(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(El,{animation:`glow`,as:`span`,children:(0,p.jsx)(El,{style:{width:`2rem`,height:`1rem`,borderRadius:`0.5rem`}})}),(0,p.jsx)(El,{animation:`glow`,as:`span`,className:`ms-2`,children:(0,p.jsx)(El,{style:{width:`15rem`}})})]})}),(0,p.jsxs)(kl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Parts`}),(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Process`}),(0,p.jsx)(`th`,{children:`Equipment`})]})}),(0,p.jsx)(`tbody`,{children:[1,2].map(e=>(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:5,className:`bg-info`,children:(0,p.jsx)(El,{animation:`glow`,as:`span`,children:(0,p.jsx)(El,{style:{width:`5rem`}})})})}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{animation:`glow`,as:`span`,children:(0,p.jsx)(El,{style:{width:`0.75rem`}})})}),(0,p.jsx)(`td`,{colSpan:2,children:(0,p.jsx)(El,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(El,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{animation:`glow`,as:`span`,children:(0,p.jsx)(El,{style:{width:`10rem`}})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{animation:`glow`,as:`span`,children:(0,p.jsx)(El,{style:{width:`12rem`}})})})]})]},e))})]})]});if(v)return(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run steps.`});let S=new Set,C=y.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||S.has(String(e.step_group.id))?!1:(S.add(String(e.step_group.id)),!0)),w={};for(let e of x)e.requirement_for_step!=null&&(w[String(e.requirement_for_step.id)]=e);let T=e=>(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:5,style:{margin:0},className:`bg-info`,children:(0,p.jsx)(`span`,{children:e.step_group?.label})})}),E=e=>{let t=e.label,n=t?.id;if(!e.is_own_label||!t||n===void 0)return null;let r=e=>{s(t=>{let n=new Map(t);return n.set(e,!n.get(e)),n})};return(0,p.jsx)(`tr`,{style:{cursor:`pointer`},onClick:()=>r(n),children:(0,p.jsx)(`td`,{colSpan:5,style:{margin:0},className:`bg-secondary`,children:(0,p.jsxs)(`span`,{className:`label-toggle`,children:[(0,p.jsx)(`i`,{className:`fa `+(o.get(e.label?.id??-1)?`fa-caret-down`:`fa-caret-right`)}),` `,t.label]})})})};return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center`,children:(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t,className:`form-check-input`,"data-toggle":`toggle`,onChange:()=>n(!t)}),(0,p.jsx)(`label`,{className:`ms-2`,children:`Show only emphasized parameters`})]})}),(0,p.jsxs)(kl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Parts`}),(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Process`}),(0,p.jsx)(`th`,{children:`Equipment`})]})}),(0,p.jsx)(`tbody`,{children:y.map(t=>{let n=`step-${t.id}`;return(0,p.jsxs)(d.default.Fragment,{children:[t.has_label&&E(t),(!t.has_label||o.get(t.label?.id??-1))&&(0,p.jsxs)(p.Fragment,{children:[t.has_step_group&&C.includes(t)&&T(t),t.has_requirement?(0,p.jsx)(iL,{requirement:x.find(e=>e.step.id===t.id),step:t,parts:b,refetchFn:u}):(0,p.jsx)(ZI,{run:e,step:t,parts:b,monitoredBy:w[t.id],refetchFn:u})]})]},n)})})]}),(0,p.jsx)(zF,{data:f.data,setPage:i,isPlaceholderData:f.isPlaceholderData})]})}function oL(){let{run:e}=(0,d.useContext)(ZF);return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run information`}),(0,p.jsx)(`h3`,{children:`Run name`}),(0,p.jsx)(`p`,{children:e.name}),(0,p.jsx)(`h3`,{children:`Project name`}),(0,p.jsx)(`p`,{children:e.project.name})]})}var sL=()=>{let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(null),{id:i}=(0,g.useParams)();(0,d.useEffect)(()=>{(e===null||i!==e.id.toString())&&Se({id:parseInt(i)}).then(e=>(xe({id:e.run_id}).then(r),e)).then(t)},[i,e]);function a(){Se({id:parseInt(i)}).then(e=>(xe({id:e.run_id}).then(r),e)).then(t)}return{run:n,runStep:e,setRunStep:t,reloadRunStep:a}};function cL({children:e}){let{runStep:t,setRunStep:n,run:r,reloadRunStep:i}=sL(),[a,o]=(0,d.useState)({});if(t===null||r===null){let e=`Loading run...`;return t===null&&r===null?e=`Loading run and run step...`:r===null&&(e=`Loading run step...`),(0,p.jsx)(Ct,{children:(0,p.jsx)(vt,{message:e})})}return(0,p.jsx)(Ct,{children:(0,p.jsx)($I.Provider,{value:{runStep:t,setRunStep:n,reloadRunStep:i,run:r,modalProperties:a,setModalProperties:o},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading...`}),children:e})})})}function lL(){return(0,p.jsx)(cL,{children:(0,p.jsx)(Wr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})})}var uL=({label:e})=>(0,p.jsx)(`div`,{className:`p-2 h4 mb-1 bg-info text-white`,children:e.label}),dL=({runStep:e})=>{let{environment:t}=(0,g.useParams)();return(0,p.jsxs)(`h2`,{children:[` `,e.number,` -`,e.process_module.process.name,` on`,` `,(0,p.jsxs)(g.Link,{to:`/${t}/operator/equipment/${e.process_module.module.equipment.id}`,children:[e.process_module.module.equipment.name,` (`,e.process_module.module.name,`)`]})]})},fL=({checklistItem:e,show:t,setModalShow:n,mutation:r})=>(0,p.jsxs)(U,{show:t,size:`lg`,onHide:()=>n(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Checklist item`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsx)(`h2`,{children:e.task}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.description}})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:()=>{r.mutate()},children:`Done`}),(0,p.jsx)(B,{variant:`secondary`,onClick:()=>n(!1),children:`Close`})]})]});function pL({checklistItem:e,onOpenModal:t,onMarkDone:n}){return e.can_finish?e.description===``?(0,p.jsx)(B,{className:`float-end`,size:`sm`,variant:`success`,onClick:n,children:`Done checklist step`}):(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:t,children:`Execute checklist step`}):null}var mL=({checklistItem:e,refetch:t})=>{let[n,r]=(0,d.useState)(!1),i=(0,m.useMutation)({mutationFn:async()=>(await f.default.create().patch(`update/run/step/checklist/done/`+e.id,{})).data,onSuccess:e=>{r(!1),t()}});return(0,p.jsxs)(Zs.Item,{disabled:e.is_executed,className:`d-flex justify-content-between align-items-start`,children:[(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[e.task,e.is_executed&&(0,p.jsxs)(`small`,{children:[`Executed on `,(0,p.jsx)(eI,{format:`DD-MM-YYYY`,children:e.date_executed})]})]}),(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(pL,{checklistItem:e,onOpenModal:()=>r(!0),onMarkDone:()=>i.mutate()})}),(0,p.jsx)(fL,{checklistItem:e,show:n,setModalShow:r,mutation:i})]})},hL={movingOut:`Moving out...`,skipping:`Skipping...`,unskipping:`Unskipping...`,operationFinished:`Operation finished`,operationSkipped:`Operation skipped`,operationUnskipped:`Operation unskipped`};function gL({run:e,runStep:t,reloadRunStep:n}){let r=(0,g.useNavigate)(),{environment:i}=(0,g.useParams)(),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),{run:l,runStep:u,reloadRunStep:h}=(0,d.useContext)($I);(0,d.useEffect)(()=>{if(a){let e=setTimeout(()=>{o(null)},3e3);return()=>clearTimeout(e)}},[a]);let _=e??l,v=t??u,y=n??h??(()=>null),{data:b,error:x,isLoading:S,refetch:C}=(0,m.useQuery)({queryKey:[`checklist`,v?.id],queryFn:()=>ke({runStep:v}),enabled:!!v}),w=(0,d.useCallback)(async e=>{o(hL.movingOut),c(!0);try{let t=await Ae(e);o(hL.operationFinished),t.data.next_step_id===null?y():r(`/${i}/operator/run/step/${t.data.next_step_id}`)}finally{c(!1)}},[i,r,y]),T=(0,d.useCallback)(async e=>{o(hL.skipping),c(!0);try{await f.default.create().patch(`update/run/step/skip/${e.id}`,{}),o(hL.operationSkipped),y()}finally{c(!1)}},[y]),E=(0,d.useCallback)(async e=>{o(hL.unskipping),c(!0);try{await f.default.create().patch(`update/run/step/un-skip/${e.id}`,{}),o(hL.operationUnskipped),y()}finally{c(!1)}},[y]),{checklistItems:D,canFinishOperation:O}=(0,d.useMemo)(()=>{let e=b?.items??[],t=e.findIndex(e=>!e.is_executed);return{checklistItems:e.map((e,n)=>({...e,can_finish:n===t})),canFinishOperation:!!(v&&!v.is_finished&&t===-1)}},[b,v]);return!v||!_?(0,p.jsx)(p.Fragment,{children:`Please set RunStepContext in RunStepChecklist`}):S?(0,p.jsx)(vt,{message:`Loading...`}):x?(0,p.jsx)(vr,{variant:`danger`,children:`Failed to load checklist.`}):(0,p.jsxs)(p.Fragment,{children:[D.length===0&&(0,p.jsx)(vr,{variant:`info`,children:`No checklist found`}),D.length>0&&(0,p.jsx)(Zs,{children:D.map(e=>(0,p.jsx)(mL,{checklistItem:e,refetch:C},e.id))}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mt-3`,children:[(0,p.jsxs)(`div`,{className:`d-flex gap-2 align-items-center`,children:[O&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`success`,onClick:()=>w(v),disabled:s,children:a===hL.operationFinished||a===hL.movingOut?a:`Move out`})}),_.access.edit&&!v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,onClick:()=>T(v),disabled:s,children:a===hL.operationSkipped||a===hL.skipping?a:`Skip operation`})}),_.access.edit&&v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`warning`,onClick:()=>E(v),disabled:s,children:a===hL.operationUnskipped||a===hL.unskipping?a:`Unskip operation`})})]}),(0,p.jsx)(`div`,{className:`d-flex gap-2`,children:v.next_step_id&&(0,p.jsx)(`div`,{children:(0,p.jsx)(g.Link,{to:`/${i}/operator/run/step/${v.next_step_id}`,className:`btn btn-secondary`,children:`Next step`})})})]})]})}var _L=()=>void 0;function vL({runStep:e,reloadRunStep:t,title:n=`Remark`,titleClassName:r=`mb-2 text-start`}){let{runStep:i,setRunStep:a}=(0,d.useContext)($I),o=e??i,s=t?()=>t():e?_L:a??_L,[c,l]=(0,d.useState)(!1),u=o?!o.is_finished:!1,m=!!o?.remark?.trim(),{register:h,handleSubmit:g,formState:_,reset:v}=Ed({defaultValues:{remark:o?.remark_unparsed??``}}),{isSubmitting:y}=_;(0,d.useEffect)(()=>{v({remark:o?.remark_unparsed??``})},[v,o?.remark_unparsed]);let b=(0,d.useCallback)(async e=>{if(!o)return;await f.default.patch(`update/run/step/`+o.id,{remark:e.remark});let t=await f.default.get(`view/run/step/`+o.id);s({...o,remark:t.data.remark,remark_unparsed:t.data.remark_unparsed}),l(!1)},[o,s]);return o?!c||!u?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:r,children:n}),!m&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`text-muted`,children:`No remark.`}),u&&(0,p.jsx)(B,{variant:`primary`,className:`ms-auto`,size:`sm`,onClick:()=>l(!0),children:`Add remark`})]}),m&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`text-success`,dangerouslySetInnerHTML:{__html:o.remark}}),` `,u&&(0,p.jsx)(B,{variant:`primary`,className:`mt-3`,onClick:()=>l(!0),children:`Edit remark`})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{className:r,children:n}),(0,p.jsxs)(H,{onSubmit:g(b),children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:6,...h(`remark`)}),(0,p.jsx)(`p`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:`If a non-conformity happens, note it here`})}),(0,p.jsxs)(B,{variant:`primary`,type:`submit`,disabled:y,children:[y&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Save remark`]}),(0,p.jsx)(B,{variant:`secondary`,className:`ms-2`,onClick:()=>l(!1),children:`Cancel`})]})]}):(0,p.jsx)(p.Fragment,{children:`Please set RunStepContext for StepRemark`})}var yL=({run:e,show:t,setShow:n,runHoldCode:r,setRunHoldCode:i})=>{let[a,o]=d.default.useState(!1),{register:s,control:c,setValue:l,handleSubmit:u,formState:m}=Ed({defaultValues:{holdCode:r?{value:r.hold_code.id,label:r.hold_code.code}:{},description:r?r.description:``}}),{errors:h,isSubmitting:g}=m,_=async t=>{try{let n=await f.default.patch(`update/run/hold-code/`+e.id,{holdcode:a?null:t.holdCode.value,description:t.description});n.data.hold_code?i(n.data):i(void 0),o(!1)}finally{n(!1)}},v=(e,t)=>{f.default.get(`list/run/hold-code`).then(e=>{let{data:t}=e;return t._embedded.items}).then(e=>{t(e.map(e=>({value:e.id,label:e.code})))})};return(0,p.jsx)(U,{show:t,size:`lg`,onHide:()=>n(!1),children:(0,p.jsxs)(H,{onSubmit:u(_),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:a?`Reset hold code`:`Update hold code`})}),(0,p.jsxs)(U.Body,{children:[!a&&(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Hold code`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(vu,{name:`holdCode`,control:c,rules:{validate:{required:e=>e.value!==void 0||a||`A hold code is required`}},render:({field:e})=>(0,p.jsx)(Vb,{isSearchable:!1,defaultOptions:!0,placeholder:`Select a hold code`,loadOptions:v,value:e.value,onChange:t=>{e.onChange(t)}})}),h.holdCode&&(0,p.jsx)(`span`,{className:`text-danger`,children:h.holdCode.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`Message`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:3,...s(`description`,{required:`A message is required`}),isInvalid:h.description!==void 0}),h.description&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:h.description.message})]})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsxs)(B,{type:`submit`,variant:a?`success`:`primary`,disabled:g,children:[g&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),a?`Release lot`:`Update Hold code`]}),r&&(0,p.jsx)(B,{variant:`outline-danger`,onClick:()=>{l(`description`,a?r.description:``),o(!a)},children:a?`Update hold Code`:`Reset hold code`})]})]})})},bL=()=>{let{run:e}=(0,d.useContext)($I),[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(e.hold_code),a=()=>{n(!0)};return(0,p.jsxs)(p.Fragment,{children:[r&&(0,p.jsx)(`span`,{className:`badge handle`,style:{backgroundColor:r.hold_code.back_color,color:r.hold_code.front_color,fontSize:`1.5rem`,cursor:`pointer`},onClick:()=>a(),children:r.hold_code.code}),!r&&(0,p.jsx)(yr,{bg:`secondary`,className:`handle`,onClick:()=>a(),style:{fontSize:`1.5rem`,cursor:`pointer`},children:`No hold code`}),(0,p.jsx)(yL,{run:e,show:t,setShow:n,runHoldCode:r,setRunHoldCode:i})]})},xL=()=>{let{run:e}=(0,d.useContext)($I),[t,n]=(0,d.useState)(e.priority);return(0,p.jsxs)(d.default.Fragment,{children:[t&&(0,p.jsx)(`span`,{className:`badge`,style:{backgroundColor:t.priority.back_color,color:t.priority.front_color,fontSize:`1.5rem`},children:t.priority.code}),!t&&(0,p.jsx)(`span`,{className:`badge bg-info`,style:{fontSize:`1.5rem`},children:`NORMAL`})]})},SL=({run:e,runStep:t,showOnlyEmphasizedParameters:n})=>(0,p.jsx)(`div`,{className:`border rounded px-3 py-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsx)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:(0,p.jsx)(qI,{run:e,runStep:t})}),(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[n&&(0,p.jsx)(`h4`,{children:`Emphasized parameters`}),!n&&(0,p.jsx)(`h4`,{children:`Parameters`}),(0,p.jsx)(sI,{runStep:t,editableParameters:!1,showOnlyEmphasizedParameters:n})]})]})}),CL=({run:e,monitoredBy:t,runStep:n,runParts:r,runStepParts:i,hideLabel:a,firstInGroup:o})=>{let{environment:s}=(0,g.useParams)(),[c,l]=(0,d.useState)(!1),{runStep:u}=(0,d.useContext)($I);return(0,p.jsxs)(p.Fragment,{children:[!a&&n.has_label&&n.is_own_label&&(0,p.jsx)(`div`,{className:`bg-info text-white rounded px-3 py-1`,children:n.label?.label}),n.step_group&&o&&(0,p.jsx)(`div`,{className:`bg-secondary text-white rounded px-3 py-1`,children:n.step_group?.label}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 border rounded px-3 py-2 ${n.has_step_group?`ms-4`:``}`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2 flex-shrink-0`,children:[n.id!==u.id&&(0,p.jsx)(`i`,{className:`fa `+(c?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:()=>{l(!c)}}),n.id===u.id&&(0,p.jsx)(`i`,{className:`fa fa-chevron-right text-success`,style:{cursor:`pointer`},title:`This step is currently running`})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 flex-grow-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(XI,{step:n,parts:r,stepParts:i,run:e})}),(0,p.jsxs)(`div`,{className:`flex-shrink-0 text-nowrap`,children:[n.number,` `,n.is_skipped&&(0,p.jsx)(yr,{bg:`info`,children:`Skipped`})]}),(0,p.jsxs)(`div`,{className:`flex-grow-1 min-w-0`,children:[(0,p.jsx)(g.Link,{to:`/${s}/operator/run/step/${n.id}`,dangerouslySetInnerHTML:{__html:n.name}}),` `,t&&(0,p.jsx)(pl,{placement:`top`,overlay:(0,p.jsx)(sl,{id:`tooltip-${t.id}`,children:`Monitored by step: ${t.step.number}`}),children:(0,p.jsx)(`i`,{className:`fa fa-search me-2`})})]})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-3 flex-shrink-0 ms-auto`,children:[(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.finish_user?n.finish_user.initials:``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.has_rework?(0,p.jsx)(`span`,{className:`badge bg-primary`,children:`Rework`}):``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.is_finished?(0,p.jsx)(eI,{format:`DD-MM-YYYY`,children:n.finish_date}):``})]})]}),c&&(0,p.jsx)(SL,{run:e,runStep:n,showOnlyEmphasizedParameters:!1})]})};function wL({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i}){let a=n.filter(t=>t.step_id===(e.requirement_for_step?.id??e.step.id)),{environment:o}=(0,g.useParams)();return(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(`div`,{className:`border rounded px-3 py-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[(0,p.jsx)(`h4`,{children:`Measurement results`}),(0,p.jsx)(eL,{requirement:e,step:t,stepParts:a,parts:r,measurementResults:i,editOnly:!0})]}),(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[(0,p.jsx)(`h4`,{children:`Monitored Step`}),(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${e.requirement_for_step?.id??e.step.id}`,children:(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-search`}),` `,e.requirement_for_step?.name??e.step.name]})}),(0,p.jsx)(`h4`,{children:`Definition`}),(0,p.jsx)(`span`,{children:e.definition}),(0,p.jsx)(`h4`,{children:`Targets`}),(0,p.jsxs)(kl,{size:`sm`,striped:!1,bordered:!1,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`min value`}),(0,p.jsx)(`th`,{children:`max value`}),(0,p.jsx)(`th`,{children:`inclusive`})]})}),(0,p.jsx)(`tbody`,{children:e.targets.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.min_value}),(0,p.jsx)(`td`,{children:e.max_value}),(0,p.jsx)(`td`,{children:e.inclusive?`yes`:`no`})]},e.id))})]})]})]})})})}function TL({requirement:e,runParts:t,runStepParts:n,hideLabel:r,firstInGroup:i}){let a=e.step,{environment:o}=(0,g.useParams)(),{runStep:s}=(0,d.useContext)($I),[c,l]=(0,d.useState)(!1),[u]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)],queryFn:()=>Oe({measurement:e.measurement})}]});return(0,p.jsxs)(p.Fragment,{children:[!r&&a.has_label&&a.is_own_label&&(0,p.jsx)(`div`,{className:`bg-info text-white rounded px-3 py-1`,children:a.label?.label}),a.step_group&&i&&(0,p.jsx)(`div`,{className:`bg-secondary text-white rounded px-3 py-1`,children:a.step_group?.label}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 border rounded px-3 py-2 ${(()=>{if(!u.data)return``;let t=!1;for(let r of n){let n=u.data?.items.find(e=>e.values.some(e=>e.step_part_id===r.id))?.values.find(e=>e.step_part_id===r.id);if(!(n&&!isNaN(parseFloat(n.string_value))))return a.id===s.id?`bg-success-subtle`:``;let i=parseFloat(n.string_value);if(e.targets.some(e=>e.inclusive?!(e.min_value<=i&&e.max_value>=i):!(e.min_value<i&&e.max_value>i))){t=!0;break}}return t?`bg-danger-subtle`:a.id===s.id?`bg-success-subtle`:``})()} ${a.has_step_group?`ms-4`:``}`,children:[(0,p.jsx)(`div`,{className:`d-flex align-items-center gap-2 flex-shrink-0`,children:a.id!==s.id&&(0,p.jsx)(`i`,{className:`fa `+(c?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:()=>{l(!c)}})}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 flex-grow-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(rL,{requirement:e,step:a,parts:t,stepParts:n,measurementResults:u.data?.items??[]})}),(0,p.jsxs)(`div`,{className:`flex-shrink-0 text-nowrap`,children:[a.number,` `,a.is_skipped&&(0,p.jsx)(yr,{bg:`info`,children:`Skipped`})]}),(0,p.jsxs)(`div`,{className:`flex-grow-1 min-w-0`,children:[(0,p.jsx)(yr,{bg:`info`,children:`requirement`}),` `,(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${a.id}`,dangerouslySetInnerHTML:{__html:a.name}}),` `]})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-3 flex-shrink-0 ms-auto`,children:[(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.finish_user?a.finish_user.initials:``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.has_rework?(0,p.jsx)(`span`,{className:`badge bg-primary`,children:`Rework`}):``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.is_finished?(0,p.jsx)(eI,{format:`DD-MM-YYYY`,children:a.finish_date}):``})]})]}),c&&(0,p.jsx)(wL,{requirement:e,step:a,stepParts:n,parts:t,measurementResults:u.data?.items??[]})]})}var EL=({pageSize:e=25,hideLabel:t=!1})=>{let{runStep:n,run:r}=(0,d.useContext)($I),[i,a]=(0,d.useState)(1);(0,d.useEffect)(()=>{n?.sequence&&a(Math.max(1,Math.ceil(n.sequence/e)))},[n?.sequence,e]);let o=r?.id??null,s=(0,m.useQuery)({queryKey:[`runParts`,`${o}`],queryFn:()=>Te({run:r}),enabled:!!o}),c=(0,m.useQuery)({queryKey:[`runStepParts`,`${o}`],queryFn:()=>Ne({run:r}),enabled:!!o}),l=(0,m.useQuery)({queryKey:[`runSteps`,o,i,e],queryFn:()=>Ee({run:r,page:i,pageSize:e}),enabled:!!o,placeholderData:m.keepPreviousData}),u=(0,m.useQuery)({queryKey:[`requirements`,o],queryFn:()=>Ce({run:r}),enabled:!!o,placeholderData:m.keepPreviousData}),f=s.isLoading||c.isLoading||l.isLoading||u.isLoading,h=s.isError||c.isError||l.isError||u.isError,g=s.error||c.error||l.error||u.error,_=s.data?.items??[],v=c.data?.items??[],y=l.data?.items??[],b=u.data?.items??[],x=new Set,S=y.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||x.has(String(e.step_group.id))?!1:(x.add(String(e.step_group.id)),!0)),C={};for(let e of b)e.requirement_for_step!=null&&(C[String(e.requirement_for_step.id)]=e);return d.default.useEffect(()=>{h&&console.error(`RunStepSimpleList query error`,{runId:o,errors:[s.error,c.error,l.error,u.error]})},[h,o,s.error,c.error,l.error,u.error]),(0,p.jsxs)(`div`,{children:[f?(0,p.jsx)(`div`,{children:`Loading...`}):h?(0,p.jsxs)(`div`,{children:[`Error: `,String(g?.message??g)]}):(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2`,children:y.map((e,n)=>(0,p.jsx)(d.default.Fragment,{children:e.has_requirement?(0,p.jsx)(TL,{requirement:b.find(t=>t.step.id===e.id),runParts:_,runStepParts:v,firstInGroup:S.includes(e)},e.id??e.sequence??n):(0,p.jsx)(CL,{run:r,monitoredBy:C[e.id],runParts:_,runStepParts:v,hideLabel:t,firstInGroup:S.includes(e),runStep:e},e.id??e.sequence??n)},n))}),(0,p.jsx)(zF,{data:l.data,setPage:a,isPlaceholderData:l.isPlaceholderData}),l.isFetching?(0,p.jsx)(`span`,{children:` Loading...`}):null]})},DL=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)($I),[r,i]=(0,d.useState)(1),{isPending:a,isLoading:o,isError:s,error:c,data:l,isFetching:u,isPlaceholderData:f}=(0,m.useQuery)({queryKey:[`run_changelog`,n,r],queryFn:()=>we({run:n,page:r}),placeholderData:m.keepPreviousData});return(0,p.jsxs)(U,{show:e,size:`lg`,onHide:()=>t(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsxs)(U.Title,{children:[`History of Run `,n.label]})}),(0,p.jsx)(U.Body,{children:(0,p.jsxs)(`div`,{children:[a?(0,p.jsx)(`div`,{children:`Loading...`}):s?(0,p.jsxs)(`div`,{children:[`Error: `,c.message]}):(0,p.jsx)(kl,{size:`sm`,striped:!0,bordered:!0,hover:!0,children:(0,p.jsx)(`tbody`,{children:l.items.map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(eI,{format:`DD-MM-YYYY`,children:e.date_created})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.message}})}),(0,p.jsxs)(`td`,{children:[e.user.first_name,` `,e.user.last_name]})]},t))})}),(0,p.jsx)(zF,{data:l,setPage:i,isPlaceholderData:f}),u?(0,p.jsx)(`span`,{children:` Loading...`}):null]})}),(0,p.jsx)(U.Footer,{children:(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},OL=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{size:e,variant:`primary`,onClick:()=>n(!t),children:`Run history`}),t&&(0,p.jsx)(DL,{show:t,setModalShow:n})]})},kL=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)($I);return(0,p.jsxs)(U,{show:e,size:`xl`,onHide:()=>t(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsxs)(U.Title,{children:[`All steps of run `,n.label]})}),(0,p.jsx)(U.Body,{children:(0,p.jsx)(EL,{hideLabel:!1})}),(0,p.jsx)(U.Footer,{children:(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},AL=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(B,{size:e,variant:`primary`,onClick:()=>n(!0),children:`All run steps`}),t&&(0,p.jsx)(kL,{show:t,setModalShow:n})]})},jL=()=>{let{runStep:e,run:t}=(0,d.useContext)($I),[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)([]),[u,h]=(0,d.useState)([]),[g,_]=(0,d.useState)([]),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)(!1);if(!e.has_recipe)return`Reworks are only possible for steps with a recipe`;let[S,C,w]=(0,m.useQueries)({queries:[{queryKey:[`templates`,g],queryFn:()=>Ue({reworkRecipes:g}),enabled:n&&g.length>0},{queryKey:[`run_steps`,e.id],queryFn:()=>Ee({run:t,page:1,pageSize:1e3}),enabled:n},{queryKey:[`template_steps`,`rework`,o,e.id],queryFn:()=>He({template:o,pageSize:1e3}),enabled:o!==null}]});(0,d.useEffect)(()=>{C.isSuccess&&c.length>0&&_([...C.data.items.filter(e=>c.includes(e.id)).map(e=>e.recipe_version.recipe)])},[C.isSuccess,c]);function T(e){let t=S.data.templates.find(t=>t.id===e);t!==void 0&&s(t)}function E(){let t={};a({}),c.length===0&&(t.runStep=`Please select at least one step`),a(e=>({...e,...t})),Object.keys(t).length===0&&(x(!0),f.default.create().patch(`/update/run/step/rework/`+e.id,{reworked_run_steps:c,template_steps:u,comment:v}).then(()=>{x(!1),window.location.reload()}))}return(0,p.jsxs)(p.Fragment,{children:[n&&(0,p.jsxs)(H,{method:`post`,onSubmit:()=>E(),children:[(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Template`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[g.length===0&&(0,p.jsx)(vr,{variant:`info`,children:`Please select a rework step`}),g.length>0&&(0,p.jsxs)(H.Control,{as:`select`,name:`template`,onChange:e=>T(parseInt(e.target.value)),isInvalid:!!i.template,children:[(0,p.jsx)(`option`,{value:``,children:`— Select a template`}),S.data!==void 0&&S.data.templates.map((e,t)=>(0,p.jsxs)(`option`,{value:e.id,children:[e.label,`: `,e.name]},t))]}),i.template&&(0,p.jsx)(`span`,{className:`text-danger`,children:i.template})]})]}),o!==null&&(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Include template steps`}),(0,p.jsx)(`div`,{className:`col-sm-9`,children:(0,p.jsx)(`ul`,{className:`list-group`,children:!w.isLoading&&w.data!==void 0&&w.data.steps.map((e,t)=>(0,p.jsx)(`li`,{className:`list-group-item `,children:(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,className:`form-check-input`,id:`templateStep`+e.id,name:`templateStep`,onChange:t=>{t.target.checked?h([...u,e.id]):h(u.filter(t=>t!==e.id))},value:e.id}),(0,p.jsxs)(`label`,{htmlFor:`templateStep`+e.id,className:`from-check-label`,children:[(0,p.jsxs)(`small`,{className:`text-muted pe-2`,children:[e.number,`:`]}),e.process_module.process.name]})]})},t))})})]}),(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Repeat steps`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(`ul`,{className:`list-group`,children:[C.isLoading&&(0,p.jsx)(`option`,{children:`Loading run steps...`}),!C.isLoading&&C.data.items.map((t,n)=>{if(e.sequence>=t.sequence)return(0,p.jsxs)(`li`,{className:`list-group-item d-flex justify-content-between`+(e.id===t.id?` bg-success-subtle`:``),children:[(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,className:`form-check-input`,id:`runStep`+t.id,name:`runStep`,onChange:e=>{e.target.checked?l([...c,t.id]):l(c.filter(e=>e!==t.id))},value:t.id}),(0,p.jsxs)(`label`,{htmlFor:`runStep`+t.id,className:`from-check-label`,children:[(0,p.jsxs)(`small`,{className:`text-muted pe-2`,children:[t.number,`:`]}),t.process_module.process.name]})]}),t.is_finished&&(0,p.jsx)(`div`,{children:(0,p.jsx)(`span`,{className:`badge bg-success`,children:`Finished`})})]},n)})]}),i.runStep&&(0,p.jsx)(`span`,{className:`text-danger`,children:i.runStep})]})]}),(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Comment`}),(0,p.jsx)(`div`,{className:`col-sm-9`,children:(0,p.jsxs)(H.Group,{controlId:`runStep.remark`,children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:6,onChange:e=>y(e.target.value),value:v,isInvalid:!!i.comment}),(0,p.jsx)(`small`,{className:`text-muted`,children:`Optional comment for the rework`})]})})]}),(0,p.jsx)(`div`,{className:`row mb-3`,children:(0,p.jsxs)(`div`,{className:`col-sm-9 offset-sm-3`,children:[(0,p.jsxs)(B,{variant:`primary`,onClick:()=>E(),disabled:b,children:[b&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Create rework`]}),`\xA0`,(0,p.jsx)(B,{variant:`warning`,onClick:()=>r(!1),children:`Cancel`})]})})]}),!n&&(0,p.jsx)(B,{variant:`primary`,className:`mt-3`,onClick:()=>r(!0),children:`Set Rework`})]})},ML=()=>{let{environment:e}=(0,g.useParams)(),{runStep:t,run:n}=(0,d.useContext)($I),r=(0,m.useQueries)({queries:[{queryKey:[`monitors`,t.process_module.module.equipment],queryFn:()=>he({equipment:t.process_module.module.equipment})},{queryKey:[`ecn`,t.process_module.module],queryFn:()=>ie({module:t.process_module.module})},{queryKey:[`equipmentModule`,t.process_module.module],queryFn:()=>ne({id:t.process_module.module.id})},{queryKey:[`requirement`,t.id],queryFn:()=>Ce({run:n,step:t})}]}),[i,a,o,s]=r,[c,l]=(0,d.useState)(!0),{addReadingCallbackFn:u,removeReadingCallbackFn:f}=AI(),[h,_]=(0,d.useState)(``),v=(0,d.useId)();(0,d.useEffect)(()=>(u(v,_),()=>{f(v)}),[]);let y=r.some(e=>e.isLoading);if(r.some(e=>e.isError))return r.filter(e=>e.isError).forEach((e,r)=>{console.error(`StepDashboard query error`,{index:r,error:e.error,runStep:t,run:n})}),(0,p.jsx)(p.Fragment,{children:`Error fetching data`});if(y)return(0,p.jsx)(`div`,{children:`Loading...`});let b=o.data;return(0,p.jsx)(Wr,{fluid:!0,children:(0,p.jsxs)(Dl,{children:[(0,p.jsxs)(Ur,{className:`col-9`,children:[n.run_type===ut.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),n.run_type===ut.PRODUCTION&&(0,p.jsx)(`small`,{children:`Production run`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[n.name,` (`,n.project.name,`)`]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-lg-row gap-2 flex-wrap justify-content-end`,children:[t.has_rework&&(0,p.jsx)(`span`,{style:{fontSize:`1.5rem`},className:`mx-1 badge bg-primary`,children:`Rework`}),(0,p.jsx)(xL,{}),(0,p.jsx)(bL,{}),t.is_skipped&&(0,p.jsx)(`span`,{style:{fontSize:`1.5rem`},className:`badge bg-info`,children:`SKIPPED`})]})]}),(0,p.jsx)(tI,{run:n}),t.label&&(0,p.jsx)(uL,{label:t.label}),(0,p.jsx)(dL,{runStep:t}),t.is_finished&&(0,p.jsxs)(vr,{variant:`success`,children:[`This step has been finished by `,t.finish_user?.first_name,` `,t.finish_user?.last_name]}),t.has_recipe&&(0,p.jsx)(Pr,{className:`rounded my-4`,children:(0,p.jsxs)(Pr.Body,{children:[(0,p.jsx)(Pr.Title,{className:`text-muted`,children:`Recipe`}),(0,p.jsxs)(Pr.Text,{className:`display-5`,children:[t.recipe_version.recipe.name,` (Version `,t.recipe_version.version,`)`]})]})}),s.data?.items.length==1&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{children:`Measurements by part`}),(0,p.jsx)(eL,{requirement:s.data.items[0],step:t,editOnly:!1}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(tL,{requirement:s.data.items[0],editOnly:!1})]}),s.data?.items.length!=1&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{children:`Experimental split`}),(0,p.jsx)(qI,{run:n,runStep:t})]}),(0,p.jsxs)(`p`,{className:`pt-3`,children:[`Reading from scanner: `,h]}),(0,p.jsxs)(Dl,{className:`pm-3`,children:[(0,p.jsxs)(Ur,{children:[(0,p.jsx)(`h3`,{children:`Checklist`}),(0,p.jsx)(gL,{}),(0,p.jsx)(`h2`,{className:`mt-2`,children:`Step files`}),(0,p.jsx)(lI,{runStep:t})]}),(0,p.jsxs)(Ur,{children:[(0,p.jsx)(`h2`,{children:`Parameters`}),(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:c,className:`form-check-input`,"data-toggle":`toggle`,onChange:()=>l(!c)}),(0,p.jsx)(`label`,{className:`ms-2`,children:`Show only emphasized parameters`})]}),(0,p.jsx)(sI,{runStep:t,editableParameters:!1,showOnlyEmphasizedParameters:c}),t.has_instructions&&t.instructions&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{children:`Instructions`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.instructions}})]}),(0,p.jsx)(vL,{}),(0,p.jsx)(`h3`,{className:`pt-3`,children:`Rework`}),(0,p.jsx)(jL,{})]})]}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mb-3`,children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsxs)(`div`,{className:`d-flex gap-2 flex-wrap justify-content-end`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(AL,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(OL,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(ZP,{size:void 0,moduleId:t.process_module.module.id})})]})]}),(0,p.jsx)(EL,{pageSize:n.run_type===ut.RESEARCH?5:1e3,hideLabel:!0})]}),(0,p.jsx)(Ur,{className:`col-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(`h2`,{children:(0,p.jsxs)(g.Link,{to:`/${e}/operator/equipment/${t.process_module.module.equipment.id}`,children:[t.process_module.module.equipment.name,` (`,t.process_module.module.name,`)`]})}),b&&(0,p.jsx)(`div`,{children:(0,p.jsx)(`h2`,{children:(0,p.jsx)(Dd,{module:b})})}),i.data?.items&&i.data.items.map((e,t)=>(0,p.jsx)(XP,{monitor:e},t)),a.data?.items.map(function(e,t){return(0,p.jsxs)(Pr,{className:`my-2`,children:[(0,p.jsxs)(Pr.Header,{children:[`ECN: `,e.ecn]}),(0,p.jsx)(Pr.Body,{children:(0,p.jsx)(Pr.Text,{children:(0,p.jsx)(kP,{children:e.description})})}),(0,p.jsxs)(Pr.Footer,{children:[e.date_created&&(0,p.jsxs)(p.Fragment,{children:[`Created by `,YP(e.date_created,`DD-MM-YY H:m`),` by `,e.owner.full_name]}),e.last_update&&(0,p.jsxs)(p.Fragment,{children:[` `,`· Updated by `,YP(e.last_update,`DD-MM-YY H:m`),` by `,e.owner.full_name]})]})]},t)})]})})]})})},NL=()=>{let[e,t]=(0,d.useState)(!1),{modalProperties:n}=(0,d.useContext)($I),r=()=>{t(!1),n.show=!1};return(0,d.useEffect)(()=>{t(n.show)},[n]),(0,p.jsxs)(U,{show:e,size:`xl`,onHide:r,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:n.modalTitle})}),(0,p.jsx)(U.Body,{children:n.modalContent}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{variant:`secondary`,onClick:r,children:`Save`}),n.modalSaveButton]})]})};function PL(e){switch(e){case`Shift`:return!0}return!1}function FL(e){return/^[a-zA-Z0-9-]$/.test(e)}function IL(e){return e.length===1}function LL(e){switch(e){case`Enter`:return!0;default:return!1}}function RL(e,t,n,r){let i=r?.requireEndCharacter??!1,a=0,o=``,s=()=>{a=0,o=``,n&&n(o)};return r=>{let c=r.key;if(c===`Escape`){s();return}if(!PL(c)){if(LL(c)){t(o),s();return}switch(o+=c,e[a]){case`/`:if(c!=`/`){s();return}else a=(a+1)%e.length;break;case`*`:if(!IL(c))return;break;default:if(!FL(e[a]))throw Error(`Invalid character expression in makeKeySequenceListener call`);if(c!=e[a]){s();return}else a=(a+1)%e.length;break}if(!i&&a===e.length){t(o),s();return}n&&n(o)}}}var zL=({children:e})=>{let[t,n]=(0,d.useState)(``),r=(0,d.useRef)(new Map),i=(0,d.useRef)(new Map),a=e=>{(0,d.startTransition)(()=>{i.current.forEach(t=>t(e))})},o=e=>{n(e);let t=MI(e);(0,d.startTransition)(()=>{r.current.get(t)?.forEach(t=>t(e))})};return(0,d.useEffect)(()=>{let e=RL(`*`,o,a,{requireEndCharacter:!0});return document.addEventListener(`keyup`,e),()=>{document.removeEventListener(`keyup`,e)}},[o,a]),(0,p.jsx)(kI.Provider,{value:{lastlyReadedKeys:t,addCallbackFn:(e,t,n)=>{r.current.has(e)||r.current.set(e,new Map),r.current.get(e).set(t,n)},removeCallbackFn:(e,t)=>{r.current.get(e)?.delete(t)},addReadingCallbackFn:(e,t)=>{i.current.set(e,t)},removeReadingCallbackFn:e=>{i.current.delete(e)}},children:e})};function BL(){return(0,p.jsx)(II,{children:(0,p.jsx)(zL,{children:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ML,{}),(0,p.jsx)(NL,{})]})})})}function VL({run:e,runStep:t,showOnlyEmphasizedParameters:n,reloadRunStepFn:r}){let{data:i,refetch:a}=(0,m.useQuery)({queryKey:[`checklist`,t?.id],queryFn:()=>ke({runStep:t})}),o=(0,d.useMemo)(()=>i?.items,[i]),[s,c]=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Te({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Ne({step:t})}]}),l=(0,d.useMemo)(()=>{let e=s.data?.items??[],n=c.data?.items??[],r=e.filter(e=>e.part_level===t.part_level);return r.length===0?!1:r.every(e=>n.find(t=>t.part_id==e.id)?.processed===!0)},[s.data,c.data,t.part_level]),[u,f]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mb-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`h3`,{className:`mb-2 text-start`,children:`Parts`})}),(0,p.jsx)(pl,{placement:`top`,overlay:(0,p.jsx)(sl,{id:`tooltip-move-out`,children:l?`Finish step`:`Finish all parts before moving out`}),children:(0,p.jsx)(`span`,{children:(0,p.jsx)(B,{variant:l?`success`:`light`,onClick:()=>{f(!0),Ae(t).finally(()=>{f(!1),r()})},disabled:u||!l,children:u?`Moving out...`:`Move out`})})})]}),(0,p.jsx)(HI,{run:e,runStep:t}),(0,p.jsx)(`h3`,{className:`mt-2`,children:`Parameters`}),(0,p.jsx)(sI,{runStep:t,showOnlyEmphasizedParameters:n}),(0,p.jsxs)(`div`,{className:`row row-cols-2`,children:[(0,p.jsx)(`div`,{className:`col`,children:(0,p.jsx)(vL,{runStep:t,reloadRunStep:r})}),(0,p.jsx)(`div`,{className:`col`,children:t.has_instructions&&t.instructions&&(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`h3`,{className:`mb-2 text-start`,children:`Instructions`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.instructions}})]})})]}),(0,p.jsxs)(`div`,{className:`row row-cols-2`,children:[(0,p.jsxs)(`div`,{className:`col`,children:[(0,p.jsx)(`h3`,{className:`mt-2`,children:`Checklist`}),!o&&(0,p.jsx)(Zs,{children:Array.from({length:1}).map((e,t)=>(0,p.jsx)(Zs.Item,{children:(0,p.jsxs)(El,{as:`div`,animation:`glow`,children:[(0,p.jsx)(El,{xs:17}),` `,(0,p.jsx)(El,{xs:4}),` `,(0,p.jsx)(El,{xs:6})]})},t))}),o&&(0,p.jsxs)(p.Fragment,{children:[o.length===0&&(0,p.jsx)(vr,{variant:`info`,children:`No checklist found`}),o.length>0&&(0,p.jsx)(Zs,{children:o.map(e=>(0,p.jsx)(mL,{checklistItem:e,refetch:a},e.id))})]})]}),(0,p.jsxs)(`div`,{className:`col`,children:[(0,p.jsx)(`h3`,{className:`mt-2`,children:`Step files`}),(0,p.jsx)(lI,{runStep:t})]})]})]})}function HL({children:e}){let[t,n]=(0,d.useState)(!1);return(0,p.jsx)(Ct,{children:(0,p.jsx)(aI.Provider,{value:{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading...`}),children:e})})})}function UL(){return(0,p.jsx)(Wr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}function WL({control:e,name:t}){let{environment:n}=(0,g.useParams)(),[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(!0);return(0,d.useEffect)(()=>{async function e(){try{i((await fe({environment:n,withLocations:!0})).items)}catch(e){console.error(`Error fetching rooms:`,e)}finally{o(!1)}}e()},[]),a?(0,p.jsx)(`p`,{children:`Loading labs...`}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{children:`Choose a lab`}),(0,p.jsx)(H.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:(0,p.jsx)(vu,{name:t,render:({field:{onChange:e,value:t}})=>(0,p.jsxs)(H.Select,{"aria-label":`Choose a lab`,value:t?.id||``,onChange:t=>{e(r.find(e=>e.id.toString()===t.target.value)||null)},children:[(0,p.jsx)(`option`,{value:``,children:`— Choose a lab`}),r.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),control:e})})]})}function GL({control:e}){return(0,p.jsx)(H.Group,{className:`mb-3`,controlId:`chemical.scanBarcode`,children:(0,p.jsx)(vu,{name:`barcode`,control:e,render:({field:e})=>(0,p.jsx)(`input`,{...e,id:`chemical.scanBarcodeElement`,type:`text`,autoFocus:!0,placeholder:`Scan or enter barcode`,className:`form-control form-control-lg`})})})}var KL=Object.defineProperty,qL=Object.getOwnPropertySymbols,JL=Object.prototype.hasOwnProperty,YL=Object.prototype.propertyIsEnumerable,XL=(e,t,n)=>t in e?KL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ZL=(e,t)=>{for(var n in t||(t={}))JL.call(t,n)&&XL(e,n,t[n]);if(qL)for(var n of qL(t))YL.call(t,n)&&XL(e,n,t[n]);return e},QL=(e,t)=>{var n={};for(var r in e)JL.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&qL)for(var r of qL(e))t.indexOf(r)<0&&YL.call(e,r)&&(n[r]=e[r]);return n},$L;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})($L||($L={})),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||(e.QrCode={}))})($L||($L={})),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||(e.QrSegment={}))})($L||($L={}));var eR=$L,tR={L:eR.QrCode.Ecc.LOW,M:eR.QrCode.Ecc.MEDIUM,Q:eR.QrCode.Ecc.QUARTILE,H:eR.QrCode.Ecc.HIGH},nR=128,rR=`L`,iR=`#FFFFFF`,aR=`#000000`,oR=!1,sR=1,cR=4,lR=0,uR=.1;function dR(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function fR(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function pR(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*uR),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function mR(e,t){return t==null?e?cR:lR:Math.max(Math.floor(t),0)}function hR({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=u.default.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...eR.QrSegment.makeSegments(t)),e),[]);return eR.QrCode.encodeSegments(r,tR[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:d,numCells:f,calculatedImageSettings:p}=u.default.useMemo(()=>{let e=c.getModules(),t=mR(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:pR(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:d,cells:l,numCells:f,calculatedImageSettings:p}}var gR=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),_R=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=nR,level:a=rR,bgColor:o=iR,fgColor:s=aR,includeMargin:c=oR,minVersion:l=sR,boostLevel:d,marginSize:f,imageSettings:p}=n,m=QL(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:h}=m,g=QL(m,[`style`]),_=p?.src,v=u.default.useRef(null),y=u.default.useRef(null),b=u.default.useCallback(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=u.default.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=hR({value:r,level:a,minVersion:l,boostLevel:d,includeMargin:c,marginSize:f,imageSettings:p,size:i});u.default.useEffect(()=>{if(v.current!=null){let e=v.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=fR(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,gR?t.fill(new Path2D(dR(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),u.default.useEffect(()=>{S(!1)},[_]);let D=ZL({height:i,width:i},h),O=null;return _!=null&&(O=u.default.createElement(`img`,{src:_,key:_,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),u.default.createElement(u.default.Fragment,null,u.default.createElement(`canvas`,ZL({style:D,height:i,width:i,ref:b,role:`img`},g)),O)});_R.displayName=`QRCodeCanvas`;var vR=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=nR,level:a=rR,bgColor:o=iR,fgColor:s=aR,includeMargin:c=oR,minVersion:l=sR,boostLevel:d,title:f,marginSize:p,imageSettings:m}=n,h=QL(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:g,cells:_,numCells:v,calculatedImageSettings:y}=hR({value:r,level:a,minVersion:l,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:m,size:i}),b=_,x=null;m!=null&&y!=null&&(y.excavation!=null&&(b=fR(_,y.excavation)),x=u.default.createElement(`image`,{href:m.src,height:y.h,width:y.w,x:y.x+g,y:y.y+g,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=dR(b,g);return u.default.createElement(`svg`,ZL({height:i,width:i,viewBox:`0 0 ${v} ${v}`,ref:t,role:`img`},h),!!f&&u.default.createElement(`title`,null,f),u.default.createElement(`path`,{fill:o,d:`M0,0 h${v}v${v}H0z`,shapeRendering:`crispEdges`}),u.default.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});vR.displayName=`QRCodeSVG`;function yR({control:e,name:t,room:n}){let[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(!0);return(0,d.useEffect)(()=>{async function e(){try{i((await de({room:n,pageSize:1e3})).items),o(!1)}catch(e){console.error(`Error fetching locations:`,e)}}e()},[n]),a?(0,p.jsx)(`p`,{children:`Loading locations...`}):(0,p.jsxs)(H.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:[(0,p.jsx)(H.Label,{children:`Select a storage location`}),(0,p.jsx)(vu,{name:t,control:e,defaultValue:``,render:({field:{onChange:e,value:t}})=>(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(Dl,{children:r.map(n=>(0,p.jsx)(Ur,{xs:4,md:3,className:`mb-3`,children:(0,p.jsx)(Pr,{onClick:()=>e(n.id.toString()),style:{cursor:`pointer`,border:t.toString()===n.id.toString()?`2px solid #007bff`:`1px solid #ddd`,borderRadius:`8px`},className:`h-100`,children:(0,p.jsxs)(Pr.Body,{children:[(0,p.jsx)(Pr.Title,{children:n.name}),(0,p.jsxs)(`div`,{className:`text-muted small mb-2 d-flex gap-2 justify-content-between`,children:[n.code&&(0,p.jsxs)(`div`,{children:[`Code: `,n.code]}),n.zone_group&&(0,p.jsxs)(`div`,{children:[`Zone group: `,n.zone_group.name]})]}),(0,p.jsxs)(`div`,{style:{textAlign:`center`,marginTop:`10px`},children:[(0,p.jsx)(vR,{value:`/l/`+n.id.toString(),size:128}),` `]})]})})},n.id))})})})]})}var bR=({show:e,setShow:t,onChemicalCreate:n})=>{let{register:r,control:i,setValue:a,handleSubmit:o,formState:{errors:s,isSubmitting:c}}=Ed({defaultValues:{}}),l=async e=>{try{let t=await f.default.post(`create/chemical`,e);t.data&&n(t.data)}finally{t(!1)}};return(0,p.jsx)(U,{show:e,size:`lg`,onHide:()=>t(!1),children:(0,p.jsxs)(H,{onSubmit:o(l),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Create new chemical`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`CAS Number`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(H.Control,{as:`input`,...r(`cas_number`,{required:`A cas number is required`}),isInvalid:s.cas_number!==void 0}),s.cas_number&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.cas_number.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`Name`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(H.Control,{as:`input`,...r(`name`,{required:`A name is required`}),isInvalid:s.name!==void 0}),s.name&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.name.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`Description`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:3,...r(`description`)}),s.description&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.description.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`Standard product`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(H.Select,{...r(`standard_product`,{required:`A standard product is required`}),isInvalid:s.standard_product!==void 0,children:[(0,p.jsx)(`option`,{value:et.NON_STANDARD_PRODUCT,children:`Non standard product`}),(0,p.jsx)(`option`,{value:et.STANDARD_PRODUCT,children:`Standard product`})]}),s.standard_product&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.standard_product.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`Physical state`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(H.Select,{...r(`physical_state`,{required:`A physical state is required`}),isInvalid:s.physical_state!==void 0,children:[(0,p.jsx)(`option`,{value:tt.SOLID,children:`Solid`}),(0,p.jsx)(`option`,{value:tt.LIQUID,children:`Liquid`}),(0,p.jsx)(`option`,{value:tt.GAS,children:`Gas`}),(0,p.jsx)(`option`,{value:tt.OTHER,children:`Other`})]}),s.physical_state&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.physical_state.message})]})]})]}),(0,p.jsx)(U.Footer,{children:(0,p.jsxs)(B,{variant:`primary`,disabled:c,onClick:()=>o(l)(),children:[c&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Create new chemical`]})})]})})};function xR({control:e,name:t,setValue:n,errors:r}){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(null),u=(e,t)=>{try{O({query:e}).then(e=>{let n=e.items.map(e=>({value:e.id,label:e.name+(e.cas_number?` (`+e.cas_number+`)`:``)})),r={...i};n.forEach(e=>{r[e.value]=e}),a(r),t(n)})}catch(e){console.error(`Error fetching chemicals:`,e)}},m=e=>e&&i[e]?i[e]:c||null;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Search Existing Chemicals`}),(0,p.jsxs)(Dl,{children:[(0,p.jsx)(vu,{name:t,control:e,render:({field:e})=>(0,p.jsx)(Vb,{isSearchable:!0,isClearable:!0,defaultOptions:!0,placeholder:`— Select a chemical, or start typing`,loadOptions:u,value:m(e.value),styles:Ub,onChange:t=>{l(null),e.onChange(t?.value)}})}),r.chemical&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:r.chemical.message}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,className:`mt-2`,onClick:()=>s(!0),children:`Create New Chemical`})})]})]}),(0,p.jsx)(bR,{show:o,setShow:s,onChemicalCreate:async e=>{try{let r=await f.default.post(`create/chemical`,e),i={value:r.data.id,label:r.data.name+(r.data.cas_number?` (${r.data.cas_number})`:``)};a(e=>({...e,[i.value]:i})),l(i),s(!1),n(t,r.data.id)}catch(e){console.error(`Error creating chemical:`,e)}}})]})}function SR(e){return/\/l\/\d+$/.test(e)}function CR(e){let t=e.match(/\/l\/(\d+)$/);return t?parseInt(t[1],10):null}var wR=[{value:`g`,label:`Gram`},{value:`kg`,label:`Kilogram`},{value:`lb`,label:`US pound`},{value:`mc`,label:`Microgram`},{value:`mg`,label:`Milligram`},{value:`oz`,label:`Ounce`},{value:`to`,label:`Tonnes`},{value:`ton`,label:`US ton`},{value:`"3`,label:`Cubic inch`},{value:`ccm`,label:`Cubic centimeter`},{value:`cl`,label:`Centiliter`},{value:`dm3`,label:`Cubic decimeter`},{value:`foz`,label:`Fluid Ounce Us`},{value:`ft3`,label:`Cubic foot`},{value:`gal`,label:`US gallon`},{value:`hl`,label:`Hectoliter`},{value:`kit`,label:`Kit`},{value:`l`,label:`Liter`},{value:`m3`,label:`Cubic meter`},{value:`ml`,label:`Mililiter`},{value:`mm3`,label:`Cubic milimeter`},{value:`pc`,label:`Item`},{value:`pce`,label:`Piece`},{value:`pt`,label:`Pint, US liquid`},{value:`qt`,label:`Quart, US liquid`},{value:`yd3`,label:`Cubic Yard`},{value:`µl`,label:`Microliter`}].sort((e,t)=>e.label.localeCompare(t.label));function TR({room:e,barcode:t,resetForm:n,location:r,setLocation:i}){let{user:a}=(0,d.useContext)(v),{environment:o}=(0,g.useParams)(),[s,c]=(0,d.useState)(null),l=new Date;l.setFullYear(l.getFullYear()+5);let{register:u,control:m,handleSubmit:h,watch:_,setValue:y,formState:{errors:b,isSubmitting:x}}=Ed({defaultValues:{expire_date:l.toISOString().split(`T`)[0],owner:{value:a?.id,label:a?.full_name}}}),S=_(`location`);(0,d.useEffect)(()=>{S&&le({id:S}).then(e=>{i(e)})},[S]),(0,d.useEffect)(()=>{let e=``,t=t=>{if(!(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement)&&!(t.key.length>1&&t.key!==`Enter`))if(t.key===`Enter`){if(SR(e)){let t=CR(e);t!==null&&(le({id:t}).then(e=>{i(e)}),y(`location`,t))}e.startsWith(`reset-scan-location`)&&w(),e=``}else e+=t.key};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[y]);let C=async e=>{if(e.user=e.owner.value,(await E({qrCodeContent:t})).items.length>0){alert(`This barcode is already registered to a container`);return}let n=await f.default.post(`create/chemical/container`,e);c(n.data),await f.default.post(`create/chemical/container/external-label`,{container:n.data.id,qr_code_content:t})},w=()=>{i(null),y(`location`,0)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(H,{onSubmit:h(C),children:[!r&&(0,p.jsx)(yR,{room:e,control:m,name:`location`}),r&&(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Scanned location`}),(0,p.jsx)(Ur,{children:(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`span`,{className:`h1`,children:r.name}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(vR,{value:`reset-scan-location`,size:100,onClick:()=>w()}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset location`})]})]})})]}),r&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(xR,{control:m,errors:b,setValue:y,...u(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Wb,{control:m,...u(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Concentration`}),(0,p.jsxs)(Ps,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...u(`concentration`,{required:`An concentration is required`}),isInvalid:b.concentration!==void 0}),b.concentration&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:b.concentration.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Amount`}),(0,p.jsxs)(Ps,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...u(`amount`,{required:`An amount is required`}),isInvalid:b.amount!==void 0}),(0,p.jsx)(vu,{name:`amount_unit`,control:m,render:({field:e})=>(0,p.jsxs)(ls,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(ss.Item,{eventKey:``,children:`(no unit)`},0),wR.map(e=>(0,p.jsxs)(ss.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),b.amount&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:b.amount.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Expire date`}),(0,p.jsx)(H.Control,{type:`date`,...u(`expire_date`,{required:`An expire date is required`}),isInvalid:b.expire_date!==void 0}),b.expire_date&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:b.expire_date.message})]}),(0,p.jsxs)(B,{type:`submit`,variant:`primary`,disabled:x,children:[x&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Register container`]})]})]}),s&&(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(vr,{variant:`success`,children:`Container registered successfully`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${o}/chemical/container/details/${s.id}/general.html`,children:`Go to container`})}),(0,p.jsx)(vR,{value:`reset-form`,size:100,className:`float-end`,onClick:()=>n()})]})]})]})}function ER({control:e,errors:t}){let[n,r]=(0,d.useState)({}),i=(e,t)=>{try{D({query:e}).then(e=>{let i=e.items.map(e=>({value:e.id,label:e.name})),a={...n};i.forEach(e=>{a[e.value]=e}),r(a),t(i)})}catch(e){console.error(`Error fetching types:`,e)}},a=e=>n[e]||null;return(0,p.jsx)(vu,{name:`container_type`,control:e,render:({field:e})=>(0,p.jsx)(Vb,{isSearchable:!0,defaultOptions:!0,placeholder:`— Select a container type`,loadOptions:i,value:a(e.value),onChange:t=>{e.onChange(t?.value)},styles:Ub})})}function DR({room:e,resetForm:t,location:n,setLocation:r}){let{user:i}=(0,d.useContext)(v),{environment:a}=(0,g.useParams)(),[o,s]=(0,d.useState)(null),c=new Date;c.setFullYear(c.getFullYear()+5);let{register:l,control:u,handleSubmit:m,watch:h,setValue:_,formState:{errors:y,isSubmitting:b}}=Ed({defaultValues:{expire_date:c.toISOString().split(`T`)[0],owner:{value:i?.id,label:i?.full_name}}}),x=h(`location`);(0,d.useEffect)(()=>{x&&le({id:x}).then(e=>{r(e)})},[x]),(0,d.useEffect)(()=>{let e=``,t=t=>{if(!(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement)&&!(t.key.length>1&&t.key!==`Enter`))if(t.key===`Enter`){if(SR(e)){let t=CR(e);t!==null&&(le({id:t}).then(e=>{r(e)}),_(`location`,t))}e.startsWith(`reset-scan-location`)&&C(),e=``}else e+=t.key};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[_]);let S=async e=>{e.user=e.owner.value,s((await f.default.post(`create/chemical/container`,e)).data)},C=()=>{r(null),_(`location`,0)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(H,{onSubmit:m(S),children:[!n&&(0,p.jsx)(yR,{room:e,control:u,name:`location`}),n&&(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Scanned location`}),(0,p.jsx)(Ur,{children:(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`span`,{className:`h1`,children:n.name}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(vR,{value:`reset-scan-location`,size:100,onClick:()=>C()}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset location`})]})]})})]}),n&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(xR,{control:u,errors:y,setValue:_,...l(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Wb,{control:u,...l(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Concentration`}),(0,p.jsxs)(Ps,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...l(`concentration`,{required:`An concentration is required`}),isInvalid:y.concentration!==void 0}),y.concentration&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:y.concentration.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Amount`}),(0,p.jsxs)(Ps,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...l(`amount`,{required:`An amount is required`}),isInvalid:y.amount!==void 0}),(0,p.jsx)(vu,{name:`amount_unit`,control:u,render:({field:e})=>(0,p.jsxs)(ls,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(ss.Item,{eventKey:``,children:`(no unit)`},0),wR.map(e=>(0,p.jsxs)(ss.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),y.amount&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:y.amount.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(H.Label,{children:`Container type`}),(0,p.jsx)(ER,{control:u,...l(`container_type`,{required:`Container type is required`}),errors:y}),y.container_type&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:y.container_type.message})]}),(0,p.jsxs)(H.Group,{className:`mb-3 w-50 w-25-sm`,children:[(0,p.jsx)(H.Label,{children:`Expire date`}),(0,p.jsx)(H.Control,{type:`date`,...l(`expire_date`,{required:`An expire date is required`}),isInvalid:y.expire_date!==void 0}),y.expire_date&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:y.expire_date.message})]}),(0,p.jsxs)(B,{type:`submit`,variant:`primary`,disabled:b,children:[b&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Register container`]})]})]}),o&&(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(vr,{variant:`success`,children:`Container registered successfully`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${a}/chemical/container/render/single-${o.id}.pdf`,children:`Print label`})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${a}/chemical/container/details/${o.id}/general.html`,children:`Go to container`})}),(0,p.jsx)(vR,{value:`reset-form`,size:100,className:`float-end`,onClick:()=>t()})]})]})]})}function OR(){let{environment:e}=(0,g.useParams)(),[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(!1),[f,m]=(0,d.useState)(null),[h,_]=(0,d.useState)(null),{control:v,watch:y,reset:b,setValue:x}=Ed({defaultValues:{room:f,barcode:``}}),S=y(`room`);(0,d.useEffect)(()=>{S&&(m(S),u(S.building.site.has_external_chemical_labelling))},[S]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`);e&&ue({id:parseInt(e)}).then(e=>{m(e),u(e.building.site.has_external_chemical_labelling),x(`room`,e)})},[x]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`location`);e&&le({id:parseInt(e)}).then(e=>{_(e),m(e.zone_group.room),u(e.zone_group.room.building.site.has_external_chemical_labelling),x(`room`,e.zone_group.room)})},[x]);let C=y(`barcode`);(0,d.useEffect)(()=>{let e=setTimeout(()=>{if(!C?.includes(`/l/`)){if(C?.includes(`/cc/`)){n(C);let e=C.split(`/cc/`)[1];T({id:parseInt(e)}).then(e=>{o(e)})}C&&(n(C),D({barcode:C}))}},1e3);return()=>{clearTimeout(e)}},[C,b]),(0,d.useEffect)(()=>{let e=``,t=t=>{t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement||t.key.length>1&&t.key!==`Enter`||(t.key===`Enter`?(e===`reset-form`&&w(),e=``):e+=t.key)};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[b]);let w=()=>{b({room:f,barcode:``}),n(null),_(null)};async function D({barcode:e}){try{let t=await E({qrCodeContent:e});t&&Array.isArray(t.items)&&t.items.length>0?(i(t.items),c(!1)):(c(!0),i([]))}catch(e){console.error(`Error fetching chemical container external labels`,e),i([]),c(!1)}}return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(WL,{control:v,name:`room`}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(vR,{value:`reset-form`,size:100,className:`float-end`,onClick:()=>w()}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset form`})]})]}),f&&l&&(0,p.jsxs)(vr,{children:[`Lab `,f.name,` has external labels, each chemical material should have a material from the internal supplier/warehouse`]}),f&&!l&&(0,p.jsxs)(vr,{children:[`Lab `,f.name,` has no external labels, labels can be printed via the intake form`]}),f!==null&&!t&&l&&(0,p.jsx)(GL,{control:v}),t&&a&&(0,p.jsxs)(vr,{variant:`info d-flex flex-column gap-3`,children:[`This is already an own chemical material, this is `,a.chemical.name,` and should be stored on`,` `,a.location.name,` in `,a.location.zone_group.room.name,(0,p.jsx)(`a`,{className:`alert-link`,href:`${e}/chemical/container/details/${a.id}/general.html`,children:`Go to container`})]}),!a&&t&&(0,p.jsx)(p.Fragment,{children:r.length===0?(0,p.jsx)(vr,{variant:`info d-flex flex-column gap-3`,children:(0,p.jsxs)(`div`,{children:[`No chemical container external labels found with label `,(0,p.jsx)(`strong`,{children:t})]})}):(0,p.jsxs)(kl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`Label`}),(0,p.jsx)(`th`,{children:`Container`}),(0,p.jsx)(`th`,{children:`Location`})]})}),(0,p.jsx)(`tbody`,{children:r.map(t=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:t.id}),(0,p.jsx)(`td`,{children:t.label}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${e}/chemical/container/details/${t.container.id}/general.html`,children:t.container.chemical.name})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${e}/location/details/${t.container.location.id}/general.html`,children:t.container.location.name})})]},t.id))})]})}),!a&&s&&f&&t&&(0,p.jsx)(TR,{room:f,barcode:t,location:h,setLocation:_,resetForm:w}),!a&&f&&!l&&(0,p.jsx)(DR,{room:f,location:h,setLocation:_,resetForm:w})]})}function kR({badge_uuid:e}){return(0,p.jsxs)(`span`,{className:`rounded p-2 bg-success`,children:[`Card read: `,e]})}function AR({user_id:e}){let[t,n]=(0,d.useState)(``);return(0,d.useEffect)(()=>{let t=`https://`+NR+`/api/onelab/view/user/${e}`;(async()=>{try{let e=await fetch(t);if(!e.ok)throw Error(`Response status: ${e.status} with body: ${await e.text()}`);n((await e.json()).full_name)}catch(e){console.log(e)}})()},[]),(0,p.jsxs)(`span`,{className:`rounded p-2 bg-success`,children:[`Clients has detected user: `,t||`loading...`]})}function jR(){return(0,p.jsx)(`div`,{})}var MR=[`all`,`equipment`,`not_set`],NR=document.getElementById(`root`)?.dataset.goldsteinEndpoint??``,PR=`mock-token`,FR=10,IR=15;async function LR(e){let t=`https://`+NR+`/api/update/client-association`,n=prompt(`Select the new association for the client:`,e);if(n===null){alert(`Please enter a not null value`);return}let[r,i]=n.split(`:`),a=Number(i);if(!r||isNaN(a)||a===0){alert(`Please follow the correct format: $item:$id`);return}if(!MR.slice(1).includes(r)){alert(`Please select a valid $item: (equipment, not_set)`);return}let o=await fetch(t,{method:`PATCH`,body:JSON.stringify({previous_association:e,new_association:n}),headers:{"Content-type":`application/json; charset=UTF-8`}});if(!o.ok)throw Error(`Response status: ${o.status} with body: ${await o.text()}`);let s=await o.text();alert(s)}function RR(){let e=(0,d.useRef)(null),[t,n]=(0,d.useState)(new Map);async function r(e){n(Av(e.notifications_list,new Date,FR,IR))}function i(){let t=`
|
|
36
|
+
`+Error().stack),r=!1}return t.apply(this,arguments)},t)}var E={};function D(e,t){n.deprecationHandler!=null&&n.deprecationHandler(e,t),E[e]||(w(t),E[e]=!0)}n.suppressDeprecationWarnings=!1,n.deprecationHandler=null;function O(e){return typeof Function<`u`&&e instanceof Function||Object.prototype.toString.call(e)===`[object Function]`}function k(e){var t,n;for(n in e)o(e,n)&&(t=e[n],O(t)?this[n]=t:this[`_`+n]=t);this._config=e,this._dayOfMonthOrdinalParseLenient=RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+`|\\d{1,2}`)}function A(e,t){var n=f({},e),r;for(r in t)o(t,r)&&(a(e[r])&&a(t[r])?(n[r]={},f(n[r],e[r]),f(n[r],t[r])):t[r]==null?delete n[r]:n[r]=t[r]);for(r in e)o(e,r)&&!o(t,r)&&a(e[r])&&(n[r]=f({},n[r]));return n}function j(e){e!=null&&this.set(e)}var M=Object.keys?Object.keys:function(e){var t,n=[];for(t in e)o(e,t)&&n.push(t);return n},ee={sameDay:`[Today at] LT`,nextDay:`[Tomorrow at] LT`,nextWeek:`dddd [at] LT`,lastDay:`[Yesterday at] LT`,lastWeek:`[Last] dddd [at] LT`,sameElse:`L`};function te(e,t,n){var r=this._calendar[e]||this._calendar.sameElse;return O(r)?r.call(t,n):r}function N(e,t,n){var r=``+Math.abs(e),i=t-r.length;return(e>=0?n?`+`:``:`-`)+(10**Math.max(0,i)).toString().substr(1)+r}var ne=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,re=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,ie={},ae={};function P(e,t,n,r){var i=r;typeof r==`string`&&(i=function(){return this[r]()}),e&&(ae[e]=i),t&&(ae[t[0]]=function(){return N(i.apply(this,arguments),t[1],t[2])}),n&&(ae[n]=function(){return this.localeData().ordinal(i.apply(this,arguments),e)})}function oe(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,``):e.replace(/\\/g,``)}function se(e){var t=e.match(ne),n,r;for(n=0,r=t.length;n<r;n++)ae[t[n]]?t[n]=ae[t[n]]:t[n]=oe(t[n]);return function(n){var i=``,a;for(a=0;a<r;a++)i+=O(t[a])?t[a].call(n,e):t[a];return i}}function ce(e,t){return e.isValid()?(t=le(t,e.localeData()),ie[t]=ie[t]||se(t),ie[t](e)):e.localeData().invalidDate()}function le(e,t){var n=5;function r(e){return t.longDateFormat(e)||e}for(re.lastIndex=0;n>=0&&re.test(e);)e=e.replace(re,r),re.lastIndex=0,--n;return e}var ue={LTS:`h:mm:ss A`,LT:`h:mm A`,L:`MM/DD/YYYY`,LL:`MMMM D, YYYY`,LLL:`MMMM D, YYYY h:mm A`,LLLL:`dddd, MMMM D, YYYY h:mm A`};function de(e){var t=this._longDateFormat[e],n=this._longDateFormat[e.toUpperCase()];return t||!n?t:(this._longDateFormat[e]=n.match(ne).map(function(e){return e===`MMMM`||e===`MM`||e===`DD`||e===`dddd`?e.slice(1):e}).join(``),this._longDateFormat[e])}var fe=`Invalid date`;function pe(){return this._invalidDate}var me=`%d`,he=/\d{1,2}/;function ge(e){return this._ordinal.replace(`%d`,e)}var _e={future:`in %s`,past:`%s ago`,s:`a few seconds`,ss:`%d seconds`,m:`a minute`,mm:`%d minutes`,h:`an hour`,hh:`%d hours`,d:`a day`,dd:`%d days`,w:`a week`,ww:`%d weeks`,M:`a month`,MM:`%d months`,y:`a year`,yy:`%d years`};function ve(e,t,n,r){var i=this._relativeTime[n];return O(i)?i(e,t,n,r):i.replace(/%d/i,e)}function ye(e,t){var n=this._relativeTime[e>0?`future`:`past`];return O(n)?n(t):n.replace(/%s/i,t)}var be={D:`date`,dates:`date`,date:`date`,d:`day`,days:`day`,day:`day`,e:`weekday`,weekdays:`weekday`,weekday:`weekday`,E:`isoWeekday`,isoweekdays:`isoWeekday`,isoweekday:`isoWeekday`,DDD:`dayOfYear`,dayofyears:`dayOfYear`,dayofyear:`dayOfYear`,h:`hour`,hours:`hour`,hour:`hour`,ms:`millisecond`,milliseconds:`millisecond`,millisecond:`millisecond`,m:`minute`,minutes:`minute`,minute:`minute`,M:`month`,months:`month`,month:`month`,Q:`quarter`,quarters:`quarter`,quarter:`quarter`,s:`second`,seconds:`second`,second:`second`,gg:`weekYear`,weekyears:`weekYear`,weekyear:`weekYear`,GG:`isoWeekYear`,isoweekyears:`isoWeekYear`,isoweekyear:`isoWeekYear`,w:`week`,weeks:`week`,week:`week`,W:`isoWeek`,isoweeks:`isoWeek`,isoweek:`isoWeek`,y:`year`,years:`year`,year:`year`};function xe(e){return typeof e==`string`?be[e]||be[e.toLowerCase()]:void 0}function Se(e){var t={},n,r;for(r in e)o(e,r)&&(n=xe(r),n&&(t[n]=e[r]));return t}var Ce={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function we(e){var t=[],n;for(n in e)o(e,n)&&t.push({unit:n,priority:Ce[n]});return t.sort(function(e,t){return e.priority-t.priority}),t}var Te=/\d/,Ee=/\d\d/,De=/\d{3}/,Oe=/\d{4}/,ke=/[+-]?\d{6}/,Ae=/\d\d?/,je=/\d\d\d\d?/,Me=/\d\d\d\d\d\d?/,Ne=/\d{1,3}/,Pe=/\d{1,4}/,Fe=/[+-]?\d{1,6}/,Ie=/\d+/,Le=/[+-]?\d+/,Re=/Z|[+-]\d\d:?\d\d/gi,ze=/Z|[+-]\d\d(?::?\d\d)?/gi,Be=/[+-]?\d+(\.\d{1,3})?/,Ve=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,He=/^[1-9]\d?/,Ue=/^([1-9]\d|\d)/,We={};function F(e,t,n){We[e]=O(t)?t:function(e,r){return e&&n?n:t}}function Ge(e,t){return o(We,e)?We[e](t._strict,t._locale):new RegExp(Ke(e))}function Ke(e){return qe(e.replace(`\\`,``).replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,t,n,r,i){return t||n||r||i}))}function qe(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,`\\$&`)}function Je(e){return e<0?Math.ceil(e)||0:Math.floor(e)}function Ye(e){var t=+e,n=0;return t!==0&&isFinite(t)&&(n=Je(t)),n}var Xe={};function Ze(e,t){var n,r=t,i;for(typeof e==`string`&&(e=[e]),l(t)&&(r=function(e,n){n[t]=Ye(e)}),i=e.length,n=0;n<i;n++)Xe[e[n]]=r}function Qe(e,t){Ze(e,function(e,n,r,i){r._w=r._w||{},t(e,r._w,r,i)})}function $e(e,t,n){t!=null&&o(Xe,e)&&Xe[e](t,n._a,n,e)}function et(e){return e%4==0&&e%100!=0||e%400==0}var tt=0,nt=1,rt=2,it=3,at=4,ot=5,st=6,ct=7,lt=8;P(`Y`,0,0,function(){var e=this.year();return e<=9999?N(e,4):`+`+e}),P(0,[`YY`,2],0,function(){return this.year()%100}),P(0,[`YYYY`,4],0,`year`),P(0,[`YYYYY`,5],0,`year`),P(0,[`YYYYYY`,6,!0],0,`year`),F(`Y`,Le),F(`YY`,Ae,Ee),F(`YYYY`,Pe,Oe),F(`YYYYY`,Fe,ke),F(`YYYYYY`,Fe,ke),Ze([`YYYYY`,`YYYYYY`],tt),Ze(`YYYY`,function(e,t){t[tt]=e.length===2?n.parseTwoDigitYear(e):Ye(e)}),Ze(`YY`,function(e,t){t[tt]=n.parseTwoDigitYear(e)}),Ze(`Y`,function(e,t){t[tt]=parseInt(e,10)});function ut(e){return et(e)?366:365}n.parseTwoDigitYear=function(e){return Ye(e)+(Ye(e)>68?1900:2e3)};var dt=pt(`FullYear`,!0);function ft(){return et(this.year())}function pt(e,t){return function(r){return r==null?mt(this,e):(ht(this,e,r),n.updateOffset(this,t),this)}}function mt(e,t){if(!e.isValid())return NaN;var n=e._d,r=e._isUTC;switch(t){case`Milliseconds`:return r?n.getUTCMilliseconds():n.getMilliseconds();case`Seconds`:return r?n.getUTCSeconds():n.getSeconds();case`Minutes`:return r?n.getUTCMinutes():n.getMinutes();case`Hours`:return r?n.getUTCHours():n.getHours();case`Date`:return r?n.getUTCDate():n.getDate();case`Day`:return r?n.getUTCDay():n.getDay();case`Month`:return r?n.getUTCMonth():n.getMonth();case`FullYear`:return r?n.getUTCFullYear():n.getFullYear();default:return NaN}}function ht(e,t,n){var r,i,a,o,s;if(!(!e.isValid()||isNaN(n))){switch(r=e._d,i=e._isUTC,t){case`Milliseconds`:i?r.setUTCMilliseconds(n):r.setMilliseconds(n);return;case`Seconds`:i?r.setUTCSeconds(n):r.setSeconds(n);return;case`Minutes`:i?r.setUTCMinutes(n):r.setMinutes(n);return;case`Hours`:i?r.setUTCHours(n):r.setHours(n);return;case`Date`:i?r.setUTCDate(n):r.setDate(n);return;case`FullYear`:break;default:return}a=n,o=e.month(),s=e.date(),s=s===29&&o===1&&!et(a)?28:s,i?r.setUTCFullYear(a,o,s):r.setFullYear(a,o,s)}}function gt(e){return e=xe(e),O(this[e])?this[e]():this}function _t(e,t){if(typeof e==`object`){e=Se(e);var n=we(e),r,i=n.length;for(r=0;r<i;r++)this[n[r].unit](e[n[r].unit])}else if(e=xe(e),O(this[e]))return this[e](t);return this}function vt(e,t){return(e%t+t)%t}var yt=Array.prototype.indexOf?Array.prototype.indexOf:function(e){var t;for(t=0;t<this.length;++t)if(this[t]===e)return t;return-1};function bt(e,t){if(isNaN(e)||isNaN(t))return NaN;var n=vt(t,12);return e+=(t-n)/12,n===1?et(e)?29:28:31-n%7%2}P(`M`,[`MM`,2],`Mo`,function(){return this.month()+1}),P(`MMM`,0,0,function(e){return this.localeData().monthsShort(this,e)}),P(`MMMM`,0,0,function(e){return this.localeData().months(this,e)}),F(`M`,Ae,He),F(`MM`,Ae,Ee),F(`MMM`,function(e,t){return t.monthsShortRegex(e)}),F(`MMMM`,function(e,t){return t.monthsRegex(e)}),Ze([`M`,`MM`],function(e,t){t[nt]=Ye(e)-1}),Ze([`MMM`,`MMMM`],function(e,t,n,r){var i=n._locale.monthsParse(e,r,n._strict);i==null?h(n).invalidMonth=e:t[nt]=i});var xt=`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),St=`Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec`.split(`_`),Ct=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,wt=Ve,Tt=Ve;function I(e,t){return e?i(this._months)?this._months[e.month()]:this._months[(this._months.isFormat||Ct).test(t)?`format`:`standalone`][e.month()]:i(this._months)?this._months:this._months.standalone}function Et(e,t){return e?i(this._monthsShort)?this._monthsShort[e.month()]:this._monthsShort[Ct.test(t)?`format`:`standalone`][e.month()]:i(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Dt(e,t,n){var r,i,a,o=e.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],r=0;r<12;++r)a=p([2e3,r]),this._shortMonthsParse[r]=this.monthsShort(a,``).toLocaleLowerCase(),this._longMonthsParse[r]=this.months(a,``).toLocaleLowerCase();return n?t===`MMM`?(i=yt.call(this._shortMonthsParse,o),i===-1?null:i):(i=yt.call(this._longMonthsParse,o),i===-1?null:i):t===`MMM`?(i=yt.call(this._shortMonthsParse,o),i===-1?(i=yt.call(this._longMonthsParse,o),i===-1?null:i):i):(i=yt.call(this._longMonthsParse,o),i===-1?(i=yt.call(this._shortMonthsParse,o),i===-1?null:i):i)}function Ot(e,t,n){var r,i,a;if(this._monthsParseExact)return Dt.call(this,e,t,n);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),r=0;r<12;r++)if(i=p([2e3,r]),n&&!this._longMonthsParse[r]&&(this._longMonthsParse[r]=RegExp(`^`+this.months(i,``).replace(`.`,``)+`$`,`i`),this._shortMonthsParse[r]=RegExp(`^`+this.monthsShort(i,``).replace(`.`,``)+`$`,`i`)),!n&&!this._monthsParse[r]&&(a=`^`+this.months(i,``)+`|^`+this.monthsShort(i,``),this._monthsParse[r]=new RegExp(a.replace(`.`,``),`i`)),n&&t===`MMMM`&&this._longMonthsParse[r].test(e)||n&&t===`MMM`&&this._shortMonthsParse[r].test(e)||!n&&this._monthsParse[r].test(e))return r}function kt(e,t){if(!e.isValid())return e;if(typeof t==`string`){if(/^\d+$/.test(t))t=Ye(t);else if(t=e.localeData().monthsParse(t),!l(t))return e}var n=t,r=e.date();return r=r<29?r:Math.min(r,bt(e.year(),n)),e._isUTC?e._d.setUTCMonth(n,r):e._d.setMonth(n,r),e}function At(e){return e==null?mt(this,`Month`):(kt(this,e),n.updateOffset(this,!0),this)}function jt(){return bt(this.year(),this.month())}function Mt(e){return this._monthsParseExact?(o(this,`_monthsRegex`)||Pt.call(this),e?this._monthsShortStrictRegex:this._monthsShortRegex):(o(this,`_monthsShortRegex`)||(this._monthsShortRegex=wt),this._monthsShortStrictRegex&&e?this._monthsShortStrictRegex:this._monthsShortRegex)}function Nt(e){return this._monthsParseExact?(o(this,`_monthsRegex`)||Pt.call(this),e?this._monthsStrictRegex:this._monthsRegex):(o(this,`_monthsRegex`)||(this._monthsRegex=Tt),this._monthsStrictRegex&&e?this._monthsStrictRegex:this._monthsRegex)}function Pt(){function e(e,t){return t.length-e.length}var t=[],n=[],r=[],i,a,o,s;for(i=0;i<12;i++)a=p([2e3,i]),o=qe(this.monthsShort(a,``)),s=qe(this.months(a,``)),t.push(o),n.push(s),r.push(s),r.push(o);t.sort(e),n.sort(e),r.sort(e),this._monthsRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`),this._monthsShortStrictRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`)}function Ft(e,t,n,r,i,a,o){var s;return e<100&&e>=0?(s=new Date(e+400,t,n,r,i,a,o),isFinite(s.getFullYear())&&s.setFullYear(e)):s=new Date(e,t,n,r,i,a,o),s}function It(e){var t,n;return e<100&&e>=0?(n=Array.prototype.slice.call(arguments),n[0]=e+400,t=new Date(Date.UTC.apply(null,n)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(e)):t=new Date(Date.UTC.apply(null,arguments)),t}function Lt(e,t,n){var r=7+t-n;return-((7+It(e,0,r).getUTCDay()-t)%7)+r-1}function L(e,t,n,r,i){var a=(7+n-r)%7,o=Lt(e,r,i),s=1+7*(t-1)+a+o,c,l;return s<=0?(c=e-1,l=ut(c)+s):s>ut(e)?(c=e+1,l=s-ut(e)):(c=e,l=s),{year:c,dayOfYear:l}}function Rt(e,t,n){var r=Lt(e.year(),t,n),i=Math.floor((e.dayOfYear()-r-1)/7)+1,a,o;return i<1?(o=e.year()-1,a=i+zt(o,t,n)):i>zt(e.year(),t,n)?(a=i-zt(e.year(),t,n),o=e.year()+1):(o=e.year(),a=i),{week:a,year:o}}function zt(e,t,n){var r=Lt(e,t,n),i=Lt(e+1,t,n);return(ut(e)-r+i)/7}P(`w`,[`ww`,2],`wo`,`week`),P(`W`,[`WW`,2],`Wo`,`isoWeek`),F(`w`,Ae,He),F(`ww`,Ae,Ee),F(`W`,Ae,He),F(`WW`,Ae,Ee),Qe([`w`,`ww`,`W`,`WW`],function(e,t,n,r){t[r.substr(0,1)]=Ye(e)});function Bt(e){return Rt(e,this._week.dow,this._week.doy).week}var R={dow:0,doy:6};function Vt(){return this._week.dow}function Ht(){return this._week.doy}function Ut(e){var t=this.localeData().week(this);return e==null?t:this.add((e-t)*7,`d`)}function Wt(e){var t=Rt(this,1,4).week;return e==null?t:this.add((e-t)*7,`d`)}P(`d`,0,`do`,`day`),P(`dd`,0,0,function(e){return this.localeData().weekdaysMin(this,e)}),P(`ddd`,0,0,function(e){return this.localeData().weekdaysShort(this,e)}),P(`dddd`,0,0,function(e){return this.localeData().weekdays(this,e)}),P(`e`,0,0,`weekday`),P(`E`,0,0,`isoWeekday`),F(`d`,Ae),F(`e`,Ae),F(`E`,Ae),F(`dd`,function(e,t){return t.weekdaysMinRegex(e)}),F(`ddd`,function(e,t){return t.weekdaysShortRegex(e)}),F(`dddd`,function(e,t){return t.weekdaysRegex(e)}),Qe([`dd`,`ddd`,`dddd`],function(e,t,n,r){var i=n._locale.weekdaysParse(e,r,n._strict);i==null?h(n).invalidWeekday=e:t.d=i}),Qe([`d`,`e`,`E`],function(e,t,n,r){t[r]=Ye(e)});function Gt(e,t){return typeof e==`string`?isNaN(e)?(e=t.weekdaysParse(e),typeof e==`number`?e:null):parseInt(e,10):e}function Kt(e,t){return typeof e==`string`?t.weekdaysParse(e)%7||7:isNaN(e)?null:e}function qt(e,t){return e.slice(t,7).concat(e.slice(0,t))}var Jt=`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),Yt=`Sun_Mon_Tue_Wed_Thu_Fri_Sat`.split(`_`),Xt=`Su_Mo_Tu_We_Th_Fr_Sa`.split(`_`),Zt=Ve,Qt=Ve,$t=Ve;function en(e,t){var n=i(this._weekdays)?this._weekdays:this._weekdays[e&&e!==!0&&this._weekdays.isFormat.test(t)?`format`:`standalone`];return e===!0?qt(n,this._week.dow):e?n[e.day()]:n}function tn(e){return e===!0?qt(this._weekdaysShort,this._week.dow):e?this._weekdaysShort[e.day()]:this._weekdaysShort}function nn(e){return e===!0?qt(this._weekdaysMin,this._week.dow):e?this._weekdaysMin[e.day()]:this._weekdaysMin}function rn(e,t,n){var r,i,a,o=e.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],r=0;r<7;++r)a=p([2e3,1]).day(r),this._minWeekdaysParse[r]=this.weekdaysMin(a,``).toLocaleLowerCase(),this._shortWeekdaysParse[r]=this.weekdaysShort(a,``).toLocaleLowerCase(),this._weekdaysParse[r]=this.weekdays(a,``).toLocaleLowerCase();return n?t===`dddd`?(i=yt.call(this._weekdaysParse,o),i===-1?null:i):t===`ddd`?(i=yt.call(this._shortWeekdaysParse,o),i===-1?null:i):(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i):t===`dddd`?(i=yt.call(this._weekdaysParse,o),i!==-1||(i=yt.call(this._shortWeekdaysParse,o),i!==-1)?i:(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i)):t===`ddd`?(i=yt.call(this._shortWeekdaysParse,o),i!==-1||(i=yt.call(this._weekdaysParse,o),i!==-1)?i:(i=yt.call(this._minWeekdaysParse,o),i===-1?null:i)):(i=yt.call(this._minWeekdaysParse,o),i!==-1||(i=yt.call(this._weekdaysParse,o),i!==-1)?i:(i=yt.call(this._shortWeekdaysParse,o),i===-1?null:i))}function an(e,t,n){var r,i,a;if(this._weekdaysParseExact)return rn.call(this,e,t,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),r=0;r<7;r++)if(i=p([2e3,1]).day(r),n&&!this._fullWeekdaysParse[r]&&(this._fullWeekdaysParse[r]=RegExp(`^`+this.weekdays(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._shortWeekdaysParse[r]=RegExp(`^`+this.weekdaysShort(i,``).replace(`.`,`\\.?`)+`$`,`i`),this._minWeekdaysParse[r]=RegExp(`^`+this.weekdaysMin(i,``).replace(`.`,`\\.?`)+`$`,`i`)),this._weekdaysParse[r]||(a=`^`+this.weekdays(i,``)+`|^`+this.weekdaysShort(i,``)+`|^`+this.weekdaysMin(i,``),this._weekdaysParse[r]=new RegExp(a.replace(`.`,``),`i`)),n&&t===`dddd`&&this._fullWeekdaysParse[r].test(e)||n&&t===`ddd`&&this._shortWeekdaysParse[r].test(e)||n&&t===`dd`&&this._minWeekdaysParse[r].test(e)||!n&&this._weekdaysParse[r].test(e))return r}function on(e){if(!this.isValid())return e==null?NaN:this;var t=mt(this,`Day`);return e==null?t:(e=Gt(e,this.localeData()),this.add(e-t,`d`))}function sn(e){if(!this.isValid())return e==null?NaN:this;var t=(this.day()+7-this.localeData()._week.dow)%7;return e==null?t:this.add(e-t,`d`)}function cn(e){if(!this.isValid())return e==null?NaN:this;if(e!=null){var t=Kt(e,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function ln(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||z.call(this),e?this._weekdaysStrictRegex:this._weekdaysRegex):(o(this,`_weekdaysRegex`)||(this._weekdaysRegex=Zt),this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex)}function un(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||z.call(this),e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(o(this,`_weekdaysShortRegex`)||(this._weekdaysShortRegex=Qt),this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function dn(e){return this._weekdaysParseExact?(o(this,`_weekdaysRegex`)||z.call(this),e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(o(this,`_weekdaysMinRegex`)||(this._weekdaysMinRegex=$t),this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function z(){function e(e,t){return t.length-e.length}var t=[],n=[],r=[],i=[],a,o,s,c,l;for(a=0;a<7;a++)o=p([2e3,1]).day(a),s=qe(this.weekdaysMin(o,``)),c=qe(this.weekdaysShort(o,``)),l=qe(this.weekdays(o,``)),t.push(s),n.push(c),r.push(l),i.push(s),i.push(c),i.push(l);t.sort(e),n.sort(e),r.sort(e),i.sort(e),this._weekdaysRegex=RegExp(`^(`+i.join(`|`)+`)`,`i`),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._weekdaysShortStrictRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`),this._weekdaysMinStrictRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`)}function fn(){return this.hours()%12||12}function pn(){return this.hours()||24}P(`H`,[`HH`,2],0,`hour`),P(`h`,[`hh`,2],0,fn),P(`k`,[`kk`,2],0,pn),P(`hmm`,0,0,function(){return``+fn.apply(this)+N(this.minutes(),2)}),P(`hmmss`,0,0,function(){return``+fn.apply(this)+N(this.minutes(),2)+N(this.seconds(),2)}),P(`Hmm`,0,0,function(){return``+this.hours()+N(this.minutes(),2)}),P(`Hmmss`,0,0,function(){return``+this.hours()+N(this.minutes(),2)+N(this.seconds(),2)});function mn(e,t){P(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}mn(`a`,!0),mn(`A`,!1);function hn(e,t){return t._meridiemParse}F(`a`,hn),F(`A`,hn),F(`H`,Ae,Ue),F(`h`,Ae,He),F(`k`,Ae,He),F(`HH`,Ae,Ee),F(`hh`,Ae,Ee),F(`kk`,Ae,Ee),F(`hmm`,je),F(`hmmss`,Me),F(`Hmm`,je),F(`Hmmss`,Me),Ze([`H`,`HH`],it),Ze([`k`,`kk`],function(e,t,n){var r=Ye(e);t[it]=r===24?0:r}),Ze([`a`,`A`],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),Ze([`h`,`hh`],function(e,t,n){t[it]=Ye(e),h(n).bigHour=!0}),Ze(`hmm`,function(e,t,n){var r=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r)),h(n).bigHour=!0}),Ze(`hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r,2)),t[ot]=Ye(e.substr(i)),h(n).bigHour=!0}),Ze(`Hmm`,function(e,t,n){var r=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r))}),Ze(`Hmmss`,function(e,t,n){var r=e.length-4,i=e.length-2;t[it]=Ye(e.substr(0,r)),t[at]=Ye(e.substr(r,2)),t[ot]=Ye(e.substr(i))});function gn(e){return(e+``).toLowerCase().charAt(0)===`p`}var _n=/[ap]\.?m?\.?/i,vn=pt(`Hours`,!0);function yn(e,t,n){return e>11?n?`pm`:`PM`:n?`am`:`AM`}var bn={calendar:ee,longDateFormat:ue,invalidDate:fe,ordinal:me,dayOfMonthOrdinalParse:he,relativeTime:_e,months:xt,monthsShort:St,week:R,weekdays:Jt,weekdaysMin:Xt,weekdaysShort:Yt,meridiemParse:_n},xn={},Sn={},Cn;function wn(e,t){var n,r=Math.min(e.length,t.length);for(n=0;n<r;n+=1)if(e[n]!==t[n])return n;return r}function Tn(e){return e&&e.toLowerCase().replace(`_`,`-`)}function En(e){for(var t=0,n,r,i,a;t<e.length;){for(a=Tn(e[t]).split(`-`),n=a.length,r=Tn(e[t+1]),r=r?r.split(`-`):null;n>0;){if(i=On(a.slice(0,n).join(`-`)),i)return i;if(r&&r.length>=n&&wn(a,r)>=n-1)break;n--}t++}return Cn}function Dn(e){return!!(e&&e.match(`^[^/\\\\]*$`))}function On(e){var n=null,r;if(xn[e]===void 0&&t!==void 0&&t&&t.exports&&Dn(e))try{n=Cn._abbr,r=require,r(`./locale/`+e),kn(n)}catch{xn[e]=null}return xn[e]}function kn(e,t){var n;return e&&(n=c(t)?Mn(e):An(e,t),n?Cn=n:typeof console<`u`&&console.warn&&console.warn(`Locale `+e+` not found. Did you forget to load it?`)),Cn._abbr}function An(e,t){if(t!==null){var n,r=bn;if(t.abbr=e,xn[e]!=null)D(`defineLocaleOverride`,`use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info.`),r=xn[e]._config;else if(t.parentLocale!=null)if(xn[t.parentLocale]!=null)r=xn[t.parentLocale]._config;else if(n=On(t.parentLocale),n!=null)r=n._config;else return Sn[t.parentLocale]||(Sn[t.parentLocale]=[]),Sn[t.parentLocale].push({name:e,config:t}),null;return xn[e]=new j(A(r,t)),Sn[e]&&Sn[e].forEach(function(e){An(e.name,e.config)}),kn(e),xn[e]}else return delete xn[e],null}function jn(e,t){if(t!=null){var n,r,i=bn;xn[e]!=null&&xn[e].parentLocale!=null?xn[e].set(A(xn[e]._config,t)):(r=On(e),r!=null&&(i=r._config),t=A(i,t),r??(t.abbr=e),n=new j(t),n.parentLocale=xn[e],xn[e]=n),kn(e)}else xn[e]!=null&&(xn[e].parentLocale==null?xn[e]!=null&&delete xn[e]:(xn[e]=xn[e].parentLocale,e===kn()&&kn(e)));return xn[e]}function Mn(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return Cn;if(!i(e)){if(t=On(e),t)return t;e=[e]}return En(e)}function Nn(){return M(xn)}function Pn(e){var t,n=e._a;return n&&h(e).overflow===-2&&(t=n[nt]<0||n[nt]>11?nt:n[rt]<1||n[rt]>bt(n[tt],n[nt])?rt:n[it]<0||n[it]>24||n[it]===24&&(n[at]!==0||n[ot]!==0||n[st]!==0)?it:n[at]<0||n[at]>59?at:n[ot]<0||n[ot]>59?ot:n[st]<0||n[st]>999?st:-1,h(e)._overflowDayOfYear&&(t<tt||t>rt)&&(t=rt),h(e)._overflowWeeks&&t===-1&&(t=ct),h(e)._overflowWeekday&&t===-1&&(t=lt),h(e).overflow=t),e}var Fn=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,In=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ln=/Z|[+-]\d\d(?::?\d\d)?/,Rn=[[`YYYYYY-MM-DD`,/[+-]\d{6}-\d\d-\d\d/],[`YYYY-MM-DD`,/\d{4}-\d\d-\d\d/],[`GGGG-[W]WW-E`,/\d{4}-W\d\d-\d/],[`GGGG-[W]WW`,/\d{4}-W\d\d/,!1],[`YYYY-DDD`,/\d{4}-\d{3}/],[`YYYY-MM`,/\d{4}-\d\d/,!1],[`YYYYYYMMDD`,/[+-]\d{10}/],[`YYYYMMDD`,/\d{8}/],[`GGGG[W]WWE`,/\d{4}W\d{3}/],[`GGGG[W]WW`,/\d{4}W\d{2}/,!1],[`YYYYDDD`,/\d{7}/],[`YYYYMM`,/\d{6}/,!1],[`YYYY`,/\d{4}/,!1]],zn=[[`HH:mm:ss.SSSS`,/\d\d:\d\d:\d\d\.\d+/],[`HH:mm:ss,SSSS`,/\d\d:\d\d:\d\d,\d+/],[`HH:mm:ss`,/\d\d:\d\d:\d\d/],[`HH:mm`,/\d\d:\d\d/],[`HHmmss.SSSS`,/\d\d\d\d\d\d\.\d+/],[`HHmmss,SSSS`,/\d\d\d\d\d\d,\d+/],[`HHmmss`,/\d\d\d\d\d\d/],[`HHmm`,/\d\d\d\d/],[`HH`,/\d\d/]],Bn=/^\/?Date\((-?\d+)/i,Vn=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,Hn={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Un(e){var t,n,r=e._i,i=Fn.exec(r)||In.exec(r),a,o,s,c,l=Rn.length,u=zn.length;if(i){for(h(e).iso=!0,t=0,n=l;t<n;t++)if(Rn[t][1].exec(i[1])){o=Rn[t][0],a=Rn[t][2]!==!1;break}if(o==null){e._isValid=!1;return}if(i[3]){for(t=0,n=u;t<n;t++)if(zn[t][1].exec(i[3])){s=(i[2]||` `)+zn[t][0];break}if(s==null){e._isValid=!1;return}}if(!a&&s!=null){e._isValid=!1;return}if(i[4])if(Ln.exec(i[4]))c=`Z`;else{e._isValid=!1;return}e._f=o+(s||``)+(c||``),tr(e)}else e._isValid=!1}function Wn(e,t,n,r,i,a){var o=[Gn(e),St.indexOf(t),parseInt(n,10),parseInt(r,10),parseInt(i,10)];return a&&o.push(parseInt(a,10)),o}function Gn(e){var t=parseInt(e,10);return t<=49?2e3+t:t<=999?1900+t:t}function Kn(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).replace(/^\s\s*/,``).replace(/\s\s*$/,``)}function qn(e,t,n){return e&&Yt.indexOf(e)!==new Date(t[0],t[1],t[2]).getDay()?(h(n).weekdayMismatch=!0,n._isValid=!1,!1):!0}function Jn(e,t,n){if(e)return Hn[e];if(t)return 0;var r=parseInt(n,10),i=r%100;return(r-i)/100*60+i}function Yn(e){var t=Vn.exec(Kn(e._i)),n;if(t){if(n=Wn(t[4],t[3],t[2],t[5],t[6],t[7]),!qn(t[1],n,e))return;e._a=n,e._tzm=Jn(t[8],t[9],t[10]),e._d=It.apply(null,e._a),e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),h(e).rfc2822=!0}else e._isValid=!1}function Xn(e){var t=Bn.exec(e._i);if(t!==null){e._d=new Date(+t[1]);return}if(Un(e),e._isValid===!1)delete e._isValid;else return;if(Yn(e),e._isValid===!1)delete e._isValid;else return;e._strict?e._isValid=!1:n.createFromInputFallback(e)}n.createFromInputFallback=T(`value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.`,function(e){e._d=new Date(e._i+(e._useUTC?` UTC`:``))});function Zn(e,t,n){return e??t??n}function Qn(e){var t=new Date(n.now());return e._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function $n(e){var t,n,r=[],i,a,o;if(!e._d){for(i=Qn(e),e._w&&e._a[rt]==null&&e._a[nt]==null&&er(e),e._dayOfYear!=null&&(o=Zn(e._a[tt],i[tt]),(e._dayOfYear>ut(o)||e._dayOfYear===0)&&(h(e)._overflowDayOfYear=!0),n=It(o,0,e._dayOfYear),e._a[nt]=n.getUTCMonth(),e._a[rt]=n.getUTCDate()),t=0;t<3&&e._a[t]==null;++t)e._a[t]=r[t]=i[t];for(;t<7;t++)e._a[t]=r[t]=e._a[t]==null?+(t===2):e._a[t];e._a[it]===24&&e._a[at]===0&&e._a[ot]===0&&e._a[st]===0&&(e._nextDay=!0,e._a[it]=0),e._d=(e._useUTC?It:Ft).apply(null,r),a=e._useUTC?e._d.getUTCDay():e._d.getDay(),e._tzm!=null&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[it]=24),e._w&&e._w.d!==void 0&&e._w.d!==a&&(h(e).weekdayMismatch=!0)}}function er(e){var t=e._w,n,r,i,a,o,s,c,l;t.GG!=null||t.W!=null||t.E!=null?(a=1,o=4,n=Zn(t.GG,e._a[tt],Rt(lr(),1,4).year),r=Zn(t.W,1),i=Zn(t.E,1),(i<1||i>7)&&(c=!0)):(a=e._locale._week.dow,o=e._locale._week.doy,l=Rt(lr(),a,o),n=Zn(t.gg,e._a[tt],l.year),r=Zn(t.w,l.week),t.d==null?t.e==null?i=a:(i=t.e+a,(t.e<0||t.e>6)&&(c=!0)):(i=t.d,(i<0||i>6)&&(c=!0))),r<1||r>zt(n,a,o)?h(e)._overflowWeeks=!0:c==null?(s=L(n,r,i,a,o),e._a[tt]=s.year,e._dayOfYear=s.dayOfYear):h(e)._overflowWeekday=!0}n.ISO_8601=function(){},n.RFC_2822=function(){};function tr(e){if(e._f===n.ISO_8601){Un(e);return}if(e._f===n.RFC_2822){Yn(e);return}e._a=[],h(e).empty=!0;var t=``+e._i,r,i,a,o,s,c=t.length,l=0,u,d;for(a=le(e._f,e._locale).match(ne)||[],d=a.length,r=0;r<d;r++)o=a[r],i=(t.match(Ge(o,e))||[])[0],i&&(s=t.substr(0,t.indexOf(i)),s.length>0&&h(e).unusedInput.push(s),t=t.slice(t.indexOf(i)+i.length),l+=i.length),ae[o]?(i?h(e).empty=!1:h(e).unusedTokens.push(o),$e(o,i,e)):e._strict&&!i&&h(e).unusedTokens.push(o);h(e).charsLeftOver=c-l,t.length>0&&h(e).unusedInput.push(t),e._a[it]<=12&&h(e).bigHour===!0&&e._a[it]>0&&(h(e).bigHour=void 0),h(e).parsedDateParts=e._a.slice(0),h(e).meridiem=e._meridiem,e._a[it]=nr(e._locale,e._a[it],e._meridiem),u=h(e).era,u!==null&&(e._a[tt]=e._locale.erasConvertYear(u,e._a[tt])),$n(e),Pn(e)}function nr(e,t,n){var r;return n==null?t:e.meridiemHour==null?e.isPM==null?t:(r=e.isPM(n),r&&t<12&&(t+=12),!r&&t===12&&(t=0),t):e.meridiemHour(t,n)}function rr(e){var t,n,r,i,a,o,s=!1,c=e._f.length;if(c===0){h(e).invalidFormat=!0,e._d=new Date(NaN);return}for(i=0;i<c;i++)a=0,o=!1,t=x({},e),e._useUTC!=null&&(t._useUTC=e._useUTC),t._f=e._f[i],tr(t),_(t)&&(o=!0),a+=h(t).charsLeftOver,a+=h(t).unusedTokens.length*10,h(t).score=a,s?a<r&&(r=a,n=t):(r==null||a<r||o)&&(r=a,n=t,o&&(s=!0));f(e,n||t)}function ir(e){if(!e._d){var t=Se(e._i),n=t.day===void 0?t.date:t.day;e._a=d([t.year,t.month,n,t.hour,t.minute,t.second,t.millisecond],function(e){return e&&parseInt(e,10)}),$n(e)}}function ar(e){var t=new S(Pn(or(e)));return t._nextDay&&(t.add(1,`d`),t._nextDay=void 0),t}function or(e){var t=e._i,n=e._f;return e._locale=e._locale||Mn(e._l),t===null||n===void 0&&t===``?v({nullInput:!0}):(typeof t==`string`&&(e._i=t=e._locale.preparse(t)),C(t)?new S(Pn(t)):(u(t)?e._d=t:i(n)?rr(e):n?tr(e):sr(e),_(e)||(e._d=null),e))}function sr(e){var t=e._i;c(t)?e._d=new Date(n.now()):u(t)?e._d=new Date(t.valueOf()):typeof t==`string`?Xn(e):i(t)?(e._a=d(t.slice(0),function(e){return parseInt(e,10)}),$n(e)):a(t)?ir(e):l(t)?e._d=new Date(t):n.createFromInputFallback(e)}function cr(e,t,n,r,o){var c={};return(t===!0||t===!1)&&(r=t,t=void 0),(n===!0||n===!1)&&(r=n,n=void 0),(a(e)&&s(e)||i(e)&&e.length===0)&&(e=void 0),c._isAMomentObject=!0,c._useUTC=c._isUTC=o,c._l=n,c._i=e,c._f=t,c._strict=r,ar(c)}function lr(e,t,n,r){return cr(e,t,n,r,!1)}var ur=T(`moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/`,function(){var e=lr.apply(null,arguments);return this.isValid()&&e.isValid()?e<this?this:e:v()}),dr=T(`moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/`,function(){var e=lr.apply(null,arguments);return this.isValid()&&e.isValid()?e>this?this:e:v()});function fr(e,t){var n,r;if(t.length===1&&i(t[0])&&(t=t[0]),!t.length)return lr();for(n=t[0],r=1;r<t.length;++r)(!t[r].isValid()||t[r][e](n))&&(n=t[r]);return n}function pr(){return fr(`isBefore`,[].slice.call(arguments,0))}function mr(){return fr(`isAfter`,[].slice.call(arguments,0))}var hr=function(){return Date.now?Date.now():+new Date},gr=[`year`,`quarter`,`month`,`week`,`day`,`hour`,`minute`,`second`,`millisecond`];function _r(e){var t,n=!1,r,i=gr.length;for(t in e)if(o(e,t)&&!(yt.call(gr,t)!==-1&&(e[t]==null||!isNaN(e[t]))))return!1;for(r=0;r<i;++r)if(e[gr[r]]){if(n)return!1;parseFloat(e[gr[r]])!==Ye(e[gr[r]])&&(n=!0)}return!0}function vr(){return this._isValid}function yr(){return Vr(NaN)}function B(e){var t=Se(e),n=t.year||0,r=t.quarter||0,i=t.month||0,a=t.week||t.isoWeek||0,o=t.day||0,s=t.hour||0,c=t.minute||0,l=t.second||0,u=t.millisecond||0;this._isValid=_r(t),this._milliseconds=+u+l*1e3+c*6e4+s*1e3*60*60,this._days=+o+a*7,this._months=+i+r*3+n*12,this._data={},this._locale=Mn(),this._bubble()}function br(e){return e instanceof B}function xr(e){return e<0?Math.round(-1*e)*-1:Math.round(e)}function Sr(e,t,n){var r=Math.min(e.length,t.length),i=Math.abs(e.length-t.length),a=0,o;for(o=0;o<r;o++)(n&&e[o]!==t[o]||!n&&Ye(e[o])!==Ye(t[o]))&&a++;return a+i}function Cr(e,t){P(e,0,0,function(){var e=this.utcOffset(),n=`+`;return e<0&&(e=-e,n=`-`),n+N(~~(e/60),2)+t+N(~~e%60,2)})}Cr(`Z`,`:`),Cr(`ZZ`,``),F(`Z`,ze),F(`ZZ`,ze),Ze([`Z`,`ZZ`],function(e,t,n){n._useUTC=!0,n._tzm=Tr(ze,e)});var wr=/([\+\-]|\d\d)/gi;function Tr(e,t){var n=(t||``).match(e),r,i,a;return n===null?null:(r=n[n.length-1]||[],i=(r+``).match(wr)||[`-`,0,0],a=+(i[1]*60)+Ye(i[2]),a===0?0:i[0]===`+`?a:-a)}function Er(e,t){var r,i;return t._isUTC?(r=t.clone(),i=(C(e)||u(e)?e.valueOf():lr(e).valueOf())-r.valueOf(),r._d.setTime(r._d.valueOf()+i),n.updateOffset(r,!1),r):lr(e).local()}function Dr(e){return-Math.round(e._d.getTimezoneOffset())}n.updateOffset=function(){};function Or(e,t,r){var i=this._offset||0,a;if(!this.isValid())return e==null?NaN:this;if(e!=null){if(typeof e==`string`){if(e=Tr(ze,e),e===null)return this}else Math.abs(e)<16&&!r&&(e*=60);return!this._isUTC&&t&&(a=Dr(this)),this._offset=e,this._isUTC=!0,a!=null&&this.add(a,`m`),i!==e&&(!t||this._changeInProgress?Kr(this,Vr(e-i,`m`),1,!1):this._changeInProgress||(this._changeInProgress=!0,n.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?i:Dr(this)}function kr(e,t){return e==null?-this.utcOffset():(typeof e!=`string`&&(e=-e),this.utcOffset(e,t),this)}function Ar(e){return this.utcOffset(0,e)}function jr(e){return this._isUTC&&(this.utcOffset(0,e),this._isUTC=!1,e&&this.subtract(Dr(this),`m`)),this}function Mr(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i==`string`){var e=Tr(Re,this._i);e==null?this.utcOffset(0,!0):this.utcOffset(e)}return this}function Nr(e){return this.isValid()?(e=e?lr(e).utcOffset():0,(this.utcOffset()-e)%60==0):!1}function Pr(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Fr(){if(!c(this._isDSTShifted))return this._isDSTShifted;var e={},t;return x(e,this),e=or(e),e._a?(t=e._isUTC?p(e._a):lr(e._a),this._isDSTShifted=this.isValid()&&Sr(e._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function Ir(){return this.isValid()?!this._isUTC:!1}function Lr(){return this.isValid()?this._isUTC:!1}function Rr(){return this.isValid()?this._isUTC&&this._offset===0:!1}var zr=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,Br=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Vr(e,t){var n=e,r=null,i,a,s;return br(e)?n={ms:e._milliseconds,d:e._days,M:e._months}:l(e)||!isNaN(+e)?(n={},t?n[t]=+e:n.milliseconds=+e):(r=zr.exec(e))?(i=r[1]===`-`?-1:1,n={y:0,d:Ye(r[rt])*i,h:Ye(r[it])*i,m:Ye(r[at])*i,s:Ye(r[ot])*i,ms:Ye(xr(r[st]*1e3))*i}):(r=Br.exec(e))?(i=r[1]===`-`?-1:1,n={y:Hr(r[2],i),M:Hr(r[3],i),w:Hr(r[4],i),d:Hr(r[5],i),h:Hr(r[6],i),m:Hr(r[7],i),s:Hr(r[8],i)}):n==null?n={}:typeof n==`object`&&(`from`in n||`to`in n)&&(s=Wr(lr(n.from),lr(n.to)),n={},n.ms=s.milliseconds,n.M=s.months),a=new B(n),br(e)&&o(e,`_locale`)&&(a._locale=e._locale),br(e)&&o(e,`_isValid`)&&(a._isValid=e._isValid),a}Vr.fn=B.prototype,Vr.invalid=yr;function Hr(e,t){var n=e&&parseFloat(e.replace(`,`,`.`));return(isNaN(n)?0:n)*t}function Ur(e,t){var n={};return n.months=t.month()-e.month()+(t.year()-e.year())*12,e.clone().add(n.months,`M`).isAfter(t)&&--n.months,n.milliseconds=t-+e.clone().add(n.months,`M`),n}function Wr(e,t){var n;return e.isValid()&&t.isValid()?(t=Er(t,e),e.isBefore(t)?n=Ur(e,t):(n=Ur(t,e),n.milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}function Gr(e,t){return function(n,r){var i,a;return r!==null&&!isNaN(+r)&&(D(t,`moment().`+t+`(period, number) is deprecated. Please use moment().`+t+`(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.`),a=n,n=r,r=a),i=Vr(n,r),Kr(this,i,e),this}}function Kr(e,t,r,i){var a=t._milliseconds,o=xr(t._days),s=xr(t._months);e.isValid()&&(i=i??!0,s&&kt(e,mt(e,`Month`)+s*r),o&&ht(e,`Date`,mt(e,`Date`)+o*r),a&&e._d.setTime(e._d.valueOf()+a*r),i&&n.updateOffset(e,o||s))}var qr=Gr(1,`add`),Jr=Gr(-1,`subtract`);function Yr(e){return typeof e==`string`||e instanceof String}function Xr(e){return C(e)||u(e)||Yr(e)||l(e)||Qr(e)||Zr(e)||e==null}function Zr(e){var t=a(e)&&!s(e),n=!1,r=[`years`,`year`,`y`,`months`,`month`,`M`,`days`,`day`,`d`,`dates`,`date`,`D`,`hours`,`hour`,`h`,`minutes`,`minute`,`m`,`seconds`,`second`,`s`,`milliseconds`,`millisecond`,`ms`],i,c,l=r.length;for(i=0;i<l;i+=1)c=r[i],n=n||o(e,c);return t&&n}function Qr(e){var t=i(e),n=!1;return t&&(n=e.filter(function(t){return!l(t)&&Yr(e)}).length===0),t&&n}function $r(e){var t=a(e)&&!s(e),n=!1,r=[`sameDay`,`nextDay`,`lastDay`,`nextWeek`,`lastWeek`,`sameElse`],i,c;for(i=0;i<r.length;i+=1)c=r[i],n=n||o(e,c);return t&&n}function ei(e,t){var n=e.diff(t,`days`,!0);return n<-6?`sameElse`:n<-1?`lastWeek`:n<0?`lastDay`:n<1?`sameDay`:n<2?`nextDay`:n<7?`nextWeek`:`sameElse`}function ti(e,t){arguments.length===1&&(arguments[0]?Xr(arguments[0])?(e=arguments[0],t=void 0):$r(arguments[0])&&(t=arguments[0],e=void 0):(e=void 0,t=void 0));var r=e||lr(),i=Er(r,this).startOf(`day`),a=n.calendarFormat(this,i)||`sameElse`,o=t&&(O(t[a])?t[a].call(this,r):t[a]);return this.format(o||this.localeData().calendar(a,this,lr(r)))}function ni(){return new S(this)}function ri(e,t){var n=C(e)?e:lr(e);return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()>n.valueOf():n.valueOf()<this.clone().startOf(t).valueOf()):!1}function ii(e,t){var n=C(e)?e:lr(e);return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()<n.valueOf():this.clone().endOf(t).valueOf()<n.valueOf()):!1}function ai(e,t,n,r){var i=C(e)?e:lr(e),a=C(t)?t:lr(t);return this.isValid()&&i.isValid()&&a.isValid()?(r=r||`()`,(r[0]===`(`?this.isAfter(i,n):!this.isBefore(i,n))&&(r[1]===`)`?this.isBefore(a,n):!this.isAfter(a,n))):!1}function oi(e,t){var n=C(e)?e:lr(e),r;return this.isValid()&&n.isValid()?(t=xe(t)||`millisecond`,t===`millisecond`?this.valueOf()===n.valueOf():(r=n.valueOf(),this.clone().startOf(t).valueOf()<=r&&r<=this.clone().endOf(t).valueOf())):!1}function si(e,t){return this.isSame(e,t)||this.isAfter(e,t)}function ci(e,t){return this.isSame(e,t)||this.isBefore(e,t)}function li(e,t,n){var r,i,a;if(!this.isValid()||(r=Er(e,this),!r.isValid()))return NaN;switch(i=(r.utcOffset()-this.utcOffset())*6e4,t=xe(t),t){case`year`:a=ui(this,r)/12;break;case`month`:a=ui(this,r);break;case`quarter`:a=ui(this,r)/3;break;case`second`:a=(this-r)/1e3;break;case`minute`:a=(this-r)/6e4;break;case`hour`:a=(this-r)/36e5;break;case`day`:a=(this-r-i)/864e5;break;case`week`:a=(this-r-i)/6048e5;break;default:a=this-r}return n?a:Je(a)}function ui(e,t){if(e.date()<t.date())return-ui(t,e);var n=(t.year()-e.year())*12+(t.month()-e.month()),r=e.clone().add(n,`months`),i,a;return t-r<0?(i=e.clone().add(n-1,`months`),a=(t-r)/(r-i)):(i=e.clone().add(n+1,`months`),a=(t-r)/(i-r)),-(n+a)||0}n.defaultFormat=`YYYY-MM-DDTHH:mm:ssZ`,n.defaultFormatUtc=`YYYY-MM-DDTHH:mm:ss[Z]`;function di(){return this.clone().locale(`en`).format(`ddd MMM DD YYYY HH:mm:ss [GMT]ZZ`)}function fi(e){if(!this.isValid())return null;var t=e!==!0,n=t?this.clone().utc():this;return n.year()<0||n.year()>9999?ce(n,t?`YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYYYY-MM-DD[T]HH:mm:ss.SSSZ`):O(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace(`Z`,ce(n,`Z`)):ce(n,t?`YYYY-MM-DD[T]HH:mm:ss.SSS[Z]`:`YYYY-MM-DD[T]HH:mm:ss.SSSZ`)}function pi(){if(!this.isValid())return`moment.invalid(/* `+this._i+` */)`;var e=`moment`,t=``,n,r,i,a;return this.isLocal()||(e=this.utcOffset()===0?`moment.utc`:`moment.parseZone`,t=`Z`),n=`[`+e+`("]`,r=0<=this.year()&&this.year()<=9999?`YYYY`:`YYYYYY`,i=`-MM-DD[T]HH:mm:ss.SSS`,a=t+`[")]`,this.format(n+r+i+a)}function mi(e){e||(e=this.isUtc()?n.defaultFormatUtc:n.defaultFormat);var t=ce(this,e);return this.localeData().postformat(t)}function hi(e,t){return this.isValid()&&(C(e)&&e.isValid()||lr(e).isValid())?Vr({to:this,from:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function gi(e){return this.from(lr(),e)}function _i(e,t){return this.isValid()&&(C(e)&&e.isValid()||lr(e).isValid())?Vr({from:this,to:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function vi(e){return this.to(lr(),e)}function yi(e){var t;return e===void 0?this._locale._abbr:(t=Mn(e),t!=null&&(this._locale=t),this)}var bi=T(`moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.`,function(e){return e===void 0?this.localeData():this.locale(e)});function xi(){return this._locale}var Si=1e3,Ci=60*Si,wi=60*Ci,Ti=146097*24*wi;function Ei(e,t){return(e%t+t)%t}function Di(e,t,n){return e<100&&e>=0?new Date(e+400,t,n)-Ti:new Date(e,t,n).valueOf()}function Oi(e,t,n){return e<100&&e>=0?Date.UTC(e+400,t,n)-Ti:Date.UTC(e,t,n)}function ki(e){var t,r;if(e=xe(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(r=this._isUTC?Oi:Di,e){case`year`:t=r(this.year(),0,1);break;case`quarter`:t=r(this.year(),this.month()-this.month()%3,1);break;case`month`:t=r(this.year(),this.month(),1);break;case`week`:t=r(this.year(),this.month(),this.date()-this.weekday());break;case`isoWeek`:t=r(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case`day`:case`date`:t=r(this.year(),this.month(),this.date());break;case`hour`:t=this._d.valueOf(),t-=Ei(t+(this._isUTC?0:this.utcOffset()*Ci),wi);break;case`minute`:t=this._d.valueOf(),t-=Ei(t,Ci);break;case`second`:t=this._d.valueOf(),t-=Ei(t,Si);break}return this._d.setTime(t),n.updateOffset(this,!0),this}function Ai(e){var t,r;if(e=xe(e),e===void 0||e===`millisecond`||!this.isValid())return this;switch(r=this._isUTC?Oi:Di,e){case`year`:t=r(this.year()+1,0,1)-1;break;case`quarter`:t=r(this.year(),this.month()-this.month()%3+3,1)-1;break;case`month`:t=r(this.year(),this.month()+1,1)-1;break;case`week`:t=r(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case`isoWeek`:t=r(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case`day`:case`date`:t=r(this.year(),this.month(),this.date()+1)-1;break;case`hour`:t=this._d.valueOf(),t+=wi-Ei(t+(this._isUTC?0:this.utcOffset()*Ci),wi)-1;break;case`minute`:t=this._d.valueOf(),t+=Ci-Ei(t,Ci)-1;break;case`second`:t=this._d.valueOf(),t+=Si-Ei(t,Si)-1;break}return this._d.setTime(t),n.updateOffset(this,!0),this}function ji(){return this._d.valueOf()-(this._offset||0)*6e4}function Mi(){return Math.floor(this.valueOf()/1e3)}function Ni(){return new Date(this.valueOf())}function Pi(){var e=this;return[e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second(),e.millisecond()]}function Fi(){var e=this;return{years:e.year(),months:e.month(),date:e.date(),hours:e.hours(),minutes:e.minutes(),seconds:e.seconds(),milliseconds:e.milliseconds()}}function Ii(){return this.isValid()?this.toISOString():null}function Li(){return _(this)}function Ri(){return f({},h(this))}function zi(){return h(this).overflow}function Bi(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}P(`N`,0,0,`eraAbbr`),P(`NN`,0,0,`eraAbbr`),P(`NNN`,0,0,`eraAbbr`),P(`NNNN`,0,0,`eraName`),P(`NNNNN`,0,0,`eraNarrow`),P(`y`,[`y`,1],`yo`,`eraYear`),P(`y`,[`yy`,2],0,`eraYear`),P(`y`,[`yyy`,3],0,`eraYear`),P(`y`,[`yyyy`,4],0,`eraYear`),F(`N`,Zi),F(`NN`,Zi),F(`NNN`,Zi),F(`NNNN`,Qi),F(`NNNNN`,$i),Ze([`N`,`NN`,`NNN`,`NNNN`,`NNNNN`],function(e,t,n,r){var i=n._locale.erasParse(e,r,n._strict);i?h(n).era=i:h(n).invalidEra=e}),F(`y`,Ie),F(`yy`,Ie),F(`yyy`,Ie),F(`yyyy`,Ie),F(`yo`,ea),Ze([`y`,`yy`,`yyy`,`yyyy`],tt),Ze([`yo`],function(e,t,n,r){var i;n._locale._eraYearOrdinalRegex&&(i=e.match(n._locale._eraYearOrdinalRegex)),n._locale.eraYearOrdinalParse?t[tt]=n._locale.eraYearOrdinalParse(e,i):t[tt]=parseInt(e,10)});function Vi(e,t){var r,i,a,o=this._eras||Mn(`en`)._eras;for(r=0,i=o.length;r<i;++r){switch(typeof o[r].since){case`string`:a=n(o[r].since).startOf(`day`),o[r].since=a.valueOf();break}switch(typeof o[r].until){case`undefined`:o[r].until=1/0;break;case`string`:a=n(o[r].until).startOf(`day`).valueOf(),o[r].until=a.valueOf();break}}return o}function Hi(e,t,n){var r,i,a=this.eras(),o,s,c;for(e=e.toUpperCase(),r=0,i=a.length;r<i;++r)if(o=a[r].name.toUpperCase(),s=a[r].abbr.toUpperCase(),c=a[r].narrow.toUpperCase(),n)switch(t){case`N`:case`NN`:case`NNN`:if(s===e)return a[r];break;case`NNNN`:if(o===e)return a[r];break;case`NNNNN`:if(c===e)return a[r];break}else if([o,s,c].indexOf(e)>=0)return a[r]}function Ui(e,t){var r=e.since<=e.until?1:-1;return t===void 0?n(e.since).year():n(e.since).year()+(t-e.offset)*r}function Wi(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].name;return``}function Gi(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].narrow;return``}function Ki(){var e,t,n,r=this.localeData().eras();for(e=0,t=r.length;e<t;++e)if(n=this.clone().startOf(`day`).valueOf(),r[e].since<=n&&n<=r[e].until||r[e].until<=n&&n<=r[e].since)return r[e].abbr;return``}function qi(){var e,t,r,i,a=this.localeData().eras();for(e=0,t=a.length;e<t;++e)if(r=a[e].since<=a[e].until?1:-1,i=this.clone().startOf(`day`).valueOf(),a[e].since<=i&&i<=a[e].until||a[e].until<=i&&i<=a[e].since)return(this.year()-n(a[e].since).year())*r+a[e].offset;return this.year()}function Ji(e){return o(this,`_erasNameRegex`)||ta.call(this),e?this._erasNameRegex:this._erasRegex}function Yi(e){return o(this,`_erasAbbrRegex`)||ta.call(this),e?this._erasAbbrRegex:this._erasRegex}function Xi(e){return o(this,`_erasNarrowRegex`)||ta.call(this),e?this._erasNarrowRegex:this._erasRegex}function Zi(e,t){return t.erasAbbrRegex(e)}function Qi(e,t){return t.erasNameRegex(e)}function $i(e,t){return t.erasNarrowRegex(e)}function ea(e,t){return t._eraYearOrdinalRegex||Ie}function ta(){var e=[],t=[],n=[],r=[],i,a,o,s,c,l=this.eras();for(i=0,a=l.length;i<a;++i)o=qe(l[i].name),s=qe(l[i].abbr),c=qe(l[i].narrow),t.push(o),e.push(s),n.push(c),r.push(o),r.push(s),r.push(c);this._erasRegex=RegExp(`^(`+r.join(`|`)+`)`,`i`),this._erasNameRegex=RegExp(`^(`+t.join(`|`)+`)`,`i`),this._erasAbbrRegex=RegExp(`^(`+e.join(`|`)+`)`,`i`),this._erasNarrowRegex=RegExp(`^(`+n.join(`|`)+`)`,`i`)}P(0,[`gg`,2],0,function(){return this.weekYear()%100}),P(0,[`GG`,2],0,function(){return this.isoWeekYear()%100});function na(e,t){P(0,[e,e.length],0,t)}na(`gggg`,`weekYear`),na(`ggggg`,`weekYear`),na(`GGGG`,`isoWeekYear`),na(`GGGGG`,`isoWeekYear`),F(`G`,Le),F(`g`,Le),F(`GG`,Ae,Ee),F(`gg`,Ae,Ee),F(`GGGG`,Pe,Oe),F(`gggg`,Pe,Oe),F(`GGGGG`,Fe,ke),F(`ggggg`,Fe,ke),Qe([`gggg`,`ggggg`,`GGGG`,`GGGGG`],function(e,t,n,r){t[r.substr(0,2)]=Ye(e)}),Qe([`gg`,`GG`],function(e,t,r,i){t[i]=n.parseTwoDigitYear(e)});function ra(e){return la.call(this,e,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function ia(e){return la.call(this,e,this.isoWeek(),this.isoWeekday(),1,4)}function aa(){return zt(this.year(),1,4)}function oa(){return zt(this.isoWeekYear(),1,4)}function sa(){var e=this.localeData()._week;return zt(this.year(),e.dow,e.doy)}function ca(){var e=this.localeData()._week;return zt(this.weekYear(),e.dow,e.doy)}function la(e,t,n,r,i){var a;return e==null?Rt(this,r,i).year:(a=zt(e,r,i),t>a&&(t=a),ua.call(this,e,t,n,r,i))}function ua(e,t,n,r,i){var a=L(e,t,n,r,i),o=It(a.year,0,a.dayOfYear);return this.year(o.getUTCFullYear()),this.month(o.getUTCMonth()),this.date(o.getUTCDate()),this}P(`Q`,0,`Qo`,`quarter`),F(`Q`,Te),Ze(`Q`,function(e,t){t[nt]=(Ye(e)-1)*3});function da(e){return e==null?Math.ceil((this.month()+1)/3):this.month((e-1)*3+this.month()%3)}P(`D`,[`DD`,2],`Do`,`date`),F(`D`,Ae,He),F(`DD`,Ae,Ee),F(`Do`,function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),Ze([`D`,`DD`],rt),Ze(`Do`,function(e,t){t[rt]=Ye(e.match(Ae)[0])});var fa=pt(`Date`,!0);P(`DDD`,[`DDDD`,3],`DDDo`,`dayOfYear`),F(`DDD`,Ne),F(`DDDD`,De),Ze([`DDD`,`DDDD`],function(e,t,n){n._dayOfYear=Ye(e)});function pa(e){var t=Math.round((this.clone().startOf(`day`)-this.clone().startOf(`year`))/864e5)+1;return e==null?t:this.add(e-t,`d`)}P(`m`,[`mm`,2],0,`minute`),F(`m`,Ae,Ue),F(`mm`,Ae,Ee),Ze([`m`,`mm`],at);var ma=pt(`Minutes`,!1);P(`s`,[`ss`,2],0,`second`),F(`s`,Ae,Ue),F(`ss`,Ae,Ee),Ze([`s`,`ss`],ot);var ha=pt(`Seconds`,!1);P(`S`,0,0,function(){return~~(this.millisecond()/100)}),P(0,[`SS`,2],0,function(){return~~(this.millisecond()/10)}),P(0,[`SSS`,3],0,`millisecond`),P(0,[`SSSS`,4],0,function(){return this.millisecond()*10}),P(0,[`SSSSS`,5],0,function(){return this.millisecond()*100}),P(0,[`SSSSSS`,6],0,function(){return this.millisecond()*1e3}),P(0,[`SSSSSSS`,7],0,function(){return this.millisecond()*1e4}),P(0,[`SSSSSSSS`,8],0,function(){return this.millisecond()*1e5}),P(0,[`SSSSSSSSS`,9],0,function(){return this.millisecond()*1e6}),F(`S`,Ne,Te),F(`SS`,Ne,Ee),F(`SSS`,Ne,De);var ga,_a;for(ga=`SSSS`;ga.length<=9;ga+=`S`)F(ga,Ie);function va(e,t){t[st]=Ye((`0.`+e)*1e3)}for(ga=`S`;ga.length<=9;ga+=`S`)Ze(ga,va);_a=pt(`Milliseconds`,!1),P(`z`,0,0,`zoneAbbr`),P(`zz`,0,0,`zoneName`);function ya(){return this._isUTC?`UTC`:``}function ba(){return this._isUTC?`Coordinated Universal Time`:``}var V=S.prototype;V.add=qr,V.calendar=ti,V.clone=ni,V.diff=li,V.endOf=Ai,V.format=mi,V.from=hi,V.fromNow=gi,V.to=_i,V.toNow=vi,V.get=gt,V.invalidAt=zi,V.isAfter=ri,V.isBefore=ii,V.isBetween=ai,V.isSame=oi,V.isSameOrAfter=si,V.isSameOrBefore=ci,V.isValid=Li,V.lang=bi,V.locale=yi,V.localeData=xi,V.max=dr,V.min=ur,V.parsingFlags=Ri,V.set=_t,V.startOf=ki,V.subtract=Jr,V.toArray=Pi,V.toObject=Fi,V.toDate=Ni,V.toISOString=fi,V.inspect=pi,typeof Symbol<`u`&&Symbol.for!=null&&(V[Symbol.for(`nodejs.util.inspect.custom`)]=function(){return`Moment<`+this.format()+`>`}),V.toJSON=Ii,V.toString=di,V.unix=Mi,V.valueOf=ji,V.creationData=Bi,V.eraName=Wi,V.eraNarrow=Gi,V.eraAbbr=Ki,V.eraYear=qi,V.year=dt,V.isLeapYear=ft,V.weekYear=ra,V.isoWeekYear=ia,V.quarter=V.quarters=da,V.month=At,V.daysInMonth=jt,V.week=V.weeks=Ut,V.isoWeek=V.isoWeeks=Wt,V.weeksInYear=sa,V.weeksInWeekYear=ca,V.isoWeeksInYear=aa,V.isoWeeksInISOWeekYear=oa,V.date=fa,V.day=V.days=on,V.weekday=sn,V.isoWeekday=cn,V.dayOfYear=pa,V.hour=V.hours=vn,V.minute=V.minutes=ma,V.second=V.seconds=ha,V.millisecond=V.milliseconds=_a,V.utcOffset=Or,V.utc=Ar,V.local=jr,V.parseZone=Mr,V.hasAlignedHourOffset=Nr,V.isDST=Pr,V.isLocal=Ir,V.isUtcOffset=Lr,V.isUtc=Rr,V.isUTC=Rr,V.zoneAbbr=ya,V.zoneName=ba,V.dates=T(`dates accessor is deprecated. Use date instead.`,fa),V.months=T(`months accessor is deprecated. Use month instead`,At),V.years=T(`years accessor is deprecated. Use year instead`,dt),V.zone=T(`moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/`,kr),V.isDSTShifted=T(`isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information`,Fr);function xa(e){return lr(e*1e3)}function Sa(){return lr.apply(null,arguments).parseZone()}function Ca(e){return e}var wa=j.prototype;wa.calendar=te,wa.longDateFormat=de,wa.invalidDate=pe,wa.ordinal=ge,wa.preparse=Ca,wa.postformat=Ca,wa.relativeTime=ve,wa.pastFuture=ye,wa.set=k,wa.eras=Vi,wa.erasParse=Hi,wa.erasConvertYear=Ui,wa.erasAbbrRegex=Yi,wa.erasNameRegex=Ji,wa.erasNarrowRegex=Xi,wa.months=I,wa.monthsShort=Et,wa.monthsParse=Ot,wa.monthsRegex=Nt,wa.monthsShortRegex=Mt,wa.week=Bt,wa.firstDayOfYear=Ht,wa.firstDayOfWeek=Vt,wa.weekdays=en,wa.weekdaysMin=nn,wa.weekdaysShort=tn,wa.weekdaysParse=an,wa.weekdaysRegex=ln,wa.weekdaysShortRegex=un,wa.weekdaysMinRegex=dn,wa.isPM=gn,wa.meridiem=yn;function Ta(e,t,n,r){var i=Mn(),a=p().set(r,t);return i[n](a,e)}function Ea(e,t,n){if(l(e)&&(t=e,e=void 0),e=e||``,t!=null)return Ta(e,t,n,`month`);var r,i=[];for(r=0;r<12;r++)i[r]=Ta(e,r,n,`month`);return i}function Da(e,t,n,r){typeof e==`boolean`?(l(t)&&(n=t,t=void 0),t=t||``):(t=e,n=t,e=!1,l(t)&&(n=t,t=void 0),t=t||``);var i=Mn(),a=e?i._week.dow:0,o,s=[];if(n!=null)return Ta(t,(n+a)%7,r,`day`);for(o=0;o<7;o++)s[o]=Ta(t,(o+a)%7,r,`day`);return s}function Oa(e,t){return Ea(e,t,`months`)}function ka(e,t){return Ea(e,t,`monthsShort`)}function Aa(e,t,n){return Da(e,t,n,`weekdays`)}function ja(e,t,n){return Da(e,t,n,`weekdaysShort`)}function Ma(e,t,n){return Da(e,t,n,`weekdaysMin`)}kn(`en`,{eras:[{since:`0001-01-01`,until:1/0,offset:1,name:`Anno Domini`,narrow:`AD`,abbr:`AD`},{since:`0000-12-31`,until:-1/0,offset:1,name:`Before Christ`,narrow:`BC`,abbr:`BC`}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var t=e%10;return e+(Ye(e%100/10)===1?`th`:t===1?`st`:t===2?`nd`:t===3?`rd`:`th`)}}),n.lang=T(`moment.lang is deprecated. Use moment.locale instead.`,kn),n.langData=T(`moment.langData is deprecated. Use moment.localeData instead.`,Mn);var Na=Math.abs;function Pa(){var e=this._data;return this._milliseconds=Na(this._milliseconds),this._days=Na(this._days),this._months=Na(this._months),e.milliseconds=Na(e.milliseconds),e.seconds=Na(e.seconds),e.minutes=Na(e.minutes),e.hours=Na(e.hours),e.months=Na(e.months),e.years=Na(e.years),this}function Fa(e,t,n,r){var i=Vr(t,n);return e._milliseconds+=r*i._milliseconds,e._days+=r*i._days,e._months+=r*i._months,e._bubble()}function Ia(e,t){return Fa(this,e,t,1)}function La(e,t){return Fa(this,e,t,-1)}function Ra(e){return e<0?Math.floor(e):Math.ceil(e)}function za(){var e=this._milliseconds,t=this._days,n=this._months,r=this._data,i,a,o,s,c;return e>=0&&t>=0&&n>=0||e<=0&&t<=0&&n<=0||(e+=Ra(Va(n)+t)*864e5,t=0,n=0),r.milliseconds=e%1e3,i=Je(e/1e3),r.seconds=i%60,a=Je(i/60),r.minutes=a%60,o=Je(a/60),r.hours=o%24,t+=Je(o/24),c=Je(Ba(t)),n+=c,t-=Ra(Va(c)),s=Je(n/12),n%=12,r.days=t,r.months=n,r.years=s,this}function Ba(e){return e*4800/146097}function Va(e){return e*146097/4800}function Ha(e){if(!this.isValid())return NaN;var t,n,r=this._milliseconds;if(e=xe(e),e===`month`||e===`quarter`||e===`year`)switch(t=this._days+r/864e5,n=this._months+Ba(t),e){case`month`:return n;case`quarter`:return n/3;case`year`:return n/12}else switch(t=this._days+Math.round(Va(this._months)),e){case`week`:return t/7+r/6048e5;case`day`:return t+r/864e5;case`hour`:return t*24+r/36e5;case`minute`:return t*1440+r/6e4;case`second`:return t*86400+r/1e3;case`millisecond`:return Math.floor(t*864e5)+r;default:throw Error(`Unknown unit `+e)}}function Ua(e){return function(){return this.as(e)}}var Wa=Ua(`ms`),Ga=Ua(`s`),Ka=Ua(`m`),qa=Ua(`h`),Ja=Ua(`d`),Ya=Ua(`w`),Xa=Ua(`M`),Za=Ua(`Q`),Qa=Ua(`y`),$a=Wa;function eo(){return Vr(this)}function to(e){return e=xe(e),this.isValid()?this[e+`s`]():NaN}function no(e){return function(){return this.isValid()?this._data[e]:NaN}}var ro=no(`milliseconds`),io=no(`seconds`),ao=no(`minutes`),oo=no(`hours`),so=no(`days`),co=no(`months`),lo=no(`years`);function uo(){return Je(this.days()/7)}var fo=Math.round,po={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function mo(e,t,n,r,i){return i.relativeTime(t||1,!!n,e,r)}function ho(e,t,n,r){var i=Vr(e).abs(),a=fo(i.as(`s`)),o=fo(i.as(`m`)),s=fo(i.as(`h`)),c=fo(i.as(`d`)),l=fo(i.as(`M`)),u=fo(i.as(`w`)),d=fo(i.as(`y`)),f=a<=n.ss&&[`s`,a]||a<n.s&&[`ss`,a]||o<=1&&[`m`]||o<n.m&&[`mm`,o]||s<=1&&[`h`]||s<n.h&&[`hh`,s]||c<=1&&[`d`]||c<n.d&&[`dd`,c];return n.w!=null&&(f=f||u<=1&&[`w`]||u<n.w&&[`ww`,u]),f=f||l<=1&&[`M`]||l<n.M&&[`MM`,l]||d<=1&&[`y`]||[`yy`,d],f[2]=t,f[3]=+e>0,f[4]=r,mo.apply(null,f)}function go(e){return e===void 0?fo:typeof e==`function`?(fo=e,!0):!1}function _o(e,t){return po[e]===void 0?!1:t===void 0?po[e]:(po[e]=t,e===`s`&&(po.ss=t-1),!0)}function vo(e,t){if(!this.isValid())return this.localeData().invalidDate();var n=!1,r=po,i,a;return typeof e==`object`&&(t=e,e=!1),typeof e==`boolean`&&(n=e),typeof t==`object`&&(r=Object.assign({},po,t),t.s!=null&&t.ss==null&&(r.ss=t.s-1)),i=this.localeData(),a=ho(this,!n,r,i),n&&(a=i.pastFuture(+this,a)),i.postformat(a)}var yo=Math.abs;function bo(e){return(e>0)-(e<0)||+e}function xo(){if(!this.isValid())return this.localeData().invalidDate();var e=yo(this._milliseconds)/1e3,t=yo(this._days),n=yo(this._months),r,i,a,o,s=this.asSeconds(),c,l,u,d;return s?(r=Je(e/60),i=Je(r/60),e%=60,r%=60,a=Je(n/12),n%=12,o=e?e.toFixed(3).replace(/\.?0+$/,``):``,c=s<0?`-`:``,l=bo(this._months)===bo(s)?``:`-`,u=bo(this._days)===bo(s)?``:`-`,d=bo(this._milliseconds)===bo(s)?``:`-`,c+`P`+(a?l+a+`Y`:``)+(n?l+n+`M`:``)+(t?u+t+`D`:``)+(i||r||e?`T`:``)+(i?d+i+`H`:``)+(r?d+r+`M`:``)+(e?d+o+`S`:``)):`P0D`}var So=B.prototype;return So.isValid=vr,So.abs=Pa,So.add=Ia,So.subtract=La,So.as=Ha,So.asMilliseconds=Wa,So.asSeconds=Ga,So.asMinutes=Ka,So.asHours=qa,So.asDays=Ja,So.asWeeks=Ya,So.asMonths=Xa,So.asQuarters=Za,So.asYears=Qa,So.valueOf=$a,So._bubble=za,So.clone=eo,So.get=to,So.milliseconds=ro,So.seconds=io,So.minutes=ao,So.hours=oo,So.days=so,So.weeks=uo,So.months=co,So.years=lo,So.humanize=vo,So.toISOString=xo,So.toString=xo,So.toJSON=xo,So.locale=yi,So.localeData=xi,So.toIsoString=T(`toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)`,xo),So.lang=bi,P(`X`,0,0,`unix`),P(`x`,0,0,`valueOf`),F(`x`,Le),F(`X`,Be),Ze(`X`,function(e,t,n){n._d=new Date(parseFloat(e)*1e3)}),Ze(`x`,function(e,t,n){n._d=new Date(Ye(e))}),n.version=`2.30.1`,r(lr),n.fn=V,n.min=pr,n.max=mr,n.now=hr,n.utc=p,n.unix=xa,n.months=Oa,n.isDate=u,n.locale=kn,n.invalid=v,n.duration=Vr,n.isMoment=C,n.weekdays=Aa,n.parseZone=Sa,n.localeData=Mn,n.isDuration=br,n.monthsShort=ka,n.weekdaysMin=Ma,n.defineLocale=An,n.updateLocale=jn,n.locales=Nn,n.weekdaysShort=ja,n.normalizeUnits=xe,n.relativeTimeRounding=go,n.relativeTimeThreshold=_o,n.calendarFormat=ei,n.prototype=V,n.HTML5_FMT={DATETIME_LOCAL:`YYYY-MM-DDTHH:mm`,DATETIME_LOCAL_SECONDS:`YYYY-MM-DDTHH:mm:ss`,DATETIME_LOCAL_MS:`YYYY-MM-DDTHH:mm:ss.SSS`,DATE:`YYYY-MM-DD`,TIME:`HH:mm`,TIME_SECONDS:`HH:mm:ss`,TIME_MS:`HH:mm:ss.SSS`,WEEK:`GGGG-[W]WW`,MONTH:`YYYY-MM`},n}))}))(),1);function LP({issue:e,equipment:t,issueAttachments:n,reloadQueryFn:r,expanded:i=!0}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(i),f=e=>{r([`issue`,`attachment`,`status_mail`]),r([`issue`,`status_mail`])},m=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(`div`,{className:`p-3 mb-4 border-bottom`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-2`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(yr,{bg:`dark`,children:`Issue`}),(0,p.jsx)(`h4`,{className:e.date_closed?`text-danger mb-0`:`mb-0`,children:e.date_closed?(0,p.jsx)(`s`,{children:e.issue}):e.issue})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(B,{variant:`outline-primary`,size:`sm`,onClick:()=>u(e=>!e),"aria-label":`Toggle Details`,children:l?`Hide Details`:`Show Details`}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{o((0,p.jsx)(FP,{equipment:t,showModal:!0,onClose:e=>{c(!1),e&&f(e)},issue:e,attachments:m()})),c(!0)},"aria-label":`Edit Issue`,children:`Edit`})]})]}),l&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`mb-2`,children:(0,p.jsx)(kP,{children:e.description})}),(0,p.jsx)(`p`,{className:`mb-3`,children:e.actions}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-4 text-muted`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Creator`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.owner.full_name})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Created`}),(0,p.jsx)(`div`,{className:`text-body`,children:(0,IP.default)(e.date_created).format(`DD MMMM YYYY`)})]}),e.date_closed&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Date Closed`}),(0,p.jsx)(`div`,{className:`text-body`,children:(0,IP.default)(e.date_closed).format(`DD MMMM YYYY`)})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Forecast Up`}),(0,p.jsx)(`div`,{className:`text-body`,children:(0,IP.default)(e.forecast_up).format(`DD MMMM YYYY`)})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Issue Type`}),(0,p.jsxs)(`div`,{className:`text-body`,children:[e.issue_type===it.DEFAULT&&`Issue`,e.issue_type===it.ESCALATION&&`Escalation`,e.issue_type===it.PRIORITY&&`Priority`]})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Attachments`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.attachments})]}),e.updated_by&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update By`}),(0,p.jsx)(`div`,{className:`text-body`,children:e.updated_by.full_name})]}),e.last_update&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`small`,{className:`text-muted`,children:`Last Update`}),(0,p.jsx)(`div`,{className:`text-body`,children:(0,IP.default)(e.last_update).format(`DD MMMM YYYY`)})]})]})]}),s&&a]})}function RP({reservations:e}){if(!e||e.length<1)return(0,p.jsx)(p.Fragment,{});let t=e[0];return(0,p.jsx)(pl,{placement:`top`,overlay:(0,p.jsxs)(sl,{id:`tooltip-${t.id}`,children:[(0,p.jsx)(`h5`,{children:t.title}),(0,p.jsx)(`p`,{children:e[0].active?`Currently active`:`Upcoming in: ${q(e[0].start).format(`DD MMMM YYYY`)}`}),(0,p.jsx)(`p`,{children:e[1]?`Next upcoming reservation in: ${q(e[1].start).format(`DD MMMM YYYY`)}`:`No next upcoming reservations`})]}),children:(0,p.jsxs)(yr,{bg:e[0].active?`info`:`dark`,children:[`Reserved by: `,e[0].user.full_name]})})}function zP({equipment:e,modules:t,issues:n,issueAttachments:r,ecnNotes:i,ecnAttachments:a,reloadQueryFn:o,showIssues:s,reservations:c}){let[l,u]=(0,d.useState)(null),[f,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)([]),[x,S]=(0,d.useState)(void 0),[C,w]=(0,d.useState)([]),[T,E]=(0,d.useState)([]),D=e=>{o([`ecn`,`attachment`,`status_mail`]),w([...C,e])},O=e=>{o([`issue`,`status_mail`]),o([`issue`,`attachment`,`status_mail`]),E([...T,e])};(0,d.useEffect)(()=>{w(i),E(n),b(t.filter(t=>t.equipment.id===e.id&&!t.type.is_main_tool)),S(t.findLast(t=>t.equipment.id===e.id&&t.type.is_main_tool))},[i,n,e,t]);let k=e=>C.filter(t=>t.module_id===e),A=e=>T.filter(t=>t.module_id===e);return(0,p.jsxs)(`div`,{className:`card mb-4`,children:[(0,p.jsxs)(`div`,{className:`card-header d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsxs)(`h4`,{className:`mb-0`,children:[e.number,` - `,e.name]}),x&&(0,p.jsx)(Dd,{module:x}),x&&(0,p.jsx)(RP,{reservations:c.filter(e=>e.modules.some(e=>e.id===x.id))})]}),(0,p.jsxs)(ls,{as:br,title:`Action`,id:`bg-nested-dropdown`,children:[(0,p.jsx)(ss.Item,{eventKey:`1`,onClick:()=>{g((0,p.jsx)(Gb,{equipment:e,showModal:!0,onClose:e=>{v(!1),e&&D(e)}})),v(!0)},children:`New ECN`}),s!==1&&(0,p.jsx)(ss.Item,{eventKey:`1`,onClick:()=>{u((0,p.jsx)(FP,{equipment:e,showModal:!0,onClose:e=>{m(!1),e&&O(e)}})),m(!0)},children:`New Issue`})]})]}),(0,p.jsx)(`div`,{className:`card-body`,children:(0,p.jsxs)(Dl,{children:[x&&(0,p.jsx)(Ur,{xs:12,md:y.length>0?6:12,children:(0,p.jsx)(Pr,{className:`mb-3`,children:(0,p.jsxs)(Pr.Body,{children:[(0,p.jsxs)(Pr.Title,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{children:`Main module`}),(0,p.jsx)(`div`,{className:`ms-2`})]}),(0,p.jsxs)(`div`,{className:`mt-3`,children:[k(x.id).map((t,n)=>(0,p.jsx)(PP,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},n)),s!==1&&A(x.id).map((t,n)=>(0,p.jsx)(LP,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},n))]})]})})}),y.length>0&&(0,p.jsx)(Ur,{xs:12,md:x?6:12,children:y.map((t,n)=>(0,p.jsx)(Pr,{className:`mb-3`,children:(0,p.jsxs)(Pr.Body,{children:[(0,p.jsx)(Pr.Title,{className:`d-flex align-items-center`,children:(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(`span`,{children:t.name}),(0,p.jsx)(Dd,{module:t}),(0,p.jsx)(RP,{reservations:c.filter(e=>e.modules.some(e=>e.id===t.id))})]})}),(0,p.jsxs)(`div`,{className:`mt-3`,children:[k(t.id).map((t,n)=>(0,p.jsx)(PP,{ecn:t,equipment:e,ecnAttachments:a,reloadQueryFn:o,expanded:!0},n)),s!==1&&A(t.id).map((t,n)=>(0,p.jsx)(LP,{issue:t,equipment:e,issueAttachments:r,reloadQueryFn:o,expanded:s!==3},n))]})]})},n))})]})}),_&&h,f&&l]})}var BP=({showModal:e,onClose:t,message:n})=>{let{register:r,handleSubmit:i,setValue:a,reset:o,control:s}=Ed({defaultValues:{title:n?.title,description:n?.description,rooms:n?.rooms,type:n?.type,owner:n?.owner}}),[c,l]=(0,d.useState)([]),[u,m]=(0,d.useState)([]),[h,g]=(0,d.useState)(``),_=()=>document.documentElement.getAttribute(`data-bs-theme`)===`dark`,v={control:e=>({...e,backgroundColor:_()?`#212529`:e.backgroundColor,borderColor:_()?`#495057`:e.borderColor,color:_()?`#fff`:e.color}),menu:e=>({...e,backgroundColor:_()?`#212529`:e.backgroundColor}),option:(e,t)=>({...e,backgroundColor:_()?t.isSelected?`#0d6efd`:t.isFocused?`#343a40`:`#212529`:e.backgroundColor,color:_()?`#fff`:e.color}),singleValue:e=>({...e,color:_()?`#fff`:e.color}),multiValue:e=>({...e,backgroundColor:_()?`#343a40`:e.backgroundColor}),multiValueLabel:e=>({...e,color:_()?`#fff`:e.color}),input:e=>({...e,color:_()?`#fff`:e.color})},{statusMail:y}=(0,d.useContext)(iy);(0,d.useEffect)(()=>{f.default.get(`/list/room`).then(e=>{l((e.data._embedded.items||[]).map(e=>({value:e,label:e.name})))}).catch(e=>{console.error(`Error fetching rooms:`,e),g(`Error fetching rooms:`+e)}),f.default.get(`/list/location/message/type`).then(e=>{let t=y.filter.messageType,r=(e.data._embedded.items||[]).filter(e=>t.includes(e.id.toString())).map(e=>({value:e,label:e.type}));m(r),a(`type`,n?.type||r[0].value)}).catch(e=>{console.error(`Error fetching message types:`,e),g(`Error fetching message types:`+e)})},[]);let b=e=>e.title?e?.owner.value===void 0&&n?.owner===void 0?`owner`:e.rooms===void 0||e.rooms.map(e=>e.id).length<=0?`room`:e.type?``:`type`:`title`;return(0,p.jsx)(U,{show:e,size:`lg`,centered:!0,onHide:()=>t(n),children:(0,p.jsxs)(H,{onSubmit:i(async e=>{let r=b(e);if(r!==``){g(`Please fill: `+r);return}try{let r={title:e.title,description:e.description,owner:e?.owner.value||n?.owner.id,type:e.type.id,rooms:e.rooms.map(e=>e.id)},i;if(i=n?await f.default.patch(`/update/location/message/${n.id}`,r):await f.default.post(`/create/location/message`,r),i){t(i?.data),o();return}console.error(`No response received`),g(`No response received`)}catch(e){console.error(`Error submitting the form:`,e),g(`Error submitting the form:`+e)}}),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Edit status mail message`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Title`}),(0,p.jsx)(H.Control,{type:`text`,placeholder:`Enter the title`,...r(`title`)})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Message`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:3,placeholder:`Give the message`,...r(`description`)})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Wb,{control:s,...r(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Rooms`}),(0,p.jsx)(vu,{name:`rooms`,control:s,render:({field:e})=>(0,p.jsx)(cv,{isMulti:!0,options:c,classNamePrefix:`react-select`,placeholder:`Select one or more rooms`,value:c.filter(t=>e.value?.some(e=>e.id===t.value.id)),onChange:t=>e.onChange(t.map(e=>e.value)),styles:v})})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Type`}),(0,p.jsx)(vu,{name:`type`,control:s,render:({field:e})=>(0,p.jsx)(cv,{options:u,classNamePrefix:`react-select`,placeholder:`Select a message type`,value:u.find(t=>t.value.id===e.value?.id)||null,onChange:t=>e.onChange(t?.value),styles:v})})]})]}),(0,p.jsxs)(U.Footer,{children:[h!=``&&(0,p.jsx)(`span`,{className:`text-danger`,children:h}),(0,p.jsx)(B,{variant:`secondary`,onClick:()=>t(n),children:`Cancel`}),(0,p.jsx)(B,{variant:`primary`,type:`submit`,children:n?`Update Message`:`Create Message`})]})]})})};function VP({message:e}){let[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(e),s=e=>{o({...a,...e})};return(0,p.jsxs)(`div`,{className:`card mb-4`,children:[(0,p.jsxs)(`div`,{className:`card-header d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(yr,{bg:`dark`,children:a.type.type}),(0,p.jsx)(`h5`,{className:`mb-0`,children:a.title})]}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{n((0,p.jsx)(BP,{showModal:!0,onClose:e=>{i(!1),e&&s(e)},message:a})),i(!0)},children:`Edit`})]}),(0,p.jsx)(`div`,{className:`card-body`,children:(0,p.jsx)(kP,{children:a.description})}),(0,p.jsx)(`div`,{className:`card-footer bg-transparent`,children:(0,p.jsxs)(`small`,{className:`text-muted d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`span`,{children:[`Created: `,q(a.date_created).format(`DD MMM YYYY`)]}),a.last_update&&(0,p.jsxs)(`span`,{children:[`Updated: `,q(a.last_update).format(`DD MMM YYYY`)]}),a.rooms.length>0&&(0,p.jsxs)(`span`,{children:[`Rooms:`,` `,a.rooms.map((e,t)=>(0,p.jsxs)(d.default.Fragment,{children:[t>0&&`, `,e.name]},e.id))]}),(0,p.jsxs)(`span`,{children:[`Owner: `,a.owner.full_name]})]})}),r&&t]})}function HP({messageList:e,refetchFn:t}){let[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex gap-3`,children:[(0,p.jsx)(`h2`,{children:`Messages`}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`secondary`,onClick:()=>{r((0,p.jsx)(BP,{showModal:!0,onClose:e=>{a(!1),t()}})),a(!0)},children:`New message`})})]}),e.map((e,t)=>(0,p.jsx)(`div`,{children:(0,p.jsx)(VP,{message:e})},e.id)),i&&n]})}function UP({issue:e,moduleName:t,issueAttachments:n,equipment:r,reloadQueryFn:i}){let[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),l=e=>{i([`issue`,`status_mail`]),i([`issue`,`attachment`,`status_mail`])},u=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{className:`align-middle`,children:[(0,p.jsx)(`td`,{className:`text-nowrap`,children:t??`-`}),(0,p.jsx)(`td`,{children:e.issue}),(0,p.jsx)(`td`,{children:(0,p.jsx)(kP,{children:e.description})}),(0,p.jsx)(`td`,{className:`text-nowrap`,children:q(e.forecast_up).format(`DD MMMM YYYY`)}),(0,p.jsx)(`td`,{className:`text-nowrap`,children:e.owner.full_name}),(0,p.jsx)(`td`,{className:`text-center`,children:(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-outline-light`,onClick:()=>{if(!r){console.error(`equipment is null in the table`);return}c(!0),o((0,p.jsx)(FP,{equipment:r,showModal:!0,onClose:e=>{c(!1),e&&l(e)},issue:e,attachments:u()}))},children:`Edit`})})]},e.id),s&&a]})}function WP({issues:e,modules:t,issueAttachments:n,reloadQueryFn:r}){return(0,p.jsx)(`div`,{className:`table-responsive`,children:(0,p.jsxs)(`table`,{className:`table table-hover table-striped table-bordered table-sm`,children:[(0,p.jsx)(`thead`,{className:`bg-primary text-white`,children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{scope:`col`,children:`Module`}),(0,p.jsx)(`th`,{scope:`col`,children:`Issue`}),(0,p.jsx)(`th`,{scope:`col`,children:`Description`}),(0,p.jsx)(`th`,{scope:`col`,children:`Forecast Up`}),(0,p.jsx)(`th`,{scope:`col`,children:`Owner`}),(0,p.jsx)(`th`,{scope:`col`,className:`text-center`,children:`Actions`})]})}),(0,p.jsx)(`tbody`,{children:e.map(e=>(0,p.jsx)(UP,{issue:e,moduleName:t.find(t=>t.id===e.module_id)?.name,issueAttachments:n,equipment:t.find(t=>t.id===e.module_id)?.equipment,reloadQueryFn:r},e.id))})]})})}function GP({statusMail:e}){let[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(!1);return(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:async()=>{try{if(n(!0),!e.id||e.id<=0)throw Error(`Status Mail ID is not correctly set`);let t={status_mail:e.id};await f.default.post(`/send/status-mail`,t),i(!0)}catch(e){console.error(`Error sending status mail:`,e),alert(`Error sending status mail. Please try again.`)}finally{n(!1)}},disabled:t,"aria-label":`Toggle Details`,children:t?`Sending...`:r?`Sending successful`:`Send Status Mail`})}function KP(){let{statusMail:e}=(0,d.useContext)(iy),[t,n]=(0,d.useState)([]),r=(0,m.useQueryClient)(),i=(0,m.useQueries)({queries:[{queryKey:[`equipment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ee({statusMail:e})},{queryKey:[`module`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>oe({statusMail:e})},{queryKey:[`ecn`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ie({statusMail:e})},{queryKey:[`issue`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>P({statusMail:e})},{queryKey:[`messages`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>ce({statusMail:e})},{queryKey:[`ecn`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>N({statusMail:e})},{queryKey:[`issue`,`attachment`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>re({statusMail:e})},{queryKey:[`reservation`,`active`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>se({which:`active`})},{queryKey:[`reservation`,`upcoming`,`status_mail`,JSON.stringify(e.filter)],queryFn:()=>se({which:`upcoming`})}]}),a=t=>{let n=t;n.push(JSON.stringify(e.filter)),r.refetchQueries({queryKey:n})},[o,s,c,l,u,f,h,g,_]=i,v=i.some(e=>e.isLoading),y=i.some(e=>e.isError),b=i.every(e=>e.isSuccess);return(0,d.useEffect)(()=>{b&&n(o.data.items)},[b]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[`Status mail `,e.name]}),(0,p.jsx)(`div`,{children:(0,p.jsx)(GP,{statusMail:e})})]}),(0,p.jsx)(`p`,{children:e.subject}),v&&(0,p.jsx)(vr,{variant:`info`,children:`Loading status mail`}),y&&(0,p.jsx)(vr,{variant:`danger`,children:`Error loading status mail`}),b&&e.show_issues_with_priority&&(()=>{let e=l.data.items.filter(e=>e.issue_type===2);return e.length===0?(0,p.jsx)(p.Fragment,{}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{children:`Issues with priority`}),(0,p.jsx)(WP,{issues:e,modules:s.data.items,issueAttachments:h.data.items,reloadQueryFn:a})]})})(),b&&u.data&&(0,p.jsx)(HP,{messageList:u.data.items,refetchFn:u.refetch}),b&&(()=>{if(!t.length)return(0,p.jsx)(`p`,{children:`No equipment available.`});t.sort((t,n)=>e.classification===ct.ROOM?t.room.name.localeCompare(n.room.name):t.area&&n.area&&e.classification===ct.AREA?t.area.title.localeCompare(n.area.title):t.area&&n.area&&e.classification===ct.AREA_PER_FACILITY?t.area.facility.title.localeCompare(n.area.facility.title)||t.area.title.localeCompare(n.area.title):0);let n,r=null,i=``;return t.map((t,o)=>{let u=[];return e.classification===ct.ROOM?t.room.name!==i&&(u.push((0,p.jsxs)(`h2`,{children:[`Room: `,t.room.name]},`room-${t.room.name}`)),i=t.room.name):e.classification===ct.AREA?t.area&&t.area!==r&&(u.push((0,p.jsxs)(`h2`,{children:[`Area: `,t.area.title]},`area-${t.area.id}`)),r=t.area):e.classification===ct.AREA_PER_FACILITY&&(t.area&&t.area.facility!==n&&(u.push((0,p.jsxs)(`h2`,{children:[`Facility: `,t.area.facility.title]},`facility-${t.area.facility.id}`)),n=t.area.facility),t.area&&t.area!==r&&(u.push((0,p.jsxs)(`h4`,{children:[`Area: `,t.area.title]},`area-${t.area.id}`)),r=t.area)),u.push((0,p.jsx)(zP,{equipment:t,modules:s.data.items,issues:l.data.items,issueAttachments:h.data.items,ecnNotes:c.data.items,ecnAttachments:f.data.items,reloadQueryFn:a,showIssues:e.show_issues,reservations:e.show_reservations?g.data.items.concat(_.data.items):[]},o)),u})})()]})}function qP(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;let t=new Date(e);return isNaN(t.getTime())?null:t}function JP(e,t){let n=qP(e);if(!n)return``;let r=e=>e.toString().padStart(2,`0`),i={YYYY:n.getFullYear().toString(),YY:n.getFullYear().toString().slice(-2),MM:r(n.getMonth()+1),DD:r(n.getDate()),HH:r(n.getHours()),mm:r(n.getMinutes()),H:n.getHours().toString(),m:n.getMinutes().toString()},a=t;return Object.keys(i).sort((e,t)=>t.length-e.length).forEach(e=>{a=a.replace(new RegExp(e,`g`),i[e])}),a}function YP(e,t=`DD-MM-YY HH:mm`){return JP(e,t)}function XP({monitor:e}){let{environment:t}=(0,g.useParams)(),[n]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,e],queryFn:()=>me({monitorId:e.id})}]});return n.isLoading?(0,p.jsx)(`div`,{children:`Loading requirements...`}):n.data?.items.map((n,r)=>{let i=`bg-secondary-subtle`;if(n.latest_result)for(let e=0;e<n.latest_result.values.length;e++){if(n.latest_result.values[e].value_is_valid===!1){i=`bg-danger-subtle`;break}if(n.latest_result.values[e].value_is_valid===!0){i=`bg-success-subtle`;break}}return(0,p.jsx)(Pr,{className:`mb-2 me-2`,children:(0,p.jsxs)(Pr.Body,{className:i,children:[(0,p.jsx)(Pr.Title,{children:(0,p.jsx)(g.Link,{to:`/${t}/operator/monitor/`+e.id,children:e.name})}),(0,p.jsxs)(Pr.Text,{children:[n.title,n.latest_result&&(0,p.jsxs)(p.Fragment,{children:[`Latest measurement: `,YP(n.latest_result.date_created,`DD-MM-YY HH:mm`)]})]})]})},r)})}var ZP=({moduleId:e,size:t})=>{let[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(``);function c(){f.default.create().post(`create/equipment/module/changelog`,{module:e,changelog:o}).finally(()=>{r(!1),a(!0),s(``)})}let l=e=>{s(e.target.value)};function u(){return(0,p.jsx)(Rl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Il,{onClose:()=>a(!1),show:i,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Il.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Assist logged`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Il.Body,{children:`Assist was logged successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,size:t,onClick:()=>r(!0),children:`Log assist`}),(0,p.jsxs)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Log assist`})}),(0,p.jsx)(U.Body,{children:(0,p.jsx)(H,{children:(0,p.jsxs)(H.Group,{className:`mb-3`,controlId:`modal.ControlTextarea1`,children:[(0,p.jsx)(H.Label,{children:`Describe the assist`}),(0,p.jsx)(H.Control,{as:`textarea`,rows:3,value:o,onChange:e=>l(e)})]})})}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:()=>c(),children:`Log assist`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{r(!1)},children:`Close`})]})]}),(0,p.jsx)(u,{})]})},QP=(0,d.createContext)({equipment:{},reloadEquipment:()=>{}});function $P({issue:e,equipment:t,issueAttachments:n,reloadQueryFn:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(e),u=e=>{r([`issue`,t.name]),r([`issue`,`attachment`,t.name]),l({...c,...e})},f=()=>n.filter(t=>t.issue.id===e.id);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(Pr,{className:`my-2`,children:[(0,p.jsxs)(Pr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(Pr.Title,{children:[(0,p.jsx)(yr,{bg:`dark`,children:`Issue`}),` `,c.issue]}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{a((0,p.jsx)(FP,{equipment:t,showModal:!0,onClose:e=>{s(!1),e&&u(e)},issue:c,attachments:f()})),s(!0)},children:`Edit`})]}),(0,p.jsx)(Pr.Text,{children:(0,p.jsx)(kP,{children:c.description})})]}),(0,p.jsxs)(Zs,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Created:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:YP(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Owner:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.owner.full_name})]}),c.updated_by&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Updated:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.updated_by.full_name}),(0,p.jsxs)(`span`,{className:`ms-1`,children:[`(`,YP(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},c.module_id),o&&i]})}function eF({ecn:e,equipment:t,ecnAttachments:n,reloadQueryFn:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(e),u=e=>{r([`ecn`,t.name]),r([`ecn`,`attachment`,t.name]),l({...c,...e})},f=()=>n.filter(t=>t.ecn.id===e.id);return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(Pr,{className:`my-2`,children:[(0,p.jsxs)(Pr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(Pr.Title,{children:[(0,p.jsx)(yr,{bg:`dark`,children:`ECN`}),` `,e.ecn]}),(0,p.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>{a((0,p.jsx)(Gb,{equipment:t,showModal:!0,onClose:e=>{s(!1),e&&u(e)},ecn:c,attachments:f()})),s(!0)},children:`Edit`})]}),(0,p.jsx)(Pr.Text,{children:(0,p.jsx)(kP,{children:e.description})})]}),(0,p.jsxs)(Zs,{className:`list-group-flush`,children:[c.date_created&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Created:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:YP(c.date_created,`DD-MM-YY HH:mm`)})]}),c.owner&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Owner:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.owner.full_name})]}),c.updated_by&&(0,p.jsxs)(Zs.Item,{className:`d-flex align-items-center`,children:[(0,p.jsx)(`span`,{className:`text-muted`,children:`Updated:`}),(0,p.jsx)(`span`,{className:`ms-1`,children:c.updated_by.full_name}),(0,p.jsxs)(`span`,{className:`ms-1`,children:[`(`,YP(c.last_update,`DD-MM-YY HH:mm`),`)`]})]})]})]},e.module_id),o&&i]})}function tF(){let{id:e}=(0,g.useParams)(),[t,n]=(0,d.useState)([]),r=(0,m.useQueries)({queries:[{queryKey:[`service`,`equipment`,e],queryFn:()=>Ve({equipmentId:Number(e)})}]}),[i]=r,a=r.some(e=>e.isLoading),o=r.some(e=>e.isError),s=r.every(e=>e.isSuccess);if((0,d.useEffect)(()=>{s&&n(i.data.items)},[s,i.data]),a)return(0,p.jsx)(`div`,{children:`Loading...`});if(o)return(0,p.jsx)(`div`,{children:`Error loading services.`});let c=e=>{if(e<60)return`${e} min`;let t=Math.floor(e/60),n=e%60;return`${t}h ${n>0?`${n}min`:``}`.trim()};return i.data.items.length===0?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsx)(vr,{variant:`info`,children:`No services found`})]}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Services`}),(0,p.jsxs)(kl,{striped:!0,bordered:!0,hover:!0,responsive:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Id`}),(0,p.jsx)(`th`,{children:`Name`}),(0,p.jsx)(`th`,{children:`Type`}),(0,p.jsx)(`th`,{children:`Team`}),(0,p.jsx)(`th`,{children:`Department`}),(0,p.jsx)(`th`,{children:`Duration`}),(0,p.jsx)(`th`,{children:`Report2`})]})}),(0,p.jsx)(`tbody`,{children:t.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.id}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${window.location.pathname.split(`/`)[1]}/service/details/${e.id}/general.html`,children:e.name})}),(0,p.jsx)(`td`,{children:e.type?.name||`N/A`}),(0,p.jsx)(`td`,{children:e.team?.name||`N/A`}),(0,p.jsx)(`td`,{children:e.department?.name||`N/A`}),(0,p.jsx)(`td`,{children:c(e.minutes_needed_for_service)}),(0,p.jsx)(`td`,{children:e.latest_event_report_id&&(0,p.jsx)(`a`,{className:`btn btn-primary btn-sm`,href:`/${window.location.pathname.split(`/`)[1]}/service/event/report/${e.latest_event_report_id}/results`,children:`View Report`})})]},e.id))})]})]})}function nF(){let{environment:e}=(0,g.useParams)(),{equipment:t}=(0,d.useContext)(QP),n=(0,m.useQueryClient)(),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(!1),[f,h,_,v,y,b,x]=(0,m.useQueries)({queries:[{queryKey:[`runs`,t.name,e],queryFn:()=>De({firstUnfinishedStepEquipment:t,environment:e})},{queryKey:[`monitors`,t.name],queryFn:()=>he({equipment:t})},{queryKey:[`ecn`,t.name],queryFn:()=>ie({equipment:t})},{queryKey:[`issue`,t.name],queryFn:()=>P({equipment:t})},{queryKey:[`module`,t.name],queryFn:()=>oe({equipment:t})},{queryKey:[`ecn`,`attachment`,t.name],queryFn:()=>N({equipment:t})},{queryKey:[`issue`,`attachment`,t.name],queryFn:()=>re({equipment:t})}]}),S=e=>{n.invalidateQueries({queryKey:e})},C=e=>e?_.data?.items.filter(t=>t.module_id===e):[],w=e=>e?v.data?.items.filter(t=>t.module_id===e):[],T=()=>{c((0,p.jsx)(Gb,{equipment:t,showModal:!0,onClose:()=>{u(!1),setTimeout(()=>{S([`ecn`,t.name]),S([`ecn`,`attachment`,t.name])},100)}})),u(!0)},E=()=>{i((0,p.jsx)(FP,{equipment:t,showModal:!0,onClose:()=>{o(!1),setTimeout(()=>{S([`issue`,t.name]),S([`issue`,`attachment`,t.name])},100)}})),o(!0)};return(0,p.jsxs)(Wr,{fluid:!0,children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-left`,children:h.data?.items&&h.data.items.map((e,t)=>(0,p.jsx)(XP,{monitor:e},t))}),(0,p.jsxs)(Dl,{children:[(0,p.jsxs)(Ur,{md:8,children:[(0,p.jsx)(`h2`,{children:`Runs`}),f.isLoading&&(0,p.jsx)(`div`,{children:`Loading...`}),` `,f.isError&&(0,p.jsx)(`div`,{children:`Error...`}),f.isFetched&&f.data&&f.data?.items.length===0&&(0,p.jsx)(vr,{variant:`info`,children:`No runs found`}),f.isFetched&&f.data&&f.data?.items.length>0&&(0,p.jsxs)(kl,{striped:!0,bordered:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Run`}),(0,p.jsx)(`th`,{children:`Priority`}),(0,p.jsx)(`th`,{children:`Hold Code`}),(0,p.jsx)(`th`,{children:`Batch Card`}),(0,p.jsx)(`th`,{children:`Project`})]})}),(0,p.jsx)(`tbody`,{children:f.data?.items.map((t,n)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsxs)(`td`,{children:[t.first_unfinished_step&&(0,p.jsx)(g.Link,{to:`/${e}/operator/run/step/${t.first_unfinished_step.id}`,children:t.name}),t.first_unfinished_step===void 0&&t.last_finished_step&&(0,p.jsx)(g.Link,{to:`/${e}/operator/run/step/${t.last_finished_step.id}`,children:t.name})]}),(0,p.jsxs)(`td`,{children:[t.priority&&(0,p.jsx)(`span`,{className:`badge`,style:{backgroundColor:t.priority.priority.back_color,color:t.priority.priority.front_color},children:t.priority.priority.code}),!t.priority&&(0,p.jsx)(`span`,{className:`badge bg-info`,children:`NORMAL`})]}),(0,p.jsx)(`td`,{children:t.hold_code&&(0,p.jsx)(`span`,{className:`badge handle`,style:{backgroundColor:t.hold_code.hold_code.back_color,color:t.hold_code.hold_code.front_color},children:t.hold_code.hold_code.code})}),(0,p.jsx)(`td`,{children:t.batch_card&&t.batch_card.content&&(0,p.jsx)(`span`,{className:`text-danger`,children:t.batch_card.content})}),(0,p.jsx)(`td`,{children:t.project.name})]},n))})]}),(0,p.jsx)(tF,{})]}),(0,p.jsxs)(Ur,{md:4,children:[(0,p.jsx)(`h2`,{children:`Assistance`}),y.data?.items.map((e,n)=>(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`h3`,{children:e.type.is_main_tool?`Main tool`:e.name}),(0,p.jsx)(`div`,{children:(0,p.jsx)(Dd,{module:e})})]}),(0,p.jsxs)(`div`,{className:`pb-lg-5`,children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-between`,children:(0,p.jsxs)(`div`,{className:`d-flex gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:E,children:`New Issue`})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:T,children:`New ECN`})}),(0,p.jsx)(`div`,{children:e.type.is_main_tool&&(0,p.jsx)(ZP,{size:`sm`,moduleId:e.id})})]})}),C(e.id)?.map((e,r)=>(0,p.jsx)(eF,{ecn:e,equipment:t,ecnAttachments:b.data?.items??[],reloadQueryFn:S},`ecn-${n}-${r}`)),w(e.id)?.map((e,r)=>(0,p.jsx)($P,{issue:e,equipment:t,issueAttachments:x.data?.items??[],reloadQueryFn:S},`issue-${n}-${r}`))]})]},n))]})]}),l&&s,a&&r]})}var rF=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{e===null&&k({id:parseInt(n)}).then(t)},[n,e]);function r(){k({id:parseInt(n)}).then(t)}return{equipment:e,setEquipment:t,reloadEquipment:r}};function iF({children:e}){let{equipment:t,reloadEquipment:n}=rF();return t===null?(0,p.jsx)(Ct,{children:(0,p.jsx)(vt,{message:`Loading equipment...`})}):(0,p.jsx)(Ct,{children:(0,p.jsx)(QP.Provider,{value:{equipment:t,reloadEquipment:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading...`}),children:e})})})}function aF(){let{equipment:e}=(0,d.useContext)(QP),t=(0,m.useQueries)({queries:[{queryKey:[`activeReservationQuery`,e],queryFn:()=>se({equipment:e,which:`active`})},{queryKey:[`upcomingReservationQuery`,e],queryFn:()=>se({equipment:e,which:`upcoming`})},{queryKey:[`modules`,e],queryFn:()=>oe({equipment:e})}]}),[n,r,i]=t,a=t.some(e=>e.isLoading);t.some(e=>e.isError);let o=t.every(e=>e.isSuccess);return a?(0,p.jsx)(`div`,{children:`Loading...`}):(i.data?.items.findLast(e=>e.type.is_main_tool),o&&(0,p.jsxs)(`div`,{className:`d-flex align-items-center justify-content-between mb-3`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[e.name,` Operator Dashboard`]}),(0,p.jsxs)(`div`,{children:[n.data?.items.map((e,t)=>(0,p.jsxs)(`div`,{className:`mx-2 p-2 rounded border-danger`,style:{backgroundColor:e.color},children:[(0,p.jsx)(`i`,{className:`fa fa-calendar-o text-white pe-2`,"aria-hidden":`true`}),`Active reservation`,(0,p.jsx)(`br`,{}),`Until `,YP(e.end,`DD-MM-YY HH:mm`),` by `,e.user.full_name]},t)),r.data?.items.map((e,t)=>(0,p.jsxs)(`div`,{className:`mx-2 p-2 rounded border-success border-2`,style:{backgroundColor:e.color},children:[(0,p.jsx)(`i`,{className:`fa fa-calendar-o text-white pe-2`,"aria-hidden":`true`}),`Next reservation`,(0,p.jsx)(`br`,{}),YP(e.start,`DD-MM-YY HH:mm`),(0,p.jsx)(`br`,{}),e.user.full_name]},t))]})]}))}function oF(){return(0,p.jsxs)(iF,{children:[(0,p.jsx)(aF,{}),(0,p.jsx)(g.Outlet,{})]})}function sF({children:e}){let{id:t}=(0,g.useParams)(),n=(0,m.useQuery)({queryKey:[`statusMail`,t],queryFn:()=>j({id:parseInt(t)}),enabled:!!t});return n.isLoading||n.isFetching?(0,p.jsx)(Ct,{children:(0,p.jsx)(vt,{message:`Loading status mail...`})}):(0,p.jsx)(Ct,{children:(0,p.jsx)(iy.Provider,{value:{statusMail:n.data},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading...`}),children:e})})})}var cF=()=>ht(),lF,uF;function dF(e){let[t,n]=(0,d.useState)(!0),[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(!1),s=()=>{n(!1),o(!0)};return(0,d.useEffect)(()=>{if(!document){i(Error(`[ScriptLoadingError] document not defined when attempting to load ${e}`));return}let t=document.querySelector(`script[src="${e}"]`);if(t?.dataset.loaded){s();return}let n=t||document.createElement(`script`);t||(n.src=e),n.addEventListener(`load`,()=>{n.dataset.loaded=`1`,s()}),n.addEventListener(`error`,t=>{console.error(`Failed to load script:`,e,t),i(Error(`[ScriptLoadingError] Failed to load script: ${e}`))}),t||document.head.append(n)},[]),{isLoading:t,error:r,isSuccess:a}}var fF=e=>e&&e.charts,pF=(e,t)=>{let{controls:n,toolbarItems:r,getChartEditor:i}=e;return t&&t.charts&&t.visualization&&t.visualization.ChartWrapper&&t.visualization.Dashboard&&(!n||t.visualization.ChartWrapper)&&(!i||t.visualization.ChartEditor)&&(!r||t.visualization.drawToolbar)},mF=e=>window.google;function hF(e){let{chartVersion:t=`current`,chartPackages:n=[`corechart`,`controls`],chartLanguage:r=`en`,mapsApiKey:i}=e,[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),{isLoading:f,error:p,isSuccess:m}=dF(e.chartLoaderScriptUrl||`https://www.gstatic.com/charts/loader.js`);return(0,d.useEffect)(()=>{if(!m)return;let a=mF();if(!fF(a)){c(Error(`[ScriptInitializationError] Script loaded but Google not attached to window.`));return}if(pF(e,a)){o(a);return}a.charts.load(t,{packages:n,language:r,mapsApiKey:i}),a.charts.setOnLoadCallback(()=>{if(!pF(e,a)){let e=Error(`[GoogleChartsInitializationError] Google Charts not ready after load callback.`);console.error(e),u(e);return}o(a)})},[m]),{error:p||s||l,isLoading:f,google:a}}var gF={legend_toggle:!1,options:{},legendToggle:!1,getChartWrapper:()=>{},spreadSheetQueryParameters:{headers:1,gid:1},rootProps:{},chartWrapperParams:{},chartLoaderScriptUrl:`https://www.gstatic.com/charts/loader.js`},_F=e=>{let{isReady:t,chartControls:n,filter:r}=e;return!t||!n||!n?.length?null:d.default.createElement(d.default.Fragment,null,n.filter(e=>{let{controlProp:t,control:n}=e;return r?r({control:n,controlProp:t}):!0}).map(e=>{let{control:t}=e;return d.default.createElement(`div`,{key:t.getContainerId(),id:t.getContainerId()})}))},vF=0,yF=()=>(vF+=1,`reactgooglegraph-${vF}`),bF=class{};lF=bF,St(bF,`initializeControls`,e=>{for(let t=0;t<e.length;t+=1){let{controlType:n,options:r,controlWrapperParams:i}=e[t].controlProp;i&&`state`in i&&e[t].control.setState(i.state),e[t].control.setOptions(r),e[t].control.setControlType(n)}}),St(bF,`listenToControlEvents`,(e,t)=>{let{google:n}=t;return e.flatMap(e=>{let{control:r,controlProp:i}=e,{controlEvents:a=[]}=i;return a.map(e=>{let{callback:i,eventName:a}=e;return n.visualization.events.addListener(r,a,function(){for(var e=arguments.length,a=Array(e),o=0;o<e;o++)a[o]=arguments[o];i({chartWrapper:null,controlWrapper:r,props:t,google:n,eventArgs:a})})})})}),St(bF,`createControlId`,e=>{let t;return t=e===void 0?`googlechart-control-${yF()}`:e,t}),St(bF,`createChartControls`,e=>{let{controls:t,google:n}=e;return t?t.map((e,t)=>{let{controlID:r,controlType:i,options:a,controlWrapperParams:o}=e,s=lF.createControlId(r);return{controlProp:e,control:new n.visualization.ControlWrapper({containerId:s,controlType:i,options:a,...o})}}):null}),St(bF,`addControls`,e=>{let{chartWrapper:t,chartDashboard:n}=e,r=lF.createChartControls(e);return!r||!n||!t?null:(n.bind(r.map(e=>{let{control:t}=e;return t}),t),lF.initializeControls(r),r)});var xF=e=>{let[t,n]=d.useState(null);return[d.useMemo(()=>!t||!e?null:e.map((e,n)=>{let r=t[n];return r?{controlProp:e,control:r}:void 0}).flatMap(e=>e?[e]:[]),[t,e]),n]},SF=(e,t)=>{d.useEffect(()=>{let n=bF.listenToControlEvents(e??[],t);return()=>{n.forEach(e=>{t.google.visualization.events.removeListener(e)})}},[e,t])},CF=e=>{let[t,n]=xF(e.controls);return SF(t??[],e),{addControls:e=>{n(bF.addControls(e)?.map(e=>e.control)??null)},renderControl:n=>{let{chartWrapper:r,chartDashboard:i}=e;return d.createElement(_F,{...e,isReady:!!(r&&i),chartControls:t,filter:n})}}},wF=e=>{let t=d.useRef(null);return{chartId:(()=>{let{graphID:n,graph_id:r}=e,i=n||r,a;return a=i||t.current||yF(),t.current=a,t.current})()}},TF=[`#3366CC`,`#DC3912`,`#FF9900`,`#109618`,`#990099`,`#3B3EAC`,`#0099C6`,`#DD4477`,`#66AA00`,`#B82E2E`,`#316395`,`#994499`,`#22AA99`,`#AAAA11`,`#6633CC`,`#E67300`,`#8B0707`,`#329262`,`#5574A6`,`#3B3EAC`],EF=async function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return new Promise((r,i)=>{let a=`${n.headers?`headers=${n.headers}`:`headers=0`}`,o=`${n.query?`&tq=${encodeURIComponent(n.query)}`:``}`,s=`${t}/gviz/tq?${`${a}${`${n.gid?`&gid=${n.gid}`:``}`}${`${n.sheet?`&sheet=${n.sheet}`:``}`}${o}${`${n.access_token?`&access_token=${n.access_token}`:``}`}`}`;new e.visualization.Query(s).send(e=>{e.isError()?i(`Error in query: ${e.getMessage()} ${e.getDetailedMessage()}`):r(e.getDataTable())})})},DF=`#CCCCCC`,OF=class{};uF=OF,St(OF,`grayOutHiddenColumnsLabel`,(e,t)=>{let{googleChartWrapper:n,options:r}=e;if(!n){console.error(`googleChartWrapper is not defined`);return}let i=n.getDataTable();if(!i)return;let a=i.getNumberOfColumns();if(!(t.length>0))return;let o=Array.from({length:a-1}).map((e,n)=>{let a=uF.getColumnId(i,n+1);return t.includes(a)?DF:r&&r.colors?r.colors[n]:TF[n]});n.setOptions({...r,colors:o}),n.draw()}),St(OF,`listenToLegendToggle`,(e,t)=>{let[n,r]=t,{google:i,googleChartWrapper:a}=e;if(!a){console.error(`googleChartWrapper is not defined`);return}return i.visualization.events.addListener(a,`select`,()=>{let e=a.getChart().getSelection(),t=a.getDataTable();if(e.length===0||e[0].row!==null||!t)return;let i=e[0].column,o=uF.getColumnId(t,i);n?.includes(o)?r(e=>[...e.filter(e=>e!==o)]):r(e=>[...e,o])})}),St(OF,`draw`,async e=>{let{data:t,diffdata:n,rows:r,columns:i,options:a,chartType:o,formatters:s,spreadSheetUrl:c,spreadSheetQueryParameters:l,googleChartDashboard:u,googleChartWrapper:d,google:f,hiddenColumns:p,legendToggle:m,legend_toggle:h}=e;if(!d){console.error(`draw was called with googleChartWrapper = null`);return}let g,_=null;if(n){let e=f.visualization.arrayToDataTable(n.old),t=f.visualization.arrayToDataTable(n.new);_=f.visualization[o].prototype.computeDiff(e,t)}g=t?t instanceof f.visualization.DataTable?t:Array.isArray(t)?f.visualization.arrayToDataTable(t):new f.visualization.DataTable(t):r&&i?f.visualization.arrayToDataTable([i,...r]):c?await EF(f,c,l):f.visualization.arrayToDataTable([]);let v=g.getNumberOfColumns(),y=Array(v).fill(0).map((e,t)=>{let n=uF.getColumnId(g,t);return p.includes(n)?{label:g.getColumnLabel(t),type:g.getColumnType(t),calc:()=>null}:t}),b=d.getChart();d.getChartType()===`Timeline`&&b&&b.clearChart(),d.setChartType(o),d.setOptions(a||{});let x=new f.visualization.DataView(g);x.setColumns(y),d.setDataTable(x),d.draw(),u&&u.draw(g),_&&(d.setDataTable(_),d.draw()),s&&(uF.applyFormatters({dataTable:g,formatters:s,google:f}),d.setDataTable(g),d.draw()),(m===!0||h===!0)&&uF.grayOutHiddenColumnsLabel(e,p)}),St(OF,`getColumnId`,(e,t)=>e.getColumnId(t)||e.getColumnLabel(t)),St(OF,`applyFormatters`,e=>{let{dataTable:t,formatters:n,google:r}=e;for(let e of n)switch(e.type){case`ArrowFormat`:new r.visualization.ArrowFormat(e.options).format(t,e.column);return;case`BarFormat`:new r.visualization.BarFormat(e.options).format(t,e.column);return;case`ColorFormat`:{let n=new r.visualization.ColorFormat(e.options),{ranges:i}=e;if(i)for(let e of i)n.addRange(...e);n.format(t,e.column);return}case`DateFormat`:new r.visualization.DateFormat(e.options).format(t,e.column);return;case`NumberFormat`:new r.visualization.NumberFormat(e.options).format(t,e.column);return;case`PatternFormat`:new r.visualization.PatternFormat(e.options).format(t,e.column);return;default:console.warn(`Unknown formatter type: ${e.type}`);return}});var kF=e=>{let{google:t,googleChartWrapper:n,googleChartDashboard:r}=e,[i,a]=d.useState([]);d.useEffect(()=>{n&&OF.draw({...e,hiddenColumns:i,googleChartWrapper:n,googleChartDashboard:r,google:t})},[i,e.data,e.rows,e.columns,e.options,e.chartLoaderScriptUrl,e.chartType,e.formatters,e.spreadSheetUrl,e.spreadSheetQueryParameters,e.legendToggle,e.legend_toggle]);let o=()=>{let{googleChartWrapper:t}=e;t&&t.draw()},s=n=>{let s=[],{legendToggle:c,legend_toggle:l}=e;if(OF.draw({...e,hiddenColumns:i,googleChartWrapper:n,googleChartDashboard:r,google:t}),window.addEventListener(`resize`,o),l||c){let t=OF.listenToLegendToggle(e,[i,a]);t&&s.push(t)}return s},c=(e,n)=>{window.removeEventListener(`resize`,o),n.forEach(e=>{t.visualization.events.removeListener(e)}),e.getChartType()===`Timeline`&&e.getChart()&&e.getChart().clearChart()};d.useEffect(()=>{if(!n)return;let e=s(n);return()=>{c(n,e)}},[n,s,c])},AF=e=>{let{chartEvents:t,google:n,googleChartWrapper:r}=e;if(t){if(!r){console.warn(`listenToEvents was called before chart wrapper ready.`);return}return t.map(t=>{let{eventName:i,callback:a}=t;return n.visualization.events.addListener(r,i,function(){for(var t=arguments.length,i=Array(t),o=0;o<t;o++)i[o]=arguments[o];a({chartWrapper:r,props:e,google:n,eventArgs:i})})})}},jF=e=>{(0,d.useEffect)(()=>{if(!e.googleChartWrapper)return;let t=AF(e);return()=>{t?.forEach(t=>{e.google.visualization.events.removeListener(t)})}},[e])},MF=e=>{let[t,n]=d.useState(null),[r,i]=d.useState(null),{addControls:a,renderControl:o}=CF({...e,chartDashboard:r,chartWrapper:t});jF({...e,googleChartWrapper:t});let{chartId:s}=wF(e),c=d.useRef(null),l=d.useRef(null);d.useEffect(()=>{let{options:t,google:r,chartType:o,chartWrapperParams:u,toolbarItems:d,getChartEditor:f,getChartWrapper:p,onLoad:m}=e,h={chartType:o,options:t,containerId:s,...u},g=new r.visualization.ChartWrapper(h);g.setOptions(t||{}),p?.(g,r);let _=new r.visualization.Dashboard(c.current);d&&r.visualization.drawToolbar(l.current,d);let v=null;f&&(v=new r.visualization.ChartEditor,f({chartEditor:v,chartWrapper:g,google:r})),a({...e,chartDashboard:_,chartWrapper:g}),n(g),i(_),m?.(r,{google:r,chartWrapper:g,chartEditor:v,chartDashboard:_})},[]),kF({...e,googleChartWrapper:t,googleChartDashboard:r});let u=()=>{let{width:t,height:n,options:r,style:i,className:a,rootProps:o,google:c}=e,l={height:n||r&&r.height,width:t||r&&r.width,...i};return d.createElement(`div`,{id:s,style:l,className:a,...o})},f=()=>e.toolbarItems?d.createElement(`div`,{ref:l}):null,{width:p,height:m,options:h,style:g}=e,_={height:m||h&&h.height,width:p||h&&h.width,...g};return e.render?d.createElement(`div`,{ref:c,style:_},d.createElement(`div`,{ref:l,id:`toolbar`}),e.render({renderChart:u,renderControl:o,renderToolbar:f})):d.createElement(`div`,{ref:c,style:_},o(e=>{let{controlProp:t}=e;return t.controlPosition!==`bottom`}),u(),o(e=>{let{controlProp:t}=e;return t.controlPosition===`bottom`}),f())},NF=d.createContext(gF),PF=e=>{let{children:t,value:n}=e;return d.createElement(NF.Provider,{value:n},t)},FF=e=>{let{google:t,isLoading:n,error:r}=hF(e);return n?e.loader??null:r?e.errorElement??null:t?d.default.createElement(MF,{google:t,...e}):null},IF=e=>{let t={...gF,...e};return d.default.createElement(PF,{value:t},d.default.createElement(FF,t))},LF;(function(e){e.annotation=`annotation`,e.annotationText=`annotationText`,e.certainty=`certainty`,e.emphasis=`emphasis`,e.interval=`interval`,e.scope=`scope`,e.style=`style`,e.tooltip=`tooltip`,e.domain=`domain`})(LF||(LF={}));function RF({target:e,results:t}){let n={title:e.logging_parameter.name,curveType:`function`,series:{0:{pointSize:10},1:{},2:{},3:{}},legend:{position:`bottom`}},r=[[{type:`date`,label:`Date`},`Value`]],i=1;return e.target&&(r[0].push(`Target`),n.series[i]={color:`#38e22c`,lineWidth:2,pointShape:{type:`square`}},i++),e.min_value&&(r[0].push(`Min`),n.series[i]={color:`#e2431e`,lineWidth:2,pointShape:{type:`triangle`},pointSize:10},i++),e.max_value&&(r[0].push(`Max`),n.series[i]={color:`#e2431e`,lineWidth:2,pointShape:{type:`triangle`,rotation:180},pointSize:10}),t.forEach(t=>{t.values.filter(t=>t.logging_parameter.id===e.logging_parameter.id).filter(e=>e.float_value!==0).forEach(n=>{let i=new Date(t.date_created);r.push([i,n.float_value]),e.target&&r[r.length-1].push(e.target),e.min_value&&r[r.length-1].push(e.min_value),e.max_value&&r[r.length-1].push(e.max_value)})}),r.length===1?(0,p.jsx)(`div`,{className:`text-center`,children:`No data available`}):(0,p.jsx)(IF,{chartType:`ScatterChart`,width:`100%`,height:`400px`,data:r,options:n})}var zF=({data:e,setPage:t,setPageSize:n,pageSize:r,isPlaceholderData:i})=>{if(e===void 0||i)return(0,p.jsx)(p.Fragment,{});let a=[];for(let n=1;n<=e.amountOfPages;n++)a.push((0,p.jsx)(Sl.Item,{active:n===e.currentPage,onClick:()=>t(e=>n),children:n},n));return(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(`div`,{className:`d-flex gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{size:`sm`,onClick:()=>t(e=>Math.max(e-1,0)),disabled:e.currentPage===1,children:`Previous Page`})}),(0,p.jsx)(Sl,{size:`sm`,children:a.map((e,t)=>(0,p.jsx)(`div`,{children:e},t))}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{size:`sm`,onClick:()=>{!i&&e.hasMore&&t(e=>e+1)},disabled:i||!e.hasMore,children:`Next Page`})})]}),n===void 0?null:(0,p.jsx)(`div`,{children:(0,p.jsxs)(H.Select,{onChange:e=>{n(t=>parseInt(e.target.value))},value:r,size:`sm`,children:[(0,p.jsx)(`option`,{value:10,children:`10`}),(0,p.jsx)(`option`,{value:25,children:`25`}),(0,p.jsx)(`option`,{value:50,children:`50`}),(0,p.jsx)(`option`,{value:100,children:`100`})]})})]})},BF=new Date().toISOString().split(`T`)[0],VF=({requirement:e,targets:t,refetchResults:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1),{control:l,register:u,handleSubmit:m,reset:h,watch:g,formState:{errors:_,isValid:v}}=Ed({defaultValues:{date:BF}}),{fields:y,append:b,remove:x}=Td({control:l,name:`results`,rules:{required:!0}});(0,d.useEffect)(()=>{x(),t.forEach(e=>{b({id:e.id,label:e.logging_parameter.name,logging_parameter_id:e.logging_parameter.id,value:``})})},[t]),(0,d.useEffect)(()=>{c(v)},[g(),v]);async function S(t){await f.default.post(`create/monitor/requirement/result`,{requirement:e.id,date:t.date,values:t.results}),o(!0),i(!1),n(),h()}function C(){return(0,p.jsx)(Rl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Il,{onClose:()=>o(!1),show:a,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Il.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Il.Body,{children:`Measurement results were saved successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,onClick:()=>i(!0),children:`Add manual result`}),(0,p.jsx)(U,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(H,{onSubmit:m(e=>S(e)),validated:s,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add manual result`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`date`,placeholder:`Date`,required:!0,...u(`date`,{required:`This field is required`})},`date`),_.date&&(0,p.jsx)(H.Control.Feedback,{children:_.date.message})]}),y.map((e,t)=>(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:e.label}),(0,p.jsxs)(Ps,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{type:`number`,step:.01,placeholder:e.label,required:!0,...u(`results.${t}.value`,{required:`This field is required`})},e.id),_?.results?.[t]?.value&&(0,p.jsx)(H.Control.Feedback,{children:_.results[t].value.message})]})]},t))]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{h(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(C,{})]})},HF=({requirement:e,result:t,refetchMonitorStepParameterValues:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)([]),{control:m,register:h,handleSubmit:g,reset:_,watch:v,formState:{errors:y,isValid:b}}=Ed({defaultValues:{}});(0,d.useEffect)(()=>{async function n(){let n=await _e({result:t}),r=await be({requirement:e}),i=await ae({module:e.step.process_module.module});r.items=r.items.filter(e=>!n.items.map(e=>e.step_parameter.id).includes(e.id)),r.items=r.items.filter(e=>i.items.map(e=>e.parameter.id).includes(e.parameter.id)),u(r.items)}r&&n()},[r]),(0,d.useEffect)(()=>{c(b)},[v(),b]);async function x(e){await f.default.post(`create/monitor/requirement/result/step-parameter-value`,{result:t.id,step_parameter:e.module_step_parameter_id,value:e.value}),o(!0),i(!1),n(),_()}function S(){return(0,p.jsx)(Rl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Il,{onClose:()=>o(!1),show:a,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Il.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Il.Body,{children:`Measurement results were saved successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`primary`,size:`sm`,onClick:()=>i(!0),children:`+`}),(0,p.jsx)(U,{show:r,size:`lg`,onHide:()=>i(!1),children:(0,p.jsxs)(H,{onSubmit:g(e=>x(e)),validated:s,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add process parameter`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`text`,value:t.date_created,readOnly:!0})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Module Step Parameter`}),(0,p.jsxs)(H.Select,{...h(`module_step_parameter_id`,{required:!0}),children:[(0,p.jsx)(`option`,{value:``,children:`— Select a parameter`}),l.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.parameter.name},e.id))]}),(0,p.jsx)(H.Text,{className:`text-muted`,children:`Only parameters are shown here which are active on the Equipment Module and in the monitor step. In case parameters are missing you should replace the process in the monitor with the same process from the process library to reload the parameters`})]}),(0,p.jsxs)(Ps,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{type:`number`,step:.01,required:!0,...h(`value`,{required:`This field is required`})}),y?.value&&(0,p.jsx)(H.Control.Feedback,{children:y.value.message})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Add manual result`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{_(),i(!1)},children:`Close`})]})]})}),(0,p.jsx)(S,{})]})},UF=({monitorResultStepParameterValue:e,refetchMonitorStepParameterValues:t})=>{let[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)(!1),{control:c,register:l,handleSubmit:u,reset:m,watch:h,formState:{errors:g,isValid:_}}=Ed({defaultValues:{value:e.value.toString()}});(0,d.useEffect)(()=>{s(_)},[h(),_]);async function v(n){await f.default.patch(`update/monitor/requirement/result/step-parameter-value/`+e.id,{value:n.value}),a(!0),r(!1),t(),m()}async function y(){await f.default.delete(`delete/monitor/requirement/result/step-parameter-value/`+e.id,{}),a(!0),r(!1),t(),m()}function b(){return(0,p.jsx)(Rl,{position:`top-end`,className:`p-3`,children:(0,p.jsxs)(Il,{onClose:()=>a(!1),show:i,delay:3e3,autohide:!0,bg:`light`,children:[(0,p.jsxs)(Il.Header,{children:[(0,p.jsx)(`strong`,{className:`me-auto`,children:`Results saved`}),(0,p.jsx)(`small`,{children:`Just now`})]}),(0,p.jsx)(Il.Body,{children:`Measurement results were saved successfully`})]})})}return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{onClick:()=>r(!0),children:e.value}),(0,p.jsx)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:(0,p.jsxs)(H,{onSubmit:u(e=>v(e)),validated:o,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Add process parameter`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Date`}),(0,p.jsx)(H.Control,{type:`text`,value:e.date_created,readOnly:!0})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Module Step Parameter`}),(0,p.jsx)(H.Control,{type:`text`,value:e.step_parameter.parameter.name,readOnly:!0})]}),(0,p.jsxs)(Ps,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{type:`number`,step:.01,required:!0,...l(`value`,{required:`This field is required`})}),g?.value&&(0,p.jsx)(H.Control.Feedback,{children:g.value.message})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,type:`submit`,variant:`primary`,children:`Update value`}),(0,p.jsx)(B,{className:`float-end`,variant:`danger`,onClick:()=>y(),children:`Delete value`}),(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{m(),r(!1)},children:`Close`})]})]})}),(0,p.jsx)(b,{})]})};function WF({requirement:e}){let[t,n]=(0,d.useState)([]),[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(1),[s,c]=(0,d.useState)(15),[l,u]=(0,d.useState)([]),[h,g,_,v]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`files`,e.step,11],queryFn:()=>ye({step:e.step,pageSize:11,order:`date-created`,direction:`desc`})},{queryKey:[`requirement`,`target`,e],queryFn:()=>ve({requirement:e})},{queryKey:[`requirement`,`results`,e,a,s],queryFn:()=>ge({requirement:e,pageSize:s,order:`date-created`,direction:`desc`,page:a}),placeholderData:m.keepPreviousData},{queryKey:[`requirement`,`monitor_step_parameters`,e,a,s],queryFn:()=>_e({requirement:e,pageSize:s,order:`date-created`,direction:`desc`,page:a}),placeholderData:m.keepPreviousData}]});(0,d.useEffect)(()=>{n([]),!h.isLoading&&h.data.items.forEach(e=>{n(t=>[...t,e])})},[h.isLoading]),(0,d.useEffect)(()=>{v.data&&u(Array.from(new Map(v.data.items.map(e=>[e.step_parameter.id,e.step_parameter])).values()))},[v.isLoading,v.data]);let{getRootProps:y,getInputProps:b,isDragActive:x,isDragAccept:S,isDragReject:C}=Ib({onDrop:(0,d.useCallback)(t=>{t.forEach(t=>{let n=new FileReader;n.onload=async()=>{let r=n.result;try{await f.default.create().post(`update/monitor/requirement/upload-file/`+e.id,{content:r,filename:t.name,type:t.type})}catch(e){i(`Upload failed due to: `+e.response.data.detail)}await h.refetch(),await _.refetch()},n.readAsDataURL(t)})},[e.id,h,_])}),w=(0,d.useMemo)(()=>({...x?{borderColor:`#83afee`}:{},...S?{borderColor:`#00e676`}:{},...C?{borderColor:`#ff1744`}:{}}),[S,C,x]);return g.isLoading||g.isFetching?(0,p.jsx)(vr,{variant:`info`,children:`Loading targets...`}):_.isLoading||_.isFetching?(0,p.jsx)(vr,{variant:`info`,children:`Loading results...`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`h1`,{className:`display-5`,children:[`Requirement: `,e.title]}),(0,p.jsx)(`p`,{className:`lead`,children:e.definition}),(0,p.jsx)(Dl,{className:`my-3`,children:(0,p.jsxs)(Ur,{children:[(0,p.jsx)(`h2`,{children:`Charts`}),(0,p.jsx)(`div`,{className:`d-flex`,children:g.data?.items.map((e,t)=>(0,p.jsx)(RF,{target:e,results:_.data.items},t))})]})}),(0,p.jsxs)(Dl,{children:[(0,p.jsxs)(Ur,{md:8,children:[e.method&&e.method!==`-`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{children:`Method`}),(0,p.jsx)(`p`,{children:e.method})]}),g.data?.items.length===0&&(0,p.jsx)(vr,{variant:`danger`,children:`No targets found`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`h2`,{children:`Results`}),(0,p.jsx)(`div`,{children:(0,p.jsx)(VF,{requirement:e,targets:g.data.items,refetchResults:_.refetch})})]}),(0,p.jsxs)(kl,{size:`sm`,striped:!0,bordered:!0,hover:!0,children:[(0,p.jsxs)(`thead`,{children:[(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`Date`}),g.data?.items.map((e,t)=>(0,p.jsx)(`th`,{children:e.logging_parameter.name},t)),l.map((e,t)=>(0,p.jsx)(`th`,{children:e.parameter.name},t)),(0,p.jsx)(`th`,{children:`+`})]}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2}),g.data?.items.map((e,t)=>(0,p.jsxs)(`td`,{children:[e.min_value,e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`≤`}),!e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`<`}),e.target??`X`,e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`≥`}),!e.is_value_inclusive&&(0,p.jsx)(`span`,{className:`text-muted px-2`,children:`>`}),e.max_value]},t)),l.map((e,t)=>(0,p.jsx)(`th`,{className:`table-secondary`},t)),(0,p.jsx)(`th`,{})]})]}),(0,p.jsx)(`tbody`,{children:_.data?.items.map((t,n)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:t.id})},n),(0,p.jsx)(`td`,{children:YP(t.date_created,`DD-MM-YY HH:mm`)}),g.data?.items.map((e,n)=>(0,p.jsx)(`td`,{children:t.values.filter(t=>t.logging_parameter.id===e.logging_parameter.id).map((e,t)=>(0,p.jsx)(`span`,{className:e.value_is_valid?`text-success`:`text-danger`,children:e.float_value},t))},n)),l.map((e,n)=>(0,p.jsx)(`td`,{className:`table-secondary`,children:v.data?.items.filter(n=>n.step_parameter.id===e.id&&n.result.id===t.id).map((e,t)=>(0,p.jsx)(UF,{monitorResultStepParameterValue:e,refetchMonitorStepParameterValues:v.refetch},t))},n)),(0,p.jsx)(`td`,{children:(0,p.jsx)(HF,{result:t,requirement:e,refetchMonitorStepParameterValues:v.refetch})})]},n))})]}),(0,p.jsx)(zF,{data:_.data,setPage:o,setPageSize:c,pageSize:s,isPlaceholderData:_.isPlaceholderData})]}),(0,p.jsxs)(Ur,{md:4,children:[(0,p.jsx)(`h2`,{children:`Upload new results`}),(0,p.jsx)(`p`,{children:`Drop your results file here`}),(0,p.jsxs)(`div`,{...y({style:w,className:`dropzone`}),children:[(0,p.jsx)(`input`,{...b()}),x?(0,p.jsx)(`p`,{children:`Drop file(s) here ...`}):(0,p.jsx)(`p`,{children:`Drag and drop file(s) here, or click to select files`}),(0,p.jsx)(`p`,{children:r})]}),t.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h2`,{className:`mt-2`,children:`Uploaded files`}),(0,p.jsxs)(`p`,{children:[`Last `,11,` uploaded files`]}),(0,p.jsx)(`ul`,{className:`list-group`,children:t.map((e,t)=>(0,p.jsxs)(`li`,{className:`list-group-item`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsxs)(`span`,{children:[t+1,` `,(0,p.jsx)(`a`,{href:cF()+e.url,children:e.name}),e.has_monitor_step_loggings&&(0,p.jsx)(yr,{className:`ms-1 bg-primary`,children:`Logging`})]}),(0,p.jsxs)(`span`,{children:[Math.round(e.size/1024),`kiB`]})]}),(0,p.jsx)(`small`,{className:`text-muted`,children:YP(e.date_created,`DD-MM-YY HH:mm`)})]},t))})]})]})]})]})}function GF(){let{id:e}=(0,g.useParams)(),[t,n]=(0,m.useQueries)({queries:[{queryKey:[`monitor`,e],queryFn:()=>pe({id:parseInt(e)})},{queryKey:[`requirements`,e],queryFn:()=>me({monitorId:parseInt(e)})}]});return t.isLoading?(0,p.jsx)(`div`,{children:`Loading...`}):(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[`SPC Test `,t.data?.name]}),n.data?.items.map((e,t)=>(0,p.jsx)(`div`,{className:`border border-1 p-3 my-3`,children:(0,p.jsx)(WF,{requirement:e})},t))]})}function KF(){return(0,p.jsx)(Wr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}var qF=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{e===null&&pe({id:parseInt(n)}).then(t)},[n,e]);function r(){pe({id:parseInt(n)}).then(t)}return{monitor:e,setMonitor:t,reloadMonitor:r}},JF=(0,d.createContext)({monitor:{},reloadMonitor:()=>{}});function YF({children:e}){let{monitor:t,reloadMonitor:n}=qF();return t===null?(0,p.jsx)(Ct,{children:(0,p.jsx)(vt,{message:`Loading monitor...`})}):(0,p.jsx)(Ct,{children:(0,p.jsx)(JF.Provider,{value:{monitor:t,reloadMonitor:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading...`}),children:e})})})}var XF=()=>{let[e,t]=(0,d.useState)(null),{id:n}=(0,g.useParams)();(0,d.useEffect)(()=>{(e===null||n!==e.id.toString())&&xe({id:parseInt(n)}).then(t)},[n,e]);function r(){xe({id:parseInt(n)}).then(t)}return{run:e,reloadRun:r}},ZF=(0,d.createContext)({run:{},reloadRun:()=>{}});function QF({children:e}){let{run:t,reloadRun:n}=XF();return t===null?(0,p.jsx)(vt,{message:`Loading run...`}):(0,p.jsx)(Ct,{children:(0,p.jsx)(ZF.Provider,{value:{run:t,reloadRun:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading rest of run...`}),children:e})})})}function $F({text:e}){if(!e)return null;let t=e.split(/\r\n|\n|\r/);return(0,p.jsx)(p.Fragment,{children:t.map((e,n)=>(0,p.jsxs)(d.default.Fragment,{children:[e,n<t.length-1&&(0,p.jsx)(`br`,{})]},n))})}var eI=({children:e,format:t=`d-M-Y`})=>(0,p.jsx)(p.Fragment,{children:q(Date.parse(e)).format(t)}),tI=({run:e})=>{let[t,n]=(0,d.useState)(e.batch_card),[r,i]=(0,d.useState)(!1),{register:a,handleSubmit:o,formState:s,resetField:c}=Ed({defaultValues:{content:t?.content}}),{isSubmitting:l,errors:u}=s,m=async t=>{await f.default.create().patch(`update/run/batch-card/`+e.id,{content:t.content}),i(!1),n((await f.default.get(`view/run/`+e.id)).data.batch_card)},h=async()=>{await f.default.create().delete(`delete/run/batch-card/`+e.id),i(!1),n(void 0),c(`content`)};return r?(0,p.jsxs)(H,{onSubmit:o(m),className:`mb-3`,children:[(0,p.jsxs)(Ps,{hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:6,...a(`content`,{required:!0}),isInvalid:u.content!==void 0}),u.content&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:`This field is required`})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-md-row gap-2 justify-content-between mt-2`,children:[(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-2`,children:[(0,p.jsxs)(B,{variant:`primary`,type:`submit`,disabled:l,className:`text-nowrap`,children:[l&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Save batch card`]}),(0,p.jsx)(B,{variant:`secondary`,onClick:()=>i(!1),children:`Cancel`})]}),t&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`outline-danger`,className:`text-nowrap`,onClick:h,children:`Delete batch card`})})]})]}):t?t&&(0,p.jsxs)(Pr,{className:`rounded my-4 shadow-sm border-0`,children:[(0,p.jsxs)(Pr.Body,{children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-start justify-content-between gap-3`,children:[(0,p.jsx)(Pr.Title,{className:`text-danger mb-0`,children:`Batch card`}),(0,p.jsx)(B,{variant:`outline-primary`,size:`sm`,className:`text-nowrap`,onClick:()=>i(!0),children:`Update batch card`})]}),(0,p.jsx)(Pr.Text,{className:`mt-3 mb-2 fs-5 text-body`,children:t&&(0,p.jsx)($F,{text:t.content})})]}),(0,p.jsx)(Pr.Footer,{className:`bg-transparent border-0 pt-0 pb-3`,children:(0,p.jsxs)(`div`,{className:`text-muted small`,children:[`Created `,(0,p.jsx)(eI,{format:`DD-MM-YY`,children:t.date_created}),` by`,` `,t.user.first_name,` `,t.user.last_name,t.last_update&&(0,p.jsxs)(`span`,{children:[` (`,`Updated `,(0,p.jsx)(eI,{format:`DD-MM-YY H:m`,children:t.last_update}),`)`]})]})})]}):(0,p.jsx)(B,{variant:`outline-primary`,className:`mb-4`,onClick:()=>i(!0),children:`Create Batch Card`})};function nI(){let{run:e}=(0,d.useContext)(ZF);return(0,p.jsxs)(p.Fragment,{children:[e.run_type===ut.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),e.run_type===ut.PRODUCTION&&(0,p.jsx)(`small`,{children:`Production run`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:(0,p.jsxs)(`h1`,{className:`display-4`,children:[e.name,` (`,e.project.name,`)`]})}),(0,p.jsx)(tI,{run:e})]})}function rI(e){let{run:t,reloadRun:n}=(0,d.useContext)(ZF),{environment:r}=(0,g.useParams)(),i=window.location.pathname,a=[{title:`Information`,link:`/${r}/operator/run/details/${t.id}/information`}];return a.push({title:`Steps`,link:`/${r}/operator/run/details/${t.id}/steps`}),(0,p.jsx)(Jc,{variant:`tabs`,className:e.className,defaultActiveKey:`/home`,activeKey:i,children:a.map((e,t)=>(0,p.jsx)(Jc.Item,{children:(0,p.jsx)(g.Link,{to:e.link,className:`nav-link `+(e.link===i?`active`:``),children:e.title})},t))})}function iI(){return(0,p.jsx)(QF,{children:(0,p.jsxs)(Wr,{fluid:!0,children:[(0,p.jsx)(nI,{}),(0,p.jsx)(rI,{className:`mb-4`}),(0,p.jsx)(g.Outlet,{})]})})}var aI=(0,d.createContext)({showOnlyEmphasizedParameters:!1,setShowOnlyEmphasizedParameters:()=>{}}),oI=({parameter:e,value:t,refetchFn:n})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(t.value),s=async r=>{let a={value:r};try{t.id===void 0?(a.parameter=e.id,await f.default.post(`/create/run/step/parameter/value`,a)):await f.default.patch(`/update/run/step/parameter/value/${t.id}`,a)}catch(e){console.error(`Failed to update parameter value with error: `,e)}n(),i(!1)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{style:{cursor:`pointer`,borderBottom:`1px dashed #999`,display:r?`none`:``},className:t.value==``||t.value==null?`text-muted`:``,onClick:()=>{i(!r)},children:t.value!==``&&t.value!==null?t.value:`edit`}),(0,p.jsxs)(`div`,{style:{display:r?``:`none`},className:`btn-group`,children:[(0,p.jsx)(`input`,{type:`text`,value:a??``,className:`form-control`,onChange:e=>o(e.target.value)}),(0,p.jsx)(`button`,{onClick:()=>{s(a)},className:`btn btn-success btn-sm`,children:(0,p.jsx)(`i`,{className:`fa fa-check`})}),(0,p.jsx)(`button`,{onClick:()=>{i(!1)},className:`btn btn-danger btn-sm`,children:(0,p.jsx)(`i`,{className:`fa fa-times`})})]})]})},sI=({runStep:e,showOnlyEmphasizedParameters:t,editableParameters:n=!0,refetchFn:r})=>{let{data:i,isLoading:a}=(0,m.useQuery)({queryKey:[`runStepParameters`,e.id],queryFn:()=>Me({runStep:e})}),o=(0,m.useQueryClient)(),s=()=>{o.refetchQueries({queryKey:[`runStepParameters`,e.id]}),r&&r()},c=i?.items??[],l=t?c.filter(e=>e.emphasize):c;return a?(0,p.jsxs)(kl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Pos`}),(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:Array.from({length:2}).map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:3})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:7})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:4})})})]},t))})]}):c.length===0?(0,p.jsx)(vr,{variant:`info`,children:`No parameters found`}):(0,p.jsxs)(kl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Pos`}),(0,p.jsx)(`th`,{children:`Parameter`}),c[0].values.map((e,t)=>(0,p.jsx)(`th`,{children:`Value`},t)),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:l.length>0?l.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:e.sequence})}),(0,p.jsx)(`td`,{children:e.parameter.name}),e.values.map((t,r)=>(0,p.jsx)(`td`,{children:n?(0,p.jsx)(oI,{parameter:e,refetchFn:s,value:t}):(0,p.jsx)(`span`,{children:t.value})},r)),(0,p.jsx)(`td`,{children:e.unit?.abbr??``})]},e.id)):(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:3+c[0].values.length,children:`No emphasized parameters found.`})})})]})},cI=e=>{if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**+r).toFixed(2))} ${n[r]}`};function lI({runStep:e,refetchFn:t}){let[n,r]=(0,d.useState)([]),[i,a]=(0,d.useState)(``),{data:o,isLoading:s}=(0,m.useQuery)({queryKey:[`files`,e.id],queryFn:()=>je({step:e})}),c=(0,m.useQueryClient)(),l=()=>{c.refetchQueries({queryKey:[`files`,e.id]}),t&&t()},u=o?.items??[],h=async e=>{if(confirm(`Are you sure you want to delete ${e.name}? You can not undo this action`))try{await f.default.delete(`delete/run/step/file/${e.id}`),l()}catch(e){console.error(e)}},{getRootProps:g,getInputProps:_,isDragActive:v,isDragAccept:y,isDragReject:b}=Ib({onDrop:e=>{r(t=>[...t,...e]),a(`${e.length} file(s) selected`)}}),x=(0,d.useMemo)(()=>({...v?{borderColor:`#83afee`}:{},...y?{borderColor:`#00e676`}:{},...b?{borderColor:`#ff1744`}:{}}),[y,b,v]),S=()=>{n.forEach(t=>{let n=new FileReader;n.onload=async()=>{let i=n.result;try{await f.default.create().post(`update/run/step/upload-file/`+e.id,{content:i,filename:t.name,type:t.type})}catch(e){a(`Upload failed due to: `+e.response.data.detail)}try{l(),a(`Files uploaded succesfully`),r([])}catch(e){a(`Error refetching file data`),console.error(e)}},n.readAsDataURL(t)})};return s?(0,p.jsx)(`div`,{children:`Loading...`}):(0,p.jsxs)(`div`,{children:[u&&u.length>0&&(0,p.jsxs)(kl,{hover:!0,striped:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`No`}),(0,p.jsx)(`th`,{children:`File`}),(0,p.jsx)(`th`,{children:`Size`}),(0,p.jsx)(`th`,{children:`Date`})]})}),(0,p.jsx)(`tbody`,{children:u.map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:t+1})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(`a`,{href:`${cF()}${e.url}`,children:e.name}),e.has_run_step_loggings&&(0,p.jsx)(yr,{className:`ms-1 bg-primary`,children:`Logging`})]}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(`i`,{className:`fa fa-trash-o remove-file handle`,style:{cursor:`pointer`},onClick:()=>h(e)}),` `,cI(e.size)]}),(0,p.jsx)(`td`,{children:YP(e.date_created,`DD-MM-YY HH:mm`)})]},t))})]}),(0,p.jsxs)(`div`,{...g({style:x,className:`dropzone bg-secondary-subtle border rounded dz-clickable`}),children:[(0,p.jsx)(`input`,{..._()}),v?(0,p.jsx)(`p`,{children:`Drop files here...`}):(0,p.jsx)(`p`,{children:`Drag and drop files here or click to select`})]}),n.length>0&&(0,p.jsx)(Zs,{className:`mt-3`,children:n.map((e,t)=>(0,p.jsx)(Zs.Item,{children:e.name},t))}),(0,p.jsxs)(`div`,{className:`text-start`,children:[(0,p.jsx)(B,{className:`mt-3`,onClick:S,disabled:n.length===0,children:`Upload Selected Files`}),(0,p.jsx)(`p`,{className:`mt-2 text-muted`,children:i})]})]})}var uI=({runStepPart:e,setRunStepPart:t,editable:n=!0})=>{let[r,i]=(0,d.useState)(!1),[a,o]=(0,d.useState)(e.comment),{register:s,handleSubmit:c,formState:l,resetField:u}=Ed({defaultValues:{comment:a}}),{isSubmitting:m,errors:h}=l;return n?r?(0,p.jsxs)(H,{onSubmit:c(async n=>{await f.default.create().patch(`update/run/step/part/`+e.id,{comment:n.comment}).then(n=>{t({...e,comment:n.data.comment}),o(n.data.comment),i(!1)})}),children:[(0,p.jsx)(H.Group,{className:`mb-3`,controlId:`formBasicEmail`,children:(0,p.jsx)(H.Control,{as:`textarea`,...s(`comment`)})}),(0,p.jsx)(B,{size:`sm`,type:`submit`,disabled:m,children:`Save`}),(0,p.jsx)(B,{variant:`warning`,size:`sm`,className:`ms-2`,onClick:()=>i(!1),children:`Cancel`})]}):a===null?(0,p.jsx)(B,{variant:`link`,size:`sm`,className:`p-0 text-muted`,onClick:()=>i(!0),children:`Add comment`}):(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-2`,children:[(0,p.jsx)(`div`,{className:`text-break`,children:a}),(0,p.jsx)(B,{variant:`link`,size:`sm`,className:`p-0 text-muted`,onClick:()=>i(!0),children:`Edit`})]}):(0,p.jsx)(`div`,{children:a})},dI=({runStepPart:e,setRunStepPartAction:t,createRunStepPart:n})=>(0,p.jsxs)(ss,{align:`end`,children:[(0,p.jsx)(ss.Toggle,{size:`sm`,variant:`outline-secondary`,children:`Actions`}),(0,p.jsxs)(ss.Menu,{children:[e.available_actions.map(({id:n,name:r})=>(0,p.jsx)(ss.Item,{onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n)),(0,p.jsx)(ss.Item,{onClick:()=>n(),children:`Init`})]})]}),fI={[Ie.START]:`btn-primary`,[Ie.FINISH]:`btn-success`,[Ie.FAIL]:`btn-danger`,[Ie.REWORK]:`btn-info`,[Ie.SET_REPAIR]:`btn-warning`,[Ie.CLEAR_REPAIR]:`btn-warning`,[Ie.SET_TESTING]:`btn-dark`,[Ie.CLEAR_TESTING]:`btn-dark`},pI=({runStepPart:e,setRunStepPartAction:t})=>e.available_actions.length===0?null:(0,p.jsx)(p.Fragment,{children:e.available_actions.map(({id:n,name:r})=>(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm me-2 ${fI[n]}`,onClick:()=>t({runStepPart:e,runStepPartAction:n}),children:r},n))}),mI=(e,t)=>{let{status:n,processed:r,failed:i,started:a,available_actions:o}=t.updated_run_step_part_state;return{...e,status:n,processed:r,failed:i,started:a,available_actions:o}},hI=(e,t)=>e&&(Array.isArray(e.pages)?{...e,pages:e.pages.map(e=>!e||!Array.isArray(e.items)?e:{...e,items:t(e.items)})}:Array.isArray(e.items)?{...e,items:t(e.items)}:e),gI=(e,t)=>{let{runStepPart:n,latestAction:r}=t;return hI(e,e=>e.map(e=>e.id===n.id?mI(e,r):e))},_I=(e,t)=>hI(e,e=>e.map(e=>t.get(e.id)??e)),vI=e=>Array.isArray(e)?e:Array.isArray(e.items)?e.items:[],yI=(e,t)=>{let n=vI(t);if(n.length===0)return e;let r=new Map(n.map(e=>[e.updated_run_step_part_state.run_step_part_id,e])),i=new Map(n.map(e=>[e.updated_run_step_part_state.run_part_id,e]));return hI(e,e=>e.map(e=>{let t=r.get(e.id)??i.get(e.part_id);return t?mI(e,t):e}))},bI=(e,t)=>{if(!e)return e;if(Array.isArray(e.pages)){let n=e.pages;if(n.some(e=>Array.isArray(e?.items)&&e.items.some(e=>e.id===t.id)))return hI(e,e=>e.map(e=>e.id===t.id?t:e));if(n.length>0){let r=n.length-1;return{...e,pages:n.map((e,n)=>n!==r||!e||!Array.isArray(e.items)?e:{...e,items:[...e.items,t]})}}return e}if(Array.isArray(e.items)){let n=e.items,r=n.some(e=>e.id===t.id);return{...e,items:r?n.map(e=>e.id===t.id?t:e):[...n,t]}}return e},xI=async(e,t)=>{if(t.length===0)return;let n=Array.from(new Set(t.map(e=>e.part_id))).map(e=>({id:e}));if(n.length===0)return;let r=await Ne({runPart:n}),i=new Map(r.items.map(e=>[e.id,e]));i.size!==0&&e.setQueriesData({queryKey:[`runStepParts`]},e=>_I(e,i))},SI=(e,t)=>{e.setQueriesData({queryKey:[`runStepParts`]},e=>gI(e,t)),xI(e,[t.runStepPart]).catch(e=>{console.error(`Failed to refresh run step part cache from run part.`,e)})},CI=(e,t)=>{SI(e,t)},wI=(e,t,n)=>{if(`latestActions`in n){e.setQueriesData({predicate:e=>Array.isArray(e.queryKey)&&e.queryKey[0]===`runStepParts`&&(e.queryKey.length===1||e.queryKey[1]===t.id)},e=>yI(e,n.latestActions)),xI(e,vI(n.latestActions).map(e=>({id:e.updated_run_step_part_state.run_step_part_id,part_id:e.updated_run_step_part_state.run_part_id}))).catch(e=>{console.error(`Failed to refresh run step part cache from run parts.`,e)});return}SI(e,n)},TI=(e,t,n)=>{e.setQueriesData({queryKey:[`runStepParts`]},e=>bI(e,n))};function EI(e){return!0}var DI=e=>!!e.closest(`button, a, input, textarea, select, option, label`),OI=({runPart:e,partIsSelected:t,setPartAsSelected:n,runStepParts:r,canInit:i,runStep:a,dropdown:o})=>{let[s,c]=(0,d.useState)(),l=(0,m.useQueryClient)();(0,d.useEffect)(()=>{c(r.find(t=>t.part_id===e.id))},[r,e.id]);let u=t=>{if(!n)return;let r=t.target;if(DI(r))return;let i=s?s.part_id:e.id;i!==void 0&&n(i)},h=()=>{i||f.default.post(`/create/run/step/part`,{run_part_id:e.id,run_step_id:a.id}).then(e=>{let t={...e.data};c(t),TI(l,a,t)})},g=async({runStepPart:e,runStepPartAction:t})=>{let n=await Pe({runStepPart:e,runStepPartAction:t});c(e=>{if(!e)return e;let{status:t,processed:r,failed:i,started:a,available_actions:o}=n.updated_run_step_part_state;return{...e,status:t,processed:r,failed:i,started:a,available_actions:o}}),wI(l,a,{runStepPart:e,latestAction:n})};return s?(0,p.jsxs)(`tr`,{onClick:u,style:n?{cursor:`pointer`}:void 0,children:[(0,p.jsx)(`td`,{children:n&&EI(a)&&(0,p.jsx)(`input`,{type:`checkbox`,id:`part-select-${s.part_id}`,name:`tomato`,className:`form-check-input`,checked:t,onChange:()=>n?.(s.part_id)})}),(0,p.jsx)(`td`,{children:e.scanner_label}),(0,p.jsx)(`td`,{children:(0,p.jsxs)(`div`,{className:`d-flex align-items-start gap-1`,children:[(0,p.jsx)(`span`,{className:`badge ${s.status.class??``}`.trim(),children:s.status.key}),(0,p.jsx)(`small`,{className:`text-muted`,children:s.status.text})]})}),EI(a)&&(0,p.jsx)(`td`,{children:o?(0,p.jsx)(dI,{runStepPart:s,setRunStepPartAction:g,createRunStepPart:h}):(0,p.jsx)(pI,{runStepPart:s,setRunStepPartAction:g})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(uI,{runStepPart:s,setRunStepPart:c})})]}):null},kI=(0,d.createContext)({lastlyReadedKeys:``,addCallbackFn:()=>{},removeCallbackFn:()=>{},addReadingCallbackFn:()=>{},removeReadingCallbackFn:()=>{}}),AI=()=>{let e=(0,d.useContext)(kI);if(e===void 0)throw Error(`useScannerContext must be used within a ScannerProvider`);return e},jI=function(e){return e[e.SELECT=0]=`SELECT`,e[e.PERFORM_ACTION=1]=`PERFORM_ACTION`,e}({});function MI(e){return e.startsWith(`_qr`)?jI.PERFORM_ACTION:jI.SELECT}function NI({parts:e}){let[t,n]=(0,d.useState)(new Map),r=(0,d.useCallback)(e=>{n(t=>{let n=new Map(t);return n.set(e,!(t.get(e)??!1)),n})},[]),{lastlyReadedKeys:i,addCallbackFn:a,removeCallbackFn:o}=AI(),s=(0,d.useId)(),c=(0,d.useRef)(new Set),l=(0,d.useCallback)(t=>{if(MI(t)!=jI.SELECT)return;let n=t.replace(/_/g,`-`).toUpperCase();if(!n)return;if(e.length==0){if(c.current.size>=15){let e=c.current.values().next().value;e!==void 0&&c.current.delete(e)}c.current.add(n);return}let i=e.find(e=>n.includes(e.scanner_label.toUpperCase()));i&&r(i.id)},[e,r]);return(0,d.useEffect)(()=>(o(jI.SELECT,s),l(i),a(jI.SELECT,s,l),()=>{o(jI.SELECT,s)}),[e]),(0,d.useEffect)(()=>{let r=new Map;for(let n of e){let e=n.id;r.set(e,t.get(e)??!1)}r.size!==t.size&&n(()=>r),e.length>0&&(c.current.forEach(e=>{l(e)}),c.current.clear())},[e,t,r]),{selectedParts:t,setPartAsSelected:r,setPartsSelection:(0,d.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return e.forEach(e=>{r.set(e,t)}),r})},[]),selectAllParts:(0,d.useCallback)(()=>{n(e=>new Map([...e.keys()].map(e=>[e,!0])))},[]),selectNoneParts:(0,d.useCallback)(()=>{n(e=>new Map([...e.keys()].map(e=>[e,!1])))},[]),hasSelectedParts:Array.from(t.values()).some(e=>e)}}var PI=null;function FI(e){if(!PI){console.warn(`notification() called before NotificationProvider is mounted`);return}PI(e)}function II({children:e}){let[t,n]=(0,d.useState)([]),r=(0,d.useRef)(0),i=(0,d.useCallback)(e=>{let t=++r.current;n(n=>[...n,{...e,id:t}])},[]);(0,d.useEffect)(()=>(PI=i,()=>{PI=null}),[i]);let a=(0,d.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,p.jsxs)(p.Fragment,{children:[e,(0,p.jsx)(Rl,{containerPosition:`fixed`,position:`top-end`,children:t.map(({id:e,notificationHeader:t,notificationBody:n,notificationType:r})=>(0,p.jsxs)(Il,{show:!0,delay:3e3+(r==`danger`?150:0),autohide:!0,bg:r,onClose:()=>a(e),className:`m-5`,children:[(0,p.jsx)(Il.Header,{children:(0,p.jsx)(`span`,{className:`me-auto`,children:t})}),(0,p.jsx)(Il.Body,{children:n})]},e))})]})}var LI=e=>`step_id`in e&&`part_id`in e;function RI({runStep:e,parts:t,selectedParts:n,getRunPart:r,getRunStepPart:i,actionsFromScanner:a=!0}){let o=(0,m.useQueryClient)(),{addCallbackFn:s,removeCallbackFn:c}=AI(),l=(0,d.useId)(),u=(0,d.useCallback)(()=>t.length===0?[]:LI(t[0])?t.filter(e=>{let t=r?r(e):e.part_id;return n.get(t)}):t.filter(e=>n.get(e.id)).map(e=>i?i(e):void 0).filter(e=>e!==void 0),[t,n,r,i]),f=(0,d.useCallback)(async t=>{let n=u();if(n.length===0)return;let r=n.filter(e=>e.available_actions.some(({id:e})=>e===t));if(r.length!==0){if(r.length===1){let e=r[0];CI(o,{runStepPart:e,latestAction:await Pe({runStepPart:e,runStepPartAction:t})});return}wI(o,e,{latestActions:await Fe({runStepPartActions:r.map(e=>({runStepPart:e,runStepPartAction:t}))})})}},[u,o,e]),p=(0,d.useCallback)(e=>{if(!e||!zI(e))return;let t=Re(e.split(`/`)[1]);if(!t){FI({notificationHeader:`Part scanner`,notificationBody:`Non valid action found in the scanned text`,notificationType:`danger`});return}FI({notificationHeader:`Part scanner`,notificationBody:`Performing action ${Le(t)} on selected parts`,notificationType:`success`}),f(t)},[f]);return(0,d.useEffect)(()=>{if(a)return c(jI.PERFORM_ACTION,l),s(jI.PERFORM_ACTION,l,p),()=>{c(jI.PERFORM_ACTION,l)}},[a,p,s,c,l]),{performActionToSelectedParts:f,getAvailableActionsForSelection:(0,d.useCallback)(()=>{let e=new Map;for(let t of u())for(let{id:n,name:r}of t.available_actions)e.has(n)||e.set(n,r);return Array.from(e.entries()).map(([e,t])=>({id:e,name:t}))},[u])}}function zI(e){return RegExp(`^_qr/.+`).test(e)}var BI=({onSelectAll:e,onSelectNone:t,hasSelectedParts:n,actionsDropdown:r,traySelections:i,onToggleTray:a})=>{let o=(i??[]).length>0;return(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`div`,{className:`btn-group btn-group-sm`,role:`group`,"aria-label":`Part selection controls`,children:[(0,p.jsx)(`button`,{className:`part-check-all btn btn-outline-secondary`,onClick:e,children:`All`}),(0,p.jsx)(`button`,{className:`part-check-none btn btn-outline-secondary`,onClick:t,children:`None`})]}),o&&(0,p.jsx)(`div`,{className:`btn-group btn-group-sm`,role:`group`,"aria-label":`Tray selection controls`,children:i?.map(e=>{let t=e.allSelected;return(0,p.jsx)(`button`,{type:`button`,className:`btn ${t?`btn-secondary`:`btn-outline-secondary`}`,"aria-pressed":t,onClick:()=>a?.(e.partIds,!t),children:e.label},e.id)})}),n&&r]})},VI=({availableActions:e,onActionSelected:t})=>{if(e.length===0)return null;let[n,r]=(0,d.useState)(null),i=async e=>{if(n===null){r(e);try{await t(e)}finally{r(null)}}};return(0,p.jsx)(p.Fragment,{children:e.map(({id:e,name:t})=>(0,p.jsxs)(`button`,{type:`button`,className:`btn btn-sm ${fI[e]}`,onClick:()=>void i(e),disabled:n!==null,children:[n===e&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),t]},e))})},HI=({run:e,runStep:t})=>{let n=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Te({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Ne({step:t})}]}),[r,i]=n,a=n.some(e=>e.isLoading),o=n.some(e=>e.isError),s=(0,d.useMemo)(()=>r.data?.items??[],[r.data]),c=(0,d.useMemo)(()=>i.data?.items??[],[i.data]),l=(0,d.useMemo)(()=>s.filter(e=>e.part_level===t.part_level),[s,t.part_level]),[u,f]=(0,d.useState)(!1),{selectedParts:h,selectAllParts:g}=NI({parts:l});GI({runStepParts:c,runParts:l});let _=(0,d.useMemo)(()=>l.filter(e=>h.get(e.id)&&(u||!UI(c,e))),[l,c,h,u]);return o?(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run parts.`}):(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsxs)(kl,{size:`sm`,striped:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2,children:`Part`}),(0,p.jsx)(`th`,{children:`Status`}),(0,p.jsx)(`th`,{children:`Actions`}),(0,p.jsx)(`th`,{children:`Comment`})]})}),(0,p.jsxs)(`tbody`,{children:[a&&Array.from({length:1}).map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{colSpan:2,children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:6})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:5})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:4})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{as:`div`,animation:`glow`,children:(0,p.jsx)(El,{xs:7})})})]},`placeholder-${t}`)),!a&&_.map((e,n)=>(0,p.jsx)(OI,{runStep:t,runPart:e,runStepParts:c,canInit:!1,partIsSelected:h.get(e.id)??!1,dropdown:!1},`${e.parsed_label}${n}`))]})]}),(0,p.jsx)(WI,{runStepParts:c,selectedPartsLength:_.length,totalParts:l.length,onSelectAll:g,toggleShowCompletedParts:()=>{f(!u)}})]})},UI=(e,t)=>{let n=e.find(e=>e.part_id==t.id);return n==null?!1:n.processed},WI=({runStepParts:e,selectedPartsLength:t,totalParts:n,onSelectAll:r,toggleShowCompletedParts:i})=>{let a=(0,d.useMemo)(()=>{let t=0;return e.forEach(e=>e.processed?t++:null),t},[e]);return(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-sm-row flex-wrap gap-2 mt-2`,children:[(0,p.jsxs)(`span`,{className:`badge rounded-pill bg-warning-subtle text-warning-emphasis border border-warning-subtle px-3 py-2 fw-semibold`,role:`button`,title:`Show all the parts`,onClick:r,style:{cursor:`pointer`},children:[`This step has `,(0,d.useMemo)(()=>n-t,[n,t]),` more parts`]}),(0,p.jsxs)(`span`,{className:`badge rounded-pill bg-info-subtle text-info-emphasis border border-info-subtle px-3 py-2 fw-semibold`,children:[`This step has `,t,` scanned parts`]}),(0,p.jsxs)(`span`,{title:`Show all the parts`,style:{cursor:`pointer`},onClick:i,className:`badge rounded-pill bg-success-subtle text-success-emphasis border border-success-subtle px-3 py-2 fw-semibold`,children:[`This step has `,a,` finished parts`]})]})};function GI({runStepParts:e,runParts:t}){let{addCallbackFn:n,removeCallbackFn:r}=AI(),i=(0,d.useId)(),a=(0,d.useCallback)(n=>{let r=n.replace(/_/g,`-`).toUpperCase();if(!r)return;let i=t.find(e=>r.includes(e.scanner_label.toUpperCase()));if(i){if(UI(e,i)){FI({notificationHeader:`Run parts table`,notificationBody:`Part ${i.parsed_label??i.scanner_label} is already completed`,notificationType:`danger`});return}FI({notificationHeader:`Part scanner`,notificationBody:`Found part: ${i.scanner_label}`,notificationType:`success`})}},[t,e]);(0,d.useEffect)(()=>(r(jI.SELECT,i),n(jI.SELECT,i,a),()=>{r(jI.SELECT,i)}),[t,e])}var KI=!1,qI=({run:e,runStep:t})=>{let n=(0,m.useQueryClient)(),r=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Te({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Ne({step:t})}]}),[i,a]=r,o=r.some(e=>e.isLoading),s=r.some(e=>e.isError),c=(0,d.useMemo)(()=>i.data?.items??[],[i.data]),l=(0,d.useMemo)(()=>a.data?.items??[],[a.data]),{selectedParts:u,setPartAsSelected:f,setPartsSelection:h,selectAllParts:g,selectNoneParts:_,hasSelectedParts:v}=NI({parts:c});GI({runStepParts:l,runParts:c}),(0,d.useEffect)(()=>{let e=Array.from(u.entries()).filter(([,e])=>e).map(([e])=>e);n.setQueryData([`runPartSelection`,t.id],e)},[n,t.id,u]);let{performActionToSelectedParts:y,getAvailableActionsForSelection:b}=RI({runStep:t,parts:c,selectedParts:u,getRunPart:void 0,getRunStepPart:e=>l.find(t=>t.part_id===e.id)}),x=(0,d.useMemo)(()=>b(),[b]),S=(0,d.useMemo)(()=>{let t=new Map;if(l.forEach(e=>{let n=c.find(t=>t.id===e.part_id)?.tray;if(!n)return;let r=t.get(n.id)??{id:n.id,label:n.name??n.label??`Tray ${n.id}`,partIds:[]};r.partIds.push(e.part_id),t.set(n.id,r)}),t.size===0)return[];let n=[...e.run_trays??[]].sort((e,t)=>e.sequence-t.sequence);return(n.length>0?n.filter(e=>t.has(e.id)).map(e=>{let n=t.get(e.id);return{...n,label:e.name??e.label??n.label}}):Array.from(t.values()).sort((e,t)=>e.label.localeCompare(t.label))).map(e=>({...e,allSelected:e.partIds.every(e=>u.get(e))}))},[e.run_trays,u,l]);if(o)return(0,p.jsx)(vt,{message:`Loading run parts`});if(s)return(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run parts.`});if(c.length===0)return(0,p.jsx)(vr,{variant:`warning`,children:`No parts found for this run step.`});if(l.length===0)return(0,p.jsx)(vr,{variant:`warning`,children:`No step parts found for this run step.`});let C=EI(t);return(0,p.jsx)(d.Fragment,{children:c&&c.length>0&&(0,p.jsxs)(p.Fragment,{children:[!C&&(0,p.jsxs)(vr,{variant:`warning`,className:`py-2 mb-2`,children:[(0,p.jsx)(`strong`,{children:`Step locked.`}),` Finish the previous step before processing these parts.`]}),(0,p.jsxs)(kl,{size:`sm`,striped:!0,hover:!0,className:C?void 0:`text-muted`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{colSpan:2,children:`Part`}),(0,p.jsx)(`th`,{children:`Status`}),C&&(0,p.jsx)(`th`,{children:`Actions`}),(0,p.jsx)(`th`,{children:`Comment`})]})}),(0,p.jsx)(`tbody`,{children:c.map((n,r)=>{let i=u.get(n.id)??!1;return(0,p.jsx)(OI,{runStep:t,runPart:n,runStepParts:l,canInit:e.run_type===ut.PRODUCTION,partIsSelected:i,setPartAsSelected:C?f:void 0,dropdown:KI},`key-${r}-${n.id}`)})})]}),C&&(0,p.jsx)(BI,{onSelectAll:g,onSelectNone:_,hasSelectedParts:v,traySelections:S,onToggleTray:(e,t)=>h(e,t),actionsDropdown:(0,p.jsx)(VI,{availableActions:x,onActionSelected:y})})]})})};function JI({run:e,step:t,refetchFn:n=()=>null}){let{run:r}=(0,d.useContext)(ZF),{showOnlyEmphasizedParameters:i}=(0,d.useContext)(aI),a=e??r;return a?(0,p.jsx)(Pr,{className:`p-4 my-3`,children:(0,p.jsx)(Pr.Body,{children:(0,p.jsxs)(Dl,{children:[(0,p.jsxs)(Ur,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Experimental split`}),(0,p.jsx)(qI,{run:a,runStep:t}),t.has_remark&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{children:`Remark`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.remark}})]})]}),(0,p.jsxs)(Ur,{md:`6`,children:[(0,p.jsx)(`h4`,{children:`Parameters`}),(0,p.jsx)(sI,{runStep:t,showOnlyEmphasizedParameters:i,refetchFn:()=>{n([JSON.stringify(t),`parameters`])}}),(0,p.jsx)(`h4`,{children:`Files`}),(0,p.jsx)(lI,{runStep:t,refetchFn:()=>{n([`runSteps`])}})]})]})})}):null}var YI=({runPart:e,statusClass:t,withTrayCell:n=!1,allowCreate:r=!1,hasStepPart:i=!1,isSelected:a=!1,runStep:o})=>{let s=(0,m.useQueryClient)(),c=!i||!e?null:r&&!i?(0,p.jsxs)(B,{size:`sm`,variant:`outline-secondary`,className:`tray-grid__badge tray-grid__badge--init`,onClick:()=>{!e||!o||f.default.post(`/create/run/step/part`,{run_part_id:e.id,run_step_id:o.id}).then(e=>{TI(s,o,{...e.data})})},children:[`Init `,e.scanner_label]}):(0,p.jsx)(`span`,{className:`tray-grid__badge ${t??`step-part-inactive`}${a?` step-part-selected`:``}`,children:e.scanner_label});return n?(0,p.jsx)(`div`,{className:`tray-grid__cell${e?``:` tray-grid__cell--empty`}`,children:c}):c},XI=({step:e,parts:t,stepParts:n,run:r})=>{let i=t.filter(t=>t.part_level===e.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),a=new Map(n.filter(t=>t.step_id===e.id).map(e=>[e.part_id,e])),o=[...r.run_trays??[]].sort((e,t)=>e.sequence-t.sequence),s=i.reduce((e,t)=>{if(!t.tray)return e;let n=e.get(t.tray.id)??[];return n.push(t),e.set(t.tray.id,n),e},new Map),c=r.run_type===ut.PRODUCTION,l=e.part_level>0,{data:u=[]}=(0,m.useQuery)({queryKey:[`runPartSelection`,e.id],queryFn:async()=>[],initialData:[],enabled:!1}),d=e=>{let t=a.get(e.id);return t?t.status.class:`step-part-inactive`},f=(t,n)=>(0,p.jsx)(`div`,{className:`tray-grid__cell${t.length?``:` tray-grid__cell--empty`}${t.length>1?` tray-grid__cell--multi`:``}`,children:t.map(t=>(0,p.jsx)(YI,{runPart:t,statusClass:d(t),allowCreate:c,hasStepPart:a.has(t.id),isSelected:u.includes(t.id),runStep:e},t.id))},n);if(o.length===0){let t=Math.max(i.length,i.reduce((e,t)=>Math.max(e,t.left??0),0)),n=Math.max(1,Math.ceil(t/12)),r={"--tray-columns":12,"--tray-rows":n},o=Array.from({length:n*12},()=>[]),s=[];return i.forEach(e=>{let t=e.left,n=t>=1&&t<=o.length?t-1:null;if(n!==null){if(l){o[n].push(e);return}if(!o[n].length){o[n].push(e);return}s.push(e)}else s.push(e)}),s.forEach(e=>{if(l){let t=o.reduce((e,t,n)=>e===-1||t.length<o[e].length?n:e,-1);t!==-1&&o[t].push(e);return}let t=o.findIndex(e=>e.length===0);t!==-1&&o[t].push(e)}),(0,p.jsx)(`div`,{className:`tray-grid`,"data-orientation":`ltr`,style:r,children:o.map((t,n)=>{if(l)return f(t,`slot-no-tray-${n}`);let r=t[0]??null;return(0,p.jsx)(YI,{runPart:r,statusClass:r?d(r):void 0,withTrayCell:!0,allowCreate:c,hasStepPart:r?a.has(r.id):!1,isSelected:r?u.includes(r.id):!1,runStep:e},`slot-no-tray-${n}`)})})}let h=(e,t,n)=>!t||!n||t<1||n<1||t>e.rows||n>e.columns?null:e.orientation===`ttb`?(n-1)*e.rows+(t-1):(t-1)*e.columns+(n-1);return(0,p.jsx)(`div`,{className:`tray-grid-group`,children:o.map(t=>{let n=t.tray_type;if(!n?.rows||!n?.columns){let n=s.get(t.id)??[];return(0,p.jsxs)(`div`,{className:`tray-grid-wrapper`,children:[(0,p.jsx)(`div`,{className:`tray-grid__label`,children:t.name??t.label}),(0,p.jsx)(`div`,{className:`d-flex flex-wrap gap-2`,children:n.map(t=>(0,p.jsx)(YI,{runPart:t,statusClass:d(t),allowCreate:c,hasStepPart:a.has(t.id),isSelected:u.includes(t.id),runStep:e},t.id))})]},`tray-${t.id}`)}let r=n.rows*n.columns,i=n.orientation===`ttb`?`ttb`:`ltr`,o={"--tray-columns":n.columns,"--tray-rows":n.rows},m=Array.from({length:r},()=>[]);return(s.get(t.id)??[]).forEach(e=>{let t=h(n,e.tray_row,e.tray_column);if(t!==null){if(l){m[t].push(e);return}m[t].length||m[t].push(e)}}),(0,p.jsxs)(`div`,{className:`tray-grid-wrapper`,children:[(0,p.jsx)(`div`,{className:`tray-grid__label`,children:t.name??t.label}),(0,p.jsx)(`div`,{className:`tray-grid`,"data-orientation":i,style:o,children:m.map((n,r)=>{if(l)return f(n,`slot-${t.id}-${r}`);let i=n[0]??null;return(0,p.jsx)(YI,{runPart:i,statusClass:i?d(i):void 0,withTrayCell:!0,allowCreate:c,hasStepPart:i?a.has(i.id):!1,isSelected:i?u.includes(i.id):!1,runStep:e},`slot-${t.id}-${r}`)})})]},`tray-${t.id}`)})})};function ZI({run:e,step:t,parts:n,monitoredBy:r,refetchFn:i}){let{environment:a}=(0,g.useParams)(),[o,s]=(0,d.useState)(!1),c=()=>{s(!o)},[l,u]=(0,d.useState)(t.process_module.module);(0,d.useEffect)(()=>{u(t.process_module.module)},[t.process_module.module]);let[f]=(0,m.useQueries)({queries:[{queryKey:[`runStepParts`,t.id],queryFn:()=>Ne({step:t}),placeholderData:m.keepPreviousData}]}),h=(0,d.useMemo)(()=>f.data?.items??[],[f.data?.items]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`i`,{className:`fa ms-2 `+(o?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:c})}),(0,p.jsx)(`td`,{className:l.latest_module_status&&l.latest_module_status.status.is_down_status?`table-danger`:``,children:f.isLoading?(0,p.jsx)(El,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(El,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(XI,{step:t,parts:n,stepParts:h,run:e})}),(0,p.jsxs)(`td`,{children:[r&&(0,p.jsx)(pl,{placement:`top`,overlay:(0,p.jsx)(sl,{id:`tooltip-${r.id}`,children:`Monitored by step: ${r.step.number}`}),children:(0,p.jsx)(`i`,{className:`fa fa-search me-2`})}),t.amount_of_files>0&&(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-paperclip`}),` `,t.amount_of_files]}),t.has_remark&&(0,p.jsx)(`i`,{className:`fa fa-comment-o text-warning me-3`}),t.is_finished&&(0,p.jsx)(`i`,{className:`fa fa-check text-success me-3`})]}),(0,p.jsxs)(`td`,{className:t.has_step_group?`ps-4`:``,children:[t.number,` - `,(0,p.jsx)(g.Link,{to:`/${a}/operator/run/step/${t.id}`,children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.name}})}),` `]}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(g.Link,{to:`/${a}/operator/equipment/${l.equipment.id}`,className:`me-2`,children:l.equipment.name}),(0,p.jsx)(Dd,{module:l,refetchFn:()=>{i([`runSteps`])}})]})]}),o&&(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:n.length+6,children:(0,p.jsx)(JI,{step:t,refetchFn:i})})})]})}var QI=({requirement:e,result:t,show:n,setShow:r,refetchFn:i,part:a,stepPart:o})=>{let[s,c]=(0,d.useState)({}),[l,u]=(0,d.useState)(!1),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(Object.keys(s).length>0)return;let n={};for(let r of e.targets){let e=``;t!==void 0&&(e=t.values.find(e=>e.logging_parameter.id==r.logging_parameter.id)?.string_value??``),n[r.logging_parameter.id]=e}c(n)},[e]),(0,d.useEffect)(()=>{_(!1),h(null),u(!1)},[n]);let v=async()=>{try{h(null),_(!1),u(!0),await f.default.delete(`/delete/run/measurement/result/${t?.id??0}`),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}},y=async()=>{try{h(null),_(!1),u(!0);let n=Object.entries(s).map(async([e,n])=>{let r=Number.parseInt(e),i={value:n},a=t?.values.find(e=>e.logging_parameter.id===r)?.id;await f.default.patch(`/update/run/measurement/result/value/${a??0}`,i)});await Promise.all(n),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}},b=async()=>{let t={measurement:e.measurement.id,values:Object.entries(s).flatMap(e=>({logging_parameter:Number.parseInt(e[0]),value:e[1]}))};o&&(t.step_part=o?.id??0,t.part=a?.id??0,t.step=e.step.id??0);try{h(null),_(!1),u(!0),await f.default.post(`/create/run/measurement/result`,t),_(!0),i([`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)])}catch(e){console.error(e),h(`Update of results failed`)}finally{u(!1)}};return(0,p.jsxs)(U,{show:n,size:`lg`,onHide:()=>r(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:t?(0,p.jsx)(p.Fragment,{children:`Update results`}):(0,p.jsx)(p.Fragment,{children:`Create result`})})}),(0,p.jsxs)(H,{onSubmit:e=>{e.preventDefault(),t?y():b()},children:[(0,p.jsxs)(U.Body,{children:[m&&(0,p.jsx)(vr,{variant:`danger`,children:m}),g&&(0,p.jsx)(vr,{variant:`success`,children:`Results have been updated successfully`}),e.targets.map(e=>(t?.values.find(t=>t.logging_parameter.id===e.logging_parameter.id)?.string_value,(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:e.logging_parameter.name}),(0,p.jsx)(H.Control,{type:`number`,step:`any`,placeholder:`Thickness`,value:s[e.logging_parameter.id]??``,onChange:t=>c(n=>({...n,[e.logging_parameter.id]:t.target.value}))})]},e.id)))]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{variant:`warning`,onClick:()=>r(!1),children:`Close`}),l?(0,p.jsxs)(B,{type:`submit`,variant:`info`,disabled:l,children:[(0,p.jsx)(Ol,{animation:`border`,size:`sm`,className:`me-2`}),` Updating results...`]}):t?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{variant:`danger`,disabled:l,onClick:v,children:`Delete result`}),(0,p.jsx)(B,{type:`submit`,variant:`info`,disabled:l,children:`Update result`})]}):(0,p.jsx)(B,{type:`submit`,variant:`info`,disabled:l,children:`Create result`})]})]})]})},$I=(0,d.createContext)({runStep:{},setRunStep:e=>{},reloadRunStep:()=>{},run:{},modalProperties:{},setModalProperties:e=>{}});function eL({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a,editOnly:o=!1}){let{run:s}=(0,d.useContext)($I),[c,l]=(0,d.useState)(r??[]),[u,f]=(0,d.useState)(n??[]),[h,g]=(0,d.useState)(i??[]),_=(0,m.useQueryClient)(),v=(0,m.useQueries)({queries:[{queryKey:[`runParts`,`${s?.id??`unknown`}`],queryFn:async()=>await Te({run:s}),enabled:!r||r.length===0,retry:1},{queryKey:[`runStepParts`,`${t?.run_id??`unknown`}`,`${t?.id??`unknown`}`],queryFn:async()=>await Ne({step:e.requirement_for_step??e.step}),enabled:!n||n.length===0,retry:1},{queryKey:[`requirement`,`measurementResults`,e.measurement.id],queryFn:async()=>await Oe({measurement:e.measurement}),enabled:!i||i.length===0,retry:1}]}),y=()=>{_.refetchQueries({queryKey:[`requirement`,`measurementResults`,e.measurement.id]})},[b,x,S]=v;(0,d.useEffect)(()=>{r&&r.length>0?l(r):b?.data&&l(b.data.items)},[r,b?.data]),(0,d.useEffect)(()=>{n&&n.length>0?f(n):x?.data&&f(x.data.items)},[n,x?.data]),(0,d.useEffect)(()=>{i&&i.length>0?g(i):S?.data&&g(S.data.items)},[i,S?.data]);let[C,w]=(0,d.useState)(null),T=r&&r.length>0?r:c,E=((n&&n.length>0?n:u)??[]).filter(e=>(T??[]).find(n=>n.id===e.part_id&&n.part_level===t.part_level)!==void 0),D=!r||r.length===0,O=!n||n.length===0,k=!i||i.length===0,A=D&&b?.isLoading||O&&x?.isLoading||k&&S?.isLoading,j=D&&b?.isError||O&&x?.isError||k&&S?.isError;if(A&&E.length===0)return(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,p.jsx)(Ol,{animation:`border`,size:`sm`}),` `,(0,p.jsx)(`span`,{children:`Loading data…`})]});if(j&&E.length===0)return(0,p.jsxs)(vr,{variant:`danger`,className:`d-flex justify-content-between align-items-center`,children:[(0,p.jsx)(`div`,{children:`Failed to load required data. Please try again.`}),(0,p.jsxs)(`div`,{children:[D&&b?.isError&&(0,p.jsx)(B,{size:`sm`,variant:`outline-light`,onClick:()=>b.refetch(),children:`Retry parts`}),` `,O&&x?.isError&&(0,p.jsx)(B,{size:`sm`,variant:`outline-light`,onClick:()=>x.refetch(),children:`Retry step parts`}),` `,k&&S?.isError&&(0,p.jsx)(B,{size:`sm`,variant:`outline-light`,onClick:()=>S.refetch(),children:`Retry results`})]})]});let M=t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return``;let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id===t.logging_parameter.id);return r?(r.inclusive?!(r.min_value<=n&&r.max_value>=n):!(r.min_value<n&&r.max_value>n))?`table-danger`:`table-success`:``};return(0,p.jsx)(p.Fragment,{children:E.length>0?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(kl,{size:`sm`,striped:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{style:{width:`26%`},children:`Part`}),(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`}),!o&&(0,p.jsx)(`th`,{style:{width:`1%`}})]})}),(0,p.jsx)(`tbody`,{children:E.map(t=>{let n=h.find(e=>e.values.some(e=>e.step_part_id===t.id)),r=(n?.values??[]).filter(e=>e.step_part_id===t.id),i=e.targets.length;return e.targets.map((e,a)=>{let s=r.find(t=>t.logging_parameter.id===e.logging_parameter.id)??null;return(0,p.jsxs)(`tr`,{className:s?M(s):``,children:[a===0&&(0,p.jsxs)(`td`,{rowSpan:i,children:[T.find(e=>e.id===t.part_id)?.short_label??t.part_id,` `,(0,p.jsxs)(`small`,{className:`text-muted`,children:[`(`,t.id,`)`]})]}),(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{children:s?s.string_value:(0,p.jsx)(`span`,{className:`text-muted`,children:`not set`})}),(0,p.jsx)(`td`,{children:e.logging_parameter.unit?.abbr??``}),!o&&a===0&&(0,p.jsx)(`td`,{rowSpan:i,className:`align-middle text-nowrap`,children:(0,p.jsxs)(B,{size:`sm`,variant:n?`outline-primary`:`outline-success`,onClick:()=>w(String(t.id)),children:[(0,p.jsx)(`i`,{className:`fa fa-edit`}),` `,n?`Edit values`:`Add values`]})})]},`${t.id}:${e.logging_parameter.id}`)})})})]}),!o&&E.map(t=>{let n=h.find(e=>e.values.some(e=>e.step_part_id===t.id));return(0,p.jsx)(QI,{requirement:e,...n?{result:n}:{part:T.find(e=>e.id===t.part_id),stepPart:t},show:C===String(t.id),setShow:e=>{e||w(null)},refetchFn:a??y},`modal:${t.id}`)})]}):(0,p.jsx)(vr,{variant:`secondary`,className:`mb-0`,children:`No selected parts`})})}function tL({requirement:e,measurementResults:t,refetchFn:n,editOnly:r=!1}){let[i,a]=(0,d.useState)(t??[]),o=(0,m.useQueryClient)(),s=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,e.measurement.id],queryFn:async()=>await Oe({measurement:e.measurement}),enabled:!t||t.length===0,retry:1}]}),c=()=>{o.refetchQueries({queryKey:[`requirement`,`measurementResults`,e.measurement.id]})},[l]=s;(0,d.useEffect)(()=>{t&&t.length>0?a(t.filter(e=>e.values.some(e=>!e.step_part_id))):l?.data&&a(l.data.items.filter(e=>e.values.some(e=>!e.step_part_id)))},[t,l?.data]);let[u,f]=(0,d.useState)(null),[h,g]=(0,d.useState)(!1),_=s.some(e=>e.isLoading);if(s.some(e=>e.isError))return s.filter(e=>e.isError).forEach((e,t)=>{console.error(`StepDashboard query error`,{index:t,error:e.error})}),(0,p.jsx)(p.Fragment,{children:`Error fetching data`});if(_)return(0,p.jsx)(`div`,{children:`Loading...`});let v=t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return``;let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id===t.logging_parameter.id);return r&&(r.inclusive?!(r.min_value<=n&&r.max_value>=n):!(r.min_value<n&&r.max_value>n))?`table-danger text-light`:``};return(0,p.jsxs)(`div`,{className:`d-flex flex-column gap-4`,children:[i.map(t=>(0,p.jsxs)(`div`,{className:`border rounded p-3 shadow-sm`,children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:[(0,p.jsxs)(`h6`,{className:`mb-0`,children:[`Result `,(0,p.jsxs)(`small`,{className:`text-muted`,children:[`#`,t.id]})]}),!r&&(0,p.jsxs)(B,{size:`sm`,variant:`outline-primary`,onClick:()=>f(t.id),children:[(0,p.jsx)(`i`,{className:`fa fa-edit`}),` Update value`]})]}),(0,p.jsxs)(`table`,{className:`table table-striped table-sm mb-0`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Parameter`}),(0,p.jsx)(`th`,{children:`Value`}),(0,p.jsx)(`th`,{children:`Unit`})]})}),(0,p.jsx)(`tbody`,{children:t.values.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{className:e?v(e):``,children:e.string_value}),(0,p.jsx)(`td`,{children:e.logging_parameter.unit?.abbr??``})]},`value:${e.id}`))})]}),(0,p.jsx)(QI,{requirement:e,result:t,show:u===t.id,setShow:e=>{e||f(null)},refetchFn:n??c})]},t.id)),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(B,{size:`sm`,onClick:()=>g(!h),children:[(0,p.jsx)(`i`,{className:`fa fa-plus`}),` Add results`]})}),(0,p.jsx)(QI,{requirement:e,show:h,setShow:e=>{e||g(!1)},refetchFn:n??c})]})}function nL({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}){let{environment:o}=(0,g.useParams)();return(0,p.jsx)(Pr,{className:`p-4 my-3`,children:(0,p.jsx)(Pr.Body,{children:(0,p.jsxs)(Dl,{children:[(0,p.jsxs)(Ur,{md:`7`,children:[(0,p.jsx)(`h4`,{children:`Measurements by part`}),(0,p.jsx)(eL,{requirement:e,step:t,stepParts:n,parts:r,measurementResults:i,refetchFn:a}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(tL,{requirement:e,measurementResults:i,refetchFn:a})]}),(0,p.jsxs)(Ur,{md:`5`,children:[(0,p.jsx)(`h4`,{children:`Monitored Step`}),(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${e.requirement_for_step?.id??e.step.id}`,children:(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-search`}),` `,e.requirement_for_step?.name??e.step.name]})}),(0,p.jsx)(`h4`,{children:`Definition`}),(0,p.jsx)(`span`,{children:e.definition}),(0,p.jsx)(`h4`,{children:`Targets`}),(0,p.jsxs)(kl,{size:`sm`,striped:!1,bordered:!1,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`parameter`}),(0,p.jsx)(`th`,{children:`min value`}),(0,p.jsx)(`th`,{children:`max value`}),(0,p.jsx)(`th`,{children:`inclusive`})]})}),(0,p.jsx)(`tbody`,{children:e.targets.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.logging_parameter.name}),(0,p.jsx)(`td`,{children:e.min_value}),(0,p.jsx)(`td`,{children:e.max_value}),(0,p.jsx)(`td`,{children:e.inclusive?`yes`:`no`})]},e.id))})]}),(0,p.jsx)(`h4`,{children:`Files`}),(0,p.jsx)(lI,{runStep:t,refetchFn:()=>{a([`requirements`])}})]})]})})})}var rL=({requirement:e,step:t,measurementResults:n,parts:r,stepParts:i})=>{let a=r.filter(e=>e.part_level===t.part_level).sort((e,t)=>e.root_id&&t.root_id&&e.root_id!==t.root_id?e.root_id-t.root_id:e.left-t.left),o=a.reduce((e,t)=>{let n=t.root_id??t.id;return e[n]||(e[n]=[]),e[n].push(t),e},{}),s=t=>{let r=i.find(e=>e.part_id===t.id);if(!r)return`badge-inactive`;let a=n.find(e=>e.values.some(e=>e.step_part_id===r.id));if(!a)return``;for(let t of a.values){let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id==t.logging_parameter.id);if(r){if(r.inclusive){if(!(r.min_value<=n&&r.max_value>=n))return`badge-failed`}else if(!(r.min_value<n&&r.max_value>n))return`badge-failed`}}return`badge-processed`},c=e=>(0,p.jsx)(pl,{placement:`top`,overlay:(0,p.jsx)(sl,{id:`tooltip-${e.id}`,children:`Level: ${e.part_level}${e.parent?`, Parent: ${e.parent.short_label}`:``}`}),children:(0,p.jsx)(`span`,{className:`badge badge-level-${e.part_level} ${s(e)} me-1`,children:e.short_label},e.id)},e.id);return(0,p.jsxs)(`div`,{children:[a[0].parent?Object.entries(o).map(([e,t])=>(0,p.jsxs)(`div`,{className:`mb-2`,children:[(0,p.jsxs)(`label`,{className:`text-muted me-1`,children:[t[0].parent?.short_label,`:`]}),` `,t.map(e=>c(e))]},e)):a.map(e=>c(e)),(0,p.jsx)(`label`,{children:`(measurements)`})]})};function iL({requirement:e,step:t,parts:n,refetchFn:r}){let{environment:i}=(0,g.useParams)(),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(t.process_module.module);(0,d.useEffect)(()=>{c(t.process_module.module)},[t.process_module.module]);let l=()=>{o(!a)},u=(0,m.useQueryClient)(),f=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)],queryFn:()=>Oe({measurement:e.measurement})},{queryKey:[`runStepParts`,e.requirement_for_step?.id??e.step.id],queryFn:()=>Ne({step:e.requirement_for_step??e.step}),placeholderData:m.keepPreviousData}]}),h=e=>{e[0]===`requirement`&&u.refetchQueries({queryKey:e}),r(e)},[_,v]=f,y=f.some(e=>e.isLoading),b=(0,d.useMemo)(()=>v.data?.items??[],[v.data?.items]),x=(0,d.useMemo)(()=>_.data?.items??[],[_.data?.items]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`tr`,{className:(t=>{if(t.length==0)return y?``:`table-info`;let n=!1;for(let r of t)if(r.values.some(t=>{if(!(t&&!isNaN(parseFloat(t.string_value))))return!1;let n=parseFloat(t.string_value),r=e.targets.find(e=>e.logging_parameter.id==t.logging_parameter.id);return r?r.inclusive?!(r.min_value<=n&&r.max_value>=n):!(r.min_value<n&&r.max_value>n):!1})){n=!0;break}return n?`table-danger`:``})(x),children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(`i`,{className:`fa ms-2 `+(a?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:l})}),(0,p.jsx)(`td`,{children:y?(0,p.jsx)(El,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(El,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))}):(0,p.jsx)(rL,{requirement:e,step:t,measurementResults:x,parts:n,stepParts:b})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(yr,{bg:`info`,children:`requirement`}),t.amount_of_files>0&&(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-paperclip`}),` `,t.amount_of_files]}),t.has_remark&&(0,p.jsx)(`i`,{className:`fa fa-comment-o text-warning`})]}),(0,p.jsx)(`td`,{className:t.has_step_group?`ps-4`:``,children:(0,p.jsxs)(`div`,{children:[`(`,t.number,`)`,` `,(0,p.jsx)(g.Link,{to:`/${i}/operator/run/step/${t.id}`,children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.name}})}),` `]})}),(0,p.jsxs)(`td`,{children:[(0,p.jsx)(g.Link,{to:`/${i}/operator/equipment/${s.equipment.id}`,className:`me-2`,children:s.equipment.name}),(0,p.jsx)(Dd,{module:s,refetchFn:()=>{r([`runSteps`])}})]})]}),a&&(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:n.length+5,children:y?`Loading...`:(0,p.jsx)(nL,{requirement:e,step:t,stepParts:b,parts:n,measurementResults:x,refetchFn:h})})})]})}function aL(){let{run:e}=(0,d.useContext)(ZF),{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n}=(0,d.useContext)(aI),[r,i]=(0,d.useState)(1),[a]=(0,d.useState)(25),[o,s]=(0,d.useState)(new Map),c=(0,m.useQueryClient)(),l=(0,m.useQueries)({queries:[{queryKey:[`runSteps`,JSON.stringify(e),r],queryFn:()=>Ee({run:e,page:r,pageSize:a}),placeholderData:m.keepPreviousData},{queryKey:[`runParts`,JSON.stringify(e)],queryFn:()=>Te({run:e})},{queryKey:[`requirements`,JSON.stringify(e)],queryFn:()=>Ce({run:e})}]}),u=t=>{let n=[...t,JSON.stringify(e)];t[0]===`runSteps`&&n.push(r),c.refetchQueries({queryKey:n})},[f,h,g]=l,_=l.some(e=>e.isLoading),v=l.some(e=>e.isError);v&&l.filter(e=>e.isError).forEach((t,n)=>{console.error(`RunStepsElement query error`,{index:n,error:t.error,run:e})});let y=(0,d.useMemo)(()=>f.data?.items??[],[f.data?.items]),b=(0,d.useMemo)(()=>h.data?.items??[],[h.data?.items]),x=(0,d.useMemo)(()=>g.data?.items??[],[g.data?.items]);if((0,d.useEffect)(()=>{s(e=>{let t=new Map(e);return y.forEach(e=>{let n=e.label?.id;n!==void 0&&!t.has(n)&&t.set(n,!0)}),t})},[y]),_)return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center`,children:(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(El,{animation:`glow`,as:`span`,children:(0,p.jsx)(El,{style:{width:`2rem`,height:`1rem`,borderRadius:`0.5rem`}})}),(0,p.jsx)(El,{animation:`glow`,as:`span`,className:`ms-2`,children:(0,p.jsx)(El,{style:{width:`15rem`}})})]})}),(0,p.jsxs)(kl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Parts`}),(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Process`}),(0,p.jsx)(`th`,{children:`Equipment`})]})}),(0,p.jsx)(`tbody`,{children:[1,2].map(e=>(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:5,className:`bg-info`,children:(0,p.jsx)(El,{animation:`glow`,as:`span`,children:(0,p.jsx)(El,{style:{width:`5rem`}})})})}),(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{animation:`glow`,as:`span`,children:(0,p.jsx)(El,{style:{width:`0.75rem`}})})}),(0,p.jsx)(`td`,{colSpan:2,children:(0,p.jsx)(El,{animation:`glow`,as:`div`,className:`d-flex flex-wrap gap-1`,children:Array.from({length:5}).map((e,t)=>(0,p.jsx)(El,{style:{width:`4.5rem`,height:`1.5rem`,borderRadius:`3px`}},t))})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{animation:`glow`,as:`span`,children:(0,p.jsx)(El,{style:{width:`10rem`}})})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(El,{animation:`glow`,as:`span`,children:(0,p.jsx)(El,{style:{width:`12rem`}})})})]})]},e))})]})]});if(v)return(0,p.jsx)(`div`,{className:`text-danger`,children:`Error loading run steps.`});let S=new Set,C=y.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||S.has(String(e.step_group.id))?!1:(S.add(String(e.step_group.id)),!0)),w={};for(let e of x)e.requirement_for_step!=null&&(w[String(e.requirement_for_step.id)]=e);let T=e=>(0,p.jsx)(`tr`,{style:{pointerEvents:`none`},children:(0,p.jsx)(`td`,{colSpan:5,style:{margin:0},className:`bg-info`,children:(0,p.jsx)(`span`,{children:e.step_group?.label})})}),E=e=>{let t=e.label,n=t?.id;if(!e.is_own_label||!t||n===void 0)return null;let r=e=>{s(t=>{let n=new Map(t);return n.set(e,!n.get(e)),n})};return(0,p.jsx)(`tr`,{style:{cursor:`pointer`},onClick:()=>r(n),children:(0,p.jsx)(`td`,{colSpan:5,style:{margin:0},className:`bg-secondary`,children:(0,p.jsxs)(`span`,{className:`label-toggle`,children:[(0,p.jsx)(`i`,{className:`fa `+(o.get(e.label?.id??-1)?`fa-caret-down`:`fa-caret-right`)}),` `,t.label]})})})};return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center`,children:(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t,className:`form-check-input`,"data-toggle":`toggle`,onChange:()=>n(!t)}),(0,p.jsx)(`label`,{className:`ms-2`,children:`Show only emphasized parameters`})]})}),(0,p.jsxs)(kl,{borderless:!0,hover:!0,striped:!0,size:`sm`,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Parts`}),(0,p.jsx)(`th`,{}),(0,p.jsx)(`th`,{children:`Process`}),(0,p.jsx)(`th`,{children:`Equipment`})]})}),(0,p.jsx)(`tbody`,{children:y.map(t=>{let n=`step-${t.id}`;return(0,p.jsxs)(d.default.Fragment,{children:[t.has_label&&E(t),(!t.has_label||o.get(t.label?.id??-1))&&(0,p.jsxs)(p.Fragment,{children:[t.has_step_group&&C.includes(t)&&T(t),t.has_requirement?(0,p.jsx)(iL,{requirement:x.find(e=>e.step.id===t.id),step:t,parts:b,refetchFn:u}):(0,p.jsx)(ZI,{run:e,step:t,parts:b,monitoredBy:w[t.id],refetchFn:u})]})]},n)})})]}),(0,p.jsx)(zF,{data:f.data,setPage:i,isPlaceholderData:f.isPlaceholderData})]})}function oL(){let{run:e}=(0,d.useContext)(ZF);return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{children:`Run information`}),(0,p.jsx)(`h3`,{children:`Run name`}),(0,p.jsx)(`p`,{children:e.name}),(0,p.jsx)(`h3`,{children:`Project name`}),(0,p.jsx)(`p`,{children:e.project.name})]})}var sL=()=>{let[e,t]=(0,d.useState)(null),[n,r]=(0,d.useState)(null),{id:i}=(0,g.useParams)();(0,d.useEffect)(()=>{(e===null||i!==e.id.toString())&&Se({id:parseInt(i)}).then(e=>(xe({id:e.run_id}).then(r),e)).then(t)},[i,e]);function a(){Se({id:parseInt(i)}).then(e=>(xe({id:e.run_id}).then(r),e)).then(t)}return{run:n,runStep:e,setRunStep:t,reloadRunStep:a}};function cL({children:e}){let{runStep:t,setRunStep:n,run:r,reloadRunStep:i}=sL(),[a,o]=(0,d.useState)({});if(t===null||r===null){let e=`Loading run...`;return t===null&&r===null?e=`Loading run and run step...`:r===null&&(e=`Loading run step...`),(0,p.jsx)(Ct,{children:(0,p.jsx)(vt,{message:e})})}return(0,p.jsx)(Ct,{children:(0,p.jsx)($I.Provider,{value:{runStep:t,setRunStep:n,reloadRunStep:i,run:r,modalProperties:a,setModalProperties:o},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading...`}),children:e})})})}function lL(){return(0,p.jsx)(cL,{children:(0,p.jsx)(Wr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})})}var uL=({label:e})=>(0,p.jsx)(`div`,{className:`p-2 h4 mb-1 bg-info text-white`,children:e.label}),dL=({runStep:e})=>{let{environment:t}=(0,g.useParams)();return(0,p.jsxs)(`h2`,{children:[` `,e.number,` -`,e.process_module.process.name,` on`,` `,(0,p.jsxs)(g.Link,{to:`/${t}/operator/equipment/${e.process_module.module.equipment.id}`,children:[e.process_module.module.equipment.name,` (`,e.process_module.module.name,`)`]})]})},fL=({checklistItem:e,show:t,setModalShow:n,mutation:r})=>(0,p.jsxs)(U,{show:t,size:`lg`,onHide:()=>n(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Checklist item`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsx)(`h2`,{children:e.task}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.description}})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:()=>{r.mutate()},children:`Done`}),(0,p.jsx)(B,{variant:`secondary`,onClick:()=>n(!1),children:`Close`})]})]});function pL({checklistItem:e,onOpenModal:t,onMarkDone:n}){return e.can_finish?e.description===``?(0,p.jsx)(B,{className:`float-end`,size:`sm`,variant:`success`,onClick:n,children:`Done checklist step`}):(0,p.jsx)(B,{className:`float-end`,variant:`primary`,onClick:t,children:`Execute checklist step`}):null}var mL=({checklistItem:e,refetch:t})=>{let[n,r]=(0,d.useState)(!1),i=(0,m.useMutation)({mutationFn:async()=>(await f.default.create().patch(`update/run/step/checklist/done/`+e.id,{})).data,onSuccess:e=>{r(!1),t()}});return(0,p.jsxs)(Zs.Item,{disabled:e.is_executed,className:`d-flex justify-content-between align-items-start`,children:[(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[e.task,e.is_executed&&(0,p.jsxs)(`small`,{children:[`Executed on `,(0,p.jsx)(eI,{format:`DD-MM-YYYY`,children:e.date_executed})]})]}),(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(pL,{checklistItem:e,onOpenModal:()=>r(!0),onMarkDone:()=>i.mutate()})}),(0,p.jsx)(fL,{checklistItem:e,show:n,setModalShow:r,mutation:i})]})},hL={movingOut:`Moving out...`,skipping:`Skipping...`,unskipping:`Unskipping...`,operationFinished:`Operation finished`,operationSkipped:`Operation skipped`,operationUnskipped:`Operation unskipped`};function gL({run:e,runStep:t,reloadRunStep:n}){let r=(0,g.useNavigate)(),{environment:i}=(0,g.useParams)(),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),{run:l,runStep:u,reloadRunStep:h}=(0,d.useContext)($I);(0,d.useEffect)(()=>{if(a){let e=setTimeout(()=>{o(null)},3e3);return()=>clearTimeout(e)}},[a]);let _=e??l,v=t??u,y=n??h??(()=>null),{data:b,error:x,isLoading:S,refetch:C}=(0,m.useQuery)({queryKey:[`checklist`,v?.id],queryFn:()=>ke({runStep:v}),enabled:!!v}),w=(0,d.useCallback)(async e=>{o(hL.movingOut),c(!0);try{let t=await Ae(e);o(hL.operationFinished),t.data.next_step_id===null?y():r(`/${i}/operator/run/step/${t.data.next_step_id}`)}finally{c(!1)}},[i,r,y]),T=(0,d.useCallback)(async e=>{o(hL.skipping),c(!0);try{await f.default.create().patch(`update/run/step/skip/${e.id}`,{}),o(hL.operationSkipped),y()}finally{c(!1)}},[y]),E=(0,d.useCallback)(async e=>{o(hL.unskipping),c(!0);try{await f.default.create().patch(`update/run/step/un-skip/${e.id}`,{}),o(hL.operationUnskipped),y()}finally{c(!1)}},[y]),{checklistItems:D,canFinishOperation:O}=(0,d.useMemo)(()=>{let e=b?.items??[],t=e.findIndex(e=>!e.is_executed);return{checklistItems:e.map((e,n)=>({...e,can_finish:n===t})),canFinishOperation:!!(v&&!v.is_finished&&t===-1)}},[b,v]);return!v||!_?(0,p.jsx)(p.Fragment,{children:`Please set RunStepContext in RunStepChecklist`}):S?(0,p.jsx)(vt,{message:`Loading...`}):x?(0,p.jsx)(vr,{variant:`danger`,children:`Failed to load checklist.`}):(0,p.jsxs)(p.Fragment,{children:[D.length===0&&(0,p.jsx)(vr,{variant:`info`,children:`No checklist found`}),D.length>0&&(0,p.jsx)(Zs,{children:D.map(e=>(0,p.jsx)(mL,{checklistItem:e,refetch:C},e.id))}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mt-3`,children:[(0,p.jsxs)(`div`,{className:`d-flex gap-2 align-items-center`,children:[O&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`success`,onClick:()=>w(v),disabled:s,children:a===hL.operationFinished||a===hL.movingOut?a:`Move out`})}),_.access.edit&&!v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,onClick:()=>T(v),disabled:s,children:a===hL.operationSkipped||a===hL.skipping?a:`Skip operation`})}),_.access.edit&&v.is_skipped&&(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`warning`,onClick:()=>E(v),disabled:s,children:a===hL.operationUnskipped||a===hL.unskipping?a:`Unskip operation`})})]}),(0,p.jsx)(`div`,{className:`d-flex gap-2`,children:v.next_step_id&&(0,p.jsx)(`div`,{children:(0,p.jsx)(g.Link,{to:`/${i}/operator/run/step/${v.next_step_id}`,className:`btn btn-secondary`,children:`Next step`})})})]})]})}var _L=()=>void 0;function vL({runStep:e,reloadRunStep:t,title:n=`Remark`,titleClassName:r=`mb-2 text-start`}){let{runStep:i,setRunStep:a}=(0,d.useContext)($I),o=e??i,s=t?()=>t():e?_L:a??_L,[c,l]=(0,d.useState)(!1),u=o?!o.is_finished:!1,m=!!o?.remark?.trim(),{register:h,handleSubmit:g,formState:_,reset:v}=Ed({defaultValues:{remark:o?.remark_unparsed??``}}),{isSubmitting:y}=_;(0,d.useEffect)(()=>{v({remark:o?.remark_unparsed??``})},[v,o?.remark_unparsed]);let b=(0,d.useCallback)(async e=>{if(!o)return;await f.default.patch(`update/run/step/`+o.id,{remark:e.remark});let t=await f.default.get(`view/run/step/`+o.id);s({...o,remark:t.data.remark,remark_unparsed:t.data.remark_unparsed}),l(!1)},[o,s]);return o?!c||!u?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:r,children:n}),!m&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`text-muted`,children:`No remark.`}),u&&(0,p.jsx)(B,{variant:`primary`,className:`ms-auto`,size:`sm`,onClick:()=>l(!0),children:`Add remark`})]}),m&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`text-success`,dangerouslySetInnerHTML:{__html:o.remark}}),` `,u&&(0,p.jsx)(B,{variant:`primary`,className:`mt-3`,onClick:()=>l(!0),children:`Edit remark`})]})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{className:r,children:n}),(0,p.jsxs)(H,{onSubmit:g(b),children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:6,...h(`remark`)}),(0,p.jsx)(`p`,{children:(0,p.jsx)(`small`,{className:`text-muted`,children:`If a non-conformity happens, note it here`})}),(0,p.jsxs)(B,{variant:`primary`,type:`submit`,disabled:y,children:[y&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Save remark`]}),(0,p.jsx)(B,{variant:`secondary`,className:`ms-2`,onClick:()=>l(!1),children:`Cancel`})]})]}):(0,p.jsx)(p.Fragment,{children:`Please set RunStepContext for StepRemark`})}var yL=({run:e,show:t,setShow:n,runHoldCode:r,setRunHoldCode:i})=>{let[a,o]=d.default.useState(!1),{register:s,control:c,setValue:l,handleSubmit:u,formState:m}=Ed({defaultValues:{holdCode:r?{value:r.hold_code.id,label:r.hold_code.code}:{},description:r?r.description:``}}),{errors:h,isSubmitting:g}=m,_=async t=>{try{let n=await f.default.patch(`update/run/hold-code/`+e.id,{holdcode:a?null:t.holdCode.value,description:t.description});n.data.hold_code?i(n.data):i(void 0),o(!1)}finally{n(!1)}},v=(e,t)=>{f.default.get(`list/run/hold-code`).then(e=>{let{data:t}=e;return t._embedded.items}).then(e=>{t(e.map(e=>({value:e.id,label:e.code})))})};return(0,p.jsx)(U,{show:t,size:`lg`,onHide:()=>n(!1),children:(0,p.jsxs)(H,{onSubmit:u(_),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:a?`Reset hold code`:`Update hold code`})}),(0,p.jsxs)(U.Body,{children:[!a&&(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Hold code`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(vu,{name:`holdCode`,control:c,rules:{validate:{required:e=>e.value!==void 0||a||`A hold code is required`}},render:({field:e})=>(0,p.jsx)(Vb,{isSearchable:!1,defaultOptions:!0,placeholder:`Select a hold code`,loadOptions:v,value:e.value,onChange:t=>{e.onChange(t)}})}),h.holdCode&&(0,p.jsx)(`span`,{className:`text-danger`,children:h.holdCode.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`Message`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:3,...s(`description`,{required:`A message is required`}),isInvalid:h.description!==void 0}),h.description&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:h.description.message})]})]})]}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsxs)(B,{type:`submit`,variant:a?`success`:`primary`,disabled:g,children:[g&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),a?`Release lot`:`Update Hold code`]}),r&&(0,p.jsx)(B,{variant:`outline-danger`,onClick:()=>{l(`description`,a?r.description:``),o(!a)},children:a?`Update hold Code`:`Reset hold code`})]})]})})},bL=()=>{let{run:e}=(0,d.useContext)($I),[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(e.hold_code),a=()=>{n(!0)};return(0,p.jsxs)(p.Fragment,{children:[r&&(0,p.jsx)(`span`,{className:`badge handle`,style:{backgroundColor:r.hold_code.back_color,color:r.hold_code.front_color,fontSize:`1.5rem`,cursor:`pointer`},onClick:()=>a(),children:r.hold_code.code}),!r&&(0,p.jsx)(yr,{bg:`secondary`,className:`handle`,onClick:()=>a(),style:{fontSize:`1.5rem`,cursor:`pointer`},children:`No hold code`}),(0,p.jsx)(yL,{run:e,show:t,setShow:n,runHoldCode:r,setRunHoldCode:i})]})},xL=()=>{let{run:e}=(0,d.useContext)($I),[t,n]=(0,d.useState)(e.priority);return(0,p.jsxs)(d.default.Fragment,{children:[t&&(0,p.jsx)(`span`,{className:`badge`,style:{backgroundColor:t.priority.back_color,color:t.priority.front_color,fontSize:`1.5rem`},children:t.priority.code}),!t&&(0,p.jsx)(`span`,{className:`badge bg-info`,style:{fontSize:`1.5rem`},children:`NORMAL`})]})},SL=({run:e,runStep:t,showOnlyEmphasizedParameters:n})=>(0,p.jsx)(`div`,{className:`border rounded px-3 py-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsx)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:(0,p.jsx)(qI,{run:e,runStep:t})}),(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[n&&(0,p.jsx)(`h4`,{children:`Emphasized parameters`}),!n&&(0,p.jsx)(`h4`,{children:`Parameters`}),(0,p.jsx)(sI,{runStep:t,editableParameters:!1,showOnlyEmphasizedParameters:n})]})]})}),CL=({run:e,monitoredBy:t,runStep:n,runParts:r,runStepParts:i,hideLabel:a,firstInGroup:o})=>{let{environment:s}=(0,g.useParams)(),[c,l]=(0,d.useState)(!1),{runStep:u}=(0,d.useContext)($I);return(0,p.jsxs)(p.Fragment,{children:[!a&&n.has_label&&n.is_own_label&&(0,p.jsx)(`div`,{className:`bg-info text-white rounded px-3 py-1`,children:n.label?.label}),n.step_group&&o&&(0,p.jsx)(`div`,{className:`bg-secondary text-white rounded px-3 py-1`,children:n.step_group?.label}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 border rounded px-3 py-2 ${n.has_step_group?`ms-4`:``}`,children:[(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-2 flex-shrink-0`,children:[n.id!==u.id&&(0,p.jsx)(`i`,{className:`fa `+(c?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:()=>{l(!c)}}),n.id===u.id&&(0,p.jsx)(`i`,{className:`fa fa-chevron-right text-success`,style:{cursor:`pointer`},title:`This step is currently running`})]}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 flex-grow-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(XI,{step:n,parts:r,stepParts:i,run:e})}),(0,p.jsxs)(`div`,{className:`flex-shrink-0 text-nowrap`,children:[n.number,` `,n.is_skipped&&(0,p.jsx)(yr,{bg:`info`,children:`Skipped`})]}),(0,p.jsxs)(`div`,{className:`flex-grow-1 min-w-0`,children:[(0,p.jsx)(g.Link,{to:`/${s}/operator/run/step/${n.id}`,dangerouslySetInnerHTML:{__html:n.name}}),` `,t&&(0,p.jsx)(pl,{placement:`top`,overlay:(0,p.jsx)(sl,{id:`tooltip-${t.id}`,children:`Monitored by step: ${t.step.number}`}),children:(0,p.jsx)(`i`,{className:`fa fa-search me-2`})})]})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-3 flex-shrink-0 ms-auto`,children:[(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.finish_user?n.finish_user.initials:``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.has_rework?(0,p.jsx)(`span`,{className:`badge bg-primary`,children:`Rework`}):``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:n.is_finished?(0,p.jsx)(eI,{format:`DD-MM-YYYY`,children:n.finish_date}):``})]})]}),c&&(0,p.jsx)(SL,{run:e,runStep:n,showOnlyEmphasizedParameters:!1})]})};function wL({requirement:e,step:t,stepParts:n,parts:r,measurementResults:i}){let a=n.filter(t=>t.step_id===(e.requirement_for_step?.id??e.step.id)),{environment:o}=(0,g.useParams)();return(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(`div`,{className:`border rounded px-3 py-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-wrap gap-3`,children:[(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[(0,p.jsx)(`h4`,{children:`Measurement results`}),(0,p.jsx)(eL,{requirement:e,step:t,stepParts:a,parts:r,measurementResults:i,editOnly:!0})]}),(0,p.jsxs)(`div`,{style:{flexGrow:1,flex:`1 1 360px`},children:[(0,p.jsx)(`h4`,{children:`Monitored Step`}),(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${e.requirement_for_step?.id??e.step.id}`,children:(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`i`,{className:`fa fa-search`}),` `,e.requirement_for_step?.name??e.step.name]})}),(0,p.jsx)(`h4`,{children:`Definition`}),(0,p.jsx)(`span`,{children:e.definition}),(0,p.jsx)(`h4`,{children:`Targets`}),(0,p.jsxs)(kl,{size:`sm`,striped:!1,bordered:!1,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`min value`}),(0,p.jsx)(`th`,{children:`max value`}),(0,p.jsx)(`th`,{children:`inclusive`})]})}),(0,p.jsx)(`tbody`,{children:e.targets.map(e=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e.min_value}),(0,p.jsx)(`td`,{children:e.max_value}),(0,p.jsx)(`td`,{children:e.inclusive?`yes`:`no`})]},e.id))})]})]})]})})})}function TL({requirement:e,runParts:t,runStepParts:n,hideLabel:r,firstInGroup:i}){let a=e.step,{environment:o}=(0,g.useParams)(),{runStep:s}=(0,d.useContext)($I),[c,l]=(0,d.useState)(!1),[u]=(0,m.useQueries)({queries:[{queryKey:[`requirement`,`measurementResults`,JSON.stringify(e.measurement.id)],queryFn:()=>Oe({measurement:e.measurement})}]});return(0,p.jsxs)(p.Fragment,{children:[!r&&a.has_label&&a.is_own_label&&(0,p.jsx)(`div`,{className:`bg-info text-white rounded px-3 py-1`,children:a.label?.label}),a.step_group&&i&&(0,p.jsx)(`div`,{className:`bg-secondary text-white rounded px-3 py-1`,children:a.step_group?.label}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 border rounded px-3 py-2 ${(()=>{if(!u.data)return``;let t=!1;for(let r of n){let n=u.data?.items.find(e=>e.values.some(e=>e.step_part_id===r.id))?.values.find(e=>e.step_part_id===r.id);if(!(n&&!isNaN(parseFloat(n.string_value))))return a.id===s.id?`bg-success-subtle`:``;let i=parseFloat(n.string_value);if(e.targets.some(e=>e.inclusive?!(e.min_value<=i&&e.max_value>=i):!(e.min_value<i&&e.max_value>i))){t=!0;break}}return t?`bg-danger-subtle`:a.id===s.id?`bg-success-subtle`:``})()} ${a.has_step_group?`ms-4`:``}`,children:[(0,p.jsx)(`div`,{className:`d-flex align-items-center gap-2 flex-shrink-0`,children:a.id!==s.id&&(0,p.jsx)(`i`,{className:`fa `+(c?`fa-chevron-down`:`fa-chevron-right`),style:{cursor:`pointer`},onClick:()=>{l(!c)}})}),(0,p.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-3 flex-grow-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`flex-shrink-0`,children:(0,p.jsx)(rL,{requirement:e,step:a,parts:t,stepParts:n,measurementResults:u.data?.items??[]})}),(0,p.jsxs)(`div`,{className:`flex-shrink-0 text-nowrap`,children:[a.number,` `,a.is_skipped&&(0,p.jsx)(yr,{bg:`info`,children:`Skipped`})]}),(0,p.jsxs)(`div`,{className:`flex-grow-1 min-w-0`,children:[(0,p.jsx)(yr,{bg:`info`,children:`requirement`}),` `,(0,p.jsx)(g.Link,{to:`/${o}/operator/run/step/${a.id}`,dangerouslySetInnerHTML:{__html:a.name}}),` `]})]}),(0,p.jsxs)(`div`,{className:`d-flex align-items-center gap-3 flex-shrink-0 ms-auto`,children:[(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.finish_user?a.finish_user.initials:``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.has_rework?(0,p.jsx)(`span`,{className:`badge bg-primary`,children:`Rework`}):``}),(0,p.jsx)(`span`,{className:`text-nowrap`,children:a.is_finished?(0,p.jsx)(eI,{format:`DD-MM-YYYY`,children:a.finish_date}):``})]})]}),c&&(0,p.jsx)(wL,{requirement:e,step:a,stepParts:n,parts:t,measurementResults:u.data?.items??[]})]})}var EL=({pageSize:e=25,hideLabel:t=!1})=>{let{runStep:n,run:r}=(0,d.useContext)($I),[i,a]=(0,d.useState)(1);(0,d.useEffect)(()=>{n?.sequence&&a(Math.max(1,Math.ceil(n.sequence/e)))},[n?.sequence,e]);let o=r?.id??null,s=(0,m.useQuery)({queryKey:[`runParts`,`${o}`],queryFn:()=>Te({run:r}),enabled:!!o}),c=(0,m.useQuery)({queryKey:[`runStepParts`,`${o}`],queryFn:()=>Ne({run:r}),enabled:!!o}),l=(0,m.useQuery)({queryKey:[`runSteps`,o,i,e],queryFn:()=>Ee({run:r,page:i,pageSize:e}),enabled:!!o,placeholderData:m.keepPreviousData}),u=(0,m.useQuery)({queryKey:[`requirements`,o],queryFn:()=>Ce({run:r}),enabled:!!o,placeholderData:m.keepPreviousData}),f=s.isLoading||c.isLoading||l.isLoading||u.isLoading,h=s.isError||c.isError||l.isError||u.isError,g=s.error||c.error||l.error||u.error,_=s.data?.items??[],v=c.data?.items??[],y=l.data?.items??[],b=u.data?.items??[],x=new Set,S=y.filter(e=>!e.has_step_group||typeof e.step_group?.id!=`number`||x.has(String(e.step_group.id))?!1:(x.add(String(e.step_group.id)),!0)),C={};for(let e of b)e.requirement_for_step!=null&&(C[String(e.requirement_for_step.id)]=e);return d.default.useEffect(()=>{h&&console.error(`RunStepSimpleList query error`,{runId:o,errors:[s.error,c.error,l.error,u.error]})},[h,o,s.error,c.error,l.error,u.error]),(0,p.jsxs)(`div`,{children:[f?(0,p.jsx)(`div`,{children:`Loading...`}):h?(0,p.jsxs)(`div`,{children:[`Error: `,String(g?.message??g)]}):(0,p.jsx)(`div`,{className:`d-flex flex-column gap-2`,children:y.map((e,n)=>(0,p.jsx)(d.default.Fragment,{children:e.has_requirement?(0,p.jsx)(TL,{requirement:b.find(t=>t.step.id===e.id),runParts:_,runStepParts:v,firstInGroup:S.includes(e)},e.id??e.sequence??n):(0,p.jsx)(CL,{run:r,monitoredBy:C[e.id],runParts:_,runStepParts:v,hideLabel:t,firstInGroup:S.includes(e),runStep:e},e.id??e.sequence??n)},n))}),(0,p.jsx)(zF,{data:l.data,setPage:a,isPlaceholderData:l.isPlaceholderData}),l.isFetching?(0,p.jsx)(`span`,{children:` Loading...`}):null]})},DL=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)($I),[r,i]=(0,d.useState)(1),{isPending:a,isLoading:o,isError:s,error:c,data:l,isFetching:u,isPlaceholderData:f}=(0,m.useQuery)({queryKey:[`run_changelog`,n,r],queryFn:()=>we({run:n,page:r}),placeholderData:m.keepPreviousData});return(0,p.jsxs)(U,{show:e,size:`lg`,onHide:()=>t(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsxs)(U.Title,{children:[`History of Run `,n.label]})}),(0,p.jsx)(U.Body,{children:(0,p.jsxs)(`div`,{children:[a?(0,p.jsx)(`div`,{children:`Loading...`}):s?(0,p.jsxs)(`div`,{children:[`Error: `,c.message]}):(0,p.jsx)(kl,{size:`sm`,striped:!0,bordered:!0,hover:!0,children:(0,p.jsx)(`tbody`,{children:l.items.map((e,t)=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:(0,p.jsx)(eI,{format:`DD-MM-YYYY`,children:e.date_created})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.message}})}),(0,p.jsxs)(`td`,{children:[e.user.first_name,` `,e.user.last_name]})]},t))})}),(0,p.jsx)(zF,{data:l,setPage:i,isPlaceholderData:f}),u?(0,p.jsx)(`span`,{children:` Loading...`}):null]})}),(0,p.jsx)(U.Footer,{children:(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},OL=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(B,{size:e,variant:`primary`,onClick:()=>n(!t),children:`Run history`}),t&&(0,p.jsx)(DL,{show:t,setModalShow:n})]})},kL=({show:e,setModalShow:t})=>{let{run:n}=(0,d.useContext)($I);return(0,p.jsxs)(U,{show:e,size:`xl`,onHide:()=>t(!1),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsxs)(U.Title,{children:[`All steps of run `,n.label]})}),(0,p.jsx)(U.Body,{children:(0,p.jsx)(EL,{hideLabel:!1})}),(0,p.jsx)(U.Footer,{children:(0,p.jsx)(B,{className:`float-end`,variant:`secondary`,onClick:()=>{t(!1)},children:`Close`})})]})},AL=({size:e})=>{let[t,n]=(0,d.useState)(!1);return(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(B,{size:e,variant:`primary`,onClick:()=>n(!0),children:`All run steps`}),t&&(0,p.jsx)(kL,{show:t,setModalShow:n})]})},jL=()=>{let{runStep:e,run:t}=(0,d.useContext)($I),[n,r]=(0,d.useState)(!1),[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)([]),[u,h]=(0,d.useState)([]),[g,_]=(0,d.useState)([]),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)(!1);if(!e.has_recipe)return`Reworks are only possible for steps with a recipe`;let[S,C,w]=(0,m.useQueries)({queries:[{queryKey:[`templates`,g],queryFn:()=>Ue({reworkRecipes:g}),enabled:n&&g.length>0},{queryKey:[`run_steps`,e.id],queryFn:()=>Ee({run:t,page:1,pageSize:1e3}),enabled:n},{queryKey:[`template_steps`,`rework`,o,e.id],queryFn:()=>He({template:o,pageSize:1e3}),enabled:o!==null}]});(0,d.useEffect)(()=>{C.isSuccess&&c.length>0&&_([...C.data.items.filter(e=>c.includes(e.id)).map(e=>e.recipe_version.recipe)])},[C.isSuccess,c]);function T(e){let t=S.data.templates.find(t=>t.id===e);t!==void 0&&s(t)}function E(){let t={};a({}),c.length===0&&(t.runStep=`Please select at least one step`),a(e=>({...e,...t})),Object.keys(t).length===0&&(x(!0),f.default.create().patch(`/update/run/step/rework/`+e.id,{reworked_run_steps:c,template_steps:u,comment:v}).then(()=>{x(!1),window.location.reload()}))}return(0,p.jsxs)(p.Fragment,{children:[n&&(0,p.jsxs)(H,{method:`post`,onSubmit:()=>E(),children:[(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Template`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[g.length===0&&(0,p.jsx)(vr,{variant:`info`,children:`Please select a rework step`}),g.length>0&&(0,p.jsxs)(H.Control,{as:`select`,name:`template`,onChange:e=>T(parseInt(e.target.value)),isInvalid:!!i.template,children:[(0,p.jsx)(`option`,{value:``,children:`— Select a template`}),S.data!==void 0&&S.data.templates.map((e,t)=>(0,p.jsxs)(`option`,{value:e.id,children:[e.label,`: `,e.name]},t))]}),i.template&&(0,p.jsx)(`span`,{className:`text-danger`,children:i.template})]})]}),o!==null&&(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Include template steps`}),(0,p.jsx)(`div`,{className:`col-sm-9`,children:(0,p.jsx)(`ul`,{className:`list-group`,children:!w.isLoading&&w.data!==void 0&&w.data.steps.map((e,t)=>(0,p.jsx)(`li`,{className:`list-group-item `,children:(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,className:`form-check-input`,id:`templateStep`+e.id,name:`templateStep`,onChange:t=>{t.target.checked?h([...u,e.id]):h(u.filter(t=>t!==e.id))},value:e.id}),(0,p.jsxs)(`label`,{htmlFor:`templateStep`+e.id,className:`from-check-label`,children:[(0,p.jsxs)(`small`,{className:`text-muted pe-2`,children:[e.number,`:`]}),e.process_module.process.name]})]})},t))})})]}),(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Repeat steps`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(`ul`,{className:`list-group`,children:[C.isLoading&&(0,p.jsx)(`option`,{children:`Loading run steps...`}),!C.isLoading&&C.data.items.map((t,n)=>{if(e.sequence>=t.sequence)return(0,p.jsxs)(`li`,{className:`list-group-item d-flex justify-content-between`+(e.id===t.id?` bg-success-subtle`:``),children:[(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,className:`form-check-input`,id:`runStep`+t.id,name:`runStep`,onChange:e=>{e.target.checked?l([...c,t.id]):l(c.filter(e=>e!==t.id))},value:t.id}),(0,p.jsxs)(`label`,{htmlFor:`runStep`+t.id,className:`from-check-label`,children:[(0,p.jsxs)(`small`,{className:`text-muted pe-2`,children:[t.number,`:`]}),t.process_module.process.name]})]}),t.is_finished&&(0,p.jsx)(`div`,{children:(0,p.jsx)(`span`,{className:`badge bg-success`,children:`Finished`})})]},n)})]}),i.runStep&&(0,p.jsx)(`span`,{className:`text-danger`,children:i.runStep})]})]}),(0,p.jsxs)(`div`,{className:`row mb-3`,children:[(0,p.jsx)(H.Label,{className:`col-sm-3 col-form-label text-end`,children:`Comment`}),(0,p.jsx)(`div`,{className:`col-sm-9`,children:(0,p.jsxs)(H.Group,{controlId:`runStep.remark`,children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:6,onChange:e=>y(e.target.value),value:v,isInvalid:!!i.comment}),(0,p.jsx)(`small`,{className:`text-muted`,children:`Optional comment for the rework`})]})})]}),(0,p.jsx)(`div`,{className:`row mb-3`,children:(0,p.jsxs)(`div`,{className:`col-sm-9 offset-sm-3`,children:[(0,p.jsxs)(B,{variant:`primary`,onClick:()=>E(),disabled:b,children:[b&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Create rework`]}),`\xA0`,(0,p.jsx)(B,{variant:`warning`,onClick:()=>r(!1),children:`Cancel`})]})})]}),!n&&(0,p.jsx)(B,{variant:`primary`,className:`mt-3`,onClick:()=>r(!0),children:`Set Rework`})]})},ML=()=>{let{environment:e}=(0,g.useParams)(),{runStep:t,run:n}=(0,d.useContext)($I),r=(0,m.useQueries)({queries:[{queryKey:[`monitors`,t.process_module.module.equipment],queryFn:()=>he({equipment:t.process_module.module.equipment})},{queryKey:[`ecn`,t.process_module.module],queryFn:()=>ie({module:t.process_module.module})},{queryKey:[`equipmentModule`,t.process_module.module],queryFn:()=>ne({id:t.process_module.module.id})},{queryKey:[`requirement`,t.id],queryFn:()=>Ce({run:n,step:t})}]}),[i,a,o,s]=r,[c,l]=(0,d.useState)(!0),{addReadingCallbackFn:u,removeReadingCallbackFn:f}=AI(),[h,_]=(0,d.useState)(``),v=(0,d.useId)();(0,d.useEffect)(()=>(u(v,_),()=>{f(v)}),[]);let y=r.some(e=>e.isLoading);if(r.some(e=>e.isError))return r.filter(e=>e.isError).forEach((e,r)=>{console.error(`StepDashboard query error`,{index:r,error:e.error,runStep:t,run:n})}),(0,p.jsx)(p.Fragment,{children:`Error fetching data`});if(y)return(0,p.jsx)(`div`,{children:`Loading...`});let b=o.data;return(0,p.jsx)(Wr,{fluid:!0,children:(0,p.jsxs)(Dl,{children:[(0,p.jsxs)(Ur,{className:`col-9`,children:[n.run_type===ut.RESEARCH&&(0,p.jsx)(`small`,{children:`Research run`}),n.run_type===ut.PRODUCTION&&(0,p.jsx)(`small`,{children:`Production run`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center mb-3`,children:[(0,p.jsxs)(`h1`,{className:`display-4`,children:[n.name,` (`,n.project.name,`)`]}),(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-lg-row gap-2 flex-wrap justify-content-end`,children:[t.has_rework&&(0,p.jsx)(`span`,{style:{fontSize:`1.5rem`},className:`mx-1 badge bg-primary`,children:`Rework`}),(0,p.jsx)(xL,{}),(0,p.jsx)(bL,{}),t.is_skipped&&(0,p.jsx)(`span`,{style:{fontSize:`1.5rem`},className:`badge bg-info`,children:`SKIPPED`})]})]}),(0,p.jsx)(tI,{run:n}),t.label&&(0,p.jsx)(uL,{label:t.label}),(0,p.jsx)(dL,{runStep:t}),t.is_finished&&(0,p.jsxs)(vr,{variant:`success`,children:[`This step has been finished by `,t.finish_user?.first_name,` `,t.finish_user?.last_name]}),t.has_recipe&&(0,p.jsx)(Pr,{className:`rounded my-4`,children:(0,p.jsxs)(Pr.Body,{children:[(0,p.jsx)(Pr.Title,{className:`text-muted`,children:`Recipe`}),(0,p.jsxs)(Pr.Text,{className:`display-5`,children:[t.recipe_version.recipe.name,` (Version `,t.recipe_version.version,`)`]})]})}),s.data?.items.length==1&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h4`,{children:`Measurements by part`}),(0,p.jsx)(eL,{requirement:s.data.items[0],step:t,editOnly:!1}),(0,p.jsx)(`h4`,{children:`Measurements for whole step`}),(0,p.jsx)(tL,{requirement:s.data.items[0],editOnly:!1})]}),s.data?.items.length!=1&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{children:`Experimental split`}),(0,p.jsx)(qI,{run:n,runStep:t})]}),(0,p.jsxs)(`p`,{className:`pt-3`,children:[`Reading from scanner: `,h]}),(0,p.jsxs)(Dl,{className:`pm-3`,children:[(0,p.jsxs)(Ur,{children:[(0,p.jsx)(`h3`,{children:`Checklist`}),(0,p.jsx)(gL,{}),(0,p.jsx)(`h2`,{className:`mt-2`,children:`Step files`}),(0,p.jsx)(lI,{runStep:t})]}),(0,p.jsxs)(Ur,{children:[(0,p.jsx)(`h2`,{children:`Parameters`}),(0,p.jsxs)(`div`,{className:`form-check form-switch`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:c,className:`form-check-input`,"data-toggle":`toggle`,onChange:()=>l(!c)}),(0,p.jsx)(`label`,{className:`ms-2`,children:`Show only emphasized parameters`})]}),(0,p.jsx)(sI,{runStep:t,editableParameters:!1,showOnlyEmphasizedParameters:c}),t.has_instructions&&t.instructions&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`h3`,{children:`Instructions`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.instructions}})]}),(0,p.jsx)(vL,{}),(0,p.jsx)(`h3`,{className:`pt-3`,children:`Rework`}),(0,p.jsx)(jL,{})]})]}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mb-3`,children:[(0,p.jsx)(`h2`,{children:`Run steps`}),(0,p.jsxs)(`div`,{className:`d-flex gap-2 flex-wrap justify-content-end`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(AL,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(OL,{size:void 0})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(ZP,{size:void 0,moduleId:t.process_module.module.id})})]})]}),(0,p.jsx)(EL,{pageSize:n.run_type===ut.RESEARCH?5:1e3,hideLabel:!0})]}),(0,p.jsx)(Ur,{className:`col-3`,children:(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(`h2`,{children:(0,p.jsxs)(g.Link,{to:`/${e}/operator/equipment/${t.process_module.module.equipment.id}`,children:[t.process_module.module.equipment.name,` (`,t.process_module.module.name,`)`]})}),b&&(0,p.jsx)(`div`,{children:(0,p.jsx)(`h2`,{children:(0,p.jsx)(Dd,{module:b})})}),i.data?.items&&i.data.items.map((e,t)=>(0,p.jsx)(XP,{monitor:e},t)),a.data?.items.map(function(e,t){return(0,p.jsxs)(Pr,{className:`my-2`,children:[(0,p.jsxs)(Pr.Header,{children:[`ECN: `,e.ecn]}),(0,p.jsx)(Pr.Body,{children:(0,p.jsx)(Pr.Text,{children:(0,p.jsx)(kP,{children:e.description})})}),(0,p.jsxs)(Pr.Footer,{children:[e.date_created&&(0,p.jsxs)(p.Fragment,{children:[`Created by `,YP(e.date_created,`DD-MM-YY H:m`),` by `,e.owner.full_name]}),e.last_update&&(0,p.jsxs)(p.Fragment,{children:[` `,`· Updated by `,YP(e.last_update,`DD-MM-YY H:m`),` by `,e.owner.full_name]})]})]},t)})]})})]})})},NL=()=>{let[e,t]=(0,d.useState)(!1),{modalProperties:n}=(0,d.useContext)($I),r=()=>{t(!1),n.show=!1};return(0,d.useEffect)(()=>{t(n.show)},[n]),(0,p.jsxs)(U,{show:e,size:`xl`,onHide:r,children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:n.modalTitle})}),(0,p.jsx)(U.Body,{children:n.modalContent}),(0,p.jsxs)(U.Footer,{children:[(0,p.jsx)(B,{variant:`secondary`,onClick:r,children:`Save`}),n.modalSaveButton]})]})};function PL(e){switch(e){case`Shift`:return!0}return!1}function FL(e){return/^[a-zA-Z0-9-]$/.test(e)}function IL(e){return e.length===1}function LL(e){switch(e){case`Enter`:return!0;default:return!1}}function RL(e,t,n,r){let i=r?.requireEndCharacter??!1,a=0,o=``,s=()=>{a=0,o=``,n&&n(o)};return r=>{let c=r.key;if(c===`Escape`){s();return}if(!PL(c)){if(LL(c)){t(o),s();return}switch(o+=c,e[a]){case`/`:if(c!=`/`){s();return}else a=(a+1)%e.length;break;case`*`:if(!IL(c))return;break;default:if(!FL(e[a]))throw Error(`Invalid character expression in makeKeySequenceListener call`);if(c!=e[a]){s();return}else a=(a+1)%e.length;break}if(!i&&a===e.length){t(o),s();return}n&&n(o)}}}var zL=({children:e})=>{let[t,n]=(0,d.useState)(``),r=(0,d.useRef)(new Map),i=(0,d.useRef)(new Map),a=e=>{(0,d.startTransition)(()=>{i.current.forEach(t=>t(e))})},o=e=>{n(e);let t=MI(e);(0,d.startTransition)(()=>{r.current.get(t)?.forEach(t=>t(e))})};return(0,d.useEffect)(()=>{let e=RL(`*`,o,a,{requireEndCharacter:!0});return document.addEventListener(`keyup`,e),()=>{document.removeEventListener(`keyup`,e)}},[o,a]),(0,p.jsx)(kI.Provider,{value:{lastlyReadedKeys:t,addCallbackFn:(e,t,n)=>{r.current.has(e)||r.current.set(e,new Map),r.current.get(e).set(t,n)},removeCallbackFn:(e,t)=>{r.current.get(e)?.delete(t)},addReadingCallbackFn:(e,t)=>{i.current.set(e,t)},removeReadingCallbackFn:e=>{i.current.delete(e)}},children:e})};function BL(){return(0,p.jsx)(II,{children:(0,p.jsx)(zL,{children:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ML,{}),(0,p.jsx)(NL,{})]})})})}function VL({run:e,runStep:t,showOnlyEmphasizedParameters:n,reloadRunStepFn:r}){let{data:i,refetch:a}=(0,m.useQuery)({queryKey:[`checklist`,t?.id],queryFn:()=>ke({runStep:t})}),o=(0,d.useMemo)(()=>i?.items,[i]),[s,c]=(0,m.useQueries)({queries:[{queryKey:[`runParts`,e.id,t.part_level],queryFn:()=>Te({run:e,level:t.part_level})},{queryKey:[`runStepParts`,t.id],queryFn:()=>Ne({step:t})}]}),l=(0,d.useMemo)(()=>{let e=s.data?.items??[],n=c.data?.items??[],r=e.filter(e=>e.part_level===t.part_level);return r.length===0?!1:r.every(e=>n.find(t=>t.part_id==e.id)?.processed===!0)},[s.data,c.data,t.part_level]),[u,f]=(0,d.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between mb-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`h3`,{className:`mb-2 text-start`,children:`Parts`})}),(0,p.jsx)(pl,{placement:`top`,overlay:(0,p.jsx)(sl,{id:`tooltip-move-out`,children:l?`Finish step`:`Finish all parts before moving out`}),children:(0,p.jsx)(`span`,{children:(0,p.jsx)(B,{variant:l?`success`:`light`,onClick:()=>{f(!0),Ae(t).finally(()=>{f(!1),r()})},disabled:u||!l,children:u?`Moving out...`:`Move out`})})})]}),(0,p.jsx)(HI,{run:e,runStep:t}),(0,p.jsx)(`h3`,{className:`mt-2`,children:`Parameters`}),(0,p.jsx)(sI,{runStep:t,showOnlyEmphasizedParameters:n}),(0,p.jsxs)(`div`,{className:`row row-cols-2`,children:[(0,p.jsx)(`div`,{className:`col`,children:(0,p.jsx)(vL,{runStep:t,reloadRunStep:r})}),(0,p.jsx)(`div`,{className:`col`,children:t.has_instructions&&t.instructions&&(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsx)(`h3`,{className:`mb-2 text-start`,children:`Instructions`}),(0,p.jsx)(`span`,{dangerouslySetInnerHTML:{__html:t.instructions}})]})})]}),(0,p.jsxs)(`div`,{className:`row row-cols-2`,children:[(0,p.jsxs)(`div`,{className:`col`,children:[(0,p.jsx)(`h3`,{className:`mt-2`,children:`Checklist`}),!o&&(0,p.jsx)(Zs,{children:Array.from({length:1}).map((e,t)=>(0,p.jsx)(Zs.Item,{children:(0,p.jsxs)(El,{as:`div`,animation:`glow`,children:[(0,p.jsx)(El,{xs:17}),` `,(0,p.jsx)(El,{xs:4}),` `,(0,p.jsx)(El,{xs:6})]})},t))}),o&&(0,p.jsxs)(p.Fragment,{children:[o.length===0&&(0,p.jsx)(vr,{variant:`info`,children:`No checklist found`}),o.length>0&&(0,p.jsx)(Zs,{children:o.map(e=>(0,p.jsx)(mL,{checklistItem:e,refetch:a},e.id))})]})]}),(0,p.jsxs)(`div`,{className:`col`,children:[(0,p.jsx)(`h3`,{className:`mt-2`,children:`Step files`}),(0,p.jsx)(lI,{runStep:t})]})]})]})}function HL({children:e}){let[t,n]=(0,d.useState)(!1);return(0,p.jsx)(Ct,{children:(0,p.jsx)(aI.Provider,{value:{showOnlyEmphasizedParameters:t,setShowOnlyEmphasizedParameters:n},children:(0,p.jsx)(d.Suspense,{fallback:(0,p.jsx)(vt,{message:`Loading...`}),children:e})})})}function UL(){return(0,p.jsx)(Wr,{fluid:!0,children:(0,p.jsx)(g.Outlet,{})})}function WL({control:e,name:t}){let{environment:n}=(0,g.useParams)(),[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(!0);return(0,d.useEffect)(()=>{async function e(){try{i((await fe({environment:n,withLocations:!0})).items)}catch(e){console.error(`Error fetching rooms:`,e)}finally{o(!1)}}e()},[]),a?(0,p.jsx)(`p`,{children:`Loading labs...`}):(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{children:`Choose a lab`}),(0,p.jsx)(H.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:(0,p.jsx)(vu,{name:t,render:({field:{onChange:e,value:t}})=>(0,p.jsxs)(H.Select,{"aria-label":`Choose a lab`,value:t?.id||``,onChange:t=>{e(r.find(e=>e.id.toString()===t.target.value)||null)},children:[(0,p.jsx)(`option`,{value:``,children:`— Choose a lab`}),r.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),control:e})})]})}function GL({control:e}){return(0,p.jsx)(H.Group,{className:`mb-3`,controlId:`chemical.scanBarcode`,children:(0,p.jsx)(vu,{name:`barcode`,control:e,render:({field:e})=>(0,p.jsx)(`input`,{...e,id:`chemical.scanBarcodeElement`,type:`text`,autoFocus:!0,placeholder:`Scan or enter barcode`,className:`form-control form-control-lg`})})})}var KL=Object.defineProperty,qL=Object.getOwnPropertySymbols,JL=Object.prototype.hasOwnProperty,YL=Object.prototype.propertyIsEnumerable,XL=(e,t,n)=>t in e?KL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ZL=(e,t)=>{for(var n in t||(t={}))JL.call(t,n)&&XL(e,n,t[n]);if(qL)for(var n of qL(t))YL.call(t,n)&&XL(e,n,t[n]);return e},QL=(e,t)=>{var n={};for(var r in e)JL.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&qL)for(var r of qL(e))t.indexOf(r)<0&&YL.call(e,r)&&(n[r]=e[r]);return n},$L;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})($L||($L={})),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||(e.QrCode={}))})($L||($L={})),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||(e.QrSegment={}))})($L||($L={}));var eR=$L,tR={L:eR.QrCode.Ecc.LOW,M:eR.QrCode.Ecc.MEDIUM,Q:eR.QrCode.Ecc.QUARTILE,H:eR.QrCode.Ecc.HIGH},nR=128,rR=`L`,iR=`#FFFFFF`,aR=`#000000`,oR=!1,sR=1,cR=4,lR=0,uR=.1;function dR(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function fR(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function pR(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*uR),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function mR(e,t){return t==null?e?cR:lR:Math.max(Math.floor(t),0)}function hR({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=u.default.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...eR.QrSegment.makeSegments(t)),e),[]);return eR.QrCode.encodeSegments(r,tR[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:d,numCells:f,calculatedImageSettings:p}=u.default.useMemo(()=>{let e=c.getModules(),t=mR(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:pR(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:d,cells:l,numCells:f,calculatedImageSettings:p}}var gR=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),_R=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=nR,level:a=rR,bgColor:o=iR,fgColor:s=aR,includeMargin:c=oR,minVersion:l=sR,boostLevel:d,marginSize:f,imageSettings:p}=n,m=QL(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:h}=m,g=QL(m,[`style`]),_=p?.src,v=u.default.useRef(null),y=u.default.useRef(null),b=u.default.useCallback(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=u.default.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=hR({value:r,level:a,minVersion:l,boostLevel:d,includeMargin:c,marginSize:f,imageSettings:p,size:i});u.default.useEffect(()=>{if(v.current!=null){let e=v.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=fR(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,gR?t.fill(new Path2D(dR(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),u.default.useEffect(()=>{S(!1)},[_]);let D=ZL({height:i,width:i},h),O=null;return _!=null&&(O=u.default.createElement(`img`,{src:_,key:_,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),u.default.createElement(u.default.Fragment,null,u.default.createElement(`canvas`,ZL({style:D,height:i,width:i,ref:b,role:`img`},g)),O)});_R.displayName=`QRCodeCanvas`;var vR=u.default.forwardRef(function(e,t){let n=e,{value:r,size:i=nR,level:a=rR,bgColor:o=iR,fgColor:s=aR,includeMargin:c=oR,minVersion:l=sR,boostLevel:d,title:f,marginSize:p,imageSettings:m}=n,h=QL(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:g,cells:_,numCells:v,calculatedImageSettings:y}=hR({value:r,level:a,minVersion:l,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:m,size:i}),b=_,x=null;m!=null&&y!=null&&(y.excavation!=null&&(b=fR(_,y.excavation)),x=u.default.createElement(`image`,{href:m.src,height:y.h,width:y.w,x:y.x+g,y:y.y+g,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=dR(b,g);return u.default.createElement(`svg`,ZL({height:i,width:i,viewBox:`0 0 ${v} ${v}`,ref:t,role:`img`},h),!!f&&u.default.createElement(`title`,null,f),u.default.createElement(`path`,{fill:o,d:`M0,0 h${v}v${v}H0z`,shapeRendering:`crispEdges`}),u.default.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});vR.displayName=`QRCodeSVG`;function yR({control:e,name:t,room:n}){let[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(!0);return(0,d.useEffect)(()=>{async function e(){try{i((await de({room:n,pageSize:1e3})).items),o(!1)}catch(e){console.error(`Error fetching locations:`,e)}}e()},[n]),a?(0,p.jsx)(`p`,{children:`Loading locations...`}):(0,p.jsxs)(H.Group,{className:`mb-3`,controlId:`chemical.roomSelect`,children:[(0,p.jsx)(H.Label,{children:`Select a storage location`}),(0,p.jsx)(vu,{name:t,control:e,defaultValue:``,render:({field:{onChange:e,value:t}})=>(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(Dl,{children:r.map(n=>(0,p.jsx)(Ur,{xs:4,md:3,className:`mb-3`,children:(0,p.jsx)(Pr,{onClick:()=>e(n.id.toString()),style:{cursor:`pointer`,border:t.toString()===n.id.toString()?`2px solid #007bff`:`1px solid #ddd`,borderRadius:`8px`},className:`h-100`,children:(0,p.jsxs)(Pr.Body,{children:[(0,p.jsx)(Pr.Title,{children:n.name}),(0,p.jsxs)(`div`,{className:`text-muted small mb-2 d-flex gap-2 justify-content-between`,children:[n.code&&(0,p.jsxs)(`div`,{children:[`Code: `,n.code]}),n.zone_group&&(0,p.jsxs)(`div`,{children:[`Zone group: `,n.zone_group.name]})]}),(0,p.jsxs)(`div`,{style:{textAlign:`center`,marginTop:`10px`},children:[(0,p.jsx)(vR,{value:`/l/`+n.id.toString(),size:128}),` `]})]})})},n.id))})})})]})}var bR=({show:e,setShow:t,onChemicalCreate:n})=>{let{register:r,control:i,setValue:a,handleSubmit:o,formState:{errors:s,isSubmitting:c}}=Ed({defaultValues:{}}),l=async e=>{try{let t=await f.default.post(`create/chemical`,e);t.data&&n(t.data)}finally{t(!1)}};return(0,p.jsx)(U,{show:e,size:`lg`,onHide:()=>t(!1),children:(0,p.jsxs)(H,{onSubmit:o(l),children:[(0,p.jsx)(U.Header,{closeButton:!0,children:(0,p.jsx)(U.Title,{children:`Create new chemical`})}),(0,p.jsxs)(U.Body,{children:[(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`CAS Number`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(H.Control,{as:`input`,...r(`cas_number`,{required:`A cas number is required`}),isInvalid:s.cas_number!==void 0}),s.cas_number&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.cas_number.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`Name`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(H.Control,{as:`input`,...r(`name`,{required:`A name is required`}),isInvalid:s.name!==void 0}),s.name&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.name.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`Description`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsx)(H.Control,{as:`textarea`,rows:3,...r(`description`)}),s.description&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.description.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`Standard product`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(H.Select,{...r(`standard_product`,{required:`A standard product is required`}),isInvalid:s.standard_product!==void 0,children:[(0,p.jsx)(`option`,{value:et.NON_STANDARD_PRODUCT,children:`Non standard product`}),(0,p.jsx)(`option`,{value:et.STANDARD_PRODUCT,children:`Standard product`})]}),s.standard_product&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.standard_product.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(`label`,{className:`col-sm-3 col-form-label text-end`,children:`Physical state`}),(0,p.jsxs)(`div`,{className:`col-sm-9`,children:[(0,p.jsxs)(H.Select,{...r(`physical_state`,{required:`A physical state is required`}),isInvalid:s.physical_state!==void 0,children:[(0,p.jsx)(`option`,{value:tt.SOLID,children:`Solid`}),(0,p.jsx)(`option`,{value:tt.LIQUID,children:`Liquid`}),(0,p.jsx)(`option`,{value:tt.GAS,children:`Gas`}),(0,p.jsx)(`option`,{value:tt.OTHER,children:`Other`})]}),s.physical_state&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:s.physical_state.message})]})]})]}),(0,p.jsx)(U.Footer,{children:(0,p.jsxs)(B,{variant:`primary`,disabled:c,onClick:()=>o(l)(),children:[c&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Create new chemical`]})})]})})};function xR({control:e,name:t,setValue:n,errors:r}){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(null),u=(e,t)=>{try{O({query:e}).then(e=>{let n=e.items.map(e=>({value:e.id,label:e.name+(e.cas_number?` (`+e.cas_number+`)`:``)})),r={...i};n.forEach(e=>{r[e.value]=e}),a(r),t(n)})}catch(e){console.error(`Error fetching chemicals:`,e)}},m=e=>e&&i[e]?i[e]:c||null;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Search Existing Chemicals`}),(0,p.jsxs)(Dl,{children:[(0,p.jsx)(vu,{name:t,control:e,render:({field:e})=>(0,p.jsx)(Vb,{isSearchable:!0,isClearable:!0,defaultOptions:!0,placeholder:`— Select a chemical, or start typing`,loadOptions:u,value:m(e.value),styles:Ub,onChange:t=>{l(null),e.onChange(t?.value)}})}),r.chemical&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:r.chemical.message}),(0,p.jsx)(`div`,{children:(0,p.jsx)(B,{variant:`primary`,className:`mt-2`,onClick:()=>s(!0),children:`Create New Chemical`})})]})]}),(0,p.jsx)(bR,{show:o,setShow:s,onChemicalCreate:async e=>{try{let r=await f.default.post(`create/chemical`,e),i={value:r.data.id,label:r.data.name+(r.data.cas_number?` (${r.data.cas_number})`:``)};a(e=>({...e,[i.value]:i})),l(i),s(!1),n(t,r.data.id)}catch(e){console.error(`Error creating chemical:`,e)}}})]})}function SR(e){return/\/l\/\d+$/.test(e)}function CR(e){let t=e.match(/\/l\/(\d+)$/);return t?parseInt(t[1],10):null}var wR=[{value:`g`,label:`Gram`},{value:`kg`,label:`Kilogram`},{value:`lb`,label:`US pound`},{value:`mc`,label:`Microgram`},{value:`mg`,label:`Milligram`},{value:`oz`,label:`Ounce`},{value:`to`,label:`Tonnes`},{value:`ton`,label:`US ton`},{value:`"3`,label:`Cubic inch`},{value:`ccm`,label:`Cubic centimeter`},{value:`cl`,label:`Centiliter`},{value:`dm3`,label:`Cubic decimeter`},{value:`foz`,label:`Fluid Ounce Us`},{value:`ft3`,label:`Cubic foot`},{value:`gal`,label:`US gallon`},{value:`hl`,label:`Hectoliter`},{value:`kit`,label:`Kit`},{value:`l`,label:`Liter`},{value:`m3`,label:`Cubic meter`},{value:`ml`,label:`Mililiter`},{value:`mm3`,label:`Cubic milimeter`},{value:`pc`,label:`Item`},{value:`pce`,label:`Piece`},{value:`pt`,label:`Pint, US liquid`},{value:`qt`,label:`Quart, US liquid`},{value:`yd3`,label:`Cubic Yard`},{value:`µl`,label:`Microliter`}].sort((e,t)=>e.label.localeCompare(t.label));function TR({room:e,barcode:t,resetForm:n,location:r,setLocation:i}){let{user:a}=(0,d.useContext)(v),{environment:o}=(0,g.useParams)(),[s,c]=(0,d.useState)(null),l=new Date;l.setFullYear(l.getFullYear()+5);let{register:u,control:m,handleSubmit:h,watch:_,setValue:y,formState:{errors:b,isSubmitting:x}}=Ed({defaultValues:{expire_date:l.toISOString().split(`T`)[0],owner:{value:a?.id,label:a?.full_name}}}),S=_(`location`);(0,d.useEffect)(()=>{S&&le({id:S}).then(e=>{i(e)})},[S]),(0,d.useEffect)(()=>{let e=``,t=t=>{if(!(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement)&&!(t.key.length>1&&t.key!==`Enter`))if(t.key===`Enter`){if(SR(e)){let t=CR(e);t!==null&&(le({id:t}).then(e=>{i(e)}),y(`location`,t))}e.startsWith(`reset-scan-location`)&&w(),e=``}else e+=t.key};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[y]);let C=async e=>{if(e.user=e.owner.value,(await E({qrCodeContent:t})).items.length>0){alert(`This barcode is already registered to a container`);return}let n=await f.default.post(`create/chemical/container`,e);c(n.data),await f.default.post(`create/chemical/container/external-label`,{container:n.data.id,qr_code_content:t})},w=()=>{i(null),y(`location`,0)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(H,{onSubmit:h(C),children:[!r&&(0,p.jsx)(yR,{room:e,control:m,name:`location`}),r&&(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Scanned location`}),(0,p.jsx)(Ur,{children:(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`span`,{className:`h1`,children:r.name}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(vR,{value:`reset-scan-location`,size:100,onClick:()=>w()}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset location`})]})]})})]}),r&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(xR,{control:m,errors:b,setValue:y,...u(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Wb,{control:m,...u(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Concentration`}),(0,p.jsxs)(Ps,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...u(`concentration`,{required:`An concentration is required`}),isInvalid:b.concentration!==void 0}),b.concentration&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:b.concentration.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Amount`}),(0,p.jsxs)(Ps,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...u(`amount`,{required:`An amount is required`}),isInvalid:b.amount!==void 0}),(0,p.jsx)(vu,{name:`amount_unit`,control:m,render:({field:e})=>(0,p.jsxs)(ls,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(ss.Item,{eventKey:``,children:`(no unit)`},0),wR.map(e=>(0,p.jsxs)(ss.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),b.amount&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:b.amount.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Expire date`}),(0,p.jsx)(H.Control,{type:`date`,...u(`expire_date`,{required:`An expire date is required`}),isInvalid:b.expire_date!==void 0}),b.expire_date&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:b.expire_date.message})]}),(0,p.jsxs)(B,{type:`submit`,variant:`primary`,disabled:x,children:[x&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Register container`]})]})]}),s&&(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(vr,{variant:`success`,children:`Container registered successfully`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${o}/chemical/container/details/${s.id}/general.html`,children:`Go to container`})}),(0,p.jsx)(vR,{value:`reset-form`,size:100,className:`float-end`,onClick:()=>n()})]})]})]})}function ER({control:e,errors:t}){let[n,r]=(0,d.useState)({}),i=(e,t)=>{try{D({query:e}).then(e=>{let i=e.items.map(e=>({value:e.id,label:e.name})),a={...n};i.forEach(e=>{a[e.value]=e}),r(a),t(i)})}catch(e){console.error(`Error fetching types:`,e)}},a=e=>n[e]||null;return(0,p.jsx)(vu,{name:`container_type`,control:e,render:({field:e})=>(0,p.jsx)(Vb,{isSearchable:!0,defaultOptions:!0,placeholder:`— Select a container type`,loadOptions:i,value:a(e.value),onChange:t=>{e.onChange(t?.value)},styles:Ub})})}function DR({room:e,resetForm:t,location:n,setLocation:r}){let{user:i}=(0,d.useContext)(v),{environment:a}=(0,g.useParams)(),[o,s]=(0,d.useState)(null),c=new Date;c.setFullYear(c.getFullYear()+5);let{register:l,control:u,handleSubmit:m,watch:h,setValue:_,formState:{errors:y,isSubmitting:b}}=Ed({defaultValues:{expire_date:c.toISOString().split(`T`)[0],owner:{value:i?.id,label:i?.full_name}}}),x=h(`location`);(0,d.useEffect)(()=>{x&&le({id:x}).then(e=>{r(e)})},[x]),(0,d.useEffect)(()=>{let e=``,t=t=>{if(!(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement)&&!(t.key.length>1&&t.key!==`Enter`))if(t.key===`Enter`){if(SR(e)){let t=CR(e);t!==null&&(le({id:t}).then(e=>{r(e)}),_(`location`,t))}e.startsWith(`reset-scan-location`)&&C(),e=``}else e+=t.key};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[_]);let S=async e=>{e.user=e.owner.value,s((await f.default.post(`create/chemical/container`,e)).data)},C=()=>{r(null),_(`location`,0)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(H,{onSubmit:m(S),children:[!n&&(0,p.jsx)(yR,{room:e,control:u,name:`location`}),n&&(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Scanned location`}),(0,p.jsx)(Ur,{children:(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(`span`,{className:`h1`,children:n.name}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(vR,{value:`reset-scan-location`,size:100,onClick:()=>C()}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset location`})]})]})})]}),n&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(xR,{control:u,errors:y,setValue:_,...l(`chemical`,{required:`Chemical is required`})}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Owner`}),(0,p.jsx)(Wb,{control:u,...l(`owner`,{required:`Owner is required`}),name:`owner`})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Concentration`}),(0,p.jsxs)(Ps,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...l(`concentration`,{required:`An concentration is required`}),isInvalid:y.concentration!==void 0}),y.concentration&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:y.concentration.message})]})]}),(0,p.jsxs)(H.Group,{className:`mb-3`,children:[(0,p.jsx)(H.Label,{children:`Amount`}),(0,p.jsxs)(Ps,{className:`mb-3 w-25`,hasValidation:!0,children:[(0,p.jsx)(H.Control,{as:`input`,...l(`amount`,{required:`An amount is required`}),isInvalid:y.amount!==void 0}),(0,p.jsx)(vu,{name:`amount_unit`,control:u,render:({field:e})=>(0,p.jsxs)(ls,{id:`input-group-dropdown-1`,title:e.value||`(no unit)`,onSelect:t=>e.onChange(t),children:[(0,p.jsx)(ss.Item,{eventKey:``,children:`(no unit)`},0),wR.map(e=>(0,p.jsxs)(ss.Item,{eventKey:e.value,children:[e.label,` (`,e.value,`)`]},e.value))]})}),y.amount&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:y.amount.message})]})]}),(0,p.jsxs)(Ps,{hasValidation:!0,className:`mb-3 row`,children:[(0,p.jsx)(H.Label,{children:`Container type`}),(0,p.jsx)(ER,{control:u,...l(`container_type`,{required:`Container type is required`}),errors:y}),y.container_type&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:y.container_type.message})]}),(0,p.jsxs)(H.Group,{className:`mb-3 w-50 w-25-sm`,children:[(0,p.jsx)(H.Label,{children:`Expire date`}),(0,p.jsx)(H.Control,{type:`date`,...l(`expire_date`,{required:`An expire date is required`}),isInvalid:y.expire_date!==void 0}),y.expire_date&&(0,p.jsx)(H.Control.Feedback,{type:`invalid`,children:y.expire_date.message})]}),(0,p.jsxs)(B,{type:`submit`,variant:`primary`,disabled:b,children:[b&&(0,p.jsx)(`span`,{className:`spinner-border spinner-border-sm me-1`}),`Register container`]})]})]}),o&&(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(vr,{variant:`success`,children:`Container registered successfully`}),(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-2`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${a}/chemical/container/render/single-${o.id}.pdf`,children:`Print label`})}),(0,p.jsx)(`div`,{children:(0,p.jsx)(`a`,{className:`btn btn-primary`,href:`${a}/chemical/container/details/${o.id}/general.html`,children:`Go to container`})}),(0,p.jsx)(vR,{value:`reset-form`,size:100,className:`float-end`,onClick:()=>t()})]})]})]})}function OR(){let{environment:e}=(0,g.useParams)(),[t,n]=(0,d.useState)(null),[r,i]=(0,d.useState)([]),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(!1),[f,m]=(0,d.useState)(null),[h,_]=(0,d.useState)(null),{control:v,watch:y,reset:b,setValue:x}=Ed({defaultValues:{room:f,barcode:``}}),S=y(`room`);(0,d.useEffect)(()=>{S&&(m(S),u(S.building.site.has_external_chemical_labelling))},[S]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`);e&&ue({id:parseInt(e)}).then(e=>{m(e),u(e.building.site.has_external_chemical_labelling),x(`room`,e)})},[x]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`location`);e&&le({id:parseInt(e)}).then(e=>{_(e),m(e.zone_group.room),u(e.zone_group.room.building.site.has_external_chemical_labelling),x(`room`,e.zone_group.room)})},[x]);let C=y(`barcode`);(0,d.useEffect)(()=>{let e=setTimeout(()=>{if(!C?.includes(`/l/`)){if(C?.includes(`/cc/`)){n(C);let e=C.split(`/cc/`)[1];T({id:parseInt(e)}).then(e=>{o(e)})}C&&(n(C),D({barcode:C}))}},1e3);return()=>{clearTimeout(e)}},[C,b]),(0,d.useEffect)(()=>{let e=``,t=t=>{t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement||t.key.length>1&&t.key!==`Enter`||(t.key===`Enter`?(e===`reset-form`&&w(),e=``):e+=t.key)};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[b]);let w=()=>{b({room:f,barcode:``}),n(null),_(null)};async function D({barcode:e}){try{let t=await E({qrCodeContent:e});t&&Array.isArray(t.items)&&t.items.length>0?(i(t.items),c(!1)):(c(!0),i([]))}catch(e){console.error(`Error fetching chemical container external labels`,e),i([]),c(!1)}}return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between`,children:[(0,p.jsx)(WL,{control:v,name:`room`}),(0,p.jsxs)(`div`,{className:`d-flex flex-column`,children:[(0,p.jsx)(vR,{value:`reset-form`,size:100,className:`float-end`,onClick:()=>w()}),(0,p.jsx)(`span`,{className:`text-muted`,children:`Reset form`})]})]}),f&&l&&(0,p.jsxs)(vr,{children:[`Lab `,f.name,` has external labels, each chemical material should have a material from the internal supplier/warehouse`]}),f&&!l&&(0,p.jsxs)(vr,{children:[`Lab `,f.name,` has no external labels, labels can be printed via the intake form`]}),f!==null&&!t&&l&&(0,p.jsx)(GL,{control:v}),t&&a&&(0,p.jsxs)(vr,{variant:`info d-flex flex-column gap-3`,children:[`This is already an own chemical material, this is `,a.chemical.name,` and should be stored on`,` `,a.location.name,` in `,a.location.zone_group.room.name,(0,p.jsx)(`a`,{className:`alert-link`,href:`${e}/chemical/container/details/${a.id}/general.html`,children:`Go to container`})]}),!a&&t&&(0,p.jsx)(p.Fragment,{children:r.length===0?(0,p.jsx)(vr,{variant:`info d-flex flex-column gap-3`,children:(0,p.jsxs)(`div`,{children:[`No chemical container external labels found with label `,(0,p.jsx)(`strong`,{children:t})]})}):(0,p.jsxs)(kl,{children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`ID`}),(0,p.jsx)(`th`,{children:`Label`}),(0,p.jsx)(`th`,{children:`Container`}),(0,p.jsx)(`th`,{children:`Location`})]})}),(0,p.jsx)(`tbody`,{children:r.map(t=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:t.id}),(0,p.jsx)(`td`,{children:t.label}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${e}/chemical/container/details/${t.container.id}/general.html`,children:t.container.chemical.name})}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`a`,{href:`/${e}/location/details/${t.container.location.id}/general.html`,children:t.container.location.name})})]},t.id))})]})}),!a&&s&&f&&t&&(0,p.jsx)(TR,{room:f,barcode:t,location:h,setLocation:_,resetForm:w}),!a&&f&&!l&&(0,p.jsx)(DR,{room:f,location:h,setLocation:_,resetForm:w})]})}function kR({badge_uuid:e}){return(0,p.jsxs)(`span`,{className:`rounded p-2 bg-success`,children:[`Card read: `,e]})}function AR({user_id:e}){let[t,n]=(0,d.useState)(``);return(0,d.useEffect)(()=>{let t=`https://`+NR+`/api/onelab/view/user/${e}`;(async()=>{try{let e=await fetch(t);if(!e.ok)throw Error(`Response status: ${e.status} with body: ${await e.text()}`);n((await e.json()).full_name)}catch(e){console.log(e)}})()},[]),(0,p.jsxs)(`span`,{className:`rounded p-2 bg-success`,children:[`Clients has detected user: `,t||`loading...`]})}function jR(){return(0,p.jsx)(`div`,{})}var MR=[`all`,`equipment`,`not_set`],NR=document.getElementById(`root`)?.dataset.goldsteinEndpoint??``,PR=`mock-token`,FR=10,IR=15;async function LR(e){let t=`https://`+NR+`/api/update/client-association`,n=prompt(`Select the new association for the client:`,e);if(n===null){alert(`Please enter a not null value`);return}let[r,i]=n.split(`:`),a=Number(i);if(!r||isNaN(a)||a===0){alert(`Please follow the correct format: $item:$id`);return}if(!MR.slice(1).includes(r)){alert(`Please select a valid $item: (equipment, not_set)`);return}let o=await fetch(t,{method:`PATCH`,body:JSON.stringify({previous_association:e,new_association:n}),headers:{"Content-type":`application/json; charset=UTF-8`}});if(!o.ok)throw Error(`Response status: ${o.status} with body: ${await o.text()}`);let s=await o.text();alert(s)}function RR(){let e=(0,d.useRef)(null),[t,n]=(0,d.useState)(new Map);async function r(e){n(Av(e.notifications_list,new Date,FR,IR))}function i(){let t=`
|
|
37
37
|
SELECT * FROM notifications
|
|
38
38
|
${s===`all`?``:`WHERE association_item = "${s}"`}
|
|
39
39
|
`.trim(),n={listening_association:`${s}:*`,sql_statement:t},r={package_type:Cv.UPDATE_LISTENING_DATA,payload:JSON.stringify(n)};Ev(e.current,r),r={package_type:Cv.GET_DATA,payload:``},Ev(e.current,r)}let a=()=>{setTimeout(()=>{(e.current===null||e.current.readyState===WebSocket.CLOSED||e.current.readyState===WebSocket.CLOSING)&&o()},1e3)},o=()=>{Ov(`wss://`+NR+`/ws`,PR).then(t=>{e.current!==null&&e.current.close(),t.onmessage=e=>{Dv(e,r)},t.onclose=()=>{console.log(`WebSocket closed`),a()},t.onerror=e=>{console.error(`WebSocket error`,e),a()},e.current=t,console.log(`WebSocket connected`),i(),Ev(t,{package_type:Cv.GET_DATA,payload:``})}).catch(e=>{console.error(`WebSocket connection failed`,e),a()})};(0,d.useEffect)(()=>(o(),()=>{e.current&&(e.current.close(),console.log(`Web socket disconnected`))}),[]);let[s,c]=(0,d.useState)(MR[0]);return(0,d.useEffect)(()=>{i()},[s]),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h1`,{children:`Goldstein Clients`}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`typeFilter`,children:`Filter by type:`}),(0,p.jsx)(`select`,{className:`form-control`,id:`typeFilter`,value:s,onChange:e=>c(e.target.value),children:MR.map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))})]}),(0,p.jsxs)(kl,{size:`sm`,striped:!0,bordered:!0,hover:!0,children:[(0,p.jsx)(`thead`,{children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{children:`Client`}),(0,p.jsx)(`th`,{children:`Status`}),(0,p.jsx)(`th`,{children:`Actions`})]})}),(0,p.jsx)(`tbody`,{children:Array.from(t.entries()).map(([e,t])=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{children:e}),(0,p.jsxs)(`td`,{children:[t.status===kv.CLIENT_CONNECTED&&(0,p.jsx)(jR,{}),t.status===kv.CARD_READED&&(0,p.jsx)(kR,{badge_uuid:t.message.badgeUUID}),t.status===kv.USER_AUTHENTICATED&&(0,p.jsx)(AR,{user_id:t.message.userID})]}),(0,p.jsx)(`td`,{children:(0,p.jsx)(`button`,{className:`btn btn-primary`,onClick:()=>LR(e),children:`Edit association`})})]},e))})]})]})}function zR({result:e,status:t,onAutoSave:n,onDirty:r}){let{control:i,formState:a}=bu(),o=e.criterion_version,s=String(e.id),c=o.criterion.background_color&&o.criterion.has_background_color?{backgroundColor:o.criterion.background_color}:void 0,l=a.errors[s]?.message,u=o.required,d=e=>u?Array.isArray(e)?e.length>0||`This field is required.`:typeof e==`boolean`||e!=null&&e!==``?!0:`This field is required.`:!0,f=l?`is-invalid`:t?.state===`saved`?`is-valid`:t?.state===`dirty`?`border-warning`:``,m=l?`border border-danger rounded p-2`:t?.state===`saved`?`border border-success rounded p-2`:t?.state===`dirty`?`border border-warning rounded p-2`:``,h=e=>typeof e==`string`?e:``,g=o.criterion.values??{};return(0,p.jsxs)(`div`,{className:`form-group mb-3 rounded ${o.highlighted?`border border-warning`:``}`,style:c,children:[(0,p.jsxs)(`label`,{htmlFor:`result-${e.id}`,className:`form-label`,children:[o.criterion.criterion,o.required&&(0,p.jsx)(`span`,{className:`text-danger`,children:`*`})]}),(0,p.jsx)(vu,{name:s,control:i,rules:{validate:d},render:({field:t})=>{switch(o.criterion.input_type){case`integer`:case`float`:return(0,p.jsx)(`input`,{id:`result-${e.id}`,type:`number`,step:o.criterion.input_type===`float`?`0.01`:`1`,className:`form-control ${f}`,value:h(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`date`:return(0,p.jsx)(`input`,{id:`result-${e.id}`,type:`date`,className:`form-control ${f}`,value:h(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`text`:return(0,p.jsx)(`textarea`,{id:`result-${e.id}`,className:`form-control ${f}`,rows:3,value:h(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`string`:return(0,p.jsx)(`input`,{id:`result-${e.id}`,type:`text`,className:`form-control ${f}`,value:h(t.value),onChange:n=>{t.onChange(n.target.value),r(e.id)},onBlur:()=>{t.onBlur(),n(e)}});case`select`:return(0,p.jsxs)(`select`,{id:`result-${e.id}`,className:`form-select ${f}`,value:h(t.value),onChange:i=>{t.onChange(i.target.value),r(e.id),n(e)},children:[(0,p.jsx)(`option`,{value:``,children:`-- select --`}),Object.entries(g).map(([e,t])=>(0,p.jsx)(`option`,{value:e,children:t},e))]});case`radio`:{let i=String(t.value??``);return(0,p.jsx)(`div`,{className:`form-check ${m}`,children:Object.entries(g).map(([a,o])=>(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`radio`,id:`result-${e.id}_${a}`,name:`result-${e.id}`,value:a,checked:i===a,onChange:i=>{t.onChange(i.target.value),r(e.id),n(e)},className:`form-check-input ${f}`}),(0,p.jsx)(`label`,{htmlFor:`result-${e.id}_${a}`,className:`form-check-label`,children:o})]},a))})}case`checkbox`:{let i=Array.isArray(t.value)?t.value:[],a=(a,o)=>{let s=o?[...i,a]:i.filter(e=>e!==a);t.onChange(s),r(e.id),n(e)};return(0,p.jsx)(`div`,{className:`form-check ${m}`,children:Object.entries(g).map(([t,n])=>(0,p.jsxs)(`div`,{className:`form-check`,children:[(0,p.jsx)(`input`,{type:`checkbox`,id:`result-${e.id}_${t}`,name:`result-${e.id}`,value:t,checked:i.includes(t),onChange:e=>a(t,e.target.checked),className:`form-check-input ${f}`}),(0,p.jsx)(`label`,{htmlFor:`result-${e.id}_${t}`,className:`form-check-label`,children:n})]},t))})}case`bool`:return(0,p.jsx)(`div`,{className:`form-check form-switch ${m}`,children:(0,p.jsx)(`input`,{type:`checkbox`,id:`result-${e.id}`,checked:!!t.value,onChange:i=>{t.onChange(i.target.checked),r(e.id),n(e)},className:`form-check-input ${f}`})});case`action`:return(0,p.jsxs)(`div`,{className:`d-flex align-items-center ${m}`,children:[(0,p.jsx)(`label`,{className:`me-2`,children:`Done `}),(0,p.jsxs)(`div`,{role:`group`,"aria-label":`${e.id}-action`,className:`btn-group btn-group-sm`,children:[(0,p.jsx)(`button`,{type:`button`,className:`btn ${t.value?`btn-primary`:`btn-outline-secondary`}`,onClick:()=>{t.onChange(!0),r(e.id),n(e)},"aria-pressed":!!t.value,children:`Yes`}),(0,p.jsx)(`button`,{type:`button`,className:`btn ${t.value?`btn-outline-secondary`:`btn-primary`}`,onClick:()=>{t.onChange(!1),r(e.id),n(e)},"aria-pressed":!t.value,children:`No`})]})]});default:return(0,p.jsx)(p.Fragment,{})}}}),o.criterion.help_block&&(0,p.jsx)(`small`,{className:`form-text text-muted`,children:o.criterion.help_block}),l&&(0,p.jsx)(`div`,{className:`invalid-feedback`,children:l})]})}function BR({categoryId:e,label:t,results:n}){let r=(0,d.useRef)({}),i=(0,d.useRef)({}),[a,o]=(0,d.useState)({}),s=(0,d.useCallback)(e=>{let t={},n=e=>e===null?null:String(e);return e.forEach(e=>{let r=e.criterion_version;if(r.criterion.input_type===`checkbox`){let n=e.value||r.default_value||``;t[String(e.id)]=n?n.toString().split(`, `):[]}else if(r.criterion.input_type===`bool`||r.criterion.input_type===`action`){let n=e.value??r.default_value??`false`;t[String(e.id)]=n===`true`}else{let i=e.value??r.default_value??``;t[String(e.id)]=n(i)??``}}),t},[]),c=Ed({defaultValues:(0,d.useMemo)(()=>s(n),[s,n]),mode:`onBlur`}),{control:l,getValues:u,reset:m,trigger:h}=c;(0,d.useEffect)(()=>{let t=String(e),i=r.current[t];if(i)m(i);else{let e=s(n);r.current[t]=e,m(e)}o({})},[s,e,m,n]);let g=gu({control:l});(0,d.useEffect)(()=>{let t=String(e);if(!g)return;let n=Object.entries(g);r.current[t]=n.reduce((e,[t,n])=>(e[t]=n??null,e),{})},[g,e]);let _=(0,d.useCallback)(async e=>{let t=String(e.id);if(!await h(t))return;let n=u(t),r=(i.current[e.id]??0)+1;i.current[e.id]=r,o(t=>({...t,[e.id]:{state:`saving`}}));let a=n??``;Array.isArray(n)?a=n.join(`, `):typeof n==`boolean`&&(a=n?`true`:`false`);try{await f.default.patch(`/update/service/event/report/result/${e.id}`,{value:a}),i.current[e.id]===r&&o(t=>({...t,[e.id]:{state:`saved`,savedAt:Date.now()}}))}catch(t){console.error(`Failed to save:`,t),i.current[e.id]===r&&o(t=>({...t,[e.id]:{state:`error`,message:`Save failed. Try again.`}}))}},[u,h]),v=(0,d.useCallback)(e=>{o(t=>({...t,[e]:{state:`dirty`}}))},[]),y=(0,d.useMemo)(()=>Object.values(a).some(e=>e.state===`dirty`||e.state===`saving`||e.state===`error`),[a]);return(0,d.useEffect)(()=>{let e=e=>{y&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[y]),(0,p.jsxs)(xu,{...c,children:[(0,p.jsx)(`legend`,{children:t}),n.map(e=>(0,p.jsx)(zR,{result:e,status:a[e.id],onAutoSave:_,onDirty:v},e.id))]})}function VR(){let{id:e}=(0,g.useParams)(),t=(0,g.useLocation)(),n=(0,g.useNavigate)(),[r,i]=(0,d.useState)(),[a,o]=(0,d.useState)({}),[s,c]=(0,d.useState)({}),[l,u]=(0,d.useState)(0),[f,m]=(0,d.useState)(null);(0,d.useEffect)(()=>{e&&(ze({id:Number(e)}).then(e=>{let t=e.reduce((e,t)=>{let n=t.criterion_version.type.category,r=String(n.id);return e[r]||(e[r]=[]),e[r].push(t),e},{}),n={},r={};e.forEach(e=>{let t=e.criterion_version.type.category,i=String(t.id);n[i]=t.category,r[i]=typeof t.sequence==`number`?t.sequence:2**53-1}),i(t),o(n),c(r)}),Be({id:Number(e)}).then(e=>m(e)).catch(()=>m(null)))},[e]);let h=(0,d.useMemo)(()=>r?Object.keys(r).sort((e,t)=>{let n=s[e]??2**53-1,r=s[t]??2**53-1;return n===r?Number(e)-Number(t):n-r}):[],[r,s]),_=h.length;return(0,d.useEffect)(()=>{if(!_)return;let e=new URLSearchParams(t.search).get(`category`);if(e){let t=h.indexOf(e);if(t!==-1){u(t);return}}u(0)},[_,t.search,h]),(0,d.useEffect)(()=>{if(!_)return;let e=h[l],r=new URLSearchParams(t.search);e&&r.get(`category`)!==e&&(r.set(`category`,e),n({pathname:t.pathname,search:r.toString()},{replace:!1}))},[l,_,h,t.pathname,t.search,n]),r?_===0?(0,p.jsx)(`div`,{children:`No categories found`}):(0,p.jsxs)(d.default.Fragment,{children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-center align-items-center gap-3 mb-3`,children:[(0,p.jsx)(`button`,{className:`btn btn-sm btn-outline-primary`,onClick:()=>{u(e=>Math.max(e-1,0))},disabled:l===0,children:`Previous`}),(0,p.jsxs)(`div`,{className:`text-center`,children:[`Category `,l+1,` of `,_]}),(0,p.jsx)(`button`,{className:`btn btn-outline-primary btn-sm`,onClick:()=>{u(e=>Math.min(e+1,_-1))},disabled:l===_-1,children:`Next`})]}),(0,p.jsx)(BR,{categoryId:h[l],label:a[h[l]],results:r[h[l]]})]}):(0,p.jsx)(`div`,{children:`Loading…`})}var HR={active:`text-bg-warning`,approved:`text-bg-success`,canceled:`text-bg-secondary`,cancelled:`text-bg-secondary`,completed:`text-bg-success`,done:`text-bg-success`,error:`text-bg-danger`,expired:`text-bg-secondary`,failed:`text-bg-danger`,pending:`text-bg-warning`,processing:`text-bg-warning`,queued:`text-bg-warning`,rejected:`text-bg-danger`,running:`text-bg-warning`,skipped:`text-bg-secondary`,started:`text-bg-warning`,success:`text-bg-success`,uploaded:`text-bg-success`};function UR(e){let t=e.trim().toLowerCase();return t in HR?HR[t]:/(fail|error|reject|invalid|deny)/.test(t)?`text-bg-danger`:/(complete|done|success|approve|upload|finish|ready|ok)/.test(t)?`text-bg-success`:/(run|process|progress|pending|queue|start|wait|active)/.test(t)?`text-bg-warning`:/(cancel|skip|expire|close|stop)/.test(t)?`text-bg-secondary`:`text-bg-info`}function WR(e){return e instanceof Map?Array.from(e.entries()):Array.isArray(e)?e.flatMap(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&typeof e[1]==`string`?[[e[0],e[1]]]:[]):typeof e==`object`&&e?Object.entries(e).flatMap(([e,t])=>typeof t==`string`?[[e,t]]:[]):[]}var GR={approve:{action:`approve`,buttonClassName:`btn-success`,label:`Approve`,successMessage:`Upload approved.`},fail:{action:`fail`,buttonClassName:`btn-outline-warning`,label:`Mark as failed`,successMessage:`Upload marked as failed.`},finish:{action:`finish`,buttonClassName:`btn-primary`,label:`Mark as finished`,successMessage:`Upload marked as finished.`},reject:{action:`reject`,buttonClassName:`btn-outline-danger`,label:`Reject`,successMessage:`Upload rejected.`}},KR={awaiting_approval:[`approve`,`reject`,`fail`],started:[`reject`,`fail`],syncing:[`fail`],uploading:[`finish`,`reject`,`fail`]};function qR(e){return(KR[e]??[]).map(e=>GR[e])}function JR(e){if(typeof e==`object`&&e&&`response`in e){let t=e.response;if(typeof t?.data?.message==`string`)return t.data.message}return e instanceof Error&&e.message!==``?e.message:`Could not process upload action.`}function YR({event:e,contentEntries:t,irisEndpoint:n,onEventUpdated:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(``),u=(0,d.useMemo)(()=>e?qR(e.state):[],[e]),f=(0,d.useCallback)(async t=>{if(e){a(t),s(``),l(``);try{let i={fileUploadEventUid:e.uid,irisServerUrl:n},a;a=t===`approve`?await Ze(i):t===`fail`?await Ye(i):t===`finish`?await Xe(i):await Qe(i);let o=u.find(e=>e.action===t);r(a),l(o?.successMessage??`Action completed.`)}catch(e){s(JR(e))}finally{a(null)}}},[u,e,n,r]);return(0,p.jsxs)(`div`,{className:`border rounded h-100`,children:[(0,p.jsxs)(`div`,{className:`border-bottom px-3 py-2`,children:[(0,p.jsx)(`div`,{className:`fw-semibold`,children:`Event details`}),(0,p.jsx)(`div`,{className:`small text-secondary`,children:`Inspect the current state and attached payload files`})]}),!e&&(0,p.jsx)(`div`,{className:`p-4 text-secondary`,children:`Choose an event to inspect its details.`}),e&&(0,p.jsxs)(`div`,{className:`p-3 p-lg-4`,children:[(0,p.jsxs)(`div`,{className:`d-flex flex-column flex-md-row justify-content-between gap-3 mb-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Event id`}),(0,p.jsx)(`code`,{className:`text-break`,children:e.uid})]}),(0,p.jsx)(`div`,{className:`d-flex align-items-start`,children:(0,p.jsx)(`span`,{className:`badge ${UR(e.state)}`,children:e.state})})]}),(0,p.jsxs)(`div`,{className:`row g-3 mb-4`,children:[(0,p.jsx)(`div`,{className:`col-md-6`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Context`}),(0,p.jsx)(`div`,{className:`fw-semibold text-break`,children:e.context})]})}),(0,p.jsx)(`div`,{className:`col-md-6`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Started`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:YP(e.start)})]})}),(0,p.jsx)(`div`,{className:`col-md-4`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Completed state`}),(0,p.jsx)(`div`,{className:`fw-semibold text-break`,children:e.completedState||`-`})]})}),(0,p.jsx)(`div`,{className:`col-md-4`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`TTL`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.TTL})]})}),(0,p.jsx)(`div`,{className:`col-md-4`,children:(0,p.jsxs)(`div`,{className:`rounded border p-3 h-100`,children:[(0,p.jsx)(`div`,{className:`small text-secondary text-uppercase fw-semibold mb-1`,children:`Auto approve`}),(0,p.jsx)(`div`,{className:`fw-semibold`,children:e.autoApprove?`Enabled`:`Disabled`})]})})]}),(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center mb-2 gap-2`,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`h6 mb-0`,children:`Actions`}),(0,p.jsx)(`div`,{className:`small text-secondary`,children:`State transition actions available for this event`})]})}),u.length===0&&(0,p.jsx)(`div`,{className:`rounded border p-3 text-secondary`,children:`No manual actions are available for this state.`}),u.length>0&&(0,p.jsx)(`div`,{className:`d-flex flex-wrap gap-2`,children:u.map(e=>(0,p.jsx)(`button`,{type:`button`,className:`btn btn-sm ${e.buttonClassName}`,disabled:i!==null,onClick:()=>f(e.action),children:i===e.action?`Processing...`:e.label},e.action))}),o!==``&&(0,p.jsx)(`div`,{className:`alert alert-danger py-2 mt-3 mb-0`,children:o}),c!==``&&(0,p.jsx)(`div`,{className:`alert alert-success py-2 mt-3 mb-0`,children:c})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`d-flex justify-content-between align-items-center mb-2 gap-2`,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`h6 mb-0`,children:`Attached files`}),(0,p.jsxs)(`div`,{className:`small text-secondary`,children:[t.length,` file entries available`]})]})}),t.length===0&&(0,p.jsx)(`div`,{className:`rounded border p-3 text-secondary`,children:`This event does not include attached files.`}),t.length>0&&(0,p.jsx)(`div`,{className:`vstack gap-3`,children:t.map(([e,t])=>(0,p.jsxs)(`div`,{className:`rounded border overflow-hidden`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-2 border-bottom d-flex justify-content-between align-items-center gap-2`,children:[(0,p.jsx)(`code`,{className:`text-break`,children:e}),(0,p.jsx)(`span`,{className:`badge border`,children:`attached`})]}),(0,p.jsx)(`pre`,{className:`m-0 p-3 bg-body-tertiary`,style:{maxHeight:220,overflow:`auto`},children:(0,p.jsx)(`code`,{children:t})})]},e))})]})]})]})}function XR({activeContext:e,events:t,selectedEventUid:n,onSelectEvent:r}){return(0,p.jsxs)(`div`,{className:`border rounded overflow-hidden h-100`,children:[(0,p.jsxs)(`div`,{className:`border-bottom px-3 py-2`,children:[(0,p.jsx)(`div`,{className:`fw-semibold`,children:`Incoming upload events`}),(0,p.jsx)(`div`,{className:`small text-secondary`,children:`Latest messages for the selected context`})]}),(0,p.jsxs)(`div`,{className:`list-group list-group-flush`,children:[t.map(e=>{let t=n===e.uid;return(0,p.jsxs)(`button`,{type:`button`,className:`list-group-item list-group-item-action text-start ${t?`active`:``}`,onClick:()=>r(e.uid),children:[(0,p.jsxs)(`div`,{className:`d-flex justify-content-between align-items-start gap-2 mb-2`,children:[(0,p.jsx)(`code`,{className:t?`text-white`:``,children:e.uid}),(0,p.jsx)(`span`,{className:`badge ${UR(e.state)}`,children:e.state})]}),(0,p.jsxs)(`div`,{className:`small ${t?`text-white-50`:`text-secondary`}`,children:[(0,p.jsxs)(`div`,{children:[`Context: `,e.context]}),(0,p.jsxs)(`div`,{children:[`Started: `,YP(e.start)]})]})]},e.uid)}),e!==``&&t.length===0&&(0,p.jsx)(`div`,{className:`list-group-item text-secondary`,children:`Listening for new events...`}),e===``&&(0,p.jsx)(`div`,{className:`list-group-item text-secondary`,children:`Select a context to start the live stream.`})]})]})}function ZR({irisEndpoint:e,context:t,onMessage:n,onError:r}){let i=(0,d.useRef)(null),a=(0,d.useRef)(null),o=(0,d.useRef)(!0),s=(0,d.useRef)(0),[c,l]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{if(!t)return;o.current=!0;let c=()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)},u=()=>{c();let d=qe({context:t,irisServerUrl:e.endsWith(`/`)?e:`${e}/`,onOpen:()=>{s.current=0,l(!0)},onEvent:e=>{n(e)},onError:e=>{if(l(!1),r(e),d.close(),!o.current)return;let t=Math.min(1e3*2**s.current,3e4);s.current+=1,a.current=window.setTimeout(()=>{u()},t)}});i.current=d,d.start()};return u(),()=>{o.current=!1,c(),i.current?.close(),i.current=null,l(!1)}},[e,t,n,r]),{isConnected:c,close:()=>{o.current=!1,a.current!==null&&(window.clearTimeout(a.current),a.current=null),i.current?.close(),i.current=null,l(!1)}}}function QR(){let[e,t]=(0,d.useState)(``),[n,r]=(0,d.useState)(``),[i,a]=(0,d.useState)([]),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(``),u=gt();(0,d.useEffect)(()=>{n&&Je({irisServerUrl:u,context:n}).then(e=>{a(e)})},[n]);let f=(0,d.useCallback)(e=>{n!==``&&e.context===n&&(l(``),a(t=>[e,...t.filter(t=>t.uid!==e.uid)]),s(e.uid))},[n]),{isConnected:m}=ZR({irisEndpoint:u,context:n,onMessage:f,onError:(0,d.useCallback)(e=>{if(n===``){l(``);return}if(e===null){l(``);return}l(`Error trying to connect to the server, reconnecting....`)},[n])}),h=(0,d.useCallback)(t=>{t.preventDefault(),r(e),a([]),s(``),l(``)},[e]),g=(0,d.useMemo)(()=>i.length===0?null:i.find(e=>e.uid===o)??i[0],[i,o]),_=(0,d.useMemo)(()=>g?WR(g.content):[],[g]);return(0,p.jsx)(`div`,{className:`w-100`,children:(0,p.jsx)(`div`,{className:`card shadow-sm border-0`,children:(0,p.jsxs)(`div`,{className:`card-body p-3 p-lg-4`,children:[(0,p.jsxs)(`form`,{onSubmit:h,className:`row g-2 align-items-end mb-4`,children:[(0,p.jsxs)(`div`,{className:`col-lg-8`,children:[(0,p.jsx)(`label`,{className:`form-label fw-semibold`,htmlFor:`iris-context-input`,children:`Context`}),(0,p.jsx)(`input`,{id:`iris-context-input`,className:`form-control`,type:`text`,value:e,placeholder:`lab-a`,onChange:e=>t(e.target.value)})]}),(0,p.jsx)(`div`,{className:`col-lg-4 col-xl-2`,children:(0,p.jsx)(`button`,{className:`btn btn-primary w-100`,type:`submit`,disabled:e.trim()===``,children:`Load context`})})]}),c!==``&&(0,p.jsx)(`div`,{className:`alert alert-danger py-2 mb-4`,children:c}),!m&&(0,p.jsx)(`div`,{className:`alert alert-warning py-2 mb-4`,children:`Could not connect to the server`}),m&&(0,p.jsxs)(`div`,{className:`row g-3`,children:[(0,p.jsx)(`div`,{className:`col-xl-5`,children:(0,p.jsx)(XR,{activeContext:n,events:i,selectedEventUid:g?.uid||``,onSelectEvent:s})}),(0,p.jsx)(`div`,{className:`col-xl-7`,children:(0,p.jsx)(YR,{event:g,contentEntries:_,irisEndpoint:u,onEventUpdated:f},g?.uid||``)})]},`${n}${i.length>0?i[0].uid:``}`)]})})})}var $R=function(e){return e.RunNotFound=`Run not found`,e}({});function ez({runsList:e,onFail:t=e=>null}){let[n,r]=(0,d.useState)(null),{lastlyReadedKeys:i}=AI();return(0,d.useEffect)(()=>{let n=i.replace(/_/g,`-`).toUpperCase(),a=e.find(e=>n.includes(e.label));if(!a){t($R.RunNotFound);return}FI({notificationHeader:`Run scanner`,notificationBody:`Run ${a.label} found`,notificationType:`success`}),r(a)},[i]),{selectedRun:n}}exports.AuthContext=v,exports.AuthProvider=wt,exports.BatchCardElement=tI,exports.ChemicalHeaderElement=UL,exports.ChemicalIntakeElement=OR,exports.DateFormat=eI,exports.EmphasizedParametersContext=aI,exports.EmphasizedParametersProvider=HL,exports.EquipmentContext=QP,exports.EquipmentDashboard=nF,exports.EquipmentHeaderElement=oF,exports.EquipmentProvider=iF,exports.GoldsteinClientsDashboard=RR,exports.GoldsteinEquipmentDashboard=ry,exports.InputModal=NL,exports.IrisOperatorDashboard=QR,exports.ModuleStatusElement=Dd,exports.MonitorCard=XP,exports.MonitorContext=JF,exports.MonitorHeaderElement=KF,exports.MonitorPage=GF,exports.MonitorProvider=YF,exports.NotificationProvider=II,exports.PaginationLinks=zF,exports.ReportResults=VR,exports.RunContext=ZF,exports.RunHeaderElement=iI,exports.RunInformationElement=oL,exports.RunProvider=QF,exports.RunStepChecklist=gL,exports.RunStepContext=$I,exports.RunStepExecuteElement=BL,exports.RunStepExecuteMinimal=VL,exports.RunStepHeaderElement=lL,exports.RunStepProvider=cL,exports.RunStepsElement=aL,exports.ScannerContext=kI,exports.ScannerProvider=zL,exports.SetupUpdateEquipment=yv,exports.StatusMailComponent=KP,exports.StatusMailContext=iy,exports.StatusMailProvider=sF,exports.StepDetails=JI,exports.initSolodbComponents=mt,exports.notification=FI,exports.useAuth=_t,exports.useScannerContext=AI,exports.useSelectRunWithScanner=ez;
|