@pie-element/math-templated 6.0.0-beta.1 → 6.0.0-next.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{_dll_react_dom as e,_dll_debug as t,_dll_react as n,_dll_prop_types as r,_dll_mui__material_styles as o,_dll_lodash as i,_dll_mui__material as a,_dll_pie_lib__render_ui as s,_dll_classnames as l,_dll_mui__icons_material as c,_dll_pie_lib__correct_answer_toggle as d}from"../../../@pie-lib/shared-module@^3.0.5/module/index.js";import{_dll_pie_lib__math_rendering as u}from"../../../@pie-lib/math-rendering-module@^4.0.5/module/index.js";import{_dll_pie_lib__math_input as p,_dll_pie_framework__mathquill as h}from"../../../@pie-lib/math-edit-module@^3.0.5/module/index.js";import{_dll_pie_lib__drag as g}from"../../../@pie-lib/drag-module@^3.0.5/module/index.js";var f,m=e;f=m.createRoot,m.hydrateRoot;var v,b,y,w={"border-radius":1,"border-top-left-radius":1,"border-top-right-radius":1,"border-bottom-left-radius":1,"border-bottom-right-radius":1,"box-shadow":1,order:1,flex:function(e,t){return[t+"box-flex"]},"box-flex":1,"box-align":1,animation:1,"animation-duration":1,"animation-name":1,transition:1,"transition-duration":1,transform:1,"transform-style":1,"transform-origin":1,"backface-visibility":1,perspective:1,"box-pack":1},x={animation:1,"column-count":1,columns:1,"font-weight":1,opacity:1,"order ":1,"z-index":1,zoom:1,flex:1,"box-flex":1,transform:1,perspective:1,"box-pack":1,"box-align":1,colspan:1,rowspan:1},C=function(e){return e.length?e.charAt(0).toUpperCase()+e.substring(1):e},k=C,E=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,S="undefined"==typeof document?{}:document.documentElement.style,R=(v=function(){for(var e in S)if(E.test(e))return e.match(E)[0];return"WebkitOpacity"in S?"Webkit":"KhtmlOpacity"in S?"Khtml":""}(),b=v.toLowerCase(),{style:v,css:"-"+b+"-",dom:{Webkit:"WebKit",ms:"MS",o:"WebKit"}[v]||k(v)}),A=function(e,t){return t?t.toUpperCase():""},D=/[-\s]+(.)?/g,_=function(e){return e?e.replace(D,A):""},T=/::/g,M=/([A-Z]+)([A-Z][a-z])/g,O=/([a-z\d])([A-Z])/g,N=/_/g,I=function(e,t){return e?e.replace(T,"/").replace(M,"$1_$2").replace(O,"$1_$2").replace(N,t||"-"):""},$=function(e){return I(e).toLowerCase()},L=_,j=$,W=function(e){return e.length?e.charAt(0).toLowerCase()+e.substring(1):e},B=C,P=R,H=w,z="undefined"==typeof document?{}:document.documentElement.style,F=function(e,t){t=t||{};var n=W(L(e)),r=j(e),o=y?n:r,i=P.style?y?P.style:P.css:"";if(n in z)return t.asString?o:[o];var a=o,s=H[r],l=[];if(y&&(a=B(o)),"function"==typeof s){var c=s(o,i)||[];c&&!Array.isArray(c)&&(c=[c]),c.length&&(c=c.map(function(e){return y?W(L(e)):j(e)})),l=l.concat(c)}return i&&l.push(i+a),l.push(o),t.asString||1==l.length?l[0]:l},q=Object.prototype.hasOwnProperty,U=function(e,t){return q.call(e,t)},K=Object.prototype.toString,V=Object.prototype.toString,X=F,Y=$,J=_,Q=U,Z=function(e){return!!e&&"[object Object]"===K.call(e)},G=function(e){return"[object Function]"===V.apply(e)},ee=function(e,t,n,r){X(t).forEach(function(t){e[r?r(t):t]=n})},te={cssUnitless:x},ne=function(e,t,n,r){"string"==typeof e&&(e=function(e){e=(e||"").split(";");var t={};return e.forEach(function(e){var n=e.split(":");2==n.length&&(t[n[0].trim()]=n[1].trim())}),t}(e)),(t=t||te).cssUnitless=t.cssUnitless||te.cssUnitless,r=r||{};var o,i,a,s,l,c,d,u,p=t.scope||{},h=null!=t.addUnits?t.addUnits:!p||null==p.addUnits||p.addUnits,g=(null!=t.cssUnitless?t.cssUnitless:p?p.cssUnitless:null)||{},f=(t.cssUnit||p?p.cssUnit:null)||"px",m=t.prefixProperties||(p?p.prefixProperties:null)||{},v=t.camelize?J:Y;for(a in e)if(Q(e,a)){if(s=e[a],i=Y(n?n+a:a),o=!1,u=!1,G(s)&&(d=s.call(p||e,s,a,i,e),Z(d)&&null!=d.value?(s=d.value,u=d.prefix,i=d.name?Y(d.name):i):s=d),c="number"==(l=typeof s)||"string"==l&&""!=s&&1*s==s,null==s||null==i||""===i)continue;if((c||"string"==l)&&(o=!0),!o&&null!=s.value&&s.prefix&&(o=!0,u=s.prefix,s=s.value),o){if(u=u||!!m[i],c&&(s=h&&!(i in g)?s+f:s+""),"border"!=i&&(i.indexOf("border")||~i.indexOf("radius")||~i.indexOf("width"))||!c||(i+="-width"),!i.indexOf("border-radius-")&&(i.replace(/border(-radius)(-(.*))/,function(e,t,n){var r={"-top":["-top-left","-top-right"],"-left":["-top-left","-bottom-left"],"-right":["-top-right","-bottom-right"],"-bottom":["-bottom-left","-bottom-right"]};n in r?(i=[],r[n].forEach(function(e){i.push("border"+e+t)})):i="border"+n+t}),Array.isArray(i))){i.forEach(function(e){u?ee(r,e,s,v):r[v(e)]=s});continue}u?ee(r,i,s,v):r[v(i)]=s}else ne(s,t,i+"-",r)}return r},re=ne,oe=U,ie={prefixProperties:w,cssUnitless:x,object:ne,string:function(e,t){e=re(e,t);var n,r=[];for(n in e)oe(e,n)&&r.push(n+": "+e[n]);return r.join("; ")}};const ae=t("@pie-lib:mask-markup:serialization"),se=["span"],le=["em","strong","u"],ce=(e,t)=>{const n=e.getAttribute(t);return r=(e=>{const t=/([\w-]*)\s*:\s*([^;]*)/g;let n;const r={};for(;n=t.exec(e);)r[n[1]]=n[2].trim();return r})(n),ie.object(r,{camelize:!0,addUnits:!1});var r},de=["border","class","style"],ue={b:"bold",em:"italic",u:"underline",s:"strikethrough",code:"code",strong:"strong"},pe=(e,t=[])=>{if(8===e.nodeType)return null;if(3===e.nodeType){const n={text:e.textContent};return t.length>0&&(n.marks=t.map(e=>({type:e,data:void 0}))),{object:"text",leaves:[n]}}if(1===e.nodeType){const r=e.tagName.toLowerCase(),o=ue[r];if(o){ae("[deserialize] mark: ",o);return{_flatten:!0,nodes:he(e.childNodes,[...t,o])}}if("math"===r)return{isMath:!0,nodes:[e]};const i=(e=>{if(!e.attributes||e.attributes.length<=0)return;const t={};let n;for(n=0;n<e.attributes.length;n++){const r=e.attributes[n];t[r.name]=r.value}return t})(e)||{};"audio"===r&&""===i.controls&&(i.controls=!0);const a=de.reduce((n=e,(e,t)=>{if(!n.getAttribute)return e;if(n.getAttribute(t))switch(t){case"style":e.style=ce(n,t);break;case"class":e.className=((e,t,n)=>{const r=e.getAttribute(n);return delete t.class,r})(n,e,t);break;default:e[t]=n.getAttribute(t)}return e}),{...i}),s=(e=>se.includes(e)?"inline":le.includes(e)?"mark":"block")(r),l=he(e.childNodes,t);return{object:s,type:r,data:{dataset:{...e.dataset},attributes:{...a}},nodes:l}}var n;return null},he=(e,t=[])=>{const n=[];for(let r=0;r<e.length;r++){const o=pe(e[r],t);null!==o&&(o._flatten&&o.nodes?n.push(...o.nodes):n.push(o))}return n},ge=n,fe=r,{get:me}=i,{styled:ve}=o,{renderMath:be}=u;function ye(e){let t,n=e[0],r=1;for(;r<e.length;){const o=e[r],i=e[r+1];if(r+=2,("optionalAccess"===o||"optionalCall"===o)&&null==n)return;"access"===o||"optionalAccess"===o?(t=n,n=i(n)):"call"!==o&&"optionalCall"!==o||(n=i((...e)=>n.call(t,...e)),t=void 0)}return n}const we=ve("div")(({theme:e})=>({paddingTop:e.spacing(2),paddingBottom:e.spacing(2)})),xe=ve("span")(()=>({display:"inline-block",width:".75em"})),Ce=["tbody","tr"],ke=(e,t,n,r,o,i)=>{if(!t)return null;const a=[];return(e.nodes||[]).forEach((e,s)=>{const l=e.type?`${e.type}-${s}`:`${s}`;if(e.isMath)return a.push(ge.createElement("span",{dangerouslySetInnerHTML:{__html:`<math displaystyle="true">${e.nodes[0].innerHTML}</math>`}})),a;if(r){const l=r(e,t,n);if(l)return a.push(l),void("td"!==ye([o,"optionalAccess",e=>e.type])&&"drag-in-the-blank"===i&&a.push(ge.createElement(xe,{key:`spacer-${s}`})))}if("text"===e.object){const t=e.leaves.reduce((e,t)=>{const n=t.text,r=((e,t)=>{const n=""===t.trim(),r=e&&e.type;return n&&Ce.includes(r)?void 0:t})(o,n);return r?e+r:e},""),n=(e=>{const t=e.leaves.find(e=>me(e,"marks",[]).length);return t?t.marks[0]:null})(e);if(n){let e;for(e in ue)if(ue[e]===n.type){const n=e;a.push(ge.createElement(n,{key:l},t));break}}else t.length>0&&(a.push(t),"td"!==ye([o,"optionalAccess",e=>e.type])&&"drag-in-the-blank"===i&&a.push(ge.createElement(xe,{key:`spacer-${s}`})))}else{const o=ke(e,t,n,r,e,i);if("p"===e.type||"paragraph"===e.type)a.push(ge.createElement(we,{key:l},o));else{const t=e.type;e.nodes&&e.nodes.length>0?a.push(ge.createElement(t,{key:l,...e.data.attributes},o)):a.push(ge.createElement(t,{key:l,...e.data.attributes}))}}}),a},Ee=ve("div")(()=>({display:"initial","&:not(.MathJax) table":{borderCollapse:"collapse"},"&:not(.MathJax) table td, &:not(.MathJax) table th":{padding:"8px 12px",textAlign:"left"}}));class Se extends ge.Component{constructor(e){super(e),Se.prototype.__init.call(this),this.internalContainerRef=ge.createRef()}static __initStatic(){this.propTypes={renderChildren:fe.func,layout:fe.object,value:fe.object,onChange:fe.func,elementType:fe.string,containerRef:fe.oneOfType([fe.func,fe.shape({current:fe.instanceOf(Element)})])}}componentDidMount(){const e=this.props.containerRef||this.internalContainerRef;e.current&&"function"==typeof be&&be(e.current)}__init(){this.handleChange=(e,t)=>{const n={...this.props.value,[e]:t};this.props.onChange(n)}}render(){const{value:e,layout:t,elementType:n,containerRef:r}=this.props,o=ke(t,e,this.handleChange,this.props.renderChildren,null,n),i=r||this.internalContainerRef;return ge.createElement(Ee,{ref:i},o)}}Se.__initStatic();const Re=/\{\{(\d+)\}\}/g;const Ae=n,De=r;var _e;const Te=(e,t)=>{const{markup:n}=(o=t,(r=e)?{markup:r.replace(Re,(e,t)=>`<span data-component="${o}" data-id="${t}"></span>`)}:{markup:""});var r,o;return(e=>{if(!e||!e.trim())return{object:"value",document:{object:"document",data:{},nodes:[{object:"block",type:"span",data:{},isVoid:!1,nodes:[]}]}};const t=(new DOMParser).parseFromString(e,"text/html");let n=he(t.body.childNodes);return!n.some(e=>"block"===e.object||"inline"===e.object)&&n.length>0&&(n=[{object:"block",type:"span",data:{},isVoid:!1,nodes:n}]),0===n.length&&(n=[{object:"block",type:"span",data:{},isVoid:!1,nodes:[]}]),{object:"value",document:{object:"document",data:{},nodes:n}}})(n).document},Me=(e,t)=>((_e=class extends Ae.Component{static __initStatic(){this.propTypes={markup:De.string,layout:De.object,value:De.object,onChange:De.func,customMarkMarkupComponent:De.func,elementType:De.string}}constructor(e){super(e),this.containerRef=Ae.createRef()}componentDidUpdate(e){if(this.props.markup!==e.markup){const e=this.containerRef.current;(e&&e.querySelectorAll('[data-latex][data-math-handled="true"]')||[]).forEach(e=>{const t=e.querySelector("mjx-container");t&&e.removeChild(t);const n=e.getAttribute("data-raw");e.innerHTML=n,e.removeAttribute("data-math-handled")})}}render(){const{markup:n,layout:r,value:o,onChange:i,elementType:a}=this.props,s=r||Te(n,e);return Ae.createElement(Se,{containerRef:this.containerRef,elementType:a,layout:s,value:o,onChange:i,renderChildren:t(this.props)})}}).__initStatic(),_e),{useMemo:Oe}=n,{useLayoutEffect:Ne}=n,{useEffect:Ie}=n,{useRef:$e}=n,{useCallback:Le}=n,je="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function We(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function Be(e){return"nodeType"in e}function Pe(e){var t,n;return e?We(e)?e:Be(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function He(e){const{Document:t}=Pe(e);return e instanceof t}function ze(e){return!We(e)&&e instanceof Pe(e).HTMLElement}function Fe(e){return e instanceof Pe(e).SVGElement}function qe(e){return e?We(e)?e.document:Be(e)?He(e)?e:ze(e)||Fe(e)?e.ownerDocument:document:document:document}const Ue=je?Ne:Ie;function Ke(e){const t=$e(e);return Ue(()=>{t.current=e}),Le(function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return null==t.current?void 0:t.current(...n)},[])}function Ve(e,t){void 0===t&&(t=[e]);const n=$e(e);return Ue(()=>{n.current!==e&&(n.current=e)},t),n}function Xe(e,t){const n=$e();return Oe(()=>{const t=e(n.current);return n.current=t,t},[...t])}function Ye(e){const t=Ke(e),n=$e(null),r=Le(e=>{e!==n.current&&(null==t||t(e,n.current)),n.current=e},[]);return[n,r]}function Je(e){const t=$e();return Ie(()=>{t.current=e},[e]),t.current}let Qe={};function Ze(e,t){return Oe(()=>{if(t)return t;const n=null==Qe[e]?0:Qe[e]+1;return Qe[e]=n,e+"-"+n},[e,t])}function Ge(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((t,n)=>{const r=Object.entries(n);for(const[n,o]of r){const r=t[n];null!=r&&(t[n]=r+e*o)}return t},{...t})}}const et=Ge(1),tt=Ge(-1);function nt(e){if(!e)return!1;const{KeyboardEvent:t}=Pe(e.target);return t&&e instanceof t}function rt(e){if(function(e){if(!e)return!1;const{TouchEvent:t}=Pe(e.target);return t&&e instanceof t}(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return function(e){return"clientX"in e&&"clientY"in e}(e)?{x:e.clientX,y:e.clientY}:null}const ot=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[ot.Translate.toString(e),ot.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),it="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function at(e){return e.matches(it)?e:e.querySelector(it)}const st=n,{useState:lt}=n,{useCallback:ct}=n,dt={display:"none"};function ut(e){let{id:t,value:n}=e;return st.createElement("div",{id:t,style:dt},n)}function pt(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return st.createElement("div",{id:t,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":r,"aria-atomic":!0},n)}const ht=n,{createContext:gt}=n,{useContext:ft}=n,{useEffect:mt}=n,{useState:vt}=n,{useCallback:bt}=n,{useMemo:yt}=n,{useRef:wt}=n,{memo:xt}=n,{useReducer:Ct}=n,{cloneElement:kt}=n,{forwardRef:Et}=n,{createPortal:St}=e,{unstable_batchedUpdates:Rt}=e,At=gt(null);const Dt={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},_t={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Tt(e){let{announcements:t=_t,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Dt}=e;const{announce:i,announcement:a}=function(){const[e,t]=lt("");return{announce:ct(e=>{null!=e&&t(e)},[]),announcement:e}}(),s=Ze("DndLiveRegion"),[l,c]=vt(!1);if(mt(()=>{c(!0)},[]),function(e){const t=ft(At);mt(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}(yt(()=>({onDragStart(e){let{active:n}=e;i(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&i(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;i(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;i(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;i(t.onDragCancel({active:n,over:r}))}}),[i,t])),!l)return null;const d=ht.createElement(ht.Fragment,null,ht.createElement(ut,{id:r,value:o.draggable}),ht.createElement(pt,{id:s,announcement:a}));return n?St(d,n):d}var Mt;function Ot(){}!function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"}(Mt||(Mt={}));const Nt=Object.freeze({x:0,y:0});function It(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function $t(e,t){const n=rt(e);if(!n)return"0 0";return(n.x-t.left)/t.width*100+"% "+(n.y-t.top)/t.height*100+"%"}function Lt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function jt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Wt(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const Bt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Wt(t,t.left,t.top),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=It(Wt(r),o);i.push({id:t,data:{droppableContainer:e,value:n}})}}return i.sort(Lt)};function Pt(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-r,s=i-n;if(r<o&&n<i){const n=t.width*t.height,r=e.width*e.height,o=a*s;return Number((o/(n+r-o)).toFixed(4))}return 0}const Ht=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const e of r){const{id:r}=e,i=n.get(r);if(i){const n=Pt(i,t);n>0&&o.push({id:r,data:{droppableContainer:e,value:n}})}}return o.sort(jt)};function zt(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Nt}const Ft=(qt=1,function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce((e,t)=>({...e,top:e.top+qt*t.y,bottom:e.bottom+qt*t.y,left:e.left+qt*t.x,right:e.right+qt*t.x}),{...e})});var qt;function Ut(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}const Kt={ignoreTransform:!1};function Vt(e,t){void 0===t&&(t=Kt);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=Pe(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=Ut(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:s}=r,l=e.left-a-(1-o)*parseFloat(n),c=e.top-s-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=o?e.width/o:e.width,u=i?e.height/i:e.height;return{width:d,height:u,top:c,right:l+d,bottom:c+u,left:l}}(n,t,r))}const{top:r,left:o,width:i,height:a,bottom:s,right:l}=n;return{top:r,left:o,width:i,height:a,bottom:s,right:l}}function Xt(e){return Vt(e,{ignoreTransform:!0})}function Yt(e,t){const n=[];return e?function r(o){if(null!=t&&n.length>=t)return n;if(!o)return n;if(He(o)&&null!=o.scrollingElement&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!ze(o)||Fe(o))return n;if(n.includes(o))return n;const i=Pe(e).getComputedStyle(o);return o!==e&&function(e,t){void 0===t&&(t=Pe(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(e=>{const r=t[e];return"string"==typeof r&&n.test(r)})}(o,i)&&n.push(o),function(e,t){return void 0===t&&(t=Pe(e).getComputedStyle(e)),"fixed"===t.position}(o,i)?n:r(o.parentNode)}(e):n}function Jt(e){const[t]=Yt(e,1);return null!=t?t:null}function Qt(e){return je&&e?We(e)?e:Be(e)?He(e)||e===qe(e).scrollingElement?window:ze(e)?e:null:null:null}function Zt(e){return We(e)?e.scrollX:e.scrollLeft}function Gt(e){return We(e)?e.scrollY:e.scrollTop}function en(e){return{x:Zt(e),y:Gt(e)}}var tn;function nn(e){return!(!je||!e)&&e===document.scrollingElement}function rn(e){const t={x:0,y:0},n=nn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}!function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"}(tn||(tn={}));const on={x:.2,y:.2};function an(e,t,n,r,o){let{top:i,left:a,right:s,bottom:l}=n;void 0===r&&(r=10),void 0===o&&(o=on);const{isTop:c,isBottom:d,isLeft:u,isRight:p}=rn(e),h={x:0,y:0},g={x:0,y:0},f=t.height*o.y,m=t.width*o.x;return!c&&i<=t.top+f?(h.y=tn.Backward,g.y=r*Math.abs((t.top+f-i)/f)):!d&&l>=t.bottom-f&&(h.y=tn.Forward,g.y=r*Math.abs((t.bottom-f-l)/f)),!p&&s>=t.right-m?(h.x=tn.Forward,g.x=r*Math.abs((t.right-m-s)/m)):!u&&a<=t.left+m&&(h.x=tn.Backward,g.x=r*Math.abs((t.left+m-a)/m)),{direction:h,speed:g}}function sn(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function ln(e){return e.reduce((e,t)=>et(e,en(t)),Nt)}function cn(e,t){if(void 0===t&&(t=Vt),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);Jt(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const dn=[["x",["left","right"],function(e){return e.reduce((e,t)=>e+Zt(t),0)}],["y",["top","bottom"],function(e){return e.reduce((e,t)=>e+Gt(t),0)}]];class un{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=Yt(t),r=ln(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[e,t,o]of dn)for(const i of t)Object.defineProperty(this,i,{get:()=>{const t=o(n),a=r[e]-t;return this.rect[i]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class pn{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)})},this.target=e}add(e,t,n){var r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function hn(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t&&r>t.y}var gn,fn;function mn(e){e.preventDefault()}function vn(e){e.stopPropagation()}!function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"}(gn||(gn={})),function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"}(fn||(fn={}));const bn={start:[fn.Space,fn.Enter],cancel:[fn.Esc],end:[fn.Space,fn.Enter,fn.Tab]},yn=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case fn.Right:return{...n,x:n.x+25};case fn.Left:return{...n,x:n.x-25};case fn.Down:return{...n,y:n.y+25};case fn.Up:return{...n,y:n.y-25}}};class wn{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new pn(qe(t)),this.windowListeners=new pn(Pe(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(gn.Resize,this.handleCancel),this.windowListeners.add(gn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(gn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&cn(n),t(Nt)}handleKeyDown(e){if(nt(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:o=bn,coordinateGetter:i=yn,scrollBehavior:a="smooth"}=r,{code:s}=e;if(o.end.includes(s))return void this.handleEnd(e);if(o.cancel.includes(s))return void this.handleCancel(e);const{collisionRect:l}=n.current,c=l?{x:l.left,y:l.top}:Nt;this.referenceCoordinates||(this.referenceCoordinates=c);const d=i(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=tt(d,c),r={x:0,y:0},{scrollableAncestors:o}=n.current;for(const n of o){const o=e.code,{isTop:i,isRight:s,isLeft:l,isBottom:c,maxScroll:u,minScroll:p}=rn(n),h=sn(n),g={x:Math.min(o===fn.Right?h.right-h.width/2:h.right,Math.max(o===fn.Right?h.left:h.left+h.width/2,d.x)),y:Math.min(o===fn.Down?h.bottom-h.height/2:h.bottom,Math.max(o===fn.Down?h.top:h.top+h.height/2,d.y))},f=o===fn.Right&&!s||o===fn.Left&&!l,m=o===fn.Down&&!c||o===fn.Up&&!i;if(f&&g.x!==d.x){const e=n.scrollLeft+t.x,i=o===fn.Right&&e<=u.x||o===fn.Left&&e>=p.x;if(i&&!t.y)return void n.scrollTo({left:e,behavior:a});r.x=i?n.scrollLeft-e:o===fn.Right?n.scrollLeft-u.x:n.scrollLeft-p.x,r.x&&n.scrollBy({left:-r.x,behavior:a});break}if(m&&g.y!==d.y){const e=n.scrollTop+t.y,i=o===fn.Down&&e<=u.y||o===fn.Up&&e>=p.y;if(i&&!t.x)return void n.scrollTo({top:e,behavior:a});r.y=i?n.scrollTop-e:o===fn.Down?n.scrollTop-u.y:n.scrollTop-p.y,r.y&&n.scrollBy({top:-r.y,behavior:a});break}}this.handleMove(e,et(tt(d,this.referenceCoordinates),r))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function xn(e){return Boolean(e&&"distance"in e)}function Cn(e){return Boolean(e&&"delay"in e)}wn.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=bn,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const t=i.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==o||o({event:e.nativeEvent}),!0)}return!1}}];class kn{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=Pe(e);return e instanceof t?e:qe(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:o}=e,{target:i}=o;this.props=e,this.events=t,this.document=qe(i),this.documentListeners=new pn(this.document),this.listeners=new pn(n),this.windowListeners=new pn(Pe(i)),this.initialCoordinates=null!=(r=rt(o))?r:Nt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(gn.Resize,this.handleCancel),this.windowListeners.add(gn.DragStart,mn),this.windowListeners.add(gn.VisibilityChange,this.handleCancel),this.windowListeners.add(gn.ContextMenu,mn),this.documentListeners.add(gn.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Cn(t))return this.timeoutId=setTimeout(this.handleStart,t.delay),void this.handlePending(t);if(xn(t))return void this.handlePending(t)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(gn.Click,vn,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(gn.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:o}=this,{onMove:i,options:{activationConstraint:a}}=o;if(!r)return;const s=null!=(t=rt(e))?t:Nt,l=tt(r,s);if(!n&&a){if(xn(a)){if(null!=a.tolerance&&hn(l,a.tolerance))return this.handleCancel();if(hn(l,a.distance))return this.handleStart()}return Cn(a)&&hn(l,a.tolerance)?this.handleCancel():void this.handlePending(a,l)}e.cancelable&&e.preventDefault(),i(s)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===fn.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const En={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Sn extends kn{constructor(e){const{event:t}=e,n=qe(t.target);super(e,En,n)}}Sn.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button)&&(null==r||r({event:n}),!0)}}];const Rn={move:{name:"mousemove"},end:{name:"mouseup"}};var An;!function(e){e[e.RightClick=2]="RightClick"}(An||(An={}));(class extends kn{constructor(e){super(e,Rn,qe(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==An.RightClick&&(null==r||r({event:n}),!0)}}];const Dn={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var _n,Tn;function Mn(e){let{acceleration:t,activator:n=_n.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:a=5,order:s=Tn.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:d,delta:u,threshold:p}=e;const h=function(e){let{delta:t,disabled:n}=e;const r=Je(t);return Xe(e=>{if(n||!r||!e)return On;const o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[tn.Backward]:e.x[tn.Backward]||-1===o.x,[tn.Forward]:e.x[tn.Forward]||1===o.x},y:{[tn.Backward]:e.y[tn.Backward]||-1===o.y,[tn.Forward]:e.y[tn.Forward]||1===o.y}}},[n,t,r])}({delta:u,disabled:!i}),[g,f]=function(){const e=$e(null);return[Le((t,n)=>{e.current=setInterval(t,n)},[]),Le(()=>{null!==e.current&&(clearInterval(e.current),e.current=null)},[])]}(),m=wt({x:0,y:0}),v=wt({x:0,y:0}),b=yt(()=>{switch(n){case _n.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case _n.DraggableRect:return o}},[n,o,l]),y=wt(null),w=bt(()=>{const e=y.current;if(!e)return;const t=m.current.x*v.current.x,n=m.current.y*v.current.y;e.scrollBy(t,n)},[]),x=yt(()=>s===Tn.TreeOrder?[...c].reverse():c,[s,c]);mt(()=>{if(i&&c.length&&b){for(const e of x){if(!1===(null==r?void 0:r(e)))continue;const n=c.indexOf(e),o=d[n];if(!o)continue;const{direction:i,speed:s}=an(e,o,b,t,p);for(const e of["x","y"])h[e][i[e]]||(s[e]=0,i[e]=0);if(s.x>0||s.y>0)return f(),y.current=e,g(w,a),m.current=s,void(v.current=i)}m.current={x:0,y:0},v.current={x:0,y:0},f()}else f()},[t,w,r,f,i,a,JSON.stringify(b),JSON.stringify(h),g,c,x,d,JSON.stringify(p)])}(class extends kn{constructor(e){super(e,Dn)}static setup(){return window.addEventListener(Dn.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Dn.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return!(o.length>1)&&(null==r||r({event:n}),!0)}}],function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"}(_n||(_n={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(Tn||(Tn={}));const On={x:{[tn.Backward]:!1,[tn.Forward]:!1},y:{[tn.Backward]:!1,[tn.Forward]:!1}};var Nn,In;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(Nn||(Nn={})),function(e){e.Optimized="optimized"}(In||(In={}));const $n=new Map;function Ln(e,t){return Xe(n=>e?n||("function"==typeof t?t(e):e):null,[t,e])}function jn(e){let{callback:t,disabled:n}=e;const r=Ke(t),o=yt(()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(r)},[n]);return mt(()=>()=>null==o?void 0:o.disconnect(),[o]),o}function Wn(e){return new un(Vt(e),e)}function Bn(e,t,n){void 0===t&&(t=Wn);const[r,o]=vt(null);function i(){o(r=>{if(!e)return null;var o;if(!1===e.isConnected)return null!=(o=null!=r?r:n)?o:null;const i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}const a=function(e){let{callback:t,disabled:n}=e;const r=Ke(t),o=yt(()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(r)},[r,n]);return mt(()=>()=>null==o?void 0:o.disconnect(),[o]),o}({callback(t){if(e)for(const n of t){const{type:t,target:r}=n;if("childList"===t&&r instanceof HTMLElement&&r.contains(e)){i();break}}}}),s=jn({callback:i});return Ue(()=>{i(),e?(null==s||s.observe(e),null==a||a.observe(document.body,{childList:!0,subtree:!0})):(null==s||s.disconnect(),null==a||a.disconnect())},[e]),r}const Pn=[];function Hn(e,t){void 0===t&&(t=[]);const n=wt(null);return mt(()=>{n.current=null},t),mt(()=>{const t=e!==Nt;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?tt(e,n.current):Nt}function zn(e){return yt(()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null,[e])}const Fn=[];function qn(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return ze(t)?t:e}const Un=[{sensor:Sn,options:{}},{sensor:wn,options:{}}],Kn={current:{}},Vn={draggable:{measure:Xt},droppable:{measure:Xt,strategy:Nn.WhileDragging,frequency:In.Optimized},dragOverlay:{measure:Vt}};class Xn extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const Yn={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Xn,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ot},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Vn,measureDroppableContainers:Ot,windowRect:null,measuringScheduled:!1},Jn={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ot,draggableNodes:new Map,over:null,measureDroppableContainers:Ot},Qn=gt(Jn),Zn=gt(Yn);function Gn(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Xn}}}function er(e,t){switch(t.type){case Mt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Mt.DragMove:return null==e.draggable.active?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Mt.DragEnd:case Mt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Mt.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Xn(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case Mt.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new Xn(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case Mt.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Xn(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function tr(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=ft(Qn),i=Je(r),a=Je(null==n?void 0:n.id);return mt(()=>{if(!t&&!r&&i&&null!=a){if(!nt(i))return;if(document.activeElement===i.target)return;const e=o.get(a);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=at(e);if(t){t.focus();break}}})}},[r,t,o,a,i]),null}function nr(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}const rr=gt({...Nt,scaleX:1,scaleY:1});var or;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}(or||(or={})),xt(function(e){var t,n,r,o;let{id:i,accessibility:a,autoScroll:s=!0,children:l,sensors:c=Un,collisionDetection:d=Ht,measuring:u,modifiers:p,...h}=e;const g=Ct(er,void 0,Gn),[f,m]=g,[v,b]=function(){const[e]=vt(()=>new Set),t=bt(t=>(e.add(t),()=>e.delete(t)),[e]);return[bt(t=>{let{type:n,event:r}=t;e.forEach(e=>{var t;return null==(t=e[n])?void 0:t.call(e,r)})},[e]),t]}(),[y,w]=vt(or.Uninitialized),x=y===or.Initialized,{draggable:{active:C,nodes:k,translate:E},droppable:{containers:S}}=f,R=null!=C?k.get(C):null,A=wt({initial:null,translated:null}),D=yt(()=>{var e;return null!=C?{id:C,data:null!=(e=null==R?void 0:R.data)?e:Kn,rect:A}:null},[C,R]),_=wt(null),[T,M]=vt(null),[O,N]=vt(null),I=Ve(h,Object.values(h)),$=Ze("DndDescribedBy",i),L=yt(()=>S.getEnabled(),[S]),j=yt(()=>({draggable:{...Vn.draggable,...null==W?void 0:W.draggable},droppable:{...Vn.droppable,...null==W?void 0:W.droppable},dragOverlay:{...Vn.dragOverlay,...null==W?void 0:W.dragOverlay}}),[null==(W=u)?void 0:W.draggable,null==W?void 0:W.droppable,null==W?void 0:W.dragOverlay]);var W;const{droppableRects:B,measureDroppableContainers:P,measuringScheduled:H}=function(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,a]=vt(null),{frequency:s,measure:l,strategy:c}=o,d=wt(e),u=function(){switch(c){case Nn.Always:return!1;case Nn.BeforeDragging:return n;default:return!n}}(),p=Ve(u),h=bt(function(e){void 0===e&&(e=[]),p.current||a(t=>null===t?e:t.concat(e.filter(e=>!t.includes(e))))},[p]),g=wt(null),f=Xe(t=>{if(u&&!n)return $n;if(!t||t===$n||d.current!==e||null!=i){const t=new Map;for(let n of e){if(!n)continue;if(i&&i.length>0&&!i.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,r=e?new un(l(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,i,n,u,l]);return mt(()=>{d.current=e},[e]),mt(()=>{u||h()},[n,u]),mt(()=>{i&&i.length>0&&a(null)},[JSON.stringify(i)]),mt(()=>{u||"number"!=typeof s||null!==g.current||(g.current=setTimeout(()=>{h(),g.current=null},s))},[s,u,h,...r]),{droppableRects:f,measureDroppableContainers:h,measuringScheduled:null!=i}}(L,{dragging:x,dependencies:[E.x,E.y],config:j.droppable}),z=function(e,t){const n=null!=t?e.get(t):void 0,r=n?n.node.current:null;return Xe(e=>{var n;return null==t?null:null!=(n=null!=r?r:e)?n:null},[r,t])}(k,C),F=yt(()=>O?rt(O):null,[O]),q=function(){const e=!1===(null==T?void 0:T.autoScrollEnabled),t="object"==typeof s?!1===s.enabled:!1===s,n=x&&!e&&!t;if("object"==typeof s)return{...s,enabled:n};return{enabled:n}}(),U=function(e,t){return Ln(e,t)}(z,j.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=wt(!1),{x:a,y:s}="boolean"==typeof o?{x:o,y:o}:o;Ue(()=>{if(!a&&!s||!t)return void(i.current=!1);if(i.current||!r)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const o=zt(n(e),r);if(a||(o.x=0),s||(o.y=0),i.current=!0,Math.abs(o.x)>0||Math.abs(o.y)>0){const t=Jt(e);t&&t.scrollBy({top:o.y,left:o.x})}},[t,a,s,r,n])}({activeNode:null!=C?k.get(C):null,config:q.layoutShiftCompensation,initialRect:U,measure:j.draggable.measure});const K=Bn(z,j.draggable.measure,U),V=Bn(z?z.parentElement:null),X=wt({activatorEvent:null,active:null,activeNode:z,collisionRect:null,collisions:null,droppableRects:B,draggableNodes:k,draggingNode:null,draggingNodeRect:null,droppableContainers:S,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Y=S.getNodeFor(null==(t=X.current.over)?void 0:t.id),J=function(e){let{measure:t}=e;const[n,r]=vt(null),o=jn({callback:bt(e=>{for(const{target:n}of e)if(ze(n)){r(e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),i=bt(e=>{const n=qn(e);null==o||o.disconnect(),n&&(null==o||o.observe(n)),r(n?t(n):null)},[t,o]),[a,s]=Ye(i);return yt(()=>({nodeRef:a,rect:n,setRef:s}),[n,a,s])}({measure:j.dragOverlay.measure}),Q=null!=(n=J.nodeRef.current)?n:z,Z=x?null!=(r=J.rect)?r:K:null,G=Boolean(J.nodeRef.current&&J.rect),ee=zt(te=G?null:K,Ln(te));var te;const ne=zn(Q?Pe(Q):null),re=function(e){const t=wt(e),n=Xe(n=>e?n&&n!==Pn&&e&&t.current&&e.parentNode===t.current.parentNode?n:Yt(e):Pn,[e]);return mt(()=>{t.current=e},[e]),n}(x?null!=Y?Y:z:null),oe=function(e,t){void 0===t&&(t=Vt);const[n]=e,r=zn(n?Pe(n):null),[o,i]=vt(Fn);function a(){i(()=>e.length?e.map(e=>nn(e)?r:new un(t(e),e)):Fn)}const s=jn({callback:a});return Ue(()=>{null==s||s.disconnect(),a(),e.forEach(e=>null==s?void 0:s.observe(e))},[e]),o}(re),ie=nr(p,{transform:{x:E.x-ee.x,y:E.y-ee.y,scaleX:1,scaleY:1},activatorEvent:O,active:D,activeNodeRect:K,containerNodeRect:V,draggingNodeRect:Z,over:X.current.over,overlayNodeRect:J.rect,scrollableAncestors:re,scrollableAncestorRects:oe,windowRect:ne}),ae=F?et(F,E):null,se=function(e){const[t,n]=vt(null),r=wt(e),o=bt(e=>{const t=Qt(e.target);t&&n(e=>e?(e.set(t,en(t)),new Map(e)):null)},[]);return mt(()=>{const t=r.current;if(e!==t){i(t);const a=e.map(e=>{const t=Qt(e);return t?(t.addEventListener("scroll",o,{passive:!0}),[t,en(t)]):null}).filter(e=>null!=e);n(a.length?new Map(a):null),r.current=e}return()=>{i(e),i(t)};function i(e){e.forEach(e=>{const t=Qt(e);null==t||t.removeEventListener("scroll",o)})}},[o,e]),yt(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>et(e,t),Nt):ln(e):Nt,[e,t])}(re),le=Hn(se),ce=Hn(se,[K]),de=et(ie,le),ue=Z?Ft(Z,ie):null,pe=D&&ue?d({active:D,collisionRect:ue,droppableRects:B,droppableContainers:L,pointerCoordinates:ae}):null,he=function(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}(pe,"id"),[ge,fe]=vt(null),me=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(G?ie:et(ie,ce),null!=(o=null==ge?void 0:ge.rect)?o:null,K),ve=wt(null),be=bt((e,t)=>{let{sensor:n,options:r}=t;if(null==_.current)return;const o=k.get(_.current);if(!o)return;const i=e.nativeEvent,a=new n({active:_.current,activeNode:o,event:i,options:r,context:X,onAbort(e){if(!k.get(e))return;const{onDragAbort:t}=I.current,n={id:e};null==t||t(n),v({type:"onDragAbort",event:n})},onPending(e,t,n,r){if(!k.get(e))return;const{onDragPending:o}=I.current,i={id:e,constraint:t,initialCoordinates:n,offset:r};null==o||o(i),v({type:"onDragPending",event:i})},onStart(e){const t=_.current;if(null==t)return;const n=k.get(t);if(!n)return;const{onDragStart:r}=I.current,o={activatorEvent:i,active:{id:t,data:n.data,rect:A}};Rt(()=>{null==r||r(o),w(or.Initializing),m({type:Mt.DragStart,initialCoordinates:e,active:t}),v({type:"onDragStart",event:o}),M(ve.current),N(i)})},onMove(e){m({type:Mt.DragMove,coordinates:e})},onEnd:s(Mt.DragEnd),onCancel:s(Mt.DragCancel)});function s(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:o}=X.current;let a=null;if(t&&o){const{cancelDrop:s}=I.current;if(a={activatorEvent:i,active:t,collisions:n,delta:o,over:r},e===Mt.DragEnd&&"function"==typeof s){await Promise.resolve(s(a))&&(e=Mt.DragCancel)}}_.current=null,Rt(()=>{m({type:e}),w(or.Uninitialized),fe(null),M(null),N(null),ve.current=null;const t=e===Mt.DragEnd?"onDragEnd":"onDragCancel";if(a){const e=I.current[t];null==e||e(a),v({type:t,event:a})}})}}ve.current=a},[k]),ye=bt((e,t)=>(n,r)=>{const o=n.nativeEvent,i=k.get(r);if(null!==_.current||!i||o.dndKit||o.defaultPrevented)return;const a={active:i};!0===e(n,t.options,a)&&(o.dndKit={capturedBy:t.sensor},_.current=r,be(n,t))},[k,be]),we=function(e,t){return yt(()=>e.reduce((e,n)=>{const{sensor:r}=n;return[...e,...r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}))]},[]),[e,t])}(c,ye);!function(e){mt(()=>{if(!je)return;const t=e.map(e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()});return()=>{for(const e of t)null==e||e()}},e.map(e=>{let{sensor:t}=e;return t}))}(c),Ue(()=>{K&&y===or.Initializing&&w(or.Initialized)},[K,y]),mt(()=>{const{onDragMove:e}=I.current,{active:t,activatorEvent:n,collisions:r,over:o}=X.current;if(!t||!n)return;const i={active:t,activatorEvent:n,collisions:r,delta:{x:de.x,y:de.y},over:o};Rt(()=>{null==e||e(i),v({type:"onDragMove",event:i})})},[de.x,de.y]),mt(()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:o}=X.current;if(!e||null==_.current||!t||!o)return;const{onDragOver:i}=I.current,a=r.get(he),s=a&&a.rect.current?{id:a.id,rect:a.rect.current,data:a.data,disabled:a.disabled}:null,l={active:e,activatorEvent:t,collisions:n,delta:{x:o.x,y:o.y},over:s};Rt(()=>{fe(s),null==i||i(l),v({type:"onDragOver",event:l})})},[he]),Ue(()=>{X.current={activatorEvent:O,active:D,activeNode:z,collisionRect:ue,collisions:pe,droppableRects:B,draggableNodes:k,draggingNode:Q,draggingNodeRect:Z,droppableContainers:S,over:ge,scrollableAncestors:re,scrollAdjustedTranslate:de},A.current={initial:Z,translated:ue}},[D,z,pe,ue,k,Q,Z,B,S,ge,re,de]),Mn({...q,delta:E,draggingRect:ue,pointerCoordinates:ae,scrollableAncestors:re,scrollableAncestorRects:oe});const xe=yt(()=>({active:D,activeNode:z,activeNodeRect:K,activatorEvent:O,collisions:pe,containerNodeRect:V,dragOverlay:J,draggableNodes:k,droppableContainers:S,droppableRects:B,over:ge,measureDroppableContainers:P,scrollableAncestors:re,scrollableAncestorRects:oe,measuringConfiguration:j,measuringScheduled:H,windowRect:ne}),[D,z,K,O,pe,V,J,k,S,B,ge,P,re,oe,j,H,ne]),Ce=yt(()=>({activatorEvent:O,activators:we,active:D,activeNodeRect:K,ariaDescribedById:{draggable:$},dispatch:m,draggableNodes:k,over:ge,measureDroppableContainers:P}),[O,we,D,K,m,$,k,ge,P]);return ht.createElement(At.Provider,{value:b},ht.createElement(Qn.Provider,{value:Ce},ht.createElement(Zn.Provider,{value:xe},ht.createElement(rr.Provider,{value:me},l)),ht.createElement(tr,{disabled:!1===(null==a?void 0:a.restoreFocus)})),ht.createElement(Tt,{...a,hiddenTextDescribedById:$}))});const ir=gt(null),ar="button";function sr(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=Ze("Draggable"),{activators:a,activatorEvent:s,active:l,activeNodeRect:c,ariaDescribedById:d,draggableNodes:u,over:p}=ft(Qn),{role:h=ar,roleDescription:g="draggable",tabIndex:f=0}=null!=o?o:{},m=(null==l?void 0:l.id)===t,v=ft(m?rr:ir),[b,y]=Ye(),[w,x]=Ye(),C=function(e,t){return yt(()=>e.reduce((e,n)=>{let{eventName:r,handler:o}=n;return e[r]=e=>{o(e,t)},e},{}),[e,t])}(a,t),k=Ve(n);Ue(()=>(u.set(t,{id:t,key:i,node:b,activatorNode:w,data:k}),()=>{const e=u.get(t);e&&e.key===i&&u.delete(t)}),[u,t]);return{active:l,activatorEvent:s,activeNodeRect:c,attributes:yt(()=>({role:h,tabIndex:f,"aria-disabled":r,"aria-pressed":!(!m||h!==ar)||void 0,"aria-roledescription":g,"aria-describedby":d.draggable}),[r,h,f,m,g,d.draggable]),isDragging:m,listeners:r?void 0:C,node:b,over:p,setNodeRef:y,setActivatorNodeRef:x,transform:v}}const lr={timeout:25};function cr(e){let{animation:t,children:n}=e;const[r,o]=vt(null),[i,a]=vt(null),s=Je(n);return n||r||!s||o(s),Ue(()=>{if(!i)return;const e=null==r?void 0:r.key,n=null==r?void 0:r.props.id;null!=e&&null!=n?Promise.resolve(t(n,i)).then(()=>{o(null)}):o(null)},[t,r,i]),ht.createElement(ht.Fragment,null,n,r?kt(r,{ref:a}):null)}const dr={x:0,y:0,scaleX:1,scaleY:1};function ur(e){let{children:t}=e;return ht.createElement(Qn.Provider,{value:Jn},ht.createElement(rr.Provider,{value:dr},t))}const pr={position:"fixed",touchAction:"none"},hr=e=>nt(e)?"transform 250ms ease":void 0,gr=Et((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:a,rect:s,style:l,transform:c,transition:d=hr}=e;if(!s)return null;const u=o?c:{...c,scaleX:1,scaleY:1},p={...pr,width:s.width,height:s.height,top:s.top,left:s.left,transform:ot.Transform.toString(u),transformOrigin:o&&r?$t(r,s):void 0,transition:"function"==typeof d?d(r):d,...l};return ht.createElement(n,{className:a,style:p,ref:t},i)}),fr={duration:250,easing:"ease",keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:ot.Transform.toString(t)},{transform:ot.Transform.toString(n)}]},sideEffects:(mr={styles:{active:{opacity:"0"}}},e=>{let{active:t,dragOverlay:n}=e;const r={},{styles:o,className:i}=mr;if(null!=o&&o.active)for(const[e,n]of Object.entries(o.active))void 0!==n&&(r[e]=t.node.style.getPropertyValue(e),t.node.style.setProperty(e,n));if(null!=o&&o.dragOverlay)for(const[e,t]of Object.entries(o.dragOverlay))void 0!==t&&n.node.style.setProperty(e,t);return null!=i&&i.active&&t.node.classList.add(i.active),null!=i&&i.dragOverlay&&n.node.classList.add(i.dragOverlay),function(){for(const[e,n]of Object.entries(r))t.node.style.setProperty(e,n);null!=i&&i.active&&t.node.classList.remove(i.active)}})};var mr;function vr(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return Ke((e,i)=>{if(null===t)return;const a=n.get(e);if(!a)return;const s=a.node.current;if(!s)return;const l=qn(i);if(!l)return;const{transform:c}=Pe(i).getComputedStyle(i),d=Ut(c);if(!d)return;const u="function"==typeof t?t:function(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...fr,...e};return e=>{let{active:i,dragOverlay:a,transform:s,...l}=e;if(!t)return;const c={x:a.rect.left-i.rect.left,y:a.rect.top-i.rect.top},d={scaleX:1!==s.scaleX?i.rect.width*s.scaleX/a.rect.width:1,scaleY:1!==s.scaleY?i.rect.height*s.scaleY/a.rect.height:1},u={x:s.x-c.x,y:s.y-c.y,...d},p=o({...l,active:i,dragOverlay:a,transform:{initial:s,final:u}}),[h]=p,g=p[p.length-1];if(JSON.stringify(h)===JSON.stringify(g))return;const f=null==r?void 0:r({active:i,dragOverlay:a,...l}),m=a.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(e=>{m.onfinish=()=>{null==f||f(),e()}})}}(t);return cn(s,o.draggable.measure),u({active:{id:e,data:a.data,node:s,rect:o.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:i,rect:o.dragOverlay.measure(l)},droppableContainers:r,measuringConfiguration:o,transform:d})})}let br=0;function yr(e){return yt(()=>{if(null!=e)return br++,br},[e])}const wr=ht.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:a,wrapperElement:s="div",className:l,zIndex:c=999}=e;const{activatorEvent:d,active:u,activeNodeRect:p,containerNodeRect:h,draggableNodes:g,droppableContainers:f,dragOverlay:m,over:v,measuringConfiguration:b,scrollableAncestors:y,scrollableAncestorRects:w,windowRect:x}=ft(Zn),C=ft(rr),k=yr(null==u?void 0:u.id),E=nr(a,{activatorEvent:d,active:u,activeNodeRect:p,containerNodeRect:h,draggingNodeRect:m.rect,over:v,overlayNodeRect:m.rect,scrollableAncestors:y,scrollableAncestorRects:w,transform:C,windowRect:x}),S=Ln(p),R=vr({config:r,draggableNodes:g,droppableContainers:f,measuringConfiguration:b}),A=S?m.setRef:void 0;return ht.createElement(ur,null,ht.createElement(cr,{animation:R},u&&k?ht.createElement(gr,{key:k,id:u.id,ref:A,as:s,activatorEvent:d,adjustScale:t,className:l,transition:i,rect:S,style:{zIndex:c,...o},transform:E},n):null))}),xr=n,{useEffect:Cr}=n,{useRef:kr}=n,Er=r,{styled:Sr}=o,{Chip:Rr}=a,{color:Ar}=s,{renderMath:Dr}=u;function _r(e){let t,n=e[0],r=1;for(;r<e.length;){const o=e[r],i=e[r+1];if(r+=2,("optionalAccess"===o||"optionalCall"===o)&&null==n)return;"access"===o||"optionalAccess"===o?(t=n,n=i(n)):"call"!==o&&"optionalCall"!==o||(n=i((...e)=>n.call(t,...e)),t=void 0)}return n}const Tr=Sr("span")(({theme:e,disabled:t})=>({border:`solid 0px ${e.palette.primary.main}`,borderRadius:e.spacing(2),margin:e.spacing(.5),transform:"translate(0, 0)",display:"inline-flex",...t&&{}})),Mr=Sr(Rr)(()=>({backgroundColor:Ar.white(),border:`1px solid ${Ar.text()}`,color:Ar.text(),alignItems:"center",display:"inline-flex",height:"initial",minHeight:"32px",fontSize:"inherit",whiteSpace:"pre-wrap",maxWidth:"374px",pointerEvents:"none",borderRadius:"3px",paddingTop:"12px",paddingBottom:"12px","&.Mui-disabled":{opacity:1}})),Or=Sr("span")(()=>({whiteSpace:"normal","& img":{display:"block",padding:"2px 0"},"& mjx-frac":{fontSize:"120% !important"}}));function Nr({choice:e,disabled:t,instanceId:n}){const r=kr(null),{attributes:o,listeners:i,setNodeRef:a,isDragging:s}=sr({id:`choice-${e.id}`,data:{choice:e,instanceId:n,fromChoice:!0,type:"MaskBlank"},disabled:t});return Cr(()=>{Dr(r.current)},[e.value]),xr.createElement(Tr,{ref:a,style:s?{width:_r([r,"access",e=>e.current,"optionalAccess",e=>e.offsetWidth]),height:_r([r,"access",e=>e.current,"optionalAccess",e=>e.offsetHeight])}:{},disabled:t,...i,...o},xr.createElement(Mr,{clickable:!1,disabled:t,ref:r,label:xr.createElement(Or,{dangerouslySetInnerHTML:{__html:e.value}})}))}Nr.propTypes={choice:Er.object.isRequired,disabled:Er.bool,instanceId:Er.oneOfType([Er.string,Er.number])};const Ir=n,$r=r,{findKey:Lr}=i,{DragDroppablePlaceholder:jr}=g;class Wr extends Ir.Component{constructor(...e){super(...e),Wr.prototype.__init.call(this)}static __initStatic(){this.propTypes={disabled:$r.bool,duplicates:$r.bool,choices:$r.arrayOf($r.shape({label:$r.string,value:$r.string})),value:$r.object,choicePosition:$r.string.isRequired,instanceId:$r.string}}__init(){this.getStyleForWrapper=()=>{const{choicePosition:e}=this.props;switch(e){case"above":return{margin:"0 0 40px 0"};case"below":return{margin:"40px 0 0 0"};case"right":return{margin:"0 0 0 40px"};default:return{margin:"0 40px 0 0"}}}}render(){const{disabled:e,duplicates:t,choices:n,value:r,instanceId:o}=this.props,i=n.filter(e=>{if(!0===t)return!0;return void 0===Lr(r,t=>t===e.id)}),a={...this.getStyleForWrapper(),minWidth:"100px"};return Ir.createElement("div",{style:a},Ir.createElement(jr,{disabled:e,instanceId:o},i.map((t,n)=>Ir.createElement(Nr,{key:`${t.value}-${n}`,disabled:e,choice:t,instanceId:o}))))}}Wr.__initStatic();var Br={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"};const Pr=n,{useRef:Hr}=n,{useState:zr}=n,{useEffect:Fr}=n,qr=r,Ur=t,{styled:Kr}=o,{Chip:Vr}=a,Xr=l,{color:Yr}=s,{renderMath:Jr}=u;function Qr(e){let t,n=e[0],r=1;for(;r<e.length;){const o=e[r],i=e[r+1];if(r+=2,("optionalAccess"===o||"optionalCall"===o)&&null==n)return;"access"===o||"optionalAccess"===o?(t=n,n=i(n)):"call"!==o&&"optionalCall"!==o||(n=i((...e)=>n.call(t,...e)),t=void 0)}return n}Ur("pie-lib:mask-markup:blank");const Zr=Kr("span")(({dragged:e,over:t})=>({border:`solid 0px ${Yr.primary()}`,minWidth:"200px",touchAction:"none",overflow:"hidden",whiteSpace:"nowrap",opacity:1,...t&&{whiteSpace:"nowrap",overflow:"hidden"},...e&&{opacity:.5}})),Gr=Kr(Vr)(()=>({backgroundColor:Yr.background(),border:`2px dashed ${Yr.text()}`,color:Yr.text(),fontSize:"inherit",maxWidth:"374px",position:"relative",borderRadius:"3px","&.over":{whiteSpace:"nowrap",overflow:"hidden"},"&.parentOver":{border:`1px solid ${Br[500]}`,backgroundColor:`${Br[300]}`},"&.correct":{border:`solid 1px ${Yr.correct()}`},"&.incorrect":{border:`solid 1px ${Yr.incorrect()}`},"&.Mui-disabled":{opacity:1}})),eo=Kr("span")(()=>({whiteSpace:"normal",pointerEvents:"none","& img":{display:"block",padding:"2px 0"},"& p":{marginTop:"0",marginBottom:"0"},"& mjx-frac":{fontSize:"120% !important"},"&.over":{whiteSpace:"nowrap",overflow:"hidden"},"&.hidden":{color:"transparent",opacity:0},"&.dragged":{position:"absolute",left:16,maxWidth:"60px"}}));function to({disabled:e,choice:t,isOver:n,isDragging:r,dragItem:o,correct:i,emptyResponseAreaWidth:a,emptyResponseAreaHeight:s}){const l=Hr(null),c=Hr(null),d=Hr(null),[u,p]=zr({height:0,width:0}),h=()=>{f()},g=()=>{const e=Qr([c,"access",e=>e.current,"optionalAccess",e=>e.querySelector,"call",e=>e("img")]);e?e.onload=h:setTimeout(()=>{f()},300)},f=()=>{if(c.current&&l.current){l.current.style.width="auto";const e=(c.current.offsetWidth||0)+24,t=(c.current.offsetHeight||0)+24,n=parseFloat(a)||0,r=parseFloat(s)||0,o=e<=n?n:e,i=t<=r?r:t;p(e=>({width:o>n?o:e.width,height:i>r?i:e.height})),l.current.style.width=`${o}px`,l.current.style.height=`${i}px`}};Fr(()=>{g()},[]),Fr(()=>{l.current&&Jr(l.current)},[n,Qr([o,"optionalAccess",e=>e.choice,"optionalAccess",e=>e.value])]),Fr(()=>{t?g():p({height:0,width:0})},[t]),Fr(()=>{n||r||(d.current={width:l.current.offsetWidth,height:l.current.offsetHeight})},[t,n,r]);const m=o&&n&&o.choice&&o.choice.value,v=t&&t.value,b=n||r?{width:Qr([d,"access",e=>e.current,"optionalAccess",e=>e.width]),height:Qr([d,"access",e=>e.current,"optionalAccess",e=>e.height])}:(()=>{const e=isNaN(parseFloat(a))?0:parseFloat(a),t=isNaN(parseFloat(s))?0:parseFloat(s);return{...{height:u.height||t,width:u.width||e},...e?{}:{minWidth:90},...t?{}:{minHeight:32}}})();return Pr.createElement(Gr,{clickable:!1,disabled:e,ref:l,component:"span",label:Pr.createElement(Pr.Fragment,null,Pr.createElement(eo,{ref:c,draggable:!0,className:Xr({over:n,hidden:m}),dangerouslySetInnerHTML:{__html:v||""}}),m&&Pr.createElement(eo,{draggable:!0,className:Xr({over:n,dragged:!0}),dangerouslySetInnerHTML:{__html:m||""}})),className:Xr({over:n,parentOver:n,correct:void 0!==i&&i,incorrect:void 0!==i&&!i}),variant:e?"outlined":void 0,style:b})}function no({id:e,disabled:t,duplicates:n,choice:r,correct:o,onChange:i,emptyResponseAreaWidth:a,emptyResponseAreaHeight:s,instanceId:l}){const{attributes:c,listeners:d,setNodeRef:u,transform:p,isDragging:h}=sr({id:`mask-blank-drag-${e}`,disabled:t||!r,data:{id:e,choice:r,instanceId:l,fromChoice:!1,type:"MaskBlank"}}),{setNodeRef:g,isOver:f,active:m}=function(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=Ze("Droppable"),{active:a,dispatch:s,over:l,measureDroppableContainers:c}=ft(Qn),d=wt({disabled:n}),u=wt(!1),p=wt(null),h=wt(null),{disabled:g,updateMeasurementsFor:f,timeout:m}={...lr,...o},v=Ve(null!=f?f:r),b=jn({callback:bt(()=>{u.current?(null!=h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{c(Array.isArray(v.current)?v.current:[v.current]),h.current=null},m)):u.current=!0},[m]),disabled:g||!a}),y=bt((e,t)=>{b&&(t&&(b.unobserve(t),u.current=!1),e&&b.observe(e))},[b]),[w,x]=Ye(y),C=Ve(t);return mt(()=>{b&&w.current&&(b.disconnect(),u.current=!1,b.observe(w.current))},[w,b]),mt(()=>(s({type:Mt.RegisterDroppable,element:{id:r,key:i,disabled:n,node:w,rect:p,data:C}}),()=>s({type:Mt.UnregisterDroppable,key:i,id:r})),[r]),mt(()=>{n!==d.current.disabled&&(s({type:Mt.SetDroppableDisabled,id:r,key:i,disabled:n}),d.current.disabled=n)},[r,i,n,s]),{active:a,rect:p,isOver:(null==l?void 0:l.id)===r,node:w,over:l,setNodeRef:x}}({id:`mask-blank-drop-${e}`,data:{id:e,accepts:["MaskBlank"],instanceId:l}}),v={transform:ot.Translate.toString(p)};return Pr.createElement(Zr,{ref:e=>{u(e),g(e)},style:v,dragged:h,over:f,...c,...d},Pr.createElement(to,{id:e,disabled:t,duplicates:n,choice:r,isOver:f,dragItem:Qr([m,"optionalAccess",e=>e.data,"optionalAccess",e=>e.current]),correct:o,onChange:i,emptyResponseAreaWidth:a,emptyResponseAreaHeight:s,instanceId:l}))}to.defaultProps={emptyResponseAreaWidth:0,emptyResponseAreaHeight:0},to.propTypes={id:qr.oneOfType([qr.string,qr.number]),disabled:qr.bool,duplicates:qr.bool,choice:qr.object,isOver:qr.bool,dragItem:qr.object,correct:qr.bool,onChange:qr.func,emptyResponseAreaWidth:qr.oneOfType([qr.string,qr.number]),emptyResponseAreaHeight:qr.oneOfType([qr.string,qr.number]),instanceId:qr.string},no.defaultProps={emptyResponseAreaWidth:0,emptyResponseAreaHeight:0},no.propTypes={id:qr.oneOfType([qr.string,qr.number]),disabled:qr.bool,duplicates:qr.bool,choice:qr.object,correct:qr.bool,onChange:qr.func,emptyResponseAreaWidth:qr.oneOfType([qr.string,qr.number]),emptyResponseAreaHeight:qr.oneOfType([qr.string,qr.number]),instanceId:qr.string};const ro=n,oo=r,{DragProvider:io}=g;function ao(e){let t,n=e[0],r=1;for(;r<e.length;){const o=e[r],i=e[r+1];if(r+=2,("optionalAccess"===o||"optionalCall"===o)&&null==n)return;"access"===o||"optionalAccess"===o?(t=n,n=i(n)):"call"!==o&&"optionalCall"!==o||(n=i((...e)=>n.call(t,...e)),t=void 0)}return n}const so=Me("blank",e=>(t,n,r)=>{const o=ao([t,"access",e=>e.data,"optionalAccess",e=>e.dataset])||{};if("blank"===o.component){const{disabled:i,duplicates:a,correctResponse:s,feedback:l,showCorrectAnswer:c,emptyResponseAreaWidth:d,emptyResponseAreaHeight:u,instanceId:p,isDragging:h}=e,g=c?s[o.id]:n[o.id],f=g&&e.choices.find(e=>e.id===g);return ro.createElement(no,{key:`${t.type}-${o.id}`,correct:c||l&&l[o.id],disabled:i,duplicates:a,choice:f,id:o.id,emptyResponseAreaWidth:d,emptyResponseAreaHeight:u,onChange:(e,t)=>{const o={...n};void 0===t?delete o[e]:o[e]=t,r(o)},instanceId:p,isDragging:h})}});class lo extends ro.Component{constructor(e){super(e),lo.prototype.__init.call(this),lo.prototype.__init2.call(this),lo.prototype.__init3.call(this),lo.prototype.__init4.call(this),this.state={activeDragItem:null}}static __initStatic(){this.propTypes={markup:oo.string,layout:oo.object,choicesPosition:oo.string,choices:oo.array,value:oo.object,onChange:oo.func,duplicates:oo.bool,disabled:oo.bool,feedback:oo.object,correctResponse:oo.object,showCorrectAnswer:oo.bool,emptyResponseAreaWidth:oo.oneOfType([oo.string,oo.number]),emptyResponseAreaHeight:oo.oneOfType([oo.string,oo.number]),instanceId:oo.string}}static __initStatic2(){this.defaultProps={instanceId:"drag-in-the-blank"}}__init(){this.handleDragStart=e=>{const{active:t}=e;ao([t,"optionalAccess",e=>e.data,"optionalAccess",e=>e.current])&&this.setState({activeDragItem:t.data.current})}}__init2(){this.renderDragOverlay=()=>{const{activeDragItem:e}=this.state;return e&&"MaskBlank"===e.type?ro.createElement(Nr,{disabled:e.disabled,choice:e.choice,instanceId:e.instanceId}):null}}__init3(){this.handleDragEnd=e=>{const{active:t,over:n}=e,{onChange:r,value:o}=this.props;if(this.setState({activeDragItem:null}),!n||!t||!r)return;const i=t.data.current,a=n.data.current;if("MaskBlank"===ao([i,"optionalAccess",e=>e.type])&&ao([a,"optionalAccess",e=>e.accepts,"optionalAccess",e=>e.includes,"call",e=>e("MaskBlank")])){const e=i,t=a.id;if(!0===a.toChoiceBoard){if(!e.fromChoice&&e.id){const t={...o};delete t[e.id],r(t)}}else if(!0===e.fromChoice){if(t&&"drag-in-the-blank-droppable"!==t){const n={...o};n[t]=e.choice.id,r(n)}}else if(e.id&&e.id!==t){const n={...o};n[t]=e.choice.id,delete n[e.id],r(n)}}}}__init4(){this.getPositionDirection=e=>{let t,n,r;switch(e){case"left":t="row",r="center";break;case"right":t="row-reverse",n="flex-end",r="center";break;case"below":t="column-reverse";break;default:t="column"}return{flexDirection:t,justifyContent:n,alignItems:r}}}render(){const{markup:e,duplicates:t,value:n,onChange:r,choicesPosition:o,choices:i,correctResponse:a,disabled:s,feedback:l,showCorrectAnswer:c,emptyResponseAreaWidth:d,emptyResponseAreaHeight:u,layout:p,instanceId:h}=this.props,g=o||"below",f={display:"flex",minWidth:"100px",...this.getPositionDirection(g)};return ro.createElement(io,{onDragStart:this.handleDragStart,onDragEnd:this.handleDragEnd,collisionDetection:Bt},ro.createElement("div",{ref:e=>this.rootRef=e,style:f},ro.createElement(Wr,{choicePosition:g,choices:i,value:n,duplicates:t,disabled:s,instanceId:h}),ro.createElement(so,{elementType:"drag-in-the-blank",markup:e,layout:p,value:n,choices:i,onChange:r,disabled:s,duplicates:t,feedback:l,correctResponse:a,showCorrectAnswer:c,emptyResponseAreaWidth:d,emptyResponseAreaHeight:u,instanceId:h,isDragging:!!this.state.activeDragItem}),ro.createElement(wr,{style:{pointerEvents:"none"}},this.renderDragOverlay())))}}lo.__initStatic(),lo.__initStatic2();const co=n,{styled:uo}=o,po=l,{color:ho}=s;function go(e){let t,n=e[0],r=1;for(;r<e.length;){const o=e[r],i=e[r+1];if(r+=2,("optionalAccess"===o||"optionalCall"===o)&&null==n)return;"access"===o||"optionalAccess"===o?(t=n,n=i(n)):"call"!==o&&"optionalCall"!==o||(n=i((...e)=>n.call(t,...e)),t=void 0)}return n}let fo,mo;"undefined"!=typeof window&&(fo=require("@pie-lib/editable-html-tip-tap").default,mo=uo(fo)(()=>({display:"inline-block",verticalAlign:"middle",margin:"4px",borderRadius:"4px",border:`1px solid ${ho.black()}`,"&.correct":{border:`1px solid ${ho.correct()}`},"&.incorrect":{border:`1px solid ${ho.incorrect()}`}})));Me("input",e=>(t,n)=>{const{adjustedLimit:r,disabled:o,feedback:i,showCorrectAnswer:a,maxLength:s,spellCheck:l,pluginProps:c,onChange:d}=e,u=go([t,"access",e=>e.data,"optionalAccess",e=>e.dataset])||{};if("input"===u.component){const p=(e.choices&&u&&e.choices[u.id]||[])[0],h=a?p&&p.label:n[u.id]||"",g=s&&s[u.id],f=i&&i[u.id],m=a||"correct"===f,v=!a&&"incorrect"===f,b=e=>{const t={...n,[u.id]:e};d(t)},y=e=>{if("Enter"===e.key||13===e.keyCode)return!0};return co.createElement(mo,{id:u.id,key:`${t.type}-input-${u.id}`,disabled:a||o,disableUnderline:!0,onChange:b,markup:h||"",charactersLimit:r?g:25,activePlugins:["languageCharacters"],pluginProps:c,languageCharactersProps:[{language:"spanish"}],spellCheck:l,width:`calc(${g}em + 32px)`,onKeyDown:y,autoWidthToolbar:!0,toolbarOpts:{minWidth:"auto",noBorder:!0,isHidden:!!go([c,"optionalAccess",e=>e.characters,"optionalAccess",e=>e.disabled])},className:po({correct:m,incorrect:v})})}});var vo=Me("input",e=>(t,n,r)=>{const o=t.data&&t.data.dataset||{};if("input"===o.component)return e.customMarkMarkupComponent(o.id)});const bo=n,yo=r,{Button:wo}=a,{InputLabel:xo}=a,{Menu:Co}=a,{MenuItem:ko}=a,{ArrowDropDown:Eo}=c,{ArrowDropUp:So}=c,{Close:Ro}=c,{Check:Ao}=c,{styled:Do}=o,{color:_o}=s,{renderMath:To}=u,Mo=Do(wo)(()=>({color:_o.text(),border:`1px solid ${_o.borderGray()}`,borderRadius:"4px",justifyContent:"space-between",backgroundColor:_o.background(),position:"relative",height:"45px",width:"fit-content",margin:"2px",textTransform:"none","& span":{paddingRight:"5px"},"& svg":{position:"absolute",right:0,top:"calc(50% - 12px)",pointerEvents:"none",color:_o.text(),marginLeft:"5px"},"&.Mui-focused":{outline:`3px solid ${_o.tertiary()}`,outlineOffset:"2px",borderWidth:"3px"},"&.disabledCorrect":{borderWidth:"2px",borderColor:_o.correct(),color:`${_o.text()} !important`},"&.disabledIncorrect":{borderWidth:"2px",borderColor:_o.incorrectWithIcon(),color:`${_o.text()} !important`}})),Oo=Do(Co)(()=>({backgroundColor:_o.background(),border:`1px solid ${_o.correct()} !important`,"&:hover":{border:`1px solid ${_o.text()} `,borderColor:"initial"},"&:focus":{border:`1px solid ${_o.text()}`,borderColor:"initial"},"& .MuiList-root":{padding:0}})),No=Do(ko)(()=>({color:_o.text(),backgroundColor:_o.background(),"&.Mui-focused":{outline:`3px solid ${_o.tertiary()}`,outlineOffset:"-1px",color:_o.text(),backgroundColor:_o.background()},"&:hover":{color:_o.text(),backgroundColor:_o.dropdownBackground()},boxSizing:"border-box",padding:"25px",borderRadius:"4px","&.selected":{color:`${_o.text()} !important`,backgroundColor:`${_o.background()} !important`,"&:hover":{color:_o.text(),backgroundColor:`${_o.dropdownBackground()} !important`}}})),Io=Do("span")(()=>({fontSize:"max(1rem, 14px)"})),$o=Do("span")(()=>({fontSize:"max(1rem, 14px)",position:"absolute",right:"10px"})),Lo=Do(xo)(()=>({position:"absolute",left:"-10000px",top:"auto",width:"1px",height:"1px",overflow:"hidden"})),jo=Do(Ao)(()=>({color:`${_o.white()} !important`,position:"absolute",top:"-8px !important",left:"-8px",marginLeft:"0 !important",borderRadius:"50%",fontSize:"16px",padding:"2px","&.correct":{backgroundColor:_o.correct()},"&.incorrect":{backgroundColor:_o.incorrectWithIcon()}})),Wo=Do(Ro)(()=>({color:`${_o.white()} !important`,position:"absolute",top:"-8px !important",left:"-8px",marginLeft:"0 !important",borderRadius:"50%",fontSize:"16px",padding:"2px","&.correct":{backgroundColor:_o.correct()},"&.incorrect":{backgroundColor:_o.incorrectWithIcon()}}));class Bo extends bo.Component{static __initStatic(){this.propTypes={id:yo.string,value:yo.string,disabled:yo.bool,onChange:yo.func,correct:yo.bool,choices:yo.arrayOf(yo.shape({value:yo.string,label:yo.string})),showCorrectAnswer:yo.bool,singleQuery:yo.bool,correctValue:yo.string}}constructor(e){super(e),Bo.prototype.__init.call(this),Bo.prototype.__init2.call(this),Bo.prototype.__init3.call(this),Bo.prototype.__init4.call(this),Bo.prototype.__init5.call(this),this.state={anchorEl:null,highlightedOptionId:null,menuWidth:null,previewValue:null},this.hiddenRef=bo.createRef(),this.buttonRef=bo.createRef(),this.previewRef=bo.createRef(),this.elementRefs=[]}componentDidMount(){this.hiddenRef.current&&null===this.state.menuWidth&&this.setState({menuWidth:this.hiddenRef.current.clientWidth})}componentDidUpdate(e,t){const n=this.hiddenRef.current;if(!t.anchorEl&&this.state.anchorEl&&this.elementRefs.forEach(e=>{if(!e)return;const t=e.querySelector("[data-latex], [data-raw]"),n=e.querySelector("mjx-container"),r=e.querySelector('[data-math-handled="true"]');!t||r&&n||To(e)}),n){const e=n.clientWidth;e!==this.state.menuWidth&&(this.elementRefs.forEach(e=>{e&&To(e)}),To(n),this.setState({menuWidth:e}))}}__init(){this.handleClick=e=>this.setState({anchorEl:e.currentTarget})}__init2(){this.handleClose=()=>{const{value:e}=this.props;this.setState({anchorEl:null,previewValue:null,highlightedOptionId:null}),!e&&this.previewRef.current&&(this.previewRef.current.innerHTML="")}}__init3(){this.handleHighlight=e=>{const t={highlightedOptionId:`dropdown-option-${this.props.id}-${e}`};this.props.value||(t.previewValue=this.props.choices[e].value),this.setState(t)}}__init4(){this.handleSelect=(e,t)=>{this.props.onChange(this.props.id,e),this.handleHighlight(t),this.handleClose()}}__init5(){this.handleHover=e=>{if(this.props.value)return;const t=`dropdown-option-${this.props.id}-${e}`,n=this.state.previewValue;this.setState({highlightedOptionId:t,previewValue:n},()=>{const t=this.elementRefs[e],n=this.previewRef.current;t&&n&&(n.innerHTML=t.innerHTML)})}}getLabel(e,t){const n=(e||[]).find(e=>e.value===t);return n?n.label.trim():void 0}render(){const{id:e,correct:t,disabled:n,value:r,choices:o,showCorrectAnswer:i,singleQuery:a,correctValue:s}=this.props,{anchorEl:l}=this.state,c=Boolean(l),d=`dropdown-button-${e}`,u=`dropdown-menu-${e}`,p=`dropdown-value-${e}`;let h;this.elementRefs=[],n&&void 0!==t&&(h=t||i?"disabledCorrect":"disabledIncorrect");const g=parseInt(e,10)+1,f=a?"Query-label":`Query-label-${g}`,m=a?"Query":`Query ${g}`;let v=null;return n&&void 0!==t&&(v=t||i?bo.createElement(jo,{className:"correct"}):bo.createElement(Wo,{className:"incorrect"})),bo.createElement(bo.Fragment,null,bo.createElement("div",{ref:this.hiddenRef,style:{position:"absolute",visibility:"hidden",top:0,left:0},tabIndex:-1,"aria-hidden":"true"},(o||[]).map((e,t)=>bo.createElement(No,{key:t,tabIndex:-1,"aria-hidden":"true"},bo.createElement(Io,{dangerouslySetInnerHTML:{__html:e.label}})))),bo.createElement(Lo,{id:f,tabIndex:-1,"aria-hidden":"true"},m),bo.createElement(Mo,{ref:this.buttonRef,style:{...this.state.menuWidth&&{minWidth:`calc(${this.state.menuWidth}px + 8px)`},borderWidth:c?"2px":"1px",transition:"border-width 0.2s ease-in-out"},"aria-controls":c?u:void 0,"aria-haspopup":"listbox","aria-expanded":c?"true":void 0,"aria-activedescendant":this.state.highlightedOptionId,onClick:this.handleClick,className:h,disabled:n,id:d,role:"combobox","aria-label":`Select an option for ${m}`,"aria-labelledby":p},v,bo.createElement(Io,{id:p,ref:this.previewRef,dangerouslySetInnerHTML:{__html:s||(c&&this.state.previewValue?this.getLabel(o,this.state.previewValue):this.getLabel(o,r)||"")}}),c?bo.createElement(So,null):bo.createElement(Eo,null)),bo.createElement(Oo,{id:u,anchorEl:l,keepMounted:!0,open:c,onClose:this.handleClose,getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},transitionDuration:{enter:225,exit:195},slotProps:{paper:this.state.menuWidth?{style:{minWidth:this.state.menuWidth,padding:"4px"}}:void 0,list:{"aria-labelledby":d,role:"listbox",disablePadding:!0}}},(o||[]).map((t,n)=>{const o=`dropdown-option-${e}-${n}`;return bo.createElement(No,{id:o,className:t.value===r?"selected":"",key:`${t.label}-${n}`,value:t.value,onClick:()=>this.handleSelect(t.value,n),role:"option","aria-selected":this.state.highlightedOptionId===o?"true":void 0,onMouseOver:()=>this.handleHover(n)},bo.createElement(Io,{ref:e=>this.elementRefs[n]=e,dangerouslySetInnerHTML:{__html:t.label}}),bo.createElement($o,{dangerouslySetInnerHTML:{__html:t.value===r?" &check;":""}}))})))}}Bo.__initStatic();const Po=n;Me("dropdown",e=>(t,n,r)=>{const o=t.data&&t.data.dataset||{};if("dropdown"===o.component){const{choices:i,disabled:a,feedback:s,showCorrectAnswer:l}=e,c=i&&i[o.id]&&i[o.id].find(e=>e.correct),d=l?c&&c.value:n[o.id];return Po.createElement(Bo,{key:`${t.type}-dropdown-${o.id}`,correct:s&&s[o.id]&&"correct"===s[o.id],disabled:a||l,value:d,correctValue:l?c&&c.label:void 0,id:o.id,onChange:r,choices:i[o.id],showCorrectAnswer:l,singleQuery:1==Object.keys(i).length})}});const Ho=n,zo=r,{isEqual:Fo}=i,{isEmpty:qo}=i,{styled:Uo}=o,{Tooltip:Ko}=a,{color:Vo}=s,{Collapsible:Xo}=s,{Readable:Yo}=s,{hasText:Jo}=s,{hasMedia:Qo}=s,{PreviewPrompt:Zo}=s,{UiLayout:Go}=s,ei=d,ti=e,{mq:ni}=p,{HorizontalKeypad:ri}=p,{updateSpans:oi}=p,ii=h,{renderMath:ai}=u;function si(e){let t,n=e[0],r=1;for(;r<e.length;){const o=e[r],i=e[r+1];if(r+=2,("optionalAccess"===o||"optionalCall"===o)&&null==n)return;"access"===o||"optionalAccess"===o?(t=n,n=i(n)):"call"!==o&&"optionalCall"!==o||(n=i((...e)=>n.call(t,...e)),t=void 0)}return n}const li=Uo(Go)({color:Vo.text(),backgroundColor:Vo.background(),display:"inline-block"}),ci=Uo("div")({width:"100%",position:"relative",backgroundColor:Vo.background(),color:Vo.text()}),di=Uo("div")(({theme:e})=>({marginBottom:e.spacing(2)})),ui=Uo("div")(({theme:e})=>({marginBottom:e.spacing(2)})),pi=Uo("div")({position:"relative","& > div > div":{display:"flex",alignItems:"baseline",flexWrap:"wrap"},"& .mq-overarrow-inner":{border:"none !important",padding:"0 !important"},"& .mq-overarrow-inner-right":{display:"none !important"},"& .mq-overarrow-inner-left":{display:"none !important"},"& .mq-overarrow.mq-arrow-both":{minWidth:"1.23em","& *":{lineHeight:"1 !important"},"&:before":{top:"-0.4em",left:"-1px"},"&:after":{top:"-2.4em",right:"-1px"},"&.mq-empty:after":{top:"-0.45em"}},"& .mq-overarrow.mq-arrow-right":{"&:before":{top:"-0.4em",right:"-1px"}},"& .mq-longdiv-inner":{borderTop:"1px solid !important",paddingTop:"1.5px !important"},"& .mq-parallelogram":{lineHeight:.85}}),hi=Uo("div")(({theme:e,$incorrect:t,$correct:n,$showCorrectness:r,$correctAnswerShown:o})=>({maxWidth:"fit-content",...t&&{borderColor:`${Vo.incorrect()} !important`},...n&&{borderColor:`${Vo.correct()} !important`},...r&&{border:"2px solid"},...o&&{padding:e.spacing(1),letterSpacing:"0.5px"},"& > .mq-math-mode":{"& > .mq-root-block":{"& > .mq-editable-field":{minWidth:"10px",padding:e.spacing(.25)}},"& sup":{top:0}}})),gi=Uo(ni.Static)({"& > .mq-root-block":{"& > .mq-editable-field":{borderColor:Vo.text()}}}),fi=Uo("div")(({theme:e})=>({zIndex:10,minWidth:"400px",marginTop:e.spacing(2)})),mi=Uo("div")(({theme:e})=>({marginBottom:e.spacing(1),pointerEvents:"none"})),vi=Uo("h2")({position:"absolute",left:"-10000px",top:"auto",width:"1px",height:"1px",overflow:"hidden"}),bi=Uo("div")(({theme:e})=>({marginBottom:e.spacing(2)})),yi=Uo(ei)(({theme:e})=>({color:Vo.text(),marginBottom:e.spacing(2)}));if("undefined"!=typeof document){const e="math-templated-main-styles";if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent=`\n .block-container {\n margin: 8px !important;\n display: inline-flex;\n border: 2px solid grey !important;\n }\n .block-response {\n flex: 2;\n color: grey;\n background: rgba(0, 0, 0, 0.04);\n font-size: 0.8rem !important;\n padding: 4px !important;\n display: flex;\n align-items: center;\n justify-content: center;\n border-right: 2px solid #bdbdbd !important;\n }\n .block-math {\n color: ${Vo.text()};\n background-color: ${Vo.background()};\n padding: 4px !important;\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 8;\n }\n .block-math > .mq-math-mode > .mq-hasCursor > .mq-cursor {\n display: none;\n }\n .correct {\n border-color: ${Vo.correct()} !important;\n }\n .incorrect {\n border-color: ${Vo.incorrect()} !important;\n }\n `,document.head.appendChild(t)}}let wi=!1;const xi=/(\{\{\d+\}\})/gm,Ci=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function ki(e=[],t){return 30*Math.floor(e.length/5)+("miscellaneous"===t?600:500)}function Ei(e,t){const{responses:n,disabled:r,markup:o,printMode:i,alwaysShowCorrect:a}=e||{};if(o){if(t.showCorrect)return Object.keys(n||{}).reduce((e,t)=>(e[t]=si([n,"optionalAccess",e=>e[t],"optionalAccess",e=>e.answer]),e),{});return o.split(xi).filter(e=>e).reduce((e,n)=>{if(n.match(xi)){const o=Si.getResponseKey(n),s=t.session.answers[`r${o}`];if(i&&!a){const t="\\ \\ ".repeat(30)+"\\embed{newLine}[] ";return{...e,[o]:`\\MathQuillMathField[r${o}]{${t.repeat(3)}}`}}return r?{...e,[o]:`\\embed{answerBlock}[r${o}]`}:{...e,[o]:`\\MathQuillMathField[r${o}]{${s&&s.value||""}}`}}return e},{})}}class Si extends Ho.Component{static __initStatic(){this.getResponseKey=e=>(e||"").replaceAll("{{","").replaceAll("}}","")}static __initStatic2(){this.propTypes={session:zo.object.isRequired,onSessionChange:zo.func,model:zo.object.isRequired}}constructor(e){super(e),Si.prototype.__init.call(this),Si.prototype.__init2.call(this),Si.prototype.__init3.call(this),Si.prototype.__init4.call(this),Si.prototype.__init5.call(this),Si.prototype.__init6.call(this),Si.prototype.__init7.call(this),Si.prototype.__init8.call(this),Si.prototype.__init9.call(this),Si.prototype.__init10.call(this),Si.prototype.__init11.call(this),Si.prototype.__init12.call(this),Si.prototype.__init13.call(this);const t={},{model:n,session:r}=e||{},{markup:o,alwaysShowCorrect:i}=n||{},{answers:a}=r||{};o&&(o||"").replace(xi,e=>{const n=Si.getResponseKey(e),r=a&&a[`r${n}`];t[`r${n}`]={value:si([r,"optionalAccess",e=>e.value])||""}}),this.state={session:{...e.session,answers:t},activeAnswerBlock:"",showCorrect:i||!1,tooltipContainerRef:Ho.createRef()}}UNSAFE_componentWillMount(){if("undefined"!=typeof window){let e=ii.getInterface(2);wi||(e.registerEmbed("answerBlock",e=>({htmlString:`<div class="block-container">\n <div class="block-response" id="${e}Index">R</div>\n <div class="block-math">\n <span id="${e}"></span>\n </div>\n </div>`,text:()=>"text",latex:()=>`\\embed{answerBlock}[${e}]`})),wi=!0)}}__init(){this.handleAnswerBlockDomUpdate=()=>{const{model:e}=this.props,{session:t,showCorrect:n}=this.state,r=t.answers;this.root&&e.disabled&&!n&&Object.keys(r).forEach(t=>{const n=this.root.querySelector(`#${t}`),o=this.root.querySelector(`#${t}Index`);if(n){let i=ii.getInterface(2);const a=r[t];n.textContent=a&&a.value||"",e.view&&(n.parentElement.parentElement.classList.remove("correct"),n.parentElement.parentElement.classList.remove("incorrect")),i.StaticMath(n),o.textContent="R"}}),ai(this.root)}}UNSAFE_componentWillReceiveProps(e){const{model:t}=this.props,{model:n={}}=e||{},{markup:r="",env:o={}}=t||{},{markup:i="",env:a={},alwaysShowCorrect:s=!1}=n,l=e=>e&&"evaluate"===e.mode;l(o)&&l(a)||this.setState(e=>({...e.session,showCorrect:!1})),s&&this.setState({showCorrect:!0});const c=r.match(xi),d=i.match(xi);if(!Fo(c,d)){const e={},t=this.state.session.answers;(d||[]).forEach(n=>{const r=Si.getResponseKey(n),o=t&&t[`r${r}`];e[`r${r}`]={value:si([o,"optionalAccess",e=>e.value])||""}}),this.setState(t=>({session:{...t.session,answers:e}}),()=>{this.props.onSessionChange(this.state.session),this.handleAnswerBlockDomUpdate()})}}shouldComponentUpdate(e,t){const n=Fo(this.props.model,e.model),r=Fo(this.state,t);return!n||!r}componentDidMount(){this.handleAnswerBlockDomUpdate(),setTimeout(()=>ai(this.root),100)}componentDidUpdate(){this.handleAnswerBlockDomUpdate()}__init2(){this.onSubFieldFocus=e=>{this.setState({activeAnswerBlock:e})}}__init3(){this.toNodeData=e=>{if(!e)return;const{type:t,value:n}=e;return"command"===t||"cursor"===t?e:"answer"===t?{type:"answer",...e}:"clear"===n?{type:"clear"}:{type:"write",value:n}}}__init4(){this.setInput=e=>{this.input=e}}__init5(){this.onClick=e=>{const t=this.toNodeData(e);"clear"===t.type?this.input.clear():"command"===t.type?Array.isArray(t.value)?t.value.forEach(e=>{this.input.cmd(e)}):this.input.cmd(t.value):"cursor"===t.type?this.input.keystroke(t.value):this.input.write(t.value),this.input.focus()}}__init6(){this.callOnSessionChange=()=>{const{onSessionChange:e}=this.props;e&&e(this.state.session)}}__init7(){this.toggleShowCorrect=e=>{this.setState({showCorrect:e},this.handleAnswerBlockDomUpdate)}}__init8(){this.subFieldChanged=(e,t)=>{oi(),e&&this.setState(n=>({session:{...n.session,answers:{...n.session.answers,[e]:{value:t}}}}),this.callOnSessionChange)}}__init9(){this.getFieldName=(e,t)=>{const{answers:n}=this.state.session;if(Object.keys(n||{}).length){return Object.keys(n).find(n=>{const r=t[n];return r&&r.id==e.id})}}}__init10(){this.onBlur=e=>{const{relatedTarget:t,currentTarget:n}=e||{};const r=function e(t,n=0){if(!t||n>=16)return null;const r=t.offsetParent;return r?"tooltip"===r.getAttribute("role")?r:e(r,n+1):null}(t),o=r?function e(t,n=0){if(!t||n>=4)return null;const r=si([t,"optionalAccess",e=>e.children,"optionalAccess",e=>e[0]]);return r?r.attributes&&r.attributes["data-keypad"]?r:e(r,n+1):null}(r):null;t&&n&&si([o,"optionalAccess",e=>e.attributes,"access",e=>e["data-keypad"]])||this.setState({activeAnswerBlock:""})}}setTooltipRef(e){setTimeout(()=>{if(e&&Ci){const e=document.querySelector("[role='tooltip']");if(e){e.firstChild.setAttribute("tabindex","-1")}}},1)}__init11(){this.renderTeacherInstructions=()=>{const{model:e}=this.props,{teacherInstructions:t,animationsDisabled:n}=e||{},r=t&&(Jo(t)||Qo(t)),o=Ho.createElement(Zo,{defaultClassName:"teacher-instructions",prompt:t});return r&&Ho.createElement(ui,null,n?o:Ho.createElement(Xo,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},o))}}__init12(){this.renderRationale=()=>{const{model:e}=this.props,{rationale:t,animationsDisabled:n}=e||{},r=Ho.createElement(Zo,{prompt:t});return t&&(Jo(t)||Qo(t))&&Ho.createElement(ui,null,n?r:Ho.createElement(Xo,{labels:{hidden:"Show Rationale",visible:"Hide Rationale"}},r))}}__init13(){this.renderPlayerContent=()=>{const{model:e}=this.props,{activeAnswerBlock:t,showCorrect:n,session:r,tooltipContainerRef:o}=this.state,{correctness:i,disabled:a,view:s,responses:l,equationEditor:c,customKeys:d,feedback:u,env:{mode:p}={},printMode:h,alwaysShowCorrect:g}=e||{},f=qo(l),m=function(e=[]){return e.map(e=>({name:e,latex:e,write:e,label:e}))}(d),v=Ei(e,this.state)||"",b=h&&!g;return Ho.createElement(pi,null,Ho.createElement(vo,{disabled:a,markup:e.markup,value:{},customMarkMarkupComponent:e=>{const l="evaluate"===p&&u&&u[e],d=Ho.createElement(gi,{ref:e=>{this.mqStatic=e||this.mqStatic},latex:v[e],onSubFieldChange:this.subFieldChanged,getFieldName:this.getFieldName,setInput:this.setInput,onSubFieldFocus:this.onSubFieldFocus,onBlur:this.onBlur});return Ho.createElement(hi,{ref:o,$incorrect:!f&&!l&&!n,$correct:!f&&(l||n),$showCorrectness:!f&&a&&i&&!s,$correctAnswerShown:n},Ho.createElement(Ko,{ref:e=>this.setTooltipRef(e),enterTouchDelay:0,interactive:!0,open:t===`r${e}`,slotProps:{popper:{container:si([o,"optionalAccess",e=>e.current])||void 0,placement:"bottom-end",sx:{backgroundColor:"transparent",width:"650px",opacity:1,"& .MuiTooltip-arrow":{display:"none"}},modifiers:{preventOverflow:{enabled:!0,boundariesElement:"body"},flip:{enabled:!1}}},tooltip:{sx:{fontSize:"initial",backgroundColor:"transparent",width:"600px",marginTop:0,paddingTop:0,boxShadow:"none"}}},title:Object.keys(r.answers).map(e=>e===t&&!(n||a)&&Ho.createElement(fi,{"data-keypad":!0,key:e,style:{width:ki(m,c)}},Ho.createElement(ri,{additionalKeys:m,mode:c||6,onClick:this.onClick}))||null)},b?Ho.createElement(mi,null,d):Ho.createElement("div",null,d)))}}))}}render(){const{model:e}=this.props,{showCorrect:t}=this.state,{prompt:n,env:{mode:r,role:o}={},extraCSSRules:i,correctness:a,responses:s,language:l,showNote:c,note:d}=e||{},u=!qo(s)&&a&&"correct"!==a.correctness,p=(t||"view"===r&&"instructor"===o)&&c&&d;return Ho.createElement(li,{extraCSSRules:i,ref:e=>{const t=ti.findDOMNode(e);this.root=t||this.root}},Ho.createElement(ci,null,"gather"===r&&Ho.createElement(vi,null,"Math Equation Response Question"),Ho.createElement(ci,null,u&&Ho.createElement(yi,{language:l,show:!0,toggled:t,onToggle:this.toggleShowCorrect})),this.renderTeacherInstructions(),n&&Ho.createElement(di,null,Ho.createElement(Zo,{prompt:n})),Ho.createElement(Yo,{false:!0},this.renderPlayerContent()),p&&Ho.createElement(bi,{className:"note",dangerouslySetInnerHTML:{__html:d}}),this.renderRationale()))}}Si.__initStatic(),Si.__initStatic2();const Ri=n,{debounce:Ai}=i,Di=t,{renderMath:_i}=u,Ti=Di("pie-element:math-templated:print");class Mi extends HTMLElement{constructor(){super(),this._options=null,this._model=null,this._session=[],this._root=null,this._rerender=Ai(()=>{if(this._model&&this._session){const e=((e,t)=>{const n="instructor"===t.role;return e.prompt=!1!==e.promptEnabled?e.prompt:void 0,e.teacherInstructions=n&&!1!==e.teacherInstructionsEnabled?e.teacherInstructions:void 0,e.rationale=n&&!1!==e.rationaleEnabled?e.rationale:void 0,e.showTeacherInstructions=n,e.alwaysShowCorrect=n,e.printMode=!0,e.feedback=void 0,e.markup=e.markup||"{{0}}",{...e,disabled:!0,env:{mode:n?"evaluate":e.mode,role:t.role}}})(this._model,this._options),t=this._options&&Ri.createElement(Si,{model:e,session:{}});this._root||(this._root=f(this)),this._root.render(t),queueMicrotask(()=>{Ti("render complete - render math"),_i(this)})}else Ti("skip")},50,{leading:!1,trailing:!0})}set options(e){this._options=e}set model(e){this._model=e,this._rerender()}connectedCallback(){}disconnectedCallback(){this._root&&this._root.unmount()}}export{Mi as default};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "repository": "pie-framework/pie-elements",
7
- "version": "6.0.0-beta.1",
7
+ "version": "6.0.0-next.43+4249fa78f",
8
8
  "description": "",
9
9
  "dependencies": {
10
10
  "@emotion/react": "^11.14.0",
@@ -12,21 +12,25 @@
12
12
  "@mui/icons-material": "^7.3.4",
13
13
  "@mui/material": "^7.3.4",
14
14
  "@pie-framework/pie-player-events": "^0.1.0",
15
- "@pie-lib/correct-answer-toggle": "3.1.0-next.5",
16
- "@pie-lib/mask-markup": "2.1.0-next.5",
17
- "@pie-lib/math-input": "7.1.0-next.4",
18
- "@pie-lib/math-rendering": "4.1.0-next.4",
19
- "@pie-lib/render-ui": "5.1.0-next.5",
20
- "prop-types": "^15.6.1",
21
- "react": "18.2.0",
22
- "react-dom": "18.2.0"
15
+ "@pie-lib/correct-answer-toggle": "3.1.1-next.0",
16
+ "@pie-lib/mask-markup": "2.1.1-next.0",
17
+ "@pie-lib/math-input": "7.1.1-next.0",
18
+ "@pie-lib/math-rendering": "4.1.1-next.0",
19
+ "@pie-lib/render-ui": "5.1.1-next.0",
20
+ "prop-types": "^15.8.1",
21
+ "react": "18.3.1",
22
+ "react-dom": "18.3.1"
23
23
  },
24
24
  "author": "",
25
25
  "license": "ISC",
26
- "gitHead": "052dc31d77fd3f6cb54ec2ac34ed84858e8672c9",
26
+ "gitHead": "4249fa78fc423ef0a8c89002b8f937c42b3478ea",
27
27
  "scripts": {
28
28
  "postpublish": "../../scripts/postpublish"
29
29
  },
30
30
  "main": "lib/index.js",
31
- "module": "src/index.js"
31
+ "module": "src/index.js",
32
+ "exports": {
33
+ ".": "./src/index.js",
34
+ "./print": "./src/print.js"
35
+ }
32
36
  }