import { a as __unplugin_components_0$1 } from './chunk-6003391e.js'; import { NCheckbox, NForm, NFormItem, NColorPicker } from 'naive-ui'; import { _ as __unplugin_components_3 } from './chunk-4e7a6a8d.js'; import { _ as __unplugin_components_0 } from './chunk-89a4876c.js'; import { a as __unplugin_components_1 } from './chunk-8109fd17.js'; import { ref, watch, isRef, defineComponent, withCtx, unref, createTextVNode, createVNode, openBlock, createBlock, createCommentVNode, useSSRContext } from 'vue'; import { ssrRenderComponent, ssrRenderAttr } from 'vue/server-renderer'; import { get } from '@vueuse/core'; import QRCode from 'qrcode'; import { u as useDownloadFileFromBase64 } from './chunk-cce4ae69.js'; import 'pinia'; import './chunk-11f44f81.js'; import './chunk-35c3d701.js'; import 'lodash'; import './chunk-bb5bb4f6.js'; import './chunk-2ce6ed5e.js'; import 'fuse.js'; import 'mime-types'; const EAPMethods = [ "MD5", "POTP", "GTC", "TLS", "IKEv2", "SIM", "AKA", "AKA'", "TTLS", "PWD", "LEAP", "PSK", "FAST", "TEAP", "EKE", "NOOB", "PEAP" ]; const EAPPhase2Methods = [ "None", "MSCHAPV2" ]; function escapeString(str) { return str.replace(/([\\;,:"])/g, "\\$1"); } function getQrCodeText(options) { const { ssid, password, encryption, eapMethod, isHiddenSSID, eapAnonymous, eapIdentity, eapPhase2Method } = options; if (!ssid) { return null; } if (encryption === "nopass") { return `WIFI:S:${escapeString(ssid)};;`; } if (encryption !== "WPA2-EAP" && password) { return `WIFI:S:${escapeString(ssid)};T:${encryption};P:${escapeString(password)};${isHiddenSSID ? "H:true" : ""};`; } if (encryption === "WPA2-EAP" && password && eapMethod) { if (!eapIdentity && !eapAnonymous) { return null; } if (eapMethod === "PEAP" && !eapPhase2Method) { return null; } const identity = eapAnonymous ? "A:anon" : `I:${escapeString(eapIdentity)}`; const phase2 = eapPhase2Method !== "None" ? `PH2:${eapPhase2Method};` : ""; return `WIFI:S:${escapeString(ssid)};T:WPA2-EAP;P:${escapeString(password)};E:${eapMethod};${phase2}${identity};${isHiddenSSID ? "H:true" : ""};`; } return null; } function useWifiQRCode({ ssid, password, eapMethod, isHiddenSSID, eapAnonymous, eapIdentity, eapPhase2Method, color: { background, foreground }, options }) { const qrcode = ref(""); const encryption = ref("WPA"); watch( [ssid, password, encryption, eapMethod, isHiddenSSID, eapAnonymous, eapIdentity, eapPhase2Method, background, foreground].filter(isRef), async () => { const text = getQrCodeText({ ssid: get(ssid), password: get(password), encryption: get(encryption), eapMethod: get(eapMethod), isHiddenSSID: get(isHiddenSSID), eapAnonymous: get(eapAnonymous), eapIdentity: get(eapIdentity), eapPhase2Method: get(eapPhase2Method) }); if (text) { qrcode.value = await QRCode.toDataURL(get(text).trim(), { color: { dark: get(foreground), light: get(background), ...options?.color }, errorCorrectionLevel: "M", ...options }); } }, { immediate: true } ); return { qrcode, encryption }; } const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "wifi-qr-code-generator", __ssrInlineRender: true, setup(__props) { const foreground = ref("#000000ff"); const background = ref("#ffffffff"); const ssid = ref(); const password = ref(); const eapMethod = ref(); const isHiddenSSID = ref(false); const eapAnonymous = ref(false); const eapIdentity = ref(); const eapPhase2Method = ref(); const { qrcode, encryption } = useWifiQRCode({ ssid, password, eapMethod, isHiddenSSID, eapAnonymous, eapIdentity, eapPhase2Method, color: { background, foreground }, options: { width: 1024 } }); const { download } = useDownloadFileFromBase64({ source: qrcode, filename: "qr-code.png" }); return (_ctx, _push, _parent, _attrs) => { const _component_c_card = __unplugin_components_1; const _component_c_select = __unplugin_components_0; const _component_c_input_text = __unplugin_components_3; const _component_n_checkbox = NCheckbox; const _component_n_form = NForm; const _component_n_form_item = NFormItem; const _component_n_color_picker = NColorPicker; const _component_c_button = __unplugin_components_0$1; _push(ssrRenderComponent(_component_c_card, _attrs, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(`