import { H as t, I as o, j as e, ae as n, K as a, v as l, Q as s, a5 as c, ao as i, c as r, ad as u, bc as d, J as m, an as f, a0 as B, bd as g, a3 as b, aw as p, ax as h, ag as C, aK as v, be as w, bf as y, aO as x, bg as k, bh as S, al as D, X as T, aL as O, aM as H, } from "./index-476be0bb.js"; import { B as j } from "./index-97676c1f.js"; import { u as A } from "./use-placeholder-8391a3e3.js"; import { a as P, u as z } from "./use-route-126c4f06.js"; const [I, K] = t("action-bar"), N = Symbol(I); const U = s( o({ name: I, props: { placeholder: Boolean, safeAreaInsetBottom: a }, setup(t, { slots: o }) { const a = e(), s = A(a, K), { linkChildren: c } = n(N); c(); const i = () => { var e; return l( "div", { ref: a, class: [K(), { "van-safe-area-bottom": t.safeAreaInsetBottom }], }, [null == (e = o.default) ? void 0 : e.call(o)] ); }; return () => (t.placeholder ? s(i) : i()); }, }) ), [E, F] = t("action-bar-button"); const L = s( o({ name: E, props: c({}, P, { type: String, text: String, icon: String, color: String, loading: Boolean, disabled: Boolean, }), setup(t, { slots: o }) { const e = z(), { parent: n, index: a } = i(N), s = r(() => { if (n) { const t = n.children[a.value - 1]; return !(t && "isButton" in t); } }), c = r(() => { if (n) { const t = n.children[a.value + 1]; return !(t && "isButton" in t); } }); return ( u({ isButton: !0 }), () => { const { type: n, icon: a, text: i, color: r, loading: u, disabled: d, } = t; return l( j, { class: F([n, { last: c.value, first: s.value }]), size: "large", type: n, icon: a, color: r, loading: u, disabled: d, onClick: e, }, { default: () => [o.default ? o.default() : i] } ); } ); }, }) ), [M, Q, J] = t("dialog"), R = c({}, d, { title: String, theme: String, width: m, message: [String, Function], callback: Function, allowHtml: Boolean, className: f, transition: B("van-dialog-bounce"), messageAlign: String, closeOnPopstate: a, showCancelButton: Boolean, cancelButtonText: String, cancelButtonColor: String, cancelButtonDisabled: Boolean, confirmButtonText: String, confirmButtonColor: String, confirmButtonDisabled: Boolean, showConfirmButton: a, closeOnClickOverlay: Boolean, }), V = [...g, "transition", "closeOnPopstate"]; var X = o({ name: M, props: R, emits: ["confirm", "cancel", "keydown", "update:show"], setup(t, { emit: o, slots: n }) { const a = e(), s = b({ confirm: !1, cancel: !1 }), c = (t) => o("update:show", t), i = (o) => { var e; c(!1), null == (e = t.callback) || e.call(t, o); }, r = (e) => () => { t.show && (o(e), t.beforeClose ? ((s[e] = !0), D(t.beforeClose, { args: [e], done() { i(e), (s[e] = !1); }, canceled() { s[e] = !1; }, })) : i(e)); }, u = r("cancel"), d = r("confirm"), m = w( (e) => { var n, l; if ( e.target !== (null == (l = null == (n = a.value) ? void 0 : n.popupRef) ? void 0 : l.value) ) return; ({ Enter: t.showConfirmButton ? d : y, Escape: t.showCancelButton ? u : y, })[e.key](), o("keydown", e); }, ["enter", "esc"] ), f = () => { const o = n.title ? n.title() : t.title; if (o) return l( "div", { class: Q("header", { isolated: !t.message && !n.default }) }, [o] ); }, B = (o) => { const { message: e, allowHtml: n, messageAlign: a } = t, s = Q("message", { "has-title": o, [a]: a }), c = x(e) ? e() : e; return n && "string" == typeof c ? l("div", { class: s, innerHTML: c }, null) : l("div", { class: s }, [c]); }, g = () => { if (n.default) return l("div", { class: Q("content") }, [n.default()]); const { title: o, message: e, allowHtml: a } = t; if (e) { const t = !(!o && !n.title); return l( "div", { key: a ? 1 : 0, class: Q("content", { isolated: !t }) }, [B(t)] ); } }, T = () => n.footer ? n.footer() : "round-button" === t.theme ? l( U, { class: Q("footer") }, { default: () => [ t.showCancelButton && l( L, { type: "warning", text: t.cancelButtonText || J("cancel"), class: Q("cancel"), color: t.cancelButtonColor, loading: s.cancel, disabled: t.cancelButtonDisabled, onClick: u, }, null ), t.showConfirmButton && l( L, { type: "danger", text: t.confirmButtonText || J("confirm"), class: Q("confirm"), color: t.confirmButtonColor, loading: s.confirm, disabled: t.confirmButtonDisabled, onClick: d, }, null ), ], } ) : l("div", { class: [S, Q("footer")] }, [ t.showCancelButton && l( j, { size: "large", text: t.cancelButtonText || J("cancel"), class: Q("cancel"), style: { color: t.cancelButtonColor }, loading: s.cancel, disabled: t.cancelButtonDisabled, onClick: u, }, null ), t.showConfirmButton && l( j, { size: "large", text: t.confirmButtonText || J("confirm"), class: [Q("confirm"), { [k]: t.showCancelButton }], style: { color: t.confirmButtonColor }, loading: s.confirm, disabled: t.confirmButtonDisabled, onClick: d, }, null ), ]); return () => { const { width: o, title: e, theme: n, message: s, className: i } = t; return l( v, p( { ref: a, role: "dialog", class: [Q([n]), i], style: { width: C(o) }, tabindex: 0, "aria-labelledby": e || s, onKeydown: m, "onUpdate:show": c, }, h(t, V) ), { default: () => [f(), g(), T()] } ); }; }, }); let q; let G = c( {}, { title: "", width: "", theme: null, message: "", overlay: !0, callback: null, teleport: "body", className: "", allowHtml: !1, lockScroll: !0, transition: void 0, beforeClose: null, overlayClass: "", overlayStyle: void 0, messageAlign: "", cancelButtonText: "", cancelButtonColor: null, cancelButtonDisabled: !1, confirmButtonText: "", confirmButtonColor: null, confirmButtonDisabled: !1, showConfirmButton: !0, showCancelButton: !1, closeOnPopstate: !0, closeOnClickOverlay: !1, } ); function W(t) { return T ? new Promise((o, e) => { q || (function () { const t = { setup() { const { state: t, toggle: o } = H(); return () => l(X, p(t, { "onUpdate:show": o }), null); }, }; ({ instance: q } = O(t)); })(), q.open( c({}, G, t, { callback: (t) => { ("confirm" === t ? o : e)(t); }, }) ); }) : Promise.resolve(); } const Y = (t) => W(c({ showCancelButton: !0 }, t)), Z = s(X); export { Z as D, W as a, Y as s };