@webx-ui/module-delivery 0.0.0-stage → 0.1.1

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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -2
  3. package/dist/BindingsPage-DiVZys4B.js +280 -0
  4. package/dist/BindingsPage-DiVZys4B.js.map +1 -0
  5. package/dist/BindingsPage.d.ts +2 -0
  6. package/dist/CarrierDialog.d.ts +26 -0
  7. package/dist/CarriersPage-DlaIE-2K.js +650 -0
  8. package/dist/CarriersPage-DlaIE-2K.js.map +1 -0
  9. package/dist/CarriersPage.d.ts +2 -0
  10. package/dist/GeographyPage-T3vwSyud.js +750 -0
  11. package/dist/GeographyPage-T3vwSyud.js.map +1 -0
  12. package/dist/GeographyPage.d.ts +2 -0
  13. package/dist/LocalityDialog.d.ts +39 -0
  14. package/dist/LocalitySearch.d.ts +33 -0
  15. package/dist/MethodPane.d.ts +29 -0
  16. package/dist/MethodsPage-DrrRpjVY.js +415 -0
  17. package/dist/MethodsPage-DrrRpjVY.js.map +1 -0
  18. package/dist/MethodsPage.d.ts +2 -0
  19. package/dist/OrderChangeDialog.d.ts +7 -0
  20. package/dist/OrderDeliveryNode.d.ts +2 -0
  21. package/dist/PointDialog.d.ts +22 -0
  22. package/dist/PointsPage-C16GT-YH.js +336 -0
  23. package/dist/PointsPage-C16GT-YH.js.map +1 -0
  24. package/dist/PointsPage.d.ts +2 -0
  25. package/dist/PopularPage-BdE59dwB.js +141 -0
  26. package/dist/PopularPage-BdE59dwB.js.map +1 -0
  27. package/dist/PopularPage.d.ts +2 -0
  28. package/dist/RegionDialog.d.ts +11 -0
  29. package/dist/WaybillDialog.d.ts +8 -0
  30. package/dist/api.d.ts +151 -0
  31. package/dist/fields/CountryField.d.ts +14 -0
  32. package/dist/fields/LocalitiesField.d.ts +14 -0
  33. package/dist/fields/LocalityField.d.ts +16 -0
  34. package/dist/fields/PointKindField.d.ts +20 -0
  35. package/dist/fields/RegionField.d.ts +19 -0
  36. package/dist/fields/ScheduleField.d.ts +24 -0
  37. package/dist/i18n.d.ts +5 -0
  38. package/dist/index-CuhwaAcG.js +2540 -0
  39. package/dist/index-CuhwaAcG.js.map +1 -0
  40. package/dist/index.d.ts +6 -0
  41. package/dist/index.js +9 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/messages.d.ts +7 -0
  44. package/dist/module.d.ts +19 -0
  45. package/dist/style.css +1 -0
  46. package/dist/types.d.ts +467 -0
  47. package/package.json +64 -3
@@ -0,0 +1,2540 @@
1
+ import { defineComponent as Z, useModel as se, ref as m, onMounted as Je, computed as M, openBlock as i, createBlock as x, unref as e, mergeModels as ie, watch as X, withCtx as d, createElementVNode as g, createElementBlock as V, Fragment as K, createCommentVNode as D, toDisplayString as s, renderList as le, createVNode as y, createTextVNode as P, withKeys as Ye, nextTick as Qe, isRef as Ae, createSlots as Ne } from "vue";
2
+ import { WxSelect as pe, WxDialog as _e, WxSkeleton as xe, WxAlert as de, WxBadge as ce, WxButton as j, WxSpace as ue, toast as J, confirm as Xe, WxAutocomplete as ge, WxIcon as Ze, WxLink as et, WxText as ae, WxFormItem as E, WxInput as Y, WxDatePicker as tt, WxAction as at, useModal as Oe, WxRadioGroup as lt, WxInputNumber as we, WxSwitch as ot, createModal as De, WxCard as ke, WxEmpty as nt, WxTooltip as rt, WxPopconfirm as it } from "@webx-ui/core";
3
+ import { useAdmin as ee, useTranslate as st, useErrorText as ye, useDefaultLocale as Ue, WxScreen as dt, useHistorySubject as ct, WxDate as ut } from "@webx-ui/module-admin";
4
+ function Q(_) {
5
+ const a = new URLSearchParams();
6
+ for (const [l, r] of Object.entries(_))
7
+ r == null || r === "" || r === !1 || a.set(l, String(r === !0 ? 1 : r));
8
+ return a.size > 0 ? `?${a}` : "";
9
+ }
10
+ function oe(_) {
11
+ const a = `${_.apiPath}/delivery`, l = _.http, r = (t) => t.data;
12
+ return {
13
+ methods: () => l.get(`${a}/methods`).then(r),
14
+ method: (t) => l.get(`${a}/methods/${t}`).then(r),
15
+ blank: (t) => l.get(`${a}/methods/blank${Q({ type: t })}`).then(r),
16
+ createMethod: (t, o) => l.post(`${a}/methods`, { type: t, values: o }).then(r),
17
+ saveMethod: (t, o) => l.put(`${a}/methods/${t}`, { values: o }).then(r),
18
+ removeMethod: (t) => l.delete(`${a}/methods/${t}`).then(() => {
19
+ }),
20
+ orderMethods: (t) => l.put(`${a}/methods/order`, { ids: t }).then(() => {
21
+ }),
22
+ defineKind: (t, o) => l.post(`${a}/methods/point-kinds`, { kind: t, names: o }).then(r),
23
+ points: (t) => l.get(`${a}/points${Q(t)}`),
24
+ point: (t) => l.get(`${a}/points/${t}`).then(r),
25
+ createPoint: (t) => l.post(`${a}/points`, { values: t }).then(r),
26
+ savePoint: (t, o) => l.put(`${a}/points/${t}`, { values: o }).then(r),
27
+ removePoint: (t) => l.delete(`${a}/points/${t}`).then(() => {
28
+ }),
29
+ carriers: () => l.get(`${a}/carriers`).then(r),
30
+ carrier: (t) => l.get(`${a}/carriers/${t}`).then(r),
31
+ saveCarrier: (t, o) => l.put(`${a}/carriers/${t}`, o).then(r),
32
+ /**
33
+ * The options of a settings field from the carrier's account (§5.2 of a satellite's spec): the
34
+ * values of what it depends on, what was typed, and `fresh` past the cache. No key travels.
35
+ */
36
+ carrierOptions: (t, o, n = {}) => {
37
+ const f = {};
38
+ for (const [C, v] of Object.entries(n.values ?? {}))
39
+ v != null && v !== "" && (f[`values[${C}]`] = String(v));
40
+ return l.get(
41
+ `${a}/carriers/${t}/options/${o}${Q({
42
+ ...f,
43
+ q: n.q || void 0,
44
+ fresh: n.fresh ? 1 : void 0
45
+ })}`
46
+ ).then(r);
47
+ },
48
+ testCarrier: (t, o) => l.post(`${a}/carriers/${t}/test`, { credentials: o }).then(r),
49
+ runSync: (t, o) => l.post(`${a}/carriers/${t}/sync/${o}`, {}).then(r),
50
+ confirmRemoval: (t, o) => l.post(`${a}/carriers/${t}/confirm/${o}`, {}).then(r),
51
+ countries: () => l.get(`${a}/geography/countries`).then(r),
52
+ enableCountry: (t) => l.post(`${a}/geography/countries`, { code: t }).then(() => {
53
+ }),
54
+ disableCountry: (t) => l.delete(`${a}/geography/countries/${t}`).then(() => {
55
+ }),
56
+ /** Gone when nothing is in it, switched off otherwise — the answer says which. */
57
+ removeCountry: (t) => l.post(
58
+ `${a}/geography/countries/${t}/remove`,
59
+ {}
60
+ ).then(r).then((o) => o.removal),
61
+ orderCountries: (t) => l.put(`${a}/geography/countries/order`, { codes: t }).then(() => {
62
+ }),
63
+ lead: (t, o) => l.put(`${a}/geography/countries/${t}/leader`, { carrier: o }).then(() => {
64
+ }),
65
+ regions: (t) => l.get(`${a}/geography/regions${Q({ country: t })}`).then(r),
66
+ createRegion: (t, o, n) => l.post(`${a}/geography/regions`, { country: t, names: o, code: n }).then(r),
67
+ saveRegion: (t, o) => l.put(`${a}/geography/regions/${t}`, o).then(() => {
68
+ }),
69
+ /** The country's regions in the order dragged to: the selects and the list read them so. */
70
+ orderRegions: (t, o) => l.put(`${a}/geography/regions/order`, { country: t, ids: o }).then(() => {
71
+ }),
72
+ removeRegion: (t) => l.delete(`${a}/geography/regions/${t}`).then(() => {
73
+ }),
74
+ localities: (t) => l.get(`${a}/geography/localities${Q(t)}`),
75
+ suggest: (t, o) => l.get(`${a}/geography/localities/suggest${Q({ q: t, country: o })}`).then(r),
76
+ brief: (t) => {
77
+ const o = new URLSearchParams();
78
+ for (const n of t) o.append("ids[]", String(n));
79
+ return l.get(`${a}/geography/localities/brief?${o}`).then(r);
80
+ },
81
+ locality: (t) => l.get(`${a}/geography/localities/${t}`).then(r),
82
+ createLocality: (t, o = !1) => l.post(`${a}/geography/localities`, { values: t, force: o }).then(r),
83
+ saveLocality: (t, o, n = !1) => l.put(`${a}/geography/localities/${t}`, { values: o, force: n }).then(r),
84
+ removeLocality: (t) => l.delete(`${a}/geography/localities/${t}`).then(r),
85
+ activateLocality: (t) => l.post(`${a}/geography/localities/${t}/activate`, {}).then(() => {
86
+ }),
87
+ deactivateLocality: (t) => l.post(`${a}/geography/localities/${t}/deactivate`, {}).then(() => {
88
+ }),
89
+ popular: () => l.get(`${a}/popular`).then(r),
90
+ setPopular: (t) => l.put(`${a}/popular`, { ids: t }).then(r),
91
+ addPopular: (t) => l.post(`${a}/popular`, { locality_id: t }).then(r),
92
+ removePopular: (t) => l.delete(`${a}/popular/${t}`).then(r),
93
+ bindings: (t) => l.get(`${a}/bindings${Q(t)}`),
94
+ batch: (t) => l.post(`${a}/bindings/batch`, t).then(r),
95
+ /** The tab «Delivery» of an order's card (§14.2). */
96
+ orderDelivery: (t) => l.get(`${a}/orders/${t}`).then(r),
97
+ createWaybill: (t, o) => l.post(`${a}/orders/${t}/waybill`, o).then(r),
98
+ previewWaybill: (t, o) => l.post(`${a}/orders/${t}/waybill`, {
99
+ ...o,
100
+ dry_run: !0
101
+ }).then((n) => n.data.request),
102
+ /** «Change delivery» (decision of 02.11.2026): the checkout's search, for the order's lines. */
103
+ changeTowns: (t, o) => l.get(`${a}/orders/${t}/change/localities${Q({ q: o })}`).then(r),
104
+ changeMethods: (t, o) => l.get(`${a}/orders/${t}/change/methods${Q({ locality: o })}`).then(r),
105
+ changePoints: (t, o, n, f, C = 1) => l.get(`${a}/orders/${t}/change/points${Q({ locality: o, method: n, q: f, page: C })}`).then(r),
106
+ changeStreets: (t, o, n, f) => l.get(`${a}/orders/${t}/change/streets${Q({ locality: o, method: n, q: f })}`).then(r),
107
+ changeDelivery: (t, o) => l.post(`${a}/orders/${t}/change`, o).then(r),
108
+ trackOrder: (t) => l.post(`${a}/orders/${t}/track`, {}).then(r),
109
+ cancelShipment: (t) => l.post(`${a}/shipments/${t}/cancel`, {}).then(r),
110
+ shipmentLabel: (t) => l.get(`${a}/shipments/${t}/label`).then(r)
111
+ };
112
+ }
113
+ function ht(_) {
114
+ return _?.body ?? null;
115
+ }
116
+ function vt(_) {
117
+ const a = _?.status;
118
+ return typeof a == "number" ? a : null;
119
+ }
120
+ const pt = /* @__PURE__ */ Z({
121
+ name: "WxDeliveryCountryField",
122
+ __name: "CountryField",
123
+ props: /* @__PURE__ */ ie({
124
+ disabled: { type: Boolean, default: !1 }
125
+ }, {
126
+ modelValue: { default: null },
127
+ modelModifiers: {}
128
+ }),
129
+ emits: ["update:modelValue"],
130
+ setup(_) {
131
+ const a = _, l = se(_, "modelValue"), r = oe(ee()), t = m([]);
132
+ Je(async () => {
133
+ try {
134
+ t.value = (await r.countries()).countries;
135
+ } catch {
136
+ t.value = [];
137
+ }
138
+ const n = t.value.filter((f) => f.active);
139
+ l.value === null && n.length === 1 && (l.value = n[0].code);
140
+ });
141
+ const o = M(
142
+ () => t.value.map((n) => ({ value: n.code, label: `${n.name} (${n.code})` }))
143
+ );
144
+ return (n, f) => (i(), x(e(pe), {
145
+ modelValue: l.value,
146
+ "onUpdate:modelValue": f[0] || (f[0] = (C) => l.value = C),
147
+ options: o.value,
148
+ filterable: "",
149
+ disabled: a.disabled
150
+ }, null, 8, ["modelValue", "options", "disabled"]));
151
+ }
152
+ }), yt = {
153
+ panel: {
154
+ sections: {
155
+ group: "Delivery",
156
+ methods: "Methods",
157
+ points: "Own points",
158
+ carriers: "Carriers",
159
+ geography: "Geography",
160
+ popular: "Popular towns",
161
+ bindings: "Binding queue"
162
+ },
163
+ common: {
164
+ save: "Save",
165
+ saved: "Saved.",
166
+ "save-failed": "Not saved: check the fields.",
167
+ cancel: "Cancel",
168
+ delete: "Delete",
169
+ add: "Add",
170
+ create: "Create",
171
+ search: "Search",
172
+ close: "Close",
173
+ untitled: "Untitled",
174
+ active: "Active",
175
+ inactive: "Off",
176
+ "any-state": "Any state",
177
+ "order-failed": "The order was not saved.",
178
+ "empty-search": "Nothing matches the search.",
179
+ drag: "Drag a row by its handle to change the order.",
180
+ edit: "Edit",
181
+ change: "Change"
182
+ },
183
+ types: {
184
+ "store-pickup": "Pick-up at the shop's points",
185
+ "store-courier": "The shop's courier",
186
+ kinds: {
187
+ branch: ":carrier branch",
188
+ locker: ":carrier locker",
189
+ courier: ":carrier courier",
190
+ door: ":carrier courier"
191
+ },
192
+ asks: {
193
+ point: "Pick-up with :carrier",
194
+ address: "Delivery by :carrier",
195
+ nothing: ":carrier"
196
+ },
197
+ help: {
198
+ "store-pickup": "The buyer collects the order at one of your own points: a store or a pick-up point.",
199
+ "store-courier": "Your own courier brings the order to the buyer's address, in the localities you choose.",
200
+ point: "The buyer chooses one of the carrier's branches or lockers.",
201
+ address: "The carrier brings the order to the buyer's address.",
202
+ nothing: "The buyer is asked for nothing but the locality."
203
+ }
204
+ },
205
+ method: {
206
+ card: "Method",
207
+ titles: "Name",
208
+ descriptions: "Description",
209
+ "descriptions-help": "One line under the name in the checkout: terms, how long it takes.",
210
+ price: "Price",
211
+ "price-help": "Empty or 0 — free.",
212
+ "point-kind": "Kind of points",
213
+ "point-kind-help": "Which of your points this method offers: the checkout lists only the points of this kind.",
214
+ localities: "Localities",
215
+ "localities-help": "Where the courier goes. Empty — nowhere: the method is not offered.",
216
+ countries: "Countries",
217
+ "countries-help": "None ticked — every country of the site.",
218
+ "paid-by-store": "Understands «the shop pays for delivery»",
219
+ "paid-by-store-help": "A discount rule that grants free delivery makes this method free.",
220
+ enabled: "On",
221
+ "enabled-help": "Off — the checkout does not offer it.",
222
+ new: "Add a method",
223
+ "choose-type": "What kind of method?",
224
+ empty: "No delivery methods yet.",
225
+ "empty-help": "Add the shop's pick-up or courier, or a carrier's method.",
226
+ off: "Off",
227
+ free: "Free",
228
+ "all-countries": "All countries",
229
+ "missing-type": "Its type is not installed",
230
+ "delete-title": "Delete «:name»?",
231
+ "delete-text": "The checkout stops offering it at once. Orders keep what was chosen.",
232
+ deleted: "The method is deleted.",
233
+ choose: "Choose a method",
234
+ "choose-help": "Or add one: the shop's own, or a carrier's.",
235
+ "new-kind": "New kind of points",
236
+ "kind-key": "Code",
237
+ "kind-key-help": "Latin letters, digits and dashes: parcel-shop.",
238
+ "kind-name": "Name",
239
+ "kind-created": "The kind is added.",
240
+ "point-kind-carrier-help": "The carrier's points this method offers: its branches or its lockers.",
241
+ "new-kind-help": "A kind groups your own points, like «Store» or «Pick-up point». Name a new one — say «Parcel shop» — to offer those points under a method of their own."
242
+ },
243
+ point: {
244
+ kind: "Kind",
245
+ "kind-help": "A method of this kind offers the point.",
246
+ titles: "Name",
247
+ locality: "Locality",
248
+ address: "Address",
249
+ lat: "Latitude",
250
+ lng: "Longitude",
251
+ phone: "Phone",
252
+ active: "Active",
253
+ "active-help": "Off — the checkout does not show it.",
254
+ schedule: "Opening hours",
255
+ "schedule-help": "Hours as 09:00–18:00; several intervals separated by commas.",
256
+ new: "Add a point",
257
+ empty: "No points of the shop yet.",
258
+ "empty-help": "A store or a pick-up point: a pick-up method offers it in its locality.",
259
+ "any-kind": "Any kind",
260
+ "delete-title": "Delete «:name»?",
261
+ "delete-text": "A buyer who chose it chooses again. Orders keep what was chosen.",
262
+ deleted: "The point is deleted.",
263
+ title: "Point",
264
+ today: "Today",
265
+ intro: "Places where buyers collect orders themselves: your stores and pick-up points. The checkout offers them under the pick-up methods of the same kind. Carriers' branches come from the carriers and are not kept here."
266
+ },
267
+ schedule: {
268
+ days: {
269
+ mon: "Monday",
270
+ tue: "Tuesday",
271
+ wed: "Wednesday",
272
+ thu: "Thursday",
273
+ fri: "Friday",
274
+ sat: "Saturday",
275
+ sun: "Sunday"
276
+ },
277
+ "not-said": "Not said",
278
+ closed: "Closed",
279
+ hours: "Open",
280
+ around: "Around the clock",
281
+ exceptions: "Exceptions",
282
+ "add-exception": "Add a date",
283
+ date: "Date",
284
+ remove: "Remove",
285
+ invalid: "Write the hours as 09:00–18:00."
286
+ },
287
+ locality: {
288
+ names: "Name",
289
+ "names-help": "In the languages of the site; the main one is required.",
290
+ kind: "Type",
291
+ country: "Country",
292
+ region: "Region",
293
+ "region-help": "Not in the list? Add the region in Geography → Regions.",
294
+ "no-region": "No region",
295
+ lat: "Latitude",
296
+ lng: "Longitude",
297
+ weight: "Weight",
298
+ "weight-help": "Heavier places come first in the suggestions. Empty — by type and points.",
299
+ active: "Active",
300
+ "active-help": "Off — not suggested to buyers.",
301
+ new: "Add a locality",
302
+ title: "Locality",
303
+ duplicate: "A locality like this already exists.",
304
+ "duplicate-help": "Pick the existing one, or create a new one anyway.",
305
+ pick: "Pick it",
306
+ "create-anyway": "Create anyway",
307
+ "delete-title": "Delete «:name»?",
308
+ "delete-text": "Nothing refers to it: it is deleted for good.",
309
+ "held-text": "Referred to by: :what. It will be switched off instead and leave the suggestions.",
310
+ deleted: "The locality is deleted.",
311
+ deactivated: "The locality is in use, so it is switched off.",
312
+ activate: "Switch on",
313
+ activated: "The locality is on.",
314
+ deactivate: "Switch off",
315
+ "switched-off": "The locality is off.",
316
+ "manual-fields": "Changed by hand, kept by the sync: :fields.",
317
+ source: "Source",
318
+ sources: {
319
+ manual: "By hand",
320
+ import: "Import",
321
+ carrier: "Carrier"
322
+ },
323
+ "nothing-found": "Nothing found.",
324
+ "add-named": "Add «:name»",
325
+ inactive: "Off",
326
+ bindings: "Carriers",
327
+ empty: "No localities yet.",
328
+ "empty-help": "Add them by hand, import a file or connect a carrier.",
329
+ "found-in": "Found in :countries — choose the country in the filters.",
330
+ "found-off": "Found in switched-off countries: :countries. Switch the country on in Countries to list them here.",
331
+ "any-country": "Any country",
332
+ search: "Search by name",
333
+ "any-region": "Any region",
334
+ "any-source": "Any source",
335
+ saved: "The locality is saved.",
336
+ created: "The locality is added."
337
+ },
338
+ country: {
339
+ title: "Countries",
340
+ add: "Switch on a country",
341
+ choose: "Choose a country",
342
+ regions: "Regions",
343
+ localities: "Localities",
344
+ on: "On",
345
+ off: "Off",
346
+ enable: "Switch on",
347
+ disable: "Switch off",
348
+ disabled: "The country is off: its localities stay where they are used.",
349
+ leader: "Leading carrier",
350
+ "leader-none": "The first to sync",
351
+ "leader-fixed": "Set in the site's config.",
352
+ empty: "No countries yet.",
353
+ "empty-help": "Switch on the countries the shop delivers to.",
354
+ "localities-tab": "Localities",
355
+ "leader-help": "The leading carrier creates the country's shared localities; the other carriers bind their records to them. «The first to sync» — whichever carrier syncs the country first becomes its leader.",
356
+ remove: "Remove",
357
+ "remove-title": "Remove «:name»?",
358
+ "remove-text": "The country has no regions or localities: it is deleted.",
359
+ "remove-held": "The country has regions or localities, and points and orders may refer to them. It will be switched off instead: the checkout stops offering it, the records stay.",
360
+ removed: "The country is removed.",
361
+ deactivated: "The country is in use, so it is switched off."
362
+ },
363
+ region: {
364
+ title: "Regions",
365
+ add: "Add a region",
366
+ name: "Name",
367
+ code: "Code",
368
+ "code-help": "ISO 3166-2 without the country, if there is one.",
369
+ "delete-title": "Delete «:name»?",
370
+ "delete-text": "Only an empty region can be deleted.",
371
+ deleted: "The region is deleted.",
372
+ saved: "The region is saved.",
373
+ empty: "The country has no regions.",
374
+ "country-first": "Choose a country first.",
375
+ edit: "Edit",
376
+ "new-title": "New region",
377
+ "edit-title": "Region",
378
+ "delete-held": "The region has localities: move them to another region or delete them first."
379
+ },
380
+ options: {
381
+ "no-options": "Carrier :carrier has no options from its account.",
382
+ "no-field": "The carrier has no field :field with options from its account.",
383
+ "no-key": "Set the API key and check the connection first.",
384
+ "choose-first": "Choose first: :field",
385
+ unavailable: "Could not get the list from the carrier's account: :reason",
386
+ "choose-from-list": "Choose from the list.",
387
+ missing: ":label — not in the carrier's account",
388
+ "missing-list": "Not in the carrier's account any more: :list",
389
+ refresh: "Refresh lists",
390
+ retry: "Try again",
391
+ search: "Type to search"
392
+ },
393
+ carrier: {
394
+ empty: "No carriers are installed.",
395
+ "empty-help": "A carrier is a Composer package of its own; the shop's pick-up and courier need none.",
396
+ enabled: "On",
397
+ settings: "Settings",
398
+ credentials: "Keys",
399
+ key: "Access key",
400
+ set: "Set",
401
+ "not-set": "Not set",
402
+ replace: "Type a new one to replace",
403
+ clear: "Clear",
404
+ test: "Check the connection",
405
+ "test-ok": "Connected.",
406
+ "test-failed": "Not connected: :message",
407
+ run: "Run",
408
+ running: "Going on",
409
+ queued: "Queued: :list.",
410
+ confirm: "Confirm removal",
411
+ confirmed: "Removed.",
412
+ held: "Held: :count to remove",
413
+ stale: "Stale",
414
+ "last-success": "Last success",
415
+ never: "Never",
416
+ records: "Records",
417
+ queue: "Waiting for a binding",
418
+ remarks: {
419
+ no_streets: "Localities with a courier and no streets: :count",
420
+ "skipped-unknown_locality": "Skipped, of unknown localities: :count",
421
+ "skipped-other": "Skipped, for another reason: :count"
422
+ },
423
+ directories: {
424
+ localities: "Localities",
425
+ points: "Points",
426
+ streets: "Streets"
427
+ },
428
+ runs: "Runs",
429
+ statuses: {
430
+ running: "Going on",
431
+ succeeded: "Done",
432
+ failed: "Failed",
433
+ held: "Held"
434
+ },
435
+ manual: "By hand only",
436
+ schedule: "Schedule",
437
+ seen: "Seen",
438
+ saved: "The carrier is saved.",
439
+ choose: "Choose a carrier"
440
+ },
441
+ popular: {
442
+ add: "Add a town",
443
+ "add-help": "Search the localities of the site.",
444
+ empty: "No popular towns.",
445
+ "empty-help": "The checkout dialog then shows only the search.",
446
+ remove: "Remove",
447
+ hidden: "Not shown: the locality is off",
448
+ added: "Added.",
449
+ removed: "Removed.",
450
+ already: "Already in the list.",
451
+ "remove-title": "Remove «:name» from the popular towns?"
452
+ },
453
+ binding: {
454
+ empty: "The queue is empty.",
455
+ "empty-help": "Every record the carriers sent is bound to a locality. New ones appear here after a carrier's sync, when it cannot match them itself.",
456
+ carrier: "Carrier",
457
+ reason: "Reason",
458
+ reasons: {
459
+ region_unknown: "Unknown region",
460
+ ambiguous: "Several namesakes",
461
+ kind_mismatch: "Another type",
462
+ not_found: "Not found"
463
+ },
464
+ record: "Record",
465
+ candidates: "Candidates",
466
+ bind: "Bind",
467
+ create: "Make a shared locality",
468
+ ignore: "Do not bind",
469
+ "bind-to": "Bind to…",
470
+ selected: "Chosen: :count",
471
+ "whole-filter": "Apply to the whole filter (:count)",
472
+ done: "Done: :count.",
473
+ failed: "Not done: :count.",
474
+ left: "Left: :count — run again for the next ones.",
475
+ km: ":distance km",
476
+ "any-carrier": "Any carrier",
477
+ "any-reason": "Any reason",
478
+ intro: "Records a carrier sent that it could not match to the shared geography itself. «Bind» attaches a record to an existing locality, «Make a shared locality» creates a new one from it, «Do not bind» sets it aside — the carrier's points there are not offered. The queue fills only while a carrier is connected and syncs its localities."
479
+ },
480
+ order: {
481
+ tab: "Delivery",
482
+ chosen: "What the buyer chose",
483
+ method: "Method",
484
+ locality: "Town",
485
+ point: "Pick-up point",
486
+ address: "Address",
487
+ note: "Note for the courier",
488
+ cost: "Delivery cost",
489
+ payer: "Pays the carrier",
490
+ "payer-sender": "The shop (sender)",
491
+ "payer-recipient": "The buyer (recipient)",
492
+ "paid-by-store": "The shop pays for the delivery",
493
+ none: "No delivery",
494
+ "none-help": "The order was placed without delivery, or before the delivery module was installed.",
495
+ own: "The shop delivers this method itself: there is no waybill.",
496
+ failed: "The delivery of the order did not load.",
497
+ create: "Create waybill",
498
+ "create-title": "New waybill",
499
+ "create-help": "The carrier gets this request. Check the recipient, the value and the cash on delivery.",
500
+ "create-help-no-cod": "The carrier gets this request. Check the recipient and the value.",
501
+ "recipient-name": "Recipient",
502
+ "recipient-phone": "Recipient's phone",
503
+ "recipient-first-name": "First name",
504
+ "recipient-last-name": "Last name",
505
+ "carrier-fields": "For the carrier",
506
+ declared: "Declared value",
507
+ cod: "Cash on delivery",
508
+ "cod-help": "Empty — nothing to collect on receipt.",
509
+ lines: "In the parcel",
510
+ created: "Waybill :number is made.",
511
+ parcels: "Parcels",
512
+ "no-parcels": "No waybill yet.",
513
+ number: "Waybill",
514
+ status: "Status",
515
+ "carrier-cost": "Carrier's price",
516
+ track: "Refresh tracking",
517
+ tracked: "Tracking is refreshed.",
518
+ label: "Label",
519
+ cancel: "Cancel waybill",
520
+ "cancel-confirm": "Cancel waybill :number at the carrier?",
521
+ cancelled: "The waybill is cancelled.",
522
+ history: "Statuses",
523
+ "next-check": "Next check :time",
524
+ final: "Tracking is over",
525
+ "made-already": "Cancel the waybill to make another one.",
526
+ change: "Change delivery",
527
+ "change-title": "Change the delivery",
528
+ "change-help": "Checked as at the checkout. The buyer is not told: let them know yourself.",
529
+ "change-town-search": "Search a town",
530
+ "change-no-methods": "No method delivers to this town.",
531
+ "change-no-points": "No point found.",
532
+ "change-point-search": "Number or address of the point",
533
+ "change-street": "Street",
534
+ "change-street-help": "Only a street of the carrier's list.",
535
+ "change-house": "House",
536
+ "change-apartment": "Apartment",
537
+ "change-reason": "Why",
538
+ "change-reason-help": "For the managers; the buyer does not see it.",
539
+ "change-from-to": ":from → :to",
540
+ "change-total": "Order total",
541
+ "change-same": "The total stays :amount.",
542
+ "change-due": "The buyer will owe :amount more.",
543
+ "change-over": "The shop will owe the buyer :amount back.",
544
+ "change-check": "Check",
545
+ "change-save": "Save delivery",
546
+ changed: "The delivery is changed.",
547
+ "change-refused-waybill": "Cancel the waybill first: the carrier has the old delivery.",
548
+ "change-refused-state": "A received, cancelled or refunded order is not changed.",
549
+ "change-refused-no_delivery": "The order has nothing to deliver.",
550
+ "change-refused-nothing": "This is the delivery the order has already."
551
+ },
552
+ errors: {
553
+ unknown_carrier: "There is no such carrier.",
554
+ leader_configured: "The leading carrier of this country is set in the site's config.",
555
+ unknown_type: "There is no such method type.",
556
+ order: "The order must name every method once.",
557
+ locality_required: "Choose the locality.",
558
+ address_required: "Write the address.",
559
+ locality_inactive: "This locality is off. Switch it on in Geography, or choose another.",
560
+ title_required: "Write the name.",
561
+ schedule: "Write the hours as 09:00–18:00, the start before the end.",
562
+ carrier_off: "The carrier is off: switch it on before running the sync.",
563
+ not_held: "Nothing is held: there is no removal to confirm.",
564
+ nothing_chosen: "Tick the rows first."
565
+ }
566
+ }
567
+ }, We = /* @__PURE__ */ new WeakSet();
568
+ function mt() {
569
+ try {
570
+ const { i18n: _ } = ee();
571
+ We.has(_) || (_.defaults("webx-delivery", yt), We.add(_));
572
+ } catch {
573
+ }
574
+ }
575
+ function ne() {
576
+ mt();
577
+ const _ = st("webx-delivery");
578
+ return (a, l) => _(`panel.${a}`, l);
579
+ }
580
+ const ft = { class: "wx-delivery-locality" }, gt = { class: "wx-delivery-locality__help" }, _t = { class: "wx-delivery-locality__similar" }, bt = { class: "wx-delivery-locality__label" }, wt = /* @__PURE__ */ Z({
581
+ __name: "LocalityDialog",
582
+ props: /* @__PURE__ */ ie({
583
+ id: { default: null },
584
+ country: { default: null },
585
+ name: { default: "" },
586
+ short: { type: Boolean, default: !1 }
587
+ }, {
588
+ open: { type: Boolean, default: !1 },
589
+ openModifiers: {}
590
+ }),
591
+ emits: /* @__PURE__ */ ie(["saved", "removed"], ["update:open"]),
592
+ setup(_, { emit: a }) {
593
+ const l = _, r = se(_, "open"), t = a, o = oe(ee()), n = ne(), f = ye(), C = Ue(), v = m({}), S = m(null), O = m({}), T = m([]), F = m(!1), B = m(!1), W = M(
594
+ () => l.id === null ? n("locality.new") : S.value?.locality.label ?? n("locality.title")
595
+ ), q = M(
596
+ () => l.short ? [...l.country ? ["country"] : [], "coordinates", "weight", "active"].map((L) => ({
597
+ op: "remove",
598
+ target: L
599
+ })) : l.id === null ? [] : (
600
+ // A locality stays in the country its carriers bound it in.
601
+ [{ op: "set", target: "country", props: { disabled: !0 } }]
602
+ )
603
+ );
604
+ async function z() {
605
+ if (O.value = {}, T.value = [], S.value = null, l.id === null) {
606
+ v.value = {
607
+ names: l.name.trim() === "" ? {} : { [C.value]: l.name.trim() },
608
+ kind: "town",
609
+ country: l.country,
610
+ region_id: null,
611
+ lat: null,
612
+ lng: null,
613
+ weight: null,
614
+ active: !0
615
+ };
616
+ return;
617
+ }
618
+ F.value = !0;
619
+ try {
620
+ S.value = await o.locality(l.id), v.value = S.value.values;
621
+ } catch (L) {
622
+ J.danger(f(L)), r.value = !1;
623
+ } finally {
624
+ F.value = !1;
625
+ }
626
+ }
627
+ X(r, (L) => {
628
+ L && z();
629
+ });
630
+ async function u(L = !1) {
631
+ if (!B.value) {
632
+ B.value = !0, O.value = {};
633
+ try {
634
+ const I = l.id === null ? await o.createLocality(v.value, L) : await o.saveLocality(l.id, v.value, L);
635
+ T.value = [], J.success(n(l.id === null ? "locality.created" : "locality.saved")), t("saved", I.locality), r.value = !1;
636
+ } catch (I) {
637
+ if (vt(I) === 409) {
638
+ T.value = ht(I)?.similar ?? [];
639
+ return;
640
+ }
641
+ const w = I.errors;
642
+ w && Object.keys(w).length > 0 ? (O.value = w, J.danger(n("common.save-failed"))) : J.danger(f(I));
643
+ } finally {
644
+ B.value = !1;
645
+ }
646
+ }
647
+ }
648
+ function h(L) {
649
+ t("saved", L), r.value = !1;
650
+ }
651
+ async function p() {
652
+ const L = S.value?.locality;
653
+ if (!L) return;
654
+ const I = L.held_by.length > 0;
655
+ if (await Xe({
656
+ title: n("locality.delete-title", { name: L.name }),
657
+ message: I ? n("locality.held-text", { what: L.held_by.join(", ") }) : n("locality.delete-text"),
658
+ confirmText: n("common.delete"),
659
+ cancelText: n("common.cancel"),
660
+ tone: "danger"
661
+ }))
662
+ try {
663
+ const { removal: R } = await o.removeLocality(L.id);
664
+ J.success(n(R === "deleted" ? "locality.deleted" : "locality.deactivated")), t("removed", L.id), r.value = !1;
665
+ } catch (R) {
666
+ J.danger(f(R));
667
+ }
668
+ }
669
+ const b = M(() => S.value?.locality.manual_fields ?? []);
670
+ return (L, I) => (i(), x(e(_e), {
671
+ open: r.value,
672
+ "onUpdate:open": I[4] || (I[4] = (w) => r.value = w),
673
+ title: W.value,
674
+ width: 560
675
+ }, {
676
+ footer: d(() => [
677
+ y(e(ue), {
678
+ size: "sm",
679
+ class: "wx-delivery-locality__footer"
680
+ }, {
681
+ default: d(() => [
682
+ _.id !== null && S.value ? (i(), x(e(j), {
683
+ key: 0,
684
+ variant: "text",
685
+ type: "danger",
686
+ icon: "trash",
687
+ onClick: p
688
+ }, {
689
+ default: d(() => [
690
+ P(s(e(n)("common.delete")), 1)
691
+ ]),
692
+ _: 1
693
+ })) : D("", !0),
694
+ I[5] || (I[5] = g("span", { class: "wx-delivery-locality__gap" }, null, -1)),
695
+ y(e(j), {
696
+ variant: "outline",
697
+ onClick: I[1] || (I[1] = (w) => r.value = !1)
698
+ }, {
699
+ default: d(() => [
700
+ P(s(e(n)("common.cancel")), 1)
701
+ ]),
702
+ _: 1
703
+ }),
704
+ T.value.length > 0 ? (i(), x(e(j), {
705
+ key: 1,
706
+ variant: "outline",
707
+ loading: B.value,
708
+ "data-test": "force",
709
+ onClick: I[2] || (I[2] = (w) => u(!0))
710
+ }, {
711
+ default: d(() => [
712
+ P(s(e(n)("locality.create-anyway")), 1)
713
+ ]),
714
+ _: 1
715
+ }, 8, ["loading"])) : (i(), x(e(j), {
716
+ key: 2,
717
+ type: "primary",
718
+ loading: B.value,
719
+ disabled: F.value,
720
+ onClick: I[3] || (I[3] = (w) => u())
721
+ }, {
722
+ default: d(() => [
723
+ P(s(_.id === null ? e(n)("common.create") : e(n)("common.save")), 1)
724
+ ]),
725
+ _: 1
726
+ }, 8, ["loading", "disabled"]))
727
+ ]),
728
+ _: 1
729
+ })
730
+ ]),
731
+ default: d(() => [
732
+ g("div", ft, [
733
+ F.value ? (i(), x(e(xe), {
734
+ key: 0,
735
+ rows: 4
736
+ })) : (i(), V(K, { key: 1 }, [
737
+ b.value.length > 0 ? (i(), x(e(de), {
738
+ key: 0,
739
+ type: "info",
740
+ description: e(n)("locality.manual-fields", { fields: b.value.join(", ") })
741
+ }, null, 8, ["description"])) : D("", !0),
742
+ T.value.length > 0 ? (i(), x(e(de), {
743
+ key: 1,
744
+ type: "warning",
745
+ title: e(n)("locality.duplicate"),
746
+ "data-test": "duplicate"
747
+ }, {
748
+ default: d(() => [
749
+ g("p", gt, s(e(n)("locality.duplicate-help")), 1),
750
+ g("ul", _t, [
751
+ (i(!0), V(K, null, le(T.value, (w) => (i(), V("li", {
752
+ key: w.id
753
+ }, [
754
+ g("span", bt, s(w.label), 1),
755
+ y(e(ce), { size: "sm" }, {
756
+ default: d(() => [
757
+ P(s(e(n)(`locality.sources.${w.source}`)), 1)
758
+ ]),
759
+ _: 2
760
+ }, 1024),
761
+ w.active ? D("", !0) : (i(), x(e(ce), {
762
+ key: 0,
763
+ size: "sm",
764
+ type: "warning"
765
+ }, {
766
+ default: d(() => [
767
+ P(s(e(n)("locality.inactive")), 1)
768
+ ]),
769
+ _: 1
770
+ })),
771
+ y(e(j), {
772
+ size: "sm",
773
+ variant: "outline",
774
+ onClick: (R) => h(w)
775
+ }, {
776
+ default: d(() => [
777
+ P(s(e(n)("locality.pick")), 1)
778
+ ]),
779
+ _: 1
780
+ }, 8, ["onClick"])
781
+ ]))), 128))
782
+ ])
783
+ ]),
784
+ _: 1
785
+ }, 8, ["title"])) : D("", !0),
786
+ y(e(dt), {
787
+ modelValue: v.value,
788
+ "onUpdate:modelValue": I[0] || (I[0] = (w) => v.value = w),
789
+ name: "delivery.locality-form",
790
+ patch: q.value,
791
+ errors: O.value,
792
+ disabled: B.value
793
+ }, null, 8, ["modelValue", "patch", "errors", "disabled"])
794
+ ], 64))
795
+ ])
796
+ ]),
797
+ _: 1
798
+ }, 8, ["open", "title"]));
799
+ }
800
+ }), re = (_, a) => {
801
+ const l = _.__vccOpts || _;
802
+ for (const [r, t] of a)
803
+ l[r] = t;
804
+ return l;
805
+ }, kt = /* @__PURE__ */ re(wt, [["__scopeId", "data-v-169d3b1d"]]), xt = { class: "wx-delivery-locality-search" }, $t = {
806
+ key: 0,
807
+ class: "wx-delivery-locality-search__add",
808
+ "data-test": "add-locality"
809
+ }, Vt = { class: "wx-delivery-locality-search__add-label" }, Ct = { class: "wx-delivery-locality-search__name" }, Tt = {
810
+ key: 0,
811
+ class: "wx-delivery-locality-search__label"
812
+ }, St = /* @__PURE__ */ Z({
813
+ __name: "LocalitySearch",
814
+ props: {
815
+ country: { default: null },
816
+ creatable: { type: Boolean, default: !1 },
817
+ exclude: { default: () => [] },
818
+ placeholder: { default: void 0 },
819
+ disabled: { type: Boolean, default: !1 }
820
+ },
821
+ emits: ["pick"],
822
+ setup(_, { emit: a }) {
823
+ const l = _, r = a, t = oe(ee()), o = ne(), n = m(""), f = m([]), C = m(""), v = m(!1), S = m(!1), O = m(""), T = M(() => f.value.filter((h) => !l.exclude.includes(h.id))), F = M(
824
+ () => l.creatable && !v.value && C.value !== "" && C.value === n.value.trim() && T.value.length === 0
825
+ ), B = M(
826
+ () => F.value ? [
827
+ {
828
+ // The typed text as the value: picking the line leaves the field as it was.
829
+ value: n.value,
830
+ label: o("locality.add-named", { name: C.value }),
831
+ action: !0
832
+ }
833
+ ] : T.value.map((h) => ({ value: h.name, description: h.label, id: h.id }))
834
+ );
835
+ let W = 0;
836
+ async function q(h) {
837
+ const p = ++W, b = h.trim();
838
+ v.value = !0;
839
+ try {
840
+ const L = await t.suggest(b, l.country);
841
+ if (p !== W) return;
842
+ f.value = L, C.value = b;
843
+ } catch {
844
+ p === W && (f.value = []);
845
+ } finally {
846
+ p === W && (v.value = !1);
847
+ }
848
+ }
849
+ function z(h) {
850
+ if (h.action === !0) {
851
+ O.value = C.value, S.value = !0;
852
+ return;
853
+ }
854
+ const p = f.value.find((b) => b.id === h.id);
855
+ p && (r("pick", p), n.value = "");
856
+ }
857
+ function u(h) {
858
+ r("pick", h), n.value = "", C.value = "";
859
+ }
860
+ return (h, p) => (i(), V("div", xt, [
861
+ y(e(ge), {
862
+ modelValue: n.value,
863
+ "onUpdate:modelValue": p[0] || (p[0] = (b) => n.value = b),
864
+ options: B.value,
865
+ remote: "",
866
+ teleport: "",
867
+ "open-on-focus": "",
868
+ loading: v.value,
869
+ "empty-text": e(o)("locality.nothing-found"),
870
+ placeholder: _.placeholder ?? e(o)("locality.search"),
871
+ "aria-label": _.placeholder ?? e(o)("locality.search"),
872
+ disabled: _.disabled,
873
+ onSearch: q,
874
+ onSelect: z
875
+ }, {
876
+ option: d(({ option: b }) => [
877
+ b.action ? (i(), V("span", $t, [
878
+ y(e(Ze), { name: "plus" }),
879
+ g("span", Vt, s(b.label), 1)
880
+ ])) : (i(), V(K, { key: 1 }, [
881
+ g("span", Ct, s(b.value), 1),
882
+ b.description ? (i(), V("span", Tt, s(b.description), 1)) : D("", !0)
883
+ ], 64))
884
+ ]),
885
+ _: 1
886
+ }, 8, ["modelValue", "options", "loading", "empty-text", "placeholder", "aria-label", "disabled"]),
887
+ y(kt, {
888
+ open: S.value,
889
+ "onUpdate:open": p[1] || (p[1] = (b) => S.value = b),
890
+ country: _.country,
891
+ name: O.value,
892
+ short: "",
893
+ onSaved: u
894
+ }, null, 8, ["open", "country", "name"])
895
+ ]));
896
+ }
897
+ }), Le = /* @__PURE__ */ re(St, [["__scopeId", "data-v-165fdb46"]]), Nt = { class: "wx-delivery-localities-field" }, Dt = {
898
+ key: 0,
899
+ class: "wx-delivery-localities-field__tags"
900
+ }, Wt = /* @__PURE__ */ Z({
901
+ name: "WxDeliveryLocalitiesField",
902
+ __name: "LocalitiesField",
903
+ props: /* @__PURE__ */ ie({
904
+ disabled: { type: Boolean, default: !1 }
905
+ }, {
906
+ modelValue: { default: null },
907
+ modelModifiers: {}
908
+ }),
909
+ emits: ["update:modelValue"],
910
+ setup(_) {
911
+ const a = _, l = se(_, "modelValue"), r = oe(ee()), t = ne(), o = m(/* @__PURE__ */ new Map()), n = M(() => Array.isArray(l.value) ? l.value : []);
912
+ X(
913
+ n,
914
+ async (v) => {
915
+ const S = v.filter((O) => !o.value.has(O));
916
+ if (S.length !== 0)
917
+ try {
918
+ const O = await r.brief(S), T = new Map(o.value);
919
+ for (const F of O) T.set(F.id, F);
920
+ o.value = T;
921
+ } catch {
922
+ }
923
+ },
924
+ { immediate: !0 }
925
+ );
926
+ function f(v) {
927
+ o.value = new Map(o.value).set(v.id, v), n.value.includes(v.id) || (l.value = [...n.value, v.id]);
928
+ }
929
+ function C(v) {
930
+ l.value = n.value.filter((S) => S !== v);
931
+ }
932
+ return (v, S) => (i(), V("div", Nt, [
933
+ n.value.length > 0 ? (i(), V("div", Dt, [
934
+ (i(!0), V(K, null, le(n.value, (O) => (i(), x(e(ce), {
935
+ key: O,
936
+ closable: !a.disabled,
937
+ type: o.value.get(O)?.active === !1 ? "warning" : void 0,
938
+ onClose: (T) => C(O)
939
+ }, {
940
+ default: d(() => [
941
+ P(s(o.value.get(O)?.label ?? `#${O}`), 1)
942
+ ]),
943
+ _: 2
944
+ }, 1032, ["closable", "type", "onClose"]))), 128))
945
+ ])) : D("", !0),
946
+ a.disabled ? D("", !0) : (i(), x(Le, {
947
+ key: 1,
948
+ creatable: "",
949
+ exclude: n.value,
950
+ placeholder: e(t)("popular.add"),
951
+ onPick: f
952
+ }, null, 8, ["exclude", "placeholder"]))
953
+ ]));
954
+ }
955
+ }), At = /* @__PURE__ */ re(Wt, [["__scopeId", "data-v-14fcba6f"]]), Ot = {
956
+ key: 0,
957
+ class: "wx-delivery-locality-field__chosen"
958
+ }, Ut = { class: "wx-delivery-locality-field__label" }, Lt = {
959
+ key: 1,
960
+ class: "wx-delivery-locality-field__search"
961
+ }, Pt = /* @__PURE__ */ Z({
962
+ name: "WxDeliveryLocalityField",
963
+ __name: "LocalityField",
964
+ props: /* @__PURE__ */ ie({
965
+ disabled: { type: Boolean, default: !1 }
966
+ }, {
967
+ modelValue: { default: null },
968
+ modelModifiers: {}
969
+ }),
970
+ emits: ["update:modelValue"],
971
+ setup(_) {
972
+ const a = _, l = se(_, "modelValue"), r = oe(ee()), t = ne(), o = m(null), n = m(!1);
973
+ X(
974
+ l,
975
+ async (T) => {
976
+ if (T == null) {
977
+ o.value = null;
978
+ return;
979
+ }
980
+ if (o.value?.id !== T)
981
+ try {
982
+ o.value = (await r.brief([T]))[0] ?? null;
983
+ } catch {
984
+ o.value = null;
985
+ }
986
+ },
987
+ { immediate: !0 }
988
+ );
989
+ const f = m(null);
990
+ function C(T) {
991
+ o.value = T, l.value = T.id, n.value = !1;
992
+ }
993
+ async function v() {
994
+ n.value = !0, await Qe(), f.value?.querySelector("input")?.focus();
995
+ }
996
+ function S() {
997
+ n.value = !1;
998
+ }
999
+ function O(T) {
1000
+ !n.value || o.value === null || (T.stopPropagation(), S());
1001
+ }
1002
+ return (T, F) => (i(), V("div", {
1003
+ ref_key: "root",
1004
+ ref: f,
1005
+ class: "wx-delivery-locality-field",
1006
+ onKeydown: Ye(O, ["esc"])
1007
+ }, [
1008
+ o.value && !n.value ? (i(), V("div", Ot, [
1009
+ g("span", Ut, s(o.value.label), 1),
1010
+ o.value.active ? D("", !0) : (i(), x(e(ce), {
1011
+ key: 0,
1012
+ size: "sm",
1013
+ type: "warning"
1014
+ }, {
1015
+ default: d(() => [
1016
+ P(s(e(t)("locality.inactive")), 1)
1017
+ ]),
1018
+ _: 1
1019
+ })),
1020
+ a.disabled ? D("", !0) : (i(), x(e(j), {
1021
+ key: 1,
1022
+ size: "sm",
1023
+ variant: "text",
1024
+ icon: "edit",
1025
+ "data-test": "locality-change",
1026
+ onClick: v
1027
+ }, {
1028
+ default: d(() => [
1029
+ P(s(e(t)("common.change")), 1)
1030
+ ]),
1031
+ _: 1
1032
+ }))
1033
+ ])) : (i(), V("div", Lt, [
1034
+ y(Le, {
1035
+ creatable: "",
1036
+ disabled: a.disabled,
1037
+ onPick: C
1038
+ }, null, 8, ["disabled"]),
1039
+ o.value ? (i(), x(e(j), {
1040
+ key: 0,
1041
+ size: "sm",
1042
+ variant: "text",
1043
+ "data-test": "locality-cancel",
1044
+ onClick: S
1045
+ }, {
1046
+ default: d(() => [
1047
+ P(s(e(t)("common.cancel")), 1)
1048
+ ]),
1049
+ _: 1
1050
+ })) : D("", !0)
1051
+ ]))
1052
+ ], 544));
1053
+ }
1054
+ }), It = /* @__PURE__ */ re(Pt, [["__scopeId", "data-v-66cad5c9"]]), zt = { class: "wx-delivery-point-kind" }, Rt = { class: "wx-delivery-point-kind__form" }, Mt = /* @__PURE__ */ Z({
1055
+ name: "WxDeliveryPointKindField",
1056
+ __name: "PointKindField",
1057
+ props: /* @__PURE__ */ ie({
1058
+ options: { default: () => [] },
1059
+ creatable: { type: Boolean, default: !1 },
1060
+ disabled: { type: Boolean, default: !1 }
1061
+ }, {
1062
+ modelValue: { default: null },
1063
+ modelModifiers: {}
1064
+ }),
1065
+ emits: ["update:modelValue"],
1066
+ setup(_) {
1067
+ const a = _, l = se(_, "modelValue"), r = oe(ee()), t = ne(), o = ye(), n = Ue(), f = m(null), C = M(() => f.value ?? a.options), v = m(!1), S = m(""), O = m(""), T = m({}), F = m(!1);
1068
+ function B(q) {
1069
+ q?.preventDefault(), S.value = "", O.value = "", T.value = {}, v.value = !0;
1070
+ }
1071
+ async function W() {
1072
+ if (!F.value) {
1073
+ F.value = !0, T.value = {};
1074
+ try {
1075
+ f.value = await r.defineKind(S.value.trim(), { [n.value]: O.value.trim() }), l.value = S.value.trim(), J.success(t("method.kind-created")), v.value = !1;
1076
+ } catch (q) {
1077
+ T.value = q.errors ?? {}, Object.keys(T.value).length === 0 && J.danger(o(q));
1078
+ } finally {
1079
+ F.value = !1;
1080
+ }
1081
+ }
1082
+ }
1083
+ return (q, z) => (i(), V("div", zt, [
1084
+ y(e(pe), {
1085
+ modelValue: l.value,
1086
+ "onUpdate:modelValue": z[0] || (z[0] = (u) => l.value = u),
1087
+ options: C.value,
1088
+ disabled: a.disabled
1089
+ }, null, 8, ["modelValue", "options", "disabled"]),
1090
+ a.creatable && !a.disabled ? (i(), x(e(et), {
1091
+ key: 0,
1092
+ class: "wx-delivery-point-kind__new",
1093
+ href: "#",
1094
+ size: "sm",
1095
+ "data-test": "new-kind",
1096
+ onClick: B
1097
+ }, {
1098
+ default: d(() => [
1099
+ P(s(e(t)("method.new-kind")), 1)
1100
+ ]),
1101
+ _: 1
1102
+ })) : D("", !0),
1103
+ y(e(_e), {
1104
+ open: v.value,
1105
+ "onUpdate:open": z[4] || (z[4] = (u) => v.value = u),
1106
+ title: e(t)("method.new-kind"),
1107
+ width: 440
1108
+ }, {
1109
+ footer: d(() => [
1110
+ y(e(ue), { size: "sm" }, {
1111
+ default: d(() => [
1112
+ y(e(j), {
1113
+ variant: "outline",
1114
+ onClick: z[3] || (z[3] = (u) => v.value = !1)
1115
+ }, {
1116
+ default: d(() => [
1117
+ P(s(e(t)("common.cancel")), 1)
1118
+ ]),
1119
+ _: 1
1120
+ }),
1121
+ y(e(j), {
1122
+ type: "primary",
1123
+ loading: F.value,
1124
+ disabled: S.value.trim() === "" || O.value.trim() === "",
1125
+ onClick: W
1126
+ }, {
1127
+ default: d(() => [
1128
+ P(s(e(t)("common.add")), 1)
1129
+ ]),
1130
+ _: 1
1131
+ }, 8, ["loading", "disabled"])
1132
+ ]),
1133
+ _: 1
1134
+ })
1135
+ ]),
1136
+ default: d(() => [
1137
+ g("div", Rt, [
1138
+ y(e(ae), {
1139
+ tone: "muted",
1140
+ size: "sm"
1141
+ }, {
1142
+ default: d(() => [
1143
+ P(s(e(t)("method.new-kind-help")), 1)
1144
+ ]),
1145
+ _: 1
1146
+ }),
1147
+ y(e(E), {
1148
+ label: e(t)("method.kind-name"),
1149
+ error: T.value.names?.[0]
1150
+ }, {
1151
+ default: d(() => [
1152
+ y(e(Y), {
1153
+ modelValue: O.value,
1154
+ "onUpdate:modelValue": z[1] || (z[1] = (u) => O.value = u),
1155
+ maxlength: 60,
1156
+ autofocus: ""
1157
+ }, null, 8, ["modelValue"])
1158
+ ]),
1159
+ _: 1
1160
+ }, 8, ["label", "error"]),
1161
+ y(e(E), {
1162
+ label: e(t)("method.kind-key"),
1163
+ help: e(t)("method.kind-key-help"),
1164
+ error: T.value.kind?.[0]
1165
+ }, {
1166
+ default: d(() => [
1167
+ y(e(Y), {
1168
+ modelValue: S.value,
1169
+ "onUpdate:modelValue": z[2] || (z[2] = (u) => S.value = u),
1170
+ maxlength: 32
1171
+ }, null, 8, ["modelValue"])
1172
+ ]),
1173
+ _: 1
1174
+ }, 8, ["label", "help", "error"])
1175
+ ])
1176
+ ]),
1177
+ _: 1
1178
+ }, 8, ["open", "title"])
1179
+ ]));
1180
+ }
1181
+ }), Ft = /* @__PURE__ */ re(Mt, [["__scopeId", "data-v-e4f84750"]]), qt = /* @__PURE__ */ Z({
1182
+ name: "WxDeliveryRegionField",
1183
+ __name: "RegionField",
1184
+ props: /* @__PURE__ */ ie({
1185
+ disabled: { type: Boolean, default: !1 },
1186
+ countryField: { default: "country" },
1187
+ context: { default: void 0 }
1188
+ }, {
1189
+ modelValue: { default: null },
1190
+ modelModifiers: {}
1191
+ }),
1192
+ emits: ["update:modelValue"],
1193
+ setup(_) {
1194
+ const a = _, l = se(_, "modelValue"), r = oe(ee()), t = ne(), o = m([]), n = M(() => {
1195
+ const C = a.context?.model[a.countryField];
1196
+ return typeof C == "string" ? C : "";
1197
+ });
1198
+ X(
1199
+ n,
1200
+ async (C, v) => {
1201
+ if (C === "") {
1202
+ o.value = [];
1203
+ return;
1204
+ }
1205
+ try {
1206
+ o.value = await r.regions(C);
1207
+ } catch {
1208
+ o.value = [];
1209
+ }
1210
+ v !== void 0 && v !== C && (l.value = null);
1211
+ },
1212
+ { immediate: !0 }
1213
+ );
1214
+ const f = M(() => o.value.map((C) => ({ value: C.id, label: C.name })));
1215
+ return (C, v) => (i(), x(e(pe), {
1216
+ modelValue: l.value,
1217
+ "onUpdate:modelValue": v[0] || (v[0] = (S) => l.value = S),
1218
+ options: f.value,
1219
+ filterable: "",
1220
+ clearable: "",
1221
+ placeholder: n.value === "" ? e(t)("region.country-first") : e(t)("locality.no-region"),
1222
+ disabled: a.disabled || n.value === ""
1223
+ }, null, 8, ["modelValue", "options", "placeholder", "disabled"]));
1224
+ }
1225
+ }), Bt = { class: "wx-delivery-schedule" }, jt = { class: "wx-delivery-schedule__name" }, Et = { class: "wx-delivery-schedule__exceptions" }, Kt = { class: "wx-delivery-schedule__title" }, Ht = /* @__PURE__ */ Z({
1226
+ name: "WxDeliveryScheduleField",
1227
+ __name: "ScheduleField",
1228
+ props: /* @__PURE__ */ ie({
1229
+ disabled: { type: Boolean, default: !1 }
1230
+ }, {
1231
+ modelValue: { default: null },
1232
+ modelModifiers: {}
1233
+ }),
1234
+ emits: ["update:modelValue"],
1235
+ setup(_) {
1236
+ const a = _, l = se(_, "modelValue"), r = ne(), t = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"], o = M(() => [
1237
+ { value: "unknown", label: r("schedule.not-said") },
1238
+ { value: "closed", label: r("schedule.closed") },
1239
+ { value: "hours", label: r("schedule.hours") },
1240
+ { value: "around", label: r("schedule.around") }
1241
+ ]);
1242
+ function n(u) {
1243
+ return u.map(([h, p]) => `${h}–${p}`).join(", ");
1244
+ }
1245
+ function f(u) {
1246
+ const h = u.split(/[,;]/).map((b) => b.trim()).filter((b) => b !== ""), p = [];
1247
+ for (const b of h) {
1248
+ const L = /^(\d{1,2})[:.](\d{2})\s*[-–—]\s*(\d{1,2})[:.](\d{2})$/.exec(b);
1249
+ if (!L) return null;
1250
+ const I = (w) => w.padStart(2, "0");
1251
+ p.push([`${I(L[1])}:${L[2]}`, `${I(L[3])}:${L[4]}`]);
1252
+ }
1253
+ return p;
1254
+ }
1255
+ function C(u) {
1256
+ return u == null ? "unknown" : u.length === 0 ? "closed" : u.length === 1 && u[0][0] === "00:00" && u[0][1] === "24:00" ? "around" : "hours";
1257
+ }
1258
+ const v = m({}), S = m({});
1259
+ X(
1260
+ l,
1261
+ (u) => {
1262
+ for (const h of t) {
1263
+ const p = u?.week?.[h];
1264
+ C(p) === "hours" && !S.value[h] && (v.value[h] = n(p));
1265
+ }
1266
+ },
1267
+ { immediate: !0 }
1268
+ );
1269
+ function O(u) {
1270
+ const h = JSON.parse(JSON.stringify(l.value ?? {}));
1271
+ u(h);
1272
+ const p = Object.keys(h.week ?? {}).length === 0 && (h.exceptions ?? []).length === 0 && Object.keys(h.text ?? {}).length === 0;
1273
+ l.value = p ? null : h;
1274
+ }
1275
+ function T(u, h) {
1276
+ O((p) => {
1277
+ if (p.week ??= {}, h === "unknown") delete p.week[u];
1278
+ else if (h === "closed") p.week[u] = [];
1279
+ else if (h === "around") p.week[u] = [["00:00", "24:00"]];
1280
+ else {
1281
+ const b = f(v.value[u] ?? "");
1282
+ p.week[u] = b && b.length > 0 ? b : [["09:00", "18:00"]], v.value[u] = n(p.week[u]);
1283
+ }
1284
+ });
1285
+ }
1286
+ function F(u, h) {
1287
+ v.value[u] = h;
1288
+ const p = f(h);
1289
+ S.value[u] = p === null || p.length === 0, S.value[u] || O((b) => (b.week ??= {})[u] = p);
1290
+ }
1291
+ const B = M(() => l.value?.exceptions ?? []);
1292
+ function W() {
1293
+ O((u) => {
1294
+ u.exceptions = [
1295
+ ...u.exceptions ?? [],
1296
+ { date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), hours: [] }
1297
+ ];
1298
+ });
1299
+ }
1300
+ function q(u, h) {
1301
+ O((p) => {
1302
+ const b = p.exceptions?.[u];
1303
+ b && (h.date !== void 0 && (b.date = h.date), h.text !== void 0 && (b.hours = f(h.text) ?? b.hours));
1304
+ });
1305
+ }
1306
+ function z(u) {
1307
+ O((h) => {
1308
+ h.exceptions = (h.exceptions ?? []).filter((p, b) => b !== u);
1309
+ });
1310
+ }
1311
+ return (u, h) => (i(), V("div", Bt, [
1312
+ (i(), V(K, null, le(t, (p) => g("div", {
1313
+ key: p,
1314
+ class: "wx-delivery-schedule__day"
1315
+ }, [
1316
+ g("span", jt, s(e(r)(`schedule.days.${p}`)), 1),
1317
+ y(e(pe), {
1318
+ class: "wx-delivery-schedule__mode",
1319
+ size: "sm",
1320
+ "model-value": C(l.value?.week?.[p]),
1321
+ options: o.value,
1322
+ "aria-label": e(r)(`schedule.days.${p}`),
1323
+ disabled: a.disabled,
1324
+ "onUpdate:modelValue": (b) => T(p, b)
1325
+ }, null, 8, ["model-value", "options", "aria-label", "disabled", "onUpdate:modelValue"]),
1326
+ C(l.value?.week?.[p]) === "hours" ? (i(), x(e(Y), {
1327
+ key: 0,
1328
+ class: "wx-delivery-schedule__hours",
1329
+ size: "sm",
1330
+ "model-value": v.value[p] ?? "",
1331
+ status: S.value[p] ? "error" : void 0,
1332
+ "aria-label": e(r)("schedule.hours"),
1333
+ placeholder: "09:00–18:00",
1334
+ disabled: a.disabled,
1335
+ "onUpdate:modelValue": (b) => F(p, String(b ?? ""))
1336
+ }, null, 8, ["model-value", "status", "aria-label", "disabled", "onUpdate:modelValue"])) : D("", !0)
1337
+ ])), 64)),
1338
+ g("div", Et, [
1339
+ g("span", Kt, s(e(r)("schedule.exceptions")), 1),
1340
+ (i(!0), V(K, null, le(B.value, (p, b) => (i(), V("div", {
1341
+ key: b,
1342
+ class: "wx-delivery-schedule__day"
1343
+ }, [
1344
+ y(e(tt), {
1345
+ class: "wx-delivery-schedule__mode",
1346
+ size: "sm",
1347
+ "model-value": p.date,
1348
+ "aria-label": e(r)("schedule.date"),
1349
+ disabled: a.disabled,
1350
+ "onUpdate:modelValue": (L) => q(b, { date: String(L ?? "") })
1351
+ }, null, 8, ["model-value", "aria-label", "disabled", "onUpdate:modelValue"]),
1352
+ y(e(Y), {
1353
+ class: "wx-delivery-schedule__hours",
1354
+ size: "sm",
1355
+ "model-value": p.hours.length === 0 ? "" : n(p.hours),
1356
+ placeholder: e(r)("schedule.closed"),
1357
+ "aria-label": e(r)("schedule.hours"),
1358
+ disabled: a.disabled,
1359
+ onChange: (L) => q(b, { text: String(L ?? "") })
1360
+ }, null, 8, ["model-value", "placeholder", "aria-label", "disabled", "onChange"]),
1361
+ y(e(at), {
1362
+ type: "remove",
1363
+ size: "sm",
1364
+ title: e(r)("schedule.remove"),
1365
+ disabled: a.disabled,
1366
+ onClick: (L) => z(b)
1367
+ }, null, 8, ["title", "disabled", "onClick"])
1368
+ ]))), 128)),
1369
+ a.disabled ? D("", !0) : (i(), x(e(j), {
1370
+ key: 0,
1371
+ size: "sm",
1372
+ variant: "outline",
1373
+ icon: "plus",
1374
+ class: "wx-delivery-schedule__add",
1375
+ onClick: W
1376
+ }, {
1377
+ default: d(() => [
1378
+ P(s(e(r)("schedule.add-exception")), 1)
1379
+ ]),
1380
+ _: 1
1381
+ }))
1382
+ ])
1383
+ ]));
1384
+ }
1385
+ }), Gt = /* @__PURE__ */ re(Ht, [["__scopeId", "data-v-bd98b4bb"]]), Jt = { class: "wx-delivery-change" }, Yt = { class: "wx-delivery-change__town" }, Qt = {
1386
+ key: 0,
1387
+ class: "wx-delivery-change__chosen",
1388
+ "data-test": "change-town"
1389
+ }, Xt = {
1390
+ key: 2,
1391
+ class: "wx-delivery-change__methods"
1392
+ }, Zt = { class: "wx-delivery-change__pair" }, ea = {
1393
+ key: 4,
1394
+ class: "wx-delivery-change__outcome",
1395
+ "data-test": "change-outcome"
1396
+ }, ta = { class: "wx-delivery-change__row" }, aa = { class: "wx-delivery-change__label" }, la = { class: "wx-delivery-change__row" }, oa = { class: "wx-delivery-change__label" }, na = {
1397
+ key: 0,
1398
+ class: "wx-delivery-change__strong"
1399
+ }, ra = { key: 1 }, ia = /* @__PURE__ */ Z({
1400
+ name: "WxDeliveryOrderChangeDialog",
1401
+ __name: "OrderChangeDialog",
1402
+ props: {
1403
+ orderId: {},
1404
+ start: {}
1405
+ },
1406
+ setup(_) {
1407
+ const a = _, { open: l, resolve: r } = Oe(), t = oe(ee()), o = ne(), n = ye(), f = m(a.start.locality), C = m(""), v = m([]), S = m([]), O = m(!1), T = m([]), F = m(!1), B = m(null), W = m(""), q = m([]), z = m(!1), u = m(null), h = m(a.start.address?.street ?? ""), p = m([]), b = m(a.start.address?.street_id ?? null), L = m(a.start.address?.house ?? ""), I = m(a.start.address?.apartment ?? ""), w = m(a.start.address?.note ?? ""), R = m(""), k = m({}), U = m(null), N = m(!1), H = m(!1), G = M(() => T.value.find((c) => c.id === B.value) ?? null), he = M(() => G.value?.carrier === "store"), Pe = M(
1408
+ () => T.value.map((c) => ({
1409
+ value: c.id,
1410
+ label: c.price ? `${c.title} · ${c.price.text}` : c.title,
1411
+ disabled: c.disabled
1412
+ }))
1413
+ ), te = (c) => k.value[c]?.[0], Ie = M(
1414
+ () => v.value.map((c) => ({ value: c.name, description: c.label, id: c.id }))
1415
+ ), ze = M(
1416
+ () => q.value.map((c) => ({
1417
+ value: c.label,
1418
+ description: c.hint ?? void 0,
1419
+ id: Number(c.value)
1420
+ }))
1421
+ ), Re = M(
1422
+ () => p.value.map((c) => ({ value: c.label, id: c.value }))
1423
+ );
1424
+ let me = 0;
1425
+ async function $e(c) {
1426
+ const $ = ++me;
1427
+ O.value = !0;
1428
+ try {
1429
+ const A = await t.changeTowns(a.orderId, c.trim());
1430
+ if ($ !== me) return;
1431
+ v.value = A.localities, S.value = A.popular;
1432
+ } catch {
1433
+ $ === me && (v.value = []);
1434
+ } finally {
1435
+ $ === me && (O.value = !1);
1436
+ }
1437
+ }
1438
+ function Ve(c) {
1439
+ f.value = { id: c.id, label: c.label }, C.value = "", v.value = [];
1440
+ }
1441
+ function Me(c) {
1442
+ const $ = v.value.find((A) => A.id === c.id);
1443
+ $ && Ve($);
1444
+ }
1445
+ async function Fe() {
1446
+ if (f.value) {
1447
+ F.value = !0, U.value = null;
1448
+ try {
1449
+ const c = await t.changeMethods(a.orderId, f.value.id);
1450
+ T.value = c.methods;
1451
+ const $ = c.methods.find((A) => A.id === B.value && !A.disabled) ?? c.methods.find((A) => A.key === a.start.method && !A.disabled);
1452
+ B.value = $?.id ?? null;
1453
+ } catch (c) {
1454
+ T.value = [], k.value = { method: [n(c)] };
1455
+ } finally {
1456
+ F.value = !1;
1457
+ }
1458
+ }
1459
+ }
1460
+ let fe = 0;
1461
+ async function Ce(c) {
1462
+ if (!f.value || !G.value) return;
1463
+ const $ = ++fe;
1464
+ z.value = !0;
1465
+ try {
1466
+ const A = await t.changePoints(a.orderId, f.value.id, G.value.id, c.trim());
1467
+ $ === fe && (q.value = A.options);
1468
+ } catch {
1469
+ $ === fe && (q.value = []);
1470
+ } finally {
1471
+ $ === fe && (z.value = !1);
1472
+ }
1473
+ }
1474
+ function qe(c) {
1475
+ const $ = c.id;
1476
+ typeof $ == "number" && (u.value = { id: $, label: c.value }, W.value = c.value);
1477
+ }
1478
+ async function Be(c) {
1479
+ if (!(!f.value || !G.value))
1480
+ try {
1481
+ p.value = (await t.changeStreets(a.orderId, f.value.id, G.value.id, c.trim())).options;
1482
+ } catch {
1483
+ p.value = [];
1484
+ }
1485
+ }
1486
+ function je(c) {
1487
+ h.value = c.value, b.value = he.value ? null : String(c.id ?? "");
1488
+ }
1489
+ function Ee(c) {
1490
+ he.value || (b.value = null), h.value = c;
1491
+ }
1492
+ const be = M(() => {
1493
+ if (!f.value || !G.value) return null;
1494
+ const c = { locality: f.value.id, method: G.value.id };
1495
+ return G.value.asks === "point" && (c.point = u.value?.id ?? null), G.value.asks === "address" && (c.address = {
1496
+ street: h.value.trim() || null,
1497
+ street_id: he.value ? null : b.value,
1498
+ house: L.value.trim() || null,
1499
+ apartment: I.value.trim() || null,
1500
+ note: w.value.trim() || null
1501
+ }), c;
1502
+ });
1503
+ function Te(c) {
1504
+ k.value = c.errors ?? {}, Object.keys(k.value).length === 0 && (k.value = { delivery: [n(c)] });
1505
+ }
1506
+ async function Ke() {
1507
+ const c = be.value;
1508
+ if (!(!c || N.value)) {
1509
+ N.value = !0, k.value = {}, U.value = null;
1510
+ try {
1511
+ U.value = (await t.changeDelivery(a.orderId, { ...c, dry_run: !0 })).change;
1512
+ } catch ($) {
1513
+ Te($);
1514
+ } finally {
1515
+ N.value = !1;
1516
+ }
1517
+ }
1518
+ }
1519
+ async function He() {
1520
+ const c = be.value;
1521
+ if (!(!c || H.value)) {
1522
+ H.value = !0, k.value = {};
1523
+ try {
1524
+ const $ = await t.changeDelivery(a.orderId, {
1525
+ ...c,
1526
+ reason: R.value.trim() || null
1527
+ });
1528
+ $.delivery && r($.delivery);
1529
+ } catch ($) {
1530
+ Te($);
1531
+ } finally {
1532
+ H.value = !1;
1533
+ }
1534
+ }
1535
+ }
1536
+ X(
1537
+ f,
1538
+ (c, $) => {
1539
+ c?.id !== $?.id && (u.value = null, W.value = "", q.value = [], p.value = []), Fe();
1540
+ },
1541
+ { immediate: !0 }
1542
+ ), X(B, (c, $) => {
1543
+ U.value = null, $ !== null && c !== $ && (u.value = null, W.value = "", q.value = [], p.value = [], he.value || (b.value = null));
1544
+ }), X(
1545
+ () => [G.value?.id, G.value?.asks, f.value?.id],
1546
+ ([, c]) => {
1547
+ c === "point" && Ce("");
1548
+ }
1549
+ ), X([u, h, L, I], () => U.value = null), $e(""), X(T, (c) => {
1550
+ if (u.value || a.start.point === null) return;
1551
+ const $ = c.find((A) => A.key === a.start.method);
1552
+ !$ || $.id !== B.value || f.value?.id !== a.start.locality?.id || (async () => {
1553
+ const ve = (await t.changePoints(a.orderId, f.value.id, $.id, "")).options.find((Ge) => Number(Ge.value) === a.start.point);
1554
+ ve && (u.value = { id: Number(ve.value), label: ve.label }, W.value = ve.label);
1555
+ })().catch(() => {
1556
+ });
1557
+ });
1558
+ const Se = M({
1559
+ get: () => B.value,
1560
+ set: (c) => B.value = c === null ? null : Number(c)
1561
+ });
1562
+ return (c, $) => (i(), x(e(_e), {
1563
+ open: e(l),
1564
+ "onUpdate:open": $[8] || ($[8] = (A) => Ae(l) ? l.value = A : null),
1565
+ title: e(o)("order.change-title"),
1566
+ width: 600
1567
+ }, {
1568
+ footer: d(() => [
1569
+ y(e(j), {
1570
+ onClick: $[7] || ($[7] = (A) => l.value = !1)
1571
+ }, {
1572
+ default: d(() => [
1573
+ P(s(e(o)("common.cancel")), 1)
1574
+ ]),
1575
+ _: 1
1576
+ }),
1577
+ U.value ? (i(), x(e(j), {
1578
+ key: 1,
1579
+ type: "primary",
1580
+ loading: H.value,
1581
+ "data-test": "change-save",
1582
+ onClick: He
1583
+ }, {
1584
+ default: d(() => [
1585
+ P(s(e(o)("order.change-save")), 1)
1586
+ ]),
1587
+ _: 1
1588
+ }, 8, ["loading"])) : (i(), x(e(j), {
1589
+ key: 0,
1590
+ type: "primary",
1591
+ disabled: !be.value,
1592
+ loading: N.value,
1593
+ "data-test": "change-check",
1594
+ onClick: Ke
1595
+ }, {
1596
+ default: d(() => [
1597
+ P(s(e(o)("order.change-check")), 1)
1598
+ ]),
1599
+ _: 1
1600
+ }, 8, ["disabled", "loading"]))
1601
+ ]),
1602
+ default: d(() => [
1603
+ g("div", Jt, [
1604
+ y(e(ae), {
1605
+ tone: "muted",
1606
+ size: "sm"
1607
+ }, {
1608
+ default: d(() => [
1609
+ P(s(e(o)("order.change-help")), 1)
1610
+ ]),
1611
+ _: 1
1612
+ }),
1613
+ te("delivery") ? (i(), x(e(de), {
1614
+ key: 0,
1615
+ type: "danger",
1616
+ description: te("delivery")
1617
+ }, null, 8, ["description"])) : D("", !0),
1618
+ y(e(E), {
1619
+ label: e(o)("order.locality"),
1620
+ error: te("locality"),
1621
+ required: ""
1622
+ }, {
1623
+ default: d(() => [
1624
+ g("div", Yt, [
1625
+ f.value ? (i(), V("span", Qt, s(f.value.label), 1)) : D("", !0),
1626
+ y(e(ge), {
1627
+ modelValue: C.value,
1628
+ "onUpdate:modelValue": $[0] || ($[0] = (A) => C.value = A),
1629
+ options: Ie.value,
1630
+ remote: "",
1631
+ teleport: "",
1632
+ loading: O.value,
1633
+ "empty-text": e(o)("locality.nothing-found"),
1634
+ placeholder: e(o)("order.change-town-search"),
1635
+ "aria-label": e(o)("order.change-town-search"),
1636
+ "data-test": "change-town-search",
1637
+ onSearch: $e,
1638
+ onSelect: Me
1639
+ }, null, 8, ["modelValue", "options", "loading", "empty-text", "placeholder", "aria-label"]),
1640
+ S.value.length > 0 ? (i(), x(e(ue), {
1641
+ key: 1,
1642
+ size: 8,
1643
+ wrap: ""
1644
+ }, {
1645
+ default: d(() => [
1646
+ (i(!0), V(K, null, le(S.value, (A) => (i(), x(e(j), {
1647
+ key: A.id,
1648
+ size: "sm",
1649
+ variant: "outline",
1650
+ type: f.value?.id === A.id ? "primary" : void 0,
1651
+ "data-test": "change-popular",
1652
+ onClick: (ve) => Ve(A)
1653
+ }, {
1654
+ default: d(() => [
1655
+ P(s(A.name), 1)
1656
+ ]),
1657
+ _: 2
1658
+ }, 1032, ["type", "onClick"]))), 128))
1659
+ ]),
1660
+ _: 1
1661
+ })) : D("", !0)
1662
+ ])
1663
+ ]),
1664
+ _: 1
1665
+ }, 8, ["label", "error"]),
1666
+ f.value ? (i(), x(e(E), {
1667
+ key: 1,
1668
+ label: e(o)("order.method"),
1669
+ error: te("method"),
1670
+ required: ""
1671
+ }, {
1672
+ default: d(() => [
1673
+ F.value ? (i(), x(e(xe), {
1674
+ key: 0,
1675
+ rows: 2
1676
+ })) : T.value.length === 0 ? (i(), x(e(ae), {
1677
+ key: 1,
1678
+ tone: "muted"
1679
+ }, {
1680
+ default: d(() => [
1681
+ P(s(e(o)("order.change-no-methods")), 1)
1682
+ ]),
1683
+ _: 1
1684
+ })) : (i(), V("div", Xt, [
1685
+ y(e(lt), {
1686
+ modelValue: Se.value,
1687
+ "onUpdate:modelValue": $[1] || ($[1] = (A) => Se.value = A),
1688
+ options: Pe.value,
1689
+ "data-test": "change-methods"
1690
+ }, null, 8, ["modelValue", "options"]),
1691
+ (i(!0), V(K, null, le(T.value.filter((A) => A.disabled && A.hint), (A) => (i(), x(e(ae), {
1692
+ key: A.id,
1693
+ size: "sm",
1694
+ tone: "muted"
1695
+ }, {
1696
+ default: d(() => [
1697
+ P(s(A.title) + ": " + s(A.hint), 1)
1698
+ ]),
1699
+ _: 2
1700
+ }, 1024))), 128))
1701
+ ]))
1702
+ ]),
1703
+ _: 1
1704
+ }, 8, ["label", "error"])) : D("", !0),
1705
+ G.value?.asks === "point" ? (i(), x(e(E), {
1706
+ key: 2,
1707
+ label: e(o)("order.point"),
1708
+ error: te("point"),
1709
+ required: ""
1710
+ }, {
1711
+ default: d(() => [
1712
+ y(e(ge), {
1713
+ modelValue: W.value,
1714
+ "onUpdate:modelValue": $[2] || ($[2] = (A) => W.value = A),
1715
+ options: ze.value,
1716
+ remote: "",
1717
+ teleport: "",
1718
+ "open-on-focus": "",
1719
+ loading: z.value,
1720
+ "empty-text": e(o)("order.change-no-points"),
1721
+ placeholder: e(o)("order.change-point-search"),
1722
+ "aria-label": e(o)("order.change-point-search"),
1723
+ "data-test": "change-point",
1724
+ onSearch: Ce,
1725
+ onSelect: qe
1726
+ }, null, 8, ["modelValue", "options", "loading", "empty-text", "placeholder", "aria-label"])
1727
+ ]),
1728
+ _: 1
1729
+ }, 8, ["label", "error"])) : D("", !0),
1730
+ G.value?.asks === "address" ? (i(), V(K, { key: 3 }, [
1731
+ y(e(E), {
1732
+ label: e(o)("order.change-street"),
1733
+ help: he.value ? void 0 : e(o)("order.change-street-help"),
1734
+ error: te("address.street") ?? te("address.street_id"),
1735
+ required: ""
1736
+ }, {
1737
+ default: d(() => [
1738
+ y(e(ge), {
1739
+ "model-value": h.value,
1740
+ options: Re.value,
1741
+ remote: "",
1742
+ teleport: "",
1743
+ "aria-label": e(o)("order.change-street"),
1744
+ "data-test": "change-street",
1745
+ "onUpdate:modelValue": Ee,
1746
+ onSearch: Be,
1747
+ onSelect: je
1748
+ }, null, 8, ["model-value", "options", "aria-label"])
1749
+ ]),
1750
+ _: 1
1751
+ }, 8, ["label", "help", "error"]),
1752
+ g("div", Zt, [
1753
+ y(e(E), {
1754
+ label: e(o)("order.change-house"),
1755
+ error: te("address.house"),
1756
+ required: ""
1757
+ }, {
1758
+ default: d(() => [
1759
+ y(e(Y), {
1760
+ modelValue: L.value,
1761
+ "onUpdate:modelValue": $[3] || ($[3] = (A) => L.value = A),
1762
+ maxlength: 32,
1763
+ "data-test": "change-house"
1764
+ }, null, 8, ["modelValue"])
1765
+ ]),
1766
+ _: 1
1767
+ }, 8, ["label", "error"]),
1768
+ y(e(E), {
1769
+ label: e(o)("order.change-apartment"),
1770
+ error: te("address.apartment")
1771
+ }, {
1772
+ default: d(() => [
1773
+ y(e(Y), {
1774
+ modelValue: I.value,
1775
+ "onUpdate:modelValue": $[4] || ($[4] = (A) => I.value = A),
1776
+ maxlength: 32
1777
+ }, null, 8, ["modelValue"])
1778
+ ]),
1779
+ _: 1
1780
+ }, 8, ["label", "error"])
1781
+ ]),
1782
+ y(e(E), {
1783
+ label: e(o)("order.note"),
1784
+ error: te("address.note")
1785
+ }, {
1786
+ default: d(() => [
1787
+ y(e(Y), {
1788
+ modelValue: w.value,
1789
+ "onUpdate:modelValue": $[5] || ($[5] = (A) => w.value = A),
1790
+ maxlength: 500
1791
+ }, null, 8, ["modelValue"])
1792
+ ]),
1793
+ _: 1
1794
+ }, 8, ["label", "error"])
1795
+ ], 64)) : D("", !0),
1796
+ y(e(E), {
1797
+ label: e(o)("order.change-reason"),
1798
+ help: e(o)("order.change-reason-help")
1799
+ }, {
1800
+ default: d(() => [
1801
+ y(e(Y), {
1802
+ modelValue: R.value,
1803
+ "onUpdate:modelValue": $[6] || ($[6] = (A) => R.value = A),
1804
+ maxlength: 300,
1805
+ "data-test": "change-reason"
1806
+ }, null, 8, ["modelValue"])
1807
+ ]),
1808
+ _: 1
1809
+ }, 8, ["label", "help"]),
1810
+ U.value ? (i(), V("div", ea, [
1811
+ g("div", ta, [
1812
+ g("span", aa, s(e(o)("order.cost")), 1),
1813
+ g("span", null, s(e(o)("order.change-from-to", { from: U.value.amount_from, to: U.value.amount_to })), 1)
1814
+ ]),
1815
+ g("div", la, [
1816
+ g("span", oa, s(e(o)("order.change-total")), 1),
1817
+ U.value.total_changes ? (i(), V("span", na, s(e(o)("order.change-from-to", { from: U.value.total_from, to: U.value.total_to })), 1)) : (i(), V("span", ra, s(e(o)("order.change-same", { amount: U.value.total_to })), 1))
1818
+ ]),
1819
+ U.value.balance ? (i(), x(e(de), {
1820
+ key: 0,
1821
+ type: U.value.balance.kind === "over" ? "danger" : "warning",
1822
+ description: e(o)(U.value.balance.kind === "over" ? "order.change-over" : "order.change-due", {
1823
+ amount: U.value.balance.amount
1824
+ })
1825
+ }, null, 8, ["type", "description"])) : D("", !0)
1826
+ ])) : D("", !0)
1827
+ ])
1828
+ ]),
1829
+ _: 1
1830
+ }, 8, ["open", "title"]));
1831
+ }
1832
+ }), sa = /* @__PURE__ */ re(ia, [["__scopeId", "data-v-ececa6e7"]]), da = { class: "wx-delivery-waybill" }, ca = { class: "wx-delivery-waybill__pair" }, ua = { class: "wx-delivery-waybill__pair" }, ha = {
1833
+ key: 2,
1834
+ class: "wx-delivery-waybill__fact",
1835
+ "data-test": "waybill-extra"
1836
+ }, va = { class: "wx-delivery-waybill__label" }, pa = { class: "wx-delivery-waybill__pair" }, ya = { class: "wx-delivery-waybill__fact" }, ma = { class: "wx-delivery-waybill__label" }, fa = {
1837
+ key: 3,
1838
+ class: "wx-delivery-waybill__fact"
1839
+ }, ga = { class: "wx-delivery-waybill__label" }, _a = { class: "wx-delivery-waybill__lines" }, ba = { class: "wx-delivery-waybill__line-name" }, wa = { class: "wx-delivery-waybill__line-qty" }, ka = { class: "wx-delivery-waybill__line-price" }, xa = /* @__PURE__ */ Z({
1840
+ name: "WxDeliveryWaybillDialog",
1841
+ __name: "WaybillDialog",
1842
+ props: {
1843
+ orderId: {},
1844
+ draft: {},
1845
+ exponent: {}
1846
+ },
1847
+ setup(_) {
1848
+ const a = _, { open: l, resolve: r } = Oe(), t = ee(), o = oe(t), n = ne(), f = ye(), C = 10 ** a.exponent, v = (k) => k === null ? null : k / C, S = (k) => k == null ? null : Math.round(k * C), O = m(a.draft.recipient.first_name), T = m(a.draft.recipient.last_name), F = m(a.draft.recipient.phone ?? ""), B = m(v(a.draft.declared_value)), W = m(v(a.draft.cod)), q = m({}), z = M(() => a.draft.form?.fields ?? []), u = M(() => a.draft.form?.cod ?? !0), h = m(
1849
+ Object.fromEntries(
1850
+ z.value.map((k) => [
1851
+ k.name,
1852
+ a.draft.extra?.[k.name] ?? k.default ?? null
1853
+ ])
1854
+ )
1855
+ );
1856
+ function p(k) {
1857
+ return typeof k.label == "string" ? k.label : k.label && typeof k.label == "object" ? k.label[t.i18n.state.locale] ?? Object.values(k.label)[0] ?? k.name : k.name;
1858
+ }
1859
+ const b = m(!1), L = (k) => new Intl.NumberFormat(void 0, {
1860
+ style: "currency",
1861
+ currency: a.draft.currency,
1862
+ minimumFractionDigits: a.exponent,
1863
+ maximumFractionDigits: a.exponent
1864
+ }).format(k / C), I = M(
1865
+ () => a.draft.payer === "sender" ? n("order.payer-sender") : n("order.payer-recipient")
1866
+ ), w = (k) => q.value[k]?.[0];
1867
+ async function R() {
1868
+ if (!(b.value || O.value.trim() === "")) {
1869
+ b.value = !0, q.value = {};
1870
+ try {
1871
+ r(
1872
+ await o.createWaybill(a.orderId, {
1873
+ recipient_first_name: O.value.trim(),
1874
+ recipient_last_name: T.value.trim(),
1875
+ recipient_phone: F.value.trim() || null,
1876
+ declared_value: S(B.value),
1877
+ ...u.value ? { cod: S(W.value) } : {},
1878
+ ...z.value.length > 0 ? { extra: h.value } : {}
1879
+ })
1880
+ );
1881
+ } catch (k) {
1882
+ q.value = k.errors ?? {}, Object.keys(q.value).length === 0 && (q.value = { waybill: [f(k)] });
1883
+ } finally {
1884
+ b.value = !1;
1885
+ }
1886
+ }
1887
+ }
1888
+ return (k, U) => (i(), x(e(_e), {
1889
+ open: e(l),
1890
+ "onUpdate:open": U[6] || (U[6] = (N) => Ae(l) ? l.value = N : null),
1891
+ title: e(n)("order.create-title"),
1892
+ width: 560
1893
+ }, {
1894
+ footer: d(() => [
1895
+ y(e(ue), { size: "sm" }, {
1896
+ default: d(() => [
1897
+ y(e(j), {
1898
+ variant: "outline",
1899
+ onClick: U[5] || (U[5] = (N) => l.value = !1)
1900
+ }, {
1901
+ default: d(() => [
1902
+ P(s(e(n)("common.cancel")), 1)
1903
+ ]),
1904
+ _: 1
1905
+ }),
1906
+ y(e(j), {
1907
+ type: "primary",
1908
+ loading: b.value,
1909
+ disabled: O.value.trim() === "",
1910
+ "data-test": "waybill-create",
1911
+ onClick: R
1912
+ }, {
1913
+ default: d(() => [
1914
+ P(s(e(n)("order.create")), 1)
1915
+ ]),
1916
+ _: 1
1917
+ }, 8, ["loading", "disabled"])
1918
+ ]),
1919
+ _: 1
1920
+ })
1921
+ ]),
1922
+ default: d(() => [
1923
+ g("div", da, [
1924
+ y(e(ae), {
1925
+ tone: "muted",
1926
+ size: "sm"
1927
+ }, {
1928
+ default: d(() => [
1929
+ P(s(e(n)(u.value ? "order.create-help" : "order.create-help-no-cod")), 1)
1930
+ ]),
1931
+ _: 1
1932
+ }),
1933
+ w("waybill") ? (i(), x(e(de), {
1934
+ key: 0,
1935
+ type: "danger",
1936
+ description: w("waybill")
1937
+ }, null, 8, ["description"])) : D("", !0),
1938
+ g("div", ca, [
1939
+ y(e(E), {
1940
+ label: e(n)("order.recipient-first-name"),
1941
+ error: w("recipient_first_name"),
1942
+ required: ""
1943
+ }, {
1944
+ default: d(() => [
1945
+ y(e(Y), {
1946
+ modelValue: O.value,
1947
+ "onUpdate:modelValue": U[0] || (U[0] = (N) => O.value = N),
1948
+ maxlength: 190,
1949
+ autocomplete: "off",
1950
+ "data-test": "waybill-first-name"
1951
+ }, null, 8, ["modelValue"])
1952
+ ]),
1953
+ _: 1
1954
+ }, 8, ["label", "error"]),
1955
+ y(e(E), {
1956
+ label: e(n)("order.recipient-last-name"),
1957
+ error: w("recipient_last_name")
1958
+ }, {
1959
+ default: d(() => [
1960
+ y(e(Y), {
1961
+ modelValue: T.value,
1962
+ "onUpdate:modelValue": U[1] || (U[1] = (N) => T.value = N),
1963
+ maxlength: 190,
1964
+ autocomplete: "off",
1965
+ "data-test": "waybill-last-name"
1966
+ }, null, 8, ["modelValue"])
1967
+ ]),
1968
+ _: 1
1969
+ }, 8, ["label", "error"])
1970
+ ]),
1971
+ g("div", ua, [
1972
+ y(e(E), {
1973
+ label: e(n)("order.recipient-phone"),
1974
+ error: w("recipient_phone")
1975
+ }, {
1976
+ default: d(() => [
1977
+ y(e(Y), {
1978
+ modelValue: F.value,
1979
+ "onUpdate:modelValue": U[2] || (U[2] = (N) => F.value = N),
1980
+ maxlength: 32,
1981
+ autocomplete: "off"
1982
+ }, null, 8, ["modelValue"])
1983
+ ]),
1984
+ _: 1
1985
+ }, 8, ["label", "error"]),
1986
+ y(e(E), {
1987
+ label: e(n)("order.declared"),
1988
+ error: w("declared_value")
1989
+ }, {
1990
+ default: d(() => [
1991
+ y(e(we), {
1992
+ modelValue: B.value,
1993
+ "onUpdate:modelValue": U[3] || (U[3] = (N) => B.value = N),
1994
+ min: 0,
1995
+ precision: _.exponent,
1996
+ step: 1
1997
+ }, null, 8, ["modelValue", "precision"])
1998
+ ]),
1999
+ _: 1
2000
+ }, 8, ["label", "error"])
2001
+ ]),
2002
+ u.value ? (i(), x(e(E), {
2003
+ key: 1,
2004
+ label: e(n)("order.cod"),
2005
+ help: e(n)("order.cod-help"),
2006
+ error: w("cod"),
2007
+ "data-test": "waybill-cod"
2008
+ }, {
2009
+ default: d(() => [
2010
+ y(e(we), {
2011
+ modelValue: W.value,
2012
+ "onUpdate:modelValue": U[4] || (U[4] = (N) => W.value = N),
2013
+ min: 0,
2014
+ precision: _.exponent,
2015
+ step: 1
2016
+ }, null, 8, ["modelValue", "precision"])
2017
+ ]),
2018
+ _: 1
2019
+ }, 8, ["label", "help", "error"])) : D("", !0),
2020
+ z.value.length > 0 ? (i(), V("div", ha, [
2021
+ g("span", va, s(e(n)("order.carrier-fields")), 1),
2022
+ g("div", pa, [
2023
+ (i(!0), V(K, null, le(z.value, (N) => (i(), x(e(E), {
2024
+ key: N.name,
2025
+ label: p(N),
2026
+ required: N.required === !0,
2027
+ error: w(`extra.${N.name}`)
2028
+ }, {
2029
+ default: d(() => [
2030
+ N.type === "number" ? (i(), x(e(we), {
2031
+ key: 0,
2032
+ modelValue: h.value[N.name],
2033
+ "onUpdate:modelValue": (H) => h.value[N.name] = H,
2034
+ min: N.min,
2035
+ max: N.max,
2036
+ step: N.step,
2037
+ precision: N.precision
2038
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "min", "max", "step", "precision"])) : N.type === "boolean" ? (i(), x(e(ot), {
2039
+ key: 1,
2040
+ modelValue: h.value[N.name],
2041
+ "onUpdate:modelValue": (H) => h.value[N.name] = H
2042
+ }, null, 8, ["modelValue", "onUpdate:modelValue"])) : N.type === "select" && Array.isArray(N.options) ? (i(), x(e(pe), {
2043
+ key: 2,
2044
+ modelValue: h.value[N.name],
2045
+ "onUpdate:modelValue": (H) => h.value[N.name] = H,
2046
+ options: N.options
2047
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "options"])) : (i(), x(e(Y), {
2048
+ key: 3,
2049
+ modelValue: h.value[N.name],
2050
+ "onUpdate:modelValue": (H) => h.value[N.name] = H,
2051
+ autocomplete: "off"
2052
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]))
2053
+ ]),
2054
+ _: 2
2055
+ }, 1032, ["label", "required", "error"]))), 128))
2056
+ ])
2057
+ ])) : D("", !0),
2058
+ g("div", ya, [
2059
+ g("span", ma, s(e(n)("order.payer")), 1),
2060
+ g("span", null, s(I.value), 1)
2061
+ ]),
2062
+ _.draft.lines.length > 0 ? (i(), V("div", fa, [
2063
+ g("span", ga, s(e(n)("order.lines")), 1),
2064
+ g("ul", _a, [
2065
+ (i(!0), V(K, null, le(_.draft.lines, (N, H) => (i(), V("li", { key: H }, [
2066
+ g("span", ba, s(N.name), 1),
2067
+ g("span", wa, "× " + s(N.qty), 1),
2068
+ g("span", ka, s(L(N.price)), 1)
2069
+ ]))), 128))
2070
+ ])
2071
+ ])) : D("", !0)
2072
+ ])
2073
+ ]),
2074
+ _: 1
2075
+ }, 8, ["open", "title"]));
2076
+ }
2077
+ }), $a = /* @__PURE__ */ re(xa, [["__scopeId", "data-v-ac182efe"]]), Va = { class: "wx-delivery-order" }, Ca = {
2078
+ class: "wx-delivery-order__facts",
2079
+ "data-test": "order-delivery-facts"
2080
+ }, Ta = { class: "wx-delivery-order__fact" }, Sa = {
2081
+ key: 0,
2082
+ class: "wx-delivery-order__fact"
2083
+ }, Na = {
2084
+ key: 1,
2085
+ class: "wx-delivery-order__fact"
2086
+ }, Da = { class: "wx-delivery-order__strong" }, Wa = { key: 0 }, Aa = {
2087
+ key: 1,
2088
+ class: "wx-delivery-order__muted"
2089
+ }, Oa = {
2090
+ key: 2,
2091
+ class: "wx-delivery-order__fact"
2092
+ }, Ua = {
2093
+ key: 0,
2094
+ class: "wx-delivery-order__muted"
2095
+ }, La = { class: "wx-delivery-order__fact" }, Pa = {
2096
+ key: 0,
2097
+ class: "wx-delivery-order__muted"
2098
+ }, Ia = {
2099
+ key: 1,
2100
+ class: "wx-delivery-order__muted"
2101
+ }, za = {
2102
+ key: 3,
2103
+ class: "wx-delivery-order__fact"
2104
+ }, Ra = {
2105
+ key: 2,
2106
+ class: "wx-delivery-order__parcels",
2107
+ "data-test": "order-parcels"
2108
+ }, Ma = { class: "wx-delivery-order__parcel-head" }, Fa = { class: "wx-delivery-order__strong" }, qa = {
2109
+ key: 0,
2110
+ class: "wx-delivery-order__muted"
2111
+ }, Ba = { class: "wx-delivery-order__events" }, ja = {
2112
+ key: 0,
2113
+ class: "wx-delivery-order__muted"
2114
+ }, Ea = /* @__PURE__ */ Z({
2115
+ name: "WxDeliveryOrder",
2116
+ __name: "OrderDeliveryNode",
2117
+ setup(_) {
2118
+ const a = ee(), l = oe(a), r = ne(), t = ye(), o = ct(), n = m(null), f = m(!1), C = m(!1), v = m(!1), S = M(() => {
2119
+ const w = Number(o?.id.value);
2120
+ return Number.isInteger(w) && w > 0 ? w : null;
2121
+ }), O = De($a), T = De(sa);
2122
+ async function F() {
2123
+ const w = n.value;
2124
+ if (!w?.change || w.change.refusal) return;
2125
+ const R = await T({ orderId: w.order_id, start: w.change });
2126
+ R && (n.value = R, J.success(r("order.changed")), await o?.reload?.());
2127
+ }
2128
+ async function B() {
2129
+ if (S.value !== null) {
2130
+ f.value = !0, C.value = !1;
2131
+ try {
2132
+ n.value = await l.orderDelivery(S.value);
2133
+ } catch {
2134
+ C.value = !0;
2135
+ } finally {
2136
+ f.value = !1;
2137
+ }
2138
+ }
2139
+ }
2140
+ X(S, () => {
2141
+ B();
2142
+ }, { immediate: !0 });
2143
+ const W = M(() => n.value?.delivery ?? null), q = M(() => n.value?.shipments.some((w) => !w.final) ?? !1), z = M(
2144
+ () => !!n.value?.can_ship && !!n.value.waybills && n.value.active === null && !!n.value.draft
2145
+ ), u = {
2146
+ created: "info",
2147
+ in_transit: "primary",
2148
+ at_point: "warning",
2149
+ out_for_delivery: "warning",
2150
+ received: "success",
2151
+ refused: "danger",
2152
+ returning: "danger",
2153
+ returned: "default",
2154
+ cancelled: "default"
2155
+ };
2156
+ async function h() {
2157
+ const w = n.value;
2158
+ if (!w?.draft) return;
2159
+ const R = await O({
2160
+ orderId: w.order_id,
2161
+ draft: w.draft,
2162
+ exponent: w.exponent
2163
+ });
2164
+ R && (n.value = R, J.success(r("order.created", { number: R.shipments[0]?.number ?? "" })));
2165
+ }
2166
+ async function p(w, R) {
2167
+ if (!v.value) {
2168
+ v.value = !0;
2169
+ try {
2170
+ n.value = await w(), J.success(R);
2171
+ } catch (k) {
2172
+ J.danger(t(k));
2173
+ } finally {
2174
+ v.value = !1;
2175
+ }
2176
+ }
2177
+ }
2178
+ const b = () => p(() => l.trackOrder(n.value.order_id), r("order.tracked")), L = (w) => p(() => l.cancelShipment(w.id), r("order.cancelled"));
2179
+ async function I(w) {
2180
+ try {
2181
+ const R = await l.shipmentLabel(w.id);
2182
+ if ("url" in R) {
2183
+ window.open(R.url, "_blank", "noopener");
2184
+ return;
2185
+ }
2186
+ const k = Uint8Array.from(atob(R.pdf), (U) => U.charCodeAt(0));
2187
+ window.open(URL.createObjectURL(new Blob([k], { type: "application/pdf" })), "_blank");
2188
+ } catch (R) {
2189
+ J.danger(t(R));
2190
+ }
2191
+ }
2192
+ return (w, R) => (i(), V("div", Va, [
2193
+ f.value && !n.value ? (i(), x(e(xe), {
2194
+ key: 0,
2195
+ rows: 4
2196
+ })) : C.value ? (i(), x(e(de), {
2197
+ key: 1,
2198
+ type: "danger",
2199
+ description: e(r)("order.failed")
2200
+ }, null, 8, ["description"])) : n.value ? (i(), V(K, { key: 2 }, [
2201
+ W.value ? (i(), V(K, { key: 1 }, [
2202
+ y(e(ke), {
2203
+ title: e(r)("order.chosen")
2204
+ }, Ne({
2205
+ default: d(() => [
2206
+ g("dl", Ca, [
2207
+ g("div", Ta, [
2208
+ g("dt", null, s(e(r)("order.method")), 1),
2209
+ g("dd", null, s(W.value.method), 1)
2210
+ ]),
2211
+ W.value.locality ? (i(), V("div", Sa, [
2212
+ g("dt", null, s(e(r)("order.locality")), 1),
2213
+ g("dd", null, s(W.value.locality), 1)
2214
+ ])) : D("", !0),
2215
+ W.value.point ? (i(), V("div", Na, [
2216
+ g("dt", null, s(e(r)("order.point")), 1),
2217
+ g("dd", null, [
2218
+ g("span", Da, s(W.value.point.title), 1),
2219
+ W.value.point.address ? (i(), V("span", Wa, s(W.value.point.address), 1)) : D("", !0),
2220
+ W.value.point.schedule ? (i(), V("span", Aa, s(W.value.point.schedule), 1)) : D("", !0)
2221
+ ])
2222
+ ])) : D("", !0),
2223
+ W.value.address ? (i(), V("div", Oa, [
2224
+ g("dt", null, s(e(r)("order.address")), 1),
2225
+ g("dd", null, [
2226
+ g("span", null, s(W.value.address), 1),
2227
+ W.value.note ? (i(), V("span", Ua, s(W.value.note), 1)) : D("", !0)
2228
+ ])
2229
+ ])) : D("", !0),
2230
+ g("div", La, [
2231
+ g("dt", null, s(e(r)("order.cost")), 1),
2232
+ g("dd", null, [
2233
+ g("span", null, [
2234
+ W.value.was ? (i(), V("s", Pa, s(W.value.was), 1)) : D("", !0),
2235
+ P(" " + s(W.value.price ?? "—") + " ", 1),
2236
+ W.value.estimate ? (i(), V("span", Ia, " ≈ " + s(W.value.estimate), 1)) : D("", !0)
2237
+ ]),
2238
+ W.value.paid_by_store ? (i(), x(e(ce), {
2239
+ key: 0,
2240
+ size: "sm",
2241
+ type: "success"
2242
+ }, {
2243
+ default: d(() => [
2244
+ P(s(e(r)("order.paid-by-store")), 1)
2245
+ ]),
2246
+ _: 1
2247
+ })) : D("", !0)
2248
+ ])
2249
+ ]),
2250
+ W.value.payer ? (i(), V("div", za, [
2251
+ g("dt", null, s(e(r)("order.payer")), 1),
2252
+ g("dd", null, s(W.value.payer === "sender" ? e(r)("order.payer-sender") : e(r)("order.payer-recipient")), 1)
2253
+ ])) : D("", !0)
2254
+ ]),
2255
+ n.value.change?.refusal ? (i(), x(e(ae), {
2256
+ key: 0,
2257
+ size: "sm",
2258
+ tone: "muted",
2259
+ class: "wx-delivery-order__why",
2260
+ "data-test": "order-change-why"
2261
+ }, {
2262
+ default: d(() => [
2263
+ P(s(n.value.change.refusal), 1)
2264
+ ]),
2265
+ _: 1
2266
+ })) : D("", !0)
2267
+ ]),
2268
+ _: 2
2269
+ }, [
2270
+ n.value.change ? {
2271
+ name: "extra",
2272
+ fn: d(() => [
2273
+ y(e(rt), {
2274
+ content: n.value.change.refusal ?? void 0,
2275
+ disabled: !n.value.change.refusal
2276
+ }, {
2277
+ default: d(() => [
2278
+ g("span", null, [
2279
+ y(e(j), {
2280
+ size: "sm",
2281
+ variant: "outline",
2282
+ icon: "edit",
2283
+ disabled: !!n.value.change.refusal || v.value,
2284
+ "data-test": "order-change",
2285
+ onClick: F
2286
+ }, {
2287
+ default: d(() => [
2288
+ P(s(e(r)("order.change")), 1)
2289
+ ]),
2290
+ _: 1
2291
+ }, 8, ["disabled"])
2292
+ ])
2293
+ ]),
2294
+ _: 1
2295
+ }, 8, ["content", "disabled"])
2296
+ ]),
2297
+ key: "0"
2298
+ } : void 0
2299
+ ]), 1032, ["title"]),
2300
+ y(e(ke), {
2301
+ title: e(r)("order.parcels")
2302
+ }, Ne({
2303
+ default: d(() => [
2304
+ n.value.waybills ? n.value.shipments.length === 0 ? (i(), x(e(ae), {
2305
+ key: 1,
2306
+ tone: "muted"
2307
+ }, {
2308
+ default: d(() => [
2309
+ P(s(e(r)("order.no-parcels")), 1)
2310
+ ]),
2311
+ _: 1
2312
+ })) : (i(), V("ul", Ra, [
2313
+ (i(!0), V(K, null, le(n.value.shipments, (k) => (i(), V("li", {
2314
+ key: k.id,
2315
+ class: "wx-delivery-order__parcel"
2316
+ }, [
2317
+ g("div", Ma, [
2318
+ g("span", Fa, s(k.number ?? "—"), 1),
2319
+ y(e(ce), {
2320
+ size: "sm",
2321
+ type: u[k.status]
2322
+ }, {
2323
+ default: d(() => [
2324
+ P(s(k.status_label), 1)
2325
+ ]),
2326
+ _: 2
2327
+ }, 1032, ["type"]),
2328
+ k.cost_formatted ? (i(), V("span", qa, s(e(r)("order.carrier-cost")) + ": " + s(k.cost_formatted), 1)) : D("", !0),
2329
+ R[0] || (R[0] = g("span", { class: "wx-delivery-order__gap" }, null, -1)),
2330
+ y(e(ue), {
2331
+ size: 8,
2332
+ wrap: ""
2333
+ }, {
2334
+ default: d(() => [
2335
+ k.label ? (i(), x(e(j), {
2336
+ key: 0,
2337
+ size: "sm",
2338
+ variant: "text",
2339
+ icon: "download",
2340
+ onClick: (U) => I(k)
2341
+ }, {
2342
+ default: d(() => [
2343
+ P(s(e(r)("order.label")), 1)
2344
+ ]),
2345
+ _: 1
2346
+ }, 8, ["onClick"])) : D("", !0),
2347
+ n.value.can_ship && k.cancellable ? (i(), x(e(it), {
2348
+ key: 1,
2349
+ title: e(r)("order.cancel-confirm", { number: k.number ?? "" }),
2350
+ "confirm-text": e(r)("order.cancel"),
2351
+ "cancel-text": e(r)("common.cancel"),
2352
+ "confirm-type": "danger",
2353
+ align: "end",
2354
+ onConfirm: (U) => L(k)
2355
+ }, {
2356
+ trigger: d(() => [
2357
+ y(e(j), {
2358
+ size: "sm",
2359
+ variant: "text",
2360
+ type: "danger",
2361
+ disabled: v.value
2362
+ }, {
2363
+ default: d(() => [
2364
+ P(s(e(r)("order.cancel")), 1)
2365
+ ]),
2366
+ _: 1
2367
+ }, 8, ["disabled"])
2368
+ ]),
2369
+ _: 1
2370
+ }, 8, ["title", "confirm-text", "cancel-text", "onConfirm"])) : D("", !0)
2371
+ ]),
2372
+ _: 2
2373
+ }, 1024)
2374
+ ]),
2375
+ g("ol", Ba, [
2376
+ (i(!0), V(K, null, le(k.events, (U, N) => (i(), V("li", {
2377
+ key: N,
2378
+ class: "wx-delivery-order__event"
2379
+ }, [
2380
+ y(e(ut), {
2381
+ value: U.at,
2382
+ size: "sm",
2383
+ tone: "muted"
2384
+ }, null, 8, ["value"]),
2385
+ g("span", null, s(U.label), 1),
2386
+ U.text ? (i(), V("span", ja, s(U.text), 1)) : D("", !0)
2387
+ ]))), 128))
2388
+ ]),
2389
+ k.final ? (i(), x(e(ae), {
2390
+ key: 0,
2391
+ size: "sm",
2392
+ tone: "muted"
2393
+ }, {
2394
+ default: d(() => [
2395
+ P(s(e(r)("order.final")), 1)
2396
+ ]),
2397
+ _: 1
2398
+ })) : D("", !0)
2399
+ ]))), 128))
2400
+ ])) : (i(), x(e(ae), {
2401
+ key: 0,
2402
+ tone: "muted"
2403
+ }, {
2404
+ default: d(() => [
2405
+ P(s(e(r)("order.own")), 1)
2406
+ ]),
2407
+ _: 1
2408
+ })),
2409
+ n.value.can_ship && n.value.waybills && n.value.active !== null ? (i(), x(e(ae), {
2410
+ key: 3,
2411
+ size: "sm",
2412
+ tone: "muted"
2413
+ }, {
2414
+ default: d(() => [
2415
+ P(s(e(r)("order.made-already")), 1)
2416
+ ]),
2417
+ _: 1
2418
+ })) : D("", !0)
2419
+ ]),
2420
+ _: 2
2421
+ }, [
2422
+ n.value.can_ship && (z.value || q.value) ? {
2423
+ name: "extra",
2424
+ fn: d(() => [
2425
+ y(e(ue), {
2426
+ size: 8,
2427
+ wrap: ""
2428
+ }, {
2429
+ default: d(() => [
2430
+ q.value ? (i(), x(e(j), {
2431
+ key: 0,
2432
+ size: "sm",
2433
+ variant: "outline",
2434
+ icon: "refresh",
2435
+ loading: v.value,
2436
+ "data-test": "order-track",
2437
+ onClick: b
2438
+ }, {
2439
+ default: d(() => [
2440
+ P(s(e(r)("order.track")), 1)
2441
+ ]),
2442
+ _: 1
2443
+ }, 8, ["loading"])) : D("", !0),
2444
+ z.value ? (i(), x(e(j), {
2445
+ key: 1,
2446
+ size: "sm",
2447
+ type: "primary",
2448
+ icon: "plus",
2449
+ "data-test": "order-waybill",
2450
+ onClick: h
2451
+ }, {
2452
+ default: d(() => [
2453
+ P(s(e(r)("order.create")), 1)
2454
+ ]),
2455
+ _: 1
2456
+ })) : D("", !0)
2457
+ ]),
2458
+ _: 1
2459
+ })
2460
+ ]),
2461
+ key: "0"
2462
+ } : void 0
2463
+ ]), 1032, ["title"])
2464
+ ], 64)) : (i(), x(e(ke), { key: 0 }, {
2465
+ default: d(() => [
2466
+ y(e(nt), {
2467
+ title: e(r)("order.none"),
2468
+ description: e(r)("order.none-help")
2469
+ }, null, 8, ["title", "description"])
2470
+ ]),
2471
+ _: 1
2472
+ }))
2473
+ ], 64)) : D("", !0)
2474
+ ]));
2475
+ }
2476
+ }), Ka = /* @__PURE__ */ re(Ea, [["__scopeId", "data-v-0e98475a"]]);
2477
+ function Ya(_ = {}) {
2478
+ const a = _.path ?? "/delivery", l = (r, t, o, n) => ({
2479
+ id: r,
2480
+ path: t === "" ? a : `${a}/${t}`,
2481
+ routes: [
2482
+ {
2483
+ path: t === "" ? a : `${a}/${t}`,
2484
+ name: o,
2485
+ meta: { help: t === "" ? "delivery.index" : `delivery.${t}` },
2486
+ component: n
2487
+ }
2488
+ ]
2489
+ });
2490
+ return [
2491
+ {
2492
+ ...l("delivery", "", "webx.delivery", () => import("./MethodsPage-DrrRpjVY.js")),
2493
+ types: {
2494
+ "wx-delivery-locality": { component: It, kind: "field" },
2495
+ "wx-delivery-localities": { component: At, kind: "field", wide: !0 },
2496
+ "wx-delivery-region": { component: qt, kind: "field", nested: !0 },
2497
+ "wx-delivery-country": { component: pt, kind: "field" },
2498
+ "wx-delivery-schedule": { component: Gt, kind: "field", wide: !0 },
2499
+ "wx-delivery-point-kind": { component: Ft, kind: "field" },
2500
+ // The tab «Delivery» of the order's card, patched onto `orders.show` by the server.
2501
+ "wx-delivery-order": { component: Ka, kind: "display" }
2502
+ }
2503
+ },
2504
+ l("delivery-points", "points", "webx.delivery.points", () => import("./PointsPage-C16GT-YH.js")),
2505
+ l(
2506
+ "delivery-carriers",
2507
+ "carriers",
2508
+ "webx.delivery.carriers",
2509
+ () => import("./CarriersPage-DlaIE-2K.js")
2510
+ ),
2511
+ l(
2512
+ "delivery-geography",
2513
+ "geography",
2514
+ "webx.delivery.geography",
2515
+ () => import("./GeographyPage-T3vwSyud.js")
2516
+ ),
2517
+ l(
2518
+ "delivery-popular",
2519
+ "popular",
2520
+ "webx.delivery.popular",
2521
+ () => import("./PopularPage-BdE59dwB.js")
2522
+ ),
2523
+ l(
2524
+ "delivery-bindings",
2525
+ "bindings",
2526
+ "webx.delivery.bindings",
2527
+ () => import("./BindingsPage-DiVZys4B.js")
2528
+ )
2529
+ ];
2530
+ }
2531
+ export {
2532
+ kt as L,
2533
+ re as _,
2534
+ Le as a,
2535
+ yt as b,
2536
+ oe as c,
2537
+ Ya as d,
2538
+ ne as u
2539
+ };
2540
+ //# sourceMappingURL=index-CuhwaAcG.js.map