@bluechaine/print-designer 0.1.1 → 0.1.2

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.
@@ -1,7 +1,25 @@
1
1
  (function(global, factory) {
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue-demi"), require("vue-plugin-hiprint"), require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue-demi", "vue-plugin-hiprint", "vue"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.Vue3PrintDesigner = {}, global.VueDemi, global.vuePluginHiprint, global.Vue));
3
- })(this, function(exports2, vueDemi, vuePluginHiprint, Vue) {
3
+ })(this, function(exports2, vueDemi, VuePluginHiprint, Vue) {
4
4
  "use strict";
5
+ var _a, _b, _c, _d;
6
+ function _interopNamespaceDefault(e) {
7
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
+ if (e) {
9
+ for (const k in e) {
10
+ if (k !== "default") {
11
+ const d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: () => e[k]
15
+ });
16
+ }
17
+ }
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+ const VuePluginHiprint__namespace = /* @__PURE__ */ _interopNamespaceDefault(VuePluginHiprint);
5
23
  /**
6
24
  * (c) Iconify
7
25
  *
@@ -2667,10 +2685,10 @@
2667
2685
  return !!value && !value.trim().startsWith("<");
2668
2686
  }
2669
2687
  function elementTypeKey(item) {
2670
- var _a, _b;
2671
- const type = String(((_a = item == null ? void 0 : item.printElementType) == null ? void 0 : _a.type) || "");
2688
+ var _a2, _b2;
2689
+ const type = String(((_a2 = item == null ? void 0 : item.printElementType) == null ? void 0 : _a2.type) || "");
2672
2690
  if (type && ELEMENT_ICON_NAMES[type]) return type;
2673
- const tid = String(((_b = item == null ? void 0 : item.printElementType) == null ? void 0 : _b.tid) || "");
2691
+ const tid = String(((_b2 = item == null ? void 0 : item.printElementType) == null ? void 0 : _b2.tid) || "");
2674
2692
  const short = tid.split(".").pop() || type;
2675
2693
  return short && ELEMENT_ICON_NAMES[short] ? short : "text";
2676
2694
  }
@@ -2799,12 +2817,12 @@
2799
2817
  return (match == null ? void 0 : match.type) || "自定义";
2800
2818
  }
2801
2819
  function resolveTemplate(tplId) {
2802
- var _a, _b;
2820
+ var _a2;
2803
2821
  const cached = templateRegistry.get(tplId);
2804
2822
  if (cached) return cached;
2805
2823
  try {
2806
- const lib = ((_a = vuePluginHiprint.hiprint) == null ? void 0 : _a.instance) ?? vuePluginHiprint.hiprint;
2807
- return ((_b = lib == null ? void 0 : lib.getPrintTemplateById) == null ? void 0 : _b.call(lib, tplId)) ?? null;
2824
+ const lib = (hiprint == null ? void 0 : hiprint.instance) ?? hiprint;
2825
+ return ((_a2 = lib == null ? void 0 : lib.getPrintTemplateById) == null ? void 0 : _a2.call(lib, tplId)) ?? null;
2808
2826
  } catch {
2809
2827
  return null;
2810
2828
  }
@@ -2894,11 +2912,11 @@
2894
2912
  return wrapper;
2895
2913
  };
2896
2914
  PaperListOptionItem.prototype.getValue = function() {
2897
- var _a, _b, _c;
2915
+ var _a2, _b2, _c2;
2898
2916
  return {
2899
- type: String(((_a = this.typeSelect) == null ? void 0 : _a.val()) || "自定义"),
2900
- width: Number((_b = this.widthInput) == null ? void 0 : _b.val()) || 0,
2901
- height: Number((_c = this.heightInput) == null ? void 0 : _c.val()) || 0
2917
+ type: String(((_a2 = this.typeSelect) == null ? void 0 : _a2.val()) || "自定义"),
2918
+ width: Number((_b2 = this.widthInput) == null ? void 0 : _b2.val()) || 0,
2919
+ height: Number((_c2 = this.heightInput) == null ? void 0 : _c2.val()) || 0
2902
2920
  };
2903
2921
  };
2904
2922
  PaperListOptionItem.prototype.setValue = function(value) {
@@ -2916,8 +2934,8 @@
2916
2934
  this.heightInput.val(value.height || "");
2917
2935
  };
2918
2936
  PaperListOptionItem.prototype.destroy = function() {
2919
- var _a, _b;
2920
- (_b = (_a = this.target) == null ? void 0 : _a.remove) == null ? void 0 : _b.call(_a);
2937
+ var _a2, _b2;
2938
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
2921
2939
  };
2922
2940
  function OrientOptionItem() {
2923
2941
  this.name = "orient";
@@ -2945,18 +2963,18 @@
2945
2963
  return this.target;
2946
2964
  };
2947
2965
  OrientOptionItem.prototype.getValue = function() {
2948
- var _a, _b, _c, _d;
2949
- const val = (_d = (_c = (_b = (_a = this.target) == null ? void 0 : _a.find) == null ? void 0 : _b.call(_a, "select")) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c);
2966
+ var _a2, _b2, _c2, _d2;
2967
+ const val = (_d2 = (_c2 = (_b2 = (_a2 = this.target) == null ? void 0 : _a2.find) == null ? void 0 : _b2.call(_a2, "select")) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2);
2950
2968
  if (val === "" || val == null) return void 0;
2951
2969
  return parseFloat(String(val));
2952
2970
  };
2953
2971
  OrientOptionItem.prototype.setValue = function(value) {
2954
- var _a, _b, _c, _d;
2955
- (_d = (_c = (_b = (_a = this.target) == null ? void 0 : _a.find) == null ? void 0 : _b.call(_a, "select")) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c, value ?? "");
2972
+ var _a2, _b2, _c2, _d2;
2973
+ (_d2 = (_c2 = (_b2 = (_a2 = this.target) == null ? void 0 : _a2.find) == null ? void 0 : _b2.call(_a2, "select")) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value ?? "");
2956
2974
  };
2957
2975
  OrientOptionItem.prototype.destroy = function() {
2958
- var _a, _b;
2959
- (_b = (_a = this.target) == null ? void 0 : _a.remove) == null ? void 0 : _b.call(_a);
2976
+ var _a2, _b2;
2977
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
2960
2978
  };
2961
2979
  const WATERMARK_TIME_FORMATS = [
2962
2980
  "YYYY-MM-DD HH:mm:ss",
@@ -3050,10 +3068,10 @@
3050
3068
  return this.target;
3051
3069
  };
3052
3070
  WatermarkOptionItem.prototype.getValue = function() {
3053
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
3054
- const format = (_b = (_a = this.format) == null ? void 0 : _a.val) == null ? void 0 : _b.call(_a);
3071
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
3072
+ const format = (_b2 = (_a2 = this.format) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2);
3055
3073
  return {
3056
- content: ((_d = (_c = this.content) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c)) || "",
3074
+ content: ((_d2 = (_c2 = this.content) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2)) || "",
3057
3075
  fillStyle: ((_f = (_e = this.fillStyle) == null ? void 0 : _e.val) == null ? void 0 : _f.call(_e)) || "rgba(184, 184, 184, 0.3)",
3058
3076
  fontSize: `${parseInt(String(((_h = (_g = this.fontSize) == null ? void 0 : _g.val) == null ? void 0 : _h.call(_g)) || "14"), 10)}px`,
3059
3077
  rotate: parseInt(String(((_j = (_i = this.rotate) == null ? void 0 : _i.val) == null ? void 0 : _j.call(_i)) || "25"), 10),
@@ -3064,10 +3082,10 @@
3064
3082
  };
3065
3083
  };
3066
3084
  WatermarkOptionItem.prototype.setValue = function(value) {
3067
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
3085
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
3068
3086
  if (!value) value = {};
3069
- (_b = (_a = this.content) == null ? void 0 : _a.val) == null ? void 0 : _b.call(_a, value.content || "");
3070
- (_d = (_c = this.fillStyle) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c, value.fillStyle || "rgba(184, 184, 184, 0.3)");
3087
+ (_b2 = (_a2 = this.content) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2, value.content || "");
3088
+ (_d2 = (_c2 = this.fillStyle) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value.fillStyle || "rgba(184, 184, 184, 0.3)");
3071
3089
  try {
3072
3090
  (_f = (_e = this.fillStyle) == null ? void 0 : _e.minicolors) == null ? void 0 : _f.call(_e, {
3073
3091
  format: "rgb",
@@ -3085,8 +3103,8 @@
3085
3103
  (_r = (_q = this.format) == null ? void 0 : _q.val) == null ? void 0 : _r.call(_q, value.format || "YYYY-MM-DD HH:mm");
3086
3104
  };
3087
3105
  WatermarkOptionItem.prototype.destroy = function() {
3088
- var _a, _b;
3089
- (_b = (_a = this.target) == null ? void 0 : _a.remove) == null ? void 0 : _b.call(_a);
3106
+ var _a2, _b2;
3107
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
3090
3108
  };
3091
3109
  function PanelBackgroundColorOptionItem() {
3092
3110
  this.name = "backgroundColor";
@@ -3105,21 +3123,21 @@
3105
3123
  return this.target;
3106
3124
  };
3107
3125
  PanelBackgroundColorOptionItem.prototype.getValue = function() {
3108
- var _a, _b;
3109
- const val = (_b = (_a = this.input) == null ? void 0 : _a.val) == null ? void 0 : _b.call(_a);
3126
+ var _a2, _b2;
3127
+ const val = (_b2 = (_a2 = this.input) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2);
3110
3128
  return val ? String(val) : void 0;
3111
3129
  };
3112
3130
  PanelBackgroundColorOptionItem.prototype.setValue = function(value) {
3113
- var _a, _b, _c, _d;
3131
+ var _a2, _b2, _c2, _d2;
3114
3132
  const color = value || "#ffffff";
3115
3133
  try {
3116
- (_b = (_a = this.input) == null ? void 0 : _a.minicolors) == null ? void 0 : _b.call(_a, {
3134
+ (_b2 = (_a2 = this.input) == null ? void 0 : _a2.minicolors) == null ? void 0 : _b2.call(_a2, {
3117
3135
  defaultValue: color,
3118
3136
  theme: "bootstrap"
3119
3137
  });
3120
3138
  } catch {
3121
3139
  }
3122
- (_d = (_c = this.input) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c, color);
3140
+ (_d2 = (_c2 = this.input) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, color);
3123
3141
  };
3124
3142
  PanelBackgroundColorOptionItem.prototype.css = function(target, value) {
3125
3143
  const $ = getJQuery();
@@ -3132,19 +3150,19 @@
3132
3150
  return null;
3133
3151
  };
3134
3152
  PanelBackgroundColorOptionItem.prototype.destroy = function() {
3135
- var _a, _b;
3136
- (_b = (_a = this.target) == null ? void 0 : _a.remove) == null ? void 0 : _b.call(_a);
3153
+ var _a2, _b2;
3154
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
3137
3155
  };
3138
3156
  function applyPanelBackgroundColor(panel, color) {
3139
- var _a, _b, _c, _d;
3157
+ var _a2, _b2, _c2, _d2;
3140
3158
  if (!panel) return;
3141
3159
  const value = color || "#ffffff";
3142
3160
  panel.backgroundColor = value;
3143
3161
  const $ = getJQuery();
3144
- const paper = ((_a = panel.designPaper) == null ? void 0 : _a.target) || ((_c = (_b = panel.target) == null ? void 0 : _b.find) == null ? void 0 : _c.call(_b, ".hiprint-printPaper")) || ($ && panel.target ? $(panel.target).find(".hiprint-printPaper") : null);
3162
+ const paper = ((_a2 = panel.designPaper) == null ? void 0 : _a2.target) || ((_c2 = (_b2 = panel.target) == null ? void 0 : _b2.find) == null ? void 0 : _c2.call(_b2, ".hiprint-printPaper")) || ($ && panel.target ? $(panel.target).find(".hiprint-printPaper") : null);
3145
3163
  if (paper == null ? void 0 : paper.css) {
3146
3164
  paper.css("background-color", value);
3147
- } else if ((paper == null ? void 0 : paper.length) && ((_d = paper[0]) == null ? void 0 : _d.style)) {
3165
+ } else if ((paper == null ? void 0 : paper.length) && ((_d2 = paper[0]) == null ? void 0 : _d2.style)) {
3148
3166
  paper[0].style.backgroundColor = value;
3149
3167
  }
3150
3168
  }
@@ -3216,33 +3234,33 @@
3216
3234
  return this.target;
3217
3235
  };
3218
3236
  PanelLayoutOptionItem.prototype.getValue = function() {
3219
- var _a, _b, _c, _d;
3237
+ var _a2, _b2, _c2, _d2;
3220
3238
  const num = (el) => {
3221
- var _a2;
3222
- return parseInt(String(((_a2 = el == null ? void 0 : el.val) == null ? void 0 : _a2.call(el)) || 0), 10) || 0;
3239
+ var _a3;
3240
+ return parseInt(String(((_a3 = el == null ? void 0 : el.val) == null ? void 0 : _a3.call(el)) || 0), 10) || 0;
3223
3241
  };
3224
3242
  return {
3225
- layoutType: ((_b = (_a = this.layoutType) == null ? void 0 : _a.val) == null ? void 0 : _b.call(_a)) || "column",
3243
+ layoutType: ((_b2 = (_a2 = this.layoutType) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2)) || "column",
3226
3244
  layoutRowGap: num(this.layoutRowGap),
3227
3245
  layoutColumnGap: num(this.layoutColumnGap),
3228
3246
  paperWidth: num(this.paperWidth),
3229
3247
  paperHeight: num(this.paperHeight),
3230
- paperStyle: ((_d = (_c = this.paperStyle) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c)) || ""
3248
+ paperStyle: ((_d2 = (_c2 = this.paperStyle) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2)) || ""
3231
3249
  };
3232
3250
  };
3233
3251
  PanelLayoutOptionItem.prototype.setValue = function(value) {
3234
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
3252
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l;
3235
3253
  if (!value) return;
3236
- (_b = (_a = this.layoutType) == null ? void 0 : _a.val) == null ? void 0 : _b.call(_a, value.layoutType || "column");
3237
- (_d = (_c = this.layoutRowGap) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c, value.layoutRowGap ?? "");
3254
+ (_b2 = (_a2 = this.layoutType) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2, value.layoutType || "column");
3255
+ (_d2 = (_c2 = this.layoutRowGap) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value.layoutRowGap ?? "");
3238
3256
  (_f = (_e = this.layoutColumnGap) == null ? void 0 : _e.val) == null ? void 0 : _f.call(_e, value.layoutColumnGap ?? "");
3239
3257
  (_h = (_g = this.paperWidth) == null ? void 0 : _g.val) == null ? void 0 : _h.call(_g, value.paperWidth ?? "");
3240
3258
  (_j = (_i = this.paperHeight) == null ? void 0 : _i.val) == null ? void 0 : _j.call(_i, value.paperHeight ?? "");
3241
3259
  (_l = (_k = this.paperStyle) == null ? void 0 : _k.val) == null ? void 0 : _l.call(_k, value.paperStyle ?? "");
3242
3260
  };
3243
3261
  PanelLayoutOptionItem.prototype.destroy = function() {
3244
- var _a, _b;
3245
- (_b = (_a = this.target) == null ? void 0 : _a.remove) == null ? void 0 : _b.call(_a);
3262
+ var _a2, _b2;
3263
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
3246
3264
  };
3247
3265
  function reorderPanelSettingOptions(options, panel, paperList) {
3248
3266
  const {
@@ -3261,11 +3279,11 @@
3261
3279
  };
3262
3280
  }
3263
3281
  function ensurePaperListSupportOptionsFirst() {
3264
- var _a, _b, _c, _d;
3282
+ var _a2, _b2, _c2;
3265
3283
  try {
3266
3284
  const cfg = window.HIPRINT_CONFIG;
3267
- const instanceOpts = (_c = (_b = (_a = vuePluginHiprint.hiprint) == null ? void 0 : _a.instance) == null ? void 0 : _b.panel) == null ? void 0 : _c.supportOptions;
3268
- const cfgOpts = (_d = cfg == null ? void 0 : cfg.panel) == null ? void 0 : _d.supportOptions;
3285
+ const instanceOpts = (_b2 = (_a2 = hiprint == null ? void 0 : hiprint.instance) == null ? void 0 : _a2.panel) == null ? void 0 : _b2.supportOptions;
3286
+ const cfgOpts = (_c2 = cfg == null ? void 0 : cfg.panel) == null ? void 0 : _c2.supportOptions;
3269
3287
  const opts = instanceOpts || cfgOpts;
3270
3288
  if (!Array.isArray(opts)) return;
3271
3289
  const idx = opts.findIndex((o) => o.name === "paperList");
@@ -3285,8 +3303,8 @@
3285
3303
  }
3286
3304
  }
3287
3305
  function patchPrintTemplatePaperList() {
3288
- var _a;
3289
- const proto = (_a = vuePluginHiprint.hiprint.PrintTemplate) == null ? void 0 : _a.prototype;
3306
+ var _a2;
3307
+ const proto = (_a2 = hiprint.PrintTemplate) == null ? void 0 : _a2.prototype;
3290
3308
  if (!proto || proto.__svpPaperListPatched) return;
3291
3309
  proto.setPaperList = function(list) {
3292
3310
  this._paperList = Array.isArray(list) && list.length ? list : defaultPaperList;
@@ -3297,13 +3315,13 @@
3297
3315
  proto.__svpPaperListPatched = true;
3298
3316
  }
3299
3317
  function patchPanelSettingTrigger(onPaperApplied) {
3300
- var _a;
3301
- const bus = (_a = window.hinnn) == null ? void 0 : _a.event;
3318
+ var _a2;
3319
+ const bus = (_a2 = window.hinnn) == null ? void 0 : _a2.event;
3302
3320
  if (!bus || bus.__svpPaperListTriggerPatch) return;
3303
3321
  const origTrigger = bus.trigger.bind(bus);
3304
3322
  bus.trigger = function(key, ...args) {
3305
- var _a2;
3306
- if (typeof key === "string" && key.startsWith("BuildCustomOptionSettingEventKey_") && ((_a2 = args[0]) == null ? void 0 : _a2.options)) {
3323
+ var _a3;
3324
+ if (typeof key === "string" && key.startsWith("BuildCustomOptionSettingEventKey_") && ((_a3 = args[0]) == null ? void 0 : _a3.options)) {
3307
3325
  const tplId = key.slice("BuildCustomOptionSettingEventKey_".length);
3308
3326
  const tpl = resolveTemplate(tplId);
3309
3327
  const panel = tpl == null ? void 0 : tpl.editingPanel;
@@ -3334,7 +3352,7 @@
3334
3352
  patchPrintTemplatePaperList();
3335
3353
  patchPanelSettingTrigger(onPaperApplied);
3336
3354
  try {
3337
- vuePluginHiprint.hiprint.setConfig({
3355
+ hiprint.setConfig({
3338
3356
  optionItems: [
3339
3357
  PaperListOptionItem,
3340
3358
  OrientOptionItem,
@@ -3511,13 +3529,13 @@
3511
3529
  }
3512
3530
  class SvpElementTypeProvider extends Provider {
3513
3531
  addElementTypes(context) {
3514
- var _a;
3515
- new vuePluginHiprint.defaultElementTypeProvider().addElementTypes(context);
3532
+ var _a2;
3533
+ new VuePluginHiprint.defaultElementTypeProvider().addElementTypes(context);
3516
3534
  if (typeof context.updateElementType === "function") {
3517
3535
  context.updateElementType(TABLE_TID, applyCustomTableType);
3518
3536
  return;
3519
3537
  }
3520
- const current = (_a = context.getElementType) == null ? void 0 : _a.call(context, TABLE_TID);
3538
+ const current = (_a2 = context.getElementType) == null ? void 0 : _a2.call(context, TABLE_TID);
3521
3539
  if (current) applyCustomTableType(current);
3522
3540
  }
3523
3541
  }
@@ -3529,13 +3547,18 @@
3529
3547
  if (!map) return [];
3530
3548
  return Array.isArray(map) ? map : [map];
3531
3549
  }
3550
+ const plugin = VuePluginHiprint__namespace;
3551
+ const hiprint = plugin.hiprint ?? ((_a = plugin.default) == null ? void 0 : _a.hiprint);
3552
+ const defaultElementTypeProvider = plugin.defaultElementTypeProvider ?? ((_b = plugin.default) == null ? void 0 : _b.defaultElementTypeProvider);
3553
+ const autoConnect = plugin.autoConnect ?? ((_c = plugin.default) == null ? void 0 : _c.autoConnect);
3554
+ const disAutoConnect = plugin.disAutoConnect ?? ((_d = plugin.default) == null ? void 0 : _d.disAutoConnect);
3532
3555
  let initialized = false;
3533
3556
  function initHiprint(options = {}) {
3534
- var _a;
3557
+ var _a2;
3535
3558
  const providers = ensureProviders(options.providers);
3536
3559
  if (!initialized) {
3537
3560
  try {
3538
- vuePluginHiprint.hiprint.init({ providers, ...options.config ?? {} });
3561
+ hiprint.init({ providers, ...options.config ?? {} });
3539
3562
  setupHiprintPaperList(
3540
3563
  options.paperList ?? DEFAULT_PAPER_LIST,
3541
3564
  options.onPaperApplied
@@ -3544,12 +3567,12 @@
3544
3567
  console.error("[vue3-print-designer] hiprint.init failed", e);
3545
3568
  }
3546
3569
  initialized = true;
3547
- } else if ((_a = options.providers) == null ? void 0 : _a.length) {
3570
+ } else if ((_a2 = options.providers) == null ? void 0 : _a2.length) {
3548
3571
  try {
3549
3572
  options.providers.forEach(
3550
3573
  (p) => {
3551
- var _a2, _b;
3552
- return (_b = (_a2 = vuePluginHiprint.hiprint.PrintElementTypeManager) == null ? void 0 : _a2.build) == null ? void 0 : _b.call(_a2, [p]);
3574
+ var _a3, _b2;
3575
+ return (_b2 = (_a3 = hiprint.PrintElementTypeManager) == null ? void 0 : _a3.build) == null ? void 0 : _b2.call(_a3, [p]);
3553
3576
  }
3554
3577
  );
3555
3578
  } catch (e) {
@@ -3558,11 +3581,11 @@
3558
3581
  }
3559
3582
  if (options.autoConnect === false) {
3560
3583
  try {
3561
- vuePluginHiprint.disAutoConnect();
3584
+ disAutoConnect();
3562
3585
  } catch (_) {
3563
3586
  }
3564
3587
  }
3565
- return vuePluginHiprint.hiprint;
3588
+ return hiprint;
3566
3589
  }
3567
3590
  function buildByHtml(selectors) {
3568
3591
  if (typeof window === "undefined") return;
@@ -3576,13 +3599,474 @@
3576
3599
  const $els = $(sel);
3577
3600
  if ($els.length) {
3578
3601
  try {
3579
- vuePluginHiprint.hiprint.PrintElementTypeManager.buildByHtml($els);
3602
+ hiprint.PrintElementTypeManager.buildByHtml($els);
3580
3603
  } catch (e) {
3581
3604
  console.warn("[vue3-print-designer] buildByHtml failed", sel, e);
3582
3605
  }
3583
3606
  }
3584
3607
  });
3585
3608
  }
3609
+ function normalizePrinterList(raw) {
3610
+ if (!Array.isArray(raw)) return [];
3611
+ return raw.map((item) => {
3612
+ if (typeof item === "string") {
3613
+ return { name: item, displayName: item };
3614
+ }
3615
+ if (!item || typeof item !== "object") return null;
3616
+ const record = item;
3617
+ const name = String(record.name ?? record.Name ?? "");
3618
+ if (!name) return null;
3619
+ return {
3620
+ ...record,
3621
+ name,
3622
+ displayName: String(record.displayName ?? record.DisplayName ?? name),
3623
+ isDefault: Boolean(record.isDefault ?? record.IsDefault ?? record.default)
3624
+ };
3625
+ }).filter((item) => item != null);
3626
+ }
3627
+ function normalizeClientList(raw) {
3628
+ if (!Array.isArray(raw)) return [];
3629
+ return raw.filter((item) => item && typeof item === "object");
3630
+ }
3631
+ function buildPrint2Payload(options) {
3632
+ if (!options) {
3633
+ return { printer: "", title: "print" };
3634
+ }
3635
+ const {
3636
+ printer,
3637
+ title,
3638
+ client,
3639
+ printByFragments,
3640
+ generateHTMLInterval,
3641
+ fragmentSize,
3642
+ sendInterval,
3643
+ ...rest
3644
+ } = options;
3645
+ return {
3646
+ printer: printer ?? "",
3647
+ title: title ?? "print",
3648
+ ...client != null ? { client } : {},
3649
+ ...printByFragments != null ? { printByFragments } : {},
3650
+ ...generateHTMLInterval != null ? { generateHTMLInterval } : {},
3651
+ ...fragmentSize != null ? { fragmentSize } : {},
3652
+ ...sendInterval != null ? { sendInterval } : {},
3653
+ ...rest
3654
+ };
3655
+ }
3656
+ function readSocketConnected() {
3657
+ try {
3658
+ const ws = hiprint.hiwebSocket;
3659
+ if (!ws) return false;
3660
+ if (ws.opened === true || ws.connected === true) return true;
3661
+ if (typeof ws.isConnected === "function" && ws.isConnected()) return true;
3662
+ return false;
3663
+ } catch {
3664
+ return false;
3665
+ }
3666
+ }
3667
+ const _PrintClient = class _PrintClient {
3668
+ constructor() {
3669
+ this.status = { connected: false };
3670
+ this.initConfig = {};
3671
+ this.connectPromise = null;
3672
+ this.connectionCallbacks = /* @__PURE__ */ new Set();
3673
+ this.printSuccessCallbacks = /* @__PURE__ */ new Set();
3674
+ this.printErrorCallbacks = /* @__PURE__ */ new Set();
3675
+ }
3676
+ static getInstance() {
3677
+ if (!_PrintClient.instance) _PrintClient.instance = new _PrintClient();
3678
+ return _PrintClient.instance;
3679
+ }
3680
+ connect(options = {}) {
3681
+ if (typeof window === "undefined") {
3682
+ const status = { connected: false, message: "PrintClient requires a browser environment." };
3683
+ this.updateStatus(status);
3684
+ return Promise.resolve(status);
3685
+ }
3686
+ if (this.getStatus().connected) {
3687
+ return Promise.resolve(this.getStatus());
3688
+ }
3689
+ if (this.connectPromise) return this.connectPromise;
3690
+ this.connectPromise = new Promise((resolve) => {
3691
+ var _a2;
3692
+ const timeoutMs = options.timeout ?? 1e4;
3693
+ let settled = false;
3694
+ const finish = (status) => {
3695
+ if (settled) return;
3696
+ settled = true;
3697
+ window.clearTimeout(timer);
3698
+ this.connectPromise = null;
3699
+ this.updateStatus(status);
3700
+ resolve(status);
3701
+ };
3702
+ const timer = window.setTimeout(() => {
3703
+ finish({
3704
+ connected: false,
3705
+ message: "Connection timeout. Is electron-hiprint running?"
3706
+ });
3707
+ }, timeoutMs);
3708
+ const config = { ...this.initConfig };
3709
+ if (options.host) config.host = options.host;
3710
+ if (options.token) config.token = options.token;
3711
+ this.initConfig = config;
3712
+ initHiprint({
3713
+ providers: ensureProviders(),
3714
+ autoConnect: false,
3715
+ config
3716
+ });
3717
+ try {
3718
+ if (options.host && typeof ((_a2 = hiprint.hiwebSocket) == null ? void 0 : _a2.setHost) === "function") {
3719
+ hiprint.hiwebSocket.setHost(options.host, options.token);
3720
+ }
3721
+ } catch (e) {
3722
+ console.warn("[print-designer] hiwebSocket.setHost failed", e);
3723
+ }
3724
+ try {
3725
+ autoConnect((status, msg) => {
3726
+ const message = typeof msg === "string" ? msg : msg != null ? String(msg) : status ? void 0 : "Failed to connect to print client.";
3727
+ finish({ connected: !!status, message });
3728
+ });
3729
+ } catch (e) {
3730
+ finish({
3731
+ connected: false,
3732
+ message: e instanceof Error ? e.message : String(e)
3733
+ });
3734
+ }
3735
+ });
3736
+ return this.connectPromise;
3737
+ }
3738
+ disconnect() {
3739
+ try {
3740
+ disAutoConnect();
3741
+ } catch {
3742
+ }
3743
+ this.connectPromise = null;
3744
+ this.updateStatus({ connected: false, message: "Disconnected." });
3745
+ }
3746
+ getStatus() {
3747
+ const socketConnected = readSocketConnected();
3748
+ if (socketConnected && !this.status.connected) {
3749
+ this.status = { connected: true };
3750
+ }
3751
+ if (!socketConnected && this.status.connected) {
3752
+ this.status = { connected: false, message: this.status.message ?? "Disconnected." };
3753
+ }
3754
+ return { ...this.status };
3755
+ }
3756
+ getPrinterList() {
3757
+ var _a2, _b2;
3758
+ try {
3759
+ const list = (_b2 = (_a2 = hiprint.hiwebSocket) == null ? void 0 : _a2.getPrinterList) == null ? void 0 : _b2.call(_a2);
3760
+ return normalizePrinterList(list);
3761
+ } catch {
3762
+ return [];
3763
+ }
3764
+ }
3765
+ getClients() {
3766
+ try {
3767
+ const ws = hiprint.hiwebSocket;
3768
+ if (!ws) return [];
3769
+ if (Array.isArray(ws.clients)) return normalizeClientList(ws.clients);
3770
+ if (typeof ws.getClients === "function") {
3771
+ return normalizeClientList(ws.getClients());
3772
+ }
3773
+ return [];
3774
+ } catch {
3775
+ return [];
3776
+ }
3777
+ }
3778
+ async printByTemplate(template, printData, options) {
3779
+ initHiprint({
3780
+ providers: ensureProviders(),
3781
+ autoConnect: false,
3782
+ config: this.initConfig
3783
+ });
3784
+ const instance = new hiprint.PrintTemplate({ template });
3785
+ return this.printByInstance(instance, printData, options);
3786
+ }
3787
+ async printByInstance(printTemplate, printData, options) {
3788
+ if (!this.getStatus().connected) {
3789
+ throw new Error("[print-designer] Print client is not connected. Call connect() first.");
3790
+ }
3791
+ if (typeof (printTemplate == null ? void 0 : printTemplate.print2) !== "function") {
3792
+ throw new Error("[print-designer] print2 is not available on the template instance.");
3793
+ }
3794
+ return new Promise((resolve, reject) => {
3795
+ var _a2, _b2;
3796
+ const onSuccess = (data2) => {
3797
+ cleanup();
3798
+ this.notifyPrintSuccess(data2);
3799
+ resolve();
3800
+ };
3801
+ const onError = (data2) => {
3802
+ cleanup();
3803
+ this.notifyPrintError(data2);
3804
+ reject(data2 instanceof Error ? data2 : new Error(String(data2 ?? "Print failed")));
3805
+ };
3806
+ const cleanup = () => {
3807
+ var _a3, _b3;
3808
+ try {
3809
+ (_a3 = printTemplate.off) == null ? void 0 : _a3.call(printTemplate, "printSuccess", onSuccess);
3810
+ } catch {
3811
+ }
3812
+ try {
3813
+ (_b3 = printTemplate.off) == null ? void 0 : _b3.call(printTemplate, "printError", onError);
3814
+ } catch {
3815
+ }
3816
+ };
3817
+ try {
3818
+ (_a2 = printTemplate.on) == null ? void 0 : _a2.call(printTemplate, "printSuccess", onSuccess);
3819
+ (_b2 = printTemplate.on) == null ? void 0 : _b2.call(printTemplate, "printError", onError);
3820
+ printTemplate.print2(printData, buildPrint2Payload(options));
3821
+ } catch (e) {
3822
+ cleanup();
3823
+ reject(e);
3824
+ }
3825
+ });
3826
+ }
3827
+ onConnectionChange(callback2) {
3828
+ this.connectionCallbacks.add(callback2);
3829
+ return () => {
3830
+ this.connectionCallbacks.delete(callback2);
3831
+ };
3832
+ }
3833
+ onPrintSuccess(callback2) {
3834
+ this.printSuccessCallbacks.add(callback2);
3835
+ return () => {
3836
+ this.printSuccessCallbacks.delete(callback2);
3837
+ };
3838
+ }
3839
+ onPrintError(callback2) {
3840
+ this.printErrorCallbacks.add(callback2);
3841
+ return () => {
3842
+ this.printErrorCallbacks.delete(callback2);
3843
+ };
3844
+ }
3845
+ updateStatus(status) {
3846
+ this.status = status;
3847
+ this.notifyConnectionChange(status);
3848
+ }
3849
+ notifyConnectionChange(status) {
3850
+ this.connectionCallbacks.forEach((cb) => {
3851
+ try {
3852
+ cb(status);
3853
+ } catch (e) {
3854
+ console.error("[print-designer] connection listener failed", e);
3855
+ }
3856
+ });
3857
+ }
3858
+ notifyPrintSuccess(data2) {
3859
+ this.printSuccessCallbacks.forEach((cb) => {
3860
+ try {
3861
+ cb(data2);
3862
+ } catch (e) {
3863
+ console.error("[print-designer] printSuccess listener failed", e);
3864
+ }
3865
+ });
3866
+ }
3867
+ notifyPrintError(data2) {
3868
+ this.printErrorCallbacks.forEach((cb) => {
3869
+ try {
3870
+ cb(data2);
3871
+ } catch (e) {
3872
+ console.error("[print-designer] printError listener failed", e);
3873
+ }
3874
+ });
3875
+ }
3876
+ };
3877
+ _PrintClient.instance = null;
3878
+ let PrintClient = _PrintClient;
3879
+ function getPrintClient() {
3880
+ return PrintClient.getInstance();
3881
+ }
3882
+ function resolvePreviewHtml(value) {
3883
+ if (value == null || value === false) return "";
3884
+ if (typeof value === "string") return value;
3885
+ const any = value;
3886
+ if (typeof any.html === "function") {
3887
+ try {
3888
+ const html = any.html();
3889
+ if (typeof html === "string") return html;
3890
+ } catch {
3891
+ }
3892
+ }
3893
+ if (Array.isArray(value)) {
3894
+ return value.map((item) => resolvePreviewHtml(item)).join("");
3895
+ }
3896
+ if (typeof any.length === "number" && any.length > 0 && any[0] != null) {
3897
+ return resolvePreviewHtml(any[0]);
3898
+ }
3899
+ if (any.target != null) {
3900
+ return resolvePreviewHtml(any.target);
3901
+ }
3902
+ return "";
3903
+ }
3904
+ function collectHostStyles() {
3905
+ if (typeof document === "undefined") return "";
3906
+ const parts = [];
3907
+ document.querySelectorAll('link[rel="stylesheet"]').forEach((el) => {
3908
+ const href = el.getAttribute("href");
3909
+ if (!href) return;
3910
+ const media = el.getAttribute("media");
3911
+ const mediaAttr = media ? ` media="${media}"` : "";
3912
+ parts.push(`<link rel="stylesheet" href="${href}"${mediaAttr}>`);
3913
+ if (media && /print/i.test(media) && href.includes("print-lock.css")) {
3914
+ parts.push(`<link rel="stylesheet" href="${href}">`);
3915
+ }
3916
+ });
3917
+ document.querySelectorAll("style").forEach((el) => {
3918
+ parts.push(`<style>${el.textContent ?? ""}</style>`);
3919
+ });
3920
+ return parts.join("\n");
3921
+ }
3922
+ function buildIframeDocument(args) {
3923
+ const handlerStyles = args.styleHandler ? args.styleHandler() : "";
3924
+ const hostStyles = args.importCss ? collectHostStyles() : "";
3925
+ return `<!DOCTYPE html>
3926
+ <html>
3927
+ <head>
3928
+ <meta charset="UTF-8">
3929
+ <title>${args.title}</title>
3930
+ ${hostStyles}
3931
+ ${handlerStyles}
3932
+ </head>
3933
+ <body>${args.html}</body>
3934
+ </html>`;
3935
+ }
3936
+ function printIframe(args) {
3937
+ if (typeof document === "undefined" || typeof window === "undefined") {
3938
+ return Promise.resolve();
3939
+ }
3940
+ const previous = document.getElementById("svp_batch_print_iframe");
3941
+ if (previous == null ? void 0 : previous.parentNode) previous.parentNode.removeChild(previous);
3942
+ const iframe = document.createElement("iframe");
3943
+ iframe.id = "svp_batch_print_iframe";
3944
+ iframe.setAttribute(
3945
+ "style",
3946
+ "visibility: hidden; height: 0; width: 0; position: absolute; border: 0;"
3947
+ );
3948
+ document.body.appendChild(iframe);
3949
+ const cleanup = () => {
3950
+ try {
3951
+ if (iframe.parentNode) iframe.parentNode.removeChild(iframe);
3952
+ } catch {
3953
+ }
3954
+ };
3955
+ return new Promise((resolve) => {
3956
+ let triggered = false;
3957
+ const trigger = () => {
3958
+ if (triggered) return;
3959
+ triggered = true;
3960
+ try {
3961
+ const win = iframe.contentWindow;
3962
+ if (!win) {
3963
+ cleanup();
3964
+ resolve();
3965
+ return;
3966
+ }
3967
+ const finish = () => {
3968
+ var _a2;
3969
+ (_a2 = args.callback) == null ? void 0 : _a2.call(args);
3970
+ setTimeout(() => {
3971
+ cleanup();
3972
+ resolve();
3973
+ }, 500);
3974
+ };
3975
+ const onAfterPrint = () => {
3976
+ win.removeEventListener("afterprint", onAfterPrint);
3977
+ finish();
3978
+ };
3979
+ win.addEventListener("afterprint", onAfterPrint);
3980
+ try {
3981
+ win.focus();
3982
+ win.print();
3983
+ } catch (e) {
3984
+ console.error("[batch-print] window.print failed", e);
3985
+ finish();
3986
+ }
3987
+ setTimeout(finish, 6e4);
3988
+ } catch (e) {
3989
+ console.error("[batch-print] trigger failed", e);
3990
+ cleanup();
3991
+ resolve();
3992
+ }
3993
+ };
3994
+ iframe.onload = () => {
3995
+ waitForImages(iframe.contentDocument, trigger);
3996
+ };
3997
+ setTimeout(() => {
3998
+ if (!triggered) trigger();
3999
+ }, args.timeout);
4000
+ const doc = iframe.contentDocument;
4001
+ const docString = buildIframeDocument(args);
4002
+ if (doc) {
4003
+ doc.open();
4004
+ doc.write(docString);
4005
+ doc.close();
4006
+ } else {
4007
+ iframe.srcdoc = docString;
4008
+ }
4009
+ });
4010
+ }
4011
+ function waitForImages(doc, done, attempt = 0) {
4012
+ if (!doc) {
4013
+ done();
4014
+ return;
4015
+ }
4016
+ const imgs = doc.getElementsByTagName("img");
4017
+ let ready = true;
4018
+ for (let i = 0; i < imgs.length; i++) {
4019
+ const img = imgs[i];
4020
+ if (!img.src || img.src.indexOf("base64") >= 0) continue;
4021
+ if (img.complete && (img.naturalWidth ?? 1) > 0) continue;
4022
+ ready = false;
4023
+ break;
4024
+ }
4025
+ if (ready || attempt >= 10) {
4026
+ done();
4027
+ return;
4028
+ }
4029
+ setTimeout(() => waitForImages(doc, done, attempt + 1), 500);
4030
+ }
4031
+ function pageWrap(html, withBreak) {
4032
+ const breakStyle = withBreak ? ' style="page-break-after: always; break-after: page;"' : "";
4033
+ return `<div class="svp-batch-page"${breakStyle}>${html}</div>`;
4034
+ }
4035
+ async function batchPrint(printTemplate, printDataList, options = {}) {
4036
+ if (!printTemplate || typeof printTemplate.getHtml !== "function") {
4037
+ throw new Error("[batch-print] printTemplate.getHtml is required.");
4038
+ }
4039
+ const list = Array.isArray(printDataList) ? printDataList : [printDataList];
4040
+ if (!list.length) {
4041
+ throw new Error("[batch-print] printDataList is empty.");
4042
+ }
4043
+ const copies = Math.max(1, Math.floor(options.copies ?? 1));
4044
+ const pageBreak = options.pageBreak !== false;
4045
+ const title = options.title ?? "print";
4046
+ const expanded = [];
4047
+ for (const item of list) {
4048
+ for (let i = 0; i < copies; i++) expanded.push(item);
4049
+ }
4050
+ const fragments = [];
4051
+ for (let i = 0; i < expanded.length; i++) {
4052
+ const raw = printTemplate.getHtml(expanded[i]);
4053
+ const html = resolvePreviewHtml(raw);
4054
+ if (!html) continue;
4055
+ const isLast = i === expanded.length - 1;
4056
+ fragments.push(pageWrap(html, pageBreak && !isLast));
4057
+ }
4058
+ if (!fragments.length) {
4059
+ throw new Error("[batch-print] No HTML produced from print data.");
4060
+ }
4061
+ await printIframe({
4062
+ html: fragments.join("\n"),
4063
+ title,
4064
+ styleHandler: options.styleHandler,
4065
+ importCss: options.importCss !== false,
4066
+ callback: options.callback,
4067
+ timeout: Math.max(500, options.timeout ?? 1500)
4068
+ });
4069
+ }
3586
4070
  class PluginManager {
3587
4071
  constructor() {
3588
4072
  this.hooks = /* @__PURE__ */ new Map();
@@ -3593,12 +4077,12 @@
3593
4077
  this.plugins = [];
3594
4078
  plugins.forEach((p) => this.register(p));
3595
4079
  }
3596
- register(plugin) {
3597
- var _a;
3598
- if (!plugin || !Array.isArray(plugin.hooks)) return;
3599
- this.plugins.push(plugin);
3600
- (_a = plugin.init) == null ? void 0 : _a.call(plugin, plugin.config ?? {});
3601
- plugin.hooks.forEach((h) => {
4080
+ register(plugin2) {
4081
+ var _a2;
4082
+ if (!plugin2 || !Array.isArray(plugin2.hooks)) return;
4083
+ this.plugins.push(plugin2);
4084
+ (_a2 = plugin2.init) == null ? void 0 : _a2.call(plugin2, plugin2.config ?? {});
4085
+ plugin2.hooks.forEach((h) => {
3602
4086
  const arr = this.hooks.get(h.hook) ?? [];
3603
4087
  arr.push(h);
3604
4088
  arr.sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));
@@ -3609,8 +4093,8 @@
3609
4093
  return this.plugins.slice();
3610
4094
  }
3611
4095
  has(hook) {
3612
- var _a;
3613
- return (((_a = this.hooks.get(hook)) == null ? void 0 : _a.length) ?? 0) > 0;
4096
+ var _a2;
4097
+ return (((_a2 = this.hooks.get(hook)) == null ? void 0 : _a2.length) ?? 0) > 0;
3614
4098
  }
3615
4099
  /** Run all callbacks sequentially. Returns the array of results. */
3616
4100
  async run(hook, ...args) {
@@ -3735,9 +4219,9 @@
3735
4219
  this.onChanged = onChanged;
3736
4220
  }
3737
4221
  applySnapshot(tpl, json, panelIndex) {
3738
- var _a, _b, _c;
4222
+ var _a2, _b2, _c2;
3739
4223
  if (!(tpl == null ? void 0 : tpl.update) || json == null) return;
3740
- const index2 = panelIndex ?? ((_a = tpl.editingPanel) == null ? void 0 : _a.index) ?? ((_c = (_b = tpl.printPanels) == null ? void 0 : _b[0]) == null ? void 0 : _c.index) ?? 0;
4224
+ const index2 = panelIndex ?? ((_a2 = tpl.editingPanel) == null ? void 0 : _a2.index) ?? ((_c2 = (_b2 = tpl.printPanels) == null ? void 0 : _b2[0]) == null ? void 0 : _c2.index) ?? 0;
3741
4225
  tpl.update(json, index2);
3742
4226
  }
3743
4227
  refreshFromTemplate() {
@@ -3792,9 +4276,9 @@
3792
4276
  this.finishChange();
3793
4277
  }
3794
4278
  jump(index2) {
3795
- var _a;
4279
+ var _a2;
3796
4280
  const tpl = this.getTpl();
3797
- if (!(tpl == null ? void 0 : tpl.history) || !((_a = tpl.historyList) == null ? void 0 : _a[index2])) return;
4281
+ if (!(tpl == null ? void 0 : tpl.history) || !((_a2 = tpl.historyList) == null ? void 0 : _a2[index2])) return;
3798
4282
  tpl.historyPos = index2;
3799
4283
  const entry = tpl.historyList[index2];
3800
4284
  this.applySnapshot(tpl, entry == null ? void 0 : entry.json);
@@ -3827,9 +4311,9 @@
3827
4311
  this.finishChange();
3828
4312
  }
3829
4313
  finishChange() {
3830
- var _a;
4314
+ var _a2;
3831
4315
  this.refreshFromTemplate();
3832
- (_a = this.onChanged) == null ? void 0 : _a.call(this);
4316
+ (_a2 = this.onChanged) == null ? void 0 : _a2.call(this);
3833
4317
  }
3834
4318
  }
3835
4319
  function normalize(e) {
@@ -3860,8 +4344,8 @@
3860
4344
  mount() {
3861
4345
  if (typeof window === "undefined" || this.handler) return;
3862
4346
  this.handler = (e) => {
3863
- var _a, _b;
3864
- if (((_b = (_a = this.options).beforeDispatch) == null ? void 0 : _b.call(_a, e)) === false) return;
4347
+ var _a2, _b2;
4348
+ if (((_b2 = (_a2 = this.options).beforeDispatch) == null ? void 0 : _b2.call(_a2, e)) === false) return;
3865
4349
  const t = e.target;
3866
4350
  if (t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable)) {
3867
4351
  const combo2 = normalize(e);
@@ -4011,7 +4495,7 @@
4011
4495
  });
4012
4496
  ta.addEventListener("scroll", syncScroll);
4013
4497
  modal.addEventListener("click", (e) => {
4014
- var _a;
4498
+ var _a2;
4015
4499
  const act = e.target.dataset.act;
4016
4500
  if (act === "cancel") close(null);
4017
4501
  else if (act === "clear") {
@@ -4020,7 +4504,7 @@
4020
4504
  syncLines();
4021
4505
  ta.focus();
4022
4506
  } else if (act === "copy") {
4023
- (_a = navigator.clipboard) == null ? void 0 : _a.writeText(ta.value).catch(() => {
4507
+ (_a2 = navigator.clipboard) == null ? void 0 : _a2.writeText(ta.value).catch(() => {
4024
4508
  ta.focus();
4025
4509
  ta.select();
4026
4510
  try {
@@ -4214,7 +4698,19 @@
4214
4698
  printDataAddRow: "添加一行",
4215
4699
  printDataDeleteRow: "删除",
4216
4700
  printDataFieldKey: "字段",
4217
- paper: "纸张"
4701
+ paper: "纸张",
4702
+ browserPrint: "浏览器打印",
4703
+ silentPrint: "静默打印",
4704
+ batchPrint: "批量打印",
4705
+ batchPrinting: "正在准备…",
4706
+ batchCopies: "每条份数",
4707
+ batchHint: "共 {rows} 条数据 × 每条份数 = 合计 {total} 页(无需客户端)",
4708
+ printClientConnected: "打印客户端已连接",
4709
+ printClientDisconnected: "打印客户端未连接",
4710
+ printClientConnect: "连接客户端",
4711
+ printClientDisconnect: "断开连接",
4712
+ printClientNoPrinters: "未检测到打印机",
4713
+ defaultPrinter: "默认"
4218
4714
  },
4219
4715
  header: {
4220
4716
  title: "打印设计器"
@@ -4317,7 +4813,19 @@
4317
4813
  printDataAddRow: "Add row",
4318
4814
  printDataDeleteRow: "Delete",
4319
4815
  printDataFieldKey: "Field",
4320
- paper: "Paper"
4816
+ paper: "Paper",
4817
+ browserPrint: "Browser Print",
4818
+ silentPrint: "Silent Print",
4819
+ batchPrint: "Batch Print",
4820
+ batchPrinting: "Preparing…",
4821
+ batchCopies: "Copies per record",
4822
+ batchHint: "{rows} records × copies = {total} pages (no client required)",
4823
+ printClientConnected: "Print client connected",
4824
+ printClientDisconnected: "Print client disconnected",
4825
+ printClientConnect: "Connect Client",
4826
+ printClientDisconnect: "Disconnect",
4827
+ printClientNoPrinters: "No printers found",
4828
+ defaultPrinter: "Default"
4321
4829
  },
4322
4830
  header: {
4323
4831
  title: "Print Designer"
@@ -4555,8 +5063,21 @@
4555
5063
  setConfig(config) {
4556
5064
  if (config) Object.assign(this.options, { config });
4557
5065
  }
4558
- setConnect(connect, _callback) {
5066
+ setConnect(connect, callback2) {
5067
+ var _a2, _b2;
4559
5068
  this.options.connect = connect;
5069
+ const client = getPrintClient();
5070
+ if (connect) {
5071
+ void client.connect({
5072
+ host: (_a2 = this.options.config) == null ? void 0 : _a2.host,
5073
+ token: (_b2 = this.options.config) == null ? void 0 : _b2.token
5074
+ }).then((status) => {
5075
+ callback2 == null ? void 0 : callback2(status.connected, status.message);
5076
+ });
5077
+ return;
5078
+ }
5079
+ client.disconnect();
5080
+ callback2 == null ? void 0 : callback2(false);
4560
5081
  }
4561
5082
  initProviders(providers) {
4562
5083
  initHiprint({
@@ -4565,9 +5086,9 @@
4565
5086
  config: this.options.config,
4566
5087
  paperList: this.options.paperList,
4567
5088
  onPaperApplied: () => {
4568
- var _a, _b;
5089
+ var _a2, _b2;
4569
5090
  try {
4570
- (_b = (_a = this.ruler) == null ? void 0 : _a.redraw) == null ? void 0 : _b.call(_a);
5091
+ (_b2 = (_a2 = this.ruler) == null ? void 0 : _a2.redraw) == null ? void 0 : _b2.call(_a2);
4571
5092
  } catch {
4572
5093
  }
4573
5094
  }
@@ -4582,7 +5103,7 @@
4582
5103
  list.forEach((m) => {
4583
5104
  try {
4584
5105
  const $els = $(m.container);
4585
- if ($els.length) vuePluginHiprint.hiprint.PrintElementTypeManager.buildByHtml($els);
5106
+ if ($els.length) hiprint.PrintElementTypeManager.buildByHtml($els);
4586
5107
  } catch (e) {
4587
5108
  console.warn("buildByProvider", e);
4588
5109
  }
@@ -4595,20 +5116,20 @@
4595
5116
  // PrintTemplate lifecycle
4596
5117
  // -------------------------------------------------------------------------
4597
5118
  newPrintTemplate(template) {
4598
- const tpl = new vuePluginHiprint.hiprint.PrintTemplate({ template });
5119
+ const tpl = new hiprint.PrintTemplate({ template });
4599
5120
  return tpl;
4600
5121
  }
4601
5122
  newDesigner(options, designOptions = {}) {
4602
- var _a, _b;
5123
+ var _a2, _b2;
4603
5124
  if (this.printTemplate) {
4604
5125
  this.unbindSelectionEvents();
4605
5126
  this.unbindZoomEvents();
4606
5127
  try {
4607
- (_b = (_a = this.printTemplate).clear) == null ? void 0 : _b.call(_a);
5128
+ (_b2 = (_a2 = this.printTemplate).clear) == null ? void 0 : _b2.call(_a2);
4608
5129
  } catch (_) {
4609
5130
  }
4610
5131
  }
4611
- const tpl = new vuePluginHiprint.hiprint.PrintTemplate({
5132
+ const tpl = new hiprint.PrintTemplate({
4612
5133
  template: options.template,
4613
5134
  settingContainer: options.settingContainer ? options.settingContainer : `#${SETTING_CONTAINER_ID}`,
4614
5135
  paginationContainer: options.paginationContainer,
@@ -4616,19 +5137,19 @@
4616
5137
  history: options.history ?? true,
4617
5138
  onImageChooseClick: options.onImageChooseClick,
4618
5139
  onZoomChange: (scale) => {
4619
- var _a2;
5140
+ var _a3;
4620
5141
  setZoom(scale);
4621
- (_a2 = options.onZoomChange) == null ? void 0 : _a2.call(options, scale);
5142
+ (_a3 = options.onZoomChange) == null ? void 0 : _a3.call(options, scale);
4622
5143
  },
4623
5144
  onPanelAddClick: options.onPanelAddClick,
4624
5145
  onFunctionClick: options.onFunctionClick,
4625
5146
  onDataChanged: (type, json) => {
4626
- var _a2;
5147
+ var _a3;
4627
5148
  this.history.refreshFromTemplate();
4628
5149
  this.refreshSelection();
4629
5150
  this.reapplyElementTransforms();
4630
5151
  designerStore.uiPulse += 1;
4631
- (_a2 = options.onDataChanged) == null ? void 0 : _a2.call(options, type, json);
5152
+ (_a3 = options.onDataChanged) == null ? void 0 : _a3.call(options, type, json);
4632
5153
  },
4633
5154
  onUpdateError: options.onUpdateError
4634
5155
  });
@@ -4661,28 +5182,28 @@
4661
5182
  return tpl;
4662
5183
  }
4663
5184
  unbindSelectionEvents() {
4664
- var _a;
4665
- (_a = this.selectionEventCleanup) == null ? void 0 : _a.call(this);
5185
+ var _a2;
5186
+ (_a2 = this.selectionEventCleanup) == null ? void 0 : _a2.call(this);
4666
5187
  this.selectionEventCleanup = null;
4667
5188
  }
4668
5189
  unbindZoomEvents() {
4669
- var _a;
4670
- (_a = this.zoomEventCleanup) == null ? void 0 : _a.call(this);
5190
+ var _a2;
5191
+ (_a2 = this.zoomEventCleanup) == null ? void 0 : _a2.call(this);
4671
5192
  this.zoomEventCleanup = null;
4672
5193
  }
4673
5194
  /** Keep store/ruler in sync when hiprint paper scale changes (e.g. zoom toolbar). */
4674
5195
  bindZoomEvents(tpl) {
4675
- var _a;
5196
+ var _a2;
4676
5197
  this.unbindZoomEvents();
4677
- const paper = (_a = tpl == null ? void 0 : tpl.editingPanel) == null ? void 0 : _a.designPaper;
5198
+ const paper = (_a2 = tpl == null ? void 0 : tpl.editingPanel) == null ? void 0 : _a2.designPaper;
4678
5199
  if (!(paper == null ? void 0 : paper.subscribePaperBaseInfoChanged)) return;
4679
5200
  const onPaperInfo = (info) => {
4680
- var _a2, _b;
5201
+ var _a3, _b2;
4681
5202
  if (typeof (info == null ? void 0 : info.scale) !== "number" || !(info.scale > 0)) return;
4682
5203
  const next = Math.max(ZOOM_MIN, Math.min(ZOOM_MAX, info.scale));
4683
5204
  if (Math.abs(next - this.state.zoom) < 1e-3) return;
4684
5205
  setZoom(next);
4685
- (_b = (_a2 = this.ruler) == null ? void 0 : _a2.redraw) == null ? void 0 : _b.call(_a2);
5206
+ (_b2 = (_a3 = this.ruler) == null ? void 0 : _a3.redraw) == null ? void 0 : _b2.call(_a3);
4686
5207
  };
4687
5208
  paper.subscribePaperBaseInfoChanged(onPaperInfo);
4688
5209
  this.zoomEventCleanup = () => {
@@ -4693,23 +5214,23 @@
4693
5214
  };
4694
5215
  }
4695
5216
  syncZoomFromTemplate() {
4696
- var _a, _b;
5217
+ var _a2, _b2;
4697
5218
  setZoom(this.getZoom());
4698
- (_b = (_a = this.ruler) == null ? void 0 : _a.redraw) == null ? void 0 : _b.call(_a);
5219
+ (_b2 = (_a2 = this.ruler) == null ? void 0 : _a2.redraw) == null ? void 0 : _b2.call(_a2);
4699
5220
  }
4700
5221
  readTemplateScale() {
4701
- var _a, _b, _c;
5222
+ var _a2, _b2, _c2;
4702
5223
  const tpl = this.printTemplate;
4703
5224
  if (!tpl) return null;
4704
- const scale = ((_b = (_a = tpl.editingPanel) == null ? void 0 : _a.designPaper) == null ? void 0 : _b.scale) ?? ((_c = tpl.editingPanel) == null ? void 0 : _c.scale) ?? tpl.scale;
5225
+ const scale = ((_b2 = (_a2 = tpl.editingPanel) == null ? void 0 : _a2.designPaper) == null ? void 0 : _b2.scale) ?? ((_c2 = tpl.editingPanel) == null ? void 0 : _c2.scale) ?? tpl.scale;
4705
5226
  return typeof scale === "number" && scale > 0 ? scale : null;
4706
5227
  }
4707
5228
  /** Sync Vue selection state when hiprint selects / deselects print elements. */
4708
5229
  bindSelectionEvents(tpl) {
4709
- var _a;
5230
+ var _a2;
4710
5231
  this.unbindSelectionEvents();
4711
5232
  if (typeof window === "undefined" || !tpl) return;
4712
- const eventBus = (_a = window.hinnn) == null ? void 0 : _a.event;
5233
+ const eventBus = (_a2 = window.hinnn) == null ? void 0 : _a2.event;
4713
5234
  const tplId = tpl.id ?? tpl.templateId;
4714
5235
  if (!eventBus || tplId == null) return;
4715
5236
  const selectKey = `PrintElementSelectEventKey_${tplId}`;
@@ -4751,9 +5272,9 @@
4751
5272
  };
4752
5273
  }
4753
5274
  refreshPrintTemplate() {
4754
- var _a, _b;
5275
+ var _a2, _b2;
4755
5276
  try {
4756
- (_b = (_a = this.printTemplate) == null ? void 0 : _a.refresh) == null ? void 0 : _b.call(_a);
5277
+ (_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.refresh) == null ? void 0 : _b2.call(_a2);
4757
5278
  } catch (_) {
4758
5279
  }
4759
5280
  this.reapplyElementTransforms();
@@ -4800,7 +5321,7 @@
4800
5321
  });
4801
5322
  }
4802
5323
  refreshSelection() {
4803
- var _a, _b, _c, _d;
5324
+ var _a2, _b2, _c2, _d2;
4804
5325
  const tpl = this.printTemplate;
4805
5326
  if (!tpl) {
4806
5327
  setSelection({ count: 0, ids: [], elements: [] });
@@ -4808,15 +5329,15 @@
4808
5329
  }
4809
5330
  let els = [];
4810
5331
  try {
4811
- els = ((_a = tpl.getSelectEls) == null ? void 0 : _a.call(tpl)) ?? [];
5332
+ els = ((_a2 = tpl.getSelectEls) == null ? void 0 : _a2.call(tpl)) ?? [];
4812
5333
  } catch {
4813
5334
  }
4814
5335
  if (!els.length) {
4815
- els = ((_d = (_c = (_b = tpl.editingPanel) == null ? void 0 : _b.printElements) == null ? void 0 : _c.filter) == null ? void 0 : _d.call(_c, (e) => {
4816
- var _a2, _b2, _c2, _d2;
5336
+ els = ((_d2 = (_c2 = (_b2 = tpl.editingPanel) == null ? void 0 : _b2.printElements) == null ? void 0 : _c2.filter) == null ? void 0 : _d2.call(_c2, (e) => {
5337
+ var _a3, _b3, _c3, _d3;
4817
5338
  if (e == null ? void 0 : e.selected) return true;
4818
5339
  try {
4819
- return !!((_b2 = (_a2 = e == null ? void 0 : e.designTarget) == null ? void 0 : _a2.hasClass) == null ? void 0 : _b2.call(_a2, "hiprint-printElement-selected")) || !!((_d2 = (_c2 = e == null ? void 0 : e.designTarget) == null ? void 0 : _c2.hasClass) == null ? void 0 : _d2.call(_c2, "selected"));
5340
+ return !!((_b3 = (_a3 = e == null ? void 0 : e.designTarget) == null ? void 0 : _a3.hasClass) == null ? void 0 : _b3.call(_a3, "hiprint-printElement-selected")) || !!((_d3 = (_c3 = e == null ? void 0 : e.designTarget) == null ? void 0 : _c3.hasClass) == null ? void 0 : _d3.call(_c3, "selected"));
4820
5341
  } catch {
4821
5342
  return false;
4822
5343
  }
@@ -4830,25 +5351,25 @@
4830
5351
  }
4831
5352
  /** Select a print element from auxiliary panels (page structure, etc.). */
4832
5353
  selectPrintElement(item) {
4833
- var _a, _b, _c, _d, _e, _f, _g;
5354
+ var _a2, _b2, _c2, _d2, _e, _f, _g;
4834
5355
  const tpl = this.printTemplate;
4835
5356
  if (!tpl || !item) return;
4836
5357
  const $ = typeof window !== "undefined" ? window.$ || window.jQuery : null;
4837
5358
  const dt = $ == null ? void 0 : $(item.designTarget);
4838
5359
  if ($ && (dt == null ? void 0 : dt.length)) {
4839
- (_b = (_a = tpl.editingPanel) == null ? void 0 : _a.printElements) == null ? void 0 : _b.forEach((el) => {
5360
+ (_b2 = (_a2 = tpl.editingPanel) == null ? void 0 : _a2.printElements) == null ? void 0 : _b2.forEach((el) => {
4840
5361
  if (el === item) return;
4841
5362
  const target = $(el.designTarget);
4842
5363
  if (!(target == null ? void 0 : target.length)) return;
4843
5364
  target.children("div[panelindex]").removeClass("selected").css({ display: "none" });
4844
5365
  });
4845
- const type = String(((_c = item.printElementType) == null ? void 0 : _c.type) || "");
5366
+ const type = String(((_c2 = item.printElementType) == null ? void 0 : _c2.type) || "");
4846
5367
  if (type.includes("table")) {
4847
5368
  dt.find("tr:first td:first").trigger("click");
4848
5369
  } else {
4849
5370
  dt.children("div[panelindex]").addClass("selected").css({ display: "block" });
4850
5371
  try {
4851
- (_f = (_e = (_d = dt.data("hidraggable")) == null ? void 0 : _d.options) == null ? void 0 : _e.onBeforeSelectAllDrag) == null ? void 0 : _f.call(dt[0], {});
5372
+ (_f = (_e = (_d2 = dt.data("hidraggable")) == null ? void 0 : _d2.options) == null ? void 0 : _e.onBeforeSelectAllDrag) == null ? void 0 : _f.call(dt[0], {});
4852
5373
  } catch {
4853
5374
  }
4854
5375
  }
@@ -4871,10 +5392,10 @@
4871
5392
  const $ = typeof window !== "undefined" ? window.$ || window.jQuery : null;
4872
5393
  if (!$) return;
4873
5394
  items.forEach((item) => {
4874
- var _a, _b, _c, _d;
5395
+ var _a2, _b2, _c2, _d2;
4875
5396
  const dt = $(item.designTarget);
4876
5397
  if (!(dt == null ? void 0 : dt.length)) return;
4877
- const type = String(((_a = item.printElementType) == null ? void 0 : _a.type) || "");
5398
+ const type = String(((_a2 = item.printElementType) == null ? void 0 : _a2.type) || "");
4878
5399
  if (type.includes("table")) {
4879
5400
  dt.find("tr:first td:first").trigger("click");
4880
5401
  return;
@@ -4882,7 +5403,7 @@
4882
5403
  dt.children("div[panelindex]").addClass("selected").css({ display: "block" });
4883
5404
  try {
4884
5405
  const dom = dt[0];
4885
- (_d = (_c = (_b = dt.data("hidraggable")) == null ? void 0 : _b.options) == null ? void 0 : _c.onBeforeSelectAllDrag) == null ? void 0 : _d.call(dom, {});
5406
+ (_d2 = (_c2 = (_b2 = dt.data("hidraggable")) == null ? void 0 : _b2.options) == null ? void 0 : _c2.onBeforeSelectAllDrag) == null ? void 0 : _d2.call(dom, {});
4886
5407
  } catch {
4887
5408
  }
4888
5409
  });
@@ -4896,9 +5417,9 @@
4896
5417
  // Persistence / IO
4897
5418
  // -------------------------------------------------------------------------
4898
5419
  getTemplateJson() {
4899
- var _a, _b;
5420
+ var _a2, _b2;
4900
5421
  try {
4901
- return ((_b = (_a = this.printTemplate) == null ? void 0 : _a.getJson) == null ? void 0 : _b.call(_a)) ?? null;
5422
+ return ((_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.getJson) == null ? void 0 : _b2.call(_a2)) ?? null;
4902
5423
  } catch {
4903
5424
  return null;
4904
5425
  }
@@ -4907,11 +5428,11 @@
4907
5428
  return `tpl:${this.options.templateKey || "default"}`;
4908
5429
  }
4909
5430
  save() {
4910
- var _a, _b;
5431
+ var _a2, _b2;
4911
5432
  const json = this.getTemplateJson();
4912
5433
  if (!json) return;
4913
5434
  const key = this.options.templateKey || "default";
4914
- const blocked = ((_b = (_a = this.options.events) == null ? void 0 : _a.onSave) == null ? void 0 : _b.call(_a, key, json)) === false;
5435
+ const blocked = ((_b2 = (_a2 = this.options.events) == null ? void 0 : _a2.onSave) == null ? void 0 : _b2.call(_a2, key, json)) === false;
4915
5436
  if (blocked) return;
4916
5437
  writeJSON(this.templateStorageKey(), json);
4917
5438
  }
@@ -4924,9 +5445,9 @@
4924
5445
  return openJsonEditorModal(options);
4925
5446
  }
4926
5447
  async edit() {
4927
- var _a, _b;
5448
+ var _a2, _b2;
4928
5449
  const json = this.getTemplateJson();
4929
- if (((_b = (_a = this.options.events) == null ? void 0 : _a.onEdit) == null ? void 0 : _b.call(_a, json)) === false) return;
5450
+ if (((_b2 = (_a2 = this.options.events) == null ? void 0 : _a2.onEdit) == null ? void 0 : _b2.call(_a2, json)) === false) return;
4930
5451
  try {
4931
5452
  const next = await this.openJsonEditor({
4932
5453
  title: translate("designer.editTemplate"),
@@ -4946,8 +5467,8 @@
4946
5467
  }
4947
5468
  }
4948
5469
  async editData() {
4949
- var _a, _b, _c;
4950
- if (((_b = (_a = this.options.events) == null ? void 0 : _a.onEditData) == null ? void 0 : _b.call(_a, this.printData)) === false) return;
5470
+ var _a2, _b2, _c2;
5471
+ if (((_b2 = (_a2 = this.options.events) == null ? void 0 : _a2.onEditData) == null ? void 0 : _b2.call(_a2, this.printData)) === false) return;
4951
5472
  try {
4952
5473
  const schema = extractTemplateFields(this.getTemplateJson());
4953
5474
  const host = this.printDataEditor;
@@ -4972,7 +5493,7 @@
4972
5493
  });
4973
5494
  if (next == null) return;
4974
5495
  this.setPrintData(next);
4975
- (_c = this.onPrintDataChange) == null ? void 0 : _c.call(this, next);
5496
+ (_c2 = this.onPrintDataChange) == null ? void 0 : _c2.call(this, next);
4976
5497
  } catch (e) {
4977
5498
  console.error("[vue3-print-designer] edit print data failed", e);
4978
5499
  }
@@ -4997,8 +5518,8 @@
4997
5518
  input.type = "file";
4998
5519
  input.accept = ".json,application/json";
4999
5520
  input.onchange = () => {
5000
- var _a;
5001
- const file = (_a = input.files) == null ? void 0 : _a[0];
5521
+ var _a2;
5522
+ const file = (_a2 = input.files) == null ? void 0 : _a2[0];
5002
5523
  if (!file) return;
5003
5524
  const reader = new FileReader();
5004
5525
  reader.onload = () => {
@@ -5015,15 +5536,15 @@
5015
5536
  }
5016
5537
  /** Import onto existing paper(s) without creating extra panels. */
5017
5538
  applyImportTemplateJson(json) {
5018
- var _a, _b, _c, _d, _e;
5539
+ var _a2, _b2, _c2, _d2, _e;
5019
5540
  const tpl = this.printTemplate;
5020
5541
  const currentJson = this.getTemplateJson();
5021
- if (!(tpl == null ? void 0 : tpl.update) || !((_a = currentJson == null ? void 0 : currentJson.panels) == null ? void 0 : _a.length)) {
5542
+ if (!(tpl == null ? void 0 : tpl.update) || !((_a2 = currentJson == null ? void 0 : currentJson.panels) == null ? void 0 : _a2.length)) {
5022
5543
  this.applyTemplateJson(json);
5023
5544
  return;
5024
5545
  }
5025
5546
  const merged = mergeImportOntoCurrentPanels(currentJson, json);
5026
- const activeIndex = ((_b = tpl.editingPanel) == null ? void 0 : _b.index) ?? ((_d = (_c = tpl.printPanels) == null ? void 0 : _c[0]) == null ? void 0 : _d.index) ?? 0;
5547
+ const activeIndex = ((_b2 = tpl.editingPanel) == null ? void 0 : _b2.index) ?? ((_d2 = (_c2 = tpl.printPanels) == null ? void 0 : _c2[0]) == null ? void 0 : _d2.index) ?? 0;
5027
5548
  try {
5028
5549
  tpl.update(merged, activeIndex);
5029
5550
  } catch (e) {
@@ -5038,33 +5559,53 @@
5038
5559
  if (nextJson) (_e = this.onTemplateChange) == null ? void 0 : _e.call(this, nextJson);
5039
5560
  }
5040
5561
  applyTemplateJson(json) {
5041
- var _a;
5562
+ var _a2;
5042
5563
  this.newDesigner(
5043
5564
  { template: json, history: true, dataMode: 1 },
5044
5565
  this.options.designOptions || {}
5045
5566
  );
5046
- (_a = this.onTemplateChange) == null ? void 0 : _a.call(this, json);
5567
+ (_a2 = this.onTemplateChange) == null ? void 0 : _a2.call(this, json);
5047
5568
  }
5048
5569
  getPrinterList() {
5049
- var _a, _b;
5050
- try {
5051
- return ((_b = (_a = vuePluginHiprint.hiprint.hiwebSocket) == null ? void 0 : _a.getPrinterList) == null ? void 0 : _b.call(_a)) ?? [];
5052
- } catch {
5053
- return [];
5570
+ return getPrintClient().getPrinterList();
5571
+ }
5572
+ getPrintClientStatus() {
5573
+ return getPrintClient().getStatus();
5574
+ }
5575
+ /**
5576
+ * Browser-side batch print. Combines records into a single print job —
5577
+ * works without electron-hiprint. `printDataList` can be a single
5578
+ * object or an array; each record can also be printed multiple times
5579
+ * via `options.copies`.
5580
+ */
5581
+ async batchPrint(printDataList, options) {
5582
+ if (!this.printTemplate) {
5583
+ throw new Error("[print-designer] No active print template.");
5584
+ }
5585
+ const data2 = printDataList ?? this.printData ?? {};
5586
+ const list = Array.isArray(data2) ? data2 : [data2];
5587
+ await this.plugins.run("beforePrint", this.printTemplate, this);
5588
+ await batchPrint(this.printTemplate, list, options);
5589
+ }
5590
+ async print2(printData, options) {
5591
+ const data2 = printData ?? this.printData;
5592
+ if (!this.printTemplate) {
5593
+ throw new Error("[print-designer] No active print template.");
5054
5594
  }
5595
+ return getPrintClient().printByInstance(this.printTemplate, data2, options);
5055
5596
  }
5056
5597
  // -------------------------------------------------------------------------
5057
5598
  // Zoom / view-port helpers
5058
5599
  // -------------------------------------------------------------------------
5059
5600
  setZoom(value) {
5060
- var _a, _b, _c, _d;
5601
+ var _a2, _b2, _c2, _d2;
5061
5602
  const scale = Math.max(ZOOM_MIN, Math.min(ZOOM_MAX, Number.isFinite(value) ? value : 1));
5062
5603
  setZoom(scale);
5063
5604
  try {
5064
- (_b = (_a = this.printTemplate) == null ? void 0 : _a.zoom) == null ? void 0 : _b.call(_a, scale);
5605
+ (_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.zoom) == null ? void 0 : _b2.call(_a2, scale);
5065
5606
  } catch (_) {
5066
5607
  }
5067
- (_d = (_c = this.ruler) == null ? void 0 : _c.redraw) == null ? void 0 : _d.call(_c);
5608
+ (_d2 = (_c2 = this.ruler) == null ? void 0 : _c2.redraw) == null ? void 0 : _d2.call(_c2);
5068
5609
  }
5069
5610
  getZoom() {
5070
5611
  const scale = this.readTemplateScale();
@@ -5086,10 +5627,10 @@
5086
5627
  return this.getZoom() > ZOOM_MIN + 1e-3;
5087
5628
  }
5088
5629
  adaptToSize() {
5089
- var _a;
5630
+ var _a2;
5090
5631
  if (typeof window === "undefined") return;
5091
5632
  const host = document.getElementById(DESIGN_CONTAINER_ID);
5092
- const paper = (_a = host == null ? void 0 : host.querySelector) == null ? void 0 : _a.call(host, ".hiprint-printPanel, .hiprint-printPaper");
5633
+ const paper = (_a2 = host == null ? void 0 : host.querySelector) == null ? void 0 : _a2.call(host, ".hiprint-printPanel, .hiprint-printPaper");
5093
5634
  if (!host || !paper) return;
5094
5635
  const hostRect = host.getBoundingClientRect();
5095
5636
  const zoom = Math.max(ZOOM_MIN, this.getZoom());
@@ -5108,24 +5649,24 @@
5108
5649
  return [...this.getPanelElements()];
5109
5650
  }
5110
5651
  getSelectedElements() {
5111
- var _a;
5652
+ var _a2;
5112
5653
  const tpl = this.printTemplate;
5113
5654
  if (!tpl) return [];
5114
5655
  let els = [];
5115
5656
  try {
5116
- els = ((_a = tpl.getSelectEls) == null ? void 0 : _a.call(tpl)) ?? [];
5657
+ els = ((_a2 = tpl.getSelectEls) == null ? void 0 : _a2.call(tpl)) ?? [];
5117
5658
  } catch {
5118
5659
  }
5119
5660
  if (!els.length) els = this.state.selection.elements;
5120
5661
  return els.filter(Boolean);
5121
5662
  }
5122
5663
  getPanelElements() {
5123
- var _a, _b;
5124
- return ((_b = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel) == null ? void 0 : _b.printElements) ?? [];
5664
+ var _a2, _b2;
5665
+ return ((_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel) == null ? void 0 : _b2.printElements) ?? [];
5125
5666
  }
5126
5667
  getExplicitZIndex(el) {
5127
- var _a;
5128
- const raw = (_a = el == null ? void 0 : el.options) == null ? void 0 : _a.zIndex;
5668
+ var _a2;
5669
+ const raw = (_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.zIndex;
5129
5670
  if (raw != null && raw !== "" && Number.isFinite(Number(raw))) return Number(raw);
5130
5671
  return null;
5131
5672
  }
@@ -5133,7 +5674,7 @@
5133
5674
  this.updateElementOption(el, "zIndex", zIndex, true);
5134
5675
  }
5135
5676
  updateElementOption(el, name, value, silent = true) {
5136
- var _a;
5677
+ var _a2;
5137
5678
  try {
5138
5679
  if (typeof (el == null ? void 0 : el.updateOption) === "function") {
5139
5680
  el.updateOption(name, value, silent);
@@ -5143,34 +5684,34 @@
5143
5684
  }
5144
5685
  try {
5145
5686
  el.options[name] = value;
5146
- (_a = el.updateDesignViewFromOptions) == null ? void 0 : _a.call(el);
5687
+ (_a2 = el.updateDesignViewFromOptions) == null ? void 0 : _a2.call(el);
5147
5688
  return true;
5148
5689
  } catch {
5149
5690
  }
5150
5691
  return false;
5151
5692
  }
5152
5693
  getElementFontSize(el) {
5153
- var _a, _b;
5154
- const raw = (_a = el == null ? void 0 : el.options) == null ? void 0 : _a.fontSize;
5694
+ var _a2, _b2;
5695
+ const raw = (_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.fontSize;
5155
5696
  const size = Number(raw);
5156
5697
  if (Number.isFinite(size) && size > 0) return size;
5157
- const typeDefault = Number((_b = el == null ? void 0 : el.printElementType) == null ? void 0 : _b.fontSize);
5698
+ const typeDefault = Number((_b2 = el == null ? void 0 : el.printElementType) == null ? void 0 : _b2.fontSize);
5158
5699
  return Number.isFinite(typeDefault) && typeDefault > 0 ? typeDefault : 12;
5159
5700
  }
5160
5701
  resolveElementTid(el) {
5161
- var _a, _b;
5162
- const tid = ((_a = el == null ? void 0 : el.printElementType) == null ? void 0 : _a.tid) ?? (el == null ? void 0 : el.tid);
5702
+ var _a2, _b2;
5703
+ const tid = ((_a2 = el == null ? void 0 : el.printElementType) == null ? void 0 : _a2.tid) ?? (el == null ? void 0 : el.tid);
5163
5704
  if (tid) return String(tid);
5164
- const type = String(((_b = el == null ? void 0 : el.printElementType) == null ? void 0 : _b.type) || "");
5705
+ const type = String(((_b2 = el == null ? void 0 : el.printElementType) == null ? void 0 : _b2.type) || "");
5165
5706
  if (!type) return null;
5166
5707
  return `defaultModule.${type}`;
5167
5708
  }
5168
5709
  serializeElement(el) {
5169
- var _a, _b;
5710
+ var _a2, _b2;
5170
5711
  if (!el) return null;
5171
5712
  try {
5172
5713
  const tid = this.resolveElementTid(el);
5173
- const optionsSource = ((_b = (_a = el.options) == null ? void 0 : _a.getPrintElementOptionEntity) == null ? void 0 : _b.call(_a)) ?? el.options ?? {};
5714
+ const optionsSource = ((_b2 = (_a2 = el.options) == null ? void 0 : _a2.getPrintElementOptionEntity) == null ? void 0 : _b2.call(_a2)) ?? el.options ?? {};
5174
5715
  const options = JSON.parse(JSON.stringify(optionsSource));
5175
5716
  const printElementType = el.printElementType ? JSON.parse(JSON.stringify(el.printElementType)) : void 0;
5176
5717
  if (!tid && !(printElementType == null ? void 0 : printElementType.type)) return null;
@@ -5187,15 +5728,15 @@
5187
5728
  return copy;
5188
5729
  }
5189
5730
  insertElementEntity(entity, initSizeByHtml = false) {
5190
- var _a, _b, _c, _d, _e, _f, _g, _h;
5191
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
5731
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
5732
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5192
5733
  const tpl = this.printTemplate;
5193
- if (!panel || !(entity == null ? void 0 : entity.tid) && !((_b = entity == null ? void 0 : entity.printElementType) == null ? void 0 : _b.type)) return null;
5734
+ if (!panel || !(entity == null ? void 0 : entity.tid) && !((_b2 = entity == null ? void 0 : entity.printElementType) == null ? void 0 : _b2.type)) return null;
5194
5735
  try {
5195
- const type = (_c = panel.getPrintElementTypeByEntity) == null ? void 0 : _c.call(panel, entity);
5736
+ const type = (_c2 = panel.getPrintElementTypeByEntity) == null ? void 0 : _c2.call(panel, entity);
5196
5737
  if (!(type == null ? void 0 : type.createPrintElement)) return null;
5197
5738
  const el = type.createPrintElement(entity.options);
5198
- (_d = el.setTemplateId) == null ? void 0 : _d.call(el, tpl.id ?? tpl.templateId);
5739
+ (_d2 = el.setTemplateId) == null ? void 0 : _d2.call(el, tpl.id ?? tpl.templateId);
5199
5740
  (_e = el.setPanel) == null ? void 0 : _e.call(el, panel);
5200
5741
  (_f = panel.appendDesignPrintElement) == null ? void 0 : _f.call(panel, panel.designPaper, el, initSizeByHtml);
5201
5742
  panel.printElements.push(el);
@@ -5211,7 +5752,7 @@
5211
5752
  }
5212
5753
  /** Insert a new canvas element by hiprint `tid` (e.g. `defaultModule.text`). */
5213
5754
  addElementByTid(tid, options = {}) {
5214
- var _a;
5755
+ var _a2;
5215
5756
  const left = Number.isFinite(options.left) ? Number(options.left) : 60;
5216
5757
  const top = Number.isFinite(options.top) ? Number(options.top) : 60;
5217
5758
  const el = this.insertElementEntity({ tid, options: { left, top } }, true);
@@ -5219,20 +5760,20 @@
5219
5760
  this.markTemplateChanged("新增元素");
5220
5761
  this.selectPrintElement(el);
5221
5762
  const json = this.getTemplateJson();
5222
- if (json) (_a = this.onTemplateChange) == null ? void 0 : _a.call(this, json);
5763
+ if (json) (_a2 = this.onTemplateChange) == null ? void 0 : _a2.call(this, json);
5223
5764
  return el;
5224
5765
  }
5225
5766
  /** Clone a live print element using hiprint's native clone path. */
5226
5767
  duplicateElement(el, delta = 10) {
5227
- var _a, _b, _c, _d, _e, _f, _g;
5228
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
5768
+ var _a2, _b2, _c2, _d2, _e, _f, _g;
5769
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5229
5770
  const tpl = this.printTemplate;
5230
5771
  if (!panel || !tpl || !el) return null;
5231
5772
  try {
5232
5773
  let copy = null;
5233
5774
  if (typeof el.clone === "function") {
5234
5775
  copy = el.clone();
5235
- } else if ((_b = el.printElementType) == null ? void 0 : _b.createPrintElement) {
5776
+ } else if ((_b2 = el.printElementType) == null ? void 0 : _b2.createPrintElement) {
5236
5777
  copy = el.printElementType.createPrintElement();
5237
5778
  Object.keys(el.options || {}).forEach((key) => {
5238
5779
  copy.options[key] = el.options[key];
@@ -5245,8 +5786,8 @@
5245
5786
  else copy.options.left = left;
5246
5787
  if (typeof copy.options.setTop === "function") copy.options.setTop(top);
5247
5788
  else copy.options.top = top;
5248
- (_c = copy.setTemplateId) == null ? void 0 : _c.call(copy, tpl.id ?? tpl.templateId);
5249
- (_d = copy.setPanel) == null ? void 0 : _d.call(copy, panel);
5789
+ (_c2 = copy.setTemplateId) == null ? void 0 : _c2.call(copy, tpl.id ?? tpl.templateId);
5790
+ (_d2 = copy.setPanel) == null ? void 0 : _d2.call(copy, panel);
5250
5791
  (_e = panel.appendDesignPrintElement) == null ? void 0 : _e.call(panel, panel.designPaper, copy, false);
5251
5792
  panel.printElements.push(copy);
5252
5793
  (_f = copy.design) == null ? void 0 : _f.call(copy, void 0, panel.designPaper);
@@ -5260,15 +5801,15 @@
5260
5801
  }
5261
5802
  }
5262
5803
  setElementDraggable(el, draggable) {
5263
- var _a, _b, _c, _d;
5804
+ var _a2, _b2, _c2, _d2;
5264
5805
  if (!(el == null ? void 0 : el.options)) return;
5265
5806
  el.options.draggable = draggable;
5266
5807
  try {
5267
- (_b = (_a = el.designTarget) == null ? void 0 : _a.hidraggable) == null ? void 0 : _b.call(_a, "update", { draggable });
5808
+ (_b2 = (_a2 = el.designTarget) == null ? void 0 : _a2.hidraggable) == null ? void 0 : _b2.call(_a2, "update", { draggable });
5268
5809
  } catch {
5269
5810
  }
5270
5811
  try {
5271
- (_d = (_c = el.designTarget) == null ? void 0 : _c.hireizeable) == null ? void 0 : _d.call(_c, "update", { draggable });
5812
+ (_d2 = (_c2 = el.designTarget) == null ? void 0 : _c2.hireizeable) == null ? void 0 : _d2.call(_c2, "update", { draggable });
5272
5813
  } catch {
5273
5814
  }
5274
5815
  }
@@ -5289,13 +5830,13 @@
5289
5830
  ];
5290
5831
  }
5291
5832
  syncPanelElementOrder(ordered) {
5292
- var _a, _b;
5293
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
5833
+ var _a2, _b2;
5834
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5294
5835
  if (!panel) return;
5295
5836
  panel.printElements = ordered;
5296
5837
  try {
5297
5838
  const $ = window.jQuery || window.$;
5298
- const container = ((_b = panel.designPaper) == null ? void 0 : _b.target) ?? panel.target;
5839
+ const container = ((_b2 = panel.designPaper) == null ? void 0 : _b2.target) ?? panel.target;
5299
5840
  if ($ && (container == null ? void 0 : container.length)) {
5300
5841
  ordered.forEach((el) => {
5301
5842
  if (el == null ? void 0 : el.designTarget) $(el.designTarget).appendTo(container);
@@ -5305,37 +5846,37 @@
5305
5846
  }
5306
5847
  }
5307
5848
  getPanelSizePt(panel) {
5308
- var _a;
5849
+ var _a2;
5309
5850
  const hinnn = window.hinnn;
5310
5851
  const mmW = Number((panel == null ? void 0 : panel.width) ?? (panel == null ? void 0 : panel.mmwidth) ?? 0);
5311
5852
  const mmH = Number((panel == null ? void 0 : panel.height) ?? (panel == null ? void 0 : panel.mmheight) ?? 0);
5312
- if ((_a = hinnn == null ? void 0 : hinnn.mm) == null ? void 0 : _a.toPt) {
5853
+ if ((_a2 = hinnn == null ? void 0 : hinnn.mm) == null ? void 0 : _a2.toPt) {
5313
5854
  return { width: hinnn.mm.toPt(mmW), height: hinnn.mm.toPt(mmH) };
5314
5855
  }
5315
5856
  return { width: mmW, height: mmH };
5316
5857
  }
5317
5858
  getElementRect(el) {
5318
- var _a, _b, _c, _d;
5859
+ var _a2, _b2, _c2, _d2;
5319
5860
  const opts = el == null ? void 0 : el.options;
5320
5861
  if (!opts) return null;
5321
- const left = Number(((_a = opts.getLeft) == null ? void 0 : _a.call(opts)) ?? opts.left ?? 0);
5322
- const top = Number(((_b = opts.getTop) == null ? void 0 : _b.call(opts)) ?? opts.top ?? 0);
5323
- const width = Number(((_c = opts.getWidth) == null ? void 0 : _c.call(opts)) ?? opts.width ?? 0);
5324
- const height = Number(((_d = opts.getHeight) == null ? void 0 : _d.call(opts)) ?? opts.height ?? 0);
5862
+ const left = Number(((_a2 = opts.getLeft) == null ? void 0 : _a2.call(opts)) ?? opts.left ?? 0);
5863
+ const top = Number(((_b2 = opts.getTop) == null ? void 0 : _b2.call(opts)) ?? opts.top ?? 0);
5864
+ const width = Number(((_c2 = opts.getWidth) == null ? void 0 : _c2.call(opts)) ?? opts.width ?? 0);
5865
+ const height = Number(((_d2 = opts.getHeight) == null ? void 0 : _d2.call(opts)) ?? opts.height ?? 0);
5325
5866
  return { el, left, top, width, height, right: left + width, bottom: top + height };
5326
5867
  }
5327
5868
  applyElementPosition(el, left, top) {
5328
- var _a, _b, _c, _d, _e, _f, _g, _h;
5869
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
5329
5870
  const opts = el == null ? void 0 : el.options;
5330
5871
  if (!opts) return;
5331
- const width = Number(((_a = opts.getWidth) == null ? void 0 : _a.call(opts)) ?? opts.width ?? 0);
5332
- const height = Number(((_b = opts.getHeight) == null ? void 0 : _b.call(opts)) ?? opts.height ?? 0);
5872
+ const width = Number(((_a2 = opts.getWidth) == null ? void 0 : _a2.call(opts)) ?? opts.width ?? 0);
5873
+ const height = Number(((_b2 = opts.getHeight) == null ? void 0 : _b2.call(opts)) ?? opts.height ?? 0);
5333
5874
  try {
5334
5875
  if (typeof el.updateSizeAndPositionOptions === "function") {
5335
5876
  el.updateSizeAndPositionOptions(left, top, width, height);
5336
5877
  } else {
5337
- (_c = opts.setLeft) == null ? void 0 : _c.call(opts, left);
5338
- (_d = opts.setTop) == null ? void 0 : _d.call(opts, top);
5878
+ (_c2 = opts.setLeft) == null ? void 0 : _c2.call(opts, left);
5879
+ (_d2 = opts.setTop) == null ? void 0 : _d2.call(opts, top);
5339
5880
  (_e = opts.copyDesignTopFromTop) == null ? void 0 : _e.call(opts);
5340
5881
  }
5341
5882
  } catch {
@@ -5351,14 +5892,14 @@
5351
5892
  }
5352
5893
  }
5353
5894
  markTemplateChanged(label = HISTORY_PARAM) {
5354
- var _a, _b, _c;
5895
+ var _a2, _b2;
5355
5896
  const tpl = this.printTemplate;
5356
5897
  if (!tpl) return;
5357
5898
  try {
5358
- const lib = ((_a = vuePluginHiprint.hiprint) == null ? void 0 : _a.instance) ?? ((_b = window.HiPrintlib) == null ? void 0 : _b.instance);
5899
+ const lib = (hiprint == null ? void 0 : hiprint.instance) ?? ((_a2 = window.HiPrintlib) == null ? void 0 : _a2.instance);
5359
5900
  if (lib) lib.changed = true;
5360
5901
  const tplId = tpl.id ?? tpl.templateId;
5361
- const bus = (_c = window.hinnn) == null ? void 0 : _c.event;
5902
+ const bus = (_b2 = window.hinnn) == null ? void 0 : _b2.event;
5362
5903
  if (bus && tplId != null) bus.trigger(`hiprintTemplateDataChanged_${tplId}`, label);
5363
5904
  } catch {
5364
5905
  }
@@ -5366,7 +5907,7 @@
5366
5907
  this.history.refreshFromTemplate();
5367
5908
  }
5368
5909
  align(side) {
5369
- var _a;
5910
+ var _a2;
5370
5911
  const tpl = this.printTemplate;
5371
5912
  if (!tpl) return;
5372
5913
  const rects = this.getSelectedElements().map((el) => this.getElementRect(el)).filter(Boolean);
@@ -5376,7 +5917,7 @@
5376
5917
  let refRight;
5377
5918
  let refBottom;
5378
5919
  if (rects.length === 1) {
5379
- const panel = tpl.editingPanel ?? ((_a = rects[0].el) == null ? void 0 : _a.panel);
5920
+ const panel = tpl.editingPanel ?? ((_a2 = rects[0].el) == null ? void 0 : _a2.panel);
5380
5921
  const { width, height } = this.getPanelSizePt(panel);
5381
5922
  refLeft = 0;
5382
5923
  refTop = 0;
@@ -5422,9 +5963,9 @@
5422
5963
  callOnSelection(method, ...args) {
5423
5964
  const els = this.state.selection.elements;
5424
5965
  els.forEach((el) => {
5425
- var _a;
5966
+ var _a2;
5426
5967
  try {
5427
- (_a = el == null ? void 0 : el[method]) == null ? void 0 : _a.call(el, ...args);
5968
+ (_a2 = el == null ? void 0 : el[method]) == null ? void 0 : _a2.call(el, ...args);
5428
5969
  } catch (_) {
5429
5970
  }
5430
5971
  });
@@ -5489,15 +6030,15 @@
5489
6030
  isSelectionLocked() {
5490
6031
  const selected = this.getSelectedElements();
5491
6032
  return selected.length > 0 && selected.every((el) => {
5492
- var _a;
5493
- return ((_a = el == null ? void 0 : el.options) == null ? void 0 : _a.draggable) === false;
6033
+ var _a2;
6034
+ return ((_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.draggable) === false;
5494
6035
  });
5495
6036
  }
5496
6037
  isSelectionUnlocked() {
5497
6038
  const selected = this.getSelectedElements();
5498
6039
  return selected.length > 0 && selected.every((el) => {
5499
- var _a;
5500
- return ((_a = el == null ? void 0 : el.options) == null ? void 0 : _a.draggable) !== false;
6040
+ var _a2;
6041
+ return ((_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.draggable) !== false;
5501
6042
  });
5502
6043
  }
5503
6044
  setLock(locked) {
@@ -5548,17 +6089,17 @@
5548
6089
  designerStore.uiPulse += 1;
5549
6090
  }
5550
6091
  delete() {
5551
- var _a;
6092
+ var _a2;
5552
6093
  const selected = this.getSelectedElements();
5553
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
6094
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5554
6095
  if (!panel || !selected.length) return;
5555
6096
  selected.forEach((el) => {
5556
- var _a2, _b;
6097
+ var _a3, _b2;
5557
6098
  try {
5558
- (_a2 = panel.deletePrintElement) == null ? void 0 : _a2.call(panel, el);
6099
+ (_a3 = panel.deletePrintElement) == null ? void 0 : _a3.call(panel, el);
5559
6100
  } catch {
5560
6101
  try {
5561
- (_b = el == null ? void 0 : el.delete) == null ? void 0 : _b.call(el);
6102
+ (_b2 = el == null ? void 0 : el.delete) == null ? void 0 : _b2.call(el);
5562
6103
  } catch {
5563
6104
  }
5564
6105
  }
@@ -5568,15 +6109,15 @@
5568
6109
  }
5569
6110
  /** Delete a single element from the structure panel or other auxiliary UI. */
5570
6111
  deletePrintElement(item) {
5571
- var _a, _b, _c;
6112
+ var _a2, _b2, _c2;
5572
6113
  if (!item) return;
5573
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
6114
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5574
6115
  if (!panel) return;
5575
6116
  try {
5576
- (_b = panel.deletePrintElement) == null ? void 0 : _b.call(panel, item);
6117
+ (_b2 = panel.deletePrintElement) == null ? void 0 : _b2.call(panel, item);
5577
6118
  } catch {
5578
6119
  try {
5579
- (_c = item == null ? void 0 : item.delete) == null ? void 0 : _c.call(item);
6120
+ (_c2 = item == null ? void 0 : item.delete) == null ? void 0 : _c2.call(item);
5580
6121
  } catch {
5581
6122
  }
5582
6123
  }
@@ -5601,14 +6142,14 @@
5601
6142
  this.markTemplateChanged(HISTORY_ALIGN);
5602
6143
  }
5603
6144
  clearPanel() {
5604
- var _a;
5605
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
6145
+ var _a2;
6146
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5606
6147
  if (!panel) return;
5607
6148
  const list = (panel.printElements ?? []).slice();
5608
6149
  list.forEach((el) => {
5609
- var _a2;
6150
+ var _a3;
5610
6151
  try {
5611
- (_a2 = panel.deletePrintElement) == null ? void 0 : _a2.call(panel, el);
6152
+ (_a3 = panel.deletePrintElement) == null ? void 0 : _a3.call(panel, el);
5612
6153
  } catch (_) {
5613
6154
  }
5614
6155
  });
@@ -5860,14 +6401,14 @@
5860
6401
  });
5861
6402
  }
5862
6403
  vueDemi.onMounted(() => {
5863
- var _a;
6404
+ var _a2;
5864
6405
  const scroller = opts.scrollerEl();
5865
6406
  scrollHandler = () => schedule();
5866
6407
  scroller == null ? void 0 : scroller.addEventListener("scroll", scrollHandler, { passive: true });
5867
6408
  if (typeof ResizeObserver !== "undefined") {
5868
6409
  resizeObserver = new ResizeObserver(() => schedule());
5869
6410
  if (scroller) resizeObserver.observe(scroller);
5870
- const workspace = (_a = opts.workspaceEl) == null ? void 0 : _a.call(opts);
6411
+ const workspace = (_a2 = opts.workspaceEl) == null ? void 0 : _a2.call(opts);
5871
6412
  if (workspace) resizeObserver.observe(workspace);
5872
6413
  const host = document.getElementById(DESIGN_CONTAINER_ID);
5873
6414
  if (host) resizeObserver.observe(host);
@@ -7819,12 +8360,12 @@ ${lines.join("\n")}
7819
8360
  const _hoisted_5$a = { class: "svp-header__center" };
7820
8361
  const _hoisted_6$6 = ["title"];
7821
8362
  const _hoisted_7$6 = ["title"];
7822
- const _hoisted_8$4 = ["title"];
7823
- const _hoisted_9$3 = ["title"];
7824
- const _hoisted_10$2 = ["title"];
7825
- const _hoisted_11$1 = ["title"];
7826
- const _hoisted_12$1 = ["title", "onClick"];
7827
- const _hoisted_13$1 = { class: "svp-header__aside svp-header__aside--right" };
8363
+ const _hoisted_8$5 = ["title"];
8364
+ const _hoisted_9$4 = ["title"];
8365
+ const _hoisted_10$3 = ["title"];
8366
+ const _hoisted_11$2 = ["title"];
8367
+ const _hoisted_12$2 = ["title", "onClick"];
8368
+ const _hoisted_13$2 = { class: "svp-header__aside svp-header__aside--right" };
7828
8369
  function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
7829
8370
  const _component_SvpIcon = Vue.resolveComponent("SvpIcon");
7830
8371
  return Vue.openBlock(), Vue.createElementBlock("header", _hoisted_1$c, [
@@ -7875,7 +8416,7 @@ ${lines.join("\n")}
7875
8416
  size: 22
7876
8417
  }, null, 8, ["icon"]),
7877
8418
  Vue.createElementVNode("span", null, Vue.toDisplayString(_ctx.t("designer.exportFile")), 1)
7878
- ], 8, _hoisted_8$4),
8419
+ ], 8, _hoisted_8$5),
7879
8420
  Vue.createElementVNode("button", {
7880
8421
  type: "button",
7881
8422
  class: "svp-header__menu",
@@ -7887,7 +8428,7 @@ ${lines.join("\n")}
7887
8428
  size: 22
7888
8429
  }, null, 8, ["icon"]),
7889
8430
  Vue.createElementVNode("span", null, Vue.toDisplayString(_ctx.t("designer.importFile")), 1)
7890
- ], 8, _hoisted_9$3),
8431
+ ], 8, _hoisted_9$4),
7891
8432
  Vue.createElementVNode("button", {
7892
8433
  type: "button",
7893
8434
  class: "svp-header__menu",
@@ -7899,7 +8440,7 @@ ${lines.join("\n")}
7899
8440
  size: 22
7900
8441
  }, null, 8, ["icon"]),
7901
8442
  Vue.createElementVNode("span", null, Vue.toDisplayString(_ctx.t("designer.save")), 1)
7902
- ], 8, _hoisted_10$2),
8443
+ ], 8, _hoisted_10$3),
7903
8444
  Vue.createElementVNode("button", {
7904
8445
  type: "button",
7905
8446
  class: "svp-header__menu",
@@ -7911,7 +8452,7 @@ ${lines.join("\n")}
7911
8452
  size: 22
7912
8453
  }, null, 8, ["icon"]),
7913
8454
  Vue.createElementVNode("span", null, Vue.toDisplayString(_ctx.t("designer.preview")), 1)
7914
- ], 8, _hoisted_11$1),
8455
+ ], 8, _hoisted_11$2),
7915
8456
  _ctx.showElementBar ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
7916
8457
  _cache[6] || (_cache[6] = Vue.createElementVNode("span", {
7917
8458
  class: "svp-header__divider",
@@ -7931,12 +8472,12 @@ ${lines.join("\n")}
7931
8472
  size: 18
7932
8473
  }, null, 8, ["icon"])) : Vue.createCommentVNode("", true),
7933
8474
  Vue.createElementVNode("span", null, Vue.toDisplayString(item.label), 1)
7934
- ], 8, _hoisted_12$1);
8475
+ ], 8, _hoisted_12$2);
7935
8476
  }), 128))
7936
8477
  ], 64)) : Vue.createCommentVNode("", true)
7937
8478
  ])
7938
8479
  ]),
7939
- Vue.createElementVNode("div", _hoisted_13$1, [
8480
+ Vue.createElementVNode("div", _hoisted_13$2, [
7940
8481
  Vue.renderSlot(_ctx.$slots, "right")
7941
8482
  ])
7942
8483
  ]);
@@ -7980,8 +8521,8 @@ ${lines.join("\n")}
7980
8521
  designerStore.lang = next;
7981
8522
  }
7982
8523
  function onToolbarMouseDown(e) {
7983
- var _a;
7984
- if ((_a = e.target) == null ? void 0 : _a.closest("button")) {
8524
+ var _a2;
8525
+ if ((_a2 = e.target) == null ? void 0 : _a2.closest("button")) {
7985
8526
  e.preventDefault();
7986
8527
  }
7987
8528
  }
@@ -8191,105 +8732,210 @@ ${lines.join("\n")}
8191
8732
  ], 32);
8192
8733
  }
8193
8734
  const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
8194
- function resolvePreviewHtml(value) {
8195
- if (value == null || value === false) return "";
8196
- if (typeof value === "string") return value;
8197
- const any = value;
8198
- if (typeof any.html === "function") {
8199
- try {
8200
- const html = any.html();
8201
- if (typeof html === "string") return html;
8202
- } catch {
8203
- }
8204
- }
8205
- if (Array.isArray(value)) {
8206
- return value.map((item) => resolvePreviewHtml(item)).join("");
8207
- }
8208
- if (typeof any.length === "number" && any.length > 0 && any[0] != null) {
8209
- return resolvePreviewHtml(any[0]);
8210
- }
8211
- if (any.target != null) {
8212
- return resolvePreviewHtml(any.target);
8213
- }
8214
- return "";
8215
- }
8216
8735
  const _sfc_main$a = vueDemi.defineComponent({
8217
8736
  name: "SvpPreview",
8218
8737
  props: {
8219
8738
  options: { type: Object, default: () => ({}) }
8220
8739
  },
8221
8740
  setup(props, { expose }) {
8741
+ var _a2;
8222
8742
  const { t } = useI18n();
8223
8743
  const utils = useDesigner();
8224
8744
  const visible = vueDemi.ref(false);
8225
8745
  const html = vueDemi.ref("");
8226
- const opts = vueDemi.reactive({ showPdf: true, showImg: true, showPrint2: true, ...props.options });
8746
+ const opts = vueDemi.reactive({
8747
+ showPdf: true,
8748
+ showImg: true,
8749
+ showBrowserPrint: true,
8750
+ showPrint2: false,
8751
+ showBatchPrint: true,
8752
+ showPrintClient: false,
8753
+ ...props.options
8754
+ });
8755
+ const clientStatus = vueDemi.ref({ connected: false });
8756
+ const printers = vueDemi.ref([]);
8757
+ const selectedPrinter = vueDemi.ref("");
8758
+ const connecting = vueDemi.ref(false);
8759
+ const batchCopies = vueDemi.ref(Math.max(1, Math.floor(((_a2 = props.options) == null ? void 0 : _a2.defaultCopies) ?? 1)));
8760
+ const batchPrinting = vueDemi.ref(false);
8227
8761
  const tpl = vueDemi.computed(() => utils.printTemplate);
8228
8762
  const canExportPdf = vueDemi.computed(() => {
8229
- var _a;
8763
+ var _a3;
8230
8764
  if (opts.showPdf === false) return false;
8231
- return typeof ((_a = tpl.value) == null ? void 0 : _a.toPdf) === "function";
8765
+ return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toPdf) === "function";
8232
8766
  });
8233
8767
  const canExportImage = vueDemi.computed(() => {
8234
- var _a;
8768
+ var _a3;
8235
8769
  if (opts.showImg === false) return false;
8236
- return typeof ((_a = tpl.value) == null ? void 0 : _a.toImage) === "function";
8770
+ return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toImage) === "function";
8237
8771
  });
8238
- const canPrint = vueDemi.computed(() => {
8239
- var _a;
8240
- if (opts.showPrint2 === false) return false;
8241
- return typeof ((_a = tpl.value) == null ? void 0 : _a.print) === "function";
8772
+ const canBrowserPrint = vueDemi.computed(() => {
8773
+ var _a3;
8774
+ if (opts.showBrowserPrint === false) return false;
8775
+ return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.print) === "function";
8242
8776
  });
8777
+ const canSilentPrint = vueDemi.computed(() => {
8778
+ var _a3;
8779
+ if (opts.showPrint2 === false || opts.showSilentPrint === false) return false;
8780
+ return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.print2) === "function";
8781
+ });
8782
+ const showPrintClientBar = vueDemi.computed(() => {
8783
+ if (opts.showPrintClient === true) return true;
8784
+ return canSilentPrint.value;
8785
+ });
8786
+ const canBatchPrint = vueDemi.computed(() => {
8787
+ var _a3;
8788
+ if (opts.showBatchPrint === false) return false;
8789
+ return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.getHtml) === "function";
8790
+ });
8791
+ const batchDataRows = vueDemi.computed(() => {
8792
+ const data2 = utils.printData;
8793
+ if (Array.isArray(data2)) return data2.length;
8794
+ return data2 == null ? 0 : 1;
8795
+ });
8796
+ const batchTotalPages = vueDemi.computed(() => {
8797
+ const copies = Math.max(1, Math.floor(batchCopies.value || 1));
8798
+ return batchDataRows.value * copies;
8799
+ });
8800
+ const batchHintText = vueDemi.computed(() => {
8801
+ const template = t("designer.batchHint");
8802
+ return template.replace("{rows}", String(batchDataRows.value)).replace("{total}", String(batchTotalPages.value));
8803
+ });
8804
+ function formatPrinterLabel(printer) {
8805
+ const label = printer.displayName || printer.name;
8806
+ return printer.isDefault ? `${label} (${t("designer.defaultPrinter")})` : label;
8807
+ }
8808
+ function syncDefaultPrinter(list) {
8809
+ if (!list.length) {
8810
+ selectedPrinter.value = "";
8811
+ return;
8812
+ }
8813
+ if (selectedPrinter.value && list.some((item) => item.name === selectedPrinter.value)) {
8814
+ return;
8815
+ }
8816
+ const fallback = list.find((item) => item.isDefault) ?? list[0];
8817
+ selectedPrinter.value = (fallback == null ? void 0 : fallback.name) ?? "";
8818
+ }
8819
+ function refreshClientState() {
8820
+ clientStatus.value = utils.getPrintClientStatus();
8821
+ if (!clientStatus.value.connected) {
8822
+ printers.value = [];
8823
+ return;
8824
+ }
8825
+ printers.value = utils.getPrinterList();
8826
+ syncDefaultPrinter(printers.value);
8827
+ }
8243
8828
  function open(content) {
8244
- var _a, _b;
8245
- const raw = content !== void 0 ? content : (_b = (_a = tpl.value) == null ? void 0 : _a.getHtml) == null ? void 0 : _b.call(_a, utils.printData);
8829
+ var _a3, _b2;
8830
+ const raw = content !== void 0 ? content : (_b2 = (_a3 = tpl.value) == null ? void 0 : _a3.getHtml) == null ? void 0 : _b2.call(_a3, utils.printData);
8246
8831
  html.value = resolvePreviewHtml(raw);
8247
8832
  visible.value = true;
8833
+ refreshClientState();
8248
8834
  utils.plugins.run("onPreview", html.value, utils).catch(() => {
8249
8835
  });
8250
8836
  }
8251
8837
  function close() {
8252
8838
  visible.value = false;
8253
8839
  }
8840
+ async function toggleConnect() {
8841
+ if (connecting.value) return;
8842
+ connecting.value = true;
8843
+ try {
8844
+ if (clientStatus.value.connected) {
8845
+ await new Promise((resolve) => {
8846
+ utils.setConnect(false, () => resolve());
8847
+ });
8848
+ } else {
8849
+ await new Promise((resolve) => {
8850
+ utils.setConnect(true, () => resolve());
8851
+ });
8852
+ }
8853
+ refreshClientState();
8854
+ } finally {
8855
+ connecting.value = false;
8856
+ }
8857
+ }
8254
8858
  async function onPrint() {
8255
- var _a, _b;
8859
+ var _a3, _b2;
8256
8860
  await utils.plugins.run("beforePrint", tpl.value, utils);
8257
8861
  try {
8258
- (_b = (_a = tpl.value) == null ? void 0 : _a.print) == null ? void 0 : _b.call(_a, utils.printData);
8862
+ (_b2 = (_a3 = tpl.value) == null ? void 0 : _a3.print) == null ? void 0 : _b2.call(_a3, utils.printData);
8863
+ } catch (e) {
8864
+ console.error(e);
8865
+ }
8866
+ }
8867
+ async function onSilentPrint() {
8868
+ const results = await utils.plugins.run("beforePrint2", tpl.value, utils, "silent");
8869
+ if (results.some((r) => r === false)) return;
8870
+ try {
8871
+ await utils.print2(utils.printData, {
8872
+ printer: selectedPrinter.value,
8873
+ title: t("designer.silentPrint")
8874
+ });
8259
8875
  } catch (e) {
8260
8876
  console.error(e);
8261
8877
  }
8262
8878
  }
8263
8879
  async function onPdf() {
8264
- var _a;
8880
+ var _a3;
8265
8881
  const results = await utils.plugins.run("beforePrint2", tpl.value, utils, "pdf");
8266
8882
  if (results.some((r) => r === false)) return;
8267
8883
  try {
8268
- if (typeof ((_a = tpl.value) == null ? void 0 : _a.toPdf) === "function") tpl.value.toPdf(utils.printData);
8884
+ if (typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toPdf) === "function") tpl.value.toPdf(utils.printData);
8269
8885
  } catch (e) {
8270
8886
  console.error(e);
8271
8887
  }
8272
8888
  }
8273
8889
  async function onImage() {
8274
- var _a;
8890
+ var _a3;
8275
8891
  const results = await utils.plugins.run("beforePrint2", tpl.value, utils, "image");
8276
8892
  if (results.some((r) => r === false)) return;
8277
8893
  try {
8278
- if (typeof ((_a = tpl.value) == null ? void 0 : _a.toImage) === "function") tpl.value.toImage(utils.printData);
8894
+ if (typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toImage) === "function") tpl.value.toImage(utils.printData);
8279
8895
  } catch (e) {
8280
8896
  console.error(e);
8281
8897
  }
8282
8898
  }
8899
+ async function onBatchPrint() {
8900
+ if (batchPrinting.value) return;
8901
+ const data2 = utils.printData;
8902
+ const list = Array.isArray(data2) ? data2 : [data2];
8903
+ if (!list.length) return;
8904
+ const copies = Math.max(1, Math.floor(batchCopies.value || 1));
8905
+ batchPrinting.value = true;
8906
+ try {
8907
+ await utils.batchPrint(list, { copies, title: t("designer.batchPrint") });
8908
+ } catch (e) {
8909
+ console.error(e);
8910
+ } finally {
8911
+ batchPrinting.value = false;
8912
+ }
8913
+ }
8283
8914
  expose({ open, close });
8284
8915
  return {
8285
8916
  t,
8286
8917
  visible,
8287
8918
  html,
8919
+ clientStatus,
8920
+ printers,
8921
+ selectedPrinter,
8922
+ batchCopies,
8923
+ batchPrinting,
8924
+ batchDataRows,
8925
+ batchTotalPages,
8926
+ batchHintText,
8288
8927
  canExportPdf,
8289
8928
  canExportImage,
8290
- canPrint,
8929
+ canBrowserPrint,
8930
+ canSilentPrint,
8931
+ canBatchPrint,
8932
+ showPrintClientBar,
8933
+ formatPrinterLabel,
8291
8934
  close,
8935
+ toggleConnect,
8292
8936
  onPrint,
8937
+ onSilentPrint,
8938
+ onBatchPrint,
8293
8939
  onPdf,
8294
8940
  onImage
8295
8941
  };
@@ -8304,12 +8950,28 @@ ${lines.join("\n")}
8304
8950
  key: 1,
8305
8951
  class: "svp-preview__empty"
8306
8952
  };
8307
- const _hoisted_7$4 = { class: "svp-dialog__footer svp-preview__footer" };
8953
+ const _hoisted_7$4 = {
8954
+ key: 0,
8955
+ class: "svp-preview__print-bar"
8956
+ };
8957
+ const _hoisted_8$4 = ["value"];
8958
+ const _hoisted_9$3 = {
8959
+ key: 1,
8960
+ class: "svp-preview__printer-empty"
8961
+ };
8962
+ const _hoisted_10$2 = {
8963
+ key: 1,
8964
+ class: "svp-preview__print-bar svp-preview__batch-bar"
8965
+ };
8966
+ const _hoisted_11$1 = { class: "svp-preview__batch-label" };
8967
+ const _hoisted_12$1 = { class: "svp-preview__batch-hint" };
8968
+ const _hoisted_13$1 = { class: "svp-dialog__footer svp-preview__footer" };
8969
+ const _hoisted_14$1 = ["disabled"];
8308
8970
  function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
8309
8971
  return _ctx.visible ? (Vue.openBlock(), Vue.createElementBlock("div", {
8310
8972
  key: 0,
8311
8973
  class: "svp-dialog-mask",
8312
- onClick: _cache[5] || (_cache[5] = Vue.withModifiers((...args) => _ctx.close && _ctx.close(...args), ["self"]))
8974
+ onClick: _cache[10] || (_cache[10] = Vue.withModifiers((...args) => _ctx.close && _ctx.close(...args), ["self"]))
8313
8975
  }, [
8314
8976
  Vue.createElementVNode("div", _hoisted_1$a, [
8315
8977
  Vue.createElementVNode("div", _hoisted_2$9, [
@@ -8328,29 +8990,86 @@ ${lines.join("\n")}
8328
8990
  innerHTML: _ctx.html
8329
8991
  }, null, 8, _hoisted_5$8)) : (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_6$4, Vue.toDisplayString(_ctx.t("panel.empty")), 1))
8330
8992
  ]),
8331
- Vue.createElementVNode("div", _hoisted_7$4, [
8332
- _ctx.canExportPdf ? (Vue.openBlock(), Vue.createElementBlock("button", {
8993
+ _ctx.showPrintClientBar ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_7$4, [
8994
+ Vue.createElementVNode("span", {
8995
+ class: Vue.normalizeClass(["svp-preview__status", { "is-connected": _ctx.clientStatus.connected }])
8996
+ }, Vue.toDisplayString(_ctx.clientStatus.connected ? _ctx.t("designer.printClientConnected") : _ctx.t("designer.printClientDisconnected")), 3),
8997
+ Vue.createElementVNode("button", {
8998
+ type: "button",
8999
+ class: "svp-btn",
9000
+ onClick: _cache[1] || (_cache[1] = (...args) => _ctx.toggleConnect && _ctx.toggleConnect(...args))
9001
+ }, Vue.toDisplayString(_ctx.clientStatus.connected ? _ctx.t("designer.printClientDisconnect") : _ctx.t("designer.printClientConnect")), 1),
9002
+ _ctx.clientStatus.connected && _ctx.printers.length ? Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("select", {
8333
9003
  key: 0,
9004
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.selectedPrinter = $event),
9005
+ class: "svp-preview__printer-select"
9006
+ }, [
9007
+ (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(_ctx.printers, (printer) => {
9008
+ return Vue.openBlock(), Vue.createElementBlock("option", {
9009
+ key: printer.name,
9010
+ value: printer.name
9011
+ }, Vue.toDisplayString(_ctx.formatPrinterLabel(printer)), 9, _hoisted_8$4);
9012
+ }), 128))
9013
+ ], 512)), [
9014
+ [Vue.vModelSelect, _ctx.selectedPrinter]
9015
+ ]) : _ctx.clientStatus.connected ? (Vue.openBlock(), Vue.createElementBlock("span", _hoisted_9$3, Vue.toDisplayString(_ctx.t("designer.printClientNoPrinters")), 1)) : Vue.createCommentVNode("", true)
9016
+ ])) : Vue.createCommentVNode("", true),
9017
+ _ctx.canBatchPrint ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_10$2, [
9018
+ Vue.createElementVNode("label", _hoisted_11$1, [
9019
+ Vue.createTextVNode(Vue.toDisplayString(_ctx.t("designer.batchCopies")) + " ", 1),
9020
+ Vue.withDirectives(Vue.createElementVNode("input", {
9021
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.batchCopies = $event),
9022
+ type: "number",
9023
+ min: "1",
9024
+ max: "999",
9025
+ class: "svp-preview__batch-input"
9026
+ }, null, 512), [
9027
+ [
9028
+ Vue.vModelText,
9029
+ _ctx.batchCopies,
9030
+ void 0,
9031
+ { number: true }
9032
+ ]
9033
+ ])
9034
+ ]),
9035
+ Vue.createElementVNode("span", _hoisted_12$1, Vue.toDisplayString(_ctx.batchHintText), 1)
9036
+ ])) : Vue.createCommentVNode("", true),
9037
+ Vue.createElementVNode("div", _hoisted_13$1, [
9038
+ _ctx.canBatchPrint ? (Vue.openBlock(), Vue.createElementBlock("button", {
9039
+ key: 0,
9040
+ type: "button",
9041
+ class: "svp-btn is-primary",
9042
+ disabled: _ctx.batchPrinting,
9043
+ onClick: _cache[4] || (_cache[4] = (...args) => _ctx.onBatchPrint && _ctx.onBatchPrint(...args))
9044
+ }, Vue.toDisplayString(_ctx.batchPrinting ? _ctx.t("designer.batchPrinting") : _ctx.t("designer.batchPrint")), 9, _hoisted_14$1)) : Vue.createCommentVNode("", true),
9045
+ _ctx.canSilentPrint ? (Vue.openBlock(), Vue.createElementBlock("button", {
9046
+ key: 1,
9047
+ type: "button",
9048
+ class: "svp-btn",
9049
+ onClick: _cache[5] || (_cache[5] = (...args) => _ctx.onSilentPrint && _ctx.onSilentPrint(...args))
9050
+ }, Vue.toDisplayString(_ctx.t("designer.silentPrint")), 1)) : Vue.createCommentVNode("", true),
9051
+ _ctx.canBrowserPrint ? (Vue.openBlock(), Vue.createElementBlock("button", {
9052
+ key: 2,
9053
+ type: "button",
9054
+ class: "svp-btn",
9055
+ onClick: _cache[6] || (_cache[6] = (...args) => _ctx.onPrint && _ctx.onPrint(...args))
9056
+ }, Vue.toDisplayString(_ctx.t("designer.browserPrint")), 1)) : Vue.createCommentVNode("", true),
9057
+ _ctx.canExportPdf ? (Vue.openBlock(), Vue.createElementBlock("button", {
9058
+ key: 3,
8334
9059
  type: "button",
8335
9060
  class: "svp-btn",
8336
- onClick: _cache[1] || (_cache[1] = (...args) => _ctx.onPdf && _ctx.onPdf(...args))
9061
+ onClick: _cache[7] || (_cache[7] = (...args) => _ctx.onPdf && _ctx.onPdf(...args))
8337
9062
  }, Vue.toDisplayString(_ctx.t("designer.pdf")), 1)) : Vue.createCommentVNode("", true),
8338
9063
  _ctx.canExportImage ? (Vue.openBlock(), Vue.createElementBlock("button", {
8339
- key: 1,
9064
+ key: 4,
8340
9065
  type: "button",
8341
9066
  class: "svp-btn",
8342
- onClick: _cache[2] || (_cache[2] = (...args) => _ctx.onImage && _ctx.onImage(...args))
9067
+ onClick: _cache[8] || (_cache[8] = (...args) => _ctx.onImage && _ctx.onImage(...args))
8343
9068
  }, Vue.toDisplayString(_ctx.t("designer.image")), 1)) : Vue.createCommentVNode("", true),
8344
- _ctx.canPrint ? (Vue.openBlock(), Vue.createElementBlock("button", {
8345
- key: 2,
8346
- type: "button",
8347
- class: "svp-btn is-primary",
8348
- onClick: _cache[3] || (_cache[3] = (...args) => _ctx.onPrint && _ctx.onPrint(...args))
8349
- }, Vue.toDisplayString(_ctx.t("designer.print")), 1)) : Vue.createCommentVNode("", true),
8350
9069
  Vue.createElementVNode("button", {
8351
9070
  type: "button",
8352
9071
  class: "svp-btn",
8353
- onClick: _cache[4] || (_cache[4] = (...args) => _ctx.close && _ctx.close(...args))
9072
+ onClick: _cache[9] || (_cache[9] = (...args) => _ctx.close && _ctx.close(...args))
8354
9073
  }, Vue.toDisplayString(_ctx.t("designer.cancel")), 1)
8355
9074
  ])
8356
9075
  ])
@@ -8443,10 +9162,10 @@ ${lines.join("\n")}
8443
9162
  if (ta && lines) lines.scrollTop = ta.scrollTop;
8444
9163
  }
8445
9164
  function doClear() {
8446
- var _a;
9165
+ var _a2;
8447
9166
  text.value = variant.value === "template" ? JSON.stringify(EMPTY_TEMPLATE_JSON, null, 2) : "{}";
8448
9167
  error.value = "";
8449
- (_a = textareaRef.value) == null ? void 0 : _a.focus();
9168
+ (_a2 = textareaRef.value) == null ? void 0 : _a2.focus();
8450
9169
  }
8451
9170
  async function doCopy() {
8452
9171
  try {
@@ -8997,25 +9716,25 @@ ${lines.join("\n")}
8997
9716
  },
8998
9717
  emits: ["update:visible", "close"],
8999
9718
  setup(props, { emit }) {
9000
- var _a, _b;
9719
+ var _a2, _b2;
9001
9720
  const boxRef = vueDemi.ref(null);
9002
9721
  const { t } = useI18n();
9003
9722
  const designerUi = useDesignerUi();
9004
9723
  const styleOverrides = vueDemi.computed(() => props.styleOptionKey ? resolvePanelDragBoxOptions(props.styleOptionKey, designerUi == null ? void 0 : designerUi.styleOption.value) : null);
9005
9724
  const resolvedTitle = vueDemi.computed(() => {
9006
- var _a2;
9007
- return ((_a2 = styleOverrides.value) == null ? void 0 : _a2.title) || props.title;
9725
+ var _a3;
9726
+ return ((_a3 = styleOverrides.value) == null ? void 0 : _a3.title) || props.title;
9008
9727
  });
9009
9728
  const draggable = vueDemi.computed(() => {
9010
- var _a2;
9011
- return ((_a2 = styleOverrides.value) == null ? void 0 : _a2.draggable) ?? true;
9729
+ var _a3;
9730
+ return ((_a3 = styleOverrides.value) == null ? void 0 : _a3.draggable) ?? true;
9012
9731
  });
9013
9732
  const showFold = vueDemi.computed(() => props.foldable);
9014
9733
  const showClose = vueDemi.computed(() => props.closable ?? !!props.panelKey);
9015
9734
  const dragBoxOptions = vueDemi.reactive({
9016
9735
  key: props.storageKey || void 0,
9017
- layoutKey: ((_a = styleOverrides.value) == null ? void 0 : _a.layoutKey) || props.layoutKey || void 0,
9018
- layoutSpec: (_b = styleOverrides.value) == null ? void 0 : _b.layoutSpec,
9736
+ layoutKey: ((_a2 = styleOverrides.value) == null ? void 0 : _a2.layoutKey) || props.layoutKey || void 0,
9737
+ layoutSpec: (_b2 = styleOverrides.value) == null ? void 0 : _b2.layoutSpec,
9019
9738
  defaultX: props.defaultX,
9020
9739
  defaultY: props.defaultY,
9021
9740
  defaultWidth: props.width,
@@ -9032,8 +9751,8 @@ ${lines.join("\n")}
9032
9751
  }, { immediate: true });
9033
9752
  vueDemi.watch(
9034
9753
  () => {
9035
- var _a2;
9036
- return (_a2 = styleOverrides.value) == null ? void 0 : _a2.layoutSpec;
9754
+ var _a3;
9755
+ return (_a3 = styleOverrides.value) == null ? void 0 : _a3.layoutSpec;
9037
9756
  },
9038
9757
  (spec) => {
9039
9758
  dragBoxOptions.layoutSpec = spec;
@@ -9041,8 +9760,8 @@ ${lines.join("\n")}
9041
9760
  );
9042
9761
  vueDemi.watch(
9043
9762
  () => {
9044
- var _a2;
9045
- return (_a2 = styleOverrides.value) == null ? void 0 : _a2.layoutKey;
9763
+ var _a3;
9764
+ return (_a3 = styleOverrides.value) == null ? void 0 : _a3.layoutKey;
9046
9765
  },
9047
9766
  (key) => {
9048
9767
  dragBoxOptions.layoutKey = key || props.layoutKey || void 0;
@@ -9066,8 +9785,8 @@ ${lines.join("\n")}
9066
9785
  }
9067
9786
  );
9068
9787
  const boxStyle = vueDemi.computed(() => {
9069
- var _a2;
9070
- const extra = { ...((_a2 = styleOverrides.value) == null ? void 0 : _a2.boxStyleExtra) ?? {} };
9788
+ var _a3;
9789
+ const extra = { ...((_a3 = styleOverrides.value) == null ? void 0 : _a3.boxStyleExtra) ?? {} };
9071
9790
  const isFixed = extra.position === "fixed";
9072
9791
  if (!isFixed) {
9073
9792
  delete extra.left;
@@ -9084,11 +9803,11 @@ ${lines.join("\n")}
9084
9803
  };
9085
9804
  });
9086
9805
  const bodyStyle = vueDemi.computed(() => {
9087
- var _a2;
9806
+ var _a3;
9088
9807
  return {
9089
9808
  padding: props.bodyPadding || void 0,
9090
9809
  ...props.bodyStyleExtra,
9091
- ...(_a2 = styleOverrides.value) == null ? void 0 : _a2.bodyStyleExtra
9810
+ ...(_a3 = styleOverrides.value) == null ? void 0 : _a3.bodyStyleExtra
9092
9811
  };
9093
9812
  });
9094
9813
  function onClose() {
@@ -9311,11 +10030,11 @@ ${lines.join("\n")}
9311
10030
  });
9312
10031
  }
9313
10032
  function refresh() {
9314
- var _a;
10033
+ var _a2;
9315
10034
  const map = miniMapRef.value;
9316
10035
  const host = document.getElementById(DESIGN_CONTAINER_ID);
9317
10036
  const scroller = host == null ? void 0 : host.parentElement;
9318
- const paper = (_a = host == null ? void 0 : host.querySelector) == null ? void 0 : _a.call(host, ".hiprint-printPaper");
10037
+ const paper = (_a2 = host == null ? void 0 : host.querySelector) == null ? void 0 : _a2.call(host, ".hiprint-printPaper");
9319
10038
  if (!map || !scroller || !paper) return;
9320
10039
  const mapW = map.clientWidth;
9321
10040
  const mapH = map.clientHeight;
@@ -9795,10 +10514,10 @@ ${lines.join("\n")}
9795
10514
  }
9796
10515
  };
9797
10516
  const activeTheme = vueDemi.computed(() => {
9798
- var _a, _b;
10517
+ var _a2, _b2;
9799
10518
  if (typeof props.theme === "string") return props.theme;
9800
- if (Array.isArray(props.theme)) return ((_a = props.theme[0]) == null ? void 0 : _a.theme) || "svpLight";
9801
- return ((_b = props.theme) == null ? void 0 : _b.theme) || "svpLight";
10519
+ if (Array.isArray(props.theme)) return ((_a2 = props.theme[0]) == null ? void 0 : _a2.theme) || "svpLight";
10520
+ return ((_b2 = props.theme) == null ? void 0 : _b2.theme) || "svpLight";
9802
10521
  });
9803
10522
  const { redraw: redrawRuler } = useRuler({
9804
10523
  canvasX: () => rulerXRef.value,
@@ -9815,9 +10534,9 @@ ${lines.join("\n")}
9815
10534
  return Array.isArray(json) && json.length > 0;
9816
10535
  }
9817
10536
  function resolveInitialTemplate() {
9818
- var _a;
10537
+ var _a2;
9819
10538
  if (templateHasPanels(props.template)) return props.template;
9820
- const saved = (_a = utils.loadSaved) == null ? void 0 : _a.call(utils);
10539
+ const saved = (_a2 = utils.loadSaved) == null ? void 0 : _a2.call(utils);
9821
10540
  if (saved && templateHasPanels(saved)) return saved;
9822
10541
  return props.template;
9823
10542
  }
@@ -9844,7 +10563,7 @@ ${lines.join("\n")}
9844
10563
  applyStyleOption(props.styleOption);
9845
10564
  }
9846
10565
  function buildDesigner() {
9847
- var _a;
10566
+ var _a2;
9848
10567
  utils.newDesigner(
9849
10568
  {
9850
10569
  template: resolveInitialTemplate(),
@@ -9861,13 +10580,13 @@ ${lines.join("\n")}
9861
10580
  utils.plugins.run("onDesigned", payload).catch(() => {
9862
10581
  });
9863
10582
  utils.setPreview(previewRef.value);
9864
- if ((_a = props.designOptions) == null ? void 0 : _a.adaptToSize) {
10583
+ if ((_a2 = props.designOptions) == null ? void 0 : _a2.adaptToSize) {
9865
10584
  requestAnimationFrame(() => utils.adaptToSize());
9866
10585
  }
9867
10586
  }
9868
10587
  let resizeHandler = null;
9869
10588
  vueDemi.onMounted(async () => {
9870
- var _a;
10589
+ var _a2;
9871
10590
  setLocale(props.lang);
9872
10591
  designerStore.lang = props.lang;
9873
10592
  designerStore.theme = activeTheme.value;
@@ -9883,10 +10602,13 @@ ${lines.join("\n")}
9883
10602
  utils.buildByHtml();
9884
10603
  } catch {
9885
10604
  }
9886
- if ((_a = props.designOptions) == null ? void 0 : _a.adaptToSize) {
10605
+ if ((_a2 = props.designOptions) == null ? void 0 : _a2.adaptToSize) {
9887
10606
  resizeHandler = () => utils.adaptToSize();
9888
10607
  window.addEventListener("resize", resizeHandler);
9889
10608
  }
10609
+ if (props.autoConnect) {
10610
+ utils.setConnect(true);
10611
+ }
9890
10612
  });
9891
10613
  vueDemi.onBeforeUnmount(() => {
9892
10614
  utils.shortcuts.unmount();
@@ -9925,8 +10647,8 @@ ${lines.join("\n")}
9925
10647
  utils.import();
9926
10648
  }
9927
10649
  function handlePreview() {
9928
- var _a, _b;
9929
- (_b = (_a = previewRef.value) == null ? void 0 : _a.open) == null ? void 0 : _b.call(_a);
10650
+ var _a2, _b2;
10651
+ (_b2 = (_a2 = previewRef.value) == null ? void 0 : _a2.open) == null ? void 0 : _b2.call(_a2);
9930
10652
  }
9931
10653
  return {
9932
10654
  DESIGN_CONTAINER_ID,
@@ -10094,7 +10816,7 @@ ${lines.join("\n")}
10094
10816
  }
10095
10817
  const Ruler = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
10096
10818
  const pluginApiPdf = (opts = {}) => {
10097
- const plugin = {
10819
+ const plugin2 = {
10098
10820
  name: "plugin-api-pdf",
10099
10821
  description: "Exports the current template as a PDF document.",
10100
10822
  config: { ...opts },
@@ -10128,10 +10850,10 @@ ${lines.join("\n")}
10128
10850
  }
10129
10851
  ]
10130
10852
  };
10131
- return plugin;
10853
+ return plugin2;
10132
10854
  };
10133
10855
  const pluginApiImage = (opts = {}) => {
10134
- const plugin = {
10856
+ const plugin2 = {
10135
10857
  name: "plugin-api-image",
10136
10858
  description: "Exports the current template as PNG / JPEG.",
10137
10859
  config: { type: "png", ...opts },
@@ -10158,7 +10880,7 @@ ${lines.join("\n")}
10158
10880
  }
10159
10881
  ]
10160
10882
  };
10161
- return plugin;
10883
+ return plugin2;
10162
10884
  };
10163
10885
  function defaultEditor(source, ctx) {
10164
10886
  return new Promise((resolve) => {
@@ -10199,7 +10921,7 @@ ${lines.join("\n")}
10199
10921
  }
10200
10922
  const pluginViewCodeEdit = (opts = {}) => {
10201
10923
  const editor = opts.editor ?? defaultEditor;
10202
- const plugin = {
10924
+ const plugin2 = {
10203
10925
  name: "plugin-view-code-edit",
10204
10926
  description: "Provides a small in-browser editor for `function` options.",
10205
10927
  config: { ...opts },
@@ -10209,18 +10931,18 @@ ${lines.join("\n")}
10209
10931
  name: "editor-create-print-element",
10210
10932
  priority: 100,
10211
10933
  run: async (option, _printElement, _ev) => {
10212
- var _a;
10934
+ var _a2;
10213
10935
  if (!option || typeof option !== "object") return;
10214
10936
  if (option.type !== "function" && option.editor !== "code") return;
10215
10937
  const next = await editor(String(option.value ?? ""), { name: option.name ?? "function" });
10216
10938
  if (next == null) return;
10217
10939
  option.value = next;
10218
- (_a = option == null ? void 0 : option.onChange) == null ? void 0 : _a.call(option, next);
10940
+ (_a2 = option == null ? void 0 : option.onChange) == null ? void 0 : _a2.call(option, next);
10219
10941
  }
10220
10942
  }
10221
10943
  ]
10222
10944
  };
10223
- return plugin;
10945
+ return plugin2;
10224
10946
  };
10225
10947
  const index = {
10226
10948
  install(app) {
@@ -10231,14 +10953,6 @@ ${lines.join("\n")}
10231
10953
  app.component("SvpDragBox", DragBox);
10232
10954
  }
10233
10955
  };
10234
- Object.defineProperty(exports2, "defaultElementTypeProvider", {
10235
- enumerable: true,
10236
- get: () => vuePluginHiprint.defaultElementTypeProvider
10237
- });
10238
- Object.defineProperty(exports2, "hiprint", {
10239
- enumerable: true,
10240
- get: () => vuePluginHiprint.hiprint
10241
- });
10242
10956
  exports2.DEFAULT_ELEMENT_CATALOGUE = DEFAULT_ELEMENT_CATALOGUE;
10243
10957
  exports2.DEFAULT_FONT_LIST = DEFAULT_FONT_LIST;
10244
10958
  exports2.DEFAULT_PAPER_LIST = DEFAULT_PAPER_LIST;
@@ -10273,6 +10987,7 @@ ${lines.join("\n")}
10273
10987
  exports2.PageStructurePanel = PageStructurePanel;
10274
10988
  exports2.PluginManager = PluginManager;
10275
10989
  exports2.Preview = Preview;
10990
+ exports2.PrintClient = PrintClient;
10276
10991
  exports2.PropertiesPanel = PropertiesPanel;
10277
10992
  exports2.Provider = Provider;
10278
10993
  exports2.Ruler = Ruler;
@@ -10288,16 +11003,22 @@ ${lines.join("\n")}
10288
11003
  exports2.ZOOM_MIN = ZOOM_MIN;
10289
11004
  exports2.ZOOM_STEP = ZOOM_STEP;
10290
11005
  exports2.applyStyleOption = applyStyleOption;
11006
+ exports2.autoConnect = autoConnect;
11007
+ exports2.batchPrint = batchPrint;
10291
11008
  exports2.buildByHtml = buildByHtml;
10292
11009
  exports2.buildPrintDataFromForm = buildPrintDataFromForm;
10293
11010
  exports2.createPrintDataFormState = createPrintDataFormState;
10294
11011
  exports2.default = index;
11012
+ exports2.defaultElementTypeProvider = defaultElementTypeProvider;
10295
11013
  exports2.designerStore = designerStore;
11014
+ exports2.disAutoConnect = disAutoConnect;
10296
11015
  exports2.elementTypeKey = elementTypeKey;
10297
11016
  exports2.enUS = enUS;
10298
11017
  exports2.extractTemplateFields = extractTemplateFields;
10299
11018
  exports2.getLocaleList = getLocaleList;
11019
+ exports2.getPrintClient = getPrintClient;
10300
11020
  exports2.headerElementsFromCatalogue = headerElementsFromCatalogue;
11021
+ exports2.hiprint = hiprint;
10301
11022
  exports2.iconForElement = iconForElement;
10302
11023
  exports2.iconForElementKey = iconForElementKey;
10303
11024
  exports2.iconForHeaderTab = iconForHeaderTab;