"use strict";(self.webpackChunkrichie_education=self.webpackChunkrichie_education||[]).push([[78419],{78419:function(e,t,r){r.r(t),r(10853),r(35054),r(55862),r(73214),r(96900),r(26364),r(86632),r(61928),r(54883),r(45007),r(68995),r(18821),r(33290),r(54994),r(4845),r(39275);var n=r(89526),i=r(10651),l=r(25002),o=r(355),a=r(71432),u=r(95418),c=r(97205),s=r(89241),m=r(67557);function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,l,o,a=[],u=!0,c=!1;try{if(l=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=l.call(r)).done)&&(a.push(n.value),a.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}t.default=function(e){var t,r=e.id,d=(0,a.k)().user,p=function(e){if(!e.ok)throw new Error("Failed to retrieve LTI consumer context at placeholder ".concat(r));return e.json()},v=f((0,s.p)(["lti-consumer-plugin-".concat(r)],(function(){var e=(null==d?void 0:d.username)||sessionStorage.getItem(u.Vy);null===e&&(e=(0,i.Z)(),sessionStorage.setItem(u.Vy,e));var t={lis_person_contact_email_primary:null==d?void 0:d.email,lis_person_name_given:null==d?void 0:d.username,lis_person_sourcedid:null==d?void 0:d.username,user_id:e};return fetch("/api/v1.0/plugins/lti-consumer/".concat(r,"/context/?").concat(o.Z.stringify(t,{skipNull:!0}))).then(p)}),{enabled:void 0!==d,staleTime:null!==(t=window.CMS)&&void 0!==t&&t.config.auth?0:u.o9.staleTimes.session,onError:c.p}),1)[0].data,y=(0,n.useRef)(null),h=(0,n.useRef)(null);return(0,n.useEffect)((function(){var e;if(v&&(null===(e=y.current)||void 0===e||e.submit(),v.is_automatic_resizing)){var t,r=null===(t=y.current)||void 0===t?void 0:t.closest(".richie-react--lti-consumer");(0,l.iframeResize)({minHeight:null==r?void 0:r.clientHeight},h.current),null==r||r.classList.remove("aspect-ratio"),null!=r&&r.attributes.getNamedItem("style")&&(null==r||r.attributes.removeNamedItem("style"))}}),[v]),v?(0,m.jsxs)("div",{className:"lti-consumer",children:[(0,m.jsx)("form",{ref:y,action:v.url,method:"POST",encType:"application/x-www-form-urlencoded",target:"lti_iframe_".concat(r),children:Object.entries(v.content_parameters).map((function(e){var t=f(e,2),r=t[0],n=t[1];return(0,m.jsx)("input",{type:"hidden",name:r,value:n},r)}))}),(0,m.jsx)("iframe",{ref:h,name:"lti_iframe_".concat(r),title:v.url,src:v.url,allow:"microphone *; camera *; midi *; geolocation *; encrypted-media *; fullscreen *; display-capture *; autoplay *",allowFullScreen:!0})]}):(0,m.jsx)("div",{className:"lti-consumer"})}}}]);
//# sourceMappingURL=78419.02a18e97b46d65f95209.index.js.map