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