@cling-se/widget 0.14.4 → 0.14.6

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 (129) hide show
  1. package/dist/AddClientCallout-C7abPZ87.js +46 -0
  2. package/dist/AnswerModal-CsA2pl2P.js +3874 -0
  3. package/dist/AttachmentItem-Da1-7xwf.js +78 -0
  4. package/dist/BaseDatePicker-k9zlSi5J.js +3183 -0
  5. package/dist/BaseUpload-BUrXX3fT.js +1977 -0
  6. package/dist/BlockMedia-CYI07qAn.js +76 -0
  7. package/dist/CCallout-Qwae66vo.js +59 -0
  8. package/dist/CCurrencyDropdown-Y_u0hgBx.js +246 -0
  9. package/dist/CDropdownItem-CXJ4xD8W.js +538 -0
  10. package/dist/CField.vue_vue_type_style_index_0_lang-l0sNRNKZ.js +1 -0
  11. package/dist/CFormField--m3PvQuT.js +241 -0
  12. package/dist/CPhoneFormat-Qg6MkDVP.js +62 -0
  13. package/dist/CPriceInput-Dlx44UrR.js +112 -0
  14. package/dist/CTabs.vue_vue_type_style_index_0_scoped_b7262014_lang-l0sNRNKZ.js +1 -0
  15. package/dist/ClientAutocomplete-BKKc_br6.js +78 -0
  16. package/dist/ClientModal-CVZFb1Br.js +625 -0
  17. package/dist/ColorPicker-Bo3s3Esp.js +2879 -0
  18. package/dist/CompanyModal-DadjAioS.js +141 -0
  19. package/dist/ContentWrapper-BC3ZBQW9.js +183 -0
  20. package/dist/CoverBlockSettings-B484eE4g.js +275 -0
  21. package/dist/DocAnswer-CcYryOWI.js +36 -0
  22. package/dist/DocDetails-BigsoEWL.js +246 -0
  23. package/dist/DocForm-DlN0eNWt.js +7273 -0
  24. package/dist/DocFormSend-TqKo210I.js +143 -0
  25. package/dist/DocLinks-DSo54vDn.js +38 -0
  26. package/dist/DocModalBase-XlM1SThW.js +28 -0
  27. package/dist/DocPrint-tD0Vd9Sw.js +240 -0
  28. package/dist/DocReceipt-CDHPrhXM.js +210 -0
  29. package/dist/DocSendReminder-C62RhltH.js +137 -0
  30. package/dist/DocTextEditor-VjhV9IRp.js +17181 -0
  31. package/dist/DocTimeline-LcW4z3nC.js +481 -0
  32. package/dist/DocumentClient-CqbTRdpB.js +136 -0
  33. package/dist/DocumentLayout-Dbf8_01r.js +4909 -0
  34. package/dist/DocumentLogotype-DXYnBedV.js +87 -0
  35. package/dist/DocumentVoided-vH1Ti5lZ.js +25 -0
  36. package/dist/EmbedInput-D9qP8OnY.js +113 -0
  37. package/dist/EmbedSettings-DISuNqJT.js +72 -0
  38. package/dist/ErrorCallout-CCtCVwSh.js +28 -0
  39. package/dist/FilePreviewModal-BjhNyb6L.js +81 -0
  40. package/dist/Flag-Dhukv9_J.js +114 -0
  41. package/dist/HeaderSettings-CK4SkB1x.js +392 -0
  42. package/dist/ImageSelectModal-DnvPZzXx.js +84 -0
  43. package/dist/ImageUploadWrapper-B7cNMu5a.js +1604 -0
  44. package/dist/Index-B3HoK_cZ.js +84 -0
  45. package/dist/Index-B3aucNji.js +25 -0
  46. package/dist/Index-B9H5MMHb.js +62 -0
  47. package/dist/Index-BAYdvT-t.js +754 -0
  48. package/dist/Index-BLeQprjq.js +46 -0
  49. package/dist/Index-BOyvQlng.js +154 -0
  50. package/dist/Index-BVsw2tak.js +70 -0
  51. package/dist/Index-BY1UKGEO.js +98 -0
  52. package/dist/Index-Bh0kMSsA.js +107 -0
  53. package/dist/Index-BlQSM7tC.js +144 -0
  54. package/dist/Index-BpcJBGGd.js +642 -0
  55. package/dist/Index-Bs8wprXw.js +58 -0
  56. package/dist/Index-BvZZAvFd.js +21 -0
  57. package/dist/Index-CFo-3Y5Q.js +26 -0
  58. package/dist/Index-CNvp5K3L.js +559 -0
  59. package/dist/Index-CPJVx14x.js +171 -0
  60. package/dist/Index-CQ325eVT.js +140 -0
  61. package/dist/Index-CWrDtcfT.js +49 -0
  62. package/dist/Index-CyJnSvDR.js +223 -0
  63. package/dist/Index-D6bc7lg4.js +52 -0
  64. package/dist/Index-DCR8ev4U.js +33 -0
  65. package/dist/Index-DGQSB9cH.js +24 -0
  66. package/dist/Index-DXAvlq74.js +292 -0
  67. package/dist/Index-D_rfst8y.js +45 -0
  68. package/dist/Index-Dm8xMFGg.js +61 -0
  69. package/dist/Index-DtSSgtxB.js +55 -0
  70. package/dist/Index-DuTw9vhb.js +77 -0
  71. package/dist/Index-Dw26jtGV.js +31 -0
  72. package/dist/Index-OxN73_fO.js +32 -0
  73. package/dist/Index-S-FHG7_k.js +2402 -0
  74. package/dist/Index-ZFkitzfq.js +69 -0
  75. package/dist/Index-dyWK9jgr.js +25 -0
  76. package/dist/Index-gb11ngPS.js +57 -0
  77. package/dist/Index-lKk_XKJ3.js +150 -0
  78. package/dist/InputToggleRow-DSSvhPKA.js +57 -0
  79. package/dist/ManualPopover-lpJYSkw5.js +58 -0
  80. package/dist/MediaWrapper-BQ22FA2B.js +23 -0
  81. package/dist/NotBindingText-JxwzZLPP.js +32 -0
  82. package/dist/PackageGroup-BLSMSUDz.js +699 -0
  83. package/dist/PdfTerms-DtutjM5Y.js +36 -0
  84. package/dist/PdfViewer-BsxcZI_x.js +374 -0
  85. package/dist/PlainHtml-BMPZs2fT.js +20 -0
  86. package/dist/PriceHeader-BRYY01H2.js +339 -0
  87. package/dist/SearchApi-6001iFxU.js +161 -0
  88. package/dist/Setup-cw6jMI9M.js +50 -0
  89. package/dist/SmartList-q6H-uLbm.js +83 -0
  90. package/dist/TermsSettings-DWvaPneu.js +102 -0
  91. package/dist/ThemeColorRow-BXWnvfz-.js +67 -0
  92. package/dist/ToggleBinding-DydtwpNG.js +38 -0
  93. package/dist/UploadModal-D_EDKHGD.js +95 -0
  94. package/dist/VideoPlayerInput-B9yzUeBW.js +93 -0
  95. package/dist/VideoPlayerSettings-Bvp9l0yj.js +61 -0
  96. package/dist/VideoSelectModal-DY3N4JiS.js +100 -0
  97. package/dist/anime.es-BrPTThYb.js +858 -0
  98. package/dist/answerDocumentMixin-BYZPU_R-.js +51 -0
  99. package/dist/color-TdtKxwVa.js +19 -0
  100. package/dist/debounce-BPnlzNwd.js +84 -0
  101. package/dist/dom-CJxkno7i.js +91 -0
  102. package/dist/favicon.ico +0 -0
  103. package/dist/focusDrawerMixin-DC9Oa1i7.js +22 -0
  104. package/dist/formComponentsInstall-CEW6TK6z.js +2499 -0
  105. package/dist/formDrawerState-CAzvSMiQ.js +20 -0
  106. package/dist/formValidationMixin-D7zXxCpC.js +49 -0
  107. package/dist/i18nMessages-Chz_lxGG.js +17 -0
  108. package/dist/index-B9WDC3Xe.js +166 -0
  109. package/dist/index-BCMaUC5r.js +3916 -0
  110. package/dist/index-BDMI4NVY.js +492 -0
  111. package/dist/index-BbscgdRg.js +81 -0
  112. package/dist/index-CLUljEDI.js +347 -0
  113. package/dist/index-SxyZvewN.js +102 -0
  114. package/dist/index.es.js +35 -0
  115. package/dist/index.umd.js +3148 -0
  116. package/dist/main-CQBEuZk9.js +56739 -0
  117. package/dist/mapFormMixin-DlFcgwhm.js +72 -0
  118. package/dist/omit-BWy0Zhd3.js +31 -0
  119. package/dist/publicSenderState-CvOcFv2U.js +21 -0
  120. package/dist/splitpanes-BHUVsCZF.js +382 -0
  121. package/dist/style.css +4 -0
  122. package/dist/throttle-BrC8eGjQ.js +18 -0
  123. package/dist/tinycolor-PhFP695w.js +633 -0
  124. package/dist/tippy.esm-7dmKOUvu.js +1799 -0
  125. package/dist/utils-NBLgNGHR.js +108 -0
  126. package/dist/vuedraggable.umd-ByfH7ZxC.js +3161 -0
  127. package/dist/vuex.esm-DKGl8mcw.js +467 -0
  128. package/package.json +1 -1
  129. package/vite.config.ts +0 -1
@@ -0,0 +1,2402 @@
1
+ import { m as y } from "./mapFormMixin-DlFcgwhm.js";
2
+ import { E as P } from "./ErrorCallout-CCtCVwSh.js";
3
+ import { aF as L, aG as S, aH as E, aI as z, aJ as B, aK as W, k as F, aL as j, n as u, g as p, w as k, aC as N, aM as w, aN as H, r as C, an as f, ae as q, aO as U, ao as G, aP as K, aQ as Y, aR as T, p as Z, b as o, T as g, z as J, B as Q, aS as X, t as ee, a6 as te } from "./main-CQBEuZk9.js";
4
+ import { m as h, a as v } from "./vuex.esm-DKGl8mcw.js";
5
+ import { T as ie } from "./DocTextEditor-VjhV9IRp.js";
6
+ import { W as ae } from "./DocumentLayout-Dbf8_01r.js";
7
+ import { o as V } from "./omit-BWy0Zhd3.js";
8
+ import { d as se } from "./vuedraggable.umd-ByfH7ZxC.js";
9
+ import { C as x } from "./CPriceInput-Dlx44UrR.js";
10
+ import { S as ne } from "./SearchApi-6001iFxU.js";
11
+ import { v as re } from "./index-BDMI4NVY.js";
12
+ import { w as oe } from "./CDropdownItem-CXJ4xD8W.js";
13
+ const ce = [
14
+ "unit",
15
+ "m2",
16
+ "hour",
17
+ "m",
18
+ "m3",
19
+ "day",
20
+ "kg",
21
+ "litre",
22
+ "km",
23
+ "mile",
24
+ "month",
25
+ "week",
26
+ "ton",
27
+ "year",
28
+ "kWh"
29
+ ];
30
+ function le() {
31
+ }
32
+ var ue = le, b = L, de = ue, pe = S, he = 1 / 0, me = b && 1 / pe(new b([, -0]))[1] == he ? function(a) {
33
+ return new b(a);
34
+ } : de, fe = me, ve = E, ge = z, ye = B, _e = W, ke = fe, $e = S, xe = 200;
35
+ function be(a, e, t) {
36
+ var i = -1, n = ge, s = a.length, r = !0, c = [], l = c;
37
+ if (t)
38
+ r = !1, n = ye;
39
+ else if (s >= xe) {
40
+ var _ = e ? null : ke(a);
41
+ if (_)
42
+ return $e(_);
43
+ r = !1, n = _e, l = new ve();
44
+ } else
45
+ l = e ? [] : c;
46
+ e:
47
+ for (; ++i < s; ) {
48
+ var d = a[i], m = e ? e(d) : d;
49
+ if (d = t || d !== 0 ? d : 0, r && m === m) {
50
+ for (var I = l.length; I--; )
51
+ if (l[I] === m)
52
+ continue e;
53
+ e && l.push(m), c.push(d);
54
+ } else
55
+ n(l, m, t) || (l !== c && l.push(m), c.push(d));
56
+ }
57
+ return c;
58
+ }
59
+ var we = be, Ce = j, Te = we;
60
+ function Ie(a, e) {
61
+ return a && a.length ? Te(a, Ce(e)) : [];
62
+ }
63
+ var Ae = Ie;
64
+ const Pe = /* @__PURE__ */ F(Ae), Se = {
65
+ name: "PackageGroupSelect",
66
+ i18nOptions: {
67
+ namespaces: "PackageGroupSelect",
68
+ messages: {
69
+ en: {
70
+ title: "What do you want to offer?",
71
+ typeOptions: {
72
+ single: {
73
+ title: "Single Option",
74
+ subTitle: "Offer one package."
75
+ },
76
+ radio: {
77
+ title: "Packages",
78
+ subTitle: "Offer several packages and let your client choose <strong>one<strong>."
79
+ },
80
+ checkbox: {
81
+ title: "Multi Options",
82
+ subTitle: "Offer many packages and let your client select <strong>multiple</strong> ones."
83
+ }
84
+ }
85
+ },
86
+ sv: {
87
+ title: "Vad vill du erbjuda för prisförslag?",
88
+ typeOptions: {
89
+ single: {
90
+ title: "Ett alternativ",
91
+ subTitle: "Erbjud ett paket."
92
+ },
93
+ radio: {
94
+ title: "Paket",
95
+ subTitle: "Erbjud flera paket och låt din kund välja <strong>ett</strong> av paketen."
96
+ },
97
+ checkbox: {
98
+ title: "Flera val",
99
+ subTitle: "Erbjud många paket som din kund välja <strong>flera</strong> utav."
100
+ }
101
+ }
102
+ }
103
+ }
104
+ },
105
+ inject: ["parentSize"],
106
+ data() {
107
+ return {
108
+ options: [
109
+ {
110
+ value: "single",
111
+ background: "hsl(209, 94%, 73%)",
112
+ title: this.$t("typeOptions.single.title"),
113
+ subTitle: this.$t("typeOptions.single.subTitle")
114
+ },
115
+ {
116
+ value: "radio",
117
+ background: "hsl(222, 96%, 73%)",
118
+ title: this.$t("typeOptions.radio.title"),
119
+ subTitle: this.$t("typeOptions.radio.subTitle")
120
+ },
121
+ {
122
+ value: "checkbox",
123
+ background: "hsl(241, 95%, 73%)",
124
+ title: this.$t("typeOptions.checkbox.title"),
125
+ subTitle: this.$t("typeOptions.checkbox.subTitle")
126
+ }
127
+ ]
128
+ };
129
+ }
130
+ };
131
+ var Ve = function() {
132
+ var e = this, t = e._self._c;
133
+ return t("div", { staticClass: "font-inter", staticStyle: { padding: "calc(2 * var(--rem)) 0 calc(1 * var(--rem)) 0", color: "#111" } }, [t("div", { staticStyle: { "font-size": "18px", "font-weight": "600", "text-align": "center", "margin-bottom": "calc(1.5 * var(--rem))" } }, [e._v(" " + e._s(e.$t("title")) + " ")]), t("div", [t("div", { staticClass: "options", class: { "is-700-or-less": e.parentSize.width <= 700 } }, e._l(e.options, function(i, n) {
134
+ return t("div", { key: n, staticClass: "package-group-option", style: { backgroundColor: i.background }, on: { click: function(s) {
135
+ return e.$emit("input", i.value);
136
+ } } }, [t("div", { staticClass: "package-group-option__illustration" }, [i.value === "single" ? t("div", { staticClass: "package-group-option__illustration-card animate" }, [e._m(0, !0)]) : e._e(), i.value === "radio" ? e._l(3, function(s) {
137
+ return t("div", { key: s, staticClass: "package-group-option__illustration-card", class: { animate: s === 2 } }, [t("div", { staticStyle: { width: "8px", height: "8px", "border-radius": "50%", "margin-right": "10px" }, style: s === 2 && {
138
+ boxShadow: `0 0 0 1px white, 0 0 0 2px ${i.background}`,
139
+ backgroundColor: i.background
140
+ } }), e._m(1, !0)]);
141
+ }) : e._e(), i.value === "checkbox" ? e._l(3, function(s) {
142
+ return t("div", { key: s, staticClass: "package-group-option__illustration-card", class: { animate: s !== 3 } }, [t("div", { staticStyle: { height: "12px", width: "12px", "border-radius": "2px", "background-color": "hsl(0, 0%, 76%)", "margin-right": "10px", color: "white", padding: "1px", display: "inline-flex", "align-items": "center", "justify-content": "center" }, style: s !== 3 && { backgroundColor: i.background } }, [t("CIcon", { attrs: { type: s !== 3 ? "check" : "empty", "stroke-width": "5", size: "8" } })], 1), e._m(2, !0)]);
143
+ }) : e._e()], 2), t("div", [t("div", { staticClass: "package-group-option__title" }, [e._v(" " + e._s(i.title) + " ")]), t("div", { staticClass: "package-group-option__subtitle", domProps: { innerHTML: e._s(i.subTitle) } })])]);
144
+ }), 0)])]);
145
+ }, Re = [function() {
146
+ var a = this, e = a._self._c;
147
+ return e("div", { staticStyle: { flex: "1 1 auto" } }, [e("div", { staticClass: "bg-gray-100", staticStyle: { width: "40%", height: "10px", "margin-bottom": "8px" } }), e("div", { staticClass: "bg-gray-100", staticStyle: { width: "80%", height: "10px" } })]);
148
+ }, function() {
149
+ var a = this, e = a._self._c;
150
+ return e("div", { staticStyle: { flex: "1 1 auto" } }, [e("div", { staticClass: "bg-gray-100", staticStyle: { width: "40%", height: "10px", "margin-bottom": "8px" } }), e("div", { staticClass: "bg-gray-100", staticStyle: { width: "80%", height: "10px" } })]);
151
+ }, function() {
152
+ var a = this, e = a._self._c;
153
+ return e("div", { staticStyle: { flex: "1 1 auto" } }, [e("div", { staticClass: "bg-gray-100", staticStyle: { width: "40%", height: "10px", "margin-bottom": "8px" } }), e("div", { staticClass: "bg-gray-100", staticStyle: { width: "80%", height: "10px" } })]);
154
+ }], De = /* @__PURE__ */ u(
155
+ Se,
156
+ Ve,
157
+ Re,
158
+ !1,
159
+ null,
160
+ "38a3147b"
161
+ );
162
+ const Oe = De.exports, Me = {
163
+ name: "ArticleAutocomplete",
164
+ components: {
165
+ SearchApi: ne
166
+ },
167
+ mixins: [y([])],
168
+ props: {
169
+ tag: {
170
+ type: String,
171
+ default: null
172
+ },
173
+ value: {
174
+ type: String,
175
+ required: !0
176
+ },
177
+ placement: {
178
+ type: String,
179
+ default: "bottom-start"
180
+ }
181
+ },
182
+ data() {
183
+ return {
184
+ isFocus: !1,
185
+ isOpen: !1,
186
+ selectedIndex: 0,
187
+ searchResults: []
188
+ };
189
+ },
190
+ computed: {
191
+ ...h({
192
+ articleData: "articles/articles",
193
+ ids: "articles/articleIdList"
194
+ }),
195
+ whiteList() {
196
+ const a = [];
197
+ if (this.$refs.dropdown !== void 0) {
198
+ const e = this.$refs.dropdown.querySelectorAll("*");
199
+ for (const t of e)
200
+ a.push(t);
201
+ }
202
+ if (this.$refs.input !== void 0) {
203
+ const e = this.$refs.input.$el.querySelectorAll("*");
204
+ for (const t of e)
205
+ a.push(t);
206
+ }
207
+ return a;
208
+ }
209
+ },
210
+ watch: {
211
+ searchResults(a, e) {
212
+ a.length !== e.length && (this.selectedIndex = 0);
213
+ }
214
+ },
215
+ created() {
216
+ document.addEventListener("click", this.onClickOutside, { passive: !0 });
217
+ },
218
+ beforeDestroy() {
219
+ document.removeEventListener("click", this.onClickOutside, {
220
+ passive: !0
221
+ });
222
+ },
223
+ methods: {
224
+ ...v({
225
+ loadArticles: p.LOAD_ARTICLES
226
+ }),
227
+ priceFormat: k,
228
+ search(a, e) {
229
+ this.$emit("input", e), !this.viewSettings.isPublicForm && a({
230
+ q: e,
231
+ cb: ({ article: t = [], extensionArticle: i = [] }) => {
232
+ this.searchResults = [
233
+ ...t.sort((n, s) => n.usedTimes > s.usedTimes ? -1 : 1),
234
+ ...i
235
+ ], !this.isOpen && this.searchResults.length && this.showResults();
236
+ }
237
+ });
238
+ },
239
+ // Function consumed by parent
240
+ focus() {
241
+ this.$refs.input.focus();
242
+ },
243
+ onFocus(a) {
244
+ this.isFocus = !0, this.$emit("focus", a);
245
+ },
246
+ onBlur(a) {
247
+ this.isFocus = !1, this.$emit("blur", a);
248
+ },
249
+ showResults() {
250
+ this.isOpen = !0;
251
+ },
252
+ hideResults() {
253
+ this.isOpen = !1;
254
+ },
255
+ onSelect(a) {
256
+ this.$emit("select", a), this.hideResults(), this.$refs.input && this.$refs.input.blur();
257
+ },
258
+ onClickOutside(a) {
259
+ this.whiteList.indexOf(a.target) < 0 && this.hideResults();
260
+ },
261
+ onKeydown({ keyCode: a }) {
262
+ if (this.isOpen) {
263
+ switch (a) {
264
+ case 38:
265
+ this.selectedIndex > 0 && this.selectedIndex--;
266
+ break;
267
+ case 40:
268
+ this.selectedIndex < this.searchResults.length - 1 && this.selectedIndex++;
269
+ break;
270
+ case 13:
271
+ this.searchResults[this.selectedIndex] && (this.onSelect(this.searchResults[this.selectedIndex]), this.searchResults = []);
272
+ break;
273
+ }
274
+ this.scrollToHighlighted();
275
+ }
276
+ },
277
+ scrollToHighlighted() {
278
+ !this.$refs.dropdown || !this.$refs.dropdown.children || !this.$refs.dropdown.children[this.selectedIndex] || this.$refs.dropdown.children[this.selectedIndex].scrollIntoView({
279
+ block: "nearest"
280
+ });
281
+ }
282
+ }
283
+ };
284
+ var Le = function() {
285
+ var e = this, t = e._self._c;
286
+ return t("div", { class: { "is-open": e.isOpen }, staticStyle: { position: "relative" }, on: { "&keydown": function(i) {
287
+ return e.onKeydown.apply(null, arguments);
288
+ } } }, [t("SearchApi", { attrs: { "custom-search": {
289
+ article: !0,
290
+ extensionArticle: !0,
291
+ project: !1,
292
+ user: !1
293
+ } }, scopedSlots: e._u([{ key: "default", fn: function({ fetch: i }) {
294
+ return [t("CInput", e._b({ ref: "input", staticClass: "r-input", attrs: { value: e.value, type: e.tag, "auto-resize": !0 }, on: { input: function(n) {
295
+ return e.search(i, n);
296
+ }, focus: e.onFocus, blur: e.onBlur }, nativeOn: { keydown: [function(n) {
297
+ return !n.type.indexOf("key") && e._k(n.keyCode, "tab", 9, n.key, "Tab") ? null : e.hideResults.apply(null, arguments);
298
+ }, function(n) {
299
+ return !n.type.indexOf("key") && e._k(n.keyCode, "escape", void 0, n.key, void 0) ? null : e.hideResults.apply(null, arguments);
300
+ }] } }, "CInput", {
301
+ ...e.$attrs,
302
+ ...e.$props
303
+ }, !1), [e._t("prefix", null, { slot: "prefix" }), e._t("suffix", null, { slot: "suffix" })], 2)];
304
+ } }], null, !0) }), e.isOpen ? t("div", { ref: "dropdown", staticClass: "r-container" }, e._l(e.searchResults, function(i, n) {
305
+ return t("div", { key: n, staticClass: "r-item", class: { active: e.selectedIndex === n }, on: { "!click": function(s) {
306
+ return s.stopPropagation(), e.onSelect(i);
307
+ } } }, [t("div", { staticClass: "r-item-title truncate-text" }, [e._v(e._s(i.name))]), t("div", { staticClass: "r-item-details" }, [i.externalReference && i.externalReference.service ? t("div", { staticStyle: { width: "18px", height: "18px", "border-radius": "2px", "background-color": "hsl(0, 0%, 60%)", display: "inline-flex", "justify-content": "center", "align-items": "center" } }, [t("CIcon", { staticStyle: { color: "white" }, attrs: { type: i.externalReference.service, size: "14" } })], 1) : e._e(), i.article_no ? t("div", [e._v(e._s(i.article_no))]) : e._e(), i.price ? t("div", [e._v(" " + e._s(e.priceFormat(i.price, { currency: i.currency })) + " ")]) : e._e(), i.vat ? t("div", [e._v(" " + e._s(e.$t("vat.sharedTitle").capitalize()) + " " + e._s(i.vat) + "% ")]) : e._e()]), e.selectedIndex === n ? t("div", { staticClass: "r-item-icon" }, [t("CIcon", { attrs: { type: "corner-down-left", size: "16" } })], 1) : e._e()]);
308
+ }), 0) : e._e()], 1);
309
+ }, Ee = [], ze = /* @__PURE__ */ u(
310
+ Me,
311
+ Le,
312
+ Ee,
313
+ !1,
314
+ null,
315
+ "f71801ef"
316
+ );
317
+ const R = ze.exports, A = {
318
+ isDeductable: !1,
319
+ isRut: !1,
320
+ greenRot15: !1,
321
+ greenRot20: !1,
322
+ greenRot50: !1
323
+ }, $ = (a, e = "", t) => {
324
+ let i = {
325
+ ...a,
326
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
327
+ // Trigger updatedAt as it us used to decide which houseWork to prioritize
328
+ };
329
+ return typeof t < "u" && (i[t] = e), Object.keys(A).includes(t) && e && (i = {
330
+ ...i,
331
+ ...A,
332
+ [t]: !0
333
+ }), N(i.quantity) !== "number" && (i.quantity = 0), w(i);
334
+ }, D = ({
335
+ stored: a,
336
+ current: e,
337
+ hidePrice: t = !1,
338
+ activeHouseWorkType: i
339
+ }) => {
340
+ let n = H({
341
+ ...a,
342
+ quantity: 1,
343
+ showPrice: !t,
344
+ id: null,
345
+ ArticleId: a.id,
346
+ packageId: e.packageId
347
+ });
348
+ if (i) {
349
+ const s = (l = []) => l.reduce((_, d) => ({ ..._, [d]: !1 }), {}), c = Object.values(
350
+ V({
351
+ rot: "isDeductable",
352
+ rut: "isRut",
353
+ greenRot15: "greenRot15",
354
+ greenRot20: "greenRot20",
355
+ greenRot50: "greenRot50"
356
+ }, [i])
357
+ );
358
+ c.some((l) => !!n[l]) && (n = { ...n, ...s(c) });
359
+ }
360
+ return n;
361
+ }, Be = (a, e = null) => {
362
+ const t = C(a.currency, e);
363
+ switch (a.priceType) {
364
+ case "approx":
365
+ return `${q.t("_common:approx")} ${t}`;
366
+ case "openAcc":
367
+ return `${t}/${f(a.unitType)}`;
368
+ case "markup":
369
+ return "%";
370
+ default:
371
+ return t;
372
+ }
373
+ }, O = {
374
+ en: {
375
+ namePlaceholder: "Service or product name",
376
+ openModalTooltip: "Edit amount and unit",
377
+ hidePriceLabel: "Hide price for client",
378
+ saveAndAddTooltip: "Save and quick-add",
379
+ priceTypeTooltips: {
380
+ fixed: "The service / product is offered at a fixed price",
381
+ approx: "Show that the price is approximate",
382
+ openAcc: "Pricing on demand. E.g. charging per hour",
383
+ markup: "Show that you take a percentage markup"
384
+ },
385
+ priceTypeShort: {
386
+ approx: "Approximate price",
387
+ markup: "Markup",
388
+ openAcc: "Open Account"
389
+ },
390
+ validations: {
391
+ name: {
392
+ maxLength: "Max length of name is 255 characters"
393
+ }
394
+ }
395
+ },
396
+ sv: {
397
+ namePlaceholder: "T.ex. arbete & material",
398
+ openModalTooltip: "Justera antal / enhet",
399
+ hidePriceLabel: "Dölj pris för kund",
400
+ saveAndAddTooltip: "Spara och lägg till ny",
401
+ priceTypeTooltips: {
402
+ fixed: "Tjänsten/varan erbjuds till fast pris",
403
+ approx: "Markera att priset är ungefärligt",
404
+ openAcc: "Tjänsten / varan erbjuds löpandes",
405
+ markup: "Markera att du tar ett procentuellt påslag"
406
+ },
407
+ priceTypeShort: {
408
+ approx: "Ca. pris",
409
+ markup: "Påslag",
410
+ openAcc: "Löp. pris"
411
+ },
412
+ validations: {
413
+ name: {
414
+ maxLength: "Namnet får vara max 255 tecken långt"
415
+ }
416
+ }
417
+ }
418
+ }, M = {
419
+ article: {
420
+ name: {
421
+ maxLength: re.maxLength(255)
422
+ }
423
+ }
424
+ }, We = {
425
+ // eslint-disable-next-line vue/no-reserved-component-names
426
+ name: "Article",
427
+ i18nOptions: {
428
+ namespaces: "Article",
429
+ messages: O
430
+ },
431
+ components: {
432
+ ErrorCallout: P,
433
+ ArticleAutocomplete: R,
434
+ CPriceInput: x
435
+ },
436
+ props: {
437
+ // Article object
438
+ value: {
439
+ type: Object,
440
+ required: !0
441
+ },
442
+ // If remove button is visible
443
+ enableRemove: {
444
+ type: Boolean,
445
+ default: !0
446
+ },
447
+ width: {
448
+ type: Number,
449
+ default: 1e3
450
+ },
451
+ hidePriceInput: {
452
+ type: Boolean,
453
+ default: !1
454
+ },
455
+ hidePriceOnNew: {
456
+ type: Boolean,
457
+ default: !1
458
+ },
459
+ isIncVat: {
460
+ type: Boolean,
461
+ default: !1
462
+ },
463
+ hideControls: {
464
+ type: Boolean,
465
+ default: !1
466
+ },
467
+ rootPriceType: {
468
+ type: String,
469
+ default: null
470
+ },
471
+ // The current active houseWorkType allowed when adding new articles from search
472
+ activeHouseWorkType: {
473
+ type: String,
474
+ default: null
475
+ }
476
+ },
477
+ validations: M,
478
+ data() {
479
+ return {
480
+ updateData: $,
481
+ addSavedArticle: D,
482
+ articleUnitLabel: f,
483
+ widthCompact: 580,
484
+ visualDisable: !1
485
+ };
486
+ },
487
+ computed: {
488
+ article: {
489
+ get() {
490
+ return this.value || {};
491
+ },
492
+ set(a) {
493
+ this.$emit("input", a);
494
+ }
495
+ },
496
+ details() {
497
+ const a = [], {
498
+ priceType: e,
499
+ quantity: t,
500
+ unitType: i,
501
+ price: n,
502
+ vat: s,
503
+ discount: r,
504
+ discountType: c
505
+ } = this.article;
506
+ if (e !== "fixed" && a.push({ title: this.$t(`priceTypeShort.${e}`) }), U(this.article)) {
507
+ const l = G(this.article);
508
+ a.push({
509
+ title: this.$t(`_common:deduction.${l}_percentage`)
510
+ });
511
+ }
512
+ return t && ["fixed", "approx"].includes(e) && (i !== "unit" || t > 1) && a.push({
513
+ title: f(this.article.unitType, {
514
+ count: t,
515
+ includeCount: !0
516
+ }),
517
+ ...!this.hidePriceInput && {
518
+ icon: '<svg style="margin: 0 4px;" width="6" height="6" viewBox="0 0 148 141" xmlns="http://www.w3.org/2000/svg"><path d="M73.742787 92.65535l-34.444359 47.40859-18.607391-13.51906 34.060775-46.88064L0 61.8743 7.107391 40 62 57.83569V0h23v57.99346L140.378182 40l7.107391 21.8743-54.751812 17.78994 34.060775 46.88064-18.607391 13.51906-34.444358-47.40859z" fill="currentColor" fill-rule="evenodd"/></svg>',
519
+ subTitle: k(n, {
520
+ showZero: !0,
521
+ withVat: this.isIncVat ? s : !1,
522
+ currency: this.article.currency,
523
+ decimals: 2,
524
+ hideZeroDecimals: !0
525
+ })
526
+ }
527
+ }), r && a.push({
528
+ title: "-" + (c === "fixed" ? k(r, {
529
+ withVat: this.isIncVat ? s : !1,
530
+ currency: this.article.currency
531
+ }) : `${r / 100} %`),
532
+ detailClass: "discount"
533
+ }), a;
534
+ }
535
+ },
536
+ methods: {
537
+ updateArticle(a, e) {
538
+ this.article = $(this.article, a, e);
539
+ },
540
+ onTotalPriceInputFocus() {
541
+ (this.article.discount || this.article.quantity !== 1) && this.$emit("open-modal", { focusEl: "priceInput" });
542
+ },
543
+ focusName() {
544
+ this.$refs.name.focus();
545
+ },
546
+ errorMessage(a) {
547
+ return a.$error && a.article.name.$error && !a.article.name.maxLength ? this.$t("validations.name.maxLength") : null;
548
+ }
549
+ }
550
+ };
551
+ var Fe = function() {
552
+ var e = this, t = e._self._c;
553
+ return t("div", { staticClass: "article-wrapper", class: {
554
+ "has-details": e.details.length,
555
+ compact: e.width <= e.widthCompact,
556
+ "show-controls": !e.hideControls
557
+ }, on: { keydown: function(i) {
558
+ return !i.type.indexOf("key") && e._k(i.keyCode, "esc", 27, i.key, ["Esc", "Escape"]) ? null : e.$emit("esc");
559
+ } } }, [t("div", { staticClass: "top-row flex w-full" }, [t("ArticleAutocomplete", { ref: "name", staticClass: "article-name-wrapper article-input-wrapper form-control form-control-left", attrs: { value: e.article.name, placeholder: e.$t("namePlaceholder"), size: "large" }, on: { input: function(i) {
560
+ return e.updateArticle(i, "name");
561
+ }, focus: function(i) {
562
+ return e.$emit("focus");
563
+ }, select: function(i) {
564
+ e.$emit(
565
+ "input",
566
+ e.addSavedArticle({
567
+ stored: i,
568
+ current: e.article,
569
+ hidePrice: e.hidePriceOnNew,
570
+ activeHouseWorkType: e.activeHouseWorkType
571
+ })
572
+ ), e.$emit("select");
573
+ } } }, [e.hideControls ? e._e() : t("div", { directives: [{ name: "tooltip", rawName: "v-tooltip", value: {
574
+ content: e.$t("openModalTooltip"),
575
+ delay: { show: 300, hide: 0 }
576
+ }, expression: `{
577
+ content: $t('openModalTooltip'),
578
+ delay: { show: 300, hide: 0 }
579
+ }` }], staticClass: "article-button fade-in", attrs: { slot: "suffix" }, on: { click: function(i) {
580
+ return e.$emit("open-modal");
581
+ } }, slot: "suffix" }, [t("CIcon", { attrs: { type: "cog", size: "18" } })], 1)]), e.hidePriceInput ? e._e() : t("CPriceInput", { key: e.rootPriceType + e.article.priceType + e.article.unitType, staticClass: "form-control form-control-right", staticStyle: { flex: "1 1", "min-width": "200px" }, attrs: { value: e.article.totalAmount, currency: e.article.currency, "is-inc-vat": e.article.priceType !== "markup" && e.isIncVat, vat: e.article.vat, placeholder: e.$t("_common:price.price").capitalize(), "price-type": e.article.priceType, "unit-label": e.articleUnitLabel(e.article.unitType) }, on: { input: function(i) {
582
+ return e.updateArticle(i, "price");
583
+ }, "update:currency": function(i) {
584
+ return e.$emit("update:currency", i);
585
+ }, focus: function(i) {
586
+ e.onTotalPriceInputFocus(), e.$emit("focus");
587
+ } }, nativeOn: { keydown: function(i) {
588
+ return !i.type.indexOf("key") && e._k(i.keyCode, "enter", 13, i.key, "Enter") ? null : e.$emit("add");
589
+ } } }), e.hideControls ? e._e() : [t("CIcon", { staticClass: "a-control-button close-button fade-in", attrs: { circle: "", type: "x", size: "18" }, nativeOn: { click: function(i) {
590
+ e.enableRemove && e.$emit("remove");
591
+ } } }), t("CIcon", { staticClass: "a-control-button fade-in move-button article-draggable-handle", class: { "c-hidden": !e.enableRemove }, attrs: { circle: "", type: "handle", size: "18" } })]], 2), e.details.length ? t("div", { staticClass: "article-details-wrapper", staticStyle: { cursor: "pointer" }, on: { click: function(i) {
592
+ return e.$emit("open-modal");
593
+ } } }, e._l(e.details, function({ title: i, icon: n, subTitle: s = "", detailClass: r = "" }, c) {
594
+ return t("div", { key: c, staticClass: "article-details-item", class: [r] }, [e._v(" " + e._s(i) + " "), n ? t("div", { domProps: { innerHTML: e._s(n) } }) : e._e(), e._v(" " + e._s(s) + " ")]);
595
+ }), 0) : e._e(), e.$v.$invalid && e.$v.$dirty ? t("ErrorCallout", { attrs: { message: e.errorMessage(e.$v) } }) : e._e()], 1);
596
+ }, je = [], Ne = /* @__PURE__ */ u(
597
+ We,
598
+ Fe,
599
+ je,
600
+ !1,
601
+ null,
602
+ "4eae2a1a"
603
+ );
604
+ const He = Ne.exports, qe = {
605
+ props: {
606
+ canForward: {
607
+ type: Boolean,
608
+ default: !1
609
+ },
610
+ canBackward: {
611
+ type: Boolean,
612
+ default: !1
613
+ }
614
+ },
615
+ created() {
616
+ document.addEventListener("keyup", this.onKeyUp);
617
+ },
618
+ beforeDestroy() {
619
+ this.removeKeyHandler();
620
+ },
621
+ methods: {
622
+ getNavTooltip(a) {
623
+ return a === -1 ? {
624
+ content: `
625
+ <div style='margin-bottom: 0.6em;'>
626
+ ${this.$t("show", { thing: this.$t("previous") })}
627
+ </div>
628
+ <div class='flex items-center justify-center w-full' style='padding-bottom: 0.5em;'>
629
+ <div style='text-align: center; background-color: hsl(0, 0%, 40%); line-height: 1; border-radius: 0.5em; display: inline-flex; align-items: center; justify-content: center; padding: 0.5em;'>
630
+ <svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M19 12H6M12 5l-7 7 7 7'></path></svg>
631
+ </div>
632
+ </div>
633
+ `,
634
+ html: !0
635
+ } : a === 1 ? {
636
+ content: `
637
+ <div style='margin-bottom: 0.6em;'>
638
+ ${this.$t("show", { thing: this.$t("next") })}
639
+ </div>
640
+ <div class='flex items-center justify-center w-full' style='padding-bottom: 0.5em;'>
641
+ <div style='text-align: center; background-color: hsl(0, 0%, 40%); line-height: 1; border-radius: 0.5em; display: inline-flex; align-items: center; justify-content: center; padding: 0.5em;'>
642
+ <svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12h13M12 5l7 7-7 7'/></svg>
643
+ </div>
644
+ </div>
645
+ `,
646
+ html: !0
647
+ } : a === "close" ? {
648
+ content: '<div style="margin-bottom: 0.6em;">Stäng</div><div style="text-align: center; opacity: 0.85;"><svg width="30" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="17 0 105.5 72" style="enable-background:new 17 0 105.5 72"><path d="M103.3 70.3H36.2c-9.6 0-17.5-7.9-17.5-17.5V19.2c0-9.6 7.9-17.5 17.5-17.5h67.1c9.6 0 17.5 7.9 17.5 17.5v33.6c0 9.6-7.9 17.5-17.5 17.5z" style="fill:none;stroke:currentColor;stroke-width:3;stroke-miterlimit:10"/><path style="fill:none" d="M17 17.8h105.5V49H17z"/><path fill="currentColor" d="M46.6 38.2c.1 5 3.3 7.1 7 7.1 2.6 0 4.2-.5 5.6-1l.6 2.6c-1.3.6-3.5 1.3-6.8 1.3-6.3 0-10-4.1-10-10.2s3.6-11 9.5-11c6.6 0 8.4 5.8 8.4 9.6 0 .8-.1 1.3-.1 1.7l-14.2-.1zm10.9-2.7c0-2.4-1-6-5.1-6-3.7 0-5.4 3.4-5.7 6h10.8zM65.1 43.9c1.1.7 3 1.5 4.9 1.5 2.7 0 3.9-1.3 3.9-3 0-1.8-1-2.7-3.8-3.7-3.7-1.3-5.4-3.3-5.4-5.8 0-3.3 2.6-6 7-6 2.1 0 3.9.6 5 1.3l-.9 2.7c-.8-.5-2.3-1.2-4.2-1.2-2.2 0-3.4 1.3-3.4 2.8 0 1.7 1.2 2.4 3.9 3.4 3.5 1.3 5.3 3.1 5.3 6.1 0 3.6-2.8 6.1-7.6 6.1-2.2 0-4.3-.5-5.7-1.4l1-2.8zM96.7 46.9c-1 .5-3.1 1.2-5.8 1.2-6.1 0-10.1-4.2-10.1-10.4 0-6.3 4.3-10.8 10.9-10.8 2.2 0 4.1.5 5.1 1l-.8 2.9c-.9-.5-2.3-1-4.3-1-4.7 0-7.2 3.4-7.2 7.7 0 4.7 3 7.6 7.1 7.6 2.1 0 3.5-.5 4.5-1l.6 2.8z"/></svg></div>',
649
+ html: !0
650
+ } : null;
651
+ },
652
+ onKeyUp(a) {
653
+ const e = document.activeElement;
654
+ !(e.hasAttribute("contenteditable") || ["input", "textarea"].includes(e.tagName.toLowerCase())) && (parseInt(a.keyCode, 10) === 37 && this.$emit("go", -1), parseInt(a.keyCode, 10) === 39 && this.$emit("go", 1));
655
+ const i = a.key || a.keyCode;
656
+ if (i === "Escape" || i === "Esc" || i === 27) {
657
+ const n = this.$modal.getOpenInstances();
658
+ if (a.defaultPrevented || n.length)
659
+ return;
660
+ this.$emit("close");
661
+ }
662
+ },
663
+ removeKeyHandler() {
664
+ document.removeEventListener("keyup", this.onKeyUp);
665
+ }
666
+ },
667
+ render() {
668
+ return this.$scopedSlots.default({
669
+ leftTooltip: this.getNavTooltip(-1),
670
+ rightTooltip: this.getNavTooltip(1),
671
+ closeTooltip: this.getNavTooltip("close")
672
+ });
673
+ }
674
+ };
675
+ var Ue = function() {
676
+ var e = this, t = e._self._c;
677
+ return t("div", { staticClass: "l-root" }, [t("div", { directives: [{ name: "tooltip", rawName: "v-tooltip", value: e.getNavTooltip(-1), expression: "getNavTooltip(-1)" }], staticClass: "l-button", class: { disabled: !e.canBackward }, staticStyle: { left: "calc(-4 * var(--rem))" }, on: { click: function(i) {
678
+ return e.$emit("go", -1);
679
+ } } }, [t("svg", { attrs: { xmlns: "http://www.w3.org/2000/svg", width: "35", height: "35", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" } }, [t("path", { attrs: { d: "M15 18l-6-6 6-6" } })])]), t("div", { directives: [{ name: "tooltip", rawName: "v-tooltip", value: e.getNavTooltip(1), expression: "getNavTooltip(1)" }], staticClass: "l-button", class: { disabled: !e.canForward }, staticStyle: { right: "calc(-4 * var(--rem))" }, on: { click: function(i) {
680
+ return e.$emit("go", 1);
681
+ } } }, [t("svg", { attrs: { xmlns: "http://www.w3.org/2000/svg", width: "35", height: "35", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" } }, [t("path", { attrs: { d: "M9 18l6-6-6-6" } })])])]);
682
+ }, Ge = [], Ke = /* @__PURE__ */ u(
683
+ qe,
684
+ Ue,
685
+ Ge,
686
+ !1,
687
+ null,
688
+ "5985de8a"
689
+ );
690
+ const Ye = Ke.exports, Ze = {
691
+ name: "ArticleUnitEditModal",
692
+ i18nOptions: {
693
+ namespaces: "ArticleUnitEditModal",
694
+ messages: {
695
+ en: {
696
+ tooltip: `
697
+ <div>
698
+ Tip: If you'd like for the unit type to pluralize automatically. Use the following format - <span style="padding: 3px; background-color: hsla(0, 0%, 100%, 0.1); border-radius: 4px;">single:plural</span>.
699
+ </div>
700
+ <div style="margin-top: 0.5em;">For example:</div>
701
+ <div style="margin-left: 0.25em;">- image:images</div>
702
+ <div style="margin-left: 0.25em;">- phone:phones</div>
703
+ `
704
+ },
705
+ sv: {
706
+ tooltip: `
707
+ <div>
708
+ Tips: Om du vill att enheten ska ta hänsyn till antalet så kan du skriva det i följande format - <span style="padding: 3px; background-color: hsla(0, 0%, 100%, 0.1); border-radius: 4px;">singular:plural</span>.
709
+ </div>
710
+ <div style="margin-top: 0.5em;">Till exempel:</div>
711
+ <div style="margin-left: 0.25em;">- bild:bilder</div>
712
+ <div style="margin-left: 0.25em;">- telefon:telefoner</div>
713
+ `
714
+ }
715
+ }
716
+ },
717
+ components: {
718
+ DragList: K,
719
+ DragItem: Y
720
+ },
721
+ data() {
722
+ return {
723
+ hoverIndex: null,
724
+ removeConfirmIndex: null,
725
+ selectedValue: {
726
+ id: null,
727
+ value: ""
728
+ },
729
+ idList: []
730
+ };
731
+ },
732
+ computed: {
733
+ ...h({
734
+ isPosting: "unitTypes/isPosting",
735
+ stateUnitIds: "unitTypes/ids",
736
+ unitById: "unitTypes/byId"
737
+ }),
738
+ unitItems() {
739
+ return (this.idList || []).map((a) => {
740
+ const e = this.unitById(a), t = f(e.value);
741
+ return {
742
+ ...e,
743
+ label: t,
744
+ value: e.value.startsWith("$") ? e.value.replace(/^[$]/, "") : t,
745
+ raw: e.value.replace(/^[$]/, "")
746
+ // replace only first occurance of '$'
747
+ };
748
+ });
749
+ }
750
+ },
751
+ watch: {
752
+ stateUnitIds: {
753
+ immediate: !0,
754
+ handler(a) {
755
+ this.idList = a || [];
756
+ }
757
+ }
758
+ },
759
+ methods: {
760
+ ...v({
761
+ loadUnits: p.LOAD_UNIT_TYPES,
762
+ createUnit: p.CREATE_UNIT_TYPE,
763
+ updateUnit: p.UPDATE_UNIT_TYPE,
764
+ deleteUnit: p.DELETE_UNIT_TYPE
765
+ }),
766
+ onEdit(a) {
767
+ this.selectedValue = { ...a }, this.$refs.unitInput && this.$refs.unitInput.focus();
768
+ },
769
+ async submit() {
770
+ const { id: a, value: e } = this.selectedValue || {};
771
+ if (!e)
772
+ throw new Error("New unitTypes need truthy value!");
773
+ const t = `$${e}`;
774
+ a ? await this.updateUnit({ id: a, body: { value: t } }) : await this.createUnit({ body: { value: t } }), this.reset(), this.$parent.$emit("select", t), this.close();
775
+ },
776
+ async remove(a, e) {
777
+ if (this.removeConfirmIndex !== e) {
778
+ this.removeConfirmIndex = e;
779
+ return;
780
+ }
781
+ await this.deleteUnit({ id: a }), this.reset(), this.removeConfirmIndex = null;
782
+ },
783
+ reset() {
784
+ this.selectedValue = { id: null, value: "" };
785
+ },
786
+ close() {
787
+ this.$emit("close");
788
+ },
789
+ async onDrop({ removedIndex: a, addedIndex: e }) {
790
+ a === null && e === null || a !== e && (this.idList = T(this.idList, a, e), await Z(
791
+ "/unitType/setPositions",
792
+ { ids: this.idList },
793
+ { invalidateCache: { type: "unitType" } }
794
+ ), this.reset(), await this.loadUnits());
795
+ }
796
+ }
797
+ };
798
+ var Je = function() {
799
+ var e = this, t = e._self._c;
800
+ return t("div", { staticClass: "modal-overlay font-inter", on: { "&click": function(i) {
801
+ return i.target !== i.currentTarget ? null : e.close.apply(null, arguments);
802
+ } } }, [t("div", { staticClass: "unit-modal-root font-inter", staticStyle: { position: "relative" } }, [t("div", { staticStyle: { padding: "calc(1.5 * var(--rem))" } }, [t("div", { staticStyle: { "font-weight": "600", "font-size": "18px", "margin-bottom": "calc(1.5 * var(--rem))" } }, [t("span", [e._v(e._s(e.$t("_common:add", { thing: e.$t("_common:unitType.unitType_plural") })))]), t("CIcon", { directives: [{ name: "tooltip", rawName: "v-tooltip", value: { content: e.$t("tooltip"), html: !0 }, expression: "{ content: $t('tooltip'), html: true }" }], staticClass: "text-gray-400", staticStyle: { "margin-left": "0.5em" }, attrs: { type: "info", size: "15" } })], 1), t("CField", { staticStyle: { margin: "0" }, attrs: { grouped: "" } }, [t("CInput", { ref: "unitInput", staticClass: "unit-input", attrs: { placeholder: e.$t("_common:name").capitalize(), expanded: "", filled: "" }, model: { value: e.selectedValue.value, callback: function(i) {
803
+ e.$set(e.selectedValue, "value", typeof i == "string" ? i.trim() : i);
804
+ }, expression: "selectedValue.value" } }, [e.selectedValue.id ? t("template", { slot: "suffix" }, [t("CButton", { staticStyle: { "border-radius": "4px" }, attrs: { icon: "x", type: "none", pattern: "tertiary", size: "small" }, on: { click: e.reset } })], 1) : e._e()], 2), t("div", { staticClass: "control" }, [t("CButton", { attrs: { loading: e.isPosting, disabled: !e.selectedValue.value, type: "secondary" }, on: { click: e.submit } }, [e._v(" " + e._s(e.selectedValue.id ? e.$t("_common:save") : e.$t("_common:add")) + " ")])], 1)], 1)], 1), t("div", { staticStyle: { "border-top": "1px solid hsl(0, 0%, 88%)", overflow: "auto", "max-height": "360px" } }, [t("div", { staticClass: "text-gray-400", staticStyle: { "font-size": "14px", padding: "calc(1 * var(--rem)) calc(1.5 * var(--rem)) 0", "font-weight": "500" } }, [e._v(" " + e._s(e.$t("_common:unit_plural").capitalize()) + " ")]), t("div", { staticClass: "unit-modal-list" }, [e.unitItems.length ? e._e() : t("div", { staticClass: "unit-modal-list-empty" }, [e._v(" " + e._s(e.$t("_common:add", { thing: e.$t("_common:unit_plural") })) + " ")]), t("DragList", { attrs: { "drop-placeholder": { className: "drag-drop-placeholder" }, "drag-class": "is-dragged", "lock-axis": "y", "drag-handle-selector": ".drag-handle" }, on: { drop: e.onDrop } }, e._l(e.unitItems, function(i, n) {
805
+ return t("DragItem", { key: i.id }, [t("div", { staticClass: "unit-modal-list-item", class: { "is-editing": e.selectedValue.id === i.id }, on: { "&mouseover": function(s) {
806
+ e.hoverIndex = n;
807
+ }, "&mouseleave": function(s) {
808
+ e.hoverIndex = null;
809
+ }, click: function(s) {
810
+ return e.onEdit(i);
811
+ } } }, [t("div", { staticClass: "drag-handle" }, [t("CIcon", { staticClass: "text-gray-300", attrs: { type: "handle", size: "16" } })], 1), t("div", { staticStyle: { "padding-left": "0.5em" } }, [e._v(" " + e._s(i.label) + " ")]), t("span", { directives: [{ name: "show", rawName: "v-show", value: e.removeConfirmIndex === n, expression: "removeConfirmIndex === i" }], staticClass: "delete-confirm" }, [e._v(" " + e._s(e.$t("_common:remove")) + "? ")]), t("div", { staticClass: "unittype-buttons" }, [e.hoverIndex === n || e.removeConfirmIndex === n ? t("CButton", { attrs: { type: e.removeConfirmIndex === n ? "danger" : "none", pattern: e.removeConfirmIndex === n ? "primary" : "tertiary", circle: "", icon: "x", size: "small" }, on: { click: function(s) {
812
+ return s.stopPropagation(), s.preventDefault(), e.remove(i.id, n);
813
+ }, blur: function(s) {
814
+ e.removeConfirmIndex = null;
815
+ } } }) : e._e(), t("CButton", { attrs: { icon: "edit", size: "small", type: "none", pattern: "tertiary", circle: "" } })], 1)])]);
816
+ }), 1)], 1)])])]);
817
+ }, Qe = [], Xe = /* @__PURE__ */ u(
818
+ Ze,
819
+ Je,
820
+ Qe,
821
+ !1,
822
+ null,
823
+ "e5d287ea"
824
+ );
825
+ const et = Xe.exports, tt = {
826
+ name: "ArticleUnitSelect",
827
+ props: {
828
+ value: {
829
+ type: String,
830
+ required: !0
831
+ },
832
+ isPublicForm: {
833
+ type: Boolean,
834
+ default: !1
835
+ },
836
+ // Optional param for plural translations
837
+ count: {
838
+ type: Number,
839
+ default: 1
840
+ }
841
+ },
842
+ computed: {
843
+ ...h({
844
+ unitIds: "unitTypes/ids",
845
+ unitById: "unitTypes/byId"
846
+ }),
847
+ unitItems() {
848
+ return this.isPublicForm ? ce : (this.unitIds || []).map((a) => this.unitById(a)).map(({ value: a }) => a);
849
+ }
850
+ },
851
+ created() {
852
+ this.isPublicForm || this.loadUnits();
853
+ },
854
+ methods: {
855
+ articleUnitLabel: f,
856
+ ...v({
857
+ loadUnits: p.LOAD_UNIT_TYPES
858
+ }),
859
+ openEditModal() {
860
+ this.$modal.show(
861
+ et,
862
+ {},
863
+ {},
864
+ {
865
+ select: (a) => this.$emit("input", a)
866
+ }
867
+ );
868
+ }
869
+ }
870
+ };
871
+ var it = function() {
872
+ var e = this, t = e._self._c;
873
+ return t("CDropdown", e._b({ attrs: { value: e.value, scrollable: "" }, on: { input: function(i) {
874
+ return e.$emit("input", i);
875
+ } } }, "CDropdown", {
876
+ position: "is-bottom-left",
877
+ maxHeight: "240px",
878
+ ...e.$attrs
879
+ }, !1), [e._t("default", function() {
880
+ return [t("CButton", { attrs: { slot: "trigger", type: "none", pattern: "tertiary" }, slot: "trigger" }, [e._v(" " + e._s(e.articleUnitLabel(e.value)) + " ")])];
881
+ }, { slot: "trigger" }), e._l(e.unitItems, function(i, n) {
882
+ return t("CDropdownItem", { key: `${i}-${n}`, attrs: { value: i } }, [e._v(" " + e._s(e.articleUnitLabel(i)) + " ")]);
883
+ }), e.isPublicForm ? e._e() : t("CButton", { staticClass: "edit-button", attrs: { slot: "footer", type: "none", pattern: "secondary", size: "small" }, on: { click: e.openEditModal }, slot: "footer" }, [e._v(" " + e._s(e.$t("_common:edit", { thing: e.$t("_common:unit_plural") })) + " ")])], 2);
884
+ }, at = [], st = /* @__PURE__ */ u(
885
+ tt,
886
+ it,
887
+ at,
888
+ !1,
889
+ null,
890
+ "9458eb82"
891
+ );
892
+ const nt = st.exports, rt = {
893
+ name: "ArticleModal",
894
+ i18nOptions: {
895
+ namespaces: "ArticleModal",
896
+ messages: O
897
+ },
898
+ components: {
899
+ ArticleAutocomplete: R,
900
+ ArticleUnitSelect: nt,
901
+ ListModalButtons: Ye,
902
+ CPriceInput: x
903
+ },
904
+ mixins: [oe],
905
+ props: {
906
+ _document: {
907
+ type: Object,
908
+ default: () => ({})
909
+ },
910
+ // Article object
911
+ index: {
912
+ type: Number,
913
+ required: !0
914
+ },
915
+ articleList: {
916
+ type: Array,
917
+ required: !0
918
+ },
919
+ // If priceType checkboxes should be visible
920
+ enablePriceTypes: {
921
+ type: Boolean,
922
+ default: !0
923
+ },
924
+ hidePriceInput: {
925
+ type: Boolean,
926
+ default: !1
927
+ },
928
+ hidePriceOnNew: {
929
+ type: Boolean,
930
+ default: !1
931
+ },
932
+ isIncVat: {
933
+ type: Boolean,
934
+ default: !1
935
+ },
936
+ rootPriceType: {
937
+ type: String,
938
+ default: "fixed"
939
+ },
940
+ currency: {
941
+ type: String,
942
+ required: !0
943
+ },
944
+ activeHouseWorkType: {
945
+ type: String,
946
+ default: null
947
+ },
948
+ // Mixin props are not injected when rendered within a portal
949
+ viewSettings: {
950
+ type: Object,
951
+ default: () => ({
952
+ canEdit: !1,
953
+ isForm: !1,
954
+ setFormValue: null,
955
+ isPublicForm: !1
956
+ })
957
+ }
958
+ },
959
+ validations: M,
960
+ data() {
961
+ return {
962
+ priceSuffix: Be,
963
+ updateData: $,
964
+ addSavedArticle: D,
965
+ vatOptions: [
966
+ { value: 25, translation: "25%" },
967
+ { value: 12, translation: "12%" },
968
+ { value: 6, translation: "6%" },
969
+ { value: 0, translation: "0%" }
970
+ ],
971
+ showDiscountInput: !1,
972
+ setPricesIncVat: !1,
973
+ getCurrencySymbol: C,
974
+ articleUnitLabel: f
975
+ };
976
+ },
977
+ computed: {
978
+ ...h({
979
+ allowHidePrice: "settings/allowHidePrice",
980
+ getCompanySetting: "settings/getCompanySetting",
981
+ feature: "application/feature"
982
+ }),
983
+ article: {
984
+ get() {
985
+ return this.articleList[this.index] || {};
986
+ },
987
+ set(a) {
988
+ this.$emit("input", a);
989
+ }
990
+ },
991
+ useVat() {
992
+ return o(this, "_document.useVat") || "";
993
+ },
994
+ vatType() {
995
+ return o(this, "_document.vatType") || "";
996
+ },
997
+ checkboxItems() {
998
+ const { article: a } = this || {}, { priceType: e } = this.article || {}, t = [
999
+ ...e !== "markup" ? [
1000
+ {
1001
+ label: this.$t("discount").capitalize(),
1002
+ value: a.discount || this.showDiscountInput,
1003
+ onClick: () => {
1004
+ this.showDiscountInput || this.focusEl("discountInput"), this.showDiscountInput = !this.showDiscountInput;
1005
+ }
1006
+ }
1007
+ ] : [],
1008
+ ...this.getCompanySetting("showRot") || a.isDeductable ? [
1009
+ {
1010
+ label: this.$t("_common:deduction.rot"),
1011
+ value: this.article.isDeductable,
1012
+ onClick: () => this.updateArticle(!a.isDeductable, "isDeductable")
1013
+ }
1014
+ ] : [],
1015
+ ...this.getCompanySetting("showRut") || a.isRut ? [
1016
+ {
1017
+ label: this.$t("_common:deduction.rut"),
1018
+ value: a.isRut,
1019
+ onClick: () => this.updateArticle(!a.isRut, "isRut")
1020
+ }
1021
+ ] : [],
1022
+ ...a.greenRot15 ? [
1023
+ {
1024
+ label: this.$t("_common:deduction.greenRot15_percentage"),
1025
+ value: a.greenRot15,
1026
+ onClick: () => this.updateArticle(!a.greenRot15, "greenRot15")
1027
+ }
1028
+ ] : [],
1029
+ ...this.getCompanySetting("showGreenRot") || a.greenRot20 || a.greenRot50 ? [
1030
+ {
1031
+ label: this.$t("_common:deduction.greenRot20_percentage"),
1032
+ value: a.greenRot20,
1033
+ onClick: () => this.updateArticle(!a.greenRot20, "greenRot20")
1034
+ },
1035
+ {
1036
+ label: this.$t("_common:deduction.greenRot50_percentage"),
1037
+ value: a.greenRot50,
1038
+ onClick: () => this.updateArticle(!a.greenRot50, "greenRot50")
1039
+ }
1040
+ ] : []
1041
+ ];
1042
+ if (this.allowHidePrice) {
1043
+ const { showPrice: i } = a || {};
1044
+ t.push({
1045
+ label: this.$t("hidePriceLabel"),
1046
+ value: !i,
1047
+ onClick: () => this.updateArticle(!i, "showPrice")
1048
+ });
1049
+ }
1050
+ return t;
1051
+ },
1052
+ priceTypeOptions() {
1053
+ if (!this.enablePriceTypes || this.rootPriceType === "fixed")
1054
+ return [];
1055
+ const { priceType: a } = this.article, e = (i) => this.$t(`priceTypeTooltips.${i}`), t = [
1056
+ {
1057
+ label: this.$t("price.fixed"),
1058
+ tooltip: e("fixed"),
1059
+ value: a === "fixed",
1060
+ onClick: () => this.updateArticle("fixed", "priceType")
1061
+ }
1062
+ ];
1063
+ return this.rootPriceType === "approx" && t.push({
1064
+ label: this.$t("price.approx"),
1065
+ tooltip: e("approx"),
1066
+ value: a === "approx",
1067
+ onClick: () => this.updateArticle("approx", "priceType")
1068
+ }), this.rootPriceType.startsWith("openAcc") && (t.push({
1069
+ label: this.$t("price.openAcc"),
1070
+ tooltip: e("openAcc"),
1071
+ value: a === "openAcc",
1072
+ onClick: () => this.updateArticle("openAcc", "priceType")
1073
+ }), t.push({
1074
+ label: this.$t("price.markup"),
1075
+ tooltip: e("markup"),
1076
+ value: a === "markup",
1077
+ onClick: () => this.updateArticle("markup", "priceType")
1078
+ })), t;
1079
+ }
1080
+ },
1081
+ watch: {
1082
+ index: {
1083
+ immediate: !0,
1084
+ handler(a, e) {
1085
+ a !== e && (this.showDiscountInput = !1);
1086
+ }
1087
+ },
1088
+ isIncVat: {
1089
+ immediate: !0,
1090
+ handler(a) {
1091
+ this.setPricesIncVat = !!a;
1092
+ }
1093
+ },
1094
+ "article.discount": {
1095
+ immediate: !0,
1096
+ handler(a) {
1097
+ a && (this.showDiscountInput = !0);
1098
+ }
1099
+ },
1100
+ "article.priceType": {
1101
+ handler(a) {
1102
+ a === "markup" && (this.showDiscountInput = !1), ["openAcc", "markup"].includes(a) && this.updateArticle(1, "quantity");
1103
+ }
1104
+ },
1105
+ showDiscountInput(a) {
1106
+ a || this.updateArticle(0, "discount");
1107
+ }
1108
+ },
1109
+ mounted() {
1110
+ !this.article.name && this.$refs.nameInput && this.$refs.nameInput.focus(), document.addEventListener("keydown", this.onKeydown);
1111
+ },
1112
+ beforeDestroy() {
1113
+ document.removeEventListener("keydown", this.onKeydown);
1114
+ },
1115
+ methods: {
1116
+ ...v({
1117
+ createArticle: p.DO_CREATE_ARTICLE
1118
+ }),
1119
+ onCustomVatBlur(a) {
1120
+ o(a, "target.value") || "" || this.updateArticle(0, "vat");
1121
+ },
1122
+ onCustomVatInput(a) {
1123
+ const e = o(a, "target.value") || "";
1124
+ if (!e)
1125
+ return;
1126
+ let t = e > 100 ? e.slice(0, e.length - 1) : e;
1127
+ t < 0 && (t = 0), this.updateArticle(Number.parseFloat(t), "vat");
1128
+ },
1129
+ updateArticle(a, e) {
1130
+ this.article = $(this.article, a, e);
1131
+ },
1132
+ close() {
1133
+ this.$emit("close");
1134
+ },
1135
+ onKeydown(a) {
1136
+ a.keyCode === 13 && a.shiftKey && (a.preventDefault(), this.addNewArticle());
1137
+ },
1138
+ onGo(a) {
1139
+ const e = this.index + a;
1140
+ this.articleList[e] && (this.close(), this.$emit("open-modal", e));
1141
+ },
1142
+ async addNewArticle() {
1143
+ this.$v.$invalid || await this.saveArticle(), this.$emit("add", { openModal: !0 }), this.close();
1144
+ },
1145
+ focusEl(a) {
1146
+ this.$nextTick(() => {
1147
+ this.$nextTick(() => {
1148
+ this.$refs[a] && this.$refs[a].focus && this.$refs[a].focus();
1149
+ });
1150
+ });
1151
+ },
1152
+ onTotalPriceInputFocus() {
1153
+ this.article.quantity > 1 && this.$nextTick(() => {
1154
+ this.$refs.priceInput && this.$refs.priceInput.focus();
1155
+ });
1156
+ },
1157
+ toggleDiscountType() {
1158
+ let a = "fixed";
1159
+ this.article.discountType === "fixed" && (a = "percentage"), this.updateArticle(a, "discountType");
1160
+ },
1161
+ async onSaveArticle() {
1162
+ if (this.$v.$invalid) {
1163
+ this.$v.$touch();
1164
+ return;
1165
+ }
1166
+ await this.saveArticle(), this.close();
1167
+ },
1168
+ async saveArticle() {
1169
+ if (this.viewSettings.isPublicForm)
1170
+ return;
1171
+ let { ArticleId: a } = this.article;
1172
+ !a && ((t) => typeof t == "string" && !!t.trim())(this.article.name) && (a = await this.createArticle({
1173
+ body: this.article,
1174
+ showMessage: !1
1175
+ }), this.article = { ...this.article, ArticleId: a });
1176
+ }
1177
+ }
1178
+ };
1179
+ var ot = function() {
1180
+ var e = this, t = e._self._c;
1181
+ return t("div", { staticClass: "font-inter", class: {
1182
+ "full-screen": e.mq === "sm",
1183
+ "modal-overlay": !0
1184
+ }, on: { "&click": function(i) {
1185
+ return i.target !== i.currentTarget ? null : e.close.apply(null, arguments);
1186
+ } } }, [t("div", { staticClass: "modal-container" }, [e.mq !== "sm" ? t("ListModalButtons", { attrs: { "can-forward": !!e.articleList[e.index + 1], "can-backward": !!e.articleList[e.index - 1] }, on: { close: e.close, go: function(i) {
1187
+ return e.onGo(i);
1188
+ } } }) : t("div", { staticClass: "modal-close", on: { click: e.close } }, [t("CIcon", { attrs: { type: "x" } })], 1), t("transition", { attrs: { name: "slide" } }, [t("div", { key: e.article._uniqueId, staticClass: "modal-main" }, [t("CField", { staticClass: "label-selector", staticStyle: { "margin-bottom": "1.5em" }, attrs: { validator: e.$v.article.name, messages: { maxLength: e.$t("validations.name.maxLength") }, label: e.$t("name").capitalize(), "label-position": "inside" } }, [t("ArticleAutocomplete", { ref: "nameInput", staticClass: "input-selector", attrs: { value: e.article.name, autosize: !0, tag: "textarea", placeholder: "", size: "large" }, on: { input: function(i) {
1189
+ return e.updateArticle(i, "name");
1190
+ }, select: function(i) {
1191
+ e.$emit(
1192
+ "input",
1193
+ e.addSavedArticle({
1194
+ stored: i,
1195
+ current: e.article,
1196
+ hidePrice: e.hidePriceOnNew,
1197
+ activeHouseWorkType: e.activeHouseWorkType
1198
+ })
1199
+ );
1200
+ } } })], 1), t("div", { staticClass: "flex w-full", staticStyle: { "margin-bottom": "1.5em" } }, [t("CField", { staticClass: "label-selector form-control form-control-left flex-grow", staticStyle: { "margin-bottom": "0" }, attrs: { label: e.$t("quantity").capitalize(), "label-position": "inside" } }, [t("CInput", { staticClass: "input-selector", attrs: { value: e.article.quantity, disabled: ["openAcc", "markup"].includes(e.article.priceType), placeholder: "", type: "number", size: "large" }, on: { input: function(i) {
1201
+ e.updateArticle(Number.parseFloat(i), "quantity");
1202
+ } } })], 1), t("ArticleUnitSelect", { attrs: { value: e.article.unitType, "is-public-form": e.viewSettings.isPublicForm }, on: { input: function(i) {
1203
+ return e.updateArticle(i, "unitType");
1204
+ } } }, [t("CButton", { staticClass: "select-css form-control form-control-right", staticStyle: { width: "8em", "box-shadow": "none" } }, [e._v(" " + e._s(e.articleUnitLabel(e.article.unitType, { count: e.article.quantity })) + " ")])], 1)], 1), e.hidePriceInput ? e._e() : [t("div", { staticClass: "flex", staticStyle: { "margin-bottom": "1.5em" } }, [t("CField", { staticClass: "label-selector form-control form-control-left flex-1", staticStyle: { "margin-bottom": "0" }, attrs: { label: e.$t("price.price").capitalize(), "label-position": "inside" } }, [t("CPriceInput", { key: e.priceSuffix(e.article), ref: "priceInput", staticClass: "input-selector", attrs: { value: e.article.price, currency: e.article.currency, "is-inc-vat": e.article.priceType !== "markup" && e.setPricesIncVat, vat: e.article.vat, "price-type": e.article.priceType, "unit-label": e.articleUnitLabel(e.article.unitType) }, on: { input: function(i) {
1205
+ return e.updateArticle(i, "price");
1206
+ }, "update:currency": function(i) {
1207
+ return e.$emit("update:currency", i);
1208
+ }, focus: function(i) {
1209
+ return e.$emit("focus");
1210
+ } } })], 1), e.useVat ? t("div", { staticClass: "select-css form-control form-control-right", staticStyle: { width: "8em" }, on: { click: function(i) {
1211
+ e.setPricesIncVat = !e.setPricesIncVat;
1212
+ } } }, [e._v(" " + e._s(e._document.$t(`vat.${e.setPricesIncVat ? "incVat" : "exVat"}`)) + " ")]) : e._e()], 1), e.showDiscountInput ? t("div", { staticClass: "flex", staticStyle: { "margin-bottom": "1.5em" } }, [t("CField", { staticClass: "label-selector form-control form-control-left flex-grow", staticStyle: { "margin-bottom": "0" }, attrs: { label: e.$t("discount").capitalize(), "label-position": "inside" } }, [t("CPriceInput", { ref: "discountInput", staticClass: "input-selector", attrs: { value: e.article.discount, currency: e.article.currency, "is-inc-vat": e.article.discountType !== "percentage" && e.setPricesIncVat, vat: e.article.vat, "suffix-class": "text-gray-400" }, on: { input: function(i) {
1213
+ e.updateArticle(Math.abs(i), "discount");
1214
+ } } }, [e.article.discountType === "fixed" ? t("template", { slot: "suffix" }, [e._v(" " + e._s(e._document.$t(`vat.${e.setPricesIncVat ? "incVat" : "exVat"}`)) + " ")]) : t("template", { slot: "suffix" }, [e._v(" " + e._s(e.getCurrencySymbol(e.article.currency)) + " ")])], 2)], 1), t("div", { staticClass: "select-css form-control form-control-right", staticStyle: { width: "5em" }, on: { click: function(i) {
1215
+ return e.updateArticle(
1216
+ e.article.discountType === "percentage" ? "fixed" : "percentage",
1217
+ "discountType"
1218
+ );
1219
+ } } }, [e._v(" " + e._s(e.article.discountType === "percentage" ? "%" : e.getCurrencySymbol(e.article.currency)) + " ")])], 1) : e._e()], t("div", { staticStyle: { margin: "calc(1 * var(--rem)) calc(-0.5 * var(--rem))" } }, [e.useVat ? [e.feature("regionSE") && Number.isInteger(e.article.vat) ? t("select", { staticClass: "select-css tag-item no-chevron", staticStyle: { display: "inline", "min-height": "initial", background: "hsl(0, 0%, 94%)", "border-color": "hsl(0, 0%, 94%)", color: "hsl(0, 0%, 30%)" }, domProps: { value: e.article.vat }, on: { input: function(i) {
1220
+ e.updateArticle(Number.parseFloat(i.target.value), "vat");
1221
+ } } }, e._l(e.vatOptions, function({ translation: i, value: n }, s) {
1222
+ return t("option", { key: s, domProps: { value: n } }, [e._v(" " + e._s(e.$t(`vat.${e.vatType}`)) + " " + e._s(i) + " ")]);
1223
+ }), 0) : t("span", { staticClass: "select-css tag-item no-chevron", staticStyle: { display: "inline", "min-height": "initial", background: "hsl(0, 0%, 94%)", "border-color": "hsl(0, 0%, 94%)", color: "hsl(0, 0%, 30%)" } }, [e._v(" " + e._s(e._document.$t("vat").capitalize()) + " "), t("input", { staticStyle: { width: "calc(2.5 * var(--rem))", display: "inline", background: "hsl(0, 0%, 94%)", "border-color": "hsl(0, 0%, 94%)", color: "hsl(0, 0%, 30%)" }, attrs: { type: "number" }, domProps: { value: e.article.vat || 0 }, on: { blur: e.onCustomVatBlur, input: e.onCustomVatInput } }), e._v(" % ")])] : e._e(), e.priceTypeOptions.length ? t("div", { staticClass: "tag-group", staticStyle: { display: "flex", "flex-direction": "row", "flex-wrap": "wrap", "margin-top": "1em" } }, e._l(e.priceTypeOptions, function({ label: i, value: n, onClick: s, tooltip: r }, c) {
1224
+ return t("div", { directives: [{ name: "tooltip", rawName: "v-tooltip", value: {
1225
+ content: r,
1226
+ delay: { show: 300, hide: 0 }
1227
+ }, expression: `{
1228
+ content: tooltip,
1229
+ delay: { show: 300, hide: 0 }
1230
+ }` }], key: i + c, staticClass: "tag-item", class: { active: n }, on: { click: s } }, [e._v(" " + e._s(i) + " ")]);
1231
+ }), 0) : e._e(), t("div", { staticStyle: { display: "flex", "flex-direction": "row", "flex-wrap": "wrap", "margin-top": "1em" } }, e._l(e.checkboxItems, function({ label: i, value: n, onClick: s }, r) {
1232
+ return t("div", { key: i + r, staticClass: "tag-item", class: { active: n }, on: { click: s } }, [e._v(" " + e._s(i) + " ")]);
1233
+ }), 0)], 2)], 2)]), t("div", { staticClass: "flex space-x-4 overflow-hidden p-4 md:p-9" }, [t("CButton", { directives: [{ name: "tooltip", rawName: "v-tooltip", value: {
1234
+ offset: 7,
1235
+ html: !0,
1236
+ content: `
1237
+ <div style='margin-bottom: 0.6em;'>
1238
+ ${e.$t("saveAndAddTooltip")}
1239
+ </div>
1240
+ <div class='flex items-center justify-center' style='padding-bottom: 0.5em;'>
1241
+ <div style='text-align: center; background-color: hsl(0, 0%, 40%); line-height: 1; border-radius: 0.5em; display: inline-flex; align-items: center; justify-content: center; padding: 0.5em;'>
1242
+ <svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 35 35'><path fill='none' stroke='#ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M11.208 31h12.584V15.895h8.732L17.5 1.39 2.476 15.895h8.732V31z'/></svg>
1243
+ </div>
1244
+ <div style='text-align: center; background-color: hsl(0, 0%, 40%); line-height: 1; border-radius: 0.5em; display: inline-flex; align-items: center; justify-content: center; padding: 0.5em; margin-left: 0.5em;'>
1245
+ <svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 -12 50 50'><path fill='none' stroke='#ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' stroke d='M45.706.897c.55.002.994.458.993.994l-.036 18.01c0 .55-.44.996-1.008.996H5.12l10.568 8.886-1.467 1.738L0 19.758 14.22 8l1.468 1.738L5.12 18.624h38.987c.162 0 .293-.134.293-.296V3.445c0-.163-.144-.295-.292-.295H32.054c-.278 0-.504-.23-.504-.5v-1.3c0-.277.214-.5.504-.498l13.652.045z'/></svg>
1246
+ </div>
1247
+ </div>
1248
+ `
1249
+ }, expression: `{
1250
+ offset: 7,
1251
+ html: true,
1252
+ content: \`
1253
+ <div style='margin-bottom: 0.6em;'>
1254
+ \${$t('saveAndAddTooltip')}
1255
+ </div>
1256
+ <div class='flex items-center justify-center' style='padding-bottom: 0.5em;'>
1257
+ <div style='text-align: center; background-color: hsl(0, 0%, 40%); line-height: 1; border-radius: 0.5em; display: inline-flex; align-items: center; justify-content: center; padding: 0.5em;'>
1258
+ <svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 35 35'><path fill='none' stroke='#ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M11.208 31h12.584V15.895h8.732L17.5 1.39 2.476 15.895h8.732V31z'/></svg>
1259
+ </div>
1260
+ <div style='text-align: center; background-color: hsl(0, 0%, 40%); line-height: 1; border-radius: 0.5em; display: inline-flex; align-items: center; justify-content: center; padding: 0.5em; margin-left: 0.5em;'>
1261
+ <svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 -12 50 50'><path fill='none' stroke='#ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' stroke d='M45.706.897c.55.002.994.458.993.994l-.036 18.01c0 .55-.44.996-1.008.996H5.12l10.568 8.886-1.467 1.738L0 19.758 14.22 8l1.468 1.738L5.12 18.624h38.987c.162 0 .293-.134.293-.296V3.445c0-.163-.144-.295-.292-.295H32.054c-.278 0-.504-.23-.504-.5v-1.3c0-.277.214-.5.504-.498l13.652.045z'/></svg>
1262
+ </div>
1263
+ </div>
1264
+ \`
1265
+ }` }], staticStyle: { padding: "1.75em", height: "4em", "font-size": "16px", "background-color": "hsl(231, 4%, 20%)", "border-color": "hsl(231, 4%, 20%)" }, attrs: { type: "primary", tabindex: "0", size: "large" }, on: { click: e.addNewArticle } }, [t("CIcon", { staticStyle: { margin: "-3px" }, attrs: { type: "zap", size: "21" } })], 1), t("CButton", { staticClass: "flex-grow", staticStyle: { padding: "1.75em", height: "4em", "font-size": "16px" }, attrs: { size: "large", type: "secondary", "full-width": "", tabindex: "0" }, on: { click: e.onSaveArticle } }, [e._v(" " + e._s(e.$t("save")) + " ")])], 1)], 1)]);
1266
+ }, ct = [], lt = /* @__PURE__ */ u(
1267
+ rt,
1268
+ ot,
1269
+ ct,
1270
+ !1,
1271
+ null,
1272
+ "2b66c814"
1273
+ );
1274
+ const ut = lt.exports, dt = {
1275
+ i18nOptions: {
1276
+ name: "ArticleListEdit",
1277
+ namespaces: "ArticleListEdit",
1278
+ messages: {
1279
+ en: {
1280
+ vatOption: {
1281
+ label: "Enter",
1282
+ message: "You are now entering prices {{- vatOption}}."
1283
+ }
1284
+ },
1285
+ sv: {
1286
+ vatOption: {
1287
+ label: "Ange",
1288
+ message: "Du anger priser {{- vatOption}} nu"
1289
+ }
1290
+ }
1291
+ }
1292
+ },
1293
+ components: {
1294
+ // eslint-disable-next-line vue/no-reserved-component-names
1295
+ Article: He,
1296
+ ArticleModal: ut,
1297
+ WithDimensions: ae,
1298
+ draggable: se
1299
+ },
1300
+ mixins: [y([])],
1301
+ props: {
1302
+ _document: {
1303
+ type: Object,
1304
+ default: () => ({})
1305
+ },
1306
+ articles: {
1307
+ type: Array,
1308
+ required: !0
1309
+ },
1310
+ activeHouseWorkType: {
1311
+ type: String,
1312
+ default: null
1313
+ },
1314
+ rootPriceType: {
1315
+ type: String,
1316
+ default: "fixed"
1317
+ },
1318
+ hideControls: {
1319
+ type: Boolean,
1320
+ default: !1
1321
+ }
1322
+ },
1323
+ data() {
1324
+ return {
1325
+ selectedIndex: null,
1326
+ showModal: !1
1327
+ };
1328
+ },
1329
+ computed: {
1330
+ ...h({
1331
+ hidePriceInput: "settings/allowHideDocArticlePriceInput",
1332
+ hidePriceOnNew: "settings/hidePriceOnNewlyAddedArticles"
1333
+ }),
1334
+ articlesWithTotal() {
1335
+ return w(this.articles);
1336
+ },
1337
+ isIndivid() {
1338
+ return o(this._document, "prices.helpers.isIndivid", !0);
1339
+ },
1340
+ setPricesIncVat() {
1341
+ return o(this, "_document.setPricesIncVat", null);
1342
+ },
1343
+ currency() {
1344
+ return o(this._document, "currency");
1345
+ },
1346
+ useVat() {
1347
+ return o(this, "_document.useVat");
1348
+ },
1349
+ vatType() {
1350
+ return o(this, "_document.vatType");
1351
+ },
1352
+ showVatToggle() {
1353
+ return this.useVat && (this.setPricesIncVat || (this.articles || []).some(({ vat: a }) => a !== null));
1354
+ }
1355
+ },
1356
+ watch: {
1357
+ activeHouseWorkType: {
1358
+ immediate: !0,
1359
+ handler(a) {
1360
+ this.toggleDeductions(a);
1361
+ }
1362
+ },
1363
+ isIndivid(a) {
1364
+ a || this.toggleDeductions(!1);
1365
+ },
1366
+ setPricesIncVat(a) {
1367
+ this.updateArticlesVatOption(), this.showMessage({
1368
+ type: "info",
1369
+ message: this.$t("vatOption.message", {
1370
+ vatOption: this.$t(`_common:vat.${a ? "incVat" : "exVat"}`, {
1371
+ thing: this.$t("_common:vat.sharedTitle")
1372
+ })
1373
+ }),
1374
+ omit: "$view:extension,$view:widget"
1375
+ });
1376
+ }
1377
+ },
1378
+ methods: {
1379
+ ...v({
1380
+ showMessage: p.SHOW_MESSAGE
1381
+ }),
1382
+ openModal(a, { focusEl: e = "" } = {}) {
1383
+ this.selectedIndex = a, this.showModal = !0, e && this.$nextTick(() => {
1384
+ this.$nextTick(() => {
1385
+ this.$refs.articleModal && this.$refs.articleModal.focusEl(e);
1386
+ });
1387
+ });
1388
+ },
1389
+ updateArticleObject(a, e) {
1390
+ const t = e;
1391
+ this.isIndivid || (t.isDeductable = !1, t.isRut = !1, t.greenRot15 = !1, t.greenRot20 = !1, t.greenRot50 = !1), this.$emit("input", { index: a, value: t });
1392
+ },
1393
+ onRemoveArticle(a) {
1394
+ this.$emit("remove", a);
1395
+ },
1396
+ onEsc(a, e) {
1397
+ a === this.articles.length - 1 && ["name", "price", "discount"].every((t) => !e[t]) && this.onRemoveArticle(a);
1398
+ },
1399
+ changeVat() {
1400
+ this.$emit("update:setPricesIncVat", !this.setPricesIncVat);
1401
+ },
1402
+ updateArticlesVatOption() {
1403
+ this.articles.forEach((a, e) => {
1404
+ if (a.priceType === "markup")
1405
+ return;
1406
+ let t = g({ amount: a.price }).divide(
1407
+ (100 + a.vat) * 0.01
1408
+ );
1409
+ this.setPricesIncVat || (t = g({ amount: a.price }).multiply(
1410
+ (100 + a.vat) * 0.01
1411
+ )), this.updateArticleObject(
1412
+ e,
1413
+ w({ ...a, price: t.getAmount() })
1414
+ );
1415
+ });
1416
+ },
1417
+ // Method used by parent component
1418
+ focusLastArticle() {
1419
+ this.$nextTick(
1420
+ () => this.$refs.articleItem[this.articles.length - 1].focusName()
1421
+ );
1422
+ },
1423
+ openLastArticle() {
1424
+ this.$nextTick(() => this.openModal(this.articles.length - 1));
1425
+ },
1426
+ toggleDeductions(a) {
1427
+ const e = {
1428
+ rot: "isDeductable",
1429
+ rut: "isRut",
1430
+ greenRot15: "greenRot15",
1431
+ greenRot20: "greenRot20",
1432
+ greenRot50: "greenRot50"
1433
+ }, t = (i = []) => i.reduce((n, s) => ({ ...n, [s]: !1 }), {});
1434
+ e[a] ? this.articles.forEach((i, n) => {
1435
+ const s = Object.values(V(e, [a]));
1436
+ if (s.some((r) => !!i[r])) {
1437
+ const r = { ...i, ...t(s) };
1438
+ this.$emit("input", { index: n, value: r });
1439
+ }
1440
+ }) : a === !1 && this.articles.forEach((i, n) => {
1441
+ const s = Object.values(e);
1442
+ if (s.some((r) => !!i[r])) {
1443
+ const r = { ...i, ...t(s) };
1444
+ this.$emit("input", { index: n, value: r });
1445
+ }
1446
+ });
1447
+ },
1448
+ onChange(a) {
1449
+ const { added: e, moved: t, removed: i } = a;
1450
+ if (e) {
1451
+ const { newIndex: n, element: s } = e;
1452
+ this.$emit("insert", { index: n, value: s });
1453
+ } else if (t) {
1454
+ const n = T(
1455
+ this.articles,
1456
+ t.oldIndex,
1457
+ t.newIndex
1458
+ );
1459
+ this.$emit("move", n);
1460
+ } else if (i) {
1461
+ const { oldIndex: n } = i;
1462
+ this.$emit("remove", n);
1463
+ }
1464
+ }
1465
+ }
1466
+ };
1467
+ var pt = function() {
1468
+ var e = this, t = e._self._c;
1469
+ return t("div", [e.showVatToggle ? t("div", { staticClass: "label-text" }, [e._v(" " + e._s(e.$t("vatOption.label")) + " "), t("span", { on: { click: function(i) {
1470
+ return e.changeVat();
1471
+ } } }, [e._v(" " + e._s(e._document.$t(`vat.${e.setPricesIncVat ? "incVat" : "exVat"}`)) + " ")])]) : e._e(), t("WithDimensions", { scopedSlots: e._u([{ key: "default", fn: function({ width: i }) {
1472
+ return [t("draggable", e._b({ staticStyle: { "min-height": "calc(3 * var(--rem))" }, attrs: { value: e.articles, group: "articles" }, on: { change: e.onChange } }, "draggable", {
1473
+ sort: !0,
1474
+ animation: 150,
1475
+ ghostClass: "article-ghost",
1476
+ handle: ".article-draggable-handle"
1477
+ }, !1), [t("transition-group", { staticStyle: { position: "relative", transition: "100ms" }, attrs: { name: "article-list" } }, e._l(e.articlesWithTotal, function(n, s) {
1478
+ return t("Article", { key: n._uniqueId || 0, ref: "articleItem", refInFor: !0, staticClass: "article-item", attrs: { value: n, width: i, "hide-price-input": e.hidePriceInput, "hide-price-on-new": e.hidePriceOnNew, "is-inc-vat": e.setPricesIncVat, "hide-controls": e.hideControls, "root-price-type": e.rootPriceType, "active-house-work-type": e.activeHouseWorkType }, on: { "update:currency": function(r) {
1479
+ return e.$emit("update:currency", r);
1480
+ }, input: function(r) {
1481
+ return e.updateArticleObject(s, r);
1482
+ }, focus: function(r) {
1483
+ return e.$emit("focus");
1484
+ }, remove: function(r) {
1485
+ return e.onRemoveArticle(s);
1486
+ }, "open-modal": function(r) {
1487
+ return e.openModal(s, r);
1488
+ }, add: function(r) {
1489
+ s === e.articlesWithTotal.length - 1 && e.$emit("add");
1490
+ }, select: function(r) {
1491
+ s === e.articlesWithTotal.length - 1 && e.$emit("add");
1492
+ }, esc: function(r) {
1493
+ return e.onEsc(s, n);
1494
+ } } });
1495
+ }), 1)], 1)];
1496
+ } }]) }), t("Portal", { attrs: { to: "modal" } }, [e.showModal && e.articlesWithTotal[e.selectedIndex] ? t("ArticleModal", { ref: "articleModal", attrs: { _document: e._document, index: e.selectedIndex, "article-list": e.articlesWithTotal, "hide-price-input": e.hidePriceInput, "hide-price-on-new": e.hidePriceOnNew, "is-inc-vat": e.setPricesIncVat, "root-price-type": e.rootPriceType, currency: e.currency, "active-house-work-type": e.activeHouseWorkType, "view-settings": e.viewSettings }, on: { "update:currency": function(i) {
1497
+ return e.$emit("update:currency", i);
1498
+ }, input: function(i) {
1499
+ return e.updateArticleObject(e.selectedIndex, i);
1500
+ }, add: function(i) {
1501
+ return e.$emit("add", i);
1502
+ }, "open-modal": e.openModal, close: function(i) {
1503
+ e.showModal = !1;
1504
+ } } }) : e._e()], 1)], 1);
1505
+ }, ht = [], mt = /* @__PURE__ */ u(
1506
+ dt,
1507
+ pt,
1508
+ ht,
1509
+ !1,
1510
+ null,
1511
+ "9a09578d"
1512
+ );
1513
+ const ft = mt.exports, vt = {
1514
+ name: "MaxTotalInput",
1515
+ i18nOptions: {
1516
+ namespaces: "MaxTotalInput",
1517
+ messages: {
1518
+ en: {
1519
+ maxTotalLabel: "Add a price"
1520
+ },
1521
+ sv: {
1522
+ maxTotalLabel: "Ange ett pris"
1523
+ }
1524
+ }
1525
+ },
1526
+ components: {
1527
+ CPriceInput: x
1528
+ },
1529
+ props: {
1530
+ value: {
1531
+ type: Number,
1532
+ default: null
1533
+ },
1534
+ currency: {
1535
+ type: String,
1536
+ required: !0
1537
+ },
1538
+ vatType: {
1539
+ type: String,
1540
+ required: !0
1541
+ }
1542
+ },
1543
+ data() {
1544
+ return {
1545
+ getCurrencySymbol: C
1546
+ };
1547
+ },
1548
+ computed: {
1549
+ ...h({
1550
+ isIncVat: "application/isIncVat"
1551
+ })
1552
+ },
1553
+ watch: {
1554
+ isIncVat(a) {
1555
+ let e = g({ amount: this.value }).divide(1.25);
1556
+ a || (e = g({ amount: this.value }).multiply(125 * 0.01)), this.$emit("input", e.getAmount());
1557
+ }
1558
+ }
1559
+ };
1560
+ var gt = function() {
1561
+ var e = this, t = e._self._c;
1562
+ return t("div", { staticClass: "flex w-full justify-end" }, [t("CPriceInput", { staticClass: "mt-4 max-w-[275px] text-sm", attrs: { value: e.value, currency: e.currency, "is-inc-vat": e.isIncVat, vat: 25, placeholder: e.$t("maxTotalLabel"), min: "0", "prefix-class": "text-gray-400", "suffix-class": "text-gray-400" }, on: { input: function(i) {
1563
+ return e.$emit("input", i);
1564
+ } } }, [t("template", { slot: "prefix" }, [e._v(e._s(e.$t("price.maxPrice").capitalize()))]), t("template", { slot: "suffix" }, [t("span", [e._v(" " + e._s(e.getCurrencySymbol(e.currency)) + " " + e._s(e.$t(`vat.${e.isIncVat ? "incVat" : "exVat"}`, { thing: e.$t(`vat.${e.vatType}`) })) + " ")])])], 2)], 1);
1565
+ }, yt = [], _t = /* @__PURE__ */ u(
1566
+ vt,
1567
+ gt,
1568
+ yt,
1569
+ !1,
1570
+ null,
1571
+ null
1572
+ );
1573
+ const kt = _t.exports, $t = {
1574
+ props: {
1575
+ value: {
1576
+ type: String,
1577
+ default: "fixed"
1578
+ }
1579
+ },
1580
+ data() {
1581
+ return {
1582
+ priceTypeOptions: ["fixed", "approx", "openAcc", "openAccMaxPrice"]
1583
+ };
1584
+ }
1585
+ };
1586
+ var xt = function() {
1587
+ var e = this, t = e._self._c;
1588
+ return t("div", { staticClass: "flex justify-end" }, [t("CDropdown", { attrs: { value: e.value } }, [t("CButton", { staticClass: "price-type-button", attrs: { slot: "trigger" }, slot: "trigger" }, [e._v(" " + e._s(e.$t("price.pricing").capitalize()) + ": "), t("span", [e._v(e._s(e.$t(`price.${e.value}`)))])]), e._l(e.priceTypeOptions, function(i) {
1589
+ return t("CDropdownItem", { key: i, staticClass: "text-right", attrs: { value: i }, on: { click: function(n) {
1590
+ return e.$emit("input", i);
1591
+ } } }, [e._v(" " + e._s(e.$t(`price.${i}`)) + " ")]);
1592
+ })], 2)], 1);
1593
+ }, bt = [], wt = /* @__PURE__ */ u(
1594
+ $t,
1595
+ xt,
1596
+ bt,
1597
+ !1,
1598
+ null,
1599
+ "11bdf1f4"
1600
+ );
1601
+ const Ct = wt.exports, Tt = {
1602
+ name: "EditDeduction",
1603
+ components: {
1604
+ CPriceInput: x
1605
+ },
1606
+ mixins: [y(["houseWorkManualAmount"])],
1607
+ props: {
1608
+ disabled: {
1609
+ type: Boolean,
1610
+ default: !1
1611
+ },
1612
+ total: {
1613
+ type: Number,
1614
+ required: !0
1615
+ },
1616
+ houseWorkType: {
1617
+ type: String,
1618
+ default: "rot"
1619
+ },
1620
+ houseWorkAmount: {
1621
+ type: Number,
1622
+ default: 0
1623
+ }
1624
+ },
1625
+ data() {
1626
+ return {
1627
+ amountUnit: "fixed",
1628
+ internalValue: null
1629
+ };
1630
+ },
1631
+ watch: {
1632
+ houseWorkType(a) {
1633
+ a || (this.houseWorkManualAmount = null);
1634
+ }
1635
+ },
1636
+ methods: {
1637
+ setDeduction(a) {
1638
+ this.internalValue = g({ amount: this.total }).multiply(a).getAmount();
1639
+ },
1640
+ showModal() {
1641
+ this.internalValue = this.houseWorkAmount, this.$modal.show(`deduction-modal-${this._uid}`);
1642
+ }
1643
+ }
1644
+ };
1645
+ var It = function() {
1646
+ var e = this, t = e._self._c;
1647
+ return t("div", [t("modal", e._b({ attrs: { name: `deduction-modal-${e._uid}` } }, "modal", {
1648
+ adaptive: !0,
1649
+ height: "auto",
1650
+ width: "90%",
1651
+ maxWidth: 420,
1652
+ classes: "primary"
1653
+ }, !1), [t("div", { staticClass: "deduction-modal flex w-full flex-col items-center justify-between rounded-lg" }, [t("div", { staticStyle: { "font-size": "calc(calc(1 * var(--rem)) + 2px)", "font-weight": "800", "text-align": "center", "margin-bottom": "calc(1.5 * var(--rem))" } }, [e._v(" " + e._s(e.$t("deduction.manualType", { type: e.houseWorkType })) + " ")]), t("div", { staticStyle: { "margin-bottom": "calc(1 * var(--rem))", width: "100%" } }, [t("CPriceInput", { attrs: { currency: "SEK", placeholder: e.$t("enterThing", { thing: e.$t("deduction.deduction") }), min: "0", size: "medium", "suffix-class": "text-gray-400" }, scopedSlots: e._u([{ key: "suffix", fn: function() {
1654
+ return [e._v(e._s(e.$t("currency.SEK")))];
1655
+ }, proxy: !0 }]), model: { value: e.internalValue, callback: function(i) {
1656
+ e.internalValue = e._n(i);
1657
+ }, expression: "internalValue" } })], 1), t("div", { staticClass: "flex w-full flex-wrap justify-center gap-2" }, e._l([
1658
+ { v: 0.09, l: "9%" },
1659
+ { v: 0.105, l: "10.5%" },
1660
+ { v: 0.1455, l: "14.55%" },
1661
+ { v: 0.194, l: "19.4%" },
1662
+ { v: 0.21, l: "21%" },
1663
+ { v: 0.485, l: "48.5%" },
1664
+ { v: 0.5, l: "50%" }
1665
+ ], function(i) {
1666
+ return t("div", { key: i.l, staticClass: "deduction-button", class: {
1667
+ active: Math.round(e.total * i.v * 0.01) * 100 === e.internalValue
1668
+ }, on: { click: function(n) {
1669
+ return e.setDeduction(i.v);
1670
+ } } }, [e._v(" " + e._s(i.l) + " ")]);
1671
+ }), 0), t("CButton", { staticClass: "mt-8", attrs: { type: "secondary", wide: "" }, on: { click: function(i) {
1672
+ e.houseWorkManualAmount = e.internalValue, e.$modal.hide(`deduction-modal-${e._uid}`);
1673
+ } } }, [e._v(" " + e._s(e.$t("save")) + " ")]), t("CButton", { staticClass: "mt-2", attrs: { type: "secondary", pattern: "tertiary", wide: "" }, on: { click: function(i) {
1674
+ e.houseWorkManualAmount = null, e.$modal.hide(`deduction-modal-${e._uid}`);
1675
+ } } }, [e._v(" " + e._s(e.$t("reset")) + " ")])], 1)]), e.houseWorkManualAmount ? t("portal", { attrs: { order: 2, to: "document-nav-bottom" } }, [t("div", { staticClass: "housework-manual-nav", on: { click: function(i) {
1676
+ return e.$modal.show(`deduction-modal-${e._uid}`);
1677
+ } } }, [t("svg", { staticClass: "css-i6dzq1", staticStyle: { "margin-right": "0.5em" }, attrs: { viewBox: "0 0 24 24", width: "12", height: "12", stroke: "currentColor", "stroke-width": "2", fill: "none", "stroke-linecap": "round", "stroke-linejoin": "round" } }, [t("path", { attrs: { d: "M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" } }), t("line", { attrs: { x1: "12", y1: "9", x2: "12", y2: "13" } }), t("line", { attrs: { x1: "12", y1: "17", x2: "12.01", y2: "17" } })]), e._v(" " + e._s(e.$t("deduction.manualType", { type: e.houseWorkType })) + " " + e._s(e.$t("using")) + " ")])]) : e._e()], 1);
1678
+ }, At = [], Pt = /* @__PURE__ */ u(
1679
+ Tt,
1680
+ It,
1681
+ At,
1682
+ !1,
1683
+ null,
1684
+ "f82c56ee"
1685
+ );
1686
+ const St = Pt.exports, Vt = {
1687
+ name: "Pricing",
1688
+ components: {
1689
+ EditDeduction: St
1690
+ },
1691
+ props: {
1692
+ _document: {
1693
+ type: Object,
1694
+ default: () => ({})
1695
+ },
1696
+ basePath: {
1697
+ type: String,
1698
+ default: "data.prices"
1699
+ },
1700
+ packageId: {
1701
+ type: String,
1702
+ default: null
1703
+ }
1704
+ },
1705
+ data() {
1706
+ return {
1707
+ get: o
1708
+ };
1709
+ },
1710
+ computed: {
1711
+ vatType() {
1712
+ return o(this, "_document.vatType");
1713
+ },
1714
+ priceArray() {
1715
+ return [
1716
+ {
1717
+ label: this._document.$t("price.net"),
1718
+ value: this.prices.subTotal
1719
+ },
1720
+ ...this.prices.useVat ? [
1721
+ {
1722
+ label: this._document.$t(`vat.${this.vatType}`),
1723
+ value: this.prices.taxAmount
1724
+ }
1725
+ ] : [],
1726
+ ...this.showHouseWork ? [
1727
+ {
1728
+ label: this._document.$t("deduction.type", {
1729
+ type: `${this.prices.region.houseWorkType}${this.prices.region.houseWorkManualAmount === null ? "_percentage" : ""}`
1730
+ }),
1731
+ value: -this.prices.region.houseWorkAmount,
1732
+ action: () => this.$refs.deduction.showModal()
1733
+ }
1734
+ ] : [],
1735
+ ...this.prices.rounding.enabled && this.prices.rounding.show ? [
1736
+ {
1737
+ label: this._document.$t(
1738
+ "chapters.pricingSummary.blocks.rounding"
1739
+ ),
1740
+ value: this.prices.roundingAmount
1741
+ }
1742
+ ] : [],
1743
+ ...this.prices.helpers.discount ? [
1744
+ {
1745
+ label: this._document.$t("price.discount"),
1746
+ value: -this.prices.helpers.discount
1747
+ }
1748
+ ] : [],
1749
+ {
1750
+ classList: "main",
1751
+ label: this._document.$t("total"),
1752
+ subLabel: this.prices.useVat ? this._document.$t("vat.incVat") : "",
1753
+ prefix: this.prices.type === "approx" ? `${this._document.$t("approx")} ` : "",
1754
+ value: this.prices.total
1755
+ },
1756
+ ...typeof this.prices.maxTotal == "number" ? [
1757
+ {
1758
+ classList: "main",
1759
+ label: this._document.$t("price.maxPrice"),
1760
+ subLabel: this.prices.useVat ? this._document.$t("vat.incVat") : "",
1761
+ value: Math.round(this.prices.maxTotal * 1.25 || 0)
1762
+ // ! Hard coded swedish VAT
1763
+ }
1764
+ ] : []
1765
+ ].map((e) => ({
1766
+ ...e,
1767
+ value: k(e.value, {
1768
+ showZero: !0,
1769
+ decimals: 2,
1770
+ currency: this.prices.currency
1771
+ })
1772
+ }));
1773
+ },
1774
+ prices() {
1775
+ const { prices: a } = this._document.packageGroups.getPackageById(
1776
+ this.packageId
1777
+ );
1778
+ return a;
1779
+ },
1780
+ showHouseWork() {
1781
+ return !!o(this.prices, "region.houseWorkType", !1) || !!o(this.prices, "region.houseWorkManualAmount", !1);
1782
+ }
1783
+ }
1784
+ };
1785
+ var Rt = function() {
1786
+ var e = this, t = e._self._c;
1787
+ return t("div", { staticClass: "price-bubble" }, [t("div", { staticClass: "flex w-full items-center justify-between" }, [e.showHouseWork ? t("EditDeduction", e._g({ ref: "deduction", attrs: { disabled: !e.get(e.prices, "region.houseWorkType", !1), _document: e._document, _value: {
1788
+ houseWorkManualAmount: `${e.basePath}.data.prices.region.houseWorkManualAmount`
1789
+ }, "house-work-type": e.prices.region.houseWorkType, "house-work-amount": e.prices.region.houseWorkAmount, total: e.prices.subTotal + e.prices.taxAmount } }, e.$listeners)) : e._e()], 1), t("div", e._l(e.priceArray, function(i, n) {
1790
+ return t("div", { key: n, staticClass: "price-row flex w-full justify-between", class: [i.classList || ""] }, [t("div", { staticClass: "price-label" }, [e._v(" " + e._s(i.label.capitalize()) + " "), i.subLabel ? t("span", { staticClass: "pricing-sub-label" }, [e._v(" " + e._s(i.subLabel) + " ")]) : e._e(), i.action ? t("span", { directives: [{ name: "tooltip", rawName: "v-tooltip", value: e.$t("edit", { thing: e.$t("deduction.deduction") }), expression: "$t('edit', { thing: $t('deduction.deduction') })" }], staticClass: "pricing-action", on: { click: function(s) {
1791
+ i.action && i.action();
1792
+ } } }, [t("svg", { attrs: { viewBox: "0 0 24 24", width: "15", height: "15", stroke: "currentColor", "stroke-width": "2.5", fill: "none", "stroke-linecap": "round", "stroke-linejoin": "round" } }, [t("path", { attrs: { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" } }), t("path", { attrs: { d: "M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" } })])]) : e._e()]), t("div", { staticClass: "price-value" }, [e._v(" " + e._s(i.prefix) + " " + e._s(i.value) + " ")])]);
1793
+ }), 0)]);
1794
+ }, Dt = [], Ot = /* @__PURE__ */ u(
1795
+ Vt,
1796
+ Rt,
1797
+ Dt,
1798
+ !1,
1799
+ null,
1800
+ "a1756759"
1801
+ );
1802
+ const Mt = Ot.exports, Lt = {
1803
+ name: "PackageItemEdit",
1804
+ i18nOptions: {
1805
+ namespaces: "PackageItemEdit",
1806
+ messages: {
1807
+ en: {
1808
+ base: "Default package",
1809
+ single: "Single option",
1810
+ option: "Selectable package",
1811
+ namePlaceholder: "Package name",
1812
+ textPlaceholder: "Package description",
1813
+ selected: "Pre selected",
1814
+ addButton: "Product / service",
1815
+ advancedButtonTooltip: "Open advanced settings"
1816
+ },
1817
+ sv: {
1818
+ base: "Grundpaket",
1819
+ single: "Ett alternativ",
1820
+ option: "Valbart alternativ",
1821
+ namePlaceholder: "Paketets namn",
1822
+ textPlaceholder: "Beskrivning av paketet",
1823
+ selected: "Förvald",
1824
+ addButton: "Vara / tjänst",
1825
+ advancedButtonTooltip: "Öppna avancerat läge"
1826
+ }
1827
+ }
1828
+ },
1829
+ components: {
1830
+ ArticleList: ft,
1831
+ PriceFormAlternatives: Ct,
1832
+ MaxTotalInput: kt,
1833
+ Pricing: Mt,
1834
+ TextEditor: ie
1835
+ },
1836
+ mixins: [
1837
+ y([
1838
+ "isSelectedDefault",
1839
+ "isSelected",
1840
+ "name",
1841
+ "description",
1842
+ "priceType",
1843
+ "maxTotal",
1844
+ "currency"
1845
+ ])
1846
+ ],
1847
+ props: {
1848
+ packageId: {
1849
+ type: String,
1850
+ required: !0
1851
+ },
1852
+ type: {
1853
+ type: String,
1854
+ required: !0
1855
+ },
1856
+ activeHouseWorkType: {
1857
+ type: String,
1858
+ default: null
1859
+ },
1860
+ toggable: {
1861
+ type: Boolean,
1862
+ default: !0
1863
+ },
1864
+ moveOptions: {
1865
+ type: Object,
1866
+ default: () => ({})
1867
+ }
1868
+ },
1869
+ data() {
1870
+ return {
1871
+ isFocus: !1,
1872
+ isHover: !1
1873
+ };
1874
+ },
1875
+ computed: {
1876
+ ...h({
1877
+ newArticle: "articles/getNewArticle"
1878
+ }),
1879
+ // keep info on original article array indices for updates
1880
+ articles() {
1881
+ return this._document.allArticles;
1882
+ },
1883
+ mappedPackageArticles() {
1884
+ return (this.articles || []).map((a, e) => ({ ...a, i: e })).filter(({ packageId: a }) => a === this.packageId);
1885
+ },
1886
+ internalDescription: {
1887
+ get() {
1888
+ return J(
1889
+ this.description,
1890
+ this._document.textTemplateMap,
1891
+ this._document._doc
1892
+ );
1893
+ },
1894
+ set(a) {
1895
+ this.description = Q(a);
1896
+ }
1897
+ }
1898
+ },
1899
+ watch: {
1900
+ priceType(a, e) {
1901
+ if (!(a && a.startsWith("open") && e && e.startsWith("open"))) {
1902
+ if (a) {
1903
+ const t = a.startsWith("open") ? "openAcc" : a;
1904
+ this.mappedPackageArticles.forEach((i, n) => {
1905
+ this.onArticleInput({
1906
+ index: n,
1907
+ value: {
1908
+ ...i,
1909
+ priceType: t,
1910
+ ...t === "openAcc" && { quantity: 1 }
1911
+ }
1912
+ });
1913
+ });
1914
+ }
1915
+ }
1916
+ a !== "openAccMaxPrice" && (this.maxTotal = null);
1917
+ }
1918
+ },
1919
+ methods: {
1920
+ onRemove() {
1921
+ this.$emit("remove-package");
1922
+ },
1923
+ // Article Methods
1924
+ createEmptyArticle() {
1925
+ const a = this.newArticle({
1926
+ priceType: this.priceType.startsWith("open") ? "openAcc" : this.priceType,
1927
+ packageId: this.packageId,
1928
+ currency: this.currency
1929
+ });
1930
+ this.$emit("input", {
1931
+ key: "articles",
1932
+ value: [...this.articles, a]
1933
+ });
1934
+ },
1935
+ onArticleInput({ index: a, value: e }) {
1936
+ const { i: t } = this.mappedPackageArticles[a], i = X(e, [
1937
+ "allowRot",
1938
+ "allowRut",
1939
+ "isIncVat",
1940
+ "rootPriceType",
1941
+ "hideControls"
1942
+ ]);
1943
+ i.currency = this.currency, this.$emit("input", { key: `articles[${[t]}]`, value: i });
1944
+ },
1945
+ onArticleAdd({ openModal: a = !1 } = {}) {
1946
+ this.createEmptyArticle(), a ? this.$refs.articleList.openLastArticle() : this.$refs.articleList.focusLastArticle();
1947
+ },
1948
+ onInsert({ index: a, value: e }) {
1949
+ const t = ee(this.mappedPackageArticles).add(
1950
+ { ...e, packageId: this.packageId },
1951
+ a
1952
+ );
1953
+ this.$emit("input", {
1954
+ key: "articles",
1955
+ value: [
1956
+ ...this.articles.filter(
1957
+ ({ packageId: i }) => i !== this.packageId
1958
+ ),
1959
+ ...t
1960
+ ]
1961
+ });
1962
+ },
1963
+ onArticleRemove(a) {
1964
+ const { i: e } = this.mappedPackageArticles[a];
1965
+ this.$emit("remove", { key: `articles[${[e]}]` });
1966
+ },
1967
+ onArticleMove(a) {
1968
+ this.$emit("input", {
1969
+ key: "articles",
1970
+ value: [
1971
+ ...this.articles.filter(
1972
+ ({ packageId: e }) => e !== this.packageId
1973
+ ),
1974
+ ...a
1975
+ ]
1976
+ });
1977
+ }
1978
+ }
1979
+ };
1980
+ var Et = function() {
1981
+ var e = this, t = e._self._c;
1982
+ return t("div", { staticClass: "min-h-0 rounded-md border border-gray-200 bg-white text-black" }, [t("div", { staticClass: "flex w-full items-center justify-between bg-gray-100 py-1 pl-4 pr-1 text-sm font-medium text-gray-600" }, [t("div", [e._v(" " + e._s(e.type === "single" ? e.$t("single") : e.type === "radio" || e.toggable ? e.$t("option") : e.$t("base")) + " ")]), e.type !== "single" ? t("CDropdown", { staticClass: "ml-4" }, [t("CButton", { staticClass: "is-thinner opacity-70", attrs: { slot: "trigger", size: "small", type: "text", pattern: "secondary" }, slot: "trigger" }, [e._v(" " + e._s(e.$t("_common:change")) + " ")]), e.toggable ? [t("CDropdownItem", { attrs: { value: e.isSelectedDefault, toggle: !0, "close-on-click": !1 }, on: { click: function(i) {
1983
+ return e.$emit("update:isSelectedDefault", !e.isSelectedDefault);
1984
+ } } }, [e._v(" " + e._s(e.$t("selected")) + " ")]), t("CDropdownItem", { attrs: { separator: "" } })] : e._e(), t("CDropdownItem", { attrs: { "icon-left": "arrow-up", disabled: !e.moveOptions.up }, on: { click: function(i) {
1985
+ return e.$emit("move", -1);
1986
+ } } }, [e._v(" " + e._s(e.$t("_common:move", { thing: e.$t("_common:up") })) + " ")]), t("CDropdownItem", { attrs: { "icon-left": "arrow-down", disabled: !e.moveOptions.down }, on: { click: function(i) {
1987
+ return e.$emit("move", 1);
1988
+ } } }, [e._v(" " + e._s(e.$t("_common:move", { thing: e.$t("_common:down") })) + " ")]), t("CDropdownItem", { attrs: { "icon-props": {
1989
+ stroke: "red"
1990
+ }, "icon-left": "trash" }, on: { click: e.onRemove } }, [e._v(" " + e._s(e.$t("_common:remove")) + " ")])], 2) : e._e()], 1), t("div", { staticClass: "p-4" }, [t("div", { staticClass: "mb-0.5 flex items-center" }, [t("input", { directives: [{ name: "model", rawName: "v-model", value: e.name, expression: "name" }], staticClass: "block w-full rounded-lg p-0 text-xl font-bold leading-loose placeholder:text-gray-400", attrs: { id: `package-name-${e.packageId}`, placeholder: e.$t("namePlaceholder") }, domProps: { value: e.name }, on: { keyup: function(i) {
1991
+ return !i.type.indexOf("key") && e._k(i.keyCode, "enter", 13, i.key, "Enter") ? null : e.$refs.editor.focus();
1992
+ }, input: function(i) {
1993
+ i.target.composing || (e.name = i.target.value);
1994
+ } } })]), t("TextEditor", { ref: "editor", staticClass: "text-editor mb-4", attrs: { placeholder: e.$t("textPlaceholder"), mentions: () => e._document.textTemplateItems, snippets: !0 }, model: { value: e.internalDescription, callback: function(i) {
1995
+ e.internalDescription = i;
1996
+ }, expression: "internalDescription" } }), t("div", { directives: [{ name: "click-outside", rawName: "v-click-outside", value: () => {
1997
+ e.isFocus = !1, e.isHover = !1;
1998
+ }, expression: `
1999
+ () => {
2000
+ isFocus = false
2001
+ isHover = false
2002
+ }
2003
+ ` }], on: { "&mouseover": function(i) {
2004
+ e.isHover = !0;
2005
+ }, "&mouseleave": function(i) {
2006
+ e.isHover = !1;
2007
+ } } }, [e.priceType === "openAccMaxPrice" ? t("MaxTotalInput", { staticClass: "mb-4", attrs: { currency: e.currency, "vat-type": e._document.vatType }, model: { value: e.maxTotal, callback: function(i) {
2008
+ e.maxTotal = i;
2009
+ }, expression: "maxTotal" } }) : e._e(), t("PriceFormAlternatives", { on: { input: function(i) {
2010
+ return e.$emit("update:priceType", i);
2011
+ } }, model: { value: e.priceType, callback: function(i) {
2012
+ e.priceType = i;
2013
+ }, expression: "priceType" } }), t("ArticleList", { ref: "articleList", attrs: { _document: e._document, articles: e.mappedPackageArticles, "root-price-type": e.priceType, "active-house-work-type": e.activeHouseWorkType, "hide-controls": !e.isFocus && !e.isHover }, on: { input: e.onArticleInput, "update:setPricesIncVat": function(i) {
2014
+ return e.$emit("update:setPricesIncVat", i);
2015
+ }, "update:currency": function(i) {
2016
+ return e.$emit("update:currency", i);
2017
+ }, move: e.onArticleMove, remove: e.onArticleRemove, add: e.onArticleAdd, focus: function(i) {
2018
+ e.isFocus = !0;
2019
+ }, insert: e.onInsert } }), t("div", { staticClass: "mt-2 flex gap-2" }, [t("div", { staticClass: "cursor-pointer rounded-md border border-gray-200 bg-gray-100 p-2.5 text-center text-sm font-medium leading-none text-gray-500 transition-colors hover:border-gray-400 hover:bg-gray-500 hover:text-white", on: { click: function(i) {
2020
+ return e.onArticleAdd();
2021
+ } } }, [t("CIcon", { staticClass: "mr-1", attrs: { type: "plus", size: "16", "stroke-width": "3" } }), e._v(" " + e._s(e.$t("addButton")) + " ")], 1), t("div", { directives: [{ name: "tooltip", rawName: "v-tooltip", value: {
2022
+ content: e.$t("advancedButtonTooltip"),
2023
+ offset: 6
2024
+ }, expression: `{
2025
+ content: $t('advancedButtonTooltip'),
2026
+ offset: 6
2027
+ }` }], staticClass: "cursor-pointer rounded-md border border-gray-200 bg-gray-100 p-2.5 text-center text-sm font-medium leading-none text-gray-500 transition-colors hover:border-gray-400 hover:bg-gray-500 hover:text-white", on: { click: function(i) {
2028
+ return e.onArticleAdd({ openModal: !0 });
2029
+ } } }, [t("CIcon", { attrs: { type: "zap", size: "16", "stroke-width": "2.5" } })], 1)]), t("Pricing", e._g({ attrs: { _document: e._document, "base-path": `${e._value.basePath}`, "package-id": e.packageId } }, e.$listeners))], 1)], 1)]);
2030
+ }, zt = [], Bt = /* @__PURE__ */ u(
2031
+ Lt,
2032
+ Et,
2033
+ zt,
2034
+ !1,
2035
+ null,
2036
+ "ceed39fb"
2037
+ );
2038
+ const Wt = Bt.exports, Ft = (a) => (a || []).slice(0, 1).map((e) => ({
2039
+ ...e,
2040
+ isSelected: !0,
2041
+ isSelectedDefault: !0,
2042
+ toggable: !1
2043
+ })), jt = (a) => {
2044
+ const e = o(a, "0.data.prices.type") || "fixed";
2045
+ return (a || []).map((t, i) => ({
2046
+ ...t,
2047
+ toggable: !0,
2048
+ ...i === 0 ? {
2049
+ isSelected: !0,
2050
+ isSelectedDefault: !0,
2051
+ toggable: !1
2052
+ } : null,
2053
+ data: {
2054
+ ...t.data,
2055
+ prices: {
2056
+ ...t.data ? t.data.prices : null,
2057
+ type: e
2058
+ }
2059
+ }
2060
+ }));
2061
+ }, Nt = (a = []) => {
2062
+ let e = !1;
2063
+ return a.map((t) => {
2064
+ const i = {
2065
+ ...t,
2066
+ // if any earlier pkg is selected, deselect pkg, otherwise keep as is
2067
+ ...e ? {
2068
+ isSelected: !1,
2069
+ isSelectedDefault: !1
2070
+ } : null,
2071
+ toggable: !0
2072
+ };
2073
+ return (i.isSelected || i.isSelectedDefault) && (e = !0), i;
2074
+ }, []);
2075
+ };
2076
+ function Ht(a, ...e) {
2077
+ if (a === "single")
2078
+ return Ft(...e);
2079
+ if (a === "checkbox")
2080
+ return jt(...e);
2081
+ if (a === "radio")
2082
+ return Nt(...e);
2083
+ throw new Error(`Package filter type '${a}' is not implemented`);
2084
+ }
2085
+ const qt = {
2086
+ name: "PackageGroupEdit",
2087
+ i18nOptions: {
2088
+ namespaces: "PackageGroupEdit",
2089
+ messages: {
2090
+ en: {
2091
+ base: "Default package",
2092
+ add: "Add package",
2093
+ basePlaceholder: "Add a default package that's always included.",
2094
+ selectablePlaceholder: "Add packages your client can choose between.",
2095
+ hideGroupPrice: "Hide summary for block",
2096
+ reset: {
2097
+ message: "Package type changed",
2098
+ button: "Revert"
2099
+ },
2100
+ error: {
2101
+ selectType: "Choose price type",
2102
+ minOnePackage: "Add at least 1 package"
2103
+ }
2104
+ },
2105
+ sv: {
2106
+ base: "Grundpaket",
2107
+ add: "Valbart alternativ",
2108
+ basePlaceholder: "Lägg till ett baspaket som alltid ingår.",
2109
+ selectablePlaceholder: "Lägg till valbara paket som din kund kan välja mellan.",
2110
+ hideGroupPrice: "Dölj summering för block",
2111
+ reset: {
2112
+ message: "Pakettyp har ändrats",
2113
+ button: "Återställ"
2114
+ },
2115
+ error: {
2116
+ selectType: "Välj ett prisförslag",
2117
+ minOnePackage: "Lägg till minst 1 paket"
2118
+ }
2119
+ }
2120
+ }
2121
+ },
2122
+ components: {
2123
+ ErrorCallout: P,
2124
+ PackageItem: Wt,
2125
+ PackageGroupSelect: Oe
2126
+ },
2127
+ mixins: [
2128
+ y([
2129
+ "type",
2130
+ // 'title',
2131
+ "packages",
2132
+ "articles",
2133
+ "hideGroupPrice"
2134
+ ])
2135
+ ],
2136
+ props: {
2137
+ persistedGroup: {
2138
+ type: Object,
2139
+ default: () => ({})
2140
+ },
2141
+ validator: {
2142
+ type: Object,
2143
+ default: () => ({})
2144
+ }
2145
+ },
2146
+ data() {
2147
+ return {
2148
+ setPricesDirty: !1
2149
+ };
2150
+ },
2151
+ computed: {
2152
+ ...h({
2153
+ getSetting: ["settings/getCompanySetting"],
2154
+ defaultCurrency: "settings/defaultCurrency",
2155
+ newArticle: "articles/getNewArticle"
2156
+ }),
2157
+ internalPackages() {
2158
+ return this.packages.map((a, e) => ({ ...a, index: e }));
2159
+ },
2160
+ topRowPackages() {
2161
+ return this.type === "checkbox" ? this.internalPackages.filter(({ toggable: a }) => a === !1) : this.internalPackages;
2162
+ },
2163
+ bottomRowPackages() {
2164
+ return this.type === "checkbox" ? this.internalPackages.filter(({ toggable: a }) => a === !0) : [];
2165
+ },
2166
+ group() {
2167
+ return this._document.packageGroups.getPackageGroupUniqId(
2168
+ this._value.groupId
2169
+ ) || {};
2170
+ },
2171
+ houseWorkType() {
2172
+ return o(this.group, "prices.region.houseWorkType", null);
2173
+ },
2174
+ isIndivid() {
2175
+ return o(this, "_document.prices.helpers.isIndivid", !0);
2176
+ },
2177
+ setPricesIncVat() {
2178
+ return this._document.setPricesIncVat;
2179
+ },
2180
+ defaultVatInput() {
2181
+ return this.isIndivid ? this.getSetting("priceInputDefault") : this.getSetting("priceInputCompany");
2182
+ },
2183
+ currency() {
2184
+ return this._document.currency;
2185
+ }
2186
+ },
2187
+ watch: {
2188
+ isIndivid() {
2189
+ this.setPricesDirty || this.setPricesIncVatAsDefault();
2190
+ }
2191
+ },
2192
+ created() {
2193
+ this.setPricesIncVat === null && this.setPricesIncVatAsDefault({ ignoreChanges: !0 });
2194
+ },
2195
+ methods: {
2196
+ ...v({
2197
+ showMessage: p.SHOW_MESSAGE
2198
+ }),
2199
+ setPricesIncVatAsDefault(a = {}) {
2200
+ this.$emit("input", {
2201
+ key: "data.formSettings.setPricesIncVat",
2202
+ value: this.defaultVatInput === "incVat",
2203
+ options: a
2204
+ });
2205
+ },
2206
+ onSelectType(a) {
2207
+ this.type = a;
2208
+ const { type: e, packages: t } = this.persistedGroup || {};
2209
+ if (e && t && t.length)
2210
+ this.addPersistedGroup(a), a !== e && this.showMessage({
2211
+ type: "info",
2212
+ message: this.$t("reset.message"),
2213
+ actions: {
2214
+ undo: {
2215
+ text: this.$t("reset.button"),
2216
+ callback: () => {
2217
+ this.addPersistedGroup(e), this.type = e;
2218
+ }
2219
+ }
2220
+ }
2221
+ });
2222
+ else {
2223
+ if (a === "checkbox")
2224
+ return;
2225
+ this.addPackage({});
2226
+ }
2227
+ },
2228
+ addPersistedGroup(a) {
2229
+ if (!this.persistedGroup || !this.persistedGroup.type)
2230
+ return;
2231
+ let { packages: e, articles: t } = this.persistedGroup;
2232
+ if (!e.length)
2233
+ return;
2234
+ if (a !== this.persistedGroup.type && (e = Ht(a, e)), a === "single" && t.length) {
2235
+ const [{ packageId: n }] = e;
2236
+ t = t.filter((s) => s.packageId === n);
2237
+ }
2238
+ const i = Pe(
2239
+ [...this._document.allArticles || [], ...t || []],
2240
+ (n) => n._uniqueId
2241
+ );
2242
+ this.$emit("input", { key: "articles", value: i }), this.$emit("input", { key: `${[this._value.packages]}`, value: e });
2243
+ },
2244
+ addPackage(a = {}) {
2245
+ const e = te(), t = this.type === "checkbox" && this.packages.length ? this.packages[0].data.prices.type : "fixed", i = this.currency || this.defaultCurrency, n = {
2246
+ isSelected: this.type === "single",
2247
+ isSelectedDefault: this.type === "single",
2248
+ toggable: !0,
2249
+ packageId: e,
2250
+ data: {
2251
+ name: "",
2252
+ description: "",
2253
+ prices: {
2254
+ type: t,
2255
+ currency: i
2256
+ }
2257
+ },
2258
+ ...a
2259
+ };
2260
+ this.$emit("input", { key: this._value.packages, value: n }), this.$emit("input", {
2261
+ key: "articles",
2262
+ value: this.newArticle({
2263
+ priceType: t.startsWith("open") ? "openAcc" : t,
2264
+ packageId: e,
2265
+ currency: i
2266
+ })
2267
+ }), this.$nextTick(() => {
2268
+ const s = document.getElementById(`package-name-${e}`);
2269
+ s && s.focus();
2270
+ });
2271
+ },
2272
+ onInputPriceType(a, e) {
2273
+ this.type === "checkbox" && this.packages.forEach((t, i) => {
2274
+ i !== a && this.$emit("input", {
2275
+ key: `${[this._value.packages]}[${[i]}].data.prices.type`,
2276
+ value: e
2277
+ });
2278
+ });
2279
+ },
2280
+ onInputSelectedDefault(a, e) {
2281
+ this.type === "radio" && !e || (this.type === "radio" && e && this.packages.forEach((t, i) => {
2282
+ i !== a && (this.$emit("input", {
2283
+ key: `${[this._value.packages]}[${[i]}].isSelectedDefault`,
2284
+ value: !1
2285
+ }), this.$emit("input", {
2286
+ key: `${[this._value.packages]}[${[i]}].isSelected`,
2287
+ value: !1
2288
+ }));
2289
+ }), this.$emit("input", {
2290
+ key: `${[this._value.packages]}[${[a]}].isSelectedDefault`,
2291
+ value: e
2292
+ }), this.$emit("input", {
2293
+ key: `${[this._value.packages]}[${[a]}].isSelected`,
2294
+ value: e
2295
+ }));
2296
+ },
2297
+ removeByIndex(a) {
2298
+ const { packageId: e } = this.packages[a], t = this._document.allArticles.filter(
2299
+ ({ packageId: i }) => i !== e
2300
+ );
2301
+ this.$emit("input", { key: "articles", value: t }), this.$emit("remove", { key: `${[this._value.packages]}[${[a]}]` });
2302
+ },
2303
+ async onResetType() {
2304
+ const a = this.packages.map((i) => i.packageId), [e, t] = this._document.allArticles.reduce(
2305
+ ([i, n], s) => a.includes(s.packageId) ? [[...i, s], n] : [i, [...n, s]],
2306
+ [[], []]
2307
+ );
2308
+ this.$emit("update:persisted-group", {
2309
+ type: this.type,
2310
+ packages: this.packages,
2311
+ articles: e
2312
+ }), this.$emit("input", { key: "articles", value: t }), this.$emit("input", { key: `${[this._value.packages]}`, value: [] }), this.type = "";
2313
+ },
2314
+ moveOptions(a, e) {
2315
+ const t = { up: !1, down: !1 };
2316
+ return a > 0 && (t.up = !0), a < e - 1 && (t.down = !0), t;
2317
+ },
2318
+ moveItem(a, e) {
2319
+ const t = T(this.packages, a, e);
2320
+ this.$emit("input", { key: this._value.packages, value: t });
2321
+ }
2322
+ }
2323
+ };
2324
+ var Ut = function() {
2325
+ var e = this, t = e._self._c;
2326
+ return t("div", { staticClass: "package-group-root font-inter" }, [e.type ? [t("div", { staticStyle: { position: "absolute", right: "0", top: "-10px", transform: "translateY(-100%)", "z-index": "2" } }, [t("CDropdown", [t("CButton", { attrs: { slot: "trigger", type: "none", size: "normal", pattern: "secondary", icon: "more-horizontal", circle: "" }, slot: "trigger" }), t("CDropdownItem", { on: { click: e.onResetType } }, [e._v(e._s(e.$t("_common:change", { thing: e.$t("_common:price.proposal").toLowerCase() })))]), t("CDropdownItem", { attrs: { value: !!e.hideGroupPrice, "close-on-click": !1, toggle: "" }, on: { input: function(i) {
2327
+ e.hideGroupPrice = i;
2328
+ } } }, [e._v(" " + e._s(e.$t("hideGroupPrice")) + " ")])], 1)], 1), e.type === "checkbox" && !e.internalPackages.find((i) => i.toggable === !1) ? t("CCallout", { staticClass: "w-full", attrs: { title: e.$t("base") } }, [t("div", { staticClass: "pb-4" }, [e._v(" " + e._s(e.$t("basePlaceholder")) + " ")]), t("CButton", { staticStyle: { "font-weight": "600" }, attrs: { type: "secondary", size: "small" }, on: { click: function(i) {
2329
+ return e.addPackage({
2330
+ isSelected: !0,
2331
+ isSelectedDefault: !0,
2332
+ toggable: !1
2333
+ });
2334
+ } } }, [e._v(" " + e._s(e.$t("_common:add", { thing: e.$t("base").toLowerCase() })) + " ")])], 1) : t("transition-group", { attrs: { name: "section-list", tag: "div" } }, e._l(e.topRowPackages, function(i, n) {
2335
+ return t("div", { key: i.packageId, staticClass: "section-item pb-4" }, [t("PackageItem", { attrs: { _document: e._document, _value: {
2336
+ isSelectedDefault: `${e._value.packages}[${i.index}].isSelectedDefault`,
2337
+ isSelected: `${e._value.packages}[${i.index}].isSelected`,
2338
+ name: `${e._value.packages}[${i.index}].data.name`,
2339
+ description: `${e._value.packages}[${i.index}].data.description`,
2340
+ priceType: `${e._value.packages}[${i.index}].data.prices.type`,
2341
+ maxTotal: `${e._value.packages}[${i.index}].data.prices.maxTotal`,
2342
+ basePath: `${e._value.packages}[${i.index}]`,
2343
+ currency: `${e._value.packages}[${i.index}].data.prices.currency`
2344
+ }, type: e.type, "active-house-work-type": e.houseWorkType, toggable: i.toggable, "package-id": i.packageId, "move-options": e.moveOptions(n, e.topRowPackages.length) }, on: { input: function(s) {
2345
+ return e.$emit("input", s);
2346
+ }, add: function(s) {
2347
+ return e.$emit("add", s);
2348
+ }, "update:isSelectedDefault": (s) => e.onInputSelectedDefault(i.index, s), "update:priceType": (s) => e.onInputPriceType(i.index, s), "update:setPricesIncVat": (s) => {
2349
+ e.$emit("input", {
2350
+ key: "data.formSettings.setPricesIncVat",
2351
+ value: s
2352
+ }), e.setPricesDirty = !0;
2353
+ }, "update:currency": (s) => e.$emit("input", { key: "currency", value: s }), remove: function(s) {
2354
+ return e.$emit("remove", s);
2355
+ }, "remove-package": function(s) {
2356
+ return e.removeByIndex(i.index);
2357
+ }, move: function(s) {
2358
+ return e.moveItem(i.index, e.topRowPackages[n + s].index);
2359
+ } } })], 1);
2360
+ }), 0), e.type === "checkbox" && e.topRowPackages.length && e.bottomRowPackages.length ? t("div", { staticStyle: { width: "calc(5 * var(--rem))", height: "1px", "margin-left": "calc(50% - calc(2.5 * var(--rem)))", "border-top": "2px dashed hsl(0, 0%, 85%)" } }) : e._e(), e.type === "checkbox" ? [t("transition-group", { staticStyle: { "margin-bottom": "calc(1 * var(--rem))" }, attrs: { name: "section-list", tag: "div" } }, e._l(e.bottomRowPackages, function(i, n) {
2361
+ return t("div", { key: i.packageId, staticClass: "section-item", staticStyle: { padding: "calc(1 * var(--rem)) 0" } }, [t("PackageItem", { staticClass: "package-item", attrs: { _document: e._document, _value: {
2362
+ isSelectedDefault: `${e._value.packages}[${i.index}].isSelectedDefault`,
2363
+ isSelected: `${e._value.packages}[${i.index}].isSelected`,
2364
+ name: `${e._value.packages}[${i.index}].data.name`,
2365
+ description: `${e._value.packages}[${i.index}].data.description`,
2366
+ priceType: `${e._value.packages}[${i.index}].data.prices.type`,
2367
+ maxTotal: `${e._value.packages}[${i.index}].data.prices.maxTotal`,
2368
+ basePath: `${e._value.packages}[${i.index}]`,
2369
+ currency: `${e._value.packages}[${i.index}].data.prices.currency`
2370
+ }, type: e.type, "active-house-work-type": e.houseWorkType, "package-id": i.packageId, "move-options": e.moveOptions(n, e.bottomRowPackages.length) }, on: { input: function(s) {
2371
+ return e.$emit("input", s);
2372
+ }, add: function(s) {
2373
+ return e.$emit("add", s);
2374
+ }, "update:isSelectedDefault": (s) => e.onInputSelectedDefault(i.index, s), "update:priceType": (s) => e.onInputPriceType(i.index, s), "update:setPricesIncVat": (s) => {
2375
+ e.$emit("input", {
2376
+ key: "data.formSettings.setPricesIncVat",
2377
+ value: s
2378
+ }), e.setPricesDirty = !0;
2379
+ }, remove: function(s) {
2380
+ return e.$emit("remove", s);
2381
+ }, "remove-package": function(s) {
2382
+ return e.removeByIndex(i.index);
2383
+ }, move: function(s) {
2384
+ return e.moveItem(i.index, e.bottomRowPackages[n + s].index);
2385
+ } } })], 1);
2386
+ }), 0)] : e._e(), e.type !== "single" || !e.packages.length ? t("div", { staticClass: "flex w-full flex-col items-center justify-center" }, [t("div", { staticStyle: { width: "100%" } }, [e.type === "radio" && !e.packages.length ? t("div", { staticClass: "package-placeholder bg-gray-100", staticStyle: { color: "hsl(0, 0%, 24%)", "font-weight": "500" } }, [t("svg", { staticStyle: { "vertical-align": "text-bottom", "margin-right": "3px" }, attrs: { width: "16", height: "16", viewBox: "0 0 18 14", xmlns: "http://www.w3.org/2000/svg" } }, [t("path", { attrs: { d: "M8.03.22c.3.3.3.77 0 1.06L5.56 3.75h6.88L9.97 1.28A.75.75 0 1111.03.21l3.53 3.54h2.69a.75.75 0 010 1.5h-.12l-1.17 6.4a2.25 2.25 0 01-2.21 1.85h-9.5a2.25 2.25 0 01-2.21-1.84L.87 5.26H.75a.75.75 0 010-1.5h2.69L6.97.21c.3-.3.77-.3 1.06 0zM2.4 5.25L3.5 11.4c.07.35.38.61.74.61h9.5c.36 0 .67-.26.74-.61l1.11-6.14H2.4zm3.1 1.5c.41-.06.8.22.86.63l.38 2.25a.75.75 0 11-1.48.24l-.37-2.25c-.07-.4.2-.8.61-.86zm7 0c.4.08.68.47.61.87l-.37 2.25a.75.75 0 11-1.48-.24l.38-2.25a.75.75 0 01.86-.62zm-3.5 0c.41 0 .75.34.75.75v2.25a.75.75 0 01-1.5 0V7.5c0-.41.34-.75.75-.75z", fill: "#000", "fill-rule": "evenodd" } })]), e._v(" " + e._s(e.$t("selectablePlaceholder")) + " ")]) : e._e()]), e.validator.$invalid && e.validator.$dirty ? t("ErrorCallout", { staticStyle: { margin: "calc(1 * var(--rem)) 0 calc(1 * var(--rem)) 0" }, attrs: { message: e.$t("error.minOnePackage") } }) : e._e(), t("div", { staticClass: "flex w-full" }, [t("CButton", { staticStyle: { "border-color": "hsl(0, 0%, 82%)" }, attrs: { type: "secondary", outlined: "", "icon-left": "plus" }, on: { click: function(i) {
2387
+ return e.addPackage();
2388
+ } } }, [e._v(" " + e._s(e.$t("add")) + " ")])], 1)], 1) : e._e()] : t("div", [t("PackageGroupSelect", { on: { input: function(i) {
2389
+ return e.onSelectType(i);
2390
+ } } }), e.validator.$invalid && e.validator.$dirty ? t("ErrorCallout", { staticStyle: { "padding-bottom": "calc(1.5 * var(--rem))" }, attrs: { message: e.$t("error.selectType") } }) : e._e()], 1)], 2);
2391
+ }, Gt = [], Kt = /* @__PURE__ */ u(
2392
+ qt,
2393
+ Ut,
2394
+ Gt,
2395
+ !1,
2396
+ null,
2397
+ "319e086a"
2398
+ );
2399
+ const oi = Kt.exports;
2400
+ export {
2401
+ oi as default
2402
+ };