UNPKG

ixfx

Version:

Bundle of ixfx libraries

2 lines 27.6 kB
import{n as e}from"./chunk-BKBlUVio.js";import{C as t,M as n,o as r,u as i,v as a}from"./src-CrVWx2VD.js";import{n as o}from"./src-BnFVBvwz.js";const s=(e,t=null,n=new WeakSet,r=``)=>{if(e===null)return e;if(typeof e!=`object`)throw TypeError(`Param 'value' must be an object. Got type: ${typeof e}`);n.add(e);let i=Object.entries(e);for(let e of i)if(e[1]!==null&&typeof e[1]==`object`){if(n.has(e[1])){e[1]=t;continue}e[1]=s(e[1],t,n,`${e[0]}.`)}return Object.fromEntries(i)},c=e=>{let t=[];for(let n in e){let i=e[n];r(i)&&t.push([n,i])}return Object.fromEntries(t)},l=(e,t)=>{let n={};for(let r of Object.entries(e)){let e=t(r[0]);n[e]=r[1]}return n},u=(e,t)=>yt(Object.keys(e),Object.keys(t)),d=(e,t)=>{let n=m(e,t,!0);if(Object.entries(n.added).length>0||Object.entries(n.removed).length>0)throw Error(`Shape of data has changed`);return f(n,t)},f=(e,t)=>{let n={};if(e.isArray)return t;for(let t of Object.entries(e.changed))n[t[0]]=t[1];for(let t of Object.entries(e.added))n[t[0]]=t[1];for(let r of Object.entries(e.children)){let e=r[1];e.hasChanged&&(n[r[0]]=f(e,t[r[0]]))}return n},p=(e,t,n=A)=>{if(!Array.isArray(e))throw Error(`Param 'a' is not an array`);if(!Array.isArray(t))throw Error(`Param 'b' is not an array`);let r=m(e,t,!1,n);if(!r.isArray)throw Error(`Change set does not have arrays as parameters`);let i=e=>{if(e.startsWith(`_`))return Number.parseInt(e.slice(1));throw Error(`Unexpected key '${e}'`)};return{...r,added:l(r.added,i),changed:l(r.changed,i),removed:r.removed.map(e=>i(e)),summary:r.summary.map(e=>[e[0],i(e[1]),e[2]])}},m=(e,t,n=!1,r=A)=>{e??={},t??={};let i=Object.entries(e),a=Object.entries(t),o=new Set,s={},c={},l={},u=[],d=Array.isArray(e),f=[],p=!1;for(let e of i){let i=d?`_${e[0]}`:e[0],a=e[1],c=t[e[0]];if(o.add(e[0]),c===void 0){p=!0,n&&!d?(s[i]=c,f.push([`mutate`,i,c])):(u.push(i),f.push([`del`,i,a]));continue}if(typeof a==`object`){let e=m(a,c,n,r);e.hasChanged&&(p=!0),l[i]=e;let t=e.summary.map(e=>[e[0],i+`.`+e[1],e[2]]);f.push(...t)}else r(a,c)||(s[i]=c,p=!0,f.push([`mutate`,i,c]))}if(!n||d)for(let e of a){let t=d?`_${e[0]}`:e[0];o.has(e[0])||(c[t]=e[1],p=!0,f.push([`add`,t,e[1]]))}return{changed:s,added:c,removed:u,children:l,hasChanged:p,isArray:d,summary:f}},h=(e,t=`throw`)=>{let n={};for(let r of Object.entries(e)){let e=Number.parseInt(r[0]);if(Number.isNaN(e))switch(t){case`throw`:throw TypeError(`Cannot convert key '${r[0]}' to an integer`);case`ignore`:continue;case`keep`:n[r[0]]=r[1];continue;default:throw Error(`Param 'onInvalidKey' should be: 'throw', 'ignore' or 'keep'.`)}n[e]=r[1]}return n},g=(e,t)=>{let n=Object.entries(e).map(([e,n],r)=>[e,t({value:n,field:e,index:r,path:e})]);return Object.fromEntries(n)};function _(e,t){let n=Object.entries(e);for(let r of n)if(r[0]in t){let n=t[r[0]];r[1]=typeof n==`object`?_(r[1],n):n(r[1],e)}return Object.fromEntries(n)}function v(...e){return Object.assign({},...e)}function y(...e){let t=Object.entries(e[0]);for(let n=1;n<e.length;n++){let r=Object.entries(e[n]);for(let[e,n]of r){let r=t.find(([t])=>t===e);r&&(r[1]=n)}}return Object.fromEntries(t)}function b(e,t){let n=[];for(let r of e){let e=Object.entries(r),i=[];for(let[n,r]of e)i.push([t+n,r]);n.push(Object.fromEntries(i))}return n}function x(e){return typeof e==`number`||typeof e==`string`||typeof e==`bigint`||typeof e==`boolean`}function S(e){return!!(x(e)||typeof e==`object`)}function ee(e){if(e.length===0)return`(empty)`;let t=``;for(let[n,r]of e.entries())t+=` `.repeat(n),t+=`${r.name} = ${JSON.stringify(r.nodeValue)}\n`;return t}function te(e,t=0,r={}){n(i(e,`node`));let a=ae(e,r.name??`node`),o=`${` `.repeat(t)} + name: ${a.name} value: ${JSON.stringify(a.nodeValue)}`,s=[...C(e,r)];return s.length>0?`${o}\n${s.map(e=>te(e.nodeValue,t+1,{...r,name:e.name})).join(` `)}`:o}function*C(e,t={}){n(i(e,`node`));let r=t.filter??`none`,a=e=>r===`none`?[!0,x(e)]:r===`leaves`&&x(e)?[!0,!0]:r===`branches`&&!x(e)?[!0,!1]:[!1,x(e)];if(Array.isArray(e))for(let[t,n]of e.entries()){let e=a(n);e[0]&&(yield{name:t.toString(),sourceValue:n,nodeValue:e[1]?n:void 0})}else if(typeof e==`object`)if(t.withPrototype)for(let t in e){let n=e[t],r=a(n);r[0]&&(yield{name:t,sourceValue:n,nodeValue:r[1]?n:void 0})}else{let t=`entries`in e?e.entries():Object.entries(e);for(let[e,n]of t){let t=a(n);t[0]&&(yield{name:e,sourceValue:n,nodeValue:t[1]?n:void 0})}}}function*w(e,t={},n=[]){if(e==null)return;let r={filter:t.filter??`none`,name:t.name??``,withPrototype:t.withPrototype??!1,seen:t.seen??new WeakSet};if(typeof e==`object`){if(r.seen.has(e))return;r.seen.add(e)}for(let t of C(e,r))yield{...t,ancestors:[...n]},yield*w(t.sourceValue,r,[...n,t.name])}function ne(e,t){for(let n of C(t))if(n.name===e)return n}function re(e,t,n={}){let r=[...ie(e,t,n)];if(r.length===0)throw Error(`Could not trace path: ${e} `);return r.at(-1)}function*ie(e,t,r={}){n(i(e,`path`),i(t,`node`));let a=r.separator??`.`,o=e.split(a),s=[];for(let e of o){let n=ne(e,t);if(!n){yield{name:e,sourceValue:void 0,nodeValue:void 0,ancestors:s};return}t=n.sourceValue,yield{...n,ancestors:[...s]},s.push(e)}}function ae(e,t=``){return`name`in e&&`nodeValue`in e&&`sourceValue`in e?e:`name`in e?{name:e.name,nodeValue:e,sourceValue:e}:{name:t,nodeValue:e,sourceValue:e}}function*oe(e,t){for(let n of e){let e=n[t];if(typeof e!=`number`)throw TypeError(`Property value was not a number. Property: ${t} Value: ${e} Type: ${typeof e}`);yield e}}function*se(...e){let t=-1;for(let n=0;n<e.length;n++){if(!Array.isArray(e[n]))throw TypeError(`Value at index ${n} is not an array as expected`);if(t===-1)t=e[n].length;else if(e[n].length!==t)throw TypeError(`Array length mismatch. Expected: ${t} Actual: ${e[n].length} Array: ${n}`)}for(let n=0;n<t;n++)yield v(...e.map(e=>e[n]))}var ce=e({changedProperties:()=>d,cloneFromFields:()=>c,compareArrays:()=>p,compareObjectData:()=>m,compareObjectKeys:()=>u,enumerateNumericalValues:()=>oe,getRecordEntryByPath:()=>re,keysToNumbers:()=>h,mapObjectByObject:()=>_,mapObjectKeys:()=>l,mapObjectShallow:()=>g,merge:()=>v,mergeSameShape:()=>y,prefixProperties:()=>b,prettyPrintEntries:()=>ee,recordChildren:()=>C,recordEntriesDepthFirst:()=>w,recordEntryPrettyPrint:()=>te,removeCircularReferences:()=>s,traceRecordEntryByPath:()=>ie,zip:()=>se});const le=Object.prototype.toString;function ue(e){return le.call(e)}function de(e){return ue(e)===`[object Map]`}function fe(e){return ue(e)===`[object Set]`}function T(e){return typeof e==`string`?e:JSON.stringify(e)}function E(e){if(e===null)return`null`;if(typeof e==`boolean`||typeof e==`number`)return e.toString();if(typeof e==`string`)return e;if(typeof e==`symbol`)throw TypeError(`Symbol cannot be converted to string`);try{return JSON.stringify(e)}catch(t){if(typeof e==`object`)return JSON.stringify(s(e,`(circular)`));throw t}}function D(e){return typeof e==`string`?e:JSON.stringify(e,(e,t)=>t instanceof Object&&!Array.isArray(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function O(e,t){return e===t?0:e>t?1:-1}function pe(e,t){if(e===void 0&&t===void 0)return 0;if(e===void 0)return 1;if(t===void 0)return-1;let n=E(e),r=E(t);return n<r?-1:n>r?1:0}function me(e){return(t,n)=>e(t,n)*-1}function k(e,t){return typeof e==`number`&&typeof t==`number`?O(e,t):pe(e,t)}const A=(e,t)=>e===t;function he(e,t){return e===t?!0:T(e)===T(t)}function ge(e,t,n){if(typeof e!=`object`)throw Error(`Param 'a' expected to be object`);if(typeof t!=`object`)throw Error(`Param 'b' expected to be object`);if(Object.is(e,t))return!0;let r=n??ge;for(let n of Object.entries(t)){let t=e[n[0]],i=n[1];if(typeof t==`object`&&typeof i==`object`){if(!r(t,i))return!1}else if(t!==i)return!1}return!0}function _e(e,t){return e===t?!0:D(e)===D(t)}const ve=e=>[...Object.entries(e)].length===0,ye=(e,t,n)=>JSON.stringify(e)===JSON.stringify(t);var be=e({addObjectEntriesMutate:()=>B,addValue:()=>M,addValueMutate:()=>j,addValueMutator:()=>N,deleteByValueCompareMutate:()=>we,filterValues:()=>L,findBySomeKey:()=>Se,findEntryByPredicate:()=>Te,findEntryByValue:()=>Ee,findValue:()=>Oe,fromIterable:()=>z,fromObject:()=>De,getClosestIntegerKey:()=>xe,getOrGenerate:()=>Ie,getOrGenerateSync:()=>Fe,hasAnyValue:()=>I,hasKeyValue:()=>Ce,mapToArray:()=>Ne,mapToObjectTransform:()=>ke,mergeByKey:()=>Pe,some:()=>V,sortByValue:()=>P,sortByValueProperty:()=>F,toArray:()=>R,toObject:()=>Me,transformMap:()=>je,zipKeyValue:()=>Ae});const xe=(e,t)=>{if(t=Math.round(t),e.has(t))return t;{let n=1;for(;n<1e3;){if(e.has(t-n))return t-n;if(e.has(t+n))return t+n;n++}throw Error(`Could not find target ${t.toString()}`)}},Se=(e,t)=>{for(let n of t)if(e.has(n))return e.get(n)},Ce=(e,t,n,r=A)=>e.has(t)?[...e.values()].some(e=>r(e,n)):!1,we=(e,t,n=A)=>{for(let r of e.entries())n(r[1],t)&&e.delete(r[0])},Te=(e,t)=>{for(let n of e.entries())if(t(n[1],n[0]))return n},Ee=(e,t,n=A)=>{for(let r of e.entries())if(n(r[1],t))return r},j=(e,t,n,...r)=>{let i=e??new Map;return N(i,t,n)(...r),i},M=(e,t,n,...r)=>{let i=e===void 0?new Map:new Map(e);for(let e of r){let r=t(e);if(n!==`overwrite`&&i.has(r)){if(n===`throw`)throw Error(`Key '${r}' already in map`);if(n===`skip`)continue}i.set(r,e)}return i},N=(e,t,n=`overwrite`)=>(...r)=>{for(let i of r){let r=t(i);if(n!==`overwrite`&&e.has(r)){if(n===`throw`)throw Error(`Key '${r}' already in map`);if(n===`skip`)continue}e.set(r,i)}return e},P=(e,t)=>{let n=t??k;return[...e.entries()].sort((e,t)=>n(e[1],t[1]))},F=(e,t,n)=>{let r=n===void 0?k:n;return[...e.entries()].sort((e,n)=>{let i=e[1],a=n[1];return r(i[t],a[t])})},I=(e,t,n)=>[...e.entries()].some(e=>n(e[1],t));function*L(e,t){for(let n of e.values())t(n)&&(yield n)}const R=e=>[...e.values()],z=(e,t=T,n=`overwrite`)=>{let r=new Map;for(let i of e){let e=t(i);if(r.has(e)){if(n===`throw`)throw Error(`Key '${e}' is already used and new data will overwrite it. `);if(n===`skip`)continue}r.set(e,i)}return r},De=e=>{let t=new Map;if(Array.isArray(e))for(let n of e)B(t,n);else B(t,e);return t},B=(e,t)=>{let n=Object.entries(t);for(let[t,r]of n)e.set(t,r)},Oe=(e,t)=>[...e.values()].find(e=>t(e)),V=(e,t)=>[...e.values()].some(e=>t(e)),ke=(e,t)=>[...e].reduce((e,[n,r])=>(e[n]=t(r),e),{}),Ae=(e,t)=>{if(e.length!==t.length)throw Error(`Keys and values arrays should be same length`);return Object.fromEntries(e.map((e,n)=>[e,t[n]]))},je=(e,t)=>new Map(Array.from(e,e=>[e[0],t(e[1],e[0])])),Me=e=>[...e].reduce((e,[t,n])=>(e[t]=n,e),{}),Ne=(e,t)=>[...e.entries()].map(e=>t(e[0],e[1])),Pe=(e,...t)=>{let n=new Map;for(let r of t)for(let[t,i]of r){let r=n.get(t);r=r?e(r,i):i,n.set(t,r)}return n},Fe=(e,t)=>(n,r)=>{let i=e.get(n);return i===void 0?(i=t(n,r),e.set(n,i),i):i},Ie=(e,t)=>async(n,r)=>{let i=e.get(n);if(i!==void 0)return i;if(i=await t(n,r),i===void 0)throw Error(`fn returned undefined`);return e.set(n,i),i};var Le=e({applyChanges:()=>ze,compareData:()=>H,getField:()=>Be,getPaths:()=>Ve,getPathsAndData:()=>He,updateByPath:()=>U});const Re=(e,t)=>{if(e===void 0)throw Error(`Param 'target' is undefined`);if(e===null)throw Error(`Param 'target' is null`);if(typeof e!=`object`)throw Error(`Param 'target' is not an object (got: ${typeof e})`);if(t){let t=[];for(let n in e){let i=e[n];r(i)&&t.push([n,i])}return t}else return Object.entries(e)};function*H(e,t,n={}){if(e===void 0){yield{path:n.pathPrefix??``,value:t,state:`added`};return}if(t===void 0){yield{path:n.pathPrefix??``,previous:e,value:void 0,state:`removed`};return}let r=n.asPartial??!1,i=n.skipInstances??new WeakSet,a=n.undefinedValueMeansRemoved??!1,o=n.pathPrefix??``,s=n.deepEntries??!1,c=n.eq??ye,l=n.includeMissingFromA??!1,u=n.includeParents??!1;if(x(e)&&x(t)){e!==t&&(yield{path:o,value:t,previous:e,state:`change`});return}if(x(t)){yield{path:o,value:t,previous:e,state:`change`};return}let d=Re(e,s),f=new Set;for(let[e,s]of d){f.add(e);let l=e in t,d=t[e];if(typeof s==`object`&&s){if(i.has(s))continue;if(i.add(s),l){if(d===void 0)throw Error(`Pathed.compareData Value for key ${e} is undefined`);{let r=[...H(s,d,{...n,skipInstances:i,pathPrefix:o+e+`.`})];if(r.length>0){for(let e of r)yield e;u&&(yield{path:o+e,value:t[e],previous:s,state:`change`})}}}else{if(r)continue;yield{path:o+e,value:void 0,previous:s,state:`removed`}}}else{let t=o+e;if(l)d===void 0&&a?yield{path:t,previous:s,value:void 0,state:`removed`}:c(s,d,t)||(yield{path:t,previous:s,value:d,state:`change`});else{if(r)continue;yield{path:t,previous:s,value:void 0,state:`removed`}}}}if(l){let e=Re(t,s);for(let[t,n]of e)f.has(t)||(yield{path:o+t,previous:void 0,value:n,state:`added`})}}const ze=(e,t)=>{for(let n of t)e=U(e,n.path,n.value);return e},U=(e,t,n,r=!1)=>{if(t===void 0)throw Error(`Parameter 'path' is undefined`);if(typeof t!=`string`)throw Error(`Parameter 'path' should be a string. Got: ${typeof t}`);if(e===void 0)throw Error(`Parameter 'target' is undefined`);if(e===null)throw Error(`Parameter 'target' is null`);return W(e,t.split(`.`),n,r)},W=(e,t,n,r)=>{if(t.length===0){if(r)return n;if(Array.isArray(e)&&!Array.isArray(n))throw Error(`Expected array value, got: '${JSON.stringify(n)}'. Set allowShapeChange=true to ignore.`);if(!Array.isArray(e)&&Array.isArray(n))throw Error(`Unexpected array value, got: '${JSON.stringify(n)}'. Set allowShapeChange=true to ignore.`);if(typeof e!=typeof n)throw Error(`Cannot reassign object type. (${typeof e} -> ${typeof n}). Set allowShapeChange=true to ignore.`);if(typeof e==`object`&&!Array.isArray(e)){let t=u(e,n);if(t.a.length>0)throw Error(`New value is missing key(s): ${t.a.join(`,`)}`);if(t.b.length>0)throw Error(`New value cannot add new key(s): ${t.b.join(`,`)}`)}return n}let i=t.shift();if(!i)return n;if(q(i)&&Array.isArray(e)){let a=Number.parseInt(i);if(a>=e.length&&!r)throw Error(`Array index ${a.toString()} is outside of the existing length of ${e.length.toString()}. Use allowShapeChange=true to permit this.`);let o=[...e];return o[a]=W(o[a],t,n,r),o}else if(i in e){let a={...e};return a[i]=W(a[i],t,n,r),a}else throw Error(`Path ${i} not found in data`)},Be=(e,t,n=`.`)=>{if(typeof t!=`string`)throw Error(`Param 'path' ought to be a string. Got: '${typeof t}'`);if(t.length===0)throw Error(`Param string 'path' is empty`);if(e===void 0)throw Error(`Param 'object' is undefined`);if(e===null)throw Error(`Param 'object' is null`);return G(e,t.split(n),t)},G=(e,t,n)=>{if(e===void 0)return{success:!1,error:`Param 'object' is undefined. Position: ${n}`};if(t.length===0)return{success:!1,error:`Path has been exhausted. position: ${n}`};let r=t.shift();if(!r)return{success:!1,error:`Unexpected empty split path. Position: ${n}`};if(q(r)&&Array.isArray(e)){let i=Number.parseInt(r);return e[i]===void 0?{success:!1,error:`Index '${i}' does not exist. Length: ${e.length}. Position: ${n}`}:t.length===0?{value:e[i],success:!0}:G(e[i],t,t.join(`.`))}else if(typeof e==`object`&&r in e)return t.length===0?{value:e[r],success:!0}:G(e[r],t,t.join(`.`));else return{success:!1,error:`Path '${r}' not found. Position: ${n}`}};function*Ve(e,t={}){let n=t.onlyLeaves??!1;if(e==null)return;let r=w(e,{seen:new WeakSet,withPrototype:!1,onlyLeaves:!1,filter:`none`,name:``,...t}),i=t.rootName?t.rootName+`.`:``;for(let e of r){if(e.nodeValue===void 0&&n)continue;let t=i+e.name;e.ancestors.length>0&&(t=e.ancestors.join(`.`)+`.`+t),yield t}}function*He(e,t=!1,n=2**53-1,r=``){e!=null&&(yield*Ue(e,r,t,n))}function*Ue(e,t,n=!1,r){if(!(r<=0)&&typeof e==`object`)for(let i of Object.entries(e)){let e=(t.length>0?t+`.`:``)+i[0],a=i[1];(n&&typeof a!=`object`||!n)&&(yield{path:e,value:a}),yield*Ue(a,e,n,r-1)}}const We=(e=T)=>{let t=new Set;return n=>{if(n===null)throw TypeError(`Param 'value' cannot be null`);if(n===void 0)throw TypeError(`Param 'value' cannot be undefined`);let r=typeof n==`string`?n:e(n);return t.has(r)?!1:(t.add(r),!0)}},Ge=()=>{let e=new Set;return t=>{if(t===null)throw TypeError(`Param 'value' cannot be null`);if(t===void 0)throw TypeError(`Param 'value' cannot be undefined`);return e.has(t)?!1:(e.add(t),!0)}};var Ke=e({unique:()=>We,uniqueInstances:()=>Ge});const qe=(e,t=0,r={})=>{let i=Y(t,0);n(a(i,`positive`,`interval`));let o=r.fireBeforeWait??!1,s=r.onStartCalled,c=r.signal,l=!1,u=`idle`,d=0,f=0,p=performance.now(),m=t??0,h=!1,g,_=()=>{g!==void 0&&(globalThis.clearTimeout(g),g=void 0,d=0,p=NaN)},v=e=>{i===0?typeof requestAnimationFrame>`u`?g=globalThis.setTimeout(e,0):(g=void 0,requestAnimationFrame(e)):g=globalThis.setTimeout(e,i)},y=()=>{h||(h=!0,u!==`idle`&&(u=`idle`,_()))},b=async()=>{if(c?.aborted&&(u=`idle`),u===`idle`)return;u=`running`,d++,f++;let t=e(d,performance.now()-p),n=typeof t==`object`?await t:t;if(!h){if(u=`scheduled`,n!==void 0&&!n){y();return}h||v(b)}},x=()=>{if(l)throw Error(`Disposed`);if(h=!1,s!==void 0)switch(s(d,performance.now()-p)){case`cancel`:y();return;case`reset`:S();return;case`dispose`:l=!0,y();return}u===`idle`&&(d=0,p=performance.now(),u=`scheduled`,o?b():v(b))},S=()=>{if(l)throw Error(`Disposed`);h=!1,d=0,p=NaN,u!==`idle`&&y(),x()};return{start:x,reset:S,cancel:y,get interval(){return m},get runState(){return u},get startCountTotal(){return f},get startCount(){return d},set interval(e){let t=Y(e,0);n(a(t,`positive`,`interval`)),i=t,m=e},get isDisposed(){return l},get elapsedMs(){return performance.now()-p}}},Je=(e,t)=>e.score>t.score?-1:e.score<t.score?1:0,Ye=(e,t,n,r={})=>{let i=r.matchThreshold??0,a=r.debug??!1,o=new Map,s=[],c=new Map;t?.forEach((e,t)=>{if(e===void 0)throw Error(`'lastData' contains undefined (index: ${t.toString()})`);c.set(e.id,e)});for(let r of n){if(!t||t.length===0){a&&console.debug(`Correlate.align() new id: ${r.id}`),s.push(r);continue}let n=Array.from(c.values()).map(t=>({id:t.id,score:t===null?-1:e(t,r),last:t}));if(n.length===0){a&&console.debug(`Correlate.align() no valid last values id: ${r.id}`),s.push(r);continue}n.sort(Je);let l=n[0];if(l.score<i){a&&console.debug(`Correlate.align() new item does not reach threshold. Top score: ${l.score.toString()} id: ${r.id}`),s.push(r);continue}a&&l.id!==r.id&&console.log(`Correlate.align() Remapped ${r.id} -> ${l.id} (score: ${l.score.toString()})`),o.set(l.id,{...r,id:l.id}),c.delete(l.id)}return s.forEach(e=>o.set(e.id,e)),Array.from(o.values())},Xe=(e,t={})=>{let n=[];return r=>(n=Ye(e,n,r,t),[...n])},Ze=e=>typeof e==`string`?e:JSON.stringify(e),Qe=()=>{let e=performance.now();return()=>performance.now()-e},$e=()=>{let e=performance.now();return()=>{let t=performance.now(),n=t-e;return e=t,n}},et=()=>{let e=Date.now(),t=0;return()=>(t===0&&(t=Date.now()-e),t)},tt=()=>()=>1/0,nt=(e,t,n)=>t(e)?e:n;function rt(e,t){if(typeof e!=`string`)throw TypeError(`Param 'a' is not a string. Got: ${typeof e}`);if(typeof t!=`string`)throw TypeError(`Param 'b' is not a string. Got: ${typeof t}`);let n=[];for(let r=0;r<=e.length;r++){n[r]=[];for(let i=0;i<=t.length;i++)r===0?n[r][i]=i:i===0?n[r][i]=r:n[r][i]=Math.min(n[r-1][i]+1,n[r][i-1]+1,n[r-1][i-1]+(e[r-1]===t[i-1]?0:1))}let r=[],i=e.length,a=t.length;for(;i>0||a>0;)i>0&&a>0&&n[i][a]===n[i-1][a-1]&&e[i-1]===t[a-1]?(r.push({type:`keep`,char:e[i-1]}),i--,a--):i>0&&a>0&&n[i][a]===n[i-1][a-1]+1?(r.push({type:`replace`,from:e[i-1],to:t[a-1]}),i--,a--):a>0&&n[i][a]===n[i][a-1]+1?(r.push({type:`insert`,char:t[a-1]}),a--):(r.push({type:`delete`,char:e[i-1]}),i--);return r.reverse()}const it=/\s+/;function at(){return{split:e=>[...e],joinWith:``}}function ot(){return{split:e=>e.split(it),joinWith:` `}}const st=/([!$()*+./:=?[\\\]^{|}])/g;function*ct(e,t=`.`){for(;e.length>0;){yield e;let n=ht(e,t);if(n===e)break;e=n}}function*lt(e,t=`.`){for(;e.length>0;){yield e;let n=mt(e,t,{ifNoMatch:`original`,fromEnd:!0});if(n===e)break;e=n}}function ut(e,t=15){if(n(a(t,`aboveZero`,`maxLength`)),typeof e!=`string`)throw Error(`Parameter 'source' is not a string`);if(e.length>t&&e.length>3){if(t>15){let n=Math.round((t-2)/2);return`${e.slice(0,n)}...${e.slice(-n)}`}return`${e.slice(0,t)}...`}return e}function K(e,t=20){return e===void 0?`(undefined)`:e===null?`(null)`:ut(JSON.stringify(e),t)}function dt(e,t,n=0,r=e.length-1){for(let i=n;i<=r;i++)if(e.codePointAt(i)===t)return i;return-1}function ft(e,t,n){return e.slice(0,t)+e.slice(t+n)}function*pt(e,t){if(e===null)throw Error(`source parameter null`);if(t<=0){yield e;return}if(n(a(t,`aboveZero`,`length`)),typeof e!=`string`)throw TypeError(`source parameter not a string`);let r=0;for(;r+t<e.length;)yield e.slice(r,r+t),r+=t;r<e.length&&(yield e.slice(r))}function mt(e,t,n={}){return gt(e,t,n)[0]}function ht(e,t,n={}){return gt(e,t,n)[1]}function gt(e,t,n={}){if(e===void 0)throw Error(`Param 'source' is undefined`);let r=n.fallback,i=n.ifNoMatch??(r?`fallback`:`original`);if(i===`original`&&(r=e),i===`fallback`&&r===void 0)throw Error(`Fallback must be provided`);let a=n.startPos??void 0,o=n.fromEnd??!1?e.lastIndexOf(t,a):e.indexOf(t,a);if(o<0&&i===`throw`)throw Error(`Match '${t}' not found in source.`);return o<0&&i===`original`?[e,e]:o<0&&i===`fallback`?[r,r]:[e.slice(0,o),e.slice(Math.max(0,o+t.length))]}function _t(e){let t=e=>e.replaceAll(st,`\\$1`);e=e.split(`*`).map(e=>t(e)).join(`.*`),e=`^${e}$`;let n=new RegExp(e);return e=>n.test(e)}const vt=e=>(t,n)=>{let r=e(t,n);return console.log(`isEqualTrace eq: ${r} a: ${K(t)} b: ${K(n)}`),r},q=e=>{if(e===void 0)return!1;if(typeof e==`string`){let t=Number.parseInt(e);return Number.isNaN(t)?!1:t.toString()===e.toString()}return typeof e==`number`?Number.isNaN(e)||!Number.isFinite(e)?!1:Math.round(e)===e:!1},yt=(e,t,n=A)=>{let r=[],i=[],a=[];for(let a of e){let e=!1;for(let r of t)if(n(a,r)){e=!0;break}e?r.push(a):i.push(a)}for(let r of t){let t=!1;for(let i of e)n(r,i)&&(t=!0);t||a.push(r)}return{shared:r,isSame:i.length===0&&a.length===0,a:i,b:a}},J=(e,t=!1)=>n=>{let r=n.toSorted((t,n)=>k(t[e],n[e]));return t?r.reverse():r},bt=e=>{switch(e){case`value`:return J(1,!1);case`value-reverse`:return J(1,!0);case`key`:return J(0,!1);case`key-reverse`:return J(0,!0);default:throw Error(`Unknown sorting value '${e}'. Expecting: value, value-reverse, key or key-reverse`)}};function xt(e,t,r){n(a(e,`positive`,`decimalPlaces`));let i=typeof t==`boolean`?t:r??!1,o;if(e===0)o=Math.round;else{let t=10**e;o=i?e=>Math.ceil(e*t)/t:e=>Math.floor(e*t)/t}return typeof t==`number`?o(t):o}function St(e){return typeof e==`object`?e instanceof Date:!1}function Y(e,t){if(Ct(e)){if(typeof e==`number`)return e;let t=e.millis??0;return t+=(e.hours??0)*60*60*1e3,t+=(e.mins??0)*60*1e3,t+=(e.secs??0)*1e3,t}else{if(t!==void 0)return t;throw Error(`Not a valid interval: ${JSON.stringify(e)}`)}}function Ct(e){if(e==null)return!1;if(typeof e==`number`)return!(Number.isNaN(e)||!Number.isFinite(e));if(typeof e!=`object`)return!1;let n=`millis`in e,r=`secs`in e,i=`mins`in e,a=`hours`in e;return n&&!t(e.millis).success||r&&!t(e.secs).success||i&&!t(e.mins).success||a&&!t(e.hours).success?!1:!!(n||r||a||i)}const wt=(e,t=2)=>{let n=0;if(typeof e==`function`)return wt(e());typeof e==`number`?n=e:typeof e==`object`&&(n=Y(e));let r=Y(n);return r===void 0?`(undefined)`:r<1e3?`${xt(t,r)}ms`:(r/=1e3,r<120?`${r.toFixed(1)}secs`:(r/=60,r<60?`${r.toFixed(2)}mins`:(r/=60,`${r.toFixed(2)}hrs`)))},Tt=()=>[`iPad Simulator`,`iPhone Simulator`,`iPod Simulator`,`iPad`,`iPhone`,`iPod`].includes(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document,Et=(e,t)=>new Promise(n=>{let r=(...i)=>{e.removeEventListener(t,r),Array.isArray(i)&&i.length===1?n(i[0]):n(i)};e.addEventListener(t,r)}),X=e=>typeof e!=`object`||!e?!1:`on`in e&&`onValue`in e,Z=e=>X(e)?`last`in e&&e.last()!==void 0:!1;async function Q(e,...t){if(typeof e==`object`)if(`next`in e){let t=e[Symbol.toStringTag];if(t===`Generator`||t==`Array Iterator`){let t=e.next();return`done`in t&&`value`in t?t.value:t}else if(t===`AsyncGenerator`){let t=await e.next();return`done`in t&&`value`in t?t.value:t}else throw Error(`Object has 'next' prop, but does not have 'AsyncGenerator', 'Generator' or 'Array Iterator' string tag symbol. Got: '${t}'`)}else if(X(e)){if(Z(e))return e.last();throw Error(`Reactive does not have last value`)}else return e;else if(typeof e==`function`)return await e(...t);else return e}function $(e,...t){if(typeof e==`object`)if(`next`in e){let t=e[Symbol.toStringTag];if(t===`Generator`||t==`Array Iterator`){let t=e.next();return`done`in t&&`value`in t?t.value:t}else if(t===`AsyncGenerator`)throw Error(`resolveSync cannot work with an async generator`);else throw Error(`Object has 'next' prop, but does not have 'Generator' or 'Array Iterator' string tag symbol. Got: '${t}'`)}else if(X(e)){if(Z(e))return e.last();throw Error(`Reactive does not have last value`)}else return e;else if(typeof e==`function`)return e(...t);else return e}async function Dt(e,t,...n){let r=!1,i=t.value,a=t.overrideWithLast??!1;if(i===void 0)throw Error(`Param 'options.value' is undefined`);try{let t=await Q(e,...n);return t===void 0||typeof t==`number`&&Number.isNaN(t)?i:(a&&(i=t),t)}catch(e){return r||(r=!0,console.warn(`resolveWithFallback swallowed an error. Additional errors not reported.`,o(e))),i}}function Ot(e,t,...n){let r=!1,i=t.value,a=t.overrideWithLast??!1;if(i===void 0)throw Error(`Param 'options.value' is undefined`);try{let t=$(e,...n);return t===void 0||typeof t==`number`&&Number.isNaN(t)?i:(a&&(i=t),t)}catch(e){return r||(r=!0,console.warn(`resolveWithFallbackSync swallowed an error. Additional errors not reported.`,o(e))),i}}const kt=(...e)=>{if(e.some(e=>!Array.isArray(e)))throw Error(`All parameters must be an array`);let t=e.map(e=>e.length),n=[],r=t[0];for(let t=0;t<r;t++)n.push(e.map(e=>e[t]));return n};async function At(e){let t=[],n=[];for(let r of Object.entries(e)){let e=r[1];t.push(Q(e)),n.push(r[0])}let r=kt(n,await Promise.all(t));return Object.fromEntries(r)}function jt(e){let t=[];for(let n of Object.entries(e)){let e=n[1],r=$(e);t.push([n[0],r])}return Object.fromEntries(t)}(typeof window>`u`||!(`requestAnimationFrame`in window))&&typeof window>`u`&&(globalThis.requestAnimationFrame=e=>{setTimeout(e,1)});const Mt=e=>{let r=Y(e,1),i=e.signal,a=e.value;return n(t(r,`positive`,`timeoutMs`)),r===0?new Promise(e=>requestAnimationFrame(t=>{e(a)})):new Promise((e,t)=>{let n=()=>{clearTimeout(o),i?(i.removeEventListener(`abort`,n),t(Error(i.reason))):t(Error(`Cancelled`))};i&&i.addEventListener(`abort`,n);let o=setTimeout(()=>{if(i?.removeEventListener(`abort`,n),i?.aborted){t(Error(i.reason));return}e(a)},r)})},Nt=async(e,t=100)=>{for(;e();)await Mt(t)},Pt=e=>{let t=new URL(e??document.location.toString()).searchParams;return{params:t,int:(e,n=NaN)=>It(t,e,n),float:(e,n=NaN)=>Lt(t,e,n),string:(e,n=``)=>Rt(t,e,n),bool:e=>Ft(t,e)}};function Ft(e,t){let n=e.get(t);return n===null?!1:n===`true`}function It(e,t,n){let r=e.get(t);return r===null?n:Number.parseInt(r)}function Lt(e,t,n){let r=e.get(t);return r===null?n:Number.parseFloat(r)}function Rt(e,t,n){let r=e.get(t);return r===null?n:r}export{N as $,_t as A,me as At,Ye as B,x as Bt,mt as C,Ae as Ct,ct as D,he as Dt,ft as E,A as Et,tt as F,de as Ft,H as G,qe as H,g as Ht,$e as I,fe as It,Le as J,Be as K,et as L,T as Lt,ot as M,pe as Mt,rt as N,O as Nt,lt as O,_e as Ot,nt as P,E as Pt,j as Q,Qe as R,D as Rt,ht as S,je as St,dt as T,ye as Tt,Ke as U,p as Ut,Xe as V,S as Vt,Ge as W,c as Wt,B as X,U as Y,M as Z,Ct as _,V as _t,jt as a,Oe as at,q as b,R as bt,Dt as c,xe as ct,X as d,I as dt,we as et,Et as f,Ce as ft,St as g,Pe as gt,Y as h,be as ht,At as i,Ee as it,at as j,k as jt,K as k,ge as kt,Ot as l,Ie as lt,wt as m,ke as mt,Mt as n,Se as nt,Q as o,z as ot,Tt as p,Ne as pt,He as q,Nt as r,Te as rt,$ as s,De as st,Pt as t,L as tt,Z as u,Fe as ut,bt as v,P as vt,pt as w,ve as wt,vt as x,Me as xt,yt as y,F as yt,Ze as z,ce as zt};