function ScoreInputs() {
  var DU = window.DULIUS || {};
  var si = (DU.settings && DU.settings.scoreInputs) || {};
  var seed = function () {
    return {
      monthlyRevenue: si.monthlyRevenue != null ? si.monthlyRevenue : "",
      founded: si.founded || "",
      creditRange: si.creditRange || "",
      currentPositions: si.currentPositions != null ? si.currentPositions : "",
      monthlyDebt: si.monthlyDebt != null ? si.monthlyDebt : ""
    };
  };
  var _a = React.useState(seed()); var form = _a[0], setForm = _a[1];
  var _b = React.useState(false); var open = _b[0], setOpen = _b[1];
  var _c = React.useState(""); var status = _c[0], setStatus = _c[1];
  var set = function (k, v) { setForm(function (f) { var n = Object.assign({}, f); n[k] = v; return n; }); };
  var fieldStyle = { display: "flex", flexDirection: "column", gap: "5px", fontSize: "13px", fontWeight: 600, color: "#243b30" };
  var inputStyle = { padding: "9px 11px", border: "1px solid #d9e2dc", borderRadius: "9px", fontSize: "14px", fontWeight: 500, fontFamily: "inherit", background: "#fff" };
  var save = function () {
    setStatus("saving");
    var num = function (v) { if (v === "" || v == null) return null; var n = parseFloat(String(v).replace(/[^0-9.]/g, "")); return isFinite(n) ? n : null; };
    var payload = { monthlyRevenue: num(form.monthlyRevenue), founded: form.founded || null, creditRange: form.creditRange || null, currentPositions: num(form.currentPositions), monthlyDebt: num(form.monthlyDebt) };
    if (window.duliusSaveScoreInputs) {
      Promise.resolve(window.duliusSaveScoreInputs(payload)).then(function (ok) { setStatus(ok ? "saved" : "error"); if (ok) setTimeout(function () { setStatus(""); }, 1600); });
    } else { setStatus("error"); }
  };
  return (
    <div className="dpanel" style={{ marginBottom: "16px" }}>
      <div className="dpanel-head dpadx" style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-start", gap: "12px" }}>
        <div>
          <h3 className="ds-h3">Refine your score</h3>
          <p className="dmuted" style={{ margin: "3px 0 0", fontSize: "13px" }}>Add a few details to sharpen your estimate. Connect your bank later to verify.</p>
        </div>
        <button onClick={function () { setForm(seed()); setStatus(""); setOpen(!open); }} style={{ padding: "8px 14px", border: "1px solid #cdd8d1", borderRadius: "9px", background: "#fff", fontWeight: 600, fontSize: "13px", cursor: "pointer", whiteSpace: "nowrap" }}>{open ? "Close" : "Update inputs"}</button>
      </div>
      {open ? (
        <div style={{ padding: "6px 18px 18px" }}>
          <div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))", gap: "13px" }}>
            <label style={fieldStyle}><span>Monthly revenue</span><input style={inputStyle} type="text" value={form.monthlyRevenue} onChange={function (e) { set("monthlyRevenue", e.target.value); }} placeholder="e.g. 35,000" /></label>
            <label style={fieldStyle}><span>Year founded</span><input style={inputStyle} type="text" value={form.founded} onChange={function (e) { set("founded", e.target.value); }} placeholder="e.g. 2019" /></label>
            <label style={fieldStyle}><span>Personal credit range</span>
              <select style={inputStyle} value={form.creditRange} onChange={function (e) { set("creditRange", e.target.value); }}>
                <option value="">Select...</option>
                <option value="800-850">Excellent (800+)</option>
                <option value="740-799">Very good (740-799)</option>
                <option value="700-739">Good (700-739)</option>
                <option value="660-699">Fair (660-699)</option>
                <option value="620-659">Building (620-659)</option>
                <option value="580-619">Poor (580-619)</option>
                <option value="300-579">Under 580</option>
              </select>
            </label>
            <label style={fieldStyle}><span>Current advances / positions</span><input style={inputStyle} type="number" min="0" value={form.currentPositions} onChange={function (e) { set("currentPositions", e.target.value); }} placeholder="e.g. 1" /></label>
            <label style={fieldStyle}><span>Monthly debt payments</span><input style={inputStyle} type="text" value={form.monthlyDebt} onChange={function (e) { set("monthlyDebt", e.target.value); }} placeholder="e.g. 2,500" /></label>
          </div>
          <div style={{ marginTop: "15px", display: "flex", gap: "12px", alignItems: "center" }}>
            <button onClick={save} disabled={status === "saving"} style={{ padding: "10px 18px", background: "#1a7f4b", color: "#fff", border: "none", borderRadius: "10px", fontWeight: 600, fontSize: "14px", cursor: status === "saving" ? "default" : "pointer", opacity: status === "saving" ? 0.7 : 1 }}>{status === "saving" ? "Saving..." : "Save & recalculate"}</button>
            {status === "saved" ? <span style={{ color: "#1a7f4b", fontWeight: 600, fontSize: "13px" }}>Score updated</span> : null}
            {status === "error" ? <span style={{ color: "#c0392b", fontWeight: 600, fontSize: "13px" }}>Couldn't save</span> : null}
          </div>
        </div>
      ) : null}
    </div>
  );
}
window.ScoreInputs = ScoreInputs;
