"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.loadScript = void 0;
const loadScript = _ref => {
  let {
    id,
    name,
    onLoad = () => {}
  } = _ref;
  const exists = document.getElementById(id);
  if (!exists) {
    const script = document.createElement('script');
    script.id = id;
    script.src = "".concat(process.env.SERVICE_STATIC, "/payments/scripts/").concat(name);
    script.onload = onLoad;
    document.head.appendChild(script);
  }
  return () => {
    const el = document.getElementById(id);
    if (el) el.parentNode.removeChild(el);
  };
};
exports.loadScript = loadScript;
//# sourceMappingURL=loadScript.js.map