import { useState as c } from "react";
import { s as o } from "./index-T-3isYi5.js";
function f(e) {
  const { getAppData: a, setAppData: i } = o(), [s, l] = c(() => {
    const t = a("enabled");
    if (!e.credentialOwner)
      return t ?? !1;
    const n = a("credentialId");
    return (t && (e.userCredentialIds.some((d) => d === n) || e.credentialOwner.credentialId === n)) ?? !1;
  });
  return { enabled: s, updateEnabled: (t) => {
    var n, r, d;
    t || i("credentialId", void 0), t && ((n = e.userCredentialIds) != null && n.length || (r = e.credentialOwner) != null && r.credentialId) && i("credentialId", ((d = e.credentialOwner) == null ? void 0 : d.credentialId) || e.userCredentialIds[0]), l(t);
  } };
}
export {
  f as u
};
