@inkandswitch/patchwork-pkg-base 0.0.74 → 0.0.76

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,591 +0,0 @@
1
- import { ensureConfig as ve, dom as be, writeScopeOverride as Ee, readScopedConfig as Se, readConfig as oe, writeConfig as xe } from "./patchwork-llm-h1ZevlV6.js";
2
- const Ce = !1, Ae = (e, t) => e === t, L = {
3
- equals: Ae
4
- };
5
- let fe = he;
6
- const E = 1, O = 2, ce = {
7
- owned: null,
8
- cleanups: null,
9
- context: null,
10
- owner: null
11
- };
12
- var a = null;
13
- let G = null, ke = null, u = null, g = null, b = null, V = 0;
14
- function ue(e, t) {
15
- const n = u, o = a, i = e.length === 0, r = t === void 0 ? o : t, l = i ? ce : {
16
- owned: null,
17
- cleanups: null,
18
- context: r ? r.context : null,
19
- owner: r
20
- }, s = i ? e : () => e(() => x(() => T(l)));
21
- a = l, u = null;
22
- try {
23
- return A(s, !0);
24
- } finally {
25
- u = n, a = o;
26
- }
27
- }
28
- function k(e, t) {
29
- t = t ? Object.assign({}, L, t) : L;
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)), de(n, i));
36
- return [ae.bind(n), o];
37
- }
38
- function _(e, t, n) {
39
- const o = I(e, t, !1, E);
40
- $(o);
41
- }
42
- function Te(e, t, n) {
43
- fe = Oe;
44
- const o = I(e, t, !1, E);
45
- n || (o.user = !0), b ? b.push(o) : $(o);
46
- }
47
- function N(e, t, n) {
48
- n = n ? Object.assign({}, L, n) : L;
49
- const o = I(e, t, !0, 0);
50
- return o.observers = null, o.observerSlots = null, o.comparator = n.equals || void 0, $(o), ae.bind(o);
51
- }
52
- function x(e) {
53
- if (u === null) return e();
54
- const t = u;
55
- u = null;
56
- try {
57
- return e();
58
- } finally {
59
- u = t;
60
- }
61
- }
62
- function se(e) {
63
- return a === null || (a.cleanups === null ? a.cleanups = [e] : a.cleanups.push(e)), e;
64
- }
65
- function $e() {
66
- return a;
67
- }
68
- function Pe(e, t) {
69
- const n = a, o = u;
70
- a = e, u = null;
71
- try {
72
- return A(t, !0);
73
- } catch (i) {
74
- q(i);
75
- } finally {
76
- a = n, u = o;
77
- }
78
- }
79
- function ae() {
80
- if (this.sources && this.state)
81
- if (this.state === E) $(this);
82
- else {
83
- const e = g;
84
- g = null, A(() => B(this), !1), g = e;
85
- }
86
- if (u) {
87
- const e = this.observers;
88
- if (!e || e[e.length - 1] !== u) {
89
- const t = e ? e.length : 0;
90
- u.sources ? (u.sources.push(this), u.sourceSlots.push(t)) : (u.sources = [this], u.sourceSlots = [t]), e ? (e.push(u), this.observerSlots.push(u.sources.length - 1)) : (this.observers = [u], this.observerSlots = [u.sources.length - 1]);
91
- }
92
- }
93
- return this.value;
94
- }
95
- function de(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 = G && G.running;
100
- l && G.disposed.has(r), (l ? !r.tState : !r.state) && (r.pure ? g.push(r) : b.push(r), r.observers && pe(r)), l || (r.state = E);
101
- }
102
- if (g.length > 1e6)
103
- throw g = [], new Error();
104
- }, !1)), t;
105
- }
106
- function $(e) {
107
- if (!e.fn) return;
108
- T(e);
109
- const t = V;
110
- Ne(e, e.value, t);
111
- }
112
- function Ne(e, t, n) {
113
- let o;
114
- const i = a, r = u;
115
- u = a = e;
116
- try {
117
- o = e.fn(t);
118
- } catch (l) {
119
- return e.pure && (e.state = E, e.owned && e.owned.forEach(T), e.owned = null), e.updatedAt = n + 1, q(l);
120
- } finally {
121
- u = r, a = i;
122
- }
123
- (!e.updatedAt || e.updatedAt <= n) && (e.updatedAt != null && "observers" in e ? de(e, o) : e.value = o, e.updatedAt = n);
124
- }
125
- function I(e, t, n, o = E, 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: a,
136
- context: a ? a.context : null,
137
- pure: n
138
- };
139
- return a === null || a !== ce && (a.owned ? a.owned.push(r) : a.owned = [r]), r;
140
- }
141
- function M(e) {
142
- if (e.state === 0) return;
143
- if (e.state === O) return B(e);
144
- if (e.suspense && x(e.suspense.inFallback)) return e.suspense.effects.push(e);
145
- const t = [e];
146
- for (; (e = e.owner) && (!e.updatedAt || e.updatedAt < V); )
147
- e.state && t.push(e);
148
- for (let n = t.length - 1; n >= 0; n--)
149
- if (e = t[n], e.state === E)
150
- $(e);
151
- else if (e.state === O) {
152
- const o = g;
153
- g = null, A(() => B(e, t[0]), !1), g = o;
154
- }
155
- }
156
- function A(e, t) {
157
- if (g) return e();
158
- let n = !1;
159
- t || (g = []), b ? n = !0 : b = [], V++;
160
- try {
161
- const o = e();
162
- return Le(n), o;
163
- } catch (o) {
164
- n || (b = null), g = null, q(o);
165
- }
166
- }
167
- function Le(e) {
168
- if (g && (he(g), g = null), e) return;
169
- const t = b;
170
- b = null, t.length && A(() => fe(t), !1);
171
- }
172
- function he(e) {
173
- for (let t = 0; t < e.length; t++) M(e[t]);
174
- }
175
- function Oe(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 : M(o);
180
- }
181
- for (t = 0; t < n; t++) M(e[t]);
182
- }
183
- function B(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 === E ? o !== t && (!o.updatedAt || o.updatedAt < V) && M(o) : i === O && B(o, t);
190
- }
191
- }
192
- }
193
- function pe(e) {
194
- for (let t = 0; t < e.observers.length; t += 1) {
195
- const n = e.observers[t];
196
- n.state || (n.state = O, n.pure ? g.push(n) : b.push(n), n.observers && pe(n));
197
- }
198
- }
199
- function T(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--) T(e.tOwned[t]);
211
- delete e.tOwned;
212
- }
213
- if (e.owned) {
214
- for (t = e.owned.length - 1; t >= 0; t--) 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 _e(e) {
224
- return e instanceof Error ? e : new Error(typeof e == "string" ? e : "Unknown error", {
225
- cause: e
226
- });
227
- }
228
- function q(e, t = a) {
229
- throw _e(e);
230
- }
231
- function ie(e, t) {
232
- return x(() => e(t || {}));
233
- }
234
- const Me = (e) => `Stale read from <${e}>.`;
235
- function Be(e) {
236
- const t = e.keyed, n = N(() => e.when, void 0, void 0), o = t ? n : N(n, void 0, {
237
- equals: (i, r) => !i == !r
238
- });
239
- return N(() => {
240
- const i = o();
241
- if (i) {
242
- const r = e.children;
243
- return typeof r == "function" && r.length > 0 ? x(() => r(t ? i : () => {
244
- if (!x(o)) throw Me("Show");
245
- return n();
246
- })) : r;
247
- }
248
- return e.fallback;
249
- }, void 0, void 0);
250
- }
251
- function De(e, t, n) {
252
- let o = n.length, i = t.length, r = o, l = 0, s = 0, f = t[i - 1].nextSibling, d = 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 h = r < o ? s ? n[s - 1].nextSibling : n[r - s] : f;
262
- for (; s < r; ) e.insertBefore(n[s++], h);
263
- } else if (r === s)
264
- for (; l < i; )
265
- (!d || !d.has(t[l])) && t[l].remove(), l++;
266
- else if (t[l] === n[r - 1] && n[s] === t[i - 1]) {
267
- const h = t[--i].nextSibling;
268
- e.insertBefore(n[s++], t[l++].nextSibling), e.insertBefore(n[--r], h), t[i] = n[r];
269
- } else {
270
- if (!d) {
271
- d = /* @__PURE__ */ new Map();
272
- let m = s;
273
- for (; m < r; ) d.set(n[m], m++);
274
- }
275
- const h = d.get(t[l]);
276
- if (h != null)
277
- if (s < h && h < r) {
278
- let m = l, y = 1, S;
279
- for (; ++m < i && m < r && !((S = d.get(t[m])) == null || S !== h + y); )
280
- y++;
281
- if (y > h - s) {
282
- const j = t[l];
283
- for (; s < h; ) e.insertBefore(n[s++], j);
284
- } else e.replaceChild(n[s++], t[l++]);
285
- } else l++;
286
- else t[l++].remove();
287
- }
288
- }
289
- }
290
- const re = "_$DX_DELEGATE";
291
- function Ue(e, t, n, o = {}) {
292
- let i;
293
- return ue((r) => {
294
- i = r, t === document ? e() : D(t, e(), t.firstChild ? null : void 0, n);
295
- }, o.owner), () => {
296
- i(), t.textContent = "";
297
- };
298
- }
299
- function ge(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 ? () => x(() => document.importNode(i || (i = r()), !0)) : () => (i || (i = r())).cloneNode(!0);
305
- return l.cloneNode = l, l;
306
- }
307
- function Ve(e, t = window.document) {
308
- const n = t[re] || (t[re] = /* @__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, je));
312
- }
313
- }
314
- function H(e, t, n) {
315
- n != null ? e.style.setProperty(t, n) : e.style.removeProperty(t);
316
- }
317
- function R(e, t, n) {
318
- return x(() => e(t, n));
319
- }
320
- function D(e, t, n, o) {
321
- if (n !== void 0 && !o && (o = []), typeof t != "function") return U(e, t, o, n);
322
- _((i) => U(e, t(), i, n), o);
323
- }
324
- function je(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 d = t[`${n}Data`];
333
- if (d !== void 0 ? f.call(t, d, 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 d = 0; d < f.length - 2 && (t = f[d], !!l()); d++) {
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 U(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 _(() => {
375
- let s = t();
376
- for (; typeof s == "function"; ) s = s();
377
- n = U(e, s, n, o);
378
- }), () => n;
379
- if (Array.isArray(t)) {
380
- const s = [], f = n && Array.isArray(n);
381
- if (F(s, t, n, i))
382
- return _(() => n = U(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 ? le(e, s, o) : De(e, n, s) : (n && C(e), le(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 F(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], d;
401
- if (!(s == null || s === !0 || s === !1)) if ((d = typeof s) == "object" && s.nodeType)
402
- e.push(s);
403
- else if (Array.isArray(s))
404
- i = F(e, s, f) || i;
405
- else if (d === "function")
406
- if (o) {
407
- for (; typeof s == "function"; ) s = s();
408
- i = F(e, Array.isArray(s) ? s : [s], Array.isArray(f) ? f : [f]) || i;
409
- } else
410
- e.push(s), i = !0;
411
- else {
412
- const h = String(s);
413
- f && f.nodeType === 3 && f.data === h ? e.push(f) : e.push(document.createTextNode(h));
414
- }
415
- }
416
- return i;
417
- }
418
- function le(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 Ge = "http://www.w3.org/2000/svg";
437
- function He(e, t = !1, n = void 0) {
438
- return t ? document.createElementNS(Ge, e) : document.createElement(e, {
439
- is: n
440
- });
441
- }
442
- function Re(e) {
443
- const {
444
- useShadow: t
445
- } = e, n = document.createTextNode(""), o = () => e.mount || document.body, i = $e();
446
- let r;
447
- return Te(() => {
448
- r || (r = Pe(i, () => N(() => e.children)));
449
- const l = o();
450
- if (l instanceof HTMLHeadElement) {
451
- const [s, f] = k(!1), d = () => f(!0);
452
- ue((h) => D(l, () => s() ? h() : r(), null)), se(d);
453
- } else {
454
- const s = He(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
- }), D(f, r), l.appendChild(s), e.ref && e.ref(s), se(() => l.contains(s) && l.removeChild(s));
463
- }
464
- }, void 0, {}), n;
465
- }
466
- var Fe = /* @__PURE__ */ ge("<div class=llm-config-tray-popover style=transform:translateY(-100%)><div>"), Ie = /* @__PURE__ */ ge('<div class=llm-config-tray><button class=llm-config-tray-button title="LLM model &amp; config"><span>🤖</span><span>model');
467
- function We(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;
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] = k(!1), [i, r] = k(), [l, s] = k({}), [f, d] = k(null);
494
- let h, m, y, S = null;
495
- function j(c) {
496
- return c ? {
497
- read: () => {
498
- try {
499
- return Se(c);
500
- } catch {
501
- return oe();
502
- }
503
- },
504
- write: (p) => Ee(c, p)
505
- } : {
506
- read: () => oe(),
507
- write: (p) => xe(p)
508
- };
509
- }
510
- async function me() {
511
- const c = i(), p = l() || {};
512
- await ve(c, e), y && (y.replaceChildren(), S = be({
513
- source: j(c),
514
- scope: c,
515
- toolName: c?.toolName || p.toolName,
516
- toolPrompt: p.toolPrompt,
517
- toolTools: p.toolTools
518
- }), y.append(S));
519
- }
520
- function we() {
521
- const c = h.getBoundingClientRect();
522
- d({
523
- left: Math.max(8, c.right - 520),
524
- top: Math.max(8, c.top - 8)
525
- });
526
- }
527
- function W(c, p) {
528
- r(c?.toolId ? c : void 0), s(p || {}), we(), o(!0), queueMicrotask(me);
529
- }
530
- function P() {
531
- try {
532
- S?.destroy?.();
533
- } catch {
534
- }
535
- S = null, o(!1);
536
- }
537
- const K = (c) => {
538
- const p = c.detail;
539
- !p || p.component !== "llm-config-tray" || W(p.scope, p);
540
- };
541
- document.addEventListener("patchwork:open-tool", K);
542
- const Q = (c) => {
543
- if (!n()) return;
544
- const p = c.composedPath();
545
- m && p.includes(m) || h && p.includes(h) || P();
546
- }, X = (c) => {
547
- c.key === "Escape" && n() && P();
548
- };
549
- document.addEventListener("click", Q), document.addEventListener("keydown", X);
550
- const ye = Ue(() => (() => {
551
- var c = Ie(), p = c.firstChild;
552
- p.$$click = (w) => {
553
- w.stopPropagation(), n() ? P() : W(void 0, {});
554
- };
555
- var Y = h;
556
- return typeof Y == "function" ? R(Y, p) : h = p, D(c, ie(Be, {
557
- get when() {
558
- return n();
559
- },
560
- get children() {
561
- return ie(Re, {
562
- get mount() {
563
- return document.body;
564
- },
565
- get children() {
566
- var w = Fe(), J = w.firstChild;
567
- w.$$click = (v) => v.stopPropagation();
568
- var Z = m;
569
- typeof Z == "function" ? R(Z, w) : m = w;
570
- var z = y;
571
- return typeof z == "function" ? R(z, J) : y = J, _((v) => {
572
- var ee = `${f()?.left ?? 0}px`, te = `${f()?.top ?? 0}px`, ne = f() ? "visible" : "hidden";
573
- return ee !== v.e && H(w, "left", v.e = ee), te !== v.t && H(w, "top", v.t = te), ne !== v.a && H(w, "visibility", v.a = ne), v;
574
- }, {
575
- e: void 0,
576
- t: void 0,
577
- a: void 0
578
- }), w;
579
- }
580
- });
581
- }
582
- }), null), c;
583
- })(), e);
584
- return () => {
585
- P(), ye(), t.remove(), document.removeEventListener("patchwork:open-tool", K), document.removeEventListener("click", Q), document.removeEventListener("keydown", X);
586
- };
587
- }
588
- Ve(["click"]);
589
- export {
590
- We as LlmConfigTray
591
- };
@@ -1,2 +0,0 @@
1
- import{s as a,t as b}from"./chunk-DV7PRUYR.js";import"./chunk-FW4363Y4.js";export{a as IsolatedDocumentArea,b as mountIsolationRoot};
2
- //# sourceMappingURL=IsolatedDocumentArea-54ZI7TNY.js.map
@@ -1,2 +0,0 @@
1
- import{a as xe,b as N,c as B,d as ne,e as ie,f as ae,g as le,h as se,i as de,j as ce,k as ue,l as me,m as fe,n as x,o as F,p as he,q as pe,r as ge,s as we}from"./chunk-DV7PRUYR.js";import{a as P,b as ve}from"./chunk-ESMUVHPH.js";import{b as We}from"./chunk-FW4363Y4.js";import{template as y}from"solid-js/web";import{delegateEvents as ot}from"solid-js/web";import{memo as rt}from"solid-js/web";import{setStyleProperty as nt}from"solid-js/web";import{setAttribute as G}from"solid-js/web";import{effect as W}from"solid-js/web";import{getOwner as T}from"solid-js/web";import{use as R}from"solid-js/web";import{insert as _}from"solid-js/web";import{createComponent as m}from"solid-js/web";import"@inkandswitch/patchwork-elements";import{subscribe as pt}from"@inkandswitch/patchwork-providers";import{template as z}from"solid-js/web";import{delegateEvents as Fe}from"solid-js/web";import{memo as Pe}from"solid-js/web";import{insert as _e}from"solid-js/web";import{createComponent as O}from"solid-js/web";import{For as Ne,Show as j}from"solid-js";var Me=z("<div class=threepane-widgets>"),He=z("<div class=threepane-widgets__empty><button type=button class=threepane-widgets__add>\uFF0B Add document list"),Ve=z("<div class=threepane-widget>"),Be="chee/document-list";function be(e){let a=()=>{let l=e.rootFolderUrl(),r=e.configHandle();!l||!r||r.change(i=>{i.sidebar.widgets.push([Be,l])})};return(()=>{var l=Me();return _e(l,O(j,{get when(){return e.ready()},get children(){return O(j,{get when(){return e.widgets().length},get fallback(){return O(j,{get when(){return Pe(()=>!!e.rootFolderUrl())()&&e.configHandle()},get children(){var r=He(),i=r.firstChild;return i.$$click=a,r}})},get children(){return O(Ne,{get each(){return e.widgets()},children:r=>(()=>{var i=Ve();return _e(i,O(F,{slot:r})),i})()})}})}})),l})()}Fe(["click"]);import{template as Se}from"solid-js/web";import{setAttribute as je}from"solid-js/web";import{effect as ze}from"solid-js/web";import{insert as ye}from"solid-js/web";import{createComponent as K}from"solid-js/web";import{For as Xe,Show as Ye}from"solid-js";var Ke=Se("<div class=frame-tray>"),Ge=Se("<div class=frame-tray__item>");function De(e){return K(Ye,{get when(){return e.slots().length},get children(){var a=Ke();return ye(a,K(Xe,{get each(){return e.slots()},children:l=>(()=>{var r=Ge();return ye(r,K(F,{slot:l})),ze(()=>je(r,"data-tray-id",x(l))),r})()})),a}})}import{createEffect as U,createMemo as q,createSignal as v,onCleanup as k,onMount as J,Show as C}from"solid-js";import{render as gt}from"solid-js/web";import{createDocOfDatatype2 as Je}from"@inkandswitch/patchwork-plugins";import{getRegistry as qe}from"@inkandswitch/patchwork-plugins";function M(e){return qe("patchwork:datatype").loadWhenReady(e)}var Qe=new Set(["document-title","spacer"]),Ze="chee/document-list";function $e(e){return e?[[Ze,e]]:[]}async function ke(e,a){let l=e.doc()?.rootFolderUrl,r=e.doc()?.tools?.threepane;if(r){(await a.find(r)).change(d=>{if(l&&!d.sidebar?.widgets?.length&&(d.sidebar.widgets=$e(l)),!d.tray)d.tray=P.slice();else{let u=new Set(d.tray.map(c=>x(c)));for(let c of P)u.has(c)||d.tray.push(c)}d.doctitle?.tools?.length||(d.doctitle={...d.doctitle,tools:ve.slice()})});return}let i=await M("threepane:config");if(!i){console.warn("frame: threepane:config datatype never registered");return}if(e.doc()?.tools?.threepane)return;let t=e.doc(),o=(t?.documentToolbarToolIds??[]).filter(n=>!Qe.has(n)),s=await Je(i,a);s.change(n=>{o.length&&(n.doctitle.tools=o),n.sidebar.widgets=$e(t?.rootFolderUrl),n.tray||(n.tray=P.slice())}),e.change(n=>{n.tools||(n.tools={}),n.tools.threepane||(n.tools.threepane=s.url)})}var Te=We(xe(),1);import{createDocOfDatatype2 as et}from"@inkandswitch/patchwork-plugins";var w=(0,Te.default)("patchwork:threepane:examples");async function Re(e,a){let l=e.doc();if(!l?.rootFolderUrl){w("skipped \u2014 account has no rootFolderUrl");return}if(l.exampleDocsSeededAt){w("skipped \u2014 already ran for this account at",new Date(l.exampleDocsSeededAt).toISOString());return}w("claiming marker on account",e.url),e.change(u=>{u.exampleDocsSeededAt||(u.exampleDocsSeededAt=Date.now())});let r=await a.find(l.rootFolderUrl),i=r.doc()?.docs?.length??0;if(i){w(`skipped \u2014 root folder already has ${i} doc(s); only fresh accounts are seeded`);return}let t=window.location.hostname.includes("gaios"),o=t?[]:await tt();if(w(t?"gaios examples":"bundle init scripts:",o),!t&&!o.length){w("skipped \u2014 no static module bundles to ask");return}let s=await M("folder");if(!s){w("folder datatype never registered; giving up");return}let n=await et(s,a,u=>{u.title="Examples"});if(t){let{seedGaiosExamples:u}=await import("./gaiosExamples-YDNQB35L.js");await u(a,n)}for(let u of o)try{await(await import(u)).default?.(a,n),w("ran init script",u)}catch(c){w("init script unavailable or failed",u,c)}let d=n.doc()?.docs?.length??0;if(!d){w("no bundle contributed any documents");return}r.change(u=>{u.docs.unshift({name:"Examples",type:"folder",url:n.url})}),w(`seeded ${d} document(s) into Examples folder`,n.url)}var Ce="https://patchwork-tools.netlify.app/init.js",Ee="https://patchwork-base.netlify.app/init.js";async function tt(){let e=window.patchwork?.packages;if(!e?.urls)return[Ee,Ce];await e.doneLoading;let a=Object.values(e.urls).filter(r=>typeof r=="string"&&!r.startsWith("automerge:")).map(r=>new URL("init.js",new URL(r,document.baseURI)).href),l=a.length?[]:[Ee];return[...new Set([...a,...l,Ce])]}var it=y("<div class=frame-shell><aside class=frame-warning-banner>research grade software. do not share links. sharing a doc is sharing your account.</aside><div class=frame><patchwork-view component=patchwork-selected-doc-provider><patchwork-view component=patchwork-account-provider><patchwork-view component=patchwork-tool-storage-provider><patchwork-view component=patchwork-worker-provider>",!0,!1,!1),at=y("<div style=display:contents>"),lt=y("<div class=main-area>"),st=y("<div class=frame__popover-backdrop><div class=frame__popover role=dialog aria-modal=true><div class=frame__popover-toolbar><patchwork-view tool-id=doc-openwith></patchwork-view></div><div class=frame__popover-body><patchwork-view>",!0,!1,!1),dt=y('<button type=button class="frame__sidebar-toggle frame__left-toggle">'),ct=y("<div class=threepane-sidebar><div class=threepane-sidebar__footer><footer class=threepane-account-bar><button type=button class=threepane-account-bar__button>Settings"),ut=y("<div class=frame__tray-dock>"),mt=y('<button type=button class="threepane-account-bar__button threepane-account-bar__avatar"title=Account aria-label=Account><patchwork-view tool-id=contact-avatar>',!0,!1,!1),ft=y("<button type=button class=threepane-account-bar__button>Packages"),ht=y('<svg xmlns=http://www.w3.org/2000/svg width=18 height=18 viewBox="0 0 24 24"fill=none stroke=var(--studio-chrome-line) stroke-width=1.75 stroke-linecap=round stroke-linejoin=round><rect width=18 height=18 x=3 y=3 rx=2></rect><path d="M9 3v18">'),wt=180,vt=720,_t=120,bt=3,X=(e,a)=>{let[l,r]=v(!1);return U(()=>{let i=a();if(!i)return;r(!1);let t=o=>{o.detail?.componentId===e&&r(!0)};i.addEventListener("patchwork:mounted",t),k(()=>i.removeEventListener("patchwork:mounted",t))}),l};function Y(e,a){e.dispatchEvent(new CustomEvent("patchwork:open-document",{detail:a,bubbles:!0,composed:!0}))}function yt({handle:e,repo:a,...l}){ge();let r=e.url,[i,t]=v(),o=X("patchwork-account-provider",i),[s,n]=v(),d=X("patchwork-tool-storage-provider",s),[u,c]=v(),h=X("patchwork-selected-doc-provider",u),g=q(()=>h()&&o()&&d());return(()=>{var S=it(),p=S.firstChild,Q=p.firstChild,H=p.nextSibling,L=H.firstChild,I=L.firstChild,D=I.firstChild,A=D.firstChild;return _(p,m(C,{get when(){return l.isolation},get children(){return[" ","isolation is highly experimental. if things are broken, switch back to wild west."]}}),null),R(c,L),L._$owner=T(),R(t,I),I.docUrl=r,I._$owner=T(),R(n,D),D.docUrl=r,D._$owner=T(),A._$owner=T(),_(A,m(C,{get when(){return g()},get children(){return m(St,{handle:e,repo:a,get isolation(){return l.isolation}})}})),S})()}function St(e){let a=N(()=>e.handle.url,{repo:e.repo});(async()=>{await ke(e.handle,e.repo),await Re(e.handle,e.repo)})().catch(f=>{console.error("frame: account bootstrap failed",f)});let[l,r]=v(0);U(()=>{let f=a();if(!f)return;let b=()=>r($=>$+1);f.on("change",b),k(()=>f.off("change",b))});let i=q(()=>(l(),a()?.doc())),t=e.handle.url,o=()=>i()?.tools?.threepane,s=N(()=>o(),{repo:e.repo}),[n,d]=v(0);U(()=>{let f=s();if(!f)return;let b=()=>d($=>$+1);f.on("change",b),k(()=>f.off("change",b))});let u=q(()=>(n(),s()?.doc())),c=()=>u()?.doctitle?.tools,h=()=>u()?.sidebar?.widgets??[],g=()=>u()?.tray??[],S=()=>i()?.rootFolderUrl,p=se(),Q=de({setLeftSidebarWidth:p.setLeftSidebarWidth,setRightSidebarWidth:p.setRightSidebarWidth,setIsSidebarCollapsed:p.setIsSidebarCollapsed,setIsRightSidebarCollapsed:p.setIsRightSidebarCollapsed,isLeftCollapsed:p.isSidebarCollapsed,isRightCollapsed:p.isRightSidebarCollapsed,minWidth:wt,maxWidth:vt,autoCloseWidth:_t,dragThreshold:bt}),{events:H,dismissEvent:L,clearAll:I}=ue(),D,[A,Ie]=v(null),[Ue,Z]=v(null);J(()=>{let f=pt(D,{type:"patchwork:selected-view"},b=>Ie(b));k(f)});let E=()=>A()?.url,V=()=>A()?.toolId??void 0,ee=()=>ae(B.rightWidth,ie),te=()=>le(B.rightCollapsed),[Le,oe]=v(),Ae=ce(Le,E),[re,Oe]=v(!1);return U(()=>{re()||(e.isolation||!E()||Ae())&&Oe(!0)}),(()=>{var f=at(),b=D;return typeof b=="function"?R(b,f):D=f,_(f,m(me,{get events(){return H()},onDismiss:L,onClearAll:I}),null),_(f,m($t,{accountDocUrl:t,sidebarState:p,sidebarResize:Q,sidebarWidgets:h,traySlots:g,configHandle:s,rootFolderUrl:S,widgetsReady:re,contactUrl:()=>i()?.contactUrl,moduleSettingsUrl:()=>i()?.moduleSettingsUrl,get isolation(){return e.isolation},onInterceptOpen:Z,get children(){return m(C,{get when(){return E()},get fallback(){return(()=>{var $=lt();return _($,m(he,{viewKey:E,selectedDocUrl:E,toolId:V,ref:oe})),$})()},get children(){return m(C,{get when(){return e.isolation},get fallback(){return m(pe,{setMainDocElement:oe,selectedDocUrl:E,selectedToolId:V,doctitleSlots:c,get isLeftCollapsed(){return p.isSidebarCollapsed},initialRightWidth:ee,initialRightCollapsed:te})},get children(){return m(we,{get contactUrl(){return i()?.contactUrl},selectedDocUrl:E,selectedToolId:V,doctitleSlots:c,get isLeftCollapsed(){return p.isSidebarCollapsed},initialRightWidth:ee,initialRightCollapsed:te})}})}})}}),null),_(f,m(C,{get when(){return Ue()},children:$=>m(Dt,{get view(){return $()},onClose:()=>Z(null)})}),null),f})()}function Dt(e){let[a,l]=v(e.view.toolId??void 0);U(()=>l(e.view.toolId??void 0));let r;return J(()=>{let i=s=>{s.key==="Escape"&&e.onClose()};window.addEventListener("keydown",i),k(()=>window.removeEventListener("keydown",i));let t=r;if(!t)return;let o=s=>{let{url:n,toolId:d}=s.detail;n&&(s.stopPropagation(),l(d??void 0))};t.addEventListener("patchwork:open-document",o),k(()=>t.removeEventListener("patchwork:open-document",o))}),(()=>{var i=st(),t=i.firstChild,o=t.firstChild,s=o.firstChild,n=o.nextSibling,d=n.firstChild;i.$$click=()=>e.onClose(),t.$$click=c=>c.stopPropagation();var u=r;return typeof u=="function"?R(u,t):r=t,s._$owner=T(),d._$owner=T(),W(c=>{var h=e.view.url,g=e.view.url,S=a();return h!==c.e&&(s.docUrl=c.e=h),g!==c.t&&(d.docUrl=c.t=g),S!==c.a&&(d.toolId=c.a=S),c},{e:void 0,t:void 0,a:void 0}),i})()}function $t(e){let a=e.sidebarState.isSidebarCollapsed,l=()=>e.traySlots().length>0,r;J(()=>{if(!e.isolation||!r)return;let t=r,o=s=>{let{url:n,toolId:d}=s.detail;n&&(s.stopPropagation(),e.onInterceptOpen?.({url:n,toolId:d??null}))};t.addEventListener("patchwork:open-document",o),k(()=>t.removeEventListener("patchwork:open-document",o))});let i;return U(()=>{if(e.sidebarState.isSidebarCollapsed())return;let t=i;if(!t)return;let o=()=>{t.getBoundingClientRect().width<=window.innerWidth*.75||(e.sidebarState.setIsSidebarCollapsed(!0),window.dispatchEvent(new CustomEvent(ne)))};t.addEventListener("patchwork:open-document",o),k(()=>t.removeEventListener("patchwork:open-document",o))}),[(()=>{var t=dt();return t.$$click=()=>e.sidebarState.setIsSidebarCollapsed(o=>!o),_(t,m(kt,{})),W(o=>{var s=a()?"Show sidebar":"Hide sidebar",n=a()?"Show sidebar":"Hide sidebar",d=!a();return s!==o.e&&G(t,"title",o.e=s),n!==o.t&&G(t,"aria-label",o.t=n),d!==o.a&&G(t,"aria-pressed",o.a=d),o},{e:void 0,t:void 0,a:void 0}),t})(),m(fe,{side:"left",isCollapsed:a,get width(){return e.sidebarState.leftSidebarWidth},get onMouseDown(){return e.sidebarResize.handleMouseDown},get onToggleClick(){return e.sidebarResize.handleToggleClick},get children(){var t=ct(),o=t.firstChild,s=o.firstChild,n=s.firstChild,d=i;typeof d=="function"?R(d,t):i=t,_(t,m(be,{get widgets(){return e.sidebarWidgets},get configHandle(){return e.configHandle},get rootFolderUrl(){return e.rootFolderUrl},get ready(){return e.widgetsReady}}),o);var u=r;return typeof u=="function"?R(u,o):r=o,_(s,m(C,{get when(){return e.contactUrl()},children:c=>(()=>{var h=mt(),g=h.firstChild;return h.$$click=S=>Y(S.currentTarget,{url:e.accountDocUrl,toolId:"account-picker"}),g._$owner=T(),W(()=>g.docUrl=c()),h})()}),n),_(s,m(C,{get when(){return e.moduleSettingsUrl()},children:c=>(()=>{var h=ft();return h.$$click=g=>Y(g.currentTarget,{url:c(),toolId:"packages"}),h})()}),n),n.$$click=c=>Y(c.currentTarget,{url:e.accountDocUrl,toolId:"frame-configurator"}),W(()=>t.classList.toggle("threepane-sidebar--has-tray",!!l())),t}}),m(C,{get when(){return l()},get children(){var t=ut();return _(t,m(De,{get slots(){return e.traySlots}})),W(o=>{var s=!!a(),n=`${e.sidebarState.leftSidebarWidth()}px`;return s!==o.e&&t.classList.toggle("frame__tray-dock--collapsed",o.e=s),n!==o.t&&nt(t,"width",o.t=n),o},{e:void 0,t:void 0}),t}}),rt(()=>e.children)]}function kt(){return ht()}function $o(e){return(a,l)=>gt(()=>m(yt,{handle:a,get repo(){return l.repo},isolation:e}),l)}ot(["click"]);export{yt as PatchworkFrame,$o as renderPatchworkFrame};
2
- //# sourceMappingURL=PatchworkFrame-REYVVXOP.js.map