@ohtaman/washi 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +111 -118
- package/README.md +109 -116
- package/README.zh-CN.md +112 -119
- package/dist/browser/highs-worker.js +21 -3
- package/dist/browser/loader-CtaDHef_.js +273 -0
- package/dist/browser/solvers/glpk.js +433 -286
- package/dist/browser/solvers/glpk.min.js +1 -1
- package/dist/browser/solvers/z3.js +1002 -981
- package/dist/browser/solvers/z3.min.js +2 -2
- package/dist/browser/washi.js +2178 -622
- package/dist/browser/washi.min.js +4 -4
- package/dist/lib/highs-worker.js +21 -3
- package/dist/lib/loader-DmNC_UNk.js +279 -0
- package/dist/lib/registry-BEfvpZW3.js +951 -0
- package/dist/lib/solvers/glpk.js +201 -90
- package/dist/lib/solvers/z3.js +399 -259
- package/dist/lib/washi.js +1674 -932
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modeler/big-m.d.ts +75 -0
- package/dist/types/modeler/big-m.d.ts.map +1 -0
- package/dist/types/modeler/boolean-expr.d.ts +103 -14
- package/dist/types/modeler/boolean-expr.d.ts.map +1 -1
- package/dist/types/modeler/constraint.d.ts +36 -9
- package/dist/types/modeler/constraint.d.ts.map +1 -1
- package/dist/types/modeler/expression.d.ts +117 -27
- package/dist/types/modeler/expression.d.ts.map +1 -1
- package/dist/types/modeler/index.d.ts +10 -6
- package/dist/types/modeler/index.d.ts.map +1 -1
- package/dist/types/modeler/lp-writer.d.ts +27 -2
- package/dist/types/modeler/lp-writer.d.ts.map +1 -1
- package/dist/types/modeler/model.d.ts +491 -140
- package/dist/types/modeler/model.d.ts.map +1 -1
- package/dist/types/modeler/objective.d.ts +59 -0
- package/dist/types/modeler/objective.d.ts.map +1 -0
- package/dist/types/modeler/parser.d.ts +39 -14
- package/dist/types/modeler/parser.d.ts.map +1 -1
- package/dist/types/modeler/quad-expr.d.ts +28 -7
- package/dist/types/modeler/quad-expr.d.ts.map +1 -1
- package/dist/types/modeler/solution-validator.d.ts +93 -0
- package/dist/types/modeler/solution-validator.d.ts.map +1 -0
- package/dist/types/modeler/solvers/glpk/solver.d.ts +26 -2
- package/dist/types/modeler/solvers/glpk/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/loader.d.ts +36 -11
- package/dist/types/modeler/solvers/highs/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/solver.d.ts +11 -4
- package/dist/types/modeler/solvers/highs/solver.d.ts.map +1 -1
- package/dist/types/modeler/solvers/highs/worker-client.d.ts.map +1 -1
- package/dist/types/modeler/solvers/mock.d.ts +14 -5
- package/dist/types/modeler/solvers/mock.d.ts.map +1 -1
- package/dist/types/modeler/solvers/types.d.ts +71 -11
- package/dist/types/modeler/solvers/types.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/loader.d.ts +2 -3
- package/dist/types/modeler/solvers/z3/loader.d.ts.map +1 -1
- package/dist/types/modeler/solvers/z3/solver.d.ts +15 -5
- package/dist/types/modeler/solvers/z3/solver.d.ts.map +1 -1
- package/dist/types/modeler/types.d.ts +60 -2
- package/dist/types/modeler/types.d.ts.map +1 -1
- package/dist/types/modeler/validation.d.ts +56 -0
- package/dist/types/modeler/validation.d.ts.map +1 -0
- package/dist/types/modeler/variable.d.ts +53 -13
- package/dist/types/modeler/variable.d.ts.map +1 -1
- package/docs/examples/diet-sensitivity.md +90 -0
- package/docs/examples/ecommerce-coupons.md +106 -0
- package/docs/examples/index.md +53 -0
- package/docs/examples/knapsack.md +60 -0
- package/docs/examples/portfolio-qp.md +83 -0
- package/docs/examples/production.md +51 -0
- package/docs/examples/shift-scheduling.md +175 -0
- package/docs/examples/smt-security.md +74 -0
- package/docs/examples/transportation.md +90 -0
- package/docs/examples/unsat-core.md +64 -0
- package/docs/getting-started/ai-agents.md +267 -0
- package/docs/getting-started/cross-origin.md +87 -0
- package/docs/getting-started/index.md +116 -0
- package/docs/getting-started/runtimes.md +227 -0
- package/docs/guide/constraints.md +177 -0
- package/docs/guide/expressions.md +204 -0
- package/docs/guide/objectives.md +170 -0
- package/docs/guide/unsat-core.md +147 -0
- package/docs/guide/variables.md +188 -0
- package/docs/ja/getting-started/ai-agents.md +266 -0
- package/docs/solvers/custom-solver.md +525 -0
- package/docs/solvers/glpk.md +66 -0
- package/docs/solvers/highs.md +93 -0
- package/docs/solvers/index.md +42 -0
- package/docs/solvers/z3.md +78 -0
- package/docs/zh/getting-started/ai-agents.md +266 -0
- package/llms-full.txt +3249 -0
- package/llms.txt +197 -0
- package/package.json +19 -6
- package/skills/washi/SKILL.md +197 -0
- package/dist/browser/loader-CVt4CloI.js +0 -58
- package/dist/lib/async-mutex-Duo4jwzn.js +0 -195
- package/dist/lib/constraint-BRuB3ooC.js +0 -90
- package/dist/lib/loader-Dti0v9yC.js +0 -50
- package/dist/lib/registry-DksqCSjI.js +0 -32
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var Washi=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),l=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},u=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},d=(e,r,i)=>(i=e==null?{}:t(a(e)),u(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e));function f(e){return e&&e.toLowerCase()===`maximize`?`Maximize`:`Minimize`}var p=0,m=class{and(e){return new g(`and`,[this,e])}or(e){return new g(`or`,[this,e])}implies(e){return new g(`implies`,[this,e])}xor(e){return new g(`xor`,[this,e])}not(){return new g(`not`,[this])}},h=class extends m{id;name;value=null;constructor(e){super(),this.id=++p,this.name=e||`p_${this.id}`}toString(){return this.name}},g=class extends m{op;children;constructor(e,t){super(),this.op=e,this.children=t}toString(){return this.op===`not`?`not(${this.children[0].toString()})`:`(${this.children.map(e=>e.toString()).join(` ${this.op} `)})`}};function _(...e){if(e.length===0)throw Error(`and() requires at least one expression`);return new g(`and`,e)}function v(...e){if(e.length===0)throw Error(`or() requires at least one expression`);return new g(`or`,e)}function y(e){return new g(`not`,[e])}function b(e,t){return new g(`implies`,[e,t])}function x(...e){if(e.length===0)throw Error(`xor() requires at least one expression`);return new g(`xor`,e)}var S=0,C=class{id;lhs;sense;rhs;name;slack=null;dual=null;constructor(e,t,n,r){this.id=++S,this.lhs=e,this.sense=t,this.rhs=n,this.name=r||`c_${this.id}`}and(e){return new g(`and`,[this,e])}or(e){return new g(`or`,[this,e])}implies(e){return new g(`implies`,[this,e])}xor(e){return new g(`xor`,[this,e])}not(){return new g(`not`,[this])}toString(){let e=this.sense===`==`?`=`:this.sense;return`${this.name}: ${this.lhs.toString()} ${e} ${this.rhs}`}};function w(e,t){let n=e.id,r=t.id;return n<=r?`${n}:${r}`:`${r}:${n}`}var T=class e{linearTerms;quadTerms;constant;constructor(e=new Map,t=new Map,n=0){this.linearTerms=new Map(e),this.quadTerms=new Map;for(let[e,n]of t)this.quadTerms.set(e,{...n});this.constant=n}clone(){return new e(this.linearTerms,this.quadTerms,this.constant)}getQuadCoeff(e,t){let n=w(e,t),r=this.quadTerms.get(n);return r?r.coeff:0}add(t){let n=this.clone();if(typeof t==`number`)return n.constant+=t,n;if(t instanceof e){for(let[e,r]of t.quadTerms){let t=n.quadTerms.get(e),i=(t?t.coeff:0)+r.coeff;Math.abs(i)<1e-12?n.quadTerms.delete(e):n.quadTerms.set(e,{var1:r.var1,var2:r.var2,coeff:i})}for(let[e,r]of t.linearTerms){let t=(n.linearTerms.get(e)||0)+r;Math.abs(t)<1e-12?n.linearTerms.delete(e):n.linearTerms.set(e,t)}return n.constant+=t.constant,n}if(`terms`in t&&t.terms instanceof Map){for(let[e,r]of t.terms){let t=(n.linearTerms.get(e)||0)+r;Math.abs(t)<1e-12?n.linearTerms.delete(e):n.linearTerms.set(e,t)}return n.constant+=t.constant,n}let r=t,i=(n.linearTerms.get(r)||0)+1;return Math.abs(i)<1e-12?n.linearTerms.delete(r):n.linearTerms.set(r,i),n}sub(t){return typeof t==`number`?this.add(-t):t instanceof e?this.add(t.neg()):(`terms`in t&&t.terms instanceof Map,this.add(t.mul(-1)))}mul(t){let n=new e(new Map,new Map,this.constant*t);for(let[e,r]of this.linearTerms){let i=r*t;Math.abs(i)>=1e-12&&n.linearTerms.set(e,i)}for(let[e,r]of this.quadTerms){let i=r.coeff*t;Math.abs(i)>=1e-12&&n.quadTerms.set(e,{var1:r.var1,var2:r.var2,coeff:i})}return n}div(e){if(Math.abs(e)<1e-12)throw Error(`Division by zero in QuadExpr.div()`);return this.mul(1/e)}neg(){return this.mul(-1)}get value(){let e=this.constant;for(let[t,n]of this.linearTerms){if(t.value===null)return null;e+=n*t.value}for(let t of this.quadTerms.values()){if(t.var1.value===null||t.var2.value===null)return null;e+=t.coeff*t.var1.value*t.var2.value}return e}getValue(){return this.value}static fromProduct(t,n,r=1){let i=new e,a=w(t,n);return i.quadTerms.set(a,{var1:t.id<=n.id?t:n,var2:t.id<=n.id?n:t,coeff:r}),i}},E=class e{terms;constant;constructor(e=new Map,t=0){this.terms=new Map(e),this.constant=t}clone(){return new e(this.terms,this.constant)}add(e){if(e instanceof T)return e.add(this);let t=this.clone();if(typeof e==`number`)t.constant+=e;else if(`terms`in e){for(let[n,r]of e.terms){let e=(t.terms.get(n)||0)+r;Math.abs(e)<1e-12?t.terms.delete(n):t.terms.set(n,e)}t.constant+=e.constant}else{let n=(t.terms.get(e)||0)+1;Math.abs(n)<1e-12?t.terms.delete(e):t.terms.set(e,n)}return t}sub(e){return e instanceof T?e.neg().add(this):typeof e==`number`?this.add(-e):(`terms`in e,this.add(e.mul(-1)))}mul(t){if(typeof t==`number`){let n=new e(new Map,this.constant*t);for(let[e,r]of this.terms){let i=r*t;Math.abs(i)>=1e-12&&n.terms.set(e,i)}return n}let n=new T;Math.abs(this.constant)>=1e-12&&n.linearTerms.set(t,this.constant);for(let[e,r]of this.terms)n=n.add(T.fromProduct(e,t,r));return n}div(e){if(Math.abs(e)<1e-12)throw Error(`Division by zero in LinExpr.div()`);return this.mul(1/e)}neg(){return this.mul(-1)}get value(){let e=this.constant;for(let[t,n]of this.terms){if(t.value===null)return null;e+=n*t.value}return e}getValue(){return this.value}le(e,t){return this.toConstraint(`<=`,e,t)}lessThanOrEqual(e,t){return this.le(e,t)}ge(e,t){return this.toConstraint(`>=`,e,t)}greaterThanOrEqual(e,t){return this.ge(e,t)}eq(e,t){return this.toConstraint(`==`,e,t)}equalTo(e,t){return this.eq(e,t)}toConstraint(t,n,r){let i=this.clone(),a=0;typeof n==`number`?a=n:`terms`in n?(i=i.sub(new e(n.terms,0)),a=n.constant):i=i.sub(n);let o=a-i.constant;return i.constant=0,new C(i,t,o,r)}toString(){let e=[],t=!0;for(let[n,r]of this.terms){let i=r>=0?t?``:`+ `:`- `,a=Math.abs(r),o=a===1?``:`${a} `;e.push(`${i}${o}${n.name}`),t=!1}if(this.constant!==0||e.length===0){let n=this.constant>=0?t?``:`+ `:`- `;e.push(`${n}${Math.abs(this.constant)}`)}return e.join(` `)||`0`}};function ee(e,t){let n=new Map,r=0;function i(e){if(e!=null){if(typeof e==`number`)r+=e;else if(typeof e==`object`&&`terms`in e){let t=e;for(let[e,r]of t.terms){let t=n.get(e)||0;n.set(e,t+r)}r+=t.constant}else{let t=e,r=n.get(t)||0;n.set(t,r+1)}}}if(typeof e==`number`){let n=e,r=t;for(let e=0;e<n;e++)i(r(e,e))}else{let n=0;for(let r of e)i(t?t(r,n++):r)}for(let[e,t]of n)Math.abs(t)<1e-12&&n.delete(e);return new E(n,r)}function D(e,t){let n=new Map,r=0;function i(e){return typeof e==`object`&&!!e&&typeof e.id==`number`&&typeof e.name==`string`&&typeof e.mul==`function`&&typeof e.le==`function`}function a(e){return i(e)||e instanceof E||e instanceof T}function o(e,t){if(typeof t==`number`)r+=e*t;else if(t instanceof E){for(let[r,i]of t.terms){let t=n.get(r)||0;n.set(r,t+e*i)}r+=e*t.constant}else if(i(t)){let r=t,i=n.get(r)||0;n.set(r,i+e)}else throw Error(`Cannot multiply number by non-variable/expression operand in dot().`)}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!a(e)}function c(e,t,n=``){if(e===void 0||t===void 0||e===null||t===null)throw Error(`Nullish or undefined operand encountered in dot() at '${n||`root`}'.`);if(typeof e==`number`){o(e,t);return}if(typeof t==`number`){o(t,e);return}if(Array.isArray(e)||Array.isArray(t)){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)throw Error(`Array length mismatch in dot() at '${n||`root`}': received lengths ${e.length} and ${t.length}.`);for(let r=0;r<e.length;r++)c(e[r],t[r],n?`${n}[${r}]`:`[${r}]`);return}let r=Array.isArray(e)?e:t,i=Array.isArray(e)?t:e;if(s(i)){let a=Object.keys(i);if(a.length>0&&a.every(e=>/^\d+$/.test(e))){if(a.length!==r.length)throw Error(`Array length mismatch in dot() at '${n||`root`}': array has length ${r.length}, but object has ${a.length} indices.`);let o=[];for(let e=0;e<r.length;e++)!(e in i)&&!(String(e)in i)&&o.push(e);if(o.length>0)throw Error(`Key mismatch in dot() at '${n||`root`}': missing indices [${o.join(`, `)}] in numeric record.`);for(let i=0;i<r.length;i++)c(e[i],t[i],n?`${n}[${i}]`:`[${i}]`);return}throw Error(`Type mismatch in dot() at '${n||`root`}': one operand is an Array while the other is an Object with keys [${a.slice(0,5).join(`, `)}].`)}throw Error(`Type mismatch in dot() at '${n||`root`}': one operand is an Array while the other is not.`)}if(s(e)&&s(t)){let r=Object.keys(e),i=Object.keys(t),a=r.filter(e=>!(e in t)),o=i.filter(t=>!(t in e));if(a.length>0||o.length>0){let e=[];throw a.length>0&&e.push(`missing in second operand: [${a.join(`, `)}]`),o.length>0&&e.push(`missing in first operand: [${o.join(`, `)}]`),Error(`Key mismatch in dot() at '${n||`root`}': ${e.join(`; `)}.`)}for(let i of r)c(e[i],t[i],n?`${n}.${i}`:i);return}throw Error(`Unsupported operand types in dot() at '${n||`root`}'.`)}c(e,t);for(let[e,t]of n)Math.abs(t)<1e-12&&n.delete(e);return new E(n,r)}var O=0;function k(e){if(!e)return`Continuous`;let t=e.toLowerCase();return t===`binary`||t===`bin`?`Binary`:t===`integer`||t===`int`?`Integer`:`Continuous`}var A=class e{id;name;type;lb;ub;value=null;reducedCost=null;constructor(e={}){this.id=++O,this.name=e.name||`x_${this.id}`,this.type=k(e.type),this.type===`Binary`?(this.lb=0,this.ub=1):(this.lb=e.lb===void 0?0:e.lb,this.ub=e.ub===void 0?1/0:e.ub)}mul(t){if(typeof t==`number`)return new E(new Map([[this,t]]),0);if(t instanceof e)return T.fromProduct(this,t,1);let n=new T;Math.abs(t.constant)>=1e-12&&n.linearTerms.set(this,t.constant);for(let[e,r]of t.terms){let t=T.fromProduct(this,e,r);n=n.add(t)}return n}add(e){return e instanceof T?e.add(this):new E(new Map([[this,1]]),0).add(e)}sub(e){return e instanceof T?e.neg().add(this):new E(new Map([[this,1]]),0).sub(e)}neg(){return this.mul(-1)}le(e,t){return new E(new Map([[this,1]]),0).le(e,t)}lessThanOrEqual(e,t){return this.le(e,t)}ge(e,t){return new E(new Map([[this,1]]),0).ge(e,t)}greaterThanOrEqual(e,t){return this.ge(e,t)}eq(e,t){return new E(new Map([[this,1]]),0).eq(e,t)}equalTo(e,t){return this.eq(e,t)}toString(){return this.name}};function j(e){let t=[],n=0,r=e.length;for(;n<r;){let i=e[n];if(/\s/.test(i)){n++;continue}if(i===`+`)t.push({type:`PLUS`,value:`+`}),n++;else if(i===`-`)t.push({type:`MINUS`,value:`-`}),n++;else if(i===`*`)t.push({type:`STAR`,value:`*`}),n++;else if(i===`/`)t.push({type:`SLASH`,value:`/`}),n++;else if(i===`(`)t.push({type:`LPAREN`,value:`(`}),n++;else if(i===`)`)t.push({type:`RPAREN`,value:`)`}),n++;else if(i===`<`||i===`>`||i===`=`){let a=i;n+1<r&&(e[n+1]===`=`||e[n+1]===`<`||e[n+1]===`>`)?(a+=e[n+1],n+=2):n++,t.push({type:`COMP`,value:a})}else if(/[0-9.]/.test(i)){let i=``;for(;n<r&&/[0-9.]/.test(e[n]);)i+=e[n],n++;t.push({type:`NUMBER`,value:i})}else if(/[a-zA-Z_]/.test(i)){let i=``;for(;n<r&&/[a-zA-Z0-9_]/.test(e[n]);)i+=e[n],n++;t.push({type:`IDENT`,value:i})}else throw Error(`Unexpected character '${i}' at position ${n} in: "${e}"`)}return t}var M=class{tokens;pos=0;resolver;constructor(e,t){this.tokens=e,this.resolver=t}peek(){return this.tokens[this.pos]}consume(e){let t=this.tokens[this.pos++];if(!t)throw Error(`Unexpected end of input`);if(e&&t.value!==e&&t.type!==e)throw Error(`Expected '${e}', but found '${t.value}'`);return t}parseExpression(){let e=this.parseTerm();for(;this.pos<this.tokens.length;){let t=this.peek();if(!t)break;if(t.type===`PLUS`)this.consume(),e=e.add(this.parseTerm());else if(t.type===`MINUS`)this.consume(),e=e.sub(this.parseTerm());else break}return e}parseTerm(){let e=this.parseFactor();for(;this.pos<this.tokens.length;){let t=this.peek();if(!t)break;if(t.type===`STAR`){this.consume();let t=this.parseFactor();e=this.multiplyExpressions(e,t)}else if(t.type===`SLASH`){this.consume();let t=this.parseFactor();if(t.terms.size>0)throw Error(`Cannot divide by variable in linear expression`);if(Math.abs(t.constant)<1e-12)throw Error(`Division by zero in expression`);e=e.div(t.constant)}else break}return e}multiplyExpressions(e,t){if(e.terms.size>0&&t.terms.size>0)throw Error(`Multiplication of two variables creates a non-linear term (not allowed in MILP/LP)`);return e.terms.size===0?t.mul(e.constant):e.mul(t.constant)}parseFactor(){let e=this.peek();if(!e)throw Error(`Unexpected end of expression`);if(e.type===`PLUS`)return this.consume(),this.parseFactor();if(e.type===`MINUS`)return this.consume(),this.parseFactor().neg();if(e.type===`NUMBER`){this.consume();let t=parseFloat(e.value);if(this.peek()?.type===`IDENT`){let e=this.consume();return this.resolveVariable(e.value).mul(t)}return new E(new Map,t)}if(e.type===`IDENT`){this.consume();let t=this.resolveVariable(e.value);return new E(new Map([[t,1]]),0)}if(e.type===`LPAREN`){this.consume(`LPAREN`);let e=this.parseExpression();return this.consume(`RPAREN`),e}throw Error(`Unexpected token '${e.value}' in expression`)}resolveVariable(e){let t=this.resolver(e);if(!t)throw Error(`Unknown variable '${e}' in expression`);return t}};function N(e,t){return new M(j(e),t).parseExpression()}function P(e,t,n){let r=e.match(/(<=|>=|==|=<|=>|=)/);if(!r)throw Error(`Constraint must contain a comparison operator (<=, >=, ==, =): "${e}"`);let i=r[0],a=r.index,o=e.substring(0,a).trim(),s=e.substring(a+i.length).trim(),c;if(i===`<=`||i===`=<`)c=`<=`;else if(i===`>=`||i===`=>`)c=`>=`;else if(i===`==`||i===`=`)c=`==`;else throw Error(`Unsupported operator "${i}"`);let l=N(o,t),u=N(s,t);return c===`<=`?l.le(u,n):c===`>=`?l.ge(u,n):l.eq(u,n)}function F(e,t){let n=new Map,r=``;for(let i=0;i<e.length;i++)if(r+=e[i],i<t.length){let e=t[i];if(typeof e==`number`)r+=`(${e})`;else if(e instanceof A){let t=`__v_${i}__`;n.set(t,e),r+=t}else if(e instanceof E){`${i}`,r+=`(${e.toString()})`;for(let[t]of e.terms)n.set(t.name,t)}}return{fullText:r,resolver:e=>n.get(e)}}function I(e,...t){let{fullText:n,resolver:r}=F(e,t);return P(n,r)}function L(e,...t){let{fullText:n,resolver:r}=F(e,t);return/(<=|>=|==|=<|=>|=)/.test(n)?P(n,r):N(n,r)}function R(e,t,n){let r=e.replace(/[^a-zA-Z0-9_]/g,`_`);return/^[0-9]/.test(r)&&(r=`${t}_${r}`),(!r||r.length===0)&&(r=`${t}_${n}`),r}function te(e){let{sense:t,objective:n,constraints:r,variables:i}=e,a=new Map,o=new Map,s=new Map,c=new Set;for(let e of i){let t=R(e.name,`x`,e.id),n=t,r=1;for(;c.has(n);)n=`${t}_${r++}`;c.add(n),o.set(e,n),a.set(n,e)}let l=new Set,u=new Map;for(let e of r){let t=R(e.name,`c`,e.id),n=t,r=1;for(;l.has(n);)n=`${t}_${r++}`;l.add(n),u.set(e,n),s.set(n,e)}let d=[];d.push(t&&t.toLowerCase()===`maximize`?`Maximize`:`Minimize`);let f=[],p=!0,m=n instanceof T?n.linearTerms:n.terms;if(m)for(let[e,t]of m){if(Math.abs(t)<1e-12)continue;let n=o.get(e),r=t>=0?p?``:`+ `:`- `,i=Math.abs(t),a=i===1?``:`${i} `;f.push(`${r}${a}${n}`),p=!1}if(n instanceof T&&n.quadTerms.size>0){let e=[],t=!0;for(let r of n.quadTerms.values()){if(Math.abs(r.coeff)<1e-12)continue;let n=2*r.coeff,i=n>=0?t?``:`+ `:`- `,a=Math.abs(n),s=a===1?``:`${a} `,c=o.get(r.var1),l=o.get(r.var2);r.var1===r.var2?e.push(`${i}${s}${c} ^ 2`):e.push(`${i}${s}${c} * ${l}`),t=!1}if(e.length>0){let t=`[ ${e.join(` `)} ] / 2`;f.length>0?f.push(`+`,t):f.push(t)}}let h=f.length>0?f.join(` `):`0`;d.push(` obj: ${h}`),d.push(`Subject To`);for(let e of r){let t=u.get(e),n=[],r=!0;for(let[t,i]of e.lhs.terms){if(Math.abs(i)<1e-12)continue;let e=o.get(t),a=i>=0?r?``:`+ `:`- `,s=Math.abs(i),c=s===1?``:`${s} `;n.push(`${a}${c}${e}`),r=!1}let i=n.length>0?n.join(` `):`0`,a=e.sense===`==`?`=`:e.sense;d.push(` ${t}: ${i} ${a} ${e.rhs}`)}d.push(`Bounds`);let g=[],_=[];for(let e of i){let t=o.get(e);if(e.type===`Binary`){_.push(t);continue}e.type===`Integer`&&g.push(t);let n=e.lb===-1/0,r=e.ub===1/0;n&&r?d.push(` ${t} free`):n&&!r?d.push(` -infinity <= ${t} <= ${e.ub}`):!n&&r?e.lb!==0&&d.push(` ${t} >= ${e.lb}`):d.push(` ${e.lb} <= ${t} <= ${e.ub}`)}if(g.length>0){d.push(`Generals`);for(let e=0;e<g.length;e+=10)d.push(` `+g.slice(e,e+10).join(` `))}if(_.length>0){d.push(`Binary`);for(let e=0;e<_.length;e+=10)d.push(` `+_.slice(e,e+10).join(` `))}return d.push(`End`),{lpString:d.join(`
|
|
1
|
+
var Washi=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),l=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},u=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},d=(e,r,i)=>(i=e==null?{}:t(a(e)),u(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e));function f(e){if(e===void 0)return`Minimize`;if(typeof e==`string`){let t=e.toLowerCase();if(t===`maximize`)return`Maximize`;if(t===`minimize`)return`Minimize`}throw Error(`Invalid optimization sense "${String(e)}": expected "Maximize", "Minimize", "maximize", or "minimize".`)}var p=0;function m(e,t){if(e instanceof h||e instanceof w)return e;throw typeof e==`object`&&e&&(`terms`in e||`quadTerms`in e)?Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical operator "${t}". Use a comparison constraint such as expr\`\${x} <= 10\` or a BoolVar/BoolExpr.`):Error(`Invalid operand passed to logical operator "${t}": expected a BoolVar, BoolExpr, or Constraint.`)}var h=class{and(e){return new _(`and`,[this,m(e,`and`)])}or(e){return new _(`or`,[this,m(e,`or`)])}implies(e){return new _(`implies`,[this,m(e,`implies`)])}xor(e){return new _(`xor`,[this,m(e,`xor`)])}not(){return new _(`not`,[this])}},g=class extends h{id;name;value=null;constructor(e){super(),this.id=++p,this.name=e||`p_${this.id}`}toString(){return this.name}},_=class extends h{op;children;constructor(e,t){super(),this.op=e,this.children=t.map(t=>m(t,e))}toString(){return this.op===`not`?`not(${this.children[0].toString()})`:`(${this.children.map(e=>e.toString()).join(` ${this.op} `)})`}};function v(...e){if(e.length===0)throw Error(`and() requires at least one expression`);return new _(`and`,e)}function y(...e){if(e.length===0)throw Error(`or() requires at least one expression`);return new _(`or`,e)}function b(e){return new _(`not`,[e])}function x(e,t){return new _(`implies`,[e,t])}function S(...e){if(e.length===0)throw Error(`xor() requires at least one expression`);return new _(`xor`,e)}var C=0,w=class e{kind=`constraint`;id;_lhs;_sense;_rhs;_name;hasExplicitName;ownerModel=null;slack=null;dual=null;constructor(e,t,n,r){this.id=++C,this._lhs=e,this._sense=t,this._rhs=n;let i=typeof r==`string`?r.trim():void 0;i&&i.length>0?(this._name=i,this.hasExplicitName=!0):(this._name=`c_${this.id}`,this.hasExplicitName=!1)}get lhs(){return this._lhs}set lhs(e){this._lhs!==e&&(this._lhs=e,this.ownerModel?.notifyMutation?.())}get sense(){return this._sense}set sense(e){this._sense!==e&&(this._sense=e,this.ownerModel?.notifyMutation?.())}get rhs(){return this._rhs}set rhs(e){Object.is(this._rhs,e)||(this._rhs=e,this.ownerModel?.notifyMutation?.())}get name(){return this._name}set name(e){this._name!==e&&(this._name=e,this.ownerModel?.notifyMutation?.()),this.hasExplicitName=!0}_assignModelName(e,t){this._name=e,this.hasExplicitName=t}and(e){return new _(`and`,[this,e])}or(e){return new _(`or`,[this,e])}implies(e){return new _(`implies`,[this,e])}xor(e){return new _(`xor`,[this,e])}not(){return new _(`not`,[this])}add(e){throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`)}sub(e){throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`)}mul(e){throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`)}div(e){throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`)}neg(){throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`)}le(e,t){throw Error(`Cannot compare a Constraint in (<=): expected a number, Var, or LinExpr.`)}ge(e,t){throw Error(`Cannot compare a Constraint in (>=): expected a number, Var, or LinExpr.`)}eq(e,t){throw Error(`Cannot compare a Constraint in (==): expected a number, Var, or LinExpr.`)}get value(){throw Error(`Cannot read numeric value of a Constraint: expected a Var, LinExpr, or QuadExpr.`)}get constant(){throw Error(`Cannot read numeric constant of a Constraint: expected a LinExpr or QuadExpr.`)}clone(){return new e(this._lhs.clone(),this._sense,this._rhs,this.hasExplicitName?this._name:void 0)}toString(){let e=this.sense===`==`?`=`:this.sense;return`${this.name}: ${this.lhs.toString()} ${e} ${this.rhs}`}};function T(e){return e instanceof w||typeof e==`object`&&!!e&&`sense`in e&&`lhs`in e&&`rhs`in e}function E(e,t){let n=e.id,r=t.id;return n<=r?`${n}:${r}`:`${r}:${n}`}var D=class e{kind=`quadratic`;linearTerms;quadTerms;constant;constructor(e=new Map,t=new Map,n=0){this.linearTerms=new Map(e),this.quadTerms=new Map;for(let[e,n]of t)this.quadTerms.set(e,{...n});this.constant=n}clone(){return new e(this.linearTerms,this.quadTerms,this.constant)}getQuadCoeff(e,t){let n=E(e,t),r=this.quadTerms.get(n);return r?r.coeff:0}add(t){if(T(t))throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`);let n=this.clone();if(typeof t==`number`)return n.constant+=t,n;if(t instanceof e){for(let[e,r]of t.quadTerms){let t=n.quadTerms.get(e),i=(t?t.coeff:0)+r.coeff;i===0?n.quadTerms.delete(e):n.quadTerms.set(e,{var1:r.var1,var2:r.var2,coeff:i})}for(let[e,r]of t.linearTerms){let t=(n.linearTerms.get(e)??0)+r;t===0?n.linearTerms.delete(e):n.linearTerms.set(e,t)}return n.constant+=t.constant,n}if(`terms`in t&&t.terms instanceof Map){for(let[e,r]of t.terms){let t=(n.linearTerms.get(e)??0)+r;t===0?n.linearTerms.delete(e):n.linearTerms.set(e,t)}return n.constant+=t.constant,n}let r=t,i=(n.linearTerms.get(r)??0)+1;return i===0?n.linearTerms.delete(r):n.linearTerms.set(r,i),n}sub(e){if(T(e))throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`);return typeof e==`number`?this.add(-e):this.add(e.mul(-1))}mul(t){if(T(t))throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`);if(typeof t==`number`){let n=this.linearTerms.size>0||this.quadTerms.size>0,r=this.constant===0&&n?0:this.constant*t;if(this.constant!==0&&t!==0&&r===0)throw Error(`Constant multiplication underflows to zero.`);let i=new e(new Map,new Map,r);for(let[e,n]of this.linearTerms){let r=n*t;if(n!==0&&t!==0&&r===0)throw Error(`Coefficient multiplication underflows to zero.`);r!==0&&i.linearTerms.set(e,r)}for(let[e,n]of this.quadTerms){let r=n.coeff*t;if(n.coeff!==0&&t!==0&&r===0)throw Error(`Coefficient multiplication underflows to zero.`);r!==0&&i.quadTerms.set(e,{var1:n.var1,var2:n.var2,coeff:r})}return i}let n=`id`in t&&`name`in t&&!(`terms`in t)&&!(`quadTerms`in t),r=`quadTerms`in t?t.quadTerms.size:0,i=n?new Map([[t,1]]):`quadTerms`in t?t.linearTerms:t.terms,a=n?0:t.constant;if(this.quadTerms.size>0&&(r>0||i.size>0)||r>0&&this.linearTerms.size>0)throw Error(`Multiplication creates a non-linear term of degree > 2 (not allowed in MILP/LP/QP)`);if(r===0&&i.size===0)return this.mul(a);if(this.quadTerms.size===0&&this.linearTerms.size===0&&!n){let n=t.mul(this.constant);return`quadTerms`in n?n:new e(n.terms,new Map,n.constant)}return e.multiplyLinearTerms(this.constant,this.linearTerms,a,i)}div(t){let n=e.extractScalarDivisor(t,`QuadExpr.div()`);return this.mul(1/n)}neg(){return this.mul(-1)}get value(){let e=this.constant;for(let[t,n]of this.linearTerms){if(t.value===null)return null;e+=n*t.value}for(let t of this.quadTerms.values()){if(t.var1.value===null||t.var2.value===null)return null;e+=t.coeff*t.var1.value*t.var2.value}return e}le(e,t){return this.toConstraint(`<=`,e,t)}ge(e,t){return this.toConstraint(`>=`,e,t)}eq(e,t){return this.toConstraint(`==`,e,t)}toConstraint(e,t,n){if(this.quadTerms.size>0)throw Error(`Quadratic expressions are not supported in linear constraints (${e}): quadratic terms are only allowed in objectives.`);let r=new O(this.linearTerms,this.constant);return e===`<=`?r.le(t,n):e===`>=`?r.ge(t,n):r.eq(t,n)}and(e){throw Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical 'and': expected a BoolVar, Constraint, or BoolOp.`)}or(e){throw Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical 'or': expected a BoolVar, Constraint, or BoolOp.`)}implies(e){throw Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical 'implies': expected a BoolVar, Constraint, or BoolOp.`)}xor(e){throw Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical 'xor': expected a BoolVar, Constraint, or BoolOp.`)}not(){throw Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical 'not': expected a BoolVar, Constraint, or BoolOp.`)}toString(){let e=[],t=!0;for(let n of this.quadTerms.values()){let r=n.coeff,i=r>=0?t?``:`+ `:`- `,a=Math.abs(r),o=a===1?``:`${a} `;n.var1===n.var2?e.push(`${i}${o}${n.var1.name}^2`):e.push(`${i}${o}${n.var1.name} * ${n.var2.name}`),t=!1}for(let[n,r]of this.linearTerms){let i=r>=0?t?``:`+ `:`- `,a=Math.abs(r),o=a===1?``:`${a} `;e.push(`${i}${o}${n.name}`),t=!1}if(this.constant!==0||e.length===0){let n=this.constant>=0?t?``:`+ `:`- `;e.push(`${n}${Math.abs(this.constant)}`)}return e.join(` `)||`0`}static fromProduct(t,n,r=1){let i=new e;if(r===0)return i;let a=E(t,n);return i.quadTerms.set(a,{var1:t.id<=n.id?t:n,var2:t.id<=n.id?n:t,coeff:r}),i}static multiplyLinearTerms(t,n,r,i){let a=n.size>0||i.size>0,o=(t===0||r===0)&&a?0:t*r;if(t!==0&&r!==0&&o===0)throw Error(`Constant multiplication underflows to zero.`);let s=new e(new Map,new Map,o===0?0:o);if(r!==0)for(let[e,t]of n){let n=t*r;if(t!==0&&n===0)throw Error(`Coefficient multiplication underflows to zero.`);n!==0&&s.linearTerms.set(e,n)}if(t!==0)for(let[e,n]of i){let r=s.linearTerms.get(e)??0,i=n*t;if(n!==0&&i===0)throw Error(`Coefficient multiplication underflows to zero.`);let a=r+i;a===0?s.linearTerms.delete(e):s.linearTerms.set(e,a)}for(let[t,r]of n)for(let[n,a]of i){let i=r*a;if(r!==0&&a!==0&&i===0)throw Error(`Coefficient multiplication underflows to zero.`);s=s.add(e.fromProduct(t,n,i))}return s}static extractScalarDivisor(e,t){if(T(e))throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`);if(typeof e==`number`){if(e===0)throw Error(`Division by zero in ${t}`);return e}let n=`quadTerms`in e?e.linearTerms.size:e.terms.size,r=`quadTerms`in e?e.quadTerms.size:0;if(n>0||r>0)throw Error(`Cannot divide by variable in expression`);if(e.constant===0)throw Error(`Division by zero in ${t}`);return e.constant}},O=class e{kind=`linear`;terms;constant;constructor(e=new Map,t=0){this.terms=new Map(e),this.constant=t}clone(){return new e(this.terms,this.constant)}add(e){if(T(e))throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`);if(e instanceof D)return e.add(this);let t=this.clone();if(typeof e==`number`)t.constant+=e;else if(`terms`in e){for(let[n,r]of e.terms){let e=(t.terms.get(n)??0)+r;e===0?t.terms.delete(n):t.terms.set(n,e)}t.constant+=e.constant}else{let n=(t.terms.get(e)??0)+1;n===0?t.terms.delete(e):t.terms.set(e,n)}return t}sub(e){if(T(e))throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`);return e instanceof D?e.neg().add(this):typeof e==`number`?this.add(-e):this.add(e.mul(-1))}mul(t){if(T(t))throw Error(`Cannot perform arithmetic on a Constraint: expected a number, Var, LinExpr, or QuadExpr.`);if(typeof t==`number`){let n=this.constant===0&&this.terms.size>0?0:this.constant*t;if(this.constant!==0&&t!==0&&n===0)throw Error(`Constant multiplication underflows to zero.`);let r=new e(new Map,n);for(let[e,n]of this.terms){let i=n*t;if(n!==0&&t!==0&&i===0)throw Error(`Coefficient multiplication underflows to zero.`);i!==0&&r.terms.set(e,i)}return r}return t instanceof W||typeof t==`object`&&t&&`id`in t&&!(`terms`in t)&&!(`quadTerms`in t)?D.multiplyLinearTerms(this.constant,this.terms,0,new Map([[t,1]])):t instanceof D?this.terms.size===0?t.mul(this.constant):new D(this.terms,new Map,this.constant).mul(t):this.terms.size===0?t.mul(this.constant):t.terms.size===0?this.mul(t.constant):D.multiplyLinearTerms(this.constant,this.terms,t.constant,t.terms)}div(e){let t=D.extractScalarDivisor(e,`LinExpr.div()`);return this.mul(1/t)}neg(){return this.mul(-1)}get value(){let e=this.constant;for(let[t,n]of this.terms){if(t.value===null)return null;e+=n*t.value}return e}le(e,t){return this.toConstraint(`<=`,e,t)}ge(e,t){return this.toConstraint(`>=`,e,t)}eq(e,t){return this.toConstraint(`==`,e,t)}toConstraint(t,n,r){let i=this.clone(),a=0;if(typeof n==`number`)a=n;else if(n instanceof w||typeof n==`object`&&n&&`sense`in n&&`lhs`in n)throw Error(`Cannot compare against a Constraint in (${t}): expected a number, Var, or LinExpr.`);else if(n instanceof D||typeof n==`object`&&n&&`quadTerms`in n){let r=n;if(r.quadTerms.size>0)throw Error(`Quadratic expressions are not supported in linear constraints (${t}): quadratic terms are only allowed in objectives.`);i=i.sub(new e(r.linearTerms,0)),a=r.constant}else`terms`in n?(i=i.sub(new e(n.terms,0)),a=n.constant):i=i.sub(n);let o=a-i.constant;return i.constant=0,new w(i,t,o,r)}and(e){throw Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical 'and': expected a BoolVar, Constraint, or BoolOp.`)}or(e){throw Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical 'or': expected a BoolVar, Constraint, or BoolOp.`)}implies(e){throw Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical 'implies': expected a BoolVar, Constraint, or BoolOp.`)}xor(e){throw Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical 'xor': expected a BoolVar, Constraint, or BoolOp.`)}not(){throw Error(`Cannot use an arithmetic expression without a comparison operator (<=, >=, ==) in logical 'not': expected a BoolVar, Constraint, or BoolOp.`)}toString(){let e=[],t=!0;for(let[n,r]of this.terms){let i=r>=0?t?``:`+ `:`- `,a=Math.abs(r),o=a===1?``:`${a} `;e.push(`${i}${o}${n.name}`),t=!1}if(this.constant!==0||e.length===0){let n=this.constant>=0?t?``:`+ `:`- `;e.push(`${n}${Math.abs(this.constant)}`)}return e.join(` `)||`0`}};function k(e,t){let n=new Map,r=0;function i(e){if(e!=null){if(typeof e==`number`)r+=e;else if(e instanceof w||typeof e==`object`&&`sense`in e&&`lhs`in e&&`rhs`in e)throw Error(`Cannot sum a constraint comparison (<=, >=, ==) in sum(): expected a number, Var, or LinExpr.`);else if(e instanceof D||typeof e==`object`&&`quadTerms`in e&&e.quadTerms instanceof Map){let t=e;if(t.quadTerms.size>0)throw Error(`Quadratic expressions are not supported in sum(): sum() produces a linear expression (LinExpr).`);for(let[e,r]of t.linearTerms){let t=n.get(e)??0;n.set(e,t+r)}r+=t.constant}else if(typeof e==`object`&&`terms`in e){let t=e;for(let[e,r]of t.terms){let t=n.get(e)??0;n.set(e,t+r)}r+=t.constant}else if(typeof e==`object`&&`id`in e&&`name`in e&&`lb`in e&&`ub`in e){let t=e,r=n.get(t)??0;n.set(t,r+1)}else throw Error(`Unsupported item in sum(): expected a number, Var, or LinExpr.`)}}if(typeof e==`number`){let n=e,r=t;for(let e=0;e<n;e++)i(r(e,e))}else{let n=0;for(let r of e)i(t?t(r,n++):r)}for(let[e,t]of n)t===0&&n.delete(e);return new O(n,r)}function A(e,t){let n=new Map,r=0;function i(e){return typeof e==`object`&&!!e&&!(e instanceof w)&&typeof e.id==`number`&&typeof e.name==`string`&&typeof e.lb==`number`&&typeof e.ub==`number`&&typeof e.type==`string`&&typeof e.mul==`function`&&typeof e.le==`function`}function a(e){return i(e)||e instanceof O||e instanceof D}function o(e,t,a){if(!Number.isFinite(e))throw Error(`Invalid non-finite coefficient "${e}" in dot() at '${a||`root`}'.`);if(t instanceof D)throw Error(`Quadratic expressions are not supported in dot() at '${a||`root`}': dot() produces a linear expression (LinExpr).`);if(t instanceof O){if(!Number.isFinite(t.constant))throw Error(`Invalid non-finite constant "${t.constant}" in dot() at '${a||`root`}'.`);let i=e===0||t.constant===0?0:e*t.constant;if(e!==0&&t.constant!==0&&i===0)throw Error(`Constant multiplication underflows to zero.`);if(!Number.isFinite(i))throw Error(`Coefficient multiplication overflows finite floating-point range in dot() at '${a||`root`}'.`);let o=r+i;if(!Number.isFinite(o))throw Error(`Constant accumulation overflows finite floating-point range in dot() at '${a||`root`}'.`);r=o;for(let[r,i]of t.terms){if(!Number.isFinite(i))throw Error(`Invalid non-finite coefficient "${i}" in dot() at '${a||`root`}'.`);let t=e*i;if(e!==0&&i!==0&&t===0)throw Error(`Coefficient multiplication underflows to zero.`);if(!Number.isFinite(t))throw Error(`Coefficient multiplication overflows finite floating-point range in dot() at '${a||`root`}'.`);let o=(n.get(r)??0)+t;if(!Number.isFinite(o))throw Error(`Coefficient accumulation overflows finite floating-point range in dot() at '${a||`root`}'.`);n.set(r,o)}}else if(i(t)){let r=t,i=(n.get(r)??0)+e;if(!Number.isFinite(i))throw Error(`Coefficient accumulation overflows finite floating-point range in dot() at '${a||`root`}'.`);n.set(r,i)}else throw Error(`Cannot multiply number by non-variable/expression operand in dot() at '${a||`root`}'.`)}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!a(e)&&!(e instanceof w)&&e.kind!==`constraint`}function c(e,t,n=``){if(e===void 0||t===void 0||e===null||t===null)throw Error(`Nullish or undefined operand encountered in dot() at '${n||`root`}'.`);if(typeof e==`number`&&typeof t==`number`)throw Error(`Cannot multiply two numbers in dot() at '${n||`root`}': expected one numeric coefficient and one Var or LinExpr.`);if(typeof e==`number`){o(e,t,n);return}if(typeof t==`number`){o(t,e,n);return}if(Array.isArray(e)||Array.isArray(t)){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)throw Error(`Array length mismatch in dot() at '${n||`root`}': received lengths ${e.length} and ${t.length}.`);for(let r=0;r<e.length;r++)c(e[r],t[r],n?`${n}[${r}]`:`[${r}]`);return}let r=Array.isArray(e)?e:t,i=Array.isArray(e)?t:e;if(s(i)){if(Object.getOwnPropertySymbols(i).length>0)throw Error(`Symbol keys are not supported in dot() at '${n||`root`}'.`);let a=Object.keys(i);if(a.length===r.length&&a.every(e=>/^(?:0|[1-9]\d*)$/.test(e))){let a=[];for(let e=0;e<r.length;e++)Object.prototype.hasOwnProperty.call(i,e)||a.push(e);if(a.length>0)throw Error(`Key mismatch in dot() at '${n||`root`}': missing indices [${a.join(`, `)}] in numeric record.`);for(let i=0;i<r.length;i++)c(e[i],t[i],n?`${n}[${i}]`:`[${i}]`);return}throw a.length>0&&a.every(e=>/^(?:0|[1-9]\d*)$/.test(e))?Error(`Array length mismatch in dot() at '${n||`root`}': array has length ${r.length}, but object has ${a.length} indices.`):Error(`Type mismatch in dot() at '${n||`root`}': one operand is an Array while the other is an Object with keys [${a.slice(0,5).join(`, `)}].`)}throw Error(`Type mismatch in dot() at '${n||`root`}': one operand is an Array while the other is not.`)}if(s(e)&&s(t)){if(Object.getOwnPropertySymbols(e).length>0||Object.getOwnPropertySymbols(t).length>0)throw Error(`Symbol keys are not supported in dot() at '${n||`root`}'.`);let r=Object.keys(e),i=Object.keys(t),a=r.filter(e=>!Object.prototype.hasOwnProperty.call(t,e)),o=i.filter(t=>!Object.prototype.hasOwnProperty.call(e,t));if(a.length>0||o.length>0){let e=[];throw a.length>0&&e.push(`missing in second operand: [${a.join(`, `)}]`),o.length>0&&e.push(`missing in first operand: [${o.join(`, `)}]`),Error(`Key mismatch in dot() at '${n||`root`}': ${e.join(`; `)}.`)}for(let i of r)c(e[i],t[i],n?`${n}.${i}`:i);return}throw Error(`Unsupported operand types in dot() at '${n||`root`}'.`)}c(e,t);for(let[e,t]of n)t===0&&n.delete(e);return new O(n,r)}var j=new WeakMap,M=new WeakMap,N=new WeakMap;function P(e,t,n){if(e instanceof _)for(let r of e.children)P(r,t,n);else if(e instanceof w){let r=e.ownerModel,i=M.get(e);(r!==t||i!==t)&&(n&&n.push(()=>{e.ownerModel=r,i?M.set(e,i):M.delete(e)}),e.ownerModel=t,M.set(e,t))}}function F(e,t){let n=j.get(e);if(n&&n!==t)throw Error(`Variable "${e.name}" already belongs to model "${n.name}" and cannot be added to model "${t.name}".`);j.set(e,t)}function I(e,t){let n=N.get(e);if(n)throw Error(n===t?`Constraint "${e.name}" is already registered in model "${t.name}".`:`Constraint "${e.name}" already belongs to model "${n.name}" and cannot be added to model "${t.name}".`);let r=M.get(e);if(r&&r!==t)throw Error(`Constraint "${e.name}" already belongs to model "${r.name}" and cannot be added to model "${t.name}".`);return N.set(e,t),M.set(e,t),r}function L(e,t){j.get(e)===t&&j.delete(e)}function R(e,t,n){N.get(e)===t&&N.delete(e),M.get(e)===t&&(n?M.set(e,n):M.delete(e))}var z=1e-6;function ee(e){if(typeof e.lb!=`number`||Number.isNaN(e.lb))throw Error(`Variable "${e.name}" has invalid lower bound: ${e.lb} (NaN or non-numeric bound is not allowed).`);if(e.lb===1/0)throw Error(`Variable "${e.name}" has invalid lower bound: +Infinity is not allowed as a lower bound.`);if(typeof e.ub!=`number`||Number.isNaN(e.ub))throw Error(`Variable "${e.name}" has invalid upper bound: ${e.ub} (NaN or non-numeric bound is not allowed).`);if(e.ub===-1/0)throw Error(`Variable "${e.name}" has invalid upper bound: -Infinity is not allowed as an upper bound.`);if(e.lb>e.ub)throw Error(`Variable "${e.name}" has invalid bounds: lower bound (${e.lb}) is strictly greater than upper bound (${e.ub}).`);if(e.initialValue!==void 0){if(typeof e.initialValue!=`number`||!Number.isFinite(e.initialValue))throw Error(`Variable "${e.name}" has invalid initialValue: ${String(e.initialValue)} (initialValue must be a finite number).`);let t=e.type===`Binary`?Math.max(0,e.lb):e.lb,n=e.type===`Binary`?Math.min(1,e.ub):e.ub;if(e.initialValue<t-1e-6||e.initialValue>n+1e-6)throw Error(`Variable "${e.name}" has initialValue (${e.initialValue}) outside its bounds [${t}, ${n}] (tolerance ${z}).`);if(e.type===`Integer`||e.type===`Binary`){let r=Math.round(e.initialValue);if(Math.abs(e.initialValue-r)>1e-6||r<t||r>n)throw Error(`Variable "${e.name}" of type "${e.type}" has non-integral or out-of-domain initialValue: ${e.initialValue} (must be within ${z} of an integer in [${t}, ${n}]).`)}}}function B(e){if(e.initialValue===void 0)return;if(ee(e),e.type===`Integer`||e.type===`Binary`){let t=Math.round(e.initialValue);return Object.is(t,-0)?0:t}let t=Math.min(e.ub,Math.max(e.lb,e.initialValue));return Object.is(t,-0)?0:t}function te(e,t,n){if(e instanceof D){if(!Number.isFinite(e.constant))throw Error(`Objective function has invalid constant: ${e.constant}. Constant must be a finite number.`);for(let[r,i]of e.linearTerms){if(!n(r))throw Error(`Variable "${r.name}" in objective function does not belong to model "${t}". All variables must belong to the model by object identity.`);if(!Number.isFinite(i))throw Error(`Variable "${r.name}" in objective function has invalid coefficient: ${i}. Coefficients must be finite numbers.`)}for(let[,r]of e.quadTerms){if(!n(r.var1))throw Error(`Variable "${r.var1.name}" in quadratic objective function does not belong to model "${t}". All variables must belong to the model by object identity.`);if(!n(r.var2))throw Error(`Variable "${r.var2.name}" in quadratic objective function does not belong to model "${t}". All variables must belong to the model by object identity.`);if(!Number.isFinite(r.coeff)||!Number.isFinite(r.coeff*2))throw Error(`Quadratic term (${r.var1.name} * ${r.var2.name}) in objective function has invalid coefficient: ${r.coeff}.`)}}else if(`terms`in e){if(!Number.isFinite(e.constant))throw Error(`Objective function has invalid constant: ${e.constant}. Constant must be a finite number.`);for(let[r,i]of e.terms){if(!n(r))throw Error(`Variable "${r.name}" in objective function does not belong to model "${t}". All variables must belong to the model by object identity.`);if(!Number.isFinite(i))throw Error(`Variable "${r.name}" in objective function has invalid coefficient: ${i}. Coefficients must be finite numbers.`)}}}function V(e,t,n,r=e.name){if(!Number.isFinite(e.rhs))throw Error(`Constraint "${r}" has invalid right-hand side (RHS): ${e.rhs}. RHS must be a finite number.`);if(e.lhs.constant!==void 0&&!Number.isFinite(e.lhs.constant))throw Error(`Constraint "${r}" has invalid LHS constant: ${e.lhs.constant}. Constant must be a finite number.`);for(let[i,a]of e.lhs.terms){if(!n(i))throw Error(`Variable "${i.name}" in constraint "${r}" does not belong to model "${t}". All variables must belong to the model by object identity.`);if(!Number.isFinite(a))throw Error(`Variable "${i.name}" in constraint "${r}" has invalid coefficient: ${a}. Coefficients must be finite numbers.`)}}function ne(e,t,n,r,i,a){if(e instanceof g){if(!i(e))throw Error(`Boolean variable "${e.name}" in logical constraint "${t}" does not belong to model "${n}".`)}else if(e instanceof _)for(let o of e.children)ne(o,t,n,r,i,a);else if(e instanceof w){if(a){let r=M.get(e)??e.ownerModel??void 0;if(r&&r!==a)throw Error(`Constraint "${e.name}" embedded in logical constraint "${t}" already belongs to model "${r.name??`another model`}" and cannot be added to model "${n}".`)}if(!Number.isFinite(e.rhs))throw Error(`Constraint "${e.name}" embedded in logical constraint "${t}" has invalid RHS: ${e.rhs}.`);if(e.lhs.constant!==void 0&&!Number.isFinite(e.lhs.constant))throw Error(`Constraint "${e.name}" embedded in logical constraint "${t}" has invalid LHS constant: ${e.lhs.constant}.`);for(let[i,a]of e.lhs.terms){if(!r(i))throw Error(`Variable "${i.name}" embedded in logical constraint "${t}" does not belong to model "${n}".`);if(!Number.isFinite(a))throw Error(`Variable "${i.name}" embedded in logical constraint "${t}" has invalid coefficient: ${a}.`)}}}function re(e){let t=new Set,n=new Set;for(let r of e.variables){ee(r);let i=j.get(r);if(i&&i!==e||t.has(r.name)||e.getVarByName(r.name)!==r)throw Error(`Variable "${r.name}" is duplicated or not canonically registered in model "${e.name}".`);t.add(r.name),n.add(r)}let r=new Set,i=new Set;for(let t of e.boolVars){if(r.has(t.name)||e.getBoolVarByName(t.name)!==t)throw Error(`Boolean variable "${t.name}" is duplicated or not canonically registered in model "${e.name}".`);r.add(t.name),i.add(t)}let a=new Set;for(let t of e.constraints){if(r.has(t.name))throw Error(`Constraint name "${t.name}" conflicts with Boolean variable "${t.name}" in model "${e.name}".`);if(a.has(t.name))throw Error(`Duplicate constraint name "${t.name}" in model "${e.name}".`);a.add(t.name)}for(let t of e.logicalConstraints){if(r.has(t.name))throw Error(`Logical constraint name "${t.name}" conflicts with Boolean variable "${t.name}" in model "${e.name}".`);if(a.has(t.name))throw Error(`Conflicting constraint name "${t.name}" across arithmetic and logical constraints in model "${e.name}".`);a.add(t.name)}for(let t of e.constraints){let n=M.get(t);if(n&&n!==e||e.getConstraintByName(t.name)!==t)throw Error(`Constraint "${t.name}" is duplicated or not canonically registered in model "${e.name}".`)}for(let t of e.logicalConstraints)if(e.getLogicalConstraintByName(t.name)!==t)throw Error(`Logical constraint "${t.name}" is duplicated or not canonically registered in model "${e.name}".`);e.objectiveExpr&&te(e.objectiveExpr,e.name,e=>n.has(e));for(let t of e.constraints)V(t,e.name,e=>n.has(e));for(let t of e.logicalConstraints)ne(t.expr,t.name,e.name,e=>n.has(e),e=>i.has(e),e)}var H=0;function U(e){if(e===void 0)return`Continuous`;if(typeof e==`string`){let t=e.toLowerCase();if(t===`binary`||t===`bin`)return`Binary`;if(t===`integer`||t===`int`)return`Integer`;if(t===`continuous`||t===`cont`)return`Continuous`}throw Error(`Invalid variable type "${String(e)}": expected "Continuous", "Integer", or "Binary".`)}var W=class{id;_name;prefix;hasExplicitName;ownerModel=null;_type;_lb;_ub;_initialValue;value=null;reducedCost=null;constructor(e={}){this.id=++H;let t=typeof e.name==`string`?e.name.trim():``,n=typeof e.prefix==`string`?e.prefix.trim():``;this.prefix=n.length>0?n:`x`,this.hasExplicitName=t.length>0,this._name=this.hasExplicitName?t:`${this.prefix}_${this.id}`,this._type=U(e.type),this._type===`Binary`?(this._lb=0,this._ub=1):(this._lb=e.lb===void 0?0:e.lb,this._ub=e.ub===void 0?1/0:e.ub),this._initialValue=e.initialValue===void 0?void 0:Object.is(e.initialValue,-0)?0:e.initialValue,this._initialValue!==void 0&&ee(this)}get name(){return this._name}get type(){return this._type}set type(e){let t=U(e);this._type!==t&&(this._type=t,this.ownerModel?.notifyMutation?.())}get lb(){return this._lb}set lb(e){Object.is(this._lb,e)||(this._lb=e,this.ownerModel?.notifyMutation?.())}get ub(){return this._ub}set ub(e){Object.is(this._ub,e)||(this._ub=e,this.ownerModel?.notifyMutation?.())}get initialValue(){return this._initialValue}set initialValue(e){let t=e!==void 0&&Object.is(e,-0)?0:e;Object.is(this._initialValue,t)||(this._initialValue=t,this.ownerModel?.notifyMutation?.())}_assignModelName(e){this._name=e}mul(e){return typeof e==`number`?new O(new Map([[this,1]]),0).mul(e):new D(new Map([[this,1]]),new Map,0).mul(e)}add(e){return e instanceof D?e.add(this):new O(new Map([[this,1]]),0).add(e)}sub(e){return e instanceof D?e.neg().add(this):new O(new Map([[this,1]]),0).sub(e)}neg(){return this.mul(-1)}le(e,t){return new O(new Map([[this,1]]),0).le(e,t)}ge(e,t){return new O(new Map([[this,1]]),0).ge(e,t)}eq(e,t){return new O(new Map([[this,1]]),0).eq(e,t)}toString(){return this.name}},ie=/^(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;function ae(e,t){let n=[],r=0,i=e.length;for(;r<i;){let a=e[r];if(/\s/.test(a)){r++;continue}if(a===`+`)n.push({type:`PLUS`,value:`+`}),r++;else if(a===`-`)n.push({type:`MINUS`,value:`-`}),r++;else if(a===`*`)r+1<i&&e[r+1]===`*`?(n.push({type:`CARET`,value:`**`}),r+=2):(n.push({type:`STAR`,value:`*`}),r++);else if(a===`^`)n.push({type:`CARET`,value:`^`}),r++;else if(a===`/`)n.push({type:`SLASH`,value:`/`}),r++;else if(a===`(`)n.push({type:`LPAREN`,value:`(`}),r++;else if(a===`)`)n.push({type:`RPAREN`,value:`)`}),r++;else if(a===`<`||a===`>`||a===`=`){let t=a;r+1<i&&(e[r+1]===`=`||e[r+1]===`<`||e[r+1]===`>`)?(t+=e[r+1],r+=2):r++,n.push({type:`COMP`,value:t})}else if(/[0-9.]/.test(a)){let t=r,a=``;for(;r<i&&/[0-9]/.test(e[r]);)a+=e[r++];if(r<i&&e[r]===`.`)for(a+=e[r++];r<i&&/[0-9]/.test(e[r]);)a+=e[r++];if(r<i&&(e[r]===`e`||e[r]===`E`)){let t=r+1<i?e[r+1]:``;if(!/[a-zA-Z_]/.test(t)){for(a+=e[r++],r<i&&(e[r]===`+`||e[r]===`-`)&&(a+=e[r++]);r<i&&/[0-9]/.test(e[r]);)a+=e[r++];for(;r<i&&(e[r]===`.`||e[r]===`e`||e[r]===`E`||/[0-9]/.test(e[r]));)a+=e[r++]}}else for(;r<i&&(e[r]===`.`||/[0-9]/.test(e[r]));)a+=e[r++];if(!ie.test(a))throw Error(`Invalid numeric literal '${a}' at position ${t} in: "${e}"`);let o=Number(a);if(!Number.isFinite(o))throw Error(`Numeric literal '${a}' overflows finite floating-point range in: "${e}"`);if(o===0&&!/^[0.]+(?:[eE][+-]?\d+)?$/.test(a))throw Error(`Numeric literal '${a}' underflows to zero at position ${t} in: "${e}"`);n.push({type:`NUMBER`,value:a,numericValue:o})}else if(/[a-zA-Z_]/.test(a)){let a=``;for(;r<i&&/[a-zA-Z0-9_]/.test(e[r]);)a+=e[r],r++;if(t&&t.has(a)){let e=t.get(a);n.push({type:`NUMBER`,value:String(e),numericValue:e})}else n.push({type:`IDENT`,value:a})}else throw Error(`Unexpected character '${a}' at position ${r} in: "${e}"`)}return n}var oe=class{tokens;pos=0;resolver;constructor(e,t){this.tokens=e,this.resolver=t}peek(){return this.tokens[this.pos]}consume(e){let t=this.tokens[this.pos++];if(!t)throw Error(`Unexpected end of input`);if(e&&t.value!==e&&t.type!==e)throw Error(`Expected '${e}', but found '${t.value}'`);return t}parseExpression(){let e=this.parseTerm();for(;this.pos<this.tokens.length;){let t=this.peek();if(!t)break;if(t.type===`PLUS`)this.consume(),e=e.add(this.parseTerm());else if(t.type===`MINUS`)this.consume(),e=e.sub(this.parseTerm());else break}return e instanceof D&&e.quadTerms.size===0?new O(e.linearTerms,e.constant):e}parseTerm(){let e=this.parseFactor();for(;this.pos<this.tokens.length;){let t=this.peek();if(!t)break;if(t.type===`STAR`)this.consume(),e=e.mul(this.parseFactor());else if(t.type===`SLASH`)this.consume(),e=e.div(this.parseFactor());else break}return e}parseFactor(){let e=this.peek();if(!e)throw Error(`Unexpected end of expression`);if(e.type===`PLUS`)return this.consume(),this.parseFactor();if(e.type===`MINUS`)return this.consume(),this.parseFactor().neg();let t;if(e.type===`NUMBER`){this.consume();let n=e.numericValue??Number(e.value);if(this.peek()?.type===`IDENT`||this.peek()?.type===`LPAREN`){let e;if(this.peek()?.type===`IDENT`){let t=this.consume(),n=this.resolve(t.value);e=n instanceof W||`id`in n&&!(`terms`in n)&&!(`quadTerms`in n)?new O(new Map([[n,1]]),0):n.clone()}else this.consume(`LPAREN`),e=this.parseExpression(),this.consume(`RPAREN`);return this.applyPower(e).mul(n)}t=new O(new Map,n)}else if(e.type===`IDENT`){this.consume();let n=this.resolve(e.value);t=n instanceof W||`id`in n&&!(`terms`in n)&&!(`quadTerms`in n)?new O(new Map([[n,1]]),0):n.clone()}else if(e.type===`LPAREN`)this.consume(`LPAREN`),t=this.parseExpression(),this.consume(`RPAREN`);else throw Error(`Unexpected token '${e.value}' in expression`);return this.applyPower(t)}applyPower(e){if(this.peek()?.type!==`CARET`)return e;let t=[];for(;this.peek()?.type===`CARET`;){this.consume();let e=this.tokens[this.pos]?.type===`LPAREN`&&this.tokens[this.pos+1]?.type===`NUMBER`&&this.tokens[this.pos+2]?.type===`RPAREN`;e&&this.consume(`LPAREN`);let n=this.peek();if(!n||n.type!==`NUMBER`)throw Error(`Exponent must be a non-negative integer number`);this.consume(),e&&this.consume(`RPAREN`);let r=n.numericValue??Number(n.value);if(!Number.isInteger(r)||r<0)throw Error(`Exponent must be a non-negative integer`);t.push(r)}let n=t[t.length-1];for(let e=t.length-2;e>=0;e--)n=t[e]**+n;if(!Number.isFinite(n)||n<0)throw Error(`Exponent creates an invalid or out-of-range power`);let r=e instanceof D,i=r?e.quadTerms.size:0,a=r?e.linearTerms.size:e.terms.size;if(i===0&&a===0){let t=e.constant**+n;if(e.constant!==0&&n>0&&t===0)throw Error(`Constant exponentiation underflows to zero.`);return new O(new Map,t)}if(n===0)return new O(new Map,1);if(n===1)return e;if(n===2)return e.mul(e);throw Error(`Exponent ${n} creates a non-linear term of degree > 2 (not allowed in MILP/LP/QP)`)}getRemainingToken(){return this.peek()}resolve(e){let t=this.resolver(e);if(!t)throw Error(`Unknown variable '${e}' in expression`);return t}};function se(e,t,n){let r=new oe(ae(e,n),t),i=r.parseExpression(),a=r.getRemainingToken();if(a)throw Error(`Unexpected token '${a.value}' after expression in "${e}"`);return ue(i),i}function ce(e,t){return se(e,t)}function G(e,t,n,r){let i=e.match(/(<=|>=|==|=<|=>|=)/);if(!i)throw Error(`Constraint must contain a comparison operator (<=, >=, ==, =): "${e}"`);let a=i[0],o=i.index,s=e.substring(0,o).trim(),c=e.substring(o+a.length).trim(),l;if(a===`<=`||a===`=<`)l=`<=`;else if(a===`>=`||a===`=>`)l=`>=`;else if(a===`==`||a===`=`)l=`==`;else throw Error(`Unsupported operator "${a}"`);let u=se(s,t,r),d=se(c,t,r);if(u instanceof D&&u.quadTerms.size>0||d instanceof D&&d.quadTerms.size>0)throw Error(`Quadratic constraints are not supported (only linear constraints are allowed in MILP/LP/QP)`);let f=u instanceof D?new O(u.linearTerms,u.constant):u,p=d instanceof D?new O(d.linearTerms,d.constant):d,m;if(m=l===`<=`?f.le(p,n):l===`>=`?f.ge(p,n):f.eq(p,n),ue(m.lhs),!Number.isFinite(m.rhs))throw Error(`Invalid non-finite right-hand side "${m.rhs}" in constraint.`);return m}function K(e,t,n){return G(e,t,n)}function le(e){return e instanceof W||e instanceof O||e instanceof D?!0:typeof e!=`object`||!e?!1:`terms`in e&&e.terms instanceof Map||`quadTerms`in e&&e.quadTerms instanceof Map||`id`in e&&`name`in e&&`lb`in e&&`ub`in e&&`type`in e&&typeof e.mul==`function`}function ue(e){if(`constant`in e&&!Number.isFinite(e.constant))throw Error(`Invalid non-finite constant "${e.constant}" in expression.`);if(`terms`in e&&e.terms instanceof Map){for(let[,t]of e.terms)if(!Number.isFinite(t))throw Error(`Invalid non-finite coefficient "${t}" in expression.`)}if(`linearTerms`in e&&e.linearTerms instanceof Map){for(let[,t]of e.linearTerms)if(!Number.isFinite(t))throw Error(`Invalid non-finite coefficient "${t}" in expression.`)}if(`quadTerms`in e&&e.quadTerms instanceof Map){for(let[,t]of e.quadTerms)if(!Number.isFinite(t.coeff))throw Error(`Invalid non-finite quadratic coefficient "${t.coeff}" in expression.`)}}function de(e){return e instanceof w||typeof e==`object`&&!!e&&`sense`in e&&`lhs`in e&&`rhs`in e}function q(e,t){let n=new Map,r=new Map,i=e.join(``),a=`__washi_`;for(;i.includes(a);)a+=`_`;let o=``;for(let i=0;i<e.length;i++)if(o+=e[i],i<t.length){let e=t[i];if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Invalid numeric value "${e}" in template expression: interpolated numbers must be finite.`);let t=`${a}num_${i}__`;r.set(t,e),o+=`(${t})`}else if(de(e))throw Error(`Cannot interpolate a constraint comparison (<=, >=, ==) inside a template expression: expected a finite number, Var, LinExpr, or QuadExpr.`);else if(le(e)){ue(e);let t=`${a}ph_${i}__`;n.set(t,e),o+=` ${t} `}else throw Error(`Unsupported interpolation value in template expression: expected a finite number, Var, LinExpr, or QuadExpr.`)}return{fullText:o,resolver:e=>n.get(e),numberMap:r}}function fe(e,...t){let{fullText:n,resolver:r,numberMap:i}=q(e,t);return/(<=|>=|==|=<|=>|=)/.test(n)?G(n,r,void 0,i):se(n,r,i)}function pe(e){return typeof e==`object`&&!!e&&typeof e.lpString==`string`&&e.nameToVar instanceof Map&&e.nameToConstraint instanceof Map}function me(e,t=`x`,n=0){let r=e.replace(/[^a-zA-Z0-9_]/g,`_`);return/^[0-9]/.test(r)&&(r=`${t}_${r}`),(!r||r.length===0)&&(r=`${t}_${n}`),r}function he(e){let t=e.variables||[],n=e.constraints||[],r=new Map,i=new Map,a=new Map,o=new Map,s=new Map,c=new Set;for(let e=0;e<t.length;e++){let n=t[e];s.set(n,e);let a=me(n.name,`x`,e),o=a,l=1;for(;c.has(o);)o=`${a}_${l++}`;c.add(o),i.set(n,o),r.set(o,n)}let l=new Set;for(let e=0;e<n.length;e++){let t=n[e],r=me(t.name,`c`,e+1),i=r,s=1;for(;l.has(i);)i=`${r}_${s++}`;l.add(i),o.set(t,i),a.set(i,t)}return{nameToVar:r,varToName:i,nameToConstraint:a,constraintToName:o,constrToName:o,varOrder:s}}function ge(e){let{sense:t,objective:n,constraints:r,variables:i}=e,{nameToVar:a,varToName:o,nameToConstraint:s,constrToName:c,varOrder:l}=he(e),u=[];u.push(t&&t.toLowerCase()===`maximize`?`Maximize`:`Minimize`);let d=[],f=!0,p=n instanceof D?n.linearTerms:n.terms;if(p)for(let[e,t]of p){if(t===0)continue;let n=o.get(e),r=t>=0?f?``:`+ `:`- `,i=Math.abs(t),a=i===1?``:`${i} `;d.push(`${r}${a}${n}`),f=!1}if(n instanceof D&&n.quadTerms.size>0){let e=[],t=!0,r=Array.from(n.quadTerms.values()).filter(e=>e.coeff!==0).map(e=>{let t=l.get(e.var1)??e.var1.id,n=l.get(e.var2)??e.var2.id,[r,i,a,o]=t<=n?[e.var1,e.var2,t,n]:[e.var2,e.var1,n,t];return{firstVar:r,secondVar:i,firstIdx:a,secondIdx:o,coeff:e.coeff}}).sort((e,t)=>e.firstIdx-t.firstIdx||e.secondIdx-t.secondIdx);for(let n of r){let r=2*n.coeff,i=r>=0?t?``:`+ `:`- `,a=Math.abs(r),s=a===1?``:`${a} `,c=o.get(n.firstVar),l=o.get(n.secondVar);n.firstVar===n.secondVar?e.push(`${i}${s}${c} ^ 2`):e.push(`${i}${s}${c} * ${l}`),t=!1}if(e.length>0){let t=`[ ${e.join(` `)} ] / 2`;d.length>0?d.push(`+`,t):d.push(t)}}let m=d.length>0?d.join(` `):`0`;u.push(` obj: ${m}`),u.push(`Subject To`);for(let e of r){let t=c.get(e),n=[],r=!0;for(let[t,i]of e.lhs.terms){if(i===0)continue;let e=o.get(t),a=i>=0?r?``:`+ `:`- `,s=Math.abs(i),c=s===1?``:`${s} `;n.push(`${a}${c}${e}`),r=!1}let i=n.length>0?n.join(` `):`0`,a=e.sense===`==`?`=`:e.sense;u.push(` ${t}: ${i} ${a} ${e.rhs}`)}u.push(`Bounds`);let h=[],g=[];for(let e of i){let t=o.get(e);if(e.type===`Binary`){g.push(t);continue}e.type===`Integer`&&h.push(t);let n=e.lb===-1/0,r=e.ub===1/0;n&&r?u.push(` ${t} free`):n&&!r?u.push(` -infinity <= ${t} <= ${e.ub}`):!n&&r?(e.lb!==0||e.initialValue!==void 0)&&u.push(` ${t} >= ${e.lb}`):u.push(` ${e.lb} <= ${t} <= ${e.ub}`)}if(h.length>0){u.push(`Generals`);for(let e=0;e<h.length;e+=10)u.push(` `+h.slice(e,e+10).join(` `))}if(g.length>0){u.push(`Binary`);for(let e=0;e<g.length;e+=10)u.push(` `+g.slice(e,e+10).join(` `))}return u.push(`End`),{lpString:u.join(`
|
|
2
2
|
`)+`
|
|
3
|
-
`,nameToVar:a,nameToConstraint:s}}var
|
|
4
|
-
`)),!e)return null;me=J(e,!0)}return me.shift()},Y={ttys:[],init(){},shutdown(){},register(e,t){Y.ttys[e]={input:[],output:[],ops:t},Q.registerDevice(e,Y.stream_ops)},stream_ops:{open(e){var t=Y.ttys[e.node.rdev];if(!t)throw new Q.ErrnoError(43);e.tty=t,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,t,n,r,i){if(!e.tty||!e.tty.ops.get_char)throw new Q.ErrnoError(60);for(var a=0,o=0;o<r;o++){var s;try{s=e.tty.ops.get_char(e.tty)}catch{throw new Q.ErrnoError(29)}if(s===void 0&&a===0)throw new Q.ErrnoError(6);if(s==null)break;a++,t[n+o]=s}return a&&(e.node.atime=Date.now()),a},write(e,t,n,r,i){if(!e.tty||!e.tty.ops.put_char)throw new Q.ErrnoError(60);try{for(var a=0;a<r;a++)e.tty.ops.put_char(e.tty,t[n+a])}catch{throw new Q.ErrnoError(29)}return r&&(e.node.mtime=e.node.ctime=Date.now()),a}},default_tty_ops:{get_char(e){return _e()},put_char(e,t){t===null||t===10?(p(pe(e.output)),e.output=[]):t!=0&&e.output.push(t)},fsync(e){e.output?.length>0&&(p(pe(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,t,n){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,t){t===null||t===10?(m(pe(e.output)),e.output=[]):t!=0&&e.output.push(t)},fsync(e){e.output?.length>0&&(m(pe(e.output)),e.output=[])}}},ve=e=>{w()},X={ops_table:null,mount(e){return X.createNode(null,`/`,16895,0)},createNode(e,t,n,r){if(Q.isBlkdev(n)||Q.isFIFO(n))throw new Q.ErrnoError(63);X.ops_table||={dir:{node:{getattr:X.node_ops.getattr,setattr:X.node_ops.setattr,lookup:X.node_ops.lookup,mknod:X.node_ops.mknod,rename:X.node_ops.rename,unlink:X.node_ops.unlink,rmdir:X.node_ops.rmdir,readdir:X.node_ops.readdir,symlink:X.node_ops.symlink},stream:{llseek:X.stream_ops.llseek}},file:{node:{getattr:X.node_ops.getattr,setattr:X.node_ops.setattr},stream:{llseek:X.stream_ops.llseek,read:X.stream_ops.read,write:X.stream_ops.write,mmap:X.stream_ops.mmap,msync:X.stream_ops.msync}},link:{node:{getattr:X.node_ops.getattr,setattr:X.node_ops.setattr,readlink:X.node_ops.readlink},stream:{}},chrdev:{node:{getattr:X.node_ops.getattr,setattr:X.node_ops.setattr},stream:Q.chrdev_stream_ops}};var i=Q.createNode(e,t,n,r);return Q.isDir(i.mode)?(i.node_ops=X.ops_table.dir.node,i.stream_ops=X.ops_table.dir.stream,i.contents={}):Q.isFile(i.mode)?(i.node_ops=X.ops_table.file.node,i.stream_ops=X.ops_table.file.stream,i.usedBytes=0,i.contents=X.emptyFileContents??=new Uint8Array):Q.isLink(i.mode)?(i.node_ops=X.ops_table.link.node,i.stream_ops=X.ops_table.link.stream):Q.isChrdev(i.mode)&&(i.node_ops=X.ops_table.chrdev.node,i.stream_ops=X.ops_table.chrdev.stream),i.atime=i.mtime=i.ctime=Date.now(),e&&(e.contents[t]=i,e.atime=e.mtime=e.ctime=i.atime),i},getFileDataAsTypedArray(e){return e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,t){var n=e.contents.length;if(!(n>=t)){t=Math.max(t,n*(n<1048576?2:1.125)>>>0),n&&(t=Math.max(t,256));var r=X.getFileDataAsTypedArray(e);e.contents=new Uint8Array(t),e.contents.set(r)}},resizeFileStorage(e,t){if(e.usedBytes!=t){var n=e.contents;e.contents=new Uint8Array(t),e.contents.set(n.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=Q.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,t.size=Q.isDir(e.mode)?4096:Q.isFile(e.mode)?e.usedBytes:Q.isLink(e.mode)?e.link.length:0,t.atime=new Date(e.atime),t.mtime=new Date(e.mtime),t.ctime=new Date(e.ctime),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){for(let n of[`mode`,`atime`,`mtime`,`ctime`])t[n]!=null&&(e[n]=t[n]);t.size!==void 0&&X.resizeFileStorage(e,t.size)},lookup(e,t){throw X.doesNotExistError||(X.doesNotExistError=new Q.ErrnoError(44),X.doesNotExistError.stack=`<generic error, no stack>`),X.doesNotExistError},mknod(e,t,n,r){return X.createNode(e,t,n,r)},rename(e,t,n){var r;try{r=Q.lookupNode(t,n)}catch{}if(r){if(Q.isDir(e.mode))for(var i in r.contents)throw new Q.ErrnoError(55);Q.hashRemoveNode(r)}delete e.parent.contents[e.name],t.contents[n]=e,e.name=n,t.ctime=t.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,t){delete e.contents[t],e.ctime=e.mtime=Date.now()},rmdir(e,t){for(var n in Q.lookupNode(e,t).contents)throw new Q.ErrnoError(55);delete e.contents[t],e.ctime=e.mtime=Date.now()},readdir(e){return[`.`,`..`,...Object.keys(e.contents)]},symlink(e,t,n){var r=X.createNode(e,t,41471,0);return r.link=n,r},readlink(e){if(!Q.isLink(e.mode))throw new Q.ErrnoError(28);return e.link}},stream_ops:{read(e,t,n,r,i){var a=e.node.contents;if(i>=e.node.usedBytes)return 0;var o=Math.min(e.node.usedBytes-i,r);return t.set(a.subarray(i,i+o),n),o},write(e,t,n,r,i,a){if(t.buffer===I.buffer&&(a=!1),!r)return 0;var o=e.node;return o.mtime=o.ctime=Date.now(),a?(o.contents=t.subarray(n,n+r),o.usedBytes=r):o.usedBytes===0&&i===0?(o.contents=t.slice(n,n+r),o.usedBytes=r):(X.expandFileStorage(o,i+r),o.contents.set(t.subarray(n,n+r),i),o.usedBytes=Math.max(o.usedBytes,i+r)),r},llseek(e,t,n){var r=t;if(n===1?r+=e.position:n===2&&Q.isFile(e.node.mode)&&(r+=e.node.usedBytes),r<0)throw new Q.ErrnoError(28);return r},mmap(e,t,n,r,i){if(!Q.isFile(e.node.mode))throw new Q.ErrnoError(43);var a,o,s=e.node.contents;if(!(i&2)&&s.buffer===I.buffer)o=!1,a=s.byteOffset;else{if(o=!0,a=ve(t),!a)throw new Q.ErrnoError(48);s&&((n>0||n+t<s.length)&&(s=s.subarray?s.subarray(n,n+t):Array.prototype.slice.call(s,n,n+t)),I.set(s,a))}return{ptr:a,allocated:o}},msync(e,t,n,r,i){return X.stream_ops.write(e,t,0,r,n,!1),0}}},ye=e=>{if(typeof e!=`string`)return e;var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(t===void 0)throw Error(`Unknown file open mode: ${e}`);return t},be=e=>(typeof e==`string`&&(e=J(e,!0)),e.subarray||(e=new Uint8Array(e)),e),xe=(e,t)=>{var n=0;return e&&(n|=365),t&&(n|=146),n},Se=async e=>{var t=await d(e);return new Uint8Array(t)},Ce=(...e)=>Q.createDataFile(...e),Z=e=>e,we=null,Te=async()=>we,Ee=0,De=null,Oe=e=>{Ee--,n.monitorRunDependencies?.(Ee),Ee||De()},ke=e=>{Ee||(we=new Promise(e=>De=e)),Ee++,n.monitorRunDependencies?.(Ee)},Ae=[],je=async(e,t)=>{typeof Browser<`u`&&Browser.init();for(var n of Ae)if(n.canHandle(t))return n.handle(e,t);return e},Me=async(e,t,n,r,i,a,o,s)=>{var c=t?K.resolve(G.join2(e,t)):e,l=Z(`cp ${c}`);ke(l);try{var u=n;typeof n==`string`&&(u=await Se(n)),u=await je(u,c),s?.(),a||Ce(e,t,u,r,i,o)}finally{Oe(l)}},Ne=(e,t,n,r,i,a,o,s,c,l)=>{Me(e,t,n,r,i,s,c,l).then(a).catch(o)},Q={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:`/`,initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,ErrnoError:class{name=`ErrnoError`;constructor(e){this.errno=e}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!=1}get isWrite(){return!!(this.flags&2097155)}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,t,n,r){e||=this,this.parent=e,this.mount=e.mount,this.id=Q.nextInode++,this.name=t,this.mode=n,this.rdev=r,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return Q.isDir(this.mode)}get isDevice(){return Q.isChrdev(this.mode)}addListener(e,t=!1){var n={cb:e,exclusive:t},r=this.listeners??=new Set;return r.add(n),{listeners:r,entry:n}}notifyListeners(e){if(this.listeners){var t;for(var n of this.listeners)n.exclusive?(t||=[]).push(n):n.cb(e);if(t){var r=(this.exclTurn||0)%t.length;this.exclTurn=r+1,t[r].cb(e)}}}},lookupPath(e,t={}){if(!e)throw new Q.ErrnoError(44);t.follow_mount??=!0,G.isAbs(e)||(e=Q.cwd()+`/`+e);linkloop:for(var n=0;n<40;n++){for(var r=e.split(`/`).filter(e=>!!e),i=Q.root,a=`/`,o=0;o<r.length;o++){var s=o===r.length-1;if(s&&t.parent)break;if(r[o]!==`.`){if(r[o]===`..`){if(a=G.dirname(a),Q.isRoot(i)){e=a+`/`+r.slice(o+1).join(`/`),n--;continue linkloop}i=i.parent;continue}a=G.join2(a,r[o]);try{i=Q.lookupNode(i,r[o])}catch(e){if(e?.errno===44&&s&&t.noent_okay)return{path:a};throw e}if(Q.isMountpoint(i)&&(!s||t.follow_mount)&&(i=i.mounted.root),Q.isLink(i.mode)&&(!s||t.follow)){if(!i.node_ops.readlink)throw new Q.ErrnoError(52);var c=i.node_ops.readlink(i);G.isAbs(c)||(c=G.dirname(a)+`/`+c),e=c+`/`+r.slice(o+1).join(`/`);continue linkloop}}}return{path:a,node:i}}throw new Q.ErrnoError(32)},getPath(e){for(var t;;){if(Q.isRoot(e)){var n=e.mount.mountpoint;return t?n[n.length-1]===`/`?n+t:`${n}/${t}`:n}t=t?`${e.name}/${t}`:e.name,e=e.parent}},hashName(e,t){for(var n=0,r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r)|0;return(e+n>>>0)%Q.nameTable.length},hashAddNode(e){var t=Q.hashName(e.parent.id,e.name);e.name_next=Q.nameTable[t],Q.nameTable[t]=e},hashRemoveNode(e){var t=Q.hashName(e.parent.id,e.name);if(Q.nameTable[t]===e)Q.nameTable[t]=e.name_next;else for(var n=Q.nameTable[t];n;){if(n.name_next===e){n.name_next=e.name_next;break}n=n.name_next}},lookupNode(e,t){var n=Q.mayLookup(e);if(n)throw new Q.ErrnoError(n);for(var r=Q.hashName(e.id,t),i=Q.nameTable[r];i;i=i.name_next){var a=i.name;if(i.parent.id===e.id&&a===t)return i}return Q.lookup(e,t)},createNode(e,t,n,r){var i=new Q.FSNode(e,t,n,r);return Q.hashAddNode(i),i},destroyNode(e){Q.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)==32768},isDir(e){return(e&61440)==16384},isLink(e){return(e&61440)==40960},isChrdev(e){return(e&61440)==8192},isBlkdev(e){return(e&61440)==24576},isFIFO(e){return(e&61440)==4096},isSocket(e){return(e&49152)==49152},flagsToPermissionString(e){var t=[`r`,`w`,`rw`][e&3];return e&512&&(t+=`w`),t},nodePermissions(e,t){return Q.ignorePermissions?0:t.includes(`r`)&&!(e.mode&292)||t.includes(`w`)&&!(e.mode&146)||t.includes(`x`)&&!(e.mode&73)?2:0},mayLookup(e){return Q.isDir(e.mode)?Q.nodePermissions(e,`x`)||(e.node_ops.lookup?0:2):54},mayCreate(e,t){if(!Q.isDir(e.mode))return 54;try{return Q.lookupNode(e,t),20}catch{}return Q.nodePermissions(e,`wx`)},mayDelete(e,t,n){var r;try{r=Q.lookupNode(e,t)}catch(e){return e.errno}var i=Q.nodePermissions(e,`wx`);if(i)return i;if(n){if(!Q.isDir(r.mode))return 54;if(Q.isRoot(r)||Q.getPath(r)===Q.cwd())return 10}else if(Q.isDir(r.mode))return 31;return 0},mayOpen(e,t){if(!e)return 44;if(Q.isLink(e.mode))return 32;var n=Q.flagsToPermissionString(t);return Q.isDir(e.mode)&&(n!==`r`||t&576)?31:Q.nodePermissions(e,n)},checkOpExists(e,t){if(!e)throw new Q.ErrnoError(t);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=Q.MAX_OPEN_FDS;e++)if(!Q.streams[e])return e;throw new Q.ErrnoError(33)},getStreamChecked(e){var t=Q.getStream(e);if(!t)throw new Q.ErrnoError(8);return t},getStream:e=>Q.streams[e],createStream(e,t=-1){return e=Object.assign(new Q.FSStream,e),t==-1&&(t=Q.nextfd()),e.fd=t,Q.streams[t]=e,e},closeStream(e){Q.streams[e]=null},dupStream(e,t=-1){var n=Q.createStream(e,t);return n.stream_ops?.dup?.(n),n},doSetAttr(e,t,n){var r=e?.stream_ops.setattr,i=r?e:t;r??=t.node_ops.setattr,Q.checkOpExists(r,63);try{r(i,n)}catch(e){throw e instanceof RangeError?new Q.ErrnoError(22):e}},chrdev_stream_ops:{open(e){e.stream_ops=Q.getDevice(e.node.rdev).stream_ops,e.stream_ops.open?.(e)},llseek(){throw new Q.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,t)=>e<<8|t,registerDevice(e,t){Q.devices[e]={stream_ops:t}},getDevice:e=>Q.devices[e],getMounts(e){for(var t=[],n=[e];n.length;){var r=n.pop();t.push(r),n.push(...r.mounts)}return t},syncfs(e,t){typeof e==`function`&&(t=e,e=!1),Q.syncFSRequests++,Q.syncFSRequests>1&&m(`warning: ${Q.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var n=Q.getMounts(Q.root.mount),r=0;function i(e){return Q.syncFSRequests--,t(e)}function a(e){if(e)return a.errored?void 0:(a.errored=!0,i(e));++r>=n.length&&i(null)}for(var o of n)o.type.syncfs?o.type.syncfs(o,e,a):a(null)},mount(e,t,n){var r=n===`/`,i=!n,a;if(r&&Q.root)throw new Q.ErrnoError(10);if(!r&&!i){var o=Q.lookupPath(n,{follow_mount:!1});if(n=o.path,a=o.node,Q.isMountpoint(a))throw new Q.ErrnoError(10);if(!Q.isDir(a.mode))throw new Q.ErrnoError(54)}var s={type:e,opts:t,mountpoint:n,mounts:[]},c=e.mount(s);return c.mount=s,s.root=c,r?Q.root=c:a&&(a.mounted=s,a.mount&&a.mount.mounts.push(s)),c},unmount(e){var t=Q.lookupPath(e,{follow_mount:!1});if(!Q.isMountpoint(t.node))throw new Q.ErrnoError(28);var n=t.node,r=n.mounted,i=Q.getMounts(r);for(var[a,o]of Object.entries(Q.nameTable))for(;o;){var s=o.name_next;i.includes(o.mount)&&Q.destroyNode(o),o=s}n.mounted=null;var c=n.mount.mounts.indexOf(r);n.mount.mounts.splice(c,1)},lookup(e,t){return e.node_ops.lookup(e,t)},mknod(e,t,n){var r=Q.lookupPath(e,{parent:!0}).node,i=G.basename(e);if(!i)throw new Q.ErrnoError(28);if(i===`.`||i===`..`)throw new Q.ErrnoError(20);var a=Q.mayCreate(r,i);if(a)throw new Q.ErrnoError(a);if(!r.node_ops.mknod)throw new Q.ErrnoError(63);return r.node_ops.mknod(r,i,t,n)},statfs(e){return Q.statfsNode(Q.lookupPath(e,{follow:!0}).node)},statfsStream(e){return Q.statfsNode(e.node)},statfsNode(e){var t={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:Q.nextInode,ffree:Q.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(t,e.node_ops.statfs(e.mount.opts.root)),t},create(e,t=438){return t&=4095,t|=32768,Q.mknod(e,t,0)},mkdir(e,t=511){return t&=1023,t|=16384,Q.mknod(e,t,0)},mkdirTree(e,t){var n=e.split(`/`),r=``;for(var i of n)if(i){(r||G.isAbs(e))&&(r+=`/`),r+=i;try{Q.mkdir(r,t)}catch(e){if(e.errno!=20)throw e}}},mkdev(e,t,n){return n===void 0&&(n=t,t=438),t|=8192,Q.mknod(e,t,n)},symlink(e,t){if(!K.resolve(e))throw new Q.ErrnoError(44);var n=Q.lookupPath(t,{parent:!0}).node;if(!n)throw new Q.ErrnoError(44);var r=G.basename(t),i=Q.mayCreate(n,r);if(i)throw new Q.ErrnoError(i);if(!n.node_ops.symlink)throw new Q.ErrnoError(63);return n.node_ops.symlink(n,r,e)},link(e,t,n){var r=Q.lookupPath(t,{parent:!0}).node;if(!r)throw new Q.ErrnoError(44);var i=G.basename(t),a=Q.mayCreate(r,i);if(a)throw new Q.ErrnoError(a);if(!r.node_ops.link)throw new Q.ErrnoError(34);return r.node_ops.link(r,i,e,n)},rename(e,t){var n=G.dirname(e),r=G.dirname(t),i=G.basename(e),a=G.basename(t),o=Q.lookupPath(e,{parent:!0}),s=o.node,c;if(o=Q.lookupPath(t,{parent:!0}),c=o.node,!s||!c)throw new Q.ErrnoError(44);if(s.mount!==c.mount)throw new Q.ErrnoError(75);var l=Q.lookupNode(s,i),u=K.relative(e,r);if(u.charAt(0)!==`.`)throw new Q.ErrnoError(28);if(u=K.relative(t,n),u.charAt(0)!==`.`)throw new Q.ErrnoError(55);var d;try{d=Q.lookupNode(c,a)}catch{}if(l!==d){var f=Q.isDir(l.mode),p=Q.mayDelete(s,i,f);if(p||(p=d?Q.mayDelete(c,a,f):Q.mayCreate(c,a),p))throw new Q.ErrnoError(p);if(!s.node_ops.rename)throw new Q.ErrnoError(63);if(Q.isMountpoint(l)||d&&Q.isMountpoint(d))throw new Q.ErrnoError(10);if(c!==s&&(p=Q.nodePermissions(s,`w`),p))throw new Q.ErrnoError(p);Q.hashRemoveNode(l);try{s.node_ops.rename(l,c,a),l.parent=c}catch(e){throw e}finally{Q.hashAddNode(l)}}},rmdir(e){var t=Q.lookupPath(e,{parent:!0}).node,n=G.basename(e),r=Q.lookupNode(t,n),i=Q.mayDelete(t,n,!0);if(i)throw new Q.ErrnoError(i);if(!t.node_ops.rmdir)throw new Q.ErrnoError(63);if(Q.isMountpoint(r))throw new Q.ErrnoError(10);t.node_ops.rmdir(t,n),Q.destroyNode(r)},readdir(e){var t=Q.lookupPath(e,{follow:!0}).node;return Q.checkOpExists(t.node_ops.readdir,54)(t)},unlink(e){var t=Q.lookupPath(e,{parent:!0}).node;if(!t)throw new Q.ErrnoError(44);var n=G.basename(e),r=Q.lookupNode(t,n),i=Q.mayDelete(t,n,!1);if(i)throw new Q.ErrnoError(i);if(!t.node_ops.unlink)throw new Q.ErrnoError(63);if(Q.isMountpoint(r))throw new Q.ErrnoError(10);t.node_ops.unlink(t,n),Q.destroyNode(r)},readlink(e){var t=Q.lookupPath(e).node;if(!t)throw new Q.ErrnoError(44);if(!t.node_ops.readlink)throw new Q.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,t){var n=Q.lookupPath(e,{follow:!t}).node;return Q.checkOpExists(n.node_ops.getattr,63)(n)},fstat(e){var t=Q.getStreamChecked(e),n=t.node,r=t.stream_ops.getattr,i=r?t:n;return r??=n.node_ops.getattr,Q.checkOpExists(r,63),r(i)},lstat(e){return Q.stat(e,!0)},doChmod(e,t,n,r){Q.doSetAttr(e,t,{mode:n&4095|t.mode&-4096,ctime:Date.now(),dontFollow:r})},chmod(e,t,n){var r=typeof e==`string`?Q.lookupPath(e,{follow:!n}).node:e;Q.doChmod(null,r,t,n)},lchmod(e,t){Q.chmod(e,t,!0)},fchmod(e,t){var n=Q.getStreamChecked(e);Q.doChmod(n,n.node,t,!1)},doChown(e,t,n){Q.doSetAttr(e,t,{timestamp:Date.now(),dontFollow:n})},chown(e,t,n,r){var i=typeof e==`string`?Q.lookupPath(e,{follow:!r}).node:e;Q.doChown(null,i,r)},lchown(e,t,n){Q.chown(e,t,n,!0)},fchown(e,t,n){var r=Q.getStreamChecked(e);Q.doChown(r,r.node,!1)},doTruncate(e,t,n){if(Q.isDir(t.mode))throw new Q.ErrnoError(31);if(!Q.isFile(t.mode))throw new Q.ErrnoError(28);var r=Q.nodePermissions(t,`w`);if(r)throw new Q.ErrnoError(r);Q.doSetAttr(e,t,{size:n,timestamp:Date.now()})},truncate(e,t){if(t<0)throw new Q.ErrnoError(28);var n=typeof e==`string`?Q.lookupPath(e,{follow:!0}).node:e;Q.doTruncate(null,n,t)},ftruncate(e,t){var n=Q.getStreamChecked(e);if(t<0||!(n.flags&2097155))throw new Q.ErrnoError(28);Q.doTruncate(n,n.node,t)},utime(e,t,n,r){var i=Q.lookupPath(e,{follow:!r});Q.doSetAttr(null,i.node,{atime:t,mtime:n,dontFollow:r})},open(e,t,n=438){if(e===``)throw new Q.ErrnoError(44);t=ye(t),n=t&64?n&4095|32768:0;var r,i;if(typeof e==`object`)r=e;else{i=e.endsWith(`/`);var a=Q.lookupPath(e,{follow:!(t&131072),noent_okay:!0});r=a.node,e=a.path}var o=!1;if(t&64){if(r){if(t&128)throw new Q.ErrnoError(20)}else if(i)throw new Q.ErrnoError(31);else r=Q.mknod(e,n|511,0),o=!0}if(!r)throw new Q.ErrnoError(44);if(Q.isChrdev(r.mode)&&(t&=-513),t&65536&&!Q.isDir(r.mode))throw new Q.ErrnoError(54);if(!o){var s=Q.mayOpen(r,t);if(s)throw new Q.ErrnoError(s)}t&512&&!o&&Q.truncate(r,0),t&=-131713;var c=Q.createStream({node:r,path:Q.getPath(r),flags:t,seekable:!0,position:0,stream_ops:r.stream_ops,ungotten:[],error:!1});return c.stream_ops.open&&c.stream_ops.open(c),o&&Q.chmod(r,n&511),c},close(e){if(Q.isClosed(e))throw new Q.ErrnoError(8);e.getdents&&=null,e.node?.notifyListeners(32);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{Q.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,t,n){if(Q.isClosed(e))throw new Q.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new Q.ErrnoError(70);if(n!=0&&n!=1&&n!=2)throw new Q.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,n),e.ungotten=[],e.position},read(e,t,n,r,i){if(r<0||i<0)throw new Q.ErrnoError(28);if(Q.isClosed(e)||(e.flags&2097155)==1)throw new Q.ErrnoError(8);if(Q.isDir(e.node.mode))throw new Q.ErrnoError(31);if(!e.stream_ops.read)throw new Q.ErrnoError(28);var a=i!==void 0;if(!a)i=e.position;else if(!e.seekable)throw new Q.ErrnoError(70);var o=e.stream_ops.read(e,t,n,r,i);return a||(e.position+=o),o},write(e,t,n,r,i,a){if(r<0||i<0)throw new Q.ErrnoError(28);if(Q.isClosed(e)||!(e.flags&2097155))throw new Q.ErrnoError(8);if(Q.isDir(e.node.mode))throw new Q.ErrnoError(31);if(!e.stream_ops.write)throw new Q.ErrnoError(28);e.seekable&&e.flags&1024&&Q.llseek(e,0,2);var o=i!==void 0;if(!o)i=e.position;else if(!e.seekable)throw new Q.ErrnoError(70);var s=e.stream_ops.write(e,t,n,r,i,a);return o||(e.position+=s),s},mmap(e,t,n,r,i){if(r&2&&!(i&2)&&(e.flags&2097155)!=2||(e.flags&2097155)==1)throw new Q.ErrnoError(2);if(!e.stream_ops.mmap)throw new Q.ErrnoError(43);if(!t)throw new Q.ErrnoError(28);return e.stream_ops.mmap(e,t,n,r,i)},msync(e,t,n,r,i){return e.stream_ops.msync?e.stream_ops.msync(e,t,n,r,i):0},ioctl(e,t,n){if(!e.stream_ops.ioctl)throw new Q.ErrnoError(59);return e.stream_ops.ioctl(e,t,n)},readFile(e,t={}){t.flags=t.flags??0,t.encoding=t.encoding??`binary`,t.encoding!==`utf8`&&t.encoding!==`binary`&&w(`Invalid encoding type "${t.encoding}"`);var n=Q.open(e,t.flags),r=Q.stat(e).size,i=new Uint8Array(r);return Q.read(n,i,0,r,0),t.encoding===`utf8`&&(i=pe(i)),Q.close(n),i},writeFile(e,t,n={}){n.flags=n.flags??577;var r=Q.open(e,n.flags,n.mode);t=be(t),Q.write(r,t,0,t.byteLength,void 0,n.canOwn),Q.close(r)},cwd:()=>Q.currentPath,chdir(e){var t=Q.lookupPath(e,{follow:!0});if(t.node===null)throw new Q.ErrnoError(44);if(!Q.isDir(t.node.mode))throw new Q.ErrnoError(54);var n=Q.nodePermissions(t.node,`x`);if(n)throw new Q.ErrnoError(n);Q.currentPath=t.path},createDefaultDirectories(){Q.mkdir(`/tmp`),Q.mkdir(`/home`),Q.mkdir(`/home/web_user`)},createDefaultDevices(){Q.mkdir(`/dev`),Q.registerDevice(Q.makedev(1,3),{read:()=>0,write:(e,t,n,r,i)=>r,llseek:()=>0}),Q.mkdev(`/dev/null`,Q.makedev(1,3)),Y.register(Q.makedev(5,0),Y.default_tty_ops),Y.register(Q.makedev(6,0),Y.default_tty1_ops),Q.mkdev(`/dev/tty`,Q.makedev(5,0)),Q.mkdev(`/dev/tty1`,Q.makedev(6,0));var e=new Uint8Array(1024),t=0,n=()=>(t===0&&(de(e),t=e.byteLength),e[--t]);Q.createDevice(`/dev`,`random`,n),Q.createDevice(`/dev`,`urandom`,n),Q.mkdir(`/dev/shm`),Q.mkdir(`/dev/shm/tmp`)},createSpecialDirectories(){Q.mkdir(`/proc`);var e=Q.mkdir(`/proc/self`);Q.mkdir(`/proc/self/fd`),Q.mount({mount(){var t=Q.createNode(e,`fd`,16895,73);return t.stream_ops={llseek:X.stream_ops.llseek},t.node_ops={lookup(e,t){var n=+t,r=Q.getStreamChecked(n),i={parent:null,mount:{mountpoint:`fake`},node_ops:{readlink:()=>r.path},id:n+1};return i.parent=i,i},readdir(){return Array.from(Q.streams.entries()).filter(([e,t])=>t).map(([e,t])=>e.toString())}},t}},{},`/proc/self/fd`)},createStandardStreams(e,t,n){e?Q.createDevice(`/dev`,`stdin`,e):Q.symlink(`/dev/tty`,`/dev/stdin`),t?Q.createDevice(`/dev`,`stdout`,null,t):Q.symlink(`/dev/tty`,`/dev/stdout`),n?Q.createDevice(`/dev`,`stderr`,null,n):Q.symlink(`/dev/tty1`,`/dev/stderr`),Q.open(`/dev/stdin`,0),Q.open(`/dev/stdout`,1),Q.open(`/dev/stderr`,1)},staticInit(){Q.nameTable=Array(4096),Q.mount(X,{},`/`),Q.createDefaultDirectories(),Q.createDefaultDevices(),Q.createSpecialDirectories(),Q.filesystems={MEMFS:X}},init(e,t,r){Q.initialized=!0,e??=n.stdin,t??=n.stdout,r??=n.stderr,Q.createStandardStreams(e,t,r)},quit(){Q.initialized=!1;for(var e of Q.streams)e&&Q.close(e)},findObject(e,t){var n=Q.analyzePath(e,t);return n.exists?n.object:null},analyzePath(e,t){try{var n=Q.lookupPath(e,{follow:!t});e=n.path}catch{}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=Q.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=n.path,r.parentObject=n.node,r.name=G.basename(e),n=Q.lookupPath(e,{follow:!t}),r.exists=!0,r.path=n.path,r.object=n.node,r.name=n.node.name,r.isRoot=n.path===`/`}catch(e){r.error=e.errno}return r},createPath(e,t,n,r){e=typeof e==`string`?e:Q.getPath(e);for(var i=t.split(`/`).reverse();i.length;){var a=i.pop();if(a){var o=G.join2(e,a);try{Q.mkdir(o)}catch(e){if(e.errno!=20)throw e}e=o}}return o},createFile(e,t,n,r,i){var a=G.join2(typeof e==`string`?e:Q.getPath(e),t),o=xe(r,i);return Q.create(a,o)},createDataFile(e,t,n,r,i,a){var o=t;e&&(e=typeof e==`string`?e:Q.getPath(e),o=t?G.join2(e,t):e);var s=xe(r,i),c=Q.create(o,s);if(n){n=be(n),Q.chmod(c,s|146);var l=Q.open(c,577);Q.write(l,n,0,n.length,0,a),Q.close(l),Q.chmod(c,s)}},createDevice(e,t,n,r){var i=G.join2(typeof e==`string`?e:Q.getPath(e),t),a=xe(!!n,!!r);Q.createDevice.major??=64;var o=Q.makedev(Q.createDevice.major++,0);return Q.registerDevice(o,{open(e){e.seekable=!1},close(e){r?.buffer?.length&&r(10)},read(e,t,r,i,a){for(var o=0,s=0;s<i;s++){var c;try{c=n()}catch{throw new Q.ErrnoError(29)}if(c===void 0&&o===0)throw new Q.ErrnoError(6);if(c==null)break;o++,t[r+s]=c}return o&&(e.node.atime=Date.now()),o},write(e,t,n,i,a){for(var o=0;o<i;o++)try{r(t[n+o])}catch{throw new Q.ErrnoError(29)}return i&&(e.node.mtime=e.node.ctime=Date.now()),o}}),Q.mkdev(i,a,o)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)w(`Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.`);else try{e.contents=f(e.url)}catch{throw new Q.ErrnoError(29)}},createLazyFile(e,t,n,r,a){class o{lengthKnown=!1;chunks=[];get(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,n=e/this.chunkSize|0;return this.getter(n)[t]}}setDataGetter(e){this.getter=e}cacheLength(){var e=new XMLHttpRequest;e.open(`HEAD`,n,!1),e.send(null),e.status>=200&&e.status<300||e.status===304||w(`Couldn't load `+n+`. Status: `+e.status);var t=Number(e.getResponseHeader(`Content-length`)),r,i=(r=e.getResponseHeader(`Accept-Ranges`))&&r===`bytes`,a=(r=e.getResponseHeader(`Content-Encoding`))&&r===`gzip`,o=1048576;i||(o=t);var s=(e,r)=>{e>r&&w(`invalid range (${e}, ${r}) or no bytes requested!`),r>t-1&&w(`only ${t} bytes available! programmer error!`);var i=new XMLHttpRequest;return i.open(`GET`,n,!1),t!==o&&i.setRequestHeader(`Range`,`bytes=`+e+`-`+r),i.responseType=`arraybuffer`,i.overrideMimeType&&i.overrideMimeType(`text/plain; charset=x-user-defined`),i.send(null),i.status>=200&&i.status<300||i.status===304||w(`Couldn't load `+n+`. Status: `+i.status),i.response===void 0?J(i.responseText??``,!0):new Uint8Array(i.response||[])},c=this;c.setDataGetter(e=>{var n=e*o,r=(e+1)*o-1;return r=Math.min(r,t-1),c.chunks[e]===void 0&&(c.chunks[e]=s(n,r)),c.chunks[e]===void 0&&w(`doXHR failed!`),c.chunks[e]}),(a||!t)&&(o=t=1,t=this.getter(0).length,o=t,p(`LazyFiles on gzip forces download of the whole file when length is accessed`)),this._length=t,this._chunkSize=o,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){i||w(`Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc`);var s={isDevice:!1,contents:new o}}else var s={isDevice:!1,url:n};var c=Q.createFile(e,t,s,r,a);s.contents?c.contents=s.contents:s.url&&(c.contents=null,c.url=s.url),Object.defineProperties(c,{usedBytes:{get:function(){return this.contents.length}}});var l={};for(let[e,t]of Object.entries(c.stream_ops))l[e]=(...e)=>(Q.forceLoadFile(c),t(...e));function u(e,t,n,r,i){var a=e.node.contents;if(i>=a.length)return 0;var o=Math.min(a.length-i,r);if(a.slice)for(var s=0;s<o;s++)t[n+s]=a[i+s];else for(var s=0;s<o;s++)t[n+s]=a.get(i+s);return o}return l.read=(e,t,n,r,i)=>(Q.forceLoadFile(c),u(e,t,n,r,i)),l.mmap=(e,t,n,r,i)=>{Q.forceLoadFile(c);var a=ve(t);if(!a)throw new Q.ErrnoError(48);return u(e,I,a,t,n),{ptr:a,allocated:!0}},c.stream_ops=l,c}},Pe=(e,t,n)=>e?pe(B,e,t,n):``,$={currentUmask:18,calculateAt(e,t,n){if(G.isAbs(t))return t;var r=e===-100?Q.cwd():$.getStreamFromFD(e).path;if(t.length==0){if(!n)throw new Q.ErrnoError(44);return r}return r+`/`+t},writeStat(e,t){z[e>>2]=t.dev,z[e+4>>2]=t.mode,z[e+8>>2]=t.nlink,z[e+12>>2]=t.uid,z[e+16>>2]=t.gid,z[e+20>>2]=t.rdev,F[e+24>>3]=BigInt(t.size),P[e+32>>2]=4096,P[e+36>>2]=t.blocks;var n=t.atime.getTime(),r=t.mtime.getTime(),i=t.ctime.getTime();return F[e+40>>3]=BigInt(Math.floor(n/1e3)),z[e+48>>2]=n%1e3*1e3*1e3,F[e+56>>3]=BigInt(Math.floor(r/1e3)),z[e+64>>2]=r%1e3*1e3*1e3,F[e+72>>3]=BigInt(Math.floor(i/1e3)),z[e+80>>2]=i%1e3*1e3*1e3,F[e+88>>3]=BigInt(t.ino),0},writeStatFs(e,t){z[e+4>>2]=t.bsize,z[e+60>>2]=t.bsize,F[e+8>>3]=BigInt(t.blocks),F[e+16>>3]=BigInt(t.bfree),F[e+24>>3]=BigInt(t.bavail),F[e+32>>3]=BigInt(t.files),F[e+40>>3]=BigInt(t.ffree),z[e+48>>2]=t.fsid,z[e+64>>2]=t.flags,z[e+56>>2]=t.namelen},doMsync(e,t,n,r,i){if(!Q.isFile(t.node.mode))throw new Q.ErrnoError(43);if(r&2)return 0;var a=B.subarray(e,e+n);Q.msync(t,a,i,n,r)},getStreamFromFD(e){return Q.getStreamChecked(e)},varargs:void 0,getStr(e){return Pe(e)}};function Fe(e,t,n){$.varargs=n;try{var r=$.getStreamFromFD(e);switch(t){case 0:var i=le();if(i<0)return-28;for(;Q.streams[i];)i++;return Q.dupStream(r,i).fd;case 1:case 2:return 0;case 3:return r.flags;case 4:var i=le(),a=289792;return r.flags=r.flags&~a|i&a,0;case 12:var i=W(),o=0;return N[i+o>>1]=2,0;case 13:case 14:return 0}return-28}catch(e){if(Q===void 0||e.name!==`ErrnoError`)throw e;return-e.errno}}function Ie(e,t,n){$.varargs=n;try{var r=$.getStreamFromFD(e);switch(t){case 21509:return r.tty?0:-59;case 21505:if(!r.tty)return-59;if(r.tty.ops.ioctl_tcgets){var i=r.tty.ops.ioctl_tcgets(r),a=W();P[a>>2]=i.c_iflag||0,P[a+4>>2]=i.c_oflag||0,P[a+8>>2]=i.c_cflag||0,P[a+12>>2]=i.c_lflag||0;for(var o=0;o<32;o++)I[a+o+17]=i.c_cc[o]||0;return 0}return 0;case 21510:case 21511:case 21512:return r.tty?0:-59;case 21506:case 21507:case 21508:if(!r.tty)return-59;if(r.tty.ops.ioctl_tcsets){for(var a=W(),s=P[a>>2],c=P[a+4>>2],l=P[a+8>>2],u=P[a+12>>2],d=[],o=0;o<32;o++)d.push(I[a+o+17]);return r.tty.ops.ioctl_tcsets(r.tty,t,{c_iflag:s,c_oflag:c,c_cflag:l,c_lflag:u,c_cc:d})}return 0;case 21519:if(!r.tty)return-59;var a=W();return P[a>>2]=0,0;case 21520:return r.tty?-28:-59;case 21537:case 21531:var a=W();return Q.ioctl(r,t,a);case 21523:if(!r.tty)return-59;if(r.tty.ops.ioctl_tiocgwinsz){var f=r.tty.ops.ioctl_tiocgwinsz(r.tty),a=W();N[a>>1]=f[0],N[a+2>>1]=f[1]}return 0;case 21524:return r.tty?0:-59;case 21515:return r.tty?0:-59;default:return-28}}catch(e){if(Q===void 0||e.name!==`ErrnoError`)throw e;return-e.errno}}function Le(e,t,n,r){$.varargs=r;try{t=$.getStr(t),t=$.calculateAt(e,t);var i=r?le():0;return n&64&&(i&=~$.currentUmask),Q.open(t,n,i).fd}catch(e){if(Q===void 0||e.name!==`ErrnoError`)throw e;return-e.errno}}var Re=()=>w(``),ze=0,Be=()=>{H=!1,ze=0},Ve={},He=e=>{if(e instanceof M||e==`unwind`)return _;c(1,e)},Ue=()=>H||ze>0,We=e=>{_=e,Ue()||(n.onExit?.(e),g=!0),c(e,new M(e))},Ge=(e,t)=>{_=e,We(e)},Ke=()=>{if(!Ue())try{Ge(_)}catch(e){He(e)}},qe=e=>{if(!g)try{return e()}catch(e){He(e)}finally{Ke()}},Je=()=>performance.now(),Ye=(e,t)=>(Ve[e]&&(clearTimeout(Ve[e].id),delete Ve[e]),t&&(Ve[e]={id:setTimeout(()=>{delete Ve[e],qe(()=>qt(e,Je()))},t),timeout_ms:t}),0),Xe=(e,t,n)=>ge(e,B,t,n),Ze=(e,t,n,r)=>{var i=new Date().getFullYear(),a=new Date(i,0,1),o=new Date(i,6,1),s=a.getTimezoneOffset(),c=o.getTimezoneOffset(),l=Math.max(s,c);z[e>>2]=l*60,P[t>>2]=Number(s!=c);var u=e=>{var t=e>=0?`-`:`+`,n=Math.abs(e);return`UTC${t}${String(Math.floor(n/60)).padStart(2,`0`)}${String(n%60).padStart(2,`0`)}`},d=u(s),f=u(c);c<s?(Xe(d,n,17),Xe(f,r,17)):(Xe(d,r,17),Xe(f,n,17))},Qe=()=>Date.now(),$e=1,et=e=>e>=0&&e<=3,tt=9007199254740992,nt=-9007199254740992,rt=e=>e<nt||e>tt?NaN:Number(e);function it(e,t,n){if(t=rt(t),!et(e))return 28;var r;if(e===0)r=Qe();else if($e)r=Je();else return 52;var i=Math.round(r*1e3*1e3);return F[n>>3]=BigInt(i),0}var at=()=>2147483648,ot=(e,t)=>Math.ceil(e/t)*t,st=e=>{var t=(e-Zt.buffer.byteLength+65535)/65536|0;try{return Zt.grow(t),b(),1}catch{}},ct=e=>{var t=B.length;e>>>=0;var n=at();if(e>n)return!1;for(var r=1;r<=4;r*=2){var i=t*(1+.2/r);if(i=Math.min(i,e+100663296),st(Math.min(n,ot(Math.max(e,i),65536))))return!0}return!1},lt={},ut=()=>s,dt=()=>{if(!dt.strings){var e={USER:`web_user`,LOGNAME:`web_user`,PATH:`/`,PWD:`/`,HOME:`/home/web_user`,LANG:(globalThis.navigator?.language??`C`).replace(`-`,`_`)+`.UTF-8`,_:ut()};for(var t in lt)lt[t]===void 0?delete e[t]:e[t]=lt[t];var n=[];for(var t in e)n.push(`${t}=${e[t]}`);dt.strings=n}return dt.strings},ft=(e,t)=>{var n=0,r=0;for(var i of dt()){var a=t+n;z[e+r>>2]=a,n+=Xe(i,a,1/0)+1,r+=4}return 0},pt=(e,t)=>{var n=dt();z[e>>2]=n.length;var r=0;for(var i of n)r+=he(i)+1;return z[t>>2]=r,0};function mt(e){try{var t=$.getStreamFromFD(e);return Q.close(t),0}catch(e){if(Q===void 0||e.name!==`ErrnoError`)throw e;return e.errno}}var ht=(e,t,n,r)=>{for(var i=0,a=0;a<n;a++){var o=z[t>>2],s=z[t+4>>2];t+=8;try{var c=Q.read(e,I,o,s,r)}catch(e){if(i>0&&e instanceof Q.ErrnoError&&(e.errno==6||e.errno==6))break;throw e}if(c<0)return-1;if(i+=c,c<s)break;r!==void 0&&(r+=c)}return i};function gt(e,t,n,r){try{var i=ht($.getStreamFromFD(e),t,n);return z[r>>2]=i,0}catch(e){if(Q===void 0||e.name!==`ErrnoError`)throw e;return e.errno}}function _t(e,t,n,r){t=rt(t);try{if(isNaN(t))return 22;var i=$.getStreamFromFD(e);return Q.llseek(i,t,n),F[r>>3]=BigInt(i.position),i.getdents&&t===0&&n===0&&(i.getdents=null),0}catch(e){if(Q===void 0||e.name!==`ErrnoError`)throw e;return e.errno}}var vt=(e,t,n,r)=>{if(n==1)return Q.write(e,I,z[t>>2],z[t+4>>2],r);for(var i=0,a=0,o=t;a<n;a++,o+=8)i+=z[o+4>>2];for(var s=new Uint8Array(i),c=0,a=0;a<n;a++,t+=8){var l=z[t>>2],u=z[t+4>>2];s.set(B.subarray(l,l+u),c),c+=u}return Q.write(e,s,0,i,r)};function yt(e,t,n,r){try{var i=vt($.getStreamFromFD(e),t,n);return z[r>>2]=i,0}catch(e){if(Q===void 0||e.name!==`ErrnoError`)throw e;return e.errno}}var bt=e=>n[`_`+e],xt=(e,t)=>{I.set(e,t)},St=e=>Yt(e),Ct=e=>{var t=he(e)+1,n=St(t);return Xe(e,n,t),n},wt=(e,t,n,r,i)=>{var a={string:e=>{var t=0;return e!=null&&e!==0&&(t=Ct(e)),t},array:e=>{var t=St(e.length);return xt(e,t),t}};function o(e){return t===`string`?Pe(e):t===`boolean`?!!e:e}var s=bt(e),c=[],l=0;if(r)for(var u=0;u<r.length;u++){var d=a[n[u]];d?(l===0&&(l=ae()),c[u]=d(r[u])):c[u]=r[u]}var f=s(...c);function p(e){return l!==0&&U(l),o(e)}return f=p(f),f},Tt=(e,t,n,r)=>{var i=!n||n.every(e=>e===`number`||e===`boolean`);return t!==`string`&&i&&!r?bt(e):(...i)=>wt(e,t,n,i,r)},Et=[],Dt=e=>{var t=Et[e];return t||(Et[e]=t=Qt.get(e)),t},Ot=(e,t)=>{if(kt)for(var n=e;n<e+t;n++){var r=Dt(n);r&&kt.set(r,n)}},kt,At=e=>(kt||(kt=new WeakMap,Ot(0,Qt.length)),kt.get(e)||0),jt=[],Mt=()=>jt.length?jt.pop():Qt.grow(1),Nt=(e,t)=>{Qt.set(e,t),Et[e]=Qt.get(e)},Pt=e=>{let t=e.length;return[t%128|128,t>>7,...e]},Ft={i:127,p:127,j:126,f:125,d:124,e:111},It=e=>Pt(Array.from(e,e=>Ft[e])),Lt=(e,t)=>{var n=Uint8Array.of(0,97,115,109,1,0,0,0,1,...Pt([1,96,...It(t.slice(1)),...It(t[0]===`v`?``:t[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),r=new WebAssembly.Module(n);return new WebAssembly.Instance(r,{e:{f:e}}).exports.f},Rt=(e,t)=>{var n=At(e);if(n)return n;var r=Mt();try{Nt(r,e)}catch(n){if(!(n instanceof TypeError))throw n;Nt(r,Lt(e,t))}return kt.set(e,r),r},zt=e=>{kt.delete(Dt(e)),Nt(e,null),jt.push(e)};Q.createPreloadedFile=Ne,Q.preloadFile=Me,Q.staticInit(),n.noExitRuntime&&(H=n.noExitRuntime),n.print&&(p=n.print),n.printErr&&(m=n.printErr),n.arguments&&n.arguments,n.thisProgram&&(s=n.thisProgram);var Bt=n.preInit;if(Bt)for(typeof Bt==`function`&&(n.preInit=Bt=[Bt]);Bt.length>0;)Bt.shift()();n.cwrap=Tt,n.addFunction=Rt,n.removeFunction=zt,n.UTF8ToString=Pe;var Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt;function $t(e){n._Highs_js_getColName=e.w,n._Highs_js_getRowName=e.x,n._Highs_js_getPresolvedColName=e.y,n._Highs_js_getPresolvedRowName=e.z,n._Highs_js_setCallback=e.A,n._Highs_js_getCallbackMipSolutionSize=e.B,n._Highs_lpCall=e.C,n._Highs_mipCall=e.D,n._Highs_qpCall=e.E,Vt=n._Highs_create=e.F,Ht=n._Highs_destroy=e.G,n._Highs_version=e.H,n._Highs_versionMajor=e.I,n._Highs_versionMinor=e.J,n._Highs_versionPatch=e.K,n._Highs_githash=e.L,n._Highs_presolve=e.M,Ut=n._Highs_run=e.N,n._Highs_postsolve=e.O,n._Highs_readModel=e.P,n._Highs_writeModel=e.Q,n._Highs_writePresolvedModel=e.R,n._Highs_writeSolution=e.S,n._Highs_writeSolutionPretty=e.T,n._Highs_passLp=e.U,n._Highs_passMip=e.V,n._Highs_passModel=e.W,n._Highs_passHessian=e.X,n._Highs_passLinearObjectives=e.Y,n._Highs_clearLinearObjectives=e.Z,n._Highs_getNumCol=e._,n._Highs_addLinearObjective=e.$,n._Highs_passRowName=e.aa,n._Highs_passColName=e.ba,n._Highs_passModelName=e.ca,n._Highs_readOptions=e.da,n._Highs_clear=e.ea,n._Highs_clearModel=e.fa,n._Highs_clearSolver=e.ga,n._Highs_releaseMemory=e.ha,n._Highs_setBoolOptionValue=e.ia,n._Highs_setIntOptionValue=e.ja,n._Highs_setDoubleOptionValue=e.ka,n._Highs_setStringOptionValue=e.la,n._Highs_getNumOptions=e.ma,n._Highs_getOptionName=e.na,n._Highs_getBoolOptionValue=e.oa,n._Highs_getBoolOptionValues=e.pa,n._Highs_getIntOptionValue=e.qa,n._Highs_getIntOptionValues=e.ra,n._Highs_getDoubleOptionValue=e.sa,n._Highs_getDoubleOptionValues=e.ta,n._Highs_getStringOptionValue=e.ua,n._Highs_getStringOptionValues=e.va,n._Highs_getOptionType=e.wa,n._Highs_resetOptions=e.xa,n._Highs_writeOptions=e.ya,n._Highs_writeOptionsDeviations=e.za,n._Highs_getIntInfoValue=e.Aa,n._Highs_getDoubleInfoValue=e.Ba,n._Highs_getInt64InfoValue=e.Ca,n._Highs_getInfoType=e.Da,n._Highs_getSolution=e.Ea,n._Highs_getBasis=e.Fa,Wt=n._Highs_getModelStatus=e.Ga,n._Highs_getDualRay=e.Ha,n._Highs_getDualUnboundednessDirection=e.Ia,n._Highs_getPrimalRay=e.Ja,n._Highs_getObjectiveValue=e.Ka,n._Highs_getBasicVariables=e.La,n._Highs_getBasisInverseRow=e.Ma,n._Highs_getBasisInverseCol=e.Na,n._Highs_getBasisSolve=e.Oa,n._Highs_getBasisTransposeSolve=e.Pa,n._Highs_getReducedRow=e.Qa,n._Highs_getReducedColumn=e.Ra,n._Highs_setBasis=e.Sa,n._Highs_getNumRow=e.Ta,n._Highs_setLogicalBasis=e.Ua,n._Highs_setSolution=e.Va,n._Highs_setSparseSolution=e.Wa,n._Highs_setCallback=e.Xa,n._Highs_startCallback=e.Ya,n._Highs_stopCallback=e.Za,n._Highs_getRunTime=e._a,n._Highs_zeroAllClocks=e.$a,n._Highs_addCol=e.ab,n._Highs_addCols=e.bb,n._Highs_addVar=e.cb,n._Highs_addVars=e.db,n._Highs_addRow=e.eb,n._Highs_addRows=e.fb,n._Highs_ensureColwise=e.gb,n._Highs_ensureRowwise=e.hb,n._Highs_changeObjectiveSense=e.ib,n._Highs_changeObjectiveOffset=e.jb,n._Highs_changeColIntegrality=e.kb,n._Highs_changeColsIntegralityByRange=e.lb,n._Highs_changeColsIntegralityBySet=e.mb,n._Highs_changeColsIntegralityByMask=e.nb,n._Highs_clearIntegrality=e.ob,n._Highs_changeColCost=e.pb,n._Highs_changeColsCostByRange=e.qb,n._Highs_changeColsCostBySet=e.rb,n._Highs_changeColsCostByMask=e.sb,n._Highs_changeColBounds=e.tb,n._Highs_changeColsBoundsByRange=e.ub,n._Highs_changeColsBoundsBySet=e.vb,n._Highs_changeColsBoundsByMask=e.wb,n._Highs_changeRowBounds=e.xb,n._Highs_changeRowsBoundsByRange=e.yb,n._Highs_changeRowsBoundsBySet=e.zb,n._Highs_changeRowsBoundsByMask=e.Ab,n._Highs_changeCoeff=e.Bb,n._Highs_getObjectiveSense=e.Cb,n._Highs_getObjectiveOffset=e.Db,n._Highs_getColsByRange=e.Eb,n._Highs_getColsBySet=e.Fb,n._Highs_getColsByMask=e.Gb,n._Highs_getRowsByRange=e.Hb,n._Highs_getRowsBySet=e.Ib,n._Highs_getRowsByMask=e.Jb,n._Highs_getRowName=e.Kb,n._Highs_getRowByName=e.Lb,n._Highs_getColName=e.Mb,n._Highs_getColByName=e.Nb,n._Highs_getColIntegrality=e.Ob,n._Highs_deleteColsByRange=e.Pb,n._Highs_deleteColsBySet=e.Qb,n._Highs_deleteColsByMask=e.Rb,n._Highs_deleteRowsByRange=e.Sb,n._Highs_deleteRowsBySet=e.Tb,n._Highs_deleteRowsByMask=e.Ub,n._Highs_scaleCol=e.Vb,n._Highs_scaleRow=e.Wb,n._Highs_getInfinity=e.Xb,n._Highs_getSizeofHighsInt=e.Yb,n._Highs_getNumNz=e.Zb,n._Highs_getHessianNumNz=e._b,n._Highs_getPresolvedNumCol=e.$b,n._Highs_getPresolvedNumRow=e.ac,n._Highs_getPresolvedNumNz=e.bc,n._Highs_getModel=e.cc,n._Highs_getLp=e.dc,n._Highs_getFixedLp=e.ec,n._Highs_getPresolvedLp=e.fc,n._Highs_getPresolvedColName=e.gc,n._Highs_getPresolvedRowName=e.hc,n._Highs_getIis=e.ic,n._Highs_getIisLp=e.jc,n._Highs_crossover=e.kc,n._Highs_getRanging=e.lc,n._Highs_feasibilityRelaxation=e.mc,n._Highs_getCallbackDataOutItem=e.nc,n._Highs_setCallbackSolution=e.oc,n._Highs_setCallbackSparseSolution=e.pc,n._Highs_repairCallbackSolution=e.qc,n._Highs_call=e.rc,Gt=n._free=e.tc,Kt=n._malloc=e.uc,qt=e.vc,Jt=e.wc,Yt=e.xc,Xt=e.yc,Zt=e.u,Qt=e.sc}var en={a:ce,e:Fe,h:Ie,i:Le,k:Re,s:Be,l:Ye,m:Ze,p:it,j:Qe,c:Je,q:ct,n:ft,o:pt,b:Ge,d:mt,g:gt,t:_t,f:yt,r:We};async function tn(){x(),Ee&&await Te();var e=n.setStatus;e&&(e(`Running...`),await new Promise(e=>setTimeout(e,1)),setTimeout(e,1,``)),!g&&(S(),n.onRuntimeInitialized?.(),C())}var nn=await j();await tn();let rn=0;n.Highs_readModel=n.cwrap(`Highs_readModel`,`number`,[`number`,`string`]);let an=n.cwrap(`Highs_setIntOptionValue`,`number`,[`number`,`string`,`number`]),on=n.cwrap(`Highs_setDoubleOptionValue`,`number`,[`number`,`string`,`number`]),sn=n.cwrap(`Highs_setStringOptionValue`,`number`,[`number`,`string`,`string`]),cn=n.cwrap(`Highs_setBoolOptionValue`,`number`,[`number`,`string`,`number`]),ln=n.cwrap(`Highs_getOptionType`,`number`,[`number`,`string`,`number`]),un=n.cwrap(`Highs_getNumCol`,`number`,[`number`]),dn=n.cwrap(`Highs_getNumRow`,`number`,[`number`]),fn=n.cwrap(`Highs_getObjectiveValue`,`number`,[`number`]),pn=n.cwrap(`Highs_getInfinity`,`number`,[]),mn=n.cwrap(`Highs_getSolution`,`number`,[`number`,`number`,`number`,`number`,`number`]),hn=n.cwrap(`Highs_getBasis`,`number`,[`number`,`number`,`number`]),gn=n.cwrap(`Highs_getColsByRange`,`number`,[`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`]),_n=n.cwrap(`Highs_getRowsByRange`,`number`,[`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`]),vn=n.cwrap(`Highs_getColIntegrality`,`number`,[`number`,`number`,`number`]),yn=n.cwrap(`Highs_js_getColName`,`number`,[`number`,`number`,`number`,`number`,`number`]),bn=n.cwrap(`Highs_js_getRowName`,`number`,[`number`,`number`,`number`,`number`,`number`]),xn={0:`Not Set`,1:`Load error`,2:`Model error`,3:`Presolve error`,4:`Solve error`,5:`Postsolve error`,6:`Empty`,7:`Optimal`,8:`Infeasible`,9:`Primal infeasible or unbounded`,10:`Unbounded`,11:`Bound on objective reached`,12:`Target for objective reached`,13:`Time limit reached`,14:`Iteration limit reached`,15:`Unknown`};var Vt,Ut,Ht,Wt,Q;let Sn={0:`LB`,1:`BS`,2:`UB`,3:`FX`};function Cn(e,t,n){return e===3||e===2&&t===n?`FX`:Sn[e]||``}let wn=new Set([`Not Set`,`Load error`,`Model error`,`Presolve error`,`Solve error`,`Postsolve error`,`Empty`,`Infeasible`,`Unknown`]);n.solve=function(e,t){let r=`highs-model-${++rn}.lp`,i,a=[];function o(e){let t=Kt(e);if(!t)throw Error(`malloc failed`);return a.push(t),t}function s(e,t){let n=o(Int32Array.BYTES_PER_ELEMENT),r=yn(e,t,0,0,n);if(r!==0&&r!==1)return``;let i=P[n>>2];if(i<=0)return``;let s=Kt(i);return a.push(s),r=yn(e,t,s,i,n),r!==0&&r!==1?``:Pe(s)}function c(e,t){let n=o(Int32Array.BYTES_PER_ELEMENT),r=bn(e,t,0,0,n);if(r!==0&&r!==1)return``;let i=P[n>>2];if(i<=0)return``;let s=Kt(i);return a.push(s),r=bn(e,t,s,i,n),r!==0&&r!==1?``:Pe(s)}try{if(Q.writeFile(r,e),i=Vt(),!i)throw Error(`Unable to create the HiGHS solver`);En(()=>n.Highs_readModel(i,r),`read LP model (see http://web.mit.edu/lpsolve/doc/CPLEX-format.htm)`);let a=t||{};for(let e in a){let t=a[e],n=typeof t,r;if(n===`number`)r=Tn;else if(n===`boolean`)r=cn;else if(n===`string`)r=sn;else throw Error(`Unsupported option value type ${t} for '${e}'`);En(()=>r(i,e,t),`set option '${e}'`)}En(()=>Ut(i),`solve the problem`);let l=Wt(i),u=xn[l]||`Unknown`;if(u===`Empty`)return{Columns:{},Rows:[],ObjectiveValue:0,Status:`Empty`};let d=un(i),f=dn(i),p=pn(),m=fn(i);Math.abs(m)>=p*.5&&(m=m>0?1/0:-1/0);let h=d>0?o(d*Float64Array.BYTES_PER_ELEMENT):0,g=d>0?o(d*Float64Array.BYTES_PER_ELEMENT):0,_=f>0?o(f*Float64Array.BYTES_PER_ELEMENT):0,v=f>0?o(f*Float64Array.BYTES_PER_ELEMENT):0;En(()=>mn(i,h,g,_,v),`get solution`);let y=d>0?o(d*Int32Array.BYTES_PER_ELEMENT):0,b=f>0?o(f*Int32Array.BYTES_PER_ELEMENT):0,x=!1,S=hn(i,y,b);(S===0||S===1)&&(x=!0);let C=o(Int32Array.BYTES_PER_ELEMENT),w=d>0?o(d*Float64Array.BYTES_PER_ELEMENT):0,T=d>0?o(d*Float64Array.BYTES_PER_ELEMENT):0,E=d>0?o(d*Float64Array.BYTES_PER_ELEMENT):0;gn(i,0,d-1,C,w,T,E,0,0,0,0);let ee=o(Int32Array.BYTES_PER_ELEMENT),D=f>0?o(f*Float64Array.BYTES_PER_ELEMENT):0,O=f>0?o(f*Float64Array.BYTES_PER_ELEMENT):0;_n(i,0,f-1,ee,D,O,0,0,0,0);let k=o(Int32Array.BYTES_PER_ELEMENT),A=!wn.has(u),j=!1;for(let e=0;e<d&&!j;e++)vn(i,e,k),P[k>>2]!==0&&(j=!0);let M={};for(let e=0;e<d;e++){let t={Index:e,Lower:R[(T>>3)+e],Upper:R[(E>>3)+e]};if(vn(i,e,k),t.Type=P[k>>2]===1?`Integer`:`Continuous`,A&&(t.Primal=R[(h>>3)+e]),x&&A&&!j){let n=P[(y>>2)+e];t.Status=Cn(n,t.Lower,t.Upper),t.Dual=R[(g>>3)+e]}t.Name=s(i,e),M[t.Name]=t}let N=[];for(let e=0;e<f;e++){let t={Index:e,Name:c(i,e),Lower:R[(D>>3)+e],Upper:R[(O>>3)+e]};if(A&&(t.Primal=R[(_>>3)+e]),x&&A&&!j){let n=P[(b>>2)+e];t.Status=Cn(n,t.Lower,t.Upper),t.Dual=R[(v>>3)+e]}N.push(t)}return{Status:u,ObjectiveValue:m,Columns:M,Rows:N}}finally{i&&Ht(i);try{Q.unlink(r)}catch{}for(let e=a.length-1;e>=0;e--)try{Gt(a[e])}catch{}}};function Tn(e,t,n){let r=Kt(Int32Array.BYTES_PER_ELEMENT);if(!r)return-1;try{let i=ln(e,t,r);if(i!==0&&i!==1)return i;let a=P[r>>2];return a===1?!Number.isSafeInteger(n)||n<-2147483648||n>2147483647?-1:an(e,t,n):a===2?on(e,t,n):-1}finally{Gt(r)}}function En(e,t){let n;try{n=e()}catch(e){n=e}if(n!==0&&n!==1)throw Error(`Unable to `+t+`. HiGHS error `+n)}var Dn=this&&this.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},On=this&&this.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)};return(function(e){"use strict";var t,n;let r={csc:1,csr:2},i={triangular:1,square:2},a=new Map,o=new Map,s=new Map,c=1,l=1,u=0;class d extends Error{constructor(e,t){super(e),this.status=-1,this.name=`HighsError`,this.operation=t}}class f extends d{constructor(){super(`Cannot use this HiGHS model after disposal; create a new model or keep the work inside highs.withModel()`,`dispose`),this.name=`HighsDisposedError`}}class p extends d{constructor(e){super(e,`validate`),this.name=`HighsValidationError`}}class m extends d{constructor(){super(`Only callback control methods may be called while HiGHS is executing a callback`,`callback`),this.name=`HighsReentrancyError`}}class h extends d{constructor(e){super(`Option '`+e+`' is not supported by the single-threaded data-only API`,`setOptionValue`),this.name=`HighsUnsupportedOptionError`,this.option=e}}function g(t,n,r){let i=t+`:`+n+`:`+r.join(`,`),a=s.get(i);if(!a){let c=e.cwrap(t,n,r);a=function(...e){let t=c.apply(null,e),n=o.get(e[0]);return n&&n._throwCallbackError(),t},s.set(i,a)}return a}function _(e,t,n=`number`){return g(e,n,Array(t).fill(`number`))}function v(e,t,n,r=`number`){return g(e,r,Array(t||0).fill(`number`).concat([`string`],Array(n||0).fill(`number`)))}function y(){return B}function b(){return P}function x(){return R}function S(e){return e?Pe(e):``}function C(e){return new p(e)}function w(){return new f}function T(e){return new d(e+` failed with HiGHS status -1`,e)}function E(e){return new h(e)}function ee(){return new m}function D(e){return{status:e}}function O(e,t){return e===-1?{status:e}:{status:e,value:t}}function k(e,t){if(e===-1)throw T(t);return{status:e,warnings:e===1?[t+` completed with a HiGHS warning`]:[]}}function A(e,t,n=0){if(!Number.isSafeInteger(e)||e<(n||0)||e>2147483647)throw C(t+` must be a 32-bit non-negative integer`);return e}function j(e,t){if(!Number.isSafeInteger(e)||e<-2147483648||e>2147483647)throw C(t+` must be a signed 32-bit integer`);return e}function M(e,t){if(e==null||typeof e.length!=`number`)throw C(t+` must be an array or typed array`);return e}function N(e,t,n){if(M(e,n),e.length!==t)throw C(n+` must contain `+t+` values; got `+e.length);return e}function F(e,t){if(typeof e!=`number`||Number.isNaN(e))throw C(t+` must be a number`);return e}function I(e,t,n){N(e,t,n);for(let t=0;t<e.length;t++)F(e[t],n+`[`+t+`]`);return e}function L(e,t,n,r){t==null?M(e,n):N(e,t,n);for(let t=0;t<e.length;t++){let i=e[t];if(A(i,n+`[`+t+`]`,0),r!=null&&i>=r)throw C(n+`[`+t+`] is outside the model`)}return e}function te(e,t,n,r){if(!e||e.format!==`csc`&&e.format!==`csr`)throw C(r+`.format must be 'csc' or 'csr'`);if(e.numRows!==t||e.numCols!==n)throw C(r+` dimensions do not match the model`);let i=e.format===`csc`?n:t;if(L(e.starts,i+1,r+`.starts`),e.starts[0]!==0)throw C(r+`.starts must begin with zero`);for(let t=1;t<e.starts.length;t++)if(e.starts[t]<e.starts[t-1])throw C(r+`.starts must be monotonic`);let a=e.starts[i];return L(e.indices,a,r+`.indices`,e.format===`csc`?t:n),I(e.values,a,r+`.values`),a}function z(e,t,n){if(!e||!(e.format in i))throw C(n+`.format must be 'triangular' or 'square'`);if(e.dimension!==t)throw C(n+`.dimension must equal numCols`);if(L(e.starts,t+1,n+`.starts`),e.starts[0]!==0)throw C(n+`.starts must begin with zero`);for(let t=1;t<e.starts.length;t++)if(e.starts[t]<e.starts[t-1])throw C(n+`.starts must be monotonic`);let r=e.starts[t];return L(e.indices,r,n+`.indices`,t),I(e.values,r,n+`.values`),r}function ne(e){if(!e||typeof e!=`object`)throw C(`model must be an object`);let t=A(e.numCols,`numCols`,0),n=A(e.numRows,`numRows`,0);I(e.colCost,t,`colCost`),I(e.colLower,t,`colLower`),I(e.colUpper,t,`colUpper`),I(e.rowLower,n,`rowLower`),I(e.rowUpper,n,`rowUpper`);let r=te(e.matrix,n,t,`matrix`);if(e.integrality!=null){L(e.integrality,t,`integrality`);for(let n=0;n<t;n++)if(e.integrality[n]>4)throw C(`integrality values must be between 0 and 4`)}let i=e.hessian?z(e.hessian,t,`hessian`):0,a=e.sense==null?1:e.sense;if(a!==1&&a!==-1)throw C(`sense must be 1 (minimize) or -1 (maximize)`);if(F(e.offset==null?0:e.offset,`offset`),e.modelName!=null&&typeof e.modelName!=`string`)throw C(`modelName must be a string`);for(let[r,i,a]of[[e.colNames,t,`colNames`],[e.rowNames,n,`rowNames`]])if(r!=null){N(r,i,a);for(let e=0;e<r.length;e++)if(typeof r[e]!=`string`)throw C(a+`[`+e+`] must be a string`)}return{numCols:t,numRows:n,numNonzeros:r,hessianNonzeros:i,sense:a}}function re(e,t,n){if(!e||typeof e!=`object`)throw C(n+` must be an object`);F(e.weight,n+`.weight`),F(e.offset,n+`.offset`),I(e.coefficients,t,n+`.coefficients`),F(e.absoluteTolerance,n+`.absoluteTolerance`),F(e.relativeTolerance,n+`.relativeTolerance`),j(e.priority,n+`.priority`)}class ie{constructor(){this.pointers=[]}bytes(e){A(e,`allocation size`,0);let t=Kt(Math.max(1,e));if(!t)throw RangeError(`Unable to allocate WebAssembly memory`);return this.pointers.push(t),t}ints(e){let t=this.bytes(e.length*4);return b().set(e,t>>2),t}doubles(e){let t=this.bytes(e.length*8);return x().set(e,t>>3),t}pack(e){let t=[],n=0;for(let r of e){let e=r.type===`f64`?8:4;n=Math.ceil(n/e)*e,t.push(n),n+=r.values.length*e}let r=this.bytes(n);return e.forEach((e,n)=>{let i=r+t[n];e.type===`f64`?x().set(e.values,i>>3):b().set(e.values,i>>2)}),t.map(e=>r+e)}outInts(e){let t=this.bytes(e*4);return b().fill(0,t>>2,(t>>2)+e),t}outDoubles(e){let t=this.bytes(e*8);return x().fill(0,t>>3,(t>>3)+e),t}free(){for(let e=this.pointers.length-1;e>=0;e--)Gt(this.pointers[e]);this.pointers.length=0}}function V(e){let t=new ie;try{return e(t)}finally{t.free()}}function H(e,t){return b().slice(e>>2,(e>>2)+t)}function U(e,t){return x().slice(e>>3,(e>>3)+t)}function ae(e){return new BigInt64Array(y().buffer,e,1)[0]}function oe(e){return`/tmp/highs-js-`+l+++`.`+e}function se(e,t){if(!e||e.format!==`lp`&&e.format!==`mps`)throw C(`format must be 'lp' or 'mps'`);if(!(typeof e.data==`string`||ArrayBuffer.isView(e.data)))throw C(`model data must be a string or Uint8Array`);let n=oe(e.format);try{return Q.writeFile(n,e.data),t(n)}finally{try{Q.unlink(n)}catch{}}}function ce(e,t,n){if(typeof e!=`string`)throw C(`data must be a string`);let r=oe(t);try{return Q.writeFile(r,e),n(r)}finally{try{Q.unlink(r)}catch{}}}function le(e,t,n){let r=oe(e);try{let e=n(r);return e===-1?O(e):O(e,Q.readFile(r,t===`utf8`?{encoding:`utf8`}:void 0))}finally{try{Q.unlink(r)}catch{}}}function W(e){return/thread|parallel|concurr/i.test(e)||/(^|_)(log_file|read_.*_file|write_.*_file|solution_file|.*_file)$/.test(e)||/^write_.*_to_file$/.test(e)}function G(e){if(typeof e!=`string`||!e)throw C(`option name is required`);if(W(e))throw E(e)}function ue(e){if(typeof e!=`string`||!e)throw C(`option name is required`);return!W(e)}function de(e){if(typeof e!=`string`)throw C(`option data must be a string`);for(let t of e.split(/\r?\n/)){let e=/^\s*([A-Za-z][A-Za-z0-9_]*)\b/.exec(t);e&&!t.trimStart().startsWith(`#`)&&G(e[1])}}function K(e,t,n,r){if(!e||typeof e!=`object`)throw C(r+` selection must be tagged`);if(e.kind===`range`){let n=A(e.from,r+`.from`,0),i=A(e.to,r+`.to`,0);if(i<n||i>=t)throw C(r+` range is outside the model`);return{suffix:`ByRange`,prefix:[n,i],count:i-n+1}}if(e.kind===`set`){L(e.indices,null,r+`.indices`,t);for(let t=1;t<e.indices.length;t++)if(e.indices[t]<=e.indices[t-1])throw C(r+` set indices must increase strictly`);return{suffix:`BySet`,prefix:[e.indices.length,n.ints(e.indices)],count:e.indices.length}}if(e.kind===`mask`){N(e.mask,t,r+`.mask`);let i=new Int32Array(t),a=0;for(let n=0;n<t;n++){if(e.mask[n]!==!1&&e.mask[n]!==!0&&e.mask[n]!==0&&e.mask[n]!==1)throw C(r+`.mask values must be boolean, 0, or 1`);i[n]=+!!e.mask[n],a+=i[n]}return{suffix:`ByMask`,prefix:[n.ints(i)],count:a}}throw C(r+`.kind must be 'range', 'set', or 'mask'`)}function q(e){return{numCols:_(`Highs_getNumCol`,1)(e),numRows:_(`Highs_getNumRow`,1)(e),numNonzeros:_(`Highs_getNumNz`,1)(e),hessianNonzeros:_(`Highs_getHessianNumNz`,1)(e)}}function fe(e){return{numCols:_(`Highs_getPresolvedNumCol`,1)(e),numRows:_(`Highs_getPresolvedNumRow`,1)(e),numNonzeros:_(`Highs_getPresolvedNumNz`,1)(e)}}class pe{constructor(e){t.set(this,void 0),n.set(this,void 0),this._callbackNumCols=0,Dn(this,t,e,`f`),Dn(this,n,!1,`f`),this._callbackDepth=0,this._callbackId=0,this._callbackError=void 0,this._callbackErrorPending=!1,o.set(e,this)}get disposed(){return On(this,n,`f`)}_require(e=!1){if(On(this,n,`f`))throw w();if(this._callbackDepth&&!e)throw ee();return On(this,t,`f`)}_rememberCallbackError(e){this._callbackErrorPending||=(this._callbackError=e,!0)}_throwCallbackError(){if(!this._callbackErrorPending)return;let e=this._callbackError;throw this._callbackError=void 0,this._callbackErrorPending=!1,e}clear(){return this._simple(`Highs_clear`)}clearSolver(){return this._simple(`Highs_clearSolver`)}presolve(){return this._simple(`Highs_presolve`)}getRunTime(){return _(`Highs_getRunTime`,1)(this._require(!1))}readModel(e){let t=this._require(!1);return D(se(e,function(e){return v(`Highs_readModel`,1,0)(t,e)}))}exportPresolvedModel(e){let t=this._require(!1);if(e!==`lp`&&e!==`mps`)throw C(`format must be 'lp' or 'mps'`);return le(e,e===`lp`?`utf8`:void 0,function(e){return v(`Highs_writePresolvedModel`,1,0)(t,e)})}passModel(e){let t=this._require(!1),n=V(function(n){let r=he(e,n);return _(`Highs_passModel`,21).apply(null,[t].concat(r.values))}),r=n===-1?n:ge(t,e);return D(n===-1||r===-1?-1:Math.max(n,r))}passMip(e){let t=this._require(!1),n=V(function(n){let i=ne(e),a=e.matrix;if(!e.integrality)throw C(`passMip requires an integrality vector`);let o=me(e,n,!0);return _(`Highs_passMip`,16)(t,i.numCols,i.numRows,i.numNonzeros,r[a.format],i.sense,e.offset==null?0:e.offset,...o)}),i=n===-1?n:ge(t,e);return D(n===-1||i===-1?-1:Math.max(n,i))}passHessian(e){let t=this._require(!1),n=q(t).numCols;return D(V(function(r){let a=z(e,n,`hessian`);return _(`Highs_passHessian`,7)(t,n,a,i[e.format],r.ints(Array.prototype.slice.call(e.starts,0,-1)),r.ints(e.indices),r.doubles(e.values))}))}addLinearObjective(e){let t=this._require(!1),n=q(t).numCols;return re(e,n,`objective`),D(V(function(n){return _(`Highs_addLinearObjective`,7)(t,e.weight,e.offset,n.doubles(e.coefficients),e.absoluteTolerance,e.relativeTolerance,j(e.priority,`priority`))}))}passRowName(e,t){let n=this._require(!1);if(A(e,`row`,0),typeof t!=`string`)throw C(`name must be a string`);return D(v(`Highs_passRowName`,2,0)(n,e,t))}passModelName(e){if(typeof e!=`string`)throw C(`name must be a string`);return D(v(`Highs_passModelName`,1,0)(this._require(!1),e))}getOptionType(e){let t=this._require(!1);return ue(e)?V(function(n){let r=n.outInts(1);return O(v(`Highs_getOptionType`,1,1)(t,e,r),[`boolean`,`integer`,`double`,`string`][b()[r>>2]])}):O(-1)}resetOptions(){return this._simple(`Highs_resetOptions`)}exportOptions(e){let t=this._require(!1),n=le(`options`,`utf8`,function(n){return v(e?`Highs_writeOptionsDeviations`:`Highs_writeOptions`,1,0)(t,n)});return n.status!==-1&&(n.value=n.value.split(/\r?\n/).filter(function(e){let t=/^\s*([A-Za-z][A-Za-z0-9_]*)\b/.exec(e);return!t||!W(t[1])}).join(`
|
|
5
|
-
`)),n}getOptionName(e){let t=this._require(!1);return A(e,`option index`,0),V(function(n){let r=n.outInts(1),i=_(`Highs_getOptionName`,3)(t,e,r),a=b()[r>>2]>>>0;if(!a)return O(i,``);try{return O(i,S(a))}finally{Gt(a)}})}getInfoType(e){let t=this._require(!1);if(typeof e!=`string`||!e)throw C(`info name is required`);return V(function(n){let r=n.outInts(1),i=v(`Highs_getInfoType`,1,1)(t,e,r),a=b()[r>>2];return O(i,a===-1?`int64`:a===1?`integer`:a===2?`double`:void 0)})}getDimensions(){return q(this._require(!1))}getInfinity(){return _(`Highs_getInfinity`,1)(this._require(!1))}getModelStatus(){return _(`Highs_getModelStatus`,1)(this._require(!1))}getSolution(){let e=this._require(!1),t=this.getModelStatus();if(t===0||t===6)throw new d(`The model has not been solved`,`getSolution`);let n=q(e);return V(function(t){let r=t.outDoubles(n.numCols),i=t.outDoubles(n.numCols),a=t.outDoubles(n.numRows),o=t.outDoubles(n.numRows);return O(_(`Highs_getSolution`,5)(e,r,i,a,o),{colValue:U(r,n.numCols),rowValue:U(a,n.numRows),colDual:U(i,n.numCols),rowDual:U(o,n.numRows)})})}setSolution(e){let t=this._require(!1),n=q(t);return D(V(function(r){function i(e,t,n){return e==null?0:(I(e,t,n),r.doubles(e))}return _(`Highs_setSolution`,5)(t,i(e.colValue,n.numCols,`colValue`),i(e.rowValue,n.numRows,`rowValue`),i(e.colDual,n.numCols,`colDual`),i(e.rowDual,n.numRows,`rowDual`))}))}setBasis(e){let t=this._require(!1),n=q(t);if(!e)throw C(`basis is required`);return L(e.colStatus,n.numCols,`colStatus`),L(e.rowStatus,n.numRows,`rowStatus`),D(V(function(n){return _(`Highs_setBasis`,3)(t,n.ints(e.colStatus),n.ints(e.rowStatus))}))}postsolve(e){let t=this._require(!1),n=fe(t);if(!e||e.colValue==null)throw C(`postsolve requires colValue`);return I(e.colValue,n.numCols,`colValue`),e.colDual!=null&&I(e.colDual,n.numCols,`colDual`),e.rowDual!=null&&I(e.rowDual,n.numRows,`rowDual`),D(V(function(n){return _(`Highs_postsolve`,4)(t,n.doubles(e.colValue),e.colDual?n.doubles(e.colDual):0,e.rowDual?n.doubles(e.rowDual):0)}))}getObjectiveOffset(){let e=this._require(!1);return V(function(t){let n=t.outDoubles(1);return O(_(`Highs_getObjectiveOffset`,2)(e,n),x()[n>>3])})}getModel(e){return J(this,`Highs_getModel`,e,!0)}getPresolvedLp(e){return J(this,`Highs_getPresolvedLp`,e,!1)}getFixedLp(e){let t=J(this,`Highs_getFixedLp`,e,!1);return t.status!==-1&&t.value&&t.value.integrality.fill(0),t}ensureRowwise(){return this._simple(`Highs_ensureRowwise`)}addVars(e,t){let n=this._require(!1);return M(e,`lower`),I(t,e.length,`upper`),I(e,e.length,`lower`),D(V(function(r){return _(`Highs_addVars`,4)(n,e.length,r.doubles(e),r.doubles(t))}))}addCol(e,t,n,r){let i=this._require(!1);return F(e,`cost`),F(t,`lower`),F(n,`upper`),_e(r,q(i).numRows),D(V(function(a){return _(`Highs_addCol`,7)(i,e,t,n,r.indices.length,a.ints(r.indices),a.doubles(r.values))}))}addCols(e){let t=this._require(!1),n=q(t).numRows;if(!e||!e.matrix)throw C(`column data and matrix are required`);let r=e.cost.length;if(I(e.cost,r,`cost`),I(e.lower,r,`lower`),I(e.upper,r,`upper`),e.matrix.format!==`csc`)throw C(`addCols requires a csc matrix`);let i=te(e.matrix,n,r,`matrix`);return D(V(function(n){return _(`Highs_addCols`,9)(t,r,n.doubles(e.cost),n.doubles(e.lower),n.doubles(e.upper),i,n.ints(Array.prototype.slice.call(e.matrix.starts,0,-1)),n.ints(e.matrix.indices),n.doubles(e.matrix.values))}))}changeObjectiveSense(e){if(e!==1&&e!==-1)throw C(`sense must be 1 or -1`);return D(_(`Highs_changeObjectiveSense`,2)(this._require(!1),e))}changeColIntegrality(e,t){if(A(e,`column`,0),A(t,`integrality`,0),t>4)throw C(`integrality must be between 0 and 4`);return D(_(`Highs_changeColIntegrality`,3)(this._require(!1),e,t))}changeColCost(e,t){return A(e,`column`,0),F(t,`cost`),D(_(`Highs_changeColCost`,3)(this._require(!1),e,t))}changeRowBounds(e,t,n){return A(e,`row`,0),F(t,`lower`),F(n,`upper`),D(_(`Highs_changeRowBounds`,4)(this._require(!1),e,t,n))}changeColsIntegrality(e,t){let n=q(this._require(!1)).numCols;return Y(this,`changeColsIntegrality`,e,[],[t],n,`columns`)}changeColsBounds(e,t,n){let r=q(this._require(!1)).numCols;return Y(this,`changeColsBounds`,e,[t,n],[],r,`columns`)}deleteCols(e){return ve(this,`Cols`,e,q(this._require(!1)).numCols)}scaleCol(e,t){return A(e,`column`,0),F(t,`factor`),D(_(`Highs_scaleCol`,3)(this._require(!1),e,t))}getCols(e){return X(this,`Cols`,e)}getColName(e){return ye(this,`Highs_js_getColName`,e)}getPresolvedColName(e){return ye(this,`Highs_js_getPresolvedColName`,e)}getColByName(e){return be(this,`Col`,e)}getColIntegrality(e){let t=this._require(!1);return A(e,`column`,0),V(function(n){let r=n.outInts(1);return O(_(`Highs_getColIntegrality`,3)(t,e,r),b()[r>>2])})}getPrimalRay(){return xe(this,`Highs_getPrimalRay`,q(this._require(!1)).numCols)}getDualUnboundednessDirection(){return xe(this,`Highs_getDualUnboundednessDirection`,q(this._require(!1)).numCols)}getBasisInverseRow(e,t){return Se(this,`Highs_getBasisInverseRow`,e,q(this._require(!1)).numRows,t)}getBasisSolve(e,t){return Ce(this,`Highs_getBasisSolve`,e,t)}getReducedRow(e,t){let n=this._require(!1),r=q(n);return A(e,`row`,0),V(function(i){let a=i.outDoubles(r.numCols),o=i.outInts(1),s=i.outInts(r.numCols),c=_(`Highs_getReducedRow`,5)(n,e,a,o,s),l={values:U(a,r.numCols)};return t&&(l.nonzeroIndices=H(s,b()[o>>2])),O(c,l)})}crossover(e){let t=this._require(!1),n=q(t);if(!e||e.colValue==null)throw C(`crossover requires colValue`);if(I(e.colValue,n.numCols,`colValue`),e.colDual==null!=(e.rowDual==null))throw C(`colDual and rowDual must be supplied together`);return e.colDual&&I(e.colDual,n.numCols,`colDual`),e.rowDual&&I(e.rowDual,n.numRows,`rowDual`),D(V(function(r){return _(`Highs_crossover`,6)(t,n.numCols,n.numRows,r.doubles(e.colValue),e.colDual?r.doubles(e.colDual):0,e.rowDual?r.doubles(e.rowDual):0)}))}getRanging(){let e=this._require(!1),t=q(e);return V(function(n){let r=Z(n,t.numCols),i=Z(n,t.numCols),a=Z(n,t.numCols),o=Z(n,t.numCols),s=Z(n,t.numRows),c=Z(n,t.numRows),l=[r,i,a,o,s,c],u=[e];return l.forEach(function(e){u.push(e.valuePointer,e.objectivePointer,e.inPointer,e.outPointer)}),O(_(`Highs_getRanging`,u.length).apply(null,u),{colCostUp:r.detach(),colCostDown:i.detach(),colBoundUp:a.detach(),colBoundDown:o.detach(),rowBoundUp:s.detach(),rowBoundDown:c.detach()})})}setCallback(e){let t=this._require(!1);if(e!=null&&typeof e!=`function`)throw C(`callback must be a function or undefined`);let n=this._callbackId;if(!e){let e=_(`Highs_js_setCallback`,3)(t,0,0);return e!==-1&&(n&&a.delete(n),this._callbackId=0),D(e)}let r=c++;a.set(r,{raw:this,callback:e});let i=_(`Highs_js_setCallback`,3)(t,Oe(),r);return i===-1?a.delete(r):(n&&a.delete(n),this._callbackId=r),D(i)}startCallback(e){return ke(e),D(_(`Highs_startCallback`,2)(this._require(!1),e))}dispose(){if(On(this,n,`f`))return;let e=this._require(!1);this._callbackId&&a.delete(this._callbackId),o.delete(e),_(`Highs_destroy`,1,null)(e),Dn(this,t,0,`f`),Dn(this,n,!0,`f`)}_simple(e){return D(_(e,1)(this._require(!1)))}clearModel(){return this._simple(`Highs_clearModel`)}releaseMemory(){return this._simple(`Highs_releaseMemory`)}zeroAllClocks(){return this._simple(`Highs_zeroAllClocks`)}run(){let e=this._require(!1);return this._callbackNumCols=q(e).numCols,D(_(`Highs_run`,1)(e))}exportModel(e){let t=this._require(!1);if(e!==`lp`&&e!==`mps`)throw C(`format must be 'lp' or 'mps'`);return le(e,e===`lp`?`utf8`:void 0,function(e){return v(`Highs_writeModel`,1,0)(t,e)})}exportSolution(e){let t=this._require(!1);return le(`sol`,`utf8`,function(n){return v(e?`Highs_writeSolutionPretty`:`Highs_writeSolution`,1,0)(t,n)})}passLp(e){let t=this._require(!1),n=V(function(n){let i=ne(e),a=e.matrix,o=me(e,n,!1);return _(`Highs_passLp`,15)(t,i.numCols,i.numRows,i.numNonzeros,r[a.format],i.sense,e.offset==null?0:e.offset,...o)}),i=n===-1?n:ge(t,e);return D(n===-1||i===-1?-1:Math.max(n,i))}passLinearObjectives(e){let t=this._require(!1),n=q(t).numCols;return M(e,`objectives`),D(V(function(r){let i=e.length,a=new Float64Array(i),o=new Float64Array(i),s=new Float64Array(i*n),c=new Float64Array(i),l=new Float64Array(i),u=new Int32Array(i);for(let t=0;t<i;t++){let r=e[t];re(r,n,`objectives[`+t+`]`),a[t]=r.weight,o[t]=r.offset,s.set(r.coefficients,t*n),c[t]=r.absoluteTolerance,l[t]=r.relativeTolerance,u[t]=j(r.priority,`objectives[`+t+`].priority`)}return _(`Highs_passLinearObjectives`,8)(t,i,r.doubles(a),r.doubles(o),r.doubles(s),r.doubles(c),r.doubles(l),r.ints(u))}))}clearLinearObjectives(){return this._simple(`Highs_clearLinearObjectives`)}passColName(e,t){let n=this._require(!1);if(A(e,`column`,0),typeof t!=`string`)throw C(`name must be a string`);return D(v(`Highs_passColName`,2,0)(n,e,t))}setOptionValue(e,t){let n=this._require(!1);if(!ue(e))return D(-1);let r=typeof t,i;if(r===`boolean`)i=v(`Highs_setBoolOptionValue`,1,1)(n,e,+!!t);else if(r===`string`)i=g(`Highs_setStringOptionValue`,`number`,[`number`,`string`,`string`])(n,e,t);else if(r===`number`){if(!Number.isFinite(t))throw C(`numeric option values must be finite`);Number.isSafeInteger(t)&&t>=-2147483648&&t<=2147483647?(i=v(`Highs_setIntOptionValue`,1,1)(n,e,t),i===-1&&(i=v(`Highs_setDoubleOptionValue`,1,1)(n,e,t))):i=v(`Highs_setDoubleOptionValue`,1,1)(n,e,t)}else throw C(`option values must be boolean, number, or string`);return D(i)}getOptionValue(e){let t=this._require(!1);if(!ue(e))return O(-1);let n=this.getOptionType(e);return n.status===-1?O(-1):V(function(r){if(n.value===`string`){let n=r.bytes(512);return O(v(`Highs_getStringOptionValue`,1,1)(t,e,n),S(n))}if(n.value===`double`){let n=r.outDoubles(1);return O(v(`Highs_getDoubleOptionValue`,1,1)(t,e,n),x()[n>>3])}let i=r.outInts(1),a=v(n.value===`boolean`?`Highs_getBoolOptionValue`:`Highs_getIntOptionValue`,1,1)(t,e,i),o=b()[i>>2];return O(a,n.value===`boolean`?!!o:o)})}readOptions(e){let t=this._require(!1);if(typeof e!=`string`)throw C(`option data must be a string`);for(let t of e.split(/\r?\n/)){let e=/^\s*([A-Za-z][A-Za-z0-9_]*)\b/.exec(t);if(e&&!t.trimStart().startsWith(`#`)&&!ue(e[1]))return D(-1)}return D(ce(e,`options`,function(e){return v(`Highs_readOptions`,1,0)(t,e)}))}getNumOptions(){return _(`Highs_getNumOptions`,1)(this._require(!1))}getOptionValues(e){let t=this._require(!1);if(!ue(e))return O(-1);let n=this.getOptionType(e);return n.status===-1?O(-1):V(function(r){let i=n.value;if(i===`boolean`){let n=r.outInts(1),a=r.outInts(1);return O(v(`Highs_getBoolOptionValues`,1,2)(t,e,n,a),{name:e,type:i,current:!!b()[n>>2],default:!!b()[a>>2]})}if(i===`integer`){let n=r.outInts(1),a=r.outInts(1),o=r.outInts(1),s=r.outInts(1);return O(v(`Highs_getIntOptionValues`,1,4)(t,e,n,a,o,s),{name:e,type:i,current:b()[n>>2],default:b()[s>>2],minimum:b()[a>>2],maximum:b()[o>>2]})}if(i===`double`){let n=r.outDoubles(1),a=r.outDoubles(1),o=r.outDoubles(1),s=r.outDoubles(1);return O(v(`Highs_getDoubleOptionValues`,1,4)(t,e,n,a,o,s),{name:e,type:i,current:x()[n>>3],default:x()[s>>3],minimum:x()[a>>3],maximum:x()[o>>3]})}let a=r.bytes(512),o=r.bytes(512);return O(v(`Highs_getStringOptionValues`,1,2)(t,e,a,o),{name:e,type:i,current:S(a),default:S(o)})})}getInfoValue(e){let t=this._require(!1),n=this.getInfoType(e);return n.status===-1?O(-1):V(function(r){if(n.value===`double`){let n=r.outDoubles(1);return O(v(`Highs_getDoubleInfoValue`,1,1)(t,e,n),x()[n>>3])}if(n.value===`int64`){let n=r.bytes(8);return O(v(`Highs_getInt64InfoValue`,1,1)(t,e,n),ae(n))}let i=r.outInts(1);return O(v(`Highs_getIntInfoValue`,1,1)(t,e,i),b()[i>>2])})}getPresolvedDimensions(){return fe(this._require(!1))}getSizeofHighsInt(){return _(`Highs_getSizeofHighsInt`,1)(this._require(!1))}getObjectiveValue(){return _(`Highs_getObjectiveValue`,1)(this._require(!1))}getBasis(){let e=this._require(!1),t=this.getModelStatus();if(t===0||t===6)throw new d(`The model has not been solved`,`getBasis`);let n=q(e);return V(function(t){let r=t.outInts(n.numCols),i=t.outInts(n.numRows);return O(_(`Highs_getBasis`,3)(e,r,i),{colStatus:H(r,n.numCols),rowStatus:H(i,n.numRows)})})}setSparseSolution(e){let t=this._require(!1);if(!e)throw C(`solution is required`);let n=e.indices.length;return L(e.indices,null,`indices`,q(t).numCols),I(e.values,n,`values`),D(V(function(r){return _(`Highs_setSparseSolution`,4)(t,n,r.ints(e.indices),r.doubles(e.values))}))}setLogicalBasis(){return this._simple(`Highs_setLogicalBasis`)}getObjectiveSense(){let e=this._require(!1);return V(function(t){let n=t.outInts(1);return O(_(`Highs_getObjectiveSense`,2)(e,n),b()[n>>2])})}getLp(e){return J(this,`Highs_getLp`,e,!1)}getIisLp(e){return J(this,`Highs_getIisLp`,e,!1)}ensureColwise(){return this._simple(`Highs_ensureColwise`)}addVar(e,t){return F(e,`lower`),F(t,`upper`),D(_(`Highs_addVar`,3)(this._require(!1),e,t))}addRow(e,t,n){let r=this._require(!1);return F(e,`lower`),F(t,`upper`),_e(n,q(r).numCols),D(V(function(i){return _(`Highs_addRow`,6)(r,e,t,n.indices.length,i.ints(n.indices),i.doubles(n.values))}))}addRows(e){let t=this._require(!1),n=q(t).numCols;if(!e||!e.matrix)throw C(`row data and matrix are required`);let r=e.lower.length;if(I(e.lower,r,`lower`),I(e.upper,r,`upper`),e.matrix.format!==`csr`)throw C(`addRows requires a csr matrix`);let i=te(e.matrix,r,n,`matrix`);return D(V(function(n){return _(`Highs_addRows`,8)(t,r,n.doubles(e.lower),n.doubles(e.upper),i,n.ints(Array.prototype.slice.call(e.matrix.starts,0,-1)),n.ints(e.matrix.indices),n.doubles(e.matrix.values))}))}changeObjectiveOffset(e){return F(e,`offset`),D(_(`Highs_changeObjectiveOffset`,2)(this._require(!1),e))}clearIntegrality(){return this._simple(`Highs_clearIntegrality`)}changeColBounds(e,t,n){return A(e,`column`,0),F(t,`lower`),F(n,`upper`),D(_(`Highs_changeColBounds`,4)(this._require(!1),e,t,n))}changeCoeff(e,t,n){return A(e,`row`,0),A(t,`column`,0),F(n,`value`),D(_(`Highs_changeCoeff`,4)(this._require(!1),e,t,n))}changeColsCost(e,t){let n=q(this._require(!1)).numCols;return Y(this,`changeColsCost`,e,[t],[],n,`columns`)}changeRowsBounds(e,t,n){let r=q(this._require(!1)).numRows;return Y(this,`changeRowsBounds`,e,[t,n],[],r,`rows`)}deleteRows(e){return ve(this,`Rows`,e,q(this._require(!1)).numRows)}scaleRow(e,t){return A(e,`row`,0),F(t,`factor`),D(_(`Highs_scaleRow`,3)(this._require(!1),e,t))}getRows(e){return X(this,`Rows`,e)}getRowName(e){return ye(this,`Highs_js_getRowName`,e)}getPresolvedRowName(e){return ye(this,`Highs_js_getPresolvedRowName`,e)}getRowByName(e){return be(this,`Row`,e)}getDualRay(){return xe(this,`Highs_getDualRay`,q(this._require(!1)).numRows)}getBasicVariables(){let e=this._require(!1),t=q(e).numRows;return V(function(n){let r=n.outInts(t);return O(_(`Highs_getBasicVariables`,2)(e,r),H(r,t))})}getBasisInverseCol(e,t){return Se(this,`Highs_getBasisInverseCol`,e,q(this._require(!1)).numRows,t)}getBasisTransposeSolve(e,t){return Ce(this,`Highs_getBasisTransposeSolve`,e,t)}getReducedColumn(e,t){return Se(this,`Highs_getReducedColumn`,e,q(this._require(!1)).numRows,t)}feasibilityRelaxation(e){let t=this._require(!1),n=q(t);if(!e)throw C(`relaxation input is required`);return F(e.globalLowerPenalty,`globalLowerPenalty`),F(e.globalUpperPenalty,`globalUpperPenalty`),F(e.globalRowPenalty,`globalRowPenalty`),D(V(function(r){function i(e,t,n){return e==null?0:(I(e,t,n),r.doubles(e))}return _(`Highs_feasibilityRelaxation`,7)(t,e.globalLowerPenalty,e.globalUpperPenalty,e.globalRowPenalty,i(e.localLowerPenalty,n.numCols,`localLowerPenalty`),i(e.localUpperPenalty,n.numCols,`localUpperPenalty`),i(e.localRowPenalty,n.numRows,`localRowPenalty`))}))}getIis(){let e=this._require(!1),t=q(e);return V(function(n){let r=n.outInts(1),i=n.outInts(1),a=n.outInts(t.numCols),o=n.outInts(t.numRows),s=n.outInts(t.numCols),c=n.outInts(t.numRows),l=n.outInts(t.numCols),u=n.outInts(t.numRows),d=_(`Highs_getIis`,9)(e,r,i,a,o,s,c,l,u);if(d===-1)return O(d);let f=b()[r>>2],p=b()[i>>2];if(f<0||f>t.numCols||p<0||p>t.numRows)throw RangeError(`HiGHS returned invalid IIS dimensions`);return O(d,{colIndex:H(a,f),rowIndex:H(o,p),colBound:H(s,f),rowBound:H(c,p),colStatus:H(l,t.numCols),rowStatus:H(u,t.numRows)})})}stopCallback(e){return ke(e),D(_(`Highs_stopCallback`,2)(this._require(!1),e))}}t=new WeakMap,n=new WeakMap;function me(e,t,n){let r=e.matrix;return t.pack([{type:`f64`,values:e.colCost},{type:`f64`,values:e.colLower},{type:`f64`,values:e.colUpper},{type:`f64`,values:e.rowLower},{type:`f64`,values:e.rowUpper},{type:`i32`,values:Array.prototype.slice.call(r.starts,0,-1)},{type:`i32`,values:r.indices},{type:`f64`,values:r.values},...n?[{type:`i32`,values:e.integrality}]:[]])}function he(e,t){let n=ne(e),a=e.matrix,o=e.hessian,s=t.pack([{type:`f64`,values:e.colCost},{type:`f64`,values:e.colLower},{type:`f64`,values:e.colUpper},{type:`f64`,values:e.rowLower},{type:`f64`,values:e.rowUpper},{type:`i32`,values:Array.prototype.slice.call(a.starts,0,-1)},{type:`i32`,values:a.indices},{type:`f64`,values:a.values},...o?[{type:`i32`,values:Array.prototype.slice.call(o.starts,0,-1)},{type:`i32`,values:o.indices},{type:`f64`,values:o.values}]:[],...e.integrality?[{type:`i32`,values:e.integrality}]:[]]),c=0,l=s[c++],u=s[c++],d=s[c++],f=s[c++],p=s[c++],m=s[c++],h=s[c++],g=s[c++],_=o?s[c++]:0,v=o?s[c++]:0,y=o?s[c++]:0,b=e.integrality?s[c]:0;return{shape:n,values:[n.numCols,n.numRows,n.numNonzeros,n.hessianNonzeros,r[a.format],o?i[o.format]:1,n.sense,e.offset==null?0:e.offset,l,u,d,f,p,m,h,g,_,v,y,b]}}function ge(e,t){let n=0;if(t.modelName!=null&&(n=Math.max(n,v(`Highs_passModelName`,1,0)(e,String(t.modelName)))),t.colNames!=null){N(t.colNames,t.numCols,`colNames`);for(let r=0;r<t.colNames.length;r++){let i=v(`Highs_passColName`,2,0)(e,r,String(t.colNames[r]));if(i===-1)return i;n=Math.max(n,i)}}if(t.rowNames!=null){N(t.rowNames,t.numRows,`rowNames`);for(let r=0;r<t.rowNames.length;r++){let i=v(`Highs_passRowName`,2,0)(e,r,String(t.rowNames[r]));if(i===-1)return i;n=Math.max(n,i)}}return n}function J(e,t,n,i){let a=e._require(!1),o=t!==`Highs_getFixedLp`,s=n??`csc`;if(!(s in r))throw C(`format must be 'csc' or 'csr'`);let c=t===`Highs_getModel`||t===`Highs_getLp`?q(a):t===`Highs_getPresolvedLp`?fe(a):t===`Highs_getFixedLp`?q(a):void 0;return V(function(e){let n=e.outInts(1),l=e.outInts(1),u=e.outInts(1),d=i?e.outInts(1):0,f=e.outInts(1),p=e.outDoubles(1),m=i?21:o?16:15,h=0,g=c?.numCols??0,v=c?.numRows??0,y=c?.numNonzeros??0,S=i?c?.hessianNonzeros??0:0;if(!c){let e=i?[a,r[s],1,n,l,u,d,f,p]:[a,r[s],n,l,u,f,p],c=i?Array(12).fill(0):Array(o?9:8).fill(0);if(h=_(t,m).apply(null,e.concat(c)),h===-1)return O(h);g=b()[n>>2],v=b()[l>>2],y=b()[u>>2],S=i?b()[d>>2]:0}let C=s===`csc`?g:v,w=e.outDoubles(g),T=e.outDoubles(g),E=e.outDoubles(g),ee=e.outDoubles(v),D=e.outDoubles(v),k=e.outInts(C),A=e.outInts(y),j=e.outDoubles(y),M=o?e.outInts(g):0,N=i?e.outInts(g):0,P=i?e.outInts(S):0,F=i?e.outDoubles(S):0,I=i?[a,r[s],1,n,l,u,d,f,p,w,T,E,ee,D,k,A,j,N,P,F,M]:[a,r[s],n,l,u,f,p,w,T,E,ee,D,k,A,j].concat(o?[M]:[]);if(h=_(t,m).apply(null,I),h===-1)return O(h);let L=new Int32Array(C+1);L.set(H(k,C)),L[C]=y;let R={numCols:g,numRows:v,sense:b()[f>>2],offset:x()[p>>3],colCost:U(w,g),colLower:U(T,g),colUpper:U(E,g),rowLower:U(ee,v),rowUpper:U(D,v),matrix:{format:s,numRows:v,numCols:g,starts:L,indices:H(A,y),values:U(j,y)},integrality:o?H(M,g):new Int32Array(g)};if(i&&S){let e=new Int32Array(g+1);e.set(H(N,g)),e[g]=S,R.hessian={format:`triangular`,dimension:g,starts:e,indices:H(P,S),values:U(F,S)}}return O(h,R)})}function _e(e,t){if(!e)throw C(`entries are required`);L(e.indices,null,`entries.indices`,t),I(e.values,e.indices.length,`entries.values`)}function Y(e,t,n,r,i,a,o){let s=e._require(!1);return D(V(function(e){let c=K(n,a,e,o),l=c.suffix===`ByMask`?a:c.count,u=r.map(function(t,n){return I(t,l,o+` values `+n),e.doubles(t)}),d=i.map(function(t,n){return L(t,l,o+` integer values `+n),e.ints(t)}),f=[s].concat(c.prefix,u,d);return _(`Highs_`+t+c.suffix,f.length).apply(null,f)}))}function ve(e,t,n,r){let i=e._require(!1);return D(V(function(e){let a=K(n,r,e,t.toLowerCase()),o=[i].concat(a.prefix);return _(`Highs_delete`+t+a.suffix,o.length).apply(null,o)}))}function X(e,t,n){let r=e._require(!1),i=q(r),a=t===`Cols`,o=a?i.numCols:i.numRows;return V(function(e){let s=K(n,o,e,t.toLowerCase()),c=e.outInts(1),l=e.outInts(1),u=a?3:2,d=[r].concat(s.prefix,[c],Array(u).fill(0),[l,0,0,0]),f=`Highs_get`+t+s.suffix,p=_(f,d.length).apply(null,d);if(p===-1)return O(p);let m=b()[c>>2],h=b()[l>>2],g=a?e.outDoubles(m):0,v=e.outDoubles(m),y=e.outDoubles(m),x=e.outInts(m),S=e.outInts(h),C=e.outDoubles(h),w=[r].concat(s.prefix,[c],a?[g,v,y]:[v,y],[l,x,S,C]);if(p=_(f,w.length).apply(null,w),p===-1)return O(p);let T=new Int32Array(m+1);T.set(H(x,m)),T[m]=h;let E={format:a?`csc`:`csr`,numRows:a?i.numRows:m,numCols:a?m:i.numCols,starts:T,indices:H(S,h),values:U(C,h)};return O(p,a?{count:m,cost:U(g,m),lower:U(v,m),upper:U(y,m),matrix:E}:{count:m,lower:U(v,m),upper:U(y,m),matrix:E})})}function ye(e,t,n){let r=e._require(!1);return A(n,`index`,0),V(function(e){let i=e.outInts(1),a=_(t,5)(r,n,0,0,i);if(a===-1)return O(a);let o=b()[i>>2];if(o<=0)return O(a,``);let s=e.bytes(o);return a=_(t,5)(r,n,s,o,i),O(a,S(s))})}function be(e,t,n){let r=e._require(!1);if(typeof n!=`string`)throw C(`name must be a string`);return V(function(e){let i=e.outInts(1);return O(v(`Highs_get`+t+`ByName`,1,1)(r,n,i),b()[i>>2])})}function xe(e,t,n){let r=e._require(!1);return V(function(e){let i=e.outInts(1),a=e.outDoubles(n);return O(_(t,3)(r,i,a),b()[i>>2]?{values:U(a,n)}:void 0)})}function Se(e,t,n,r,i){let a=e._require(!1);return V(function(e){let o=e.outDoubles(r),s=e.outInts(1),c=e.outInts(r);if(n==null)throw C(`an index is required`);A(n,`index`,0);let l=[a,n,o,s,c],u=_(t,l.length).apply(null,l),d={values:U(o,r)};return i&&(d.nonzeroIndices=H(c,b()[s>>2])),O(u,d)})}function Ce(e,t,n,r){let i=e._require(!1),a=q(i).numRows;return I(n,a,`rhs`),V(function(e){let o=e.outDoubles(a),s=e.outInts(1),c=e.outInts(a),l=_(t,5)(i,e.doubles(n),o,s,c),u={values:U(o,a)};return r&&(u.nonzeroIndices=H(c,b()[s>>2])),O(l,u)})}function Z(e,t){return{valuePointer:e.outDoubles(t),objectivePointer:e.outDoubles(t),inPointer:e.outInts(t),outPointer:e.outInts(t),detach:function(){return{value:U(this.valuePointer,t),objective:U(this.objectivePointer,t),inVariable:H(this.inPointer,t),outVariable:H(this.outPointer,t)}}}}function we(e,t){return v(`Highs_getCallbackDataOutItem`,1,0)(e,t)}function Te(e,t,n){let r=we(e,t);if(r)return n===`double`?x()[r>>3]:n===`int64`?ae(r):b()[r>>2]}let Ee=[[`running_time`,`double`],[`objective_function_value`,`double`],[`mip_node_count`,`int64`],[`mip_total_lp_iterations`,`int64`],[`mip_primal_bound`,`double`],[`mip_dual_bound`,`double`],[`mip_gap`,`double`]];function De(e,t,n,r,i){let o=a.get(i);if(!o)return;let s=o.raw,c=o.callback,l=!0;function u(){if(!l)throw C(`callback controls expire when the callback returns`)}s._callbackDepth+=1;try{let i={numCols:s._callbackNumCols},a={};if((e===0?[[`log_type`,`int`]]:e===1?[[`simplex_iteration_count`,`int`]]:e===2?[[`ipm_iteration_count`,`int`]]:e>=3&&e<=9?Ee:[]).forEach(function(e){let t=Te(n,e[0],e[1]);t!==void 0&&(a[e[0]]=t)}),e===3||e===4){let e=we(n,`mip_solution`),t=_(`Highs_js_getCallbackMipSolutionSize`,1)(n);if(t<0)throw RangeError(`HiGHS returned an invalid MIP solution size`);if(e)a.mip_solution=U(e,t);else if(t)throw RangeError(`HiGHS returned a null MIP solution`)}if(e===7){let e=Te(n,`cutpool_num_cut`,`int`),t=Te(n,`cutpool_num_nz`,`int`),r=Te(n,`cutpool_num_col`,`int`);if(typeof e==`number`&&typeof t==`number`&&typeof r==`number`&&e>=0&&t>=0){let i=we(n,`cutpool_start`),o=we(n,`cutpool_index`),s=we(n,`cutpool_value`),c=we(n,`cutpool_lower`),l=we(n,`cutpool_upper`);i&&o&&s&&c&&l&&(a.cut_pool={numCols:r,numCuts:e,starts:H(i,e+1),indices:H(o,t),values:U(s,t),lower:U(c,e),upper:U(l,e)})}}let o={type:e,message:S(t),data:a};e===9?(o.setSolution=function(e){u();try{return e&&e.indices?(L(e.indices,null,`indices`,i.numCols),I(e.values,e.indices.length,`values`),D(V(function(t){return _(`Highs_setCallbackSparseSolution`,4)(r,e.indices.length,t.ints(e.indices),t.doubles(e.values))}))):(I(e,i.numCols,`solution`),D(V(function(t){return _(`Highs_setCallbackSolution`,3)(r,i.numCols,t.doubles(e))})))}catch(e){return s._rememberCallbackError(e),D(-1)}},o.repairSolution=function(){return u(),D(_(`Highs_repairCallbackSolution`,1)(r))}):(e===1||e===2||e===6)&&(o.interrupt=function(){u(),b()[r>>2]=1});let l=c(o);if(l&&(typeof l==`object`||typeof l==`function`)&&typeof l.then==`function`)throw Promise.resolve(l).catch(function(){}),C(`callbacks must be synchronous and return undefined`)}catch(t){s._rememberCallbackError(t),(e===1||e===2||e===6)&&r&&(b()[r>>2]=1)}finally{l=!1,--s._callbackDepth}}function Oe(){return u||=Rt(De,`viiiii`),u}function ke(e){if(A(e,`callback type`,0),e===8||e>9)throw C(`callback type must be one of 0..7 or 9`)}function Ae(e,t,n=void 0){if(e.status===-1)throw T(t);return n&&n._setLast(e.status,t),e.value}class je{constructor(e){this.raw=e,this.lastCall={status:0,warnings:[]},this.options=new Me(this),this.info=new Ne(this)}get disposed(){return this.raw.disposed}_setLast(e,t){return this.lastCall=k(e,t),this.lastCall}_value(e,t=[]){return Ae(this.raw[e].apply(this.raw,t||[]),e,this)}exportModel(e){return this._value(`exportModel`,[e])}exportSolution(e){return this._value(`exportSolution`,[e])}getPresolvedDimensions(){return this.raw.getPresolvedDimensions()}getModelStatus(){return this.raw.getModelStatus()}setSolution(e){if(e==null)throw C(`solution is required`);return this._status(e.indices?`setSparseSolution`:`setSolution`,[e])}setLogicalBasis(){return this._status(`setLogicalBasis`)}dispose(){this.raw.dispose()}_status(e,t=[]){let n=this.raw[e].apply(this.raw,t||[]);return this._setLast(n.status,e)}exportPresolvedModel(e){return this._value(`exportPresolvedModel`,[e])}getDimensions(){return this.raw.getDimensions()}getRunTime(){return this.raw.getRunTime()}getObjectiveValue(){return this.raw.getObjectiveValue()}getObjectiveSense(){return this._value(`getObjectiveSense`)}getObjectiveOffset(){return this._value(`getObjectiveOffset`)}setBasis(e){return e==null?this._status(`setLogicalBasis`):this._status(`setBasis`,[e])}run(e){let t=this.raw,n=[],r=!1;try{if(e&&Object.keys(e).length){if(t._callbackId)throw C(`run callbacks cannot replace a callback registered through model.raw`);if(t.setCallback(function(t){let n=e[t.type];if(n)return n(t)}).status===-1)throw T(`setCallback`);r=!0,Object.keys(e).forEach(function(e){let r=Number(e);if(ke(r),t.startCallback(r).status===-1)throw T(`startCallback`);n.push(r)})}let i=t.run(),a=this._setLast(i.status,`run`);return{status:a.status,warnings:a.warnings,modelStatus:t.getModelStatus()}}finally{try{for(let e=0;e<n.length;e++)t.stopCallback(n[e])}finally{r&&t.setCallback(void 0)}}}clear(...e){return this._status(`clear`,e)}clearModel(...e){return this._status(`clearModel`,e)}clearSolver(...e){return this._status(`clearSolver`,e)}releaseMemory(...e){return this._status(`releaseMemory`,e)}readModel(...e){return this._status(`readModel`,e)}passModel(...e){return this._status(`passModel`,e)}passHessian(...e){return this._status(`passHessian`,e)}passLinearObjectives(...e){return this._status(`passLinearObjectives`,e)}addLinearObjective(...e){return this._status(`addLinearObjective`,e)}clearLinearObjectives(...e){return this._status(`clearLinearObjectives`,e)}presolve(...e){return this._status(`presolve`,e)}postsolve(...e){return this._status(`postsolve`,e)}zeroAllClocks(...e){return this._status(`zeroAllClocks`,e)}addVar(...e){return this._status(`addVar`,e)}addVars(...e){return this._status(`addVars`,e)}addCol(...e){return this._status(`addCol`,e)}addCols(...e){return this._status(`addCols`,e)}addRow(...e){return this._status(`addRow`,e)}addRows(...e){return this._status(`addRows`,e)}ensureColwise(...e){return this._status(`ensureColwise`,e)}ensureRowwise(...e){return this._status(`ensureRowwise`,e)}changeObjectiveSense(...e){return this._status(`changeObjectiveSense`,e)}changeObjectiveOffset(...e){return this._status(`changeObjectiveOffset`,e)}changeColIntegrality(...e){return this._status(`changeColIntegrality`,e)}changeColsIntegrality(...e){return this._status(`changeColsIntegrality`,e)}clearIntegrality(...e){return this._status(`clearIntegrality`,e)}changeColCost(...e){return this._status(`changeColCost`,e)}changeColsCost(...e){return this._status(`changeColsCost`,e)}changeColBounds(...e){return this._status(`changeColBounds`,e)}changeColsBounds(...e){return this._status(`changeColsBounds`,e)}changeRowBounds(...e){return this._status(`changeRowBounds`,e)}changeRowsBounds(...e){return this._status(`changeRowsBounds`,e)}deleteCols(...e){return this._status(`deleteCols`,e)}deleteRows(...e){return this._status(`deleteRows`,e)}scaleCol(...e){return this._status(`scaleCol`,e)}scaleRow(...e){return this._status(`scaleRow`,e)}passColName(...e){return this._status(`passColName`,e)}passRowName(...e){return this._status(`passRowName`,e)}passModelName(...e){return this._status(`passModelName`,e)}crossover(...e){return this._status(`crossover`,e)}feasibilityRelaxation(...e){return this._status(`feasibilityRelaxation`,e)}changeCoefficient(...e){return this._status(`changeCoeff`,e)}getSolution(...e){return this._value(`getSolution`,e)}getBasis(...e){return this._value(`getBasis`,e)}getPrimalRay(...e){return this._value(`getPrimalRay`,e)}getDualRay(...e){return this._value(`getDualRay`,e)}getDualUnboundednessDirection(...e){return this._value(`getDualUnboundednessDirection`,e)}getModel(...e){return this._value(`getModel`,e)}getLp(...e){return this._value(`getLp`,e)}getPresolvedLp(...e){return this._value(`getPresolvedLp`,e)}getIisLp(...e){return this._value(`getIisLp`,e)}getFixedLp(...e){return this._value(`getFixedLp`,e)}getCols(...e){return this._value(`getCols`,e)}getRows(...e){return this._value(`getRows`,e)}getColName(...e){return this._value(`getColName`,e)}getRowName(...e){return this._value(`getRowName`,e)}getPresolvedColName(...e){return this._value(`getPresolvedColName`,e)}getPresolvedRowName(...e){return this._value(`getPresolvedRowName`,e)}getColByName(...e){return this._value(`getColByName`,e)}getRowByName(...e){return this._value(`getRowByName`,e)}getColIntegrality(...e){return this._value(`getColIntegrality`,e)}getBasicVariables(...e){return this._value(`getBasicVariables`,e)}getBasisInverseRow(...e){return this._value(`getBasisInverseRow`,e)}getBasisInverseCol(...e){return this._value(`getBasisInverseCol`,e)}getBasisSolve(...e){return this._value(`getBasisSolve`,e)}getBasisTransposeSolve(...e){return this._value(`getBasisTransposeSolve`,e)}getReducedRow(...e){return this._value(`getReducedRow`,e)}getReducedColumn(...e){return this._value(`getReducedColumn`,e)}getRanging(...e){return this._value(`getRanging`,e)}getIis(...e){return this._value(`getIis`,e)}}class Me{constructor(e){this._model=e}set(e,t){if(typeof e==`object`&&e){Object.keys(e).forEach(G);let t=0;return Object.keys(e).forEach(function(n){let r=this._model.raw.setOptionValue(n,e[n]);if(r.status===-1)throw T(`setOptionValue`);t=Math.max(t,r.status)}.bind(this)),this._model._setLast(t,`setOptionValue`)}return G(e),this._model._status(`setOptionValue`,[e,t])}describe(e){return G(e),this._model._value(`getOptionValues`,[e])}reset(){return this._model._status(`resetOptions`)}export(e){return this._model._value(`exportOptions`,[e])}get(e){return G(e),this._model._value(`getOptionValue`,[e])}names(){let e=this._model.raw.getNumOptions(),t=[];for(let n=0;n<e;n++){let e=this._model.raw.getOptionName(n);if(e.status===-1)throw T(`getOptionName`);W(e.value)||t.push(e.value)}return t}read(e){return de(e),this._model._status(`readOptions`,[e])}}class Ne{constructor(e){this._model=e}get(e){return this._model._value(`getInfoValue`,[e])}type(e){return this._model._value(`getInfoType`,[e])}}function $(){let e=_(`Highs_create`,0)();if(!e)throw Error(`Highs_create failed`);let t=Ie(new pe(e));return v(`Highs_setIntOptionValue`,1,1)(e,`threads`,1),g(`Highs_setStringOptionValue`,`number`,[`number`,`string`,`string`])(e,`parallel`,`off`),t}function Fe(e){let t=Ie(new je($()));try{return e&&(e.format===`lp`||e.format===`mps`?t.readModel(e):t.passModel(e)),t}catch(e){throw t.dispose(),e}}function Ie(e){let t=Symbol.dispose;return t!==void 0&&Object.defineProperty(e,t,{configurable:!0,writable:!0,value:e.dispose}),e}function Le(e){return e!==null&&(typeof e==`object`||typeof e==`function`)&&typeof e.then==`function`}function Re(e,t=void 0){let n=typeof e!=`function`,r=n?e:void 0,i=n?t:e;if(typeof i!=`function`)throw C(`withModel requires a callback`);let a=Fe(r);try{let e=i(a);return Le(e)?Promise.resolve(e).finally(function(){a.dispose()}):(a.dispose(),e)}catch(e){throw a.dispose(),e}}function ze(e,t){let n=ne(t);return V(function(a){let o=t.matrix,s=e===`Highs_mipCall`,c=a.outDoubles(n.numCols),l=s?0:a.outDoubles(n.numCols),u=a.outDoubles(n.numRows),d=s?0:a.outDoubles(n.numRows),f=s?0:a.outInts(n.numCols),p=s?0:a.outInts(n.numRows),m=a.outInts(1),h=me(t,a,s),g=[n.numCols,n.numRows,n.numNonzeros,r[o.format],n.sense,t.offset==null?0:t.offset,...h.slice(0,8)],v;if(e===`Highs_mipCall`){if(!t.integrality)throw C(`mipCall requires integrality`);v=g.concat([h[8],c,u,m])}else if(e===`Highs_qpCall`){if(!t.hessian)throw C(`qpCall requires hessian`);let e=t.hessian;v=g.slice(0,3).concat([n.hessianNonzeros,r[o.format],i[e.format],n.sense,t.offset==null?0:t.offset,...h.slice(0,8),a.ints(Array.prototype.slice.call(e.starts,0,-1)),a.ints(e.indices),a.doubles(e.values),c,l,u,d,f,p,m])}else v=g.concat([c,l,u,d,f,p,m]);let y=_(e,v.length).apply(null,v);return s?O(y,{modelStatus:b()[m>>2],solution:{colValue:U(c,n.numCols),rowValue:U(u,n.numRows)}}):O(y,{modelStatus:b()[m>>2],solution:{colValue:U(c,n.numCols),rowValue:U(u,n.numRows),colDual:U(l,n.numCols),rowDual:U(d,n.numRows)},basis:{colStatus:H(f,n.numCols),rowStatus:H(p,n.numRows)}})})}let Be=Object.freeze({major:_(`Highs_versionMajor`,0)(),minor:_(`Highs_versionMinor`,0)(),patch:_(`Highs_versionPatch`,0)(),string:g(`Highs_version`,`string`,[])(),gitHash:g(`Highs_githash`,`string`,[])()}),Ve=Object.freeze({status:Object.freeze({error:-1,ok:0,warning:1}),variableType:Object.freeze({continuous:0,integer:1,semiContinuous:2,semiInteger:3,implicitInteger:4}),objectiveSense:Object.freeze({minimize:1,maximize:-1}),matrixFormat:Object.freeze({columnWise:1,rowWise:2}),hessianFormat:Object.freeze({triangular:1,square:2}),optionType:Object.freeze({boolean:0,integer:1,double:2,string:3}),infoType:Object.freeze({int64:-1,integer:1,double:2}),solutionStatus:Object.freeze({none:0,infeasible:1,feasible:2}),basisValidity:Object.freeze({invalid:0,valid:1}),basisStatus:Object.freeze({lower:0,basic:1,upper:2,zero:3,nonbasic:4}),callbackType:Object.freeze({logging:0,simplexInterrupt:1,ipmInterrupt:2,mipSolution:3,mipImprovingSolution:4,mipLogging:5,mipInterrupt:6,mipCutPool:7,mipUserSolution:9}),presolveStatus:Object.freeze({notPresolved:-1,notReduced:0,infeasible:1,unboundedOrInfeasible:2,reduced:3,reducedToEmpty:4,timeout:5,nullError:6,optionsError:7,outOfMemory:8}),modelStatus:Object.freeze({notSet:0,loadError:1,modelError:2,presolveError:3,solveError:4,postsolveError:5,empty:6,optimal:7,infeasible:8,unboundedOrInfeasible:9,unbounded:10,objectiveBound:11,objectiveTarget:12,timeLimit:13,iterationLimit:14,unknown:15,solutionLimit:16,interrupted:17}),iis:Object.freeze({strategyLight:0,strategyRowPriority:6,strategyColPriority:14,boundFree:1,boundLower:2,boundUpper:3,boundBoxed:4,notInConflict:-1,maybeInConflict:0,inConflict:1})}),He=$(),Ue=He.getInfinity(),We=He.getSizeofHighsInt();if(He.dispose(),We!==4)throw Error(`This highs-js runtime requires a 32-bit HighsInt build; received `+We*8+` bits`);e.version=Be,e.infinity=Ue,e.intBytes=We,e.intBits=We*8,Object.defineProperty(e,"memoryBytes",{enumerable:!0,get:function(){return y().buffer.byteLength}}),e.constants=Ve,e.errors=Object.freeze({HighsError:d,HighsDisposedError:f,HighsValidationError:p,HighsReentrancyError:m,HighsUnsupportedOptionError:h}),e.createModel=Fe,e.withModel=Re,e.raw=Object.freeze({version:function(){return Be},lpCall:function(e){return ze(`Highs_lpCall`,e)},mipCall:function(e){return ze(`Highs_mipCall`,e)},qpCall:function(e){return ze(`Highs_qpCall`,e)},createModel:$})})(n),n}})();typeof e==`object`&&typeof t==`object`?(t.exports=n,t.exports.default=n):typeof define==`function`&&define.amd&&define([],()=>n)})),W=l({default:()=>G.default}),G,ue=s((()=>{G=d(le(),1)})),de=`https://cdn.jsdelivr.net/npm/highs@1.15.3/build/highs.wasm`,K=null,q=null,fe=null;function pe(e){fe=e,K=null,q=null}function me(){return fe}function he(e){return e.length>=4&&e[0]===0&&e[1]===97&&e[2]===115&&e[3]===109}async function ge(e){try{let t=await fetch(e,{headers:{Range:`bytes=0-3`}});if(!t.ok||(t.headers.get(`content-type`)||``).includes(`text/html`))return!1;if(!t.body)return!0;let n=t.body.getReader(),{value:r,done:i}=await n.read();return await n.cancel(),i||!r||r.length<4?!1:he(r)}catch{return!1}}async function J(e){return e||fe||ce()}async function _e(e={}){let t=await J(e.wasmUrl),n=t??`node`;if(K&&q===n)return K;q=n;let r=(async()=>{let e=(await Promise.resolve().then(()=>(ue(),W))).default;return await e({locateFile:e=>e.endsWith(`.wasm`)?t:e})})().catch(e=>{K===r&&(K=null,q=null);let n=e instanceof Error?e.message:String(e);throw Error(`[WaSHI] Failed to initialize HiGHS${t?` from "${t}"`:``}. Deploy the package's WASM asset or explicitly set wasmUrl; no CDN fallback is attempted. ${n}`,{cause:e})});return K=r,r}async function Y(e,t={}){let n=await _e(t),r=performance.now(),i={output_flag:t.outputFlag??!1};return t.timeLimit!==void 0&&(i.time_limit=t.timeLimit),t.presolve!==void 0&&(i.presolve=t.presolve),t.solver!==void 0&&(i.solver=t.solver),t.relGap!==void 0&&(i.mip_rel_gap=t.relGap),t.absGap!==void 0&&(i.mip_abs_gap=t.absGap),{result:n.solve(e,i),runTime:(performance.now()-r)/1e3}}function ve(){let e=se(`highs-worker.js`);if(new URL(e).origin===window.location.origin)return new Worker(e,{type:`module`});let t=URL.createObjectURL(new Blob([`import `+JSON.stringify(e)+`;`],{type:`text/javascript`}));try{let e=new Worker(t,{type:`module`}),n=()=>URL.revokeObjectURL(t);return e.addEventListener(`message`,n,{once:!0}),e.addEventListener(`error`,n,{once:!0}),e}catch(e){throw URL.revokeObjectURL(t),e}}var X=null,ye=0,be=new Map;function xe(){if(typeof window>`u`||typeof Worker>`u`)return null;if(!X)try{X=ve();let e=X;X.onmessage=e=>{let{type:t,id:n,result:r,runTime:i,error:a}=e.data,o=be.get(n);o&&(be.delete(n),t===`SOLVE_SUCCESS`?o.resolve({result:r,runTime:i}):o.reject(Error(a||`Worker solve failed`)))};let t=t=>{if(X===e){X=null,e.terminate();for(let e of be.values())e.reject(t);be.clear()}};X.onerror=e=>t(Error(`[WaSHI] HiGHS Worker failed to load or execute. Check Worker assets, CORS and CSP. ${e?.message||``}`)),X.onmessageerror=()=>t(Error(`[WaSHI] Could not deserialize the HiGHS Worker response.`))}catch{X=null}return X}async function Se(e,t={}){let n=await J(t.wasmUrl),r=t.useWorker??typeof window<`u`?xe():null;if(!r)return Y(e,t);let i={...t,wasmUrl:n},a=`req_${++ye}`;return new Promise((t,n)=>{be.set(a,{resolve:t,reject:n});try{r.postMessage({type:`SOLVE`,id:a,lpString:e,options:i})}catch(e){be.delete(a),n(e)}})}function Ce(e){if(typeof e!=`string`)return`Unknown`;let t=e.trim();if(!t)return`Unknown`;switch(t){case`Optimal`:return`Optimal`;case`Infeasible`:return`Infeasible`;case`Unbounded`:return`Unbounded`;case`Primal infeasible or unbounded`:return`Unknown`;case`Time limit reached`:case`TimeLimit`:return`TimeLimit`;case`Iteration limit reached`:case`IterationLimit`:return`IterationLimit`;case`Bound on objective reached`:case`Target for objective reached`:case`Feasible`:return`Feasible`;case`Not Set`:return`NotSolved`;case`Load error`:case`Model error`:case`Presolve error`:case`Solve error`:case`Postsolve error`:case`Error`:return`Error`;case`Empty`:case`Unknown`:return`Unknown`}let n=t.toLowerCase();return n.includes(`infeasible`)&&n.includes(`unbounded`)?`Unknown`:n.includes(`infeasible`)?`Infeasible`:n.includes(`unbounded`)?`Unbounded`:n.includes(`time limit`)||n.includes(`timelimit`)?`TimeLimit`:n.includes(`iteration limit`)||n.includes(`iterationlimit`)?`IterationLimit`:n.includes(`error`)?`Error`:n===`optimal`?`Optimal`:`Unknown`}var Z=class e{static capabilities={supportsMIP:!0,supportsQP:!0};name=`HiGHS`;version=`1.15.3`;capabilities=e.capabilities;options;constructor(e={}){this.options=e}async solve(e,t,n={}){let r={...this.options,...n},{lpString:i,nameToVar:a,nameToConstraint:o}=t,{result:s,runTime:c}=await Se(i,r),l=Ce(s?.Status);if(l===`Infeasible`||l===`Unbounded`)return{status:l,objectiveValue:null,values:{},reducedCosts:{},duals:{},slacks:{},runTime:c,raw:s};let u=s.ObjectiveValue,d=typeof u==`number`?u+e.objective.constant:null,f={},p={},m={},h={};if(s.Columns)for(let[e,t]of Object.entries(s.Columns)){let n=a.get(e);if(n){let e=Math.abs(t.Primal)<1e-9?0:t.Primal;f[n.name]=e,t.Dual!==void 0&&(m[n.name]=Math.abs(t.Dual)<1e-9?0:t.Dual)}}if(s.Rows){let e=Array.isArray(s.Rows)?s.Rows:Object.values(s.Rows);for(let t of e){let e=t.Name,n=o.get(e);if(n&&(t.Dual!==void 0&&(p[n.name]=Math.abs(t.Dual)<1e-9?0:t.Dual),t.Primal!==void 0)){let e=n.rhs-t.Primal;h[n.name]=Math.abs(e)<1e-9?0:e}}}return{status:l,objectiveValue:d,values:f,reducedCosts:m,duals:p,slacks:h,runTime:c,raw:s}}},we=Z;function Te(){ie(`highs`,e=>new Z(e)),V(e=>new Z(e))}Te();var Ee=class{name;capabilities;options;constructor(e={}){this.name=e.name||`MockSolver`,this.capabilities=e.capabilities||{supportsMIP:!0,supportsQP:!0},this.options=e}async solve(e,t,n={}){let r={...this.options,...n};return r.delayMs&&r.delayMs>0&&await new Promise(e=>setTimeout(e,r.delayMs)),{status:r.status||`Optimal`,objectiveValue:r.objectiveValue??0,values:r.values||{},reducedCosts:r.reducedCosts,duals:r.duals,slacks:r.slacks,runTime:.001,raw:{mock:!0}}}};function De(){ie(`mock`,e=>new Ee(e))}De();var Oe=class{name;sense;objective;variables=[];constraints=[];boolVars=[];logicalConstraints=[];unsatCore=[];values=new Map;varMapByName=new Map;constrMapByName=new Map;status=`NotSolved`;objectiveValue=null;runTime=0;solution=null;solver=null;constructor(e={},t){let n;n=typeof e==`string`?{...t,name:e}:e,this.name=n.name||`OptimizationModel`,this.sense=f(n.sense),this.objective=new E,n.solver&&(this.solver=H(n.solver))}get vars(){return this.variables}get constrs(){return this.constraints}get numVars(){return this.variables.length}get numConstrs(){return this.constraints.length}createDomainVars(e,t,n,r){if(typeof n==`number`||Array.isArray(n)){let i=typeof t==`number`?Array.from({length:t},(e,t)=>t):t,a=typeof n==`number`?Array.from({length:n},(e,t)=>t):n,o=r||{},s=o.prefix||o.name||`x`,c={};for(let t of i){c[t]={};for(let n of a)c[t][n]=this.addVar({...o,type:e,name:`${s}_${t}_${n}`})}return c}if(typeof t==`string`){let r=n||{};return this.addVar({...r,type:e,name:t})}let i=n||{},a=i.prefix||i.name;if(typeof t==`number`){let n=[],r=a||`x`;for(let a=0;a<t;a++)n.push(this.addVar({...i,type:e,name:`${r}_${a}`}));return n}if(Array.isArray(t)||t&&typeof t[Symbol.iterator]==`function`){let n={};for(let r of t){let t=a?`${a}_${r}`:`${r}`;n[r]=this.addVar({...i,type:e,name:t})}return n}throw Error(`Invalid arguments provided for ${e.toLowerCase()} variable creation`)}binary(e,t,n){return this.createDomainVars(`Binary`,e,t,n)}integer(e,t,n){return this.createDomainVars(`Integer`,e,t,n)}continuous(e,t,n){return this.createDomainVars(`Continuous`,e,t,n)}addVar(e,t,n,r){let i;i=typeof e==`string`?{name:e,type:t,lb:n,ub:r}:e||{};let a=new A(i);if(this.varMapByName.has(a.name))throw Error(`Variable with name '${a.name}' already exists in model`);return this.variables.push(a),this.varMapByName.set(a.name,a),a}addVars(e,t,n){if(typeof t==`number`||Array.isArray(t)){let r=typeof e==`number`?Array.from({length:e},(e,t)=>t):e,i=typeof t==`number`?Array.from({length:t},(e,t)=>t):t,a=n||{},o=a.prefix||a.name||`x`,s={};for(let e of r){s[e]={};for(let t of i)s[e][t]=this.addVar({...a,name:`${o}_${e}_${t}`})}return s}let r=t||{},i=r.prefix||r.name;if(typeof e==`number`){let t=[],n=i||`x`;for(let i=0;i<e;i++)t.push(this.addVar({...r,name:`${n}_${i}`}));return t}{let t={};for(let n of e){let e=i?`${i}_${n}`:`${n}`;t[n]=this.addVar({...r,name:e})}return t}}addVars2D(e,t,n){let r={},i=n?.name||`x`;for(let a of e){r[a]={};for(let e of t)r[a][e]=this.addVar({...n,name:`${i}_${a}_${e}`})}return r}getVarByName(e){return this.varMapByName.get(e)}getConstraintByName(e){return this.constrMapByName.get(e)}setObjective(e,t){if(e instanceof C)throw Error("Cannot set objective to a constraint comparison (<=, >=, ==). Did you mean to use m.constrain(expr`... <= ...`)? For objectives, supply an unconstrained expression like expr`45 * ${x} + 80 * ${y}`.");t&&(this.sense=f(t)),this.objective=typeof e==`string`?N(e,e=>this.getVarByName(e)):typeof e==`number`?new E(new Map,e):e instanceof T||`terms`in e?e.clone():new E(new Map([[e,1]]),0)}maximize(e){this.setObjective(e,`Maximize`)}minimize(e){this.setObjective(e,`Minimize`)}constrain(e,t){if(Array.isArray(e)){for(let t of e)this.constrain(t);return this}if(e instanceof E)throw Error("Cannot add a linear expression without a comparison operator (<=, >=, ==) as a constraint. Use expr`... <= ...` or .le(), .ge(), .eq().");return this.addConstraint(e,t),this}getValues(e){if(e==null)return null;if(e instanceof A)return e.value;if(Array.isArray(e))return e.map(e=>this.getValues(e));if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=this.getValues(r);return t}return null}addBoolVar(e){let t=new h(e);return this.boolVars.push(t),t}addConstraint(e,t){if(e instanceof E)throw Error("Cannot add a linear expression without a comparison operator (<=, >=, ==) as a constraint. Use expr`... <= ...` or .le(), .ge(), .eq().");if(e instanceof m){let n=t||`lc_${this.logicalConstraints.length+1}`;return this.logicalConstraints.push({name:n,expr:e}),e}let n;if(typeof e==`string`?n=P(e,e=>this.getVarByName(e),t):(n=e,t&&(n.name=t)),this.constrMapByName.has(n.name))throw Error(`Constraint with name '${n.name}' already exists in model`);return this.constraints.push(n),this.constrMapByName.set(n.name,n),n}addConstr(e,t){return this.addConstraint(e,t)}addConstrs(e){return e.map(e=>this.addConstraint(e))}add(e,t){if(Array.isArray(e)){for(let t of e)this.add(t);return this}return e instanceof A?(this.varMapByName.has(e.name)||(this.variables.push(e),this.varMapByName.set(e.name,e)),this):(this.addConstraint(e,t),this)}indicator(e,t,n={}){if(!(`sense`in t)||!(`lhs`in t))throw Error(`Invalid constraint expression passed to indicator(). Expression must include a comparison operator (<=, >=, ==).`);let r=t,i=n.activeValue===void 0?1:n.activeValue,a=n.M===void 0?1e5:n.M,o=n.name||`ind_${e.name}_${r.name}`,s=[],{lhs:c,sense:l,rhs:u}=r;if(i===1){if(l===`<=`||l===`==`){let t=this.addConstraint(c.add(e.mul(a)).le(u+a),l===`==`?`${o}_le`:o);s.push(t)}if(l===`>=`||l===`==`){let t=this.addConstraint(c.sub(e.mul(a)).ge(u-a),l===`==`?`${o}_ge`:o);s.push(t)}}else{if(l===`<=`||l===`==`){let t=this.addConstraint(c.sub(e.mul(a)).le(u),l===`==`?`${o}_le`:o);s.push(t)}if(l===`>=`||l===`==`){let t=this.addConstraint(c.add(e.mul(a)).ge(u),l===`==`?`${o}_ge`:o);s.push(t)}}return s}addIndicator(e,t,n={}){return this.indicator(e,t,n)}toLpString(){let{lpString:e}=te({name:this.name,sense:this.sense,objective:this.objective,constraints:this.constraints,variables:this.variables});return e}async optimize(e,t){let n,r;if(e&&typeof e==`object`&&`solve`in e&&typeof e.solve==`function`?(n=e,r=t||{}):typeof e==`function`?(n=new e(t),r=t||{}):typeof e==`string`?(n=H(e,t),r=t||{}):(r={...e},r.solver?(n=H(r.solver,r),delete r.solver):n=this.solver||H()),this.objective instanceof T&&this.objective.quadTerms.size>0&&n.capabilities?.supportsQP===!1)throw Error(`Solver "${n.name}" does not support quadratic objectives (QP). Please use a QP-capable solver such as HiGHS or Clarabel.`);let i={name:this.name,sense:this.sense,objective:this.objective,constraints:this.constraints,variables:this.variables,logicalConstraints:this.logicalConstraints,boolVars:this.boolVars},a=te(i),o=await n.solve(i,a,r);this.runTime=o.runTime??0,this.status=o.status,this.objectiveValue=o.objectiveValue??null;let s={},c={},l={},u={};this.values.clear();for(let e of this.variables)e.value=null,e.reducedCost=null;for(let e of this.boolVars)e.value=null;for(let e of this.constraints)e.dual=null,e.slack=null;if(a?.nameToVar)for(let e of a.nameToVar.values())e.value=null,e.reducedCost=null;if(a?.nameToConstraint)for(let e of a.nameToConstraint.values())e.dual=null,e.slack=null;if(o.values&&o.status!==`Infeasible`&&o.status!==`Unbounded`){for(let[e,t]of Object.entries(o.values))if(typeof t==`number`&&!Number.isNaN(t)){this.values.set(e,t);let n=this.getVarByName(e)||a.nameToVar.get(e);n&&(n.value=t,s[n.name]=t);let r=this.boolVars.find(t=>t.name===e);r&&(r.value=!!t)}}if(o.reducedCosts)for(let[e,t]of Object.entries(o.reducedCosts)){let n=this.getVarByName(e)||a.nameToVar.get(e);n&&(n.reducedCost=t,l[n.name]=t)}if(o.duals)for(let[e,t]of Object.entries(o.duals)){let n=this.getConstraintByName(e)||a.nameToConstraint.get(e);n&&(n.dual=t,c[n.name]=t)}if(o.slacks)for(let[e,t]of Object.entries(o.slacks)){let n=this.getConstraintByName(e)||a.nameToConstraint.get(e);n&&(n.slack=t,u[n.name]=t)}return this.solution={status:this.status,objectiveValue:this.objectiveValue,values:s,duals:c,reducedCosts:l,slacks:u,runTime:this.runTime,raw:o.raw},this.status}async solve(e,t){return this.optimize(e,t)}async check(e,t){let n,r;if(e&&typeof e==`object`&&`solve`in e&&typeof e.solve==`function`?(n=e,r=t||{}):typeof e==`function`?(n=new e(t),r=t||{}):typeof e==`string`?(n=H(e,t),r=t||{}):(r={...e},r.solver?(n=H(r.solver,r),delete r.solver):n=this.solver||H()),this.logicalConstraints.length>0&&n.capabilities?.supportsSMT!==!0)throw Error(`Solver "${n.name}" does not support SMT / logical constraints (or, implies, not, xor). Please use an SMT-capable solver such as Z3.`);if(typeof n.check==`function`){let e=await n.check({name:this.name,variables:this.variables,boolVars:this.boolVars,constraints:this.constraints,logicalConstraints:this.logicalConstraints},r);this.status=e.status,this.runTime=e.runTime??0,this.unsatCore=e.unsatCore||[],this.values.clear();for(let e of this.variables)e.value=null;for(let e of this.boolVars)e.value=null;if(e.values&&e.status===`Sat`)for(let[t,n]of Object.entries(e.values)){this.values.set(t,n);let e=this.getVarByName(t);e&&typeof n==`number`&&(e.value=n);let r=this.boolVars.find(e=>e.name===t);r&&(r.value=!!n)}return e}let i=this.objective,a=this.sense;try{this.objective=new E,this.sense=`Minimize`;let e=await this.optimize(n,r),t=e===`Optimal`||e===`Feasible`,i=e===`Infeasible`,a={};if(t){for(let e of this.variables)e.value!==null&&(a[e.name]=e.value);for(let e of this.boolVars)e.value!==null&&(a[e.name]=e.value)}return{status:t?`Sat`:i?`Unsat`:`Unknown`,values:a,runTime:this.runTime}}finally{this.objective=i,this.sense=a}}};return e.BoolExpr=m,e.BoolOp=g,e.BoolVar=h,e.Constraint=C,e.HiGHS=we,e.HighsSolver=Z,e.LinExpr=E,e.MockSolver=Ee,e.Model=Oe,e.OFFICIAL_HIGHS_CDN_WASM_URL=de,e.QuadExpr=T,e.Var=A,e.and=_,e.c=I,e.dot=D,e.expr=L,e.generateLpString=te,e.getHighs=_e,e.getHighsWasmUrl=me,e.getSolver=H,e.implies=b,e.isValidWasmHeader=he,e.listAvailableSolvers=U,e.normalizeSense=f,e.not=y,e.or=v,e.parseConstraint=P,e.parseExpr=N,e.probeWasmUrl=ge,e.registerSolver=ie,e.resolveBrowserWasmUrl=J,e.setDefaultSolver=V,e.setHighsWasmUrl=pe,e.solveLpWithHighs=Y,e.sum=ee,e.xor=x,e})({});
|
|
3
|
+
`,nameToVar:a,nameToConstraint:s}}var _e=Symbol.for(`washi.solverRegistry`),ve=Symbol.for(`washi.defaultSolverFactory`),J=globalThis;J[_e]||(J[_e]=new Map);var ye=J[_e];function Y(e,t){ye.set(e.toLowerCase(),t)}function be(e){if(typeof e==`string`){let t=ye.get(e.toLowerCase());if(!t)throw Error(`Solver '${e}' is not registered.`);J[ve]=t}else J[ve]=typeof e==`function`?e:()=>e}function xe(e,t){if(!e){let e=J[ve]||ye.get(`highs`);if(!e)throw Error(`No default solver available. Available solvers: ${Se().join(`, `)}`);return e(t)}if(typeof e==`string`){let n=e.toLowerCase(),r=ye.get(n);if(!r)throw Error(n===`glpk`?`Solver 'glpk' not found. Available solvers: ${Se().join(`, `)}. Please import '@ohtaman/washi/solvers/glpk' before selecting this solver.`:n===`z3`?`Solver 'z3' not found. Available solvers: ${Se().join(`, `)}. Please import '@ohtaman/washi/solvers/z3' before selecting this solver.`:`Solver '${e}' not found. Available solvers: ${Se().join(`, `)}`);return r(t)}return e}function Se(){return Array.from(ye.keys())}var Ce=typeof document<`u`?document.currentScript?.src:null,we=Ce?new URL(`.`,Ce).href:null;function Te(e){if(!we)throw Error(`[WaSHI] Load the browser IIFE using an external script src, or use the browser ESM build.`);return new URL(e,we).href}function Ee(){return Te(`highs.wasm`)}var De=c(((e,t)=>{var n=(()=>{var e=globalThis.document?.currentScript?.src;return async function(t={}){var n=t,r=!!globalThis.window,i=!!globalThis.WorkerGlobalScope;let a=n.print,o=n.printErr;n.print=e=>{a&&a(e)},n.printErr=e=>{o&&o(e)};var s=`./this.program`,c=(e,t)=>{throw t};i&&(e=self.location.href);var l=``;function u(e){return n.locateFile?n.locateFile(e,l):l+e}var d,f;if(r||i){try{l=new URL(`.`,e).href}catch{}i&&(f=e=>{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}),d=async e=>{if(v(e))return new Promise((t,n)=>{var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=()=>{if(r.status==200||r.status==0&&r.response){t(r.response);return}n(r.status)},r.onerror=n,r.send(null)});var t=await fetch(e,{credentials:`same-origin`});if(t.ok)return t.arrayBuffer();throw Error(t.status+` : `+t.url)}}var p=console.log.bind(console),m=console.error.bind(console),h,g=!1,_,v=e=>e.startsWith(`file://`);function y(){return Zt.buffer}function b(){if(!L?.buffer?.resizable){var e=y();L=new Int8Array(e),P=new Int16Array(e),V=new Uint8Array(e),ee=new Uint16Array(e),F=new Int32Array(e),B=new Uint32Array(e),R=new Float32Array(e),z=new Float64Array(e),I=new BigInt64Array(e),te=new BigUint64Array(e)}}function x(){var e=n.preRun;e&&(typeof e==`function`&&(e=[e]),H.push(...e)),ne(H)}function S(){!n.noFSInit&&!X.initialized&&X.init(),J.init(),nn.v(),X.ignorePermissions=!1}function C(){var e=n.postRun;e&&(typeof e==`function`&&(e=[e]),re.push(...e)),ne(re)}function w(e){throw n.onAbort?.(e),e=`Aborted(${e})`,m(e),g=!0,e+=`. Build with -sASSERTIONS for more info.`,new WebAssembly.RuntimeError(e)}var T;function E(){return u(`highs.wasm`)}function D(e){if(f)return f(e);throw`both async and sync fetching of the wasm failed`}async function O(e){if(!h)try{var t=await d(e);return new Uint8Array(t)}catch{}return D(e)}async function k(e,t){try{var n=await O(e);return await WebAssembly.instantiate(n,t)}catch(e){m(`failed to asynchronously prepare wasm: ${e}`),w(e)}}async function A(e,t,n){if(!e&&!v(t))try{var r=fetch(t,{credentials:`same-origin`});return await WebAssembly.instantiateStreaming(r,n)}catch(e){m(`wasm streaming compile failed: ${e}`),m(`falling back to ArrayBuffer instantiation`)}return k(t,n)}function j(){return{a:en}}async function M(){function e(e){return nn=e.exports,$t(nn),b(),nn}function t(t){return e(t.instance)}var r=j(),i=n.instantiateWasm;return i?new Promise(t=>{i(r,n=>t(e(n)))}):(T??=E(),t(await A(h,T,r)))}class N{name=`ExitStatus`;constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var P,F,I,L,R,z,ee,B,te,V,ne=e=>{for(;e.length>0;)e.shift()(n)},re=[],H=[],U=!0,W=e=>Jt(e),ie=()=>Xt();class ae{constructor(e){this.excPtr=e,this.ptr=e-24}set_type(e){B[this.ptr+4>>2]=e}get_type(){return B[this.ptr+4>>2]}set_destructor(e){B[this.ptr+8>>2]=e}get_destructor(){return B[this.ptr+8>>2]}set_caught(e){e=+!!e,L[this.ptr+12]=e}get_caught(){return L[this.ptr+12]!=0}set_rethrown(e){e=+!!e,L[this.ptr+13]=e}get_rethrown(){return L[this.ptr+13]!=0}init(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)}set_adjusted_ptr(e){B[this.ptr+16>>2]=e}get_adjusted_ptr(){return B[this.ptr+16>>2]}}var oe=0,se=(e,t,n)=>{new ae(e).init(t,n),oe++,w()},ce=()=>{var e=F[Z.varargs>>2];return Z.varargs+=4,e},G=ce,K={isAbs:e=>e.charAt(0)===`/`,splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];i===`.`?e.splice(r,1):i===`..`?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n;n--)e.unshift(`..`);return e},normalize:e=>{var t=K.isAbs(e),n=e.slice(-1)===`/`;return e=K.normalizeArray(e.split(`/`).filter(e=>!!e),!t).join(`/`),!e&&!t&&(e=`.`),e&&n&&(e+=`/`),(t?`/`:``)+e},dirname:e=>{var t=K.splitPath(e),n=t[0],r=t[1];return!n&&!r?`.`:(r&&=r.slice(0,-1),n+r)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>K.normalize(e.join(`/`)),join2:(e,t)=>K.normalize(e+`/`+t)},le=()=>e=>(crypto.getRandomValues(e),0),ue=e=>(ue=le())(e),de={resolve:(...e)=>{for(var t=``,n=!1,r=e.length-1;r>=-1&&!n;r--){var i=r>=0?e[r]:X.cwd();if(typeof i!=`string`)throw TypeError(`Arguments to path.resolve must be strings`);if(!i)return``;t=i+`/`+t,n=K.isAbs(i)}return t=K.normalizeArray(t.split(`/`).filter(e=>!!e),!n).join(`/`),(n?`/`:``)+t||`.`},relative:(e,t)=>{e=de.resolve(e).slice(1),t=de.resolve(t).slice(1);function n(e){for(var t=0;t<e.length&&e[t]===``;t++);for(var n=e.length-1;n>=0&&e[n]===``;n--);return t>n?[]:e.slice(t,n-t+1)}for(var r=n(e.split(`/`)),i=n(t.split(`/`)),a=Math.min(r.length,i.length),o=a,s=0;s<a;s++)if(r[s]!==i[s]){o=s;break}for(var c=[],s=o;s<r.length;s++)c.push(`..`);return c=c.concat(i.slice(o)),c.join(`/`)}},q=globalThis.TextDecoder&&new TextDecoder,fe=(e,t,n,r)=>{var i=t+n;if(r)return i;for(;e[t]&&!(t>=i);)++t;return t},pe=(e,t=0,n,r)=>{var i=fe(e,t,n,r);if(i-t>16&&e.buffer&&q)return q.decode(e.subarray(t,i));for(var a=``;t<i;){var o=e[t++];if(!(o&128)){a+=String.fromCharCode(o);continue}var s=e[t++]&63;if((o&224)==192){a+=String.fromCharCode((o&31)<<6|s);continue}var c=e[t++]&63;if(o=(o&240)==224?(o&15)<<12|s<<6|c:(o&7)<<18|s<<12|c<<6|e[t++]&63,o<65536)a+=String.fromCharCode(o);else{var l=o-65536;a+=String.fromCharCode(55296|l>>10,56320|l&1023)}}return a},me=[],he=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r<=127?t++:r<=2047?t+=2:r>=55296&&r<=57343?(t+=4,++n):t+=3}return t},ge=(e,t,n,r)=>{if(!(r>0))return 0;for(var i=n,a=n+r-1,o=0;o<e.length;++o){var s=e.codePointAt(o);if(s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|s&63}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|s&63}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|s&63,o++}}return t[n]=0,n-i},_e=(e,t,n)=>{var r=n>0?n:he(e)+1,i=Array(r),a=ge(e,i,0,i.length);return t&&(i.length=a),i},ve=()=>{if(!me.length){var e=null;if(globalThis.window?.prompt&&(e=window.prompt(`Input: `),e!==null&&(e+=`
|
|
4
|
+
`)),!e)return null;me=_e(e,!0)}return me.shift()},J={ttys:[],init(){},shutdown(){},register(e,t){J.ttys[e]={input:[],output:[],ops:t},X.registerDevice(e,J.stream_ops)},stream_ops:{open(e){var t=J.ttys[e.node.rdev];if(!t)throw new X.ErrnoError(43);e.tty=t,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,t,n,r,i){if(!e.tty||!e.tty.ops.get_char)throw new X.ErrnoError(60);for(var a=0,o=0;o<r;o++){var s;try{s=e.tty.ops.get_char(e.tty)}catch{throw new X.ErrnoError(29)}if(s===void 0&&a===0)throw new X.ErrnoError(6);if(s==null)break;a++,t[n+o]=s}return a&&(e.node.atime=Date.now()),a},write(e,t,n,r,i){if(!e.tty||!e.tty.ops.put_char)throw new X.ErrnoError(60);try{for(var a=0;a<r;a++)e.tty.ops.put_char(e.tty,t[n+a])}catch{throw new X.ErrnoError(29)}return r&&(e.node.mtime=e.node.ctime=Date.now()),a}},default_tty_ops:{get_char(e){return ve()},put_char(e,t){t===null||t===10?(p(pe(e.output)),e.output=[]):t!=0&&e.output.push(t)},fsync(e){e.output?.length>0&&(p(pe(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,t,n){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,t){t===null||t===10?(m(pe(e.output)),e.output=[]):t!=0&&e.output.push(t)},fsync(e){e.output?.length>0&&(m(pe(e.output)),e.output=[])}}},ye=e=>{w()},Y={ops_table:null,mount(e){return Y.createNode(null,`/`,16895,0)},createNode(e,t,n,r){if(X.isBlkdev(n)||X.isFIFO(n))throw new X.ErrnoError(63);Y.ops_table||={dir:{node:{getattr:Y.node_ops.getattr,setattr:Y.node_ops.setattr,lookup:Y.node_ops.lookup,mknod:Y.node_ops.mknod,rename:Y.node_ops.rename,unlink:Y.node_ops.unlink,rmdir:Y.node_ops.rmdir,readdir:Y.node_ops.readdir,symlink:Y.node_ops.symlink},stream:{llseek:Y.stream_ops.llseek}},file:{node:{getattr:Y.node_ops.getattr,setattr:Y.node_ops.setattr},stream:{llseek:Y.stream_ops.llseek,read:Y.stream_ops.read,write:Y.stream_ops.write,mmap:Y.stream_ops.mmap,msync:Y.stream_ops.msync}},link:{node:{getattr:Y.node_ops.getattr,setattr:Y.node_ops.setattr,readlink:Y.node_ops.readlink},stream:{}},chrdev:{node:{getattr:Y.node_ops.getattr,setattr:Y.node_ops.setattr},stream:X.chrdev_stream_ops}};var i=X.createNode(e,t,n,r);return X.isDir(i.mode)?(i.node_ops=Y.ops_table.dir.node,i.stream_ops=Y.ops_table.dir.stream,i.contents={}):X.isFile(i.mode)?(i.node_ops=Y.ops_table.file.node,i.stream_ops=Y.ops_table.file.stream,i.usedBytes=0,i.contents=Y.emptyFileContents??=new Uint8Array):X.isLink(i.mode)?(i.node_ops=Y.ops_table.link.node,i.stream_ops=Y.ops_table.link.stream):X.isChrdev(i.mode)&&(i.node_ops=Y.ops_table.chrdev.node,i.stream_ops=Y.ops_table.chrdev.stream),i.atime=i.mtime=i.ctime=Date.now(),e&&(e.contents[t]=i,e.atime=e.mtime=e.ctime=i.atime),i},getFileDataAsTypedArray(e){return e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,t){var n=e.contents.length;if(!(n>=t)){t=Math.max(t,n*(n<1048576?2:1.125)>>>0),n&&(t=Math.max(t,256));var r=Y.getFileDataAsTypedArray(e);e.contents=new Uint8Array(t),e.contents.set(r)}},resizeFileStorage(e,t){if(e.usedBytes!=t){var n=e.contents;e.contents=new Uint8Array(t),e.contents.set(n.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=X.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,t.size=X.isDir(e.mode)?4096:X.isFile(e.mode)?e.usedBytes:X.isLink(e.mode)?e.link.length:0,t.atime=new Date(e.atime),t.mtime=new Date(e.mtime),t.ctime=new Date(e.ctime),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){for(let n of[`mode`,`atime`,`mtime`,`ctime`])t[n]!=null&&(e[n]=t[n]);t.size!==void 0&&Y.resizeFileStorage(e,t.size)},lookup(e,t){throw Y.doesNotExistError||(Y.doesNotExistError=new X.ErrnoError(44),Y.doesNotExistError.stack=`<generic error, no stack>`),Y.doesNotExistError},mknod(e,t,n,r){return Y.createNode(e,t,n,r)},rename(e,t,n){var r;try{r=X.lookupNode(t,n)}catch{}if(r){if(X.isDir(e.mode))for(var i in r.contents)throw new X.ErrnoError(55);X.hashRemoveNode(r)}delete e.parent.contents[e.name],t.contents[n]=e,e.name=n,t.ctime=t.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,t){delete e.contents[t],e.ctime=e.mtime=Date.now()},rmdir(e,t){for(var n in X.lookupNode(e,t).contents)throw new X.ErrnoError(55);delete e.contents[t],e.ctime=e.mtime=Date.now()},readdir(e){return[`.`,`..`,...Object.keys(e.contents)]},symlink(e,t,n){var r=Y.createNode(e,t,41471,0);return r.link=n,r},readlink(e){if(!X.isLink(e.mode))throw new X.ErrnoError(28);return e.link}},stream_ops:{read(e,t,n,r,i){var a=e.node.contents;if(i>=e.node.usedBytes)return 0;var o=Math.min(e.node.usedBytes-i,r);return t.set(a.subarray(i,i+o),n),o},write(e,t,n,r,i,a){if(t.buffer===L.buffer&&(a=!1),!r)return 0;var o=e.node;return o.mtime=o.ctime=Date.now(),a?(o.contents=t.subarray(n,n+r),o.usedBytes=r):o.usedBytes===0&&i===0?(o.contents=t.slice(n,n+r),o.usedBytes=r):(Y.expandFileStorage(o,i+r),o.contents.set(t.subarray(n,n+r),i),o.usedBytes=Math.max(o.usedBytes,i+r)),r},llseek(e,t,n){var r=t;if(n===1?r+=e.position:n===2&&X.isFile(e.node.mode)&&(r+=e.node.usedBytes),r<0)throw new X.ErrnoError(28);return r},mmap(e,t,n,r,i){if(!X.isFile(e.node.mode))throw new X.ErrnoError(43);var a,o,s=e.node.contents;if(!(i&2)&&s.buffer===L.buffer)o=!1,a=s.byteOffset;else{if(o=!0,a=ye(t),!a)throw new X.ErrnoError(48);s&&((n>0||n+t<s.length)&&(s=s.subarray?s.subarray(n,n+t):Array.prototype.slice.call(s,n,n+t)),L.set(s,a))}return{ptr:a,allocated:o}},msync(e,t,n,r,i){return Y.stream_ops.write(e,t,0,r,n,!1),0}}},be=e=>{if(typeof e!=`string`)return e;var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(t===void 0)throw Error(`Unknown file open mode: ${e}`);return t},xe=e=>(typeof e==`string`&&(e=_e(e,!0)),e.subarray||(e=new Uint8Array(e)),e),Se=(e,t)=>{var n=0;return e&&(n|=365),t&&(n|=146),n},Ce=async e=>{var t=await d(e);return new Uint8Array(t)},we=(...e)=>X.createDataFile(...e),Te=e=>e,Ee=null,De=async()=>Ee,Oe=0,ke=null,Ae=e=>{Oe--,n.monitorRunDependencies?.(Oe),Oe||ke()},je=e=>{Oe||(Ee=new Promise(e=>ke=e)),Oe++,n.monitorRunDependencies?.(Oe)},Me=[],Ne=async(e,t)=>{typeof Browser<`u`&&Browser.init();for(var n of Me)if(n.canHandle(t))return n.handle(e,t);return e},Pe=async(e,t,n,r,i,a,o,s)=>{var c=t?de.resolve(K.join2(e,t)):e,l=Te(`cp ${c}`);je(l);try{var u=n;typeof n==`string`&&(u=await Ce(n)),u=await Ne(u,c),s?.(),a||we(e,t,u,r,i,o)}finally{Ae(l)}},Fe=(e,t,n,r,i,a,o,s,c,l)=>{Pe(e,t,n,r,i,s,c,l).then(a).catch(o)},X={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:`/`,initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,ErrnoError:class{name=`ErrnoError`;constructor(e){this.errno=e}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!=1}get isWrite(){return!!(this.flags&2097155)}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,t,n,r){e||=this,this.parent=e,this.mount=e.mount,this.id=X.nextInode++,this.name=t,this.mode=n,this.rdev=r,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return X.isDir(this.mode)}get isDevice(){return X.isChrdev(this.mode)}addListener(e,t=!1){var n={cb:e,exclusive:t},r=this.listeners??=new Set;return r.add(n),{listeners:r,entry:n}}notifyListeners(e){if(this.listeners){var t;for(var n of this.listeners)n.exclusive?(t||=[]).push(n):n.cb(e);if(t){var r=(this.exclTurn||0)%t.length;this.exclTurn=r+1,t[r].cb(e)}}}},lookupPath(e,t={}){if(!e)throw new X.ErrnoError(44);t.follow_mount??=!0,K.isAbs(e)||(e=X.cwd()+`/`+e);linkloop:for(var n=0;n<40;n++){for(var r=e.split(`/`).filter(e=>!!e),i=X.root,a=`/`,o=0;o<r.length;o++){var s=o===r.length-1;if(s&&t.parent)break;if(r[o]!==`.`){if(r[o]===`..`){if(a=K.dirname(a),X.isRoot(i)){e=a+`/`+r.slice(o+1).join(`/`),n--;continue linkloop}i=i.parent;continue}a=K.join2(a,r[o]);try{i=X.lookupNode(i,r[o])}catch(e){if(e?.errno===44&&s&&t.noent_okay)return{path:a};throw e}if(X.isMountpoint(i)&&(!s||t.follow_mount)&&(i=i.mounted.root),X.isLink(i.mode)&&(!s||t.follow)){if(!i.node_ops.readlink)throw new X.ErrnoError(52);var c=i.node_ops.readlink(i);K.isAbs(c)||(c=K.dirname(a)+`/`+c),e=c+`/`+r.slice(o+1).join(`/`);continue linkloop}}}return{path:a,node:i}}throw new X.ErrnoError(32)},getPath(e){for(var t;;){if(X.isRoot(e)){var n=e.mount.mountpoint;return t?n[n.length-1]===`/`?n+t:`${n}/${t}`:n}t=t?`${e.name}/${t}`:e.name,e=e.parent}},hashName(e,t){for(var n=0,r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r)|0;return(e+n>>>0)%X.nameTable.length},hashAddNode(e){var t=X.hashName(e.parent.id,e.name);e.name_next=X.nameTable[t],X.nameTable[t]=e},hashRemoveNode(e){var t=X.hashName(e.parent.id,e.name);if(X.nameTable[t]===e)X.nameTable[t]=e.name_next;else for(var n=X.nameTable[t];n;){if(n.name_next===e){n.name_next=e.name_next;break}n=n.name_next}},lookupNode(e,t){var n=X.mayLookup(e);if(n)throw new X.ErrnoError(n);for(var r=X.hashName(e.id,t),i=X.nameTable[r];i;i=i.name_next){var a=i.name;if(i.parent.id===e.id&&a===t)return i}return X.lookup(e,t)},createNode(e,t,n,r){var i=new X.FSNode(e,t,n,r);return X.hashAddNode(i),i},destroyNode(e){X.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)==32768},isDir(e){return(e&61440)==16384},isLink(e){return(e&61440)==40960},isChrdev(e){return(e&61440)==8192},isBlkdev(e){return(e&61440)==24576},isFIFO(e){return(e&61440)==4096},isSocket(e){return(e&49152)==49152},flagsToPermissionString(e){var t=[`r`,`w`,`rw`][e&3];return e&512&&(t+=`w`),t},nodePermissions(e,t){return X.ignorePermissions?0:t.includes(`r`)&&!(e.mode&292)||t.includes(`w`)&&!(e.mode&146)||t.includes(`x`)&&!(e.mode&73)?2:0},mayLookup(e){return X.isDir(e.mode)?X.nodePermissions(e,`x`)||(e.node_ops.lookup?0:2):54},mayCreate(e,t){if(!X.isDir(e.mode))return 54;try{return X.lookupNode(e,t),20}catch{}return X.nodePermissions(e,`wx`)},mayDelete(e,t,n){var r;try{r=X.lookupNode(e,t)}catch(e){return e.errno}var i=X.nodePermissions(e,`wx`);if(i)return i;if(n){if(!X.isDir(r.mode))return 54;if(X.isRoot(r)||X.getPath(r)===X.cwd())return 10}else if(X.isDir(r.mode))return 31;return 0},mayOpen(e,t){if(!e)return 44;if(X.isLink(e.mode))return 32;var n=X.flagsToPermissionString(t);return X.isDir(e.mode)&&(n!==`r`||t&576)?31:X.nodePermissions(e,n)},checkOpExists(e,t){if(!e)throw new X.ErrnoError(t);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=X.MAX_OPEN_FDS;e++)if(!X.streams[e])return e;throw new X.ErrnoError(33)},getStreamChecked(e){var t=X.getStream(e);if(!t)throw new X.ErrnoError(8);return t},getStream:e=>X.streams[e],createStream(e,t=-1){return e=Object.assign(new X.FSStream,e),t==-1&&(t=X.nextfd()),e.fd=t,X.streams[t]=e,e},closeStream(e){X.streams[e]=null},dupStream(e,t=-1){var n=X.createStream(e,t);return n.stream_ops?.dup?.(n),n},doSetAttr(e,t,n){var r=e?.stream_ops.setattr,i=r?e:t;r??=t.node_ops.setattr,X.checkOpExists(r,63);try{r(i,n)}catch(e){throw e instanceof RangeError?new X.ErrnoError(22):e}},chrdev_stream_ops:{open(e){e.stream_ops=X.getDevice(e.node.rdev).stream_ops,e.stream_ops.open?.(e)},llseek(){throw new X.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,t)=>e<<8|t,registerDevice(e,t){X.devices[e]={stream_ops:t}},getDevice:e=>X.devices[e],getMounts(e){for(var t=[],n=[e];n.length;){var r=n.pop();t.push(r),n.push(...r.mounts)}return t},syncfs(e,t){typeof e==`function`&&(t=e,e=!1),X.syncFSRequests++,X.syncFSRequests>1&&m(`warning: ${X.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var n=X.getMounts(X.root.mount),r=0;function i(e){return X.syncFSRequests--,t(e)}function a(e){if(e)return a.errored?void 0:(a.errored=!0,i(e));++r>=n.length&&i(null)}for(var o of n)o.type.syncfs?o.type.syncfs(o,e,a):a(null)},mount(e,t,n){var r=n===`/`,i=!n,a;if(r&&X.root)throw new X.ErrnoError(10);if(!r&&!i){var o=X.lookupPath(n,{follow_mount:!1});if(n=o.path,a=o.node,X.isMountpoint(a))throw new X.ErrnoError(10);if(!X.isDir(a.mode))throw new X.ErrnoError(54)}var s={type:e,opts:t,mountpoint:n,mounts:[]},c=e.mount(s);return c.mount=s,s.root=c,r?X.root=c:a&&(a.mounted=s,a.mount&&a.mount.mounts.push(s)),c},unmount(e){var t=X.lookupPath(e,{follow_mount:!1});if(!X.isMountpoint(t.node))throw new X.ErrnoError(28);var n=t.node,r=n.mounted,i=X.getMounts(r);for(var[a,o]of Object.entries(X.nameTable))for(;o;){var s=o.name_next;i.includes(o.mount)&&X.destroyNode(o),o=s}n.mounted=null;var c=n.mount.mounts.indexOf(r);n.mount.mounts.splice(c,1)},lookup(e,t){return e.node_ops.lookup(e,t)},mknod(e,t,n){var r=X.lookupPath(e,{parent:!0}).node,i=K.basename(e);if(!i)throw new X.ErrnoError(28);if(i===`.`||i===`..`)throw new X.ErrnoError(20);var a=X.mayCreate(r,i);if(a)throw new X.ErrnoError(a);if(!r.node_ops.mknod)throw new X.ErrnoError(63);return r.node_ops.mknod(r,i,t,n)},statfs(e){return X.statfsNode(X.lookupPath(e,{follow:!0}).node)},statfsStream(e){return X.statfsNode(e.node)},statfsNode(e){var t={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:X.nextInode,ffree:X.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(t,e.node_ops.statfs(e.mount.opts.root)),t},create(e,t=438){return t&=4095,t|=32768,X.mknod(e,t,0)},mkdir(e,t=511){return t&=1023,t|=16384,X.mknod(e,t,0)},mkdirTree(e,t){var n=e.split(`/`),r=``;for(var i of n)if(i){(r||K.isAbs(e))&&(r+=`/`),r+=i;try{X.mkdir(r,t)}catch(e){if(e.errno!=20)throw e}}},mkdev(e,t,n){return n===void 0&&(n=t,t=438),t|=8192,X.mknod(e,t,n)},symlink(e,t){if(!de.resolve(e))throw new X.ErrnoError(44);var n=X.lookupPath(t,{parent:!0}).node;if(!n)throw new X.ErrnoError(44);var r=K.basename(t),i=X.mayCreate(n,r);if(i)throw new X.ErrnoError(i);if(!n.node_ops.symlink)throw new X.ErrnoError(63);return n.node_ops.symlink(n,r,e)},link(e,t,n){var r=X.lookupPath(t,{parent:!0}).node;if(!r)throw new X.ErrnoError(44);var i=K.basename(t),a=X.mayCreate(r,i);if(a)throw new X.ErrnoError(a);if(!r.node_ops.link)throw new X.ErrnoError(34);return r.node_ops.link(r,i,e,n)},rename(e,t){var n=K.dirname(e),r=K.dirname(t),i=K.basename(e),a=K.basename(t),o=X.lookupPath(e,{parent:!0}),s=o.node,c;if(o=X.lookupPath(t,{parent:!0}),c=o.node,!s||!c)throw new X.ErrnoError(44);if(s.mount!==c.mount)throw new X.ErrnoError(75);var l=X.lookupNode(s,i),u=de.relative(e,r);if(u.charAt(0)!==`.`)throw new X.ErrnoError(28);if(u=de.relative(t,n),u.charAt(0)!==`.`)throw new X.ErrnoError(55);var d;try{d=X.lookupNode(c,a)}catch{}if(l!==d){var f=X.isDir(l.mode),p=X.mayDelete(s,i,f);if(p||(p=d?X.mayDelete(c,a,f):X.mayCreate(c,a),p))throw new X.ErrnoError(p);if(!s.node_ops.rename)throw new X.ErrnoError(63);if(X.isMountpoint(l)||d&&X.isMountpoint(d))throw new X.ErrnoError(10);if(c!==s&&(p=X.nodePermissions(s,`w`),p))throw new X.ErrnoError(p);X.hashRemoveNode(l);try{s.node_ops.rename(l,c,a),l.parent=c}catch(e){throw e}finally{X.hashAddNode(l)}}},rmdir(e){var t=X.lookupPath(e,{parent:!0}).node,n=K.basename(e),r=X.lookupNode(t,n),i=X.mayDelete(t,n,!0);if(i)throw new X.ErrnoError(i);if(!t.node_ops.rmdir)throw new X.ErrnoError(63);if(X.isMountpoint(r))throw new X.ErrnoError(10);t.node_ops.rmdir(t,n),X.destroyNode(r)},readdir(e){var t=X.lookupPath(e,{follow:!0}).node;return X.checkOpExists(t.node_ops.readdir,54)(t)},unlink(e){var t=X.lookupPath(e,{parent:!0}).node;if(!t)throw new X.ErrnoError(44);var n=K.basename(e),r=X.lookupNode(t,n),i=X.mayDelete(t,n,!1);if(i)throw new X.ErrnoError(i);if(!t.node_ops.unlink)throw new X.ErrnoError(63);if(X.isMountpoint(r))throw new X.ErrnoError(10);t.node_ops.unlink(t,n),X.destroyNode(r)},readlink(e){var t=X.lookupPath(e).node;if(!t)throw new X.ErrnoError(44);if(!t.node_ops.readlink)throw new X.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,t){var n=X.lookupPath(e,{follow:!t}).node;return X.checkOpExists(n.node_ops.getattr,63)(n)},fstat(e){var t=X.getStreamChecked(e),n=t.node,r=t.stream_ops.getattr,i=r?t:n;return r??=n.node_ops.getattr,X.checkOpExists(r,63),r(i)},lstat(e){return X.stat(e,!0)},doChmod(e,t,n,r){X.doSetAttr(e,t,{mode:n&4095|t.mode&-4096,ctime:Date.now(),dontFollow:r})},chmod(e,t,n){var r=typeof e==`string`?X.lookupPath(e,{follow:!n}).node:e;X.doChmod(null,r,t,n)},lchmod(e,t){X.chmod(e,t,!0)},fchmod(e,t){var n=X.getStreamChecked(e);X.doChmod(n,n.node,t,!1)},doChown(e,t,n){X.doSetAttr(e,t,{timestamp:Date.now(),dontFollow:n})},chown(e,t,n,r){var i=typeof e==`string`?X.lookupPath(e,{follow:!r}).node:e;X.doChown(null,i,r)},lchown(e,t,n){X.chown(e,t,n,!0)},fchown(e,t,n){var r=X.getStreamChecked(e);X.doChown(r,r.node,!1)},doTruncate(e,t,n){if(X.isDir(t.mode))throw new X.ErrnoError(31);if(!X.isFile(t.mode))throw new X.ErrnoError(28);var r=X.nodePermissions(t,`w`);if(r)throw new X.ErrnoError(r);X.doSetAttr(e,t,{size:n,timestamp:Date.now()})},truncate(e,t){if(t<0)throw new X.ErrnoError(28);var n=typeof e==`string`?X.lookupPath(e,{follow:!0}).node:e;X.doTruncate(null,n,t)},ftruncate(e,t){var n=X.getStreamChecked(e);if(t<0||!(n.flags&2097155))throw new X.ErrnoError(28);X.doTruncate(n,n.node,t)},utime(e,t,n,r){var i=X.lookupPath(e,{follow:!r});X.doSetAttr(null,i.node,{atime:t,mtime:n,dontFollow:r})},open(e,t,n=438){if(e===``)throw new X.ErrnoError(44);t=be(t),n=t&64?n&4095|32768:0;var r,i;if(typeof e==`object`)r=e;else{i=e.endsWith(`/`);var a=X.lookupPath(e,{follow:!(t&131072),noent_okay:!0});r=a.node,e=a.path}var o=!1;if(t&64){if(r){if(t&128)throw new X.ErrnoError(20)}else if(i)throw new X.ErrnoError(31);else r=X.mknod(e,n|511,0),o=!0}if(!r)throw new X.ErrnoError(44);if(X.isChrdev(r.mode)&&(t&=-513),t&65536&&!X.isDir(r.mode))throw new X.ErrnoError(54);if(!o){var s=X.mayOpen(r,t);if(s)throw new X.ErrnoError(s)}t&512&&!o&&X.truncate(r,0),t&=-131713;var c=X.createStream({node:r,path:X.getPath(r),flags:t,seekable:!0,position:0,stream_ops:r.stream_ops,ungotten:[],error:!1});return c.stream_ops.open&&c.stream_ops.open(c),o&&X.chmod(r,n&511),c},close(e){if(X.isClosed(e))throw new X.ErrnoError(8);e.getdents&&=null,e.node?.notifyListeners(32);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{X.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,t,n){if(X.isClosed(e))throw new X.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new X.ErrnoError(70);if(n!=0&&n!=1&&n!=2)throw new X.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,n),e.ungotten=[],e.position},read(e,t,n,r,i){if(r<0||i<0)throw new X.ErrnoError(28);if(X.isClosed(e)||(e.flags&2097155)==1)throw new X.ErrnoError(8);if(X.isDir(e.node.mode))throw new X.ErrnoError(31);if(!e.stream_ops.read)throw new X.ErrnoError(28);var a=i!==void 0;if(!a)i=e.position;else if(!e.seekable)throw new X.ErrnoError(70);var o=e.stream_ops.read(e,t,n,r,i);return a||(e.position+=o),o},write(e,t,n,r,i,a){if(r<0||i<0)throw new X.ErrnoError(28);if(X.isClosed(e)||!(e.flags&2097155))throw new X.ErrnoError(8);if(X.isDir(e.node.mode))throw new X.ErrnoError(31);if(!e.stream_ops.write)throw new X.ErrnoError(28);e.seekable&&e.flags&1024&&X.llseek(e,0,2);var o=i!==void 0;if(!o)i=e.position;else if(!e.seekable)throw new X.ErrnoError(70);var s=e.stream_ops.write(e,t,n,r,i,a);return o||(e.position+=s),s},mmap(e,t,n,r,i){if(r&2&&!(i&2)&&(e.flags&2097155)!=2||(e.flags&2097155)==1)throw new X.ErrnoError(2);if(!e.stream_ops.mmap)throw new X.ErrnoError(43);if(!t)throw new X.ErrnoError(28);return e.stream_ops.mmap(e,t,n,r,i)},msync(e,t,n,r,i){return e.stream_ops.msync?e.stream_ops.msync(e,t,n,r,i):0},ioctl(e,t,n){if(!e.stream_ops.ioctl)throw new X.ErrnoError(59);return e.stream_ops.ioctl(e,t,n)},readFile(e,t={}){t.flags=t.flags??0,t.encoding=t.encoding??`binary`,t.encoding!==`utf8`&&t.encoding!==`binary`&&w(`Invalid encoding type "${t.encoding}"`);var n=X.open(e,t.flags),r=X.stat(e).size,i=new Uint8Array(r);return X.read(n,i,0,r,0),t.encoding===`utf8`&&(i=pe(i)),X.close(n),i},writeFile(e,t,n={}){n.flags=n.flags??577;var r=X.open(e,n.flags,n.mode);t=xe(t),X.write(r,t,0,t.byteLength,void 0,n.canOwn),X.close(r)},cwd:()=>X.currentPath,chdir(e){var t=X.lookupPath(e,{follow:!0});if(t.node===null)throw new X.ErrnoError(44);if(!X.isDir(t.node.mode))throw new X.ErrnoError(54);var n=X.nodePermissions(t.node,`x`);if(n)throw new X.ErrnoError(n);X.currentPath=t.path},createDefaultDirectories(){X.mkdir(`/tmp`),X.mkdir(`/home`),X.mkdir(`/home/web_user`)},createDefaultDevices(){X.mkdir(`/dev`),X.registerDevice(X.makedev(1,3),{read:()=>0,write:(e,t,n,r,i)=>r,llseek:()=>0}),X.mkdev(`/dev/null`,X.makedev(1,3)),J.register(X.makedev(5,0),J.default_tty_ops),J.register(X.makedev(6,0),J.default_tty1_ops),X.mkdev(`/dev/tty`,X.makedev(5,0)),X.mkdev(`/dev/tty1`,X.makedev(6,0));var e=new Uint8Array(1024),t=0,n=()=>(t===0&&(ue(e),t=e.byteLength),e[--t]);X.createDevice(`/dev`,`random`,n),X.createDevice(`/dev`,`urandom`,n),X.mkdir(`/dev/shm`),X.mkdir(`/dev/shm/tmp`)},createSpecialDirectories(){X.mkdir(`/proc`);var e=X.mkdir(`/proc/self`);X.mkdir(`/proc/self/fd`),X.mount({mount(){var t=X.createNode(e,`fd`,16895,73);return t.stream_ops={llseek:Y.stream_ops.llseek},t.node_ops={lookup(e,t){var n=+t,r=X.getStreamChecked(n),i={parent:null,mount:{mountpoint:`fake`},node_ops:{readlink:()=>r.path},id:n+1};return i.parent=i,i},readdir(){return Array.from(X.streams.entries()).filter(([e,t])=>t).map(([e,t])=>e.toString())}},t}},{},`/proc/self/fd`)},createStandardStreams(e,t,n){e?X.createDevice(`/dev`,`stdin`,e):X.symlink(`/dev/tty`,`/dev/stdin`),t?X.createDevice(`/dev`,`stdout`,null,t):X.symlink(`/dev/tty`,`/dev/stdout`),n?X.createDevice(`/dev`,`stderr`,null,n):X.symlink(`/dev/tty1`,`/dev/stderr`),X.open(`/dev/stdin`,0),X.open(`/dev/stdout`,1),X.open(`/dev/stderr`,1)},staticInit(){X.nameTable=Array(4096),X.mount(Y,{},`/`),X.createDefaultDirectories(),X.createDefaultDevices(),X.createSpecialDirectories(),X.filesystems={MEMFS:Y}},init(e,t,r){X.initialized=!0,e??=n.stdin,t??=n.stdout,r??=n.stderr,X.createStandardStreams(e,t,r)},quit(){X.initialized=!1;for(var e of X.streams)e&&X.close(e)},findObject(e,t){var n=X.analyzePath(e,t);return n.exists?n.object:null},analyzePath(e,t){try{var n=X.lookupPath(e,{follow:!t});e=n.path}catch{}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=X.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=n.path,r.parentObject=n.node,r.name=K.basename(e),n=X.lookupPath(e,{follow:!t}),r.exists=!0,r.path=n.path,r.object=n.node,r.name=n.node.name,r.isRoot=n.path===`/`}catch(e){r.error=e.errno}return r},createPath(e,t,n,r){e=typeof e==`string`?e:X.getPath(e);for(var i=t.split(`/`).reverse();i.length;){var a=i.pop();if(a){var o=K.join2(e,a);try{X.mkdir(o)}catch(e){if(e.errno!=20)throw e}e=o}}return o},createFile(e,t,n,r,i){var a=K.join2(typeof e==`string`?e:X.getPath(e),t),o=Se(r,i);return X.create(a,o)},createDataFile(e,t,n,r,i,a){var o=t;e&&(e=typeof e==`string`?e:X.getPath(e),o=t?K.join2(e,t):e);var s=Se(r,i),c=X.create(o,s);if(n){n=xe(n),X.chmod(c,s|146);var l=X.open(c,577);X.write(l,n,0,n.length,0,a),X.close(l),X.chmod(c,s)}},createDevice(e,t,n,r){var i=K.join2(typeof e==`string`?e:X.getPath(e),t),a=Se(!!n,!!r);X.createDevice.major??=64;var o=X.makedev(X.createDevice.major++,0);return X.registerDevice(o,{open(e){e.seekable=!1},close(e){r?.buffer?.length&&r(10)},read(e,t,r,i,a){for(var o=0,s=0;s<i;s++){var c;try{c=n()}catch{throw new X.ErrnoError(29)}if(c===void 0&&o===0)throw new X.ErrnoError(6);if(c==null)break;o++,t[r+s]=c}return o&&(e.node.atime=Date.now()),o},write(e,t,n,i,a){for(var o=0;o<i;o++)try{r(t[n+o])}catch{throw new X.ErrnoError(29)}return i&&(e.node.mtime=e.node.ctime=Date.now()),o}}),X.mkdev(i,a,o)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)w(`Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.`);else try{e.contents=f(e.url)}catch{throw new X.ErrnoError(29)}},createLazyFile(e,t,n,r,a){class o{lengthKnown=!1;chunks=[];get(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,n=e/this.chunkSize|0;return this.getter(n)[t]}}setDataGetter(e){this.getter=e}cacheLength(){var e=new XMLHttpRequest;e.open(`HEAD`,n,!1),e.send(null),e.status>=200&&e.status<300||e.status===304||w(`Couldn't load `+n+`. Status: `+e.status);var t=Number(e.getResponseHeader(`Content-length`)),r,i=(r=e.getResponseHeader(`Accept-Ranges`))&&r===`bytes`,a=(r=e.getResponseHeader(`Content-Encoding`))&&r===`gzip`,o=1048576;i||(o=t);var s=(e,r)=>{e>r&&w(`invalid range (${e}, ${r}) or no bytes requested!`),r>t-1&&w(`only ${t} bytes available! programmer error!`);var i=new XMLHttpRequest;return i.open(`GET`,n,!1),t!==o&&i.setRequestHeader(`Range`,`bytes=`+e+`-`+r),i.responseType=`arraybuffer`,i.overrideMimeType&&i.overrideMimeType(`text/plain; charset=x-user-defined`),i.send(null),i.status>=200&&i.status<300||i.status===304||w(`Couldn't load `+n+`. Status: `+i.status),i.response===void 0?_e(i.responseText??``,!0):new Uint8Array(i.response||[])},c=this;c.setDataGetter(e=>{var n=e*o,r=(e+1)*o-1;return r=Math.min(r,t-1),c.chunks[e]===void 0&&(c.chunks[e]=s(n,r)),c.chunks[e]===void 0&&w(`doXHR failed!`),c.chunks[e]}),(a||!t)&&(o=t=1,t=this.getter(0).length,o=t,p(`LazyFiles on gzip forces download of the whole file when length is accessed`)),this._length=t,this._chunkSize=o,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){i||w(`Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc`);var s={isDevice:!1,contents:new o}}else var s={isDevice:!1,url:n};var c=X.createFile(e,t,s,r,a);s.contents?c.contents=s.contents:s.url&&(c.contents=null,c.url=s.url),Object.defineProperties(c,{usedBytes:{get:function(){return this.contents.length}}});var l={};for(let[e,t]of Object.entries(c.stream_ops))l[e]=(...e)=>(X.forceLoadFile(c),t(...e));function u(e,t,n,r,i){var a=e.node.contents;if(i>=a.length)return 0;var o=Math.min(a.length-i,r);if(a.slice)for(var s=0;s<o;s++)t[n+s]=a[i+s];else for(var s=0;s<o;s++)t[n+s]=a.get(i+s);return o}return l.read=(e,t,n,r,i)=>(X.forceLoadFile(c),u(e,t,n,r,i)),l.mmap=(e,t,n,r,i)=>{X.forceLoadFile(c);var a=ye(t);if(!a)throw new X.ErrnoError(48);return u(e,L,a,t,n),{ptr:a,allocated:!0}},c.stream_ops=l,c}},Ie=(e,t,n)=>e?pe(V,e,t,n):``,Z={currentUmask:18,calculateAt(e,t,n){if(K.isAbs(t))return t;var r=e===-100?X.cwd():Z.getStreamFromFD(e).path;if(t.length==0){if(!n)throw new X.ErrnoError(44);return r}return r+`/`+t},writeStat(e,t){B[e>>2]=t.dev,B[e+4>>2]=t.mode,B[e+8>>2]=t.nlink,B[e+12>>2]=t.uid,B[e+16>>2]=t.gid,B[e+20>>2]=t.rdev,I[e+24>>3]=BigInt(t.size),F[e+32>>2]=4096,F[e+36>>2]=t.blocks;var n=t.atime.getTime(),r=t.mtime.getTime(),i=t.ctime.getTime();return I[e+40>>3]=BigInt(Math.floor(n/1e3)),B[e+48>>2]=n%1e3*1e3*1e3,I[e+56>>3]=BigInt(Math.floor(r/1e3)),B[e+64>>2]=r%1e3*1e3*1e3,I[e+72>>3]=BigInt(Math.floor(i/1e3)),B[e+80>>2]=i%1e3*1e3*1e3,I[e+88>>3]=BigInt(t.ino),0},writeStatFs(e,t){B[e+4>>2]=t.bsize,B[e+60>>2]=t.bsize,I[e+8>>3]=BigInt(t.blocks),I[e+16>>3]=BigInt(t.bfree),I[e+24>>3]=BigInt(t.bavail),I[e+32>>3]=BigInt(t.files),I[e+40>>3]=BigInt(t.ffree),B[e+48>>2]=t.fsid,B[e+64>>2]=t.flags,B[e+56>>2]=t.namelen},doMsync(e,t,n,r,i){if(!X.isFile(t.node.mode))throw new X.ErrnoError(43);if(r&2)return 0;var a=V.subarray(e,e+n);X.msync(t,a,i,n,r)},getStreamFromFD(e){return X.getStreamChecked(e)},varargs:void 0,getStr(e){return Ie(e)}};function Le(e,t,n){Z.varargs=n;try{var r=Z.getStreamFromFD(e);switch(t){case 0:var i=ce();if(i<0)return-28;for(;X.streams[i];)i++;return X.dupStream(r,i).fd;case 1:case 2:return 0;case 3:return r.flags;case 4:var i=ce(),a=289792;return r.flags=r.flags&~a|i&a,0;case 12:var i=G(),o=0;return P[i+o>>1]=2,0;case 13:case 14:return 0}return-28}catch(e){if(X===void 0||e.name!==`ErrnoError`)throw e;return-e.errno}}function Re(e,t,n){Z.varargs=n;try{var r=Z.getStreamFromFD(e);switch(t){case 21509:return r.tty?0:-59;case 21505:if(!r.tty)return-59;if(r.tty.ops.ioctl_tcgets){var i=r.tty.ops.ioctl_tcgets(r),a=G();F[a>>2]=i.c_iflag||0,F[a+4>>2]=i.c_oflag||0,F[a+8>>2]=i.c_cflag||0,F[a+12>>2]=i.c_lflag||0;for(var o=0;o<32;o++)L[a+o+17]=i.c_cc[o]||0;return 0}return 0;case 21510:case 21511:case 21512:return r.tty?0:-59;case 21506:case 21507:case 21508:if(!r.tty)return-59;if(r.tty.ops.ioctl_tcsets){for(var a=G(),s=F[a>>2],c=F[a+4>>2],l=F[a+8>>2],u=F[a+12>>2],d=[],o=0;o<32;o++)d.push(L[a+o+17]);return r.tty.ops.ioctl_tcsets(r.tty,t,{c_iflag:s,c_oflag:c,c_cflag:l,c_lflag:u,c_cc:d})}return 0;case 21519:if(!r.tty)return-59;var a=G();return F[a>>2]=0,0;case 21520:return r.tty?-28:-59;case 21537:case 21531:var a=G();return X.ioctl(r,t,a);case 21523:if(!r.tty)return-59;if(r.tty.ops.ioctl_tiocgwinsz){var f=r.tty.ops.ioctl_tiocgwinsz(r.tty),a=G();P[a>>1]=f[0],P[a+2>>1]=f[1]}return 0;case 21524:return r.tty?0:-59;case 21515:return r.tty?0:-59;default:return-28}}catch(e){if(X===void 0||e.name!==`ErrnoError`)throw e;return-e.errno}}function Q(e,t,n,r){Z.varargs=r;try{t=Z.getStr(t),t=Z.calculateAt(e,t);var i=r?ce():0;return n&64&&(i&=~Z.currentUmask),X.open(t,n,i).fd}catch(e){if(X===void 0||e.name!==`ErrnoError`)throw e;return-e.errno}}var ze=()=>w(``),$=0,Be=()=>{U=!1,$=0},Ve={},He=e=>{if(e instanceof N||e==`unwind`)return _;c(1,e)},Ue=()=>U||$>0,We=e=>{_=e,Ue()||(n.onExit?.(e),g=!0),c(e,new N(e))},Ge=(e,t)=>{_=e,We(e)},Ke=()=>{if(!Ue())try{Ge(_)}catch(e){He(e)}},qe=e=>{if(!g)try{return e()}catch(e){He(e)}finally{Ke()}},Je=()=>performance.now(),Ye=(e,t)=>(Ve[e]&&(clearTimeout(Ve[e].id),delete Ve[e]),t&&(Ve[e]={id:setTimeout(()=>{delete Ve[e],qe(()=>qt(e,Je()))},t),timeout_ms:t}),0),Xe=(e,t,n)=>ge(e,V,t,n),Ze=(e,t,n,r)=>{var i=new Date().getFullYear(),a=new Date(i,0,1),o=new Date(i,6,1),s=a.getTimezoneOffset(),c=o.getTimezoneOffset(),l=Math.max(s,c);B[e>>2]=l*60,F[t>>2]=Number(s!=c);var u=e=>{var t=e>=0?`-`:`+`,n=Math.abs(e);return`UTC${t}${String(Math.floor(n/60)).padStart(2,`0`)}${String(n%60).padStart(2,`0`)}`},d=u(s),f=u(c);c<s?(Xe(d,n,17),Xe(f,r,17)):(Xe(d,r,17),Xe(f,n,17))},Qe=()=>Date.now(),$e=1,et=e=>e>=0&&e<=3,tt=9007199254740992,nt=-9007199254740992,rt=e=>e<nt||e>tt?NaN:Number(e);function it(e,t,n){if(t=rt(t),!et(e))return 28;var r;if(e===0)r=Qe();else if($e)r=Je();else return 52;var i=Math.round(r*1e3*1e3);return I[n>>3]=BigInt(i),0}var at=()=>2147483648,ot=(e,t)=>Math.ceil(e/t)*t,st=e=>{var t=(e-Zt.buffer.byteLength+65535)/65536|0;try{return Zt.grow(t),b(),1}catch{}},ct=e=>{var t=V.length;e>>>=0;var n=at();if(e>n)return!1;for(var r=1;r<=4;r*=2){var i=t*(1+.2/r);if(i=Math.min(i,e+100663296),st(Math.min(n,ot(Math.max(e,i),65536))))return!0}return!1},lt={},ut=()=>s,dt=()=>{if(!dt.strings){var e={USER:`web_user`,LOGNAME:`web_user`,PATH:`/`,PWD:`/`,HOME:`/home/web_user`,LANG:(globalThis.navigator?.language??`C`).replace(`-`,`_`)+`.UTF-8`,_:ut()};for(var t in lt)lt[t]===void 0?delete e[t]:e[t]=lt[t];var n=[];for(var t in e)n.push(`${t}=${e[t]}`);dt.strings=n}return dt.strings},ft=(e,t)=>{var n=0,r=0;for(var i of dt()){var a=t+n;B[e+r>>2]=a,n+=Xe(i,a,1/0)+1,r+=4}return 0},pt=(e,t)=>{var n=dt();B[e>>2]=n.length;var r=0;for(var i of n)r+=he(i)+1;return B[t>>2]=r,0};function mt(e){try{var t=Z.getStreamFromFD(e);return X.close(t),0}catch(e){if(X===void 0||e.name!==`ErrnoError`)throw e;return e.errno}}var ht=(e,t,n,r)=>{for(var i=0,a=0;a<n;a++){var o=B[t>>2],s=B[t+4>>2];t+=8;try{var c=X.read(e,L,o,s,r)}catch(e){if(i>0&&e instanceof X.ErrnoError&&(e.errno==6||e.errno==6))break;throw e}if(c<0)return-1;if(i+=c,c<s)break;r!==void 0&&(r+=c)}return i};function gt(e,t,n,r){try{var i=ht(Z.getStreamFromFD(e),t,n);return B[r>>2]=i,0}catch(e){if(X===void 0||e.name!==`ErrnoError`)throw e;return e.errno}}function _t(e,t,n,r){t=rt(t);try{if(isNaN(t))return 22;var i=Z.getStreamFromFD(e);return X.llseek(i,t,n),I[r>>3]=BigInt(i.position),i.getdents&&t===0&&n===0&&(i.getdents=null),0}catch(e){if(X===void 0||e.name!==`ErrnoError`)throw e;return e.errno}}var vt=(e,t,n,r)=>{if(n==1)return X.write(e,L,B[t>>2],B[t+4>>2],r);for(var i=0,a=0,o=t;a<n;a++,o+=8)i+=B[o+4>>2];for(var s=new Uint8Array(i),c=0,a=0;a<n;a++,t+=8){var l=B[t>>2],u=B[t+4>>2];s.set(V.subarray(l,l+u),c),c+=u}return X.write(e,s,0,i,r)};function yt(e,t,n,r){try{var i=vt(Z.getStreamFromFD(e),t,n);return B[r>>2]=i,0}catch(e){if(X===void 0||e.name!==`ErrnoError`)throw e;return e.errno}}var bt=e=>n[`_`+e],xt=(e,t)=>{L.set(e,t)},St=e=>Yt(e),Ct=e=>{var t=he(e)+1,n=St(t);return Xe(e,n,t),n},wt=(e,t,n,r,i)=>{var a={string:e=>{var t=0;return e!=null&&e!==0&&(t=Ct(e)),t},array:e=>{var t=St(e.length);return xt(e,t),t}};function o(e){return t===`string`?Ie(e):t===`boolean`?!!e:e}var s=bt(e),c=[],l=0;if(r)for(var u=0;u<r.length;u++){var d=a[n[u]];d?(l===0&&(l=ie()),c[u]=d(r[u])):c[u]=r[u]}var f=s(...c);function p(e){return l!==0&&W(l),o(e)}return f=p(f),f},Tt=(e,t,n,r)=>{var i=!n||n.every(e=>e===`number`||e===`boolean`);return t!==`string`&&i&&!r?bt(e):(...i)=>wt(e,t,n,i,r)},Et=[],Dt=e=>{var t=Et[e];return t||(Et[e]=t=Qt.get(e)),t},Ot=(e,t)=>{if(kt)for(var n=e;n<e+t;n++){var r=Dt(n);r&&kt.set(r,n)}},kt,At=e=>(kt||(kt=new WeakMap,Ot(0,Qt.length)),kt.get(e)||0),jt=[],Mt=()=>jt.length?jt.pop():Qt.grow(1),Nt=(e,t)=>{Qt.set(e,t),Et[e]=Qt.get(e)},Pt=e=>{let t=e.length;return[t%128|128,t>>7,...e]},Ft={i:127,p:127,j:126,f:125,d:124,e:111},It=e=>Pt(Array.from(e,e=>Ft[e])),Lt=(e,t)=>{var n=Uint8Array.of(0,97,115,109,1,0,0,0,1,...Pt([1,96,...It(t.slice(1)),...It(t[0]===`v`?``:t[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),r=new WebAssembly.Module(n);return new WebAssembly.Instance(r,{e:{f:e}}).exports.f},Rt=(e,t)=>{var n=At(e);if(n)return n;var r=Mt();try{Nt(r,e)}catch(n){if(!(n instanceof TypeError))throw n;Nt(r,Lt(e,t))}return kt.set(e,r),r},zt=e=>{kt.delete(Dt(e)),Nt(e,null),jt.push(e)};X.createPreloadedFile=Fe,X.preloadFile=Pe,X.staticInit(),n.noExitRuntime&&(U=n.noExitRuntime),n.print&&(p=n.print),n.printErr&&(m=n.printErr),n.arguments&&n.arguments,n.thisProgram&&(s=n.thisProgram);var Bt=n.preInit;if(Bt)for(typeof Bt==`function`&&(n.preInit=Bt=[Bt]);Bt.length>0;)Bt.shift()();n.cwrap=Tt,n.addFunction=Rt,n.removeFunction=zt,n.UTF8ToString=Ie;var Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt;function $t(e){n._Highs_js_getColName=e.w,n._Highs_js_getRowName=e.x,n._Highs_js_getPresolvedColName=e.y,n._Highs_js_getPresolvedRowName=e.z,n._Highs_js_setCallback=e.A,n._Highs_js_getCallbackMipSolutionSize=e.B,n._Highs_lpCall=e.C,n._Highs_mipCall=e.D,n._Highs_qpCall=e.E,Vt=n._Highs_create=e.F,Ht=n._Highs_destroy=e.G,n._Highs_version=e.H,n._Highs_versionMajor=e.I,n._Highs_versionMinor=e.J,n._Highs_versionPatch=e.K,n._Highs_githash=e.L,n._Highs_presolve=e.M,Ut=n._Highs_run=e.N,n._Highs_postsolve=e.O,n._Highs_readModel=e.P,n._Highs_writeModel=e.Q,n._Highs_writePresolvedModel=e.R,n._Highs_writeSolution=e.S,n._Highs_writeSolutionPretty=e.T,n._Highs_passLp=e.U,n._Highs_passMip=e.V,n._Highs_passModel=e.W,n._Highs_passHessian=e.X,n._Highs_passLinearObjectives=e.Y,n._Highs_clearLinearObjectives=e.Z,n._Highs_getNumCol=e._,n._Highs_addLinearObjective=e.$,n._Highs_passRowName=e.aa,n._Highs_passColName=e.ba,n._Highs_passModelName=e.ca,n._Highs_readOptions=e.da,n._Highs_clear=e.ea,n._Highs_clearModel=e.fa,n._Highs_clearSolver=e.ga,n._Highs_releaseMemory=e.ha,n._Highs_setBoolOptionValue=e.ia,n._Highs_setIntOptionValue=e.ja,n._Highs_setDoubleOptionValue=e.ka,n._Highs_setStringOptionValue=e.la,n._Highs_getNumOptions=e.ma,n._Highs_getOptionName=e.na,n._Highs_getBoolOptionValue=e.oa,n._Highs_getBoolOptionValues=e.pa,n._Highs_getIntOptionValue=e.qa,n._Highs_getIntOptionValues=e.ra,n._Highs_getDoubleOptionValue=e.sa,n._Highs_getDoubleOptionValues=e.ta,n._Highs_getStringOptionValue=e.ua,n._Highs_getStringOptionValues=e.va,n._Highs_getOptionType=e.wa,n._Highs_resetOptions=e.xa,n._Highs_writeOptions=e.ya,n._Highs_writeOptionsDeviations=e.za,n._Highs_getIntInfoValue=e.Aa,n._Highs_getDoubleInfoValue=e.Ba,n._Highs_getInt64InfoValue=e.Ca,n._Highs_getInfoType=e.Da,n._Highs_getSolution=e.Ea,n._Highs_getBasis=e.Fa,Wt=n._Highs_getModelStatus=e.Ga,n._Highs_getDualRay=e.Ha,n._Highs_getDualUnboundednessDirection=e.Ia,n._Highs_getPrimalRay=e.Ja,n._Highs_getObjectiveValue=e.Ka,n._Highs_getBasicVariables=e.La,n._Highs_getBasisInverseRow=e.Ma,n._Highs_getBasisInverseCol=e.Na,n._Highs_getBasisSolve=e.Oa,n._Highs_getBasisTransposeSolve=e.Pa,n._Highs_getReducedRow=e.Qa,n._Highs_getReducedColumn=e.Ra,n._Highs_setBasis=e.Sa,n._Highs_getNumRow=e.Ta,n._Highs_setLogicalBasis=e.Ua,n._Highs_setSolution=e.Va,n._Highs_setSparseSolution=e.Wa,n._Highs_setCallback=e.Xa,n._Highs_startCallback=e.Ya,n._Highs_stopCallback=e.Za,n._Highs_getRunTime=e._a,n._Highs_zeroAllClocks=e.$a,n._Highs_addCol=e.ab,n._Highs_addCols=e.bb,n._Highs_addVar=e.cb,n._Highs_addVars=e.db,n._Highs_addRow=e.eb,n._Highs_addRows=e.fb,n._Highs_ensureColwise=e.gb,n._Highs_ensureRowwise=e.hb,n._Highs_changeObjectiveSense=e.ib,n._Highs_changeObjectiveOffset=e.jb,n._Highs_changeColIntegrality=e.kb,n._Highs_changeColsIntegralityByRange=e.lb,n._Highs_changeColsIntegralityBySet=e.mb,n._Highs_changeColsIntegralityByMask=e.nb,n._Highs_clearIntegrality=e.ob,n._Highs_changeColCost=e.pb,n._Highs_changeColsCostByRange=e.qb,n._Highs_changeColsCostBySet=e.rb,n._Highs_changeColsCostByMask=e.sb,n._Highs_changeColBounds=e.tb,n._Highs_changeColsBoundsByRange=e.ub,n._Highs_changeColsBoundsBySet=e.vb,n._Highs_changeColsBoundsByMask=e.wb,n._Highs_changeRowBounds=e.xb,n._Highs_changeRowsBoundsByRange=e.yb,n._Highs_changeRowsBoundsBySet=e.zb,n._Highs_changeRowsBoundsByMask=e.Ab,n._Highs_changeCoeff=e.Bb,n._Highs_getObjectiveSense=e.Cb,n._Highs_getObjectiveOffset=e.Db,n._Highs_getColsByRange=e.Eb,n._Highs_getColsBySet=e.Fb,n._Highs_getColsByMask=e.Gb,n._Highs_getRowsByRange=e.Hb,n._Highs_getRowsBySet=e.Ib,n._Highs_getRowsByMask=e.Jb,n._Highs_getRowName=e.Kb,n._Highs_getRowByName=e.Lb,n._Highs_getColName=e.Mb,n._Highs_getColByName=e.Nb,n._Highs_getColIntegrality=e.Ob,n._Highs_deleteColsByRange=e.Pb,n._Highs_deleteColsBySet=e.Qb,n._Highs_deleteColsByMask=e.Rb,n._Highs_deleteRowsByRange=e.Sb,n._Highs_deleteRowsBySet=e.Tb,n._Highs_deleteRowsByMask=e.Ub,n._Highs_scaleCol=e.Vb,n._Highs_scaleRow=e.Wb,n._Highs_getInfinity=e.Xb,n._Highs_getSizeofHighsInt=e.Yb,n._Highs_getNumNz=e.Zb,n._Highs_getHessianNumNz=e._b,n._Highs_getPresolvedNumCol=e.$b,n._Highs_getPresolvedNumRow=e.ac,n._Highs_getPresolvedNumNz=e.bc,n._Highs_getModel=e.cc,n._Highs_getLp=e.dc,n._Highs_getFixedLp=e.ec,n._Highs_getPresolvedLp=e.fc,n._Highs_getPresolvedColName=e.gc,n._Highs_getPresolvedRowName=e.hc,n._Highs_getIis=e.ic,n._Highs_getIisLp=e.jc,n._Highs_crossover=e.kc,n._Highs_getRanging=e.lc,n._Highs_feasibilityRelaxation=e.mc,n._Highs_getCallbackDataOutItem=e.nc,n._Highs_setCallbackSolution=e.oc,n._Highs_setCallbackSparseSolution=e.pc,n._Highs_repairCallbackSolution=e.qc,n._Highs_call=e.rc,Gt=n._free=e.tc,Kt=n._malloc=e.uc,qt=e.vc,Jt=e.wc,Yt=e.xc,Xt=e.yc,Zt=e.u,Qt=e.sc}var en={a:se,e:Le,h:Re,i:Q,k:ze,s:Be,l:Ye,m:Ze,p:it,j:Qe,c:Je,q:ct,n:ft,o:pt,b:Ge,d:mt,g:gt,t:_t,f:yt,r:We};async function tn(){x(),Oe&&await De();var e=n.setStatus;e&&(e(`Running...`),await new Promise(e=>setTimeout(e,1)),setTimeout(e,1,``)),!g&&(S(),n.onRuntimeInitialized?.(),C())}var nn=await M();await tn();let rn=0;n.Highs_readModel=n.cwrap(`Highs_readModel`,`number`,[`number`,`string`]);let an=n.cwrap(`Highs_setIntOptionValue`,`number`,[`number`,`string`,`number`]),on=n.cwrap(`Highs_setDoubleOptionValue`,`number`,[`number`,`string`,`number`]),sn=n.cwrap(`Highs_setStringOptionValue`,`number`,[`number`,`string`,`string`]),cn=n.cwrap(`Highs_setBoolOptionValue`,`number`,[`number`,`string`,`number`]),ln=n.cwrap(`Highs_getOptionType`,`number`,[`number`,`string`,`number`]),un=n.cwrap(`Highs_getNumCol`,`number`,[`number`]),dn=n.cwrap(`Highs_getNumRow`,`number`,[`number`]),fn=n.cwrap(`Highs_getObjectiveValue`,`number`,[`number`]),pn=n.cwrap(`Highs_getInfinity`,`number`,[]),mn=n.cwrap(`Highs_getSolution`,`number`,[`number`,`number`,`number`,`number`,`number`]),hn=n.cwrap(`Highs_getBasis`,`number`,[`number`,`number`,`number`]),gn=n.cwrap(`Highs_getColsByRange`,`number`,[`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`]),_n=n.cwrap(`Highs_getRowsByRange`,`number`,[`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`,`number`]),vn=n.cwrap(`Highs_getColIntegrality`,`number`,[`number`,`number`,`number`]),yn=n.cwrap(`Highs_js_getColName`,`number`,[`number`,`number`,`number`,`number`,`number`]),bn=n.cwrap(`Highs_js_getRowName`,`number`,[`number`,`number`,`number`,`number`,`number`]),xn={0:`Not Set`,1:`Load error`,2:`Model error`,3:`Presolve error`,4:`Solve error`,5:`Postsolve error`,6:`Empty`,7:`Optimal`,8:`Infeasible`,9:`Primal infeasible or unbounded`,10:`Unbounded`,11:`Bound on objective reached`,12:`Target for objective reached`,13:`Time limit reached`,14:`Iteration limit reached`,15:`Unknown`};var Vt,Ut,Ht,Wt,X;let Sn={0:`LB`,1:`BS`,2:`UB`,3:`FX`};function Cn(e,t,n){return e===3||e===2&&t===n?`FX`:Sn[e]||``}let wn=new Set([`Not Set`,`Load error`,`Model error`,`Presolve error`,`Solve error`,`Postsolve error`,`Empty`,`Infeasible`,`Unknown`]);n.solve=function(e,t){let r=`highs-model-${++rn}.lp`,i,a=[];function o(e){let t=Kt(e);if(!t)throw Error(`malloc failed`);return a.push(t),t}function s(e,t){let n=o(Int32Array.BYTES_PER_ELEMENT),r=yn(e,t,0,0,n);if(r!==0&&r!==1)return``;let i=F[n>>2];if(i<=0)return``;let s=Kt(i);return a.push(s),r=yn(e,t,s,i,n),r!==0&&r!==1?``:Ie(s)}function c(e,t){let n=o(Int32Array.BYTES_PER_ELEMENT),r=bn(e,t,0,0,n);if(r!==0&&r!==1)return``;let i=F[n>>2];if(i<=0)return``;let s=Kt(i);return a.push(s),r=bn(e,t,s,i,n),r!==0&&r!==1?``:Ie(s)}try{if(X.writeFile(r,e),i=Vt(),!i)throw Error(`Unable to create the HiGHS solver`);En(()=>n.Highs_readModel(i,r),`read LP model (see http://web.mit.edu/lpsolve/doc/CPLEX-format.htm)`);let a=t||{};for(let e in a){let t=a[e],n=typeof t,r;if(n===`number`)r=Tn;else if(n===`boolean`)r=cn;else if(n===`string`)r=sn;else throw Error(`Unsupported option value type ${t} for '${e}'`);En(()=>r(i,e,t),`set option '${e}'`)}En(()=>Ut(i),`solve the problem`);let l=Wt(i),u=xn[l]||`Unknown`;if(u===`Empty`)return{Columns:{},Rows:[],ObjectiveValue:0,Status:`Empty`};let d=un(i),f=dn(i),p=pn(),m=fn(i);Math.abs(m)>=p*.5&&(m=m>0?1/0:-1/0);let h=d>0?o(d*Float64Array.BYTES_PER_ELEMENT):0,g=d>0?o(d*Float64Array.BYTES_PER_ELEMENT):0,_=f>0?o(f*Float64Array.BYTES_PER_ELEMENT):0,v=f>0?o(f*Float64Array.BYTES_PER_ELEMENT):0;En(()=>mn(i,h,g,_,v),`get solution`);let y=d>0?o(d*Int32Array.BYTES_PER_ELEMENT):0,b=f>0?o(f*Int32Array.BYTES_PER_ELEMENT):0,x=!1,S=hn(i,y,b);(S===0||S===1)&&(x=!0);let C=o(Int32Array.BYTES_PER_ELEMENT),w=d>0?o(d*Float64Array.BYTES_PER_ELEMENT):0,T=d>0?o(d*Float64Array.BYTES_PER_ELEMENT):0,E=d>0?o(d*Float64Array.BYTES_PER_ELEMENT):0;gn(i,0,d-1,C,w,T,E,0,0,0,0);let D=o(Int32Array.BYTES_PER_ELEMENT),O=f>0?o(f*Float64Array.BYTES_PER_ELEMENT):0,k=f>0?o(f*Float64Array.BYTES_PER_ELEMENT):0;_n(i,0,f-1,D,O,k,0,0,0,0);let A=o(Int32Array.BYTES_PER_ELEMENT),j=!wn.has(u),M=!1;for(let e=0;e<d&&!M;e++)vn(i,e,A),F[A>>2]!==0&&(M=!0);let N={};for(let e=0;e<d;e++){let t={Index:e,Lower:z[(T>>3)+e],Upper:z[(E>>3)+e]};if(vn(i,e,A),t.Type=F[A>>2]===1?`Integer`:`Continuous`,j&&(t.Primal=z[(h>>3)+e]),x&&j&&!M){let n=F[(y>>2)+e];t.Status=Cn(n,t.Lower,t.Upper),t.Dual=z[(g>>3)+e]}t.Name=s(i,e),N[t.Name]=t}let P=[];for(let e=0;e<f;e++){let t={Index:e,Name:c(i,e),Lower:z[(O>>3)+e],Upper:z[(k>>3)+e]};if(j&&(t.Primal=z[(_>>3)+e]),x&&j&&!M){let n=F[(b>>2)+e];t.Status=Cn(n,t.Lower,t.Upper),t.Dual=z[(v>>3)+e]}P.push(t)}return{Status:u,ObjectiveValue:m,Columns:N,Rows:P}}finally{i&&Ht(i);try{X.unlink(r)}catch{}for(let e=a.length-1;e>=0;e--)try{Gt(a[e])}catch{}}};function Tn(e,t,n){let r=Kt(Int32Array.BYTES_PER_ELEMENT);if(!r)return-1;try{let i=ln(e,t,r);if(i!==0&&i!==1)return i;let a=F[r>>2];return a===1?!Number.isSafeInteger(n)||n<-2147483648||n>2147483647?-1:an(e,t,n):a===2?on(e,t,n):-1}finally{Gt(r)}}function En(e,t){let n;try{n=e()}catch(e){n=e}if(n!==0&&n!==1)throw Error(`Unable to `+t+`. HiGHS error `+n)}var Dn=this&&this.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},On=this&&this.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)};return(function(e){"use strict";var t,n;let r={csc:1,csr:2},i={triangular:1,square:2},a=new Map,o=new Map,s=new Map,c=1,l=1,u=0;class d extends Error{constructor(e,t){super(e),this.status=-1,this.name=`HighsError`,this.operation=t}}class f extends d{constructor(){super(`Cannot use this HiGHS model after disposal; create a new model or keep the work inside highs.withModel()`,`dispose`),this.name=`HighsDisposedError`}}class p extends d{constructor(e){super(e,`validate`),this.name=`HighsValidationError`}}class m extends d{constructor(){super(`Only callback control methods may be called while HiGHS is executing a callback`,`callback`),this.name=`HighsReentrancyError`}}class h extends d{constructor(e){super(`Option '`+e+`' is not supported by the single-threaded data-only API`,`setOptionValue`),this.name=`HighsUnsupportedOptionError`,this.option=e}}function g(t,n,r){let i=t+`:`+n+`:`+r.join(`,`),a=s.get(i);if(!a){let c=e.cwrap(t,n,r);a=function(...e){let t=c.apply(null,e),n=o.get(e[0]);return n&&n._throwCallbackError(),t},s.set(i,a)}return a}function _(e,t,n=`number`){return g(e,n,Array(t).fill(`number`))}function v(e,t,n,r=`number`){return g(e,r,Array(t||0).fill(`number`).concat([`string`],Array(n||0).fill(`number`)))}function y(){return V}function b(){return F}function x(){return z}function S(e){return e?Ie(e):``}function C(e){return new p(e)}function w(){return new f}function T(e){return new d(e+` failed with HiGHS status -1`,e)}function E(e){return new h(e)}function D(){return new m}function O(e){return{status:e}}function k(e,t){return e===-1?{status:e}:{status:e,value:t}}function A(e,t){if(e===-1)throw T(t);return{status:e,warnings:e===1?[t+` completed with a HiGHS warning`]:[]}}function j(e,t,n=0){if(!Number.isSafeInteger(e)||e<(n||0)||e>2147483647)throw C(t+` must be a 32-bit non-negative integer`);return e}function M(e,t){if(!Number.isSafeInteger(e)||e<-2147483648||e>2147483647)throw C(t+` must be a signed 32-bit integer`);return e}function N(e,t){if(e==null||typeof e.length!=`number`)throw C(t+` must be an array or typed array`);return e}function P(e,t,n){if(N(e,n),e.length!==t)throw C(n+` must contain `+t+` values; got `+e.length);return e}function I(e,t){if(typeof e!=`number`||Number.isNaN(e))throw C(t+` must be a number`);return e}function L(e,t,n){P(e,t,n);for(let t=0;t<e.length;t++)I(e[t],n+`[`+t+`]`);return e}function R(e,t,n,r){t==null?N(e,n):P(e,t,n);for(let t=0;t<e.length;t++){let i=e[t];if(j(i,n+`[`+t+`]`,0),r!=null&&i>=r)throw C(n+`[`+t+`] is outside the model`)}return e}function ee(e,t,n,r){if(!e||e.format!==`csc`&&e.format!==`csr`)throw C(r+`.format must be 'csc' or 'csr'`);if(e.numRows!==t||e.numCols!==n)throw C(r+` dimensions do not match the model`);let i=e.format===`csc`?n:t;if(R(e.starts,i+1,r+`.starts`),e.starts[0]!==0)throw C(r+`.starts must begin with zero`);for(let t=1;t<e.starts.length;t++)if(e.starts[t]<e.starts[t-1])throw C(r+`.starts must be monotonic`);let a=e.starts[i];return R(e.indices,a,r+`.indices`,e.format===`csc`?t:n),L(e.values,a,r+`.values`),a}function B(e,t,n){if(!e||!(e.format in i))throw C(n+`.format must be 'triangular' or 'square'`);if(e.dimension!==t)throw C(n+`.dimension must equal numCols`);if(R(e.starts,t+1,n+`.starts`),e.starts[0]!==0)throw C(n+`.starts must begin with zero`);for(let t=1;t<e.starts.length;t++)if(e.starts[t]<e.starts[t-1])throw C(n+`.starts must be monotonic`);let r=e.starts[t];return R(e.indices,r,n+`.indices`,t),L(e.values,r,n+`.values`),r}function te(e){if(!e||typeof e!=`object`)throw C(`model must be an object`);let t=j(e.numCols,`numCols`,0),n=j(e.numRows,`numRows`,0);L(e.colCost,t,`colCost`),L(e.colLower,t,`colLower`),L(e.colUpper,t,`colUpper`),L(e.rowLower,n,`rowLower`),L(e.rowUpper,n,`rowUpper`);let r=ee(e.matrix,n,t,`matrix`);if(e.integrality!=null){R(e.integrality,t,`integrality`);for(let n=0;n<t;n++)if(e.integrality[n]>4)throw C(`integrality values must be between 0 and 4`)}let i=e.hessian?B(e.hessian,t,`hessian`):0,a=e.sense==null?1:e.sense;if(a!==1&&a!==-1)throw C(`sense must be 1 (minimize) or -1 (maximize)`);if(I(e.offset==null?0:e.offset,`offset`),e.modelName!=null&&typeof e.modelName!=`string`)throw C(`modelName must be a string`);for(let[r,i,a]of[[e.colNames,t,`colNames`],[e.rowNames,n,`rowNames`]])if(r!=null){P(r,i,a);for(let e=0;e<r.length;e++)if(typeof r[e]!=`string`)throw C(a+`[`+e+`] must be a string`)}return{numCols:t,numRows:n,numNonzeros:r,hessianNonzeros:i,sense:a}}function ne(e,t,n){if(!e||typeof e!=`object`)throw C(n+` must be an object`);I(e.weight,n+`.weight`),I(e.offset,n+`.offset`),L(e.coefficients,t,n+`.coefficients`),I(e.absoluteTolerance,n+`.absoluteTolerance`),I(e.relativeTolerance,n+`.relativeTolerance`),M(e.priority,n+`.priority`)}class re{constructor(){this.pointers=[]}bytes(e){j(e,`allocation size`,0);let t=Kt(Math.max(1,e));if(!t)throw RangeError(`Unable to allocate WebAssembly memory`);return this.pointers.push(t),t}ints(e){let t=this.bytes(e.length*4);return b().set(e,t>>2),t}doubles(e){let t=this.bytes(e.length*8);return x().set(e,t>>3),t}pack(e){let t=[],n=0;for(let r of e){let e=r.type===`f64`?8:4;n=Math.ceil(n/e)*e,t.push(n),n+=r.values.length*e}let r=this.bytes(n);return e.forEach((e,n)=>{let i=r+t[n];e.type===`f64`?x().set(e.values,i>>3):b().set(e.values,i>>2)}),t.map(e=>r+e)}outInts(e){let t=this.bytes(e*4);return b().fill(0,t>>2,(t>>2)+e),t}outDoubles(e){let t=this.bytes(e*8);return x().fill(0,t>>3,(t>>3)+e),t}free(){for(let e=this.pointers.length-1;e>=0;e--)Gt(this.pointers[e]);this.pointers.length=0}}function H(e){let t=new re;try{return e(t)}finally{t.free()}}function U(e,t){return b().slice(e>>2,(e>>2)+t)}function W(e,t){return x().slice(e>>3,(e>>3)+t)}function ie(e){return new BigInt64Array(y().buffer,e,1)[0]}function ae(e){return`/tmp/highs-js-`+l+++`.`+e}function oe(e,t){if(!e||e.format!==`lp`&&e.format!==`mps`)throw C(`format must be 'lp' or 'mps'`);if(!(typeof e.data==`string`||ArrayBuffer.isView(e.data)))throw C(`model data must be a string or Uint8Array`);let n=ae(e.format);try{return X.writeFile(n,e.data),t(n)}finally{try{X.unlink(n)}catch{}}}function se(e,t,n){if(typeof e!=`string`)throw C(`data must be a string`);let r=ae(t);try{return X.writeFile(r,e),n(r)}finally{try{X.unlink(r)}catch{}}}function ce(e,t,n){let r=ae(e);try{let e=n(r);return e===-1?k(e):k(e,X.readFile(r,t===`utf8`?{encoding:`utf8`}:void 0))}finally{try{X.unlink(r)}catch{}}}function G(e){return/thread|parallel|concurr/i.test(e)||/(^|_)(log_file|read_.*_file|write_.*_file|solution_file|.*_file)$/.test(e)||/^write_.*_to_file$/.test(e)}function K(e){if(typeof e!=`string`||!e)throw C(`option name is required`);if(G(e))throw E(e)}function le(e){if(typeof e!=`string`||!e)throw C(`option name is required`);return!G(e)}function ue(e){if(typeof e!=`string`)throw C(`option data must be a string`);for(let t of e.split(/\r?\n/)){let e=/^\s*([A-Za-z][A-Za-z0-9_]*)\b/.exec(t);e&&!t.trimStart().startsWith(`#`)&&K(e[1])}}function de(e,t,n,r){if(!e||typeof e!=`object`)throw C(r+` selection must be tagged`);if(e.kind===`range`){let n=j(e.from,r+`.from`,0),i=j(e.to,r+`.to`,0);if(i<n||i>=t)throw C(r+` range is outside the model`);return{suffix:`ByRange`,prefix:[n,i],count:i-n+1}}if(e.kind===`set`){R(e.indices,null,r+`.indices`,t);for(let t=1;t<e.indices.length;t++)if(e.indices[t]<=e.indices[t-1])throw C(r+` set indices must increase strictly`);return{suffix:`BySet`,prefix:[e.indices.length,n.ints(e.indices)],count:e.indices.length}}if(e.kind===`mask`){P(e.mask,t,r+`.mask`);let i=new Int32Array(t),a=0;for(let n=0;n<t;n++){if(e.mask[n]!==!1&&e.mask[n]!==!0&&e.mask[n]!==0&&e.mask[n]!==1)throw C(r+`.mask values must be boolean, 0, or 1`);i[n]=+!!e.mask[n],a+=i[n]}return{suffix:`ByMask`,prefix:[n.ints(i)],count:a}}throw C(r+`.kind must be 'range', 'set', or 'mask'`)}function q(e){return{numCols:_(`Highs_getNumCol`,1)(e),numRows:_(`Highs_getNumRow`,1)(e),numNonzeros:_(`Highs_getNumNz`,1)(e),hessianNonzeros:_(`Highs_getHessianNumNz`,1)(e)}}function fe(e){return{numCols:_(`Highs_getPresolvedNumCol`,1)(e),numRows:_(`Highs_getPresolvedNumRow`,1)(e),numNonzeros:_(`Highs_getPresolvedNumNz`,1)(e)}}class pe{constructor(e){t.set(this,void 0),n.set(this,void 0),this._callbackNumCols=0,Dn(this,t,e,`f`),Dn(this,n,!1,`f`),this._callbackDepth=0,this._callbackId=0,this._callbackError=void 0,this._callbackErrorPending=!1,o.set(e,this)}get disposed(){return On(this,n,`f`)}_require(e=!1){if(On(this,n,`f`))throw w();if(this._callbackDepth&&!e)throw D();return On(this,t,`f`)}_rememberCallbackError(e){this._callbackErrorPending||=(this._callbackError=e,!0)}_throwCallbackError(){if(!this._callbackErrorPending)return;let e=this._callbackError;throw this._callbackError=void 0,this._callbackErrorPending=!1,e}clear(){return this._simple(`Highs_clear`)}clearSolver(){return this._simple(`Highs_clearSolver`)}presolve(){return this._simple(`Highs_presolve`)}getRunTime(){return _(`Highs_getRunTime`,1)(this._require(!1))}readModel(e){let t=this._require(!1);return O(oe(e,function(e){return v(`Highs_readModel`,1,0)(t,e)}))}exportPresolvedModel(e){let t=this._require(!1);if(e!==`lp`&&e!==`mps`)throw C(`format must be 'lp' or 'mps'`);return ce(e,e===`lp`?`utf8`:void 0,function(e){return v(`Highs_writePresolvedModel`,1,0)(t,e)})}passModel(e){let t=this._require(!1),n=H(function(n){let r=he(e,n);return _(`Highs_passModel`,21).apply(null,[t].concat(r.values))}),r=n===-1?n:ge(t,e);return O(n===-1||r===-1?-1:Math.max(n,r))}passMip(e){let t=this._require(!1),n=H(function(n){let i=te(e),a=e.matrix;if(!e.integrality)throw C(`passMip requires an integrality vector`);let o=me(e,n,!0);return _(`Highs_passMip`,16)(t,i.numCols,i.numRows,i.numNonzeros,r[a.format],i.sense,e.offset==null?0:e.offset,...o)}),i=n===-1?n:ge(t,e);return O(n===-1||i===-1?-1:Math.max(n,i))}passHessian(e){let t=this._require(!1),n=q(t).numCols;return O(H(function(r){let a=B(e,n,`hessian`);return _(`Highs_passHessian`,7)(t,n,a,i[e.format],r.ints(Array.prototype.slice.call(e.starts,0,-1)),r.ints(e.indices),r.doubles(e.values))}))}addLinearObjective(e){let t=this._require(!1),n=q(t).numCols;return ne(e,n,`objective`),O(H(function(n){return _(`Highs_addLinearObjective`,7)(t,e.weight,e.offset,n.doubles(e.coefficients),e.absoluteTolerance,e.relativeTolerance,M(e.priority,`priority`))}))}passRowName(e,t){let n=this._require(!1);if(j(e,`row`,0),typeof t!=`string`)throw C(`name must be a string`);return O(v(`Highs_passRowName`,2,0)(n,e,t))}passModelName(e){if(typeof e!=`string`)throw C(`name must be a string`);return O(v(`Highs_passModelName`,1,0)(this._require(!1),e))}getOptionType(e){let t=this._require(!1);return le(e)?H(function(n){let r=n.outInts(1);return k(v(`Highs_getOptionType`,1,1)(t,e,r),[`boolean`,`integer`,`double`,`string`][b()[r>>2]])}):k(-1)}resetOptions(){return this._simple(`Highs_resetOptions`)}exportOptions(e){let t=this._require(!1),n=ce(`options`,`utf8`,function(n){return v(e?`Highs_writeOptionsDeviations`:`Highs_writeOptions`,1,0)(t,n)});return n.status!==-1&&(n.value=n.value.split(/\r?\n/).filter(function(e){let t=/^\s*([A-Za-z][A-Za-z0-9_]*)\b/.exec(e);return!t||!G(t[1])}).join(`
|
|
5
|
+
`)),n}getOptionName(e){let t=this._require(!1);return j(e,`option index`,0),H(function(n){let r=n.outInts(1),i=_(`Highs_getOptionName`,3)(t,e,r),a=b()[r>>2]>>>0;if(!a)return k(i,``);try{return k(i,S(a))}finally{Gt(a)}})}getInfoType(e){let t=this._require(!1);if(typeof e!=`string`||!e)throw C(`info name is required`);return H(function(n){let r=n.outInts(1),i=v(`Highs_getInfoType`,1,1)(t,e,r),a=b()[r>>2];return k(i,a===-1?`int64`:a===1?`integer`:a===2?`double`:void 0)})}getDimensions(){return q(this._require(!1))}getInfinity(){return _(`Highs_getInfinity`,1)(this._require(!1))}getModelStatus(){return _(`Highs_getModelStatus`,1)(this._require(!1))}getSolution(){let e=this._require(!1),t=this.getModelStatus();if(t===0||t===6)throw new d(`The model has not been solved`,`getSolution`);let n=q(e);return H(function(t){let r=t.outDoubles(n.numCols),i=t.outDoubles(n.numCols),a=t.outDoubles(n.numRows),o=t.outDoubles(n.numRows);return k(_(`Highs_getSolution`,5)(e,r,i,a,o),{colValue:W(r,n.numCols),rowValue:W(a,n.numRows),colDual:W(i,n.numCols),rowDual:W(o,n.numRows)})})}setSolution(e){let t=this._require(!1),n=q(t);return O(H(function(r){function i(e,t,n){return e==null?0:(L(e,t,n),r.doubles(e))}return _(`Highs_setSolution`,5)(t,i(e.colValue,n.numCols,`colValue`),i(e.rowValue,n.numRows,`rowValue`),i(e.colDual,n.numCols,`colDual`),i(e.rowDual,n.numRows,`rowDual`))}))}setBasis(e){let t=this._require(!1),n=q(t);if(!e)throw C(`basis is required`);return R(e.colStatus,n.numCols,`colStatus`),R(e.rowStatus,n.numRows,`rowStatus`),O(H(function(n){return _(`Highs_setBasis`,3)(t,n.ints(e.colStatus),n.ints(e.rowStatus))}))}postsolve(e){let t=this._require(!1),n=fe(t);if(!e||e.colValue==null)throw C(`postsolve requires colValue`);return L(e.colValue,n.numCols,`colValue`),e.colDual!=null&&L(e.colDual,n.numCols,`colDual`),e.rowDual!=null&&L(e.rowDual,n.numRows,`rowDual`),O(H(function(n){return _(`Highs_postsolve`,4)(t,n.doubles(e.colValue),e.colDual?n.doubles(e.colDual):0,e.rowDual?n.doubles(e.rowDual):0)}))}getObjectiveOffset(){let e=this._require(!1);return H(function(t){let n=t.outDoubles(1);return k(_(`Highs_getObjectiveOffset`,2)(e,n),x()[n>>3])})}getModel(e){return _e(this,`Highs_getModel`,e,!0)}getPresolvedLp(e){return _e(this,`Highs_getPresolvedLp`,e,!1)}getFixedLp(e){let t=_e(this,`Highs_getFixedLp`,e,!1);return t.status!==-1&&t.value&&t.value.integrality.fill(0),t}ensureRowwise(){return this._simple(`Highs_ensureRowwise`)}addVars(e,t){let n=this._require(!1);return N(e,`lower`),L(t,e.length,`upper`),L(e,e.length,`lower`),O(H(function(r){return _(`Highs_addVars`,4)(n,e.length,r.doubles(e),r.doubles(t))}))}addCol(e,t,n,r){let i=this._require(!1);return I(e,`cost`),I(t,`lower`),I(n,`upper`),ve(r,q(i).numRows),O(H(function(a){return _(`Highs_addCol`,7)(i,e,t,n,r.indices.length,a.ints(r.indices),a.doubles(r.values))}))}addCols(e){let t=this._require(!1),n=q(t).numRows;if(!e||!e.matrix)throw C(`column data and matrix are required`);let r=e.cost.length;if(L(e.cost,r,`cost`),L(e.lower,r,`lower`),L(e.upper,r,`upper`),e.matrix.format!==`csc`)throw C(`addCols requires a csc matrix`);let i=ee(e.matrix,n,r,`matrix`);return O(H(function(n){return _(`Highs_addCols`,9)(t,r,n.doubles(e.cost),n.doubles(e.lower),n.doubles(e.upper),i,n.ints(Array.prototype.slice.call(e.matrix.starts,0,-1)),n.ints(e.matrix.indices),n.doubles(e.matrix.values))}))}changeObjectiveSense(e){if(e!==1&&e!==-1)throw C(`sense must be 1 or -1`);return O(_(`Highs_changeObjectiveSense`,2)(this._require(!1),e))}changeColIntegrality(e,t){if(j(e,`column`,0),j(t,`integrality`,0),t>4)throw C(`integrality must be between 0 and 4`);return O(_(`Highs_changeColIntegrality`,3)(this._require(!1),e,t))}changeColCost(e,t){return j(e,`column`,0),I(t,`cost`),O(_(`Highs_changeColCost`,3)(this._require(!1),e,t))}changeRowBounds(e,t,n){return j(e,`row`,0),I(t,`lower`),I(n,`upper`),O(_(`Highs_changeRowBounds`,4)(this._require(!1),e,t,n))}changeColsIntegrality(e,t){let n=q(this._require(!1)).numCols;return J(this,`changeColsIntegrality`,e,[],[t],n,`columns`)}changeColsBounds(e,t,n){let r=q(this._require(!1)).numCols;return J(this,`changeColsBounds`,e,[t,n],[],r,`columns`)}deleteCols(e){return ye(this,`Cols`,e,q(this._require(!1)).numCols)}scaleCol(e,t){return j(e,`column`,0),I(t,`factor`),O(_(`Highs_scaleCol`,3)(this._require(!1),e,t))}getCols(e){return Y(this,`Cols`,e)}getColName(e){return be(this,`Highs_js_getColName`,e)}getPresolvedColName(e){return be(this,`Highs_js_getPresolvedColName`,e)}getColByName(e){return xe(this,`Col`,e)}getColIntegrality(e){let t=this._require(!1);return j(e,`column`,0),H(function(n){let r=n.outInts(1);return k(_(`Highs_getColIntegrality`,3)(t,e,r),b()[r>>2])})}getPrimalRay(){return Se(this,`Highs_getPrimalRay`,q(this._require(!1)).numCols)}getDualUnboundednessDirection(){return Se(this,`Highs_getDualUnboundednessDirection`,q(this._require(!1)).numCols)}getBasisInverseRow(e,t){return Ce(this,`Highs_getBasisInverseRow`,e,q(this._require(!1)).numRows,t)}getBasisSolve(e,t){return we(this,`Highs_getBasisSolve`,e,t)}getReducedRow(e,t){let n=this._require(!1),r=q(n);return j(e,`row`,0),H(function(i){let a=i.outDoubles(r.numCols),o=i.outInts(1),s=i.outInts(r.numCols),c=_(`Highs_getReducedRow`,5)(n,e,a,o,s),l={values:W(a,r.numCols)};return t&&(l.nonzeroIndices=U(s,b()[o>>2])),k(c,l)})}crossover(e){let t=this._require(!1),n=q(t);if(!e||e.colValue==null)throw C(`crossover requires colValue`);if(L(e.colValue,n.numCols,`colValue`),e.colDual==null!=(e.rowDual==null))throw C(`colDual and rowDual must be supplied together`);return e.colDual&&L(e.colDual,n.numCols,`colDual`),e.rowDual&&L(e.rowDual,n.numRows,`rowDual`),O(H(function(r){return _(`Highs_crossover`,6)(t,n.numCols,n.numRows,r.doubles(e.colValue),e.colDual?r.doubles(e.colDual):0,e.rowDual?r.doubles(e.rowDual):0)}))}getRanging(){let e=this._require(!1),t=q(e);return H(function(n){let r=Te(n,t.numCols),i=Te(n,t.numCols),a=Te(n,t.numCols),o=Te(n,t.numCols),s=Te(n,t.numRows),c=Te(n,t.numRows),l=[r,i,a,o,s,c],u=[e];return l.forEach(function(e){u.push(e.valuePointer,e.objectivePointer,e.inPointer,e.outPointer)}),k(_(`Highs_getRanging`,u.length).apply(null,u),{colCostUp:r.detach(),colCostDown:i.detach(),colBoundUp:a.detach(),colBoundDown:o.detach(),rowBoundUp:s.detach(),rowBoundDown:c.detach()})})}setCallback(e){let t=this._require(!1);if(e!=null&&typeof e!=`function`)throw C(`callback must be a function or undefined`);let n=this._callbackId;if(!e){let e=_(`Highs_js_setCallback`,3)(t,0,0);return e!==-1&&(n&&a.delete(n),this._callbackId=0),O(e)}let r=c++;a.set(r,{raw:this,callback:e});let i=_(`Highs_js_setCallback`,3)(t,Ae(),r);return i===-1?a.delete(r):(n&&a.delete(n),this._callbackId=r),O(i)}startCallback(e){return je(e),O(_(`Highs_startCallback`,2)(this._require(!1),e))}dispose(){if(On(this,n,`f`))return;let e=this._require(!1);this._callbackId&&a.delete(this._callbackId),o.delete(e),_(`Highs_destroy`,1,null)(e),Dn(this,t,0,`f`),Dn(this,n,!0,`f`)}_simple(e){return O(_(e,1)(this._require(!1)))}clearModel(){return this._simple(`Highs_clearModel`)}releaseMemory(){return this._simple(`Highs_releaseMemory`)}zeroAllClocks(){return this._simple(`Highs_zeroAllClocks`)}run(){let e=this._require(!1);return this._callbackNumCols=q(e).numCols,O(_(`Highs_run`,1)(e))}exportModel(e){let t=this._require(!1);if(e!==`lp`&&e!==`mps`)throw C(`format must be 'lp' or 'mps'`);return ce(e,e===`lp`?`utf8`:void 0,function(e){return v(`Highs_writeModel`,1,0)(t,e)})}exportSolution(e){let t=this._require(!1);return ce(`sol`,`utf8`,function(n){return v(e?`Highs_writeSolutionPretty`:`Highs_writeSolution`,1,0)(t,n)})}passLp(e){let t=this._require(!1),n=H(function(n){let i=te(e),a=e.matrix,o=me(e,n,!1);return _(`Highs_passLp`,15)(t,i.numCols,i.numRows,i.numNonzeros,r[a.format],i.sense,e.offset==null?0:e.offset,...o)}),i=n===-1?n:ge(t,e);return O(n===-1||i===-1?-1:Math.max(n,i))}passLinearObjectives(e){let t=this._require(!1),n=q(t).numCols;return N(e,`objectives`),O(H(function(r){let i=e.length,a=new Float64Array(i),o=new Float64Array(i),s=new Float64Array(i*n),c=new Float64Array(i),l=new Float64Array(i),u=new Int32Array(i);for(let t=0;t<i;t++){let r=e[t];ne(r,n,`objectives[`+t+`]`),a[t]=r.weight,o[t]=r.offset,s.set(r.coefficients,t*n),c[t]=r.absoluteTolerance,l[t]=r.relativeTolerance,u[t]=M(r.priority,`objectives[`+t+`].priority`)}return _(`Highs_passLinearObjectives`,8)(t,i,r.doubles(a),r.doubles(o),r.doubles(s),r.doubles(c),r.doubles(l),r.ints(u))}))}clearLinearObjectives(){return this._simple(`Highs_clearLinearObjectives`)}passColName(e,t){let n=this._require(!1);if(j(e,`column`,0),typeof t!=`string`)throw C(`name must be a string`);return O(v(`Highs_passColName`,2,0)(n,e,t))}setOptionValue(e,t){let n=this._require(!1);if(!le(e))return O(-1);let r=typeof t,i;if(r===`boolean`)i=v(`Highs_setBoolOptionValue`,1,1)(n,e,+!!t);else if(r===`string`)i=g(`Highs_setStringOptionValue`,`number`,[`number`,`string`,`string`])(n,e,t);else if(r===`number`){if(!Number.isFinite(t))throw C(`numeric option values must be finite`);Number.isSafeInteger(t)&&t>=-2147483648&&t<=2147483647?(i=v(`Highs_setIntOptionValue`,1,1)(n,e,t),i===-1&&(i=v(`Highs_setDoubleOptionValue`,1,1)(n,e,t))):i=v(`Highs_setDoubleOptionValue`,1,1)(n,e,t)}else throw C(`option values must be boolean, number, or string`);return O(i)}getOptionValue(e){let t=this._require(!1);if(!le(e))return k(-1);let n=this.getOptionType(e);return n.status===-1?k(-1):H(function(r){if(n.value===`string`){let n=r.bytes(512);return k(v(`Highs_getStringOptionValue`,1,1)(t,e,n),S(n))}if(n.value===`double`){let n=r.outDoubles(1);return k(v(`Highs_getDoubleOptionValue`,1,1)(t,e,n),x()[n>>3])}let i=r.outInts(1),a=v(n.value===`boolean`?`Highs_getBoolOptionValue`:`Highs_getIntOptionValue`,1,1)(t,e,i),o=b()[i>>2];return k(a,n.value===`boolean`?!!o:o)})}readOptions(e){let t=this._require(!1);if(typeof e!=`string`)throw C(`option data must be a string`);for(let t of e.split(/\r?\n/)){let e=/^\s*([A-Za-z][A-Za-z0-9_]*)\b/.exec(t);if(e&&!t.trimStart().startsWith(`#`)&&!le(e[1]))return O(-1)}return O(se(e,`options`,function(e){return v(`Highs_readOptions`,1,0)(t,e)}))}getNumOptions(){return _(`Highs_getNumOptions`,1)(this._require(!1))}getOptionValues(e){let t=this._require(!1);if(!le(e))return k(-1);let n=this.getOptionType(e);return n.status===-1?k(-1):H(function(r){let i=n.value;if(i===`boolean`){let n=r.outInts(1),a=r.outInts(1);return k(v(`Highs_getBoolOptionValues`,1,2)(t,e,n,a),{name:e,type:i,current:!!b()[n>>2],default:!!b()[a>>2]})}if(i===`integer`){let n=r.outInts(1),a=r.outInts(1),o=r.outInts(1),s=r.outInts(1);return k(v(`Highs_getIntOptionValues`,1,4)(t,e,n,a,o,s),{name:e,type:i,current:b()[n>>2],default:b()[s>>2],minimum:b()[a>>2],maximum:b()[o>>2]})}if(i===`double`){let n=r.outDoubles(1),a=r.outDoubles(1),o=r.outDoubles(1),s=r.outDoubles(1);return k(v(`Highs_getDoubleOptionValues`,1,4)(t,e,n,a,o,s),{name:e,type:i,current:x()[n>>3],default:x()[s>>3],minimum:x()[a>>3],maximum:x()[o>>3]})}let a=r.bytes(512),o=r.bytes(512);return k(v(`Highs_getStringOptionValues`,1,2)(t,e,a,o),{name:e,type:i,current:S(a),default:S(o)})})}getInfoValue(e){let t=this._require(!1),n=this.getInfoType(e);return n.status===-1?k(-1):H(function(r){if(n.value===`double`){let n=r.outDoubles(1);return k(v(`Highs_getDoubleInfoValue`,1,1)(t,e,n),x()[n>>3])}if(n.value===`int64`){let n=r.bytes(8);return k(v(`Highs_getInt64InfoValue`,1,1)(t,e,n),ie(n))}let i=r.outInts(1);return k(v(`Highs_getIntInfoValue`,1,1)(t,e,i),b()[i>>2])})}getPresolvedDimensions(){return fe(this._require(!1))}getSizeofHighsInt(){return _(`Highs_getSizeofHighsInt`,1)(this._require(!1))}getObjectiveValue(){return _(`Highs_getObjectiveValue`,1)(this._require(!1))}getBasis(){let e=this._require(!1),t=this.getModelStatus();if(t===0||t===6)throw new d(`The model has not been solved`,`getBasis`);let n=q(e);return H(function(t){let r=t.outInts(n.numCols),i=t.outInts(n.numRows);return k(_(`Highs_getBasis`,3)(e,r,i),{colStatus:U(r,n.numCols),rowStatus:U(i,n.numRows)})})}setSparseSolution(e){let t=this._require(!1);if(!e)throw C(`solution is required`);let n=e.indices.length;return R(e.indices,null,`indices`,q(t).numCols),L(e.values,n,`values`),O(H(function(r){return _(`Highs_setSparseSolution`,4)(t,n,r.ints(e.indices),r.doubles(e.values))}))}setLogicalBasis(){return this._simple(`Highs_setLogicalBasis`)}getObjectiveSense(){let e=this._require(!1);return H(function(t){let n=t.outInts(1);return k(_(`Highs_getObjectiveSense`,2)(e,n),b()[n>>2])})}getLp(e){return _e(this,`Highs_getLp`,e,!1)}getIisLp(e){return _e(this,`Highs_getIisLp`,e,!1)}ensureColwise(){return this._simple(`Highs_ensureColwise`)}addVar(e,t){return I(e,`lower`),I(t,`upper`),O(_(`Highs_addVar`,3)(this._require(!1),e,t))}addRow(e,t,n){let r=this._require(!1);return I(e,`lower`),I(t,`upper`),ve(n,q(r).numCols),O(H(function(i){return _(`Highs_addRow`,6)(r,e,t,n.indices.length,i.ints(n.indices),i.doubles(n.values))}))}addRows(e){let t=this._require(!1),n=q(t).numCols;if(!e||!e.matrix)throw C(`row data and matrix are required`);let r=e.lower.length;if(L(e.lower,r,`lower`),L(e.upper,r,`upper`),e.matrix.format!==`csr`)throw C(`addRows requires a csr matrix`);let i=ee(e.matrix,r,n,`matrix`);return O(H(function(n){return _(`Highs_addRows`,8)(t,r,n.doubles(e.lower),n.doubles(e.upper),i,n.ints(Array.prototype.slice.call(e.matrix.starts,0,-1)),n.ints(e.matrix.indices),n.doubles(e.matrix.values))}))}changeObjectiveOffset(e){return I(e,`offset`),O(_(`Highs_changeObjectiveOffset`,2)(this._require(!1),e))}clearIntegrality(){return this._simple(`Highs_clearIntegrality`)}changeColBounds(e,t,n){return j(e,`column`,0),I(t,`lower`),I(n,`upper`),O(_(`Highs_changeColBounds`,4)(this._require(!1),e,t,n))}changeCoeff(e,t,n){return j(e,`row`,0),j(t,`column`,0),I(n,`value`),O(_(`Highs_changeCoeff`,4)(this._require(!1),e,t,n))}changeColsCost(e,t){let n=q(this._require(!1)).numCols;return J(this,`changeColsCost`,e,[t],[],n,`columns`)}changeRowsBounds(e,t,n){let r=q(this._require(!1)).numRows;return J(this,`changeRowsBounds`,e,[t,n],[],r,`rows`)}deleteRows(e){return ye(this,`Rows`,e,q(this._require(!1)).numRows)}scaleRow(e,t){return j(e,`row`,0),I(t,`factor`),O(_(`Highs_scaleRow`,3)(this._require(!1),e,t))}getRows(e){return Y(this,`Rows`,e)}getRowName(e){return be(this,`Highs_js_getRowName`,e)}getPresolvedRowName(e){return be(this,`Highs_js_getPresolvedRowName`,e)}getRowByName(e){return xe(this,`Row`,e)}getDualRay(){return Se(this,`Highs_getDualRay`,q(this._require(!1)).numRows)}getBasicVariables(){let e=this._require(!1),t=q(e).numRows;return H(function(n){let r=n.outInts(t);return k(_(`Highs_getBasicVariables`,2)(e,r),U(r,t))})}getBasisInverseCol(e,t){return Ce(this,`Highs_getBasisInverseCol`,e,q(this._require(!1)).numRows,t)}getBasisTransposeSolve(e,t){return we(this,`Highs_getBasisTransposeSolve`,e,t)}getReducedColumn(e,t){return Ce(this,`Highs_getReducedColumn`,e,q(this._require(!1)).numRows,t)}feasibilityRelaxation(e){let t=this._require(!1),n=q(t);if(!e)throw C(`relaxation input is required`);return I(e.globalLowerPenalty,`globalLowerPenalty`),I(e.globalUpperPenalty,`globalUpperPenalty`),I(e.globalRowPenalty,`globalRowPenalty`),O(H(function(r){function i(e,t,n){return e==null?0:(L(e,t,n),r.doubles(e))}return _(`Highs_feasibilityRelaxation`,7)(t,e.globalLowerPenalty,e.globalUpperPenalty,e.globalRowPenalty,i(e.localLowerPenalty,n.numCols,`localLowerPenalty`),i(e.localUpperPenalty,n.numCols,`localUpperPenalty`),i(e.localRowPenalty,n.numRows,`localRowPenalty`))}))}getIis(){let e=this._require(!1),t=q(e);return H(function(n){let r=n.outInts(1),i=n.outInts(1),a=n.outInts(t.numCols),o=n.outInts(t.numRows),s=n.outInts(t.numCols),c=n.outInts(t.numRows),l=n.outInts(t.numCols),u=n.outInts(t.numRows),d=_(`Highs_getIis`,9)(e,r,i,a,o,s,c,l,u);if(d===-1)return k(d);let f=b()[r>>2],p=b()[i>>2];if(f<0||f>t.numCols||p<0||p>t.numRows)throw RangeError(`HiGHS returned invalid IIS dimensions`);return k(d,{colIndex:U(a,f),rowIndex:U(o,p),colBound:U(s,f),rowBound:U(c,p),colStatus:U(l,t.numCols),rowStatus:U(u,t.numRows)})})}stopCallback(e){return je(e),O(_(`Highs_stopCallback`,2)(this._require(!1),e))}}t=new WeakMap,n=new WeakMap;function me(e,t,n){let r=e.matrix;return t.pack([{type:`f64`,values:e.colCost},{type:`f64`,values:e.colLower},{type:`f64`,values:e.colUpper},{type:`f64`,values:e.rowLower},{type:`f64`,values:e.rowUpper},{type:`i32`,values:Array.prototype.slice.call(r.starts,0,-1)},{type:`i32`,values:r.indices},{type:`f64`,values:r.values},...n?[{type:`i32`,values:e.integrality}]:[]])}function he(e,t){let n=te(e),a=e.matrix,o=e.hessian,s=t.pack([{type:`f64`,values:e.colCost},{type:`f64`,values:e.colLower},{type:`f64`,values:e.colUpper},{type:`f64`,values:e.rowLower},{type:`f64`,values:e.rowUpper},{type:`i32`,values:Array.prototype.slice.call(a.starts,0,-1)},{type:`i32`,values:a.indices},{type:`f64`,values:a.values},...o?[{type:`i32`,values:Array.prototype.slice.call(o.starts,0,-1)},{type:`i32`,values:o.indices},{type:`f64`,values:o.values}]:[],...e.integrality?[{type:`i32`,values:e.integrality}]:[]]),c=0,l=s[c++],u=s[c++],d=s[c++],f=s[c++],p=s[c++],m=s[c++],h=s[c++],g=s[c++],_=o?s[c++]:0,v=o?s[c++]:0,y=o?s[c++]:0,b=e.integrality?s[c]:0;return{shape:n,values:[n.numCols,n.numRows,n.numNonzeros,n.hessianNonzeros,r[a.format],o?i[o.format]:1,n.sense,e.offset==null?0:e.offset,l,u,d,f,p,m,h,g,_,v,y,b]}}function ge(e,t){let n=0;if(t.modelName!=null&&(n=Math.max(n,v(`Highs_passModelName`,1,0)(e,String(t.modelName)))),t.colNames!=null){P(t.colNames,t.numCols,`colNames`);for(let r=0;r<t.colNames.length;r++){let i=v(`Highs_passColName`,2,0)(e,r,String(t.colNames[r]));if(i===-1)return i;n=Math.max(n,i)}}if(t.rowNames!=null){P(t.rowNames,t.numRows,`rowNames`);for(let r=0;r<t.rowNames.length;r++){let i=v(`Highs_passRowName`,2,0)(e,r,String(t.rowNames[r]));if(i===-1)return i;n=Math.max(n,i)}}return n}function _e(e,t,n,i){let a=e._require(!1),o=t!==`Highs_getFixedLp`,s=n??`csc`;if(!(s in r))throw C(`format must be 'csc' or 'csr'`);let c=t===`Highs_getModel`||t===`Highs_getLp`?q(a):t===`Highs_getPresolvedLp`?fe(a):t===`Highs_getFixedLp`?q(a):void 0;return H(function(e){let n=e.outInts(1),l=e.outInts(1),u=e.outInts(1),d=i?e.outInts(1):0,f=e.outInts(1),p=e.outDoubles(1),m=i?21:o?16:15,h=0,g=c?.numCols??0,v=c?.numRows??0,y=c?.numNonzeros??0,S=i?c?.hessianNonzeros??0:0;if(!c){let e=i?[a,r[s],1,n,l,u,d,f,p]:[a,r[s],n,l,u,f,p],c=i?Array(12).fill(0):Array(o?9:8).fill(0);if(h=_(t,m).apply(null,e.concat(c)),h===-1)return k(h);g=b()[n>>2],v=b()[l>>2],y=b()[u>>2],S=i?b()[d>>2]:0}let C=s===`csc`?g:v,w=e.outDoubles(g),T=e.outDoubles(g),E=e.outDoubles(g),D=e.outDoubles(v),O=e.outDoubles(v),A=e.outInts(C),j=e.outInts(y),M=e.outDoubles(y),N=o?e.outInts(g):0,P=i?e.outInts(g):0,F=i?e.outInts(S):0,I=i?e.outDoubles(S):0,L=i?[a,r[s],1,n,l,u,d,f,p,w,T,E,D,O,A,j,M,P,F,I,N]:[a,r[s],n,l,u,f,p,w,T,E,D,O,A,j,M].concat(o?[N]:[]);if(h=_(t,m).apply(null,L),h===-1)return k(h);let R=new Int32Array(C+1);R.set(U(A,C)),R[C]=y;let z={numCols:g,numRows:v,sense:b()[f>>2],offset:x()[p>>3],colCost:W(w,g),colLower:W(T,g),colUpper:W(E,g),rowLower:W(D,v),rowUpper:W(O,v),matrix:{format:s,numRows:v,numCols:g,starts:R,indices:U(j,y),values:W(M,y)},integrality:o?U(N,g):new Int32Array(g)};if(i&&S){let e=new Int32Array(g+1);e.set(U(P,g)),e[g]=S,z.hessian={format:`triangular`,dimension:g,starts:e,indices:U(F,S),values:W(I,S)}}return k(h,z)})}function ve(e,t){if(!e)throw C(`entries are required`);R(e.indices,null,`entries.indices`,t),L(e.values,e.indices.length,`entries.values`)}function J(e,t,n,r,i,a,o){let s=e._require(!1);return O(H(function(e){let c=de(n,a,e,o),l=c.suffix===`ByMask`?a:c.count,u=r.map(function(t,n){return L(t,l,o+` values `+n),e.doubles(t)}),d=i.map(function(t,n){return R(t,l,o+` integer values `+n),e.ints(t)}),f=[s].concat(c.prefix,u,d);return _(`Highs_`+t+c.suffix,f.length).apply(null,f)}))}function ye(e,t,n,r){let i=e._require(!1);return O(H(function(e){let a=de(n,r,e,t.toLowerCase()),o=[i].concat(a.prefix);return _(`Highs_delete`+t+a.suffix,o.length).apply(null,o)}))}function Y(e,t,n){let r=e._require(!1),i=q(r),a=t===`Cols`,o=a?i.numCols:i.numRows;return H(function(e){let s=de(n,o,e,t.toLowerCase()),c=e.outInts(1),l=e.outInts(1),u=a?3:2,d=[r].concat(s.prefix,[c],Array(u).fill(0),[l,0,0,0]),f=`Highs_get`+t+s.suffix,p=_(f,d.length).apply(null,d);if(p===-1)return k(p);let m=b()[c>>2],h=b()[l>>2],g=a?e.outDoubles(m):0,v=e.outDoubles(m),y=e.outDoubles(m),x=e.outInts(m),S=e.outInts(h),C=e.outDoubles(h),w=[r].concat(s.prefix,[c],a?[g,v,y]:[v,y],[l,x,S,C]);if(p=_(f,w.length).apply(null,w),p===-1)return k(p);let T=new Int32Array(m+1);T.set(U(x,m)),T[m]=h;let E={format:a?`csc`:`csr`,numRows:a?i.numRows:m,numCols:a?m:i.numCols,starts:T,indices:U(S,h),values:W(C,h)};return k(p,a?{count:m,cost:W(g,m),lower:W(v,m),upper:W(y,m),matrix:E}:{count:m,lower:W(v,m),upper:W(y,m),matrix:E})})}function be(e,t,n){let r=e._require(!1);return j(n,`index`,0),H(function(e){let i=e.outInts(1),a=_(t,5)(r,n,0,0,i);if(a===-1)return k(a);let o=b()[i>>2];if(o<=0)return k(a,``);let s=e.bytes(o);return a=_(t,5)(r,n,s,o,i),k(a,S(s))})}function xe(e,t,n){let r=e._require(!1);if(typeof n!=`string`)throw C(`name must be a string`);return H(function(e){let i=e.outInts(1);return k(v(`Highs_get`+t+`ByName`,1,1)(r,n,i),b()[i>>2])})}function Se(e,t,n){let r=e._require(!1);return H(function(e){let i=e.outInts(1),a=e.outDoubles(n);return k(_(t,3)(r,i,a),b()[i>>2]?{values:W(a,n)}:void 0)})}function Ce(e,t,n,r,i){let a=e._require(!1);return H(function(e){let o=e.outDoubles(r),s=e.outInts(1),c=e.outInts(r);if(n==null)throw C(`an index is required`);j(n,`index`,0);let l=[a,n,o,s,c],u=_(t,l.length).apply(null,l),d={values:W(o,r)};return i&&(d.nonzeroIndices=U(c,b()[s>>2])),k(u,d)})}function we(e,t,n,r){let i=e._require(!1),a=q(i).numRows;return L(n,a,`rhs`),H(function(e){let o=e.outDoubles(a),s=e.outInts(1),c=e.outInts(a),l=_(t,5)(i,e.doubles(n),o,s,c),u={values:W(o,a)};return r&&(u.nonzeroIndices=U(c,b()[s>>2])),k(l,u)})}function Te(e,t){return{valuePointer:e.outDoubles(t),objectivePointer:e.outDoubles(t),inPointer:e.outInts(t),outPointer:e.outInts(t),detach:function(){return{value:W(this.valuePointer,t),objective:W(this.objectivePointer,t),inVariable:U(this.inPointer,t),outVariable:U(this.outPointer,t)}}}}function Ee(e,t){return v(`Highs_getCallbackDataOutItem`,1,0)(e,t)}function De(e,t,n){let r=Ee(e,t);if(r)return n===`double`?x()[r>>3]:n===`int64`?ie(r):b()[r>>2]}let Oe=[[`running_time`,`double`],[`objective_function_value`,`double`],[`mip_node_count`,`int64`],[`mip_total_lp_iterations`,`int64`],[`mip_primal_bound`,`double`],[`mip_dual_bound`,`double`],[`mip_gap`,`double`]];function ke(e,t,n,r,i){let o=a.get(i);if(!o)return;let s=o.raw,c=o.callback,l=!0;function u(){if(!l)throw C(`callback controls expire when the callback returns`)}s._callbackDepth+=1;try{let i={numCols:s._callbackNumCols},a={};if((e===0?[[`log_type`,`int`]]:e===1?[[`simplex_iteration_count`,`int`]]:e===2?[[`ipm_iteration_count`,`int`]]:e>=3&&e<=9?Oe:[]).forEach(function(e){let t=De(n,e[0],e[1]);t!==void 0&&(a[e[0]]=t)}),e===3||e===4){let e=Ee(n,`mip_solution`),t=_(`Highs_js_getCallbackMipSolutionSize`,1)(n);if(t<0)throw RangeError(`HiGHS returned an invalid MIP solution size`);if(e)a.mip_solution=W(e,t);else if(t)throw RangeError(`HiGHS returned a null MIP solution`)}if(e===7){let e=De(n,`cutpool_num_cut`,`int`),t=De(n,`cutpool_num_nz`,`int`),r=De(n,`cutpool_num_col`,`int`);if(typeof e==`number`&&typeof t==`number`&&typeof r==`number`&&e>=0&&t>=0){let i=Ee(n,`cutpool_start`),o=Ee(n,`cutpool_index`),s=Ee(n,`cutpool_value`),c=Ee(n,`cutpool_lower`),l=Ee(n,`cutpool_upper`);i&&o&&s&&c&&l&&(a.cut_pool={numCols:r,numCuts:e,starts:U(i,e+1),indices:U(o,t),values:W(s,t),lower:W(c,e),upper:W(l,e)})}}let o={type:e,message:S(t),data:a};e===9?(o.setSolution=function(e){u();try{return e&&e.indices?(R(e.indices,null,`indices`,i.numCols),L(e.values,e.indices.length,`values`),O(H(function(t){return _(`Highs_setCallbackSparseSolution`,4)(r,e.indices.length,t.ints(e.indices),t.doubles(e.values))}))):(L(e,i.numCols,`solution`),O(H(function(t){return _(`Highs_setCallbackSolution`,3)(r,i.numCols,t.doubles(e))})))}catch(e){return s._rememberCallbackError(e),O(-1)}},o.repairSolution=function(){return u(),O(_(`Highs_repairCallbackSolution`,1)(r))}):(e===1||e===2||e===6)&&(o.interrupt=function(){u(),b()[r>>2]=1});let l=c(o);if(l&&(typeof l==`object`||typeof l==`function`)&&typeof l.then==`function`)throw Promise.resolve(l).catch(function(){}),C(`callbacks must be synchronous and return undefined`)}catch(t){s._rememberCallbackError(t),(e===1||e===2||e===6)&&r&&(b()[r>>2]=1)}finally{l=!1,--s._callbackDepth}}function Ae(){return u||=Rt(ke,`viiiii`),u}function je(e){if(j(e,`callback type`,0),e===8||e>9)throw C(`callback type must be one of 0..7 or 9`)}function Me(e,t,n=void 0){if(e.status===-1)throw T(t);return n&&n._setLast(e.status,t),e.value}class Ne{constructor(e){this.raw=e,this.lastCall={status:0,warnings:[]},this.options=new Pe(this),this.info=new Fe(this)}get disposed(){return this.raw.disposed}_setLast(e,t){return this.lastCall=A(e,t),this.lastCall}_value(e,t=[]){return Me(this.raw[e].apply(this.raw,t||[]),e,this)}exportModel(e){return this._value(`exportModel`,[e])}exportSolution(e){return this._value(`exportSolution`,[e])}getPresolvedDimensions(){return this.raw.getPresolvedDimensions()}getModelStatus(){return this.raw.getModelStatus()}setSolution(e){if(e==null)throw C(`solution is required`);return this._status(e.indices?`setSparseSolution`:`setSolution`,[e])}setLogicalBasis(){return this._status(`setLogicalBasis`)}dispose(){this.raw.dispose()}_status(e,t=[]){let n=this.raw[e].apply(this.raw,t||[]);return this._setLast(n.status,e)}exportPresolvedModel(e){return this._value(`exportPresolvedModel`,[e])}getDimensions(){return this.raw.getDimensions()}getRunTime(){return this.raw.getRunTime()}getObjectiveValue(){return this.raw.getObjectiveValue()}getObjectiveSense(){return this._value(`getObjectiveSense`)}getObjectiveOffset(){return this._value(`getObjectiveOffset`)}setBasis(e){return e==null?this._status(`setLogicalBasis`):this._status(`setBasis`,[e])}run(e){let t=this.raw,n=[],r=!1;try{if(e&&Object.keys(e).length){if(t._callbackId)throw C(`run callbacks cannot replace a callback registered through model.raw`);if(t.setCallback(function(t){let n=e[t.type];if(n)return n(t)}).status===-1)throw T(`setCallback`);r=!0,Object.keys(e).forEach(function(e){let r=Number(e);if(je(r),t.startCallback(r).status===-1)throw T(`startCallback`);n.push(r)})}let i=t.run(),a=this._setLast(i.status,`run`);return{status:a.status,warnings:a.warnings,modelStatus:t.getModelStatus()}}finally{try{for(let e=0;e<n.length;e++)t.stopCallback(n[e])}finally{r&&t.setCallback(void 0)}}}clear(...e){return this._status(`clear`,e)}clearModel(...e){return this._status(`clearModel`,e)}clearSolver(...e){return this._status(`clearSolver`,e)}releaseMemory(...e){return this._status(`releaseMemory`,e)}readModel(...e){return this._status(`readModel`,e)}passModel(...e){return this._status(`passModel`,e)}passHessian(...e){return this._status(`passHessian`,e)}passLinearObjectives(...e){return this._status(`passLinearObjectives`,e)}addLinearObjective(...e){return this._status(`addLinearObjective`,e)}clearLinearObjectives(...e){return this._status(`clearLinearObjectives`,e)}presolve(...e){return this._status(`presolve`,e)}postsolve(...e){return this._status(`postsolve`,e)}zeroAllClocks(...e){return this._status(`zeroAllClocks`,e)}addVar(...e){return this._status(`addVar`,e)}addVars(...e){return this._status(`addVars`,e)}addCol(...e){return this._status(`addCol`,e)}addCols(...e){return this._status(`addCols`,e)}addRow(...e){return this._status(`addRow`,e)}addRows(...e){return this._status(`addRows`,e)}ensureColwise(...e){return this._status(`ensureColwise`,e)}ensureRowwise(...e){return this._status(`ensureRowwise`,e)}changeObjectiveSense(...e){return this._status(`changeObjectiveSense`,e)}changeObjectiveOffset(...e){return this._status(`changeObjectiveOffset`,e)}changeColIntegrality(...e){return this._status(`changeColIntegrality`,e)}changeColsIntegrality(...e){return this._status(`changeColsIntegrality`,e)}clearIntegrality(...e){return this._status(`clearIntegrality`,e)}changeColCost(...e){return this._status(`changeColCost`,e)}changeColsCost(...e){return this._status(`changeColsCost`,e)}changeColBounds(...e){return this._status(`changeColBounds`,e)}changeColsBounds(...e){return this._status(`changeColsBounds`,e)}changeRowBounds(...e){return this._status(`changeRowBounds`,e)}changeRowsBounds(...e){return this._status(`changeRowsBounds`,e)}deleteCols(...e){return this._status(`deleteCols`,e)}deleteRows(...e){return this._status(`deleteRows`,e)}scaleCol(...e){return this._status(`scaleCol`,e)}scaleRow(...e){return this._status(`scaleRow`,e)}passColName(...e){return this._status(`passColName`,e)}passRowName(...e){return this._status(`passRowName`,e)}passModelName(...e){return this._status(`passModelName`,e)}crossover(...e){return this._status(`crossover`,e)}feasibilityRelaxation(...e){return this._status(`feasibilityRelaxation`,e)}changeCoefficient(...e){return this._status(`changeCoeff`,e)}getSolution(...e){return this._value(`getSolution`,e)}getBasis(...e){return this._value(`getBasis`,e)}getPrimalRay(...e){return this._value(`getPrimalRay`,e)}getDualRay(...e){return this._value(`getDualRay`,e)}getDualUnboundednessDirection(...e){return this._value(`getDualUnboundednessDirection`,e)}getModel(...e){return this._value(`getModel`,e)}getLp(...e){return this._value(`getLp`,e)}getPresolvedLp(...e){return this._value(`getPresolvedLp`,e)}getIisLp(...e){return this._value(`getIisLp`,e)}getFixedLp(...e){return this._value(`getFixedLp`,e)}getCols(...e){return this._value(`getCols`,e)}getRows(...e){return this._value(`getRows`,e)}getColName(...e){return this._value(`getColName`,e)}getRowName(...e){return this._value(`getRowName`,e)}getPresolvedColName(...e){return this._value(`getPresolvedColName`,e)}getPresolvedRowName(...e){return this._value(`getPresolvedRowName`,e)}getColByName(...e){return this._value(`getColByName`,e)}getRowByName(...e){return this._value(`getRowByName`,e)}getColIntegrality(...e){return this._value(`getColIntegrality`,e)}getBasicVariables(...e){return this._value(`getBasicVariables`,e)}getBasisInverseRow(...e){return this._value(`getBasisInverseRow`,e)}getBasisInverseCol(...e){return this._value(`getBasisInverseCol`,e)}getBasisSolve(...e){return this._value(`getBasisSolve`,e)}getBasisTransposeSolve(...e){return this._value(`getBasisTransposeSolve`,e)}getReducedRow(...e){return this._value(`getReducedRow`,e)}getReducedColumn(...e){return this._value(`getReducedColumn`,e)}getRanging(...e){return this._value(`getRanging`,e)}getIis(...e){return this._value(`getIis`,e)}}class Pe{constructor(e){this._model=e}set(e,t){if(typeof e==`object`&&e){Object.keys(e).forEach(K);let t=0;return Object.keys(e).forEach(function(n){let r=this._model.raw.setOptionValue(n,e[n]);if(r.status===-1)throw T(`setOptionValue`);t=Math.max(t,r.status)}.bind(this)),this._model._setLast(t,`setOptionValue`)}return K(e),this._model._status(`setOptionValue`,[e,t])}describe(e){return K(e),this._model._value(`getOptionValues`,[e])}reset(){return this._model._status(`resetOptions`)}export(e){return this._model._value(`exportOptions`,[e])}get(e){return K(e),this._model._value(`getOptionValue`,[e])}names(){let e=this._model.raw.getNumOptions(),t=[];for(let n=0;n<e;n++){let e=this._model.raw.getOptionName(n);if(e.status===-1)throw T(`getOptionName`);G(e.value)||t.push(e.value)}return t}read(e){return ue(e),this._model._status(`readOptions`,[e])}}class Fe{constructor(e){this._model=e}get(e){return this._model._value(`getInfoValue`,[e])}type(e){return this._model._value(`getInfoType`,[e])}}function Z(){let e=_(`Highs_create`,0)();if(!e)throw Error(`Highs_create failed`);let t=Re(new pe(e));return v(`Highs_setIntOptionValue`,1,1)(e,`threads`,1),g(`Highs_setStringOptionValue`,`number`,[`number`,`string`,`string`])(e,`parallel`,`off`),t}function Le(e){let t=Re(new Ne(Z()));try{return e&&(e.format===`lp`||e.format===`mps`?t.readModel(e):t.passModel(e)),t}catch(e){throw t.dispose(),e}}function Re(e){let t=Symbol.dispose;return t!==void 0&&Object.defineProperty(e,t,{configurable:!0,writable:!0,value:e.dispose}),e}function Q(e){return e!==null&&(typeof e==`object`||typeof e==`function`)&&typeof e.then==`function`}function ze(e,t=void 0){let n=typeof e!=`function`,r=n?e:void 0,i=n?t:e;if(typeof i!=`function`)throw C(`withModel requires a callback`);let a=Le(r);try{let e=i(a);return Q(e)?Promise.resolve(e).finally(function(){a.dispose()}):(a.dispose(),e)}catch(e){throw a.dispose(),e}}function $(e,t){let n=te(t);return H(function(a){let o=t.matrix,s=e===`Highs_mipCall`,c=a.outDoubles(n.numCols),l=s?0:a.outDoubles(n.numCols),u=a.outDoubles(n.numRows),d=s?0:a.outDoubles(n.numRows),f=s?0:a.outInts(n.numCols),p=s?0:a.outInts(n.numRows),m=a.outInts(1),h=me(t,a,s),g=[n.numCols,n.numRows,n.numNonzeros,r[o.format],n.sense,t.offset==null?0:t.offset,...h.slice(0,8)],v;if(e===`Highs_mipCall`){if(!t.integrality)throw C(`mipCall requires integrality`);v=g.concat([h[8],c,u,m])}else if(e===`Highs_qpCall`){if(!t.hessian)throw C(`qpCall requires hessian`);let e=t.hessian;v=g.slice(0,3).concat([n.hessianNonzeros,r[o.format],i[e.format],n.sense,t.offset==null?0:t.offset,...h.slice(0,8),a.ints(Array.prototype.slice.call(e.starts,0,-1)),a.ints(e.indices),a.doubles(e.values),c,l,u,d,f,p,m])}else v=g.concat([c,l,u,d,f,p,m]);let y=_(e,v.length).apply(null,v);return s?k(y,{modelStatus:b()[m>>2],solution:{colValue:W(c,n.numCols),rowValue:W(u,n.numRows)}}):k(y,{modelStatus:b()[m>>2],solution:{colValue:W(c,n.numCols),rowValue:W(u,n.numRows),colDual:W(l,n.numCols),rowDual:W(d,n.numRows)},basis:{colStatus:U(f,n.numCols),rowStatus:U(p,n.numRows)}})})}let Be=Object.freeze({major:_(`Highs_versionMajor`,0)(),minor:_(`Highs_versionMinor`,0)(),patch:_(`Highs_versionPatch`,0)(),string:g(`Highs_version`,`string`,[])(),gitHash:g(`Highs_githash`,`string`,[])()}),Ve=Object.freeze({status:Object.freeze({error:-1,ok:0,warning:1}),variableType:Object.freeze({continuous:0,integer:1,semiContinuous:2,semiInteger:3,implicitInteger:4}),objectiveSense:Object.freeze({minimize:1,maximize:-1}),matrixFormat:Object.freeze({columnWise:1,rowWise:2}),hessianFormat:Object.freeze({triangular:1,square:2}),optionType:Object.freeze({boolean:0,integer:1,double:2,string:3}),infoType:Object.freeze({int64:-1,integer:1,double:2}),solutionStatus:Object.freeze({none:0,infeasible:1,feasible:2}),basisValidity:Object.freeze({invalid:0,valid:1}),basisStatus:Object.freeze({lower:0,basic:1,upper:2,zero:3,nonbasic:4}),callbackType:Object.freeze({logging:0,simplexInterrupt:1,ipmInterrupt:2,mipSolution:3,mipImprovingSolution:4,mipLogging:5,mipInterrupt:6,mipCutPool:7,mipUserSolution:9}),presolveStatus:Object.freeze({notPresolved:-1,notReduced:0,infeasible:1,unboundedOrInfeasible:2,reduced:3,reducedToEmpty:4,timeout:5,nullError:6,optionsError:7,outOfMemory:8}),modelStatus:Object.freeze({notSet:0,loadError:1,modelError:2,presolveError:3,solveError:4,postsolveError:5,empty:6,optimal:7,infeasible:8,unboundedOrInfeasible:9,unbounded:10,objectiveBound:11,objectiveTarget:12,timeLimit:13,iterationLimit:14,unknown:15,solutionLimit:16,interrupted:17}),iis:Object.freeze({strategyLight:0,strategyRowPriority:6,strategyColPriority:14,boundFree:1,boundLower:2,boundUpper:3,boundBoxed:4,notInConflict:-1,maybeInConflict:0,inConflict:1})}),He=Z(),Ue=He.getInfinity(),We=He.getSizeofHighsInt();if(He.dispose(),We!==4)throw Error(`This highs-js runtime requires a 32-bit HighsInt build; received `+We*8+` bits`);e.version=Be,e.infinity=Ue,e.intBytes=We,e.intBits=We*8,Object.defineProperty(e,"memoryBytes",{enumerable:!0,get:function(){return y().buffer.byteLength}}),e.constants=Ve,e.errors=Object.freeze({HighsError:d,HighsDisposedError:f,HighsValidationError:p,HighsReentrancyError:m,HighsUnsupportedOptionError:h}),e.createModel=Le,e.withModel=ze,e.raw=Object.freeze({version:function(){return Be},lpCall:function(e){return $(`Highs_lpCall`,e)},mipCall:function(e){return $(`Highs_mipCall`,e)},qpCall:function(e){return $(`Highs_qpCall`,e)},createModel:Z})})(n),n}})();typeof e==`object`&&typeof t==`object`?(t.exports=n,t.exports.default=n):typeof define==`function`&&define.amd&&define([],()=>n)})),Oe=l({default:()=>ke.default}),ke,Ae=s((()=>{ke=d(De(),1)})),je=null,Me=null,Ne=null;function Pe(e){Ne=e,je=null,Me=null}function Fe(){return Ne}async function X(e){return e||Ne||Ee()}async function Ie(e={}){let t=await X(e.wasmUrl),n=t??`node`;if(je&&Me===n)return je;Me=n;let r=(async()=>{let e=(await Promise.resolve().then(()=>(Ae(),Oe))).default;return await e({locateFile:e=>e.endsWith(`.wasm`)?t:e})})().catch(e=>{je===r&&(je=null,Me=null);let n=e instanceof Error?e.message:String(e);throw Error(`[WaSHI] Failed to initialize HiGHS${t?` from "${t}"`:``}. Deploy the package's WASM asset or explicitly set wasmUrl; no CDN fallback is attempted. ${n}`,{cause:e})});return je=r,r}var Z={0:`Not Set`,1:`Load error`,2:`Model error`,3:`Presolve error`,4:`Solve error`,5:`Postsolve error`,6:`Empty`,7:`Optimal`,8:`Infeasible`,9:`Primal infeasible or unbounded`,10:`Unbounded`,11:`Bound on objective reached`,12:`Target for objective reached`,13:`Time limit reached`,14:`Iteration limit reached`,15:`Unknown`,16:`Solution limit reached`,17:`Interrupted`,18:`Memory limit reached`};async function Le(e,t={}){if(t.signal?.aborted)return{result:{Status:`Interrupted`,StatusCode:17,HasPrimalSolution:!1,ObjectiveValue:NaN,Columns:{},Rows:[]},runTime:0};let n=await Ie(t);if(t.signal?.aborted)return{result:{Status:`Interrupted`,StatusCode:17,HasPrimalSolution:!1,ObjectiveValue:NaN,Columns:{},Rows:[]},runTime:0};let r=performance.now(),i={output_flag:t.outputFlag??!1};t.timeLimit!==void 0&&(i.time_limit=t.timeLimit),t.presolve!==void 0&&(i.presolve=t.presolve),t.solver!==void 0&&(i.solver=t.solver),t.relGap===void 0?t.mipGap!==void 0&&(i.mip_rel_gap=t.mipGap):i.mip_rel_gap=t.relGap,t.absGap!==void 0&&(i.mip_abs_gap=t.absGap);for(let e of[`mip_max_nodes`,`mip_max_improving_sols`,`mip_max_leaves`,`simplex_iteration_limit`,`ipm_iteration_limit`])t[e]!==void 0&&(i[e]=t[e]);let a=typeof t.objectiveOffset==`number`&&Number.isFinite(t.objectiveOffset)?t.objectiveOffset:0,o=t.initialValues,s=!1;if(o){for(let[e,t]of Object.entries(o))if(t!==void 0){if(typeof t!=`number`||!Number.isFinite(t))throw Error(`Invalid initial value for column "${e}": ${String(t)} (must be a finite number).`);s=!0}}if(typeof n.withModel==`function`)return{result:n.withModel({format:`lp`,data:e},e=>{if(a!==0&&typeof e.changeObjectiveOffset==`function`){let t=typeof e.getObjectiveOffset==`function`?e.getObjectiveOffset():0;e.changeObjectiveOffset(t+a)}for(let[t,r]of Object.entries(i))try{e.options.set(t,r)}catch(e){if(e?.name!==`HighsUnsupportedOptionError`&&!(n.errors?.HighsUnsupportedOptionError&&e instanceof n.errors.HighsUnsupportedOptionError))throw e}let c=e.getDimensions(),l=[],u=!1;for(let t=0;t<c.numCols;t++){let n=e.getColIntegrality(t);n!==0&&(u=!0),l.push({name:e.getColName(t),type:n===1?`Integer`:`Continuous`})}if(s&&o){if(typeof e.setSolution!=`function`)throw Error(`HiGHS runtime does not support setting primal initial values (setSolution is unavailable).`);let t=new Map;for(let e=0;e<c.numCols;e++)t.set(l[e].name,e);for(let[e,n]of Object.entries(o))if(n!==void 0&&!t.has(e))throw Error(`Unknown column "${e}" in initialValues (column does not exist in the HiGHS LP model).`);let n=[],r=[];for(let e=0;e<c.numCols;e++){let t=l[e].name;if(Object.prototype.hasOwnProperty.call(o,t)){let i=o[t];i!==void 0&&(n.push(e),r.push(i))}}n.length>0&&(n.length===c.numCols?e.setSolution({colValue:r}):e.setSolution({indices:n,values:r}))}let d=null,f=null,p=0,m=e=>{let t=e?.data??{},n=typeof t.running_time==`number`&&Number.isFinite(t.running_time)?t.running_time:(performance.now()-r)/1e3,i=typeof t.mip_primal_bound==`number`&&Number.isFinite(t.mip_primal_bound)?t.mip_primal_bound:typeof t.objective_function_value==`number`&&Number.isFinite(t.objective_function_value)?t.objective_function_value:void 0,a=typeof t.mip_dual_bound==`number`&&Number.isFinite(t.mip_dual_bound)?t.mip_dual_bound:void 0,o=typeof t.mip_gap==`number`&&Number.isFinite(t.mip_gap)?t.mip_gap:void 0,s=i!==void 0&&a!==void 0?Math.abs(i-a):void 0,c=typeof t.mip_node_count==`bigint`?Number(t.mip_node_count):typeof t.mip_node_count==`number`&&Number.isFinite(t.mip_node_count)?t.mip_node_count:void 0,l=typeof t.mip_total_lp_iterations==`bigint`?Number(t.mip_total_lp_iterations):typeof t.simplex_iteration_count==`number`&&Number.isFinite(t.simplex_iteration_count)?t.simplex_iteration_count:typeof t.ipm_iteration_count==`number`&&Number.isFinite(t.ipm_iteration_count)?t.ipm_iteration_count:void 0,u=typeof e?.message==`string`&&e.message.trim().length>0?e.message.trim():void 0,d={elapsedTime:n,elapsedSeconds:n,...i===void 0?{}:{objectiveValue:i},...a===void 0?{}:{objectiveBound:a},...o===void 0?{}:{relGap:o,mipGap:o},...s===void 0?{}:{absGap:s},...c===void 0?{}:{nodes:c},...l===void 0?{}:{iterations:l},...u===void 0?{}:{message:u}};return f=d,d},h=e=>{let n=e?.data;if(!n||!(n.mip_solution instanceof Float64Array))return;let r=n.mip_solution,i={};for(let e=0;e<l.length&&e<r.length;e++)Object.defineProperty(i,l[e].name,{value:{Index:e,Type:l[e].type,Name:l[e].name,Primal:r[e]},enumerable:!0,writable:!0,configurable:!0});let a=typeof n.objective_function_value==`number`&&Number.isFinite(n.objective_function_value)?n.objective_function_value:typeof n.mip_primal_bound==`number`&&Number.isFinite(n.mip_primal_bound)?n.mip_primal_bound:NaN;Number.isFinite(a)&&(d={objectiveValue:a,...typeof n.mip_dual_bound==`number`&&Number.isFinite(n.mip_dual_bound)?{mipDualBound:n.mip_dual_bound}:{},...typeof n.mip_gap==`number`&&Number.isFinite(n.mip_gap)?{mipGap:n.mip_gap}:{},columns:i},t.onIncumbent?.(d))},g=!1;if(t.signal||t.onProgress||t.onIncumbent){let r=n.constants?.callbackType??{logging:0,simplexInterrupt:1,ipmInterrupt:2,mipSolution:3,mipImprovingSolution:4,mipLogging:5,mipInterrupt:6},i=e=>{if(t.signal?.aborted){g=!0,e.interrupt();return}t.onProgress&&(p++,t.onProgress(m(e)),t.signal?.aborted&&(g=!0,e.interrupt()))},a={[r.simplexInterrupt]:i,[r.ipmInterrupt]:i,[r.mipInterrupt]:i,[r.mipImprovingSolution]:e=>{h(e),t.onProgress&&!t.signal?.aborted&&(p++,t.onProgress(m(e)))},[r.mipLogging]:e=>{t.onProgress&&!t.signal?.aborted&&(p++,t.onProgress(m(e)))}};e.run(a)}else e.run();let _=e.getModelStatus();g&&(_=17);let v=Z[_]??`Unknown`,y=0,b=0;try{y=Number(e.info.get(`primal_solution_status`))}catch{}try{b=Number(e.info.get(`dual_solution_status`))}catch{}let x=n.constants?.solutionStatus?.feasible??2,S=y===x,C=b===x,w=S||C?e.getSolution():null,T=S,E={};if(!S&&d!==null)T=!0,E=d.columns;else for(let e=0;e<c.numCols;e++){let t=l[e],n={Index:e,Type:t.type,Name:t.name};S&&w&&(n.Primal=w.colValue[e]),!u&&C&&w&&(n.Dual=w.colDual[e]),Object.defineProperty(E,t.name,{value:n,enumerable:!0,writable:!0,configurable:!0})}let D=[];for(let t=0;t<c.numRows;t++){let n=e.getRowName(t),r={Index:t,Name:n};S&&w&&(r.Primal=w.rowValue[t]),!u&&C&&w&&(r.Dual=w.rowDual[t]),D.push(r)}let O=S?e.getObjectiveValue():d===null?NaN:d.objectiveValue,k,A;if(u){try{let t=Number(e.info.get(`mip_dual_bound`));Number.isFinite(t)&&(k=t)}catch{}k===void 0&&f&&f.objectiveBound!==void 0&&(k=f.objectiveBound);try{let t=Number(e.info.get(`mip_gap`));Number.isFinite(t)&&(A=t)}catch{}A===void 0&&f&&f.relGap!==void 0&&(A=f.relGap)}return{Status:Z[_]??v,StatusCode:_,PrimalSolutionStatus:y,DualSolutionStatus:b,HasPrimalSolution:T,IsMip:u,ObjectiveValue:O,ObjectiveOffsetApplied:a!==0,MipDualBound:k,MipGap:A,Columns:E,Rows:D}}),runTime:(performance.now()-r)/1e3};if(s)throw Error(`HiGHS runtime does not support setting primal initial values (withModel/setSolution is unavailable).`);return{result:n.solve(e,i),runTime:(performance.now()-r)/1e3}}function Re(){let e=Te(`highs-worker.js`);if(new URL(e).origin===window.location.origin)return new Worker(e,{type:`module`});let t=URL.createObjectURL(new Blob([`import `+JSON.stringify(e)+`;`],{type:`text/javascript`}));try{let e=new Worker(t,{type:`module`}),n=()=>URL.revokeObjectURL(t);return e.addEventListener(`message`,n,{once:!0}),e.addEventListener(`error`,n,{once:!0}),e}catch(e){throw URL.revokeObjectURL(t),e}}var Q=null,ze=0,$=new Map;function Be(e,t){return e?{Status:`Interrupted`,StatusCode:17,HasPrimalSolution:!0,IsMip:!0,ObjectiveValue:e.objectiveValue,ObjectiveOffsetApplied:!0,...t?.objectiveBound===void 0?e.mipDualBound===void 0?{}:{MipDualBound:e.mipDualBound}:{MipDualBound:t.objectiveBound},...t?.relGap===void 0?e.mipGap===void 0?{}:{MipGap:e.mipGap}:{MipGap:t.relGap},Columns:e.columns,Rows:[]}:{Status:`Interrupted`,StatusCode:17,HasPrimalSolution:!1,ObjectiveValue:NaN,ObjectiveOffsetApplied:!0,...t?.objectiveBound===void 0?{}:{MipDualBound:t.objectiveBound},...t?.relGap===void 0?{}:{MipGap:t.relGap},Columns:{},Rows:[]}}function Ve(e){let t=$.values().next().value;if(t&&!t.dispatched){t.dispatched=!0;try{e.postMessage({type:`SOLVE`,id:t.id,lpString:t.lpString,options:t.workerOptions,...t.reportProgress?{reportProgress:!0}:{}})}catch(n){$.delete(t.id),t.cleanupAbort?.(),t.reject(n),Ve(e)}}}function He(){let e=Q;e&&(Q=null,e.terminate());for(let e of $.values())e.dispatched=!1;if($.size>0){let e=Ue();if(e)Ve(e);else{let e=Error(`[WaSHI] Failed to recreate HiGHS Worker after interruption.`);for(let t of Array.from($.values()))$.delete(t.id),t.cleanupAbort?.(),t.reject(e)}}}function Ue(){if(typeof window>`u`||typeof Worker>`u`)return null;if(!Q)try{Q=Re();let e=Q;Q.onmessage=t=>{let{type:n,id:r,result:i,runTime:a,error:o,progress:s,incumbent:c}=t.data,l=$.get(r);if(l){if(n===`SOLVE_PROGRESS`){if(s){l.lastProgress=s;try{l.onProgress?.(s)}catch(e){let t=$.get(r);if(t){let n=$.keys().next().value;$.delete(r),t.cleanupAbort?.(),n===r&&He(),t.reject(e)}}}return}if(n===`SOLVE_INCUMBENT`){c&&(l.lastIncumbent=c);return}$.delete(r),l.cleanupAbort?.(),n===`SOLVE_SUCCESS`?l.resolve({result:i,runTime:a}):l.reject(Error(o||`Worker solve failed`)),Q===e&&Ve(e)}};let t=t=>{if(Q===e){Q=null,e.terminate();for(let e of $.values())e.cleanupAbort?.(),e.reject(t);$.clear()}};Q.onerror=e=>t(Error(`[WaSHI] HiGHS Worker failed to load or execute. Check Worker assets, CORS and CSP. ${e?.message||``}`)),Q.onmessageerror=()=>t(Error(`[WaSHI] Could not deserialize the HiGHS Worker response.`))}catch{Q=null}return Q}async function We(e,t={}){if(t.signal?.aborted)return{result:Be(),runTime:0};let n=await X(t.wasmUrl);if(t.signal?.aborted)return{result:Be(),runTime:0};let r=t.useWorker??typeof window<`u`?Ue():null;if(!r)return Le(e,t);let{signal:i,onProgress:a,...o}=t,s={};for(let[e,t]of Object.entries(o))typeof t!=`function`&&(s[e]=t);s.wasmUrl=n;let c=!!(a||i),l=`req_${++ze}`,u=performance.now();return new Promise((t,n)=>{let o={id:l,lpString:e,workerOptions:s,reportProgress:c,startTime:u,onProgress:a,resolve:t,reject:n};if(i){let e=()=>{let e=$.get(l);if(!e)return;let t=$.keys().next().value;$.delete(l),e.cleanupAbort?.(),t===l&&He();let n=(performance.now()-e.startTime)/1e3;e.resolve({result:Be(e.lastIncumbent,e.lastProgress),runTime:n})};i.addEventListener(`abort`,e,{once:!0}),o.cleanupAbort=()=>i.removeEventListener(`abort`,e)}$.set(l,o),Ve(r)})}function Ge(e,t){if(typeof t==`number`)switch(t){case 0:return`NotSolved`;case 1:case 2:case 3:case 4:case 5:return`Error`;case 6:return`Unknown`;case 7:return`Optimal`;case 8:return`Infeasible`;case 9:return`InfeasibleOrUnbounded`;case 10:return`Unbounded`;case 11:return`ObjectiveBound`;case 12:return`ObjectiveTarget`;case 13:return`TimeLimit`;case 14:return`IterationLimit`;case 15:return`Unknown`;case 16:return`SolutionLimit`;case 17:return`Interrupted`;case 18:return`MemoryLimit`}if(typeof e!=`string`)return`Unknown`;let n=e.trim();if(!n)return`Unknown`;switch(n){case`Optimal`:return`Optimal`;case`Infeasible`:return`Infeasible`;case`Unbounded`:return`Unbounded`;case`Primal infeasible or unbounded`:case`InfeasibleOrUnbounded`:return`InfeasibleOrUnbounded`;case`Time limit reached`:case`TimeLimit`:return`TimeLimit`;case`Iteration limit reached`:case`IterationLimit`:return`IterationLimit`;case`Solution limit reached`:case`SolutionLimit`:return`SolutionLimit`;case`Memory limit reached`:case`MemoryLimit`:return`MemoryLimit`;case`Bound on objective reached`:case`ObjectiveBound`:return`ObjectiveBound`;case`Target for objective reached`:case`ObjectiveTarget`:return`ObjectiveTarget`;case`Interrupted`:case`User interrupt`:return`Interrupted`;case`Feasible`:return`Feasible`;case`Not Set`:return`NotSolved`;case`Load error`:case`Model error`:case`Presolve error`:case`Solve error`:case`Postsolve error`:case`Error`:return`Error`;case`Empty`:case`Unknown`:return`Unknown`}let r=n.toLowerCase();return r.includes(`infeasible`)&&r.includes(`unbounded`)?`InfeasibleOrUnbounded`:r.includes(`infeasible`)?`Infeasible`:r.includes(`unbounded`)?`Unbounded`:r.includes(`time limit`)||r.includes(`timelimit`)?`TimeLimit`:r.includes(`iteration limit`)||r.includes(`iterationlimit`)?`IterationLimit`:r.includes(`solution limit`)||r.includes(`solutionlimit`)?`SolutionLimit`:r.includes(`memory limit`)||r.includes(`memorylimit`)?`MemoryLimit`:r.includes(`bound on objective`)?`ObjectiveBound`:r.includes(`target for objective`)?`ObjectiveTarget`:r.includes(`interrupt`)?`Interrupted`:r.includes(`error`)?`Error`:r===`optimal`?`Optimal`:`Unknown`}function Ke(e,t,n){switch(Ge(e,t)){case`Optimal`:return`Optimal`;case`Infeasible`:return`Infeasible`;case`Unbounded`:return`Unbounded`;case`TimeLimit`:return`TimeLimit`;case`IterationLimit`:return`IterationLimit`;case`Feasible`:return`Feasible`;case`ObjectiveBound`:case`ObjectiveTarget`:case`SolutionLimit`:return n===!1?`Unknown`:`Feasible`;case`MemoryLimit`:case`Interrupted`:return n?`Feasible`:`Unknown`;case`NotSolved`:return`NotSolved`;case`Error`:return`Error`;default:return`Unknown`}}var qe=class e{static capabilities={supportsMIP:!0,supportsQP:!0,supportsWarmStart:!0};name=`HiGHS`;version=`1.15.3`;capabilities=e.capabilities;options;constructor(e={}){this.options=e}async solve(e,t={},n={}){let r=pe(t),i=r?n:t,a={...this.options,...i},o=e.objective.constant||0;for(let t of e.variables)ee(t);let{lpString:s,nameToVar:c,nameToConstraint:l}=r?t:ge(e),u=Object.create(null),d=!1,f=new Set;for(let[e,t]of c.entries()){f.add(t);let n=B(t);n!==void 0&&(u[e]=n,d=!0)}for(let t=0;t<e.variables.length;t++){let n=e.variables[t];if(!f.has(n)){let e=B(n);if(e!==void 0){let r=me(n.name,`x`,t);Object.prototype.hasOwnProperty.call(u,r)||(u[r]=e,d=!0)}}}let p=a;(o!==0||d||p.initialValues!==void 0)&&(p={...p,...o===0?{}:{objectiveOffset:o},initialValues:d?u:void 0});let{result:m,runTime:h}=await We(s,p),g=m?.ObjectiveOffsetApplied?0:o,_=Ge(m?.Status,m?.StatusCode),v=typeof m?.IsMip==`boolean`?m.IsMip:e.variables.some(e=>e.type===`Integer`||e.type===`Binary`),y;if(typeof m?.HasPrimalSolution==`boolean`)y=m.HasPrimalSolution;else{let e=m?.Columns?Object.values(m.Columns):[],t=e.length>0&&e.some(e=>typeof e?.Primal==`number`&&Number.isFinite(e.Primal)),n=typeof m?.ObjectiveValue==`number`&&Number.isFinite(m.ObjectiveValue);y=_===`Infeasible`||_===`Unbounded`||_===`InfeasibleOrUnbounded`||_===`Error`||_===`NotSolved`?!1:_===`Optimal`||_===`Feasible`?n||t:n&&(e.length===0||t)}let b=Ke(m?.Status,m?.StatusCode,y),x=null;y&&typeof m?.ObjectiveValue==`number`&&Number.isFinite(m.ObjectiveValue)&&(x=m.ObjectiveValue+g);let S,C,w;if(typeof m?.MipDualBound==`number`&&Number.isFinite(m.MipDualBound)?S=m.MipDualBound+g:!v&&_===`Optimal`&&x!==null&&(S=x),x!==null&&S!==void 0&&Number.isFinite(S)&&(w=Math.abs(x-S)),g!==0&&v&&x!==null&&S!==void 0&&w!==void 0){if(w===0)C=0;else if(Math.abs(x)>0){let e=w/Math.abs(x);C=Number.isFinite(e)?e:void 0}else C=void 0}else typeof m?.MipGap==`number`&&Number.isFinite(m.MipGap)?C=m.MipGap:v&&_===`Optimal`&&y&&(w===void 0||w===0)&&(C=0);if(!y)return{status:b,terminationStatus:_,hasPrimalSolution:!1,objectiveValue:null,...S===void 0?{}:{objectiveBound:S},...C===void 0?{}:{relGap:C,mipGap:C},...w===void 0?{}:{absGap:w},values:{},reducedCosts:{},duals:{},slacks:{},runTime:h,raw:m};let T=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})},E={},D={},O={},k={};if(m.Columns)for(let[e,t]of Object.entries(m.Columns)){let n=c.get(e);if(n){if(typeof t.Primal==`number`&&Number.isFinite(t.Primal)){let e=Math.abs(t.Primal)<1e-9?0:t.Primal;T(E,n.name,e)}typeof t.Dual==`number`&&Number.isFinite(t.Dual)&&T(O,n.name,Math.abs(t.Dual)<1e-9?0:t.Dual)}}if(m.Rows){let e=Array.isArray(m.Rows)?m.Rows:Object.values(m.Rows);for(let t of e){let e=t.Name,n=e?l.get(e):void 0;if(n&&(typeof t.Dual==`number`&&Number.isFinite(t.Dual)&&T(D,n.name,Math.abs(t.Dual)<1e-9?0:t.Dual),typeof t.Primal==`number`&&Number.isFinite(t.Primal))){let e=n.rhs-t.Primal;T(k,n.name,Math.abs(e)<1e-9?0:e)}}}return{status:b,terminationStatus:_,hasPrimalSolution:!0,objectiveValue:x,...S===void 0?{}:{objectiveBound:S},...C===void 0?{}:{relGap:C,mipGap:C},...w===void 0?{}:{absGap:w},values:E,reducedCosts:O,duals:D,slacks:k,runTime:h,raw:m}}},Je=qe;function Ye(){Y(`highs`,e=>new qe(e)),be(e=>new qe(e))}Ye();var Xe=class{name;capabilities;options;constructor(e={}){this.name=e.name||`MockSolver`,this.capabilities=e.capabilities||{supportsMIP:!0,supportsQP:!0,supportsWarmStart:!0},this.options=e}async solve(e,t={},n={}){let r=pe(t)?n:t,i={...this.options,...r},a=!!(i.values&&Object.keys(i.values).length>0||i.boolValues&&Object.keys(i.boolValues).length>0);if(i.signal?.aborted)return{status:`Unknown`,terminationStatus:`Interrupted`,hasPrimalSolution:!1,objectiveValue:null,values:{},runTime:0,raw:{mock:!0}};if(i.delayMs&&i.delayMs>0&&(await new Promise(e=>{let t=setTimeout(()=>{i.signal?.removeEventListener(`abort`,n),e()},i.delayMs),n=()=>{clearTimeout(t),e()};i.signal?.addEventListener(`abort`,n,{once:!0})}),i.signal?.aborted)){let e=!!(i.hasPrimalSolution??a);return{status:e?`Feasible`:`Unknown`,terminationStatus:`Interrupted`,hasPrimalSolution:e,objectiveValue:e?i.objectiveValue??0:null,...i.objectiveBound===void 0?{}:{objectiveBound:i.objectiveBound},...i.relGap===void 0?i.mipGap===void 0?{}:{relGap:i.mipGap,mipGap:i.mipGap}:{relGap:i.relGap,mipGap:i.relGap},...i.absGap===void 0?{}:{absGap:i.absGap},values:e&&i.values||{},...e&&i.boolValues!==void 0?{boolValues:i.boolValues}:{},runTime:.001,raw:{mock:!0}}}if(i.onProgress&&Array.isArray(i.progressEvents))for(let e of i.progressEvents){if(i.signal?.aborted)break;i.onProgress(e)}let o=i.status||`Optimal`,s=i.terminationStatus??o,c=i.hasPrimalSolution===void 0?o===`Optimal`||o===`Feasible`||o===`Sat`||(o===`TimeLimit`||o===`IterationLimit`||s===`Interrupted`)&&a:i.hasPrimalSolution;if(i.onProgress&&!Array.isArray(i.progressEvents)&&!i.signal?.aborted){let e=c?i.objectiveValue??0:void 0;i.onProgress({elapsedTime:.001,elapsedSeconds:.001,...typeof e==`number`&&Number.isFinite(e)?{objectiveValue:e}:{},...i.objectiveBound===void 0?{}:{objectiveBound:i.objectiveBound},...i.relGap===void 0?i.mipGap===void 0?{}:{relGap:i.mipGap,mipGap:i.mipGap}:{relGap:i.relGap,mipGap:i.relGap},...i.absGap===void 0?{}:{absGap:i.absGap}})}return i.signal?.aborted&&(s=`Interrupted`,c=i.hasPrimalSolution===void 0?a:i.hasPrimalSolution,o=c?`Feasible`:`Unknown`),{status:o,terminationStatus:s,hasPrimalSolution:c,objectiveValue:c?i.objectiveValue??0:null,...i.objectiveBound===void 0?{}:{objectiveBound:i.objectiveBound},...i.relGap===void 0?i.mipGap===void 0?{}:{relGap:i.mipGap,mipGap:i.mipGap}:{relGap:i.relGap,mipGap:i.relGap},...i.absGap===void 0?{}:{absGap:i.absGap},values:c&&i.values||{},...c&&i.boolValues!==void 0?{boolValues:i.boolValues}:{},reducedCosts:i.reducedCosts,duals:i.duals,slacks:i.slacks,runTime:.001,raw:{mock:!0}}}};function Ze(){Y(`mock`,e=>new Xe(e))}Ze();function Qe(e,t){if(e===void 0)return 1e-6;if(typeof e!=`number`||!Number.isFinite(e)||e<0)throw Error(`Invalid ${t}: expected a finite non-negative number, received ${String(e)}.`);return e}function $e(e,t={}){let n=Qe(t.feasibilityTolerance,`feasibilityTolerance`),r=Qe(t.integralityTolerance,`integralityTolerance`),i=t.evaluateLogicalConstraints===void 0||!!t.evaluateLogicalConstraints,a=t.values!==void 0&&t.values!==null;if(t.values!==void 0&&(typeof t.values!=`object`||t.values===null||Array.isArray(t.values)))throw Error(`Invalid values option: expected a plain object mapping variable names to values.`);let o=t.values,s=[],c=Object.create(null),l=[],u=[],d=0,f=e=>{typeof e==`number`&&!Number.isNaN(e)&&e>d&&(d=e)},p=e=>{s.push(e),Object.prototype.hasOwnProperty.call(c,e.name)||(c[e.name]=[]),c[e.name].push(e),e.type!==`missing_value`&&e.type!==`unchecked_constraint`&&f(e.violation)},m=new Map,h=new Map,v=0,y=0,b=0,x=0;for(let t of e.variables){let e=a?Object.prototype.hasOwnProperty.call(o,t.name)?o[t.name]:void 0:t.value;if(e==null){u.push(t.name),p({type:`missing_value`,target:`variable`,name:t.name,actual:e??null,violation:1/0,message:`Variable "${t.name}" has no assigned solution value.`});continue}if(typeof e!=`number`||!Number.isFinite(e)){p({type:`non_finite_value`,target:`variable`,name:t.name,actual:e,violation:1/0,message:`Variable "${t.name}" has non-finite or non-numeric value: ${String(e)}.`});continue}m.set(t,e),v++;let i=t.type===`Binary`||t.type===`BINARY`,s=i||t.type===`Integer`||t.type===`INTEGER`,c=i?Math.max(0,t.lb):t.lb,l=i?Math.min(1,t.ub):t.ub,d=typeof t.lb==`number`&&!Number.isNaN(t.lb)&&t.lb!==1/0,h=typeof t.ub==`number`&&!Number.isNaN(t.ub)&&t.ub!==-1/0;if(!d)p({type:`lower_bound`,target:`variable`,name:t.name,actual:e,limit:t.lb,violation:1/0,message:`Variable "${t.name}" has invalid lower bound (${String(t.lb)}).`});else if(c!==-1/0){let r=e-c,i=Math.max(0,c-e);f(i),i>n&&p({type:`lower_bound`,target:`variable`,name:t.name,actual:e,limit:c,violation:i,signedViolation:r,message:`Variable "${t.name}" value (${e}) violates lower bound (${c}) by ${i}.`})}if(!h)p({type:`upper_bound`,target:`variable`,name:t.name,actual:e,limit:t.ub,violation:1/0,message:`Variable "${t.name}" has invalid upper bound (${String(t.ub)}).`});else if(l!==1/0){let r=e-l,i=Math.max(0,e-l);f(i),i>n&&p({type:`upper_bound`,target:`variable`,name:t.name,actual:e,limit:l,violation:i,signedViolation:r,message:`Variable "${t.name}" value (${e}) violates upper bound (${l}) by ${i}.`})}if(d&&h&&c>l&&c-e<=n&&e-l<=n){let n=c-l;p({type:`lower_bound`,target:`variable`,name:t.name,actual:e,limit:c,violation:n,signedViolation:e-c,message:`Variable "${t.name}" has inverted bounds [${c}, ${l}].`})}if(s){let n=Math.round(e),a=e-n,o=Math.abs(a);f(o),o>r&&p({type:`integrality`,target:`variable`,name:t.name,varType:i?`Binary`:`Integer`,actual:e,nearestInteger:n,violation:o,signedViolation:a,message:`${i?`Binary`:`Integer`} variable "${t.name}" value (${e}) violates integrality by ${o} (nearest integer: ${n}).`})}}for(let t of e.boolVars){let e=a?Object.prototype.hasOwnProperty.call(o,t.name)?o[t.name]:void 0:t.value;if(e==null){u.push(t.name),p({type:`missing_value`,target:`bool_variable`,name:t.name,actual:e??null,violation:1/0,message:`Boolean variable "${t.name}" has no assigned solution value.`});continue}if(typeof e!=`boolean`){p({type:`invalid_boolean_value`,target:`bool_variable`,name:t.name,actual:e,violation:1/0,message:`Boolean variable "${t.name}" has non-boolean value: ${String(e)}.`});continue}h.set(t,e),y++}let S=e=>{let t=e.constant===void 0?0:e.constant;if(typeof t!=`number`||!Number.isFinite(t))return{ok:!1,reason:`non-finite constant (${String(t)})`};let n=t;for(let[t,r]of e.terms){if(typeof r!=`number`||!Number.isFinite(r))return{ok:!1,reason:`non-finite coefficient (${String(r)}) for variable "${t.name}"`};if(r!==0){if(!m.has(t))return{ok:!1,reason:`missing or invalid value for variable "${t.name}"`};if(n+=r*m.get(t),!Number.isFinite(n))return{ok:!1,reason:`linear expression evaluation overflowed finite range`}}}return{ok:!0,value:n}},C=(e,t=n)=>{if(typeof e.rhs!=`number`||!Number.isFinite(e.rhs))return{status:`unchecked`,reason:`non-finite right-hand side (${String(e.rhs)})`};let r=S(e.lhs);if(!r.ok)return{status:`unchecked`,reason:r.reason};let i=r.value,a=i-e.rhs;if(!Number.isFinite(a))return{status:`unchecked`,reason:`constraint residual overflowed finite range`};let o=e.sense===`<=`?Math.max(0,a):e.sense===`>=`?Math.max(0,-a):Math.abs(a);return o>t?{status:`violated`,lhsVal:i,signed:a,violation:o,message:`Constraint "${e.name}" (${i} ${e.sense} ${e.rhs}) violated by ${o}.`}:{status:`satisfied`,lhsVal:i,signed:a,violation:o}};for(let t of e.constraints){let e=C(t);e.status===`unchecked`?(l.push(t.name),p({type:`unchecked_constraint`,target:`constraint`,name:t.name,sense:t.sense,limit:t.rhs,rhs:t.rhs,violation:1/0,message:`Constraint "${t.name}" could not be evaluated: ${e.reason}.`})):e.status===`violated`?(b++,p({type:`linear_constraint`,target:`constraint`,name:t.name,sense:t.sense,actual:e.lhsVal,limit:t.rhs,rhs:t.rhs,violation:e.violation,signedViolation:e.signed,message:e.message})):(b++,f(e.violation))}let T=e=>{if(e instanceof g)return h.has(e)?{ok:!0,value:h.get(e),violation:0}:{ok:!1,reason:`missing or invalid value for Boolean variable "${e.name}"`};if(e instanceof w){let t=C(e,0);if(t.status===`unchecked`)return{ok:!1,reason:t.reason};if(n>0){let r=Math.abs(t.lhsVal-e.rhs);if(r>0&&r<=n)return{ok:!1,reason:`numeric comparison "${e.name}" lies within feasibilityTolerance (${n}) of boundary (${t.lhsVal} vs ${e.rhs})`}}return{ok:!0,value:t.status===`satisfied`,violation:0}}if(e instanceof _)switch(e.op){case`not`:{let t=T(e.children[0]);return t.ok?{ok:!0,value:!t.value,violation:0}:t}case`and`:{let t=0;for(let n of e.children){let e=T(n);if(!e.ok)return e;if(!e.value)return{ok:!0,value:!1,violation:0};e.violation>t&&(t=e.violation)}return{ok:!0,value:!0,violation:t}}case`or`:{let t=!1,n=1/0;for(let r of e.children){let e=T(r);if(!e.ok)return e;e.value&&(t=!0,e.violation<n&&(n=e.violation))}return{ok:!0,value:t,violation:t?n:0}}case`implies`:{let t=T(e.children[0]);if(!t.ok)return t;if(!t.value)return{ok:!0,value:!0,violation:0};let n=T(e.children[1]);return n.ok?{ok:!0,value:n.value,violation:n.value?n.violation:0}:n}case`xor`:{let t=!1,n=0;for(let r of e.children){let e=T(r);if(!e.ok)return e;e.value&&(t=!t,e.violation>n&&(n=e.violation))}return{ok:!0,value:t,violation:t?n:0}}default:return{ok:!1,reason:`unsupported logical operator "${String(e.op)}"`}}return{ok:!1,reason:`unsupported logical expression node`}};for(let t=0;t<e.logicalConstraints.length;t++){let n=e.logicalConstraints[t],r=n.name||`lc_${t+1}`;if(!i){l.push(r),p({type:`unchecked_constraint`,target:`logical_constraint`,name:r,violation:1/0,message:`Logical constraint "${r}" was not evaluated because evaluateLogicalConstraints is false.`});continue}let a=T(n.expr);if(!a.ok){l.push(r),p({type:`unchecked_constraint`,target:`logical_constraint`,name:r,violation:1/0,message:`Logical constraint "${r}" could not be evaluated: ${a.reason}.`});continue}x++,a.value?f(a.violation):p({type:`logical_constraint`,target:`logical_constraint`,name:r,actual:!1,limit:!0,violation:1,signedViolation:-1,message:`Logical constraint "${r}" evaluated to false.`})}let E=v===e.variables.length&&y===e.boolVars.length&&b===e.constraints.length&&x===e.logicalConstraints.length&&l.length===0&&u.length===0;return{valid:E&&s.length===0,complete:E,violations:s,violationsByName:c,uncheckedConstraints:l,missingVariables:u,maxViolation:d,summary:{checkedVariables:v,totalVariables:e.variables.length,checkedBoolVariables:y,totalBoolVariables:e.boolVars.length,checkedLinearConstraints:b,totalLinearConstraints:e.constraints.length,checkedLogicalConstraints:x,totalLogicalConstraints:e.logicalConstraints.length}}}function et(e,t){if(typeof e!=`number`||!Number.isFinite(e)||e<=0)throw Error(`Invalid Big-M value for indicator constraint "${t}": expected a finite positive number, received ${e}.`)}function tt(e,t,n){let r=e.constant===void 0?0:e.constant;if(!Number.isFinite(t)||!Number.isFinite(r))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": constraint contains non-finite constant (${r}) or right-hand side (${t}).`);let i=t-r;if(!Number.isFinite(i))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": effective right-hand side (${t} - ${r}) overflows finite floating-point range. Please rescale coefficients/constants.`);for(let[t,r]of e.terms){if(!Number.isFinite(r))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": variable "${t.name}" has non-finite coefficient (${r}).`);if(Number.isNaN(t.lb)||Number.isNaN(t.ub)||t.lb===1/0||t.ub===-1/0||t.lb>t.ub)throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": variable "${t.name}" has invalid bounds [${t.lb}, ${t.ub}].`)}return i}function nt(e,t,n){let r=tt(e,t,n),i=0;for(let[t,r]of e.terms){if(r===0)continue;let e;if(r>0){if(!Number.isFinite(t.ub))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": variable "${t.name}" lacks a finite upper bound (required because coefficient ${r} is positive in <= constraint). Please set an explicit finite upper bound on the variable or specify { M } explicitly in indicator options.`);e=t.ub}else{if(!Number.isFinite(t.lb))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": variable "${t.name}" lacks a finite lower bound (required because coefficient ${r} is negative in <= constraint). Please set an explicit finite lower bound on the variable or specify { M } explicitly in indicator options.`);e=t.lb}let a=r*e;if(i+=a,!Number.isFinite(a)||!Number.isFinite(i))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": numeric overflow while bounding contribution of variable "${t.name}". Please rescale coefficients/bounds or specify a finite { M } explicitly.`)}let a=i-r;if(!Number.isFinite(a))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": numeric overflow while computing Big-M (${i} - ${r}). Please rescale coefficients/bounds or specify a finite { M } explicitly.`);let o=Math.max(0,a);if(!Number.isFinite(o)||!Number.isFinite(r+o))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": derived Big-M (${o}) or shifted right-hand side overflows finite floating-point range. Please rescale coefficients/bounds or specify a finite { M } explicitly.`);return o}function rt(e,t,n){let r=tt(e,t,n),i=0;for(let[t,r]of e.terms){if(r===0)continue;let e;if(r>0){if(!Number.isFinite(t.lb))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": variable "${t.name}" lacks a finite lower bound (required because coefficient ${r} is positive in >= constraint). Please set an explicit finite lower bound on the variable or specify { M } explicitly in indicator options.`);e=t.lb}else{if(!Number.isFinite(t.ub))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": variable "${t.name}" lacks a finite upper bound (required because coefficient ${r} is negative in >= constraint). Please set an explicit finite upper bound on the variable or specify { M } explicitly in indicator options.`);e=t.ub}let a=r*e;if(i+=a,!Number.isFinite(a)||!Number.isFinite(i))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": numeric overflow while bounding contribution of variable "${t.name}". Please rescale coefficients/bounds or specify a finite { M } explicitly.`)}let a=r-i;if(!Number.isFinite(a))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": numeric overflow while computing Big-M (${r} - ${i}). Please rescale coefficients/bounds or specify a finite { M } explicitly.`);let o=Math.max(0,a);if(!Number.isFinite(o)||!Number.isFinite(r-o))throw Error(`Cannot derive safe Big-M for indicator constraint "${n}": derived Big-M (${o}) or shifted right-hand side overflows finite floating-point range. Please rescale coefficients/bounds or specify a finite { M } explicitly.`);return o}function it(e,t,n,r,i,a,o){if(!(e instanceof W&&(e.type===`Binary`||e.type===`Integer`&&e.lb===0&&e.ub===1)))throw Error(`Indicator variable "${e?.name??String(e)}" must be a Binary variable (or Integer variable with bounds [0, 1]), received "${e?.type??typeof e}" with bounds [${e?.lb}, ${e?.ub}].`);if(!Number.isFinite(e.lb)||!Number.isFinite(e.ub)||e.lb<0||e.ub>1||e.lb>e.ub)throw Error(`Binary indicator variable "${e.name}" has invalid bounds [${e.lb}, ${e.ub}]. Binary variables must stay within [0, 1] with lb <= ub.`);let s=tt(t,r,o);if(i!==0&&i!==1)throw Error(`Invalid activeValue: ${i}. Indicator activation value must be 0 or 1.`);if(n!==`<=`&&n!==`>=`)throw Error(`Invalid indicator sense for "${o}": expected "<=" or ">=", received "${String(n)}".`);if(!Number.isFinite(a)||a<0)throw Error(`Invalid Big-M value for indicator constraint "${o}": expected a finite non-negative number, received ${a}.`);let c=t.terms.get(e);if(c!==void 0&&c!==0)throw Error(`Indicator constraint "${o}" cannot include its own binary activation variable "${e.name}" in the linear expression.`);let l,u;if(i===1?n===`<=`?(l=a,u=s+a):(l=-a,u=s-a):n===`<=`?(l=-a,u=s):(l=a,u=s),!Number.isFinite(u))throw Error(`Cannot construct finite indicator constraint "${o}": shifted right-hand side overflows finite floating-point range. Please rescale coefficients/bounds or specify a smaller finite { M }.`);let d=new Map;for(let[e,n]of t.terms)n!==0&&d.set(e,n);return l!==0&&d.set(e,l),{lhs:new O(d,0),rhs:u}}function at(e){return Array.isArray(e)||typeof e==`object`&&!!e&&!(e instanceof String)&&typeof e[Symbol.iterator]==`function`}function ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof String)&&typeof e[Symbol.iterator]!=`function`}function st(e,t){if(!Number.isInteger(e)||e<0)throw Error(`Invalid count (${e}) for ${t} variable creation: count must be a non-negative integer.`)}var ct=class{name;_sense;_objectiveExpr;variables=[];constraints=[];boolVars=[];logicalConstraints=[];unsatCore=void 0;values=new Map;varMapByName=new Map;varPrefixCounters=new Map;boolVarMapByName=new Map;boolVarPrefixCounters=new Map;constrMapByName=new Map;constrPrefixCounters=new Map;logicalConstrMapByName=new Map;logicalConstrCounter=0;status=`NotSolved`;terminationStatus=`NotSolved`;hasPrimalSolution=!1;objectiveValue=null;objectiveBound=void 0;relGap=void 0;mipGap=void 0;absGap=void 0;runTime=0;solution=null;solver=null;hasSolutionState=!1;modelRevision=0;activeOperationId=0;batchDepth=0;batchMutated=!1;batchUndoActions=[];constructor(e={},t){let n;n=typeof e==`string`?{...t,name:e}:e,this.name=n.name||`OptimizationModel`,this._sense=f(n.sense),this._objectiveExpr=new O,n.solver&&(this.solver=xe(n.solver))}get sense(){return this._sense}set sense(e){let t=f(e);this._sense!==t&&(this._sense=t,this.recordModelMutation())}get objectiveExpr(){return this._objectiveExpr.clone()}set objectiveExpr(e){this.applyObjective(e)}get conflicts(){return this.unsatCore}get numVars(){return this.variables.length}get numConstrs(){return this.constraints.length}clearSolutionFields(){if(this.hasSolutionState||this.status!==`NotSolved`||this.terminationStatus!==`NotSolved`||this.hasPrimalSolution||this.solution!==null||this.unsatCore!==void 0){this.hasSolutionState=!1,this.status=`NotSolved`,this.terminationStatus=`NotSolved`,this.hasPrimalSolution=!1,this.objectiveValue=null,this.objectiveBound=void 0,this.relGap=void 0,this.mipGap=void 0,this.absGap=void 0,this.solution=null,this.runTime=0,this.unsatCore=void 0,this.values.clear();for(let e of this.variables)e.value=null,e.reducedCost=null;for(let e of this.boolVars)e.value=null;for(let e of this.constraints)e.dual=null,e.slack=null}}recordModelMutation(){if(this.batchDepth>0){this.batchMutated=!0;return}this.modelRevision++,this.clearSolutionFields()}notifyMutation(){this.recordModelMutation()}resetSolutionState(){this.recordModelMutation()}runTransactionalBatch(e){if(this.batchDepth>0)return e();let t=this.variables.length,n=this.boolVars.length,r=this.constraints.length,i=this.logicalConstraints.length,a=new Map(this.varPrefixCounters),o=new Map(this.boolVarPrefixCounters),s=new Map(this.constrPrefixCounters),c=this.logicalConstrCounter;this.batchDepth=1,this.batchMutated=!1,this.batchUndoActions=[];try{let t=e();this.batchDepth=0;let n=this.batchMutated;return this.batchMutated=!1,this.batchUndoActions=[],n&&this.recordModelMutation(),t}catch(e){this.batchDepth=0,this.batchMutated=!1;for(let e=t;e<this.variables.length;e++){let t=this.variables[e];this.varMapByName.delete(t.name),t.ownerModel=null,L(t,this)}this.variables.length=t;for(let e=n;e<this.boolVars.length;e++){let t=this.boolVars[e];this.boolVarMapByName.delete(t.name)}this.boolVars.length=n;for(let e=r;e<this.constraints.length;e++){let t=this.constraints[e];this.constrMapByName.delete(t.name)}this.constraints.length=r;for(let e=i;e<this.logicalConstraints.length;e++){let t=this.logicalConstraints[e];this.logicalConstrMapByName.delete(t.name)}this.logicalConstraints.length=i;for(let e=this.batchUndoActions.length-1;e>=0;e--)this.batchUndoActions[e]();throw this.batchUndoActions=[],this.varPrefixCounters=a,this.boolVarPrefixCounters=o,this.constrPrefixCounters=s,this.logicalConstrCounter=c,e}}createDomainVars(e,t,n,r){let i=e.toLowerCase(),a=typeof t==`number`,o=typeof n==`number`,s=at(t),c=at(n);if(o||c){if(a&&st(t,i),o&&st(n,i),!a&&!s||r!==void 0&&!ot(r))throw Error(`Invalid arguments provided for ${i} variable creation`);let c=a?Array.from({length:t},(e,t)=>t):Array.from(t),l=o?Array.from({length:n},(e,t)=>t):n===t?c:Array.from(n),u=r||{},d=u.prefix||u.name||`x`;return this.runTransactionalBatch(()=>{let t=a?[]:{};for(let n of c){let r=o?[]:{};for(let t of l)r[t]=this.addVar({...u,type:e,name:`${d}_${n}_${t}`});t[n]=r}return t})}if(typeof t==`string`||t===void 0){if(n!==void 0&&!ot(n))throw Error(`Invalid arguments provided for ${i} variable creation`);let r=n||{},a=typeof t==`string`?t:r.name;return this.addVar({...r,type:e,name:a})}if(ot(t)){if(n!==void 0)throw Error(`Invalid arguments provided for ${i} variable creation`);let r=t;return this.addVar({...r,type:e})}if(n!==void 0&&!ot(n))throw Error(`Invalid arguments provided for ${i} variable creation`);let l=n||{},u=l.prefix||l.name;if(typeof t==`number`)return st(t,i),this.runTransactionalBatch(()=>{let n=[],r=u||`x`;for(let i=0;i<t;i++)n.push(this.addVar({...l,type:e,name:void 0,prefix:r}));return n});if(at(t))return this.runTransactionalBatch(()=>{let n={};for(let r of t){let t=u?`${u}_${r}`:`${r}`;n[r]=this.addVar({...l,type:e,name:t})}return n});throw Error(`Invalid arguments provided for ${i} variable creation`)}binary(e,t,n){return this.createDomainVars(`Binary`,e,t,n)}integer(e,t,n){return this.createDomainVars(`Integer`,e,t,n)}continuous(e,t,n){return this.createDomainVars(`Continuous`,e,t,n)}bool(e,t,n){let r=typeof e==`number`,i=typeof t==`number`,a=at(e),o=at(t);if(i||o){if(r&&st(e,`boolean`),i&&st(t,`boolean`),!r&&!a||n!==void 0&&!ot(n))throw Error(`Invalid arguments provided for boolean variable creation`);let o=r?Array.from({length:e},(e,t)=>t):Array.from(e),s=i?Array.from({length:t},(e,t)=>t):t===e?o:Array.from(t),c=n||{},l=c.prefix||c.name||`p`;return this.runTransactionalBatch(()=>{let e=r?[]:{};for(let t of o){let n=i?[]:{};for(let e of s)n[e]=this.createBoolVar(`${l}_${t}_${e}`);e[t]=n}return e})}if(typeof e==`string`||e===void 0){if(t!==void 0&&!ot(t))throw Error(`Invalid arguments provided for boolean variable creation`);let n=t||{},r=typeof e==`string`?e:n.name;return this.createBoolVar(r,n.prefix)}if(ot(e)){if(t!==void 0)throw Error(`Invalid arguments provided for boolean variable creation`);let n=e;return this.createBoolVar(n.name,n.prefix)}if(t!==void 0&&!ot(t))throw Error(`Invalid arguments provided for boolean variable creation`);let s=t||{},c=s.prefix||s.name;if(typeof e==`number`)return st(e,`boolean`),this.runTransactionalBatch(()=>{let t=[],n=c||`p`;for(let r=0;r<e;r++)t.push(this.createBoolVar(void 0,n));return t});if(at(e))return this.runTransactionalBatch(()=>{let t={};for(let n of e){let e=c?`${c}_${n}`:`${n}`;t[n]=this.createBoolVar(e)}return t});throw Error(`Invalid arguments provided for boolean variable creation`)}hasVarName(e){return this.varMapByName.has(e)||this.boolVarMapByName.has(e)}getNextVarName(e){let t=this.varPrefixCounters.get(e)??0,n=`${e}_${t}`;for(;this.hasVarName(n);)t++,n=`${e}_${t}`;return this.varPrefixCounters.set(e,t+1),n}getNextBoolVarName(e){let t=this.boolVarPrefixCounters.get(e)??0,n=`${e}_${t}`;for(;this.hasVarName(n)||this.hasConstraintName(n);)t++,n=`${e}_${t}`;return this.boolVarPrefixCounters.set(e,t+1),n}hasConstraintName(e){return this.constrMapByName.has(e)||this.logicalConstrMapByName.has(e)}hasBoolVarName(e){return this.boolVarMapByName.has(e)}getNextConstrName(e=`c`){let t=this.constrPrefixCounters.get(e)??1,n=`${e}_${t}`;for(;this.hasConstraintName(n)||this.hasBoolVarName(n);)t++,n=`${e}_${t}`;return this.constrPrefixCounters.set(e,t+1),n}getNextLogicalConstrName(){let e=this.logicalConstrCounter+1,t=`lc_${e}`;for(;this.hasConstraintName(t)||this.hasBoolVarName(t);)e++,t=`lc_${e}`;return this.logicalConstrCounter=e,t}createBoolVar(e,t){let n=typeof e==`string`?e.trim():void 0,r=typeof t==`string`?t.trim():``,i=r.length>0?r:`p`,a=n&&n.length>0?n:this.getNextBoolVarName(i);if(this.hasVarName(a))throw Error(`Variable with name '${a}' already exists in model`);if(this.hasConstraintName(a))throw Error(`Boolean variable name '${a}' conflicts with an existing constraint in model`);let o=new g(a);return this.boolVars.push(o),this.boolVarMapByName.set(o.name,o),this.recordModelMutation(),o}addVar(e){let t=e||{},n=typeof t.name==`string`?t.name.trim():void 0,r=n&&n.length>0?n:void 0,i=typeof t.prefix==`string`?t.prefix.trim():``,a=i.length>0?i:`x`,o=this.varPrefixCounters.get(a),s=r??this.getNextVarName(a);try{if(this.hasVarName(s))throw Error(`Variable with name '${s}' already exists in model`);let e=new W({...t,name:s,prefix:a});return e.hasExplicitName=r!==void 0,ee(e),F(e,this),e.ownerModel=this,this.variables.push(e),this.varMapByName.set(e.name,e),this.recordModelMutation(),e}catch(e){throw r===void 0&&(o===void 0?this.varPrefixCounters.delete(a):this.varPrefixCounters.set(a,o)),e}}getVarByName(e){return this.varMapByName.get(e)}getBoolVarByName(e){return this.boolVarMapByName.get(e)}getConstraintByName(e){return this.constrMapByName.get(e)}getLogicalConstraintByName(e){return this.logicalConstrMapByName.get(e)}objective(e){return e?(this.applyObjective(e.expr,e.sense),this):this.objectiveExpr}applyObjective(e,t){if(e instanceof w||typeof e==`object`&&e&&`sense`in e&&`lhs`in e&&`rhs`in e||typeof e==`string`&&/(<=|>=|==|=<|=>|=)/.test(e))throw Error(typeof e==`string`?"Cannot use a comparison constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)?":"Cannot use a Constraint as an objective. Did you mean to use m.constraint(expr`... <= ...`)? For objectives, supply an unconstrained expression like expr`45 * ${x} + 80 * ${y}`.");let n=t===void 0?this.sense:f(t),r;if(typeof e==`string`)r=ce(e,e=>this.getVarByName(e));else if(typeof e==`number`)r=new O(new Map,e);else if(e instanceof D)r=e.clone();else if(e instanceof O)r=e.clone();else if(typeof e==`object`&&e&&`quadTerms`in e&&e.quadTerms instanceof Map&&`linearTerms`in e&&e.linearTerms instanceof Map&&typeof e.constant==`number`){let t=e;r=new D(t.linearTerms,t.quadTerms,t.constant)}else if(typeof e==`object`&&e&&`terms`in e&&e.terms instanceof Map&&typeof e.constant==`number`){let t=e;r=new O(t.terms,t.constant)}else if(e instanceof W||typeof e==`object`&&e&&`id`in e&&`name`in e&&`lb`in e&&`ub`in e)r=new O(new Map([[e,1]]),0);else throw Error(`Invalid objective expression: expected a finite number, Var, LinExpr, QuadExpr, or arithmetic expression string.`);te(r,this.name,e=>this.varMapByName.get(e.name)===e),this._sense=n,this._objectiveExpr=r,this.recordModelMutation()}constraint(e,t){if(Array.isArray(e))return this.runTransactionalBatch(()=>{for(let t of e)this.constraint(t);return this});if(e instanceof D||typeof e==`object`&&e&&`quadTerms`in e)throw Error(`Constraint must contain a comparison operator (<=, >=, ==): cannot add a quadratic expression as a constraint.`);if(e instanceof O||typeof e==`object`&&e&&`terms`in e)throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a linear expression without a comparison operator. Use expr`... <= ...` or .le(), .ge(), .eq().");return this.addConstraint(e,t),this}getValues(e){if(e==null)return null;if(e instanceof W||e instanceof g)return e.value;if(Array.isArray(e))return e.map(e=>this.getValues(e));if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=this.getValues(r);return t}return null}addConstraint(e,t){if(e instanceof D||typeof e==`object`&&e&&`quadTerms`in e)throw Error(`Constraint must contain a comparison operator (<=, >=, ==): cannot add a quadratic expression as a constraint.`);if(e instanceof O||typeof e==`object`&&e&&`terms`in e)throw Error("Constraint must contain a comparison operator (<=, >=, ==): cannot add a linear expression without a comparison operator. Use expr`... <= ...` or .le(), .ge(), .eq().");if(e instanceof h){let n=typeof t==`string`&&t.trim().length>0?t.trim():void 0;if(n!==void 0){if(this.hasConstraintName(n))throw Error(`Constraint with name '${n}' already exists in model`);if(this.hasBoolVarName(n))throw Error(`Constraint name '${n}' conflicts with an existing Boolean variable in model`)}let r=this.logicalConstrCounter,i=n??this.getNextLogicalConstrName();try{ne(e,i,this.name,e=>this.varMapByName.get(e.name)===e,e=>this.boolVarMapByName.get(e.name)===e,this)}catch(e){throw n===void 0&&(this.logicalConstrCounter=r),e}P(e,this,this.batchDepth>0?this.batchUndoActions:void 0);let a={name:i,expr:e};return this.logicalConstraints.push(a),this.logicalConstrMapByName.set(i,a),this.recordModelMutation(),e}let n=typeof e==`string`?K(e,e=>this.getVarByName(e),t):e;n.ownerModel&&n.ownerModel!==this&&(V(n,this.name,e=>this.varMapByName.get(e.name)===e,n.name),I(n,this));let r=typeof t==`string`&&t.trim().length>0?t.trim():n.hasExplicitName?n.name.trim():void 0;if(r!==void 0){if(this.hasConstraintName(r))throw Error(`Constraint with name '${r}' already exists in model`);if(this.hasBoolVarName(r))throw Error(`Constraint name '${r}' conflicts with an existing Boolean variable in model`)}let i=this.constrPrefixCounters.get(`c`),a=r??this.getNextConstrName(`c`),o;try{V(n,this.name,e=>this.varMapByName.get(e.name)===e,a),o=I(n,this)}catch(e){throw r===void 0&&(i===void 0?this.constrPrefixCounters.delete(`c`):this.constrPrefixCounters.set(`c`,i)),e}let s=n.name,c=n.hasExplicitName,l=n.ownerModel,u=o;return this.batchUndoActions.push(()=>{n.ownerModel=l,n._assignModelName(s,c),R(n,this,u)}),this.batchDepth===0&&(this.batchUndoActions=[]),n._assignModelName(a,!0),n.ownerModel=this,this.constraints.push(n),this.constrMapByName.set(n.name,n),this.recordModelMutation(),n}indicator(e,t,n={}){if(!(e instanceof W))throw Error(`Invalid binary variable passed to indicator(). Expected a binary Var instance.`);if(!(e.type===`Binary`||e.type===`Integer`&&e.lb===0&&e.ub===1))throw Error(`Invalid variable "${e.name}" passed to indicator(): variable has type "${e.type}" with bounds [${e.lb}, ${e.ub}]. Indicator activation variable must be a Binary variable (or Integer variable with bounds [0, 1]).`);if(t instanceof D)throw Error(`Quadratic expressions or constraints are not supported in indicator constraints (only linear constraints are allowed).`);if(!(`sense`in t)||!(`lhs`in t))throw Error(`Invalid constraint expression passed to indicator(). Expression must include a comparison operator (<=, >=, ==).`);let r=t,i=n.activeValue===void 0?1:n.activeValue;if(i!==0&&i!==1)throw Error(`Invalid activeValue: ${i}. Indicator activeValue must be 0 or 1.`);if(this.varMapByName.get(e.name)!==e)throw Error(`Variable "${e.name}" passed to indicator() does not belong to model "${this.name}". All variables must belong to the model by object identity.`);let a=typeof n.name==`string`&&n.name.trim().length>0?n.name.trim():void 0,o=this.constrPrefixCounters.get(`c`),{lhs:s,sense:c,rhs:l}=r,u,d,f;if(a!==void 0)u=a,d=c===`==`?`${u}_le`:u,f=c===`==`?`${u}_ge`:u;else if(r.hasExplicitName)u=`ind_${e.name}_${r.name.trim()}`,d=c===`==`?`${u}_le`:u,f=c===`==`?`${u}_ge`:u;else do{let t=this.getNextConstrName(`c`);u=`ind_${e.name}_${t}`,d=c===`==`?`${u}_le`:u,f=c===`==`?`${u}_ge`:u}while((c===`<=`||c===`==`)&&(this.hasConstraintName(d)||this.hasBoolVarName(d))||(c===`>=`||c===`==`)&&(this.hasConstraintName(f)||this.hasBoolVarName(f)));let p=[];try{if((c===`<=`||c===`==`)&&(this.hasConstraintName(d)||this.hasBoolVarName(d)))throw Error(this.hasBoolVarName(d)?`Constraint name '${d}' conflicts with an existing Boolean variable in model`:`Constraint with name '${d}' already exists in model`);if((c===`>=`||c===`==`)&&(this.hasConstraintName(f)||this.hasBoolVarName(f)))throw Error(this.hasBoolVarName(f)?`Constraint name '${f}' conflicts with an existing Boolean variable in model`:`Constraint with name '${f}' already exists in model`);n.M!==void 0&&et(n.M,u);let t=e=>this.varMapByName.get(e.name)===e;for(let[e]of s.terms)if(!t(e))throw Error(`Variable "${e.name}" in constraint "${u}" does not belong to model "${this.name}". All variables must belong to the model by object identity.`);if(c===`<=`||c===`==`){let t=it(e,s,`<=`,l,i,n.M===void 0?nt(s,l,d):n.M,d);p.push([new w(t.lhs,`<=`,t.rhs,d),d])}if(c===`>=`||c===`==`){let t=it(e,s,`>=`,l,i,n.M===void 0?rt(s,l,f):n.M,f);p.push([new w(t.lhs,`>=`,t.rhs,f),f])}for(let[e,n]of p)V(e,this.name,t,n)}catch(e){throw o===void 0?this.constrPrefixCounters.delete(`c`):this.constrPrefixCounters.set(`c`,o),e}return this.runTransactionalBatch(()=>p.map(([e,t])=>this.addConstraint(e,t)))}toLpString(){this.validateIntegrity();let{lpString:e}=ge({name:this.name,sense:this.sense,objective:this.objectiveExpr,constraints:this.constraints,variables:this.variables});return e}validateIntegrity(){re(this)}ensureExecutionValid(e,t,n){if(this.modelRevision!==e)throw this.activeOperationId===t&&this.clearSolutionFields(),Error(`Model "${this.name}" was modified while ${n}() was in progress; stale solver result was discarded.`);if(this.activeOperationId!==t)throw Error(`Stale ${n}() result discarded because a newer solve or check operation was started on model "${this.name}".`)}wrapSolveOptions(e,t,n){let r=e.onProgress;return r?{...e,onProgress:e=>{this.activeOperationId===n&&this.modelRevision===t&&r(e)}}:e}hasPrimalFromResult(e){if(typeof e.hasPrimalSolution==`boolean`)return e.hasPrimalSolution;let t=e.status,n=e.terminationStatus??t,r=e.values||{},i=e.boolValues||{};return t!==`Infeasible`&&t!==`Unsat`&&t!==`Unbounded`&&t!==`Error`&&t!==`NotSolved`&&n!==`Infeasible`&&n!==`Unsat`&&n!==`Unbounded`&&n!==`InfeasibleOrUnbounded`&&n!==`Error`&&n!==`NotSolved`&&(t===`Optimal`||t===`Feasible`||t===`Sat`||n===`Optimal`||n===`Feasible`||n===`Sat`||typeof e.objectiveValue==`number`&&Number.isFinite(e.objectiveValue)||Object.values(r).some(e=>typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`)||Object.values(i).some(e=>typeof e==`boolean`))}resolveSolverAndOptions(e,t){if(e&&typeof e==`object`&&`solve`in e&&typeof e.solve==`function`){let{solver:n,...r}=t||{};return{activeSolver:e,activeOptions:r}}if(typeof e==`function`){let{solver:n,...r}=t||{};return{activeSolver:new e(r),activeOptions:r}}if(typeof e==`string`){let{solver:n,...r}=t||{};return{activeSolver:xe(e,r),activeOptions:r}}let{solver:n,...r}=e||{};return n?{activeSolver:xe(n,r),activeOptions:r}:{activeSolver:this.solver||xe(),activeOptions:r}}async solve(e,t){let n=++this.activeOperationId,r=this.modelRevision;this.clearSolutionFields(),this.validateIntegrity();let{activeSolver:i,activeOptions:a}=this.resolveSolverAndOptions(e,t);if(this._objectiveExpr instanceof D&&this._objectiveExpr.quadTerms.size>0&&i.capabilities?.supportsQP===!1)throw Error(`Solver "${i.name}" does not support quadratic objectives (QP). Please use a QP-capable solver such as HiGHS or Clarabel.`);if(this.logicalConstraints.length>0&&i.capabilities?.supportsSMT!==!0)throw Error(`Solver "${i.name}" does not support SMT / logical constraints (or, implies, not, xor). Please use an SMT-capable solver such as Z3.`);if(this.variables.some(e=>e.initialValue!==void 0)&&i.capabilities?.supportsWarmStart!==!0)throw Error(`Solver "${i.name}" does not support primal initial values (initialValue). Please use a solver with warm-start support such as HiGHS.`);let o={name:this.name,sense:this.sense,objective:this._objectiveExpr,constraints:this.constraints,variables:this.variables,logicalConstraints:this.logicalConstraints,boolVars:this.boolVars},s=this.wrapSolveOptions(a,r,n),c;try{c=await i.solve(o,s)}catch(e){throw this.activeOperationId===n&&this.clearSolutionFields(),e}this.ensureExecutionValid(r,n,`solve`),this.runTime=c.runTime??0,this.status=c.status,this.terminationStatus=c.terminationStatus??c.status;let l=this.hasPrimalFromResult(c);this.hasPrimalSolution=l,this.objectiveValue=l&&typeof c.objectiveValue==`number`&&Number.isFinite(c.objectiveValue)?c.objectiveValue:null,this.objectiveBound=typeof c.objectiveBound==`number`&&Number.isFinite(c.objectiveBound)?c.objectiveBound:void 0;let u=typeof c.relGap==`number`&&Number.isFinite(c.relGap)?c.relGap:typeof c.mipGap==`number`&&Number.isFinite(c.mipGap)?c.mipGap:void 0;this.relGap=u,this.mipGap=u,this.absGap=typeof c.absGap==`number`&&Number.isFinite(c.absGap)?c.absGap:this.objectiveValue!==null&&this.objectiveBound!==void 0?Math.abs(this.objectiveValue-this.objectiveBound):void 0;let d=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})},f={},p={},m={},h={};if(this.values.clear(),l&&c.values){for(let[e,t]of Object.entries(c.values))if(typeof t==`number`&&Number.isFinite(t)){let n=this.getVarByName(e),r=this.getBoolVarByName(e);n&&(n.value=t,d(f,n.name,t),this.values.set(n.name,t)),r&&(r.value=!!t,this.values.set(r.name,t)),!n&&!r&&this.values.set(e,t)}else if(typeof t==`boolean`){let n=t,r=this.getBoolVarByName(e);r?(r.value=n,d(f,r.name,+!!n),this.values.set(r.name,n)):this.values.set(e,n)}}if(l&&c.boolValues)for(let[e,t]of Object.entries(c.boolValues)){if(typeof t!=`boolean`)continue;let n=this.getBoolVarByName(e);n?(n.value=t,this.values.has(n.name)||this.values.set(n.name,t)):this.values.has(e)||this.values.set(e,t)}if(l&&c.reducedCosts)for(let[e,t]of Object.entries(c.reducedCosts)){if(typeof t!=`number`||!Number.isFinite(t))continue;let n=this.getVarByName(e);n&&(n.reducedCost=t,d(m,n.name,t))}if(c.duals)for(let[e,t]of Object.entries(c.duals)){if(typeof t!=`number`||!Number.isFinite(t))continue;let n=this.getConstraintByName(e);n&&(n.dual=t,d(p,n.name,t))}if(c.slacks)for(let[e,t]of Object.entries(c.slacks)){if(typeof t!=`number`||!Number.isFinite(t))continue;let n=this.getConstraintByName(e);n&&(n.slack=t,d(h,n.name,t))}return this.solution={status:this.status,terminationStatus:this.terminationStatus,hasPrimalSolution:this.hasPrimalSolution,objectiveValue:this.objectiveValue,...this.objectiveBound===void 0?{}:{objectiveBound:this.objectiveBound},...this.relGap===void 0?{}:{relGap:this.relGap,mipGap:this.mipGap},...this.absGap===void 0?{}:{absGap:this.absGap},values:f,duals:p,reducedCosts:m,slacks:h,runTime:this.runTime,raw:c.raw},this.hasSolutionState=!0,this.status}async check(e,t){let n=++this.activeOperationId,r=this.modelRevision;this.clearSolutionFields(),this.validateIntegrity();let{activeSolver:i,activeOptions:a}=this.resolveSolverAndOptions(e,t);if(this.logicalConstraints.length>0&&i.capabilities?.supportsSMT!==!0)throw Error(`Solver "${i.name}" does not support SMT / logical constraints (or, implies, not, xor). Please use an SMT-capable solver such as Z3.`);if(this.variables.some(e=>e.initialValue!==void 0)&&i.capabilities?.supportsWarmStart!==!0)throw Error(`Solver "${i.name}" does not support primal initial values (initialValue). Please use a solver with warm-start support such as HiGHS.`);let o=this.wrapSolveOptions(a,r,n),s=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})},c={name:this.name,variables:this.variables,boolVars:this.boolVars,constraints:this.constraints,logicalConstraints:this.logicalConstraints};if(typeof i.check==`function`){let e;try{e=await i.check(c,o)}catch(e){throw this.activeOperationId===n&&this.clearSolutionFields(),e}this.ensureExecutionValid(r,n,`check`),this.status=e.status,this.terminationStatus=a.signal?.aborted?`Interrupted`:e.status,this.hasPrimalSolution=e.status===`Sat`,this.runTime=e.runTime??0,this.unsatCore=e.unsatCore===void 0?void 0:Object.freeze([...e.unsatCore]);let t={};if(e.values&&e.status===`Sat`){for(let[n,r]of Object.entries(e.values))if(typeof r==`number`){if(!Number.isFinite(r))continue;let e=this.getVarByName(n),i=this.getBoolVarByName(n);e&&(e.value=r,this.values.set(e.name,r),s(t,e.name,r)),i&&(i.value=!!r,this.values.set(i.name,i.value),s(t,i.name,i.value)),!e&&!i&&(this.values.set(n,r),s(t,n,r))}else if(typeof r==`boolean`){let e=this.getBoolVarByName(n);e?(e.value=r,this.values.set(e.name,r),s(t,e.name,r)):(this.values.set(n,r),s(t,n,r))}}return this.hasSolutionState=!0,{status:e.status,values:t,unsatCore:this.unsatCore,conflicts:this.unsatCore,runTime:this.runTime}}let l={name:this.name,sense:`Minimize`,objective:new O,constraints:this.constraints,variables:this.variables,logicalConstraints:this.logicalConstraints,boolVars:this.boolVars},u;try{u=await i.solve(l,o)}catch(e){throw this.activeOperationId===n&&this.clearSolutionFields(),e}this.ensureExecutionValid(r,n,`check`),this.runTime=u.runTime??0;let d=u.status,f=u.terminationStatus??d,p=this.hasPrimalFromResult(u)||d===`Optimal`||d===`Feasible`,m=p?`Sat`:d===`Infeasible`?`Unsat`:`Unknown`;this.status=m,this.terminationStatus=a.signal?.aborted||f===`Interrupted`?`Interrupted`:f===`Optimal`||f===`Feasible`||f===`Infeasible`?m:f,this.hasPrimalSolution=p,this.objectiveValue=null,this.objectiveBound=void 0,this.relGap=void 0,this.mipGap=void 0,this.absGap=void 0,this.solution=null,this.values.clear();let h={};if(p&&u.values){for(let[e,t]of Object.entries(u.values))if(typeof t==`number`&&Number.isFinite(t)){let n=this.getVarByName(e),r=this.getBoolVarByName(e);n&&(n.value=t,this.values.set(n.name,t),s(h,n.name,t)),r&&(r.value=!!t,this.values.set(r.name,r.value),s(h,r.name,r.value)),!n&&!r&&(this.values.set(e,t),s(h,e,t))}else if(typeof t==`boolean`){let n=t,r=this.getBoolVarByName(e);r?(r.value=n,this.values.set(r.name,n),s(h,r.name,n)):(this.values.set(e,n),s(h,e,n))}}if(p&&u.boolValues)for(let[e,t]of Object.entries(u.boolValues)){if(typeof t!=`boolean`)continue;let n=this.getBoolVarByName(e);n?(n.value=t,this.values.set(n.name,t),s(h,n.name,t)):(this.values.set(e,t),s(h,e,t))}if(u.slacks)for(let[e,t]of Object.entries(u.slacks)){if(typeof t!=`number`||!Number.isFinite(t))continue;let n=this.getConstraintByName(e);n&&(n.slack=t)}return this.hasSolutionState=!0,{status:m,values:h,runTime:this.runTime}}validateSolution(e={}){return $e(this,e)}};function lt(e,t){let n=e;if(n instanceof w||typeof n==`object`&&n&&`sense`in n&&`lhs`in n&&`rhs`in n)throw Error(`Cannot use a Constraint as an objective in ${t}(). Use model.constraint(expr\`... <= ...\`) for constraints, or supply an unconstrained arithmetic expression to ${t}().`);if(typeof n==`string`&&/(<=|>=|==|=<|=>|=)/.test(n))throw Error(`Cannot use a comparison constraint as an objective in ${t}(). Use model.constraint(expr\`... <= ...\`) for constraints, or supply an unconstrained arithmetic expression to ${t}().`);if(typeof n==`number`){if(!Number.isFinite(n))throw Error(`Invalid non-finite objective constant "${n}" passed to ${t}().`);return n}if(typeof n==`string`||n instanceof O||n instanceof D||n instanceof W||typeof n==`object`&&n&&(`terms`in n&&n.terms instanceof Map&&typeof n.constant==`number`||`quadTerms`in n&&n.quadTerms instanceof Map&&`linearTerms`in n&&n.linearTerms instanceof Map&&typeof n.constant==`number`||`id`in n&&`name`in n&&`lb`in n&&`ub`in n))return n;throw Error(`Invalid expression passed to ${t}(): expected a finite number, Var, LinExpr, QuadExpr, or arithmetic expression string.`)}function ut(e){return{expr:lt(e,`maximize`),sense:`Maximize`}}function dt(e){return{expr:lt(e,`minimize`),sense:`Minimize`}}return e.BoolExpr=h,e.BoolOp=_,e.BoolVar=g,e.Constraint=w,e.HiGHS=Je,e.HighsSolver=qe,e.LinExpr=O,e.MockSolver=Xe,e.Model=ct,e.QuadExpr=D,e.Var=W,e.and=v,e.buildIndicatorLinearization=it,e.buildLpSymbolMaps=he,e.deriveBigMForGe=rt,e.deriveBigMForLe=nt,e.dot=A,e.expr=fe,e.generateLpString=ge,e.getHighs=Ie,e.getHighsWasmUrl=Fe,e.getSolver=xe,e.implies=x,e.isLpExportResult=pe,e.listAvailableSolvers=Se,e.maximize=ut,e.minimize=dt,e.normalizeSense=f,e.not=b,e.or=y,e.parseConstraint=K,e.parseExpr=ce,e.registerSolver=Y,e.sanitizeIdentifier=me,e.setDefaultSolver=be,e.setHighsWasmUrl=Pe,e.solveLpWithHighs=Le,e.sum=k,e.validateModelIntegrity=re,e.validateModelSolution=$e,e.validateUserBigM=et,e.xor=S,e})({});
|