@valbuild/ui 0.43.0 → 0.44.0

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.
@@ -32887,6 +32887,63 @@ var ArraySchema = /* @__PURE__ */ function(_Schema) {
32887
32887
  }]);
32888
32888
  return ArraySchema2;
32889
32889
  }(Schema);
32890
+ var LiteralSchema = /* @__PURE__ */ function(_Schema) {
32891
+ _inherits(LiteralSchema2, _Schema);
32892
+ var _super = _createSuper(LiteralSchema2);
32893
+ function LiteralSchema2(value) {
32894
+ var _this;
32895
+ var opt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
32896
+ _classCallCheck(this, LiteralSchema2);
32897
+ _this = _super.call(this);
32898
+ _this.value = value;
32899
+ _this.opt = opt;
32900
+ return _this;
32901
+ }
32902
+ _createClass(LiteralSchema2, [{
32903
+ key: "validate",
32904
+ value: function validate(path, src) {
32905
+ if (this.opt && (src === null || src === void 0)) {
32906
+ return false;
32907
+ }
32908
+ if (typeof src !== "string") {
32909
+ return _defineProperty$1({}, path, [{
32910
+ message: "Expected 'string', got '".concat(_typeof(src), "'"),
32911
+ value: src
32912
+ }]);
32913
+ }
32914
+ if (src !== this.value) {
32915
+ return _defineProperty$1({}, path, [{
32916
+ message: "Expected literal '".concat(this.value, "', got '").concat(src, "'"),
32917
+ value: src
32918
+ }]);
32919
+ }
32920
+ return false;
32921
+ }
32922
+ }, {
32923
+ key: "assert",
32924
+ value: function assert(src) {
32925
+ if (this.opt && (src === null || src === void 0)) {
32926
+ return true;
32927
+ }
32928
+ return typeof src === "string";
32929
+ }
32930
+ }, {
32931
+ key: "optional",
32932
+ value: function optional() {
32933
+ return new LiteralSchema2(this.value, true);
32934
+ }
32935
+ }, {
32936
+ key: "serialize",
32937
+ value: function serialize() {
32938
+ return {
32939
+ type: "literal",
32940
+ value: this.value,
32941
+ opt: this.opt
32942
+ };
32943
+ }
32944
+ }]);
32945
+ return LiteralSchema2;
32946
+ }(Schema);
32890
32947
  var UnionSchema = /* @__PURE__ */ function(_Schema) {
32891
32948
  _inherits(UnionSchema2, _Schema);
32892
32949
  var _super = _createSuper(UnionSchema2);
@@ -32903,7 +32960,139 @@ var UnionSchema = /* @__PURE__ */ function(_Schema) {
32903
32960
  _createClass(UnionSchema2, [{
32904
32961
  key: "validate",
32905
32962
  value: function validate(path, src) {
32906
- return false;
32963
+ var unknownSrc = src;
32964
+ var errors = false;
32965
+ if (this.opt && (unknownSrc === null || unknownSrc === void 0)) {
32966
+ return false;
32967
+ }
32968
+ if (!this.key) {
32969
+ return _defineProperty$1({}, path, [{
32970
+ message: "Missing required first argument in union"
32971
+ }]);
32972
+ }
32973
+ var key = this.key;
32974
+ if (!Array.isArray(this.items)) {
32975
+ return _defineProperty$1({}, path, [{
32976
+ message: "A union schema must take more than 1 schema arguments",
32977
+ fatal: true
32978
+ }]);
32979
+ }
32980
+ if (typeof key === "string") {
32981
+ if (this.items.some(function(item) {
32982
+ return !(item instanceof ObjectSchema);
32983
+ })) {
32984
+ return _defineProperty$1({}, path, [{
32985
+ message: "Key is a string, so all schema items must be objects",
32986
+ fatal: true
32987
+ }]);
32988
+ }
32989
+ var objectSchemas = this.items;
32990
+ var serializedSchemas = objectSchemas.map(function(schema2) {
32991
+ return schema2.serialize();
32992
+ });
32993
+ var illegalSchemas = serializedSchemas.filter(function(schema2) {
32994
+ return !(schema2.type === "object") || !(schema2.items[key].type === "literal");
32995
+ });
32996
+ if (illegalSchemas.length > 0) {
32997
+ return _defineProperty$1({}, path, [{
32998
+ message: "All schema items must be objects with a key: ".concat(key, " that is a literal schema. Found: ").concat(JSON.stringify(illegalSchemas, null, 2)),
32999
+ fatal: true
33000
+ }]);
33001
+ }
33002
+ var serializedObjectSchemas = serializedSchemas;
33003
+ var optionalLiterals = serializedObjectSchemas.filter(function(schema2) {
33004
+ return schema2.items[key].opt;
33005
+ });
33006
+ if (optionalLiterals.length > 1) {
33007
+ return _defineProperty$1({}, path, [{
33008
+ message: "Schema cannot have an optional keys: ".concat(key),
33009
+ fatal: true
33010
+ }]);
33011
+ }
33012
+ if (_typeof(unknownSrc) !== "object") {
33013
+ return _defineProperty$1({}, path, [{
33014
+ message: "Expected an object"
33015
+ }]);
33016
+ }
33017
+ var objectSrc = unknownSrc;
33018
+ if (objectSrc[key] === void 0) {
33019
+ return _defineProperty$1({}, path, [{
33020
+ message: "Missing required key: ".concat(key)
33021
+ }]);
33022
+ }
33023
+ var foundSchemaLiterals = [];
33024
+ var _iterator = _createForOfIteratorHelper$1(serializedObjectSchemas), _step;
33025
+ try {
33026
+ for (_iterator.s(); !(_step = _iterator.n()).done; ) {
33027
+ var schema = _step.value;
33028
+ var schemaKey = schema.items[key];
33029
+ if (schemaKey.type === "literal") {
33030
+ if (!foundSchemaLiterals.includes(schemaKey.value)) {
33031
+ foundSchemaLiterals.push(schemaKey.value);
33032
+ } else {
33033
+ return _defineProperty$1({}, path, [{
33034
+ message: "Found duplicate key in schema: ".concat(schemaKey.value),
33035
+ fatal: true
33036
+ }]);
33037
+ }
33038
+ }
33039
+ }
33040
+ } catch (err2) {
33041
+ _iterator.e(err2);
33042
+ } finally {
33043
+ _iterator.f();
33044
+ }
33045
+ var objectSchemaAtKey = objectSchemas.find(function(schema2) {
33046
+ return !schema2.items[key].validate(path, objectSrc[key]);
33047
+ });
33048
+ if (!objectSchemaAtKey) {
33049
+ var keyPath = createValPathOfItem$1(path, key);
33050
+ if (!keyPath) {
33051
+ throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(key));
33052
+ }
33053
+ return _defineProperty$1({}, keyPath, [{
33054
+ message: 'Invalid key: "'.concat(key, '". Value was: "').concat(objectSrc[key], '". Valid values: ').concat(serializedObjectSchemas.map(function(schema2) {
33055
+ var keySchema = schema2.items[key];
33056
+ if (keySchema.type === "literal" && keySchema.value) {
33057
+ return '"'.concat(keySchema.value, '"');
33058
+ } else {
33059
+ throw new Error("Expected literal schema, got ".concat(JSON.stringify(keySchema, null, 2)));
33060
+ }
33061
+ }).join(", "))
33062
+ }]);
33063
+ }
33064
+ var error = objectSchemaAtKey.validate(path, objectSrc);
33065
+ if (error) {
33066
+ return error;
33067
+ }
33068
+ } else if (key instanceof LiteralSchema) {
33069
+ if (this.items.some(function(item) {
33070
+ return !(item instanceof LiteralSchema);
33071
+ })) {
33072
+ return _defineProperty$1({}, path, [{
33073
+ message: "Key is a literal schema, so all schema items must be literals",
33074
+ fatal: true
33075
+ }]);
33076
+ }
33077
+ var literalItems = [key].concat(_toConsumableArray$1(this.items));
33078
+ if (typeof unknownSrc === "string") {
33079
+ var isMatch = literalItems.some(function(item) {
33080
+ return !item.validate(path, unknownSrc);
33081
+ });
33082
+ if (!isMatch) {
33083
+ return _defineProperty$1({}, path, [{
33084
+ message: "Union must match one of the following: ".concat(literalItems.map(function(item) {
33085
+ return '"'.concat(item.value, '"');
33086
+ }).join(", "))
33087
+ }]);
33088
+ }
33089
+ }
33090
+ } else {
33091
+ return _defineProperty$1({}, path, [{
33092
+ message: "Expected a string or literal"
33093
+ }]);
33094
+ }
33095
+ return errors;
32907
33096
  }
32908
33097
  }, {
32909
33098
  key: "assert",
@@ -33625,8 +33814,8 @@ function isBE() {
33625
33814
  var getSHA256Hash = function getSHA256Hash2(bits) {
33626
33815
  return createHash().update(bits).digest("hex");
33627
33816
  };
33628
- function _regeneratorRuntime$1() {
33629
- _regeneratorRuntime$1 = function() {
33817
+ function _regeneratorRuntime() {
33818
+ _regeneratorRuntime = function() {
33630
33819
  return e;
33631
33820
  };
33632
33821
  var t, e = {}, r2 = Object.prototype, n = r2.hasOwnProperty, o = Object.defineProperty || function(t2, e2, r3) {
@@ -33936,7 +34125,7 @@ function _regeneratorRuntime$1() {
33936
34125
  }
33937
34126
  }, e;
33938
34127
  }
33939
- function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
34128
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
33940
34129
  try {
33941
34130
  var info = gen[key](arg);
33942
34131
  var value = info.value;
@@ -33950,16 +34139,16 @@ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
33950
34139
  Promise.resolve(value).then(_next, _throw);
33951
34140
  }
33952
34141
  }
33953
- function _asyncToGenerator$1(fn) {
34142
+ function _asyncToGenerator(fn) {
33954
34143
  return function() {
33955
34144
  var self = this, args = arguments;
33956
34145
  return new Promise(function(resolve, reject) {
33957
34146
  var gen = fn.apply(self, args);
33958
34147
  function _next(value) {
33959
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
34148
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
33960
34149
  }
33961
34150
  function _throw(err2) {
33962
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err2);
34151
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err2);
33963
34152
  }
33964
34153
  _next(void 0);
33965
34154
  });
@@ -33988,9 +34177,9 @@ var ValApi = /* @__PURE__ */ function() {
33988
34177
  }, {
33989
34178
  key: "getPatches",
33990
34179
  value: function() {
33991
- var _getPatches = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(_ref) {
34180
+ var _getPatches = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(_ref) {
33992
34181
  var patchIds, headers, patchIdsParam;
33993
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
34182
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
33994
34183
  while (1)
33995
34184
  switch (_context.prev = _context.next) {
33996
34185
  case 0:
@@ -34084,9 +34273,9 @@ function parse$1(_x2) {
34084
34273
  return _parse.apply(this, arguments);
34085
34274
  }
34086
34275
  function _parse() {
34087
- _parse = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2(res) {
34276
+ _parse = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2(res) {
34088
34277
  var json;
34089
- return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
34278
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
34090
34279
  while (1)
34091
34280
  switch (_context2.prev = _context2.next) {
34092
34281
  case 0:
@@ -40083,316 +40272,35 @@ marked.walkTokens;
40083
40272
  marked.parseInline;
40084
40273
  _Parser.parse;
40085
40274
  const lexer = _Lexer.lex;
40086
- function _regeneratorRuntime() {
40087
- _regeneratorRuntime = function() {
40088
- return e;
40089
- };
40090
- var t, e = {}, r2 = Object.prototype, n = r2.hasOwnProperty, o = Object.defineProperty || function(t2, e2, r3) {
40091
- t2[e2] = r3.value;
40092
- }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag";
40093
- function define(t2, e2, r3) {
40094
- return Object.defineProperty(t2, e2, {
40095
- value: r3,
40096
- enumerable: true,
40097
- configurable: true,
40098
- writable: true
40099
- }), t2[e2];
40100
- }
40101
- try {
40102
- define({}, "");
40103
- } catch (t2) {
40104
- define = function(t3, e2, r3) {
40105
- return t3[e2] = r3;
40106
- };
40107
- }
40108
- function wrap(t2, e2, r3, n2) {
40109
- var i2 = e2 && e2.prototype instanceof Generator ? e2 : Generator, a2 = Object.create(i2.prototype), c2 = new Context(n2 || []);
40110
- return o(a2, "_invoke", {
40111
- value: makeInvokeMethod(t2, r3, c2)
40112
- }), a2;
40113
- }
40114
- function tryCatch(t2, e2, r3) {
40275
+ function _arrayWithHoles(arr) {
40276
+ if (Array.isArray(arr))
40277
+ return arr;
40278
+ }
40279
+ function _iterableToArrayLimit(r2, l) {
40280
+ var t = null == r2 ? null : "undefined" != typeof Symbol && r2[Symbol.iterator] || r2["@@iterator"];
40281
+ if (null != t) {
40282
+ var e, n, i, u, a = [], f = true, o = false;
40115
40283
  try {
40116
- return {
40117
- type: "normal",
40118
- arg: t2.call(e2, r3)
40119
- };
40120
- } catch (t3) {
40121
- return {
40122
- type: "throw",
40123
- arg: t3
40124
- };
40125
- }
40126
- }
40127
- e.wrap = wrap;
40128
- var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {};
40129
- function Generator() {
40130
- }
40131
- function GeneratorFunction() {
40132
- }
40133
- function GeneratorFunctionPrototype() {
40134
- }
40135
- var p = {};
40136
- define(p, a, function() {
40137
- return this;
40138
- });
40139
- var d = Object.getPrototypeOf, v = d && d(d(values([])));
40140
- v && v !== r2 && n.call(v, a) && (p = v);
40141
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
40142
- function defineIteratorMethods(t2) {
40143
- ["next", "throw", "return"].forEach(function(e2) {
40144
- define(t2, e2, function(t3) {
40145
- return this._invoke(e2, t3);
40146
- });
40147
- });
40148
- }
40149
- function AsyncIterator(t2, e2) {
40150
- function invoke(r4, o2, i2, a2) {
40151
- var c2 = tryCatch(t2[r4], t2, o2);
40152
- if ("throw" !== c2.type) {
40153
- var u2 = c2.arg, h2 = u2.value;
40154
- return h2 && "object" == typeof h2 && n.call(h2, "__await") ? e2.resolve(h2.__await).then(function(t3) {
40155
- invoke("next", t3, i2, a2);
40156
- }, function(t3) {
40157
- invoke("throw", t3, i2, a2);
40158
- }) : e2.resolve(h2).then(function(t3) {
40159
- u2.value = t3, i2(u2);
40160
- }, function(t3) {
40161
- return invoke("throw", t3, i2, a2);
40162
- });
40163
- }
40164
- a2(c2.arg);
40165
- }
40166
- var r3;
40167
- o(this, "_invoke", {
40168
- value: function(t3, n2) {
40169
- function callInvokeWithMethodAndArg() {
40170
- return new e2(function(e3, r4) {
40171
- invoke(t3, n2, e3, r4);
40172
- });
40173
- }
40174
- return r3 = r3 ? r3.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
40175
- }
40176
- });
40177
- }
40178
- function makeInvokeMethod(e2, r3, n2) {
40179
- var o2 = h;
40180
- return function(i2, a2) {
40181
- if (o2 === f)
40182
- throw new Error("Generator is already running");
40183
- if (o2 === s) {
40184
- if ("throw" === i2)
40185
- throw a2;
40186
- return {
40187
- value: t,
40188
- done: true
40189
- };
40190
- }
40191
- for (n2.method = i2, n2.arg = a2; ; ) {
40192
- var c2 = n2.delegate;
40193
- if (c2) {
40194
- var u2 = maybeInvokeDelegate(c2, n2);
40195
- if (u2) {
40196
- if (u2 === y)
40197
- continue;
40198
- return u2;
40199
- }
40200
- }
40201
- if ("next" === n2.method)
40202
- n2.sent = n2._sent = n2.arg;
40203
- else if ("throw" === n2.method) {
40204
- if (o2 === h)
40205
- throw o2 = s, n2.arg;
40206
- n2.dispatchException(n2.arg);
40207
- } else
40208
- "return" === n2.method && n2.abrupt("return", n2.arg);
40209
- o2 = f;
40210
- var p2 = tryCatch(e2, r3, n2);
40211
- if ("normal" === p2.type) {
40212
- if (o2 = n2.done ? s : l, p2.arg === y)
40213
- continue;
40214
- return {
40215
- value: p2.arg,
40216
- done: n2.done
40217
- };
40218
- }
40219
- "throw" === p2.type && (o2 = s, n2.method = "throw", n2.arg = p2.arg);
40220
- }
40221
- };
40222
- }
40223
- function maybeInvokeDelegate(e2, r3) {
40224
- var n2 = r3.method, o2 = e2.iterator[n2];
40225
- if (o2 === t)
40226
- return r3.delegate = null, "throw" === n2 && e2.iterator.return && (r3.method = "return", r3.arg = t, maybeInvokeDelegate(e2, r3), "throw" === r3.method) || "return" !== n2 && (r3.method = "throw", r3.arg = new TypeError("The iterator does not provide a '" + n2 + "' method")), y;
40227
- var i2 = tryCatch(o2, e2.iterator, r3.arg);
40228
- if ("throw" === i2.type)
40229
- return r3.method = "throw", r3.arg = i2.arg, r3.delegate = null, y;
40230
- var a2 = i2.arg;
40231
- return a2 ? a2.done ? (r3[e2.resultName] = a2.value, r3.next = e2.nextLoc, "return" !== r3.method && (r3.method = "next", r3.arg = t), r3.delegate = null, y) : a2 : (r3.method = "throw", r3.arg = new TypeError("iterator result is not an object"), r3.delegate = null, y);
40232
- }
40233
- function pushTryEntry(t2) {
40234
- var e2 = {
40235
- tryLoc: t2[0]
40236
- };
40237
- 1 in t2 && (e2.catchLoc = t2[1]), 2 in t2 && (e2.finallyLoc = t2[2], e2.afterLoc = t2[3]), this.tryEntries.push(e2);
40238
- }
40239
- function resetTryEntry(t2) {
40240
- var e2 = t2.completion || {};
40241
- e2.type = "normal", delete e2.arg, t2.completion = e2;
40242
- }
40243
- function Context(t2) {
40244
- this.tryEntries = [{
40245
- tryLoc: "root"
40246
- }], t2.forEach(pushTryEntry, this), this.reset(true);
40247
- }
40248
- function values(e2) {
40249
- if (e2 || "" === e2) {
40250
- var r3 = e2[a];
40251
- if (r3)
40252
- return r3.call(e2);
40253
- if ("function" == typeof e2.next)
40254
- return e2;
40255
- if (!isNaN(e2.length)) {
40256
- var o2 = -1, i2 = function next() {
40257
- for (; ++o2 < e2.length; )
40258
- if (n.call(e2, o2))
40259
- return next.value = e2[o2], next.done = false, next;
40260
- return next.value = t, next.done = true, next;
40261
- };
40262
- return i2.next = i2;
40284
+ if (i = (t = t.call(r2)).next, 0 === l) {
40285
+ if (Object(t) !== t)
40286
+ return;
40287
+ f = false;
40288
+ } else
40289
+ for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true)
40290
+ ;
40291
+ } catch (r3) {
40292
+ o = true, n = r3;
40293
+ } finally {
40294
+ try {
40295
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u))
40296
+ return;
40297
+ } finally {
40298
+ if (o)
40299
+ throw n;
40263
40300
  }
40264
40301
  }
40265
- throw new TypeError(typeof e2 + " is not iterable");
40302
+ return a;
40266
40303
  }
40267
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
40268
- value: GeneratorFunctionPrototype,
40269
- configurable: true
40270
- }), o(GeneratorFunctionPrototype, "constructor", {
40271
- value: GeneratorFunction,
40272
- configurable: true
40273
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function(t2) {
40274
- var e2 = "function" == typeof t2 && t2.constructor;
40275
- return !!e2 && (e2 === GeneratorFunction || "GeneratorFunction" === (e2.displayName || e2.name));
40276
- }, e.mark = function(t2) {
40277
- return Object.setPrototypeOf ? Object.setPrototypeOf(t2, GeneratorFunctionPrototype) : (t2.__proto__ = GeneratorFunctionPrototype, define(t2, u, "GeneratorFunction")), t2.prototype = Object.create(g), t2;
40278
- }, e.awrap = function(t2) {
40279
- return {
40280
- __await: t2
40281
- };
40282
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function() {
40283
- return this;
40284
- }), e.AsyncIterator = AsyncIterator, e.async = function(t2, r3, n2, o2, i2) {
40285
- void 0 === i2 && (i2 = Promise);
40286
- var a2 = new AsyncIterator(wrap(t2, r3, n2, o2), i2);
40287
- return e.isGeneratorFunction(r3) ? a2 : a2.next().then(function(t3) {
40288
- return t3.done ? t3.value : a2.next();
40289
- });
40290
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function() {
40291
- return this;
40292
- }), define(g, "toString", function() {
40293
- return "[object Generator]";
40294
- }), e.keys = function(t2) {
40295
- var e2 = Object(t2), r3 = [];
40296
- for (var n2 in e2)
40297
- r3.push(n2);
40298
- return r3.reverse(), function next() {
40299
- for (; r3.length; ) {
40300
- var t3 = r3.pop();
40301
- if (t3 in e2)
40302
- return next.value = t3, next.done = false, next;
40303
- }
40304
- return next.done = true, next;
40305
- };
40306
- }, e.values = values, Context.prototype = {
40307
- constructor: Context,
40308
- reset: function(e2) {
40309
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e2)
40310
- for (var r3 in this)
40311
- "t" === r3.charAt(0) && n.call(this, r3) && !isNaN(+r3.slice(1)) && (this[r3] = t);
40312
- },
40313
- stop: function() {
40314
- this.done = true;
40315
- var t2 = this.tryEntries[0].completion;
40316
- if ("throw" === t2.type)
40317
- throw t2.arg;
40318
- return this.rval;
40319
- },
40320
- dispatchException: function(e2) {
40321
- if (this.done)
40322
- throw e2;
40323
- var r3 = this;
40324
- function handle(n2, o3) {
40325
- return a2.type = "throw", a2.arg = e2, r3.next = n2, o3 && (r3.method = "next", r3.arg = t), !!o3;
40326
- }
40327
- for (var o2 = this.tryEntries.length - 1; o2 >= 0; --o2) {
40328
- var i2 = this.tryEntries[o2], a2 = i2.completion;
40329
- if ("root" === i2.tryLoc)
40330
- return handle("end");
40331
- if (i2.tryLoc <= this.prev) {
40332
- var c2 = n.call(i2, "catchLoc"), u2 = n.call(i2, "finallyLoc");
40333
- if (c2 && u2) {
40334
- if (this.prev < i2.catchLoc)
40335
- return handle(i2.catchLoc, true);
40336
- if (this.prev < i2.finallyLoc)
40337
- return handle(i2.finallyLoc);
40338
- } else if (c2) {
40339
- if (this.prev < i2.catchLoc)
40340
- return handle(i2.catchLoc, true);
40341
- } else {
40342
- if (!u2)
40343
- throw new Error("try statement without catch or finally");
40344
- if (this.prev < i2.finallyLoc)
40345
- return handle(i2.finallyLoc);
40346
- }
40347
- }
40348
- }
40349
- },
40350
- abrupt: function(t2, e2) {
40351
- for (var r3 = this.tryEntries.length - 1; r3 >= 0; --r3) {
40352
- var o2 = this.tryEntries[r3];
40353
- if (o2.tryLoc <= this.prev && n.call(o2, "finallyLoc") && this.prev < o2.finallyLoc) {
40354
- var i2 = o2;
40355
- break;
40356
- }
40357
- }
40358
- i2 && ("break" === t2 || "continue" === t2) && i2.tryLoc <= e2 && e2 <= i2.finallyLoc && (i2 = null);
40359
- var a2 = i2 ? i2.completion : {};
40360
- return a2.type = t2, a2.arg = e2, i2 ? (this.method = "next", this.next = i2.finallyLoc, y) : this.complete(a2);
40361
- },
40362
- complete: function(t2, e2) {
40363
- if ("throw" === t2.type)
40364
- throw t2.arg;
40365
- return "break" === t2.type || "continue" === t2.type ? this.next = t2.arg : "return" === t2.type ? (this.rval = this.arg = t2.arg, this.method = "return", this.next = "end") : "normal" === t2.type && e2 && (this.next = e2), y;
40366
- },
40367
- finish: function(t2) {
40368
- for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
40369
- var r3 = this.tryEntries[e2];
40370
- if (r3.finallyLoc === t2)
40371
- return this.complete(r3.completion, r3.afterLoc), resetTryEntry(r3), y;
40372
- }
40373
- },
40374
- catch: function(t2) {
40375
- for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
40376
- var r3 = this.tryEntries[e2];
40377
- if (r3.tryLoc === t2) {
40378
- var n2 = r3.completion;
40379
- if ("throw" === n2.type) {
40380
- var o2 = n2.arg;
40381
- resetTryEntry(r3);
40382
- }
40383
- return o2;
40384
- }
40385
- }
40386
- throw new Error("illegal catch attempt");
40387
- },
40388
- delegateYield: function(e2, r3, n2) {
40389
- return this.delegate = {
40390
- iterator: values(e2),
40391
- resultName: r3,
40392
- nextLoc: n2
40393
- }, "next" === this.method && (this.arg = t), y;
40394
- }
40395
- }, e;
40396
40304
  }
40397
40305
  function _arrayLikeToArray(arr, len) {
40398
40306
  if (len == null || len > arr.length)
@@ -40414,6 +40322,42 @@ function _unsupportedIterableToArray(o, minLen) {
40414
40322
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
40415
40323
  return _arrayLikeToArray(o, minLen);
40416
40324
  }
40325
+ function _nonIterableRest() {
40326
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
40327
+ }
40328
+ function _slicedToArray(arr, i) {
40329
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
40330
+ }
40331
+ function _toPrimitive(input, hint) {
40332
+ if (typeof input !== "object" || input === null)
40333
+ return input;
40334
+ var prim = input[Symbol.toPrimitive];
40335
+ if (prim !== void 0) {
40336
+ var res = prim.call(input, hint || "default");
40337
+ if (typeof res !== "object")
40338
+ return res;
40339
+ throw new TypeError("@@toPrimitive must return a primitive value.");
40340
+ }
40341
+ return (hint === "string" ? String : Number)(input);
40342
+ }
40343
+ function _toPropertyKey(arg) {
40344
+ var key = _toPrimitive(arg, "string");
40345
+ return typeof key === "symbol" ? key : String(key);
40346
+ }
40347
+ function _defineProperty(obj, key, value) {
40348
+ key = _toPropertyKey(key);
40349
+ if (key in obj) {
40350
+ Object.defineProperty(obj, key, {
40351
+ value,
40352
+ enumerable: true,
40353
+ configurable: true,
40354
+ writable: true
40355
+ });
40356
+ } else {
40357
+ obj[key] = value;
40358
+ }
40359
+ return obj;
40360
+ }
40417
40361
  function _createForOfIteratorHelper(o, allowArrayLike) {
40418
40362
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
40419
40363
  if (!it) {
@@ -40468,101 +40412,6 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
40468
40412
  }
40469
40413
  };
40470
40414
  }
40471
- function _toPrimitive(input, hint) {
40472
- if (typeof input !== "object" || input === null)
40473
- return input;
40474
- var prim = input[Symbol.toPrimitive];
40475
- if (prim !== void 0) {
40476
- var res = prim.call(input, hint || "default");
40477
- if (typeof res !== "object")
40478
- return res;
40479
- throw new TypeError("@@toPrimitive must return a primitive value.");
40480
- }
40481
- return (hint === "string" ? String : Number)(input);
40482
- }
40483
- function _toPropertyKey(arg) {
40484
- var key = _toPrimitive(arg, "string");
40485
- return typeof key === "symbol" ? key : String(key);
40486
- }
40487
- function _defineProperty(obj, key, value) {
40488
- key = _toPropertyKey(key);
40489
- if (key in obj) {
40490
- Object.defineProperty(obj, key, {
40491
- value,
40492
- enumerable: true,
40493
- configurable: true,
40494
- writable: true
40495
- });
40496
- } else {
40497
- obj[key] = value;
40498
- }
40499
- return obj;
40500
- }
40501
- function _arrayWithHoles(arr) {
40502
- if (Array.isArray(arr))
40503
- return arr;
40504
- }
40505
- function _iterableToArrayLimit(r2, l) {
40506
- var t = null == r2 ? null : "undefined" != typeof Symbol && r2[Symbol.iterator] || r2["@@iterator"];
40507
- if (null != t) {
40508
- var e, n, i, u, a = [], f = true, o = false;
40509
- try {
40510
- if (i = (t = t.call(r2)).next, 0 === l) {
40511
- if (Object(t) !== t)
40512
- return;
40513
- f = false;
40514
- } else
40515
- for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true)
40516
- ;
40517
- } catch (r3) {
40518
- o = true, n = r3;
40519
- } finally {
40520
- try {
40521
- if (!f && null != t.return && (u = t.return(), Object(u) !== u))
40522
- return;
40523
- } finally {
40524
- if (o)
40525
- throw n;
40526
- }
40527
- }
40528
- return a;
40529
- }
40530
- }
40531
- function _nonIterableRest() {
40532
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
40533
- }
40534
- function _slicedToArray(arr, i) {
40535
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
40536
- }
40537
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
40538
- try {
40539
- var info = gen[key](arg);
40540
- var value = info.value;
40541
- } catch (error) {
40542
- reject(error);
40543
- return;
40544
- }
40545
- if (info.done) {
40546
- resolve(value);
40547
- } else {
40548
- Promise.resolve(value).then(_next, _throw);
40549
- }
40550
- }
40551
- function _asyncToGenerator(fn) {
40552
- return function() {
40553
- var self = this, args = arguments;
40554
- return new Promise(function(resolve, reject) {
40555
- var gen = fn.apply(self, args);
40556
- function _next(value) {
40557
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
40558
- }
40559
- function _throw(err2) {
40560
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err2);
40561
- }
40562
- _next(void 0);
40563
- });
40564
- };
40565
- }
40566
40415
  function _arrayWithoutHoles(arr) {
40567
40416
  if (Array.isArray(arr))
40568
40417
  return _arrayLikeToArray(arr);
@@ -40643,101 +40492,42 @@ function createBlock(node) {
40643
40492
  throw new Error("Unhandled node type: ".concat("type" in exhaustiveCheck ? "exhaustiveCheck.type" : "unknown"));
40644
40493
  }
40645
40494
  }
40646
- function fromIRToRichTextSource(_x) {
40647
- return _fromIRToRichTextSource.apply(this, arguments);
40648
- }
40649
- function _fromIRToRichTextSource() {
40650
- _fromIRToRichTextSource = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(markdownIRBlocks) {
40651
- var templateStrings, exprs, files, blockIdx, block2, _iterator, _step, child, exhaustiveCheck;
40652
- return _regeneratorRuntime().wrap(function _callee$(_context) {
40653
- while (1)
40654
- switch (_context.prev = _context.next) {
40655
- case 0:
40656
- templateStrings = ["\n"];
40657
- exprs = [];
40658
- files = {};
40659
- blockIdx = 0;
40660
- case 4:
40661
- if (!(blockIdx < markdownIRBlocks.length)) {
40662
- _context.next = 44;
40663
- break;
40664
- }
40665
- block2 = markdownIRBlocks[blockIdx];
40666
- _iterator = _createForOfIteratorHelper(block2.children);
40667
- _context.prev = 7;
40668
- _iterator.s();
40669
- case 9:
40670
- if ((_step = _iterator.n()).done) {
40671
- _context.next = 32;
40672
- break;
40673
- }
40674
- child = _step.value;
40675
- if (!(typeof child === "string")) {
40676
- _context.next = 15;
40677
- break;
40678
- }
40679
- templateStrings[templateStrings.length - 1] += child;
40680
- _context.next = 30;
40681
- break;
40682
- case 15:
40683
- if (!(child.type === "image")) {
40684
- _context.next = 23;
40685
- break;
40686
- }
40687
- _context.t0 = exprs;
40688
- _context.next = 19;
40689
- return fromLexicalImageNode(child, files);
40690
- case 19:
40691
- _context.t1 = _context.sent;
40692
- _context.t0.push.call(_context.t0, _context.t1);
40693
- _context.next = 29;
40694
- break;
40695
- case 23:
40696
- if (!(child.type === "link")) {
40697
- _context.next = 27;
40698
- break;
40699
- }
40495
+ function fromIRToRichTextSource(markdownIRBlocks) {
40496
+ var templateStrings = ["\n"];
40497
+ var exprs = [];
40498
+ var files = {};
40499
+ for (var blockIdx = 0; blockIdx < markdownIRBlocks.length; blockIdx++) {
40500
+ var block2 = markdownIRBlocks[blockIdx];
40501
+ var _iterator = _createForOfIteratorHelper(block2.children), _step;
40502
+ try {
40503
+ for (_iterator.s(); !(_step = _iterator.n()).done; ) {
40504
+ var child = _step.value;
40505
+ if (typeof child === "string") {
40506
+ templateStrings[templateStrings.length - 1] += child;
40507
+ } else {
40508
+ if (child.type === "image") {
40509
+ exprs.push(fromLexicalImageNode(child, files));
40510
+ } else if (child.type === "link") {
40700
40511
  exprs.push(fromLexicalLinkNode(child));
40701
- _context.next = 29;
40702
- break;
40703
- case 27:
40704
- exhaustiveCheck = child;
40512
+ } else {
40513
+ var exhaustiveCheck = child;
40705
40514
  throw new Error("Unexpected node type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
40706
- case 29:
40707
- templateStrings.push("");
40708
- case 30:
40709
- _context.next = 9;
40710
- break;
40711
- case 32:
40712
- _context.next = 37;
40713
- break;
40714
- case 34:
40715
- _context.prev = 34;
40716
- _context.t2 = _context["catch"](7);
40717
- _iterator.e(_context.t2);
40718
- case 37:
40719
- _context.prev = 37;
40720
- _iterator.f();
40721
- return _context.finish(37);
40722
- case 40:
40723
- if (blockIdx === markdownIRBlocks.length - 1) {
40724
- templateStrings[templateStrings.length - 1] += "\n";
40725
- } else {
40726
- templateStrings[templateStrings.length - 1] += "\n\n";
40727
- }
40728
- case 41:
40729
- blockIdx++;
40730
- _context.next = 4;
40731
- break;
40732
- case 44:
40733
- return _context.abrupt("return", _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "richtext"), "templateStrings", templateStrings), "exprs", exprs), "files", files));
40734
- case 45:
40735
- case "end":
40736
- return _context.stop();
40515
+ }
40516
+ templateStrings.push("");
40737
40517
  }
40738
- }, _callee, null, [[7, 34, 37, 40]]);
40739
- }));
40740
- return _fromIRToRichTextSource.apply(this, arguments);
40518
+ }
40519
+ } catch (err2) {
40520
+ _iterator.e(err2);
40521
+ } finally {
40522
+ _iterator.f();
40523
+ }
40524
+ if (blockIdx === markdownIRBlocks.length - 1) {
40525
+ templateStrings[templateStrings.length - 1] += "\n";
40526
+ } else {
40527
+ templateStrings[templateStrings.length - 1] += "\n\n";
40528
+ }
40529
+ }
40530
+ return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "richtext"), "templateStrings", templateStrings), "exprs", exprs), "files", files);
40741
40531
  }
40742
40532
  function formatText(node) {
40743
40533
  var classes = typeof node.format === "number" ? fromLexicalFormat(node.format) : [];
@@ -40803,8 +40593,8 @@ var FORMAT_MAPPING$1 = {
40803
40593
  // underline: 8, // 1000
40804
40594
  };
40805
40595
  function fromLexicalFormat(format) {
40806
- return Object.entries(FORMAT_MAPPING$1).flatMap(function(_ref) {
40807
- var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
40596
+ return Object.entries(FORMAT_MAPPING$1).flatMap(function(_ref2) {
40597
+ var _ref3 = _slicedToArray(_ref2, 2), key = _ref3[0], value = _ref3[1];
40808
40598
  if ((value & /* bitwise and */
40809
40599
  format) === value) {
40810
40600
  return [key];
@@ -40813,53 +40603,29 @@ function fromLexicalFormat(format) {
40813
40603
  });
40814
40604
  }
40815
40605
  var textEncoder$1 = new TextEncoder();
40816
- function fromLexicalImageNode(_x2, _x3) {
40817
- return _fromLexicalImageNode.apply(this, arguments);
40818
- }
40819
- function _fromLexicalImageNode() {
40820
- _fromLexicalImageNode = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2(node, files) {
40821
- var sha256, mimeType, fileExt, filePath, _sha;
40822
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
40823
- while (1)
40824
- switch (_context2.prev = _context2.next) {
40825
- case 0:
40826
- if (!node.src.startsWith("data:")) {
40827
- _context2.next = 13;
40828
- break;
40829
- }
40830
- _context2.next = 3;
40831
- return Internal.getSHA256Hash(textEncoder$1.encode(node.src));
40832
- case 3:
40833
- sha256 = _context2.sent;
40834
- mimeType = getMimeType(node.src);
40835
- if (!(mimeType === void 0)) {
40836
- _context2.next = 7;
40837
- break;
40838
- }
40839
- throw new Error("Could not detect Mime Type for image: ".concat(node.src));
40840
- case 7:
40841
- fileExt = mimeTypeToFileExt(mimeType);
40842
- filePath = "/public/".concat(sha256, ".").concat(fileExt);
40843
- files[filePath] = node.src;
40844
- return _context2.abrupt("return", _defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, filePath), "metadata", {
40845
- width: node.width || 0,
40846
- height: node.height || 0,
40847
- sha256: sha256 || ""
40848
- }));
40849
- case 13:
40850
- _sha = getParam("sha256", node.src);
40851
- return _context2.abrupt("return", _defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, "/public".concat(node.src.split("?")[0])), "metadata", {
40852
- width: node.width || 0,
40853
- height: node.height || 0,
40854
- sha256: _sha || ""
40855
- }));
40856
- case 15:
40857
- case "end":
40858
- return _context2.stop();
40859
- }
40860
- }, _callee2);
40861
- }));
40862
- return _fromLexicalImageNode.apply(this, arguments);
40606
+ function fromLexicalImageNode(node, files) {
40607
+ if (node.src.startsWith("data:")) {
40608
+ var sha256 = Internal.getSHA256Hash(textEncoder$1.encode(node.src));
40609
+ var mimeType = getMimeType(node.src);
40610
+ if (mimeType === void 0) {
40611
+ throw new Error("Could not detect Mime Type for image: ".concat(node.src));
40612
+ }
40613
+ var fileExt = mimeTypeToFileExt(mimeType);
40614
+ var filePath = "/public/".concat(sha256, ".").concat(fileExt);
40615
+ files[filePath] = node.src;
40616
+ return _defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, filePath), "metadata", {
40617
+ width: node.width || 0,
40618
+ height: node.height || 0,
40619
+ sha256: sha256 || ""
40620
+ });
40621
+ } else {
40622
+ var _sha = getParam("sha256", node.src);
40623
+ return _defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, "/public".concat(node.src.split("?")[0])), "metadata", {
40624
+ width: node.width || 0,
40625
+ height: node.height || 0,
40626
+ sha256: _sha || ""
40627
+ });
40628
+ }
40863
40629
  }
40864
40630
  function getParam(param, url) {
40865
40631
  var urlParts = url.split("?");
@@ -62497,8 +62263,8 @@ const Button$1 = ({
62497
62263
  "font-sans font-[12px] tracking-[0.04em] py-1 px-2 rounded whitespace-nowrap group relative text-primary",
62498
62264
  {
62499
62265
  "font-bold": variant === "primary",
62500
- "bg-background hover:bg-background text-fill disabled:bg-fill disabled:text-background": variant === "primary",
62501
- "bg-transparent border border-primary text-primary hover:border-highlight hover:text-highlight disabled:bg-fill disabled:text-background": variant !== "primary"
62266
+ "text-fill disabled:bg-fill disabled:text-background": variant === "primary",
62267
+ "border border-primary text-primary hover:border-highlight hover:text-highlight disabled:bg-fill disabled:text-background": variant !== "primary"
62502
62268
  }
62503
62269
  ),
62504
62270
  onClick,
@@ -62648,7 +62414,7 @@ const Dropdown = ({
62648
62414
  isOpen && /* @__PURE__ */ jsxRuntimeExports.jsx(
62649
62415
  "div",
62650
62416
  {
62651
- className: "absolute -top-[4px] overflow-scroll shadow-lg -left-2 text-primary bg-border w-fit z-overlay",
62417
+ className: "absolute -top-[4px] overflow-scroll shadow-lg -left-2 text-primary w-fit z-overlay",
62652
62418
  style: { maxHeight: windowSize == null ? void 0 : windowSize.innerHeight },
62653
62419
  children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col ", children: options == null ? void 0 : options.map((option, idx) => /* @__PURE__ */ jsxRuntimeExports.jsx(
62654
62420
  "button",
@@ -62657,7 +62423,7 @@ const Dropdown = ({
62657
62423
  ev.preventDefault();
62658
62424
  handleSelect(option, idx);
62659
62425
  },
62660
- className: `text-left px-2 py-1 hover:bg-background hover:text-highlight ${idx === selectedOption && "font-bold bg-background hover:bg-background truncate"}`,
62426
+ className: `text-left px-2 py-1 hover:text-highlight ${idx === selectedOption && "font-bold truncate"}`,
62661
62427
  children: option
62662
62428
  },
62663
62429
  option
@@ -62679,10 +62445,8 @@ function readImage(ev) {
62679
62445
  const result2 = reader.result;
62680
62446
  if (typeof result2 === "string") {
62681
62447
  const image = new Image();
62682
- image.addEventListener("load", async () => {
62683
- const sha256 = await Internal.getSHA256Hash(
62684
- textEncoder.encode(result2)
62685
- );
62448
+ image.addEventListener("load", () => {
62449
+ const sha256 = Internal.getSHA256Hash(textEncoder.encode(result2));
62686
62450
  if (image.naturalWidth && image.naturalHeight) {
62687
62451
  const mimeType = getMimeType(result2);
62688
62452
  resolve({
@@ -64092,7 +63856,7 @@ const Toolbar = ({
64092
63856
  }
64093
63857
  });
64094
63858
  }, [activeEditor]);
64095
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sticky top-0 border-b bg-background border-highlight flex flex-col", children: [
63859
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sticky top-0 flex flex-col px-4 py-2 border-b backdrop-blur-3xl bg-background/10 border-highlight", children: [
64096
63860
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row gap-1", children: [
64097
63861
  /* @__PURE__ */ jsxRuntimeExports.jsx(
64098
63862
  Dropdown$1,
@@ -64184,7 +63948,7 @@ const Toolbar = ({
64184
63948
  {
64185
63949
  type: "text",
64186
63950
  placeholder: "Enter URL",
64187
- className: "w-1/3 text-primary bg-background px-2",
63951
+ className: "w-1/3 px-2 text-primary",
64188
63952
  value: url,
64189
63953
  onChange: (ev) => {
64190
63954
  ev.preventDefault();
@@ -64451,7 +64215,7 @@ function ValMenu({
64451
64215
  children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-[24px] w-[24px] flex justify-center items-center", children: editMode === "full" ? /* @__PURE__ */ jsxRuntimeExports.jsx(Minimize, { size: 15 }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Maximize, { size: 15 }) })
64452
64216
  }
64453
64217
  ),
64454
- patchCount !== void 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(
64218
+ patchCount !== void 0 && session.status === "success" && session.data.mode === "proxy" && /* @__PURE__ */ jsxRuntimeExports.jsx(
64455
64219
  MenuButton,
64456
64220
  {
64457
64221
  onClick: () => {
@@ -72934,8 +72698,16 @@ function createImagePatch(path, data, filename, metadata) {
72934
72698
  const mimeType = getMimeType(data) ?? "unknown";
72935
72699
  const newExt = mimeTypeToFileExt(mimeType);
72936
72700
  if (filename) {
72937
- const filenameWithoutExt = filename.split(".").slice(0, -1).join(".") || filename;
72938
- return `/public/${filenameWithoutExt}_${shaSuffix}.${newExt}`;
72701
+ let cleanFilename = filename.split(".").slice(0, -1).join(".") || filename;
72702
+ const maybeShaSuffixPos = cleanFilename.lastIndexOf("_");
72703
+ const currentShaSuffix = cleanFilename.slice(
72704
+ maybeShaSuffixPos + 1,
72705
+ cleanFilename.length
72706
+ );
72707
+ if (currentShaSuffix === shaSuffix) {
72708
+ cleanFilename = cleanFilename.slice(0, maybeShaSuffixPos);
72709
+ }
72710
+ return `/public/${cleanFilename}_${shaSuffix}.${newExt}`;
72939
72711
  }
72940
72712
  return `/public/${metadata.sha256}.${newExt}`;
72941
72713
  }();
@@ -72984,8 +72756,8 @@ function ImageField({
72984
72756
  });
72985
72757
  }
72986
72758
  }, [data, defaultValue]);
72987
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "max-w-4xl p-4", children: [
72988
- /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: `img_input:${path}`, className: "", children: [
72759
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(FieldContainer, { children: [
72760
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "max-w-4xl p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: `img_input:${path}`, className: "", children: [
72989
72761
  data || url ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (data == null ? void 0 : data.src) || url }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Empty" }),
72990
72762
  /* @__PURE__ */ jsxRuntimeExports.jsx(
72991
72763
  "input",
@@ -73013,11 +72785,11 @@ function ImageField({
73013
72785
  }
73014
72786
  }
73015
72787
  )
73016
- ] }),
73017
- onSubmit && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: data && /* @__PURE__ */ jsxRuntimeExports.jsx(
73018
- Button,
72788
+ ] }) }, path),
72789
+ onSubmit && data && /* @__PURE__ */ jsxRuntimeExports.jsx(
72790
+ SubmitButton,
73019
72791
  {
73020
- disabled: loading,
72792
+ loading,
73021
72793
  onClick: () => {
73022
72794
  setLoading(true);
73023
72795
  onSubmit(
@@ -73034,14 +72806,13 @@ function ImageField({
73034
72806
  setData(null);
73035
72807
  setMetadata(void 0);
73036
72808
  });
73037
- },
73038
- children: loading ? "Saving..." : "Save"
72809
+ }
73039
72810
  }
73040
- ) })
73041
- ] }, path);
72811
+ )
72812
+ ] });
73042
72813
  }
73043
- async function createRichTextPatch(path, editor) {
73044
- const { templateStrings, exprs, files } = editor ? await lexicalToRichTextSource(
72814
+ function createRichTextPatch(path, editor) {
72815
+ const { templateStrings, exprs, files } = editor ? lexicalToRichTextSource(
73045
72816
  editor.getEditorState().toJSON().root
73046
72817
  ) : {
73047
72818
  [VAL_EXTENSION]: "richtext",
@@ -73090,10 +72861,10 @@ function RichTextField({
73090
72861
  }, [editor]);
73091
72862
  reactExports.useEffect(() => {
73092
72863
  if (editor && registerPatchCallback) {
73093
- registerPatchCallback((path) => createRichTextPatch(path, editor));
72864
+ registerPatchCallback(async (path) => createRichTextPatch(path, editor));
73094
72865
  }
73095
72866
  }, [editor]);
73096
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 border rounded border-card", children: [
72867
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(FieldContainer, { children: [
73097
72868
  /* @__PURE__ */ jsxRuntimeExports.jsx(
73098
72869
  RichTextEditor,
73099
72870
  {
@@ -73106,24 +72877,23 @@ function RichTextField({
73106
72877
  }
73107
72878
  }
73108
72879
  ),
73109
- onSubmit && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: didChange && /* @__PURE__ */ jsxRuntimeExports.jsx(
73110
- Button,
72880
+ onSubmit && didChange && /* @__PURE__ */ jsxRuntimeExports.jsx(
72881
+ SubmitButton,
73111
72882
  {
73112
- disabled: loading || !editor,
72883
+ loading: loading || !editor,
73113
72884
  onClick: () => {
73114
72885
  if (editor) {
73115
72886
  setLoading(true);
73116
- onSubmit((path) => createRichTextPatch(path, editor)).finally(
73117
- () => {
73118
- setLoading(false);
73119
- setDidChange(false);
73120
- }
73121
- );
72887
+ onSubmit(
72888
+ async (path) => createRichTextPatch(path, editor)
72889
+ ).finally(() => {
72890
+ setLoading(false);
72891
+ setDidChange(false);
72892
+ });
73122
72893
  }
73123
- },
73124
- children: loading ? "Saving..." : "Save"
72894
+ }
73125
72895
  }
73126
- ) })
72896
+ )
73127
72897
  ] });
73128
72898
  }
73129
72899
  function KeyOfField({
@@ -73177,7 +72947,7 @@ function KeyOfField({
73177
72947
  });
73178
72948
  }
73179
72949
  }, [value]);
73180
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col justify-between h-full gap-y-4", children: [
72950
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(FieldContainer, { children: [
73181
72951
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
73182
72952
  Select,
73183
72953
  {
@@ -73192,10 +72962,10 @@ function KeyOfField({
73192
72962
  ]
73193
72963
  }
73194
72964
  ),
73195
- onSubmit && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: defaultValue !== value && /* @__PURE__ */ jsxRuntimeExports.jsx(
73196
- Button,
72965
+ onSubmit && defaultValue !== value && /* @__PURE__ */ jsxRuntimeExports.jsx(
72966
+ SubmitButton,
73197
72967
  {
73198
- disabled: loading,
72968
+ loading,
73199
72969
  onClick: () => {
73200
72970
  setLoading(true);
73201
72971
  onSubmit(async (path) => [
@@ -73207,10 +72977,9 @@ function KeyOfField({
73207
72977
  ]).finally(() => {
73208
72978
  setLoading(false);
73209
72979
  });
73210
- },
73211
- children: loading ? "Saving..." : "Save"
72980
+ }
73212
72981
  }
73213
- ) })
72982
+ )
73214
72983
  ] });
73215
72984
  }
73216
72985
  function NumberField({
@@ -73239,7 +73008,7 @@ function NumberField({
73239
73008
  });
73240
73009
  }
73241
73010
  }, []);
73242
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col justify-between h-full gap-y-4", children: [
73011
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(FieldContainer, { children: [
73243
73012
  /* @__PURE__ */ jsxRuntimeExports.jsx(
73244
73013
  Input,
73245
73014
  {
@@ -73250,10 +73019,10 @@ function NumberField({
73250
73019
  type: "number"
73251
73020
  }
73252
73021
  ),
73253
- onSubmit && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: defaultValue !== value && /* @__PURE__ */ jsxRuntimeExports.jsx(
73254
- Button,
73022
+ onSubmit && defaultValue !== value && /* @__PURE__ */ jsxRuntimeExports.jsx(
73023
+ SubmitButton,
73255
73024
  {
73256
- disabled: loading,
73025
+ loading,
73257
73026
  onClick: () => {
73258
73027
  setLoading(true);
73259
73028
  onSubmit(async (path) => {
@@ -73268,10 +73037,9 @@ function NumberField({
73268
73037
  }).finally(() => {
73269
73038
  setLoading(false);
73270
73039
  });
73271
- },
73272
- children: loading ? "Saving..." : "Save"
73040
+ }
73273
73041
  }
73274
- ) })
73042
+ )
73275
73043
  ] });
73276
73044
  }
73277
73045
  function StringField({
@@ -73300,7 +73068,7 @@ function StringField({
73300
73068
  });
73301
73069
  }
73302
73070
  }, []);
73303
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col justify-between h-full gap-y-4", children: [
73071
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(FieldContainer, { children: [
73304
73072
  /* @__PURE__ */ jsxRuntimeExports.jsx(
73305
73073
  Input,
73306
73074
  {
@@ -73310,10 +73078,10 @@ function StringField({
73310
73078
  onChange: (e) => setValue(e.target.value)
73311
73079
  }
73312
73080
  ),
73313
- onSubmit && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: defaultValue !== value && /* @__PURE__ */ jsxRuntimeExports.jsx(
73314
- Button,
73081
+ onSubmit && defaultValue !== value && /* @__PURE__ */ jsxRuntimeExports.jsx(
73082
+ SubmitButton,
73315
73083
  {
73316
- disabled: loading,
73084
+ loading,
73317
73085
  onClick: () => {
73318
73086
  setLoading(true);
73319
73087
  onSubmit(async (path) => {
@@ -73328,12 +73096,20 @@ function StringField({
73328
73096
  }).finally(() => {
73329
73097
  setLoading(false);
73330
73098
  });
73331
- },
73332
- children: loading ? "Saving..." : "Save"
73099
+ }
73333
73100
  }
73334
- ) })
73101
+ )
73335
73102
  ] });
73336
73103
  }
73104
+ function FieldContainer({ children }) {
73105
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative p-4 border rounded border-card", children });
73106
+ }
73107
+ function SubmitButton({
73108
+ loading,
73109
+ onClick
73110
+ }) {
73111
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sticky bottom-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex justify-end w-full py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: loading, onClick, children: loading ? "Saving..." : "Save" }) }) });
73112
+ }
73337
73113
  const Logo = ({ className: className2 }) => {
73338
73114
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
73339
73115
  "svg",