/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/glpk-ts@0.0.11/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("glpk-wasm")):"function"==typeof define&&define.amd?define(["exports","glpk-wasm"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).GLPK={},t.glpkWasm)}(this,(function(t,e){"use strict";function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=r(e);function s(t,e,r,i){return new(r||(r=Promise))((function(s,n){function o(t){try{l(i.next(t))}catch(t){n(t)}}function a(t){try{l(i.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}l((i=i.apply(t,e||[])).next())}))}let n,o;var a;function l(t,e){return void 0===t?void 0===e?a.BoundType.FREE:a.BoundType.UB:void 0===e?a.BoundType.LB:t===e?a.BoundType.FIXED:a.BoundType.BOUNDED}function u(t){const e=t.model.numConstrs,r=t.model.numVars,i=o._malloc(12*(r+1));let s=new Float64Array(o.HEAPU8.buffer,i,r+1),n=new Int32Array(o.HEAPU8.buffer,i+8*(r+1),r+1);o._glp_eval_tab_row(t.model.ptr,t instanceof g?e+t.id:t.id,i+8*(r+1),i);const a=Array.from(n.slice(1).filter((t=>t>0)),((r,i)=>[r<=e?t.model.constrs[r-1]:t.model.vars[r-1-e],s[i+1]]));return o._free(i),a}function _(t){const e=t.model.numConstrs,r=o._malloc(12*(e+1));let i=new Float64Array(o.HEAPU8.buffer,r,e+1),s=new Int32Array(o.HEAPU8.buffer,r+8*(e+1),e+1);o._glp_eval_tab_col(t.model.ptr,t instanceof g?e+t.id:t.id,r+8*(e+1),r);const n=Array.from(s.slice(1).filter((t=>t>0)),((r,s)=>[r<=e?t.model.constrs[r-1]:t.model.vars[r-1-e],i[s+1]]));return o._free(r),n}"function"==typeof SuppressedError&&SuppressedError,function(t){var e,r,i,s,n,o,a,l,u,_,c,d,p,h,g,f,m,b,E,v,w,I;(e=t.ObjectiveDirection||(t.ObjectiveDirection={}))[e.MIN=1]="MIN",e[e.MAX=2]="MAX",(r=t.BoundType||(t.BoundType={}))[r.FREE=1]="FREE",r[r.LB=2]="LB",r[r.UB=3]="UB",r[r.BOUNDED=4]="BOUNDED",r[r.FIXED=5]="FIXED",(i=t.VariableStatus||(t.VariableStatus={}))[i.BASIC=1]="BASIC",i[i.LB=2]="LB",i[i.UB=3]="UB",i[i.FREE=4]="FREE",i[i.FIXED=5]="FIXED",(s=t.VariableType||(t.VariableType={}))[s.CONTINUOUS=1]="CONTINUOUS",s[s.INTEGER=2]="INTEGER",s[s.BINARY=3]="BINARY",(n=t.Scaling||(t.Scaling={}))[n.GEOMETRIC_MEAN=1]="GEOMETRIC_MEAN",n[n.EQUILIBRATION=16]="EQUILIBRATION",n[n.POWER_TWO=32]="POWER_TWO",n[n.SKIP=64]="SKIP",n[n.AUTO=128]="AUTO",(o=t.SolutionIndicator||(t.SolutionIndicator={}))[o.BASIC=1]="BASIC",o[o.INTERIOR_POINT=2]="INTERIOR_POINT",o[o.MIXED_INTEGER=3]="MIXED_INTEGER",(a=t.Status||(t.Status={}))[a.UNDEFINED=1]="UNDEFINED",a[a.FEASIBLE=2]="FEASIBLE",a[a.INFEASIBLE=3]="INFEASIBLE",a[a.NO_FEASIBLE=4]="NO_FEASIBLE",a[a.OPTIMAL=5]="OPTIMAL",a[a.UNBOUNDED=6]="UNBOUNDED",(l=t.MessageLevel||(t.MessageLevel={}))[l.OFF=0]="OFF",l[l.ERR=1]="ERR",l[l.ON=2]="ON",l[l.ALL=3]="ALL",l[l.DBG=4]="DBG",(u=t.Method||(t.Method={}))[u.PRIMAL=1]="PRIMAL",u[u.DUALP=2]="DUALP",u[u.DUAL=3]="DUAL",(_=t.Pricing||(t.Pricing={}))[_.STD=17]="STD",_[_.PSE=34]="PSE",(c=t.RatioTest||(t.RatioTest={}))[c.STD=17]="STD",c[c.HAR=34]="HAR",c[c.FLIP=51]="FLIP",(d=t.OrderingAlgorithm||(t.OrderingAlgorithm={}))[d.NONE=0]="NONE",d[d.QMD=1]="QMD",d[d.AMD=2]="AMD",d[d.SYMAMD=3]="SYMAMD",(p=t.ReturnCode||(t.ReturnCode={}))[p.OK=0]="OK",p[p.EBADB=1]="EBADB",p[p.ESING=2]="ESING",p[p.ECOND=3]="ECOND",p[p.EBOUND=4]="EBOUND",p[p.EFAIL=5]="EFAIL",p[p.EOBJLL=6]="EOBJLL",p[p.EOBJUL=7]="EOBJUL",p[p.EITLIM=8]="EITLIM",p[p.ETMLIM=9]="ETMLIM",p[p.ENOPFS=10]="ENOPFS",p[p.ENODFS=11]="ENODFS",p[p.EROOT=12]="EROOT",p[p.ESTOP=13]="ESTOP",p[p.EMIPGAP=14]="EMIPGAP",p[p.ENOFEAS=15]="ENOFEAS",p[p.ENOCVG=16]="ENOCVG",p[p.EINSTAB=17]="EINSTAB",p[p.EDATA=18]="EDATA",p[p.ERANGE=19]="ERANGE",(h=t.BranchingTechnique||(t.BranchingTechnique={}))[h.FFV=1]="FFV",h[h.LFV=2]="LFV",h[h.MFV=3]="MFV",h[h.DTH=4]="DTH",h[h.PCH=5]="PCH",(g=t.BacktrackingTechnique||(t.BacktrackingTechnique={}))[g.DFS=1]="DFS",g[g.BFS=2]="BFS",g[g.BLB=3]="BLB",g[g.BPH=4]="BPH",(f=t.PreprocessingTechnique||(t.PreprocessingTechnique={}))[f.NONE=0]="NONE",f[f.ROOT=1]="ROOT",f[f.ALL=2]="ALL",(m=t.ConditionIndicator||(t.ConditionIndicator={}))[m.PE=1]="PE",m[m.PB=2]="PB",m[m.DE=3]="DE",m[m.DB=4]="DB",m[m.CS=5]="CS",(b=t.ReasonCode||(t.ReasonCode={}))[b.ROWGEN=1]="ROWGEN",b[b.BINGO=2]="BINGO",b[b.HEUR=3]="HEUR",b[b.CUTGEN=4]="CUTGEN",b[b.BRANCH=5]="BRANCH",b[b.SELECT=6]="SELECT",b[b.PREPRO=7]="PREPRO",(E=t.BranchSelection||(t.BranchSelection={}))[E.NO_BRNCH=0]="NO_BRNCH",E[E.DN_BRNCH=1]="DN_BRNCH",E[E.UP_BRNCH=2]="UP_BRNCH",(v=t.RowOrigin||(t.RowOrigin={}))[v.REG=0]="REG",v[v.LAZY=1]="LAZY",v[v.CUT=2]="CUT",(w=t.RowClass||(t.RowClass={}))[w.GMI=1]="GMI",w[w.MIR=2]="MIR",w[w.COV=3]="COV",w[w.CLQ=4]="CLQ",(I=t.MPSFormat||(t.MPSFormat={}))[I.DECK=1]="DECK",I[I.FILE=2]="FILE"}(a||(a={}));const c=new Map([[void 0,a.VariableType.CONTINUOUS],["c",a.VariableType.CONTINUOUS],["cont",a.VariableType.CONTINUOUS],["continuous",a.VariableType.CONTINUOUS],["i",a.VariableType.INTEGER],["int",a.VariableType.INTEGER],["integer",a.VariableType.INTEGER],["b",a.VariableType.BINARY],["bin",a.VariableType.BINARY],["binary",a.VariableType.BINARY]]),d=new Map(Array.from(c.entries(),(([t,e])=>[e,t])));const p=new Map([["basic",a.VariableStatus.BASIC],["lower-bound",a.VariableStatus.LB],["upper-bound",a.VariableStatus.UB],["free",a.VariableStatus.FREE],["fixed",a.VariableStatus.FIXED]]),h=new Map(Array.from(p.entries(),(([t,e])=>[e,t])));class g{get ptr(){return this.model.ptr}constructor(t,e,r){if(this._lb=0,this._ub=0,this.model=t,this._idx=e,void 0===r)return;const{obj:i,lb:s,ub:n,type:o,name:a}=r;void 0!==i&&(this.obj=i),this.setBounds(s,n),void 0!==o&&(this.type=o),void 0!==a&&(this.name=a)}get id(){return this._idx}setBounds(t,e){if(t===this._lb&&e===this._ub)return;this._lb=t,this._ub=e;const r=l(t,e);o._glp_set_col_bnds(this.ptr,this._idx,r,t||0,e||0)}set bounds([t,e]){this.setBounds(t,e)}set name(t){const e=o.lengthBytesUTF8(t)+1,r=o._malloc(e);o.stringToUTF8(t,r,e),o._glp_set_col_name(this.ptr,this._idx,r),o._free(r)}get name(){const t=o._glp_get_col_name(this.ptr,this._idx);return o.UTF8ToString(t)}set lb(t){this.setBounds(t,this.ub)}set ub(t){this.setBounds(this.lb,t)}get lb(){return this._lb}get ub(){return this._ub}get obj(){return o._glp_get_obj_coef(this.ptr,this._idx)}set obj(t){if("number"!=typeof t)throw new Error("obj should be a number");o._glp_set_obj_coef(this.ptr,this._idx,t)}set type(t){o._glp_set_col_kind(this.ptr,this._idx,function(t){const e=c.get(t);if(void 0===e)throw new Error(`unknown variable type '${t}'`);return e}(t))}get type(){return d.get(o._glp_get_col_kind(this.ptr,this._idx))}get value(){return o._glp_get_col_prim(this.ptr,this._idx)}get dual(){return o._glp_get_col_dual(this.ptr,this._idx)}get valueInt(){return o._glp_ipt_col_prim(this.ptr,this._idx)}get dualInt(){return o._glp_ipt_col_dual(this.ptr,this._idx)}get valueMIP(){return o._glp_mip_col_val(this.ptr,this._idx)}get status(){return h.get(o._glp_get_col_stat(this.ptr,this._idx))}get row(){return u(this)}get column(){return _(this)}}class f{get ptr(){return this.model.ptr}constructor(t,e,r){if(this._needsUpdate=!1,this.model=t,this._idx=e,this._coeffs=new Map,!r)return;const{lb:i,ub:s,coeffs:n,name:o}=r;this.setBounds(i,s),void 0!==n&&this.addCollection(n),void 0!==o&&(this.name=o)}get id(){return this._idx}set name(t){const e=o.lengthBytesUTF8(t)+1,r=o._malloc(e);o.stringToUTF8(t,r,e),o._glp_set_row_name(this.ptr,this._idx,r),o._free(r)}get name(){const t=o._glp_get_row_name(this.ptr,this._idx);return o.UTF8ToString(t)}setBounds(t,e){if(t===this._lb&&e===this._ub)return;const r=l(t,e);this._lb=t,this._ub=e,o._glp_set_row_bnds(this.ptr,this._idx,r,t||0,e||0)}set bounds([t,e]){this.setBounds(t,e)}set lb(t){this.setBounds(t,this._ub)}set ub(t){this.setBounds(this.lb,t)}get lb(){return this._lb}get ub(){return this._ub}add(t,e){if(void 0===e)return this.addCollection(t);if(!(t instanceof g))throw new Error("variable should have type Variable");if(!e)return this;const r=(this._coeffs.get(t.id)||0)+e;return r?this._coeffs.set(t.id,r):this._coeffs.delete(t.id),this._needsUpdate=!0,this}addCollection(t){const e=t instanceof Array?t:t instanceof Map?t.entries():void 0;if(void 0===e)throw new Error("coeffs should have type Array or Map");for(const[t,r]of e){if(!(t instanceof g))throw new Error("variable should have type Variable");if(!r)continue;const e=(this._coeffs.get(t.id)||0)+r;e?this._coeffs.set(t.id,e):this._coeffs.delete(t.id),this._needsUpdate=!0}return this}update(){if(!this._needsUpdate)return this;const t=this._coeffs.size+1,e=o._malloc(4*t),r=o._malloc(8*t);let i=new Int32Array(o.HEAPU8.buffer,e,t),s=new Float64Array(o.HEAPU8.buffer,r,t);i[0]=0,s[0]=0;let n=0;for(const[t,e]of this._coeffs.entries())n++,i[n]=t,s[n]=e;return o._glp_set_mat_row(this.ptr,this._idx,t-1,e,r),o._free(e),o._free(r),this._needsUpdate=!1,this}get value(){return o._glp_get_row_prim(this.ptr,this._idx)}get dual(){return o._glp_get_row_dual(this.ptr,this._idx)}get valueInt(){return o._glp_ipt_row_prim(this.ptr,this._idx)}get dualInt(){return o._glp_ipt_row_dual(this.ptr,this._idx)}get valueMIP(){return o._glp_mip_row_val(this.ptr,this._idx)}get status(){return h.get(o._glp_get_row_stat(this.ptr,this._idx))}get row(){return u(this)}get column(){return _(this)}}const m=new Map([["optimal",a.Status.OPTIMAL],["feasible",a.Status.FEASIBLE],["infeasible",a.Status.INFEASIBLE],["no_feasible",a.Status.NO_FEASIBLE],["unbounded",a.Status.UNBOUNDED],["undefined",a.Status.UNDEFINED]]),b=new Map(Array.from(m.entries(),(([t,e])=>[e,t])));function E(t){return b.get(t)}function v(t){const e={all:a.MessageLevel.ALL,on:a.MessageLevel.ON,off:a.MessageLevel.OFF,debug:a.MessageLevel.DBG,error:a.MessageLevel.ERR}[t];if(void 0===e)throw new Error(`unknown message level '${t}'`);return e}t.Interior=void 0,(t.Interior||(t.Interior={})).solve=function(t,e){const r=o._malloc(392);o._glp_init_iptcp(r),void 0!==e.msgLevel&&o.setValue(r,v(e.msgLevel),"i32"),void 0!==e.ordering&&o.setValue(r+4,function(t){const e={none:a.OrderingAlgorithm.NONE,qmd:a.OrderingAlgorithm.QMD,amd:a.OrderingAlgorithm.AMD,symamd:a.OrderingAlgorithm.SYMAMD}[t];if(void 0===e)throw new Error(`unknown ordering '${t}'`);return e}(e.ordering),"i32");const i=o._glp_interior(t.ptr,r);switch(o._free(r),i){case a.ReturnCode.OK:return"ok";case a.ReturnCode.EFAIL:return"no_data";case a.ReturnCode.ENOCVG:return"no_convergence";case a.ReturnCode.EITLIM:return"iteration_limit";case a.ReturnCode.EINSTAB:return"instability";default:throw new Error(`unknown return code from interior: ${i}`)}},t.Simplex=void 0,function(t){function e(t){switch(t){case a.ReturnCode.OK:return"ok";case a.ReturnCode.EBADB:return"basis_invalid";case a.ReturnCode.ESING:return"basis_singular";case a.ReturnCode.ECOND:return"basis_ill_conditioned";case a.ReturnCode.EBOUND:return"bounds_incorrect";case a.ReturnCode.EFAIL:return"failure";case a.ReturnCode.EOBJLL:return"objective_lower";case a.ReturnCode.EOBJUL:return"objective_upper";case a.ReturnCode.EITLIM:return"iteration_limit";case a.ReturnCode.ETMLIM:return"time_limit";case a.ReturnCode.ENOPFS:return"no_primal_feasible";case a.ReturnCode.ENODFS:return"no_dual_feasible";default:throw new Error(`unknown return code from simplex: ${t}`)}}function r(t){const e=o._malloc(352);return o._glp_init_smcp(e),void 0!==t.msgLevel&&o.setValue(e,v(t.msgLevel),"i32"),void 0!==t.method&&o.setValue(e+4,function(t){const e={primal:a.Method.PRIMAL,dual:a.Method.DUAL,dual_primal:a.Method.DUALP}[t];if(void 0===e)throw new Error(`unknown method '${t}'`);return e}(t.method),"i32"),void 0!==t.pricing&&o.setValue(e+8,function(t){const e={std:a.Pricing.STD,pse:a.Pricing.PSE}[t];if(void 0===e)throw new Error(`unknown pricing '${t}'`);return e}(t.pricing),"i32"),void 0!==t.ratioTest&&o.setValue(e+12,function(t){const e={std:a.RatioTest.STD,harris:a.RatioTest.HAR,flipflop:a.RatioTest.FLIP}[t];if(void 0===e)throw new Error(`unknown ratioTest '${t}'`);return e}(t.ratioTest),"i32"),void 0!==t.tolPrimal&&o.setValue(e+16,t.tolPrimal,"double"),void 0!==t.tolDual&&o.setValue(e+24,t.tolDual,"double"),void 0!==t.tolPivot&&o.setValue(e+32,t.tolPivot,"double"),void 0!==t.objLower&&o.setValue(e+40,t.objLower,"double"),void 0!==t.objUpper&&o.setValue(e+48,t.objUpper,"double"),void 0!==t.limitIter&&o.setValue(e+56,t.limitIter,"i32"),void 0!==t.limitTime&&o.setValue(e+60,t.limitTime,"i32"),void 0!==t.logFreq&&o.setValue(e+64,t.logFreq,"i32"),void 0!==t.logDelay&&o.setValue(e+68,t.logDelay,"i32"),void 0!==t.presolve&&o.setValue(e+72,t.presolve?1:0,"i32"),e}t.solve=function(t,i){const s=r(i),n=o._glp_simplex(t.ptr,s);return o._free(s),e(n)},t.solveExact=function(t,i){const s=r(i),n=o._glp_exact(t.ptr,s);return o._free(s),e(n)}}(t.Simplex||(t.Simplex={}));const w={row:a.ReasonCode.ROWGEN,improved:a.ReasonCode.BINGO,heuristic:a.ReasonCode.HEUR,cut:a.ReasonCode.CUTGEN,branch:a.ReasonCode.BRANCH,select:a.ReasonCode.SELECT,preprocessing:a.ReasonCode.PREPRO},I=new Map(Object.entries(w).map((([t,e])=>[e,t]))),B={regular:a.RowOrigin.REG,lazy:a.RowOrigin.LAZY,cut:a.RowOrigin.CUT},T=new Map(Object.entries(B).map((([t,e])=>[e,t]))),O={gomory:a.RowClass.GMI,mir:a.RowClass.MIR,cover:a.RowClass.COV,clique:a.RowClass.CLQ},N=new Map(Object.entries(O).map((([t,e])=>[e,t]))),R={down:a.BranchSelection.DN_BRNCH,up:a.BranchSelection.UP_BRNCH,general:a.BranchSelection.NO_BRNCH};class P{constructor(t,e){this.tree=t,this.idx=e}select(){o._glp_ios_select_node(this.tree.ptr,this.idx)}get next(){const t=o._glp_ios_next_node(this.tree.ptr,this.idx);if(0!==t)return new P(this.tree,t)}get previous(){const t=o._glp_ios_prev_node(this.tree.ptr,this.idx);if(0!==t)return new P(this.tree,t)}get parent(){const t=o._glp_ios_up_node(this.tree.ptr,this.idx);if(0!==t)return new P(this.tree,t)}get level(){return o._glp_ios_node_level(this.tree.ptr,this.idx)}get bound(){return o._glp_ios_node_bound(this.tree.ptr,this.idx)}}class C{constructor(t){this.ptr=t}static _alloc(){void 0===C._data&&(C._data=o._malloc(72))}get reason(){const t=o._glp_ios_reason(this.ptr),e=I.get(t);if(void 0===e)throw new Error(`unknown reason code '${t}'`);return e}get model(){const t=o._glp_ios_get_prob(this.ptr);return A.fromPointer(t)}rowAttribute(t){return C._alloc(),o._glp_ios_row_attr(this.ptr,t,C._data),{level:o.getValue(C._data+0,"i32"),origin:T.get(o.getValue(C._data+4,"i32")),cls:N.get(o.getValue(C._data+8,"i32"))}}get gap(){return o._glp_ios_mip_gap(this.ptr)}setHeuristicSolution(t){const e=t.length,r=o._malloc(8*e),i=new Float64Array(o.HEAPU8.buffer,r,e);if(t instanceof Float64Array)t.set(i);else for(let[e,r]of t.entries())i[e]=r;o._glp_ios_heur_sol(this.ptr,r),o._free(r)}canBranch(t){return o._glp_ios_can_branch(this.ptr,t)}branchUpon(t,e){const r=R[e];if(void 0===r)throw new Error(`unknown branch selection '${e}'`);o._glp_ios_branch_upon(this.ptr,t,r)}terminate(){o._glp_ios_terminate(this.ptr)}get size(){C._alloc();const t=C._data;return o._glp_ios_tree_size(this.ptr,t,t+4,t+8),{active:o.getValue(t,"i32"),current:o.getValue(t+4,"i32"),total:o.getValue(t+8,"i32")}}get currentNode(){const t=o._glp_ios_curr_node(this.ptr);if(0!==t)return new P(this,t)}get bestNode(){const t=o._glp_ios_best_node(this.ptr);if(0!==t)return new P(this,t)}get firstNode(){const t=o._glp_ios_next_node(this.ptr,0);if(0!==t)return new P(this,t)}get lastNode(){const t=o._glp_ios_prev_node(this.ptr,0);if(0!==t)return new P(this,t)}get cutPoolSize(){return o._glp_ios_pool_size(this.ptr)}clearCutPool(){o._glp_ios_clear_pool(this.ptr)}}t.MIP=void 0,function(t){const e={ffv:a.BranchingTechnique.FFV,lfv:a.BranchingTechnique.LFV,mfv:a.BranchingTechnique.MFV,dth:a.BranchingTechnique.DTH,pch:a.BranchingTechnique.PCH,first_fractional:a.BranchingTechnique.FFV,last_fractional:a.BranchingTechnique.LFV,most_fractional:a.BranchingTechnique.MFV,driebeck_tomlin:a.BranchingTechnique.DTH,hybrid_pseudocost:a.BranchingTechnique.PCH},r={dfs:a.BacktrackingTechnique.DFS,bfs:a.BacktrackingTechnique.BFS,blb:a.BacktrackingTechnique.BLB,bph:a.BacktrackingTechnique.BPH,depth_first:a.BacktrackingTechnique.DFS,breadth_first:a.BacktrackingTechnique.BFS,best_bound:a.BacktrackingTechnique.BLB,best_projection:a.BacktrackingTechnique.BPH},i={none:a.PreprocessingTechnique.NONE,root:a.PreprocessingTechnique.ROOT,all:a.PreprocessingTechnique.ALL};t.solve=function(t,s){if(void 0!==s.callback){const t=s.callback;s.callbackPtr=o.addFunction((e=>t(new C(e))),"vii")}const n=function(t){const s=o._malloc(328);let n;if(o._glp_init_iocp(s),void 0!==t.msgLevel&&o.setValue(s,v(t.msgLevel),"i32"),void 0!==t.branching){if(n=e[t.branching],void 0===n)throw new Error(`unknown branching technique '${t.branching}'`);o.setValue(s+4,n,"i32")}if(void 0!==t.backtracking){if(n=r[t.backtracking],void 0===n)throw new Error(`unknown backtracking technique '${t.backtracking}'`);o.setValue(s+8,n,"i32")}if(void 0!==t.tolInt&&o.setValue(s+16,t.tolInt,"double"),void 0!==t.tolObj&&o.setValue(s+24,t.tolObj,"double"),void 0!==t.limitTime&&o.setValue(s+32,t.limitTime,"i32"),void 0!==t.logFreq&&o.setValue(s+36,t.logFreq,"i32"),void 0!==t.logDelay&&o.setValue(s+40,t.logDelay,"i32"),void 0!==t.callbackPtr&&o.setValue(s+44,t.callbackPtr,"*"),void 0!==t.preprocessing){if(n=i[t.preprocessing],void 0===n)throw new Error(`unknown preprocessing technique '${t.preprocessing}'`);o.setValue(s+56,n,"i32")}return void 0!==t.gapMIP&&o.setValue(s+64,t.gapMIP,"double"),void 0!==t.cutsMIR&&o.setValue(s+72,t.cutsMIR?1:0,"i32"),void 0!==t.cutsGomory&&o.setValue(s+76,t.cutsGomory?1:0,"i32"),void 0!==t.cutsCover&&o.setValue(s+80,t.cutsCover?1:0,"i32"),void 0!==t.cutsClique&&o.setValue(s+84,t.cutsClique?1:0,"i32"),void 0!==t.presolve&&o.setValue(s+88,t.presolve?1:0,"i32"),void 0!==t.binarize&&o.setValue(s+92,t.binarize?1:0,"i32"),void 0!==t.heuristicFP&&o.setValue(s+96,t.heuristicFP?1:0,"i32"),void 0!==t.heuristicPS&&o.setValue(s+100,t.heuristicPS?1:0,"i32"),void 0!==t.limitProxy&&o.setValue(s+104,t.limitProxy,"i32"),void 0!==t.heuristicRound&&o.setValue(s+108,t.heuristicRound?1:0,"i32"),s}(s||{}),l=o._glp_intopt(t.ptr,n);return o._free(n),void 0!==s.callback&&(o.removeFunction(s.callbackPtr),s.callbackPtr=void 0),function(t){switch(t){case a.ReturnCode.OK:return"ok";case a.ReturnCode.EBOUND:return"bounds_incorrect";case a.ReturnCode.EROOT:return"no_root_basis";case a.ReturnCode.ENOPFS:return"no_primal_feasible";case a.ReturnCode.ENODFS:return"no_dual_feasible";case a.ReturnCode.EFAIL:return"failure";case a.ReturnCode.EMIPGAP:return"mip_gap_tolerance";case a.ReturnCode.ETMLIM:return"time_limit";case a.ReturnCode.ESTOP:return"stopped";default:throw new Error(`unknown return code from intopt: ${t}`)}}(l)}}(t.MIP||(t.MIP={}));class A{get vars(){return this._vars}get constrs(){return this._constrs}constructor(t){if(this._vars=[],this._constrs=[],void 0===o)throw new Error("wasm module not loaded");if(this.ptr=o._glp_create_prob(),void 0===t)return;const{name:e,sense:r}=t;void 0!==e&&(this.name=e),void 0!==r&&(this.sense=r)}set name(t){const e=o.lengthBytesUTF8(t)+1,r=o._malloc(e);o.stringToUTF8(t,r,e),o._glp_set_prob_name(this.ptr,r),o._free(r)}get name(){const t=o._glp_get_prob_name(this.ptr);return o.UTF8ToString(t)}static fromPointer(t){const e=Object.create(A.prototype);return e.ptr=t,e}get value(){return o._glp_get_obj_val(this.ptr)}get valueInt(){return o._glp_ipt_obj_val(this.ptr)}get valueMIP(){return o._glp_mip_obj_val(this.ptr)}get numVars(){return o._glp_get_num_cols(this.ptr)}get numConstrs(){return o._glp_get_num_rows(this.ptr)}get numNZs(){return o._glp_get_num_nz(this.ptr)}get numBinary(){return o._glp_get_num_bin(this.ptr)}get numInteger(){return o._glp_get_num_int(this.ptr)}get status(){return E(o._glp_get_status(this.ptr))}get statusPrimal(){return E(o._glp_get_prim_stat(this.ptr))}get statusDual(){return E(o._glp_get_dual_stat(this.ptr))}get statusInt(){return E(o._glp_ipt_status(this.ptr))}get statusMIP(){return E(o._glp_mip_status(this.ptr))}addVars(t,e){return Number.isInteger(t)?this.addVarsByCount(t,e):Array.isArray(t)?0===t.length||"string"==typeof t[0]?this.addVarsByKeys(t,e):this.addVarsByProperties(t):this.addVarsFromPropertiesArray(t)}addVar(t){const e=o._glp_add_cols(this.ptr,1),r=new g(this,e,t);return this._vars.push(r),r}addVarsByProperties(t){const e=o._glp_add_cols(this.ptr,t.length),r=t.map(((t,r)=>new g(this,e+r,t)));return this._vars=this._vars.concat(r),r}addVarsByCount(t,e){const r=o._glp_add_cols(this.ptr,t),i=Array.from(Array(t).keys(),(t=>new g(this,r+t,e&&e.name?Object.assign(Object.assign({},e),{name:`${e.name}_${t}`}):e)));return this._vars=this._vars.concat(i),i}addVarsByKeys(t,e){const r=e||{},{name:i}=r,s=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]])}return r}(r,["name"]);return this.addVarsFromPropertiesArray(Object.fromEntries(t.map((t=>[t,Object.assign(Object.assign({},s),{name:`${i}[${t}]`})]))))}addVarsFromPropertiesArray(t){const e=[...Object.keys(t)];return Object.fromEntries(this.addVarsByProperties(Object.values(t)).map(((t,r)=>[e[r],t])))}addConstrs(t,e){return Number.isInteger(t)?this.addConstrsByCount(t,e):this.addConstrsByProperties(t)}addConstr(t){const e=o._glp_add_rows(this.ptr,1),r=new f(this,e,t);return this._constrs.push(r),r}addConstrsByProperties(t){const e=o._glp_add_rows(this.ptr,t.length),r=t.map(((t,r)=>new f(this,e+r,t)));return this._constrs=this._constrs.concat(r),r}addConstrsByCount(t,e){const r=o._glp_add_rows(this.ptr,t),i=Array.from(Array(t).keys(),(t=>new f(this,r+t,e&&e.name?Object.assign(Object.assign({},e),{name:`${e.name}_${t}`}):e)));return this._constrs=this._constrs.concat(i),i}update(){for(const t of this._constrs)t.update()}get sense(){return o._glp_get_obj_dir(this.ptr)===a.ObjectiveDirection.MIN?"min":"max"}set sense(t){if("min"!==t&&"max"!==t)throw new Error(`unknown sense '${t}'`);o._glp_set_obj_dir(this.ptr,"min"===t?a.ObjectiveDirection.MIN:a.ObjectiveDirection.MAX)}toModelLP(){this.update();const t="_tmp.lp",e=o._malloc(8);return o.stringToUTF8(t,e,8),o._glp_write_lp(this.ptr,0,e),o._free(e),o.FS.readFile(t,{encoding:"utf8"})}_refreshVariables(){const t=o._glp_get_num_cols(this.ptr);this._vars=Array.from(Array(t).keys(),(t=>new g(this,t+1,{lb:o._glp_get_col_lb(this.ptr,t+1),ub:o._glp_get_col_ub(this.ptr,t+1)})))}_refreshConstraints(){const t=o._glp_get_num_rows(this.ptr);this._constrs=Array.from(Array(t).keys(),(t=>new f(this,t+1,{lb:o._glp_get_row_lb(this.ptr,t+1),ub:o._glp_get_row_ub(this.ptr,t+1)})))}static fromModelLP(t){const e=new A,r="_tmp.lp";o.FS.writeFile(r,t);const i=o._malloc(8);return o.stringToUTF8(r,i,8),o._glp_read_lp(e.ptr,0,i),o._free(i),e._refreshVariables(),e._refreshConstraints(),e}toMPS(){this.update();const t="_tmp.mps",e=o._malloc(9);return o.stringToUTF8(t,e,9),o._glp_write_mps(this.ptr,a.MPSFormat.FILE,0,e),o._free(e),o.FS.readFile(t,{encoding:"utf8"})}static fromMPS(t,e){const r=new A,i="_tmp.mps";o.FS.writeFile(i,t);const s=o._malloc(9);o.stringToUTF8(i,s,9);const n="deck"===e?a.MPSFormat.DECK:a.MPSFormat.FILE,l=o._glp_read_mps(r.ptr,n,0,s);if(o._free(s),0!==l)throw new Error("mps reading failed");return r._refreshVariables(),r._refreshConstraints(),r}simplex(e){return this.update(),t.Simplex.solve(this,e||{})}exact(e){return this.update(),t.Simplex.solveExact(this,e||{})}interior(e){return this.update(),t.Interior.solve(this,e||{})}intopt(e){return this.update(),t.MIP.solve(this,e||{})}get solution(){switch(this.status){case"undefined":case"infeasible":throw new Error(`status is '${this.status}', run simplex first`);case"feasible":case"optimal":return[`status = ${this.status}`,...this._vars.map((t=>`${t.name} = ${t.value}`)),`value = ${this.value}`].join("\n");case"unbounded":return"problem is unbounded";case"no_feasible":return"problem has no feasible solution";default:throw new Error("unknown status")}}get solutionInt(){switch(this.statusInt){case"undefined":case"infeasible":throw new Error(`status is '${this.statusInt}', run interior first`);case"optimal":return[`status = ${this.statusInt}`,...this._vars.map((t=>`${t.name} = ${Number(t.valueInt.toFixed(6))}`)),`value = ${Number(this.valueInt.toFixed(6))}`].join("\n");case"no_feasible":return"problem has no feasible solution";default:throw new Error("unknown status")}}get solutionMIP(){switch(this.statusMIP){case"undefined":throw new Error(`status is '${this.statusMIP}', run intopt first`);case"feasible":case"optimal":return[`status = ${this.statusMIP}`,...this._vars.map((t=>`${t.name} = ${t.valueMIP}`)),`value = ${this.valueMIP}`].join("\n");case"no_feasible":return"problem has no feasible solution";default:throw new Error("unknown status")}}get ray(){const t=o._glp_get_unbnd_ray(this.ptr);if(0===t)throw new Error("no unbounded ray");return t<=this.numConstrs?this._constrs[t-1]:this._vars[t-1-this.numConstrs]}getTableau(t){const e=void 0===t?t=t=>t.toString():t;return[...[...this.vars,...this.constrs].filter((t=>"basic"===t.status)).map((t=>t.name+" = "+[...t.row.map((([t,r])=>`${e(t instanceof g?r:-r)} ${t.name}`)),e(t.value)].join(" + "))),"z = "+[...[...this.vars,...this.constrs].filter((t=>"basic"!==t.status)).map((t=>`${e(t instanceof g?t.dual:-t.dual)} ${t.name}`)),e(this.value)].join(" + ")].join("\n")}}t.Constraint=f,t.Model=A,t.Node=P,t.Tree=C,t.Variable=g,t.loadModule=function(t){return s(this,void 0,void 0,(function*(){return void 0===n&&(n=void 0===t?i.default():i.default({locateFile:()=>t})),o=yield n,o}))},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=/sm/846881f4af6bd72330701daaac3c8ae61dd8cbf4754d8e40084cf2ebc0af33c1.map