\n\t\n\t\t\n\t
\n\n\n\n\n\n","import '../assets/NcPasswordField-mhXQk8aT.css';\nimport axios from \"@nextcloud/axios\";\nimport { loadState } from \"@nextcloud/initial-state\";\nimport { generateOcsUrl } from \"@nextcloud/router\";\nimport { useVModel } from \"@vueuse/core\";\nimport debounce from \"debounce\";\nimport { n as normalizeComponent } from \"./_plugin-vue2_normalizer-DU4iP6Vu.mjs\";\nimport { N as NcInputField } from \"./NcInputField-kKgY_2GV.mjs\";\nimport { u as useModelMigration } from \"./useModelMigration-EhAWvqDD.mjs\";\nimport { r as register, D as t28, a as t } from \"./_l10n-BEfeU7gr.mjs\";\nimport { l as logger } from \"./logger-D3RVzcfQ.mjs\";\nconst _sfc_main$2 = {\n name: \"EyeIcon\",\n emits: [\"click\"],\n props: {\n title: {\n type: String\n },\n fillColor: {\n type: String,\n default: \"currentColor\"\n },\n size: {\n type: Number,\n default: 24\n }\n }\n};\nvar _sfc_render$2 = function render() {\n var _vm = this, _c = _vm._self._c;\n return _c(\"span\", _vm._b({ staticClass: \"material-design-icon eye-icon\", attrs: { \"aria-hidden\": _vm.title ? null : \"true\", \"aria-label\": _vm.title, \"role\": \"img\" }, on: { \"click\": function($event) {\n return _vm.$emit(\"click\", $event);\n } } }, \"span\", _vm.$attrs, false), [_c(\"svg\", { staticClass: \"material-design-icon__svg\", attrs: { \"fill\": _vm.fillColor, \"width\": _vm.size, \"height\": _vm.size, \"viewBox\": \"0 0 24 24\" } }, [_c(\"path\", { attrs: { \"d\": \"M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z\" } }, [_vm.title ? _c(\"title\", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]);\n};\nvar _sfc_staticRenderFns$2 = [];\nvar __component__$2 = /* @__PURE__ */ normalizeComponent(\n _sfc_main$2,\n _sfc_render$2,\n _sfc_staticRenderFns$2,\n false,\n null,\n null\n);\nconst IconEye = __component__$2.exports;\nconst _sfc_main$1 = {\n name: \"EyeOffIcon\",\n emits: [\"click\"],\n props: {\n title: {\n type: String\n },\n fillColor: {\n type: String,\n default: \"currentColor\"\n },\n size: {\n type: Number,\n default: 24\n }\n }\n};\nvar _sfc_render$1 = function render2() {\n var _vm = this, _c = _vm._self._c;\n return _c(\"span\", _vm._b({ staticClass: \"material-design-icon eye-off-icon\", attrs: { \"aria-hidden\": _vm.title ? null : \"true\", \"aria-label\": _vm.title, \"role\": \"img\" }, on: { \"click\": function($event) {\n return _vm.$emit(\"click\", $event);\n } } }, \"span\", _vm.$attrs, false), [_c(\"svg\", { staticClass: \"material-design-icon__svg\", attrs: { \"fill\": _vm.fillColor, \"width\": _vm.size, \"height\": _vm.size, \"viewBox\": \"0 0 24 24\" } }, [_c(\"path\", { attrs: { \"d\": \"M11.83,9L15,12.16C15,12.11 15,12.05 15,12A3,3 0 0,0 12,9C11.94,9 11.89,9 11.83,9M7.53,9.8L9.08,11.35C9.03,11.56 9,11.77 9,12A3,3 0 0,0 12,15C12.22,15 12.44,14.97 12.65,14.92L14.2,16.47C13.53,16.8 12.79,17 12,17A5,5 0 0,1 7,12C7,11.21 7.2,10.47 7.53,9.8M2,4.27L4.28,6.55L4.73,7C3.08,8.3 1.78,10 1,12C2.73,16.39 7,19.5 12,19.5C13.55,19.5 15.03,19.2 16.38,18.66L16.81,19.08L19.73,22L21,20.73L3.27,3M12,7A5,5 0 0,1 17,12C17,12.64 16.87,13.26 16.64,13.82L19.57,16.75C21.07,15.5 22.27,13.86 23,12C21.27,7.61 17,4.5 12,4.5C10.6,4.5 9.26,4.75 8,5.2L10.17,7.35C10.74,7.13 11.35,7 12,7Z\" } }, [_vm.title ? _c(\"title\", [_vm._v(_vm._s(_vm.title))]) : _vm._e()])])]);\n};\nvar _sfc_staticRenderFns$1 = [];\nvar __component__$1 = /* @__PURE__ */ normalizeComponent(\n _sfc_main$1,\n _sfc_render$1,\n _sfc_staticRenderFns$1,\n false,\n null,\n null\n);\nconst IconEyeOff = __component__$1.exports;\nregister(t28);\nconst passwordPolicy = loadState(\"core\", \"capabilities\", {}).password_policy || null;\nconst NcInputFieldProps = new Set(Object.keys(NcInputField.props));\nconst _sfc_main = {\n name: \"NcPasswordField\",\n components: {\n NcInputField,\n IconEye,\n IconEyeOff\n },\n // Allow forwarding all attributes\n inheritAttrs: false,\n model: {\n prop: \"modelValue\",\n event: \"update:modelValue\"\n },\n props: {\n /**\n * Any [NcInputField](#/Components/NcFields?id=ncinputfield) props\n */\n // Not an actual prop but needed to show in vue-styleguidist docs\n // eslint-disable-next-line\n \" \": {},\n // Reuse all the props from NcInputField for better typing and documentation\n ...NcInputField.props,\n // Redefined props\n /**\n * Controls whether to display the trailing button.\n */\n showTrailingButton: {\n type: Boolean,\n // eslint-disable-next-line vue/no-boolean-default\n default: true\n },\n /**\n * Removed NcInputField props, defined only by this component\n */\n trailingButtonLabel: void 0,\n // Custom props\n /**\n * Check if the user entered a valid password using the password_policy\n * app if available.\n *\n * Warning: this doesn't replace server side checking and will do nothing\n * if the password_policy app is disabled.\n */\n checkPasswordStrength: {\n type: Boolean,\n default: false\n },\n /**\n * The minlength property defines the minimum number of characters\n * (as UTF-16 code units) the user can enter\n */\n minlength: {\n type: Number,\n default: 0\n },\n /**\n * The maxlength property defines the maximum number of characters\n * (as UTF-16 code units) the user can enter\n */\n maxlength: {\n type: Number,\n default: null\n },\n /**\n * Render as input[type=text] that looks like password field.\n * Allows to avoid unwanted password-specific browser behavior,\n * such as save or generate password prompt.\n * Useful for secret token fields.\n * Note: autocomplete=\"off\" is ignored by browsers.\n */\n asText: {\n type: Boolean,\n default: false\n },\n /**\n * Visibility of the password.\n * If this is set to `true` then the password will be shown to the user (input type will be set to `text`).\n */\n visible: {\n type: Boolean,\n default: false\n }\n },\n emits: [\n \"valid\",\n \"invalid\",\n /**\n * Removed in v9 - use `update:modelValue` (`v-model`) instead\n *\n * @deprecated\n */\n \"update:value\",\n /**\n * Triggers when the value inside the password field is\n * updated.\n *\n * @property {string} The new value\n */\n \"update:modelValue\",\n /** Same as update:modelValue for Vue 2 compatibility */\n \"update:model-value\",\n /**\n * Updated visibility of the password\n *\n * @property {boolean} visible the new visibility state\n */\n \"update:visible\"\n ],\n setup(props, { emit }) {\n const model = useModelMigration(\"value\", \"update:value\");\n const visibility = useVModel(props, \"visible\", emit, { passive: true });\n return {\n t,\n model,\n visibility\n };\n },\n data() {\n return {\n internalHelpMessage: \"\",\n isValid: null\n };\n },\n computed: {\n computedError() {\n return this.error || this.isValid === false;\n },\n computedSuccess() {\n return this.success || this.isValid === true;\n },\n computedHelperText() {\n if (this.helperText.length > 0) {\n return this.helperText;\n }\n return this.internalHelpMessage;\n },\n rules() {\n const { minlength } = this;\n return {\n minlength: minlength ?? passwordPolicy?.minLength\n };\n },\n trailingButtonLabelPassword() {\n return this.visibility ? t(\"Hide password\") : t(\"Show password\");\n },\n propsAndAttrsToForward() {\n return {\n // Proxy all the HTML attributes\n ...this.$attrs,\n // Proxy original NcInputField's props\n ...Object.fromEntries(Object.entries(this.$props).filter(([key]) => NcInputFieldProps.has(key)))\n };\n }\n },\n watch: {\n model(newValue) {\n if (this.checkPasswordStrength) {\n if (passwordPolicy === null) {\n return;\n }\n this.checkPassword(newValue);\n }\n }\n },\n methods: {\n /**\n * Focus the input element\n *\n * @public\n */\n focus() {\n this.$refs.inputField.focus();\n },\n /**\n * Select all the text in the input\n *\n * @public\n */\n select() {\n this.$refs.inputField.select();\n },\n handleInput(event) {\n this.model = event.target.value;\n },\n toggleVisibility() {\n this.visibility = !this.visibility;\n },\n checkPassword: debounce(async function(password) {\n try {\n const { data } = await axios.post(generateOcsUrl(\"apps/password_policy/api/v1/validate\"), { password });\n this.isValid = data.ocs.data.passed;\n if (data.ocs.data.passed) {\n this.internalHelpMessage = t(\"Password is secure\");\n this.$emit(\"valid\");\n return;\n }\n this.internalHelpMessage = data.ocs.data.reason;\n this.$emit(\"invalid\");\n } catch (e) {\n logger.error(\"Password policy returned an error\", e);\n }\n }, 500)\n }\n};\nvar _sfc_render = function render3() {\n var _vm = this, _c = _vm._self._c;\n return _c(\"NcInputField\", _vm._g(_vm._b({ ref: \"inputField\", attrs: { \"type\": _vm.visibility || _vm.asText ? \"text\" : \"password\", \"trailing-button-label\": _vm.trailingButtonLabelPassword, \"helper-text\": _vm.computedHelperText, \"error\": _vm.computedError, \"success\": _vm.computedSuccess, \"minlength\": _vm.rules.minlength, \"input-class\": { \"password-field__input--secure-text\": !_vm.visibility && _vm.asText } }, on: { \"trailing-button-click\": _vm.toggleVisibility, \"input\": _vm.handleInput }, scopedSlots: _vm._u([!!_vm.$scopedSlots.icon || !!_vm.$slots.default || !!_vm.$scopedSlots.default ? { key: \"icon\", fn: function() {\n return [_vm._t(\"icon\", function() {\n return [_vm._t(\"default\")];\n })];\n }, proxy: true } : null, { key: \"trailing-button-icon\", fn: function() {\n return [_vm.visibility ? _c(\"IconEyeOff\", { attrs: { \"size\": 18 } }) : _c(\"IconEye\", { attrs: { \"size\": 18 } })];\n }, proxy: true }], null, true) }, \"NcInputField\", _vm.propsAndAttrsToForward, false), _vm.$listeners));\n};\nvar _sfc_staticRenderFns = [];\nvar __component__ = /* @__PURE__ */ normalizeComponent(\n _sfc_main,\n _sfc_render,\n _sfc_staticRenderFns,\n false,\n null,\n \"822eec9d\"\n);\nconst NcPasswordField = __component__.exports;\nexport {\n NcPasswordField as N\n};\n//# sourceMappingURL=NcPasswordField-9LYKS0t_.mjs.map\n","