@ohhwells/bridge 0.1.179-next.476 → 0.1.179-next.478
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/index.cjs +289 -255
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +289 -255
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -19621,260 +19621,6 @@ function ItemInteractionLayer({
|
|
|
19621
19621
|
);
|
|
19622
19622
|
}
|
|
19623
19623
|
|
|
19624
|
-
// src/lib/forms.ts
|
|
19625
|
-
var FORM_SELECTOR2 = '[data-ohw-editable="form"]';
|
|
19626
|
-
function getFormElement(el) {
|
|
19627
|
-
if (!el) return null;
|
|
19628
|
-
return el.closest(FORM_SELECTOR2);
|
|
19629
|
-
}
|
|
19630
|
-
function formKeyOf(form) {
|
|
19631
|
-
return form.getAttribute("data-ohw-key");
|
|
19632
|
-
}
|
|
19633
|
-
function formHasLongText(form) {
|
|
19634
|
-
return form.querySelector("textarea") !== null;
|
|
19635
|
-
}
|
|
19636
|
-
function collectFormFields(form) {
|
|
19637
|
-
const fields = {};
|
|
19638
|
-
form.querySelectorAll(
|
|
19639
|
-
"input, textarea, select"
|
|
19640
|
-
).forEach((input) => {
|
|
19641
|
-
const type = input.type;
|
|
19642
|
-
if (type === "submit" || type === "button" || type === "reset") return;
|
|
19643
|
-
const key = input.getAttribute("name") ?? input.getAttribute("data-ohw-key");
|
|
19644
|
-
if (!key) return;
|
|
19645
|
-
if (type === "checkbox") {
|
|
19646
|
-
fields[key] = input.checked ? "yes" : "no";
|
|
19647
|
-
return;
|
|
19648
|
-
}
|
|
19649
|
-
fields[key] = input.value;
|
|
19650
|
-
});
|
|
19651
|
-
return fields;
|
|
19652
|
-
}
|
|
19653
|
-
function formStateContainer(form) {
|
|
19654
|
-
return form.closest("[data-ohw-editable-state]") ?? form.parentElement ?? form;
|
|
19655
|
-
}
|
|
19656
|
-
function showSuccess(form, message) {
|
|
19657
|
-
const container = formStateContainer(form);
|
|
19658
|
-
const views = container.querySelectorAll("[data-ohw-state-view]");
|
|
19659
|
-
if (views.length > 0) {
|
|
19660
|
-
views.forEach((view) => {
|
|
19661
|
-
view.style.display = view.getAttribute("data-ohw-state-view") === "success" ? "block" : "none";
|
|
19662
|
-
});
|
|
19663
|
-
return;
|
|
19664
|
-
}
|
|
19665
|
-
const text = message || form.getAttribute("data-ohw-success-text") || DEFAULT_SUCCESS_TEXT;
|
|
19666
|
-
const note = document.createElement("p");
|
|
19667
|
-
note.setAttribute("data-ohw-form-success", "");
|
|
19668
|
-
note.setAttribute("role", "status");
|
|
19669
|
-
note.innerHTML = text;
|
|
19670
|
-
form.replaceChildren(note);
|
|
19671
|
-
}
|
|
19672
|
-
function showSubmitError(form, message = "Something went wrong. Please try again.") {
|
|
19673
|
-
let note = form.querySelector("[data-ohw-form-error]");
|
|
19674
|
-
if (!note) {
|
|
19675
|
-
note = document.createElement("p");
|
|
19676
|
-
note.setAttribute("data-ohw-form-error", "");
|
|
19677
|
-
note.setAttribute("role", "alert");
|
|
19678
|
-
note.style.marginTop = "8px";
|
|
19679
|
-
form.appendChild(note);
|
|
19680
|
-
}
|
|
19681
|
-
note.textContent = message;
|
|
19682
|
-
note.style.display = "";
|
|
19683
|
-
}
|
|
19684
|
-
function clearSubmitError(form) {
|
|
19685
|
-
const note = form.querySelector("[data-ohw-form-error]");
|
|
19686
|
-
if (note) note.style.display = "none";
|
|
19687
|
-
}
|
|
19688
|
-
var SUCCESS_TEXT_ATTR = "data-ohw-form-success-text";
|
|
19689
|
-
var HIDDEN_ATTR4 = "data-ohw-form-hidden";
|
|
19690
|
-
var DEFAULT_SUCCESS_TEXT = "Thanks! We'll be in touch.";
|
|
19691
|
-
function formSuccessKey(formKey) {
|
|
19692
|
-
return `${formKey}-success`;
|
|
19693
|
-
}
|
|
19694
|
-
function ensureSuccessTextEl(form, formKey, initialText) {
|
|
19695
|
-
let el = form.querySelector(`[${SUCCESS_TEXT_ATTR}]`);
|
|
19696
|
-
if (el) return el;
|
|
19697
|
-
el = document.createElement("p");
|
|
19698
|
-
el.setAttribute(SUCCESS_TEXT_ATTR, "");
|
|
19699
|
-
el.setAttribute("data-ohw-editable", "text");
|
|
19700
|
-
el.setAttribute("data-ohw-key", formSuccessKey(formKey));
|
|
19701
|
-
el.innerHTML = initialText;
|
|
19702
|
-
el.style.display = "none";
|
|
19703
|
-
el.style.margin = "56px 4px 16px";
|
|
19704
|
-
form.appendChild(el);
|
|
19705
|
-
return el;
|
|
19706
|
-
}
|
|
19707
|
-
function successInitialFor(form, formKey, content) {
|
|
19708
|
-
return content[formSuccessKey(formKey)] || form.getAttribute("data-ohw-success-text") || DEFAULT_SUCCESS_TEXT;
|
|
19709
|
-
}
|
|
19710
|
-
function setFormViewState(form, formKey, state, initialText) {
|
|
19711
|
-
const success = ensureSuccessTextEl(form, formKey, initialText);
|
|
19712
|
-
Array.from(form.children).forEach((child) => {
|
|
19713
|
-
if (!(child instanceof HTMLElement) || child === success) return;
|
|
19714
|
-
if (state === "success") {
|
|
19715
|
-
if (!child.hasAttribute(HIDDEN_ATTR4)) {
|
|
19716
|
-
child.setAttribute(HIDDEN_ATTR4, child.style.display);
|
|
19717
|
-
child.style.display = "none";
|
|
19718
|
-
}
|
|
19719
|
-
} else if (child.hasAttribute(HIDDEN_ATTR4)) {
|
|
19720
|
-
child.style.display = child.getAttribute(HIDDEN_ATTR4) ?? "";
|
|
19721
|
-
child.removeAttribute(HIDDEN_ATTR4);
|
|
19722
|
-
}
|
|
19723
|
-
});
|
|
19724
|
-
success.style.display = state === "success" ? "" : "none";
|
|
19725
|
-
}
|
|
19726
|
-
var BOUND_ATTR = "data-ohw-form-bound";
|
|
19727
|
-
var publishedFormContext = {
|
|
19728
|
-
apiUrl: "",
|
|
19729
|
-
subdomain: "",
|
|
19730
|
-
content: {}
|
|
19731
|
-
};
|
|
19732
|
-
function bindPublishedForms(apiUrl, subdomain, content = {}) {
|
|
19733
|
-
publishedFormContext = { apiUrl, subdomain, content };
|
|
19734
|
-
if (document.documentElement.hasAttribute(BOUND_ATTR)) return;
|
|
19735
|
-
document.documentElement.setAttribute(BOUND_ATTR, "");
|
|
19736
|
-
document.addEventListener(
|
|
19737
|
-
"submit",
|
|
19738
|
-
async (e) => {
|
|
19739
|
-
const target = e.target;
|
|
19740
|
-
const form = target?.closest(FORM_SELECTOR2);
|
|
19741
|
-
if (!form || !(form instanceof HTMLFormElement)) return;
|
|
19742
|
-
const formKey = formKeyOf(form);
|
|
19743
|
-
if (!formKey) return;
|
|
19744
|
-
e.preventDefault();
|
|
19745
|
-
clearSubmitError(form);
|
|
19746
|
-
const filled = collectFormFields(form);
|
|
19747
|
-
if (!Object.values(filled).some((value) => value.trim() !== "")) {
|
|
19748
|
-
showSubmitError(form, "Please fill in at least one field.");
|
|
19749
|
-
return;
|
|
19750
|
-
}
|
|
19751
|
-
const submitButton = form.querySelector(
|
|
19752
|
-
'button[type="submit"], input[type="submit"], button:not([type])'
|
|
19753
|
-
);
|
|
19754
|
-
if (submitButton) submitButton.disabled = true;
|
|
19755
|
-
try {
|
|
19756
|
-
const { apiUrl: api, subdomain: site, content: latest } = publishedFormContext;
|
|
19757
|
-
const response = await fetch(`${api}/api/public/sites/${site}/forms/submissions`, {
|
|
19758
|
-
method: "POST",
|
|
19759
|
-
headers: { "Content-Type": "application/json" },
|
|
19760
|
-
body: JSON.stringify({
|
|
19761
|
-
formKey,
|
|
19762
|
-
fields: filled,
|
|
19763
|
-
hasLongText: formHasLongText(form)
|
|
19764
|
-
})
|
|
19765
|
-
});
|
|
19766
|
-
if (!response.ok) throw new Error(`submit failed: ${response.status}`);
|
|
19767
|
-
showSuccess(form, latest[formSuccessKey(formKey)]);
|
|
19768
|
-
} catch {
|
|
19769
|
-
showSubmitError(form);
|
|
19770
|
-
if (submitButton) submitButton.disabled = false;
|
|
19771
|
-
}
|
|
19772
|
-
},
|
|
19773
|
-
true
|
|
19774
|
-
);
|
|
19775
|
-
}
|
|
19776
|
-
|
|
19777
|
-
// src/lib/outage-beacon.ts
|
|
19778
|
-
var DEDUP_MS = 5 * 60 * 1e3;
|
|
19779
|
-
var lastSent = /* @__PURE__ */ new Map();
|
|
19780
|
-
function apiBase() {
|
|
19781
|
-
return process.env.NEXT_PUBLIC_FLOWOPS_API_URL ?? "https://flowops-backend-staging-2yfdh7pwpq-as.a.run.app";
|
|
19782
|
-
}
|
|
19783
|
-
function bridgeVersion() {
|
|
19784
|
-
try {
|
|
19785
|
-
if (true) {
|
|
19786
|
-
return "0.1.179-next.476";
|
|
19787
|
-
}
|
|
19788
|
-
} catch {
|
|
19789
|
-
}
|
|
19790
|
-
if (typeof document !== "undefined") {
|
|
19791
|
-
return document.documentElement.getAttribute("data-ohw-bridge-version") || void 0;
|
|
19792
|
-
}
|
|
19793
|
-
return void 0;
|
|
19794
|
-
}
|
|
19795
|
-
function stampBridgeVersionOnDocument() {
|
|
19796
|
-
if (typeof document === "undefined") {
|
|
19797
|
-
return;
|
|
19798
|
-
}
|
|
19799
|
-
try {
|
|
19800
|
-
const v = true ? "0.1.179-next.476" : "";
|
|
19801
|
-
if (v) {
|
|
19802
|
-
document.documentElement.setAttribute("data-ohw-bridge-version", v);
|
|
19803
|
-
window.__OHW_BRIDGE_VERSION__ = v;
|
|
19804
|
-
}
|
|
19805
|
-
} catch {
|
|
19806
|
-
}
|
|
19807
|
-
}
|
|
19808
|
-
var TRANSIENT_CONTENT_FETCH = /^(Failed to fetch|Load failed|NetworkError when attempting to fetch resource\.?|fetch failed|The user aborted a request\.?|The operation was aborted\.?)$/i;
|
|
19809
|
-
var RECOVERABLE_PAGE_ERROR = /Minified React error #(?:418|419|421|422|423|425)\b|Hydration failed because the initial UI does not match|Text content does not match server-rendered HTML|There was an error while hydrating|did not match\. Server:/i;
|
|
19810
|
-
function isVercelPreviewHost() {
|
|
19811
|
-
if (typeof location === "undefined") {
|
|
19812
|
-
return false;
|
|
19813
|
-
}
|
|
19814
|
-
return location.hostname.toLowerCase().endsWith(".vercel.ohhwells.site");
|
|
19815
|
-
}
|
|
19816
|
-
function reportOutageBeacon(args) {
|
|
19817
|
-
if (typeof window === "undefined" || !args.subdomain) {
|
|
19818
|
-
return;
|
|
19819
|
-
}
|
|
19820
|
-
if (isVercelPreviewHost()) {
|
|
19821
|
-
return;
|
|
19822
|
-
}
|
|
19823
|
-
if (args.reason === "page_error" && args.detail && RECOVERABLE_PAGE_ERROR.test(args.detail)) {
|
|
19824
|
-
return;
|
|
19825
|
-
}
|
|
19826
|
-
if (args.reason === "content_fetch_failed" && args.detail && TRANSIENT_CONTENT_FETCH.test(args.detail.trim())) {
|
|
19827
|
-
return;
|
|
19828
|
-
}
|
|
19829
|
-
const key = `${args.subdomain}|${args.reason}`;
|
|
19830
|
-
const now = Date.now();
|
|
19831
|
-
const prev = lastSent.get(key) || 0;
|
|
19832
|
-
if (now - prev < DEDUP_MS) {
|
|
19833
|
-
return;
|
|
19834
|
-
}
|
|
19835
|
-
lastSent.set(key, now);
|
|
19836
|
-
const body = JSON.stringify({
|
|
19837
|
-
subdomain: args.subdomain,
|
|
19838
|
-
reason: args.reason,
|
|
19839
|
-
detail: args.detail?.slice(0, 300),
|
|
19840
|
-
templateId: args.templateId,
|
|
19841
|
-
bridgeVersion: bridgeVersion(),
|
|
19842
|
-
href: typeof location !== "undefined" ? location.href : void 0
|
|
19843
|
-
});
|
|
19844
|
-
const url = `${apiBase()}/api/public/sites/outage-beacon`;
|
|
19845
|
-
try {
|
|
19846
|
-
if (typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function") {
|
|
19847
|
-
const blob = new Blob([body], { type: "application/json" });
|
|
19848
|
-
if (navigator.sendBeacon(url, blob)) {
|
|
19849
|
-
return;
|
|
19850
|
-
}
|
|
19851
|
-
}
|
|
19852
|
-
void fetch(url, {
|
|
19853
|
-
method: "POST",
|
|
19854
|
-
headers: { "Content-Type": "application/json" },
|
|
19855
|
-
body,
|
|
19856
|
-
keepalive: true,
|
|
19857
|
-
cache: "no-store"
|
|
19858
|
-
}).catch(() => {
|
|
19859
|
-
});
|
|
19860
|
-
} catch {
|
|
19861
|
-
}
|
|
19862
|
-
}
|
|
19863
|
-
function armLoaderHangBeacon(subdomain, fetchState, hangMs = 15e3) {
|
|
19864
|
-
if (!subdomain || fetchState !== "loading") {
|
|
19865
|
-
return () => {
|
|
19866
|
-
};
|
|
19867
|
-
}
|
|
19868
|
-
const timer = window.setTimeout(() => {
|
|
19869
|
-
reportOutageBeacon({
|
|
19870
|
-
subdomain,
|
|
19871
|
-
reason: "loader_stuck",
|
|
19872
|
-
detail: `fetchState still loading after ${hangMs}ms`
|
|
19873
|
-
});
|
|
19874
|
-
}, hangMs);
|
|
19875
|
-
return () => window.clearTimeout(timer);
|
|
19876
|
-
}
|
|
19877
|
-
|
|
19878
19624
|
// src/lib/form-fields.ts
|
|
19879
19625
|
var DEFAULT_DROPDOWN_OPTIONS = ["Option 1", "Option 2", "Option 3"];
|
|
19880
19626
|
var FIELD_DEFAULTS = {
|
|
@@ -20527,6 +20273,294 @@ function reconcileFieldsFromContent(form, content) {
|
|
|
20527
20273
|
}
|
|
20528
20274
|
}
|
|
20529
20275
|
|
|
20276
|
+
// src/lib/forms.ts
|
|
20277
|
+
var FORM_SELECTOR2 = '[data-ohw-editable="form"]';
|
|
20278
|
+
function getFormElement(el) {
|
|
20279
|
+
if (!el) return null;
|
|
20280
|
+
return el.closest(FORM_SELECTOR2);
|
|
20281
|
+
}
|
|
20282
|
+
function formKeyOf(form) {
|
|
20283
|
+
return form.getAttribute("data-ohw-key");
|
|
20284
|
+
}
|
|
20285
|
+
function formHasLongText(form) {
|
|
20286
|
+
return form.querySelector("textarea") !== null;
|
|
20287
|
+
}
|
|
20288
|
+
function submissionColumnKey(label, fallback, used) {
|
|
20289
|
+
const base = (label.trim() || fallback.trim() || "field").slice(0, 128);
|
|
20290
|
+
if (!used.has(base)) {
|
|
20291
|
+
used.add(base);
|
|
20292
|
+
return base;
|
|
20293
|
+
}
|
|
20294
|
+
let n = 2;
|
|
20295
|
+
while (n < 1e3) {
|
|
20296
|
+
const candidate = `${base} ${n}`.slice(0, 128);
|
|
20297
|
+
if (!used.has(candidate)) {
|
|
20298
|
+
used.add(candidate);
|
|
20299
|
+
return candidate;
|
|
20300
|
+
}
|
|
20301
|
+
n += 1;
|
|
20302
|
+
}
|
|
20303
|
+
used.add(fallback);
|
|
20304
|
+
return fallback;
|
|
20305
|
+
}
|
|
20306
|
+
function collectFormFields(form) {
|
|
20307
|
+
const fields = {};
|
|
20308
|
+
const used = /* @__PURE__ */ new Set();
|
|
20309
|
+
const wrappers = listFieldWrappers(form);
|
|
20310
|
+
if (wrappers.length > 0) {
|
|
20311
|
+
wrappers.forEach((wrapper) => {
|
|
20312
|
+
const input = fieldControlOf(wrapper);
|
|
20313
|
+
if (!input) return;
|
|
20314
|
+
const type = input.type;
|
|
20315
|
+
if (type === "submit" || type === "button" || type === "reset") return;
|
|
20316
|
+
const fallback = input.getAttribute("name") ?? fieldKeyOf(wrapper) ?? input.getAttribute("data-ohw-key") ?? "";
|
|
20317
|
+
if (!fallback && !fieldLabelOf(wrapper)) return;
|
|
20318
|
+
const key = submissionColumnKey(fieldLabelText(fieldLabelOf(wrapper)), fallback, used);
|
|
20319
|
+
fields[key] = type === "checkbox" ? input.checked ? "yes" : "no" : input.value;
|
|
20320
|
+
});
|
|
20321
|
+
return fields;
|
|
20322
|
+
}
|
|
20323
|
+
form.querySelectorAll(
|
|
20324
|
+
"input, textarea, select"
|
|
20325
|
+
).forEach((input) => {
|
|
20326
|
+
const type = input.type;
|
|
20327
|
+
if (type === "submit" || type === "button" || type === "reset") return;
|
|
20328
|
+
const key = input.getAttribute("name") ?? input.getAttribute("data-ohw-key");
|
|
20329
|
+
if (!key) return;
|
|
20330
|
+
const column = submissionColumnKey(key, key, used);
|
|
20331
|
+
if (type === "checkbox") {
|
|
20332
|
+
fields[column] = input.checked ? "yes" : "no";
|
|
20333
|
+
return;
|
|
20334
|
+
}
|
|
20335
|
+
fields[column] = input.value;
|
|
20336
|
+
});
|
|
20337
|
+
return fields;
|
|
20338
|
+
}
|
|
20339
|
+
function formStateContainer(form) {
|
|
20340
|
+
return form.closest("[data-ohw-editable-state]") ?? form.parentElement ?? form;
|
|
20341
|
+
}
|
|
20342
|
+
function showSuccess(form, message) {
|
|
20343
|
+
const container = formStateContainer(form);
|
|
20344
|
+
const views = container.querySelectorAll("[data-ohw-state-view]");
|
|
20345
|
+
if (views.length > 0) {
|
|
20346
|
+
views.forEach((view) => {
|
|
20347
|
+
view.style.display = view.getAttribute("data-ohw-state-view") === "success" ? "block" : "none";
|
|
20348
|
+
});
|
|
20349
|
+
return;
|
|
20350
|
+
}
|
|
20351
|
+
const text = message || form.getAttribute("data-ohw-success-text") || DEFAULT_SUCCESS_TEXT;
|
|
20352
|
+
const note = document.createElement("p");
|
|
20353
|
+
note.setAttribute("data-ohw-form-success", "");
|
|
20354
|
+
note.setAttribute("role", "status");
|
|
20355
|
+
note.innerHTML = text;
|
|
20356
|
+
form.replaceChildren(note);
|
|
20357
|
+
}
|
|
20358
|
+
function showSubmitError(form, message = "Something went wrong. Please try again.") {
|
|
20359
|
+
let note = form.querySelector("[data-ohw-form-error]");
|
|
20360
|
+
if (!note) {
|
|
20361
|
+
note = document.createElement("p");
|
|
20362
|
+
note.setAttribute("data-ohw-form-error", "");
|
|
20363
|
+
note.setAttribute("role", "alert");
|
|
20364
|
+
note.style.marginTop = "8px";
|
|
20365
|
+
form.appendChild(note);
|
|
20366
|
+
}
|
|
20367
|
+
note.textContent = message;
|
|
20368
|
+
note.style.display = "";
|
|
20369
|
+
}
|
|
20370
|
+
function clearSubmitError(form) {
|
|
20371
|
+
const note = form.querySelector("[data-ohw-form-error]");
|
|
20372
|
+
if (note) note.style.display = "none";
|
|
20373
|
+
}
|
|
20374
|
+
var SUCCESS_TEXT_ATTR = "data-ohw-form-success-text";
|
|
20375
|
+
var HIDDEN_ATTR4 = "data-ohw-form-hidden";
|
|
20376
|
+
var DEFAULT_SUCCESS_TEXT = "Thanks! We'll be in touch.";
|
|
20377
|
+
function formSuccessKey(formKey) {
|
|
20378
|
+
return `${formKey}-success`;
|
|
20379
|
+
}
|
|
20380
|
+
function ensureSuccessTextEl(form, formKey, initialText) {
|
|
20381
|
+
let el = form.querySelector(`[${SUCCESS_TEXT_ATTR}]`);
|
|
20382
|
+
if (el) return el;
|
|
20383
|
+
el = document.createElement("p");
|
|
20384
|
+
el.setAttribute(SUCCESS_TEXT_ATTR, "");
|
|
20385
|
+
el.setAttribute("data-ohw-editable", "text");
|
|
20386
|
+
el.setAttribute("data-ohw-key", formSuccessKey(formKey));
|
|
20387
|
+
el.innerHTML = initialText;
|
|
20388
|
+
el.style.display = "none";
|
|
20389
|
+
el.style.margin = "56px 4px 16px";
|
|
20390
|
+
form.appendChild(el);
|
|
20391
|
+
return el;
|
|
20392
|
+
}
|
|
20393
|
+
function successInitialFor(form, formKey, content) {
|
|
20394
|
+
return content[formSuccessKey(formKey)] || form.getAttribute("data-ohw-success-text") || DEFAULT_SUCCESS_TEXT;
|
|
20395
|
+
}
|
|
20396
|
+
function setFormViewState(form, formKey, state, initialText) {
|
|
20397
|
+
const success = ensureSuccessTextEl(form, formKey, initialText);
|
|
20398
|
+
Array.from(form.children).forEach((child) => {
|
|
20399
|
+
if (!(child instanceof HTMLElement) || child === success) return;
|
|
20400
|
+
if (state === "success") {
|
|
20401
|
+
if (!child.hasAttribute(HIDDEN_ATTR4)) {
|
|
20402
|
+
child.setAttribute(HIDDEN_ATTR4, child.style.display);
|
|
20403
|
+
child.style.display = "none";
|
|
20404
|
+
}
|
|
20405
|
+
} else if (child.hasAttribute(HIDDEN_ATTR4)) {
|
|
20406
|
+
child.style.display = child.getAttribute(HIDDEN_ATTR4) ?? "";
|
|
20407
|
+
child.removeAttribute(HIDDEN_ATTR4);
|
|
20408
|
+
}
|
|
20409
|
+
});
|
|
20410
|
+
success.style.display = state === "success" ? "" : "none";
|
|
20411
|
+
}
|
|
20412
|
+
var BOUND_ATTR = "data-ohw-form-bound";
|
|
20413
|
+
var publishedFormContext = {
|
|
20414
|
+
apiUrl: "",
|
|
20415
|
+
subdomain: "",
|
|
20416
|
+
content: {}
|
|
20417
|
+
};
|
|
20418
|
+
function bindPublishedForms(apiUrl, subdomain, content = {}) {
|
|
20419
|
+
publishedFormContext = { apiUrl, subdomain, content };
|
|
20420
|
+
if (document.documentElement.hasAttribute(BOUND_ATTR)) return;
|
|
20421
|
+
document.documentElement.setAttribute(BOUND_ATTR, "");
|
|
20422
|
+
document.addEventListener(
|
|
20423
|
+
"submit",
|
|
20424
|
+
async (e) => {
|
|
20425
|
+
const target = e.target;
|
|
20426
|
+
const form = target?.closest(FORM_SELECTOR2);
|
|
20427
|
+
if (!form || !(form instanceof HTMLFormElement)) return;
|
|
20428
|
+
const formKey = formKeyOf(form);
|
|
20429
|
+
if (!formKey) return;
|
|
20430
|
+
e.preventDefault();
|
|
20431
|
+
clearSubmitError(form);
|
|
20432
|
+
const filled = collectFormFields(form);
|
|
20433
|
+
if (!Object.values(filled).some((value) => value.trim() !== "")) {
|
|
20434
|
+
showSubmitError(form, "Please fill in at least one field.");
|
|
20435
|
+
return;
|
|
20436
|
+
}
|
|
20437
|
+
const submitButton = form.querySelector(
|
|
20438
|
+
'button[type="submit"], input[type="submit"], button:not([type])'
|
|
20439
|
+
);
|
|
20440
|
+
if (submitButton) submitButton.disabled = true;
|
|
20441
|
+
try {
|
|
20442
|
+
const { apiUrl: api, subdomain: site, content: latest } = publishedFormContext;
|
|
20443
|
+
const response = await fetch(`${api}/api/public/sites/${site}/forms/submissions`, {
|
|
20444
|
+
method: "POST",
|
|
20445
|
+
headers: { "Content-Type": "application/json" },
|
|
20446
|
+
body: JSON.stringify({
|
|
20447
|
+
formKey,
|
|
20448
|
+
fields: filled,
|
|
20449
|
+
hasLongText: formHasLongText(form)
|
|
20450
|
+
})
|
|
20451
|
+
});
|
|
20452
|
+
if (!response.ok) throw new Error(`submit failed: ${response.status}`);
|
|
20453
|
+
showSuccess(form, latest[formSuccessKey(formKey)]);
|
|
20454
|
+
} catch {
|
|
20455
|
+
showSubmitError(form);
|
|
20456
|
+
if (submitButton) submitButton.disabled = false;
|
|
20457
|
+
}
|
|
20458
|
+
},
|
|
20459
|
+
true
|
|
20460
|
+
);
|
|
20461
|
+
}
|
|
20462
|
+
|
|
20463
|
+
// src/lib/outage-beacon.ts
|
|
20464
|
+
var DEDUP_MS = 5 * 60 * 1e3;
|
|
20465
|
+
var lastSent = /* @__PURE__ */ new Map();
|
|
20466
|
+
function apiBase() {
|
|
20467
|
+
return process.env.NEXT_PUBLIC_FLOWOPS_API_URL ?? "https://flowops-backend-staging-2yfdh7pwpq-as.a.run.app";
|
|
20468
|
+
}
|
|
20469
|
+
function bridgeVersion() {
|
|
20470
|
+
try {
|
|
20471
|
+
if (true) {
|
|
20472
|
+
return "0.1.179-next.478";
|
|
20473
|
+
}
|
|
20474
|
+
} catch {
|
|
20475
|
+
}
|
|
20476
|
+
if (typeof document !== "undefined") {
|
|
20477
|
+
return document.documentElement.getAttribute("data-ohw-bridge-version") || void 0;
|
|
20478
|
+
}
|
|
20479
|
+
return void 0;
|
|
20480
|
+
}
|
|
20481
|
+
function stampBridgeVersionOnDocument() {
|
|
20482
|
+
if (typeof document === "undefined") {
|
|
20483
|
+
return;
|
|
20484
|
+
}
|
|
20485
|
+
try {
|
|
20486
|
+
const v = true ? "0.1.179-next.478" : "";
|
|
20487
|
+
if (v) {
|
|
20488
|
+
document.documentElement.setAttribute("data-ohw-bridge-version", v);
|
|
20489
|
+
window.__OHW_BRIDGE_VERSION__ = v;
|
|
20490
|
+
}
|
|
20491
|
+
} catch {
|
|
20492
|
+
}
|
|
20493
|
+
}
|
|
20494
|
+
var TRANSIENT_CONTENT_FETCH = /^(Failed to fetch|Load failed|NetworkError when attempting to fetch resource\.?|fetch failed|The user aborted a request\.?|The operation was aborted\.?)$/i;
|
|
20495
|
+
var RECOVERABLE_PAGE_ERROR = /Minified React error #(?:418|419|421|422|423|425)\b|Hydration failed because the initial UI does not match|Text content does not match server-rendered HTML|There was an error while hydrating|did not match\. Server:/i;
|
|
20496
|
+
function isVercelPreviewHost() {
|
|
20497
|
+
if (typeof location === "undefined") {
|
|
20498
|
+
return false;
|
|
20499
|
+
}
|
|
20500
|
+
return location.hostname.toLowerCase().endsWith(".vercel.ohhwells.site");
|
|
20501
|
+
}
|
|
20502
|
+
function reportOutageBeacon(args) {
|
|
20503
|
+
if (typeof window === "undefined" || !args.subdomain) {
|
|
20504
|
+
return;
|
|
20505
|
+
}
|
|
20506
|
+
if (isVercelPreviewHost()) {
|
|
20507
|
+
return;
|
|
20508
|
+
}
|
|
20509
|
+
if (args.reason === "page_error" && args.detail && RECOVERABLE_PAGE_ERROR.test(args.detail)) {
|
|
20510
|
+
return;
|
|
20511
|
+
}
|
|
20512
|
+
if (args.reason === "content_fetch_failed" && args.detail && TRANSIENT_CONTENT_FETCH.test(args.detail.trim())) {
|
|
20513
|
+
return;
|
|
20514
|
+
}
|
|
20515
|
+
const key = `${args.subdomain}|${args.reason}`;
|
|
20516
|
+
const now = Date.now();
|
|
20517
|
+
const prev = lastSent.get(key) || 0;
|
|
20518
|
+
if (now - prev < DEDUP_MS) {
|
|
20519
|
+
return;
|
|
20520
|
+
}
|
|
20521
|
+
lastSent.set(key, now);
|
|
20522
|
+
const body = JSON.stringify({
|
|
20523
|
+
subdomain: args.subdomain,
|
|
20524
|
+
reason: args.reason,
|
|
20525
|
+
detail: args.detail?.slice(0, 300),
|
|
20526
|
+
templateId: args.templateId,
|
|
20527
|
+
bridgeVersion: bridgeVersion(),
|
|
20528
|
+
href: typeof location !== "undefined" ? location.href : void 0
|
|
20529
|
+
});
|
|
20530
|
+
const url = `${apiBase()}/api/public/sites/outage-beacon`;
|
|
20531
|
+
try {
|
|
20532
|
+
if (typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function") {
|
|
20533
|
+
const blob = new Blob([body], { type: "application/json" });
|
|
20534
|
+
if (navigator.sendBeacon(url, blob)) {
|
|
20535
|
+
return;
|
|
20536
|
+
}
|
|
20537
|
+
}
|
|
20538
|
+
void fetch(url, {
|
|
20539
|
+
method: "POST",
|
|
20540
|
+
headers: { "Content-Type": "application/json" },
|
|
20541
|
+
body,
|
|
20542
|
+
keepalive: true,
|
|
20543
|
+
cache: "no-store"
|
|
20544
|
+
}).catch(() => {
|
|
20545
|
+
});
|
|
20546
|
+
} catch {
|
|
20547
|
+
}
|
|
20548
|
+
}
|
|
20549
|
+
function armLoaderHangBeacon(subdomain, fetchState, hangMs = 15e3) {
|
|
20550
|
+
if (!subdomain || fetchState !== "loading") {
|
|
20551
|
+
return () => {
|
|
20552
|
+
};
|
|
20553
|
+
}
|
|
20554
|
+
const timer = window.setTimeout(() => {
|
|
20555
|
+
reportOutageBeacon({
|
|
20556
|
+
subdomain,
|
|
20557
|
+
reason: "loader_stuck",
|
|
20558
|
+
detail: `fetchState still loading after ${hangMs}ms`
|
|
20559
|
+
});
|
|
20560
|
+
}, hangMs);
|
|
20561
|
+
return () => window.clearTimeout(timer);
|
|
20562
|
+
}
|
|
20563
|
+
|
|
20530
20564
|
// src/ui/form-field-toolbar.tsx
|
|
20531
20565
|
var import_lucide_react5 = require("lucide-react");
|
|
20532
20566
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
@@ -35737,7 +35771,7 @@ function OhhwellsBridge() {
|
|
|
35737
35771
|
postToParent2({
|
|
35738
35772
|
type: "ow:ready",
|
|
35739
35773
|
version: "1",
|
|
35740
|
-
bridgeVersion: "0.1.179-next.
|
|
35774
|
+
bridgeVersion: "0.1.179-next.478",
|
|
35741
35775
|
path: pathname,
|
|
35742
35776
|
nodes: collectEditableNodes(editContentRef.current),
|
|
35743
35777
|
sections
|