pimath 0.0.122 → 0.0.124

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.
@@ -1,2 +1,2 @@
1
- (()=>{"use strict";var e={607:(e,t,i)=>{t.l=void 0;const s=i(956),n=i(394),o=i(505),r=i(330),a=i(506),l=i(872),h=i(937),c=i(38),u=i(760),d=i(554),f=i(107),m=i(236),_=i(586),p=i(9),g=i(164),y=i(699),v=i(557);t.l={ShutingYard:o.Shutingyard,Numeric:s.Numeric,NumExp:n.NumExp,Fraction:a.Fraction,Root:l.NthRoot,Monom:h.Monom,Polynom:c.Polynom,Equation:u.Equation,LinearSystem:d.LinearSystem,Rational:f.Rational,Logicalset:m.Logicalset,Random:r.Random,Geometry:{Vector:_.Vector,Point:v.Point,Line:p.Line,Triangle:g.Triangle,Circle:y.Circle}},window.Pi=t.l},760:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Equation=t.PARTICULAR_SOLUTION=void 0;const s=i(38),n=i(956),o=i(506),r=i(872);var a;!function(e){e.real="\\mathbb{R}",e.varnothing="\\varnothing"}(a||(t.PARTICULAR_SOLUTION=a={}));class l{constructor(...e){if(this._varnothing=a.varnothing,this._real=a.real,this.hasVariable=e=>this.variables.includes(e),this._randomizeDefaults={degree:2},this.parse=e=>{let t,i;if(i=this._findSign(e),!1!==i)return t=e.split(i),this.create(new s.Polynom(t[0]),new s.Polynom(t[1]),this._formatSign(i));console.error("The equation is not valid (no sign found)")},this.create=(e,t,i)=>(this._left=e,this._right=t,this._sign=this._formatSign(i),this),this.clone=()=>(new l).create(this._left.clone(),this._right.clone(),this._sign+""),this.randomize=(e,t)=>(new l).create(new s.Polynom,new s.Polynom,t),this.moveLeft=()=>(this._left=this._left.clone().subtract(this._right),this._right.zero(),this),this.reorder=e=>(this._left.subtract(this._right),this._right.zero(),this._left.reorder(),e||(this._left.monoms.filter((e=>e.degree().isZero())).forEach((e=>{const t=e.clone();this._left.subtract(t),this._right.subtract(t)})),this._left.reorder(),this._right.reorder()),this),this.simplify=()=>(this.multiply(n.Numeric.lcm(...this._left.getDenominators(),...this._right.getDenominators())),this.divide(n.Numeric.gcd(...this._left.getNumerators(),...this._right.getNumerators())),this),this.isolate=e=>{if(!this.degree(e).isOne())return!1;if(this.isMultiVariable())return!1;let t,i;this._left.subtract(this._right),this._right.zero();let s=[...this._left.monoms];for(let i of s)i.hasLetter(e)||(t=i.clone(),this._left.subtract(t),this._right.subtract(t));return 1===this._left.length&&(i=this._left.monoms[0].coefficient.clone(),this._left.divide(i),this._right.divide(i),this)},this.replaceBy=(e,t)=>(this._left.replaceBy(e,t),this._right.replaceBy(e,t),this),this.multiply=e=>{let t=new o.Fraction(e);return this._left.multiply(t),this._right.multiply(t),"="!==this._sign&&-1===t.sign()&&this._reverseSign(),this},this.divide=e=>{let t=new o.Fraction(e);return t.isZero()?this:this.multiply(t.invert())},this.degree=e=>o.Fraction.max(this._left.degree(e),this._right.degree(e)),this.isMultiVariable=()=>this._left.isMultiVariable||this._right.isMultiVariable,this.letters=()=>[...new Set([...this._left.letters(),...this._right.letters()])],this.solve=()=>{switch(this._solutions=[],this._polynom=this._left.clone().subtract(this._right),this._polynom.degree().value){case 0:case 1:this._solveDegree1();break;case 2:this._solveDegree2();break;default:this._solveDegree3plus()}return this._solutions=l.makeSolutionsUnique(this._solutions),this},this.test=e=>this.left.evaluate(e).isEqual(this.right.evaluate(e)),this.isSameAs=e=>{let t=e.clone().moveLeft().left,i=this.clone().moveLeft().left;return t.isEqual(i)||t.isOpposedAt(i)},this.isLinearTo=e=>{let t=e.clone().moveLeft().simplify().left,i=this.clone().moveLeft().simplify().left;return t.isEqual(i)||t.isOpposedAt(i)},this._findSign=e=>e.includes("geq")?e.includes("\\geq")?"\\geq":"geq":e.includes("leq")?e.includes("\\leq")?"\\leq":"leq":e.includes(">=")?">=":e.includes("=>")?"=>":e.includes(">")?">":e.includes("<=")?"<=":e.includes("=<")?"=<":e.includes("<")?"<":e.includes("=")?"=":(console.log("Equation: parse string : sign not found"),!1),this._formatSign=e=>void 0===e?"=":e.includes("geq")||e.includes(">=")||e.includes("=>")?">=":e.includes(">")?">":e.includes("leq")||e.includes("<=")||e.includes("=<")?"<=":e.includes("<")?"<":"=",this._reverseSign=()=>"="===this._sign?this:this._sign.includes("<")?(this._sign.replace("<",">"),this):this._sign.includes(">")?(this._sign.replace(">","<"),this):this,this.isGreater=()=>-1!==this._sign.indexOf(">")||-1!==this._sign.indexOf("geq"),this.isStrictEqual=()=>"="===this._sign,this.isAlsoEqual=()=>-1!==this._sign.indexOf("=")||-1!==this._sign.indexOf("geq")||-1!==this._sign.indexOf("leq")||void 0,this._solveDegree1=e=>{const t=this._polynom.monomByDegree(1,e).coefficient,i=this._polynom.monomByDegree(0,e).coefficient,s=i.clone().opposed().divide(t);let n,o;return this.isStrictEqual()?0===t.value?0===i.value?this._solutions=[{tex:this._real,display:"RR",value:NaN,exact:!1}]:this._solutions=[{tex:this._varnothing,display:"O/",value:NaN,exact:!1}]:this._solutions=[{tex:s.tex,display:s.display,value:s.value,exact:s}]:(0===t.value?0===i.value&&this.isAlsoEqual()?(n="\\mathbb{R}",o="RR"):i.value>0?(n=this.isGreater()?this._real:this._varnothing,n=this.isGreater()?"RR":"O/"):(n=this.isGreater()?this._varnothing:this._real,n=this.isGreater()?"O/":"RR"):this.isGreater()&&1===t.sign()||!this.isGreater()&&-1===t.sign()?(n=`\\left${this.isAlsoEqual()?"[":"]"}${s.tex};+\\infty\\right[`,o=`${this.isAlsoEqual()?"[":"]"}${s.tex};+oo[`):(n=`\\left]-\\infty;${s.tex} \\right${this.isAlsoEqual()?"]":"["}`,o=`]-oo;${s.tex}${this.isAlsoEqual()?"]":"["}`),this._solutions=[{tex:n,display:o,value:NaN,exact:!1}]),this._solutions},this._solveDegree2=e=>{let t,i,s,a,l,h,c=this._polynom.monomByDegree(2,e).coefficient,u=this._polynom.monomByDegree(1,e).coefficient,d=this._polynom.monomByDegree(0,e).coefficient,f=n.Numeric.lcm(c.denominator,u.denominator,d.denominator),m=c.multiply(f).value,_=u.multiply(f).value;if(t=_*_-4*m*d.multiply(f).value,t>0)if(s=(-_-Math.sqrt(t))/(2*m),a=(-_+Math.sqrt(t))/(2*m),t>1e5){let e=((-_-Math.sqrt(t))/(2*m)).toFixed(5),i=((-_+Math.sqrt(t))/(2*m)).toFixed(5);this._solutions=[{tex:e,display:e,value:s,exact:!1},{tex:i,display:i,value:a,exact:!1}]}else if(i=new r.NthRoot(t).reduce(),i.hasRadical()){let e=n.Numeric.gcd(_,2*m,i.coefficient),t=m/e,o=_/e;i.coefficient=i.coefficient/e,m<0&&(t=-t,o=-o);let r="",l="",h="",c="";r=`${0!==o?-o+" - ":""}${i.tex}`,l=`${0!==o?-o+" + ":""}${i.tex}`,h=`${0!==o?-o+" - ":""}${i.display}`,c=`${0!==o?-o+" + ":""}${i.display}`,1!==t&&(r=`\\frac{ ${r} }{ ${2*t} }`,l=`\\frac{ ${l} }{ ${2*t} }`),this._solutions=[{tex:r,display:r,value:s,exact:!1},{tex:l,display:l,value:a,exact:!1}]}else{const e=new o.Fraction(-_-i.coefficient,2*m).reduce(),t=new o.Fraction(-_+i.coefficient,2*m).reduce();this._solutions=[{tex:e.frac,display:e.display,value:s,exact:e},{tex:t.frac,display:t.display,value:a,exact:t}]}else if(0===t){const e=new o.Fraction(-_,2*m).reduce();this._solutions=[{tex:e.frac,display:e.display,value:e.value,exact:e}]}else this._solutions=[{tex:this._varnothing,display:"O/",value:NaN,exact:!1}];return this.isStrictEqual()||(2===this._solutions.length?(l=s<a?this._solutions[0].tex:this._solutions[1].tex,h=s<a?this._solutions[1].tex:this._solutions[0].tex,this.isGreater()&&1===c.sign()||!this.isGreater()&&-1===c.sign()?this._solutions=[{tex:`\\left]-\\infty ; ${l}\\right${this.isAlsoEqual()?"]":"["} \\cup \\left${this.isAlsoEqual()?"[":"]"}${h};+\\infty\\right[`,display:`]-oo;${l}${this.isAlsoEqual()?"]":"["}uu${this.isAlsoEqual()?"[":"]"}${h};+oo[`,value:NaN,exact:!1}]:this._solutions=[{tex:`\\left${this.isAlsoEqual()?"[":"]"}${l} ; ${h}\\right${this.isAlsoEqual()?"]":"["}`,display:`${this.isAlsoEqual()?"[":"]"}${l};${h}${this.isAlsoEqual()?"]":"["}`,value:NaN,exact:!1}]):1===this._solutions.length&&this._solutions[0].tex!==this._varnothing?this.isAlsoEqual()?(this.isGreater()&&1===c.sign()||!this.isGreater()&&-1===c.sign())&&(this._solutions=[{tex:this._real,display:"RR",value:NaN,exact:!1}]):this.isGreater()&&1===c.sign()||!this.isGreater()&&-1===c.sign()?this._solutions=[{tex:`\\left]-\\infty ; ${this._solutions[0].tex}\\right[ \\cup \\left]${this._solutions[0].tex};+\\infty\\right[`,display:`]-oo;${this._solutions[0].tex}[uu]${this._solutions[0].tex};+oo[`,value:NaN,exact:!1}]:this._solutions=[{tex:this._varnothing,display:"O/",value:NaN,exact:!1}]:this.isGreater()?this._solutions=[{tex:1===c.sign()?this._real:this._varnothing,display:1===c.sign()?"RR":"O/",value:NaN,exact:!1}]:this._solutions=[{tex:-1===c.sign()?this._real:this._varnothing,display:-1===c.sign()?"RR":"O/",value:NaN,exact:!1}]),this._solutions},this._solveDegree3plus=e=>{let t=this.clone().moveLeft();return t.left.factorize(),this._solutions=[],t.left.factors.forEach((t=>{if(t.degree(e).leq(2)){let e=new l(t,0);e.solve(),e.solutions.forEach((e=>{this._solutions.push(e)}))}else console.log(t.tex,": cannot actually get the solution of this equation")})),this._solutions},this._left=(new s.Polynom).zero(),this._right=(new s.Polynom).zero(),this._sign="=",1===e.length){if(e[0]instanceof l)return e[0].clone();"string"==typeof e[0]&&this.parse(e[0])}else{if(2!==e.length)return this;e[0]instanceof s.Polynom?this.left=e[0].clone():"string"==typeof e[0]&&(this.left=new s.Polynom(e[0])),e[1]instanceof s.Polynom?this.right=e[1].clone():"string"==typeof e[1]&&(this.right=new s.Polynom(e[1]))}return this}get left(){return this._left}set left(e){this._left=e}get right(){return this._right}set right(e){this._right=e}get sign(){return this._sign}set sign(e){this._sign=this._formatSign(e)}get solutions(){return this._solutions}get isEquation(){return!0}get solution(){return 1!==this._solutions.length||this._solutions[0].tex!==this._real&&this._solutions[0].tex!==this._varnothing&&!this._solutions[0].tex.includes("\\left")?`S = \\left{ ${this._solutions.map((e=>e.tex)).join(";")} \\right}`:`S = ${this._solutions[0]}`}get isReal(){return void 0===this._solutions&&this.solve(),this._solutions[0].tex===this._real}get isVarnothing(){return void 0===this._solutions&&this.solve(),this._solutions[0].tex===this._varnothing}get signAsTex(){return">="===this._sign||"=>"===this._sign||"geq"===this._sign?"\\geq":"<="===this._sign||"=<"===this._sign||"leq"===this._sign?"\\leq":this._sign}get tex(){return`${this._left.tex}${this.signAsTex}${this._right.tex}`}get display(){return`${this._left.display}${this.signAsTex}${this._right.display}`}get raw(){return`${this._left.raw}${this.signAsTex}${this._right.raw}`}get variables(){return[...new Set(this._right.variables.concat(this._left.variables))]}get numberOfVars(){return this.variables.length}get randomizeDefaults(){return this._randomizeDefaults}set randomizeDefaults(e){this._randomizeDefaults=e}static makeSolutionsUnique(e,t){let i=[],s=e.filter((e=>!i.includes(e.tex)&&(i.push(e.tex),!0)));return!0===t&&s.sort(((e,t)=>e.value-t.value)),s}}t.Equation=l},554:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LinearSystem=void 0;const s=i(760),n=i(506),o=i(38),r=i(956);class a{constructor(...e){return this.buildTex=(e,t)=>{let i,s,n=[],o=[];for(let t of e)o=o.concat(t.letters());o=[...new Set(o)],o.sort();for(let r=0;r<e.length;r++){let a=e[r];i=[];for(let e of o)s=a.left.monomByLetter(e),0===i.length?i.push(s.isZero()?"":s.tex):i.push(s.isZero()?"":(1===s.coefficient.sign()?"+":"")+s.tex);if(i.push("="),i.push(a.right.tex),void 0!==t&&void 0!==t[r]){i[i.length-1]=i[i.length-1]+" \\phantom{\\quad}";for(let e of t[r])i.push(`\\ \\cdot\\ ${e.startsWith("-")?"\\left("+e+"\\right)":e}`)}n.push(i.join("&"))}let r=0;return void 0!==t&&t.length>0&&(r=t[0].length),`\\left\\{\\begin{array}{${"r".repeat(o.length)}cl ${"|l".repeat(r)}}${n.join("\\\\ ")}\\end{array}\\right.`},this.stepTex=e=>{const t=this._resolutionSteps[e];if(void 0===t)return"";let i=[];for(let e=0;e<t.length;e++)i.push(this.buildTex(t[e].equations,t[e].operations));return`\\begin{aligned}&${i.join("\\\\&")}\\end{aligned}`},this.parse=(...e)=>(this._equations=e.map((e=>new s.Equation(e))),this._findLetters(),this),this.clone=()=>(new a).parse(...this._equations.map((e=>e.clone()))),this.reorder=()=>{for(let e of this._equations)e.reorder();return this},this.solve=e=>{this._solutions={},this._resolutionSteps={},this.reorder(),void 0===e&&(e=!1);for(let t of this.variables)this._solutions[t]=this._solveOneLetter(t,e);return this},this.mergeEquations=(e,t,i,s)=>{let o=e.clone().multiply(new n.Fraction(i)),r=t.clone().multiply(new n.Fraction(s));return o.left.add(r.left),o.right.add(r.right),o},this._findLetters=()=>{let e=new Set;for(let t of this._equations)e=new Set([...e,...t.variables]);return this._letters=[...e],this._letters.sort(),this},this._equations=[],this._letters="xyz".split(""),void 0!==e&&e.length>0&&this.parse(...e),this}get equations(){return this._equations}set equations(e){this._equations=e}get letters(){return this._letters.join("")}set letters(e){this._letters=e.split("")}get isSolvable(){return this.variables.length===this._equations.length}get variables(){return this._letters}get tex(){let e=this.clone().reorder();return e.variables,this.buildTex(e.equations)}get solution(){let e=[];void 0===this._solutions&&this.solve();for(let t in this._solutions){if("RR"===this._solutions[t].display)return`\\left\\{ \\left(${this._letters.join(";")}\\right) \\big\\vert ${this.equations[0].tex} \\right\\}`;if("O/"===this._solutions[t].display)return"\\varnothing";e.push(this._solutions[t].tex)}return`\\left(${e.join(";")}\\right)`}get solutionAsDisplay(){let e=[];void 0===this._solutions&&this.solve();for(let t in this._solutions){if("RR"===this._solutions[t].display)return`{(${this._letters.join(";")}) | ${this.equations[0].display} }`;if("O/"===this._solutions[t].display)return"O/";e.push(this._solutions[t].display)}return`(${e.join(";")})`}get resolutionSteps(){return this._resolutionSteps}_linearReduction(e,t,i){let s=e.left.monomByDegree(1,i).coefficient.clone(),n=t.left.monomByDegree(1,i).coefficient.clone().opposed();const o=r.Numeric.gcd(s.numerator,n.numerator),a=r.Numeric.gcd(s.denominator,n.denominator);return s.divide(o).multiply(a),n.divide(o).multiply(a),(n.isNegativeOne()||s.isNegativeOne())&&(s.opposed(),n.opposed()),{merged:this.mergeEquations(e,t,n,s),factors:[n,s]}}_solveOneLetter(e,t){let i,r=this.clone().equations,a=[];this._resolutionSteps[e]=[];for(let s of this.variables)if(a=[],s!==e){t&&(this._resolutionSteps[e].push({equations:r.map((e=>e.clone())),operations:[...new Array(r.length)].map((e=>[...new Array(r.length-1)].map((e=>""))))}),i=this._resolutionSteps[e].length-1);for(let n=0;n<r.length-1;n++){const o=this._linearReduction(r[n],r[n+1],s);a.push(o.merged),t&&(this._resolutionSteps[e][i].operations[n][n]=o.factors[0].tex,this._resolutionSteps[e][i].operations[n+1][n]=o.factors[1].tex)}r=[...a]}let l=r[0];l.solve();const h=l.solutions[0];if(t){let t;this._resolutionSteps[e].push({equations:[r[0]],operations:[[r[0].left.monoms[0].coefficient.tex]]}),t=h.exact instanceof n.Fraction||"string"==typeof h.exact?new o.Polynom(h.exact):new o.Polynom(h.value),this._resolutionSteps[e].push({equations:[new s.Equation(new o.Polynom(e),t)],operations:[]})}return l.solutions[0]}}t.LinearSystem=a},236:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Logicalset=void 0;const s=i(505);t.Logicalset=class{constructor(e){return this.parse=e=>(this._rpn=new s.Shutingyard(s.ShutingyardMode.SET).parse(e).rpn,this),this._rawString=e,this.parse(e),this}get isLogicalset(){return!0}evaluate(e,t){let i,s=[];if(void 0===t){i=new Set;for(let t in e)i=new Set([...i,...e[t]])}else i=new Set(t);for(let t of this._rpn)if("variable"===t.tokenType)void 0===e[t.token]?s.push(new Set):s.push(new Set(e[t.token]));else switch(t.token){case"&":if(s.length>=2){let e=s.pop(),t=s.pop();s.push(new Set([...t].filter((t=>e.has(t)))))}break;case"|":if(s.length>=2){let e=s.pop(),t=s.pop();s.push(new Set([...t,...e]))}break;case"-":if(s.length>=2){let e=s.pop(),t=s.pop();s.push(new Set([...t].filter((t=>!e.has(t)))))}break;case"!":if(s.length>=1){let e=s.pop();s.push(new Set([...i].filter((t=>!e.has(t)))))}}return[...s[0]].sort()}vennAB(){return this.evaluate({A:["A","AB"],B:["B","AB"]},["A","B","AB","E"])}vennABC(){return this.evaluate({A:["A","AB","AC","ABC"],B:["B","AB","BC","ABC"],C:["C","AC","BC","ABC"]},["A","B","C","AB","AC","BC","E"])}get rpn(){return this._rpn}get tex(){let e=[];for(let t of this._rpn)if("variable"===t.tokenType)e.push(t);else switch(t.token){case"&":if(e.length>=2){let t=e.pop(),i=e.pop();"mix"===i.tokenType&&(i.token=`( ${i.token} )`),"mix"===t.tokenType&&(t.token=`( ${t.token} )`),e.push({token:`${i.token} \\cap ${t.token}`,tokenType:"mix"})}break;case"|":if(e.length>=2){let t=e.pop(),i=e.pop();"mix"===i.tokenType&&(i.token=`( ${i.token} )`),"mix"===t.tokenType&&(t.token=`( ${t.token} )`),e.push({token:`${i.token} \\cup ${t.token}`,tokenType:"mix"})}break;case"-":if(e.length>=2){let t=e.pop(),i=e.pop();"mix"===i.tokenType&&(i.token=`( ${i.token} )`),"mix"===t.tokenType&&(t.token=`( ${t.token} )`),e.push({token:`${i.token} \\setminus ${t.token}`,tokenType:"mix"})}break;case"!":if(e.length>=1){let t=e.pop();e.push({token:`\\overline{ ${t.token} }`,tokenType:"variable"})}}return e[0].token}}},937:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Monom=void 0;const s=i(956),n=i(505),o=i(506);class r{constructor(e){return this.parse=e=>("string"==typeof e?this._shutingYardToReducedMonom(e):"number"==typeof e?(this._coefficient=new o.Fraction(e),this._literal={}):e instanceof o.Fraction?(this._coefficient=e.clone(),this._literal={}):e instanceof r&&(this._coefficient=e._coefficient.clone(),this._literal=this.copyLiterals(e.literal)),this),this.addToken=(e,t)=>{let i,s,a,l,h;if(t.tokenType===n.ShutingyardType.COEFFICIENT)e.push(new r(new o.Fraction(t.token)));else if(t.tokenType===n.ShutingyardType.VARIABLE){let i=(new r).one();i.setLetter(t.token,1),e.push(i.clone())}else if(t.tokenType===n.ShutingyardType.OPERATION)switch(t.token){case"-":s=e.pop()||(new r).zero(),i=e.pop()||(new r).zero(),e.push(i.subtract(s));break;case"*":s=e.pop()||(new r).one(),i=e.pop()||(new r).one(),e.push(i.multiply(s));break;case"/":s=e.pop()||(new r).one(),i=e.pop()||(new r).one(),e.push(i.divide(s));break;case"^":h=e.pop().coefficient||(new o.Fraction).one(),a=e.pop()||(new r).one(),l=a.variables[0],void 0!==l&&a.setLetter(l,h),e.push(a)}},this._shutingYardToReducedMonom=e=>{const t=(new n.Shutingyard).parse(e).rpn;let i=[];if(0===t.length)return this.zero(),this;if(1===t.length){const e=t[0];return this.one(),"coefficient"===e.tokenType?this.coefficient=new o.Fraction(e.token):"variable"===e.tokenType&&this.setLetter(e.token,1),this}for(const e of t)this.addToken(i,e);return this.one(),this.multiply(i[0]),this},this.clone=()=>{let e=new r;e.coefficient=this._coefficient.clone();for(let t in this._literal)e.setLetter(t,this._literal[t].clone());return e},this.copyLiterals=e=>{let t={};for(let i in e)t[i]=e[i].clone();return t},this.makeSame=e=>{for(let t in e._literal)this.setLetter(t,e._literal[t].clone());return this},this.zero=()=>(this._coefficient=(new o.Fraction).zero(),this._literal={},this),this.one=()=>(this._coefficient=(new o.Fraction).one(),this._literal={},this),this.clean=()=>{for(let e in this._literal)this._literal[e].isZero()&&delete this._literal[e];return this},this.reduce=()=>(this.clean(),this.coefficient.reduce(),this),this.opposed=()=>(this._coefficient.opposed(),this),this.add=(...e)=>{for(let t of e)this.isSameAs(t)?(this.isZero()&&this.makeSame(t),this._coefficient.add(t.coefficient)):console.log("Add monom: "+this.display+" is not similar with ",t.display);return this},this.subtract=(...e)=>{for(let t of e)this.isSameAs(t)?(this.isZero()&&this.makeSame(t),this._coefficient.add(t.clone().coefficient.opposed())):console.log("Subtract: Is not similar: ",t.display);return this},this.multiply=(...e)=>{for(let t of e){this._coefficient.multiply(t.coefficient);for(let e in t.literal)void 0===this._literal[e]?this._literal[e]=t.literal[e].clone():this._literal[e].add(t.literal[e])}return this},this.multiplyByNumber=e=>(this._coefficient.multiply(e),this),this.divide=(...e)=>{for(let t of e){this._coefficient.divide(t.coefficient);for(let e in t.literal)this._literal[e]=void 0===this._literal[e]?t.literal[e].clone().opposed():this._literal[e].subtract(t.literal[e]),this._literal[e].isZero()&&delete this._literal[e]}return this},this.pow=e=>{this._coefficient.pow(e);for(let t in this._literal)this._literal[t].multiply(e);return this},this.root=e=>this,this.sqrt=()=>{if(this.isSquare()){this._coefficient.sqrt();for(let e in this._literal)this._literal[e].clone().divide(2)}return this.root(2)},this.compare=(e,t)=>{switch(void 0===t&&(t="="),t){case"=":return!!this.compare(e,"same")&&this._coefficient.isEqual(e.coefficient);case"same":let t=this.variables,i=e.variables,s=t.concat(i.filter((e=>t.indexOf(e)<0)));if(0===t.length&&0===i.length)return!0;if(!this.isZero()&&!e.isZero())for(let t of s){if(void 0===this._literal[t]||void 0===e.literal[t])return!1;if(!this._literal[t].isEqual(e.literal[t]))return!1}return!0;default:return!1}},this.isEqual=e=>this.compare(e,"="),this.isSameAs=e=>this.compare(e,"same"),this.isSquare=()=>!!this.coefficient.isSquare()&&this.isLiteralSquare(),this.isLiteralSquare=()=>{for(let e in this.literal){if(this.literal[e].isRational())return!1;if(this.literal[e].isEven())return!1}return!0},this.hasFractionCoefficient=()=>{for(let e in this._literal)if(this._literal[e].isRational())return!0;return!1},this.hasLetter=e=>void 0!==this._literal[void 0===e?"x":e]&&this._literal[void 0===e?"x":e].isNotZero(),this.setLetter=(e,t)=>{t instanceof o.Fraction?(this.hasLetter(e)&&t.isZero()&&delete this._literal[e],this._literal[e]=t.clone()):this.setLetter(e,new o.Fraction(t))},this.degree=e=>0===this.variables.length?(new o.Fraction).zero():void 0===e?Object.values(this._literal).reduce(((e,t)=>e.clone().add(t))):void 0===this._literal[e]?(new o.Fraction).zero():this._literal[e].clone(),this.evaluate=e=>{let t=this.coefficient.clone();if("number"==typeof e||e instanceof o.Fraction){let t={};return t[this.variables[0]]=new o.Fraction(e),this.evaluate(t)}if("object"==typeof e){if(0===this.variables.length)return this.coefficient;for(let i in this._literal){if(void 0===e[i])return(new o.Fraction).zero();let s=new o.Fraction(e[i]);t.multiply(s.pow(this._literal[i]))}}return t},this.evaluateAsNumeric=e=>{let t=this.coefficient.value;if("number"==typeof e){let t={};return t[this.variables[0]]=e,this.evaluateAsNumeric(t)}if("object"==typeof e){if(0===this.variables.length)return this.coefficient.value;for(let i in this._literal){if(void 0===e[i])return 0;t*=e[i]**this._literal[i].value}}return t},this.derivative=e=>{if(void 0===e&&(e="x"),this.hasLetter(e)){let t=this._literal[e].clone(),i=this.clone();return i._literal[e].subtract(1),i._coefficient.multiply(new o.Fraction(t.clone())),i}return(new r).zero()},this.primitive=e=>{void 0===e&&(e="x");let t,i=this.clone();return i.hasLetter(e)?(t=i.degree(e).clone().add(1),i.coefficient=i.coefficient.clone().divide(t),i.setLetter(e,t)):(i.coefficient.isZero()&&(i.coefficient=(new o.Fraction).one()),i.setLetter(e,1)),i},this.areSameAs=(...e)=>{for(let t=0;t<e.length;t++)if(!this.isSameAs(e[t]))return!1;return!0},this.areEquals=(...e)=>{if(!this.areSameAs(...e))return!1;for(let t of e)if(!this._coefficient.isEqual(t.coefficient))return!1;return!0},this.isDivisible=e=>{if(e.degree().isStrictlyPositive())for(let t of e.variables)if(!this.degree(t).geq(e.degree(t)))return!1;return!(!this.coefficient.isRational()&&!e.coefficient.isRational())||this.coefficient.clone().divide(e.coefficient).isRelative()},this.zero(),void 0!==e&&this.parse(e),this}get coefficient(){return this._coefficient}set coefficient(e){this._coefficient=new o.Fraction(e)}get literal(){return this._literal}get literalSqrt(){if(this.isLiteralSquare()){let e={};for(let t in this._literal)e[t]=this._literal[t].clone().sqrt();return e}return this._literal}set literal(e){this._literal=e}set literalStr(e){for(const t of[...e.matchAll(/([a-z])\^([+-]?[0-9]+)/g)])t[1]in this._literal||(this._literal[t[1]]=(new o.Fraction).zero()),this._literal[t[1]].add(+t[2]);for(const t of[...e.matchAll(/([a-z](?!\^))/g)])t[1]in this._literal||(this._literal[t[1]]=(new o.Fraction).zero()),this._literal[t[1]].add(1)}get variables(){let e=this.clone().clean();return Object.keys(e.literal)}get display(){let e="",t=Object.keys(this._literal).sort();for(let i of t)this._literal[i].isNotZero()&&(e+=`${i}`,this._literal[i].isNotEqual(1)&&(e+=`^(${this._literal[i].display})`));return""===e?0!=this._coefficient.value?`${this._coefficient.display}`:"":1===this._coefficient.value?e:-1===this._coefficient.value?`-${e}`:0===this._coefficient.value?"0":`${this._coefficient.display}${e}`}get dividers(){if(!this.coefficient.isRelative())return[this.clone()];if(this.hasFractionCoefficient())return[this.clone()];if(this.coefficient.numerator>1e6)return[this.clone()];const e=s.Numeric.dividers(Math.abs(this.coefficient.numerator));let t=[];for(let e in this.literal)t=this._getLiteralDividers(t,e);const i=[];if(t.length>0&&e.length>0)for(let s of e)for(let e of t){let t=new r;t.coefficient=new o.Fraction(s),t.literal=e,i.push(t)}else if(0===e.length)for(let e of t){let t=new r;t.coefficient=(new o.Fraction).one(),t.literal=e,i.push(t)}else for(let t of e){let e=new r;e.coefficient=new o.Fraction(t),i.push(e)}return 0===i.length?[(new r).one()]:i}_getLiteralDividers(e,t){let i=[];for(let s=0;s<=this.literal[t].value;s++)if(0===e.length){let e={};e[t]=new o.Fraction(s),i.push(e)}else for(let n of e){let e={};for(let t in n)e[t]=n[t];e[t]=new o.Fraction(s),i.push(e)}return i}get displayWithSign(){let e=this.display;return("-"!==e[0]?"+":"")+e}get texWithSign(){return this.coefficient.isStrictlyPositive()?"+"+this.tex:this.tex}get plotFunction(){let e="",t=Object.keys(this._literal).sort();for(let i of t)this._literal[i].isNotZero()&&(e+=(""===e?"":"*")+`${i}`,this._literal[i].isNotEqual(1)&&(e+=`^(${this._literal[i].display})`));return""===e?0!=this._coefficient.value?`${this._coefficient.display}`:"":1===this._coefficient.value?e:-1===this._coefficient.value?`-${e}`:0===this._coefficient.value?"0":`${this._coefficient.display}*${e}`}get tex(){let e="",t=Object.keys(this._literal).sort();for(let i of t)this._literal[i].isNotZero()&&(e+=`${i}`,this._literal[i].isNotEqual(1)&&(e+=`^{${this._literal[i].tfrac}}`));return""===e?0!=this._coefficient.value?`${this._coefficient.frac}`:"0":1===this._coefficient.value?e:-1===this._coefficient.value?`-${e}`:0===this._coefficient.value?"0":`${this._coefficient.frac}${e}`}isZero(){return 0===this._coefficient.value}isOne(){return 1===this._coefficient.value&&0===this.variables.length}}t.Monom=r,r.lcm=(...e)=>{for(let t of e)if(t.hasFractionCoefficient())return(new r).zero();let t=new r,i=e.map((e=>e.coefficient.numerator)),n=e.map((e=>e.coefficient.denominator)),a=s.Numeric.gcd(...i),l=s.Numeric.lcm(...n);t.coefficient=new o.Fraction(a,l).reduce();for(let i of e){for(let e in t.literal)e in i.literal||t.literal[e].zero();for(let e in i.literal)void 0===t.literal[e]&&i.literal[e].isStrictlyPositive()?t.literal[e]=i.literal[e].clone():t.literal[e]=new o.Fraction(Math.min(i.literal[e].value,t.literal[e].value))}return t},r.xmultiply=(...e)=>{let t=(new r).one();for(let i of e)t.multiply(i);return t}},38:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Polynom=void 0;const s=i(937),n=i(505),o=i(956),r=i(506),a=i(760);class l{constructor(e,...t){return this.mark_as_dirty=()=>{this.dirty_factors=!0,this.dirty_zeroes=!0,this.euclidianCache={}},this.addToken=(e,t)=>{switch(t.tokenType){case n.ShutingyardType.COEFFICIENT:e.push(new l(t.token));break;case n.ShutingyardType.VARIABLE:e.push((new l).add(new s.Monom(t.token)));break;case n.ShutingyardType.CONSTANT:console.log("Actually, not supported - will be added later !");break;case n.ShutingyardType.OPERATION:if(e.length>=2){const i=e.pop(),s=e.pop();if("+"===t.token)e.push(s.add(i));else if("-"===t.token)e.push(s.subtract(i));else if("*"===t.token)e.push(s.multiply(i));else if("/"===t.token)i.degree().isStrictlyPositive()?console.log("divide by a polynom -> should create a rational polynom !"):e.push(s.divide(i.monoms[0].coefficient));else if("^"===t.token)if(i.degree().isStrictlyPositive())console.error("Cannot elevate a polynom with another polynom !",s.tex,i.tex);else if(i.monoms[0].coefficient.isRelative())e.push(s.pow(i.monoms[0].coefficient.value));else if(1===s.monoms.length&&s.monoms[0].coefficient.isOne()){for(let e in s.monoms[0].literal)s.monoms[0].literal[e].multiply(i.monoms[0].coefficient);e.push(s)}else console.error("Cannot have power with fraction")}else{if("-"!==t.token)throw"Error parsing the polynom "+this._rawString;e.push(e.pop().opposed())}break;case n.ShutingyardType.MONOM:console.error("The monom token should not appear here");break;case n.ShutingyardType.FUNCTION:console.error("The function token should not appear here - might be introduced later.")}},this.parse=(e,...t)=>{if(this._monoms=[],this._factors=[],this.mark_as_dirty(),"string"==typeof e)return this._parseString(e,...t);if(!("number"==typeof e||e instanceof r.Fraction||e instanceof s.Monom)||void 0!==t&&0!==t.length){if(e instanceof s.Monom&&t.length>0)this._monoms.push(new s.Monom(e)),t.forEach((e=>{this._monoms.push(new s.Monom(e))}));else if(e instanceof l)for(const t of e.monoms)this._monoms.push(t.clone())}else this._monoms.push(new s.Monom(e));return this},this.clone=()=>{const e=new l,t=[];for(const e of this._monoms)t.push(e.clone());return e.monoms=t,e},this.zero=()=>(this._monoms=[],this._monoms.push((new s.Monom).zero()),this._rawString="0",this.mark_as_dirty(),this),this.one=()=>(this._monoms=[],this._monoms.push((new s.Monom).one()),this._rawString="1",this.mark_as_dirty(),this),this.empty=()=>(this._monoms=[],this._rawString="",this.mark_as_dirty(),this),this.opposed=()=>(this._monoms=this._monoms.map((e=>e.opposed())),this.mark_as_dirty(),this),this.add=(...e)=>{this.mark_as_dirty();for(let t of e)t instanceof l?this._monoms=this._monoms.concat(t.monoms):t instanceof s.Monom?this._monoms.push(t.clone()):Number.isSafeInteger(t)?this._monoms.push(new s.Monom(t.toString())):this._monoms.push(new s.Monom(t));return this.reduce()},this.subtract=(...e)=>{this.mark_as_dirty();for(let t of e)t instanceof l?this._monoms=this._monoms.concat(t.clone().opposed().monoms):t instanceof s.Monom?this._monoms.push(t.clone().opposed()):Number.isSafeInteger(t)?this._monoms.push(new s.Monom(t.toString()).opposed()):this._monoms.push(new s.Monom(t).opposed());return this.reduce()},this.multiply=e=>(this.mark_as_dirty(),e instanceof l?this.multiplyByPolynom(e):e instanceof r.Fraction?this.multiplyByFraction(e):e instanceof s.Monom?this.multiplyByMonom(e):Number.isSafeInteger(e)&&"number"==typeof e?this.multiplyByInteger(e):this),this.euclidian=e=>{if(void 0!==this.euclidianCache[e.tex])return this.euclidianCache[e.tex];const t=e.variables[0],i=(new l).zero(),s=this.clone().reorder(t);if(0===e.variables.length)return this.clone().divide(e),{quotient:this.clone().divide(e),reminder:(new l).zero()};const n=e.monomByDegree(void 0,t),o=e.degree(t);let r,a=this.degree(t).clone().multiply(2);for(;s.degree(t).geq(o)&&a.isPositive()&&(a.subtract(1),r=s.monomByDegree(void 0,t).clone().divide(n),!r.isZero());)i.add(r),s.subtract(e.clone().multiply(r));return i.reduce(),s.reduce(),{quotient:i,reminder:s}},this.divide=e=>{if(this.mark_as_dirty(),e instanceof r.Fraction)return this.divideByFraction(e);if("number"==typeof e&&Number.isSafeInteger(e))return this.divideByInteger(e);if(e instanceof s.Monom)return this.divide(new l(e));if(e instanceof l){if(1===e.monoms.length&&0===e.variables.length)return this.divideByFraction(e.monoms[0].coefficient);{let{quotient:t,reminder:i}=this.euclidian(e);return i.isZero()?t:(console.log(`${this.tex} is not divideable by ${e.tex}`),(new l).zero())}}},this.pow=e=>{if(this.mark_as_dirty(),!Number.isSafeInteger(e))return this.zero();if(e<0)return this.zero();if(0===e)return new l;const t=this.clone();for(let i=1;i<e;i++)this.multiply(t);return this.reduce()},this.compare=(e,t)=>{void 0===t&&(t="=");const i=this.clone().reduce().reorder(),s=e.clone().reduce().reorder();switch(t){case"=":if(i.length!==s.length||i.degree().isNotEqual(s.degree()))return!1;for(const e in i.monoms)if(!i.monoms[e].isEqual(s.monoms[e]))return!1;return!0;case"same":if(i.length!==s.length||i.degree()!==s.degree())return!1;for(const e in i.monoms)if(!i.monoms[e].isSameAs(s.monoms[e]))return!1;return!0;default:return!1}},this.isEqual=e=>this.compare(e,"="),this.isSameAs=e=>this.compare(e,"same"),this.isOpposedAt=e=>this.compare(e.clone().opposed(),"="),this.isFactorized=(e,t)=>{let i;if(e.split("(").length!==e.split(")").length)return!1;try{i=new l(e)}catch(e){return!1}if(!this.isEqual(i))return!1;let s=e.replaceAll("*",""),n=""+s,o=[];for(let e of s.matchAll(/\(([a-z0-9+\-]+)\)(\^[0-9]*)?/g)){if(void 0!==e[2])for(let t=0;t<+e[2].substring(1);t++)o.push(e[1]);else o.push(e[1]);n=n.replaceAll(e[0],"")}""!==n&&o.push(n);let a=o.map((e=>new l(e))),h=a.filter((e=>e.degree().geq(1)&&!e.commonMonom().isOne()));if(h.length>0&&!t)return!1;if(h.length>0&&t){a=a.filter((e=>e.commonMonom().isOne()));let e=(new r.Fraction).one();for(let t of h){let i=t.commonMonom(),s=t.clone().divide(i);i.degree().isZero()&&(e.multiply(i.coefficient),a.push(s.clone()))}}this.factorize();let c=1,u=[];for(let e of this.factors){e.degree().isZero()&&e.monoms[0].coefficient.isNegativeOne()&&(c=-c);let t=!1;for(let i=0;i<a.length;i++){if(e.isEqual(a[i])){a.splice(i,1),t=!0;break}if(e.isOpposedAt(a[i])){a.splice(i,1),c=-c,t=!0;break}}t||u.push(e.clone())}return 0===a.length&&1===c},this.isReduced=e=>{if(!this.isDeveloped(e))return!1;let t=new l(e);if(t.monoms.length>this.monoms.length)return!1;for(let e of t.monoms)if(!e.coefficient.isReduced())return!1;return!1},this.isDeveloped=e=>{let t;if(e.split("(").length+e.split(")").length>0)return!1;try{t=new l(e)}catch(e){return!1}return!!this.isEqual(t)&&e.replaceAll("[*s]","")===t.reduce().reorder().display},this.reduce=()=>{let e=[...this._monoms],t=[...this.variables];this._monoms=[];let i=e.filter((e=>0===e.variables.length));i.length>0&&this._monoms.push(i.reduce(((e,t)=>e.add(t))));for(let i of t){let t=e.filter((e=>e.hasLetter(i)));for(;t.length>0;){const e=t.shift(),s=e.degree(i);for(let n of t.filter((e=>e.degree(i).isEqual(s))))e.add(n);this._monoms.push(e),t=t.filter((e=>e.degree(i).isNotEqual(s)))}}this._monoms=this._monoms.filter((e=>0!==e.coefficient.value));for(const e of this._monoms)e.coefficient.reduce();return 0===this.length?(new l).zero():this.reorder()},this.reorder=(e="x",t)=>{void 0===t&&(t=!1);let i=this.variables.filter((t=>t!==e));return this._monoms.sort((function(s,n){let o=s.degree(e).value,r=n.degree(e).value;if(o!==r)return t?o-r:r-o;if(i.length>0)for(let e of i){let i=s.degree(e).value,o=n.degree(e).value;if(i!==o)return t?i-o:o-i}return 0})),this},this.degree=e=>{let t=(new r.Fraction).zero();for(const i of this._monoms)t=r.Fraction.max(i.degree(e).value,t);return t},this.letters=()=>{let e=new Set;for(let t of this._monoms)e=new Set([...e,...t.variables]);return[...e]},this.replaceBy=(e,t)=>{let i;this.mark_as_dirty();const s=(new l).zero();for(const n of this.monoms)void 0===n.literal[e]||n.literal[e].isZero()?s.add(n.clone()):(i=n.literal[e].clone(),delete n.literal[e],s.add(t.clone().pow(Math.abs(i.numerator)).multiply(n)));return this._monoms=s.reduce().reorder().monoms,this},this.evaluate=e=>{const t=(new r.Fraction).zero();return this._monoms.forEach((i=>{t.add(i.evaluate(e))})),t},this.evaluateAsNumeric=e=>{let t=0;return this._monoms.forEach((i=>{t+=i.evaluateAsNumeric(e)})),t},this.derivative=e=>{let t=new l;for(let i of this._monoms)t.add(i.derivative(e));return t},this.primitive=e=>{let t=new l;for(let i of this._monoms)t.add(i.primitive(e));return t},this.integrate=(e,t,i)=>{const s=this.primitive(i);void 0===i&&(i="x");let n={},o={};return n[i]=new r.Fraction(e),o[i]=new r.Fraction(t),s.evaluate(o).subtract(s.evaluate(n))},this.factorize=e=>{if(!this.dirty_factors)return this._factors;let t=[],i=this.clone().reorder(),s=i.commonMonom();if(i.monomByDegree().coefficient.isStrictlyNegative()&&s.coefficient.isStrictlyPositive()&&!s.isOne()&&s.opposed(),!s.isOne()){let e=new l(s);t=[e.clone()],i=i.euclidian(e).quotient}let n=i.degree().clone().multiply(2).value,o=1;for(;n>=0;){if(n--,i.monoms.length<2){i.isOne()||(t.push(i.clone()),i.one());break}if(i.degree(e).isOne()){t.push(i.clone()),i.one();break}{let s=this._getAllPotentialFactors(i,o,e);for(o=i.degree(e).value;s.length>0;){let e=s[0];if(i.isDividableBy(e)){let n=i.euclidian(e);t.push(e),i=n.quotient.clone(),s=s.filter((e=>{let t=i.monoms[0],s=i.monoms[i.monoms.length-1],n=e.monoms[0],o=e.monoms[e.monoms.length-1];return!!s.isDivisible(o)&&!!t.isDivisible(n)}))}else s.shift()}}}return i.isOne()||t.push(i.clone()),this._factors=t,this.dirty_factors=!1,this._factors},this.isDividableBy=e=>{if(e.degree().isOne()){let t=e.getZeroes()[0];return t.exact instanceof r.Fraction&&this.evaluate(t.exact).isZero()}return this.euclidianCache[e.tex]=this.euclidian(e),this.euclidianCache[e.tex].reminder.isZero()},this.getZeroes=()=>{if(this.dirty_zeroes){let e=new a.Equation(this.clone(),0);e.solve(),this._zeroes=e.solutions,this.dirty_zeroes=!1}return this._zeroes},this.monomByDegree=(e,t)=>{if(void 0===e)return this.monomByDegree(this.degree(t),t);const i=this.clone().reduce();for(const s of i._monoms)if(s.degree(t).isEqual(e))return s.clone();return(new s.Monom).zero()},this.monomsByDegree=(e,t)=>{if(void 0===e)return this.monomsByDegree(this.degree(t));let i=[];const s=this.clone().reduce();for(const n of s._monoms)n.degree(t)===e&&i.push(n.clone());return i},this.monomByLetter=e=>{const t=this.clone().reduce();for(const i of t._monoms)if(i.hasLetter(e))return i.clone();return(new s.Monom).zero()},this.getDenominators=()=>{const e=[];for(const t of this._monoms)e.push(t.coefficient.denominator);return e},this.getNumerators=()=>{const e=[];for(const t of this._monoms)e.push(t.coefficient.numerator);return e},this.lcmDenominator=()=>o.Numeric.lcm(...this.getDenominators()),this.gcdDenominator=()=>o.Numeric.gcd(...this.getDenominators()),this.lcmNumerator=()=>o.Numeric.lcm(...this.getNumerators()),this.gcdNumerator=()=>o.Numeric.gcd(...this.getNumerators()),this.commonMonom=()=>{let e,t,i=(new s.Monom).one(),n=this.degree();e=this.gcdNumerator(),t=this.gcdDenominator(),i.coefficient=new r.Fraction(e,t);for(let e of this.variables){i.setLetter(e,n);for(let t of this._monoms)if(i.setLetter(e,r.Fraction.min(t.degree(e),i.degree(e))),i.degree(e).isZero())break}return i},this.limitToInfinity=e=>{const t=this.monomByDegree(void 0,e),i=t.coefficient.sign(),s=t.degree(e);return s.isStrictlyPositive()?1===i?(new r.Fraction).infinite():(new r.Fraction).infinite().opposed():s.isZero()?t.coefficient:(new r.Fraction).zero()},this.limitToNegativeInfinity=e=>{const t=this.monomByDegree(void 0,e),i=t.coefficient.sign(),s=t.degree(e);return s.isStrictlyPositive()?-1===i?(new r.Fraction).infinite():(new r.Fraction).infinite().opposed():s.isZero()?t.coefficient:(new r.Fraction).zero()},this._getAllPotentialFactors=(e,t,i)=>{let s=e.monoms[0].dividers,n=e.monoms[e.monoms.length-1].dividers,o=[];return s.forEach((e=>{e.degree(i).leq(t)&&n.forEach((t=>{e.degree(i).isNotEqual(t.degree(i))&&(o.push(new l(e,t)),o.push(new l(e,t.clone().opposed())))}))})),o},this.genDisplay=(e,t,i,s)=>{let n="";for(const i of this._monoms){if(0===i.coefficient.value)continue;let o;o=s?i.plotFunction:"tex"===e?i.tex:i.display,n+=`${1!==i.coefficient.sign()||""===n&&!0!==t?"":"+"}${o}`}return!0===i&&this.length>1&&(n="tex"===e?`\\left( ${n} \\right)`:`(${n})`),""===n&&(n="0"),n},this.shutingYardToReducedPolynom=e=>{const t=(new n.Shutingyard).parse(e).rpn;this.zero();let i=[];new s.Monom;for(const e of t)this.addToken(i,e);return 1===i.length&&this.add(i[0]),this.reorder()},this.multiplyByPolynom=e=>{const t=[];for(const i of this._monoms)for(const n of e.monoms)t.push(s.Monom.xmultiply(i,n));return this._monoms=t,this.reduce()},this.multiplyByFraction=e=>{for(const t of this._monoms)t.coefficient.multiply(e);return this.reduce()},this.multiplyByInteger=e=>this.multiplyByFraction(new r.Fraction(e)),this.multiplyByMonom=e=>{for(const t of this._monoms)t.multiply(e);return this.reduce()},this.divideByInteger=e=>{const t=new r.Fraction(e);for(const e of this._monoms)e.coefficient.divide(t);return this},this.divideByFraction=e=>{for(const t of this._monoms)t.coefficient.divide(e);return this},this._factorize2ndDegree=e=>{let t,i,s,n,o,r,a,h,c;if(1===this.numberOfVars)return s=this.monomByDegree(2,e).coefficient,n=this.monomByDegree(1,e).coefficient,o=this.monomByDegree(0,e).coefficient,r=n.clone().pow(2).subtract(s.clone().multiply(o).multiply(4)),r.isZero()?(a=n.clone().opposed().divide(s.clone().multiply(2)),t=new l(e).subtract(a.display).multiply(a.denominator),i=new l(e).subtract(a.display).multiply(a.denominator),c=s.divide(a.denominator).divide(a.denominator),c.isOne()?[t,i]:[new l(c.display),t,i]):r.isPositive()&&r.isSquare()?(a=n.clone().opposed().add(r.clone().sqrt()).divide(s.clone().multiply(2)),h=n.clone().opposed().subtract(r.clone().sqrt()).divide(s.clone().multiply(2)),c=s.divide(a.denominator).divide(h.denominator),c.isOne()?[new l(e).subtract(a.display).multiply(a.denominator),new l(e).subtract(h.display).multiply(h.denominator)]:[new l(c.display),new l(e).subtract(a.display).multiply(a.denominator),new l(e).subtract(h.display).multiply(h.denominator)]):[this.clone()];if(s=this.monomByDegree(2,e),n=this.monomByDegree(1,e),o=this.monomByDegree(0,e),s.isLiteralSquare()&&o.isLiteralSquare()&&n.clone().pow(2).isSameAs(s.clone().multiply(o))){let e,t=new l("x",s.coefficient,n.coefficient,o.coefficient)._factorize2ndDegree("x"),i=[];if(t.length>=2){for(let n of t)n.degree().isZero()?i.push(n.clone()):(e=n.clone(),e.monoms[0].literal=s.literalSqrt,e.monoms[1].literal=o.literalSqrt,i.push(e.clone()));return i}}return[this.clone()]},this._factorizeByGroups=()=>[],this._monoms=[],this._factors=[],this.mark_as_dirty(),void 0!==e&&this.parse(e,...t),this}get euclidianCache(){return this._euclidianCache}set euclidianCache(e){this._euclidianCache=e}get dirty_zeroes(){return this._dirty_zeroes}set dirty_zeroes(e){this._dirty_zeroes=e}get dirty_factors(){return this._dirty_factors}set dirty_factors(e){this._dirty_factors=e}get monoms(){return this._monoms}set monoms(e){this._monoms=e}get zeroes(){return this.getZeroes()}get factors(){return this.factorize()}set factors(e){this.mark_as_dirty(),this._factors=e}get texString(){return this._texString}get texFactors(){if(this.factorize(),this.factors.length<=1)return this.tex;let e={};for(let t of this.factors)void 0!==e[t.tex]?e[t.tex].degree++:e[t.tex]={degree:1,factor:t};let t=(new l).one();for(let i of Object.values(e).filter((e=>1===e.factor.monoms.length)))t.multiply(i.factor);let i=t.isOne()?"":t.tex;for(let t of Object.values(e).filter((e=>e.factor.monoms.length>1)))t.factor.length>1&&(i+=`\\left( ${t.factor.tex} \\right)${t.degree>1?"^{ "+t.degree+" }":""}`);return i}get displayFactors(){if(this.factorize(),this.factors.length<=1)return this.display;let e={};for(let t of this.factors)void 0!==e[t.display]?e[t.display].degree++:e[t.display]={degree:1,factor:t};let t=(new l).one();for(let i of Object.values(e).filter((e=>1===e.factor.monoms.length)))t.multiply(i.factor);let i=t.isOne()?"":t.display;for(let t of Object.values(e).filter((e=>e.factor.monoms.length>1)))t.factor.length>1&&(i+=`(${t.factor.display})${t.degree>1?"^("+t.degree+")":""}`);return i}get length(){return this._monoms.length}get display(){return this.genDisplay()}get raw(){return this._rawString}get tex(){return this.genDisplay("tex")}get isMultiVariable(){for(const e of this._monoms)if(e.variables.length>1)return!0;return!1}get variables(){let e=[];for(const t of this._monoms)e=e.concat(t.variables);return e=[...new Set(e)],e.sort(),e}get numberOfVars(){return this.variables.length}get plotFunction(){return this.genDisplay("tex",!1,!1,!0)}isZero(){return 1===this._monoms.length&&this._monoms[0].coefficient.isZero()||0===this._monoms.length}isOne(){return 1===this._monoms.length&&this._monoms[0].coefficient.isOne()}_parseString(e,...t){if(void 0===t||0===t.length){if(e=""+e,this._rawString=e.trim().replaceAll(" ",""),""!==e&&!isNaN(Number(e))){this.empty();let t=new s.Monom(e);return this.add(t),this}return this.shutingYardToReducedPolynom(e)}if(/^[a-z]/.test(e)){this.empty();let i=t.map((e=>new r.Fraction(e)));if(e.length>1){let t=e.split(""),n=0;for(let e of i){let i=new s.Monom;i.coefficient=e.clone(),i.literalStr=t[n]||"",this.add(i),n++}}else{let t=i.length-1;for(let n of i){let i=new s.Monom;i.coefficient=n.clone(),i.literalStr=`${e}^${t}`,this.add(i),t--}}return this}return this.zero()}}t.Polynom=l},107:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Rational=void 0;const s=i(38),n=i(506),o=i(760),r=i(572);class a{constructor(e,t){this.clone=()=>new a(this._numerator.clone(),this._denominator.clone()),this.domain=()=>{let e=this._denominator.getZeroes();return 0===e.length||e[0].tex===o.PARTICULAR_SOLUTION.real?o.PARTICULAR_SOLUTION.varnothing:e[0].tex===o.PARTICULAR_SOLUTION.varnothing?o.PARTICULAR_SOLUTION.real:"\\mathbb{R}\\setminus\\left\\{"+e.map((e=>e.tex)).join(";")+"\\right\\}"},this.amplify=e=>(this._numerator.multiply(e),this._denominator.multiply(e),this),this.derivative=e=>{let t=this._numerator.clone(),i=this._denominator.clone(),s=t.clone().derivative(e),n=i.clone().derivative(e);return this._numerator=s.clone().multiply(i).subtract(t.clone().multiply(n)),this._denominator=i.clone().pow(2),this},this.factorize=e=>(this._numerator.factorize(e),this._denominator.factorize(e),this),this.simplify=e=>{let t=this._numerator.euclidian(e);if(!t.reminder.isZero())return this;let i=this._denominator.euclidian(e);return i.reminder.isZero()?(this._numerator=t.quotient,this._denominator=i.quotient,this):this},this.reduce=()=>{this._numerator.factorize();for(let e of this._numerator.factors)this.simplify(e);return this},this.opposed=()=>(this._numerator.opposed(),this),this.add=e=>{let t=this._denominator.clone();return this.amplify(e._denominator),this._numerator.add(e._numerator.clone().multiply(t)),this},this.subtract=e=>this.add(e.clone().opposed()),this.euclidian=()=>this._numerator.euclidian(this._denominator),this.limits=(e,t,i)=>{if(e===1/0||e===-1/0){let{quotient:t,reminder:s}=this._numerator.clone().euclidian(this._denominator);return t.degree(i).isStrictlyPositive()?e===1/0?t.limitToInfinity(i):t.limitToNegativeInfinity(i):t.monomByDegree(void 0,i).coefficient}{let s,o,r={},a={},l=this.clone().reduce();return r[void 0===i?"x":i]=new n.Fraction(e),"above"!==t&&"below"!==t?(s=l._numerator.evaluate(r).divide(l._denominator.evaluate(r)),s.isInfinity()?s.abs():s):("above"===t?a[void 0===i?"x":i]=new n.Fraction(e).add(1e-6):"below"===t&&(a[void 0===i?"x":i]=new n.Fraction(e).subtract(1e-6)),s=l._numerator.evaluate(r).divide(l._denominator.evaluate(r)),o=l._numerator.evaluate(a).divide(l._denominator.evaluate(a)).sign(),s.isInfinity()?1===o?s.abs():s.abs().opposed():s)}},this.evaluate=e=>{(new n.Fraction).zero();let t=this._numerator.evaluate(e),i=this._denominator.evaluate(e);return t.divide(i)},this.evaluateAsNumeric=e=>this._numerator.evaluateAsNumeric(e)/this._denominator.evaluateAsNumeric(e),this.study=e=>new r.RationalStudy(this,e),e instanceof s.Polynom?this._numerator=e.clone():this._numerator="string"==typeof e?new s.Polynom(e):new s.Polynom,t instanceof s.Polynom?this._denominator=t.clone():this._denominator="string"==typeof t?new s.Polynom(t):new s.Polynom}get numerator(){return this._numerator}get denominator(){return this._denominator}get tex(){return`\\frac{ ${this._numerator.tex} }{ ${this._denominator.tex} }`}get texFactors(){return`\\frac{ ${this._numerator.texFactors} }{ ${this._denominator.texFactors} }`}get plotFunction(){return`(${this._numerator.plotFunction})/(${this._denominator.plotFunction})`}}t.Rational=a},996:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Study=t.TABLE_OF_SIGNS=t.FUNCTION_EXTREMA=t.ASYMPTOTE_POSITION=t.ASYMPTOTE=t.ZEROTYPE=void 0;const s=i(506),n=i(394);var o,r,a,l,h;!function(e){e.ZERO="z",e.DEFENCE="d",e.NOTHING="t"}(o||(t.ZEROTYPE=o={})),function(e){e.VERTICAL="av",e.HORIZONTAL="ah",e.SLOPE="ao",e.HOLE="hole"}(r||(t.ASYMPTOTE=r={})),function(e){e.LT="LT",e.RT="RT",e.LB="LB",e.RB="RB"}(a||(t.ASYMPTOTE_POSITION=a={})),function(e){e.MIN="min",e.MAX="max",e.FLAT="flat",e.NOTHING=""}(l||(t.FUNCTION_EXTREMA=l={})),function(e){e.SIGNS="signs",e.GROWS="grows",e.VARIATIONS="variatins"}(h||(t.TABLE_OF_SIGNS=h={})),t.Study=class{constructor(e,t){if(this.makeStudy=()=>{this._zeroes=this.makeZeroes(),this._config.signs&&(this._signs=this.makeSigns()),this._config.asymptotes&&(this._asymptotes=this.makeAsymptotes()),this._config.derivative&&(this._derivative=this.makeDerivative()),this._config.variations&&(this._variations=this.makeVariation()),this._config.signs&&(this._signs.tex=this.texSigns),this._config.derivative&&(this._derivative.tex=this.texGrows),this._config.variations&&(this._variations.tex=this.texVariations)},this.indexOfZero=(e,t)=>{for(let i=0;i<e.length;i++)if(e[i].tex===t.tex)return i;return-1},this.makeOneLineForSigns=(e,t,i)=>{let s=[],n=e.getZeroes().map((e=>e.tex));s.push(""),e.degree().isZero()?s.push(1===e.monoms[0].coefficient.sign()?"+":"-"):s.push(1===e.evaluate(t[0].value-1).sign()?"+":"-");for(let r=0;r<t.length;r++)s.push(n.includes(t[r].tex)?i:o.NOTHING),r<t.length-1?s.push(1===e.evaluate((t[r].value+t[r+1].value)/2).sign()?"+":"-"):r===t.length-1&&s.push(1===e.evaluate(t[r].value+1).sign()?"+":"-");return s.push(""),s},this.makeSignsResult=e=>{let t=e[0].map(((t,i)=>0===i||i===e[0].length-1?"":i%2==0?"t":"+"));for(let i of e)for(let e=0;e<i.length;e++)if(e%2==0){if("d"===t[e])continue;"t"!==i[e]&&(t[e]=i[e])}else"-"===i[e]&&(t[e]="+"===t[e]?"-":"+");return t},this.makeGrowsResult=e=>{let t=Object.values(e.signs),i=t[t.length-1],o=[],r={},a=e.zeroes;for(let e=0;e<a.length;e++){let t=2*e+2;if("z"===i[t]){let o,h,c,u,d,f=a[e].exact,m=new n.NumExp(this.fx.plotFunction);if(f instanceof s.Fraction){let e=f,t=this.fx.evaluate(e);o=f.value,h=t.value,c=f.tex,u=t.tex}else o=a[e].value,h=m.evaluate({x:o}),c=o.toFixed(2),u=h.toFixed(2);d=i[t-1]===i[t+1]?l.FLAT:"+"===i[t-1]?l.MAX:l.MIN,r[a[e].tex]={type:d,tex:{x:c,y:u},value:{x:o,y:h}}}}o.push("+"===i[1]?"-/":"+/");for(let e=1;e<i.length-1;e++)if("z"===i[e]){let t=r[a[(e-2)/2].tex];o.push(`${i[e-1]}/\\(${t.type}(${t.tex.x};${t.tex.y})\\)`)}else"d"===i[e]&&o.push(`${i[e-1]}D${"+"===i[e+1]?"-":"+"}/`);return o.push(`${i[i.length-2]}/`),{growsLine:o,extremes:r}},this.makeVariationsResult=e=>({varsLine:[],extremes:{}}),this.drawCode=()=>{let e=`f(x)=${this.fx.plotFunction}`,t=1;this.asymptotes.forEach((i=>{i.type===r.VERTICAL?(e+=`\nav_${t}=line x=${i.zero.value}->red,dash`,t++):i.type===r.HORIZONTAL?e+=`\nah=line y=${i.fx.monoms[0].coefficient.value}->orange,dash`:i.type===r.SLOPE&&(e+=`\nao=line y=${i.fx.plotFunction}->red,dash`),t++}));for(let i in this.derivative.extremes){let s=this.derivative.extremes[i];e+=`\nM_${t}(${s.value.x},${s.value.y})*`,t++}return this.zeroes.forEach((i=>{i.type===o.ZERO&&(e+=`\nZ_${t}(${i.value},0)*`,t++)})),e},this._makeTexFromTableOfSigns=e=>{let t=e.factors.map((e=>`\\(${e.tex}\\)/1`)),i=`\\(${this._config.name}(${this._config.variable})\\)/1.2`,s=e.zeroes;e.type===h.GROWS?i=`\\(${this._config.name}'(${this._config.variable})\\)/1.2,\\(f(x${this._config.variable})\\)/2`:e.type===h.VARIATIONS&&(i=`\\(${this._config.name}''(${this._config.variable})\\)/1.2,\\(f(${this._config.variable})\\)/2`);let n,o=`\\begin{tikzpicture}\n\\tkzTabInit[lgt=3,espcl=2,deltacl=0]{/1.2,${t.join(",")},/.1,${i} }{{\\scriptsize \\hspace{1cm} \\(-\\infty\\)},\\(${s.map((e=>e.tex)).join("\\),\\(")}\\),{\\scriptsize \\hspace{-1cm} \\(+\\infty\\)}}`;for(n=0;n<e.factors.length;n++)o+=`\n\\tkzTabLine{${e.signs[n].join(",")}}`;return o+=`\n\\tkzTabLine{${e.signs[n].join(",")}}`,(e.type===h.GROWS||e.type===h.VARIATIONS)&&(o+=`\n\\tkzTabVar{${e.signs[n+1].join(",")}}`),o+="\n\\end{tikzpicture}",o},this.fx=e,this._config={name:"f",variable:"x",domain:!0,asymptotes:!0,signs:!0,derivative:!0,variations:!0},t)if("string"==typeof t){const e=t.split(",");this._config={};let i=e.filter((e=>e.includes("(")&&e.includes(")")));1===i.length&&(this._config.name=i[0].split("(")[0],this._config.variable=i[0].split("(")[1].split(")")[0]),this._config.domain=e.includes("d"),this._config.asymptotes=e.includes("a"),this._config.signs=e.includes("signs"),this._config.derivative=e.includes("dx"),this._config.variations=e.includes("ddx")}else this._config=t;return this.makeStudy(),this}get name(){return this._config.name}set name(e){this._config.name=e}get config(){return this._config}set config(e){this._config=e}get zeroes(){return this._zeroes}get domain(){return this.fx.domain()}get signs(){return this._signs}get asymptotes(){return this._asymptotes}get derivative(){return this._derivative}get texSigns(){return this._makeTexFromTableOfSigns(this._signs)}get texGrows(){return this._makeTexFromTableOfSigns(this._derivative)}get texVariations(){return this._makeTexFromTableOfSigns(this._variations)}makeZeroes(){return[]}makeSigns(){return{type:h.SIGNS,fx:null,factors:[],zeroes:[],signs:[],extremes:{},tex:""}}makeAsymptotes(){return[]}makeDerivative(){return{type:h.GROWS,fx:null,factors:[],zeroes:[],signs:[],extremes:{},tex:""}}makeVariation(){return{type:h.VARIATIONS,fx:null,factors:[],zeroes:[],signs:[],extremes:{},tex:""}}}},572:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RationalStudy=void 0;const s=i(996),n=i(107),o=i(506),r=i(38);class a extends s.Study{constructor(e,t){return super(e,t),this}makeZeroes(){return this._getZeroes(this.fx)}makeSigns(){return this._getSigns(this.fx,this.zeroes)}makeAsymptotes(){const e=this.fx.clone().reduce();let t=[];this.zeroes.filter((e=>e.type===s.ZEROTYPE.DEFENCE)).forEach((i=>{let n=s.ASYMPTOTE.VERTICAL,r=`x=${i.tex}`,a=`x=${i.display}`;i.exact instanceof o.Fraction?e.denominator.evaluate(i.exact).isNotZero()&&(n=s.ASYMPTOTE.HOLE,r=`(${i.tex};${e.evaluate(i.exact).tex})`,a=`(${i.display};${e.evaluate(i.exact).display})`):e.denominator.evaluate(i.value).isNotZero()&&(n=s.ASYMPTOTE.HOLE,r=`(${i.tex};${e.evaluate(i.value).tex})`,a=`(${i.display};${e.evaluate(i.value).display})`);const l=1e-6;let h=this.fx.evaluateAsNumeric(i.value-l),c=this.fx.evaluateAsNumeric(i.value+l),u=[],d="";c<-1e4?(u.push(s.ASYMPTOTE_POSITION.RB),d+="m"):c>1e4&&(u.push(s.ASYMPTOTE_POSITION.RT),d+="p"),h<-1e4?(u.push(s.ASYMPTOTE_POSITION.LB),d+="m"):h>1e4&&(u.push(s.ASYMPTOTE_POSITION.LT),d+="p"),d="pp"===d?"+":"mm"===d?"-":`\\${d}`,t.push({fx:null,type:n,tex:r,display:a,zero:i,limits:`\\lim_{x\\to${i.tex} }\\ f(x) = ${d}\\infty`,deltaX:null,tableOfSign:null,position:u})}));let i=this.fx.numerator.degree(),a=this.fx.denominator.degree();if(i.isEqual(a)){let i=this.fx.numerator.monomByDegree().coefficient.clone().divide(this.fx.denominator.monomByDegree().coefficient),o=i.tex,{reminder:a}=e.euclidian(),l=new n.Rational(a,e.denominator);t.push({fx:new r.Polynom(i),type:s.ASYMPTOTE.HORIZONTAL,tex:`y=${o}`,display:`y=${i.display}`,zero:null,limits:`\\lim_{x\\to\\infty}\\ f(x) = ${o}`,deltaX:l,tableOfSign:this._getSigns(l),position:this._getHorizontalAsymptoteRelativePositon(l)})}else if(a.greater(i))t.push({fx:new r.Polynom("0"),type:s.ASYMPTOTE.HORIZONTAL,tex:"y=0",display:"y=0",zero:null,limits:"\\lim_{x\\to\\infty}\\ f(x) = 0",deltaX:null,tableOfSign:null,position:this._getHorizontalAsymptoteRelativePositon(this.fx)});else if(i.value-1===a.value){let{quotient:i,reminder:o}=e.euclidian(),r=new n.Rational(o,e.denominator);t.push({fx:i.clone(),type:s.ASYMPTOTE.SLOPE,tex:`y=${i.tex}`,display:`y=${i.display}`,zero:null,limits:"",deltaX:new n.Rational(o,e.denominator),tableOfSign:this._getSigns(r),position:this._getHorizontalAsymptoteRelativePositon(r)})}return t}_getHorizontalAsymptoteRelativePositon(e,t=1e6){let i=[],n=e.evaluateAsNumeric(-t),o=e.evaluateAsNumeric(t);return n>=0?i.push(s.ASYMPTOTE_POSITION.LT):i.push(s.ASYMPTOTE_POSITION.LB),o>=0?i.push(s.ASYMPTOTE_POSITION.RT):i.push(s.ASYMPTOTE_POSITION.RB),i}makeDerivative(){let e=this.fx.clone().derivative(),t=this._getSigns(e,this._getZeroes(e),s.TABLE_OF_SIGNS.GROWS),i=this.makeGrowsResult(t);return t.signs.push(i.growsLine),t.extremes=i.extremes,t}makeVariation(){let e=this.derivative.fx.clone().derivative(),t=this._getSigns(e,this._getZeroes(e),s.TABLE_OF_SIGNS.VARIATIONS),i=this.makeVariationsResult(t);return t.signs.push(i.varsLine),t.extremes=i.extremes,t}_getZeroes(e){let t=[];return e.numerator.getZeroes().filter((e=>!isNaN(e.value))).forEach((e=>{t.push({tex:e.tex,display:e.display,value:e.value,exact:e.exact,extrema:s.FUNCTION_EXTREMA.NOTHING,type:s.ZEROTYPE.ZERO})})),e.denominator.getZeroes().filter((e=>!isNaN(e.value))).forEach((e=>{let i=this.indexOfZero(t,e);-1!==i?t[i].type=s.ZEROTYPE.DEFENCE:t.push({tex:e.tex,display:e.display,value:e.value,exact:e.exact,extrema:s.FUNCTION_EXTREMA.NOTHING,type:s.ZEROTYPE.DEFENCE})})),t.sort(((e,t)=>e.value-t.value)),t}_getSigns(e,t,i){let n=[],o=[];return void 0===t&&(t=this._getZeroes(e)),e.numerator.factors.forEach((e=>{n.push(this.makeOneLineForSigns(e,t,s.ZEROTYPE.ZERO)),o.push(e.clone())})),e.denominator.factors.forEach((e=>{n.push(this.makeOneLineForSigns(e,t,s.ZEROTYPE.DEFENCE)),o.push(e.clone())})),n.push(this.makeSignsResult(n)),{type:i,fx:e,factors:o,zeroes:t,signs:n,extremes:{},tex:""}}}t.RationalStudy=a},506:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fraction=void 0;const s=i(956);class n{constructor(e,t){return this.isApproximative=()=>this._numerator.toString().length>=15&&this._denominator.toString().length>=15,this.isExact=()=>!this.isApproximative(),this.parse=(e,t)=>{let i;if(null===e||""===e)return this._numerator=0,this._denominator=1,this;switch(typeof e){case"string":if(i=e.split("/"),i.length>2)throw e+" has too many divide signs";if(i.map((e=>""===e||isNaN(Number(e)))).includes(!0))throw e+" is not a valid number";if(1===i.length)return this.parse(+i[0]);2===i.length?"0"===i[1]?(this._numerator=NaN,this._denominator=1):(this._numerator=+i[0],this._denominator=+i[1]):(this._numerator=NaN,this._denominator=1);break;case"number":if(Number.isSafeInteger(e))this._numerator=+e,void 0!==t&&Number.isSafeInteger(t)?this._denominator=+t:this._denominator=1;else{let[i,s]=e.toString().split("."),n=s?s.length:0;void 0===t?(this._numerator=e*Math.pow(10,n),this._denominator=Math.pow(10,n)):Number.isSafeInteger(t)&&(this._numerator=e*Math.pow(10,n)-Math.floor(e*Math.pow(10,n-t)),this.denominator=Math.pow(10,n)-Math.pow(10,n-t)),this.reduce()}break;case"object":e instanceof n&&(this._numerator=+e.numerator,this._denominator=+e.denominator)}return this},this.clone=()=>{let e=new n;return e.numerator=+this._numerator,e.denominator=+this._denominator,e},this.zero=()=>(this._numerator=0,this._denominator=1,this),this.one=()=>(this._numerator=1,this._denominator=1,this),this.infinite=()=>(this._numerator=1/0,this._denominator=1,this),this.invalid=()=>(this._numerator=NaN,this._denominator=1,this),this.opposed=()=>(this._numerator=-this._numerator,this),this.add=e=>{if(!(e instanceof n))return this.add(new n(e));{let t=this._numerator,i=this._denominator;this._numerator=t*e.denominator+e.numerator*i,this._denominator=i*e.denominator}return this.reduce()},this.subtract=e=>e instanceof n?this.add(e.clone().opposed()):this.add(-e),this.multiply=e=>{let t=new n(e);return this._numerator=this._numerator*t.numerator,this._denominator=this._denominator*t.denominator,this.reduce()},this.xMultiply=(...e)=>{for(let t of e){let e=new n(t);this._numerator=this._numerator*e.numerator,this._denominator=this._denominator*e.denominator}return this},this.divide=e=>{let t=new n(e);if(0===t.numerator)return(new n).infinite();let i=+this._numerator,s=+this._denominator;return this._numerator=i*t.denominator,this._denominator=s*t.numerator,this.reduce()},this.invert=()=>{let e=+this._numerator,t=+this._denominator;return this._numerator=t,this._denominator=e,this},this.pow=e=>{if(e instanceof n)return this.pow(e.value);this.reduce(),e<0&&this.invert();let t=Math.floor(Math.pow(this._numerator,Math.abs(e)));return Math.floor(Math.pow(this._denominator,Math.abs(e))),t**Math.abs(e)===this._numerator&&(Math.abs(e),this._denominator),this._numerator=this._numerator**Math.abs(e),this._denominator=this._denominator**Math.abs(e),this},this.root=e=>(0===e||(e<0&&this.invert(),Math.pow(this._numerator,Math.abs(1/e)),Math.pow(this._denominator,Math.abs(1/e)),this._numerator=Math.pow(this._numerator,Math.abs(1/e)),this._denominator=Math.pow(this._denominator,Math.abs(1/e))),this),this.sqrt=()=>this.root(2),this.abs=()=>(this._numerator=Math.abs(this._numerator),this._denominator=Math.abs(this._denominator),this),this.reduce=()=>{let e=s.Numeric.gcd(this._numerator,this._denominator);return this._numerator=this._numerator/e,this._denominator=this._denominator/e,this._denominator<0&&(this._denominator=-this._denominator,this._numerator=-this._numerator),this},this.amplify=e=>(Number.isSafeInteger(e)&&(this._numerator*=e,this._denominator*=e),this),this.compare=(e,t)=>{let i;switch(void 0===t&&(t="="),i=e instanceof n?e.clone():new n(e),t){case">":return this.value>i.value;case">=":return this.value>=i.value;case"<":return this.value<i.value;case"<=":return this.value<=i.value;case"=":return this.value===i.value;case"<>":return this.value!==i.value;default:return!1}},this.lesser=e=>this.compare(e,"<"),this.leq=e=>this.compare(e,"<="),this.greater=e=>this.compare(e,">"),this.geq=e=>this.compare(e,">="),this.isEqual=e=>this.compare(e,"="),this.isNotEqual=e=>this.compare(e,"<>"),this.isOpposed=e=>this.isEqual(e.clone().opposed()),this.isInverted=e=>this.isEqual((new n).one().divide(e.clone())),this.isZero=()=>0===this._numerator,this.isNotZero=()=>0!==this._numerator,this.isOne=()=>1===this._numerator&&1===this._denominator,this.isNegativeOne=()=>-1===this._numerator&&1===this._denominator,this.isPositive=()=>1===this.sign(),this.isNegative=()=>-1===this.sign(),this.isStrictlyPositive=()=>this.value>0,this.isStrictlyNegative=()=>this.value<0,this.isNaN=()=>isNaN(this._numerator),this.isInfinity=()=>Math.abs(this._numerator)===1/0,this.isFinite=()=>!this.isInfinity()&&!this.isNaN(),this.isSquare=()=>Math.sqrt(this._numerator)%1==0&&Math.sqrt(this._denominator)%1==0,this.isReduced=()=>1===Math.abs(s.Numeric.gcd(this._numerator,this._denominator)),this.isNatural=()=>this.isRelative()&&this.isPositive(),this.isRelative=()=>1===this.clone().reduce().denominator,this.isRational=()=>!this.isRelative(),this.isEven=()=>this.isRelative()&&this.value%2==0,this.isOdd=()=>this.isRelative()&&this.value%2==1,this.sign=()=>this._numerator*this._denominator>=0?1:-1,this.areEquals=(...e)=>{for(let t=0;t<e.length;t++)if(!this.isEqual(e[t]))return!1;return!0},this._numerator=1,this._denominator=1,void 0!==e&&this.parse(e,t),this}get numerator(){return this._numerator}set numerator(e){this._numerator=e}get denominator(){return this._denominator}set denominator(e){this._denominator=e}get value(){return this._numerator/this._denominator}get tex(){return this.isInfinity()?(1===this.sign()?"+":"-")+"\\infty":this.isExact()?1===this._denominator?`${this._numerator}`:this._numerator<0?`-\\frac{ ${-this._numerator} }{ ${this._denominator} }`:`\\frac{ ${this._numerator} }{ ${this._denominator} }`:this.value.toFixed(3)}get texWithSign(){return this.isPositive()?`+${this.tex}`:this.tex}get display(){return this.isExact()?1===this._denominator?`${this._numerator}`:`${this._numerator}/${this._denominator}`:this.value.toFixed(3)}get frac(){return this.tex}get dfrac(){return this.tex.replace("\\frac","\\dfrac")}get tfrac(){return this.tex.replace("\\frac","\\tfrac")}}t.Fraction=n,n.max=(...e)=>{let t=new n(e[0]);for(let i of e){let e=new n(i);e.greater(t)&&(t=e.clone())}return t},n.min=(...e)=>{let t=new n(e[0]);for(let i of e){let e=new n(i);e.lesser(t)&&(t=e.clone())}return t},n.average=(...e)=>{let t=(new n).zero();for(let i of e)t.add(i);return t.divide(e.length),t},n.unique=(e,t)=>{let i={},s=[];return e.forEach((e=>{i[e.clone().reduce().tex]||(s.push(e.clone()),i[e.tex]=!0)})),t?n.sort(s):s},n.sort=(e,t)=>{let i=e.sort(((e,t)=>e.value-t.value));return t&&i.reverse(),i}},872:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NthRoot=void 0,t.NthRoot=class{constructor(...e){this.parse=(e,t,i)=>(this._coefficient=void 0===i?1:i,this._nth=void 0===t?2:t,this._radical=void 0===e?1:e,this._nth%2==0&&this._radical<0&&(this._isValid=!1),this),this.reduce=()=>{let e=Math.floor(Math.pow(this._radical,1/this._nth));for(;e>1;)this._radical%Math.pow(e,this._nth)!=0?e--:(this._coefficient*=e,this._radical=this._radical/Math.pow(e,this._nth),e=Math.floor(Math.pow(this._radical,1/this._nth)));return this},this.multiply=e=>(this._radical*=e.radical,this.reduce()),this.hasRadical=()=>!(1===this._radical||0===this._radical||!1===this._isValid),this._radical=1,this._coefficient=1,this._nth=2,this._isValid=!0,void 0!==e&&this.parse(e[0],e[1],e[2])}get radical(){return this._radical}set radical(e){this._radical=e}get nth(){return this._nth}set nth(e){Number.isSafeInteger(e)&&e>=2?this._nth=e:(console.log("Error setting the nth root"),this._nth=2)}get coefficient(){return this._coefficient}set coefficient(e){this._coefficient=e}get tex(){let e;return e=1===this._coefficient?"":-1===this._coefficient?"-":this._coefficient.toString(),1===this._radical?`${this._coefficient}`:2===this._nth?`${e}\\sqrt{${this._radical}}`:`${e}\\sqrt[${this._nth}]{${this._radical}}`}get display(){let e;return e=1===this._coefficient?"":-1===this._coefficient?"-":this._coefficient.toString(),1===this._radical?`${this._coefficient}`:2===this._nth?`${e}sqrt{${this._radical}}`:`${e}root(${this._nth}){${this._radical}}`}get value(){return this._coefficient*Math.pow(this._radical,1/this._nth)}}},699:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Circle=void 0;const s=i(557),n=i(9),o=i(586),r=i(164),a=i(956),l=i(506),h=i(760),c=i(38);class u{constructor(...e){this.relativePosition=e=>{let t=e.distanceTo(this.center),i=Math.sqrt(this._squareRadius.value);return t.value-i>1e-10?0:Math.abs(t.value-i)<1e-10?1:2},this.lineIntersection=e=>{let t,i=[];if(null===this._cartesian)return[];const n=this._cartesian.clone(),o=e.equation.clone().isolate("x"),r=e.equation.clone().isolate("y");if(o instanceof h.Equation&&r instanceof h.Equation){n.replaceBy("y",r.right).simplify(),n.solve();for(let e of n.solutions)!1===e.exact&&isNaN(e.value)||(t=new l.Fraction(!1===e.exact?e.value:e.exact),i.push(new s.Point(t.clone(),r.right.evaluate(t))))}return i},this.tangents=e=>e instanceof l.Fraction?this._tangentsWithSlope(e):this.isPointOnCircle(e)?this._tangentsThroughOnePointOnTheCircle(e):this.center.distanceTo(e).value>this.radius.value?this._tangentsThroughOnePointOutsideTheCircle(e):(console.log("No tangents as the point is inside !"),[]),this.isPointOnCircle=e=>this._cartesian.test({x:e.x,y:e.y}),this.getPointsOnCircle=e=>{void 0===e&&(e=!1);let t,i=a.Numeric.pythagoricianTripletsWithTarget(this._squareRadius.value,!0),n=[];return i.forEach((e=>{for(let i of[[1,1],[-1,1],[-1,-1],[1,-1]])t=new s.Point(this.center.x.clone().add(i[0]*e[0]),this.center.y.clone().add(i[1]*e[1])),t.isInListOfPoints(n)||n.push(t)})),n},this._tangentsThroughOnePointOnTheCircle=e=>{let t=new o.Vector(this._center,e);return[new n.Line(e,t,n.LinePropriety.Perpendicular)]},this._tangentsThroughOnePointOutsideTheCircle=e=>{let t=this.center.x.clone().subtract(e.x),i=this.center.y.clone().subtract(e.y),s=new c.Polynom("x"),o=new c.Polynom("x^2+1");s.multiply(t).subtract(i).pow(2),o.multiply(this.squareRadius);let r=new h.Equation(s,o);return r.moveLeft().simplify().solve(),r.solutions.map((t=>{let i,s=new h.Equation("y","x");return t.exact instanceof l.Fraction?(i=e.x.clone().opposed().multiply(t.exact).add(e.y),s.right.multiply(t.exact).add(i)):(i=e.x.clone().opposed().multiply(t.value).add(e.y),s.right.multiply(t.value).add(i)),new n.Line(s)}))},this._tangentsWithSlope=e=>{const t=e.numerator,i=-e.denominator,s=this._center.x.clone(),o=this._center.y.clone();this._squareRadius;let r=this._squareRadius.clone().multiply(e.numerator**2+e.denominator**2),a=s.clone().multiply(t).opposed().subtract(o.clone().multiply(i)).add(r.clone().sqrt()),l=s.clone().multiply(t).opposed().subtract(o.clone().multiply(i)).subtract(r.clone().sqrt());return[new n.Line(t,i,a),new n.Line(t,i,l)]},this._exists=!1,void 0!==e&&this.parse(...e)}get center(){return this._center}get squareRadius(){return this._squareRadius}get cartesian(){return this._cartesian}get exists(){return this._exists}get radius(){return this._squareRadius.isSquare()?{tex:this._squareRadius.clone().sqrt().tex,display:this._squareRadius.clone().sqrt().display,value:this._squareRadius.clone().sqrt().value}:{tex:`\\sqrt{${this._squareRadius.tex}}`,display:`sqrt(${this._squareRadius.display})`,value:this._squareRadius.clone().sqrt().value}}get tex(){if(this._exists){let e,t;return e=this._center.x.isZero()?"x^2":`\\left(x${this._center.x.isNegative()?"+":"-"}${this._center.x.clone().abs().tex}\\right)^2`,t=this._center.y.isZero()?"y^2":`\\left(y${this._center.y.isNegative()?"+":"-"}${this._center.y.clone().abs().tex}\\right)^2`,`${e}+${t}=${this._squareRadius.tex}`}return"\\text{le cercle n'existe pas.}"}get developed(){return this._cartesian.tex}get display(){if(this._exists){let e,t;return e=this._center.x.isZero()?"x^2":`(x${this._center.x.isNegative()?"+":"-"}${this._center.x.clone().abs().tex})^2`,t=this._center.y.isZero()?"y^2":`(y${this._center.y.isNegative()?"+":"-"}${this._center.y.clone().abs().tex})^2`,`${e}+${t}=${this._squareRadius.display}`}return"\\text{le cercle n'existe pas.}"}clone(){return this._center=this._center.clone(),this._squareRadius=this._squareRadius.clone(),this._calculateCartesian(),this}_reset(){return this._center=null,this._squareRadius=null,this._cartesian=null,this._exists=!1,this}parse(...e){return this._reset(),"string"==typeof e[0]?this._parseEquation(new h.Equation(e[0])):e[0]instanceof h.Equation?this._parseEquation(e[0]):e[0]instanceof u?this._parseCopyCircle(e[0]):e[0]instanceof s.Point&&e.length>1&&(e[1]instanceof s.Point?e[2]instanceof s.Point?this._parseThroughtThreePoints(e[0],e[1],e[2]):this._parseCenterAndPointThrough(e[0],e[1]):(e[1]instanceof l.Fraction||"number"==typeof e[1])&&this._parseCenterAndRadius(e[0],e[1],"boolean"==typeof e[2]&&e[2])),this._exists&&(this._calculateCartesian(),void 0!==this._squareRadius&&this._squareRadius.isNegative()&&(this._exists=!1)),this}_calculateCartesian(){this._cartesian=new h.Equation(new c.Polynom(`(x-(${this._center.x.display}))^2+(y-(${this._center.y.display}))^2`),new c.Polynom(`${this._squareRadius.display}`)).moveLeft()}_parseCopyCircle(e){return this._center=e.center.clone(),this._squareRadius=e.squareRadius.clone(),this._calculateCartesian(),this._exists=e.exists,this}_parseCenterAndRadius(e,t,i){return this._center=e.clone(),this._squareRadius=i?new l.Fraction(t):new l.Fraction(t).pow(2),this._exists=!0,this}_parseCenterAndPointThrough(e,t){return this._center=e.clone(),this._squareRadius=new o.Vector(this._center,t).normSquare,this._exists=!0,this}_parseEquation(e){if(this._exists=!1,e.moveLeft(),2===e.degree("x").value&&2===e.degree("y").value){let t,i,n,o=e.left.monomByDegree(2,"x"),r=e.left.monomByDegree(2,"y");o.coefficient.isEqual(r.coefficient)?(e.divide(o.coefficient),t=e.left.monomByDegree(1,"x"),i=e.left.monomByDegree(1,"y"),n=e.left.monomByDegree(0),this._center=new s.Point(t.coefficient.clone().divide(2).opposed(),i.coefficient.clone().divide(2).opposed()),this._squareRadius=n.coefficient.clone().opposed().add(this._center.x.clone().pow(2)).add(this._center.y.clone().pow(2)),this._calculateCartesian(),this._exists=!0):(this._center=null,this._squareRadius=null,this._exists=!1)}return this}_parseThroughtThreePoints(e,t,i){let s=new r.Triangle(e,t,i),n=s.remarquables.mediators.AB.clone(),o=s.remarquables.mediators.AC.clone();return this.parse(n.intersection(o).point,e),this}}t.Circle=u},9:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Line=t.LinePropriety=void 0;const s=i(586),n=i(557),o=i(956),r=i(506),a=i(760),l=i(38),h=i(330),c=i(937);var u;!function(e){e[e.None=0]="None",e.Parallel="parallel",e.Perpendicular="perpendicular",e.Tangent="tangent"}(u||(t.LinePropriety=u={}));class d{constructor(...e){return this.randomPoint=e=>this._d.clone().multiplyByScalar(h.Random.numberSym(void 0===e||e<=1?3:e,!1)).add(this._OA.asVector).asPoint,this.randomNearPoint=e=>{let t=this.randomPoint(e),i=10;for(;this.isOnLine(t)&&i>0;)t.x.add(h.Random.numberSym(1,!1)),t.y.add(h.Random.numberSym(1,!1)),i--;return t},this.parse=(...e)=>{if(this._exists=!1,0===e.length)return this;if(1===e.length){if(e[0]instanceof d)return e[0].clone();if(e[0]instanceof a.Equation)return this.parseEquation(e[0]);if("string"==typeof e[0])try{let t=new a.Equation(e[0]);return this.parse(t)}catch(e){return this}}if(2===e.length){if(e[0]instanceof n.Point&&e[1]instanceof s.Vector)return this.parseByPointAndVector(e[0],e[1]);if(e[0]instanceof n.Point&&e[1]instanceof n.Point)return this.parseByPointAndVector(e[0],new s.Vector(e[0],e[1]));if(e[0]instanceof s.Vector&&e[1]instanceof n.Point)return this.parseByPointAndNormal(e[1],e[0])}if(3===e.length){if((e[0]instanceof r.Fraction||"number"==typeof e[0])&&(e[1]instanceof r.Fraction||"number"==typeof e[1])&&(e[2]instanceof r.Fraction||"number"==typeof e[2]))return this.parseByCoefficient(e[0],e[1],e[2]);if(e[0]instanceof n.Point&&e[1]instanceof s.Vector){if(e[2]===u.Perpendicular)return this.parseByPointAndNormal(e[0],e[1]);if(e[2]===u.Parallel)return this.parseByPointAndVector(e[0],e[1])}else if(e[0]instanceof n.Point&&e[1]instanceof d)return e[2]===u.Parallel||null===e[2]?this.parseByPointAndLine(e[0],e[1],u.Parallel):this.parseByPointAndLine(e[0],e[1],u.Perpendicular)}return console.log("Someting wrong happend while creating the line"),this},this.parseEquation=e=>{e.reorder(!0);let t=new Set(e.letters());if(!t.has("x")&&!t.has("y"))return this;for(let e of["x","y"])t.has(e)&&t.delete(e);return t.size>0?this:this.parseByCoefficient(e.left.monomByLetter("x").coefficient,e.left.monomByLetter("y").coefficient,e.left.monomByDegree(0).coefficient)},this.parseByCoefficient=(e,t,i)=>(this._a=new r.Fraction(e),this._b=new r.Fraction(t),this._c=new r.Fraction(i),this._d=new s.Vector(this._b.clone(),this._a.clone().opposed()),this._OA=new n.Point((new r.Fraction).zero(),this._c.clone()),this._n=this._d.clone().normal(),this._exists=!0,this),this.parseByPointAndVector=(e,t)=>(this.parseByCoefficient(t.y,t.x.clone().opposed(),e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposed()),this._OA=e.clone(),this._d=t.clone(),this._n=this._d.clone().normal(),this._exists=!0,this),this.parseByPointAndNormal=(e,t)=>this.parseByCoefficient(t.x,t.y,e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposed()),this.parseByPointAndLine=(e,t,i)=>(void 0===i&&(i=u.Parallel),i===u.Parallel?this.parseByPointAndNormal(e,t.normal):i===u.Perpendicular?this.parseByPointAndNormal(e,t.director):(this._exists=!1,this)),this.clone=()=>(this._a=this._a.clone(),this._b=this._b.clone(),this._c=this._c.clone(),this._d=this._d.clone(),this._OA=this._OA.clone(),this._n=this._n.clone(),this._exists=this.exists,this),this.isOnLine=e=>this._a.clone().multiply(e.x).add(this._b.clone().multiply(e.y)).add(this._c).isZero(),this.isParallelTo=e=>this.slope.isEqual(e.slope)&&this.height.isNotEqual(e.height),this.isSameAs=e=>this.slope.isEqual(e.slope)&&this.height.isEqual(e.height),this.isPerpendicularTo=e=>this.d.isNormalTo(e.d),this.isVertical=()=>this.slope.isInfinity(),this.simplify=()=>{let e=o.Numeric.lcm(this._a.denominator,this._b.denominator,this._c.denominator),t=o.Numeric.gcd(this._a.numerator,this._b.numerator,this._c.numerator);return this.parseByCoefficient(this._a.clone().multiply(e).divide(t),this._b.clone().multiply(e).divide(t),this._c.clone().multiply(e).divide(t)),this},this.simplifyDirection=()=>(this._d.simplifyDirection(),this),this.intersection=e=>{let t=new n.Point,i=!1,s=!1;return this._b.isZero()||e.b.isZero(),this.isParallelTo(e)?(t.x=null,t.y=null,i=!0):this.isSameAs(e)?(t.x=null,t.y=null,s=!0):(t.x=this._b.clone().multiply(e.c).subtract(this._c.clone().multiply(e.b)).divide(this._a.clone().multiply(e.b).subtract(this._b.clone().multiply(e.a))),t.y=this._a.clone().multiply(e.c).subtract(this._c.clone().multiply(e.a)).divide(this._b.clone().multiply(e.a).subtract(this._a.clone().multiply(e.b)))),{point:t,hasIntersection:!(i||s),isParallel:i,isSame:s}},this.getValueAtX=e=>{const t=this.equation.clone().isolate("y"),i=new r.Fraction(e);if(t instanceof a.Equation)return t.right.evaluate({x:i})},this.getValueAtY=e=>{const t=this.equation.clone().isolate("x"),i=new r.Fraction(e);if(t instanceof a.Equation)return t.right.evaluate({y:i})},this._exists=!1,this._reduceBeforeDisplay=!0,e.length>0&&this.parse(...e),this}get a(){return this._a}set a(e){this._a=e}get b(){return this._b}set b(e){this._b=e}get c(){return this._c}set c(e){this._c=e}get OA(){return this._OA}set OA(e){this._OA=e}get d(){return this._d}set d(e){this._d=e}get n(){return this._n}get exists(){return this._exists}get equation(){let e=new a.Equation((new l.Polynom).parse("xy",this._a,this._b,this._c),new l.Polynom("0"));return this._reduceBeforeDisplay?e.simplify():e}get system(){return{x:new a.Equation(new l.Polynom("x"),new l.Polynom(this._OA.x).add(new c.Monom("k").multiplyByNumber(this._d.x))),y:new a.Equation(new l.Polynom("y"),new l.Polynom(this._OA.y).add(new c.Monom("k").multiplyByNumber(this._d.y)))}}get tex(){let e=this.equation.clone().reorder(!0);this._a.isNegative()&&e.multiply(-1);let t=this._d.clone();return this._reduceBeforeDisplay&&t.simplifyDirection(),{canonical:e.tex,equation:e.clone().reorder().tex,mxh:this.slope.isInfinity()?"x="+this.OA.x.tex:"y="+(new l.Polynom).parse("x",this.slope,this.height).tex,parametric:`${n.Point.pmatrix("x","y")} = ${n.Point.pmatrix(this._OA.x,this._OA.y)} + k\\cdot ${n.Point.pmatrix(t.x,t.y)}`,system:`\\left\\{\\begin{aligned}\n x &= ${new l.Polynom(this._OA.x).add(new c.Monom(this._d.x).multiply(new c.Monom("k"))).reorder("k",!0).tex}\\\\ \n y &= ${new l.Polynom(this._OA.y).add(new c.Monom(this._d.y).multiply(new c.Monom("k"))).reorder("k",!0).tex}\n \\end{aligned}\\right.`}}get reduceBeforeDisplay(){return this._reduceBeforeDisplay}set reduceBeforeDisplay(e){this._reduceBeforeDisplay=e}get display(){let e=this.equation;return this._a.isNegative()&&e.multiply(-1),{canonical:e.display,mxh:this.slope.isInfinity()?"x="+this.OA.x.display:"y="+(new l.Polynom).parse("x",this.slope,this.height).display,parametric:""}}get normal(){return new s.Vector(this._a,this._b)}get director(){return this._d.clone()}get slope(){return this._a.clone().opposed().divide(this._b)}get height(){return this._c.clone().opposed().divide(this._b)}distanceTo(e){let t=e.x.clone().multiply(this._a).add(e.y.clone().multiply(this._b)).add(this._c).abs(),i=this.normal.normSquare;if(i.isZero())return{value:NaN,tex:"Not a line",fraction:(new r.Fraction).infinite()};let s=t.value/Math.sqrt(i.value),n=t.clone().divide(i.clone().sqrt());return i.isSquare()?{value:s,tex:n.tex,fraction:n}:{value:s,tex:`\\frac{${t.tex}}{\\sqrt{${i.tex}}}`,fraction:n}}hitSegment(e,t){let i=this.intersection(new d(e,t));return!!i.hasIntersection&&i.point.x.value>=Math.min(e.x.value,t.x.value)&&i.point.x.value<=Math.max(e.x.value,t.x.value)&&i.point.y.value>=Math.min(e.y.value,t.y.value)&&i.point.y.value<=Math.max(e.y.value,t.y.value)}canonicalAsFloatCoefficient(e){void 0===e&&(e=2),this._a.value,this._b.value,this._c.value;let t="";return this._a.isZero()||(t=this._a.isOne()?"x":this._a.clone().opposed().isOne()?"-x":this._a.value.toFixed(e)+"x"),this._b.isZero()||(this._b.isPositive()&&(t+="+"),t+=this._b.value.toFixed(e)+"y"),this._c.isZero()||(this._c.isPositive()&&(t+="+"),t+=this._c.value.toFixed(e)),t+"=0"}}t.Line=d,d.PERPENDICULAR=u.Perpendicular,d.PARALLEL=u.Parallel},557:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Point=void 0;const s=i(9),n=i(586),o=i(506);class r{}class a{constructor(...e){return this.parse=(...e)=>{if(this.zero(),0===e.length)return this;if(1===e.length){if(e[0]instanceof a)return this._x=e[0].x.clone(),this._y=e[0].y.clone(),this;if("string"==typeof e[0]){let t=e[0].split(",");if(2===t.length)return this._x=new o.Fraction(t[0]).reduce(),this._y=new o.Fraction(t[1]).reduce(),this}return e[0]instanceof r?(this._x=new o.Fraction(e[0].x).reduce(),this._y=new o.Fraction(e[0].y).reduce(),this):this.zero()}return 2===e.length?(this._x=new o.Fraction(e[0]).reduce(),this._y=new o.Fraction(e[1]).reduce(),this):this},this.clone=()=>(this._x=this._x.clone(),this._y=this._y.clone(),this),this.zero=()=>(this._x=new o.Fraction(null),this._y=new o.Fraction(null),this),this.origin=()=>(this.zero(),this),this.middleOf=(e,t)=>(this._x=e.x.clone().add(t.x).divide(2),this._y=e.y.clone().add(t.y).divide(2),this),this.texValues=e=>{let t=[];return t.push(this._x.value.toFixed(void 0===e?2:e)),t.push(this._y.value.toFixed(void 0===e?2:e)),`\\left(${t.join(";")}\\right)`},this.distanceTo=e=>{let t=0,i=new o.Fraction,r="";if(e instanceof s.Line)return e.distanceTo(this);if(e instanceof a){let s=new n.Vector(this,e);t=s.norm,i=s.normSquare.sqrt(),r=s.normSquare.isSquare()?i.tex:`\\sqrt{\\frac{ ${s.normSquare.numerator} }{ ${s.normSquare.denominator} }}`}return{value:t,fraction:i,tex:r}},this.isInListOfPoints=e=>e.map((e=>e.key)).includes(this.key),this._x=(new o.Fraction).zero(),this._y=(new o.Fraction).zero(),void 0!==e&&this.parse(...e),this}get x(){return this._x}set x(e){this._x=e}get y(){return this._y}set y(e){this._y=e}get tex(){let e=[];return e.push(this._x.tex),e.push(this._y.tex),`\\left(${e.join(";")}\\right)`}get display(){let e=[];return e.push(this._x.tex),e.push(this._y.tex),`(${e.join(";")})`}get asVector(){return new n.Vector(this.x,this.y)}get key(){return`${this.x.display};${this.y.display}`}}t.Point=a,a.pmatrix=(e,t,i)=>void 0===i?`\\begin{pmatrix} ${e.tex?e.tex:e} \\\\ ${t.tex?t.tex:t} \\end{pmatrix}`:`\\begin{pmatrix} ${e.tex?e.tex:e} \\\\ ${t.tex?t.tex:t} \\\\ ${i.tex?i.tex:i} \\end{pmatrix}`},164:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Triangle=void 0;const s=i(557),n=i(506),o=i(586),r=i(9),a=i(760);class l{constructor(...e){return this.parse=(...e)=>{if(6===e.length){let t=e.map((e=>new n.Fraction(e)));return this.parse(new s.Point(t[0],t[1]),new s.Point(t[2],t[3]),new s.Point(t[4],t[5]))}if(3===e.length){if(3===e.filter((e=>"string"==typeof e)).length)return this.parse(...e.map((e=>new r.Line(e))));if(3===e.filter((e=>e instanceof r.Line)).length){this._lines={AB:e[0],BC:e[1],AC:e[2]};let t=e[0].intersection(e[1]);if(!t.hasIntersection)return this;if(this._B=t.point.clone(),t=e[1].intersection(e[2]),!t.hasIntersection)return this;if(this._C=t.point.clone(),t=e[2].intersection(e[0]),!t.hasIntersection)return this;this._A=t.point.clone()}else{if(e.filter((e=>e instanceof s.Point)).length<3)return this.parse(new s.Point(e[0]),new s.Point(e[1]),new s.Point(e[2]));this._A=e[0].clone(),this._B=e[1].clone(),this._C=e[2].clone(),this._lines={AB:new r.Line(this._A,this._B),BC:new r.Line(this._B,this._C),AC:new r.Line(this._A,this._C)}}}else if(1===e.length&&e[0]instanceof l)return e[0].clone();return this._updateTriangle(),this},this.clone=()=>(this._A=this._A.clone(),this._B=this._B.clone(),this._C=this._C.clone(),this._lines={AB:this._lines.AB.clone(),BC:this._lines.BC.clone(),AC:this._lines.AC.clone()},this._updateTriangle(),this),this._updateTriangle=()=>{this._middles={AB:(new s.Point).middleOf(this._A,this._B),AC:(new s.Point).middleOf(this._A,this._C),BC:(new s.Point).middleOf(this._B,this._C)},this._remarquables=this._calculateRemarquableLines()},this.getPointByName=e=>{switch(e.toUpperCase()){case"A":return this._A;case"B":return this._B;case"C":return this._C}return this._A},this.getSegment=(e,t)=>new o.Vector(this.getPointByName(e),this.getPointByName(t)),this._calculateRemarquableLines=()=>{let e={medians:{A:new r.Line(this._A,this._middles.BC),B:new r.Line(this._B,this._middles.AC),C:new r.Line(this._C,this._middles.AB),intersection:null},mediators:{AB:new r.Line(this._middles.AB,new o.Vector(this._A,this._B).normal()),AC:new r.Line(this._middles.AC,new o.Vector(this._A,this._C).normal()),BC:new r.Line(this._middles.BC,new o.Vector(this._B,this._C).normal()),intersection:null},heights:{A:new r.Line(this._A,new o.Vector(this._B,this._C).normal()),B:new r.Line(this._B,new o.Vector(this._A,this._C).normal()),C:new r.Line(this._C,new o.Vector(this._A,this._B).normal()),intersection:null},bisectors:{A:this._calculateBisectors("A"),B:this._calculateBisectors("B"),C:this._calculateBisectors("C"),intersection:null}};return e.medians.intersection=e.medians.A.intersection(e.medians.B).point,e.mediators.intersection=e.mediators.AB.intersection(e.mediators.BC).point,e.heights.intersection=e.heights.A.intersection(e.heights.B).point,e.bisectors.intersection=e.bisectors.A.intersection(e.bisectors.B).point,e},this._calculateBisectors=e=>{let t,i,s=this.lines;"A"===e?(t=s.AB,i=s.AC):"B"===e?(t=s.AB,i=s.BC):"C"===e&&(t=s.BC,i=s.AC);let n=new r.Line(new a.Equation(t.equation.left.clone().multiply(i.n.simplify().norm),i.equation.left.clone().multiply(t.n.simplify().norm)).reorder(!0).simplify()),o=new r.Line(new a.Equation(t.equation.left.clone().multiply(i.n.simplify().norm),i.equation.left.clone().multiply(t.n.simplify().norm).opposed()).reorder(!0).simplify());return"A"===e?n.hitSegment(this.B,this.C)?n:o:"B"===e?n.hitSegment(this.A,this.C)?n:o:"C"===e?n.hitSegment(this.B,this.A)?n:o:n},e.length>0&&this.parse(...e),this}get A(){return this._A}get B(){return this._B}get C(){return this._C}get AB(){return this.getSegment("A","B")}get BA(){return this.getSegment("B","A")}get BC(){return this.getSegment("B","C")}get CB(){return this.getSegment("C","B")}get AC(){return this.getSegment("A","C")}get CA(){return this.getSegment("C","A")}get isRectangle(){return!!this.AB.isNormalTo(this.BC)||!!this.AB.isNormalTo(this.AC)||!!this.BC.isNormalTo(this.AC)}get isEquilateral(){return this.AB.normSquare.isEqual(this.BC.normSquare)&&this.AB.normSquare.isEqual(this.AC.normSquare)}get isIsocele(){return this.AB.normSquare.isEqual(this.BC.normSquare)||this.AB.normSquare.isEqual(this.AC.normSquare)||this.BC.normSquare.isEqual(this.AC.normSquare)}get lines(){return this._lines}get remarquables(){return this._remarquables}}t.Triangle=l},586:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Vector=void 0;const s=i(506),n=i(956),o=i(557);class r{constructor(...e){this.parse=(...e)=>{if(this.zero(),0===e.length)return this;if(1===e.length)return e[0]instanceof r?e[0].clone():this._parseString(e[0]);if(e.length>=2){if(e[0]instanceof o.Point&&e[1]instanceof o.Point)return this._x=e[1].x.clone().subtract(e[0].x),this._y=e[1].y.clone().subtract(e[0].y),this;(e[0]instanceof s.Fraction||!isNaN(e[0]))&&(this._x=new s.Fraction(e[0])),(e[1]instanceof s.Fraction||!isNaN(e[1]))&&(this._y=new s.Fraction(e[1])),"object"!=typeof e[0]||isNaN(e[0].x)||isNaN(e[0].x)||"object"!=typeof e[1]||isNaN(e[1].x)||isNaN(e[1].x)||(this._x=new s.Fraction(+e[1].x-e[0].x),this._y=new s.Fraction(+e[1].y-e[0].y))}return this},this.clone=()=>{let e=new r;return null!==this._x&&(e.x=this._x.clone()),null!==this._y&&(e.y=this._y.clone()),e},this.reset=()=>(this._x=null,this._y=null,this),this.zero=()=>(this.reset(),this._x=new s.Fraction(null),this._y=new s.Fraction(null),this),this.one=()=>(this._x=new s.Fraction,this._y=new s.Fraction,this),this._parseString=e=>{let t=e.split(/[,;\s]/g);return this.x=new s.Fraction(t[0]||null),this.y=new s.Fraction(t[1]||null),this},this.opposed=()=>(this._x.opposed(),this._y.opposed(),this),this.add=e=>(this._x.add(e.x),this._y.add(e.y),this),this.subtract=e=>this.add(e.clone().opposed()),this.scalarProductWithVector=e=>r.scalarProduct(this,e),this.determinantWithVector=e=>r.determinant(this,e),this.normal=()=>{let e=this.x.clone().opposed(),t=this.y.clone();return this._x=t,this._y=e,this},this.isColinearTo=e=>this.determinantWithVector(e).isZero(),this.isNormalTo=e=>this.scalarProductWithVector(e).isZero(),this.multiplyByScalar=e=>{let t=new s.Fraction(e);return this._x.multiply(t),this._y.multiply(t),this},this.divideByScalar=e=>this.multiplyByScalar(new s.Fraction(e).invert()),this.simplify=()=>this.multiplyByScalar(n.Numeric.lcm(this._x.denominator,this._y.denominator)).divideByScalar(n.Numeric.gcd(this._x.numerator,this._y.numerator)),this.simplifyDirection=()=>{let e=n.Numeric.lcm(this.x.denominator,this.y.denominator),t=n.Numeric.gcd(this.x.numerator,this.y.numerator);return this.x.multiply(e).divide(t),this.y.multiply(e).divide(t),this},this.angleWith=(e,t,i)=>{let s=this.scalarProductWithVector(e).value,n=i?1:180/Math.PI;return t&&(s=Math.abs(s)),n*Math.acos(s/(this.norm*e.norm))},this._x=(new s.Fraction).zero(),this._y=(new s.Fraction).zero(),void 0!==e&&this.parse(...e)}get x(){return this._x}set x(e){this._x=new s.Fraction(e)}get y(){return this._y}set y(e){this._y=new s.Fraction(e)}get normSquare(){return this._x.clone().pow(2).add(this._y.clone().pow(2))}get norm(){return Math.sqrt(this.normSquare.value)}get tex(){return`\\begin{pmatrix}${this._x.tex} \\\\ ${this._y.tex} \\end{pmatrix}`}get asPoint(){return new o.Point(this.x,this.y)}get isNull(){return this.x.isZero()&&this.y.isZero()}}t.Vector=r,r.scalarProduct=(e,t)=>e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)),r.determinant=(e,t)=>e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x))},956:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Numeric=void 0;class i{static round(e,t=2){return Number(Math.round(Number(e+"e"+t))+"e-"+t)}static primes(e){let t=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999,5003,5009,5011,5021,5023,5039,5051,5059,5077,5081,5087,5099,5101,5107,5113,5119,5147,5153,5167,5171,5179,5189,5197,5209,5227,5231,5233,5237,5261,5273,5279,5281,5297,5303,5309,5323,5333,5347,5351,5381,5387,5393,5399,5407,5413,5417,5419,5431,5437,5441,5443,5449,5471,5477,5479,5483,5501,5503,5507,5519,5521,5527,5531,5557,5563,5569,5573,5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,5683,5689,5693,5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,5801,5807,5813,5821,5827,5839,5843,5849,5851,5857,5861,5867,5869,5879,5881,5897,5903,5923,5927,5939,5953,5981,5987,6007,6011,6029,6037,6043,6047,6053,6067,6073,6079,6089,6091,6101,6113,6121,6131,6133,6143,6151,6163,6173,6197,6199,6203,6211,6217,6221,6229,6247,6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,6323,6329,6337,6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,6449,6451,6469,6473,6481,6491,6521,6529,6547,6551,6553,6563,6569,6571,6577,6581,6599,6607,6619,6637,6653,6659,6661,6673,6679,6689,6691,6701,6703,6709,6719,6733,6737,6761,6763,6779,6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,6863,6869,6871,6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,6977,6983,6991,6997,7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,7127,7129,7151,7159,7177,7187,7193,7207,7211,7213,7219,7229,7237,7243,7247,7253,7283,7297,7307,7309,7321,7331,7333,7349,7351,7369,7393,7411,7417,7433,7451,7457,7459,7477,7481,7487,7489,7499,7507,7517,7523,7529,7537,7541,7547,7549,7559,7561,7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,7673,7681,7687,7691,7699,7703,7717,7723,7727,7741,7753,7757,7759,7789,7793,7817,7823,7829,7841,7853,7867,7873,7877,7879,7883,7901,7907,7919,7927,7933,7937,7949,7951,7963,7993,8009,8011,8017,8039,8053,8059,8069,8081,8087,8089,8093,8101,8111,8117,8123,8147,8161,8167,8171,8179,8191,8209,8219,8221,8231,8233,8237,8243,8263,8269,8273,8287,8291,8293,8297,8311,8317,8329,8353,8363,8369,8377,8387,8389,8419,8423,8429,8431,8443,8447,8461,8467,8501,8513,8521,8527,8537,8539,8543,8563,8573,8581,8597,8599,8609,8623,8627,8629,8641,8647,8663,8669,8677,8681,8689,8693,8699,8707,8713,8719,8731,8737,8741,8747,8753,8761,8779,8783,8803,8807,8819,8821,8831,8837,8839,8849,8861,8863,8867,8887,8893,8923,8929,8933,8941,8951,8963,8969,8971,8999,9001,9007,9011,9013,9029,9041,9043,9049,9059,9067,9091,9103,9109,9127,9133,9137,9151,9157,9161,9173,9181,9187,9199,9203,9209,9221,9227,9239,9241,9257,9277,9281,9283,9293,9311,9319,9323,9337,9341,9343,9349,9371,9377,9391,9397,9403,9413,9419,9421,9431,9433,9437,9439,9461,9463,9467,9473,9479,9491,9497,9511,9521,9533,9539,9547,9551,9587,9601,9613,9619,9623,9629,9631,9643,9649,9661,9677,9679,9689,9697,9719,9721,9733,9739,9743,9749,9767,9769,9781,9787,9791,9803,9811,9817,9829,9833,9839,9851,9857,9859,9871,9883,9887,9901,9907,9923,9929,9931,9941,9949,9967,9973];return void 0===e?t:t.slice(0,Math.min(t.length,e))}static dividers(e){let t;const i=Math.sqrt(Math.abs(e));t=[];for(let s=1;s<=i;s++)e%s==0&&(t.push(s),t.push(e/s));return t.sort((function(e,t){return e-t})),[...new Set(t)]}static gcd(...e){let t=function(e,i){return 0===i?e:t(i,e%i)},i=1,s=2;if(0===e.length)return 1;if(1===e.length)return 0===e[0]?1:e[0];if(i=t(e[0],e[1]),1===i)return 1;for(s=2;s<e.length&&(i=t(i,e[s]),1!==i);s++);return Math.abs(i)}static divideNumbersByGCD(...e){let t=i.gcd(...e);return e.map((e=>e/t))}static lcm(...e){return e.reduce((function(e,t){return Math.abs(e*t/i.gcd(e,t))}))}static pythagoricianTripletsWithTarget(e,t){const i=[],s=!0===t?+e:e**2;for(let t=0;t<=e;t++)for(let n=0;n<=e;n++)t**2+n**2===s&&i.push([t,n,e]);return i}static numberCorrection(e,t=1,i=10,s=8){return+e.toFixed(s)}static periodic(e){return Number.isSafeInteger(e)||e.toString().split(".")[0].length<10?0:void 0}static decompose(e){let t,s,n=i.dividers(e),o=(Math.sqrt(e),[]);for(;n.length>0;)t=n.shift(),s=n.length>0?n.pop():+t,o.push([t,s]);return o}}t.Numeric=i},394:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumExp=void 0;const s=i(505),n=i(506);t.NumExp=class{constructor(e,t){this._expression=e;try{this._rpn=new s.Shutingyard(s.ShutingyardMode.NUMERIC).parse(e,t||void 0===t).rpn}catch(e){this._rpn=null,this._isValid=!1}}get rpn(){return this._rpn}get isValid(){if(void 0===this._isValid)try{this.evaluate({x:0})}catch{this._isValid=!1}return this._isValid}set isValid(e){this._isValid=e}get expression(){return this._expression}_extractDecimalPart(e){let t=e.toString();return t.includes(".")?(t=t.split(".")[1],t.substring(0,t.length-2)):""}_numberCorrection(e){const t=1e-14,i=this._extractDecimalPart(e);if(""===i)return e;const s=i.match(/9+$/g),n=i.match(/0+$/g);if(s&&s[0].length>=6){const i=this._extractDecimalPart(e+t).match(/0+$/g);if(i&&i[0].length>=6)return+(e+t).toString().split(i[0])[0]}if(n&&n[0].length>=6){const i=this._extractDecimalPart(e-t).match(/9+$/g);if(i&&i[0].length>=6)return+e.toString().split(n[0])[0]}return e}_addToStack(e,t){e.push(this._numberCorrection(t))}evaluate(e){const t=[];if(null===this._rpn)return this._isValid=!1,0;this.isValid=!0;for(const i of this._rpn)if(i.tokenType===s.ShutingyardType.COEFFICIENT)isNaN(+i.token)?this._addToStack(t,new n.Fraction(i.token).value):this._addToStack(t,+i.token);else if(i.tokenType===s.ShutingyardType.VARIABLE)void 0!==e[i.token]&&this._addToStack(t,+e[i.token]);else if(i.tokenType===s.ShutingyardType.CONSTANT)this._addToStack(t,s.tokenConstant[i.token]);else if(i.tokenType===s.ShutingyardType.OPERATION){if("*"===i.token){const e=t.pop(),i=t.pop();void 0!==i&&void 0!==e||(this.isValid=!1),this._addToStack(t,i*e)}else if("/"===i.token){const e=t.pop(),i=t.pop();void 0!==i&&void 0!==e||(this.isValid=!1),this._addToStack(t,i/e)}else if("+"===i.token){const e=t.pop(),i=t.pop();void 0!==i&&void 0!==e||(this.isValid=!1),this._addToStack(t,+i+ +e)}else if("-"===i.token){const e=t.pop(),i=t.pop()||0;void 0===e&&(this.isValid=!1),this._addToStack(t,i-e)}else if("^"===i.token){const e=t.pop(),i=t.pop();void 0!==i&&void 0!==e||(this.isValid=!1),this._addToStack(t,Math.pow(i,e))}}else if(i.tokenType===s.ShutingyardType.FUNCTION){const e=t.pop();if(void 0===e&&(this.isValid=!1),"sin"===i.token)this._addToStack(t,Math.sin(e));else if("cos"===i.token)this._addToStack(t,Math.cos(e));else if("tan"===i.token)this._addToStack(t,Math.tan(e));else if("sqrt"===i.token)this._addToStack(t,Math.sqrt(e));else if("nthrt"===i.token){let i=t.pop();e%2==0&&i<0?this._addToStack(t,NaN):this._addToStack(t,(i<0?-1:1)*Math.pow(Math.abs(i),1/e))}else"ln"===i.token?this._addToStack(t,Math.log(e)):"log"===i.token&&this._addToStack(t,Math.log10(e))}if(1===t.length)return t[0];throw`There was a problem parsing: ${this._expression}`}}},330:function(e,t,i){var s=this&&this.__createBinding||(Object.create?function(e,t,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,s,n)}:function(e,t,i,s){void 0===s&&(s=i),e[s]=t[i]}),n=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||s(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),t.Random=void 0;const o=i(22),r=i(793),a=i(140),l=i(754),h=i(821),c=i(246);var u;n(i(230),t),function(e){let t;e.polynom=function(e){return new o.rndPolynom(e).generate()},e.monom=function(e){return new r.rndMonom(e).generate()},e.fraction=function(e){return new l.rndFraction(e).generate()},e.number=function(e,t){return a.rndHelpers.randomInt(e,t)},e.numberSym=function(e,t){return a.rndHelpers.randomIntSym(e,t)},e.prime=function(e){return a.rndHelpers.randomPrime(e)},e.bool=function(e){return a.rndHelpers.randomBool(e)},e.array=function(e,t){return a.rndHelpers.randomArray(e,t)},e.item=function(e){return a.rndHelpers.randomItem(e)},e.shuffle=function(e){return a.rndHelpers.shuffleArray(e)},function(e){e.line=function(e){return new h.rndGeometryLine(e).generate()},e.point=function(e){return new c.rndGeometryPoint(e).generate()}}(t=e.Geometry||(e.Geometry={}))}(u||(t.Random=u={}))},373:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.randomCore=void 0,t.randomCore=class{constructor(){this.mergeConfig=(e,t)=>void 0!==e?{...t,...e}:t,this.generate=()=>{},this.config=e=>(this._config=this.mergeConfig(e,this._defaultConfig),this)}}},754:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndFraction=void 0;const s=i(373),n=i(330),o=i(506);class r extends s.randomCore{constructor(e){super(),this.generate=()=>{let e=new o.Fraction;if(this._config.negative?e.numerator=n.Random.numberSym(this._config.max,this._config.zero):e.numerator=n.Random.number(this._config.zero?0:1,this._config.max),this._config.natural)e.denominator=1;else{let t=0;for(;e.isRelative()&&t<10;)e.denominator=n.Random.number(1,this._config.max),t++}return this._config.reduced?e.reduce():e},this._defaultConfig={negative:!0,max:10,reduced:!0,zero:!0,natural:!1},this._config=this.mergeConfig(e,this._defaultConfig)}}t.rndFraction=r},821:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndGeometryLine=void 0;const s=i(373),n=i(330),o=i(9),r=i(586),a=i(557);class l extends s.randomCore{constructor(e){super(),this.generate=()=>{const e=new r.Vector(n.Random.numberSym(10),n.Random.numberSym(10));for(;e.isNull;)e.x=n.Random.numberSym(10),e.y=n.Random.numberSym(10);return 1===this._config.slope?e.x.sign()!==e.y.sign()&&e.y.opposed():-1===this._config.slope&&e.x.sign()!==e.y.sign()&&e.y.opposed(),new o.Line(new a.Point(this._config.A.x,this._config.A.y),e)},this._defaultConfig={A:{x:n.Random.numberSym(10),y:n.Random.numberSym(10)}},this._config=this.mergeConfig(e,this._defaultConfig)}}t.rndGeometryLine=l},246:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndGeometryPoint=void 0;const s=i(373),n=i(330),o=i(557),r=i(506);class a extends s.randomCore{constructor(e){super(),this.generate=()=>{let e,t,i=!0===this._config.axis||"x"===this._config.axis,s=!0===this._config.axis||"y"===this._config.axis;return e=this._config.fraction?n.Random.fraction({max:this._config.max,zero:i}):new r.Fraction(n.Random.numberSym(this._config.max,i)),t=this._config.fraction?n.Random.fraction({max:this._config.max,zero:s}):new r.Fraction(n.Random.numberSym(this._config.max,s)),1==+this._config.quadrant&&(e.abs(),t.abs()),2==+this._config.quadrant&&(e.isPositive()&&e.opposed(),t.isNegative()&&t.opposed()),3==+this._config.quadrant&&(e.isPositive()&&e.opposed(),t.isPositive()&&t.opposed()),4==+this._config.quadrant&&(e.isNegative()&&e.opposed(),t.isPositive()&&t.opposed()),new o.Point(e,t)},this._defaultConfig={axis:!0,fraction:!1,max:10},this._config=this.mergeConfig(e,this._defaultConfig)}}t.rndGeometryPoint=a},140:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndHelpers=void 0;const s=i(956);class n{static randomBool(e=.5){return Math.random()<e}static randomInt(e,t){return void 0===t?this.randomInt(0,e):Math.floor(Math.random()*(t-e+1)+e)}static randomIntSym(e,t){return!1===t?this.randomBool()?this.randomInt(1,e):-this.randomInt(1,e):this.randomInt(-e,e)}static randomPrime(e){let t=s.Numeric.primes();return void 0!==e&&(t=t.filter((t=>t<e))),this.randomItem(t)}static randomArray(e,t){return void 0===t&&(t=1),e.length<=0?Object.values(e):n.shuffleArray(e).slice(0,t)}static randomItem(e){return 0===e.length?"":this.randomArray(e,1)[0]}static shuffleArray(e){let t=Object.values(e);for(let e=t.length-1;e>0;e--){const i=Math.floor(Math.random()*(e+1)),s=t[e];t[e]=t[i],t[i]=s}return t}}t.rndHelpers=n},793:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndMonom=void 0;const s=i(373),n=i(330),o=i(937);class r extends s.randomCore{constructor(e){super(),this.generate=()=>{let e=new o.Monom;if("boolean"==typeof this._config.fraction?e.coefficient=n.Random.fraction({zero:this._config.zero,reduced:!0,natural:!this._config.fraction}):e.coefficient=n.Random.fraction(this._config.fraction),this._config.letters.length>1){for(let t of this._config.letters.split(""))e.setLetter(t,0);for(let t=0;t<this._config.degree;t++){const t=n.Random.item(this._config.letters.split(""));e.setLetter(t,e.degree(t).clone().add(1))}}else e.setLetter(this._config.letters,this._config.degree);return e},this._defaultConfig={letters:"x",degree:2,fraction:!0,zero:!1},this._config=this.mergeConfig(e,this._defaultConfig)}}t.rndMonom=r},22:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndPolynom=void 0;const s=i(373),n=i(793),o=i(330),r=i(38);class a extends s.randomCore{constructor(e){super(),this.generate=()=>{if(this._config.factorable&&this._config.degree>1)return this.factorable();let e,t=(new r.Polynom).empty();for(let i=this._config.degree;i>=0;i--)e=new n.rndMonom({letters:this._config.letters,degree:i,fraction:this._config.fraction,zero:i!==this._config.degree&&this._config.allowNullMonom}).generate(),this._config.unit&&this._config.degree===i&&e.coefficient.one(),t.add(e);if(this._config.positive&&t.monomByDegree().coefficient.isNegative()&&t.monomByDegree().coefficient.opposed(),this._config.numberOfMonoms>0&&this._config.numberOfMonoms<t.length){let e=t.monomByDegree().clone();t.monoms=o.Random.array(t.monoms.slice(1),this._config.numberOfMonoms-1),t.add(e).reorder().reduce()}return t},this.factorable=()=>{let e=(new r.Polynom).one(),t={...this._config};t.degree=1,t.factorable=!1;for(let i=0;i<this._config.degree;i++)e.multiply(o.Random.polynom(t));return e},this._defaultConfig={letters:"x",degree:2,fraction:!1,zero:!1,unit:!1,factorable:!1,allowNullMonom:!0,numberOfMonoms:0,positive:!0},this._config=this.mergeConfig(e,this._defaultConfig)}}t.rndPolynom=a},230:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},505:(e,t)=>{var i,s;Object.defineProperty(t,"__esModule",{value:!0}),t.Shutingyard=t.ShutingyardMode=t.ShutingyardType=t.tokenConstant=void 0,t.tokenConstant={pi:Math.PI,e:Math.exp(1)},function(e){e.VARIABLE="variable",e.COEFFICIENT="coefficient",e.OPERATION="operation",e.CONSTANT="constant",e.FUNCTION="function",e.MONOM="monom"}(i||(t.ShutingyardType=i={})),function(e){e.EXPRESSION="expression",e.POLYNOM="polynom",e.SET="set",e.NUMERIC="numeric"}(s||(t.ShutingyardMode=s={})),t.Shutingyard=class{constructor(e){this._rpn=[],this._mode=void 0===e?s.POLYNOM:e,this.tokenConfigInitialization()}get rpn(){return this._rpn}get rpnToken(){return this._rpn.map((e=>e.token))}tokenConfigInitialization(){return this._mode===s.SET?(this._tokenConfig={"&":{precedence:3,associative:"left",type:i.OPERATION},"|":{precedence:3,associative:"left",type:i.OPERATION},"!":{precedence:4,associative:"right",type:i.OPERATION},"-":{precedence:2,associative:"left",type:i.OPERATION}},this._uniformize=!1):this._mode===s.NUMERIC?(this._tokenConfig={"^":{precedence:4,associative:"right",type:i.OPERATION},"*":{precedence:3,associative:"left",type:i.OPERATION},"/":{precedence:3,associative:"left",type:i.OPERATION},"+":{precedence:2,associative:"left",type:i.OPERATION},"-":{precedence:2,associative:"left",type:i.OPERATION},"%":{precedence:3,associative:"right",type:i.OPERATION},sin:{precedence:4,associative:"right",type:i.FUNCTION},cos:{precedence:4,associative:"right",type:i.FUNCTION},tan:{precedence:4,associative:"right",type:i.FUNCTION},sqrt:{precedence:4,associative:"right",type:i.FUNCTION},nthrt:{precedence:4,associative:"right",type:i.FUNCTION},ln:{precedence:4,associative:"right",type:i.FUNCTION},log:{precedence:4,associative:"right",type:i.FUNCTION}},this._uniformize=!1):this._mode===s.EXPRESSION?(this._tokenConfig={"^":{precedence:4,associative:"right",type:i.OPERATION},"*":{precedence:3,associative:"left",type:i.OPERATION},"/":{precedence:3,associative:"left",type:i.OPERATION},"+":{precedence:2,associative:"left",type:i.OPERATION},"-":{precedence:2,associative:"left",type:i.OPERATION},"%":{precedence:3,associative:"right",type:i.OPERATION},sin:{precedence:4,associative:"right",type:i.FUNCTION},cos:{precedence:4,associative:"right",type:i.FUNCTION},tan:{precedence:4,associative:"right",type:i.FUNCTION},sqrt:{precedence:4,associative:"right",type:i.FUNCTION},nthrt:{precedence:4,associative:"right",type:i.FUNCTION}},this._uniformize=!0):(this._tokenConfig={"^":{precedence:4,associative:"right",type:i.OPERATION},"*":{precedence:3,associative:"left",type:i.OPERATION},"/":{precedence:3,associative:"left",type:i.OPERATION},"+":{precedence:2,associative:"left",type:i.OPERATION},"-":{precedence:2,associative:"left",type:i.OPERATION}},this._uniformize=!0),this._tokenKeys=Object.keys(this._tokenConfig).sort(((e,t)=>t.length-e.length)),this._tokenConfig}NextToken(e,n){let o,r;if(o="",r="","("===e[n])o="(",r="(";else if(")"===e[n])o=")",r=")";else if(","===e[n])o=",",r="function-argument";else{for(let t of this._tokenKeys)if(e.substring(n,n+t.length)===t){o+=t,r=this._tokenConfig[t].type;break}for(let s in t.tokenConstant)if(e.substring(n,n+s.length)===s){o+=s,r=i.CONSTANT;break}""===o&&(e[n].match(/[0-9]/)?(this._mode,s.POLYNOM,o=e.substring(n).match(/^([0-9.]+)/)[0],r=i.COEFFICIENT):e[n].match(/[a-zA-Z]/)?(o=e.substring(n).match(/^([a-zA-Z])/)[0],r=i.VARIABLE):(console.log("Unidentified token",e[n],e,n),o=e[n],r=i.MONOM))}return[o,n+o.length,r]}normalize(e){if(1===e.length)return e;let s=[],n=[];for(let e in this._tokenConfig)this._tokenConfig[e].type===i.FUNCTION&&s.push(e);s.sort(((e,t)=>t.length-e.length));for(let e in t.tokenConstant)n.push(e);n.sort(((e,t)=>t.length-e.length));let o,r,a="",l=0;for(;l<e.length-1;){let t=0;for(;t<s.length;){let i=s[t];e.slice(l,l+i.length+1)===i+"("?(a+=i+"(",l+=i.length+1,t=0):t++}for(t=0;t<n.length;){let i=n[t];if(e.slice(l,l+i.length)===i){a+=i.slice(0,-1),l+=i.length-1;break}t++}o=e[l],r=e[l+1],a+=o,o.match(/[a-zA-Z]/g)?r.match(/[a-zA-Z\d(]/)&&(a+="*"):o.match(/\d/)?r.match(/[a-zA-Z(]/)&&(a+="*"):")"===o&&r.match(/[a-zA-Z\d(]/)&&(a+="*"),l++}return a+r}parse(e,t){let i=[],s=[],n="",o=0,r="",a=0;(t||this._uniformize)&&(e=this.normalize(e));let l,h=50;for(;o<e.length;){if(h--,0===h){console.log("SECURITY LEVEL 1 EXIT");break}switch([n,o,r]=this.NextToken(e,o),r){case"monom":case"coefficient":case"variable":case"constant":i.push({token:n,tokenType:r});break;case"operation":if(a=s.length,s.length>0){let e=s[s.length-1];for(l=50;e.token in this._tokenConfig&&("left"===this._tokenConfig[n].associative&&this._tokenConfig[n].precedence<=this._tokenConfig[e.token].precedence||"right"===this._tokenConfig[n].associative&&this._tokenConfig[n].precedence<this._tokenConfig[e.token].precedence);){if(l--,0===l){console.log("SECURITY LEVEL 2 OPERATION EXIT");break}if(i.push(s.pop()||{token:"",tokenType:"operation"}),0===s.length)break;e=s[s.length-1]}}s.push({token:n,tokenType:r});break;case"function-argument":for(l=50;"("!==s[s.length-1].token&&s.length>0;){if(l--,0===l){console.log("SECURITY LEVEL 2 FUNCTION ARGUMENT EXIT");break}i.push(s.pop()||{token:n,tokenType:r})}break;case"(":s.push({token:n,tokenType:r}),"-"===e[o]&&i.push({token:"0",tokenType:"coefficient"});break;case")":for(l=50;"("!==s[s.length-1].token&&s.length>1;){if(l--,0===l){console.log("SECURITY LEVEL 2 CLOSING PARENTHESE EXIT");break}i.push(s.pop()||{token:n,tokenType:r})}s.pop();break;case"function":s.push({token:n,tokenType:r});break;default:console.log(`SHUTING YARD: ${r} : ${n} `)}}return this._rpn=i.concat(s.reverse()),this}}}},t={};!function i(s){var n=t[s];if(void 0!==n)return n.exports;var o=t[s]={exports:{}};return e[s].call(o.exports,o,o.exports,i),o.exports}(607)})();
1
+ (()=>{"use strict";var e={607:(e,t,i)=>{t.l=void 0;const s=i(956),n=i(394),o=i(505),r=i(330),a=i(506),l=i(872),h=i(937),c=i(38),u=i(760),d=i(554),f=i(107),m=i(236),_=i(586),p=i(9),g=i(164),y=i(699),v=i(557);t.l={ShutingYard:o.Shutingyard,Numeric:s.Numeric,NumExp:n.NumExp,Fraction:a.Fraction,Root:l.NthRoot,Monom:h.Monom,Polynom:c.Polynom,Equation:u.Equation,LinearSystem:d.LinearSystem,Rational:f.Rational,Logicalset:m.Logicalset,Random:r.Random,Geometry:{Vector:_.Vector,Point:v.Point,Line:p.Line,Triangle:g.Triangle,Circle:y.Circle}},window.Pi=t.l},760:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Equation=t.PARTICULAR_SOLUTION=void 0;const s=i(38),n=i(956),o=i(506),r=i(872);var a;!function(e){e.real="\\mathbb{R}",e.varnothing="\\varnothing"}(a||(t.PARTICULAR_SOLUTION=a={}));class l{constructor(...e){if(this._varnothing=a.varnothing,this._real=a.real,this.hasVariable=e=>this.variables.includes(e),this._randomizeDefaults={degree:2},this.parse=e=>{let t,i;if(i=this._findSign(e),!1!==i)return t=e.split(i),this.create(new s.Polynom(t[0]),new s.Polynom(t[1]),this._formatSign(i));console.error("The equation is not valid (no sign found)")},this.create=(e,t,i)=>(this._left=e,this._right=t,this._sign=this._formatSign(i),this),this.clone=()=>(new l).create(this._left.clone(),this._right.clone(),this._sign+""),this.randomize=(e,t)=>(new l).create(new s.Polynom,new s.Polynom,t),this.moveLeft=()=>(this._left=this._left.clone().subtract(this._right),this._right.zero(),this),this.reorder=e=>(this._left.subtract(this._right),this._right.zero(),this._left.reorder(),e||(this._left.monoms.filter((e=>e.degree().isZero())).forEach((e=>{const t=e.clone();this._left.subtract(t),this._right.subtract(t)})),this._left.reorder(),this._right.reorder()),this),this.simplify=()=>(this.multiply(n.Numeric.lcm(...this._left.getDenominators(),...this._right.getDenominators())),this.divide(n.Numeric.gcd(...this._left.getNumerators(),...this._right.getNumerators())),this),this.isolate=e=>{if(!this.degree(e).isOne())return!1;if(this.isMultiVariable())return!1;let t,i;this._left.subtract(this._right),this._right.zero();let s=[...this._left.monoms];for(let i of s)i.hasLetter(e)||(t=i.clone(),this._left.subtract(t),this._right.subtract(t));return 1===this._left.length&&(i=this._left.monoms[0].coefficient.clone(),this._left.divide(i),this._right.divide(i),this)},this.replaceBy=(e,t)=>(this._left.replaceBy(e,t),this._right.replaceBy(e,t),this),this.multiply=e=>{let t=new o.Fraction(e);return this._left.multiply(t),this._right.multiply(t),"="!==this._sign&&-1===t.sign()&&this._reverseSign(),this},this.divide=e=>{let t=new o.Fraction(e);return t.isZero()?this:this.multiply(t.invert())},this.degree=e=>o.Fraction.max(this._left.degree(e),this._right.degree(e)),this.isMultiVariable=()=>this._left.isMultiVariable||this._right.isMultiVariable,this.letters=()=>[...new Set([...this._left.letters(),...this._right.letters()])],this.solve=()=>{switch(this._solutions=[],this._polynom=this._left.clone().subtract(this._right),this._polynom.degree().value){case 0:case 1:this._solveDegree1();break;case 2:this._solveDegree2();break;default:this._solveDegree3plus()}return this._solutions=l.makeSolutionsUnique(this._solutions),this},this.test=e=>this.left.evaluate(e).isEqual(this.right.evaluate(e)),this.isSameAs=e=>{let t=e.clone().moveLeft().left,i=this.clone().moveLeft().left;return t.isEqual(i)||t.isOpposedAt(i)},this.isLinearTo=e=>{let t=e.clone().moveLeft().simplify().left,i=this.clone().moveLeft().simplify().left;return t.isEqual(i)||t.isOpposedAt(i)},this._findSign=e=>e.includes("geq")?e.includes("\\geq")?"\\geq":"geq":e.includes("leq")?e.includes("\\leq")?"\\leq":"leq":e.includes(">=")?">=":e.includes("=>")?"=>":e.includes(">")?">":e.includes("<=")?"<=":e.includes("=<")?"=<":e.includes("<")?"<":e.includes("=")?"=":(console.log("Equation: parse string : sign not found"),!1),this._formatSign=e=>void 0===e?"=":e.includes("geq")||e.includes(">=")||e.includes("=>")?">=":e.includes(">")?">":e.includes("leq")||e.includes("<=")||e.includes("=<")?"<=":e.includes("<")?"<":"=",this._reverseSign=()=>"="===this._sign?this:this._sign.includes("<")?(this._sign.replace("<",">"),this):this._sign.includes(">")?(this._sign.replace(">","<"),this):this,this.isGreater=()=>-1!==this._sign.indexOf(">")||-1!==this._sign.indexOf("geq"),this.isStrictEqual=()=>"="===this._sign,this.isAlsoEqual=()=>-1!==this._sign.indexOf("=")||-1!==this._sign.indexOf("geq")||-1!==this._sign.indexOf("leq")||void 0,this._solveDegree1=e=>{const t=this._polynom.monomByDegree(1,e).coefficient,i=this._polynom.monomByDegree(0,e).coefficient,s=i.clone().opposed().divide(t);let n,o;return this.isStrictEqual()?0===t.value?0===i.value?this._solutions=[{tex:this._real,display:"RR",value:NaN,exact:!1}]:this._solutions=[{tex:this._varnothing,display:"O/",value:NaN,exact:!1}]:this._solutions=[{tex:s.tex,display:s.display,value:s.value,exact:s}]:(0===t.value?0===i.value&&this.isAlsoEqual()?(n="\\mathbb{R}",o="RR"):i.value>0?(n=this.isGreater()?this._real:this._varnothing,n=this.isGreater()?"RR":"O/"):(n=this.isGreater()?this._varnothing:this._real,n=this.isGreater()?"O/":"RR"):this.isGreater()&&1===t.sign()||!this.isGreater()&&-1===t.sign()?(n=`\\left${this.isAlsoEqual()?"[":"]"}${s.tex};+\\infty\\right[`,o=`${this.isAlsoEqual()?"[":"]"}${s.tex};+oo[`):(n=`\\left]-\\infty;${s.tex} \\right${this.isAlsoEqual()?"]":"["}`,o=`]-oo;${s.tex}${this.isAlsoEqual()?"]":"["}`),this._solutions=[{tex:n,display:o,value:NaN,exact:!1}]),this._solutions},this._solveDegree2=e=>{let t,i,s,a,l,h,c=this._polynom.monomByDegree(2,e).coefficient,u=this._polynom.monomByDegree(1,e).coefficient,d=this._polynom.monomByDegree(0,e).coefficient,f=n.Numeric.lcm(c.denominator,u.denominator,d.denominator),m=c.multiply(f).value,_=u.multiply(f).value;if(t=_*_-4*m*d.multiply(f).value,t>0)if(s=(-_-Math.sqrt(t))/(2*m),a=(-_+Math.sqrt(t))/(2*m),t>1e5){let e=((-_-Math.sqrt(t))/(2*m)).toFixed(5),i=((-_+Math.sqrt(t))/(2*m)).toFixed(5);this._solutions=[{tex:e,display:e,value:s,exact:!1},{tex:i,display:i,value:a,exact:!1}]}else if(i=new r.NthRoot(t).reduce(),i.hasRadical()){let e=n.Numeric.gcd(_,2*m,i.coefficient),t=m/e,o=_/e;i.coefficient=i.coefficient/e,m<0&&(t=-t,o=-o);let r="",l="",h="",c="";r=`${0!==o?-o+" - ":""}${i.tex}`,l=`${0!==o?-o+" + ":""}${i.tex}`,h=`${0!==o?-o+" - ":""}${i.display}`,c=`${0!==o?-o+" + ":""}${i.display}`,1!==t&&(r=`\\frac{ ${r} }{ ${2*t} }`,l=`\\frac{ ${l} }{ ${2*t} }`),this._solutions=[{tex:r,display:r,value:s,exact:!1},{tex:l,display:l,value:a,exact:!1}]}else{const e=new o.Fraction(-_-i.coefficient,2*m).reduce(),t=new o.Fraction(-_+i.coefficient,2*m).reduce();this._solutions=[{tex:e.frac,display:e.display,value:s,exact:e},{tex:t.frac,display:t.display,value:a,exact:t}]}else if(0===t){const e=new o.Fraction(-_,2*m).reduce();this._solutions=[{tex:e.frac,display:e.display,value:e.value,exact:e}]}else this._solutions=[{tex:this._varnothing,display:"O/",value:NaN,exact:!1}];return this.isStrictEqual()||(2===this._solutions.length?(l=s<a?this._solutions[0].tex:this._solutions[1].tex,h=s<a?this._solutions[1].tex:this._solutions[0].tex,this.isGreater()&&1===c.sign()||!this.isGreater()&&-1===c.sign()?this._solutions=[{tex:`\\left]-\\infty ; ${l}\\right${this.isAlsoEqual()?"]":"["} \\cup \\left${this.isAlsoEqual()?"[":"]"}${h};+\\infty\\right[`,display:`]-oo;${l}${this.isAlsoEqual()?"]":"["}uu${this.isAlsoEqual()?"[":"]"}${h};+oo[`,value:NaN,exact:!1}]:this._solutions=[{tex:`\\left${this.isAlsoEqual()?"[":"]"}${l} ; ${h}\\right${this.isAlsoEqual()?"]":"["}`,display:`${this.isAlsoEqual()?"[":"]"}${l};${h}${this.isAlsoEqual()?"]":"["}`,value:NaN,exact:!1}]):1===this._solutions.length&&this._solutions[0].tex!==this._varnothing?this.isAlsoEqual()?(this.isGreater()&&1===c.sign()||!this.isGreater()&&-1===c.sign())&&(this._solutions=[{tex:this._real,display:"RR",value:NaN,exact:!1}]):this.isGreater()&&1===c.sign()||!this.isGreater()&&-1===c.sign()?this._solutions=[{tex:`\\left]-\\infty ; ${this._solutions[0].tex}\\right[ \\cup \\left]${this._solutions[0].tex};+\\infty\\right[`,display:`]-oo;${this._solutions[0].tex}[uu]${this._solutions[0].tex};+oo[`,value:NaN,exact:!1}]:this._solutions=[{tex:this._varnothing,display:"O/",value:NaN,exact:!1}]:this.isGreater()?this._solutions=[{tex:1===c.sign()?this._real:this._varnothing,display:1===c.sign()?"RR":"O/",value:NaN,exact:!1}]:this._solutions=[{tex:-1===c.sign()?this._real:this._varnothing,display:-1===c.sign()?"RR":"O/",value:NaN,exact:!1}]),this._solutions},this._solveDegree3plus=e=>{let t=this.clone().moveLeft();return t.left.factorize(),this._solutions=[],t.left.factors.forEach((t=>{if(t.degree(e).leq(2)){let e=new l(t,0);e.solve(),e.solutions.forEach((e=>{this._solutions.push(e)}))}else console.log(t.tex,": cannot actually get the solution of this equation")})),this._solutions},this._left=(new s.Polynom).zero(),this._right=(new s.Polynom).zero(),this._sign="=",1===e.length){if(e[0]instanceof l)return e[0].clone();"string"==typeof e[0]&&this.parse(e[0])}else{if(2!==e.length)return this;e[0]instanceof s.Polynom?this.left=e[0].clone():"string"==typeof e[0]&&(this.left=new s.Polynom(e[0])),e[1]instanceof s.Polynom?this.right=e[1].clone():"string"==typeof e[1]&&(this.right=new s.Polynom(e[1]))}return this}get left(){return this._left}set left(e){this._left=e}get right(){return this._right}set right(e){this._right=e}get sign(){return this._sign}set sign(e){this._sign=this._formatSign(e)}get solutions(){return this._solutions}get isEquation(){return!0}get solution(){return 1!==this._solutions.length||this._solutions[0].tex!==this._real&&this._solutions[0].tex!==this._varnothing&&!this._solutions[0].tex.includes("\\left")?`S = \\left{ ${this._solutions.map((e=>e.tex)).join(";")} \\right}`:`S = ${this._solutions[0]}`}get isReal(){return void 0===this._solutions&&this.solve(),this._solutions[0].tex===this._real}get isVarnothing(){return void 0===this._solutions&&this.solve(),this._solutions[0].tex===this._varnothing}get signAsTex(){return">="===this._sign||"=>"===this._sign||"geq"===this._sign?"\\geq":"<="===this._sign||"=<"===this._sign||"leq"===this._sign?"\\leq":this._sign}get tex(){return`${this._left.tex}${this.signAsTex}${this._right.tex}`}get display(){return`${this._left.display}${this.signAsTex}${this._right.display}`}get raw(){return`${this._left.raw}${this.signAsTex}${this._right.raw}`}get variables(){return[...new Set(this._right.variables.concat(this._left.variables))]}get numberOfVars(){return this.variables.length}get randomizeDefaults(){return this._randomizeDefaults}set randomizeDefaults(e){this._randomizeDefaults=e}static makeSolutionsUnique(e,t){let i=[],s=e.filter((e=>!i.includes(e.tex)&&(i.push(e.tex),!0)));return!0===t&&s.sort(((e,t)=>e.value-t.value)),s}}t.Equation=l},554:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LinearSystem=void 0;const s=i(760),n=i(506),o=i(38),r=i(956);class a{constructor(...e){return this.buildTex=(e,t)=>{let i,s,n=[],o=[];for(let t of e)o=o.concat(t.letters());o=[...new Set(o)],o.sort();for(let r=0;r<e.length;r++){let a=e[r];i=[];for(let e of o)s=a.left.monomByLetter(e),0===i.length?i.push(s.isZero()?"":s.tex):i.push(s.isZero()?"":(1===s.coefficient.sign()?"+":"")+s.tex);if(i.push("="),i.push(a.right.tex),void 0!==t&&void 0!==t[r]){i[i.length-1]=i[i.length-1]+" \\phantom{\\quad}";for(let e of t[r])i.push(`\\ \\cdot\\ ${e.startsWith("-")?"\\left("+e+"\\right)":e}`)}n.push(i.join("&"))}let r=0;return void 0!==t&&t.length>0&&(r=t[0].length),`\\left\\{\\begin{array}{${"r".repeat(o.length)}cl ${"|l".repeat(r)}}${n.join("\\\\ ")}\\end{array}\\right.`},this.stepTex=e=>{const t=this._resolutionSteps[e];if(void 0===t)return"";let i=[];for(let e=0;e<t.length;e++)i.push(this.buildTex(t[e].equations,t[e].operations));return`\\begin{aligned}&${i.join("\\\\&")}\\end{aligned}`},this.parse=(...e)=>(this._equations=e.map((e=>new s.Equation(e))),this._findLetters(),this),this.clone=()=>(new a).parse(...this._equations.map((e=>e.clone()))),this.reorder=()=>{for(let e of this._equations)e.reorder();return this},this.solve=e=>{this._solutions={},this._resolutionSteps={},this.reorder(),void 0===e&&(e=!1);for(let t of this.variables)this._solutions[t]=this._solveOneLetter(t,e);return this},this.mergeEquations=(e,t,i,s)=>{let o=e.clone().multiply(new n.Fraction(i)),r=t.clone().multiply(new n.Fraction(s));return o.left.add(r.left),o.right.add(r.right),o},this._findLetters=()=>{let e=new Set;for(let t of this._equations)e=new Set([...e,...t.variables]);return this._letters=[...e],this._letters.sort(),this},this._equations=[],this._letters="xyz".split(""),void 0!==e&&e.length>0&&this.parse(...e),this}get equations(){return this._equations}set equations(e){this._equations=e}get letters(){return this._letters.join("")}set letters(e){this._letters=e.split("")}get isSolvable(){return this.variables.length===this._equations.length}get variables(){return this._letters}get tex(){let e=this.clone().reorder();return e.variables,this.buildTex(e.equations)}get solution(){let e=[];void 0===this._solutions&&this.solve();for(let t in this._solutions){if("RR"===this._solutions[t].display)return`\\left\\{ \\left(${this._letters.join(";")}\\right) \\big\\vert ${this.equations[0].tex} \\right\\}`;if("O/"===this._solutions[t].display)return"\\varnothing";e.push(this._solutions[t].tex)}return`\\left(${e.join(";")}\\right)`}get solutionAsDisplay(){let e=[];void 0===this._solutions&&this.solve();for(let t in this._solutions){if("RR"===this._solutions[t].display)return`{(${this._letters.join(";")}) | ${this.equations[0].display} }`;if("O/"===this._solutions[t].display)return"O/";e.push(this._solutions[t].display)}return`(${e.join(";")})`}get resolutionSteps(){return this._resolutionSteps}_linearReduction(e,t,i){let s=e.left.monomByDegree(1,i).coefficient.clone(),n=t.left.monomByDegree(1,i).coefficient.clone().opposed();const o=r.Numeric.gcd(s.numerator,n.numerator),a=r.Numeric.gcd(s.denominator,n.denominator);return s.divide(o).multiply(a),n.divide(o).multiply(a),(n.isNegativeOne()||s.isNegativeOne())&&(s.opposed(),n.opposed()),{merged:this.mergeEquations(e,t,n,s),factors:[n,s]}}_solveOneLetter(e,t){let i,r=this.clone().equations,a=[];this._resolutionSteps[e]=[];for(let s of this.variables)if(a=[],s!==e){t&&(this._resolutionSteps[e].push({equations:r.map((e=>e.clone())),operations:[...new Array(r.length)].map((e=>[...new Array(r.length-1)].map((e=>""))))}),i=this._resolutionSteps[e].length-1);for(let n=0;n<r.length-1;n++){const o=this._linearReduction(r[n],r[n+1],s);a.push(o.merged),t&&(this._resolutionSteps[e][i].operations[n][n]=o.factors[0].tex,this._resolutionSteps[e][i].operations[n+1][n]=o.factors[1].tex)}r=[...a]}let l=r[0];l.solve();const h=l.solutions[0];if(t){let t;this._resolutionSteps[e].push({equations:[r[0]],operations:[[r[0].left.monoms[0].coefficient.tex]]}),t=h.exact instanceof n.Fraction||"string"==typeof h.exact?new o.Polynom(h.exact):new o.Polynom(h.value),this._resolutionSteps[e].push({equations:[new s.Equation(new o.Polynom(e),t)],operations:[]})}return l.solutions[0]}}t.LinearSystem=a},236:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Logicalset=void 0;const s=i(505);t.Logicalset=class{constructor(e){return this.parse=e=>(this._rpn=new s.Shutingyard(s.ShutingyardMode.SET).parse(e).rpn,this),this._rawString=e,this.parse(e),this}get isLogicalset(){return!0}evaluate(e,t){let i,s=[];if(void 0===t){i=new Set;for(let t in e)i=new Set([...i,...e[t]])}else i=new Set(t);for(let t of this._rpn)if("variable"===t.tokenType)void 0===e[t.token]?s.push(new Set):s.push(new Set(e[t.token]));else switch(t.token){case"&":if(s.length>=2){let e=s.pop(),t=s.pop();s.push(new Set([...t].filter((t=>e.has(t)))))}break;case"|":if(s.length>=2){let e=s.pop(),t=s.pop();s.push(new Set([...t,...e]))}break;case"-":if(s.length>=2){let e=s.pop(),t=s.pop();s.push(new Set([...t].filter((t=>!e.has(t)))))}break;case"!":if(s.length>=1){let e=s.pop();s.push(new Set([...i].filter((t=>!e.has(t)))))}}return[...s[0]].sort()}vennAB(){return this.evaluate({A:["A","AB"],B:["B","AB"]},["A","B","AB","E"])}vennABC(){return this.evaluate({A:["A","AB","AC","ABC"],B:["B","AB","BC","ABC"],C:["C","AC","BC","ABC"]},["A","B","C","AB","AC","BC","E"])}get rpn(){return this._rpn}get tex(){let e=[];for(let t of this._rpn)if("variable"===t.tokenType)e.push(t);else switch(t.token){case"&":if(e.length>=2){let t=e.pop(),i=e.pop();"mix"===i.tokenType&&(i.token=`( ${i.token} )`),"mix"===t.tokenType&&(t.token=`( ${t.token} )`),e.push({token:`${i.token} \\cap ${t.token}`,tokenType:"mix"})}break;case"|":if(e.length>=2){let t=e.pop(),i=e.pop();"mix"===i.tokenType&&(i.token=`( ${i.token} )`),"mix"===t.tokenType&&(t.token=`( ${t.token} )`),e.push({token:`${i.token} \\cup ${t.token}`,tokenType:"mix"})}break;case"-":if(e.length>=2){let t=e.pop(),i=e.pop();"mix"===i.tokenType&&(i.token=`( ${i.token} )`),"mix"===t.tokenType&&(t.token=`( ${t.token} )`),e.push({token:`${i.token} \\setminus ${t.token}`,tokenType:"mix"})}break;case"!":if(e.length>=1){let t=e.pop();e.push({token:`\\overline{ ${t.token} }`,tokenType:"variable"})}}return e[0].token}}},937:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Monom=void 0;const s=i(956),n=i(505),o=i(506);class r{constructor(e){return this.parse=e=>("string"==typeof e?this._shutingYardToReducedMonom(e):"number"==typeof e?(this._coefficient=new o.Fraction(e),this._literal={}):e instanceof o.Fraction?(this._coefficient=e.clone(),this._literal={}):e instanceof r&&(this._coefficient=e._coefficient.clone(),this._literal=this.copyLiterals(e.literal)),this),this.addToken=(e,t)=>{let i,s,a,l,h;if(t.tokenType===n.ShutingyardType.COEFFICIENT)e.push(new r(new o.Fraction(t.token)));else if(t.tokenType===n.ShutingyardType.VARIABLE){let i=(new r).one();i.setLetter(t.token,1),e.push(i.clone())}else if(t.tokenType===n.ShutingyardType.OPERATION)switch(t.token){case"-":s=e.pop()||(new r).zero(),i=e.pop()||(new r).zero(),e.push(i.subtract(s));break;case"*":s=e.pop()||(new r).one(),i=e.pop()||(new r).one(),e.push(i.multiply(s));break;case"/":s=e.pop()||(new r).one(),i=e.pop()||(new r).one(),e.push(i.divide(s));break;case"^":h=e.pop().coefficient||(new o.Fraction).one(),a=e.pop()||(new r).one(),l=a.variables[0],void 0!==l&&a.setLetter(l,h),e.push(a)}},this._shutingYardToReducedMonom=e=>{const t=(new n.Shutingyard).parse(e).rpn;let i=[];if(0===t.length)return this.zero(),this;if(1===t.length){const e=t[0];return this.one(),"coefficient"===e.tokenType?this.coefficient=new o.Fraction(e.token):"variable"===e.tokenType&&this.setLetter(e.token,1),this}for(const e of t)this.addToken(i,e);return this.one(),this.multiply(i[0]),this},this.clone=()=>{let e=new r;e.coefficient=this._coefficient.clone();for(let t in this._literal)e.setLetter(t,this._literal[t].clone());return e},this.copyLiterals=e=>{let t={};for(let i in e)t[i]=e[i].clone();return t},this.makeSame=e=>{for(let t in e._literal)this.setLetter(t,e._literal[t].clone());return this},this.zero=()=>(this._coefficient=(new o.Fraction).zero(),this._literal={},this),this.one=()=>(this._coefficient=(new o.Fraction).one(),this._literal={},this),this.clean=()=>{for(let e in this._literal)this._literal[e].isZero()&&delete this._literal[e];return this},this.reduce=()=>(this.clean(),this.coefficient.reduce(),this),this.opposed=()=>(this._coefficient.opposed(),this),this.add=(...e)=>{for(let t of e)this.isSameAs(t)?(this.isZero()&&this.makeSame(t),this._coefficient.add(t.coefficient)):console.log("Add monom: "+this.display+" is not similar with ",t.display);return this},this.subtract=(...e)=>{for(let t of e)this.isSameAs(t)?(this.isZero()&&this.makeSame(t),this._coefficient.add(t.clone().coefficient.opposed())):console.log("Subtract: Is not similar: ",t.display);return this},this.multiply=(...e)=>{for(let t of e){this._coefficient.multiply(t.coefficient);for(let e in t.literal)void 0===this._literal[e]?this._literal[e]=t.literal[e].clone():this._literal[e].add(t.literal[e])}return this},this.multiplyByNumber=e=>(this._coefficient.multiply(e),this),this.divide=(...e)=>{for(let t of e){this._coefficient.divide(t.coefficient);for(let e in t.literal)this._literal[e]=void 0===this._literal[e]?t.literal[e].clone().opposed():this._literal[e].subtract(t.literal[e]),this._literal[e].isZero()&&delete this._literal[e]}return this},this.pow=e=>{this._coefficient.pow(e);for(let t in this._literal)this._literal[t].multiply(e);return this},this.root=e=>this,this.sqrt=()=>{if(this.isSquare()){this._coefficient.sqrt();for(let e in this._literal)this._literal[e].clone().divide(2)}return this.root(2)},this.compare=(e,t)=>{switch(void 0===t&&(t="="),t){case"=":return!!this.compare(e,"same")&&this._coefficient.isEqual(e.coefficient);case"same":let t=this.variables,i=e.variables,s=t.concat(i.filter((e=>t.indexOf(e)<0)));if(0===t.length&&0===i.length)return!0;if(!this.isZero()&&!e.isZero())for(let t of s){if(void 0===this._literal[t]||void 0===e.literal[t])return!1;if(!this._literal[t].isEqual(e.literal[t]))return!1}return!0;default:return!1}},this.isEqual=e=>this.compare(e,"="),this.isSameAs=e=>this.compare(e,"same"),this.isSquare=()=>!!this.coefficient.isSquare()&&this.isLiteralSquare(),this.isLiteralSquare=()=>{for(let e in this.literal){if(this.literal[e].isRational())return!1;if(this.literal[e].isEven())return!1}return!0},this.hasFractionCoefficient=()=>{for(let e in this._literal)if(this._literal[e].isRational())return!0;return!1},this.hasLetter=e=>void 0!==this._literal[void 0===e?"x":e]&&this._literal[void 0===e?"x":e].isNotZero(),this.setLetter=(e,t)=>{t instanceof o.Fraction?(this.hasLetter(e)&&t.isZero()&&delete this._literal[e],this._literal[e]=t.clone()):this.setLetter(e,new o.Fraction(t))},this.degree=e=>0===this.variables.length?(new o.Fraction).zero():void 0===e?Object.values(this._literal).reduce(((e,t)=>e.clone().add(t))):void 0===this._literal[e]?(new o.Fraction).zero():this._literal[e].clone(),this.evaluate=e=>{let t=this.coefficient.clone();if("number"==typeof e||e instanceof o.Fraction){let t={};return t[this.variables[0]]=new o.Fraction(e),this.evaluate(t)}if("object"==typeof e){if(0===this.variables.length)return this.coefficient;for(let i in this._literal){if(void 0===e[i])return(new o.Fraction).zero();let s=new o.Fraction(e[i]);t.multiply(s.pow(this._literal[i]))}}return t},this.evaluateAsNumeric=e=>{let t=this.coefficient.value;if("number"==typeof e){let t={};return t[this.variables[0]]=e,this.evaluateAsNumeric(t)}if("object"==typeof e){if(0===this.variables.length)return this.coefficient.value;for(let i in this._literal){if(void 0===e[i])return 0;t*=e[i]**this._literal[i].value}}return t},this.derivative=e=>{if(void 0===e&&(e="x"),this.hasLetter(e)){let t=this._literal[e].clone(),i=this.clone();return i._literal[e].subtract(1),i._coefficient.multiply(new o.Fraction(t.clone())),i}return(new r).zero()},this.primitive=e=>{void 0===e&&(e="x");let t,i=this.clone();return i.hasLetter(e)?(t=i.degree(e).clone().add(1),i.coefficient=i.coefficient.clone().divide(t),i.setLetter(e,t)):(i.coefficient.isZero()&&(i.coefficient=(new o.Fraction).one()),i.setLetter(e,1)),i},this.areSameAs=(...e)=>{for(let t=0;t<e.length;t++)if(!this.isSameAs(e[t]))return!1;return!0},this.areEquals=(...e)=>{if(!this.areSameAs(...e))return!1;for(let t of e)if(!this._coefficient.isEqual(t.coefficient))return!1;return!0},this.isDivisible=e=>{if(e.degree().isStrictlyPositive())for(let t of e.variables)if(!this.degree(t).geq(e.degree(t)))return!1;return!(!this.coefficient.isRational()&&!e.coefficient.isRational())||this.coefficient.clone().divide(e.coefficient).isRelative()},this.zero(),void 0!==e&&this.parse(e),this}get coefficient(){return this._coefficient}set coefficient(e){this._coefficient=new o.Fraction(e)}get literal(){return this._literal}get literalSqrt(){if(this.isLiteralSquare()){let e={};for(let t in this._literal)e[t]=this._literal[t].clone().sqrt();return e}return this._literal}set literal(e){this._literal=e}set literalStr(e){for(const t of[...e.matchAll(/([a-z])\^([+-]?[0-9]+)/g)])t[1]in this._literal||(this._literal[t[1]]=(new o.Fraction).zero()),this._literal[t[1]].add(+t[2]);for(const t of[...e.matchAll(/([a-z](?!\^))/g)])t[1]in this._literal||(this._literal[t[1]]=(new o.Fraction).zero()),this._literal[t[1]].add(1)}get variables(){let e=this.clone().clean();return Object.keys(e.literal)}get display(){let e="",t=Object.keys(this._literal).sort();for(let i of t)this._literal[i].isNotZero()&&(e+=`${i}`,this._literal[i].isNotEqual(1)&&(e+=`^(${this._literal[i].display})`));return""===e?0!=this._coefficient.value?`${this._coefficient.display}`:"":1===this._coefficient.value?e:-1===this._coefficient.value?`-${e}`:0===this._coefficient.value?"0":`${this._coefficient.display}${e}`}get dividers(){if(!this.coefficient.isRelative())return[this.clone()];if(this.hasFractionCoefficient())return[this.clone()];if(this.coefficient.numerator>1e6)return[this.clone()];const e=s.Numeric.dividers(Math.abs(this.coefficient.numerator));let t=[];for(let e in this.literal)t=this._getLiteralDividers(t,e);const i=[];if(t.length>0&&e.length>0)for(let s of e)for(let e of t){let t=new r;t.coefficient=new o.Fraction(s),t.literal=e,i.push(t)}else if(0===e.length)for(let e of t){let t=new r;t.coefficient=(new o.Fraction).one(),t.literal=e,i.push(t)}else for(let t of e){let e=new r;e.coefficient=new o.Fraction(t),i.push(e)}return 0===i.length?[(new r).one()]:i}_getLiteralDividers(e,t){let i=[];for(let s=0;s<=this.literal[t].value;s++)if(0===e.length){let e={};e[t]=new o.Fraction(s),i.push(e)}else for(let n of e){let e={};for(let t in n)e[t]=n[t];e[t]=new o.Fraction(s),i.push(e)}return i}get displayWithSign(){let e=this.display;return("-"!==e[0]?"+":"")+e}get texWithSign(){return this.coefficient.isStrictlyPositive()?"+"+this.tex:this.tex}get plotFunction(){let e="",t=Object.keys(this._literal).sort();for(let i of t)this._literal[i].isNotZero()&&(e+=(""===e?"":"*")+`${i}`,this._literal[i].isNotEqual(1)&&(e+=`^(${this._literal[i].display})`));return""===e?0!=this._coefficient.value?`${this._coefficient.display}`:"":1===this._coefficient.value?e:-1===this._coefficient.value?`-${e}`:0===this._coefficient.value?"0":`${this._coefficient.display}*${e}`}get tex(){let e="",t=Object.keys(this._literal).sort();for(let i of t)this._literal[i].isNotZero()&&(e+=`${i}`,this._literal[i].isNotEqual(1)&&(e+=`^{${this._literal[i].tfrac}}`));return""===e?0!=this._coefficient.value?`${this._coefficient.frac}`:"0":1===this._coefficient.value?e:-1===this._coefficient.value?`-${e}`:0===this._coefficient.value?"0":`${this._coefficient.frac}${e}`}isZero(){return 0===this._coefficient.value}isOne(){return 1===this._coefficient.value&&0===this.variables.length}}t.Monom=r,r.lcm=(...e)=>{for(let t of e)if(t.hasFractionCoefficient())return(new r).zero();let t=new r,i=e.map((e=>e.coefficient.numerator)),n=e.map((e=>e.coefficient.denominator)),a=s.Numeric.gcd(...i),l=s.Numeric.lcm(...n);t.coefficient=new o.Fraction(a,l).reduce();for(let i of e){for(let e in t.literal)e in i.literal||t.literal[e].zero();for(let e in i.literal)void 0===t.literal[e]&&i.literal[e].isStrictlyPositive()?t.literal[e]=i.literal[e].clone():t.literal[e]=new o.Fraction(Math.min(i.literal[e].value,t.literal[e].value))}return t},r.xmultiply=(...e)=>{let t=(new r).one();for(let i of e)t.multiply(i);return t}},38:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Polynom=void 0;const s=i(937),n=i(505),o=i(956),r=i(506),a=i(760);class l{constructor(e,...t){return this.mark_as_dirty=()=>{this.dirty_factors=!0,this.dirty_zeroes=!0,this.euclidianCache={}},this.addToken=(e,t)=>{switch(t.tokenType){case n.ShutingyardType.COEFFICIENT:e.push(new l(t.token));break;case n.ShutingyardType.VARIABLE:e.push((new l).add(new s.Monom(t.token)));break;case n.ShutingyardType.CONSTANT:console.log("Actually, not supported - will be added later !");break;case n.ShutingyardType.OPERATION:if(e.length>=2){const i=e.pop(),s=e.pop();if("+"===t.token)e.push(s.add(i));else if("-"===t.token)e.push(s.subtract(i));else if("*"===t.token)e.push(s.multiply(i));else if("/"===t.token)i.degree().isStrictlyPositive()?console.log("divide by a polynom -> should create a rational polynom !"):e.push(s.divide(i.monoms[0].coefficient));else if("^"===t.token)if(i.degree().isStrictlyPositive())console.error("Cannot elevate a polynom with another polynom !",s.tex,i.tex);else if(i.monoms[0].coefficient.isRelative())e.push(s.pow(i.monoms[0].coefficient.value));else if(1===s.monoms.length&&s.monoms[0].coefficient.isOne()){for(let e in s.monoms[0].literal)s.monoms[0].literal[e].multiply(i.monoms[0].coefficient);e.push(s)}else console.error("Cannot have power with fraction")}else{if("-"!==t.token)throw"Error parsing the polynom "+this._rawString;e.push(e.pop().opposed())}break;case n.ShutingyardType.MONOM:console.error("The monom token should not appear here");break;case n.ShutingyardType.FUNCTION:console.error("The function token should not appear here - might be introduced later.")}},this.parse=(e,...t)=>{if(this._monoms=[],this._factors=[],this.mark_as_dirty(),"string"==typeof e)return this._parseString(e,...t);if(!("number"==typeof e||e instanceof r.Fraction||e instanceof s.Monom)||void 0!==t&&0!==t.length){if(e instanceof s.Monom&&t.length>0)this._monoms.push(new s.Monom(e)),t.forEach((e=>{this._monoms.push(new s.Monom(e))}));else if(e instanceof l)for(const t of e.monoms)this._monoms.push(t.clone())}else this._monoms.push(new s.Monom(e));return this},this.clone=()=>{const e=new l,t=[];for(const e of this._monoms)t.push(e.clone());return e.monoms=t,e},this.zero=()=>(this._monoms=[],this._monoms.push((new s.Monom).zero()),this._rawString="0",this.mark_as_dirty(),this),this.one=()=>(this._monoms=[],this._monoms.push((new s.Monom).one()),this._rawString="1",this.mark_as_dirty(),this),this.empty=()=>(this._monoms=[],this._rawString="",this.mark_as_dirty(),this),this.opposed=()=>(this._monoms=this._monoms.map((e=>e.opposed())),this.mark_as_dirty(),this),this.add=(...e)=>{this.mark_as_dirty();for(let t of e)t instanceof l?this._monoms=this._monoms.concat(t.monoms):t instanceof s.Monom?this._monoms.push(t.clone()):Number.isSafeInteger(t)?this._monoms.push(new s.Monom(t.toString())):this._monoms.push(new s.Monom(t));return this.reduce()},this.subtract=(...e)=>{this.mark_as_dirty();for(let t of e)t instanceof l?this._monoms=this._monoms.concat(t.clone().opposed().monoms):t instanceof s.Monom?this._monoms.push(t.clone().opposed()):Number.isSafeInteger(t)?this._monoms.push(new s.Monom(t.toString()).opposed()):this._monoms.push(new s.Monom(t).opposed());return this.reduce()},this.multiply=e=>(this.mark_as_dirty(),e instanceof l?this.multiplyByPolynom(e):e instanceof r.Fraction?this.multiplyByFraction(e):e instanceof s.Monom?this.multiplyByMonom(e):Number.isSafeInteger(e)&&"number"==typeof e?this.multiplyByInteger(e):this),this.euclidian=e=>{if(void 0!==this.euclidianCache[e.tex])return this.euclidianCache[e.tex];const t=e.variables[0],i=(new l).zero(),s=this.clone().reorder(t);if(0===e.variables.length)return this.clone().divide(e),{quotient:this.clone().divide(e),reminder:(new l).zero()};const n=e.monomByDegree(void 0,t),o=e.degree(t);let r,a=this.degree(t).clone().multiply(2);for(;s.degree(t).geq(o)&&a.isPositive()&&(a.subtract(1),r=s.monomByDegree(void 0,t).clone().divide(n),!r.isZero());)i.add(r),s.subtract(e.clone().multiply(r));return i.reduce(),s.reduce(),{quotient:i,reminder:s}},this.divide=e=>{if(this.mark_as_dirty(),e instanceof r.Fraction)return this.divideByFraction(e);if("number"==typeof e&&Number.isSafeInteger(e))return this.divideByInteger(e);if(e instanceof s.Monom)return this.divide(new l(e));if(e instanceof l){if(1===e.monoms.length&&0===e.variables.length)return this.divideByFraction(e.monoms[0].coefficient);{let{quotient:t,reminder:i}=this.euclidian(e);return i.isZero()?t:(console.log(`${this.tex} is not divideable by ${e.tex}`),(new l).zero())}}},this.pow=e=>{if(this.mark_as_dirty(),!Number.isSafeInteger(e))return this.zero();if(e<0)return this.zero();if(0===e)return new l;const t=this.clone();for(let i=1;i<e;i++)this.multiply(t);return this.reduce()},this.compare=(e,t)=>{void 0===t&&(t="=");const i=this.clone().reduce().reorder(),s=e.clone().reduce().reorder();switch(t){case"=":if(i.length!==s.length||i.degree().isNotEqual(s.degree()))return!1;for(const e in i.monoms)if(!i.monoms[e].isEqual(s.monoms[e]))return!1;return!0;case"same":if(i.length!==s.length||i.degree()!==s.degree())return!1;for(const e in i.monoms)if(!i.monoms[e].isSameAs(s.monoms[e]))return!1;return!0;default:return!1}},this.isEqual=e=>this.compare(e,"="),this.isSameAs=e=>this.compare(e,"same"),this.isOpposedAt=e=>this.compare(e.clone().opposed(),"="),this.isFactorized=(e,t)=>{let i;if(e.split("(").length!==e.split(")").length)return!1;try{i=new l(e)}catch(e){return!1}if(!this.isEqual(i))return!1;let s=e.replaceAll("*",""),n=""+s,o=[];for(let e of s.matchAll(/\(([a-z0-9+\-]+)\)(\^[0-9]*)?/g)){if(void 0!==e[2])for(let t=0;t<+e[2].substring(1);t++)o.push(e[1]);else o.push(e[1]);n=n.replaceAll(e[0],"")}""!==n&&o.push(n);let a=o.map((e=>new l(e))),h=a.filter((e=>e.degree().geq(1)&&!e.commonMonom().isOne()));if(h.length>0&&!t)return!1;if(h.length>0&&t){a=a.filter((e=>e.commonMonom().isOne()));let e=(new r.Fraction).one();for(let t of h){let i=t.commonMonom(),s=t.clone().divide(i);i.degree().isZero()&&(e.multiply(i.coefficient),a.push(s.clone()))}}this.factorize();let c=1,u=[];for(let e of this.factors){e.degree().isZero()&&e.monoms[0].coefficient.isNegativeOne()&&(c=-c);let t=!1;for(let i=0;i<a.length;i++){if(e.isEqual(a[i])){a.splice(i,1),t=!0;break}if(e.isOpposedAt(a[i])){a.splice(i,1),c=-c,t=!0;break}}t||u.push(e.clone())}return 0===a.length&&1===c},this.isReduced=e=>{if(!this.isDeveloped(e))return!1;let t=new l(e);if(t.monoms.length>this.monoms.length)return!1;for(let e of t.monoms)if(!e.coefficient.isReduced())return!1;return!1},this.isDeveloped=e=>{let t,i=e.replaceAll(/\^\(([-0-9/]+)\)/g,"$1");if(i.includes("(")||i.includes(")"))return!1;try{t=new l(e)}catch(e){return!1}return!!this.isEqual(t)},this.reduce=()=>{let e=[...this._monoms],t=[...this.variables];this._monoms=[];let i=e.filter((e=>0===e.variables.length));i.length>0&&this._monoms.push(i.reduce(((e,t)=>e.add(t))));for(let i of t){let t=e.filter((e=>e.hasLetter(i)));for(;t.length>0;){const e=t.shift(),s=e.degree(i);for(let n of t.filter((e=>e.degree(i).isEqual(s))))e.add(n);this._monoms.push(e),t=t.filter((e=>e.degree(i).isNotEqual(s)))}}this._monoms=this._monoms.filter((e=>0!==e.coefficient.value));for(const e of this._monoms)e.coefficient.reduce();return 0===this.length?(new l).zero():this.reorder()},this.reorder=(e="x",t)=>{void 0===t&&(t=!1);let i=this.variables.filter((t=>t!==e));return this._monoms.sort((function(s,n){let o=s.degree(e).value,r=n.degree(e).value;if(o!==r)return t?o-r:r-o;if(i.length>0)for(let e of i){let i=s.degree(e).value,o=n.degree(e).value;if(i!==o)return t?i-o:o-i}return 0})),this},this.degree=e=>{let t=(new r.Fraction).zero();for(const i of this._monoms)t=r.Fraction.max(i.degree(e).value,t);return t},this.letters=()=>{let e=new Set;for(let t of this._monoms)e=new Set([...e,...t.variables]);return[...e]},this.replaceBy=(e,t)=>{let i;this.mark_as_dirty();const s=(new l).zero();for(const n of this.monoms)void 0===n.literal[e]||n.literal[e].isZero()?s.add(n.clone()):(i=n.literal[e].clone(),delete n.literal[e],s.add(t.clone().pow(Math.abs(i.numerator)).multiply(n)));return this._monoms=s.reduce().reorder().monoms,this},this.evaluate=e=>{const t=(new r.Fraction).zero();return this._monoms.forEach((i=>{t.add(i.evaluate(e))})),t},this.evaluateAsNumeric=e=>{let t=0;return this._monoms.forEach((i=>{t+=i.evaluateAsNumeric(e)})),t},this.derivative=e=>{let t=new l;for(let i of this._monoms)t.add(i.derivative(e));return t},this.primitive=e=>{let t=new l;for(let i of this._monoms)t.add(i.primitive(e));return t},this.integrate=(e,t,i)=>{const s=this.primitive(i);void 0===i&&(i="x");let n={},o={};return n[i]=new r.Fraction(e),o[i]=new r.Fraction(t),s.evaluate(o).subtract(s.evaluate(n))},this.factorize=e=>{if(!this.dirty_factors)return this._factors;let t=[],i=this.clone().reorder(),s=i.commonMonom();if(i.monomByDegree().coefficient.isStrictlyNegative()&&s.coefficient.isStrictlyPositive()&&!s.isOne()&&s.opposed(),!s.isOne()){let e=new l(s);t=[e.clone()],i=i.euclidian(e).quotient}let n=i.degree().clone().multiply(2).value,o=1;for(;n>=0;){if(n--,i.monoms.length<2){i.isOne()||(t.push(i.clone()),i.one());break}if(i.degree(e).isOne()){t.push(i.clone()),i.one();break}{let s=this._getAllPotentialFactors(i,o,e);for(o=i.degree(e).value;s.length>0;){let e=s[0];if(i.isDividableBy(e)){let n=i.euclidian(e);t.push(e),i=n.quotient.clone(),s=s.filter((e=>{let t=i.monoms[0],s=i.monoms[i.monoms.length-1],n=e.monoms[0],o=e.monoms[e.monoms.length-1];return!!s.isDivisible(o)&&!!t.isDivisible(n)}))}else s.shift()}}}return i.isOne()||t.push(i.clone()),this._factors=t,this.dirty_factors=!1,this._factors},this.isDividableBy=e=>{if(e.degree().isOne()){let t=e.getZeroes()[0];return t.exact instanceof r.Fraction&&this.evaluate(t.exact).isZero()}return this.euclidianCache[e.tex]=this.euclidian(e),this.euclidianCache[e.tex].reminder.isZero()},this.getZeroes=()=>{if(this.dirty_zeroes){let e=new a.Equation(this.clone(),0);e.solve(),this._zeroes=e.solutions,this.dirty_zeroes=!1}return this._zeroes},this.monomByDegree=(e,t)=>{if(void 0===e)return this.monomByDegree(this.degree(t),t);const i=this.clone().reduce();for(const s of i._monoms)if(s.degree(t).isEqual(e))return s.clone();return(new s.Monom).zero()},this.monomsByDegree=(e,t)=>{if(void 0===e)return this.monomsByDegree(this.degree(t));let i=[];const s=this.clone().reduce();for(const n of s._monoms)n.degree(t)===e&&i.push(n.clone());return i},this.monomByLetter=e=>{const t=this.clone().reduce();for(const i of t._monoms)if(i.hasLetter(e))return i.clone();return(new s.Monom).zero()},this.getDenominators=()=>{const e=[];for(const t of this._monoms)e.push(t.coefficient.denominator);return e},this.getNumerators=()=>{const e=[];for(const t of this._monoms)e.push(t.coefficient.numerator);return e},this.lcmDenominator=()=>o.Numeric.lcm(...this.getDenominators()),this.gcdDenominator=()=>o.Numeric.gcd(...this.getDenominators()),this.lcmNumerator=()=>o.Numeric.lcm(...this.getNumerators()),this.gcdNumerator=()=>o.Numeric.gcd(...this.getNumerators()),this.commonMonom=()=>{let e,t,i=(new s.Monom).one(),n=this.degree();e=this.gcdNumerator(),t=this.gcdDenominator(),i.coefficient=new r.Fraction(e,t);for(let e of this.variables){i.setLetter(e,n);for(let t of this._monoms)if(i.setLetter(e,r.Fraction.min(t.degree(e),i.degree(e))),i.degree(e).isZero())break}return i},this.limitToInfinity=e=>{const t=this.monomByDegree(void 0,e),i=t.coefficient.sign(),s=t.degree(e);return s.isStrictlyPositive()?1===i?(new r.Fraction).infinite():(new r.Fraction).infinite().opposed():s.isZero()?t.coefficient:(new r.Fraction).zero()},this.limitToNegativeInfinity=e=>{const t=this.monomByDegree(void 0,e),i=t.coefficient.sign(),s=t.degree(e);return s.isStrictlyPositive()?-1===i?(new r.Fraction).infinite():(new r.Fraction).infinite().opposed():s.isZero()?t.coefficient:(new r.Fraction).zero()},this._getAllPotentialFactors=(e,t,i)=>{let s=e.monoms[0].dividers,n=e.monoms[e.monoms.length-1].dividers,o=[];return s.forEach((e=>{e.degree(i).leq(t)&&n.forEach((t=>{e.degree(i).isNotEqual(t.degree(i))&&(o.push(new l(e,t)),o.push(new l(e,t.clone().opposed())))}))})),o},this.genDisplay=(e,t,i,s)=>{let n="";for(const i of this._monoms){if(0===i.coefficient.value)continue;let o;o=s?i.plotFunction:"tex"===e?i.tex:i.display,n+=`${1!==i.coefficient.sign()||""===n&&!0!==t?"":"+"}${o}`}return!0===i&&this.length>1&&(n="tex"===e?`\\left( ${n} \\right)`:`(${n})`),""===n&&(n="0"),n},this.shutingYardToReducedPolynom=e=>{const t=(new n.Shutingyard).parse(e).rpn;this.zero();let i=[];new s.Monom;for(const e of t)this.addToken(i,e);return 1===i.length&&this.add(i[0]),this.reorder()},this.multiplyByPolynom=e=>{const t=[];for(const i of this._monoms)for(const n of e.monoms)t.push(s.Monom.xmultiply(i,n));return this._monoms=t,this.reduce()},this.multiplyByFraction=e=>{for(const t of this._monoms)t.coefficient.multiply(e);return this.reduce()},this.multiplyByInteger=e=>this.multiplyByFraction(new r.Fraction(e)),this.multiplyByMonom=e=>{for(const t of this._monoms)t.multiply(e);return this.reduce()},this.divideByInteger=e=>{const t=new r.Fraction(e);for(const e of this._monoms)e.coefficient.divide(t);return this},this.divideByFraction=e=>{for(const t of this._monoms)t.coefficient.divide(e);return this},this._factorize2ndDegree=e=>{let t,i,s,n,o,r,a,h,c;if(1===this.numberOfVars)return s=this.monomByDegree(2,e).coefficient,n=this.monomByDegree(1,e).coefficient,o=this.monomByDegree(0,e).coefficient,r=n.clone().pow(2).subtract(s.clone().multiply(o).multiply(4)),r.isZero()?(a=n.clone().opposed().divide(s.clone().multiply(2)),t=new l(e).subtract(a.display).multiply(a.denominator),i=new l(e).subtract(a.display).multiply(a.denominator),c=s.divide(a.denominator).divide(a.denominator),c.isOne()?[t,i]:[new l(c.display),t,i]):r.isPositive()&&r.isSquare()?(a=n.clone().opposed().add(r.clone().sqrt()).divide(s.clone().multiply(2)),h=n.clone().opposed().subtract(r.clone().sqrt()).divide(s.clone().multiply(2)),c=s.divide(a.denominator).divide(h.denominator),c.isOne()?[new l(e).subtract(a.display).multiply(a.denominator),new l(e).subtract(h.display).multiply(h.denominator)]:[new l(c.display),new l(e).subtract(a.display).multiply(a.denominator),new l(e).subtract(h.display).multiply(h.denominator)]):[this.clone()];if(s=this.monomByDegree(2,e),n=this.monomByDegree(1,e),o=this.monomByDegree(0,e),s.isLiteralSquare()&&o.isLiteralSquare()&&n.clone().pow(2).isSameAs(s.clone().multiply(o))){let e,t=new l("x",s.coefficient,n.coefficient,o.coefficient)._factorize2ndDegree("x"),i=[];if(t.length>=2){for(let n of t)n.degree().isZero()?i.push(n.clone()):(e=n.clone(),e.monoms[0].literal=s.literalSqrt,e.monoms[1].literal=o.literalSqrt,i.push(e.clone()));return i}}return[this.clone()]},this._factorizeByGroups=()=>[],this._monoms=[],this._factors=[],this.mark_as_dirty(),void 0!==e&&this.parse(e,...t),this}get euclidianCache(){return this._euclidianCache}set euclidianCache(e){this._euclidianCache=e}get dirty_zeroes(){return this._dirty_zeroes}set dirty_zeroes(e){this._dirty_zeroes=e}get dirty_factors(){return this._dirty_factors}set dirty_factors(e){this._dirty_factors=e}get monoms(){return this._monoms}set monoms(e){this._monoms=e}get zeroes(){return this.getZeroes()}get factors(){return this.factorize()}set factors(e){this.mark_as_dirty(),this._factors=e}get texString(){return this._texString}get texFactors(){if(this.factorize(),this.factors.length<=1)return this.tex;let e={};for(let t of this.factors)void 0!==e[t.tex]?e[t.tex].degree++:e[t.tex]={degree:1,factor:t};let t=(new l).one();for(let i of Object.values(e).filter((e=>1===e.factor.monoms.length)))t.multiply(i.factor);let i=t.isOne()?"":t.tex;for(let t of Object.values(e).filter((e=>e.factor.monoms.length>1)))t.factor.length>1&&(i+=`\\left( ${t.factor.tex} \\right)${t.degree>1?"^{ "+t.degree+" }":""}`);return i}get displayFactors(){if(this.factorize(),this.factors.length<=1)return this.display;let e={};for(let t of this.factors)void 0!==e[t.display]?e[t.display].degree++:e[t.display]={degree:1,factor:t};let t=(new l).one();for(let i of Object.values(e).filter((e=>1===e.factor.monoms.length)))t.multiply(i.factor);let i=t.isOne()?"":t.display;for(let t of Object.values(e).filter((e=>e.factor.monoms.length>1)))t.factor.length>1&&(i+=`(${t.factor.display})${t.degree>1?"^("+t.degree+")":""}`);return i}get length(){return this._monoms.length}get display(){return this.genDisplay()}get raw(){return this._rawString}get tex(){return this.genDisplay("tex")}get isMultiVariable(){for(const e of this._monoms)if(e.variables.length>1)return!0;return!1}get variables(){let e=[];for(const t of this._monoms)e=e.concat(t.variables);return e=[...new Set(e)],e.sort(),e}get numberOfVars(){return this.variables.length}get plotFunction(){return this.genDisplay("tex",!1,!1,!0)}isZero(){return 1===this._monoms.length&&this._monoms[0].coefficient.isZero()||0===this._monoms.length}isOne(){return 1===this._monoms.length&&this._monoms[0].coefficient.isOne()}_parseString(e,...t){if(void 0===t||0===t.length){if(e=""+e,this._rawString=e.trim().replaceAll(" ",""),""!==e&&!isNaN(Number(e))){this.empty();let t=new s.Monom(e);return this.add(t),this}return this.shutingYardToReducedPolynom(e)}if(/^[a-z]/.test(e)){this.empty();let i=t.map((e=>new r.Fraction(e)));if(e.length>1){let t=e.split(""),n=0;for(let e of i){let i=new s.Monom;i.coefficient=e.clone(),i.literalStr=t[n]||"",this.add(i),n++}}else{let t=i.length-1;for(let n of i){let i=new s.Monom;i.coefficient=n.clone(),i.literalStr=`${e}^${t}`,this.add(i),t--}}return this}return this.zero()}}t.Polynom=l},107:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Rational=void 0;const s=i(38),n=i(506),o=i(760),r=i(572);class a{constructor(e,t){this.clone=()=>new a(this._numerator.clone(),this._denominator.clone()),this.domain=()=>{let e=this._denominator.getZeroes();return 0===e.length||e[0].tex===o.PARTICULAR_SOLUTION.real?o.PARTICULAR_SOLUTION.varnothing:e[0].tex===o.PARTICULAR_SOLUTION.varnothing?o.PARTICULAR_SOLUTION.real:"\\mathbb{R}\\setminus\\left\\{"+e.map((e=>e.tex)).join(";")+"\\right\\}"},this.amplify=e=>(this._numerator.multiply(e),this._denominator.multiply(e),this),this.derivative=e=>{let t=this._numerator.clone(),i=this._denominator.clone(),s=t.clone().derivative(e),n=i.clone().derivative(e);return this._numerator=s.clone().multiply(i).subtract(t.clone().multiply(n)),this._denominator=i.clone().pow(2),this},this.factorize=e=>(this._numerator.factorize(e),this._denominator.factorize(e),this),this.simplify=e=>{let t=this._numerator.euclidian(e);if(!t.reminder.isZero())return this;let i=this._denominator.euclidian(e);return i.reminder.isZero()?(this._numerator=t.quotient,this._denominator=i.quotient,this):this},this.reduce=()=>{this._numerator.factorize();for(let e of this._numerator.factors)e.degree().isZero()?this._denominator.commonMonom().coefficient.clone().divide(e.monomByDegree().coefficient).isNatural()&&this.simplify(e):this.simplify(e);return this},this.opposed=()=>(this._numerator.opposed(),this),this.add=e=>{let t=this._denominator.clone();return this.amplify(e._denominator),this._numerator.add(e._numerator.clone().multiply(t)),this},this.subtract=e=>this.add(e.clone().opposed()),this.euclidian=()=>this._numerator.euclidian(this._denominator),this.limits=(e,t,i)=>{if(e===1/0||e===-1/0){let{quotient:t,reminder:s}=this._numerator.clone().euclidian(this._denominator);return t.degree(i).isStrictlyPositive()?e===1/0?t.limitToInfinity(i):t.limitToNegativeInfinity(i):t.monomByDegree(void 0,i).coefficient}{let s,o,r={},a={},l=this.clone().reduce();return r[void 0===i?"x":i]=new n.Fraction(e),"above"!==t&&"below"!==t?(s=l._numerator.evaluate(r).divide(l._denominator.evaluate(r)),s.isInfinity()?s.abs():s):("above"===t?a[void 0===i?"x":i]=new n.Fraction(e).add(1e-6):"below"===t&&(a[void 0===i?"x":i]=new n.Fraction(e).subtract(1e-6)),s=l._numerator.evaluate(r).divide(l._denominator.evaluate(r)),o=l._numerator.evaluate(a).divide(l._denominator.evaluate(a)).sign(),s.isInfinity()?1===o?s.abs():s.abs().opposed():s)}},this.evaluate=e=>{(new n.Fraction).zero();let t=this._numerator.evaluate(e),i=this._denominator.evaluate(e);return t.divide(i)},this.evaluateAsNumeric=e=>this._numerator.evaluateAsNumeric(e)/this._denominator.evaluateAsNumeric(e),this.study=e=>new r.RationalStudy(this,e),e instanceof s.Polynom?this._numerator=e.clone():this._numerator="string"==typeof e?new s.Polynom(e):new s.Polynom,t instanceof s.Polynom?this._denominator=t.clone():this._denominator="string"==typeof t?new s.Polynom(t):new s.Polynom}get numerator(){return this._numerator}get denominator(){return this._denominator}get tex(){return`\\frac{ ${this._numerator.tex} }{ ${this._denominator.tex} }`}get display(){return`(${this._numerator.display})/(${this._denominator.display})`}get texFactors(){return`\\frac{ ${this._numerator.texFactors} }{ ${this._denominator.texFactors} }`}get plotFunction(){return`(${this._numerator.plotFunction})/(${this._denominator.plotFunction})`}}t.Rational=a},996:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Study=t.TABLE_OF_SIGNS=t.FUNCTION_EXTREMA=t.ASYMPTOTE_POSITION=t.ASYMPTOTE=t.ZEROTYPE=void 0;const s=i(506),n=i(394);var o,r,a,l,h;!function(e){e.ZERO="z",e.DEFENCE="d",e.NOTHING="t"}(o||(t.ZEROTYPE=o={})),function(e){e.VERTICAL="av",e.HORIZONTAL="ah",e.SLOPE="ao",e.HOLE="hole"}(r||(t.ASYMPTOTE=r={})),function(e){e.LT="LT",e.RT="RT",e.LB="LB",e.RB="RB"}(a||(t.ASYMPTOTE_POSITION=a={})),function(e){e.MIN="min",e.MAX="max",e.FLAT="flat",e.NOTHING=""}(l||(t.FUNCTION_EXTREMA=l={})),function(e){e.SIGNS="signs",e.GROWS="grows",e.VARIATIONS="variatins"}(h||(t.TABLE_OF_SIGNS=h={})),t.Study=class{constructor(e,t){if(this.makeStudy=()=>{this._zeroes=this.makeZeroes(),this._config.signs&&(this._signs=this.makeSigns()),this._config.asymptotes&&(this._asymptotes=this.makeAsymptotes()),this._config.derivative&&(this._derivative=this.makeDerivative()),this._config.variations&&(this._variations=this.makeVariation()),this._config.signs&&(this._signs.tex=this.texSigns),this._config.derivative&&(this._derivative.tex=this.texGrows),this._config.variations&&(this._variations.tex=this.texVariations)},this.indexOfZero=(e,t)=>{for(let i=0;i<e.length;i++)if(e[i].tex===t.tex)return i;return-1},this.makeOneLineForSigns=(e,t,i)=>{let s=[],n=e.getZeroes().map((e=>e.tex));s.push(""),e.degree().isZero()?s.push(1===e.monoms[0].coefficient.sign()?"+":"-"):s.push(1===e.evaluate(t[0].value-1).sign()?"+":"-");for(let r=0;r<t.length;r++)s.push(n.includes(t[r].tex)?i:o.NOTHING),r<t.length-1?s.push(1===e.evaluate((t[r].value+t[r+1].value)/2).sign()?"+":"-"):r===t.length-1&&s.push(1===e.evaluate(t[r].value+1).sign()?"+":"-");return s.push(""),s},this.makeSignsResult=e=>{let t=e[0].map(((t,i)=>0===i||i===e[0].length-1?"":i%2==0?"t":"+"));for(let i of e)for(let e=0;e<i.length;e++)if(e%2==0){if("d"===t[e])continue;"t"!==i[e]&&(t[e]=i[e])}else"-"===i[e]&&(t[e]="+"===t[e]?"-":"+");return t},this.makeGrowsResult=e=>{let t=Object.values(e.signs),i=t[t.length-1],o=[],r={},a=e.zeroes;for(let e=0;e<a.length;e++){let t=2*e+2;if("z"===i[t]){let o,h,c,u,d,f=a[e].exact,m=new n.NumExp(this.fx.plotFunction);if(f instanceof s.Fraction){let e=f,t=this.fx.evaluate(e);o=f.value,h=t.value,c=f.tex,u=t.tex}else o=a[e].value,h=m.evaluate({x:o}),c=o.toFixed(2),u=h.toFixed(2);d=i[t-1]===i[t+1]?l.FLAT:"+"===i[t-1]?l.MAX:l.MIN,r[a[e].tex]={type:d,tex:{x:c,y:u},value:{x:o,y:h}}}}o.push("+"===i[1]?"-/":"+/");for(let e=1;e<i.length-1;e++)if("z"===i[e]){let t=r[a[(e-2)/2].tex];o.push(`${i[e-1]}/\\(${t.type}(${t.tex.x};${t.tex.y})\\)`)}else"d"===i[e]&&o.push(`${i[e-1]}D${"+"===i[e+1]?"-":"+"}/`);return o.push(`${i[i.length-2]}/`),{growsLine:o,extremes:r}},this.makeVariationsResult=e=>({varsLine:[],extremes:{}}),this.drawCode=()=>{let e=`f(x)=${this.fx.plotFunction}`,t=1;this.asymptotes.forEach((i=>{i.type===r.VERTICAL?(e+=`\nav_${t}=line x=${i.zero.value}->red,dash`,t++):i.type===r.HORIZONTAL?e+=`\nah=line y=${i.fx.monoms[0].coefficient.value}->orange,dash`:i.type===r.SLOPE&&(e+=`\nao=line y=${i.fx.plotFunction}->red,dash`),t++}));for(let i in this.derivative.extremes){let s=this.derivative.extremes[i];e+=`\nM_${t}(${s.value.x},${s.value.y})*`,t++}return this.zeroes.forEach((i=>{i.type===o.ZERO&&(e+=`\nZ_${t}(${i.value},0)*`,t++)})),e},this._makeTexFromTableOfSigns=e=>{let t=e.factors.map((e=>`\\(${e.tex}\\)/1`)),i=`\\(${this._config.name}(${this._config.variable})\\)/1.2`,s=e.zeroes;e.type===h.GROWS?i=`\\(${this._config.name}'(${this._config.variable})\\)/1.2,\\(f(x${this._config.variable})\\)/2`:e.type===h.VARIATIONS&&(i=`\\(${this._config.name}''(${this._config.variable})\\)/1.2,\\(f(${this._config.variable})\\)/2`);let n,o=`\\begin{tikzpicture}\n\\tkzTabInit[lgt=3,espcl=2,deltacl=0]{/1.2,${t.join(",")},/.1,${i} }{{\\scriptsize \\hspace{1cm} \\(-\\infty\\)},\\(${s.map((e=>e.tex)).join("\\),\\(")}\\),{\\scriptsize \\hspace{-1cm} \\(+\\infty\\)}}`;for(n=0;n<e.factors.length;n++)o+=`\n\\tkzTabLine{${e.signs[n].join(",")}}`;return o+=`\n\\tkzTabLine{${e.signs[n].join(",")}}`,(e.type===h.GROWS||e.type===h.VARIATIONS)&&(o+=`\n\\tkzTabVar{${e.signs[n+1].join(",")}}`),o+="\n\\end{tikzpicture}",o},this.fx=e,this._config={name:"f",variable:"x",domain:!0,asymptotes:!0,signs:!0,derivative:!0,variations:!0},t)if("string"==typeof t){const e=t.split(",");this._config={};let i=e.filter((e=>e.includes("(")&&e.includes(")")));1===i.length&&(this._config.name=i[0].split("(")[0],this._config.variable=i[0].split("(")[1].split(")")[0]),this._config.domain=e.includes("d"),this._config.asymptotes=e.includes("a"),this._config.signs=e.includes("signs"),this._config.derivative=e.includes("dx"),this._config.variations=e.includes("ddx")}else this._config=t;return this.makeStudy(),this}get name(){return this._config.name}set name(e){this._config.name=e}get config(){return this._config}set config(e){this._config=e}get zeroes(){return this._zeroes}get domain(){return this.fx.domain()}get signs(){return this._signs}get asymptotes(){return this._asymptotes}get derivative(){return this._derivative}get texSigns(){return this._makeTexFromTableOfSigns(this._signs)}get texGrows(){return this._makeTexFromTableOfSigns(this._derivative)}get texVariations(){return this._makeTexFromTableOfSigns(this._variations)}makeZeroes(){return[]}makeSigns(){return{type:h.SIGNS,fx:null,factors:[],zeroes:[],signs:[],extremes:{},tex:""}}makeAsymptotes(){return[]}makeDerivative(){return{type:h.GROWS,fx:null,factors:[],zeroes:[],signs:[],extremes:{},tex:""}}makeVariation(){return{type:h.VARIATIONS,fx:null,factors:[],zeroes:[],signs:[],extremes:{},tex:""}}}},572:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RationalStudy=void 0;const s=i(996),n=i(107),o=i(506),r=i(38);class a extends s.Study{constructor(e,t){return super(e,t),this}makeZeroes(){return this._getZeroes(this.fx)}makeSigns(){return this._getSigns(this.fx,this.zeroes)}makeAsymptotes(){const e=this.fx.clone().reduce();let t=[];this.zeroes.filter((e=>e.type===s.ZEROTYPE.DEFENCE)).forEach((i=>{let n=s.ASYMPTOTE.VERTICAL,r=`x=${i.tex}`,a=`x=${i.display}`;i.exact instanceof o.Fraction?e.denominator.evaluate(i.exact).isNotZero()&&(n=s.ASYMPTOTE.HOLE,r=`(${i.tex};${e.evaluate(i.exact).tex})`,a=`(${i.display};${e.evaluate(i.exact).display})`):e.denominator.evaluate(i.value).isNotZero()&&(n=s.ASYMPTOTE.HOLE,r=`(${i.tex};${e.evaluate(i.value).tex})`,a=`(${i.display};${e.evaluate(i.value).display})`);const l=1e-6;let h=this.fx.evaluateAsNumeric(i.value-l),c=this.fx.evaluateAsNumeric(i.value+l),u=[],d="";c<-1e4?(u.push(s.ASYMPTOTE_POSITION.RB),d+="m"):c>1e4&&(u.push(s.ASYMPTOTE_POSITION.RT),d+="p"),h<-1e4?(u.push(s.ASYMPTOTE_POSITION.LB),d+="m"):h>1e4&&(u.push(s.ASYMPTOTE_POSITION.LT),d+="p"),d="pp"===d?"+":"mm"===d?"-":`\\${d}`,t.push({fx:null,type:n,tex:r,display:a,zero:i,limits:`\\lim_{x\\to${i.tex} }\\ f(x) = ${d}\\infty`,deltaX:null,tableOfSign:null,position:u})}));let i=this.fx.numerator.degree(),a=this.fx.denominator.degree();if(i.isEqual(a)){let i=this.fx.numerator.monomByDegree().coefficient.clone().divide(this.fx.denominator.monomByDegree().coefficient),o=i.tex,{reminder:a}=e.euclidian(),l=new n.Rational(a,e.denominator);t.push({fx:new r.Polynom(i),type:s.ASYMPTOTE.HORIZONTAL,tex:`y=${o}`,display:`y=${i.display}`,zero:null,limits:`\\lim_{x\\to\\infty}\\ f(x) = ${o}`,deltaX:l,tableOfSign:this._getSigns(l),position:this._getHorizontalAsymptoteRelativePositon(l)})}else if(a.greater(i))t.push({fx:new r.Polynom("0"),type:s.ASYMPTOTE.HORIZONTAL,tex:"y=0",display:"y=0",zero:null,limits:"\\lim_{x\\to\\infty}\\ f(x) = 0",deltaX:null,tableOfSign:null,position:this._getHorizontalAsymptoteRelativePositon(this.fx)});else if(i.value-1===a.value){let{quotient:i,reminder:o}=e.euclidian(),r=new n.Rational(o,e.denominator);t.push({fx:i.clone(),type:s.ASYMPTOTE.SLOPE,tex:`y=${i.tex}`,display:`y=${i.display}`,zero:null,limits:"",deltaX:new n.Rational(o,e.denominator),tableOfSign:this._getSigns(r),position:this._getHorizontalAsymptoteRelativePositon(r)})}return t}_getHorizontalAsymptoteRelativePositon(e,t=1e6){let i=[],n=e.evaluateAsNumeric(-t),o=e.evaluateAsNumeric(t);return n>=0?i.push(s.ASYMPTOTE_POSITION.LT):i.push(s.ASYMPTOTE_POSITION.LB),o>=0?i.push(s.ASYMPTOTE_POSITION.RT):i.push(s.ASYMPTOTE_POSITION.RB),i}makeDerivative(){let e=this.fx.clone().derivative(),t=this._getSigns(e,this._getZeroes(e),s.TABLE_OF_SIGNS.GROWS),i=this.makeGrowsResult(t);return t.signs.push(i.growsLine),t.extremes=i.extremes,t}makeVariation(){let e=this.derivative.fx.clone().derivative(),t=this._getSigns(e,this._getZeroes(e),s.TABLE_OF_SIGNS.VARIATIONS),i=this.makeVariationsResult(t);return t.signs.push(i.varsLine),t.extremes=i.extremes,t}_getZeroes(e){let t=[];return e.numerator.getZeroes().filter((e=>!isNaN(e.value))).forEach((e=>{t.push({tex:e.tex,display:e.display,value:e.value,exact:e.exact,extrema:s.FUNCTION_EXTREMA.NOTHING,type:s.ZEROTYPE.ZERO})})),e.denominator.getZeroes().filter((e=>!isNaN(e.value))).forEach((e=>{let i=this.indexOfZero(t,e);-1!==i?t[i].type=s.ZEROTYPE.DEFENCE:t.push({tex:e.tex,display:e.display,value:e.value,exact:e.exact,extrema:s.FUNCTION_EXTREMA.NOTHING,type:s.ZEROTYPE.DEFENCE})})),t.sort(((e,t)=>e.value-t.value)),t}_getSigns(e,t,i){let n=[],o=[];return void 0===t&&(t=this._getZeroes(e)),e.numerator.factors.forEach((e=>{n.push(this.makeOneLineForSigns(e,t,s.ZEROTYPE.ZERO)),o.push(e.clone())})),e.denominator.factors.forEach((e=>{n.push(this.makeOneLineForSigns(e,t,s.ZEROTYPE.DEFENCE)),o.push(e.clone())})),n.push(this.makeSignsResult(n)),{type:i,fx:e,factors:o,zeroes:t,signs:n,extremes:{},tex:""}}}t.RationalStudy=a},506:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fraction=void 0;const s=i(956);class n{constructor(e,t){return this.isApproximative=()=>this._numerator.toString().length>=15&&this._denominator.toString().length>=15,this.isExact=()=>!this.isApproximative(),this.parse=(e,t)=>{let i;if(null===e||""===e)return this._numerator=0,this._denominator=1,this;switch(typeof e){case"string":if(i=e.split("/"),i.length>2)throw e+" has too many divide signs";if(i.map((e=>""===e||isNaN(Number(e)))).includes(!0))throw e+" is not a valid number";if(1===i.length)return this.parse(+i[0]);2===i.length?"0"===i[1]?(this._numerator=NaN,this._denominator=1):(this._numerator=+i[0],this._denominator=+i[1]):(this._numerator=NaN,this._denominator=1);break;case"number":if(Number.isSafeInteger(e))this._numerator=+e,void 0!==t&&Number.isSafeInteger(t)?this._denominator=+t:this._denominator=1;else{let[i,s]=e.toString().split("."),n=s?s.length:0;void 0===t?(this._numerator=e*Math.pow(10,n),this._denominator=Math.pow(10,n)):Number.isSafeInteger(t)&&(this._numerator=e*Math.pow(10,n)-Math.floor(e*Math.pow(10,n-t)),this.denominator=Math.pow(10,n)-Math.pow(10,n-t)),this.reduce()}break;case"object":e instanceof n&&(this._numerator=+e.numerator,this._denominator=+e.denominator)}return this},this.clone=()=>{let e=new n;return e.numerator=+this._numerator,e.denominator=+this._denominator,e},this.zero=()=>(this._numerator=0,this._denominator=1,this),this.one=()=>(this._numerator=1,this._denominator=1,this),this.infinite=()=>(this._numerator=1/0,this._denominator=1,this),this.invalid=()=>(this._numerator=NaN,this._denominator=1,this),this.opposed=()=>(this._numerator=-this._numerator,this),this.add=e=>{if(!(e instanceof n))return this.add(new n(e));{let t=this._numerator,i=this._denominator;this._numerator=t*e.denominator+e.numerator*i,this._denominator=i*e.denominator}return this.reduce()},this.subtract=e=>e instanceof n?this.add(e.clone().opposed()):this.add(-e),this.multiply=e=>{let t=new n(e);return this._numerator=this._numerator*t.numerator,this._denominator=this._denominator*t.denominator,this.reduce()},this.xMultiply=(...e)=>{for(let t of e){let e=new n(t);this._numerator=this._numerator*e.numerator,this._denominator=this._denominator*e.denominator}return this},this.divide=e=>{let t=new n(e);if(0===t.numerator)return(new n).infinite();let i=+this._numerator,s=+this._denominator;return this._numerator=i*t.denominator,this._denominator=s*t.numerator,this.reduce()},this.invert=()=>{let e=+this._numerator,t=+this._denominator;return this._numerator=t,this._denominator=e,this},this.pow=e=>{if(e instanceof n)return this.pow(e.value);this.reduce(),e<0&&this.invert();let t=Math.floor(Math.pow(this._numerator,Math.abs(e)));return Math.floor(Math.pow(this._denominator,Math.abs(e))),t**Math.abs(e)===this._numerator&&(Math.abs(e),this._denominator),this._numerator=this._numerator**Math.abs(e),this._denominator=this._denominator**Math.abs(e),this},this.root=e=>(0===e||(e<0&&this.invert(),Math.pow(this._numerator,Math.abs(1/e)),Math.pow(this._denominator,Math.abs(1/e)),this._numerator=Math.pow(this._numerator,Math.abs(1/e)),this._denominator=Math.pow(this._denominator,Math.abs(1/e))),this),this.sqrt=()=>this.root(2),this.abs=()=>(this._numerator=Math.abs(this._numerator),this._denominator=Math.abs(this._denominator),this),this.reduce=()=>{let e=s.Numeric.gcd(this._numerator,this._denominator);return this._numerator=this._numerator/e,this._denominator=this._denominator/e,this._denominator<0&&(this._denominator=-this._denominator,this._numerator=-this._numerator),this},this.amplify=e=>(Number.isSafeInteger(e)&&(this._numerator*=e,this._denominator*=e),this),this.compare=(e,t)=>{let i;switch(void 0===t&&(t="="),i=e instanceof n?e.clone():new n(e),t){case">":return this.value>i.value;case">=":return this.value>=i.value;case"<":return this.value<i.value;case"<=":return this.value<=i.value;case"=":return this.value===i.value;case"<>":return this.value!==i.value;default:return!1}},this.lesser=e=>this.compare(e,"<"),this.leq=e=>this.compare(e,"<="),this.greater=e=>this.compare(e,">"),this.geq=e=>this.compare(e,">="),this.isEqual=e=>this.compare(e,"="),this.isNotEqual=e=>this.compare(e,"<>"),this.isOpposed=e=>this.isEqual(e.clone().opposed()),this.isInverted=e=>this.isEqual((new n).one().divide(e.clone())),this.isZero=()=>0===this._numerator,this.isNotZero=()=>0!==this._numerator,this.isOne=()=>1===this._numerator&&1===this._denominator,this.isNegativeOne=()=>-1===this._numerator&&1===this._denominator,this.isPositive=()=>1===this.sign(),this.isNegative=()=>-1===this.sign(),this.isStrictlyPositive=()=>this.value>0,this.isStrictlyNegative=()=>this.value<0,this.isNaN=()=>isNaN(this._numerator),this.isInfinity=()=>Math.abs(this._numerator)===1/0,this.isFinite=()=>!this.isInfinity()&&!this.isNaN(),this.isSquare=()=>Math.sqrt(this._numerator)%1==0&&Math.sqrt(this._denominator)%1==0,this.isReduced=()=>1===Math.abs(s.Numeric.gcd(this._numerator,this._denominator)),this.isNatural=()=>this.isRelative()&&this.isPositive(),this.isRelative=()=>1===this.clone().reduce().denominator,this.isRational=()=>!this.isRelative(),this.isEven=()=>this.isRelative()&&this.value%2==0,this.isOdd=()=>this.isRelative()&&this.value%2==1,this.sign=()=>this._numerator*this._denominator>=0?1:-1,this.areEquals=(...e)=>{for(let t=0;t<e.length;t++)if(!this.isEqual(e[t]))return!1;return!0},this._numerator=1,this._denominator=1,void 0!==e&&this.parse(e,t),this}get numerator(){return this._numerator}set numerator(e){this._numerator=e}get denominator(){return this._denominator}set denominator(e){this._denominator=e}get value(){return this._numerator/this._denominator}get tex(){return this.isInfinity()?(1===this.sign()?"+":"-")+"\\infty":this.isExact()?1===this._denominator?`${this._numerator}`:this._numerator<0?`-\\frac{ ${-this._numerator} }{ ${this._denominator} }`:`\\frac{ ${this._numerator} }{ ${this._denominator} }`:this.value.toFixed(3)}get texWithSign(){return this.isPositive()?`+${this.tex}`:this.tex}get display(){return this.isExact()?1===this._denominator?`${this._numerator}`:`${this._numerator}/${this._denominator}`:this.value.toFixed(3)}get frac(){return this.tex}get dfrac(){return this.tex.replace("\\frac","\\dfrac")}get tfrac(){return this.tex.replace("\\frac","\\tfrac")}}t.Fraction=n,n.max=(...e)=>{let t=new n(e[0]);for(let i of e){let e=new n(i);e.greater(t)&&(t=e.clone())}return t},n.min=(...e)=>{let t=new n(e[0]);for(let i of e){let e=new n(i);e.lesser(t)&&(t=e.clone())}return t},n.average=(...e)=>{let t=(new n).zero();for(let i of e)t.add(i);return t.divide(e.length),t},n.unique=(e,t)=>{let i={},s=[];return e.forEach((e=>{i[e.clone().reduce().tex]||(s.push(e.clone()),i[e.tex]=!0)})),t?n.sort(s):s},n.sort=(e,t)=>{let i=e.sort(((e,t)=>e.value-t.value));return t&&i.reverse(),i}},872:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NthRoot=void 0,t.NthRoot=class{constructor(...e){this.parse=(e,t,i)=>(this._coefficient=void 0===i?1:i,this._nth=void 0===t?2:t,this._radical=void 0===e?1:e,this._nth%2==0&&this._radical<0&&(this._isValid=!1),this),this.reduce=()=>{let e=Math.floor(Math.pow(this._radical,1/this._nth));for(;e>1;)this._radical%Math.pow(e,this._nth)!=0?e--:(this._coefficient*=e,this._radical=this._radical/Math.pow(e,this._nth),e=Math.floor(Math.pow(this._radical,1/this._nth)));return this},this.multiply=e=>(this._radical*=e.radical,this.reduce()),this.hasRadical=()=>!(1===this._radical||0===this._radical||!1===this._isValid),this._radical=1,this._coefficient=1,this._nth=2,this._isValid=!0,void 0!==e&&this.parse(e[0],e[1],e[2])}get radical(){return this._radical}set radical(e){this._radical=e}get nth(){return this._nth}set nth(e){Number.isSafeInteger(e)&&e>=2?this._nth=e:(console.log("Error setting the nth root"),this._nth=2)}get coefficient(){return this._coefficient}set coefficient(e){this._coefficient=e}get tex(){let e;return e=1===this._coefficient?"":-1===this._coefficient?"-":this._coefficient.toString(),1===this._radical?`${this._coefficient}`:2===this._nth?`${e}\\sqrt{${this._radical}}`:`${e}\\sqrt[${this._nth}]{${this._radical}}`}get display(){let e;return e=1===this._coefficient?"":-1===this._coefficient?"-":this._coefficient.toString(),1===this._radical?`${this._coefficient}`:2===this._nth?`${e}sqrt{${this._radical}}`:`${e}root(${this._nth}){${this._radical}}`}get value(){return this._coefficient*Math.pow(this._radical,1/this._nth)}}},699:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Circle=void 0;const s=i(557),n=i(9),o=i(586),r=i(164),a=i(956),l=i(506),h=i(760),c=i(38);class u{constructor(...e){this.relativePosition=e=>{let t=e.distanceTo(this.center),i=Math.sqrt(this._squareRadius.value);return t.value-i>1e-10?0:Math.abs(t.value-i)<1e-10?1:2},this.lineIntersection=e=>{let t,i=[];if(null===this._cartesian)return[];const n=this._cartesian.clone(),o=e.equation.clone().isolate("x"),r=e.equation.clone().isolate("y");if(o instanceof h.Equation&&r instanceof h.Equation){n.replaceBy("y",r.right).simplify(),n.solve();for(let e of n.solutions)!1===e.exact&&isNaN(e.value)||(t=new l.Fraction(!1===e.exact?e.value:e.exact),i.push(new s.Point(t.clone(),r.right.evaluate(t))))}return i},this.tangents=e=>e instanceof l.Fraction?this._tangentsWithSlope(e):this.isPointOnCircle(e)?this._tangentsThroughOnePointOnTheCircle(e):this.center.distanceTo(e).value>this.radius.value?this._tangentsThroughOnePointOutsideTheCircle(e):(console.log("No tangents as the point is inside !"),[]),this.isPointOnCircle=e=>this._cartesian.test({x:e.x,y:e.y}),this.getPointsOnCircle=e=>{void 0===e&&(e=!1);let t,i=a.Numeric.pythagoricianTripletsWithTarget(this._squareRadius.value,!0),n=[];return i.forEach((e=>{for(let i of[[1,1],[-1,1],[-1,-1],[1,-1]])t=new s.Point(this.center.x.clone().add(i[0]*e[0]),this.center.y.clone().add(i[1]*e[1])),t.isInListOfPoints(n)||n.push(t)})),n},this._tangentsThroughOnePointOnTheCircle=e=>{let t=new o.Vector(this._center,e);return[new n.Line(e,t,n.LinePropriety.Perpendicular)]},this._tangentsThroughOnePointOutsideTheCircle=e=>{let t=this.center.x.clone().subtract(e.x),i=this.center.y.clone().subtract(e.y),s=new c.Polynom("x"),o=new c.Polynom("x^2+1");s.multiply(t).subtract(i).pow(2),o.multiply(this.squareRadius);let r=new h.Equation(s,o);return r.moveLeft().simplify().solve(),r.solutions.map((t=>{let i,s=new h.Equation("y","x");return t.exact instanceof l.Fraction?(i=e.x.clone().opposed().multiply(t.exact).add(e.y),s.right.multiply(t.exact).add(i)):(i=e.x.clone().opposed().multiply(t.value).add(e.y),s.right.multiply(t.value).add(i)),new n.Line(s)}))},this._tangentsWithSlope=e=>{const t=e.numerator,i=-e.denominator,s=this._center.x.clone(),o=this._center.y.clone();this._squareRadius;let r=this._squareRadius.clone().multiply(e.numerator**2+e.denominator**2),a=s.clone().multiply(t).opposed().subtract(o.clone().multiply(i)).add(r.clone().sqrt()),l=s.clone().multiply(t).opposed().subtract(o.clone().multiply(i)).subtract(r.clone().sqrt());return[new n.Line(t,i,a),new n.Line(t,i,l)]},this._exists=!1,void 0!==e&&this.parse(...e)}get center(){return this._center}get squareRadius(){return this._squareRadius}get cartesian(){return this._cartesian}get exists(){return this._exists}get radius(){return this._squareRadius.isSquare()?{tex:this._squareRadius.clone().sqrt().tex,display:this._squareRadius.clone().sqrt().display,value:this._squareRadius.clone().sqrt().value}:{tex:`\\sqrt{${this._squareRadius.tex}}`,display:`sqrt(${this._squareRadius.display})`,value:this._squareRadius.clone().sqrt().value}}get tex(){if(this._exists){let e,t;return e=this._center.x.isZero()?"x^2":`\\left(x${this._center.x.isNegative()?"+":"-"}${this._center.x.clone().abs().tex}\\right)^2`,t=this._center.y.isZero()?"y^2":`\\left(y${this._center.y.isNegative()?"+":"-"}${this._center.y.clone().abs().tex}\\right)^2`,`${e}+${t}=${this._squareRadius.tex}`}return"\\text{le cercle n'existe pas.}"}get developed(){return this._cartesian.tex}get display(){if(this._exists){let e,t;return e=this._center.x.isZero()?"x^2":`(x${this._center.x.isNegative()?"+":"-"}${this._center.x.clone().abs().tex})^2`,t=this._center.y.isZero()?"y^2":`(y${this._center.y.isNegative()?"+":"-"}${this._center.y.clone().abs().tex})^2`,`${e}+${t}=${this._squareRadius.display}`}return"\\text{le cercle n'existe pas.}"}clone(){return this._center=this._center.clone(),this._squareRadius=this._squareRadius.clone(),this._calculateCartesian(),this}_reset(){return this._center=null,this._squareRadius=null,this._cartesian=null,this._exists=!1,this}parse(...e){return this._reset(),"string"==typeof e[0]?this._parseEquation(new h.Equation(e[0])):e[0]instanceof h.Equation?this._parseEquation(e[0]):e[0]instanceof u?this._parseCopyCircle(e[0]):e[0]instanceof s.Point&&e.length>1&&(e[1]instanceof s.Point?e[2]instanceof s.Point?this._parseThroughtThreePoints(e[0],e[1],e[2]):this._parseCenterAndPointThrough(e[0],e[1]):(e[1]instanceof l.Fraction||"number"==typeof e[1])&&this._parseCenterAndRadius(e[0],e[1],"boolean"==typeof e[2]&&e[2])),this._exists&&(this._calculateCartesian(),void 0!==this._squareRadius&&this._squareRadius.isNegative()&&(this._exists=!1)),this}_calculateCartesian(){this._cartesian=new h.Equation(new c.Polynom(`(x-(${this._center.x.display}))^2+(y-(${this._center.y.display}))^2`),new c.Polynom(`${this._squareRadius.display}`)).moveLeft()}_parseCopyCircle(e){return this._center=e.center.clone(),this._squareRadius=e.squareRadius.clone(),this._calculateCartesian(),this._exists=e.exists,this}_parseCenterAndRadius(e,t,i){return this._center=e.clone(),this._squareRadius=i?new l.Fraction(t):new l.Fraction(t).pow(2),this._exists=!0,this}_parseCenterAndPointThrough(e,t){return this._center=e.clone(),this._squareRadius=new o.Vector(this._center,t).normSquare,this._exists=!0,this}_parseEquation(e){if(this._exists=!1,e.moveLeft(),2===e.degree("x").value&&2===e.degree("y").value){let t,i,n,o=e.left.monomByDegree(2,"x"),r=e.left.monomByDegree(2,"y");o.coefficient.isEqual(r.coefficient)?(e.divide(o.coefficient),t=e.left.monomByDegree(1,"x"),i=e.left.monomByDegree(1,"y"),n=e.left.monomByDegree(0),this._center=new s.Point(t.coefficient.clone().divide(2).opposed(),i.coefficient.clone().divide(2).opposed()),this._squareRadius=n.coefficient.clone().opposed().add(this._center.x.clone().pow(2)).add(this._center.y.clone().pow(2)),this._calculateCartesian(),this._exists=!0):(this._center=null,this._squareRadius=null,this._exists=!1)}return this}_parseThroughtThreePoints(e,t,i){let s=new r.Triangle(e,t,i),n=s.remarquables.mediators.AB.clone(),o=s.remarquables.mediators.AC.clone();return this.parse(n.intersection(o).point,e),this}}t.Circle=u},9:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Line=t.LinePropriety=void 0;const s=i(586),n=i(557),o=i(956),r=i(506),a=i(760),l=i(38),h=i(330),c=i(937);var u;!function(e){e[e.None=0]="None",e.Parallel="parallel",e.Perpendicular="perpendicular",e.Tangent="tangent"}(u||(t.LinePropriety=u={}));class d{constructor(...e){return this.randomPoint=e=>this._d.clone().multiplyByScalar(h.Random.numberSym(void 0===e||e<=1?3:e,!1)).add(this._OA.asVector).asPoint,this.randomNearPoint=e=>{let t=this.randomPoint(e),i=10;for(;this.isOnLine(t)&&i>0;)t.x.add(h.Random.numberSym(1,!1)),t.y.add(h.Random.numberSym(1,!1)),i--;return t},this.parse=(...e)=>{if(this._exists=!1,0===e.length)return this;if(1===e.length){if(e[0]instanceof d)return e[0].clone();if(e[0]instanceof a.Equation)return this.parseEquation(e[0]);if("string"==typeof e[0])try{let t=new a.Equation(e[0]);return this.parse(t)}catch(e){return this}}if(2===e.length){if(e[0]instanceof n.Point&&e[1]instanceof s.Vector)return this.parseByPointAndVector(e[0],e[1]);if(e[0]instanceof n.Point&&e[1]instanceof n.Point)return this.parseByPointAndVector(e[0],new s.Vector(e[0],e[1]));if(e[0]instanceof s.Vector&&e[1]instanceof n.Point)return this.parseByPointAndNormal(e[1],e[0])}if(3===e.length){if((e[0]instanceof r.Fraction||"number"==typeof e[0])&&(e[1]instanceof r.Fraction||"number"==typeof e[1])&&(e[2]instanceof r.Fraction||"number"==typeof e[2]))return this.parseByCoefficient(e[0],e[1],e[2]);if(e[0]instanceof n.Point&&e[1]instanceof s.Vector){if(e[2]===u.Perpendicular)return this.parseByPointAndNormal(e[0],e[1]);if(e[2]===u.Parallel)return this.parseByPointAndVector(e[0],e[1])}else if(e[0]instanceof n.Point&&e[1]instanceof d)return e[2]===u.Parallel||null===e[2]?this.parseByPointAndLine(e[0],e[1],u.Parallel):this.parseByPointAndLine(e[0],e[1],u.Perpendicular)}return console.log("Someting wrong happend while creating the line"),this},this.parseEquation=e=>{e.reorder(!0);let t=new Set(e.letters());if(!t.has("x")&&!t.has("y"))return this;for(let e of["x","y"])t.has(e)&&t.delete(e);return t.size>0?this:this.parseByCoefficient(e.left.monomByLetter("x").coefficient,e.left.monomByLetter("y").coefficient,e.left.monomByDegree(0).coefficient)},this.parseByCoefficient=(e,t,i)=>(this._a=new r.Fraction(e),this._b=new r.Fraction(t),this._c=new r.Fraction(i),this._d=new s.Vector(this._b.clone(),this._a.clone().opposed()),this._OA=new n.Point((new r.Fraction).zero(),this._c.clone()),this._n=this._d.clone().normal(),this._exists=!0,this),this.parseByPointAndVector=(e,t)=>(this.parseByCoefficient(t.y,t.x.clone().opposed(),e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposed()),this._OA=e.clone(),this._d=t.clone(),this._n=this._d.clone().normal(),this._exists=!0,this),this.parseByPointAndNormal=(e,t)=>this.parseByCoefficient(t.x,t.y,e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposed()),this.parseByPointAndLine=(e,t,i)=>(void 0===i&&(i=u.Parallel),i===u.Parallel?this.parseByPointAndNormal(e,t.normal):i===u.Perpendicular?this.parseByPointAndNormal(e,t.director):(this._exists=!1,this)),this.clone=()=>(this._a=this._a.clone(),this._b=this._b.clone(),this._c=this._c.clone(),this._d=this._d.clone(),this._OA=this._OA.clone(),this._n=this._n.clone(),this._exists=this.exists,this),this.isOnLine=e=>this._a.clone().multiply(e.x).add(this._b.clone().multiply(e.y)).add(this._c).isZero(),this.isParallelTo=e=>this.slope.isEqual(e.slope)&&this.height.isNotEqual(e.height),this.isSameAs=e=>this.slope.isEqual(e.slope)&&this.height.isEqual(e.height),this.isPerpendicularTo=e=>this.d.isNormalTo(e.d),this.isVertical=()=>this.slope.isInfinity(),this.simplify=()=>{let e=o.Numeric.lcm(this._a.denominator,this._b.denominator,this._c.denominator),t=o.Numeric.gcd(this._a.numerator,this._b.numerator,this._c.numerator);return this.parseByCoefficient(this._a.clone().multiply(e).divide(t),this._b.clone().multiply(e).divide(t),this._c.clone().multiply(e).divide(t)),this},this.simplifyDirection=()=>(this._d.simplifyDirection(),this),this.intersection=e=>{let t=new n.Point,i=!1,s=!1;return this._b.isZero()||e.b.isZero(),this.isParallelTo(e)?(t.x=null,t.y=null,i=!0):this.isSameAs(e)?(t.x=null,t.y=null,s=!0):(t.x=this._b.clone().multiply(e.c).subtract(this._c.clone().multiply(e.b)).divide(this._a.clone().multiply(e.b).subtract(this._b.clone().multiply(e.a))),t.y=this._a.clone().multiply(e.c).subtract(this._c.clone().multiply(e.a)).divide(this._b.clone().multiply(e.a).subtract(this._a.clone().multiply(e.b)))),{point:t,hasIntersection:!(i||s),isParallel:i,isSame:s}},this.getValueAtX=e=>{const t=this.equation.clone().isolate("y"),i=new r.Fraction(e);if(t instanceof a.Equation)return t.right.evaluate({x:i})},this.getValueAtY=e=>{const t=this.equation.clone().isolate("x"),i=new r.Fraction(e);if(t instanceof a.Equation)return t.right.evaluate({y:i})},this._exists=!1,this._reduceBeforeDisplay=!0,e.length>0&&this.parse(...e),this}get a(){return this._a}set a(e){this._a=e}get b(){return this._b}set b(e){this._b=e}get c(){return this._c}set c(e){this._c=e}get OA(){return this._OA}set OA(e){this._OA=e}get d(){return this._d}set d(e){this._d=e}get n(){return this._n}get exists(){return this._exists}get equation(){let e=new a.Equation((new l.Polynom).parse("xy",this._a,this._b,this._c),new l.Polynom("0"));return this._reduceBeforeDisplay?e.simplify():e}get system(){return{x:new a.Equation(new l.Polynom("x"),new l.Polynom(this._OA.x).add(new c.Monom("k").multiplyByNumber(this._d.x))),y:new a.Equation(new l.Polynom("y"),new l.Polynom(this._OA.y).add(new c.Monom("k").multiplyByNumber(this._d.y)))}}get tex(){let e=this.equation.clone().reorder(!0);this._a.isNegative()&&e.multiply(-1);let t=this._d.clone();return this._reduceBeforeDisplay&&t.simplifyDirection(),{canonical:e.tex,equation:e.clone().reorder().tex,mxh:this.slope.isInfinity()?"x="+this.OA.x.tex:"y="+(new l.Polynom).parse("x",this.slope,this.height).tex,parametric:`${n.Point.pmatrix("x","y")} = ${n.Point.pmatrix(this._OA.x,this._OA.y)} + k\\cdot ${n.Point.pmatrix(t.x,t.y)}`,system:`\\left\\{\\begin{aligned}\n x &= ${new l.Polynom(this._OA.x).add(new c.Monom(this._d.x).multiply(new c.Monom("k"))).reorder("k",!0).tex}\\\\ \n y &= ${new l.Polynom(this._OA.y).add(new c.Monom(this._d.y).multiply(new c.Monom("k"))).reorder("k",!0).tex}\n \\end{aligned}\\right.`}}get reduceBeforeDisplay(){return this._reduceBeforeDisplay}set reduceBeforeDisplay(e){this._reduceBeforeDisplay=e}get display(){let e=this.equation;return this._a.isNegative()&&e.multiply(-1),{canonical:e.display,mxh:this.slope.isInfinity()?"x="+this.OA.x.display:"y="+(new l.Polynom).parse("x",this.slope,this.height).display,parametric:""}}get normal(){return new s.Vector(this._a,this._b)}get director(){return this._d.clone()}get slope(){return this._a.clone().opposed().divide(this._b)}get height(){return this._c.clone().opposed().divide(this._b)}distanceTo(e){let t=e.x.clone().multiply(this._a).add(e.y.clone().multiply(this._b)).add(this._c).abs(),i=this.normal.normSquare;if(i.isZero())return{value:NaN,tex:"Not a line",fraction:(new r.Fraction).infinite()};let s=t.value/Math.sqrt(i.value),n=t.clone().divide(i.clone().sqrt());return i.isSquare()?{value:s,tex:n.tex,fraction:n}:{value:s,tex:`\\frac{${t.tex}}{\\sqrt{${i.tex}}}`,fraction:n}}hitSegment(e,t){let i=this.intersection(new d(e,t));return!!i.hasIntersection&&i.point.x.value>=Math.min(e.x.value,t.x.value)&&i.point.x.value<=Math.max(e.x.value,t.x.value)&&i.point.y.value>=Math.min(e.y.value,t.y.value)&&i.point.y.value<=Math.max(e.y.value,t.y.value)}canonicalAsFloatCoefficient(e){void 0===e&&(e=2),this._a.value,this._b.value,this._c.value;let t="";return this._a.isZero()||(t=this._a.isOne()?"x":this._a.clone().opposed().isOne()?"-x":this._a.value.toFixed(e)+"x"),this._b.isZero()||(this._b.isPositive()&&(t+="+"),t+=this._b.value.toFixed(e)+"y"),this._c.isZero()||(this._c.isPositive()&&(t+="+"),t+=this._c.value.toFixed(e)),t+"=0"}}t.Line=d,d.PERPENDICULAR=u.Perpendicular,d.PARALLEL=u.Parallel},557:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Point=void 0;const s=i(9),n=i(586),o=i(506);class r{}class a{constructor(...e){return this.parse=(...e)=>{if(this.zero(),0===e.length)return this;if(1===e.length){if(e[0]instanceof a)return this._x=e[0].x.clone(),this._y=e[0].y.clone(),this;if("string"==typeof e[0]){let t=e[0].split(",");if(2===t.length)return this._x=new o.Fraction(t[0]).reduce(),this._y=new o.Fraction(t[1]).reduce(),this}return e[0]instanceof r?(this._x=new o.Fraction(e[0].x).reduce(),this._y=new o.Fraction(e[0].y).reduce(),this):this.zero()}return 2===e.length?(this._x=new o.Fraction(e[0]).reduce(),this._y=new o.Fraction(e[1]).reduce(),this):this},this.clone=()=>(this._x=this._x.clone(),this._y=this._y.clone(),this),this.zero=()=>(this._x=new o.Fraction(null),this._y=new o.Fraction(null),this),this.origin=()=>(this.zero(),this),this.middleOf=(e,t)=>(this._x=e.x.clone().add(t.x).divide(2),this._y=e.y.clone().add(t.y).divide(2),this),this.texValues=e=>{let t=[];return t.push(this._x.value.toFixed(void 0===e?2:e)),t.push(this._y.value.toFixed(void 0===e?2:e)),`\\left(${t.join(";")}\\right)`},this.distanceTo=e=>{let t=0,i=new o.Fraction,r="";if(e instanceof s.Line)return e.distanceTo(this);if(e instanceof a){let s=new n.Vector(this,e);t=s.norm,i=s.normSquare.sqrt(),r=s.normSquare.isSquare()?i.tex:`\\sqrt{\\frac{ ${s.normSquare.numerator} }{ ${s.normSquare.denominator} }}`}return{value:t,fraction:i,tex:r}},this.isInListOfPoints=e=>e.map((e=>e.key)).includes(this.key),this._x=(new o.Fraction).zero(),this._y=(new o.Fraction).zero(),void 0!==e&&this.parse(...e),this}get x(){return this._x}set x(e){this._x=e}get y(){return this._y}set y(e){this._y=e}get tex(){let e=[];return e.push(this._x.tex),e.push(this._y.tex),`\\left(${e.join(";")}\\right)`}get display(){let e=[];return e.push(this._x.tex),e.push(this._y.tex),`(${e.join(";")})`}get asVector(){return new n.Vector(this.x,this.y)}get key(){return`${this.x.display};${this.y.display}`}}t.Point=a,a.pmatrix=(e,t,i)=>void 0===i?`\\begin{pmatrix} ${e.tex?e.tex:e} \\\\ ${t.tex?t.tex:t} \\end{pmatrix}`:`\\begin{pmatrix} ${e.tex?e.tex:e} \\\\ ${t.tex?t.tex:t} \\\\ ${i.tex?i.tex:i} \\end{pmatrix}`},164:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Triangle=void 0;const s=i(557),n=i(506),o=i(586),r=i(9),a=i(760);class l{constructor(...e){return this.parse=(...e)=>{if(6===e.length){let t=e.map((e=>new n.Fraction(e)));return this.parse(new s.Point(t[0],t[1]),new s.Point(t[2],t[3]),new s.Point(t[4],t[5]))}if(3===e.length){if(3===e.filter((e=>"string"==typeof e)).length)return this.parse(...e.map((e=>new r.Line(e))));if(3===e.filter((e=>e instanceof r.Line)).length){this._lines={AB:e[0],BC:e[1],AC:e[2]};let t=e[0].intersection(e[1]);if(!t.hasIntersection)return this;if(this._B=t.point.clone(),t=e[1].intersection(e[2]),!t.hasIntersection)return this;if(this._C=t.point.clone(),t=e[2].intersection(e[0]),!t.hasIntersection)return this;this._A=t.point.clone()}else{if(e.filter((e=>e instanceof s.Point)).length<3)return this.parse(new s.Point(e[0]),new s.Point(e[1]),new s.Point(e[2]));this._A=e[0].clone(),this._B=e[1].clone(),this._C=e[2].clone(),this._lines={AB:new r.Line(this._A,this._B),BC:new r.Line(this._B,this._C),AC:new r.Line(this._A,this._C)}}}else if(1===e.length&&e[0]instanceof l)return e[0].clone();return this._updateTriangle(),this},this.clone=()=>(this._A=this._A.clone(),this._B=this._B.clone(),this._C=this._C.clone(),this._lines={AB:this._lines.AB.clone(),BC:this._lines.BC.clone(),AC:this._lines.AC.clone()},this._updateTriangle(),this),this._updateTriangle=()=>{this._middles={AB:(new s.Point).middleOf(this._A,this._B),AC:(new s.Point).middleOf(this._A,this._C),BC:(new s.Point).middleOf(this._B,this._C)},this._remarquables=this._calculateRemarquableLines()},this.getPointByName=e=>{switch(e.toUpperCase()){case"A":return this._A;case"B":return this._B;case"C":return this._C}return this._A},this.getSegment=(e,t)=>new o.Vector(this.getPointByName(e),this.getPointByName(t)),this._calculateRemarquableLines=()=>{const e=this._calculateBisectors("A"),t=this._calculateBisectors("B"),i=this._calculateBisectors("C");let s={medians:{A:new r.Line(this._A,this._middles.BC),B:new r.Line(this._B,this._middles.AC),C:new r.Line(this._C,this._middles.AB),intersection:null},mediators:{AB:new r.Line(this._middles.AB,new o.Vector(this._A,this._B).normal()),AC:new r.Line(this._middles.AC,new o.Vector(this._A,this._C).normal()),BC:new r.Line(this._middles.BC,new o.Vector(this._B,this._C).normal()),intersection:null},heights:{A:new r.Line(this._A,new o.Vector(this._B,this._C).normal()),B:new r.Line(this._B,new o.Vector(this._A,this._C).normal()),C:new r.Line(this._C,new o.Vector(this._A,this._B).normal()),intersection:null},bisectors:{A:e.internal,B:t.internal,C:t.internal,intersection:null},externalBisectors:{A:e.external,B:t.external,C:i.external,intersection:null}};return s.medians.intersection=s.medians.A.intersection(s.medians.B).point,s.mediators.intersection=s.mediators.AB.intersection(s.mediators.BC).point,s.heights.intersection=s.heights.A.intersection(s.heights.B).point,s.bisectors.intersection=s.bisectors.A.intersection(s.bisectors.B).point,s},this._calculateBisectors=e=>{let t,i,s=this.lines;"A"===e?(t=s.AB,i=s.AC):"B"===e?(t=s.AB,i=s.BC):"C"===e&&(t=s.BC,i=s.AC);let n=new r.Line(new a.Equation(t.equation.left.clone().multiply(i.n.simplify().norm),i.equation.left.clone().multiply(t.n.simplify().norm)).reorder(!0).simplify()),o=new r.Line(new a.Equation(t.equation.left.clone().multiply(i.n.simplify().norm),i.equation.left.clone().multiply(t.n.simplify().norm).opposed()).reorder(!0).simplify());return"A"===e?n.hitSegment(this.B,this.C)?{internal:n,external:o}:{internal:o,external:n}:"B"===e?n.hitSegment(this.A,this.C)?{internal:n,external:o}:{internal:o,external:n}:"C"===e?n.hitSegment(this.B,this.A)?{internal:n,external:o}:{internal:o,external:n}:{internal:n,external:o}},e.length>0&&this.parse(...e),this}get A(){return this._A}get B(){return this._B}get C(){return this._C}get AB(){return this.getSegment("A","B")}get BA(){return this.getSegment("B","A")}get BC(){return this.getSegment("B","C")}get CB(){return this.getSegment("C","B")}get AC(){return this.getSegment("A","C")}get CA(){return this.getSegment("C","A")}get isRectangle(){return!!this.AB.isNormalTo(this.BC)||!!this.AB.isNormalTo(this.AC)||!!this.BC.isNormalTo(this.AC)}get isEquilateral(){return this.AB.normSquare.isEqual(this.BC.normSquare)&&this.AB.normSquare.isEqual(this.AC.normSquare)}get isIsocele(){return this.AB.normSquare.isEqual(this.BC.normSquare)||this.AB.normSquare.isEqual(this.AC.normSquare)||this.BC.normSquare.isEqual(this.AC.normSquare)}get lines(){return this._lines}get remarquables(){return this._remarquables}}t.Triangle=l},586:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Vector=void 0;const s=i(506),n=i(956),o=i(557);class r{constructor(...e){this.parse=(...e)=>{if(this.zero(),0===e.length)return this;if(1===e.length)return e[0]instanceof r?e[0].clone():this._parseString(e[0]);if(e.length>=2){if(e[0]instanceof o.Point&&e[1]instanceof o.Point)return this._x=e[1].x.clone().subtract(e[0].x),this._y=e[1].y.clone().subtract(e[0].y),this;(e[0]instanceof s.Fraction||!isNaN(e[0]))&&(this._x=new s.Fraction(e[0])),(e[1]instanceof s.Fraction||!isNaN(e[1]))&&(this._y=new s.Fraction(e[1])),"object"!=typeof e[0]||isNaN(e[0].x)||isNaN(e[0].x)||"object"!=typeof e[1]||isNaN(e[1].x)||isNaN(e[1].x)||(this._x=new s.Fraction(+e[1].x-e[0].x),this._y=new s.Fraction(+e[1].y-e[0].y))}return this},this.clone=()=>{let e=new r;return null!==this._x&&(e.x=this._x.clone()),null!==this._y&&(e.y=this._y.clone()),e},this.reset=()=>(this._x=null,this._y=null,this),this.zero=()=>(this.reset(),this._x=new s.Fraction(null),this._y=new s.Fraction(null),this),this.one=()=>(this._x=new s.Fraction,this._y=new s.Fraction,this),this._parseString=e=>{let t=e.split(/[,;\s]/g);return this.x=new s.Fraction(t[0]||null),this.y=new s.Fraction(t[1]||null),this},this.opposed=()=>(this._x.opposed(),this._y.opposed(),this),this.add=e=>(this._x.add(e.x),this._y.add(e.y),this),this.subtract=e=>this.add(e.clone().opposed()),this.scalarProductWithVector=e=>r.scalarProduct(this,e),this.determinantWithVector=e=>r.determinant(this,e),this.normal=()=>{let e=this.x.clone().opposed(),t=this.y.clone();return this._x=t,this._y=e,this},this.isColinearTo=e=>this.determinantWithVector(e).isZero(),this.isNormalTo=e=>this.scalarProductWithVector(e).isZero(),this.multiplyByScalar=e=>{let t=new s.Fraction(e);return this._x.multiply(t),this._y.multiply(t),this},this.divideByScalar=e=>this.multiplyByScalar(new s.Fraction(e).invert()),this.simplify=()=>this.multiplyByScalar(n.Numeric.lcm(this._x.denominator,this._y.denominator)).divideByScalar(n.Numeric.gcd(this._x.numerator,this._y.numerator)),this.simplifyDirection=()=>{let e=n.Numeric.lcm(this.x.denominator,this.y.denominator),t=n.Numeric.gcd(this.x.numerator,this.y.numerator);return this.x.multiply(e).divide(t),this.y.multiply(e).divide(t),this},this.angleWith=(e,t,i)=>{let s=this.scalarProductWithVector(e).value,n=i?1:180/Math.PI;return t&&(s=Math.abs(s)),n*Math.acos(s/(this.norm*e.norm))},this._x=(new s.Fraction).zero(),this._y=(new s.Fraction).zero(),void 0!==e&&this.parse(...e)}get x(){return this._x}set x(e){this._x=new s.Fraction(e)}get y(){return this._y}set y(e){this._y=new s.Fraction(e)}get normSquare(){return this._x.clone().pow(2).add(this._y.clone().pow(2))}get norm(){return Math.sqrt(this.normSquare.value)}get tex(){return`\\begin{pmatrix}${this._x.tex} \\\\ ${this._y.tex} \\end{pmatrix}`}get asPoint(){return new o.Point(this.x,this.y)}get isNull(){return this.x.isZero()&&this.y.isZero()}}t.Vector=r,r.scalarProduct=(e,t)=>e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)),r.determinant=(e,t)=>e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x))},956:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Numeric=void 0;class i{static round(e,t=2){return Number(Math.round(Number(e+"e"+t))+"e-"+t)}static primes(e){let t=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999,5003,5009,5011,5021,5023,5039,5051,5059,5077,5081,5087,5099,5101,5107,5113,5119,5147,5153,5167,5171,5179,5189,5197,5209,5227,5231,5233,5237,5261,5273,5279,5281,5297,5303,5309,5323,5333,5347,5351,5381,5387,5393,5399,5407,5413,5417,5419,5431,5437,5441,5443,5449,5471,5477,5479,5483,5501,5503,5507,5519,5521,5527,5531,5557,5563,5569,5573,5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,5683,5689,5693,5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,5801,5807,5813,5821,5827,5839,5843,5849,5851,5857,5861,5867,5869,5879,5881,5897,5903,5923,5927,5939,5953,5981,5987,6007,6011,6029,6037,6043,6047,6053,6067,6073,6079,6089,6091,6101,6113,6121,6131,6133,6143,6151,6163,6173,6197,6199,6203,6211,6217,6221,6229,6247,6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,6323,6329,6337,6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,6449,6451,6469,6473,6481,6491,6521,6529,6547,6551,6553,6563,6569,6571,6577,6581,6599,6607,6619,6637,6653,6659,6661,6673,6679,6689,6691,6701,6703,6709,6719,6733,6737,6761,6763,6779,6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,6863,6869,6871,6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,6977,6983,6991,6997,7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,7127,7129,7151,7159,7177,7187,7193,7207,7211,7213,7219,7229,7237,7243,7247,7253,7283,7297,7307,7309,7321,7331,7333,7349,7351,7369,7393,7411,7417,7433,7451,7457,7459,7477,7481,7487,7489,7499,7507,7517,7523,7529,7537,7541,7547,7549,7559,7561,7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,7673,7681,7687,7691,7699,7703,7717,7723,7727,7741,7753,7757,7759,7789,7793,7817,7823,7829,7841,7853,7867,7873,7877,7879,7883,7901,7907,7919,7927,7933,7937,7949,7951,7963,7993,8009,8011,8017,8039,8053,8059,8069,8081,8087,8089,8093,8101,8111,8117,8123,8147,8161,8167,8171,8179,8191,8209,8219,8221,8231,8233,8237,8243,8263,8269,8273,8287,8291,8293,8297,8311,8317,8329,8353,8363,8369,8377,8387,8389,8419,8423,8429,8431,8443,8447,8461,8467,8501,8513,8521,8527,8537,8539,8543,8563,8573,8581,8597,8599,8609,8623,8627,8629,8641,8647,8663,8669,8677,8681,8689,8693,8699,8707,8713,8719,8731,8737,8741,8747,8753,8761,8779,8783,8803,8807,8819,8821,8831,8837,8839,8849,8861,8863,8867,8887,8893,8923,8929,8933,8941,8951,8963,8969,8971,8999,9001,9007,9011,9013,9029,9041,9043,9049,9059,9067,9091,9103,9109,9127,9133,9137,9151,9157,9161,9173,9181,9187,9199,9203,9209,9221,9227,9239,9241,9257,9277,9281,9283,9293,9311,9319,9323,9337,9341,9343,9349,9371,9377,9391,9397,9403,9413,9419,9421,9431,9433,9437,9439,9461,9463,9467,9473,9479,9491,9497,9511,9521,9533,9539,9547,9551,9587,9601,9613,9619,9623,9629,9631,9643,9649,9661,9677,9679,9689,9697,9719,9721,9733,9739,9743,9749,9767,9769,9781,9787,9791,9803,9811,9817,9829,9833,9839,9851,9857,9859,9871,9883,9887,9901,9907,9923,9929,9931,9941,9949,9967,9973];return void 0===e?t:t.slice(0,Math.min(t.length,e))}static dividers(e){let t;const i=Math.sqrt(Math.abs(e));t=[];for(let s=1;s<=i;s++)e%s==0&&(t.push(s),t.push(e/s));return t.sort((function(e,t){return e-t})),[...new Set(t)]}static gcd(...e){let t=function(e,i){return 0===i?e:t(i,e%i)},i=1,s=2;if(0===e.length)return 1;if(1===e.length)return 0===e[0]?1:e[0];if(i=t(e[0],e[1]),1===i)return 1;for(s=2;s<e.length&&(i=t(i,e[s]),1!==i);s++);return Math.abs(i)}static divideNumbersByGCD(...e){let t=i.gcd(...e);return e.map((e=>e/t))}static lcm(...e){return e.reduce((function(e,t){return Math.abs(e*t/i.gcd(e,t))}))}static pythagoricianTripletsWithTarget(e,t){const i=[],s=!0===t?+e:e**2;for(let t=0;t<=e;t++)for(let n=0;n<=e;n++)t**2+n**2===s&&i.push([t,n,e]);return i}static numberCorrection(e,t=1,i=10,s=8){return+e.toFixed(s)}static periodic(e){return Number.isSafeInteger(e)||e.toString().split(".")[0].length<10?0:void 0}static decompose(e){let t,s,n=i.dividers(e),o=(Math.sqrt(e),[]);for(;n.length>0;)t=n.shift(),s=n.length>0?n.pop():+t,o.push([t,s]);return o}}t.Numeric=i},394:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumExp=void 0;const s=i(505),n=i(506);t.NumExp=class{constructor(e,t){this._expression=e;try{this._rpn=new s.Shutingyard(s.ShutingyardMode.NUMERIC).parse(e,t||void 0===t).rpn}catch(e){this._rpn=null,this._isValid=!1}}get rpn(){return this._rpn}get isValid(){if(void 0===this._isValid)try{this.evaluate({x:0})}catch{this._isValid=!1}return this._isValid}set isValid(e){this._isValid=e}get expression(){return this._expression}_extractDecimalPart(e){let t=e.toString();return t.includes(".")?(t=t.split(".")[1],t.substring(0,t.length-2)):""}_numberCorrection(e){const t=1e-14,i=this._extractDecimalPart(e);if(""===i)return e;const s=i.match(/9+$/g),n=i.match(/0+$/g);if(s&&s[0].length>=6){const i=this._extractDecimalPart(e+t).match(/0+$/g);if(i&&i[0].length>=6)return+(e+t).toString().split(i[0])[0]}if(n&&n[0].length>=6){const i=this._extractDecimalPart(e-t).match(/9+$/g);if(i&&i[0].length>=6)return+e.toString().split(n[0])[0]}return e}_addToStack(e,t){e.push(this._numberCorrection(t))}evaluate(e){const t=[];if(null===this._rpn)return this._isValid=!1,0;this.isValid=!0;for(const i of this._rpn)if(i.tokenType===s.ShutingyardType.COEFFICIENT)isNaN(+i.token)?this._addToStack(t,new n.Fraction(i.token).value):this._addToStack(t,+i.token);else if(i.tokenType===s.ShutingyardType.VARIABLE)void 0!==e[i.token]&&this._addToStack(t,+e[i.token]);else if(i.tokenType===s.ShutingyardType.CONSTANT)this._addToStack(t,s.tokenConstant[i.token]);else if(i.tokenType===s.ShutingyardType.OPERATION){if("*"===i.token){const e=t.pop(),i=t.pop();void 0!==i&&void 0!==e||(this.isValid=!1),this._addToStack(t,i*e)}else if("/"===i.token){const e=t.pop(),i=t.pop();void 0!==i&&void 0!==e||(this.isValid=!1),this._addToStack(t,i/e)}else if("+"===i.token){const e=t.pop(),i=t.pop();void 0!==i&&void 0!==e||(this.isValid=!1),this._addToStack(t,+i+ +e)}else if("-"===i.token){const e=t.pop(),i=t.pop()||0;void 0===e&&(this.isValid=!1),this._addToStack(t,i-e)}else if("^"===i.token){const e=t.pop(),i=t.pop();void 0!==i&&void 0!==e||(this.isValid=!1),this._addToStack(t,Math.pow(i,e))}}else if(i.tokenType===s.ShutingyardType.FUNCTION){const e=t.pop();if(void 0===e&&(this.isValid=!1),"sin"===i.token)this._addToStack(t,Math.sin(e));else if("cos"===i.token)this._addToStack(t,Math.cos(e));else if("tan"===i.token)this._addToStack(t,Math.tan(e));else if("sqrt"===i.token)this._addToStack(t,Math.sqrt(e));else if("nthrt"===i.token){let i=t.pop();e%2==0&&i<0?this._addToStack(t,NaN):this._addToStack(t,(i<0?-1:1)*Math.pow(Math.abs(i),1/e))}else"ln"===i.token?this._addToStack(t,Math.log(e)):"log"===i.token&&this._addToStack(t,Math.log10(e))}if(1===t.length)return t[0];throw`There was a problem parsing: ${this._expression}`}}},330:function(e,t,i){var s=this&&this.__createBinding||(Object.create?function(e,t,i,s){void 0===s&&(s=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,s,n)}:function(e,t,i,s){void 0===s&&(s=i),e[s]=t[i]}),n=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||s(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),t.Random=void 0;const o=i(22),r=i(793),a=i(140),l=i(754),h=i(821),c=i(246);var u;n(i(230),t),function(e){let t;e.polynom=function(e){return new o.rndPolynom(e).generate()},e.monom=function(e){return new r.rndMonom(e).generate()},e.fraction=function(e){return new l.rndFraction(e).generate()},e.number=function(e,t){return a.rndHelpers.randomInt(e,t)},e.numberSym=function(e,t){return a.rndHelpers.randomIntSym(e,t)},e.prime=function(e){return a.rndHelpers.randomPrime(e)},e.bool=function(e){return a.rndHelpers.randomBool(e)},e.array=function(e,t){return a.rndHelpers.randomArray(e,t)},e.item=function(e){return a.rndHelpers.randomItem(e)},e.shuffle=function(e){return a.rndHelpers.shuffleArray(e)},function(e){e.line=function(e){return new h.rndGeometryLine(e).generate()},e.point=function(e){return new c.rndGeometryPoint(e).generate()}}(t=e.Geometry||(e.Geometry={}))}(u||(t.Random=u={}))},373:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.randomCore=void 0,t.randomCore=class{constructor(){this.mergeConfig=(e,t)=>void 0!==e?{...t,...e}:t,this.generate=()=>{},this.config=e=>(this._config=this.mergeConfig(e,this._defaultConfig),this)}}},754:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndFraction=void 0;const s=i(373),n=i(330),o=i(506);class r extends s.randomCore{constructor(e){super(),this.generate=()=>{let e=new o.Fraction;if(this._config.negative?e.numerator=n.Random.numberSym(this._config.max,this._config.zero):e.numerator=n.Random.number(this._config.zero?0:1,this._config.max),this._config.natural)e.denominator=1;else{let t=0;for(;e.isRelative()&&t<10;)e.denominator=n.Random.number(1,this._config.max),t++}return this._config.reduced?e.reduce():e},this._defaultConfig={negative:!0,max:10,reduced:!0,zero:!0,natural:!1},this._config=this.mergeConfig(e,this._defaultConfig)}}t.rndFraction=r},821:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndGeometryLine=void 0;const s=i(373),n=i(330),o=i(9),r=i(586),a=i(557);class l extends s.randomCore{constructor(e){super(),this.generate=()=>{const e=new r.Vector(n.Random.numberSym(10),n.Random.numberSym(10));for(;e.isNull;)e.x=n.Random.numberSym(10),e.y=n.Random.numberSym(10);return 1===this._config.slope?e.x.sign()!==e.y.sign()&&e.y.opposed():-1===this._config.slope&&e.x.sign()!==e.y.sign()&&e.y.opposed(),new o.Line(new a.Point(this._config.A.x,this._config.A.y),e)},this._defaultConfig={A:{x:n.Random.numberSym(10),y:n.Random.numberSym(10)}},this._config=this.mergeConfig(e,this._defaultConfig)}}t.rndGeometryLine=l},246:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndGeometryPoint=void 0;const s=i(373),n=i(330),o=i(557),r=i(506);class a extends s.randomCore{constructor(e){super(),this.generate=()=>{let e,t,i=!0===this._config.axis||"x"===this._config.axis,s=!0===this._config.axis||"y"===this._config.axis;return e=this._config.fraction?n.Random.fraction({max:this._config.max,zero:i}):new r.Fraction(n.Random.numberSym(this._config.max,i)),t=this._config.fraction?n.Random.fraction({max:this._config.max,zero:s}):new r.Fraction(n.Random.numberSym(this._config.max,s)),1==+this._config.quadrant&&(e.abs(),t.abs()),2==+this._config.quadrant&&(e.isPositive()&&e.opposed(),t.isNegative()&&t.opposed()),3==+this._config.quadrant&&(e.isPositive()&&e.opposed(),t.isPositive()&&t.opposed()),4==+this._config.quadrant&&(e.isNegative()&&e.opposed(),t.isPositive()&&t.opposed()),new o.Point(e,t)},this._defaultConfig={axis:!0,fraction:!1,max:10},this._config=this.mergeConfig(e,this._defaultConfig)}}t.rndGeometryPoint=a},140:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndHelpers=void 0;const s=i(956);class n{static randomBool(e=.5){return Math.random()<e}static randomInt(e,t){return void 0===t?this.randomInt(0,e):Math.floor(Math.random()*(t-e+1)+e)}static randomIntSym(e,t){return!1===t?this.randomBool()?this.randomInt(1,e):-this.randomInt(1,e):this.randomInt(-e,e)}static randomPrime(e){let t=s.Numeric.primes();return void 0!==e&&(t=t.filter((t=>t<e))),this.randomItem(t)}static randomArray(e,t){return void 0===t&&(t=1),e.length<=0?Object.values(e):n.shuffleArray(e).slice(0,t)}static randomItem(e){return 0===e.length?"":this.randomArray(e,1)[0]}static shuffleArray(e){let t=Object.values(e);for(let e=t.length-1;e>0;e--){const i=Math.floor(Math.random()*(e+1)),s=t[e];t[e]=t[i],t[i]=s}return t}}t.rndHelpers=n},793:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndMonom=void 0;const s=i(373),n=i(330),o=i(937);class r extends s.randomCore{constructor(e){super(),this.generate=()=>{let e=new o.Monom;if("boolean"==typeof this._config.fraction?e.coefficient=n.Random.fraction({zero:this._config.zero,reduced:!0,natural:!this._config.fraction}):e.coefficient=n.Random.fraction(this._config.fraction),this._config.letters.length>1){for(let t of this._config.letters.split(""))e.setLetter(t,0);for(let t=0;t<this._config.degree;t++){const t=n.Random.item(this._config.letters.split(""));e.setLetter(t,e.degree(t).clone().add(1))}}else e.setLetter(this._config.letters,this._config.degree);return e},this._defaultConfig={letters:"x",degree:2,fraction:!0,zero:!1},this._config=this.mergeConfig(e,this._defaultConfig)}}t.rndMonom=r},22:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rndPolynom=void 0;const s=i(373),n=i(793),o=i(330),r=i(38);class a extends s.randomCore{constructor(e){super(),this.generate=()=>{if(this._config.factorable&&this._config.degree>1)return this.factorable();let e,t=(new r.Polynom).empty();for(let i=this._config.degree;i>=0;i--)e=new n.rndMonom({letters:this._config.letters,degree:i,fraction:this._config.fraction,zero:i!==this._config.degree&&this._config.allowNullMonom}).generate(),this._config.unit&&this._config.degree===i&&e.coefficient.one(),t.add(e);if(this._config.positive&&t.monomByDegree().coefficient.isNegative()&&t.monomByDegree().coefficient.opposed(),this._config.numberOfMonoms>0&&this._config.numberOfMonoms<t.length){let e=t.monomByDegree().clone();t.monoms=o.Random.array(t.monoms.slice(1),this._config.numberOfMonoms-1),t.add(e).reorder().reduce()}return t},this.factorable=()=>{let e=(new r.Polynom).one(),t={...this._config};t.degree=1,t.factorable=!1;for(let i=0;i<this._config.degree;i++)e.multiply(o.Random.polynom(t));return e},this._defaultConfig={letters:"x",degree:2,fraction:!1,zero:!1,unit:!1,factorable:!1,allowNullMonom:!0,numberOfMonoms:0,positive:!0},this._config=this.mergeConfig(e,this._defaultConfig)}}t.rndPolynom=a},230:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},505:(e,t)=>{var i,s;Object.defineProperty(t,"__esModule",{value:!0}),t.Shutingyard=t.ShutingyardMode=t.ShutingyardType=t.tokenConstant=void 0,t.tokenConstant={pi:Math.PI,e:Math.exp(1)},function(e){e.VARIABLE="variable",e.COEFFICIENT="coefficient",e.OPERATION="operation",e.CONSTANT="constant",e.FUNCTION="function",e.MONOM="monom"}(i||(t.ShutingyardType=i={})),function(e){e.EXPRESSION="expression",e.POLYNOM="polynom",e.SET="set",e.NUMERIC="numeric"}(s||(t.ShutingyardMode=s={})),t.Shutingyard=class{constructor(e){this._rpn=[],this._mode=void 0===e?s.POLYNOM:e,this.tokenConfigInitialization()}get rpn(){return this._rpn}get rpnToken(){return this._rpn.map((e=>e.token))}tokenConfigInitialization(){return this._mode===s.SET?(this._tokenConfig={"&":{precedence:3,associative:"left",type:i.OPERATION},"|":{precedence:3,associative:"left",type:i.OPERATION},"!":{precedence:4,associative:"right",type:i.OPERATION},"-":{precedence:2,associative:"left",type:i.OPERATION}},this._uniformize=!1):this._mode===s.NUMERIC?(this._tokenConfig={"^":{precedence:4,associative:"right",type:i.OPERATION},"*":{precedence:3,associative:"left",type:i.OPERATION},"/":{precedence:3,associative:"left",type:i.OPERATION},"+":{precedence:2,associative:"left",type:i.OPERATION},"-":{precedence:2,associative:"left",type:i.OPERATION},"%":{precedence:3,associative:"right",type:i.OPERATION},sin:{precedence:4,associative:"right",type:i.FUNCTION},cos:{precedence:4,associative:"right",type:i.FUNCTION},tan:{precedence:4,associative:"right",type:i.FUNCTION},sqrt:{precedence:4,associative:"right",type:i.FUNCTION},nthrt:{precedence:4,associative:"right",type:i.FUNCTION},ln:{precedence:4,associative:"right",type:i.FUNCTION},log:{precedence:4,associative:"right",type:i.FUNCTION}},this._uniformize=!1):this._mode===s.EXPRESSION?(this._tokenConfig={"^":{precedence:4,associative:"right",type:i.OPERATION},"*":{precedence:3,associative:"left",type:i.OPERATION},"/":{precedence:3,associative:"left",type:i.OPERATION},"+":{precedence:2,associative:"left",type:i.OPERATION},"-":{precedence:2,associative:"left",type:i.OPERATION},"%":{precedence:3,associative:"right",type:i.OPERATION},sin:{precedence:4,associative:"right",type:i.FUNCTION},cos:{precedence:4,associative:"right",type:i.FUNCTION},tan:{precedence:4,associative:"right",type:i.FUNCTION},sqrt:{precedence:4,associative:"right",type:i.FUNCTION},nthrt:{precedence:4,associative:"right",type:i.FUNCTION}},this._uniformize=!0):(this._tokenConfig={"^":{precedence:4,associative:"right",type:i.OPERATION},"*":{precedence:3,associative:"left",type:i.OPERATION},"/":{precedence:3,associative:"left",type:i.OPERATION},"+":{precedence:2,associative:"left",type:i.OPERATION},"-":{precedence:2,associative:"left",type:i.OPERATION}},this._uniformize=!0),this._tokenKeys=Object.keys(this._tokenConfig).sort(((e,t)=>t.length-e.length)),this._tokenConfig}NextToken(e,n){let o,r;if(o="",r="","("===e[n])o="(",r="(";else if(")"===e[n])o=")",r=")";else if(","===e[n])o=",",r="function-argument";else{for(let t of this._tokenKeys)if(e.substring(n,n+t.length)===t){o+=t,r=this._tokenConfig[t].type;break}for(let s in t.tokenConstant)if(e.substring(n,n+s.length)===s){o+=s,r=i.CONSTANT;break}""===o&&(e[n].match(/[0-9]/)?(this._mode,s.POLYNOM,o=e.substring(n).match(/^([0-9.]+)/)[0],r=i.COEFFICIENT):e[n].match(/[a-zA-Z]/)?(o=e.substring(n).match(/^([a-zA-Z])/)[0],r=i.VARIABLE):(console.log("Unidentified token",e[n],e,n),o=e[n],r=i.MONOM))}return[o,n+o.length,r]}normalize(e){if(1===e.length)return e;let s=[],n=[];for(let e in this._tokenConfig)this._tokenConfig[e].type===i.FUNCTION&&s.push(e);s.sort(((e,t)=>t.length-e.length));for(let e in t.tokenConstant)n.push(e);n.sort(((e,t)=>t.length-e.length));let o,r,a="",l=0;for(;l<e.length-1;){let t=0;for(;t<s.length;){let i=s[t];e.slice(l,l+i.length+1)===i+"("?(a+=i+"(",l+=i.length+1,t=0):t++}for(t=0;t<n.length;){let i=n[t];if(e.slice(l,l+i.length)===i){a+=i.slice(0,-1),l+=i.length-1;break}t++}o=e[l],r=e[l+1],a+=o,o.match(/[a-zA-Z]/g)?r?.match(/[a-zA-Z\d(]/)&&(a+="*"):o.match(/\d/)?r?.match(/[a-zA-Z(]/)&&(a+="*"):")"===o&&r?.match(/[a-zA-Z\d(]/)&&(a+="*"),l++}return a+(void 0===r?"":r)}parse(e,t){let i=[],s=[],n="",o=0,r="",a=0;(t||this._uniformize)&&(e=this.normalize(e));let l,h=50;for(;o<e.length;){if(h--,0===h){console.log("SECURITY LEVEL 1 EXIT");break}switch([n,o,r]=this.NextToken(e,o),r){case"monom":case"coefficient":case"variable":case"constant":i.push({token:n,tokenType:r});break;case"operation":if(a=s.length,s.length>0){let e=s[s.length-1];for(l=50;e.token in this._tokenConfig&&("left"===this._tokenConfig[n].associative&&this._tokenConfig[n].precedence<=this._tokenConfig[e.token].precedence||"right"===this._tokenConfig[n].associative&&this._tokenConfig[n].precedence<this._tokenConfig[e.token].precedence);){if(l--,0===l){console.log("SECURITY LEVEL 2 OPERATION EXIT");break}if(i.push(s.pop()||{token:"",tokenType:"operation"}),0===s.length)break;e=s[s.length-1]}}s.push({token:n,tokenType:r});break;case"function-argument":for(l=50;"("!==s[s.length-1].token&&s.length>0;){if(l--,0===l){console.log("SECURITY LEVEL 2 FUNCTION ARGUMENT EXIT");break}i.push(s.pop()||{token:n,tokenType:r})}break;case"(":s.push({token:n,tokenType:r}),"-"===e[o]&&i.push({token:"0",tokenType:"coefficient"});break;case")":for(l=50;"("!==s[s.length-1].token&&s.length>1;){if(l--,0===l){console.log("SECURITY LEVEL 2 CLOSING PARENTHESE EXIT");break}i.push(s.pop()||{token:n,tokenType:r})}s.pop();break;case"function":s.push({token:n,tokenType:r});break;default:console.log(`SHUTING YARD: ${r} : ${n} `)}}return this._rpn=i.concat(s.reverse()),this}}}},t={};!function i(s){var n=t[s];if(void 0!==n)return n.exports;var o=t[s]={exports:{}};return e[s].call(o.exports,o,o.exports,i),o.exports}(607)})();
2
2
  //# sourceMappingURL=pimath.min.js.map