@jant/core 0.2.7 → 0.2.9
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/plugin.d.ts +3 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +20 -0
- package/package.json +4 -18
- package/src/plugin.ts +26 -0
- package/dist/assets/datastar.min.js +0 -1775
- package/dist/client/.vite/manifest.json +0 -17
- package/dist/client/assets/client-DKznU4dt.js +0 -3434
- package/dist/client/assets/style-D2PQnJEV.css +0 -2
- package/dist/client.d.ts +0 -12
- package/dist/client.d.ts.map +0 -1
- package/dist/jant/.dev.vars +0 -1
- package/dist/jant/.vite/manifest.json +0 -58
- package/dist/jant/assets/bun-sqlite-dialect-B0Ne_8k6.js +0 -155
- package/dist/jant/assets/index-Cg7EsRQZ.js +0 -212
- package/dist/jant/assets/index-RJeuizBo.js +0 -295
- package/dist/jant/assets/node-sqlite-dialect-bZ-6E1mH.js +0 -155
- package/dist/jant/assets/worker-entry-DWNZHBc4.js +0 -66717
- package/dist/jant/index.js +0 -2
- package/dist/jant/wrangler.json +0 -1
- package/dist/lib/assets.d.ts +0 -21
- package/dist/lib/assets.d.ts.map +0 -1
- package/dist/lib/assets.js +0 -29
- package/dist/lib/image-processor.d.ts +0 -30
- package/dist/lib/image-processor.d.ts.map +0 -1
- package/dist/theme/styles/main.css +0 -2
- package/src/style.css +0 -13
|
@@ -1,1775 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minified by jsDelivr using Terser v5.19.2.
|
|
3
|
-
* Original file: /npm/@sudodevnull/datastar@0.19.9/dist/datastar.js
|
|
4
|
-
*
|
|
5
|
-
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
6
|
-
*/ function ze(e) {
|
|
7
|
-
return e instanceof HTMLElement || e instanceof SVGElement ? e : null;
|
|
8
|
-
}
|
|
9
|
-
function ue() {
|
|
10
|
-
throw new Error("Cycle detected");
|
|
11
|
-
}
|
|
12
|
-
function Et() {
|
|
13
|
-
throw new Error("Computed cannot have side-effects");
|
|
14
|
-
}
|
|
15
|
-
const _t = Symbol.for("preact-signals"), O = 1, B = 2, Y = 4, W = 8, J = 16, H = 32;
|
|
16
|
-
function fe() {
|
|
17
|
-
G++;
|
|
18
|
-
}
|
|
19
|
-
function de() {
|
|
20
|
-
if (G > 1) return void G--;
|
|
21
|
-
let e, t = !1;
|
|
22
|
-
for(; void 0 !== K;){
|
|
23
|
-
let n = K;
|
|
24
|
-
for(K = void 0, we++; void 0 !== n;){
|
|
25
|
-
const s = n._nextBatchedEffect;
|
|
26
|
-
if (n._nextBatchedEffect = void 0, n._flags &= ~B, !(n._flags & W) && Qe(n)) try {
|
|
27
|
-
n._callback();
|
|
28
|
-
} catch (n) {
|
|
29
|
-
t || (e = n, t = !0);
|
|
30
|
-
}
|
|
31
|
-
n = s;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (we = 0, G--, t) throw e;
|
|
35
|
-
}
|
|
36
|
-
function St(e) {
|
|
37
|
-
if (G > 0) return e();
|
|
38
|
-
fe();
|
|
39
|
-
try {
|
|
40
|
-
return e();
|
|
41
|
-
} finally{
|
|
42
|
-
de();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
let _, K, G = 0, we = 0, le = 0;
|
|
46
|
-
function Ze(e) {
|
|
47
|
-
if (void 0 === _) return;
|
|
48
|
-
let t = e._node;
|
|
49
|
-
return void 0 === t || t._target !== _ ? (t = {
|
|
50
|
-
_version: 0,
|
|
51
|
-
_source: e,
|
|
52
|
-
_prevSource: _._sources,
|
|
53
|
-
_nextSource: void 0,
|
|
54
|
-
_target: _,
|
|
55
|
-
_prevTarget: void 0,
|
|
56
|
-
_nextTarget: void 0,
|
|
57
|
-
_rollbackNode: t
|
|
58
|
-
}, void 0 !== _._sources && (_._sources._nextSource = t), _._sources = t, e._node = t, _._flags & H && e._subscribe(t), t) : -1 === t._version ? (t._version = 0, void 0 !== t._nextSource && (t._nextSource._prevSource = t._prevSource, void 0 !== t._prevSource && (t._prevSource._nextSource = t._nextSource), t._prevSource = _._sources, t._nextSource = void 0, _._sources._nextSource = t, _._sources = t), t) : void 0;
|
|
59
|
-
}
|
|
60
|
-
function T(e) {
|
|
61
|
-
this._value = e, this._version = 0, this._node = void 0, this._targets = void 0;
|
|
62
|
-
}
|
|
63
|
-
function Xe(e) {
|
|
64
|
-
return new T(e);
|
|
65
|
-
}
|
|
66
|
-
function Qe(e) {
|
|
67
|
-
for(let t = e._sources; void 0 !== t; t = t._nextSource)if (t._source._version !== t._version || !t._source._refresh() || t._source._version !== t._version) return !0;
|
|
68
|
-
return !1;
|
|
69
|
-
}
|
|
70
|
-
function et(e) {
|
|
71
|
-
for(let t = e._sources; void 0 !== t; t = t._nextSource){
|
|
72
|
-
const n = t._source._node;
|
|
73
|
-
if (void 0 !== n && (t._rollbackNode = n), t._source._node = t, t._version = -1, void 0 === t._nextSource) {
|
|
74
|
-
e._sources = t;
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function tt(e) {
|
|
80
|
-
let t, n = e._sources;
|
|
81
|
-
for(; void 0 !== n;){
|
|
82
|
-
const e = n._prevSource;
|
|
83
|
-
-1 === n._version ? (n._source._unsubscribe(n), void 0 !== e && (e._nextSource = n._nextSource), void 0 !== n._nextSource && (n._nextSource._prevSource = e)) : t = n, n._source._node = n._rollbackNode, void 0 !== n._rollbackNode && (n._rollbackNode = void 0), n = e;
|
|
84
|
-
}
|
|
85
|
-
e._sources = t;
|
|
86
|
-
}
|
|
87
|
-
function R(e) {
|
|
88
|
-
T.call(this, void 0), this._compute = e, this._sources = void 0, this._globalVersion = le - 1, this._flags = Y;
|
|
89
|
-
}
|
|
90
|
-
function Tt(e) {
|
|
91
|
-
return new R(e);
|
|
92
|
-
}
|
|
93
|
-
function st(e) {
|
|
94
|
-
const t = e._cleanup;
|
|
95
|
-
if (e._cleanup = void 0, "function" == typeof t) {
|
|
96
|
-
fe();
|
|
97
|
-
const n = _;
|
|
98
|
-
_ = void 0;
|
|
99
|
-
try {
|
|
100
|
-
t();
|
|
101
|
-
} catch (t) {
|
|
102
|
-
throw e._flags &= ~O, e._flags |= W, Ne(e), t;
|
|
103
|
-
} finally{
|
|
104
|
-
_ = n, de();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function Ne(e) {
|
|
109
|
-
for(let t = e._sources; void 0 !== t; t = t._nextSource)t._source._unsubscribe(t);
|
|
110
|
-
e._compute = void 0, e._sources = void 0, st(e);
|
|
111
|
-
}
|
|
112
|
-
function At(e) {
|
|
113
|
-
if (_ !== this) throw new Error("Out-of-order effect");
|
|
114
|
-
tt(this), _ = e, this._flags &= ~O, this._flags & W && Ne(this), de();
|
|
115
|
-
}
|
|
116
|
-
function X(e) {
|
|
117
|
-
this._compute = e, this._cleanup = void 0, this._sources = void 0, this._nextBatchedEffect = void 0, this._flags = H;
|
|
118
|
-
}
|
|
119
|
-
function nt(e) {
|
|
120
|
-
const t = new X(e);
|
|
121
|
-
try {
|
|
122
|
-
t._callback();
|
|
123
|
-
} catch (e) {
|
|
124
|
-
throw t._dispose(), e;
|
|
125
|
-
}
|
|
126
|
-
return t._dispose.bind(t);
|
|
127
|
-
}
|
|
128
|
-
T.prototype.brand = _t, T.prototype._refresh = function() {
|
|
129
|
-
return !0;
|
|
130
|
-
}, T.prototype._subscribe = function(e) {
|
|
131
|
-
this._targets !== e && void 0 === e._prevTarget && (e._nextTarget = this._targets, void 0 !== this._targets && (this._targets._prevTarget = e), this._targets = e);
|
|
132
|
-
}, T.prototype._unsubscribe = function(e) {
|
|
133
|
-
if (void 0 !== this._targets) {
|
|
134
|
-
const t = e._prevTarget, n = e._nextTarget;
|
|
135
|
-
void 0 !== t && (t._nextTarget = n, e._prevTarget = void 0), void 0 !== n && (n._prevTarget = t, e._nextTarget = void 0), e === this._targets && (this._targets = n);
|
|
136
|
-
}
|
|
137
|
-
}, T.prototype.subscribe = function(e) {
|
|
138
|
-
const t = this;
|
|
139
|
-
return nt(function() {
|
|
140
|
-
const n = t.value, s = this._flags & H;
|
|
141
|
-
this._flags &= ~H;
|
|
142
|
-
try {
|
|
143
|
-
e(n);
|
|
144
|
-
} finally{
|
|
145
|
-
this._flags |= s;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}, T.prototype.valueOf = function() {
|
|
149
|
-
return this.value;
|
|
150
|
-
}, T.prototype.toString = function() {
|
|
151
|
-
return this.value + "";
|
|
152
|
-
}, T.prototype.toJSON = function() {
|
|
153
|
-
return this.value;
|
|
154
|
-
}, T.prototype.peek = function() {
|
|
155
|
-
return this._value;
|
|
156
|
-
}, Object.defineProperty(T.prototype, "value", {
|
|
157
|
-
get () {
|
|
158
|
-
const e = Ze(this);
|
|
159
|
-
return void 0 !== e && (e._version = this._version), this._value;
|
|
160
|
-
},
|
|
161
|
-
set (e) {
|
|
162
|
-
if (_ instanceof R && Et(), e !== this._value) {
|
|
163
|
-
we > 100 && ue(), this._value = e, this._version++, le++, fe();
|
|
164
|
-
try {
|
|
165
|
-
for(let e = this._targets; void 0 !== e; e = e._nextTarget)e._target._notify();
|
|
166
|
-
} finally{
|
|
167
|
-
de();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}), R.prototype = new T, R.prototype._refresh = function() {
|
|
172
|
-
if (this._flags &= ~B, this._flags & O) return !1;
|
|
173
|
-
if ((this._flags & (Y | H)) === H || (this._flags &= ~Y, this._globalVersion === le)) return !0;
|
|
174
|
-
if (this._globalVersion = le, this._flags |= O, this._version > 0 && !Qe(this)) return this._flags &= ~O, !0;
|
|
175
|
-
const e = _;
|
|
176
|
-
try {
|
|
177
|
-
et(this), _ = this;
|
|
178
|
-
const e = this._compute();
|
|
179
|
-
(this._flags & J || this._value !== e || 0 === this._version) && (this._value = e, this._flags &= ~J, this._version++);
|
|
180
|
-
} catch (e) {
|
|
181
|
-
this._value = e, this._flags |= J, this._version++;
|
|
182
|
-
}
|
|
183
|
-
return _ = e, tt(this), this._flags &= ~O, !0;
|
|
184
|
-
}, R.prototype._subscribe = function(e) {
|
|
185
|
-
if (void 0 === this._targets) {
|
|
186
|
-
this._flags |= Y | H;
|
|
187
|
-
for(let e = this._sources; void 0 !== e; e = e._nextSource)e._source._subscribe(e);
|
|
188
|
-
}
|
|
189
|
-
T.prototype._subscribe.call(this, e);
|
|
190
|
-
}, R.prototype._unsubscribe = function(e) {
|
|
191
|
-
if (void 0 !== this._targets && (T.prototype._unsubscribe.call(this, e), void 0 === this._targets)) {
|
|
192
|
-
this._flags &= ~H;
|
|
193
|
-
for(let e = this._sources; void 0 !== e; e = e._nextSource)e._source._unsubscribe(e);
|
|
194
|
-
}
|
|
195
|
-
}, R.prototype._notify = function() {
|
|
196
|
-
if (!(this._flags & B)) {
|
|
197
|
-
this._flags |= Y | B;
|
|
198
|
-
for(let e = this._targets; void 0 !== e; e = e._nextTarget)e._target._notify();
|
|
199
|
-
}
|
|
200
|
-
}, R.prototype.peek = function() {
|
|
201
|
-
if (this._refresh() || ue(), this._flags & J) throw this._value;
|
|
202
|
-
return this._value;
|
|
203
|
-
}, Object.defineProperty(R.prototype, "value", {
|
|
204
|
-
get () {
|
|
205
|
-
this._flags & O && ue();
|
|
206
|
-
const e = Ze(this);
|
|
207
|
-
if (this._refresh(), void 0 !== e && (e._version = this._version), this._flags & J) throw this._value;
|
|
208
|
-
return this._value;
|
|
209
|
-
}
|
|
210
|
-
}), X.prototype._callback = function() {
|
|
211
|
-
const e = this._start();
|
|
212
|
-
try {
|
|
213
|
-
if (this._flags & W || void 0 === this._compute) return;
|
|
214
|
-
const e = this._compute();
|
|
215
|
-
"function" == typeof e && (this._cleanup = e);
|
|
216
|
-
} finally{
|
|
217
|
-
e();
|
|
218
|
-
}
|
|
219
|
-
}, X.prototype._start = function() {
|
|
220
|
-
this._flags & O && ue(), this._flags |= O, this._flags &= ~W, st(this), et(this), fe();
|
|
221
|
-
const e = _;
|
|
222
|
-
return _ = this, At.bind(this, e);
|
|
223
|
-
}, X.prototype._notify = function() {
|
|
224
|
-
this._flags & B || (this._flags |= B, this._nextBatchedEffect = K, K = this);
|
|
225
|
-
}, X.prototype._dispose = function() {
|
|
226
|
-
this._flags |= W, this._flags & O || Ne(this);
|
|
227
|
-
};
|
|
228
|
-
class rt {
|
|
229
|
-
get value() {
|
|
230
|
-
return Ee(this);
|
|
231
|
-
}
|
|
232
|
-
set value(e) {
|
|
233
|
-
St(()=>Nt(this, e));
|
|
234
|
-
}
|
|
235
|
-
peek() {
|
|
236
|
-
return Ee(this, {
|
|
237
|
-
peek: !0
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
const oe = (e)=>Object.assign(new rt, Object.entries(e).reduce((e, [t, n])=>{
|
|
242
|
-
if ([
|
|
243
|
-
"value",
|
|
244
|
-
"peek"
|
|
245
|
-
].some((e)=>e === t)) throw new Error(`${t} is a reserved property name`);
|
|
246
|
-
return "object" != typeof n || null === n || Array.isArray(n) ? e[t] = Xe(n) : e[t] = oe(n), e;
|
|
247
|
-
}, {})), Nt = (e, t)=>Object.keys(t).forEach((n)=>e[n].value = t[n]), Ee = (e, { peek: t = !1 } = {})=>Object.entries(e).reduce((e, [n, s])=>(s instanceof T ? e[n] = t ? s.peek() : s.value : s instanceof rt && (e[n] = Ee(s, {
|
|
248
|
-
peek: t
|
|
249
|
-
})), e), {});
|
|
250
|
-
function ot(e, t) {
|
|
251
|
-
if ("object" != typeof t || Array.isArray(t) || !t) return t;
|
|
252
|
-
if ("object" == typeof t && void 0 !== t.toJSON && "function" == typeof t.toJSON) return t.toJSON();
|
|
253
|
-
let n = e;
|
|
254
|
-
return "object" != typeof e && (n = {
|
|
255
|
-
...t
|
|
256
|
-
}), Object.keys(t).forEach((e)=>{
|
|
257
|
-
n.hasOwnProperty(e) || (n[e] = t[e]), null === t[e] ? delete n[e] : n[e] = ot(n[e], t[e]);
|
|
258
|
-
}), n;
|
|
259
|
-
}
|
|
260
|
-
const q = "datastar-event", it = "[a-zA-Z_$]+", Lt = it + "[0-9a-zA-Z_$.]*";
|
|
261
|
-
function Le(e, t, n, s = !0) {
|
|
262
|
-
return new RegExp(`(?<whole>\\${e}(?<${t}>${s ? Lt : it})${n})`, "g");
|
|
263
|
-
}
|
|
264
|
-
const kt = {
|
|
265
|
-
regexp: Le("$", "signal", "(?<method>\\([^\\)]*\\))?"),
|
|
266
|
-
replacer: (e)=>{
|
|
267
|
-
const { signal: t, method: n } = e, s = "ctx.store()";
|
|
268
|
-
if (!n?.length) return `${s}.${t}.value`;
|
|
269
|
-
const o = t.split("."), r = o.pop();
|
|
270
|
-
return `${s}.${o.join(".")}.value.${r}${n}`;
|
|
271
|
-
}
|
|
272
|
-
}, Mt = {
|
|
273
|
-
regexp: Le("$\\$", "action", "(?<call>\\((?<args>.*)\\))?"),
|
|
274
|
-
replacer: ({ action: e, args: t })=>{
|
|
275
|
-
const n = [
|
|
276
|
-
"ctx"
|
|
277
|
-
];
|
|
278
|
-
t && n.push(...t.split(",").map((e)=>e.trim()));
|
|
279
|
-
return `ctx.actions.${e}(${n.join(",")})`;
|
|
280
|
-
}
|
|
281
|
-
}, Pt = {
|
|
282
|
-
regexp: Le("~", "ref", "", !1),
|
|
283
|
-
replacer: ({ ref: e })=>`document.querySelector(ctx.store()._dsPlugins.refs.${e})`
|
|
284
|
-
}, $t = [
|
|
285
|
-
Mt,
|
|
286
|
-
kt,
|
|
287
|
-
Pt
|
|
288
|
-
], Ot = {
|
|
289
|
-
prefix: "store",
|
|
290
|
-
removeNewLines: !0,
|
|
291
|
-
preprocessors: {
|
|
292
|
-
pre: [
|
|
293
|
-
{
|
|
294
|
-
regexp: /(?<whole>.+)/g,
|
|
295
|
-
replacer: (e)=>{
|
|
296
|
-
const { whole: t } = e;
|
|
297
|
-
return `Object.assign({...ctx.store()}, ${t})`;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
]
|
|
301
|
-
},
|
|
302
|
-
allowedModifiers: new Set([
|
|
303
|
-
"local",
|
|
304
|
-
"session",
|
|
305
|
-
"ifmissing"
|
|
306
|
-
]),
|
|
307
|
-
onLoad: (e)=>{
|
|
308
|
-
let t = "";
|
|
309
|
-
const n = (n)=>{
|
|
310
|
-
const s = e.store(), o = JSON.stringify(s);
|
|
311
|
-
o !== t && (window.localStorage.setItem(U, o), t = o);
|
|
312
|
-
}, s = e.modifiers.has("local");
|
|
313
|
-
if (s) {
|
|
314
|
-
window.addEventListener(q, n);
|
|
315
|
-
const t = window.localStorage.getItem(U) || "{}", s = JSON.parse(t);
|
|
316
|
-
e.mergeStore(s);
|
|
317
|
-
}
|
|
318
|
-
const o = e.modifiers.has("session"), r = (t)=>{
|
|
319
|
-
const n = e.store(), s = JSON.stringify(n);
|
|
320
|
-
window.sessionStorage.setItem(U, s);
|
|
321
|
-
};
|
|
322
|
-
if (o) {
|
|
323
|
-
window.addEventListener(q, r);
|
|
324
|
-
const t = window.sessionStorage.getItem(U) || "{}", n = JSON.parse(t);
|
|
325
|
-
e.mergeStore(n);
|
|
326
|
-
}
|
|
327
|
-
const i = e.expressionFn(e), a = lt(e.store(), i, e.modifiers.has("ifmissing"));
|
|
328
|
-
return e.mergeStore(a), delete e.el.dataset[e.rawKey], ()=>{
|
|
329
|
-
s && window.removeEventListener(q, n), o && window.removeEventListener(q, r);
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
}, It = {
|
|
333
|
-
prefix: "computed",
|
|
334
|
-
mustNotEmptyKey: !0,
|
|
335
|
-
onLoad: (e)=>(e.store()[e.key] = e.reactivity.computed(()=>e.expressionFn(e)), ()=>{
|
|
336
|
-
delete e.store()[e.key];
|
|
337
|
-
})
|
|
338
|
-
}, Rt = {
|
|
339
|
-
prefix: "ref",
|
|
340
|
-
mustHaveEmptyKey: !0,
|
|
341
|
-
mustNotEmptyExpression: !0,
|
|
342
|
-
bypassExpressionFunctionCreation: ()=>!0,
|
|
343
|
-
onLoad: (e)=>{
|
|
344
|
-
e.upsertIfMissingFromStore("_dsPlugins.refs", {});
|
|
345
|
-
const { el: t, expression: n } = e, s = {
|
|
346
|
-
_dsPlugins: {
|
|
347
|
-
refs: {
|
|
348
|
-
...e.store()._dsPlugins.refs.value,
|
|
349
|
-
[n]: at(t)
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
return e.mergeStore(s), ()=>{
|
|
354
|
-
const t = e.store(), s = {
|
|
355
|
-
...t._dsPlugins.refs.value
|
|
356
|
-
};
|
|
357
|
-
delete s[n], t._dsPlugins.refs = s;
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
}, Ct = [
|
|
361
|
-
Ot,
|
|
362
|
-
It,
|
|
363
|
-
Rt
|
|
364
|
-
];
|
|
365
|
-
function at(e) {
|
|
366
|
-
if (!e) return "null";
|
|
367
|
-
if ("string" == typeof e) return e;
|
|
368
|
-
if (e instanceof Window) return "Window";
|
|
369
|
-
if (e instanceof Document) return "Document";
|
|
370
|
-
if ("BODY" === e.tagName) return "BODY";
|
|
371
|
-
const t = [];
|
|
372
|
-
for(; e.parentElement && "BODY" !== e.tagName;){
|
|
373
|
-
if (e.id) {
|
|
374
|
-
t.unshift("#" + e.getAttribute("id"));
|
|
375
|
-
break;
|
|
376
|
-
}
|
|
377
|
-
{
|
|
378
|
-
let n = 1, s = e;
|
|
379
|
-
for(; s.previousElementSibling; s = s.previousElementSibling, n++);
|
|
380
|
-
t.unshift(e.tagName + ":nth-child(" + n + ")");
|
|
381
|
-
}
|
|
382
|
-
e = e.parentElement;
|
|
383
|
-
}
|
|
384
|
-
return t.join(">");
|
|
385
|
-
}
|
|
386
|
-
function lt(e, t, n) {
|
|
387
|
-
const s = {};
|
|
388
|
-
if (n) for(const n in t){
|
|
389
|
-
const o = e[n]?.value;
|
|
390
|
-
null == o && (s[n] = t[n]);
|
|
391
|
-
}
|
|
392
|
-
else Object.assign(s, t);
|
|
393
|
-
return s;
|
|
394
|
-
}
|
|
395
|
-
const U = "datastar", k = `${U}-`;
|
|
396
|
-
class Dt {
|
|
397
|
-
constructor(e = {}, ...t){
|
|
398
|
-
if (this.plugins = [], this.store = oe({
|
|
399
|
-
_dsPlugins: {}
|
|
400
|
-
}), this.actions = {}, this.refs = {}, this.reactivity = {
|
|
401
|
-
signal: Xe,
|
|
402
|
-
computed: Tt,
|
|
403
|
-
effect: nt
|
|
404
|
-
}, this.parentID = "", this.missingIDNext = 0, this.removals = new Map, this.mergeRemovals = new Array, this.actions = Object.assign(this.actions, e), !(t = [
|
|
405
|
-
...Ct,
|
|
406
|
-
...t
|
|
407
|
-
]).length) throw new Error("No plugins provided");
|
|
408
|
-
const n = new Set;
|
|
409
|
-
for (const e of t){
|
|
410
|
-
if (e.requiredPluginPrefixes) {
|
|
411
|
-
for (const t of e.requiredPluginPrefixes)if (!n.has(t)) throw new Error(`${e.prefix} requires ${t}`);
|
|
412
|
-
}
|
|
413
|
-
this.plugins.push(e), n.add(e.prefix);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
run() {
|
|
417
|
-
new MutationObserver((e, t)=>{
|
|
418
|
-
N("core", "dom", "mutation", document.body, document.body.outerHTML);
|
|
419
|
-
}).observe(document.body, {
|
|
420
|
-
attributes: !0,
|
|
421
|
-
childList: !0,
|
|
422
|
-
subtree: !0
|
|
423
|
-
}), this.plugins.forEach((e)=>{
|
|
424
|
-
e.onGlobalInit && (e.onGlobalInit({
|
|
425
|
-
actions: this.actions,
|
|
426
|
-
reactivity: this.reactivity,
|
|
427
|
-
mergeStore: this.mergeStore.bind(this),
|
|
428
|
-
store: this.store
|
|
429
|
-
}), N("core", "plugins", "registration", "BODY", `On prefix ${e.prefix}`));
|
|
430
|
-
}), this.applyPlugins(document.body);
|
|
431
|
-
}
|
|
432
|
-
cleanupElementRemovals(e) {
|
|
433
|
-
const t = this.removals.get(e);
|
|
434
|
-
if (t) {
|
|
435
|
-
for (const e of t.set)e();
|
|
436
|
-
this.removals.delete(e);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
mergeStore(e) {
|
|
440
|
-
this.mergeRemovals.forEach((e)=>e()), this.mergeRemovals = this.mergeRemovals.slice(0);
|
|
441
|
-
const t = ot(this.store.value, e);
|
|
442
|
-
this.store = oe(t), this.mergeRemovals.push(this.reactivity.effect(()=>{
|
|
443
|
-
N("core", "store", "merged", "STORE", JSON.stringify(this.store.value));
|
|
444
|
-
}));
|
|
445
|
-
}
|
|
446
|
-
removeFromStore(...e) {
|
|
447
|
-
const t = {
|
|
448
|
-
...this.store.value
|
|
449
|
-
};
|
|
450
|
-
for (const n of e){
|
|
451
|
-
const e = n.split(".");
|
|
452
|
-
let s = e[0], o = t;
|
|
453
|
-
for(let t = 1; t < e.length; t++){
|
|
454
|
-
const n = e[t];
|
|
455
|
-
o[s] || (o[s] = {}), o = o[s], s = n;
|
|
456
|
-
}
|
|
457
|
-
delete o[s];
|
|
458
|
-
}
|
|
459
|
-
this.store = oe(t), this.applyPlugins(document.body);
|
|
460
|
-
}
|
|
461
|
-
upsertIfMissingFromStore(e, t) {
|
|
462
|
-
const n = e.split(".");
|
|
463
|
-
let s = this.store;
|
|
464
|
-
for(let e = 0; e < n.length - 1; e++){
|
|
465
|
-
const t = n[e];
|
|
466
|
-
s[t] || (s[t] = {}), s = s[t];
|
|
467
|
-
}
|
|
468
|
-
const o = n[n.length - 1];
|
|
469
|
-
s[o] || (s[o] = this.reactivity.signal(t), N("core", "store", "upsert", e, t));
|
|
470
|
-
}
|
|
471
|
-
signalByName(e) {
|
|
472
|
-
return this.store[e];
|
|
473
|
-
}
|
|
474
|
-
applyPlugins(e) {
|
|
475
|
-
const t = new Set;
|
|
476
|
-
this.plugins.forEach((n, s)=>{
|
|
477
|
-
this.walkDownDOM(e, (e)=>{
|
|
478
|
-
s || this.cleanupElementRemovals(e);
|
|
479
|
-
for(const s in e.dataset){
|
|
480
|
-
const o = e.dataset[s] || "";
|
|
481
|
-
let r = o;
|
|
482
|
-
if (!s.startsWith(n.prefix)) continue;
|
|
483
|
-
if (0 === e.id.length && (e.id = `ds-${this.parentID}-${this.missingIDNext++}`), t.clear(), n.allowedTagRegexps) {
|
|
484
|
-
const t = e.tagName.toLowerCase();
|
|
485
|
-
if (![
|
|
486
|
-
...n.allowedTagRegexps
|
|
487
|
-
].some((e)=>t.match(e))) throw new Error(`'${e.tagName}' not allowed for '${s}', allowed ${[
|
|
488
|
-
[
|
|
489
|
-
...n.allowedTagRegexps
|
|
490
|
-
].map((e)=>`'${e}'`)
|
|
491
|
-
].join(", ")}`);
|
|
492
|
-
}
|
|
493
|
-
let i = s.slice(n.prefix.length), [a, ...l] = i.split(".");
|
|
494
|
-
if (n.mustHaveEmptyKey && a.length > 0) throw new Error(`'${s}' must have empty key`);
|
|
495
|
-
if (n.mustNotEmptyKey && 0 === a.length) throw new Error(`'${s}' must have non-empty key`);
|
|
496
|
-
a.length && (a = a[0].toLowerCase() + a.slice(1));
|
|
497
|
-
const c = l.map((e)=>{
|
|
498
|
-
const [t, ...n] = e.split("_");
|
|
499
|
-
return {
|
|
500
|
-
label: t,
|
|
501
|
-
args: n
|
|
502
|
-
};
|
|
503
|
-
});
|
|
504
|
-
if (n.allowedModifiers) {
|
|
505
|
-
for (const e of c)if (!n.allowedModifiers.has(e.label)) throw new Error(`'${e.label}' is not allowed`);
|
|
506
|
-
}
|
|
507
|
-
const u = new Map;
|
|
508
|
-
for (const e of c)u.set(e.label, e.args);
|
|
509
|
-
if (n.mustHaveEmptyExpression && r.length) throw new Error(`'${s}' must have empty expression`);
|
|
510
|
-
if (n.mustNotEmptyExpression && !r.length) throw new Error(`'${s}' must have non-empty expression`);
|
|
511
|
-
const d = /;|\n/;
|
|
512
|
-
n.removeNewLines && (r = r.split("\n").map((e)=>e.trim()).join(" "));
|
|
513
|
-
const f = [
|
|
514
|
-
...n.preprocessors?.pre || [],
|
|
515
|
-
...$t,
|
|
516
|
-
...n.preprocessors?.post || []
|
|
517
|
-
];
|
|
518
|
-
for (const e of f){
|
|
519
|
-
if (t.has(e)) continue;
|
|
520
|
-
t.add(e);
|
|
521
|
-
const n = r.split(d), s = [];
|
|
522
|
-
n.forEach((t)=>{
|
|
523
|
-
let n = t;
|
|
524
|
-
const o = [
|
|
525
|
-
...n.matchAll(e.regexp)
|
|
526
|
-
];
|
|
527
|
-
if (o.length) for (const t of o){
|
|
528
|
-
if (!t.groups) continue;
|
|
529
|
-
const { groups: s } = t, { whole: o } = s;
|
|
530
|
-
n = n.replace(o, e.replacer(s));
|
|
531
|
-
}
|
|
532
|
-
s.push(n);
|
|
533
|
-
}), r = s.join("; ");
|
|
534
|
-
}
|
|
535
|
-
const h = {
|
|
536
|
-
store: ()=>this.store,
|
|
537
|
-
mergeStore: this.mergeStore.bind(this),
|
|
538
|
-
upsertIfMissingFromStore: this.upsertIfMissingFromStore.bind(this),
|
|
539
|
-
removeFromStore: this.removeFromStore.bind(this),
|
|
540
|
-
applyPlugins: this.applyPlugins.bind(this),
|
|
541
|
-
cleanupElementRemovals: this.cleanupElementRemovals.bind(this),
|
|
542
|
-
walkSignals: this.walkSignals.bind(this),
|
|
543
|
-
actions: this.actions,
|
|
544
|
-
reactivity: this.reactivity,
|
|
545
|
-
el: e,
|
|
546
|
-
rawKey: s,
|
|
547
|
-
key: a,
|
|
548
|
-
rawExpression: o,
|
|
549
|
-
expression: r,
|
|
550
|
-
expressionFn: ()=>{
|
|
551
|
-
throw new Error("Expression function not created");
|
|
552
|
-
},
|
|
553
|
-
modifiers: u,
|
|
554
|
-
sendDatastarEvent: N
|
|
555
|
-
};
|
|
556
|
-
if (!n.bypassExpressionFunctionCreation?.(h) && !n.mustHaveEmptyExpression && r.length) {
|
|
557
|
-
const e = r.split(d).map((e)=>e.trim()).filter((e)=>e.length);
|
|
558
|
-
e[e.length - 1] = `return ${e[e.length - 1]}`;
|
|
559
|
-
const t = e.map((e)=>` ${e}`).join(";\n"), o = `\ntry {\n const _datastarExpression = () => {\n${t}\n }\n const _datastarReturnVal = _datastarExpression()\n ctx.sendDatastarEvent('core', 'attributes', 'expr_eval', ctx.el, '${s} equals ' + JSON.stringify(_datastarReturnVal))\n return _datastarReturnVal\n} catch (e) {\n const msg = \`\nError evaluating Datastar expression:\n${t.replaceAll("`", "\\`")}\n\nError: \${e.message}\n\nCheck if the expression is valid before raising an issue.\n\`.trim()\n ctx.sendDatastarEvent('core', 'attributes', 'expr_eval_err', ctx.el, msg)\n console.error(msg)\n debugger\n}\n `;
|
|
560
|
-
try {
|
|
561
|
-
const e = n.argumentNames || [], t = new Function("ctx", ...e, o);
|
|
562
|
-
h.expressionFn = t;
|
|
563
|
-
} catch (e) {
|
|
564
|
-
const t = new Error(`Error creating expression function for '${o}', error: ${e}`);
|
|
565
|
-
N("core", "attributes", "expr_construction_err", h.el, String(t)), console.error(t);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
const p = n.onLoad(h);
|
|
569
|
-
p && (this.removals.has(e) || this.removals.set(e, {
|
|
570
|
-
id: e.id,
|
|
571
|
-
set: new Set
|
|
572
|
-
}), this.removals.get(e).set.add(p));
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
walkSignalsStore(e, t) {
|
|
578
|
-
const n = Object.keys(e);
|
|
579
|
-
for(let s = 0; s < n.length; s++){
|
|
580
|
-
const o = n[s], r = e[o], i = r instanceof T, a = "object" == typeof r && Object.keys(r).length > 0;
|
|
581
|
-
i ? t(o, r) : a && this.walkSignalsStore(r, t);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
walkSignals(e) {
|
|
585
|
-
this.walkSignalsStore(this.store, e);
|
|
586
|
-
}
|
|
587
|
-
walkDownDOM(e, t, n = 0) {
|
|
588
|
-
if (!e) return;
|
|
589
|
-
const s = ze(e);
|
|
590
|
-
if (s) for(t(s), n = 0, e = e.firstElementChild; e;)this.walkDownDOM(e, t, n++), e = e.nextElementSibling;
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
const ct = (e)=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (e, t)=>(t ? "-" : "") + e.toLowerCase()), Ft = {
|
|
594
|
-
prefix: "bind",
|
|
595
|
-
mustNotEmptyKey: !0,
|
|
596
|
-
mustNotEmptyExpression: !0,
|
|
597
|
-
onLoad: (e)=>e.reactivity.effect(async ()=>{
|
|
598
|
-
const t = ct(e.key), n = e.expressionFn(e);
|
|
599
|
-
let s;
|
|
600
|
-
s = "string" == typeof n ? n : JSON.stringify(n), s && "false" !== s && "null" !== s && "undefined" !== s ? e.el.setAttribute(t, s) : e.el.removeAttribute(t);
|
|
601
|
-
})
|
|
602
|
-
}, Ht = /^data:(?<mime>[^;]+);base64,(?<contents>.*)$/, te = [
|
|
603
|
-
"change",
|
|
604
|
-
"input",
|
|
605
|
-
"keydown"
|
|
606
|
-
], Vt = {
|
|
607
|
-
prefix: "model",
|
|
608
|
-
mustHaveEmptyKey: !0,
|
|
609
|
-
preprocessors: {
|
|
610
|
-
post: [
|
|
611
|
-
{
|
|
612
|
-
regexp: /(?<whole>.+)/g,
|
|
613
|
-
replacer: (e)=>{
|
|
614
|
-
const { whole: t } = e;
|
|
615
|
-
return `ctx.store().${t}`;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
]
|
|
619
|
-
},
|
|
620
|
-
onLoad: (e)=>{
|
|
621
|
-
const { el: t, expression: n } = e, s = e.expressionFn(e), o = t.tagName.toLowerCase();
|
|
622
|
-
if (n.startsWith("ctx.store().ctx.store()")) throw new Error(`Model attribute on #${t.id} must have a signal name, you probably prefixed with $ by accident`);
|
|
623
|
-
const r = o.includes("input"), i = t.getAttribute("type"), a = o.includes("checkbox") || r && "checkbox" === i, l = o.includes("select"), c = o.includes("radio") || r && "radio" === i, u = r && "file" === i, d = n.replaceAll("ctx.store().", "");
|
|
624
|
-
c && (t.getAttribute("name")?.length || t.setAttribute("name", d));
|
|
625
|
-
const f = e.reactivity.effect(()=>{
|
|
626
|
-
if (!s) throw new Error(`Signal ${d} not found`);
|
|
627
|
-
const e = "value" in t, n = s.value;
|
|
628
|
-
if (a || c) {
|
|
629
|
-
const e = t;
|
|
630
|
-
a ? e.checked = n : c && (e.checked = `${n}` === e.value);
|
|
631
|
-
} else if (!u) if (l) {
|
|
632
|
-
const e = t;
|
|
633
|
-
if (e.multiple) {
|
|
634
|
-
const t = s.value;
|
|
635
|
-
Array.from(e.options).forEach((e)=>{
|
|
636
|
-
e?.disabled || (e.selected = t.includes(e.value));
|
|
637
|
-
});
|
|
638
|
-
} else e.value = `${n}`;
|
|
639
|
-
} else e ? t.value = `${n}` : t.setAttribute("value", `${n}`);
|
|
640
|
-
}), h = async ()=>{
|
|
641
|
-
if (u) {
|
|
642
|
-
const n = [
|
|
643
|
-
...t?.files || []
|
|
644
|
-
], o = [], r = [], i = [];
|
|
645
|
-
await Promise.all(n.map((e)=>new Promise((t)=>{
|
|
646
|
-
const n = new FileReader;
|
|
647
|
-
n.onload = ()=>{
|
|
648
|
-
if ("string" != typeof n.result) throw new Error("Invalid result type: " + typeof n.result);
|
|
649
|
-
const t = n.result.match(Ht);
|
|
650
|
-
if (!t?.groups) throw new Error(`Invalid data URI: ${n.result}`);
|
|
651
|
-
o.push(t.groups.contents), r.push(t.groups.mime), i.push(e.name);
|
|
652
|
-
}, n.onloadend = ()=>t(void 0), n.readAsDataURL(e);
|
|
653
|
-
}))), s.value = o;
|
|
654
|
-
const a = e.store(), l = `${d}Mimes`, c = `${d}Names`;
|
|
655
|
-
return l in a && (a[`${l}`].value = r), void (c in a && (a[`${c}`].value = i));
|
|
656
|
-
}
|
|
657
|
-
const n = s.value, o = t || t;
|
|
658
|
-
if ("number" == typeof n) s.value = Number(o.value || o.getAttribute("value"));
|
|
659
|
-
else if ("string" == typeof n) s.value = o.value || o.getAttribute("value") || "";
|
|
660
|
-
else if ("boolean" == typeof n) s.value = a ? o.checked || "true" === o.getAttribute("checked") : !(!o.value && !o.getAttribute("value"));
|
|
661
|
-
else if (!(typeof n > "u")) if ("bigint" == typeof n) s.value = BigInt(o.value || o.getAttribute("value") || "0");
|
|
662
|
-
else {
|
|
663
|
-
if (!Array.isArray(n)) throw console.log(typeof n), new Error(`Unsupported type ${typeof n} for signal ${d}`);
|
|
664
|
-
if (l) {
|
|
665
|
-
const e = [
|
|
666
|
-
...t.selectedOptions
|
|
667
|
-
].map((e)=>e.value);
|
|
668
|
-
s.value = e;
|
|
669
|
-
} else s.value = JSON.parse(o.value).split(",");
|
|
670
|
-
console.log(o.value);
|
|
671
|
-
}
|
|
672
|
-
}, p = t.tagName.split("-");
|
|
673
|
-
if (p.length > 1) {
|
|
674
|
-
const e = p[0].toLowerCase();
|
|
675
|
-
te.forEach((t)=>{
|
|
676
|
-
te.push(`${e}-${t}`);
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
return te.forEach((e)=>t.addEventListener(e, h)), ()=>{
|
|
680
|
-
f(), te.forEach((e)=>t.removeEventListener(e, h));
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
}, xt = {
|
|
684
|
-
prefix: "text",
|
|
685
|
-
mustHaveEmptyKey: !0,
|
|
686
|
-
onLoad: (e)=>{
|
|
687
|
-
const { el: t, expressionFn: n } = e;
|
|
688
|
-
if (!(t instanceof HTMLElement)) throw new Error("Element is not HTMLElement");
|
|
689
|
-
return e.reactivity.effect(()=>{
|
|
690
|
-
const s = n(e);
|
|
691
|
-
t.textContent = `${s}`;
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
};
|
|
695
|
-
let $e = "";
|
|
696
|
-
const jt = new Set([
|
|
697
|
-
"window",
|
|
698
|
-
"once",
|
|
699
|
-
"passive",
|
|
700
|
-
"capture",
|
|
701
|
-
"debounce",
|
|
702
|
-
"throttle",
|
|
703
|
-
"remote",
|
|
704
|
-
"outside"
|
|
705
|
-
]), Ut = {
|
|
706
|
-
prefix: "on",
|
|
707
|
-
mustNotEmptyKey: !0,
|
|
708
|
-
mustNotEmptyExpression: !0,
|
|
709
|
-
argumentNames: [
|
|
710
|
-
"evt"
|
|
711
|
-
],
|
|
712
|
-
onLoad: (e)=>{
|
|
713
|
-
const { el: t, key: n, expressionFn: s } = e;
|
|
714
|
-
let o = e.el;
|
|
715
|
-
e.modifiers.get("window") && (o = window);
|
|
716
|
-
let r = (t)=>{
|
|
717
|
-
N("plugin", "event", n, o, "triggered"), s(e, t);
|
|
718
|
-
};
|
|
719
|
-
const i = e.modifiers.get("debounce");
|
|
720
|
-
if (i) {
|
|
721
|
-
const e = _e(i), t = se(i, "leading", !1), n = se(i, "noTrail", !0);
|
|
722
|
-
r = Jt(r, e, t, n);
|
|
723
|
-
}
|
|
724
|
-
const a = e.modifiers.get("throttle");
|
|
725
|
-
if (a) {
|
|
726
|
-
const e = _e(a), t = se(a, "noLead", !0), n = se(a, "noTrail", !1);
|
|
727
|
-
r = Kt(r, e, t, n);
|
|
728
|
-
}
|
|
729
|
-
const l = {
|
|
730
|
-
capture: !0,
|
|
731
|
-
passive: !1,
|
|
732
|
-
once: !1
|
|
733
|
-
};
|
|
734
|
-
e.modifiers.has("capture") || (l.capture = !1), e.modifiers.has("passive") && (l.passive = !0), e.modifiers.has("once") && (l.once = !0), [
|
|
735
|
-
...e.modifiers.keys()
|
|
736
|
-
].filter((e)=>!jt.has(e)).forEach((s)=>{
|
|
737
|
-
const o = e.modifiers.get(s) || [], i = r;
|
|
738
|
-
r = ()=>{
|
|
739
|
-
const e = event, r = e[s];
|
|
740
|
-
let a;
|
|
741
|
-
if ("function" == typeof r) a = r(...o);
|
|
742
|
-
else if ("boolean" == typeof r) a = r;
|
|
743
|
-
else {
|
|
744
|
-
if ("string" != typeof r) {
|
|
745
|
-
const e = `Invalid value for ${s} modifier on ${n} on ${t}`;
|
|
746
|
-
throw console.error(e), new Error(e);
|
|
747
|
-
}
|
|
748
|
-
a = r.toLowerCase().trim() === o.join("").toLowerCase().trim();
|
|
749
|
-
}
|
|
750
|
-
a && i(e);
|
|
751
|
-
};
|
|
752
|
-
});
|
|
753
|
-
const c = ct(n).toLowerCase();
|
|
754
|
-
switch(c){
|
|
755
|
-
case "load":
|
|
756
|
-
return r(), delete e.el.dataset.onLoad, ()=>{};
|
|
757
|
-
case "raf":
|
|
758
|
-
let n1;
|
|
759
|
-
const s1 = ()=>{
|
|
760
|
-
r(), n1 = requestAnimationFrame(s1);
|
|
761
|
-
};
|
|
762
|
-
return n1 = requestAnimationFrame(s1), ()=>{
|
|
763
|
-
n1 && cancelAnimationFrame(n1);
|
|
764
|
-
};
|
|
765
|
-
case "store-change":
|
|
766
|
-
return e.reactivity.effect(()=>{
|
|
767
|
-
let t = e.store().value;
|
|
768
|
-
e.modifiers.has("remote") && (t = he(t));
|
|
769
|
-
const n = JSON.stringify(t);
|
|
770
|
-
$e !== n && ($e = n, r());
|
|
771
|
-
});
|
|
772
|
-
default:
|
|
773
|
-
if (e.modifiers.has("outside")) {
|
|
774
|
-
o = document;
|
|
775
|
-
const e = r;
|
|
776
|
-
let n = !1;
|
|
777
|
-
r = (s)=>{
|
|
778
|
-
const o = s?.target;
|
|
779
|
-
if (!o) return;
|
|
780
|
-
const r = t.id === o.id;
|
|
781
|
-
r && n && (n = !1), !r && !n && (e(s), n = !0);
|
|
782
|
-
};
|
|
783
|
-
}
|
|
784
|
-
return o.addEventListener(c, r, l), ()=>{
|
|
785
|
-
o.removeEventListener(c, r);
|
|
786
|
-
};
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
};
|
|
790
|
-
function he(e) {
|
|
791
|
-
const t = {};
|
|
792
|
-
for (const [n, s] of Object.entries(e))n.startsWith("_") || ("object" != typeof s || Array.isArray(s) ? t[n] = s : t[n] = he(s));
|
|
793
|
-
return t;
|
|
794
|
-
}
|
|
795
|
-
const Bt = {
|
|
796
|
-
prefix: "class",
|
|
797
|
-
mustHaveEmptyKey: !0,
|
|
798
|
-
mustNotEmptyExpression: !0,
|
|
799
|
-
onLoad: (e)=>e.reactivity.effect(()=>{
|
|
800
|
-
const t = e.expressionFn(e);
|
|
801
|
-
for (const [n, s] of Object.entries(t))s ? e.el.classList.add(n) : e.el.classList.remove(n);
|
|
802
|
-
return ()=>{
|
|
803
|
-
e.el.classList.remove(...Object.keys(t));
|
|
804
|
-
};
|
|
805
|
-
})
|
|
806
|
-
}, Wt = [
|
|
807
|
-
Ft,
|
|
808
|
-
Vt,
|
|
809
|
-
xt,
|
|
810
|
-
Ut,
|
|
811
|
-
Bt
|
|
812
|
-
], qt = {
|
|
813
|
-
remote: async (e)=>he(e.store().value)
|
|
814
|
-
};
|
|
815
|
-
function _e(e) {
|
|
816
|
-
if (!e || 0 === e?.length) return 0;
|
|
817
|
-
for (const t of e){
|
|
818
|
-
if (t.endsWith("ms")) return Number(t.replace("ms", ""));
|
|
819
|
-
if (t.endsWith("s")) return 1e3 * Number(t.replace("s", ""));
|
|
820
|
-
try {
|
|
821
|
-
return parseFloat(t);
|
|
822
|
-
} catch {}
|
|
823
|
-
}
|
|
824
|
-
return 0;
|
|
825
|
-
}
|
|
826
|
-
function se(e, t, n = !1) {
|
|
827
|
-
return !!e && (e.includes(t) || n);
|
|
828
|
-
}
|
|
829
|
-
function Jt(e, t, n = !1, s = !0) {
|
|
830
|
-
let o;
|
|
831
|
-
const r = ()=>o && clearTimeout(o);
|
|
832
|
-
return function(...i) {
|
|
833
|
-
r(), n && !o && e(...i), o = setTimeout(()=>{
|
|
834
|
-
s && e(...i), r();
|
|
835
|
-
}, t);
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
function Kt(e, t, n = !0, s = !1) {
|
|
839
|
-
let o = !1;
|
|
840
|
-
return function(...r) {
|
|
841
|
-
o || (n && e(...r), o = !0, setTimeout(()=>{
|
|
842
|
-
o = !1, s && e(...r);
|
|
843
|
-
}, t));
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
function Gt(e, { signal: t, headers: n, onopen: s, onmessage: o, onclose: r, onerror: i, openWhenHidden: a, ...l }) {
|
|
847
|
-
return new Promise((c, u)=>{
|
|
848
|
-
let d = 0;
|
|
849
|
-
const f = {
|
|
850
|
-
...n
|
|
851
|
-
};
|
|
852
|
-
let h;
|
|
853
|
-
function p() {
|
|
854
|
-
h.abort(), document.hidden || y();
|
|
855
|
-
}
|
|
856
|
-
f.accept || (f.accept = Se), a || document.addEventListener("visibilitychange", p);
|
|
857
|
-
let m = Oe, g = 0;
|
|
858
|
-
function v() {
|
|
859
|
-
document.removeEventListener("visibilitychange", p), window.clearTimeout(g), h.abort();
|
|
860
|
-
}
|
|
861
|
-
t?.addEventListener("abort", ()=>{
|
|
862
|
-
v(), c();
|
|
863
|
-
});
|
|
864
|
-
const b = s ?? Zt;
|
|
865
|
-
async function y() {
|
|
866
|
-
h = new AbortController;
|
|
867
|
-
try {
|
|
868
|
-
const t = await fetch(e, {
|
|
869
|
-
...l,
|
|
870
|
-
headers: f,
|
|
871
|
-
signal: h.signal
|
|
872
|
-
});
|
|
873
|
-
await b(t), await Xt(t.body, Qt(es((e)=>{
|
|
874
|
-
e ? f[Ie] = e : delete f[Ie];
|
|
875
|
-
}, (e)=>{
|
|
876
|
-
m = e;
|
|
877
|
-
}, o))), r?.(), v(), c();
|
|
878
|
-
} catch (e) {
|
|
879
|
-
if (!h.signal.aborted) try {
|
|
880
|
-
const t = i?.(e) ?? m;
|
|
881
|
-
window.clearTimeout(g), g = window.setTimeout(y, t), m *= 1.5, m = Math.min(m, Yt), d++, d >= zt ? (v(), u(new Error("Max retries hit, check your server or network connection."))) : console.error(`Error fetching event source, retrying in ${t}ms`);
|
|
882
|
-
} catch (e) {
|
|
883
|
-
v(), u(e);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
m = Oe, y();
|
|
888
|
-
});
|
|
889
|
-
}
|
|
890
|
-
const Se = "text/event-stream", Oe = 100, Yt = 1e4, zt = 10, Ie = "last-event-id";
|
|
891
|
-
function Zt(e) {
|
|
892
|
-
const t = e.headers.get("content-type");
|
|
893
|
-
if (!t?.startsWith(Se)) throw new Error(`Expected content-type to be ${Se}, Actual: ${t}`);
|
|
894
|
-
}
|
|
895
|
-
async function Xt(e, t) {
|
|
896
|
-
const n = e.getReader();
|
|
897
|
-
for(;;){
|
|
898
|
-
const e = await n.read();
|
|
899
|
-
if (e.done) break;
|
|
900
|
-
t(e.value);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
function Qt(e) {
|
|
904
|
-
let t, n, s, o = !1;
|
|
905
|
-
return function(r) {
|
|
906
|
-
void 0 === t ? (t = r, n = 0, s = -1) : t = ts(t, r);
|
|
907
|
-
const i = t.length;
|
|
908
|
-
let a = 0;
|
|
909
|
-
for(; n < i;){
|
|
910
|
-
o && (10 === t[n] && (a = ++n), o = !1);
|
|
911
|
-
let r = -1;
|
|
912
|
-
for(; n < i && -1 === r; ++n)switch(t[n]){
|
|
913
|
-
case 58:
|
|
914
|
-
-1 === s && (s = n - a);
|
|
915
|
-
break;
|
|
916
|
-
case 13:
|
|
917
|
-
o = !0;
|
|
918
|
-
case 10:
|
|
919
|
-
r = n;
|
|
920
|
-
}
|
|
921
|
-
if (-1 === r) break;
|
|
922
|
-
e(t.subarray(a, r), s), a = n, s = -1;
|
|
923
|
-
}
|
|
924
|
-
a === i ? t = void 0 : 0 !== a && (t = t.subarray(a), n -= a);
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
function es(e, t, n) {
|
|
928
|
-
let s = Re();
|
|
929
|
-
const o = new TextDecoder;
|
|
930
|
-
return function(r, i) {
|
|
931
|
-
if (0 === r.length) n?.(s), s = Re();
|
|
932
|
-
else if (i > 0) {
|
|
933
|
-
const n = o.decode(r.subarray(0, i)), a = i + (32 === r[i + 1] ? 2 : 1), l = o.decode(r.subarray(a));
|
|
934
|
-
switch(n){
|
|
935
|
-
case "data":
|
|
936
|
-
s.data = s.data ? s.data + "\n" + l : l;
|
|
937
|
-
break;
|
|
938
|
-
case "event":
|
|
939
|
-
s.event = l;
|
|
940
|
-
break;
|
|
941
|
-
case "id":
|
|
942
|
-
e(s.id = l);
|
|
943
|
-
break;
|
|
944
|
-
case "retry":
|
|
945
|
-
const n1 = parseInt(l, 10);
|
|
946
|
-
isNaN(n1) || t(s.retry = n1);
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
};
|
|
950
|
-
}
|
|
951
|
-
function ts(e, t) {
|
|
952
|
-
const n = new Uint8Array(e.length + t.length);
|
|
953
|
-
return n.set(e), n.set(t, e.length), n;
|
|
954
|
-
}
|
|
955
|
-
function Re() {
|
|
956
|
-
return {
|
|
957
|
-
data: "",
|
|
958
|
-
event: "",
|
|
959
|
-
id: "",
|
|
960
|
-
retry: void 0
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
const ie = new WeakSet;
|
|
964
|
-
function ss(e, t, n = {}) {
|
|
965
|
-
let s;
|
|
966
|
-
e instanceof Document && (e = e.documentElement), s = "string" == typeof t ? as(t) : t;
|
|
967
|
-
const o = ls(s);
|
|
968
|
-
return ut(e, o, rs(e, o, n));
|
|
969
|
-
}
|
|
970
|
-
function ut(e, t, n) {
|
|
971
|
-
if (n.head.block) {
|
|
972
|
-
const s = e.querySelector("head"), o = t.querySelector("head");
|
|
973
|
-
if (s && o) {
|
|
974
|
-
const r = dt(o, s, n);
|
|
975
|
-
return void Promise.all(r).then(()=>{
|
|
976
|
-
ut(e, t, Object.assign(n, {
|
|
977
|
-
head: {
|
|
978
|
-
block: !1,
|
|
979
|
-
ignore: !0
|
|
980
|
-
}
|
|
981
|
-
}));
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
if ("innerHTML" === n.morphStyle) return ft(t, e, n), e.children;
|
|
986
|
-
if ("outerHTML" === n.morphStyle || null == n.morphStyle) {
|
|
987
|
-
const s = us(t, e, n);
|
|
988
|
-
if (!s) throw new Error("Could not find best match");
|
|
989
|
-
const o = s?.previousSibling, r = s?.nextSibling, i = ae(e, s, n);
|
|
990
|
-
return s ? cs(o, i, r) : [];
|
|
991
|
-
}
|
|
992
|
-
throw "Do not understand how to morph style " + n.morphStyle;
|
|
993
|
-
}
|
|
994
|
-
function ae(e, t, n) {
|
|
995
|
-
if (!n.ignoreActive || e !== document.activeElement) {
|
|
996
|
-
if (null == t) {
|
|
997
|
-
if (!1 === n.callbacks.beforeNodeRemoved(e)) return;
|
|
998
|
-
return e.remove(), void n.callbacks.afterNodeRemoved(e);
|
|
999
|
-
}
|
|
1000
|
-
if (ce(e, t)) return !1 === n.callbacks.beforeNodeMorphed(e, t) ? void 0 : (e instanceof HTMLHeadElement && n.head.ignore || (t instanceof HTMLHeadElement && e instanceof HTMLHeadElement && "morph" !== n.head.style ? dt(t, e, n) : (ns(t, e), ft(t, e, n))), n.callbacks.afterNodeMorphed(e, t), e);
|
|
1001
|
-
if (!1 === n.callbacks.beforeNodeRemoved(e) || !1 === n.callbacks.beforeNodeAdded(t)) return;
|
|
1002
|
-
if (!e.parentElement) throw new Error("oldNode has no parentElement");
|
|
1003
|
-
return e.parentElement.replaceChild(t, e), n.callbacks.afterNodeAdded(t), n.callbacks.afterNodeRemoved(e), t;
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
function ft(e, t, n) {
|
|
1007
|
-
let s, o = e.firstChild, r = t.firstChild;
|
|
1008
|
-
for(; o;){
|
|
1009
|
-
if (s = o, o = s.nextSibling, null == r) {
|
|
1010
|
-
if (!1 === n.callbacks.beforeNodeAdded(s)) return;
|
|
1011
|
-
t.appendChild(s), n.callbacks.afterNodeAdded(s), x(n, s);
|
|
1012
|
-
continue;
|
|
1013
|
-
}
|
|
1014
|
-
if (ht(s, r, n)) {
|
|
1015
|
-
ae(r, s, n), r = r.nextSibling, x(n, s);
|
|
1016
|
-
continue;
|
|
1017
|
-
}
|
|
1018
|
-
let i = os(e, t, s, r, n);
|
|
1019
|
-
if (i) {
|
|
1020
|
-
r = Ce(r, i, n), ae(i, s, n), x(n, s);
|
|
1021
|
-
continue;
|
|
1022
|
-
}
|
|
1023
|
-
let a = is(e, s, r, n);
|
|
1024
|
-
if (a) r = Ce(r, a, n), ae(a, s, n), x(n, s);
|
|
1025
|
-
else {
|
|
1026
|
-
if (!1 === n.callbacks.beforeNodeAdded(s)) return;
|
|
1027
|
-
t.insertBefore(s, r), n.callbacks.afterNodeAdded(s), x(n, s);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
for(; null !== r;){
|
|
1031
|
-
let e = r;
|
|
1032
|
-
r = r.nextSibling, pt(e, n);
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
function ns(e, t) {
|
|
1036
|
-
let n = e.nodeType;
|
|
1037
|
-
if (1 === n) {
|
|
1038
|
-
for (const n of e.attributes)t.getAttribute(n.name) !== n.value && t.setAttribute(n.name, n.value);
|
|
1039
|
-
for (const n of t.attributes)e.hasAttribute(n.name) || t.removeAttribute(n.name);
|
|
1040
|
-
}
|
|
1041
|
-
if ((n === Node.COMMENT_NODE || n === Node.TEXT_NODE) && t.nodeValue !== e.nodeValue && (t.nodeValue = e.nodeValue), e instanceof HTMLInputElement && t instanceof HTMLInputElement && "file" !== e.type) t.value = e.value || "", ne(e, t, "value"), ne(e, t, "checked"), ne(e, t, "disabled");
|
|
1042
|
-
else if (e instanceof HTMLOptionElement) ne(e, t, "selected");
|
|
1043
|
-
else if (e instanceof HTMLTextAreaElement && t instanceof HTMLTextAreaElement) {
|
|
1044
|
-
const n = e.value;
|
|
1045
|
-
n !== t.value && (t.value = n), t.firstChild && t.firstChild.nodeValue !== n && (t.firstChild.nodeValue = n);
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
function ne(e, t, n) {
|
|
1049
|
-
const s = e.getAttribute(n);
|
|
1050
|
-
s !== t.getAttribute(n) && (s ? t.setAttribute(n, s) : t.removeAttribute(n));
|
|
1051
|
-
}
|
|
1052
|
-
function dt(e, t, n) {
|
|
1053
|
-
const s = [], o = [], r = [], i = [], a = n.head.style, l = new Map;
|
|
1054
|
-
for (const t of e.children)l.set(t.outerHTML, t);
|
|
1055
|
-
for (const e of t.children){
|
|
1056
|
-
let t = l.has(e.outerHTML), s = n.head.shouldReAppend(e), c = n.head.shouldPreserve(e);
|
|
1057
|
-
t || c ? s ? o.push(e) : (l.delete(e.outerHTML), r.push(e)) : "append" === a ? s && (o.push(e), i.push(e)) : !1 !== n.head.shouldRemove(e) && o.push(e);
|
|
1058
|
-
}
|
|
1059
|
-
i.push(...l.values());
|
|
1060
|
-
const c = [];
|
|
1061
|
-
for (const e of i){
|
|
1062
|
-
const o = document.createRange().createContextualFragment(e.outerHTML).firstChild;
|
|
1063
|
-
if (!o) throw new Error("could not create new element from: " + e.outerHTML);
|
|
1064
|
-
if (n.callbacks.beforeNodeAdded(o)) {
|
|
1065
|
-
if (o.hasAttribute("href") || o.hasAttribute("src")) {
|
|
1066
|
-
let e;
|
|
1067
|
-
const t = new Promise((t)=>{
|
|
1068
|
-
e = t;
|
|
1069
|
-
});
|
|
1070
|
-
o.addEventListener("load", function() {
|
|
1071
|
-
e(void 0);
|
|
1072
|
-
}), c.push(t);
|
|
1073
|
-
}
|
|
1074
|
-
t.appendChild(o), n.callbacks.afterNodeAdded(o), s.push(o);
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
for (const e of o)!1 !== n.callbacks.beforeNodeRemoved(e) && (t.removeChild(e), n.callbacks.afterNodeRemoved(e));
|
|
1078
|
-
return n.head.afterHeadMorphed(t, {
|
|
1079
|
-
added: s,
|
|
1080
|
-
kept: r,
|
|
1081
|
-
removed: o
|
|
1082
|
-
}), c;
|
|
1083
|
-
}
|
|
1084
|
-
function F() {}
|
|
1085
|
-
function rs(e, t, n) {
|
|
1086
|
-
return {
|
|
1087
|
-
target: e,
|
|
1088
|
-
newContent: t,
|
|
1089
|
-
config: n,
|
|
1090
|
-
morphStyle: n.morphStyle,
|
|
1091
|
-
ignoreActive: n.ignoreActive,
|
|
1092
|
-
idMap: ps(e, t),
|
|
1093
|
-
deadIds: new Set,
|
|
1094
|
-
callbacks: Object.assign({
|
|
1095
|
-
beforeNodeAdded: F,
|
|
1096
|
-
afterNodeAdded: F,
|
|
1097
|
-
beforeNodeMorphed: F,
|
|
1098
|
-
afterNodeMorphed: F,
|
|
1099
|
-
beforeNodeRemoved: F,
|
|
1100
|
-
afterNodeRemoved: F
|
|
1101
|
-
}, n.callbacks),
|
|
1102
|
-
head: Object.assign({
|
|
1103
|
-
style: "merge",
|
|
1104
|
-
shouldPreserve: (e)=>"true" === e.getAttribute("im-preserve"),
|
|
1105
|
-
shouldReAppend: (e)=>"true" === e.getAttribute("im-re-append"),
|
|
1106
|
-
shouldRemove: F,
|
|
1107
|
-
afterHeadMorphed: F
|
|
1108
|
-
}, n.head)
|
|
1109
|
-
};
|
|
1110
|
-
}
|
|
1111
|
-
function ht(e, t, n) {
|
|
1112
|
-
return !(!e || !t) && e.nodeType === t.nodeType && e.tagName === t.tagName && (!(!e?.id?.length || e.id !== t.id) || z(n, e, t) > 0);
|
|
1113
|
-
}
|
|
1114
|
-
function ce(e, t) {
|
|
1115
|
-
return !(!e || !t) && e.nodeType === t.nodeType && e.tagName === t.tagName;
|
|
1116
|
-
}
|
|
1117
|
-
function Ce(e, t, n) {
|
|
1118
|
-
for(; e !== t;){
|
|
1119
|
-
const t = e;
|
|
1120
|
-
if (e = e?.nextSibling, !t) throw new Error("tempNode is null");
|
|
1121
|
-
pt(t, n);
|
|
1122
|
-
}
|
|
1123
|
-
return x(n, t), t.nextSibling;
|
|
1124
|
-
}
|
|
1125
|
-
function os(e, t, n, s, o) {
|
|
1126
|
-
const r = z(o, n, t);
|
|
1127
|
-
let i = null;
|
|
1128
|
-
if (r > 0) {
|
|
1129
|
-
i = s;
|
|
1130
|
-
let t = 0;
|
|
1131
|
-
for(; null != i;){
|
|
1132
|
-
if (ht(n, i, o)) return i;
|
|
1133
|
-
if (t += z(o, i, e), t > r) return null;
|
|
1134
|
-
i = i.nextSibling;
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
return i;
|
|
1138
|
-
}
|
|
1139
|
-
function is(e, t, n, s) {
|
|
1140
|
-
let o = n, r = t.nextSibling, i = 0;
|
|
1141
|
-
for(; o && r;){
|
|
1142
|
-
if (z(s, o, e) > 0) return null;
|
|
1143
|
-
if (ce(t, o)) return o;
|
|
1144
|
-
if (ce(r, o) && (i++, r = r.nextSibling, i >= 2)) return null;
|
|
1145
|
-
o = o.nextSibling;
|
|
1146
|
-
}
|
|
1147
|
-
return o;
|
|
1148
|
-
}
|
|
1149
|
-
const De = new DOMParser;
|
|
1150
|
-
function as(e) {
|
|
1151
|
-
const t = e.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim, "");
|
|
1152
|
-
if (t.match(/<\/html>/) || t.match(/<\/head>/) || t.match(/<\/body>/)) {
|
|
1153
|
-
const n = De.parseFromString(e, "text/html");
|
|
1154
|
-
if (t.match(/<\/html>/)) return ie.add(n), n;
|
|
1155
|
-
{
|
|
1156
|
-
let e = n.firstChild;
|
|
1157
|
-
return e ? (ie.add(e), e) : null;
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
{
|
|
1161
|
-
const t = De.parseFromString(`<body><template>${e}</template></body>`, "text/html").body.querySelector("template")?.content;
|
|
1162
|
-
if (!t) throw new Error("content is null");
|
|
1163
|
-
return ie.add(t), t;
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
function ls(e) {
|
|
1167
|
-
if (null == e) return document.createElement("div");
|
|
1168
|
-
if (ie.has(e)) return e;
|
|
1169
|
-
if (e instanceof Node) {
|
|
1170
|
-
const t = document.createElement("div");
|
|
1171
|
-
return t.append(e), t;
|
|
1172
|
-
}
|
|
1173
|
-
{
|
|
1174
|
-
const t = document.createElement("div");
|
|
1175
|
-
for (const n of [
|
|
1176
|
-
...e
|
|
1177
|
-
])t.append(n);
|
|
1178
|
-
return t;
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
function cs(e, t, n) {
|
|
1182
|
-
const s = [], o = [];
|
|
1183
|
-
for(; e;)s.push(e), e = e.previousSibling;
|
|
1184
|
-
for(; s.length > 0;){
|
|
1185
|
-
const e = s.pop();
|
|
1186
|
-
o.push(e), t?.parentElement?.insertBefore(e, t);
|
|
1187
|
-
}
|
|
1188
|
-
for(o.push(t); n;)s.push(n), o.push(n), n = n.nextSibling;
|
|
1189
|
-
for(; s.length;)t?.parentElement?.insertBefore(s.pop(), t.nextSibling);
|
|
1190
|
-
return o;
|
|
1191
|
-
}
|
|
1192
|
-
function us(e, t, n) {
|
|
1193
|
-
let s = e.firstChild, o = s, r = 0;
|
|
1194
|
-
for(; s;){
|
|
1195
|
-
let e = fs(s, t, n);
|
|
1196
|
-
e > r && (o = s, r = e), s = s.nextSibling;
|
|
1197
|
-
}
|
|
1198
|
-
return o;
|
|
1199
|
-
}
|
|
1200
|
-
function fs(e, t, n) {
|
|
1201
|
-
return ce(e, t) ? .5 + z(n, e, t) : 0;
|
|
1202
|
-
}
|
|
1203
|
-
function pt(e, t) {
|
|
1204
|
-
x(t, e), !1 !== t.callbacks.beforeNodeRemoved(e) && (e.remove(), t.callbacks.afterNodeRemoved(e));
|
|
1205
|
-
}
|
|
1206
|
-
function ds(e, t) {
|
|
1207
|
-
return !e.deadIds.has(t);
|
|
1208
|
-
}
|
|
1209
|
-
function hs(e, t, n) {
|
|
1210
|
-
return e.idMap.get(n)?.has(t) || !1;
|
|
1211
|
-
}
|
|
1212
|
-
function x(e, t) {
|
|
1213
|
-
const n = e.idMap.get(t);
|
|
1214
|
-
if (n) for (const t of n)e.deadIds.add(t);
|
|
1215
|
-
}
|
|
1216
|
-
function z(e, t, n) {
|
|
1217
|
-
const s = e.idMap.get(t);
|
|
1218
|
-
if (!s) return 0;
|
|
1219
|
-
let o = 0;
|
|
1220
|
-
for (const t of s)ds(e, t) && hs(e, t, n) && ++o;
|
|
1221
|
-
return o;
|
|
1222
|
-
}
|
|
1223
|
-
function Fe(e, t) {
|
|
1224
|
-
const n = e.parentElement, s = e.querySelectorAll("[id]");
|
|
1225
|
-
for (const e of s){
|
|
1226
|
-
let s = e;
|
|
1227
|
-
for(; s !== n && s;){
|
|
1228
|
-
let n = t.get(s);
|
|
1229
|
-
null == n && (n = new Set, t.set(s, n)), n.add(e.id), s = s.parentElement;
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
function ps(e, t) {
|
|
1234
|
-
const n = new Map;
|
|
1235
|
-
return Fe(e, n), Fe(t, n), n;
|
|
1236
|
-
}
|
|
1237
|
-
const ge = "display", He = "none", ve = "important", Ve = "duration", ms = "show", be = `${k}showing`, ye = `${k}hiding`, xe = `${k}show-transition-style`, gs = {
|
|
1238
|
-
prefix: ms,
|
|
1239
|
-
allowedModifiers: new Set([
|
|
1240
|
-
ve,
|
|
1241
|
-
Ve
|
|
1242
|
-
]),
|
|
1243
|
-
onLoad: (e)=>{
|
|
1244
|
-
const { el: t, modifiers: n, expressionFn: s, reactivity: o } = e, r = n.has(ve) ? ve : void 0;
|
|
1245
|
-
let i, a;
|
|
1246
|
-
const l = e.modifiers.get(Ve);
|
|
1247
|
-
if (l) {
|
|
1248
|
-
let e = document.getElementById(xe);
|
|
1249
|
-
if (!e) {
|
|
1250
|
-
e = document.createElement("style"), e.id = xe, document.head.appendChild(e);
|
|
1251
|
-
const t = _e(l) || "300";
|
|
1252
|
-
e.innerHTML = `\n .${be} {\n visibility: visible;\n transition: opacity ${t}ms linear;\n }\n .${ye} {\n visibility: hidden;\n transition: visibility 0s ${t}ms, opacity ${t}ms linear;\n }\n `;
|
|
1253
|
-
}
|
|
1254
|
-
const n = (e)=>(s)=>{
|
|
1255
|
-
s.target === t && (t.classList.remove(e), t.removeEventListener("transitionend", n(e)));
|
|
1256
|
-
};
|
|
1257
|
-
i = ()=>{
|
|
1258
|
-
t.addEventListener("transitionend", n(be)), t.classList.add(be), requestAnimationFrame(()=>{
|
|
1259
|
-
t.style.setProperty("opacity", "1", r);
|
|
1260
|
-
});
|
|
1261
|
-
}, a = ()=>{
|
|
1262
|
-
t.addEventListener("transitionend", n(ye)), t.classList.add(ye), requestAnimationFrame(()=>{
|
|
1263
|
-
t.style.setProperty("opacity", "0", r);
|
|
1264
|
-
});
|
|
1265
|
-
};
|
|
1266
|
-
} else i = ()=>{
|
|
1267
|
-
1 === t.style.length && t.style.display === He ? t.style.removeProperty(ge) : t.style.setProperty(ge, "", r);
|
|
1268
|
-
}, a = ()=>{
|
|
1269
|
-
t.style.setProperty(ge, He, r);
|
|
1270
|
-
};
|
|
1271
|
-
return o.effect(async ()=>{
|
|
1272
|
-
await s(e) ? i() : a();
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1275
|
-
}, vs = "intersects", je = "once", Ue = "half", Be = "full", bs = {
|
|
1276
|
-
prefix: vs,
|
|
1277
|
-
allowedModifiers: new Set([
|
|
1278
|
-
je,
|
|
1279
|
-
Ue,
|
|
1280
|
-
Be
|
|
1281
|
-
]),
|
|
1282
|
-
mustHaveEmptyKey: !0,
|
|
1283
|
-
onLoad: (e)=>{
|
|
1284
|
-
const { modifiers: t } = e, n = {
|
|
1285
|
-
threshold: 0
|
|
1286
|
-
};
|
|
1287
|
-
t.has(Be) ? n.threshold = 1 : t.has(Ue) && (n.threshold = .5);
|
|
1288
|
-
const s = new IntersectionObserver((n)=>{
|
|
1289
|
-
n.forEach((n)=>{
|
|
1290
|
-
n.isIntersecting && (e.expressionFn(e), t.has(je) && (s.disconnect(), delete e.el.dataset[e.rawKey]));
|
|
1291
|
-
});
|
|
1292
|
-
}, n);
|
|
1293
|
-
return s.observe(e.el), ()=>s.disconnect();
|
|
1294
|
-
}
|
|
1295
|
-
}, We = "prepend", qe = "append", Je = new Error("Target element must have a parent if using prepend or append"), ys = {
|
|
1296
|
-
prefix: "teleport",
|
|
1297
|
-
allowedModifiers: new Set([
|
|
1298
|
-
We,
|
|
1299
|
-
qe
|
|
1300
|
-
]),
|
|
1301
|
-
allowedTagRegexps: new Set([
|
|
1302
|
-
"template"
|
|
1303
|
-
]),
|
|
1304
|
-
bypassExpressionFunctionCreation: ()=>!0,
|
|
1305
|
-
onLoad: (e)=>{
|
|
1306
|
-
const { el: t, modifiers: n, expression: s } = e;
|
|
1307
|
-
if (!(t instanceof HTMLTemplateElement)) throw new Error("el must be a template element");
|
|
1308
|
-
const o = document.querySelector(s);
|
|
1309
|
-
if (!o) throw new Error(`Target element not found: ${s}`);
|
|
1310
|
-
if (!t.content) throw new Error("Template element must have content");
|
|
1311
|
-
const r = t.content.cloneNode(!0);
|
|
1312
|
-
if (ze(r)?.firstElementChild) throw new Error("Empty template");
|
|
1313
|
-
if (n.has(We)) {
|
|
1314
|
-
if (!o.parentNode) throw Je;
|
|
1315
|
-
o.parentNode.insertBefore(r, o);
|
|
1316
|
-
} else if (n.has(qe)) {
|
|
1317
|
-
if (!o.parentNode) throw Je;
|
|
1318
|
-
o.parentNode.insertBefore(r, o.nextSibling);
|
|
1319
|
-
} else o.appendChild(r);
|
|
1320
|
-
}
|
|
1321
|
-
}, ws = {
|
|
1322
|
-
prefix: "scrollIntoView",
|
|
1323
|
-
mustHaveEmptyKey: !0,
|
|
1324
|
-
mustHaveEmptyExpression: !0,
|
|
1325
|
-
allowedModifiers: new Set([
|
|
1326
|
-
"smooth",
|
|
1327
|
-
"instant",
|
|
1328
|
-
"auto",
|
|
1329
|
-
"hstart",
|
|
1330
|
-
"hcenter",
|
|
1331
|
-
"hend",
|
|
1332
|
-
"hnearest",
|
|
1333
|
-
"vstart",
|
|
1334
|
-
"vcenter",
|
|
1335
|
-
"vend",
|
|
1336
|
-
"vnearest",
|
|
1337
|
-
"focus"
|
|
1338
|
-
]),
|
|
1339
|
-
onLoad: ({ el: e, modifiers: t, rawKey: n })=>{
|
|
1340
|
-
e.tabIndex || e.setAttribute("tabindex", "0");
|
|
1341
|
-
const s = {
|
|
1342
|
-
behavior: "smooth",
|
|
1343
|
-
block: "center",
|
|
1344
|
-
inline: "center"
|
|
1345
|
-
};
|
|
1346
|
-
return t.has("smooth") && (s.behavior = "smooth"), t.has("instant") && (s.behavior = "instant"), t.has("auto") && (s.behavior = "auto"), t.has("hstart") && (s.inline = "start"), t.has("hcenter") && (s.inline = "center"), t.has("hend") && (s.inline = "end"), t.has("hnearest") && (s.inline = "nearest"), t.has("vstart") && (s.block = "start"), t.has("vcenter") && (s.block = "center"), t.has("vend") && (s.block = "end"), t.has("vnearest") && (s.block = "nearest"), vt(e, s, t.has("focus")), delete e.dataset[n], ()=>{};
|
|
1347
|
-
}
|
|
1348
|
-
}, mt = document, gt = !!mt.startViewTransition, Es = {
|
|
1349
|
-
prefix: "viewTransition",
|
|
1350
|
-
onGlobalInit () {
|
|
1351
|
-
let e = !1;
|
|
1352
|
-
if (document.head.childNodes.forEach((t)=>{
|
|
1353
|
-
t instanceof HTMLMetaElement && "view-transition" === t.name && (e = !0);
|
|
1354
|
-
}), !e) {
|
|
1355
|
-
const e = document.createElement("meta");
|
|
1356
|
-
e.name = "view-transition", e.content = "same-origin", document.head.appendChild(e);
|
|
1357
|
-
}
|
|
1358
|
-
},
|
|
1359
|
-
onLoad: (e)=>{
|
|
1360
|
-
if (gt) return e.reactivity.effect(()=>{
|
|
1361
|
-
const { el: t, expressionFn: n } = e;
|
|
1362
|
-
let s = n(e);
|
|
1363
|
-
if (!s) return;
|
|
1364
|
-
t.style.viewTransitionName = s;
|
|
1365
|
-
});
|
|
1366
|
-
console.error("Browser does not support view transitions");
|
|
1367
|
-
}
|
|
1368
|
-
}, _s = [
|
|
1369
|
-
gs,
|
|
1370
|
-
bs,
|
|
1371
|
-
ys,
|
|
1372
|
-
ws,
|
|
1373
|
-
Es
|
|
1374
|
-
], Ss = {
|
|
1375
|
-
scroll: async (e, t, n)=>{
|
|
1376
|
-
const s = Object.assign({
|
|
1377
|
-
behavior: "smooth",
|
|
1378
|
-
vertical: "center",
|
|
1379
|
-
horizontal: "center",
|
|
1380
|
-
shouldFocus: !0
|
|
1381
|
-
}, n);
|
|
1382
|
-
vt(document.querySelector(t), s);
|
|
1383
|
-
}
|
|
1384
|
-
};
|
|
1385
|
-
function vt(e, t, n = !0) {
|
|
1386
|
-
if (!(e instanceof HTMLElement || e instanceof SVGElement)) throw new Error("Element not found");
|
|
1387
|
-
e.tabIndex || e.setAttribute("tabindex", "0"), e.scrollIntoView(t), n && e.focus();
|
|
1388
|
-
}
|
|
1389
|
-
const Ts = 500, As = !0, Ns = "morph", Ls = "Content-Type", ks = `${U}-request`, Ms = "application/json", Ps = "true", $s = `${k}fragment`, Os = `${k}signal`, Is = `${k}delete`, Rs = `${k}redirect`, Cs = `${k}console`, Z = `${k}indicator`, Te = `${Z}-loading`, Ke = `${k}settling`, re = `${k}swapping`, Ds = "self", Fs = "get", Hs = "post", Vs = "put", xs = "patch", js = "delete", I = {
|
|
1390
|
-
MorphElement: "morph",
|
|
1391
|
-
InnerElement: "inner",
|
|
1392
|
-
OuterElement: "outer",
|
|
1393
|
-
PrependElement: "prepend",
|
|
1394
|
-
AppendElement: "append",
|
|
1395
|
-
BeforeElement: "before",
|
|
1396
|
-
AfterElement: "after",
|
|
1397
|
-
UpsertAttributes: "upsert_attributes"
|
|
1398
|
-
}, Us = {
|
|
1399
|
-
prefix: "fetchIndicator",
|
|
1400
|
-
mustHaveEmptyKey: !0,
|
|
1401
|
-
mustNotEmptyExpression: !0,
|
|
1402
|
-
onGlobalInit: ()=>{
|
|
1403
|
-
const e = document.createElement("style");
|
|
1404
|
-
e.innerHTML = `\n.${Z}{\n opacity:0;\n transition: opacity 300ms ease-out;\n}\n.${Te} {\n opacity:1;\n transition: opacity 300ms ease-in;\n}\n`, document.head.appendChild(e);
|
|
1405
|
-
},
|
|
1406
|
-
onLoad: (e)=>e.reactivity.effect(()=>{
|
|
1407
|
-
e.upsertIfMissingFromStore("_dsPlugins.fetch.indicatorElements", {}), e.upsertIfMissingFromStore("_dsPlugins.fetch.indicatorsVisible", []);
|
|
1408
|
-
const t = e.reactivity.computed(()=>`${e.expressionFn(e)}`), n = e.store(), s = document.querySelectorAll(t.value);
|
|
1409
|
-
if (0 === s.length) throw new Error("No indicator found");
|
|
1410
|
-
return s.forEach((e)=>{
|
|
1411
|
-
e.classList.add(Z);
|
|
1412
|
-
}), n._dsPlugins.fetch.indicatorElements[e.el.id] = e.reactivity.signal(s), ()=>{
|
|
1413
|
-
delete n._dsPlugins.fetch.indicatorElements[e.el.id];
|
|
1414
|
-
};
|
|
1415
|
-
})
|
|
1416
|
-
}, Bs = {
|
|
1417
|
-
prefix: "header",
|
|
1418
|
-
mustNotEmptyKey: !0,
|
|
1419
|
-
mustNotEmptyExpression: !0,
|
|
1420
|
-
preprocessors: {
|
|
1421
|
-
post: [
|
|
1422
|
-
{
|
|
1423
|
-
regexp: /(?<whole>.+)/g,
|
|
1424
|
-
replacer: (e)=>{
|
|
1425
|
-
const { whole: t } = e;
|
|
1426
|
-
return `'${t}'`;
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
]
|
|
1430
|
-
},
|
|
1431
|
-
onLoad: (e)=>{
|
|
1432
|
-
e.upsertIfMissingFromStore("_dsPlugins.fetch.headers", {});
|
|
1433
|
-
const t = e.key.replace(/([a-z](?=[A-Z]))/g, "$1-").toUpperCase(), n = e.expressionFn(e);
|
|
1434
|
-
return e.store()._dsPlugins.fetch.headers[t] = n, ()=>{
|
|
1435
|
-
delete e.store()._dsPlugins.fetch.headers[t];
|
|
1436
|
-
};
|
|
1437
|
-
}
|
|
1438
|
-
}, Ws = [
|
|
1439
|
-
Us,
|
|
1440
|
-
Bs
|
|
1441
|
-
];
|
|
1442
|
-
async function qs(e, t, n, s = !0) {
|
|
1443
|
-
const o = n.store();
|
|
1444
|
-
if (!t) throw new Error(`No signal for ${e} on ${t}`);
|
|
1445
|
-
let r = {
|
|
1446
|
-
...o.value
|
|
1447
|
-
};
|
|
1448
|
-
s && (r = he(r));
|
|
1449
|
-
const i = JSON.stringify(r), a = n.el;
|
|
1450
|
-
N("plugin", "backend", "fetch_start", a, JSON.stringify({
|
|
1451
|
-
method: e,
|
|
1452
|
-
urlExpression: t,
|
|
1453
|
-
onlyRemote: s,
|
|
1454
|
-
storeJSON: i
|
|
1455
|
-
}));
|
|
1456
|
-
const l = o?._dsPlugins?.fetch?.indicatorElements && o._dsPlugins.fetch.indicatorElements[a.id]?.value || [], c = o?._dsPlugins.fetch?.indicatorsVisible;
|
|
1457
|
-
l?.forEach && l.forEach((e)=>{
|
|
1458
|
-
if (!e || !c) return;
|
|
1459
|
-
const t = c.value.findIndex((t)=>!!t && e.isSameNode(t.el));
|
|
1460
|
-
if (t > -1) {
|
|
1461
|
-
const n = c.value[t], s = [
|
|
1462
|
-
...c.value
|
|
1463
|
-
];
|
|
1464
|
-
delete s[t], c.value = [
|
|
1465
|
-
...s.filter((e)=>!!e),
|
|
1466
|
-
{
|
|
1467
|
-
el: e,
|
|
1468
|
-
count: n.count + 1
|
|
1469
|
-
}
|
|
1470
|
-
];
|
|
1471
|
-
} else e.classList.remove(Z), e.classList.add(Te), c.value = [
|
|
1472
|
-
...c.value,
|
|
1473
|
-
{
|
|
1474
|
-
el: e,
|
|
1475
|
-
count: 1
|
|
1476
|
-
}
|
|
1477
|
-
];
|
|
1478
|
-
});
|
|
1479
|
-
const u = new URL(t, window.location.origin), d = {
|
|
1480
|
-
method: e = e.toUpperCase(),
|
|
1481
|
-
headers: {
|
|
1482
|
-
[Ls]: Ms,
|
|
1483
|
-
[ks]: Ps
|
|
1484
|
-
},
|
|
1485
|
-
onmessage: (e)=>{
|
|
1486
|
-
if (e.event) switch(e.event.startsWith(k) || console.log(`Unknown event: ${e.event}`), e.event){
|
|
1487
|
-
case $s:
|
|
1488
|
-
const t = e.data.trim().split("\n"), s = [
|
|
1489
|
-
"selector",
|
|
1490
|
-
"merge",
|
|
1491
|
-
"settle",
|
|
1492
|
-
"fragment",
|
|
1493
|
-
"vt"
|
|
1494
|
-
];
|
|
1495
|
-
let o = "", r = Ns, i = Ts, a = As, l = !1, c = "", u = "";
|
|
1496
|
-
for(let e = 0; e < t.length; e++){
|
|
1497
|
-
let n = t[e];
|
|
1498
|
-
if (!n?.length) continue;
|
|
1499
|
-
const d = n.split(" ", 1)[0];
|
|
1500
|
-
if (s.includes(d) && d !== u) switch(u = d, n = n.slice(d.length + 1), u){
|
|
1501
|
-
case "selector":
|
|
1502
|
-
c = n;
|
|
1503
|
-
break;
|
|
1504
|
-
case "merge":
|
|
1505
|
-
if (r = n, l = Object.values(I).includes(r), !l) throw new Error(`Unknown merge option: ${r}`);
|
|
1506
|
-
break;
|
|
1507
|
-
case "settle":
|
|
1508
|
-
i = parseInt(n);
|
|
1509
|
-
break;
|
|
1510
|
-
case "fragment":
|
|
1511
|
-
break;
|
|
1512
|
-
case "vt":
|
|
1513
|
-
a = "true" === n;
|
|
1514
|
-
break;
|
|
1515
|
-
default:
|
|
1516
|
-
throw new Error("Unknown data type");
|
|
1517
|
-
}
|
|
1518
|
-
"fragment" === u && (o += n + "\n");
|
|
1519
|
-
}
|
|
1520
|
-
o?.length || (o = "<div></div>"), Js(n, c, r, o, i, a), N("plugin", "backend", "merge", c, JSON.stringify({
|
|
1521
|
-
fragment: o,
|
|
1522
|
-
settleTime: i,
|
|
1523
|
-
useViewTransition: a
|
|
1524
|
-
}));
|
|
1525
|
-
break;
|
|
1526
|
-
case Os:
|
|
1527
|
-
let d = !1, f = "";
|
|
1528
|
-
const h = e.data.trim().split("\n");
|
|
1529
|
-
for(let e = 0; e < h.length; e++){
|
|
1530
|
-
const t = h[e], [n, ...s] = t.split(" "), o = s.join(" ");
|
|
1531
|
-
switch(n){
|
|
1532
|
-
case "onlyIfMissing":
|
|
1533
|
-
d = "true" === o.trim();
|
|
1534
|
-
break;
|
|
1535
|
-
case "store":
|
|
1536
|
-
f += `${o}\n`;
|
|
1537
|
-
break;
|
|
1538
|
-
default:
|
|
1539
|
-
throw new Error(`Unknown signal type: ${n}`);
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
const p = ` return Object.assign({...ctx.store()}, ${f})`;
|
|
1543
|
-
try {
|
|
1544
|
-
const e = new Function("ctx", p)(n), t = lt(n.store(), e, d);
|
|
1545
|
-
n.mergeStore(t), n.applyPlugins(document.body);
|
|
1546
|
-
} catch (e) {
|
|
1547
|
-
console.log(p), console.error(e);
|
|
1548
|
-
}
|
|
1549
|
-
break;
|
|
1550
|
-
case Is:
|
|
1551
|
-
const [m, ...g] = e.data.trim().split(" ");
|
|
1552
|
-
switch(m){
|
|
1553
|
-
case "selector":
|
|
1554
|
-
const e1 = g.join(" ");
|
|
1555
|
-
document.querySelectorAll(e1).forEach((e)=>e.remove());
|
|
1556
|
-
break;
|
|
1557
|
-
case "paths":
|
|
1558
|
-
const t1 = g.join(" ").split(" ");
|
|
1559
|
-
n.removeFromStore(...t1);
|
|
1560
|
-
break;
|
|
1561
|
-
default:
|
|
1562
|
-
throw new Error(`Unknown delete prefix: ${m}`);
|
|
1563
|
-
}
|
|
1564
|
-
break;
|
|
1565
|
-
case Rs:
|
|
1566
|
-
const [v, ...b] = e.data.trim().split(" ");
|
|
1567
|
-
if ("url" !== v) throw new Error(`Unknown redirect selector: ${v}`);
|
|
1568
|
-
const y = b.join(" ");
|
|
1569
|
-
N("plugin", "backend", "redirect", "WINDOW", y), window.location.href = y;
|
|
1570
|
-
break;
|
|
1571
|
-
case Cs:
|
|
1572
|
-
const [w, ..._] = e.data.trim().split(" "), E = _.join(" ");
|
|
1573
|
-
switch(w){
|
|
1574
|
-
case "debug":
|
|
1575
|
-
case "error":
|
|
1576
|
-
case "info":
|
|
1577
|
-
case "group":
|
|
1578
|
-
case "groupEnd":
|
|
1579
|
-
case "log":
|
|
1580
|
-
case "warn":
|
|
1581
|
-
console[w](E);
|
|
1582
|
-
break;
|
|
1583
|
-
default:
|
|
1584
|
-
throw new Error(`Unknown console mode: '${w}', message: '${E}'`);
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1587
|
-
},
|
|
1588
|
-
onerror: (e)=>{
|
|
1589
|
-
console.error(e);
|
|
1590
|
-
},
|
|
1591
|
-
onclose: ()=>{
|
|
1592
|
-
try {
|
|
1593
|
-
const e = n.store(), t = e?._dsPlugins?.fetch?.indicatorsVisible || [], s = e?._dsPlugins?.fetch?.indicatorElements && e._dsPlugins.fetch.indicatorElements[a.id]?.value || [], o = [];
|
|
1594
|
-
s?.forEach && s.forEach((e)=>{
|
|
1595
|
-
if (!e || !t) return;
|
|
1596
|
-
const n = t.value, s = n.findIndex((t)=>!!t && e.isSameNode(t.el)), r = n[s];
|
|
1597
|
-
r && (r.count < 2 ? (o.push(new Promise(()=>setTimeout(()=>{
|
|
1598
|
-
e.classList.remove(Te), e.classList.add(Z);
|
|
1599
|
-
}, 300))), delete n[s]) : s > -1 && (n[s].count = n[s].count - 1), t.value = n.filter((e)=>!!e));
|
|
1600
|
-
}), Promise.all(o);
|
|
1601
|
-
} catch (e) {
|
|
1602
|
-
console.error(e);
|
|
1603
|
-
} finally{
|
|
1604
|
-
N("plugin", "backend", "fetch_end", a, JSON.stringify({
|
|
1605
|
-
method: e,
|
|
1606
|
-
urlExpression: t
|
|
1607
|
-
}));
|
|
1608
|
-
}
|
|
1609
|
-
}
|
|
1610
|
-
};
|
|
1611
|
-
if ("GET" === e) {
|
|
1612
|
-
const e = new URLSearchParams(u.search);
|
|
1613
|
-
e.append("datastar", i), u.search = e.toString();
|
|
1614
|
-
} else d.body = i;
|
|
1615
|
-
const f = o?._dsPlugins?.fetch?.headers || {};
|
|
1616
|
-
if (d.headers) for (const [e, t] of Object.entries(f))e.startsWith("_") || (d.headers[e] = `${t}`);
|
|
1617
|
-
Gt(u, d);
|
|
1618
|
-
}
|
|
1619
|
-
const Ge = document.createElement("template");
|
|
1620
|
-
function Js(e, t, n, s, o, r) {
|
|
1621
|
-
const { el: i } = e;
|
|
1622
|
-
Ge.innerHTML = s.trim(), [
|
|
1623
|
-
...Ge.content.children
|
|
1624
|
-
].forEach((s)=>{
|
|
1625
|
-
if (!(s instanceof Element)) throw new Error("No fragment found");
|
|
1626
|
-
const a = (t)=>{
|
|
1627
|
-
for (const r of t){
|
|
1628
|
-
r.classList.add(re);
|
|
1629
|
-
const t = r.outerHTML;
|
|
1630
|
-
let i = r;
|
|
1631
|
-
switch(n){
|
|
1632
|
-
case I.MorphElement:
|
|
1633
|
-
const t1 = ss(i, s, {
|
|
1634
|
-
callbacks: {
|
|
1635
|
-
beforeNodeRemoved: (t, n)=>(e.cleanupElementRemovals(t), !0)
|
|
1636
|
-
}
|
|
1637
|
-
});
|
|
1638
|
-
if (!t1?.length) throw new Error("No morph result");
|
|
1639
|
-
i = t1[0];
|
|
1640
|
-
break;
|
|
1641
|
-
case I.InnerElement:
|
|
1642
|
-
i.innerHTML = s.innerHTML;
|
|
1643
|
-
break;
|
|
1644
|
-
case I.OuterElement:
|
|
1645
|
-
i.replaceWith(s);
|
|
1646
|
-
break;
|
|
1647
|
-
case I.PrependElement:
|
|
1648
|
-
i.prepend(s);
|
|
1649
|
-
break;
|
|
1650
|
-
case I.AppendElement:
|
|
1651
|
-
i.append(s);
|
|
1652
|
-
break;
|
|
1653
|
-
case I.BeforeElement:
|
|
1654
|
-
i.before(s);
|
|
1655
|
-
break;
|
|
1656
|
-
case I.AfterElement:
|
|
1657
|
-
i.after(s);
|
|
1658
|
-
break;
|
|
1659
|
-
case I.UpsertAttributes:
|
|
1660
|
-
s.getAttributeNames().forEach((e)=>{
|
|
1661
|
-
const t = s.getAttribute(e);
|
|
1662
|
-
i.setAttribute(e, t);
|
|
1663
|
-
});
|
|
1664
|
-
break;
|
|
1665
|
-
default:
|
|
1666
|
-
throw new Error(`Unknown merge type: ${n}`);
|
|
1667
|
-
}
|
|
1668
|
-
e.cleanupElementRemovals(i), i.classList.add(re), e.applyPlugins(document.body), setTimeout(()=>{
|
|
1669
|
-
r.classList.remove(re), i.classList.remove(re);
|
|
1670
|
-
}, o);
|
|
1671
|
-
t !== i.outerHTML && (i.classList.add(Ke), setTimeout(()=>{
|
|
1672
|
-
i.classList.remove(Ke);
|
|
1673
|
-
}, o));
|
|
1674
|
-
}
|
|
1675
|
-
};
|
|
1676
|
-
let l;
|
|
1677
|
-
if (t === Ds) l = [
|
|
1678
|
-
i
|
|
1679
|
-
];
|
|
1680
|
-
else {
|
|
1681
|
-
const e = t || `#${s.getAttribute("id")}`;
|
|
1682
|
-
if (l = document.querySelectorAll(e) || [], !l) throw new Error(`No targets found for ${e}`);
|
|
1683
|
-
}
|
|
1684
|
-
const c = [
|
|
1685
|
-
...l
|
|
1686
|
-
];
|
|
1687
|
-
if (!c.length) throw new Error(`No targets found for ${t}`);
|
|
1688
|
-
gt && r ? mt.startViewTransition(()=>a(c)) : a(c);
|
|
1689
|
-
});
|
|
1690
|
-
}
|
|
1691
|
-
const Ks = [
|
|
1692
|
-
Fs,
|
|
1693
|
-
Hs,
|
|
1694
|
-
Vs,
|
|
1695
|
-
xs,
|
|
1696
|
-
js
|
|
1697
|
-
].reduce((e, t)=>(e[t] = (e, n, s)=>{
|
|
1698
|
-
const o = [
|
|
1699
|
-
"true",
|
|
1700
|
-
!0,
|
|
1701
|
-
void 0
|
|
1702
|
-
].includes(s);
|
|
1703
|
-
qs(t, n, e, o);
|
|
1704
|
-
}, e), {
|
|
1705
|
-
isFetching: (e, t)=>{
|
|
1706
|
-
const n = [
|
|
1707
|
-
...document.querySelectorAll(t)
|
|
1708
|
-
], s = e.store()?._dsPlugins?.fetch.indicatorsVisible?.value || [];
|
|
1709
|
-
return !!n.length && n.some((e)=>s.filter((e)=>!!e).some((t)=>t.el.isSameNode(e) && t.count > 0));
|
|
1710
|
-
}
|
|
1711
|
-
}), Ye = "0.19.9", ke = (e, t, n, s, o, r)=>(t - n) / (s - n) * (r - o) + o, Gs = (e, t, n, s, o, r)=>Math.round(ke(0, t, n, s, o, r)), bt = (e, t, n, s, o, r)=>Math.max(o, Math.min(r, ke(0, t, n, s, o, r))), Ys = (e, t, n, s, o, r)=>Math.round(bt(0, t, n, s, o, r)), zs = {
|
|
1712
|
-
setAll: (e, t, n)=>{
|
|
1713
|
-
const s = new RegExp(t);
|
|
1714
|
-
e.walkSignals((e, t)=>s.test(e) && (t.value = n));
|
|
1715
|
-
},
|
|
1716
|
-
toggleAll: (e, t)=>{
|
|
1717
|
-
const n = new RegExp(t);
|
|
1718
|
-
e.walkSignals((e, t)=>n.test(e) && (t.value = !t.value));
|
|
1719
|
-
},
|
|
1720
|
-
clipboard: (e, t)=>{
|
|
1721
|
-
if (!navigator.clipboard) throw new Error("Clipboard API not available");
|
|
1722
|
-
navigator.clipboard.writeText(t);
|
|
1723
|
-
},
|
|
1724
|
-
fit: ke,
|
|
1725
|
-
fitInt: Gs,
|
|
1726
|
-
clampFit: bt,
|
|
1727
|
-
clampFitInt: Ys
|
|
1728
|
-
};
|
|
1729
|
-
function Zs(e = {}, ...t) {
|
|
1730
|
-
const n = new Dt(e, ...t);
|
|
1731
|
-
return n.run(), n;
|
|
1732
|
-
}
|
|
1733
|
-
function Xs(e = {}, ...t) {
|
|
1734
|
-
return Zs(Object.assign({}, zs, qt, Ks, Ss, e), ...[
|
|
1735
|
-
...Ws,
|
|
1736
|
-
..._s,
|
|
1737
|
-
...Wt,
|
|
1738
|
-
...t
|
|
1739
|
-
]);
|
|
1740
|
-
}
|
|
1741
|
-
const Qs = {
|
|
1742
|
-
bubbles: !0,
|
|
1743
|
-
cancelable: !0,
|
|
1744
|
-
composed: !0
|
|
1745
|
-
}, Ae = window, N = (e, t, n, s, o, r = Qs)=>{
|
|
1746
|
-
Ae.dispatchEvent(new CustomEvent(q, Object.assign({
|
|
1747
|
-
detail: {
|
|
1748
|
-
time: new Date,
|
|
1749
|
-
category: e,
|
|
1750
|
-
subcategory: t,
|
|
1751
|
-
type: n,
|
|
1752
|
-
target: at(s),
|
|
1753
|
-
message: o
|
|
1754
|
-
}
|
|
1755
|
-
}, r)));
|
|
1756
|
-
};
|
|
1757
|
-
Ae.ds || setTimeout(()=>{
|
|
1758
|
-
N("core", "init", "start", document.body, `Datastar v${Ye} loading`);
|
|
1759
|
-
const e = performance.now();
|
|
1760
|
-
Ae.ds = Xs();
|
|
1761
|
-
const t = performance.now();
|
|
1762
|
-
N("core", "init", "end", document.body, `Datastar v${Ye} loaded and attached to all DOM elements in ${(t - e).toFixed(2)}ms`);
|
|
1763
|
-
const n = document.createElement("style");
|
|
1764
|
-
n.innerHTML = "\n.datastar-inspector-highlight {\n border: 2px solid blue;\n}\n", document.head.appendChild(n), window.addEventListener("datastar-inspector-event", (e)=>{
|
|
1765
|
-
if ("detail" in e && "object" == typeof e.detail && e.detail) {
|
|
1766
|
-
const { detail: t } = e;
|
|
1767
|
-
if ("script" in t && "string" == typeof t.script) try {
|
|
1768
|
-
new Function(t.script)();
|
|
1769
|
-
} catch (e) {
|
|
1770
|
-
console.error(e);
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
});
|
|
1774
|
-
}, 0);
|
|
1775
|
-
export { qt as AttributeActions, Wt as AttributePlugins, Ks as BackendActions, Ws as BackendPlugins, Ft as BindAttributePlugin, Bt as ClassPlugin, Ct as CorePlugins, $t as CorePreprocessors, k as DATASTAR_CLASS_PREFIX, U as DATASTAR_STR, Dt as Datastar, Ut as EventPlugin, Us as FetchIndicatorPlugin, Bs as HeadersPlugin, bs as IntersectionPlugin, ws as ScrollIntoViewPlugin, gs as ShowPlugin, ys as TeleportPlugin, xt as TextPlugin, Vt as TwoWayBindingModelPlugin, Es as ViewTransitionPlugin, Ss as VisibilityActions, _s as VisibilityPlugins, ot as apply, se as argsHas, _e as argsToMs, q as datastarEventName, mt as docWithViewTransitionAPI, at as elemToSelector, Js as mergeHTMLFragment, he as remoteSignals, Zs as runDatastarWith, Xs as runDatastarWithAllPlugins, N as sendDatastarEvent, lt as storeFromPossibleContents, gt as supportsViewTransitions, ze as toHTMLorSVGElement }; //# sourceMappingURL=/sm/f6f92b3ab2fb83c5537b1f460774e082dabf5f4b2965609c51fc3065ab07633d.map
|