{"version":3,"file":"sweetalert2-preset.mjs","sources":["../src/index.ts"],"sourcesContent":["import Swal from 'sweetalert2'\nimport type { SweetAlertOptions } from 'sweetalert2'\n\nfunction success(options: string | SweetAlertOptions) {\n  if (!options) {\n    console.error('Options is required.')\n    return\n  }\n\n  const Options = typeof options === 'string' ? { titleText: options } : options\n\n  return Swal.fire({\n    icon: 'success',\n    toast: true,\n    timer: 2000,\n    didOpen: (toast) => {\n      toast.addEventListener('mouseenter', Swal.stopTimer)\n      toast.addEventListener('mouseleave', Swal.resumeTimer)\n    },\n    position: 'top',\n    showConfirmButton: false,\n    ...Options,\n  })\n}\n\nfunction info(options: string | SweetAlertOptions) {\n  if (!options) {\n    console.error('Options is required.')\n    return\n  }\n\n  const Options = typeof options === 'string' ? { titleText: options } : options\n\n  return Swal.fire({\n    icon: 'info',\n    toast: true,\n    timer: 3000,\n    timerProgressBar: true,\n    didOpen: (toast) => {\n      toast.addEventListener('mouseenter', Swal.stopTimer)\n      toast.addEventListener('mouseleave', Swal.resumeTimer)\n    },\n    showConfirmButton: false,\n    ...Options,\n  })\n}\n\nfunction warning(options: string | SweetAlertOptions) {\n  if (!options) {\n    console.error('Options is required.')\n    return\n  }\n\n  const Options = typeof options === 'string' ? { titleText: options } : options\n\n  return Swal.fire({\n    icon: 'warning',\n    backdrop: false,\n    confirmButtonColor: '#66b1ff',\n    timer: 5000,\n    timerProgressBar: true,\n    didOpen: (toast) => {\n      toast.addEventListener('mouseenter', Swal.stopTimer)\n      toast.addEventListener('mouseleave', Swal.resumeTimer)\n    },\n    ...Options,\n  })\n}\n\nfunction error(options: string | SweetAlertOptions) {\n  if (!options) {\n    console.error('Options is required.')\n    return\n  }\n\n  const Options = typeof options === 'string' ? { titleText: options } : options\n\n  // timer 不为0时才会触发 Promise.resolve\n  return Swal.fire({\n    icon: 'error',\n    allowOutsideClick: false,\n    confirmButtonColor: '#66b1ff',\n    ...Options,\n  })\n}\n\nfunction confirm(options: string | SweetAlertOptions) {\n  if (!options) {\n    console.error('Options is required.')\n    return\n  }\n\n  const Options = typeof options === 'string' ? { titleText: options } : options\n\n  return new Promise((resolve, reject) => {\n    Swal.fire({\n      icon: 'question',\n      confirmButtonColor: '#66b1ff',\n      showCancelButton: true,\n      reverseButtons: true,\n      allowOutsideClick: false,\n      ...Options,\n    }).then((e: any) => {\n      e.isConfirmed ? resolve(e) : reject(e)\n    })\n  })\n}\n\nexport default { success, warning, info, error, confirm }\n"],"names":["success","options","Options","Swal","toast","info","warning","error","confirm","resolve","reject","e","index"],"mappings":";AAGA,SAASA,EAAQC,GAAqC;AACpD,MAAI,CAACA,GAAS;AACZ,YAAQ,MAAM,sBAAsB;AACpC;AAAA,EACF;AAEA,QAAMC,IAAU,OAAOD,KAAY,WAAW,EAAE,WAAWA,EAAY,IAAAA;AAEvE,SAAOE,EAAK,KAAK;AAAA,IACf,MAAM;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS,CAACC,MAAU;AACZ,MAAAA,EAAA,iBAAiB,cAAcD,EAAK,SAAS,GAC7CC,EAAA,iBAAiB,cAAcD,EAAK,WAAW;AAAA,IACvD;AAAA,IACA,UAAU;AAAA,IACV,mBAAmB;AAAA,IACnB,GAAGD;AAAA,EAAA,CACJ;AACH;AAEA,SAASG,EAAKJ,GAAqC;AACjD,MAAI,CAACA,GAAS;AACZ,YAAQ,MAAM,sBAAsB;AACpC;AAAA,EACF;AAEA,QAAMC,IAAU,OAAOD,KAAY,WAAW,EAAE,WAAWA,EAAY,IAAAA;AAEvE,SAAOE,EAAK,KAAK;AAAA,IACf,MAAM;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,IACP,kBAAkB;AAAA,IAClB,SAAS,CAACC,MAAU;AACZ,MAAAA,EAAA,iBAAiB,cAAcD,EAAK,SAAS,GAC7CC,EAAA,iBAAiB,cAAcD,EAAK,WAAW;AAAA,IACvD;AAAA,IACA,mBAAmB;AAAA,IACnB,GAAGD;AAAA,EAAA,CACJ;AACH;A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