@local-logic/types 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export type { SDKPropsMappings, SDKProps } from "@local-logic/sdks-app";
2
- export { ChannelEvents } from "@local-logic/channel";
1
+ export type { SDKPropsMappings, SDKProps } from '@local-logic/sdks-app';
2
+ export { ChannelEvents } from '@local-logic/channel';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -4,29 +4,29 @@ function T(_) {
4
4
  }
5
5
  var C = { exports: {} };
6
6
  (function(_) {
7
- var b = (() => {
8
- var c = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, E = Object.getOwnPropertyNames, I = Object.getOwnPropertySymbols, y = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable, m = (n, e, r) => e in n ? c(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r, D = (n, e) => {
9
- for (var r in e || (e = {}))
10
- y.call(e, r) && m(n, r, e[r]);
7
+ var m = (() => {
8
+ var u = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, E = Object.getOwnPropertyNames, I = Object.getOwnPropertySymbols, y = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable, b = (n, e, h) => e in n ? u(n, e, { enumerable: !0, configurable: !0, writable: !0, value: h }) : n[e] = h, D = (n, e) => {
9
+ for (var h in e || (e = {}))
10
+ y.call(e, h) && b(n, h, e[h]);
11
11
  if (I)
12
- for (var r of I(e))
13
- L.call(e, r) && m(n, r, e[r]);
12
+ for (var h of I(e))
13
+ L.call(e, h) && b(n, h, e[h]);
14
14
  return n;
15
15
  }, S = (n, e) => {
16
- for (var r in e)
17
- c(n, r, { get: e[r], enumerable: !0 });
18
- }, M = (n, e, r, f) => {
16
+ for (var h in e)
17
+ u(n, h, { get: e[h], enumerable: !0 });
18
+ }, M = (n, e, h, f) => {
19
19
  if (e && typeof e == "object" || typeof e == "function")
20
- for (let d of E(e))
21
- !y.call(n, d) && d !== r && c(n, d, { get: () => e[d], enumerable: !(f = $(e, d)) || f.enumerable });
20
+ for (let p of E(e))
21
+ !y.call(n, p) && p !== h && u(n, p, { get: () => e[p], enumerable: !(f = $(e, p)) || f.enumerable });
22
22
  return n;
23
- }, O = (n) => M(c({}, "__esModule", { value: !0 }), n), i = (n, e, r) => (m(n, typeof e != "symbol" ? e + "" : e, r), r), x = {};
23
+ }, O = (n) => M(u({}, "__esModule", { value: !0 }), n), i = (n, e, h) => (b(n, typeof e != "symbol" ? e + "" : e, h), h), x = {};
24
24
  S(x, {
25
25
  DEFAULT_OPTIONS: () => v,
26
26
  DEFAULT_UUID_LENGTH: () => g,
27
27
  default: () => q
28
28
  });
29
- var B = "5.0.3", g = 6, v = {
29
+ var B = "5.2.0", g = 6, v = {
30
30
  dictionary: "alphanum",
31
31
  shuffle: !0,
32
32
  debug: !1,
@@ -69,22 +69,24 @@ var C = { exports: {} };
69
69
  const s = [...t];
70
70
  if (s[0] = `[short-unique-id] ${t[0]}`, this.debug === !0 && typeof console < "u" && console !== null)
71
71
  return console.log(...s);
72
- }), i(this, "setDictionary", (t, s) => {
72
+ }), i(this, "_normalizeDictionary", (t, s) => {
73
73
  let a;
74
74
  if (t && Array.isArray(t) && t.length > 1)
75
75
  a = t;
76
76
  else {
77
77
  a = [];
78
- let h;
79
- this.dictIndex = h = 0;
78
+ let r;
79
+ this.dictIndex = r = 0;
80
80
  const o = `_${t}_dict_ranges`, l = this._dict_ranges[o];
81
- Object.keys(l).forEach((p) => {
82
- const U = p;
83
- for (this.dictRange = l[U], this.lowerBound = this.dictRange[0], this.upperBound = this.dictRange[1], this.dictIndex = h = this.lowerBound; this.lowerBound <= this.upperBound ? h < this.upperBound : h > this.upperBound; this.dictIndex = this.lowerBound <= this.upperBound ? h += 1 : h -= 1)
81
+ Object.keys(l).forEach((d) => {
82
+ const U = d;
83
+ for (this.dictRange = l[U], this.lowerBound = this.dictRange[0], this.upperBound = this.dictRange[1], this.dictIndex = r = this.lowerBound; this.lowerBound <= this.upperBound ? r < this.upperBound : r > this.upperBound; this.dictIndex = this.lowerBound <= this.upperBound ? r += 1 : r -= 1)
84
84
  a.push(String.fromCharCode(this.dictIndex));
85
85
  });
86
86
  }
87
- s && (a = a.sort(() => Math.random() - 0.5)), this.dict = a, this.dictLength = this.dict.length, this.setCounter(0);
87
+ return s && (a = a.sort(() => Math.random() - 0.5)), a;
88
+ }), i(this, "setDictionary", (t, s) => {
89
+ this.dict = this._normalizeDictionary(t, s), this.dictLength = this.dict.length, this.setCounter(0);
88
90
  }), i(this, "seq", () => this.sequentialUUID()), i(this, "sequentialUUID", () => {
89
91
  let t, s, a = "";
90
92
  t = this.counter;
@@ -93,10 +95,10 @@ var C = { exports: {} };
93
95
  while (t !== 0);
94
96
  return this.counter += 1, a;
95
97
  }), i(this, "rnd", (t = this.uuidLength || g) => this.randomUUID(t)), i(this, "randomUUID", (t = this.uuidLength || g) => {
96
- let s, a, h;
98
+ let s, a, r;
97
99
  if (t === null || typeof t > "u" || t < 1)
98
100
  throw new Error("Invalid UUID Length Provided");
99
- for (s = "", h = 0; h < t; h += 1)
101
+ for (s = "", r = 0; r < t; r += 1)
100
102
  a = parseInt(
101
103
  (Math.random() * this.dictLength).toFixed(0),
102
104
  10
@@ -110,8 +112,8 @@ var C = { exports: {} };
110
112
  };
111
113
  return t.replace(
112
114
  /\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
113
- (h) => {
114
- const o = h.slice(0, 2), l = parseInt(h.slice(2), 10);
115
+ (r) => {
116
+ const o = r.slice(0, 2), l = parseInt(r.slice(2), 10);
115
117
  return o === "$s" ? a[o]().padStart(l, "0") : o === "$t" && s ? a[o](l, s) : a[o](l);
116
118
  }
117
119
  );
@@ -138,7 +140,7 @@ var C = { exports: {} };
138
140
  ].join(`
139
141
  `)
140
142
  );
141
- const h = t - 9, o = Math.round(Math.random() * (h > 15 ? 15 : h)), l = this.randomUUID(h);
143
+ const r = t - 9, o = Math.round(Math.random() * (r > 15 ? 15 : r)), l = this.randomUUID(r);
142
144
  return `${l.substring(0, o)}${a}${l.substring(o)}${o.toString(16)}`;
143
145
  }), i(this, "parseStamp", (t, s) => {
144
146
  if (s && !/t0|t[1-9]\d{1,}/.test(s))
@@ -147,34 +149,37 @@ var C = { exports: {} };
147
149
  /\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
148
150
  (o) => {
149
151
  const l = {
150
- $r: (u) => [...Array(u)].map(() => "r").join(""),
151
- $s: (u) => [...Array(u)].map(() => "s").join(""),
152
- $t: (u) => [...Array(u)].map(() => "t").join("")
153
- }, p = o.slice(0, 2), U = parseInt(o.slice(2), 10);
154
- return l[p](U);
152
+ $r: (c) => [...Array(c)].map(() => "r").join(""),
153
+ $s: (c) => [...Array(c)].map(() => "s").join(""),
154
+ $t: (c) => [...Array(c)].map(() => "t").join("")
155
+ }, d = o.slice(0, 2), U = parseInt(o.slice(2), 10);
156
+ return l[d](U);
155
157
  }
156
158
  ).replace(
157
159
  /^(.*?)(t{8,})(.*)$/g,
158
- (o, l, p) => t.substring(l.length, l.length + p.length)
160
+ (o, l, d) => t.substring(l.length, l.length + d.length)
159
161
  ) : t;
160
162
  if (a.length === 8)
161
163
  return new Date(parseInt(a, 16) * 1e3);
162
164
  if (a.length < 10)
163
165
  throw new Error("Stamp length invalid");
164
- const h = parseInt(a.substring(a.length - 1), 16);
165
- return new Date(parseInt(a.substring(h, h + 8), 16) * 1e3);
166
+ const r = parseInt(a.substring(a.length - 1), 16);
167
+ return new Date(parseInt(a.substring(r, r + 8), 16) * 1e3);
166
168
  }), i(this, "setCounter", (t) => {
167
169
  this.counter = t;
170
+ }), i(this, "validate", (t, s) => {
171
+ const a = s ? this._normalizeDictionary(s) : this.dict;
172
+ return t.split("").every((r) => a.includes(r));
168
173
  });
169
174
  const e = D(D({}, v), n);
170
175
  this.counter = 0, this.debug = !1, this.dict = [], this.version = B;
171
176
  const {
172
- dictionary: r,
177
+ dictionary: h,
173
178
  shuffle: f,
174
- length: d,
179
+ length: p,
175
180
  counter: j
176
181
  } = e;
177
- return this.uuidLength = d, this.setDictionary(r, f), this.setCounter(j), this.debug = e.debug, this.log(this.dict), this.log(
182
+ return this.uuidLength = p, this.setDictionary(h, f), this.setCounter(j), this.debug = e.debug, this.log(this.dict), this.log(
178
183
  `Generator instantiated with Dictionary Size ${this.dictLength} and counter set to ${this.counter}`
179
184
  ), this.log = this.log.bind(this), this.setDictionary = this.setDictionary.bind(this), this.setCounter = this.setCounter.bind(this), this.seq = this.seq.bind(this), this.sequentialUUID = this.sequentialUUID.bind(this), this.rnd = this.rnd.bind(this), this.randomUUID = this.randomUUID.bind(this), this.fmt = this.fmt.bind(this), this.formattedUUID = this.formattedUUID.bind(this), this.availableUUIDs = this.availableUUIDs.bind(this), this.approxMaxBeforeCollision = this.approxMaxBeforeCollision.bind(this), this.collisionProbability = this.collisionProbability.bind(this), this.uniqueness = this.uniqueness.bind(this), this.getVersion = this.getVersion.bind(this), this.stamp = this.stamp.bind(this), this.parseStamp = this.parseStamp.bind(this), this;
180
185
  }
@@ -183,7 +188,7 @@ var C = { exports: {} };
183
188
  var q = w;
184
189
  return O(x);
185
190
  })();
186
- _.exports = b.default, typeof window < "u" && (b = b.default);
191
+ _.exports = m.default, typeof window < "u" && (m = m.default);
187
192
  })(C);
188
193
  var A = C.exports;
189
194
  const F = /* @__PURE__ */ T(A);
@@ -0,0 +1,2 @@
1
+ (function(p,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(p=typeof globalThis<"u"?globalThis:p||self,u(p.LL_Types={}))})(this,function(p){"use strict";var u=(_=>(_.GET_STATE="get-state",_.GET_STATE_RESPONSE="get-state-response",_.SET_STATE="set-state",_.ON_CHANGE="on-change",_.RESIZE="resize",_))(u||{});function E(_){return _&&_.__esModule&&Object.prototype.hasOwnProperty.call(_,"default")?_.default:_}var D={exports:{}};(function(_){var w=(()=>{var f=Object.defineProperty,O=Object.getOwnPropertyDescriptor,T=Object.getOwnPropertyNames,x=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable,U=(h,e,n)=>e in h?f(h,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):h[e]=n,C=(h,e)=>{for(var n in e||(e={}))v.call(e,n)&&U(h,n,e[n]);if(x)for(var n of x(e))B.call(e,n)&&U(h,n,e[n]);return h},j=(h,e)=>{for(var n in e)f(h,n,{get:e[n],enumerable:!0})},q=(h,e,n,b)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of T(e))!v.call(h,d)&&d!==n&&f(h,d,{get:()=>e[d],enumerable:!(b=O(e,d))||b.enumerable});return h},P=h=>q(f({},"__esModule",{value:!0}),h),i=(h,e,n)=>(U(h,typeof e!="symbol"?e+"":e,n),n),L={};j(L,{DEFAULT_OPTIONS:()=>$,DEFAULT_UUID_LENGTH:()=>m,default:()=>F});var A="5.2.0",m=6,$={dictionary:"alphanum",shuffle:!0,debug:!1,length:m,counter:0},y=class{constructor(h={}){i(this,"counter"),i(this,"debug"),i(this,"dict"),i(this,"version"),i(this,"dictIndex",0),i(this,"dictRange",[]),i(this,"lowerBound",0),i(this,"upperBound",0),i(this,"dictLength",0),i(this,"uuidLength"),i(this,"_digit_first_ascii",48),i(this,"_digit_last_ascii",58),i(this,"_alpha_lower_first_ascii",97),i(this,"_alpha_lower_last_ascii",123),i(this,"_hex_last_ascii",103),i(this,"_alpha_upper_first_ascii",65),i(this,"_alpha_upper_last_ascii",91),i(this,"_number_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii]}),i(this,"_alpha_dict_ranges",{lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_alpha_lower_dict_ranges",{lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]}),i(this,"_alpha_upper_dict_ranges",{upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_alphanum_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_alphanum_lower_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]}),i(this,"_alphanum_upper_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_hex_dict_ranges",{decDigits:[this._digit_first_ascii,this._digit_last_ascii],alphaDigits:[this._alpha_lower_first_ascii,this._hex_last_ascii]}),i(this,"_dict_ranges",{_number_dict_ranges:this._number_dict_ranges,_alpha_dict_ranges:this._alpha_dict_ranges,_alpha_lower_dict_ranges:this._alpha_lower_dict_ranges,_alpha_upper_dict_ranges:this._alpha_upper_dict_ranges,_alphanum_dict_ranges:this._alphanum_dict_ranges,_alphanum_lower_dict_ranges:this._alphanum_lower_dict_ranges,_alphanum_upper_dict_ranges:this._alphanum_upper_dict_ranges,_hex_dict_ranges:this._hex_dict_ranges}),i(this,"log",(...t)=>{const s=[...t];if(s[0]=`[short-unique-id] ${t[0]}`,this.debug===!0&&typeof console<"u"&&console!==null)return console.log(...s)}),i(this,"_normalizeDictionary",(t,s)=>{let a;if(t&&Array.isArray(t)&&t.length>1)a=t;else{a=[];let r;this.dictIndex=r=0;const o=`_${t}_dict_ranges`,l=this._dict_ranges[o];Object.keys(l).forEach(c=>{const I=c;for(this.dictRange=l[I],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=r=this.lowerBound;this.lowerBound<=this.upperBound?r<this.upperBound:r>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?r+=1:r-=1)a.push(String.fromCharCode(this.dictIndex))})}return s&&(a=a.sort(()=>Math.random()-.5)),a}),i(this,"setDictionary",(t,s)=>{this.dict=this._normalizeDictionary(t,s),this.dictLength=this.dict.length,this.setCounter(0)}),i(this,"seq",()=>this.sequentialUUID()),i(this,"sequentialUUID",()=>{let t,s,a="";t=this.counter;do s=t%this.dictLength,t=Math.trunc(t/this.dictLength),a+=this.dict[s];while(t!==0);return this.counter+=1,a}),i(this,"rnd",(t=this.uuidLength||m)=>this.randomUUID(t)),i(this,"randomUUID",(t=this.uuidLength||m)=>{let s,a,r;if(t===null||typeof t>"u"||t<1)throw new Error("Invalid UUID Length Provided");for(s="",r=0;r<t;r+=1)a=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,s+=this.dict[a];return s}),i(this,"fmt",(t,s)=>this.formattedUUID(t,s)),i(this,"formattedUUID",(t,s)=>{const a={$r:this.randomUUID,$s:this.sequentialUUID,$t:this.stamp};return t.replace(/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,r=>{const o=r.slice(0,2),l=parseInt(r.slice(2),10);return o==="$s"?a[o]().padStart(l,"0"):o==="$t"&&s?a[o](l,s):a[o](l)})}),i(this,"availableUUIDs",(t=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,t).toFixed(0))),i(this,"approxMaxBeforeCollision",(t=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*t).toFixed(20))),i(this,"collisionProbability",(t=this.availableUUIDs(this.uuidLength),s=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(t)/this.availableUUIDs(s)).toFixed(20))),i(this,"uniqueness",(t=this.availableUUIDs(this.uuidLength))=>{const s=parseFloat((1-this.approxMaxBeforeCollision(t)/t).toFixed(20));return s>1?1:s<0?0:s}),i(this,"getVersion",()=>this.version),i(this,"stamp",(t,s)=>{const a=Math.floor(+(s||new Date)/1e3).toString(16);if(typeof t=="number"&&t===0)return a;if(typeof t!="number"||t<10)throw new Error(["Param finalLength must be a number greater than or equal to 10,","or 0 if you want the raw hexadecimal timestamp"].join(`
2
+ `));const r=t-9,o=Math.round(Math.random()*(r>15?15:r)),l=this.randomUUID(r);return`${l.substring(0,o)}${a}${l.substring(o)}${o.toString(16)}`}),i(this,"parseStamp",(t,s)=>{if(s&&!/t0|t[1-9]\d{1,}/.test(s))throw new Error("Cannot extract date from a formated UUID with no timestamp in the format");const a=s?s.replace(/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,o=>{const l={$r:g=>[...Array(g)].map(()=>"r").join(""),$s:g=>[...Array(g)].map(()=>"s").join(""),$t:g=>[...Array(g)].map(()=>"t").join("")},c=o.slice(0,2),I=parseInt(o.slice(2),10);return l[c](I)}).replace(/^(.*?)(t{8,})(.*)$/g,(o,l,c)=>t.substring(l.length,l.length+c.length)):t;if(a.length===8)return new Date(parseInt(a,16)*1e3);if(a.length<10)throw new Error("Stamp length invalid");const r=parseInt(a.substring(a.length-1),16);return new Date(parseInt(a.substring(r,r+8),16)*1e3)}),i(this,"setCounter",t=>{this.counter=t}),i(this,"validate",(t,s)=>{const a=s?this._normalizeDictionary(s):this.dict;return t.split("").every(r=>a.includes(r))});const e=C(C({},$),h);this.counter=0,this.debug=!1,this.dict=[],this.version=A;const{dictionary:n,shuffle:b,length:d,counter:R}=e;return this.uuidLength=d,this.setDictionary(n,b),this.setCounter(R),this.debug=e.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength} and counter set to ${this.counter}`),this.log=this.log.bind(this),this.setDictionary=this.setDictionary.bind(this),this.setCounter=this.setCounter.bind(this),this.seq=this.seq.bind(this),this.sequentialUUID=this.sequentialUUID.bind(this),this.rnd=this.rnd.bind(this),this.randomUUID=this.randomUUID.bind(this),this.fmt=this.fmt.bind(this),this.formattedUUID=this.formattedUUID.bind(this),this.availableUUIDs=this.availableUUIDs.bind(this),this.approxMaxBeforeCollision=this.approxMaxBeforeCollision.bind(this),this.collisionProbability=this.collisionProbability.bind(this),this.uniqueness=this.uniqueness.bind(this),this.getVersion=this.getVersion.bind(this),this.stamp=this.stamp.bind(this),this.parseStamp=this.parseStamp.bind(this),this}};i(y,"default",y);var F=y;return P(L)})();_.exports=w.default,typeof window<"u"&&(w=w.default)})(D);var S=D.exports;const M=E(S);new M({length:10}),p.ChannelEvents=u,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@local-logic/types",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "author": "Local Logic",
5
+ "type": "module",
5
6
  "publishConfig": {
6
7
  "access": "public"
7
8
  },
@@ -21,17 +22,15 @@
21
22
  "devDependencies": {
22
23
  "@local-logic/channel": "*",
23
24
  "@local-logic/client": "*",
24
- "@local-logic/elements-react": "*",
25
25
  "@local-logic/eslint-config": "*",
26
- "@local-logic/lat-client": "*",
27
26
  "@local-logic/sdks-app": "*",
28
- "eslint": "^8.53.0",
29
- "prettier": "^3.1.0",
30
- "rollup-plugin-visualizer": "^5.9.2",
27
+ "eslint": "^8.57.1",
28
+ "prettier": "^3.3.3",
29
+ "rollup-plugin-visualizer": "^5.12.0",
31
30
  "tsconfig": "*",
32
- "typescript": "^5.2.2",
33
- "vite": "^4.5.0",
34
- "vite-plugin-dts": "^3.6.3",
35
- "vitest": "^0.34.6"
31
+ "typescript": "^5.6.3",
32
+ "vite": "^5.4.12",
33
+ "vite-plugin-dts": "^4.3.0",
34
+ "vitest": "^2.1.9"
36
35
  }
37
36
  }
package/dist/index.umd.js DELETED
@@ -1,2 +0,0 @@
1
- (function(p,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(p=typeof globalThis<"u"?globalThis:p||self,u(p.LL_Types={}))})(this,function(p){"use strict";var u=(_=>(_.GET_STATE="get-state",_.GET_STATE_RESPONSE="get-state-response",_.SET_STATE="set-state",_.ON_CHANGE="on-change",_.RESIZE="resize",_))(u||{});function E(_){return _&&_.__esModule&&Object.prototype.hasOwnProperty.call(_,"default")?_.default:_}var D={exports:{}};(function(_){var w=(()=>{var f=Object.defineProperty,O=Object.getOwnPropertyDescriptor,T=Object.getOwnPropertyNames,x=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable,U=(n,e,r)=>e in n?f(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r,C=(n,e)=>{for(var r in e||(e={}))v.call(e,r)&&U(n,r,e[r]);if(x)for(var r of x(e))B.call(e,r)&&U(n,r,e[r]);return n},j=(n,e)=>{for(var r in e)f(n,r,{get:e[r],enumerable:!0})},q=(n,e,r,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of T(e))!v.call(n,d)&&d!==r&&f(n,d,{get:()=>e[d],enumerable:!(m=O(e,d))||m.enumerable});return n},P=n=>q(f({},"__esModule",{value:!0}),n),i=(n,e,r)=>(U(n,typeof e!="symbol"?e+"":e,r),r),L={};j(L,{DEFAULT_OPTIONS:()=>$,DEFAULT_UUID_LENGTH:()=>b,default:()=>F});var A="5.0.3",b=6,$={dictionary:"alphanum",shuffle:!0,debug:!1,length:b,counter:0},y=class{constructor(n={}){i(this,"counter"),i(this,"debug"),i(this,"dict"),i(this,"version"),i(this,"dictIndex",0),i(this,"dictRange",[]),i(this,"lowerBound",0),i(this,"upperBound",0),i(this,"dictLength",0),i(this,"uuidLength"),i(this,"_digit_first_ascii",48),i(this,"_digit_last_ascii",58),i(this,"_alpha_lower_first_ascii",97),i(this,"_alpha_lower_last_ascii",123),i(this,"_hex_last_ascii",103),i(this,"_alpha_upper_first_ascii",65),i(this,"_alpha_upper_last_ascii",91),i(this,"_number_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii]}),i(this,"_alpha_dict_ranges",{lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_alpha_lower_dict_ranges",{lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]}),i(this,"_alpha_upper_dict_ranges",{upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_alphanum_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_alphanum_lower_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]}),i(this,"_alphanum_upper_dict_ranges",{digits:[this._digit_first_ascii,this._digit_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]}),i(this,"_hex_dict_ranges",{decDigits:[this._digit_first_ascii,this._digit_last_ascii],alphaDigits:[this._alpha_lower_first_ascii,this._hex_last_ascii]}),i(this,"_dict_ranges",{_number_dict_ranges:this._number_dict_ranges,_alpha_dict_ranges:this._alpha_dict_ranges,_alpha_lower_dict_ranges:this._alpha_lower_dict_ranges,_alpha_upper_dict_ranges:this._alpha_upper_dict_ranges,_alphanum_dict_ranges:this._alphanum_dict_ranges,_alphanum_lower_dict_ranges:this._alphanum_lower_dict_ranges,_alphanum_upper_dict_ranges:this._alphanum_upper_dict_ranges,_hex_dict_ranges:this._hex_dict_ranges}),i(this,"log",(...t)=>{const s=[...t];if(s[0]=`[short-unique-id] ${t[0]}`,this.debug===!0&&typeof console<"u"&&console!==null)return console.log(...s)}),i(this,"setDictionary",(t,s)=>{let a;if(t&&Array.isArray(t)&&t.length>1)a=t;else{a=[];let h;this.dictIndex=h=0;const o=`_${t}_dict_ranges`,l=this._dict_ranges[o];Object.keys(l).forEach(c=>{const I=c;for(this.dictRange=l[I],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=h=this.lowerBound;this.lowerBound<=this.upperBound?h<this.upperBound:h>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?h+=1:h-=1)a.push(String.fromCharCode(this.dictIndex))})}s&&(a=a.sort(()=>Math.random()-.5)),this.dict=a,this.dictLength=this.dict.length,this.setCounter(0)}),i(this,"seq",()=>this.sequentialUUID()),i(this,"sequentialUUID",()=>{let t,s,a="";t=this.counter;do s=t%this.dictLength,t=Math.trunc(t/this.dictLength),a+=this.dict[s];while(t!==0);return this.counter+=1,a}),i(this,"rnd",(t=this.uuidLength||b)=>this.randomUUID(t)),i(this,"randomUUID",(t=this.uuidLength||b)=>{let s,a,h;if(t===null||typeof t>"u"||t<1)throw new Error("Invalid UUID Length Provided");for(s="",h=0;h<t;h+=1)a=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,s+=this.dict[a];return s}),i(this,"fmt",(t,s)=>this.formattedUUID(t,s)),i(this,"formattedUUID",(t,s)=>{const a={$r:this.randomUUID,$s:this.sequentialUUID,$t:this.stamp};return t.replace(/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,h=>{const o=h.slice(0,2),l=parseInt(h.slice(2),10);return o==="$s"?a[o]().padStart(l,"0"):o==="$t"&&s?a[o](l,s):a[o](l)})}),i(this,"availableUUIDs",(t=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,t).toFixed(0))),i(this,"approxMaxBeforeCollision",(t=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*t).toFixed(20))),i(this,"collisionProbability",(t=this.availableUUIDs(this.uuidLength),s=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(t)/this.availableUUIDs(s)).toFixed(20))),i(this,"uniqueness",(t=this.availableUUIDs(this.uuidLength))=>{const s=parseFloat((1-this.approxMaxBeforeCollision(t)/t).toFixed(20));return s>1?1:s<0?0:s}),i(this,"getVersion",()=>this.version),i(this,"stamp",(t,s)=>{const a=Math.floor(+(s||new Date)/1e3).toString(16);if(typeof t=="number"&&t===0)return a;if(typeof t!="number"||t<10)throw new Error(["Param finalLength must be a number greater than or equal to 10,","or 0 if you want the raw hexadecimal timestamp"].join(`
2
- `));const h=t-9,o=Math.round(Math.random()*(h>15?15:h)),l=this.randomUUID(h);return`${l.substring(0,o)}${a}${l.substring(o)}${o.toString(16)}`}),i(this,"parseStamp",(t,s)=>{if(s&&!/t0|t[1-9]\d{1,}/.test(s))throw new Error("Cannot extract date from a formated UUID with no timestamp in the format");const a=s?s.replace(/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,o=>{const l={$r:g=>[...Array(g)].map(()=>"r").join(""),$s:g=>[...Array(g)].map(()=>"s").join(""),$t:g=>[...Array(g)].map(()=>"t").join("")},c=o.slice(0,2),I=parseInt(o.slice(2),10);return l[c](I)}).replace(/^(.*?)(t{8,})(.*)$/g,(o,l,c)=>t.substring(l.length,l.length+c.length)):t;if(a.length===8)return new Date(parseInt(a,16)*1e3);if(a.length<10)throw new Error("Stamp length invalid");const h=parseInt(a.substring(a.length-1),16);return new Date(parseInt(a.substring(h,h+8),16)*1e3)}),i(this,"setCounter",t=>{this.counter=t});const e=C(C({},$),n);this.counter=0,this.debug=!1,this.dict=[],this.version=A;const{dictionary:r,shuffle:m,length:d,counter:R}=e;return this.uuidLength=d,this.setDictionary(r,m),this.setCounter(R),this.debug=e.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength} and counter set to ${this.counter}`),this.log=this.log.bind(this),this.setDictionary=this.setDictionary.bind(this),this.setCounter=this.setCounter.bind(this),this.seq=this.seq.bind(this),this.sequentialUUID=this.sequentialUUID.bind(this),this.rnd=this.rnd.bind(this),this.randomUUID=this.randomUUID.bind(this),this.fmt=this.fmt.bind(this),this.formattedUUID=this.formattedUUID.bind(this),this.availableUUIDs=this.availableUUIDs.bind(this),this.approxMaxBeforeCollision=this.approxMaxBeforeCollision.bind(this),this.collisionProbability=this.collisionProbability.bind(this),this.uniqueness=this.uniqueness.bind(this),this.getVersion=this.getVersion.bind(this),this.stamp=this.stamp.bind(this),this.parseStamp=this.parseStamp.bind(this),this}};i(y,"default",y);var F=y;return P(L)})();_.exports=w.default,typeof window<"u"&&(w=w.default)})(D);var S=D.exports;const M=E(S);new M({length:10}),p.ChannelEvents=u,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});