@factoringplus/pl-components-pack-v3 0.1.7 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +43 -24
  2. package/dist/CNAME +1 -0
  3. package/dist/element-plus-logo-small.svg +1 -0
  4. package/dist/favicon.svg +1 -0
  5. package/dist/pl-components-pack-v3.es.js +2599 -0
  6. package/dist/pl-components-pack-v3.umd.js +13 -0
  7. package/dist/style.css +1 -0
  8. package/package.json +46 -69
  9. package/.browserslistrc +0 -3
  10. package/.editorconfig +0 -7
  11. package/.eslintrc.js +0 -17
  12. package/.storybook/main.js +0 -30
  13. package/.storybook/preview.js +0 -15
  14. package/babel.config.js +0 -5
  15. package/build/rollup.config.js +0 -38
  16. package/entry.js +0 -37
  17. package/public/favicon.ico +0 -0
  18. package/public/index.html +0 -17
  19. package/src/App.vue +0 -6
  20. package/src/assets/logo.png +0 -0
  21. package/src/components/pl-currency/src/pl-currency.vue +0 -47
  22. package/src/main.js +0 -13
  23. package/src/router/index.js +0 -16
  24. package/src/store/index.js +0 -12
  25. package/src/stories/Button.stories.js +0 -52
  26. package/src/stories/Button.vue +0 -53
  27. package/src/stories/Header.stories.js +0 -28
  28. package/src/stories/Header.vue +0 -54
  29. package/src/stories/Introduction.stories.mdx +0 -211
  30. package/src/stories/Page.stories.js +0 -30
  31. package/src/stories/Page.vue +0 -79
  32. package/src/stories/assets/code-brackets.svg +0 -1
  33. package/src/stories/assets/colors.svg +0 -1
  34. package/src/stories/assets/comments.svg +0 -1
  35. package/src/stories/assets/direction.svg +0 -1
  36. package/src/stories/assets/flow.svg +0 -1
  37. package/src/stories/assets/plugin.svg +0 -1
  38. package/src/stories/assets/repo.svg +0 -1
  39. package/src/stories/assets/stackalt.svg +0 -1
  40. package/src/stories/button.css +0 -30
  41. package/src/stories/currency-input/pl-currency.stories.js +0 -27
  42. package/src/stories/currency-input/pl-currency.vue +0 -47
  43. package/src/stories/header.css +0 -26
  44. package/src/stories/page.css +0 -69
  45. package/src/views/Home.vue +0 -10
  46. package/vue.config.js +0 -3
@@ -0,0 +1,2599 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { defineComponent, openBlock, createElementBlock, createElementVNode, warn, getCurrentInstance, computed, ref, inject, unref, mergeProps, renderSlot, shallowRef, watch, nextTick, onMounted, onUpdated, resolveComponent, withDirectives, normalizeClass, normalizeStyle, createCommentVNode, Fragment, createBlock, withCtx, resolveDynamicComponent, withModifiers, createVNode, toDisplayString, vShow, useSlots, Text, provide, reactive, toRef, createTextVNode, onUnmounted } from "vue";
21
+ function fromPairs(pairs) {
22
+ var index = -1, length = pairs == null ? 0 : pairs.length, result = {};
23
+ while (++index < length) {
24
+ var pair = pairs[index];
25
+ result[pair[0]] = pair[1];
26
+ }
27
+ return result;
28
+ }
29
+ const isClient = typeof window !== "undefined";
30
+ const isNumber = (val) => typeof val === "number";
31
+ const NOOP = () => {
32
+ };
33
+ const hasOwnProperty = Object.prototype.hasOwnProperty;
34
+ const hasOwn = (val, key) => hasOwnProperty.call(val, key);
35
+ const isString = (val) => typeof val === "string";
36
+ const isObject = (val) => val !== null && typeof val === "object";
37
+ const isUndefined = (val) => val === void 0;
38
+ var _export_sfc$1 = (sfc, props) => {
39
+ const target = sfc.__vccOpts || sfc;
40
+ for (const [key, val] of props) {
41
+ target[key] = val;
42
+ }
43
+ return target;
44
+ };
45
+ const _sfc_main$9 = defineComponent({
46
+ name: "CircleCheck"
47
+ });
48
+ const _hoisted_1$7 = {
49
+ class: "icon",
50
+ width: "200",
51
+ height: "200",
52
+ viewBox: "0 0 1024 1024",
53
+ xmlns: "http://www.w3.org/2000/svg"
54
+ };
55
+ const _hoisted_2$5 = /* @__PURE__ */ createElementVNode("path", {
56
+ fill: "currentColor",
57
+ d: "M512 896a384 384 0 100-768 384 384 0 000 768zm0 64a448 448 0 110-896 448 448 0 010 896z"
58
+ }, null, -1);
59
+ const _hoisted_3$3 = /* @__PURE__ */ createElementVNode("path", {
60
+ fill: "currentColor",
61
+ d: "M745.344 361.344a32 32 0 0145.312 45.312l-288 288a32 32 0 01-45.312 0l-160-160a32 32 0 1145.312-45.312L480 626.752l265.344-265.408z"
62
+ }, null, -1);
63
+ const _hoisted_4$1 = [
64
+ _hoisted_2$5,
65
+ _hoisted_3$3
66
+ ];
67
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
68
+ return openBlock(), createElementBlock("svg", _hoisted_1$7, _hoisted_4$1);
69
+ }
70
+ var circleCheck = /* @__PURE__ */ _export_sfc$1(_sfc_main$9, [["render", _sfc_render$4]]);
71
+ const _sfc_main$8 = defineComponent({
72
+ name: "CircleClose"
73
+ });
74
+ const _hoisted_1$6 = {
75
+ class: "icon",
76
+ width: "200",
77
+ height: "200",
78
+ viewBox: "0 0 1024 1024",
79
+ xmlns: "http://www.w3.org/2000/svg"
80
+ };
81
+ const _hoisted_2$4 = /* @__PURE__ */ createElementVNode("path", {
82
+ fill: "currentColor",
83
+ d: "M466.752 512l-90.496-90.496a32 32 0 0145.248-45.248L512 466.752l90.496-90.496a32 32 0 1145.248 45.248L557.248 512l90.496 90.496a32 32 0 11-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 01-45.248-45.248L466.752 512z"
84
+ }, null, -1);
85
+ const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("path", {
86
+ fill: "currentColor",
87
+ d: "M512 896a384 384 0 100-768 384 384 0 000 768zm0 64a448 448 0 110-896 448 448 0 010 896z"
88
+ }, null, -1);
89
+ const _hoisted_4 = [
90
+ _hoisted_2$4,
91
+ _hoisted_3$2
92
+ ];
93
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
94
+ return openBlock(), createElementBlock("svg", _hoisted_1$6, _hoisted_4);
95
+ }
96
+ var circleClose = /* @__PURE__ */ _export_sfc$1(_sfc_main$8, [["render", _sfc_render$3]]);
97
+ const _sfc_main$7 = defineComponent({
98
+ name: "Loading"
99
+ });
100
+ const _hoisted_1$5 = {
101
+ class: "icon",
102
+ width: "200",
103
+ height: "200",
104
+ viewBox: "0 0 1024 1024",
105
+ xmlns: "http://www.w3.org/2000/svg"
106
+ };
107
+ const _hoisted_2$3 = /* @__PURE__ */ createElementVNode("path", {
108
+ fill: "currentColor",
109
+ d: "M512 64a32 32 0 0132 32v192a32 32 0 01-64 0V96a32 32 0 0132-32zm0 640a32 32 0 0132 32v192a32 32 0 11-64 0V736a32 32 0 0132-32zm448-192a32 32 0 01-32 32H736a32 32 0 110-64h192a32 32 0 0132 32zm-640 0a32 32 0 01-32 32H96a32 32 0 010-64h192a32 32 0 0132 32zM195.2 195.2a32 32 0 0145.248 0L376.32 331.008a32 32 0 01-45.248 45.248L195.2 240.448a32 32 0 010-45.248zm452.544 452.544a32 32 0 0145.248 0L828.8 783.552a32 32 0 01-45.248 45.248L647.744 692.992a32 32 0 010-45.248zM828.8 195.264a32 32 0 010 45.184L692.992 376.32a32 32 0 01-45.248-45.248l135.808-135.808a32 32 0 0145.248 0zm-452.544 452.48a32 32 0 010 45.248L240.448 828.8a32 32 0 01-45.248-45.248l135.808-135.808a32 32 0 0145.248 0z"
110
+ }, null, -1);
111
+ const _hoisted_3$1 = [
112
+ _hoisted_2$3
113
+ ];
114
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
115
+ return openBlock(), createElementBlock("svg", _hoisted_1$5, _hoisted_3$1);
116
+ }
117
+ var loading = /* @__PURE__ */ _export_sfc$1(_sfc_main$7, [["render", _sfc_render$2]]);
118
+ const _sfc_main$6 = defineComponent({
119
+ name: "View"
120
+ });
121
+ const _hoisted_1$4 = {
122
+ class: "icon",
123
+ width: "200",
124
+ height: "200",
125
+ viewBox: "0 0 1024 1024",
126
+ xmlns: "http://www.w3.org/2000/svg"
127
+ };
128
+ const _hoisted_2$2 = /* @__PURE__ */ createElementVNode("path", {
129
+ fill: "currentColor",
130
+ d: "M512 160c320 0 512 352 512 352S832 864 512 864 0 512 0 512s192-352 512-352zm0 64c-225.28 0-384.128 208.064-436.8 288 52.608 79.872 211.456 288 436.8 288 225.28 0 384.128-208.064 436.8-288-52.608-79.872-211.456-288-436.8-288zm0 64a224 224 0 110 448 224 224 0 010-448zm0 64a160.192 160.192 0 00-160 160c0 88.192 71.744 160 160 160s160-71.808 160-160-71.744-160-160-160z"
131
+ }, null, -1);
132
+ const _hoisted_3 = [
133
+ _hoisted_2$2
134
+ ];
135
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
136
+ return openBlock(), createElementBlock("svg", _hoisted_1$4, _hoisted_3);
137
+ }
138
+ var view = /* @__PURE__ */ _export_sfc$1(_sfc_main$6, [["render", _sfc_render$1]]);
139
+ const wrapperKey = Symbol();
140
+ const propKey = "__elPropsReservedKey";
141
+ function buildProp(option, key) {
142
+ if (!isObject(option) || !!option[propKey])
143
+ return option;
144
+ const { values, required, default: defaultValue, type, validator } = option;
145
+ const _validator = values || validator ? (val) => {
146
+ let valid = false;
147
+ let allowedValues = [];
148
+ if (values) {
149
+ allowedValues = Array.from(values);
150
+ if (hasOwn(option, "default")) {
151
+ allowedValues.push(defaultValue);
152
+ }
153
+ valid || (valid = allowedValues.includes(val));
154
+ }
155
+ if (validator)
156
+ valid || (valid = validator(val));
157
+ if (!valid && allowedValues.length > 0) {
158
+ const allowValuesText = [...new Set(allowedValues)].map((value) => JSON.stringify(value)).join(", ");
159
+ warn(`Invalid prop: validation failed${key ? ` for prop "${key}"` : ""}. Expected one of [${allowValuesText}], got value ${JSON.stringify(val)}.`);
160
+ }
161
+ return valid;
162
+ } : void 0;
163
+ const prop = {
164
+ type: isObject(type) && Object.getOwnPropertySymbols(type).includes(wrapperKey) ? type[wrapperKey] : type,
165
+ required: !!required,
166
+ validator: _validator,
167
+ [propKey]: true
168
+ };
169
+ if (hasOwn(option, "default"))
170
+ prop.default = defaultValue;
171
+ return prop;
172
+ }
173
+ const buildProps = (props) => fromPairs(Object.entries(props).map(([key, option]) => [
174
+ key,
175
+ buildProp(option, key)
176
+ ]));
177
+ const definePropType = (val) => ({ [wrapperKey]: val });
178
+ const iconPropType = definePropType([
179
+ String,
180
+ Object,
181
+ Function
182
+ ]);
183
+ const ValidateComponentsMap = {
184
+ validating: loading,
185
+ success: circleCheck,
186
+ error: circleClose
187
+ };
188
+ const withInstall = (main, extra) => {
189
+ main.install = (app) => {
190
+ for (const comp of [main, ...Object.values(extra != null ? extra : {})]) {
191
+ app.component(comp.name, comp);
192
+ }
193
+ };
194
+ if (extra) {
195
+ for (const [key, comp] of Object.entries(extra)) {
196
+ main[key] = comp;
197
+ }
198
+ }
199
+ return main;
200
+ };
201
+ const withNoopInstall = (component) => {
202
+ component.install = NOOP;
203
+ return component;
204
+ };
205
+ function addUnit(value, defaultUnit = "px") {
206
+ if (!value)
207
+ return "";
208
+ if (isString(value)) {
209
+ return value;
210
+ } else if (isNumber(value)) {
211
+ return `${value}${defaultUnit}`;
212
+ }
213
+ }
214
+ const UPDATE_MODEL_EVENT = "update:modelValue";
215
+ const componentSizes = ["default", "small", "large"];
216
+ const isKorean = (text) => /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi.test(text);
217
+ const mutable = (val) => val;
218
+ const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
219
+ const LISTENER_PREFIX = /^on[A-Z]/;
220
+ const useAttrs = (params = {}) => {
221
+ const { excludeListeners = false, excludeKeys = [] } = params;
222
+ const allExcludeKeys = excludeKeys.concat(DEFAULT_EXCLUDE_KEYS);
223
+ const instance = getCurrentInstance();
224
+ if (!instance) {
225
+ return computed(() => ({}));
226
+ }
227
+ return computed(() => {
228
+ var _a;
229
+ return fromPairs(Object.entries((_a = instance.proxy) == null ? void 0 : _a.$attrs).filter(([key]) => !allExcludeKeys.includes(key) && !(excludeListeners && LISTENER_PREFIX.test(key))));
230
+ });
231
+ };
232
+ const elFormKey = Symbol("elForm");
233
+ const elFormItemKey = Symbol("elFormItem");
234
+ const buttonGroupContextKey = Symbol("buttonGroupContextKey");
235
+ const configProviderContextKey = Symbol();
236
+ const useProp = (name) => {
237
+ const vm = getCurrentInstance();
238
+ return computed(() => {
239
+ var _a, _b;
240
+ return (_b = (_a = vm.proxy) == null ? void 0 : _a.$props[name]) != null ? _b : void 0;
241
+ });
242
+ };
243
+ const globalConfig = ref();
244
+ function useGlobalConfig(key, defaultValue = void 0) {
245
+ const config = getCurrentInstance() ? inject(configProviderContextKey, globalConfig) : globalConfig;
246
+ if (key) {
247
+ return computed(() => {
248
+ var _a, _b;
249
+ return (_b = (_a = config.value) == null ? void 0 : _a[key]) != null ? _b : defaultValue;
250
+ });
251
+ } else {
252
+ return config;
253
+ }
254
+ }
255
+ const useSizeProp = buildProp({
256
+ type: String,
257
+ values: componentSizes,
258
+ required: false
259
+ });
260
+ const useSize = (fallback, ignore = {}) => {
261
+ const emptyRef = ref(void 0);
262
+ const size = ignore.prop ? emptyRef : useProp("size");
263
+ const globalConfig2 = ignore.global ? emptyRef : useGlobalConfig("size");
264
+ const form = ignore.form ? { size: void 0 } : inject(elFormKey, void 0);
265
+ const formItem = ignore.formItem ? { size: void 0 } : inject(elFormItemKey, void 0);
266
+ return computed(() => size.value || unref(fallback) || (formItem == null ? void 0 : formItem.size) || (form == null ? void 0 : form.size) || globalConfig2.value || "default");
267
+ };
268
+ const useDisabled = (fallback) => {
269
+ const disabled = useProp("disabled");
270
+ const form = inject(elFormKey, void 0);
271
+ return computed(() => disabled.value || unref(fallback) || (form == null ? void 0 : form.disabled) || false);
272
+ };
273
+ const useFormItem = () => {
274
+ const form = inject(elFormKey, void 0);
275
+ const formItem = inject(elFormItemKey, void 0);
276
+ return {
277
+ form,
278
+ formItem
279
+ };
280
+ };
281
+ const defaultNamespace = "el";
282
+ const statePrefix = "is-";
283
+ const _bem = (namespace, block, blockSuffix, element, modifier) => {
284
+ let cls = `${namespace}-${block}`;
285
+ if (blockSuffix) {
286
+ cls += `-${blockSuffix}`;
287
+ }
288
+ if (element) {
289
+ cls += `__${element}`;
290
+ }
291
+ if (modifier) {
292
+ cls += `--${modifier}`;
293
+ }
294
+ return cls;
295
+ };
296
+ const useNamespace = (block) => {
297
+ const globalConfig2 = useGlobalConfig("namespace");
298
+ const namespace = computed(() => globalConfig2.value || defaultNamespace);
299
+ const b = (blockSuffix = "") => _bem(unref(namespace), block, blockSuffix, "", "");
300
+ const e = (element) => element ? _bem(unref(namespace), block, "", element, "") : "";
301
+ const m = (modifier) => modifier ? _bem(unref(namespace), block, "", "", modifier) : "";
302
+ const be = (blockSuffix, element) => blockSuffix && element ? _bem(unref(namespace), block, blockSuffix, element, "") : "";
303
+ const em = (element, modifier) => element && modifier ? _bem(unref(namespace), block, "", element, modifier) : "";
304
+ const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(unref(namespace), block, blockSuffix, "", modifier) : "";
305
+ const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(unref(namespace), block, blockSuffix, element, modifier) : "";
306
+ const is = (name, ...args) => {
307
+ const state = args.length >= 1 ? args[0] : true;
308
+ return name && state ? `${statePrefix}${name}` : "";
309
+ };
310
+ return {
311
+ namespace,
312
+ b,
313
+ e,
314
+ m,
315
+ be,
316
+ em,
317
+ bm,
318
+ bem,
319
+ is
320
+ };
321
+ };
322
+ const iconProps = buildProps({
323
+ size: {
324
+ type: definePropType([Number, String])
325
+ },
326
+ color: {
327
+ type: String
328
+ }
329
+ });
330
+ const __default__$4 = {
331
+ name: "ElIcon",
332
+ inheritAttrs: false
333
+ };
334
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$4), {
335
+ props: iconProps,
336
+ setup(__props) {
337
+ const props = __props;
338
+ const ns = useNamespace("icon");
339
+ const style = computed(() => {
340
+ if (!props.size && !props.color)
341
+ return {};
342
+ return {
343
+ fontSize: isUndefined(props.size) ? void 0 : addUnit(props.size),
344
+ "--color": props.color
345
+ };
346
+ });
347
+ return (_ctx, _cache) => {
348
+ return openBlock(), createElementBlock("i", mergeProps({
349
+ class: unref(ns).b(),
350
+ style: unref(style)
351
+ }, _ctx.$attrs), [
352
+ renderSlot(_ctx.$slots, "default")
353
+ ], 16);
354
+ };
355
+ }
356
+ }));
357
+ const ElIcon = withInstall(_sfc_main$5);
358
+ let hiddenTextarea = void 0;
359
+ const HIDDEN_STYLE = `
360
+ height:0 !important;
361
+ visibility:hidden !important;
362
+ overflow:hidden !important;
363
+ position:absolute !important;
364
+ z-index:-1000 !important;
365
+ top:0 !important;
366
+ right:0 !important;
367
+ `;
368
+ const CONTEXT_STYLE = [
369
+ "letter-spacing",
370
+ "line-height",
371
+ "padding-top",
372
+ "padding-bottom",
373
+ "font-family",
374
+ "font-weight",
375
+ "font-size",
376
+ "text-rendering",
377
+ "text-transform",
378
+ "width",
379
+ "text-indent",
380
+ "padding-left",
381
+ "padding-right",
382
+ "border-width",
383
+ "box-sizing"
384
+ ];
385
+ function calculateNodeStyling(targetElement) {
386
+ const style = window.getComputedStyle(targetElement);
387
+ const boxSizing = style.getPropertyValue("box-sizing");
388
+ const paddingSize = parseFloat(style.getPropertyValue("padding-bottom")) + parseFloat(style.getPropertyValue("padding-top"));
389
+ const borderSize = parseFloat(style.getPropertyValue("border-bottom-width")) + parseFloat(style.getPropertyValue("border-top-width"));
390
+ const contextStyle = CONTEXT_STYLE.map((name) => `${name}:${style.getPropertyValue(name)}`).join(";");
391
+ return { contextStyle, paddingSize, borderSize, boxSizing };
392
+ }
393
+ function calcTextareaHeight(targetElement, minRows = 1, maxRows) {
394
+ var _a;
395
+ if (!hiddenTextarea) {
396
+ hiddenTextarea = document.createElement("textarea");
397
+ document.body.appendChild(hiddenTextarea);
398
+ }
399
+ const { paddingSize, borderSize, boxSizing, contextStyle } = calculateNodeStyling(targetElement);
400
+ hiddenTextarea.setAttribute("style", `${contextStyle};${HIDDEN_STYLE}`);
401
+ hiddenTextarea.value = targetElement.value || targetElement.placeholder || "";
402
+ let height = hiddenTextarea.scrollHeight;
403
+ const result = {};
404
+ if (boxSizing === "border-box") {
405
+ height = height + borderSize;
406
+ } else if (boxSizing === "content-box") {
407
+ height = height - paddingSize;
408
+ }
409
+ hiddenTextarea.value = "";
410
+ const singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
411
+ if (isNumber(minRows)) {
412
+ let minHeight = singleRowHeight * minRows;
413
+ if (boxSizing === "border-box") {
414
+ minHeight = minHeight + paddingSize + borderSize;
415
+ }
416
+ height = Math.max(minHeight, height);
417
+ result.minHeight = `${minHeight}px`;
418
+ }
419
+ if (isNumber(maxRows)) {
420
+ let maxHeight = singleRowHeight * maxRows;
421
+ if (boxSizing === "border-box") {
422
+ maxHeight = maxHeight + paddingSize + borderSize;
423
+ }
424
+ height = Math.min(maxHeight, height);
425
+ }
426
+ result.height = `${height}px`;
427
+ (_a = hiddenTextarea.parentNode) == null ? void 0 : _a.removeChild(hiddenTextarea);
428
+ hiddenTextarea = void 0;
429
+ return result;
430
+ }
431
+ const inputProps = buildProps({
432
+ size: useSizeProp,
433
+ disabled: Boolean,
434
+ modelValue: {
435
+ type: definePropType(void 0),
436
+ default: ""
437
+ },
438
+ type: {
439
+ type: String,
440
+ default: "text"
441
+ },
442
+ resize: {
443
+ type: String,
444
+ values: ["none", "both", "horizontal", "vertical"]
445
+ },
446
+ autosize: {
447
+ type: definePropType([Boolean, Object]),
448
+ default: false
449
+ },
450
+ autocomplete: {
451
+ type: String,
452
+ default: "off"
453
+ },
454
+ placeholder: {
455
+ type: String
456
+ },
457
+ form: {
458
+ type: String,
459
+ default: ""
460
+ },
461
+ readonly: {
462
+ type: Boolean,
463
+ default: false
464
+ },
465
+ clearable: {
466
+ type: Boolean,
467
+ default: false
468
+ },
469
+ showPassword: {
470
+ type: Boolean,
471
+ default: false
472
+ },
473
+ showWordLimit: {
474
+ type: Boolean,
475
+ default: false
476
+ },
477
+ suffixIcon: {
478
+ type: iconPropType,
479
+ default: ""
480
+ },
481
+ prefixIcon: {
482
+ type: iconPropType,
483
+ default: ""
484
+ },
485
+ label: {
486
+ type: String
487
+ },
488
+ tabindex: {
489
+ type: [Number, String]
490
+ },
491
+ validateEvent: {
492
+ type: Boolean,
493
+ default: true
494
+ },
495
+ inputStyle: {
496
+ type: definePropType([Object, Array, String]),
497
+ default: () => mutable({})
498
+ }
499
+ });
500
+ const inputEmits = {
501
+ [UPDATE_MODEL_EVENT]: (value) => isString(value),
502
+ input: (value) => isString(value),
503
+ change: (value) => isString(value),
504
+ focus: (evt) => evt instanceof FocusEvent,
505
+ blur: (evt) => evt instanceof FocusEvent,
506
+ clear: () => true,
507
+ mouseleave: (evt) => evt instanceof MouseEvent,
508
+ mouseenter: (evt) => evt instanceof MouseEvent,
509
+ keydown: (evt) => evt instanceof KeyboardEvent,
510
+ compositionstart: (evt) => evt instanceof CompositionEvent,
511
+ compositionupdate: (evt) => evt instanceof CompositionEvent,
512
+ compositionend: (evt) => evt instanceof CompositionEvent
513
+ };
514
+ var _export_sfc = (sfc, props) => {
515
+ const target = sfc.__vccOpts || sfc;
516
+ for (const [key, val] of props) {
517
+ target[key] = val;
518
+ }
519
+ return target;
520
+ };
521
+ const PENDANT_MAP = {
522
+ suffix: "append",
523
+ prefix: "prepend"
524
+ };
525
+ const _sfc_main$4 = defineComponent({
526
+ name: "ElInput",
527
+ components: { ElIcon, CircleClose: circleClose, IconView: view },
528
+ inheritAttrs: false,
529
+ props: inputProps,
530
+ emits: inputEmits,
531
+ setup(props, { slots, emit, attrs: rawAttrs }) {
532
+ const instance = getCurrentInstance();
533
+ const attrs = useAttrs();
534
+ const { form, formItem } = useFormItem();
535
+ const inputSize = useSize();
536
+ const inputDisabled = useDisabled();
537
+ const nsInput = useNamespace("input");
538
+ const nsTextarea = useNamespace("textarea");
539
+ const input2 = ref();
540
+ const textarea = ref();
541
+ const focused = ref(false);
542
+ const hovering = ref(false);
543
+ const isComposing = ref(false);
544
+ const passwordVisible = ref(false);
545
+ const _textareaCalcStyle = shallowRef(props.inputStyle);
546
+ const inputOrTextarea = computed(() => input2.value || textarea.value);
547
+ const needStatusIcon = computed(() => {
548
+ var _a;
549
+ return (_a = form == null ? void 0 : form.statusIcon) != null ? _a : false;
550
+ });
551
+ const validateState = computed(() => (formItem == null ? void 0 : formItem.validateState) || "");
552
+ const validateIcon = computed(() => ValidateComponentsMap[validateState.value]);
553
+ const containerStyle = computed(() => rawAttrs.style);
554
+ const computedTextareaStyle = computed(() => [
555
+ props.inputStyle,
556
+ _textareaCalcStyle.value,
557
+ { resize: props.resize }
558
+ ]);
559
+ const nativeInputValue = computed(() => props.modelValue === null || props.modelValue === void 0 ? "" : String(props.modelValue));
560
+ const showClear = computed(() => props.clearable && !inputDisabled.value && !props.readonly && !!nativeInputValue.value && (focused.value || hovering.value));
561
+ const showPwdVisible = computed(() => props.showPassword && !inputDisabled.value && !props.readonly && (!!nativeInputValue.value || focused.value));
562
+ const isWordLimitVisible = computed(() => props.showWordLimit && !!attrs.value.maxlength && (props.type === "text" || props.type === "textarea") && !inputDisabled.value && !props.readonly && !props.showPassword);
563
+ const textLength = computed(() => Array.from(nativeInputValue.value).length);
564
+ const inputExceed = computed(() => !!isWordLimitVisible.value && textLength.value > Number(attrs.value.maxlength));
565
+ const resizeTextarea = () => {
566
+ const { type, autosize } = props;
567
+ if (!isClient || type !== "textarea")
568
+ return;
569
+ if (autosize) {
570
+ const minRows = isObject(autosize) ? autosize.minRows : void 0;
571
+ const maxRows = isObject(autosize) ? autosize.maxRows : void 0;
572
+ _textareaCalcStyle.value = __spreadValues({}, calcTextareaHeight(textarea.value, minRows, maxRows));
573
+ } else {
574
+ _textareaCalcStyle.value = {
575
+ minHeight: calcTextareaHeight(textarea.value).minHeight
576
+ };
577
+ }
578
+ };
579
+ const setNativeInputValue = () => {
580
+ const input22 = inputOrTextarea.value;
581
+ if (!input22 || input22.value === nativeInputValue.value)
582
+ return;
583
+ input22.value = nativeInputValue.value;
584
+ };
585
+ const calcIconOffset = (place) => {
586
+ const { el } = instance.vnode;
587
+ if (!el)
588
+ return;
589
+ const elList = Array.from(el.querySelectorAll(`.${nsInput.e(place)}`));
590
+ const target = elList.find((item) => item.parentNode === el);
591
+ if (!target)
592
+ return;
593
+ const pendant = PENDANT_MAP[place];
594
+ if (slots[pendant]) {
595
+ target.style.transform = `translateX(${place === "suffix" ? "-" : ""}${el.querySelector(`.${nsInput.be("group", pendant)}`).offsetWidth}px)`;
596
+ } else {
597
+ target.removeAttribute("style");
598
+ }
599
+ };
600
+ const updateIconOffset = () => {
601
+ calcIconOffset("prefix");
602
+ calcIconOffset("suffix");
603
+ };
604
+ const handleInput = (event) => {
605
+ const { value } = event.target;
606
+ if (isComposing.value)
607
+ return;
608
+ if (value === nativeInputValue.value)
609
+ return;
610
+ emit(UPDATE_MODEL_EVENT, value);
611
+ emit("input", value);
612
+ nextTick(setNativeInputValue);
613
+ };
614
+ const handleChange = (event) => {
615
+ emit("change", event.target.value);
616
+ };
617
+ const focus = () => {
618
+ nextTick(() => {
619
+ var _a;
620
+ (_a = inputOrTextarea.value) == null ? void 0 : _a.focus();
621
+ });
622
+ };
623
+ const blur = () => {
624
+ var _a;
625
+ (_a = inputOrTextarea.value) == null ? void 0 : _a.blur();
626
+ };
627
+ const handleFocus = (event) => {
628
+ focused.value = true;
629
+ emit("focus", event);
630
+ };
631
+ const handleBlur = (event) => {
632
+ var _a;
633
+ focused.value = false;
634
+ emit("blur", event);
635
+ if (props.validateEvent) {
636
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "blur");
637
+ }
638
+ };
639
+ const select = () => {
640
+ var _a;
641
+ (_a = inputOrTextarea.value) == null ? void 0 : _a.select();
642
+ };
643
+ const handleCompositionStart = (event) => {
644
+ emit("compositionstart", event);
645
+ isComposing.value = true;
646
+ };
647
+ const handleCompositionUpdate = (event) => {
648
+ var _a;
649
+ emit("compositionupdate", event);
650
+ const text = (_a = event.target) == null ? void 0 : _a.value;
651
+ const lastCharacter = text[text.length - 1] || "";
652
+ isComposing.value = !isKorean(lastCharacter);
653
+ };
654
+ const handleCompositionEnd = (event) => {
655
+ emit("compositionend", event);
656
+ if (isComposing.value) {
657
+ isComposing.value = false;
658
+ handleInput(event);
659
+ }
660
+ };
661
+ const clear = () => {
662
+ emit(UPDATE_MODEL_EVENT, "");
663
+ emit("change", "");
664
+ emit("clear");
665
+ emit("input", "");
666
+ };
667
+ const handlePasswordVisible = () => {
668
+ passwordVisible.value = !passwordVisible.value;
669
+ focus();
670
+ };
671
+ const suffixVisible = computed(() => !!slots.suffix || !!props.suffixIcon || showClear.value || props.showPassword || isWordLimitVisible.value || !!validateState.value && needStatusIcon.value);
672
+ watch(() => props.modelValue, () => {
673
+ var _a;
674
+ nextTick(resizeTextarea);
675
+ if (props.validateEvent) {
676
+ (_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
677
+ }
678
+ });
679
+ watch(nativeInputValue, () => setNativeInputValue());
680
+ watch(() => props.type, () => {
681
+ nextTick(() => {
682
+ setNativeInputValue();
683
+ resizeTextarea();
684
+ updateIconOffset();
685
+ });
686
+ });
687
+ onMounted(() => {
688
+ setNativeInputValue();
689
+ updateIconOffset();
690
+ nextTick(resizeTextarea);
691
+ });
692
+ onUpdated(() => {
693
+ nextTick(updateIconOffset);
694
+ });
695
+ const onMouseLeave = (evt) => {
696
+ hovering.value = false;
697
+ emit("mouseleave", evt);
698
+ };
699
+ const onMouseEnter = (evt) => {
700
+ hovering.value = true;
701
+ emit("mouseenter", evt);
702
+ };
703
+ const handleKeydown = (evt) => {
704
+ emit("keydown", evt);
705
+ };
706
+ return {
707
+ input: input2,
708
+ textarea,
709
+ attrs,
710
+ inputSize,
711
+ validateState,
712
+ validateIcon,
713
+ containerStyle,
714
+ computedTextareaStyle,
715
+ inputDisabled,
716
+ showClear,
717
+ showPwdVisible,
718
+ isWordLimitVisible,
719
+ textLength,
720
+ hovering,
721
+ inputExceed,
722
+ passwordVisible,
723
+ inputOrTextarea,
724
+ suffixVisible,
725
+ needStatusIcon,
726
+ resizeTextarea,
727
+ handleInput,
728
+ handleChange,
729
+ handleFocus,
730
+ handleBlur,
731
+ handleCompositionStart,
732
+ handleCompositionUpdate,
733
+ handleCompositionEnd,
734
+ handlePasswordVisible,
735
+ clear,
736
+ select,
737
+ focus,
738
+ blur,
739
+ onMouseLeave,
740
+ onMouseEnter,
741
+ handleKeydown,
742
+ nsInput,
743
+ nsTextarea
744
+ };
745
+ }
746
+ });
747
+ const _hoisted_1$3 = ["type", "disabled", "readonly", "autocomplete", "tabindex", "aria-label", "placeholder"];
748
+ const _hoisted_2$1 = ["tabindex", "disabled", "readonly", "autocomplete", "aria-label", "placeholder"];
749
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
750
+ const _component_el_icon = resolveComponent("el-icon");
751
+ const _component_circle_close = resolveComponent("circle-close");
752
+ const _component_icon_view = resolveComponent("icon-view");
753
+ return withDirectives((openBlock(), createElementBlock("div", {
754
+ class: normalizeClass([
755
+ _ctx.type === "textarea" ? _ctx.nsTextarea.b() : _ctx.nsInput.b(),
756
+ _ctx.nsInput.m(_ctx.inputSize),
757
+ _ctx.nsInput.is("disabled", _ctx.inputDisabled),
758
+ _ctx.nsInput.is("exceed", _ctx.inputExceed),
759
+ {
760
+ [_ctx.nsInput.b("group")]: _ctx.$slots.prepend || _ctx.$slots.append,
761
+ [_ctx.nsInput.bm("group", "append")]: _ctx.$slots.append,
762
+ [_ctx.nsInput.bm("group", "prepend")]: _ctx.$slots.prepend,
763
+ [_ctx.nsInput.m("prefix")]: _ctx.$slots.prefix || _ctx.prefixIcon,
764
+ [_ctx.nsInput.m("suffix")]: _ctx.$slots.suffix || _ctx.suffixIcon || _ctx.clearable || _ctx.showPassword,
765
+ [_ctx.nsInput.m("suffix--password-clear")]: _ctx.showClear && _ctx.showPwdVisible
766
+ },
767
+ _ctx.$attrs.class
768
+ ]),
769
+ style: normalizeStyle(_ctx.containerStyle),
770
+ onMouseenter: _cache[17] || (_cache[17] = (...args) => _ctx.onMouseEnter && _ctx.onMouseEnter(...args)),
771
+ onMouseleave: _cache[18] || (_cache[18] = (...args) => _ctx.onMouseLeave && _ctx.onMouseLeave(...args))
772
+ }, [
773
+ createCommentVNode(" input "),
774
+ _ctx.type !== "textarea" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
775
+ createCommentVNode(" prepend slot "),
776
+ _ctx.$slots.prepend ? (openBlock(), createElementBlock("div", {
777
+ key: 0,
778
+ class: normalizeClass(_ctx.nsInput.be("group", "prepend"))
779
+ }, [
780
+ renderSlot(_ctx.$slots, "prepend")
781
+ ], 2)) : createCommentVNode("v-if", true),
782
+ createElementVNode("input", mergeProps({
783
+ ref: "input",
784
+ class: _ctx.nsInput.e("inner")
785
+ }, _ctx.attrs, {
786
+ type: _ctx.showPassword ? _ctx.passwordVisible ? "text" : "password" : _ctx.type,
787
+ disabled: _ctx.inputDisabled,
788
+ readonly: _ctx.readonly,
789
+ autocomplete: _ctx.autocomplete,
790
+ tabindex: _ctx.tabindex,
791
+ "aria-label": _ctx.label,
792
+ placeholder: _ctx.placeholder,
793
+ style: _ctx.inputStyle,
794
+ onCompositionstart: _cache[0] || (_cache[0] = (...args) => _ctx.handleCompositionStart && _ctx.handleCompositionStart(...args)),
795
+ onCompositionupdate: _cache[1] || (_cache[1] = (...args) => _ctx.handleCompositionUpdate && _ctx.handleCompositionUpdate(...args)),
796
+ onCompositionend: _cache[2] || (_cache[2] = (...args) => _ctx.handleCompositionEnd && _ctx.handleCompositionEnd(...args)),
797
+ onInput: _cache[3] || (_cache[3] = (...args) => _ctx.handleInput && _ctx.handleInput(...args)),
798
+ onFocus: _cache[4] || (_cache[4] = (...args) => _ctx.handleFocus && _ctx.handleFocus(...args)),
799
+ onBlur: _cache[5] || (_cache[5] = (...args) => _ctx.handleBlur && _ctx.handleBlur(...args)),
800
+ onChange: _cache[6] || (_cache[6] = (...args) => _ctx.handleChange && _ctx.handleChange(...args)),
801
+ onKeydown: _cache[7] || (_cache[7] = (...args) => _ctx.handleKeydown && _ctx.handleKeydown(...args))
802
+ }), null, 16, _hoisted_1$3),
803
+ createCommentVNode(" prefix slot "),
804
+ _ctx.$slots.prefix || _ctx.prefixIcon ? (openBlock(), createElementBlock("span", {
805
+ key: 1,
806
+ class: normalizeClass(_ctx.nsInput.e("prefix"))
807
+ }, [
808
+ createElementVNode("span", {
809
+ class: normalizeClass(_ctx.nsInput.e("prefix-inner"))
810
+ }, [
811
+ renderSlot(_ctx.$slots, "prefix"),
812
+ _ctx.prefixIcon ? (openBlock(), createBlock(_component_el_icon, {
813
+ key: 0,
814
+ class: normalizeClass(_ctx.nsInput.e("icon"))
815
+ }, {
816
+ default: withCtx(() => [
817
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.prefixIcon)))
818
+ ]),
819
+ _: 1
820
+ }, 8, ["class"])) : createCommentVNode("v-if", true)
821
+ ], 2)
822
+ ], 2)) : createCommentVNode("v-if", true),
823
+ createCommentVNode(" suffix slot "),
824
+ _ctx.suffixVisible ? (openBlock(), createElementBlock("span", {
825
+ key: 2,
826
+ class: normalizeClass(_ctx.nsInput.e("suffix"))
827
+ }, [
828
+ createElementVNode("span", {
829
+ class: normalizeClass(_ctx.nsInput.e("suffix-inner"))
830
+ }, [
831
+ !_ctx.showClear || !_ctx.showPwdVisible || !_ctx.isWordLimitVisible ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
832
+ renderSlot(_ctx.$slots, "suffix"),
833
+ _ctx.suffixIcon ? (openBlock(), createBlock(_component_el_icon, {
834
+ key: 0,
835
+ class: normalizeClass(_ctx.nsInput.e("icon"))
836
+ }, {
837
+ default: withCtx(() => [
838
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.suffixIcon)))
839
+ ]),
840
+ _: 1
841
+ }, 8, ["class"])) : createCommentVNode("v-if", true)
842
+ ], 64)) : createCommentVNode("v-if", true),
843
+ _ctx.showClear ? (openBlock(), createBlock(_component_el_icon, {
844
+ key: 1,
845
+ class: normalizeClass([_ctx.nsInput.e("icon"), _ctx.nsInput.e("clear")]),
846
+ onMousedown: _cache[8] || (_cache[8] = withModifiers(() => {
847
+ }, ["prevent"])),
848
+ onClick: _ctx.clear
849
+ }, {
850
+ default: withCtx(() => [
851
+ createVNode(_component_circle_close)
852
+ ]),
853
+ _: 1
854
+ }, 8, ["class", "onClick"])) : createCommentVNode("v-if", true),
855
+ _ctx.showPwdVisible ? (openBlock(), createBlock(_component_el_icon, {
856
+ key: 2,
857
+ class: normalizeClass([_ctx.nsInput.e("icon"), _ctx.nsInput.e("clear")]),
858
+ onClick: _ctx.handlePasswordVisible
859
+ }, {
860
+ default: withCtx(() => [
861
+ createVNode(_component_icon_view)
862
+ ]),
863
+ _: 1
864
+ }, 8, ["class", "onClick"])) : createCommentVNode("v-if", true),
865
+ _ctx.isWordLimitVisible ? (openBlock(), createElementBlock("span", {
866
+ key: 3,
867
+ class: normalizeClass(_ctx.nsInput.e("count"))
868
+ }, [
869
+ createElementVNode("span", {
870
+ class: normalizeClass(_ctx.nsInput.e("count-inner"))
871
+ }, toDisplayString(_ctx.textLength) + " / " + toDisplayString(_ctx.attrs.maxlength), 3)
872
+ ], 2)) : createCommentVNode("v-if", true)
873
+ ], 2),
874
+ _ctx.validateState && _ctx.validateIcon && _ctx.needStatusIcon ? (openBlock(), createBlock(_component_el_icon, {
875
+ key: 0,
876
+ class: normalizeClass([_ctx.nsInput.e("icon"), _ctx.nsInput.e("validateIcon")])
877
+ }, {
878
+ default: withCtx(() => [
879
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.validateIcon)))
880
+ ]),
881
+ _: 1
882
+ }, 8, ["class"])) : createCommentVNode("v-if", true)
883
+ ], 2)) : createCommentVNode("v-if", true),
884
+ createCommentVNode(" append slot "),
885
+ _ctx.$slots.append ? (openBlock(), createElementBlock("div", {
886
+ key: 3,
887
+ class: normalizeClass(_ctx.nsInput.be("group", "append"))
888
+ }, [
889
+ renderSlot(_ctx.$slots, "append")
890
+ ], 2)) : createCommentVNode("v-if", true)
891
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
892
+ createCommentVNode(" textarea "),
893
+ createElementVNode("textarea", mergeProps({
894
+ ref: "textarea",
895
+ class: _ctx.nsTextarea.e("inner")
896
+ }, _ctx.attrs, {
897
+ tabindex: _ctx.tabindex,
898
+ disabled: _ctx.inputDisabled,
899
+ readonly: _ctx.readonly,
900
+ autocomplete: _ctx.autocomplete,
901
+ style: _ctx.computedTextareaStyle,
902
+ "aria-label": _ctx.label,
903
+ placeholder: _ctx.placeholder,
904
+ onCompositionstart: _cache[9] || (_cache[9] = (...args) => _ctx.handleCompositionStart && _ctx.handleCompositionStart(...args)),
905
+ onCompositionupdate: _cache[10] || (_cache[10] = (...args) => _ctx.handleCompositionUpdate && _ctx.handleCompositionUpdate(...args)),
906
+ onCompositionend: _cache[11] || (_cache[11] = (...args) => _ctx.handleCompositionEnd && _ctx.handleCompositionEnd(...args)),
907
+ onInput: _cache[12] || (_cache[12] = (...args) => _ctx.handleInput && _ctx.handleInput(...args)),
908
+ onFocus: _cache[13] || (_cache[13] = (...args) => _ctx.handleFocus && _ctx.handleFocus(...args)),
909
+ onBlur: _cache[14] || (_cache[14] = (...args) => _ctx.handleBlur && _ctx.handleBlur(...args)),
910
+ onChange: _cache[15] || (_cache[15] = (...args) => _ctx.handleChange && _ctx.handleChange(...args)),
911
+ onKeydown: _cache[16] || (_cache[16] = (...args) => _ctx.handleKeydown && _ctx.handleKeydown(...args))
912
+ }), null, 16, _hoisted_2$1),
913
+ _ctx.isWordLimitVisible ? (openBlock(), createElementBlock("span", {
914
+ key: 0,
915
+ class: normalizeClass(_ctx.nsInput.e("count"))
916
+ }, toDisplayString(_ctx.textLength) + " / " + toDisplayString(_ctx.attrs.maxlength), 3)) : createCommentVNode("v-if", true)
917
+ ], 64))
918
+ ], 38)), [
919
+ [vShow, _ctx.type !== "hidden"]
920
+ ]);
921
+ }
922
+ var Input = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render]]);
923
+ const ElInput = withInstall(Input);
924
+ function bound01(n, max) {
925
+ if (isOnePointZero(n)) {
926
+ n = "100%";
927
+ }
928
+ var isPercent = isPercentage(n);
929
+ n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
930
+ if (isPercent) {
931
+ n = parseInt(String(n * max), 10) / 100;
932
+ }
933
+ if (Math.abs(n - max) < 1e-6) {
934
+ return 1;
935
+ }
936
+ if (max === 360) {
937
+ n = (n < 0 ? n % max + max : n % max) / parseFloat(String(max));
938
+ } else {
939
+ n = n % max / parseFloat(String(max));
940
+ }
941
+ return n;
942
+ }
943
+ function clamp01(val) {
944
+ return Math.min(1, Math.max(0, val));
945
+ }
946
+ function isOnePointZero(n) {
947
+ return typeof n === "string" && n.indexOf(".") !== -1 && parseFloat(n) === 1;
948
+ }
949
+ function isPercentage(n) {
950
+ return typeof n === "string" && n.indexOf("%") !== -1;
951
+ }
952
+ function boundAlpha(a) {
953
+ a = parseFloat(a);
954
+ if (isNaN(a) || a < 0 || a > 1) {
955
+ a = 1;
956
+ }
957
+ return a;
958
+ }
959
+ function convertToPercentage(n) {
960
+ if (n <= 1) {
961
+ return Number(n) * 100 + "%";
962
+ }
963
+ return n;
964
+ }
965
+ function pad2(c) {
966
+ return c.length === 1 ? "0" + c : String(c);
967
+ }
968
+ function rgbToRgb(r, g, b) {
969
+ return {
970
+ r: bound01(r, 255) * 255,
971
+ g: bound01(g, 255) * 255,
972
+ b: bound01(b, 255) * 255
973
+ };
974
+ }
975
+ function rgbToHsl(r, g, b) {
976
+ r = bound01(r, 255);
977
+ g = bound01(g, 255);
978
+ b = bound01(b, 255);
979
+ var max = Math.max(r, g, b);
980
+ var min = Math.min(r, g, b);
981
+ var h = 0;
982
+ var s = 0;
983
+ var l = (max + min) / 2;
984
+ if (max === min) {
985
+ s = 0;
986
+ h = 0;
987
+ } else {
988
+ var d = max - min;
989
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
990
+ switch (max) {
991
+ case r:
992
+ h = (g - b) / d + (g < b ? 6 : 0);
993
+ break;
994
+ case g:
995
+ h = (b - r) / d + 2;
996
+ break;
997
+ case b:
998
+ h = (r - g) / d + 4;
999
+ break;
1000
+ }
1001
+ h /= 6;
1002
+ }
1003
+ return { h, s, l };
1004
+ }
1005
+ function hue2rgb(p, q, t) {
1006
+ if (t < 0) {
1007
+ t += 1;
1008
+ }
1009
+ if (t > 1) {
1010
+ t -= 1;
1011
+ }
1012
+ if (t < 1 / 6) {
1013
+ return p + (q - p) * (6 * t);
1014
+ }
1015
+ if (t < 1 / 2) {
1016
+ return q;
1017
+ }
1018
+ if (t < 2 / 3) {
1019
+ return p + (q - p) * (2 / 3 - t) * 6;
1020
+ }
1021
+ return p;
1022
+ }
1023
+ function hslToRgb(h, s, l) {
1024
+ var r;
1025
+ var g;
1026
+ var b;
1027
+ h = bound01(h, 360);
1028
+ s = bound01(s, 100);
1029
+ l = bound01(l, 100);
1030
+ if (s === 0) {
1031
+ g = l;
1032
+ b = l;
1033
+ r = l;
1034
+ } else {
1035
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
1036
+ var p = 2 * l - q;
1037
+ r = hue2rgb(p, q, h + 1 / 3);
1038
+ g = hue2rgb(p, q, h);
1039
+ b = hue2rgb(p, q, h - 1 / 3);
1040
+ }
1041
+ return { r: r * 255, g: g * 255, b: b * 255 };
1042
+ }
1043
+ function rgbToHsv(r, g, b) {
1044
+ r = bound01(r, 255);
1045
+ g = bound01(g, 255);
1046
+ b = bound01(b, 255);
1047
+ var max = Math.max(r, g, b);
1048
+ var min = Math.min(r, g, b);
1049
+ var h = 0;
1050
+ var v = max;
1051
+ var d = max - min;
1052
+ var s = max === 0 ? 0 : d / max;
1053
+ if (max === min) {
1054
+ h = 0;
1055
+ } else {
1056
+ switch (max) {
1057
+ case r:
1058
+ h = (g - b) / d + (g < b ? 6 : 0);
1059
+ break;
1060
+ case g:
1061
+ h = (b - r) / d + 2;
1062
+ break;
1063
+ case b:
1064
+ h = (r - g) / d + 4;
1065
+ break;
1066
+ }
1067
+ h /= 6;
1068
+ }
1069
+ return { h, s, v };
1070
+ }
1071
+ function hsvToRgb(h, s, v) {
1072
+ h = bound01(h, 360) * 6;
1073
+ s = bound01(s, 100);
1074
+ v = bound01(v, 100);
1075
+ var i = Math.floor(h);
1076
+ var f = h - i;
1077
+ var p = v * (1 - s);
1078
+ var q = v * (1 - f * s);
1079
+ var t = v * (1 - (1 - f) * s);
1080
+ var mod = i % 6;
1081
+ var r = [v, q, p, p, t, v][mod];
1082
+ var g = [t, v, v, q, p, p][mod];
1083
+ var b = [p, p, t, v, v, q][mod];
1084
+ return { r: r * 255, g: g * 255, b: b * 255 };
1085
+ }
1086
+ function rgbToHex(r, g, b, allow3Char) {
1087
+ var hex = [
1088
+ pad2(Math.round(r).toString(16)),
1089
+ pad2(Math.round(g).toString(16)),
1090
+ pad2(Math.round(b).toString(16))
1091
+ ];
1092
+ if (allow3Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1))) {
1093
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
1094
+ }
1095
+ return hex.join("");
1096
+ }
1097
+ function rgbaToHex(r, g, b, a, allow4Char) {
1098
+ var hex = [
1099
+ pad2(Math.round(r).toString(16)),
1100
+ pad2(Math.round(g).toString(16)),
1101
+ pad2(Math.round(b).toString(16)),
1102
+ pad2(convertDecimalToHex(a))
1103
+ ];
1104
+ if (allow4Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1)) && hex[3].startsWith(hex[3].charAt(1))) {
1105
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
1106
+ }
1107
+ return hex.join("");
1108
+ }
1109
+ function convertDecimalToHex(d) {
1110
+ return Math.round(parseFloat(d) * 255).toString(16);
1111
+ }
1112
+ function convertHexToDecimal(h) {
1113
+ return parseIntFromHex(h) / 255;
1114
+ }
1115
+ function parseIntFromHex(val) {
1116
+ return parseInt(val, 16);
1117
+ }
1118
+ function numberInputToObject(color) {
1119
+ return {
1120
+ r: color >> 16,
1121
+ g: (color & 65280) >> 8,
1122
+ b: color & 255
1123
+ };
1124
+ }
1125
+ var names = {
1126
+ aliceblue: "#f0f8ff",
1127
+ antiquewhite: "#faebd7",
1128
+ aqua: "#00ffff",
1129
+ aquamarine: "#7fffd4",
1130
+ azure: "#f0ffff",
1131
+ beige: "#f5f5dc",
1132
+ bisque: "#ffe4c4",
1133
+ black: "#000000",
1134
+ blanchedalmond: "#ffebcd",
1135
+ blue: "#0000ff",
1136
+ blueviolet: "#8a2be2",
1137
+ brown: "#a52a2a",
1138
+ burlywood: "#deb887",
1139
+ cadetblue: "#5f9ea0",
1140
+ chartreuse: "#7fff00",
1141
+ chocolate: "#d2691e",
1142
+ coral: "#ff7f50",
1143
+ cornflowerblue: "#6495ed",
1144
+ cornsilk: "#fff8dc",
1145
+ crimson: "#dc143c",
1146
+ cyan: "#00ffff",
1147
+ darkblue: "#00008b",
1148
+ darkcyan: "#008b8b",
1149
+ darkgoldenrod: "#b8860b",
1150
+ darkgray: "#a9a9a9",
1151
+ darkgreen: "#006400",
1152
+ darkgrey: "#a9a9a9",
1153
+ darkkhaki: "#bdb76b",
1154
+ darkmagenta: "#8b008b",
1155
+ darkolivegreen: "#556b2f",
1156
+ darkorange: "#ff8c00",
1157
+ darkorchid: "#9932cc",
1158
+ darkred: "#8b0000",
1159
+ darksalmon: "#e9967a",
1160
+ darkseagreen: "#8fbc8f",
1161
+ darkslateblue: "#483d8b",
1162
+ darkslategray: "#2f4f4f",
1163
+ darkslategrey: "#2f4f4f",
1164
+ darkturquoise: "#00ced1",
1165
+ darkviolet: "#9400d3",
1166
+ deeppink: "#ff1493",
1167
+ deepskyblue: "#00bfff",
1168
+ dimgray: "#696969",
1169
+ dimgrey: "#696969",
1170
+ dodgerblue: "#1e90ff",
1171
+ firebrick: "#b22222",
1172
+ floralwhite: "#fffaf0",
1173
+ forestgreen: "#228b22",
1174
+ fuchsia: "#ff00ff",
1175
+ gainsboro: "#dcdcdc",
1176
+ ghostwhite: "#f8f8ff",
1177
+ goldenrod: "#daa520",
1178
+ gold: "#ffd700",
1179
+ gray: "#808080",
1180
+ green: "#008000",
1181
+ greenyellow: "#adff2f",
1182
+ grey: "#808080",
1183
+ honeydew: "#f0fff0",
1184
+ hotpink: "#ff69b4",
1185
+ indianred: "#cd5c5c",
1186
+ indigo: "#4b0082",
1187
+ ivory: "#fffff0",
1188
+ khaki: "#f0e68c",
1189
+ lavenderblush: "#fff0f5",
1190
+ lavender: "#e6e6fa",
1191
+ lawngreen: "#7cfc00",
1192
+ lemonchiffon: "#fffacd",
1193
+ lightblue: "#add8e6",
1194
+ lightcoral: "#f08080",
1195
+ lightcyan: "#e0ffff",
1196
+ lightgoldenrodyellow: "#fafad2",
1197
+ lightgray: "#d3d3d3",
1198
+ lightgreen: "#90ee90",
1199
+ lightgrey: "#d3d3d3",
1200
+ lightpink: "#ffb6c1",
1201
+ lightsalmon: "#ffa07a",
1202
+ lightseagreen: "#20b2aa",
1203
+ lightskyblue: "#87cefa",
1204
+ lightslategray: "#778899",
1205
+ lightslategrey: "#778899",
1206
+ lightsteelblue: "#b0c4de",
1207
+ lightyellow: "#ffffe0",
1208
+ lime: "#00ff00",
1209
+ limegreen: "#32cd32",
1210
+ linen: "#faf0e6",
1211
+ magenta: "#ff00ff",
1212
+ maroon: "#800000",
1213
+ mediumaquamarine: "#66cdaa",
1214
+ mediumblue: "#0000cd",
1215
+ mediumorchid: "#ba55d3",
1216
+ mediumpurple: "#9370db",
1217
+ mediumseagreen: "#3cb371",
1218
+ mediumslateblue: "#7b68ee",
1219
+ mediumspringgreen: "#00fa9a",
1220
+ mediumturquoise: "#48d1cc",
1221
+ mediumvioletred: "#c71585",
1222
+ midnightblue: "#191970",
1223
+ mintcream: "#f5fffa",
1224
+ mistyrose: "#ffe4e1",
1225
+ moccasin: "#ffe4b5",
1226
+ navajowhite: "#ffdead",
1227
+ navy: "#000080",
1228
+ oldlace: "#fdf5e6",
1229
+ olive: "#808000",
1230
+ olivedrab: "#6b8e23",
1231
+ orange: "#ffa500",
1232
+ orangered: "#ff4500",
1233
+ orchid: "#da70d6",
1234
+ palegoldenrod: "#eee8aa",
1235
+ palegreen: "#98fb98",
1236
+ paleturquoise: "#afeeee",
1237
+ palevioletred: "#db7093",
1238
+ papayawhip: "#ffefd5",
1239
+ peachpuff: "#ffdab9",
1240
+ peru: "#cd853f",
1241
+ pink: "#ffc0cb",
1242
+ plum: "#dda0dd",
1243
+ powderblue: "#b0e0e6",
1244
+ purple: "#800080",
1245
+ rebeccapurple: "#663399",
1246
+ red: "#ff0000",
1247
+ rosybrown: "#bc8f8f",
1248
+ royalblue: "#4169e1",
1249
+ saddlebrown: "#8b4513",
1250
+ salmon: "#fa8072",
1251
+ sandybrown: "#f4a460",
1252
+ seagreen: "#2e8b57",
1253
+ seashell: "#fff5ee",
1254
+ sienna: "#a0522d",
1255
+ silver: "#c0c0c0",
1256
+ skyblue: "#87ceeb",
1257
+ slateblue: "#6a5acd",
1258
+ slategray: "#708090",
1259
+ slategrey: "#708090",
1260
+ snow: "#fffafa",
1261
+ springgreen: "#00ff7f",
1262
+ steelblue: "#4682b4",
1263
+ tan: "#d2b48c",
1264
+ teal: "#008080",
1265
+ thistle: "#d8bfd8",
1266
+ tomato: "#ff6347",
1267
+ turquoise: "#40e0d0",
1268
+ violet: "#ee82ee",
1269
+ wheat: "#f5deb3",
1270
+ white: "#ffffff",
1271
+ whitesmoke: "#f5f5f5",
1272
+ yellow: "#ffff00",
1273
+ yellowgreen: "#9acd32"
1274
+ };
1275
+ function inputToRGB(color) {
1276
+ var rgb = { r: 0, g: 0, b: 0 };
1277
+ var a = 1;
1278
+ var s = null;
1279
+ var v = null;
1280
+ var l = null;
1281
+ var ok = false;
1282
+ var format = false;
1283
+ if (typeof color === "string") {
1284
+ color = stringInputToObject(color);
1285
+ }
1286
+ if (typeof color === "object") {
1287
+ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
1288
+ rgb = rgbToRgb(color.r, color.g, color.b);
1289
+ ok = true;
1290
+ format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
1291
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
1292
+ s = convertToPercentage(color.s);
1293
+ v = convertToPercentage(color.v);
1294
+ rgb = hsvToRgb(color.h, s, v);
1295
+ ok = true;
1296
+ format = "hsv";
1297
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
1298
+ s = convertToPercentage(color.s);
1299
+ l = convertToPercentage(color.l);
1300
+ rgb = hslToRgb(color.h, s, l);
1301
+ ok = true;
1302
+ format = "hsl";
1303
+ }
1304
+ if (Object.prototype.hasOwnProperty.call(color, "a")) {
1305
+ a = color.a;
1306
+ }
1307
+ }
1308
+ a = boundAlpha(a);
1309
+ return {
1310
+ ok,
1311
+ format: color.format || format,
1312
+ r: Math.min(255, Math.max(rgb.r, 0)),
1313
+ g: Math.min(255, Math.max(rgb.g, 0)),
1314
+ b: Math.min(255, Math.max(rgb.b, 0)),
1315
+ a
1316
+ };
1317
+ }
1318
+ var CSS_INTEGER = "[-\\+]?\\d+%?";
1319
+ var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
1320
+ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
1321
+ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
1322
+ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
1323
+ var matchers = {
1324
+ CSS_UNIT: new RegExp(CSS_UNIT),
1325
+ rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
1326
+ rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
1327
+ hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
1328
+ hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
1329
+ hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
1330
+ hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
1331
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1332
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1333
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1334
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
1335
+ };
1336
+ function stringInputToObject(color) {
1337
+ color = color.trim().toLowerCase();
1338
+ if (color.length === 0) {
1339
+ return false;
1340
+ }
1341
+ var named = false;
1342
+ if (names[color]) {
1343
+ color = names[color];
1344
+ named = true;
1345
+ } else if (color === "transparent") {
1346
+ return { r: 0, g: 0, b: 0, a: 0, format: "name" };
1347
+ }
1348
+ var match = matchers.rgb.exec(color);
1349
+ if (match) {
1350
+ return { r: match[1], g: match[2], b: match[3] };
1351
+ }
1352
+ match = matchers.rgba.exec(color);
1353
+ if (match) {
1354
+ return { r: match[1], g: match[2], b: match[3], a: match[4] };
1355
+ }
1356
+ match = matchers.hsl.exec(color);
1357
+ if (match) {
1358
+ return { h: match[1], s: match[2], l: match[3] };
1359
+ }
1360
+ match = matchers.hsla.exec(color);
1361
+ if (match) {
1362
+ return { h: match[1], s: match[2], l: match[3], a: match[4] };
1363
+ }
1364
+ match = matchers.hsv.exec(color);
1365
+ if (match) {
1366
+ return { h: match[1], s: match[2], v: match[3] };
1367
+ }
1368
+ match = matchers.hsva.exec(color);
1369
+ if (match) {
1370
+ return { h: match[1], s: match[2], v: match[3], a: match[4] };
1371
+ }
1372
+ match = matchers.hex8.exec(color);
1373
+ if (match) {
1374
+ return {
1375
+ r: parseIntFromHex(match[1]),
1376
+ g: parseIntFromHex(match[2]),
1377
+ b: parseIntFromHex(match[3]),
1378
+ a: convertHexToDecimal(match[4]),
1379
+ format: named ? "name" : "hex8"
1380
+ };
1381
+ }
1382
+ match = matchers.hex6.exec(color);
1383
+ if (match) {
1384
+ return {
1385
+ r: parseIntFromHex(match[1]),
1386
+ g: parseIntFromHex(match[2]),
1387
+ b: parseIntFromHex(match[3]),
1388
+ format: named ? "name" : "hex"
1389
+ };
1390
+ }
1391
+ match = matchers.hex4.exec(color);
1392
+ if (match) {
1393
+ return {
1394
+ r: parseIntFromHex(match[1] + match[1]),
1395
+ g: parseIntFromHex(match[2] + match[2]),
1396
+ b: parseIntFromHex(match[3] + match[3]),
1397
+ a: convertHexToDecimal(match[4] + match[4]),
1398
+ format: named ? "name" : "hex8"
1399
+ };
1400
+ }
1401
+ match = matchers.hex3.exec(color);
1402
+ if (match) {
1403
+ return {
1404
+ r: parseIntFromHex(match[1] + match[1]),
1405
+ g: parseIntFromHex(match[2] + match[2]),
1406
+ b: parseIntFromHex(match[3] + match[3]),
1407
+ format: named ? "name" : "hex"
1408
+ };
1409
+ }
1410
+ return false;
1411
+ }
1412
+ function isValidCSSUnit(color) {
1413
+ return Boolean(matchers.CSS_UNIT.exec(String(color)));
1414
+ }
1415
+ var TinyColor = function() {
1416
+ function TinyColor2(color, opts) {
1417
+ if (color === void 0) {
1418
+ color = "";
1419
+ }
1420
+ if (opts === void 0) {
1421
+ opts = {};
1422
+ }
1423
+ var _a;
1424
+ if (color instanceof TinyColor2) {
1425
+ return color;
1426
+ }
1427
+ if (typeof color === "number") {
1428
+ color = numberInputToObject(color);
1429
+ }
1430
+ this.originalInput = color;
1431
+ var rgb = inputToRGB(color);
1432
+ this.originalInput = color;
1433
+ this.r = rgb.r;
1434
+ this.g = rgb.g;
1435
+ this.b = rgb.b;
1436
+ this.a = rgb.a;
1437
+ this.roundA = Math.round(100 * this.a) / 100;
1438
+ this.format = (_a = opts.format) !== null && _a !== void 0 ? _a : rgb.format;
1439
+ this.gradientType = opts.gradientType;
1440
+ if (this.r < 1) {
1441
+ this.r = Math.round(this.r);
1442
+ }
1443
+ if (this.g < 1) {
1444
+ this.g = Math.round(this.g);
1445
+ }
1446
+ if (this.b < 1) {
1447
+ this.b = Math.round(this.b);
1448
+ }
1449
+ this.isValid = rgb.ok;
1450
+ }
1451
+ TinyColor2.prototype.isDark = function() {
1452
+ return this.getBrightness() < 128;
1453
+ };
1454
+ TinyColor2.prototype.isLight = function() {
1455
+ return !this.isDark();
1456
+ };
1457
+ TinyColor2.prototype.getBrightness = function() {
1458
+ var rgb = this.toRgb();
1459
+ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1e3;
1460
+ };
1461
+ TinyColor2.prototype.getLuminance = function() {
1462
+ var rgb = this.toRgb();
1463
+ var R;
1464
+ var G;
1465
+ var B;
1466
+ var RsRGB = rgb.r / 255;
1467
+ var GsRGB = rgb.g / 255;
1468
+ var BsRGB = rgb.b / 255;
1469
+ if (RsRGB <= 0.03928) {
1470
+ R = RsRGB / 12.92;
1471
+ } else {
1472
+ R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
1473
+ }
1474
+ if (GsRGB <= 0.03928) {
1475
+ G = GsRGB / 12.92;
1476
+ } else {
1477
+ G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
1478
+ }
1479
+ if (BsRGB <= 0.03928) {
1480
+ B = BsRGB / 12.92;
1481
+ } else {
1482
+ B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
1483
+ }
1484
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
1485
+ };
1486
+ TinyColor2.prototype.getAlpha = function() {
1487
+ return this.a;
1488
+ };
1489
+ TinyColor2.prototype.setAlpha = function(alpha) {
1490
+ this.a = boundAlpha(alpha);
1491
+ this.roundA = Math.round(100 * this.a) / 100;
1492
+ return this;
1493
+ };
1494
+ TinyColor2.prototype.toHsv = function() {
1495
+ var hsv = rgbToHsv(this.r, this.g, this.b);
1496
+ return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };
1497
+ };
1498
+ TinyColor2.prototype.toHsvString = function() {
1499
+ var hsv = rgbToHsv(this.r, this.g, this.b);
1500
+ var h = Math.round(hsv.h * 360);
1501
+ var s = Math.round(hsv.s * 100);
1502
+ var v = Math.round(hsv.v * 100);
1503
+ return this.a === 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this.roundA + ")";
1504
+ };
1505
+ TinyColor2.prototype.toHsl = function() {
1506
+ var hsl = rgbToHsl(this.r, this.g, this.b);
1507
+ return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };
1508
+ };
1509
+ TinyColor2.prototype.toHslString = function() {
1510
+ var hsl = rgbToHsl(this.r, this.g, this.b);
1511
+ var h = Math.round(hsl.h * 360);
1512
+ var s = Math.round(hsl.s * 100);
1513
+ var l = Math.round(hsl.l * 100);
1514
+ return this.a === 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this.roundA + ")";
1515
+ };
1516
+ TinyColor2.prototype.toHex = function(allow3Char) {
1517
+ if (allow3Char === void 0) {
1518
+ allow3Char = false;
1519
+ }
1520
+ return rgbToHex(this.r, this.g, this.b, allow3Char);
1521
+ };
1522
+ TinyColor2.prototype.toHexString = function(allow3Char) {
1523
+ if (allow3Char === void 0) {
1524
+ allow3Char = false;
1525
+ }
1526
+ return "#" + this.toHex(allow3Char);
1527
+ };
1528
+ TinyColor2.prototype.toHex8 = function(allow4Char) {
1529
+ if (allow4Char === void 0) {
1530
+ allow4Char = false;
1531
+ }
1532
+ return rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);
1533
+ };
1534
+ TinyColor2.prototype.toHex8String = function(allow4Char) {
1535
+ if (allow4Char === void 0) {
1536
+ allow4Char = false;
1537
+ }
1538
+ return "#" + this.toHex8(allow4Char);
1539
+ };
1540
+ TinyColor2.prototype.toRgb = function() {
1541
+ return {
1542
+ r: Math.round(this.r),
1543
+ g: Math.round(this.g),
1544
+ b: Math.round(this.b),
1545
+ a: this.a
1546
+ };
1547
+ };
1548
+ TinyColor2.prototype.toRgbString = function() {
1549
+ var r = Math.round(this.r);
1550
+ var g = Math.round(this.g);
1551
+ var b = Math.round(this.b);
1552
+ return this.a === 1 ? "rgb(" + r + ", " + g + ", " + b + ")" : "rgba(" + r + ", " + g + ", " + b + ", " + this.roundA + ")";
1553
+ };
1554
+ TinyColor2.prototype.toPercentageRgb = function() {
1555
+ var fmt = function(x) {
1556
+ return Math.round(bound01(x, 255) * 100) + "%";
1557
+ };
1558
+ return {
1559
+ r: fmt(this.r),
1560
+ g: fmt(this.g),
1561
+ b: fmt(this.b),
1562
+ a: this.a
1563
+ };
1564
+ };
1565
+ TinyColor2.prototype.toPercentageRgbString = function() {
1566
+ var rnd = function(x) {
1567
+ return Math.round(bound01(x, 255) * 100);
1568
+ };
1569
+ return this.a === 1 ? "rgb(" + rnd(this.r) + "%, " + rnd(this.g) + "%, " + rnd(this.b) + "%)" : "rgba(" + rnd(this.r) + "%, " + rnd(this.g) + "%, " + rnd(this.b) + "%, " + this.roundA + ")";
1570
+ };
1571
+ TinyColor2.prototype.toName = function() {
1572
+ if (this.a === 0) {
1573
+ return "transparent";
1574
+ }
1575
+ if (this.a < 1) {
1576
+ return false;
1577
+ }
1578
+ var hex = "#" + rgbToHex(this.r, this.g, this.b, false);
1579
+ for (var _i = 0, _a = Object.entries(names); _i < _a.length; _i++) {
1580
+ var _b = _a[_i], key = _b[0], value = _b[1];
1581
+ if (hex === value) {
1582
+ return key;
1583
+ }
1584
+ }
1585
+ return false;
1586
+ };
1587
+ TinyColor2.prototype.toString = function(format) {
1588
+ var formatSet = Boolean(format);
1589
+ format = format !== null && format !== void 0 ? format : this.format;
1590
+ var formattedString = false;
1591
+ var hasAlpha = this.a < 1 && this.a >= 0;
1592
+ var needsAlphaFormat = !formatSet && hasAlpha && (format.startsWith("hex") || format === "name");
1593
+ if (needsAlphaFormat) {
1594
+ if (format === "name" && this.a === 0) {
1595
+ return this.toName();
1596
+ }
1597
+ return this.toRgbString();
1598
+ }
1599
+ if (format === "rgb") {
1600
+ formattedString = this.toRgbString();
1601
+ }
1602
+ if (format === "prgb") {
1603
+ formattedString = this.toPercentageRgbString();
1604
+ }
1605
+ if (format === "hex" || format === "hex6") {
1606
+ formattedString = this.toHexString();
1607
+ }
1608
+ if (format === "hex3") {
1609
+ formattedString = this.toHexString(true);
1610
+ }
1611
+ if (format === "hex4") {
1612
+ formattedString = this.toHex8String(true);
1613
+ }
1614
+ if (format === "hex8") {
1615
+ formattedString = this.toHex8String();
1616
+ }
1617
+ if (format === "name") {
1618
+ formattedString = this.toName();
1619
+ }
1620
+ if (format === "hsl") {
1621
+ formattedString = this.toHslString();
1622
+ }
1623
+ if (format === "hsv") {
1624
+ formattedString = this.toHsvString();
1625
+ }
1626
+ return formattedString || this.toHexString();
1627
+ };
1628
+ TinyColor2.prototype.toNumber = function() {
1629
+ return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
1630
+ };
1631
+ TinyColor2.prototype.clone = function() {
1632
+ return new TinyColor2(this.toString());
1633
+ };
1634
+ TinyColor2.prototype.lighten = function(amount) {
1635
+ if (amount === void 0) {
1636
+ amount = 10;
1637
+ }
1638
+ var hsl = this.toHsl();
1639
+ hsl.l += amount / 100;
1640
+ hsl.l = clamp01(hsl.l);
1641
+ return new TinyColor2(hsl);
1642
+ };
1643
+ TinyColor2.prototype.brighten = function(amount) {
1644
+ if (amount === void 0) {
1645
+ amount = 10;
1646
+ }
1647
+ var rgb = this.toRgb();
1648
+ rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
1649
+ rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
1650
+ rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
1651
+ return new TinyColor2(rgb);
1652
+ };
1653
+ TinyColor2.prototype.darken = function(amount) {
1654
+ if (amount === void 0) {
1655
+ amount = 10;
1656
+ }
1657
+ var hsl = this.toHsl();
1658
+ hsl.l -= amount / 100;
1659
+ hsl.l = clamp01(hsl.l);
1660
+ return new TinyColor2(hsl);
1661
+ };
1662
+ TinyColor2.prototype.tint = function(amount) {
1663
+ if (amount === void 0) {
1664
+ amount = 10;
1665
+ }
1666
+ return this.mix("white", amount);
1667
+ };
1668
+ TinyColor2.prototype.shade = function(amount) {
1669
+ if (amount === void 0) {
1670
+ amount = 10;
1671
+ }
1672
+ return this.mix("black", amount);
1673
+ };
1674
+ TinyColor2.prototype.desaturate = function(amount) {
1675
+ if (amount === void 0) {
1676
+ amount = 10;
1677
+ }
1678
+ var hsl = this.toHsl();
1679
+ hsl.s -= amount / 100;
1680
+ hsl.s = clamp01(hsl.s);
1681
+ return new TinyColor2(hsl);
1682
+ };
1683
+ TinyColor2.prototype.saturate = function(amount) {
1684
+ if (amount === void 0) {
1685
+ amount = 10;
1686
+ }
1687
+ var hsl = this.toHsl();
1688
+ hsl.s += amount / 100;
1689
+ hsl.s = clamp01(hsl.s);
1690
+ return new TinyColor2(hsl);
1691
+ };
1692
+ TinyColor2.prototype.greyscale = function() {
1693
+ return this.desaturate(100);
1694
+ };
1695
+ TinyColor2.prototype.spin = function(amount) {
1696
+ var hsl = this.toHsl();
1697
+ var hue = (hsl.h + amount) % 360;
1698
+ hsl.h = hue < 0 ? 360 + hue : hue;
1699
+ return new TinyColor2(hsl);
1700
+ };
1701
+ TinyColor2.prototype.mix = function(color, amount) {
1702
+ if (amount === void 0) {
1703
+ amount = 50;
1704
+ }
1705
+ var rgb1 = this.toRgb();
1706
+ var rgb2 = new TinyColor2(color).toRgb();
1707
+ var p = amount / 100;
1708
+ var rgba = {
1709
+ r: (rgb2.r - rgb1.r) * p + rgb1.r,
1710
+ g: (rgb2.g - rgb1.g) * p + rgb1.g,
1711
+ b: (rgb2.b - rgb1.b) * p + rgb1.b,
1712
+ a: (rgb2.a - rgb1.a) * p + rgb1.a
1713
+ };
1714
+ return new TinyColor2(rgba);
1715
+ };
1716
+ TinyColor2.prototype.analogous = function(results, slices) {
1717
+ if (results === void 0) {
1718
+ results = 6;
1719
+ }
1720
+ if (slices === void 0) {
1721
+ slices = 30;
1722
+ }
1723
+ var hsl = this.toHsl();
1724
+ var part = 360 / slices;
1725
+ var ret = [this];
1726
+ for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results; ) {
1727
+ hsl.h = (hsl.h + part) % 360;
1728
+ ret.push(new TinyColor2(hsl));
1729
+ }
1730
+ return ret;
1731
+ };
1732
+ TinyColor2.prototype.complement = function() {
1733
+ var hsl = this.toHsl();
1734
+ hsl.h = (hsl.h + 180) % 360;
1735
+ return new TinyColor2(hsl);
1736
+ };
1737
+ TinyColor2.prototype.monochromatic = function(results) {
1738
+ if (results === void 0) {
1739
+ results = 6;
1740
+ }
1741
+ var hsv = this.toHsv();
1742
+ var h = hsv.h;
1743
+ var s = hsv.s;
1744
+ var v = hsv.v;
1745
+ var res = [];
1746
+ var modification = 1 / results;
1747
+ while (results--) {
1748
+ res.push(new TinyColor2({ h, s, v }));
1749
+ v = (v + modification) % 1;
1750
+ }
1751
+ return res;
1752
+ };
1753
+ TinyColor2.prototype.splitcomplement = function() {
1754
+ var hsl = this.toHsl();
1755
+ var h = hsl.h;
1756
+ return [
1757
+ this,
1758
+ new TinyColor2({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }),
1759
+ new TinyColor2({ h: (h + 216) % 360, s: hsl.s, l: hsl.l })
1760
+ ];
1761
+ };
1762
+ TinyColor2.prototype.onBackground = function(background) {
1763
+ var fg = this.toRgb();
1764
+ var bg = new TinyColor2(background).toRgb();
1765
+ return new TinyColor2({
1766
+ r: bg.r + (fg.r - bg.r) * fg.a,
1767
+ g: bg.g + (fg.g - bg.g) * fg.a,
1768
+ b: bg.b + (fg.b - bg.b) * fg.a
1769
+ });
1770
+ };
1771
+ TinyColor2.prototype.triad = function() {
1772
+ return this.polyad(3);
1773
+ };
1774
+ TinyColor2.prototype.tetrad = function() {
1775
+ return this.polyad(4);
1776
+ };
1777
+ TinyColor2.prototype.polyad = function(n) {
1778
+ var hsl = this.toHsl();
1779
+ var h = hsl.h;
1780
+ var result = [this];
1781
+ var increment = 360 / n;
1782
+ for (var i = 1; i < n; i++) {
1783
+ result.push(new TinyColor2({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l }));
1784
+ }
1785
+ return result;
1786
+ };
1787
+ TinyColor2.prototype.equals = function(color) {
1788
+ return this.toRgbString() === new TinyColor2(color).toRgbString();
1789
+ };
1790
+ return TinyColor2;
1791
+ }();
1792
+ const buttonTypes = [
1793
+ "default",
1794
+ "primary",
1795
+ "success",
1796
+ "warning",
1797
+ "info",
1798
+ "danger",
1799
+ "text",
1800
+ ""
1801
+ ];
1802
+ const buttonNativeTypes = ["button", "submit", "reset"];
1803
+ const buttonProps = buildProps({
1804
+ size: useSizeProp,
1805
+ disabled: Boolean,
1806
+ type: {
1807
+ type: String,
1808
+ values: buttonTypes,
1809
+ default: ""
1810
+ },
1811
+ icon: {
1812
+ type: iconPropType,
1813
+ default: ""
1814
+ },
1815
+ nativeType: {
1816
+ type: String,
1817
+ values: buttonNativeTypes,
1818
+ default: "button"
1819
+ },
1820
+ loading: Boolean,
1821
+ loadingIcon: {
1822
+ type: iconPropType,
1823
+ default: () => loading
1824
+ },
1825
+ plain: Boolean,
1826
+ autofocus: Boolean,
1827
+ round: Boolean,
1828
+ circle: Boolean,
1829
+ color: String,
1830
+ autoInsertSpace: {
1831
+ type: Boolean,
1832
+ default: void 0
1833
+ }
1834
+ });
1835
+ const buttonEmits = {
1836
+ click: (evt) => evt instanceof MouseEvent
1837
+ };
1838
+ const _hoisted_1$2 = ["disabled", "autofocus", "type"];
1839
+ const __default__$3 = {
1840
+ name: "ElButton"
1841
+ };
1842
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$3), {
1843
+ props: buttonProps,
1844
+ emits: buttonEmits,
1845
+ setup(__props, { expose, emit }) {
1846
+ const props = __props;
1847
+ const slots = useSlots();
1848
+ const buttonGroupContext = inject(buttonGroupContextKey, void 0);
1849
+ const globalConfig2 = useGlobalConfig("button");
1850
+ const ns = useNamespace("button");
1851
+ const { form } = useFormItem();
1852
+ const _size = useSize(computed(() => buttonGroupContext == null ? void 0 : buttonGroupContext.size));
1853
+ const _disabled = useDisabled();
1854
+ const _ref = ref();
1855
+ const _type = computed(() => props.type || (buttonGroupContext == null ? void 0 : buttonGroupContext.type) || "");
1856
+ const autoInsertSpace = computed(() => {
1857
+ var _a, _b, _c;
1858
+ return (_c = (_b = props.autoInsertSpace) != null ? _b : (_a = globalConfig2.value) == null ? void 0 : _a.autoInsertSpace) != null ? _c : false;
1859
+ });
1860
+ const shouldAddSpace = computed(() => {
1861
+ var _a;
1862
+ const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots);
1863
+ if (autoInsertSpace.value && (defaultSlot == null ? void 0 : defaultSlot.length) === 1) {
1864
+ const slot = defaultSlot[0];
1865
+ if ((slot == null ? void 0 : slot.type) === Text) {
1866
+ const text = slot.children;
1867
+ return /^\p{Unified_Ideograph}{2}$/u.test(text);
1868
+ }
1869
+ }
1870
+ return false;
1871
+ });
1872
+ const buttonStyle = computed(() => {
1873
+ let styles = {};
1874
+ const buttonColor = props.color;
1875
+ if (buttonColor) {
1876
+ const color = new TinyColor(buttonColor);
1877
+ const shadeBgColor = color.shade(20).toString();
1878
+ if (props.plain) {
1879
+ styles = {
1880
+ "--el-button-bg-color": color.tint(90).toString(),
1881
+ "--el-button-text-color": buttonColor,
1882
+ "--el-button-hover-text-color": "var(--el-color-white)",
1883
+ "--el-button-hover-bg-color": buttonColor,
1884
+ "--el-button-hover-border-color": buttonColor,
1885
+ "--el-button-active-bg-color": shadeBgColor,
1886
+ "--el-button-active-text-color": "var(--el-color-white)",
1887
+ "--el-button-active-border-color": shadeBgColor
1888
+ };
1889
+ } else {
1890
+ const tintBgColor = color.tint(30).toString();
1891
+ styles = {
1892
+ "--el-button-bg-color": buttonColor,
1893
+ "--el-button-border-color": buttonColor,
1894
+ "--el-button-hover-bg-color": tintBgColor,
1895
+ "--el-button-hover-border-color": tintBgColor,
1896
+ "--el-button-active-bg-color": shadeBgColor,
1897
+ "--el-button-active-border-color": shadeBgColor
1898
+ };
1899
+ }
1900
+ if (_disabled.value) {
1901
+ const disabledButtonColor = color.tint(50).toString();
1902
+ styles["--el-button-disabled-bg-color"] = disabledButtonColor;
1903
+ styles["--el-button-disabled-border-color"] = disabledButtonColor;
1904
+ }
1905
+ }
1906
+ return styles;
1907
+ });
1908
+ const handleClick = (evt) => {
1909
+ if (props.nativeType === "reset") {
1910
+ form == null ? void 0 : form.resetFields();
1911
+ }
1912
+ emit("click", evt);
1913
+ };
1914
+ expose({
1915
+ ref: _ref,
1916
+ size: _size,
1917
+ type: _type,
1918
+ disabled: _disabled,
1919
+ shouldAddSpace
1920
+ });
1921
+ return (_ctx, _cache) => {
1922
+ return openBlock(), createElementBlock("button", {
1923
+ ref_key: "_ref",
1924
+ ref: _ref,
1925
+ class: normalizeClass([
1926
+ unref(ns).b(),
1927
+ unref(ns).m(unref(_type)),
1928
+ unref(ns).m(unref(_size)),
1929
+ unref(ns).is("disabled", unref(_disabled)),
1930
+ unref(ns).is("loading", _ctx.loading),
1931
+ unref(ns).is("plain", _ctx.plain),
1932
+ unref(ns).is("round", _ctx.round),
1933
+ unref(ns).is("circle", _ctx.circle)
1934
+ ]),
1935
+ disabled: unref(_disabled) || _ctx.loading,
1936
+ autofocus: _ctx.autofocus,
1937
+ type: _ctx.nativeType,
1938
+ style: normalizeStyle(unref(buttonStyle)),
1939
+ onClick: handleClick
1940
+ }, [
1941
+ _ctx.loading ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1942
+ _ctx.$slots.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }) : (openBlock(), createBlock(unref(ElIcon), {
1943
+ key: 1,
1944
+ class: normalizeClass(unref(ns).is("loading"))
1945
+ }, {
1946
+ default: withCtx(() => [
1947
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.loadingIcon)))
1948
+ ]),
1949
+ _: 1
1950
+ }, 8, ["class"]))
1951
+ ], 2112)) : _ctx.icon ? (openBlock(), createBlock(unref(ElIcon), { key: 1 }, {
1952
+ default: withCtx(() => [
1953
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon)))
1954
+ ]),
1955
+ _: 1
1956
+ })) : createCommentVNode("v-if", true),
1957
+ _ctx.$slots.default ? (openBlock(), createElementBlock("span", {
1958
+ key: 2,
1959
+ class: normalizeClass({ [unref(ns).em("text", "expand")]: unref(shouldAddSpace) })
1960
+ }, [
1961
+ renderSlot(_ctx.$slots, "default")
1962
+ ], 2)) : createCommentVNode("v-if", true)
1963
+ ], 14, _hoisted_1$2);
1964
+ };
1965
+ }
1966
+ }));
1967
+ const buttonGroupProps = {
1968
+ size: buttonProps.size,
1969
+ type: buttonProps.type
1970
+ };
1971
+ const __default__$2 = {
1972
+ name: "ElButtonGroup"
1973
+ };
1974
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__$2), {
1975
+ props: buttonGroupProps,
1976
+ setup(__props) {
1977
+ const props = __props;
1978
+ provide(buttonGroupContextKey, reactive({
1979
+ size: toRef(props, "size"),
1980
+ type: toRef(props, "type")
1981
+ }));
1982
+ const ns = useNamespace("button");
1983
+ return (_ctx, _cache) => {
1984
+ return openBlock(), createElementBlock("div", {
1985
+ class: normalizeClass(`${unref(ns).b("group")}`)
1986
+ }, [
1987
+ renderSlot(_ctx.$slots, "default")
1988
+ ], 2);
1989
+ };
1990
+ }
1991
+ }));
1992
+ const ElButton = withInstall(_sfc_main$3, {
1993
+ ButtonGroup: _sfc_main$2
1994
+ });
1995
+ withNoopInstall(_sfc_main$2);
1996
+ var base = "";
1997
+ var button = "";
1998
+ var input = "";
1999
+ const _hoisted_1$1 = /* @__PURE__ */ createElementVNode("p", null, "Hello NPM!", -1);
2000
+ const _hoisted_2 = /* @__PURE__ */ createTextVNode("Increment count");
2001
+ const __default__$1 = {
2002
+ name: "TestViteNpmComponent"
2003
+ };
2004
+ const _sfc_main$1 = /* @__PURE__ */ Object.assign(__default__$1, {
2005
+ setup(__props) {
2006
+ const msg = ref("");
2007
+ const count2 = ref(0);
2008
+ const incrementCount = () => count2.value++;
2009
+ return (_ctx, _cache) => {
2010
+ const _component_el_input = ElInput;
2011
+ const _component_el_button = ElButton;
2012
+ return openBlock(), createElementBlock(Fragment, null, [
2013
+ _hoisted_1$1,
2014
+ createElementVNode("div", null, [
2015
+ createVNode(_component_el_input, {
2016
+ modelValue: msg.value,
2017
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => msg.value = $event),
2018
+ style: { "width": "40%" }
2019
+ }, null, 8, ["modelValue"]),
2020
+ createElementVNode("div", null, "This is input message: " + toDisplayString(msg.value), 1)
2021
+ ]),
2022
+ createElementVNode("div", null, [
2023
+ createVNode(_component_el_button, {
2024
+ type: "primary",
2025
+ onClick: incrementCount
2026
+ }, {
2027
+ default: withCtx(() => [
2028
+ _hoisted_2
2029
+ ]),
2030
+ _: 1
2031
+ }),
2032
+ createElementVNode("div", null, "This is count: " + toDisplayString(count2.value), 1)
2033
+ ])
2034
+ ], 64);
2035
+ };
2036
+ }
2037
+ });
2038
+ /**
2039
+ * Vue Currency Input 2.4.0
2040
+ * (c) 2018-2022 Matthias Stiller
2041
+ * @license MIT
2042
+ */
2043
+ const escapeRegExp = (str) => {
2044
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2045
+ };
2046
+ const removeLeadingZeros = (str) => {
2047
+ return str.replace(/^0+(0$|[^0])/, "$1");
2048
+ };
2049
+ const count = (str, search) => {
2050
+ return (str.match(new RegExp(escapeRegExp(search), "g")) || []).length;
2051
+ };
2052
+ const substringBefore = (str, search) => {
2053
+ return str.substring(0, str.indexOf(search));
2054
+ };
2055
+ var CurrencyDisplay;
2056
+ (function(CurrencyDisplay2) {
2057
+ CurrencyDisplay2["symbol"] = "symbol";
2058
+ CurrencyDisplay2["narrowSymbol"] = "narrowSymbol";
2059
+ CurrencyDisplay2["code"] = "code";
2060
+ CurrencyDisplay2["name"] = "name";
2061
+ CurrencyDisplay2["hidden"] = "hidden";
2062
+ })(CurrencyDisplay || (CurrencyDisplay = {}));
2063
+ var ValueScaling;
2064
+ (function(ValueScaling2) {
2065
+ ValueScaling2["precision"] = "precision";
2066
+ ValueScaling2["thousands"] = "thousands";
2067
+ ValueScaling2["millions"] = "millions";
2068
+ ValueScaling2["billions"] = "billions";
2069
+ })(ValueScaling || (ValueScaling = {}));
2070
+ const DECIMAL_SEPARATORS = [",", ".", "\u066B"];
2071
+ const INTEGER_PATTERN = "(0|[1-9]\\d*)";
2072
+ class CurrencyFormat {
2073
+ constructor(options) {
2074
+ var _a, _b, _c, _d, _e, _f;
2075
+ const { currency, currencyDisplay, locale, precision, accountingSign } = options;
2076
+ this.locale = locale;
2077
+ this.options = {
2078
+ style: "currency",
2079
+ currency,
2080
+ currencySign: accountingSign ? "accounting" : void 0,
2081
+ currencyDisplay: currencyDisplay !== CurrencyDisplay.hidden ? currencyDisplay : void 0
2082
+ };
2083
+ const numberFormat = new Intl.NumberFormat(locale, this.options);
2084
+ const formatParts = numberFormat.formatToParts(123456);
2085
+ this.currency = (_a = formatParts.find(({ type }) => type === "currency")) === null || _a === void 0 ? void 0 : _a.value;
2086
+ this.digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((i) => i.toLocaleString(locale));
2087
+ this.decimalSymbol = (_b = formatParts.find(({ type }) => type === "decimal")) === null || _b === void 0 ? void 0 : _b.value;
2088
+ this.groupingSymbol = (_c = formatParts.find(({ type }) => type === "group")) === null || _c === void 0 ? void 0 : _c.value;
2089
+ this.minusSign = (_d = numberFormat.formatToParts(-1).find(({ type }) => type === "minusSign")) === null || _d === void 0 ? void 0 : _d.value;
2090
+ if (this.decimalSymbol === void 0) {
2091
+ this.minimumFractionDigits = this.maximumFractionDigits = 0;
2092
+ } else if (typeof precision === "number") {
2093
+ this.minimumFractionDigits = this.maximumFractionDigits = precision;
2094
+ } else {
2095
+ this.minimumFractionDigits = (_e = precision === null || precision === void 0 ? void 0 : precision.min) !== null && _e !== void 0 ? _e : numberFormat.resolvedOptions().minimumFractionDigits;
2096
+ this.maximumFractionDigits = (_f = precision === null || precision === void 0 ? void 0 : precision.max) !== null && _f !== void 0 ? _f : numberFormat.resolvedOptions().maximumFractionDigits;
2097
+ }
2098
+ const getPrefix = (str) => {
2099
+ return substringBefore(str, this.digits[1]);
2100
+ };
2101
+ const getSuffix = (str) => {
2102
+ return str.substring(str.lastIndexOf(this.decimalSymbol ? this.digits[0] : this.digits[1]) + 1);
2103
+ };
2104
+ this.prefix = getPrefix(numberFormat.format(1));
2105
+ this.suffix = getSuffix(numberFormat.format(1));
2106
+ this.negativePrefix = getPrefix(numberFormat.format(-1));
2107
+ this.negativeSuffix = getSuffix(numberFormat.format(-1));
2108
+ }
2109
+ parse(str) {
2110
+ if (str) {
2111
+ const negative = this.isNegative(str);
2112
+ str = this.normalizeDigits(str);
2113
+ str = this.stripCurrency(str, negative);
2114
+ str = this.stripSignLiterals(str);
2115
+ const fraction = this.decimalSymbol ? `(?:${escapeRegExp(this.decimalSymbol)}(\\d*))?` : "";
2116
+ const match = this.stripGroupingSeparator(str).match(new RegExp(`^${INTEGER_PATTERN}${fraction}$`));
2117
+ if (match && this.isValidIntegerFormat(this.decimalSymbol ? str.split(this.decimalSymbol)[0] : str, Number(match[1]))) {
2118
+ return Number(`${negative ? "-" : ""}${this.onlyDigits(match[1])}.${this.onlyDigits(match[2] || "")}`);
2119
+ }
2120
+ }
2121
+ return null;
2122
+ }
2123
+ isValidIntegerFormat(formattedNumber, integerNumber) {
2124
+ const options = __spreadProps(__spreadValues({}, this.options), { minimumFractionDigits: 0 });
2125
+ return [
2126
+ this.stripCurrency(this.normalizeDigits(integerNumber.toLocaleString(this.locale, __spreadProps(__spreadValues({}, options), {
2127
+ useGrouping: true
2128
+ }))), false),
2129
+ this.stripCurrency(this.normalizeDigits(integerNumber.toLocaleString(this.locale, __spreadProps(__spreadValues({}, options), {
2130
+ useGrouping: false
2131
+ }))), false)
2132
+ ].includes(formattedNumber);
2133
+ }
2134
+ format(value, options = {
2135
+ minimumFractionDigits: this.minimumFractionDigits,
2136
+ maximumFractionDigits: this.maximumFractionDigits
2137
+ }) {
2138
+ return value != null ? value.toLocaleString(this.locale, __spreadValues(__spreadValues({}, this.options), options)) : "";
2139
+ }
2140
+ toFraction(str) {
2141
+ return `${this.digits[0]}${this.decimalSymbol}${this.onlyLocaleDigits(str.substr(1)).substr(0, this.maximumFractionDigits)}`;
2142
+ }
2143
+ isFractionIncomplete(str) {
2144
+ return !!this.normalizeDigits(this.stripGroupingSeparator(str)).match(new RegExp(`^${INTEGER_PATTERN}${escapeRegExp(this.decimalSymbol)}$`));
2145
+ }
2146
+ isNegative(str) {
2147
+ return str.startsWith(this.negativePrefix) || this.minusSign === void 0 && (str.startsWith("(") || str.startsWith("-")) || this.minusSign !== void 0 && str.replace("-", this.minusSign).startsWith(this.minusSign);
2148
+ }
2149
+ insertCurrency(str, negative) {
2150
+ return `${negative ? this.negativePrefix : this.prefix}${str}${negative ? this.negativeSuffix : this.suffix}`;
2151
+ }
2152
+ stripGroupingSeparator(str) {
2153
+ return this.groupingSymbol !== void 0 ? str.replace(new RegExp(escapeRegExp(this.groupingSymbol), "g"), "") : str;
2154
+ }
2155
+ stripSignLiterals(str) {
2156
+ if (this.minusSign !== void 0) {
2157
+ return str.replace("-", this.minusSign).replace(this.minusSign, "");
2158
+ } else {
2159
+ return str.replace(/[-()]/g, "");
2160
+ }
2161
+ }
2162
+ stripCurrency(str, negative) {
2163
+ return str.replace(negative ? this.negativePrefix : this.prefix, "").replace(negative ? this.negativeSuffix : this.suffix, "");
2164
+ }
2165
+ normalizeDecimalSeparator(str, from) {
2166
+ DECIMAL_SEPARATORS.forEach((s) => {
2167
+ str = str.substr(0, from) + str.substr(from).replace(s, this.decimalSymbol);
2168
+ });
2169
+ return str;
2170
+ }
2171
+ normalizeDigits(str) {
2172
+ if (this.digits[0] !== "0") {
2173
+ this.digits.forEach((digit, index) => {
2174
+ str = str.replace(new RegExp(digit, "g"), String(index));
2175
+ });
2176
+ }
2177
+ return str;
2178
+ }
2179
+ onlyDigits(str) {
2180
+ return this.normalizeDigits(str).replace(/\D+/g, "");
2181
+ }
2182
+ onlyLocaleDigits(str) {
2183
+ return str.replace(new RegExp(`[^${this.digits.join("")}]*`, "g"), "");
2184
+ }
2185
+ }
2186
+ class AbstractInputMask {
2187
+ constructor(currencyFormat) {
2188
+ this.currencyFormat = currencyFormat;
2189
+ }
2190
+ }
2191
+ class DefaultInputMask extends AbstractInputMask {
2192
+ conformToMask(str, previousConformedValue = "") {
2193
+ const negative = this.currencyFormat.isNegative(str);
2194
+ const isEmptyNegativeValue = (str2) => str2 === "" && negative && !(this.currencyFormat.minusSign === void 0 ? previousConformedValue === this.currencyFormat.negativePrefix + this.currencyFormat.negativeSuffix : previousConformedValue === this.currencyFormat.negativePrefix);
2195
+ const checkIncompleteValue = (str2) => {
2196
+ if (isEmptyNegativeValue(str2)) {
2197
+ return "";
2198
+ } else if (this.currencyFormat.maximumFractionDigits > 0) {
2199
+ if (this.currencyFormat.isFractionIncomplete(str2)) {
2200
+ return str2;
2201
+ } else if (str2.startsWith(this.currencyFormat.decimalSymbol)) {
2202
+ return this.currencyFormat.toFraction(str2);
2203
+ }
2204
+ }
2205
+ return null;
2206
+ };
2207
+ let value = str;
2208
+ value = this.currencyFormat.stripCurrency(value, negative);
2209
+ value = this.currencyFormat.stripSignLiterals(value);
2210
+ const incompleteValue = checkIncompleteValue(value);
2211
+ if (incompleteValue != null) {
2212
+ return this.currencyFormat.insertCurrency(incompleteValue, negative);
2213
+ }
2214
+ const [integer, ...fraction] = value.split(this.currencyFormat.decimalSymbol);
2215
+ const integerDigits = removeLeadingZeros(this.currencyFormat.onlyDigits(integer));
2216
+ const fractionDigits = this.currencyFormat.onlyDigits(fraction.join("")).substr(0, this.currencyFormat.maximumFractionDigits);
2217
+ const invalidFraction = fraction.length > 0 && fractionDigits.length === 0;
2218
+ const invalidNegativeValue = integerDigits === "" && negative && (this.currencyFormat.minusSign === void 0 ? previousConformedValue === str.slice(0, -2) + this.currencyFormat.negativeSuffix : previousConformedValue === str.slice(0, -1));
2219
+ if (invalidFraction || invalidNegativeValue || isEmptyNegativeValue(integerDigits)) {
2220
+ return previousConformedValue;
2221
+ } else if (integerDigits.match(/\d+/)) {
2222
+ return {
2223
+ numberValue: Number(`${negative ? "-" : ""}${integerDigits}.${fractionDigits}`),
2224
+ fractionDigits
2225
+ };
2226
+ } else {
2227
+ return "";
2228
+ }
2229
+ }
2230
+ }
2231
+ class AutoDecimalDigitsInputMask extends AbstractInputMask {
2232
+ conformToMask(str, previousConformedValue = "") {
2233
+ if (str === "" || this.currencyFormat.parse(previousConformedValue) === 0 && this.currencyFormat.stripCurrency(previousConformedValue, true).slice(0, -1) === this.currencyFormat.stripCurrency(str, true)) {
2234
+ return "";
2235
+ }
2236
+ const negative = this.currencyFormat.isNegative(str);
2237
+ const numberValue = this.currencyFormat.stripSignLiterals(str) === "" ? -0 : Number(`${negative ? "-" : ""}${removeLeadingZeros(this.currencyFormat.onlyDigits(str))}`) / Math.pow(10, this.currencyFormat.maximumFractionDigits);
2238
+ return {
2239
+ numberValue,
2240
+ fractionDigits: numberValue.toFixed(this.currencyFormat.maximumFractionDigits).slice(-this.currencyFormat.maximumFractionDigits)
2241
+ };
2242
+ }
2243
+ }
2244
+ const DEFAULT_OPTIONS = {
2245
+ locale: void 0,
2246
+ currency: void 0,
2247
+ currencyDisplay: void 0,
2248
+ exportValueAsInteger: false,
2249
+ hideGroupingSeparatorOnFocus: true,
2250
+ hideCurrencySymbolOnFocus: true,
2251
+ hideNegligibleDecimalDigitsOnFocus: true,
2252
+ precision: void 0,
2253
+ autoDecimalDigits: false,
2254
+ valueRange: void 0,
2255
+ autoSign: true,
2256
+ useGrouping: true,
2257
+ valueScaling: void 0
2258
+ };
2259
+ class CurrencyInput {
2260
+ constructor(el, options) {
2261
+ this.el = el;
2262
+ this.numberValue = null;
2263
+ this.addEventListener();
2264
+ this.init(options);
2265
+ this.setValue(this.currencyFormat.parse(this.el.value));
2266
+ }
2267
+ setOptions(options) {
2268
+ this.init(options);
2269
+ this.applyFixedFractionFormat(this.numberValue, true);
2270
+ }
2271
+ getValue() {
2272
+ const numberValue = this.valueScaling && this.numberValue != null ? this.toInteger(this.numberValue, this.valueScaling) : this.numberValue;
2273
+ return { number: numberValue, formatted: this.formattedValue };
2274
+ }
2275
+ setValue(value) {
2276
+ const newValue = this.valueScaling !== void 0 && value != null ? this.toFloat(value, this.valueScaling) : value;
2277
+ if (newValue !== this.numberValue) {
2278
+ this.applyFixedFractionFormat(newValue);
2279
+ }
2280
+ }
2281
+ dispatchEvent(eventName) {
2282
+ this.el.dispatchEvent(new CustomEvent(eventName, { detail: this.getValue() }));
2283
+ }
2284
+ init(options) {
2285
+ this.options = __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options);
2286
+ if (this.options.autoDecimalDigits) {
2287
+ this.options.hideNegligibleDecimalDigitsOnFocus = false;
2288
+ this.el.setAttribute("inputmode", "numeric");
2289
+ } else {
2290
+ this.el.setAttribute("inputmode", "decimal");
2291
+ }
2292
+ this.currencyFormat = new CurrencyFormat(this.options);
2293
+ this.numberMask = this.options.autoDecimalDigits ? new AutoDecimalDigitsInputMask(this.currencyFormat) : new DefaultInputMask(this.currencyFormat);
2294
+ const valueScalingOptions = {
2295
+ [ValueScaling.precision]: this.currencyFormat.maximumFractionDigits,
2296
+ [ValueScaling.thousands]: 3,
2297
+ [ValueScaling.millions]: 6,
2298
+ [ValueScaling.billions]: 9
2299
+ };
2300
+ if (this.options.exportValueAsInteger) {
2301
+ this.valueScaling = valueScalingOptions[ValueScaling.precision];
2302
+ } else {
2303
+ this.valueScaling = this.options.valueScaling ? valueScalingOptions[this.options.valueScaling] : void 0;
2304
+ }
2305
+ this.valueScalingFractionDigits = this.valueScaling !== void 0 && this.options.valueScaling !== ValueScaling.precision ? this.valueScaling + this.currencyFormat.maximumFractionDigits : this.currencyFormat.maximumFractionDigits;
2306
+ this.minValue = this.getMinValue();
2307
+ this.maxValue = this.getMaxValue();
2308
+ }
2309
+ getMinValue() {
2310
+ var _a, _b;
2311
+ let min = this.toFloat(-Number.MAX_SAFE_INTEGER);
2312
+ if (((_a = this.options.valueRange) === null || _a === void 0 ? void 0 : _a.min) !== void 0) {
2313
+ min = Math.max((_b = this.options.valueRange) === null || _b === void 0 ? void 0 : _b.min, this.toFloat(-Number.MAX_SAFE_INTEGER));
2314
+ }
2315
+ if (!this.options.autoSign && min < 0) {
2316
+ min = 0;
2317
+ }
2318
+ return min;
2319
+ }
2320
+ getMaxValue() {
2321
+ var _a, _b;
2322
+ let max = this.toFloat(Number.MAX_SAFE_INTEGER);
2323
+ if (((_a = this.options.valueRange) === null || _a === void 0 ? void 0 : _a.max) !== void 0) {
2324
+ max = Math.min((_b = this.options.valueRange) === null || _b === void 0 ? void 0 : _b.max, this.toFloat(Number.MAX_SAFE_INTEGER));
2325
+ }
2326
+ if (!this.options.autoSign && max < 0) {
2327
+ max = this.toFloat(Number.MAX_SAFE_INTEGER);
2328
+ }
2329
+ return max;
2330
+ }
2331
+ toFloat(value, maxFractionDigits) {
2332
+ return value / Math.pow(10, maxFractionDigits !== null && maxFractionDigits !== void 0 ? maxFractionDigits : this.valueScalingFractionDigits);
2333
+ }
2334
+ toInteger(value, maxFractionDigits) {
2335
+ return Number(value.toFixed(maxFractionDigits !== null && maxFractionDigits !== void 0 ? maxFractionDigits : this.valueScalingFractionDigits).split(".").join(""));
2336
+ }
2337
+ validateValueRange(value) {
2338
+ return value != null ? Math.min(Math.max(value, this.minValue), this.maxValue) : value;
2339
+ }
2340
+ applyFixedFractionFormat(number, forcedChange = false) {
2341
+ this.format(this.currencyFormat.format(this.validateValueRange(number)));
2342
+ if (number !== this.numberValue || forcedChange) {
2343
+ this.dispatchEvent("change");
2344
+ }
2345
+ }
2346
+ format(value, hideNegligibleDecimalDigits = false) {
2347
+ if (value != null) {
2348
+ if (this.decimalSymbolInsertedAt !== void 0) {
2349
+ value = this.currencyFormat.normalizeDecimalSeparator(value, this.decimalSymbolInsertedAt);
2350
+ this.decimalSymbolInsertedAt = void 0;
2351
+ }
2352
+ const conformedValue = this.numberMask.conformToMask(value, this.formattedValue);
2353
+ let formattedValue;
2354
+ if (typeof conformedValue === "object") {
2355
+ const { numberValue, fractionDigits } = conformedValue;
2356
+ let { maximumFractionDigits, minimumFractionDigits } = this.currencyFormat;
2357
+ if (this.focus) {
2358
+ minimumFractionDigits = hideNegligibleDecimalDigits ? fractionDigits.replace(/0+$/, "").length : Math.min(maximumFractionDigits, fractionDigits.length);
2359
+ } else if (Number.isInteger(numberValue) && !this.options.autoDecimalDigits && (this.options.precision === void 0 || minimumFractionDigits === 0)) {
2360
+ minimumFractionDigits = maximumFractionDigits = 0;
2361
+ }
2362
+ formattedValue = this.toInteger(Math.abs(numberValue)) > Number.MAX_SAFE_INTEGER ? this.formattedValue : this.currencyFormat.format(numberValue, {
2363
+ useGrouping: this.options.useGrouping && !(this.focus && this.options.hideGroupingSeparatorOnFocus),
2364
+ minimumFractionDigits,
2365
+ maximumFractionDigits
2366
+ });
2367
+ } else {
2368
+ formattedValue = conformedValue;
2369
+ }
2370
+ if (this.options.autoSign) {
2371
+ if (this.maxValue <= 0 && !this.currencyFormat.isNegative(formattedValue) && this.currencyFormat.parse(formattedValue) !== 0) {
2372
+ formattedValue = formattedValue.replace(this.currencyFormat.prefix, this.currencyFormat.negativePrefix);
2373
+ }
2374
+ if (this.minValue >= 0) {
2375
+ formattedValue = formattedValue.replace(this.currencyFormat.negativePrefix, this.currencyFormat.prefix);
2376
+ }
2377
+ }
2378
+ if (this.options.currencyDisplay === CurrencyDisplay.hidden || this.focus && this.options.hideCurrencySymbolOnFocus) {
2379
+ formattedValue = formattedValue.replace(this.currencyFormat.negativePrefix, this.currencyFormat.minusSign !== void 0 ? this.currencyFormat.minusSign : "(").replace(this.currencyFormat.negativeSuffix, this.currencyFormat.minusSign !== void 0 ? "" : ")").replace(this.currencyFormat.prefix, "").replace(this.currencyFormat.suffix, "");
2380
+ }
2381
+ this.el.value = formattedValue;
2382
+ this.numberValue = this.currencyFormat.parse(formattedValue);
2383
+ } else {
2384
+ this.el.value = "";
2385
+ this.numberValue = null;
2386
+ }
2387
+ this.formattedValue = this.el.value;
2388
+ this.dispatchEvent("input");
2389
+ }
2390
+ addEventListener() {
2391
+ this.el.addEventListener("input", (e) => {
2392
+ if (!e.detail) {
2393
+ const { value, selectionStart } = this.el;
2394
+ const inputEvent = e;
2395
+ if (selectionStart && inputEvent.data && DECIMAL_SEPARATORS.includes(inputEvent.data)) {
2396
+ this.decimalSymbolInsertedAt = selectionStart - 1;
2397
+ }
2398
+ this.format(value);
2399
+ if (this.focus && selectionStart != null) {
2400
+ const getCaretPositionAfterFormat = () => {
2401
+ const { prefix, suffix, decimalSymbol, maximumFractionDigits, groupingSymbol } = this.currencyFormat;
2402
+ let caretPositionFromLeft = value.length - selectionStart;
2403
+ const newValueLength = this.formattedValue.length;
2404
+ if (this.currencyFormat.minusSign === void 0 && (value.startsWith("(") || value.startsWith("-")) && !value.endsWith(")")) {
2405
+ return newValueLength - this.currencyFormat.negativeSuffix.length > 1 ? this.formattedValue.substring(selectionStart).length : 1;
2406
+ }
2407
+ if (this.formattedValue.substr(selectionStart, 1) === groupingSymbol && count(this.formattedValue, groupingSymbol) === count(value, groupingSymbol) + 1) {
2408
+ return newValueLength - caretPositionFromLeft - 1;
2409
+ }
2410
+ if (newValueLength < caretPositionFromLeft) {
2411
+ return selectionStart;
2412
+ }
2413
+ if (decimalSymbol !== void 0 && value.indexOf(decimalSymbol) !== -1) {
2414
+ const decimalSymbolPosition = value.indexOf(decimalSymbol) + 1;
2415
+ if (Math.abs(newValueLength - value.length) > 1 && selectionStart <= decimalSymbolPosition) {
2416
+ return this.formattedValue.indexOf(decimalSymbol) + 1;
2417
+ } else {
2418
+ if (!this.options.autoDecimalDigits && selectionStart > decimalSymbolPosition) {
2419
+ if (this.currencyFormat.onlyDigits(value.substr(decimalSymbolPosition)).length - 1 === maximumFractionDigits) {
2420
+ caretPositionFromLeft -= 1;
2421
+ }
2422
+ }
2423
+ }
2424
+ }
2425
+ return this.options.hideCurrencySymbolOnFocus || this.options.currencyDisplay === CurrencyDisplay.hidden ? newValueLength - caretPositionFromLeft : Math.max(newValueLength - Math.max(caretPositionFromLeft, suffix.length), prefix.length);
2426
+ };
2427
+ this.setCaretPosition(getCaretPositionAfterFormat());
2428
+ }
2429
+ }
2430
+ }, { capture: true });
2431
+ this.el.addEventListener("focus", () => {
2432
+ this.focus = true;
2433
+ setTimeout(() => {
2434
+ const { value, selectionStart, selectionEnd } = this.el;
2435
+ this.format(value, this.options.hideNegligibleDecimalDigitsOnFocus);
2436
+ if (selectionStart != null && selectionEnd != null && Math.abs(selectionStart - selectionEnd) > 0) {
2437
+ this.setCaretPosition(0, this.el.value.length);
2438
+ } else if (selectionStart != null) {
2439
+ const caretPositionOnFocus = this.getCaretPositionOnFocus(value, selectionStart);
2440
+ this.setCaretPosition(caretPositionOnFocus);
2441
+ }
2442
+ });
2443
+ });
2444
+ this.el.addEventListener("blur", () => {
2445
+ this.focus = false;
2446
+ this.applyFixedFractionFormat(this.numberValue);
2447
+ });
2448
+ this.el.addEventListener("change", (e) => {
2449
+ if (!e.detail) {
2450
+ this.dispatchEvent("change");
2451
+ }
2452
+ }, { capture: true });
2453
+ }
2454
+ getCaretPositionOnFocus(value, selectionStart) {
2455
+ if (this.numberValue == null) {
2456
+ return selectionStart;
2457
+ }
2458
+ const { prefix, negativePrefix, suffix, negativeSuffix, groupingSymbol, currency } = this.currencyFormat;
2459
+ const isNegative = this.numberValue < 0;
2460
+ const currentPrefix = isNegative ? negativePrefix : prefix;
2461
+ const prefixLength = currentPrefix.length;
2462
+ if (this.options.hideCurrencySymbolOnFocus || this.options.currencyDisplay === CurrencyDisplay.hidden) {
2463
+ if (isNegative) {
2464
+ if (selectionStart <= 1) {
2465
+ return 1;
2466
+ } else if (value.endsWith(")") && selectionStart > value.indexOf(")")) {
2467
+ return this.formattedValue.length - 1;
2468
+ }
2469
+ }
2470
+ } else {
2471
+ const suffixLength = isNegative ? negativeSuffix.length : suffix.length;
2472
+ if (selectionStart >= value.length - suffixLength) {
2473
+ return this.formattedValue.length - suffixLength;
2474
+ } else if (selectionStart < prefixLength) {
2475
+ return prefixLength;
2476
+ }
2477
+ }
2478
+ let result = selectionStart;
2479
+ if (this.options.hideCurrencySymbolOnFocus && this.options.currencyDisplay !== CurrencyDisplay.hidden && selectionStart >= prefixLength && currency !== void 0 && currentPrefix.includes(currency)) {
2480
+ result -= prefixLength;
2481
+ if (isNegative) {
2482
+ result += 1;
2483
+ }
2484
+ }
2485
+ if (this.options.hideGroupingSeparatorOnFocus && groupingSymbol !== void 0) {
2486
+ result -= count(value.substring(0, selectionStart), groupingSymbol);
2487
+ }
2488
+ return result;
2489
+ }
2490
+ setCaretPosition(start, end = start) {
2491
+ this.el.setSelectionRange(start, end);
2492
+ }
2493
+ }
2494
+ const findInput = (el) => (el === null || el === void 0 ? void 0 : el.matches("input")) ? el : el === null || el === void 0 ? void 0 : el.querySelector("input");
2495
+ var useCurrencyInput = (options) => {
2496
+ var _a;
2497
+ let numberInput;
2498
+ let input2;
2499
+ const inputRef = ref(null);
2500
+ const formattedValue = ref(null);
2501
+ const instance = getCurrentInstance();
2502
+ const emit = (event, value) => instance === null || instance === void 0 ? void 0 : instance.emit(event, value);
2503
+ const lazyModel = (_a = instance === null || instance === void 0 ? void 0 : instance.attrs.modelModifiers) === null || _a === void 0 ? void 0 : _a.lazy;
2504
+ const numberValue = computed(() => instance === null || instance === void 0 ? void 0 : instance.props["modelValue"]);
2505
+ const inputEvent = "update:modelValue";
2506
+ const changeEvent = lazyModel ? "update:modelValue" : "change";
2507
+ const hasInputEventListener = !lazyModel;
2508
+ const hasChangeEventListener = lazyModel || !(instance === null || instance === void 0 ? void 0 : instance.attrs.onChange);
2509
+ const onInput = (e) => {
2510
+ if (e.detail) {
2511
+ if (numberValue.value !== e.detail.number) {
2512
+ emit(inputEvent, e.detail.number);
2513
+ }
2514
+ formattedValue.value = e.detail.formatted;
2515
+ }
2516
+ };
2517
+ const onChange = (e) => {
2518
+ if (e.detail) {
2519
+ emit(changeEvent, e.detail.number);
2520
+ formattedValue.value = e.detail.formatted;
2521
+ }
2522
+ };
2523
+ watch(inputRef, (value) => {
2524
+ var _a2, _b;
2525
+ if (value) {
2526
+ input2 = findInput((_b = (_a2 = value) === null || _a2 === void 0 ? void 0 : _a2.$el) !== null && _b !== void 0 ? _b : value);
2527
+ if (input2) {
2528
+ numberInput = new CurrencyInput(input2, options);
2529
+ if (hasInputEventListener) {
2530
+ input2.addEventListener("input", onInput);
2531
+ }
2532
+ if (hasChangeEventListener) {
2533
+ input2.addEventListener("change", onChange);
2534
+ }
2535
+ numberInput.setValue(numberValue.value);
2536
+ } else {
2537
+ console.error('No input element found. Please make sure that the "inputRef" template ref is properly assigned.');
2538
+ }
2539
+ } else {
2540
+ numberInput = null;
2541
+ }
2542
+ });
2543
+ onUnmounted(() => {
2544
+ if (hasInputEventListener) {
2545
+ input2 === null || input2 === void 0 ? void 0 : input2.removeEventListener("input", onInput);
2546
+ }
2547
+ if (hasChangeEventListener) {
2548
+ input2 === null || input2 === void 0 ? void 0 : input2.removeEventListener("change", onChange);
2549
+ }
2550
+ });
2551
+ return {
2552
+ inputRef,
2553
+ formattedValue,
2554
+ setValue: (value) => numberInput === null || numberInput === void 0 ? void 0 : numberInput.setValue(value),
2555
+ setOptions: (options2) => numberInput === null || numberInput === void 0 ? void 0 : numberInput.setOptions(options2)
2556
+ };
2557
+ };
2558
+ var plCurrency_vue_vue_type_style_index_0_lang = "";
2559
+ const _hoisted_1 = /* @__PURE__ */ createElementVNode("span", { class: "pl-currency__rub-icon" }, "\u20BD", -1);
2560
+ const __default__ = {
2561
+ name: "PlCurrency"
2562
+ };
2563
+ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
2564
+ props: {
2565
+ modelValue: String,
2566
+ width: String
2567
+ },
2568
+ emits: ["update:modelValue"],
2569
+ setup(__props, { emit }) {
2570
+ const innerValue = ref(null);
2571
+ const options = reactive({
2572
+ currency: "EUR",
2573
+ currencyDisplay: "hidden",
2574
+ precision: 2
2575
+ });
2576
+ const { inputRef } = useCurrencyInput(options);
2577
+ watch(innerValue, (newValue) => {
2578
+ emit("update:modelValue", newValue);
2579
+ });
2580
+ return (_ctx, _cache) => {
2581
+ const _component_el_input = ElInput;
2582
+ return openBlock(), createBlock(_component_el_input, mergeProps({
2583
+ style: `width: ${__props.width};`
2584
+ }, _ctx.$attrs, {
2585
+ ref_key: "inputRef",
2586
+ ref: inputRef,
2587
+ modelValue: innerValue.value,
2588
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => innerValue.value = $event),
2589
+ class: "pl-currency"
2590
+ }), {
2591
+ append: withCtx(() => [
2592
+ _hoisted_1
2593
+ ]),
2594
+ _: 1
2595
+ }, 16, ["style", "modelValue"]);
2596
+ };
2597
+ }
2598
+ });
2599
+ export { _sfc_main as PlCurrency, _sfc_main$1 as TestViteNpmComponent };