@inkandswitch/patchwork-pkg-base 0.0.83 → 0.0.85

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.
@@ -1 +1 @@
1
- automerge:3EczzaSxpKiaPMgNjXnpiNBFfNPc
1
+ automerge:3VfoHhyCxHKMxfr8uYdXGgDd2FRv
@@ -1,595 +0,0 @@
1
- import { ensureConfig as xe, dom as Se, writeScopeOverride as Ee, readScopedConfig as Ce, readConfig as ie, writeConfig as Ae } from "./patchwork-llm-h1ZevlV6.js";
2
- const ke = !1, Te = (e, t) => e === t, M = {
3
- equals: Te
4
- };
5
- let ue = ge;
6
- const x = 1, _ = 2, ae = {
7
- owned: null,
8
- cleanups: null,
9
- context: null,
10
- owner: null
11
- };
12
- var d = null;
13
- let R = null, Pe = null, a = null, m = null, b = null, j = 0;
14
- function de(e, t) {
15
- const n = a, o = d, i = e.length === 0, r = t === void 0 ? o : t, l = i ? ae : {
16
- owned: null,
17
- cleanups: null,
18
- context: r ? r.context : null,
19
- owner: r
20
- }, s = i ? e : () => e(() => E(() => $(l)));
21
- d = l, a = null;
22
- try {
23
- return A(s, !0);
24
- } finally {
25
- a = n, d = o;
26
- }
27
- }
28
- function P(e, t) {
29
- t = t ? Object.assign({}, M, t) : M;
30
- const n = {
31
- value: e,
32
- observers: null,
33
- observerSlots: null,
34
- comparator: t.equals || void 0
35
- }, o = (i) => (typeof i == "function" && (i = i(n.value)), pe(n, i));
36
- return [he.bind(n), o];
37
- }
38
- function H(e, t, n) {
39
- const o = q(e, t, !1, x);
40
- N(o);
41
- }
42
- function $e(e, t, n) {
43
- ue = _e;
44
- const o = q(e, t, !1, x);
45
- n || (o.user = !0), b ? b.push(o) : N(o);
46
- }
47
- function O(e, t, n) {
48
- n = n ? Object.assign({}, M, n) : M;
49
- const o = q(e, t, !0, 0);
50
- return o.observers = null, o.observerSlots = null, o.comparator = n.equals || void 0, N(o), he.bind(o);
51
- }
52
- function E(e) {
53
- if (a === null) return e();
54
- const t = a;
55
- a = null;
56
- try {
57
- return e();
58
- } finally {
59
- a = t;
60
- }
61
- }
62
- function re(e) {
63
- return d === null || (d.cleanups === null ? d.cleanups = [e] : d.cleanups.push(e)), e;
64
- }
65
- function Ne() {
66
- return d;
67
- }
68
- function Le(e, t) {
69
- const n = d, o = a;
70
- d = e, a = null;
71
- try {
72
- return A(t, !0);
73
- } catch (i) {
74
- W(i);
75
- } finally {
76
- d = n, a = o;
77
- }
78
- }
79
- function he() {
80
- if (this.sources && this.state)
81
- if (this.state === x) N(this);
82
- else {
83
- const e = m;
84
- m = null, A(() => D(this), !1), m = e;
85
- }
86
- if (a) {
87
- const e = this.observers;
88
- if (!e || e[e.length - 1] !== a) {
89
- const t = e ? e.length : 0;
90
- a.sources ? (a.sources.push(this), a.sourceSlots.push(t)) : (a.sources = [this], a.sourceSlots = [t]), e ? (e.push(a), this.observerSlots.push(a.sources.length - 1)) : (this.observers = [a], this.observerSlots = [a.sources.length - 1]);
91
- }
92
- }
93
- return this.value;
94
- }
95
- function pe(e, t, n) {
96
- let o = e.value;
97
- return (!e.comparator || !e.comparator(o, t)) && (e.value = t, e.observers && e.observers.length && A(() => {
98
- for (let i = 0; i < e.observers.length; i += 1) {
99
- const r = e.observers[i], l = R && R.running;
100
- l && R.disposed.has(r), (l ? !r.tState : !r.state) && (r.pure ? m.push(r) : b.push(r), r.observers && me(r)), l || (r.state = x);
101
- }
102
- if (m.length > 1e6)
103
- throw m = [], new Error();
104
- }, !1)), t;
105
- }
106
- function N(e) {
107
- if (!e.fn) return;
108
- $(e);
109
- const t = j;
110
- Oe(e, e.value, t);
111
- }
112
- function Oe(e, t, n) {
113
- let o;
114
- const i = d, r = a;
115
- a = d = e;
116
- try {
117
- o = e.fn(t);
118
- } catch (l) {
119
- return e.pure && (e.state = x, e.owned && e.owned.forEach($), e.owned = null), e.updatedAt = n + 1, W(l);
120
- } finally {
121
- a = r, d = i;
122
- }
123
- (!e.updatedAt || e.updatedAt <= n) && (e.updatedAt != null && "observers" in e ? pe(e, o) : e.value = o, e.updatedAt = n);
124
- }
125
- function q(e, t, n, o = x, i) {
126
- const r = {
127
- fn: e,
128
- state: o,
129
- updatedAt: null,
130
- owned: null,
131
- sources: null,
132
- sourceSlots: null,
133
- cleanups: null,
134
- value: t,
135
- owner: d,
136
- context: d ? d.context : null,
137
- pure: n
138
- };
139
- return d === null || d !== ae && (d.owned ? d.owned.push(r) : d.owned = [r]), r;
140
- }
141
- function B(e) {
142
- if (e.state === 0) return;
143
- if (e.state === _) return D(e);
144
- if (e.suspense && E(e.suspense.inFallback)) return e.suspense.effects.push(e);
145
- const t = [e];
146
- for (; (e = e.owner) && (!e.updatedAt || e.updatedAt < j); )
147
- e.state && t.push(e);
148
- for (let n = t.length - 1; n >= 0; n--)
149
- if (e = t[n], e.state === x)
150
- N(e);
151
- else if (e.state === _) {
152
- const o = m;
153
- m = null, A(() => D(e, t[0]), !1), m = o;
154
- }
155
- }
156
- function A(e, t) {
157
- if (m) return e();
158
- let n = !1;
159
- t || (m = []), b ? n = !0 : b = [], j++;
160
- try {
161
- const o = e();
162
- return Me(n), o;
163
- } catch (o) {
164
- n || (b = null), m = null, W(o);
165
- }
166
- }
167
- function Me(e) {
168
- if (m && (ge(m), m = null), e) return;
169
- const t = b;
170
- b = null, t.length && A(() => ue(t), !1);
171
- }
172
- function ge(e) {
173
- for (let t = 0; t < e.length; t++) B(e[t]);
174
- }
175
- function _e(e) {
176
- let t, n = 0;
177
- for (t = 0; t < e.length; t++) {
178
- const o = e[t];
179
- o.user ? e[n++] = o : B(o);
180
- }
181
- for (t = 0; t < n; t++) B(e[t]);
182
- }
183
- function D(e, t) {
184
- e.state = 0;
185
- for (let n = 0; n < e.sources.length; n += 1) {
186
- const o = e.sources[n];
187
- if (o.sources) {
188
- const i = o.state;
189
- i === x ? o !== t && (!o.updatedAt || o.updatedAt < j) && B(o) : i === _ && D(o, t);
190
- }
191
- }
192
- }
193
- function me(e) {
194
- for (let t = 0; t < e.observers.length; t += 1) {
195
- const n = e.observers[t];
196
- n.state || (n.state = _, n.pure ? m.push(n) : b.push(n), n.observers && me(n));
197
- }
198
- }
199
- function $(e) {
200
- let t;
201
- if (e.sources)
202
- for (; e.sources.length; ) {
203
- const n = e.sources.pop(), o = e.sourceSlots.pop(), i = n.observers;
204
- if (i && i.length) {
205
- const r = i.pop(), l = n.observerSlots.pop();
206
- o < i.length && (r.sourceSlots[l] = o, i[o] = r, n.observerSlots[o] = l);
207
- }
208
- }
209
- if (e.tOwned) {
210
- for (t = e.tOwned.length - 1; t >= 0; t--) $(e.tOwned[t]);
211
- delete e.tOwned;
212
- }
213
- if (e.owned) {
214
- for (t = e.owned.length - 1; t >= 0; t--) $(e.owned[t]);
215
- e.owned = null;
216
- }
217
- if (e.cleanups) {
218
- for (t = e.cleanups.length - 1; t >= 0; t--) e.cleanups[t]();
219
- e.cleanups = null;
220
- }
221
- e.state = 0;
222
- }
223
- function He(e) {
224
- return e instanceof Error ? e : new Error(typeof e == "string" ? e : "Unknown error", {
225
- cause: e
226
- });
227
- }
228
- function W(e, t = d) {
229
- throw He(e);
230
- }
231
- function le(e, t) {
232
- return E(() => e(t || {}));
233
- }
234
- const Be = (e) => `Stale read from <${e}>.`;
235
- function De(e) {
236
- const t = e.keyed, n = O(() => e.when, void 0, void 0), o = t ? n : O(n, void 0, {
237
- equals: (i, r) => !i == !r
238
- });
239
- return O(() => {
240
- const i = o();
241
- if (i) {
242
- const r = e.children;
243
- return typeof r == "function" && r.length > 0 ? E(() => r(t ? i : () => {
244
- if (!E(o)) throw Be("Show");
245
- return n();
246
- })) : r;
247
- }
248
- return e.fallback;
249
- }, void 0, void 0);
250
- }
251
- function Ue(e, t, n) {
252
- let o = n.length, i = t.length, r = o, l = 0, s = 0, f = t[i - 1].nextSibling, h = null;
253
- for (; l < i || s < r; ) {
254
- if (t[l] === n[s]) {
255
- l++, s++;
256
- continue;
257
- }
258
- for (; t[i - 1] === n[r - 1]; )
259
- i--, r--;
260
- if (i === l) {
261
- const p = r < o ? s ? n[s - 1].nextSibling : n[r - s] : f;
262
- for (; s < r; ) e.insertBefore(n[s++], p);
263
- } else if (r === s)
264
- for (; l < i; )
265
- (!h || !h.has(t[l])) && t[l].remove(), l++;
266
- else if (t[l] === n[r - 1] && n[s] === t[i - 1]) {
267
- const p = t[--i].nextSibling;
268
- e.insertBefore(n[s++], t[l++].nextSibling), e.insertBefore(n[--r], p), t[i] = n[r];
269
- } else {
270
- if (!h) {
271
- h = /* @__PURE__ */ new Map();
272
- let v = s;
273
- for (; v < r; ) h.set(n[v], v++);
274
- }
275
- const p = h.get(t[l]);
276
- if (p != null)
277
- if (s < p && p < r) {
278
- let v = l, y = 1, S;
279
- for (; ++v < i && v < r && !((S = h.get(t[v])) == null || S !== p + y); )
280
- y++;
281
- if (y > p - s) {
282
- const G = t[l];
283
- for (; s < p; ) e.insertBefore(n[s++], G);
284
- } else e.replaceChild(n[s++], t[l++]);
285
- } else l++;
286
- else t[l++].remove();
287
- }
288
- }
289
- }
290
- const fe = "_$DX_DELEGATE";
291
- function Ve(e, t, n, o = {}) {
292
- let i;
293
- return de((r) => {
294
- i = r, t === document ? e() : U(t, e(), t.firstChild ? null : void 0, n);
295
- }, o.owner), () => {
296
- i(), t.textContent = "";
297
- };
298
- }
299
- function we(e, t, n, o) {
300
- let i;
301
- const r = () => {
302
- const s = o ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
303
- return s.innerHTML = e, n ? s.content.firstChild.firstChild : o ? s.firstChild : s.content.firstChild;
304
- }, l = t ? () => E(() => document.importNode(i || (i = r()), !0)) : () => (i || (i = r())).cloneNode(!0);
305
- return l.cloneNode = l, l;
306
- }
307
- function je(e, t = window.document) {
308
- const n = t[fe] || (t[fe] = /* @__PURE__ */ new Set());
309
- for (let o = 0, i = e.length; o < i; o++) {
310
- const r = e[o];
311
- n.has(r) || (n.add(r), t.addEventListener(r, Ge));
312
- }
313
- }
314
- function T(e, t, n) {
315
- n != null ? e.style.setProperty(t, n) : e.style.removeProperty(t);
316
- }
317
- function F(e, t, n) {
318
- return E(() => e(t, n));
319
- }
320
- function U(e, t, n, o) {
321
- if (n !== void 0 && !o && (o = []), typeof t != "function") return V(e, t, o, n);
322
- H((i) => V(e, t(), i, n), o);
323
- }
324
- function Ge(e) {
325
- let t = e.target;
326
- const n = `$$${e.type}`, o = e.target, i = e.currentTarget, r = (f) => Object.defineProperty(e, "target", {
327
- configurable: !0,
328
- value: f
329
- }), l = () => {
330
- const f = t[n];
331
- if (f && !t.disabled) {
332
- const h = t[`${n}Data`];
333
- if (h !== void 0 ? f.call(t, h, e) : f.call(t, e), e.cancelBubble) return;
334
- }
335
- return t.host && typeof t.host != "string" && !t.host._$host && t.contains(e.target) && r(t.host), !0;
336
- }, s = () => {
337
- for (; l() && (t = t._$host || t.parentNode || t.host); ) ;
338
- };
339
- if (Object.defineProperty(e, "currentTarget", {
340
- configurable: !0,
341
- get() {
342
- return t || document;
343
- }
344
- }), e.composedPath) {
345
- const f = e.composedPath();
346
- r(f[0]);
347
- for (let h = 0; h < f.length - 2 && (t = f[h], !!l()); h++) {
348
- if (t._$host) {
349
- t = t._$host, s();
350
- break;
351
- }
352
- if (t.parentNode === i)
353
- break;
354
- }
355
- } else s();
356
- r(o);
357
- }
358
- function V(e, t, n, o, i) {
359
- for (; typeof n == "function"; ) n = n();
360
- if (t === n) return n;
361
- const r = typeof t, l = o !== void 0;
362
- if (e = l && n[0] && n[0].parentNode || e, r === "string" || r === "number") {
363
- if (r === "number" && (t = t.toString(), t === n))
364
- return n;
365
- if (l) {
366
- let s = n[0];
367
- s && s.nodeType === 3 ? s.data !== t && (s.data = t) : s = document.createTextNode(t), n = C(e, n, o, s);
368
- } else
369
- n !== "" && typeof n == "string" ? n = e.firstChild.data = t : n = e.textContent = t;
370
- } else if (t == null || r === "boolean")
371
- n = C(e, n, o);
372
- else {
373
- if (r === "function")
374
- return H(() => {
375
- let s = t();
376
- for (; typeof s == "function"; ) s = s();
377
- n = V(e, s, n, o);
378
- }), () => n;
379
- if (Array.isArray(t)) {
380
- const s = [], f = n && Array.isArray(n);
381
- if (I(s, t, n, i))
382
- return H(() => n = V(e, s, n, o, !0)), () => n;
383
- if (s.length === 0) {
384
- if (n = C(e, n, o), l) return n;
385
- } else f ? n.length === 0 ? ce(e, s, o) : Ue(e, n, s) : (n && C(e), ce(e, s));
386
- n = s;
387
- } else if (t.nodeType) {
388
- if (Array.isArray(n)) {
389
- if (l) return n = C(e, n, o, t);
390
- C(e, n, null, t);
391
- } else n == null || n === "" || !e.firstChild ? e.appendChild(t) : e.replaceChild(t, e.firstChild);
392
- n = t;
393
- }
394
- }
395
- return n;
396
- }
397
- function I(e, t, n, o) {
398
- let i = !1;
399
- for (let r = 0, l = t.length; r < l; r++) {
400
- let s = t[r], f = n && n[e.length], h;
401
- if (!(s == null || s === !0 || s === !1)) if ((h = typeof s) == "object" && s.nodeType)
402
- e.push(s);
403
- else if (Array.isArray(s))
404
- i = I(e, s, f) || i;
405
- else if (h === "function")
406
- if (o) {
407
- for (; typeof s == "function"; ) s = s();
408
- i = I(e, Array.isArray(s) ? s : [s], Array.isArray(f) ? f : [f]) || i;
409
- } else
410
- e.push(s), i = !0;
411
- else {
412
- const p = String(s);
413
- f && f.nodeType === 3 && f.data === p ? e.push(f) : e.push(document.createTextNode(p));
414
- }
415
- }
416
- return i;
417
- }
418
- function ce(e, t, n = null) {
419
- for (let o = 0, i = t.length; o < i; o++) e.insertBefore(t[o], n);
420
- }
421
- function C(e, t, n, o) {
422
- if (n === void 0) return e.textContent = "";
423
- const i = o || document.createTextNode("");
424
- if (t.length) {
425
- let r = !1;
426
- for (let l = t.length - 1; l >= 0; l--) {
427
- const s = t[l];
428
- if (i !== s) {
429
- const f = s.parentNode === e;
430
- !r && !l ? f ? e.replaceChild(i, s) : e.insertBefore(i, n) : f && s.remove();
431
- } else r = !0;
432
- }
433
- } else e.insertBefore(i, n);
434
- return [i];
435
- }
436
- const Re = "http://www.w3.org/2000/svg";
437
- function Fe(e, t = !1, n = void 0) {
438
- return t ? document.createElementNS(Re, e) : document.createElement(e, {
439
- is: n
440
- });
441
- }
442
- function Ie(e) {
443
- const {
444
- useShadow: t
445
- } = e, n = document.createTextNode(""), o = () => e.mount || document.body, i = Ne();
446
- let r;
447
- return $e(() => {
448
- r || (r = Le(i, () => O(() => e.children)));
449
- const l = o();
450
- if (l instanceof HTMLHeadElement) {
451
- const [s, f] = P(!1), h = () => f(!0);
452
- de((p) => U(l, () => s() ? p() : r(), null)), re(h);
453
- } else {
454
- const s = Fe(e.isSVG ? "g" : "div", e.isSVG), f = t && s.attachShadow ? s.attachShadow({
455
- mode: "open"
456
- }) : s;
457
- Object.defineProperty(s, "_$host", {
458
- get() {
459
- return n.parentNode;
460
- },
461
- configurable: !0
462
- }), U(f, r), l.appendChild(s), e.ref && e.ref(s), re(() => l.contains(s) && l.removeChild(s));
463
- }
464
- }, void 0, {}), n;
465
- }
466
- var qe = /* @__PURE__ */ we("<div class=llm-config-tray-popover><div>"), We = /* @__PURE__ */ we('<div class=llm-config-tray><button class=llm-config-tray-button title="LLM model &amp; config"><span>🤖</span><span>model');
467
- function Qe(e) {
468
- const t = document.createElement("style");
469
- t.textContent = `
470
- .llm-config-tray { position: relative; display: inline-flex; align-items: center; }
471
- .llm-config-tray-button {
472
- display: inline-flex; align-items: center; gap: var(--studio-space-2xs, 0.25rem);
473
- height: 1.75rem; padding: 0 var(--studio-space-xs, 0.375rem);
474
- border: 1px solid var(--studio-chrome-offset-20, var(--studio-fill-offset-20, #d4d4d4));
475
- border-radius: var(--studio-radius-sm, 4px);
476
- background: var(--studio-chrome, var(--studio-fill, white));
477
- color: var(--studio-chrome-line, var(--studio-line, black));
478
- font: 500 0.75rem/1 var(--studio-family-sans, system-ui, sans-serif); cursor: pointer;
479
- }
480
- .llm-config-tray-button:hover {
481
- background: var(--studio-chrome-offset-10, var(--studio-fill-offset-10, #f2f2f2));
482
- }
483
- .llm-config-tray-popover {
484
- position: fixed; z-index: 2147483000; box-sizing: border-box;
485
- max-width: min(92vw, 520px); max-height: 80vh; overflow: auto;
486
- background: var(--studio-fill, white); color: var(--studio-line, black);
487
- border: 1px solid var(--studio-fill-offset-20, #d4d4d4);
488
- border-radius: var(--studio-radius-md, 8px);
489
- box-shadow: var(--studio-shadow-lg, 0 8px 32px rgba(0,0,0,0.24));
490
- padding: var(--studio-space-sm, 0.5rem);
491
- }
492
- `, e.append(t);
493
- const [n, o] = P(!1), [i, r] = P(), [l, s] = P({}), [f, h] = P(null);
494
- let p, v, y, S = null;
495
- function G(c) {
496
- return c ? {
497
- read: () => {
498
- try {
499
- return Ce(c);
500
- } catch {
501
- return ie();
502
- }
503
- },
504
- write: (u) => Ee(c, u)
505
- } : {
506
- read: () => ie(),
507
- write: (u) => Ae(u)
508
- };
509
- }
510
- async function ve() {
511
- const c = i(), u = l() || {};
512
- await xe(c, e), y && (y.replaceChildren(), S = Se({
513
- source: G(c),
514
- scope: c,
515
- toolName: c?.toolName || u.toolName,
516
- toolPrompt: u.toolPrompt,
517
- toolTools: u.toolTools
518
- }), y.append(S));
519
- }
520
- function ye() {
521
- const c = p.getBoundingClientRect(), u = Math.max(0, c.top - 16), k = Math.max(0, window.innerHeight - c.bottom - 16), g = u >= Math.min(window.innerHeight * 0.8, k);
522
- h({
523
- left: Math.max(8, c.right - Math.min(520, window.innerWidth * 0.92)),
524
- top: g ? c.top - 8 : c.bottom + 8,
525
- maxHeight: Math.min(window.innerHeight * 0.8, g ? u : k),
526
- above: g
527
- });
528
- }
529
- function K(c, u) {
530
- r(c?.toolId ? c : void 0), s(u || {}), ye(), o(!0), queueMicrotask(ve);
531
- }
532
- function L() {
533
- try {
534
- S?.destroy?.();
535
- } catch {
536
- }
537
- S = null, o(!1);
538
- }
539
- const Q = (c) => {
540
- const u = c.detail;
541
- !u || u.component !== "llm-config-tray" || K(u.scope, u);
542
- };
543
- document.addEventListener("patchwork:open-tool", Q);
544
- const X = (c) => {
545
- if (!n()) return;
546
- const u = c.composedPath();
547
- v && u.includes(v) || p && u.includes(p) || L();
548
- }, Y = (c) => {
549
- c.key === "Escape" && n() && L();
550
- };
551
- document.addEventListener("click", X), document.addEventListener("keydown", Y);
552
- const be = Ve(() => (() => {
553
- var c = We(), u = c.firstChild;
554
- u.$$click = (g) => {
555
- g.stopPropagation(), n() ? L() : K(void 0, {});
556
- };
557
- var k = p;
558
- return typeof k == "function" ? F(k, u) : p = u, U(c, le(De, {
559
- get when() {
560
- return n();
561
- },
562
- get children() {
563
- return le(Ie, {
564
- get mount() {
565
- return document.body;
566
- },
567
- get children() {
568
- var g = qe(), J = g.firstChild;
569
- g.$$click = (w) => w.stopPropagation();
570
- var Z = v;
571
- typeof Z == "function" ? F(Z, g) : v = g;
572
- var z = y;
573
- return typeof z == "function" ? F(z, J) : y = J, H((w) => {
574
- var ee = `${f()?.left ?? 0}px`, te = `${f()?.top ?? 0}px`, ne = `${f()?.maxHeight ?? 0}px`, oe = f()?.above ? "translateY(-100%)" : "none", se = f() ? "visible" : "hidden";
575
- return ee !== w.e && T(g, "left", w.e = ee), te !== w.t && T(g, "top", w.t = te), ne !== w.a && T(g, "max-height", w.a = ne), oe !== w.o && T(g, "transform", w.o = oe), se !== w.i && T(g, "visibility", w.i = se), w;
576
- }, {
577
- e: void 0,
578
- t: void 0,
579
- a: void 0,
580
- o: void 0,
581
- i: void 0
582
- }), g;
583
- }
584
- });
585
- }
586
- }), null), c;
587
- })(), e);
588
- return () => {
589
- L(), be(), t.remove(), document.removeEventListener("patchwork:open-tool", Q), document.removeEventListener("click", X), document.removeEventListener("keydown", Y);
590
- };
591
- }
592
- je(["click"]);
593
- export {
594
- Qe as LlmConfigTray
595
- };