cognikit 0.1.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +309 -237
- package/dist/client.d.ts +2 -1
- package/dist/client.js +264 -193
- package/dist/client.js.map +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +250 -179
- package/dist/index.js.map +3 -3
- package/dist/interactions/shared/classification-implementation/grader.d.ts +1 -1
- package/dist/shared/config.d.ts +10 -2
- package/dist/shell/simple-shell/script.d.ts +0 -1
- package/package.json +1 -1
- package/public/app.js +331 -140
- package/public/app.js.map +2 -2
- package/public/assets/DEMONSTRATION-1.jpeg +0 -0
- package/public/index.html +62 -16
package/dist/index.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
var HTMLElement = globalThis.HTMLElement ?? class {}; var customElements = globalThis.customElements ?? { get() { return undefined; }, define() {} };
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
`+e.mark.snippet),r+" "+t):r}function he(e,n){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=n,this.message=
|
|
5
|
-
`+s;for(c=
|
|
6
|
-
`,s+=
|
|
7
|
-
`,l=1;l<=n.linesAfter&&!(a+l>=i.length);l++)c=
|
|
8
|
-
`;return s.replace(/\n$/,"")}var
|
|
9
|
-
\r`;function
|
|
10
|
-
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function
|
|
11
|
-
`,n-1))}function
|
|
12
|
-
`,o?1+l:l):i===
|
|
13
|
-
`);break}for(r?V(u)?(c=!0,e.result+=
|
|
14
|
-
`,o?1+l:l)):c?(c=!1,e.result+=
|
|
15
|
-
`,l+1)):l===0?o&&(e.result+=" "):e.result+=
|
|
16
|
-
`,l):e.result+=
|
|
17
|
-
`,o?1+l:l),o=!0,a=!0,l=0,t=e.position;!R(u)&&u!==0;)u=e.input.charCodeAt(++e.position);H(e,t,e.position,!1)}return!0}function
|
|
18
|
-
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var t=new
|
|
2
|
+
function et(){let e=globalThis;if(typeof e.HTMLElement>"u"&&(e.HTMLElement=class{}),typeof e.customElements>"u"){let n=new Map;e.customElements={define(t,r){n.has(t)||n.set(t,r)},get(t){return n.get(t)},getName(t){for(let[r,i]of n.entries())if(i===t)return r;return null},upgrade(){},whenDefined(){return Promise.resolve(class{})}}}}et();function zt(e){return typeof e>"u"||e===null}function fi(e){return typeof e=="object"&&e!==null}function bi(e){return Array.isArray(e)?e:zt(e)?[]:[e]}function vi(e,n){var t,r,i,o;if(n)for(o=Object.keys(n),t=0,r=o.length;t<r;t+=1)i=o[t],e[i]=n[i];return e}function xi(e,n){var t="",r;for(r=0;r<n;r+=1)t+=e;return t}function wi(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var yi=zt,Ci=fi,Ei=bi,ki=xi,Si=wi,Ti=vi,k={isNothing:yi,isObject:Ci,toArray:Ei,repeat:ki,isNegativeZero:Si,extend:Ti};function Ht(e,n){var t="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(t+='in "'+e.mark.name+'" '),t+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!n&&e.mark.snippet&&(t+=`
|
|
3
|
+
|
|
4
|
+
`+e.mark.snippet),r+" "+t):r}function he(e,n){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=n,this.message=Ht(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}he.prototype=Object.create(Error.prototype);he.prototype.constructor=he;he.prototype.toString=function(n){return this.name+": "+Ht(this,n)};var _=he;function tt(e,n,t,r,i){var o="",a="",s=Math.floor(i/2)-1;return r-n>s&&(o=" ... ",n=r-s+o.length),t-r>s&&(a=" ...",t=r+s-a.length),{str:o+e.slice(n,t).replace(/\t/g,"\u2192")+a,pos:r-n+o.length}}function rt(e,n){return k.repeat(" ",n-e.length)+e}function $i(e,n){if(n=Object.create(n||null),!e.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!="number"&&(n.indent=1),typeof n.linesBefore!="number"&&(n.linesBefore=3),typeof n.linesAfter!="number"&&(n.linesAfter=2);for(var t=/\r?\n|\r|\0/g,r=[0],i=[],o,a=-1;o=t.exec(e.buffer);)i.push(o.index),r.push(o.index+o[0].length),e.position<=o.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var s="",l,c,d=Math.min(e.line+n.linesAfter,i.length).toString().length,u=n.maxLength-(n.indent+d+3);for(l=1;l<=n.linesBefore&&!(a-l<0);l++)c=tt(e.buffer,r[a-l],i[a-l],e.position-(r[a]-r[a-l]),u),s=k.repeat(" ",n.indent)+rt((e.line-l+1).toString(),d)+" | "+c.str+`
|
|
5
|
+
`+s;for(c=tt(e.buffer,r[a],i[a],e.position,u),s+=k.repeat(" ",n.indent)+rt((e.line+1).toString(),d)+" | "+c.str+`
|
|
6
|
+
`,s+=k.repeat("-",n.indent+d+3+c.pos)+`^
|
|
7
|
+
`,l=1;l<=n.linesAfter&&!(a+l>=i.length);l++)c=tt(e.buffer,r[a+l],i[a+l],e.position-(r[a]-r[a+l]),u),s+=k.repeat(" ",n.indent)+rt((e.line+l+1).toString(),d)+" | "+c.str+`
|
|
8
|
+
`;return s.replace(/\n$/,"")}var Ai=$i,_i=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Ii=["scalar","sequence","mapping"];function Mi(e){var n={};return e!==null&&Object.keys(e).forEach(function(t){e[t].forEach(function(r){n[String(r)]=t})}),n}function Li(e,n){if(n=n||{},Object.keys(n).forEach(function(t){if(_i.indexOf(t)===-1)throw new _('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')}),this.options=n,this.tag=e,this.kind=n.kind||null,this.resolve=n.resolve||function(){return!0},this.construct=n.construct||function(t){return t},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.representName=n.representName||null,this.defaultStyle=n.defaultStyle||null,this.multi=n.multi||!1,this.styleAliases=Mi(n.styleAliases||null),Ii.indexOf(this.kind)===-1)throw new _('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var $=Li;function Et(e,n){var t=[];return e[n].forEach(function(r){var i=t.length;t.forEach(function(o,a){o.tag===r.tag&&o.kind===r.kind&&o.multi===r.multi&&(i=a)}),t[i]=r}),t}function Di(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},n,t;function r(i){i.multi?(e.multi[i.kind].push(i),e.multi.fallback.push(i)):e[i.kind][i.tag]=e.fallback[i.tag]=i}for(n=0,t=arguments.length;n<t;n+=1)arguments[n].forEach(r);return e}function nt(e){return this.extend(e)}nt.prototype.extend=function(n){var t=[],r=[];if(n instanceof $)r.push(n);else if(Array.isArray(n))r=r.concat(n);else if(n&&(Array.isArray(n.implicit)||Array.isArray(n.explicit)))n.implicit&&(t=t.concat(n.implicit)),n.explicit&&(r=r.concat(n.explicit));else throw new _("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.forEach(function(o){if(!(o instanceof $))throw new _("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new _("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(o.multi)throw new _("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(o){if(!(o instanceof $))throw new _("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(nt.prototype);return i.implicit=(this.implicit||[]).concat(t),i.explicit=(this.explicit||[]).concat(r),i.compiledImplicit=Et(i,"implicit"),i.compiledExplicit=Et(i,"explicit"),i.compiledTypeMap=Di(i.compiledImplicit,i.compiledExplicit),i};var Nt=nt,Gt=new $("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Ot=new $("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Vt=new $("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Ft=new Nt({explicit:[Gt,Ot,Vt]});function Ri(e){if(e===null)return!0;var n=e.length;return n===1&&e==="~"||n===4&&(e==="null"||e==="Null"||e==="NULL")}function Pi(){return null}function Bi(e){return e===null}var jt=new $("tag:yaml.org,2002:null",{kind:"scalar",resolve:Ri,construct:Pi,predicate:Bi,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function qi(e){if(e===null)return!1;var n=e.length;return n===4&&(e==="true"||e==="True"||e==="TRUE")||n===5&&(e==="false"||e==="False"||e==="FALSE")}function zi(e){return e==="true"||e==="True"||e==="TRUE"}function Hi(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Ut=new $("tag:yaml.org,2002:bool",{kind:"scalar",resolve:qi,construct:zi,predicate:Hi,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function Ni(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Gi(e){return 48<=e&&e<=55}function Oi(e){return 48<=e&&e<=57}function Vi(e){if(e===null)return!1;var n=e.length,t=0,r=!1,i;if(!n)return!1;if(i=e[t],(i==="-"||i==="+")&&(i=e[++t]),i==="0"){if(t+1===n)return!0;if(i=e[++t],i==="b"){for(t++;t<n;t++)if(i=e[t],i!=="_"){if(i!=="0"&&i!=="1")return!1;r=!0}return r&&i!=="_"}if(i==="x"){for(t++;t<n;t++)if(i=e[t],i!=="_"){if(!Ni(e.charCodeAt(t)))return!1;r=!0}return r&&i!=="_"}if(i==="o"){for(t++;t<n;t++)if(i=e[t],i!=="_"){if(!Gi(e.charCodeAt(t)))return!1;r=!0}return r&&i!=="_"}}if(i==="_")return!1;for(;t<n;t++)if(i=e[t],i!=="_"){if(!Oi(e.charCodeAt(t)))return!1;r=!0}return!(!r||i==="_")}function Fi(e){var n=e,t=1,r;if(n.indexOf("_")!==-1&&(n=n.replace(/_/g,"")),r=n[0],(r==="-"||r==="+")&&(r==="-"&&(t=-1),n=n.slice(1),r=n[0]),n==="0")return 0;if(r==="0"){if(n[1]==="b")return t*parseInt(n.slice(2),2);if(n[1]==="x")return t*parseInt(n.slice(2),16);if(n[1]==="o")return t*parseInt(n.slice(2),8)}return t*parseInt(n,10)}function ji(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!k.isNegativeZero(e)}var Yt=new $("tag:yaml.org,2002:int",{kind:"scalar",resolve:Vi,construct:Fi,predicate:ji,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ui=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Yi(e){return!(e===null||!Ui.test(e)||e[e.length-1]==="_")}function Ki(e){var n,t;return n=e.replace(/_/g,"").toLowerCase(),t=n[0]==="-"?-1:1,"+-".indexOf(n[0])>=0&&(n=n.slice(1)),n===".inf"?t===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:n===".nan"?NaN:t*parseFloat(n,10)}var Wi=/^[-+]?[0-9]+e/;function Qi(e,n){var t;if(isNaN(e))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(k.isNegativeZero(e))return"-0.0";return t=e.toString(10),Wi.test(t)?t.replace("e",".e"):t}function Zi(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||k.isNegativeZero(e))}var Kt=new $("tag:yaml.org,2002:float",{kind:"scalar",resolve:Yi,construct:Ki,predicate:Zi,represent:Qi,defaultStyle:"lowercase"}),Wt=Ft.extend({implicit:[jt,Ut,Yt,Kt]}),Qt=Wt,Zt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Xt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Xi(e){return e===null?!1:Zt.exec(e)!==null||Xt.exec(e)!==null}function Ji(e){var n,t,r,i,o,a,s,l=0,c=null,d,u,p;if(n=Zt.exec(e),n===null&&(n=Xt.exec(e)),n===null)throw new Error("Date resolve error");if(t=+n[1],r=+n[2]-1,i=+n[3],!n[4])return new Date(Date.UTC(t,r,i));if(o=+n[4],a=+n[5],s=+n[6],n[7]){for(l=n[7].slice(0,3);l.length<3;)l+="0";l=+l}return n[9]&&(d=+n[10],u=+(n[11]||0),c=(d*60+u)*6e4,n[9]==="-"&&(c=-c)),p=new Date(Date.UTC(t,r,i,o,a,s,l)),c&&p.setTime(p.getTime()-c),p}function en(e){return e.toISOString()}var Jt=new $("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Xi,construct:Ji,instanceOf:Date,represent:en});function tn(e){return e==="<<"||e===null}var er=new $("tag:yaml.org,2002:merge",{kind:"scalar",resolve:tn}),ct=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
9
|
+
\r`;function rn(e){if(e===null)return!1;var n,t,r=0,i=e.length,o=ct;for(t=0;t<i;t++)if(n=o.indexOf(e.charAt(t)),!(n>64)){if(n<0)return!1;r+=6}return r%8===0}function nn(e){var n,t,r=e.replace(/[\r\n=]/g,""),i=r.length,o=ct,a=0,s=[];for(n=0;n<i;n++)n%4===0&&n&&(s.push(a>>16&255),s.push(a>>8&255),s.push(a&255)),a=a<<6|o.indexOf(r.charAt(n));return t=i%4*6,t===0?(s.push(a>>16&255),s.push(a>>8&255),s.push(a&255)):t===18?(s.push(a>>10&255),s.push(a>>2&255)):t===12&&s.push(a>>4&255),new Uint8Array(s)}function on(e){var n="",t=0,r,i,o=e.length,a=ct;for(r=0;r<o;r++)r%3===0&&r&&(n+=a[t>>18&63],n+=a[t>>12&63],n+=a[t>>6&63],n+=a[t&63]),t=(t<<8)+e[r];return i=o%3,i===0?(n+=a[t>>18&63],n+=a[t>>12&63],n+=a[t>>6&63],n+=a[t&63]):i===2?(n+=a[t>>10&63],n+=a[t>>4&63],n+=a[t<<2&63],n+=a[64]):i===1&&(n+=a[t>>2&63],n+=a[t<<4&63],n+=a[64],n+=a[64]),n}function an(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var tr=new $("tag:yaml.org,2002:binary",{kind:"scalar",resolve:rn,construct:nn,predicate:an,represent:on}),sn=Object.prototype.hasOwnProperty,ln=Object.prototype.toString;function cn(e){if(e===null)return!0;var n=[],t,r,i,o,a,s=e;for(t=0,r=s.length;t<r;t+=1){if(i=s[t],a=!1,ln.call(i)!=="[object Object]")return!1;for(o in i)if(sn.call(i,o))if(!a)a=!0;else return!1;if(!a)return!1;if(n.indexOf(o)===-1)n.push(o);else return!1}return!0}function dn(e){return e!==null?e:[]}var rr=new $("tag:yaml.org,2002:omap",{kind:"sequence",resolve:cn,construct:dn}),un=Object.prototype.toString;function pn(e){if(e===null)return!0;var n,t,r,i,o,a=e;for(o=new Array(a.length),n=0,t=a.length;n<t;n+=1){if(r=a[n],un.call(r)!=="[object Object]"||(i=Object.keys(r),i.length!==1))return!1;o[n]=[i[0],r[i[0]]]}return!0}function hn(e){if(e===null)return[];var n,t,r,i,o,a=e;for(o=new Array(a.length),n=0,t=a.length;n<t;n+=1)r=a[n],i=Object.keys(r),o[n]=[i[0],r[i[0]]];return o}var ir=new $("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:pn,construct:hn}),gn=Object.prototype.hasOwnProperty;function mn(e){if(e===null)return!0;var n,t=e;for(n in t)if(gn.call(t,n)&&t[n]!==null)return!1;return!0}function fn(e){return e!==null?e:{}}var nr=new $("tag:yaml.org,2002:set",{kind:"mapping",resolve:mn,construct:fn}),dt=Qt.extend({implicit:[Jt,er],explicit:[tr,rr,ir,nr]}),N=Object.prototype.hasOwnProperty,qe=1,or=2,ar=3,ze=4,it=1,bn=2,kt=3,vn=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,xn=/[\x85\u2028\u2029]/,wn=/[,\[\]\{\}]/,sr=/^(?:!|!!|![a-z\-]+!)$/i,lr=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function St(e){return Object.prototype.toString.call(e)}function R(e){return e===10||e===13}function V(e){return e===9||e===32}function I(e){return e===9||e===32||e===10||e===13}function Q(e){return e===44||e===91||e===93||e===123||e===125}function yn(e){var n;return 48<=e&&e<=57?e-48:(n=e|32,97<=n&&n<=102?n-97+10:-1)}function Cn(e){return e===120?2:e===117?4:e===85?8:0}function En(e){return 48<=e&&e<=57?e-48:-1}function Tt(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
|
|
10
|
+
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function kn(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function cr(e,n,t){n==="__proto__"?Object.defineProperty(e,n,{configurable:!0,enumerable:!0,writable:!0,value:t}):e[n]=t}var dr=new Array(256),ur=new Array(256);for(O=0;O<256;O++)dr[O]=Tt(O)?1:0,ur[O]=Tt(O);var O;function Sn(e,n){this.input=e,this.filename=n.filename||null,this.schema=n.schema||dt,this.onWarning=n.onWarning||null,this.legacy=n.legacy||!1,this.json=n.json||!1,this.listener=n.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function pr(e,n){var t={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return t.snippet=Ai(t),new _(n,t)}function f(e,n){throw pr(e,n)}function He(e,n){e.onWarning&&e.onWarning.call(null,pr(e,n))}var $t={YAML:function(n,t,r){var i,o,a;n.version!==null&&f(n,"duplication of %YAML directive"),r.length!==1&&f(n,"YAML directive accepts exactly one argument"),i=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),i===null&&f(n,"ill-formed argument of the YAML directive"),o=parseInt(i[1],10),a=parseInt(i[2],10),o!==1&&f(n,"unacceptable YAML version of the document"),n.version=r[0],n.checkLineBreaks=a<2,a!==1&&a!==2&&He(n,"unsupported YAML version of the document")},TAG:function(n,t,r){var i,o;r.length!==2&&f(n,"TAG directive accepts exactly two arguments"),i=r[0],o=r[1],sr.test(i)||f(n,"ill-formed tag handle (first argument) of the TAG directive"),N.call(n.tagMap,i)&&f(n,'there is a previously declared suffix for "'+i+'" tag handle'),lr.test(o)||f(n,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch{f(n,"tag prefix is malformed: "+o)}n.tagMap[i]=o}};function H(e,n,t,r){var i,o,a,s;if(n<t){if(s=e.input.slice(n,t),r)for(i=0,o=s.length;i<o;i+=1)a=s.charCodeAt(i),a===9||32<=a&&a<=1114111||f(e,"expected valid JSON character");else vn.test(s)&&f(e,"the stream contains non-printable characters");e.result+=s}}function At(e,n,t,r){var i,o,a,s;for(k.isObject(t)||f(e,"cannot merge mappings; the provided source object is unacceptable"),i=Object.keys(t),a=0,s=i.length;a<s;a+=1)o=i[a],N.call(n,o)||(cr(n,o,t[o]),r[o]=!0)}function Z(e,n,t,r,i,o,a,s,l){var c,d;if(Array.isArray(i))for(i=Array.prototype.slice.call(i),c=0,d=i.length;c<d;c+=1)Array.isArray(i[c])&&f(e,"nested arrays are not supported inside keys"),typeof i=="object"&&St(i[c])==="[object Object]"&&(i[c]="[object Object]");if(typeof i=="object"&&St(i)==="[object Object]"&&(i="[object Object]"),i=String(i),n===null&&(n={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(o))for(c=0,d=o.length;c<d;c+=1)At(e,n,o[c],t);else At(e,n,o,t);else!e.json&&!N.call(t,i)&&N.call(n,i)&&(e.line=a||e.line,e.lineStart=s||e.lineStart,e.position=l||e.position,f(e,"duplicated mapping key")),cr(n,i,o),delete t[i];return n}function ut(e){var n;n=e.input.charCodeAt(e.position),n===10?e.position++:n===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):f(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function C(e,n,t){for(var r=0,i=e.input.charCodeAt(e.position);i!==0;){for(;V(i);)i===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),i=e.input.charCodeAt(++e.position);if(n&&i===35)do i=e.input.charCodeAt(++e.position);while(i!==10&&i!==13&&i!==0);if(R(i))for(ut(e),i=e.input.charCodeAt(e.position),r++,e.lineIndent=0;i===32;)e.lineIndent++,i=e.input.charCodeAt(++e.position);else break}return t!==-1&&r!==0&&e.lineIndent<t&&He(e,"deficient indentation"),r}function Oe(e){var n=e.position,t;return t=e.input.charCodeAt(n),!!((t===45||t===46)&&t===e.input.charCodeAt(n+1)&&t===e.input.charCodeAt(n+2)&&(n+=3,t=e.input.charCodeAt(n),t===0||I(t)))}function pt(e,n){n===1?e.result+=" ":n>1&&(e.result+=k.repeat(`
|
|
11
|
+
`,n-1))}function Tn(e,n,t){var r,i,o,a,s,l,c,d,u=e.kind,p=e.result,h;if(h=e.input.charCodeAt(e.position),I(h)||Q(h)||h===35||h===38||h===42||h===33||h===124||h===62||h===39||h===34||h===37||h===64||h===96||(h===63||h===45)&&(i=e.input.charCodeAt(e.position+1),I(i)||t&&Q(i)))return!1;for(e.kind="scalar",e.result="",o=a=e.position,s=!1;h!==0;){if(h===58){if(i=e.input.charCodeAt(e.position+1),I(i)||t&&Q(i))break}else if(h===35){if(r=e.input.charCodeAt(e.position-1),I(r))break}else{if(e.position===e.lineStart&&Oe(e)||t&&Q(h))break;if(R(h))if(l=e.line,c=e.lineStart,d=e.lineIndent,C(e,!1,-1),e.lineIndent>=n){s=!0,h=e.input.charCodeAt(e.position);continue}else{e.position=a,e.line=l,e.lineStart=c,e.lineIndent=d;break}}s&&(H(e,o,a,!1),pt(e,e.line-l),o=a=e.position,s=!1),V(h)||(a=e.position+1),h=e.input.charCodeAt(++e.position)}return H(e,o,a,!1),e.result?!0:(e.kind=u,e.result=p,!1)}function $n(e,n){var t,r,i;if(t=e.input.charCodeAt(e.position),t!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=i=e.position;(t=e.input.charCodeAt(e.position))!==0;)if(t===39)if(H(e,r,e.position,!0),t=e.input.charCodeAt(++e.position),t===39)r=e.position,e.position++,i=e.position;else return!0;else R(t)?(H(e,r,i,!0),pt(e,C(e,!1,n)),r=i=e.position):e.position===e.lineStart&&Oe(e)?f(e,"unexpected end of the document within a single quoted scalar"):(e.position++,i=e.position);f(e,"unexpected end of the stream within a single quoted scalar")}function An(e,n){var t,r,i,o,a,s;if(s=e.input.charCodeAt(e.position),s!==34)return!1;for(e.kind="scalar",e.result="",e.position++,t=r=e.position;(s=e.input.charCodeAt(e.position))!==0;){if(s===34)return H(e,t,e.position,!0),e.position++,!0;if(s===92){if(H(e,t,e.position,!0),s=e.input.charCodeAt(++e.position),R(s))C(e,!1,n);else if(s<256&&dr[s])e.result+=ur[s],e.position++;else if((a=Cn(s))>0){for(i=a,o=0;i>0;i--)s=e.input.charCodeAt(++e.position),(a=yn(s))>=0?o=(o<<4)+a:f(e,"expected hexadecimal character");e.result+=kn(o),e.position++}else f(e,"unknown escape sequence");t=r=e.position}else R(s)?(H(e,t,r,!0),pt(e,C(e,!1,n)),t=r=e.position):e.position===e.lineStart&&Oe(e)?f(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}f(e,"unexpected end of the stream within a double quoted scalar")}function _n(e,n){var t=!0,r,i,o,a=e.tag,s,l=e.anchor,c,d,u,p,h,g=Object.create(null),m,b,w,v;if(v=e.input.charCodeAt(e.position),v===91)d=93,h=!1,s=[];else if(v===123)d=125,h=!0,s={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=s),v=e.input.charCodeAt(++e.position);v!==0;){if(C(e,!0,n),v=e.input.charCodeAt(e.position),v===d)return e.position++,e.tag=a,e.anchor=l,e.kind=h?"mapping":"sequence",e.result=s,!0;t?v===44&&f(e,"expected the node content, but found ','"):f(e,"missed comma between flow collection entries"),b=m=w=null,u=p=!1,v===63&&(c=e.input.charCodeAt(e.position+1),I(c)&&(u=p=!0,e.position++,C(e,!0,n))),r=e.line,i=e.lineStart,o=e.position,X(e,n,qe,!1,!0),b=e.tag,m=e.result,C(e,!0,n),v=e.input.charCodeAt(e.position),(p||e.line===r)&&v===58&&(u=!0,v=e.input.charCodeAt(++e.position),C(e,!0,n),X(e,n,qe,!1,!0),w=e.result),h?Z(e,s,g,b,m,w,r,i,o):u?s.push(Z(e,null,g,b,m,w,r,i,o)):s.push(m),C(e,!0,n),v=e.input.charCodeAt(e.position),v===44?(t=!0,v=e.input.charCodeAt(++e.position)):t=!1}f(e,"unexpected end of the stream within a flow collection")}function In(e,n){var t,r,i=it,o=!1,a=!1,s=n,l=0,c=!1,d,u;if(u=e.input.charCodeAt(e.position),u===124)r=!1;else if(u===62)r=!0;else return!1;for(e.kind="scalar",e.result="";u!==0;)if(u=e.input.charCodeAt(++e.position),u===43||u===45)it===i?i=u===43?kt:bn:f(e,"repeat of a chomping mode identifier");else if((d=En(u))>=0)d===0?f(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?f(e,"repeat of an indentation width identifier"):(s=n+d-1,a=!0);else break;if(V(u)){do u=e.input.charCodeAt(++e.position);while(V(u));if(u===35)do u=e.input.charCodeAt(++e.position);while(!R(u)&&u!==0)}for(;u!==0;){for(ut(e),e.lineIndent=0,u=e.input.charCodeAt(e.position);(!a||e.lineIndent<s)&&u===32;)e.lineIndent++,u=e.input.charCodeAt(++e.position);if(!a&&e.lineIndent>s&&(s=e.lineIndent),R(u)){l++;continue}if(e.lineIndent<s){i===kt?e.result+=k.repeat(`
|
|
12
|
+
`,o?1+l:l):i===it&&o&&(e.result+=`
|
|
13
|
+
`);break}for(r?V(u)?(c=!0,e.result+=k.repeat(`
|
|
14
|
+
`,o?1+l:l)):c?(c=!1,e.result+=k.repeat(`
|
|
15
|
+
`,l+1)):l===0?o&&(e.result+=" "):e.result+=k.repeat(`
|
|
16
|
+
`,l):e.result+=k.repeat(`
|
|
17
|
+
`,o?1+l:l),o=!0,a=!0,l=0,t=e.position;!R(u)&&u!==0;)u=e.input.charCodeAt(++e.position);H(e,t,e.position,!1)}return!0}function _t(e,n){var t,r=e.tag,i=e.anchor,o=[],a,s=!1,l;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=o),l=e.input.charCodeAt(e.position);l!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,f(e,"tab characters must not be used in indentation")),!(l!==45||(a=e.input.charCodeAt(e.position+1),!I(a))));){if(s=!0,e.position++,C(e,!0,-1)&&e.lineIndent<=n){o.push(null),l=e.input.charCodeAt(e.position);continue}if(t=e.line,X(e,n,ar,!1,!0),o.push(e.result),C(e,!0,-1),l=e.input.charCodeAt(e.position),(e.line===t||e.lineIndent>n)&&l!==0)f(e,"bad indentation of a sequence entry");else if(e.lineIndent<n)break}return s?(e.tag=r,e.anchor=i,e.kind="sequence",e.result=o,!0):!1}function Mn(e,n,t){var r,i,o,a,s,l,c=e.tag,d=e.anchor,u={},p=Object.create(null),h=null,g=null,m=null,b=!1,w=!1,v;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),v=e.input.charCodeAt(e.position);v!==0;){if(!b&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,f(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),o=e.line,(v===63||v===58)&&I(r))v===63?(b&&(Z(e,u,p,h,g,null,a,s,l),h=g=m=null),w=!0,b=!0,i=!0):b?(b=!1,i=!0):f(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,v=r;else{if(a=e.line,s=e.lineStart,l=e.position,!X(e,t,or,!1,!0))break;if(e.line===o){for(v=e.input.charCodeAt(e.position);V(v);)v=e.input.charCodeAt(++e.position);if(v===58)v=e.input.charCodeAt(++e.position),I(v)||f(e,"a whitespace character is expected after the key-value separator within a block mapping"),b&&(Z(e,u,p,h,g,null,a,s,l),h=g=m=null),w=!0,b=!1,i=!1,h=e.tag,g=e.result;else if(w)f(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=c,e.anchor=d,!0}else if(w)f(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=c,e.anchor=d,!0}if((e.line===o||e.lineIndent>n)&&(b&&(a=e.line,s=e.lineStart,l=e.position),X(e,n,ze,!0,i)&&(b?g=e.result:m=e.result),b||(Z(e,u,p,h,g,m,a,s,l),h=g=m=null),C(e,!0,-1),v=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>n)&&v!==0)f(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return b&&Z(e,u,p,h,g,null,a,s,l),w&&(e.tag=c,e.anchor=d,e.kind="mapping",e.result=u),w}function Ln(e){var n,t=!1,r=!1,i,o,a;if(a=e.input.charCodeAt(e.position),a!==33)return!1;if(e.tag!==null&&f(e,"duplication of a tag property"),a=e.input.charCodeAt(++e.position),a===60?(t=!0,a=e.input.charCodeAt(++e.position)):a===33?(r=!0,i="!!",a=e.input.charCodeAt(++e.position)):i="!",n=e.position,t){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(o=e.input.slice(n,e.position),a=e.input.charCodeAt(++e.position)):f(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!I(a);)a===33&&(r?f(e,"tag suffix cannot contain exclamation marks"):(i=e.input.slice(n-1,e.position+1),sr.test(i)||f(e,"named tag handle cannot contain such characters"),r=!0,n=e.position+1)),a=e.input.charCodeAt(++e.position);o=e.input.slice(n,e.position),wn.test(o)&&f(e,"tag suffix cannot contain flow indicator characters")}o&&!lr.test(o)&&f(e,"tag name cannot contain such characters: "+o);try{o=decodeURIComponent(o)}catch{f(e,"tag name is malformed: "+o)}return t?e.tag=o:N.call(e.tagMap,i)?e.tag=e.tagMap[i]+o:i==="!"?e.tag="!"+o:i==="!!"?e.tag="tag:yaml.org,2002:"+o:f(e,'undeclared tag handle "'+i+'"'),!0}function Dn(e){var n,t;if(t=e.input.charCodeAt(e.position),t!==38)return!1;for(e.anchor!==null&&f(e,"duplication of an anchor property"),t=e.input.charCodeAt(++e.position),n=e.position;t!==0&&!I(t)&&!Q(t);)t=e.input.charCodeAt(++e.position);return e.position===n&&f(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(n,e.position),!0}function Rn(e){var n,t,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),n=e.position;r!==0&&!I(r)&&!Q(r);)r=e.input.charCodeAt(++e.position);return e.position===n&&f(e,"name of an alias node must contain at least one character"),t=e.input.slice(n,e.position),N.call(e.anchorMap,t)||f(e,'unidentified alias "'+t+'"'),e.result=e.anchorMap[t],C(e,!0,-1),!0}function X(e,n,t,r,i){var o,a,s,l=1,c=!1,d=!1,u,p,h,g,m,b;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=a=s=ze===t||ar===t,r&&C(e,!0,-1)&&(c=!0,e.lineIndent>n?l=1:e.lineIndent===n?l=0:e.lineIndent<n&&(l=-1)),l===1)for(;Ln(e)||Dn(e);)C(e,!0,-1)?(c=!0,s=o,e.lineIndent>n?l=1:e.lineIndent===n?l=0:e.lineIndent<n&&(l=-1)):s=!1;if(s&&(s=c||i),(l===1||ze===t)&&(qe===t||or===t?m=n:m=n+1,b=e.position-e.lineStart,l===1?s&&(_t(e,b)||Mn(e,b,m))||_n(e,m)?d=!0:(a&&In(e,m)||$n(e,m)||An(e,m)?d=!0:Rn(e)?(d=!0,(e.tag!==null||e.anchor!==null)&&f(e,"alias node should not have any properties")):Tn(e,m,qe===t)&&(d=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):l===0&&(d=s&&_t(e,b))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&f(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),u=0,p=e.implicitTypes.length;u<p;u+=1)if(g=e.implicitTypes[u],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(N.call(e.typeMap[e.kind||"fallback"],e.tag))g=e.typeMap[e.kind||"fallback"][e.tag];else for(g=null,h=e.typeMap.multi[e.kind||"fallback"],u=0,p=h.length;u<p;u+=1)if(e.tag.slice(0,h[u].tag.length)===h[u].tag){g=h[u];break}g||f(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&f(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+g.kind+'", not "'+e.kind+'"'),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):f(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||d}function Pn(e){var n=e.position,t,r,i,o=!1,a;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(a=e.input.charCodeAt(e.position))!==0&&(C(e,!0,-1),a=e.input.charCodeAt(e.position),!(e.lineIndent>0||a!==37));){for(o=!0,a=e.input.charCodeAt(++e.position),t=e.position;a!==0&&!I(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(t,e.position),i=[],r.length<1&&f(e,"directive name must not be less than one character in length");a!==0;){for(;V(a);)a=e.input.charCodeAt(++e.position);if(a===35){do a=e.input.charCodeAt(++e.position);while(a!==0&&!R(a));break}if(R(a))break;for(t=e.position;a!==0&&!I(a);)a=e.input.charCodeAt(++e.position);i.push(e.input.slice(t,e.position))}a!==0&&ut(e),N.call($t,r)?$t[r](e,r,i):He(e,'unknown document directive "'+r+'"')}if(C(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,C(e,!0,-1)):o&&f(e,"directives end mark is expected"),X(e,e.lineIndent-1,ze,!1,!0),C(e,!0,-1),e.checkLineBreaks&&xn.test(e.input.slice(n,e.position))&&He(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Oe(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,C(e,!0,-1));return}if(e.position<e.length-1)f(e,"end of the stream or a document separator is expected");else return}function hr(e,n){e=String(e),n=n||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
18
|
+
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var t=new Sn(e,n),r=e.indexOf("\0");for(r!==-1&&(t.position=r,f(t,"null byte is not allowed in input")),t.input+="\0";t.input.charCodeAt(t.position)===32;)t.lineIndent+=1,t.position+=1;for(;t.position<t.length-1;)Pn(t);return t.documents}function Bn(e,n,t){n!==null&&typeof n=="object"&&typeof t>"u"&&(t=n,n=null);var r=hr(e,t);if(typeof n!="function")return r;for(var i=0,o=r.length;i<o;i+=1)n(r[i])}function qn(e,n){var t=hr(e,n);if(t.length!==0){if(t.length===1)return t[0];throw new _("expected a single document in the stream, but found more")}}var zn=Bn,Hn=qn,gr={loadAll:zn,load:Hn},mr=Object.prototype.toString,fr=Object.prototype.hasOwnProperty,ht=65279,Nn=9,ge=10,Gn=13,On=32,Vn=33,Fn=34,ot=35,jn=37,Un=38,Yn=39,Kn=42,br=44,Wn=45,Ne=58,Qn=61,Zn=62,Xn=63,Jn=64,vr=91,xr=93,eo=96,wr=123,to=124,yr=125,A={};A[0]="\\0";A[7]="\\a";A[8]="\\b";A[9]="\\t";A[10]="\\n";A[11]="\\v";A[12]="\\f";A[13]="\\r";A[27]="\\e";A[34]='\\"';A[92]="\\\\";A[133]="\\N";A[160]="\\_";A[8232]="\\L";A[8233]="\\P";var ro=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],io=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function no(e,n){var t,r,i,o,a,s,l;if(n===null)return{};for(t={},r=Object.keys(n),i=0,o=r.length;i<o;i+=1)a=r[i],s=String(n[a]),a.slice(0,2)==="!!"&&(a="tag:yaml.org,2002:"+a.slice(2)),l=e.compiledTypeMap.fallback[a],l&&fr.call(l.styleAliases,s)&&(s=l.styleAliases[s]),t[a]=s;return t}function oo(e){var n,t,r;if(n=e.toString(16).toUpperCase(),e<=255)t="x",r=2;else if(e<=65535)t="u",r=4;else if(e<=4294967295)t="U",r=8;else throw new _("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+t+k.repeat("0",r-n.length)+n}var ao=1,me=2;function so(e){this.schema=e.schema||dt,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=k.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=no(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?me:ao,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function It(e,n){for(var t=k.repeat(" ",n),r=0,i=-1,o="",a,s=e.length;r<s;)i=e.indexOf(`
|
|
19
19
|
`,r),i===-1?(a=e.slice(r),r=s):(a=e.slice(r,i+1),r=i+1),a.length&&a!==`
|
|
20
|
-
`&&(o+=t),o+=a;return o}function
|
|
21
|
-
`+
|
|
20
|
+
`&&(o+=t),o+=a;return o}function at(e,n){return`
|
|
21
|
+
`+k.repeat(" ",e.indent*n)}function lo(e,n){var t,r,i;for(t=0,r=e.implicitTypes.length;t<r;t+=1)if(i=e.implicitTypes[t],i.resolve(n))return!0;return!1}function Ge(e){return e===On||e===Nn}function fe(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==ht||65536<=e&&e<=1114111}function Mt(e){return fe(e)&&e!==ht&&e!==Gn&&e!==ge}function Lt(e,n,t){var r=Mt(e),i=r&&!Ge(e);return(t?r:r&&e!==br&&e!==vr&&e!==xr&&e!==wr&&e!==yr)&&e!==ot&&!(n===Ne&&!i)||Mt(n)&&!Ge(n)&&e===ot||n===Ne&&i}function co(e){return fe(e)&&e!==ht&&!Ge(e)&&e!==Wn&&e!==Xn&&e!==Ne&&e!==br&&e!==vr&&e!==xr&&e!==wr&&e!==yr&&e!==ot&&e!==Un&&e!==Kn&&e!==Vn&&e!==to&&e!==Qn&&e!==Zn&&e!==Yn&&e!==Fn&&e!==jn&&e!==Jn&&e!==eo}function uo(e){return!Ge(e)&&e!==Ne}function pe(e,n){var t=e.charCodeAt(n),r;return t>=55296&&t<=56319&&n+1<e.length&&(r=e.charCodeAt(n+1),r>=56320&&r<=57343)?(t-55296)*1024+r-56320+65536:t}function Cr(e){var n=/^\n* /;return n.test(e)}var Er=1,st=2,kr=3,Sr=4,W=5;function po(e,n,t,r,i,o,a,s){var l,c=0,d=null,u=!1,p=!1,h=r!==-1,g=-1,m=co(pe(e,0))&&uo(pe(e,e.length-1));if(n||a)for(l=0;l<e.length;c>=65536?l+=2:l++){if(c=pe(e,l),!fe(c))return W;m=m&&Lt(c,d,s),d=c}else{for(l=0;l<e.length;c>=65536?l+=2:l++){if(c=pe(e,l),c===ge)u=!0,h&&(p=p||l-g-1>r&&e[g+1]!==" ",g=l);else if(!fe(c))return W;m=m&&Lt(c,d,s),d=c}p=p||h&&l-g-1>r&&e[g+1]!==" "}return!u&&!p?m&&!a&&!i(e)?Er:o===me?W:st:t>9&&Cr(e)?W:a?o===me?W:st:p?Sr:kr}function ho(e,n,t,r,i){e.dump=function(){if(n.length===0)return e.quotingType===me?'""':"''";if(!e.noCompatMode&&(ro.indexOf(n)!==-1||io.test(n)))return e.quotingType===me?'"'+n+'"':"'"+n+"'";var o=e.indent*Math.max(1,t),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),s=r||e.flowLevel>-1&&t>=e.flowLevel;function l(c){return lo(e,c)}switch(po(n,s,e.indent,a,l,e.quotingType,e.forceQuotes&&!r,i)){case Er:return n;case st:return"'"+n.replace(/'/g,"''")+"'";case kr:return"|"+Dt(n,e.indent)+Rt(It(n,o));case Sr:return">"+Dt(n,e.indent)+Rt(It(go(n,a),o));case W:return'"'+mo(n)+'"';default:throw new _("impossible error: invalid scalar style")}}()}function Dt(e,n){var t=Cr(e)?String(n):"",r=e[e.length-1]===`
|
|
22
22
|
`,i=r&&(e[e.length-2]===`
|
|
23
23
|
`||e===`
|
|
24
24
|
`),o=i?"+":r?"":"-";return t+o+`
|
|
25
|
-
`}function
|
|
26
|
-
`?e.slice(0,-1):e}function
|
|
27
|
-
`);return c=c!==-1?c:e.length,t.lastIndex=c,
|
|
25
|
+
`}function Rt(e){return e[e.length-1]===`
|
|
26
|
+
`?e.slice(0,-1):e}function go(e,n){for(var t=/(\n+)([^\n]*)/g,r=function(){var c=e.indexOf(`
|
|
27
|
+
`);return c=c!==-1?c:e.length,t.lastIndex=c,Pt(e.slice(0,c),n)}(),i=e[0]===`
|
|
28
28
|
`||e[0]===" ",o,a;a=t.exec(e);){var s=a[1],l=a[2];o=l[0]===" ",r+=s+(!i&&!o&&l!==""?`
|
|
29
|
-
`:"")+
|
|
29
|
+
`:"")+Pt(l,n),i=o}return r}function Pt(e,n){if(e===""||e[0]===" ")return e;for(var t=/ [^ ]/g,r,i=0,o,a=0,s=0,l="";r=t.exec(e);)s=r.index,s-i>n&&(o=a>i?a:s,l+=`
|
|
30
30
|
`+e.slice(i,o),i=o+1),a=s;return l+=`
|
|
31
31
|
`,e.length-i>n&&a>i?l+=e.slice(i,a)+`
|
|
32
|
-
`+e.slice(a+1):l+=e.slice(i),l.slice(1)}function
|
|
33
|
-
`:""}var
|
|
34
|
-
${n instanceof Error?n.message:String(n)}`)}}function
|
|
35
|
-
- `)}`),this.name="AssetValidationError",this.issues=n}};function
|
|
36
|
-
${
|
|
32
|
+
`+e.slice(a+1):l+=e.slice(i),l.slice(1)}function mo(e){for(var n="",t=0,r,i=0;i<e.length;t>=65536?i+=2:i++)t=pe(e,i),r=A[t],!r&&fe(t)?(n+=e[i],t>=65536&&(n+=e[i+1])):n+=r||oo(t);return n}function fo(e,n,t){var r="",i=e.tag,o,a,s;for(o=0,a=t.length;o<a;o+=1)s=t[o],e.replacer&&(s=e.replacer.call(t,String(o),s)),(z(e,n,s,!1,!1)||typeof s>"u"&&z(e,n,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=i,e.dump="["+r+"]"}function Bt(e,n,t,r){var i="",o=e.tag,a,s,l;for(a=0,s=t.length;a<s;a+=1)l=t[a],e.replacer&&(l=e.replacer.call(t,String(a),l)),(z(e,n+1,l,!0,!0,!1,!0)||typeof l>"u"&&z(e,n+1,null,!0,!0,!1,!0))&&((!r||i!=="")&&(i+=at(e,n)),e.dump&&ge===e.dump.charCodeAt(0)?i+="-":i+="- ",i+=e.dump);e.tag=o,e.dump=i||"[]"}function bo(e,n,t){var r="",i=e.tag,o=Object.keys(t),a,s,l,c,d;for(a=0,s=o.length;a<s;a+=1)d="",r!==""&&(d+=", "),e.condenseFlow&&(d+='"'),l=o[a],c=t[l],e.replacer&&(c=e.replacer.call(t,l,c)),z(e,n,l,!1,!1)&&(e.dump.length>1024&&(d+="? "),d+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),z(e,n,c,!1,!1)&&(d+=e.dump,r+=d));e.tag=i,e.dump="{"+r+"}"}function vo(e,n,t,r){var i="",o=e.tag,a=Object.keys(t),s,l,c,d,u,p;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new _("sortKeys must be a boolean or a function");for(s=0,l=a.length;s<l;s+=1)p="",(!r||i!=="")&&(p+=at(e,n)),c=a[s],d=t[c],e.replacer&&(d=e.replacer.call(t,c,d)),z(e,n+1,c,!0,!0,!0)&&(u=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,u&&(e.dump&&ge===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,u&&(p+=at(e,n)),z(e,n+1,d,!0,u)&&(e.dump&&ge===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,i+=p));e.tag=o,e.dump=i||"{}"}function qt(e,n,t){var r,i,o,a,s,l;for(i=t?e.explicitTypes:e.implicitTypes,o=0,a=i.length;o<a;o+=1)if(s=i[o],(s.instanceOf||s.predicate)&&(!s.instanceOf||typeof n=="object"&&n instanceof s.instanceOf)&&(!s.predicate||s.predicate(n))){if(t?s.multi&&s.representName?e.tag=s.representName(n):e.tag=s.tag:e.tag="?",s.represent){if(l=e.styleMap[s.tag]||s.defaultStyle,mr.call(s.represent)==="[object Function]")r=s.represent(n,l);else if(fr.call(s.represent,l))r=s.represent[l](n,l);else throw new _("!<"+s.tag+'> tag resolver accepts not "'+l+'" style');e.dump=r}return!0}return!1}function z(e,n,t,r,i,o,a){e.tag=null,e.dump=t,qt(e,t,!1)||qt(e,t,!0);var s=mr.call(e.dump),l=r,c;r&&(r=e.flowLevel<0||e.flowLevel>n);var d=s==="[object Object]"||s==="[object Array]",u,p;if(d&&(u=e.duplicates.indexOf(t),p=u!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&n>0)&&(i=!1),p&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(d&&p&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),s==="[object Object]")r&&Object.keys(e.dump).length!==0?(vo(e,n,e.dump,i),p&&(e.dump="&ref_"+u+e.dump)):(bo(e,n,e.dump),p&&(e.dump="&ref_"+u+" "+e.dump));else if(s==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&n>0?Bt(e,n-1,e.dump,i):Bt(e,n,e.dump,i),p&&(e.dump="&ref_"+u+e.dump)):(fo(e,n,e.dump),p&&(e.dump="&ref_"+u+" "+e.dump));else if(s==="[object String]")e.tag!=="?"&&ho(e,e.dump,n,o,l);else{if(s==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new _("unacceptable kind of an object to dump "+s)}e.tag!==null&&e.tag!=="?"&&(c=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?c="!"+c:c.slice(0,18)==="tag:yaml.org,2002:"?c="!!"+c.slice(18):c="!<"+c+">",e.dump=c+" "+e.dump)}return!0}function xo(e,n){var t=[],r=[],i,o;for(lt(e,t,r),i=0,o=r.length;i<o;i+=1)n.duplicates.push(t[r[i]]);n.usedDuplicates=new Array(o)}function lt(e,n,t){var r,i,o;if(e!==null&&typeof e=="object")if(i=n.indexOf(e),i!==-1)t.indexOf(i)===-1&&t.push(i);else if(n.push(e),Array.isArray(e))for(i=0,o=e.length;i<o;i+=1)lt(e[i],n,t);else for(r=Object.keys(e),i=0,o=r.length;i<o;i+=1)lt(e[r[i]],n,t)}function wo(e,n){n=n||{};var t=new so(n);t.noRefs||xo(e,t);var r=e;return t.replacer&&(r=t.replacer.call({"":r},"",r)),z(t,0,r,!0,!0)?t.dump+`
|
|
33
|
+
`:""}var yo=wo,Co={dump:yo};function gt(e,n){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}var Eo=$,ko=Nt,So=Ft,To=Wt,$o=Qt,Ao=dt,_o=gr.load,Io=gr.loadAll,Mo=Co.dump,Lo=_,Do={binary:tr,float:Kt,map:Vt,null:jt,pairs:ir,set:nr,timestamp:Jt,bool:Ut,int:Yt,merge:er,omap:rr,seq:Ot,str:Gt},Ro=gt("safeLoad","load"),Po=gt("safeLoadAll","loadAll"),Bo=gt("safeDump","dump"),Tr={Type:Eo,Schema:ko,FAILSAFE_SCHEMA:So,JSON_SCHEMA:To,CORE_SCHEMA:$o,DEFAULT_SCHEMA:Ao,load:_o,loadAll:Io,dump:Mo,YAMLException:Lo,types:Do,safeLoad:Ro,safeLoadAll:Po,safeDump:Bo};var F=["#10b981","#f59e0b","#06b6d4","#ec4899","#8b5cf6","#3b82f6","#f43f5e","#84cc16","#a855f7","#6366f1"];function S(e){let n=e.length,t;for(;n!==0;)t=Math.floor(Math.random()*n),n--,[e[n],e[t]]=[e[t],e[n]];return e}var P=(e,n=0)=>{let t=3735928559^n,r=1103547991^n;for(let i=0,o;i<e.length;i++)o=e.charCodeAt(i),t=Math.imul(t^o,265443561),r=Math.imul(r^o,159334677);return t=Math.imul(t^r>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2009751&r)+(t>>>0)).toString()};function E(e){return e.replace(/[&<>"']/g,n=>n==="&"?"&":n==="<"?"<":n===">"?">":n==='"'?""":"'")}function qo(e){try{return Tr.load(e)}catch(n){throw new Error(`Invalid YAML assets:
|
|
34
|
+
${n instanceof Error?n.message:String(n)}`)}}function M(e){return typeof e=="string"}function mt(e){return typeof e=="number"}function ft(e){return/^(\d{1,2}:)?\d{1,2}:\d{2}$/.test(e)}function $r(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Ve(e){return typeof e=="object"&&e!==null&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function j(e){return e.split("|").map(n=>n.trim()).filter(Boolean)}var J=e=>[...new Set(e)];var be=class extends Error{constructor(n){super(`Asset validation failed:n- ${n.join(`
|
|
35
|
+
- `)}`),this.name="AssetValidationError",this.issues=n}};function zo(e){let n=[];if(!Ve(e))throw new be(["Top-level assets must be an object/map like { mango: {...}, trend: {...} }"]);let t=e,r={};for(let[o,a]of Object.entries(t)){if(!o||typeof o!="string"){n.push(`Asset key must be a non-empty string (got: ${String(o)})`);continue}if(/^[a-zA-Z0-9._-]+$/.test(o)||n.push(`Asset id "${o}" has invalid chars; use letters/numbers/._-`),!Ve(a)){n.push(`Asset "${o}" must be an object (got: ${$r(a)})`);continue}let s=a,l=s.type,c=!!s.dialog;if(!M(l)){n.push(`Asset "${o}" missing string field "type"`);continue}if(!Ho(l)){n.push(`Asset "${o}" has unsupported type "${l}" (use image|video|audio|html)`);continue}switch(l){case"image":{let d=s.url;M(d)||n.push(`Asset "${o}" (image) missing "url"`);let u=s.size;u!==void 0&&!M(u)&&n.push(`Asset "${o}" (image) field "size" must be a string`),M(d)&&(r[o]={id:o,type:l,dialog:c,url:d,...M(u)?{size:u}:{}});break}case"video":{let d=s.url;M(d)||n.push(`Asset "${o}" (video) missing "url"`);let u=s.span,p;if(u!==void 0)if(!Ve(u))n.push(`Asset "${o}" (video) field "span" must be an object`);else{let h=u.from,g=u.to;!M(h)||!M(g)?n.push(`Asset "${o}" (video) span requires string "from" and "to"`):((!ft(h)||!ft(g))&&n.push(`Asset "${o}" (video) span times should look like "02:15" or "01:02:45"`),p={from:h,to:g})}M(d)&&(r[o]={id:o,type:l,dialog:c,url:d,...p?{span:p}:{}});break}case"audio":{let d=s.url;M(d)||n.push(`Asset "${o}" (audio) missing "url"`);let u=s.volume;u!==void 0&&(!mt(u)||!Number.isFinite(u)?n.push(`Asset "${o}" (audio) field "volume" must be a number`):(u<0||u>100)&&n.push(`Asset "${o}" (audio) field "volume" must be between 0 and 100`)),M(d)&&(r[o]={id:o,type:l,dialog:c,url:d,...mt(u)?{volume:u}:{}});break}case"html":{let d=s.content;if(!M(d)){n.push(`Asset "${o}" (html) missing string field "content"`);break}r[o]={id:o,type:l,dialog:c,content:d};break}case"tts":{let d=s.content;if(!M(d)){n.push(`Asset "${o}" (tts) missing string field "content"`);break}r[o]={id:o,type:l,dialog:c,content:d};break}}}if(n.length)throw new be(n);let i=Object.keys(r).sort((o,a)=>o.localeCompare(a)).map(o=>r[o]);return{assetsById:r,assetsList:i}}function Ho(e){return e==="image"||e==="video"||e==="audio"||e==="html"}var Fe={"default-light":{"--edu-bg":"247 249 252","--edu-card":"255 255 255","--edu-ink":"31 41 55","--edu-second-ink":"71 85 105","--edu-third-ink":"100 116 139","--edu-inverted-ink":"248 250 252","--edu-success":"22 163 74","--edu-error":"220 38 38","--edu-warning":"255 222 33","--edu-neutral":"14 165 233","--edu-first-accent":"49 120 198","--edu-second-accent":"245 158 11","--edu-third-accent":"236 72 153","--edu-border":"229 231 235","--edu-muted":"243 244 246","--edu-radius":"0.375rem","--edu-shadow-color":"0 0 0","--edu-pad":"1rem","--edu-mar":"0"},"default-dark":{"--edu-bg":"15 23 42","--edu-card":"30 41 59","--edu-ink":"241 245 249","--edu-second-ink":"203 213 225","--edu-third-ink":"148 163 184","--edu-inverted-ink":"15 23 42","--edu-success":"74 222 128","--edu-error":"248 113 113","--edu-warning":"250 204 21","--edu-neutral":"56 189 248","--edu-first-accent":"96 165 250","--edu-second-accent":"251 191 36","--edu-third-accent":"244 114 182","--edu-border":"71 85 105","--edu-muted":"51 65 85","--edu-radius":"0.375rem","--edu-shadow-color":"2 6 23","--edu-pad":"1rem","--edu-mar":"0"},"ocean-light":{"--edu-bg":"239 246 255","--edu-card":"255 255 255","--edu-ink":"8 47 73","--edu-second-ink":"14 116 144","--edu-third-ink":"8 145 178","--edu-inverted-ink":"239 246 255","--edu-success":"5 150 105","--edu-error":"225 29 72","--edu-warning":"245 158 11","--edu-neutral":"2 132 199","--edu-first-accent":"6 182 212","--edu-second-accent":"59 130 246","--edu-third-accent":"14 165 233","--edu-border":"186 230 253","--edu-muted":"224 242 254","--edu-radius":"0.5rem","--edu-shadow-color":"8 47 73","--edu-pad":"1rem","--edu-mar":"0"},"ocean-dark":{"--edu-bg":"8 47 73","--edu-card":"12 74 110","--edu-ink":"236 254 255","--edu-second-ink":"165 243 252","--edu-third-ink":"103 232 249","--edu-inverted-ink":"8 47 73","--edu-success":"52 211 153","--edu-error":"251 113 133","--edu-warning":"251 191 36","--edu-neutral":"34 211 238","--edu-first-accent":"103 232 249","--edu-second-accent":"56 189 248","--edu-third-accent":"45 212 191","--edu-border":"14 116 144","--edu-muted":"14 116 144","--edu-radius":"0.5rem","--edu-shadow-color":"8 47 73","--edu-pad":"1rem","--edu-mar":"0"},"forest-light":{"--edu-bg":"240 253 244","--edu-card":"255 255 255","--edu-ink":"20 83 45","--edu-second-ink":"22 101 52","--edu-third-ink":"74 124 89","--edu-inverted-ink":"240 253 244","--edu-success":"22 163 74","--edu-error":"220 38 38","--edu-warning":"234 179 8","--edu-neutral":"34 197 94","--edu-first-accent":"34 197 94","--edu-second-accent":"132 204 22","--edu-third-accent":"16 185 129","--edu-border":"187 247 208","--edu-muted":"220 252 231","--edu-radius":"0.5rem","--edu-shadow-color":"20 83 45","--edu-pad":"1rem","--edu-mar":"0"},"forest-dark":{"--edu-bg":"20 83 45","--edu-card":"22 101 52","--edu-ink":"240 253 244","--edu-second-ink":"187 247 208","--edu-third-ink":"134 239 172","--edu-inverted-ink":"20 83 45","--edu-success":"74 222 128","--edu-error":"248 113 113","--edu-warning":"250 204 21","--edu-neutral":"74 222 128","--edu-first-accent":"134 239 172","--edu-second-accent":"190 242 100","--edu-third-accent":"52 211 153","--edu-border":"34 197 94","--edu-muted":"21 128 61","--edu-radius":"0.5rem","--edu-shadow-color":"20 83 45","--edu-pad":"1rem","--edu-mar":"0"}},bt=Fe["default-light"],y={audioBaseUrl:null,soundFiles:{},injectThemeVariables:!0,theme:null,themeVariables:{}},Ar="cognikit-theme-variables";function No(e){e.audioBaseUrl!==void 0&&(y.audioBaseUrl=e.audioBaseUrl),e.soundFiles&&(y.soundFiles={...y.soundFiles,...e.soundFiles}),e.injectThemeVariables!==void 0&&(y.injectThemeVariables=e.injectThemeVariables),e.theme!==void 0&&(y.theme=e.theme),e.themeVariables===null&&(y.themeVariables={}),e.themeVariables&&(y.themeVariables={...y.themeVariables,...e.themeVariables}),je()}function Go(){return y}function Oo(){return Fe}function Mr(e=y.theme,n=y.themeVariables){return{...e?Fe[e]:bt,...n}}function Vo(e,n){y.theme=e,n!==void 0&&(y.themeVariables={...n}),je()}function Fo(){y.theme=null,y.themeVariables={},je()}function je(){if(typeof document>"u")return;let e=document.getElementById(Ar);if(e||(e=document.createElement("style"),e.id=Ar,document.head.appendChild(e)),!y.injectThemeVariables){e.textContent="";return}let n=document.documentElement,t=window.getComputedStyle(n),r=Mr();if(y.theme!==null||Object.keys(y.themeVariables).length>0){e.textContent=Ir(r);return}let o=Object.entries(bt).filter(([a])=>t.getPropertyValue(a).trim()==="");e.textContent=o.length===0?"":Ir(Object.fromEntries(o))}function Lr(e,n){let t=y.soundFiles[e];return t?_r(t,y.audioBaseUrl):y.audioBaseUrl?_r(n,y.audioBaseUrl):null}function _r(e,n){return Uo(e)||e.startsWith("data:")?e:n?new URL(e,jo(n)).href:e}function jo(e){return typeof window>"u"?e:new URL(e,document.baseURI||window.location.href).href}function Uo(e){return/^https?:\/\//.test(e)}function Ir(e){return`:root {
|
|
36
|
+
${Object.entries(e).map(([n,t])=>` ${n}: ${t};`).join(`
|
|
37
37
|
`)}
|
|
38
|
-
}`}
|
|
38
|
+
}`}var U=new Map,T=e=>{let n=U.get(e.id);if(n){if(n.ctor===e.ctor)return;throw new Error(`Duplicate interaction id: "${e.id}"`)}U.set(e.id,e)},Ia=e=>U.delete(e),Ma=()=>{U.clear()},La=()=>U,Da=()=>Array.from(U.values()),Yo=e=>U.get(e)??null,Ra=(e,...n)=>{let t=Yo(e);if(!t)throw new Error(`Unknown interaction "${e}"`);return new t.ctor(...n)};var Ue=class{constructor(){this._current=0;this._total=0}initialize(n){if(n<0)throw new Error("Total must be non-negative");this._total=n,this._current=0}setCurrent(n){n<0?this._current=0:n>this._total?this._current=this._total:this._current=n}increment(){this._current<this._total&&this._current++}decrement(){this._current>0&&this._current--}reset(){this._current=0}getPercentage(){return this._total===0?0:Math.round(this._current/this._total*100)}isComplete(){return this._current===this._total&&this._total>0}get current(){return this._current}get total(){return this._total}get remaining(){return Math.max(0,this._total-this._current)}};var Ko=`
|
|
39
39
|
@keyframes shake {
|
|
40
40
|
0%, 100% { transform: translateX(0); }
|
|
41
41
|
25% { transform: translateX(-8px); }
|
|
@@ -127,8 +127,8 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
127
127
|
50% { transform: rotate(180deg) translateX(50px) rotate(-180deg) scale(1.5); }
|
|
128
128
|
100% { transform: rotate(360deg) translateX(0) rotate(-360deg); }
|
|
129
129
|
}
|
|
130
|
-
`,
|
|
131
|
-
${s}: ${l}`}))}this.progressTracker=new
|
|
130
|
+
`,Dr={shake:"0.4s","pulse-green":"2s infinite","bounce-in":"0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55)",float:"3s ease-in-out infinite",rubber:"0.6s",jello:"0.8s",heartbeat:"1.5s ease-in-out infinite",shimmer:"2s infinite",wobble:"4s infinite",pop:"0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)","fade-slide":"0.5s ease-out",swing:"2s infinite",flash:"0.5s",orbit:"1s ease-in-out","spin-pulse":"3s cubic-bezier(0.175, 0.885, 0.32, 1.275) infinite"},L=class{constructor(){this.isEnabled=!1}static{this.injectedRoots=new WeakSet}static injectKeyframes(n){if(this.injectedRoots.has(n))return;let t=document.createElement("style");t.textContent=Ko,n.prepend(t),this.injectedRoots.add(n)}animate(n,t,r){if(!this.isEnabled)return;n.style.animation="";let i=r?.duration||"",o=r?.timing||"",a=r?.iterations||"",s=r?.delay||"",l="";i||o||a||s?l=`${t} ${i} ${o} ${s} ${a}`.trim():l=`${t} ${Dr[t]}`,n.style.animation=l}stop(n){n.style.animation=""}animateFor(n,t,r,i){this.isEnabled&&(this.animate(n,t,i),setTimeout(()=>{this.stop(n)},r))}getAvailableAnimations(){return Object.keys(Dr)}addAnimationClass(n,t){this.isEnabled&&n.classList.add(`anim-${t}`)}removeAnimationClass(n,t){n.classList.remove(`anim-${t}`)}};var G=class{constructor(){this.isEnabled=!0;this.audioCache=new Map;this.activeSounds=new Set;this.localSounds={success:"success.mp3",failure:"failure.mp3",pop:"pop.mp3","low-time":"low-time.mp3",start:"start.mp3",flip:"flip.mp3"}}async playSound(n,t={}){if(this.isEnabled)try{let r=this.resolveUrl(n),i=await this.getAudio(r);this.configureAudio(i,t),await this.playAudio(i,t)}catch(r){let i=r instanceof Error?r:new Error(String(r));console.warn(`[SoundManager] Failed to play sound "${n}":`,i.message),t.onError&&t.onError(i)}}async preload(n){let t=n.map(async r=>{try{let i=this.resolveUrl(r);await this.getAudio(i)}catch(i){console.warn(`[SoundManager] Failed to preload sound "${r}":`,i)}});await Promise.allSettled(t)}stopAll(){this.activeSounds.forEach(n=>{n.pause(),n.currentTime=0}),this.activeSounds.clear()}stop(n){let t=this.resolveUrl(n),r=this.audioCache.get(t);r&&(r.pause(),r.currentTime=0,this.activeSounds.delete(r))}clearCache(){this.stopAll(),this.audioCache.clear()}setGlobalVolume(n){let t=Math.max(0,Math.min(1,n));this.activeSounds.forEach(r=>{r.volume=t})}resolveUrl(n){if(n in this.localSounds){let t=this.localSounds[n],r=Lr(n,t);if(!r)throw new Error(`No configured URL for sound "${n}"`);return r}return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:"),n}async getAudio(n){if(this.audioCache.has(n))return this.audioCache.get(n).cloneNode(!0);let t=new Audio,r=new Promise((i,o)=>{let a=setTimeout(()=>{o(new Error("Audio loading timeout"))},1e4);t.addEventListener("canplaythrough",()=>{clearTimeout(a),i()},{once:!0}),t.addEventListener("error",()=>{clearTimeout(a),o(new Error(`Failed to load audio: ${n}`))},{once:!0})});return t.src=n,t.preload="auto",t.load(),await r,this.audioCache.set(n,t),t.cloneNode(!0)}configureAudio(n,t){n.volume=t.volume!==void 0?Math.max(0,Math.min(1,t.volume)):1,n.loop=t.loop??!1,n.playbackRate=t.playbackRate??1,t.fadeIn&&t.fadeIn>0&&(n.volume=0,this.fadeVolume(n,t.volume??1,t.fadeIn))}async playAudio(n,t){this.activeSounds.add(n);let r=()=>{this.activeSounds.delete(n),t.onEnd&&t.onEnd()};n.addEventListener("ended",r,{once:!0}),t.fadeOut&&t.fadeOut>0&&!t.loop&&n.addEventListener("timeupdate",()=>{n.duration-n.currentTime<=t.fadeOut/1e3&&this.fadeVolume(n,0,t.fadeOut)});try{await n.play()}catch(i){throw this.activeSounds.delete(n),new Error(`Playback failed: ${i instanceof Error?i.message:String(i)}`)}}fadeVolume(n,t,r){let i=n.volume,o=t-i,a=Date.now(),s=()=>{let l=Date.now()-a,c=Math.min(l/r,1);n.volume=i+o*c,c<1&&this.activeSounds.has(n)&&requestAnimationFrame(s)};requestAnimationFrame(s)}},Ye=new G;var x=class extends HTMLElement{constructor(t,r,i,o){super();this.isValid=!0;this.implementsProgress=!0;this._initialized=!1;this.errors="";if(!t||!r){console.warn("[BaseInteraction] Constructor called without required parameters"),this.id=crypto.randomUUID(),this.data=t,this.config=r||{},this.assets=i||null,this.isValid=!1;return}if(this.id=crypto.randomUUID(),this.data=t,this.config=r,this.assets=i||null,o){let a=o(this.data);a.ok||(this.isValid=!1,Object.entries(a.errors).forEach(([s,l])=>{this.errors=`${this.errors}
|
|
131
|
+
${s}: ${l}`}))}this.progressTracker=new Ue,this.soundManager=new G,this.animationsManager=new L,this.animationsManager.isEnabled=this.config?.animationsEnabled??!0,this.soundManager.isEnabled=this.config?.soundEnabled??!0,this.setAttribute("variant",this.config?.variant??"elegant")}connectedCallback(){if(!this._initialized){if(this._initialized=!0,!this.isValid)return;this.initialize(),requestAnimationFrame(()=>{this.render(),this.emitReady()})}}disconnectedCallback(){this.cleanup()}initialize(){}cleanup(){}initializeProgress(t){this.progressTracker.initialize(t),this.emitProgress()}setProgress(t){this.progressTracker.setCurrent(t),this.emitProgress()}incrementProgress(){this.progressTracker.increment(),this.emitProgress()}decrementProgress(){this.progressTracker.decrement(),this.emitProgress()}getProgress(){return{current:this.progressTracker.current,total:this.progressTracker.total,percentage:this.progressTracker.getPercentage()}}emitReady(){this.dispatchEvent(new CustomEvent("interaction:ready",{detail:{id:this.id},bubbles:!0,composed:!0}))}emitProgress(){let t=this.getProgress();this.dispatchEvent(new CustomEvent("interaction:progress",{detail:t,bubbles:!0,composed:!0}))}emitStateChange(){this.dispatchEvent(new CustomEvent("interaction:state-change",{detail:{state:this.getCurrentState(),isComplete:this.isInteractionComplete()},bubbles:!0,composed:!0}))}emitComplete(){this.dispatchEvent(new CustomEvent("interaction:complete",{detail:{state:this.getCurrentState(),id:this.id},bubbles:!0,composed:!0}))}emitHintShown(t){this.dispatchEvent(new CustomEvent("interaction:hint-shown",{detail:{message:t},bubbles:!0,composed:!0}))}emitError(t,r){this.dispatchEvent(new CustomEvent("interaction:error",{detail:{error:t,message:r||t.message},bubbles:!0,composed:!0}))}onChange(t){}setSteps(t){}submit(){this.setAttribute("inert",""),this.emitComplete()}hint(){this.onHint()}reset(){this.progressTracker.reset(),this.emitProgress(),this.removeAttribute("inert"),this.render()}set(t){this.config.variant=t,this.setAttribute("variant",t),this.onVariantChange(t)}get(){return this.getAttribute("variant")||this.config.variant||"outline"}};var Rr=`<div class="chip-container" part="container">
|
|
132
132
|
|
|
133
133
|
<div class="content-zone" part="content-zone" role="button" tabindex="0" aria-pressed="false">
|
|
134
134
|
<span class="prefix" part="prefix"></span>
|
|
@@ -155,12 +155,13 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
155
155
|
</div>
|
|
156
156
|
</div>
|
|
157
157
|
|
|
158
|
-
`;var
|
|
158
|
+
`;var Pr=`/* ==================== BASE STYLES ==================== */
|
|
159
159
|
|
|
160
160
|
* { box-sizing: border-box; }
|
|
161
161
|
|
|
162
162
|
:host {
|
|
163
163
|
display: inline-block;
|
|
164
|
+
container-type: size;
|
|
164
165
|
--chip-color: rgb(var(--edu-first-accent));
|
|
165
166
|
--chip-colored-color: #d1d1d1;
|
|
166
167
|
}
|
|
@@ -168,20 +169,36 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
168
169
|
:host([colored]) {
|
|
169
170
|
& .chip-container { position: relative; }
|
|
170
171
|
|
|
172
|
+
& .content-zone {
|
|
173
|
+
border-color: color-mix(in srgb, var(--chip-colored-color) 55%, rgb(var(--edu-border)));
|
|
174
|
+
background:
|
|
175
|
+
linear-gradient(
|
|
176
|
+
180deg,
|
|
177
|
+
color-mix(in srgb, var(--chip-colored-color) 18%, rgb(var(--edu-card))) 0%,
|
|
178
|
+
rgb(var(--edu-card)) 44%
|
|
179
|
+
);
|
|
180
|
+
box-shadow:
|
|
181
|
+
inset 0 4px 0 color-mix(in srgb, var(--chip-colored-color) 85%, white 15%),
|
|
182
|
+
0 0 0 1px color-mix(in srgb, var(--chip-colored-color) 22%, transparent);
|
|
183
|
+
}
|
|
184
|
+
|
|
171
185
|
& .chip-container::after {
|
|
172
186
|
content: '';
|
|
173
187
|
position: absolute;
|
|
174
|
-
top:
|
|
175
|
-
left:
|
|
176
|
-
right:
|
|
177
|
-
|
|
188
|
+
top: 0.25rem;
|
|
189
|
+
left: 0.25rem;
|
|
190
|
+
right: 0.25rem;
|
|
191
|
+
height: 0.4rem;
|
|
178
192
|
border-radius: 10px;
|
|
179
|
-
background: var(--chip-colored-color);
|
|
180
|
-
opacity: 0.
|
|
181
|
-
mix-blend-mode: multiply;
|
|
193
|
+
background: color-mix(in srgb, var(--chip-colored-color) 90%, white 10%);
|
|
194
|
+
opacity: 0.95;
|
|
182
195
|
z-index: 2;
|
|
183
196
|
pointer-events: none;
|
|
184
197
|
}
|
|
198
|
+
|
|
199
|
+
& .prefix {
|
|
200
|
+
color: color-mix(in srgb, var(--chip-colored-color) 82%, rgb(var(--edu-ink)));
|
|
201
|
+
}
|
|
185
202
|
}
|
|
186
203
|
|
|
187
204
|
:host([aria-disabled]) {
|
|
@@ -194,7 +211,8 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
194
211
|
flex-direction: column;
|
|
195
212
|
align-items: center;
|
|
196
213
|
position: relative;
|
|
197
|
-
width: 100%;
|
|
214
|
+
width: 100%;
|
|
215
|
+
height: 100%;
|
|
198
216
|
}
|
|
199
217
|
|
|
200
218
|
::slotted(img.chip-image) {
|
|
@@ -228,8 +246,9 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
228
246
|
border: 1px solid rgb(var(--edu-border));
|
|
229
247
|
padding: 0.5rem 1rem;
|
|
230
248
|
cursor: pointer;
|
|
231
|
-
font-size:
|
|
249
|
+
font-size: clamp(0.95rem, min(12cqi, 24cqb), 2.35rem);
|
|
232
250
|
font-weight: 500;
|
|
251
|
+
line-height: 1.2;
|
|
233
252
|
text-align: center;
|
|
234
253
|
transition: all 0.2s ease;
|
|
235
254
|
user-select: none;
|
|
@@ -267,6 +286,7 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
267
286
|
align-items: center;
|
|
268
287
|
justify-content: center;
|
|
269
288
|
min-width: 0;
|
|
289
|
+
overflow-wrap: anywhere;
|
|
270
290
|
}
|
|
271
291
|
|
|
272
292
|
/* ==================== MODALITY ACTION BUTTON ==================== */
|
|
@@ -454,38 +474,45 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
454
474
|
/* ==================== VARIANT: PLAYFUL ==================== */
|
|
455
475
|
|
|
456
476
|
:host([variant="playful"]) .content-zone {
|
|
457
|
-
background:
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
border:
|
|
461
|
-
|
|
477
|
+
background:
|
|
478
|
+
linear-gradient(135deg, rgb(var(--edu-card)), rgb(var(--edu-muted) / 0.9));
|
|
479
|
+
color: rgb(var(--edu-ink));
|
|
480
|
+
border-radius: 14px;
|
|
481
|
+
border: 2px solid rgb(var(--edu-border));
|
|
482
|
+
box-shadow: 0 6px 14px rgb(var(--edu-shadow-color) / 0.12);
|
|
462
483
|
font-weight: 600;
|
|
463
484
|
}
|
|
464
485
|
|
|
465
486
|
:host([variant="playful"]) .content-zone:hover:not([aria-disabled="true"]) {
|
|
466
|
-
|
|
487
|
+
transform: translateY(-2px) rotate(-1deg);
|
|
488
|
+
border-color: rgb(var(--edu-first-accent) / 0.5);
|
|
489
|
+
box-shadow: 0 10px 22px rgb(var(--edu-shadow-color) / 0.18);
|
|
467
490
|
}
|
|
468
491
|
|
|
469
492
|
:host([variant="playful"]) .content-zone:active:not([aria-disabled="true"]) {
|
|
493
|
+
transform: translateY(0) rotate(0deg);
|
|
470
494
|
}
|
|
471
495
|
|
|
472
496
|
:host([variant="playful"]) .prefix {
|
|
473
|
-
color:
|
|
474
|
-
opacity:
|
|
497
|
+
color: var(--chip-color);
|
|
498
|
+
opacity: 1;
|
|
475
499
|
}
|
|
476
500
|
|
|
477
501
|
:host([variant="playful"]) .modality-action {
|
|
478
|
-
background:
|
|
479
|
-
color: var(--
|
|
502
|
+
background: var(--chip-color);
|
|
503
|
+
color: rgb(var(--edu-inverted-ink));
|
|
480
504
|
}
|
|
481
505
|
|
|
482
506
|
:host([variant="playful"][selected]) .content-zone {
|
|
483
|
-
|
|
507
|
+
background:
|
|
508
|
+
linear-gradient(135deg, rgb(var(--edu-card)), rgb(var(--edu-muted)));
|
|
509
|
+
border-color: var(--chip-color);
|
|
510
|
+
box-shadow: 0 0 0 3px rgb(var(--chip-color) / 0.22), 0 10px 22px rgb(var(--edu-shadow-color) / 0.16);
|
|
484
511
|
}
|
|
485
512
|
|
|
486
513
|
:host([variant="playful"]) ::slotted(img.chip-image) {
|
|
487
|
-
border:
|
|
488
|
-
border-radius:
|
|
514
|
+
border: 3px solid rgb(var(--edu-border) / 0.6);
|
|
515
|
+
border-radius: 8px;
|
|
489
516
|
}
|
|
490
517
|
|
|
491
518
|
|
|
@@ -550,7 +577,6 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
550
577
|
border-radius: 2px;
|
|
551
578
|
background: rgb(var(--edu-card));
|
|
552
579
|
color: rgb(var(--edu-ink));
|
|
553
|
-
font-size: 0.95rem;
|
|
554
580
|
letter-spacing: 0.5px;
|
|
555
581
|
}
|
|
556
582
|
|
|
@@ -578,82 +604,88 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
578
604
|
/* ==================== VARIANT: MINIMAL ==================== */
|
|
579
605
|
|
|
580
606
|
:host([variant="minimal"]) .content-zone {
|
|
581
|
-
background:
|
|
607
|
+
background: transparent;
|
|
582
608
|
border: 1px solid rgb(var(--edu-border));
|
|
583
|
-
border-radius:
|
|
584
|
-
color: rgb(var(--edu-ink));
|
|
585
|
-
padding: 0.
|
|
586
|
-
font-size: 0.9rem;
|
|
609
|
+
border-radius: 10px;
|
|
610
|
+
color: rgb(var(--edu-second-ink));
|
|
611
|
+
padding: 0.45rem 0.85rem;
|
|
587
612
|
}
|
|
588
613
|
|
|
589
614
|
:host([variant="minimal"]) .content-zone:hover:not([aria-disabled="true"]) {
|
|
590
|
-
|
|
591
|
-
|
|
615
|
+
background: rgb(var(--edu-card) / 0.8);
|
|
616
|
+
color: rgb(var(--edu-ink));
|
|
617
|
+
border-color: rgb(var(--edu-first-accent) / 0.35);
|
|
618
|
+
box-shadow: 0 4px 12px rgba(var(--edu-shadow-color), 0.08);
|
|
592
619
|
}
|
|
593
620
|
|
|
594
621
|
:host([variant="minimal"][selected]) .content-zone {
|
|
595
622
|
border-color: var(--chip-color);
|
|
596
623
|
background: rgba(var(--chip-color), 0.08);
|
|
624
|
+
color: rgb(var(--edu-ink));
|
|
597
625
|
}
|
|
598
626
|
|
|
599
627
|
/* ==================== VARIANT: GLASS ==================== */
|
|
600
628
|
|
|
601
629
|
:host([variant="glass"]) .content-zone {
|
|
602
|
-
background: rgb(var(--edu-card));
|
|
603
|
-
|
|
604
|
-
border
|
|
630
|
+
background: rgb(var(--edu-card) / 0.65);
|
|
631
|
+
backdrop-filter: blur(10px);
|
|
632
|
+
border: 1px solid rgb(var(--edu-border) / 0.6);
|
|
633
|
+
border-radius: 14px;
|
|
605
634
|
color: rgb(var(--edu-ink));
|
|
606
|
-
padding: 0.5rem
|
|
607
|
-
font-weight:
|
|
608
|
-
letter-spacing:
|
|
609
|
-
|
|
635
|
+
padding: 0.5rem 1rem;
|
|
636
|
+
font-weight: 600;
|
|
637
|
+
letter-spacing: 0.03em;
|
|
638
|
+
box-shadow: inset 0 1px 0 rgb(var(--edu-card) / 0.8), 0 8px 20px rgb(var(--edu-shadow-color) / 0.12);
|
|
610
639
|
}
|
|
611
640
|
|
|
612
641
|
:host([variant="glass"]) .content-zone:hover:not([aria-disabled="true"]) {
|
|
613
|
-
background: var(--
|
|
614
|
-
color: rgb(var(--edu-
|
|
615
|
-
|
|
642
|
+
background: rgb(var(--edu-card) / 0.78);
|
|
643
|
+
border-color: rgb(var(--edu-first-accent) / 0.45);
|
|
644
|
+
box-shadow: inset 0 1px 0 rgb(var(--edu-card) / 0.9), 0 12px 24px rgb(var(--edu-shadow-color) / 0.16);
|
|
616
645
|
}
|
|
617
646
|
|
|
618
647
|
:host([variant="glass"]) .content-zone:active:not([aria-disabled="true"]) {
|
|
619
|
-
background:
|
|
648
|
+
background: rgb(var(--edu-card) / 0.88);
|
|
620
649
|
}
|
|
621
650
|
|
|
622
651
|
:host([variant="glass"]) .prefix {
|
|
623
|
-
font-weight:
|
|
652
|
+
font-weight: 700;
|
|
653
|
+
color: rgb(var(--edu-first-accent));
|
|
624
654
|
}
|
|
625
655
|
|
|
626
656
|
:host([variant="glass"][selected]) .content-zone {
|
|
627
657
|
background: rgba(var(--chip-color), 0.15);
|
|
628
658
|
border-color: var(--chip-color);
|
|
629
|
-
box-shadow: 0 0 0 2px rgba(var(--chip-color), 0.
|
|
659
|
+
box-shadow: 0 0 0 2px rgba(var(--chip-color), 0.24), inset 0 1px 0 rgb(var(--edu-card) / 0.85);
|
|
630
660
|
}
|
|
631
661
|
|
|
632
662
|
/* ==================== VARIANT: CARD ==================== */
|
|
633
663
|
|
|
634
664
|
:host([variant="card"]) .content-zone {
|
|
635
|
-
background:
|
|
636
|
-
border:
|
|
637
|
-
border-radius:
|
|
665
|
+
background: rgb(var(--edu-card));
|
|
666
|
+
border: 1px solid rgb(var(--edu-border));
|
|
667
|
+
border-radius: 12px;
|
|
638
668
|
color: rgb(var(--edu-ink));
|
|
669
|
+
box-shadow: 0 8px 18px rgb(var(--edu-shadow-color) / 0.1);
|
|
639
670
|
}
|
|
640
671
|
|
|
641
672
|
:host([variant="card"]) .content-zone:hover:not([aria-disabled="true"]) {
|
|
642
|
-
background: rgb(var(--edu-muted));
|
|
643
|
-
border-color: var(--
|
|
673
|
+
background: linear-gradient(180deg, rgb(var(--edu-card)), rgb(var(--edu-muted) / 0.8));
|
|
674
|
+
border-color: rgb(var(--edu-first-accent) / 0.35);
|
|
675
|
+
box-shadow: 0 12px 24px rgb(var(--edu-shadow-color) / 0.14);
|
|
644
676
|
}
|
|
645
677
|
|
|
646
678
|
:host([variant="card"]) .content-zone:active:not([aria-disabled="true"]) {
|
|
647
|
-
|
|
679
|
+
transform: translateY(1px);
|
|
648
680
|
}
|
|
649
681
|
|
|
650
682
|
:host([variant="card"]) .prefix {
|
|
651
|
-
color: var(--
|
|
683
|
+
color: rgb(var(--edu-third-ink));
|
|
652
684
|
}
|
|
653
685
|
|
|
654
686
|
:host([variant="card"][selected]) .content-zone {
|
|
655
687
|
border-color: var(--chip-color);
|
|
656
|
-
box-shadow: 0 0 0 3px rgba(var(--chip-color), 0.
|
|
688
|
+
box-shadow: 0 0 0 3px rgba(var(--chip-color), 0.18), 0 12px 24px rgb(var(--edu-shadow-color) / 0.12);
|
|
657
689
|
}
|
|
658
690
|
|
|
659
691
|
/* ==================== VARIANT: SIGN ==================== */
|
|
@@ -663,9 +695,8 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
663
695
|
border-radius: 0;
|
|
664
696
|
color: rgb(var(--edu-ink));
|
|
665
697
|
padding: 0.5rem 1.2rem;
|
|
666
|
-
font-size: 0.9rem;
|
|
667
698
|
font-weight: bold;
|
|
668
|
-
transform: skewX(-
|
|
699
|
+
transform: skewX(-3deg);
|
|
669
700
|
text-transform: uppercase;
|
|
670
701
|
letter-spacing: 0.2rem;
|
|
671
702
|
}
|
|
@@ -698,7 +729,7 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
698
729
|
:host([variant="sign"]) ::slotted(img.chip-image) {
|
|
699
730
|
transform: skewX(-10deg);
|
|
700
731
|
}
|
|
701
|
-
`;var
|
|
732
|
+
`;var Zo=`
|
|
702
733
|
<style>
|
|
703
734
|
:host {
|
|
704
735
|
display: none;
|
|
@@ -878,7 +909,7 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
878
909
|
<slot name="footer"></slot>
|
|
879
910
|
</div>
|
|
880
911
|
</div>
|
|
881
|
-
`,ve=class extends HTMLElement{constructor(){super();this.handleEscape=t=>{t.key==="Escape"&&this.hasAttribute("open")&&this.close()};this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=
|
|
912
|
+
`,ve=class extends HTMLElement{constructor(){super();this.handleEscape=t=>{t.key==="Escape"&&this.hasAttribute("open")&&this.close()};this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=Zo,this.$backdrop=this.shadowRoot.querySelector(".backdrop"),this.$dialog=this.shadowRoot.querySelector(".dialog"),this.$title=this.shadowRoot.querySelector("#title"),this.$content=this.shadowRoot.querySelector(".content"),this.$footer=this.shadowRoot.querySelector(".footer"),this.$closeBtn=this.shadowRoot.querySelector(".close-btn")}static get observedAttributes(){return["open","title"]}connectedCallback(){this.$backdrop.addEventListener("click",()=>this.close()),this.$closeBtn.addEventListener("click",()=>this.close()),document.addEventListener("keydown",this.handleEscape);let t=this.shadowRoot.querySelector('slot[name="footer"]');t.addEventListener("slotchange",()=>{let r=t.assignedNodes().length>0;this.$footer.style.display=r?"flex":"none"})}disconnectedCallback(){document.removeEventListener("keydown",this.handleEscape)}attributeChangedCallback(t,r,i){t==="title"?this.$title.textContent=i||"":t==="open"&&i!==r&&(this.hasAttribute("open")?document.body.style.overflow="hidden":document.body.style.overflow="")}open(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("dialog:open",{bubbles:!0,composed:!0}))}close(){this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("dialog:close",{bubbles:!0,composed:!0}))}setContent(t){this.$content.innerHTML=t}get isOpen(){return this.hasAttribute("open")}get title(){return this.getAttribute("title")||""}set title(t){this.setAttribute("title",t)}};customElements.get("edu-dialog")||customElements.define("edu-dialog",ve);function D(e,n,t){if(!t||!e.startsWith("@:")||e.length<3){n.textContent=e;return}let r=e.slice(2,e.length);if(!t[r]){n.textContent=r;return}let i=t[r],o=i.type;switch(n.modality=o,o){case"image":n.data=i.url;break;case"video":break;case"audio":break;case"html":n.data=i.content;break}}var vt=class extends HTMLElement{static get observedAttributes(){return["accent","variant","selected","prefix","disabled","modality","state","display","color","colored","draggable"]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=Rr;let n=document.createElement("style");n.textContent=Pr,this.shadowRoot.append(n),this.$prefix=this.shadowRoot.querySelector(".prefix"),this.$chip=this.shadowRoot.querySelector(".content-zone"),this.$dragHandler=this.shadowRoot.querySelector(".drag-handle"),this.$dialog=new ve,L.injectKeyframes(this.shadowRoot)}connectedCallback(){this.hasAttribute("variant")||(this.variant="outline"),this.sync()}attributeChangedCallback(){this.sync()}getButton(){return this.$chip}getPrefix(){return this.$prefix}getDragHandler(){return this.$dragHandler}sync(){this.hasAttribute("prefix")&&(this.$prefix.textContent=this.prefix??""),this.hasAttribute("draggable")&&(this.style.userSelect="none",this.style.touchAction="none");let n=this.selected?"true":"false";this.$chip.setAttribute("aria-pressed",n)}updateContent(){if(!this.hasAttribute("data")||!this.hasAttribute("modality"))return;let n=this.getAttribute("modality"),t=this.getAttribute("data");switch(n){case"image":this.innerHTML=`<img src="${t}" alt="no image" class="chip-image" width="64" height="64"/>`;break;case"audio":break;case"video":break;case"html":this.innerHTML=t}}get variant(){return this.getAttribute("variant")??"outline"}set variant(n){this.setAttribute("variant",n)}get prefix(){return this.getAttribute("prefix")}set prefix(n){n==null||n===""?this.removeAttribute("prefix"):this.setAttribute("prefix",String(n))}get chipState(){return this.getAttribute("state")}set chipState(n){n==null?this.removeAttribute("state"):this.setAttribute("state",String(n))}get draggable(){return this.hasAttribute("draggable")}set draggable(n){n==null||n===!1?this.removeAttribute("draggable"):this.setAttribute("draggable","true")}get color(){return this.getAttribute("color")}set color(n){n==null||n===""?this.removeAttribute("color"):(this.setAttribute("color",String(n)),this.style.setProperty("--chip-colored-color",String(n)))}get colored(){return this.hasAttribute("colored")}set colored(n){n?this.setAttribute("colored","true"):this.removeAttribute("colored")}set data(n){n==null||n===""?this.removeAttribute("data"):(this.setAttribute("data",String(n)),this.updateContent())}set modality(n){n==null?this.removeAttribute("modality"):(console.log(1),this.setAttribute("modality",String(n)),this.updateContent())}get disabled(){return this.hasAttribute("disabled")}set disabled(n){n?(this.setAttribute("aria-disabled","true"),this.$chip.setAttribute("aria-disabled","true"),this.$dragHandler.setAttribute("aria-disabled","true")):(this.removeAttribute("aria-disabled"),this.$chip.removeAttribute("aria-disabled"),this.$dragHandler.removeAttribute("aria-disabled"))}get selected(){return this.hasAttribute("selected")}set selected(n){n?this.setAttribute("selected",""):this.removeAttribute("selected")}get value(){return this.getAttribute("value")??""}set value(n){this.setAttribute("value",String(n))}toggle(n){return typeof n=="boolean"?this.selected=n:this.selected=!this.selected,this.selected}removeSelf(){this.remove()}};customElements.get("edu-chip")||customElements.define("edu-chip",vt);var Xo=`
|
|
882
913
|
<style>
|
|
883
914
|
:host {
|
|
884
915
|
display: block;
|
|
@@ -924,16 +955,17 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
924
955
|
}
|
|
925
956
|
|
|
926
957
|
.block[variant="playful"] {
|
|
927
|
-
background: var(--
|
|
928
|
-
border:
|
|
929
|
-
color: rgb(var(--edu-
|
|
958
|
+
background: linear-gradient(135deg, rgb(var(--edu-card)), rgb(var(--edu-muted) / 0.92));
|
|
959
|
+
border: 2px solid rgb(var(--edu-border));
|
|
960
|
+
color: rgb(var(--edu-ink));
|
|
930
961
|
border-radius: 16px;
|
|
931
|
-
box-shadow:
|
|
962
|
+
box-shadow: 0 6px 14px rgb(var(--edu-shadow-color) / 0.12);
|
|
932
963
|
}
|
|
933
964
|
|
|
934
965
|
.block[variant="playful"]:hover {
|
|
935
|
-
transform: translateY(-2px) rotate(-
|
|
936
|
-
|
|
966
|
+
transform: translateY(-2px) rotate(-1deg);
|
|
967
|
+
border-color: color-mix(in srgb, var(--accent-color) 38%, rgb(var(--edu-border)));
|
|
968
|
+
box-shadow: 0 10px 22px rgb(var(--edu-shadow-color) / 0.18);
|
|
937
969
|
}
|
|
938
970
|
|
|
939
971
|
.block[variant="outline"] {
|
|
@@ -964,40 +996,45 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
964
996
|
}
|
|
965
997
|
|
|
966
998
|
.block[variant="minimal"] {
|
|
967
|
-
background:
|
|
968
|
-
color: rgb(var(--edu-ink));
|
|
999
|
+
background: transparent;
|
|
1000
|
+
color: rgb(var(--edu-second-ink));
|
|
969
1001
|
border: 1px solid rgb(var(--edu-border));
|
|
970
|
-
border-radius:
|
|
1002
|
+
border-radius: 10px;
|
|
971
1003
|
padding: 0.75rem;
|
|
972
1004
|
}
|
|
973
1005
|
|
|
974
1006
|
.block[variant="minimal"]:hover {
|
|
975
|
-
|
|
976
|
-
|
|
1007
|
+
background: rgb(var(--edu-card) / 0.8);
|
|
1008
|
+
color: rgb(var(--edu-ink));
|
|
1009
|
+
border-color: rgb(var(--edu-first-accent) / 0.35);
|
|
1010
|
+
box-shadow: 0 4px 12px rgba(var(--edu-shadow-color), 0.08);
|
|
977
1011
|
}
|
|
978
1012
|
|
|
979
1013
|
.block[variant="glass"] {
|
|
980
1014
|
background: rgba(var(--edu-card), 0.7);
|
|
981
1015
|
backdrop-filter: blur(10px);
|
|
982
|
-
border:
|
|
983
|
-
border-radius:
|
|
1016
|
+
border: 1px solid rgba(var(--edu-border), 0.45);
|
|
1017
|
+
border-radius: 14px;
|
|
1018
|
+
box-shadow: inset 0 1px 0 rgb(var(--edu-card) / 0.85), 0 8px 20px rgba(var(--edu-shadow-color), 0.12);
|
|
984
1019
|
}
|
|
985
1020
|
|
|
986
1021
|
.block[variant="glass"]:hover {
|
|
987
|
-
background: rgba(var(--edu-card), 0.
|
|
988
|
-
border-color: rgba(var(--edu-first-accent), 0.
|
|
1022
|
+
background: rgba(var(--edu-card), 0.82);
|
|
1023
|
+
border-color: rgba(var(--edu-first-accent), 0.4);
|
|
1024
|
+
box-shadow: inset 0 1px 0 rgb(var(--edu-card) / 0.95), 0 12px 24px rgba(var(--edu-shadow-color), 0.16);
|
|
989
1025
|
}
|
|
990
1026
|
|
|
991
1027
|
.block[variant="card"] {
|
|
992
1028
|
background: rgb(var(--edu-card));
|
|
993
|
-
border:
|
|
994
|
-
border-radius:
|
|
995
|
-
box-shadow: 0
|
|
1029
|
+
border: 1px solid rgb(var(--edu-border));
|
|
1030
|
+
border-radius: 12px;
|
|
1031
|
+
box-shadow: 0 8px 18px rgba(var(--edu-shadow-color), 0.1);
|
|
996
1032
|
}
|
|
997
1033
|
|
|
998
1034
|
.block[variant="card"]:hover {
|
|
999
|
-
|
|
1000
|
-
|
|
1035
|
+
background: linear-gradient(180deg, rgb(var(--edu-card)), rgb(var(--edu-muted) / 0.8));
|
|
1036
|
+
border-color: rgb(var(--edu-first-accent) / 0.35);
|
|
1037
|
+
box-shadow: 0 12px 24px rgba(var(--edu-shadow-color), 0.14);
|
|
1001
1038
|
}
|
|
1002
1039
|
|
|
1003
1040
|
.block[variant="sign"] {
|
|
@@ -1013,7 +1050,7 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
1013
1050
|
|
|
1014
1051
|
.block[variant="sign"]:hover {
|
|
1015
1052
|
border-color: var(--accent-color);
|
|
1016
|
-
background: var(
|
|
1053
|
+
background: rgb(var(--edu-muted));
|
|
1017
1054
|
}
|
|
1018
1055
|
|
|
1019
1056
|
.block[variant="empty"] {
|
|
@@ -1033,10 +1070,10 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
1033
1070
|
<div class="block" part="block">
|
|
1034
1071
|
<slot></slot>
|
|
1035
1072
|
</div>
|
|
1036
|
-
`,Y=class extends HTMLElement{static get observedAttributes(){return["variant"]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=
|
|
1073
|
+
`,Y=class extends HTMLElement{static get observedAttributes(){return["variant"]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=Xo,this.$blockEl=this.shadowRoot.querySelector(".block"),L.injectKeyframes(this.shadowRoot)}connectedCallback(){this.hasAttribute("variant")||(this.variant="outline"),this.sync()}attributeChangedCallback(){this.sync()}sync(){this.$blockEl&&this.$blockEl.setAttribute("variant",this.variant)}getBlock(){return this.$blockEl}get variant(){return this.getAttribute("variant")??"outline"}set variant(n){this.setAttribute("variant",n)}setAccentColor(n){this.shadowRoot.host.style.setProperty("--accent-color",n)}removeSelf(){this.remove()}};customElements.get("edu-block")||customElements.define("edu-block",Y);function xe(e,n,t,r){let i=0,o=0;return e.forEach(s=>{s.items.forEach(l=>{o++;let c=n.get(l),d=t.querySelector(`[data-label="${l}"]`);c===s.label?(i++,d.chipState="correct"):d.chipState="wrong"})}),r&&r.forEach(s=>{o++;let l=n.get(s),c=t.querySelector(`[data-label="${s}"]`);l==="Invalid"?(i++,c.chipState="correct"):c.chipState="wrong"}),{score:o>0?Math.round(i/o*100):0,correct:i,total:o}}var we=class extends x{constructor(t,r,i){super(t,r,i);this.interactionMechanic="static";this.categories=[];this.allItems=[];this.categoryColors=["#6366f1","#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316","#94a3b8"];this.currentColor=this.categoryColors[0];this.data.categories.forEach(({label:o,items:a})=>{this.categories.push(o),this.allItems.push(...a)}),this.currentCategory=this.categories[0],this.data.distractors&&(this.allItems.push(...this.data.distractors),this.categories.push("Invalid")),this.allItems=S(this.allItems),this.categorized=new Map,this.initializeProgress(this.allItems.length)}initialize(){}cleanup(){}onVariantChange(t){this.querySelectorAll("edu-chip, edu-block").forEach(r=>{r.variant!==void 0&&(r.variant=t)})}render(){this.innerHTML=`
|
|
1037
1074
|
<style>
|
|
1038
1075
|
open-classification {
|
|
1039
|
-
--current-color: #
|
|
1076
|
+
--current-color: #aa94b8;
|
|
1040
1077
|
display: flex;
|
|
1041
1078
|
width: 100%;
|
|
1042
1079
|
height: 100%;
|
|
@@ -1081,7 +1118,7 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
1081
1118
|
.items-container {
|
|
1082
1119
|
display: grid;
|
|
1083
1120
|
grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
|
|
1084
|
-
grid-auto-rows: minmax(
|
|
1121
|
+
grid-auto-rows: minmax(clamp(56px, 12cqh, 88px), 1fr);
|
|
1085
1122
|
gap: clamp(0.5rem, min(1.6cqw, 1.6cqh), 1rem);
|
|
1086
1123
|
padding: clamp(0.5rem, min(1.6cqw, 1.6cqh), 1.25rem);
|
|
1087
1124
|
background: rgb(var(--edu-muted));
|
|
@@ -1193,7 +1230,7 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
1193
1230
|
</div>
|
|
1194
1231
|
`,this.style.setProperty("--current-color",this.currentColor),this.$categoriesBar=this.querySelector("#categories-bar"),this.setCategories(this.$categoriesBar);let t=this.querySelector(".items-container");this.setItems(t)}setItems(t){this.allItems.forEach((r,i)=>{let o=document.createElement("edu-chip");o.variant=this.config.variant,o.dataset.label=r,D(r,o,this.assets?.assetsById),o.addEventListener("click",a=>{let s=a.currentTarget,l=s.dataset.label;if(this.categorized.get(l)===this.currentCategory){this.categorized.delete(l),s.colored=!1,this.decrementProgress(),this.emitStateChange();return}this.categorized.has(l)||this.incrementProgress(),this.categorized.set(l,this.currentCategory),s.color=this.currentColor,s.colored=!0,this.emitStateChange()}),t.append(o)})}setCategories(t){this.categories.forEach((r,i)=>{let o=new Y;o.variant=this.config.variant;let a=this.categoryColors[i%this.categoryColors.length];o.dataset.category=r,o.dataset.color=a,o.style.setProperty("--category-color",a),o.innerHTML=`
|
|
1195
1232
|
<div class="category-label">${r}</div>
|
|
1196
|
-
`,o.addEventListener("click",s=>{let l=s.currentTarget;this.currentCategory=l.dataset.category,this.currentColor=l.dataset.color,this.style.setProperty("--current-color",this.currentColor),t.querySelectorAll("edu-block").forEach(c=>c.classList.remove("active")),o.classList.add("active")}),r===this.currentCategory&&o.classList.add("active"),t.append(o)})}getCurrentState(){return{categorized:Object.fromEntries(this.categorized),progress:this.progressTracker.current}}isInteractionComplete(){if(this.categorized.size!==this.allItems.length)return!1;for(let t of this.categorized.values())if(t==null)return!1;return!0}onHint(){let t=this.allItems.filter(i=>!this.categorized.has(i));if(t.length===0){alert('All items are categorized! Click "Check" to submit.'),this.emitHintShown("All items categorized");return}let r=t[0];alert(`Hint: You haven't categorized "${r}" yet. Which category does it belong to?`),this.emitHintShown(`Uncategorized item: ${r}`)}submit(){super.submit();let t=xe(this.data.categories,this.categorized,this);console.log(`Classification Score: ${t.score.toFixed(1)}% (${t.correct}/${t.total} correct)`),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0}))
|
|
1233
|
+
`,o.addEventListener("click",s=>{let l=s.currentTarget;this.currentCategory=l.dataset.category,this.currentColor=l.dataset.color,this.style.setProperty("--current-color",this.currentColor),t.querySelectorAll("edu-block").forEach(c=>c.classList.remove("active")),o.classList.add("active")}),r===this.currentCategory&&o.classList.add("active"),t.append(o)})}getCurrentState(){return{categorized:Object.fromEntries(this.categorized),progress:this.progressTracker.current}}isInteractionComplete(){if(this.categorized.size!==this.allItems.length)return!1;for(let t of this.categorized.values())if(t==null)return!1;return!0}onHint(){let t=this.allItems.filter(i=>!this.categorized.has(i));if(t.length===0){alert('All items are categorized! Click "Check" to submit.'),this.emitHintShown("All items categorized");return}let r=t[0];alert(`Hint: You haven't categorized "${r}" yet. Which category does it belong to?`),this.emitHintShown(`Uncategorized item: ${r}`)}submit(){super.submit();let t=xe(this.data.categories,this.categorized,this,this.data.distractors);console.log(`Classification Score: ${t.score.toFixed(1)}% (${t.correct}/${t.total} correct)`),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0}))}reset(){super.reset(),this.categorized.clear(),this.querySelectorAll("edu-chip").forEach(t=>{t.classList.remove("colorized"),t.style.setProperty("--current-color","")})}};customElements.get("open-classification")||customElements.define("open-classification",we);var ye=class extends x{constructor(t,r,i){super(t,r,i);this.interactionMechanic="automatic-sequencing";this.categories=[];this.allItems=[];this.categorized=new Map;this.zones=[];this.chips=[];this.activeChip=null;this.currentZone=null;this.isDragging=!1;this.startX=0;this.startY=0;this.offsetX=0;this.offsetY=0;this.data.categories.forEach(({label:o,items:a})=>{this.categories.push(o),this.allItems.push(...a)}),this.data.distractors&&console.warn("Found a distractor in a Sequential Classification interaction, those are not useful and will be ignored"),this.allItems=this.config.shuffle?S(this.allItems):this.allItems,this.initializeProgress(this.allItems.length),this.boundPointerMove=this.handlePointerMove.bind(this),this.boundPointerUp=this.handlePointerUp.bind(this),this.variant=this.config.variant}initialize(){window.addEventListener("pointermove",this.boundPointerMove),window.addEventListener("pointerup",this.boundPointerUp)}cleanup(){window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp)}onVariantChange(t){this.querySelectorAll("edu-chip, edu-block").forEach(r=>{r.variant!==void 0&&(r.variant=t)}),this.variant=t}render(){let t=Math.min(this.categories.length,4);this.innerHTML=`
|
|
1197
1234
|
<style>
|
|
1198
1235
|
sequential-classification {
|
|
1199
1236
|
display: flex;
|
|
@@ -1275,6 +1312,7 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
1275
1312
|
gap: clamp(0.5rem, min(1.5cqw, 1.5cqh), 1rem);
|
|
1276
1313
|
overflow-y: auto;
|
|
1277
1314
|
overflow-x: hidden;
|
|
1315
|
+
scrollbar-gutter: stable;
|
|
1278
1316
|
align-content: stretch;
|
|
1279
1317
|
padding: clamp(0.25rem, min(1cqw, 1cqh), 0.5rem);
|
|
1280
1318
|
min-height: 0;
|
|
@@ -1318,11 +1356,17 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
1318
1356
|
|
|
1319
1357
|
edu-chip {
|
|
1320
1358
|
position: absolute;
|
|
1359
|
+
width: clamp(160px, 20cqw, 280px);
|
|
1360
|
+
max-width: calc(100% - 0.5rem);
|
|
1321
1361
|
user-select: none;
|
|
1322
1362
|
touch-action: none;
|
|
1323
1363
|
transition: transform 0.2s ease;
|
|
1324
1364
|
}
|
|
1325
1365
|
|
|
1366
|
+
edu-chip::part(content-zone) {
|
|
1367
|
+
min-height: clamp(56px, 10cqh, 88px);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1326
1370
|
edu-chip:hover {
|
|
1327
1371
|
transform: scale(1.05);
|
|
1328
1372
|
}
|
|
@@ -1352,7 +1396,7 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
1352
1396
|
<div id="zones-grid"></div>
|
|
1353
1397
|
</div>
|
|
1354
1398
|
</div>
|
|
1355
|
-
`,this.container=this.querySelector("#container"),this.centerZone=this.querySelector("#center-zone"),this.zonesGrid=this.querySelector("#zones-grid"),this.createDropZones(),this.showNextChip()}createDropZones(){let t=this.querySelector("#zones-grid");this.categories.forEach((r,i)=>{let o=document.createElement("edu-block");o.variant=this.variant,o.setAccentColor(F[i%F.length]),o.classList.add("zone","empty"),o.textContent=`${r}: 0`,o.dataset.label=r,t.appendChild(o),this.zones.push(o)})}showNextChip(){let t=this.allItems.find(i=>!this.categorized.has(i));if(!t){this.centerZone.classList.add("empty");return}let r=document.createElement("edu-chip");r.variant=this.variant,D(t,r,this.assets?.assetsById),r.prefix=(this.allItems.indexOf(t)+1).toString(),r.draggable=!0,r.dataset.label=t,r.addEventListener("pointerdown",i=>this.handlePointerDown(i,r)),this.container.appendChild(r),this.chips.push(r),requestAnimationFrame(()=>{let i=this.centerZone.getBoundingClientRect(),o=this.container.getBoundingClientRect(),a=r.getBoundingClientRect(),s=i.left-o.left+(i.width-a.width)/2,l=i.top-o.top+(i.height-a.height)/2;r.style.left=`${s}px`,r.style.top=`${l}px`})}reparentChip(t,r){if(t.parentElement===r)return;let i=t.getBoundingClientRect(),o=r.getBoundingClientRect(),a=i.left-o.left,s=i.top-o.top;r===this.zonesGrid&&(a+=this.zonesGrid.scrollLeft,s+=this.zonesGrid.scrollTop),t.style.left=`${a}px`,t.style.top=`${s}px`,r.appendChild(t)}handlePointerDown(t,r){t.preventDefault(),this.reparentChip(r,this.container),this.activeChip=r,this.isDragging=!0,r.classList.add("dragging");let i=r.getBoundingClientRect(),o=this.container.getBoundingClientRect();this.offsetX=t.clientX-i.left,this.offsetY=t.clientY-i.top,this.chips.forEach(a=>{a!==r&&(a.style.opacity="0.3")}),this.handlePointerMove(t)}handlePointerMove(t){if(!this.isDragging||!this.activeChip)return;let r=this.container.getBoundingClientRect(),i=t.clientX-r.left-this.offsetX,o=t.clientY-r.top-this.offsetY,a=this.activeChip.getBoundingClientRect();i=Math.max(0,Math.min(i,r.width-a.width)),o=Math.max(0,Math.min(o,r.height-a.height)),this.activeChip.style.left=`${i}px`,this.activeChip.style.top=`${o}px`,this.checkZoneOverlap(t.clientX,t.clientY)}handlePointerUp(t){if(!this.isDragging||!this.activeChip)return;this.isDragging=!1,this.chips.forEach(i=>i.style.opacity="1"),this.activeChip.classList.remove("dragging");let r=this.activeChip.dataset.label;if(this.currentZone){let i=this.currentZone.dataset.label,o=this.categorized.get(r);o!==i&&(this.categorized.set(r,i),this.emitStateChange(),o===void 0&&(this.incrementProgress(),this.showNextChip()),o===null&&this.incrementProgress()),this.reparentChip(this.activeChip,this.zonesGrid)}else this.categorized.get(r)&&(this.categorized.set(r,null),this.decrementProgress()),this.reparentChip(this.activeChip,this.container);this.zones.forEach(i=>{i.classList.remove("highlight");let o=Array.from(this.categorized.values()).filter(a=>a===i.dataset.label).length;i.textContent=`${i.dataset.label}: ${o}`,o>0?i.classList.remove("empty"):i.classList.add("empty")}),this.activeChip=null,this.currentZone=null}checkZoneOverlap(t,r){this.currentZone=null;for(let i of this.zones){let o=i.getBoundingClientRect();t>=o.left&&t<=o.right&&r>=o.top&&r<=o.bottom?(i.classList.add("highlight"),this.currentZone=i):i.classList.remove("highlight")}}getCurrentState(){return{categorized:Object.fromEntries(this.categorized),progress:this.progressTracker.current}}isInteractionComplete(){return this.categorized.size===this.allItems.length}onHint(){let t=this.allItems.filter(o=>!this.categorized.has(o));if(t.length===0){alert('All items are categorized! Click "Check" to submit.'),this.emitHintShown("All items categorized");return}let r=t[0],i=this.data.categories.find(o=>o.items.includes(r))?.label;i&&(alert(`Hint: "${r}" belongs to "${i}".`),this.emitHintShown(`Item: ${r} \u2192 Category: ${i}`))}submit(){super.submit();let t=xe(this.data.categories,this.categorized,this);console.log(`Classification Score: ${t.score.toFixed(1)}% (${t.correct}/${t.total} correct)`),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0}))}reset(){super.reset(),this.categorized.clear(),this.chips.forEach(t=>t.remove()),this.chips=[],this.centerZone.classList.remove("empty"),this.activeChip=null,this.currentZone=null,this.isDragging=!1,this.zonesGrid&&(this.zonesGrid.scrollTop=0),this.showNextChip()}};customElements.get("sequential-classification")||customElements.define("sequential-classification",ye);var
|
|
1399
|
+
`,this.container=this.querySelector("#container"),this.centerZone=this.querySelector("#center-zone"),this.zonesGrid=this.querySelector("#zones-grid"),this.createDropZones(),this.showNextChip()}createDropZones(){let t=this.querySelector("#zones-grid");this.categories.forEach((r,i)=>{let o=document.createElement("edu-block");o.variant=this.variant,o.setAccentColor(F[i%F.length]),o.classList.add("zone","empty"),o.textContent=`${r}: 0`,o.dataset.label=r,t.appendChild(o),this.zones.push(o)})}showNextChip(){let t=this.allItems.find(i=>!this.categorized.has(i));if(!t){this.centerZone.classList.add("empty");return}let r=document.createElement("edu-chip");r.variant=this.variant,D(t,r,this.assets?.assetsById),r.prefix=(this.allItems.indexOf(t)+1).toString(),r.draggable=!0,r.dataset.label=t,r.addEventListener("pointerdown",i=>this.handlePointerDown(i,r)),this.container.appendChild(r),this.chips.push(r),requestAnimationFrame(()=>{let i=this.centerZone.getBoundingClientRect(),o=this.container.getBoundingClientRect(),a=r.getBoundingClientRect(),s=i.left-o.left+(i.width-a.width)/2,l=i.top-o.top+(i.height-a.height)/2;r.style.left=`${s}px`,r.style.top=`${l}px`})}reparentChip(t,r){if(t.parentElement===r)return;let i=t.getBoundingClientRect(),o=r.getBoundingClientRect(),a=i.left-o.left,s=i.top-o.top;r===this.zonesGrid&&(a+=this.zonesGrid.scrollLeft,s+=this.zonesGrid.scrollTop),t.style.left=`${a}px`,t.style.top=`${s}px`,r.appendChild(t)}handlePointerDown(t,r){t.preventDefault(),this.reparentChip(r,this.container),this.activeChip=r,this.isDragging=!0,r.classList.add("dragging");let i=r.getBoundingClientRect(),o=this.container.getBoundingClientRect();this.offsetX=t.clientX-i.left,this.offsetY=t.clientY-i.top,this.chips.forEach(a=>{a!==r&&(a.style.opacity="0.3")}),this.handlePointerMove(t)}handlePointerMove(t){if(!this.isDragging||!this.activeChip)return;let r=this.container.getBoundingClientRect(),i=t.clientX-r.left-this.offsetX,o=t.clientY-r.top-this.offsetY,a=this.activeChip.getBoundingClientRect();i=Math.max(0,Math.min(i,r.width-a.width)),o=Math.max(0,Math.min(o,r.height-a.height)),this.activeChip.style.left=`${i}px`,this.activeChip.style.top=`${o}px`,this.checkZoneOverlap(t.clientX,t.clientY)}handlePointerUp(t){if(!this.isDragging||!this.activeChip)return;this.isDragging=!1,this.chips.forEach(i=>i.style.opacity="1"),this.activeChip.classList.remove("dragging");let r=this.activeChip.dataset.label;if(this.currentZone){let i=this.currentZone.dataset.label,o=this.categorized.get(r);o!==i&&(this.categorized.set(r,i),this.emitStateChange(),o===void 0&&(this.incrementProgress(),this.showNextChip()),o===null&&this.incrementProgress()),this.reparentChip(this.activeChip,this.zonesGrid)}else this.categorized.get(r)&&(this.categorized.set(r,null),this.decrementProgress()),this.reparentChip(this.activeChip,this.container);this.zones.forEach(i=>{i.classList.remove("highlight");let o=Array.from(this.categorized.values()).filter(a=>a===i.dataset.label).length;i.textContent=`${i.dataset.label}: ${o}`,o>0?i.classList.remove("empty"):i.classList.add("empty")}),this.activeChip=null,this.currentZone=null}checkZoneOverlap(t,r){this.currentZone=null;for(let i of this.zones){let o=i.getBoundingClientRect();t>=o.left&&t<=o.right&&r>=o.top&&r<=o.bottom?(i.classList.add("highlight"),this.currentZone=i):i.classList.remove("highlight")}}getCurrentState(){return{categorized:Object.fromEntries(this.categorized),progress:this.progressTracker.current}}isInteractionComplete(){return this.categorized.size===this.allItems.length}onHint(){let t=this.allItems.filter(o=>!this.categorized.has(o));if(t.length===0){alert('All items are categorized! Click "Check" to submit.'),this.emitHintShown("All items categorized");return}let r=t[0],i=this.data.categories.find(o=>o.items.includes(r))?.label;i&&(alert(`Hint: "${r}" belongs to "${i}".`),this.emitHintShown(`Item: ${r} \u2192 Category: ${i}`))}submit(){super.submit();let t=xe(this.data.categories,this.categorized,this);console.log(`Classification Score: ${t.score.toFixed(1)}% (${t.correct}/${t.total} correct)`),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0}))}reset(){super.reset(),this.categorized.clear(),this.chips.forEach(t=>t.remove()),this.chips=[],this.centerZone.classList.remove("empty"),this.activeChip=null,this.currentZone=null,this.isDragging=!1,this.zonesGrid&&(this.zonesGrid.scrollTop=0),this.showNextChip()}};customElements.get("sequential-classification")||customElements.define("sequential-classification",ye);var Jo={audio:`
|
|
1356
1400
|
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
1357
1401
|
<path d="M11 5 6 9H3v6h3l5 4V5Z"/>
|
|
1358
1402
|
<path d="M15.5 8.5a5 5 0 0 1 0 7"/>
|
|
@@ -1411,7 +1455,7 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
1411
1455
|
<rect x="3" y="5" width="14" height="14" rx="2"/>
|
|
1412
1456
|
<path d="m17 10 4-2.5v9L17 14"/>
|
|
1413
1457
|
</svg>
|
|
1414
|
-
`};function B(e){return
|
|
1458
|
+
`};function B(e){return Jo[e]}function Br(e,n,t){if(n.innerHTML="",!e.startsWith("@:")||!t||e.length<3){n.textContent=e;return}let r=e.slice(2),i=t[r];if(!i){n.textContent=r;return}console.log("DIALOG",i.dialog),i.dialog===!0?ea(n,i):ta(n,i)}function ea(e,n){let t=document.createElement("button");t.className="media-dialog-trigger";let r={image:`${B("image")}View Image`,video:`${B("video")}Play Video`,audio:`${B("audio")}Play Audio`,html:`${B("data")}View Content`,tts:`${B("audio")}Play Audio`};t.innerHTML=r[n.type],t.style.cssText=`
|
|
1415
1459
|
width: 80%;
|
|
1416
1460
|
justify-content: center;
|
|
1417
1461
|
padding: 1rem 1.5rem;
|
|
@@ -1426,7 +1470,7 @@ ${i.map(([o,a])=>` ${o}: ${a};`).join(`
|
|
|
1426
1470
|
display: inline-flex;
|
|
1427
1471
|
align-items: center;
|
|
1428
1472
|
gap: 0.5rem;
|
|
1429
|
-
`,t.addEventListener("mouseenter",()=>{t.style.transform="translateY(-2px)",t.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)"}),t.addEventListener("mouseleave",()=>{t.style.transform="translateY(0)",t.style.boxShadow="none"}),t.addEventListener("click",()=>{
|
|
1473
|
+
`,t.addEventListener("mouseenter",()=>{t.style.transform="translateY(-2px)",t.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)"}),t.addEventListener("mouseleave",()=>{t.style.transform="translateY(0)",t.style.boxShadow="none"}),t.addEventListener("click",()=>{qr(n)}),e.appendChild(t)}function ta(e,n){let t=document.createElement("div");t.style.cssText=`
|
|
1430
1474
|
position: relative;
|
|
1431
1475
|
display: flex;
|
|
1432
1476
|
justify-content: center;
|
|
@@ -1455,7 +1499,7 @@ overflow-x: hidden;`;let r=document.createElement("edu-media");r.setAttribute("t
|
|
|
1455
1499
|
transition: all 0.2s;
|
|
1456
1500
|
z-index: 10;
|
|
1457
1501
|
opacity: 0.8;
|
|
1458
|
-
`,o.addEventListener("mouseenter",()=>{o.style.opacity="1",o.style.transform="scale(1.1)"}),o.addEventListener("mouseleave",()=>{o.style.opacity="0.8",o.style.transform="scale(1)"}),o.addEventListener("click",()=>{
|
|
1502
|
+
`,o.addEventListener("mouseenter",()=>{o.style.opacity="1",o.style.transform="scale(1.1)"}),o.addEventListener("mouseleave",()=>{o.style.opacity="0.8",o.style.transform="scale(1)"}),o.addEventListener("click",()=>{qr(n)}),t.appendChild(r),t.appendChild(o),e.appendChild(t)}function qr(e){let n=document.querySelector("edu-dialog#asset-dialog");n||(n=document.createElement("edu-dialog"),n.id="asset-dialog",document.body.appendChild(n));let t={image:"Image",video:"Video",audio:"Audio",html:"Content",tts:"Audio"};n.title=t[e.type];let r=document.createElement("edu-media");r.setAttribute("type",e.type),e.type==="image"||e.type==="video"||e.type==="audio"?r.setAttribute("data",e.url):(e.type==="html"||e.type==="tts")&&r.setAttribute("data",e.content);let i={};e.type==="image"&&e.size?i.size="large":e.type==="video"&&e.span?i.span=e.span:(e.type==="audio"||e.type==="tts")&&e.volume!==void 0&&(i.volume=e.volume),Object.keys(i).length>0&&r.setAttribute("spec",JSON.stringify(i)),n.innerHTML="",n.appendChild(r),n.open()}var xt=class extends HTMLElement{constructor(){super();this.mediaType=null;this.mediaData=null;this.mediaSpec=null;this.audioPlaying=!1;this.currentAudioUrl=null}static get observedAttributes(){return["type","data","spec"]}connectedCallback(){this.render()}attributeChangedCallback(t,r,i){if(r!==i){if(t==="type")this.mediaType=i;else if(t==="data")this.mediaData=i;else if(t==="spec")try{this.mediaSpec=i?JSON.parse(i):null}catch{console.warn("[EduMedia] Invalid spec JSON:",i),this.mediaSpec=null}this.isConnected&&this.render()}}disconnectedCallback(){this.audioPlaying&&this.currentAudioUrl&&(Ye.stop(this.currentAudioUrl),this.audioPlaying=!1)}render(){if(!this.mediaType||!this.mediaData){this.innerHTML="";return}switch(this.mediaType){case"image":this.renderImage();break;case"video":this.renderVideo();break;case"audio":this.renderAudio();break;case"html":this.renderHtml();break;case"tts":this.innerHTML='<div style="font-style: italic; color: gray;">TTS not yet supported</div>';break;default:console.warn(`[EduMedia] Unknown media type: ${this.mediaType}`),this.innerHTML=""}}renderImage(){let t=this.mediaSpec?.size||"medium";this.innerHTML=`
|
|
1459
1503
|
<style>
|
|
1460
1504
|
:host {
|
|
1461
1505
|
display: block;
|
|
@@ -1558,7 +1602,7 @@ overflow-x: hidden;`;let r=document.createElement("edu-media");r.setAttribute("t
|
|
|
1558
1602
|
</button>
|
|
1559
1603
|
<div class="audio-label">Audio clip</div>
|
|
1560
1604
|
</div>
|
|
1561
|
-
`;let i=this.querySelector(".audio-button");i&&i.addEventListener("click",async()=>{this.audioPlaying?(
|
|
1605
|
+
`;let i=this.querySelector(".audio-button");i&&i.addEventListener("click",async()=>{this.audioPlaying?(Ye.stop(this.mediaData),this.audioPlaying=!1,this.currentAudioUrl=null,i.title="Play audio"):(this.currentAudioUrl=this.mediaData,console.log(this.currentAudioUrl),await Ye.playSound(this.mediaData,{volume:t,loop:r,onEnd:()=>{this.audioPlaying=!1,this.currentAudioUrl=null,i.title="Play audio"},onError:o=>{console.error("[EduMedia] Audio playback error:",o),this.audioPlaying=!1,this.currentAudioUrl=null,i.title="Play audio"}}),this.audioPlaying=!0,i.title="Stop audio")})}renderHtml(){this.innerHTML=`
|
|
1562
1606
|
<style>
|
|
1563
1607
|
:host {
|
|
1564
1608
|
display: block;
|
|
@@ -1575,7 +1619,7 @@ overflow-x: hidden;`;let r=document.createElement("edu-media");r.setAttribute("t
|
|
|
1575
1619
|
}
|
|
1576
1620
|
</style>
|
|
1577
1621
|
<div class="media-html">${this.mediaData}</div>
|
|
1578
|
-
`}parseTime(t){let r=t.split(":").map(i=>parseInt(i,10));return r.length===2?r[0]*60+r[1]:r.length===3?r[0]*3600+r[1]*60+r[2]:null}};customElements.get("edu-media")||customElements.define("edu-media",
|
|
1622
|
+
`}parseTime(t){let r=t.split(":").map(i=>parseInt(i,10));return r.length===2?r[0]*60+r[1]:r.length===3?r[0]*3600+r[1]*60+r[2]:null}};customElements.get("edu-media")||customElements.define("edu-media",xt);function zr(e,n){let t=0,r=e.data.length;e.data.forEach(a=>{let s=new Set(a.correctOptions),l=new Set(n[a.question]||[]),c=0,d=0,u=0;l.forEach(m=>{s.has(m)?c++:d++}),s.forEach(m=>{l.has(m)||u++});let p=s.size,h=c-d-u,g=Math.max(0,h/p*100);t+=g});let i=Math.round(t/r),o=0;return e.data.forEach(a=>{let s=new Set(a.correctOptions),l=new Set(n[a.question]||[]);s.size===l.size&&[...s].every(c=>l.has(c))&&o++}),{score:i,correct:o,total:r}}var ee=class extends x{constructor(t,r,i){super(t,r,i);this.interactionMechanic="sequential";this.currentQuestionIndex=0;this.userAnswers={};this.shuffledOptions=new Map;this.isGraded=!1;this.data.data.forEach(o=>{this.userAnswers[o.question]=[],this.config.shuffle?this.shuffledOptions.set(o.question,S([...o.options,...o.correctOptions])):this.shuffledOptions.set(o.question,[...o.options,...o.correctOptions])}),this.variant=this.config.variant,this.initializeProgress(this.data.data.length)}get slidesCount(){return this.data.data.length}initialize(){}cleanup(){}onVariantChange(t){this.querySelectorAll("edu-chip, edu-block").forEach(r=>{r.variant!==void 0&&(r.variant=t)}),this.variant=t}setSteps(t){let r=t-1;r>=0&&r<this.data.data.length&&(this.currentQuestionIndex=r,this.renderCurrentQuestion())}render(){this.innerHTML=`
|
|
1579
1623
|
<style>
|
|
1580
1624
|
mcq-interaction {
|
|
1581
1625
|
display: flex;
|
|
@@ -1612,17 +1656,17 @@ overflow-x: hidden;`;let r=document.createElement("edu-media");r.setAttribute("t
|
|
|
1612
1656
|
flex-shrink: 0;
|
|
1613
1657
|
display: flex;
|
|
1614
1658
|
flex-direction: column;
|
|
1615
|
-
min-height: clamp(
|
|
1616
|
-
max-height: clamp(
|
|
1659
|
+
min-height: clamp(88px, 16cqh, 160px);
|
|
1660
|
+
max-height: clamp(132px, 32cqh, 280px);
|
|
1617
1661
|
overflow: hidden;
|
|
1618
1662
|
}
|
|
1619
1663
|
|
|
1620
1664
|
.question-text {
|
|
1621
1665
|
padding: 0;
|
|
1622
|
-
font-size: clamp(
|
|
1666
|
+
font-size: clamp(1.05rem, 2.6cqh, 1.45rem);
|
|
1623
1667
|
font-weight: 600;
|
|
1624
1668
|
color: rgb(var(--edu-ink));
|
|
1625
|
-
line-height: 1.
|
|
1669
|
+
line-height: 1.35;
|
|
1626
1670
|
}
|
|
1627
1671
|
|
|
1628
1672
|
.divider {
|
|
@@ -1686,7 +1730,7 @@ overflow-x: hidden;`;let r=document.createElement("edu-media");r.setAttribute("t
|
|
|
1686
1730
|
border: none;
|
|
1687
1731
|
padding: clamp(0.5rem, min(1.6cqw, 1.6cqh), 1rem);
|
|
1688
1732
|
height: 100%;
|
|
1689
|
-
max-height: clamp(
|
|
1733
|
+
max-height: clamp(132px, 32cqh, 280px);
|
|
1690
1734
|
overflow: auto;
|
|
1691
1735
|
align-items: center;
|
|
1692
1736
|
justify-content: flex-start;
|
|
@@ -1727,8 +1771,8 @@ overflow-x: hidden;`;let r=document.createElement("edu-media");r.setAttribute("t
|
|
|
1727
1771
|
<div class="options-container"></div>
|
|
1728
1772
|
</div>
|
|
1729
1773
|
</div>
|
|
1730
|
-
`,this.$modeLabel=this.querySelector(".mode-label"),this.$optionsContainer=this.querySelector(".options-container");let t=this.querySelector("#question-block");this.$questionBlock=document.createElement("edu-block"),this.$questionBlock.variant=this.config.variant,this.$questionBlock.innerHTML='<div class="question-text"></div>',t.appendChild(this.$questionBlock),this.$questionText=this.$questionBlock.querySelector(".question-text"),this.renderCurrentQuestion()}renderCurrentQuestion(){let t=this.data.data[this.currentQuestionIndex];if(!t)return;let r=t.correctOptions.length===1;this.$modeLabel.textContent=r?"Multiple Choice":"Multiple Response",
|
|
1731
|
-
`).map(s=>s.trim()).filter(Boolean),i=null,o=0;for(let s=0;s<r.length;s++){let l=r[s];if(l.startsWith("#")){i=l.substring(1).trim(),o++;continue}if(l.endsWith(";")){if(!i){t[`parse.noQuestion.line${s+1}`]=`Line ${s+1}: Found options without a preceding question (# question).`;continue}let c=l.slice(0,-1).trim(),d=c.match(/\[([^\]]+)\]/),u=[],p=c;d&&(u=d[1].split("|").map(w=>w.trim()).filter(Boolean),p=c.replace(/\[([^\]]+)\]/,"").trim());let h=p.split("|").map(b=>b.trim()).filter(Boolean),g=[...u,...h],m=new Set;for(let b of g){if(m.has(b)){t[`parse.duplicate.q${o}`]=`Question ${o}: Duplicate option "${b}" found.`;break}m.add(b)}n.push({question:i,correctOptions:u,options:g}),i=null}else t[`parse.missingSemicolon.line${s+1}`]=`Line ${s+1}: Options line must end with ';'.`}i&&(t["parse.danglingQuestion"]=`Question "${i}" has no options defined.`);let a={type:"recognition",data:n};return Object.keys(t).length>0?{data:a,errors:t}:{data:a}}function
|
|
1774
|
+
`,this.$modeLabel=this.querySelector(".mode-label"),this.$optionsContainer=this.querySelector(".options-container");let t=this.querySelector("#question-block");this.$questionBlock=document.createElement("edu-block"),this.$questionBlock.variant=this.config.variant,this.$questionBlock.innerHTML='<div class="question-text"></div>',t.appendChild(this.$questionBlock),this.$questionText=this.$questionBlock.querySelector(".question-text"),this.renderCurrentQuestion()}renderCurrentQuestion(){let t=this.data.data[this.currentQuestionIndex];if(!t)return;let r=t.correctOptions.length===1;this.$modeLabel.textContent=r?"Multiple Choice":"Multiple Response",Br(t.question,this.$questionText,this.assets?.assetsById);let i=this.shuffledOptions.get(t.question)||t.options;this.$optionsContainer.innerHTML="",i.forEach((o,a)=>{let s=document.createElement("edu-chip");s.variant=this.variant,s.prefix=`${a+1}:`,s.dataset.option=o,D(o,s,this.assets?.assetsById);let l=this.userAnswers[t.question]?.includes(o);if(l&&(s.selected=!0,s.classList.add("selected")),this.isGraded){let c=t.correctOptions.includes(o);l&&c?s.chipState="correct":l&&!c?s.chipState="wrong":!l&&c&&(s.chipState="missed")}this.isGraded||s.addEventListener("click",()=>{this.handleOptionClick(o,s,r)}),this.$optionsContainer.appendChild(s)})}handleOptionClick(t,r,i){let o=this.data.data[this.currentQuestionIndex],a=this.userAnswers[o.question];if(i){let s=a.includes(t);this.$optionsContainer.querySelectorAll("edu-chip").forEach(l=>{l.selected=!1,l.classList.remove("selected")}),this.userAnswers[o.question]=[],s||(r.selected=!0,r.classList.add("selected"),this.userAnswers[o.question]=[t])}else{let s=a.indexOf(t);s>-1?(a.splice(s,1),r.selected=!1,r.classList.remove("selected")):(a.push(t),r.selected=!0,r.classList.add("selected"))}this.updateProgress(),this.emitStateChange()}updateProgress(){let t=0;this.data.data.forEach(r=>{this.userAnswers[r.question]?.length>0&&t++}),this.setProgress(t)}getCurrentState(){return{...this.userAnswers}}isInteractionComplete(){return this.data.data.every(t=>this.userAnswers[t.question]?.length>0)}onHint(){let t=this.data.data[this.currentQuestionIndex];this.userAnswers[t.question]?.length>0?(alert("Hint: You've selected an answer. Review your choice and make sure it's correct before submitting."),this.emitHintShown(`Answer exists for question ${this.currentQuestionIndex+1}`)):(alert("Hint: This question requires at least one selection. Read the question carefully and choose the best answer(s)."),this.emitHintShown(`No answer selected for question ${this.currentQuestionIndex+1}`))}submit(){super.submit();let t=zr(this.data,this.userAnswers);console.log(`Recognition Score: ${t.score}% (${t.correct}/${t.total} questions fully correct)`),this.isGraded=!0,this.renderCurrentQuestion(),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0})),this.setAttribute("inert","")}reset(){super.reset(),this.data.data.forEach(t=>{this.userAnswers[t.question]=[]}),this.isGraded=!1,this.currentQuestionIndex=0,this.renderCurrentQuestion()}};customElements.get("mcq-interaction")||customElements.define("mcq-interaction",ee);function Hs(e){let n=[],t={},r=e.split(`
|
|
1775
|
+
`).map(s=>s.trim()).filter(Boolean),i=null,o=0;for(let s=0;s<r.length;s++){let l=r[s];if(l.startsWith("#")){i=l.substring(1).trim(),o++;continue}if(l.endsWith(";")){if(!i){t[`parse.noQuestion.line${s+1}`]=`Line ${s+1}: Found options without a preceding question (# question).`;continue}let c=l.slice(0,-1).trim(),d=c.match(/\[([^\]]+)\]/),u=[],p=c;d&&(u=d[1].split("|").map(w=>w.trim()).filter(Boolean),p=c.replace(/\[([^\]]+)\]/,"").trim());let h=p.split("|").map(b=>b.trim()).filter(Boolean),g=[...u,...h],m=new Set;for(let b of g){if(m.has(b)){t[`parse.duplicate.q${o}`]=`Question ${o}: Duplicate option "${b}" found.`;break}m.add(b)}n.push({question:i,correctOptions:u,options:g}),i=null}else t[`parse.missingSemicolon.line${s+1}`]=`Line ${s+1}: Options line must end with ';'.`}i&&(t["parse.danglingQuestion"]=`Question "${i}" has no options defined.`);let a={type:"recognition",data:n};return Object.keys(t).length>0?{data:a,errors:t}:{data:a}}function Gs(e){let n={};return!e.data||e.data.length===0?(n["validation.noQuestions"]="No questions found. Expected at least one question with format: # question\\n[correct] | incorrect;",{ok:!1,errors:n}):(e.data.forEach((t,r)=>{let i=r+1;if((!t.question||t.question.trim()==="")&&(n[`validation.emptyQuestion.q${i}`]=`Question ${i}: Question text cannot be empty.`),(!t.correctOptions||t.correctOptions.length===0)&&(n[`validation.noCorrectOptions.q${i}`]=`Question ${i}: Must have at least one correct answer. Use [correct] syntax.`),(!t.options||t.options.length<2)&&(n[`validation.insufficientOptions.q${i}`]=`Question ${i}: Must have at least 2 options (correct and incorrect).`),t.options&&t.options.forEach((o,a)=>{(!o||o.trim()==="")&&(n[`validation.emptyOption.q${i}.opt${a+1}`]=`Question ${i}, Option ${a+1}: Option text cannot be empty.`)}),t.correctOptions&&t.options&&t.correctOptions.forEach(o=>{t.options.includes(o)||(n[`validation.missingCorrectOption.q${i}`]=`Question ${i}: Correct option "${o}" not found in options array.`)}),t.options){let o=new Set;t.options.forEach(a=>{o.has(a)&&(n[`validation.duplicateOption.q${i}`]=`Question ${i}: Duplicate option "${a}" found.`),o.add(a)})}}),Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0})}function Hr(e,n,t){let r=0;for(let[a,s]of n.entries()){let l=t.querySelector(`[data-val="${a}"]`),c=e.find(d=>d.left===a);c&&c.right===s?(l.chipState="correct",r++):l.chipState="wrong"}let i=e.length,o=i>0?r/i*100:0;return console.log(`Association Score: ${o.toFixed(1)}% (${r}/${i} correct)`),{score:o,correct:r,total:i,answerKey:e,userResponse:n}}var Ce=class extends x{constructor(t,r,i,o){super(t,r,i);this.interactionMechanic="static";this.leftItems=[];this.rightItems=[];this.matched=new Map;this.matchColors=new Map;this.data.pairs.forEach(({left:a,right:s})=>{this.leftItems.push(a),this.rightItems.push(s)}),this.data.distractors&&this.rightItems.push(...this.data.distractors),this.config.shuffle&&(this.leftItems=S(this.leftItems),this.rightItems=S(this.rightItems)),this.initializeProgress(this.leftItems.length),this.currentColor=F[0]}initialize(){}cleanup(){}onVariantChange(t){this.querySelectorAll("edu-chip").forEach(r=>{r.variant!==void 0&&(r.variant=t)})}render(){this.innerHTML=`
|
|
1732
1776
|
<style>
|
|
1733
1777
|
simultaneous-association {
|
|
1734
1778
|
--current-color: #3b82f6;
|
|
@@ -1771,7 +1815,7 @@ overflow-x: hidden;`;let r=document.createElement("edu-media");r.setAttribute("t
|
|
|
1771
1815
|
.items-list {
|
|
1772
1816
|
display: grid;
|
|
1773
1817
|
grid-template-columns: 1fr;
|
|
1774
|
-
grid-auto-rows: minmax(
|
|
1818
|
+
grid-auto-rows: minmax(clamp(56px, 12cqh, 88px), 1fr);
|
|
1775
1819
|
gap: clamp(0.35rem, min(1.2cqw, 1.2cqh), 0.75rem);
|
|
1776
1820
|
min-height: 0;
|
|
1777
1821
|
height: 100%;
|
|
@@ -1823,7 +1867,7 @@ overflow-x: hidden;`;let r=document.createElement("edu-media");r.setAttribute("t
|
|
|
1823
1867
|
<div class="items-list" id="right-col" data-compact="${this.rightItems.length>=7}"></div>
|
|
1824
1868
|
</div>
|
|
1825
1869
|
</div>
|
|
1826
|
-
`,this.$leftCol=this.querySelector("#left-col"),this.$rightCol=this.querySelector("#right-col"),this.renderItems()}renderItems(){this.leftItems.forEach((t,r)=>{let i=document.createElement("edu-chip");i.variant=this.config.variant,D(t,i,this.assets?.assetsById),i.dataset.val=t,i.addEventListener("click",o=>{let a=o.currentTarget,s=a.dataset.val;if(this.currentSelected===s){a.selected=!1,this.currentSelected="",this.currentEl=null;return}if(this.matched.get(s)){let l=this.matched.get(s),c=this.querySelector(`[data-val="${l}"]`);a.color="",a.colored=!1,c.colored=!1,c.color="",this.matched.delete(s),this.matchColors.delete(s),this.decrementProgress(),this.emitStateChange();return}this.currentSelected&&(this.currentEl.selected=!1),this.currentSelected=s,this.currentEl=a,a.selected=!0}),this.$leftCol.append(i)}),this.rightItems.forEach((t,r)=>{let i=document.createElement("edu-chip");i.variant=this.config.variant,D(t,i,this.assets?.assetsById),i.dataset.val=t,i.dataset.colorIndex=`${r+1}`,i.addEventListener("click",o=>{let a=o.currentTarget,s=a.dataset.val;if(this.currentSelected===s){this.currentSelected="",this.currentEl=null,a.selected=!1;return}if(![...this.matched.values()].includes(s)){if(this.currentSelected)if(this.leftItems.includes(this.currentSelected)&&this.rightItems.includes(s)){let c=Number(a.dataset.colorIndex)%F.length,d=F[c];this.matched.set(this.currentSelected,s),this.matchColors.set(this.currentSelected,d),a.selected=!1,this.currentEl.selected=!1,a.color=d,a.colored=!0,this.currentEl.color=d,this.currentEl.colored=!0,this.incrementProgress(),this.emitStateChange(),this.currentSelected="",this.currentEl=null;return}else this.currentEl.selected=!1;this.currentSelected=s,this.currentEl=a,a.selected=!0}}),this.$rightCol.append(i)})}getCurrentState(){return{matched:Object.fromEntries(this.matched),progress:this.progressTracker.current}}isInteractionComplete(){return this.matched.size===this.leftItems.length}onHint(){let t=this.leftItems.filter(i=>!this.matched.has(i));if(t.length===0){alert('All items are matched! Click "Check" to submit.'),this.emitHintShown("All items matched");return}let r=t[0];alert(`Hint: You haven't matched "${r}" yet. Select it from the left, then select its match from the right.`),this.emitHintShown(`Unmatched: ${r}`)}submit(){super.submit();let t=
|
|
1870
|
+
`,this.$leftCol=this.querySelector("#left-col"),this.$rightCol=this.querySelector("#right-col"),this.renderItems()}renderItems(){this.leftItems.forEach((t,r)=>{let i=document.createElement("edu-chip");i.variant=this.config.variant,D(t,i,this.assets?.assetsById),i.dataset.val=t,i.addEventListener("click",o=>{let a=o.currentTarget,s=a.dataset.val;if(this.currentSelected===s){a.selected=!1,this.currentSelected="",this.currentEl=null;return}if(this.matched.get(s)){let l=this.matched.get(s),c=this.querySelector(`[data-val="${l}"]`);a.color="",a.colored=!1,c.colored=!1,c.color="",this.matched.delete(s),this.matchColors.delete(s),this.decrementProgress(),this.emitStateChange();return}this.currentSelected&&(this.currentEl.selected=!1),this.currentSelected=s,this.currentEl=a,a.selected=!0}),this.$leftCol.append(i)}),this.rightItems.forEach((t,r)=>{let i=document.createElement("edu-chip");i.variant=this.config.variant,D(t,i,this.assets?.assetsById),i.dataset.val=t,i.dataset.colorIndex=`${r+1}`,i.addEventListener("click",o=>{let a=o.currentTarget,s=a.dataset.val;if(this.currentSelected===s){this.currentSelected="",this.currentEl=null,a.selected=!1;return}if(![...this.matched.values()].includes(s)){if(this.currentSelected)if(this.leftItems.includes(this.currentSelected)&&this.rightItems.includes(s)){let c=Number(a.dataset.colorIndex)%F.length,d=F[c];this.matched.set(this.currentSelected,s),this.matchColors.set(this.currentSelected,d),a.selected=!1,this.currentEl.selected=!1,a.color=d,a.colored=!0,this.currentEl.color=d,this.currentEl.colored=!0,this.incrementProgress(),this.emitStateChange(),this.currentSelected="",this.currentEl=null;return}else this.currentEl.selected=!1;this.currentSelected=s,this.currentEl=a,a.selected=!0}}),this.$rightCol.append(i)})}getCurrentState(){return{matched:Object.fromEntries(this.matched),progress:this.progressTracker.current}}isInteractionComplete(){return this.matched.size===this.leftItems.length}onHint(){let t=this.leftItems.filter(i=>!this.matched.has(i));if(t.length===0){alert('All items are matched! Click "Check" to submit.'),this.emitHintShown("All items matched");return}let r=t[0];alert(`Hint: You haven't matched "${r}" yet. Select it from the left, then select its match from the right.`),this.emitHintShown(`Unmatched: ${r}`)}submit(){super.submit();let t=Hr(this.data.pairs,this.matched,this);this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0}))}reset(){super.reset(),this.matched.clear(),this.matchColors.clear(),this.currentSelected="",this.currentEl=null,this.querySelectorAll("edu-chip").forEach(t=>{t.classList.remove("colorized","selected"),t.style.setProperty("--current-color","")})}};customElements.get("simultaneous-association")||customElements.define("simultaneous-association",Ce);var te=class extends x{constructor(t,r){super(t,r);this.interactionMechanic="static";this._recalledItems=new Set;this.initializeProgress(t.items.length)}initialize(){}cleanup(){}onVariantChange(t){this._$textInput&&(this._$textInput.variant=t),this._$addButton&&(this._$addButton.variant=t),this._$chipsContainer?.querySelectorAll("edu-chip").forEach(r=>{r.variant=t})}render(){this.innerHTML=`
|
|
1827
1871
|
<style>
|
|
1828
1872
|
list-recall {
|
|
1829
1873
|
display: flex;
|
|
@@ -1839,8 +1883,8 @@ overflow-x: hidden;`;let r=document.createElement("edu-media");r.setAttribute("t
|
|
|
1839
1883
|
.chips-container {
|
|
1840
1884
|
flex: 1;
|
|
1841
1885
|
display: grid;
|
|
1842
|
-
grid-template-columns:
|
|
1843
|
-
grid-auto-rows: minmax(
|
|
1886
|
+
grid-template-columns: 1fr 1fr;
|
|
1887
|
+
grid-auto-rows: minmax(56px, auto);
|
|
1844
1888
|
gap: clamp(0.4rem, min(1.4cqw, 1.4cqh), 0.75rem);
|
|
1845
1889
|
padding: clamp(0.5rem, min(1.6cqw, 1.6cqh), 1rem);
|
|
1846
1890
|
border: 2px dashed rgb(var(--edu-border));
|
|
@@ -1903,7 +1947,7 @@ overflow-x: hidden;`;let r=document.createElement("edu-media");r.setAttribute("t
|
|
|
1903
1947
|
<edu-input type="text" placeholder="Enter an item..."></edu-input>
|
|
1904
1948
|
<edu-input as="button">Add</edu-input>
|
|
1905
1949
|
</div>
|
|
1906
|
-
`,this._$chipsContainer=this.querySelector(".chips-container"),this._$textInput=this.querySelector('edu-input[type="text"]'),this._$addButton=this.querySelector('edu-input[as="button"]'),this._$textInput.variant=this.config.variant,this._$addButton.variant=this.config.variant,this._$addButton.addEventListener("click",()=>this.handleAddItem()),this._$textInput.addEventListener("keydown",t=>{t.key==="Enter"&&(t.preventDefault(),this.handleAddItem())})}handleAddItem(){let t=this._$textInput.value.trim();if(!t)return;let r=t.toLowerCase();if(this._recalledItems.has(r)){alert("You have already added this item."),this._$textInput.value="";return}if(this._recalledItems.size>=this.data.items.length){alert(`You can only add up to ${this.data.items.length} items.`),this._$textInput.value="";return}this._recalledItems.add(r),this.addChip(t),this._$textInput.value="",this.setProgress(this._recalledItems.size),this.emitStateChange()}addChip(t){let r=document.createElement("edu-chip");r.textContent=t,r.variant=this.config.variant,r.value=t.toLowerCase(),r.addEventListener("click",()=>{let i=r.value;this._recalledItems.delete(i),r.remove(),this.setProgress(this._recalledItems.size),this.emitStateChange()}),this._$chipsContainer.appendChild(r)}getCurrentState(){return Array.from(this._recalledItems)}isInteractionComplete(){return this._recalledItems.size===this.data.items.length}onHint(){let t=this._recalledItems.size,r=this.data.items.length;t===0?(alert(`Hint: Try to recall all ${r} items from memory.`),this.emitHintShown("No items recalled yet")):t<r?(alert(`Hint: You've recalled ${t} out of ${r} items. Keep going!`),this.emitHintShown(`${t}/${r} items recalled`)):(alert(`Great! You've recalled all items. Click "Check" to submit.`),this.emitHintShown("All items recalled"))}submit(){super.submit();let t=this.gradeRecall();console.log(`List Recall Score: ${t.score.toFixed(1)}% (${t.correct}/${t.total} correct)`),this.applyGradingFeedback(t),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0}))}gradeRecall(){let t=this.data.items.map(s=>s.toLowerCase()),r=Array.from(this._recalledItems),i=0;for(let s of r)t.includes(s)&&i++;let o=this.data.items.length;return{score:o>0?Math.round(i/o*100):0,correct:i,total:o,answerKey:this.data.items,userResponse:r}}applyGradingFeedback(t){let r=this.data.items.map(o=>o.toLowerCase());this._$chipsContainer.querySelectorAll("edu-chip").forEach(o=>{let a=o.value;r.includes(a)?o.chipState="correct":o.chipState="wrong"})}reset(){super.reset(),this._recalledItems.clear(),this._$chipsContainer.innerHTML="";let t=this._$textInput.querySelector(".control");t&&(t.value=""),this.setProgress(0)}};customElements.get("list-recall")||customElements.define("list-recall",te);function tl(e){let n=[],t=[],r=new Map,i={},o=/^\s*(?<category>[A-Z_](?:[A-Z0-9_]* ?[A-Z0-9_]+)*)\s*=\s*(?<items>[^;]+?)\s*;\s*$/gm,a=[...e.matchAll(o)];a.length===0&&(i["parse.noMatches"]="No valid category entries found. Expected lines like: CATEGORY = item1 | item2;");let s=new Set;for(let c of a){let d=c.groups?.category??"",u=c.groups?.items??"",p=d.trim().toLowerCase();if(r.has(p)){i[`parse.duplicateCategory.${p}`]=`Duplicate category "${p}" was defined more than once. Merge them into a single entry.`;continue}let h=u.split("|").map(g=>g.replace(/\s+/g," ").trim()).filter(Boolean);if(h.length===0){i[`parse.emptyCategory.${p}`]=`Category "${p}" has no items. Expected at least one item before ';'.`,t.push(p),r.set(p,[]);continue}t.push(p);for(let g of h)s.has(g)||(s.add(g),n.push(g));r.set(p,h)}let l={rows:n,cols:t,answerKey:r};return Object.keys(i).length>0?{data:l,errors:i}:{data:l}}function rl(e){let n={},t=[],r=new Map,i=/^\s*(?<category>[a-z_](?:[a-z0-9_]* ?[a-z0-9_]+)*)\s*=\s*(?<values>[^;]+?)\s*;/gim,o=[...e.matchAll(i)];if(o.length===0)return n["parse.noMatches"]="No valid category entries found. Expected lines like: category = val1 | val2;",{data:{rows:[],cols:[],answerKey:{}},errors:n};let a=new Set;for(let d of o){let u=d.groups?.category??"",p=d.groups?.values??"",h=u.trim().toLowerCase();if(a.has(h)){n[`parse.duplicateCategory.${h}`]=`Duplicate category "${h}" was defined more than once.`;continue}a.add(h);let g=p.split("|").map(m=>m.trim()).filter(Boolean);t.push(h),r.set(h,g)}let s=t.length;for(let d of t){let u=r.get(d)??[],p=s-1;u.length!==p&&(n[`parse.valueCount.${d}`]=`Category "${d}" has ${u.length} values, but expected ${p} (n-1 where n=${s}).`)}let l={};for(let d=0;d<t.length;d++){let u=t[d],p=r.get(u)??[];l[u]={};let h=0;for(let g=0;g<t.length;g++){if(d===g)continue;let m=t[g],b=p[h],w=null;if(b!==void 0&&b!==""){let v=Number(b);w=isNaN(v)?b:v}l[u][m]=w,h++}}let c={rows:t,cols:t,answerKey:l};return Object.keys(n).length>0?{data:c,errors:n}:{data:c}}function il(e){let n={},t=[],r=[],i={},o=/^\s*=\s*(?<cols>[^;]+?)\s*;/m,a=e.match(o);if(!a)return n["parse.noHeader"]="Missing header line. Expected first line like: = col1 | col2 | col3;",{data:{rows:[],cols:[],answerKey:{}},errors:n};if(t=(a.groups?.cols??"").split("|").map(p=>p.trim()).filter(Boolean),t.length===0)return n["parse.emptyHeader"]='Header line has no columns. Expected at least one column after "=".',{data:{rows:[],cols:[],answerKey:{}},errors:n};let l=/^\s*(?<row>[^=]+?)\s*=\s*(?<values>[^;]+?)\s*;/gm,c=[...e.matchAll(l)],d=new Set;for(let p of c){let h=p.groups?.row??"",g=p.groups?.values??"";if(h.trim()==="")continue;let m=h.trim();if(d.has(m)){n[`parse.duplicateRow.${m}`]=`Duplicate row "${m}" was defined more than once.`;continue}d.add(m);let b=g.split("|").map(w=>w.trim()).filter(w=>w!=="");if(b.length!==t.length){n[`parse.valueCount.${m}`]=`Row "${m}" has ${b.length} values, but expected ${t.length} (matching column count).`;continue}r.push(m),i[m]={};for(let w=0;w<t.length;w++){let v=t[w],q=b[w];if(q==="-"){i[m][v]=null;continue}let K=null;if(q!==void 0&&q!==""){let xt=Number(q);K=isNaN(xt)?q:xt}i[m][v]=K}}r.length===0&&(n["parse.noRows"]="No data rows found. Expected at least one line like: row = val1 | val2;");let u={rows:r,cols:t,answerKey:i};return Object.keys(n).length>0?{data:u,errors:n}:{data:u}}function ol(e,n="classification"){let t={},r=e.answerKey;e.cols.length===0&&(t["cols.empty"]="No categories were found. Expected at least one CATEGORY = ... ; entry."),e.rows.length===0&&(t["rows.empty"]="No row items were found. Expected at least one item in any category.");for(let i of e.cols)e.rows.includes(i)&&(t[`cols.rowConflict.${i}`]=`Category "${i}" is also present as an item. Category labels cannot be used as row items.`);for(let i of e.cols){let o=r.get(i);if(!o){t[`answerKey.missing.${i}`]=`Category "${i}" has no entry in answerKey. This usually indicates a parser issue.`;continue}o.length===0&&(t[`answerKey.emptyCategory.${i}`]=`Category "${i}" has no items. Each category must include at least one item.`)}for(let[i,o]of r.entries()){let a=new Set;for(let s of o){if(a.has(s)){t[`answerKey.duplicateItem.${i}`]=`Category "${i}" includes duplicate item "${s}". Remove duplicates.`;break}a.add(s)}}if(n==="n-ary"){let i=new Map;for(let[o,a]of r.entries())for(let s of a){let l=i.get(s);l?l.push(o):i.set(s,[o])}for(let o of e.rows){let a=i.get(o)??[];if(a.length===0){t[`nary.unassigned.${o}`]=`Item "${o}" is not assigned to any category. In n-ary tables, every item must belong to exactly one category.`;continue}a.length>1&&(t[`nary.multiCategory.${o}`]=`Item "${o}" appears in multiple categories (${a.join(", ")}). In n-ary tables, items must belong to exactly one category.`)}}return Object.keys(t).length>0?{ok:!1,errors:t}:{ok:!0}}function al(e){let n={};if(e.rows.length===0&&(n["rows.empty"]="No rows found. Expected at least one category."),e.cols.length===0&&(n["cols.empty"]="No columns found. Expected at least one category."),e.rows.length!==e.cols.length)n["symmetry.lengthMismatch"]=`Rows (${e.rows.length}) and columns (${e.cols.length}) must have the same length for adjacency tables.`;else{let t=new Set(e.rows),r=new Set(e.cols);for(let i of e.rows)r.has(i)||(n[`symmetry.rowNotInCols.${i}`]=`Row "${i}" does not appear in columns. Adjacency tables must be symmetric.`);for(let i of e.cols)t.has(i)||(n[`symmetry.colNotInRows.${i}`]=`Column "${i}" does not appear in rows. Adjacency tables must be symmetric.`)}for(let t of e.rows){if(!e.answerKey[t]){n[`answerKey.missingRow.${t}`]=`Row "${t}" has no entry in answer key.`;continue}for(let r of e.cols)if(t===r){let i=e.answerKey[t][r];i!=null&&(n[`answerKey.diagonalValue.${t}`]=`Diagonal cell (${t}, ${t}) should be empty, but has value "${i}".`)}else e.answerKey[t][r]===void 0&&(n[`answerKey.missingCell.${t}.${r}`]=`Missing value at cell (${t}, ${r}). All non-diagonal cells must have values.`)}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0}}function sl(e){let n={};e.cols.length===0&&(n["cols.empty"]="No columns found. Expected at least one column in header line."),e.rows.length===0&&(n["rows.empty"]="No rows found. Expected at least one data row.");let t=new Set(e.cols);for(let r of e.rows)t.has(r)&&(n[`naming.rowColConflict.${r}`]=`Row name "${r}" is also a column name. This creates ambiguity and should be avoided.`);for(let r of e.rows){if(!e.answerKey[r]){n[`answerKey.missingRow.${r}`]=`Row "${r}" has no entry in answer key.`;continue}for(let i of e.cols)e.answerKey[r][i]===void 0&&(n[`answerKey.missingCell.${r}.${i}`]=`Missing value at cell (${r}, ${i}). Cells must have values or be marked as disabled with '-'.`)}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0}}function Ce(e){let n=[];for(let t of Object.values(e))for(let r of Object.values(t))r!==null&&n.push(r);return n}function Ue(e){let n=Ce(e);return Array.from(new Set(n))}function Ye(e){let n=new Set(e.filter(t=>t!==null));return e.every(t=>t===null||typeof t=="number")?"number":n.size>0&&n.size<=10?"select":"text"}function ke(e,n){return e===null||n===null?!1:typeof e=="number"&&typeof n=="number"?Math.abs(e-n)<1e-4:String(e).trim()===String(n).trim()}function qr(e,n,t){let r=0,i=t.length;for(let a of t){let s=n[a]?.selectedCols??[],l=null;for(let[c,d]of e.entries())if(d.includes(a)){l=c;break}s.length===1&&s[0]===l&&r++}return{score:i>0?Math.round(r/i*100):0,correct:r,total:i}}function zr(e,n,t,r){let i=0,o=0;for(let s of t)for(let l of r){let c=e[s]?.[l];if(c===null)continue;let d=n[s]?.values[l];o++,ke(c,d)&&i++}return{score:o>0?Math.round(i/o*100):0,correct:i,total:o}}function Hr(e,n,t,r){let i=0,o=0;for(let s of t){let l=new Set(n[s]?.selectedCols??[]),c=new Set;for(let[d,u]of e.entries())u.includes(s)&&c.add(d);for(let d of r){let u=c.has(d),p=l.has(d);u===p&&i++,o++}}return{score:o>0?Math.round(i/o*100):0,correct:i,total:o}}function Gr(e,n,t){let r=0,i=0;for(let a of t)for(let s of t){if(a===s)continue;let l=e[a]?.[s],c=n[a]?.values[s];i++,ke(l,c)&&r++}return{score:i>0?Math.round(r/i*100):0,correct:r,total:i}}function Nr(e,n,t){let r={};for(let i of t){r[i]={};for(let o of t){if(i===o)continue;let a=e[i]?.[o],s=n[i]?.values[o];s==null||s===""?r[i][o]="missed":ke(a,s)?r[i][o]="correct":r[i][o]="wrong"}}return r}function Or(e,n,t,r){let i={};for(let o of t){i[o]={};for(let a of r){let s=e[o]?.[a];if(s===null)continue;let l=n[o]?.values[a];l==null||l===""?i[o][a]="missed":ke(s,l)?i[o][a]="correct":i[o][a]="wrong"}}return i}function Vr(e,n,t,r){let i={};for(let o of t){i[o]={};let a=new Set(n[o]?.selectedCols??[]),s=new Set;for(let[l,c]of e.entries())c.includes(o)&&s.add(l);for(let l of r){let c=s.has(l),d=a.has(l);c===d?i[o][l]="correct":!d&&c?i[o][l]="missed":i[o][l]="wrong"}}return i}function Fr(e,n,t){let r={};for(let i of t){r[i]={};let o=n[i]?.selectedCols??[],a=null;for(let[s,l]of e.entries())if(l.includes(i)){a=s;break}if(o.length===1){let s=o[0];s===a?r[i][s]="correct":r[i][s]="wrong"}else o.length===0&&a&&(r[i][a]="missed")}return r}var jr=`/* ===========================================
|
|
1950
|
+
`,this._$chipsContainer=this.querySelector(".chips-container"),this._$textInput=this.querySelector('edu-input[type="text"]'),this._$addButton=this.querySelector('edu-input[as="button"]'),this._$textInput.variant=this.config.variant,this._$addButton.variant=this.config.variant,this._$addButton.addEventListener("click",()=>this.handleAddItem()),this._$textInput.addEventListener("keydown",t=>{t.key==="Enter"&&(t.preventDefault(),this.handleAddItem())})}handleAddItem(){let t=this._$textInput.value.trim();if(!t)return;let r=t.toLowerCase();if(this._recalledItems.has(r)){alert("You have already added this item."),this._$textInput.value="";return}if(this._recalledItems.size>=this.data.items.length){alert(`You can only add up to ${this.data.items.length} items.`),this._$textInput.value="";return}this._recalledItems.add(r),this.addChip(t),this._$textInput.value="",this.setProgress(this._recalledItems.size),this.emitStateChange()}addChip(t){let r=document.createElement("edu-chip");r.textContent=t,r.variant=this.config.variant,r.value=t.toLowerCase(),r.addEventListener("click",()=>{let i=r.value;this._recalledItems.delete(i),r.remove(),this.setProgress(this._recalledItems.size),this.emitStateChange()}),this._$chipsContainer.appendChild(r)}getCurrentState(){return Array.from(this._recalledItems)}isInteractionComplete(){return this._recalledItems.size===this.data.items.length}onHint(){let t=this._recalledItems.size,r=this.data.items.length;t===0?(alert(`Hint: Try to recall all ${r} items from memory.`),this.emitHintShown("No items recalled yet")):t<r?(alert(`Hint: You've recalled ${t} out of ${r} items. Keep going!`),this.emitHintShown(`${t}/${r} items recalled`)):(alert(`Great! You've recalled all items. Click "Check" to submit.`),this.emitHintShown("All items recalled"))}submit(){super.submit();let t=this.gradeRecall();console.log(`List Recall Score: ${t.score.toFixed(1)}% (${t.correct}/${t.total} correct)`),this.applyGradingFeedback(t),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0}))}gradeRecall(){let t=this.data.items.map(s=>s.toLowerCase()),r=Array.from(this._recalledItems),i=0;for(let s of r)t.includes(s)&&i++;let o=this.data.items.length;return{score:o>0?Math.round(i/o*100):0,correct:i,total:o,answerKey:this.data.items,userResponse:r}}applyGradingFeedback(t){let r=this.data.items.map(o=>o.toLowerCase());this._$chipsContainer.querySelectorAll("edu-chip").forEach(o=>{let a=o.value;r.includes(a)?o.chipState="correct":o.chipState="wrong"})}reset(){super.reset(),this._recalledItems.clear(),this._$chipsContainer.innerHTML="";let t=this._$textInput.querySelector(".control");t&&(t.value=""),this.setProgress(0)}};customElements.get("list-recall")||customElements.define("list-recall",te);function sl(e){let n=[],t=[],r=new Map,i={},o=/^\s*(?<category>[A-Z_](?:[A-Z0-9_]* ?[A-Z0-9_]+)*)\s*=\s*(?<items>[^;]+?)\s*;\s*$/gm,a=[...e.matchAll(o)];a.length===0&&(i["parse.noMatches"]="No valid category entries found. Expected lines like: CATEGORY = item1 | item2;");let s=new Set;for(let c of a){let d=c.groups?.category??"",u=c.groups?.items??"",p=d.trim().toLowerCase();if(r.has(p)){i[`parse.duplicateCategory.${p}`]=`Duplicate category "${p}" was defined more than once. Merge them into a single entry.`;continue}let h=u.split("|").map(g=>g.replace(/\s+/g," ").trim()).filter(Boolean);if(h.length===0){i[`parse.emptyCategory.${p}`]=`Category "${p}" has no items. Expected at least one item before ';'.`,t.push(p),r.set(p,[]);continue}t.push(p);for(let g of h)s.has(g)||(s.add(g),n.push(g));r.set(p,h)}let l={rows:n,cols:t,answerKey:r};return Object.keys(i).length>0?{data:l,errors:i}:{data:l}}function ll(e){let n={},t=[],r=new Map,i=/^\s*(?<category>[a-z_](?:[a-z0-9_]* ?[a-z0-9_]+)*)\s*=\s*(?<values>[^;]+?)\s*;/gim,o=[...e.matchAll(i)];if(o.length===0)return n["parse.noMatches"]="No valid category entries found. Expected lines like: category = val1 | val2;",{data:{rows:[],cols:[],answerKey:{}},errors:n};let a=new Set;for(let d of o){let u=d.groups?.category??"",p=d.groups?.values??"",h=u.trim().toLowerCase();if(a.has(h)){n[`parse.duplicateCategory.${h}`]=`Duplicate category "${h}" was defined more than once.`;continue}a.add(h);let g=p.split("|").map(m=>m.trim()).filter(Boolean);t.push(h),r.set(h,g)}let s=t.length;for(let d of t){let u=r.get(d)??[],p=s-1;u.length!==p&&(n[`parse.valueCount.${d}`]=`Category "${d}" has ${u.length} values, but expected ${p} (n-1 where n=${s}).`)}let l={};for(let d=0;d<t.length;d++){let u=t[d],p=r.get(u)??[];l[u]={};let h=0;for(let g=0;g<t.length;g++){if(d===g)continue;let m=t[g],b=p[h],w=null;if(b!==void 0&&b!==""){let v=Number(b);w=isNaN(v)?b:v}l[u][m]=w,h++}}let c={rows:t,cols:t,answerKey:l};return Object.keys(n).length>0?{data:c,errors:n}:{data:c}}function cl(e){let n={},t=[],r=[],i={},o=/^\s*=\s*(?<cols>[^;]+?)\s*;/m,a=e.match(o);if(!a)return n["parse.noHeader"]="Missing header line. Expected first line like: = col1 | col2 | col3;",{data:{rows:[],cols:[],answerKey:{}},errors:n};if(t=(a.groups?.cols??"").split("|").map(p=>p.trim()).filter(Boolean),t.length===0)return n["parse.emptyHeader"]='Header line has no columns. Expected at least one column after "=".',{data:{rows:[],cols:[],answerKey:{}},errors:n};let l=/^\s*(?<row>[^=]+?)\s*=\s*(?<values>[^;]+?)\s*;/gm,c=[...e.matchAll(l)],d=new Set;for(let p of c){let h=p.groups?.row??"",g=p.groups?.values??"";if(h.trim()==="")continue;let m=h.trim();if(d.has(m)){n[`parse.duplicateRow.${m}`]=`Duplicate row "${m}" was defined more than once.`;continue}d.add(m);let b=g.split("|").map(w=>w.trim()).filter(w=>w!=="");if(b.length!==t.length){n[`parse.valueCount.${m}`]=`Row "${m}" has ${b.length} values, but expected ${t.length} (matching column count).`;continue}r.push(m),i[m]={};for(let w=0;w<t.length;w++){let v=t[w],q=b[w];if(q==="-"){i[m][v]=null;continue}let K=null;if(q!==void 0&&q!==""){let Ct=Number(q);K=isNaN(Ct)?q:Ct}i[m][v]=K}}r.length===0&&(n["parse.noRows"]="No data rows found. Expected at least one line like: row = val1 | val2;");let u={rows:r,cols:t,answerKey:i};return Object.keys(n).length>0?{data:u,errors:n}:{data:u}}function ul(e,n="classification"){let t={},r=e.answerKey;e.cols.length===0&&(t["cols.empty"]="No categories were found. Expected at least one CATEGORY = ... ; entry."),e.rows.length===0&&(t["rows.empty"]="No row items were found. Expected at least one item in any category.");for(let i of e.cols)e.rows.includes(i)&&(t[`cols.rowConflict.${i}`]=`Category "${i}" is also present as an item. Category labels cannot be used as row items.`);for(let i of e.cols){let o=r.get(i);if(!o){t[`answerKey.missing.${i}`]=`Category "${i}" has no entry in answerKey. This usually indicates a parser issue.`;continue}o.length===0&&(t[`answerKey.emptyCategory.${i}`]=`Category "${i}" has no items. Each category must include at least one item.`)}for(let[i,o]of r.entries()){let a=new Set;for(let s of o){if(a.has(s)){t[`answerKey.duplicateItem.${i}`]=`Category "${i}" includes duplicate item "${s}". Remove duplicates.`;break}a.add(s)}}if(n==="n-ary"){let i=new Map;for(let[o,a]of r.entries())for(let s of a){let l=i.get(s);l?l.push(o):i.set(s,[o])}for(let o of e.rows){let a=i.get(o)??[];if(a.length===0){t[`nary.unassigned.${o}`]=`Item "${o}" is not assigned to any category. In n-ary tables, every item must belong to exactly one category.`;continue}a.length>1&&(t[`nary.multiCategory.${o}`]=`Item "${o}" appears in multiple categories (${a.join(", ")}). In n-ary tables, items must belong to exactly one category.`)}}return Object.keys(t).length>0?{ok:!1,errors:t}:{ok:!0}}function pl(e){let n={};if(e.rows.length===0&&(n["rows.empty"]="No rows found. Expected at least one category."),e.cols.length===0&&(n["cols.empty"]="No columns found. Expected at least one category."),e.rows.length!==e.cols.length)n["symmetry.lengthMismatch"]=`Rows (${e.rows.length}) and columns (${e.cols.length}) must have the same length for adjacency tables.`;else{let t=new Set(e.rows),r=new Set(e.cols);for(let i of e.rows)r.has(i)||(n[`symmetry.rowNotInCols.${i}`]=`Row "${i}" does not appear in columns. Adjacency tables must be symmetric.`);for(let i of e.cols)t.has(i)||(n[`symmetry.colNotInRows.${i}`]=`Column "${i}" does not appear in rows. Adjacency tables must be symmetric.`)}for(let t of e.rows){if(!e.answerKey[t]){n[`answerKey.missingRow.${t}`]=`Row "${t}" has no entry in answer key.`;continue}for(let r of e.cols)if(t===r){let i=e.answerKey[t][r];i!=null&&(n[`answerKey.diagonalValue.${t}`]=`Diagonal cell (${t}, ${t}) should be empty, but has value "${i}".`)}else e.answerKey[t][r]===void 0&&(n[`answerKey.missingCell.${t}.${r}`]=`Missing value at cell (${t}, ${r}). All non-diagonal cells must have values.`)}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0}}function hl(e){let n={};e.cols.length===0&&(n["cols.empty"]="No columns found. Expected at least one column in header line."),e.rows.length===0&&(n["rows.empty"]="No rows found. Expected at least one data row.");let t=new Set(e.cols);for(let r of e.rows)t.has(r)&&(n[`naming.rowColConflict.${r}`]=`Row name "${r}" is also a column name. This creates ambiguity and should be avoided.`);for(let r of e.rows){if(!e.answerKey[r]){n[`answerKey.missingRow.${r}`]=`Row "${r}" has no entry in answer key.`;continue}for(let i of e.cols)e.answerKey[r][i]===void 0&&(n[`answerKey.missingCell.${r}.${i}`]=`Missing value at cell (${r}, ${i}). Cells must have values or be marked as disabled with '-'.`)}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0}}function Ee(e){let n=[];for(let t of Object.values(e))for(let r of Object.values(t))r!==null&&n.push(r);return n}function Ke(e){let n=Ee(e);return Array.from(new Set(n))}function We(e){let n=new Set(e.filter(t=>t!==null));return e.every(t=>t===null||typeof t=="number")?"number":n.size>0&&n.size<=10?"select":"text"}function ke(e,n){return e===null||n===null?!1:typeof e=="number"&&typeof n=="number"?Math.abs(e-n)<1e-4:String(e).trim()===String(n).trim()}function Nr(e,n,t){let r=0,i=t.length;for(let a of t){let s=n[a]?.selectedCols??[],l=null;for(let[c,d]of e.entries())if(d.includes(a)){l=c;break}s.length===1&&s[0]===l&&r++}return{score:i>0?Math.round(r/i*100):0,correct:r,total:i}}function Gr(e,n,t,r){let i=0,o=0;for(let s of t)for(let l of r){let c=e[s]?.[l];if(c===null)continue;let d=n[s]?.values[l];o++,ke(c,d)&&i++}return{score:o>0?Math.round(i/o*100):0,correct:i,total:o}}function Or(e,n,t,r){let i=0,o=0;for(let s of t){let l=new Set(n[s]?.selectedCols??[]),c=new Set;for(let[d,u]of e.entries())u.includes(s)&&c.add(d);for(let d of r){let u=c.has(d),p=l.has(d);u===p&&i++,o++}}return{score:o>0?Math.round(i/o*100):0,correct:i,total:o}}function Vr(e,n,t){let r=0,i=0;for(let a of t)for(let s of t){if(a===s)continue;let l=e[a]?.[s],c=n[a]?.values[s];i++,ke(l,c)&&r++}return{score:i>0?Math.round(r/i*100):0,correct:r,total:i}}function Fr(e,n,t){let r={};for(let i of t){r[i]={};for(let o of t){if(i===o)continue;let a=e[i]?.[o],s=n[i]?.values[o];s==null||s===""?r[i][o]="missed":ke(a,s)?r[i][o]="correct":r[i][o]="wrong"}}return r}function jr(e,n,t,r){let i={};for(let o of t){i[o]={};for(let a of r){let s=e[o]?.[a];if(s===null)continue;let l=n[o]?.values[a];l==null||l===""?i[o][a]="missed":ke(s,l)?i[o][a]="correct":i[o][a]="wrong"}}return i}function Ur(e,n,t,r){let i={};for(let o of t){i[o]={};let a=new Set(n[o]?.selectedCols??[]),s=new Set;for(let[l,c]of e.entries())c.includes(o)&&s.add(l);for(let l of r){let c=s.has(l),d=a.has(l);c===d?i[o][l]="correct":!d&&c?i[o][l]="missed":i[o][l]="wrong"}}return i}function Yr(e,n,t){let r={};for(let i of t){r[i]={};let o=n[i]?.selectedCols??[],a=null;for(let[s,l]of e.entries())if(l.includes(i)){a=s;break}if(o.length===1){let s=o[0];s===a?r[i][s]="correct":r[i][s]="wrong"}else o.length===0&&a&&(r[i][a]="missed")}return r}var Kr=`/* ===========================================
|
|
1907
1951
|
BASE TABLE STYLES
|
|
1908
1952
|
=========================================== */
|
|
1909
1953
|
|
|
@@ -2446,19 +2490,19 @@ input[type="radio"] {
|
|
|
2446
2490
|
min-width: clamp(48px, 10cqw, 60px);
|
|
2447
2491
|
}
|
|
2448
2492
|
}
|
|
2449
|
-
`;function re(e){return E(e)}var
|
|
2493
|
+
`;function re(e){return E(e)}var Qe=class extends HTMLElement{constructor(){super();this._state={};this._mounted=!1;this.onChange=t=>{let r=t.target,i=r.getAttribute?.("data-r"),o=r.getAttribute?.("data-c");if(!i||!o||!this._config)return;let a=this._config.cellKind,s=null;r instanceof HTMLInputElement&&(a==="checkbox"||a==="radio"?s=r.checked:a==="text"?s=r.value:a==="number"&&(s=r.value===""?null:Number(r.value))),r instanceof HTMLSelectElement&&(s=r.value===""?null:r.value),this.applyCellValue(i,o,s),this.emitChange(i,o,s)};this.onInput=t=>{};this.attachShadow({mode:"open"});let t=document.createElement("section");t.className="wrap",this.shadowRoot.append(t),this.$wrapEl=t}static get observedAttributes(){return["variant"]}connectedCallback(){this._mounted=!0,this.shadowRoot?.addEventListener("change",this.onChange),this.shadowRoot?.addEventListener("input",this.onInput),this.render()}disconnectedCallback(){this._mounted=!1}set config(t){this._config=t,this._state=this.initState(t),t.variant&&this.setAttribute("variant",t.variant),this.render()}get config(){if(!this._config)throw new Error("<edu-table>: spec not set");return this._config}get value(){return this._state}set value(t){this._state=t,this.render()}getValue(){return this._state}setValue(t){this._state=t,this.render()}getState(){let t=this._config;if(!t)return{};let r={};for(let i of t.rows){let o=this._state[i]??{},a=[];for(let s of t.cols){let l=o[s]??null;(t.cellKind==="checkbox"||t.cellKind==="radio")&&l===!0&&a.push(s)}r[i]={selectedCols:a,values:{...o}}}return r}attributeChangedCallback(t,r,i){r!==i&&t==="variant"&&(this.setAttribute("variant",i),this.$wrapEl.querySelectorAll("edu-input").forEach(o=>{o.setAttribute("variant",i)}))}initState(t){let r={};for(let i of t.rows){r[i]={};for(let o of t.cols)switch(t.cellKind){case"checkbox":case"radio":r[i][o]=!1;break;case"select":case"text":case"number":r[i][o]=null;break}}return r}render(){if(!this._mounted||!this.shadowRoot)return;if(!this._config){this.$wrapEl.innerHTML="<style>:host{display:block}</style><div></div>";return}let t=this._config,r=t.shuffle?S(t.cols):t.cols,i=`
|
|
2450
2494
|
<tr>
|
|
2451
2495
|
<th></th>
|
|
2452
2496
|
${r.map(s=>`<th scope="col">${E(s)}</th>`).join("")}
|
|
2453
2497
|
</tr>
|
|
2454
|
-
`,a=(t.shuffle?
|
|
2455
|
-
<style>${
|
|
2498
|
+
`,a=(t.shuffle?S(t.rows):t.rows).map(s=>{let l=r.map(c=>this.renderCell(t,s,c)).join("");return`<tr><th scope="row">${E(s)}</th>${l}</tr>`}).join("");this.$wrapEl.innerHTML=`
|
|
2499
|
+
<style>${Kr}</style>
|
|
2456
2500
|
<table part="table">
|
|
2457
2501
|
<thead>${i}</thead>
|
|
2458
2502
|
<tbody>${a}</tbody>
|
|
2459
2503
|
</table>
|
|
2460
2504
|
`}renderCell(t,r,i){if(t.disabled?.(r,i)??!1)return'<td aria-disabled="true" class="disabled-cell"></td>';let a=`cell-${P(r)}-${P(i)}`,s=this._state[r]?.[i]??null,l=t.gradingState?.[r]?.[i],c=l?`cell-${l}`:"",d=p=>`<td class="${c}">${p}</td>`,u=`id="${a}" data-r="${re(r)}" data-c="${re(i)}"
|
|
2461
|
-
aria-label="${re(`${r} / ${i}`)}" variant="${this.getAttribute("variant")}" `;switch(t.cellKind){case"checkbox":return d(`<input ${u} type="checkbox" ${s===!0?"checked":""}/>`);case"radio":{let p=s===!0?"checked":"";return d(`<input ${u} type="radio" name="row-${P(r)}" ${p}/>`)}case"text":{let p=s==null?"":String(s);return d(`<edu-input ${u} type="text" value="${re(p)}"/>`)}case"number":{let p=s==null?"":String(s);return d(`<edu-input ${u} type="number" value="${re(p)}"/>`)}case"select":{let p=t.allowed?.(r,i)??[],h=s==null?"":String(s),g=['<option value=""></option>',...p.map(m=>{let b=String(m),w=b===h?"selected":"";return`<option value="${re(b)}" ${w}>${E(b)}</option>`})].join("");return d(`<edu-input as="select" ${u}>${g}</select>`)}}}reset(){this._config&&(this._state=this.initState(this._config),this.render(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0})))}setGradingState(t){this._config&&(this._config.gradingState=t,this.render())}clearGradingState(){this._config&&(this._config.gradingState=void 0,this.render())}applyCellValue(t,r,i){let o=this._config;if(o&&!o.disabled?.(t,r)){if(o.cellKind==="select"){let a=o.allowed?.(t,r);if(a&&i!==null&&!a.some(s=>String(s)===String(i)))return}if(this._state[t]??={},this._config.cellKind==="radio"&&i===!0){for(let a of this._config.cols)this._state[t][a]=!1;this._state[t][r]=!0;return}this._state[t][r]=i}}emitChange(t,r,i){let o={row:t,col:r,value:i,state:this.getValue(),selection:this.getState()};this.dispatchEvent(new CustomEvent("change",{detail:o,bubbles:!0,composed:!0}))}};customElements.get("edu-table")||customElements.define("edu-table",
|
|
2505
|
+
aria-label="${re(`${r} / ${i}`)}" variant="${this.getAttribute("variant")}" `;switch(t.cellKind){case"checkbox":return d(`<input ${u} type="checkbox" ${s===!0?"checked":""}/>`);case"radio":{let p=s===!0?"checked":"";return d(`<input ${u} type="radio" name="row-${P(r)}" ${p}/>`)}case"text":{let p=s==null?"":String(s);return d(`<edu-input ${u} type="text" value="${re(p)}"/>`)}case"number":{let p=s==null?"":String(s);return d(`<edu-input ${u} type="number" value="${re(p)}"/>`)}case"select":{let p=t.allowed?.(r,i)??[],h=s==null?"":String(s),g=['<option value=""></option>',...p.map(m=>{let b=String(m),w=b===h?"selected":"";return`<option value="${re(b)}" ${w}>${E(b)}</option>`})].join("");return d(`<edu-input as="select" ${u}>${g}</select>`)}}}reset(){this._config&&(this._state=this.initState(this._config),this.render(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0})))}setGradingState(t){this._config&&(this._config.gradingState=t,this.render())}clearGradingState(){this._config&&(this._config.gradingState=void 0,this.render())}applyCellValue(t,r,i){let o=this._config;if(o&&!o.disabled?.(t,r)){if(o.cellKind==="select"){let a=o.allowed?.(t,r);if(a&&i!==null&&!a.some(s=>String(s)===String(i)))return}if(this._state[t]??={},this._config.cellKind==="radio"&&i===!0){for(let a of this._config.cols)this._state[t][a]=!1;this._state[t][r]=!0;return}this._state[t][r]=i}}emitChange(t,r,i){let o={row:t,col:r,value:i,state:this.getValue(),selection:this.getState()};this.dispatchEvent(new CustomEvent("change",{detail:o,bubbles:!0,composed:!0}))}};customElements.get("edu-table")||customElements.define("edu-table",Qe);var Se=class extends x{constructor(t,r){super(t,r);this.interactionMechanic="static";let i=Ee(t.answerKey),o=We(i);this._tableConfig={rows:t.rows,cols:t.cols,answerKey:t.answerKey,cellKind:o,preset:"lookup",disabled:(s,l)=>t.answerKey[s]?.[l]===null,allowed:o==="select"?()=>Ke(t.answerKey):void 0,variant:r.variant??"outline",shuffle:r.shuffle??!1};let a=0;for(let s of t.rows)for(let l of t.cols)t.answerKey[s]?.[l]!==null&&a++;this.initializeProgress(a)}initialize(){}cleanup(){}onVariantChange(t){this._tableConfig.variant=t,this._$table&&this._$table.setAttribute("variant",t)}render(){this._tableConfig.variant=this.config.variant,this._$table=document.createElement("edu-table"),this._$table.config=this._tableConfig,this._$table.addEventListener("change",()=>{this.updateProgressBasedOnCompletion(),this.emitStateChange()}),this.innerHTML=`
|
|
2462
2506
|
<style>
|
|
2463
2507
|
:host {
|
|
2464
2508
|
display: flex;
|
|
@@ -2487,7 +2531,7 @@ input[type="radio"] {
|
|
|
2487
2531
|
<div class="table-container">
|
|
2488
2532
|
<div class="table-wrapper"></div>
|
|
2489
2533
|
</div>
|
|
2490
|
-
`,this.querySelector(".table-wrapper").appendChild(this._$table)}updateProgressBasedOnCompletion(){let t=this._$table.getState(),r=0;for(let i of this.data.rows)for(let o of this.data.cols){if(this.data.answerKey[i]?.[o]===null)continue;let a=t[i]?.values[o];a!=null&&a!==""&&r++}this.setProgress(r)}getCurrentState(){return this._$table.getState()}isInteractionComplete(){let t=this._$table.getState();for(let r of this.data.rows)for(let i of this.data.cols){if(this.data.answerKey[r]?.[i]===null)continue;let o=t[r]?.values[i];if(o==null||o==="")return!1}return!0}onHint(){let t=this._$table.getState();for(let r of this.data.rows)for(let i of this.data.cols){if(this.data.answerKey[r]?.[i]===null)continue;let o=t[r]?.values[i];if(o==null||o===""){alert(`Hint: You haven't filled the cell for "${r}" / "${i}" yet.`),this.emitHintShown(`Empty cell: ${r} / ${i}`);return}}alert('All cells are complete! Click "Check" to submit.'),this.emitHintShown("All cells complete")}submit(){super.submit();let t=this.getCurrentState(),r=
|
|
2534
|
+
`,this.querySelector(".table-wrapper").appendChild(this._$table)}updateProgressBasedOnCompletion(){let t=this._$table.getState(),r=0;for(let i of this.data.rows)for(let o of this.data.cols){if(this.data.answerKey[i]?.[o]===null)continue;let a=t[i]?.values[o];a!=null&&a!==""&&r++}this.setProgress(r)}getCurrentState(){return this._$table.getState()}isInteractionComplete(){let t=this._$table.getState();for(let r of this.data.rows)for(let i of this.data.cols){if(this.data.answerKey[r]?.[i]===null)continue;let o=t[r]?.values[i];if(o==null||o==="")return!1}return!0}onHint(){let t=this._$table.getState();for(let r of this.data.rows)for(let i of this.data.cols){if(this.data.answerKey[r]?.[i]===null)continue;let o=t[r]?.values[i];if(o==null||o===""){alert(`Hint: You haven't filled the cell for "${r}" / "${i}" yet.`),this.emitHintShown(`Empty cell: ${r} / ${i}`);return}}alert('All cells are complete! Click "Check" to submit.'),this.emitHintShown("All cells complete")}submit(){super.submit();let t=this.getCurrentState(),r=Gr(this.data.answerKey,t,this.data.rows,this.data.cols),i=jr(this.data.answerKey,t,this.data.rows,this.data.cols);this._$table.setGradingState(i),console.log(`Lookup Table Score: ${r.score.toFixed(1)}% (${r.correct}/${r.total} correct)`),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:r},bubbles:!0,composed:!0}))}reset(){super.reset(),this._$table&&(this._$table.reset(),this._$table.clearGradingState())}};customElements.get("lookup-table")||customElements.define("lookup-table",Se);var Te=class extends x{constructor(t,r){super(t,r);this.interactionMechanic="static";this._tableConfig={rows:t.rows,cols:t.cols,answerKey:t.answerKey,cellKind:"checkbox",preset:"classification",variant:r.variant??"outline",shuffle:r.shuffle},this.initializeProgress(t.rows.length)}initialize(){}cleanup(){}onVariantChange(t){this._tableConfig.variant=t,this._$table&&this._$table.setAttribute("variant",t)}render(){this._tableConfig.variant=this.config.variant,this._$table=document.createElement("edu-table"),this._$table.config=this._tableConfig,this._$table.addEventListener("change",()=>{this.updateProgressBasedOnCompletion(),this.emitStateChange()}),this.innerHTML="",this.appendChild(this._$table)}updateProgressBasedOnCompletion(){let t=this._$table.getState(),r=0;for(let i of this.data.rows)t[i]?.selectedCols.length>0&&r++;this.setProgress(r)}getCurrentState(){return this._$table.getState()}isInteractionComplete(){let t=this._$table.getState();return this.data.rows.every(r=>t[r]?.selectedCols.length>0)}onHint(){let t=this._$table.getState(),r=this.data.rows.filter(o=>!t[o]||t[o].selectedCols.length===0);if(r.length===0){alert('All rows are complete! Click "Check" to submit.'),this.emitHintShown("All rows complete");return}let i=r[0];alert(`Hint: You haven't classified "${i}" yet. Which categories does it belong to?`),this.emitHintShown(`Incomplete row: ${i}`)}submit(){super.submit();let t=this.getCurrentState(),r=Or(this.data.answerKey,t,this.data.rows,this.data.cols),i=Ur(this.data.answerKey,t,this.data.rows,this.data.cols);this._$table.setGradingState(i),console.log(`Classification Score: ${r.score.toFixed(1)}% (${r.correct}/${r.total} correct)`),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:r},bubbles:!0,composed:!0}))}reset(){super.reset(),this._$table&&(this._$table.reset(),this._$table.clearGradingState())}};customElements.get("classification-matrix")||customElements.define("classification-matrix",Te);var $e=class extends x{constructor(t,r){super(t,r);this.interactionMechanic="static";this._tableConfig={rows:t.rows,cols:t.cols,answerKey:t.answerKey,cellKind:"radio",preset:"n-ary",variant:r.variant??"outline",shuffle:!0},this.initializeProgress(t.rows.length)}initialize(){}cleanup(){}onVariantChange(t){this._tableConfig.variant=t,this._$table&&this._$table.setAttribute("variant",t)}render(){this._tableConfig.variant=this.config.variant,this._$table=document.createElement("edu-table"),this._$table.config=this._tableConfig,this._$table.addEventListener("change",()=>{this.updateProgressBasedOnCompletion(),this.emitStateChange()}),this.innerHTML=`
|
|
2491
2535
|
<style>
|
|
2492
2536
|
nary-choice-table {
|
|
2493
2537
|
display: flex;
|
|
@@ -2516,7 +2560,7 @@ input[type="radio"] {
|
|
|
2516
2560
|
<div class="table-container">
|
|
2517
2561
|
<div class="table-wrapper"></div>
|
|
2518
2562
|
</div>
|
|
2519
|
-
`,this.querySelector(".table-wrapper").appendChild(this._$table)}updateProgressBasedOnCompletion(){let t=this._$table.getState(),r=0;for(let i of this.data.rows)t[i]?.selectedCols.length===1&&r++;this.setProgress(r)}getCurrentState(){return this._$table.getState()}isInteractionComplete(){let t=this._$table.getState();return this.data.rows.every(r=>t[r]?.selectedCols.length===1)}onHint(){let t=this._$table.getState(),r=this.data.rows.filter(o=>!t[o]||t[o].selectedCols.length!==1);if(r.length===0){alert('All rows are complete! Click "Check" to submit.'),this.emitHintShown("All rows complete");return}let i=r[0];alert(`Hint: You haven't selected a category for "${i}" yet. Which one does it belong to?`),this.emitHintShown(`Incomplete row: ${i}`)}submit(){super.submit();let t=this.getCurrentState(),r=
|
|
2563
|
+
`,this.querySelector(".table-wrapper").appendChild(this._$table)}updateProgressBasedOnCompletion(){let t=this._$table.getState(),r=0;for(let i of this.data.rows)t[i]?.selectedCols.length===1&&r++;this.setProgress(r)}getCurrentState(){return this._$table.getState()}isInteractionComplete(){let t=this._$table.getState();return this.data.rows.every(r=>t[r]?.selectedCols.length===1)}onHint(){let t=this._$table.getState(),r=this.data.rows.filter(o=>!t[o]||t[o].selectedCols.length!==1);if(r.length===0){alert('All rows are complete! Click "Check" to submit.'),this.emitHintShown("All rows complete");return}let i=r[0];alert(`Hint: You haven't selected a category for "${i}" yet. Which one does it belong to?`),this.emitHintShown(`Incomplete row: ${i}`)}submit(){super.submit();let t=this.getCurrentState(),r=Nr(this.data.answerKey,t,this.data.rows),i=Yr(this.data.answerKey,t,this.data.rows);this._$table.setGradingState(i),console.log(`N-ary Choice Score: ${r.score.toFixed(1)}% (${r.correct}/${r.total} correct)`),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:r},bubbles:!0,composed:!0}))}reset(){super.reset(),this._$table&&(this._$table.reset(),this._$table.clearGradingState())}};customElements.get("nary-choice-table")||customElements.define("nary-choice-table",$e);var Ae=class extends x{constructor(t,r){super(t,r);this.interactionMechanic="static";let i=Ee(t.answerKey),o=We(i);this._tableConfig={rows:t.rows,cols:t.cols,answerKey:t.answerKey,cellKind:o,preset:"adjacency",disabled:(s,l)=>s===l,allowed:o==="select"?()=>Ke(t.answerKey):void 0,variant:r.variant??"outline",shuffle:r.shuffle??!1};let a=t.rows.length*(t.rows.length-1);this.initializeProgress(a)}initialize(){}cleanup(){}onVariantChange(t){this._tableConfig.variant=t,this._$table&&this._$table.setAttribute("variant",t)}render(){this._tableConfig.variant=this.config.variant,this._$table=document.createElement("edu-table"),this._$table.config=this._tableConfig,this._$table.addEventListener("change",()=>{this.updateProgressBasedOnCompletion(),this.emitStateChange()}),this.innerHTML=`
|
|
2520
2564
|
<style>
|
|
2521
2565
|
:host {
|
|
2522
2566
|
display: flex;
|
|
@@ -2545,10 +2589,10 @@ input[type="radio"] {
|
|
|
2545
2589
|
<div class="table-container">
|
|
2546
2590
|
<div class="table-wrapper"></div>
|
|
2547
2591
|
</div>
|
|
2548
|
-
`,this.querySelector(".table-wrapper").appendChild(this._$table)}updateProgressBasedOnCompletion(){let t=this._$table.getState(),r=0;for(let i of this.data.rows)for(let o of this.data.cols){if(i===o)continue;let a=t[i]?.values[o];a!=null&&a!==""&&r++}this.setProgress(r)}getCurrentState(){return this._$table.getState()}isInteractionComplete(){let t=this._$table.getState();for(let r of this.data.rows)for(let i of this.data.cols){if(r===i)continue;let o=t[r]?.values[i];if(o==null||o==="")return!1}return!0}onHint(){let t=this._$table.getState();for(let r of this.data.rows)for(let i of this.data.cols){if(r===i)continue;let o=t[r]?.values[i];if(o==null||o===""){alert(`Hint: You haven't filled the cell for "${r}" \u2192 "${i}" yet.`),this.emitHintShown(`Empty cell: ${r} \u2192 ${i}`);return}}alert('All cells are complete! Click "Check" to submit.'),this.emitHintShown("All cells complete")}submit(){super.submit();let t=this.getCurrentState(),r=
|
|
2549
|
-
`||p===" "||p==="\r"){if(s.trim().length>0){let h=s.trim();l&&c.words.push(h),n.push(h),s=""}d++;continue}s+=p,d++}if(s.trim().length>0){let p=s.trim();l&&(c.words.push(p),c.endPos=n.length,t.push(c)),n.push(p)}l&&(r.unclosed="Unclosed opening bracket '['. Expected ']'.");let u=Object.keys(r).length>0;return{ok:!u,data:{type:"base",parts:n,targets:t,...i&&{distractors:i}},errors:u?r:null}},
|
|
2550
|
-
`||s===" "||s==="\r"){i.trim().length>0&&(t.push(i.trim()),i=""),o++;continue}i+=s,o++;continue}i.trim().length>0&&(t.push(i.trim()),i="");let l=o;o++;let c="";for(;o<e.length&&/[a-z]/i.test(e[o]);)c+=e[o++];if(!c||!
|
|
2551
|
-
`||l===" "||l==="\r"){i.trim().length>0&&(n.push(i.trim()),i=""),o++;continue}i+=l,o++;continue}i.trim().length>0&&(n.push(i.trim()),i="");let c=o;o++;let d="";for(;o<e.length&&/[a-z]/i.test(e[o]);)d+=e[o++];if(d!=="ct"){t[`at:${c}`]=`Invalid reference "@${d}". Expected "@ct" for classification.`;continue}if(o>=e.length||e[o]!=="("){t[`at:${c}`]=`Expected '(' after @ct at position ${o}.`;continue}o++;let u="",p=!1;for(;o<e.length;){if(e[o]===")"){p=!0,o++;break}u+=e[o++]}if(!p){t[`at:${c}`]="Unclosed parenthesis for @ct. Expected ')'.";continue}let h=u.split(",").map(K=>K.trim());if(h.length!==2){t[`at:${c}`]=`Invalid @ct syntax. Expected: @ct(category, word). Got: @ct(${u})`;continue}let[g,m]=h;if(!g||!m){t[`at:${c}`]=`Category and word cannot be empty in @ct(${u}).`;continue}let b=m.split(/\s+/).filter(Boolean),w=n.length;for(let K of b)n.push(K);let v=n.length-1,q={words:b,startPos:w,endPos:v};r.has(g)||r.set(g,[]),r.get(g).push(q)}i.trim().length>0&&n.push(i.trim());let a=[];for(let[l,c]of r.entries())a.push({category:l,targets:c});let s=Object.keys(t).length>0;return{ok:!s,data:{type:"classification",parts:n,targets:a},errors:s?t:null}},ra={base:Jr,blanks:ei,classification:ti};function ia(e,n){let t=Zr(e),r=ra[n],i=[],o=[];for(let a of t){let s=r(a);if(!s.ok){s.errors&&(Array.isArray(s.errors)?o.push(...s.errors):o.push(s.errors));continue}i.push(s.data)}return o.length>0?{ok:!1,data:null,errors:o}:{ok:!0,data:i,errors:null}}function ri(e){let n={};if((!e.parts||e.parts.length===0)&&(n["parts.empty"]="No parts found. Text must contain at least one word."),(!e.targets||e.targets.length===0)&&(n["targets.empty"]="No targets found. Text must contain at least one [target] to interact with."),e.targets&&e.targets.length>0&&e.parts&&e.parts.length>0)for(let t=0;t<e.targets.length;t++){let r=e.targets[t],i=`targets[${t}]`;if(!r.words||r.words.length===0){n[`${i}.words.empty`]=`Target ${t} has no words. Each target must contain at least one word.`;continue}if(r.startPos<0&&(n[`${i}.startPos.negative`]=`Target ${t} has negative startPos (${r.startPos}).`),r.endPos<0&&(n[`${i}.endPos.negative`]=`Target ${t} has negative endPos (${r.endPos}).`),r.startPos>r.endPos&&(n[`${i}.position.invalid`]=`Target ${t} has startPos (${r.startPos}) greater than endPos (${r.endPos}).`),r.startPos>=e.parts.length&&(n[`${i}.startPos.outOfBounds`]=`Target ${t} startPos (${r.startPos}) is out of bounds (parts length: ${e.parts.length}).`),r.endPos>=e.parts.length&&(n[`${i}.endPos.outOfBounds`]=`Target ${t} endPos (${r.endPos}) is out of bounds (parts length: ${e.parts.length}).`),r.startPos<e.parts.length&&r.endPos<e.parts.length){let o=r.endPos-r.startPos+1;r.words.length!==o&&(n[`${i}.words.countMismatch`]=`Target ${t} has ${r.words.length} words but position range indicates ${o} words.`);for(let a=0;a<r.words.length;a++){let s=r.startPos+a;if(s<e.parts.length){let l=e.parts[s],c=r.words[a];l!==c&&(n[`${i}.words[${a}].mismatch`]=`Target ${t} word "${c}" doesn't match part at position ${s}: "${l}".`)}}}}if(e.distractors)if(!Array.isArray(e.distractors))n["distractors.notArray"]="Distractors must be an array.";else{e.distractors.length===0&&(n["distractors.empty"]="Distractors array is empty. Remove distractors field or add at least one distractor.");let t=new Set;for(let r=0;r<e.distractors.length;r++){let i=e.distractors[r];t.has(i)&&(n[`distractors[${r}].duplicate`]=`Duplicate distractor found: "${i}".`),t.add(i),(!i||i.trim().length===0)&&(n[`distractors[${r}].empty`]=`Distractor at index ${r} is empty.`)}}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0,errors:null}}function ii(e){let n={};(!e.parts||e.parts.length===0)&&(n["parts.empty"]="No parts found. Text must contain at least one part."),(!e.targets||e.targets.length===0)&&(n["targets.empty"]="No targets found. Text must contain at least one input element (@tx, @nm, @sl, @dt, @tm).");let t=new Set;if(e.targets&&e.targets.length>0)for(let r=0;r<e.targets.length;r++){let i=e.targets[r],o=`targets[${r}]`;if(!i.id||i.id.trim().length===0?n[`${o}.id.empty`]=`Target ${r} has no ID. Each input element must have a unique ID.`:(t.has(i.id)&&(n[`${o}.id.duplicate`]=`Duplicate ID found: "${i.id}". Each input element must have a unique ID.`),t.add(i.id)),!i.expectedValue){n[`${o}.expectedValue.missing`]=`Target ${r} has no expectedValue. Each input element must define expected answer data.`;continue}let a=i.expectedValue;a.type||(n[`${o}.expectedValue.type.missing`]=`Target ${r} expectedValue has no type field.`),a.id||(n[`${o}.expectedValue.id.missing`]=`Target ${r} expectedValue has no id field.`),a.html||(n[`${o}.expectedValue.html.missing`]=`Target ${r} expectedValue has no html field.`);let s=a.type;if(s)switch(s){case"text":(!("value"in a)||!Array.isArray(a.value))&&(n[`${o}.expectedValue.text.value`]=`Target ${r} is type 'text' but has no valid 'value' array.`);break;case"number":"targets"in a||(n[`${o}.expectedValue.number.targets`]=`Target ${r} is type 'number' but has no 'targets' field.`);break;case"select":(!("correctOptions"in a)||!("options"in a))&&(n[`${o}.expectedValue.select.options`]=`Target ${r} is type 'select' but is missing 'correctOptions' or 'options' fields.`);break;case"date":case"time":"value"in a||(n[`${o}.expectedValue.${s}.value`]=`Target ${r} is type '${s}' but has no 'value' field.`);break}}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0,errors:null}}function ni(e){let n={};(!e.parts||e.parts.length===0)&&(n["parts.empty"]="No parts found. Text must contain at least one word."),(!e.targets||e.targets.length===0)&&(n["targets.empty"]="No categories found. Text must contain at least one @ct(category, word) reference.");let t=new Set;if(e.targets&&e.targets.length>0)for(let r=0;r<e.targets.length;r++){let i=e.targets[r],o=`targets[${r}]`;if(!i.category||i.category.trim().length===0?n[`${o}.category.empty`]=`Category ${r} has no name.`:(t.has(i.category)&&(n[`${o}.category.duplicate`]=`Duplicate category found: "${i.category}". Each category must have a unique name.`),t.add(i.category)),!i.targets||i.targets.length===0){n[`${o}.targets.empty`]=`Category "${i.category}" has no targets. Each category must contain at least one word.`;continue}for(let a=0;a<i.targets.length;a++){let s=i.targets[a],l=`${o}.targets[${a}]`;if(!s.words||s.words.length===0){n[`${l}.words.empty`]=`Category "${i.category}" target ${a} has no words.`;continue}if(s.startPos<0&&(n[`${l}.startPos.negative`]=`Category "${i.category}" target ${a} has negative startPos.`),s.endPos<0&&(n[`${l}.endPos.negative`]=`Category "${i.category}" target ${a} has negative endPos.`),s.startPos>s.endPos&&(n[`${l}.position.invalid`]=`Category "${i.category}" target ${a} has startPos greater than endPos.`),e.parts&&e.parts.length>0&&(s.startPos>=e.parts.length&&(n[`${l}.startPos.outOfBounds`]=`Category "${i.category}" target ${a} startPos is out of bounds.`),s.endPos>=e.parts.length&&(n[`${l}.endPos.outOfBounds`]=`Category "${i.category}" target ${a} endPos is out of bounds.`),s.startPos<e.parts.length&&s.endPos<e.parts.length)){let c=s.endPos-s.startPos+1;s.words.length!==c&&(n[`${l}.words.countMismatch`]=`Category "${i.category}" target ${a} word count mismatch.`)}}}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0,errors:null}}function na(e){switch(e.type){case"base":return ri(e);case"blanks":return ii(e);case"classification":return ni(e);default:return{ok:!1,errors:{"type.invalid":`Unknown text engine type: ${e.type}`}}}}function _e(e,n){let t=new Set(n.selectedIndices??[]),r=new Set;for(let p of e.targets)for(let h=p.startPos;h<=p.endPos;h++)r.add(h);let i=0,o=0,a=0;for(let p=0;p<e.parts.length;p++){let h=r.has(p),g=t.has(p);h&&g?i++:h&&!g?a++:!h&&g&&o++}let s=r.size,l=i+o>0?i/(i+o):0,c=i+a>0?i/(i+a):0,d=l+c>0?2*l*c/(l+c):0;return{score:Math.round(d*100),correct:i,total:s}}function oa(e,n){let t=new Set,r=n.dndPlacements??{};for(let l of e.targets)for(let c=l.startPos;c<=l.endPos;c++)t.add(c);let i=0;if(Object.keys(r).length>0)for(let l of t){let c=e.parts[l],d=r[l];d&&We(d)===We(c)&&i++}else{let l=new Set(n.placedIndices??[]);for(let c of l)t.has(c)&&i++}let a=t.size;return{score:a>0?Math.round(i/a*100):0,correct:i,total:a}}function aa(e,n){let t={},r=n.dndPlacements??{};for(let i of e.targets)for(let o=i.startPos;o<=i.endPos;o++){let a=e.parts[o],s=r[o];s?We(s)===We(a)?t[o]="correct":t[o]="wrong":t[o]="missed"}return t}function Ie(e,n,t){let r=n.transformations??{},i=0,o=0;for(let s=0;s<e.targets.length;s++){let l=t[s],c=r[s];l&&(o++,c&&l.length===c.length&&l.every((u,p)=>u.toLowerCase().trim()===(c[p]||"").toLowerCase().trim())&&i++)}return{score:o>0?Math.round(i/o*100):0,correct:i,total:o}}function bt(e,n,t){let r=n.transformations??{},i={};for(let o=0;o<e.targets.length;o++){let a=t[o],s=r[o];if(!a){i[o]="missed";continue}if(!s||s.length===0){i[o]="missed";continue}if(a.length===s.length){let l=a.every((c,d)=>c.toLowerCase().trim()===(s[d]||"").toLowerCase().trim());i[o]=l?"correct":"wrong"}else i[o]="wrong"}return i}function Me(e,n){let t=new Set(n.selectedIndices??[]),r=new Set,i={};for(let o of e.targets)for(let a=o.startPos;a<=o.endPos;a++)r.add(a);for(let o=0;o<e.parts.length;o++){let a=r.has(o),s=t.has(o);a&&s?i[o]="correct":a&&!s?i[o]="missed":!a&&s&&(i[o]="wrong")}return i}function Le(e,n){let t=0,r=e.targets.length;for(let o of e.targets){let a=n.inputValues[o.id],s=o.expectedValue;si(s,a)&&t++}return{score:r>0?Math.round(t/r*100):0,correct:t,total:r}}function De(e,n){let t={};for(let r of e.targets){let i=n.inputValues[r.id],o=r.expectedValue;i==null||i===""?t[r.id]="missed":si(o,i)?t[r.id]="correct":t[r.id]="wrong"}return t}function si(e,n){if(n==null||n==="")return!1;switch(e.type){case"text":{let t=String(n).toLowerCase().trim();return e.value.some(r=>r.toLowerCase().trim()===t)}case"number":{let t=Number(n);return isNaN(t)?!1:e.targets.includes(t)?!0:e.ranges?e.ranges.some(r=>t>=r.from&&t<=r.to):!1}case"select":{let t=String(n).trim();return e.correctOptions.some(r=>String(r).trim()===t)}case"date":{let t=oi(String(e.value)),r=oi(String(n));return t.length>0&&t===r}case"time":{let t=ai(String(e.value)),r=ai(String(n));return t.length>0&&t===r}default:return!1}}function We(e){return String(e).trim().toLowerCase()}function oi(e){return String(e).trim().replace(/\//g,"-")}function ai(e){let n=String(e).trim(),t=n.match(/^([01]\d|2[0-3]):([0-5]\d)(?::[0-5]\d)?$/);return t?`${t[1]}:${t[2]}`:n}function Re(e,n){let t=0,r=0,i=new Map;for(let a of e.targets)for(let s of a.targets)for(let l=s.startPos;l<=s.endPos;l++)i.set(l,a.category),r++;for(let[a,s]of Object.entries(n.wordCategories)){let l=Number(a),c=i.get(l);c&&s===c&&t++}return{score:r>0?Math.round(t/r*100):0,correct:t,total:r}}function Pe(e,n){let t={},r=new Map;for(let i of e.targets)for(let o of i.targets)for(let a=o.startPos;a<=o.endPos;a++)r.set(a,i.category);for(let[i,o]of r){let a=n.wordCategories[i];a?a===o?t[i]="correct":t[i]="wrong":t[i]="missed"}return t}var li=`/* ==================== BASE STYLES ==================== */
|
|
2592
|
+
`,this.querySelector(".table-wrapper").appendChild(this._$table)}updateProgressBasedOnCompletion(){let t=this._$table.getState(),r=0;for(let i of this.data.rows)for(let o of this.data.cols){if(i===o)continue;let a=t[i]?.values[o];a!=null&&a!==""&&r++}this.setProgress(r)}getCurrentState(){return this._$table.getState()}isInteractionComplete(){let t=this._$table.getState();for(let r of this.data.rows)for(let i of this.data.cols){if(r===i)continue;let o=t[r]?.values[i];if(o==null||o==="")return!1}return!0}onHint(){let t=this._$table.getState();for(let r of this.data.rows)for(let i of this.data.cols){if(r===i)continue;let o=t[r]?.values[i];if(o==null||o===""){alert(`Hint: You haven't filled the cell for "${r}" \u2192 "${i}" yet.`),this.emitHintShown(`Empty cell: ${r} \u2192 ${i}`);return}}alert('All cells are complete! Click "Check" to submit.'),this.emitHintShown("All cells complete")}submit(){super.submit();let t=this.getCurrentState(),r=Vr(this.data.answerKey,t,this.data.rows),i=Fr(this.data.answerKey,t,this.data.rows);this._$table.setGradingState(i),console.log(`Adjacency Table Score: ${r.score.toFixed(1)}% (${r.correct}/${r.total} correct)`),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:r},bubbles:!0,composed:!0}))}reset(){super.reset(),this._$table&&(this._$table.reset(),this._$table.clearGradingState())}};customElements.get("adjacency-table")||customElements.define("adjacency-table",Ae);var ia=/\[([^\]]+)\]/g,na=/^\s*(-?\d+)\s*(\.\.)\s*(-?\d+)\s*$/,oa=/^\d{4}\/(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])$/,aa=/^([01]\d|2[0-3]):[0-5]\d$/,Wr=e=>{let n=j(e);if(n.length===0||n.some(o=>!o))return{ok:!1,data:null,errors:{"@tx":"provide at least one non-empty answer."}};let t=J(n),r=`text-${P(e)}`,i=`<edu-input type="text" id="${r}" variant="outline" autocomplete="off"></edu-input>`;return{ok:!0,data:{type:"text",id:r,value:t,html:i},errors:null}},Qr=e=>{let t=[...e.matchAll(ia)].flatMap(c=>j(c[1])),r=e.replace(/\[|\]/g,""),i=[" ",...S(J(j(r)))];if(i.length===0)return{ok:!1,data:null,errors:{"@sl":"provide at least one option for the select."}};if(t.length===0)return{ok:!1,data:null,errors:{"@sl":"Mark at least one correct option inside of square brackets."}};let o=[...i],a=`select-${P(e)}-${Math.random().toString(36).slice(2)}`,s=o.map(c=>`<option>${c}</option>`).join(""),l=`<edu-input as="select" id="${a}" variant="outline">${s}</edu-input>`;return{ok:!0,data:{type:"select",id:a,correctOptions:t,options:i,html:l},errors:null}},Zr=e=>{let n=j(e);if(n.length===0||n.some(a=>!a.trim()))return{ok:!1,data:null,errors:{"@nm":"provide at least one non-empty option."}};let t=[],r=[];for(let a of n){let s=a.match(na);if(s){let l=parseInt(s[1],10),c=parseInt(s[3],10);if(Number.isNaN(l)||Number.isNaN(c)||l>c)return{ok:!1,data:null,errors:{"@nm":"Invalid range ${t}"}};r.push({from:l,to:c})}else{let l=Number(a.trim());if(!Number.isInteger(l))return{ok:!1,data:null,errors:{"@nm":"${t} is not an integer."}};t.push(l)}}let i=`number-${P(e)}-${Math.random().toString(36).slice(2)}`,o=`<edu-input type="number" variant="outline" id="${i}"></edu-input>`;return{ok:!0,data:{type:"number",id:i,targets:J(t),ranges:r,html:o},errors:null}},Xr=e=>{let n=j(e);if(n.length===0||n.some(a=>!a.trim()))return{ok:!1,data:null,errors:{"@dt":"provide at least one non-empty date option."}};let t=[];for(let a of n){let s=a.trim();if(!oa.test(s))return{ok:!1,data:null,errors:{"@dt":`"${s}" is not a valid date. Expected format: YYYY/MM/DD`}};t.push(s)}let r=J(t),i=`date-${P(e)}`,o=`<edu-input type="date" id="${i}" variant="outline"></edu-input>`;return{ok:!0,data:{type:"date",id:i,value:r[0],html:o},errors:null}},Jr=e=>{let n=j(e);if(n.length===0||n.some(a=>!a.trim()))return{ok:!1,data:null,errors:{"@tm":"provide at least one non-empty time option."}};let t=[];for(let a of n){let s=a.trim();if(!aa.test(s))return{ok:!1,data:null,errors:{"@tm":`"${s}" is not a valid time. Expected format: HH:MM (24-hour)`}};t.push(s)}let r=J(t),i=`time-${P(e)}`,o=`<edu-input type="time" id="${i}" variant="outline"></edu-input>`;return{ok:!0,data:{type:"time",id:i,value:r[0],html:o},errors:null}};function ei(e){return e.trim().split(";;")}var ti=["tx","nm","sl","dt","tm"],sa={tx:Wr,nm:Zr,sl:Qr,dt:Xr,tm:Jr},ri=e=>{let n=[],t=[],r={},i,o=/^\s*=\s*\[([^\]]+)\]\s*;/m,a=e.match(o);a&&(i=a[1].split("|").map(h=>h.trim().replace(/^["']|["']$/g,"")).filter(Boolean),e=e.replace(o,""));let s="",l=!1,c=null,d=0;for(;d<e.length;){let p=e[d];if(d+1<e.length&&p==="["&&e[d+1]==="["){s+="[",d+=2;continue}if(p==="["){s.trim().length>0&&(n.push(s.trim()),s=""),l=!0,c={words:[],startPos:n.length,endPos:n.length},d++;continue}if(p==="]"){if(!l){r[`at:${d}`]="Unexpected closing bracket ']' without matching opening bracket.",d++;continue}if(s.trim().length>0){let h=s.trim();c.words.push(h),n.push(h),s=""}c.words.length===0?r[`at:${d}`]="Empty brackets [] are not allowed as targets.":(c.endPos=n.length-1,t.push(c)),c=null,l=!1,d++;continue}if(p===" "||p===`
|
|
2593
|
+
`||p===" "||p==="\r"){if(s.trim().length>0){let h=s.trim();l&&c.words.push(h),n.push(h),s=""}d++;continue}s+=p,d++}if(s.trim().length>0){let p=s.trim();l&&(c.words.push(p),c.endPos=n.length,t.push(c)),n.push(p)}l&&(r.unclosed="Unclosed opening bracket '['. Expected ']'.");let u=Object.keys(r).length>0;return{ok:!u,data:{type:"base",parts:n,targets:t,...i&&{distractors:i}},errors:u?r:null}},ii=e=>{let n={},t=[],r=[],i="",o=0;for(;o<e.length;){let s=e[o];if(o+1<e.length&&s==="@"&&e[o+1]==="@"){i+="@",o+=2;continue}if(s!=="@"){if(s===" "||s===`
|
|
2594
|
+
`||s===" "||s==="\r"){i.trim().length>0&&(t.push(i.trim()),i=""),o++;continue}i+=s,o++;continue}i.trim().length>0&&(t.push(i.trim()),i="");let l=o;o++;let c="";for(;o<e.length&&/[a-z]/i.test(e[o]);)c+=e[o++];if(!c||!ti.includes(c)){n[`at:${l}`]=`Invalid element reference "@${c}". Expected one of: ${ti.join(", ")}.`;continue}if(o>=e.length||e[o]!=="("){n[`at:${l}`]=`Expected '(' after @${c} at position ${o}.`;continue}o++;let d="",u=!1;for(;o<e.length;){if(e[o]===")"){u=!0,o++;break}d+=e[o++]}if(!u){n[`at:${l}`]=`Unclosed parenthesis for @${c}. Expected ')'.`;continue}let p=sa[c];if(!p){n[`at:${l}`]=`No parser found for @${c}.`;continue}let h=p(d);if(!h.ok){n[`at:${l}`]=h.errors?JSON.stringify(h.errors):`Failed to parse @${c}(${d})`;continue}t.push(h.data.html);let g={id:h.data.id,expectedValue:h.data};r.push(g)}i.trim().length>0&&t.push(i.trim());let a=Object.keys(n).length>0;return{ok:!a,data:{type:"blanks",parts:t,targets:r},errors:a?n:null}},ni=e=>{let n=[],t={},r=new Map,i="",o=0;for(;o<e.length;){let l=e[o];if(o+1<e.length&&l==="@"&&e[o+1]==="@"){i+="@",o+=2;continue}if(l!=="@"){if(l===" "||l===`
|
|
2595
|
+
`||l===" "||l==="\r"){i.trim().length>0&&(n.push(i.trim()),i=""),o++;continue}i+=l,o++;continue}i.trim().length>0&&(n.push(i.trim()),i="");let c=o;o++;let d="";for(;o<e.length&&/[a-z]/i.test(e[o]);)d+=e[o++];if(d!=="ct"){t[`at:${c}`]=`Invalid reference "@${d}". Expected "@ct" for classification.`;continue}if(o>=e.length||e[o]!=="("){t[`at:${c}`]=`Expected '(' after @ct at position ${o}.`;continue}o++;let u="",p=!1;for(;o<e.length;){if(e[o]===")"){p=!0,o++;break}u+=e[o++]}if(!p){t[`at:${c}`]="Unclosed parenthesis for @ct. Expected ')'.";continue}let h=u.split(",").map(K=>K.trim());if(h.length!==2){t[`at:${c}`]=`Invalid @ct syntax. Expected: @ct(category, word). Got: @ct(${u})`;continue}let[g,m]=h;if(!g||!m){t[`at:${c}`]=`Category and word cannot be empty in @ct(${u}).`;continue}let b=m.split(/\s+/).filter(Boolean),w=n.length;for(let K of b)n.push(K);let v=n.length-1,q={words:b,startPos:w,endPos:v};r.has(g)||r.set(g,[]),r.get(g).push(q)}i.trim().length>0&&n.push(i.trim());let a=[];for(let[l,c]of r.entries())a.push({category:l,targets:c});let s=Object.keys(t).length>0;return{ok:!s,data:{type:"classification",parts:n,targets:a},errors:s?t:null}},la={base:ri,blanks:ii,classification:ni};function ca(e,n){let t=ei(e),r=la[n],i=[],o=[];for(let a of t){let s=r(a);if(!s.ok){s.errors&&(Array.isArray(s.errors)?o.push(...s.errors):o.push(s.errors));continue}i.push(s.data)}return o.length>0?{ok:!1,data:null,errors:o}:{ok:!0,data:i,errors:null}}function oi(e){let n={};if((!e.parts||e.parts.length===0)&&(n["parts.empty"]="No parts found. Text must contain at least one word."),(!e.targets||e.targets.length===0)&&(n["targets.empty"]="No targets found. Text must contain at least one [target] to interact with."),e.targets&&e.targets.length>0&&e.parts&&e.parts.length>0)for(let t=0;t<e.targets.length;t++){let r=e.targets[t],i=`targets[${t}]`;if(!r.words||r.words.length===0){n[`${i}.words.empty`]=`Target ${t} has no words. Each target must contain at least one word.`;continue}if(r.startPos<0&&(n[`${i}.startPos.negative`]=`Target ${t} has negative startPos (${r.startPos}).`),r.endPos<0&&(n[`${i}.endPos.negative`]=`Target ${t} has negative endPos (${r.endPos}).`),r.startPos>r.endPos&&(n[`${i}.position.invalid`]=`Target ${t} has startPos (${r.startPos}) greater than endPos (${r.endPos}).`),r.startPos>=e.parts.length&&(n[`${i}.startPos.outOfBounds`]=`Target ${t} startPos (${r.startPos}) is out of bounds (parts length: ${e.parts.length}).`),r.endPos>=e.parts.length&&(n[`${i}.endPos.outOfBounds`]=`Target ${t} endPos (${r.endPos}) is out of bounds (parts length: ${e.parts.length}).`),r.startPos<e.parts.length&&r.endPos<e.parts.length){let o=r.endPos-r.startPos+1;r.words.length!==o&&(n[`${i}.words.countMismatch`]=`Target ${t} has ${r.words.length} words but position range indicates ${o} words.`);for(let a=0;a<r.words.length;a++){let s=r.startPos+a;if(s<e.parts.length){let l=e.parts[s],c=r.words[a];l!==c&&(n[`${i}.words[${a}].mismatch`]=`Target ${t} word "${c}" doesn't match part at position ${s}: "${l}".`)}}}}if(e.distractors)if(!Array.isArray(e.distractors))n["distractors.notArray"]="Distractors must be an array.";else{e.distractors.length===0&&(n["distractors.empty"]="Distractors array is empty. Remove distractors field or add at least one distractor.");let t=new Set;for(let r=0;r<e.distractors.length;r++){let i=e.distractors[r];t.has(i)&&(n[`distractors[${r}].duplicate`]=`Duplicate distractor found: "${i}".`),t.add(i),(!i||i.trim().length===0)&&(n[`distractors[${r}].empty`]=`Distractor at index ${r} is empty.`)}}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0,errors:null}}function ai(e){let n={};(!e.parts||e.parts.length===0)&&(n["parts.empty"]="No parts found. Text must contain at least one part."),(!e.targets||e.targets.length===0)&&(n["targets.empty"]="No targets found. Text must contain at least one input element (@tx, @nm, @sl, @dt, @tm).");let t=new Set;if(e.targets&&e.targets.length>0)for(let r=0;r<e.targets.length;r++){let i=e.targets[r],o=`targets[${r}]`;if(!i.id||i.id.trim().length===0?n[`${o}.id.empty`]=`Target ${r} has no ID. Each input element must have a unique ID.`:(t.has(i.id)&&(n[`${o}.id.duplicate`]=`Duplicate ID found: "${i.id}". Each input element must have a unique ID.`),t.add(i.id)),!i.expectedValue){n[`${o}.expectedValue.missing`]=`Target ${r} has no expectedValue. Each input element must define expected answer data.`;continue}let a=i.expectedValue;a.type||(n[`${o}.expectedValue.type.missing`]=`Target ${r} expectedValue has no type field.`),a.id||(n[`${o}.expectedValue.id.missing`]=`Target ${r} expectedValue has no id field.`),a.html||(n[`${o}.expectedValue.html.missing`]=`Target ${r} expectedValue has no html field.`);let s=a.type;if(s)switch(s){case"text":(!("value"in a)||!Array.isArray(a.value))&&(n[`${o}.expectedValue.text.value`]=`Target ${r} is type 'text' but has no valid 'value' array.`);break;case"number":"targets"in a||(n[`${o}.expectedValue.number.targets`]=`Target ${r} is type 'number' but has no 'targets' field.`);break;case"select":(!("correctOptions"in a)||!("options"in a))&&(n[`${o}.expectedValue.select.options`]=`Target ${r} is type 'select' but is missing 'correctOptions' or 'options' fields.`);break;case"date":case"time":"value"in a||(n[`${o}.expectedValue.${s}.value`]=`Target ${r} is type '${s}' but has no 'value' field.`);break}}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0,errors:null}}function si(e){let n={};(!e.parts||e.parts.length===0)&&(n["parts.empty"]="No parts found. Text must contain at least one word."),(!e.targets||e.targets.length===0)&&(n["targets.empty"]="No categories found. Text must contain at least one @ct(category, word) reference.");let t=new Set;if(e.targets&&e.targets.length>0)for(let r=0;r<e.targets.length;r++){let i=e.targets[r],o=`targets[${r}]`;if(!i.category||i.category.trim().length===0?n[`${o}.category.empty`]=`Category ${r} has no name.`:(t.has(i.category)&&(n[`${o}.category.duplicate`]=`Duplicate category found: "${i.category}". Each category must have a unique name.`),t.add(i.category)),!i.targets||i.targets.length===0){n[`${o}.targets.empty`]=`Category "${i.category}" has no targets. Each category must contain at least one word.`;continue}for(let a=0;a<i.targets.length;a++){let s=i.targets[a],l=`${o}.targets[${a}]`;if(!s.words||s.words.length===0){n[`${l}.words.empty`]=`Category "${i.category}" target ${a} has no words.`;continue}if(s.startPos<0&&(n[`${l}.startPos.negative`]=`Category "${i.category}" target ${a} has negative startPos.`),s.endPos<0&&(n[`${l}.endPos.negative`]=`Category "${i.category}" target ${a} has negative endPos.`),s.startPos>s.endPos&&(n[`${l}.position.invalid`]=`Category "${i.category}" target ${a} has startPos greater than endPos.`),e.parts&&e.parts.length>0&&(s.startPos>=e.parts.length&&(n[`${l}.startPos.outOfBounds`]=`Category "${i.category}" target ${a} startPos is out of bounds.`),s.endPos>=e.parts.length&&(n[`${l}.endPos.outOfBounds`]=`Category "${i.category}" target ${a} endPos is out of bounds.`),s.startPos<e.parts.length&&s.endPos<e.parts.length)){let c=s.endPos-s.startPos+1;s.words.length!==c&&(n[`${l}.words.countMismatch`]=`Category "${i.category}" target ${a} word count mismatch.`)}}}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0,errors:null}}function da(e){switch(e.type){case"base":return oi(e);case"blanks":return ai(e);case"classification":return si(e);default:return{ok:!1,errors:{"type.invalid":`Unknown text engine type: ${e.type}`}}}}function _e(e,n){let t=new Set(n.selectedIndices??[]),r=new Set;for(let p of e.targets)for(let h=p.startPos;h<=p.endPos;h++)r.add(h);let i=0,o=0,a=0;for(let p=0;p<e.parts.length;p++){let h=r.has(p),g=t.has(p);h&&g?i++:h&&!g?a++:!h&&g&&o++}let s=r.size,l=i+o>0?i/(i+o):0,c=i+a>0?i/(i+a):0,d=l+c>0?2*l*c/(l+c):0;return{score:Math.round(d*100),correct:i,total:s}}function ua(e,n){let t=new Set,r=n.dndPlacements??{};for(let l of e.targets)for(let c=l.startPos;c<=l.endPos;c++)t.add(c);let i=0;if(Object.keys(r).length>0)for(let l of t){let c=e.parts[l],d=r[l];d&&Ze(d)===Ze(c)&&i++}else{let l=new Set(n.placedIndices??[]);for(let c of l)t.has(c)&&i++}let a=t.size;return{score:a>0?Math.round(i/a*100):0,correct:i,total:a}}function pa(e,n){let t={},r=n.dndPlacements??{};for(let i of e.targets)for(let o=i.startPos;o<=i.endPos;o++){let a=e.parts[o],s=r[o];s?Ze(s)===Ze(a)?t[o]="correct":t[o]="wrong":t[o]="missed"}return t}function Ie(e,n,t){let r=n.transformations??{},i=0,o=0;for(let s=0;s<e.targets.length;s++){let l=t[s],c=r[s];l&&(o++,c&&l.length===c.length&&l.every((u,p)=>u.toLowerCase().trim()===(c[p]||"").toLowerCase().trim())&&i++)}return{score:o>0?Math.round(i/o*100):0,correct:i,total:o}}function wt(e,n,t){let r=n.transformations??{},i={};for(let o=0;o<e.targets.length;o++){let a=t[o],s=r[o];if(!a){i[o]="missed";continue}if(!s||s.length===0){i[o]="missed";continue}if(a.length===s.length){let l=a.every((c,d)=>c.toLowerCase().trim()===(s[d]||"").toLowerCase().trim());i[o]=l?"correct":"wrong"}else i[o]="wrong"}return i}function Me(e,n){let t=new Set(n.selectedIndices??[]),r=new Set,i={};for(let o of e.targets)for(let a=o.startPos;a<=o.endPos;a++)r.add(a);for(let o=0;o<e.parts.length;o++){let a=r.has(o),s=t.has(o);a&&s?i[o]="correct":a&&!s?i[o]="missed":!a&&s&&(i[o]="wrong")}return i}function Le(e,n){let t=0,r=e.targets.length;for(let o of e.targets){let a=n.inputValues[o.id],s=o.expectedValue;di(s,a)&&t++}return{score:r>0?Math.round(t/r*100):0,correct:t,total:r}}function De(e,n){let t={};for(let r of e.targets){let i=n.inputValues[r.id],o=r.expectedValue;i==null||i===""?t[r.id]="missed":di(o,i)?t[r.id]="correct":t[r.id]="wrong"}return t}function di(e,n){if(n==null||n==="")return!1;switch(e.type){case"text":{let t=String(n).toLowerCase().trim();return e.value.some(r=>r.toLowerCase().trim()===t)}case"number":{let t=Number(n);return isNaN(t)?!1:e.targets.includes(t)?!0:e.ranges?e.ranges.some(r=>t>=r.from&&t<=r.to):!1}case"select":{let t=String(n).trim();return e.correctOptions.some(r=>String(r).trim()===t)}case"date":{let t=li(String(e.value)),r=li(String(n));return t.length>0&&t===r}case"time":{let t=ci(String(e.value)),r=ci(String(n));return t.length>0&&t===r}default:return!1}}function Ze(e){return String(e).trim().toLowerCase()}function li(e){return String(e).trim().replace(/\//g,"-")}function ci(e){let n=String(e).trim(),t=n.match(/^([01]\d|2[0-3]):([0-5]\d)(?::[0-5]\d)?$/);return t?`${t[1]}:${t[2]}`:n}function Re(e,n){let t=0,r=0,i=new Map;for(let a of e.targets)for(let s of a.targets)for(let l=s.startPos;l<=s.endPos;l++)i.set(l,a.category),r++;for(let[a,s]of Object.entries(n.wordCategories)){let l=Number(a),c=i.get(l);c&&s===c&&t++}return{score:r>0?Math.round(t/r*100):0,correct:t,total:r}}function Pe(e,n){let t={},r=new Map;for(let i of e.targets)for(let o of i.targets)for(let a=o.startPos;a<=o.endPos;a++)r.set(a,i.category);for(let[i,o]of r){let a=n.wordCategories[i];a?a===o?t[i]="correct":t[i]="wrong":t[i]="missed"}return t}var ui=`/* ==================== BASE STYLES ==================== */
|
|
2552
2596
|
|
|
2553
2597
|
* { box-sizing: border-box; }
|
|
2554
2598
|
|
|
@@ -3060,7 +3104,7 @@ input[type="radio"] {
|
|
|
3060
3104
|
gap: 1.1rem;
|
|
3061
3105
|
}
|
|
3062
3106
|
}
|
|
3063
|
-
`;var
|
|
3107
|
+
`;var ga=`
|
|
3064
3108
|
:host {
|
|
3065
3109
|
display: inline-flex;
|
|
3066
3110
|
align-items: center;
|
|
@@ -3185,8 +3229,8 @@ slot {
|
|
|
3185
3229
|
background: rgb(var(--edu-warning) / 0.1);
|
|
3186
3230
|
box-shadow: 0 0 0 2px rgb(var(--edu-warning) / 0.2);
|
|
3187
3231
|
}
|
|
3188
|
-
`,
|
|
3189
|
-
<style>${
|
|
3232
|
+
`,ma=["input","select","textarea","button"],Xe=class extends HTMLElement{constructor(){super();this.$slot=null;this.controlEl=null;this.currentTag="input";this.handleSlotChange=()=>{this.syncAttributes(),this.syncContent()};this.attachShadow({mode:"open"})}static get observedAttributes(){return["as","variant","state","disabled","readonly","required","placeholder","value","type","name","autocomplete","min","max","step","pattern","rows","cols","multiple","size"]}connectedCallback(){this.hasAttribute("variant")||(this.variant="outline"),this.render(),this.$slot?.addEventListener("slotchange",this.handleSlotChange),this.syncAttributes(),this.syncContent()}disconnectedCallback(){this.$slot?.removeEventListener("slotchange",this.handleSlotChange)}attributeChangedCallback(t,r,i){r!==i&&(t==="as"&&this.render(),this.syncAttributes(),this.syncContent())}getTag(){let t=(this.getAttribute("as")??"input").toLowerCase();return ma.includes(t)?t:"input"}render(){let t=this.getTag();if(this.controlEl&&this.currentTag===t)return;this.currentTag=t,this.shadowRoot.innerHTML="";let r=document.createElement("style");r.textContent=ga,this.shadowRoot.append(r);let i=document.createElement(t);i.className="control",i.setAttribute("part","control"),this.$slot=document.createElement("slot"),this.shadowRoot.append(i,this.$slot),this.controlEl=i}applyAttr(t){this.controlEl&&(this.hasAttribute(t)?this.controlEl.setAttribute(t,this.getAttribute(t)??""):this.controlEl.removeAttribute(t))}applyBoolAttr(t){this.controlEl&&(this.hasAttribute(t)?this.controlEl.setAttribute(t,""):this.controlEl.removeAttribute(t))}syncAttributes(){this.controlEl&&(this.applyBoolAttr("disabled"),this.applyBoolAttr("readonly"),this.applyBoolAttr("required"),this.applyAttr("placeholder"),this.applyAttr("name"),this.applyAttr("autocomplete"),this.applyAttr("min"),this.applyAttr("max"),this.applyAttr("step"),this.applyAttr("pattern"),this.controlEl instanceof HTMLInputElement&&this.applyAttr("type"),this.controlEl instanceof HTMLTextAreaElement&&(this.applyAttr("rows"),this.applyAttr("cols")),this.controlEl instanceof HTMLSelectElement&&(this.applyBoolAttr("multiple"),this.applyAttr("size")),"value"in this.controlEl&&(this.hasAttribute("value")?this.controlEl.value=this.getAttribute("value")??"":this.controlEl.value=""))}syncContent(){if(!this.controlEl||!this.$slot)return;let r=this.$slot.assignedNodes({flatten:!0}).filter(i=>i.nodeType===Node.TEXT_NODE?i.textContent?.trim():i.nodeType===Node.ELEMENT_NODE);if(this.controlEl instanceof HTMLSelectElement){this.controlEl.innerHTML="",r.forEach(i=>{(i instanceof HTMLOptionElement||i instanceof HTMLOptGroupElement)&&this.controlEl.append(i.cloneNode(!0))});return}if(this.controlEl instanceof HTMLButtonElement){this.controlEl.innerHTML="",r.forEach(i=>{this.controlEl.append(i.cloneNode(!0))});return}if(this.controlEl instanceof HTMLTextAreaElement&&!this.hasAttribute("value")){let i=r.map(o=>o.textContent??"").join("");this.controlEl.value=i}}get variant(){return this.getAttribute("variant")??"outline"}set variant(t){this.setAttribute("variant",t)}get value(){return this.controlEl&&"value"in this.controlEl?this.controlEl.value:this.getAttribute("value")??""}set value(t){this.setAttribute("value",String(t)),this.controlEl&&"value"in this.controlEl&&(this.controlEl.value=t)}};customElements.get("edu-input")||customElements.define("edu-input",Xe);var Je=class extends HTMLElement{constructor(){super();this._state={};this._mounted=!1;this.onClick=t=>{let r=t.target;if(r.classList.contains("word-selectable")){let i=parseInt(r.getAttribute("data-index")??"");isNaN(i)||this.toggleWordSelection(i)}if(r.classList.contains("category-btn")){let i=r.getAttribute("data-category");i&&this.setActiveCategory(i)}if(r.classList.contains("word-classifiable")){let i=parseInt(r.getAttribute("data-index")??"");!isNaN(i)&&this._activeCategory&&this.assignWordToCategory(i,this._activeCategory)}if(r.classList.contains("dropzone-filled")){let i=parseInt(r.getAttribute("data-index")??"");isNaN(i)||this.clearDropzone(i)}};this.onChange=t=>{let r=t.target;if(r.tagName==="EDU-INPUT"||r.tagName==="INPUT"){let i=r.getAttribute("id");if(i){let o=r.value;this.updateInputValue(i,o)}}};this.onInput=t=>{let r=t.target;if(r.tagName==="EDU-INPUT"||r.tagName==="INPUT"){let i=r.getAttribute("id");if(i){let o=r.value;this.updateInputValue(i,o)}}if(r.hasAttribute("contenteditable")&&r.getAttribute("contenteditable")==="true"){let i=parseInt(r.getAttribute("data-target-index")??"");if(!isNaN(i)){let o=r.textContent??"";this.updateTransformation(i,o)}}};this.onDragStart=t=>{let r=t,i=r.target;if(!r.dataTransfer||!i.classList.contains("chip"))return;let o=i.getAttribute("data-word")||i.textContent||"";o&&(r.dataTransfer.setData("text/plain",o),r.dataTransfer.effectAllowed="move")};this.onDragOver=t=>{let r=t;r.target.classList.contains("dropzone")&&(r.preventDefault(),r.dataTransfer.dropEffect="move")};this.onDrop=t=>{let r=t,i=r.target;if(!i.classList.contains("dropzone")||(r.preventDefault(),!r.dataTransfer))return;let o=parseInt(i.getAttribute("data-index")??"");if(isNaN(o))return;let a=r.dataTransfer.getData("text/plain");a&&this.placeWordInDropzone(o,a)};this._activeCategory=null;this.attachShadow({mode:"open"});let t=document.createElement("section");t.className="wrap",this.shadowRoot.append(t),this.$wrapEl=t}static get observedAttributes(){return["variant"]}connectedCallback(){this._mounted=!0,this.shadowRoot?.addEventListener("click",this.onClick),this.shadowRoot?.addEventListener("change",this.onChange),this.shadowRoot?.addEventListener("input",this.onInput),this.shadowRoot?.addEventListener("dragstart",this.onDragStart),this.shadowRoot?.addEventListener("dragover",this.onDragOver),this.shadowRoot?.addEventListener("drop",this.onDrop),this.render()}disconnectedCallback(){this._mounted=!1,this.shadowRoot?.removeEventListener("click",this.onClick),this.shadowRoot?.removeEventListener("change",this.onChange),this.shadowRoot?.removeEventListener("input",this.onInput),this.shadowRoot?.removeEventListener("dragstart",this.onDragStart),this.shadowRoot?.removeEventListener("dragover",this.onDragOver),this.shadowRoot?.removeEventListener("drop",this.onDrop)}set config(t){this._config=t,this._state=this.initState(t),t.variant&&this.setAttribute("variant",t.variant),this.render()}get config(){if(!this._config)throw new Error("<edu-text>: config not set");return this._config}getValue(){switch(this._config.data.type){case"base":if(this._config.mode==="highlight")return{selectedIndices:Array.from(this._state.selectedIndices??[])};if(this._config.mode==="dnd"){let r=this._state.dndPlacements??{};return{placedIndices:Object.keys(r).map(i=>Number(i)),dndPlacements:{...r}}}else if(this._config.mode==="transformation")return{transformations:this._state.transformations??{}};break;case"blanks":return{inputValues:this._state.inputValues??{}};case"classification":return{wordCategories:this._state.wordCategories??{}}}return{}}getState(){return{...this._state}}setState(t){t&&(this._state={...this._state,...t.selectedIndices?{selectedIndices:new Set(t.selectedIndices)}:{},...t.dndPlacements?{dndPlacements:{...t.dndPlacements}}:{},...t.inputValues?{inputValues:{...t.inputValues}}:{},...t.wordCategories?{wordCategories:{...t.wordCategories}}:{},...t.transformations?{transformations:{...t.transformations}}:{}},this.render())}reset(){this._config&&(this._state=this.initState(this._config),this.render(),this.dispatchEvent(new CustomEvent("reset",{bubbles:!0,composed:!0})))}setGradingState(t){this._config&&(this._config.gradingState=t,this.render())}clearGradingState(){this._config&&(this._config.gradingState=void 0,this.render())}attributeChangedCallback(t,r,i){r!==i&&t==="variant"&&(this.setAttribute("variant",i),this.shadowRoot?.querySelectorAll("edu-input").forEach(o=>{let a=o;a.variant!==void 0&&(a.variant=i)}),this.shadowRoot?.querySelectorAll("edu-block").forEach(o=>{let a=o;a.variant!==void 0&&(a.variant=i)}),this.render())}upsertHtmlAttribute(t,r,i){let o=new RegExp(`${r}="[^"]*"`,"i");return o.test(t)?t.replace(o,`${r}="${i}"`):t.replace(/<([a-z0-9-]+)/i,`<$1 ${r}="${i}"`)}removeHtmlAttribute(t,r){let i=new RegExp(`\\s${r}="[^"]*"`,"ig");return t.replace(i,"")}upsertHtmlClass(t,r){let i=/class="([^"]*)"/i;return i.test(t)?t.replace(i,(o,a)=>{let s=String(a||"").split(/\s+/).filter(Boolean);return s.includes(r)||s.push(r),`class="${s.join(" ")}"`}):t.replace(/<([a-z0-9-]+)/i,`<$1 class="${r}"`)}removeHtmlClassPrefix(t,r){let i=/class="([^"]*)"/i;return i.test(t)?t.replace(i,(o,a)=>{let s=String(a||"").split(/\s+/).filter(Boolean).filter(l=>!l.startsWith(r));return s.length>0?`class="${s.join(" ")}"`:""}):t}initState(t){let r={};switch(t.data.type){case"base":t.mode==="highlight"||t.mode==="dnd"?(r.selectedIndices=new Set,t.mode==="dnd"&&(r.dndPlacements={})):t.mode==="transformation"&&(r.transformations={});break;case"blanks":r.inputValues={};break;case"classification":r.wordCategories={};break}return r}render(){if(!this._mounted||!this.shadowRoot)return;if(!this._config){this.$wrapEl.innerHTML="<style>:host{display:block}</style><div></div>";return}let t=this._config,r=t.data,i="";switch(t.mode){case"highlight":i=this.renderHighlight(r);break;case"blanks":i=this.renderBlanks(r);break;case"classification":i=this.renderClassification(r);break;case"dnd":i=this.renderDND(r);break;case"transformation":i=this.renderTransformation(r);break}this.$wrapEl.innerHTML=`
|
|
3233
|
+
<style>${ui}</style>
|
|
3190
3234
|
<div class="text-content" part="content">
|
|
3191
3235
|
${i}
|
|
3192
3236
|
</div>
|
|
@@ -3211,7 +3255,7 @@ slot {
|
|
|
3211
3255
|
<div class="words" part="words">${d}</div>
|
|
3212
3256
|
${u}
|
|
3213
3257
|
</div>
|
|
3214
|
-
`}renderDND(t){let r=t.parts,i=this._state.dndPlacements??{},o=this._config.gradingState??{},a=new Set;for(let h of t.targets)for(let g=h.startPos;g<=h.endPos;g++)a.add(g);let s=r.map((h,g)=>{if(a.has(g)){let m=i[g],b=!!m,w=o[g],v=["dropzone"];b&&v.push("dropzone-filled"),w&&v.push(`dropzone-${w}`);let q=b?E(m):"";return`<span class="${v.join(" ")}" data-index="${g}">${q}</span>`}else return`<span class="word">${E(h)}</span>`}).join(" "),l=[...t.targets.flatMap(h=>h.words)];t.distractors&&l.push(...t.distractors);let c=Object.values(i),d=[...l];for(let h of c){let g=d.findIndex(m=>
|
|
3258
|
+
`}renderDND(t){let r=t.parts,i=this._state.dndPlacements??{},o=this._config.gradingState??{},a=new Set;for(let h of t.targets)for(let g=h.startPos;g<=h.endPos;g++)a.add(g);let s=r.map((h,g)=>{if(a.has(g)){let m=i[g],b=!!m,w=o[g],v=["dropzone"];b&&v.push("dropzone-filled"),w&&v.push(`dropzone-${w}`);let q=b?E(m):"";return`<span class="${v.join(" ")}" data-index="${g}">${q}</span>`}else return`<span class="word">${E(h)}</span>`}).join(" "),l=[...t.targets.flatMap(h=>h.words)];t.distractors&&l.push(...t.distractors);let c=Object.values(i),d=[...l];for(let h of c){let g=d.findIndex(m=>pi(m)===pi(h));g!==-1&&d.splice(g,1)}let p=S(d).map(h=>`<div class="chip" draggable="true" data-word="${E(h)}">${E(h)}</div>`).join("");return`
|
|
3215
3259
|
<div class="dnd-container">
|
|
3216
3260
|
<div class="dnd-text">${s}</div>
|
|
3217
3261
|
<div class="dnd-chips">${p}</div>
|
|
@@ -3221,7 +3265,7 @@ slot {
|
|
|
3221
3265
|
contenteditable="true"
|
|
3222
3266
|
data-target-index="${c}"
|
|
3223
3267
|
data-original="${E(s)}">${E(p)}</span>
|
|
3224
|
-
`}else return`<span class="word">${E(s)}</span>`}).join(" ")}toggleWordSelection(t){this._state.selectedIndices||(this._state.selectedIndices=new Set),this._state.selectedIndices.has(t)?this._state.selectedIndices.delete(t):this._state.selectedIndices.add(t),this.render(),this.emitChange()}setActiveCategory(t){this._activeCategory=t,this.shadowRoot?.querySelectorAll(".category-btn").forEach(r=>{r.getAttribute("data-category")===t?(r.classList.add("category-active"),r.setAttribute("data-active","true")):(r.classList.remove("category-active"),r.removeAttribute("data-active")),r instanceof Y&&(r.variant=this.getAttribute("variant")??"outline")})}assignWordToCategory(t,r){this._state.wordCategories||(this._state.wordCategories={}),this._state.wordCategories[t]===r?delete this._state.wordCategories[t]:this._state.wordCategories[t]=r,this.render(),this.emitChange()}updateInputValue(t,r){this._state.inputValues||(this._state.inputValues={}),this._state.inputValues[t]=r,this.emitChange()}updateTransformation(t,r){this._state.transformations||(this._state.transformations={});let i=r.split(/\s+/).filter(Boolean);this._state.transformations[t]=i,this.emitChange()}placeWordInDropzone(t,r){this._state.dndPlacements||(this._state.dndPlacements={}),this._state.dndPlacements[t]=r,this.render(),this.emitChange()}clearDropzone(t){this._state.dndPlacements&&t in this._state.dndPlacements&&(delete this._state.dndPlacements[t],this.render(),this.emitChange())}emitChange(){let t={userState:this.getValue(),dataType:this._config.data.type};this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,composed:!0}))}};function
|
|
3268
|
+
`}else return`<span class="word">${E(s)}</span>`}).join(" ")}toggleWordSelection(t){this._state.selectedIndices||(this._state.selectedIndices=new Set),this._state.selectedIndices.has(t)?this._state.selectedIndices.delete(t):this._state.selectedIndices.add(t),this.render(),this.emitChange()}setActiveCategory(t){this._activeCategory=t,this.shadowRoot?.querySelectorAll(".category-btn").forEach(r=>{r.getAttribute("data-category")===t?(r.classList.add("category-active"),r.setAttribute("data-active","true")):(r.classList.remove("category-active"),r.removeAttribute("data-active")),r instanceof Y&&(r.variant=this.getAttribute("variant")??"outline")})}assignWordToCategory(t,r){this._state.wordCategories||(this._state.wordCategories={}),this._state.wordCategories[t]===r?delete this._state.wordCategories[t]:this._state.wordCategories[t]=r,this.render(),this.emitChange()}updateInputValue(t,r){this._state.inputValues||(this._state.inputValues={}),this._state.inputValues[t]=r,this.emitChange()}updateTransformation(t,r){this._state.transformations||(this._state.transformations={});let i=r.split(/\s+/).filter(Boolean);this._state.transformations[t]=i,this.emitChange()}placeWordInDropzone(t,r){this._state.dndPlacements||(this._state.dndPlacements={}),this._state.dndPlacements[t]=r,this.render(),this.emitChange()}clearDropzone(t){this._state.dndPlacements&&t in this._state.dndPlacements&&(delete this._state.dndPlacements[t],this.render(),this.emitChange())}emitChange(){let t={userState:this.getValue(),dataType:this._config.data.type};this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,composed:!0}))}};function pi(e){return e.trim().toLowerCase()}customElements.get("edu-text")||customElements.define("edu-text",Je);var ie=class extends x{constructor(t,r){super(t,r);this.interactionMechanic="static";this._textConfig={data:t,mode:"highlight",variant:r.variant??"outline"},this.implementsProgress=!1}initialize(){}cleanup(){}onVariantChange(t){this.config.variant=t,this._textConfig.variant=t,this._$text&&this._$text.setAttribute("variant",t)}render(){this._textConfig.variant=this.config.variant,this._$text=document.createElement("edu-text"),this._$text.config=this._textConfig,this._$text.addEventListener("change",()=>{this.emitStateChange()}),this.innerHTML=`
|
|
3225
3269
|
<style>
|
|
3226
3270
|
mark-the-words {
|
|
3227
3271
|
display: flex;
|
|
@@ -3395,7 +3439,7 @@ slot {
|
|
|
3395
3439
|
<div class="text-container">
|
|
3396
3440
|
<div class="text-wrapper"></div>
|
|
3397
3441
|
</div>
|
|
3398
|
-
`,this.querySelector(".text-wrapper").appendChild(this._$text)}getTotalTargetCount(){return this._slides.reduce((t,r)=>t+r.targets.length,0)}buildDefaultExpectations(){let t={};for(let r=0;r<this._slides.length;r++){let i=this._slides[r];t[r]={};for(let o=0;o<i.targets.length;o++)t[r][o]=i.targets[o].words}return t}getExpectedForStep(t){return this._expectedByStep[t]??{}}saveCurrentStepResponse(){this._$text&&(this._responses[this._currentStep]=this._$text.getValue())}getResponseForStep(t){return this._responses[t]??{transformations:{}}}updateProgressAcrossSteps(){let t=0;for(let r=0;r<this._slides.length;r++){let i=this._slides[r],a=this.getResponseForStep(r).transformations??{};t+=i.targets.filter((s,l)=>{let c=a[l];return Array.isArray(c)&&c.length>0}).length}this.setProgress(t)}getCurrentState(){return this.saveCurrentStepResponse(),{step:this._currentStep,responses:this._responses}}isInteractionComplete(){return this.getProgress().current===this.getProgress().total}onHint(){this.saveCurrentStepResponse();let t=this._slides[this._currentStep],i=this.getResponseForStep(this._currentStep).transformations??{},o=this.getExpectedForStep(this._currentStep);for(let a=0;a<t.targets.length;a++)if(!i[a]||i[a].length===0){let s=t.targets[a].words.join(" "),l=o[a]?.join(" ")||s;this.emitHintShown(`Transform "${s}" to "${l}"`);return}this.emitHintShown("This step is complete. Move to another step or submit.")}grade(){this.saveCurrentStepResponse();let t=0,r=0,i={};for(let s=0;s<this._slides.length;s++){let l=this._slides[s],c=this.getResponseForStep(s),d=this.getExpectedForStep(s),u=Ie(l,c,d);t+=u.correct,r+=u.total,i[s]=
|
|
3442
|
+
`,this.querySelector(".text-wrapper").appendChild(this._$text)}getTotalTargetCount(){return this._slides.reduce((t,r)=>t+r.targets.length,0)}buildDefaultExpectations(){let t={};for(let r=0;r<this._slides.length;r++){let i=this._slides[r];t[r]={};for(let o=0;o<i.targets.length;o++)t[r][o]=i.targets[o].words}return t}getExpectedForStep(t){return this._expectedByStep[t]??{}}saveCurrentStepResponse(){this._$text&&(this._responses[this._currentStep]=this._$text.getValue())}getResponseForStep(t){return this._responses[t]??{transformations:{}}}updateProgressAcrossSteps(){let t=0;for(let r=0;r<this._slides.length;r++){let i=this._slides[r],a=this.getResponseForStep(r).transformations??{};t+=i.targets.filter((s,l)=>{let c=a[l];return Array.isArray(c)&&c.length>0}).length}this.setProgress(t)}getCurrentState(){return this.saveCurrentStepResponse(),{step:this._currentStep,responses:this._responses}}isInteractionComplete(){return this.getProgress().current===this.getProgress().total}onHint(){this.saveCurrentStepResponse();let t=this._slides[this._currentStep],i=this.getResponseForStep(this._currentStep).transformations??{},o=this.getExpectedForStep(this._currentStep);for(let a=0;a<t.targets.length;a++)if(!i[a]||i[a].length===0){let s=t.targets[a].words.join(" "),l=o[a]?.join(" ")||s;this.emitHintShown(`Transform "${s}" to "${l}"`);return}this.emitHintShown("This step is complete. Move to another step or submit.")}grade(){this.saveCurrentStepResponse();let t=0,r=0,i={};for(let s=0;s<this._slides.length;s++){let l=this._slides[s],c=this.getResponseForStep(s),d=this.getExpectedForStep(s),u=Ie(l,c,d);t+=u.correct,r+=u.total,i[s]=wt(l,c,d)}this._gradingByStep=i,this._isGraded=!0;let o=this._gradingByStep[this._currentStep];return o&&this._$text.setGradingState(o),{score:r>0?Math.round(t/r*100):0,correct:t,total:r}}submit(){super.submit();let t=this.grade();this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0}))}reset(){super.reset(),this._responses={},this._gradingByStep={},this._isGraded=!1,this._currentStep=0,this._$text&&(this._$text.reset(),this._$text.clearGradingState()),this.setProgress(0),this.render()}setExpectedTransformationsByStep(t){this._expectedByStep=t}};customElements.get("sequential-text-transformation")||customElements.define("sequential-text-transformation",le);var ce=class extends x{constructor(t,r){super(t,r);this.interactionMechanic="static";this._textConfig={data:t,mode:"blanks",variant:r.variant??"outline"},this.initializeProgress(t.targets.length)}initialize(){}cleanup(){}onVariantChange(t){this.config.variant=t,this._textConfig.variant=t,this._$text&&this._$text.setAttribute("variant",t)}render(){this._textConfig.variant=this.config.variant,this._$text=document.createElement("edu-text"),this._$text.config=this._textConfig,this._$text.addEventListener("change",()=>{this.updateProgressBasedOnInputs(),this.emitStateChange()}),this.innerHTML=`
|
|
3399
3443
|
<style>
|
|
3400
3444
|
fill-blanks {
|
|
3401
3445
|
display: flex;
|
|
@@ -3460,8 +3504,8 @@ slot {
|
|
|
3460
3504
|
<div class="text-container">
|
|
3461
3505
|
<div class="text-wrapper"></div>
|
|
3462
3506
|
</div>
|
|
3463
|
-
`,this.querySelector(".text-wrapper").appendChild(this._$text)}getTotalTargetCount(){return this._slides.reduce((t,r)=>t+r.targets.length,0)}saveCurrentStepResponse(){this._$text&&(this._responses[this._currentStep]=this._$text.getValue())}getResponseForStep(t){return this._responses[t]??{inputValues:{}}}updateProgressAcrossSteps(){let t=0;for(let r=0;r<this._slides.length;r++){let i=this._slides[r],a=this.getResponseForStep(r).inputValues??{};t+=i.targets.filter(s=>{let l=a[s.id];return l!=null&&String(l).trim()!==""}).length}this.setProgress(t)}getCurrentState(){return this.saveCurrentStepResponse(),{step:this._currentStep,responses:this._responses}}isInteractionComplete(){return this.getProgress().current===this.getProgress().total}onHint(){this.saveCurrentStepResponse();let t=this._slides[this._currentStep],i=this.getResponseForStep(this._currentStep).inputValues??{},o=t.targets.find(a=>{let s=i[a.id];return s==null||String(s).trim()===""});if(!o){this.emitHintShown("This step is complete. Move to another step or submit.");return}this.emitHintShown(`Complete the ${o.expectedValue.type} input on this step.`)}grade(){this.saveCurrentStepResponse();let t=0,r=0,i={};for(let s=0;s<this._slides.length;s++){let l=this._slides[s],c=this.getResponseForStep(s),d=Le(l,c);t+=d.correct,r+=d.total,i[s]=De(l,c)}this._gradingByStep=i,this._isGraded=!0;let o=this._gradingByStep[this._currentStep];return o&&this._$text.setGradingState(o),{score:r>0?Math.round(t/r*100):0,correct:t,total:r}}submit(){super.submit();let t=this.grade();this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0}))}reset(){super.reset(),this._responses={},this._gradingByStep={},this._isGraded=!1,this._currentStep=0,this._$text&&(this._$text.reset(),this._$text.clearGradingState()),this.setProgress(0),this.render()}};customElements.get("sequential-fill-blanks")||customElements.define("sequential-fill-blanks",de);function
|
|
3464
|
-
`).map(i=>i.replace(/^\s*[\d\w]+[\.\)]\s*/,"").trim()).filter(i=>i.length>0),t.length<2?{ok:!1,errors:{items:"At least 2 items are required for seriation"}}:{ok:!0,data:{type:"seriation",items:t}}}catch(n){return{ok:!1,errors:{"Parse Error":`${n instanceof Error?n.message:String(n)}`}}}}var ue=class extends x{constructor(t,r,i){super(t,r,i);this.interactionMechanic="static";this.currentOrder=[];this.isGraded=!1;this.draggedRowIndex=null;this.dragOverRowIndex=null;this.isDragging=!1;this.draggedRow=null;this.dragOffsetY=0;this.MAX_ITEMS=10;this.MIN_ITEM_HEIGHT=
|
|
3507
|
+
`,this.querySelector(".text-wrapper").appendChild(this._$text)}getTotalTargetCount(){return this._slides.reduce((t,r)=>t+r.targets.length,0)}saveCurrentStepResponse(){this._$text&&(this._responses[this._currentStep]=this._$text.getValue())}getResponseForStep(t){return this._responses[t]??{inputValues:{}}}updateProgressAcrossSteps(){let t=0;for(let r=0;r<this._slides.length;r++){let i=this._slides[r],a=this.getResponseForStep(r).inputValues??{};t+=i.targets.filter(s=>{let l=a[s.id];return l!=null&&String(l).trim()!==""}).length}this.setProgress(t)}getCurrentState(){return this.saveCurrentStepResponse(),{step:this._currentStep,responses:this._responses}}isInteractionComplete(){return this.getProgress().current===this.getProgress().total}onHint(){this.saveCurrentStepResponse();let t=this._slides[this._currentStep],i=this.getResponseForStep(this._currentStep).inputValues??{},o=t.targets.find(a=>{let s=i[a.id];return s==null||String(s).trim()===""});if(!o){this.emitHintShown("This step is complete. Move to another step or submit.");return}this.emitHintShown(`Complete the ${o.expectedValue.type} input on this step.`)}grade(){this.saveCurrentStepResponse();let t=0,r=0,i={};for(let s=0;s<this._slides.length;s++){let l=this._slides[s],c=this.getResponseForStep(s),d=Le(l,c);t+=d.correct,r+=d.total,i[s]=De(l,c)}this._gradingByStep=i,this._isGraded=!0;let o=this._gradingByStep[this._currentStep];return o&&this._$text.setGradingState(o),{score:r>0?Math.round(t/r*100):0,correct:t,total:r}}submit(){super.submit();let t=this.grade();this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0}))}reset(){super.reset(),this._responses={},this._gradingByStep={},this._isGraded=!1,this._currentStep=0,this._$text&&(this._$text.reset(),this._$text.clearGradingState()),this.setProgress(0),this.render()}};customElements.get("sequential-fill-blanks")||customElements.define("sequential-fill-blanks",de);function fa(e){let n={};if(!e)return n.data="Data is required",{ok:!1,errors:n};if(e.type!=="seriation"&&(n.type='Data type must be "seriation"'),!Array.isArray(e.items))return n.items="Items must be an array",{ok:!1,errors:n};e.items.length<2&&(n.items="At least 2 items are required for seriation"),e.items.some(i=>typeof i!="string"||i.trim()==="")&&(n.items="All items must be non-empty strings"),new Set(e.items).size!==e.items.length&&(n.items="All items must be unique (duplicates found)");let r=Object.keys(n).length===0;return{ok:r,errors:r?null:n}}function yt(e,n,t){let r=0,i=0,o=e.length;e.forEach((s,l)=>{let c=n.indexOf(s),d=t.querySelector(`[data-item="${s}"]`);if(c===-1){d&&(d.chipState="wrong");return}let u=Math.abs(c-l);u===0?(r+=100,i++,d&&(d.chipState="correct")):u===1?(r+=50,d&&(d.chipState="missed")):d&&(d.chipState="wrong")});let a=o>0?r/o:0;return console.log(`Seriation Score: ${a.toFixed(1)}% (${i}/${o} in correct position)`),{score:a,correct:i,total:o,answerKey:e,userResponse:n}}function ba(e){try{if(!e||typeof e!="string")return{ok:!1,errors:{input:"Input must be a non-empty string"}};let n=e.trim();if(n.length===0)return{ok:!1,errors:{input:"Input cannot be empty"}};let t=[];return n.includes("|")?t=n.split("|").map(i=>i.trim()).filter(i=>i.length>0):t=n.split(`
|
|
3508
|
+
`).map(i=>i.replace(/^\s*[\d\w]+[\.\)]\s*/,"").trim()).filter(i=>i.length>0),t.length<2?{ok:!1,errors:{items:"At least 2 items are required for seriation"}}:{ok:!0,data:{type:"seriation",items:t}}}catch(n){return{ok:!1,errors:{"Parse Error":`${n instanceof Error?n.message:String(n)}`}}}}var ue=class extends x{constructor(t,r,i){super(t,r,i);this.interactionMechanic="static";this.currentOrder=[];this.isGraded=!1;this.draggedRowIndex=null;this.dragOverRowIndex=null;this.isDragging=!1;this.draggedRow=null;this.dragOffsetY=0;this.MAX_ITEMS=10;this.MIN_ITEM_HEIGHT=56;if(!this.isValid||!this.data||!this.config)return;let o=this.data.items;this.data.items=o,this.config.shuffle?this.currentOrder=S([...this.data.items]):this.currentOrder=[...this.data.items],this.implementsProgress=!1,this.variant=this.config.variant}initialize(){this.boundPointerMove=this.handlePointerMove.bind(this),this.boundPointerUp=this.handlePointerUp.bind(this),window.addEventListener("pointermove",this.boundPointerMove),window.addEventListener("pointerup",this.boundPointerUp)}cleanup(){window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp)}onVariantChange(t){this.querySelectorAll("edu-chip").forEach(r=>{r.variant!==void 0&&(r.variant=t)}),this.variant=t}render(){this.innerHTML=`
|
|
3465
3509
|
<style>
|
|
3466
3510
|
rank-order {
|
|
3467
3511
|
display: flex;
|
|
@@ -3680,7 +3724,7 @@ slot {
|
|
|
3680
3724
|
<div class="container">
|
|
3681
3725
|
<div class="rows-container"></div>
|
|
3682
3726
|
</div>
|
|
3683
|
-
`,this.$container=this.querySelector(".container"),this.$rowsContainer=this.querySelector(".rows-container"),this.renderRows()}renderRows(){this.$rowsContainer.innerHTML="",this.currentOrder.forEach((t,r)=>{let i=document.createElement("div");i.className="row",i.dataset.index=String(r);let o=document.createElement("div");o.className="chip-wrapper";let a=document.createElement("edu-chip");a.variant=this.variant,a.dataset.item=t,a.prefix=String(r+1),a.draggable=!0,D(t,a,this.assets?.assetsById),this.isGraded&&(this.data.items.indexOf(t)===r?a.chipState="correct":a.chipState="wrong"),o.appendChild(a);let s=document.createElement("div");s.className="controls";let l=this.createButton("up",r);s.appendChild(l),i.appendChild(o),i.appendChild(s),this.isGraded||i.addEventListener("pointerdown",c=>this.handlePointerDown(c,r)),this.$rowsContainer.appendChild(i)})}createButton(t,r){let i=document.createElement("button");i.className="btn",i.dataset.direction=t,i.dataset.index=String(r),i.setAttribute("aria-label",t==="up"?"Move up":"Move down"),t==="up"&&r===0&&(i.disabled=!0),t==="down"&&r===this.currentOrder.length-1&&(i.disabled=!0),this.isGraded&&(i.disabled=!0);let o=t==="up"?B("up"):B("down");return i.innerHTML=o,i.addEventListener("click",()=>{t==="up"&&r>0?this.swapItems(r,r-1):t==="down"&&r<this.currentOrder.length-1&&this.swapItems(r,r+1)}),i}swapItems(t,r){let i=this.currentOrder[t];this.currentOrder[t]=this.currentOrder[r],this.currentOrder[r]=i,this.renderRows(),this.emitStateChange()}handlePointerDown(t,r){if(t.target.closest(".btn, .controls"))return;t.preventDefault(),t.stopPropagation(),this.isDragging=!0,this.draggedRow=t.currentTarget,this.draggedRowIndex=r;let i=this.draggedRow.getBoundingClientRect();this.dragOffsetY=t.clientY-i.top;try{this.draggedRow.setPointerCapture(t.pointerId)}catch(o){console.warn("Failed to capture pointer:",o)}this.draggedRow.classList.add("dragging"),this.$rowsContainer.style.userSelect="none"}handlePointerMove(t){if(!this.isDragging||!this.draggedRow)return;let r=this.getRowIndexAtY(t.clientY);if(this.$rowsContainer.querySelectorAll(".row").forEach(i=>{i.classList.remove("drag-over")}),r!==-1&&r!==this.draggedRowIndex){let i=Array.from(this.$rowsContainer.children);i[r]&&i[r].classList.add("drag-over")}}handlePointerUp(t){if(!this.isDragging||!this.draggedRow)return;try{this.draggedRow.releasePointerCapture(t.pointerId)}catch{}let r=this.getRowIndexAtY(t.clientY);r!==-1&&r!==this.draggedRowIndex&&this.swapItems(this.draggedRowIndex,r),this.$rowsContainer.querySelectorAll(".row").forEach(i=>{i.classList.remove("dragging","drag-over")}),this.$rowsContainer.style.userSelect="",this.isDragging=!1,this.draggedRow=null,this.draggedRowIndex=null,this.dragOverRowIndex=null}getRowIndexAtY(t){let r=Array.from(this.$rowsContainer.children);for(let i=0;i<r.length;i++){let o=r[i].getBoundingClientRect();if(t>=o.top&&t<=o.bottom)return i}return-1}getCurrentState(){return{currentOrder:[...this.currentOrder],correctOrder:[...this.data.items]}}isInteractionComplete(){return!0}onHint(){let t=0;this.currentOrder.forEach((r,i)=>{this.data.items[i]===r&&t++}),t===this.currentOrder.length?(alert('All items are in the correct order! Click "Check" to submit.'),this.emitHintShown("All items correctly ordered")):(alert(`Hint: ${t} out of ${this.currentOrder.length} items are in the correct position. Keep reordering!`),this.emitHintShown(`${t}/${this.currentOrder.length} correct`))}submit(){super.submit();let t=
|
|
3727
|
+
`,this.$container=this.querySelector(".container"),this.$rowsContainer=this.querySelector(".rows-container"),this.renderRows()}renderRows(){this.$rowsContainer.innerHTML="",this.currentOrder.forEach((t,r)=>{let i=document.createElement("div");i.className="row",i.dataset.index=String(r);let o=document.createElement("div");o.className="chip-wrapper";let a=document.createElement("edu-chip");a.variant=this.variant,a.dataset.item=t,a.prefix=String(r+1),a.draggable=!0,D(t,a,this.assets?.assetsById),this.isGraded&&(this.data.items.indexOf(t)===r?a.chipState="correct":a.chipState="wrong"),o.appendChild(a);let s=document.createElement("div");s.className="controls";let l=this.createButton("up",r);s.appendChild(l),i.appendChild(o),i.appendChild(s),this.isGraded||i.addEventListener("pointerdown",c=>this.handlePointerDown(c,r)),this.$rowsContainer.appendChild(i)})}createButton(t,r){let i=document.createElement("button");i.className="btn",i.dataset.direction=t,i.dataset.index=String(r),i.setAttribute("aria-label",t==="up"?"Move up":"Move down"),t==="up"&&r===0&&(i.disabled=!0),t==="down"&&r===this.currentOrder.length-1&&(i.disabled=!0),this.isGraded&&(i.disabled=!0);let o=t==="up"?B("up"):B("down");return i.innerHTML=o,i.addEventListener("click",()=>{t==="up"&&r>0?this.swapItems(r,r-1):t==="down"&&r<this.currentOrder.length-1&&this.swapItems(r,r+1)}),i}swapItems(t,r){let i=this.currentOrder[t];this.currentOrder[t]=this.currentOrder[r],this.currentOrder[r]=i,this.renderRows(),this.emitStateChange()}handlePointerDown(t,r){if(t.target.closest(".btn, .controls"))return;t.preventDefault(),t.stopPropagation(),this.isDragging=!0,this.draggedRow=t.currentTarget,this.draggedRowIndex=r;let i=this.draggedRow.getBoundingClientRect();this.dragOffsetY=t.clientY-i.top;try{this.draggedRow.setPointerCapture(t.pointerId)}catch(o){console.warn("Failed to capture pointer:",o)}this.draggedRow.classList.add("dragging"),this.$rowsContainer.style.userSelect="none"}handlePointerMove(t){if(!this.isDragging||!this.draggedRow)return;let r=this.getRowIndexAtY(t.clientY);if(this.$rowsContainer.querySelectorAll(".row").forEach(i=>{i.classList.remove("drag-over")}),r!==-1&&r!==this.draggedRowIndex){let i=Array.from(this.$rowsContainer.children);i[r]&&i[r].classList.add("drag-over")}}handlePointerUp(t){if(!this.isDragging||!this.draggedRow)return;try{this.draggedRow.releasePointerCapture(t.pointerId)}catch{}let r=this.getRowIndexAtY(t.clientY);r!==-1&&r!==this.draggedRowIndex&&this.swapItems(this.draggedRowIndex,r),this.$rowsContainer.querySelectorAll(".row").forEach(i=>{i.classList.remove("dragging","drag-over")}),this.$rowsContainer.style.userSelect="",this.isDragging=!1,this.draggedRow=null,this.draggedRowIndex=null,this.dragOverRowIndex=null}getRowIndexAtY(t){let r=Array.from(this.$rowsContainer.children);for(let i=0;i<r.length;i++){let o=r[i].getBoundingClientRect();if(t>=o.top&&t<=o.bottom)return i}return-1}getCurrentState(){return{currentOrder:[...this.currentOrder],correctOrder:[...this.data.items]}}isInteractionComplete(){return!0}onHint(){let t=0;this.currentOrder.forEach((r,i)=>{this.data.items[i]===r&&t++}),t===this.currentOrder.length?(alert('All items are in the correct order! Click "Check" to submit.'),this.emitHintShown("All items correctly ordered")):(alert(`Hint: ${t} out of ${this.currentOrder.length} items are in the correct position. Keep reordering!`),this.emitHintShown(`${t}/${this.currentOrder.length} correct`))}submit(){super.submit();let t=yt(this.data.items,this.currentOrder,this);console.log(`Rank Order Score: ${t.score.toFixed(1)}% (${t.correct}/${t.total} correct)`),this.isGraded=!0,this.renderRows(),this.dispatchEvent(new CustomEvent("interaction:graded",{detail:{result:t},bubbles:!0,composed:!0})),this.setAttribute("inert","")}reset(){super.reset(),this.config.shuffle?this.currentOrder=S([...this.data.items]):this.currentOrder=[...this.data.items],this.isGraded=!1,this.renderRows()}};customElements.get("rank-order")||customElements.define("rank-order",ue);var hi=!1,va=()=>{hi||(hi=!0,T({id:"open-classification",label:"Open Classification",elementTag:"open-classification",cognitiveOp:"classification",mechanic:"static",engine:"direct",ctor:we,capabilities:{isSequential:!1,implementsProgress:!0,usesAssets:!0,hasParser:!0,hasValidator:!0,hasGrader:!0}}),T({id:"sequential-classification",label:"Sequential Classification",elementTag:"sequential-classification",cognitiveOp:"classification",mechanic:"automatic-sequencing",engine:"direct",ctor:ye,capabilities:{isSequential:!0,implementsProgress:!0,usesAssets:!0,hasParser:!0,hasValidator:!0,hasGrader:!0}}),T({id:"mcq",label:"Multiple Choice / Multiple Response",elementTag:"mcq-interaction",cognitiveOp:"recognition",mechanic:"sequential",engine:"direct",ctor:ee,capabilities:{isSequential:!0,implementsProgress:!0,usesAssets:!0,hasParser:!0,hasValidator:!0,hasGrader:!0}}),T({id:"simultaneous-association",label:"Simultaneous Association",elementTag:"simultaneous-association",cognitiveOp:"association",mechanic:"static",engine:"direct",ctor:Ce,capabilities:{isSequential:!1,implementsProgress:!0,usesAssets:!0,hasParser:!0,hasValidator:!0,hasGrader:!0}}),T({id:"list-recall",label:"List Recall",elementTag:"list-recall",cognitiveOp:"freerecall",mechanic:"static",engine:"direct",ctor:te,capabilities:{isSequential:!1,implementsProgress:!0,usesAssets:!1,hasParser:!0,hasValidator:!0,hasGrader:!0}}),T({id:"lookup-table",label:"Lookup Table",elementTag:"lookup-table",cognitiveOp:"production",mechanic:"static",engine:"tables",ctor:Se,capabilities:{isSequential:!1,implementsProgress:!0,usesAssets:!1,hasParser:!0,hasValidator:!0,hasGrader:!0}}),T({id:"classification-matrix",label:"Classification Matrix",elementTag:"classification-matrix",cognitiveOp:"classification",mechanic:"static",engine:"tables",ctor:Te,capabilities:{isSequential:!1,implementsProgress:!0,usesAssets:!1,hasParser:!0,hasValidator:!0,hasGrader:!0}}),T({id:"nary-choice-table",label:"N-ary Choice Table",elementTag:"nary-choice-table",cognitiveOp:"discrimination",mechanic:"static",engine:"tables",ctor:$e,capabilities:{isSequential:!1,implementsProgress:!0,usesAssets:!1,hasParser:!0,hasValidator:!0,hasGrader:!0}}),T({id:"adjacency-table",label:"Adjacency Table",elementTag:"adjacency-table",cognitiveOp:"association",mechanic:"static",engine:"tables",ctor:Ae,capabilities:{isSequential:!1,implementsProgress:!0,usesAssets:!1,hasParser:!0,hasValidator:!0,hasGrader:!0}}),T({id:"mark-the-words",label:"Mark The Words",elementTag:"mark-the-words",cognitiveOp:"recognition",mechanic:"static",engine:"text",ctor:ie,capabilities:{isSequential:!1,implementsProgress:!0,usesAssets:!1,hasParser:!1,hasValidator:!0,hasGrader:!0}}),T({id:"sequential-mark-the-words",label:"Sequential Mark The Words",elementTag:"sequential-mark-the-words",cognitiveOp:"recognition",mechanic:"sequential",engine:"text",ctor:ne,capabilities:{isSequential:!0,implementsProgress:!0,usesAssets:!1,hasParser:!1,hasValidator:!0,hasGrader:!0}}),T({id:"categorize-the-words",label:"Categorize The Words",elementTag:"categorize-the-words",cognitiveOp:"classification",mechanic:"static",engine:"text",ctor:oe,capabilities:{isSequential:!1,implementsProgress:!0,usesAssets:!1,hasParser:!1,hasValidator:!0,hasGrader:!0}}),T({id:"sequential-categorize-the-words",label:"Sequential Categorize The Words",elementTag:"sequential-categorize-the-words",cognitiveOp:"classification",mechanic:"sequential",engine:"text",ctor:ae,capabilities:{isSequential:!0,implementsProgress:!0,usesAssets:!1,hasParser:!1,hasValidator:!0,hasGrader:!0}}),T({id:"text-transformation",label:"Text Transformation",elementTag:"text-transformation",cognitiveOp:"transformation",mechanic:"static",engine:"text",ctor:se,capabilities:{isSequential:!1,implementsProgress:!0,usesAssets:!1,hasParser:!1,hasValidator:!0,hasGrader:!0}}),T({id:"sequential-text-transformation",label:"Sequential Text Transformation",elementTag:"sequential-text-transformation",cognitiveOp:"transformation",mechanic:"sequential",engine:"text",ctor:le,capabilities:{isSequential:!0,implementsProgress:!0,usesAssets:!1,hasParser:!1,hasValidator:!0,hasGrader:!0}}),T({id:"fill-blanks",label:"Fill Blanks",elementTag:"fill-blanks",cognitiveOp:"cuedrecall",mechanic:"static",engine:"text",ctor:ce,capabilities:{isSequential:!1,implementsProgress:!0,usesAssets:!1,hasParser:!1,hasValidator:!0,hasGrader:!0}}),T({id:"sequential-fill-blanks",label:"Sequential Fill Blanks",elementTag:"sequential-fill-blanks",cognitiveOp:"cuedrecall",mechanic:"sequential",engine:"text",ctor:de,capabilities:{isSequential:!0,implementsProgress:!0,usesAssets:!1,hasParser:!1,hasValidator:!0,hasGrader:!0}}),T({id:"rank-order",label:"Rank Order",elementTag:"rank-order",cognitiveOp:"seriation",mechanic:"static",engine:"direct",ctor:ue,capabilities:{isSequential:!1,implementsProgress:!1,usesAssets:!0,hasParser:!0,hasValidator:!0,hasGrader:!0}}))};va();var gi=`<header part='header'>
|
|
3684
3728
|
<div class="prompt-container">
|
|
3685
3729
|
<button class="prompt-btn btn" title="See Prompt Data" part="see-prompt">
|
|
3686
3730
|
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
@@ -3742,13 +3786,6 @@ slot {
|
|
|
3742
3786
|
<div class="radio-nav" part="radio-nav"></div>
|
|
3743
3787
|
<div class="action-buttons">
|
|
3744
3788
|
<button class="check-btn" type="button" part="check">Check</button>
|
|
3745
|
-
|
|
3746
|
-
<button class="see-answers-btn btn" title="See answers" part="see-answers">
|
|
3747
|
-
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
3748
|
-
<path d="M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6-10-6-10-6Z"/>
|
|
3749
|
-
<circle cx="12" cy="12" r="3"/>
|
|
3750
|
-
</svg>
|
|
3751
|
-
</button>
|
|
3752
3789
|
<button class="retry-btn btn" title="Retry" part="retry">
|
|
3753
3790
|
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
3754
3791
|
<path d="M17 2v4h-4"/>
|
|
@@ -3767,7 +3804,7 @@ slot {
|
|
|
3767
3804
|
|
|
3768
3805
|
</div>
|
|
3769
3806
|
</footer>
|
|
3770
|
-
`;var
|
|
3807
|
+
`;var mi=`:host {
|
|
3771
3808
|
display: flex;
|
|
3772
3809
|
width: 100%;
|
|
3773
3810
|
height: 100%;
|
|
@@ -3916,13 +3953,15 @@ footer {
|
|
|
3916
3953
|
position: relative;
|
|
3917
3954
|
display: flex;
|
|
3918
3955
|
flex-direction: column;
|
|
3919
|
-
justify-content:
|
|
3956
|
+
justify-content: flex-start;
|
|
3920
3957
|
align-items: center;
|
|
3921
|
-
|
|
3958
|
+
padding: clamp(0.35rem, 1cqh, 0.75rem) clamp(0.5rem, 1.5cqw, 1rem);
|
|
3922
3959
|
gap: clamp(0.25rem, 0.8cqh, 0.5rem);
|
|
3923
3960
|
flex-shrink: 0;
|
|
3924
|
-
height:
|
|
3925
|
-
min-height: clamp(
|
|
3961
|
+
height: auto;
|
|
3962
|
+
min-height: clamp(76px, 12cqh, 120px);
|
|
3963
|
+
box-sizing: border-box;
|
|
3964
|
+
overflow: visible;
|
|
3926
3965
|
}
|
|
3927
3966
|
|
|
3928
3967
|
.progress-container {
|
|
@@ -3932,6 +3971,7 @@ footer {
|
|
|
3932
3971
|
justify-content: space-between;
|
|
3933
3972
|
gap: clamp(0.25rem, 1cqw, 0.6rem);
|
|
3934
3973
|
width: 100%;
|
|
3974
|
+
min-width: 0;
|
|
3935
3975
|
}
|
|
3936
3976
|
|
|
3937
3977
|
.progress-bar {
|
|
@@ -4051,6 +4091,14 @@ footer {
|
|
|
4051
4091
|
align-items: center;
|
|
4052
4092
|
justify-content: center;
|
|
4053
4093
|
flex-wrap: wrap;
|
|
4094
|
+
width: 100%;
|
|
4095
|
+
min-width: 0;
|
|
4096
|
+
}
|
|
4097
|
+
|
|
4098
|
+
.prompt-btn,
|
|
4099
|
+
.retry-btn,
|
|
4100
|
+
.scores-btn {
|
|
4101
|
+
color: rgb(var(--edu-ink));
|
|
4054
4102
|
}
|
|
4055
4103
|
|
|
4056
4104
|
.check-btn {
|
|
@@ -4111,6 +4159,8 @@ footer {
|
|
|
4111
4159
|
gap: 0.5rem;
|
|
4112
4160
|
align-items: center;
|
|
4113
4161
|
justify-content: center;
|
|
4162
|
+
width: 100%;
|
|
4163
|
+
min-width: 0;
|
|
4114
4164
|
}
|
|
4115
4165
|
|
|
4116
4166
|
.radio-nav[data-active="true"] {
|
|
@@ -4173,6 +4223,10 @@ footer {
|
|
|
4173
4223
|
|
|
4174
4224
|
& .timer { }
|
|
4175
4225
|
|
|
4226
|
+
& footer {
|
|
4227
|
+
color: rgb(var(--edu-inverted-ink));
|
|
4228
|
+
}
|
|
4229
|
+
|
|
4176
4230
|
& .check-btn {
|
|
4177
4231
|
background: transparent;
|
|
4178
4232
|
color: rgb(var(--edu-ink));
|
|
@@ -4206,7 +4260,8 @@ footer {
|
|
|
4206
4260
|
:host([variant="minimal"]) {
|
|
4207
4261
|
& .wrap {
|
|
4208
4262
|
border: 1px solid rgb(var(--edu-border));
|
|
4209
|
-
border-radius:
|
|
4263
|
+
border-radius: 10px;
|
|
4264
|
+
background: rgb(var(--edu-card));
|
|
4210
4265
|
}
|
|
4211
4266
|
|
|
4212
4267
|
& .timer {
|
|
@@ -4214,10 +4269,12 @@ footer {
|
|
|
4214
4269
|
}
|
|
4215
4270
|
|
|
4216
4271
|
& .check-btn {
|
|
4217
|
-
border-radius:
|
|
4272
|
+
border-radius: 10px;
|
|
4273
|
+
box-shadow: none;
|
|
4218
4274
|
}
|
|
4219
4275
|
|
|
4220
4276
|
& footer {
|
|
4277
|
+
color: rgb(var(--edu-inverted-ink));
|
|
4221
4278
|
border-top: 1px solid rgb(var(--edu-border));
|
|
4222
4279
|
}
|
|
4223
4280
|
|
|
@@ -4234,7 +4291,8 @@ footer {
|
|
|
4234
4291
|
}
|
|
4235
4292
|
|
|
4236
4293
|
& .radio-nav label {
|
|
4237
|
-
border-radius:
|
|
4294
|
+
border-radius: 999px;
|
|
4295
|
+
background: transparent;
|
|
4238
4296
|
}
|
|
4239
4297
|
}
|
|
4240
4298
|
|
|
@@ -4256,6 +4314,7 @@ footer {
|
|
|
4256
4314
|
}
|
|
4257
4315
|
|
|
4258
4316
|
& footer {
|
|
4317
|
+
color: rgb(var(--edu-inverted-ink));
|
|
4259
4318
|
border-top: 1px solid rgb(var(--edu-border) / 0.5);
|
|
4260
4319
|
padding: 1.25rem;
|
|
4261
4320
|
}
|
|
@@ -4291,7 +4350,7 @@ footer {
|
|
|
4291
4350
|
|
|
4292
4351
|
:host([variant="playful"]) {
|
|
4293
4352
|
& .wrap {
|
|
4294
|
-
color: rgb(var(--edu-
|
|
4353
|
+
color: rgb(var(--edu-ink));
|
|
4295
4354
|
border-radius: 14px;
|
|
4296
4355
|
border: 2px dashed rgb(var(--edu-border));
|
|
4297
4356
|
}
|
|
@@ -4302,10 +4361,13 @@ footer {
|
|
|
4302
4361
|
}
|
|
4303
4362
|
|
|
4304
4363
|
& .check-btn {
|
|
4364
|
+
background: linear-gradient(135deg, rgb(var(--edu-first-accent));
|
|
4365
|
+
color: rgb(var(--edu-inverted-ink));
|
|
4305
4366
|
border-radius: 12px;
|
|
4306
4367
|
font-weight: 700;
|
|
4307
4368
|
text-transform: uppercase;
|
|
4308
4369
|
letter-spacing: 0.5px;
|
|
4370
|
+
box-shadow: 0 8px 18px rgb(var(--edu-shadow-color) / 0.16);
|
|
4309
4371
|
}
|
|
4310
4372
|
|
|
4311
4373
|
& .check-btn:hover:not(:disabled) {
|
|
@@ -4313,6 +4375,7 @@ footer {
|
|
|
4313
4375
|
}
|
|
4314
4376
|
|
|
4315
4377
|
& footer {
|
|
4378
|
+
color: rgb(var(--edu-inverted-ink));
|
|
4316
4379
|
border-top: 2px dashed rgb(var(--edu-border));
|
|
4317
4380
|
}
|
|
4318
4381
|
|
|
@@ -4332,7 +4395,9 @@ footer {
|
|
|
4332
4395
|
}
|
|
4333
4396
|
|
|
4334
4397
|
& .radio-nav label {
|
|
4335
|
-
background: rgb(var(--edu-
|
|
4398
|
+
background: rgb(var(--edu-card));
|
|
4399
|
+
color: rgb(var(--edu-ink));
|
|
4400
|
+
border: 2px solid rgb(var(--edu-border));
|
|
4336
4401
|
border-radius: 50px;
|
|
4337
4402
|
font-weight: 700;
|
|
4338
4403
|
}
|
|
@@ -4342,9 +4407,10 @@ footer {
|
|
|
4342
4407
|
}
|
|
4343
4408
|
|
|
4344
4409
|
& .radio-nav input:checked + label {
|
|
4345
|
-
background: rgb(var(--edu-first-accent));
|
|
4410
|
+
background: linear-gradient(135deg, rgb(var(--edu-first-accent));
|
|
4346
4411
|
color: rgb(var(--edu-inverted-ink));
|
|
4347
|
-
|
|
4412
|
+
border-color: transparent;
|
|
4413
|
+
box-shadow: 0 5px 15px rgb(var(--edu-shadow-color) / 0.18);
|
|
4348
4414
|
}
|
|
4349
4415
|
}
|
|
4350
4416
|
|
|
@@ -4353,13 +4419,14 @@ footer {
|
|
|
4353
4419
|
background: rgba(var(--edu-card), 0.7);
|
|
4354
4420
|
backdrop-filter: blur(10px);
|
|
4355
4421
|
border: 1px solid rgba(var(--edu-border), 0.35);
|
|
4356
|
-
border-radius:
|
|
4422
|
+
border-radius: 14px;
|
|
4423
|
+
box-shadow: 0 16px 32px rgba(var(--edu-shadow-color), 0.12);
|
|
4357
4424
|
}
|
|
4358
4425
|
|
|
4359
4426
|
& .check-btn {
|
|
4360
|
-
background: rgba(var(--edu-first-accent), 0.
|
|
4427
|
+
background: rgba(var(--edu-first-accent), 0.88);
|
|
4361
4428
|
backdrop-filter: blur(5px);
|
|
4362
|
-
border-radius:
|
|
4429
|
+
border-radius: 999px;
|
|
4363
4430
|
}
|
|
4364
4431
|
|
|
4365
4432
|
& .check-btn:hover:not(:disabled) {
|
|
@@ -4383,6 +4450,7 @@ footer {
|
|
|
4383
4450
|
background: rgba(var(--edu-card), 0.5);
|
|
4384
4451
|
backdrop-filter: blur(5px);
|
|
4385
4452
|
border: 1px solid rgba(var(--edu-border), 0.35);
|
|
4453
|
+
border-radius: 999px;
|
|
4386
4454
|
}
|
|
4387
4455
|
|
|
4388
4456
|
& .radio-nav input:checked + label {
|
|
@@ -4412,6 +4480,7 @@ footer {
|
|
|
4412
4480
|
}
|
|
4413
4481
|
|
|
4414
4482
|
& footer {
|
|
4483
|
+
color: rgb(var(--edu-inverted-ink));
|
|
4415
4484
|
border-top: 1px solid rgb(var(--edu-border));
|
|
4416
4485
|
padding: 1rem 1.5rem;
|
|
4417
4486
|
}
|
|
@@ -4465,6 +4534,7 @@ footer {
|
|
|
4465
4534
|
}
|
|
4466
4535
|
|
|
4467
4536
|
& footer {
|
|
4537
|
+
color: rgb(var(--edu-inverted-ink));
|
|
4468
4538
|
border-top: 2px solid rgb(var(--edu-border));
|
|
4469
4539
|
}
|
|
4470
4540
|
|
|
@@ -4561,13 +4631,14 @@ footer {
|
|
|
4561
4631
|
|
|
4562
4632
|
:host([variant="card"]) {
|
|
4563
4633
|
& .wrap {
|
|
4564
|
-
border-radius:
|
|
4565
|
-
|
|
4634
|
+
border-radius: 14px;
|
|
4635
|
+
background: rgb(var(--edu-card));
|
|
4636
|
+
box-shadow: 0 10px 24px rgba(var(--edu-shadow-color), 0.12), 0 2px 4px rgba(var(--edu-shadow-color), 0.05);
|
|
4566
4637
|
}
|
|
4567
4638
|
|
|
4568
4639
|
& .check-btn {
|
|
4569
|
-
border-radius:
|
|
4570
|
-
box-shadow: 0
|
|
4640
|
+
border-radius: 999px;
|
|
4641
|
+
box-shadow: 0 6px 14px rgba(var(--edu-shadow-color), 0.12);
|
|
4571
4642
|
}
|
|
4572
4643
|
|
|
4573
4644
|
& .check-btn:hover:not(:disabled) {
|
|
@@ -4579,20 +4650,20 @@ footer {
|
|
|
4579
4650
|
}
|
|
4580
4651
|
|
|
4581
4652
|
& .radio-nav label {
|
|
4582
|
-
border-radius:
|
|
4583
|
-
box-shadow: 0
|
|
4653
|
+
border-radius: 999px;
|
|
4654
|
+
box-shadow: 0 4px 10px rgba(var(--edu-shadow-color), 0.08);
|
|
4584
4655
|
}
|
|
4585
4656
|
|
|
4586
4657
|
& .radio-nav input:checked + label {
|
|
4587
4658
|
box-shadow: 0 4px 8px rgba(var(--edu-first-accent), 0.2);
|
|
4588
4659
|
}
|
|
4589
4660
|
}
|
|
4590
|
-
`;var Be=class extends HTMLElement{constructor(){super();this.soundManager=new
|
|
4661
|
+
`;var Be=class extends HTMLElement{constructor(){super();this.soundManager=new G;this.animationsManager=new L;this.timerInterval=null;this.remainingSeconds=0;this.interactionComplete=!1;this.attemptCount=0;this.attemptLimit=null;this.currentScreen="interaction";this.attachShadow({mode:"open"});let t=document.createElement("style");t.textContent=mi,this.shadowRoot.append(t);let r=document.createElement("section");r.className="wrap",r.innerHTML=gi,this.shadowRoot.append(r),L.injectKeyframes(this.shadowRoot),this.$headerEl=r.querySelector("header"),this.$footerEl=r.querySelector("footer"),this.$titleEl=r.querySelector(".title"),this.$promptBtn=r.querySelector(".prompt-btn"),this.$timerEl=r.querySelector(".timer"),this.$checkBtn=r.querySelector(".check-btn"),this.$scoresBtn=r.querySelector(".scores-btn"),this.$retryBtn=r.querySelector(".retry-btn"),this.$radioNav=r.querySelector(".radio-nav"),this.$progressContainer=r.querySelector(".progress-container"),this.$progressBar=r.querySelector(".progress-bar"),this.$progressIcon=r.querySelector(".progress-icon-wrapper"),this.$progressCounter=r.querySelector(".progress-counter"),this.$contentEl=r.querySelector('[part="content"]'),this.animationsManager.isEnabled=!0,this.$interactionScreen=r.querySelector('[data-screen="interaction"]'),this.$errorContent=r.querySelector(".error-content"),this.$attemptsMessage=r.querySelector(".attempts-message"),this.$scoreDisplay=r.querySelector(".score-display"),this.$timerDisplay=r.querySelector(".timer-display"),this.setupShellListeners()}static get observedAttributes(){return["show-header","show-footer"]}connectedCallback(){this.hasAttribute("show-header")||this.setAttribute("show-header","true"),this.hasAttribute("show-footer")||this.setAttribute("show-footer","true"),this.updateVisibility(),this.animationsManager.animate(this.$progressIcon,"heartbeat"),this.animationsManager.animate(this.$promptBtn,"wobble")}disconnectedCallback(){this.stopTimer(),this.removeInteractionListeners()}attributeChangedCallback(t,r,i){r!==i&&this.updateVisibility()}setInteraction(t){if(this.stopTimer(),!t.isValid){this.$errorContent.textContent=t.errors??"Error loading the interaction.",this.switchScreen("error");return}this.soundManager.playSound("start"),this.interaction&&(this.removeInteractionListeners(),this.$interactionScreen.innerHTML=""),this.interaction=t,this.interactionComplete=!1;let r=this.interaction.config;this.reset(),this.switchScreen("interaction");let i=r.variant??"elegant";this.setAttribute("variant",i),this.interaction.onVariantChange(i),this.$titleEl.textContent=r.prompt||"",r.promptData&&r.promptModality?(this.$titleEl.style.cursor="pointer",this.$titleEl.title="Click to view prompt details",this.$promptBtn.addEventListener("click",()=>this.openPromptDialog()),this.$titleEl.addEventListener("click",()=>this.openPromptDialog())):(this.$titleEl.style.cursor="",this.$titleEl.style.textDecoration="",this.$titleEl.title=""),r.timer!==null&&r.timer>30?(this.remainingSeconds=r.timer,this.$timerEl.classList.remove("edu-hidden"),this.updateTimerDisplay(),this.startTimer()):this.$timerEl.classList.add("edu-hidden"),this.attemptLimit=r.attemptLimit,this.attemptCount=0,this.interaction.interactionMechanic==="sequential"?(this.$radioNav.dataset.active="true",this.renderRadioNav()):this.$radioNav.dataset.active="false",this.interaction.implementsProgress?(this.$checkBtn.classList.add("edu-hidden"),this.$progressContainer.classList.remove("edu-hidden"),this.$progressCounter.textContent=`0/${this.interaction.progressTracker.total}`):(this.$progressContainer.classList.add("edu-hidden"),this.$checkBtn.classList.remove("edu-hidden")),this.setupInteractionListeners(),this.$interactionScreen.innerHTML="",this.$interactionScreen.appendChild(t)}removeInteraction(){this.interaction&&(this.removeInteractionListeners(),this.$interactionScreen.innerHTML="",this.interaction=void 0,this.interactionComplete=!1)}setupShellListeners(){this.$checkBtn.addEventListener("click",()=>{this.soundManager.playSound("pop");try{this.interaction.submit()}catch(t){console.error("Submit failed:",t)}}),this.$scoresBtn.addEventListener("click",()=>{this.soundManager.playSound("pop"),this.currentScreen==="score"?this.switchScreen("interaction"):this.switchScreen("score")}),this.$timerEl.addEventListener("click",()=>{this.soundManager.playSound("pop"),this.$timerDisplay.append(this.$timerEl),this.currentScreen==="time"?(this.switchScreen("interaction"),this.$headerEl.append(this.$timerEl)):this.switchScreen("time")}),this.$retryBtn.addEventListener("click",()=>this.handleRetry()),this.$radioNav.addEventListener("change",t=>{let r=t.target;if(r.type==="radio"){let i=parseInt(r.id.replace("step-",""),10);this.interaction&&this.interaction.setSteps(i),this.dispatchEvent(new CustomEvent("navigation-change",{detail:{step:i},bubbles:!0,composed:!0}))}})}setupInteractionListeners(){this.interaction.addEventListener("interaction:ready",t=>{console.log("[Shell] Interaction ready:",t.detail.id)}),this.interaction.addEventListener("interaction:progress",t=>{let{current:r,total:i,percentage:o}=t.detail;this.updateProgress(r,i),r===i&&i>0?(this.interactionComplete=!0,this.$checkBtn.classList.remove("edu-hidden")):(this.interactionComplete=!1,this.interaction.implementsProgress&&this.$checkBtn.classList.add("edu-hidden"))}),this.interaction.addEventListener("interaction:complete",t=>{console.log("[Shell] Interaction complete:",t.detail),this.stopTimer(),this.handleCompletion(t.detail.state)}),this.interaction.addEventListener("interaction:graded",t=>{t.detail.result.score===100?(this.soundManager.playSound("success"),this.animationsManager.animate(this.$progressIcon,"spin-pulse")):(this.soundManager.playSound("failure"),this.animationsManager.animate(this.$progressIcon,"shake")),this.handleGraded(t.detail.result)}),this.interaction.addEventListener("interaction:hint-shown",t=>{console.log("[Shell] Hint shown:",t.detail.message)}),this.interaction.addEventListener("interaction:error",t=>{console.error("[Shell] Interaction error:",t.detail),alert(t.detail.message)})}removeInteractionListeners(){}updateProgress(t,r){this.$progressBar.max=r,this.$progressBar.value=t??0,this.$progressCounter.textContent=`${t}/${r}`;let i=r>0?t/r*100:0,a=this.$progressBar.offsetWidth*i/100-12;this.$progressIcon.style.left=`${Math.max(0,a)}px`}handleCompletion(t){this.dispatchEvent(new CustomEvent("shell:interaction-complete",{detail:{state:t},bubbles:!0,composed:!0})),console.log("[Shell] Interaction submitted with state:",t)}handleGraded(t){this.$checkBtn.classList.add("edu-hidden"),this.$scoresBtn.classList.remove("edu-hidden"),this.$retryBtn.classList.remove("edu-hidden"),this.attemptLimit&&this.attemptCount>this.attemptLimit&&this.$retryBtn.classList.add("edu-hidden");let r=t.score;this.$scoreDisplay.innerHTML=`
|
|
4591
4662
|
<div style="font-size: 4rem; font-weight: 700; color: ${r>=75?"rgb(var(--edu-success))":r>=50?"rgba(139, 195, 74)":r>=25?"rgb(var(--edu-warning))":"rgb(var(--edu-error))"}">${r}%</div>
|
|
4592
4663
|
<div style="font-size: 1.5rem; margin-top: 1rem; color: rgb(var(--edu-second-ink));">
|
|
4593
4664
|
${r===100?"Perfect Score! \u{1F389}":r>=75?"Great Job!":r>=50?"Good Effort!":r>=25?"Keep Trying!":"Try Again!"}
|
|
4594
4665
|
</div>
|
|
4595
|
-
`,this.$progressIcon.classList.remove("score-fail","score-low","score-mid","score-high"),this.$progressBar.classList.remove("score-fail","score-low","score-mid","score-high");let i="";r<=25?i="score-fail":r<=50?i="score-low":r<=75?i="score-mid":i="score-high",this.$progressIcon.classList.add(i),this.$progressBar.classList.add(i)}reset(){this.resetTimer(),this.interaction.implementsProgress||this.$checkBtn.classList.remove("edu-hidden"),this.$
|
|
4666
|
+
`,this.$progressIcon.classList.remove("score-fail","score-low","score-mid","score-high"),this.$progressBar.classList.remove("score-fail","score-low","score-mid","score-high");let i="";r<=25?i="score-fail":r<=50?i="score-low":r<=75?i="score-mid":i="score-high",this.$progressIcon.classList.add(i),this.$progressBar.classList.add(i)}reset(){this.resetTimer(),this.interaction.implementsProgress||this.$checkBtn.classList.remove("edu-hidden"),this.$scoresBtn.classList.add("edu-hidden"),this.$retryBtn.classList.add("edu-hidden"),this.$progressIcon.classList.remove("score-fail","score-low","score-mid","score-high"),this.$progressBar.classList.remove("score-fail","score-low","score-mid","score-high"),this.animationsManager.animate(this.$progressIcon,"heartbeat"),this.$progressBar.value=0,this.updateProgress(0,this.interaction.progressTracker.total),this.interaction.interactionMechanic==="sequential"&&this.renderRadioNav()}handleRetry(){if(this.$retryBtn.classList.add("edu-hidden"),this.soundManager.playSound("pop"),this.attemptCount++,this.attemptLimit&&this.attemptLimit>0){let t=this.attemptLimit-this.attemptCount+1;this.$attemptsMessage.textContent=`${t} attempt${t!==1?"s":""} remaining`,this.switchScreen("attempts"),setTimeout(()=>{this.switchScreen("interaction"),this.reset(),this.resumeTimer(),this.interaction?.reset(),this.soundManager.playSound("flip")},2e3)}else this.switchScreen("interaction"),this.interaction?.reset()}openPromptDialog(){let t=this.interaction?.config;if(!t)return;this.soundManager.playSound("pop");let r=document.querySelector("edu-dialog#prompt-dialog");r||(r=document.createElement("edu-dialog"),r.id="prompt-dialog",document.body.appendChild(r)),r.title=t.construct||this.interaction?.config.promptModality||"Prompt";let i=document.createElement("edu-media");i.setAttribute("type",t.promptModality),i.setAttribute("data",t.promptData),t.promptDataSpec&&i.setAttribute("spec",t.promptDataSpec),r.innerHTML="",r.appendChild(i),r.open()}switchScreen(t){this.shadowRoot.querySelectorAll(".screen").forEach(r=>{let i=r.getAttribute("data-screen");r.style.display=i===t?"block":"none"}),this.currentScreen=t,console.log(`[Shell] Switched to screen: ${t}`)}startTimer(){this.timerInterval=window.setInterval(()=>{this.remainingSeconds--,this.updateTimerDisplay(),this.remainingSeconds<=0&&(this.stopTimer(),this.handleTimerComplete())},1e3)}stopTimer(){this.timerInterval!==null&&(clearInterval(this.timerInterval),this.timerInterval=null)}getFormattedTime(t){let r=Math.floor(t/60),i=t%60;return`${r}:${i.toString().padStart(2,"0")}`}updateTimerDisplay(){this.$timerEl.textContent=this.getFormattedTime(this.remainingSeconds),this.remainingSeconds===30&&(this.soundManager.playSound("low-time"),this.animationsManager.animate(this.$timerEl,"shake")),delete this.$timerEl.dataset.warning,delete this.$timerEl.dataset.danger,this.remainingSeconds<=10?this.$timerEl.dataset.danger="true":this.remainingSeconds<=30&&(this.$timerEl.dataset.warning="true")}handleTimerComplete(){console.log("[Shell] Timer complete");try{this.interaction.submit()}catch(t){console.error("Auto-submit on timer failed:",t)}this.dispatchEvent(new CustomEvent("shell:timer-complete",{bubbles:!0,composed:!0}))}pauseTimer(){this.stopTimer()}resumeTimer(){this.remainingSeconds>0&&this.timerInterval===null&&this.startTimer()}resetTimer(){this.stopTimer(),this.remainingSeconds=this.interaction.config.timer,this.updateTimerDisplay()}updateVisibility(){let t=this.getAttribute("show-header")!=="false",r=this.getAttribute("show-footer")!=="false";this.$headerEl.style.display=t?"":"none",this.$footerEl.style.display=r?"":"none"}renderRadioNav(){let t=this.interaction&&"slidesCount"in this.interaction?this.interaction.slidesCount:1;this.$radioNav.innerHTML="";for(let r=1;r<=t;r++){let i=document.createElement("input");i.type="radio",i.name="step-nav",i.id=`step-${r}`,r===1&&(i.checked=!0);let o=document.createElement("label");o.htmlFor=`step-${r}`,o.textContent=String(r),this.$radioNav.appendChild(i),this.$radioNav.appendChild(o)}}getContentArea(){return this.$contentEl}};customElements.get("edu-window")||customElements.define("edu-window",Be);et();export{Ae as AdjacencyTable,be as AssetValidationError,x as BaseInteraction,oe as CategorizeTheWords,Te as ClassificationMatrix,Qe as EduTable,Je as EduText,ce as FillBlanks,Be as InteractionsBaseShell,te as ListRecall,Se as LookupTable,ee as MCQ,ie as MarkTheWords,$e as NaryChoiceTable,we as OpenClassification,ue as RankOrder,ae as SequentialCategorizeTheWords,ye as SequentialClassification,de as SequentialFillBlanks,ne as SequentialMarkTheWords,le as SequentialTextTransformation,Ce as SimultaneousAssociation,se as TextTransformation,ll as adjacencyTableDataParser,pl as adjacencyTableDataValidator,Vr as adjacencyTableGrader,sl as basicTableDataParser,ul as basicTableDataValidator,Or as classificationTableGrader,Ma as clearInteractionRegistry,Fe as cognikitThemePresets,ke as compareValues,No as configureCognikit,Ra as createInteraction,bt as defaultCognikitThemeVariables,We as detectCellKind,je as ensureCognikitTheme,Fr as getAdjacencyCellGrading,Ke as getAllUniqueValues,Ee as getAllValues,De as getBlanksGradingState,Ur as getClassificationCellGrading,Pe as getClassificationGradingState,Go as getCognikitConfig,Oo as getCognikitThemePresets,pa as getDNDGradingState,Me as getHighlightGradingState,Yo as getInteraction,La as getInteractionRegistry,jr as getLookupCellGrading,Yr as getNaryCellGrading,wt as getTransformationGradingState,Da as listInteractions,cl as lookupTableDataParser,hl as lookupTableDataValidator,Gr as lookupTableGrader,Nr as naryTableGrader,ca as parseTextEngineSequential,qo as parseYamlAssets,zr as recognitionGrader,Hs as recognitionParser,Gs as recognitionValidator,va as registerBuiltInInteractions,T as registerInteraction,Fo as resetCognikitTheme,Mr as resolveCognikitTheme,yt as seriationGrader,ba as seriationParser,fa as seriationValidator,Vo as setCognikitTheme,oi as textEngineBaseDataValidator,ri as textEngineBaseGrammarParser,ai as textEngineBlanksDataValidator,Le as textEngineBlanksGrader,ii as textEngineBlanksGrammarParser,si as textEngineClassificationDataValidator,Re as textEngineClassificationGrader,ni as textEngineClassificationGrammarParser,ua as textEngineDNDGrader,da as textEngineDataValidator,_e as textEngineHighlightGrader,Ie as textEngineTransformationGrader,Ia as unregisterInteraction,zo as validateAndNormalizeAssets};
|
|
4596
4667
|
/*! Bundled license information:
|
|
4597
4668
|
|
|
4598
4669
|
js-yaml/dist/js-yaml.mjs:
|