js-randomness-predictor
Version:
Predict Math.random output in Node, Deno, Bun, Chrome, Firefox, and Safari
1 lines • 58.4 kB
JavaScript
"use strict";const ke=require("./index-BsXrCQEH.cjs");function Jn(u,o){for(var c=0;c<o.length;c++){const i=o[c];if(typeof i!="string"&&!Array.isArray(i)){for(const _ in i)if(_!=="default"&&!(_ in u)){const f=Object.getOwnPropertyDescriptor(i,_);f&&Object.defineProperty(u,_,f.get?f:{enumerable:!0,get:()=>i[_]})}}}return Object.freeze(Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}))}var ot={},Mt={},be={},Se=function(u,o){return Se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,i){c.__proto__=i}||function(c,i){for(var _ in i)Object.prototype.hasOwnProperty.call(i,_)&&(c[_]=i[_])},Se(u,o)};function br(u,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");Se(u,o);function c(){this.constructor=u}u.prototype=o===null?Object.create(o):(c.prototype=o.prototype,new c)}var Dt=function(){return Dt=Object.assign||function(o){for(var c,i=1,_=arguments.length;i<_;i++){c=arguments[i];for(var f in c)Object.prototype.hasOwnProperty.call(c,f)&&(o[f]=c[f])}return o},Dt.apply(this,arguments)};function kr(u,o){var c={};for(var i in u)Object.prototype.hasOwnProperty.call(u,i)&&o.indexOf(i)<0&&(c[i]=u[i]);if(u!=null&&typeof Object.getOwnPropertySymbols=="function")for(var _=0,i=Object.getOwnPropertySymbols(u);_<i.length;_++)o.indexOf(i[_])<0&&Object.prototype.propertyIsEnumerable.call(u,i[_])&&(c[i[_]]=u[i[_]]);return c}function Sr(u,o,c,i){var _=arguments.length,f=_<3?o:i===null?i=Object.getOwnPropertyDescriptor(o,c):i,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(u,o,c,i);else for(var p=u.length-1;p>=0;p--)(l=u[p])&&(f=(_<3?l(f):_>3?l(o,c,f):l(o,c))||f);return _>3&&f&&Object.defineProperty(o,c,f),f}function Er(u,o){return function(c,i){o(c,i,u)}}function Ar(u,o,c,i,_,f){function l(C){if(C!==void 0&&typeof C!="function")throw new TypeError("Function expected");return C}for(var p=i.kind,r=p==="getter"?"get":p==="setter"?"set":"value",d=!o&&u?i.static?u:u.prototype:null,v=o||(d?Object.getOwnPropertyDescriptor(d,i.name):{}),S,E=!1,y=c.length-1;y>=0;y--){var I={};for(var R in i)I[R]=R==="access"?{}:i[R];for(var R in i.access)I.access[R]=i.access[R];I.addInitializer=function(C){if(E)throw new TypeError("Cannot add initializers after decoration has completed");f.push(l(C||null))};var N=(0,c[y])(p==="accessor"?{get:v.get,set:v.set}:v[r],I);if(p==="accessor"){if(N===void 0)continue;if(N===null||typeof N!="object")throw new TypeError("Object expected");(S=l(N.get))&&(v.get=S),(S=l(N.set))&&(v.set=S),(S=l(N.init))&&_.unshift(S)}else(S=l(N))&&(p==="field"?_.unshift(S):v[r]=S)}d&&Object.defineProperty(d,i.name,v),E=!0}function Or(u,o,c){for(var i=arguments.length>2,_=0;_<o.length;_++)c=i?o[_].call(u,c):o[_].call(u);return i?c:void 0}function xr(u){return typeof u=="symbol"?u:"".concat(u)}function Tr(u,o,c){return typeof o=="symbol"&&(o=o.description?"[".concat(o.description,"]"):""),Object.defineProperty(u,"name",{configurable:!0,value:c?"".concat(c," ",o):o})}function Ir(u,o){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(u,o)}function Rr(u,o,c,i){function _(f){return f instanceof c?f:new c(function(l){l(f)})}return new(c||(c=Promise))(function(f,l){function p(v){try{d(i.next(v))}catch(S){l(S)}}function r(v){try{d(i.throw(v))}catch(S){l(S)}}function d(v){v.done?f(v.value):_(v.value).then(p,r)}d((i=i.apply(u,o||[])).next())})}function Pr(u,o){var c={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},i,_,f,l=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return l.next=p(0),l.throw=p(1),l.return=p(2),typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function p(d){return function(v){return r([d,v])}}function r(d){if(i)throw new TypeError("Generator is already executing.");for(;l&&(l=0,d[0]&&(c=0)),c;)try{if(i=1,_&&(f=d[0]&2?_.return:d[0]?_.throw||((f=_.return)&&f.call(_),0):_.next)&&!(f=f.call(_,d[1])).done)return f;switch(_=0,f&&(d=[d[0]&2,f.value]),d[0]){case 0:case 1:f=d;break;case 4:return c.label++,{value:d[1],done:!1};case 5:c.label++,_=d[1],d=[0];continue;case 7:d=c.ops.pop(),c.trys.pop();continue;default:if(f=c.trys,!(f=f.length>0&&f[f.length-1])&&(d[0]===6||d[0]===2)){c=0;continue}if(d[0]===3&&(!f||d[1]>f[0]&&d[1]<f[3])){c.label=d[1];break}if(d[0]===6&&c.label<f[1]){c.label=f[1],f=d;break}if(f&&c.label<f[2]){c.label=f[2],c.ops.push(d);break}f[2]&&c.ops.pop(),c.trys.pop();continue}d=o.call(u,c)}catch(v){d=[6,v],_=0}finally{i=f=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}var jt=Object.create?(function(u,o,c,i){i===void 0&&(i=c);var _=Object.getOwnPropertyDescriptor(o,c);(!_||("get"in _?!o.__esModule:_.writable||_.configurable))&&(_={enumerable:!0,get:function(){return o[c]}}),Object.defineProperty(u,i,_)}):(function(u,o,c,i){i===void 0&&(i=c),u[i]=o[c]});function qr(u,o){for(var c in u)c!=="default"&&!Object.prototype.hasOwnProperty.call(o,c)&&jt(o,u,c)}function Ut(u){var o=typeof Symbol=="function"&&Symbol.iterator,c=o&&u[o],i=0;if(c)return c.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&i>=u.length&&(u=void 0),{value:u&&u[i++],done:!u}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ae(u,o){var c=typeof Symbol=="function"&&u[Symbol.iterator];if(!c)return u;var i=c.call(u),_,f=[],l;try{for(;(o===void 0||o-- >0)&&!(_=i.next()).done;)f.push(_.value)}catch(p){l={error:p}}finally{try{_&&!_.done&&(c=i.return)&&c.call(i)}finally{if(l)throw l.error}}return f}function Lr(){for(var u=[],o=0;o<arguments.length;o++)u=u.concat(Ae(arguments[o]));return u}function Nr(){for(var u=0,o=0,c=arguments.length;o<c;o++)u+=arguments[o].length;for(var i=Array(u),_=0,o=0;o<c;o++)for(var f=arguments[o],l=0,p=f.length;l<p;l++,_++)i[_]=f[l];return i}function Mr(u,o,c){if(c||arguments.length===2)for(var i=0,_=o.length,f;i<_;i++)(f||!(i in o))&&(f||(f=Array.prototype.slice.call(o,0,i)),f[i]=o[i]);return u.concat(f||Array.prototype.slice.call(o))}function ft(u){return this instanceof ft?(this.v=u,this):new ft(u)}function Cr(u,o,c){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=c.apply(u,o||[]),_,f=[];return _=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),p("next"),p("throw"),p("return",l),_[Symbol.asyncIterator]=function(){return this},_;function l(y){return function(I){return Promise.resolve(I).then(y,S)}}function p(y,I){i[y]&&(_[y]=function(R){return new Promise(function(N,C){f.push([y,R,N,C])>1||r(y,R)})},I&&(_[y]=I(_[y])))}function r(y,I){try{d(i[y](I))}catch(R){E(f[0][3],R)}}function d(y){y.value instanceof ft?Promise.resolve(y.value.v).then(v,S):E(f[0][2],y)}function v(y){r("next",y)}function S(y){r("throw",y)}function E(y,I){y(I),f.shift(),f.length&&r(f[0][0],f[0][1])}}function zr(u){var o,c;return o={},i("next"),i("throw",function(_){throw _}),i("return"),o[Symbol.iterator]=function(){return this},o;function i(_,f){o[_]=u[_]?function(l){return(c=!c)?{value:ft(u[_](l)),done:!1}:f?f(l):l}:f}}function Dr(u){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=u[Symbol.asyncIterator],c;return o?o.call(u):(u=typeof Ut=="function"?Ut(u):u[Symbol.iterator](),c={},i("next"),i("throw"),i("return"),c[Symbol.asyncIterator]=function(){return this},c);function i(f){c[f]=u[f]&&function(l){return new Promise(function(p,r){l=u[f](l),_(p,r,l.done,l.value)})}}function _(f,l,p,r){Promise.resolve(r).then(function(d){f({value:d,done:p})},l)}}function Ur(u,o){return Object.defineProperty?Object.defineProperty(u,"raw",{value:o}):u.raw=o,u}var Zn=Object.create?(function(u,o){Object.defineProperty(u,"default",{enumerable:!0,value:o})}):function(u,o){u.default=o},Ee=function(u){return Ee=Object.getOwnPropertyNames||function(o){var c=[];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(c[c.length]=i);return c},Ee(u)};function jr(u){if(u&&u.__esModule)return u;var o={};if(u!=null)for(var c=Ee(u),i=0;i<c.length;i++)c[i]!=="default"&&jt(o,u,c[i]);return Zn(o,u),o}function $r(u){return u&&u.__esModule?u:{default:u}}function Fr(u,o,c,i){if(c==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?u!==o||!i:!o.has(u))throw new TypeError("Cannot read private member from an object whose class did not declare it");return c==="m"?i:c==="a"?i.call(u):i?i.value:o.get(u)}function Vr(u,o,c,i,_){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!_)throw new TypeError("Private accessor was defined without a setter");if(typeof o=="function"?u!==o||!_:!o.has(u))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?_.call(u,c):_?_.value=c:o.set(u,c),c}function Br(u,o){if(o===null||typeof o!="object"&&typeof o!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof u=="function"?o===u:u.has(o)}function Gr(u,o,c){if(o!=null){if(typeof o!="object"&&typeof o!="function")throw new TypeError("Object expected.");var i,_;if(c){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=o[Symbol.asyncDispose]}if(i===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=o[Symbol.dispose],c&&(_=i)}if(typeof i!="function")throw new TypeError("Object not disposable.");_&&(i=function(){try{_.call(this)}catch(f){return Promise.reject(f)}}),u.stack.push({value:o,dispose:i,async:c})}else c&&u.stack.push({async:!0});return o}var ts=typeof SuppressedError=="function"?SuppressedError:function(u,o,c){var i=new Error(c);return i.name="SuppressedError",i.error=u,i.suppressed=o,i};function Wr(u){function o(f){u.error=u.hasError?new ts(f,u.error,"An error was suppressed during disposal."):f,u.hasError=!0}var c,i=0;function _(){for(;c=u.stack.pop();)try{if(!c.async&&i===1)return i=0,u.stack.push(c),Promise.resolve().then(_);if(c.dispose){var f=c.dispose.call(c.value);if(c.async)return i|=2,Promise.resolve(f).then(_,function(l){return o(l),_()})}else i|=1}catch(l){o(l)}if(i===1)return u.hasError?Promise.reject(u.error):Promise.resolve();if(u.hasError)throw u.error}return _()}function Qr(u,o){return typeof u=="string"&&/^\.\.?\//.test(u)?u.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(c,i,_,f,l){return i?o?".jsx":".js":_&&(!f||!l)?c:_+f+"."+l.toLowerCase()+"js"}):u}const es={__extends:br,__assign:Dt,__rest:kr,__decorate:Sr,__param:Er,__esDecorate:Ar,__runInitializers:Or,__propKey:xr,__setFunctionName:Tr,__metadata:Ir,__awaiter:Rr,__generator:Pr,__createBinding:jt,__exportStar:qr,__values:Ut,__read:Ae,__spread:Lr,__spreadArrays:Nr,__spreadArray:Mr,__await:ft,__asyncGenerator:Cr,__asyncDelegator:zr,__asyncValues:Dr,__makeTemplateObject:Ur,__importStar:jr,__importDefault:$r,__classPrivateFieldGet:Fr,__classPrivateFieldSet:Vr,__classPrivateFieldIn:Br,__addDisposableResource:Gr,__disposeResources:Wr,__rewriteRelativeImportExtension:Qr},rs=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource:Gr,get __assign(){return Dt},__asyncDelegator:zr,__asyncGenerator:Cr,__asyncValues:Dr,__await:ft,__awaiter:Rr,__classPrivateFieldGet:Fr,__classPrivateFieldIn:Br,__classPrivateFieldSet:Vr,__createBinding:jt,__decorate:Sr,__disposeResources:Wr,__esDecorate:Ar,__exportStar:qr,__extends:br,__generator:Pr,__importDefault:$r,__importStar:jr,__makeTemplateObject:Ur,__metadata:Ir,__param:Er,__propKey:xr,__read:Ae,__rest:kr,__rewriteRelativeImportExtension:Qr,__runInitializers:Or,__setFunctionName:Tr,__spread:Lr,__spreadArray:Mr,__spreadArrays:Nr,__values:Ut,default:es},Symbol.toStringTag,{value:"Module"})),$t=ke.getAugmentedNamespace(rs);var Ct={},zt={},W={},fr;function Ft(){return fr||(fr=1,Object.defineProperty(W,"__esModule",{value:!0}),W.E_CANCELED=W.E_ALREADY_LOCKED=W.E_TIMEOUT=void 0,W.E_TIMEOUT=new Error("timeout while waiting for mutex to become available"),W.E_ALREADY_LOCKED=new Error("mutex already locked"),W.E_CANCELED=new Error("request for lock canceled")),W}var lr;function Kr(){if(lr)return zt;lr=1,Object.defineProperty(zt,"__esModule",{value:!0});var u=$t,o=Ft(),c=(function(){function f(l,p){p===void 0&&(p=o.E_CANCELED),this._value=l,this._cancelError=p,this._queue=[],this._weightedWaiters=[]}return f.prototype.acquire=function(l,p){var r=this;if(l===void 0&&(l=1),p===void 0&&(p=0),l<=0)throw new Error("invalid weight ".concat(l,": must be positive"));return new Promise(function(d,v){var S={resolve:d,reject:v,weight:l,priority:p},E=_(r._queue,function(y){return p<=y.priority});E===-1&&l<=r._value?r._dispatchItem(S):r._queue.splice(E+1,0,S)})},f.prototype.runExclusive=function(l){return u.__awaiter(this,arguments,void 0,function(p,r,d){var v,S,E;return r===void 0&&(r=1),d===void 0&&(d=0),u.__generator(this,function(y){switch(y.label){case 0:return[4,this.acquire(r,d)];case 1:v=y.sent(),S=v[0],E=v[1],y.label=2;case 2:return y.trys.push([2,,4,5]),[4,p(S)];case 3:return[2,y.sent()];case 4:return E(),[7];case 5:return[2]}})})},f.prototype.waitForUnlock=function(l,p){var r=this;if(l===void 0&&(l=1),p===void 0&&(p=0),l<=0)throw new Error("invalid weight ".concat(l,": must be positive"));return this._couldLockImmediately(l,p)?Promise.resolve():new Promise(function(d){r._weightedWaiters[l-1]||(r._weightedWaiters[l-1]=[]),i(r._weightedWaiters[l-1],{resolve:d,priority:p})})},f.prototype.isLocked=function(){return this._value<=0},f.prototype.getValue=function(){return this._value},f.prototype.setValue=function(l){this._value=l,this._dispatchQueue()},f.prototype.release=function(l){if(l===void 0&&(l=1),l<=0)throw new Error("invalid weight ".concat(l,": must be positive"));this._value+=l,this._dispatchQueue()},f.prototype.cancel=function(){var l=this;this._queue.forEach(function(p){return p.reject(l._cancelError)}),this._queue=[]},f.prototype._dispatchQueue=function(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()},f.prototype._dispatchItem=function(l){var p=this._value;this._value-=l.weight,l.resolve([p,this._newReleaser(l.weight)])},f.prototype._newReleaser=function(l){var p=this,r=!1;return function(){r||(r=!0,p.release(l))}},f.prototype._drainUnlockWaiters=function(){if(this._queue.length===0)for(var l=this._value;l>0;l--){var p=this._weightedWaiters[l-1];p&&(p.forEach(function(v){return v.resolve()}),this._weightedWaiters[l-1]=[])}else for(var r=this._queue[0].priority,l=this._value;l>0;l--){var p=this._weightedWaiters[l-1];if(p){var d=p.findIndex(function(E){return E.priority<=r});(d===-1?p:p.splice(0,d)).forEach((function(E){return E.resolve()}))}}},f.prototype._couldLockImmediately=function(l,p){return(this._queue.length===0||this._queue[0].priority<p)&&l<=this._value},f})();function i(f,l){var p=_(f,function(r){return l.priority<=r.priority});f.splice(p+1,0,l)}function _(f,l){for(var p=f.length-1;p>=0;p--)if(l(f[p]))return p;return-1}return zt.default=c,zt}var hr;function ns(){if(hr)return Ct;hr=1,Object.defineProperty(Ct,"__esModule",{value:!0});var u=$t,o=Kr(),c=(function(){function i(_){this._semaphore=new o.default(1,_)}return i.prototype.acquire=function(){return u.__awaiter(this,arguments,void 0,function(_){var f,l;return _===void 0&&(_=0),u.__generator(this,function(p){switch(p.label){case 0:return[4,this._semaphore.acquire(1,_)];case 1:return f=p.sent(),l=f[1],[2,l]}})})},i.prototype.runExclusive=function(_,f){return f===void 0&&(f=0),this._semaphore.runExclusive(function(){return _()},1,f)},i.prototype.isLocked=function(){return this._semaphore.isLocked()},i.prototype.waitForUnlock=function(_){return _===void 0&&(_=0),this._semaphore.waitForUnlock(1,_)},i.prototype.release=function(){this._semaphore.isLocked()&&this._semaphore.release()},i.prototype.cancel=function(){return this._semaphore.cancel()},i})();return Ct.default=c,Ct}var yt={},pr;function Yr(){if(pr)return yt;pr=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.withTimeout=void 0;var u=$t,o=Ft();function c(_,f,l){var p=this;return l===void 0&&(l=o.E_TIMEOUT),{acquire:function(r,d){var v;if(i(_)?v=r:(v=void 0,d=r),v!==void 0&&v<=0)throw new Error("invalid weight ".concat(v,": must be positive"));return new Promise(function(S,E){return u.__awaiter(p,void 0,void 0,function(){var y,I,R,N,C;return u.__generator(this,function(X){switch(X.label){case 0:y=!1,I=setTimeout(function(){y=!0,E(l)},f),X.label=1;case 1:return X.trys.push([1,3,,4]),[4,i(_)?_.acquire(v,d):_.acquire(d)];case 2:return R=X.sent(),y?(N=Array.isArray(R)?R[1]:R,N()):(clearTimeout(I),S(R)),[3,4];case 3:return C=X.sent(),y||(clearTimeout(I),E(C)),[3,4];case 4:return[2]}})})})},runExclusive:function(r,d,v){return u.__awaiter(this,void 0,void 0,function(){var S,E;return u.__generator(this,function(y){switch(y.label){case 0:S=function(){},y.label=1;case 1:return y.trys.push([1,,7,8]),[4,this.acquire(d,v)];case 2:return E=y.sent(),Array.isArray(E)?(S=E[1],[4,r(E[0])]):[3,4];case 3:return[2,y.sent()];case 4:return S=E,[4,r()];case 5:return[2,y.sent()];case 6:return[3,8];case 7:return S(),[7];case 8:return[2]}})})},release:function(r){_.release(r)},cancel:function(){return _.cancel()},waitForUnlock:function(r,d){var v;if(i(_)?v=r:(v=void 0,d=r),v!==void 0&&v<=0)throw new Error("invalid weight ".concat(v,": must be positive"));return new Promise(function(S,E){var y=setTimeout(function(){return E(l)},f);(i(_)?_.waitForUnlock(v,d):_.waitForUnlock(d)).then(function(){clearTimeout(y),S()})})},isLocked:function(){return _.isLocked()},getValue:function(){return _.getValue()},setValue:function(r){return _.setValue(r)}}}yt.withTimeout=c;function i(_){return _.getValue!==void 0}return yt}var vt={},dr;function ss(){if(dr)return vt;dr=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.tryAcquire=void 0;var u=Ft(),o=Yr();function c(i,_){return _===void 0&&(_=u.E_ALREADY_LOCKED),(0,o.withTimeout)(i,0,_)}return vt.tryAcquire=c,vt}var mr;function is(){return mr||(mr=1,(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.tryAcquire=u.withTimeout=u.Semaphore=u.Mutex=void 0;var o=$t,c=ns();Object.defineProperty(u,"Mutex",{enumerable:!0,get:function(){return c.default}});var i=Kr();Object.defineProperty(u,"Semaphore",{enumerable:!0,get:function(){return i.default}});var _=Yr();Object.defineProperty(u,"withTimeout",{enumerable:!0,get:function(){return _.withTimeout}});var f=ss();Object.defineProperty(u,"tryAcquire",{enumerable:!0,get:function(){return f.tryAcquire}}),o.__exportStar(Ft(),u)})(be)),be}var at={},wr;function Oe(){if(wr)return at;wr=1,Object.defineProperty(at,"__esModule",{value:!0}),at.Z3AssertionError=at.Z3Error=void 0;class u extends Error{}at.Z3Error=u;class o extends u{}return at.Z3AssertionError=o,at}var _t={},gr;function os(){if(gr)return _t;gr=1,Object.defineProperty(_t,"__esModule",{value:!0}),_t.assertExhaustive=o,_t.assert=c,_t.allSatisfy=i;const u=Oe();function o(_){throw new Error("Unexpected code execution detected, should be caught at compile time")}function c(_,f){if(!_)throw new u.Z3AssertionError(f??"Assertion failed")}function i(_,f){let l=!1;for(const p of _)if(l=!0,!f(p))return!1;return l===!0?!0:null}return _t}var yr;function as(){if(yr)return Mt;yr=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.createApi=p;const u=is(),o=ke.requireLowLevel(),c=Oe(),i=os(),_=17,f=new u.Mutex;function l(r){const d=r!==null&&(typeof r=="object"||typeof r=="function")&&r.numerator!==null&&(typeof r.numerator=="number"||typeof r.numerator=="bigint")&&r.denominator!==null&&(typeof r.denominator=="number"||typeof r.denominator=="bigint");return d&&(0,i.assert)((typeof r.numerator!="number"||Number.isSafeInteger(r.numerator))&&(typeof r.denominator!="number"||Number.isSafeInteger(r.denominator)),"Fraction numerator and denominator must be integers"),d}function p(r){const d=new FinalizationRegistry(P=>P());function v(P){r.enable_trace(P)}function S(P){r.disable_trace(P)}function E(){return r.get_version()}function y(){const{major:P,minor:J,build_number:Z}=r.get_version();return`${P}.${J}.${Z}`}function I(){return r.get_full_version()}function R(P){return r.open_log(P)}function N(P){r.append_log(P)}function C(P,J){typeof P=="string"?r.global_param_set(P,J.toString()):((0,i.assert)(J===void 0,"Can't provide a Record and second parameter to set_param at the same time"),Object.entries(P).forEach(([Z,n])=>C(Z,n)))}function X(){r.global_param_reset_all()}function xe(P){return r.global_param_get(P)}function Hr(P,J){const Z=r.mk_config();J!=null&&Object.entries(J).forEach(([e,t])=>a(r.set_param_value(Z,e,t.toString())));const n=r.mk_context_rc(Z);r.set_ast_print_mode(n,o.Z3_ast_print_mode.Z3_PRINT_SMTLIB2_COMPLIANT),r.del_config(Z);function m(...e){e.forEach(t=>(0,i.assert)("ctx"in t?x===t.ctx:x===t,"Context mismatch"))}function Vt(e){if(e==null)throw new TypeError("Expected non-null pointer")}function Bt(){if(r.get_error_code(n)!==o.Z3_error_code.Z3_OK)throw new Error(r.get_error_msg(x.ptr,r.get_error_code(x.ptr)))}function a(e){return Bt(),e}function O(e){return a(typeof e=="number"?r.mk_int_symbol(n,e):r.mk_string_symbol(n,e))}function bt(e){const t=a(r.get_symbol_kind(n,e));switch(t){case o.Z3_symbol_kind.Z3_INT_SYMBOL:return r.get_symbol_int(n,e);case o.Z3_symbol_kind.Z3_STRING_SYMBOL:return r.get_symbol_string(n,e);default:(0,i.assertExhaustive)(t)}}function Te(e,t){const s=r.mk_params(n);return r.params_inc_ref(n,s),typeof t=="boolean"?r.params_set_bool(n,s,O(e),t):typeof t=="number"?Number.isInteger(t)?a(r.params_set_uint(n,s,O(e),t)):a(r.params_set_double(n,s,O(e),t)):typeof t=="string"&&a(r.params_set_symbol(n,s,O(e),O(t))),s}function Gt(e){switch(a(r.get_ast_kind(n,e))){case o.Z3_ast_kind.Z3_SORT_AST:return Q(e);case o.Z3_ast_kind.Z3_FUNC_DECL_AST:return new D(e);default:return T(e)}}function Q(e){switch(a(r.get_sort_kind(n,e))){case o.Z3_sort_kind.Z3_BOOL_SORT:return new ir(e);case o.Z3_sort_kind.Z3_INT_SORT:case o.Z3_sort_kind.Z3_REAL_SORT:return new dt(e);case o.Z3_sort_kind.Z3_BV_SORT:return new me(e);case o.Z3_sort_kind.Z3_ARRAY_SORT:return new It(e);default:return new B(e)}}function T(e){const t=a(r.get_ast_kind(n,e));if(t===o.Z3_ast_kind.Z3_QUANTIFIER_AST)return r.is_lambda(n,e)?new cr(e):new ye(e);switch(a(r.get_sort_kind(n,r.get_sort(n,e)))){case o.Z3_sort_kind.Z3_BOOL_SORT:return new b(e);case o.Z3_sort_kind.Z3_INT_SORT:return t===o.Z3_ast_kind.Z3_NUMERAL_AST?new mt(e):new A(e);case o.Z3_sort_kind.Z3_REAL_SORT:return t===o.Z3_ast_kind.Z3_NUMERAL_AST?new de(e):new A(e);case o.Z3_sort_kind.Z3_BV_SORT:return t===o.Z3_ast_kind.Z3_NUMERAL_AST?new we(e):new k(e);case o.Z3_sort_kind.Z3_ARRAY_SORT:return new Rt(e);default:return new F(e)}}function kt(e){const t=[];for(const s of e)Ne(s)?t.push(...s.values()):t.push(s);return t}function Ie(e){return et(e)?e:new Tt(e)}function Re(e,t){(0,i.assert)(t.length>0,"At least one argument expected");let s=Ie(t[0]);for(let h=1;h<t.length;h++)s=new Tt(a(e(n,s.ptr,Ie(t[h]).ptr)));return s}function Xr(){a(r.interrupt(n))}function Jr(e){const t=e instanceof xt;return t&&m(e),t}function Pe(e){const t=e instanceof Ot;return t&&m(e),t}function St(e){const t=e instanceof B;return t&&m(e),t}function ut(e){const t=e instanceof D;return t&&m(e),t}function qe(e){const t=e instanceof ae;return t&&m(e),t}function tt(e){if(!L(e))return!1;const t=a(r.get_ast_kind(n,e.ast));return t===o.Z3_ast_kind.Z3_NUMERAL_AST||t===o.Z3_ast_kind.Z3_APP_AST}function V(e){return L(e)&&tt(e)&&e.numArgs()===0}function L(e){const t=e instanceof F;return t&&m(e),t}function Le(e){return L(e)&&a(r.get_ast_kind(n,e.ast))===o.Z3_ast_kind.Z3_VAR_AST}function $(e,t){return L(e)&&tt(e)&&e.decl().kind()===t}function Et(e){const t=e instanceof F&&e.sort.kind()===o.Z3_sort_kind.Z3_BOOL_SORT;return t&&m(e),t}function Zr(e){return $(e,o.Z3_decl_kind.Z3_OP_TRUE)}function tn(e){return $(e,o.Z3_decl_kind.Z3_OP_FALSE)}function en(e){return $(e,o.Z3_decl_kind.Z3_OP_AND)}function rn(e){return $(e,o.Z3_decl_kind.Z3_OP_OR)}function nn(e){return $(e,o.Z3_decl_kind.Z3_OP_IMPLIES)}function sn(e){return $(e,o.Z3_decl_kind.Z3_OP_NOT)}function on(e){return $(e,o.Z3_decl_kind.Z3_OP_EQ)}function an(e){return $(e,o.Z3_decl_kind.Z3_OP_DISTINCT)}function un(e){const t=e instanceof ge;return t&&m(e),t}function lt(e){const t=e instanceof A;return t&&m(e),t}function cn(e){const t=e instanceof dt;return t&&m(e),t}function Wt(e){return lt(e)&&ct(e.sort)}function _n(e){const t=e instanceof mt;return t&&m(e),t}function ct(e){return St(e)&&e.kind()===o.Z3_sort_kind.Z3_INT_SORT}function Qt(e){return lt(e)&&Kt(e.sort)}function fn(e){const t=e instanceof de;return t&&m(e),t}function Kt(e){return St(e)&&e.kind()===o.Z3_sort_kind.Z3_REAL_SORT}function At(e){const t=e instanceof me;return t&&m(e),t}function ln(e){const t=e instanceof k;return t&&m(e),t}function hn(e){const t=e instanceof we;return t&&m(e),t}function pn(e){const t=e instanceof It;return t&&m(e),t}function dn(e){const t=e instanceof Rt;return t&&m(e),t}function mn(e){return $(e,o.Z3_decl_kind.Z3_OP_CONST_ARRAY)}function et(e){const t=e instanceof Tt;return t&&m(e),t}function ht(e){const t=e instanceof ue;return t&&m(e),t}function Ne(e){const t=e instanceof K;return t&&m(e),t}function wn(e,t){return e.eqIdentity(t)}function gn(e){return(0,i.assert)(Le(e),"Z3 bound variable expected"),r.get_index_value(n,e.ast)}function q(e){if(typeof e=="boolean")return U.val(e);if(typeof e=="number"){if(!Number.isFinite(e))throw new Error(`cannot represent infinity/NaN (got ${e})`);return Math.floor(e)===e?j.val(e):z.val(e)}else{if(l(e))return z.val(e);if(typeof e=="bigint")return j.val(e);if(L(e))return e}(0,i.assert)(!1)}async function yn(...e){const t=new x.Solver;t.add(...e);const s=await t.check();return s==="sat"?t.model():s}async function vn(e){const t=await r.simplify(n,e.ast);return T(a(t))}const bn={declare:e=>new B(r.mk_uninterpreted_sort(n,O(e)))},kn={declare:(e,...t)=>{const s=t.length-1,h=t[s];m(h);const w=[];for(let g=0;g<s;g++)m(t[g]),w.push(t[g].ptr);return new D(r.mk_func_decl(n,O(e),w,h.ptr))},fresh:(...e)=>{const t=e.length-1,s=e[t];m(s);const h=[];for(let w=0;w<t;w++)m(e[w]),h.push(e[w].ptr);return new D(r.mk_fresh_func_decl(n,"f",h,s.ptr))}},Sn={declare:(e,...t)=>{const s=t.length-1,h=t[s];m(h);const w=[];for(let g=0;g<s;g++)m(t[g]),w.push(t[g].ptr);return new D(r.mk_rec_func_decl(n,O(e),w,h.ptr))},addDefinition:(e,t,s)=>{m(e,...t,s),a(r.add_rec_def(n,e.ptr,t.map(h=>h.ast),s.ast))}},U={sort:()=>new ir(r.mk_bool_sort(n)),const:e=>new b(r.mk_const(n,O(e),U.sort().ptr)),consts:e=>(typeof e=="string"&&(e=e.split(" ")),e.map(t=>U.const(t))),vector:(e,t)=>{const s=[];for(let h=0;h<t;h++)s.push(U.const(`${e}__${h}`));return s},fresh:(e="b")=>new b(r.mk_fresh_const(n,e,U.sort().ptr)),val:e=>e?new b(r.mk_true(n)):new b(r.mk_false(n))},j={sort:()=>new dt(r.mk_int_sort(n)),const:e=>new A(r.mk_const(n,O(e),j.sort().ptr)),consts:e=>(typeof e=="string"&&(e=e.split(" ")),e.map(t=>j.const(t))),vector:(e,t)=>{const s=[];for(let h=0;h<t;h++)s.push(j.const(`${e}__${h}`));return s},fresh:(e="x")=>new A(r.mk_fresh_const(n,e,j.sort().ptr)),val:e=>((0,i.assert)(typeof e=="bigint"||typeof e=="string"||Number.isSafeInteger(e)),new mt(a(r.mk_numeral(n,e.toString(),j.sort().ptr))))},z={sort:()=>new dt(r.mk_real_sort(n)),const:e=>new A(a(r.mk_const(n,O(e),z.sort().ptr))),consts:e=>(typeof e=="string"&&(e=e.split(" ")),e.map(t=>z.const(t))),vector:(e,t)=>{const s=[];for(let h=0;h<t;h++)s.push(z.const(`${e}__${h}`));return s},fresh:(e="b")=>new A(r.mk_fresh_const(n,e,z.sort().ptr)),val:e=>(l(e)&&(e=`${e.numerator}/${e.denominator}`),new de(r.mk_numeral(n,e.toString(),z.sort().ptr)))},rt={sort(e){return(0,i.assert)(Number.isSafeInteger(e),"number of bits must be an integer"),new me(r.mk_bv_sort(n,e))},const(e,t){return new k(a(r.mk_const(n,O(e),At(t)?t.ptr:rt.sort(t).ptr)))},consts(e,t){return typeof e=="string"&&(e=e.split(" ")),e.map(s=>rt.const(s,t))},val(e,t){return e===!0?rt.val(1,t):e===!1?rt.val(0,t):new we(a(r.mk_numeral(n,e.toString(),At(t)?t.ptr:rt.sort(t).ptr)))}},pt={sort(...e){const t=e.length-1,s=e[t],h=e[0];if(t===1)return new It(r.mk_array_sort(n,h.ptr,s.ptr));const w=e.slice(0,t);return new It(r.mk_array_sort_n(n,w.map(g=>g.ptr),s.ptr))},const(e,...t){return new Rt(a(r.mk_const(n,O(e),pt.sort(...t).ptr)))},consts(e,...t){return typeof e=="string"&&(e=e.split(" ")),e.map(s=>pt.const(s,...t))},K(e,t){return new Rt(a(r.mk_const_array(n,e.ptr,t.ptr)))}},Me={sort(e){return pt.sort(e,U.sort())},const(e,t){return new G(a(r.mk_const(n,O(e),pt.sort(t,U.sort()).ptr)))},consts(e,t){return typeof e=="string"&&(e=e.split(" ")),e.map(s=>Me.const(s,t))},empty(e){return oe(e)},val(e,t){var s=oe(t);for(const h of e)s=ie(s,h);return s}},En=Object.assign(e=>new ar(x,e),{createDatatypes(...e){return ur(...e)}});function Yt(e,t,s){return et(e)&&ht(t)&&ht(s)?ze(e,t,s):((0,i.assert)(!et(e)&&!ht(t)&&!ht(s),"Mixed expressions and goals"),typeof e=="boolean"&&(e=U.val(e)),t=q(t),s=q(s),T(a(r.mk_ite(n,e.ptr,t.ast,s.ast))))}function An(...e){return(0,i.assert)(e.length>0,"Can't make Distinct ouf of nothing"),new b(a(r.mk_distinct(n,e.map(t=>(t=q(t),m(t),t.ast)))))}function Ce(e,t){return m(t),T(a(r.mk_const(n,O(e),t.ptr)))}function On(e,t){return m(t),typeof e=="string"&&(e=e.split(" ")),e.map(s=>Ce(s,t))}function xn(e,t="c"){return m(e),T(r.mk_fresh_const(e.ctx.ptr,t,e.ptr))}function Tn(e,t){return m(t),T(r.mk_bound(t.ctx.ptr,e,t.ptr))}function Ht(e,t){return e=q(e),t=q(t),m(e,t),new b(a(r.mk_implies(n,e.ptr,t.ptr)))}function Xt(e,t){return e=q(e),t=q(t),m(e,t),new b(a(r.mk_iff(n,e.ptr,t.ptr)))}function In(e,t){return e=q(e),t=q(t),m(e,t),e.eq(t)}function Jt(e,t){return e=q(e),t=q(t),m(e,t),new b(a(r.mk_xor(n,e.ptr,t.ptr)))}function Zt(e){return typeof e=="boolean"&&(e=q(e)),m(e),et(e)?new Tt(a(r.probe_not(n,e.ptr))):new b(a(r.mk_not(n,e.ptr)))}function te(...e){if(e.length==1&&e[0]instanceof x.AstVector&&(e=[...e[0].values()],(0,i.assert)((0,i.allSatisfy)(e,Et)??!0,"AstVector containing not bools")),(0,i.allSatisfy)(e,et)??!1)return Re(r.probe_and,e);{const s=e.map(q);return m(...s),new b(a(r.mk_and(n,s.map(h=>h.ptr))))}}function ee(...e){if(e.length==1&&e[0]instanceof x.AstVector&&(e=[...e[0].values()],(0,i.assert)((0,i.allSatisfy)(e,Et)??!0,"AstVector containing not bools")),(0,i.allSatisfy)(e,et)??!1)return Re(r.probe_or,e);{const s=e.map(q);return m(...s),new b(a(r.mk_or(n,s.map(h=>h.ptr))))}}function Rn(e,t,s){if(m(...e),e.length!==t.length)throw new Error("Number of arguments and coefficients must match");return new b(a(r.mk_pbeq(n,e.map(h=>h.ast),t,s)))}function Pn(e,t,s){if(m(...e),e.length!==t.length)throw new Error("Number of arguments and coefficients must match");return new b(a(r.mk_pbge(n,e.map(h=>h.ast),t,s)))}function qn(e,t,s){if(m(...e),e.length!==t.length)throw new Error("Number of arguments and coefficients must match");return new b(a(r.mk_pble(n,e.map(h=>h.ast),t,s)))}function Ln(e,t,s=1){if(!(0,i.allSatisfy)(e,V))throw new Error("Quantifier variables must be constants");return new ye(a(r.mk_quantifier_const_ex(n,!0,s,O(""),O(""),e.map(h=>h.ptr),[],[],t.ptr)))}function Nn(e,t,s=1){if(!(0,i.allSatisfy)(e,V))throw new Error("Quantifier variables must be constants");return new ye(a(r.mk_quantifier_const_ex(n,!1,s,O(""),O(""),e.map(h=>h.ptr),[],[],t.ptr)))}function Mn(e,t){if(!(0,i.allSatisfy)(e,V))throw new Error("Quantifier variables must be constants");return new cr(a(r.mk_lambda_const(n,e.map(s=>s.ptr),t.ptr)))}function re(e){return e=q(e),m(e),(0,i.assert)(Wt(e),"Int expression expected"),new A(a(r.mk_int2real(n,e.ast)))}function Cn(e){return L(e)||(e=z.val(e)),m(e),(0,i.assert)(Qt(e),"Real expression expected"),new A(a(r.mk_real2int(n,e.ast)))}function zn(e){return L(e)||(e=z.val(e)),m(e),(0,i.assert)(Qt(e),"Real expression expected"),new b(a(r.mk_is_int(n,e.ast)))}function Dn(e){return L(e)||(e=z.val(e)),e.pow("1/2")}function Un(e){return L(e)||(e=z.val(e)),e.pow("1/3")}function jn(e,t){return m(e),new A(a(r.mk_bv2int(n,e.ast,t)))}function $n(e,t){return lt(e)?(0,i.assert)(Wt(e),"parameter must be an integer"):((0,i.assert)(typeof e!="number"||Number.isSafeInteger(e),"parameter must not have decimal places"),e=j.val(e)),new k(a(r.mk_int2bv(n,t,e.ast)))}function Fn(...e){return m(...e),e.reduce((t,s)=>new k(a(r.mk_concat(n,t.ast,s.ast))))}function ze(e,t,s){return m(e,t,s),new ue(a(r.tactic_cond(n,e.ptr,t.ptr,s.ptr)))}function De(e,t){return new b(a(r.mk_lt(n,e.ast,e.sort.cast(t).ast)))}function Ue(e,t){return new b(a(r.mk_gt(n,e.ast,e.sort.cast(t).ast)))}function je(e,t){return new b(a(r.mk_le(n,e.ast,e.sort.cast(t).ast)))}function $e(e,t){return new b(a(r.mk_ge(n,e.ast,e.sort.cast(t).ast)))}function Fe(e,t){return new b(a(r.mk_bvult(n,e.ast,e.sort.cast(t).ast)))}function Ve(e,t){return new b(a(r.mk_bvugt(n,e.ast,e.sort.cast(t).ast)))}function Be(e,t){return new b(a(r.mk_bvule(n,e.ast,e.sort.cast(t).ast)))}function Ge(e,t){return new b(a(r.mk_bvuge(n,e.ast,e.sort.cast(t).ast)))}function We(e,t){return new b(a(r.mk_bvslt(n,e.ast,e.sort.cast(t).ast)))}function Qe(e,t){return new b(a(r.mk_bvsgt(n,e.ast,e.sort.cast(t).ast)))}function Ke(e,t){return new b(a(r.mk_bvsle(n,e.ast,e.sort.cast(t).ast)))}function Ye(e,t){return new b(a(r.mk_bvsge(n,e.ast,e.sort.cast(t).ast)))}function He(e,t,s){return new k(a(r.mk_extract(n,e,t,s.ast)))}function ne(e,...t){const s=t.map((w,g)=>e.domain_n(g).cast(w));if(s.length===1)return T(a(r.mk_select(n,e.ast,s[0].ast)));const h=s.map(w=>w.ast);return T(a(r.mk_select_n(n,e.ast,h)))}function se(e,...t){const s=t.map((w,g)=>g===t.length-1?e.range().cast(w):e.domain_n(g).cast(w));if(s.length<=1)throw new Error("Array store requires both index and value arguments");if(s.length===2)return T(a(r.mk_store(n,e.ast,s[0].ast,s[1].ast)));const h=s.slice(0,s.length-1).map(w=>w.ast);return T(a(r.mk_store_n(n,e.ast,h,s[s.length-1].ast)))}function Xe(...e){return new G(a(r.mk_set_union(n,e.map(t=>t.ast))))}function Je(...e){return new G(a(r.mk_set_intersect(n,e.map(t=>t.ast))))}function Ze(e,t){return new G(a(r.mk_set_difference(n,e.ast,t.ast)))}function tr(e,t){const s=j.sort().cast(t);return new b(a(r.mk_set_has_size(n,e.ast,s.ast)))}function ie(e,t){const s=e.elemSort().cast(t);return new G(a(r.mk_set_add(n,e.ast,s.ast)))}function er(e,t){const s=e.elemSort().cast(t);return new G(a(r.mk_set_del(n,e.ast,s.ast)))}function rr(e){return new G(a(r.mk_set_complement(n,e.ast)))}function oe(e){return new G(a(r.mk_empty_set(n,e.ptr)))}function Vn(e){return new G(a(r.mk_full_set(n,e.ptr)))}function nr(e,t){const s=t.elemSort().cast(e);return new b(a(r.mk_set_member(n,s.ast,t.ast)))}function sr(e,t){return new b(a(r.mk_set_subset(n,e.ast,t.ast)))}class Ot{constructor(t){this.ptr=t,this.ctx=x;const s=this.ast;r.inc_ref(n,s),d.register(this,()=>r.dec_ref(n,s),this)}get ast(){return this.ptr}id(){return r.get_ast_id(n,this.ast)}eqIdentity(t){return m(t),a(r.is_eq_ast(n,this.ast,t.ast))}neqIdentity(t){return m(t),!this.eqIdentity(t)}sexpr(){return r.ast_to_string(n,this.ast)}hash(){return r.get_ast_hash(n,this.ast)}toString(){return this.sexpr()}}class Bn{get ptr(){return Vt(this._ptr),this._ptr}constructor(t=r.mk_solver(n)){this.ctx=x;let s;typeof t=="string"?s=a(r.mk_solver_for_logic(n,O(t))):s=t,this._ptr=s,r.solver_inc_ref(n,s),d.register(this,()=>r.solver_dec_ref(n,s),this)}set(t,s){r.solver_set_params(n,this.ptr,Te(t,s))}push(){r.solver_push(n,this.ptr)}pop(t=1){r.solver_pop(n,this.ptr,t)}numScopes(){return r.solver_get_num_scopes(n,this.ptr)}reset(){r.solver_reset(n,this.ptr)}add(...t){kt(t).forEach(s=>{m(s),a(r.solver_assert(n,this.ptr,s.ast))})}addAndTrack(t,s){typeof s=="string"&&(s=U.const(s)),(0,i.assert)(V(s),"Provided expression that is not a constant to addAndTrack"),a(r.solver_assert_and_track(n,this.ptr,t.ast,s.ast))}assertions(){return new K(a(r.solver_get_assertions(n,this.ptr)))}async check(...t){const s=kt(t).map(w=>(m(w),w.ast)),h=await f.runExclusive(()=>a(r.solver_check_assumptions(n,this.ptr,s)));switch(h){case o.Z3_lbool.Z3_L_FALSE:return"unsat";case o.Z3_lbool.Z3_L_TRUE:return"sat";case o.Z3_lbool.Z3_L_UNDEF:return"unknown";default:(0,i.assertExhaustive)(h)}}model(){return new xt(a(r.solver_get_model(n,this.ptr)))}toString(){return a(r.solver_to_string(n,this.ptr))}fromString(t){r.solver_from_string(n,this.ptr,t),Bt()}release(){r.solver_dec_ref(n,this.ptr),this._ptr=null,d.unregister(this)}}class Gn{get ptr(){return Vt(this._ptr),this._ptr}constructor(t=r.mk_optimize(n)){this.ctx=x;let s;s=t,this._ptr=s,r.optimize_inc_ref(n,s),d.register(this,()=>r.optimize_dec_ref(n,s),this)}set(t,s){r.optimize_set_params(n,this.ptr,Te(t,s))}push(){r.optimize_push(n,this.ptr)}pop(){r.optimize_pop(n,this.ptr)}add(...t){kt(t).forEach(s=>{m(s),a(r.optimize_assert(n,this.ptr,s.ast))})}addSoft(t,s,h=""){l(s)&&(s=`${s.numerator}/${s.denominator}`),a(r.optimize_assert_soft(n,this.ptr,t.ast,s.toString(),O(h)))}addAndTrack(t,s){typeof s=="string"&&(s=U.const(s)),(0,i.assert)(V(s),"Provided expression that is not a constant to addAndTrack"),a(r.optimize_assert_and_track(n,this.ptr,t.ast,s.ast))}assertions(){return new K(a(r.optimize_get_assertions(n,this.ptr)))}maximize(t){a(r.optimize_maximize(n,this.ptr,t.ast))}minimize(t){a(r.optimize_minimize(n,this.ptr,t.ast))}async check(...t){const s=kt(t).map(w=>(m(w),w.ast)),h=await f.runExclusive(()=>a(r.optimize_check(n,this.ptr,s)));switch(h){case o.Z3_lbool.Z3_L_FALSE:return"unsat";case o.Z3_lbool.Z3_L_TRUE:return"sat";case o.Z3_lbool.Z3_L_UNDEF:return"unknown";default:(0,i.assertExhaustive)(h)}}model(){return new xt(a(r.optimize_get_model(n,this.ptr)))}toString(){return a(r.optimize_to_string(n,this.ptr))}fromString(t){r.optimize_from_string(n,this.ptr,t),Bt()}release(){r.optimize_dec_ref(n,this.ptr),this._ptr=null,d.unregister(this)}}class xt{get ptr(){return Vt(this._ptr),this._ptr}constructor(t=r.mk_model(n)){this.ctx=x,this._ptr=t,r.model_inc_ref(n,t),d.register(this,()=>r.model_dec_ref(n,t),this)}length(){return r.model_get_num_consts(n,this.ptr)+r.model_get_num_funcs(n,this.ptr)}[Symbol.iterator](){return this.values()}*entries(){const t=this.length();for(let s=0;s<t;s++)yield[s,this.get(s)]}*keys(){for(const[t]of this.entries())yield t}*values(){for(const[,t]of this.entries())yield t}decls(){return[...this.values()]}sexpr(){return a(r.model_to_string(n,this.ptr))}toString(){return this.sexpr()}eval(t,s=!1){m(t);const h=a(r.model_eval(n,this.ptr,t.ast,s));if(h===null)throw new c.Z3Error("Failed to evaluate expression in the model");return T(h)}get(t,s){if((0,i.assert)(s===void 0||typeof t=="number"),typeof t=="number"){const h=this.length();if(t>=h)throw new RangeError(`expected index ${t} to be less than length ${h}`);if(s===void 0){const g=a(r.model_get_num_consts(n,this.ptr));return t<g?new D(a(r.model_get_const_decl(n,this.ptr,t))):new D(a(r.model_get_func_decl(n,this.ptr,t-g)))}if(s<0&&(s+=h),s>=h)throw new RangeError(`expected index ${s} to be less than length ${h}`);const w=[];for(let g=t;g<s;g++)w.push(this.get(g));return w}else if(ut(t)||L(t)&&V(t)){const h=this.getInterp(t);return(0,i.assert)(h!==null),h}else if(St(t))return this.getUniverse(t);(0,i.assert)(!1,"Number, declaration or constant expected")}updateValue(t,s){if(m(t),m(s),L(t)&&(t=t.decl()),ut(t)&&t.arity()!==0&&qe(s)){const h=this.addFuncInterp(t,s.elseValue());for(let w=0;w<s.numEntries();w++){const g=s.entry(w),Pt=g.numArgs(),qt=ke.commonjsGlobal.Array(Pt).map((Y,M)=>g.argValue(M));h.addEntry(qt,g.value())}return}if(!ut(t)||t.arity()!==0)throw new c.Z3Error("Expecting 0-ary function or constant expression");if(!Pe(s))throw new c.Z3Error("Only func declarations can be assigned to func interpretations");a(r.add_const_interp(n,this.ptr,t.ptr,s.ast))}addFuncInterp(t,s){const h=a(r.add_func_interp(n,this.ptr,t.ptr,t.range().cast(s).ptr));return new ae(h)}getInterp(t){if((0,i.assert)(ut(t)||V(t),"Declaration expected"),V(t)&&((0,i.assert)(L(t)),t=t.decl()),(0,i.assert)(ut(t)),t.arity()===0){const s=a(r.model_get_const_interp(n,this.ptr,t.ptr));return s===null?null:T(s)}else{const s=a(r.model_get_func_interp(n,this.ptr,t.ptr));return s===null?null:new ae(s)}}getUniverse(t){return m(t),new K(a(r.model_get_sort_universe(n,this.ptr,t.ptr)))}release(){r.model_dec_ref(n,this.ptr),this._ptr=null,d.unregister(this)}}class Wn{constructor(t){this.ptr=t,this.ctx=x,r.func_entry_inc_ref(n,t),d.register(this,()=>r.func_entry_dec_ref(n,t),this)}numArgs(){return a(r.func_entry_get_num_args(n,this.ptr))}argValue(t){return T(a(r.func_entry_get_arg(n,this.ptr,t)))}value(){return T(a(r.func_entry_get_value(n,this.ptr)))}}class ae{constructor(t){this.ptr=t,this.ctx=x,r.func_interp_inc_ref(n,t),d.register(this,()=>r.func_interp_dec_ref(n,t),this)}elseValue(){return T(a(r.func_interp_get_else(n,this.ptr)))}numEntries(){return a(r.func_interp_get_num_entries(n,this.ptr))}arity(){return a(r.func_interp_get_arity(n,this.ptr))}entry(t){return new Wn(a(r.func_interp_get_entry(n,this.ptr,t)))}addEntry(t,s){const h=new K;for(const w of t)h.push(w);m(h),m(s),(0,i.assert)(this.arity()===h.length(),"Number of arguments in entry doesn't match function arity"),a(r.func_interp_add_entry(n,this.ptr,h.ptr,s.ptr))}}class B extends Ot{get ast(){return r.sort_to_ast(n,this.ptr)}kind(){return r.get_sort_kind(n,this.ptr)}subsort(t){return m(t),!1}cast(t){return m(t),(0,i.assert)(t.sort.eqIdentity(t.sort),"Sort mismatch"),t}name(){return bt(r.get_sort_name(n,this.ptr))}eqIdentity(t){return m(t),a(r.is_eq_sort(n,this.ptr,t.ptr))}neqIdentity(t){return!this.eqIdentity(t)}}class D extends Ot{get ast(){return r.func_decl_to_ast(n,this.ptr)}name(){return bt(r.get_decl_name(n,this.ptr))}arity(){return r.get_arity(n,this.ptr)}domain(t){return(0,i.assert)(t<this.arity(),"Index out of bounds"),Q(r.get_domain(n,this.ptr,t))}range(){return Q(r.get_range(n,this.ptr))}kind(){return r.get_decl_kind(n,this.ptr)}params(){const t=r.get_decl_num_parameters(n,this.ptr),s=[];for(let h=0;h<t;h++){const w=a(r.get_decl_parameter_kind(n,this.ptr,h));switch(w){case o.Z3_parameter_kind.Z3_PARAMETER_INT:s.push(a(r.get_decl_int_parameter(n,this.ptr,h)));break;case o.Z3_parameter_kind.Z3_PARAMETER_DOUBLE:s.push(a(r.get_decl_double_parameter(n,this.ptr,h)));break;case o.Z3_parameter_kind.Z3_PARAMETER_RATIONAL:s.push(a(r.get_decl_rational_parameter(n,this.ptr,h)));break;case o.Z3_parameter_kind.Z3_PARAMETER_SYMBOL:s.push(bt(a(r.get_decl_symbol_parameter(n,this.ptr,h))));break;case o.Z3_parameter_kind.Z3_PARAMETER_SORT:s.push(new B(a(r.get_decl_sort_parameter(n,this.ptr,h))));break;case o.Z3_parameter_kind.Z3_PARAMETER_AST:s.push(new F(a(r.get_decl_ast_parameter(n,this.ptr,h))));break;case o.Z3_parameter_kind.Z3_PARAMETER_FUNC_DECL:s.push(new D(a(r.get_decl_func_decl_parameter(n,this.ptr,h))));break;case o.Z3_parameter_kind.Z3_PARAMETER_INTERNAL:break;case o.Z3_parameter_kind.Z3_PARAMETER_ZSTRING:break;default:(0,i.assertExhaustive)(w)}}return s}call(...t){return(0,i.assert)(t.length===this.arity(),`Incorrect number of arguments to ${this}`),T(a(r.mk_app(n,this.ptr,t.map((s,h)=>this.domain(h).cast(s).ast))))}}class F extends Ot{get sort(){return Q(r.get_sort(n,this.ast))}eq(t){return new b(a(r.mk_eq(n,this.ast,q(t).ast)))}neq(t){return new b(a(r.mk_distinct(n,[this,t].map(s=>q(s).ast))))}name(){return this.decl().name()}params(){return this.decl().params()}decl(){return(0,i.assert)(tt(this),"Z3 application expected"),new D(a(r.get_app_decl(n,a(r.to_app(n,this.ast)))))}numArgs(){return(0,i.assert)(tt(this),"Z3 applicaiton expected"),a(r.get_app_num_args(n,a(r.to_app(n,this.ast))))}arg(t){return(0,i.assert)(tt(this),"Z3 applicaiton expected"),(0,i.assert)(t<this.numArgs(),`Invalid argument index - expected ${t} to be less than ${this.numArgs()}`),T(a(r.get_app_arg(n,a(r.to_app(n,this.ast)),t)))}children(){const t=this.numArgs();if(tt(this)){const s=[];for(let h=0;h<t;h++)s.push(this.arg(h));return s}return[]}}class Qn{constructor(t){this.ptr=t,this.ctx=x}}class ir extends B{cast(t){return typeof t=="boolean"&&(t=U.val(t)),(0,i.assert)(L(t),"true, false or Z3 Boolean expression expected."),(0,i.assert)(this.eqIdentity(t.sort),"Value cannot be converted into a Z3 Boolean value"),t}subsort(t){return m(t.ctx),t instanceof dt}}class b extends F{not(){return Zt(this)}and(t){return te(this,t)}or(t){return ee(this,t)}xor(t){return Jt(this,t)}implies(t){return Ht(this,t)}iff(t){return Xt(this,t)}}class Tt{constructor(t){this.ptr=t,this.ctx=x}}class ue{constructor(t){this.ctx=x;let s;typeof t=="string"?s=a(r.mk_tactic(n,t)):s=t,this.ptr=s,r.tactic_inc_ref(n,s),d.register(this,()=>r.tactic_dec_ref(n,s),this)}}class dt extends B{cast(t){const s=ct(this)?"IntSort":"RealSort";if(L(t)){const h=t.sort;if(lt(t)){if(this.eqIdentity(h))return t;if(ct(h)&&Kt(this))return re(t);(0,i.assert)(!1,"Can't cast Real to IntSort without loss")}else if(Et(t))return ct(this)?Yt(t,1,0):re(Yt(t,1,0));(0,i.assert)(!1,`Can't cast expression to ${s}`)}else{if(typeof t!="boolean")return ct(this)?((0,i.assert)(!l(t),"Can't cast fraction to IntSort"),j.val(t)):z.val(t);(0,i.assert)(!1,`Can't cast primitive to ${s}`)}}}function ce(e,...t){if(e instanceof k){if(t.length!==1)throw new Error("BitVec add only supports 2 arguments");return new k(a(r.mk_bvadd(n,e.ast,e.sort.cast(t[0]).ast)))}else return(0,i.assert)(e instanceof A),new A(a(r.mk_add(n,[e.ast].concat(t.map(s=>e.sort.cast(s).ast)))))}function _e(e,...t){if(e instanceof k){if(t.length!==1)throw new Error("BitVec sub only supports 2 arguments");return new k(a(r.mk_bvsub(n,e.ast,e.sort.cast(t[0]).ast)))}else return(0,i.assert)(e instanceof A),new A(a(r.mk_sub(n,[e.ast].concat(t.map(s=>e.sort.cast(s).ast)))))}function fe(e,...t){if(e instanceof k){if(t.length!==1)throw new Error("BitVec mul only supports 2 arguments");return new k(a(r.mk_bvmul(n,e.ast,e.sort.cast(t[0]).ast)))}else return(0,i.assert)(e instanceof A),new A(a(r.mk_mul(n,[e.ast].concat(t.map(s=>e.sort.cast(s).ast)))))}function le(e,t){return e instanceof k?new k(a(r.mk_bvsdiv(n,e.ast,e.sort.cast(t).ast))):((0,i.assert)(e instanceof A),new A(a(r.mk_div(n,e.ast,e.sort.cast(t).ast))))}function or(e,t){return new k(a(r.mk_bvudiv(n,e.ast,e.sort.cast(t).ast)))}function he(e){return e instanceof k?new k(a(r.mk_bvneg(n,e.ast))):((0,i.assert)(e instanceof A),new A(a(r.mk_unary_minus(n,e.ast))))}function pe(e,t){return e instanceof k?new k(a(r.mk_bvsrem(n,e.ast,e.sort.cast(t).ast))):((0,i.assert)(e instanceof A),new A(a(r.mk_mod(n,e.ast,e.sort.cast(t).ast))))}class A extends F{add(t){return ce(this,t)}mul(t){return fe(this,t)}sub(t){return _e(this,t)}pow(t){return new A(a(r.mk_power(n,this.ast,this.sort.cast(t).ast)))}div(t){return le(this,t)}mod(t){return pe(this,t)}neg(){return he(this)}le(t){return je(this,t)}lt(t){return De(this,t)}gt(t){return Ue(this,t)}ge(t){return $e(this,t)}}class mt extends A{value(){return BigInt(this.asString())}asString(){return r.get_numeral_string(n,this.ast)}asBinary(){return r.get_numeral_binary_string(n,this.ast)}}class de extends A{value(){return{numerator:this.numerator().value(),denominator:this.denominator().value()}}numerator(){return new mt(r.get_numerator(n,this.ast))}denominator(){return new mt(r.get_denominator(n,this.ast))}asNumber(){const{numerator:t,denominator:s}=this.value(),h=t/s;return Number(h)+Number(t-h*s)/Number(s)}asDecimal(t=Number.parseInt(xe("precision")??_.toString())){return r.get_numeral_decimal_string(n,this.ast,t)}asString(){return r.get_numeral_string(n,this.ast)}}class me extends B{size(){return r.get_bv_sort_size(n,this.ptr)}subsort(t){return At(t)&&this.size()<t.size()}cast(t){return L(t)?(m(t),t):((0,i.assert)(!l(t),"Can't convert rational to BitVec"),rt.val(t,this.size()))}}class k extends F{size(){return this.sort.size()}add(t){return ce(this,t)}mul(t){return fe(this,t)}sub(t){return _e(this,t)}sdiv(t){return le(this,t)}udiv(t){return or(this,t)}smod(t){return pe(this,t)}urem(t){return new k(a(r.mk_bvurem(n,this.ast,this.sort.cast(t).ast)))}srem(t){return new k(a(r.mk_bvsrem(n,this.ast,this.sort.cast(t).ast)))}neg(){return he(this)}or(t){return new k(a(r.mk_bvor(n,this.ast,this.sort.cast(t).ast)))}and(t){return new k(a(r.mk_bvand(n,this.ast,this.sort.cast(t).ast)))}nand(t){return new k(a(r.mk_bvnand(n,this.ast,this.sort.cast(t).ast)))}xor(t){return new k(a(r.mk_bvxor(n,this.ast,this.sort.cast(t).ast)))}xnor(t){return new k(a(r.mk_bvxnor(n,this.ast,this.sort.cast(t).ast)))}shr(t){return new k(a(r.mk_bvashr(n,this.ast,this.sort.cast(t).ast)))}lshr(t){return new k(a(r.mk_bvlshr(n,this.ast,this.sort.cast(t).ast)))}shl(t){return new k(a(r.mk_bvshl(n,this.ast,this.sort.cast(t).ast)))}rotateRight(t){return new k(a(r.mk_ext_rotate_right(n,this.ast,this.sort.cast(t).ast)))}rotateLeft(t){return new k(a(r.mk_ext_rotate_left(n,this.ast,this.sort.cast(t).ast)))}not(){return new k(a(r.mk_bvnot(n,this.ast)))}extract(t,s){return He(t,s,this)}signExt(t){return new k(a(r.mk_sign_ext(n,t,this.ast)))}zeroExt(t){return new k(a(r.mk_zero_ext(n,t,this.ast)))}repeat(t){return new k(a(r.mk_repeat(n,t,this.ast)))}sle(t){return Ke(this,t)}ule(t){return Be(this,t)}slt(t){return We(this,t)}ult(t){return Fe(this,t)}sge(t){return Ye(this,t)}uge(t){return Ge(this,t)}sgt(t){return Qe(this,t)}ugt(t){return Ve(this,t)}redAnd(){return new k(a(r.mk_bvredand(n,this.ast)))}redOr(){return new k(a(r.mk_bvredor(n,this.ast)))}addNoOverflow(t,s){return new b(a(r.mk_bvadd_no_overflow(n,this.ast,this.sort.cast(t).ast,s)))}addNoUnderflow(t){return new b(a(r.mk_bvadd_no_underflow(n,this.ast,this.sort.cast(t).ast)))}subNoOverflow(t){return new b(a(r.mk_bvsub_no_overflow(n,this.ast,this.sort.cast(t).ast)))}subNoUndeflow(t,s){return new b(a(r.mk_bvsub_no_underflow(n,this.ast,this.sort.cast(t).ast,s)))}sdivNoOverflow(t){return new b(a(r.mk_bvsdiv_no_overflow(n,this.ast,this.sort.cast(t).ast)))}mulNoOverflow(t,s){return new b(a(r.mk_bvmul_no_overflow(n,this.ast,this.sort.cast(t).ast,s)))}mulNoUndeflow(t){return new b(a(r.mk_bvmul_no_underflow(n,this.ast,this.sort.cast(t).ast)))}negNoOverflow(){return new b(a(r.mk_bvneg_no_overflow(n,this.ast)))}}class we ex