@ai-ecoverse/slicc-spectrum 1.110.0 → 1.111.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/slicc-ui.js CHANGED
@@ -17944,14 +17944,14 @@ var resolver = {
17944
17944
  };
17945
17945
  var string = initializeFactory("string");
17946
17946
  var text = initializeFactory("text");
17947
- function initializeFactory(field2) {
17947
+ function initializeFactory(field3) {
17948
17948
  return {
17949
- resolveAll: createResolver(field2 === "text" ? resolveAllLineSuffixes : void 0),
17949
+ resolveAll: createResolver(field3 === "text" ? resolveAllLineSuffixes : void 0),
17950
17950
  tokenize: initializeText
17951
17951
  };
17952
17952
  function initializeText(effects) {
17953
17953
  const self2 = this;
17954
- const constructs2 = this.parser.constructs[field2];
17954
+ const constructs2 = this.parser.constructs[field3];
17955
17955
  const text4 = effects.attempt(constructs2, start2, notText);
17956
17956
  return start2;
17957
17957
  function start2(code3) {
@@ -25063,7 +25063,7 @@ var File = class {
25063
25063
  const sessionAnnotationsCurrent = editSessionAnnotations?.current;
25064
25064
  let acceptedFile;
25065
25065
  let failed2 = false;
25066
- let failure2;
25066
+ let failure3;
25067
25067
  if (editor == null) throw new Error("File.__completeEditSession: editor is required for completion");
25068
25068
  const completedFile = { ...editSessionFile };
25069
25069
  const event2 = {
@@ -25082,7 +25082,7 @@ var File = class {
25082
25082
  }
25083
25083
  } catch (error) {
25084
25084
  failed2 = true;
25085
- failure2 = error;
25085
+ failure3 = error;
25086
25086
  }
25087
25087
  const settledFile = installResult && acceptedFile != null ? acceptedFile : inputFile;
25088
25088
  const settledAnnotations = installResult && acceptedFile != null ? sessionAnnotationsCurrent ?? inputAnnotations : inputAnnotations;
@@ -25095,7 +25095,7 @@ var File = class {
25095
25095
  this.fileRenderer.endEditSession(settledFile);
25096
25096
  if (areFileTargetsEqual(this.getRenderedFile(), settledFile)) this.adoptRenderData(settledFile);
25097
25097
  if (installResult && this.fileContainer != null) this.rerender();
25098
- if (failed2) throw failure2;
25098
+ if (failed2) throw failure3;
25099
25099
  }
25100
25100
  applyDocumentChange(textDocument, newLineAnnotations) {
25101
25101
  const editSessionFile = this.editSession?.file;
@@ -31513,7 +31513,7 @@ var FileDiff = class {
31513
31513
  let acceptedOldFile = null;
31514
31514
  let acceptedNewFile = null;
31515
31515
  let failed2 = false;
31516
- let failure2;
31516
+ let failure3;
31517
31517
  if (editor == null) throw new Error("FileDiff.__completeEditSession: editor is required for completion");
31518
31518
  const completedDiff = cloneFileDiffMetadata(editSessionDiff);
31519
31519
  const newFile = {
@@ -31544,7 +31544,7 @@ var FileDiff = class {
31544
31544
  }
31545
31545
  } catch (error) {
31546
31546
  failed2 = true;
31547
- failure2 = error;
31547
+ failure3 = error;
31548
31548
  }
31549
31549
  if (installResult && acceptedDiff != null) {
31550
31550
  if (this.additionFile != null) {
@@ -31559,7 +31559,7 @@ var FileDiff = class {
31559
31559
  lineAnnotations: installResult && acceptedDiff != null ? sessionAnnotationsCurrent ?? inputAnnotations : inputAnnotations
31560
31560
  };
31561
31561
  if (installResult && this.fileContainer != null) this.rerender();
31562
- if (failed2) throw failure2;
31562
+ if (failed2) throw failure3;
31563
31563
  }
31564
31564
  /**
31565
31565
  * Run the session-end recompute: restore recompute-shaped hunks (a
@@ -33411,14 +33411,14 @@ function errorCard(item2, handlers) {
33411
33411
  const signing = login?.state === "signing-in" && login.window;
33412
33412
  const text4 = resolved ? signedIn : signing ? signInText(login.waited) : item2.text;
33413
33413
  const title2 = resolved && login.provider ? `Signed in to ${login.provider} again.` : item2.title;
33414
- const failure2 = login?.state === "idle" ? login.error : void 0;
33414
+ const failure3 = login?.state === "idle" ? login.error : void 0;
33415
33415
  return b`<div class="error-card" role=${resolved ? A : "alert"} aria-atomic=${resolved ? A : "false"} data-id=${id || A} data-login=${login?.state ?? A}>
33416
33416
  ${resolved ? b`<swc-icon-info-circle class="icon" size="s" aria-hidden="true"></swc-icon-info-circle>` : b`<swc-icon-alert-diamond class="icon" size="s" aria-hidden="true"></swc-icon-alert-diamond>`}
33417
33417
  ${resolved ? A : b`<span class="sr">Error: </span>`}<span class="lead">${title2}</span>
33418
33418
  ${text4 ? b`<span class="detail" role=${login ? "status" : A}>${text4}</span>` : A}
33419
33419
  ${fix ? b`<div class="fix" aria-live="off">${fixButton(fix, item2, handlers, login)}</div>` : A}
33420
33420
  ${signing ? signInDetails(item2.account, login.signIn, login.copied, (code3) => handlers.copySignIn?.(item2.account, id, code3), "s") : A}
33421
- ${failure2 ? b`<div class="help" data-error="login"><sp-help-text size="s" variant="negative" icon>${failure2}</sp-help-text><swc-action-button size="s" quiet data-action="settings" @click=${() => handlers.action("settings", item2.id, item2.account)}>Open settings</swc-action-button></div>` : A}
33421
+ ${failure3 ? b`<div class="help" data-error="login"><sp-help-text size="s" variant="negative" icon>${failure3}</sp-help-text><swc-action-button size="s" quiet data-action="settings" @click=${() => handlers.action("settings", item2.id, item2.account)}>Open settings</swc-action-button></div>` : A}
33422
33422
  </div>`;
33423
33423
  }
33424
33424
  function time(at) {
@@ -33620,8 +33620,8 @@ function question(item2, handlers) {
33620
33620
  } else {
33621
33621
  const submit = (event2) => {
33622
33622
  event2.preventDefault();
33623
- const field2 = event2.currentTarget.querySelector("input");
33624
- if (field2.value.trim()) answer(field2.value.trim());
33623
+ const field3 = event2.currentTarget.querySelector("input");
33624
+ if (field3.value.trim()) answer(field3.value.trim());
33625
33625
  };
33626
33626
  body2 = b`<form class="options" @submit=${submit}>
33627
33627
  <input class="input" type=${item2.kind === "email" ? "email" : item2.kind === "number" ? "number" : item2.kind === "date" ? "date" : "text"} aria-label=${item2.question} ?disabled=${handlers.readOnly} />
@@ -34891,8 +34891,8 @@ function failureText(error) {
34891
34891
  const text4 = isVaultFailure(error) ? codeTexts[error.code] : void 0;
34892
34892
  return text4 ?? (error instanceof Error ? error.message : "The vault did not answer");
34893
34893
  }
34894
- function fieldOf(error, field2) {
34895
- return isVaultFailure(error) && error.code === "EINVAL" ? field2 : null;
34894
+ function fieldOf(error, field3) {
34895
+ return isVaultFailure(error) && error.code === "EINVAL" ? field3 : null;
34896
34896
  }
34897
34897
  function away(vault) {
34898
34898
  const state2 = vault.availability?.() ?? (vault.status() ? "ready" : "waiting");
@@ -35814,12 +35814,12 @@ var SliccComposer = class extends ThemedElement {
35814
35814
  this.renderRoot.querySelector('.item[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
35815
35815
  }
35816
35816
  #wire() {
35817
- const field2 = this.#field;
35818
- void field2.updateComplete.then(() => {
35817
+ const field3 = this.#field;
35818
+ void field3.updateComplete.then(() => {
35819
35819
  const popover = this.renderRoot.querySelector("swc-popover");
35820
35820
  if (popover) {
35821
35821
  popover.triggerElement = null;
35822
- popover.triggerElement = field2.shadowRoot.querySelector(
35822
+ popover.triggerElement = field3.shadowRoot.querySelector(
35823
35823
  ".swc-PromptField-upload"
35824
35824
  );
35825
35825
  }
@@ -36030,16 +36030,16 @@ ${this.value}` : text4;
36030
36030
  text4 === null || text4 === void 0 ? { ...base, kind: "file", size: 0, error: "Could not read the file" } : { ...base, kind: "text", size: text4.length, text: text4 }
36031
36031
  ];
36032
36032
  }
36033
- async shareSecret(name, field2 = null) {
36033
+ async shareSecret(name, field3 = null) {
36034
36034
  const clean = name.trim().toUpperCase().replace(/[^A-Z0-9_]/g, "_");
36035
36035
  if (this.sharing) return;
36036
36036
  if (!clean) {
36037
- if (field2) this.#refuse("Enter a name", "name", true);
36037
+ if (field3) this.#refuse("Enter a name", "name", true);
36038
36038
  return;
36039
36039
  }
36040
- const value = field2 ? take(field2) : "";
36040
+ const value = field3 ? take(field3) : "";
36041
36041
  const vault = this.model?.vault;
36042
- if (field2 && vault?.put && !await this.#store(vault, clean, value)) return;
36042
+ if (field3 && vault?.put && !await this.#store(vault, clean, value)) return;
36043
36043
  this.#refuse(null);
36044
36044
  this.attachments = [
36045
36045
  ...this.attachments,
@@ -36053,12 +36053,12 @@ ${this.value}` : text4;
36053
36053
  ];
36054
36054
  this.popup = null;
36055
36055
  }
36056
- #refuse(text4, field2 = null, focus = false) {
36056
+ #refuse(text4, field3 = null, focus = false) {
36057
36057
  this.secretError = text4;
36058
- this.secretField = text4 ? field2 : null;
36059
- if (focus && text4 && field2)
36058
+ this.secretField = text4 ? field3 : null;
36059
+ if (focus && text4 && field3)
36060
36060
  void this.updateComplete.then(
36061
- () => this.renderRoot.querySelector(`form.secret input[name=${field2}]`)?.focus()
36061
+ () => this.renderRoot.querySelector(`form.secret input[name=${field3}]`)?.focus()
36062
36062
  );
36063
36063
  }
36064
36064
  async #store(vault, clean, value) {
@@ -41104,9 +41104,9 @@ var defaultGates = {
41104
41104
  messages: ["user", "agent", "cone", "scoop:*", "off"],
41105
41105
  tools: ["user", "agent", "scoop:*"]
41106
41106
  };
41107
- function gateChoice(field2, cone, gate) {
41107
+ function gateChoice(field3, cone, gate) {
41108
41108
  if (gate === "scoop:*")
41109
- return cone.scoops.flatMap((name) => gateChoice(field2, cone, `scoop:${name}`));
41109
+ return cone.scoops.flatMap((name) => gateChoice(field3, cone, `scoop:${name}`));
41110
41110
  if (gate.startsWith("scoop:")) {
41111
41111
  const name = gate.slice(6);
41112
41112
  return cone.scoops.includes(name) ? [{ value: gate, label: `${name} decides`, description: `The scoop ${name} decides.` }] : [];
@@ -41126,14 +41126,14 @@ function gateChoice(field2, cone, gate) {
41126
41126
  off: {
41127
41127
  value: "off",
41128
41128
  label: "No review",
41129
- description: field2 === "messages" ? "Messages go straight in as follow-ups." : "Tool calls run without review."
41129
+ description: field3 === "messages" ? "Messages go straight in as follow-ups." : "Tool calls run without review."
41130
41130
  }
41131
41131
  };
41132
41132
  return choices[gate] ? [choices[gate]] : [];
41133
41133
  }
41134
- function gateOptions(field2, cone, allowed = defaultGates[field2]) {
41135
- const options2 = allowed.flatMap((gate) => gateChoice(field2, cone, gate)).filter((option, index2, all2) => all2.findIndex(({ value }) => value === option.value) === index2);
41136
- return options2.length ? options2 : gateChoice(field2, cone, "user");
41134
+ function gateOptions(field3, cone, allowed = defaultGates[field3]) {
41135
+ const options2 = allowed.flatMap((gate) => gateChoice(field3, cone, gate)).filter((option, index2, all2) => all2.findIndex(({ value }) => value === option.value) === index2);
41136
+ return options2.length ? options2 : gateChoice(field3, cone, "user");
41137
41137
  }
41138
41138
  function defaultGate(options2) {
41139
41139
  return options2.some(({ value }) => value === "user") ? "user" : options2[0].value;
@@ -41278,11 +41278,11 @@ var SliccGuestInvite = class extends i2 {
41278
41278
  get #current() {
41279
41279
  return this.cones.find((cone) => cone.id === this.cone) ?? this.cones[0];
41280
41280
  }
41281
- #options(field2, cone) {
41282
- return gateOptions(field2, cone, this.port?.gates?.()[field2]);
41281
+ #options(field3, cone) {
41282
+ return gateOptions(field3, cone, this.port?.gates?.()[field3]);
41283
41283
  }
41284
- #keep(gate, field2, cone) {
41285
- const options2 = this.#options(field2, cone);
41284
+ #keep(gate, field3, cone) {
41285
+ const options2 = this.#options(field3, cone);
41286
41286
  return options2.some((option) => option.value === gate) ? gate : defaultGate(options2);
41287
41287
  }
41288
41288
  #settle() {
@@ -41354,18 +41354,18 @@ var SliccGuestInvite = class extends i2 {
41354
41354
  this.remove();
41355
41355
  if (this.trigger?.isConnected) this.trigger.focus();
41356
41356
  }
41357
- #gate(field2, title2, value) {
41358
- const options2 = this.#options(field2, this.#current);
41357
+ #gate(field3, title2, value) {
41358
+ const options2 = this.#options(field3, this.#current);
41359
41359
  const chosen = options2.find((option) => option.value === value);
41360
- const id = `guest-${field2}`;
41360
+ const id = `guest-${field3}`;
41361
41361
  return b`<div class="field">
41362
41362
  <sp-field-label for=${id} size="m">${title2}</sp-field-label>
41363
- <sp-picker id=${id} size="m" label=${title2} data-action=${`guest-${field2}`} .value=${l(value)} ?disabled=${this.pending} @change=${(event2) => {
41364
- this[field2] = this.#pick(event2);
41363
+ <sp-picker id=${id} size="m" label=${title2} data-action=${`guest-${field3}`} .value=${l(value)} ?disabled=${this.pending} @change=${(event2) => {
41364
+ this[field3] = this.#pick(event2);
41365
41365
  }}>
41366
41366
  ${options2.map((option) => b`<sp-menu-item value=${option.value}>${option.label}<span slot="description">${option.description}</span></sp-menu-item>`)}
41367
41367
  </sp-picker>
41368
- <sp-help-text size="m" data-help=${field2}>${chosen.description}</sp-help-text>
41368
+ <sp-help-text size="m" data-help=${field3}>${chosen.description}</sp-help-text>
41369
41369
  </div>`;
41370
41370
  }
41371
41371
  #form() {
@@ -42951,11 +42951,11 @@ var SliccNetwork = class extends ModelElement {
42951
42951
  }
42952
42952
  async #submitPair(event2, port) {
42953
42953
  event2.preventDefault();
42954
- const field2 = this.renderRoot.querySelector("#pair-url");
42955
- const url = field2.value.trim();
42954
+ const field3 = this.renderRoot.querySelector("#pair-url");
42955
+ const url = field3.value.trim();
42956
42956
  if (!url || this.pairBusy || !port.pairComputer) return;
42957
42957
  if (await this.#pairAct("pair", () => port.pairComputer?.(url))) {
42958
- field2.value = "";
42958
+ field3.value = "";
42959
42959
  this.pairFilled = false;
42960
42960
  }
42961
42961
  }
@@ -43024,11 +43024,11 @@ var SliccNetwork = class extends ModelElement {
43024
43024
  #submitKey(event2, port) {
43025
43025
  event2.preventDefault();
43026
43026
  if (this.busy) return;
43027
- const field2 = event2.currentTarget.querySelector(
43027
+ const field3 = event2.currentTarget.querySelector(
43028
43028
  "sp-textfield"
43029
43029
  );
43030
- const key = field2.value.trim();
43031
- field2.value = "";
43030
+ const key = field3.value.trim();
43031
+ field3.value = "";
43032
43032
  if (key) void this.#tailnet("key", () => port.submitAuthKey?.(key));
43033
43033
  }
43034
43034
  #sendKey(event2) {
@@ -50437,7 +50437,7 @@ var SliccApprovals = class extends ModelElement {
50437
50437
  const list6 = this.#current();
50438
50438
  const [approval, ...rest] = held2 ? [held2, ...list6.filter(({ id }) => id !== held2.id)] : list6;
50439
50439
  if (!approval) return A;
50440
- const failure2 = this.failure?.id === approval.id ? this.failure.message : "";
50440
+ const failure3 = this.failure?.id === approval.id ? this.failure.message : "";
50441
50441
  const verdict = rulesOf(approval);
50442
50442
  const rules = verdict.certain ?? verdict.maybe;
50443
50443
  const always = approval.kind !== "tray" && approval.always && !deniedSudo(approval) && !rules;
@@ -50453,10 +50453,10 @@ var SliccApprovals = class extends ModelElement {
50453
50453
  ${this.#verdict(approval)}
50454
50454
  ${rules ? b`<div class="rules" data-secret-rules=${rules}><swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle><p>${verdict.certain ? b`<strong>This changes secret rules.</strong> It names <code>${commandText(rules, false)}</code>, where SLICC keeps which secrets programs may use and where they may be sent.` : b`<strong>This may change secret rules.</strong> SLICC can't tell where <code>${commandText(rules, false)}</code> leads, and it could reach the files where SLICC keeps which secrets programs may use and where they may be sent.`} Allow it only if you asked for this change.</p></div>` : A}
50455
50455
  ${hint2 ? b`<p class="hint">${hint2}</p>` : A}
50456
- ${!failure2 && gate ? b`<p class="hint" data-allow-hint>${gate}</p>` : A}
50457
- ${failure2 ? b`<p class="problem" role="alert" data-error><swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle><span>${failure2}</span></p>` : b`<p class="timer" data-timer>Denied automatically in ${countdown(approval.expiresAt - this.now)}.</p>`}
50456
+ ${!failure3 && gate ? b`<p class="hint" data-allow-hint>${gate}</p>` : A}
50457
+ ${failure3 ? b`<p class="problem" role="alert" data-error><swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle><span>${failure3}</span></p>` : b`<p class="timer" data-timer>Denied automatically in ${countdown(approval.expiresAt - this.now)}.</p>`}
50458
50458
  ${rest.length ? b`<p class="more" data-more>${rest.length === 1 ? "1 more request is waiting." : `${rest.length} more requests are waiting.`}</p>` : A}
50459
- ${this.#actions(approval, !!failure2, always)}
50459
+ ${this.#actions(approval, !!failure3, always)}
50460
50460
  </sp-alert-dialog>`
50461
50461
  );
50462
50462
  }
@@ -52683,15 +52683,15 @@ var SliccMemory = class extends ModelElement {
52683
52683
  }
52684
52684
  #save(memory) {
52685
52685
  const form = this.renderRoot.querySelector(".editor");
52686
- const field2 = (name) => form.querySelector(`[name=${name}]`).value.trim();
52687
- if (!field2("title")) return;
52688
- const tag3 = field2("tag");
52686
+ const field3 = (name) => form.querySelector(`[name=${name}]`).value.trim();
52687
+ if (!field3("title")) return;
52688
+ const tag3 = field3("tag");
52689
52689
  const saved = this.model?.memory.save({
52690
52690
  ...memory.id ? { id: memory.id } : {},
52691
52691
  scope: memory.scope,
52692
- section: field2("section") || "Notes",
52693
- title: field2("title"),
52694
- body: field2("body"),
52692
+ section: field3("section") || "Notes",
52693
+ title: field3("title"),
52694
+ body: field3("body"),
52695
52695
  tag: tag3 !== "none" ? tag3 : null
52696
52696
  });
52697
52697
  this.editing = null;
@@ -52968,13 +52968,13 @@ var SliccNotices = class extends ModelElement {
52968
52968
  }
52969
52969
  #notice(notice) {
52970
52970
  const pending = this.pending.get(notice.id);
52971
- const failure2 = this.failures.get(notice.id);
52971
+ const failure3 = this.failures.get(notice.id);
52972
52972
  return b`<div class="notice" role="status" data-notice=${notice.id} data-tone=${notice.tone}>
52973
52973
  ${notice.tone === "warning" ? b`<swc-icon-alert-triangle></swc-icon-alert-triangle>` : b`<swc-icon-info-circle></swc-icon-info-circle>`}
52974
52974
  <div class="text">
52975
52975
  <span class="title">${notice.title}</span>
52976
52976
  <p>${notice.body}</p>
52977
- ${failure2 ? b`<p class="problem" data-error><swc-icon-alert-triangle></swc-icon-alert-triangle><span>${failure2}</span></p>` : A}
52977
+ ${failure3 ? b`<p class="problem" data-error><swc-icon-alert-triangle></swc-icon-alert-triangle><span>${failure3}</span></p>` : A}
52978
52978
  ${notice.actions.length ? b`<div class="actions">${notice.actions.map(
52979
52979
  (action) => b`<swc-button size="s" variant="secondary" fill-style="outline" data-action=${action.id} ?pending=${pending === action.id} ?disabled=${!!pending && pending !== action.id} @click=${() => void this.act(notice.id, action.id)}>${action.label}</swc-button>`
52980
52980
  )}</div>` : A}
@@ -53674,19 +53674,19 @@ var SliccSecrets = class extends ThemedElement {
53674
53674
  if (form?.kind === "import") this.importKind = "bundle";
53675
53675
  if (form) void this.updateComplete.then(() => this.#focus());
53676
53676
  }
53677
- #refuse(text4, field2 = null, focus = false) {
53677
+ #refuse(text4, field3 = null, focus = false) {
53678
53678
  this.problem = text4;
53679
- this.invalid = text4 ? field2 : null;
53680
- if (focus && text4 && field2) void this.updateComplete.then(() => this.#field(field2)?.focus());
53679
+ this.invalid = text4 ? field3 : null;
53680
+ if (focus && text4 && field3) void this.updateComplete.then(() => this.#field(field3)?.focus());
53681
53681
  }
53682
53682
  #typed() {
53683
53683
  this.invalid = null;
53684
53684
  }
53685
- #bad(field2) {
53686
- return this.invalid === field2 ? "true" : A;
53685
+ #bad(field3) {
53686
+ return this.invalid === field3 ? "true" : A;
53687
53687
  }
53688
- #described(field2) {
53689
- return this.invalid === field2 ? "error-form" : A;
53688
+ #described(field3) {
53689
+ return this.invalid === field3 ? "error-form" : A;
53690
53690
  }
53691
53691
  #focus() {
53692
53692
  this.renderRoot.querySelector("[data-form] input, [data-form] sp-picker")?.focus();
@@ -53924,8 +53924,8 @@ var SliccSecrets = class extends ThemedElement {
53924
53924
  event2.preventDefault();
53925
53925
  if (!locked && !this.busy) void run();
53926
53926
  }
53927
- #value(label, field2 = "value") {
53928
- return b`<label class="field"><span>${label}</span><input type="password" autocomplete="off" spellcheck="false" data-field=${field2} aria-invalid=${this.#bad(field2)} aria-describedby=${this.#described(field2)} /></label>`;
53927
+ #value(label, field3 = "value") {
53928
+ return b`<label class="field"><span>${label}</span><input type="password" autocomplete="off" spellcheck="false" data-field=${field3} aria-invalid=${this.#bad(field3)} aria-describedby=${this.#described(field3)} /></label>`;
53929
53929
  }
53930
53930
  #actions(locked, label, action, run) {
53931
53931
  return b`<div class="buttons">
@@ -54979,13 +54979,13 @@ var SliccSettings = class extends ThemedElement {
54979
54979
  });
54980
54980
  }
54981
54981
  #settingsOf(account, fields) {
54982
- const settable = (account.fields ?? []).filter((field2) => field2.vaultSetting);
54982
+ const settable = (account.fields ?? []).filter((field3) => field3.vaultSetting);
54983
54983
  if (account.group === "mcp" || !settable.length) return void 0;
54984
54984
  return Object.fromEntries(
54985
- settable.flatMap((field2) => {
54986
- const value = fields?.[field2.name];
54987
- if (!value || field2.customBase && this.#baseOf(value)) return [];
54988
- return [[field2.vaultSetting, value]];
54985
+ settable.flatMap((field3) => {
54986
+ const value = fields?.[field3.name];
54987
+ if (!value || field3.customBase && this.#baseOf(value)) return [];
54988
+ return [[field3.vaultSetting, value]];
54989
54989
  })
54990
54990
  );
54991
54991
  }
@@ -54998,17 +54998,17 @@ var SliccSettings = class extends ThemedElement {
54998
54998
  #keyOptional(account) {
54999
54999
  const vault = this.#vault(account);
55000
55000
  const fields = account.fields ?? [];
55001
- if (!vault || !fields.some((field2) => field2.vaultSetting || field2.customBase)) return false;
55002
- if (fields.some((field2) => field2.vaultSetting) && !vault.settings) return false;
55001
+ if (!vault || !fields.some((field3) => field3.vaultSetting || field3.customBase)) return false;
55002
+ if (fields.some((field3) => field3.vaultSetting) && !vault.settings) return false;
55003
55003
  return !!this.#record(account);
55004
55004
  }
55005
55005
  #refused(account, message, keyed2) {
55006
- const field2 = (account.fields ?? []).find(
55006
+ const field3 = (account.fields ?? []).find(
55007
55007
  (candidate) => [candidate.vaultSetting, candidate.name, candidate.label].some(
55008
55008
  (word2) => word2 && words(message, word2)
55009
55009
  )
55010
55010
  );
55011
- if (field2) this.#refuse(account.id, field2.name, message);
55011
+ if (field3) this.#refuse(account.id, field3.name, message);
55012
55012
  else if (keyed2) this.#refuse(account.id, "value", message);
55013
55013
  else this.failure = { id: account.id, message };
55014
55014
  }
@@ -55020,14 +55020,14 @@ var SliccSettings = class extends ThemedElement {
55020
55020
  return void 0;
55021
55021
  }
55022
55022
  }
55023
- #oldBase(account, field2) {
55024
- return this.#baseOf(field2.value) ?? this.#bases.get(`${account.id} ${field2.name}`);
55023
+ #oldBase(account, field3) {
55024
+ return this.#baseOf(field3.value) ?? this.#bases.get(`${account.id} ${field3.name}`);
55025
55025
  }
55026
55026
  #baseChanges(account, fields) {
55027
- return (account.fields ?? []).filter((field2) => field2.customBase).map((field2) => ({
55028
- field: field2.name,
55029
- url: this.#baseOf(fields?.[field2.name]),
55030
- old: this.#oldBase(account, field2)
55027
+ return (account.fields ?? []).filter((field3) => field3.customBase).map((field3) => ({
55028
+ field: field3.name,
55029
+ url: this.#baseOf(fields?.[field3.name]),
55030
+ old: this.#oldBase(account, field3)
55031
55031
  })).filter((change) => change.url !== change.old);
55032
55032
  }
55033
55033
  #modelChange(name, changes2, from, to) {
@@ -55053,8 +55053,8 @@ var SliccSettings = class extends ThemedElement {
55053
55053
  await live?.endpoints?.(forward);
55054
55054
  } catch (error) {
55055
55055
  this.#busy(id, false);
55056
- const field2 = changes2.find((change) => change.url) ?? changes2[0];
55057
- if (this.model === model) this.#refuse(id, field2.field, failureText(error));
55056
+ const field3 = changes2.find((change) => change.url) ?? changes2[0];
55057
+ if (this.model === model) this.#refuse(id, field3.field, failureText(error));
55058
55058
  return;
55059
55059
  }
55060
55060
  if (this.model !== model) {
@@ -55078,35 +55078,35 @@ var SliccSettings = class extends ThemedElement {
55078
55078
  }
55079
55079
  #placeFailure(account, fields) {
55080
55080
  const message = this.failure.message;
55081
- const field2 = (account.fields ?? []).find(
55081
+ const field3 = (account.fields ?? []).find(
55082
55082
  (candidate) => candidate.customBase && !!fields?.[candidate.name] && [candidate.name, candidate.label, "https", "url", "port", "userinfo"].some(
55083
55083
  (word2) => words(message, word2)
55084
55084
  )
55085
55085
  );
55086
- if (!field2) return;
55086
+ if (!field3) return;
55087
55087
  this.failure = null;
55088
- this.#refuse(account.id, field2.name, message);
55088
+ this.#refuse(account.id, field3.name, message);
55089
55089
  }
55090
- #refuse(id, field2, message) {
55091
- this.problem = { id, field: field2, message };
55090
+ #refuse(id, field3, message) {
55091
+ this.problem = { id, field: field3, message };
55092
55092
  void this.updateComplete.then(
55093
55093
  () => this.renderRoot.querySelector(
55094
- field2 === "value" ? ".key input[data-field=value]" : `.key [data-account-field="${field2}"]`
55094
+ field3 === "value" ? ".key input[data-field=value]" : `.key [data-account-field="${field3}"]`
55095
55095
  )?.focus()
55096
55096
  );
55097
55097
  }
55098
55098
  #fields(form, account) {
55099
55099
  if (!account.fields?.length) return void 0;
55100
55100
  const values = {};
55101
- for (const field2 of account.fields) {
55102
- const input = form.querySelector(`[data-account-field="${field2.name}"]`);
55101
+ for (const field3 of account.fields) {
55102
+ const input = form.querySelector(`[data-account-field="${field3.name}"]`);
55103
55103
  const value = input.value.trim();
55104
- if (value) values[field2.name] = value;
55105
- else if (field2.required && field2.options?.length !== 0) {
55104
+ if (value) values[field3.name] = value;
55105
+ else if (field3.required && field3.options?.length !== 0) {
55106
55106
  this.#refuse(
55107
55107
  account.id,
55108
- field2.name,
55109
- field2.options ? `Select a ${field2.label.toLowerCase()}.` : `${field2.label} can\u2019t be empty`
55108
+ field3.name,
55109
+ field3.options ? `Select a ${field3.label.toLowerCase()}.` : `${field3.label} can\u2019t be empty`
55110
55110
  );
55111
55111
  return null;
55112
55112
  }
@@ -55149,7 +55149,7 @@ var SliccSettings = class extends ThemedElement {
55149
55149
  this.failure = null;
55150
55150
  this.problem = null;
55151
55151
  this.filled = new Set(
55152
- (account.fields ?? []).filter((field2) => field2.options || field2.value?.trim()).map((field2) => field2.name)
55152
+ (account.fields ?? []).filter((field3) => field3.options || field3.value?.trim()).map((field3) => field3.name)
55153
55153
  );
55154
55154
  this.entering = account.id;
55155
55155
  void this.updateComplete.then(() => this.focusOn(".key sp-textfield", ".key input"));
@@ -55171,9 +55171,9 @@ var SliccSettings = class extends ThemedElement {
55171
55171
  if (fields2 !== null && !this.pending.has(account.id)) void this.keep(account, value, fields2);
55172
55172
  return;
55173
55173
  }
55174
- const field2 = form.querySelector("sp-textfield");
55175
- const secret = field2.value.trim();
55176
- field2.value = "";
55174
+ const field3 = form.querySelector("sp-textfield");
55175
+ const secret = field3.value.trim();
55176
+ field3.value = "";
55177
55177
  const fields = this.#fields(form, account);
55178
55178
  if (secret && fields !== null) void this.#connectBases(account, secret, fields);
55179
55179
  }
@@ -55256,67 +55256,67 @@ var SliccSettings = class extends ThemedElement {
55256
55256
  this.failure = null;
55257
55257
  this.problem = null;
55258
55258
  }
55259
- #problem(account, field2, icon = true) {
55259
+ #problem(account, field3, icon = true) {
55260
55260
  const problem = this.problem;
55261
- if (problem?.id !== account.id || problem.field !== field2) return A;
55261
+ if (problem?.id !== account.id || problem.field !== field3) return A;
55262
55262
  return b`<div class="problem" id="key-problem" role="alert">
55263
55263
  ${icon ? b`<swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle>` : A}
55264
55264
  <span>${problem.message}</span>
55265
55265
  </div>`;
55266
55266
  }
55267
- #described(account, field2) {
55268
- return this.problem?.id === account.id && this.problem.field === field2 ? "key-problem" : A;
55267
+ #described(account, field3) {
55268
+ return this.problem?.id === account.id && this.problem.field === field3 ? "key-problem" : A;
55269
55269
  }
55270
- #invalid(account, field2) {
55271
- return this.#described(account, field2) === A ? A : "true";
55270
+ #invalid(account, field3) {
55271
+ return this.#described(account, field3) === A ? A : "true";
55272
55272
  }
55273
55273
  #extra(account) {
55274
55274
  return (account.fields ?? []).map(
55275
- (field2) => field2.options ? b`<div class="field">
55276
- <sp-field-label for=${`field-${field2.name}`} size="m">${field2.label}</sp-field-label>${this.#control(account, field2)}
55277
- ${field2.options.length ? A : b`<p class="hint" data-empty=${field2.name}>${nothingToChoose}</p>`}
55278
- ${field2.help ? b`<p class="hint" id=${`help-${field2.name}`}>${field2.help}</p>` : A}
55279
- ${this.#problem(account, field2.name, false)}
55275
+ (field3) => field3.options ? b`<div class="field">
55276
+ <sp-field-label for=${`field-${field3.name}`} size="m">${field3.label}</sp-field-label>${this.#control(account, field3)}
55277
+ ${field3.options.length ? A : b`<p class="hint" data-empty=${field3.name}>${nothingToChoose}</p>`}
55278
+ ${field3.help ? b`<p class="hint" id=${`help-${field3.name}`}>${field3.help}</p>` : A}
55279
+ ${this.#problem(account, field3.name, false)}
55280
55280
  </div>` : b`<label class="field">
55281
- <span>${field2.label}</span>${this.#control(account, field2)}
55281
+ <span>${field3.label}</span>${this.#control(account, field3)}
55282
55282
  </label>
55283
- ${field2.help ? b`<p class="hint" id=${`help-${field2.name}`}>${field2.help}</p>` : A}
55284
- ${this.#problem(account, field2.name)}`
55283
+ ${field3.help ? b`<p class="hint" id=${`help-${field3.name}`}>${field3.help}</p>` : A}
55284
+ ${this.#problem(account, field3.name)}`
55285
55285
  );
55286
55286
  }
55287
- #describedBy(account, field2) {
55288
- const problem = this.#described(account, field2.name);
55289
- const ids = [problem === A ? "" : problem, field2.help ? `help-${field2.name}` : ""];
55287
+ #describedBy(account, field3) {
55288
+ const problem = this.#described(account, field3.name);
55289
+ const ids = [problem === A ? "" : problem, field3.help ? `help-${field3.name}` : ""];
55290
55290
  return ids.filter(Boolean).join(" ") || A;
55291
55291
  }
55292
- #control(account, field2) {
55293
- if (field2.options) {
55294
- const empty4 = !field2.options.length;
55295
- const described2 = this.problem?.id === account.id && this.problem.field === field2.name;
55292
+ #control(account, field3) {
55293
+ if (field3.options) {
55294
+ const empty4 = !field3.options.length;
55295
+ const described2 = this.problem?.id === account.id && this.problem.field === field3.name;
55296
55296
  return b`<sp-picker
55297
55297
  size="m"
55298
- data-account-field=${field2.name}
55299
- label=${empty4 ? "None available" : field2.label}
55300
- id=${`field-${field2.name}`}
55301
- value=${start(field2.options, field2.value)}
55298
+ data-account-field=${field3.name}
55299
+ label=${empty4 ? "None available" : field3.label}
55300
+ id=${`field-${field3.name}`}
55301
+ value=${start(field3.options, field3.value)}
55302
55302
  ?disabled=${empty4}
55303
55303
  ?invalid=${described2}
55304
- aria-required=${field2.required ? "true" : A}
55304
+ aria-required=${field3.required ? "true" : A}
55305
55305
  >
55306
- ${field2.options.map((option) => b`<sp-menu-item value=${option.value}>${option.label}</sp-menu-item>`)}
55307
- ${described2 || empty4 || field2.help ? b`<span slot="description" class="sr">${described2 ? this.problem?.message : empty4 ? nothingToChoose : field2.help}</span>` : A}
55306
+ ${field3.options.map((option) => b`<sp-menu-item value=${option.value}>${option.label}</sp-menu-item>`)}
55307
+ ${described2 || empty4 || field3.help ? b`<span slot="description" class="sr">${described2 ? this.problem?.message : empty4 ? nothingToChoose : field3.help}</span>` : A}
55308
55308
  </sp-picker>`;
55309
55309
  }
55310
55310
  return b`<input
55311
55311
  type="text"
55312
55312
  autocomplete="off"
55313
55313
  spellcheck="false"
55314
- data-account-field=${field2.name}
55315
- value=${field2.value ?? A}
55316
- placeholder=${field2.placeholder ?? A}
55317
- aria-required=${field2.required ? "true" : A}
55318
- aria-invalid=${this.#invalid(account, field2.name)}
55319
- aria-describedby=${this.#describedBy(account, field2)}
55314
+ data-account-field=${field3.name}
55315
+ value=${field3.value ?? A}
55316
+ placeholder=${field3.placeholder ?? A}
55317
+ aria-required=${field3.required ? "true" : A}
55318
+ aria-invalid=${this.#invalid(account, field3.name)}
55319
+ aria-describedby=${this.#describedBy(account, field3)}
55320
55320
  />`;
55321
55321
  }
55322
55322
  #getKey(account) {
@@ -55334,9 +55334,9 @@ var SliccSettings = class extends ThemedElement {
55334
55334
  #ready(account) {
55335
55335
  if (account.blocked) return false;
55336
55336
  if (!this.#offered()) return true;
55337
- const required = (account.fields ?? []).filter((field2) => field2.required && !field2.options);
55337
+ const required = (account.fields ?? []).filter((field3) => field3.required && !field3.options);
55338
55338
  const key = this.#keyOptional(account) ? [] : ["value"];
55339
- return [...key, ...required.map((field2) => field2.name)].every((name) => this.filled.has(name));
55339
+ return [...key, ...required.map((field3) => field3.name)].every((name) => this.filled.has(name));
55340
55340
  }
55341
55341
  #fill(event2) {
55342
55342
  const input = event2.target;
@@ -55530,7 +55530,7 @@ var SliccSettings = class extends ThemedElement {
55530
55530
  const status2 = this.#status(account);
55531
55531
  const [variant, generic] = accountStatus[status2];
55532
55532
  const label = status2 === "rejected" ? rejectedNames[account.secret ?? "api-key"] : generic;
55533
- const failure2 = this.failure?.id === account.id ? b`<div class="failure" role="alert">
55533
+ const failure3 = this.failure?.id === account.id ? b`<div class="failure" role="alert">
55534
55534
  <swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle>
55535
55535
  <span>${this.failure.message}</span>
55536
55536
  </div>` : A;
@@ -55542,7 +55542,7 @@ var SliccSettings = class extends ThemedElement {
55542
55542
  </div>
55543
55543
  ${this.#rowNotes(account)}
55544
55544
  ${this.#movedNote(account)}
55545
- ${this.adding?.id === account.id ? A : b`${this.#key(account)}${this.#otherKey(account)}${failure2}`}`;
55545
+ ${this.adding?.id === account.id ? A : b`${this.#key(account)}${this.#otherKey(account)}${failure3}`}`;
55546
55546
  }
55547
55547
  #refusedNote(account) {
55548
55548
  if (account.state !== "refused") return A;
@@ -55624,7 +55624,7 @@ var SliccSettings = class extends ThemedElement {
55624
55624
  this.#busy(account.id, false);
55625
55625
  }
55626
55626
  this.focusOn("[data-action=add-provider]");
55627
- for (const field2 of account.fields ?? []) this.#bases.delete(`${account.id} ${field2.name}`);
55627
+ for (const field3 of account.fields ?? []) this.#bases.delete(`${account.id} ${field3.name}`);
55628
55628
  }
55629
55629
  #heldRecords(account, vault) {
55630
55630
  const server = serverOf(account);
@@ -55735,7 +55735,7 @@ var SliccSettings = class extends ThemedElement {
55735
55735
  event2.preventDefault();
55736
55736
  if (this.serverBusy) return;
55737
55737
  const form = event2.currentTarget;
55738
- const text4 = (field2) => form.querySelector(`[data-server-field=${field2}]`)?.value.trim();
55738
+ const text4 = (field3) => form.querySelector(`[data-server-field=${field3}]`)?.value.trim();
55739
55739
  const name = text4("name");
55740
55740
  const url = text4("url");
55741
55741
  const problem = this.#checkServer(name, url);
@@ -55764,21 +55764,21 @@ var SliccSettings = class extends ThemedElement {
55764
55764
  this.serverProblem = problem;
55765
55765
  if (problem.field !== "form") this.focusOn(`[data-server-field=${problem.field}]`);
55766
55766
  }
55767
- #serverNote(field2) {
55768
- if (this.serverProblem?.field !== field2) return A;
55769
- return b`<div class="problem" id=${`server-${field2}-problem`} role="alert" data-problem=${field2}>
55767
+ #serverNote(field3) {
55768
+ if (this.serverProblem?.field !== field3) return A;
55769
+ return b`<div class="problem" id=${`server-${field3}-problem`} role="alert" data-problem=${field3}>
55770
55770
  <swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle>
55771
55771
  <span>${this.serverProblem.message}</span>
55772
55772
  </div>`;
55773
55773
  }
55774
- #serverInput(field2, type, help2) {
55775
- const invalid = this.serverProblem?.field === field2;
55776
- const problem = invalid ? `server-${field2}-problem ` : "";
55774
+ #serverInput(field3, type, help2) {
55775
+ const invalid = this.serverProblem?.field === field3;
55776
+ const problem = invalid ? `server-${field3}-problem ` : "";
55777
55777
  return b`<input
55778
55778
  type=${type}
55779
55779
  autocomplete="off"
55780
55780
  spellcheck="false"
55781
- data-server-field=${field2}
55781
+ data-server-field=${field3}
55782
55782
  aria-required="true"
55783
55783
  aria-invalid=${invalid ? "true" : A}
55784
55784
  aria-describedby=${`${problem}${help2}`}
@@ -55875,8 +55875,8 @@ var SliccSettings = class extends ThemedElement {
55875
55875
  const dialog = this.#dialog;
55876
55876
  if (!changed2.has("picking") || !dialog || dialog.open) return;
55877
55877
  dialog.showModal();
55878
- const field2 = this.renderRoot.querySelector("sp-search");
55879
- void field2.updateComplete.then(() => field2.focus());
55878
+ const field3 = this.renderRoot.querySelector("sp-search");
55879
+ void field3.updateComplete.then(() => field3.focus());
55880
55880
  }
55881
55881
  get #dialog() {
55882
55882
  return this.renderRoot.querySelector("dialog.picker");
@@ -56233,13 +56233,197 @@ var bridge = `(() => {
56233
56233
  face.load().then(size, () => {});
56234
56234
  }
56235
56235
  };
56236
+ const runs = new Map();
56236
56237
  addEventListener('message', (event) => {
56237
56238
  if (event.source !== parent) return;
56238
56239
  const message = event.data || {};
56239
56240
  if (message.type === 'slicc-icons') swap(message.icons);
56240
56241
  if (message.type === 'slicc-fonts') fonts(message.fonts);
56241
56242
  if (message.type === 'slicc-theme') document.documentElement.classList.toggle('theme-light', message.color === 'light');
56243
+ const run = runs.get(message.id);
56244
+ if (run && message.type === 'slicc-cgi-head') run.head(message);
56245
+ if (run && message.type === 'slicc-cgi-chunk') run.chunk(message);
56242
56246
  });
56247
+ const native = window.fetch;
56248
+ const tag = Math.random().toString(36).slice(2);
56249
+ let count = 0;
56250
+ const empty = new Set([101, 103, 204, 205, 304]);
56251
+ const moved = new Set([301, 302, 303, 307, 308]);
56252
+ const decode = (text) => Uint8Array.from(atob(text || ''), (char) => char.charCodeAt(0));
56253
+ const encode = (bytes) => {
56254
+ let text = '';
56255
+ for (let at = 0; at < bytes.length; at += 32768) text += String.fromCharCode(...bytes.subarray(at, at + 32768));
56256
+ return btoa(text);
56257
+ };
56258
+ const scope = (input) => {
56259
+ try {
56260
+ const href = input instanceof Request ? input.url : new URL(input, document.baseURI).href;
56261
+ const base = new URL('cgi-bin/', document.baseURI);
56262
+ return href.startsWith(base.href) ? base : null;
56263
+ } catch {
56264
+ return null;
56265
+ }
56266
+ };
56267
+ const send = (input, init, hops) => {
56268
+ const base = scope(input);
56269
+ if (!base) return native.call(window, input, init);
56270
+ let request;
56271
+ try {
56272
+ request = new Request(input, init);
56273
+ } catch (error) {
56274
+ return Promise.reject(error);
56275
+ }
56276
+ const payload = request.body ? request.arrayBuffer() : Promise.resolve(null);
56277
+ return payload.then((bytes) => exchange(request, base, bytes, hops));
56278
+ };
56279
+ const redirect = (request, payload, status, location, hops) => {
56280
+ if (request.redirect === 'error') throw new TypeError('fetch: the response redirects and redirect is error');
56281
+ if (hops >= 20) throw new TypeError('fetch: more than 20 redirects');
56282
+ const get = (status === 303 && request.method !== 'GET' && request.method !== 'HEAD') || ((status === 301 || status === 302) && request.method === 'POST');
56283
+ const headers = new Headers(request.headers);
56284
+ if (get) for (const name of ['content-encoding', 'content-language', 'content-location', 'content-type']) headers.delete(name);
56285
+ const init = { method: get ? 'GET' : request.method, headers, body: get ? null : payload, signal: request.signal, redirect: request.redirect };
56286
+ return send(new URL(location, request.url).href, init, hops + 1).then((response) => Object.defineProperty(response, 'redirected', { value: true }));
56287
+ };
56288
+ const exchange = (request, base, payload, hops) => new Promise((resolve, reject) => {
56289
+ const { signal } = request;
56290
+ if (signal.aborted) return reject(signal.reason);
56291
+ const id = tag + ':' + ++count;
56292
+ const url = new URL(request.url);
56293
+ const headers = new Headers(request.headers);
56294
+ if (!headers.has('accept')) headers.set('accept', '*/*');
56295
+ const language = navigator.languages.join(',') || navigator.language;
56296
+ if (language && !headers.has('accept-language')) headers.set('accept-language', language);
56297
+ let stream = null;
56298
+ const finish = () => {
56299
+ runs.delete(id);
56300
+ signal.removeEventListener('abort', abort);
56301
+ };
56302
+ const close = () => {
56303
+ finish();
56304
+ post({ type: 'slicc-cgi-close', id });
56305
+ };
56306
+ const abort = () => {
56307
+ close();
56308
+ reject(signal.reason);
56309
+ if (stream) stream.error(signal.reason);
56310
+ };
56311
+ signal.addEventListener('abort', abort);
56312
+ runs.set(id, {
56313
+ head(message) {
56314
+ if (typeof message.error === 'string') {
56315
+ finish();
56316
+ return reject(new TypeError(message.error));
56317
+ }
56318
+ const head = message.head;
56319
+ let response;
56320
+ let follow = false;
56321
+ try {
56322
+ const fields = new Headers(head.headers);
56323
+ follow = moved.has(head.status) && fields.has('location') && request.redirect !== 'manual';
56324
+ const drop = follow || request.method === 'HEAD' || empty.has(head.status);
56325
+ const body = drop ? null : new ReadableStream({
56326
+ start(controller) {
56327
+ const first = decode(head.body);
56328
+ if (first.length) controller.enqueue(first);
56329
+ if (head.done) controller.close();
56330
+ else stream = controller;
56331
+ },
56332
+ cancel() {
56333
+ if (runs.has(id)) close();
56334
+ },
56335
+ });
56336
+ response = new Response(body, { status: head.status, statusText: head.statusText, headers: fields });
56337
+ } catch (error) {
56338
+ close();
56339
+ return reject(new TypeError(error.message));
56340
+ }
56341
+ if (head.done) finish();
56342
+ url.hash = '';
56343
+ Object.defineProperty(response, 'url', { value: url.href });
56344
+ if (!follow) return resolve(response);
56345
+ try {
56346
+ resolve(redirect(request, payload, head.status, response.headers.get('location'), hops));
56347
+ } catch (error) {
56348
+ reject(error);
56349
+ }
56350
+ },
56351
+ chunk(message) {
56352
+ if (typeof message.error === 'string') {
56353
+ finish();
56354
+ if (stream) stream.error(new TypeError(message.error));
56355
+ return;
56356
+ }
56357
+ const bytes = decode(message.body);
56358
+ if (stream && bytes.length) stream.enqueue(bytes);
56359
+ if (!message.done) return;
56360
+ finish();
56361
+ if (stream) stream.close();
56362
+ },
56363
+ });
56364
+ post({
56365
+ type: 'slicc-cgi',
56366
+ id,
56367
+ request: {
56368
+ method: request.method,
56369
+ path: url.pathname.slice(base.pathname.length),
56370
+ query: url.search.slice(1),
56371
+ headers: [...headers],
56372
+ body: payload && payload.byteLength ? encode(new Uint8Array(payload)) : null,
56373
+ },
56374
+ });
56375
+ });
56376
+ window.fetch = function fetch(input, init) {
56377
+ return send(input, init, 0);
56378
+ };
56379
+ const formOf = (form, submitter) => {
56380
+ const own = (name) => !!submitter && submitter.hasAttribute('form' + name);
56381
+ return {
56382
+ action: (own('action') ? submitter.getAttribute('formaction') : form.getAttribute('action')) || '',
56383
+ method: own('method') ? submitter.formMethod : form.method,
56384
+ enctype: own('enctype') ? submitter.formEnctype : form.enctype,
56385
+ };
56386
+ };
56387
+ const submitted = (form, submitter) => {
56388
+ const { action, method, enctype } = formOf(form, submitter);
56389
+ if (!action || !scope(action)) return;
56390
+ const url = new URL(action, document.baseURI);
56391
+ const data = new FormData(form, submitter || null);
56392
+ const entries = [...data].map(([name, value]) => [name, typeof value === 'string' ? value : value.name]);
56393
+ const init = { method: method === 'post' ? 'POST' : 'GET', redirect: 'manual', headers: {} };
56394
+ if (init.method === 'GET') url.search = new URLSearchParams(entries).toString();
56395
+ else if (enctype === 'multipart/form-data') init.body = data;
56396
+ else if (enctype === 'text/plain') {
56397
+ init.body = entries.map(([name, value]) => name + '=' + value + '\\r\\n').join('');
56398
+ init.headers['content-type'] = 'text/plain';
56399
+ } else {
56400
+ init.body = new URLSearchParams(entries).toString();
56401
+ init.headers['content-type'] = 'application/x-www-form-urlencoded';
56402
+ }
56403
+ const tell = (detail) => form.dispatchEvent(new CustomEvent('slicc-cgi', { bubbles: true, cancelable: true, detail }));
56404
+ send(url.href, init, 0).then(
56405
+ (response) => {
56406
+ if (tell({ response }) && response.headers.has('location')) post({ type: 'slicc-reload' });
56407
+ },
56408
+ (error) => tell({ error }),
56409
+ );
56410
+ };
56411
+ const copies = new WeakSet();
56412
+ addEventListener('submit', (event) => {
56413
+ if (copies.has(event)) return;
56414
+ const form = event.composedPath()[0];
56415
+ if (!(form instanceof HTMLFormElement) || formOf(form, event.submitter).method === 'dialog') return;
56416
+ event.preventDefault();
56417
+ event.stopImmediatePropagation();
56418
+ const copy = new SubmitEvent('submit', { bubbles: true, cancelable: true, submitter: event.submitter });
56419
+ copies.add(copy);
56420
+ if (form.dispatchEvent(copy)) submitted(form, event.submitter);
56421
+ }, true);
56422
+ const submit = HTMLFormElement.prototype.submit;
56423
+ HTMLFormElement.prototype.submit = function () {
56424
+ if (formOf(this, null).method === 'dialog') return submit.call(this);
56425
+ submitted(this, null);
56426
+ };
56243
56427
  const size = () => {
56244
56428
  const style = getComputedStyle(document.body);
56245
56429
  post({ type: 'slicc-size', height: Math.ceil(document.body.offsetHeight + parseFloat(style.marginTop) + parseFloat(style.marginBottom)) });
@@ -56332,12 +56516,47 @@ async function frameFonts(files, base) {
56332
56516
  (font) => Boolean(font.data)
56333
56517
  );
56334
56518
  }
56519
+ var cgiMethods = /* @__PURE__ */ new Set([
56520
+ "cgi",
56521
+ "cgiRead",
56522
+ "cgiClose"
56523
+ ]);
56335
56524
  var sprinkleMethods = /* @__PURE__ */ new Set([
56336
56525
  "readFile",
56337
56526
  "exists",
56338
56527
  "getState",
56339
- "setState"
56528
+ "setState",
56529
+ ...cgiMethods
56340
56530
  ]);
56531
+ var field2 = (value) => typeof value === "string" ? value : "";
56532
+ function cgiRequest(value) {
56533
+ const given = value ?? {};
56534
+ const headers = (Array.isArray(given.headers) ? given.headers : []).filter(
56535
+ (pair) => Array.isArray(pair) && typeof pair[0] === "string" && typeof pair[1] === "string"
56536
+ ).map(([name, text4]) => [name, text4]);
56537
+ return {
56538
+ method: field2(given.method) || "GET",
56539
+ path: field2(given.path),
56540
+ query: field2(given.query),
56541
+ headers,
56542
+ body: field2(given.body) || null
56543
+ };
56544
+ }
56545
+ function cgiRefusal(status2, text4) {
56546
+ return {
56547
+ status: status2,
56548
+ statusText: status2 === 403 ? "Forbidden" : "Not Found",
56549
+ headers: [["Content-Type", "text/plain; charset=utf-8"]],
56550
+ body: btoa(`${text4}
56551
+ `),
56552
+ done: true,
56553
+ stream: null
56554
+ };
56555
+ }
56556
+ var cgiGuest = "A guest seat has no cgi-bin/.";
56557
+ var cgiReadOnly = "This sprinkle is read-only here, so its cgi-bin/ only answers GET and HEAD.";
56558
+ var cgiMissing = "This sprinkle has no cgi-bin/ here.";
56559
+ var failure2 = (error) => error instanceof Error ? error.message : String(error);
56341
56560
  var grip = w`<svg class="grip" viewBox="0 0 8 14" width="8" height="14" aria-hidden="true">${[2, 7, 12].flatMap((y8) => [2, 6].map((x5) => w`<circle cx=${x5} cy=${y8} r="1.25"></circle>`))}</svg>`;
56342
56561
  var plainId = (id) => id.replace(/^cone:/, "");
56343
56562
  var SliccSprinkle = class extends ThemedElement {
@@ -56477,8 +56696,75 @@ var SliccSprinkle = class extends ThemedElement {
56477
56696
  this.height = data.height;
56478
56697
  } else if (data.type === "slicc-call") {
56479
56698
  await this.#call(source, data);
56699
+ } else if (data.type === "slicc-cgi") {
56700
+ await this.#cgi(source, data);
56701
+ } else if (data.type === "slicc-cgi-close") {
56702
+ this.#close(data.id);
56703
+ } else if (data.type === "slicc-reload") {
56704
+ this.#reload();
56480
56705
  }
56481
56706
  };
56707
+ #runs = /* @__PURE__ */ new Map();
56708
+ #refusal(method) {
56709
+ if (this.model?.seat) return cgiRefusal(403, cgiGuest);
56710
+ const reading = ["GET", "HEAD"].includes(method.toUpperCase());
56711
+ if (!reading && this.#readOnly()) return cgiRefusal(403, cgiReadOnly);
56712
+ return void 0;
56713
+ }
56714
+ async #cgi(source, data) {
56715
+ if (typeof data.id !== "string") return;
56716
+ const id = data.id;
56717
+ const post2 = (message) => source.postMessage({ ...message, id }, "*");
56718
+ const request2 = cgiRequest(data.request);
56719
+ const port = this.model?.sprinkles;
56720
+ const call = port?.call?.bind(port);
56721
+ const refused3 = this.#refusal(request2.method);
56722
+ if (refused3 || !call)
56723
+ return post2({ type: "slicc-cgi-head", head: refused3 ?? cgiRefusal(404, cgiMissing) });
56724
+ const run = { call, sprinkle: this.sprinkle, stream: null, closed: false };
56725
+ this.#runs.set(id, run);
56726
+ let headed = false;
56727
+ try {
56728
+ const head = await call(run.sprinkle, "cgi", [request2]);
56729
+ let done2 = head.done || !head.stream;
56730
+ run.stream = done2 ? null : head.stream;
56731
+ if (run.closed) return this.#shut(run);
56732
+ headed = true;
56733
+ const { status: status2, statusText, headers, body: body2 } = head;
56734
+ post2({ type: "slicc-cgi-head", head: { status: status2, statusText, headers, body: body2, done: done2 } });
56735
+ while (!done2) {
56736
+ const chunk = await call(run.sprinkle, "cgiRead", [run.stream]);
56737
+ if (run.closed) return;
56738
+ done2 = chunk.done;
56739
+ post2({ type: "slicc-cgi-chunk", body: chunk.body, done: done2 });
56740
+ }
56741
+ } catch (error) {
56742
+ if (!run.closed)
56743
+ post2({ type: headed ? "slicc-cgi-chunk" : "slicc-cgi-head", error: failure2(error) });
56744
+ } finally {
56745
+ if (this.#runs.get(id) === run) this.#runs.delete(id);
56746
+ }
56747
+ }
56748
+ #close(id) {
56749
+ const run = typeof id === "string" ? this.#runs.get(id) : void 0;
56750
+ if (!run) return;
56751
+ this.#runs.delete(id);
56752
+ this.#shut(run);
56753
+ }
56754
+ #shut(run) {
56755
+ run.closed = true;
56756
+ if (run.stream) run.call(run.sprinkle, "cgiClose", [run.stream]).catch(() => void 0);
56757
+ }
56758
+ #closeAll() {
56759
+ for (const run of this.#runs.values()) this.#shut(run);
56760
+ this.#runs.clear();
56761
+ }
56762
+ #reload() {
56763
+ this.#closeAll();
56764
+ this.#frame = { key: "", doc: "" };
56765
+ this.#mounts++;
56766
+ this.requestUpdate();
56767
+ }
56482
56768
  #readOnly() {
56483
56769
  return this.readonly || !!this.model?.seat || this.#frozen() || !!watchOnly(this.model);
56484
56770
  }
@@ -56500,6 +56786,7 @@ var SliccSprinkle = class extends ThemedElement {
56500
56786
  async #call(source, data) {
56501
56787
  const port = this.model?.sprinkles;
56502
56788
  if (!port?.call || typeof data.method !== "string" || !sprinkleMethods.has(data.method)) return;
56789
+ if (cgiMethods.has(data.method)) return;
56503
56790
  const method = data.method;
56504
56791
  if (method === "setState" && this.#readOnly()) {
56505
56792
  source.postMessage({ type: "slicc-result", id: data.id, error: "read-only" }, "*");
@@ -56556,6 +56843,7 @@ var SliccSprinkle = class extends ThemedElement {
56556
56843
  return [
56557
56844
  ...super.subscribe(model),
56558
56845
  () => globalThis.removeEventListener("message", this.#message),
56846
+ () => this.#closeAll(),
56559
56847
  model.sprinkles.on("sprinkles", () => this.requestUpdate()),
56560
56848
  this.#dips.on("change", () => this.requestUpdate()),
56561
56849
  ...onWatch(model, () => this.requestUpdate())
@@ -56609,7 +56897,7 @@ ${data.html}`;
56609
56897
  const style2 = `color-scheme:${this.color};${this.inline ? `height:${this.height}px;` : ""}`;
56610
56898
  const frame = b`${i23(
56611
56899
  this.#mounts,
56612
- b`<iframe title=${data.title} sandbox="allow-scripts" ?inert=${watch2} style=${style2} .srcdoc=${this.#document(data, state2)}></iframe>`
56900
+ b`<iframe title=${data.title} sandbox="allow-scripts allow-forms" ?inert=${watch2} style=${style2} .srcdoc=${this.#document(data, state2)}></iframe>`
56613
56901
  )}`;
56614
56902
  if (!this.inline)
56615
56903
  return watch2 ? b`<div class="panel"><div class="bar">${caption2}</div>${frame}</div>` : frame;
@@ -56892,10 +57180,10 @@ var SliccValueRequest = class extends ThemedElement {
56892
57180
  const bad = nameProblem(name);
56893
57181
  const value = bad ? "" : take(this.#field("value"));
56894
57182
  const text4 = bad ?? valueProblem(value);
56895
- const field2 = bad ? "name" : "value";
56896
- this.problem = text4 ? { id: request2.id, text: text4, field: field2 } : null;
57183
+ const field3 = bad ? "name" : "value";
57184
+ this.problem = text4 ? { id: request2.id, text: text4, field: field3 } : null;
56897
57185
  if (text4) {
56898
- void this.updateComplete.then(() => this.#field(field2)?.focus());
57186
+ void this.updateComplete.then(() => this.#field(field3)?.focus());
56899
57187
  return;
56900
57188
  }
56901
57189
  this.busy = true;
@@ -56905,8 +57193,8 @@ var SliccValueRequest = class extends ThemedElement {
56905
57193
  this.#done.add(request2.id);
56906
57194
  } catch (error) {
56907
57195
  if (this.#mine(vault)) {
56908
- const field3 = fieldOf(error, "value");
56909
- this.problem = { id: request2.id, text: failureText(error), ...field3 ? { field: field3 } : {} };
57196
+ const field4 = fieldOf(error, "value");
57197
+ this.problem = { id: request2.id, text: failureText(error), ...field4 ? { field: field4 } : {} };
56910
57198
  }
56911
57199
  } finally {
56912
57200
  if (this.model?.vault === vault) this.busy = false;
@@ -56915,8 +57203,8 @@ var SliccValueRequest = class extends ThemedElement {
56915
57203
  #typed() {
56916
57204
  if (this.problem?.field) this.problem = { id: this.problem.id, text: this.problem.text };
56917
57205
  }
56918
- #aria(field2, problem) {
56919
- const bad = problem?.field === field2;
57206
+ #aria(field3, problem) {
57207
+ const bad = problem?.field === field3;
56920
57208
  return { invalid: bad ? "true" : A, described: bad ? "error-request" : A };
56921
57209
  }
56922
57210
  async cancelRequest(request2) {
@@ -56987,7 +57275,7 @@ var SliccValueRequest = class extends ThemedElement {
56987
57275
  const shown4 = this.problem?.id === request2.id ? this.problem : null;
56988
57276
  const problem = shown4?.text ?? "";
56989
57277
  const name = this.#aria("name", shown4);
56990
- const field2 = this.#aria("value", shown4);
57278
+ const field3 = this.#aria("value", shown4);
56991
57279
  return i23(
56992
57280
  request2.id,
56993
57281
  b`<dialog role="alertdialog" aria-labelledby="title" aria-describedby="asked" data-request=${request2.id} @cancel=${(event2) => {
@@ -57003,7 +57291,7 @@ var SliccValueRequest = class extends ThemedElement {
57003
57291
  const input = event2.currentTarget;
57004
57292
  input.value = input.value.toUpperCase();
57005
57293
  }} /></label>`}
57006
- <label class="field"><span>Value</span><input type="password" autocomplete="off" spellcheck="false" data-field="value" aria-invalid=${field2.invalid} aria-describedby=${field2.described} /></label>
57294
+ <label class="field"><span>Value</span><input type="password" autocomplete="off" spellcheck="false" data-field="value" aria-invalid=${field3.invalid} aria-describedby=${field3.described} /></label>
57007
57295
  </div>` : A}
57008
57296
  ${locked ? this.#unlock(vault) : A}
57009
57297
  ${problem ? b`<p class="problem" role="alert" id="error-request" data-error><swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle><span>${problem}</span></p>` : A}
@@ -71102,10 +71390,10 @@ var ShellManager = class {
71102
71390
  this._shellElement.remove();
71103
71391
  }
71104
71392
  };
71105
- function logFailedPopout(failure2) {
71106
- if (failure2.error) console.error("dockview: failed to create popout.", failure2.error);
71107
- else if (failure2.reason === "blocked") console.error("dockview: failed to create popout. perhaps you need to allow pop-ups for this website");
71108
- else console.error(`dockview: failed to create popout (${failure2.reason}).`);
71393
+ function logFailedPopout(failure3) {
71394
+ if (failure3.error) console.error("dockview: failed to create popout.", failure3.error);
71395
+ else if (failure3.reason === "blocked") console.error("dockview: failed to create popout. perhaps you need to allow pop-ups for this website");
71396
+ else console.error(`dockview: failed to create popout (${failure3.reason}).`);
71109
71397
  }
71110
71398
  function buildTabGroupColorPalette(options2) {
71111
71399
  var _options$tabGroupColo;
@@ -71936,10 +72224,10 @@ var DockviewComponent = class extends BaseGrid {
71936
72224
  return false;
71937
72225
  }
71938
72226
  if (_window.isDisposed) {
71939
- const failure2 = _window.failure;
71940
- if (failure2 && !this.isDisposed) {
71941
- logFailedPopout(failure2);
71942
- this._onDidOpenPopoutWindowFail.fire(failure2);
72227
+ const failure3 = _window.failure;
72228
+ if (failure3 && !this.isDisposed) {
72229
+ logFailedPopout(failure3);
72230
+ this._onDidOpenPopoutWindowFail.fire(failure3);
71943
72231
  }
71944
72232
  return false;
71945
72233
  }
@@ -72132,10 +72420,10 @@ var DockviewComponent = class extends BaseGrid {
72132
72420
  * render nothing and later crash clear()/remove().
72133
72421
  */
72134
72422
  handleBlockedPopout(params) {
72135
- const { group, referenceGroup, options: options2, popoutWindowDisposable, failure: failure2 } = params;
72136
- logFailedPopout(failure2);
72423
+ const { group, referenceGroup, options: options2, popoutWindowDisposable, failure: failure3 } = params;
72424
+ logFailedPopout(failure3);
72137
72425
  popoutWindowDisposable.dispose();
72138
- this._onDidOpenPopoutWindowFail.fire(failure2);
72426
+ this._onDidOpenPopoutWindowFail.fire(failure3);
72139
72427
  if (options2 === null || options2 === void 0 ? void 0 : options2.overridePopoutGridview) {
72140
72428
  const blockedGridview = options2.overridePopoutGridview;
72141
72429
  const members = this.groups.filter((candidate) => blockedGridview.element.contains(candidate.element));