PageSourceSearch

https://app.trainwel.com/static/js/36.28525234.chunk.js

js trainwel.com collected 2026-10-05 23:21:07 UTC 209,086 bytes, 2 lines download raw bytes

1/*! For license information please see 36.28525234.chunk.js.LICENSE.txt */
2(this.webpackJsonpstatstudio=this.webpackJsonpstatstudio||[]).push([[36,22,85],{1024:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var i=n(1),s=n(43);function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const[n,a]=Object(i.useState)(),[r,o]=Object(i.useState)(!0),[c,l]=Object(i.useState)(),d=async()=>{o(!0),l(!1);try{const n=await s.a.getQuizDetails(e,t);200===(null===n||void 0===n?void 0:n.status)?a(n.data):404===(null===n||void 0===n?void 0:n.status)?l("404: Quiz not found"):l("An error occurred loading this quiz")}catch(i){var n;const e=null===i||void 0===i||null===(n=i.response)||void 0===n?void 0:n.status;l(404===e?"404: Quiz not found":"An error occurred loading this quiz")}finally{o(!1)}};return{quiz:n,loading:r,error:c,fetchQuizDetails:d}}},1025:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var i=n(1),s=n(68),a=n(31),r=n(212),o=n(43),c=n(3);function l(e){let{quizId:t,onDeleteCallback:n,quizTitle:l,filledIcon:d}=e;const[u,h]=Object(i.useState)(!1),[m,b]=Object(i.useState)(!1),p=()=>h(!1);return Object(c.jsxs)(c.Fragment,{children:[Object(c.jsx)(s.a,{className:d?"btn-sm btn-danger p-1":"btn-outline-danger",size:"sm",onClick:()=>h(!0),title:"Delete","aria-label":"Delete","data-testid":"delete-quiz-modal-delete-icon-button",children:d?Object(c.jsx)("i",{className:"feather icon-trash-2"}):Object(c.jsx)(r.i,{})}),Object(c.jsxs)(a.a,{backdrop:"static",enforceFocus:!1,show:u,onHide:p,"data-testid":"delete-quiz-modal",children:[Object(c.jsx)(a.a.Header,{closeButton:!0,children:Object(c.jsx)(a.a.Title,{children:"Confirm Delete"})}),Object(c.jsxs)(a.a.Body,{children:[Object(c.jsxs)("p",{children:["Are you sure you want to delete ",l?`"${l}"`:"this quiz","?"]}),Object(c.jsx)("p",{className:"text-danger font-weight-bold",children:"This action cannot be undone."})]}),Object(c.jsxs)(a.a.Footer,{children:[Object(c.jsx)(s.a,{variant:"danger",onClick:async()=>{b(!0);await o.a.deleteQuiz(t)&&("function"===typeof n&&n(),p()),b(!1)},disabled:m,"data-testid":"delete-quiz-modal-delete-button",children:m?"Deleting...":"Delete"}),Object(c.jsx)(s.a,{variant:"secondary",onClick:p,disabled:m,"data-testid":"delete-quiz-modal-close-button",children:"Close"})]})]})]})}},1026:function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));n(1);var i=n(837),s=n(1027),a=n(19),r=n(29),o=n(34),c=n(900),l=n(41),d=n(3);function u(e){var t,n,u,h,m;let{article:b,showDownloadPdf:p=!0,showCopyLink:j=!0,showEditButton:f=!0}=e;const{user:g}=Object(a.d)((e=>({user:e.account.user,user_is_kb_admin:e.account.user.user_roles.user_is_kb_admin,wait_to_acknowledge_article:e.account.user.company.wait_to_acknowledge_article}))),v=(null===g||void 0===g||null===(t=g.user_roles)||void 0===t?void 0:t.user_is_kb_admin)||(null===g||void 0===g||null===(n=g.user_roles)||void 0===n?void 0:n.user_is_kb_article_admin);return Object(d.jsxs)(i.a.Header,{className:"article-detail-card-header",children:[Object(d.jsxs)("h5",{className:"font-weight-bold",style:{fontSize:"20px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif'},"data-testid":"article-detail-title",children:[null===b||void 0===b?void 0:b.title," "]}),Object(d.jsxs)(d.Fragment,{children:[f&&v&&Object(d.jsx)(r.b,{to:`/knowledgebase/articles/${null===b||void 0===b?void 0:b.id}/edit`,className:"btn btn-primary btn-sm float-right printhide mr-0","data-testid":"article-detail-edit-button",children:"Edit"}),Object(d.jsxs)("div",{children:[Object(d.jsxs)("span",{"data-testid":"article-detail-author",children:[b.author," | "]}),Object(d.jsxs)("span",{"data-testid":"article-detail-published-on",children:[Object(o.s)(b.published_on)," | "]}),Object(d.jsxs)("span",{"data-testid":"article-detail-version",children:["Version ",b.version," | "]}),b.version>1&&b.last_edited_on&&Object(d.jsxs)("span",{"data-testid":"article-detail-last-updated",children:["Last updated: ",Object(o.s)(b.last_edited_on)," | "]}),j&&Object(d.jsx)(l.a,{title:"Click to copy the link to this article to your clipboard",children:Object(d.jsxs)("span",{className:"cursor-pointer printhide",onClick:o.f,"data-testid":"article-detail-copy-link-button",children:[Object(d.jsx)("i",{className:"fa fa-clone"})," |"]})}),p&&Object(d.jsx)(l.a,{title:"Click to save this as a PDF or print it.",children:Object(d.jsxs)("span",{className:"cursor-pointer printhide",onClick:()=>{const e=document.getElementById(`html-content-${null===b||void 0===b?void 0:b.id}-current`);e?Object(c.a)(b,e,null===b||void 0===b?void 0:b.title):alert("Content not found for PDF generation.")},"data-testid":"article-detail-download-pdf-button",children:[Object(d.jsx)(s.a,{})," |"]})}),(null===b||void 0===b||null===(u=b.type_info)||void 0===u?void 0:u.type)&&Object(d.jsxs)("span",{children:[Object(d.jsx)("span",{style:{color:null===b||void 0===b||null===(h=b.type_info)||void 0===h?void 0:h.color},"data-testid":"article-detail-type",children:null===b||void 0===b||null===(m=b.type_info)||void 0===m?void 0:m.type})," ","|"]})]})]})]})}},1027:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n(0);function s(e){return Object(i.a)({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",stroke:"#000",strokeWidth:"2",d:"M4.99787498,8.99999999 L4.99787498,0.999999992 L19.4999998,0.999999992 L22.9999998,4.50000005 L23,23 L4,23 M18,1 L18,6 L23,6 M3,12 L3.24999995,12 L4.49999995,12 
2C6.5,12 6.75,13.25 6.75,14 C6.75,14.75 6.5,16 4.49999995,16 L3.24999995,16 L3.24999995,18 L3,17.9999999 L3,12 Z M9.5,18 L9.5,12 C9.5,12 10.4473684,12 11.2052633,12 C12.3421053,12 13.5,12.5 13.5,15 C13.5,17.5 12.3421053,18 11.2052633,18 C10.4473684,18 9.5,18 9.5,18 Z M16.5,19 L16.5,12 L20.5,12 M16.5,15.5 L19.5,15.5"}}]})(e)}},1043:function(e,t,n){"use strict";n.d(t,"a",(function(){return b}));var i=n(1),s=n(68),a=n(19),r=n(41),o=n(65),c=n(914),l=n(3);function d(e){let{isCourseArticle:t,article:n,handleArticleAcknowledgement:r,handleCourseAcknowledgement:d}=e;const[u,h]=Object(i.useState)(n.article_answers),[m,b]=Object(i.useState)(""),[p,j]=Object(i.useState)(!1),[f,g]=Object(i.useState)(!1),[v,x]=Object(i.useState)(!1),[y,O]=Object(i.useState)(!1),{courseDetailItems:w}=Object(a.d)((e=>e.knowledgebaseReducer)),_=Object(c.a)(w),C=()=>{let e={};for(var t in null===u||void 0===u||u.map((t=>{const n=t.id;e={...e,[n]:!1}})),m)e={...e,[parseInt(t)]:m[t]};for(var t in e){if(!(u.find((e=>e.id===parseInt(t))).is_correct===e[t]))return j(!1),!1}return j(!0),!0};return Object(l.jsxs)("div",{"data-testid":"article-qaa-acknowledgement",children:[Object(l.jsx)("h6",{className:"font-weight-bold mb-3",children:"Answer the challenge below to acknowledge:"}),Object(l.jsx)("p",{"data-testid":"article-qaa-acknowledgement-question",children:n.acknowledgement_question}),Object(l.jsxs)(o.a,{children:[null===u||void 0===u?void 0:u.map((e=>{const{id:t,answer:n}=e;return Object(l.jsx)(o.a.Group,{className:"mb-3",controlId:t,children:Object(l.jsx)(o.a.Check,{type:"checkbox",label:n,name:t,onChange:e=>(e=>{const t=e.target.name,n=e.target.checked;b({...m,[t]:n}),g(!0)})(e)})},t)})),v&&!p&&Object(l.jsx)("p",{className:"text-danger","data-testid":"article-qaa-acknowledgement-incorrect-answer-message",children:"Incorrect answer(s) please try again"}),t?Object(l.jsx)(s.a,{variant:1==_?"success":"primary",className:"float-right mt-3",onClick:async()=>{if("function"!==typeof d)return;const e=C();if(x(!0),e){O(!0);await d("answer");O(!1)}},disabled:y||!f,"data-testid":"article-qaa-acknowledgement-finish-course-button",children:y?"Submitting":1==_?"Finish Course":"Acknowledge and go to Next"}):Object(l.jsx)(s.a,{variant:"primary",className:"float-right mt-3 mr-0",onClick:async()=>{if("function"!==typeof r)return;const e=C();if(x(!0),e){O(!0);await r("answer");O(!1)}},disabled:y||!f,"data-testid":"article-qaa-acknowledgement-acknowledge-button",children:y?"Submitting":"Acknowledge and Mark as Read"})]})]})}var u=n(943),h=n.n(u);function m(e){let{article:t,isCourseArticle:n,handleArticleAcknowledgement:r,handleCourseAcknowledgement:o}=e;const[c,d]=Object(i.useState)(!0),[u,m]=Object(i.useState)(!1),b=Object(i.useRef)({}
2),{courseDetailArticles:p,hasReadAllCourseArticles:j}=Object(a.d)((e=>e.knowledgebaseReducer)),f=(p||[]).filter((e=>!1===e.has_read)).length;return Object(l.jsxs)("div",{"data-testid":"article-signature-pad",children:[Object(l.jsx)("p",{children:null!==t&&void 0!==t&&t.title?`Enter your signature to acknowledge "${t.title}":`:"Enter your signature to acknowledge:"}),Object(l.jsx)(h.a,{ref:b,canvasProps:{width:300,height:150,className:"sigCanvas border border-secondary"},onBegin:()=>d(!1),onEnd:()=>d(!1)}),Object(l.jsxs)("div",{className:"mt-1",children:[Object(l.jsx)(s.a,{variant:"info",size:"sm",onClick:()=>{d(!0),b.current.clear()},"data-testid":"article-signature-pad-clear-button",children:"Clear"}),!n&&Object(l.jsx)("div",{children:Object(l.jsx)(s.a,{variant:"primary float-right mt-2 mr-0",onClick:async()=>{if("function"!==typeof r)return;m(!0);const e=b.current.getTrimmedCanvas().toDataURL("image/png");await r(e);m(!1)},disabled:c||u,"data-testid":"article-signature-pad-acknowledge-button",children:u?"Submitting":"Acknowledge and Mark as Read"})})]}),n&&Object(l.jsx)(s.a,{variant:1==f?"success":"primary",className:"float-right mt-3",onClick:async()=>{if("function"!==typeof o)return;m(!0);const e=b.current.getTrimmedCanvas().toDataURL("image/png");await o(e);m(!1)},disabled:c||u,"data-testid":"article-signature-pad-finish-course-button",children:u?"Submitting":1==f?"Finish Course":"Acknowledge and go to Next"})]})}function b(e){let{article:t,loading:n,hasError:o,articleTranscript:c,handleAcknowledgement:u,isSubmitting:h,isCourseArticle:b=!1,isLastCourseItem:p=!1,customButtonProps:j={}}=e;const f=Object(a.d)((e=>{var t,n;return null===(t=e.account.user)||void 0===t||null===(n=t.company)||void 0===n?void 0:n.wait_to_acknowledge_article})),g=t&&"boolean"===typeof t.wait_to_acknowledge_article?t.wait_to_acknowledge_article:f,[v,x]=Object(i.useState)(0),[y,O]=Object(i.useState)(!1),[w,_]=Object(i.useState)(0);Object(i.useEffect)((()=>{if(v>0){const e=setTimeout((()=>{x((e=>e-1))}),1e3);return()=>clearTimeout(e)}w>0&&0===v&&O(!0)}),[v,w]),Object(i.useEffect)((()=>{!t||t.has_read||n||o||!g?g||(O(!0),_(0),x(0)):((e=>{if(!e)return 0;if(Boolean(e.video_url||e.video_uploaded)){const e=5;_(e),x(e),setTimeout((()=>{var e,t;if(null!==c&&void 0!==c&&null!==(e=c.videoPlayerRef)&&void 0!==e&&null!==(t=e.current)&&void 0!==t&&t.getState){const e=c.videoPlayerRef.current.getState();if(e.player&&e.player.duration&&!isNaN(e.player.duration)){const t=Math.ceil(e.player.duration);return _(t),void x(t)}}const n=document.querySelector("video");if(n&&n.duration&&!isNaN(n.duration)){const e=Math.ceil(n.duration);_(e),x(e)}else{const e=5;_(e),x(e)}}),3e3)}else{const t=(e.body?e.body.replace(/<[^>]*>/g,""):"").split(/\s+/).filter((e=>e.length>0)).length,n=400,i=Math.max(t/n*60,5);_(Math.ceil(i)),x(Math.ceil(i))}})(t),O(!1))}),[t,n,o,g]);if(n||o||!t||t.has_read)return null;const C=Object(l.jsxs)("div",{className:"mb-2","data-testid":"article-acknowledgement-context",children:[Object(l.jsx)("small",{className:"text-muted d-block",children:"You're acknowledging:"}),Object(l.jsx)("h6",{className:"font-weight-bold mb-0",children:t.title})]});if(g&&!y)return Object(l.jsxs)("div",{className:"bg-light rounded p-3 clearfix",children:[C,Object(l.jsx)(r.a,{title:Boolean((null===t||void 0===t?void 0:t.video_url)||(null===t||void 0===t?void 0:t.video_uploaded))?"Please watch the video content completely before acknowledging.":"Please take time to read through the article content before acknowledging.",children:Object(l.jsx)(s.a,{variant:"primary",className:b?"float-right mt-3":"float-right mt-3 mr-0",disabled:!0,style:{cursor:"not-allowed"},"data-testid":"article-acknowledgement-timer-button",children:(()=>{const e=Boolean((null===t||void 0===t?void 0:t.video_url)||(null===t||void 0===t?void 0:t.video_uploaded)),n=(e=>{const t=Math.floor(e/60),n=e%60;return t>0?`${t}:${n.toString().padStart(2,"0")}`:`${n}`})(v);return e?`Watch Video to Acknowledge (${n})`:`Read Article to Acknowledge (${n})`})()})})]});if(y||!g){let e;if(t.acknowledgement_type)e=1===t.acknowledgement_type?Object(l.jsx)(m,{article:t,isCourseArt
2icle:b,handleArticleAcknowledgement:u,handleCourseAcknowledgement:b?u:void 0}):2===t.acknowledgement_type?Object(l.jsx)(d,{isCourseArticle:b,article:t,handleArticleAcknowledgement:u,handleCourseAcknowledgement:b?u:void 0}):Object(l.jsx)("p",{});else{const t=b?p?"Finish Course":"Acknowledge and go to Next":"Acknowledge and Mark as Read",n=b&&p?"success":"primary";e=Object(l.jsx)(s.a,{variant:n,className:b?"float-right mt-3":"float-right mt-3 mr-0",onClick:()=>u(""),disabled:h,...j,"data-testid":"article-acknowledgement-submit-button",children:h?"Submitting...":t})}return Object(l.jsxs)("div",{className:"bg-light rounded p-3 clearfix",children:[C,e]})}return null}},1046:function(e,t,n){"use strict";n.d(t,"a",(function(){return y}));var i=n(1),s=n(31),a=n(65),r=n(68),o=n(19),c=n(8),l=n(1024),d=n(43),u=n(383),h=n(137),m=n(972),b=n(914),p=n(332),j=n(923),f=n(1025),g=n(212),v=n(3);function x(e){let{quiz:t,onUpdateCallback:n}=e;const[a,o]=Object(i.useState)(!1),c=()=>o(!1);return Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)(r.a,{variant:"outline-primary",className:"mr-1",size:"sm",onClick:()=>o(!0),"data-testid":"update-quiz-modal-edit-icon-button",children:Object(v.jsx)(g.e,{})}),Object(v.jsxs)(s.a,{backdrop:"static",size:"lg",show:a,onHide:c,"data-testid":"update-quiz-modal",children:[Object(v.jsx)(s.a.Header,{closeButton:!0,children:Object(v.jsx)(s.a.Title,{children:"Edit Quiz"})}),Object(v.jsx)(s.a.Body,{children:Object(v.jsx)(j.g,{instance:t,callbackFunc:e=>{"function"===typeof n&&n(e),c()}})})]})]})}function y(e){var t;let{quizId:n,isCourseItem:g,courseSectionItemId:y=null,isLastCourseItemToBeRead:O,handleCourseQuizAcknowledgement:w,showEditModal:_=!1,onUpdateCallback:C,onDeleteCallback:N,showResponse:k=!0}=e;const{quiz:S,loading:E,error:I,fetchQuizDetails:T}=Object(l.a)(n,y),[q,A]=Object(i.useState)([]),[z,L]=Object(i.useState)({}),[$,P]=Object(i.useState)({}),[R,M]=Object(i.useState)(!1),[F,D]=Object(i.useState)({}),B=Object(o.d)((e=>e.account.user)),H="abcdefghijklmnopqrstuvwxyz".split("");Object(i.useEffect)((()=>{T()}),[n,y]),Object(i.useEffect)((()=>{L({}),P({}),D({}),M(!1)}),[n]),Object(i.useEffect)((()=>{if(S){let e={};null===S||void 0===S||S.questions.map((t=>{j.d.includes(t.type)||(e[t.id]=t.choices.filter((e=>e.is_correct)).map((e=>e.id)))})),A(e)}}),[S]),Object(i.useLayoutEffect)((()=>(document.querySelectorAll(".mce-content-body .tox-checklist>li").forEach(((e,t)=>{const i=`quiz=${n}-id=${t}-user=${B.id}`;e.id=i;"true"===localStorage.getItem(i)&&e.classList.add("tox-checklist--checked"),e.addEventListener("click",(()=>{e.classList.toggle("tox-checklist--checked"),localStorage.setItem(i,e.classList.contains("tox-checklist--checked"))}))})),()=>{document.querySelectorAll(".mce-content-body .tox-checklist>li").forEach((e=>{e.removeEventListener("click",(()=>{e.classList.toggle("tox-checklist--checked")}))}))})),[E]);const U=e=>{P((t=>{const n={...t};return delete n[e],n}))},G=(e,t)=>{L((n=>({...n,[t]:e}))),P(""===e?e=>({...e,[t]:"You must provide an answer"}):e=>{const n={...e};return delete n[t],n})},W=e=>{const t=e.target.checked,n=parseInt(e.target.dataset.question),i=parseInt(e.target.dataset.choice);U(n),L((e=>{const s={...e};if(t)if(s[n]){if(S.questions.find((e=>e.id===n)).type===j.e)return s[n]=[i],s;s[n].push(i)}else s[n]=[i];else s[n]=s[n].filter((e=>e!==i));return s}))},Q=()=>{let e={};Object.keys(z).forEach((t=>{const n=S.questions.find((e=>e.id===parseInt(t))).type;if([j.e,j.b].includes(n)){const i=q[t],s=z[t];if(n===j.b&&i.length>1){const n=s.filter((e=>i.includes(e))),a=s.filter((e=>!i.includes(e)));0===n.length&&a.length>0?e[t]="You only selected incorrect answers":n.length>0&&n.length<i.length&&a.length>0?e[t]="You selected some correct answers but also some incorrect ones":n.length>0&&n.length<i.length?e[t]="You selected some correct answers but missed others":n.length===i.length&&a.length>0&&(e[t]="You selected all correct answers but also some incorrect ones")}else if(i.length<s.length)e[t]="You selected too many answers";else if(i.length>s.length)e[t]="You did not select the correct answer";else{i.every((e=>s.includes(e)))||(e[t]="You selected the wrong answer")}}}));let t=[];S.questions.map((e=>{e.type!==j.a&&t.push(e.id)}
2));const n=Object.keys(z).map((e=>parseInt(e)));return t.filter((e=>!n.includes(e))).forEach((t=>{var n,i;const s=null===(n=S.questions.find((e=>e.id===parseInt(t))))||void 0===n?void 0:n.type;if(s===j.c)e[t]="You must provide an answer";else{if(s===j.f&&null!==(i=F[t])&&void 0!==i&&i.length)return;e[t]="You must select at least one answer"}})),P(e),0===Object.keys(e).length};return I?Object(v.jsx)("h5",{className:"font-weight-bold",children:I}):(console.log({quiz:S},null===S||void 0===S||null===(t=S.quiz_response)||void 0===t?void 0:t.files,F),Object(v.jsx)(v.Fragment,{children:E?Object(v.jsx)(m.a,{}):Object(v.jsxs)("div",{id:"mce",children:[Object(v.jsx)(s.a.Header,{closeButton:!g,className:"mb-4 ",children:Object(v.jsxs)(s.a.Title,{"data-testid":"quiz-details-title w-100 ",children:[S.title,!g&&Object(v.jsxs)("div",{className:"float-right ml-2",children:[_&&(null===S||void 0===S?void 0:S.id)&&Object(v.jsx)(x,{quiz:S,onUpdateCallback:()=>{T(),"function"===typeof C&&C()}}),Object(v.jsx)(f.a,{quizId:S.id,onDeleteCallback:N})]})]})}),Object(v.jsx)("p",{className:"text-bold",children:"Questions:"}),Object(v.jsx)("ul",{children:S.questions.map((e=>Object(v.jsx)("li",{children:e.type===j.a?Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("h5",{className:"font-weight-bold",children:"Instruction"}),Object(v.jsx)("div",{className:"mce-content-body",id:"mce",dangerouslySetInnerHTML:{__html:e.question},"data-testid":`quiz-details-instruction-question-${e.id}`}),Object(v.jsx)("hr",{})]}):e.type===j.c?Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("h5",{className:"font-weight-bold",children:"Open Text"}),Object(v.jsx)("div",{className:"mce-content-body",id:"mce",dangerouslySetInnerHTML:{__html:e.question},"data-testid":`quiz-details-open-text-question-${e.id}`}),k&&null!==S&&void 0!==S&&S.has_acknowledged&&null!==e&&void 0!==e&&e.response?Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("p",{className:"text-muted mt-1",children:"Your Response:"}),Object(v.jsx)(h.a,{value:e.response.text,onChange:()=>{},readOnly:!0,height:100,minHeight:100,enableAI:!1,simple:!0,"data-testid":`quiz-details-open-text-question-${e.id}-response`})]}):Object(v.jsx)(a.a.Group,{controlId:e.id,children:Object(v.jsx)(h.a,{value:z[e.id],onChange:t=>G(t,e.id),placeholder:"Enter your answer here...",height:100,minHeight:100,enableAI:!1,simple:!0,readOnly:(null===S||void 0===S?void 0:S.has_acknowledged)||!1,"data-testid":`quiz-details-open-text-question-${e.id}-response-editor`})}),$[e.id]&&Object(v.jsx)("p",{className:"text-danger",children:$[e.id]}),Object(v.jsx)("hr",{})]}):e.type===j.f?Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("h5",{className:"font-weight-bold",children:"Submission"}),Object(v.jsx)("div",{className:"mce-content-body",id:"mce",dangerouslySetInnerHTML:{__html:e.question},"data-testid":`quiz-details-submission-question-${e.id}`}),k&&null!==S&&void 0!==S&&S.has_acknowledged&&null!==e&&void 0!==e&&e.response?Object(v.jsxs)(v.Fragment,{children:[e.response.text&&Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("p",{className:"text-muted mt-1",children:"Your Text Response:"}),Object(v.jsx)(h.a,{value:e.response.text,onChange:()=>{},readOnly:!0,height:100,minHeight:100,enableAI:!1,simple:!0,"data-testid":`quiz-details-submission-question-${e.id}-response`})]}),k&&e.response.files&&e.response.files.length>0&&Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("p",{className:"text-muted mt-3",children:"Your Uploaded Files:"}),Object(v.jsx)(u.a,{uploadedFiles:e.response.files,setUploadedFiles:()=>{},callbackFunc:null,disableDelete:!0})]})]}):Object(v.jsxs)(a.a.Group,{controlId:e.id,children:[Object(v.jsx)(h.a,{value:z[e.id],onChange:t=>G(t,e.id),placeholder:"Enter your text response here (optional)...",height:100,minHeight:100,enableAI:!1,simple:!0,readOnly:(null===S||void 0===S?void 0:S.has_acknowledged)||!1}),Object(v.jsx)("div",{className:"mt-3",children:!(null!==S&&void 0!==S&&S.has_acknowledged)&&Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("p",{children:Object(v.jsx)("em",{children:"Upload a file (optional):"})}),Object(v.jsx)(p.a,{setVideo:t=>((e,t)=>{e&&e.length>0&&(D((n=>({...n,[t]:e}))),U(t),L((e=>({...e,[t]:e[t]||""}))))})(t,e.id),small:!0,allTypes:!0,initialFiles:F[e.id]||[]})]})})]}
2),$[e.id]&&Object(v.jsx)("p",{className:"text-danger",children:$[e.id]}),Object(v.jsx)("hr",{})]}):Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("h5",{className:"font-weight-bold",children:e.type===j.b?"Multiple Choice":"Single Choice"}),Object(v.jsx)("div",{className:"mce-content-body",id:"mce",dangerouslySetInnerHTML:{__html:e.question}}),k&&null!==S&&void 0!==S&&S.has_acknowledged&&null!==e&&void 0!==e&&e.response?Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("p",{className:"text-muted mt-1",children:"Choices:"}),Object(v.jsx)("div",{className:"mt-2",children:e.choices.map(((t,n)=>{const i=e.response.selected_choices.includes(t.id);return Object(v.jsxs)("li",{className:"d-flex",children:[Object(v.jsxs)("span",{className:"mr-2",children:[H[n]+")"," "]}),Object(v.jsx)("div",{className:"mr-2",dangerouslySetInnerHTML:{__html:t.text}}),i&&Object(v.jsx)("span",{className:"ml-2 text-primary",children:"(Chosen)"}),i&&t.is_correct&&Object(v.jsx)("span",{className:"ml-2 text-success",children:"(Correct)"}),i&&!t.is_correct&&Object(v.jsx)("span",{className:"ml-2 text-danger",children:"(Incorrect)"})]},t.id)}))})]}):Object(v.jsxs)(v.Fragment,{children:[e.type===j.b?Object(v.jsx)("p",{className:"text-muted mt-1",children:Object(v.jsx)("em",{children:"Select all that apply:"})}):Object(v.jsx)("p",{className:"text-muted mt-1",children:Object(v.jsx)("em",{children:"Select One Option:"})}),Object(v.jsx)("div",{className:"mt-2",children:e.choices.map(((t,n)=>{var i;return Object(v.jsxs)("li",{className:"d-flex",children:[!(null!==S&&void 0!==S&&S.has_acknowledged)&&Object(v.jsx)(a.a.Group,{controlId:t.id,children:Object(v.jsx)(a.a.Check,{className:" mr-1 mt-1",type:e.type===j.e?"radio":"checkbox",name:e.type===j.e?`${e.id}-choice`:t.id,"data-choice":t.id,"data-question":e.id,label:"",inline:!0,checked:(null===(i=z[e.id])||void 0===i?void 0:i.includes(t.id))||!1,onChange:W})}),Object(v.jsxs)("span",{className:"mr-2",children:[H[n]+")"," "]}),Object(v.jsx)("div",{className:"mr-2",dangerouslySetInnerHTML:{__html:t.text}})]},t.id)}))})]}),$[e.id]&&Object(v.jsx)("p",{className:"text-danger",children:$[e.id]}),Object(v.jsx)("hr",{})]})},e.id)))}),null!==S&&void 0!==S&&S.has_acknowledged?Object(v.jsx)(v.Fragment,{}):g&&Object(v.jsx)(r.a,{variant:O?"success":"primary",className:"float-right mt-3",size:"sm",onClick:async()=>{const e=S.questions.filter((e=>e.type!==j.a)).map((e=>e.id)),t=Object.keys(z).map((e=>parseInt(e)));if(e.some((e=>{const n=S.questions.find((t=>t.id===e));var i;return(null===n||void 0===n?void 0:n.type)===j.f?!t.includes(e)&&!(null!==(i=F[e])&&void 0!==i&&i.length):!t.includes(e)})))return void Q();if(!Q())return;M(!0);const i=await(async()=>{let e=[];Object.keys(z).forEach((t=>{const i=S.questions.find((e=>e.id===parseInt(t)));i.type===j.c?e.push({quiz:n,quiz_question:t,text:z[t],selected_choices:[],staff:null===B||void 0===B?void 0:B.id}):i.type===j.f?e.push({quiz:n,quiz_question:t,text:z[t],selected_choices:[],files:F[t]||[],staff:null===B||void 0===B?void 0:B.id}):e.push({quiz:n,quiz_question:t,selected_choices:z[t],text:"",staff:null===B||void 0===B?void 0:B.id})}));const t=await d.a.quizResponseBulkCreate({responses:e});return t&&{score:t.score,passed:t.passed,question_results:t.question_results}})();if(!i)return void M(!1);const s=i.passed,a=i.score;if(s){if(g){await w()&&await T()}else await(async()=>{await Object(b.d)(null===B||void 0===B?void 0:B.id,n)&&(c.b.success("Quiz completed successfully!"),await T())})();c.b.success(`Quiz passed! Score: ${Math.round(a)}%`)}else{var r,o;const e=null!==(r=null===S||void 0===S?void 0:S.passing_grade)&&void 0!==r?r:100,t=(i.question_results||[]).filter((e=>!e.correct)).length;if(c.b.warning(t?`Score: ${Math.round(a)}%. Pass mark is ${e}%. ${t} question(s) marked below \u2014 review and try again.`:`Score: ${Math.round(a)}%. Pass mark is ${e}%. Please try again.`),null!==(o=i.question_results)&&void 0!==o&&o.length){const e={};i.question_results.forEach((t=>{t.correct||(e[t.question_id]="This answer was incorrect \u2014 check all options that apply")})),P(e)}}M(!1)},disabled:R,"data-testid":"quiz-details-submit-button",children:R?"Submitting...":O?"Finis
2h Course":(()=>{var e;if(null===S||void 0===S||null===(e=S.questions)||void 0===e||!e.length)return"Submit";const t=S.questions.filter((e=>e.type===j.a)),n=S.questions.filter((e=>e.type!==j.a));return 0===n.length&&t.length>0?"Mark as Complete":1===n.length&&0===t.length?"Submit Answer":1===n.length&&t.length>0?"Submit Answer and Mark as Complete":n.length>1&&t.length>0?"Submit Answers and Mark as Complete":"Submit Answers"})()})]})}))}},1066:function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return s})),n.d(t,"c",(function(){return o}));const i="application/x-course-item",s=e=>`sec-${e}`,a="root",r=e=>{var t,n,i;return(null===e||void 0===e||null===(t=e.article)||void 0===t?void 0:t.title)||(null===e||void 0===e||null===(n=e.quiz)||void 0===n?void 0:n.title)||(null===e||void 0===e||null===(i=e.file_type)||void 0===i?void 0:i.name)||(null===e||void 0===e?void 0:e.title)||"Untitled"};function o(e){const t=Array.isArray(e)?e:[],n={[a]:{index:a,isFolder:!0,canMove:!1,canRename:!1,children:[],data:{kind:"root"}}};return t.forEach((e=>{const t=s(e.id),i=[];(e.section_items||[]).forEach(((t,s)=>{const a=`it-${e.id}-${s}`;n[a]={index:a,isFolder:!1,canMove:!0,canRename:!1,children:[],data:{kind:"item",id:t.id,type:t.type,title:r(t),raw:t}},i.push(a)})),n[t]={index:t,isFolder:!0,canMove:!0,canRename:!0,children:i,data:{kind:"section",id:e.id,title:e.title,raw:e}},n.root.children.push(t)})),n}},1072:function(e,t,n){"use strict";n.d(t,"a",(function(){return m}));var i=n(38),s=n(1),a=n(65),r=n(68),o=n(53),c=n(113),l=n(44),d=n(1078),u=n(41),h=n(3);function m(e){let{instance:t,handleCloseModal:n,callbackFunc:m}=e;const{user:b}=Object(l.d)((e=>e.account)),[p,j]=Object(s.useState)(""),f=o.f().shape({name:o.h().required("This field is required"),description:o.h(),is_company_file_type:o.c()}),g=async e=>{e.preventDefault();await c.a.deleteHRFileType(t.id);"function"===typeof m&&m({id:t.id,deleted:!0}),n()};return Object(h.jsx)(i.e,{validationSchema:f,initialValues:{name:(null===t||void 0===t?void 0:t.name)||"",description:(null===t||void 0===t?void 0:t.description)||"",is_company_file_type:(null===t||void 0===t?void 0:t.is_company_file_type)||!1},onSubmit:async(e,i)=>{const s=new FormData;let a;p&&s.append("template_slug",p),Object.keys(e).forEach((t=>{("template_file"===t&&e[t]||"template_slug"!==t)&&s.append(t,e[t])})),t?(s.append("id",t.id),a=await c.a.patchHRFileType(t.id,s)):a=await c.a.createHRFileType(s),a&&"function"===typeof m&&m(a),i.setSubmitting(!1),n()},children:e=>{let{errors:s,isSubmitting:o,values:c,setFieldValue:l}=e;return Object(h.jsxs)(i.d,{children:[Object(h.jsxs)("div",{className:"form-group",children:[Object(h.jsx)("label",{htmlFor:"name",children:"Type"}),Object(h.jsx)(i.b,{className:"form-control",name:"name",type:"text",placeholder:"Enter type name..."}),s.name&&Object(h.jsx)("span",{className:"text-danger",children:s.name})]}),Object(h.jsxs)("div",{className:"form-group",children:[Object(h.jsx)("label",{htmlFor:"desc",children:"Description"}),Object(h.jsx)(i.b,{className:"form-control",name:"description",component:"textarea",placeholder:"Enter description..."}),s.description&&Object(h.jsx)("span",{className:"text-danger",children:s.description})]}),Object(h.jsx)(u.a,{title:"If this is true this will only show for company files and not employee files",children:Object(h.jsxs)("div",{className:"form-group",children:[Object(h.jsxs)("div",{className:"d-flex align-items-center",children:["Employee File Type",Object(h.jsxs)("div",{className:"switch d-inline mx-1",children:[Object(h.jsx)(a.a.Control,{type:"checkbox",name:"is_company_file_type",id:"is_company_file_type_switch",checked:c.is_company_file_type,onChange:e=>l("is_company_file_type",e.target.checked)}),Object(h.jsx)(a.a.Label,{htmlFor:"is_company_file_type_switch",className:"cr"})]}),"Company File Type"]}),s.is_company_file_type&&Object(h.jsx)("div",{className:"text-danger mt-1",children:s.is_company_file_type})]})}),(null===t||void 0===t?void 0:t.id)&&Object(h.jsxs)("div",{className:"mb-3",children:[Object(h.jsx)("label",{className:"mr-2",children:"Turn Template Into An E-sign: "}),Object(h.jsx)(d.default,{setSlug:j,doc_id:null===t||void 0===t?void 0:t.id,doc_url:c.template_file,doc_name:c.name})]}
2),t&&Object(h.jsx)(r.a,{className:"btn-danger btn-sm mr-auto",onClick:g,children:"Delete"}),Object(h.jsx)(r.a,{type:"submit",className:"btn-sm float-right",disabled:o,children:o?"Saving....":"Save"}),Object(h.jsx)(r.a,{variant:"Secondary",className:"btn-sm text-dark float-right",onClick:n,children:"Close"})]})}})}},1073:function(e,t,n){},1074:function(e,t,n){},1078:function(e,t,n){"use strict";n.r(t);var i=n(1),s=n(929),a=n(113),r=n(68),o=n(837),c=n(31),l=n(45),d=n(3);t.default=e=>{let{callbackFunc:t,doc_id:n,doc_url:u,doc_name:h,btn_txt:m,className:b,onModalOpen:p,onModalClose:j}=e;const[f,g]=Object(i.useState)(null),{layoutType:v}=Object(i.useContext)(l.a).state,[x,y]=Object(i.useState)(!1);let O;O="I-9"===h?"https://www.uscis.gov/sites/default/files/document/forms/i-9.pdf":("W-4"===h||"W2"===h)&&"https://www.irs.gov/pub/irs-pdf/fw4.pdf";const w=n+h||void 0,_=h||"W-9 Test";Object(i.useEffect)((()=>{(async()=>{try{const e=await a.a.getHumeSignToken(w,O,_);console.log({response:e}),g(e.token)}catch(e){console.error("Error fetching token:",e)}})()}),[]);const C=async()=>{y(!1),"function"===typeof t&&await t(),"function"===typeof j&&await j()};return Object(d.jsxs)(d.Fragment,{children:[Object(d.jsx)(r.a,{variant:"primary",className:b||"btn-sm",onClick:async()=>{y(!0),"function"===typeof p&&await p()},children:m||"Prepare E-Sign"}),Object(d.jsxs)(c.a,{backdrop:"static",enforceFocus:!1,size:"xl",show:x,onHide:C,children:[Object(d.jsx)(c.a.Header,{closeButton:!0,children:Object(d.jsxs)(c.a.Title,{className:"w-100",children:["Prepare E-Sign",Object(d.jsx)(r.a,{className:"btn-sm float-right",onClick:C,children:"Save"})]})}),Object(d.jsx)(c.a.Body,{children:f&&Object(d.jsx)(o.a,{children:Object(d.jsx)(s.a,{token:f,withSendButton:!1,withUploadButton:!0,withSignYourselfButton:!1,autosave:!0,withDocumentsList:!0,fieldTypes:["text","signature","initials","date","number","image","checkbox","radio","select"],customCss:"dark"===v&&"#fields_list_container { color: #fff;}#title_container {color: #fff;}#documents_container {color: #fff;}#save_button {background-color: #04a9f5; border-radius: 0.25rem;}.btn {background-color: #04a9f5; border-color: #04a9f5; border-radius: 0.25rem; color: #fff;}.btn-outline {color: hsl(var(--bc) / var(--tw-text-opacity));}",onSave:async e=>{await a.a.patchHRFileType(n,{template_slug:e.slug})}})})})]})]})}},1086:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var i=n(1),s=n(68),a=n(31),r=n(41),o=n(1072),c=n(3);function l(e){let{callbackFunc:t,className:n,title:l}=e;const[d,u]=Object(i.useState)(!1),h=()=>u(!1);return Object(c.jsxs)(c.Fragment,{children:[Object(c.jsx)(r.a,{title:"Add New File type",children:Object(c.jsx)(s.a,{className:n?n+" btn-sm":"btn-icon mx-0 btn-sm",style:{height:42.8},type:"button",onClick:()=>u(!0),children:l||Object(c.jsx)("i",{className:"feather icon-plus fa-lg mx-0"})})}),d&&Object(c.jsxs)(a.a,{enforceFocus:!1,show:d,onHide:h,children:[Object(c.jsx)(a.a.Header,{closeButton:!0,children:Object(c.jsx)(a.a.Title,{children:"Add File Type"})}),Object(c.jsx)(a.a.Body,{children:Object(c.jsx)(o.a,{handleCloseModal:h,callbackFunc:async e=>{h(),"function"===typeof t&&t(e)}})})]})]})}},1087:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var i=n(1),s=n(68),a=n(31),r=n(41),o=n(1072),c=n(3);function l(e){let{instance:t,callbackFunc:n,clearButton:l,className:d,onModalOpen:u,onModalClose:h}=e;const[m,b]=Object(i.useState)(!1),p=async()=>("function"===typeof h&&await h(),b(!1)),j=async()=>{"function"===typeof u&&await u(),b(!0)};return Object(c.jsxs)(c.Fragment,{children:[l?Object(c.jsx)("i",{className:"feather icon-edit",style:{cursor:"pointer"},onClick:j}):Object(c.jsx)(r.a,{title:"Edit File type",children:Object(c.jsxs)(s.a,{className:d||"btn btn-sm btn-icon ml-1",type:"button",style:d?{}:{height:42.8},onClick:j,children:[" ",Object(c.jsx)("i",{className:"feather icon-edit"})]})}),Object(c.jsxs)(a.a,{enforceFocus:!1,show:m,onHide:p,children:[Object(c.jsx)(a.a.Header,{closeButton:!0,children:Object(c.jsxs)(a.a.Title,{children:["Edit File Type: ",null===t||void 0===t?void 0:t.type]})}),Object(c.jsx)(a.a.Body,{children:Object(c.jsx)(o.a,{instance:t,handleCloseModal:p,callbackFunc:async e=>{"function"===typeof n&&n(e),p()}})})]})]})}},1112:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var i=n(1),s=n(19),a=n(113),r=n(11),o=n(34);function c(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const[t,n]=Object(i.useState)(!1),[c,l]=Object(i.useState)(null),d=Object(s.c)(),{fileTypes:u}=Object(s.d)((e=>e.companyReducer)),h=e=>{d({type:r.xb,payload:e})},m=async()=>{n(!0);try{const t=e?await a.a.getAllCompanyFileTypes():await a.a.getEmployeeFileTypes();if(t){const e=Object(o.r)(t,"name");h(e)}}catch(c){l(c)}n(!1)};return{fileTypes:u,loading:t,error:c,fetchFileTypes:m,setFileTypes:h}}},1117:function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var i=n(1),s=n(870),a=n(869),r=n(65),o=n(68),c=n(136),l=n(3);function d(e){let{onSendMessage:t,chatHistory:n=[],isLoading:d=!1,placeholder:u="Ask me anything...",title:h="AI Assistant",showTitle:m=!0,maxHeight:b="400px",analysisData:p=null}=e;const[j,f]=Object(i.useState)("");return Object(l.jsxs)("div",{className:"ai-chat-component",children:[m&&Object(l.jsxs)("div",{className:"h-list-header text-center",children:[Object(l.jsx)("h6",{children:h}),p&&Object(l.jsx)("div",{className:"mt-2",children:Object(l.jsxs)("small",{className:"text-success",children:[Object(l.jsx)("i",{className:"feather icon-check-circle mr-1"}),"Analysis data available - Ask about trends, insights, or recommendations"]})})]}),Object(l.jsx)("div",{className:"h-list-body",children:Object(l.jsx)("div",{className:"main-chat-cont",children:Object(l.jsxs)("div",{className:"chat-history",style:{maxHeight:b,overflowY:"auto"},children:[0===n.length?Object(l.jsxs)("div",{className:"text-center text-muted p-4",children:[Object(l.jsx)(c.o,{size:24,className:"mb-2"}),Object(l.jsx)("p",{children:"Ask me anything!"})]}):Object(l.jsx)("div",{className:"main-friend-chat",children:n.map(((e,t)=>{const n="user"===e.role,i=n?"chat-menu-reply text-muted":"chat-menu-content";return Object(l.jsxs)(s.a,{className:"media chat-messages",children:[!n&&Object(l.jsx)("div",{className:"media-left photo-table",children:Object(l.jsx)(c.o,{size:24,className:"text-primary"})}),Object(l.jsxs)(s.a.Body,{className:i,children:[Object(l.jsx)("div",{className:"",children:Object(l.jsx)("p",{className:"chat-cont",children:"assistant"===e.role?Object(l.jsx)("div",{dangerouslySetInnerHTML:{__html:(a=e.content,a?a.replace(/^###\s+(.*?)$/gm,'<h5 class="mt-3 mb-2">$1</h5>').replace(/^##\s+(.*?)$/gm,'<h6 class="mt-3 mb-2">$1</h6>').replace(/^#\s+(.*?)$/gm,'<h4 class="mt-3 mb-2">$1</h4>').replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/^(\d+\.\s)/gm,"<br><strong>$1</strong>").replace(/^(\*\s)/gm,"<br>\u2022 ").replace(/^(-\s)/gm,"<br>\u2022 ").replace(/\n/g,"<br>"):"")}}):e.content})}),Object(l.jsx)("p",{className:"chat-time",children:e.timestamp?new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""})]})]},t);var a}))}),d&&Object(l.jsxs)("div",{className:"text-center p-3",children:[Object(l.jsx)(a.a,{animation:"border",size:"sm"}),Object(l.jsx)("span",{className:"ms-2",children:"AI is thinking..."})]})]})})}),Object(l.jsx)("div",{className:"h-list-footer",children:Object(l.jsx)(r.a,{onSubmit:e=>{e.preventDefault(),e.stopPropagation(),j.trim()&&!d&&(t(j.trim()),f(""))},children:Object(l.jsxs)("div",{className:"input-group",children:[Object(l.jsx)(r.a.Control,{type:"text",value:j,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),j.trim()&&!d&&(t(j.trim()),f("")))},placeholder:u,disabled:d,className:"h-send-chat"}),Object(l.jsx)(o.a,{type:"submit",disabled:!j.trim()||d,className:"btn-send",children:d?Object(l.jsx)(a.a,{animation:"border",size:"sm"}):Object(l.jsx)("i",{className:"feather icon-message-circle"})})]})})})]})}},1119:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}
2)),n.d(t,"e",(function(){return c})),n.d(t,"c",(function(){return l})),n.d(t,"d",(function(){return d})),n.d(t,"b",(function(){return u}));var i=n(1),s=n(1902),a=n(1897),r=(n(1073),n(3));class o{constructor(e,t){this.data=e,this.onChange=t,this.listeners=[],this._emitScheduled=!1}async getTreeItem(e){const t=this.data[e];return t?t.children?t:{...t,children:[]}:{index:e,children:[],isFolder:!1,canMove:!1,canRename:!1,data:{}}}async onChangeItemChildren(e,t){this.data[e]={...this.data[e],children:t||[]},this.listeners.forEach((t=>t([e]))),this._scheduleEmit()}async onRenameItem(e,t){const n=this.data[e.index];this.data[e.index]={...n,data:{...n.data,title:t}},this.listeners.forEach((t=>t([e.index]))),this._scheduleEmit()}onDidChangeTreeData(e){return this.listeners.push(e),{dispose:()=>this.listeners=this.listeners.filter((t=>t!==e))}}applyExternal(e){const t=[];new Set([...Object.keys(this.data),...Object.keys(e)]).forEach((n=>{n in e&&JSON.stringify(this.data[n])!==JSON.stringify(e[n])&&t.push(n)})),t.length&&(this.data=e,this.listeners.forEach((e=>e(t))))}_scheduleEmit(){this._emitScheduled||(this._emitScheduled=!0,Promise.resolve().then((()=>{this._emitScheduled=!1,this.onChange&&this.onChange(this.data)})))}}const c=e=>{let{children:t,containerProps:n}=e;return Object(r.jsx)("div",{...n,className:"shared-tree__children",children:t})},l=e=>{let{lineProps:t}=e;return Object(r.jsx)("div",{...t,className:"shared-tree__between-line"})},d=e=>{let{item:t,context:n}=e;return t.isFolder?Object(r.jsx)("span",{...n.arrowProps,className:"shared-tree__arrow",role:"button",onClick:e=>{e.stopPropagation(),n.toggleExpandedState()},children:Object(r.jsx)("i",{className:"feather "+(n.isExpanded?"icon-chevron-down":"icon-chevron-right")})}):Object(r.jsx)("span",{className:"shared-tree__arrow-spacer"})};function u(e){let{items:t,rootItem:n="root",treeId:u,renderRow:h,onItemsChange:m,getItemTitle:b=(e=>{var t,n;return null!==(t=null===e||void 0===e||null===(n=e.data)||void 0===n?void 0:n.title)&&void 0!==t?t:""}),canReparent:p=!0,canDragAndDrop:j=!0,canDropAt:f,expandedItems:g,treeRef:v,onExpandItem:x,onCollapseItem:y,renderItemsContainer:O=c,renderItemArrow:w=d,renderDragBetweenLine:_=l}=e;const C=Object(i.useRef)(m);Object(i.useEffect)((()=>{C.current=m}),[m]);const N=Object(i.useRef)(null),k=Object(i.useMemo)((()=>new o(JSON.parse(JSON.stringify(t)),(e=>{const t={...e};N.current=t,C.current&&C.current(t)}))),[]);Object(i.useEffect)((()=>{t!==N.current&&k.applyExternal(JSON.parse(JSON.stringify(t)))}),[t,k]);const S=Object(i.useMemo)((()=>({[u]:g?{expandedItems:g}:{}})),[u,g]);return Object(r.jsx)(s.a,{dataProvider:k,getItemTitle:b,viewState:S,canDragAndDrop:j,canReorderItems:!0,canDropOnFolder:p,canDropAt:f,canRename:!0,onExpandItem:x,onCollapseItem:y,renderItem:e=>{let{item:t,depth:n,children:i,arrow:s,context:a}=e;const o=["shared-tree__row",a.isDraggingOver&&"shared-tree__row--drag-over",a.isDraggingOver&&t.isFolder&&"shared-tree__row--drop-into"].filter(Boolean).join(" ");return Object(r.jsxs)("li",{...a.itemContainerWithChildrenProps,className:"shared-tree__item",children:[Object(r.jsx)("div",{...a.itemContainerWithoutChildrenProps,...a.interactiveElementProps,className:o,children:h({item:t,depth:n,arrow:s,context:a})}),i]})},renderItemArrow:w,renderItemsContainer:O,renderDragBetweenLine:_,children:Object(r.jsx)(a.a,{treeId:u,rootItem:n,ref:v})})}},1120:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));n(1);var i=n(837),s=n(915),a=n(964),r=(n(1074),n(1073),n(3));function o(e){let{title:t,actions:n=null,badgeColor:o=null,active:c=!1,dragging:l=!1,onClick:d=null,innerRef:u=null,containerProps:h={},className:m=""}=e;return Object(r.jsx)(i.a,{ref:u,...h,style:{opacity:l?.5:1,...h.style||{}},className:`section-article mb-3 shadow-sm tree-item-row ${c?"tree-item-row--active":""} ${m}`,children:Object(r.jsxs)("div",{className:"p-2 align-items-center d-flex",children:[Object(r.jsx)("div",{className:"drag-icon-container","aria-hidden":"true",children:Object(r.jsx)(a.a,{})}),Object(r.jsx)("span",{className:"pl-3 tree-item-row__title",style:d?{cursor:"pointer"}:void 0,onClick:d||void 0,children:t}),Object(r.jsxs)("div",{className:"ml-auto d-flex align-items-center",children:[n&&Object(r.jsx)("span",{className:"p-2 tree-item-row__actions d-flex align-items-center",children:n}),o&&Object(r.jsx)(s.a,{style:{backgroundColor:o},children:Object(r.jsx)("span",{className:"sr-only",children:"item type"})})]})]})})}},1121:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}
2));var i=n(1),s=n(43),a=n(998);const r=()=>({[a.c]:{index:a.c,isFolder:!0,canMove:!1,canRename:!1,children:[],data:{kind:"root"}}});function o(){const[e,t]=Object(i.useState)(r),[n,o]=Object(i.useState)(!0),[c,l]=Object(i.useState)([]),[d,u]=Object(i.useState)((()=>new Set)),h=Object(i.useRef)(e);Object(i.useEffect)((()=>{h.current=e}),[e]);const m=Object(i.useCallback)((async()=>{o(!0);const e=await s.a.getArticleCategories({simple:!0}),n=Array.isArray(e)?e:(null===e||void 0===e?void 0:e.results)||[];t(Object(a.d)(n,{})),u(new Set),o(!1)}),[]);Object(i.useEffect)((()=>{m()}),[m]);const b=Object(i.useCallback)((async e=>{const n=await s.a.getKBArticlesSimple({article_category:e,simple_details:!0,paginate:!1}),i=Array.isArray(n)?n:(null===n||void 0===n?void 0:n.results)||[];t((t=>function(e,t,n){const i=Object(a.b)(t),s=e[i];if(!s)return e;const r={...e},o=(s.children||[]).filter((e=>"category"===Object(a.f)(e)));(s.children||[]).filter((e=>"article"===Object(a.f)(e))).forEach((e=>delete r[e]));const c=[];return(n||[]).forEach((e=>{const t=Object(a.a)(e.id);r[t]={index:t,isFolder:!1,canMove:!0,canRename:!1,children:[],data:{kind:"article",id:e.id,title:e.title}},c.push(t)})),r[i]={...s,children:[...o,...c]},r}(t,e,i))),u((t=>new Set(t).add(e)))}),[]),p=Object(i.useCallback)((e=>{const t=e.index;if(l((e=>e.includes(t)?e:[...e,t])),"category"===Object(a.f)(t)){const e=Object(a.e)(t);d.has(e)||b(e)}}),[d,b]),j=Object(i.useCallback)((e=>{l((t=>t.filter((t=>t!==e.index))))}),[]);return{items:e,setItems:t,itemsRef:h,loadingTree:n,expandedKeys:c,setExpandedKeys:l,loadedCats:d,fetchTree:m,loadArticles:b,onExpandItem:p,onCollapseItem:j}}},1122:function(e,t,n){},1328:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(1),s=n(19),a=n(400);function r(){const{courseName:e,courseCategory:t,courseDescription:n,coursePriority:r,courseDivisions:o,courseIndividuals:c,courseSections:l,courseResponsibilities:d,coursePositions:u,courseIsAssignedToEveryone:h,courseHasCertificate:m,courseReassignDuration:b,courseReassignRepeats:p,courseReminderFrequencyDays:j,is_scorm_course:f,scorm_file_url:g}=Object(s.d)((e=>e.knowledgebaseReducer));return Object(i.useCallback)((function(){let{isCreate:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=[...l||[]];!i||1!==s.length||s[0].title&&""!==s[0].title.trim()||(s[0]={...s[0],title:e});const v=s.map(((e,t)=>({...e,order:t+1,section_items:(e.section_items||[]).map(((e,t)=>({...e,order:t+1})))}))),x={name:e,category:t,description:n,priority:parseInt(r),new_divisions:Object(a.b)(o),course_individuals:c,responsibilities:Object(a.b)(d),positions:Object(a.b)(u),is_assigned_to_everyone:h,has_certificate:m,reassign_month_duration:b,reassign_repeats:p,reminder_frequency_days:j,is_scorm_course:f,sections:v};return(i||f&&g)&&(x.scorm_file_url=g),x}),[e,t,n,r,o,c,l,d,u,h,m,b,p,j,f,g])}},1369:function(e,t,n){"use strict";n.d(t,"a",(function(){return $e}));var i=n(1),s=n(68),a=n(19),r=n(55),o=n(11),c=n(837),l=n(869),d=n(838),u=n(834),h=n(1897),m=n(1902),b=n(43);var p=n(1112),j=n(960),f=n(964),g=n(1120),v=n(1119),x=n(1121),y=n(998),O=n(1066),w=n(970);const _="course-root",C="art-root",N="quiz-root",k="file-root",S=e=>"string"===typeof e&&e.startsWith("sec-"),E=e=>"string"===typeof e&&e.startsWith("it-"),I=e=>"string"===typeof e&&e.startsWith("cat-"),T=e=>"string"===typeof e&&e.startsWith("art-"),q=e=>"string"===typeof e&&e.startsWith("quiz-"),A=e=>"string"===typeof e&&e.startsWith("file-");function z(e,t,n,i){let{kind:s,titleOf:a,canMove:r=(()=>!0)}=i;const o={[e]:{index:e,isFolder:!0,canMove:!1,canRename:!1,children:[],data:{kind:"root"}}};return(n||[]).forEach((n=>{const i=`${t}${n.id}`;o[i]={index:i,isFolder:!1,canMove:r(n),canRename:!1,children:[],data:{kind:s,id:n.id,title:a(n),raw:n}},o[e].children.push(i)})),o}function L(e,t){const n={};return Object.entries(e||{}).forEach((e=>{let[i,s]=e;"root"===i?n[t]={...s,index:t}:n[i]=s})),n[t]||(n[t]={index:t,isFolder:!0,canMove:!1,canRename:!1,children:[],data:{kind:"root"}}),n}function $(e){let{id:t,title:n,type:i}=e;const s={id:t,type:i};return w.d.forEach((e=>{s[e.itemKey]=i===e.type?{id:t,title:n,name:n}:null})),i===w.c&&(s.show_previous_answers=!0),s}function P(e,t){var n,i;const s=(null===t||void 0===t||null===(n=t[e])||void 0===n?void 0:n.data)||{};return T(e)?$({id:null!==(i=s.id)&&void 0!==i?i:Object(y.e)(e),title:s.title,type:w.a}):e.startsWith("quiz-")?$({id:s.id,title:s.title,type:w.c}):e.startsWith("file-")?$({id:s.id,title:s.title,type:w.b}):null}function R(e,t){if(!e)return null;var n,i;if("between-items"===e.targetType)return e.parentItem===_?{kind:"section-list",index:e.childIndex}:S(e.parentItem)?{kind:"into-section",sectionId:null===t||void 0===t||null===(n=t[e.parentItem])||void 0===n||null===(i=n.data)||void 0===i?void 0:i.id,index:e.childIndex}:null;const s=e.targetItem;if(s===_)return{kind:"section-list",index:null};if(S(s)){var a;const e=null===t||void 0===t?void 0:t[s];return{kind:"into-section",sectionId:null===e||void 0===e||null===(a=e.data)||void 0===a?void 0:a.id,index:((null===e||void 0===e?void 0:e.children)||[]).length}}return null}const M=(e,t)=>null==t?e.length:Math.max(0,Math.min(t,e.length)),F=e=>{const t=(e||[]).map((e=>Number(e.id))).filter((e=>!Number.isNaN(e)));return(t.length?Math.max(...t):0)+1},D=e=>e.map(((e,t)=>({...e,order:t+1})));
2var B=n(31),H=n(1046),U=n(3);function G(e){let{quizId:t,showIcon:n=!1,showEditModal:a=!1,onDeleteCallback:r,onUpdateCallback:o}=e;const[c,l]=Object(i.useState)(!1),h=()=>l(!1),m=()=>l(!0);return Object(U.jsxs)(U.Fragment,{children:[Object(U.jsx)(d.a,{placement:"bottom",overlay:Object(U.jsx)(u.a,{children:"View this quiz"}),children:n?Object(U.jsx)(s.a,{className:"p-1 ml-2 bg-transparent border-0 m-0",onClick:m,"data-testid":"quiz-details-modal-view-icon-button",children:Object(U.jsx)("i",{className:"feather icon-eye text-dark",onClick:m})}):Object(U.jsx)(s.a,{className:"btn-sm btn-light p-1 mr-1",onClick:m,"data-testid":"quiz-details-modal-view-button",children:"View"})}),Object(U.jsxs)(B.a,{backdrop:"static",enforceFocus:!1,size:"lg",show:c,onHide:h,"data-testid":"quiz-details-modal",children:[Object(U.jsx)(B.a.Body,{children:Object(U.jsx)(H.a,{quizId:t,isCourseItem:!1,showEditModal:a,onDeleteCallback:r,onUpdateCallback:o,showResponse:!1})}),Object(U.jsx)(B.a.Footer,{children:Object(U.jsx)(s.a,{variant:"secondary",size:"sm",onClick:h,"data-testid":"quiz-details-modal-close-button",children:"Close"})})]})]})}var W=n(550),Q=n(112),J=n(1024),Y=n(972),V=n(923);function K(e){let{quizId:t,onUpdateCallback:n}=e;const{quiz:s,loading:a,error:r,fetchQuizDetails:o}=Object(J.a)(t);return Object(i.useEffect)((()=>{o()}),[t]),r?Object(U.jsx)("h5",{className:"font-weight-bold",children:r}):Object(U.jsx)(U.Fragment,{children:a?Object(U.jsx)(Y.a,{}):Object(U.jsxs)(W.a,{children:[Object(U.jsx)(Q.a,{md:12,sm:12,children:Object(U.jsxs)("h5",{className:"font-weight-bold ",children:["Edit Quiz: ",s.title," "]})}),Object(U.jsx)(Q.a,{md:12,sm:12,children:Object(U.jsx)(V.g,{instance:s,callbackFunc:n})})]})})}function X(e){let{quizId:t,onUpdateCallback:n}=e;const[a,r]=Object(i.useState)(!1),o=()=>r(!1);return Object(U.jsxs)(U.Fragment,{children:[Object(U.jsx)(s.a,{className:"btn-sm p-1 mr-1",onClick:()=>r(!0),children:"Edit"}),Object(U.jsxs)(B.a,{backdrop:"static",enforceFocus:!1,size:"lg",show:a,onHide:o,children:[Object(U.jsx)(B.a.Header,{closeButton:!0,children:Object(U.jsx)(B.a.Title,{children:"Edit Quiz"})}),Object(U.jsx)(B.a.Body,{children:Object(U.jsx)(K,{quizId:t,onUpdateCallback:e=>{"function"===typeof n&&n(e),o()}})})]})]})}var Z=n(1025),ee=n(1023),te=n(65),ne=n(113);function ie(e){let{show:t,handleClose:n,onQuizCreated:r,formHasContent:o=!1}=e;const[c,d]=Object(i.useState)([]),[u,h]=Object(i.useState)([]),[m,p]=Object(i.useState)(2),[j,f]=Object(i.useState)(!1),[g,v]=Object(i.useState)(null),[x,y]=Object(i.useState)(!0),[O,w]=Object(i.useState)(!1),[_,C]=Object(i.useState)(3),{courseSections:N}=Object(a.d)((e=>e.knowledgebaseReducer)),[k,S]=Object(i.useState)(["SINGLE_CHOICE","MULTIPLE_CHOICE","OPEN_TEXT"]),[E,I]=Object(i.useState)(["INSTRUCTION","SUBMISSION"]),[T,q]=Object(i.useState)(!1),[A,z]=Object(i.useState)(["SINGLE_CHOICE","MULTIPLE_CHOICE","OPEN_TEXT"]);Object(i.useEffect)((()=>{if(N&&N.length>0){const e=[];N.forEach(((t,n)=>{t.section_items&&t.section_items.length>0&&t.section_items.forEach(((i,s)=>{i.article&&e.push({id:i.article.id,title:i.article.title,sectionId:t.id,sectionTitle:t.title,type:"article",body:i.article.body,transcript:i.article.transcript,sectionOrder:n,itemOrder:s})}))})),d(e)}}),[N,t]);const L=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"replace";if(console.log("[generateQuiz] selectedItems:",u),0!==u.length){f(!0),v(null);try{const t=u.map((async e=>await b.a.fetchArticle(e))),n=(await Promise.all(t)).filter((e=>e)).map((e=>{const t=document.createElement("div");t.innerHTML=e.body||"";t.querySelectorAll("img").forEach((e=>e.remove()));const n=t.textContent||t.innerText||"";let i="";if(e.transcript){const t=document.createElement("div");t.innerHTML=e.transcript;t.querySelectorAll("img").forEach((e=>e.remove())),i=t.textContent||t.innerText||""}return{title:e.title,body:n.trim(),transcript:i.trim()}}));if(0===n.length)throw new Error("Failed to fetch article content");console.log("Fetched article content:",n);const i=await ae(n,m,x,O,_,k,E,T,A);i&&r(i,e)}catch(g){console.error("Error generating quiz:",g),v("Failed to generate quiz. Please try again.")}finally{f(!1)}}else v("Please select at least one item to generate a quiz from.")},$={};
2c.forEach((e=>{$[e.sectionId]||($[e.sectionId]={id:e.sectionId,title:e.sectionTitle,sectionOrder:e.sectionOrder,items:[]}),$[e.sectionId].items.push(e)}));const P=Object.values($).sort(((e,t)=>e.sectionOrder-t.sectionOrder));return P.forEach((e=>{e.items.sort(((e,t)=>e.itemOrder-t.itemOrder))})),Object(U.jsxs)(B.a,{backdrop:"static",size:"lg",show:t,onHide:n,children:[Object(U.jsx)(B.a.Header,{closeButton:!0,children:Object(U.jsx)(B.a.Title,{children:"Generate Quiz with AI"})}),Object(U.jsxs)(B.a.Body,{children:[Object(U.jsx)("p",{children:"Select content to generate quiz questions from:"}),g&&Object(U.jsx)(ee.a,{variant:"danger",children:g}),Object(U.jsxs)(te.a,{children:[Object(U.jsx)(te.a.Group,{children:Object(U.jsxs)(W.a,{children:[Object(U.jsxs)(Q.a,{children:[Object(U.jsx)(te.a.Label,{children:"Number of questions to generate:"}),Object(U.jsx)(te.a.Control,{type:"number",min:"1",max:"10",value:m,onChange:e=>p(""===e.target.value?"":parseInt(e.target.value)),onBlur:e=>{(""===e.target.value||isNaN(parseInt(e.target.value)))&&p(1)}})]}),Object(U.jsxs)(Q.a,{children:[Object(U.jsxs)(te.a.Label,{children:["Difficulty Level (1-5): ",_]}),Object(U.jsx)(te.a.Control,{type:"range",className:"form-control-range",min:"1",max:"5",value:_,onChange:e=>C(parseInt(e.target.value))}),Object(U.jsxs)("div",{className:"d-flex justify-content-between",children:[Object(U.jsx)("small",{children:"1 (Simple)"}),Object(U.jsx)("small",{children:"5 (Advanced)"})]})]})]})}),Object(U.jsxs)(te.a.Group,{className:"mb-3",children:[Object(U.jsx)(te.a.Label,{children:"Content Types:"}),Object(U.jsxs)("div",{children:[Object(U.jsx)(te.a.Check,{inline:!0,type:"radio",id:"include-quizzes",name:"content-type",label:"Quizzes (Test Knowledge)",checked:x,onChange:()=>{y(!0),w(!1),q(!1)}}),Object(U.jsx)(te.a.Check,{inline:!0,type:"radio",id:"include-scenarios",name:"content-type",label:"Scenarios (Hypothetical situations)",checked:T,onChange:()=>{y(!1),w(!1),q(!0)}}),Object(U.jsx)(te.a.Check,{inline:!0,type:"radio",id:"include-drills",name:"content-type",label:"Drills (Practice applying knowledge)",checked:O,onChange:()=>{y(!1),w(!0),q(!1)}})]}),x&&Object(U.jsxs)("div",{className:"ml-4 mt-2",children:[Object(U.jsx)(te.a.Check,{inline:!0,type:"checkbox",id:"quiz-type-single",label:"Single choice",checked:k.includes("SINGLE_CHOICE"),onChange:()=>{k.includes("SINGLE_CHOICE")?S(k.filter((e=>"SINGLE_CHOICE"!==e))):S([...k,"SINGLE_CHOICE"])}}),Object(U.jsx)(te.a.Check,{inline:!0,type:"checkbox",id:"quiz-type-multiple",label:"Multiple choice",checked:k.includes("MULTIPLE_CHOICE"),onChange:()=>{k.includes("MULTIPLE_CHOICE")?S(k.filter((e=>"MULTIPLE_CHOICE"!==e))):S([...k,"MULTIPLE_CHOICE"])}}),Object(U.jsx)(te.a.Check,{inline:!0,type:"checkbox",id:"quiz-type-open-text",label:"Open text",checked:k.includes("OPEN_TEXT"),onChange:()=>{k.includes("OPEN_TEXT")?S(k.filter((e=>"OPEN_TEXT"!==e))):S([...k,"OPEN_TEXT"])}})]}),O&&Object(U.jsxs)("div",{className:"ml-4 mt-2",children:[Object(U.jsx)(te.a.Check,{inline:!0,type:"checkbox",id:"drill-type-instruction",label:"Instruction",checked:E.includes("INSTRUCTION"),onChange:()=>{E.includes("INSTRUCTION")?I(E.filter((e=>"INSTRUCTION"!==e))):I([...E,"INSTRUCTION"])}}),Object(U.jsx)(te.a.Check,{inline:!0,type:"checkbox",id:"drill-type-submission",label:"Submission",checked:E.includes("SUBMISSION"),onChange:()=>{E.includes("SUBMISSION")?I(E.filter((e=>"SUBMISSION"!==e))):I([...E,"SUBMISSION"])}})]}),T&&Object(U.jsxs)("div",{className:"ml-4 mt-2",children:[Object(U.jsx)(te.a.Check,{inline:!0,type:"checkbox",id:"scenario-type-single",label:"Single choice",checked:A.includes("SINGLE_CHOICE"),onChange:()=>{A.includes("SINGLE_CHOICE")?z(A.filter((e=>"SINGLE_CHOICE"!==e))):z([...A,"SINGLE_CHOICE"])}}),Object(U.jsx)(te.a.Check,{inline:!0,type:"checkbox",id:"scenario-type-multiple",label:"Multiple choice",checked:A.includes("MULTIPLE_CHOICE"),onChange:()=>{A.includes("MULTIPLE_CHOICE")?z(A.filter((e=>"MULTIPLE_CHOICE"!==e))):z([...A,"MULTIPLE_CHOICE"])}}),Object(U.jsx)(te.a.Check,{inline:!0,type:"checkbox",id:"scenario-type-open-text",label:"Open text",checked:A.includes("OPEN_TEXT"),onChange:()=>{A.includes("OPEN_TEXT")?z(A.filter((e=>"OPEN_TEXT"!==e))):z([...A,"OPEN_TEXT"])}})]})]}),Object(U.jsx)("div",{style:{maxHeight:"400px",overflowY:"auto",padding:"10px"},children:P.map((e=>Object(U.jsxs)("div",{className:"mb-3",children:[Object(U.jsx)(te.a.Check,{type:"checkbox",id:`section-${e.id}`,label:Object(U.jsx)("strong",{children:e.title}),checked:e.items.every((e=>u.includes(e.id))),onChange:()=>(e=>{const t=c.filter((t=>t.sectionId===e)).map((e=>e.id));if(t.every((e=>u.includes(e))))h(u.filter((e=>!t.includes(e))));else{const e=[...u];t.forEach((t=>{e.includes(t)||e.push(t)})),h(e)}})(e.id)}),Object(U.jsx)("div",{className:"ml-4",children:e.items.map((t=>Object(U.jsx)(te.a.Check,{type:"checkbox",id:`item-${e.id}-${t.id}`,label:t.title,checked:u.includes(t.id),onChange:()=>{return n=t.id,e.id,void(u.includes(n)?h(u.filter((e=>e!==n))):h([...u,n]));var n}},`${e.id}-${t.id}`)))})]},e.id)))})]})]}),Object(U.jsxs)(B.a.Footer,{children:[Object(U.jsx)(s.a,{variant:"secondary",onClick:n,children:"Cancel"}),j?Object(U.jsxs)(s.a,{variant:"primary",disabled:!0,children:[Object(U.jsx)(l.a,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true"})," ","Generating Quiz..."]}):o?Object(U.jsxs)(U.Fragment,{children:[Object(U.jsx)(s.a,{variant:"primary",className:"mr-2",onClick:()=>L("replace"),disabled:0===u.length||!x&&!O&&!T,children:"Generate and Replace"}),Object(U.jsx)(s.a,{variant:"outline-primary",onClick:()=>L("add"),disabled:0===u.length||!x&&!O&&!T,children:"Generate and Add"})]}):Object(U.jsx)(s.a,{variant:"primary",onClick:()=>L("replace"),disabled:0===u.length||!x&&!O&&!T,children:"Generate Quiz"})]})]})}function se(e,t){const n=e,i=Math.max(1,Math.min(5,parseInt(t,10)||1));if("QUIZ"===n)switch(i){case 1:return"These questions must be easy to answer from a quick skim of the article. Avoid ambiguity and trick options. Keep choices short and clearly distinct.";case 2:return"These questions should be straightforward and mostly recall-based with minimal ambiguity. Include simple distractors that are clearly wrong if the article was read.";case 3:return"These questions should require comprehension beyond a skim. Include plausible distractors that might seem correct without a careful read. Tie questions to specific sentences/steps.";case 4:return"These questions should hinge on small but crucial details in the content. all incorrect answers appear correct at first glance but are contradicted by precise wording in the article.";case 5:default:return"These should be tricky, SAT-level questions that certainly require re-reading the content closely. all incorrect answers should seem more correct then the right answers. we should be trying to trick the user; only a deep understanding reveals the correct answer."}if("SCENARIO"===n)switch(i){case 1:return"Use simple, realistic sce
2narios with clear cues and a single obvious best action supported directly by the article.";case 2:return"Use short scenarios with limited context. Options should be mostly clear, with one or two mild pitfalls resolvable by reading the article.";case 3:return"Use richer scenarios where multiple options seem reasonable at a glance. Learners must reference the article to choose correctly. Include options that might appear correct on a skim.";case 4:return"Use complex scenarios with constraints or stakeholders. all options that seem correct but one is the most correct and the others are wrong because they are not valid due to a small policy or procedural detail in the article.";case 5:default:return"Use multi-step, high-ambiguity scenarios that demand careful application of nuanced policies. all options must appear correct, allign with some details and have a plausible reason why they are correct; only one best action aligns with all details."}switch(i){case 1:return"Provide a short, single-step practice task with explicit instructions and an easy deliverable directly grounded in the article.";case 2:return"Provide a two-step practice task with clear instructions. Minimal ambiguity; easy to complete if the article was read.";case 3:return"Provide a multi-step practice task. Word the task so that it may be unclear to those who have not fully understood the article. Require evidence of completion.";case 4:return"Provide a complex, realistic task with multiple dependencies. Require cross-referencing details from the article. Include strict acceptance criteria and constraints.";case 5:default:return"Provide a capstone-like, end-to-end task demanding planning and precise adherence to the article. Require rigorous evidence and a detailed rubric for evaluation."}}async function ae(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:["SINGLE_CHOICE","MULTIPLE_CHOICE","OPEN_TEXT"],r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:["INSTRUCTION","SUBMISSION"],o=arguments.length>7&&void 0!==arguments[7]&&arguments[7],c=arguments.length>8&&void 0!==arguments[8]?arguments[8]:["SINGLE_CHOICE","MULTIPLE_CHOICE","OPEN_TEXT"];console.log("[generateQuizFromContent] contentItems:",e);try{let u=[];n&&u.push(...a),i&&u.push(...r),o&&u.push(...c);const h=u.join("|");let m="";n?m="questions":i?m="drills":o&&(m="scenarios");let b="";n?b="a quiz":i?b="a set of drills":o&&(b="a set of scenarios");const p=se(n?"QUIZ":i?"DRILL":"SCENARIO",s),j=`\nYou are an instructional design expert. Carefully read the provided course content (titles, bodies, and optional transcripts). Identify the key subjects/concepts that the content is trying to teach. Only include concepts that are clearly supported by the provided content.\n\nReturn a JSON object in EXACTLY this format (no extra commentary):\n{\n  "concepts": [\n    { "concept": "Short concept name", "importance": 1-5, "rationale": "One sentence why this concept is important and supported by the content" }\n  ]\n}\n\nRules:\n- Sort concepts from most important to least important.\n- Do not include unimportant or unsupported concepts.\n- Importance is 5 for most essential concepts, 1 for least essential but still relevant.\n\nContent:\n${e.map((e=>`Title: ${e.title}\nContent: ${e.body||""}${e.transcript?`\nTranscript: ${e.transcript}`:""}`)).join("\n\n")}\n`;console.log("Sending analysis request to OpenAI with prompt:",j);const f=await ne.a.getOpenAIProxy({model:"gpt-4.1-nano",messages:[{role:"user",content:j}]});if(console.log("Analysis response from OpenAI:",f),!f||!f.data||!f.data.choices||0===f.data.choices.length)throw new Error("No response from ChatGPT during analysis");const g=f.data.choices[0].message.content.trim();console.log("Analysis response content:",g);const v=g.indexOf("{"),x=g.lastIndexOf("}")+1;if(-1===v||0===x)throw new Error("No JSON object found in analysis response");const y=g.substring(v,x);console.log("Extracted analysis JSON string:",y);let O=[];try{const e=JSON.parse(y);e&&Array.isArray(e.concepts)&&(O=e.concepts)}catch(l){throw console.error("Error parsing analysis JSON:",l),new Error("Failed to parse analysis JSON")}const w=O.slice(0,Math.max(0,Math.min(t,O.length)));console.log("Selected concepts for generation:",w);const _=n?`\nQUIZZES (use only the selected types: ${a.join(", ")}):\n${a.includes("SINGLE_CHOICE")?"- SINGLE_CHOICE: One definitive correct answer. Provide 3-5 options with exactly one correct choice.\n":""}\n${a.includes("MULTIPLE_CHOICE")?"- MULTIPLE_CHOICE: Multiple correct answers possible. Provide 3-5 options with at least two correct choices when appropriate.\n":""}\n${a.includes("OPEN_TEXT")?"- OPEN_TEXT: Short free-text response reinfor
2cing the concept. Provide an exemplar answer in the rationale of the correct choice.\n":""}\n`:"",C=i?`\nDRILLS (use only the selected types: ${r.join(", ")}):\n- Create tasks that are grounded in the content and key concepts. this must be something they can actually do to practice the knowledge or methods. eg write a blog, create a proposal, look up x record on x site, etc.\n${r.includes("SUBMISSION")?"- SUBMISSION: Learner submits evidence of doing the task (screenshots, videos, notes).\n":""}\n${r.includes("INSTRUCTION")?"- INSTRUCTION: Provide a clear instruction when submission is not feasible.\n":""}\n`:"",N=o?`\nSCENARIOS (use only the selected answer formats: ${c.join(", ")}):\n- Create realistic, context-rich hypothetical what would you do drills of things that would happen in the real world while applying the key concepts.\n- Ask what the learner should do next or what they should have done prior to the scenario.\n${c.includes("SINGLE_CHOICE")?"- For SINGLE_CHOICE scenarios: Only one best action is correct; include 3-5 options.\n":""}\n${c.includes("MULTIPLE_CHOICE")?"- For MULTIPLE_CHOICE scenarios: Multiple actions may be jointly correct; include 3-5 options with at least two correct where appropriate.\n":""}\n${c.includes("OPEN_TEXT")?"- For OPEN_TEXT scenarios: Ask the learner to describe the appropriate action; include an exemplar correct response in the rationale.\n":""}\n`:"",k=`\n            You are an employee training expert with years of experience getting people to really understand and apply courses. You need to create ${b} based on provided content.\n            \n            Create ${b} with exactly ${t} ${m} based on the following content and prioritized key concepts:\n            \n            KEY CONCEPTS TO EMPHASIZE (in priority order; use only these concepts; if there are fewer concepts than ${t}, create multiple ${m} across the listed concepts):\n            ${w.map(((e,t)=>`${t+1}. ${e.concept} (importance: ${e.importance}) - ${e.rationale||""}`)).join("\n")}\n            \n            CONTENT:\n            ${e.map((e=>`\n                Title: ${e.title}\n                Content: ${e.body||""}\n                ${e.transcript?`Transcript: ${e.transcript}`:""}\n            `)).join("\n\n")}\n            \n            VERY IMPORTANT: ALL ${m} MUST be directly answerable from the content provided above. Do not create questions that require external knowledge. Users should be able to answer every question by reviewing the provided content. Questions should actively reinforce the key concepts listed above.\n            \n            Difficulty Guidance:\n            ${p}\n            \n            Follow this procedure:\n            1) Map each ${m} to a key concept from the list, starting from the most important concept.\n            2) For each ${m}, extract the exact supporting sentences from the content to ensure answerability.\n            3) Select a type from the allowed set (${h}) that best fits the concept and the Difficulty Guidance above.\n            4) Draft the ${m} ensuring clarity, relevance, and direct grounding in the extracted sentences.\n            5) For choice-based types, craft plausible distractors anchored in the content but clearly distinguishable from the correct answer.\n            6) Set the "type" field exactly to one of: ${h}.\n            \n            Guidance by type:\n            ${_}\n            ${C}\n            ${N}\n            \n            Additional requirements:\n            - Create exactly ${t} ${m}\n            ${n||o?"- For choice-based items: Include 3-5 options.\n- SINGLE_CHOICE: exactly one option is correct.\n- MULTIPLE_CHOICE: at least one and possibly multiple options are correct.\n":""}\n            - ${m} should test understanding and motivate application of key concepts, not just recall of facts\n            \n            Respond with a JSON object in this exact format:\n            {\n              "title": "Quiz title based on content",\n              "questions": [\n                {\n                  "question": "Question text",\n                  "type": "${h}",\n                  "order": 1,\n                  "choices": [\n                    {"text": "Answer text", "is_correct": true|false}\n                  ]\n                }\n              ]\n            }\n            \n            For INSTRUCTION and OPEN_TEXT types, include a single choice with is_correct=true and placeholder/exemplar text.\n        `;console.log("Sending request to OpenAI with prompt:",k);const S=await ne.a.getOpenAIProxy({model:"gpt-4.1-nano",messages:[{role:"user",content:k}]});if(console.log("Response from OpenAI:",S),!S)throw new Error("Failed to get response from OpenAI");const E=S.data;if(console.log("Response data:",E),!E.choices||0===E.choices.length)throw new Error("No response from ChatGPT");const I=E.choices[0].message.content.trim();console.log("Response content:",I);const T=I.indexOf("{"),q=I.lastIndexOf("}")+1;if(-1===T||0===q)throw new Error("No JSON object found in response");const A=I.substring(T,q);console.log("Extracted JSON string:",A);try{return JSON.parse(A)}catch(d){throw console.error("Error parsing extracted JSON:",d),new Error("Failed to parse extracted JSON")}}catch(d){throw console.error("Error calling ChatGPT:",d),d}}function re(e){let{callbackFunc:t,className:n,variant:a="primary",btnText:r="Create Quiz"}=e;const[o,c]=Object(i.useState)(!1),[l,d]=Object(i.useState)(!1),[u,h]=Object(i.useState)(null),m=()=>{c(!1),h(null)},b=Object(i.useMemo)((()=>{const e=null===u||void 0===u?void 0:u.questions;if(!e||!Array.isArray(e)||0===e.length)return!1;if(e.length>1)return!0;const t=e[0];return(t&&"string"===typeof t.question?t.question:"").replace(/<[^>]*>/g,"").trim().length>0}),[u]);return Object(U.jsxs)(U.Fragment,{children:[Object(U.jsx)(s.a,{variant:a,className:`btn-sm mb-1 p-1 ${n||""}`,onClick:()=>c(!0),"data-testid":"create-quiz-modal-button",children:r}),Object(U.jsxs)(B.a,{backdrop:"static",size:"lg",enforceFocus:!1,show:o,onHide:m,"data-testid":"create-quiz-modal",children:[Object(U.jsx)(B.a.Header,{closeButton:!0,children:Object(U.jsxs)(B.a.Title,{children:["Quiz Details",Object(U.jsx)(s.a,{variant:"info",className:"btn-sm ml-2",onClick:()=>{d(!0)},children:"Create with AI"})]})}),Object(U.jsx)(B.a.Body,{children:Object(U.jsx)(V.g,{callbackFunc:e=>{"function"===typeof t&&t(e),m()},aiGeneratedData:u})})]}),Object(U.jsx)(ie,{show:l,handleClose:()=>{d(!1)},onQuizCreated:function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"replace";if(d(!1),"add"===n&&null!==u&&void 0!==u&&null!==(t=u.questions)&&void 0!==t&&t.length){const t={title:u.title||e.title||"",questions:[...u.questions,...(null===e||void 0===e?void 0:e.questions)||[]]};h(t)}else h(e);c(!0)},formHasContent:b})]})}var oe=n(426);function ce(e){let{callbackFunc:t,className:n,variant:a="primary",btnText:r="Create Article",defaultShowAdvanced:o}=e;const[c,l]=Object(i.useState)(!1),[d,u]=Object(i.useState)(!1),h=e=>{"function"===typeof t&&t(e),l(!1)};return Object(i.useEffect)((()=>{d&&u(!1),h()}),[d]),Object(U.jsxs)(U.Fragment,{children:[Object(U.jsx)(s.a,{variant:a,className:`btn-sm mb-1 p-1 ${n||""}`,onClick:()=>l(!0),"data-testid":"create-article-modal-button",children:r}),c&&Object(U.jsx)(oe.a,{showCreate:c,setShowCreate:l,reload:d,setReload:u,callbackFunc:h,defaultShowAdvanced:o})]})}var le=n(1078),de=n(1087),ue=n(1086);n(1074),n(1122);const he="course-sections",me="course-articles";function be(e){let{title:t,badgeColor:n,treeId:i,rootKey:s,treeRef:a,treeKey:r,loading:o,empty:d,emptyText:u,placeholder:m,headerExtra:b,query:p,onQuery:j}=e;return Object(U.jsxs)(c.a,{className:"mb-2",children:[Object(U.jsxs)(c.a.Header,{className:"d-flex align-items-center",children:[Object(U.jsx)("span",{className:"course-itemtype-badge",style:{backgroundColor:n}}),Object(U.jsx)("span",{className:"font-weight-bold mr-auto",children:t}),b]}),Object(U.jsx)("div",{className:"p-2",children:Object(U.jsx)("input",{type:"text",className:"form-control form-control-sm",placeholder:m,value:p,onChange:e=>j(e.target.value)})}),Object(U.jsx)("div",{style:{maxHeight:260,overflow:"auto"},className:"px-2 pb-2",children:o?Object(U.jsx)("div",{className:"text-center py-3",children:Object(U.jsx)(l.a,{animation:"border",size:"sm"})}):d?Object(U.jsx)("div",{className:"text-muted small px-2 py-3",children:u}):Object(U.jsx)(h.a,{treeId:i,rootItem:s,ref:a},r)})]})}function pe(e){var t;let{handleSubmit:n,submitting:r,isCreate:l}=e;const B=Object(a.c)(),{courseSections:H,courseFormErrors:W}=Object(a.d)((e=>e.knowledgebaseReducer)),Q=Object(x.a)(),{quizzes:J,fetchQuizzes:Y}=function(e){const[t,n]=Object(i.useState)(!1),[s,r]=Object(i.useState)(null),c=Object(a.c)(),{quizzes:l}=Object(a.d)((e=>e.knowledgebaseReducer));return{quizzes:l,loading:t,error:s,fetchQuizzes:async()=>{n(!0);try{const t=await b.a.getQuizzes(e);t&&c({type:o.Eb,payload:t})}catch(s){r(s)}n(!1)}}}({paginate:!1}),{fileTypes:V,fetchFileTypes:K}=Object(p.a)();Object(i.useEffect)((()=>{Y(),K()}),[]);const ee=Object(i.useRef)(null),te=Object(i.useRef)(null),ne=Object(i.useRef)(null),[ie,se]=Object(i.useState)(""),[ae,oe]=Object(i.useState)(""),[pe,je]=Object(i.useState)(""),[fe,ge]=Object(i.useState)(!1),[ve,xe]=Object(i.useState)(null),ye=Object(i.useRef)(null),Oe=Object(i.useRef)(0),we=Object(i.useCallback)((async e=>{const t=(e||"").trim();if(!t)return xe(null),void ge(!1);const n=++Oe.current;ge(!0);try{const e=t.toLowerCase(),i=Object.values(Q.itemsRef.current||{}).filter((t=>{var n;return"category"===(null===t||void 0===t||null===(n=t.data)||void 0===n?void 0:n.kind)&&(t.data.title||"").toLowerCase().includes(e)})).map((e=>({index:Object(y.b)(e.data.id),isFolder:!1,canMove:!0,canRename:!1,children:[],data:{kind:"category",id:e.data.id,title:e.data.title,articles_count:e.data.articles_count}}))),s=await b.a.getKBArticlesSimple({title:t,simple_details:!0,paginate:!0,page:1}),a=(Array.isArray(s)?s:(null===s||void 0===s?void 0:s.results)||[]).map((e=>({index:Object(y.a)(e.id),isFolder:!1,canMove:!0,canRename:!1,children:[],data:{kind:"article",id:e.id,title:e.title}}
2)));if(n!==Oe.current)return;const r={root:{index:"root",isFolder:!0,canMove:!1,canRename:!1,children:[...i.map((e=>e.index)),...a.map((e=>e.index))],data:{kind:"root"}}};[...i,...a].forEach((e=>{r[e.index]=e})),xe(r)}catch(i){n===Oe.current&&xe({root:{index:"root",isFolder:!0,canMove:!1,canRename:!1,children:[],data:{kind:"root"}}})}finally{n===Oe.current&&ge(!1)}}),[Q.itemsRef]),_e=Object(i.useCallback)((e=>{if(se(e),ye.current&&clearTimeout(ye.current),!e.trim())return Oe.current+=1,xe(null),void ge(!1);ge(!0),ye.current=setTimeout((()=>we(e)),300)}),[we]),Ce=Object(i.useCallback)((async e=>{if(!e)return;await Q.fetchTree();const t=e.article_category;t&&(Q.setExpandedKeys((e=>e.includes(Object(y.b)(t))?e:[...e,Object(y.b)(t)])),await Q.loadArticles(t))}),[Q]),Ne=Object(i.useRef)(H);Object(i.useEffect)((()=>{Ne.current=H}),[H]);const ke=Object(i.useMemo)((()=>Object(O.c)(H||[])),[H]),Se=Object(i.useMemo)((()=>{const e=ae.trim().toLowerCase();return e?(J||[]).filter((t=>(t.title||"").toLowerCase().includes(e))):J}),[J,ae]),Ee=Object(i.useMemo)((()=>{const e=pe.trim().toLowerCase();return e?(V||[]).filter((t=>(t.name||"").toLowerCase().includes(e))):V}),[V,pe]),Ie=Object(i.useMemo)((()=>z(N,"quiz-",Se,{kind:"quiz",titleOf:e=>e.title})),[Se]),Te=Object(i.useMemo)((()=>z(k,"file-",Ee,{kind:"file",titleOf:e=>e.name,canMove:e=>!!e.template_slug})),[Ee]),qe=ve||Q.items,Ae=Object(i.useMemo)((()=>function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return Object.assign({},L(e,_),L(t,C),...i)}(ke,qe,Ie,Te)),[ke,qe,Ie,Te]),ze=Object(i.useRef)(Ae);Object(i.useEffect)((()=>{ze.current=Ae}),[Ae]);const Le=Object(i.useMemo)((()=>new v.a(JSON.parse(JSON.stringify(ze.current)),(()=>{}))),[]);Object(i.useEffect)((()=>{Le.applyExternal(JSON.parse(JSON.stringify(Ae)))}),[Ae,Le]);const $e=Object(i.useMemo)((()=>{var e;return(null===(e=Ae[_])||void 0===e?void 0:e.children)||[]}),[Ae]),Pe=Object(i.useMemo)((()=>[...$e].sort().join(",")),[$e]),Re=Object(i.useMemo)((()=>({[he]:{expandedItems:$e},[me]:{expandedItems:Q.expandedKeys}})),[$e,Q.expandedKeys]),Me=Object(i.useCallback)((e=>{I(e.index)&&Q.onExpandItem(e)}),[Q]),Fe=Object(i.useCallback)((e=>{I(e.index)&&Q.onCollapseItem(e)}),[Q]),De=Object(i.useCallback)(((e,t)=>{var n;if(!t||t.treeId!==he)return!1;const i=e||[];if(!i.length)return!1;const s=null===(n=i[0])||void 0===n?void 0:n.index,a=(e=>T(e)||q(e)||A(e))(s)||E(s),r=S(s)||I(s);return"between-items"===t.targetType?t.parentItem===_?r:!!S(t.parentItem)&&a:t.targetItem===_?r:!!S(t.targetItem)&&a}),[]),Be=Object(i.useCallback)((async(e,t)=>{const n=e.map((e=>e.index)),i=n[0],s={...ze.current};e.forEach((e=>{s[e.index]||(s[e.index]=e)}));const a=Ne.current;let r={};if(I(i)){var c,l,d,u;const e=null!==(c=null===s||void 0===s||null===(l=s[i])||void 0===l||null===(d=l.data)||void 0===d?void 0:d.id)&&void 0!==c?c:Number(i.split("-")[1]),t=((null===(u=s[i])||void 0===u?void 0:u.children)||[]).filter(T).map((e=>{var t;return null===(t=s[e])||void 0===t?void 0:t.data})).filter(Boolean);if(t.length)r[e]=t.map((e=>({id:e.id,title:e.title})));else{const t=await b.a.getKBArticlesSimple({article_category:e,simple_details:!0,paginate:!1}),n=Array.isArray(t)?t:(null===t||void 0===t?void 0:t.results)||[];r[e]=n.map((e=>({id:e.id,title:e.title})))}}const h=function(e,t,n,i){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const a=R(n,i);if(!a)return e;let r=(e||[]).map((e=>({...e,section_items:[...e.section_items||[]]})));const o=(t||[])[0];if(!o)return e;if(S(o)&&"section-list"===a.kind){const t=r.findIndex((e=>Object(O.b)(e.id)===o));if(-1===t)return e;const[n]=r.splice(t,1),i=M(r,null!=a.index&&a.index>t?a.index-1:a.index);return r.splice(i,0,n),D(r)}if(I(o)&&"section-list"===a.kind){var c,l,d,u,h;const e=s[null!==(c=null===i||void 0===i||null===(l=i[o])||void 0===l||null===(d=l.data)||void 0===d?void 0:d.id)&&void 0!==c?c:Object(y.e)(o)]||[],t={id:F(r),title:(null===i||void 0===i||null===(u=i[o])||void 0===u||null===(h=u.data)||void 0===h?void 0:h.title)||"",section_items:e.map((e=>$({id:e.id,title:e.title,type:w.a}))),order:0};return r.splice(M(r,a.index),0,t),D(r)}if("into-section"!==a.kind||null==a.sectionId)return e;const m=r.findIndex((e=>e.id===a.sectionId));if(-1===m)return e;if(T(o)||o.startsWith("quiz-")||o.startsWith("file-")){const t=P(o,i);if(!t)return e;const n=r[m].section_items;return n.splice(M(n,a.index),0,t),D(r)}if(E(o)){const[,t,n]=o.split("-"),i=Number(t),s=Number(n),c=r.findIndex((e=>e.id===i));if(-1===c)return e;const[l]=r[c].section_items.splice(s,1),d=r.findIndex((e=>e.id===a.sectionId)),u=r[d].section_items;let h=M(u,a.index);return i===a.sectionId&&null!=a.index&&a.index>s&&(h-=1),u.splice(h,0,l),D(r)}return e}(a,n,t,s,r);h!==a&&B({type:o.tb,payload:h})}),[B]),He=Object(i.useCallback)(((e,t)=>B({type:o.tb,payload:(Ne.current||[]).map((n=>n.id===e?{...n,title:t}:n))})),[B]),Ue=Object(i.useCallback)((e=>B({type:o.tb,payload:(Ne.current||[]).filter((t=>
2t.id!==e))})),[B]),Ge=Object(i.useCallback)(((e,t)=>B({type:o.tb,payload:(Ne.current||[]).map((n=>n.id!==e?n:{...n,section_items:(n.section_items||[]).filter(((e,n)=>n!==t))}))})),[B]),We=Object(i.useCallback)((()=>{const e=Ne.current||[],t=e.map((e=>Number(e.id))).filter((e=>!Number.isNaN(e))),n=(t.length?Math.max(...t):0)+1;B({type:o.tb,payload:[...e,{id:n,order:e.length+1,title:"",section_items:[]}]})}),[B]),Qe=Object(i.useCallback)((e=>{let{item:t,children:n,arrow:i,context:s}=e;const a=t.index,r=t.data||{},o=S(a),l=["shared-tree__row",s.isDraggingOver&&"shared-tree__row--drag-over",s.isDraggingOver&&t.isFolder&&"shared-tree__row--drop-into"].filter(Boolean).join(" "),h=s.interactiveElementProps||{},{draggable:m,onDragStart:b}=h,p=o?{draggable:!1}:h,v=o?{draggable:m,onDragStart:b}:{};let x;if(o)x=Object(U.jsx)(c.a,{className:"section-article shadow-sm mb-2 w-100",children:Object(U.jsxs)("div",{className:"p-3 align-items-center d-flex section-article",children:[Object(U.jsx)("span",{className:"drag-icon-container",title:"Drag to reorder","aria-hidden":"true",style:{cursor:"grab"},...v,children:Object(U.jsx)(f.a,{})}),i,Object(U.jsx)("input",{type:"text",className:"form-control form-control-sm mx-2",defaultValue:r.title||"",onChange:e=>He(r.id,e.target.value),onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),placeholder:"Section title"},r.id),Object(U.jsx)(d.a,{placement:"bottom",overlay:Object(U.jsx)(u.a,{children:"Remove section"}),children:Object(U.jsx)("button",{type:"button",className:"p-1 bg-transparent border-0 m-0 article-remove",onClick:e=>{e.stopPropagation(),Ue(r.id)}
2,children:Object(U.jsx)("i",{className:"fa fa-trash course-action-icon"})})})]})});else if(E(a)){var y,O,_,C;const e=Number(a.split("-")[1]),t=Number(a.split("-")[2]),n=r.type===w.c,i=r.type===w.a,s=r.raw,o=null!==(y=null===s||void 0===s||null===(O=s.article)||void 0===O?void 0:O.id)&&void 0!==y?y:r.id,c=null!==(_=null===s||void 0===s||null===(C=s.quiz)||void 0===C?void 0:C.id)&&void 0!==_?_:r.id,l=Object(U.jsxs)(U.Fragment,{children:[i&&Object(U.jsx)(j.a,{isCourseArticle:!1,articleId:o,button:Object(U.jsx)("i",{className:"feather icon-eye text-dark"}),className:"p-1 ml-2 bg-transparent border-0 m-0"}),n&&Object(U.jsx)(G,{quizId:c,showIcon:!0,showEditModal:!0,onDeleteCallback:()=>Ge(e,t)}),Object(U.jsx)(d.a,{placement:"bottom",overlay:Object(U.jsx)(u.a,{children:"Remove from course"}),children:Object(U.jsx)("button",{type:"button",className:"p-1 bg-transparent border-0 m-0",onClick:n=>{n.stopPropagation(),Ge(e,t)},children:Object(U.jsx)("i",{className:"fa fa-times course-action-icon"})})})]});x=Object(U.jsx)(g.a,{title:r.title,actions:l,badgeColor:Object(w.e)(r.type)})}else if(I(a))x=Object(U.jsxs)("div",{className:"kbnav-cat-row d-flex align-items-center w-100 grabbable",title:"Drag in as a section, or open to drag its articles",children:[i,Object(U.jsx)("span",{className:"kbnav-cat-name flex-grow-1",children:r.title}),"number"===typeof r.articles_count&&Object(U.jsx)("span",{className:"kbnav-count badge badge-light",children:r.articles_count})]});else if(q(a)){const e=Object(U.jsxs)(U.Fragment,{children:[Object(U.jsx)(X,{quizId:r.id}),Object(U.jsx)(G,{quizId:r.id}),Object(U.jsx)(Z.a,{quizId:r.id,quizTitle:r.title,filledIcon:!0,onDeleteCallback:Y})]});x=Object(U.jsx)("div",{className:"grabbable",title:"Drag into a section",children:Object(U.jsx)(g.a,{title:r.title,actions:e,badgeColor:Object(w.e)(w.c)})})}else if(A(a)){const e=r.raw||{},t=!!e.template_slug,n=Object(U.jsxs)(U.Fragment,{children:[Object(U.jsx)(le.default,{callbackFunc:K,doc_id:e.id,doc_url:e.template_file,doc_name:e.name,btn_txt:"Prepare",className:"btn-sm btn-primary p-1"}),Object(U.jsx)(de.a,{instance:e,className:"btn-sm btn-primary p-1",callbackFunc:K})]});x=Object(U.jsx)("div",{className:t?"grabbable":"",title:t?"Drag into a section":"Add a template to make this draggable",children:Object(U.jsx)(g.a,{title:r.title,actions:n,badgeColor:Object(w.e)(w.b)})})}else x=Object(U.jsx)("div",{className:"grabbable",title:"Drag into a section",children:Object(U.jsx)(g.a,{title:Object(U.jsxs)("span",{children:[Object(U.jsx)("i",{className:"feather icon-file-text"})," ",r.title]}),badgeColor:Object(w.e)(w.a)})});return Object(U.jsxs)("li",{...s.itemContainerWithChildrenProps,className:"shared-tree__item",children:[Object(U.jsx)("div",{...s.itemContainerWithoutChildrenProps,...p,className:l,children:x}),n]})}),[He,Ue,Ge,K]),Je=0===((null===(t=Ae[C])||void 0===t?void 0:t.children)||[]).length;return Object(U.jsx)(m.a,{dataProvider:Le,getItemTitle:e=>{var t,n;return null!==(t=null===e||void 0===e||null===(n=e.data)||void 0===n?void 0:n.title)&&void 0!==t?t:""},viewState:Re,canDragAndDrop:!0,canReorderItems:!0,canDropOnFolder:!0,canDropOnNonFolder:!1,canSearch:!1,canSearchByStartingTyping:!1,canDropAt:De,onDrop:Be,onExpandItem:Me,onCollapseItem:Fe,renderItem:Qe,renderItemArrow:v.d,renderItemsContainer:v.e,renderDragBetweenLine:v.c,children:Object(U.jsxs)("div",{className:"row",children:[Object(U.jsxs)("div",{className:"col-md-8 col-12 course-builder-column",children:[(null===W||void 0===W?void 0:W.courseSections)&&Object(U.jsx)("p",{className:"text-danger text-center",children:W.courseSections}),Object(U.jsx)(h.a,{treeId:he,rootItem:_}),Object(U.jsxs)("div",{className:"text-center mt-3",children:[Object(U.jsx)(s.a,{variant:"primary",onClick:We,"data-testid":"course-section-add-section-button",children:"Add Another Section"})," ",Object(U.jsx)(s.a,{variant:"primary",className:"float-right",type:"submit",disabled:r,onClick:n,"data-testid":"course-section-submit-button",children:r?"Submitting...":l?"Create Course":"Update Course"})]})]}),Object(U.jsx)("div",{className:"col-md-4 col-12 course-builder
2-column",children:Object(U.jsxs)("div",{style:{position:"sticky",top:20},children:[Object(U.jsx)(be,{title:"Articles",badgeColor:Object(w.e)(w.a),treeId:me,rootKey:C,treeRef:ee,loading:Q.loadingTree||fe,empty:Je,emptyText:ie.trim()?"No matching articles or categories.":"No categories yet.",placeholder:"Search articles & categories\u2026",query:ie,onQuery:_e,headerExtra:Object(U.jsx)(ce,{callbackFunc:Ce,className:"float-right"})}),Object(U.jsx)(be,{title:"Quizzes",badgeColor:Object(w.e)(w.c),treeId:"course-quizzes",rootKey:N,treeRef:te,empty:0===(Se||[]).length,emptyText:ae.trim()?"No matching quizzes.":"No quizzes yet.",placeholder:"Search quizzes by title\u2026",query:ae,onQuery:oe,headerExtra:Object(U.jsx)(re,{callbackFunc:Y,className:"float-right"})}),Object(U.jsx)(be,{title:"E-Sign Files",badgeColor:Object(w.e)(w.b),treeId:"course-files",rootKey:k,treeRef:ne,empty:0===(Ee||[]).length,emptyText:pe.trim()?"No matching file types.":"No file types yet.",placeholder:"Search file types by name\u2026",query:pe,onQuery:je,headerExtra:Object(U.jsx)(ue.a,{title:"Create",className:"float-right pb-1 p-1",callbackFunc:K})})]})})]})},Pe)}var je=n(73),fe=n(919),ge=n(33),ve=n(34),xe=n(136),ye=n(212);function Oe(e){let{showEditModal:t,handleCloseModal:n,getCourseCategories:r}=e;const[o,c]=Object(i.useState)({name:"",id:"",is_starred:!1}),[l,d]=Object(i.useState)(""),[u,h]=Object(i.useState)(!1),{courseCategories:m,courseCategory:p}=Object(a.d)((e=>e.knowledgebaseReducer)),j=(Object(a.c)(),Object(i.useCallback)((e=>{const t=e.target.value;c({...o,name:t})}))),f=Object(i.useCallback)((e=>{c((t=>({...t,is_starred:e.target.checked})))}),[]),g=Object(i.useCallback)((async()=>{const e={name:o.name,is_starred:!!o.is_starred};await b.a.updateCourseCategory(o.id,e)&&(r(),c({name:"",id:"",is_starred:!1}),d(""),n())})),v=Object(i.useCallback)((async()=>{h(!0);try{await b.a.deleteCourseCategory(o.id),r(),n()}catch(e){console.error("Error deleting category:",e)}finally{h(!1)}}),[o.id,r,n]);return Object(i.useEffect)((()=>{t&&(()=>{const e=m.find((e=>e.id==p));c(e?{...e,is_starred:!!e.is_starred}:{name:"",id:"",is_starred:!1})})()}),[t]),Object(U.jsxs)(B.a,{backdrop:"static",show:t,onHide:n,"data-testid":"add-course-category-edit-modal",children:[Object(U.jsx)(B.a.Header,{closeButton:!0,children:Object(U.jsx)(B.a.Title,{children:"Edit Category "})}),Object(U.jsx)(B.a.Body,{children:Object(U.jsxs)(te.a,{children:[Object(U.jsxs)(te.a.Group,{controlId:"formBasicEmail",children:[Object(U.jsx)(te.a.Label,{children:"Category Name"}),Object(U.jsx)(te.a.Control,{type:"text",value:o.name,onChange:j,placeholder:"Enter new category name","data-testid":"add-course-category-edit-modal-category-name-input"}),l&&"submitting"!==l&&Object(U.jsx)("div",{className:"text-danger","data-testid":"add-course-category-edit-modal-category-name-error",children:l})]}),Object(U.jsx)(te.a.Group,{controlId:"formCategoryStarred",className:"mt-2",children:Object(U.jsx)(te.a.Check,{type:"checkbox",label:"Star category (show at top of c
2ategory lists, alphabetically with other starred categories)",checked:!!o.is_starred,onChange:f,"data-testid":"add-course-category-edit-modal-starred-checkbox"})})]})}),Object(U.jsxs)(B.a.Footer,{className:"d-flex justify-content-between",children:[Object(U.jsx)(s.a,{variant:"danger",onClick:v,disabled:u||"submitting"===l,"data-testid":"add-course-category-edit-modal-delete-button",children:u?"Deleting...":"Delete Category"}),Object(U.jsxs)("div",{children:[Object(U.jsx)(s.a,{variant:"secondary",onClick:n,className:"mr-2","data-testid":"add-course-category-edit-modal-close-button",children:"Close"}),Object(U.jsx)(s.a,{variant:"primary",onClick:e=>{o.name?(d("submitting"),g()):(console.log("No category name ,show no category name error"),d("This field is required"))},disabled:"submitting"===l,"data-testid":"add-course-category-edit-modal-submit-button",children:"submitting"==l?"Submitting...":"Submit"})]})]})]})}function we(){const[e,t]=Object(i.useState)(!1),[n,r]=Object(i.useState)(!1),[c,l]=Object(i.useState)(""),[d,u]=Object(i.useState)(""),h=Object(a.c)(),{courseCategories:m,courseCategory:p}=Object(a.d)((e=>e.knowledgebaseReducer)),j=()=>t(!1),f=Object(i.useCallback)((e=>{const t=e.target.value;l(t)})),g=Object(i.useCallback)((async()=>{const e=await b.a.getCourseCategories();if(e){const t=e.results;h({type:o.ib,payload:t}),t.length>0&&h({type:o.yb,name:"courseCategory",payload:t[0].id})}}),[m]),v=Object(i.useCallback)((async()=>{const e={name:c};await b.a.addCourseCategory(e)&&(g(),l(""),u(""),j())}));return Object(i.useEffect)((()=>{setTimeout((()=>{u("")}),[3e3])}),[d]),Object(U.jsxs)(U.Fragment,{children:[Object(U.jsx)(s.a,{variant:"primary",className:"btn btn-sm btn-icon btn-primary mx-1",style:{height:"42.8px"},onClick:()=>t(!0),"data-testid":"add-course-category-create-modal-button",children:Object(U.jsx)(xe.n,{})}),p&&Object(U.jsx)(s.a,{variant:"primary",className:"btn btn-sm btn-icon btn-primary",style:{height:"42.8px"},onClick:()=>r(!0),"data-testid":"add-course-category-edit-modal-button",children:Object(U.jsx)(ye.f,{})}),Object(U.jsxs)(B.a,{show:e,backdrop:"static",onHide:j,"data-testid":"add-course-category-create-modal",children:[Object(U.jsx)(B.a.Header,{closeButton:!0,children:Object(U.jsx)(B.a.Title,{children:"Create New Category"})}),Object(U.jsx)(B.a.Body,{children:Object(U.jsx)(te.a,{children:Object(U.jsxs)(te.a.Group,{controlId:"formBasicEmail",children:[Object(U.jsx)(te.a.Label,{children:"Category Name"}),Object(U.jsx)(te.a.Control,{type:"text",value:c,onChange:f,placeholder:"Enter new category name","data-testid":"add-course-category-create-modal-category-name-input"}),d&&"submitting"!==d&&Object(U.jsx)("div",{className:"text-danger","data-testid":"add-course-category-create-modal-category-name-error",children:d})]})})}),Object(U.jsxs)(B.a.Footer,{children:[Object(U.jsx)(s.a,{variant:"secondary",onClick:j,"data-testid":"add-course-category-create-modal-close-button",children:"Close"}),Object(U.jsx)(s.a,{variant:"primary",onClick:e=>{c?(u("submitting"),v()):(console.log("No category name ,show no category name error"),u("This field is required"))},disabled:"submitting"===d,"data-testid":"add-course-category-create-modal-submit-button",children:"submitting"==d?"Submitting...":"Submit"})]})]}),Object(U.jsx)(Oe,{showEditModal:n,handleCloseModal:()=>r(!1),getCourseCategories:g})]})}var _e=n(223),Ce=n(154),Ne=n(41),ke=n(332);function Se(){const e=Object(a.c)(),{courseName:t,courseCategory:n,courseDescription:r,coursePriority:c,courseCategories:l,courseDivisions:d,courseIndividuals:u,courseFormErrors:h,courseResponsibilities:m,coursePositions:b,courseIsAssignedToEveryone:p,courseHasCertificate:j,courseReassignDuration:f,courseReassignRepeats:g,courseReminderFrequencyDays:v,is_scorm_course:x,scorm_file_url:y,existing_scorm_package_name:O,existing_scorm_package_id:w}=Object(a.d)((e=>e.knowledgebaseReducer)),[_,C]=Object(i.useState)([]),[N,k]=Object(i.useState)([]),{positions:S}=Object(a.d)((e=>e.account)),[E,I]=Object(i.useState)(!1),[T,q]=Object(i.useState)(!1),[A,z]=Object(i.useState)(!1);Object(i.useEffect)((()=>{z(!!y||!O)}),[O,y]);const L=(t,n)=>{const i=n.name;if("individuals"===i){if(("clear"===n.action||"remove-value"===n.action)&&d.length>0)return;e({type:o.pb,payload:null===t||void 0===t?void 0:t.map((e=>e.id))})}if("divisions"===i){e({type:o.mb,payload:t});let n=[];null===t||void 0===t||t.map((e=>{e.staff_division&&n.push(...e.staff_division)})),(t=>{let n=null===t||void 0===t?void 0:t.map((e=>e.id));e({type:o.pb,payload:n})})(n)}},$=(t,n)=>{const i=t.target.name,s=n?t.target.checked:t.target.value;e({type:o.yb,payload:s,name:i})},P=(t,n)=>{const{name:i}=n;console.log({name:i,data:t});const s={responsibilities:o.sb,positions:o.qb};e({type:s[i],payload:t})};Object(i.useEffect)((()=>{(async()=>{const t=await fe.a.getCourseCategories();if(t){const n=t.results;e({type:o.ib,payload:n})}})(),(async()=>{I(!0);const t=await Object(ge.k)({simple_details:!0});t&&(e({type:o.Db,payload:t}),I(!1))})(),(async()=>
2{if(!_.length>0){q(!0);const e=100,t=!0,n=await Object(ge.l)(e,t);if(n){const e=Object(ve.i)(n.results,"title");C(e),q(!1)}}})()}),[]),Object(i.useEffect)((()=>{if(S.length>0){const e=Object(ve.i)(S,"name");k(e)}}),[S]);const R=Number(f)>0;return Object(U.jsxs)(U.Fragment,{children:[Object(U.jsxs)("div",{className:"row",children:[Object(U.jsx)("div",{className:"col-md-6 col-12",children:Object(U.jsxs)("div",{className:"form-group",children:[Object(U.jsx)(te.a.Label,{children:"Course Name"}),Object(U.jsx)(te.a.Control,{type:"text",name:"courseName",value:t,onChange:$,placeholder:"Write a course name","data-testid":"course-form-name-input"}),h.courseName&&Object(U.jsx)("div",{className:"text-danger","data-testid":"course-form-name-error",children:"This field is required"})]})}),Object(U.jsx)("div",{className:"col-md-3 col-12",children:Object(U.jsx)(Ne.a,{title:"This determines the order in which courses are assigned to employees. Employees will only see ",children:Object(U.jsxs)("div",{className:"form-group",children:[Object(U.jsx)(te.a.Label,{children:"Assigned to Phase"}),Object(U.jsxs)(te.a.Control,{as:"select",name:"coursePriority",value:c,onChange:$,custom:!0,"data-testid":"course-form-priority-input",children:[Object(U.jsx)("option",{value:"0",children:"No Assignment Phase"}),Object(U.jsx)("option",{value:"1",children:"Assignment Phase 1"}),Object(U.jsx)("option",{value:"2",children:"Assignment Phase 2"}),Object(U.jsx)("option",{value:"3",children:"Assignment Phase 3"}),Object(U.jsx)("option",{value:"4",children:"Assignment Phase 4"}),Object(U.jsx)("option",{value:"5",children:"Assignment Phase 5"}),Object(U.jsx)("option",{value:"6",children:"Assignment Phase 6"}),Object(U.jsx)("option",{value:"7",children:"Assignment Phase 7"}),Object(U.jsx)("option",{value:"8",children:"Assignment Phase 8"}),Object(U.jsx)("option",{value:"9",children:"Assignment Phase 9"}),Object(U.jsx)("option",{value:"10",children:"Assignment Phase 10"}),Object(U.jsx)("option",{value:"11",children:"Assignment Phase 11"}),Object(U.jsx)("option",{value:"12",children:"Assignment Phase 12"}),Object(U.jsx)("option",{value:"13",children:"Assignment Phase 13"}),Object(U.jsx)("option",{value:"14",children:"Assignment Phase 14"}),Object(U.jsx)("option",{value:"15",children:"Assignment Phase 15"}),Object(U.jsx)("option",{value:"16",children:"Assignment Phase 16"}),Object(U.jsx)("option",{value:"17",children:"Assignment Phase 17"}),Object(U.jsx)("option",{value:"18",children:"Assignment Phase 18"}),Object(U.jsx)("option",{value:"19",children:"Assignment Phase 19"}),Object(U.jsx)("option",{value:"20",children:"Assignment Phase 20"}),Object(U.jsx)("option",{value:"21",children:"Assignment Phase 21"}),Object(U.jsx)("option",{value:"22",children:"Assignment Phase 22"}),Object(U.jsx)("option",{value:"23",children:"Assignment Phase 23"}),Object(U.jsx)("option",{value:"24",children:"Assignment Phase 24"}),Object(U.jsx)("option",{value:"25",children:"Assignment Phase 25"})]}),h.coursePriority&&Object(U.jsx)("div",{className:"text-danger","data-testid":"course-form-priority-error",children:"This field is required"})]})})}),Object(U.jsx)("div",{className:"col-md-3 col-12",children:Object(U.jsxs)("div",{className:"form-group",children:[Object(U.jsx)(te.a.Label,{children:"Category"}),Object(U.jsxs)("div",{className:"d-flex align-items-center",children:[Object(U.jsx)(te.a.Control,{as:"select",name:"courseCategory",value:n,onChange:$,placeholder:n?"":"No course category",custom:!0,"data-testid":"course-form-category-input",children:0===l.length?Object(U.jsx)("option",{value:"",disabled:!0,children:"No Categories"}):Object(U.jsxs)(U.Fragment,{children:[Object(U.jsx)("option",{value:"",disabled:!0,children:"------------"}),null===l||void 0===l?void 0:l.map((e=>Object(U.jsx)("option",{value:e.id,children:e.name},e.id)))]})}),Object(U.jsx)(we,{})]}),h.courseCategory&&Object(U.jsx)("div",{className:"text-danger","data-testid":"course-form-category-error",children:"This field is required"})]})})]}),Object(U.jsx)("div",{className:"row mb-3",children:Object(U.jsxs)("div",{className:"col-12",children:[Object(U.jsx)(te.a.Label,{children:"Course Description"}),Object(U.jsx)(te.a.Control,{as:"textarea",rows:3,name:"courseDescription",value:r,onChange:$,placeholder:"Write a course description","data-testid":"course-form-description-input"})]})}),Object(U.jsxs)("div",{className:"row mb-3",children:[Object(U.jsx)("div",{className:"col-md-4",children:Object(U.jsxs)(te.a.Group,{controlId:"courseIsAssignedToEveryoneCheckbox",children:[Object(U.jsx)(te.a.Check,{type:"switch",id:"course_is_assigned_to_everyone_switch",label:"Assign to everyone (all current and future staff)",name:"courseIsAssignedToEveryone",checked:p,onChange:e=>$(e,!0),"data-testid":"course-form-assign-to-everyone-checkbox"}),Object(U.jsx)(te.a.Text,{className:"text-muted",children:"This will assign the course to all current and future staff."})]})}),Object(U.jsx)("div",{className:"col-md-4",children:Object(U.jsxs)(te.a.Group,{controlId:"courseHasCertificateCheckbox",children:[Object(U.jsx)(te.a.Check,{type:"switch",id:"course_has_certificate_switch",label:"Has Certificate",name:"courseHasCertificate",checked:j,onChange:e=>$(e,!0),"data-testid":"course-form-has-certificate-checkbox"}),Object(U.jsx)(te.a.Text,{className:"text-muted",children:"If checked, a certificate will be available for users who complete this course."})]})}),Object(U.jsx)("div",{className:"col-md-4",children:Object(U.jsxs)(te.a.Group,{controlId:"courseReassignDuration",children:[Object(U.jsx)(te.a.Label,{children:"Reassignment"}),Object(U.jsx)(te.a.Check,{type:"switch",id:"course_reassign_switch",label:"Reassign on a schedule",checked:R,onChange:t=>{t.target.checked?(e({type:o.yb,name:"courseReassignDuration",payload:12}),Number.isInteger(Number(g))&&0!==Number(g)||e({type:o.yb,name:"courseReassignRepeats",payload:-1})):e({type:o.yb,name:"courseReassignDuration",payload:0})},"data-testid":"course-form-reassign-toggle"}),R&&Object(U.jsxs)(U.Fragment,{children:[Object(U.jsxs)("div",{className:"d-flex align-items-center mt-1",children:[Object(U.jsx)("span",{className:"text-muted mr-2",children:"After"}),Object(U.jsx)(te.a.Control,{type:"number",name:"courseReassignDuration",value:f,onChange:$,min:"1",step:"1",style:{maxWidth:80},"data-testid":"course-form-reassign-duration-input"}),Object(U.jsx)("span",{className:"text-muted ml-2",children:"month(s),"})]}),Object(U.jsxs)("div",{className:"d-flex align-items-center mt-1",children:[Object(U.jsx)("span",{className:"text-muted mr-2",children:"repeat"}),Object(U.jsx)(te.a.Control,{as:"select",name:"courseReassignRepeats",value:g,onChange:t=>{e({type:o.yb,name:"courseReassignRepeats",payload:parseInt(t.target.value,10)})},style:{maxWidth:150},"data-testid":"course-form-reassign-repeats-input",children:[{value:1,label:"One time only"},{value:2,label:"2 times"},{value:3,label:"3 times"},{value:4,label:"4 times"},{value:5,label:"5 times"},{value:6,label:"6 times"},{value:-1,label:"Forever"}].map((e=>Object(U.jsx)("option",{value:e.value,children:e.label},e.value)))})]})]}),Object(U.jsx)(te.a.Text,{className:"text-muted",children:R?1===Number(g)?`Reassigns once, ${f} month(s) after assignment, then never again.`:-1===Number(g)?"Reassigns to staff on this interval, indef
2initely.":`Reassigns ${g} times on this interval.`:"Assigned once \u2014 no automatic reassignment."})]})}),Object(U.jsx)("div",{className:"col-md-4",children:Object(U.jsxs)(te.a.Group,{controlId:"reminderFrequencyDays",children:[Object(U.jsx)(te.a.Label,{children:"Reminder frequency"}),Object(U.jsx)(te.a.Control,{type:"number",name:"courseReminderFrequencyDays",value:v,onChange:$,min:"0",step:"1","data-testid":"course-form-reminder-frequency-input"}),Object(U.jsx)(te.a.Text,{className:"text-muted",children:"Days without progress before sending a reminder email (0 to disable)"})]})})]}),!p&&Object(U.jsxs)(U.Fragment,{children:[Object(U.jsxs)("div",{className:"row mb-3",children:[Object(U.jsx)("div",{className:"col-12 col-md-6",children:Object(U.jsx)(Ce.a,{style:{height:500},classNames:"select basic-single w-100",label:"Assign to Individuals",value:u,handleInputChange:L,name:"individuals",placeholder:"Select Individuals"})}),Object(U.jsx)("div",{className:"col-12 col-md-6",children:Object(U.jsx)(_e.a,{label:"Assign to Divisions/Depts",handleInputChange:L,name:"divisions",defaultValue:d,enableOptionsColor:!0,getDivisionsWithEmployees:!0})})]}),Object(U.jsxs)("div",{className:"row mb-3",children:[Object(U.jsx)("div",{className:"col-12 col-md-6",children:Object(U.jsxs)(te.a.Group,{children:[Object(U.jsx)(te.a.Label,{children:"Assign to Responsibilities"}),Object(U.jsx)(je.a,{className:"basic-single w-100",classNamePrefix:"select",value:m,isDisabled:T,isLoading:T,placeholder:T?"loading...":"Select Responsibilities",isClearable:!0,isMulti:!0,isSearchable:!0,name:"responsibilities",onChange:P,options:_})]})}),Object(U.jsx)("div",{className:"col-12 col-md-6",children:Object(U.jsxs)(te.a.Group,{children:[Object(U.jsx)(te.a.Label,{children:"Assign to Positions"}),Object(U.jsx)(je.a,{className:"basic-single w-100",classNamePrefix:"select",value:b,isDisabled:E,isLoading:E,placeholder:E?"loading...":"Select Positions",isClearable:!0,isMulti:!0,isSearchable:!0,name:"positions",onChange:P,options:N})]})})]})]}),Object(U.jsx)("div",{className:"row mb-3",children:Object(U.jsx)("div",{className:"col-12",children:Object(U.jsxs)(te.a.Group,{controlId:"isScormCourseCheckbox",children:[Object(U.jsx)(te.a.Check,{type:"switch",id:"is_scorm_course_switch",label:"This is a SCORM Course",name:"is_scorm_course",checked:x,onChange:e=>$(e,!0),"data-testid":"course-form-is-scorm-course-checkbox"}),Object(U.jsx)(te.a.Text,{className:"text-muted",children:"If checked, this course will use an uploaded SCORM package instead of manually built sections and articles."})]})})}),x&&Object(U.jsx)("div",{className:"row mb-3",children:Object(U.jsxs)("div",{className:"col-12","data-testid":"course-form-scorm-package-container",children:[Object(U.jsx)(te.a.Label,{children:"SCORM Package (.zip file)"}),O&&!A?Object(U.jsxs)("div",{className:"mb-2",children:[Object(U.jsxs)("p",{className:"mb-1",children:["Current SCORM package: ",Object(U.jsx)("strong",{children:O}),w&&Object(U.jsxs)("small",{className:"text-muted",children:[" (ID: ",w,")"]})]}),Object(U.jsx)(s.a,{variant:"outline-primary",size:"sm",onClick:()=>z(!0),"data-testid":"course-form-replace-package-button",children:"Replace Package"})]}):Object(U.jsx)(U.Fragment,{children:Object(U.jsx)(ke.a,{setVideo:t=>{const n=t&&t.length>0?t[0]:null;e({type:o.yb,payload:n,name:"scorm_file_url"}),z(!0)},small:!0,allTypes:!1,uploadPreset:"scormZip",setOnDeck:()=>{},initialFiles:y?[y]:[]})}),h.scorm_file_url&&Object(U.jsx)("div",{className:"text-danger","data-testid":"course-form-scorm-file-url-error",children:h.scorm_file_url})]})})]})}var Ee=n(915),Ie=n(1117);const Te=e=>e?e.replace(/^###\s+(.*?)$/gm,'<h5 class="mt-3 mb-2">$1</h5>').replace(/^##\s+(.*?)$/gm,'<h6 class="mt-3 mb-2">$1</h6>').replace(/^#\s+(.*?)$/gm,'<h4 class="mt-3 mb-2">$1</h4>').replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/^(\d+\.\s)/gm,"<br><strong>$1</strong>").replace(/^(\*\s)/gm,"<br>\u2022 ").replace(/^(-\s)/gm,"<br>\u2022 ").replace(/\n/g,"<br>"):"";function qe(e){var t,n,r;let{show:o,handleClose:d}=e;const[u,h]=Object(i.useState)(!1),[m,p]=Object(i.useState)(null),[j,f]=Object(i.useState)(null),[g,v]=Object(i.useState)([]),[x,y]=Object(i.useState)(!1),{courseName:O,courseDescription:w,courseSections:_,courseCategory:C}=Object(a.d)((e=>e.knowledgebaseReducer)),N=Object(a.d)((e=>e.account)),k=null===N||void 0===N?void 0:N.user,S=null===k||void 0===k?void 0:k.company,E=e=>e>=8?"success":e>=6?"warning":"danger";return Object(U.jsxs)(B.a,{backdrop:"static",enforceFocus:!1,size:"xl",show:o,onHide:d,children:[Object(U.jsx)(B.a.Header,{closeButton:!0,children:Object(U.jsxs)(B.a.Title,{children:[Object(U.jsx)("i",{className:"feather icon-zap mr-2"}),"Course AI Analysis"]})}),Object(U.jsx)(B.a.Body,{children:Object(U.jsxs)(W.a,{children:[Object(U.jsxs)(Q.a,{md:6,children:[Object(U.jsxs)(c.a,{className:"mb-3",children:[Object(U.jsx)(c.a.Header,{children:Object(U.jsx)("h6",{className:"mb-0",children:"Course Overview"})}),Object(U.jsxs)(c.a.Body,{children:[Object(U.jsxs)("p",{children:[Object(U.jsx)("strong",{children:"Name:"})," ",O||"Not set"]}),Object(U.jsxs)("p",{children:[Object(U.jsx)("strong",{children:"Category:"})," ",C||"Not set"]}),Object(U.jsxs)("p",{children:[Object(U.jsx)("strong",{children:"Sections:"})," ",(null===_||void 0===_?void 0:_.length)||0]}),Object(U.jsxs)("p",{children:[Object(U.jsx)("strong",{children:"Total Items:"})," ",(null===_||void 0===_?void 0:_.reduce(((e,t)=>{var n;return e+((null===(n=t.section_items)||void 0===n?void 0:n.length)||0)}),0))||0]})]})]}),Object(U.jsx)(s.a,{variant:"primary",onClick:async()=>{h(!0),f(null),p(null);try{const t=[],n=[];_.forEach(((e,i)=>{e.section_items&&e.section_items.length>
20&&e.section_items.forEach(((s,a)=>{s.article?(t.push({id:s.article.id,title:s.article.title,sectionId:e.id,sectionTitle:e.title,type:"article",sectionOrder:i,itemOrder:a}),n.push(b.a.fetchArticle(s.article.id))):s.quiz?(t.push({id:s.quiz.id,title:s.quiz.title,sectionId:e.id,sectionTitle:e.title,type:"quiz",sectionOrder:i,itemOrder:a}),n.push(Promise.resolve(s.quiz))):s.file_type&&(t.push({id:s.file_type.id,title:s.file_type.name,sectionId:e.id,sectionTitle:e.title,type:"file_type",sectionOrder:i,itemOrder:a}),n.push(Promise.resolve(s.file_type)))}))}));const i=(await Promise.all(n)).filter((e=>e)).map(((e,n)=>{const i=t[n];if("article"===i.type){const t=document.createElement("div");t.innerHTML=e.body||"";t.querySelectorAll("img").forEach((e=>e.remove()));const n=t.textContent||t.innerText||"";let s="";if(e.transcript){const t=document.createElement("div");t.innerHTML=e.transcript;t.querySelectorAll("img").forEach((e=>e.remove())),s=t.textContent||t.innerText||""}return{...i,content:n.trim(),transcript:s.trim()}}return"quiz"===i.type?{...i,content:e.description||"",questions:e.questions||[]}:"file_type"===i.type?{...i,content:e.description||""}:i})),s={name:O,description:w,category:C,sections:_.map((e=>({title:e.title,items:i.filter((t=>t.sectionId===e.id))})))},a=`\nYou are an expert course designer and training specialist. Analyze the following course structure and content to provide comprehensive insights.\n\nCourse Data:\n${JSON.stringify(s,null,2)}\n\nPlease provide a detailed analysis including:\n\n1. **Course Structure Analysis:**\n   - Overall flow and logical progression\n   - Section organization and sequencing\n   - Content distribution across sections\n\n2. **Content Quality Analysis:**\n   - Depth and comprehensiveness of articles\n   - Quality of quiz questions and assessment methods\n   - Effectiveness of drills and interactive elements\n   - Content relevance and accuracy\n\n3. **Engagement & Interactivity Assessment:**\n   - Variety of content types (articles, quizzes, drills)\n   - Quality and quantity of interactive elements\n   - Assessment methods and their effectiveness\n   - Opportunities for learner engagement\n\n4. **Learning Experience Evaluation:**\n   - Content difficulty and progression\n   - Practical application opportunities\n   - Knowledge retention strategies\n   - Learning objectives alignment\n\n5. **Content Gap Analysis:**\n   - Missing critical topics or concepts\n   - Incomplete learning objectives\n   - Areas that need more depth or coverage\n   - Missing interactive elements\n\n6. **Quality Recommendations:**\n   - Specific improvements for each section\n   - Suggested additional content types\n   - Best practices for course completion\n   - Enhancement opportunities\n\n7. **Risk Assessment:**\n   - Potential learning barriers\n   - Areas of confusion or complexity\n   - Compliance or safety considerations\n\nPay special attention to:\n- Quiz quality and variety of question types\n- Drill effectiveness and practical application\n- Content depth and engagement level\n- Balance between different content types\n- Interactive elements and their effectiveness\n\nRespond in a structured JSON format with the following structure:\n{\n  "summary": "Brief overview of the course with focus on content quality and engagement",\n  "structure_score": 1-10,\n  "content_score": 1-10,\n  "engagement_score": 1-10,\n  "interactivity_score": 1-10,\n  "analysis": {\n    "strengths": ["list of strengths including good content, quizzes, drills"],\n    "weaknesses": ["list of weaknesses including content gaps, poor engagement"],\n    "gaps": ["identified content gaps and missing interactive elements"],\n    "recommendations": ["specific recommendations for improvement"]\n  },\n  "section_analysis": [\n    {\n      "section_title": "section name",\n      "score": 1-10,\n      "content_quality": "assessment of content depth and quality",\n      "interactivity": "assessment of quizzes, drills, and interactive elements",\n      "issues": ["specific issues with content or engagement"],\n      "suggestions": ["improvement suggestions for c
2ontent and interactivity"]\n    }\n  ],\n  "overall_recommendations": ["high-level recommendations for course improvement"]\n}\n`,r=await ne.a.getOpenAIProxy({model:"gpt-4.1-nano",temperature:.3,max_tokens:2e3,messages:[{role:"user",content:a}]});if(!r||!r.data||!r.data.choices||0===r.data.choices.length)throw new Error("No response from AI analysis");const o=r.data.choices[0].message.content.trim();let c;try{c=JSON.parse(o)}catch(e){const t=o.match(/\{[\s\S]*\}/);if(!t)throw new Error("Could not parse AI response as JSON");c=JSON.parse(t[0])}p(c);const l={role:"assistant",content:"\ud83c\udf93 **Course Analysis Complete!**\n\nI've analyzed your course structure and content. You can now ask me about:\n\u2022 Content quality and learning flow\n\u2022 Quiz and drill effectiveness\n\u2022 Engagement and interactive elements\n\u2022 Specific recommendations for improvement\n\u2022 Questions about any course sections or content",timestamp:new Date,isSystem:!0};v((e=>[...e,l]))}catch(t){console.error("Error analyzing course:",t),f(`Failed to analyze course: ${t.message}`)}finally{h(!1)}},disabled:u,className:"mb-3 w-100",children:u?Object(U.jsxs)(U.Fragment,{children:[Object(U.jsx)(l.a,{animation:"border",size:"sm",className:"mr-2"}),"Analyzing Course..."]}):Object(U.jsxs)(U.Fragment,{children:[Object(U.jsx)(xe.o,{className:"mr-2"}),"Analyze Course Structure"]})}),j&&Object(U.jsx)(ee.a,{variant:"danger",className:"mb-3",children:j}),m&&Object(U.jsxs)(c.a,{children:[Object(U.jsx)(c.a.Header,{children:Object(U.jsx)("h6",{className:"mb-0",children:"Analysis Results"})}),Object(U.jsxs)(c.a.Body,{children:[Object(U.jsxs)("div",{className:"mb-3",children:[Object(U.jsx)("h6",{children:"Summary"}),Object(U.jsx)("div",{dangerouslySetInnerHTML:{__html:Te(m.summary)}})]}),Object(U.jsxs)(W.a,{className:"mb-3",children:[Object(U.jsx)(Q.a,{children:Object(U.jsxs)("div",{className:"text-center",children:[Object(U.jsx)("h6",{children:"Structure"}),Object(U.jsxs)(Ee.a,{variant:E(m.structure_score),children:[m.structure_score,"/10"]})]})}),Object(U.jsx)(Q.a,{children:Object(U.jsxs)("div",{className:"text-center",children:[Object(U.jsx)("h6",{children:"Content"}),Object(U.jsxs)(Ee.a,{variant:E(m.content_score),children:[m.content_score,"/10"]})]})}),Object(U.jsx)(Q.a,{children:Object(U.jsxs)("div",{className:"text-center",children:[Object(U.jsx)("h6",{children:"Engagement"}),Object(U.jsxs)(Ee.a,{variant:E(m.engagement_score),children:[m.engagement_score,"/10"]})]})}),Object(U.jsx)(Q.a,{children:Object(U.jsxs)("div",{className:"text-center",children:[Object(U.jsx)("h6",{children:"Interactivity"}),Object(U.jsxs)(Ee.a,{variant:E(m.interactivity_score),children:[m.interactivity_score,"/10"]})]})})]}),m.analysis&&Object(U.jsxs)(U.Fragment,{children:[Object(U.jsxs)("div",{className:"mb-3",children:[Object(U.jsx)("h6",{children:"Strengths"}),Object(U.jsx)("div",{dangerouslySetInnerHTML:{__html:(null===(t=m.analysis.strengths)||void 0===t?void 0:t.map(((e,t)=>`<div class="mb-1">\u2022 ${Te(e)}</div>`)).join(""))||""}})]}),Object(U.jsxs)("div",{className:"mb-3",children:[Object(U.jsx)("h6",{children:"Areas for Improvement"}),Object(U.jsx)("div",{dangerouslySetInnerHTML:{__html:(null===(n=m.analysis.weaknesses)||void 0===n?void 0:n.map(((e,t)=>`<div class="mb-1">\u2022 ${Te(e)}</div>`)).join(""))||""}})]}),Object(U.jsxs)("div",{className:"mb-3",children:[Object(U.jsx)("h6",{children:"Content Gaps"}),Object(U.jsx)("div",{dangerouslySetInnerHTML:{__html:(null===(r=m.analysis.gaps)||void 0===r?void 0:r.map(((e,t)=>`<div class="mb-1">\u2022 ${Te(e)}</div>`)).join(""))||""}})]})]})]})]})]}),Object(U.jsx)(Q.a,{md:6,children:Object(U.jsxs)(c.a,{children:[Object(U.jsx)(c.a.Header,{children:Object(U.jsx)("h6",{className:"mb-0",children:"AI Assistant Chat"})}),Object(U.jsx)(c.a.Body,{children:Object(U.jsx)(Ie.a,{onSendMessage:async e=>{if(!e.trim())return;y(!0);const t={role:"user",content:e,timestamp:new Date};
2v((e=>[...e,t]));try{const t=[],n=[];_.forEach(((e,i)=>{e.section_items&&e.section_items.length>0&&e.section_items.forEach(((s,a)=>{s.article?(t.push({id:s.article.id,title:s.article.title,sectionId:e.id,sectionTitle:e.title,type:"article",sectionOrder:i,itemOrder:a}),n.push(b.a.fetchArticle(s.article.id))):s.quiz?(t.push({id:s.quiz.id,title:s.quiz.title,sectionId:e.id,sectionTitle:e.title,type:"quiz",sectionOrder:i,itemOrder:a}),n.push(Promise.resolve(s.quiz))):s.file_type&&(t.push({id:s.file_type.id,title:s.file_type.name,sectionId:e.id,sectionTitle:e.title,type:"file_type",sectionOrder:i,itemOrder:a}),n.push(Promise.resolve(s.file_type)))}))}));const i=(await Promise.all(n)).filter((e=>e)).map(((e,n)=>{const i=t[n];if("article"===i.type){const t=document.createElement("div");t.innerHTML=e.body||"";t.querySelectorAll("img").forEach((e=>e.remove()));const n=t.textContent||t.innerText||"";let s="";if(e.transcript){const t=document.createElement("div");t.innerHTML=e.transcript;t.querySelectorAll("img").forEach((e=>e.remove())),s=t.textContent||t.innerText||""}return{...i,content:n.trim(),transcript:s.trim()}}return"quiz"===i.type?{...i,content:e.description||"",questions:e.questions||[]}:"file_type"===i.type?{...i,content:e.description||""}:i})),s={name:O,description:w,sections:_.map((e=>({title:e.title,items:i.filter((t=>t.sectionId===e.id))})))},a=`\nYou are an AI assistant helping with course design and analysis. \n\nCourse Context:\n${JSON.stringify(s,null,2)}\n\nCompany Business Context:\n${null!==S&&void 0!==S&&S.company_information?JSON.stringify(S.company_information,null,2):"No additional business context available"}\n\n${m?`\nPREVIOUS ANALYSIS AVAILABLE:\nThe following analysis was previously performed and is available for reference:\n\nSummary: ${m.summary||"Not available"}\n\n${m.analysis?`\nContent Quality: ${m.analysis.content_quality||"Not available"}\nLearning Flow: ${m.analysis.learning_flow||"Not available"}\nEngagement: ${m.analysis.engagement||"Not available"}\nGaps: ${m.analysis.gaps?m.analysis.gaps.join(", "):"Not available"}\nRecommendations: ${m.analysis.recommendations?m.analysis.recommendations.join(", "):"Not available"}\n`:""}\n\nYou can reference this analysis when answering questions about course quality, flow, engagement, or recommendations.\n`:""}\n\nUser Question: ${e}\n\nPlease provide a helpful, specific answer based on the course structure and actual content. \n\nKeep responses focused on specifically what was asked for in the User Question and don't go outside of that scope to give advice that wasn't asked for.\n\n${m?"If the user asks about the previous analysis, quality scores, gaps, or recommendations, reference the analysis data provided above.":""}\nUse the company business context to provide more relevant insights when appropriate.\n`,r=await ne.a.getOpenAIProxy({model:"gpt-4.1-nano",temperature:.7,max_tokens:1e3,messages:[{role:"user",content:a}]});if(!r||!r.data||!r.data.choices||0===r.data.choices.length)throw new Error("No response from AI");const o={role:"assistant",content:r.data.choices[0].message.content.trim(),timestamp:new Date};
2v((e=>[...e,o]))}catch(n){console.error("Error asking AI:",n);const e={role:"assistant",content:`Error: ${n.message}`,timestamp:new Date,isError:!0};v((t=>[...t,e]))}finally{y(!1)}},chatHistory:g,isLoading:x,placeholder:"Ask about your course...",title:"Course AI Assistant",showTitle:!1,maxHeight:"300px",analysisData:m})})]})})]})}),Object(U.jsx)(B.a.Footer,{children:Object(U.jsx)(s.a,{variant:"secondary",onClick:d,children:"Close"})})]})}var Ae=n(871);var ze=e=>{let{onCreate:t}=e;const[n,a]=Object(i.useState)(""),[r,o]=Object(i.useState)(!1),[d,u]=Object(i.useState)(!1),[h,m]=Object(i.useState)(""),[p,j]=Object(i.useState)(null),[f,g]=Object(i.useState)(""),[v,x]=Object(i.useState)([]),[y,O]=Object(i.useState)({}),[w,_]=Object(i.useState)(!1),[C,N]=Object(i.useState)([]),[k,S]=Object(i.useState)(""),[E,I]=Object(i.useState)([]),[T,q]=Object(i.useState)(0),[A,z]=Object(i.useState)(0),[L,$]=Object(i.useState)(!0),[P,R]=Object(i.useState)(2),M=Object(i.useRef)({}),F=Object(i.useRef)({}),D=Object(ve.v)(n);Object(i.useEffect)((()=>{(async()=>{try{const e=await b.a.getArticleCategoriesSimple({simple_details:!0}),t=((null===e||void 0===e?void 0:e.results)||e||[]).map((e=>e.name||e.title)).filter(Boolean);N(t),!k&&t&&t.length>0&&S(t[0])}catch(e){}})()}),[]),Object(i.useEffect)((()=>{if(window.YT&&window.YT.Player)return void _(!0);if(document.getElementById("youtube-iframe-api"))return;const e=document.createElement("script");e.id="youtube-iframe-api",e.src="https://www.youtube.com/iframe_api",document.body.appendChild(e),window.onYouTubeIframeAPIReady=function(){_(!0)}}),[]),Object(i.useEffect)((()=>()=>{Object.values(F.current).forEach((e=>clearInterval(e))),Object.values(M.current).forEach((e=>{try{e.destroy()}catch(t){}})),F.current={},M.current={}}),[]);const B=e=>{const t=Math.max(0,Math.floor(e||0));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,"0")}`},H=e=>{if(!E||0===E.length)return e.transcript||"";const t=Number(P||0),n=Number(e.start_time||0),i=Number(e.end_time||0);return E.filter((e=>e.start<=i+t&&e.end>=n-t)).map((e=>e.text)).join("\n").trim()},G=(e,t,n)=>{let i=Math.max(0,t),s=Math.max(i+5,n);if(L&&E.length>0){const e=.5;let t=i,n=s;E.forEach((a=>{Math.abs(a.start-i)<Math.abs(t-i)&&Math.abs(a.start-i)<=e&&(t=a.start),Math.abs(a.end-s)<Math.abs(n-s)&&Math.abs(a.end-s)<=e&&(n=a.end)})),i=t,s=Math.max(i+5,n)}T&&(i=Math.min(i,T-5),s=Math.min(Math.max(s,i+5),T));const a=[...v],r={...a[e],start_time:i,end_time:s};r.transcript=H(r),r.captions_transcript=r.transcript,a[e]=r,x(a)},J=e=>{if(e<0||e>=v.length-1)return;const t=v[e],n=v[e+1],i={...t,end_time:Math.max(t.end_time,n.end_time),title:t.title||n.title||`Segment ${e+1}`};i.transcript=H(i);const s=[...v.slice(0,e),i,...v.slice(e+2)];x(s),z(e)},Y=()=>{const e=A;if(e<0||e>=v.length)return;const t=v[e],n=(Number(t.start_time)+Number(t.end_time))/2;if(n-t.start_time<5||t.end_time-n<5)return;const i={...t,end_time:n};i.transcript=H(i);const s={...t,start_time:n,title:t.title};s.transcript=H(s);const a=[...v.slice(0,e),i,s,...v.slice(e+1)];x(a),z(e)};Object(i.useEffect)((()=>{const e=e=>{if(!p)return;if(["INPUT","TEXTAREA"].includes((e.target||{}).tagName))return;const t=e.altKey?.1:e.shiftKey?.5:.2;if("ArrowLeft"===e.key){const e=v[A];if(!e)return;G(A,e.start_time-t,e.end_time-t)}else if("ArrowRight"===e.key){const e=v[A];if(!e)return;G(A,e.start_time+t,e.end_time+t)}else"m"===e.key.toLowerCase()?J(A):"s"===e.key.toLowerCase()&&Y()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)}),[v,A,L,P,p]);const V=e=>new Date(1e3*(Number(e)||0)).toISOString().substr(14,5),K=e=>`yt-segment-${e}`,X=(e,t,n)=>{F.current[e]&&clearInterval(F.current[e]),F.current[e]=setInterval((()=>{const i=M.current[e];if(!i||"function"!==typeof i.getCurrentTime)return;const s=i.getCurrentTime(),a=Math.max(0,Math.floor(Number(t)||0)),r=Math.max(0,Math.floor(Number(n)||0));s<a-.2?i.seekTo(a,!0):r&&s>=r&&(i.pauseVideo(),i.seekTo(a,!0))}),250)},Z=(e,t,n,i)=>{if(!w||!D)return;const s=K(e);if(document.getElementById(s)){if(M.current[e]){try{M.current[e].destroy()}catch(a){}M.current[e]=null}M.current[e]=new window.YT.Player(s,{videoId:D,height:"100%",width:"100%",playerVars:{start:Math.max(0,Math.floor(Number(t)||0)),end:Math.max(0,Math.floor(Number(n)||0))||void 0,rel:0,modestbranding:1,controls:1},events:{onReady:s=>
2{X(e,t,n),i&&s.target.playVideo()},onStateChange:e=>{if(e.data===window.YT.PlayerState.ENDED){const n=Math.max(0,Math.floor(Number(t)||0));e.target.seekTo(n,!0),e.target.pauseVideo()}}}})}};Object(i.useEffect)((()=>{w&&Object.keys(y).forEach((e=>{const t=Number(e);if(y[t]&&!M.current[t]){const e=v[t]||{};Z(t,e.start_time,e.end_time,!1)}}))}),[w]),Object(i.useEffect)((()=>{Object.keys(M.current).forEach((e=>{const t=Number(e),n=M.current[t],i=v[t];if(n&&i)try{n.cueVideoById({videoId:D,startSeconds:Math.max(0,Math.floor(Number(i.start_time)||0)),endSeconds:Math.max(0,Math.floor(Number(i.end_time)||0))||void 0}),X(t,i.start_time,i.end_time)}catch(s){}}))}),[v]);const ne=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"w-100";return Object(U.jsx)(s.a,{variant:"primary",className:`mb-3 ${e}`,disabled:d||!v||0===v.length,onClick:async()=>{if("function"===typeof t){u(!0);try{const e=(k||f||"YouTube Import").trim();await t({youtubeUrl:n,videoTitle:f,segments:v,category:e})}catch(e){m("Failed to create articles from segments.")}finally{u(!1)}}},children:d?"Creating...":"Create Course from Segments"})},ie=Object(i.useRef)(null),se=Object(i.useRef)(null),ae=e=>{e!==A&&(Object.keys(M.current).forEach((t=>{const n=Number(t);if(n!==e&&M.current[n]){try{M.current[n].destroy()}catch(i){}delete M.current[n]}})),z(e))},re=(e,t,n)=>{const i=v[t];i&&(ie.current={index:t,edge:n,startX:e.clientX,initStart:i.start_time,initEnd:i.end_time},ae(t),e.preventDefault())};Object(i.useEffect)((()=>{const e=e=>{const t=ie.current;t&&(se.current||(se.current=requestAnimationFrame((()=>{se.current=null;const n=e.clientX-t.startX,i=document.getElementById("yt-timeline-bar");if(!i||!T)return;const s=n/(i.getBoundingClientRect().width||1)*T,a=[...v],r=t.initStart+("start"===t.edge?s:0),o=t.initEnd+("end"===t.edge?s:0);let c=Math.max(0,r),l=Math.max(c+5,o);T&&(c=Math.min(c,T-5),l=Math.min(Math.max(l,c+5),T)),a[t.index]={...a[t.index],start_time:c,end_time:l},x(a),t.startX=e.clientX,t.initStart=c,t.initEnd=l}))))},t=()=>{const e=ie.current;if(ie.current=null,e){const t=v[e.index];if(t){const n={...t};n.transcript=H(n),n.captions_transcript=n.transcript;const i=[...v];i[e.index]=n,x(i)}}};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}}),[v,T,L,P]);const oe=()=>{if(!v||0===v.length)return null;const e=T||Math.max(...v.map((e=>Number(e.end_time||0))));return Object(U.jsxs)("div",{children:[Object(U.jsxs)("div",{className:"d-flex align-items-center mb-2",children:[Object(U.jsx)("div",{className:"mr-3",children:Object(U.jsx)(te.a.Check,{type:"switch",id:"snap-toggle",label:"Snap to captions",checked:L,onChange:e=>$(e.target.checked)})}),Object(U.jsxs)("div",{className:"mr-2",children:["Padding: ",P.toFixed(1),"s"]}),Object(U.jsx)(te.a.Control,{type:"range",min:0,max:3,step:.1,value:P,onChange:e=>R(parseFloat(e.target.value)),style:{maxWidth:200}}),Object(U.jsx)(s.a,{className:"ml-3 mr-2",size:"sm",variant:"outline-primary",onClick:()=>J(A),children:"Merge \u2192"}),Object(U.jsx)(s.a,{size:"sm",variant:"outline-primary",onClick:Y,children:"Split"}),v[A]&&Object(U.jsxs)("div",{className:"ml-3 small text-muted",children:["Selected: ",Object(U.jsx)("strong",{children:v[A].title||`Segment ${A+1}`})," ","(",B(v[A].start_time),"\u2013",B(v[A].end_time),")"]})]}),Object(U.jsx)("div",{id:"yt-timeline-bar",style:{position:"relative",height:32,background:"#f1f3f5",borderRadius:4},children:v.map(((t,n)=>{const i=Number(t.start_time)/e*100+"%",s=(Number(t.end_time)-Number(t.start_time))/e*100+"%",a=n===A;return Object(U.jsxs)("div",{onClick:()=>ae(n),style:{position:"absolute",left:i,width:s,top:4,bottom:4,background:a?"#1c7ed6":"#74c0fc",borderRadius:3,cursor:"pointer",opacity:a?1:.6,boxShadow:a?"0 0 0 2px #1971c2":void 0},title:`${t.title||`Segment ${n+1}`} (${B(t.start_time)} - ${B(t.end_time)})`,children:[Object(U.jsx)("div",{onMouseDown:e=>re(e,n,"start"),style:{position:"absolute",left:0,top:-2,bottom:-2,width:6,background:"#1971c2",cursor:"ew-resize",borderRadius:2}}),Object(U.jsx)("div",{onMouseDown:e=>re(e,n,"end"),style:{position:"absolute",right:0,top:-2,bottom:-2,width:6,background:"#1971c2",cursor:"ew-resize",borderRadius:2}})]},n)}))}),Object(U.jsxs)("div",{className:"d-flex justify-content-between mt-1",style:{fontSize:12},children:[Object(U.jsx)("div",{children:B(0)}),Object(U.jsx)("div",{children:B(e)})]})]})};return Object(U.jsxs)("div",{children:[Object(U.jsx)(W.a,{className:"mb-3",children:Object(U.jsx)(Q.a,{children:Object(U.jsxs)(Ae.a,{children:[Object(U.jsx)(te.a.Control,{type:"text",placeholder:"Enter YouTube URL",value:n,onChange:e=>a(e.target.value),disabled:r}
2),Object(U.jsx)(s.a,{onClick:async()=>{if(D){o(!0),m(""),j(null);try{const e=await b.a.analyzeYouTubeVideo(n);if(e&&"object"===typeof e){j(e),g(e.video_title||"");const t=e.segments||[],n=Array.isArray(e.supadata_transcript||e.supadata_trascript)?e.supadata_transcript||e.supadata_trascript:[];let i=t;if(Array.isArray(n)&&n.length>0){const e=n.map((e=>{const t=void 0!==e.offset||void 0!==e.duration;return{start:t?Number(e.offset||0)/1e3:Number(e.start||e.start_time||0),end:t?(Number(e.offset||0)+Number(e.duration||0))/1e3:Number(e.end||e.end_time||Number(e.start||0)+Number(e.duration||0)),text:e.text||e.caption||""}}));I(e);const s=e.length>0?Math.max(...e.map((e=>e.end))):0,a=t.length>0?Math.max(...t.map((e=>Number(e.end_time||0)))):0;q(Math.max(s,a));const r=2;i=t.map((t=>{const n=Number(t.start_time||0),i=Number(t.end_time||n+999999),s=e.filter((e=>e.start<=i+r&&e.end>=n-r)).map((e=>e.text)).join("\n").trim();return{...t,captions_transcript:s,transcript:s}}))}else I([]),q(t.length>0?Math.max(...t.map((e=>Number(e.end_time||0)))):0),i=t.map((e=>({...e,captions_transcript:"",transcript:""})));x(i),O({}),z(0),Object.values(F.current).forEach((e=>clearInterval(e))),Object.values(M.current).forEach((e=>{try{e.destroy()}catch(t){}})),F.current={},M.current={},!k&&(e.video_title||"").trim()&&S(e.video_title.trim())}else m("Failed to analyze the video. Please check the URL and try again.")}catch(e){m("An unexpected error occurred while analyzing the video.")}finally{o(!1)}}else m("Please enter a valid YouTube URL.")},disabled:r||!n,children:r?Object(U.jsx)(l.a,{as:"span",animation:"border",size:"sm"}):"Analyze"})]})})}),h&&Object(U.jsx)(ee.a,{variant:"danger",children:h}),p&&Object(U.jsxs)(U.Fragment,{children:[Object(U.jsxs)("div",{className:"d-flex justify-content-between align-items-center mb-2",children:[Object(U.jsx)("h5",{className:"mb-0",children:f}),ne("")]}),Object(U.jsxs)(te.a.Group,{className:"mb-3",children:[Object(U.jsx)(te.a.Label,{children:"Category for all new articles"}),Object(U.jsx)(te.a.Control,{list:"kb-article-categories",type:"text",placeholder:"Type or select a category",value:k,onChange:e=>S(e.target.value)}),Object(U.jsx)("datalist",{id:"kb-article-categories",children:(C||[]).map(((e,t)=>Object(U.jsx)("option",{value:e},t)))}),Object(U.jsx)(te.a.Text,{className:"text-muted",children:"If the name matches an existing category, it will be used; otherwise a new category will be created."})]}),Object(U.jsx)(oe,{}),(v||[]).map(((e,t)=>{const n=!!y[t],i=e.captions_transcript||e.transcript||"No transcript available",s=t===A;return Object(U.jsx)(c.a,{className:"mb-3",style:{borderColor:s?"#1c7ed6":void 0,boxShadow:s?"0 0 0 2px #1c7ed6":void 0},children:Object(U.jsx)(c.a.Body,{children:Object(U.jsxs)(W.a,{children:[Object(U.jsx)(Q.a,{md:6,className:"mb-3 mb-md-0",children:Object(U.jsxs)(te.a.Group,{className:"mb-0",children:[Object(U.jsx)(te.a.Label,{children:"Transcript"}),Object(U.jsx)("div",{style:{maxHeight:300,overflowY:"auto",whiteSpace:"pre-wrap"},children:i})]})}),Object(U.jsxs)(Q.a,{md:6,children:[s&&Object(U.jsx)("div",{className:"mb-1",children:Object(U.jsx)("span",{className:"badge badge-primary",children:"Selected"})}),Object(U.jsx)("div",{className:"mb-2",style:{position:"relative",paddingTop:"56.25%"},children:n?Object(U.jsx)("div",{id:K(t),style:{position:"absolute",top:0,left:0,width:"100%",height:"100%"}}):Object(U.jsx)("button",{type:"button",onClick:()=>{(e=>{O((t=>({...t,[e]:!0})))})(t),ae(t),setTimeout((()=>Z(t,e.start_time,e.end_time,!0)),0)},style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",background:`url(${D?`https://img.youtube.com/vi/${D}/hqdefault.jpg`:""}) center / cover no-repeat`,border:"none",cursor:"pointer"},children:Object(U.jsx)("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(0,0,0,0.6)",borderRadius:"50%",width:64,height:64,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:24},children:"\u25b6"})})}),Object(U.jsxs)(te.a.Group,{className:"mb-2",children:[Object(U.jsx)(te.a.Label,{children:"Title"}),Object(U.jsx)(te.a.Control,{type:"text",value:e.title,onChange:e=>{const n=[...v];n[t]={...n[t],title:e.target.value},x(n)},onFocus:()=>ae(t)})]}),Object(U.jsxs)(W.a,{children:[Object(U.jsx)(Q.a,{children:Object(U.jsxs)(te.a.Group,{children:[Object(U.jsx)(te.a.Label,{children:"Start"}),Object(U.jsx)(te.a.Control,{type:"number",value:e.start_time,onChange:n=>G(t,parseFloat(n.target.value||0),e.end_time),onFocus:()=>ae(t)})]})}),Object(U.jsx)(Q.a,{children:Object(U.jsxs)(te.a.Group,{children:[Object(U.jsx)(te.a.Label,{children:"End"}),Object(U.jsx)(te.a.Control,{type:"number",value:e.end_time,onChange:n=>G(t,e.start_time,parseFloat(n.target.value||0)),onFocus:()=>ae(t)})]})})]}),Object(U.jsxs)("div",{className:"text-muted small mt-1",children:[V(e.start_time)," - ",V(e.end_time)]})]})]})})},t)})),ne("w-100")]})]})};var Le=e=>{let{show:t,handleClose:n,onCreate:i}=e;return Object(U.jsxs)(B.a,{show:t,onHide:n,size:"xl",backdrop:"static",enforceFocus:!1,children:[Object(U.jsx)(B.a.Header,{closeButton:!0,children:Object(U.jsx)(B.a.Title,{children:"Create Course from YouTube"})}),Object(U.jsx)(B.a.Body,{children:Object(U.jsx)(ze,{onCreate:i})}),Object(U.jsx)(B.a.Footer,{children:Object(U.jsx)(s.a,{variant:"secondary",onClick:n,children:"Close"})})]})};function $e(e){let{submitDataToServer:t,isCreate:n}=e;const c=Object(a.c)(),{courseName:l,courseCategory:d,coursePriority:u,courseSections:h,is_scorm_course:m,scorm_file_url:p}=Object(a.d)((e=>e.knowledgebaseReducer)),[j,f]=Object(i.useState)(!1),[,g]=Object(i.useState)(!1),[v,x]=Object(i.useState)(!1),[y,O]=Object(i.useState)(!1),w=Object(r.useHistory)(),_=async e=>{e.preventDefault(),f(!0);if((()=>{let e=!0,t={courseName:"",courseCategory:"",coursePriority:"",courseSections:"",scorm_file_url:""};if(l||(t.courseName="error",e=!1),d||(t.courseCategory="error",e=!1),u||(t.coursePriority="error",e=!1),m)(p||n)&&(p||(t.scorm_file_url="A SCORM package URL is required for SCORM courses.",e=!1));else if(!m)if(h.length>0){for(var i=0;i<h.length;i++)if(!h[i].title){e=!1,t.courseSections="Each course section must have a title";break}}else e=!1,t.courseSections="Course should have at least one section";return c({type:o.ob,payload:t}),e})()){const e=await t();f(!1),e&&w.push("/knowledgebase/courses")}else window.scrollTo(0,0),f(!1)};return Object(U.jsxs)("form",{method:"post",onSubmit:_,children:[Object(U.jsxs)("div",{className:"card",children:[Object(U.jsxs)("div",{className:"card-header pb-2",children:[Object(U.jsx)("h5",{children:n?"Create Course":`Edit Course: ${l}`}),Object(U.jsxs)("div",{className:"float-right",children:[Object(U.jsxs)(s.a,{variant:"outline-primary",className:"mr-2",onClick:()=>x(!0),disabled:j,children:[Object(U.jsx)("i",{className:"feather icon-zap mr-1"}),"AI Analysis"]}),Object(U.jsxs)(s.a,{variant:"outline-primary",className:"mr-2",onClick:()=>O(!0),disabled:j,children:[Object(U.jsx)("i",{className:"feather icon-youtube mr-1"}),"From YouTube"]}),Object(U.jsx)(s.a,{variant:"primary",type:"submit",disabled:j,"data-testid":"course-builder
2-form-submit-button",children:j?"Submitting...":n?"Create Course":"Update Course"})]})]}),Object(U.jsx)("div",{className:"pt-1 pb-3 px-3 ",children:Object(U.jsx)(Se,{})})]}),!m&&Object(U.jsx)(pe,{handleSubmit:_,submitting:j,isCreate:n,setIsExpanded:g}),Object(U.jsx)(qe,{show:v,handleClose:()=>x(!1)}),Object(U.jsx)(Le,{show:y,handleClose:()=>O(!1),onCreate:async e=>{let{youtubeUrl:t,videoTitle:n,segments:i,category:s}=e;const a=i.map(((e,n)=>{const i=Math.max(0,Math.floor(Number(e.start_time)||0)),a=Math.max(0,Math.floor(Number(e.end_time)||0)),r=a?`https://www.youtube.com/embed/${Object(ve.v)(t)}?start=${i}&end=${a}`:`https://www.youtube.com/embed/${Object(ve.v)(t)}?start=${i}`,o=e.transcript||e.text||e.segment_transcript||"",c=`<div><iframe width="560" height="315" src="${r}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>`;return{title:e.title||`Segment ${n+1}`,body:c,category:s,transcript:o}})),r=await b.a.bulkCreateArticles(a),l=Array.isArray(r)?r.filter((e=>e&&e.id)):Array.isArray(null===r||void 0===r?void 0:r.created_articles)?r.created_articles.filter((e=>e&&e.id)):[];if(0===l.length)return;const d=h[0],u=(d&&(!d.title||""===d.title.trim())&&(!d.section_items||0===d.section_items.length)?h.slice(1):h.slice()).map(((e,t)=>({...e,id:t+1,order:t+1}))),m=u.length,p=l.map(((e,t)=>({id:m+t+1,order:m+t+1,title:e.title,section_items:[{id:e.id,type:"ARTICLE",article:{id:e.id,title:e.title},quiz:null,file_type:null}]})));c({type:o.tb,payload:[...u,...p]}),O(!1)}})]})}},1965:function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return d}));var i=n(1),s=n(19),a=n(1369),r=n(43),o=n(11),c=n(1328),l=n(3);function d(){const e=Object(s.c)(),t=Object(c.a)();return Object(i.useEffect)((()=>{e({type:o.h})}),[]),Object(l.jsx)(a.a,{submitDataToServer:async()=>{const n=t({isCreate:!0});return!!await r.a.createCourse(n)&&(e({type:o.h}),!0)},isCreate:!0})}},898:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(76),s=(n(1),n(837)),a=n(3);function r(){return Object(a.jsxs)(s.a.Body,{"data-testid":"article-detail-skeleton-loader",children:[Object(a.jsx)(i.a,{variant:"rect",height:25,width:"80%"}),Object(a.jsx)(i.a,{variant:"rect",width:"50%",className:"mt-2 mb-3",animation:!1}),Object(a.jsx)(i.a,{variant:"rect",height:570,animation:"wave"})]})}},900:function(e,t,n){"use strict";n.d(t,"c",(function(){return a})),n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return c}));n(961);var i=n(1005);function s(){document.querySelectorAll(".printhide").forEach((function(e){e.classList.contains("d-none")?e.classList.remove("d-none"):e.classList.add("d-none")}))}const a=(e,t)=>{const n=new i.jsPDF("landscape","mm","letter");n.addFileToVFS("FontAwesome.ttf","base64-encoded-font-string"),n.addFont("FontAwesome.ttf","FontAwesome","normal"),n.setFont("FontAwesome"),n.text(20,20,"\uf002"),n.html(e,{callback:function(e){const n=t||"generated";e.save(`${n}.pdf`)},x:10,y:10,width:259.4,windowWidth:1056})},r=async(e,t,n)=>{s();try{var a;const r=new i.jsPDF("p","mm","a4"),c=o(t.innerHTML),l=`\n            <div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; max-width: 100%; padding: 0; background: white;">\n                <div style="padding: 10px; margin-bottom: 0;">\n                    <div style="border-left: 4px solid #04a9f5; margin-left: -15px;">\n                        <h1 style="margin: 0 0 10px 0; font-size: 30px; padding-left: 10px; font-weight: 700; color: #212529; line-height: 1.2;">${(null===e||void 0===e?void 0:e.title)||"Article"}</h1>\n                    </div>\n                    <div style="color: #6c757d; font-size: 18px;">\n                    ${null!==e&&void 0!==e&&e.author?`<span>${e.author}</span>`:""}\n                    ${null!==e&&void 0!==e&&e.published_on?`<span> | ${new Date(e.published_on).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"2-digit"})}</span>`:""}
2\n                    ${null!==e&&void 0!==e&&e.version?`<span> | Version ${e.version}</span>`:""}\n                    ${(null===e||void 0===e?void 0:e.version)>1&&null!==e&&void 0!==e&&e.last_edited_on?`<span> | Last updated: ${new Date(e.last_edited_on).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"2-digit"})}</span>`:""}\n                    ${null!==e&&void 0!==e&&null!==(a=e.type_info)&&void 0!==a&&a.type?`<span> | <span style="color: ${e.type_info.color||"#007bff"};">${e.type_info.type}</span></span>`:""}\n                    </div>\n                </div>\n                <div style="padding: 10px; line-height: 1.6; color: #333; background: white;">\n                    ${c}\n                </div>\n            </div>\n        `;await r.html(l,{callback:function(e){const t=n||"article";e.save(`${t}.pdf`)},x:10,y:10,width:170,windowWidth:800,margin:[10,10,10,10],autoPaging:"text",html2canvas:{allowTaint:!0,useCORS:!0}})}catch(r){console.error("Error generating PDF:",r),alert("Error generating PDF. Please try again.")}finally{s()}};function o(e){return e?e.replace(/<ul>/g,'<ul style="list-style-type: disc; padding-left: 2em; margin: 1em 0;">').replace(/<ol>/g,'<ol style="list-style-type: decimal; padding-left: 2em; margin: 1em 0;">').replace(/<li>/g,'<li style="display: list-item; margin: 0.5em 0;">').replace(/<table>/g,'<table style="border-collapse: collapse; width: 100%; margin: 1em 0;">').replace(/<th>/g,'<th style="border: 1px solid #ddd; padding: 8px; text-align: left; background-color: #f8f9fa; font-weight: bold;">').replace(/<td>/g,'<td style="border: 1px solid #ddd; padding: 8px; text-align: left;">').replace(/<p>/g,'<p style="margin: 1em 0;">').replace(/<h1>/g,'<h1 style="margin: 1em 0; font-size: 2em; font-weight: bold;">').replace(/<h2>/g,'<h2 style="margin: 1em 0; font-size: 1.6em; font-weight: bold;">').replace(/<h3>/g,'<h3 style="margin: 1em 0; font-size: 1.17em; font-weight: bold;">').replace(/<h4>/g,'<h4 style="margin: 1em 0; font-weight: bold;">').replace(/<h5>/g,'<h5 style="margin: 1em 0; font-size: 0.83em; font-weight: bold;">').replace(/<h6>/g,'<h6 style="margin: 1em 0; font-size: 0.67em; font-weight: bold;">'):""}const c=async function(e,t,n,a,r){let c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"",l=arguments.length>6&&void 0!==arguments[6]&&arguments[6];s();const d=(new Date).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"}),u=null!==e&&void 0!==e&&e.published_on?new Date(e.published_on).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"}):"",h=null!==t&&void 0!==t&&t.timestamp?new Date(t.timestamp).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"}):"",m=null!==e&&void 0!==e&&e.version?`Version ${e.version}`:"",b=l?`This attestation applies to the version of the policy edited on ${u}${m?` (${m})`:""}.`:`This attestation applies to the policy${u?` edited on ${u}`:""}.`;let p="";if(1===(null===t||void 0===t?void 0:t.question_type)&&null!==t&&void 0!==t&&t.signature_image){p=`<img src="${t.signature_image.startsWith("http")?t.signature_image:((null===c||void 0===c?void 0:c.replace(/\/$/,""))||"")+t.signature_image}" width="120" alt="signature" style="display:block;margin:8px 0;" />`}else if(2===(null===t||void 0===t?void 0:t.question_type)&&null!==t&&void 0!==t&&t.question){const e=(t.answer||"").split(",").map((e=>e.trim())).filter(Boolean);p=`\n            <p style="margin:0 0 4px 0;font-weight:bold;">${t.question}</p>\n            <div style="margin-bottom:12px;">\n                ${e.map((e=>`<p style="margin:0 0 2px 0;font-size:11px;">${e}</p>`)).join("")}\n            </div>\n        `}const j=o((null===e||void 0===e?void 0:e.body)||""),f=`\n        <div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; max-width: 100%; padding: 0; background: white;">\n            <div style="padding: 10px; margin-bottom: 0;">\n                <div style="border-left: 4px solid #04a9f5; margin-left: -15px;">\n                    <h1 style="margin: 0 0 10px 0; font-size: 30px; padding-left: 10px; font-weight: 700; color: #212529; line-height: 1.2;">Certificate of Acknowledgement</h1>\n                </div>\n                <div style="color: #6c757d; font-size: 16px; margin-bottom: 10px;">
2\n                    <span>${a||""}</span>\n                    <span style="float:right;">${d}</span>\n                </div>\n                <div style="clear: both;"></div>\n                <h2 style="margin: 12px 0 10px 0; font-size: 24px; font-weight: 600; color: #212529; line-height: 1.3;">${(null===e||void 0===e?void 0:e.title)||""}</h2>\n                <p style="margin: 0 0 15px 0; font-size: 12px; color: #555;">${b}</p>\n            </div>\n            <hr style="margin: 15px 0; border: 0; border-top: 1px solid #eee;" />\n            <p style="margin: 0 0 14px 0; font-weight: bold; font-size: 12px;">FULL ARTICLE CONTENT (as attested)</p>\n            <div style="margin-top: 6px; padding: 12px 10px; line-height: 1.6; color: #333; background: white;">\n                ${j}\n            </div>\n            <hr style="margin: 20px 0; border: 0; border-top: 1px solid #ddd;" />\n            <p style="margin: 0 0 12px 0; font-weight: bold; font-size: 12px;">ATTESTATION</p>\n            <div style="margin-top: 15px; padding-top: 15px; border-top: 1px solid #eee;">\n                ${p}\n                <p style="margin: 8px 0;">\n                    User ${n||""} Acknowledged and Marked as Read on : ${h}\n                </p>\n                <small style="color: #666;">\n                    Certified by Humanagement.io on ${d}\n                    for the version of the policy edited on ${u}\n                </small>\n            </div>\n        </div>\n    `;try{const e=new i.jsPDF("p","mm","a4");await e.html(f,{callback:function(e){const t=r||"attestation";e.save(`${t}.pdf`)},x:10,y:10,width:170,windowWidth:800,margin:[10,10,10,10],autoPaging:"text",html2canvas:{allowTaint:!0,useCORS:!0}})}catch(g){throw console.error("Error generating attestation PDF:",g),g}finally{s()}}},911:function(e,t,n){"use strict";n.d(t,"a",(function(){return S})),n.d(t,"b",(function(){return E}));var i=n(1),s=n(837),a=n(1023),r=n(68),o=n(29),c=n(19),l=(n(379),n(43)),d=n(898),u=n(370),h=n(8),m=n(1022),b=(n(1004),n(382)),p=n(192),j=n(869),f=n(45),g=n(4),v=n(191),x=n(3);function y(e){var t;let{articleId:n,height:s}=e;const[o,c]=Object(i.useState)(!0),[l,d]=Object(i.useState)(""),[u,h]=Object(i.useState)(null),[m,b]=Object(i.useState)(""),[p,y]=Object(i.useState)(!1),[O,w]=Object(i.useState)(0),_=Object(i.useRef)(""),C=Object(i.useContext)(f.a),N="dark"===(null===C||void 0===C||null===(t=C.state)||void 0===t?void 0:t.layoutType),k=N?"dark":"light";Object(i.useEffect)((()=>{let e=!1;const t=()=>{_.current&&(URL.revokeObjectURL(_.current),_.current="")};return n&&(async()=>{c(!0),d(""),t(),b("");try{const t=await v.a.getArticleDrivePreviewInfo(n);if(e)return;if(h(t),"pdf"===t.render_kind||"html"===t.render_kind){const n=t.content_url.includes("?")?"&":"?",i=`${t.content_url}${n}theme=${k}`,s=await g.a.get(i,{...g.a.tokenConfig(),responseType:"blob"});if(e)return;const a=URL.createObjectURL(s.data);_.current=a,b(a)}}catch(a){var i,s;if(e)return;const t=null===a||void 0===a||null===(i=a.response)||void 0===i||null===(s=i.data)||void 0===s?void 0:s.detail;d(t||"Unable to load the Google Drive file.")}finally{e||c(!1)}})(),()=>{e=!0,t()}}),[n,k,O]),Object(i.useEffect)((()=>y(!1)),[n]);const S=()=>(null===u||void 0===u?void 0:u.web_view_link)&&window.open(u.web_view_link,"_blank","noopener,noreferrer"),E=(null===u||void 0===u?void 0:u.web_view_link)||"",I=!(null===u||void 0===u||!u.editable||!E);if(o)return Object(x.jsxs)("div",{className:"d-flex align-items-center justify-content-center py-5",children:[Object(x.jsx)(j.a,{animation:"border",size:"sm",className:"mr-2"})," Loading document\u2026"]});if(l)return Object(x.jsxs)(a.a,{variant:"warning","data-testid":"gdrive-embed-error",children:[Object(x.jsx)("p",{className:"mb-2",children:l}),(null===u||void 0===u?void 0:u.web_view_link)&&Object(x.jsx)(r.a,{size:"sm",variant:"outline-primary",onClick:S,children:"Open in Google Drive"})]});const T=s||720;return Object(x.jsxs)("div",{className:"google-drive-embed","data-testid":"gdrive-embed",children:[Object(x.jsxs)("div",{className:"d-flex align-items-center justify-content-between mb-2",children:[Object(x.jsx)("span",{className:"font-weight-bold text-truncate mr-2",children:(null===u||void 0===u?void 0:u.file_name)||"Document"}),Object(x.jsxs)("div",{className:"d-flex flex-shrink-0",children:[I&&(p?Object(x.jsx)(r.a,{size:"sm",variant:"primary",className:"mr-2",onClick:()=>{y(!1),w((e=>e+1))},children:"Done editing"}):Object(x.jsx)(r.a,{size:"sm",variant:"outline-primary",className:"mr-2",onClick:()=>y(!0),children:"Edit"})),(null===u||void 0===u?void 0:u.web_view_link)&&Object(x.jsx)(r.a,{size:"sm",variant:"outline-secondary",onClick:S,children:I?"Open in new tab":"Open in Google to edit"})]})]}),p&&I?Object(x.jsxs)(x.Fragment,{children:[Object(x.jsx)("iframe",{title:`Edit ${(null===u||void 0===u?void 0:u.file_name)||"Google Drive document"}`,src:E,style:{width:"100%",height:`${T}px`,border:"1px solid "+(N?"#3a3a3a":"#e2e2e2"),borderRadius:4,background:"#ffffff"},allow:"clipboard-read; clipboard-write"}),Object(x.jsx)("small",{className:"text-muted d-block mt-1",children:"Editing happens in Google and needs an account with access to this file. If the editor doesn\u2019t load here, use \u201cOpen in new tab.\u201d Changes appear in the article when you click \u201cDone editing.\u201d"})]}):"pdf"!==(null===u||void 0===u?void 0:u.render_kind)&&"html"!==(null===u||void 0===u?void 0:u.render_kind)||!m?Object(x.jsxs)(a.a,{variant:"info",className:"mb-0",children:["This file type can\u2019t be displayed inline."," ",(null===u||void 0===u?void 0:u.web_view_link)&&Object(x.jsx)(r.a,{size:"sm",variant:"link",className:"p-0 align-baseline",onClick:S,children:"Open it in Google Drive"})]}):Object(x.jsx)("iframe",{title:(null===u||void 0===u?void 0:u.file_name)||"Google Drive document",src:m,style:{width:"100%",height:`${T}px`,border:"1px solid "+(N?"#3a3a3a":"#e2e2e2"),borderRadius:4,background:N?"#1f1f1f":"#ffffff"},sandbox:"html"===(null===u||void 0===u?void 0:u.render_kind)?"allow-same-origin allow-popups":void 0})]})}var O=n.p+"static/media/emptyoffice.50a69e89.jpg";function w(e,t,n,i,s,a){let r=arguments.length>6&&void 0!==arguments[6]&&arguments[6];for(var o=(t=t||"").split(" "),c="",l=0;l<o.length;l++){var d=c+o[l]+" ",u=e.measureText(d),h=u.width;h>s-90&&l>0?(r&&(e.shadowColor="rgba(0,0,0,0.7)"),r&&(e.shadowBlur=8),e.fillText(c,n,i),r&&(e.shadowBlur=0),c=o[l]+" ",i+=a):c=d}return r&&(e.shadowColor="rgba(0,0,0,0.7)"),r&&(e.shadowBlur=8),null===e||void 0===e||e.fillText(c,n,i),r&&(e.shadowBlur=0),i+a}var _=e=>{const t=Object(c.d)((e=>{var t,n;return null===e||void 0===e||null===(t=e.account)||void 0===t||null===(n=t.user)||void 0===n?void 0:n.company})),[n,s]=Object(i.useState)("");return Object(i.useEffect)((()=>{const n=document.createElement("canvas"),i=n.getContext("2d"),a=1920,r=1080;n.width=a,n.height=r;const o=new window.Image;o.src=O,o.onload=()=>{var c,l;i.drawImage(o,0,0,a,r),i.fillStyle="rgba(0,0,0,0.65)",i.fillRect(0,0,a,r),i.textAlign="center",i.textBaseline="top",i.fillStyle="#FFF",i.font="bold 92px Quicksand, sans-serif";let d=null===e||void 0===e||null===(c=e.title)||void 0===c?void 0:c.toUpperCase(),u=w(i,d,960,216,a,92,!0);u+=8,i.fillStyle="#CCC",i.font="600 36px Quicksand, sans-serif";let h="A "+(null===e||void 0===e||null===(l=e.type_info)||void 0===l?void 0:l.type)+" By "+(null===t||void 0===t?void 0:t.company_name),m=w(i,h,960,u,a,36,!0);m+=450,i.fillStyle="#FFF",i.font="500 30px Quicksand, sans-serif";if(w(i,"Adjust The Video Speed To Enhance Comprehension",960,m,a,36,!0),null!==t&&void 0!==t&&t.company_logo){const e=new window.Image;e.crossOrigin="anonymous",e.src=t.company_logo,e.onload=()=>{const t=180;i.save(),i.globalAlpha=.92,i.drawImage(e,1692,852,t,t),i.restore(
2),s(n.toDataURL("image/png"))},e.onerror=()=>{s(n.toDataURL("image/png"))}}else s(n.toDataURL("image/png"))},o.onerror=()=>{i.fillStyle="#111111",i.fillRect(0,0,a,r),s(n.toDataURL("image/png"))}}),[e,t]),n},C=n(380),N=n(1e3);const k=e=>{e.preventDefault()},S=e=>{var t,n,s,a,r,o,l,d,u,m,j;let{article:f,body:g,videoPlayerRef:v}=e;const O=null!==(t=null===f||void 0===f?void 0:f.type_info)&&void 0!==t?t:null!==f&&void 0!==f&&f.type&&"object"===typeof f.type?f.type:null,w=O?String(null!==(n=O.theme_logo_url)&&void 0!==n?n:"").trim():"",k=null===O||void 0===O?void 0:O.theme_header_html,S=null!=k&&String(k).length>0&&/\S/.test(String(k).replace(/<[^>]+>/g," ")),E=O&&(!!w||S),I={},T=String(null!==(s=null===O||void 0===O?void 0:O.theme_default_font_family)&&void 0!==s?s:"").trim();T&&(I.fontFamily=T);const q=String(null!==(a=null===O||void 0===O?void 0:O.theme_default_font_color)&&void 0!==a?a:"").trim();q&&(I.color=q);const A=Object(c.d)((e=>{var t,n;return null===e||void 0===e||null===(t=e.account)||void 0===t||null===(n=t.user)||void 0===n?void 0:n.company})),z=Object(c.d)((e=>{var t;return null===e||void 0===e||null===(t=e.account)||void 0===t?void 0:t.user})),L=(null===z||void 0===z||null===(r=z.user_roles)||void 0===r?void 0:r.user_is_kb_admin)||(null===z||void 0===z||null===(o=z.user_roles)||void 0===o?void 0:o.user_is_kb_article_admin)||(null===z||void 0===z||null===(l=z.user_roles)||void 0===l?void 0:l.user_is_kb_viewer)||(null===z||void 0===z||null===(d=z.user_roles)||void 0===d?void 0:d.user_is_kb_article_viewer)||(null===z||void 0===z||null===(u=z.user_roles)||void 0===u?void 0:u.user_is_kb_training_admin)||(null===z||void 0===z||null===(m=z.user_roles)||void 0===m?void 0:m.user_is_kb_viewer),[$,P]=Object(i.useState)(!1),[R,M]=Object(i.useState)(null),F=Object(i.useRef)(null),[D,B]=Object(i.useState)(null),H=_(f);return Object(i.useLayoutEffect)((()=>{const e=[];return document.querySelectorAll(".mce-content-body .tox-checklist>li").forEach(((t,n)=>{const i=`art=${f.id}-id=${n}-user=${null===z||void 0===z?void 0:z.id}`;t.id=i;"true"===localStorage.getItem(i)&&t.classList.add("tox-checklist--checked");const s=()=>{t.classList.toggle("tox-checklist--checked"),localStorage.setItem(i,t.classList.contains("tox-checklist--checked"))};t.addEventListener("click",s),e.push({item:t,handler:s})})),()=>{e.forEach((e=>{let{item:t,handler:n}=e;t.removeEventListener("click",n)}))}}),[g]),Object(i.useEffect)((()=>{const e=async()=>{try{const e=null===F||void 0===F?void 0:F.current;if(!e)return;const t=await Object(N.a)(e,{backgroundColor:"#ffffff",pixelRatio:2,cacheBust:!0,useCORS:!0});M(t),B(t)}catch(e){}},t=setTimeout(e,100),n=()=>e();return window.addEventListener("beforeprint",n),()=>{clearTimeout(t),window.removeEventListener("beforeprint",n)}}),[null===f||void 0===f?void 0:f.flow_chart,null===f||void 0===f?void 0:f.flow_chart_info,null===f||void 0===f?void 0:f.decision_chart]),Object(x.jsxs)(x.Fragment,{children:[E?Object(x.jsxs)("div",{className:"article-type-theme-chrome position-relative mb-2","data-testid":"article-type-theme-chrome",children:[w?Object(x.jsx)("img",{src:w,alt:"",className:"article-type-theme-logo"}):null,S?Object(x.jsx)("div",{className:"article-type-theme-header mce-content-body pr-md-5",dangerouslySetInnerHTML:{__html:String(k)}}):null]}):null,Object(x.jsx)("div",{className:"sun-editor sun-editor--readonly",style:{border:"none",backgroundColor:"transparent"},children:Object(x.jsx)("div",{className:"se-wrapper",children:Object(x.jsx)("div",{className:"sun-editor-editable article-content mce-content-body article-type-theme-body",style:Object.keys(I).length?I:void 0,dangerouslySetInnerHTML:{__html:g},"data-testid":"article-body"})})}),null!==f&&void 0!==f&&f.flow_chart_info&&null!==f&&void 0!==f&&f.flow_chart_info.nodes?Object(x.jsx)("div",{className:"my-3 "+(R?"printhide":""),style:{height:"800px",width:"100%",overflow:"hidden"},"data-testid":"article-flow",ref:F,children:Object(x.jsx)(b.a,{editmode:!1,decision_chart:f.flow_chart_info})}):null!==f&&void 0!==f&&f.flow_chart?Object(x.jsx)("div",{className:"my-3 "+(R?"printhide":""),style:{height:"800px",width:"100%",overflow:"hidden"},"data-testid":"article-flow",ref:F,children:Object(x.jsx)(b.a,{editmode:!1,flow_chart:f.flow_chart})}):null!==f&&void 0!==f&&f.decision_chart&&null!==f&&void 0!==f&&f.decision_chart.edges&&null!==f&&void 0!==f&&f.decision_chart.nodes?Object(x.jsx)("div",{className:"my-3 "+(R?"printhide":""),style:{height:"800px",width:"100%",overflow:"hidden"},"data-testid":"article-flow",ref:F,children:Object(x.jsx)(b.a,{editmode:!1,decision_chart:f.decision_chart})}):null!==f&&void 0!==f&&f.decision_chart&&null!==f&&void 0!==f&&f.decision_chart.id?Object(x.jsx)("div",{className:"my-3 "+(R?"printhide":""),style:{height:"800px",width:"100%",overflow:"hidden"},"data-testid":"article-flow",ref:F,children:Object(x.jsx)(b.a,{editmode:!1,flow_chart:f.decision_chart.id})}):null,R&&Object(x.jsx)("img",{src:R,alt:"Flow chart",className:"printshow",style:{display:"none",width:"100%",height:"auto"},"data-testid":"article-flow-print-fallback"}),D&&Object(x.jsx)("div",{className:"my-3",children:Object(x.jsx)("img",{src:D,alt:"Flow chart",style:{width:"100%",height:"auto"},"data-testid":"article-flow-image"})}),((null===f||void 0===f?void 0:f.video_url)||(null===f||void 0===f?void 0:f.video_uploaded))&&Object(x.jsxs)("div",{"data-testid":"article-video-player",children:[Object(x.jsx)(C.a,{ref:v,videoUrl:f.video_url||f.video_uploaded,posterUrl:H,transcript:f.transcript,companyLogo:null===A||void 0===A?void 0:A.company_logo,onDownload:()=>(async e=>{if(e){P(!0);try{const n=await fetch(e);if(!n.ok)throw h.b.error(`Failed to fetch video: ${n.status} ${n.statusText}`),new Error(`HTTP error! status: ${n.status}`);const i=await n.blob(),s=window.URL.createObjectURL(i),a=document.createElement("a");a.href=s;let r="video.mp4";try{const t=e.split("/"),n=t[t.length-1];n.includes(".")&&(r=n.split("?")[0])}catch(t){console.warn("Could not determine filename from URL",t)}null!==f&&void 0!==f&&f.title&&!r.startsWith(f.title.replace(/[^a-z0-9_\-\s]/gi,"").replace(/\s+/g,"_"))&&(r=`${f.title.replace(/[^a-z0-9_\-\s]/gi,"").replace(/\s+/g,"_")}.mp4`),a.setAttribute("download",r),a.type=i.type,document.body.appendChild(a),a.click(),setTimeout((()=>{document.body.removeChild(a),window.URL.revokeObjectURL(s)}),100)}catch(n){console.error("Error downloading video:",n),h.b.error("Error downloading video. Check console for details.")}finally{P(!1)}}else h.b.error("No video URL provided")})(f.video_url||f.video_uploaded),isDownloading:$,canDownload:L}),Object(x.jsxs)("div",{id:"debug-info",style:{display:"none"},children:["Video player ref available: ",v?"Yes":"No"]})]}),f.file_url&&Object(x.jsx)(p.a,{urls:[f.file_url],admin:L||!1!==(null===A||void 0===A?void 0:A.kb_copy_article)}),(null===(j=f.file_urls)||void 0===j?void 0:j.length)>0&&Object(x.jsx)(p.a,{urls:f.file_urls,admin:L||!1!==(null===A||void 0===A?void 0:A.kb_copy_article)}),f.google_drive_file_id&&f.id&&Object(x.jsx)("div",{className:"mt-3",children:Object(x.jsx)(y,{articleId:f.id})})]})};function E(e){var t,n,h,b,p,j,f;let{articleId:g,article:v,loading:y,hasError:O,errorInfo:w,articleErrorBackTo:_="/knowledgebase/articles",setFoundDefinitions:C,setArticleTranscript:N}=e;Object(c.c)();const E=Object(c.d)((e=>e.account.user)),I=(null===E||void 0===E||null===(t=E.user_roles)||void 0===t?void 0:t.user_is_kb_admin)||(null===E||void 0===E||null===(n=E.user_roles)||void 0===n?void 0:n.user_is_kb_article_admin)||(null===E||void 0===E||null===(h=E.user_roles)||void 0===h?void 0:h.user_is_kb_viewer)||(null===E||void 0===E||null===(b=E.user_roles)||void 0===b?void 0:b.user_is_kb_article_viewer)||(null===E||void 0===E||null===(p=E.user_roles)||void 0===p?void 0:p.user_is_kb_training_admin)||(null===E||void 0===E||null===(j=E.user_roles)||void 0===j?void 0:j.user_is_kb_viewer),T=!1===(null===E||void 0===E||null===(f=E.company)||void 0===f?void 0:f.kb_copy_article)&&!I,q=Object(i.useRef)(null),A=Object(i.useRef)(null),[z,L]=Object(i.useState)(v||!1),[$,P]=Object(i.useState)(y||!1);if(Object(i.useEffect)((()=>{P(!0),L(v),P(!1)}),[v]),Object(i.useEffect)((()=>{O?P(!1):z||(P(!0),l.a.fetchArticle(g,!0,{display_only:"true"}).then((e=>{L(e)})).catch((e=>{console.error("Error fetching article:",e)})).finally((()=>{P(!1)})))}),[v,O]),Object(i.useEffect)((()=>{setTimeout((()=>{var e;const t=null===q||void 0===q||null===(e=q.current)||void 0===e?void 0:e.querySelectorAll("img");null===t||void 0===t||t.forEach((e=>{e.style.maxWidth="100%",e.style.height="auto"}))}),0)}),[z]),Object(i.useEffect)((()=>{null!==z&&void 0!==z&&z.found_definitions&&"function"===typeof C&&C(z.found_definitions)}),[z,C]),Object(i.useEffect)((()=>{const e=new MutationObserver((e=>{e.forEach((e=>{(e.addedNodes.length||e.removedNodes.length)&&t()}))})),t=()=>{document.querySelectorAll(".tooltip-def:not(.tippy-initialized)").forEach((e=>{e.classList.add("tippy-initialized"),Object(m.a)(e,{allowHTML:!0,placement:"top",boundary:"scrollParent",padding:5,interactive:!0})}
2))};return q.current&&e.observe(q.current,{childList:!0,subtree:!0}),t(),()=>e.disconnect()}),[z,C]),Object(i.useEffect)((()=>{z&&"function"===typeof N&&A.current&&N({transcript:z.transcript||"",video_url:Boolean(z.video_url||z.video_uploaded),videoPlayerRef:A})}),[z,N,A.current]),O&&w){const e=403===w.status?"warning":404===w.status?"secondary":"danger";return Object(x.jsxs)(s.a.Body,{children:[Object(x.jsxs)(a.a,{variant:e,"data-testid":"article-detail-api-error",children:[Object(x.jsxs)(a.a.Heading,{as:"h4",className:"h5",children:[w.title,w.status?` (${w.status})`:""]}),Object(x.jsx)("p",{className:"mb-0",children:w.message})]}),Object(x.jsx)(r.a,{variant:"outline-primary",className:"mt-2",as:o.b,to:_,"data-testid":"article-detail-error-back",children:"Back to Knowledge Base"})]})}return O?Object(x.jsx)(u.default,{}):Object(x.jsx)(s.a.Body,{ref:q,className:"article-detail-card-body"+(T?" noCopy":""),onContextMenu:T?k:void 0,children:Object(x.jsxs)("div",{id:`html-content-${g}-current`,children:[(null===z||void 0===z?void 0:z.previous_version_exists)&&(null===z||void 0===z?void 0:z.previous_version_diff_body)&&Object(x.jsxs)("div",{className:"border p-3 mb-3 printhide",children:[Object(x.jsx)("h5",{className:"mb-3",children:"Changes from Previous Version:"}),Object(x.jsx)("div",{dangerouslySetInnerHTML:{__html:z.previous_version_diff_body},"data-testid":"article-previous-version-diff-body"})]}),$?Object(x.jsx)(d.a,{}):O?Object(x.jsx)("div",{children:Object(x.jsx)(u.default,{})}):z?Object(x.jsxs)(x.Fragment,{children:[Object(x.jsx)("style",{type:"text/css",media:"print",children:"@page { size: portrait; -webkit-print-color-adjust: exact;}"}),Object(x.jsx)(S,{article:z,body:null===z||void 0===z?void 0:z.body,videoPlayerRef:A})]}):"There is an error with this article. Please ensure it is currently published"]})})}},914:function(e,t,n){"use strict";n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return d})),n.d(t,"d",(function(){return u})),n.d(t,"c",(function(){return h}));var i=n(68),s=n(8),a=n(43),r=n(11),o=n(900),c=n(3);const l=e=>null===e||void 0===e?void 0:e.filter((e=>!1===e.is_complete)).length,d=e=>null===e||void 0===e?void 0:e.find((e=>!1===(null===e||void 0===e?void 0:e.is_complete))),u=async(e,t)=>{const n={staff:e,action:"QUIZ_COMPLETED",acknowledgement_type:"QUIZ_ACKNOWLEDGEMENT",question:"",question_type:null,answer:"",article:null,course:null,quiz:parseInt(t),version:""};return await a.a.createKBAcknowledgement(n)},h=async(e,t,n,l,u,h)=>{var m;const b=await a.a.fetchCourseDetails(e,t);if(!b)throw new Error("Failed to refresh course details after acknowledgement");const p=[];null===(m=b.sections)||void 0===m||m.forEach((e=>{p.push(...e.section_items||[])}));if(b.section_items_completed_count===b.section_items_count||(e=>e.every((e=>!0===e.is_complete)))(p))t({type:r.zb,payload:!0}),p.length>0&&t({type:r.ub,payload:p[0].id});else{const e=d(p);e&&t({type:r.ub,payload:e.id})}if(1===l){const n=await(async(e,t)=>{const n={staff:e,action:"READ",acknowledgement_type:"COURSE_ACKNOWLEDGEMENT",question:"",question_type:null,answer:"",article:null,course:parseInt(t),version:""};return await a.a.createKBAcknowledgement(n)})(h,e);if(console.log({data:n},"certificate html",n.certificate_html),t({type:r.hb,payload:!0}),n.certificate_html){const e=()=>{Object(o.c)(n.certificate_html,"certificate")};Object(s.b)(Object(c.jsx)("div",{className:"force-center",style:{padding:10,marginRight:-10,display:"flex",justifyContent:"center",transform:"scale(0.7)",alignItems:"center",transformOrigin:"top right",marginLeft:120,marginTop:100,width:400,height:250},children:Object(c.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:10},children:[Object(c.jsx)("style",{children:"\n                        /* Override the inline width/height of the certificate's outer container */\n                    .certificate-container > div {\n                        // max-width: 400px;\n                        // max-height: 200px;\n                        // /* Scale down the rendered HTML */\n                        // // transform: scale(0.7);\n                        // transform-origin: top center; /* Adjust origin as needed */\n                    }\n                    "}),Object(c.jsx)("div",{className:"certificate-container",dangerouslySetInnerHTML:{__html:n.certificate_html}}
2),Object(c.jsx)(i.a,{onClick:e,style:{marginTop:"10px",padding:"5px 10px",fontSize:"12px"},children:"Download Certificate"})]})}),{position:"top-center",autoClose:!1,style:{width:"800px",height:"650px",marginTop:50,marginRight:50,marginLeft:-110,fontFamily:"League Spartan, San-Serif",overflow:"auto"},hideProgressBar:!0,closeOnClick:!1,pauseOnHover:!1,draggable:!0,progress:void 0})}Object(s.b)(Object(c.jsx)("h2",{className:"font-weight-bold f-52 text-center theme-font ",children:"CONGRATS ON COMPLETING!!!"}),{position:"top-center",autoClose:2500,style:{width:"500px",marginTop:50,fontFamily:"League Spartan, San-Serif"},hideProgressBar:!0,closeOnClick:!0,pauseOnHover:!1,draggable:!0,progress:void 0}),setTimeout((()=>t({type:r.hb,payload:!1})),100)}}},915:function(e,t,n){"use strict";var i=n(7),s=n(16),a=n(12),r=n.n(a),o=n(1),c=n.n(o),l=n(21),d=["bsPrefix","variant","pill","className","as"],u=c.a.forwardRef((function(e,t){var n=e.bsPrefix,a=e.variant,o=e.pill,u=e.className,h=e.as,m=void 0===h?"span":h,b=Object(s.a)(e,d),p=Object(l.a)(n,"badge");return c.a.createElement(m,Object(i.a)({ref:t},b,{className:r()(u,p,o&&p+"-pill",a&&p+"-"+a)}))}));u.displayName="Badge",u.defaultProps={pill:!1},t.a=u},919:function(e,t,n){"use strict";var i=n(63),s=n(8),a=n(6),r=n(4),o=n(33);t.a={getAttendanceClockDashboardData:async()=>{try{const{data:e}=await r.a.get(`${a.a}inout/api/clock-dashboard/`,r.a.tokenConfig());return e}catch(e){return console.log("error fetching attendanceData >>>>",null===e||void 0===e?void 0:e.response),!1}},getStaffWithInoutPage:async function(){let{page:e=1,pageSize:t=10,search:n="",division:i="",employeesIds:s=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const c=new URLSearchParams({paginate:"true",page:String(e),page_size:String(t)});n&&c.set("search",n),i&&c.set("division",String(i)),s&&c.set("employees_ids",s);const{data:l}=await r.a.get(`${a.a}inout/api/staff-list-with-inout/?${c.toString()}`,r.a.tokenConfig());return Object(o.n)(l)}catch(c){return console.log("error fetching staff inout list >>>>",null===c||void 0===c?void 0:c.response),{results:[],count:0,next:null,previous:null}}},addAttendanceRecord:async function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=t?"?dashboard=true":"";try{const{data:o}=await r.a.post(`${a.a}inout/api/inout/${n}`,e,r.a.tokenConfig());return t?s.b.success("Clocked status set to "+o.status+" successfully!"):s.b.success(`Clock Event: "${o.status} - ${o.comment} at ${Object(i.a)(o.timestamp).format("lll")}" added successfully!`),o}catch(o){return console.log(o),Object(r.c)(null===o||void 0===o?void 0:o.response),!1}},updateAttendanceRecord:async(e,t)=>{try{const{data:n}=await r.a.patch(`${a.a}inout/api/inout/${e}/`,t,r.a.tokenConfig());return s.b.success("Clock Event updated successfully!"),n}catch(o){var n,i;if(console.log(o.response),o.response&&404===o.response.status)s.b.error("Attendance record not found"+JSON.stringify(null===(i=o.response)||void 0===i?void 0:i.data));return(null===(n=o.response)||void 0===n?void 0:n.data)&&Object(r.c)(null===o||void 0===o?void 0:o.response),!1}},deleteAttendanceRecord:async e=>{try{return await r.a.delete(`${a.a}inout/api/inout/${e}/`,r.a.tokenConfig()),s.b.success("Attendance record deleted successfully!"),!0}catch(n){var t;if(console.log(n),n.response&&404===n.response.status)s.b.error("inout not found"+JSON.stringify(null===(t=n.response)||void 0===t?void 0:t.data));return!1}},getCourseCategories:async()=>{try{const{data:e}=await r.a.get(`${a.a}knowledgebase/api/course-categories/`,r.a.tokenConfig());return e}catch(e){return console.log(e),!1}},getInOutTags:async()=>{try{const{data:e}=await r.a.get(`${a.a}inout/api/inout-tags/`,r.a.tokenConfig());return e}catch(e){return console.log(e),!1}},deleteInOutTags:async e=>{try{const{data:t}=await r.a.delete(`${a.a}inout/api/inout-tags/${e}/`,r.a.tokenConfig());return t}catch(n){var t;if(console.log(n),n.response&&404===n.response.status)s.b.error("Tag not found"+JSON.stringify(null===(t=n.response)||void 0===t?void 0:t.data));return!1}},createInOutTags:async e=>{try{const{data:t}=await r.a.post(`${a.a}inout/api/inout-tags/`,e,r.a.tokenConfig());return t}catch(i){var t,n;return console.log(i),(null===(t=i.response)||void 0===t?void 0:t.data)&&s.b.error(JSON.stringify(null===(n=i.response)||void 0===n?void 0:n.data)),!1}},updateInOutTags:async(e,t)=>{try{const{data:n}=await r.a.patch(`${a.a}inout/api/inout-tags/${e}/`,t,r.a.tokenConfig());return n}catch(c){var n,i,o;if(console.log(c.response),c.response&&404===c.response.status)s.b.error("Tag not found"+JSON.stringify(null===(o=c.response)||void 0===o?void 0:o.data));return(null===(n=c.response)||void 0===n?void 0:n.data)&&s.b.error(JSON.stringify(null===(i=c.response)||void 0===i?void 0:i.data)),!1}},getScheduledInOutTags:async()=>{try{const{data:e}=await r.a.get(`${a.a}inout/api/scheduled-inout/`,r.a.tokenConfig());return e}catch(e){return console.log(e),!1}},createScheduledInOut:async e=>{try{const{data:t}=await r.a.post(`${a.a}inout/api/scheduled-inout/`,e,r.a.tokenConfig());return t}catch(t){return console.log(t),!1}},deleteScheduledInOut:async e=>{try{return await r.a.delete(`${a.a}inout/api/scheduled-inout/${e}/`,r.a.tokenConfig()),"success"}catch(n){var t;if(console.log(n),n.response&&404===n.response.status)s.b.error("inout not found"+JSON.stringify(null===(t=n.response)||void 0===t?void 0:t.data));else console.error("Delete request failed:",JSON.stringify(null===n||void 0===n?void 0:n.response));return!1}},addWorkingBonus:async e=>{try{const{data:t}=await r.a.post(`${a.a}inout/api/working-bonus/`,e,r.a.tokenConfig());return s.b.success(`Bonus added for "${t.employee.full_name_or_email} on ${Object(i.a)(t.date).format("ll")}" added successfully!`),t}catch(t){return console.log(t),Object(r.c)(null===t||void 0===t?void 0:t.response),!1}},deleteWorkingBonus:async e=>{try{return await r.a.delete(`${a.a}inout/api/working-bonus/${e}/`,r.a.tokenConfig()),s.b.success("working bonus deleted successfully!"),"success"}catch(n){var t;if(console.log(n),n.response&&404===n.response.status)s.b.error("item not found"+JSON.stringify(null===(t=n.response)||void 0===t?void 0:t.data));return!1}},bulkProcessEntries:async e=>{try{const{data:t}=await r.a.post(`${a.a}inout/api/bulk-process/`,e,r.a.tokenConfig());return s.b.success(`Successfully ${e.status.toLowerCase()} ${t.processed_entries} entries`),t}catch(t){return console.log(t),Object(r.c)(null===t||void 0===t?void 0:t.response),!1}}}},923:function(e,t,n){"use strict";n.d(t,"b",(function(){return y}
2)),n.d(t,"e",(function(){return O})),n.d(t,"a",(function(){return w})),n.d(t,"c",(function(){return _})),n.d(t,"f",(function(){return C})),n.d(t,"d",(function(){return N})),n.d(t,"g",(function(){return k}));var i=n(38),s=n(1),a=n(550),r=n(112),o=n(68),c=n(1095),l=n(212),d=n(1094),u=n(53),h=n(43),m=n(41),b=n(114),p=n.n(b),j=n(137),f=n(977),g=n(3);const v=e=>{if(!e)return"";const t=document.createElement("DIV");return t.innerHTML=e,t.textContent||t.innerText||""};var x=e=>{let{field:t,form:n,...i}=e;const a=(e=>null===e||void 0===e?"":"string"===typeof e?e:String(e))(t.value),[r,o]=Object(s.useState)(!!(c=a)&&/<([a-z][a-z0-9]*)\b[^>]*>|<\/([a-z][a-z0-9]*)\b[^>]*>/i.test(c));var c;const{onChange:l,type:d,value:u,...h}=i;return Object(g.jsxs)("div",{children:[Object(g.jsx)("div",{className:"d-flex justify-content-end mb-1",children:Object(g.jsxs)("div",{className:"custom-control custom-switch",children:[Object(g.jsx)("input",{type:"checkbox",className:"custom-control-input",id:`richtext-toggle-${t.name}`,checked:r,onChange:()=>{r?p.a.fire({title:"Warning",text:"Switching to plain text will remove all formatting. Are you sure?",icon:"warning",showCancelButton:!0,confirmButtonText:"Yes, switch",cancelButtonText:"Cancel"}).then((e=>{if(e.isConfirmed){const e=v(a);n.setFieldValue(t.name,e),o(!1)}})):o(!0)}}),Object(g.jsx)("label",{className:"custom-control-label",htmlFor:`richtext-toggle-${t.name}`,children:"Rich Text"})]})}),r?Object(g.jsx)(j.a,{value:a,onChange:e=>n.setFieldValue(t.name,e),height:100,minHeight:100,enableAI:!1,simple:!0,inline:!0,...h}):Object(g.jsx)(f.default,{className:"form-control",value:a,onChange:e=>n.setFieldValue(t.name,e.target.value),minRows:4,style:{minHeight:"100px"},...h})]})};const y="MULTIPLE_CHOICE",O="SINGLE_CHOICE",w="INSTRUCTION",_="OPEN_TEXT",C="SUBMISSION",N=[w,_,C];function k(e){let{instance:t,callbackFunc:n,aiGeneratedData:b}=e;const p=Object(s.useMemo)((()=>[{text:"Single Choice",value:O},{text:"Multiple Choice",value:y},{text:"Instruction",value:w},{text:"Open Text",value:_},{text:"Submission",value:C}]),[]),j=u.f().shape({questions:u.a().of(u.f().shape({question:u.h().required("Please enter a question"),type:u.h().required("This field is required"),choices:u.a().of(u.f().shape({text:u.h().required("Please enter an answer"),is_correct:u.c().required("This field is required")})).min(1,"A question must have at least one choice").test("at-least-one-correct-choice","A question must have at least one correct choice",(e=>e.some((e=>e.is_correct))))}))}),f={question:"",order:1,type:p[0].value,choices:[{text:"",is_correct:!1}]},k=Object(s.useMemo)((()=>{var e,n;return{title:(null===b||void 0===b?void 0:b.title)||(null===t||void 0===t?void 0:t.title)||"",passing_grade:null!==(e=null!==(n=null===b||void 0===b?void 0:b.passing_grade)&&void 0!==n?n:null===t||void 0===t?void 0:t.passing_grade)&&void 0!==e?e:100,questions:(null===b||void 0===b?void 0:b.questions)||(null===t||void 0===t?void 0:t.questions)||[f]}}),[b,t]);return Object(g.jsx)(i.e,{validationSchema:j,initialValues:k,enableReinitialize:!0,onSubmit:async(e,i)=>{try{let i;console.log("Submitting quiz data:",e),""===e.title&&(e.title=e.questions[0].question),i=t?await h.a.updateQuiz(null===t||void 0===t?void 0:t.id,e):await h.a.createQuiz(e),console.log("Response from quiz creation/update:",i),i?"function"===typeof n&&n(i):console.error("No data returned from quiz service")}catch(s){console.error("Error submitting quiz:",s)}i.setSubmitting(!1)},children:e=>{let{errors:t,values:n,isSubmitting:s,setFieldValue:u}=e;return Object(g.jsxs)(i.d,{children:[Object(g.jsxs)("div",{className:"row",children:[Object(g.jsxs)("div",{className:"col-12",children:[Object(g.jsx)("p",{children:"Fill in the form below to create a quiz. A quiz can have multiple questions to it."}),Object(g.jsxs)("div",{className:"form-group "+(1===n.questions.length?" d-none":""),children:[Object(g.jsx)("label",{htmlFor:"name",children:"Quiz Title"}),Object(g.jsx)(i.b,{className:"form-control",name:"title",type:"text",placeholder:"Enter title...",onChange:e=>{u("title",e.target.value),1===n.questions.length&&u("questions.0.question",e.target.value)},"data-testid":"quiz-form-title-input"}),t.title&&Object(g.jsx)("span",{className:"text-danger","data-testid":"quiz-form-title-error",children:t.title})]}),Object(g.jsxs)("div",{className:"form-group",children:[Object(g.jsx)("label",{htmlFor:"passing_grade",children:"Passing Grade (%)"}),Object(g.jsx)(i.b,{className:"form-control",name:"passing_grade",type:"number",min:"0",max:"100",placeholder:"100","data-testid":"quiz-form-passing-grade-input"}),Object(g.jsx)("small",{className:"text-muted",children:"Percent required to pass (e.g. 80). Default 100 = all correct."})]})]}),Object(g.jsx)("hr",{}),Object(g.jsx)("div",{className:" col-12",children:Object(g.jsxs)("div",{className:"form-group",children:[Object(g.jsx)(a.a,{children:Object(g.jsx)(r.a,{xs:12,children:Object(g.jsx)("p",{className:"font-weight-bold",children:"Add Questions to this quiz:"})})}),n.questions.map(((e,s)=>{var o;return Object(g.jsxs)(a.a,{className:"mb-1",noGutters:!0,children:[Object(g.jsx)(r.a,{xs:12,className:"",children:Object(g.jsxs)(a.a,{className:" p-3 rounded",children:[Object(g.jsx)(r.a,{md:12,xs:12,children:Object(g.jsxs)(a.a,{className:"mb-2",children:[Object(g.jsx)(r.a,{md:1,children:Object(g.jsxs)("h4",{className:"mr-1",children:[s+1,". "]})}),Object(g.jsx)(r.a,{md:n.questions.length>1?10:11,xs:11,children:Object(g.jsx)(i.b,{as:"select",name:`questions.${s}.type`,className:"form-control form-control-sm",style:{height:"calc(1.5em + 0.5rem + 2px)",padding:"0.25rem 0.5rem",fontSize:"0.875rem",lineHeight:"1.5",bordeRadius:"0.2rem"},onChange:e=>{const t=n.questions[s].type,i=e.target.value,a=[{text:"instruction",is_correct:!0}];if(!N.includes(i)&&N.includes(t)){const e=n.questions[s].choices.map((e=>({...e,text:""}))),t=n.questions.filter(((e,t)=>t===s))[0];let i=[...n.questions];i[s]={...t,choices:e},u("questions",i)}else if(i===O&&t===y){const e=n.questions[s].choices.map((e=>({...e,is_correct:!1}))),t=n.questions.filter(((e,t)=>t===s))[0];let i=[...n.questions];i[s]={...t,choices:e},u("questions",i)}else if(N.includes(i)){const e=n.questions.filter(((e,t)=>t===s))[0];let t=[...n.questions];t[s]={...e,choices:a},u("questions",t)}u(`questions.${s}.type`,e.target.value)},"data-testid":`quiz-form-question-type-select-${s}`,children:null===p||void 0===p?void 0:p.map((e=>Object(g.jsx)("option",{value:e.value,"data-testid":`quiz-form-question-type-select-option-${s}-${e.value}`,children:e.text},e.value)))})}),n.questions.length>1&&Object(g.jsx)(r.a,{md:1,xs:1,children:Object(g.jsx)(m.a,{id:`remove-text-tooltip-${s}`,position:"right",title:"Remove question",children:Object(g.jsx)(d.a,{className:"cursor-pointer float-right my-1",style:{fontSize:"18px"},onClick:()=>{const e=n.questions.filter(((e,t)=>t!==s));u("questions",e),1===e.length&&u("title",v(e[0].question))},"data-testid":`quiz-form-remove-question-button-${s}`})})})]})}),Object(g.jsxs)(r.a,{md:12,xs:12,children:[Object(g.jsx)(i.b,{className:"form-control form-control-sm w-100",name:`questions.${s}.question`,type:"textarea",component:x,placeholder:`Enter ${e.type===w?"instruction":"question"}...`,onChange:e=>{u(`questions.${s}.question`,e),1===n.questions.length&&u("title",v(e))},"data-testid":`quiz-form-question-input-${s}`}),t.questions&&t.questions[s]&&t.questions[s].question&&Object(g.jsx)("div",{className:"text-danger ml-1","data-testid":`quiz-form-question-error-${s}`,children:t.questions[s].question})]})]})}),Object(g.jsx)(r.a,{xs:12,className:"",children:!N.includes(e.type)&&Object(g.jsxs)("div",{className:"ml-3 mt-1",children:[e.choices.map(((o,l)=>{var d,h,b,p;return Object(g.jsxs)(a.a,{className:"mb-1  p-3 rounded",children:[Object(g.jsxs)(r.a,{xs:1,children:["Choice: # ",l+1]}),Object(g.jsx)(r.a,{xs:e.choices.length>1?10:11,children:Object(g.jsxs)(a.a,{children:[Object(g.jsxs)(r.a,{xs:12,children:[Object(g.jsx)(i.b,{className:"form-control form-control-sm w-100 ",name:`questions.${s}.choices.${l}.text`,type:"textarea",height:100,component:x,placeholder:"Enter choice text...","data-testid":`quiz-form-question-choice-text-input-${s}-${l}`}),t.questions&&(null===(d=t.questions[s])||void 0===d?void 0:d.choices)&&(null===(h=t.questions[s])||void 0===h?void 0:h.choices[l])&&(null===(b=t.questions[s])||void 0===b||null===(p=b.choices[l])||void 0===p?void 0:p.text)&&Object(g.jsx)("span",{className:"text-danger","data-testid":`quiz-form-question-choice-text-error-${s}-${l}`,children:t.questions[s].choices[l].text})]}),Object(g.jsx)(r.a,{xs:12,children:Object(g.jsx)(i.b,{as:"select",name:`questions.${s}.choices.${l}.is_correct`,className:"form-control form-control-sm mt-2",style:{height:"calc(1.5em + 0.5rem + 2px)",padding:"0.25rem 0.5rem",fontSize:"0.875rem",lineHeight:"1.5",bordeRadius:"0.2rem"},onChange:e=>{if("true"===e.target.value&&"SINGLE_CHOICE"===n.questions[s].type){const e=n.questions[s].choices.map(((e,t)=>({...e,is_correct:t===l}))),t=n.questions.filter(((e,t)=>t===s))[0];let i=[...n.questions];i[s]={...t,choices:e},u("questions",i)}else u(`questions.${s}.choices.${l}.is_correct`,"true"===e.target.value)},"data-testid":`quiz-form-question-choice-is-correct-select-${s}-${l}`,children:[{text:"Correct",value:!0},{text:"Incorrect",value:!1}].map((e=>Object(g.jsx)("option",{value:e.value,"data-testid":`quiz-form-question-choice-is-correct-select-option-${s}-${l}-${e.value}`,children:e.text},e.value)))})})]})}),e.choices.length>1&&Object(g.jsx)(r.a,{xs:1,children:Object(g.jsx)(m.a,{id:`remove-choice-tooltip-${l}`,position:"right",title:"Remove choice",children:Object(g.jsx)(c.a,{className:"cursor-pointer my-1",style:{fontSize:"14px"},onClick:()=>{const t=e.choices.filter(((e,t)=>t!==l)),i=n.questions.filter(((e,t)=>t===s))[0];let a=[...n.questions];a[s]={...i,choices:t},u("questions",a)},"data-testid":`quiz-form-remove-choice-button-${s}-${l}`})})})]},l)})),Object(g.jsxs)(a.a,{children:[Object(g.jsx)(r.a,{xs:12,children:t.questions&&(null===(o=t.questions[s])||void 0===o?void 0:o.choices)&&"string"===typeof t.questions[s].choices&&Object(g.jsx)("span",{className:"text-danger","data-testid":`quiz-form-question-choices-error-${s}`,children:t.questions[s].choices})}),Object(g.jsx)(r.a,{md:12,children:Object(g.jsxs)("span",{className:"font-weight-bold cursor-pointer",onClick:()=>{u(`questions.${s}.choices`,[...e.choices,{text:"",is_correct:!1}])},"data-testid":`quiz-form-add-choice-button-${s}`,children:[Object(g.jsx)(l.h,{style:{fontSize:"20px"}})," Add Choice"]})})]})]})})]},s)})),Object(g.jsx)("div",{className:"mt-4",children:Object(g.jsxs)("span",{className:"font-weight-bold cursor-pointer",onClick:()=>{const e=n.questions[n.questions.length-1];u("questions",[...n.questions,{...f,order:e.order+1}])},children:[Object(g.jsx)(l.h,{style:{fontSize:"20px"},"data-testid":"quiz-form-add-question-button-icon"})," ","Add another question"]})})]})})]}),Object(g.jsx)(o.a,{className:"float-right",type:"submit",disabled:s,children:s?"Saving....":"Save"})]})}})}},929:function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return a}));var i=n(1),s=n.n(i),a=e=>{let{src:t="",host:n="cdn.docuseal.co",role:i="",submitter:a="",preview:r=!1,expand:o=!0,minimize:c=!1,email:l="",backgroundColor:d="",sendCopyEmail
2:u,applicationKey:h="",externalId:m="",logo:b="",language:p="",completedRedirectUrl:j="",completedButton:f={title:"",url:""},goToLast:g=!0,skipFields:v=!1,autoscrollFields:x=!0,withTitle:y=!0,withFieldNames:O=!0,withDownloadButton:w=!0,allowToResubmit:_=!0,allowTypedSignature:C=!0,withSendCopyButton:N=!0,values:k={},metadata:S={},i18n:E={},fields:I=[],readonlyFields:T=[],onComplete:q=(()=>{}),onInit:A=(()=>{}),onLoad:z=(()=>{}),className:L="",customCss:$="",style:P={}}=e,R="docuseal-form-script",M=`https://${n}/js/form.js`,F=typeof window>"u",D=F?null:s.a.useRef(null);return F||(s.a.useEffect((()=>{if(!document.getElementById(R)){let e=document.createElement("script");e.id=R,e.async=!0,e.src=M,document.head.appendChild(e)}}),[]),s.a.useEffect((()=>{let e=null==D?void 0:D.current,t=e=>q&&q(e.detail);return e&&e.addEventListener("completed",t),()=>{e&&e.removeEventListener("completed",t)}}),[q]),s.a.useEffect((()=>{let e=null==D?void 0:D.current,t=e=>A&&A(e.detail);return e&&e.addEventListener("init",t),()=>{e&&e.removeEventListener("init",t)}}),[A]),s.a.useEffect((()=>{let e=null==D?void 0:D.current,t=e=>z&&z(e.detail);return e&&e.addEventListener("load",t),()=>{e&&e.removeEventListener("load",t)}}),[z])),s.a.createElement(s.a.Fragment,null,s.a.createElement("docuseal-form",{"data-src":t,"data-email":l,"data-role":i||a,"data-external-id":m||h,"data-expand":o,"data-minimize":c,"data-preview":r,"data-go-to-last":g,"data-skip-fields":v,"data-autoscroll-fields":x,"data-send-copy-email":u,"data-with-title":y,"data-logo":b,"data-language":p,"data-with-field-names":O,"data-with-download-button":w,"data-allow-to-resubmit":_,"data-allow-typed-signature":C,"data-completed-redirect-url":j,"data-with-send-copy-button":N,"data-values":JSON.stringify(k),"data-metadata":JSON.stringify(S),"data-fields":JSON.stringify(I),"data-i18n":JSON.stringify(E),"data-readonly-fields":T.join(","),"data-completed-button-title":f.title,"data-completed-button-url":f.url,"data-background-color":d,"data-custom-css":$,ref:D,className:L,style:P}),F&&s.a.createElement("script",{id:R,src:M,async:!0}))},r=e=>{let{token:t,host:n="cdn.docuseal.co",language:i="en",preview:a=!1,autosave:r=!0,withRecipientsButton:o=!0,withDocumentsList:c=!0,withFieldsList:l=!0,withSendButton:d=!0,withTitle:u=!0,onlyDefinedFields:h=!1,withSignYourselfButton:m=!0,withUploadButton:b=!0,roles:p=[],fields:j=[],requiredFields:f=[],i18n:g={},fieldTypes:v=[],drawFieldType:x="text",customButton:y={title:"",url:""},backgroundColor:O="",onLoad:w=(()=>{}),onUpload:_=(()=>{}),onSend:C=(()=>{}),onSave:N=(()=>{}),onChange:k=(()=>{}),className:S="",sendButtonText:E="",saveButtonText:I="",customCss:T="",style:q={}}=e,A="docuseal-builder-script",z=`https://${n}/js/builder.js`,L=typeof window>"u",$=L?null:s.a.useRef(null);return L||(s.a.useEffect((()=>{if(!document.getElementById(A)){let e=document.createElement("script");e.id=A,e.async=!0,e.src=z,document.head.appendChild(e)}}),[]),s.a.useEffect((()=>{let e=null==$?void 0:$.current,t=e=>C&&C(e.detail);return e&&e.addEventListener("send",t),()=>{e&&e.removeEventListener("send",t)}}),[C]),s.a.useEffect((()=>{let e=null==$?void 0:$.current,t=e=>w&&w(e.detail);return e&&e.addEventListener("load",t),()=>{e&&e.removeEventListener("load",t)}}),[w]),s.a.useEffect((()=>{let e=null==$?void 0:$.current,t=e=>_&&_(e.detail);return e&&e.addEventListener("upload",t),()=>{e&&e.removeEventListener("upload",t)}}),[_]),s.a.useEffect((()=>{let e=null==$?void 0:$.current,t=e=>N&&N(e.detail);return e&&e.addEventListener("save",t),()=>{e&&e.removeEventListener("save",t)}}),[N]),s.a.useEffect((()=>{let e=null==$?void 0:$.current,t=e=>k&&k(e.detail);return e&&e.addEventListener("change",t),()=>{e&&e.removeEventListener("change",t)}}),[k])),s.a.createElement(s.a.Fragment,null,s.a.createElement("docuseal-builder",{"data-token":t,"data-preview":a,"data-language":i,"data-autosave":r,"data-send-button-text":E,"data-save-button-text":I,"data-roles":p.join(","),"data-field-types":v.join(","),"data-draw-field-type":x,"data-fields":JSON.stringify(j),"data-required-fields":JSON.stringify(f),"data-i18n":JSON.stringify(g),"data-custom-button-title":y.title,"data-custom-button-url":y.url,"data-with-recipients-button":o,"data-with-send-button":d,"data-with-documents-list":c,"data-with-fields-list":l,"data-with-title":u,"data-only-def
2ined-fields":h,"data-with-upload-button":b,"data-with-sign-yourself-button":m,"data-background-color":O,"data-custom-css":T,ref:$,className:S,style:q}),L&&s.a.createElement("script",{id:A,src:z,async:!0}))}},943:function(e,t,n){var i,s,a,r;e.exports=(i=n(10),s=n(1),a=n(962),r=n(963),function(e){function t(i){if(n[i])return n[i].exports;var s=n[i]={exports:{},id:i,loaded:!1};return e[i].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function s(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),d=i(n(1)),u=n(2),h=i(u),m=i(n(3)),b=i(n(4)),p=function(e){function t(){var e,n,i;a(this,t);for(var o=arguments.length,c=Array(o),l=0;l<o;l++)c[l]=arguments[l];return n=i=r(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(c))),i._sigPad=null,i._excludeOurProps=function(){var e=i.props;return e.canvasProps,e.clearOnResize,s(e,["canvasProps","clearOnResize"])},i.getCanvas=function(){return i._canvas},i.getTrimmedCanvas=function(){var e=document.createElement("canvas");return e.width=i._canvas.width,e.height=i._canvas.height,e.getContext("2d").drawImage(i._canvas,0,0),(0,b.default)(e)},i.getSignaturePad=function(){return i._sigPad},i._checkClearOnResize=function(){i.props.clearOnResize&&i._resizeCanvas()},i._resizeCanvas=function(){var e=i.props.canvasProps||{},t=e.width,n=e.height;if(!t||!n){var s=i._canvas,a=Math.max(window.devicePixelRatio||1,1);t||(s.width=s.offsetWidth*a),n||(s.height=s.offsetHeight*a),s.getContext("2d").scale(a,a),i.clear()}},i.on=function(){return window.addEventListener("resize",i._checkClearOnResize),i._sigPad.on()},i.off=function(){return window.removeEventListener("resize",i._checkClearOnResize),i._sigPad.off()},i.clear=function(){return i._sigPad.clear()},i.isEmpty=function(){return i._sigPad.isEmpty()},i.fromDataURL=function(e,t){return i._sigPad.fromDataURL(e,t)},i.toDataURL=function(e,t){return i._sigPad.toDataURL(e,t)},i.fromData=function(e){return i._sigPad.fromData(e)},i.toData=function(){return i._sigPad.toData()},r(i,n)}return o(t,e),l(t,[{key:"componentDidMount",value:function(){this._sigPad=new m.default(this._canvas,this._excludeOurProps()),this._resizeCanvas(),this.on()}},{key:"componentWillUnmount",value:function(){this.off()}},{key:"componentDidUpdate",value:function(){Object.assign(this._sigPad,this._excludeOurProps())}},{key:"render",value:function(){var e=this,t=this.props.canvasProps;return h.default.createElement("canvas",c({ref:function(t){e._canvas=t}},t))}}]),t}(u.Component);p.propTypes={velocityFilterWeight:d.default.number,minWidth:d.default.number,maxWidth:d.default.number,minDistance:d.default.number,dotSize:d.default.oneOfType([d.default.number,d.default.func]),penColor:d.default.string,throttle:d.default.number,onEnd:d.default.func,onBegin:d.default.func,canvasProps:d.default.object,clearOnResize:d.default.bool},p.defaultProps={clearOnResize:!0},t.default=p},function(e,t){e.exports=i},function(e,t){e.exports=s},function(e,t){e.exports=a},function(e,t){e.exports=r}]))},960:function(e,t,n){"use strict";n.d(t,"a",(function(){return b}));var i=n(1),s=n(838),a=n(834),r=n(68),o=n(31),c=n(837),l=n(19),d=n(911),u=n(11),h=n(381),m=n(3);function b(e){const[t,n]=Object(i.useState)(!1),[b,p]=Object(i.useState)(!1),{user_is_kb_admin:j,user_is_kb_article_admin:f}=Object(l.d)((e=>{var t,n;return(null===(t=e.account)||void 0===t||null===(n=t.user)||void 0===n?void 0:n.user_roles)||{}})),g=j||f,v=Object(l.c)(),x=e.className?e.className:"btn-sm ml-3 px-2 py-1 float-right btn-light",y=e.button?e.button:"View";return Object(m.jsxs)(m.Fragment,{children:[Object(m.jsx)(s.a,{placement:"bottom",overlay:Object(m.jsx)(a.a,{children:"View This Article"}),children:Object(m.jsx)(r.a,{className:x,onClick:()=>n(!0),"data-testid":"view-article-modal-button",children:y})}),Object(m.jsx)(o.a,{size:"lg",enforceFocus:!1,backdrop:"static",show:t,onHide:()=>n(!1),children:Object(m.jsxs)(c.a,{children:[Object(m.jsxs)(o.a.Header,{closeButton:!0,className:"align-items-center",children:[Object(m.jsx)(o.a.Title,{children:"Company Article"}),g&&Object(m.jsx)(r.a,{className:b?"btn-sm btn-secondary ml-3 mt-2":"btn-sm ml-3 mt-2",onClick:()=>p((e=>!e)),"data-testid":"view-article-modal-edit-button",children:b?"Cancel":"Edit"})]}),b?Object(m.jsx)(o.a.Body,{children:Object(m.jsx)(h.a,{editArticle:!0,isCourseArt
vendor: 8,303 bytes, line 2
2icle:e.isCourseArticle,articleId:e.articleId,callbackFunc:()=>{p(!1),n(!1),v({type:u.Lb})}})}):Object(m.jsx)(d.b,{isCourseArticle:!0,articleId:e.articleId})]})})]})}},962:function(e,t,n){"use strict";function i(e,t,n){this.x=e,this.y=t,this.time=n||(new Date).getTime()}function s(e,t,n,i){this.startPoint=e,this.control1=t,this.control2=n,this.endPoint=i}function a(e,t){var n=this,i=t||{};this.velocityFilterWeight=i.velocityFilterWeight||.7,this.minWidth=i.minWidth||.5,this.maxWidth=i.maxWidth||2.5,this.throttle="throttle"in i?i.throttle:16,this.minDistance="minDistance"in i?i.minDistance:5,this.throttle?this._strokeMoveUpdate=function(e,t,n){var i,s,a,r=null,o=0;n||(n={});var c=function(){o=!1===n.leading?0:Date.now(),r=null,a=e.apply(i,s),r||(i=s=null)};return function(){var l=Date.now();o||!1!==n.leading||(o=l);var d=t-(l-o);return i=this,s=arguments,d<=0||d>t?(r&&(clearTimeout(r),r=null),o=l,a=e.apply(i,s),r||(i=s=null)):r||!1===n.trailing||(r=setTimeout(c,d)),a}}(a.prototype._strokeUpdate,this.throttle):this._strokeMoveUpdate=a.prototype._strokeUpdate,this.dotSize=i.dotSize||function(){return(this.minWidth+this.maxWidth)/2},this.penColor=i.penColor||"black",this.backgroundColor=i.backgroundColor||"rgba(0,0,0,0)",this.onBegin=i.onBegin,this.onEnd=i.onEnd,this._canvas=e,this._ctx=e.getContext("2d"),this.clear(),this._handleMouseDown=function(e){1===e.which&&(n._mouseButtonDown=!0,n._strokeBegin(e))},this._handleMouseMove=function(e){n._mouseButtonDown&&n._strokeMoveUpdate(e)},this._handleMouseUp=function(e){1===e.which&&n._mouseButtonDown&&(n._mouseButtonDown=!1,n._strokeEnd(e))},this._handleTouchStart=function(e){if(1===e.targetTouches.length){var t=e.changedTouches[0];n._strokeBegin(t)}},this._handleTouchMove=function(e){e.preventDefault();var t=e.targetTouches[0];n._strokeMoveUpdate(t)},this._handleTouchEnd=function(e){e.target===n._canvas&&(e.preventDefault(),n._strokeEnd(e))},this.on()}n.r(t),i.prototype.velocityFrom=function(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):1},i.prototype.distanceTo=function(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))},i.prototype.equals=function(e){return this.x===e.x&&this.y===e.y&&this.time===e.time},s.prototype.length=function(){for(var e=0,t=void 0,n=void 0,i=0;i<=10;i+=1){var s=i/10,a=this._point(s,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),r=this._point(s,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(i>0){var o=a-t,c=r-n;e+=Math.sqrt(o*o+c*c)}t=a,n=r}return e},s.prototype._point=function(e,t,n,i,s){return t*(1-e)*(1-e)*(1-e)+3*n*(1-e)*(1-e)*e+3*i*(1-e)*e*e+s*e*e*e},a.prototype.clear=function(){var e=this._ctx,t=this._canvas;e.fillStyle=this.backgroundColor,e.clearRect(0,0,t.width,t.height),e.fillRect(0,0,t.width,t.height),this._data=[],this._reset(),this._isEmpty=!0},a.prototype.fromDataURL=function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=new Image,s=n.ratio||window.devicePixelRatio||1,a=n.width||this._canvas.width/s,r=n.height||this._canvas.height/s;this._reset(),i.src=e,i.onload=function(){t._ctx.drawImage(i,0,0,a,r)},this._isEmpty=!1},a.prototype.toDataURL=function(e){var t;switch(e){case"image/svg+xml":return this._toSVG();default:for(var n=arguments.length,i=Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return(t=this._canvas).toDataURL.apply(t,[e].concat(i))}},a.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()},a.prototype.off=function(){this._canvas.removeEventListener("mousedown",this._handleMouseDown),this._canvas.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._canvas.removeEventListener("touchstart",this._handleTouchStart),this._canvas.removeEventListener("touchmove",this._handleTouchMove),this._canvas.removeEventListener("touchend",this._handleTouchEnd)},a.prototype.isEmpty=function(){return this._isEmpty},a.prototype._strokeBegin=function(e){this._data.push([]),this._reset(),this._strokeUpdate(e),"function"===typeof this.onBegin&&this.onBegin(e)},a.prototype._strokeUpdate=function(e){var t=e.clientX,n=e.clientY,i=this._createPoint(t,n),s=this._data[this._data.length-1],a=s&&s[s.length-1],r=a&&i.distanceTo(a)<this.minDistance;if(!a||!r){var o=this._addPoint(i),c=o.curve,l=o.widths;c&&l&&this._drawCurve(c,l.start,l.end),this._data[this._data.length-1].push({x:i.x,y:i.y,time:i.time,color:this.penColor})}},a.prototype._strokeEnd=function(e){var t=this.points.length>2,n=this.points[0];if(!t&&n&&this._drawDot(n),n){var i=this._data[this._data.length-1],s=i[i.length-1];n.equals(s)||i.push({x:n.x,y:n.y,time:n.time,color:this.penColor})}"function"===typeof this.onEnd&&this.onEnd(e)},a.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)},a.prototype._handleTouchEvents=function(){this._canvas.style.msTouchAction="none",this._canvas.style.touchAction="none",this._canvas.addEventListener("touchstart",this._handleTouchStart),this._canvas.addEventListener("touchmove",this._handleTouchMove),this._canvas.addEventListener("touchend",this._handleTouchEnd)},a.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._ctx.fillStyle=this.penColor},a.prototype._createPoint=function(e,t,n){var s=this._canvas.getBoundingClientRect();return new i(e-s.left,t-s.top,n||(new Date).getTime())},a.prototype._addPoint=function(e){var t=this.points;if(t.push(e),t.length>2){3===t.length&&t.unshift(t[0]);var n=this._calculateCurveControlPoints(t[0],t[1],t[2]).c2,i=this._calculateCurveControlPoints(t[1],t[2],t[3]).c1,a=new s(t[1],n,i,t[2]),r=this._calculateCurveWidths(a);return t.shift(),{curve:a,widths:r}}return{}},a.prototype._calculateCurveControlPoints=function(e,t,n){var s=e.x-t.x,a=e.y-t.y,r=t.x-n.x,o=t.y-n.y,c=(e.x+t.x)/2,l=(e.y+t.y)/2,d=(t.x+n.x)/2,u=(t.y+n.y)/2,h=Math.sqrt(s*s+a*a),m=Math.sqrt(r*r+o*o),b=m/(h+m),p=d+(c-d)*b,j=u+(l-u)*b,f=t.x-p,g=t.y-j;return{c1:new i(c+f,l+g),c2:new i(d+f,u+g)}},a.prototype._calculateCurveWidths=function(e){var t=e.startPoint,n=e.endPoint,i={start:null,end:null},s=this.velocityFilterWeight*n.velocityFrom(t)+(1-this.velocityFilterWeight)*this._lastVelocity,a=this._strokeWidth(s);return i.start=this._lastWidth,i.end=a,this._lastVelocity=s,this._lastWidth=a,i},a.prototype._strokeWidth=function(e){return Math.max(this.maxWidth/(e+1),this.minWidth)},a.prototype._drawPoint=function(e,t,n){var i=this._ctx;i.moveTo(e,t),i.arc(e,t,n,0,2*Math.PI,!1),this._isEmpty=!1},a.prototype._drawCurve=function(e,t,n){var i=this._ctx,s=n-t,a=Math.floor(e.length());i.beginPath();for(var r=0;r<a;r+=1){var o=r/a,c=o*o,l=c*o,d=1-o,u=d*d,h=u*d,m=h*e.startPoint.x;m+=3*u*o*e.control1.x,m+=3*d*c*e.control2.x,m+=l*e.endPoint.x;var b=h*e.startPoint.y;b+=3*u*o*e.control1.y,b+=3*d*c*e.control2.y,b+=l*e.endPoint.y;var p=t+l*s;this._drawPoint(m,b,p)}i.closePath(),i.fill()},a.prototype._drawDot=function(e){var t=this._ctx,n="function"===typeof this.dotSize?this.dotSize():this.dotSize;t.beginPath(),this._drawPoint(e.x,e.y,n),t.closePath(),t.fill()},a.prototype._fromData=function(e,t,n){for(var s=0;s<e.length;s+=1){var a=e[s];if(a.length>1)for(var r=0;r<a.length;r+=1){var o=a[r],c=new i(o.x,o.y,o.time),l=o.color;if(0===r)this.penColor=l,this._reset(),this._addPoint(c);else if(r!==a.length-1){var d=this._addPoint(c),u=d.curve,h=d.widths;u&&h&&t(u,h,l)}}else this._reset(),n(a[0])}},a.prototype._toSVG=function(){var e=this,t=this._data,n=this._canvas,i=Math.max(window.devicePixelRatio||1,1),s=n.width/i,a=n.height/i,r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttributeNS(null,"width",n.width),r.setAttributeNS(null,"height",n.height),this._fromData(t,(function(e,t,n){var i=document.createElement("path");if(!isNaN(e.control1.x)&&!isNaN(e.control1.y)&&!isNaN(e.control2.x)&&!isNaN(e.control2.y)){var s="M "+e.startPoint.x.toFixed(3)+","+e.startPoint.y.toFixed(3)+" C "+e.control1.x.toFixed(3)+","+e.control1.y.toFixed(3)+" "+e.control2.x.toFixed(3)+","+e.control2.y.toFixed(3)+" "+e.endPoint.x.toFixed(3)+","+e.endPoint.y.toFixed(3);
2i.setAttribute("d",s),i.setAttribute("stroke-width",(2.25*t.end).toFixed(3)),i.setAttribute("stroke",n),i.setAttribute("fill","none"),i.setAttribute("stroke-linecap","round"),r.appendChild(i)}}),(function(t){var n=document.createElement("circle"),i="function"===typeof e.dotSize?e.dotSize():e.dotSize;n.setAttribute("r",i),n.setAttribute("cx",t.x),n.setAttribute("cy",t.y),n.setAttribute("fill",t.color),r.appendChild(n)}));var o='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 '+s+" "+a+'" width="'+s+'" height="'+a+'">',c=r.innerHTML;if(void 0===c){var l=document.createElement("dummy"),d=r.childNodes;l.innerHTML="";for(var u=0;u<d.length;u+=1)l.appendChild(d[u].cloneNode(!0));c=l.innerHTML}return"data:image/svg+xml;base64,"+btoa(o+c+"</svg>")},a.prototype.fromData=function(e){var t=this;this.clear(),this._fromData(e,(function(e,n){return t._drawCurve(e,n.start,n.end)}),(function(e){return t._drawDot(e)})),this._data=e},a.prototype.toData=function(){return this._data},t.default=a},963:function(e,t,n){e.exports=function(e){function t(i){if(n[i])return n[i].exports;var s=n[i]={exports:{},id:i,loaded:!1};return e[i].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){"use strict";function n(e){var t=e.getContext("2d"),n=e.width,i=e.height,s=t.getImageData(0,0,n,i).data,o=a(!0,n,i,s),c=a(!1,n,i,s),l=r(!0,n,i,s),d=r(!1,n,i,s)-l+1,u=c-o+1,h=t.getImageData(l,o,d,u);return e.width=d,e.height=u,t.clearRect(0,0,d,u),t.putImageData(h,0,0),e}function i(e,t,n,i){return{red:i[4*(n*t+e)],green:i[4*(n*t+e)+1],blue:i[4*(n*t+e)+2],alpha:i[4*(n*t+e)+3]}}function s(e,t,n,s){return i(e,t,n,s).alpha}function a(e,t,n,i){for(var a=e?1:-1,r=e?0:n-1;e?r<n:r>-1;r+=a)for(var o=0;o<t;o++)if(s(o,r,t,i))return r;return null}function r(e,t,n,i){for(var a=e?1:-1,r=e?0:t-1;e?r<t:r>-1;r+=a)for(var o=0;o<n;o++)if(s(r,o,t,i))return r;return null}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n}])},964:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n(3);const s=e=>Object(i.jsxs)("svg",{stroke:"currentColor",fill:"none",strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",children:[Object(i.jsx)("circle",{cx:"12",cy:"3",r:"1"}),Object(i.jsx)("circle",{cx:"19",cy:"3",r:"1"}),Object(i.jsx)("circle",{cx:"5",cy:"3",r:"1"}),Object(i.jsx)("circle",{cx:"12",cy:"10",r:"1"}),Object(i.jsx)("circle",{cx:"19",cy:"10",r:"1"}),Object(i.jsx)("circle",{cx:"5",cy:"10",r:"1"}),Object(i.jsx)("circle",{cx:"12",cy:"17",r:"1"}),Object(i.jsx)("circle",{cx:"19",cy:"17",r:"1"}),Object(i.jsx)("circle",{cx:"5",cy:"17",r:"1"})]})},970:function(e,t,n){"use strict";n.d(t,"a",(function(){return f})),n.d(t,"c",(function(){return g})),n.d(t,"b",(function(){return v})),n.d(t,"f",(function(){return x})),n.d(t,"e",(function(){return y})),n.d(t,"d",(function(){return O}));var i=n(1),s=n.n(i),a=n(113);var r=n(986),o=n(3);var c=n(19),l=n(914),d=n(1046);var u=n(987),h=n(43),m=n(898),b=n(1043),p=n(911),j=n(1026);const f="ARTICLE",g="QUIZ",v="FILE_TYPE",x=e=>{var t,n,i;return(null===(t=e.quiz)||void 0===t?void 0:t.title)||(null===(n=e.article)||void 0===n?void 0:n.title)||(null===(i=e.file_type)||void 0===i?void 0:i.title)},y=e=>({[f]:"#04a9f5",[g]:"#51b33eff",[v]:"#dc3545"}[e]),O=[{id:1,title:"Articles",type:f,itemKey:"article",itemTitleKey:"title",badgeColor:y(f),courseDetailReadComponent:function(e){let{itemId:t,isLastCourseItem:n,onAcknowledgementComplete:a}=e;const[r,c]=Object(i.useState)(!1),[l,d]=Object(i.useState)(""),{article:f,loading:g,hasError:v,errorInfo:x,fetchArticleDetails:y}=Object(u.a)(t,{highlight_body_changes:!0,show_previous_version_if_draft:!0},!1);return s.a.useEffect((()=>{c(!1),d("")}),[t]),Object(o.jsxs)(o.Fragment,{children:[g?Object(o.jsx)(m.a,{}):Object(o.jsxs)(o.Fragment,{children:[!v&&f?Object(o.jsx)(j.a,{article:f,showDownloadPdf:!1,showCopyLink:!1,showEditButton:!1}):null,Object(o.jsx)(p.b,{article:f,loading:g,hasError:v,errorInfo:x,articleId:t,setArticleTranscript:d})]}),!g&&!v&&f&&!f.has_read&&Object(o.jsx)("div",{className:"printhide clearfix",style:{position:"relative",zIndex:2},children:Object(o.jsx)(b.a,{article:f,loading:g,hasError:v,articleTranscript:l,handleAcknowledgement:async e=>{c(!0);const n={answer:e||""};let i=!1;return await h.a.acknowledgeArticle(n,t)?(i=!0,y(),"function"===typeof a&&a()):console.log("Acknowledgement failed for item",t),c(!1),i}
2,isSubmitting:r,isCourseArticle:!0,isLastCourseItem:n})})]})}},{id:2,title:"Quizzes",type:g,itemKey:"quiz",itemTitleKey:"title",badgeColor:y(g),courseDetailReadComponent:function(e){let{itemId:t,courseSectionItemId:n,isLastCourseItem:i,onAcknowledgementComplete:s}=e;const a=Object(c.d)((e=>e.account.user));return Object(o.jsx)(d.a,{isCourseItem:!0,quizId:t,courseSectionItemId:n,isLastCourseItemToBeRead:i,handleCourseQuizAcknowledgement:async()=>!await Object(l.d)(null===a||void 0===a?void 0:a.id,t)||"function"!==typeof s||s(),showResponse:!0})}},{id:3,title:"E-Sign Files",type:v,itemTitleKey:"name",itemKey:"file_type",badgeColor:y(v),courseDetailReadComponent:function(e){let{itemId:t,isLastCourseItem:n,onAcknowledgementComplete:s}=e;const{fileType:c,loading:l,getFileTypeDetails:d}=function(e){const[t,n]=Object(i.useState)(!0),[s,r]=Object(i.useState)(null),[o,c]=Object(i.useState)();return{fileType:o,loading:t,error:s,getFileTypeDetails:async()=>{n(!0);try{const t=await a.a.getHRFileTypeDetails(e);t&&c(t)}catch(s){r("Error getting file types details")}n(!1)},setFileType:c}}(t);return Object(i.useEffect)((()=>{d()}),[t]),Object(o.jsx)("div",{children:l?Object(o.jsx)("p",{children:"Loading details..."}):Object(o.jsx)(r.a,{fileType:c,onSignComplete:async e=>{"function"===typeof s&&await s()}})})}}]},972:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));n(1);var i=n(76),s=n(3);function a(){return Object(s.jsxs)(s.Fragment,{children:[Object(s.jsx)(i.a,{variant:"rect",width:"60%",className:"mb-3"}),Object(s.jsx)(i.a,{variant:"rect",width:"100%",className:"mb-2"}),Object(s.jsx)(i.a,{variant:"rect",width:"100%",className:"mb-2"}),Object(s.jsx)(i.a,{variant:"rect",width:"100%",className:"mb-2"})]})}function r(){return Object(s.jsxs)(s.Fragment,{children:[Object(s.jsx)(a,{}),Object(s.jsx)("br",{}),Object(s.jsx)(a,{}),Object(s.jsx)("br",{}),Object(s.jsx)(a,{})]})}},986:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var i=n(929),s=(n(1),n(19)),a=n(8),r=n(113),o=n(3);function c(e){let{onSignComplete:t,fileType:n}=e;const c=Object(s.d)((e=>{var t;return null===e||void 0===e||null===(t=e.account)||void 0===t?void 0:t.user}));return Object(o.jsx)(i.b,{src:`https://docuseal.co/d/${n.template_slug}`,email:c.email+2,onComplete:async e=>{a.b.warning("E-Sign Saving...");const i=await r.a.getHumeSignDoc(e.submission_id,n.id,c.id,c.company.id);"function"===typeof t&&t(i),a.b.success("E-Sign Completed Successfully")}})}},987:function(e,t,n){"use strict";var i=n(1),s=n(43);function a(e){if(!e||"object"!==typeof e)return{status:0,title:"Unable to load",message:"Something went wrong while loading this article."};const t=e.response;if(!t)return{status:0,title:"Network error",message:e.message||"No response from the server. Check your connection and try again."};const n=t.status,i=t.data;let s="";if("string"===typeof i)s=i;else if(i&&"object"===typeof i&&(void 0!==i.detail&&null!==i.detail&&(s=Array.isArray(i.detail)?i.detail.map((e=>"string"===typeof e?e:e.msg||JSON.stringify(e))).join(" "):String(i.detail)),!s)){const e=Object.values(i).flat().filter((e=>null!=e&&String(e).length));s=e.length?e.map(String).join(" "):""}s||(s=t.statusText||e.message||"An error occurred");return{status:n,title:{400:"Invalid request",401:"Sign-in required",403:"Permission denied",404:"Not found",500:"Server error",502:"Server error",503:"Service unavailable"}[n]||"Something went wrong",message:s}}function r(e){return e&&"object"===typeof e&&("isAxiosError"in e||"response"in e&&"config"in e)}t.a=(e,t,n)=>{const[o,c]=Object(i.useState)(!!e),[l,d]=Object(i.useState)(!1),[u,h]=Object(i.useState)(null),[m,b]=Object(i.useState)(!1),p=async()=>{let i;d(!1),h(null),c(!0),i=n?await s.a.fetchPublicArticle(e,!0,t):await s.a.fetchArticle(e,!0,{...t||{},display_only:"true"}),!1===i||null==i?(d(!0),h({status:0,title:"Unable to load",message:"The article could not be loaded."}),b(null)):r(i)&&i.response&&i.response.status>=400||r(i)&&!i.response?(d(!0),h(a(i)),b(null)):(b(i),d(!1),h(null)),c(!1)};return Object(i.useEffect)((()=>{e?p():(c(!1),d(!1),h(null),b(!1))}),[e]),{article:m,hasError:l,errorInfo:u,loading:o,fetchArticleDetails:p}}},998:function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return s})),n.d(t,"c",(function(){return a})),n.d(t,"f",(function(){return r})),n.d(t,"e",(function(){return o}
2)),n.d(t,"d",(function(){return c})),n.d(t,"g",(function(){return l})),n.d(t,"h",(function(){return d}));const i=e=>`cat-${e}`,s=e=>`art-${e}`,a="root",r=e=>e===a?"root":e.startsWith("cat-")?"category":"article",o=e=>Number(e.split("-")[1]);function c(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n={[a]:{index:a,isFolder:!0,canMove:!1,canRename:!1,children:[],data:{kind:"root"}}},r=(e,a)=>{(e||[]).forEach((e=>{const o=i(e.id),c=[];r(e.subcategories||[],c);const l=t[e.id];Array.isArray(l)&&l.forEach((e=>{const t=s(e.id);n[t]={index:t,isFolder:!1,canMove:!0,canRename:!1,children:[],data:{kind:"article",id:e.id,title:e.title}},c.push(t)})),n[o]={index:o,isFolder:!0,canMove:!0,canRename:!1,children:c,data:{kind:"category",id:e.id,title:e.category,articles_count:e.articles_count,hasSubcats:(e.subcategories||[]).length>0}},a.push(o)}))};return r(e,n[a].children),n}function l(e,t){return Object.keys(e).find((n=>(e[n].children||[]).includes(t)))||null}function d(e,t){var n;const i=(null===(n=e[t])||void 0===n?void 0:n.children)||[],s=[],a=[];return i.forEach((e=>{"category"===r(e)?s.push(o(e)):"article"===r(e)&&a.push(o(e))})),{categoryIds:s,articleIds:a}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.