@cossackframework/renderer 0.9.0 → 0.9.2
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/README.md +171 -29
- package/agent-docs.json +33 -0
- package/dist/attributes.d.ts +824 -0
- package/dist/attributes.js +1 -0
- package/dist/browser.js +10 -8
- package/dist/component-tags.d.ts +69 -0
- package/dist/component-tags.js +106 -0
- package/dist/cossack-element.d.ts +31 -1
- package/dist/cossack-element.js +20 -25
- package/dist/cossack-html.d.ts +2 -3
- package/dist/cossack-html.js +742 -531
- package/dist/css-result.d.ts +9 -0
- package/dist/css-result.js +14 -0
- package/dist/css-scoping.d.ts +4 -0
- package/dist/css-scoping.js +95 -0
- package/dist/css.d.ts +3 -16
- package/dist/css.js +13 -111
- package/dist/diagnostics.d.ts +85 -0
- package/dist/diagnostics.js +465 -0
- package/dist/directives.d.ts +9 -7
- package/dist/directives.js +7 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -7
- package/dist/minify-html.d.ts +22 -0
- package/dist/minify-html.js +123 -18
- package/dist/server.d.ts +3 -1
- package/dist/server.js +6 -4
- package/dist/ssr-form-values.js +4 -3
- package/dist/style-registry.d.ts +42 -0
- package/dist/style-registry.js +73 -0
- package/dist/style-runtime.d.ts +47 -0
- package/dist/style-runtime.js +43 -0
- package/dist/template-analysis.d.ts +224 -0
- package/dist/template-analysis.js +321 -0
- package/dist/template-parse.d.ts +157 -0
- package/dist/template-parse.js +546 -0
- package/dist/template.d.ts +2 -0
- package/dist/template.js +3 -0
- package/package.json +18 -4
package/dist/cossack-html.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// @ts-self-types="./cossack-html.d.ts"
|
|
2
2
|
import { serializeFormValues as e } from "./ssr-form-values.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { RAW_TEXT_TAGS as t, getTemplateAnalysis as n, tokenizeHtml as r } from "./template-analysis.js";
|
|
4
|
+
import { recordStyleScope as i, stylesForScope as a } from "./style-runtime.js";
|
|
5
|
+
import { acquireStyle as o, flushStyleAcquisitions as s, isManagedStyle as c, releaseStyle as l, updateStyleRoot as u } from "./style-registry.js";
|
|
6
|
+
import { isComponentResult as d } from "./component.js";
|
|
7
|
+
import { compileComponentTags as f, mayContainComponentTags as ee } from "./component-tags.js";
|
|
8
|
+
import { CossackElement as p, getComponentRange as te, popCurrentInstance as ne, pushCurrentInstance as re, setComponentRange as m } from "./cossack-element.js";
|
|
9
|
+
import { BindResult as h, CacheResult as g, GuardResult as _, IfDefinedResult as v, KeyResult as y, LiveResult as b, PreventDefaultResult as ie, RepeatResult as x, resolveField as S, setField as ae } from "./directives.js";
|
|
6
10
|
//#region src/cossack-html.ts
|
|
7
|
-
var
|
|
11
|
+
var oe = class {
|
|
8
12
|
strings;
|
|
9
13
|
values;
|
|
10
14
|
_cossack_template_result = !0;
|
|
@@ -14,51 +18,123 @@ var h = class {
|
|
|
14
18
|
}
|
|
15
19
|
__cossackOwner;
|
|
16
20
|
__cossackScope;
|
|
17
|
-
},
|
|
18
|
-
let r = new
|
|
21
|
+
}, C = (e, t, n) => {
|
|
22
|
+
let r = new oe(e, t, n), i = p.currentRenderingInstance;
|
|
19
23
|
return i && (r.__cossackOwner = i, r.__cossackScope = i._getStyleScopeId()), r;
|
|
20
|
-
},
|
|
21
|
-
let
|
|
22
|
-
return
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
}, se = /* @__PURE__ */ new WeakMap(), ce = (e, t) => {
|
|
25
|
+
let n = se.get(e);
|
|
26
|
+
return n === void 0 && (n = ee(e) ? f(e, { svg: t }) : null, se.set(e, n)), n;
|
|
27
|
+
}, le = (e) => e === null ? "null" : typeof e == "function" ? `function ${e.name || "(anonymous)"}` : typeof e, ue = (e, t, n) => {
|
|
28
|
+
let r = t[e.binding];
|
|
29
|
+
if (typeof r != "function") throw TypeError(`[cossack/renderer] A component tag <\${...}> must bind a component class, not ${le(r)}.`);
|
|
30
|
+
if (e.closeBinding !== null && t[e.closeBinding] !== r) throw Error(`[cossack/renderer] The closing tag of <\${${r.name || "Component"}}> binds ${le(t[e.closeBinding])}. Close a component tag with the same class.`);
|
|
31
|
+
let i = {};
|
|
32
|
+
for (let n of e.props) if (n.kind === "static") i[n.name] = n.value;
|
|
33
|
+
else if (n.kind === "value") i[n.name] = t[n.binding];
|
|
34
|
+
else if (n.kind === "spread") {
|
|
35
|
+
let e = t[n.binding];
|
|
36
|
+
typeof e == "object" && e && Object.assign(i, e);
|
|
37
|
+
} else if (ze(n.bindings, t)) delete i[n.name];
|
|
38
|
+
else {
|
|
39
|
+
let e = n.segments[0];
|
|
40
|
+
for (let r = 0; r < n.bindings.length; r++) e += M(t[n.bindings[r]]) + n.segments[r + 1];
|
|
41
|
+
i[n.name] = e;
|
|
42
|
+
}
|
|
43
|
+
let a = e.children;
|
|
44
|
+
return pe(r, i, a.kind === "none" ? void 0 : a.kind === "text" ? a.text : a.kind === "slot" ? de(a.slot, t, n) : w(a.plan, t, n));
|
|
45
|
+
}, de = (e, t, n) => typeof e == "number" ? t[e] : ue(e, t, n), w = (e, t, n) => C(e.strings, e.slots.map((e) => de(e, t, n)), n), T = (e, ...t) => {
|
|
46
|
+
let n = ce(e, !1);
|
|
47
|
+
return n ? w(n, t, 1) : C(e, t, 1);
|
|
48
|
+
}, fe = (e, ...t) => {
|
|
49
|
+
let n = ce(e, !0);
|
|
50
|
+
return n ? w(n, t, 2) : C(e, t, 2);
|
|
51
|
+
}, E = Symbol.for("cossack-nothing");
|
|
52
|
+
function pe(e, t, n) {
|
|
53
|
+
return T`${{
|
|
26
54
|
_type: "COMPONENT",
|
|
27
55
|
clazz: e,
|
|
28
56
|
props: t ?? {},
|
|
29
|
-
children:
|
|
30
|
-
parent:
|
|
57
|
+
children: n,
|
|
58
|
+
parent: p.currentRenderingInstance
|
|
31
59
|
}}`;
|
|
32
60
|
}
|
|
33
|
-
var
|
|
61
|
+
var D = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0, me = Symbol.for("@cossackframework/renderer/unsafe-html"), he = class {
|
|
34
62
|
value;
|
|
35
|
-
[
|
|
63
|
+
[me] = !0;
|
|
36
64
|
constructor(e) {
|
|
37
65
|
this.value = e;
|
|
38
66
|
}
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
67
|
+
}, ge = (e) => new he(e), O = (e) => typeof e == "object" && !!e && e[me] === !0, _e = {
|
|
68
|
+
"&": "&",
|
|
69
|
+
"<": "<",
|
|
70
|
+
">": ">",
|
|
71
|
+
"\"": """,
|
|
72
|
+
"'": "'"
|
|
73
|
+
}, ve = /[&<>"']/, ye = /[&<>"']/g, k = (e) => {
|
|
74
|
+
let t = String(e);
|
|
75
|
+
return ve.test(t) ? t.replace(ye, (e) => _e[e]) : t;
|
|
76
|
+
}, A = (e) => typeof e == "function" ? "" : String(e), j = (e) => {
|
|
77
|
+
for (;;) if (e instanceof b || e instanceof v) e = e.value;
|
|
78
|
+
else if (e instanceof h) e = S(e.component, e.fieldName);
|
|
79
|
+
else return e;
|
|
80
|
+
}, M = (e) => (e = j(e), e === E || e == null || typeof e == "function" ? "" : String(e)), be = (e) => !e.whole && !/^[.?@]/.test(e.name) && e.name !== "ref" && e.name !== "...", xe = (e) => d(e) || Array.isArray(e) || e instanceof x || e instanceof y || e instanceof _ || e instanceof g, Se = (e) => {
|
|
81
|
+
let t = e.__parent;
|
|
82
|
+
if (!t) return;
|
|
83
|
+
let n;
|
|
84
|
+
do
|
|
85
|
+
n = `${t._id}:${t._childCounter++}`;
|
|
86
|
+
while (t._liveChildIds.has(n));
|
|
87
|
+
e._id = n, t._liveChildIds.set(n, e), P(t);
|
|
88
|
+
}, Ce = (e) => {
|
|
89
|
+
e.__parent && (e.__parent._childCounter++, P(e.__parent));
|
|
90
|
+
}, N = null, P = (e, t = 1) => {
|
|
91
|
+
if (!N) return;
|
|
92
|
+
let n = N.slots ??= /* @__PURE__ */ new Map();
|
|
93
|
+
n.set(e, (n.get(e) ?? 0) + t);
|
|
94
|
+
}, we = (e) => {
|
|
95
|
+
let t = N, n = { slots: null };
|
|
96
|
+
N = n;
|
|
97
|
+
try {
|
|
98
|
+
e();
|
|
99
|
+
} finally {
|
|
100
|
+
if (N = t, n.slots) for (let [e, t] of n.slots) P(e, t);
|
|
101
|
+
}
|
|
102
|
+
return n.slots;
|
|
103
|
+
}, Te = (e) => {
|
|
104
|
+
if (e) for (let [t, n] of e) t._childCounter += n, P(t, n);
|
|
105
|
+
}, Ee = (e) => {
|
|
106
|
+
let t = e.__parent?._liveChildIds;
|
|
107
|
+
t?.get(e._id) === e && t.delete(e._id);
|
|
108
|
+
}, De = (e, t) => {
|
|
109
|
+
e.willUpdate(/* @__PURE__ */ new Map());
|
|
110
|
+
let n = e._getWrappedTemplate, r = typeof n == "function" ? n.call(e) : e._finalizeRenderOutput(e.render());
|
|
111
|
+
return r ? We(D(r) ? r : T`${r}`, t) : "";
|
|
112
|
+
}, F = (e, t = {}) => {
|
|
113
|
+
if (e === E || e === "" || e == null || e === !1) return "";
|
|
114
|
+
if (Array.isArray(e)) return t.hydrate ? e.map((e) => `<!--CSA-S-->${F(e, t)}<!--CSA-E-->`).join("") : e.map((e) => F(e, t)).join("");
|
|
115
|
+
if (D(e)) return We(e, t);
|
|
116
|
+
if (e instanceof b || e instanceof v) return F(e.value, t);
|
|
117
|
+
if (e instanceof x) return t.hydrate ? e.items.map((n, r) => `<!--CSA-S-->${F(e.templateFn(n, r), t)}<!--CSA-E-->`).join("") : e.items.map((n, r) => F(e.templateFn(n, r), t)).join("");
|
|
118
|
+
if (e instanceof y) return F(e.template, t);
|
|
119
|
+
if (e instanceof _) return F(e.factory(), t);
|
|
120
|
+
if (e instanceof g) return F(e.value, t);
|
|
121
|
+
if (e instanceof h) return F(S(e.component, e.fieldName), t);
|
|
122
|
+
if (d(e)) {
|
|
123
|
+
let n = new e.clazz();
|
|
124
|
+
Object.assign(n, e.props), "props" in n && (n.props = e.props), n.children = e.children, n.__parent = e.parent || p.currentRenderingInstance, e.serviceScope && typeof n._setServiceScope == "function" && n._setServiceScope(e.serviceScope), n.__parent && (n._id = `${n.__parent._id}:${n.__parent._childCounter++}`), n.connectedCallback(), re(n);
|
|
52
125
|
try {
|
|
53
|
-
|
|
54
|
-
let e = t._getWrappedTemplate, n = typeof e == "function" ? e.call(t) : t._finalizeRenderOutput(t.render());
|
|
55
|
-
return n ? O(v(n) ? n : g`${n}`, c) : "";
|
|
126
|
+
return De(n, t);
|
|
56
127
|
} finally {
|
|
57
|
-
|
|
128
|
+
ne();
|
|
129
|
+
try {
|
|
130
|
+
n.disconnectedCallback();
|
|
131
|
+
} catch (e) {
|
|
132
|
+
console.error("[cossack] SSR component disconnection failed:", e);
|
|
133
|
+
}
|
|
58
134
|
}
|
|
59
135
|
}
|
|
60
|
-
return
|
|
61
|
-
},
|
|
136
|
+
return O(e) ? e.value : k(A(e));
|
|
137
|
+
}, I = /* @__PURE__ */ new Set([
|
|
62
138
|
"allowfullscreen",
|
|
63
139
|
"async",
|
|
64
140
|
"autofocus",
|
|
@@ -84,190 +160,167 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
84
160
|
"required",
|
|
85
161
|
"reversed",
|
|
86
162
|
"selected"
|
|
87
|
-
]),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
if (w.has(e)) {
|
|
102
|
-
i && (t.result += ` ${e}`);
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if ((e === "class" || e === "className") && i instanceof c) {
|
|
107
|
-
if (i.value === void 0) continue;
|
|
108
|
-
i = String(i.value);
|
|
109
|
-
}
|
|
110
|
-
if ((e === "class" || e === "className") && typeof i == "string") {
|
|
111
|
-
let e = ie(t.result, i);
|
|
112
|
-
if (e !== null) {
|
|
113
|
-
t.result = e;
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
import.meta.env?.DEV && console.warn("[cossack/renderer] spread class merge failed — falling back to a separate class attribute. If the tag already has a class attribute, check that it uses double quotes.");
|
|
117
|
-
}
|
|
118
|
-
if (i !== _) if (i instanceof c) i.value !== void 0 && (t.result += ` ${e}="${S(String(i.value))}"`);
|
|
119
|
-
else if (typeof i == "boolean") {
|
|
120
|
-
let n = T(e, i);
|
|
121
|
-
n === "" ? t.result += ` ${e}` : n !== null && (t.result += ` ${e}="${n}"`);
|
|
122
|
-
} else typeof i == "function" || i != null && (t.result += ` ${e}="${S(i)}"`);
|
|
123
|
-
}
|
|
124
|
-
}, ie = (e, t) => {
|
|
125
|
-
let n = e.lastIndexOf("<"), r = n >= 0 ? e.slice(n) : e, i = r.match(/(^|\s)class="([^"]*)"(\s|\/?>|$)/);
|
|
126
|
-
if (!i) return null;
|
|
127
|
-
let a = i[1], o = i[2], s = i[3], c = S(t.trim());
|
|
128
|
-
if (!c) return e;
|
|
129
|
-
let l = o ? `${o} ${c}` : c, u = r.replace(i[0], () => `${a}class="${l}"${s}`);
|
|
130
|
-
return e.slice(0, n) + u;
|
|
131
|
-
}, ae = (e) => {
|
|
132
|
-
let t = [], n = !1, r = null, i = /(\.\.\.|[.@?]?[a-zA-Z0-9_:-]+)=["']?$/;
|
|
133
|
-
for (let a = 0; a < e.length - 1; a++) {
|
|
134
|
-
let o = e[a];
|
|
135
|
-
for (let e = 0; e < o.length; e++) r ? o[e] === r && (r = null) : n && (o[e] === "\"" || o[e] === "'") ? e > 0 && o[e - 1] === "=" && (r = o[e]) : o[e] === "<" && o[e + 1] !== "!" && o[e + 1] !== "/" ? n = !0 : o[e] === ">" && (n = !1);
|
|
136
|
-
let s = o.match(i);
|
|
137
|
-
t[a] = !(n && (s || r));
|
|
163
|
+
]), L = (e, t) => I.has(e.toLowerCase()) ? t ? "" : null : String(t), Oe = (e) => (e instanceof v && (e = e.value === void 0 ? void 0 : String(e.value)), e === E || e == null || e === !1 || typeof e == "function" ? "" : String(e)), ke = (e) => e.split(/[ \t\n\f\r]+/).filter(Boolean), Ae = /^[?.@]?(?![?.@])[^\s"'<>/=\u0000-\u001f\u007f-\u009f]+$/u, je = (e) => {
|
|
164
|
+
let t = {
|
|
165
|
+
entries: /* @__PURE__ */ new Map(),
|
|
166
|
+
classes: [],
|
|
167
|
+
events: /* @__PURE__ */ new Map()
|
|
168
|
+
};
|
|
169
|
+
for (let n = 0; n < e.length; n++) {
|
|
170
|
+
let r = e[n];
|
|
171
|
+
if (!(typeof r != "object" || !r)) for (let [e, i] of Object.entries(r)) Ae.test(e) && (e === "class" || e === "className" ? t.classes.push(...ke(Oe(i))) : e.startsWith("@") ? t.events.set(`${n}:${e}`, {
|
|
172
|
+
key: e,
|
|
173
|
+
value: i
|
|
174
|
+
}) : (t.entries.delete(e), t.entries.set(e, i)));
|
|
138
175
|
}
|
|
139
176
|
return t;
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return
|
|
147
|
-
|
|
148
|
-
|
|
177
|
+
}, Me = (e, t, n) => {
|
|
178
|
+
if (t instanceof h && (t = S(t.component, t.fieldName)), t instanceof b && (t = t.value), t === E) return "";
|
|
179
|
+
if (e === "value") return ` ${n ? "value" : ".value"}="${k(String(t ?? ""))}"`;
|
|
180
|
+
let r = e.toLowerCase();
|
|
181
|
+
return I.has(r) && t ? ` ${r}` : "";
|
|
182
|
+
}, Ne = (e, t) => {
|
|
183
|
+
if (t === E || t == null || typeof t == "function") return null;
|
|
184
|
+
if (t instanceof v) return t.value === void 0 ? null : ` ${e}="${k(String(t.value))}"`;
|
|
185
|
+
if (typeof t == "boolean") {
|
|
186
|
+
let n = L(e, t);
|
|
187
|
+
return n === null ? null : n === "" ? ` ${e}` : ` ${e}="${n}"`;
|
|
188
|
+
}
|
|
189
|
+
return ` ${e}="${k(t)}"`;
|
|
190
|
+
}, Pe = (e, t) => {
|
|
191
|
+
let n = /* @__PURE__ */ new Map(), r = (e, t) => {
|
|
192
|
+
let r = e.toLowerCase();
|
|
193
|
+
n.delete(r), n.set(r, t);
|
|
149
194
|
};
|
|
150
|
-
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
}, se = class {
|
|
195
|
+
for (let [n, i] of e) if (n.startsWith("?")) r(n.slice(1), i !== E && i ? ` ${n.slice(1)}` : null);
|
|
196
|
+
else if (n.startsWith(".")) {
|
|
197
|
+
let e = n.slice(1), a = e === "value" ? t ? "value" : ".value" : I.has(e.toLowerCase()) ? e : void 0;
|
|
198
|
+
a && r(a, Me(e, i, t) || null);
|
|
199
|
+
} else r(n, Ne(n, i));
|
|
200
|
+
return n;
|
|
201
|
+
}, Fe = (e, t, n) => {
|
|
202
|
+
let i = r(e.slice(t))[0];
|
|
203
|
+
if (i?.type !== "start-tag") return e;
|
|
204
|
+
let a = i.attributes.find((e) => e.name.toLowerCase() === "class"), o = a && a.valueStart >= 0 ? ke(e.slice(t + a.valueStart, t + a.valueEnd)) : [], s = [.../* @__PURE__ */ new Set([...o, ...n.map((e) => k(e))])].join(" ");
|
|
205
|
+
if (!a) {
|
|
206
|
+
let n = t + (i.closed ? i.end - (i.selfClosing ? 2 : 1) : i.end);
|
|
207
|
+
return `${e.slice(0, n)} class="${s}"${e.slice(n)}`;
|
|
208
|
+
}
|
|
209
|
+
let c = t + (a.valueStart >= 0 ? a.valueStart : a.nameStart), l = t + (a.valueStart >= 0 ? a.valueEnd : a.nameEnd);
|
|
210
|
+
if (a.valueStart >= 0 && a.quote) return e.slice(0, c) + s + e.slice(l);
|
|
211
|
+
let u = `"${s.replace(/"/g, """)}"`;
|
|
212
|
+
return e.slice(0, c) + (a.valueStart >= 0 ? u : `class=${u}`) + e.slice(l);
|
|
213
|
+
}, Ie = (e, t, n, i, a) => {
|
|
214
|
+
let o = (e.slice(t, n) + e.slice(i)).toLowerCase(), s = !1;
|
|
215
|
+
for (let e of a.keys()) if (o.includes(e)) {
|
|
216
|
+
s = !0;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
if (!s) return e;
|
|
220
|
+
let c = r(e.slice(t))[0];
|
|
221
|
+
if (c?.type !== "start-tag") return e;
|
|
222
|
+
for (let r = c.attributes.length - 1; r >= 0; r--) {
|
|
223
|
+
let o = c.attributes[r], s = t + o.nameStart;
|
|
224
|
+
if (s >= n && s < i || !a.has(o.name.toLowerCase())) continue;
|
|
225
|
+
let l = t + (o.valueStart >= 0 ? o.valueEnd + +!!o.quote : o.nameEnd), u = s;
|
|
226
|
+
for (; u > t && /[ \t\n\f\r]/.test(e[u - 1]);) u--;
|
|
227
|
+
e = e.slice(0, u) + e.slice(l);
|
|
228
|
+
}
|
|
229
|
+
return e;
|
|
230
|
+
}, Le = (e, t) => {
|
|
231
|
+
let { entries: n, classes: r } = je(t.values), i = Pe(n, t.directValue), a = "";
|
|
232
|
+
for (let e of i.values()) e && (a += e);
|
|
233
|
+
let { tagStart: o, insertAt: s } = t;
|
|
234
|
+
return e = e.slice(0, s) + a + e.slice(s), i.size > 0 && (e = Ie(e, o, s, s + a.length, i)), r.length > 0 ? Fe(e, o, r) : e;
|
|
235
|
+
}, Re = (e) => n(e.strings, e.__cossackScope), ze = (e, t) => {
|
|
236
|
+
for (let n = 0; n < e.length; n++) if (t[e[n]] === E) return !0;
|
|
237
|
+
return !1;
|
|
238
|
+
}, Be = (e) => (e = j(e), e === E || e == null || e === !1 ? "" : Array.isArray(e) ? e.map(Be).join("") : O(e) ? e.value : A(e)), Ve = (e, t) => {
|
|
239
|
+
let n = Be(t);
|
|
240
|
+
return e === "script" ? n.replace(/<\/(script)/gi, "<\\/$1").replace(/<!--/g, "\\u003c!--") : e === "style" ? n.replace(/<\/(style)/gi, "<\\/$1") : n;
|
|
241
|
+
}, He = (e, t, n) => {
|
|
242
|
+
let r = Ve(e, t);
|
|
243
|
+
if (e === "script" || e === "style") return r;
|
|
244
|
+
let i = k(r);
|
|
245
|
+
return e === "textarea" && n && i.startsWith("\n") ? `\n${i}` : i;
|
|
246
|
+
}, Ue = class {
|
|
203
247
|
resultObj;
|
|
204
248
|
opts;
|
|
205
249
|
result = "";
|
|
206
250
|
stringIdx = 0;
|
|
207
251
|
charIdxForNext = 0;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
252
|
+
analysis;
|
|
253
|
+
stringStarts = [];
|
|
254
|
+
pendingSpreads = null;
|
|
211
255
|
constructor(e, t = {}) {
|
|
212
|
-
this.resultObj = e, this.opts = t, this.
|
|
256
|
+
this.resultObj = e, this.opts = t, this.analysis = Re(e), e.__cossackScope !== void 0 && i(e.__cossackScope);
|
|
213
257
|
}
|
|
214
258
|
scan() {
|
|
215
|
-
let { values:
|
|
216
|
-
for (; this.stringIdx <
|
|
217
|
-
let
|
|
218
|
-
if (
|
|
219
|
-
let e =
|
|
220
|
-
|
|
221
|
-
|
|
259
|
+
let { values: e } = this.resultObj, { strings: t, bindings: n, attributeGroups: r } = this.analysis;
|
|
260
|
+
for (; this.stringIdx < t.length;) {
|
|
261
|
+
let i = t[this.stringIdx], a = this.pendingSpreads;
|
|
262
|
+
if (a && a.endString === this.stringIdx) {
|
|
263
|
+
let e = a.endOffset + 1;
|
|
264
|
+
this.result += i.substring(this.charIdxForNext, e), this.result = Le(this.result, a), this.pendingSpreads = null, this.stringStarts[this.stringIdx] = this.result.length - e, this.result += i.substring(e);
|
|
265
|
+
} else this.stringStarts[this.stringIdx] = this.result.length - this.charIdxForNext, this.result += i.substring(this.charIdxForNext);
|
|
266
|
+
if (this.charIdxForNext = 0, this.stringIdx < t.length - 1) {
|
|
267
|
+
let a = n[this.stringIdx], o = e[this.stringIdx];
|
|
268
|
+
a.kind === "attribute" && o instanceof b && (o = o.value);
|
|
269
|
+
let s = r[this.stringIdx];
|
|
270
|
+
if (s && !(a.kind === "attribute" && a.name === "...") && ze(s.indices, e)) {
|
|
271
|
+
this.result.endsWith(s.prefix) && (this.result = this.result.slice(0, -s.prefix.length)), this.stringIdx = s.indices[s.indices.length - 1], this.charIdxForNext = s.suffixLength, this.stringIdx++;
|
|
222
272
|
continue;
|
|
223
273
|
}
|
|
224
|
-
if (
|
|
225
|
-
let
|
|
226
|
-
this.result = this.result.substring(0, this.result.length -
|
|
227
|
-
let
|
|
228
|
-
if (
|
|
274
|
+
if (a.kind === "attribute" && a.start && !be(a)) {
|
|
275
|
+
let e = i.slice(a.prefixStart), n = a.name;
|
|
276
|
+
this.result = this.result.substring(0, this.result.length - e.length);
|
|
277
|
+
let r = a.quote, s = !0;
|
|
278
|
+
if (n === "...") {
|
|
229
279
|
this.result = this.result.trimEnd();
|
|
230
|
-
let
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
else if (
|
|
245
|
-
else if (typeof
|
|
280
|
+
let e = this.stringStarts[a.tagString] + a.tagOffset, t = this.pendingSpreads;
|
|
281
|
+
t?.tagStart === e ? (t.values.push(o), t.insertAt = this.result.length) : this.pendingSpreads = {
|
|
282
|
+
tagStart: e,
|
|
283
|
+
insertAt: this.result.length,
|
|
284
|
+
values: [o],
|
|
285
|
+
directValue: a.directValue,
|
|
286
|
+
endString: a.tagEndString,
|
|
287
|
+
endOffset: a.tagEndOffset
|
|
288
|
+
};
|
|
289
|
+
} else if (n === "ref") this.result = this.result.trimEnd();
|
|
290
|
+
else if (n.startsWith("@")) this.result = this.result.trimEnd();
|
|
291
|
+
else if (n.startsWith("?")) o ? (this.result = this.result.trimEnd(), this.result += ` ${n.slice(1)}`) : this.result = this.result.trimEnd();
|
|
292
|
+
else if (n.startsWith(".")) this.result = this.result.trimEnd(), this.result += Me(n.slice(1), o, a.directValue);
|
|
293
|
+
else if (o instanceof v) o.value === void 0 ? this.result = this.result.trimEnd() : (this.result = this.result.trimEnd(), this.result += ` ${n}="${k(String(o.value))}"`);
|
|
294
|
+
else if (o == null || o === E) this.result = this.result.trimEnd();
|
|
295
|
+
else if (typeof o == "boolean") {
|
|
246
296
|
this.result = this.result.trimEnd();
|
|
247
|
-
let
|
|
248
|
-
|
|
297
|
+
let e = L(n, o);
|
|
298
|
+
e === "" ? this.result += ` ${n}` : e !== null && (this.result += ` ${n}="${e}"`);
|
|
249
299
|
} else {
|
|
250
|
-
this.result +=
|
|
251
|
-
let
|
|
252
|
-
|
|
300
|
+
this.result += e;
|
|
301
|
+
let t = k(M(o));
|
|
302
|
+
r ? (this.result += t, s = !1) : this.result += `"${t}"`;
|
|
253
303
|
}
|
|
254
|
-
if (
|
|
255
|
-
let e =
|
|
256
|
-
e && e.startsWith(
|
|
304
|
+
if (r && s) {
|
|
305
|
+
let e = t[this.stringIdx + 1];
|
|
306
|
+
e && e.startsWith(r) && (this.charIdxForNext = 1);
|
|
257
307
|
}
|
|
258
|
-
} else this.
|
|
308
|
+
} else a.kind === "raw-text" ? this.result += He(a.tag, o, a.first) : a.kind === "attribute" ? this.result += k(M(o)) : a.kind === "comment" || a.kind === "element" || (a.kind === "node" && this.opts.hydrate ? (this.result += `<!--CRP_${this.stringIdx}-->`, this.result += F(o, this.opts), this.result += "<!--/CRP-->") : this.result += F(o, this.opts));
|
|
259
309
|
}
|
|
260
310
|
this.stringIdx++;
|
|
261
311
|
}
|
|
262
|
-
return
|
|
312
|
+
return this.pendingSpreads && (this.result = Le(this.result, this.pendingSpreads)), this.result;
|
|
263
313
|
}
|
|
264
|
-
},
|
|
265
|
-
|
|
314
|
+
}, We = (e, t) => new Ue(e, t).scan(), Ge = (t, n = {}) => e(We(t, n)), R = !!import.meta.env?.DEV, Ke = R, qe = (e, t, n) => {
|
|
315
|
+
for (let r = 0, i = 0; r < e.length; r++) if (Object.is(e[r], t) && i++ === n) return r;
|
|
316
|
+
return -1;
|
|
317
|
+
}, z = R ? /* @__PURE__ */ new WeakMap() : void 0, Je = (e, t) => {
|
|
318
|
+
if (!(!R || !t)) for (let n = 0; n < e.length; n++) e[n] && z.set(e[n], {
|
|
266
319
|
...t,
|
|
267
320
|
fields: void 0,
|
|
268
321
|
statePath: t.fields?.[n] ?? t.statePath
|
|
269
322
|
});
|
|
270
|
-
},
|
|
323
|
+
}, B = (e, t) => ({
|
|
271
324
|
identity: e.identity,
|
|
272
325
|
parts: e.parts.map((n) => {
|
|
273
326
|
if (!n) return;
|
|
@@ -285,23 +338,23 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
285
338
|
return {
|
|
286
339
|
...n,
|
|
287
340
|
component: r,
|
|
288
|
-
template: n.template ?
|
|
289
|
-
cached: new Map([...n.cached].map(([e, n]) => [e,
|
|
290
|
-
children:
|
|
341
|
+
template: n.template ? B(n.template, t) : void 0,
|
|
342
|
+
cached: new Map([...n.cached].map(([e, n]) => [e, B(n, t)])),
|
|
343
|
+
children: B({
|
|
291
344
|
identity: e.identity,
|
|
292
345
|
parts: n.children
|
|
293
346
|
}, t).parts,
|
|
294
347
|
keys: [...n.keys]
|
|
295
348
|
};
|
|
296
349
|
})
|
|
297
|
-
}),
|
|
350
|
+
}), V = /* @__PURE__ */ new WeakMap(), H = (e) => e.map((e) => e instanceof K ? e.captureDraft() : void 0), U = (e, t, n) => {
|
|
298
351
|
!t || t.tree.identity !== n || !t.context.active || !t.context.current() || e.forEach((e, n) => {
|
|
299
|
-
e instanceof
|
|
352
|
+
e instanceof K && e.restoreDraft(t.tree.parts[n], t.context);
|
|
300
353
|
});
|
|
301
|
-
},
|
|
302
|
-
let t =
|
|
354
|
+
}, Ye = (e) => {
|
|
355
|
+
let t = q.get(e), n = t ? {
|
|
303
356
|
identity: t.identity,
|
|
304
|
-
parts:
|
|
357
|
+
parts: H(t.parts)
|
|
305
358
|
} : void 0, r;
|
|
306
359
|
return {
|
|
307
360
|
restore(t, i = []) {
|
|
@@ -309,27 +362,27 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
309
362
|
active: !0,
|
|
310
363
|
current: t,
|
|
311
364
|
owners: new Map(i)
|
|
312
|
-
},
|
|
365
|
+
}, V.set(e, {
|
|
313
366
|
tree: n,
|
|
314
367
|
context: r
|
|
315
368
|
}), n = void 0);
|
|
316
369
|
},
|
|
317
370
|
discard() {
|
|
318
|
-
n = void 0, r && (r.active = !1, r.owners.clear(),
|
|
371
|
+
n = void 0, r && (r.active = !1, r.owners.clear(), V.get(e)?.context === r && V.delete(e));
|
|
319
372
|
}
|
|
320
373
|
};
|
|
321
|
-
},
|
|
374
|
+
}, W = (e) => {
|
|
322
375
|
for (let t of e) try {
|
|
323
376
|
t?.dispose?.();
|
|
324
377
|
} catch (e) {
|
|
325
378
|
console.error("[cossack] Failed render cleanup:", e);
|
|
326
379
|
}
|
|
327
|
-
},
|
|
328
|
-
let t =
|
|
329
|
-
t || (t = /* @__PURE__ */ new Map(),
|
|
380
|
+
}, Xe = /* @__PURE__ */ new WeakMap(), G = (e) => {
|
|
381
|
+
let t = Xe.get(e.strings);
|
|
382
|
+
t || (t = /* @__PURE__ */ new Map(), Xe.set(e.strings, t));
|
|
330
383
|
let n = `${e._$litType$}:${e.__cossackScope ?? ""}`, r = t.get(n);
|
|
331
384
|
return r || (r = {}, t.set(n, r)), r;
|
|
332
|
-
},
|
|
385
|
+
}, K = class e {
|
|
333
386
|
startNode;
|
|
334
387
|
endNode;
|
|
335
388
|
_draft;
|
|
@@ -337,10 +390,10 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
337
390
|
_cacheDrafts = /* @__PURE__ */ new Map();
|
|
338
391
|
captureDraft() {
|
|
339
392
|
let e = this.componentInstance, t = /* @__PURE__ */ new Map();
|
|
340
|
-
for (let [e, n] of this._cacheDrafts) n.context.active && n.context.current() && t.set(e,
|
|
393
|
+
for (let [e, n] of this._cacheDrafts) n.context.active && n.context.current() && t.set(e, B(n.tree, n.context));
|
|
341
394
|
for (let [e, n] of this._cacheMap) e !== this._cachedTemplateIdentity && t.set(e, {
|
|
342
395
|
identity: e,
|
|
343
|
-
parts:
|
|
396
|
+
parts: H(n.parts)
|
|
344
397
|
});
|
|
345
398
|
return {
|
|
346
399
|
component: e ? {
|
|
@@ -353,7 +406,7 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
353
406
|
} : void 0,
|
|
354
407
|
template: this._cachedParts && this._cachedTemplateIdentity ? {
|
|
355
408
|
identity: this._cachedTemplateIdentity,
|
|
356
|
-
parts:
|
|
409
|
+
parts: H(this._cachedParts)
|
|
357
410
|
} : void 0,
|
|
358
411
|
cached: t,
|
|
359
412
|
children: this._childParts.map((e) => e.captureDraft()),
|
|
@@ -382,11 +435,25 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
382
435
|
this._componentDraft = void 0, this.updateNode(e, t ?? null);
|
|
383
436
|
}
|
|
384
437
|
componentInstance = null;
|
|
438
|
+
range = (() => {
|
|
439
|
+
let e = this;
|
|
440
|
+
return {
|
|
441
|
+
get start() {
|
|
442
|
+
return e.startNode;
|
|
443
|
+
},
|
|
444
|
+
get end() {
|
|
445
|
+
return e.endNode;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
})();
|
|
385
449
|
renderListener = null;
|
|
386
450
|
_childParts = [];
|
|
387
451
|
_partKeys = [];
|
|
388
452
|
_cachedTemplateIdentity = null;
|
|
389
453
|
_cachedParts = null;
|
|
454
|
+
_unsafeHTML = void 0;
|
|
455
|
+
_committed = void 0;
|
|
456
|
+
_committedSlots = null;
|
|
390
457
|
_key = void 0;
|
|
391
458
|
_keySet = !1;
|
|
392
459
|
_guardDeps = null;
|
|
@@ -402,17 +469,23 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
402
469
|
this._hydrating = !0;
|
|
403
470
|
}
|
|
404
471
|
update(e) {
|
|
472
|
+
e = j(e);
|
|
473
|
+
let t = this._committed;
|
|
474
|
+
this._committed = void 0;
|
|
405
475
|
try {
|
|
406
|
-
if (!(e instanceof
|
|
407
|
-
this._hydrating = !1,
|
|
476
|
+
if (!(e instanceof g) && !(e instanceof _) && this._cacheDrafts.clear(), this._hydrating) {
|
|
477
|
+
if (this._hydrating = !1, D(e)) {
|
|
478
|
+
let t = e;
|
|
479
|
+
this._committedSlots = we(() => this._hydrateValue(t)), this._committed = t;
|
|
480
|
+
} else this._hydrateValue(e);
|
|
408
481
|
return;
|
|
409
482
|
}
|
|
410
|
-
e instanceof
|
|
483
|
+
e instanceof _ ? (e = this._resolveGuard(e), e instanceof g || this._cacheDrafts.clear()) : this._guardHasDeps && (this._guardHasDeps = !1, this._guardDeps = null, this._guardValue = void 0), O(e) || (this._unsafeHTML = void 0);
|
|
411
484
|
let n = !1;
|
|
412
|
-
if (e instanceof
|
|
485
|
+
if (e instanceof g) {
|
|
413
486
|
this.prepareCacheDrafts();
|
|
414
487
|
let t = e.value;
|
|
415
|
-
if (
|
|
488
|
+
if (D(t)) {
|
|
416
489
|
this.componentInstance && this.disposeComponent(), this._childParts.length > 0 && this.clearChildParts(), this.updateCache(t);
|
|
417
490
|
return;
|
|
418
491
|
}
|
|
@@ -423,12 +496,23 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
423
496
|
}
|
|
424
497
|
if (n && this._cacheCurrent) {
|
|
425
498
|
if (this._stashCurrent(), this._draft) {
|
|
426
|
-
for (let e of this._cacheMap.values())
|
|
499
|
+
for (let e of this._cacheMap.values()) W(e.parts);
|
|
427
500
|
this._cacheMap.clear();
|
|
428
501
|
}
|
|
429
502
|
this._cacheCurrent = null;
|
|
430
503
|
}
|
|
431
|
-
this.componentInstance && (!
|
|
504
|
+
if (this.componentInstance && (!d(e) || e.clazz !== this.componentInstance.constructor) && this.disposeComponent(), !(e instanceof x) && !Array.isArray(e) && this._childParts.length > 0 && this.clearChildParts(), !(e instanceof y) && this._draft?.snapshot.keySet && (this._draft = void 0), d(e)) this.updateComponent(e);
|
|
505
|
+
else if (e instanceof x) this.updateRepeat(e);
|
|
506
|
+
else if (e instanceof y) this.updateKey(e);
|
|
507
|
+
else if (Array.isArray(e)) this.updateArray(e);
|
|
508
|
+
else if (D(e)) {
|
|
509
|
+
if (e === t && !n && this._draft === void 0 && this._cachedParts && this._cachedTemplateIdentity === G(e) && this.startNode.parentNode) {
|
|
510
|
+
this._committed = e, Te(this._committedSlots);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
let r = e;
|
|
514
|
+
this._committedSlots = we(() => this.updateNode(r)), this._committed = r;
|
|
515
|
+
} else this.updateNode(e);
|
|
432
516
|
} finally {
|
|
433
517
|
this._draft = void 0;
|
|
434
518
|
}
|
|
@@ -443,15 +527,15 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
443
527
|
return !0;
|
|
444
528
|
}
|
|
445
529
|
_hydrateValue(e) {
|
|
446
|
-
if (
|
|
530
|
+
if (e = j(e), d(e)) {
|
|
447
531
|
this._adoptComponent(e);
|
|
448
532
|
return;
|
|
449
533
|
}
|
|
450
|
-
if (
|
|
534
|
+
if (D(e)) {
|
|
451
535
|
this._adoptTemplate(e);
|
|
452
536
|
return;
|
|
453
537
|
}
|
|
454
|
-
if (e instanceof
|
|
538
|
+
if (e instanceof x) {
|
|
455
539
|
this._adoptSequence(e.items.map((t, n) => e.templateFn(t, n)), e.items.map((t, n) => e.keyFn(t, n)));
|
|
456
540
|
return;
|
|
457
541
|
}
|
|
@@ -459,51 +543,55 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
459
543
|
this._adoptSequence(e);
|
|
460
544
|
return;
|
|
461
545
|
}
|
|
462
|
-
if (e instanceof
|
|
463
|
-
if (
|
|
546
|
+
if (e instanceof y) {
|
|
547
|
+
if (D(e.template)) {
|
|
464
548
|
this._keySet = !0, this._key = e.value, this._adoptTemplate(e.template);
|
|
465
549
|
return;
|
|
466
550
|
}
|
|
467
551
|
this.clear(), this._clearTemplateCache(), this.updateNode(e.template);
|
|
468
552
|
return;
|
|
469
553
|
}
|
|
470
|
-
if (e instanceof
|
|
554
|
+
if (e instanceof _) {
|
|
471
555
|
let t = this._resolveGuard(e);
|
|
472
556
|
this._hydrateValue(t);
|
|
473
557
|
return;
|
|
474
558
|
}
|
|
475
|
-
if (e instanceof
|
|
559
|
+
if (e instanceof g) {
|
|
476
560
|
let t = e.value;
|
|
477
|
-
if (
|
|
478
|
-
let e =
|
|
561
|
+
if (D(t)) {
|
|
562
|
+
let e = G(t);
|
|
479
563
|
this._cacheMap.has(e) ? this.updateCache(t) : (this._adoptTemplate(t), this._cacheCurrent = e);
|
|
480
564
|
} else this._hydrateValue(t);
|
|
481
565
|
return;
|
|
482
566
|
}
|
|
483
|
-
if (e ===
|
|
567
|
+
if (e === E || e === "" || e == null || e === !1) {
|
|
484
568
|
this.clear();
|
|
485
569
|
return;
|
|
486
570
|
}
|
|
487
|
-
if (
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
this.
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
if (typeof e != "object") {
|
|
494
|
-
let t = String(e), n = this.startNode.nextSibling;
|
|
495
|
-
n && n.nodeType === Node.TEXT_NODE && n.nextSibling === this.endNode ? n.nodeValue !== t && (k && X(new J("text-content", ue(n), "text", "text"), A.get(this)?.boundary ?? "root", void 0, A.get(this), "text-reconcile"), n.nodeValue = t) : (this.clear(), this.startNode.parentNode.insertBefore(document.createTextNode(t), this.endNode));
|
|
571
|
+
if (e instanceof Node) return;
|
|
572
|
+
if (O(e)) {
|
|
573
|
+
if (this.startNode.nextSibling !== this.endNode) {
|
|
574
|
+
this._unsafeHTML = e.value;
|
|
496
575
|
return;
|
|
497
576
|
}
|
|
498
577
|
this.clear(), this._clearTemplateCache(), this.updateNode(e);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
let t = A(e);
|
|
581
|
+
if (t === "") {
|
|
582
|
+
this.clear();
|
|
583
|
+
return;
|
|
499
584
|
}
|
|
585
|
+
let n = this.startNode.nextSibling;
|
|
586
|
+
n && n.nodeType === Node.TEXT_NODE && n.nextSibling === this.endNode ? n.nodeValue !== t && (R && Q(new X("text-content", ft(n), "text", "text"), z.get(this)?.boundary ?? "root", void 0, z.get(this), "text-reconcile"), n.nodeValue = t) : (this.clear(), this.startNode.parentNode.insertBefore(document.createTextNode(t), this.endNode));
|
|
500
587
|
}
|
|
501
588
|
_adoptComponent(e) {
|
|
502
|
-
let t = e.parent ||
|
|
503
|
-
if (this.componentInstance && (this.componentInstance.constructor !== e.clazz || this.componentInstance.__parent !== t) && this.disposeComponent(),
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
589
|
+
let t = e.parent || p.currentRenderingInstance;
|
|
590
|
+
if (this.componentInstance && (this.componentInstance.constructor !== e.clazz || this.componentInstance.__parent !== t) && this.disposeComponent(), this.componentInstance) Ce(this.componentInstance), m(this.componentInstance, this.range);
|
|
591
|
+
else {
|
|
592
|
+
if (this.componentInstance = new e.clazz(), this.componentInstance.__parent = t, e.serviceScope && typeof this.componentInstance._setServiceScope == "function" && this.componentInstance._setServiceScope(e.serviceScope), Se(this.componentInstance), m(this.componentInstance, this.range), R) {
|
|
593
|
+
let t = this.componentInstance.hydrationMetadata, n = z.get(this);
|
|
594
|
+
z.set(this, {
|
|
507
595
|
...n,
|
|
508
596
|
...t,
|
|
509
597
|
component: t?.component ?? e.clazz.name ?? n?.component,
|
|
@@ -514,10 +602,10 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
514
602
|
}
|
|
515
603
|
let n = !0;
|
|
516
604
|
this.renderListener = (t) => {
|
|
517
|
-
if (n) if (n = !1,
|
|
605
|
+
if (n) if (n = !1, D(t)) try {
|
|
518
606
|
this._adoptTemplate(t);
|
|
519
607
|
} catch (n) {
|
|
520
|
-
if (n instanceof
|
|
608
|
+
if (n instanceof X) R && Q(n, "component", e.clazz.name || "anonymous", z.get(this)), this.clear(), this._clearTemplateCache(), this.updateComponentTemplate(t);
|
|
521
609
|
else throw n;
|
|
522
610
|
}
|
|
523
611
|
else t == null ? this.clear() : this.updateComponentTemplate(t);
|
|
@@ -529,31 +617,31 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
529
617
|
throw this.disposeComponent(), e;
|
|
530
618
|
}
|
|
531
619
|
}
|
|
532
|
-
let
|
|
533
|
-
this._draft?.snapshot.component?.instance ===
|
|
620
|
+
let n = this.componentInstance;
|
|
621
|
+
this._draft?.snapshot.component?.instance === n && this.restoreComponentDraft(n), Object.assign(n, e.props), "props" in n && (n.props = e.props), n.children = e.children, n.requestUpdate();
|
|
534
622
|
}
|
|
535
623
|
_adoptSequence(t, n) {
|
|
536
|
-
let r =
|
|
537
|
-
if (r.length !== t.length) throw new
|
|
624
|
+
let r = dt(this._nodesBetween());
|
|
625
|
+
if (r.length !== t.length) throw new X("sequence-length", "sequence", `${t.length} client items`, `${r.length} SSR items`);
|
|
538
626
|
this._childParts = [], this._partKeys = n ? [] : this._partKeys;
|
|
539
627
|
for (let i = 0; i < t.length; i++) {
|
|
540
628
|
let [a, o] = r[i], s = new e(a, o);
|
|
541
|
-
if (
|
|
542
|
-
let e =
|
|
543
|
-
e &&
|
|
629
|
+
if (R) {
|
|
630
|
+
let e = z.get(this);
|
|
631
|
+
e && z.set(s, e);
|
|
544
632
|
}
|
|
545
633
|
s._beginHydration(), this._childParts.push(s), n && this._partKeys.push(n[i]), s.update(t[i]);
|
|
546
634
|
}
|
|
547
635
|
}
|
|
548
636
|
_adoptTemplate(e) {
|
|
549
|
-
let { fragment: t, parts: n } =
|
|
637
|
+
let { fragment: t, parts: n } = J(e);
|
|
550
638
|
try {
|
|
551
639
|
let r = this._nodesBetween(), i = /* @__PURE__ */ new Map();
|
|
552
|
-
|
|
640
|
+
pt(t.childNodes, r, i, "root", R ? z.get(this) : void 0), mt(n, i), Je(n, R ? z.get(this) : void 0);
|
|
553
641
|
for (let t = 0; t < e.values.length; t++) n[t] && n[t].update(e.values[t]);
|
|
554
|
-
this._cachedTemplateIdentity =
|
|
642
|
+
this._cachedTemplateIdentity = G(e), this._cachedParts = n, this.startNode.isConnected && s();
|
|
555
643
|
} catch (e) {
|
|
556
|
-
throw
|
|
644
|
+
throw W(n), e;
|
|
557
645
|
}
|
|
558
646
|
}
|
|
559
647
|
_nodesBetween() {
|
|
@@ -571,7 +659,7 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
571
659
|
try {
|
|
572
660
|
typeof e.destroy == "function" && e.destroy();
|
|
573
661
|
} catch {} finally {
|
|
574
|
-
e._frameworkRendererDetached?.();
|
|
662
|
+
te(e) === this.range && m(e, void 0), Ee(e), e._frameworkRendererDetached?.();
|
|
575
663
|
}
|
|
576
664
|
}
|
|
577
665
|
}
|
|
@@ -579,9 +667,10 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
579
667
|
this.componentInstance && (this.teardownComponent(this.componentInstance), this.componentInstance = null, this._clearTemplateCache());
|
|
580
668
|
}
|
|
581
669
|
updateComponent(e) {
|
|
582
|
-
let t = e.parent ||
|
|
583
|
-
if (this.componentInstance && this.componentInstance.__parent !== t && this.disposeComponent(),
|
|
584
|
-
|
|
670
|
+
let t = e.parent || p.currentRenderingInstance;
|
|
671
|
+
if (this.componentInstance && this.componentInstance.__parent !== t && this.disposeComponent(), this.componentInstance) Ce(this.componentInstance), m(this.componentInstance, this.range);
|
|
672
|
+
else {
|
|
673
|
+
this.componentInstance = new e.clazz(), this.componentInstance.__parent = t, e.serviceScope && typeof this.componentInstance._setServiceScope == "function" && this.componentInstance._setServiceScope(e.serviceScope), Se(this.componentInstance), m(this.componentInstance, this.range), this.renderListener = (e) => {
|
|
585
674
|
this.updateComponentTemplate(e);
|
|
586
675
|
}, this.componentInstance.addRenderListener(this.renderListener), Object.assign(this.componentInstance, e.props), "props" in this.componentInstance && (this.componentInstance.props = e.props), this.componentInstance.children = e.children;
|
|
587
676
|
try {
|
|
@@ -590,27 +679,35 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
590
679
|
throw this.disposeComponent(), e;
|
|
591
680
|
}
|
|
592
681
|
}
|
|
593
|
-
let
|
|
594
|
-
this._draft?.snapshot.component?.instance ===
|
|
682
|
+
let n = this.componentInstance;
|
|
683
|
+
this._draft?.snapshot.component?.instance === n && this.restoreComponentDraft(n), Object.assign(n, e.props), "props" in n && (n.props = e.props), n.children = e.children, n.requestUpdate();
|
|
595
684
|
}
|
|
596
685
|
updateRepeat(e) {
|
|
597
|
-
let { items: t, keyFn: n, templateFn: r } = e, i = /* @__PURE__ */ new Map();
|
|
686
|
+
let { items: t, keyFn: n, templateFn: r } = e, i = /* @__PURE__ */ new Map(), a = [];
|
|
598
687
|
this._childParts.forEach((e, t) => {
|
|
599
|
-
|
|
600
|
-
|
|
688
|
+
if (t >= this._partKeys.length) {
|
|
689
|
+
a.push(e);
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
let n = this._partKeys[t], r = i.get(n);
|
|
693
|
+
r ? r.push(e) : i.set(n, [e]);
|
|
601
694
|
});
|
|
602
|
-
let
|
|
695
|
+
let o = [], s = [], c = /* @__PURE__ */ new Map(), l = !1, u = this.startNode;
|
|
603
696
|
try {
|
|
604
697
|
t.forEach((e, t) => {
|
|
605
|
-
let
|
|
606
|
-
|
|
607
|
-
let
|
|
608
|
-
|
|
609
|
-
let
|
|
610
|
-
|
|
611
|
-
|
|
698
|
+
let a = n(e, t);
|
|
699
|
+
s.push(a);
|
|
700
|
+
let d = c.get(a) ?? 0;
|
|
701
|
+
c.set(a, d + 1), d > 0 && (l = !0);
|
|
702
|
+
let f = i.get(a)?.shift();
|
|
703
|
+
if (f ? f.startNode.previousSibling !== u && this.movePart(f, u) : f = this.createChildPart(u), o.push(f), this._draft) {
|
|
704
|
+
let e = qe(this._draft.snapshot.keys, a, d);
|
|
705
|
+
e !== -1 && f.restoreDraft(this._draft.snapshot.children[e], this._draft.context);
|
|
706
|
+
}
|
|
707
|
+
f.update(r(e, t)), u = f.endNode;
|
|
708
|
+
}), l && Ke && console.warn("[cossack/renderer] repeat() received a duplicate key. Keys must be unique; duplicates are matched by position and lose identity when the list reorders."), i.forEach((e) => e.forEach((e) => e.dispose())), a.forEach((e) => e.dispose()), this._childParts = o, this._partKeys = s;
|
|
612
709
|
} catch (e) {
|
|
613
|
-
throw
|
|
710
|
+
throw W([.../* @__PURE__ */ new Set([...this._childParts, ...o])]), this._childParts = [], this._partKeys = [], e;
|
|
614
711
|
}
|
|
615
712
|
}
|
|
616
713
|
updateKey(e) {
|
|
@@ -622,7 +719,7 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
622
719
|
for (let [e, t] of this._cacheDrafts) (!t.context.active || !t.context.current()) && this._cacheDrafts.delete(e);
|
|
623
720
|
if (this._draft && this._draft.context.active && this._draft.context.current()) {
|
|
624
721
|
let { snapshot: e, context: t } = this._draft;
|
|
625
|
-
for (let [e, t] of this._cacheMap) e !== this._cachedTemplateIdentity && (
|
|
722
|
+
for (let [e, t] of this._cacheMap) e !== this._cachedTemplateIdentity && (W(t.parts), this._cacheMap.delete(e));
|
|
626
723
|
for (let [n, r] of e.cached) this._cacheDrafts.set(n, {
|
|
627
724
|
tree: r,
|
|
628
725
|
context: t
|
|
@@ -634,21 +731,21 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
634
731
|
}
|
|
635
732
|
}
|
|
636
733
|
updateCache(e) {
|
|
637
|
-
let t =
|
|
734
|
+
let t = G(e), n = this._cacheDrafts.get(t);
|
|
638
735
|
if (this._cacheDrafts.delete(t), this._cacheCurrent === t && this._cachedParts) {
|
|
639
|
-
|
|
736
|
+
U(this._cachedParts, n, t), this._cachedParts.forEach((t, n) => {
|
|
640
737
|
t.update(e.values[n]);
|
|
641
738
|
});
|
|
642
739
|
return;
|
|
643
740
|
}
|
|
644
|
-
if ((this._cacheCurrent || this._cachedParts) && (this._stashCurrent(), this._draft)) for (let [e, n] of this._cacheMap) e !== t && (
|
|
741
|
+
if ((this._cacheCurrent || this._cachedParts) && (this._stashCurrent(), this._draft)) for (let [e, n] of this._cacheMap) e !== t && (W(n.parts), this._cacheMap.delete(e));
|
|
645
742
|
let r = this._cacheMap.get(t);
|
|
646
743
|
if (r) {
|
|
647
744
|
this.clear();
|
|
648
745
|
let i = this.startNode.parentNode;
|
|
649
746
|
if (!i) return;
|
|
650
747
|
for (let e of r.nodes) i.insertBefore(e, this.endNode);
|
|
651
|
-
this._cachedTemplateIdentity = t, this._cachedParts = r.parts,
|
|
748
|
+
this._cachedTemplateIdentity = t, this._cachedParts = r.parts, U(r.parts, n, t);
|
|
652
749
|
for (let t = 0; t < e.values.length; t++) r.parts[t] && r.parts[t].update(e.values[t]);
|
|
653
750
|
} else this.clear(), this.updateNode(e, n ?? null);
|
|
654
751
|
this._cacheCurrent = t;
|
|
@@ -701,23 +798,24 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
701
798
|
}
|
|
702
799
|
this._cacheCurrent = null, this.clearChildParts(), this.startNode.parentNode && this.startNode.parentNode.removeChild(this.startNode), this.endNode.parentNode && this.endNode.parentNode.removeChild(this.endNode), this.componentInstance &&= (this.teardownComponent(this.componentInstance), null);
|
|
703
800
|
}
|
|
704
|
-
updateNode(e,
|
|
705
|
-
let
|
|
801
|
+
updateNode(e, t) {
|
|
802
|
+
let n = t === void 0 ? this._draft?.snapshot.template ? {
|
|
706
803
|
tree: this._draft.snapshot.template,
|
|
707
804
|
context: this._draft.context
|
|
708
|
-
} : void 0 :
|
|
709
|
-
if (this.startNode.parentNode) if (
|
|
805
|
+
} : void 0 : t ?? void 0;
|
|
806
|
+
if (this.startNode.parentNode) if (e = j(e), O(e) || (this._unsafeHTML = void 0), D(e)) if (this._cachedTemplateIdentity === G(e) && this._cachedParts) U(this._cachedParts, n, G(e)), this._cachedParts.forEach((t, n) => {
|
|
710
807
|
t.update(e.values[n]);
|
|
711
808
|
});
|
|
712
809
|
else {
|
|
713
810
|
this._clearTemplateCache(), this.clear();
|
|
714
811
|
let t = document.createDocumentFragment();
|
|
715
|
-
|
|
716
|
-
let
|
|
717
|
-
|
|
812
|
+
n && V.set(t, n), Y(e, t), this.startNode.parentNode.insertBefore(t, this.endNode), this.startNode.isConnected && s();
|
|
813
|
+
let r = q.get(t.firstChild?.childNodes[0] || t);
|
|
814
|
+
r && (this._cachedTemplateIdentity = r.identity, this._cachedParts = r.parts);
|
|
718
815
|
}
|
|
719
|
-
else if (
|
|
720
|
-
this.
|
|
816
|
+
else if (O(e)) {
|
|
817
|
+
if (this._unsafeHTML === e.value && this.startNode.nextSibling !== this.endNode) return;
|
|
818
|
+
this._clearTemplateCache(), this.clear(), this._unsafeHTML = e.value;
|
|
721
819
|
let t = this.startNode.parentNode, n = this.startNode.ownerDocument;
|
|
722
820
|
if (t instanceof Element && t.namespaceURI === "http://www.w3.org/2000/svg" && ![
|
|
723
821
|
"foreignObject",
|
|
@@ -733,15 +831,15 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
733
831
|
let r = n.createElement("template");
|
|
734
832
|
r.innerHTML = e.value, t.insertBefore(r.content, this.endNode);
|
|
735
833
|
}
|
|
736
|
-
} else if (
|
|
834
|
+
} else if (xe(e)) {
|
|
737
835
|
this._clearTemplateCache(), this.clear();
|
|
738
836
|
let t = document.createDocumentFragment();
|
|
739
|
-
|
|
837
|
+
Y(T`${e}`, t), this.startNode.parentNode.insertBefore(t, this.endNode), this.startNode.isConnected && s();
|
|
740
838
|
} else if (e instanceof Node) this._clearTemplateCache(), this.clear(), this.startNode.parentNode.insertBefore(e, this.endNode);
|
|
741
|
-
else if (e ===
|
|
839
|
+
else if (e === E || e === "" || e == null || e === !1 || typeof e == "function") this._clearTemplateCache(), this.clear();
|
|
742
840
|
else {
|
|
743
|
-
let t =
|
|
744
|
-
if (n && n.nodeType === Node.TEXT_NODE && n.nextSibling === this.endNode) n.nodeValue !== t && (n.nodeValue = t);
|
|
841
|
+
let t = A(e), n = this.startNode.nextSibling;
|
|
842
|
+
if (n && n.nodeType === Node.TEXT_NODE && n.nextSibling === this.endNode) n.nodeValue !== t && (n.nodeValue = t), this._clearTemplateCache();
|
|
745
843
|
else {
|
|
746
844
|
this._clearTemplateCache(), this.clear();
|
|
747
845
|
let e = document.createTextNode(t);
|
|
@@ -760,78 +858,121 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
760
858
|
e.parentNode.removeChild(e), e = t;
|
|
761
859
|
}
|
|
762
860
|
}
|
|
763
|
-
},
|
|
861
|
+
}, Ze = class {
|
|
862
|
+
use;
|
|
863
|
+
constructor(e, t) {
|
|
864
|
+
this.use = o(t, e);
|
|
865
|
+
}
|
|
866
|
+
update() {
|
|
867
|
+
u(this.use);
|
|
868
|
+
}
|
|
869
|
+
dispose() {
|
|
870
|
+
l(this.use);
|
|
871
|
+
}
|
|
872
|
+
}, Qe = /* @__PURE__ */ new WeakMap(), $e = (e) => {
|
|
873
|
+
let t = Qe.get(e);
|
|
874
|
+
if (t) for (let e of t) e.reapplyClasses();
|
|
875
|
+
}, et = class {
|
|
876
|
+
group;
|
|
877
|
+
spread;
|
|
878
|
+
constructor(e, t) {
|
|
879
|
+
this.group = e, this.spread = t;
|
|
880
|
+
}
|
|
881
|
+
update(e) {
|
|
882
|
+
this.group.update(this.spread, e);
|
|
883
|
+
}
|
|
884
|
+
}, tt = class {
|
|
764
885
|
element;
|
|
765
|
-
|
|
766
|
-
|
|
886
|
+
values = [];
|
|
887
|
+
selectCommit = new ot();
|
|
888
|
+
previousEntries = /* @__PURE__ */ new Map();
|
|
767
889
|
bindStates = /* @__PURE__ */ new Map();
|
|
768
890
|
spreadClasses = [];
|
|
891
|
+
eventHandlers = /* @__PURE__ */ new Map();
|
|
892
|
+
templateAttributes = /* @__PURE__ */ new Map();
|
|
769
893
|
constructor(e) {
|
|
770
894
|
this.element = e;
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
if (
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
if (i && !(r instanceof a) && (this.element.removeEventListener(i.listener.__eventName, i.listener), this.bindStates.delete(e)), r === _) this.element[t] = void 0;
|
|
803
|
-
else if (r instanceof a && (t === "value" || t === "checked")) this.applySpreadBind(e, t, r);
|
|
804
|
-
else if (t === "value" && (this.element instanceof HTMLSelectElement || this.element instanceof HTMLTextAreaElement || this.element instanceof HTMLInputElement)) {
|
|
805
|
-
let t = r instanceof u, i = t ? r.value : r, o = i == null ? "" : String(i), s = this.previousValues[e], c = s instanceof u ? s.value : s, l = !(e in this.previousValues) || s instanceof a || s === _ || String(c ?? "") !== o;
|
|
806
|
-
(t ? this.element.value !== o : l) && (this.element.value = o), this.element instanceof HTMLSelectElement && (t || l || n) && this.selectCommit.schedule(this.element, o);
|
|
807
|
-
} else if (r instanceof u && (t === "value" || t === "checked")) {
|
|
808
|
-
let e = this.element;
|
|
809
|
-
if (t === "checked") {
|
|
810
|
-
let t = !!r.value;
|
|
811
|
-
e.checked !== t && (e.checked = t);
|
|
895
|
+
for (let t of Array.from(e.attributes)) this.templateAttributes.set(t.name.toLowerCase(), t.value.includes("__CRP_") ? null : t.value);
|
|
896
|
+
}
|
|
897
|
+
add() {
|
|
898
|
+
return this.values.push(void 0) - 1;
|
|
899
|
+
}
|
|
900
|
+
update(e, t) {
|
|
901
|
+
this.values[e] = t, e === this.values.length - 1 && this.commit();
|
|
902
|
+
}
|
|
903
|
+
reapplyClasses() {
|
|
904
|
+
for (let e of this.spreadClasses) this.element.classList.add(e);
|
|
905
|
+
}
|
|
906
|
+
commit() {
|
|
907
|
+
let { entries: e, classes: t, events: n } = je(this.values), r = this.selectCommit.cancel();
|
|
908
|
+
for (let [e, t] of this.eventHandlers) n.has(e) || (this.element.removeEventListener(t.eventName, t.listener), this.eventHandlers.delete(e));
|
|
909
|
+
for (let t of this.previousEntries.keys()) if (!e.has(t)) if (t.startsWith(".")) {
|
|
910
|
+
let e = this.bindStates.get(t);
|
|
911
|
+
e && (this.element.removeEventListener(e.listener.__eventName, e.listener), this.bindStates.delete(t)), this.element[t.slice(1)] = void 0;
|
|
912
|
+
} else this.resetAttribute(t.startsWith("?") ? t.slice(1) : t);
|
|
913
|
+
for (let [e, { key: t, value: r }] of n) this.applyEvent(e, t.slice(1), r);
|
|
914
|
+
for (let [t, n] of e) if (t.startsWith(".")) {
|
|
915
|
+
let e = t.slice(1), i = this.bindStates.get(t);
|
|
916
|
+
if (i && !(n instanceof h) && (this.element.removeEventListener(i.listener.__eventName, i.listener), this.bindStates.delete(t)), n === E) this.element[e] = void 0;
|
|
917
|
+
else if (n instanceof h && (e === "value" || e === "checked")) this.applySpreadBind(t, e, n);
|
|
918
|
+
else if (e === "value" && (this.element instanceof HTMLSelectElement || this.element instanceof HTMLTextAreaElement || this.element instanceof HTMLInputElement)) {
|
|
919
|
+
let e = n instanceof b, i = e ? n.value : n, a = i == null ? "" : String(i), o = this.previousEntries.get(t), s = o instanceof b ? o.value : o, c = !this.previousEntries.has(t) || o instanceof h || o === E || String(s ?? "") !== a;
|
|
920
|
+
(e ? this.element.value !== a : c) && (this.element.value = a), this.element instanceof HTMLSelectElement && (e || c || r) && this.selectCommit.schedule(this.element, a);
|
|
921
|
+
} else if (n instanceof b && (e === "value" || e === "checked")) {
|
|
922
|
+
let t = this.element;
|
|
923
|
+
if (e === "checked") {
|
|
924
|
+
let e = !!n.value;
|
|
925
|
+
t.checked !== e && (t.checked = e);
|
|
812
926
|
} else {
|
|
813
|
-
let
|
|
814
|
-
|
|
927
|
+
let e = n.value == null ? "" : String(n.value);
|
|
928
|
+
t.value !== e && (t.value = e);
|
|
815
929
|
}
|
|
816
|
-
} else
|
|
817
|
-
} else
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
this.
|
|
930
|
+
} else n instanceof h ? this.element[e] = S(n.component, n.fieldName) : n instanceof b ? this.element[e] = n.value : this.element[e] = n;
|
|
931
|
+
} else t.startsWith("?") ? this.writeAttribute(t.slice(1), n !== E && n ? "" : null) : n === E || n == null || typeof n == "function" ? this.writeAttribute(t, null) : n instanceof v ? this.writeAttribute(t, n.value === void 0 ? null : String(n.value)) : typeof n == "boolean" ? this.writeAttribute(t, L(t, n)) : this.writeAttribute(t, String(n));
|
|
932
|
+
this.applySpreadClass(t), this.previousEntries = e;
|
|
933
|
+
}
|
|
934
|
+
writeAttribute(e, t) {
|
|
935
|
+
this.element.getAttribute(e) !== t && (t === null ? this.element.removeAttribute(e) : this.element.setAttribute(e, t));
|
|
936
|
+
}
|
|
937
|
+
resetAttribute(e) {
|
|
938
|
+
let t = this.templateAttributes.get(e.toLowerCase());
|
|
939
|
+
typeof t == "string" ? this.element.setAttribute(e, t) : this.element.removeAttribute(e);
|
|
940
|
+
}
|
|
941
|
+
applyEvent(e, t, n) {
|
|
942
|
+
let r = this.eventHandlers.get(e);
|
|
943
|
+
if (n === E || typeof n != "function" && !(n instanceof ie)) {
|
|
944
|
+
r && (r.handler = void 0);
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
let i;
|
|
948
|
+
if (n instanceof ie) {
|
|
949
|
+
let e = n.handler, t = this.element instanceof HTMLFormElement ? this.element : this.element.closest("form");
|
|
950
|
+
t instanceof HTMLFormElement && (n.novalidate ? t.setAttribute("novalidate", "") : t.removeAttribute("novalidate")), i = (t) => {
|
|
951
|
+
t.preventDefault(), e.call(t.currentTarget, t);
|
|
952
|
+
};
|
|
953
|
+
} else i = n;
|
|
954
|
+
if (!r) {
|
|
955
|
+
let n = {
|
|
956
|
+
eventName: t,
|
|
957
|
+
handler: void 0,
|
|
958
|
+
listener: (e) => n.handler?.call(e.currentTarget, e)
|
|
959
|
+
};
|
|
960
|
+
r = n, this.eventHandlers.set(e, r), this.element.addEventListener(t, r.listener);
|
|
961
|
+
}
|
|
962
|
+
r.handler = i;
|
|
826
963
|
}
|
|
827
964
|
applySpreadClass(e) {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
965
|
+
if (!(e.length === this.spreadClasses.length && e.every((e, t) => e === this.spreadClasses[t]))) {
|
|
966
|
+
for (let e of this.spreadClasses) this.element.classList.remove(e);
|
|
967
|
+
for (let t of e) this.element.classList.add(t);
|
|
968
|
+
if (e.length === 0 && !this.templateAttributes.has("class") && this.element.getAttribute("class") === "" && this.element.removeAttribute("class"), this.spreadClasses = e, e.length > 0) {
|
|
969
|
+
let e = Qe.get(this.element);
|
|
970
|
+
e || Qe.set(this.element, e = /* @__PURE__ */ new Set()), e.add(this);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
832
973
|
}
|
|
833
974
|
applySpreadBind(e, t, n) {
|
|
834
|
-
let r = this.element, i = n.component, a =
|
|
975
|
+
let r = this.element, i = n.component, a = S(i, n.fieldName), o = this.bindStates.get(e);
|
|
835
976
|
if (t === "checked") {
|
|
836
977
|
let e = !!a;
|
|
837
978
|
(!o || o.lastKind !== "checked" || o.lastValue !== e) && (r.checked = e);
|
|
@@ -839,12 +980,12 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
839
980
|
let e = a == null ? "" : String(a);
|
|
840
981
|
(!o || o.lastKind !== "value" || String(o.lastValue) !== e || this.element instanceof HTMLSelectElement && r.value !== e) && (r.value = e);
|
|
841
982
|
}
|
|
842
|
-
let s =
|
|
983
|
+
let s = ct(this.element, t), c = !!o && (o.boundComponent !== i || o.boundField !== n.fieldName || o.listener.__eventName !== s);
|
|
843
984
|
if (o && c && (this.element.removeEventListener(o.listener.__eventName, o.listener), this.bindStates.delete(e), o = void 0), o) o.lastKind = t, o.lastValue = t === "checked" ? !!a : a == null ? "" : String(a);
|
|
844
985
|
else {
|
|
845
986
|
let r = (e) => {
|
|
846
987
|
let r = e.currentTarget, a = t === "checked" ? !!r[t] : r[t];
|
|
847
|
-
i &&
|
|
988
|
+
i && ae(i, n.fieldName, a);
|
|
848
989
|
};
|
|
849
990
|
r.__eventName = s, this.element.addEventListener(s, r), o = {
|
|
850
991
|
listener: r,
|
|
@@ -852,19 +993,52 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
852
993
|
lastValue: t === "checked" ? !!a : a == null ? "" : String(a),
|
|
853
994
|
boundComponent: i,
|
|
854
995
|
boundField: n.fieldName
|
|
855
|
-
}, this.bindStates.set(e, o), t === "value" &&
|
|
996
|
+
}, this.bindStates.set(e, o), t === "value" && st(this.element, () => this.bindStates.get(e) === o, () => S(o.boundComponent, o.boundField));
|
|
856
997
|
}
|
|
857
998
|
}
|
|
858
|
-
},
|
|
999
|
+
}, nt = class {
|
|
859
1000
|
element;
|
|
860
1001
|
name;
|
|
861
|
-
|
|
1002
|
+
domName;
|
|
862
1003
|
segments;
|
|
863
|
-
|
|
864
|
-
|
|
1004
|
+
values;
|
|
1005
|
+
written = void 0;
|
|
1006
|
+
constructor(e, t, n, r) {
|
|
1007
|
+
this.element = e, this.name = t, this.domName = n, this.segments = r, this.values = Array.from({ length: r.length - 1 });
|
|
1008
|
+
}
|
|
1009
|
+
update(e, t) {
|
|
1010
|
+
this.values[e] = t, e === this.values.length - 1 && this.commit();
|
|
1011
|
+
}
|
|
1012
|
+
commit() {
|
|
1013
|
+
let e = null;
|
|
1014
|
+
if (!this.values.includes(E)) {
|
|
1015
|
+
e = this.segments[0];
|
|
1016
|
+
for (let t = 0; t < this.values.length; t++) e += M(this.values[t]) + this.segments[t + 1];
|
|
1017
|
+
}
|
|
1018
|
+
let t = this.written === void 0 ? this.element.getAttribute(this.domName) : this.written;
|
|
1019
|
+
this.written = e, e !== t && (e === null ? this.element.removeAttribute(this.domName) : this.element.setAttribute(this.name, e), this.name === "class" && $e(this.element));
|
|
1020
|
+
}
|
|
1021
|
+
}, rt = class {
|
|
1022
|
+
attribute;
|
|
1023
|
+
position;
|
|
1024
|
+
constructor(e, t) {
|
|
1025
|
+
this.attribute = e, this.position = t;
|
|
1026
|
+
}
|
|
1027
|
+
update(e) {
|
|
1028
|
+
this.attribute.update(this.position, e);
|
|
1029
|
+
}
|
|
1030
|
+
}, it = class {
|
|
1031
|
+
element;
|
|
1032
|
+
name;
|
|
1033
|
+
domName;
|
|
1034
|
+
selectCommit = new ot();
|
|
865
1035
|
lastFormValue = void 0;
|
|
866
1036
|
lastFormKind = null;
|
|
1037
|
+
writtenAttribute = void 0;
|
|
867
1038
|
bindListener = null;
|
|
1039
|
+
eventHandler = void 0;
|
|
1040
|
+
eventListener = null;
|
|
1041
|
+
eventListenerTarget = null;
|
|
868
1042
|
boundPropName = null;
|
|
869
1043
|
boundComponent = null;
|
|
870
1044
|
boundFieldName = null;
|
|
@@ -873,70 +1047,53 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
873
1047
|
let e = this.bindListener;
|
|
874
1048
|
this.element.removeEventListener(e.__eventName, e), this.bindListener = null, this.boundPropName = null, this.boundComponent = null, this.boundFieldName = null;
|
|
875
1049
|
}
|
|
876
|
-
constructor(e, t, n
|
|
877
|
-
this.element = e, this.name = t;
|
|
878
|
-
let i = [...n.matchAll(/__CRP_(\d+)__/g)];
|
|
879
|
-
this.segments = [];
|
|
880
|
-
let a = 0;
|
|
881
|
-
for (let e of i) {
|
|
882
|
-
let t = e.index;
|
|
883
|
-
this.segments.push(n.substring(a, t)), a = t + e[0].length;
|
|
884
|
-
}
|
|
885
|
-
this.segments.push(n.substring(a)), this.isMulti = i.length > 1, this.multiState = r ?? null;
|
|
1050
|
+
constructor(e, t, n = t) {
|
|
1051
|
+
this.element = e, this.name = t, this.domName = n;
|
|
886
1052
|
}
|
|
887
1053
|
update(e) {
|
|
1054
|
+
this.commit(e);
|
|
1055
|
+
}
|
|
1056
|
+
writeAttribute(e, t, n) {
|
|
1057
|
+
n !== this.writtenAttribute && (this.writtenAttribute = n, n === null ? (this.element.removeAttribute(e), t !== e && this.element.hasAttribute(t) && this.element.removeAttribute(t)) : this.element.setAttribute(e, n), this.name === "class" && $e(this.element));
|
|
1058
|
+
}
|
|
1059
|
+
commit(e) {
|
|
888
1060
|
let t = this.selectCommit.cancel();
|
|
889
|
-
if (e ===
|
|
890
|
-
if (this.bindListener && this._detachBindListener(), this.
|
|
891
|
-
this.multiState.currentValues[this.multiState.position] = _, this.element.removeAttribute(this.name);
|
|
892
|
-
return;
|
|
893
|
-
}
|
|
894
|
-
if (this.name.startsWith("@")) this.element[`__crp_handler_${this.name.slice(1)}`] = void 0, this.element.removeAttribute(this.name);
|
|
1061
|
+
if (e === E) {
|
|
1062
|
+
if (this.bindListener && this._detachBindListener(), this.name.startsWith("@")) this.eventHandler = void 0, this.element.removeAttribute(this.domName);
|
|
895
1063
|
else if (this.name.startsWith(".")) {
|
|
896
1064
|
let e = this.name.slice(1);
|
|
897
|
-
this.element[e] = void 0, this.lastFormKind = null, this.lastFormValue = void 0, this.element.removeAttribute(this.
|
|
898
|
-
} else this.name.startsWith("?")
|
|
1065
|
+
this.element[e] = void 0, this.lastFormKind = null, this.lastFormValue = void 0, this.element.removeAttribute(this.domName);
|
|
1066
|
+
} else this.name.startsWith("?") ? (this.writeAttribute(this.name.slice(1), this.name.slice(1), null), this.element.hasAttribute(this.domName) && this.element.removeAttribute(this.domName)) : this.writeAttribute(this.name, this.domName, null);
|
|
899
1067
|
return;
|
|
900
1068
|
}
|
|
901
1069
|
let n = !1;
|
|
902
|
-
e instanceof
|
|
1070
|
+
e instanceof b && (n = !0, e = e.value);
|
|
903
1071
|
let r = !1;
|
|
904
|
-
if (e instanceof
|
|
1072
|
+
if (e instanceof v && (r = !0, e = e.value), e instanceof h) {
|
|
905
1073
|
this.updateBind(e);
|
|
906
1074
|
return;
|
|
907
1075
|
}
|
|
908
1076
|
if (this.bindListener && this._detachBindListener(), this.name === "ref") {
|
|
909
|
-
typeof e == "function" ? e(this.element) : e && typeof e == "object" && "value" in e && (e.value = this.element), this.element.hasAttribute(this.
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
912
|
-
if (this.isMulti && this.multiState) {
|
|
913
|
-
let { currentValues: t, position: n } = this.multiState;
|
|
914
|
-
if (t[n] = e, t.includes(_)) {
|
|
915
|
-
this.element.removeAttribute(this.name);
|
|
916
|
-
return;
|
|
917
|
-
}
|
|
918
|
-
let r = this.segments[0];
|
|
919
|
-
for (let e = 0; e < t.length; e++) r += String(t[e]) + this.segments[e + 1];
|
|
920
|
-
this.element.setAttribute(this.name, r);
|
|
1077
|
+
typeof e == "function" ? e(this.element) : e && typeof e == "object" && "value" in e && (e.value = this.element), this.element.hasAttribute(this.domName) && this.element.removeAttribute(this.domName);
|
|
921
1078
|
return;
|
|
922
1079
|
}
|
|
923
1080
|
if (this.name.startsWith("@")) {
|
|
924
|
-
let t = this.name.slice(1)
|
|
925
|
-
if (!this.element
|
|
1081
|
+
let t = this.name.slice(1);
|
|
1082
|
+
if (!this.eventListener || this.eventListenerTarget !== this.element) {
|
|
926
1083
|
let e = (e) => {
|
|
927
|
-
let t =
|
|
1084
|
+
let t = this.eventHandler;
|
|
928
1085
|
typeof t == "function" && t.call(e.currentTarget, e);
|
|
929
1086
|
};
|
|
930
|
-
this.
|
|
1087
|
+
this.eventListener = e, this.eventListenerTarget = this.element, this.element.addEventListener(t, e);
|
|
931
1088
|
}
|
|
932
|
-
let
|
|
933
|
-
if (
|
|
934
|
-
let e =
|
|
935
|
-
t instanceof HTMLFormElement && (
|
|
1089
|
+
let n = e;
|
|
1090
|
+
if (n instanceof ie) {
|
|
1091
|
+
let e = n.handler, t = this.element instanceof HTMLFormElement ? this.element : this.element.closest("form");
|
|
1092
|
+
t instanceof HTMLFormElement && (n.novalidate ? t.setAttribute("novalidate", "") : t.removeAttribute("novalidate")), n = (t) => {
|
|
936
1093
|
t.preventDefault(), e.call(t.currentTarget, t);
|
|
937
1094
|
};
|
|
938
1095
|
}
|
|
939
|
-
this.
|
|
1096
|
+
this.eventHandler = typeof n == "function" ? n : void 0, this.element.hasAttribute(this.domName) && this.element.removeAttribute(this.domName);
|
|
940
1097
|
} else if (this.name.startsWith(".")) {
|
|
941
1098
|
let r = this.name.slice(1);
|
|
942
1099
|
if ((r === "value" || r === "checked") && (this.element instanceof HTMLInputElement || this.element instanceof HTMLTextAreaElement || this.element instanceof HTMLSelectElement)) if (r === "checked") {
|
|
@@ -947,24 +1104,19 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
947
1104
|
i && (this.element.value = r, this.lastFormValue = r, this.lastFormKind = "value"), this.element instanceof HTMLSelectElement && (n || i || t) && this.selectCommit.schedule(this.element, r);
|
|
948
1105
|
}
|
|
949
1106
|
else this.element[r] = e;
|
|
950
|
-
this.element.hasAttribute(this.
|
|
1107
|
+
this.element.hasAttribute(this.domName) && this.element.removeAttribute(this.domName);
|
|
951
1108
|
} else if (this.name.startsWith("?")) {
|
|
952
1109
|
let t = this.name.slice(1);
|
|
953
|
-
|
|
954
|
-
} else
|
|
955
|
-
else if (e == null) this.element.removeAttribute(this.name);
|
|
956
|
-
else if (typeof e == "boolean") {
|
|
957
|
-
let t = T(this.name, e);
|
|
958
|
-
t === null ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t);
|
|
959
|
-
} else this.element.setAttribute(this.name, this.segments[0] + String(e) + this.segments[1]);
|
|
1110
|
+
this.writeAttribute(t, t, e ? "" : null), this.element.hasAttribute(this.domName) && this.element.removeAttribute(this.domName);
|
|
1111
|
+
} else r ? this.writeAttribute(this.name, this.domName, e === void 0 ? null : String(e)) : e == null ? this.writeAttribute(this.name, this.domName, null) : typeof e == "boolean" ? this.writeAttribute(this.name, this.domName, L(this.name, e)) : this.writeAttribute(this.name, this.domName, M(e));
|
|
960
1112
|
}
|
|
961
1113
|
updateBind(e) {
|
|
962
1114
|
let t = this.name.startsWith(".") ? this.name.slice(1) : this.name;
|
|
963
1115
|
if (t !== "value" && t !== "checked") {
|
|
964
|
-
this.element[t] =
|
|
1116
|
+
this.element[t] = S(e.component, e.fieldName), this.element.hasAttribute(this.domName) && this.element.removeAttribute(this.domName), this.bindListener && this._detachBindListener();
|
|
965
1117
|
return;
|
|
966
1118
|
}
|
|
967
|
-
let n = this.element, r = e.component, i =
|
|
1119
|
+
let n = this.element, r = e.component, i = S(r, e.fieldName);
|
|
968
1120
|
if (t === "checked") {
|
|
969
1121
|
let e = !!i;
|
|
970
1122
|
(this.lastFormKind !== "checked" || this.lastFormValue !== e) && (n.checked = e, this.lastFormValue = e, this.lastFormKind = "checked");
|
|
@@ -972,20 +1124,34 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
972
1124
|
let e = i == null ? "" : String(i);
|
|
973
1125
|
(this.lastFormKind !== "value" || String(this.lastFormValue) !== e || this.element instanceof HTMLSelectElement && n.value !== e) && (n.value = e, this.lastFormValue = e, this.lastFormKind = "value");
|
|
974
1126
|
}
|
|
975
|
-
let a =
|
|
1127
|
+
let a = ct(this.element, t);
|
|
976
1128
|
if (this.bindListener && (this.boundPropName !== t || this.boundComponent !== r || this.boundFieldName !== e.fieldName || this.bindListener.__eventName !== a) && this._detachBindListener(), !this.bindListener) {
|
|
977
1129
|
let n = (n) => {
|
|
978
1130
|
let i = n.currentTarget, a = t === "checked" ? !!i[t] : i[t];
|
|
979
|
-
r &&
|
|
1131
|
+
r && ae(r, e.fieldName, a);
|
|
980
1132
|
};
|
|
981
1133
|
if (n.__eventName = a, this.bindListener = n, this.boundPropName = t, this.boundComponent = r, this.boundFieldName = e.fieldName, this.element.addEventListener(a, n), t === "value") {
|
|
982
1134
|
let e = n;
|
|
983
|
-
|
|
1135
|
+
st(this.element, () => this.bindListener === e, () => S(this.boundComponent, this.boundFieldName));
|
|
984
1136
|
}
|
|
985
1137
|
}
|
|
986
|
-
this.element.hasAttribute(this.
|
|
1138
|
+
this.element.hasAttribute(this.domName) && this.element.removeAttribute(this.domName);
|
|
1139
|
+
}
|
|
1140
|
+
}, at = class {
|
|
1141
|
+
element;
|
|
1142
|
+
state;
|
|
1143
|
+
position;
|
|
1144
|
+
constructor(e, t, n) {
|
|
1145
|
+
this.element = e, this.state = t, this.position = n;
|
|
1146
|
+
}
|
|
1147
|
+
update(e) {
|
|
1148
|
+
let { tag: t, segments: n, values: r } = this.state;
|
|
1149
|
+
r[this.position] = e;
|
|
1150
|
+
let i = n[0];
|
|
1151
|
+
for (let e = 0; e < r.length; e++) i += Ve(t, r[e]) + n[e + 1];
|
|
1152
|
+
this.element.textContent !== i && (this.element.textContent = i);
|
|
987
1153
|
}
|
|
988
|
-
},
|
|
1154
|
+
}, ot = class {
|
|
989
1155
|
pending = null;
|
|
990
1156
|
cancel() {
|
|
991
1157
|
let e = this.pending !== null;
|
|
@@ -997,13 +1163,13 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
997
1163
|
this.pending === n && (this.pending = null, e.value !== t && (e.value = t));
|
|
998
1164
|
});
|
|
999
1165
|
}
|
|
1000
|
-
},
|
|
1166
|
+
}, st = (e, t, n) => {
|
|
1001
1167
|
e instanceof HTMLSelectElement && queueMicrotask(() => {
|
|
1002
1168
|
if (!t()) return;
|
|
1003
1169
|
let r = n(), i = r == null ? "" : String(r);
|
|
1004
1170
|
e.value !== i && (e.value = i);
|
|
1005
1171
|
});
|
|
1006
|
-
},
|
|
1172
|
+
}, ct = (e, t) => {
|
|
1007
1173
|
if (e instanceof HTMLSelectElement) return "change";
|
|
1008
1174
|
if (e instanceof HTMLTextAreaElement) return "input";
|
|
1009
1175
|
if (e instanceof HTMLInputElement) {
|
|
@@ -1011,104 +1177,136 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
1011
1177
|
return t === "checked" || n === "checkbox" || n === "radio" || n === "range" ? "change" : "input";
|
|
1012
1178
|
}
|
|
1013
1179
|
return "input";
|
|
1014
|
-
},
|
|
1015
|
-
let
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
r
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
let
|
|
1029
|
-
for (let e = 0; e < s.length; e++) a ? s[e] === a && (a = null) : s[e] === "<" && s[e + 1] !== "!" && s[e + 1] !== "/" ? i = !0 : s[e] === ">" && (i = !1);
|
|
1030
|
-
r += s;
|
|
1031
|
-
let c = document.createElement("template");
|
|
1180
|
+
}, q = /* @__PURE__ */ new WeakMap(), lt = /* @__PURE__ */ new WeakMap(), ut = (e, { strings: t, bindings: n }) => {
|
|
1181
|
+
let r = G(e), i = lt.get(r);
|
|
1182
|
+
if (i && i.ownerDocument === document) return i;
|
|
1183
|
+
let a = "";
|
|
1184
|
+
for (let e = 0; e < t.length - 1; e++) {
|
|
1185
|
+
let r = n[e];
|
|
1186
|
+
if (r.kind === "attribute" && r.start && r.name === "...") {
|
|
1187
|
+
let n = t[e];
|
|
1188
|
+
a += `${n.slice(0, r.prefixStart)}crp-spread-${e}${n.slice(r.prefixStart + 3)}`;
|
|
1189
|
+
} else a += t[e];
|
|
1190
|
+
let i = r.kind;
|
|
1191
|
+
i === "node" ? a += `<!--CRP_${e}-->` : (i === "attribute" || i === "raw-text") && (a += `__CRP_${e}__`);
|
|
1192
|
+
}
|
|
1193
|
+
a += t[t.length - 1];
|
|
1194
|
+
let o = document.createElement("template");
|
|
1032
1195
|
if (e._$litType$ === 2) {
|
|
1033
|
-
|
|
1034
|
-
let e =
|
|
1196
|
+
o.innerHTML = `<svg>${a}</svg>`;
|
|
1197
|
+
let e = o.content.firstElementChild, t = document.createDocumentFragment();
|
|
1035
1198
|
if (e) for (; e.firstChild;) t.appendChild(e.firstChild);
|
|
1036
|
-
|
|
1037
|
-
} else
|
|
1038
|
-
|
|
1199
|
+
o.content.replaceChildren(t);
|
|
1200
|
+
} else o.innerHTML = a;
|
|
1201
|
+
return lt.set(r, o), o;
|
|
1202
|
+
}, J = (e) => {
|
|
1203
|
+
let n = [], r = Re(e), { bindings: i } = r, o = (e, t) => {
|
|
1204
|
+
let n = i[e];
|
|
1205
|
+
return n?.kind === "attribute" && /^[.@?]/.test(n.name) ? n.name : t;
|
|
1206
|
+
}, s = (e) => {
|
|
1207
|
+
let t = i[e];
|
|
1208
|
+
return t?.kind === "attribute" && t.name === "...";
|
|
1209
|
+
}, c = /* @__PURE__ */ new Map(), l = ut(e, r).content.cloneNode(!0), u = document.createTreeWalker(l, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT), d, f = [];
|
|
1039
1210
|
for (; d = u.nextNode();) f.push(d);
|
|
1040
|
-
|
|
1211
|
+
f.forEach((e) => {
|
|
1041
1212
|
if (e.nodeType === Node.COMMENT_NODE) {
|
|
1042
|
-
let
|
|
1043
|
-
if (
|
|
1044
|
-
let r = parseInt(
|
|
1213
|
+
let t = e.nodeValue?.match(/^CRP_(\d+)$/);
|
|
1214
|
+
if (t) {
|
|
1215
|
+
let r = parseInt(t[1]), i = document.createComment("/CRP");
|
|
1045
1216
|
e.parentNode.insertBefore(i, e.nextSibling);
|
|
1046
|
-
let a = new
|
|
1047
|
-
|
|
1217
|
+
let a = new K(e, i);
|
|
1218
|
+
n[r] = a;
|
|
1048
1219
|
}
|
|
1049
1220
|
} else if (e.nodeType === Node.ELEMENT_NODE) {
|
|
1050
|
-
let
|
|
1051
|
-
|
|
1052
|
-
let r = [...e.
|
|
1053
|
-
if (
|
|
1054
|
-
|
|
1055
|
-
let i =
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1221
|
+
let r = e;
|
|
1222
|
+
if (t.has(r.localName)) {
|
|
1223
|
+
let e = r.textContent ?? "", t = [...e.matchAll(/__CRP_(\d+)__/g)].filter((e) => i[Number(e[1])]?.kind === "raw-text");
|
|
1224
|
+
if (t.length > 0) {
|
|
1225
|
+
let i = [], a = 0;
|
|
1226
|
+
for (let n of t) i.push(e.slice(a, n.index)), a = n.index + n[0].length;
|
|
1227
|
+
i.push(e.slice(a));
|
|
1228
|
+
let o = {
|
|
1229
|
+
tag: r.localName,
|
|
1230
|
+
segments: i,
|
|
1231
|
+
values: Array(t.length).fill(void 0)
|
|
1232
|
+
};
|
|
1233
|
+
t.forEach((e, t) => {
|
|
1234
|
+
n[Number(e[1])] = new at(r, o, t);
|
|
1235
|
+
}), r.textContent = i.join("");
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
Array.from(r.attributes).forEach((e) => {
|
|
1239
|
+
let t = [...e.value.matchAll(/__CRP_(\d+)__/g)];
|
|
1240
|
+
if (t.length === 0) return;
|
|
1241
|
+
let a = t.map((e) => parseInt(e[1]));
|
|
1242
|
+
if (a.some((e) => n[e])) return;
|
|
1243
|
+
let l = i[a[0]];
|
|
1244
|
+
if (s(a[0])) {
|
|
1245
|
+
if (a.length === 1) {
|
|
1246
|
+
let e = c.get(r);
|
|
1247
|
+
e || c.set(r, e = new tt(r)), n[a[0]] = new et(e, e.add());
|
|
1062
1248
|
}
|
|
1249
|
+
r.removeAttribute(e.name);
|
|
1063
1250
|
return;
|
|
1064
1251
|
}
|
|
1065
|
-
if (
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
let o = i[r];
|
|
1069
|
-
if (!t[o]) {
|
|
1070
|
-
let i = new V(n, e.name, e.value, {
|
|
1071
|
-
currentValues: a,
|
|
1072
|
-
position: r
|
|
1073
|
-
});
|
|
1074
|
-
t[o] = i;
|
|
1075
|
-
}
|
|
1252
|
+
if (a.length === 1 && !(l?.kind === "attribute" && be(l))) {
|
|
1253
|
+
n[a[0]] = new it(r, o(a[0], e.name), e.name);
|
|
1254
|
+
return;
|
|
1076
1255
|
}
|
|
1256
|
+
let u = [], d = 0;
|
|
1257
|
+
for (let n of t) u.push(e.value.slice(d, n.index)), d = n.index + n[0].length;
|
|
1258
|
+
u.push(e.value.slice(d));
|
|
1259
|
+
let f = new nt(r, o(a[0], e.name), e.name, u);
|
|
1260
|
+
a.forEach((e, t) => {
|
|
1261
|
+
n[e] = new rt(f, t);
|
|
1262
|
+
});
|
|
1077
1263
|
});
|
|
1078
1264
|
}
|
|
1079
|
-
})
|
|
1265
|
+
});
|
|
1266
|
+
let ee = e.__cossackScope === void 0 ? void 0 : a(e.__cossackScope);
|
|
1267
|
+
if (ee) {
|
|
1268
|
+
let t = l.firstChild;
|
|
1269
|
+
for (; t && $(t);) t = t.nextSibling;
|
|
1270
|
+
t && (n[e.strings.length - 1] = new Ze(t, ee));
|
|
1271
|
+
}
|
|
1272
|
+
return {
|
|
1080
1273
|
fragment: l,
|
|
1081
|
-
parts:
|
|
1274
|
+
parts: n
|
|
1082
1275
|
};
|
|
1083
|
-
},
|
|
1084
|
-
let n =
|
|
1085
|
-
|
|
1086
|
-
let r =
|
|
1276
|
+
}, Y = (e, t) => {
|
|
1277
|
+
let n = V.get(t);
|
|
1278
|
+
V.delete(t);
|
|
1279
|
+
let r = q.get(t), i = G(e);
|
|
1087
1280
|
if (r && r.identity === i) {
|
|
1088
|
-
|
|
1281
|
+
U(r.parts, n, i), r.parts.forEach((t, n) => {
|
|
1089
1282
|
t.update(e.values[n]);
|
|
1090
1283
|
});
|
|
1091
1284
|
return;
|
|
1092
1285
|
}
|
|
1093
1286
|
if (r) {
|
|
1094
|
-
|
|
1287
|
+
q.delete(t);
|
|
1095
1288
|
for (let e of r.parts) e && typeof e.dispose == "function" && e.dispose();
|
|
1096
1289
|
}
|
|
1097
|
-
let { fragment: a, parts: o } =
|
|
1098
|
-
|
|
1099
|
-
let
|
|
1290
|
+
let { fragment: a, parts: o } = J(e);
|
|
1291
|
+
U(o, n, i);
|
|
1292
|
+
let l = e.values;
|
|
1100
1293
|
try {
|
|
1101
|
-
for (let e = 0; e <
|
|
1102
|
-
if (typeof
|
|
1294
|
+
for (let e = 0; e < l.length; e++) o[e] && o[e].update(l[e]);
|
|
1295
|
+
if (typeof ShadowRoot < "u" && t instanceof ShadowRoot) for (let e = t.firstChild; e;) {
|
|
1296
|
+
let n = e.nextSibling;
|
|
1297
|
+
c(e) || t.removeChild(e), e = n;
|
|
1298
|
+
}
|
|
1299
|
+
else if (typeof HTMLElement < "u" && t instanceof HTMLElement) t.innerHTML = "";
|
|
1103
1300
|
else for (; t.firstChild;) t.removeChild(t.firstChild);
|
|
1104
|
-
t.appendChild(a),
|
|
1301
|
+
t.appendChild(a), q.set(t, {
|
|
1105
1302
|
identity: i,
|
|
1106
1303
|
parts: o
|
|
1107
1304
|
});
|
|
1108
1305
|
} catch (e) {
|
|
1109
|
-
throw
|
|
1306
|
+
throw W(o), e;
|
|
1110
1307
|
}
|
|
1111
|
-
|
|
1308
|
+
t.isConnected && s();
|
|
1309
|
+
}, X = class extends Error {
|
|
1112
1310
|
category;
|
|
1113
1311
|
path;
|
|
1114
1312
|
expected;
|
|
@@ -1116,8 +1314,8 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
1116
1314
|
constructor(e, t, n, r) {
|
|
1117
1315
|
super(`${e} at ${t}: expected ${n}; found ${r}`), this.category = e, this.path = t, this.expected = n, this.actual = r;
|
|
1118
1316
|
}
|
|
1119
|
-
},
|
|
1120
|
-
if (!
|
|
1317
|
+
}, Z = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? `<${e.nodeName.toLowerCase()}>` : e.nodeType === Node.COMMENT_NODE ? "comment" : e.nodeType === Node.TEXT_NODE ? "text" : `nodeType:${e.nodeType}` : "<none>", Q = (e, t, n, r, i = "full-render-fallback") => {
|
|
1318
|
+
if (!R || r?.expectedClientOnly) return;
|
|
1121
1319
|
n ??= r?.component;
|
|
1122
1320
|
let a = r?.statePath && /^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\])*$/.test(r.statePath) ? r.statePath.slice(0, 160) : void 0, o = r?.source?.file, s = typeof o == "string" && o.length <= 240 && !o.startsWith("/") && !o.includes("\\") && !o.split("/").includes("..") && !/^[a-zA-Z]+:/.test(o) ? {
|
|
1123
1321
|
file: o,
|
|
@@ -1136,14 +1334,14 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
1136
1334
|
actual: e.actual,
|
|
1137
1335
|
action: i
|
|
1138
1336
|
});
|
|
1139
|
-
},
|
|
1337
|
+
}, $ = (e) => {
|
|
1140
1338
|
if (e.nodeType === Node.TEXT_NODE) return (e.nodeValue || "").trim() === "";
|
|
1141
1339
|
if (e.nodeType === Node.COMMENT_NODE) {
|
|
1142
1340
|
let t = e.nodeValue || "";
|
|
1143
1341
|
return !/^CRP_\d+$/.test(t) && t !== "/CRP" && t !== "CSA-S" && t !== "CSA-E";
|
|
1144
1342
|
}
|
|
1145
1343
|
return !1;
|
|
1146
|
-
},
|
|
1344
|
+
}, dt = (e) => {
|
|
1147
1345
|
let t = [], n = [];
|
|
1148
1346
|
for (let r of e) {
|
|
1149
1347
|
if (r.nodeType !== Node.COMMENT_NODE) continue;
|
|
@@ -1155,85 +1353,98 @@ var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0,
|
|
|
1155
1353
|
}
|
|
1156
1354
|
}
|
|
1157
1355
|
return t;
|
|
1158
|
-
},
|
|
1356
|
+
}, ft = (e) => {
|
|
1159
1357
|
let t = [];
|
|
1160
1358
|
for (let n = e; n?.parentNode && t.length < 12; n = n.parentNode) {
|
|
1161
1359
|
let e = Array.prototype.indexOf.call(n.parentNode.childNodes, n);
|
|
1162
1360
|
t.unshift(`${n.nodeType === Node.ELEMENT_NODE ? n.nodeName.toLowerCase() : "node"}[${e}]`);
|
|
1163
1361
|
}
|
|
1164
1362
|
return `root/${t.join("/")}`;
|
|
1165
|
-
},
|
|
1166
|
-
let
|
|
1167
|
-
for (let
|
|
1168
|
-
let
|
|
1169
|
-
if (
|
|
1170
|
-
for (;
|
|
1171
|
-
let
|
|
1172
|
-
if (!
|
|
1173
|
-
if (
|
|
1174
|
-
if (
|
|
1175
|
-
if (
|
|
1176
|
-
if (
|
|
1177
|
-
|
|
1363
|
+
}, pt = (e, n, r, i = "root", a) => {
|
|
1364
|
+
let o = 0;
|
|
1365
|
+
for (let s = 0; s < e.length; s++) {
|
|
1366
|
+
let c = e[s];
|
|
1367
|
+
if ($(c)) continue;
|
|
1368
|
+
for (; o < n.length && $(n[o]);) o++;
|
|
1369
|
+
let l = n[o], u = `${i}/${c.nodeType === Node.ELEMENT_NODE ? c.nodeName.toLowerCase() : "node"}[${s}]`;
|
|
1370
|
+
if (!l) throw new X("missing-node", u, Z(c), "<none>");
|
|
1371
|
+
if (c.nodeType === Node.ELEMENT_NODE) {
|
|
1372
|
+
if (l.nodeType !== Node.ELEMENT_NODE || c.nodeName !== l.nodeName) throw new X("element-tag", u, Z(c), Z(l));
|
|
1373
|
+
if (c.namespaceURI !== l.namespaceURI) throw new X("element-namespace", u, Z(c), Z(l));
|
|
1374
|
+
if (r.set(c, l), t.has(c.localName)) {
|
|
1375
|
+
o++;
|
|
1178
1376
|
continue;
|
|
1179
1377
|
}
|
|
1180
|
-
|
|
1378
|
+
pt(c.childNodes, Array.from(l.childNodes), r, `${i}/${c.nodeName.toLowerCase()}[${s}]`, a);
|
|
1181
1379
|
} else {
|
|
1182
|
-
if (
|
|
1183
|
-
|
|
1380
|
+
if (c.nodeType !== l.nodeType) throw new X("node-type", u, Z(c), Z(l));
|
|
1381
|
+
c.nodeType === Node.TEXT_NODE && c.nodeValue !== l.nodeValue && (R && Q(new X("text-content", u, "text", "text"), a?.boundary ?? "root", void 0, a, "text-reconcile"), l.nodeValue = c.nodeValue), r.set(c, l);
|
|
1184
1382
|
}
|
|
1185
|
-
if (
|
|
1383
|
+
if (o++, c.nodeType === Node.COMMENT_NODE && /^CRP_\d+$/.test(c.nodeValue || "")) {
|
|
1186
1384
|
let e = 1;
|
|
1187
|
-
for (;
|
|
1188
|
-
let
|
|
1189
|
-
if (
|
|
1190
|
-
if (/^CRP_\d+$/.test(
|
|
1191
|
-
else if (
|
|
1385
|
+
for (; o < n.length && e > 0;) {
|
|
1386
|
+
let t = n[o];
|
|
1387
|
+
if (t.nodeType === Node.COMMENT_NODE) {
|
|
1388
|
+
if (/^CRP_\d+$/.test(t.nodeValue || "")) e++;
|
|
1389
|
+
else if (t.nodeValue === "/CRP" && (e--, e === 0)) break;
|
|
1192
1390
|
}
|
|
1193
|
-
|
|
1391
|
+
o++;
|
|
1194
1392
|
}
|
|
1195
1393
|
}
|
|
1196
1394
|
}
|
|
1197
|
-
for (;
|
|
1198
|
-
if (
|
|
1199
|
-
},
|
|
1395
|
+
for (; o < n.length && $(n[o]);) o++;
|
|
1396
|
+
if (o < n.length) throw new X("unexpected-node", `${i}/node[${o}]`, "end of template", Z(n[o]));
|
|
1397
|
+
}, mt = (e, t) => {
|
|
1200
1398
|
for (let n of e) if (n) {
|
|
1201
|
-
if (n instanceof
|
|
1399
|
+
if (n instanceof K) {
|
|
1202
1400
|
let e = t.get(n.startNode), r = t.get(n.endNode);
|
|
1203
|
-
if (!e || !r) throw new
|
|
1401
|
+
if (!e || !r) throw new X("missing-part-anchor", "part", "start and end anchors", "missing anchor");
|
|
1204
1402
|
n.startNode = e, n.endNode = r, n._beginHydration();
|
|
1205
|
-
} else if (n instanceof
|
|
1403
|
+
} else if (n instanceof it || n instanceof at) {
|
|
1206
1404
|
let e = t.get(n.element);
|
|
1207
|
-
if (!e) throw new
|
|
1405
|
+
if (!e) throw new X("missing-part-element", "part", "attribute element", "missing element");
|
|
1208
1406
|
n.element = e;
|
|
1407
|
+
} else if (n instanceof et) {
|
|
1408
|
+
if (n.spread !== 0) continue;
|
|
1409
|
+
let e = t.get(n.group.element);
|
|
1410
|
+
if (!e) throw new X("missing-part-element", "part", "attribute element", "missing element");
|
|
1411
|
+
n.group.element = e;
|
|
1412
|
+
} else if (n instanceof rt) {
|
|
1413
|
+
if (n.position !== 0) continue;
|
|
1414
|
+
let e = t.get(n.attribute.element);
|
|
1415
|
+
if (!e) throw new X("missing-part-element", "part", "attribute element", "missing element");
|
|
1416
|
+
n.attribute.element = e;
|
|
1417
|
+
} else if (n instanceof Ze) {
|
|
1418
|
+
let e = t.get(n.use.anchor);
|
|
1419
|
+
e && (n.use.anchor = e);
|
|
1209
1420
|
}
|
|
1210
1421
|
}
|
|
1211
|
-
},
|
|
1212
|
-
if (
|
|
1213
|
-
let r =
|
|
1422
|
+
}, ht = (e) => Array.from(e.childNodes).filter((e) => !c(e)), gt = (e, t, n) => {
|
|
1423
|
+
if (ht(t).length === 0) return Y(e, t);
|
|
1424
|
+
let r = q.get(t), i = G(e);
|
|
1214
1425
|
if (r && r.identity === i) {
|
|
1215
1426
|
r.parts.forEach((t, n) => t.update(e.values[n]));
|
|
1216
1427
|
return;
|
|
1217
1428
|
}
|
|
1218
1429
|
if (r) {
|
|
1219
|
-
|
|
1430
|
+
q.delete(t);
|
|
1220
1431
|
for (let e of r.parts) e && typeof e.dispose == "function" && e.dispose();
|
|
1221
1432
|
}
|
|
1222
1433
|
let a = [];
|
|
1223
1434
|
try {
|
|
1224
|
-
let { fragment: r, parts: i } =
|
|
1435
|
+
let { fragment: r, parts: i } = J(e);
|
|
1225
1436
|
a = i;
|
|
1226
1437
|
let o = /* @__PURE__ */ new Map();
|
|
1227
|
-
|
|
1438
|
+
pt(r.childNodes, ht(t), o, "root", R ? n : void 0), mt(a, o), Je(a, n);
|
|
1228
1439
|
for (let t = 0; t < e.values.length; t++) a[t] && a[t].update(e.values[t]);
|
|
1229
1440
|
} catch (r) {
|
|
1230
|
-
if (
|
|
1441
|
+
if (W(a), r instanceof X) return R && Q(r, "root", void 0, n), Y(e, t);
|
|
1231
1442
|
throw r;
|
|
1232
1443
|
}
|
|
1233
|
-
|
|
1444
|
+
q.set(t, {
|
|
1234
1445
|
identity: i,
|
|
1235
1446
|
parts: a
|
|
1236
|
-
});
|
|
1447
|
+
}), t.isConnected && s();
|
|
1237
1448
|
};
|
|
1238
1449
|
//#endregion
|
|
1239
|
-
export {
|
|
1450
|
+
export { oe as TemplateResult, he as UnsafeHTMLResult, Ye as captureRenderDrafts, pe as component, k as escapeHtml, T as html, gt as hydrate, D as isTemplateResult, O as isUnsafeHTML, E as nothing, Y as render, Ge as renderToString, fe as svg, ge as unsafeHTML };
|