@mathwiz/ui-components 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/EquationRender/EquationRender.d.ts.map +1 -1
- package/dist/components/MathCard/MathCard.d.ts.map +1 -1
- package/dist/components/MathCard/MathCard.types.d.ts +3 -2
- package/dist/components/MathCard/MathCard.types.d.ts.map +1 -1
- package/dist/components/MathCard/components/Explanation.d.ts +1 -1
- package/dist/components/MathCard/components/Explanation.d.ts.map +1 -1
- package/dist/components/MathCard/context.d.ts +1 -0
- package/dist/components/MathCard/context.d.ts.map +1 -1
- package/dist/components/MathCard/utils/contentRenderer.d.ts +6 -2
- package/dist/components/MathCard/utils/contentRenderer.d.ts.map +1 -1
- package/dist/components/MathCard/utils/templateParser.d.ts +14 -0
- package/dist/components/MathCard/utils/templateParser.d.ts.map +1 -1
- package/dist/components/MathGraph/GraphContainer.d.ts.map +1 -1
- package/dist/components/MathSessionContainer/MathSessionContainer.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +235 -79
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -328,7 +328,7 @@ l0,-`+(r+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
328
328
|
|[ \r ]+
|
|
329
329
|
?)[ \r ]*`,combiningDiacriticalMarkString="[̀-ͯ]",combiningDiacriticalMarksEndRegex=new RegExp(combiningDiacriticalMarkString+"+$"),tokenRegexString="("+spaceRegexString+"+)|"+(controlSpaceRegexString+"|")+"([!-\\[\\]-‧-豈-]"+(combiningDiacriticalMarkString+"*")+"|[\uD800-\uDBFF][\uDC00-\uDFFF]"+(combiningDiacriticalMarkString+"*")+"|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5"+("|"+controlWordWhitespaceRegexString)+("|"+controlSymbolRegexString+")");class Lexer{constructor(t,r){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=t,this.settings=r,this.tokenRegex=new RegExp(tokenRegexString,"g"),this.catcodes={"%":14,"~":13}}setCatcode(t,r){this.catcodes[t]=r}lex(){var t=this.input,r=this.tokenRegex.lastIndex;if(r===t.length)return new Token("EOF",new SourceLocation(this,r,r));var s=this.tokenRegex.exec(t);if(s===null||s.index!==r)throw new ParseError("Unexpected character: '"+t[r]+"'",new Token(t[r],new SourceLocation(this,r,r+1)));var n=s[6]||s[3]||(s[2]?"\\ ":" ");if(this.catcodes[n]===14){var o=t.indexOf(`
|
|
330
330
|
`,this.tokenRegex.lastIndex);return o===-1?(this.tokenRegex.lastIndex=t.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=o+1,this.lex()}return new Token(n,new SourceLocation(this,r,this.tokenRegex.lastIndex))}}class Namespace{constructor(t,r){t===void 0&&(t={}),r===void 0&&(r={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=r,this.builtins=t,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new ParseError("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var t=this.undefStack.pop();for(var r in t)t.hasOwnProperty(r)&&(t[r]==null?delete this.current[r]:this.current[r]=t[r])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(t){return this.current.hasOwnProperty(t)||this.builtins.hasOwnProperty(t)}get(t){return this.current.hasOwnProperty(t)?this.current[t]:this.builtins[t]}set(t,r,s){if(s===void 0&&(s=!1),s){for(var n=0;n<this.undefStack.length;n++)delete this.undefStack[n][t];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][t]=r)}else{var o=this.undefStack[this.undefStack.length-1];o&&!o.hasOwnProperty(t)&&(o[t]=this.current[t])}r==null?delete this.current[t]:this.current[t]=r}}var macros=_macros;defineMacro("\\noexpand",function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),defineMacro("\\expandafter",function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),defineMacro("\\@firstoftwo",function(e){var t=e.consumeArgs(2);return{tokens:t[0],numArgs:0}}),defineMacro("\\@secondoftwo",function(e){var t=e.consumeArgs(2);return{tokens:t[1],numArgs:0}}),defineMacro("\\@ifnextchar",function(e){var t=e.consumeArgs(3);e.consumeSpaces();var r=e.future();return t[0].length===1&&t[0][0].text===r.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),defineMacro("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),defineMacro("\\TextOrMath",function(e){var t=e.consumeArgs(2);return e.mode==="text"?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var digitToNumber={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};defineMacro("\\char",function(e){var t=e.popToken(),r,s="";if(t.text==="'")r=8,t=e.popToken();else if(t.text==='"')r=16,t=e.popToken();else if(t.text==="`")if(t=e.popToken(),t.text[0]==="\\")s=t.text.charCodeAt(1);else{if(t.text==="EOF")throw new ParseError("\\char` missing argument");s=t.text.charCodeAt(0)}else r=10;if(r){if(s=digitToNumber[t.text],s==null||s>=r)throw new ParseError("Invalid base-"+r+" digit "+t.text);for(var n;(n=digitToNumber[e.future().text])!=null&&n<r;)s*=r,s+=n,e.popToken()}return"\\@char{"+s+"}"});var newcommand=(e,t,r,s)=>{var n=e.consumeArg().tokens;if(n.length!==1)throw new ParseError("\\newcommand's first argument must be a macro name");var o=n[0].text,a=e.isDefined(o);if(a&&!t)throw new ParseError("\\newcommand{"+o+"} attempting to redefine "+(o+"; use \\renewcommand"));if(!a&&!r)throw new ParseError("\\renewcommand{"+o+"} when command "+o+" does not yet exist; use \\newcommand");var l=0;if(n=e.consumeArg().tokens,n.length===1&&n[0].text==="["){for(var h="",c=e.expandNextToken();c.text!=="]"&&c.text!=="EOF";)h+=c.text,c=e.expandNextToken();if(!h.match(/^\s*[0-9]+\s*$/))throw new ParseError("Invalid number of arguments: "+h);l=parseInt(h),n=e.consumeArg().tokens}return a&&s||e.macros.set(o,{tokens:n,numArgs:l}),""};defineMacro("\\newcommand",e=>newcommand(e,!1,!0,!1)),defineMacro("\\renewcommand",e=>newcommand(e,!0,!1,!1)),defineMacro("\\providecommand",e=>newcommand(e,!0,!0,!0)),defineMacro("\\message",e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(r=>r.text).join("")),""}),defineMacro("\\errmessage",e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(r=>r.text).join("")),""}),defineMacro("\\show",e=>{var t=e.popToken(),r=t.text;return console.log(t,e.macros.get(r),functions[r],symbols.math[r],symbols.text[r]),""}),defineMacro("\\bgroup","{"),defineMacro("\\egroup","}"),defineMacro("~","\\nobreakspace"),defineMacro("\\lq","`"),defineMacro("\\rq","'"),defineMacro("\\aa","\\r a"),defineMacro("\\AA","\\r A"),defineMacro("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`©}"),defineMacro("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"),defineMacro("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),defineMacro("ℬ","\\mathscr{B}"),defineMacro("ℰ","\\mathscr{E}"),defineMacro("ℱ","\\mathscr{F}"),defineMacro("ℋ","\\mathscr{H}"),defineMacro("ℐ","\\mathscr{I}"),defineMacro("ℒ","\\mathscr{L}"),defineMacro("ℳ","\\mathscr{M}"),defineMacro("ℛ","\\mathscr{R}"),defineMacro("ℭ","\\mathfrak{C}"),defineMacro("ℌ","\\mathfrak{H}"),defineMacro("ℨ","\\mathfrak{Z}"),defineMacro("\\Bbbk","\\Bbb{k}"),defineMacro("·","\\cdotp"),defineMacro("\\llap","\\mathllap{\\textrm{#1}}"),defineMacro("\\rlap","\\mathrlap{\\textrm{#1}}"),defineMacro("\\clap","\\mathclap{\\textrm{#1}}"),defineMacro("\\mathstrut","\\vphantom{(}"),defineMacro("\\underbar","\\underline{\\text{#1}}"),defineMacro("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}'),defineMacro("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),defineMacro("\\ne","\\neq"),defineMacro("≠","\\neq"),defineMacro("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),defineMacro("∉","\\notin"),defineMacro("≘","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),defineMacro("≙","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),defineMacro("≚","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),defineMacro("≛","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),defineMacro("≝","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),defineMacro("≞","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),defineMacro("≟","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),defineMacro("⟂","\\perp"),defineMacro("‼","\\mathclose{!\\mkern-0.8mu!}"),defineMacro("∌","\\notni"),defineMacro("⌜","\\ulcorner"),defineMacro("⌝","\\urcorner"),defineMacro("⌞","\\llcorner"),defineMacro("⌟","\\lrcorner"),defineMacro("©","\\copyright"),defineMacro("®","\\textregistered"),defineMacro("️","\\textregistered"),defineMacro("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}'),defineMacro("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}'),defineMacro("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}'),defineMacro("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}'),defineMacro("\\vdots","{\\varvdots\\rule{0pt}{15pt}}"),defineMacro("⋮","\\vdots"),defineMacro("\\varGamma","\\mathit{\\Gamma}"),defineMacro("\\varDelta","\\mathit{\\Delta}"),defineMacro("\\varTheta","\\mathit{\\Theta}"),defineMacro("\\varLambda","\\mathit{\\Lambda}"),defineMacro("\\varXi","\\mathit{\\Xi}"),defineMacro("\\varPi","\\mathit{\\Pi}"),defineMacro("\\varSigma","\\mathit{\\Sigma}"),defineMacro("\\varUpsilon","\\mathit{\\Upsilon}"),defineMacro("\\varPhi","\\mathit{\\Phi}"),defineMacro("\\varPsi","\\mathit{\\Psi}"),defineMacro("\\varOmega","\\mathit{\\Omega}"),defineMacro("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),defineMacro("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"),defineMacro("\\boxed","\\fbox{$\\displaystyle{#1}$}"),defineMacro("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),defineMacro("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),defineMacro("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;"),defineMacro("\\dddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"),defineMacro("\\ddddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");var dotsByToken={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"};defineMacro("\\dots",function(e){var t="\\dotso",r=e.expandAfterFuture().text;return r in dotsByToken?t=dotsByToken[r]:(r.slice(0,4)==="\\not"||r in symbols.math&&["bin","rel"].includes(symbols.math[r].group))&&(t="\\dotsb"),t});var spaceAfterDots={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};defineMacro("\\dotso",function(e){var t=e.future().text;return t in spaceAfterDots?"\\ldots\\,":"\\ldots"}),defineMacro("\\dotsc",function(e){var t=e.future().text;return t in spaceAfterDots&&t!==","?"\\ldots\\,":"\\ldots"}),defineMacro("\\cdots",function(e){var t=e.future().text;return t in spaceAfterDots?"\\@cdots\\,":"\\@cdots"}),defineMacro("\\dotsb","\\cdots"),defineMacro("\\dotsm","\\cdots"),defineMacro("\\dotsi","\\!\\cdots"),defineMacro("\\dotsx","\\ldots\\,"),defineMacro("\\DOTSI","\\relax"),defineMacro("\\DOTSB","\\relax"),defineMacro("\\DOTSX","\\relax"),defineMacro("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),defineMacro("\\,","\\tmspace+{3mu}{.1667em}"),defineMacro("\\thinspace","\\,"),defineMacro("\\>","\\mskip{4mu}"),defineMacro("\\:","\\tmspace+{4mu}{.2222em}"),defineMacro("\\medspace","\\:"),defineMacro("\\;","\\tmspace+{5mu}{.2777em}"),defineMacro("\\thickspace","\\;"),defineMacro("\\!","\\tmspace-{3mu}{.1667em}"),defineMacro("\\negthinspace","\\!"),defineMacro("\\negmedspace","\\tmspace-{4mu}{.2222em}"),defineMacro("\\negthickspace","\\tmspace-{5mu}{.277em}"),defineMacro("\\enspace","\\kern.5em "),defineMacro("\\enskip","\\hskip.5em\\relax"),defineMacro("\\quad","\\hskip1em\\relax"),defineMacro("\\qquad","\\hskip2em\\relax"),defineMacro("\\tag","\\@ifstar\\tag@literal\\tag@paren"),defineMacro("\\tag@paren","\\tag@literal{({#1})}"),defineMacro("\\tag@literal",e=>{if(e.macros.get("\\df@tag"))throw new ParseError("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),defineMacro("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"),defineMacro("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),defineMacro("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),defineMacro("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),defineMacro("\\newline","\\\\\\relax"),defineMacro("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");var latexRaiseA=makeEm(fontMetricsData["Main-Regular"][84][1]-.7*fontMetricsData["Main-Regular"][65][1]);defineMacro("\\LaTeX","\\textrm{\\html@mathml{"+("L\\kern-.36em\\raisebox{"+latexRaiseA+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{LaTeX}}"),defineMacro("\\KaTeX","\\textrm{\\html@mathml{"+("K\\kern-.17em\\raisebox{"+latexRaiseA+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{KaTeX}}"),defineMacro("\\hspace","\\@ifstar\\@hspacer\\@hspace"),defineMacro("\\@hspace","\\hskip #1\\relax"),defineMacro("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),defineMacro("\\ordinarycolon",":"),defineMacro("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}"),defineMacro("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}'),defineMacro("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}'),defineMacro("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}'),defineMacro("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}'),defineMacro("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}'),defineMacro("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}'),defineMacro("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}'),defineMacro("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}'),defineMacro("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}'),defineMacro("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}'),defineMacro("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}'),defineMacro("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}'),defineMacro("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}'),defineMacro("∷","\\dblcolon"),defineMacro("∹","\\eqcolon"),defineMacro("≔","\\coloneqq"),defineMacro("≕","\\eqqcolon"),defineMacro("⩴","\\Coloneqq"),defineMacro("\\ratio","\\vcentcolon"),defineMacro("\\coloncolon","\\dblcolon"),defineMacro("\\colonequals","\\coloneqq"),defineMacro("\\coloncolonequals","\\Coloneqq"),defineMacro("\\equalscolon","\\eqqcolon"),defineMacro("\\equalscoloncolon","\\Eqqcolon"),defineMacro("\\colonminus","\\coloneq"),defineMacro("\\coloncolonminus","\\Coloneq"),defineMacro("\\minuscolon","\\eqcolon"),defineMacro("\\minuscoloncolon","\\Eqcolon"),defineMacro("\\coloncolonapprox","\\Colonapprox"),defineMacro("\\coloncolonsim","\\Colonsim"),defineMacro("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),defineMacro("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"),defineMacro("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),defineMacro("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"),defineMacro("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),defineMacro("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),defineMacro("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),defineMacro("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),defineMacro("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),defineMacro("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}"),defineMacro("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}"),defineMacro("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}"),defineMacro("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}"),defineMacro("\\gvertneqq","\\html@mathml{\\@gvertneqq}{≩}"),defineMacro("\\lvertneqq","\\html@mathml{\\@lvertneqq}{≨}"),defineMacro("\\ngeqq","\\html@mathml{\\@ngeqq}{≱}"),defineMacro("\\ngeqslant","\\html@mathml{\\@ngeqslant}{≱}"),defineMacro("\\nleqq","\\html@mathml{\\@nleqq}{≰}"),defineMacro("\\nleqslant","\\html@mathml{\\@nleqslant}{≰}"),defineMacro("\\nshortmid","\\html@mathml{\\@nshortmid}{∤}"),defineMacro("\\nshortparallel","\\html@mathml{\\@nshortparallel}{∦}"),defineMacro("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{⊈}"),defineMacro("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{⊉}"),defineMacro("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{⊊}"),defineMacro("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{⫋}"),defineMacro("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{⊋}"),defineMacro("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{⫌}"),defineMacro("\\imath","\\html@mathml{\\@imath}{ı}"),defineMacro("\\jmath","\\html@mathml{\\@jmath}{ȷ}"),defineMacro("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),defineMacro("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),defineMacro("⟦","\\llbracket"),defineMacro("⟧","\\rrbracket"),defineMacro("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),defineMacro("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),defineMacro("⦃","\\lBrace"),defineMacro("⦄","\\rBrace"),defineMacro("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),defineMacro("⦵","\\minuso"),defineMacro("\\darr","\\downarrow"),defineMacro("\\dArr","\\Downarrow"),defineMacro("\\Darr","\\Downarrow"),defineMacro("\\lang","\\langle"),defineMacro("\\rang","\\rangle"),defineMacro("\\uarr","\\uparrow"),defineMacro("\\uArr","\\Uparrow"),defineMacro("\\Uarr","\\Uparrow"),defineMacro("\\N","\\mathbb{N}"),defineMacro("\\R","\\mathbb{R}"),defineMacro("\\Z","\\mathbb{Z}"),defineMacro("\\alef","\\aleph"),defineMacro("\\alefsym","\\aleph"),defineMacro("\\Alpha","\\mathrm{A}"),defineMacro("\\Beta","\\mathrm{B}"),defineMacro("\\bull","\\bullet"),defineMacro("\\Chi","\\mathrm{X}"),defineMacro("\\clubs","\\clubsuit"),defineMacro("\\cnums","\\mathbb{C}"),defineMacro("\\Complex","\\mathbb{C}"),defineMacro("\\Dagger","\\ddagger"),defineMacro("\\diamonds","\\diamondsuit"),defineMacro("\\empty","\\emptyset"),defineMacro("\\Epsilon","\\mathrm{E}"),defineMacro("\\Eta","\\mathrm{H}"),defineMacro("\\exist","\\exists"),defineMacro("\\harr","\\leftrightarrow"),defineMacro("\\hArr","\\Leftrightarrow"),defineMacro("\\Harr","\\Leftrightarrow"),defineMacro("\\hearts","\\heartsuit"),defineMacro("\\image","\\Im"),defineMacro("\\infin","\\infty"),defineMacro("\\Iota","\\mathrm{I}"),defineMacro("\\isin","\\in"),defineMacro("\\Kappa","\\mathrm{K}"),defineMacro("\\larr","\\leftarrow"),defineMacro("\\lArr","\\Leftarrow"),defineMacro("\\Larr","\\Leftarrow"),defineMacro("\\lrarr","\\leftrightarrow"),defineMacro("\\lrArr","\\Leftrightarrow"),defineMacro("\\Lrarr","\\Leftrightarrow"),defineMacro("\\Mu","\\mathrm{M}"),defineMacro("\\natnums","\\mathbb{N}"),defineMacro("\\Nu","\\mathrm{N}"),defineMacro("\\Omicron","\\mathrm{O}"),defineMacro("\\plusmn","\\pm"),defineMacro("\\rarr","\\rightarrow"),defineMacro("\\rArr","\\Rightarrow"),defineMacro("\\Rarr","\\Rightarrow"),defineMacro("\\real","\\Re"),defineMacro("\\reals","\\mathbb{R}"),defineMacro("\\Reals","\\mathbb{R}"),defineMacro("\\Rho","\\mathrm{P}"),defineMacro("\\sdot","\\cdot"),defineMacro("\\sect","\\S"),defineMacro("\\spades","\\spadesuit"),defineMacro("\\sub","\\subset"),defineMacro("\\sube","\\subseteq"),defineMacro("\\supe","\\supseteq"),defineMacro("\\Tau","\\mathrm{T}"),defineMacro("\\thetasym","\\vartheta"),defineMacro("\\weierp","\\wp"),defineMacro("\\Zeta","\\mathrm{Z}"),defineMacro("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),defineMacro("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),defineMacro("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits"),defineMacro("\\bra","\\mathinner{\\langle{#1}|}"),defineMacro("\\ket","\\mathinner{|{#1}\\rangle}"),defineMacro("\\braket","\\mathinner{\\langle{#1}\\rangle}"),defineMacro("\\Bra","\\left\\langle#1\\right|"),defineMacro("\\Ket","\\left|#1\\right\\rangle");var braketHelper=e=>t=>{var r=t.consumeArg().tokens,s=t.consumeArg().tokens,n=t.consumeArg().tokens,o=t.consumeArg().tokens,a=t.macros.get("|"),l=t.macros.get("\\|");t.macros.beginGroup();var h=d=>f=>{e&&(f.macros.set("|",a),n.length&&f.macros.set("\\|",l));var p=d;if(!d&&n.length){var m=f.future();m.text==="|"&&(f.popToken(),p=!0)}return{tokens:p?n:s,numArgs:0}};t.macros.set("|",h(!1)),n.length&&t.macros.set("\\|",h(!0));var c=t.consumeArg().tokens,u=t.expandTokens([...o,...c,...r]);return t.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};defineMacro("\\bra@ket",braketHelper(!1)),defineMacro("\\bra@set",braketHelper(!0)),defineMacro("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"),defineMacro("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"),defineMacro("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"),defineMacro("\\angln","{\\angl n}"),defineMacro("\\blue","\\textcolor{##6495ed}{#1}"),defineMacro("\\orange","\\textcolor{##ffa500}{#1}"),defineMacro("\\pink","\\textcolor{##ff00af}{#1}"),defineMacro("\\red","\\textcolor{##df0030}{#1}"),defineMacro("\\green","\\textcolor{##28ae7b}{#1}"),defineMacro("\\gray","\\textcolor{gray}{#1}"),defineMacro("\\purple","\\textcolor{##9d38bd}{#1}"),defineMacro("\\blueA","\\textcolor{##ccfaff}{#1}"),defineMacro("\\blueB","\\textcolor{##80f6ff}{#1}"),defineMacro("\\blueC","\\textcolor{##63d9ea}{#1}"),defineMacro("\\blueD","\\textcolor{##11accd}{#1}"),defineMacro("\\blueE","\\textcolor{##0c7f99}{#1}"),defineMacro("\\tealA","\\textcolor{##94fff5}{#1}"),defineMacro("\\tealB","\\textcolor{##26edd5}{#1}"),defineMacro("\\tealC","\\textcolor{##01d1c1}{#1}"),defineMacro("\\tealD","\\textcolor{##01a995}{#1}"),defineMacro("\\tealE","\\textcolor{##208170}{#1}"),defineMacro("\\greenA","\\textcolor{##b6ffb0}{#1}"),defineMacro("\\greenB","\\textcolor{##8af281}{#1}"),defineMacro("\\greenC","\\textcolor{##74cf70}{#1}"),defineMacro("\\greenD","\\textcolor{##1fab54}{#1}"),defineMacro("\\greenE","\\textcolor{##0d923f}{#1}"),defineMacro("\\goldA","\\textcolor{##ffd0a9}{#1}"),defineMacro("\\goldB","\\textcolor{##ffbb71}{#1}"),defineMacro("\\goldC","\\textcolor{##ff9c39}{#1}"),defineMacro("\\goldD","\\textcolor{##e07d10}{#1}"),defineMacro("\\goldE","\\textcolor{##a75a05}{#1}"),defineMacro("\\redA","\\textcolor{##fca9a9}{#1}"),defineMacro("\\redB","\\textcolor{##ff8482}{#1}"),defineMacro("\\redC","\\textcolor{##f9685d}{#1}"),defineMacro("\\redD","\\textcolor{##e84d39}{#1}"),defineMacro("\\redE","\\textcolor{##bc2612}{#1}"),defineMacro("\\maroonA","\\textcolor{##ffbde0}{#1}"),defineMacro("\\maroonB","\\textcolor{##ff92c6}{#1}"),defineMacro("\\maroonC","\\textcolor{##ed5fa6}{#1}"),defineMacro("\\maroonD","\\textcolor{##ca337c}{#1}"),defineMacro("\\maroonE","\\textcolor{##9e034e}{#1}"),defineMacro("\\purpleA","\\textcolor{##ddd7ff}{#1}"),defineMacro("\\purpleB","\\textcolor{##c6b9fc}{#1}"),defineMacro("\\purpleC","\\textcolor{##aa87ff}{#1}"),defineMacro("\\purpleD","\\textcolor{##7854ab}{#1}"),defineMacro("\\purpleE","\\textcolor{##543b78}{#1}"),defineMacro("\\mintA","\\textcolor{##f5f9e8}{#1}"),defineMacro("\\mintB","\\textcolor{##edf2df}{#1}"),defineMacro("\\mintC","\\textcolor{##e0e5cc}{#1}"),defineMacro("\\grayA","\\textcolor{##f6f7f7}{#1}"),defineMacro("\\grayB","\\textcolor{##f0f1f2}{#1}"),defineMacro("\\grayC","\\textcolor{##e3e5e6}{#1}"),defineMacro("\\grayD","\\textcolor{##d6d8da}{#1}"),defineMacro("\\grayE","\\textcolor{##babec2}{#1}"),defineMacro("\\grayF","\\textcolor{##888d93}{#1}"),defineMacro("\\grayG","\\textcolor{##626569}{#1}"),defineMacro("\\grayH","\\textcolor{##3b3e40}{#1}"),defineMacro("\\grayI","\\textcolor{##21242c}{#1}"),defineMacro("\\kaBlue","\\textcolor{##314453}{#1}"),defineMacro("\\kaGreen","\\textcolor{##71B307}{#1}");var implicitCommands={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class MacroExpander{constructor(t,r,s){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=r,this.expansionCount=0,this.feed(t),this.macros=new Namespace(macros,r.macros),this.mode=s,this.stack=[]}feed(t){this.lexer=new Lexer(t,this.settings)}switchMode(t){this.mode=t}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(t){this.stack.push(t)}pushTokens(t){this.stack.push(...t)}scanArgument(t){var r,s,n;if(t){if(this.consumeSpaces(),this.future().text!=="[")return null;r=this.popToken(),{tokens:n,end:s}=this.consumeArg(["]"])}else({tokens:n,start:r,end:s}=this.consumeArg());return this.pushToken(new Token("EOF",s.loc)),this.pushTokens(n),new Token("",SourceLocation.range(r,s))}consumeSpaces(){for(;;){var t=this.future();if(t.text===" ")this.stack.pop();else break}}consumeArg(t){var r=[],s=t&&t.length>0;s||this.consumeSpaces();var n=this.future(),o,a=0,l=0;do{if(o=this.popToken(),r.push(o),o.text==="{")++a;else if(o.text==="}"){if(--a,a===-1)throw new ParseError("Extra }",o)}else if(o.text==="EOF")throw new ParseError("Unexpected end of input in a macro argument, expected '"+(t&&s?t[l]:"}")+"'",o);if(t&&s)if((a===0||a===1&&t[l]==="{")&&o.text===t[l]){if(++l,l===t.length){r.splice(-l,l);break}}else l=0}while(a!==0||s);return n.text==="{"&&r[r.length-1].text==="}"&&(r.pop(),r.shift()),r.reverse(),{tokens:r,start:n,end:o}}consumeArgs(t,r){if(r){if(r.length!==t+1)throw new ParseError("The length of delimiters doesn't match the number of args!");for(var s=r[0],n=0;n<s.length;n++){var o=this.popToken();if(s[n]!==o.text)throw new ParseError("Use of the macro doesn't match its definition",o)}}for(var a=[],l=0;l<t;l++)a.push(this.consumeArg(r&&r[l+1]).tokens);return a}countExpansion(t){if(this.expansionCount+=t,this.expansionCount>this.settings.maxExpand)throw new ParseError("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(t){var r=this.popToken(),s=r.text,n=r.noexpand?null:this._getExpansion(s);if(n==null||t&&n.unexpandable){if(t&&n==null&&s[0]==="\\"&&!this.isDefined(s))throw new ParseError("Undefined control sequence: "+s);return this.pushToken(r),!1}this.countExpansion(1);var o=n.tokens,a=this.consumeArgs(n.numArgs,n.delimiters);if(n.numArgs){o=o.slice();for(var l=o.length-1;l>=0;--l){var h=o[l];if(h.text==="#"){if(l===0)throw new ParseError("Incomplete placeholder at end of macro body",h);if(h=o[--l],h.text==="#")o.splice(l+1,1);else if(/^[1-9]$/.test(h.text))o.splice(l,2,...a[+h.text-1]);else throw new ParseError("Not a valid argument number",h)}}}return this.pushTokens(o),o.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var t=this.stack.pop();return t.treatAsRelax&&(t.text="\\relax"),t}throw new Error}expandMacro(t){return this.macros.has(t)?this.expandTokens([new Token(t)]):void 0}expandTokens(t){var r=[],s=this.stack.length;for(this.pushTokens(t);this.stack.length>s;)if(this.expandOnce(!0)===!1){var n=this.stack.pop();n.treatAsRelax&&(n.noexpand=!1,n.treatAsRelax=!1),r.push(n)}return this.countExpansion(r.length),r}expandMacroAsText(t){var r=this.expandMacro(t);return r&&r.map(s=>s.text).join("")}_getExpansion(t){var r=this.macros.get(t);if(r==null)return r;if(t.length===1){var s=this.lexer.catcodes[t];if(s!=null&&s!==13)return}var n=typeof r=="function"?r(this):r;if(typeof n=="string"){var o=0;if(n.indexOf("#")!==-1)for(var a=n.replace(/##/g,"");a.indexOf("#"+(o+1))!==-1;)++o;for(var l=new Lexer(n,this.settings),h=[],c=l.lex();c.text!=="EOF";)h.push(c),c=l.lex();h.reverse();var u={tokens:h,numArgs:o};return u}return n}isDefined(t){return this.macros.has(t)||functions.hasOwnProperty(t)||symbols.math.hasOwnProperty(t)||symbols.text.hasOwnProperty(t)||implicitCommands.hasOwnProperty(t)}isExpandable(t){var r=this.macros.get(t);return r!=null?typeof r=="string"||typeof r=="function"||!r.unexpandable:functions.hasOwnProperty(t)&&!functions[t].primitive}}var unicodeSubRegEx=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,uSubsAndSups=Object.freeze({"₊":"+","₋":"-","₌":"=","₍":"(","₎":")","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9","ₐ":"a","ₑ":"e","ₕ":"h","ᵢ":"i","ⱼ":"j","ₖ":"k","ₗ":"l","ₘ":"m","ₙ":"n","ₒ":"o","ₚ":"p","ᵣ":"r","ₛ":"s","ₜ":"t","ᵤ":"u","ᵥ":"v","ₓ":"x","ᵦ":"β","ᵧ":"γ","ᵨ":"ρ","ᵩ":"ϕ","ᵪ":"χ","⁺":"+","⁻":"-","⁼":"=","⁽":"(","⁾":")","⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","ᴬ":"A","ᴮ":"B","ᴰ":"D","ᴱ":"E","ᴳ":"G","ᴴ":"H","ᴵ":"I","ᴶ":"J","ᴷ":"K","ᴸ":"L","ᴹ":"M","ᴺ":"N","ᴼ":"O","ᴾ":"P","ᴿ":"R","ᵀ":"T","ᵁ":"U","ⱽ":"V","ᵂ":"W","ᵃ":"a","ᵇ":"b","ᶜ":"c","ᵈ":"d","ᵉ":"e","ᶠ":"f","ᵍ":"g",ʰ:"h","ⁱ":"i",ʲ:"j","ᵏ":"k",ˡ:"l","ᵐ":"m",ⁿ:"n","ᵒ":"o","ᵖ":"p",ʳ:"r",ˢ:"s","ᵗ":"t","ᵘ":"u","ᵛ":"v",ʷ:"w",ˣ:"x",ʸ:"y","ᶻ":"z","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),unicodeAccents={"́":{text:"\\'",math:"\\acute"},"̀":{text:"\\`",math:"\\grave"},"̈":{text:'\\"',math:"\\ddot"},"̃":{text:"\\~",math:"\\tilde"},"̄":{text:"\\=",math:"\\bar"},"̆":{text:"\\u",math:"\\breve"},"̌":{text:"\\v",math:"\\check"},"̂":{text:"\\^",math:"\\hat"},"̇":{text:"\\.",math:"\\dot"},"̊":{text:"\\r",math:"\\mathring"},"̋":{text:"\\H"},"̧":{text:"\\c"}},unicodeSymbols={á:"á",à:"à",ä:"ä",ǟ:"ǟ",ã:"ã",ā:"ā",ă:"ă",ắ:"ắ",ằ:"ằ",ẵ:"ẵ",ǎ:"ǎ",â:"â",ấ:"ấ",ầ:"ầ",ẫ:"ẫ",ȧ:"ȧ",ǡ:"ǡ",å:"å",ǻ:"ǻ",ḃ:"ḃ",ć:"ć",ḉ:"ḉ",č:"č",ĉ:"ĉ",ċ:"ċ",ç:"ç",ď:"ď",ḋ:"ḋ",ḑ:"ḑ",é:"é",è:"è",ë:"ë",ẽ:"ẽ",ē:"ē",ḗ:"ḗ",ḕ:"ḕ",ĕ:"ĕ",ḝ:"ḝ",ě:"ě",ê:"ê",ế:"ế",ề:"ề",ễ:"ễ",ė:"ė",ȩ:"ȩ",ḟ:"ḟ",ǵ:"ǵ",ḡ:"ḡ",ğ:"ğ",ǧ:"ǧ",ĝ:"ĝ",ġ:"ġ",ģ:"ģ",ḧ:"ḧ",ȟ:"ȟ",ĥ:"ĥ",ḣ:"ḣ",ḩ:"ḩ",í:"í",ì:"ì",ï:"ï",ḯ:"ḯ",ĩ:"ĩ",ī:"ī",ĭ:"ĭ",ǐ:"ǐ",î:"î",ǰ:"ǰ",ĵ:"ĵ",ḱ:"ḱ",ǩ:"ǩ",ķ:"ķ",ĺ:"ĺ",ľ:"ľ",ļ:"ļ",ḿ:"ḿ",ṁ:"ṁ",ń:"ń",ǹ:"ǹ",ñ:"ñ",ň:"ň",ṅ:"ṅ",ņ:"ņ",ó:"ó",ò:"ò",ö:"ö",ȫ:"ȫ",õ:"õ",ṍ:"ṍ",ṏ:"ṏ",ȭ:"ȭ",ō:"ō",ṓ:"ṓ",ṑ:"ṑ",ŏ:"ŏ",ǒ:"ǒ",ô:"ô",ố:"ố",ồ:"ồ",ỗ:"ỗ",ȯ:"ȯ",ȱ:"ȱ",ő:"ő",ṕ:"ṕ",ṗ:"ṗ",ŕ:"ŕ",ř:"ř",ṙ:"ṙ",ŗ:"ŗ",ś:"ś",ṥ:"ṥ",š:"š",ṧ:"ṧ",ŝ:"ŝ",ṡ:"ṡ",ş:"ş",ẗ:"ẗ",ť:"ť",ṫ:"ṫ",ţ:"ţ",ú:"ú",ù:"ù",ü:"ü",ǘ:"ǘ",ǜ:"ǜ",ǖ:"ǖ",ǚ:"ǚ",ũ:"ũ",ṹ:"ṹ",ū:"ū",ṻ:"ṻ",ŭ:"ŭ",ǔ:"ǔ",û:"û",ů:"ů",ű:"ű",ṽ:"ṽ",ẃ:"ẃ",ẁ:"ẁ",ẅ:"ẅ",ŵ:"ŵ",ẇ:"ẇ",ẘ:"ẘ",ẍ:"ẍ",ẋ:"ẋ",ý:"ý",ỳ:"ỳ",ÿ:"ÿ",ỹ:"ỹ",ȳ:"ȳ",ŷ:"ŷ",ẏ:"ẏ",ẙ:"ẙ",ź:"ź",ž:"ž",ẑ:"ẑ",ż:"ż",Á:"Á",À:"À",Ä:"Ä",Ǟ:"Ǟ",Ã:"Ã",Ā:"Ā",Ă:"Ă",Ắ:"Ắ",Ằ:"Ằ",Ẵ:"Ẵ",Ǎ:"Ǎ",Â:"Â",Ấ:"Ấ",Ầ:"Ầ",Ẫ:"Ẫ",Ȧ:"Ȧ",Ǡ:"Ǡ",Å:"Å",Ǻ:"Ǻ",Ḃ:"Ḃ",Ć:"Ć",Ḉ:"Ḉ",Č:"Č",Ĉ:"Ĉ",Ċ:"Ċ",Ç:"Ç",Ď:"Ď",Ḋ:"Ḋ",Ḑ:"Ḑ",É:"É",È:"È",Ë:"Ë",Ẽ:"Ẽ",Ē:"Ē",Ḗ:"Ḗ",Ḕ:"Ḕ",Ĕ:"Ĕ",Ḝ:"Ḝ",Ě:"Ě",Ê:"Ê",Ế:"Ế",Ề:"Ề",Ễ:"Ễ",Ė:"Ė",Ȩ:"Ȩ",Ḟ:"Ḟ",Ǵ:"Ǵ",Ḡ:"Ḡ",Ğ:"Ğ",Ǧ:"Ǧ",Ĝ:"Ĝ",Ġ:"Ġ",Ģ:"Ģ",Ḧ:"Ḧ",Ȟ:"Ȟ",Ĥ:"Ĥ",Ḣ:"Ḣ",Ḩ:"Ḩ",Í:"Í",Ì:"Ì",Ï:"Ï",Ḯ:"Ḯ",Ĩ:"Ĩ",Ī:"Ī",Ĭ:"Ĭ",Ǐ:"Ǐ",Î:"Î",İ:"İ",Ĵ:"Ĵ",Ḱ:"Ḱ",Ǩ:"Ǩ",Ķ:"Ķ",Ĺ:"Ĺ",Ľ:"Ľ",Ļ:"Ļ",Ḿ:"Ḿ",Ṁ:"Ṁ",Ń:"Ń",Ǹ:"Ǹ",Ñ:"Ñ",Ň:"Ň",Ṅ:"Ṅ",Ņ:"Ņ",Ó:"Ó",Ò:"Ò",Ö:"Ö",Ȫ:"Ȫ",Õ:"Õ",Ṍ:"Ṍ",Ṏ:"Ṏ",Ȭ:"Ȭ",Ō:"Ō",Ṓ:"Ṓ",Ṑ:"Ṑ",Ŏ:"Ŏ",Ǒ:"Ǒ",Ô:"Ô",Ố:"Ố",Ồ:"Ồ",Ỗ:"Ỗ",Ȯ:"Ȯ",Ȱ:"Ȱ",Ő:"Ő",Ṕ:"Ṕ",Ṗ:"Ṗ",Ŕ:"Ŕ",Ř:"Ř",Ṙ:"Ṙ",Ŗ:"Ŗ",Ś:"Ś",Ṥ:"Ṥ",Š:"Š",Ṧ:"Ṧ",Ŝ:"Ŝ",Ṡ:"Ṡ",Ş:"Ş",Ť:"Ť",Ṫ:"Ṫ",Ţ:"Ţ",Ú:"Ú",Ù:"Ù",Ü:"Ü",Ǘ:"Ǘ",Ǜ:"Ǜ",Ǖ:"Ǖ",Ǚ:"Ǚ",Ũ:"Ũ",Ṹ:"Ṹ",Ū:"Ū",Ṻ:"Ṻ",Ŭ:"Ŭ",Ǔ:"Ǔ",Û:"Û",Ů:"Ů",Ű:"Ű",Ṽ:"Ṽ",Ẃ:"Ẃ",Ẁ:"Ẁ",Ẅ:"Ẅ",Ŵ:"Ŵ",Ẇ:"Ẇ",Ẍ:"Ẍ",Ẋ:"Ẋ",Ý:"Ý",Ỳ:"Ỳ",Ÿ:"Ÿ",Ỹ:"Ỹ",Ȳ:"Ȳ",Ŷ:"Ŷ",Ẏ:"Ẏ",Ź:"Ź",Ž:"Ž",Ẑ:"Ẑ",Ż:"Ż",ά:"ά",ὰ:"ὰ",ᾱ:"ᾱ",ᾰ:"ᾰ",έ:"έ",ὲ:"ὲ",ή:"ή",ὴ:"ὴ",ί:"ί",ὶ:"ὶ",ϊ:"ϊ",ΐ:"ΐ",ῒ:"ῒ",ῑ:"ῑ",ῐ:"ῐ",ό:"ό",ὸ:"ὸ",ύ:"ύ",ὺ:"ὺ",ϋ:"ϋ",ΰ:"ΰ",ῢ:"ῢ",ῡ:"ῡ",ῠ:"ῠ",ώ:"ώ",ὼ:"ὼ",Ύ:"Ύ",Ὺ:"Ὺ",Ϋ:"Ϋ",Ῡ:"Ῡ",Ῠ:"Ῠ",Ώ:"Ώ",Ὼ:"Ὼ"};class Parser{constructor(t,r){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new MacroExpander(t,r,this.mode),this.settings=r,this.leftrightDepth=0}expect(t,r){if(r===void 0&&(r=!0),this.fetch().text!==t)throw new ParseError("Expected '"+t+"', got '"+this.fetch().text+"'",this.fetch());r&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(t){this.mode=t,this.gullet.switchMode(t)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{var t=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),t}finally{this.gullet.endGroups()}}subparse(t){var r=this.nextToken;this.consume(),this.gullet.pushToken(new Token("}")),this.gullet.pushTokens(t);var s=this.parseExpression(!1);return this.expect("}"),this.nextToken=r,s}parseExpression(t,r){for(var s=[];;){this.mode==="math"&&this.consumeSpaces();var n=this.fetch();if(Parser.endOfExpression.indexOf(n.text)!==-1||r&&n.text===r||t&&functions[n.text]&&functions[n.text].infix)break;var o=this.parseAtom(r);if(o){if(o.type==="internal")continue}else break;s.push(o)}return this.mode==="text"&&this.formLigatures(s),this.handleInfixNodes(s)}handleInfixNodes(t){for(var r=-1,s,n=0;n<t.length;n++)if(t[n].type==="infix"){if(r!==-1)throw new ParseError("only one infix operator per group",t[n].token);r=n,s=t[n].replaceWith}if(r!==-1&&s){var o,a,l=t.slice(0,r),h=t.slice(r+1);l.length===1&&l[0].type==="ordgroup"?o=l[0]:o={type:"ordgroup",mode:this.mode,body:l},h.length===1&&h[0].type==="ordgroup"?a=h[0]:a={type:"ordgroup",mode:this.mode,body:h};var c;return s==="\\\\abovefrac"?c=this.callFunction(s,[o,t[r],a],[]):c=this.callFunction(s,[o,a],[]),[c]}else return t}handleSupSubscript(t){var r=this.fetch(),s=r.text;this.consume(),this.consumeSpaces();var n;do{var o;n=this.parseGroup(t)}while(((o=n)==null?void 0:o.type)==="internal");if(!n)throw new ParseError("Expected group after '"+s+"'",r);return n}formatUnsupportedCmd(t){for(var r=[],s=0;s<t.length;s++)r.push({type:"textord",mode:"text",text:t[s]});var n={type:"text",mode:this.mode,body:r},o={type:"color",mode:this.mode,color:this.settings.errorColor,body:[n]};return o}parseAtom(t){var r=this.parseGroup("atom",t);if(r?.type==="internal"||this.mode==="text")return r;for(var s,n;;){this.consumeSpaces();var o=this.fetch();if(o.text==="\\limits"||o.text==="\\nolimits"){if(r&&r.type==="op"){var a=o.text==="\\limits";r.limits=a,r.alwaysHandleSupSub=!0}else if(r&&r.type==="operatorname")r.alwaysHandleSupSub&&(r.limits=o.text==="\\limits");else throw new ParseError("Limit controls must follow a math operator",o);this.consume()}else if(o.text==="^"){if(s)throw new ParseError("Double superscript",o);s=this.handleSupSubscript("superscript")}else if(o.text==="_"){if(n)throw new ParseError("Double subscript",o);n=this.handleSupSubscript("subscript")}else if(o.text==="'"){if(s)throw new ParseError("Double superscript",o);var l={type:"textord",mode:this.mode,text:"\\prime"},h=[l];for(this.consume();this.fetch().text==="'";)h.push(l),this.consume();this.fetch().text==="^"&&h.push(this.handleSupSubscript("superscript")),s={type:"ordgroup",mode:this.mode,body:h}}else if(uSubsAndSups[o.text]){var c=unicodeSubRegEx.test(o.text),u=[];for(u.push(new Token(uSubsAndSups[o.text])),this.consume();;){var d=this.fetch().text;if(!uSubsAndSups[d]||unicodeSubRegEx.test(d)!==c)break;u.unshift(new Token(uSubsAndSups[d])),this.consume()}var f=this.subparse(u);c?n={type:"ordgroup",mode:"math",body:f}:s={type:"ordgroup",mode:"math",body:f}}else break}return s||n?{type:"supsub",mode:this.mode,base:r,sup:s,sub:n}:r}parseFunction(t,r){var s=this.fetch(),n=s.text,o=functions[n];if(!o)return null;if(this.consume(),r&&r!=="atom"&&!o.allowedInArgument)throw new ParseError("Got function '"+n+"' with no arguments"+(r?" as "+r:""),s);if(this.mode==="text"&&!o.allowedInText)throw new ParseError("Can't use function '"+n+"' in text mode",s);if(this.mode==="math"&&o.allowedInMath===!1)throw new ParseError("Can't use function '"+n+"' in math mode",s);var{args:a,optArgs:l}=this.parseArguments(n,o);return this.callFunction(n,a,l,s,t)}callFunction(t,r,s,n,o){var a={funcName:t,parser:this,token:n,breakOnTokenText:o},l=functions[t];if(l&&l.handler)return l.handler(a,r,s);throw new ParseError("No function handler for "+t)}parseArguments(t,r){var s=r.numArgs+r.numOptionalArgs;if(s===0)return{args:[],optArgs:[]};for(var n=[],o=[],a=0;a<s;a++){var l=r.argTypes&&r.argTypes[a],h=a<r.numOptionalArgs;(r.primitive&&l==null||r.type==="sqrt"&&a===1&&o[0]==null)&&(l="primitive");var c=this.parseGroupOfType("argument to '"+t+"'",l,h);if(h)o.push(c);else if(c!=null)n.push(c);else throw new ParseError("Null argument, please report this as a bug")}return{args:n,optArgs:o}}parseGroupOfType(t,r,s){switch(r){case"color":return this.parseColorGroup(s);case"size":return this.parseSizeGroup(s);case"url":return this.parseUrlGroup(s);case"math":case"text":return this.parseArgumentGroup(s,r);case"hbox":{var n=this.parseArgumentGroup(s,"text");return n!=null?{type:"styling",mode:n.mode,body:[n],style:"text"}:null}case"raw":{var o=this.parseStringGroup("raw",s);return o!=null?{type:"raw",mode:"text",string:o.text}:null}case"primitive":{if(s)throw new ParseError("A primitive argument cannot be optional");var a=this.parseGroup(t);if(a==null)throw new ParseError("Expected group as "+t,this.fetch());return a}case"original":case null:case void 0:return this.parseArgumentGroup(s);default:throw new ParseError("Unknown group type as "+t,this.fetch())}}consumeSpaces(){for(;this.fetch().text===" ";)this.consume()}parseStringGroup(t,r){var s=this.gullet.scanArgument(r);if(s==null)return null;for(var n="",o;(o=this.fetch()).text!=="EOF";)n+=o.text,this.consume();return this.consume(),s.text=n,s}parseRegexGroup(t,r){for(var s=this.fetch(),n=s,o="",a;(a=this.fetch()).text!=="EOF"&&t.test(o+a.text);)n=a,o+=n.text,this.consume();if(o==="")throw new ParseError("Invalid "+r+": '"+s.text+"'",s);return s.range(n,o)}parseColorGroup(t){var r=this.parseStringGroup("color",t);if(r==null)return null;var s=/^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(r.text);if(!s)throw new ParseError("Invalid color: '"+r.text+"'",r);var n=s[0];return/^[0-9a-f]{6}$/i.test(n)&&(n="#"+n),{type:"color-token",mode:this.mode,color:n}}parseSizeGroup(t){var r,s=!1;if(this.gullet.consumeSpaces(),!t&&this.gullet.future().text!=="{"?r=this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"):r=this.parseStringGroup("size",t),!r)return null;!t&&r.text.length===0&&(r.text="0pt",s=!0);var n=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(r.text);if(!n)throw new ParseError("Invalid size: '"+r.text+"'",r);var o={number:+(n[1]+n[2]),unit:n[3]};if(!validUnit(o))throw new ParseError("Invalid unit: '"+o.unit+"'",r);return{type:"size",mode:this.mode,value:o,isBlank:s}}parseUrlGroup(t){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);var r=this.parseStringGroup("url",t);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),r==null)return null;var s=r.text.replace(/\\([#$%&~_^{}])/g,"$1");return{type:"url",mode:this.mode,url:s}}parseArgumentGroup(t,r){var s=this.gullet.scanArgument(t);if(s==null)return null;var n=this.mode;r&&this.switchMode(r),this.gullet.beginGroup();var o=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();var a={type:"ordgroup",mode:this.mode,loc:s.loc,body:o};return r&&this.switchMode(n),a}parseGroup(t,r){var s=this.fetch(),n=s.text,o;if(n==="{"||n==="\\begingroup"){this.consume();var a=n==="{"?"}":"\\endgroup";this.gullet.beginGroup();var l=this.parseExpression(!1,a),h=this.fetch();this.expect(a),this.gullet.endGroup(),o={type:"ordgroup",mode:this.mode,loc:SourceLocation.range(s,h),body:l,semisimple:n==="\\begingroup"||void 0}}else if(o=this.parseFunction(r,t)||this.parseSymbol(),o==null&&n[0]==="\\"&&!implicitCommands.hasOwnProperty(n)){if(this.settings.throwOnError)throw new ParseError("Undefined control sequence: "+n,s);o=this.formatUnsupportedCmd(n),this.consume()}return o}formLigatures(t){for(var r=t.length-1,s=0;s<r;++s){var n=t[s],o=n.text;o==="-"&&t[s+1].text==="-"&&(s+1<r&&t[s+2].text==="-"?(t.splice(s,3,{type:"textord",mode:"text",loc:SourceLocation.range(n,t[s+2]),text:"---"}),r-=2):(t.splice(s,2,{type:"textord",mode:"text",loc:SourceLocation.range(n,t[s+1]),text:"--"}),r-=1)),(o==="'"||o==="`")&&t[s+1].text===o&&(t.splice(s,2,{type:"textord",mode:"text",loc:SourceLocation.range(n,t[s+1]),text:o+o}),r-=1)}}parseSymbol(){var t=this.fetch(),r=t.text;if(/^\\verb[^a-zA-Z]/.test(r)){this.consume();var s=r.slice(5),n=s.charAt(0)==="*";if(n&&(s=s.slice(1)),s.length<2||s.charAt(0)!==s.slice(-1))throw new ParseError(`\\verb assertion failed --
|
|
331
|
-
please report what input caused this bug`);return s=s.slice(1,-1),{type:"verb",mode:"text",body:s,star:n}}unicodeSymbols.hasOwnProperty(r[0])&&!symbols[this.mode][r[0]]&&(this.settings.strict&&this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Accented Unicode text character "'+r[0]+'" used in math mode',t),r=unicodeSymbols[r[0]]+r.slice(1));var o=combiningDiacriticalMarksEndRegex.exec(r);o&&(r=r.substring(0,o.index),r==="i"?r="ı":r==="j"&&(r="ȷ"));var a;if(symbols[this.mode][r]){this.settings.strict&&this.mode==="math"&&extraLatin.indexOf(r)>=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+r[0]+'" used in math mode',t);var l=symbols[this.mode][r].group,h=SourceLocation.range(t),c;if(ATOMS.hasOwnProperty(l)){var u=l;c={type:"atom",mode:this.mode,family:u,loc:h,text:r}}else c={type:l,mode:this.mode,loc:h,text:r};a=c}else if(r.charCodeAt(0)>=128)this.settings.strict&&(supportedCodepoint(r.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+r[0]+'" used in math mode',t):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+r[0]+'"'+(" ("+r.charCodeAt(0)+")"),t)),a={type:"textord",mode:"text",loc:SourceLocation.range(t),text:r};else return null;if(this.consume(),o)for(var d=0;d<o[0].length;d++){var f=o[0][d];if(!unicodeAccents[f])throw new ParseError("Unknown accent ' "+f+"'",t);var p=unicodeAccents[f][this.mode]||unicodeAccents[f].text;if(!p)throw new ParseError("Accent "+f+" unsupported in "+this.mode+" mode",t);a={type:"accent",mode:this.mode,loc:SourceLocation.range(t),label:p,isStretchy:!1,isShifty:!0,base:a}}return a}}Parser.endOfExpression=["}","\\endgroup","\\end","\\right","&"];var parseTree=function(t,r){if(!(typeof t=="string"||t instanceof String))throw new TypeError("KaTeX can only parse string typed expression");var s=new Parser(t,r);delete s.gullet.macros.current["\\df@tag"];var n=s.parse();if(delete s.gullet.macros.current["\\current@color"],delete s.gullet.macros.current["\\color"],s.gullet.macros.get("\\df@tag")){if(!r.displayMode)throw new ParseError("\\tag works only in display equations");n=[{type:"tag",mode:"text",body:n,tag:s.subparse([new Token("\\df@tag")])}]}return n};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&typeof console<"u"&&console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.");var renderToString=function(t,r){var s=renderToDomTree(t,r).toMarkup();return s},renderError=function(t,r,s){if(s.throwOnError||!(t instanceof ParseError))throw t;var n=buildCommon.makeSpan(["katex-error"],[new SymbolNode(r)]);return n.setAttribute("title",t.toString()),n.setAttribute("style","color:"+s.errorColor),n},renderToDomTree=function(t,r){var s=new Settings(r);try{var n=parseTree(t,s);return buildTree(n,t,s)}catch(o){return renderError(o,t,s)}};const loadKaTeXCSS=()=>{typeof window<"u"&&Promise.resolve().then(()=>katex_min).catch(e=>{console.warn("KaTeX CSS loading failed in Storybook environment:",e)})},EquationRender=React.memo(({parts:e=[],children:t=null,fontSize:r="1rem",color:s="#333333",displayMode:n=!1,className:o=""})=>{if(React.useEffect(()=>{loadKaTeXCSS()},[]),e.length===0)return null;const a=React.useMemo(()=>e.map((u,d)=>{try{return renderToString(u,{displayMode:n,throwOnError:!1,errorColor:"#ff0000"})}catch(f){return console.error(`KaTeX rendering error in part ${d}:`,f),'<span style="color: red;">KaTeX Error</span>'}}),[e,n]),l=n?"div":"span",h=React.Children.toArray(t),c=[];return a.forEach((u,d)=>{c.push(jsxRuntimeExports.jsx("span",{dangerouslySetInnerHTML:{__html:u},style:{display:"inline-block"}},`part-${d}`)),d<h.length&&d<e.length-1&&c.push(jsxRuntimeExports.jsx("span",{style:{display:"inline-block"},children:h[d]},`slot-${d}`))}),jsxRuntimeExports.jsx(l,{className:`equation-render ${o}`.trim(),style:{fontSize:r,color:s,display:"flex",alignItems:"center",gap:"0.3em",...n?{justifyContent:"center",margin:"1em 0"}:{}},children:c})}),renderContentBlock=e=>e.type==="formula"?React.createElement(EquationRender,{key:e.content,parts:[e.content],displayMode:!1,fontSize:"1em",color:"#333333"}):e.type==="image"?React.createElement("img",{src:e.content,alt:"content",className:"image",key:e.content}):React.createElement("span",{key:e.content},e.content),renderContentBlocks=e=>e.map((t,r)=>React.createElement("div",{className:"content-block",key:r},renderContentBlock(t))),Banner=({scene:e,position:t="header",size:r="medium",color:s,bgColor:n,hidden:o=!1})=>{if(o)return null;const a={question:"题目作答",solve:"官方解析",review:"用户复习"},l=()=>{const h={display:"flex",alignItems:"center",justifyContent:"center",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},c={question:"#f97316",solve:"#4a6cf7",review:"#4ade80"};return h.background=n||c[e],h.color=s||"#ffffff",t==="header"?h.borderBottom="1px solid #e0e0e0":t==="sidebar"&&(h.borderRight="1px solid #e0e0e0",h.writingMode="vertical-rl",h.textOrientation="mixed"),Object.assign(h,{small:{fontSize:"12px",padding:"8px 12px"},medium:{fontSize:"14px",padding:"12px 16px"},large:{fontSize:"16px",padding:"16px 20px"}}[r]),h};return jsxRuntimeExports.jsx("div",{style:l(),children:a[e]})},Question=({question:e,problemType:t})=>{const r={padding:"20px",lineHeight:"1.6",fontSize:"16px"};return jsxRuntimeExports.jsx("div",{style:r,children:renderContentBlocks(e)})},AnswerInput=({problemType:e,options:t,value:r=[],onChange:s,placeholder:n="请输入答案"})=>{const o={padding:"20px",borderTop:"1px solid #e0e0e0"},a={width:"100%",padding:"12px 16px",border:"1px solid #e0e0e0",borderRadius:"4px",fontSize:"14px"},l={display:"grid",gap:"12px"},h=d=>({padding:"12px 16px",border:"1px solid #e0e0e0",borderRadius:"4px",cursor:"pointer",transition:"all 0.2s ease",background:d?"#f97316":"transparent",color:d?"#ffffff":"inherit",borderColor:d?"#f97316":"#e0e0e0"}),c=d=>{if(s)if(e==="multiple-choice"){const f=r.includes(d)?r.filter(p=>p!==d):[...r,d];s(f)}else s([d])},u=d=>{s&&s([d.target.value])};return e==="multiple-choice"&&t?jsxRuntimeExports.jsx("div",{style:o,children:jsxRuntimeExports.jsx("div",{style:l,children:t.map(d=>jsxRuntimeExports.jsx("div",{style:h(r.includes(d.id)),onClick:()=>c(d.id),children:renderContentBlocks(d.content)},d.id))})}):jsxRuntimeExports.jsx("div",{style:o,children:jsxRuntimeExports.jsx("input",{type:"text",style:a,placeholder:n,value:r[0]||"",onChange:u})})},SubmitButton=({onClick:e,children:t,disabled:r=!1,loading:s=!1})=>{const n={padding:"12px 24px",background:"#f97316",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:600,cursor:r?"not-allowed":"pointer",opacity:r?.6:1};return jsxRuntimeExports.jsx("button",{style:n,onClick:e,disabled:r||s,children:s?"提交中...":t})},Explanation=({steps:e,title:t="解题步骤"})=>{const r={padding:"20px",borderTop:"1px solid #e0e0e0"},s={fontSize:"18px",fontWeight:600,marginBottom:"16px",color:"#4a6cf7"},n={display:"flex",flexDirection:"column",gap:"12px"},o={padding:"12px",borderLeft:"3px solid #4a6cf7",background:"#f8f9fa",borderRadius:"0 4px 4px 0",lineHeight:"1.6"};return jsxRuntimeExports.jsxs("div",{style:r,children:[jsxRuntimeExports.jsx("div",{style:s,children:t}),jsxRuntimeExports.jsx("div",{style:n,children:e.map(a=>jsxRuntimeExports.jsx("div",{style:o,children:a.content},a.id))})]})},ReviewContent=({reviewContent:e,userAnswer:t,correctAnswer:r})=>{const s={padding:"20px",borderTop:"1px solid #e0e0e0"},n={fontSize:"18px",fontWeight:600,marginBottom:"16px",color:"#4ade80"},o={lineHeight:"1.6"},a={padding:"12px",background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:"4px",marginBottom:"16px"},l={display:"flex",flexDirection:"column",gap:"12px"},h={padding:"12px",borderLeft:"3px solid #4ade80",background:"#f8f9fa",borderRadius:"0 4px 4px 0",lineHeight:"1.6"};return jsxRuntimeExports.jsxs("div",{style:s,children:[jsxRuntimeExports.jsx("div",{style:n,children:"复习内容"}),jsxRuntimeExports.jsxs("div",{style:o,children:[e.reviewTemplate&&jsxRuntimeExports.jsx("div",{style:a,children:e.reviewTemplate.replace(/{correctAnswer}/g,r.join(", ")).replace(/{userAnswer}/g,t.join(", "))}),e.reviewExplanation&&jsxRuntimeExports.jsx("div",{style:l,children:e.reviewExplanation.map(c=>jsxRuntimeExports.jsx("div",{style:h,children:c.content},c.id))})]})]})},LoadingState=({type:e="skeleton"})=>{const t={padding:"20px"},r={height:"16px",background:"linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%)",backgroundSize:"200% 100%",animation:"loading 1.5s infinite",borderRadius:"4px",marginBottom:"12px"},s={display:"flex",justifyContent:"center",alignItems:"center",padding:"24px"},n={width:"40px",height:"40px",border:"4px solid #f0f0f0",borderTop:"4px solid #f97316",borderRadius:"50%",animation:"spin 1s linear infinite"};return e==="spinner"?jsxRuntimeExports.jsx("div",{style:s,children:jsxRuntimeExports.jsx("div",{style:n})}):jsxRuntimeExports.jsxs("div",{style:t,"data-testid":"loading-skeleton",children:[jsxRuntimeExports.jsx("div",{style:{...r,width:"80%"}}),jsxRuntimeExports.jsx("div",{style:{...r,width:"60%"}}),jsxRuntimeExports.jsx("div",{style:{...r,width:"70%"}})]})},ErrorState=({error:e,onRetry:t})=>{const r={padding:"24px",textAlign:"center",color:"#ef4444"},s={marginBottom:"16px",fontSize:"16px"},n={padding:"12px 16px",background:"#ef4444",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px"},o=typeof e=="string"?e:e.message;return jsxRuntimeExports.jsxs("div",{style:r,children:[jsxRuntimeExports.jsx("div",{style:s,children:o}),t&&jsxRuntimeExports.jsx("button",{style:n,onClick:()=>t(e),children:"重试"})]})},Divider=({orientation:e="horizontal",size:t="medium"})=>{const r={background:"#e0e0e0"},s={small:"12px",medium:"16px",large:"20px"};return e==="horizontal"?(r.height="1px",r.width="100%",r.margin=`${s[t]} 0`):(r.width="1px",r.height="100%",r.margin=`0 ${s[t]}`),jsxRuntimeExports.jsx("div",{style:r})},DefaultLayout=({onSubmit:e,onNext:t,onRetry:r,onAnswerChange:s,onHintToggle:n})=>{const{problemData:o,scene:a,submissionResult:l,config:h}=useMathCardContext();if(!o)return jsxRuntimeExports.jsx(ErrorState,{error:"No problem data provided"});const c=()=>{e&&e()},u=()=>{t&&t(o.problemId)},d=()=>{r&&r(o.problemId)},f=g=>{s&&s(g,o.problemType)},p={background:h?.theme==="dark"?"#1a1a1a":"#ffffff",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",fontFamily:"'Arial', sans-serif",fontSize:"14px",overflow:"hidden",color:h?.theme==="dark"?"#ffffff":"#333333",width:"100%",maxWidth:"800px"},m={padding:"20px",borderTop:"1px solid #e0e0e0",display:"flex",gap:"12px"};return jsxRuntimeExports.jsxs("div",{style:p,"data-testid":"math-card","data-theme":h?.theme,children:[h?.showBanner!==!1&&jsxRuntimeExports.jsx(Banner,{scene:a,position:h?.bannerPosition,size:h?.bannerSize,color:h?.bannerCustomStyle?.color,bgColor:h?.bannerCustomStyle?.bgColor}),jsxRuntimeExports.jsx(Question,{question:o.question,problemType:o.problemType}),a==="question"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(AnswerInput,{problemType:o.problemType,options:o.answer.options,onChange:f,placeholder:h?.inputPlaceholder}),jsxRuntimeExports.jsx("div",{style:m,children:jsxRuntimeExports.jsx(SubmitButton,{onClick:c,disabled:!e,children:h?.submitButtonText||"提交答案"})})]}),a==="solve"&&o.explanation&&jsxRuntimeExports.jsx(Explanation,{steps:o.explanation,title:"官方解析"}),a==="review"&&l&&o.reviewContent&&jsxRuntimeExports.jsx(ReviewContent,{reviewContent:o.reviewContent,userAnswer:l.userAnswer,correctAnswer:o.answer.correctAnswer}),(a==="solve"||a==="review")&&jsxRuntimeExports.jsxs("div",{style:m,children:[t&&jsxRuntimeExports.jsx(SubmitButton,{onClick:u,children:h?.nextButtonText||"下一题"}),r&&jsxRuntimeExports.jsx(SubmitButton,{onClick:d,children:h?.retryButtonText||"重新作答"})]})]})},MathCard=({problemData:e,scene:t,submissionResult:r,loading:s,error:n,config:o,children:a,onSubmit:l,onNext:h,onRetry:c,onErrorRetry:u,onAnswerChange:d,onHintToggle:f})=>{if(s)return jsxRuntimeExports.jsx(LoadingState,{type:"skeleton"});if(n)return jsxRuntimeExports.jsx(ErrorState,{error:n,onRetry:u});if(!e)return jsxRuntimeExports.jsx(ErrorState,{error:"No problem data provided"});const p={problemData:e,scene:t,submissionResult:r,config:o};return jsxRuntimeExports.jsx(MathCardContext.Provider,{value:p,children:a||jsxRuntimeExports.jsx(DefaultLayout,{onSubmit:l,onNext:h,onRetry:c,onAnswerChange:d,onHintToggle:f})})};MathCard.Banner=Banner,MathCard.Question=Question,MathCard.AnswerInput=AnswerInput,MathCard.SubmitButton=SubmitButton,MathCard.Explanation=Explanation,MathCard.ReviewContent=ReviewContent,MathCard.LoadingState=LoadingState,MathCard.ErrorState=ErrorState,MathCard.Divider=Divider;function sheetForTag(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}function createStyleElement(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),e.nonce!==void 0&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}var StyleSheet=(function(){function e(r){var s=this;this._insertTag=function(n){var o;s.tags.length===0?s.insertionPoint?o=s.insertionPoint.nextSibling:s.prepend?o=s.container.firstChild:o=s.before:o=s.tags[s.tags.length-1].nextSibling,s.container.insertBefore(n,o),s.tags.push(n)},this.isSpeedy=r.speedy===void 0?!0:r.speedy,this.tags=[],this.ctr=0,this.nonce=r.nonce,this.key=r.key,this.container=r.container,this.prepend=r.prepend,this.insertionPoint=r.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(s){s.forEach(this._insertTag)},t.insert=function(s){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(createStyleElement(this));var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=sheetForTag(n);try{o.insertRule(s,o.cssRules.length)}catch{}}else n.appendChild(document.createTextNode(s));this.ctr++},t.flush=function(){this.tags.forEach(function(s){var n;return(n=s.parentNode)==null?void 0:n.removeChild(s)}),this.tags=[],this.ctr=0},e})(),MS="-ms-",MOZ="-moz-",WEBKIT="-webkit-",COMMENT="comm",RULESET="rule",DECLARATION="decl",IMPORT="@import",KEYFRAMES="@keyframes",LAYER="@layer",abs=Math.abs,from=String.fromCharCode,assign=Object.assign;function hash(e,t){return charat(e,0)^45?(((t<<2^charat(e,0))<<2^charat(e,1))<<2^charat(e,2))<<2^charat(e,3):0}function trim(e){return e.trim()}function match(e,t){return(e=t.exec(e))?e[0]:e}function replace(e,t,r){return e.replace(t,r)}function indexof(e,t){return e.indexOf(t)}function charat(e,t){return e.charCodeAt(t)|0}function substr(e,t,r){return e.slice(t,r)}function strlen(e){return e.length}function sizeof(e){return e.length}function append(e,t){return t.push(e),e}function combine(e,t){return e.map(t).join("")}var line=1,column=1,length=0,position=0,character=0,characters="";function node(e,t,r,s,n,o,a){return{value:e,root:t,parent:r,type:s,props:n,children:o,line,column,length:a,return:""}}function copy(e,t){return assign(node("",null,null,"",null,null,0),e,{length:-e.length},t)}function char(){return character}function prev(){return character=position>0?charat(characters,--position):0,column--,character===10&&(column=1,line--),character}function next(){return character=position<length?charat(characters,position++):0,column++,character===10&&(column=1,line++),character}function peek(){return charat(characters,position)}function caret(){return position}function slice(e,t){return substr(characters,e,t)}function token(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function alloc(e){return line=column=1,length=strlen(characters=e),position=0,[]}function dealloc(e){return characters="",e}function delimit(e){return trim(slice(position-1,delimiter(e===91?e+2:e===40?e+1:e)))}function whitespace(e){for(;(character=peek())&&character<33;)next();return token(e)>2||token(character)>3?"":" "}function escaping(e,t){for(;--t&&next()&&!(character<48||character>102||character>57&&character<65||character>70&&character<97););return slice(e,caret()+(t<6&&peek()==32&&next()==32))}function delimiter(e){for(;next();)switch(character){case e:return position;case 34:case 39:e!==34&&e!==39&&delimiter(character);break;case 40:e===41&&delimiter(e);break;case 92:next();break}return position}function commenter(e,t){for(;next()&&e+character!==57;)if(e+character===84&&peek()===47)break;return"/*"+slice(t,position-1)+"*"+from(e===47?e:next())}function identifier(e){for(;!token(peek());)next();return slice(e,position)}function compile(e){return dealloc(parse("",null,null,null,[""],e=alloc(e),0,[0],e))}function parse(e,t,r,s,n,o,a,l,h){for(var c=0,u=0,d=a,f=0,p=0,m=0,g=1,b=1,v=1,x=0,C="",_=n,y=o,w=s,X=C;b;)switch(m=x,x=next()){case 40:if(m!=108&&charat(X,d-1)==58){indexof(X+=replace(delimit(x),"&","&\f"),"&\f")!=-1&&(v=-1);break}case 34:case 39:case 91:X+=delimit(x);break;case 9:case 10:case 13:case 32:X+=whitespace(m);break;case 92:X+=escaping(caret()-1,7);continue;case 47:switch(peek()){case 42:case 47:append(comment(commenter(next(),caret()),t,r),h);break;default:X+="/"}break;case 123*g:l[c++]=strlen(X)*v;case 125*g:case 59:case 0:switch(x){case 0:case 125:b=0;case 59+u:v==-1&&(X=replace(X,/\f/g,"")),p>0&&strlen(X)-d&&append(p>32?declaration(X+";",s,r,d-1):declaration(replace(X," ","")+";",s,r,d-2),h);break;case 59:X+=";";default:if(append(w=ruleset(X,t,r,c,u,n,l,C,_=[],y=[],d),o),x===123)if(u===0)parse(X,t,w,w,_,o,d,l,y);else switch(f===99&&charat(X,3)===110?100:f){case 100:case 108:case 109:case 115:parse(e,w,w,s&&append(ruleset(e,w,w,0,0,n,l,C,n,_=[],d),y),n,y,d,l,s?_:y);break;default:parse(X,w,w,w,[""],y,0,l,y)}}c=u=p=0,g=v=1,C=X="",d=a;break;case 58:d=1+strlen(X),p=m;default:if(g<1){if(x==123)--g;else if(x==125&&g++==0&&prev()==125)continue}switch(X+=from(x),x*g){case 38:v=u>0?1:(X+="\f",-1);break;case 44:l[c++]=(strlen(X)-1)*v,v=1;break;case 64:peek()===45&&(X+=delimit(next())),f=peek(),u=d=strlen(C=X+=identifier(caret())),x++;break;case 45:m===45&&strlen(X)==2&&(g=0)}}return o}function ruleset(e,t,r,s,n,o,a,l,h,c,u){for(var d=n-1,f=n===0?o:[""],p=sizeof(f),m=0,g=0,b=0;m<s;++m)for(var v=0,x=substr(e,d+1,d=abs(g=a[m])),C=e;v<p;++v)(C=trim(g>0?f[v]+" "+x:replace(x,/&\f/g,f[v])))&&(h[b++]=C);return node(e,t,r,n===0?RULESET:l,h,c,u)}function comment(e,t,r){return node(e,t,r,COMMENT,from(char()),substr(e,2,-2),0)}function declaration(e,t,r,s){return node(e,t,r,DECLARATION,substr(e,0,s),substr(e,s+1,-1),s)}function serialize(e,t){for(var r="",s=sizeof(e),n=0;n<s;n++)r+=t(e[n],n,e,t)||"";return r}function stringify(e,t,r,s){switch(e.type){case LAYER:if(e.children.length)break;case IMPORT:case DECLARATION:return e.return=e.return||e.value;case COMMENT:return"";case KEYFRAMES:return e.return=e.value+"{"+serialize(e.children,s)+"}";case RULESET:e.value=e.props.join(",")}return strlen(r=serialize(e.children,s))?e.return=e.value+"{"+r+"}":""}function middleware(e){var t=sizeof(e);return function(r,s,n,o){for(var a="",l=0;l<t;l++)a+=e[l](r,s,n,o)||"";return a}}function rulesheet(e){return function(t){t.root||(t=t.return)&&e(t)}}function memoize(e){var t=Object.create(null);return function(r){return t[r]===void 0&&(t[r]=e(r)),t[r]}}var identifierWithPointTracking=function(t,r,s){for(var n=0,o=0;n=o,o=peek(),n===38&&o===12&&(r[s]=1),!token(o);)next();return slice(t,position)},toRules=function(t,r){var s=-1,n=44;do switch(token(n)){case 0:n===38&&peek()===12&&(r[s]=1),t[s]+=identifierWithPointTracking(position-1,r,s);break;case 2:t[s]+=delimit(n);break;case 4:if(n===44){t[++s]=peek()===58?"&\f":"",r[s]=t[s].length;break}default:t[s]+=from(n)}while(n=next());return t},getRules=function(t,r){return dealloc(toRules(alloc(t),r))},fixedElements=new WeakMap,compat=function(t){if(!(t.type!=="rule"||!t.parent||t.length<1)){for(var r=t.value,s=t.parent,n=t.column===s.column&&t.line===s.line;s.type!=="rule";)if(s=s.parent,!s)return;if(!(t.props.length===1&&r.charCodeAt(0)!==58&&!fixedElements.get(s))&&!n){fixedElements.set(t,!0);for(var o=[],a=getRules(r,o),l=s.props,h=0,c=0;h<a.length;h++)for(var u=0;u<l.length;u++,c++)t.props[c]=o[h]?a[h].replace(/&\f/g,l[u]):l[u]+" "+a[h]}}},removeLabel=function(t){if(t.type==="decl"){var r=t.value;r.charCodeAt(0)===108&&r.charCodeAt(2)===98&&(t.return="",t.value="")}};function prefix(e,t){switch(hash(e,t)){case 5103:return WEBKIT+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return WEBKIT+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return WEBKIT+e+MOZ+e+MS+e+e;case 6828:case 4268:return WEBKIT+e+MS+e+e;case 6165:return WEBKIT+e+MS+"flex-"+e+e;case 5187:return WEBKIT+e+replace(e,/(\w+).+(:[^]+)/,WEBKIT+"box-$1$2"+MS+"flex-$1$2")+e;case 5443:return WEBKIT+e+MS+"flex-item-"+replace(e,/flex-|-self/,"")+e;case 4675:return WEBKIT+e+MS+"flex-line-pack"+replace(e,/align-content|flex-|-self/,"")+e;case 5548:return WEBKIT+e+MS+replace(e,"shrink","negative")+e;case 5292:return WEBKIT+e+MS+replace(e,"basis","preferred-size")+e;case 6060:return WEBKIT+"box-"+replace(e,"-grow","")+WEBKIT+e+MS+replace(e,"grow","positive")+e;case 4554:return WEBKIT+replace(e,/([^-])(transform)/g,"$1"+WEBKIT+"$2")+e;case 6187:return replace(replace(replace(e,/(zoom-|grab)/,WEBKIT+"$1"),/(image-set)/,WEBKIT+"$1"),e,"")+e;case 5495:case 3959:return replace(e,/(image-set\([^]*)/,WEBKIT+"$1$`$1");case 4968:return replace(replace(e,/(.+:)(flex-)?(.*)/,WEBKIT+"box-pack:$3"+MS+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+WEBKIT+e+e;case 4095:case 3583:case 4068:case 2532:return replace(e,/(.+)-inline(.+)/,WEBKIT+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(strlen(e)-1-t>6)switch(charat(e,t+1)){case 109:if(charat(e,t+4)!==45)break;case 102:return replace(e,/(.+:)(.+)-([^]+)/,"$1"+WEBKIT+"$2-$3$1"+MOZ+(charat(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~indexof(e,"stretch")?prefix(replace(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(charat(e,t+1)!==115)break;case 6444:switch(charat(e,strlen(e)-3-(~indexof(e,"!important")&&10))){case 107:return replace(e,":",":"+WEBKIT)+e;case 101:return replace(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+WEBKIT+(charat(e,14)===45?"inline-":"")+"box$3$1"+WEBKIT+"$2$3$1"+MS+"$2box$3")+e}break;case 5936:switch(charat(e,t+11)){case 114:return WEBKIT+e+MS+replace(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return WEBKIT+e+MS+replace(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return WEBKIT+e+MS+replace(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return WEBKIT+e+MS+e+e}return e}var prefixer=function(t,r,s,n){if(t.length>-1&&!t.return)switch(t.type){case DECLARATION:t.return=prefix(t.value,t.length);break;case KEYFRAMES:return serialize([copy(t,{value:replace(t.value,"@","@"+WEBKIT)})],n);case RULESET:if(t.length)return combine(t.props,function(o){switch(match(o,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return serialize([copy(t,{props:[replace(o,/:(read-\w+)/,":"+MOZ+"$1")]})],n);case"::placeholder":return serialize([copy(t,{props:[replace(o,/:(plac\w+)/,":"+WEBKIT+"input-$1")]}),copy(t,{props:[replace(o,/:(plac\w+)/,":"+MOZ+"$1")]}),copy(t,{props:[replace(o,/:(plac\w+)/,MS+"input-$1")]})],n)}return""})}},defaultStylisPlugins=[prefixer],createCache=function(t){var r=t.key;if(r==="css"){var s=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(s,function(g){var b=g.getAttribute("data-emotion");b.indexOf(" ")!==-1&&(document.head.appendChild(g),g.setAttribute("data-s",""))})}var n=t.stylisPlugins||defaultStylisPlugins,o={},a,l=[];a=t.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+r+' "]'),function(g){for(var b=g.getAttribute("data-emotion").split(" "),v=1;v<b.length;v++)o[b[v]]=!0;l.push(g)});var h,c=[compat,removeLabel];{var u,d=[stringify,rulesheet(function(g){u.insert(g)})],f=middleware(c.concat(n,d)),p=function(b){return serialize(compile(b),f)};h=function(b,v,x,C){u=x,p(b?b+"{"+v.styles+"}":v.styles),C&&(m.inserted[v.name]=!0)}}var m={key:r,sheet:new StyleSheet({key:r,container:a,nonce:t.nonce,speedy:t.speedy,prepend:t.prepend,insertionPoint:t.insertionPoint}),nonce:t.nonce,inserted:o,registered:{},insert:h};return m.sheet.hydrate(l),m},reactIs={exports:{}},reactIs_production_min={};/** @license React v16.13.1
|
|
331
|
+
please report what input caused this bug`);return s=s.slice(1,-1),{type:"verb",mode:"text",body:s,star:n}}unicodeSymbols.hasOwnProperty(r[0])&&!symbols[this.mode][r[0]]&&(this.settings.strict&&this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Accented Unicode text character "'+r[0]+'" used in math mode',t),r=unicodeSymbols[r[0]]+r.slice(1));var o=combiningDiacriticalMarksEndRegex.exec(r);o&&(r=r.substring(0,o.index),r==="i"?r="ı":r==="j"&&(r="ȷ"));var a;if(symbols[this.mode][r]){this.settings.strict&&this.mode==="math"&&extraLatin.indexOf(r)>=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+r[0]+'" used in math mode',t);var l=symbols[this.mode][r].group,h=SourceLocation.range(t),c;if(ATOMS.hasOwnProperty(l)){var u=l;c={type:"atom",mode:this.mode,family:u,loc:h,text:r}}else c={type:l,mode:this.mode,loc:h,text:r};a=c}else if(r.charCodeAt(0)>=128)this.settings.strict&&(supportedCodepoint(r.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+r[0]+'" used in math mode',t):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+r[0]+'"'+(" ("+r.charCodeAt(0)+")"),t)),a={type:"textord",mode:"text",loc:SourceLocation.range(t),text:r};else return null;if(this.consume(),o)for(var d=0;d<o[0].length;d++){var f=o[0][d];if(!unicodeAccents[f])throw new ParseError("Unknown accent ' "+f+"'",t);var p=unicodeAccents[f][this.mode]||unicodeAccents[f].text;if(!p)throw new ParseError("Accent "+f+" unsupported in "+this.mode+" mode",t);a={type:"accent",mode:this.mode,loc:SourceLocation.range(t),label:p,isStretchy:!1,isShifty:!0,base:a}}return a}}Parser.endOfExpression=["}","\\endgroup","\\end","\\right","&"];var parseTree=function(t,r){if(!(typeof t=="string"||t instanceof String))throw new TypeError("KaTeX can only parse string typed expression");var s=new Parser(t,r);delete s.gullet.macros.current["\\df@tag"];var n=s.parse();if(delete s.gullet.macros.current["\\current@color"],delete s.gullet.macros.current["\\color"],s.gullet.macros.get("\\df@tag")){if(!r.displayMode)throw new ParseError("\\tag works only in display equations");n=[{type:"tag",mode:"text",body:n,tag:s.subparse([new Token("\\df@tag")])}]}return n};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&typeof console<"u"&&console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.");var renderToString=function(t,r){var s=renderToDomTree(t,r).toMarkup();return s},renderError=function(t,r,s){if(s.throwOnError||!(t instanceof ParseError))throw t;var n=buildCommon.makeSpan(["katex-error"],[new SymbolNode(r)]);return n.setAttribute("title",t.toString()),n.setAttribute("style","color:"+s.errorColor),n},renderToDomTree=function(t,r){var s=new Settings(r);try{var n=parseTree(t,s);return buildTree(n,t,s)}catch(o){return renderError(o,t,s)}};const loadKaTeXCSS=()=>typeof window<"u"?Promise.resolve().then(()=>katex_min).catch(e=>{console.warn("KaTeX CSS loading failed in Storybook environment:",e)}):Promise.resolve(),EquationRender=React.memo(({parts:e=[],children:t=null,fontSize:r="1rem",color:s="#333333",displayMode:n=!1,className:o=""})=>{const[a,l]=React.useState(!1);React.useEffect(()=>{loadKaTeXCSS().then(()=>{l(!0)})},[]);const h=React.useMemo(()=>e.length===0?[]:a?e.map((f,p)=>{try{return renderToString(f,{displayMode:n,throwOnError:!1,errorColor:"#ff0000"})}catch(m){return console.error(`KaTeX rendering error in part ${p}:`,m),'<span style="color: red;">KaTeX Error</span>'}}):e.map(f=>f),[e,n,a]);if(e.length===0)return null;const c=n?"div":"span",u=React.Children.toArray(t),d=[];return h.forEach((f,p)=>{d.push(jsxRuntimeExports.jsx("span",{dangerouslySetInnerHTML:{__html:f},style:{display:"inline-block"}},`part-${p}`)),p<u.length&&p<e.length-1&&d.push(jsxRuntimeExports.jsx("span",{style:{display:"inline-block"},children:u[p]},`slot-${p}`))}),jsxRuntimeExports.jsx(c,{className:`equation-render ${o}`.trim(),style:{fontSize:r,color:s,display:"flex",alignItems:"center",gap:"0.3em",...n?{justifyContent:"center",margin:"1em 0"}:{}},children:d})}),parseTemplate=(e,t,r)=>e.replace(/{correctAnswer}/g,t.join(", ")).replace(/{userAnswer}/g,r.join(", ")),renderContentBlock=e=>e.type==="formula"?React.createElement(EquationRender,{key:e.content,parts:[e.content],children:null,displayMode:!1,fontSize:"1em",color:"#333333"}):e.type==="image"?React.createElement("img",{src:e.content,alt:"content",className:"image",key:e.content}):React.createElement("span",{key:e.content},e.content),renderContentBlocks=e=>e.map((t,r)=>React.createElement("div",{className:"content-block",key:r},renderContentBlock(t))),parseTemplateWithFormulas=e=>{const t=[];let r=0;const s=/\$\$?[^$]+\$\$?/g;let n;for(;(n=s.exec(e))!==null;){const o=n.index,a=n.index+n[0].length;if(o>r){const c=e.substring(r,o);c.trim()&&t.push({type:"text",content:c})}const h=n[0].replace(/^\$\$?/,"").replace(/\$\$?$/,"");t.push({type:"formula",content:h}),r=a}if(r<e.length){const o=e.substring(r);o.trim()&&t.push({type:"text",content:o})}return t},renderTemplateWithFormulas=(e,t,r)=>{const s=parseTemplate(e,t,r),n=parseTemplateWithFormulas(s);return renderContentBlocks(n)},renderExplanationStep=e=>{const{type:t,content:r,style:s={}}=e,n={marginBottom:"8px",lineHeight:"1.6",...s};switch(t){case"instruction":return React.createElement("div",{key:e.id,style:{...n,fontWeight:"bold",color:"#4a6cf7"}},r);case"formula":const o=r.includes("\\\\")||r.includes("\\downarrow")||r.includes("\\quad");return React.createElement(EquationRender,{key:e.id,parts:[r],children:null,displayMode:o,fontSize:"1.1em",color:"#333333"});case"conclusion":return React.createElement("div",{key:e.id,style:{...n,fontWeight:"bold",color:"#22c55e",borderLeft:"3px solid #22c55e",paddingLeft:"12px"}},r);case"image":return React.createElement("div",{key:e.id,style:n},React.createElement("img",{src:r,alt:"解题步骤",style:{maxWidth:"100%",height:"auto",borderRadius:"4px"}}));case"table":return React.createElement("div",{key:e.id,style:n},React.createElement("div",{style:{border:"1px solid #e0e0e0",borderRadius:"4px",padding:"8px",backgroundColor:"#f8f9fa"}},r));default:return React.createElement("div",{key:e.id,style:n},r)}},renderReviewStep=(e,t,r)=>{const{type:s,content:n,style:o={}}=e,a={marginBottom:"8px",lineHeight:"1.6",...o};switch(s){case"instruction":return React.createElement("div",{key:e.id,style:{...a,fontWeight:"bold",color:"#4ade80"}},n);case"formula":const l=n.includes("\\\\")||n.includes("\\downarrow")||n.includes("\\quad");return React.createElement(EquationRender,{key:e.id,parts:[n],children:null,displayMode:l,fontSize:"1.1em",color:"#333333"});case"conclusion":const h=parseTemplate(n,r,t);return React.createElement("div",{key:e.id,style:{...a,fontWeight:"bold",color:"#4ade80",borderLeft:"3px solid #4ade80",paddingLeft:"12px"}},h);default:return React.createElement("div",{key:e.id,style:a},n)}},renderExplanationSteps=e=>e.map(renderExplanationStep),renderReviewSteps=(e,t,r)=>e.map(s=>renderReviewStep(s,t,r)),Banner=({scene:e,position:t="header",size:r="medium",color:s,bgColor:n,hidden:o=!1})=>{if(o)return null;const a={question:"题目作答",solve:"官方解析",review:"用户复习"},l=()=>{const h={display:"flex",alignItems:"center",justifyContent:"center",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},c={question:"#f97316",solve:"#4a6cf7",review:"#4ade80"};return h.background=n||c[e],h.color=s||"#ffffff",t==="header"?h.borderBottom="1px solid #e0e0e0":t==="sidebar"&&(h.borderRight="1px solid #e0e0e0",h.writingMode="vertical-rl",h.textOrientation="mixed"),Object.assign(h,{small:{fontSize:"12px",padding:"8px 12px"},medium:{fontSize:"14px",padding:"12px 16px"},large:{fontSize:"16px",padding:"16px 20px"}}[r]),h};return jsxRuntimeExports.jsx("div",{style:l(),children:a[e]})},Question=({question:e})=>{const t={padding:"20px",lineHeight:"1.6",fontSize:"16px"};return jsxRuntimeExports.jsx("div",{style:t,children:renderContentBlocks(e)})},AnswerInput=({problemType:e,options:t,value:r=[],onChange:s,placeholder:n="请输入答案"})=>{const o={padding:"20px",borderTop:"1px solid #e0e0e0"},a={width:"100%",padding:"12px 16px",border:"1px solid #e0e0e0",borderRadius:"4px",fontSize:"14px"},l={display:"grid",gap:"12px"},h=d=>({padding:"12px 16px",border:"1px solid #e0e0e0",borderRadius:"4px",cursor:"pointer",transition:"all 0.2s ease",background:d?"#f97316":"transparent",color:d?"#ffffff":"inherit",borderColor:d?"#f97316":"#e0e0e0"}),c=d=>{if(s)if(e==="multiple-choice"){const f=r.includes(d)?r.filter(p=>p!==d):[...r,d];s(f)}else s([d])},u=d=>{s&&s([d.target.value])};return e==="multiple-choice"&&t?jsxRuntimeExports.jsx("div",{style:o,children:jsxRuntimeExports.jsx("div",{style:l,children:t.map(d=>jsxRuntimeExports.jsx("div",{style:h(r.includes(d.id)),onClick:()=>c(d.id),children:renderContentBlocks(d.content)},d.id))})}):jsxRuntimeExports.jsx("div",{style:o,children:jsxRuntimeExports.jsx("input",{type:"text",style:a,placeholder:n,value:r[0]||"",onChange:u})})},SubmitButton=({onClick:e,children:t,disabled:r=!1,loading:s=!1})=>{const n={padding:"12px 24px",background:"#f97316",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:600,cursor:r?"not-allowed":"pointer",opacity:r?.6:1};return jsxRuntimeExports.jsx("button",{style:n,onClick:e,disabled:r||s,children:s?"提交中...":t})},Explanation=({steps:e,title:t="解题步骤"})=>{const r={padding:"20px",borderTop:"1px solid #e0e0e0"},s={fontSize:"18px",fontWeight:600,marginBottom:"16px",color:"#4a6cf7"},n={display:"flex",flexDirection:"column",gap:"12px"},o={padding:"12px",borderLeft:"3px solid #4a6cf7",background:"#f8f9fa",borderRadius:"0 4px 4px 0",lineHeight:"1.6"};return jsxRuntimeExports.jsxs("div",{style:r,children:[jsxRuntimeExports.jsx("div",{style:s,children:t}),jsxRuntimeExports.jsx("div",{style:n,children:renderExplanationSteps(e).map((a,l)=>jsxRuntimeExports.jsx("div",{style:o,children:a},e[l].id))})]})},ReviewContent=({reviewContent:e,userAnswer:t,correctAnswer:r})=>{const s={padding:"20px",borderTop:"1px solid #e0e0e0"},n={fontSize:"18px",fontWeight:600,marginBottom:"16px",color:"#4ade80"},o={lineHeight:"1.6"},a={padding:"12px",background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:"4px",marginBottom:"16px"},l={display:"flex",flexDirection:"column",gap:"12px"},h={padding:"12px",borderLeft:"3px solid #4ade80",background:"#f8f9fa",borderRadius:"0 4px 4px 0",lineHeight:"1.6"};return jsxRuntimeExports.jsxs("div",{style:s,children:[jsxRuntimeExports.jsx("div",{style:n,children:"复习内容"}),jsxRuntimeExports.jsxs("div",{style:o,children:[e.reviewTemplate&&jsxRuntimeExports.jsx("div",{style:a,children:renderTemplateWithFormulas(e.reviewTemplate,r,t)}),e.reviewExplanation&&jsxRuntimeExports.jsx("div",{style:l,children:renderReviewSteps(e.reviewExplanation,t,r).map((c,u)=>jsxRuntimeExports.jsx("div",{style:h,children:c},e.reviewExplanation[u].id))})]})]})},LoadingState=({type:e="skeleton"})=>{const t={padding:"20px"},r={height:"16px",background:"linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%)",backgroundSize:"200% 100%",animation:"loading 1.5s infinite",borderRadius:"4px",marginBottom:"12px"},s={display:"flex",justifyContent:"center",alignItems:"center",padding:"24px"},n={width:"40px",height:"40px",border:"4px solid #f0f0f0",borderTop:"4px solid #f97316",borderRadius:"50%",animation:"spin 1s linear infinite"};return e==="spinner"?jsxRuntimeExports.jsx("div",{style:s,children:jsxRuntimeExports.jsx("div",{style:n})}):jsxRuntimeExports.jsxs("div",{style:t,"data-testid":"loading-skeleton",children:[jsxRuntimeExports.jsx("div",{style:{...r,width:"80%"}}),jsxRuntimeExports.jsx("div",{style:{...r,width:"60%"}}),jsxRuntimeExports.jsx("div",{style:{...r,width:"70%"}})]})},ErrorState=({error:e,onRetry:t})=>{const r={padding:"24px",textAlign:"center",color:"#ef4444"},s={marginBottom:"16px",fontSize:"16px"},n={padding:"12px 16px",background:"#ef4444",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px"},o=typeof e=="string"?e:e.message;return jsxRuntimeExports.jsxs("div",{style:r,children:[jsxRuntimeExports.jsx("div",{style:s,children:o}),t&&jsxRuntimeExports.jsx("button",{style:n,onClick:()=>t(e),children:"重试"})]})},Divider=({orientation:e="horizontal",size:t="medium"})=>{const r={background:"#e0e0e0"},s={small:"12px",medium:"16px",large:"20px"};return e==="horizontal"?(r.height="1px",r.width="100%",r.margin=`${s[t]} 0`):(r.width="1px",r.height="100%",r.margin=`0 ${s[t]}`),jsxRuntimeExports.jsx("div",{style:r})},DefaultLayout=({onSubmit:e,onNext:t,onRetry:r,onAnswerChange:s,onHintToggle:n,value:o})=>{const{problemData:a,scene:l,submissionResult:h,config:c}=useMathCardContext();if(!a)return jsxRuntimeExports.jsx(ErrorState,{error:"No problem data provided"});const u=()=>{e&&e()},d=()=>{t&&t(a.problemId)},f=()=>{r&&r(a.problemId)},p=b=>{s&&s(b,a.problemType)},m={background:c?.theme==="dark"?"#1a1a1a":"#ffffff",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",fontFamily:"'Arial', sans-serif",fontSize:"14px",overflow:"hidden",color:c?.theme==="dark"?"#ffffff":"#333333",width:"100%",maxWidth:"800px"},g={padding:"20px",borderTop:"1px solid #e0e0e0",display:"flex",gap:"12px"};return jsxRuntimeExports.jsxs("div",{style:m,"data-testid":"math-card","data-theme":c?.theme,children:[c?.showBanner!==!1&&jsxRuntimeExports.jsx(Banner,{scene:l,position:c?.bannerPosition,size:c?.bannerSize,color:c?.bannerCustomStyle?.color,bgColor:c?.bannerCustomStyle?.bgColor}),jsxRuntimeExports.jsx(Question,{question:a.question,problemType:a.problemType}),l==="question"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(AnswerInput,{problemType:a.problemType,options:a.answer.options,value:o,onChange:p,placeholder:c?.inputPlaceholder}),jsxRuntimeExports.jsx("div",{style:g,children:jsxRuntimeExports.jsx(SubmitButton,{onClick:u,disabled:!e,children:c?.submitButtonText||"提交答案"})})]}),l==="solve"&&a.explanation&&jsxRuntimeExports.jsx(Explanation,{steps:a.explanation,title:"官方解析"}),l==="review"&&h&&a.reviewContent&&jsxRuntimeExports.jsx(ReviewContent,{reviewContent:a.reviewContent,userAnswer:h.userAnswer,correctAnswer:a.answer.correctAnswer}),(l==="solve"||l==="review")&&jsxRuntimeExports.jsxs("div",{style:g,children:[t&&jsxRuntimeExports.jsx(SubmitButton,{onClick:d,children:c?.nextButtonText||"下一题"}),r&&jsxRuntimeExports.jsx(SubmitButton,{onClick:f,children:c?.retryButtonText||"重新作答"})]})]})},MathCard=({problemData:e,scene:t,submissionResult:r,loading:s,error:n,config:o,children:a,onSubmit:l,onNext:h,onRetry:c,onErrorRetry:u,onAnswerChange:d,onHintToggle:f,value:p})=>{if(s)return jsxRuntimeExports.jsx(LoadingState,{type:"skeleton"});if(n)return jsxRuntimeExports.jsx(ErrorState,{error:n,onRetry:u});if(!e)return jsxRuntimeExports.jsx(ErrorState,{error:"No problem data provided"});const m={problemData:e,scene:t,submissionResult:r,config:o,value:p};return jsxRuntimeExports.jsx(MathCardContext.Provider,{value:m,children:a||jsxRuntimeExports.jsx(DefaultLayout,{onSubmit:l,onNext:h,onRetry:c,onAnswerChange:d,onHintToggle:f,value:p})})};MathCard.Banner=Banner,MathCard.Question=Question,MathCard.AnswerInput=AnswerInput,MathCard.SubmitButton=SubmitButton,MathCard.Explanation=Explanation,MathCard.ReviewContent=ReviewContent,MathCard.LoadingState=LoadingState,MathCard.ErrorState=ErrorState,MathCard.Divider=Divider;function sheetForTag(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}function createStyleElement(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),e.nonce!==void 0&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}var StyleSheet=(function(){function e(r){var s=this;this._insertTag=function(n){var o;s.tags.length===0?s.insertionPoint?o=s.insertionPoint.nextSibling:s.prepend?o=s.container.firstChild:o=s.before:o=s.tags[s.tags.length-1].nextSibling,s.container.insertBefore(n,o),s.tags.push(n)},this.isSpeedy=r.speedy===void 0?!0:r.speedy,this.tags=[],this.ctr=0,this.nonce=r.nonce,this.key=r.key,this.container=r.container,this.prepend=r.prepend,this.insertionPoint=r.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(s){s.forEach(this._insertTag)},t.insert=function(s){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(createStyleElement(this));var n=this.tags[this.tags.length-1];if(this.isSpeedy){var o=sheetForTag(n);try{o.insertRule(s,o.cssRules.length)}catch{}}else n.appendChild(document.createTextNode(s));this.ctr++},t.flush=function(){this.tags.forEach(function(s){var n;return(n=s.parentNode)==null?void 0:n.removeChild(s)}),this.tags=[],this.ctr=0},e})(),MS="-ms-",MOZ="-moz-",WEBKIT="-webkit-",COMMENT="comm",RULESET="rule",DECLARATION="decl",IMPORT="@import",KEYFRAMES="@keyframes",LAYER="@layer",abs=Math.abs,from=String.fromCharCode,assign=Object.assign;function hash(e,t){return charat(e,0)^45?(((t<<2^charat(e,0))<<2^charat(e,1))<<2^charat(e,2))<<2^charat(e,3):0}function trim(e){return e.trim()}function match(e,t){return(e=t.exec(e))?e[0]:e}function replace(e,t,r){return e.replace(t,r)}function indexof(e,t){return e.indexOf(t)}function charat(e,t){return e.charCodeAt(t)|0}function substr(e,t,r){return e.slice(t,r)}function strlen(e){return e.length}function sizeof(e){return e.length}function append(e,t){return t.push(e),e}function combine(e,t){return e.map(t).join("")}var line=1,column=1,length=0,position=0,character=0,characters="";function node(e,t,r,s,n,o,a){return{value:e,root:t,parent:r,type:s,props:n,children:o,line,column,length:a,return:""}}function copy(e,t){return assign(node("",null,null,"",null,null,0),e,{length:-e.length},t)}function char(){return character}function prev(){return character=position>0?charat(characters,--position):0,column--,character===10&&(column=1,line--),character}function next(){return character=position<length?charat(characters,position++):0,column++,character===10&&(column=1,line++),character}function peek(){return charat(characters,position)}function caret(){return position}function slice(e,t){return substr(characters,e,t)}function token(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function alloc(e){return line=column=1,length=strlen(characters=e),position=0,[]}function dealloc(e){return characters="",e}function delimit(e){return trim(slice(position-1,delimiter(e===91?e+2:e===40?e+1:e)))}function whitespace(e){for(;(character=peek())&&character<33;)next();return token(e)>2||token(character)>3?"":" "}function escaping(e,t){for(;--t&&next()&&!(character<48||character>102||character>57&&character<65||character>70&&character<97););return slice(e,caret()+(t<6&&peek()==32&&next()==32))}function delimiter(e){for(;next();)switch(character){case e:return position;case 34:case 39:e!==34&&e!==39&&delimiter(character);break;case 40:e===41&&delimiter(e);break;case 92:next();break}return position}function commenter(e,t){for(;next()&&e+character!==57;)if(e+character===84&&peek()===47)break;return"/*"+slice(t,position-1)+"*"+from(e===47?e:next())}function identifier(e){for(;!token(peek());)next();return slice(e,position)}function compile(e){return dealloc(parse("",null,null,null,[""],e=alloc(e),0,[0],e))}function parse(e,t,r,s,n,o,a,l,h){for(var c=0,u=0,d=a,f=0,p=0,m=0,g=1,b=1,v=1,x=0,C="",_=n,y=o,w=s,X=C;b;)switch(m=x,x=next()){case 40:if(m!=108&&charat(X,d-1)==58){indexof(X+=replace(delimit(x),"&","&\f"),"&\f")!=-1&&(v=-1);break}case 34:case 39:case 91:X+=delimit(x);break;case 9:case 10:case 13:case 32:X+=whitespace(m);break;case 92:X+=escaping(caret()-1,7);continue;case 47:switch(peek()){case 42:case 47:append(comment(commenter(next(),caret()),t,r),h);break;default:X+="/"}break;case 123*g:l[c++]=strlen(X)*v;case 125*g:case 59:case 0:switch(x){case 0:case 125:b=0;case 59+u:v==-1&&(X=replace(X,/\f/g,"")),p>0&&strlen(X)-d&&append(p>32?declaration(X+";",s,r,d-1):declaration(replace(X," ","")+";",s,r,d-2),h);break;case 59:X+=";";default:if(append(w=ruleset(X,t,r,c,u,n,l,C,_=[],y=[],d),o),x===123)if(u===0)parse(X,t,w,w,_,o,d,l,y);else switch(f===99&&charat(X,3)===110?100:f){case 100:case 108:case 109:case 115:parse(e,w,w,s&&append(ruleset(e,w,w,0,0,n,l,C,n,_=[],d),y),n,y,d,l,s?_:y);break;default:parse(X,w,w,w,[""],y,0,l,y)}}c=u=p=0,g=v=1,C=X="",d=a;break;case 58:d=1+strlen(X),p=m;default:if(g<1){if(x==123)--g;else if(x==125&&g++==0&&prev()==125)continue}switch(X+=from(x),x*g){case 38:v=u>0?1:(X+="\f",-1);break;case 44:l[c++]=(strlen(X)-1)*v,v=1;break;case 64:peek()===45&&(X+=delimit(next())),f=peek(),u=d=strlen(C=X+=identifier(caret())),x++;break;case 45:m===45&&strlen(X)==2&&(g=0)}}return o}function ruleset(e,t,r,s,n,o,a,l,h,c,u){for(var d=n-1,f=n===0?o:[""],p=sizeof(f),m=0,g=0,b=0;m<s;++m)for(var v=0,x=substr(e,d+1,d=abs(g=a[m])),C=e;v<p;++v)(C=trim(g>0?f[v]+" "+x:replace(x,/&\f/g,f[v])))&&(h[b++]=C);return node(e,t,r,n===0?RULESET:l,h,c,u)}function comment(e,t,r){return node(e,t,r,COMMENT,from(char()),substr(e,2,-2),0)}function declaration(e,t,r,s){return node(e,t,r,DECLARATION,substr(e,0,s),substr(e,s+1,-1),s)}function serialize(e,t){for(var r="",s=sizeof(e),n=0;n<s;n++)r+=t(e[n],n,e,t)||"";return r}function stringify(e,t,r,s){switch(e.type){case LAYER:if(e.children.length)break;case IMPORT:case DECLARATION:return e.return=e.return||e.value;case COMMENT:return"";case KEYFRAMES:return e.return=e.value+"{"+serialize(e.children,s)+"}";case RULESET:e.value=e.props.join(",")}return strlen(r=serialize(e.children,s))?e.return=e.value+"{"+r+"}":""}function middleware(e){var t=sizeof(e);return function(r,s,n,o){for(var a="",l=0;l<t;l++)a+=e[l](r,s,n,o)||"";return a}}function rulesheet(e){return function(t){t.root||(t=t.return)&&e(t)}}function memoize(e){var t=Object.create(null);return function(r){return t[r]===void 0&&(t[r]=e(r)),t[r]}}var identifierWithPointTracking=function(t,r,s){for(var n=0,o=0;n=o,o=peek(),n===38&&o===12&&(r[s]=1),!token(o);)next();return slice(t,position)},toRules=function(t,r){var s=-1,n=44;do switch(token(n)){case 0:n===38&&peek()===12&&(r[s]=1),t[s]+=identifierWithPointTracking(position-1,r,s);break;case 2:t[s]+=delimit(n);break;case 4:if(n===44){t[++s]=peek()===58?"&\f":"",r[s]=t[s].length;break}default:t[s]+=from(n)}while(n=next());return t},getRules=function(t,r){return dealloc(toRules(alloc(t),r))},fixedElements=new WeakMap,compat=function(t){if(!(t.type!=="rule"||!t.parent||t.length<1)){for(var r=t.value,s=t.parent,n=t.column===s.column&&t.line===s.line;s.type!=="rule";)if(s=s.parent,!s)return;if(!(t.props.length===1&&r.charCodeAt(0)!==58&&!fixedElements.get(s))&&!n){fixedElements.set(t,!0);for(var o=[],a=getRules(r,o),l=s.props,h=0,c=0;h<a.length;h++)for(var u=0;u<l.length;u++,c++)t.props[c]=o[h]?a[h].replace(/&\f/g,l[u]):l[u]+" "+a[h]}}},removeLabel=function(t){if(t.type==="decl"){var r=t.value;r.charCodeAt(0)===108&&r.charCodeAt(2)===98&&(t.return="",t.value="")}};function prefix(e,t){switch(hash(e,t)){case 5103:return WEBKIT+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return WEBKIT+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return WEBKIT+e+MOZ+e+MS+e+e;case 6828:case 4268:return WEBKIT+e+MS+e+e;case 6165:return WEBKIT+e+MS+"flex-"+e+e;case 5187:return WEBKIT+e+replace(e,/(\w+).+(:[^]+)/,WEBKIT+"box-$1$2"+MS+"flex-$1$2")+e;case 5443:return WEBKIT+e+MS+"flex-item-"+replace(e,/flex-|-self/,"")+e;case 4675:return WEBKIT+e+MS+"flex-line-pack"+replace(e,/align-content|flex-|-self/,"")+e;case 5548:return WEBKIT+e+MS+replace(e,"shrink","negative")+e;case 5292:return WEBKIT+e+MS+replace(e,"basis","preferred-size")+e;case 6060:return WEBKIT+"box-"+replace(e,"-grow","")+WEBKIT+e+MS+replace(e,"grow","positive")+e;case 4554:return WEBKIT+replace(e,/([^-])(transform)/g,"$1"+WEBKIT+"$2")+e;case 6187:return replace(replace(replace(e,/(zoom-|grab)/,WEBKIT+"$1"),/(image-set)/,WEBKIT+"$1"),e,"")+e;case 5495:case 3959:return replace(e,/(image-set\([^]*)/,WEBKIT+"$1$`$1");case 4968:return replace(replace(e,/(.+:)(flex-)?(.*)/,WEBKIT+"box-pack:$3"+MS+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+WEBKIT+e+e;case 4095:case 3583:case 4068:case 2532:return replace(e,/(.+)-inline(.+)/,WEBKIT+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(strlen(e)-1-t>6)switch(charat(e,t+1)){case 109:if(charat(e,t+4)!==45)break;case 102:return replace(e,/(.+:)(.+)-([^]+)/,"$1"+WEBKIT+"$2-$3$1"+MOZ+(charat(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~indexof(e,"stretch")?prefix(replace(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(charat(e,t+1)!==115)break;case 6444:switch(charat(e,strlen(e)-3-(~indexof(e,"!important")&&10))){case 107:return replace(e,":",":"+WEBKIT)+e;case 101:return replace(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+WEBKIT+(charat(e,14)===45?"inline-":"")+"box$3$1"+WEBKIT+"$2$3$1"+MS+"$2box$3")+e}break;case 5936:switch(charat(e,t+11)){case 114:return WEBKIT+e+MS+replace(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return WEBKIT+e+MS+replace(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return WEBKIT+e+MS+replace(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return WEBKIT+e+MS+e+e}return e}var prefixer=function(t,r,s,n){if(t.length>-1&&!t.return)switch(t.type){case DECLARATION:t.return=prefix(t.value,t.length);break;case KEYFRAMES:return serialize([copy(t,{value:replace(t.value,"@","@"+WEBKIT)})],n);case RULESET:if(t.length)return combine(t.props,function(o){switch(match(o,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return serialize([copy(t,{props:[replace(o,/:(read-\w+)/,":"+MOZ+"$1")]})],n);case"::placeholder":return serialize([copy(t,{props:[replace(o,/:(plac\w+)/,":"+WEBKIT+"input-$1")]}),copy(t,{props:[replace(o,/:(plac\w+)/,":"+MOZ+"$1")]}),copy(t,{props:[replace(o,/:(plac\w+)/,MS+"input-$1")]})],n)}return""})}},defaultStylisPlugins=[prefixer],createCache=function(t){var r=t.key;if(r==="css"){var s=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(s,function(g){var b=g.getAttribute("data-emotion");b.indexOf(" ")!==-1&&(document.head.appendChild(g),g.setAttribute("data-s",""))})}var n=t.stylisPlugins||defaultStylisPlugins,o={},a,l=[];a=t.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+r+' "]'),function(g){for(var b=g.getAttribute("data-emotion").split(" "),v=1;v<b.length;v++)o[b[v]]=!0;l.push(g)});var h,c=[compat,removeLabel];{var u,d=[stringify,rulesheet(function(g){u.insert(g)})],f=middleware(c.concat(n,d)),p=function(b){return serialize(compile(b),f)};h=function(b,v,x,C){u=x,p(b?b+"{"+v.styles+"}":v.styles),C&&(m.inserted[v.name]=!0)}}var m={key:r,sheet:new StyleSheet({key:r,container:a,nonce:t.nonce,speedy:t.speedy,prepend:t.prepend,insertionPoint:t.insertionPoint}),nonce:t.nonce,inserted:o,registered:{},insert:h};return m.sheet.hydrate(l),m},reactIs={exports:{}},reactIs_production_min={};/** @license React v16.13.1
|
|
332
332
|
* react-is.production.min.js
|
|
333
333
|
*
|
|
334
334
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -723,10 +723,10 @@ Possible parent types: [[x,y,z], text], [x,y,z, text]`);return n=JXG$2.copyAttri
|
|
|
723
723
|
`}return l+="endsolid "+e+`
|
|
724
724
|
`,l}}),JXG$2.createPolyhedron3D=function(e,t,r){var s=t[0],n,o,a,l,h,c,u,d=[],f=null,p=null,m={view:s,vertices:{},coords:{},coords2D:{},zIndex:{},faces:[]};if(JXG$2.exists(t[1].type)&&t[1].type===Const.OBJECT_TYPE_POLYHEDRON3D)f=t[1],p=t[2],m.vertices=f.def.vertices,m.faces=f.def.faces;else{if(JXG$2.isArray(t[1]))for(o=t[1].length,n=0;n<o;n++)m.vertices[n]=t[1][n];else if(JXG$2.isObject(t[1]))for(n in t[1])t[1].hasOwnProperty(n)&&(m.vertices[n]=t[1][n]);m.faces=t[2]}for(u=JXG$2.copyAttributes(r,e.options,"polyhedron3d"),console.time("polyhedron"),s.board.suspendUpdate(),o=m.faces.length,n=0;n<o;n++)c=JXG$2.copyAttributes(r,e.options,"face3d"),u.fillcolorarray.length>0&&(c.fillcolor=u.fillcolorarray[n%u.fillcolorarray.length]),l=m.faces[n],JXG$2.isArray(l)&&l.length===2&&JXG$2.isObject(l[1])&&JXG$2.isArray(l[0])&&(JXG$2.mergeAttr(c,l[1]),m.faces[n]=l[0]),a=s.create("face3d",[m,n],c),d.push(a);for(h=new JXG$2.Polyhedron3D(s,m,d,u),h.setParents(h),n=0;n<o;n++)h.inherits.push(h.faces[n]),h.addChild(h.faces[n]);return f!==null&&(h.addTransform(f,p),h.addParents(f)),s.board.unsuspendUpdate(),console.timeEnd("polyhedron"),h},JXG$2.registerElement("polyhedron3d",JXG$2.createPolyhedron3D),JXG$2.Sphere3D=function(e,t,r,s,n){this.constructor(e.board,n,Const.OBJECT_TYPE_SPHERE3D,Const.OBJECT_CLASS_3D),this.constructor3D(e,"sphere3d"),this.board.finalizeAdding(this),this.method=t,this.center=this.board.select(r),this.point2=null,this.points=[],this.element2D=null,this.aux2D=[],this.projectionType=e.projectionType,t==="twoPoints"?(this.point2=this.board.select(s),this.radius=this.Radius()):t==="pointRadius"&&(this.updateRadius=JXG$2.createFunction(s,this.board),this.updateRadius(),this.addParentsFromJCFunctions([this.updateRadius])),JXG$2.exists(this.center._is_new)?(this.addChild(this.center),delete this.center._is_new):this.center.addChild(this),t==="twoPoints"&&(JXG$2.exists(this.point2._is_new)?(this.addChild(this.point2),delete this.point2._is_new):this.point2.addChild(this)),this.methodMap=JXG$2.deepCopy(this.methodMap,{center:"center",point2:"point2",Radius:"Radius"})},JXG$2.Sphere3D.prototype=new JXG$2.GeometryElement,JXG$2.copyPrototypeMethods(JXG$2.Sphere3D,JXG$2.GeometryElement3D,"constructor3D"),JXG$2.extend(JXG$2.Sphere3D.prototype,{X:function(e,t){var r=this.Radius();return r*Math.sin(e)*Math.cos(t)},Y:function(e,t){var r=this.Radius();return r*Math.sin(e)*Math.sin(t)},Z:function(e,t){var r=this.Radius();return r*Math.cos(e)},range_u:[0,2*Math.PI],range_v:[0,Math.PI],update:function(){return this.projectionType!==this.view.projectionType&&this.rebuildProjection(),this},updateRenderer:function(){return this.needsUpdate=!1,this},setRadius:function(e){return this.updateRadius=JXG$2.createFunction(e,this.board),this.addParentsFromJCFunctions([this.updateRadius]),this.board.update(),this},Radius:function(e){return JXG$2.exists(e)?(this.setRadius(e),this.Radius()):this.method==="twoPoints"?!this.center.testIfFinite()||!this.point2.testIfFinite()?NaN:this.center.distance(this.point2):this.method==="pointRadius"?Math.abs(this.updateRadius()):NaN},focusFn:function(e){var t=this;return function(){var r=t.view.boxToCam[3],s=t.Radius();return t.view.project3DTo2D([t.center.X()+e*s*r[1],t.center.Y()+e*s*r[2],t.center.Z()+e*s*r[3]]).slice(1,3)}},innerVertexFn:function(){var e=this;return function(){var t=e.view,r=t.worldToFocal(e.center.coords,!1),s=Mat.hypot(r[0],r[1]),n=t.boxToCam,o=e.Radius(),a=Math.atan(-s/r[2]),l=Math.acos(o/Mat.norm(r)),h=a+l,c=Math.cos(h),u=Math.sin(h),d;return s>1e-8?d=[-(r[0]*n[1][1]+r[1]*n[2][1])/s,-(r[0]*n[1][2]+r[1]*n[2][2])/s,-(r[0]*n[1][3]+r[1]*n[2][3])/s]:d=[n[1][1],n[1][2],n[1][3]],t.project3DTo2D([e.center.X()+o*(u*d[0]+c*n[3][1]),e.center.Y()+o*(u*d[1]+c*n[3][2]),e.center.Z()+o*(u*d[2]+c*n[3][3])])}},buildCentralProjection:function(e){var t=this.view,r={visible:!1,withLabel:!1},s=t.create("point",this.focusFn(-1),r),n=t.create("point",this.focusFn(1),r),o=t.create("point",this.innerVertexFn(t),r);this.aux2D=[s,n,o],this.element2D=t.create("ellipse",this.aux2D,e===void 0?this.visProp:e)},buildParallelProjection:function(e){var t=this,r=function(){var s=t.view.bbox3D[0][1]-t.view.bbox3D[0][0];return t.Radius()*t.view.size[0]/s};this.aux2D=[],this.element2D=this.view.create("circle",[t.center.element2D,r],e===void 0?this.visProp:e)},rebuildProjection:function(e){var t;if(this.element2D){this.view.board.removeObject(this.element2D);for(t in this.aux2D)this.aux2D.hasOwnProperty(t)&&this.view.board.removeObject(this.aux2D[t])}this.projectionType=this.view.projectionType,this.projectionType==="central"?this.buildCentralProjection(e):this.buildParallelProjection(e),this.addChild(this.element2D),this.inherits.push(this.element2D),this.element2D.view=this.view},projectCoords:function(e,t){var r=this.Radius(),s=[1].concat(e),n=this.center.coords,o=Geometry.distance(n,s,4),a=Stat.subtract(s,n);return o===0?(t[0]=0,t[1]=0,[1,r,0,0]):r===0?(t[0]=0,t[1]=0,this.center.coords):(o=r/o,a[0]=1,a[1]*=o,a[2]*=o,a[3]*=o,t[1]=Math.atan2(a[2],a[1]),t[1]+=t[1]<0?Math.PI:0,t[1]!==0?t[0]=Math.atan2(a[2],a[3]*Math.sin(t[1])):t[0]=Math.atan2(a[1],a[3]*Math.cos(t[1])),t[0]+=t[0]<0?2*Math.PI:0,a)}}),JXG$2.createSphere3D=function(e,t,r){var s=t[0],n,o,a,l,h,c;for(n=JXG$2.copyAttributes(r,e.options,"sphere3d"),o=[],c=1;c<t.length;c++)if(JXG$2.isPointType3D(e,t[c])){if(o.length===0?a="center":a="point",l=JXG$2.providePoints3D(s,[t[c]],r,"sphere3d",[a])[0],l===!1)throw new Error("JSXGraph: Can't create sphere3d from this type. Please provide a point type.");o.push(l)}else o.push(t[c]);if(JXG$2.isPoint3D(o[0])&&JXG$2.isPoint3D(o[1]))h=new JXG$2.Sphere3D(s,"twoPoints",o[0],o[1],n);else if(JXG$2.isPoint3D(o[0])&&(JXG$2.isNumber(o[1])||JXG$2.isFunction(o[1])||JXG$2.isString(o[1])))h=new JXG$2.Sphere3D(s,"pointRadius",o[0],o[1],n);else throw new Error("JSXGraph: Can't create sphere3d with parent types '"+typeof t[1]+"' and '"+typeof t[2]+`'.
|
|
725
725
|
Possible parent types: [point,point], [point,number], [point,function]`);return n=h.setAttr2D(n),h.rebuildProjection(n),h.element2D.prepareUpdate().update(),e.isSuspendedUpdate||h.element2D.updateVisibility().updateRenderer(),h},JXG$2.registerElement("sphere3d",JXG$2.createSphere3D),JXG$2.Surface3D=function(e,t,r,s,n,o,a,l){this.constructor(e.board,l,Const.OBJECT_TYPE_SURFACE3D,Const.OBJECT_CLASS_3D),this.constructor3D(e,"surface3d"),this.board.finalizeAdding(this),this._F=t,this._X=r,this._Y=s,this._Z=n,this._F!==null?(this._X=function(h,c){return this._F(h,c)[0]},this._Y=function(h,c){return this._F(h,c)[1]},this._Z=function(h,c){return this._F(h,c)[2]}):this._X!==null&&(this._F=function(h,c){return[this._X(h,c),this._Y(h,c),this._Z(h,c)]}),this.range_u=o,this.range_v=a,this.dataX=null,this.dataY=null,this.dataZ=null,this.points=[],this.methodMap=JXG$2.deepCopy(this.methodMap,{})},JXG$2.Surface3D.prototype=new JXG$2.GeometryElement,JXG$2.copyPrototypeMethods(JXG$2.Surface3D,JXG$2.GeometryElement3D,"constructor3D"),JXG$2.extend(JXG$2.Surface3D.prototype,{updateWireframe:function(){var e,t,r,s,n,o,a,l,h,c,u,d,f,p,m=[1,0,0,0];for(this.points=[],e=this.evalVisProp("stepsu"),t=this.evalVisProp("stepsv"),n=JXG$2.evaluate(this.range_u),o=JXG$2.evaluate(this.range_v),a=JXG$2.evaluate(n[0]),l=JXG$2.evaluate(o[0]),h=JXG$2.evaluate(n[1]),c=JXG$2.evaluate(o[1]),u=(h-a)/e,d=(c-l)/t,r=0,f=a;r<=e;r++,f+=u)for(this.points.push([]),s=0,p=l;s<=t;s++,p+=d)m=this.F(f,p),m.unshift(1),this.points[r].push(m);return this},updateCoords:function(){return this._F!==null?this.updateWireframe():this.updateTransform(),this},evalF:function(e,t){var r,s,n=[0,0,0,0];if(this.transformations.length===0||!JXG$2.exists(this.baseElement))return n=this._F(e,t),n;for(r=this.transformations,s=0;s<r.length;s++)r[s].update();for(this===this.baseElement?n=this._F(e,t):n=this.baseElement.evalF(e,t),n.unshift(1),n=Mat.matVecMult(r[0].matrix,n),s=1;s<r.length;s++)n=Mat.matVecMult(r[s].matrix,n);return n.slice(1)},F:function(e,t){return this.evalF(e,t)},X:function(e,t){return this.evalF(e,t)[0]},Y:function(e,t){return this.evalF(e,t)[1]},Z:function(e,t){return this.evalF(e,t)[2]},updateDataArray2D:function(){var e,t,r,s,n=[],o=[],a;if(r=this.points.length,r!==0){for(s=this.points[0].length,e=0;e<r;e++){for(t=0;t<s;t++)a=this.view.project3DTo2D(this.points[e][t]),n.push(a[1]),o.push(a[2]);n.push(NaN),o.push(NaN)}for(t=0;t<s;t++){for(e=0;e<r;e++)a=this.view.project3DTo2D(this.points[e][t]),n.push(a[1]),o.push(a[2]);n.push(NaN),o.push(NaN)}}return{X:n,Y:o}},addTransform:function(e,t){return this.addTransformGeneric(e,t),this},updateTransform:function(){var e,t,r,s,n,o,a;if(this.transformations.length===0||this.baseElement===null||JXG$2.exists(this._F))return this;for(e=this.transformations,r=0;r<e.length;r++)e[r].update();if(this!==this.baseElement&&(this.points=[]),o=this.baseElement.points.length,o>0)for(a=this.baseElement.points[0].length,r=0;r<o;r++)for(this!==this.baseElement&&this.points.push([]),s=0;s<a;s++){for(this===this.baseElement?t=this.points[r][s]:t=this.baseElement.points[r][s],n=0;n<e.length;n++)t=Mat.matVecMult(e[n].matrix,t);this===this.baseElement?this.points[r][s]=t:this.points[r].push(t)}return this},updateDataArray:function(){},update:function(){return this.needsUpdate&&(this.updateDataArray(),this.updateCoords()),this},updateRenderer:function(){return this.needsUpdate=!1,this},projectCoords:function(e,t){return Geometry.projectCoordsToParametric(e,this,2,t)}}),JXG$2.createParametricSurface3D=function(e,t,r){var s=t[0],n,o,a,l,h,c,u,d=null,f=null,p;return t.length===3?(d=t[1],f=t[2],n=null,o=null,a=null,l=null):t.length===4?(n=t[1],h=t[2],c=t[3],o=null,a=null,l=null):(o=t[1],a=t[2],l=t[3],h=t[4],c=t[5],n=null),u=JXG$2.copyAttributes(r,e.options,"surface3d"),p=new JXG$2.Surface3D(s,n,o,a,l,h,c,u),u=p.setAttr2D(u),p.element2D=s.create("curve",[[],[]],u),p.element2D.view=s,d!==null&&(p.addTransform(d,f),p.addParents(d)),p.element2D.updateDataArray=function(){var m=p.updateDataArray2D();this.dataX=m.X,this.dataY=m.Y},p.addChild(p.element2D),p.inherits.push(p.element2D),p.element2D.setParents(p),p.element2D.prepareUpdate().update(),e.isSuspendedUpdate||p.element2D.updateVisibility().updateRenderer(),p},JXG$2.registerElement("parametricsurface3d",JXG$2.createParametricSurface3D),JXG$2.createFunctiongraph3D=function(e,t,r){var s=t[0],n=function(u,d){return u},o=function(u,d){return d},a=JXG$2.createFunction(t[1],e,"x, y"),l=t[2],h=t[3],c;return c=s.create("parametricsurface3d",[n,o,a,l,h],r),c.elType="functiongraph3d",c},JXG$2.registerElement("functiongraph3d",JXG$2.createFunctiongraph3D),JXG$2.Parse3D={STL:function(e){var t,r,s,n,o,a,l,h,c,u=[],d=[],f=[];for(a=e.split(`
|
|
726
|
-
`),n=a.length,t=0;t<n;t++)if(o=a[t].trim(),o.indexOf("solid")===0)h=-1,d=[],f=[];else if(o.indexOf("endsolid")===0)u.push([d.slice(),f.slice()]);else if(o.indexOf("facet")===0)h++,f.push([]);else{if(o.indexOf("outer loop")===0||o.indexOf("endloop")===0)continue;if(o.indexOf("vertex")===0){for(l=o.split(" ").slice(1).map(p=>parseFloat(p)),c=!1,r=0;r<d.length;r++)if(JXG$2.Math.Geometry.distance(d[r],l,3)<JXG$2.Math.eps){c=!0,s=r;break}c===!1&&(s=d.length,d.push(l)),f[h].push(s)}}return u}},JXG$2.Parse3D;let size=.75,color="#000";JXG$2.themes.mono_thin={board:{showInfobox:!1,showCopyright:!0,defaultAxes:{x:{ticks:{minorTicks:0,majorHeight:10,majorTickEndings:[1,0]}},y:{ticks:{minorTicks:0,majorHeight:10,majorTickEndings:[0,1]}}}},navbar:{strokeColor:"#bbb",fillColor:"none"},elements:{strokeColor:color,highlightStrokeColor:color,fillColor:"none",highlightFillColor:"none",strokeOpacity:.6,highlightStrokeOpacity:1},angle:{strokeColor:color,fillColor:"#aaaaaa55",fillOpacity:.3,highlightFillColor:"#aaaaaa33",highlightFillOpacity:.3,label:{strokeColor:color}},arc:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size},axis:{},boxplot:{strokeWidth:size,strokeColor:color,fillColor:color,fillOpacity:.2,highlightStrokeWidth:size,highlightStrokeColor:color,highlightFillColor:color,highlightFillOpacity:.1},circle:{strokeWidth:size,highlightStrokeWidth:1.5*size,strokeColor:color,highlightFillColor:"none",highlightStrokeColor:color,center:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},point2:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color}},circumcircle:{strokeWidth:size,highlightStrokeWidth:1.5*size,strokeColor:color,highlightFillColor:"none",highlightStrokeColor:color,center:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color}},circumcirclearc:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size},circumcirclesector:{strokeColor:color,fillColor:"#aaaaaa55",fillOpacity:.3,highlightFillColor:"#aaaaaa33",highlightFillOpacity:.3},comb:{strokeColor:color,strokeWidth:size},conic:{strokeWidth:size,highlightStrokeWidth:1.5*size,strokeColor:color,highlightStrokeColor:color,fillColor:"none",highlightFillColor:"none"},curve:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size},grid:{strokeWidth:size},hatch:{strokeColor:color,strokeWidth:size},incircle:{strokeWidth:size,highlightStrokeWidth:1.5*size,strokeColor:color,highlightFillColor:"none",highlightStrokeColor:color,center:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color}},inequality:{fillColor:"#aaaaaa55",fillOpacity:.2},integral:{fillColor:"#aaaaaa55",highlightFillColor:"#aaaaa33",fillOpacity:.3,highlightFillOpacity:.3,curveLeft:{color},baseLeft:{color},curveRight:{color},baseRight:{color}},label:{strokeColor:color},line:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size,point1:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},point2:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color}},normal:{strokeColor:color},parallel:{strokeColor:color},perpendicular:{strokeColor:color},perpendicularsegment:{strokeColor:color},point:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},polygon:{fillColor:"#aaaaaa55",highlightFillColor:"#aaaaaa33",fillOpacity:.3,highlightFillOpacity:.3,vertices:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},borders:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size}},sector:{strokeColor:color,fillColor:"#aaaaaa55",fillOpacity:.3,highlightFillColor:"#aaaaaa33",highlightFillOpacity:.3},semicircle:{center:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color}},slider:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color,baseline:{strokeWidth:size,strokeColor:color,highlightStrokeColor:color},label:{strokeColor:color},highline:{strokeWidth:3*size,name:"",strokeColor:color,highlightStrokeColor:color},ticks:{strokeColor:color}},slopefield:{strokeWidth:.75*size,highlightStrokeWidth:size,highlightStrokeColor:color,highlightStrokeOpacity:.8},tapemeasure:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size,point1:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},point2:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},ticks:{strokeWidth:size}},text:{strokeColor:color},tracecurve:{strokeColor:color},turtle:{strokeWidth:size,strokeColor:color,arrow:{strokeWidth:2*size,strokeColor:"#aaaaaa55"}},vectorfield:{strokeWidth:.75*size,highlightStrokeWidth:size,highlightStrokeColor:color,highlightStrokeOpacity:.8}},JXG$2.COORDS_BY_SCREEN,JXG$2.COORDS_BY_USER,JXG$2.Dump,JXG$2.Expect,JXG$2.JSXGraph,JXG$2.Math,JXG$2.Options,JXG$2.boards,JXG$2.elements,JXG$2.palette,JXG$2.paletteWong,JXG$2.Board,JXG$2.Chart,JXG$2.Circle,JXG$2.Complex,JXG$2.Composition,JXG$2.Coords,JXG$2.CoordsElement,JXG$2.Curve,JXG$2.GeometryElement,JXG$2.Group,JXG$2.Image,JXG$2.JessieCode,JXG$2.PrefixParser,JXG$2.Line,JXG$2.Point,JXG$2.Polygon,JXG$2.Text,JXG$2.Ticks,JXG$2.Transformation,JXG$2.Turtle,JXG$2.View3D,JXG$2.LMS2rgb,JXG$2.addEvent,JXG$2.autoDigits,JXG$2.autoHighlight,JXG$2.bind,JXG$2.capitalize,JXG$2.clearVisPropOld,JXG$2.clone,JXG$2.cloneAndCopy,JXG$2.cmpArrays,JXG$2.coordsArrayToMatrix,JXG$2.copyAttributes,JXG$2.createEvalFunction,JXG$2.createFunction,JXG$2.createHTMLSlider,JXG$2.darkenColor,JXG$2.debug,JXG$2.debugInt,JXG$2.debugLine,JXG$2.debugWST,JXG$2.deepCopy,JXG$2.def,JXG$2.deprecated,JXG$2.eliminateDuplicates,JXG$2.escapeHTML,JXG$2.evalSlider,JXG$2.evaluate,JXG$2.filterElements,JXG$2.getBoardByContainerId,JXG$2.getCSSTransformMatrix,JXG$2.getCSSTransform,JXG$2.getDimensions,JXG$2.getOffset,JXG$2.getPosition,JXG$2.getProp,JXG$2.hex2rgb,JXG$2.hsv2rgb,JXG$2.isAndroid,JXG$2.isApple,JXG$2.isArray,JXG$2.isDesktop,JXG$2.isInArray,JXG$2.isInObject,JXG$2.isMetroApp,JXG$2.isMobile,JXG$2.isMozilla,JXG$2.isBoard,JXG$2.isName,JXG$2.isNode,JXG$2.isNumber,JXG$2.isObject,JXG$2.isPoint,JXG$2.isPoint3D,JXG$2.isPointType,JXG$2.isPointType3D,JXG$2.isString,JXG$2.isTouchDevice,JXG$2.isTransformationOrArray,JXG$2.isWebWorker,JXG$2.isWebkitAndroid,JXG$2.isWebkitApple,JXG$2.keys,JXG$2.lightenColor,JXG$2.merge,JXG$2.normalizePointFace,JXG$2.providePoints,JXG$2.registerElement,JXG$2.registerReader,JXG$2.removeAllEvents,JXG$2.removeElementFromArray,JXG$2.removeEvent,JXG$2.rgb2LMS,JXG$2.rgb2bw,JXG$2.rgb2cb,JXG$2.rgb2css,JXG$2.rgb2hex,JXG$2.rgb2hsv,JXG$2.rgbParser,JXG$2.rgba2rgbo,JXG$2.rgbo2rgba,JXG$2.sanitizeHTML,JXG$2.shortcut,JXG$2.str2Bool,JXG$2.supportsCanvas,JXG$2.supportsPointerEvents,JXG$2.supportsSVG,JXG$2.supportsVML,JXG$2.swap,JXG$2.timedChunk,JXG$2.toFixed,JXG$2.toFullscreen,JXG$2.toJSON,JXG$2.trim,JXG$2.trimNumber,JXG$2.truncate,JXG$2.unescapeHTML,JXG$2.uniqueArray,JXG$2.useBlackWhiteOptions,JXG$2.useStandardOptions,JXG$2.warn,JXG$2.isBrowser?window.JXG=JXG$2:JXG$2.isWebWorker()&&(self.JXG=JXG$2);const JXG$1=JXG$2.JSXGraph,{OBJECT_TYPE_POINT}=JXG$1,GraphContainer=e=>{const t=React.useRef(null),[r,s]=React.useState(null),[n,o]=React.useState({}),a=React.useCallback((h,c)=>{e.onShapeChange&&e.onShapeChange(h,c)},[e.onShapeChange]),l=React.useCallback(h=>{e.onSelectionChange&&e.onSelectionChange(h)},[e.onSelectionChange]);return React.useEffect(()=>{if(t.current){try{const h=e.boundingBox||[-10,10,10,-10];console.log("🔍 JSXGraph Board Initialization:"),console.log(" - Received boundingBox:",h),console.log(" - Container dimensions:",t.current.clientWidth,"x",t.current.clientHeight);const c=JXG$1.initBoard(t.current,{boundingbox:h,axis:e.showAxis??!0,grid:e.showGrid??!0,showNavigation:!1,pan:{enabled:e.mode==="edit"},zoom:{enabled:!1},keepaspectratio:!0,showCopyright:!1});console.log(" - Board actual boundingbox:",c.getBoundingBox()),setTimeout(()=>{console.log(" - 验证坐标转换:"),console.log(" * 理论边界框:",h),console.log(" * 实际边界框:",c.getBoundingBox()),console.log(" * 实际显示范围:",{left:c.getBoundingBox()[0],top:c.getBoundingBox()[1],right:c.getBoundingBox()[2],bottom:c.getBoundingBox()[3]})},100),s(c)}catch(h){console.error("JSXGraph initialization failed:",h)}return()=>{r&&JXG$1.freeBoard(r)}}},[]),React.useEffect(()=>{if(r)try{r.suspendUpdate(),[...r.objectsList].forEach(u=>{r.removeObject(u)});const c={};e.shapes.forEach(u=>{if(u.type==="point")try{const d=createShapeWithEvents(r,u,e.mode,a,l);d&&(c[u.id]=d)}catch(d){console.warn(`Failed to create point shape ${u.id}:`,d)}}),console.log("📐 Starting phase 2: creating lines, circles and polygons"),console.log("📊 Current board.objectsList:",r.objectsList.map(u=>({id:u.id,name:u.name,type:u.elementClass}))),e.shapes.forEach(u=>{if(u.type==="line"||u.type==="circle"||u.type==="polygon")try{const d=createShapeWithEvents(r,u,e.mode,a,l);d&&(c[u.id]=d)}catch(d){console.warn(`Failed to create shape ${u.id}:`,d)}}),console.log("📝 Starting phase 3: creating text labels"),e.shapes.forEach(u=>{if(u.type==="text")try{const d=createShapeWithEvents(r,u,e.mode,a,l);d&&(c[u.id]=d)}catch(d){console.warn(`Failed to create text ${u.id}:`,d)}}),o(c),r.unsuspendUpdate()}catch(h){console.error("Shape rendering failed:",h)}},[r,e.shapes,e.mode,a,l]),jsxRuntimeExports.jsx("div",{ref:t,className:"w-full h-full"})};function createShapeWithEvents(e,t,r,s,n){const o=r==="edit";switch(t.type){case"point":try{const c=e.create("point",[t.position.x,t.position.y],{id:t.id,name:t.name||t.id,fixed:!o,size:t.size??3,strokeColor:t.strokeColor||t.color||"black",visible:t.visible??!0});return console.log("🔵 Created point:",{shapeId:t.id,pointId:c.id,pointName:c.name,hasIdProperty:"id"in c}),o&&(e.on("drag",()=>{s(t.id,{x:c.X(),y:c.Y()})}),e.on("down",()=>{n(t.id)})),c}catch(c){return console.error(`Failed to create point ${t.id}:`,c),null}case"line":const a=resolvePointRef(t.start,e),l=resolvePointRef(t.end,e);if(a&&l)try{const c=e.create("line",[a,l],{strokeWidth:t.strokeWidth??2,strokeColor:t.strokeColor||t.color||"black",dash:t.dash??0,fixed:!o,visible:t.visible??!0,straightFirst:!1,straightLast:!1});return o&&e.on("down",()=>{n(t.id)}),c}catch(c){return console.error(`Failed to create line ${t.id}:`,c),null}else console.warn(`Cannot create line ${t.id}: missing start or end point`,{startPoint:!!a,endPoint:!!l,startRef:t.start,endRef:t.end});break;case"circle":const h=resolvePointRef(t.center,e);if(h){let c;if(t.through){const u=resolvePointRef(t.through,e);u&&(c=e.create("circle",[h,u],{strokeWidth:t.strokeWidth??2,strokeColor:t.strokeColor||t.color||"black",fillColor:t.fillColor||"none",fillOpacity:t.fillOpacity??.3,dash:t.dash??0,fixed:!o,visible:t.visible??!0}))}else t.radius!==void 0&&(c=e.create("circle",[h,t.radius],{strokeWidth:t.strokeWidth??2,strokeColor:t.strokeColor||t.color||"black",fillColor:t.fillColor||"none",fillOpacity:t.fillOpacity??.3,dash:t.dash??0,fixed:!o,visible:t.visible??!0}));return c&&o&&e.on("down",()=>{n(t.id)}),c}break;case"polygon":try{const c=t.vertices.map(u=>resolvePointRef(u,e));if(c.every(u=>u!==null)){const u=e.create("polygon",c,{strokeWidth:t.strokeWidth??2,strokeColor:t.strokeColor||t.color||"black",fillColor:t.fillColor||"lightblue",fillOpacity:t.fillOpacity??.3,dash:t.dash??0,fixed:!o,visible:t.visible??!0});return o&&e.on("down",()=>{n(t.id)}),u}else console.warn(`Cannot create polygon ${t.id}: some vertices are missing`,{vertices:t.vertices,resolvedVertices:c})}catch(c){console.error(`Failed to create polygon ${t.id}:`,c)}break;case"text":try{return e.create("text",[t.position.x,t.position.y,t.content],{color:t.color||"black",fontSize:t.fontSize??14,fixed:!0,visible:t.visible??!0})}catch(c){console.error(`Failed to create text ${t.id}:`,c)}break}return null}function resolvePointRef(e,t){if(typeof e=="object"&&e!==null){if("x"in e&&"y"in e)return[e.x,e.y];if("$ref"in e)try{if(t.objects&&t.objects[e.$ref]){const s=t.objects[e.$ref];if(s)return s}const r=t.objectsList.find(s=>s.id===e.$ref);if(r)return console.log(`✅ Found referenced point ${e.$ref}:`,r),r;console.warn(`⚠️ Point reference ${e.$ref} not found in board.objectsList`)}catch(r){console.warn(`Failed to resolve point reference ${e.$ref}:`,r)}}return null}function calculateBoundingBox(e,t={}){const{padding:r=.2,margin:s=1,aspectRatio:n,minSize:o=4}=t,a=[];if(e.forEach(M=>{switch(M.type){case"point":a.push(M.position);break;case"line":const G=resolvePoint(M.start,e),E=resolvePoint(M.end,e);G&&a.push(G),E&&a.push(E);break;case"circle":const P=resolvePoint(M.center,e);if(P&&(a.push(P),M.radius!==void 0&&a.push({x:P.x+M.radius,y:P.y},{x:P.x-M.radius,y:P.y},{x:P.x,y:P.y+M.radius},{x:P.x,y:P.y-M.radius})),M.through){const A=resolvePoint(M.through,e);A&&a.push(A)}break;case"polygon":M.vertices.forEach(A=>{const I=resolvePoint(A,e);I&&a.push(I)});break;case"text":a.push(M.position);const $=M.content.length*(M.fontSize||14)/20,k=(M.fontSize||14)/10;a.push({x:M.position.x+$,y:M.position.y},{x:M.position.x-$,y:M.position.y},{x:M.position.x,y:M.position.y+k},{x:M.position.x,y:M.position.y-k});break}}),a.length===0)return{boundingBox:[-o,o,o,-o],center:{x:0,y:0},width:o*2,height:o*2};const l=Math.min(...a.map(M=>M.x)),h=Math.max(...a.map(M=>M.x)),c=Math.min(...a.map(M=>M.y)),u=Math.max(...a.map(M=>M.y)),d=(l+h)/2,f=(c+u)/2;let p=Math.max(h-l,o),m=Math.max(u-c,o);const g=800/500,b=p/m;Math.abs(b-g)>.1&&(b>g?m=p/g:p=m*g);const v=p*(1+r)+s*2,x=m*(1+r)+s*2,C=d-v/2,_=f+x/2,y=d+v/2,w=f-x/2,X=[C,_,y,w];if(process.env.NODE_ENV==="development"){const G=a.map(E=>({x:E.x,y:E.y,insideX:E.x>=C&&E.x<=y,insideY:E.y<=_&&E.y>=w,inside:E.x>=C&&E.x<=y&&E.y<=_&&E.y>=w})).filter(E=>!E.inside);G.length>0&&console.warn("⚠️ 边界框验证警告: 有图形元素超出边界框",{boundingBox:X,outsidePoints:G.slice(0,5),totalOutside:G.length})}return{boundingBox:X,center:{x:d,y:f},width:v,height:x}}function resolvePoint(e,t=[]){if(typeof e=="object"&&e!==null){if("x"in e&&"y"in e)return{x:e.x,y:e.y};if("$ref"in e){const r=t.find(s=>s.id===e.$ref&&s.type==="point");if(r)return r.position}}return null}function debugBoundingBox(e,t="Debug"){console.group(`🔍 ${t} - 边界框计算调试`);const r=[];if(e.forEach(n=>{switch(n.type){case"point":r.push({x:n.position.x,y:n.position.y,source:`point:${n.id}`});break;case"text":r.push({x:n.position.x,y:n.position.y,source:`text:${n.id}`});const o=n.content.length*(n.fontSize||14)/20,a=(n.fontSize||14)/10;r.push({x:n.position.x+o,y:n.position.y,source:`text:${n.id}:right`},{x:n.position.x-o,y:n.position.y,source:`text:${n.id}:left`},{x:n.position.x,y:n.position.y+a,source:`text:${n.id}:top`},{x:n.position.x,y:n.position.y-a,source:`text:${n.id}:bottom`});break;case"polygon":n.vertices.forEach((l,h)=>{const c=resolvePoint(l,e);c&&r.push({x:c.x,y:c.y,source:`polygon:${n.id}:vertex${h}`})});break}}),console.log("📊 收集到的坐标点:",r),r.length>0){const n=Math.min(...r.map(h=>h.x)),o=Math.max(...r.map(h=>h.x)),a=Math.min(...r.map(h=>h.y)),l=Math.max(...r.map(h=>h.y));console.log("📐 原始包围盒:",{minX:n,maxX:o,minY:a,maxY:l,width:o-n,height:l-a})}const s=calculateBoundingBox(e,{padding:.3,margin:1,minSize:4});return console.log("🎯 自动边界框计算结果:",s),console.groupEnd(),s}const MathGraph=e=>{const{shapes:t,mode:r,onShapeChange:s,onSelectionChange:n,width:o=600,height:a=400,showGrid:l=!0,showAxis:h=!0,className:c="",boundingBox:u,autoBoundingBox:d=!0,boundingBoxOptions:f}=e,p=React.useMemo(()=>{if(u)return u;if(d&&t.length>0)try{process.env.NODE_ENV==="development"&&debugBoundingBox(t,"MathGraph Auto BoundingBox");const g=calculateBoundingBox(t,f);return console.log("📐 Auto-calculated bounding box:"),console.log(" - BoundingBox:",g.boundingBox),console.log(" - Center:",g.center),console.log(" - Width:",g.width),console.log(" - Height:",g.height),console.log(" - Options used:",f),g.boundingBox}catch(g){return console.warn("Failed to calculate auto bounding box, using default:",g),[-10,10,10,-10]}return[-10,10,10,-10]},[u,d,t,f]),m=React.useMemo(()=>({width:typeof o=="number"?`${o}px`:o,height:typeof a=="number"?`${a}px`:a}),[o,a]);return jsxRuntimeExports.jsx(MathGraphErrorBoundary,{children:jsxRuntimeExports.jsx("div",{className:`border border-gray-200 rounded-lg bg-white shadow-sm overflow-hidden ${c}`,style:m,"data-testid":"mathgraph",role:"application","aria-label":"数学绘图区域",children:jsxRuntimeExports.jsx(GraphContainer,{shapes:t,mode:r,onShapeChange:s,onSelectionChange:n,boundingBox:p,showGrid:l,showAxis:h})})})},__vite_import_meta_env__={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},trackedConnections=new Map,getTrackedConnectionState=e=>{const t=trackedConnections.get(e);return t?Object.fromEntries(Object.entries(t.stores).map(([r,s])=>[r,s.getState()])):{}},extractConnectionInformation=(e,t,r)=>{if(e===void 0)return{type:"untracked",connection:t.connect(r)};const s=trackedConnections.get(r.name);if(s)return{type:"tracked",store:e,...s};const n={connection:t.connect(r),stores:{}};return trackedConnections.set(r.name,n),{type:"tracked",store:e,...n}},removeStoreFromTrackedConnections=(e,t)=>{if(t===void 0)return;const r=trackedConnections.get(e);r&&(delete r.stores[t],Object.keys(r.stores).length===0&&trackedConnections.delete(e))},findCallerName=e=>{var t,r;if(!e)return;const s=e.split(`
|
|
726
|
+
`),n=a.length,t=0;t<n;t++)if(o=a[t].trim(),o.indexOf("solid")===0)h=-1,d=[],f=[];else if(o.indexOf("endsolid")===0)u.push([d.slice(),f.slice()]);else if(o.indexOf("facet")===0)h++,f.push([]);else{if(o.indexOf("outer loop")===0||o.indexOf("endloop")===0)continue;if(o.indexOf("vertex")===0){for(l=o.split(" ").slice(1).map(p=>parseFloat(p)),c=!1,r=0;r<d.length;r++)if(JXG$2.Math.Geometry.distance(d[r],l,3)<JXG$2.Math.eps){c=!0,s=r;break}c===!1&&(s=d.length,d.push(l)),f[h].push(s)}}return u}},JXG$2.Parse3D;let size=.75,color="#000";JXG$2.themes.mono_thin={board:{showInfobox:!1,showCopyright:!0,defaultAxes:{x:{ticks:{minorTicks:0,majorHeight:10,majorTickEndings:[1,0]}},y:{ticks:{minorTicks:0,majorHeight:10,majorTickEndings:[0,1]}}}},navbar:{strokeColor:"#bbb",fillColor:"none"},elements:{strokeColor:color,highlightStrokeColor:color,fillColor:"none",highlightFillColor:"none",strokeOpacity:.6,highlightStrokeOpacity:1},angle:{strokeColor:color,fillColor:"#aaaaaa55",fillOpacity:.3,highlightFillColor:"#aaaaaa33",highlightFillOpacity:.3,label:{strokeColor:color}},arc:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size},axis:{},boxplot:{strokeWidth:size,strokeColor:color,fillColor:color,fillOpacity:.2,highlightStrokeWidth:size,highlightStrokeColor:color,highlightFillColor:color,highlightFillOpacity:.1},circle:{strokeWidth:size,highlightStrokeWidth:1.5*size,strokeColor:color,highlightFillColor:"none",highlightStrokeColor:color,center:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},point2:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color}},circumcircle:{strokeWidth:size,highlightStrokeWidth:1.5*size,strokeColor:color,highlightFillColor:"none",highlightStrokeColor:color,center:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color}},circumcirclearc:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size},circumcirclesector:{strokeColor:color,fillColor:"#aaaaaa55",fillOpacity:.3,highlightFillColor:"#aaaaaa33",highlightFillOpacity:.3},comb:{strokeColor:color,strokeWidth:size},conic:{strokeWidth:size,highlightStrokeWidth:1.5*size,strokeColor:color,highlightStrokeColor:color,fillColor:"none",highlightFillColor:"none"},curve:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size},grid:{strokeWidth:size},hatch:{strokeColor:color,strokeWidth:size},incircle:{strokeWidth:size,highlightStrokeWidth:1.5*size,strokeColor:color,highlightFillColor:"none",highlightStrokeColor:color,center:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color}},inequality:{fillColor:"#aaaaaa55",fillOpacity:.2},integral:{fillColor:"#aaaaaa55",highlightFillColor:"#aaaaa33",fillOpacity:.3,highlightFillOpacity:.3,curveLeft:{color},baseLeft:{color},curveRight:{color},baseRight:{color}},label:{strokeColor:color},line:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size,point1:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},point2:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color}},normal:{strokeColor:color},parallel:{strokeColor:color},perpendicular:{strokeColor:color},perpendicularsegment:{strokeColor:color},point:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},polygon:{fillColor:"#aaaaaa55",highlightFillColor:"#aaaaaa33",fillOpacity:.3,highlightFillOpacity:.3,vertices:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},borders:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size}},sector:{strokeColor:color,fillColor:"#aaaaaa55",fillOpacity:.3,highlightFillColor:"#aaaaaa33",highlightFillOpacity:.3},semicircle:{center:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color}},slider:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color,baseline:{strokeWidth:size,strokeColor:color,highlightStrokeColor:color},label:{strokeColor:color},highline:{strokeWidth:3*size,name:"",strokeColor:color,highlightStrokeColor:color},ticks:{strokeColor:color}},slopefield:{strokeWidth:.75*size,highlightStrokeWidth:size,highlightStrokeColor:color,highlightStrokeOpacity:.8},tapemeasure:{strokeColor:color,strokeWidth:size,highlightStrokeColor:color,highlightStrokeWidth:size,point1:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},point2:{size,fillColor:color,strokeColor:color,highlightStrokeWidth:4*size,highlightFillColor:color,highlightStrokeColor:color},ticks:{strokeWidth:size}},text:{strokeColor:color},tracecurve:{strokeColor:color},turtle:{strokeWidth:size,strokeColor:color,arrow:{strokeWidth:2*size,strokeColor:"#aaaaaa55"}},vectorfield:{strokeWidth:.75*size,highlightStrokeWidth:size,highlightStrokeColor:color,highlightStrokeOpacity:.8}},JXG$2.COORDS_BY_SCREEN,JXG$2.COORDS_BY_USER,JXG$2.Dump,JXG$2.Expect,JXG$2.JSXGraph,JXG$2.Math,JXG$2.Options,JXG$2.boards,JXG$2.elements,JXG$2.palette,JXG$2.paletteWong,JXG$2.Board,JXG$2.Chart,JXG$2.Circle,JXG$2.Complex,JXG$2.Composition,JXG$2.Coords,JXG$2.CoordsElement,JXG$2.Curve,JXG$2.GeometryElement,JXG$2.Group,JXG$2.Image,JXG$2.JessieCode,JXG$2.PrefixParser,JXG$2.Line,JXG$2.Point,JXG$2.Polygon,JXG$2.Text,JXG$2.Ticks,JXG$2.Transformation,JXG$2.Turtle,JXG$2.View3D,JXG$2.LMS2rgb,JXG$2.addEvent,JXG$2.autoDigits,JXG$2.autoHighlight,JXG$2.bind,JXG$2.capitalize,JXG$2.clearVisPropOld,JXG$2.clone,JXG$2.cloneAndCopy,JXG$2.cmpArrays,JXG$2.coordsArrayToMatrix,JXG$2.copyAttributes,JXG$2.createEvalFunction,JXG$2.createFunction,JXG$2.createHTMLSlider,JXG$2.darkenColor,JXG$2.debug,JXG$2.debugInt,JXG$2.debugLine,JXG$2.debugWST,JXG$2.deepCopy,JXG$2.def,JXG$2.deprecated,JXG$2.eliminateDuplicates,JXG$2.escapeHTML,JXG$2.evalSlider,JXG$2.evaluate,JXG$2.filterElements,JXG$2.getBoardByContainerId,JXG$2.getCSSTransformMatrix,JXG$2.getCSSTransform,JXG$2.getDimensions,JXG$2.getOffset,JXG$2.getPosition,JXG$2.getProp,JXG$2.hex2rgb,JXG$2.hsv2rgb,JXG$2.isAndroid,JXG$2.isApple,JXG$2.isArray,JXG$2.isDesktop,JXG$2.isInArray,JXG$2.isInObject,JXG$2.isMetroApp,JXG$2.isMobile,JXG$2.isMozilla,JXG$2.isBoard,JXG$2.isName,JXG$2.isNode,JXG$2.isNumber,JXG$2.isObject,JXG$2.isPoint,JXG$2.isPoint3D,JXG$2.isPointType,JXG$2.isPointType3D,JXG$2.isString,JXG$2.isTouchDevice,JXG$2.isTransformationOrArray,JXG$2.isWebWorker,JXG$2.isWebkitAndroid,JXG$2.isWebkitApple,JXG$2.keys,JXG$2.lightenColor,JXG$2.merge,JXG$2.normalizePointFace,JXG$2.providePoints,JXG$2.registerElement,JXG$2.registerReader,JXG$2.removeAllEvents,JXG$2.removeElementFromArray,JXG$2.removeEvent,JXG$2.rgb2LMS,JXG$2.rgb2bw,JXG$2.rgb2cb,JXG$2.rgb2css,JXG$2.rgb2hex,JXG$2.rgb2hsv,JXG$2.rgbParser,JXG$2.rgba2rgbo,JXG$2.rgbo2rgba,JXG$2.sanitizeHTML,JXG$2.shortcut,JXG$2.str2Bool,JXG$2.supportsCanvas,JXG$2.supportsPointerEvents,JXG$2.supportsSVG,JXG$2.supportsVML,JXG$2.swap,JXG$2.timedChunk,JXG$2.toFixed,JXG$2.toFullscreen,JXG$2.toJSON,JXG$2.trim,JXG$2.trimNumber,JXG$2.truncate,JXG$2.unescapeHTML,JXG$2.uniqueArray,JXG$2.useBlackWhiteOptions,JXG$2.useStandardOptions,JXG$2.warn,JXG$2.isBrowser?window.JXG=JXG$2:JXG$2.isWebWorker()&&(self.JXG=JXG$2);const JXG$1=JXG$2.JSXGraph,GraphContainer=e=>{const t=React.useRef(null),[r,s]=React.useState(null),[n,o]=React.useState({}),a=React.useCallback((h,c)=>{e.onShapeChange},[e.onShapeChange]),l=React.useCallback(h=>{e.onSelectionChange&&e.onSelectionChange(h?[h]:[])},[e.onSelectionChange]);return React.useEffect(()=>{if(t.current){try{const h=e.boundingBox||[-10,10,10,-10];console.log("🔍 JSXGraph Board Initialization:"),console.log(" - Received boundingBox:",h),console.log(" - Container dimensions:",t.current.clientWidth,"x",t.current.clientHeight);const c=JXG$1.initBoard(t.current,{boundingbox:h,axis:e.showAxis??!0,grid:e.showGrid??!0,showNavigation:!1,pan:{enabled:e.mode==="edit"},keepaspectratio:!0,showCopyright:!1});console.log(" - Board actual boundingbox:",c.getBoundingBox()),setTimeout(()=>{console.log(" - 验证坐标转换:"),console.log(" * 理论边界框:",h),console.log(" * 实际边界框:",c.getBoundingBox()),console.log(" * 实际显示范围:",{left:c.getBoundingBox()[0],top:c.getBoundingBox()[1],right:c.getBoundingBox()[2],bottom:c.getBoundingBox()[3]})},100),s(c)}catch(h){console.error("JSXGraph initialization failed:",h)}return()=>{r&&JXG$1.freeBoard(r)}}},[]),React.useEffect(()=>{if(r)try{r.suspendUpdate(),[...r.objectsList].forEach(u=>{r.removeObject(u)});const c={};e.shapes.forEach(u=>{if(u.type==="point")try{const d=createShapeWithEvents(r,u,e.mode,a,l);d&&(c[u.id]=d)}catch(d){console.warn(`Failed to create point shape ${u.id}:`,d)}}),console.log("📐 Starting phase 2: creating lines, circles and polygons"),console.log("📊 Current board.objectsList:",r.objectsList.map(u=>({id:u.id,name:u.name,type:u.elementClass}))),e.shapes.forEach(u=>{if(u.type==="line"||u.type==="circle"||u.type==="polygon")try{const d=createShapeWithEvents(r,u,e.mode,a,l);d&&(c[u.id]=d)}catch(d){console.warn(`Failed to create shape ${u.id}:`,d)}}),console.log("📝 Starting phase 3: creating text labels"),e.shapes.forEach(u=>{if(u.type==="text")try{const d=createShapeWithEvents(r,u,e.mode,a,l);d&&(c[u.id]=d)}catch(d){console.warn(`Failed to create text ${u.id}:`,d)}}),o(c),r.unsuspendUpdate()}catch(h){console.error("Shape rendering failed:",h)}},[r,e.shapes,e.mode,a,l]),jsxRuntimeExports.jsx("div",{ref:t,className:"w-full h-full"})};function createShapeWithEvents(e,t,r,s,n){const o=r==="edit";switch(t.type){case"point":try{const c=e.create("point",[t.position.x,t.position.y],{id:t.id,name:t.name||t.id,fixed:!o,size:t.size??3,strokeColor:t.strokeColor||t.color||"black",visible:t.visible??!0});return console.log("🔵 Created point:",{shapeId:t.id,pointId:c.id,pointName:c.name,hasIdProperty:"id"in c}),o&&(e.on("drag",()=>{s(t.id,{x:c.X(),y:c.Y()})}),e.on("down",()=>{n(t.id)})),c}catch(c){return console.error(`Failed to create point ${t.id}:`,c),null}case"line":const a=resolvePointRef(t.start,e),l=resolvePointRef(t.end,e);if(a&&l)try{const c=e.create("line",[a,l],{strokeWidth:t.strokeWidth??2,strokeColor:t.strokeColor||t.color||"black",dash:t.dash??0,fixed:!o,visible:t.visible??!0,straightFirst:!1,straightLast:!1});return o&&e.on("down",()=>{n(t.id)}),c}catch(c){return console.error(`Failed to create line ${t.id}:`,c),null}else console.warn(`Cannot create line ${t.id}: missing start or end point`,{startPoint:!!a,endPoint:!!l,startRef:t.start,endRef:t.end});break;case"circle":const h=resolvePointRef(t.center,e);if(h){let c;if(t.through){const u=resolvePointRef(t.through,e);u&&(c=e.create("circle",[h,u],{strokeWidth:t.strokeWidth??2,strokeColor:t.strokeColor||t.color||"black",fillColor:t.fillColor||"none",fillOpacity:t.fillOpacity??.3,dash:t.dash??0,fixed:!o,visible:t.visible??!0}))}else t.radius!==void 0&&(c=e.create("circle",[h,t.radius],{strokeWidth:t.strokeWidth??2,strokeColor:t.strokeColor||t.color||"black",fillColor:t.fillColor||"none",fillOpacity:t.fillOpacity??.3,dash:t.dash??0,fixed:!o,visible:t.visible??!0}));return c&&o&&e.on("down",()=>{n(t.id)}),c}break;case"polygon":try{const c=t.vertices.map(u=>resolvePointRef(u,e));if(c.every(u=>u!==null)){const u=e.create("polygon",c,{strokeWidth:t.strokeWidth??2,strokeColor:t.strokeColor||t.color||"black",fillColor:t.fillColor||"lightblue",fillOpacity:t.fillOpacity??.3,dash:t.dash??0,fixed:!o,visible:t.visible??!0});return o&&e.on("down",()=>{n(t.id)}),u}else console.warn(`Cannot create polygon ${t.id}: some vertices are missing`,{vertices:t.vertices,resolvedVertices:c})}catch(c){console.error(`Failed to create polygon ${t.id}:`,c)}break;case"text":try{return e.create("text",[t.position.x,t.position.y,t.content],{color:t.color||"black",fontSize:t.fontSize??14,fixed:!0,visible:t.visible??!0})}catch(c){console.error(`Failed to create text ${t.id}:`,c)}break}return null}function resolvePointRef(e,t){if(typeof e=="object"&&e!==null){if("x"in e&&"y"in e)return[e.x,e.y];if("$ref"in e)try{if(t.objects&&t.objects[e.$ref]){const s=t.objects[e.$ref];if(s)return s}const r=t.objectsList.find(s=>s.id===e.$ref);if(r)return console.log(`✅ Found referenced point ${e.$ref}:`,r),r;console.warn(`⚠️ Point reference ${e.$ref} not found in board.objectsList`)}catch(r){console.warn(`Failed to resolve point reference ${e.$ref}:`,r)}}return null}function calculateBoundingBox(e,t={}){const{padding:r=.2,margin:s=1,aspectRatio:n,minSize:o=4}=t,a=[];if(e.forEach(M=>{switch(M.type){case"point":a.push(M.position);break;case"line":const G=resolvePoint(M.start,e),E=resolvePoint(M.end,e);G&&a.push(G),E&&a.push(E);break;case"circle":const P=resolvePoint(M.center,e);if(P&&(a.push(P),M.radius!==void 0&&a.push({x:P.x+M.radius,y:P.y},{x:P.x-M.radius,y:P.y},{x:P.x,y:P.y+M.radius},{x:P.x,y:P.y-M.radius})),M.through){const A=resolvePoint(M.through,e);A&&a.push(A)}break;case"polygon":M.vertices.forEach(A=>{const I=resolvePoint(A,e);I&&a.push(I)});break;case"text":a.push(M.position);const $=M.content.length*(M.fontSize||14)/20,k=(M.fontSize||14)/10;a.push({x:M.position.x+$,y:M.position.y},{x:M.position.x-$,y:M.position.y},{x:M.position.x,y:M.position.y+k},{x:M.position.x,y:M.position.y-k});break}}),a.length===0)return{boundingBox:[-o,o,o,-o],center:{x:0,y:0},width:o*2,height:o*2};const l=Math.min(...a.map(M=>M.x)),h=Math.max(...a.map(M=>M.x)),c=Math.min(...a.map(M=>M.y)),u=Math.max(...a.map(M=>M.y)),d=(l+h)/2,f=(c+u)/2;let p=Math.max(h-l,o),m=Math.max(u-c,o);const g=800/500,b=p/m;Math.abs(b-g)>.1&&(b>g?m=p/g:p=m*g);const v=p*(1+r)+s*2,x=m*(1+r)+s*2,C=d-v/2,_=f+x/2,y=d+v/2,w=f-x/2,X=[C,_,y,w];if(process.env.NODE_ENV==="development"){const G=a.map(E=>({x:E.x,y:E.y,insideX:E.x>=C&&E.x<=y,insideY:E.y<=_&&E.y>=w,inside:E.x>=C&&E.x<=y&&E.y<=_&&E.y>=w})).filter(E=>!E.inside);G.length>0&&console.warn("⚠️ 边界框验证警告: 有图形元素超出边界框",{boundingBox:X,outsidePoints:G.slice(0,5),totalOutside:G.length})}return{boundingBox:X,center:{x:d,y:f},width:v,height:x}}function resolvePoint(e,t=[]){if(typeof e=="object"&&e!==null){if("x"in e&&"y"in e)return{x:e.x,y:e.y};if("$ref"in e){const r=t.find(s=>s.id===e.$ref&&s.type==="point");if(r)return r.position}}return null}function debugBoundingBox(e,t="Debug"){console.group(`🔍 ${t} - 边界框计算调试`);const r=[];if(e.forEach(n=>{switch(n.type){case"point":r.push({x:n.position.x,y:n.position.y,source:`point:${n.id}`});break;case"text":r.push({x:n.position.x,y:n.position.y,source:`text:${n.id}`});const o=n.content.length*(n.fontSize||14)/20,a=(n.fontSize||14)/10;r.push({x:n.position.x+o,y:n.position.y,source:`text:${n.id}:right`},{x:n.position.x-o,y:n.position.y,source:`text:${n.id}:left`},{x:n.position.x,y:n.position.y+a,source:`text:${n.id}:top`},{x:n.position.x,y:n.position.y-a,source:`text:${n.id}:bottom`});break;case"polygon":n.vertices.forEach((l,h)=>{const c=resolvePoint(l,e);c&&r.push({x:c.x,y:c.y,source:`polygon:${n.id}:vertex${h}`})});break}}),console.log("📊 收集到的坐标点:",r),r.length>0){const n=Math.min(...r.map(h=>h.x)),o=Math.max(...r.map(h=>h.x)),a=Math.min(...r.map(h=>h.y)),l=Math.max(...r.map(h=>h.y));console.log("📐 原始包围盒:",{minX:n,maxX:o,minY:a,maxY:l,width:o-n,height:l-a})}const s=calculateBoundingBox(e,{padding:.3,margin:1,minSize:4});return console.log("🎯 自动边界框计算结果:",s),console.groupEnd(),s}const MathGraph=e=>{const{shapes:t,mode:r,onShapeChange:s,onSelectionChange:n,width:o=600,height:a=400,showGrid:l=!0,showAxis:h=!0,className:c="",boundingBox:u,autoBoundingBox:d=!0,boundingBoxOptions:f}=e,p=React.useMemo(()=>{if(u)return u;if(d&&t.length>0)try{process.env.NODE_ENV==="development"&&debugBoundingBox(t,"MathGraph Auto BoundingBox");const g=calculateBoundingBox(t,f);return console.log("📐 Auto-calculated bounding box:"),console.log(" - BoundingBox:",g.boundingBox),console.log(" - Center:",g.center),console.log(" - Width:",g.width),console.log(" - Height:",g.height),console.log(" - Options used:",f),g.boundingBox}catch(g){return console.warn("Failed to calculate auto bounding box, using default:",g),[-10,10,10,-10]}return[-10,10,10,-10]},[u,d,t,f]),m=React.useMemo(()=>({width:typeof o=="number"?`${o}px`:o,height:typeof a=="number"?`${a}px`:a}),[o,a]);return jsxRuntimeExports.jsx(MathGraphErrorBoundary,{children:jsxRuntimeExports.jsx("div",{className:`border border-gray-200 rounded-lg bg-white shadow-sm overflow-hidden ${c}`,style:m,"data-testid":"mathgraph",role:"application","aria-label":"数学绘图区域",children:jsxRuntimeExports.jsx(GraphContainer,{shapes:t,mode:r,onShapeChange:s,onSelectionChange:n,boundingBox:p,showGrid:l,showAxis:h})})})},__vite_import_meta_env__={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},trackedConnections=new Map,getTrackedConnectionState=e=>{const t=trackedConnections.get(e);return t?Object.fromEntries(Object.entries(t.stores).map(([r,s])=>[r,s.getState()])):{}},extractConnectionInformation=(e,t,r)=>{if(e===void 0)return{type:"untracked",connection:t.connect(r)};const s=trackedConnections.get(r.name);if(s)return{type:"tracked",store:e,...s};const n={connection:t.connect(r),stores:{}};return trackedConnections.set(r.name,n),{type:"tracked",store:e,...n}},removeStoreFromTrackedConnections=(e,t)=>{if(t===void 0)return;const r=trackedConnections.get(e);r&&(delete r.stores[t],Object.keys(r.stores).length===0&&trackedConnections.delete(e))},findCallerName=e=>{var t,r;if(!e)return;const s=e.split(`
|
|
727
727
|
`),n=s.findIndex(a=>a.includes("api.setState"));if(n<0)return;const o=((t=s[n+1])==null?void 0:t.trim())||"";return(r=/.+ (.+) .+/.exec(o))==null?void 0:r[1]},devtoolsImpl=(e,t={})=>(r,s,n)=>{const{enabled:o,anonymousActionType:a,store:l,...h}=t;let c;try{c=(o??(__vite_import_meta_env__?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return e(r,s,n);const{connection:u,...d}=extractConnectionInformation(l,c,h);let f=!0;n.setState=((g,b,v)=>{const x=r(g,b);if(!f)return x;const C=v===void 0?{type:a||findCallerName(new Error().stack)||"anonymous"}:typeof v=="string"?{type:v}:v;return l===void 0?(u?.send(C,s()),x):(u?.send({...C,type:`${l}/${C.type}`},{...getTrackedConnectionState(h.name),[l]:n.getState()}),x)}),n.devtools={cleanup:()=>{u&&typeof u.unsubscribe=="function"&&u.unsubscribe(),removeStoreFromTrackedConnections(h.name,l)}};const p=(...g)=>{const b=f;f=!1,r(...g),f=b},m=e(n.setState,s,n);if(d.type==="untracked"?u?.init(m):(d.stores[d.store]=n,u?.init(Object.fromEntries(Object.entries(d.stores).map(([g,b])=>[g,g===d.store?m:b.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let g=!1;const b=n.dispatch;n.dispatch=(...v)=>{(__vite_import_meta_env__?"production":void 0)!=="production"&&v[0].type==="__setState"&&!g&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),g=!0),b(...v)}}return u.subscribe(g=>{var b;switch(g.type){case"ACTION":if(typeof g.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return parseJsonThen(g.payload,v=>{if(v.type==="__setState"){if(l===void 0){p(v.state);return}Object.keys(v.state).length!==1&&console.error(`
|
|
728
728
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
729
729
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
730
730
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
731
|
-
`);const x=v.state[l];if(x==null)return;JSON.stringify(n.getState())!==JSON.stringify(x)&&p(x);return}n.dispatchFromDevtools&&typeof n.dispatch=="function"&&n.dispatch(v)});case"DISPATCH":switch(g.payload.type){case"RESET":return p(m),l===void 0?u?.init(n.getState()):u?.init(getTrackedConnectionState(h.name));case"COMMIT":if(l===void 0){u?.init(n.getState());return}return u?.init(getTrackedConnectionState(h.name));case"ROLLBACK":return parseJsonThen(g.state,v=>{if(l===void 0){p(v),u?.init(n.getState());return}p(v[l]),u?.init(getTrackedConnectionState(h.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return parseJsonThen(g.state,v=>{if(l===void 0){p(v);return}JSON.stringify(n.getState())!==JSON.stringify(v[l])&&p(v[l])});case"IMPORT_STATE":{const{nextLiftedState:v}=g.payload,x=(b=v.computedStates.slice(-1)[0])==null?void 0:b.state;if(!x)return;p(l===void 0?x:x[l]),u?.send(null,v);return}case"PAUSE_RECORDING":return f=!f}return}}),m},devtools=devtoolsImpl,parseJsonThen=(e,t)=>{let r;try{r=JSON.parse(e)}catch(s){console.error("[zustand devtools middleware] Could not parse the received json",s)}r!==void 0&&t(r)},API_BASE_URL="/api/v1/content",MOCK_JWT_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c2VyLTAwMSIsIm5hbWUiOiLlsI_mmI4iLCJsZXZlbCI6NSwiYXZhdGFyIjoiaHR0cHM6Ly9pLnByYXZhdGFyLmNjLzQwP3U9c3R1ZGVudDEiLCJiYWRnZXMiOlsi8J-SoiIsIvCfjZUiLCLwn5KbIl0sImlhdCI6MTY5MTYwMDAwMCwiZXhwIjoxNzIzMTM2MDAwfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",DEFAULT_QUESTION_COUNT=10,INITIAL_SCENE="question",useSessionStore=create()(devtools((e,t)=>({sessionId:null,problems:[],totalProblems:0,currentProblemIndex:0,currentScene:"question",userAnswers:{},submissionResults:{},geometryShapes:{},selectedShapeId:null,geometryMode:"view",loading:!1,error:null,timeSpent:0,startTime:null,sessionComplete:!1,loadQuestions:async(r,s)=>{e({loading:!0,sessionId:r});try{const{gradeLevel:n,unitId:o,lessonId:a,count:l=DEFAULT_QUESTION_COUNT}=s,h=`${API_BASE_URL}/grades/${n}/units/${o}/lessons/${a}/sessions/${r}/questions`,c=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${MOCK_JWT_TOKEN}`},body:JSON.stringify({count:l})});if(!c.ok)throw new Error(`Failed to load questions: ${c.status} ${c.statusText}`);const d=(await c.json()).questions||[],f={};d.forEach(p=>{p.geometryShapes&&Array.isArray(p.geometryShapes)&&(f[p.problemId]=p.geometryShapes)}),e({problems:d,totalProblems:d.length,currentProblemIndex:0,currentScene:INITIAL_SCENE,geometryShapes:f,loading:!1,error:null,startTime:Date.now()})}catch(n){const o=n instanceof Error?n.message:"Unknown error occurred";throw e({error:o,loading:!1}),n}},goToNextProblem:()=>{const{currentProblemIndex:r,problems:s,currentScene:n}=t();if(n!==INITIAL_SCENE){console.warn("Cannot navigate during review/solve scene");return}r<s.length-1?e({currentProblemIndex:r+1,currentScene:INITIAL_SCENE}):e({sessionComplete:!0})},goToPreviousProblem:()=>{const{currentProblemIndex:r,currentScene:s}=t();s===INITIAL_SCENE&&r>0&&e({currentProblemIndex:r-1,currentScene:INITIAL_SCENE})},goToProblem:r=>{const{problems:s,currentScene:n}=t();n===INITIAL_SCENE&&(r<0||r>=s.length||e({currentProblemIndex:r,currentScene:INITIAL_SCENE}))},switchScene:r=>{e({currentScene:r})},submitAnswer:async(r,s)=>{const{problems:n,currentProblemIndex:o}=t(),a=n[o];e({loading:!0});try{const l=a?.answer.correctAnswer||[],h=s.length>0&&s[0]===l[0],c={userAnswer:s,isCorrect:h,feedback:h?"🎉 Great job! Your answer is correct!":"❌ Sorry, that's not correct."};e(u=>({userAnswers:{...u.userAnswers,[r]:s},submissionResults:{...u.submissionResults,[r]:c},loading:!1,currentScene:h?"review":"solve"}))}catch(l){e({error:l instanceof Error?l.message:"Submission error",loading:!1})}},updateUserAnswer:(r,s)=>{e(n=>({userAnswers:{...n.userAnswers,[r]:s}}))},updateShape:(r,s,n)=>{e(o=>{const l=(o.geometryShapes[r]||[]).map(h=>h.id===s&&h.type==="point"?{...h,position:n}:h);return{geometryShapes:{...o.geometryShapes,[r]:l}}})},selectShape:(r,s)=>{e({selectedShapeId:s})},setGeometryMode:(r,s)=>{e({geometryMode:s})},startTimer:()=>{e({startTime:Date.now()})},stopTimer:()=>{const{startTime:r}=t();if(r){const s=Math.floor((Date.now()-r)/1e3);e(n=>({timeSpent:n.timeSpent+s,startTime:null}))}},reset:()=>{e({sessionId:null,problems:[],totalProblems:0,currentProblemIndex:0,currentScene:INITIAL_SCENE,userAnswers:{},submissionResults:{},geometryShapes:{},selectedShapeId:null,geometryMode:"view",loading:!1,error:null,timeSpent:0,startTime:null,sessionComplete:!1})},getCurrentProblem:()=>{const{problems:r,currentProblemIndex:s}=t();return r[s]||null},getProgress:()=>{const{currentProblemIndex:r,totalProblems:s}=t();return{current:r+1,total:s,percentage:s>0?(r+1)/s*100:0}},getSessionResults:()=>{const{sessionId:r,problems:s,submissionResults:n,timeSpent:o}=t(),a=s.map(h=>({problemId:h.problemId,userAnswer:n[h.problemId]?.userAnswer||[],isCorrect:n[h.problemId]?.isCorrect||!1,timeSpent:0})),l=a.filter(h=>h.isCorrect).length;return{sessionId:r||"",totalProblems:s.length,correctAnswers:l,accuracy:s.length>0?l/s.length:0,timeSpent:o,averageTime:s.length>0?o/s.length:0,answers:a}}}),{name:"MathSessionStore"})),useSessionCalculations=(e,t,r,s,n,o,a)=>{const l=React.useMemo(()=>r==="question",[r]),h=React.useMemo(()=>e<t.length-1,[e,t.length]),c=React.useMemo(()=>e>0,[e]),u=React.useMemo(()=>!s||!n?!1:s.problemType?.includes("geometry")||o&&o[n]&&o[n].length>0?!0:a?.enableMathGraph!==void 0?a.enableMathGraph:!1,[s,n,o,a?.enableMathGraph]);return{canNavigate:l,canGoNext:h,canGoPrevious:c,shouldRenderMathGraph:u}},useGeometryManagement=(e,t,r,s,n)=>{const o=useSessionStore(u=>u.selectShape),a=useSessionStore(u=>u.setGeometryMode),l=React.useMemo(()=>t?s[t]||[]:[],[s,t]);React.useEffect(()=>{if(!t||!r)return;let u="view";switch(e){case"question":u="edit";break;case"solve":case"review":u="view";break;default:u="view"}n!==u&&a(t,u)},[e,t,n,a,r]);const h=React.useCallback(u=>{t&&useSessionStore.setState(d=>({geometryShapes:{...d.geometryShapes,[t]:u}}))},[t]),c=React.useCallback(u=>{if(t){const d=u.length>0?u[0]:null;o(t,d)}},[t,o]);return{currentGeometryShapes:l,geometryMode:n,handleShapeChange:h,handleSelectionChange:c}},useSessionEventHandlers=(e,t,r)=>{const s=useSessionStore(p=>p.updateUserAnswer),n=useSessionStore(p=>p.submitAnswer),o=useSessionStore(p=>p.goToNextProblem),a=useSessionStore(p=>p.goToPreviousProblem),l=useSessionStore(p=>p.goToProblem),h=React.useCallback(p=>{e&&s(e,p)},[e,s]),c=React.useCallback(()=>{e&&r[e]&&n(e,r[e])},[e,r,n]),u=React.useCallback(p=>{o(),p?.(e,t+1)},[o,e,t]),d=React.useCallback(p=>{a(),p?.(e,t-1)},[a,e,t]),f=React.useCallback((p,m)=>{l(p-1),m?.(e,p-1)},[l,e]);return{handleAnswerChange:h,handleSubmit:c,handleNext:u,handlePrevious:d,handlePagination:f}},MathSessionContainer=({config:e={},onSessionComplete:t,onSessionExit:r,onProblemChange:s,className:n="",style:o})=>{const a=useSessionStore(R=>R.problems),l=useSessionStore(R=>R.currentProblemIndex),h=useSessionStore(R=>R.currentScene),c=useSessionStore(R=>R.loading),u=useSessionStore(R=>R.error),d=useSessionStore(R=>R.sessionComplete),f=useSessionStore(R=>R.submissionResults),p=useSessionStore(R=>R.userAnswers),m=useSessionStore(R=>R.geometryShapes),g=useSessionStore(R=>R.geometryMode),b=useSessionStore(R=>R.getSessionResults),v=React.useMemo(()=>a[l]??null,[a,l]),x=React.useMemo(()=>v?.problemId??"",[v]),{canNavigate:C,canGoNext:_,canGoPrevious:y,shouldRenderMathGraph:w}=useSessionCalculations(l,a,h,v,x,m,e),{currentGeometryShapes:X,handleShapeChange:M,handleSelectionChange:G}=useGeometryManagement(h,x,w,m,g),{handleAnswerChange:E,handleSubmit:P,handleNext:$,handlePrevious:k,handlePagination:A}=useSessionEventHandlers(x,l,p);React.useEffect(()=>{if(d&&typeof b=="function"){const R=b();t?.(R)}},[d,b,t]);const I=R=>typeof R=="string"?R:R instanceof Error?R.message:String(R);return c&&a.length===0?jsxRuntimeExports.jsx("div",{className:"flex items-center justify-center p-12","data-testid":"math-session-loading",children:jsxRuntimeExports.jsxs("div",{className:"text-center",children:[jsxRuntimeExports.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),jsxRuntimeExports.jsx("p",{className:"text-gray-600",children:"Loading questions..."})]})}):u&&u!==null?jsxRuntimeExports.jsx("div",{className:"flex items-center justify-center p-12","data-testid":"math-session-error",children:jsxRuntimeExports.jsxs("div",{className:"text-center text-red-600",children:[jsxRuntimeExports.jsx("p",{className:"text-lg font-semibold mb-2",children:"Error"}),jsxRuntimeExports.jsx("p",{children:I(u)})]})}):v?jsxRuntimeExports.jsxs("div",{className:`flex flex-col max-w-4xl mx-auto p-6 ${n}`,style:o,"data-testid":"math-session-container",role:"region","aria-label":"数学练习会话",children:[jsxRuntimeExports.jsx("div",{className:"mb-6",children:jsxRuntimeExports.jsx(react.Pagination,{total:a.length,page:l+1,onChange:R=>A(R,s),isDisabled:!C,showControls:!1,color:"primary",size:"lg",className:"justify-center"})}),jsxRuntimeExports.jsx(MathCard,{problemData:v,scene:h,submissionResult:f[x],loading:c,error:u?I(u):void 0,onAnswerChange:E,onSubmit:P,onNext:()=>$(s),config:{theme:e.theme??"light",submitButtonText:"提交答案",nextButtonText:h==="solve"?"Got it!":"下一题",showHints:e.enableHints}}),w&&jsxRuntimeExports.jsx("div",{className:"mt-4 w-full max-w-4xl mx-auto","data-testid":"mathgraph-container",children:jsxRuntimeExports.jsx(MathGraph,{shapes:X,mode:g,onShapeChange:M,onSelectionChange:G,showGrid:!0,showAxis:!0,width:800,height:500,boundingBoxOptions:{padding:.5,margin:2,minSize:8}})}),e.showProgress&&jsxRuntimeExports.jsxs("div",{className:"mt-6 flex justify-between items-center",children:[jsxRuntimeExports.jsx("button",{onClick:()=>k(s),disabled:!y,className:"px-4 py-2 text-sm border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"上一题"}),jsxRuntimeExports.jsxs("div",{className:"text-sm text-gray-600",children:[l+1," / ",a.length]}),jsxRuntimeExports.jsx("button",{onClick:()=>$(s),disabled:!_||!C,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"下一题"})]}),r&&jsxRuntimeExports.jsx("div",{className:"mt-4 flex justify-center",children:jsxRuntimeExports.jsx("button",{onClick:r,className:"px-4 py-2 text-sm text-gray-600 hover:text-gray-900 transition-colors",children:"退出练习"})})]}):jsxRuntimeExports.jsx("div",{className:"flex items-center justify-center p-12","data-testid":"math-session-empty",children:jsxRuntimeExports.jsx("p",{className:"text-gray-600",children:"No problems available"})})},MathSessionPage=({sessionId:e,gradeId:t,unitId:r,lessonId:s,userId:n,config:o={},className:a="",onSessionComplete:l,onSessionExit:h})=>{const[c,u]=React.useState({loading:!1,error:null,initialized:!1}),[d,f]=React.useState(0),[p,m]=React.useState(""),g=React.useRef(null),b=React.useRef(null),v=React.useRef(null),x=useSessionStore(M=>M.loadQuestions),C=useSessionStore(M=>M.reset);React.useEffect(()=>{const M=async()=>{try{u(G=>({...G,loading:!0,error:null})),console.log("🎯 MathSessionPage: 开始初始化会话",{sessionId:e,gradeId:t,unitId:r,lessonId:s,userId:n}),await x(e,{gradeLevel:parseInt(t.replace("g",""))||5,unitId:r,lessonId:s,count:o.questionCount||10}),u(G=>({...G,loading:!1,initialized:!0})),console.log("✅ MathSessionPage: 会话初始化完成")}catch(G){const E=G instanceof Error?G.message:"Failed to initialize session";u(P=>({...P,loading:!1,error:E,initialized:!1})),console.error("❌ MathSessionPage: 会话初始化失败",G)}};e&&t&&r&&s&&!c.initialized&&M()},[e,t,r,s,x,o.questionCount,c.initialized,d]),React.useEffect(()=>{c.loading&&!c.initialized?m("正在加载数学练习内容,请稍候..."):c.error?m(`加载失败:${c.error},请点击重试按钮重新加载`):c.initialized&&m("数学练习内容已加载完成,可以开始练习")},[c.loading,c.error,c.initialized]),React.useEffect(()=>{c.initialized&&g.current&&g.current.focus()},[c.initialized]),React.useEffect(()=>{c.error&&v.current&&v.current.focus()},[c.error]),React.useEffect(()=>{c.loading&&b.current&&b.current.focus()},[c.loading]),React.useEffect(()=>()=>{console.log("🧹 MathSessionPage: 清理会话状态"),C()},[C]);const _=React.useCallback(M=>{console.log("🎉 MathSessionPage: 会话完成",M),l?.(M)},[l]),y=React.useCallback(()=>{console.log("🚪 MathSessionPage: 退出会话"),h?.()},[h]),w=React.useCallback((M,G)=>{console.log(`📝 MathSessionPage: 切换到题目 ${G+1}`,M)},[]),X=React.useCallback(M=>{M.key==="Escape"&&(M.preventDefault(),y()),M.key==="Enter"&&c.error&&M.target===v.current&&(M.preventDefault(),u({loading:!1,error:null,initialized:!1}),f(G=>G+1))},[y,c.error]);return c.loading&&!c.initialized?jsxRuntimeExports.jsxs("div",{className:`math-session-page loading ${a}`,"data-testid":"math-session-page",role:"main","aria-label":"数学练习页面",onKeyDown:X,tabIndex:-1,ref:b,children:[jsxRuntimeExports.jsx("div",{"aria-live":"assertive","aria-atomic":"true",className:"sr-only",children:p}),jsxRuntimeExports.jsx("div",{className:"page-loading-container",children:jsxRuntimeExports.jsxs("div",{className:"loading-spinner","data-testid":"page-loading-spinner",role:"status","aria-label":"正在加载练习内容",children:[jsxRuntimeExports.jsx("div",{className:"spinner","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:"loading-text",children:"正在加载练习内容..."})]})})]}):c.error?jsxRuntimeExports.jsxs("div",{className:`math-session-page error ${a}`,"data-testid":"math-session-page",role:"main","aria-label":"数学练习页面 - 错误状态",onKeyDown:X,tabIndex:-1,ref:v,children:[jsxRuntimeExports.jsx("div",{"aria-live":"assertive","aria-atomic":"true",className:"sr-only",children:p}),jsxRuntimeExports.jsxs("div",{className:"error-container",children:[jsxRuntimeExports.jsx("div",{className:"error-icon",role:"img","aria-label":"警告图标",children:"⚠️"}),jsxRuntimeExports.jsx("h3",{className:"error-title",children:"加载失败"}),jsxRuntimeExports.jsx("p",{className:"error-message",children:c.error}),jsxRuntimeExports.jsx("button",{onClick:()=>{u({loading:!1,error:null,initialized:!1}),f(M=>M+1)},className:"retry-button","data-testid":"retry-button","aria-label":"重新加载练习内容",children:"重试"})]})]}):jsxRuntimeExports.jsxs("div",{className:`math-session-page ${a}`,"data-testid":"math-session-page",role:"main","aria-label":"数学练习页面",onKeyDown:X,children:[jsxRuntimeExports.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:p}),o.layout?.showHeader&&jsxRuntimeExports.jsx("header",{className:"page-header",role:"banner",children:jsxRuntimeExports.jsxs("div",{className:"header-content",children:[jsxRuntimeExports.jsx("h1",{className:"page-title",children:"数学练习"}),jsxRuntimeExports.jsxs("div",{className:"session-info","aria-label":"会话信息",children:[jsxRuntimeExports.jsxs("span",{className:"session-id",children:["会话: ",e]}),jsxRuntimeExports.jsxs("span",{className:"grade-info",children:["年级: ",t]})]})]})}),jsxRuntimeExports.jsx("main",{className:"page-main",ref:g,tabIndex:-1,"aria-label":"数学练习主要内容区域",children:jsxRuntimeExports.jsx(MathSessionContainer,{config:{showProgress:o.showProgress??!0,enableHints:o.enableHints??!1,autoAdvance:o.autoAdvance??!1,theme:o.theme??"light"},onSessionComplete:_,onSessionExit:y,onProblemChange:w})}),o.layout?.showFooter&&jsxRuntimeExports.jsx("footer",{className:"page-footer",role:"contentinfo",children:jsxRuntimeExports.jsx("div",{className:"footer-content",children:jsxRuntimeExports.jsx("p",{className:"footer-text",children:"© 2024 MathWiz - 小学数学益智教育平台"})})})]})},MathSessionPage$1=React.memo(MathSessionPage),pointOnLine=(e,t,r)=>({x:e.x+(t.x-e.x)*r,y:e.y+(t.y-e.y)*r}),calculateGamePoints=()=>{const e={x:.5,y:.1,name:"A"},t={x:.1,y:.75,name:"B"},r={x:.9,y:.75,name:"C"},s={...pointOnLine(e,t,1/3),name:"D"},n={...pointOnLine(e,r,1/3),name:"E"},o={...pointOnLine(e,t,2/3),name:"M"},a={...pointOnLine(e,r,2/3),name:"N"},l={...pointOnLine(t,r,1/3),name:"P"},h={...pointOnLine(t,r,2/3),name:"Q"},c={...pointOnLine(s,n,1/3),name:"U"},u={...pointOnLine(s,n,2/3),name:"S"},d={...pointOnLine(o,a,1/3),name:"K"},f={...pointOnLine(o,a,2/3),name:"L"};return{A:e,B:t,C:r,D:s,E:n,M:o,N:a,P:l,Q:h,U:c,S:u,K:d,L:f}},toPixelCoordinates=(e,t,r)=>{const s={};for(const[n,o]of Object.entries(e))s[n]={...o,x:o.x*t,y:o.y*r};return s},isPointInTriangle=(e,t)=>{const[r,s,n]=t,{x:o,y:a}=e,l=(s.y-n.y)*(r.x-n.x)+(n.x-s.x)*(r.y-n.y);if(Math.abs(l)<1e-4)return!1;const h=((s.y-n.y)*(o-n.x)+(n.x-s.x)*(a-n.y))/l,c=((n.y-r.y)*(o-n.x)+(r.x-n.x)*(a-n.y))/l,u=1-h-c;return h>=-.001&&c>=-.001&&u>=-.001},trianglesMatch=(e,t)=>{if(!e||!t||e.length!==3||t.length!==3)return!1;const r=e.map(n=>n.name).sort(),s=t.map(n=>n.name).sort();return r.every((n,o)=>n===s[o])},comparePointArrays=(e,t)=>{if(!e||!t||e.length!==t.length)return!1;const r=e.map(n=>n.name).sort(),s=t.map(n=>n.name).sort();return r.join("")===s.join("")},getBasicLineDefinitions=()=>[{from:"A",to:"B"},{from:"A",to:"C"},{from:"B",to:"C"},{from:"D",to:"E"},{from:"M",to:"N"},{from:"P",to:"Q"},{from:"A",to:"D"},{from:"A",to:"E"},{from:"A",to:"M"},{from:"A",to:"N"},{from:"A",to:"P"},{from:"A",to:"Q"},{from:"D",to:"U"},{from:"U",to:"S"},{from:"S",to:"E"},{from:"M",to:"K"},{from:"K",to:"L"},{from:"L",to:"N"},{from:"B",to:"P"},{from:"P",to:"Q"},{from:"Q",to:"C"}],getBasicGemDefinitions=()=>[{id:"gem_1",vertices:["A","B","P"],points:10,category:"basic"},{id:"gem_2",vertices:["A","P","Q"],points:10,category:"basic"},{id:"gem_3",vertices:["A","Q","C"],points:10,category:"basic"},{id:"gem_4",vertices:["A","B","Q"],points:15,category:"medium"},{id:"gem_5",vertices:["A","P","C"],points:15,category:"medium"},{id:"gem_6",vertices:["A","B","C"],points:20,category:"large"},{id:"gem_7",vertices:["A","D","U"],points:12,category:"ade_small"},{id:"gem_8",vertices:["A","U","S"],points:12,category:"ade_small"},{id:"gem_9",vertices:["A","S","E"],points:12,category:"ade_small"},{id:"gem_10",vertices:["A","D","S"],points:18,category:"ade_medium"},{id:"gem_11",vertices:["A","U","E"],points:18,category:"ade_medium"},{id:"gem_12",vertices:["A","D","E"],points:25,category:"ade_large"},{id:"gem_13",vertices:["A","M","K"],points:14,category:"amn_small"},{id:"gem_14",vertices:["A","K","L"],points:14,category:"amn_small"},{id:"gem_15",vertices:["A","L","N"],points:14,category:"amn_small"},{id:"gem_16",vertices:["A","M","L"],points:20,category:"amn_medium"},{id:"gem_17",vertices:["A","K","N"],points:20,category:"amn_medium"},{id:"gem_18",vertices:["A","M","N"],points:30,category:"amn_large"}],GEOMETRY_CONFIG={TOTAL_GEMS:18,CANVAS_RATIO:4/3,DEFAULT_VIEWBOX:{width:700,height:600},POINT_RADIUS:{default:6,selected:9},TOLERANCE:.001,MIN_TRIANGLE_AREA:.001,COORDINATE_PRECISION:1e-4,BARYCENTRIC_TOLERANCE:-.001},generateMockUserCourseProgress=(e=MOCK_USER_DATA.id)=>{const t=courseData.units.map((n,o)=>{const a=Math.min(100,Math.max(0,o*15+Math.random()*20)),l=Math.floor(n.lessons.length*a/100),h=n.lessons.map((c,u)=>{const d=Math.min(100,Math.max(0,a-u*10+Math.random()*30));return{lessonId:c.id,status:d>=100?"completed":d>0?"in-progress":"not-started",progressPercentage:Math.round(d),lastAccessed:d>0?new Date(Date.now()-Math.random()*7*24*60*60*1e3).toISOString():void 0,timeSpent:d>0?Math.floor(Math.random()*120+10):void 0,score:d>=100?Math.floor(Math.random()*21+80):void 0,attempts:d>0?Math.floor(Math.random()*3+1):void 0}});return{unitId:n.id,userId:e,totalLessons:n.lessons.length,completedLessons:l,progressPercentage:Math.round(a),status:a>=100?"completed":a>0?"in-progress":"not-started",lastAccessed:a>0?new Date(Date.now()-Math.random()*14*24*60*60*1e3).toISOString():void 0,lessons:h}}),r=t.reduce((n,o)=>n+o.progressPercentage,0)/t.length,s=t.filter(n=>n.status==="completed").length;return{courseId:courseData.id,userId:e,totalUnits:t.length,completedUnits:s,progressPercentage:Math.round(r),status:r>=100?"completed":r>0?"in-progress":"not-started",lastAccessed:new Date(Date.now()-Math.random()*3*24*60*60*1e3).toISOString(),units:t}},MOCK_USER_COURSE_PROGRESS=generateMockUserCourseProgress(),getUserCourseProgress=(e,t)=>e===MOCK_USER_DATA.id&&t===courseData.id?MOCK_USER_COURSE_PROGRESS:null,getUserUnitProgress=(e,t,r)=>{const s=getUserCourseProgress(e,t);return s&&s.units.find(n=>n.unitId===r)||null},getUserLessonProgress=(e,t,r,s)=>{const n=getUserUnitProgress(e,t,r);return n&&n.lessons.find(o=>o.lessonId===s)||null},updateUserLessonProgress=(e,t,r,s,n)=>(console.log("Updating lesson progress:",{userId:e,courseId:t,unitId:r,lessonId:s,progress:n}),!0),getUserGradeUnitsNav=(e,t)=>{const r=getUserCourseProgress(e,t);if(!r)return null;const s=courseData.units.map((n,o)=>{const a=r.units.find(l=>l.unitId===n.id);return{unitId:n.id,title:n.title,description:n.description,moduleCategory:n.moduleCategory,estimatedDuration:n.estimatedDuration,totalLessons:n.lessons.length,completedLessons:a?.completedLessons||0,progressPercentage:a?.progressPercentage||0,status:a?.status||"not-started",lastAccessed:a?.lastAccessed,isActive:o===0,route:`/math/grade-${courseData.level}/unit/${n.id}`}});return{userId:e,courseId:courseData.id,courseTitle:courseData.title,courseLevel:courseData.level,totalUnits:s.length,completedUnits:s.filter(n=>n.status==="completed").length,overallProgress:r.progressPercentage,status:r.status,lastAccessed:r.lastAccessed,units:s}},getUnitNavItem=(e,t,r)=>{const s=getUserGradeUnitsNav(e,t);return s&&s.units.find(n=>n.unitId===r)||null},updateUnitActiveStatus=(e,t,r,s)=>(console.log("Updating unit active status:",{userId:e,courseId:t,unitId:r,isActive:s}),!0),MOCK_USER_GRADE_UNITS_NAV=getUserGradeUnitsNav(MOCK_USER_DATA.id,courseData.id),MOCK_USER_GRADE_UNITS_PROGRESS={userId:MOCK_USER_DATA.id,courseId:courseData.id,courseTitle:courseData.title,courseLevel:courseData.level,totalUnits:courseData.units.length,completedUnits:3,overallProgress:45,status:"in-progress",lastAccessed:"2024-01-15T10:30:00Z",units:[{unitId:"unit_1",title:"小数乘法",description:"学习小数乘法的计算方法及应用",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"3周",totalLessons:10,completedLessons:8,progressPercentage:80,status:"completed",lastAccessed:"2024-01-10T14:20:00Z",isActive:!1,route:"/math/grade-5/unit/unit_1",icon:"🔢"},{unitId:"unit_2",title:"小数除法",description:"学习小数除法的计算方法及应用",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"3周",totalLessons:12,completedLessons:6,progressPercentage:50,status:"in-progress",lastAccessed:"2024-01-15T10:30:00Z",isActive:!0,route:"/math/grade-5/unit/unit_2",icon:"➗"},{unitId:"unit_3",title:"简易方程",description:"学习用字母表示数和解简易方程",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"4周",totalLessons:14,completedLessons:2,progressPercentage:14,status:"in-progress",lastAccessed:"2024-01-12T16:45:00Z",isActive:!1,route:"/math/grade-5/unit/unit_3",icon:"📝"},{unitId:"unit_4",title:"多边形的面积",description:"学习平行四边形、三角形、梯形和组合图形的面积计算",moduleCategory:"Graphics and Geometry",estimatedDuration:"3周",totalLessons:12,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_4",icon:"📐"},{unitId:"unit_5",title:"因数与倍数",description:"学习因数、倍数、质数、合数等概念",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"3周",totalLessons:10,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_5",icon:"🔢"},{unitId:"unit_6",title:"长方体和正方体",description:"学习长方体和正方体的特征、表面积和体积计算",moduleCategory:"Graphics and Geometry",estimatedDuration:"4周",totalLessons:14,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_6",icon:"📦"},{unitId:"unit_7",title:"分数的意义和性质",description:"学习分数的意义、性质和约分、通分等方法",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"4周",totalLessons:16,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_7",icon:"½"},{unitId:"unit_8",title:"分数的加法和减法",description:"学习同分母分数、异分母分数的加法和减法",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"3周",totalLessons:12,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_8",icon:"➕"},{unitId:"unit_9",title:"折线统计图",description:"学习单式折线统计图和复式折线统计图的认识和制作",moduleCategory:"Probability and Statistics",estimatedDuration:"2周",totalLessons:6,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_9",icon:"📊"}]},katex_min=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.AbilityAssessmentDashboard=AbilityAssessmentDashboard,exports.AbilityProgressBar=AbilityProgressBar,exports.Button=Button,exports.ContentAccordion=ContentAccordion,exports.GEOMETRY_CONFIG=GEOMETRY_CONFIG,exports.GradeUnitBrowserPage=GradeUnitBrowserPage,exports.GradeUnitBrowserProvider=GradeUnitBrowserProvider,exports.GraphContainer=GraphContainer,exports.MOCK_USER_COURSE_PROGRESS=MOCK_USER_COURSE_PROGRESS,exports.MOCK_USER_GRADE_UNITS_NAV=MOCK_USER_GRADE_UNITS_NAV,exports.MOCK_USER_GRADE_UNITS_PROGRESS=MOCK_USER_GRADE_UNITS_PROGRESS,exports.MathCard=MathCard,exports.MathGraph=MathGraph,exports.MathSessionContainer=MathSessionContainer,exports.MathSessionPage=MathSessionPage$1,exports.MathWizHeader=MathWizHeader$1,exports.PersonalizedAdvicePanel=PersonalizedAdvicePanel,exports.RadarChart=RadarChart,exports.RecommendationCard=RecommendationCard,exports.Sidebar=Sidebar,exports.Submenu=Submenu,exports.UserProfile=UserProfile,exports.calculateBoundingBox=calculateBoundingBox,exports.calculateGamePoints=calculateGamePoints,exports.categoryIcons=categoryIcons,exports.comparePointArrays=comparePointArrays,exports.courseData=courseData,exports.exploreItems=exploreItems,exports.generateMockUserCourseProgress=generateMockUserCourseProgress,exports.getBasicGemDefinitions=getBasicGemDefinitions,exports.getBasicLineDefinitions=getBasicLineDefinitions,exports.getUnitNavItem=getUnitNavItem,exports.getUserCourseProgress=getUserCourseProgress,exports.getUserGradeUnitsNav=getUserGradeUnitsNav,exports.getUserLessonProgress=getUserLessonProgress,exports.getUserUnitProgress=getUserUnitProgress,exports.isPointInTriangle=isPointInTriangle,exports.pointOnLine=pointOnLine,exports.statusColors=statusColors,exports.statusMapping=statusMapping,exports.toPixelCoordinates=toPixelCoordinates,exports.trianglesMatch=trianglesMatch,exports.updateUnitActiveStatus=updateUnitActiveStatus,exports.updateUserLessonProgress=updateUserLessonProgress,exports.useGeometryManagement=useGeometryManagement,exports.useGradeUnitBrowser=useGradeUnitBrowser,exports.useSessionCalculations=useSessionCalculations,exports.useSessionEventHandlers=useSessionEventHandlers,exports.useSessionStore=useSessionStore,exports.userData=userData,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})}));
|
|
731
|
+
`);const x=v.state[l];if(x==null)return;JSON.stringify(n.getState())!==JSON.stringify(x)&&p(x);return}n.dispatchFromDevtools&&typeof n.dispatch=="function"&&n.dispatch(v)});case"DISPATCH":switch(g.payload.type){case"RESET":return p(m),l===void 0?u?.init(n.getState()):u?.init(getTrackedConnectionState(h.name));case"COMMIT":if(l===void 0){u?.init(n.getState());return}return u?.init(getTrackedConnectionState(h.name));case"ROLLBACK":return parseJsonThen(g.state,v=>{if(l===void 0){p(v),u?.init(n.getState());return}p(v[l]),u?.init(getTrackedConnectionState(h.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return parseJsonThen(g.state,v=>{if(l===void 0){p(v);return}JSON.stringify(n.getState())!==JSON.stringify(v[l])&&p(v[l])});case"IMPORT_STATE":{const{nextLiftedState:v}=g.payload,x=(b=v.computedStates.slice(-1)[0])==null?void 0:b.state;if(!x)return;p(l===void 0?x:x[l]),u?.send(null,v);return}case"PAUSE_RECORDING":return f=!f}return}}),m},devtools=devtoolsImpl,parseJsonThen=(e,t)=>{let r;try{r=JSON.parse(e)}catch(s){console.error("[zustand devtools middleware] Could not parse the received json",s)}r!==void 0&&t(r)},API_BASE_URL="/api/v1/content",MOCK_JWT_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c2VyLTAwMSIsIm5hbWUiOiLlsI_mmI4iLCJsZXZlbCI6NSwiYXZhdGFyIjoiaHR0cHM6Ly9pLnByYXZhdGFyLmNjLzQwP3U9c3R1ZGVudDEiLCJiYWRnZXMiOlsi8J-SoiIsIvCfjZUiLCLwn5KbIl0sImlhdCI6MTY5MTYwMDAwMCwiZXhwIjoxNzIzMTM2MDAwfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",DEFAULT_QUESTION_COUNT=10,INITIAL_SCENE="question",useSessionStore=create()(devtools((e,t)=>({sessionId:null,problems:[],totalProblems:0,currentProblemIndex:0,currentScene:"question",userAnswers:{},submissionResults:{},geometryShapes:{},selectedShapeId:null,geometryMode:"view",loading:!1,error:null,timeSpent:0,startTime:null,sessionComplete:!1,loadQuestions:async(r,s)=>{e({loading:!0,sessionId:r});try{const{gradeLevel:n,unitId:o,lessonId:a,count:l=DEFAULT_QUESTION_COUNT}=s,h=`${API_BASE_URL}/grades/${n}/units/${o}/lessons/${a}/sessions/${r}/questions`,c=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${MOCK_JWT_TOKEN}`},body:JSON.stringify({count:l})});if(!c.ok)throw new Error(`Failed to load questions: ${c.status} ${c.statusText}`);const d=(await c.json()).questions||[],f={};d.forEach(p=>{p.geometryShapes&&Array.isArray(p.geometryShapes)&&(f[p.problemId]=p.geometryShapes)}),e({problems:d,totalProblems:d.length,currentProblemIndex:0,currentScene:INITIAL_SCENE,geometryShapes:f,loading:!1,error:null,startTime:Date.now()})}catch(n){const o=n instanceof Error?n.message:"Unknown error occurred";throw e({error:o,loading:!1}),n}},goToNextProblem:()=>{const{currentProblemIndex:r,problems:s,currentScene:n}=t();if(n!==INITIAL_SCENE){console.warn("Cannot navigate during review/solve scene");return}r<s.length-1?e({currentProblemIndex:r+1,currentScene:INITIAL_SCENE}):e({sessionComplete:!0})},goToPreviousProblem:()=>{const{currentProblemIndex:r,currentScene:s}=t();s===INITIAL_SCENE&&r>0&&e({currentProblemIndex:r-1,currentScene:INITIAL_SCENE})},goToProblem:r=>{const{problems:s,currentScene:n}=t();n===INITIAL_SCENE&&(r<0||r>=s.length||e({currentProblemIndex:r,currentScene:INITIAL_SCENE}))},switchScene:r=>{e({currentScene:r})},submitAnswer:async(r,s)=>{const{problems:n,currentProblemIndex:o}=t(),a=n[o];e({loading:!0});try{const l=a?.answer.correctAnswer||[],h=s.length>0&&s[0]===l[0],c={userAnswer:s,isCorrect:h,feedback:h?"🎉 Great job! Your answer is correct!":"❌ Sorry, that's not correct."};e(u=>({userAnswers:{...u.userAnswers,[r]:s},submissionResults:{...u.submissionResults,[r]:c},loading:!1,currentScene:h?"review":"solve"}))}catch(l){e({error:l instanceof Error?l.message:"Submission error",loading:!1})}},updateUserAnswer:(r,s)=>{e(n=>({userAnswers:{...n.userAnswers,[r]:s}}))},updateShape:(r,s,n)=>{e(o=>{const l=(o.geometryShapes[r]||[]).map(h=>h.id===s&&h.type==="point"?{...h,position:n}:h);return{geometryShapes:{...o.geometryShapes,[r]:l}}})},selectShape:(r,s)=>{e({selectedShapeId:s})},setGeometryMode:(r,s)=>{e({geometryMode:s})},startTimer:()=>{e({startTime:Date.now()})},stopTimer:()=>{const{startTime:r}=t();if(r){const s=Math.floor((Date.now()-r)/1e3);e(n=>({timeSpent:n.timeSpent+s,startTime:null}))}},reset:()=>{e({sessionId:null,problems:[],totalProblems:0,currentProblemIndex:0,currentScene:INITIAL_SCENE,userAnswers:{},submissionResults:{},geometryShapes:{},selectedShapeId:null,geometryMode:"view",loading:!1,error:null,timeSpent:0,startTime:null,sessionComplete:!1})},getCurrentProblem:()=>{const{problems:r,currentProblemIndex:s}=t();return r[s]||null},getProgress:()=>{const{currentProblemIndex:r,totalProblems:s}=t();return{current:r+1,total:s,percentage:s>0?(r+1)/s*100:0}},getSessionResults:()=>{const{sessionId:r,problems:s,submissionResults:n,timeSpent:o}=t(),a=s.map(h=>({problemId:h.problemId,userAnswer:n[h.problemId]?.userAnswer||[],isCorrect:n[h.problemId]?.isCorrect||!1,timeSpent:0})),l=a.filter(h=>h.isCorrect).length;return{sessionId:r||"",totalProblems:s.length,correctAnswers:l,accuracy:s.length>0?l/s.length:0,timeSpent:o,averageTime:s.length>0?o/s.length:0,answers:a}}}),{name:"MathSessionStore"})),useSessionCalculations=(e,t,r,s,n,o,a)=>{const l=React.useMemo(()=>r==="question",[r]),h=React.useMemo(()=>e<t.length-1,[e,t.length]),c=React.useMemo(()=>e>0,[e]),u=React.useMemo(()=>!s||!n?!1:s.problemType?.includes("geometry")||o&&o[n]&&o[n].length>0?!0:a?.enableMathGraph!==void 0?a.enableMathGraph:!1,[s,n,o,a?.enableMathGraph]);return{canNavigate:l,canGoNext:h,canGoPrevious:c,shouldRenderMathGraph:u}},useGeometryManagement=(e,t,r,s,n)=>{const o=useSessionStore(u=>u.selectShape),a=useSessionStore(u=>u.setGeometryMode),l=React.useMemo(()=>t?s[t]||[]:[],[s,t]);React.useEffect(()=>{if(!t||!r)return;let u="view";switch(e){case"question":u="edit";break;case"solve":case"review":u="view";break;default:u="view"}n!==u&&a(t,u)},[e,t,n,a,r]);const h=React.useCallback(u=>{t&&useSessionStore.setState(d=>({geometryShapes:{...d.geometryShapes,[t]:u}}))},[t]),c=React.useCallback(u=>{if(t){const d=u.length>0?u[0]:null;o(t,d)}},[t,o]);return{currentGeometryShapes:l,geometryMode:n,handleShapeChange:h,handleSelectionChange:c}},useSessionEventHandlers=(e,t,r)=>{const s=useSessionStore(p=>p.updateUserAnswer),n=useSessionStore(p=>p.submitAnswer),o=useSessionStore(p=>p.goToNextProblem),a=useSessionStore(p=>p.goToPreviousProblem),l=useSessionStore(p=>p.goToProblem),h=React.useCallback(p=>{e&&s(e,p)},[e,s]),c=React.useCallback(()=>{e&&r[e]&&n(e,r[e])},[e,r,n]),u=React.useCallback(p=>{o(),p?.(e,t+1)},[o,e,t]),d=React.useCallback(p=>{a(),p?.(e,t-1)},[a,e,t]),f=React.useCallback((p,m)=>{l(p-1),m?.(e,p-1)},[l,e]);return{handleAnswerChange:h,handleSubmit:c,handleNext:u,handlePrevious:d,handlePagination:f}},MathSessionContainer=({config:e={},onSessionComplete:t,onSessionExit:r,onProblemChange:s,className:n="",style:o})=>{const a=useSessionStore(R=>R.problems),l=useSessionStore(R=>R.currentProblemIndex),h=useSessionStore(R=>R.currentScene),c=useSessionStore(R=>R.loading),u=useSessionStore(R=>R.error),d=useSessionStore(R=>R.sessionComplete),f=useSessionStore(R=>R.submissionResults),p=useSessionStore(R=>R.userAnswers),m=useSessionStore(R=>R.geometryShapes),g=useSessionStore(R=>R.geometryMode),b=useSessionStore(R=>R.getSessionResults),v=React.useMemo(()=>a[l]??null,[a,l]),x=React.useMemo(()=>v?.problemId??"",[v]),{canNavigate:C,canGoNext:_,canGoPrevious:y,shouldRenderMathGraph:w}=useSessionCalculations(l,a,h,v,x,m,e),{currentGeometryShapes:X,handleShapeChange:M,handleSelectionChange:G}=useGeometryManagement(h,x,w,m,g),{handleAnswerChange:E,handleSubmit:P,handleNext:$,handlePrevious:k,handlePagination:A}=useSessionEventHandlers(x,l,p);React.useEffect(()=>{if(d&&typeof b=="function"){const R=b();t?.(R)}},[d,b,t]);const I=R=>typeof R=="string"?R:R instanceof Error?R.message:String(R);return c&&a.length===0?jsxRuntimeExports.jsx("div",{className:"flex items-center justify-center p-12","data-testid":"math-session-loading",children:jsxRuntimeExports.jsxs("div",{className:"text-center",children:[jsxRuntimeExports.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),jsxRuntimeExports.jsx("p",{className:"text-gray-600",children:"Loading questions..."})]})}):u&&u!==null?jsxRuntimeExports.jsx("div",{className:"flex items-center justify-center p-12","data-testid":"math-session-error",children:jsxRuntimeExports.jsxs("div",{className:"text-center text-red-600",children:[jsxRuntimeExports.jsx("p",{className:"text-lg font-semibold mb-2",children:"Error"}),jsxRuntimeExports.jsx("p",{children:I(u)})]})}):v?jsxRuntimeExports.jsxs("div",{className:`flex flex-col max-w-4xl mx-auto p-6 ${n}`,style:o,"data-testid":"math-session-container",role:"region","aria-label":"数学练习会话",children:[jsxRuntimeExports.jsx("div",{className:"mb-6",children:jsxRuntimeExports.jsx(react.Pagination,{total:a.length,page:l+1,onChange:R=>A(R,s),isDisabled:!C,showControls:!1,color:"primary",size:"lg",className:"justify-center"})}),jsxRuntimeExports.jsx(MathCard,{problemData:v,scene:h,submissionResult:f[x],loading:c,error:u?I(u):void 0,value:p[x],onAnswerChange:E,onSubmit:P,onNext:()=>$(s),config:{theme:e.theme??"light",submitButtonText:"提交答案",nextButtonText:h==="solve"?"Got it!":"下一题",showHints:e.enableHints}}),w&&jsxRuntimeExports.jsx("div",{className:"mt-4 w-full max-w-4xl mx-auto","data-testid":"mathgraph-container",children:jsxRuntimeExports.jsx(MathGraph,{shapes:X,mode:g,onShapeChange:M,onSelectionChange:G,showGrid:!0,showAxis:!0,width:800,height:500,boundingBoxOptions:{padding:.5,margin:2,minSize:8}})}),e.showProgress&&jsxRuntimeExports.jsxs("div",{className:"mt-6 flex justify-between items-center",children:[jsxRuntimeExports.jsx("button",{onClick:()=>k(s),disabled:!y,className:"px-4 py-2 text-sm border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"上一题"}),jsxRuntimeExports.jsxs("div",{className:"text-sm text-gray-600",children:[l+1," / ",a.length]}),jsxRuntimeExports.jsx("button",{onClick:()=>$(s),disabled:!_||!C,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"下一题"})]}),r&&jsxRuntimeExports.jsx("div",{className:"mt-4 flex justify-center",children:jsxRuntimeExports.jsx("button",{onClick:r,className:"px-4 py-2 text-sm text-gray-600 hover:text-gray-900 transition-colors",children:"退出练习"})})]}):jsxRuntimeExports.jsx("div",{className:"flex items-center justify-center p-12","data-testid":"math-session-empty",children:jsxRuntimeExports.jsx("p",{className:"text-gray-600",children:"No problems available"})})},MathSessionPage=({sessionId:e,gradeId:t,unitId:r,lessonId:s,userId:n,config:o={},className:a="",onSessionComplete:l,onSessionExit:h})=>{const[c,u]=React.useState({loading:!1,error:null,initialized:!1}),[d,f]=React.useState(0),[p,m]=React.useState(""),g=React.useRef(null),b=React.useRef(null),v=React.useRef(null),x=useSessionStore(M=>M.loadQuestions),C=useSessionStore(M=>M.reset);React.useEffect(()=>{const M=async()=>{try{u(G=>({...G,loading:!0,error:null})),console.log("🎯 MathSessionPage: 开始初始化会话",{sessionId:e,gradeId:t,unitId:r,lessonId:s,userId:n}),await x(e,{gradeLevel:parseInt(t.replace("g",""))||5,unitId:r,lessonId:s,count:o.questionCount||10}),u(G=>({...G,loading:!1,initialized:!0})),console.log("✅ MathSessionPage: 会话初始化完成")}catch(G){const E=G instanceof Error?G.message:"Failed to initialize session";u(P=>({...P,loading:!1,error:E,initialized:!1})),console.error("❌ MathSessionPage: 会话初始化失败",G)}};e&&t&&r&&s&&!c.initialized&&M()},[e,t,r,s,x,o.questionCount,c.initialized,d]),React.useEffect(()=>{c.loading&&!c.initialized?m("正在加载数学练习内容,请稍候..."):c.error?m(`加载失败:${c.error},请点击重试按钮重新加载`):c.initialized&&m("数学练习内容已加载完成,可以开始练习")},[c.loading,c.error,c.initialized]),React.useEffect(()=>{c.initialized&&g.current&&g.current.focus()},[c.initialized]),React.useEffect(()=>{c.error&&v.current&&v.current.focus()},[c.error]),React.useEffect(()=>{c.loading&&b.current&&b.current.focus()},[c.loading]),React.useEffect(()=>()=>{console.log("🧹 MathSessionPage: 清理会话状态"),C()},[C]);const _=React.useCallback(M=>{console.log("🎉 MathSessionPage: 会话完成",M),l?.(M)},[l]),y=React.useCallback(()=>{console.log("🚪 MathSessionPage: 退出会话"),h?.()},[h]),w=React.useCallback((M,G)=>{console.log(`📝 MathSessionPage: 切换到题目 ${G+1}`,M)},[]),X=React.useCallback(M=>{M.key==="Escape"&&(M.preventDefault(),y()),M.key==="Enter"&&c.error&&M.target===v.current&&(M.preventDefault(),u({loading:!1,error:null,initialized:!1}),f(G=>G+1))},[y,c.error]);return c.loading&&!c.initialized?jsxRuntimeExports.jsxs("div",{className:`math-session-page loading ${a}`,"data-testid":"math-session-page",role:"main","aria-label":"数学练习页面",onKeyDown:X,tabIndex:-1,ref:b,children:[jsxRuntimeExports.jsx("div",{"aria-live":"assertive","aria-atomic":"true",className:"sr-only",children:p}),jsxRuntimeExports.jsx("div",{className:"page-loading-container",children:jsxRuntimeExports.jsxs("div",{className:"loading-spinner","data-testid":"page-loading-spinner",role:"status","aria-label":"正在加载练习内容",children:[jsxRuntimeExports.jsx("div",{className:"spinner","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:"loading-text",children:"正在加载练习内容..."})]})})]}):c.error?jsxRuntimeExports.jsxs("div",{className:`math-session-page error ${a}`,"data-testid":"math-session-page",role:"main","aria-label":"数学练习页面 - 错误状态",onKeyDown:X,tabIndex:-1,ref:v,children:[jsxRuntimeExports.jsx("div",{"aria-live":"assertive","aria-atomic":"true",className:"sr-only",children:p}),jsxRuntimeExports.jsxs("div",{className:"error-container",children:[jsxRuntimeExports.jsx("div",{className:"error-icon",role:"img","aria-label":"警告图标",children:"⚠️"}),jsxRuntimeExports.jsx("h3",{className:"error-title",children:"加载失败"}),jsxRuntimeExports.jsx("p",{className:"error-message",children:c.error}),jsxRuntimeExports.jsx("button",{onClick:()=>{u({loading:!1,error:null,initialized:!1}),f(M=>M+1)},className:"retry-button","data-testid":"retry-button","aria-label":"重新加载练习内容",children:"重试"})]})]}):jsxRuntimeExports.jsxs("div",{className:`math-session-page ${a}`,"data-testid":"math-session-page",role:"main","aria-label":"数学练习页面",onKeyDown:X,children:[jsxRuntimeExports.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:p}),o.layout?.showHeader&&jsxRuntimeExports.jsx("header",{className:"page-header",role:"banner",children:jsxRuntimeExports.jsxs("div",{className:"header-content",children:[jsxRuntimeExports.jsx("h1",{className:"page-title",children:"数学练习"}),jsxRuntimeExports.jsxs("div",{className:"session-info","aria-label":"会话信息",children:[jsxRuntimeExports.jsxs("span",{className:"session-id",children:["会话: ",e]}),jsxRuntimeExports.jsxs("span",{className:"grade-info",children:["年级: ",t]})]})]})}),jsxRuntimeExports.jsx("main",{className:"page-main",ref:g,tabIndex:-1,"aria-label":"数学练习主要内容区域",children:jsxRuntimeExports.jsx(MathSessionContainer,{config:{showProgress:o.showProgress??!0,enableHints:o.enableHints??!1,autoAdvance:o.autoAdvance??!1,theme:o.theme??"light"},onSessionComplete:_,onSessionExit:y,onProblemChange:w})}),o.layout?.showFooter&&jsxRuntimeExports.jsx("footer",{className:"page-footer",role:"contentinfo",children:jsxRuntimeExports.jsx("div",{className:"footer-content",children:jsxRuntimeExports.jsx("p",{className:"footer-text",children:"© 2024 MathWiz - 小学数学益智教育平台"})})})]})},MathSessionPage$1=React.memo(MathSessionPage),pointOnLine=(e,t,r)=>({x:e.x+(t.x-e.x)*r,y:e.y+(t.y-e.y)*r}),calculateGamePoints=()=>{const e={x:.5,y:.1,name:"A"},t={x:.1,y:.75,name:"B"},r={x:.9,y:.75,name:"C"},s={...pointOnLine(e,t,1/3),name:"D"},n={...pointOnLine(e,r,1/3),name:"E"},o={...pointOnLine(e,t,2/3),name:"M"},a={...pointOnLine(e,r,2/3),name:"N"},l={...pointOnLine(t,r,1/3),name:"P"},h={...pointOnLine(t,r,2/3),name:"Q"},c={...pointOnLine(s,n,1/3),name:"U"},u={...pointOnLine(s,n,2/3),name:"S"},d={...pointOnLine(o,a,1/3),name:"K"},f={...pointOnLine(o,a,2/3),name:"L"};return{A:e,B:t,C:r,D:s,E:n,M:o,N:a,P:l,Q:h,U:c,S:u,K:d,L:f}},toPixelCoordinates=(e,t,r)=>{const s={};for(const[n,o]of Object.entries(e))s[n]={...o,x:o.x*t,y:o.y*r};return s},isPointInTriangle=(e,t)=>{const[r,s,n]=t,{x:o,y:a}=e,l=(s.y-n.y)*(r.x-n.x)+(n.x-s.x)*(r.y-n.y);if(Math.abs(l)<1e-4)return!1;const h=((s.y-n.y)*(o-n.x)+(n.x-s.x)*(a-n.y))/l,c=((n.y-r.y)*(o-n.x)+(r.x-n.x)*(a-n.y))/l,u=1-h-c;return h>=-.001&&c>=-.001&&u>=-.001},trianglesMatch=(e,t)=>{if(!e||!t||e.length!==3||t.length!==3)return!1;const r=e.map(n=>n.name).sort(),s=t.map(n=>n.name).sort();return r.every((n,o)=>n===s[o])},comparePointArrays=(e,t)=>{if(!e||!t||e.length!==t.length)return!1;const r=e.map(n=>n.name).sort(),s=t.map(n=>n.name).sort();return r.join("")===s.join("")},getBasicLineDefinitions=()=>[{from:"A",to:"B"},{from:"A",to:"C"},{from:"B",to:"C"},{from:"D",to:"E"},{from:"M",to:"N"},{from:"P",to:"Q"},{from:"A",to:"D"},{from:"A",to:"E"},{from:"A",to:"M"},{from:"A",to:"N"},{from:"A",to:"P"},{from:"A",to:"Q"},{from:"D",to:"U"},{from:"U",to:"S"},{from:"S",to:"E"},{from:"M",to:"K"},{from:"K",to:"L"},{from:"L",to:"N"},{from:"B",to:"P"},{from:"P",to:"Q"},{from:"Q",to:"C"}],getBasicGemDefinitions=()=>[{id:"gem_1",vertices:["A","B","P"],points:10,category:"basic"},{id:"gem_2",vertices:["A","P","Q"],points:10,category:"basic"},{id:"gem_3",vertices:["A","Q","C"],points:10,category:"basic"},{id:"gem_4",vertices:["A","B","Q"],points:15,category:"medium"},{id:"gem_5",vertices:["A","P","C"],points:15,category:"medium"},{id:"gem_6",vertices:["A","B","C"],points:20,category:"large"},{id:"gem_7",vertices:["A","D","U"],points:12,category:"ade_small"},{id:"gem_8",vertices:["A","U","S"],points:12,category:"ade_small"},{id:"gem_9",vertices:["A","S","E"],points:12,category:"ade_small"},{id:"gem_10",vertices:["A","D","S"],points:18,category:"ade_medium"},{id:"gem_11",vertices:["A","U","E"],points:18,category:"ade_medium"},{id:"gem_12",vertices:["A","D","E"],points:25,category:"ade_large"},{id:"gem_13",vertices:["A","M","K"],points:14,category:"amn_small"},{id:"gem_14",vertices:["A","K","L"],points:14,category:"amn_small"},{id:"gem_15",vertices:["A","L","N"],points:14,category:"amn_small"},{id:"gem_16",vertices:["A","M","L"],points:20,category:"amn_medium"},{id:"gem_17",vertices:["A","K","N"],points:20,category:"amn_medium"},{id:"gem_18",vertices:["A","M","N"],points:30,category:"amn_large"}],GEOMETRY_CONFIG={TOTAL_GEMS:18,CANVAS_RATIO:4/3,DEFAULT_VIEWBOX:{width:700,height:600},POINT_RADIUS:{default:6,selected:9},TOLERANCE:.001,MIN_TRIANGLE_AREA:.001,COORDINATE_PRECISION:1e-4,BARYCENTRIC_TOLERANCE:-.001},generateMockUserCourseProgress=(e=MOCK_USER_DATA.id)=>{const t=courseData.units.map((n,o)=>{const a=Math.min(100,Math.max(0,o*15+Math.random()*20)),l=Math.floor(n.lessons.length*a/100),h=n.lessons.map((c,u)=>{const d=Math.min(100,Math.max(0,a-u*10+Math.random()*30));return{lessonId:c.id,status:d>=100?"completed":d>0?"in-progress":"not-started",progressPercentage:Math.round(d),lastAccessed:d>0?new Date(Date.now()-Math.random()*7*24*60*60*1e3).toISOString():void 0,timeSpent:d>0?Math.floor(Math.random()*120+10):void 0,score:d>=100?Math.floor(Math.random()*21+80):void 0,attempts:d>0?Math.floor(Math.random()*3+1):void 0}});return{unitId:n.id,userId:e,totalLessons:n.lessons.length,completedLessons:l,progressPercentage:Math.round(a),status:a>=100?"completed":a>0?"in-progress":"not-started",lastAccessed:a>0?new Date(Date.now()-Math.random()*14*24*60*60*1e3).toISOString():void 0,lessons:h}}),r=t.reduce((n,o)=>n+o.progressPercentage,0)/t.length,s=t.filter(n=>n.status==="completed").length;return{courseId:courseData.id,userId:e,totalUnits:t.length,completedUnits:s,progressPercentage:Math.round(r),status:r>=100?"completed":r>0?"in-progress":"not-started",lastAccessed:new Date(Date.now()-Math.random()*3*24*60*60*1e3).toISOString(),units:t}},MOCK_USER_COURSE_PROGRESS=generateMockUserCourseProgress(),getUserCourseProgress=(e,t)=>e===MOCK_USER_DATA.id&&t===courseData.id?MOCK_USER_COURSE_PROGRESS:null,getUserUnitProgress=(e,t,r)=>{const s=getUserCourseProgress(e,t);return s&&s.units.find(n=>n.unitId===r)||null},getUserLessonProgress=(e,t,r,s)=>{const n=getUserUnitProgress(e,t,r);return n&&n.lessons.find(o=>o.lessonId===s)||null},updateUserLessonProgress=(e,t,r,s,n)=>(console.log("Updating lesson progress:",{userId:e,courseId:t,unitId:r,lessonId:s,progress:n}),!0),getUserGradeUnitsNav=(e,t)=>{const r=getUserCourseProgress(e,t);if(!r)return null;const s=courseData.units.map((n,o)=>{const a=r.units.find(l=>l.unitId===n.id);return{unitId:n.id,title:n.title,description:n.description,moduleCategory:n.moduleCategory,estimatedDuration:n.estimatedDuration,totalLessons:n.lessons.length,completedLessons:a?.completedLessons||0,progressPercentage:a?.progressPercentage||0,status:a?.status||"not-started",lastAccessed:a?.lastAccessed,isActive:o===0,route:`/math/grade-${courseData.level}/unit/${n.id}`}});return{userId:e,courseId:courseData.id,courseTitle:courseData.title,courseLevel:courseData.level,totalUnits:s.length,completedUnits:s.filter(n=>n.status==="completed").length,overallProgress:r.progressPercentage,status:r.status,lastAccessed:r.lastAccessed,units:s}},getUnitNavItem=(e,t,r)=>{const s=getUserGradeUnitsNav(e,t);return s&&s.units.find(n=>n.unitId===r)||null},updateUnitActiveStatus=(e,t,r,s)=>(console.log("Updating unit active status:",{userId:e,courseId:t,unitId:r,isActive:s}),!0),MOCK_USER_GRADE_UNITS_NAV=getUserGradeUnitsNav(MOCK_USER_DATA.id,courseData.id),MOCK_USER_GRADE_UNITS_PROGRESS={userId:MOCK_USER_DATA.id,courseId:courseData.id,courseTitle:courseData.title,courseLevel:courseData.level,totalUnits:courseData.units.length,completedUnits:3,overallProgress:45,status:"in-progress",lastAccessed:"2024-01-15T10:30:00Z",units:[{unitId:"unit_1",title:"小数乘法",description:"学习小数乘法的计算方法及应用",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"3周",totalLessons:10,completedLessons:8,progressPercentage:80,status:"completed",lastAccessed:"2024-01-10T14:20:00Z",isActive:!1,route:"/math/grade-5/unit/unit_1",icon:"🔢"},{unitId:"unit_2",title:"小数除法",description:"学习小数除法的计算方法及应用",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"3周",totalLessons:12,completedLessons:6,progressPercentage:50,status:"in-progress",lastAccessed:"2024-01-15T10:30:00Z",isActive:!0,route:"/math/grade-5/unit/unit_2",icon:"➗"},{unitId:"unit_3",title:"简易方程",description:"学习用字母表示数和解简易方程",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"4周",totalLessons:14,completedLessons:2,progressPercentage:14,status:"in-progress",lastAccessed:"2024-01-12T16:45:00Z",isActive:!1,route:"/math/grade-5/unit/unit_3",icon:"📝"},{unitId:"unit_4",title:"多边形的面积",description:"学习平行四边形、三角形、梯形和组合图形的面积计算",moduleCategory:"Graphics and Geometry",estimatedDuration:"3周",totalLessons:12,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_4",icon:"📐"},{unitId:"unit_5",title:"因数与倍数",description:"学习因数、倍数、质数、合数等概念",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"3周",totalLessons:10,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_5",icon:"🔢"},{unitId:"unit_6",title:"长方体和正方体",description:"学习长方体和正方体的特征、表面积和体积计算",moduleCategory:"Graphics and Geometry",estimatedDuration:"4周",totalLessons:14,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_6",icon:"📦"},{unitId:"unit_7",title:"分数的意义和性质",description:"学习分数的意义、性质和约分、通分等方法",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"4周",totalLessons:16,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_7",icon:"½"},{unitId:"unit_8",title:"分数的加法和减法",description:"学习同分母分数、异分母分数的加法和减法",moduleCategory:"Arithmetic and Algebra",estimatedDuration:"3周",totalLessons:12,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_8",icon:"➕"},{unitId:"unit_9",title:"折线统计图",description:"学习单式折线统计图和复式折线统计图的认识和制作",moduleCategory:"Probability and Statistics",estimatedDuration:"2周",totalLessons:6,completedLessons:0,progressPercentage:0,status:"not-started",isActive:!1,route:"/math/grade-5/unit/unit_9",icon:"📊"}]},katex_min=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.AbilityAssessmentDashboard=AbilityAssessmentDashboard,exports.AbilityProgressBar=AbilityProgressBar,exports.Button=Button,exports.ContentAccordion=ContentAccordion,exports.GEOMETRY_CONFIG=GEOMETRY_CONFIG,exports.GradeUnitBrowserPage=GradeUnitBrowserPage,exports.GradeUnitBrowserProvider=GradeUnitBrowserProvider,exports.GraphContainer=GraphContainer,exports.MOCK_USER_COURSE_PROGRESS=MOCK_USER_COURSE_PROGRESS,exports.MOCK_USER_GRADE_UNITS_NAV=MOCK_USER_GRADE_UNITS_NAV,exports.MOCK_USER_GRADE_UNITS_PROGRESS=MOCK_USER_GRADE_UNITS_PROGRESS,exports.MathCard=MathCard,exports.MathGraph=MathGraph,exports.MathSessionContainer=MathSessionContainer,exports.MathSessionPage=MathSessionPage$1,exports.MathWizHeader=MathWizHeader$1,exports.PersonalizedAdvicePanel=PersonalizedAdvicePanel,exports.RadarChart=RadarChart,exports.RecommendationCard=RecommendationCard,exports.Sidebar=Sidebar,exports.Submenu=Submenu,exports.UserProfile=UserProfile,exports.calculateBoundingBox=calculateBoundingBox,exports.calculateGamePoints=calculateGamePoints,exports.categoryIcons=categoryIcons,exports.comparePointArrays=comparePointArrays,exports.courseData=courseData,exports.exploreItems=exploreItems,exports.generateMockUserCourseProgress=generateMockUserCourseProgress,exports.getBasicGemDefinitions=getBasicGemDefinitions,exports.getBasicLineDefinitions=getBasicLineDefinitions,exports.getUnitNavItem=getUnitNavItem,exports.getUserCourseProgress=getUserCourseProgress,exports.getUserGradeUnitsNav=getUserGradeUnitsNav,exports.getUserLessonProgress=getUserLessonProgress,exports.getUserUnitProgress=getUserUnitProgress,exports.isPointInTriangle=isPointInTriangle,exports.pointOnLine=pointOnLine,exports.statusColors=statusColors,exports.statusMapping=statusMapping,exports.toPixelCoordinates=toPixelCoordinates,exports.trianglesMatch=trianglesMatch,exports.updateUnitActiveStatus=updateUnitActiveStatus,exports.updateUserLessonProgress=updateUserLessonProgress,exports.useGeometryManagement=useGeometryManagement,exports.useGradeUnitBrowser=useGradeUnitBrowser,exports.useSessionCalculations=useSessionCalculations,exports.useSessionEventHandlers=useSessionEventHandlers,exports.useSessionStore=useSessionStore,exports.userData=userData,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})}));
|
|
732
732
|
//# sourceMappingURL=index.cjs.map
|