@formfeed/mcp 0.3.10 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/formfeed-mcp.mjs +1549 -358
  2. package/package.json +1 -1
@@ -914,7 +914,7 @@ var require_version_check = __commonJS({
914
914
  var require_regex = __commonJS({
915
915
  "node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"(exports) {
916
916
  "use strict";
917
- var numeric = "[0-9]+";
917
+ var numeric2 = "[0-9]+";
918
918
  var alphanumeric = "[A-Z $%*+\\-./:]+";
919
919
  var kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
920
920
  kanji = kanji.replace(/u/g, "\\u");
@@ -922,10 +922,10 @@ var require_regex = __commonJS({
922
922
  exports.KANJI = new RegExp(kanji, "g");
923
923
  exports.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
924
924
  exports.BYTE = new RegExp(byte, "g");
925
- exports.NUMERIC = new RegExp(numeric, "g");
925
+ exports.NUMERIC = new RegExp(numeric2, "g");
926
926
  exports.ALPHANUMERIC = new RegExp(alphanumeric, "g");
927
927
  var TEST_KANJI = new RegExp("^" + kanji + "$");
928
- var TEST_NUMERIC = new RegExp("^" + numeric + "$");
928
+ var TEST_NUMERIC = new RegExp("^" + numeric2 + "$");
929
929
  var TEST_ALPHANUMERIC = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
930
930
  exports.testKanji = function testKanji(str2) {
931
931
  return TEST_KANJI.test(str2);
@@ -4409,7 +4409,7 @@ var require_browser = __commonJS({
4409
4409
  var QRCode = require_qrcode();
4410
4410
  var CanvasRenderer = require_canvas();
4411
4411
  var SvgRenderer = require_svg_tag();
4412
- function renderCanvas(renderFunc, canvas, text2, opts, cb) {
4412
+ function renderCanvas(renderFunc, canvas, text4, opts, cb) {
4413
4413
  const args2 = [].slice.call(arguments, 1);
4414
4414
  const argsNum = args2.length;
4415
4415
  const isLastArgCb = typeof args2[argsNum - 1] === "function";
@@ -4421,8 +4421,8 @@ var require_browser = __commonJS({
4421
4421
  throw new Error("Too few arguments provided");
4422
4422
  }
4423
4423
  if (argsNum === 2) {
4424
- cb = text2;
4425
- text2 = canvas;
4424
+ cb = text4;
4425
+ text4 = canvas;
4426
4426
  canvas = opts = void 0;
4427
4427
  } else if (argsNum === 3) {
4428
4428
  if (canvas.getContext && typeof cb === "undefined") {
@@ -4430,8 +4430,8 @@ var require_browser = __commonJS({
4430
4430
  opts = void 0;
4431
4431
  } else {
4432
4432
  cb = opts;
4433
- opts = text2;
4434
- text2 = canvas;
4433
+ opts = text4;
4434
+ text4 = canvas;
4435
4435
  canvas = void 0;
4436
4436
  }
4437
4437
  }
@@ -4440,16 +4440,16 @@ var require_browser = __commonJS({
4440
4440
  throw new Error("Too few arguments provided");
4441
4441
  }
4442
4442
  if (argsNum === 1) {
4443
- text2 = canvas;
4443
+ text4 = canvas;
4444
4444
  canvas = opts = void 0;
4445
4445
  } else if (argsNum === 2 && !canvas.getContext) {
4446
- opts = text2;
4447
- text2 = canvas;
4446
+ opts = text4;
4447
+ text4 = canvas;
4448
4448
  canvas = void 0;
4449
4449
  }
4450
4450
  return new Promise(function(resolve2, reject) {
4451
4451
  try {
4452
- const data = QRCode.create(text2, opts);
4452
+ const data = QRCode.create(text4, opts);
4453
4453
  resolve2(renderFunc(data, canvas, opts));
4454
4454
  } catch (e) {
4455
4455
  reject(e);
@@ -4457,7 +4457,7 @@ var require_browser = __commonJS({
4457
4457
  });
4458
4458
  }
4459
4459
  try {
4460
- const data = QRCode.create(text2, opts);
4460
+ const data = QRCode.create(text4, opts);
4461
4461
  cb(null, renderFunc(data, canvas, opts));
4462
4462
  } catch (e) {
4463
4463
  cb(e);
@@ -4482,8 +4482,8 @@ var require_server = __commonJS({
4482
4482
  var Utf8Renderer = require_utf8();
4483
4483
  var TerminalRenderer = require_terminal2();
4484
4484
  var SvgRenderer = require_svg();
4485
- function checkParams(text2, opts, cb) {
4486
- if (typeof text2 === "undefined") {
4485
+ function checkParams(text4, opts, cb) {
4486
+ if (typeof text4 === "undefined") {
4487
4487
  throw new Error("String required as first argument");
4488
4488
  }
4489
4489
  if (typeof cb === "undefined") {
@@ -4530,11 +4530,11 @@ var require_server = __commonJS({
4530
4530
  return Utf8Renderer;
4531
4531
  }
4532
4532
  }
4533
- function render(renderFunc, text2, params) {
4533
+ function render(renderFunc, text4, params) {
4534
4534
  if (!params.cb) {
4535
4535
  return new Promise(function(resolve2, reject) {
4536
4536
  try {
4537
- const data = QRCode.create(text2, params.opts);
4537
+ const data = QRCode.create(text4, params.opts);
4538
4538
  return renderFunc(data, params.opts, function(err, data2) {
4539
4539
  return err ? reject(err) : resolve2(data2);
4540
4540
  });
@@ -4544,7 +4544,7 @@ var require_server = __commonJS({
4544
4544
  });
4545
4545
  }
4546
4546
  try {
4547
- const data = QRCode.create(text2, params.opts);
4547
+ const data = QRCode.create(text4, params.opts);
4548
4548
  return renderFunc(data, params.opts, params.cb);
4549
4549
  } catch (e) {
4550
4550
  params.cb(e);
@@ -4552,43 +4552,43 @@ var require_server = __commonJS({
4552
4552
  }
4553
4553
  exports.create = QRCode.create;
4554
4554
  exports.toCanvas = require_browser().toCanvas;
4555
- exports.toString = function toString2(text2, opts, cb) {
4556
- const params = checkParams(text2, opts, cb);
4555
+ exports.toString = function toString2(text4, opts, cb) {
4556
+ const params = checkParams(text4, opts, cb);
4557
4557
  const type = params.opts ? params.opts.type : void 0;
4558
4558
  const renderer = getStringRendererFromType(type);
4559
- return render(renderer.render, text2, params);
4559
+ return render(renderer.render, text4, params);
4560
4560
  };
4561
- exports.toDataURL = function toDataURL(text2, opts, cb) {
4562
- const params = checkParams(text2, opts, cb);
4561
+ exports.toDataURL = function toDataURL(text4, opts, cb) {
4562
+ const params = checkParams(text4, opts, cb);
4563
4563
  const renderer = getRendererFromType(params.opts.type);
4564
- return render(renderer.renderToDataURL, text2, params);
4564
+ return render(renderer.renderToDataURL, text4, params);
4565
4565
  };
4566
- exports.toBuffer = function toBuffer(text2, opts, cb) {
4567
- const params = checkParams(text2, opts, cb);
4566
+ exports.toBuffer = function toBuffer(text4, opts, cb) {
4567
+ const params = checkParams(text4, opts, cb);
4568
4568
  const renderer = getRendererFromType(params.opts.type);
4569
- return render(renderer.renderToBuffer, text2, params);
4569
+ return render(renderer.renderToBuffer, text4, params);
4570
4570
  };
4571
- exports.toFile = function toFile(path, text2, opts, cb) {
4572
- if (typeof path !== "string" || !(typeof text2 === "string" || typeof text2 === "object")) {
4571
+ exports.toFile = function toFile(path, text4, opts, cb) {
4572
+ if (typeof path !== "string" || !(typeof text4 === "string" || typeof text4 === "object")) {
4573
4573
  throw new Error("Invalid argument");
4574
4574
  }
4575
4575
  if (arguments.length < 3 && !canPromise()) {
4576
4576
  throw new Error("Too few arguments provided");
4577
4577
  }
4578
- const params = checkParams(text2, opts, cb);
4578
+ const params = checkParams(text4, opts, cb);
4579
4579
  const type = params.opts.type || getTypeFromFilename(path);
4580
4580
  const renderer = getRendererFromType(type);
4581
4581
  const renderToFile = renderer.renderToFile.bind(null, path);
4582
- return render(renderToFile, text2, params);
4582
+ return render(renderToFile, text4, params);
4583
4583
  };
4584
- exports.toFileStream = function toFileStream(stream, text2, opts) {
4584
+ exports.toFileStream = function toFileStream(stream, text4, opts) {
4585
4585
  if (arguments.length < 2) {
4586
4586
  throw new Error("Too few arguments provided");
4587
4587
  }
4588
- const params = checkParams(text2, opts, stream.emit.bind(stream, "error"));
4588
+ const params = checkParams(text4, opts, stream.emit.bind(stream, "error"));
4589
4589
  const renderer = getRendererFromType("png");
4590
4590
  const renderToFileStream = renderer.renderToFileStream.bind(null, stream);
4591
- render(renderToFileStream, text2, params);
4591
+ render(renderToFileStream, text4, params);
4592
4592
  };
4593
4593
  }
4594
4594
  });
@@ -4707,13 +4707,13 @@ var require_exception = __commonJS({
4707
4707
  exports.__esModule = true;
4708
4708
  var errorProps = ["description", "fileName", "lineNumber", "endLineNumber", "message", "name", "number", "stack"];
4709
4709
  function Exception(message2, node) {
4710
- var loc = node && node.loc, line = void 0, endLineNumber = void 0, column = void 0, endColumn = void 0;
4710
+ var loc = node && node.loc, line2 = void 0, endLineNumber = void 0, column = void 0, endColumn = void 0;
4711
4711
  if (loc) {
4712
- line = loc.start.line;
4712
+ line2 = loc.start.line;
4713
4713
  endLineNumber = loc.end.line;
4714
4714
  column = loc.start.column;
4715
4715
  endColumn = loc.end.column;
4716
- message2 += " - " + line + ":" + column;
4716
+ message2 += " - " + line2 + ":" + column;
4717
4717
  }
4718
4718
  var tmp = Error.prototype.constructor.call(this, message2);
4719
4719
  for (var idx = 0; idx < errorProps.length; idx++) {
@@ -4724,7 +4724,7 @@ var require_exception = __commonJS({
4724
4724
  }
4725
4725
  try {
4726
4726
  if (loc) {
4727
- this.lineNumber = line;
4727
+ this.lineNumber = line2;
4728
4728
  this.endLineNumber = endLineNumber;
4729
4729
  if (Object.defineProperty) {
4730
4730
  Object.defineProperty(this, "column", {
@@ -8428,10 +8428,10 @@ var require_source_map_consumer = __commonJS({
8428
8428
  }, this).forEach(aCallback, context);
8429
8429
  };
8430
8430
  SourceMapConsumer.prototype.allGeneratedPositionsFor = function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
8431
- var line = util.getArg(aArgs, "line");
8431
+ var line2 = util.getArg(aArgs, "line");
8432
8432
  var needle = {
8433
8433
  source: util.getArg(aArgs, "source"),
8434
- originalLine: line,
8434
+ originalLine: line2,
8435
8435
  originalColumn: util.getArg(aArgs, "column", 0)
8436
8436
  };
8437
8437
  needle.source = this._findSourceIndex(needle.source);
@@ -8461,7 +8461,7 @@ var require_source_map_consumer = __commonJS({
8461
8461
  }
8462
8462
  } else {
8463
8463
  var originalColumn = mapping.originalColumn;
8464
- while (mapping && mapping.originalLine === line && mapping.originalColumn == originalColumn) {
8464
+ while (mapping && mapping.originalLine === line2 && mapping.originalColumn == originalColumn) {
8465
8465
  mappings.push({
8466
8466
  line: util.getArg(mapping, "generatedLine", null),
8467
8467
  column: util.getArg(mapping, "generatedColumn", null),
@@ -9240,7 +9240,7 @@ var require_code_gen = __commonJS({
9240
9240
  }
9241
9241
  var SourceMap;
9242
9242
  if (!SourceNode) {
9243
- SourceNode = function(line, column, srcFile, chunks) {
9243
+ SourceNode = function(line2, column, srcFile, chunks) {
9244
9244
  this.src = "";
9245
9245
  if (chunks) {
9246
9246
  this.add(chunks);
@@ -9295,8 +9295,8 @@ var require_code_gen = __commonJS({
9295
9295
  },
9296
9296
  merge: function merge2() {
9297
9297
  var source = this.empty();
9298
- this.each(function(line) {
9299
- source.add([" ", line, "\n"]);
9298
+ this.each(function(line2) {
9299
+ source.add([" ", line2, "\n"]);
9300
9300
  });
9301
9301
  return source;
9302
9302
  },
@@ -9559,14 +9559,14 @@ var require_javascript_compiler = __commonJS({
9559
9559
  },
9560
9560
  mergeSource: function mergeSource(varDeclarations) {
9561
9561
  var isSimple = this.environment.isSimple, appendOnly = !this.forceBuffer, appendFirst = void 0, sourceSeen = void 0, bufferStart = void 0, bufferEnd = void 0;
9562
- this.source.each(function(line) {
9563
- if (line.appendToBuffer) {
9562
+ this.source.each(function(line2) {
9563
+ if (line2.appendToBuffer) {
9564
9564
  if (bufferStart) {
9565
- line.prepend(" + ");
9565
+ line2.prepend(" + ");
9566
9566
  } else {
9567
- bufferStart = line;
9567
+ bufferStart = line2;
9568
9568
  }
9569
- bufferEnd = line;
9569
+ bufferEnd = line2;
9570
9570
  } else {
9571
9571
  if (bufferStart) {
9572
9572
  if (!sourceSeen) {
@@ -9924,11 +9924,11 @@ var require_javascript_compiler = __commonJS({
9924
9924
  // This operation emits more code than the other options,
9925
9925
  // and can be avoided by passing the `knownHelpers` and
9926
9926
  // `knownHelpersOnly` flags at compile-time.
9927
- invokeAmbiguous: function invokeAmbiguous(name, helperCall) {
9927
+ invokeAmbiguous: function invokeAmbiguous(name, helperCall2) {
9928
9928
  this.useRegister("helper");
9929
9929
  var nonHelper = this.popStack();
9930
9930
  this.emptyHash();
9931
- var helper = this.setupHelper(0, name, helperCall);
9931
+ var helper = this.setupHelper(0, name, helperCall2);
9932
9932
  var helperName = this.lastHelper = this.nameLookup("helpers", name, "helper");
9933
9933
  var lookup = ["(", "(helper = ", helperName, " || ", nonHelper, ")"];
9934
9934
  if (!this.options.strict) {
@@ -11590,12 +11590,12 @@ var require_nunjucks = __commonJS({
11590
11590
  var CallExtensionAsync = CallExtension.extend("CallExtensionAsync");
11591
11591
  function print(str2, indent, inline) {
11592
11592
  var lines = str2.split("\n");
11593
- lines.forEach(function(line, i) {
11594
- if (line && (inline && i > 0 || !inline)) {
11593
+ lines.forEach(function(line2, i) {
11594
+ if (line2 && (inline && i > 0 || !inline)) {
11595
11595
  process.stdout.write(" ".repeat(indent));
11596
11596
  }
11597
11597
  var nl3 = i === lines.length - 1 ? "" : "\n";
11598
- process.stdout.write("" + line + nl3);
11598
+ process.stdout.write("" + line2 + nl3);
11599
11599
  });
11600
11600
  }
11601
11601
  function printNodes(node, indent) {
@@ -11780,8 +11780,8 @@ var require_nunjucks = __commonJS({
11780
11780
  for (var _len = arguments.length, lines = new Array(_len), _key = 0; _key < _len; _key++) {
11781
11781
  lines[_key] = arguments[_key];
11782
11782
  }
11783
- lines.forEach(function(line) {
11784
- return _this._emitLine(line);
11783
+ lines.forEach(function(line2) {
11784
+ return _this._emitLine(line2);
11785
11785
  });
11786
11786
  };
11787
11787
  _proto._emitFuncBegin = function _emitFuncBegin(node, name) {
@@ -13476,10 +13476,10 @@ var require_nunjucks = __commonJS({
13476
13476
  return node;
13477
13477
  };
13478
13478
  _proto.parseExtends = function parseExtends() {
13479
- var tagName = "extends";
13479
+ var tagName2 = "extends";
13480
13480
  var tag = this.peekToken();
13481
- if (!this.skipSymbol(tagName)) {
13482
- this.fail("parseTemplateRef: expected " + tagName);
13481
+ if (!this.skipSymbol(tagName2)) {
13482
+ this.fail("parseTemplateRef: expected " + tagName2);
13483
13483
  }
13484
13484
  var node = new nodes.Extends(tag.lineno, tag.colno);
13485
13485
  node.template = this.parseExpression();
@@ -13487,10 +13487,10 @@ var require_nunjucks = __commonJS({
13487
13487
  return node;
13488
13488
  };
13489
13489
  _proto.parseInclude = function parseInclude() {
13490
- var tagName = "include";
13490
+ var tagName2 = "include";
13491
13491
  var tag = this.peekToken();
13492
- if (!this.skipSymbol(tagName)) {
13493
- this.fail("parseInclude: expected " + tagName);
13492
+ if (!this.skipSymbol(tagName2)) {
13493
+ this.fail("parseInclude: expected " + tagName2);
13494
13494
  }
13495
13495
  var node = new nodes.Include(tag.lineno, tag.colno);
13496
13496
  node.template = this.parseExpression();
@@ -13651,10 +13651,10 @@ var require_nunjucks = __commonJS({
13651
13651
  }
13652
13652
  return node;
13653
13653
  };
13654
- _proto.parseRaw = function parseRaw(tagName) {
13655
- tagName = tagName || "raw";
13656
- var endTagName = "end" + tagName;
13657
- var rawBlockRegex = new RegExp("([\\s\\S]*?){%\\s*(" + tagName + "|" + endTagName + ")\\s*(?=%})%}");
13654
+ _proto.parseRaw = function parseRaw(tagName2) {
13655
+ tagName2 = tagName2 || "raw";
13656
+ var endTagName = "end" + tagName2;
13657
+ var rawBlockRegex = new RegExp("([\\s\\S]*?){%\\s*(" + tagName2 + "|" + endTagName + ")\\s*(?=%})%}");
13658
13658
  var rawLevel = 1;
13659
13659
  var str2 = "";
13660
13660
  var matches = null;
@@ -13663,7 +13663,7 @@ var require_nunjucks = __commonJS({
13663
13663
  var all = matches[0];
13664
13664
  var pre = matches[1];
13665
13665
  var blockName = matches[2];
13666
- if (blockName === tagName) {
13666
+ if (blockName === tagName2) {
13667
13667
  rawLevel += 1;
13668
13668
  } else if (blockName === endTagName) {
13669
13669
  rawLevel -= 1;
@@ -15081,27 +15081,27 @@ var require_nunjucks = __commonJS({
15081
15081
  return this;
15082
15082
  };
15083
15083
  EventEmitter.prototype.removeListener = function removeListener(type, listener) {
15084
- var list2, events, position, i, originalListener;
15084
+ var list3, events, position, i, originalListener;
15085
15085
  checkListener(listener);
15086
15086
  events = this._events;
15087
15087
  if (events === void 0)
15088
15088
  return this;
15089
- list2 = events[type];
15090
- if (list2 === void 0)
15089
+ list3 = events[type];
15090
+ if (list3 === void 0)
15091
15091
  return this;
15092
- if (list2 === listener || list2.listener === listener) {
15092
+ if (list3 === listener || list3.listener === listener) {
15093
15093
  if (--this._eventsCount === 0)
15094
15094
  this._events = /* @__PURE__ */ Object.create(null);
15095
15095
  else {
15096
15096
  delete events[type];
15097
15097
  if (events.removeListener)
15098
- this.emit("removeListener", type, list2.listener || listener);
15098
+ this.emit("removeListener", type, list3.listener || listener);
15099
15099
  }
15100
- } else if (typeof list2 !== "function") {
15100
+ } else if (typeof list3 !== "function") {
15101
15101
  position = -1;
15102
- for (i = list2.length - 1; i >= 0; i--) {
15103
- if (list2[i] === listener || list2[i].listener === listener) {
15104
- originalListener = list2[i].listener;
15102
+ for (i = list3.length - 1; i >= 0; i--) {
15103
+ if (list3[i] === listener || list3[i].listener === listener) {
15104
+ originalListener = list3[i].listener;
15105
15105
  position = i;
15106
15106
  break;
15107
15107
  }
@@ -15109,12 +15109,12 @@ var require_nunjucks = __commonJS({
15109
15109
  if (position < 0)
15110
15110
  return this;
15111
15111
  if (position === 0)
15112
- list2.shift();
15112
+ list3.shift();
15113
15113
  else {
15114
- spliceOne(list2, position);
15114
+ spliceOne(list3, position);
15115
15115
  }
15116
- if (list2.length === 1)
15117
- events[type] = list2[0];
15116
+ if (list3.length === 1)
15117
+ events[type] = list3[0];
15118
15118
  if (events.removeListener !== void 0)
15119
15119
  this.emit("removeListener", type, originalListener || listener);
15120
15120
  }
@@ -15207,10 +15207,10 @@ var require_nunjucks = __commonJS({
15207
15207
  copy[i] = arr[i];
15208
15208
  return copy;
15209
15209
  }
15210
- function spliceOne(list2, index) {
15211
- for (; index + 1 < list2.length; index++)
15212
- list2[index] = list2[index + 1];
15213
- list2.pop();
15210
+ function spliceOne(list3, index) {
15211
+ for (; index + 1 < list3.length; index++)
15212
+ list3[index] = list3[index + 1];
15213
+ list3.pop();
15214
15214
  }
15215
15215
  function unwrapListeners(arr) {
15216
15216
  var ret = new Array(arr.length);
@@ -15593,7 +15593,7 @@ var require_nunjucks = __commonJS({
15593
15593
  return 0;
15594
15594
  }
15595
15595
  exports2.length = lengthFilter;
15596
- function list2(val2) {
15596
+ function list3(val2) {
15597
15597
  if (lib.isString(val2)) {
15598
15598
  return val2.split("");
15599
15599
  } else if (lib.isObject(val2)) {
@@ -15610,7 +15610,7 @@ var require_nunjucks = __commonJS({
15610
15610
  throw new lib.TemplateError("list filter: type not iterable");
15611
15611
  }
15612
15612
  }
15613
- exports2.list = list2;
15613
+ exports2.list = list3;
15614
15614
  function lower(str2) {
15615
15615
  str2 = normalize(str2, "");
15616
15616
  return str2.toLowerCase();
@@ -15699,7 +15699,7 @@ var require_nunjucks = __commonJS({
15699
15699
  function reverse(val2) {
15700
15700
  var arr;
15701
15701
  if (lib.isString(val2)) {
15702
- arr = list2(val2);
15702
+ arr = list3(val2);
15703
15703
  } else {
15704
15704
  arr = lib.map(val2, function(v2) {
15705
15705
  return v2;
@@ -16092,7 +16092,7 @@ var require_nunjucks = __commonJS({
16092
16092
  }
16093
16093
  function globals() {
16094
16094
  return {
16095
- range: function range(start, stop, step) {
16095
+ range: function range2(start, stop, step) {
16096
16096
  if (typeof stop === "undefined") {
16097
16097
  stop = start;
16098
16098
  start = 0;
@@ -16689,7 +16689,7 @@ var require_liquid_node = __commonJS({
16689
16689
  const type = typeof value;
16690
16690
  return value !== null && (type === "object" || type === "function");
16691
16691
  }
16692
- function range(start, stop, step = 1) {
16692
+ function range2(start, stop, step = 1) {
16693
16693
  const arr = [];
16694
16694
  for (let i = start; i < stop; i += step) {
16695
16695
  arr.push(i);
@@ -16850,26 +16850,26 @@ var require_liquid_node = __commonJS({
16850
16850
  }
16851
16851
  };
16852
16852
  function mkContext(token) {
16853
- const [line, col] = token.getPosition();
16853
+ const [line2, col] = token.getPosition();
16854
16854
  const lines = token.input.split("\n");
16855
- const begin = Math.max(line - 2, 1);
16856
- const end = Math.min(line + 3, lines.length);
16857
- const context = range(begin, end + 1).map((lineNumber) => {
16858
- const rowIndicator = lineNumber === line ? ">> " : " ";
16855
+ const begin = Math.max(line2 - 2, 1);
16856
+ const end = Math.min(line2 + 3, lines.length);
16857
+ const context = range2(begin, end + 1).map((lineNumber) => {
16858
+ const rowIndicator = lineNumber === line2 ? ">> " : " ";
16859
16859
  const num = padStart(String(lineNumber), String(end).length);
16860
- let text2 = `${rowIndicator}${num}| `;
16861
- const colIndicator = lineNumber === line ? "\n" + padStart("^", col + text2.length) : "";
16862
- text2 += lines[lineNumber - 1];
16863
- text2 += colIndicator;
16864
- return text2;
16860
+ let text4 = `${rowIndicator}${num}| `;
16861
+ const colIndicator = lineNumber === line2 ? "\n" + padStart("^", col + text4.length) : "";
16862
+ text4 += lines[lineNumber - 1];
16863
+ text4 += colIndicator;
16864
+ return text4;
16865
16865
  }).join("\n");
16866
16866
  return context;
16867
16867
  }
16868
16868
  function mkMessage(msg, token) {
16869
16869
  if (token.file)
16870
16870
  msg += `, file:${token.file}`;
16871
- const [line, col] = token.getPosition();
16872
- msg += `, line:${line}, col:${col}`;
16871
+ const [line2, col] = token.getPosition();
16872
+ msg += `, line:${line2}, col:${col}`;
16873
16873
  return msg;
16874
16874
  }
16875
16875
  var TYPES = [0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 4, 4, 4, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 2, 8, 0, 0, 0, 0, 8, 0, 0, 0, 64, 0, 65, 0, 0, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 0, 0, 2, 2, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0];
@@ -17819,7 +17819,7 @@ var require_liquid_node = __commonJS({
17819
17819
  const low = yield evalToken(token.lhs, ctx);
17820
17820
  const high = yield evalToken(token.rhs, ctx);
17821
17821
  ctx.memoryLimit.use(high - low + 1);
17822
- return range(+low, +high + 1);
17822
+ return range2(+low, +high + 1);
17823
17823
  }
17824
17824
  function* toPostfix(tokens) {
17825
17825
  const ops = [];
@@ -18291,12 +18291,12 @@ var require_liquid_node = __commonJS({
18291
18291
  return nameOrFunction;
18292
18292
  }
18293
18293
  function normalizeDirectoryList(value) {
18294
- let list2 = [];
18294
+ let list3 = [];
18295
18295
  if (isArray(value))
18296
- list2 = value;
18296
+ list3 = value;
18297
18297
  if (isString(value))
18298
- list2 = [value];
18299
- return list2;
18298
+ list3 = [value];
18299
+ return list3;
18300
18300
  }
18301
18301
  function whiteSpaceCtrl(tokens, options) {
18302
18302
  let inRaw = false;
@@ -18335,12 +18335,12 @@ var require_liquid_node = __commonJS({
18335
18335
  token.trimLeft++;
18336
18336
  }
18337
18337
  var Tokenizer = class {
18338
- constructor(input, operators = defaultOptions2.operators, file, range2, groupedExpressions = false) {
18338
+ constructor(input, operators = defaultOptions2.operators, file, range3, groupedExpressions = false) {
18339
18339
  this.input = input;
18340
18340
  this.file = file;
18341
18341
  this.rawBeginAt = -1;
18342
- this.p = range2 ? range2[0] : 0;
18343
- this.N = range2 ? range2[1] : input.length;
18342
+ this.p = range3 ? range3[0] : 0;
18343
+ this.N = range3 ? range3[1] : input.length;
18344
18344
  this.opTrie = createTrie(operators);
18345
18345
  this.literalTrie = createTrie(literalValues);
18346
18346
  this.groupedExpressions = groupedExpressions;
@@ -19597,7 +19597,7 @@ var require_liquid_node = __commonJS({
19597
19597
  BlockMode2[BlockMode2["OUTPUT"] = 0] = "OUTPUT";
19598
19598
  BlockMode2[BlockMode2["STORE"] = 1] = "STORE";
19599
19599
  })(BlockMode || (BlockMode = {}));
19600
- var abs = argumentsToNumber(Math.abs);
19600
+ var abs2 = argumentsToNumber(Math.abs);
19601
19601
  var at_least = argumentsToNumber(Math.max);
19602
19602
  var at_most = argumentsToNumber(Math.min);
19603
19603
  var ceil = argumentsToNumber(Math.ceil);
@@ -19616,7 +19616,7 @@ var require_liquid_node = __commonJS({
19616
19616
  }
19617
19617
  var mathFilters = /* @__PURE__ */ Object.freeze({
19618
19618
  __proto__: null,
19619
- abs,
19619
+ abs: abs2,
19620
19620
  at_least,
19621
19621
  at_most,
19622
19622
  ceil,
@@ -19952,20 +19952,20 @@ var require_liquid_node = __commonJS({
19952
19952
  function date_to_rfc822(v2) {
19953
19953
  return date.call(this, v2, "%a, %d %b %Y %H:%M:%S %z");
19954
19954
  }
19955
- function date_to_string(v2, type, style) {
19956
- return stringify_date.call(this, v2, "%b", type, style);
19955
+ function date_to_string(v2, type, style2) {
19956
+ return stringify_date.call(this, v2, "%b", type, style2);
19957
19957
  }
19958
- function date_to_long_string(v2, type, style) {
19959
- return stringify_date.call(this, v2, "%B", type, style);
19958
+ function date_to_long_string(v2, type, style2) {
19959
+ return stringify_date.call(this, v2, "%B", type, style2);
19960
19960
  }
19961
- function stringify_date(v2, month_type, type, style) {
19961
+ function stringify_date(v2, month_type, type, style2) {
19962
19962
  const date2 = parseDate2(v2, this.context.opts);
19963
19963
  if (!date2)
19964
19964
  return v2;
19965
19965
  const ml = this.context.memoryLimit;
19966
19966
  if (type === "ordinal") {
19967
19967
  const d = date2.getDate();
19968
- return style === "US" ? strftime(date2, `${month_type} ${d}%q, %Y`, ml) : strftime(date2, `${d}%q ${month_type} %Y`, ml);
19968
+ return style2 === "US" ? strftime(date2, `${month_type} ${d}%q, %Y`, ml) : strftime(date2, `${d}%q ${month_type} %Y`, ml);
19969
19969
  }
19970
19970
  return strftime(date2, `%d ${month_type} %Y`, ml);
19971
19971
  }
@@ -21416,10 +21416,10 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
21416
21416
 
21417
21417
  // packages/engine/src/lib/errors.ts
21418
21418
  var EngineSyntaxError = class extends Error {
21419
- constructor(engine, message2, line, column) {
21419
+ constructor(engine, message2, line2, column) {
21420
21420
  super(message2);
21421
21421
  this.engine = engine;
21422
- this.line = line;
21422
+ this.line = line2;
21423
21423
  this.column = column;
21424
21424
  }
21425
21425
  name = "EngineSyntaxError";
@@ -21435,10 +21435,10 @@ var RenderLimitError = class extends Error {
21435
21435
  name = "RenderLimitError";
21436
21436
  };
21437
21437
  var RenderError = class extends Error {
21438
- constructor(engine, message2, line, column) {
21438
+ constructor(engine, message2, line2, column) {
21439
21439
  super(message2);
21440
21440
  this.engine = engine;
21441
- this.line = line;
21441
+ this.line = line2;
21442
21442
  this.column = column;
21443
21443
  }
21444
21444
  name = "RenderError";
@@ -67329,9 +67329,9 @@ function bwipp_validatetext() {
67329
67329
  }
67330
67330
  $_ = $__;
67331
67331
  }
67332
- function bwipp_encode(bwipjs, encoder3, text2, opts, dontdraw) {
67333
- if (typeof text2 !== "string") {
67334
- throw new Error("bwipp.typeError: barcode text not a string (" + text2 + ")");
67332
+ function bwipp_encode(bwipjs, encoder3, text4, opts, dontdraw) {
67333
+ if (typeof text4 !== "string") {
67334
+ throw new Error("bwipp.typeError: barcode text not a string (" + text4 + ")");
67335
67335
  }
67336
67336
  opts = opts || {};
67337
67337
  if (typeof opts === "string") {
@@ -67356,11 +67356,11 @@ function bwipp_encode(bwipjs, encoder3, text2, opts, dontdraw) {
67356
67356
  throw new Error("bwipp.typeError: options not an object");
67357
67357
  }
67358
67358
  if (opts.binarytext) {
67359
- if (/[\u0100-\uffff]/.test(text2)) {
67359
+ if (/[\u0100-\uffff]/.test(text4)) {
67360
67360
  throw new Error("bwip-js: 16-bit chars not allowed with binarytext");
67361
67361
  }
67362
- } else if (/[\u0080-\uffff]/.test(text2)) {
67363
- text2 = unescape(encodeURIComponent(text2));
67362
+ } else if (/[\u0080-\uffff]/.test(text4)) {
67363
+ text4 = unescape(encodeURIComponent(text4));
67364
67364
  }
67365
67365
  if (opts.dontdraw) {
67366
67366
  dontdraw = true;
@@ -67372,7 +67372,7 @@ function bwipp_encode(bwipjs, encoder3, text2, opts, dontdraw) {
67372
67372
  }
67373
67373
  }
67374
67374
  $$ = bwipjs;
67375
- $k = [text2, map];
67375
+ $k = [text4, map];
67376
67376
  $j = 2;
67377
67377
  $_ = {
67378
67378
  bwipjs_rawstack: dontdraw ? [] : false
@@ -67683,8 +67683,8 @@ var BWIPJS_OPTIONS = {
67683
67683
  backgroundcolor: 1
67684
67684
  };
67685
67685
  function _Render(encoder3, options, drawing) {
67686
- var text2 = options.text;
67687
- if (!text2) {
67686
+ var text4 = options.text;
67687
+ if (!text4) {
67688
67688
  throw new ReferenceError("bwip-js: bar code text not specified.");
67689
67689
  }
67690
67690
  FixupOptions(options);
@@ -67709,7 +67709,7 @@ function _Render(encoder3, options, drawing) {
67709
67709
  bwippopts.width = bwippopts.width / 25.4 || 0;
67710
67710
  }
67711
67711
  bw.scale(scaleX, scaleY);
67712
- bwipp_encode(bw, encoder3, text2, bwippopts);
67712
+ bwipp_encode(bw, encoder3, text4, bwippopts);
67713
67713
  return bw.render();
67714
67714
  }
67715
67715
  var BWIPJS = (function() {
@@ -67831,8 +67831,8 @@ var BWIPJS = (function() {
67831
67831
  BWIPJS2.prototype.setlinewidth = function(w) {
67832
67832
  this.g_penw = w;
67833
67833
  };
67834
- BWIPJS2.prototype.selectfont = function(f2, z3) {
67835
- this.g_font = { FontName: this.jsstring(f2), FontSize: +z3 };
67834
+ BWIPJS2.prototype.selectfont = function(f2, z4) {
67835
+ this.g_font = { FontName: this.jsstring(f2), FontSize: +z4 };
67836
67836
  };
67837
67837
  BWIPJS2.prototype.getfont = function() {
67838
67838
  return this.g_font.FontName;
@@ -68937,7 +68937,7 @@ var STBTT = /* @__PURE__ */ (function() {
68937
68937
  var floor = Math.floor;
68938
68938
  var ceil = Math.ceil;
68939
68939
  var sqrt = Math.sqrt;
68940
- var abs = Math.abs;
68940
+ var abs2 = Math.abs;
68941
68941
  function oalloc(n) {
68942
68942
  var o = [];
68943
68943
  for (var i = 0; i < n; i++) {
@@ -69948,7 +69948,7 @@ var STBTT = /* @__PURE__ */ (function() {
69948
69948
  dx6 = dy6 = s[10];
69949
69949
  dx = dx1 + dx2 + dx3 + dx4 + dx5;
69950
69950
  dy = dy1 + dy2 + dy3 + dy4 + dy5;
69951
- if (abs(dx) > abs(dy)) {
69951
+ if (abs2(dx) > abs2(dy)) {
69952
69952
  dy6 = -dy;
69953
69953
  } else {
69954
69954
  dx6 = -dx;
@@ -70201,7 +70201,7 @@ var STBTT = /* @__PURE__ */ (function() {
70201
70201
  }
70202
70202
  function stbtt__rasterize_sorted_edges(result, edges, nedges, vsubsample, off_x, off_y) {
70203
70203
  vsubsample |= 0, off_x |= 0, off_y |= 0;
70204
- var active = null, z3;
70204
+ var active = null, z4;
70205
70205
  var y2 = off_y, j2 = 0, i;
70206
70206
  var scanline = new Float32Array(result.w * 2 + 1);
70207
70207
  var scanline2 = scanline.subarray(result.w);
@@ -70215,18 +70215,18 @@ var STBTT = /* @__PURE__ */ (function() {
70215
70215
  for (var $i = 0, $l = scanline.length; $i < $l; $i++) scanline[$i] = 0;
70216
70216
  }
70217
70217
  while (step) {
70218
- z3 = step;
70219
- step = z3.next;
70220
- if (z3.ey <= scan_y_top) {
70221
- z3.direction = 0;
70218
+ z4 = step;
70219
+ step = z4.next;
70220
+ if (z4.ey <= scan_y_top) {
70221
+ z4.direction = 0;
70222
70222
  } else {
70223
70223
  }
70224
70224
  }
70225
70225
  while (edges[eoff].y0 <= scan_y_bottom) {
70226
70226
  if (edges[eoff].y0 != edges[eoff].y1) {
70227
- z3 = stbtt__new_active(edges[eoff], off_x, scan_y_top);
70228
- z3.next = active;
70229
- active = z3;
70227
+ z4 = stbtt__new_active(edges[eoff], off_x, scan_y_top);
70228
+ z4.next = active;
70229
+ active = z4;
70230
70230
  }
70231
70231
  ++eoff;
70232
70232
  }
@@ -70237,7 +70237,7 @@ var STBTT = /* @__PURE__ */ (function() {
70237
70237
  var k2, m2;
70238
70238
  sum += scanline2[i];
70239
70239
  k2 = scanline[i] + sum;
70240
- k2 = abs(k2) * 255 + 0.5;
70240
+ k2 = abs2(k2) * 255 + 0.5;
70241
70241
  m2 = k2 >>> 0;
70242
70242
  if (m2 > 255) {
70243
70243
  m2 = 255;
@@ -70246,9 +70246,9 @@ var STBTT = /* @__PURE__ */ (function() {
70246
70246
  }
70247
70247
  step = active;
70248
70248
  while (step) {
70249
- z3 = step;
70250
- z3.fx += z3.fdx;
70251
- step = z3.next;
70249
+ z4 = step;
70250
+ z4.fx += z4.fdx;
70251
+ step = z4.next;
70252
70252
  }
70253
70253
  ++y2;
70254
70254
  ++j2;
@@ -70268,12 +70268,12 @@ var STBTT = /* @__PURE__ */ (function() {
70268
70268
  }
70269
70269
  function stbtt__sort_edges_quicksort(p, o, n) {
70270
70270
  while (n > 12) {
70271
- var t, c, i, j2, z3, m2 = n >> 1, c01 = p[o].y0 < p[o + m2].y0, c12 = p[o + m2].y0 < p[o + n - 1].y0;
70271
+ var t, c, i, j2, z4, m2 = n >> 1, c01 = p[o].y0 < p[o + m2].y0, c12 = p[o + m2].y0 < p[o + n - 1].y0;
70272
70272
  if (c01 != c12) {
70273
70273
  c = p[o].y0 < p[o + n - 11].y0;
70274
- z3 = c == c12 ? 0 : n - 1;
70275
- t = p[o + z3];
70276
- p[o + z3] = p[o + m2];
70274
+ z4 = c == c12 ? 0 : n - 1;
70275
+ t = p[o + z4];
70276
+ p[o + z4] = p[o + m2];
70277
70277
  p[o + m2] = t;
70278
70278
  }
70279
70279
  t = p[o];
@@ -70686,6 +70686,12 @@ var barcodeTypes = {
70686
70686
  datamatrix: "datamatrix",
70687
70687
  pdf417: "pdf417"
70688
70688
  };
70689
+ var ownTextLayout = /* @__PURE__ */ new Set(["ean13", "ean8", "upca"]);
70690
+ function codeText(helper, value) {
70691
+ const text4 = value === void 0 || value === null ? "" : String(value);
70692
+ if (text4 === "") throw new Error(`${helper}: nothing to encode, the value is empty or missing from the data`);
70693
+ return text4;
70694
+ }
70689
70695
  var codeHelpers = [
70690
70696
  {
70691
70697
  name: "qrcode",
@@ -70702,7 +70708,7 @@ var codeHelpers = [
70702
70708
  },
70703
70709
  fn: (ctx, value, options) => {
70704
70710
  const o = options ?? {};
70705
- const svg = qrSvg(String(value ?? ""), o);
70711
+ const svg = qrSvg(codeText("qrcode", value), o);
70706
70712
  if (ctx.drawing) return ctx.drawing({ kind: "svg", svg, width: o.size, height: o.size, alt: "QR code" });
70707
70713
  return svgDataUri(svg);
70708
70714
  }
@@ -70722,16 +70728,17 @@ var codeHelpers = [
70722
70728
  fn: (ctx, value, options) => {
70723
70729
  const o = options ?? {};
70724
70730
  const bcid = barcodeTypes[String(o.type ?? "code128").toLowerCase()] ?? "code128";
70731
+ const text4 = codeText("barcode", value);
70725
70732
  const svg = ToSVG({
70726
70733
  bcid,
70727
- text: String(value ?? ""),
70734
+ text: text4,
70728
70735
  height: o.height ?? 12,
70729
70736
  ...o.width === void 0 ? {} : { width: o.width },
70730
70737
  scale: o.scale ?? 2,
70731
70738
  includetext: o.text !== false,
70732
- textxalign: "center"
70739
+ ...ownTextLayout.has(bcid) ? {} : { textxalign: "center" }
70733
70740
  });
70734
- if (ctx.drawing) return ctx.drawing({ kind: "svg", svg, alt: `Barcode ${String(value ?? "")}` });
70741
+ if (ctx.drawing) return ctx.drawing({ kind: "svg", svg, alt: `Barcode ${text4}` });
70735
70742
  return svgDataUri(svg);
70736
70743
  }
70737
70744
  },
@@ -70757,12 +70764,12 @@ var codeHelpers = [
70757
70764
  ...input && typeof input === "object" ? input : typeof input === "string" && input ? { iban: input } : {},
70758
70765
  ...options ?? {}
70759
70766
  };
70760
- const payment = {};
70767
+ const payment2 = {};
70761
70768
  const qr = {};
70762
70769
  for (const [key, value] of Object.entries(fields))
70763
- (EPC_FIELDS.has(key) ? payment : qr)[key] = value;
70770
+ (EPC_FIELDS.has(key) ? payment2 : qr)[key] = value;
70764
70771
  const o = { ecc: "M", ...qr };
70765
- const svg = qrSvg(epcPayload(payment), o);
70772
+ const svg = qrSvg(epcPayload(payment2), o);
70766
70773
  if (ctx.drawing) return ctx.drawing({ kind: "svg", svg, width: o.size, height: o.size, alt: "GiroCode" });
70767
70774
  return svgDataUri(svg);
70768
70775
  }
@@ -77594,6 +77601,16 @@ var currencyValues6 = { currency: (
77594
77601
  Object.keys(nl2)
77595
77602
  ) };
77596
77603
 
77604
+ // packages/engine/src/lib/translation.ts
77605
+ function resolveTranslation(dictionaries, locale, key) {
77606
+ const lang = locale.split("-")[0] ?? locale;
77607
+ for (const candidate of [locale, lang, "en"]) {
77608
+ const text4 = dictionaries?.[candidate]?.[key];
77609
+ if (typeof text4 === "string") return { text: text4, from: candidate };
77610
+ }
77611
+ return { text: key, from: null };
77612
+ }
77613
+
77597
77614
  // packages/engine/src/lib/helpers/office.ts
77598
77615
  function officeUnsupported(name) {
77599
77616
  return `${name}() is not supported in office templates`;
@@ -77637,7 +77654,9 @@ var str = (v2) => v2 === void 0 || v2 === null ? "" : String(v2);
77637
77654
  var opt = (v2, fallback) => v2 === void 0 || v2 === null || v2 === "" ? fallback : v2;
77638
77655
  function requireFinite(helper, value) {
77639
77656
  if (typeof value === "number" && !Number.isFinite(value))
77640
- throw new Error(`${helper}: got ${value}, the result of a calculation with a value that is missing or not a number`);
77657
+ throw new Error(
77658
+ `${helper}: got ${value}, the result of a calculation with a value that is missing or not a number`
77659
+ );
77641
77660
  }
77642
77661
  var wordsByLang = {
77643
77662
  de: toCardinal,
@@ -77815,13 +77834,20 @@ var formatHelpers = [
77815
77834
  if (Number.isNaN(n)) return "";
77816
77835
  const named = args2.find(isNamedArgs) ?? {};
77817
77836
  const [decimals, method] = args2.filter((a) => !isNamedArgs(a));
77818
- const places = Number(opt(decimals, opt(named["precision"], opt(named["decimals"], 0))));
77837
+ const places = Number(
77838
+ opt(decimals, opt(named["precision"], opt(named["decimals"], 0)))
77839
+ );
77819
77840
  const how = String(opt(method, opt(named["method"], "common")));
77820
77841
  const f2 = 10 ** places;
77821
77842
  const scaled = Number((Math.abs(n) * f2).toPrecision(15));
77822
- if (how === "floor") return (n < 0 ? -Math.ceil(scaled) : Math.floor(scaled)) / f2;
77823
- if (how === "ceil") return (n < 0 ? -Math.floor(scaled) : Math.ceil(scaled)) / f2;
77824
- if (how !== "common") throw new Error(`round: method must be 'common', 'floor' or 'ceil', not '${how}'`);
77843
+ if (how === "floor")
77844
+ return (n < 0 ? -Math.ceil(scaled) : Math.floor(scaled)) / f2;
77845
+ if (how === "ceil")
77846
+ return (n < 0 ? -Math.floor(scaled) : Math.ceil(scaled)) / f2;
77847
+ if (how !== "common")
77848
+ throw new Error(
77849
+ `round: method must be 'common', 'floor' or 'ceil', not '${how}'`
77850
+ );
77825
77851
  return Math.round(scaled + Number.EPSILON) / f2 * Math.sign(n);
77826
77852
  }
77827
77853
  },
@@ -78053,11 +78079,9 @@ var formatHelpers = [
78053
78079
  category: "text"
78054
78080
  },
78055
78081
  fn: (ctx, key, params) => {
78056
- const dictionaries = ctx.i18n ?? {};
78057
- const lang = ctx.locale.split("-")[0] ?? ctx.locale;
78058
- const text2 = dictionaries[ctx.locale]?.[str(key)] ?? dictionaries[lang]?.[str(key)] ?? dictionaries["en"]?.[str(key)] ?? str(key);
78082
+ const { text: text4 } = resolveTranslation(ctx.i18n, ctx.locale, str(key));
78059
78083
  const p = params ?? {};
78060
- return text2.replace(/\{(\w+)\}/g, (_2, name) => str(p[name]));
78084
+ return text4.replace(/\{(\w+)\}/g, (_2, name) => str(p[name]));
78061
78085
  }
78062
78086
  },
78063
78087
  {
@@ -78382,8 +78406,8 @@ function imageMarkup(url, options = {}) {
78382
78406
  options.fit ? `object-fit:${options.fit}` : ""
78383
78407
  ].filter(Boolean).join(";");
78384
78408
  const cls = options.class ? ` class="${escapeHtml(options.class)}"` : "";
78385
- const style = styles ? ` style="${styles}"` : "";
78386
- return `<img src="${escapeHtml(url)}" alt="${escapeHtml(options.alt ?? "")}"${cls}${style}>`;
78409
+ const style2 = styles ? ` style="${styles}"` : "";
78410
+ return `<img src="${escapeHtml(url)}" alt="${escapeHtml(options.alt ?? "")}"${cls}${style2}>`;
78387
78411
  }
78388
78412
  function resolveAsset(base, url) {
78389
78413
  if (!base || /^[a-z][a-z0-9+.-]*:/i.test(url)) return url;
@@ -78579,22 +78603,22 @@ function unavailableHelper(name) {
78579
78603
  }
78580
78604
 
78581
78605
  // packages/engine/src/lib/analysis/tags.ts
78582
- function rangeAt(line, column, length) {
78606
+ function rangeAt(line2, column, length) {
78583
78607
  return {
78584
- start: { line, column },
78585
- end: { line, column: column + Math.max(1, length) }
78608
+ start: { line: line2, column },
78609
+ end: { line: line2, column: column + Math.max(1, length) }
78586
78610
  };
78587
78611
  }
78588
78612
  function positionOf(source, offset) {
78589
- let line = 1;
78613
+ let line2 = 1;
78590
78614
  let last = -1;
78591
78615
  for (let i = 0; i < offset && i < source.length; i++) {
78592
78616
  if (source.charCodeAt(i) === 10) {
78593
- line++;
78617
+ line2++;
78594
78618
  last = i;
78595
78619
  }
78596
78620
  }
78597
- return { line, column: offset - last };
78621
+ return { line: line2, column: offset - last };
78598
78622
  }
78599
78623
  function rangeOf(source, start, end) {
78600
78624
  return { start: positionOf(source, start), end: positionOf(source, end) };
@@ -78662,11 +78686,11 @@ function scanBlocks(source, spec) {
78662
78686
  while (m2 = pattern.exec(source)) {
78663
78687
  const keyword = m2[1] ?? "";
78664
78688
  const rest = m2[2] ?? "";
78665
- const range = rangeOf(source, m2.index, m2.index + m2[0].length);
78689
+ const range2 = rangeOf(source, m2.index, m2.index + m2[0].length);
78666
78690
  if (inRaw) {
78667
78691
  if (spec.closers[keyword] === inRaw) {
78668
78692
  const open = stack.pop();
78669
- if (open) open.block.close = range;
78693
+ if (open) open.block.close = range2;
78670
78694
  inRaw = null;
78671
78695
  }
78672
78696
  continue;
@@ -78674,7 +78698,7 @@ function scanBlocks(source, spec) {
78674
78698
  if (isBlockOpener(keyword, rest)) {
78675
78699
  const block = {
78676
78700
  type: spec.openers[keyword] ?? "other",
78677
- open: range
78701
+ open: range2
78678
78702
  };
78679
78703
  blocks.push(block);
78680
78704
  stack.push({ keyword, block });
@@ -78688,7 +78712,7 @@ function scanBlocks(source, spec) {
78688
78712
  code: "unexpected-end-tag",
78689
78713
  message: `Unexpected {% ${keyword} %} without an open block`,
78690
78714
  args: { keyword },
78691
- range
78715
+ range: range2
78692
78716
  });
78693
78717
  } else if (top.keyword !== expected) {
78694
78718
  diagnostics.push({
@@ -78696,16 +78720,16 @@ function scanBlocks(source, spec) {
78696
78720
  code: "mismatched-end-tag",
78697
78721
  message: `Expected {% end${top.keyword} %} to close the {% ${top.keyword} %} at line ${top.block.open.start.line}, found {% ${keyword} %}`,
78698
78722
  args: { open: top.keyword, line: top.block.open.start.line, found: keyword },
78699
- range
78723
+ range: range2
78700
78724
  });
78701
78725
  const idx = stack.map((s) => s.keyword).lastIndexOf(expected);
78702
78726
  if (idx >= 0) {
78703
78727
  const closed = stack.splice(idx, 1)[0];
78704
- if (closed) closed.block.close = range;
78728
+ if (closed) closed.block.close = range2;
78705
78729
  }
78706
78730
  } else {
78707
78731
  stack.pop();
78708
- top.block.close = range;
78732
+ top.block.close = range2;
78709
78733
  }
78710
78734
  } else if (spec.continuations.includes(keyword) && !stack.length) {
78711
78735
  diagnostics.push({
@@ -78713,7 +78737,7 @@ function scanBlocks(source, spec) {
78713
78737
  code: "unexpected-tag",
78714
78738
  message: `{% ${keyword} %} outside of a block`,
78715
78739
  args: { keyword },
78716
- range
78740
+ range: range2
78717
78741
  });
78718
78742
  }
78719
78743
  }
@@ -78840,12 +78864,12 @@ function toSyntaxError(e) {
78840
78864
  const err = e;
78841
78865
  const message2 = String(err.message ?? e);
78842
78866
  const m2 = /Parse error on line (\d+)/.exec(message2);
78843
- const line = err.lineNumber ?? (m2 ? Number(m2[1]) : 1);
78867
+ const line2 = err.lineNumber ?? (m2 ? Number(m2[1]) : 1);
78844
78868
  const column = typeof err.column === "number" ? err.column + 1 : 1;
78845
78869
  return new EngineSyntaxError(
78846
78870
  "handlebars",
78847
78871
  message2.split("\n")[0] ?? message2,
78848
- line,
78872
+ line2,
78849
78873
  column
78850
78874
  );
78851
78875
  }
@@ -79155,48 +79179,48 @@ var SPEC = /^(?:([\s\S])?([<>=^]))?([+\- ])?(#)?(0)?(\d+)?([,_])?(?:\.(\d+))?([b
79155
79179
  function group(digits, separator) {
79156
79180
  return digits.replace(/\B(?=(\d{3})+(?!\d))/g, separator);
79157
79181
  }
79158
- function pythonExponent(text2) {
79159
- return text2.replace(/e([+-])(\d)$/i, (m2, sign, digit) => `${m2[0]}${sign}0${digit}`);
79182
+ function pythonExponent(text4) {
79183
+ return text4.replace(/e([+-])(\d)$/i, (m2, sign, digit) => `${m2[0]}${sign}0${digit}`);
79160
79184
  }
79161
79185
  function formatNumber(value, type, precision, alternate) {
79162
79186
  if (!Number.isFinite(value)) return Number.isNaN(value) ? "nan" : "inf";
79163
- const abs = Math.abs(value);
79187
+ const abs2 = Math.abs(value);
79164
79188
  switch (type) {
79165
79189
  case "f":
79166
79190
  case "F":
79167
- return abs.toFixed(precision ?? 6);
79191
+ return abs2.toFixed(precision ?? 6);
79168
79192
  case "%":
79169
- return `${(abs * 100).toFixed(precision ?? 6)}%`;
79193
+ return `${(abs2 * 100).toFixed(precision ?? 6)}%`;
79170
79194
  case "e":
79171
79195
  case "E": {
79172
- const text2 = pythonExponent(abs.toExponential(precision ?? 6));
79173
- return type === "E" ? text2.toUpperCase() : text2;
79196
+ const text4 = pythonExponent(abs2.toExponential(precision ?? 6));
79197
+ return type === "E" ? text4.toUpperCase() : text4;
79174
79198
  }
79175
79199
  case "g":
79176
79200
  case "G": {
79177
79201
  const p = precision === 0 ? 1 : precision ?? 6;
79178
- const exp = abs === 0 ? 0 : Math.floor(Math.log10(abs));
79179
- let text2 = exp < -4 || exp >= p ? pythonExponent(abs.toExponential(p - 1)) : abs.toFixed(Math.max(0, p - 1 - exp));
79202
+ const exp = abs2 === 0 ? 0 : Math.floor(Math.log10(abs2));
79203
+ let text4 = exp < -4 || exp >= p ? pythonExponent(abs2.toExponential(p - 1)) : abs2.toFixed(Math.max(0, p - 1 - exp));
79180
79204
  if (!alternate) {
79181
- const [mantissa = "", exponent] = text2.split("e");
79205
+ const [mantissa = "", exponent] = text4.split("e");
79182
79206
  const trimmed = mantissa.includes(".") ? mantissa.replace(/0+$/, "").replace(/\.$/, "") : mantissa;
79183
- text2 = exponent === void 0 ? trimmed : `${trimmed}e${exponent}`;
79207
+ text4 = exponent === void 0 ? trimmed : `${trimmed}e${exponent}`;
79184
79208
  }
79185
- return type === "G" ? text2.toUpperCase() : text2;
79209
+ return type === "G" ? text4.toUpperCase() : text4;
79186
79210
  }
79187
79211
  case "d":
79188
79212
  case "n":
79189
- return String(Math.trunc(abs));
79213
+ return String(Math.trunc(abs2));
79190
79214
  case "b":
79191
- return (alternate ? "0b" : "") + Math.trunc(abs).toString(2);
79215
+ return (alternate ? "0b" : "") + Math.trunc(abs2).toString(2);
79192
79216
  case "o":
79193
- return (alternate ? "0o" : "") + Math.trunc(abs).toString(8);
79217
+ return (alternate ? "0o" : "") + Math.trunc(abs2).toString(8);
79194
79218
  case "x":
79195
- return (alternate ? "0x" : "") + Math.trunc(abs).toString(16);
79219
+ return (alternate ? "0x" : "") + Math.trunc(abs2).toString(16);
79196
79220
  case "X":
79197
- return (alternate ? "0X" : "") + Math.trunc(abs).toString(16).toUpperCase();
79221
+ return (alternate ? "0X" : "") + Math.trunc(abs2).toString(16).toUpperCase();
79198
79222
  default:
79199
- return precision === void 0 ? String(abs) : formatNumber(abs, "g", precision, alternate);
79223
+ return precision === void 0 ? String(abs2) : formatNumber(abs2, "g", precision, alternate);
79200
79224
  }
79201
79225
  }
79202
79226
  function formatValue(value, spec) {
@@ -79251,35 +79275,35 @@ function lookupField(name, positional, named, next) {
79251
79275
  function pythonFormat(template, positional, named = {}) {
79252
79276
  let auto = 0;
79253
79277
  const next = () => auto++;
79254
- const render = (text2) => {
79278
+ const render = (text4) => {
79255
79279
  let out = "";
79256
- for (let i = 0; i < text2.length; i++) {
79257
- const ch = text2[i];
79280
+ for (let i = 0; i < text4.length; i++) {
79281
+ const ch = text4[i];
79258
79282
  if (ch === "}") {
79259
79283
  out += "}";
79260
- if (text2[i + 1] === "}") i++;
79284
+ if (text4[i + 1] === "}") i++;
79261
79285
  continue;
79262
79286
  }
79263
79287
  if (ch !== "{") {
79264
79288
  out += ch;
79265
79289
  continue;
79266
79290
  }
79267
- if (text2[i + 1] === "{") {
79291
+ if (text4[i + 1] === "{") {
79268
79292
  out += "{";
79269
79293
  i++;
79270
79294
  continue;
79271
79295
  }
79272
79296
  let depth = 1;
79273
79297
  let j2 = i + 1;
79274
- for (; j2 < text2.length && depth > 0; j2++) {
79275
- if (text2[j2] === "{") depth++;
79276
- else if (text2[j2] === "}") depth--;
79298
+ for (; j2 < text4.length && depth > 0; j2++) {
79299
+ if (text4[j2] === "{") depth++;
79300
+ else if (text4[j2] === "}") depth--;
79277
79301
  }
79278
79302
  if (depth > 0) {
79279
- out += text2.slice(i);
79303
+ out += text4.slice(i);
79280
79304
  break;
79281
79305
  }
79282
- const field = text2.slice(i + 1, j2 - 1);
79306
+ const field = text4.slice(i + 1, j2 - 1);
79283
79307
  const colon = field.indexOf(":");
79284
79308
  const head = colon < 0 ? field : field.slice(0, colon);
79285
79309
  const name = head.replace(/![rsa]$/, "");
@@ -79383,7 +79407,7 @@ var stringMethods = {
79383
79407
  return out;
79384
79408
  },
79385
79409
  split: (s, sep, max) => sep === void 0 || sep === null ? s.trim().split(/\s+/) : s.split(String(sep), max === void 0 ? void 0 : Number(max) + 1),
79386
- join: (s, list2) => Array.isArray(list2) ? list2.join(s) : String(list2),
79410
+ join: (s, list3) => Array.isArray(list3) ? list3.join(s) : String(list3),
79387
79411
  format: (s, ...args2) => {
79388
79412
  const named = keywordArgs(args2);
79389
79413
  return pythonFormat(s, named ? args2.slice(0, -1) : args2, named ?? {});
@@ -79617,9 +79641,9 @@ function toSyntaxError2(e, fallbackLine = 1) {
79617
79641
  const fromMessage = /\[Line (\d+), Column (\d+)\]/.exec(
79618
79642
  String(err.message ?? "")
79619
79643
  );
79620
- const line = typeof err.lineno === "number" ? err.lineno + 1 : fromMessage ? Number(fromMessage[1]) : fallbackLine;
79644
+ const line2 = typeof err.lineno === "number" ? err.lineno + 1 : fromMessage ? Number(fromMessage[1]) : fallbackLine;
79621
79645
  const column = typeof err.colno === "number" ? err.colno + 1 : fromMessage ? Number(fromMessage[2]) : 1;
79622
- return new EngineSyntaxError("jinja2", message2, line, column);
79646
+ return new EngineSyntaxError("jinja2", message2, line2, column);
79623
79647
  }
79624
79648
  function nodeRange(node, length = 1) {
79625
79649
  return rangeAt(node.lineno + 1, node.colno + 1, length);
@@ -80114,12 +80138,12 @@ var validationContext3 = {
80114
80138
  };
80115
80139
  function toSyntaxError3(e) {
80116
80140
  const err = e;
80117
- let line = err.line ?? 1;
80141
+ let line2 = err.line ?? 1;
80118
80142
  let column = err.col ?? 1;
80119
80143
  const pos = err.token?.getPosition?.();
80120
- if (pos) [line, column] = pos;
80144
+ if (pos) [line2, column] = pos;
80121
80145
  const message2 = String(err.message ?? e).replace(/,\s*line:\d+,\s*col:\d+/, "").trim();
80122
- return new EngineSyntaxError("liquid", message2, line, column);
80146
+ return new EngineSyntaxError("liquid", message2, line2, column);
80123
80147
  }
80124
80148
  var identifier = /(?<![\w."'])([A-Za-z_][\w]*)((?:\.[A-Za-z_]\w*|\[\d+\])*)/g;
80125
80149
  function pathsIn(expression, base, source, out, scopes) {
@@ -80408,8 +80432,8 @@ function unionTypes(a, b2) {
80408
80432
  ...Array.isArray(b2) ? b2 : b2 ? [b2] : []
80409
80433
  ]);
80410
80434
  if (set.has("number")) set.delete("integer");
80411
- const list2 = [...set];
80412
- return list2.length === 1 ? list2[0] : list2;
80435
+ const list3 = [...set];
80436
+ return list3.length === 1 ? list3[0] : list3;
80413
80437
  }
80414
80438
  function merge(a, b2) {
80415
80439
  if (!a) return b2;
@@ -80476,10 +80500,10 @@ function inferSchema(sample) {
80476
80500
  // packages/engine/src/lib/output.ts
80477
80501
  var outputFormats = ["pdf", "png", "jpg", "webp", "docx", "pptx"];
80478
80502
 
80479
- // packages/engine/src/lib/snippets.ts
80480
- var loop = (engine, item, list2, body) => engine === "handlebars" ? `{{#each ${list2}}}
80503
+ // packages/engine/src/lib/dialect.ts
80504
+ var loop = (engine, item, list3, body) => engine === "handlebars" ? `{{#each ${list3}}}
80481
80505
  ${body.replace(new RegExp(`(?<![\\w.])${item}\\.`, "g"), "")}
80482
- {{/each}}` : `{% for ${item} in ${list2} %}
80506
+ {{/each}}` : `{% for ${item} in ${list3} %}
80483
80507
  ${body}
80484
80508
  {% endfor %}`;
80485
80509
  var val = (engine, expr, filter) => {
@@ -80497,6 +80521,8 @@ var tr = (engine, key, params = {}) => {
80497
80521
  return `{{ '${key}' | t${entries.length ? ": " + entries.map(([k2, v2]) => `${k2}: ${v2}`).join(", ") : ""} }}`;
80498
80522
  return `{{ t('${key}'${entries.length ? `, { ${entries.map(([k2, v2]) => `${k2}: ${v2}`).join(", ")} }` : ""}) }}`;
80499
80523
  };
80524
+
80525
+ // packages/engine/src/lib/snippets.ts
80500
80526
  function forAll(build) {
80501
80527
  return {
80502
80528
  jinja2: build("jinja2"),
@@ -80537,8 +80563,18 @@ var snippets = [
80537
80563
  </div>$0`
80538
80564
  ),
80539
80565
  sampleData: {
80540
- company: { name: "Fennlor Studio GmbH", street: "Musterstra\xDFe 1", zip: "12345", city: "Musterstadt" },
80541
- customer: { name: "Olvarest GmbH", street: "Beispielweg 2", zip: "54321", city: "Beispielstadt" }
80566
+ company: {
80567
+ name: "Fennlor Studio GmbH",
80568
+ street: "Musterstra\xDFe 1",
80569
+ zip: "12345",
80570
+ city: "Musterstadt"
80571
+ },
80572
+ customer: {
80573
+ name: "Olvarest GmbH",
80574
+ street: "Beispielweg 2",
80575
+ zip: "54321",
80576
+ city: "Beispielstadt"
80577
+ }
80542
80578
  },
80543
80579
  // Form B puts the field 45 mm below the top edge and 20 mm from the left; the page margins decide where it lands
80544
80580
  css: `.ff-window { width: 85mm; height: 45mm; box-sizing: border-box; padding: 0 5mm; overflow: hidden; }
@@ -80565,8 +80601,16 @@ var snippets = [
80565
80601
  .ff-reference th { text-align: left; font-weight: normal; color: #555; padding: 1px 12px 1px 0; }
80566
80602
  .ff-reference td { text-align: right; padding: 1px 0; }`,
80567
80603
  i18n: {
80568
- en: { "reference.customer": "Customer no.", "reference.invoice": "Invoice no.", "reference.date": "Date" },
80569
- de: { "reference.customer": "Kundennummer", "reference.invoice": "Rechnungsnummer", "reference.date": "Datum" }
80604
+ en: {
80605
+ "reference.customer": "Customer no.",
80606
+ "reference.invoice": "Invoice no.",
80607
+ "reference.date": "Date"
80608
+ },
80609
+ de: {
80610
+ "reference.customer": "Kundennummer",
80611
+ "reference.invoice": "Rechnungsnummer",
80612
+ "reference.date": "Datum"
80613
+ }
80570
80614
  }
80571
80615
  },
80572
80616
  {
@@ -80581,14 +80625,24 @@ var snippets = [
80581
80625
  </div>$0`
80582
80626
  ),
80583
80627
  sampleData: {
80584
- invoice: { number: "2026-0042", period_start: "2026-09-01", period_end: "2026-09-30" }
80628
+ invoice: {
80629
+ number: "2026-0042",
80630
+ period_start: "2026-09-01",
80631
+ period_end: "2026-09-30"
80632
+ }
80585
80633
  },
80586
80634
  css: `.ff-heading { margin: 24px 0 16px; }
80587
80635
  .ff-heading h1 { font-family: var(--brand-font-heading, inherit); font-size: 18pt; color: var(--brand-color-primary, inherit); margin: 0 0 4px; }
80588
80636
  .ff-heading p { margin: 0; color: #555; }`,
80589
80637
  i18n: {
80590
- en: { "heading.title": "Invoice {number}", "heading.period": "Service period:" },
80591
- de: { "heading.title": "Rechnung {number}", "heading.period": "Leistungszeitraum:" }
80638
+ en: {
80639
+ "heading.title": "Invoice {number}",
80640
+ "heading.period": "Service period:"
80641
+ },
80642
+ de: {
80643
+ "heading.title": "Rechnung {number}",
80644
+ "heading.period": "Leistungszeitraum:"
80645
+ }
80592
80646
  }
80593
80647
  },
80594
80648
  {
@@ -80715,11 +80769,17 @@ ${loop(e, "line", "invoice.lines", ` <tr><td>${val(e, "line.description")}</t
80715
80769
  group: "invoice",
80716
80770
  title: "Small business VAT note",
80717
80771
  description: "States that no VAT is charged under \xA7 19 UStG (Kleinunternehmerregelung).",
80718
- source: forAll((e) => `<p class="ff-note">${tr(e, "vat.small_business")}</p>$0`),
80772
+ source: forAll(
80773
+ (e) => `<p class="ff-note">${tr(e, "vat.small_business")}</p>$0`
80774
+ ),
80719
80775
  css: `.ff-note { margin-top: 12px; font-size: 9pt; color: #444; }`,
80720
80776
  i18n: {
80721
- en: { "vat.small_business": "No VAT is charged under the small business scheme of \xA7 19 UStG." },
80722
- de: { "vat.small_business": "Gem\xE4\xDF \xA7 19 UStG wird keine Umsatzsteuer berechnet." }
80777
+ en: {
80778
+ "vat.small_business": "No VAT is charged under the small business scheme of \xA7 19 UStG."
80779
+ },
80780
+ de: {
80781
+ "vat.small_business": "Gem\xE4\xDF \xA7 19 UStG wird keine Umsatzsteuer berechnet."
80782
+ }
80723
80783
  }
80724
80784
  },
80725
80785
  {
@@ -80780,7 +80840,9 @@ ${loop(e, "line", "invoice.lines", ` <tr><td>${val(e, "line.description")}</t
80780
80840
  <span>${tr(e, "footer.page")} <span class="pageNumber"></span> ${tr(e, "footer.of")} <span class="totalPages"></span></span>
80781
80841
  </div>$0`
80782
80842
  ),
80783
- sampleData: { company: { name: "Fennlor Studio GmbH", email: "hello@fennlor.example" } },
80843
+ sampleData: {
80844
+ company: { name: "Fennlor Studio GmbH", email: "hello@fennlor.example" }
80845
+ },
80784
80846
  i18n: {
80785
80847
  en: { "footer.page": "Page", "footer.of": "of" },
80786
80848
  de: { "footer.page": "Seite", "footer.of": "von" }
@@ -80865,7 +80927,10 @@ ${loop(e, "line", "invoice.lines", ` <tr><td>${val(e, "line.description")}</t
80865
80927
  },
80866
80928
  i18n: {
80867
80929
  en: { "qr.alt": "Payment QR code", "qr.caption": "Scan to pay" },
80868
- de: { "qr.alt": "QR-Code zur Zahlung", "qr.caption": "Zum Bezahlen scannen" }
80930
+ de: {
80931
+ "qr.alt": "QR-Code zur Zahlung",
80932
+ "qr.caption": "Zum Bezahlen scannen"
80933
+ }
80869
80934
  },
80870
80935
  sampleData: {
80871
80936
  payment: {
@@ -80974,6 +81039,745 @@ var SEGMENT = "[A-Za-z0-9][A-Za-z0-9._-]*";
80974
81039
  var ASSET_NAME_PATTERN = new RegExp(`^${SEGMENT}(?:/${SEGMENT})*$`);
80975
81040
  var ASSET_MAX_BYTES = 10 * 1024 * 1024;
80976
81041
 
81042
+ // packages/engine/src/lib/generated/frames.ts
81043
+ var textEditRuntime = '"use strict";(()=>{var O=`\nhtml.ff-edit-mode [data-ff-edit] { cursor: text; }\nhtml.ff-edit-mode [data-ff-edit]:hover { outline: 1px dashed rgba(37,99,235,.85); outline-offset: 2px; }\nhtml.ff-edit-mode [data-ff-edit="t"]:hover { outline-color: rgba(147,51,234,.9); }\n.ff-editing { outline: 2px solid #2563eb !important; outline-offset: 2px; cursor: text; }\n.ff-editing .ff-chip { background: rgba(37,99,235,.14) !important; box-shadow: inset 0 0 0 1px rgba(37,99,235,.45) !important; border-radius: 3px !important; padding: 0 1px !important; cursor: default; }\n.ff-edit-badge { position: absolute; z-index: 2147483647; font: 500 11px/1.4 system-ui, sans-serif !important; color: #fff !important; background: #2563eb !important; padding: 1px 6px !important; border-radius: 4px !important; pointer-events: none; white-space: nowrap; }\n`;function F(l,d={}){let m=d.clicks!==!1,g=d.live===!0,o=l.document,i=null,s=null,f=e=>{try{l.parent.postMessage(e,"*")}catch{}},v=m?o.querySelector(\'meta[name="formfeed:document"]\')?.getAttribute("content")??null:null,h=!1;l.addEventListener("blur",()=>{h=!0}),l.addEventListener("focus",()=>{h=!1});let y=o.createElement("style");y.setAttribute("data-formfeed","edit"),y.setAttribute("data-pagedjs-ignore",""),y.textContent=O,(o.head??o.documentElement).appendChild(y),m&&o.documentElement.classList.add("ff-edit-mode");let M=e=>(e&&typeof e.closest=="function"?e:null)?.closest("[data-ff-edit]")??null;o.addEventListener("click",e=>{if(!m)return;if(i&&!i.done&&i.element.contains(e.target)){e.stopImmediatePropagation();return}let t=M(e.target);t&&(e.preventDefault(),e.stopImmediatePropagation(),C(t,{x:e.clientX,y:e.clientY}))},!0);function C(e,t){i&&!i.done&&x();let n=e.getAttribute("data-ff-src")??"",r=e.getBoundingClientRect(),u=Array.from(o.querySelectorAll(`[data-ff-src="${n.replace(/"/g,"")}"]`));s={src:n,element:e,point:t},f({type:"formfeed:edit-request",src:n,doc:v,edit:e.getAttribute("data-ff-edit"),text:e.textContent??"",elements:e.childElementCount,count:u.length,index:Math.max(0,u.indexOf(e)),split:e.hasAttribute("data-split-from")||e.hasAttribute("data-split-to"),rect:{left:r.left,top:r.top,width:r.width,height:r.height}})}o.addEventListener("keydown",e=>{if(!m||i&&!i.done||!(e.ctrlKey||e.metaKey)||e.altKey)return;let t=e.key.toLowerCase();(t==="z"||t==="y")&&(e.preventDefault(),f({type:t==="y"||e.shiftKey?"formfeed:redo":"formfeed:undo"}))}),l.addEventListener("message",e=>{if(e.source!==l.parent)return;let t=e.data;!t||typeof t.type!="string"||(t.type==="formfeed:edit-begin"?P(t):t.type==="formfeed:edit-refuse"||t.type==="formfeed:edit-end"?(s=null,i&&!i.done&&E(!1)):t.type==="formfeed:edit-open"&&B(t))});function B(e){if(!m||typeof e.src!="string"||i&&!i.done)return;let t=Array.from(o.querySelectorAll(`[data-ff-src="${e.src.replace(/"/g,"")}"][data-ff-edit]`)),n=Number.isInteger(e.index)?Number(e.index):0,r=t[n]??t[0];r&&C(r,null)}if(m){let e=()=>f({type:"formfeed:edit-ready",doc:v}),t=l;t.PagedConfig?t.formfeedEditReady=e:o.readyState==="loading"?o.addEventListener("DOMContentLoaded",e):e()}function P(e){i&&!i.done&&E(!1);let t=e.layer?o.querySelector(`[data-ff-layer="${String(e.layer).replace(/"/g,"")}"] > .ff-text`):s&&s.src===e.src?s.element:o.querySelector(`[data-ff-src="${String(e.src).replace(/"/g,"")}"]`),n=e.at,r=e.layer?n&&Number.isFinite(n.x)&&Number.isFinite(n.y)?{x:Number(n.x),y:Number(n.y)}:null:s&&s.src===e.src?s.point:null;s=null;let u=h&&!o.hasFocus();if(!t||!Array.isArray(e.items)||u){f({type:"formfeed:edit-cancel",token:String(e.token)});return}let c=Array.from(t.childNodes),b=o.createDocumentFragment();for(let a of e.items)if(a.kind==="text")b.appendChild(o.createTextNode(String(a.text)));else if(a.kind==="break")b.appendChild(o.createElement("br"));else if(a.kind==="chip"){let p=o.createElement("span");p.className="ff-chip",p.setAttribute("data-ff-chip",String(a.index)),p.setAttribute("contenteditable","false"),a.title&&(p.title=String(a.title)),p.textContent=String(a.text),b.appendChild(p)}for(let a of c)t.removeChild(a);t.appendChild(b),t.contentEditable="true",t.classList.add("ff-editing"),t.setAttribute("role","textbox"),e.label&&t.setAttribute("aria-label",String(e.label)),t.spellcheck=!0,i={token:String(e.token),element:t,saved:c,allowBreaks:e.allowBreaks===!0,badge:e.note?H(t,String(e.note)):null,done:!1},t.addEventListener("keydown",A),t.addEventListener("beforeinput",T),t.addEventListener("paste",S),t.addEventListener("drop",N),t.addEventListener("focusout",R),g&&t.addEventListener("input",k),t.focus(),e.select==="all"?I(t):K(t,r),f({type:"formfeed:edit-started",token:i.token}),typeof e.insert=="string"&&e.insert&&L(e.insert.replace(/\\r\\n?|\\n/g," "))}function L(e){if(typeof o.execCommand=="function"&&o.execCommand("insertText",!1,e))return;let t=l.getSelection(),n=t&&t.rangeCount?t.getRangeAt(0):null;n&&(n.deleteContents(),n.insertNode(o.createTextNode(e)),n.collapse(!1),g&&k())}function k(){i&&!i.done&&f({type:"formfeed:edit-input",token:i.token,items:D(i.element)})}function H(e,t){let n=o.createElement("div");n.className="ff-edit-badge",n.textContent=t;let r=e.getBoundingClientRect();return n.style.left=`${r.left+l.scrollX}px`,n.style.top=`${Math.max(0,r.top+l.scrollY-22)}px`,o.body.appendChild(n),n}function I(e){let t=l.getSelection();if(!t)return;let n=o.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}function K(e,t){let n=l.getSelection();if(!n)return;let r=null,u=o;if(t){if(u.caretRangeFromPoint)r=u.caretRangeFromPoint(t.x,t.y);else if(u.caretPositionFromPoint){let c=u.caretPositionFromPoint(t.x,t.y);c&&(r=o.createRange(),r.setStart(c.offsetNode,c.offset))}}if(!r||!e.contains(r.startContainer))r=o.createRange(),r.selectNodeContents(e),r.collapse(!1);else if(t){let c=r.startContainer,a=(c.nodeType===1?c:c.parentElement)?.closest("[data-ff-chip]")??null;if(a&&a!==e&&e.contains(a)){let p=a.getBoundingClientRect();r=o.createRange(),t.x<p.left+p.width/2?r.setStartBefore(a):r.setStartAfter(a),r.collapse(!0)}}n.removeAllRanges(),n.addRange(r)}function A(e){let t=e.key;t==="Escape"?(e.preventDefault(),E(!0)):t==="Enter"&&!e.shiftKey?(e.preventDefault(),x()):t==="Enter"?(e.preventDefault(),i?.allowBreaks&&q()):t==="Tab"?(e.preventDefault(),x()):(e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t.toLowerCase())&&(e.preventDefault(),g&&i&&!e.altKey&&f({type:"formfeed:edit-style",token:i.token,key:t.toLowerCase()}))}function T(e){let t=e.inputType??"";(t.startsWith("format")||t==="insertFromDrop"||t==="insertParagraph"||t==="insertLineBreak")&&e.preventDefault()}function S(e){e.preventDefault(),L((e.clipboardData?.getData("text/plain")??"").replace(/\\r\\n?|\\n/g," "))}function N(e){e.preventDefault()}function R(){l.setTimeout(()=>{i&&!i.done&&(!o.hasFocus()||!i.element.contains(o.activeElement))&&x()},0)}function q(){let e=l.getSelection();if(!e||!e.rangeCount)return;let t=e.getRangeAt(0);t.deleteContents();let n=o.createElement("br");t.insertNode(n),n.nextSibling||n.parentNode?.appendChild(o.createElement("br"));let r=o.createRange();r.setStartAfter(n),r.collapse(!0),e.removeAllRanges(),e.addRange(r)}function w(e){e.done=!0;let t=e.element;t.removeEventListener("keydown",A),t.removeEventListener("beforeinput",T),t.removeEventListener("paste",S),t.removeEventListener("drop",N),t.removeEventListener("focusout",R),t.removeEventListener("input",k),t.removeAttribute("contenteditable"),t.removeAttribute("role"),t.removeAttribute("aria-label"),t.classList.remove("ff-editing"),e.badge?.remove(),i===e&&(i=null)}function x(){let e=i;if(!e||e.done)return;let t=D(e.element);w(e),f({type:"formfeed:edit-commit",token:e.token,items:t})}function E(e){let t=i;if(!t||t.done)return;let n=t.element;for(;n.firstChild;)n.removeChild(n.firstChild);for(let r of t.saved)n.appendChild(r);w(t),e&&f({type:"formfeed:edit-cancel",token:t.token})}}function D(l){let d=[],m=o=>{let i=d[d.length-1];i?.kind==="text"?i.text+=o:o&&d.push({kind:"text",text:o})},g=o=>{for(let i of Array.from(o.childNodes))if(i.nodeType===3)m(i.data);else if(i.nodeType===1){let s=i,f=s.getAttribute("data-ff-chip");f!==null?d.push({kind:"chip",index:Number(f)}):s.tagName==="BR"?d.push({kind:"break"}):((s.tagName==="DIV"||s.tagName==="P")&&d.length&&d.push({kind:"break"}),g(s))}};for(g(l);d[d.length-1]?.kind==="break";)d.pop();return d}F(window);})();';
81044
+
81045
+ // packages/engine/src/lib/preview.ts
81046
+ var textEditScript = `<script>${textEditRuntime.replace(/<\/script/gi, "<\\/script")}</script>`;
81047
+
81048
+ // packages/engine/src/lib/source-edit.ts
81049
+ var NBSP = String.fromCharCode(160);
81050
+ var BREAK = String.fromCharCode(57344);
81051
+ var REMOVED = String.fromCharCode(57345);
81052
+ var CHIP_OPEN = String.fromCharCode(57346);
81053
+ var CHIP_CLOSE = String.fromCharCode(57347);
81054
+
81055
+ // packages/engine/src/lib/design/types.ts
81056
+ var DESIGN_VERSION = 1;
81057
+
81058
+ // packages/engine/src/lib/design/parse.ts
81059
+ var DESIGN_LIMITS = {
81060
+ layers: 200,
81061
+ textPerLayer: 5e3,
81062
+ bytes: 256 * 1024
81063
+ };
81064
+
81065
+ // packages/engine/src/lib/design/fonts.ts
81066
+ var range = (from, to) => Array.from({ length: (to - from) / 100 + 1 }, (_2, i) => from + i * 100);
81067
+ var googleFonts = [
81068
+ {
81069
+ family: "Inter",
81070
+ category: "sans-serif",
81071
+ weights: range(100, 900),
81072
+ italic: true
81073
+ },
81074
+ {
81075
+ family: "Roboto",
81076
+ category: "sans-serif",
81077
+ weights: range(100, 900),
81078
+ italic: true
81079
+ },
81080
+ {
81081
+ family: "Open Sans",
81082
+ category: "sans-serif",
81083
+ weights: range(300, 800),
81084
+ italic: true
81085
+ },
81086
+ {
81087
+ family: "Lato",
81088
+ category: "sans-serif",
81089
+ weights: [100, 300, 400, 700, 900],
81090
+ italic: true
81091
+ },
81092
+ {
81093
+ family: "Montserrat",
81094
+ category: "sans-serif",
81095
+ weights: range(100, 900),
81096
+ italic: true
81097
+ },
81098
+ {
81099
+ family: "Poppins",
81100
+ category: "sans-serif",
81101
+ weights: range(100, 900),
81102
+ italic: true
81103
+ },
81104
+ {
81105
+ family: "Source Sans 3",
81106
+ category: "sans-serif",
81107
+ weights: range(200, 900),
81108
+ italic: true
81109
+ },
81110
+ {
81111
+ family: "Nunito",
81112
+ category: "sans-serif",
81113
+ weights: range(200, 900),
81114
+ italic: true
81115
+ },
81116
+ {
81117
+ family: "Raleway",
81118
+ category: "sans-serif",
81119
+ weights: range(100, 900),
81120
+ italic: true
81121
+ },
81122
+ {
81123
+ family: "Work Sans",
81124
+ category: "sans-serif",
81125
+ weights: range(100, 900),
81126
+ italic: true
81127
+ },
81128
+ {
81129
+ family: "DM Sans",
81130
+ category: "sans-serif",
81131
+ weights: range(100, 900),
81132
+ italic: true
81133
+ },
81134
+ {
81135
+ family: "Manrope",
81136
+ category: "sans-serif",
81137
+ weights: range(200, 800),
81138
+ italic: false
81139
+ },
81140
+ {
81141
+ family: "Rubik",
81142
+ category: "sans-serif",
81143
+ weights: range(300, 900),
81144
+ italic: true
81145
+ },
81146
+ {
81147
+ family: "Noto Sans",
81148
+ category: "sans-serif",
81149
+ weights: range(100, 900),
81150
+ italic: true
81151
+ },
81152
+ {
81153
+ family: "IBM Plex Sans",
81154
+ category: "sans-serif",
81155
+ weights: range(100, 700),
81156
+ italic: true
81157
+ },
81158
+ {
81159
+ family: "Space Grotesk",
81160
+ category: "sans-serif",
81161
+ weights: range(300, 700),
81162
+ italic: false
81163
+ },
81164
+ {
81165
+ family: "Outfit",
81166
+ category: "sans-serif",
81167
+ weights: range(100, 900),
81168
+ italic: false
81169
+ },
81170
+ {
81171
+ family: "Plus Jakarta Sans",
81172
+ category: "sans-serif",
81173
+ weights: range(200, 800),
81174
+ italic: true
81175
+ },
81176
+ {
81177
+ family: "Figtree",
81178
+ category: "sans-serif",
81179
+ weights: range(300, 900),
81180
+ italic: true
81181
+ },
81182
+ {
81183
+ family: "Karla",
81184
+ category: "sans-serif",
81185
+ weights: range(200, 800),
81186
+ italic: true
81187
+ },
81188
+ {
81189
+ family: "Barlow",
81190
+ category: "sans-serif",
81191
+ weights: range(100, 900),
81192
+ italic: true
81193
+ },
81194
+ {
81195
+ family: "Archivo",
81196
+ category: "sans-serif",
81197
+ weights: range(100, 900),
81198
+ italic: true
81199
+ },
81200
+ {
81201
+ family: "Oswald",
81202
+ category: "display",
81203
+ weights: range(200, 700),
81204
+ italic: false
81205
+ },
81206
+ { family: "Bebas Neue", category: "display", weights: [400], italic: false },
81207
+ { family: "Anton", category: "display", weights: [400], italic: false },
81208
+ {
81209
+ family: "Playfair Display",
81210
+ category: "serif",
81211
+ weights: range(400, 900),
81212
+ italic: true
81213
+ },
81214
+ {
81215
+ family: "Merriweather",
81216
+ category: "serif",
81217
+ weights: range(300, 900),
81218
+ italic: true
81219
+ },
81220
+ { family: "Lora", category: "serif", weights: range(400, 700), italic: true },
81221
+ {
81222
+ family: "Libre Baskerville",
81223
+ category: "serif",
81224
+ weights: [400, 700],
81225
+ italic: true
81226
+ },
81227
+ {
81228
+ family: "Source Serif 4",
81229
+ category: "serif",
81230
+ weights: range(200, 900),
81231
+ italic: true
81232
+ },
81233
+ {
81234
+ family: "EB Garamond",
81235
+ category: "serif",
81236
+ weights: range(400, 800),
81237
+ italic: true
81238
+ },
81239
+ {
81240
+ family: "Cormorant Garamond",
81241
+ category: "serif",
81242
+ weights: range(300, 700),
81243
+ italic: true
81244
+ },
81245
+ {
81246
+ family: "DM Serif Display",
81247
+ category: "serif",
81248
+ weights: [400],
81249
+ italic: true
81250
+ },
81251
+ {
81252
+ family: "Fraunces",
81253
+ category: "serif",
81254
+ weights: range(100, 900),
81255
+ italic: true
81256
+ },
81257
+ {
81258
+ family: "Roboto Slab",
81259
+ category: "serif",
81260
+ weights: range(100, 900),
81261
+ italic: false
81262
+ },
81263
+ {
81264
+ family: "Zilla Slab",
81265
+ category: "serif",
81266
+ weights: [300, 400, 500, 600, 700],
81267
+ italic: true
81268
+ },
81269
+ {
81270
+ family: "JetBrains Mono",
81271
+ category: "monospace",
81272
+ weights: range(100, 800),
81273
+ italic: true
81274
+ },
81275
+ {
81276
+ family: "IBM Plex Mono",
81277
+ category: "monospace",
81278
+ weights: range(100, 700),
81279
+ italic: true
81280
+ },
81281
+ {
81282
+ family: "Space Mono",
81283
+ category: "monospace",
81284
+ weights: [400, 700],
81285
+ italic: true
81286
+ },
81287
+ {
81288
+ family: "Caveat",
81289
+ category: "handwriting",
81290
+ weights: range(400, 700),
81291
+ italic: false
81292
+ },
81293
+ {
81294
+ family: "Pacifico",
81295
+ category: "handwriting",
81296
+ weights: [400],
81297
+ italic: false
81298
+ },
81299
+ {
81300
+ family: "Dancing Script",
81301
+ category: "handwriting",
81302
+ weights: range(400, 700),
81303
+ italic: false
81304
+ }
81305
+ ];
81306
+ var byFamily = new Map(googleFonts.map((font) => [font.family, font]));
81307
+
81308
+ // packages/engine/src/lib/design/starters.ts
81309
+ var style = (overrides) => ({
81310
+ font: { family: "Inter", source: "google" },
81311
+ weight: 600,
81312
+ size: 40,
81313
+ lineHeight: 1.2,
81314
+ letterSpacing: 0,
81315
+ color: { color: "#111827" },
81316
+ align: "left",
81317
+ ...overrides
81318
+ });
81319
+ var text = (layer) => ({
81320
+ type: "text",
81321
+ rotation: 0,
81322
+ opacity: 1,
81323
+ visible: true,
81324
+ sizing: "fixed",
81325
+ valign: "top",
81326
+ ...layer
81327
+ });
81328
+ var design = (background, layers) => ({
81329
+ version: DESIGN_VERSION,
81330
+ output: "",
81331
+ background,
81332
+ layers
81333
+ });
81334
+ var designStarters = [
81335
+ {
81336
+ id: "blank",
81337
+ title: "Blank",
81338
+ size: { width: 1200, height: 630 },
81339
+ design: design({ color: "#ffffff" }, []),
81340
+ sampleData: {}
81341
+ },
81342
+ {
81343
+ id: "article",
81344
+ title: "Article card",
81345
+ size: { width: 1200, height: 630 },
81346
+ design: design({ brand: "primary", fallback: "#0f172a" }, [
81347
+ text({
81348
+ id: "site",
81349
+ name: "Site",
81350
+ x: 80,
81351
+ y: 64,
81352
+ width: 1040,
81353
+ height: 40,
81354
+ content: [{ path: "site.name" }],
81355
+ style: style({
81356
+ size: 26,
81357
+ weight: 600,
81358
+ letterSpacing: 2,
81359
+ uppercase: true,
81360
+ color: { color: "#cbd5e1" }
81361
+ })
81362
+ }),
81363
+ text({
81364
+ id: "title",
81365
+ name: "Title",
81366
+ x: 80,
81367
+ y: 130,
81368
+ width: 1040,
81369
+ height: 320,
81370
+ content: [{ path: "post.title" }],
81371
+ sizing: "shrink",
81372
+ minFontSize: 40,
81373
+ valign: "middle",
81374
+ style: style({
81375
+ size: 76,
81376
+ weight: 800,
81377
+ lineHeight: 1.1,
81378
+ color: { color: "#ffffff" }
81379
+ })
81380
+ }),
81381
+ {
81382
+ id: "rule",
81383
+ name: "Rule",
81384
+ type: "shape",
81385
+ shape: "rectangle",
81386
+ x: 80,
81387
+ y: 478,
81388
+ width: 120,
81389
+ height: 6,
81390
+ rotation: 0,
81391
+ opacity: 1,
81392
+ visible: true,
81393
+ fill: { brand: "accent", fallback: "#38bdf8" }
81394
+ },
81395
+ text({
81396
+ id: "byline",
81397
+ name: "Byline",
81398
+ x: 80,
81399
+ y: 508,
81400
+ width: 1040,
81401
+ height: 50,
81402
+ content: [{ text: "By " }, { path: "post.author" }],
81403
+ showWhen: { path: "post.author" },
81404
+ style: style({ size: 30, weight: 500, color: { color: "#cbd5e1" } })
81405
+ })
81406
+ ]),
81407
+ sampleData: {
81408
+ site: { name: "Fennlor Studio" },
81409
+ post: {
81410
+ title: "How we cut our invoice run from an hour to four minutes",
81411
+ author: "Max Mustermann"
81412
+ }
81413
+ }
81414
+ },
81415
+ {
81416
+ id: "quote",
81417
+ title: "Quote card",
81418
+ size: { width: 1080, height: 1080 },
81419
+ design: design({ color: "#f5efe6" }, [
81420
+ text({
81421
+ id: "mark",
81422
+ name: "Quotation mark",
81423
+ x: 96,
81424
+ y: 60,
81425
+ width: 240,
81426
+ height: 220,
81427
+ content: [{ text: "\u201C" }],
81428
+ style: style({
81429
+ font: { family: "Playfair Display", source: "google" },
81430
+ size: 220,
81431
+ weight: 700,
81432
+ lineHeight: 1,
81433
+ color: { color: "#d97706" }
81434
+ })
81435
+ }),
81436
+ text({
81437
+ id: "quote",
81438
+ name: "Quote",
81439
+ x: 96,
81440
+ y: 260,
81441
+ width: 888,
81442
+ height: 520,
81443
+ content: [{ path: "review.quote" }],
81444
+ sizing: "shrink",
81445
+ minFontSize: 32,
81446
+ valign: "middle",
81447
+ style: style({
81448
+ font: { family: "Playfair Display", source: "google" },
81449
+ size: 60,
81450
+ weight: 600,
81451
+ lineHeight: 1.22,
81452
+ color: { color: "#1c1917" }
81453
+ })
81454
+ }),
81455
+ text({
81456
+ id: "author",
81457
+ name: "Author",
81458
+ x: 96,
81459
+ y: 836,
81460
+ width: 888,
81461
+ height: 50,
81462
+ content: [{ path: "review.author" }],
81463
+ style: style({ size: 36, weight: 600, color: { color: "#1c1917" } })
81464
+ }),
81465
+ text({
81466
+ id: "role",
81467
+ name: "Role",
81468
+ x: 96,
81469
+ y: 896,
81470
+ width: 888,
81471
+ height: 44,
81472
+ content: [{ path: "review.role" }],
81473
+ showWhen: { path: "review.role" },
81474
+ style: style({ size: 28, weight: 400, color: { color: "#78716c" } })
81475
+ })
81476
+ ]),
81477
+ sampleData: {
81478
+ review: {
81479
+ quote: "Delivery took two days, and the one shade that arrived dented was replaced before we had finished the call.",
81480
+ author: "Erika Mustermann",
81481
+ role: "Office manager, Olvarest GmbH"
81482
+ }
81483
+ }
81484
+ },
81485
+ {
81486
+ id: "event",
81487
+ title: "Event story",
81488
+ size: { width: 1080, height: 1920 },
81489
+ design: design({ color: "#111827" }, [
81490
+ text({
81491
+ id: "label",
81492
+ name: "Label",
81493
+ x: 96,
81494
+ y: 200,
81495
+ width: 888,
81496
+ height: 50,
81497
+ content: [{ text: "Event" }],
81498
+ style: style({
81499
+ size: 36,
81500
+ weight: 700,
81501
+ letterSpacing: 6,
81502
+ uppercase: true,
81503
+ color: { color: "#fbbf24" }
81504
+ })
81505
+ }),
81506
+ text({
81507
+ id: "title",
81508
+ name: "Title",
81509
+ x: 96,
81510
+ y: 290,
81511
+ width: 888,
81512
+ height: 620,
81513
+ content: [{ path: "event.title" }],
81514
+ sizing: "shrink",
81515
+ minFontSize: 56,
81516
+ valign: "bottom",
81517
+ style: style({
81518
+ size: 112,
81519
+ weight: 800,
81520
+ lineHeight: 1.05,
81521
+ color: { color: "#ffffff" }
81522
+ })
81523
+ }),
81524
+ text({
81525
+ id: "date",
81526
+ name: "Date",
81527
+ x: 96,
81528
+ y: 980,
81529
+ width: 888,
81530
+ height: 70,
81531
+ content: [
81532
+ {
81533
+ path: "event.date",
81534
+ format: { helper: "date", pattern: "d MMMM yyyy" }
81535
+ }
81536
+ ],
81537
+ style: style({ size: 52, weight: 600, color: { color: "#e5e7eb" } })
81538
+ }),
81539
+ text({
81540
+ id: "place",
81541
+ name: "Place",
81542
+ x: 96,
81543
+ y: 1060,
81544
+ width: 888,
81545
+ height: 60,
81546
+ content: [{ path: "event.place" }],
81547
+ style: style({ size: 38, weight: 400, color: { color: "#9ca3af" } })
81548
+ }),
81549
+ {
81550
+ id: "qr",
81551
+ name: "QR code",
81552
+ type: "qr",
81553
+ x: 96,
81554
+ y: 1440,
81555
+ width: 300,
81556
+ height: 300,
81557
+ rotation: 0,
81558
+ opacity: 1,
81559
+ visible: true,
81560
+ radius: 16,
81561
+ value: { path: "event.url" },
81562
+ ecc: "M",
81563
+ color: { color: "#111827" },
81564
+ background: { color: "#ffffff" }
81565
+ },
81566
+ text({
81567
+ id: "scan",
81568
+ name: "Scan note",
81569
+ x: 440,
81570
+ y: 1560,
81571
+ width: 544,
81572
+ height: 60,
81573
+ content: [{ text: "Scan for your ticket" }],
81574
+ style: style({ size: 40, weight: 600, color: { color: "#ffffff" } })
81575
+ })
81576
+ ]),
81577
+ sampleData: {
81578
+ event: {
81579
+ title: "Formfeed meetup: documents as code",
81580
+ date: "2026-11-12",
81581
+ place: "Musterstra\xDFe 1 \xB7 12345 Musterstadt",
81582
+ url: "https://fennlor.test/events/meetup"
81583
+ }
81584
+ }
81585
+ }
81586
+ ];
81587
+
81588
+ // packages/engine/src/lib/einvoice/codes.generated.ts
81589
+ var list2 = (codes) => new Set(codes.split(" "));
81590
+ var documentTypeCodes = list2(
81591
+ "71 80 81 82 83 84 102 130 202 203 204 211 218 219 261 262 295 296 308 325 326 331 380 381 382 383 384 385 386 387 388 389 390 393 394 395 396 420 456 457 458 471 472 473 500 501 502 503 527 532 553 575 623 633 751 780 817 870 875 876 877 935"
81592
+ );
81593
+ var countryCodes = list2(
81594
+ "1A AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS XI YE YT ZA ZM ZW 1A XI"
81595
+ );
81596
+ var unitCodes = list2(
81597
+ "10 11 13 14 15 20 21 22 23 24 25 27 28 33 34 35 37 38 40 41 56 57 58 59 60 61 74 77 80 81 85 87 89 91 1I 2A 2B 2C 2G 2H 2I 2J 2K 2L 2M 2N 2P 2Q 2R 2U 2X 2Y 2Z 3B 3C 4C 4G 4H 4K 4L 4M 4N 4O 4P 4Q 4R 4T 4U 4W 4X 5A 5B 5E 5J A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A2 A20 A21 A22 A23 A24 A26 A27 A28 A29 A3 A30 A31 A32 A33 A34 A35 A36 A37 A38 A39 A4 A40 A41 A42 A43 A44 A45 A47 A48 A49 A5 A53 A54 A55 A56 A59 A6 A68 A69 A7 A70 A71 A73 A74 A75 A76 A8 A84 A85 A86 A87 A88 A89 A9 A90 A91 A93 A94 A95 A96 A97 A98 A99 AA AB ACR ACT AD AE AH AI AK AL AMH AMP ANN APZ AQ AS ASM ASU ATM AWG AY AZ B1 B10 B11 B12 B13 B14 B15 B16 B17 B18 B19 B20 B21 B22 B23 B24 B25 B26 B27 B28 B29 B3 B30 B31 B32 B33 B34 B35 B4 B41 B42 B43 B44 B45 B46 B47 B48 B49 B50 B52 B53 B54 B55 B56 B57 B58 B59 B60 B61 B62 B63 B64 B66 B67 B68 B69 B7 B70 B71 B72 B73 B74 B75 B76 B77 B78 B79 B8 B80 B81 B82 B83 B84 B85 B86 B87 B88 B89 B90 B91 B92 B93 B94 B95 B96 B97 B98 B99 BAR BB BFT BHP BIL BLD BLL BP BPM BQL BTU BUA BUI C0 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19 C20 C21 C22 C23 C24 C25 C26 C27 C28 C29 C3 C30 C31 C32 C33 C34 C35 C36 C37 C38 C39 C40 C41 C42 C43 C44 C45 C46 C47 C48 C49 C50 C51 C52 C53 C54 C55 C56 C57 C58 C59 C60 C61 C62 C63 C64 C65 C66 C67 C68 C69 C7 C70 C71 C72 C73 C74 C75 C76 C78 C79 C8 C80 C81 C82 C83 C84 C85 C86 C87 C88 C89 C9 C90 C91 C92 C93 C94 C95 C96 C97 C99 CCT CDL CEL CEN CG CGM CKG CLF CLT CMK CMQ CMT CNP CNT COU CTG CTM CTN CUR CWA CWI D03 D04 D1 D10 D11 D12 D13 D15 D16 D17 D18 D19 D2 D20 D21 D22 D23 D24 D25 D26 D27 D29 D30 D31 D32 D33 D34 D36 D41 D42 D43 D44 D45 D46 D47 D48 D49 D5 D50 D51 D52 D53 D54 D55 D56 D57 D58 D59 D6 D60 D61 D62 D63 D65 D68 D69 D73 D74 D77 D78 D80 D81 D82 D83 D85 D86 D87 D88 D89 D91 D93 D94 D95 DAA DAD DAY DB DBM DBW DD DEC DG DJ DLT DMA DMK DMO DMQ DMT DN DPC DPR DPT DRA DRI DRL DT DTN DWT DZN DZP E01 E07 E08 E09 E10 E12 E14 E15 E16 E17 E18 E19 E20 E21 E22 E23 E25 E27 E28 E30 E31 E32 E33 E34 E35 E36 E37 E38 E39 E4 E40 E41 E42 E43 E44 E45 E46 E47 E48 E49 E50 E51 E52 E53 E54 E55 E56 E57 E58 E59 E60 E61 E62 E63 E64 E65 E66 E67 E68 E69 E70 E71 E72 E73 E74 E75 E76 E77 E78 E79 E80 E81 E82 E83 E84 E85 E86 E87 E88 E89 E90 E91 E92 E93 E94 E95 E96 E97 E98 E99 EA EB EQ F01 F02 F03 F04 F05 F06 F07 F08 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31 F32 F33 F34 F35 F36 F37 F38 F39 F40 F41 F42 F43 F44 F45 F46 F47 F48 F49 F50 F51 F52 F53 F54 F55 F56 F57 F58 F59 F60 F61 F62 F63 F64 F65 F66 F67 F68 F69 F70 F71 F72 F73 F74 F75 F76 F77 F78 F79 F80 F81 F82 F83 F84 F85 F86 F87 F88 F89 F90 F91 F92 F93 F94 F95 F96 F97 F98 F99 FAH FAR FBM FC FF FH FIT FL FNU FOT FP FR FS FTK FTQ G01 G04 G05 G06 G08 G09 G10 G11 G12 G13 G14 G15 G16 G17 G18 G19 G2 G20 G21 G23 G24 G25 G26 G27 G28 G29 G3 G30 G31 G32 G33 G34 G35 G36 G37 G38 G39 G40 G41 G42 G43 G44 G45 G46 G47 G48 G49 G50 G51 G52 G53 G54 G55 G56 G57 G58 G59 G60 G61 G62 G63 G64 G65 G66 G67 G68 G69 G70 G71 G72 G73 G74 G75 G76 G77 G78 G79 G80 G81 G82 G83 G84 G85 G86 G87 G88 G89 G90 G91 G92 G93 G94 G95 G96 G97 G98 G99 GB GBQ GDW GE GF GFI GGR GIA GIC GII GIP GJ GL GLD GLI GLL GM GO GP GQ GRM GRN GRO GV GWH H03 H04 H05 H06 H07 H08 H09 H10 H11 H12 H13 H14 H15 H16 H18 H19 H20 H21 H22 H23 H24 H25 H26 H27 H28 H29 H30 H31 H32 H33 H34 H35 H36 H37 H38 H39 H40 H41 H42 H43 H44 H45 H46 H47 H48 H49 H50 H51 H52 H53 H54 H55 H56 H57 H58 H59 H60 H61 H62 H63 H64 H65 H66 H67 H68 H69 H70 H71 H72 H73 H74 H75 H76 H77 H79 H80 H81 H82 H83 H84 H85 H87 H88 H89 H90 H91 H92 H93 H94 H95 H96 H98 H99 HA HAD HBA HBX HC HDW HEA HGM HH HIU HKM HLT HM HMO HMQ HMT HPA HTZ HUR HWE IA IE INH INK INQ ISD IU IUG IV J10 J12 J13 J14 J15 J16 J17 J18 J19 J2 J20 J21 J22 J23 J24 J25 J26 J27 J28 J29 J30 J31 J32 J33 J34 J35 J36 J38 J39 J40 J41 J42 J43 J44 J45 J46 J47 J48 J49 J50 J51 J52 J53 J54 J55 J56 J57 J58 J59 J60 J61 J62 J63 J64 J65 J66 J67 J68 J69 J70 J71 J72 J73 J74 J75 J76 J78 J79 J81 J82 J83 J84 J85 J87 J90 J91 J92 J93 J95 J96 J97 J98 J99 JE JK JM JNT JOU JPS JWL K1 K10 K11 K12 K13 K14 K15 K16 K17 K18 K19 K2 K20 K21 K22 K23 K26 K27 K28 K3 K30 K31 K32 K33 K34 K35 K36 K37 K38 K39 K40 K41 K42 K43 K45 K46 K47 K48 K49 K50 K51 K52 K53 K54 K55 K58 K59 K6 K60 K61 K62 K63 K64 K65 K66 K67 K68 K69 K70 K71 K73 K74 K75 K76 K77 K78 K79 K80 K81 K82 K83 K84 K85 K86 K87 K88 K89 K90 K91 K92 K93 K94 K95 K96 K97 K98 K99 KA KAT KB KBA KCC KDW KEL KGM KGS KHY KHZ KI KIC KIP KJ KJO KL KLK KLX KMA KMH KMK KMQ KMT KNI KNM KNS KNT KO KPA KPH KPO KPP KR KSD KSH KT KTN KUR KVA KVR KVT KW KWH KWN KWO KWS KWT KWY KX L10 L11 L12 L13 L14 L15 L16 L17 L18 L19 L2 L20 L21 L23 L24 L25 L26 L27 L28 L29 L30 L31 L32 L33 L34 L35 L36 L37 L38 L39 L40 L41 L42 L43 L44 L45 L46 L47 L48 L49 L50 L51 L52 L53 L54 L55 L56 L57 L58 L59 L60 L63 L64 L65 L66 L67 L68 L69 L70 L71 L72 L73 L74 L75 L76 L77 L78 L79 L80 L81 L82 L83 L84 L85 L86 L87 L88 L89 L90 L91 L92 L93 L94 L95 L96 L98 L99 LA LAC LBR LBT LD LEF LF LH LK LM LN LO LP LPA LR LS LTN LTR LUB LUM LUX LY M1 M10 M11 M12 M13 M14 M15 M16 M17 M18 M19 M20 M21 M22 M23 M24 M25 M26 M27 M29 M30 M31 M32 M33 M34 M35 M36 M37 M38 M39 M4 M40 M41 M42 M43 M44 M45 M46 M47 M48 M49 M5 M50 M51 M52 M53 M55 M56 M57 M58 M59 M60 M61 M62 M63 M64 M65 M66 M67 M68 M69 M7 M70 M71 M72 M73 M74 M75 M76 M77 M78 M79 M80 M81 M82 M83 M84 M85 M86 M87 M88 M89 M9 M90 M91 M92 M93 M94 M95 M96 M97 M98 M99 MAH MAL MAM MAR MAW MBE MBF MBR MC MCU MD MGM MHZ MIK MIL MIN MIO MIU MKD MKM MKW MLD MLT MMK MMQ MMT MND MNJ MON MPA MQD MQH MQM MQS MQW MRD MRM MRW MSK MTK MTQ MTR MTS MTZ MVA MWH N1 N10 N11 N12 N13 N14 N15 N16 N17 N18 N19 N20 N21 N22 N23 N24 N25 N26 N27 N28 N29 N3 N30 N31 N32 N33 N34 N35 N36 N37 N38 N39 N40 N41 N42 N43 N44 N45 N46 N47 N48 N49 N50 N51 N52 N53 N54 N55 N56 N57 N58 N59 N60 N61 N62 N63 N64 N65 N66 N67 N68 N69 N70 N71 N72 N73 N74 N75 N76 N77 N78 N79 N80 N81 N82 N83 N84 N85 N86 N87 N88 N89 N90 N91 N92 N93 N94 N95 N96 N97 N98 N99 NA NAR NCL NEW NF NIL NIU NL NM3 NMI NMP NPT NT NTU NU NX OA ODE ODG ODK ODM OHM ON ONZ OPM OT OZA OZI P1 P10 P11 P12 P13 P14 P15 P16 P17 P18 P19 P2 P20 P21 P22 P23 P24 P25 P26 P27 P28 P29 P30 P31 P32 P33 P34 P35 P36 P37 P38 P39 P40 P41 P42 P43 P44 P45 P46 P47 P48 P49 P5 P50 P51 P52 P53 P54 P55 P56 P57 P58 P59 P60 P61 P62 P63 P64 P65 P66 P67 P68 P69 P70 P71 P72 P73 P74 P75 P76 P77 P78 P79 P80 P81 P82 P83 P84 P85 P86 P87 P88 P89 P90 P91 P92 P93 P94 P95 P96 P97 P98 P99 PAL PD PFL PGL PI PLA PO PQ PR PS PTD PTI PTL PTN Q10 Q11 Q12 Q13 Q14 Q15 Q16 Q17 Q18 Q19 Q20 Q21 Q22 Q23 Q24 Q25 Q26 Q27 Q28 Q29 Q3 Q30 Q31 Q32 Q33 Q34 Q35 Q36 Q37 Q38 Q39 Q40 Q41 Q42 QA QAN QB QR QTD QTI QTL QTR R1 R9 RH RM ROM RP RPM RPS RT S3 S4 SAN SCO SCR SEC SET SG SIE SM3 SMI SQ SQR SR STC STI STK STL STN STW SW SX SYR T0 T3 TAH TAN TI TIC TIP TKM TMS TNE TP TPI TPR TQD TRL TST TTS U1 U2 UB UC VA VLT VP W2 WA WB WCD WE WEB WEE WG WHR WM WSD WTT X1 X1A X1B X1D X1F X1G X1W X2C X3A X3H X43 X44 X4A X4B X4C X4D X4F X4G X4H X5H X5L X5M X6H X6P X7A X7B X8A X8B X8C XAA XAB XAC XAD XAE XAF XAG XAH XAI XAJ XAL XAM XAP XAT XAV XB4 XBA XBB XBC XBD XBE XBF XBG XBH XBI XBJ XBK XBL XBM XBN XBO XBP XBQ XBR XBS XBT XBU XBV XBW XBX XBY XBZ XCA XCB XCC XCD XCE XCF XCG XCH XCI XCJ XCK XCL XCM XCN XCO XCP XCQ XCR XCS XCT XCU XCV XCW XCX XCY XCZ XDA XDB XDC XDG XDH XDI XDJ XDK XDL XDM XDN XDP XDR XDS XDT XDU XDV XDW XDX XDY XEC XED XEE XEF XEG XEH XEI XEN XFB XFC XFD XFE XFI XFL XFO XFP XFR XFT XFW XFX XGB XGI XGL XGR XGU XGY XGZ XHA XHB XHC XHG XHN XHR XIA XIB XIC XID XIE XIF XIG XIH XIK XIL XIN XIZ XJB XJC XJG XJR XJT XJY XKG XKI XLE XLG XLT XLU XLV XLZ XMA XMB XMC XME XMR XMS XMT XMW XMX XNA XNE XNF XNG XNS XNT XNU XNV XO1 XO2 XO3 XO4 XO5 XO6 XO7 XO8 XO9 XOA XOB XOC XOD XOE XOF XOG XOH XOI XOJ XOK XOL XOM XON XOP XOQ XOR XOS XOT XOU XOV XOW XOX XOY XOZ XP1 XP2 XP3 XP4 XPA XPB XPC XPD XPE XPF XPG XPH XPI XPJ XPK XPL XPN XPO XPP XPR XPT XPU XPV XPX XPY XPZ XQA XQB XQC XQD XQF XQG XQH XQJ XQK XQL XQM XQN XQP XQQ XQR XQS XRD XRG XRJ XRK XRL XRO XRT XRZ XSA XSB XSC XSD XSE XSH XSI XSK XSL XSM XSO XSP XSS XST XSU XSV XSW XSX XSY XSZ XT1 XTB XTC XTD XTE XTG XTI XTK XTL XTN XTO XTR XTS XTT XTU XTV XTW XTY XTZ XUC XUN XVA XVG XVI XVK XVL XVN XVO XVP XVQ XVR XVS XVY XWA XWB XWC XWD XWF XWG XWH XWJ XWK XWL XWM XWN XWP XWQ XWR XWS XWT XWU XWV XWW XWX XWY XWZ XXA XXB XXC XXD XXF XXG XXH XXJ XXK XYA XYB XYC XYD XYF XYG XYH XYJ XYK XYL XYM XYN XYP XYQ XYR XYS XYT XYV XYW XYX XYY XYZ XZA XZB XZC XZD XZF XZG XZH XZJ XZK XZL XZM XZN XZP XZQ XZR XZS XZT XZU XZV XZW XZX XZY XZZ YDK YDQ YRD Z11 Z9 ZP ZZ"
81598
+ );
81599
+ var electronicAddressSchemes = list2(
81600
+ "0002 0007 0009 0037 0060 0088 0096 0097 0106 0130 0135 0142 0147 0151 0154 0158 0170 0177 0183 0184 0188 0190 0191 0192 0193 0194 0195 0196 0198 0199 0200 0201 0202 0203 0204 0205 0208 0209 0210 0211 0212 0213 0215 0216 0217 0218 0221 0225 0230 0235 0240 0242 0244 0245 0246 0248 9910 9913 9914 9915 9918 9919 9920 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9957 9959 AN AQ AS AU EM"
81601
+ );
81602
+ var currencyCodes = list2(
81603
+ "AED AFN ALL AMD AOA ARS AUD AWG AZN BAM BBD BDT BHD BIF BMD BND BOB BOV BRL BSD BTN BWP BYN BZD CAD CDF CHE CHF CHW CLF CLP CNH CNY COP COU CRC CUP CVE CZK DJF DKK DOP DZD EGP ERN ETB EUR FJD FKP GBP GEL GHS GIP GMD GNF GTQ GYD HKD HNL HTG HUF IDR ILS INR IQD IRR ISK JMD JOD JPY KES KGS KHR KMF KPW KRW KWD KYD KZT LAK LBP LKR LRD LSL LYD MAD MDL MGA MKD MMK MNT MOP MRU MUR MVR MWK MXN MXV MYR MZN NAD NGN NIO NOK NPR NZD OMR PAB PEN PGK PHP PKR PLN PYG QAR RON RSD RUB RWF SAR SBD SCR SDG SEK SGD SHP SLE SOS SRD SSP STN SVC SYP SZL THB TJS TMT TND TOP TRY TTD TWD TZS UAH UGX USD USN UYI UYU UYW UZS VED VES VND VUV WST XAF XAG XAU XBA XBB XBC XBD XCD XCG XDR XOF XPD XPF XPT XSU XTS XUA XXX YER ZAR ZMW ZWG"
81604
+ );
81605
+ var paymentMeansCodes = list2(
81606
+ "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 74 75 76 77 78 91 92 93 94 95 96 97 98 ZZZ"
81607
+ );
81608
+
81609
+ // packages/engine/src/lib/einvoice/schema.ts
81610
+ import { z as z2 } from "zod";
81611
+ var numeric = z2.union([z2.number(), z2.string()]);
81612
+ var text2 = z2.string().trim().min(1);
81613
+ var isoDate2 = z2.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Expected a date as YYYY-MM-DD");
81614
+ var identifier2 = z2.union([
81615
+ text2,
81616
+ z2.object({ value: text2, scheme: text2.optional() })
81617
+ ]);
81618
+ var address = z2.object({
81619
+ street: text2.optional(),
81620
+ street2: text2.optional(),
81621
+ street3: text2.optional(),
81622
+ postcode: text2.optional(),
81623
+ city: text2.optional(),
81624
+ /** ISO 3166-1 alpha-2 (BT-40, BT-55, BT-80). */
81625
+ country: text2,
81626
+ /** Region or province (BT-39, BT-54, BT-79). */
81627
+ subdivision: text2.optional()
81628
+ });
81629
+ var contact = z2.object({
81630
+ name: text2.optional(),
81631
+ phone: text2.optional(),
81632
+ email: text2.optional()
81633
+ });
81634
+ var party = z2.object({
81635
+ name: text2,
81636
+ /** The name the business trades under, where it differs (BT-28, BT-45). */
81637
+ trading_name: text2.optional(),
81638
+ /** An identifier of the party (BT-29, BT-46). */
81639
+ id: identifier2.optional(),
81640
+ /** The register entry (BT-30, BT-47): a SIREN, a company number. */
81641
+ legal_registration: identifier2.optional(),
81642
+ vat_id: text2.optional(),
81643
+ address,
81644
+ contact: contact.optional(),
81645
+ /** Where the party receives electronic invoices (BT-34, BT-49); a bare e-mail address is scheme EM. */
81646
+ electronic_address: identifier2.optional()
81647
+ });
81648
+ var period = z2.object({ start: isoDate2.optional(), end: isoDate2.optional() });
81649
+ var VAT_CATEGORIES = ["S", "Z", "E", "AE", "K", "G", "O"];
81650
+ var vatCategory = z2.enum(VAT_CATEGORIES);
81651
+ var lineTax = z2.object({
81652
+ category: vatCategory,
81653
+ /** Percent, `19` for 19 %. Left out for category O only. */
81654
+ rate: numeric.optional()
81655
+ });
81656
+ var allowanceOrCharge = z2.object({
81657
+ amount: numeric,
81658
+ reason: text2.optional(),
81659
+ /** UNTDID 5189 for an allowance, UNTDID 7161 for a charge. */
81660
+ reason_code: text2.optional(),
81661
+ base_amount: numeric.optional(),
81662
+ percent: numeric.optional()
81663
+ });
81664
+ var line = z2.object({
81665
+ id: z2.union([text2, z2.number()]),
81666
+ name: text2,
81667
+ description: text2.optional(),
81668
+ quantity: numeric,
81669
+ /** UN/ECE Recommendation 20: C62 a piece, HUR an hour, DAY a day, KGM a kilogram. */
81670
+ unit_code: text2.default("C62"),
81671
+ net_price: numeric,
81672
+ /** The quantity the price is for, where it is not one unit (BT-149). */
81673
+ price_base_quantity: numeric.optional(),
81674
+ net_amount: numeric,
81675
+ tax: lineTax,
81676
+ period: period.optional(),
81677
+ allowances: z2.array(allowanceOrCharge).optional(),
81678
+ charges: z2.array(allowanceOrCharge).optional(),
81679
+ buyer_accounting_reference: text2.optional(),
81680
+ note: text2.optional(),
81681
+ /** The seller's and the buyer's article numbers (BT-155, BT-156), a GTIN and the like (BT-157). */
81682
+ seller_item_id: text2.optional(),
81683
+ buyer_item_id: text2.optional(),
81684
+ standard_item_id: identifier2.optional(),
81685
+ /** The line of the buyer's order this one answers (BT-132). */
81686
+ order_line_reference: text2.optional()
81687
+ });
81688
+ var breakdown = z2.object({
81689
+ category: vatCategory,
81690
+ rate: numeric.optional(),
81691
+ basis: numeric,
81692
+ amount: numeric,
81693
+ exemption_reason: text2.optional(),
81694
+ /** A VATEX code (BT-121), for example VATEX-EU-AE for reverse charge. */
81695
+ exemption_reason_code: text2.optional()
81696
+ });
81697
+ var totals = z2.object({
81698
+ line_net: numeric,
81699
+ allowances: numeric.optional(),
81700
+ charges: numeric.optional(),
81701
+ tax_basis: numeric,
81702
+ tax_total: numeric,
81703
+ /** The VAT total in the accounting currency (BT-111). */
81704
+ tax_total_accounting: numeric.optional(),
81705
+ grand: numeric,
81706
+ prepaid: numeric.optional(),
81707
+ rounding: numeric.optional(),
81708
+ due: numeric
81709
+ });
81710
+ var payment = z2.object({
81711
+ /** UNTDID 4461: 58 SEPA credit transfer, 59 SEPA direct debit, 30 credit transfer, 48 card. */
81712
+ means_code: z2.union([text2, z2.number()]).optional(),
81713
+ iban: text2.optional(),
81714
+ bic: text2.optional(),
81715
+ account_name: text2.optional(),
81716
+ /** What the payer quotes with the payment (BT-83). */
81717
+ reference: text2.optional(),
81718
+ terms: text2.optional(),
81719
+ due_date: isoDate2.optional(),
81720
+ /** Direct debit: the mandate (BT-89), the creditor's identifier (BT-90), the account debited (BT-91). */
81721
+ mandate_id: text2.optional(),
81722
+ creditor_id: text2.optional(),
81723
+ debited_iban: text2.optional()
81724
+ });
81725
+ var note = z2.object({
81726
+ text: text2,
81727
+ /** UNTDID 4451, which French invoices use for their statutory mentions (PMT, PMD, AAB). */
81728
+ subject_code: text2.optional()
81729
+ });
81730
+ var invoiceSchema = z2.object({
81731
+ number: text2,
81732
+ issue_date: isoDate2,
81733
+ /** UNTDID 1001: 380 invoice, 381 credit note, 384 corrected invoice, 389 self-billed. */
81734
+ type_code: z2.union([text2, z2.number()]).default("380"),
81735
+ currency: text2,
81736
+ /** The currency the VAT is accounted in, where the invoice is in another (BT-6); goes with `totals.tax_total_accounting`. */
81737
+ accounting_currency: text2.optional(),
81738
+ /** The buyer's routing reference (BT-10); a German authority's Leitweg-ID goes here. */
81739
+ buyer_reference: text2.optional(),
81740
+ order_reference: text2.optional(),
81741
+ contract_reference: text2.optional(),
81742
+ note: text2.optional(),
81743
+ notes: z2.array(note).optional(),
81744
+ period: period.optional(),
81745
+ /** The invoices a credit note or a correction refers to (BG-3). */
81746
+ preceding_invoices: z2.array(z2.object({ number: text2, issue_date: isoDate2.optional() })).optional(),
81747
+ /** France (spec 17 §4.4): what was sold, and the billing framework's code where the plain case does not fit. */
81748
+ operation: z2.enum(["goods", "services", "mixed"]).optional(),
81749
+ operation_code: text2.optional(),
81750
+ seller: party.extend({
81751
+ tax_number: text2.optional(),
81752
+ /** Further legal information the invoice must state (BT-33): register court, capital. */
81753
+ legal_info: text2.optional(),
81754
+ /** France: VAT is owed when the invoice is issued, not when it is paid. */
81755
+ vat_on_debits: z2.boolean().optional()
81756
+ }),
81757
+ buyer: party.extend({
81758
+ /** France: the buyer's SIREN, nine digits. */
81759
+ siren: text2.optional()
81760
+ }),
81761
+ delivery: z2.object({
81762
+ name: text2.optional(),
81763
+ date: isoDate2.optional(),
81764
+ address: address.optional()
81765
+ }).optional(),
81766
+ lines: z2.array(line).min(1),
81767
+ /** Allowances and charges on the whole document (BG-20, BG-21), each with the VAT it falls under. */
81768
+ allowances: z2.array(allowanceOrCharge.extend({ tax: lineTax })).optional(),
81769
+ charges: z2.array(allowanceOrCharge.extend({ tax: lineTax })).optional(),
81770
+ tax: z2.object({ breakdown: z2.array(breakdown).min(1) }),
81771
+ totals,
81772
+ payment: payment.optional()
81773
+ });
81774
+ var einvoiceOptionsSchema = z2.object({
81775
+ profile: z2.string().optional(),
81776
+ flavour: z2.string().optional(),
81777
+ xml: z2.enum(["embedded", "both"]).optional(),
81778
+ display_check: z2.enum(["warn", "strict"]).optional()
81779
+ }).strict();
81780
+
80977
81781
  // packages/engine/src/lib/office/errors.ts
80978
81782
  var officeLimits = {
80979
81783
  /** Entries in one container. */
@@ -81014,7 +81818,10 @@ function multipart(fields, file) {
81014
81818
  form.set("file", blob, name);
81015
81819
  for (const [key, value] of Object.entries(fields)) {
81016
81820
  if (value === void 0) continue;
81017
- form.set(key, typeof value === "string" ? value : typeof value === "object" ? JSON.stringify(value) : String(value));
81821
+ form.set(
81822
+ key,
81823
+ typeof value === "string" ? value : typeof value === "object" ? JSON.stringify(value) : String(value)
81824
+ );
81018
81825
  }
81019
81826
  return form;
81020
81827
  }
@@ -81044,7 +81851,10 @@ function randomKey() {
81044
81851
  if (c?.randomUUID) return c.randomUUID();
81045
81852
  return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
81046
81853
  }
81047
- var withKey = (options) => ({ ...options, idempotencyKey: options.idempotencyKey ?? randomKey() });
81854
+ var withKey = (options) => ({
81855
+ ...options,
81856
+ idempotencyKey: options.idempotencyKey ?? randomKey()
81857
+ });
81048
81858
  var idOf = (source) => typeof source === "string" ? source : source.id;
81049
81859
  var Formfeed = class {
81050
81860
  baseUrl;
@@ -81054,14 +81864,28 @@ var Formfeed = class {
81054
81864
  timeoutMs;
81055
81865
  extraHeaders;
81056
81866
  constructor(options) {
81057
- if (!options.apiKey) throw new FormfeedError("invalid_request", "apiKey is required", 0);
81867
+ if (!options.apiKey)
81868
+ throw new FormfeedError("invalid_request", "apiKey is required", 0);
81058
81869
  this.apiKey = options.apiKey;
81059
- this.baseUrl = (options.baseUrl ?? hosts[options.region ?? "eu"]).replace(/\/$/, "");
81870
+ this.baseUrl = (options.baseUrl ?? hosts[options.region ?? "eu"]).replace(
81871
+ /\/$/,
81872
+ ""
81873
+ );
81060
81874
  this.fetchImpl = options.fetch ?? globalThis.fetch;
81061
81875
  this.maxRetries = options.maxRetries ?? 3;
81062
81876
  this.timeoutMs = options.timeoutMs ?? 12e4;
81063
- this.extraHeaders = Object.fromEntries(Object.entries(options.headers ?? {}).map(([name, value]) => [name.toLowerCase(), value]));
81064
- if (!this.fetchImpl) throw new FormfeedError("invalid_request", "fetch is not available; pass options.fetch", 0);
81877
+ this.extraHeaders = Object.fromEntries(
81878
+ Object.entries(options.headers ?? {}).map(([name, value]) => [
81879
+ name.toLowerCase(),
81880
+ value
81881
+ ])
81882
+ );
81883
+ if (!this.fetchImpl)
81884
+ throw new FormfeedError(
81885
+ "invalid_request",
81886
+ "fetch is not available; pass options.fetch",
81887
+ 0
81888
+ );
81065
81889
  }
81066
81890
  renders = {
81067
81891
  /** Renders a template, HTML or URL. Sync by default; `mode: 'async'` returns a queued render. */
@@ -81069,16 +81893,26 @@ var Formfeed = class {
81069
81893
  ...options,
81070
81894
  idempotencyKey: options.idempotencyKey ?? randomKey()
81071
81895
  }),
81072
- get: (id, options = {}) => this.request("GET", `/renders/${encodeURIComponent(id)}`, void 0, options),
81896
+ get: (id, options = {}) => this.request(
81897
+ "GET",
81898
+ `/renders/${encodeURIComponent(id)}`,
81899
+ void 0,
81900
+ options
81901
+ ),
81073
81902
  /** Polls until the render succeeded or failed (async renders). */
81074
81903
  waitFor: async (id, options = {}) => {
81075
81904
  const deadline = Date.now() + (options.timeoutMs ?? 12e4);
81076
81905
  const interval = options.intervalMs ?? 1e3;
81077
81906
  for (; ; ) {
81078
81907
  const render = await this.renders.get(id, { signal: options.signal });
81079
- if (render.status === "succeeded" || render.status === "failed") return render;
81908
+ if (render.status === "succeeded" || render.status === "failed")
81909
+ return render;
81080
81910
  if (Date.now() + interval > deadline)
81081
- throw new FormfeedError("timeout", `render ${id} did not finish within the wait time`, 0);
81911
+ throw new FormfeedError(
81912
+ "timeout",
81913
+ `render ${id} did not finish within the wait time`,
81914
+ 0
81915
+ );
81082
81916
  await sleep(interval, options.signal);
81083
81917
  }
81084
81918
  },
@@ -81086,17 +81920,34 @@ var Formfeed = class {
81086
81920
  download: async (render, options = {}) => {
81087
81921
  const target = typeof render === "string" ? await this.renders.get(render, options) : render;
81088
81922
  if (!target.download_url)
81089
- throw new FormfeedError("not_ready", `render ${target.id} has no output (${target.status})`, 0);
81090
- const res = await this.fetchImpl(target.download_url, { signal: options.signal });
81091
- if (!res.ok) throw new FormfeedError("download_failed", `download answered HTTP ${res.status}`, res.status);
81923
+ throw new FormfeedError(
81924
+ "not_ready",
81925
+ `render ${target.id} has no output (${target.status})`,
81926
+ 0
81927
+ );
81928
+ const res = await this.fetchImpl(target.download_url, {
81929
+ signal: options.signal
81930
+ });
81931
+ if (!res.ok)
81932
+ throw new FormfeedError(
81933
+ "download_failed",
81934
+ `download answered HTTP ${res.status}`,
81935
+ res.status
81936
+ );
81092
81937
  return new Uint8Array(await res.arrayBuffer());
81093
81938
  },
81094
81939
  /** Page of renders, newest first. */
81095
81940
  list: (query = {}, options = {}) => {
81096
81941
  const params = new URLSearchParams();
81097
- for (const [k2, v2] of Object.entries(query)) if (v2 !== void 0 && v2 !== null && v2 !== "") params.set(k2, String(v2));
81942
+ for (const [k2, v2] of Object.entries(query))
81943
+ if (v2 !== void 0 && v2 !== null && v2 !== "") params.set(k2, String(v2));
81098
81944
  const qs = params.toString();
81099
- return this.request("GET", `/renders${qs ? `?${qs}` : ""}`, void 0, options);
81945
+ return this.request(
81946
+ "GET",
81947
+ `/renders${qs ? `?${qs}` : ""}`,
81948
+ void 0,
81949
+ options
81950
+ );
81100
81951
  },
81101
81952
  /** Every render matching the query, following the cursor. */
81102
81953
  all: async (query = {}, options = {}) => {
@@ -81110,12 +81961,22 @@ var Formfeed = class {
81110
81961
  return out;
81111
81962
  },
81112
81963
  /** Removes the stored files of a render before they expire. Needs the `file:delete` scope. */
81113
- deleteOutputs: (id, options = {}) => this.request("DELETE", `/renders/${encodeURIComponent(id)}/outputs`, void 0, options),
81964
+ deleteOutputs: (id, options = {}) => this.request(
81965
+ "DELETE",
81966
+ `/renders/${encodeURIComponent(id)}/outputs`,
81967
+ void 0,
81968
+ options
81969
+ ),
81114
81970
  /**
81115
81971
  * The stored request of a render, to render it again. Needs `render:input`; throws
81116
81972
  * `render_input_expired` (410) when the workspace keeps no requests or the period ended.
81117
81973
  */
81118
- input: (id, options = {}) => this.request("GET", `/renders/${encodeURIComponent(id)}/input`, void 0, options),
81974
+ input: (id, options = {}) => this.request(
81975
+ "GET",
81976
+ `/renders/${encodeURIComponent(id)}/input`,
81977
+ void 0,
81978
+ options
81979
+ ),
81119
81980
  batch: (request, options = {}) => this.request("POST", "/renders/batch", request, {
81120
81981
  ...options,
81121
81982
  idempotencyKey: options.idempotencyKey ?? randomKey()
@@ -81127,10 +81988,30 @@ var Formfeed = class {
81127
81988
  * 0.5 units each on live keys; info is free.
81128
81989
  */
81129
81990
  pdf = {
81130
- merge: (sources, output = {}, options = {}) => this.request("POST", "/pdf/merge", { ...output, sources: sources.map(idOf) }, withKey(options)),
81131
- protect: (source, protect, options = {}) => this.request("POST", "/pdf/protect", { ...protect, source: idOf(source) }, withKey(options)),
81132
- watermark: (source, watermark, options = {}) => this.request("POST", "/pdf/watermark", { ...watermark, source: idOf(source) }, withKey(options)),
81133
- info: (source, options = {}) => this.request("POST", "/pdf/info", { source: idOf(source) }, options),
81991
+ merge: (sources, output = {}, options = {}) => this.request(
81992
+ "POST",
81993
+ "/pdf/merge",
81994
+ { ...output, sources: sources.map(idOf) },
81995
+ withKey(options)
81996
+ ),
81997
+ protect: (source, protect, options = {}) => this.request(
81998
+ "POST",
81999
+ "/pdf/protect",
82000
+ { ...protect, source: idOf(source) },
82001
+ withKey(options)
82002
+ ),
82003
+ watermark: (source, watermark, options = {}) => this.request(
82004
+ "POST",
82005
+ "/pdf/watermark",
82006
+ { ...watermark, source: idOf(source) },
82007
+ withKey(options)
82008
+ ),
82009
+ info: (source, options = {}) => this.request(
82010
+ "POST",
82011
+ "/pdf/info",
82012
+ { source: idOf(source) },
82013
+ options
82014
+ ),
81134
82015
  /**
81135
82016
  * Converts an office document to a PDF render (Starter plan and above): an uploaded file (Word,
81136
82017
  * Excel, PowerPoint, OpenDocument, RTF or HTML, up to 20 MB, not kept), or the output of a Word or
@@ -81139,8 +82020,18 @@ var Formfeed = class {
81139
82020
  */
81140
82021
  convert: (source, convert = {}, options = {}) => {
81141
82022
  if (typeof source === "object" && "file" in source)
81142
- return this.request("POST", "/pdf/convert", multipart({ ...convert }, source.file), withKey(options));
81143
- return this.request("POST", "/pdf/convert", { ...convert, source: idOf(source) }, withKey(options));
82023
+ return this.request(
82024
+ "POST",
82025
+ "/pdf/convert",
82026
+ multipart({ ...convert }, source.file),
82027
+ withKey(options)
82028
+ );
82029
+ return this.request(
82030
+ "POST",
82031
+ "/pdf/convert",
82032
+ { ...convert, source: idOf(source) },
82033
+ withKey(options)
82034
+ );
81144
82035
  }
81145
82036
  };
81146
82037
  /**
@@ -81152,7 +82043,10 @@ var Formfeed = class {
81152
82043
  files = {
81153
82044
  /** Uploads a file; the same name replaces the existing file in place and keeps its URL. */
81154
82045
  upload: (file, options = {}) => {
81155
- const blob = file.data instanceof Blob ? file.data : new Blob([file.data], file.contentType ? { type: file.contentType } : {});
82046
+ const blob = file.data instanceof Blob ? file.data : new Blob(
82047
+ [file.data],
82048
+ file.contentType ? { type: file.contentType } : {}
82049
+ );
81156
82050
  const form = new FormData();
81157
82051
  form.set("file", blob, file.name);
81158
82052
  form.set("name", file.name);
@@ -81161,9 +82055,15 @@ var Formfeed = class {
81161
82055
  /** Page of files, newest first. */
81162
82056
  list: (query = {}, options = {}) => {
81163
82057
  const params = new URLSearchParams();
81164
- for (const [k2, v2] of Object.entries(query)) if (v2 !== void 0 && v2 !== null && v2 !== "") params.set(k2, String(v2));
82058
+ for (const [k2, v2] of Object.entries(query))
82059
+ if (v2 !== void 0 && v2 !== null && v2 !== "") params.set(k2, String(v2));
81165
82060
  const qs = params.toString();
81166
- return this.request("GET", `/files${qs ? `?${qs}` : ""}`, void 0, options);
82061
+ return this.request(
82062
+ "GET",
82063
+ `/files${qs ? `?${qs}` : ""}`,
82064
+ void 0,
82065
+ options
82066
+ );
81167
82067
  },
81168
82068
  /** Every file matching the query, following the cursor. */
81169
82069
  all: async (query = {}, options = {}) => {
@@ -81176,9 +82076,19 @@ var Formfeed = class {
81176
82076
  } while (cursor);
81177
82077
  return out;
81178
82078
  },
81179
- get: (id, options = {}) => this.request("GET", `/files/${encodeURIComponent(id)}`, void 0, options),
82079
+ get: (id, options = {}) => this.request(
82080
+ "GET",
82081
+ `/files/${encodeURIComponent(id)}`,
82082
+ void 0,
82083
+ options
82084
+ ),
81180
82085
  /** Removes the file and its bytes; templates that name it render a missing image afterwards. */
81181
- delete: (file, options = {}) => this.request("DELETE", `/files/${encodeURIComponent(idOf(file))}`, void 0, options)
82086
+ delete: (file, options = {}) => this.request(
82087
+ "DELETE",
82088
+ `/files/${encodeURIComponent(idOf(file))}`,
82089
+ void 0,
82090
+ options
82091
+ )
81182
82092
  };
81183
82093
  /** The organisation's brand kit, read-only through the API (it is edited in the app). Needs `template:read`. */
81184
82094
  brand = {
@@ -81190,19 +82100,44 @@ var Formfeed = class {
81190
82100
  */
81191
82101
  partials = {
81192
82102
  /** Every shared partial, without its source. */
81193
- list: async (options = {}) => (await this.request("GET", "/partials", void 0, options)).data,
82103
+ list: async (options = {}) => (await this.request(
82104
+ "GET",
82105
+ "/partials",
82106
+ void 0,
82107
+ options
82108
+ )).data,
81194
82109
  /** One partial with its source. */
81195
- get: (name, options = {}) => this.request("GET", `/partials/${encodeURIComponent(name)}`, void 0, options),
82110
+ get: (name, options = {}) => this.request(
82111
+ "GET",
82112
+ `/partials/${encodeURIComponent(name)}`,
82113
+ void 0,
82114
+ options
82115
+ ),
81196
82116
  /** Creates or replaces a partial; pass `base_version` to fail with 409 when it changed since you read it. */
81197
82117
  put: async (name, input, options = {}) => {
81198
- const { status, body } = await this.send("PUT", `/partials/${encodeURIComponent(name)}`, input, options);
82118
+ const { status, body } = await this.send(
82119
+ "PUT",
82120
+ `/partials/${encodeURIComponent(name)}`,
82121
+ input,
82122
+ options
82123
+ );
81199
82124
  return { partial: body, created: status === 201 };
81200
82125
  },
81201
82126
  /** Removes a partial; templates that still include it fail to render afterwards. */
81202
- delete: (name, options = {}) => this.request("DELETE", `/partials/${encodeURIComponent(name)}`, void 0, options)
82127
+ delete: (name, options = {}) => this.request(
82128
+ "DELETE",
82129
+ `/partials/${encodeURIComponent(name)}`,
82130
+ void 0,
82131
+ options
82132
+ )
81203
82133
  };
81204
82134
  jobs = {
81205
- get: (id, options = {}) => this.request("GET", `/jobs/${encodeURIComponent(id)}`, void 0, options),
82135
+ get: (id, options = {}) => this.request(
82136
+ "GET",
82137
+ `/jobs/${encodeURIComponent(id)}`,
82138
+ void 0,
82139
+ options
82140
+ ),
81206
82141
  waitFor: async (id, options = {}) => {
81207
82142
  const deadline = Date.now() + (options.timeoutMs ?? 6e5);
81208
82143
  const interval = options.intervalMs ?? 2e3;
@@ -81210,37 +82145,77 @@ var Formfeed = class {
81210
82145
  const job = await this.jobs.get(id, { signal: options.signal });
81211
82146
  if (job.status !== "queued" && job.status !== "processing") return job;
81212
82147
  if (Date.now() + interval > deadline)
81213
- throw new FormfeedError("timeout", `job ${id} did not finish within the wait time`, 0);
82148
+ throw new FormfeedError(
82149
+ "timeout",
82150
+ `job ${id} did not finish within the wait time`,
82151
+ 0
82152
+ );
81214
82153
  await sleep(interval, options.signal);
81215
82154
  }
81216
82155
  }
81217
82156
  };
81218
82157
  webhooks = {
81219
- list: async (options = {}) => (await this.request("GET", "/webhooks", void 0, options)).data,
82158
+ list: async (options = {}) => (await this.request(
82159
+ "GET",
82160
+ "/webhooks",
82161
+ void 0,
82162
+ options
82163
+ )).data,
81220
82164
  create: (input, options = {}) => this.request("POST", "/webhooks", input, options),
81221
- update: (id, patch, options = {}) => this.request("PUT", `/webhooks/${encodeURIComponent(id)}`, patch, options),
81222
- delete: (id, options = {}) => this.request("DELETE", `/webhooks/${encodeURIComponent(id)}`, void 0, options),
81223
- test: (id, options = {}) => this.request("POST", `/webhooks/${encodeURIComponent(id)}/test`, void 0, options),
82165
+ update: (id, patch, options = {}) => this.request(
82166
+ "PUT",
82167
+ `/webhooks/${encodeURIComponent(id)}`,
82168
+ patch,
82169
+ options
82170
+ ),
82171
+ delete: (id, options = {}) => this.request(
82172
+ "DELETE",
82173
+ `/webhooks/${encodeURIComponent(id)}`,
82174
+ void 0,
82175
+ options
82176
+ ),
82177
+ test: (id, options = {}) => this.request(
82178
+ "POST",
82179
+ `/webhooks/${encodeURIComponent(id)}/test`,
82180
+ void 0,
82181
+ options
82182
+ ),
81224
82183
  /**
81225
82184
  * Sends a stored event (`evt_…`) again as a new delivery to a registered endpoint (`webhook:manage`)
81226
82185
  * or a running listen session (`webhook:listen`).
81227
82186
  */
81228
- resend: (eventId, endpointId, options = {}) => this.request("POST", `/webhooks/events/${encodeURIComponent(eventId)}/resend`, { endpoint_id: endpointId }, options),
82187
+ resend: (eventId, endpointId, options = {}) => this.request(
82188
+ "POST",
82189
+ `/webhooks/events/${encodeURIComponent(eventId)}/resend`,
82190
+ { endpoint_id: endpointId },
82191
+ options
82192
+ ),
81229
82193
  /**
81230
82194
  * Listen sessions, what `formfeed listen` uses. Needs `webhook:listen`. Starting a session ends the
81231
82195
  * previous one of the same key; the WebSocket itself is up to the caller.
81232
82196
  */
81233
82197
  listen: {
81234
82198
  start: (input = {}, options = {}) => this.request("POST", "/webhooks/listen", input, options),
81235
- end: (id, options = {}) => this.request("DELETE", `/webhooks/listen/${encodeURIComponent(id)}`, void 0, options)
82199
+ end: (id, options = {}) => this.request(
82200
+ "DELETE",
82201
+ `/webhooks/listen/${encodeURIComponent(id)}`,
82202
+ void 0,
82203
+ options
82204
+ )
81236
82205
  }
81237
82206
  };
81238
82207
  templates = {
81239
82208
  list: (query = {}, options = {}) => {
81240
82209
  const params = new URLSearchParams();
81241
- for (const [k2, v2] of Object.entries(query)) if (v2 !== void 0 && v2 !== null && v2 !== "") params.set(k2, String(v2));
82210
+ for (const [k2, v2] of Object.entries(query))
82211
+ if (v2 !== void 0 && v2 !== null && v2 !== "") params.set(k2, String(v2));
81242
82212
  const qs = params.toString();
81243
- return this.request("GET", `/templates${qs ? `?${qs}` : ""}`, void 0, options);
82213
+ return this.request(
82214
+ "GET",
82215
+ `/templates${qs ? `?${qs}` : ""}`,
82216
+ void 0,
82217
+ options
82218
+ );
81244
82219
  },
81245
82220
  /** Every template of the workspace, following the cursor. */
81246
82221
  all: async (query = {}, options = {}) => {
@@ -81253,27 +82228,63 @@ var Formfeed = class {
81253
82228
  } while (cursor);
81254
82229
  return out;
81255
82230
  },
81256
- get: (idOrSlug, options = {}) => this.request("GET", `/templates/${encodeURIComponent(idOrSlug)}`, void 0, options),
82231
+ get: (idOrSlug, options = {}) => this.request(
82232
+ "GET",
82233
+ `/templates/${encodeURIComponent(idOrSlug)}`,
82234
+ void 0,
82235
+ options
82236
+ ),
81257
82237
  /** A Word or PowerPoint template (`kind` `docx` or `pptx`) is created from its `file`, sent as multipart. */
81258
82238
  create: (input, options = {}) => {
81259
82239
  if (isOfficeInput(input) && input.file) {
81260
82240
  const { file, ...fields } = input;
81261
- return this.request("POST", "/templates", multipart(fields, file), options);
82241
+ return this.request(
82242
+ "POST",
82243
+ "/templates",
82244
+ multipart(fields, file),
82245
+ options
82246
+ );
81262
82247
  }
81263
82248
  return this.request("POST", "/templates", input, options);
81264
82249
  },
81265
- update: (idOrSlug, patch, options = {}) => this.request("PUT", `/templates/${encodeURIComponent(idOrSlug)}`, patch, options),
81266
- archive: (idOrSlug, options = {}) => this.request("DELETE", `/templates/${encodeURIComponent(idOrSlug)}`, void 0, options),
82250
+ update: (idOrSlug, patch, options = {}) => this.request(
82251
+ "PUT",
82252
+ `/templates/${encodeURIComponent(idOrSlug)}`,
82253
+ patch,
82254
+ options
82255
+ ),
82256
+ archive: (idOrSlug, options = {}) => this.request(
82257
+ "DELETE",
82258
+ `/templates/${encodeURIComponent(idOrSlug)}`,
82259
+ void 0,
82260
+ options
82261
+ ),
81267
82262
  versions: {
81268
- list: async (idOrSlug, options = {}) => (await this.request("GET", `/templates/${encodeURIComponent(idOrSlug)}/versions`, void 0, options)).data,
82263
+ list: async (idOrSlug, options = {}) => (await this.request(
82264
+ "GET",
82265
+ `/templates/${encodeURIComponent(idOrSlug)}/versions`,
82266
+ void 0,
82267
+ options
82268
+ )).data,
81269
82269
  /** `which`: 'published', 'latest', a version number or a channel name (its main version). Carries the files. */
81270
- get: (idOrSlug, which = "published", options = {}) => this.request("GET", `/templates/${encodeURIComponent(idOrSlug)}/versions/${encodeURIComponent(String(which))}`, void 0, options),
82270
+ get: (idOrSlug, which = "published", options = {}) => this.request(
82271
+ "GET",
82272
+ `/templates/${encodeURIComponent(idOrSlug)}/versions/${encodeURIComponent(String(which))}`,
82273
+ void 0,
82274
+ options
82275
+ ),
81271
82276
  /** For a Word or PowerPoint template, pass `file` to replace the document; without it the latest file is kept. */
81272
82277
  create: (idOrSlug, input, options = {}) => {
81273
82278
  const path = `/templates/${encodeURIComponent(idOrSlug)}/versions`;
81274
82279
  if (isOfficeInput(input)) {
81275
82280
  const { file, ...fields } = input;
81276
- if (file) return this.request("POST", path, multipart(fields, file), options);
82281
+ if (file)
82282
+ return this.request(
82283
+ "POST",
82284
+ path,
82285
+ multipart(fields, file),
82286
+ options
82287
+ );
81277
82288
  return this.request("POST", path, fields, options);
81278
82289
  }
81279
82290
  return this.request("POST", path, input, options);
@@ -81302,7 +82313,12 @@ var Formfeed = class {
81302
82313
  * uses the version the channel points at. Moves reach renders within a minute.
81303
82314
  */
81304
82315
  channels: {
81305
- list: (idOrSlug, options = {}) => this.request("GET", `/templates/${encodeURIComponent(idOrSlug)}/channels`, void 0, options),
82316
+ list: (idOrSlug, options = {}) => this.request(
82317
+ "GET",
82318
+ `/templates/${encodeURIComponent(idOrSlug)}/channels`,
82319
+ void 0,
82320
+ options
82321
+ ),
81306
82322
  /** Creates or moves a channel; on `published` this publishes. */
81307
82323
  set: (idOrSlug, name, move, options = {}) => {
81308
82324
  const { allowBreaking, ...rest } = options;
@@ -81336,19 +82352,39 @@ var Formfeed = class {
81336
82352
  schema: (idOrSlug, options = {}) => {
81337
82353
  const { version, ...rest } = options;
81338
82354
  const query = version === void 0 ? "" : `?version=${encodeURIComponent(String(version))}`;
81339
- return this.request("GET", `/templates/${encodeURIComponent(idOrSlug)}/schema${query}`, void 0, rest);
82355
+ return this.request(
82356
+ "GET",
82357
+ `/templates/${encodeURIComponent(idOrSlug)}/schema${query}`,
82358
+ void 0,
82359
+ rest
82360
+ );
81340
82361
  },
81341
82362
  /**
81342
82363
  * Checks a version with data without rendering: syntax, header and footer, missing partials,
81343
82364
  * runtime errors and the data against the stored schema. Free. Without `data`, the version's
81344
82365
  * sample data is checked. `version` takes a channel name too.
81345
82366
  */
81346
- validate: (idOrSlug, input = {}, options = {}) => this.request("POST", `/templates/${encodeURIComponent(idOrSlug)}/validate`, input, options)
82367
+ validate: (idOrSlug, input = {}, options = {}) => this.request(
82368
+ "POST",
82369
+ `/templates/${encodeURIComponent(idOrSlug)}/validate`,
82370
+ input,
82371
+ options
82372
+ )
81347
82373
  };
81348
82374
  account = {
81349
- get: (options = {}) => this.request("GET", "/account", void 0, options),
82375
+ get: (options = {}) => this.request(
82376
+ "GET",
82377
+ "/account",
82378
+ void 0,
82379
+ options
82380
+ ),
81350
82381
  /** Units of the current period, or of `YYYY-MM`, with a daily series and a breakdown per template. */
81351
- usage: (period = "current", options = {}) => this.request("GET", `/usage?period=${encodeURIComponent(period)}`, void 0, options)
82382
+ usage: (period2 = "current", options = {}) => this.request(
82383
+ "GET",
82384
+ `/usage?period=${encodeURIComponent(period2)}`,
82385
+ void 0,
82386
+ options
82387
+ )
81352
82388
  };
81353
82389
  /** Workspaces of the key's organisation. Needs `workspace:delete`, which no key has by default. */
81354
82390
  workspaces = {
@@ -81356,7 +82392,12 @@ var Formfeed = class {
81356
82392
  * Deletes a workspace: it leaves the app and the API at once, its keys are revoked and its content
81357
82393
  * is removed after 30 days. The organisation's last workspace is refused with `last_workspace`.
81358
82394
  */
81359
- delete: (id, options = {}) => this.request("DELETE", `/workspaces/${encodeURIComponent(id)}`, void 0, options)
82395
+ delete: (id, options = {}) => this.request(
82396
+ "DELETE",
82397
+ `/workspaces/${encodeURIComponent(id)}`,
82398
+ void 0,
82399
+ options
82400
+ )
81360
82401
  };
81361
82402
  channelAction(idOrSlug, name, action, options) {
81362
82403
  const { allowBreaking, ...rest } = options;
@@ -81384,13 +82425,21 @@ var Formfeed = class {
81384
82425
  ...this.extraHeaders
81385
82426
  };
81386
82427
  const isForm = typeof FormData !== "undefined" && body instanceof FormData;
81387
- if (body !== void 0 && !isForm) headers["content-type"] = "application/json";
81388
- if (options.idempotencyKey) headers["idempotency-key"] = options.idempotencyKey;
82428
+ if (body !== void 0 && !isForm)
82429
+ headers["content-type"] = "application/json";
82430
+ if (options.idempotencyKey)
82431
+ headers["idempotency-key"] = options.idempotencyKey;
81389
82432
  let attempt = 0;
81390
82433
  for (; ; ) {
81391
82434
  const controller = new AbortController();
81392
- const timer = setTimeout(() => controller.abort(new Error("request timed out")), this.timeoutMs);
81393
- options.signal?.addEventListener("abort", () => controller.abort(options.signal?.reason));
82435
+ const timer = setTimeout(
82436
+ () => controller.abort(new Error("request timed out")),
82437
+ this.timeoutMs
82438
+ );
82439
+ options.signal?.addEventListener(
82440
+ "abort",
82441
+ () => controller.abort(options.signal?.reason)
82442
+ );
81394
82443
  let res;
81395
82444
  try {
81396
82445
  res = await this.fetchImpl(url, {
@@ -81406,22 +82455,38 @@ var Formfeed = class {
81406
82455
  await sleep(this.backoff(attempt, null), options.signal);
81407
82456
  continue;
81408
82457
  }
81409
- throw new FormfeedError("network_error", e instanceof Error ? e.message : String(e), 0);
82458
+ throw new FormfeedError(
82459
+ "network_error",
82460
+ e instanceof Error ? e.message : String(e),
82461
+ 0
82462
+ );
81410
82463
  }
81411
82464
  clearTimeout(timer);
81412
82465
  if ((res.status === 429 || res.status === 503) && attempt < this.maxRetries) {
81413
82466
  attempt++;
81414
- await sleep(this.backoff(attempt, res.headers.get("retry-after")), options.signal);
82467
+ await sleep(
82468
+ this.backoff(attempt, res.headers.get("retry-after")),
82469
+ options.signal
82470
+ );
81415
82471
  continue;
81416
82472
  }
81417
82473
  if (res.status === 204) return { status: 204, body: void 0 };
81418
- if (as === "bytes" && res.ok) return { status: res.status, body: new Uint8Array(await res.arrayBuffer()) };
81419
- const text2 = await res.text();
82474
+ if (as === "bytes" && res.ok)
82475
+ return {
82476
+ status: res.status,
82477
+ body: new Uint8Array(await res.arrayBuffer())
82478
+ };
82479
+ const text4 = await res.text();
81420
82480
  let json2 = null;
81421
82481
  try {
81422
- json2 = text2 ? JSON.parse(text2) : null;
82482
+ json2 = text4 ? JSON.parse(text4) : null;
81423
82483
  } catch {
81424
- if (res.ok) throw new FormfeedError("invalid_response", `the API answered HTTP ${res.status} with a body that is not JSON`, res.status);
82484
+ if (res.ok)
82485
+ throw new FormfeedError(
82486
+ "invalid_response",
82487
+ `the API answered HTTP ${res.status} with a body that is not JSON`,
82488
+ res.status
82489
+ );
81425
82490
  }
81426
82491
  if (!res.ok) {
81427
82492
  const problem = json2 ?? {};
@@ -81447,14 +82512,23 @@ var Formfeed = class {
81447
82512
  var encoder2 = new TextEncoder();
81448
82513
 
81449
82514
  // packages/mcp/src/lib/server.ts
81450
- import { z as z2 } from "zod";
82515
+ import { z as z3 } from "zod";
81451
82516
  var CONVERT_LIMIT_BYTES = 20 * 1024 * 1024;
81452
- var SERVER_INFO = { name: "formfeed", version: "0.3.10" };
81453
- var READS = { readOnlyHint: true, destructiveHint: false, openWorldHint: false };
81454
- var CREATES = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
81455
- var engineSchema = z2.enum(["jinja2", "liquid", "handlebars"]);
81456
- var outputSchema = z2.enum(outputFormats);
81457
- var kindSchema = z2.enum(["pdf", "image", "docx", "pptx"]);
82517
+ var SERVER_INFO = { name: "formfeed", version: "0.3.12" };
82518
+ var READS = {
82519
+ readOnlyHint: true,
82520
+ destructiveHint: false,
82521
+ openWorldHint: false
82522
+ };
82523
+ var CREATES = {
82524
+ readOnlyHint: false,
82525
+ destructiveHint: false,
82526
+ idempotentHint: false,
82527
+ openWorldHint: false
82528
+ };
82529
+ var engineSchema = z3.enum(["jinja2", "liquid", "handlebars"]);
82530
+ var outputSchema = z3.enum(outputFormats);
82531
+ var kindSchema = z3.enum(["pdf", "image", "docx", "pptx"]);
81458
82532
  var templateSummary = (t) => ({
81459
82533
  id: t.id,
81460
82534
  slug: t.slug,
@@ -81477,17 +82551,26 @@ var renderSummary = (r) => ({
81477
82551
  template: r.template,
81478
82552
  error: r.error
81479
82553
  });
81480
- function text(data) {
81481
- return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], structuredContent: data };
82554
+ function text3(data) {
82555
+ return {
82556
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
82557
+ structuredContent: data
82558
+ };
81482
82559
  }
81483
82560
  function failure(e) {
81484
82561
  const message2 = e instanceof FormfeedError ? `${e.code}: ${e.message}` : e instanceof Error ? e.message : String(e);
81485
- return { content: [{ type: "text", text: message2 }], isError: true };
82562
+ return {
82563
+ content: [{ type: "text", text: message2 }],
82564
+ isError: true
82565
+ };
81486
82566
  }
81487
82567
  function createFormfeedServer(options) {
81488
82568
  const client = new Formfeed({
81489
82569
  apiKey: options.apiKey,
81490
- headers: { "user-agent": `formfeed-mcp/${SERVER_INFO.version}`, ...options.workspaceId ? { "x-formfeed-workspace": options.workspaceId } : {} },
82570
+ headers: {
82571
+ "user-agent": `formfeed-mcp/${SERVER_INFO.version}`,
82572
+ ...options.workspaceId ? { "x-formfeed-workspace": options.workspaceId } : {}
82573
+ },
81491
82574
  ...options.region ? { region: options.region } : {},
81492
82575
  ...options.baseUrl ? { baseUrl: options.baseUrl } : {},
81493
82576
  ...options.fetch ? { fetch: options.fetch } : {}
@@ -81503,15 +82586,19 @@ function createFormfeedServer(options) {
81503
82586
  inputSchema: {
81504
82587
  kind: kindSchema.optional().describe("Only templates that produce this kind of document"),
81505
82588
  engine: engineSchema.optional().describe("Only templates written in this template language"),
81506
- tag: z2.string().optional().describe("Only templates with this tag; exact match, tags are lowercase with dashes (e.g. billing)"),
81507
- q: z2.string().optional().describe("Text to find in the name or slug, case-insensitive (e.g. invoice)")
82589
+ tag: z3.string().optional().describe(
82590
+ "Only templates with this tag; exact match, tags are lowercase with dashes (e.g. billing)"
82591
+ ),
82592
+ q: z3.string().optional().describe(
82593
+ "Text to find in the name or slug, case-insensitive (e.g. invoice)"
82594
+ )
81508
82595
  },
81509
82596
  annotations: READS
81510
82597
  },
81511
82598
  async (args2) => {
81512
82599
  try {
81513
82600
  const templates = await client.templates.all(args2);
81514
- return text({ templates: templates.map(templateSummary) });
82601
+ return text3({ templates: templates.map(templateSummary) });
81515
82602
  } catch (e) {
81516
82603
  return failure(e);
81517
82604
  }
@@ -81522,17 +82609,28 @@ function createFormfeedServer(options) {
81522
82609
  {
81523
82610
  title: "Get the data schema of a template",
81524
82611
  description: "Returns the JSON Schema of the `data` object a template expects and the sample data it was designed with, from its published version, else its latest draft. Call it after list_templates and before render or validate_template, to build data that fits; ad-hoc html has no stored schema to read. When the template stores no schema, one is inferred from the sample data: treat that as a guide, not a contract. Read-only and free; an unknown slug returns an error.",
81525
- inputSchema: { template: z2.string().describe("Slug (e.g. invoice) or tpl_ id, as list_templates returns them") },
82612
+ inputSchema: {
82613
+ template: z3.string().describe(
82614
+ "Slug (e.g. invoice) or tpl_ id, as list_templates returns them"
82615
+ )
82616
+ },
81526
82617
  annotations: READS
81527
82618
  },
81528
82619
  async ({ template }) => {
81529
82620
  try {
81530
82621
  const version = await client.templates.versions.get(template, "published").catch(async (e) => {
81531
- if (e.status === 404) return client.templates.versions.get(template, "latest");
82622
+ if (e.status === 404)
82623
+ return client.templates.versions.get(template, "latest");
81532
82624
  throw e;
81533
82625
  });
81534
82626
  const schema = version.data_schema ?? inferSchema(version.sample_data ?? {});
81535
- return text({ template, version: version.number, status: version.status, schema, sample_data: version.sample_data ?? {} });
82627
+ return text3({
82628
+ template,
82629
+ version: version.number,
82630
+ status: version.status,
82631
+ schema,
82632
+ sample_data: version.sample_data ?? {}
82633
+ });
81536
82634
  } catch (e) {
81537
82635
  return failure(e);
81538
82636
  }
@@ -81544,22 +82642,29 @@ function createFormfeedServer(options) {
81544
82642
  title: "Validate a template with data",
81545
82643
  description: "Checks a template and its data without rendering: free, no units, nothing stored, no document produced. Call it before render when you assembled the data yourself, or after writing ad-hoc html. With template, the API checks the published version (else the latest) as a render would: syntax, header and footer, errors only this data triggers, and the data against the stored JSON Schema (a wrong type or a missing required field is an error). With html and engine it compiles offline and reports syntax errors, unknown filters and variables missing from data. Returns ok and diagnostics (severity, code, message, plus path, line and column, or part and paragraph for Word and PowerPoint). Warnings leave ok true: settle each before rendering.",
81546
82644
  inputSchema: {
81547
- template: z2.string().optional().describe("Slug or tpl_ id of a stored template; pass this or html"),
81548
- html: z2.string().optional().describe("Template source to check offline, when there is no stored template; pass this or template"),
82645
+ template: z3.string().optional().describe("Slug or tpl_ id of a stored template; pass this or html"),
82646
+ html: z3.string().optional().describe(
82647
+ "Template source to check offline, when there is no stored template; pass this or template"
82648
+ ),
81549
82649
  engine: engineSchema.optional().describe("Template language of html; required with html"),
81550
- data: z2.record(z2.string(), z2.unknown()).optional().describe("The data the document will be rendered with, shaped as get_template_schema describes. Left out, a stored template is checked with its sample data")
82650
+ data: z3.record(z3.string(), z3.unknown()).optional().describe(
82651
+ "The data the document will be rendered with, shaped as get_template_schema describes. Left out, a stored template is checked with its sample data"
82652
+ )
81551
82653
  },
81552
82654
  annotations: READS
81553
82655
  },
81554
82656
  async ({ template, html, engine, data }) => {
81555
82657
  try {
81556
82658
  if (template) {
81557
- const check = (version) => client.templates.validate(template, { version, ...data ? { data } : {} });
82659
+ const check = (version) => client.templates.validate(template, {
82660
+ version,
82661
+ ...data ? { data } : {}
82662
+ });
81558
82663
  const result = await check("published").catch((e) => {
81559
82664
  if (e.status === 404) return check("latest");
81560
82665
  throw e;
81561
82666
  });
81562
- return text({
82667
+ return text3({
81563
82668
  ok: result.ok,
81564
82669
  template: result.template,
81565
82670
  diagnostics: result.diagnostics.map((d) => ({
@@ -81572,18 +82677,35 @@ function createFormfeedServer(options) {
81572
82677
  }))
81573
82678
  });
81574
82679
  }
81575
- if (!html || !engine) return failure(new Error("Pass a template slug, or html and engine"));
82680
+ if (!html || !engine)
82681
+ return failure(new Error("Pass a template slug, or html and engine"));
81576
82682
  const eng = getEngine(engine);
81577
82683
  const diagnostics = [];
81578
82684
  try {
81579
82685
  eng.compile(html, { name: "ad-hoc" });
81580
82686
  } catch (e) {
81581
- diagnostics.push({ severity: "error", code: "syntax-error", message: e instanceof Error ? e.message : String(e), range: { start: { line: 1, column: 1 }, end: { line: 1, column: 2 } } });
82687
+ diagnostics.push({
82688
+ severity: "error",
82689
+ code: "syntax-error",
82690
+ message: e instanceof Error ? e.message : String(e),
82691
+ range: {
82692
+ start: { line: 1, column: 1 },
82693
+ end: { line: 1, column: 2 }
82694
+ }
82695
+ });
81582
82696
  }
81583
- diagnostics.push(...eng.analyze(html, { sampleData: data ?? {} }).diagnostics);
81584
- return text({
82697
+ diagnostics.push(
82698
+ ...eng.analyze(html, { sampleData: data ?? {} }).diagnostics
82699
+ );
82700
+ return text3({
81585
82701
  ok: !diagnostics.some((d) => d.severity === "error"),
81586
- diagnostics: diagnostics.map((d) => ({ severity: d.severity, code: d.code, message: d.message, line: d.range.start.line, column: d.range.start.column }))
82702
+ diagnostics: diagnostics.map((d) => ({
82703
+ severity: d.severity,
82704
+ code: d.code,
82705
+ message: d.message,
82706
+ line: d.range.start.line,
82707
+ column: d.range.start.column
82708
+ }))
81587
82709
  });
81588
82710
  } catch (e) {
81589
82711
  return failure(e);
@@ -81596,22 +82718,42 @@ function createFormfeedServer(options) {
81596
82718
  title: "Render a document",
81597
82719
  description: "Creates a document by filling a stored template, or ad-hoc html, with data: a PDF or image, or DOCX, PPTX or PDF from Word and PowerPoint templates. Returns the render with status and download_url. Use it to make a document from data; to turn an existing office file into a PDF, use convert_to_pdf. Stored templates render their published version, so one whose published_version is null fails with template_not_found. Every call is a new render: a live key consumes units, a test key is free (watermarked on the Free plan). A render that fails returns status failed and an error with code and message; validate_template finds most causes beforehand. The link expires at expires_at; get_render issues a fresh one.",
81598
82720
  inputSchema: {
81599
- template: z2.string().optional().describe("Slug or tpl_ id of a stored template; pass this or html"),
81600
- html: z2.string().optional().describe("A complete HTML document to render instead of a stored template, up to 5 MB"),
81601
- engine: engineSchema.optional().describe("Template language of html, when it contains expressions to fill from data"),
81602
- data: z2.record(z2.string(), z2.unknown()).optional().describe("Values for the template, shaped as get_template_schema describes; leave out when it needs none"),
82721
+ template: z3.string().optional().describe("Slug or tpl_ id of a stored template; pass this or html"),
82722
+ html: z3.string().optional().describe(
82723
+ "A complete HTML document to render instead of a stored template, up to 5 MB"
82724
+ ),
82725
+ engine: engineSchema.optional().describe(
82726
+ "Template language of html, when it contains expressions to fill from data"
82727
+ ),
82728
+ data: z3.record(z3.string(), z3.unknown()).optional().describe(
82729
+ "Values for the template, shaped as get_template_schema describes; leave out when it needs none"
82730
+ ),
81603
82731
  output: outputSchema.optional().describe(
81604
82732
  "Left out, the template decides: PDF for PDF templates and html, its image format for image templates, its default output for Word and PowerPoint templates. Word templates render docx or pdf, PowerPoint templates pptx or pdf"
81605
82733
  ),
81606
- filename: z2.string().optional().describe("Name of the file behind download_url, e.g. invoice-2026-0042.pdf"),
81607
- locale: z2.string().optional().describe("BCP 47 tag for helpers and translations, e.g. de-DE"),
81608
- wait: z2.boolean().default(true).describe("Most renders are finished when the call returns; true also waits for one that continues in the background, false returns it as it is (queued or rendering) to check later with get_render")
82734
+ filename: z3.string().optional().describe(
82735
+ "Name of the file behind download_url, e.g. invoice-2026-0042.pdf"
82736
+ ),
82737
+ locale: z3.string().optional().describe("BCP 47 tag for helpers and translations, e.g. de-DE"),
82738
+ wait: z3.boolean().default(true).describe(
82739
+ "Most renders are finished when the call returns; true also waits for one that continues in the background, false returns it as it is (queued or rendering) to check later with get_render"
82740
+ )
81609
82741
  },
81610
82742
  annotations: CREATES
81611
82743
  },
81612
- async ({ template, html, engine, data, output, filename, locale, wait }) => {
82744
+ async ({
82745
+ template,
82746
+ html,
82747
+ engine,
82748
+ data,
82749
+ output,
82750
+ filename,
82751
+ locale,
82752
+ wait
82753
+ }) => {
81613
82754
  try {
81614
- if (!template && !html) return failure(new Error("Pass template or html"));
82755
+ if (!template && !html)
82756
+ return failure(new Error("Pass template or html"));
81615
82757
  let render = await client.renders.create({
81616
82758
  ...template ? { template } : {},
81617
82759
  ...html ? { html } : {},
@@ -81622,8 +82764,9 @@ function createFormfeedServer(options) {
81622
82764
  ...locale ? { locale } : {},
81623
82765
  meta: { source: "mcp" }
81624
82766
  });
81625
- if (wait && render.status !== "succeeded" && render.status !== "failed") render = await client.renders.waitFor(render.id);
81626
- return text(renderSummary(render));
82767
+ if (wait && render.status !== "succeeded" && render.status !== "failed")
82768
+ render = await client.renders.waitFor(render.id);
82769
+ return text3(renderSummary(render));
81627
82770
  } catch (e) {
81628
82771
  return failure(e);
81629
82772
  }
@@ -81641,23 +82784,46 @@ function createFormfeedServer(options) {
81641
82784
  "Every call is a new render that counts units like a PDF; the Free plan cannot convert (Starter and above). The document is converted and not kept."
81642
82785
  ].join(" "),
81643
82786
  inputSchema: {
81644
- render_id: z2.string().optional().describe("rnd_ id of a render whose output is docx or pptx, to get that document as a PDF"),
81645
- ...options.localFiles ? { path: z2.string().optional().describe("Absolute path of the document on this machine") } : {},
81646
- file_base64: z2.string().optional().describe("The document to convert, base64 encoded; needs file_name"),
81647
- file_name: z2.string().optional().describe("Name of the document, e.g. report.xlsx; the type is read from the content"),
81648
- page_ranges: z2.string().regex(/^\d+(-\d+)?(,\d+(-\d+)?)*$/).optional().describe("Pages to convert, e.g. 1-3,5; all pages when left out"),
81649
- landscape: z2.boolean().optional().describe("Landscape for spreadsheets and documents without their own page setup"),
81650
- single_page_sheets: z2.boolean().optional().describe("Each spreadsheet sheet on one page"),
81651
- filename: z2.string().optional().describe("Name of the PDF behind download_url, e.g. report.pdf")
82787
+ render_id: z3.string().optional().describe(
82788
+ "rnd_ id of a render whose output is docx or pptx, to get that document as a PDF"
82789
+ ),
82790
+ ...options.localFiles ? {
82791
+ path: z3.string().optional().describe("Absolute path of the document on this machine")
82792
+ } : {},
82793
+ file_base64: z3.string().optional().describe("The document to convert, base64 encoded; needs file_name"),
82794
+ file_name: z3.string().optional().describe(
82795
+ "Name of the document, e.g. report.xlsx; the type is read from the content"
82796
+ ),
82797
+ page_ranges: z3.string().regex(/^\d+(-\d+)?(,\d+(-\d+)?)*$/).optional().describe("Pages to convert, e.g. 1-3,5; all pages when left out"),
82798
+ landscape: z3.boolean().optional().describe(
82799
+ "Landscape for spreadsheets and documents without their own page setup"
82800
+ ),
82801
+ single_page_sheets: z3.boolean().optional().describe("Each spreadsheet sheet on one page"),
82802
+ filename: z3.string().optional().describe("Name of the PDF behind download_url, e.g. report.pdf")
81652
82803
  },
81653
82804
  annotations: CREATES
81654
82805
  },
81655
82806
  async (args2) => {
81656
82807
  try {
81657
- const { render_id, file_base64, file_name, page_ranges, landscape, single_page_sheets, filename } = args2;
82808
+ const {
82809
+ render_id,
82810
+ file_base64,
82811
+ file_name,
82812
+ page_ranges,
82813
+ landscape,
82814
+ single_page_sheets,
82815
+ filename
82816
+ } = args2;
81658
82817
  const path = args2.path;
81659
- const sources = [render_id, file_base64, path].filter((s) => s !== void 0 && s !== "");
81660
- if (sources.length !== 1) return failure(new Error("Pass exactly one of render_id, file_base64" + (options.localFiles ? " or path" : "")));
82818
+ const sources = [render_id, file_base64, path].filter(
82819
+ (s) => s !== void 0 && s !== ""
82820
+ );
82821
+ if (sources.length !== 1)
82822
+ return failure(
82823
+ new Error(
82824
+ "Pass exactly one of render_id, file_base64" + (options.localFiles ? " or path" : "")
82825
+ )
82826
+ );
81661
82827
  const convert = {
81662
82828
  meta: { source: "mcp" },
81663
82829
  ...page_ranges ? { page_ranges } : {},
@@ -81674,20 +82840,41 @@ function createFormfeedServer(options) {
81674
82840
  if (path) {
81675
82841
  const { readFile, stat } = await import("node:fs/promises");
81676
82842
  const { basename } = await import("node:path");
81677
- if ((await stat(path)).size > CONVERT_LIMIT_BYTES) return failure(new Error(`${path} is larger than 20 MB, the limit for conversions`));
82843
+ if ((await stat(path)).size > CONVERT_LIMIT_BYTES)
82844
+ return failure(
82845
+ new Error(
82846
+ `${path} is larger than 20 MB, the limit for conversions`
82847
+ )
82848
+ );
81678
82849
  data = new Uint8Array(await readFile(path));
81679
82850
  name = file_name ?? basename(path);
81680
82851
  } else {
81681
- if (!file_name) return failure(new Error("file_name is required with file_base64"));
82852
+ if (!file_name)
82853
+ return failure(
82854
+ new Error("file_name is required with file_base64")
82855
+ );
81682
82856
  data = Uint8Array.from(Buffer.from(file_base64, "base64"));
81683
- if (data.length === 0) return failure(new Error("file_base64 is empty or not base64"));
81684
- if (data.length > CONVERT_LIMIT_BYTES) return failure(new Error("The document is larger than 20 MB, the limit for conversions"));
82857
+ if (data.length === 0)
82858
+ return failure(new Error("file_base64 is empty or not base64"));
82859
+ if (data.length > CONVERT_LIMIT_BYTES)
82860
+ return failure(
82861
+ new Error(
82862
+ "The document is larger than 20 MB, the limit for conversions"
82863
+ )
82864
+ );
81685
82865
  name = file_name;
81686
82866
  }
81687
- render = await client.pdf.convert({ file: { data, name } }, { ...convert, ...filename ? {} : { filename: `${name.replace(/\.[^.]+$/, "")}.pdf` } });
82867
+ render = await client.pdf.convert(
82868
+ { file: { data, name } },
82869
+ {
82870
+ ...convert,
82871
+ ...filename ? {} : { filename: `${name.replace(/\.[^.]+$/, "")}.pdf` }
82872
+ }
82873
+ );
81688
82874
  }
81689
- if (render.status !== "succeeded" && render.status !== "failed") render = await client.renders.waitFor(render.id);
81690
- return text(renderSummary(render));
82875
+ if (render.status !== "succeeded" && render.status !== "failed")
82876
+ render = await client.renders.waitFor(render.id);
82877
+ return text3(renderSummary(render));
81691
82878
  } catch (e) {
81692
82879
  return failure(e);
81693
82880
  }
@@ -81698,12 +82885,16 @@ function createFormfeedServer(options) {
81698
82885
  {
81699
82886
  title: "Get a render",
81700
82887
  description: "Returns the current state of a render: status (queued, rendering, succeeded or failed), download_url with expires_at, page_count, units and error. Use it to follow a render started with wait false, or to get a fresh link once the old one has expired; render and convert_to_pdf already return this for the render they just made. Read-only and free; an unknown id returns an error.",
81701
- inputSchema: { id: z2.string().describe("rnd_ id of the render, as render or convert_to_pdf returned it") },
82888
+ inputSchema: {
82889
+ id: z3.string().describe(
82890
+ "rnd_ id of the render, as render or convert_to_pdf returned it"
82891
+ )
82892
+ },
81702
82893
  annotations: READS
81703
82894
  },
81704
82895
  async ({ id }) => {
81705
82896
  try {
81706
- return text(renderSummary(await client.renders.get(id)));
82897
+ return text3(renderSummary(await client.renders.get(id)));
81707
82898
  } catch (e) {
81708
82899
  return failure(e);
81709
82900
  }