function i(n){return typeof(n==null?void 0:n[Symbol.iterator])=="function"}function s(n){return typeof(n==null?void 0:n[Symbol.asyncIterator])=="function"}const dn=function*(){},U=n=>n!=null,h=n=>n instanceof Promise||n!==null&&typeof n=="object"&&typeof n.then=="function"&&typeof n.catch=="function",W=n=>typeof n=="number",E=n=>typeof n=="string";function rn(n,e){if(W(n)&&W(e)||E(n)&&E(e))return n+e;throw new TypeError("'a' or 'b' must be type of number or string")}async function hn(n,e){return rn(await n,await e)}function B(n,e){return e===void 0?t=>B(n,t):h(n)||h(e)?hn(Promise.resolve(n),Promise.resolve(e)):rn(n,e)}function wn(n,e){if(e===void 0)return r=>wn(n,r);const t=h(e)?e.then(n):n(e);return h(t)?t.then(()=>e):e}function mn(n,e){const t=e[Symbol.iterator]();return{next(){const{done:r,value:o}=t.next();return r?{done:!0,value:void 0}:{done:!1,value:n(o)}},[Symbol.iterator](){return this}}}function pn(n,e){const t=e[Symbol.asyncIterator]();return{async next(r){const{done:o,value:u}=await t.next(r);return o?{done:o,value:u}:{done:!1,value:await n(u)}},[Symbol.asyncIterator](){return this}}}function p(n,e){if(e===void 0)return t=>p(n,t);if(i(e))return mn(n,e);if(s(e))return pn(n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}const x=(n,e)=>h(n)?n.then(e):e(n);function H(n,e,t){for(const r of t)e=n(e,r);return e}async function J(n,e,t){for await(const r of t)e=await x(e,o=>n(o,r));return e}function l(n,e,t){if(t===void 0){if(e===void 0)return r=>l(n,r);if(i(e)){const r=e[Symbol.iterator](),{done:o,value:u}=r.next();if(o)throw new TypeError("'reduce' of empty iterable with no initial value");return H(n,u,{[Symbol.iterator](){return r}})}if(s(e)){const r=e[Symbol.asyncIterator]();return r.next().then(({done:o,value:u})=>{if(o)throw new TypeError("'reduce' of empty iterable with no initial value");return J(n,u,{[Symbol.asyncIterator](){return r}})})}throw new TypeError("'iterable' must be type of Iterable or AsyncIterable. Are you looking for 'reduceLazy'?")}if(i(t))return H(n,e,t);if(s(t))return J(n,Promise.resolve(e),t);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function I(n,...e){return l(x,n,e)}function me(n){if(Array.isArray(n))return n.reduce(B,0);if(i(n))return l((e,t)=>B(e,t),0,n);if(s(n))return l(B,Promise.resolve(0),n);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}async function In(n){const e=[];for await(const t of n)e.push(t);return e}function S(n){return s(n)?In(n):i(n)?Array.from(n):[]}class q{constructor(e){this.length=e}static of(e){return new q(e)}}const A=n=>n instanceof q;function v(n,e){if(e===void 0)return y=>v(n,y);if(!Number.isFinite(n)||n<=0)throw new RangeError("'length' must be positive integer");if(!s(e))throw new TypeError("'iterable' must be type of AsyncIterable");const t=e[Symbol.asyncIterator](),r=[];let o=Promise.resolve(),u=0,f=0,d=!1,m=!1;const T=[],b=()=>{for(;r.length>0&&u>f;){const y=r.shift(),[w,C]=T.shift();if(y.status==="fulfilled")f++,w(y.value),y.value.done&&(d=!0);else{C(y.reason),d=!0;break}}},c=()=>{if(m)o=o.then(()=>void(!d&&u>f&&c()));else{const y=Promise.allSettled(Array.from({length:n},()=>t.next(q.of(n))));m=!0,o=o.then(()=>y).then(w=>{r.push(...w),m=!1,a()})}};function a(){d||u===f||(r.length>0?b():c())}return{[Symbol.asyncIterator](){return this},next(){return u++,d?{done:!0,value:void 0}:new Promise((y,w)=>{T.push([y,w]),a()})}}}function*Sn(n,e){const t=e[Symbol.iterator]();let r=null;for(;n-- >0&&(r=t.next()).done===!1;)yield r.value}function vn(n,e){const t=e[Symbol.asyncIterator]();return{[Symbol.asyncIterator](){return this},async next(r){return n--<1?{done:!0,value:void 0}:t.next(r)}}}function M(n,e){if(e===void 0)return t=>M(n,t);if(i(e))return Sn(n,e);if(s(e))return vn(n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}const xn=n=>n===null,on=n=>n===void 0,An=n=>on(n)||xn(n);function*En(n,e,t=1){if(e===void 0)return yield*En(0,n);if(t<0)for(;n>e;)yield n,n+=t;else for(;n{if(h(n))throw new g;return n};function $n(n,e){for(const t of e)n(t)}async function gn(n,e){for await(const t of e){const r=n(t);h(r)&&await r}}function R(n,e){if(e===void 0)return t=>R(n,t);if(i(e))return $n(n,e);if(s(e))return gn(n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function*Tn(n,e){for(const t of e){yield t;const r=n(t);if(h(r))throw new g;if(r)break}}function K(n,e){const t=e[Symbol.asyncIterator]();let r=!1;return{[Symbol.asyncIterator](){return this},async next(o){if(r)return{done:!0,value:void 0};const{done:u,value:f}=await t.next(o);if(u||r)return{done:!0,value:void 0};const d=await n(f);return r?{done:!0,value:void 0}:(d&&(r=!0),{done:!1,value:f})}}}function bn(n,e){let t;return{async next(r){return t===void 0&&(t=A(r)?K(n,v(r.length,e)):K(n,e)),t.next(r)},[Symbol.asyncIterator](){return this}}}function k(n,e){if(e===void 0)return t=>k(n,t);if(i(e))return Tn(n,e);if(s(e))return bn(n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function V(n){return!n}function Pn(n,e){if(e===void 0)return t=>Pn(n,t);if(i(e))return I(p(t=>L(n(t)),e),k(V),t=>l((r,o)=>r&&o,!0,t),t=>t??!0,Boolean);if(s(e))return I(p(n,e),k(V),t=>l((r,o)=>r&&o,!0,t),t=>t??!0,Boolean);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function O(n){return n}function X(n){if(i(n))return I(M(1,n),S,([e])=>e);if(s(n))return I(M(1,n),S,([e])=>e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}async function*kn(n,e){for await(const t of e)await n(t)&&(yield t)}function Bn(n){const e=n[Symbol.asyncIterator](),t=[],r=[];let o=!1,u=0,f=0,d=Promise.resolve();function m(c){const a=e.next(c);d=d.then(()=>a).then(({done:y,value:w})=>{if(y){for(;t.length>0;){const[ln]=t.shift();ln({done:!0,value:void 0})}return void(o=!0)}const[C,an]=w;C&&r.push(an),b(c)}).catch(y=>{for(o=!0;t.length>0;){const[,w]=t.shift();w(y)}})}function T(){for(;r.length>0&&u>f;){const c=r.shift(),[a]=t.shift();a({done:!1,value:c}),f++}}function b(c){o||u===f||(r.length>0?T():m(c))}return{async next(c){return u++,o?{done:!0,value:void 0}:new Promise((a,y)=>{t.push([a,y]),b(c)})},[Symbol.asyncIterator](){return this}}}function On(n,e){const t=e[Symbol.asyncIterator]();return{[Symbol.asyncIterator](){return this},async next(r){const{done:o,value:u}=await t.next(r);return o?{done:!0,value:void 0}:x(n(u),f=>({done:o,value:[!!f,u]}))}}}function qn(n,e){let t;return{async next(r){return t===void 0&&(t=A(r)?Bn(v(r.length,On(n,e))):kn(n,e)),t.next(r)},[Symbol.asyncIterator](){return this}}}function*Cn(n,e){for(const t of e){const r=n(t);if(h(r))throw new g;r&&(yield t)}}function $(n,e){if(e===void 0)return t=>$(n,t);if(i(e))return Cn(n,e);if(s(e))return qn(n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function N(n,e){if(e===void 0)return t=>N(n,t);if(i(e)||s(e))return X($(n,e));throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function z(n){let e=-1;return p(t=>[++e,t],n)}function Mn(n){let e;return{async next(t){return e===void 0&&(e=A(t)?z(v(t.length,n)):z(n)),e.next(t)},[Symbol.asyncIterator](){return this}}}function Y(n){if(s(n))return Mn(n);if(i(n))return z(n);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function Nn(n,e){if(e===void 0)return t=>Nn(n,t);if(i(e))return I(Y(e),N(([,t])=>n(t)),t=>t?t[0]:-1);if(s(e))return I(Y(e),N(([,t])=>x(t,n)),t=>t?t[0]:-1);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function zn(n,e){if(e===void 0)return r=>zn(n,r);const t={};if(i(e))return l((r,o)=>{const u=n(o);if(h(u))throw new g;return(r[u]||(r[u]=[])).push(o),r},t,e);if(s(e))return l(async(r,o)=>{const u=await n(o);return(r[u]||(r[u]=[])).push(o),r},t,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function F(n,e){if(e===void 0)return t=>F(n,t);if(i(e))return I(p(t=>L(n(t)),e),k(O),t=>l((r,o)=>r||o,!1,t),Boolean);if(s(e))return I(p(n,e),k(O),t=>l((r,o)=>r||o,!1,t),Boolean);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function Fn(n,e){if(e===void 0)return t=>Fn(n,t);if(i(e))return F(t=>t===n,e);if(s(e))return F(t=>t===n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}const P=n=>Array.isArray(n),pe=n=>typeof n=="boolean",Ie=n=>An(n)||typeof n=="object"&&n.constructor===Object&&Object.getOwnPropertyNames(n).length===0||P(n)&&n.length===0||n===""?!0:n instanceof Map||n instanceof Set?n.size===0:!1;function Qn(n,e){const t=l((r,o)=>r==""?`${o}`:`${r}${n}${o}`,"",e);return t==null?"":E(t)?t:String(t)}function Gn(n,e){return l((t,r)=>t==""?`${r}`:`${t}${n}${r}`,"",e).then(t=>t==null?"":E(t)?t:String(t))}function Ln(n,e){if(e===void 0)return t=>Ln(n,t);if(Array.isArray(e)&&e.length===0)return"";if(i(e))return Qn(n,e);if(s(e))return Gn(n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function un(n){if(P(n)||E(n))return n[n.length-1];if(i(n))return l((e,t)=>t,n);if(s(n))return l((e,t)=>t,n);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function Rn(n,e){if(e===void 0)return t=>Rn(n,t);if(n.constructor!==e.constructor)throw new TypeError("The values you want to compare must be of the same type");return n<=e}function sn(n,e){return Object.fromEntries(Object.entries(n).filter(([t])=>!e.has(t)))}function Dn(n,e){const t=new Set(n);return sn(e,t)}async function Un(n,e){const t=new Set(await S(n));return sn(e,t)}function Wn(n,e){if(e===void 0)return t=>Wn(n,t);if(i(n))return Dn(n,e);if(s(n))return Un(n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function Hn(n,e){if(e!==null)return e===void 0?t=>Hn(n,t):e[n]}function Se(n,e){return e===void 0?t=>l(n,t):t=>l(n,e,t)}function Jn(n){let e=0;return R(()=>e++,n),e}async function Kn(n){let e=0;return await R(()=>e++,n),e}function ve(n){if(i(n))return Jn(n);if(s(n))return Kn(n);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function Q(n,e){if(e===void 0)return t=>Q(n,t);if(P(e))return e.sort(n);if(i(e))return x(S(e),t=>t.sort(n));if(s(e))return x(S(e),t=>t.sort(n));throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function Vn(n,e){if(e===void 0)return r=>Vn(n,r);const t=(r,o)=>{const u=n(r),f=n(o);return uf?1:0};if(P(e))return e.sort(t);if(i(e)||s(e))return Q(t,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function Xn(n,e,t){return on(t)?r=>Xn(n,e,r):n(t)?e(t):t}function*Yn(n,e){yield*e,yield n}function Z(n,e){const t=e[Symbol.asyncIterator]();let r=!1;return{[Symbol.asyncIterator](){return this},async next(){if(r)return{done:!0,value:void 0};const{value:o,done:u}=await t.next();return r?{done:!0,value:void 0}:u?(r=!0,{done:!1,value:await n}):{done:u,value:o}}}}function Zn(n,e){let t=null;return{[Symbol.asyncIterator](){return this},async next(r){return t===null&&(t=A(r)?Z(n,v(r.length,e)):Z(n,e)),t.next(r)}}}function fn(n,e){if(e===void 0)return t=>fn(n,t);if(s(e))return Zn(h(n)?n:Promise.resolve(n),e);if(i(e))return Yn(n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function xe(n){if(i(n)||s(n))return $(U,n);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function*jn(n,e){yield*n,yield*e}function _n(n,e){let t=!1;const r=n[Symbol.asyncIterator](),o=e[Symbol.asyncIterator]();return{[Symbol.asyncIterator](){return this},async next(u){const f=t?o:r,{done:d,value:m}=await f.next(u);return d?(f===r&&(t=!0),o.next(u)):{done:d,value:m}}}}function j(n){if(s(n))return n;const e=n[Symbol.iterator]();return{[Symbol.asyncIterator](){return e}}}function cn(n,e){if(e===void 0)return t=>cn(n,t);if(s(n)||s(e))return _n(j(n),j(e));if(i(n)&&i(e))return jn(n,e);throw new TypeError("'iterable1','iterable2' must be type of Iterable or AsyncIterable")}function G(n,e){if(e===void 0)return o=>G(n,o);const t=new Set,r=o=>t.has(o)?!1:(t.add(o),!0);if(i(e))return I(e,$(o=>x(n(o),r)));if(s(e))return I(e,$(o=>x(n(o),r)));throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function Ae(n){if(i(n)||s(n))return G(O,n);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function*Ee(n){if(n instanceof Map)for(const e of n.entries())yield e;else if(n instanceof Set)for(const e of n)yield[e,e];else for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&(yield[e,n[e]])}const D=function(n){return typeof n!="string"&&i(n)};function yn(n,e){const r=[n[Symbol.iterator]()];return{[Symbol.iterator](){return this},next(){for(;r.length>0;){const o=un(r),{value:u,done:f}=o.next();if(f){r.pop();continue}if(D(u)&&r.length{const{done:c,value:a}=await t.next();return c?!1:(D(a)?o=cn(yn(a,e-1),o):o=fn(a,o),!0)},m=async()=>{if(u)return{done:!0,value:void 0};const{value:c,done:a}=o.next();return a?await d()?m():{done:!0,value:void 0}:{done:!1,value:c}},T=({done:c,value:a})=>{if(c||u){for(;f.length>0;){const[w]=f.shift();w({done:!0,value:void 0})}return}const[y]=f.shift();y({done:c,value:a})},b=c=>{u=!0;const[a,y]=f.shift();y(c)};return{[Symbol.asyncIterator](){return this},async next(){return new Promise((c,a)=>{f.push([c,a]),r=r.then(()=>m()).then(T).catch(b)})}}}function ee(n,e){const r=[n[Symbol.asyncIterator]()];return{[Symbol.asyncIterator](){return this},async next(){const o=un(r);if(!o)return{done:!0,value:void 0};const{value:u,done:f}=await o.next();return f?(r.pop(),this.next()):D(u)&&r.lengthre(n,t);if(i(e))return _(p(t=>L(n(t)),e));if(s(e))return _(p(n,e));throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function*$e(n){if(n instanceof Map)for(const e of n.keys())yield e;else if(n instanceof Set)for(const e of n)yield e;else for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&(yield e)}function oe(n,e){if(e===void 0)return t=>oe(n,t);if(i(e))return p(t=>t[n],e);if(s(e))return p(t=>t[n],e);throw new TypeError("iterable must be type of Iterable or AsyncIterable")}function*ue(n,e){yield n,yield*e}function se(n,e){let t=!0;const r=e[Symbol.asyncIterator]();return{[Symbol.asyncIterator](){return this},async next(o){return t?(t=!1,{done:!1,value:await n}):r.next(o)}}}function ie(n,e){if(e===void 0)return t=>ie(n,t);if(s(e))return se(h(n)?n:Promise.resolve(n),e);if(i(e))return ue(n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function*fe(n){const e=P(n)||E(n)?n:S(n);for(let t=e.length-1;t>=0;t--)yield e[t]}async function*nn(n){const e=await S(n);for(let t=e.length-1;t>=0;t--)yield e[t]}function ce(n){let e;return{[Symbol.asyncIterator](){return this},async next(t){return e===void 0&&(e=A(t)?nn(v(t.length,n)):nn(n)),e.next(t)}}}function ge(n){if(i(n))return fe(n);if(s(n))return ce(n);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function*ye(n,e){let t="",r="";for(r of e)r===n?(yield t,t=""):t+=r;r===n?yield"":t.length>0&&(yield t)}async function*en(n,e){let t="",r="";for await(r of e)r===n?(yield t,t=""):t+=r;r===n?yield"":t.length>0&&(yield t)}function ae(n,e){let t;return{async next(r){return t===void 0&&(t=A(r)?en(n,v(r.length,e)):en(n,e)),t.next(r)},[Symbol.asyncIterator](){return this}}}function le(n,e){if(e===void 0)return t=>le(n,t);if(i(e))return ye(n,e);if(s(e))return ae(n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function*de(n,e){const t=P(e)||E(e)?e:S(e),r=t.length-n;for(let o=r;owe(n,t);if(i(e))return de(n,e);if(s(e))return he(n,e);throw new TypeError("'iterable' must be type of Iterable or AsyncIterable")}function*Te(n){if(n instanceof Map)for(const e of n.values())yield e;else if(n instanceof Set)for(const e of n)yield e;else for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&(yield n[e])}export{ie as A,cn as B,xn as C,V as D,Pn as E,G as F,ve as G,Te as H,Q as I,_ as J,oe as K,ge as L,pe as M,En as N,un as O,Rn as P,Xn as Q,we as R,Wn as S,wn as T,le as a,re as b,Vn as c,Hn as d,Ee as e,$ as f,zn as g,X as h,N as i,Ln as j,fn as k,xe as l,p as m,on as n,Fn as o,I as p,Ie as q,M as r,F as s,S as t,Ae as u,P as v,me as w,Se as x,Nn as y,$e as z};