js-randomness-predictor
Version:
Predict Math.random output in Node, Deno, Bun, Chrome, Firefox, and Safari
1 lines • 59 kB
JavaScript
"use strict";const Xn=require("./index-C9ON69fg.cjs");function Jn(a,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 a)){const f=Object.getOwnPropertyDescriptor(i,_);f&&Object.defineProperty(a,_,f.get?f:{enumerable:!0,get:()=>i[_]})}}}return Object.freeze(Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}))}var Zn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ts(a){if(Object.prototype.hasOwnProperty.call(a,"__esModule"))return a;var o=a.default;if(typeof o=="function"){var c=function i(){var _=!1;try{_=this instanceof i}catch{}return _?Reflect.construct(o,arguments,this.constructor):o.apply(this,arguments)};c.prototype=o.prototype}else c={};return Object.defineProperty(c,"__esModule",{value:!0}),Object.keys(a).forEach(function(i){var _=Object.getOwnPropertyDescriptor(a,i);Object.defineProperty(c,i,_.get?_:{enumerable:!0,get:function(){return a[i]}})}),c}var ot={},Mt={},be={},ke=function(a,o){return ke=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[_])},ke(a,o)};function vr(a,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");ke(a,o);function c(){this.constructor=a}a.prototype=o===null?Object.create(o):(c.prototype=o.prototype,new c)}var zt=function(){return zt=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},zt.apply(this,arguments)};function br(a,o){var c={};for(var i in a)Object.prototype.hasOwnProperty.call(a,i)&&o.indexOf(i)<0&&(c[i]=a[i]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var _=0,i=Object.getOwnPropertySymbols(a);_<i.length;_++)o.indexOf(i[_])<0&&Object.prototype.propertyIsEnumerable.call(a,i[_])&&(c[i[_]]=a[i[_]]);return c}function kr(a,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(a,o,c,i);else for(var p=a.length-1;p>=0;p--)(l=a[p])&&(f=(_<3?l(f):_>3?l(o,c,f):l(o,c))||f);return _>3&&f&&Object.defineProperty(o,c,f),f}function Sr(a,o){return function(c,i){o(c,i,a)}}function Er(a,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&&a?i.static?a:a.prototype:null,v=o||(d?Object.getOwnPropertyDescriptor(d,i.name):{}),S,E=!1,y=c.length-1;y>=0;y--){var I={};for(var P in i)I[P]=P==="access"?{}:i[P];for(var P in i.access)I.access[P]=i.access[P];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(a,o,c){for(var i=arguments.length>2,_=0;_<o.length;_++)c=i?o[_].call(a,c):o[_].call(a);return i?c:void 0}function Ar(a){return typeof a=="symbol"?a:"".concat(a)}function xr(a,o,c){return typeof o=="symbol"&&(o=o.description?"[".concat(o.description,"]"):""),Object.defineProperty(a,"name",{configurable:!0,value:c?"".concat(c," ",o):o})}function Tr(a,o){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,o)}function Ir(a,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(a,o||[])).next())})}function Pr(a,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(a,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(a,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(a,i,_)}):(function(a,o,c,i){i===void 0&&(i=c),a[i]=o[c]});function Rr(a,o){for(var c in a)c!=="default"&&!Object.prototype.hasOwnProperty.call(o,c)&&jt(o,a,c)}function $t(a){var o=typeof Symbol=="function"&&Symbol.iterator,c=o&&a[o],i=0;if(c)return c.call(a);if(a&&typeof a.length=="number")return{next:function(){return a&&i>=a.length&&(a=void 0),{value:a&&a[i++],done:!a}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ee(a,o){var c=typeof Symbol=="function"&&a[Symbol.iterator];if(!c)return a;var i=c.call(a),_,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 qr(){for(var a=[],o=0;o<arguments.length;o++)a=a.concat(Ee(arguments[o]));return a}function Lr(){for(var a=0,o=0,c=arguments.length;o<c;o++)a+=arguments[o].length;for(var i=Array(a),_=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 Nr(a,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 a.concat(f||Array.prototype.slice.call(o))}function ft(a){return this instanceof ft?(this.v=a,this):new ft(a)}function Mr(a,o,c){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=c.apply(a,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(P){return new Promise(function(N,C){f.push([y,P,N,C])>1||r(y,P)})},I&&(_[y]=I(_[y])))}function r(y,I){try{d(i[y](I))}catch(P){E(f[0][3],P)}}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 Cr(a){var o,c;return o={},i("next"),i("throw",function(_){throw _}),i("return"),o[Symbol.iterator]=function(){return this},o;function i(_,f){o[_]=a[_]?function(l){return(c=!c)?{value:ft(a[_](l)),done:!1}:f?f(l):l}:f}}function Dr(a){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=a[Symbol.asyncIterator],c;return o?o.call(a):(a=typeof $t=="function"?$t(a):a[Symbol.iterator](),c={},i("next"),i("throw"),i("return"),c[Symbol.asyncIterator]=function(){return this},c);function i(f){c[f]=a[f]&&function(l){return new Promise(function(p,r){l=a[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 zr(a,o){return Object.defineProperty?Object.defineProperty(a,"raw",{value:o}):a.raw=o,a}var es=Object.create?(function(a,o){Object.defineProperty(a,"default",{enumerable:!0,value:o})}):function(a,o){a.default=o},Se=function(a){return Se=Object.getOwnPropertyNames||function(o){var c=[];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(c[c.length]=i);return c},Se(a)};function $r(a){if(a&&a.__esModule)return a;var o={};if(a!=null)for(var c=Se(a),i=0;i<c.length;i++)c[i]!=="default"&&jt(o,a,c[i]);return es(o,a),o}function jr(a){return a&&a.__esModule?a:{default:a}}function Ur(a,o,c,i){if(c==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?a!==o||!i:!o.has(a))throw new TypeError("Cannot read private member from an object whose class did not declare it");return c==="m"?i:c==="a"?i.call(a):i?i.value:o.get(a)}function Fr(a,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"?a!==o||!_:!o.has(a))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?_.call(a,c):_?_.value=c:o.set(a,c),c}function Vr(a,o){if(o===null||typeof o!="object"&&typeof o!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof a=="function"?o===a:a.has(o)}function Br(a,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)}}),a.stack.push({value:o,dispose:i,async:c})}else c&&a.stack.push({async:!0});return o}var rs=typeof SuppressedError=="function"?SuppressedError:function(a,o,c){var i=new Error(c);return i.name="SuppressedError",i.error=a,i.suppressed=o,i};function Gr(a){function o(f){a.error=a.hasError?new rs(f,a.error,"An error was suppressed during disposal."):f,a.hasError=!0}var c,i=0;function _(){for(;c=a.stack.pop();)try{if(!c.async&&i===1)return i=0,a.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 a.hasError?Promise.reject(a.error):Promise.resolve();if(a.hasError)throw a.error}return _()}function Wr(a,o){return typeof a=="string"&&/^\.\.?\//.test(a)?a.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(c,i,_,f,l){return i?o?".jsx":".js":_&&(!f||!l)?c:_+f+"."+l.toLowerCase()+"js"}):a}const ns={__extends:vr,__assign:zt,__rest:br,__decorate:kr,__param:Sr,__esDecorate:Er,__runInitializers:Or,__propKey:Ar,__setFunctionName:xr,__metadata:Tr,__awaiter:Ir,__generator:Pr,__createBinding:jt,__exportStar:Rr,__values:$t,__read:Ee,__spread:qr,__spreadArrays:Lr,__spreadArray:Nr,__await:ft,__asyncGenerator:Mr,__asyncDelegator:Cr,__asyncValues:Dr,__makeTemplateObject:zr,__importStar:$r,__importDefault:jr,__classPrivateFieldGet:Ur,__classPrivateFieldSet:Fr,__classPrivateFieldIn:Vr,__addDisposableResource:Br,__disposeResources:Gr,__rewriteRelativeImportExtension:Wr},ss=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource:Br,get __assign(){return zt},__asyncDelegator:Cr,__asyncGenerator:Mr,__asyncValues:Dr,__await:ft,__awaiter:Ir,__classPrivateFieldGet:Ur,__classPrivateFieldIn:Vr,__classPrivateFieldSet:Fr,__createBinding:jt,__decorate:kr,__disposeResources:Gr,__esDecorate:Er,__exportStar:Rr,__extends:vr,__generator:Pr,__importDefault:jr,__importStar:$r,__makeTemplateObject:zr,__metadata:Tr,__param:Sr,__propKey:Ar,__read:Ee,__rest:br,__rewriteRelativeImportExtension:Wr,__runInitializers:Or,__setFunctionName:xr,__spread:qr,__spreadArray:Nr,__spreadArrays:Lr,__values:$t,default:ns},Symbol.toStringTag,{value:"Module"})),Ut=ts(ss);var Ct={},Dt={},W={},_r;function Ft(){return _r||(_r=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 fr;function Qr(){if(fr)return Dt;fr=1,Object.defineProperty(Dt,"__esModule",{value:!0});var a=Ut,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 a.__awaiter(this,arguments,void 0,function(p,r,d){var v,S,E;return r===void 0&&(r=1),d===void 0&&(d=0),a.__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 Dt.default=c,Dt}var lr;function is(){if(lr)return Ct;lr=1,Object.defineProperty(Ct,"__esModule",{value:!0});var a=Ut,o=Qr(),c=(function(){function i(_){this._semaphore=new o.default(1,_)}return i.prototype.acquire=function(){return a.__awaiter(this,arguments,void 0,function(_){var f,l;return _===void 0&&(_=0),a.__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={},hr;function Kr(){if(hr)return yt;hr=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.withTimeout=void 0;var a=Ut,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 a.__awaiter(p,void 0,void 0,function(){var y,I,P,N,C;return a.__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 P=X.sent(),y?(N=Array.isArray(P)?P[1]:P,N()):(clearTimeout(I),S(P)),[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 a.__awaiter(this,void 0,void 0,function(){var S,E;return a.__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={},pr;function os(){if(pr)return vt;pr=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.tryAcquire=void 0;var a=Ft(),o=Kr();function c(i,_){return _===void 0&&(_=a.E_ALREADY_LOCKED),(0,o.withTimeout)(i,0,_)}return vt.tryAcquire=c,vt}var dr;function as(){return dr||(dr=1,(function(a){Object.defineProperty(a,"__esModule",{value:!0}),a.tryAcquire=a.withTimeout=a.Semaphore=a.Mutex=void 0;var o=Ut,c=is();Object.defineProperty(a,"Mutex",{enumerable:!0,get:function(){return c.default}});var i=Qr();Object.defineProperty(a,"Semaphore",{enumerable:!0,get:function(){return i.default}});var _=Kr();Object.defineProperty(a,"withTimeout",{enumerable:!0,get:function(){return _.withTimeout}});var f=os();Object.defineProperty(a,"tryAcquire",{enumerable:!0,get:function(){return f.tryAcquire}}),o.__exportStar(Ft(),a)})(be)),be}var at={},mr;function Oe(){if(mr)return at;mr=1,Object.defineProperty(at,"__esModule",{value:!0}),at.Z3AssertionError=at.Z3Error=void 0;class a extends Error{}at.Z3Error=a;class o extends a{}return at.Z3AssertionError=o,at}var _t={},gr;function us(){if(gr)return _t;gr=1,Object.defineProperty(_t,"__esModule",{value:!0}),_t.assertExhaustive=o,_t.assert=c,_t.allSatisfy=i;const a=Oe();function o(_){throw new Error("Unexpected code execution detected, should be caught at compile time")}function c(_,f){if(!_)throw new a.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 wr;function cs(){if(wr)return Mt;wr=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.createApi=p;const a=as(),o=Xn.requireLowLevel(),c=Oe(),i=us(),_=17,f=new a.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(R=>R());function v(R){r.enable_trace(R)}function S(R){r.disable_trace(R)}function E(){return r.get_version()}function y(){const{major:R,minor:J,build_number:Z}=r.get_version();return`${R}.${J}.${Z}`}function I(){return r.get_full_version()}function P(R){return r.open_log(R)}function N(R){r.append_log(R)}function C(R,J){typeof R=="string"?r.global_param_set(R,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(R).forEach(([Z,n])=>C(Z,n)))}function X(){r.global_param_reset_all()}function Ae(R){return r.global_param_get(R)}function Yr(R,J){const Z=r.mk_config();J!=null&&Object.entries(J).forEach(([e,t])=>u(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 u(e){return Bt(),e}function A(e){return u(typeof e=="number"?r.mk_int_symbol(n,e):r.mk_string_symbol(n,e))}function bt(e){const t=u(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 xe(e,t){const s=r.mk_params(n);return r.params_inc_ref(n,s),typeof t=="boolean"?r.params_set_bool(n,s,A(e),t):typeof t=="number"?Number.isInteger(t)?u(r.params_set_uint(n,s,A(e),t)):u(r.params_set_double(n,s,A(e),t)):typeof t=="string"&&u(r.params_set_symbol(n,s,A(e),A(t))),s}function Gt(e){switch(u(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 z(e);default:return T(e)}}function Q(e){switch(u(r.get_sort_kind(n,e))){case o.Z3_sort_kind.Z3_BOOL_SORT:return new sr(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=u(r.get_ast_kind(n,e));if(t===o.Z3_ast_kind.Z3_QUANTIFIER_AST)return r.is_lambda(n,e)?new ur(e):new ye(e);switch(u(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 O(e);case o.Z3_sort_kind.Z3_REAL_SORT:return t===o.Z3_ast_kind.Z3_NUMERAL_AST?new de(e):new O(e);case o.Z3_sort_kind.Z3_BV_SORT:return t===o.Z3_ast_kind.Z3_NUMERAL_AST?new ge(e):new k(e);case o.Z3_sort_kind.Z3_ARRAY_SORT:return new Pt(e);default:return new F(e)}}function kt(e){const t=[];for(const s of e)Le(s)?t.push(...s.values()):t.push(s);return t}function Te(e){return et(e)?e:new Tt(e)}function Ie(e,t){(0,i.assert)(t.length>0,"At least one argument expected");let s=Te(t[0]);for(let h=1;h<t.length;h++)s=new Tt(u(e(n,s.ptr,Te(t[h]).ptr)));return s}function Hr(){u(r.interrupt(n))}function Xr(e){const t=e instanceof xt;return t&&m(e),t}function Pe(e){const t=e instanceof At;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 z;return t&&m(e),t}function Re(e){const t=e instanceof ae;return t&&m(e),t}function tt(e){if(!L(e))return!1;const t=u(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 qe(e){return L(e)&&u(r.get_ast_kind(n,e.ast))===o.Z3_ast_kind.Z3_VAR_AST}function U(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 Jr(e){return U(e,o.Z3_decl_kind.Z3_OP_TRUE)}function Zr(e){return U(e,o.Z3_decl_kind.Z3_OP_FALSE)}function tn(e){return U(e,o.Z3_decl_kind.Z3_OP_AND)}function en(e){return U(e,o.Z3_decl_kind.Z3_OP_OR)}function rn(e){return U(e,o.Z3_decl_kind.Z3_OP_IMPLIES)}function nn(e){return U(e,o.Z3_decl_kind.Z3_OP_NOT)}function sn(e){return U(e,o.Z3_decl_kind.Z3_OP_EQ)}function on(e){return U(e,o.Z3_decl_kind.Z3_OP_DISTINCT)}function an(e){const t=e instanceof we;return t&&m(e),t}function lt(e){const t=e instanceof O;return t&&m(e),t}function un(e){const t=e instanceof dt;return t&&m(e),t}function Wt(e){return lt(e)&&ct(e.sort)}function cn(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 _n(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 Ot(e){const t=e instanceof me;return t&&m(e),t}function fn(e){const t=e instanceof k;return t&&m(e),t}function ln(e){const t=e instanceof ge;return t&&m(e),t}function hn(e){const t=e instanceof It;return t&&m(e),t}function pn(e){const t=e instanceof Pt;return t&&m(e),t}function dn(e){return U(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 Le(e){const t=e instanceof K;return t&&m(e),t}function mn(e,t){return e.eqIdentity(t)}function gn(e){return(0,i.assert)(qe(e),"Z3 bound variable expected"),r.get_index_value(n,e.ast)}function q(e){if(typeof e=="boolean")return $.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):D.val(e)}else{if(l(e))return D.val(e);if(typeof e=="bigint")return j.val(e);if(L(e))return e}(0,i.assert)(!1)}async function wn(...e){const t=new x.Solver;t.add(...e);const s=await t.check();return s==="sat"?t.model():s}async function yn(e){const t=await r.simplify(n,e.ast);return T(u(t))}const vn={declare:e=>new B(r.mk_uninterpreted_sort(n,A(e)))},bn={declare:(e,...t)=>{const s=t.length-1,h=t[s];m(h);const g=[];for(let w=0;w<s;w++)m(t[w]),g.push(t[w].ptr);return new z(r.mk_func_decl(n,A(e),g,h.ptr))},fresh:(...e)=>{const t=e.length-1,s=e[t];m(s);const h=[];for(let g=0;g<t;g++)m(e[g]),h.push(e[g].ptr);return new z(r.mk_fresh_func_decl(n,"f",h,s.ptr))}},kn={declare:(e,...t)=>{const s=t.length-1,h=t[s];m(h);const g=[];for(let w=0;w<s;w++)m(t[w]),g.push(t[w].ptr);return new z(r.mk_rec_func_decl(n,A(e),g,h.ptr))},addDefinition:(e,t,s)=>{m(e,...t,s),u(r.add_rec_def(n,e.ptr,t.map(h=>h.ast),s.ast))}},$={sort:()=>new sr(r.mk_bool_sort(n)),const:e=>new b(r.mk_const(n,A(e),$.sort().ptr)),consts:e=>(typeof e=="string"&&(e=e.split(" ")),e.map(t=>$.const(t))),vector:(e,t)=>{const s=[];for(let h=0;h<t;h++)s.push($.const(`${e}__${h}`));return s},fresh:(e="b")=>new b(r.mk_fresh_const(n,e,$.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 O(r.mk_const(n,A(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 O(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(u(r.mk_numeral(n,e.toString(),j.sort().ptr))))},D={sort:()=>new dt(r.mk_real_sort(n)),const:e=>new O(u(r.mk_const(n,A(e),D.sort().ptr))),consts:e=>(typeof e=="string"&&(e=e.split(" ")),e.map(t=>D.const(t))),vector:(e,t)=>{const s=[];for(let h=0;h<t;h++)s.push(D.const(`${e}__${h}`));return s},fresh:(e="b")=>new O(r.mk_fresh_const(n,e,D.sort().ptr)),val:e=>(l(e)&&(e=`${e.numerator}/${e.denominator}`),new de(r.mk_numeral(n,e.toString(),D.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(u(r.mk_const(n,A(e),Ot(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 ge(u(r.mk_numeral(n,e.toString(),Ot(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 g=e.slice(0,t);return new It(r.mk_array_sort_n(n,g.map(w=>w.ptr),s.ptr))},const(e,...t){return new Pt(u(r.mk_const(n,A(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 Pt(u(r.mk_const_array(n,e.ptr,t.ptr)))}},Ne={sort(e){return pt.sort(e,$.sort())},const(e,t){return new G(u(r.mk_const(n,A(e),pt.sort(t,$.sort()).ptr)))},consts(e,t){return typeof e=="string"&&(e=e.split(" ")),e.map(s=>Ne.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}},Sn=Object.assign(e=>new or(x,e),{createDatatypes(...e){return ar(...e)}});function Yt(e,t,s){return et(e)&&ht(t)&&ht(s)?Ce(e,t,s):((0,i.assert)(!et(e)&&!ht(t)&&!ht(s),"Mixed expressions and goals"),typeof e=="boolean"&&(e=$.val(e)),t=q(t),s=q(s),T(u(r.mk_ite(n,e.ptr,t.ast,s.ast))))}function En(...e){return(0,i.assert)(e.length>0,"Can't make Distinct ouf of nothing"),new b(u(r.mk_distinct(n,e.map(t=>(t=q(t),m(t),t.ast)))))}function Me(e,t){return m(t),T(u(r.mk_const(n,A(e),t.ptr)))}function On(e,t){return m(t),typeof e=="string"&&(e=e.split(" ")),e.map(s=>Me(s,t))}function An(e,t="c"){return m(e),T(r.mk_fresh_const(e.ctx.ptr,t,e.ptr))}function xn(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(u(r.mk_implies(n,e.ptr,t.ptr)))}function Xt(e,t){return e=q(e),t=q(t),m(e,t),new b(u(r.mk_iff(n,e.ptr,t.ptr)))}function Tn(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(u(r.mk_xor(n,e.ptr,t.ptr)))}function Zt(e){return typeof e=="boolean"&&(e=q(e)),m(e),et(e)?new Tt(u(r.probe_not(n,e.ptr))):new b(u(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 Ie(r.probe_and,e);{const s=e.map(q);return m(...s),new b(u(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 Ie(r.probe_or,e);{const s=e.map(q);return m(...s),new b(u(r.mk_or(n,s.map(h=>h.ptr))))}}function In(e,t,s){if(m(...e),e.length!==t.length)throw new Error("Number of arguments and coefficients must match");return new b(u(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(u(r.mk_pbge(n,e.map(h=>h.ast),t,s)))}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(u(r.mk_pble(n,e.map(h=>h.ast),t,s)))}function qn(e,t,s=1){if(!(0,i.allSatisfy)(e,V))throw new Error("Quantifier variables must be constants");return new ye(u(r.mk_quantifier_const_ex(n,!0,s,A(""),A(""),e.map(h=>h.ptr),[],[],t.ptr)))}function Ln(e,t,s=1){if(!(0,i.allSatisfy)(e,V))throw new Error("Quantifier variables must be constants");return new ye(u(r.mk_quantifier_const_ex(n,!1,s,A(""),A(""),e.map(h=>h.ptr),[],[],t.ptr)))}function Nn(e,t){if(!(0,i.allSatisfy)(e,V))throw new Error("Quantifier variables must be constants");return new ur(u(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 O(u(r.mk_int2real(n,e.ast)))}function Mn(e){return L(e)||(e=D.val(e)),m(e),(0,i.assert)(Qt(e),"Real expression expected"),new O(u(r.mk_real2int(n,e.ast)))}function Cn(e){return L(e)||(e=D.val(e)),m(e),(0,i.assert)(Qt(e),"Real expression expected"),new b(u(r.mk_is_int(n,e.ast)))}function Dn(e){return L(e)||(e=D.val(e)),e.pow("1/2")}function zn(e){return L(e)||(e=D.val(e)),e.pow("1/3")}function $n(e,t){return m(e),new O(u(r.mk_bv2int(n,e.ast,t)))}function jn(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(u(r.mk_int2bv(n,t,e.ast)))}function Un(...e){return m(...e),e.reduce((t,s)=>new k(u(r.mk_concat(n,t.ast,s.ast))))}function Ce(e,t,s){return m(e,t,s),new ue(u(r.tactic_cond(n,e.ptr,t.ptr,s.ptr)))}function De(e,t){return new b(u(r.mk_lt(n,e.ast,e.sort.cast(t).ast)))}function ze(e,t){return new b(u(r.mk_gt(n,e.ast,e.sort.cast(t).ast)))}function $e(e,t){return new b(u(r.mk_le(n,e.ast,e.sort.cast(t).ast)))}function je(e,t){return new b(u(r.mk_ge(n,e.ast,e.sort.cast(t).ast)))}function Ue(e,t){return new b(u(r.mk_bvult(n,e.ast,e.sort.cast(t).ast)))}function Fe(e,t){return new b(u(r.mk_bvugt(n,e.ast,e.sort.cast(t).ast)))}function Ve(e,t){return new b(u(r.mk_bvule(n,e.ast,e.sort.cast(t).ast)))}function Be(e,t){return new b(u(r.mk_bvuge(n,e.ast,e.sort.cast(t).ast)))}function Ge(e,t){return new b(u(r.mk_bvslt(n,e.ast,e.sort.cast(t).ast)))}function We(e,t){return new b(u(r.mk_bvsgt(n,e.ast,e.sort.cast(t).ast)))}function Qe(e,t){return new b(u(r.mk_bvsle(n,e.ast,e.sort.cast(t).ast)))}function Ke(e,t){return new b(u(r.mk_bvsge(n,e.ast,e.sort.cast(t).ast)))}function Ye(e,t,s){return new k(u(r.mk_extract(n,e,t,s.ast)))}function ne(e,...t){const s=t.map((g,w)=>e.domain_n(w).cast(g));if(s.length===1)return T(u(r.mk_select(n,e.ast,s[0].ast)));const h=s.map(g=>g.ast);return T(u(r.mk_select_n(n,e.ast,h)))}function se(e,...t){const s=t.map((g,w)=>w===t.length-1?e.range().cast(g):e.domain_n(w).cast(g));if(s.length<=1)throw new Error("Array store requires both index and value arguments");if(s.length===2)return T(u(r.mk_store(n,e.ast,s[0].ast,s[1].ast)));const h=s.slice(0,s.length-1).map(g=>g.ast);return T(u(r.mk_store_n(n,e.ast,h,s[s.length-1].ast)))}function He(...e){return new G(u(r.mk_set_union(n,e.map(t=>t.ast))))}function Xe(...e){return new G(u(r.mk_set_intersect(n,e.map(t=>t.ast))))}function Je(e,t){return new G(u(r.mk_set_difference(n,e.ast,t.ast)))}function Ze(e,t){const s=j.sort().cast(t);return new b(u(r.mk_set_has_size(n,e.ast,s.ast)))}function ie(e,t){const s=e.elemSort().cast(t);return new G(u(r.mk_set_add(n,e.ast,s.ast)))}function tr(e,t){const s=e.elemSort().cast(t);return new G(u(r.mk_set_del(n,e.ast,s.ast)))}function er(e){return new G(u(r.mk_set_complement(n,e.ast)))}function oe(e){return new G(u(r.mk_empty_set(n,e.ptr)))}function Fn(e){return new G(u(r.mk_full_set(n,e.ptr)))}function rr(e,t){const s=t.elemSort().cast(e);return new b(u(r.mk_set_member(n,s.ast,t.ast)))}function nr(e,t){return new b(u(r.mk_set_subset(n,e.ast,t.ast)))}class At{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),u(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 Vn{get ptr(){return Vt(this._ptr),this._ptr}constructor(t=r.mk_solver(n)){this.ctx=x;let s;typeof t=="string"?s=u(r.mk_solver_for_logic(n,A(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,xe(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),u(r.solver_assert(n,this.ptr,s.ast))})}addAndTrack(t,s){typeof s=="string"&&(s=$.const(s)),(0,i.assert)(V(s),"Provided expression that is not a constant to addAndTrack"),u(r.solver_assert_and_track(n,this.ptr,t.ast,s.ast))}assertions(){return new K(u(r.solver_get_assertions(n,this.ptr)))}async check(...t){const s=kt(t).map(g=>(m(g),g.ast)),h=await f.runExclusive(()=>u(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(u(r.solver_get_model(n,this.ptr)))}toString(){return u(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 Bn{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,xe(t,s))}push(){r.optimize_push(n,this.ptr)}pop(){r.optimize_pop(n,this.ptr)}add(...t){kt(t).forEach(s=>{m(s),u(r.optimize_assert(n,this.ptr,s.ast))})}addSoft(t,s,h=""){l(s)&&(s=`${s.numerator}/${s.denominator}`),u(r.optimize_assert_soft(n,this.ptr,t.ast,s.toString(),A(h)))}addAndTrack(t,s){typeof s=="string"&&(s=$.const(s)),(0,i.assert)(V(s),"Provided expression that is not a constant to addAndTrack"),u(r.optimize_assert_and_track(n,this.ptr,t.ast,s.ast))}assertions(){return new K(u(r.optimize_get_assertions(n,this.ptr)))}maximize(t){u(r.optimize_maximize(n,this.ptr,t.ast))}minimize(t){u(r.optimize_minimize(n,this.ptr,t.ast))}async check(...t){const s=kt(t).map(g=>(m(g),g.ast)),h=await f.runExclusive(()=>u(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(u(r.optimize_get_model(n,this.ptr)))}toString(){return u(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 u(r.model_to_string(n,this.ptr))}toString(){return this.sexpr()}eval(t,s=!1){m(t);const h=u(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 w=u(r.model_get_num_consts(n,this.ptr));return t<w?new z(u(r.model_get_const_decl(n,this.ptr,t))):new z(u(r.model_get_func_decl(n,this.ptr,t-w)))}if(s<0&&(s+=h),s>=h)throw new RangeError(`expected index ${s} to be less than length ${h}`);const g=[];for(let w=t;w<s;w++)g.push(this.get(w));return g}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&&Re(s)){const h=this.addFuncInterp(t,s.elseValue());for(let g=0;g<s.numEntries();g++){const w=s.entry(g),Rt=w.numArgs(),qt=Zn.Array(Rt).map((Y,M)=>w.argValue(M));h.addEntry(qt,w.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");u(r.add_const_interp(n,this.ptr,t.ptr,s.ast))}addFuncInterp(t,s){const h=u(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=u(r.model_get_const_interp(n,this.ptr,t.ptr));return s===null?null:T(s)}else{const s=u(r.model_get_func_interp(n,this.ptr,t.ptr));return s===null?null:new ae(s)}}getUniverse(t){return m(t),new K(u(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 Gn{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 u(r.func_entry_get_num_args(n,this.ptr))}argValue(t){return T(u(r.func_entry_get_arg(n,this.ptr,t)))}value(){return T(u(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(u(r.func_interp_get_else(n,this.ptr)))}numEntries(){return u(r.func_interp_get_num_entries(n,this.ptr))}arity(){return u(r.func_interp_get_arity(n,this.ptr))}entry(t){return new Gn(u(r.func_interp_get_entry(n,this.ptr,t)))}addEntry(t,s){const h=new K;for(const g of t)h.push(g);m(h),m(s),(0,i.assert)(this.arity()===h.length(),"Number of arguments in entry doesn't match function arity"),u(r.func_interp_add_entry(n,this.ptr,h.ptr,s.ptr))}}class B extends At{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),u(r.is_eq_sort(n,this.ptr,t.ptr))}neqIdentity(t){return!this.eqIdentity(t)}}class z extends At{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 g=u(r.get_decl_parameter_kind(n,this.ptr,h));switch(g){case o.Z3_parameter_kind.Z3_PARAMETER_INT:s.push(u(r.get_decl_int_parameter(n,this.ptr,h)));break;case o.Z3_parameter_kind.Z3_PARAMETER_DOUBLE:s.push(u(r.get_decl_double_parameter(n,this.ptr,h)));break;case o.Z3_parameter_kind.Z3_PARAMETER_RATIONAL:s.push(u(r.get_decl_rational_parameter(n,this.ptr,h)));break;case o.Z3_parameter_kind.Z3_PARAMETER_SYMBOL:s.push(bt(u(r.get_decl_symbol_parameter(n,this.ptr,h))));break;case o.Z3_parameter_kind.Z3_PARAMETER_SORT:s.push(new B(u(r.get_decl_sort_parameter(n,this.ptr,h))));break;case o.Z3_parameter_kind.Z3_PARAMETER_AST:s.push(new F(u(r.get_decl_ast_parameter(n,this.ptr,h))));break;case o.Z3_parameter_kind.Z3_PARAMETER_FUNC_DECL:s.push(new z(u(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)(g)}}return s}call(...t){return(0,i.assert)(t.length===this.arity(),`Incorrect number of arguments to ${this}`),T(u(r.mk_app(n,this.ptr,t.map((s,h)=>this.domain(h).cast(s).ast))))}}class F extends At{get sort(){return Q(r.get_sort(n,this.ast))}eq(t){return new b(u(r.mk_eq(n,this.ast,q(t).ast)))}neq(t){return new b(u(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 z(u(r.get_app_decl(n,u(r.to_app(n,this.ast)))))}numArgs(){return(0,i.assert)(tt(this),"Z3 applicaiton expected"),u(r.get_app_num_args(n,u(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(u(r.get_app_arg(n,u(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 Wn{constructor(t){this.ptr=t,this.ctx=x}}class sr extends B{cast(t){return typeof t=="boolean"&&(t=$.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=u(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)):D.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(u(r.mk_bvadd(n,e.ast,e.sort.cast(t[0]).ast)))}else return(0,i.assert)(e instanceof O),new O(u(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(u(r.mk_bvsub(n,e.ast,e.sort.cast(t[0]).ast)))}else return(0,i.assert)(e instanceof O),new O(u(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(u(r.mk_bvmul(n,e.ast,e.sort.cast(t[0]).ast)))}else return(0,i.assert)(e instanceof O),new O(u(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(u(r.mk_bvsdiv(n,e.ast,e.sort.cast(t).ast))):((0,i.assert)(e instanceof O),new O(u(r.mk_div(n,e.ast,e.sort.cast(t).ast))))}function ir(e,t){return new k(u(r.mk_bvudiv(n,e.ast,e.sort.cast(t).ast)))}function he(e){return e instanceof k?new k(u(r.mk_bvneg(n,e.ast))):((0,i.assert)(e instanceof O),new O(u(r.mk_unary_minus(n,e.ast))))}function pe(e,t){return e instanceof k?new k(u(r.mk_bvsrem(n,e.ast,e.sort.cast(t).ast))):((0,i.assert)(e instanceof O),new O(u(r.mk_mod(n,e.ast,e.sort.cast(t).ast))))}class O extends F{add(t){return ce(this,t)}mul(t){return fe(this,t)}sub(t){return _e(this,t)}pow(t){return new O(u(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 $e(this,t)}lt(t){return De(this,t)}gt(t){return ze(this,t)}ge(t){return je(this,t)}}class mt extends O{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 O{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(Ae("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 Ot(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 ir(this,t)}smod(t){return pe(this,t)}urem(t){return new k(u(r.mk_bvurem(n,this.ast,this.sort.cast(t).ast)))}srem(t){return new k(u(r.mk_bvsrem(n,this.ast,this.sort.cast(t).ast)))}neg(){return he(this)}or(t){return new k(u(r.mk_bvor(n,this.ast,this.sort.cast(t).ast)))}and(t){return new k(u(r.mk_bvand(n,this.ast,this.sort.cast(t).ast)))}nand(t){return new k(u(r.mk_bvnand(n,this.ast,this.sort.cast(t).ast)))}xor(t){return new k(u(r.mk_bvxor(n,this.ast,this.sort.cast(t).ast)))}xnor(t){return new k(u(r.mk_bvxnor(n,this.ast,this.sort.cast(t).ast)))}shr(t){return new k(u(r.mk_bvashr(n,this.ast,this.sort.cast(t).ast)))}lshr(t){return new k(u(r.mk_bvlshr(n,this.ast,this.sort.cast(t).ast)))}shl(t){return new k(u(r.mk_bvshl(n,this.ast,this.sort.cast(t).ast)))}rotateRight(t){return new k(u(r.mk_ext_rotate_right(n,this.ast,this.sort.cast(t).ast)))}rotateLeft(t){return new k(u(r.mk_ext_rotate_left(n,this.ast,this.sort.cast(t).ast)))}not(){return new k(u(r.mk_bvnot(n,this.ast)))}extract(t,s){return Ye(t,s,this)}signExt(t){return new k(u(r.mk_sign_ext(n,t,this.ast)))}zeroExt(t){return new k(u(r.mk_zero_ext(n,t,this.ast)))}repeat(t){return new k(u(r.mk_repeat(n,t,this.ast)))}sle(t){return Qe(this,t)}ule(t){return Ve(this,t)}slt(t){return Ge(this,t)}ult(t){return Ue(this,t)}sge(t){return Ke(this,t)}uge(t){return Be(this,t)}sgt(t){return We(this,t)}ugt(t){return Fe(this,t)}redAnd(){return new k(u(r.mk_bvredand(n,this.ast)))}redOr(){return new k(u(r.mk_bvredor(n,this.ast)))}addNoOverflow(t,s){return new b(u(r.mk_bvadd_no_overflow(n,this.ast,this.sort.cast(t).ast,s)))}addNoUnderflow(t){return new b(u(r.mk_bvadd_no_und