@chaibuilder/sdk 1.2.52 → 1.2.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/{AddBlocks-GxEmM16E.js → AddBlocks-HeYXoex4.js} +2 -2
  2. package/dist/{AddBlocks-fozauzIV.cjs → AddBlocks-VHoZezjj.cjs} +1 -1
  3. package/dist/{CanvasArea-NRtblq5d.cjs → CanvasArea-137WY3Wx.cjs} +2 -2
  4. package/dist/{CanvasArea-rdY6SFYn.js → CanvasArea-CqILE5PR.js} +3 -3
  5. package/dist/{ChaiBuilderEditor-Pga_zJgw.cjs → ChaiBuilderEditor-aY8flOgX.cjs} +1 -1
  6. package/dist/{ChaiBuilderEditor-bNZZWYMh.js → ChaiBuilderEditor-tkzS851D.js} +2 -2
  7. package/dist/{CodeEditor-ye3IXW3i.cjs → CodeEditor-R2jKe97T.cjs} +1 -1
  8. package/dist/{CodeEditor-tqtgia3I.js → CodeEditor-kxV5RCpd.js} +1 -1
  9. package/dist/{CurrentPage-7NM90y76.js → CurrentPage-IrFGAb7n.js} +3 -3
  10. package/dist/{CurrentPage-sx7KVTmt.cjs → CurrentPage-PjrVzHXR.cjs} +1 -1
  11. package/dist/{ListTree-oRbeDNod.js → ListTree-0n_G8NJx.js} +1 -1
  12. package/dist/{ListTree-7Pz6H6eE.cjs → ListTree-C6oCXZDV.cjs} +1 -1
  13. package/dist/{PagesPanel-XiTUaiq_.js → PagesPanel-RYBf0Yct.js} +4 -4
  14. package/dist/{PagesPanel-Nr-908vy.cjs → PagesPanel-lIC3kYmS.cjs} +1 -1
  15. package/dist/{ProjectPanel-SuFYN60H.cjs → ProjectPanel-0Siyi5YS.cjs} +1 -1
  16. package/dist/{ProjectPanel-XfknsGkz.js → ProjectPanel-Zagx6l3Q.js} +4 -4
  17. package/dist/Settings-6QRVcl16.cjs +1 -0
  18. package/dist/{Settings-dJ72rwnH.js → Settings-RLDTFFf8.js} +797 -807
  19. package/dist/{SidePanels-t9oUA51J.js → SidePanels-ao969pMV.js} +2 -2
  20. package/dist/{SidePanels-5dnRAsJh.cjs → SidePanels-j1EFsBlK.cjs} +1 -1
  21. package/dist/{ThemeConfiguration-pcHbYiIP.js → ThemeConfiguration-S7yArRMp.js} +1 -1
  22. package/dist/{ThemeConfiguration-2Sbh29qi.cjs → ThemeConfiguration-q1471P7b.cjs} +1 -1
  23. package/dist/{Topbar-0DmS6VpB.js → Topbar-B8u0whpc.js} +1 -1
  24. package/dist/{Topbar-ID6Ipphd.cjs → Topbar-ogFKKDbx.cjs} +1 -1
  25. package/dist/{UILibrariesPanel-sXY6hozJ.cjs → UILibrariesPanel-cm9CFWxc.cjs} +1 -1
  26. package/dist/{UILibrariesPanel-G9J4KUsZ.js → UILibrariesPanel-tcfz2ELp.js} +1 -1
  27. package/dist/{UnsplashImages-HK4_1VVL.cjs → UnsplashImages-E2L3YDJI.cjs} +1 -1
  28. package/dist/{UnsplashImages-MeS5Cu7a.js → UnsplashImages-wWRifkCp.js} +1 -1
  29. package/dist/{UploadImages-AIKATqfP.js → UploadImages-lUvZhW_j.js} +1 -1
  30. package/dist/{UploadImages-LSnxByGV.cjs → UploadImages-s-eeaGiS.cjs} +1 -1
  31. package/dist/{add-page-modal-JkD45moJ.js → add-page-modal-04b4l2zu.js} +4 -4
  32. package/dist/{add-page-modal-krxKdX7-.cjs → add-page-modal-eroF20lO.cjs} +1 -1
  33. package/dist/{confirm-alert-NHxthdRK.js → confirm-alert-FX5030eR.js} +1 -1
  34. package/dist/{confirm-alert--QTC21Z2.cjs → confirm-alert-XuxEzG-V.cjs} +1 -1
  35. package/dist/core.cjs +1 -1
  36. package/dist/core.js +1 -1
  37. package/dist/{delete-page-modal-8rjPEchH.js → delete-page-modal-1u9CyAIP.js} +3 -3
  38. package/dist/{delete-page-modal-BIe0kYNH.cjs → delete-page-modal-pgh7sdfg.cjs} +1 -1
  39. package/dist/email.cjs +1 -1
  40. package/dist/email.js +1 -1
  41. package/dist/{form-PQYPrD_Q.js → form-HRdEJjVq.js} +1 -1
  42. package/dist/{form-6OLp5uEG.cjs → form-Z4IRWj0o.cjs} +1 -1
  43. package/dist/{html-to-json-ofq1N3tB.js → html-to-json-OnIZDDXw.js} +63 -58
  44. package/dist/html-to-json-rauxDBi6.cjs +1 -0
  45. package/dist/{index-seU0_UZX.cjs → index-bt7EhwLh.cjs} +1 -1
  46. package/dist/{index-9_b2eou7.js → index-vfmO3y2d.js} +3 -3
  47. package/dist/lib.cjs +1 -1
  48. package/dist/lib.js +1 -1
  49. package/dist/{page-viewer-WwwMC1Kq.cjs → page-viewer-O960kM2x.cjs} +1 -1
  50. package/dist/{page-viewer-sKluQ_e1.js → page-viewer-dcb3u4OV.js} +4 -4
  51. package/dist/{project-general-setting-Lc2ByvTt.js → project-general-setting--sS34seu.js} +4 -4
  52. package/dist/{project-general-setting-pRO1ikDV.cjs → project-general-setting-lIvNs-Vq.cjs} +1 -1
  53. package/dist/{project-seo-setting-530_6o9S.js → project-seo-setting-8tc3I-0M.js} +2 -2
  54. package/dist/{project-seo-setting-BzSrXFVv.cjs → project-seo-setting-MIlAuqcc.cjs} +1 -1
  55. package/dist/{single-page-detail-_VP4zaCI.cjs → single-page-detail-0Z_hvd_j.cjs} +1 -1
  56. package/dist/{single-page-detail-qDxxtedN.js → single-page-detail-tP2pfgBp.js} +5 -5
  57. package/dist/studio.cjs +1 -1
  58. package/dist/studio.js +3 -3
  59. package/dist/ui.cjs +1 -1
  60. package/dist/ui.js +1 -1
  61. package/dist/{useCanvasSettings-pURFQG4q.cjs → useCanvasSettings-R0h03UfD.cjs} +1 -1
  62. package/dist/{useCanvasSettings-5y2fSCpN.js → useCanvasSettings-rEZHbw3s.js} +1 -1
  63. package/dist/web-blocks.cjs +1 -1
  64. package/dist/web-blocks.js +241 -195
  65. package/package.json +1 -1
  66. package/dist/Settings-22Hy7jUT.cjs +0 -1
  67. package/dist/html-to-json-9uiQ2Dp2.cjs +0 -1
@@ -1,16 +1,16 @@
1
- import { stringify as m, parse as w } from "himalaya";
2
- import { g as N, c as k } from "./Functions-7jnEwJyw.js";
3
- import { isEmpty as g, includes as y, get as l, forEach as L, find as u, set as o, capitalize as S, flatMapDeep as $, filter as C, flatten as A } from "lodash-es";
1
+ import { stringify as m, parse as N } from "himalaya";
2
+ import { g as k, c as L } from "./Functions-7jnEwJyw.js";
3
+ import { isEmpty as g, includes as y, get as n, forEach as S, find as u, set as o, capitalize as $, flatMapDeep as A, filter as B, flatten as C } from "lodash-es";
4
4
  import { a as p } from "./MODIFIERS-fd5XOmum.js";
5
- const B = (t) => {
6
- const e = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, r = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
7
- return e.test(t) || r.test(t);
8
- }, R = (t) => {
5
+ const R = (t) => {
6
+ const e = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, a = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
7
+ return e.test(t) || a.test(t);
8
+ }, E = (t) => {
9
9
  if (g(t))
10
10
  return t;
11
- const e = /<video[^>]+src=['"]([^'">]+)['"]/, r = /<iframe[^>]+src=['"]([^'">]+)['"]/, a = t.match(e), i = t.match(r), c = a ? a[1] : i ? i[1] : null, s = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, n = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
12
- return c && (s.test(c) || n.test(c)) ? c : t;
13
- }, H = {
11
+ const e = /<video[^>]+src=['"]([^'">]+)['"]/, a = /<iframe[^>]+src=['"]([^'">]+)['"]/, r = t.match(e), i = t.match(a), c = r ? r[1] : i ? i[1] : null, s = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, l = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
12
+ return c && (s.test(c) || l.test(c)) ? c : t;
13
+ }, b = "$name", M = {
14
14
  img: { alt: "alt", width: "width", height: "height", src: "image" },
15
15
  video: {
16
16
  src: "url",
@@ -43,30 +43,31 @@ const B = (t) => {
43
43
  multiple: "multiple",
44
44
  name: "fieldName"
45
45
  }
46
- }, M = (t, e) => t.children.length === 1 && y(["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link"], e._type), b = (t) => t.map((e) => e.type === "text" ? l(e, "content", "") : g(e.children) ? "" : b(e.children)).join(""), h = (t) => t === null ? !0 : t, f = (t) => {
46
+ }, H = (t, e) => t.children.length === 1 && y(["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link"], e._type), _ = (t) => t.map((e) => e.type === "text" ? n(e, "content", "") : g(e.children) ? "" : _(e.children)).join(""), h = (t) => t === null ? !0 : t, f = (t) => {
47
47
  if (t.tagName === "svg")
48
48
  return {};
49
- const e = {}, r = H[t.tagName] || {}, a = t.attributes;
50
- return L(a, ({ key: i, value: c }) => {
51
- if (r[i]) {
52
- if (t.tagName === "img" && i === "src" && !c.startsWith("http")) {
53
- const s = u(t.attributes, { key: "width" }), n = u(t.attributes, { key: "height" });
54
- s && n ? c = `https://via.placeholder.com/${s == null ? void 0 : s.value}x${n == null ? void 0 : n.value}` : c = "https://via.placeholder.com/150x150";
55
- }
56
- o(e, r[i], h(c));
57
- } else
58
- y(["style", "class", "srcset"], i) || o(e, `styles_attrs.${i}`, h(c));
49
+ const e = {}, a = M[t.tagName] || {}, r = t.attributes;
50
+ return S(r, ({ key: i, value: c }) => {
51
+ if (i !== b)
52
+ if (a[i]) {
53
+ if (t.tagName === "img" && i === "src" && !c.startsWith("http")) {
54
+ const s = u(t.attributes, { key: "width" }), l = u(t.attributes, { key: "height" });
55
+ s && l ? c = `https://via.placeholder.com/${s == null ? void 0 : s.value}x${l == null ? void 0 : l.value}` : c = "https://via.placeholder.com/150x150";
56
+ }
57
+ o(e, a[i], h(c));
58
+ } else
59
+ y(["style", "class", "srcset"], i) || o(e, `styles_attrs.${i}`, h(c));
59
60
  }), delete e.class, e;
60
- }, E = (t, e = "styles") => {
61
+ }, I = (t, e = "styles") => {
61
62
  if (!t.attributes)
62
63
  return { [e]: `${p},` };
63
- const r = u(t.attributes, { key: "class" });
64
- if (r) {
65
- const a = r.value;
66
- return { [e]: `${p},${a}` };
64
+ const a = u(t.attributes, { key: "class" });
65
+ if (a) {
66
+ const r = a.value;
67
+ return { [e]: `${p},${r}` };
67
68
  }
68
69
  return { [e]: `${p},` };
69
- }, I = (t) => {
70
+ }, q = (t) => {
70
71
  switch (t.tagName) {
71
72
  case "img":
72
73
  return { _type: "Image" };
@@ -139,48 +140,52 @@ const B = (t) => {
139
140
  case "tfoot":
140
141
  return { _type: "TableFooter" };
141
142
  default:
142
- const e = l(t, "children", []).length > 0 ? "Box" : "EmptyBox";
143
+ const e = n(t, "children", []).length > 0 ? "Box" : "EmptyBox";
143
144
  return {
144
145
  _type: e,
145
146
  tag: t.tagName,
146
- _name: e == "EmptyBox" || t.tagName === "div" ? e : S(t.tagName)
147
+ _name: e == "EmptyBox" || t.tagName === "div" ? e : $(t.tagName)
147
148
  };
148
149
  }
149
- }, d = (t, e = null) => $(t, (r) => {
150
+ }, d = (t, e = null) => A(t, (a) => {
150
151
  var c;
151
- if (r.type === "comment")
152
+ if (a.type === "comment")
152
153
  return [];
153
- let a = { _id: N() };
154
- if (e && (a._parent = e.block._id), r.type === "text")
155
- return g(l(r, "content", "")) ? [] : e && M(e.node, e.block) ? (o(e, "block.content", l(r, "content", "")), []) : { ...a, _type: "Text", content: l(r, "content", "") };
156
- if (a = {
157
- ...a,
158
- ...I(r),
159
- ...f(r),
160
- ...E(r)
161
- }, a._type === "Input") {
162
- const s = a.inputType || "text";
163
- s === "checkbox" ? o(a, "_type", "Checkbox") : s === "radio" && o(a, "_type", "Radio");
164
- } else if (r.tagName === "video" || r.tagName === "iframe") {
165
- const s = m([r]);
166
- return B(s) && (o(a, "_type", "Video"), o(a, "url", R(s)), o(a, "styles", `${p},absolute top-0 left-0 w-full h-full`), o(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = s, [a];
167
- } else if (r.tagName === "svg") {
168
- const s = u(r.attributes, { key: "height" }), n = u(r.attributes, { key: "width" }), _ = l(s, "value") ? `[${l(s, "value")}px]` : "24px", v = l(n, "value") ? `[${l(n, "value")}px]` : "24px", T = l(u(r.attributes, { key: "class" }), "value", "w-full h-full");
169
- return a.styles = `${p}, ${k(`w-${v} h-${_}`, T)}`.trim(), r.attributes = C(r.attributes, (x) => !y(["style", "width", "height", "class"], x.key)), a.icon = m([r]), [a];
170
- } else if (r.tagName == "option" && e && ((c = e.block) == null ? void 0 : c._type) === "Select")
154
+ let r = { _id: k() };
155
+ if (e && (r._parent = e.block._id), a.type === "text")
156
+ return g(n(a, "content", "")) ? [] : e && H(e.node, e.block) ? (o(e, "block.content", n(a, "content", "")), []) : { ...r, _type: "Text", content: n(a, "content", "") };
157
+ if (r = {
158
+ ...r,
159
+ ...q(a),
160
+ ...f(a),
161
+ ...I(a)
162
+ }, a.attributes) {
163
+ const s = a.attributes.find((l) => l.key === b);
164
+ s && (r._name = s.value);
165
+ }
166
+ if (r._type === "Input") {
167
+ const s = r.inputType || "text";
168
+ s === "checkbox" ? o(r, "_type", "Checkbox") : s === "radio" && o(r, "_type", "Radio");
169
+ } else if (a.tagName === "video" || a.tagName === "iframe") {
170
+ const s = m([a]);
171
+ return R(s) && (o(r, "_type", "Video"), o(r, "url", E(s)), o(r, "styles", `${p},absolute top-0 left-0 w-full h-full`), o(r, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), r.content = s, [r];
172
+ } else if (a.tagName === "svg") {
173
+ const s = u(a.attributes, { key: "height" }), l = u(a.attributes, { key: "width" }), v = n(s, "value") ? `[${n(s, "value")}px]` : "24px", T = n(l, "value") ? `[${n(l, "value")}px]` : "24px", x = n(u(a.attributes, { key: "class" }), "value", "w-full h-full");
174
+ return r.styles = `${p}, ${L(`w-${T} h-${v}`, x)}`.trim(), a.attributes = B(a.attributes, (w) => !y(["style", "width", "height", "class"], w.key)), r.icon = m([a]), [r];
175
+ } else if (a.tagName == "option" && e && ((c = e.block) == null ? void 0 : c._type) === "Select")
171
176
  return e.block.options.push({
172
- label: b(r.children),
173
- ...f(r)
177
+ label: _(a.children),
178
+ ...f(a)
174
179
  }), [];
175
- const i = d(r.children, { block: a, node: r });
176
- return [a, ...i];
177
- }), q = (t) => {
180
+ const i = d(a.children, { block: r, node: a });
181
+ return [r, ...i];
182
+ }), P = (t) => {
178
183
  const e = t.match(/<body[^>]*>[\s\S]*?<\/body>/);
179
184
  return (e && e.length > 0 ? e[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : t).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
180
- }, V = (t) => {
181
- const e = w(q(t));
182
- return g(t) ? [] : A(d(e));
185
+ }, D = (t) => {
186
+ const e = N(P(t));
187
+ return g(t) ? [] : C(d(e));
183
188
  };
184
189
  export {
185
- V as g
190
+ D as g
186
191
  };
@@ -0,0 +1 @@
1
+ "use strict";const u=require("himalaya"),p=require("./Functions-N3yhPYKY.cjs"),s=require("lodash-es"),o=require("./MODIFIERS-mVmfEGgo.cjs"),v=t=>{const e=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,r=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return e.test(t)||r.test(t)},x=t=>{if(s.isEmpty(t))return t;const e=/<video[^>]+src=['"]([^'">]+)['"]/,r=/<iframe[^>]+src=['"]([^'">]+)['"]/,a=t.match(e),n=t.match(r),c=a?a[1]:n?n[1]:null,i=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,l=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return c&&(i.test(c)||l.test(c))?c:t},m="$name",w={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"}},S=(t,e)=>t.children.length===1&&s.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link"],e._type),h=t=>t.map(e=>e.type==="text"?s.get(e,"content",""):s.isEmpty(e.children)?"":h(e.children)).join(""),g=t=>t===null?!0:t,y=t=>{if(t.tagName==="svg")return{};const e={},r=w[t.tagName]||{},a=t.attributes;return s.forEach(a,({key:n,value:c})=>{if(n!==m)if(r[n]){if(t.tagName==="img"&&n==="src"&&!c.startsWith("http")){const i=s.find(t.attributes,{key:"width"}),l=s.find(t.attributes,{key:"height"});i&&l?c=`https://via.placeholder.com/${i==null?void 0:i.value}x${l==null?void 0:l.value}`:c="https://via.placeholder.com/150x150"}s.set(e,r[n],g(c))}else s.includes(["style","class","srcset"],n)||s.set(e,`styles_attrs.${n}`,g(c))}),delete e.class,e},E=(t,e="styles")=>{if(!t.attributes)return{[e]:`${o.STYLES_KEY},`};const r=s.find(t.attributes,{key:"class"});if(r){const a=r.value;return{[e]:`${o.STYLES_KEY},${a}`}}return{[e]:`${o.STYLES_KEY},`}},N=t=>{switch(t.tagName){case"img":return{_type:"Image"};case"input":return{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:t.tagName,_listType:t.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:t.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:t.tagName};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:"Button"};case"code":return{_type:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:t.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:t.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:const e=s.get(t,"children",[]).length>0?"Box":"EmptyBox";return{_type:e,tag:t.tagName,_name:e=="EmptyBox"||t.tagName==="div"?e:s.capitalize(t.tagName)}}},f=(t,e=null)=>s.flatMapDeep(t,r=>{var c;if(r.type==="comment")return[];let a={_id:p.generateUUID()};if(e&&(a._parent=e.block._id),r.type==="text")return s.isEmpty(s.get(r,"content",""))?[]:e&&S(e.node,e.block)?(s.set(e,"block.content",s.get(r,"content","")),[]):{...a,_type:"Text",content:s.get(r,"content","")};if(a={...a,...N(r),...y(r),...E(r)},r.attributes){const i=r.attributes.find(l=>l.key===m);i&&(a._name=i.value)}if(a._type==="Input"){const i=a.inputType||"text";i==="checkbox"?s.set(a,"_type","Checkbox"):i==="radio"&&s.set(a,"_type","Radio")}else if(r.tagName==="video"||r.tagName==="iframe"){const i=u.stringify([r]);return v(i)&&(s.set(a,"_type","Video"),s.set(a,"url",x(i)),s.set(a,"styles",`${o.STYLES_KEY},absolute top-0 left-0 w-full h-full`),s.set(a,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),a.content=i,[a]}else if(r.tagName==="svg"){const i=s.find(r.attributes,{key:"height"}),l=s.find(r.attributes,{key:"width"}),b=s.get(i,"value")?`[${s.get(i,"value")}px]`:"24px",d=s.get(l,"value")?`[${s.get(l,"value")}px]`:"24px",_=s.get(s.find(r.attributes,{key:"class"}),"value","w-full h-full");return a.styles=`${o.STYLES_KEY}, ${p.cn(`w-${d} h-${b}`,_)}`.trim(),r.attributes=s.filter(r.attributes,T=>!s.includes(["style","width","height","class"],T.key)),a.icon=u.stringify([r]),[a]}else if(r.tagName=="option"&&e&&((c=e.block)==null?void 0:c._type)==="Select")return e.block.options.push({label:h(r.children),...y(r)}),[];const n=f(r.children,{block:a,node:r});return[a,...n]}),L=t=>{const e=t.match(/<body[^>]*>[\s\S]*?<\/body>/);return(e&&e.length>0?e[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):t).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},k=t=>{const e=u.parse(L(t));return s.isEmpty(t)?[]:s.flatten(f(e))};exports.getBlocksFromHTML=k;
@@ -1 +1 @@
1
- "use strict";var H2=(h,t,c)=>{if(!t.has(h))throw TypeError("Cannot "+c)};var n=(h,t,c)=>(H2(h,t,"read from private field"),c?c.call(h):t.get(h)),e=(h,t,c)=>{if(t.has(h))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(h):t.set(h,c)},v=(h,t,c,a)=>(H2(h,t,"write to private field"),a?a.call(h,c):t.set(h,c),c);var i2=(h,t,c,a)=>({set _(l){v(h,t,l,c)},get _(){return n(h,t,a)}}),M=(h,t,c)=>(H2(h,t,"access private method"),c);const d=require("./jsx-runtime-Z_BpKhVy.cjs"),N=require("react");require("./core.cjs");const r2=require("@radix-ui/react-icons"),T=require("./ChaiBuilderEditor-Pga_zJgw.cjs"),h1=require("sonner"),s0=require("react-i18next"),c1=require("lodash-es"),p0=require("./html-to-json-9uiQ2Dp2.cjs"),S2=require("lucide-react"),t0=require("./index--mLLy7QQ.cjs");function V0(h){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const c in h)if(c!=="default"){const a=Object.getOwnPropertyDescriptor(h,c);Object.defineProperty(t,c,a.get?a:{enumerable:!0,get:()=>h[c]})}}return t.default=h,Object.freeze(t)}const A=V0(N);var W1=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(h){return this.listeners.add(h),this.onSubscribe(),()=>{this.listeners.delete(h),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},N1=typeof window>"u"||"Deno"in window;function _(){}function f0(h,t){return typeof h=="function"?h(t):h}function s2(h){return typeof h=="number"&&h>=0&&h!==1/0}function h0(h,t){return Math.max(h+(t||0)-Date.now(),0)}function R2(h,t){const{type:c="all",exact:a,fetchStatus:l,predicate:i,queryKey:r,stale:z}=h;if(r){if(a){if(t.queryHash!==A2(r,t.options))return!1}else if(!Q1(t.queryKey,r))return!1}if(c!=="all"){const s=t.isActive();if(c==="active"&&!s||c==="inactive"&&s)return!1}return!(typeof z=="boolean"&&t.isStale()!==z||typeof l<"u"&&l!==t.state.fetchStatus||i&&!i(t))}function F2(h,t){const{exact:c,status:a,predicate:l,mutationKey:i}=h;if(i){if(!t.options.mutationKey)return!1;if(c){if(U1(t.options.mutationKey)!==U1(i))return!1}else if(!Q1(t.options.mutationKey,i))return!1}return!(a&&t.state.status!==a||l&&!l(t))}function A2(h,t){return((t==null?void 0:t.queryKeyHashFn)||U1)(h)}function U1(h){return JSON.stringify(h,(t,c)=>p2(c)?Object.keys(c).sort().reduce((a,l)=>(a[l]=c[l],a),{}):c)}function Q1(h,t){return h===t?!0:typeof h!=typeof t?!1:h&&t&&typeof h=="object"&&typeof t=="object"?!Object.keys(t).some(c=>!Q1(h[c],t[c])):!1}function c0(h,t){if(h===t)return h;const c=k2(h)&&k2(t);if(c||p2(h)&&p2(t)){const a=c?h.length:Object.keys(h).length,l=c?t:Object.keys(t),i=l.length,r=c?[]:{};let z=0;for(let s=0;s<i;s++){const p=c?s:l[s];r[p]=c0(h[p],t[p]),r[p]===h[p]&&z++}return a===i&&z===a?h:r}return t}function e2(h,t){if(h&&!t||t&&!h)return!1;for(const c in h)if(h[c]!==t[c])return!1;return!0}function k2(h){return Array.isArray(h)&&h.length===Object.keys(h).length}function p2(h){if(!D2(h))return!1;const t=h.constructor;if(typeof t>"u")return!0;const c=t.prototype;return!(!D2(c)||!c.hasOwnProperty("isPrototypeOf"))}function D2(h){return Object.prototype.toString.call(h)==="[object Object]"}function a0(h){return new Promise(t=>{setTimeout(t,h)})}function E2(h){a0(0).then(h)}function V2(h,t,c){return typeof c.structuralSharing=="function"?c.structuralSharing(h,t):c.structuralSharing!==!1?c0(h,t):t}function m0(h,t,c=0){const a=[...h,t];return c&&a.length>c?a.slice(1):a}function x0(h,t,c=0){const a=[t,...h];return c&&a.length>c?a.slice(0,-1):a}var u1,v1,B1,U2,L0=(U2=class extends W1{constructor(){super();e(this,u1,void 0);e(this,v1,void 0);e(this,B1,void 0);v(this,B1,t=>{if(!N1&&window.addEventListener){const c=()=>t();return window.addEventListener("visibilitychange",c,!1),()=>{window.removeEventListener("visibilitychange",c)}}})}onSubscribe(){n(this,v1)||this.setEventListener(n(this,B1))}onUnsubscribe(){var t;this.hasListeners()||((t=n(this,v1))==null||t.call(this),v(this,v1,void 0))}setEventListener(t){var c;v(this,B1,t),(c=n(this,v1))==null||c.call(this),v(this,v1,t(a=>{typeof a=="boolean"?this.setFocused(a):this.onFocus()}))}setFocused(t){n(this,u1)!==t&&(v(this,u1,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof n(this,u1)=="boolean"?n(this,u1):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},u1=new WeakMap,v1=new WeakMap,B1=new WeakMap,U2),o2=new L0,I1,d1,G1,Q2,w0=(Q2=class extends W1{constructor(){super();e(this,I1,!0);e(this,d1,void 0);e(this,G1,void 0);v(this,G1,t=>{if(!N1&&window.addEventListener){const c=()=>t(!0),a=()=>t(!1);return window.addEventListener("online",c,!1),window.addEventListener("offline",a,!1),()=>{window.removeEventListener("online",c),window.removeEventListener("offline",a)}}})}onSubscribe(){n(this,d1)||this.setEventListener(n(this,G1))}onUnsubscribe(){var t;this.hasListeners()||((t=n(this,d1))==null||t.call(this),v(this,d1,void 0))}setEventListener(t){var c;v(this,G1,t),(c=n(this,d1))==null||c.call(this),v(this,d1,t(this.setOnline.bind(this)))}setOnline(t){n(this,I1)!==t&&(v(this,I1,t),this.listeners.forEach(a=>{a(t)}))}isOnline(){return n(this,I1)}},I1=new WeakMap,d1=new WeakMap,G1=new WeakMap,Q2),z2=new w0;function B0(h){return Math.min(1e3*2**h,3e4)}function M2(h){return(h??"online")==="online"?z2.isOnline():!0}var n0=class{constructor(h){this.revert=h==null?void 0:h.revert,this.silent=h==null?void 0:h.silent}};function u2(h){return h instanceof n0}function l0(h){let t=!1,c=0,a=!1,l,i,r;const z=new Promise((g,u)=>{i=g,r=u}),s=g=>{var u;a||(H(new n0(g)),(u=h.abort)==null||u.call(h))},p=()=>{t=!0},o=()=>{t=!1},L=()=>!o2.isFocused()||h.networkMode!=="always"&&!z2.isOnline(),b=g=>{var u;a||(a=!0,(u=h.onSuccess)==null||u.call(h,g),l==null||l(),i(g))},H=g=>{var u;a||(a=!0,(u=h.onError)==null||u.call(h,g),l==null||l(),r(g))},V=()=>new Promise(g=>{var u;l=G=>{const f=a||!L();return f&&g(G),f},(u=h.onPause)==null||u.call(h)}).then(()=>{var g;l=void 0,a||(g=h.onContinue)==null||g.call(h)}),B=()=>{if(a)return;let g;try{g=h.fn()}catch(u){g=Promise.reject(u)}Promise.resolve(g).then(b).catch(u=>{var F;if(a)return;const G=h.retry??(N1?0:3),f=h.retryDelay??B0,m=typeof f=="function"?f(c,u):f,y=G===!0||typeof G=="number"&&c<G||typeof G=="function"&&G(c,u);if(t||!y){H(u);return}c++,(F=h.onFail)==null||F.call(h,c,u),a0(m).then(()=>{if(L())return V()}).then(()=>{t?H(u):B()})})};return M2(h.networkMode)?B():V().then(B),{promise:z,cancel:s,continue:()=>(l==null?void 0:l())?z:Promise.resolve(),cancelRetry:p,continueRetry:o}}function I0(){let h=[],t=0,c=o=>{o()},a=o=>{o()};const l=o=>{let L;t++;try{L=o()}finally{t--,t||z()}return L},i=o=>{t?h.push(o):E2(()=>{c(o)})},r=o=>(...L)=>{i(()=>{o(...L)})},z=()=>{const o=h;h=[],o.length&&E2(()=>{a(()=>{o.forEach(L=>{c(L)})})})};return{batch:l,batchCalls:r,schedule:i,setNotifyFunction:o=>{c=o},setBatchNotifyFunction:o=>{a=o}}}var O=I0(),s1,K2,i0=(K2=class{constructor(){e(this,s1,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),s2(this.gcTime)&&v(this,s1,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(h){this.gcTime=Math.max(this.gcTime||0,h??(N1?1/0:5*60*1e3))}clearGcTimeout(){n(this,s1)&&(clearTimeout(n(this,s1)),v(this,s1,void 0))}},s1=new WeakMap,K2),C1,O1,U,r1,Q,S,K1,p1,S1,v2,$,n1,q2,G0=(q2=class extends i0{constructor(t){super();e(this,S1);e(this,$);e(this,C1,void 0);e(this,O1,void 0);e(this,U,void 0);e(this,r1,void 0);e(this,Q,void 0);e(this,S,void 0);e(this,K1,void 0);e(this,p1,void 0);v(this,p1,!1),v(this,K1,t.defaultOptions),M(this,S1,v2).call(this,t.options),v(this,S,[]),v(this,U,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,v(this,C1,t.state||C0(this.options)),this.state=n(this,C1),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!n(this,S).length&&this.state.fetchStatus==="idle"&&n(this,U).remove(this)}setData(t,c){const a=V2(this.state.data,t,this.options);return M(this,$,n1).call(this,{data:a,type:"success",dataUpdatedAt:c==null?void 0:c.updatedAt,manual:c==null?void 0:c.manual}),a}setState(t,c){M(this,$,n1).call(this,{type:"setState",state:t,setStateOptions:c})}cancel(t){var a;const c=n(this,r1);return(a=n(this,Q))==null||a.cancel(t),c?c.then(_).catch(_):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(n(this,C1))}isActive(){return n(this,S).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||n(this,S).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!h0(this.state.dataUpdatedAt,t)}onFocus(){var c;const t=n(this,S).find(a=>a.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(c=n(this,Q))==null||c.continue()}onOnline(){var c;const t=n(this,S).find(a=>a.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(c=n(this,Q))==null||c.continue()}addObserver(t){n(this,S).includes(t)||(n(this,S).push(t),this.clearGcTimeout(),n(this,U).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){n(this,S).includes(t)&&(v(this,S,n(this,S).filter(c=>c!==t)),n(this,S).length||(n(this,Q)&&(n(this,p1)?n(this,Q).cancel({revert:!0}):n(this,Q).cancelRetry()),this.scheduleGc()),n(this,U).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return n(this,S).length}invalidate(){this.state.isInvalidated||M(this,$,n1).call(this,{type:"invalidate"})}fetch(t,c){var p,o,L,b;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(c!=null&&c.cancelRefetch))this.cancel({silent:!0});else if(n(this,r1))return(p=n(this,Q))==null||p.continueRetry(),n(this,r1)}if(t&&M(this,S1,v2).call(this,t),!this.options.queryFn){const H=n(this,S).find(V=>V.options.queryFn);H&&M(this,S1,v2).call(this,H.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const a=new AbortController,l={queryKey:this.queryKey,meta:this.meta},i=H=>{Object.defineProperty(H,"signal",{enumerable:!0,get:()=>(v(this,p1,!0),a.signal)})};i(l);const r=()=>this.options.queryFn?(v(this,p1,!1),this.options.persister?this.options.persister(this.options.queryFn,l,this):this.options.queryFn(l)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),z={fetchOptions:c,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:r};i(z),(o=this.options.behavior)==null||o.onFetch(z,this),v(this,O1,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((L=z.fetchOptions)==null?void 0:L.meta))&&M(this,$,n1).call(this,{type:"fetch",meta:(b=z.fetchOptions)==null?void 0:b.meta});const s=H=>{var V,B,g,u;u2(H)&&H.silent||M(this,$,n1).call(this,{type:"error",error:H}),u2(H)||((B=(V=n(this,U).config).onError)==null||B.call(V,H,this),(u=(g=n(this,U).config).onSettled)==null||u.call(g,this.state.data,H,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return v(this,Q,l0({fn:z.fetchFn,abort:a.abort.bind(a),onSuccess:H=>{var V,B,g,u;if(typeof H>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),s(new Error(`${this.queryHash} data is undefined`));return}this.setData(H),(B=(V=n(this,U).config).onSuccess)==null||B.call(V,H,this),(u=(g=n(this,U).config).onSettled)==null||u.call(g,H,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:s,onFail:(H,V)=>{M(this,$,n1).call(this,{type:"failed",failureCount:H,error:V})},onPause:()=>{M(this,$,n1).call(this,{type:"pause"})},onContinue:()=>{M(this,$,n1).call(this,{type:"continue"})},retry:z.options.retry,retryDelay:z.options.retryDelay,networkMode:z.options.networkMode})),v(this,r1,n(this,Q).promise),n(this,r1)}},C1=new WeakMap,O1=new WeakMap,U=new WeakMap,r1=new WeakMap,Q=new WeakMap,S=new WeakMap,K1=new WeakMap,p1=new WeakMap,S1=new WeakSet,v2=function(t){this.options={...n(this,K1),...t},this.updateGcTime(this.options.gcTime)},$=new WeakSet,n1=function(t){const c=a=>{switch(t.type){case"failed":return{...a,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...a,fetchStatus:"paused"};case"continue":return{...a,fetchStatus:"fetching"};case"fetch":return{...a,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:M2(this.options.networkMode)?"fetching":"paused",...!a.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...a,data:t.data,dataUpdateCount:a.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const l=t.error;return u2(l)&&l.revert&&n(this,O1)?{...n(this,O1),fetchStatus:"idle"}:{...a,error:l,errorUpdateCount:a.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:a.fetchFailureCount+1,fetchFailureReason:l,fetchStatus:"idle",status:"error"};case"invalidate":return{...a,isInvalidated:!0};case"setState":return{...a,...t.state}}};this.state=c(this.state),O.batch(()=>{n(this,S).forEach(a=>{a.onQueryUpdate()}),n(this,U).notify({query:this,type:"updated",action:t})})},q2);function C0(h){const t=typeof h.initialData=="function"?h.initialData():h.initialData,c=typeof t<"u",a=c?typeof h.initialDataUpdatedAt=="function"?h.initialDataUpdatedAt():h.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:c?a??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:c?"success":"pending",fetchStatus:"idle"}}var Z,_2,O0=(_2=class extends W1{constructor(t={}){super();e(this,Z,void 0);this.config=t,v(this,Z,new Map)}build(t,c,a){const l=c.queryKey,i=c.queryHash??A2(l,c);let r=this.get(i);return r||(r=new G0({cache:this,queryKey:l,queryHash:i,options:t.defaultQueryOptions(c),state:a,defaultOptions:t.getQueryDefaults(l)}),this.add(r)),r}add(t){n(this,Z).has(t.queryHash)||(n(this,Z).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const c=n(this,Z).get(t.queryHash);c&&(t.destroy(),c===t&&n(this,Z).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){O.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return n(this,Z).get(t)}getAll(){return[...n(this,Z).values()]}find(t){const c={exact:!0,...t};return this.getAll().find(a=>R2(c,a))}findAll(t={}){const c=this.getAll();return Object.keys(t).length>0?c.filter(a=>R2(t,a)):c}notify(t){O.batch(()=>{this.listeners.forEach(c=>{c(t)})})}onFocus(){O.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){O.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Z=new WeakMap,_2),Y,q1,E,A1,X,i1,$2,S0=($2=class extends i0{constructor(t){super();e(this,X);e(this,Y,void 0);e(this,q1,void 0);e(this,E,void 0);e(this,A1,void 0);this.mutationId=t.mutationId,v(this,q1,t.defaultOptions),v(this,E,t.mutationCache),v(this,Y,[]),this.state=t.state||v0(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...n(this,q1),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){n(this,Y).includes(t)||(n(this,Y).push(t),this.clearGcTimeout(),n(this,E).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){v(this,Y,n(this,Y).filter(c=>c!==t)),this.scheduleGc(),n(this,E).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){n(this,Y).length||(this.state.status==="pending"?this.scheduleGc():n(this,E).remove(this))}continue(){var t;return((t=n(this,A1))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,i,r,z,s,p,o,L,b,H,V,B,g,u,G,f,m,y,F,I;const c=()=>(v(this,A1,l0({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(w,a1)=>{M(this,X,i1).call(this,{type:"failed",failureCount:w,error:a1})},onPause:()=>{M(this,X,i1).call(this,{type:"pause"})},onContinue:()=>{M(this,X,i1).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),n(this,A1).promise),a=this.state.status==="pending";try{if(!a){M(this,X,i1).call(this,{type:"pending",variables:t}),await((i=(l=n(this,E).config).onMutate)==null?void 0:i.call(l,t,this));const a1=await((z=(r=this.options).onMutate)==null?void 0:z.call(r,t));a1!==this.state.context&&M(this,X,i1).call(this,{type:"pending",context:a1,variables:t})}const w=await c();return await((p=(s=n(this,E).config).onSuccess)==null?void 0:p.call(s,w,t,this.state.context,this)),await((L=(o=this.options).onSuccess)==null?void 0:L.call(o,w,t,this.state.context)),await((H=(b=n(this,E).config).onSettled)==null?void 0:H.call(b,w,null,this.state.variables,this.state.context,this)),await((B=(V=this.options).onSettled)==null?void 0:B.call(V,w,null,t,this.state.context)),M(this,X,i1).call(this,{type:"success",data:w}),w}catch(w){try{throw await((u=(g=n(this,E).config).onError)==null?void 0:u.call(g,w,t,this.state.context,this)),await((f=(G=this.options).onError)==null?void 0:f.call(G,w,t,this.state.context)),await((y=(m=n(this,E).config).onSettled)==null?void 0:y.call(m,void 0,w,this.state.variables,this.state.context,this)),await((I=(F=this.options).onSettled)==null?void 0:I.call(F,void 0,w,t,this.state.context)),w}finally{M(this,X,i1).call(this,{type:"error",error:w})}}}},Y=new WeakMap,q1=new WeakMap,E=new WeakMap,A1=new WeakMap,X=new WeakSet,i1=function(t){const c=a=>{switch(t.type){case"failed":return{...a,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...a,isPaused:!0};case"continue":return{...a,isPaused:!1};case"pending":return{...a,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!M2(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...a,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...a,data:void 0,error:t.error,failureCount:a.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=c(this.state),O.batch(()=>{n(this,Y).forEach(a=>{a.onMutationUpdate(t)}),n(this,E).notify({mutation:this,type:"updated",action:t})})},$2);function v0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var K,_1,V1,J2,A0=(J2=class extends W1{constructor(t={}){super();e(this,K,void 0);e(this,_1,void 0);e(this,V1,void 0);this.config=t,v(this,K,[]),v(this,_1,0)}build(t,c,a){const l=new S0({mutationCache:this,mutationId:++i2(this,_1)._,options:t.defaultMutationOptions(c),state:a});return this.add(l),l}add(t){n(this,K).push(t),this.notify({type:"added",mutation:t})}remove(t){v(this,K,n(this,K).filter(c=>c!==t)),this.notify({type:"removed",mutation:t})}clear(){O.batch(()=>{n(this,K).forEach(t=>{this.remove(t)})})}getAll(){return n(this,K)}find(t){const c={exact:!0,...t};return n(this,K).find(a=>F2(c,a))}findAll(t={}){return n(this,K).filter(c=>F2(t,c))}notify(t){O.batch(()=>{this.listeners.forEach(c=>{c(t)})})}resumePausedMutations(){return v(this,V1,(n(this,V1)??Promise.resolve()).then(()=>{const t=n(this,K).filter(c=>c.state.isPaused);return O.batch(()=>t.reduce((c,a)=>c.then(()=>a.continue().catch(_)),Promise.resolve()))}).then(()=>{v(this,V1,void 0)})),n(this,V1)}},K=new WeakMap,_1=new WeakMap,V1=new WeakMap,J2);function y0(h){return{onFetch:(t,c)=>{const a=async()=>{var V,B,g,u,G;const l=t.options,i=(g=(B=(V=t.fetchOptions)==null?void 0:V.meta)==null?void 0:B.fetchMore)==null?void 0:g.direction,r=((u=t.state.data)==null?void 0:u.pages)||[],z=((G=t.state.data)==null?void 0:G.pageParams)||[],s={pages:[],pageParams:[]};let p=!1;const o=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(t.signal.aborted?p=!0:t.signal.addEventListener("abort",()=>{p=!0}),t.signal)})},L=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),b=async(f,m,y)=>{if(p)return Promise.reject();if(m==null&&f.pages.length)return Promise.resolve(f);const F={queryKey:t.queryKey,pageParam:m,direction:y?"backward":"forward",meta:t.options.meta};o(F);const I=await L(F),{maxPages:w}=t.options,a1=y?x0:m0;return{pages:a1(f.pages,I,w),pageParams:a1(f.pageParams,m,w)}};let H;if(i&&r.length){const f=i==="backward",m=f?b0:T2,y={pages:r,pageParams:z},F=m(l,y);H=await b(y,F,f)}else{H=await b(s,z[0]??l.initialPageParam);const f=h??r.length;for(let m=1;m<f;m++){const y=T2(l,H);H=await b(H,y)}}return H};t.options.persister?t.fetchFn=()=>{var l,i;return(i=(l=t.options).persister)==null?void 0:i.call(l,a,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},c)}:t.fetchFn=a}}}function T2(h,{pages:t,pageParams:c}){const a=t.length-1;return h.getNextPageParam(t[a],t,c[a],c)}function b0(h,{pages:t,pageParams:c}){var a;return(a=h.getPreviousPageParam)==null?void 0:a.call(h,t[0],t,c[0],c)}var C,e1,o1,y1,b1,z1,P1,R1,Z2,P0=(Z2=class{constructor(h={}){e(this,C,void 0);e(this,e1,void 0);e(this,o1,void 0);e(this,y1,void 0);e(this,b1,void 0);e(this,z1,void 0);e(this,P1,void 0);e(this,R1,void 0);v(this,C,h.queryCache||new O0),v(this,e1,h.mutationCache||new A0),v(this,o1,h.defaultOptions||{}),v(this,y1,new Map),v(this,b1,new Map),v(this,z1,0)}mount(){i2(this,z1)._++,n(this,z1)===1&&(v(this,P1,o2.subscribe(()=>{o2.isFocused()&&(this.resumePausedMutations(),n(this,C).onFocus())})),v(this,R1,z2.subscribe(()=>{z2.isOnline()&&(this.resumePausedMutations(),n(this,C).onOnline())})))}unmount(){var h,t;i2(this,z1)._--,n(this,z1)===0&&((h=n(this,P1))==null||h.call(this),v(this,P1,void 0),(t=n(this,R1))==null||t.call(this),v(this,R1,void 0))}isFetching(h){return n(this,C).findAll({...h,fetchStatus:"fetching"}).length}isMutating(h){return n(this,e1).findAll({...h,status:"pending"}).length}getQueryData(h){var t;return(t=n(this,C).find({queryKey:h}))==null?void 0:t.state.data}ensureQueryData(h){const t=this.getQueryData(h.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(h)}getQueriesData(h){return this.getQueryCache().findAll(h).map(({queryKey:t,state:c})=>{const a=c.data;return[t,a]})}setQueryData(h,t,c){const a=n(this,C).find({queryKey:h}),l=a==null?void 0:a.state.data,i=f0(t,l);if(typeof i>"u")return;const r=this.defaultQueryOptions({queryKey:h});return n(this,C).build(this,r).setData(i,{...c,manual:!0})}setQueriesData(h,t,c){return O.batch(()=>this.getQueryCache().findAll(h).map(({queryKey:a})=>[a,this.setQueryData(a,t,c)]))}getQueryState(h){var t;return(t=n(this,C).find({queryKey:h}))==null?void 0:t.state}removeQueries(h){const t=n(this,C);O.batch(()=>{t.findAll(h).forEach(c=>{t.remove(c)})})}resetQueries(h,t){const c=n(this,C),a={type:"active",...h};return O.batch(()=>(c.findAll(h).forEach(l=>{l.reset()}),this.refetchQueries(a,t)))}cancelQueries(h={},t={}){const c={revert:!0,...t},a=O.batch(()=>n(this,C).findAll(h).map(l=>l.cancel(c)));return Promise.all(a).then(_).catch(_)}invalidateQueries(h={},t={}){return O.batch(()=>{if(n(this,C).findAll(h).forEach(a=>{a.invalidate()}),h.refetchType==="none")return Promise.resolve();const c={...h,type:h.refetchType??h.type??"active"};return this.refetchQueries(c,t)})}refetchQueries(h={},t){const c={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},a=O.batch(()=>n(this,C).findAll(h).filter(l=>!l.isDisabled()).map(l=>{let i=l.fetch(void 0,c);return c.throwOnError||(i=i.catch(_)),l.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(a).then(_)}fetchQuery(h){const t=this.defaultQueryOptions(h);typeof t.retry>"u"&&(t.retry=!1);const c=n(this,C).build(this,t);return c.isStaleByTime(t.staleTime)?c.fetch(t):Promise.resolve(c.state.data)}prefetchQuery(h){return this.fetchQuery(h).then(_).catch(_)}fetchInfiniteQuery(h){return h.behavior=y0(h.pages),this.fetchQuery(h)}prefetchInfiniteQuery(h){return this.fetchInfiniteQuery(h).then(_).catch(_)}resumePausedMutations(){return n(this,e1).resumePausedMutations()}getQueryCache(){return n(this,C)}getMutationCache(){return n(this,e1)}getDefaultOptions(){return n(this,o1)}setDefaultOptions(h){v(this,o1,h)}setQueryDefaults(h,t){n(this,y1).set(U1(h),{queryKey:h,defaultOptions:t})}getQueryDefaults(h){const t=[...n(this,y1).values()];let c={};return t.forEach(a=>{Q1(h,a.queryKey)&&(c={...c,...a.defaultOptions})}),c}setMutationDefaults(h,t){n(this,b1).set(U1(h),{mutationKey:h,defaultOptions:t})}getMutationDefaults(h){const t=[...n(this,b1).values()];let c={};return t.forEach(a=>{Q1(h,a.mutationKey)&&(c={...c,...a.defaultOptions})}),c}defaultQueryOptions(h){if(h!=null&&h._defaulted)return h;const t={...n(this,o1).queries,...(h==null?void 0:h.queryKey)&&this.getQueryDefaults(h.queryKey),...h,_defaulted:!0};return t.queryHash||(t.queryHash=A2(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(h){return h!=null&&h._defaulted?h:{...n(this,o1).mutations,...(h==null?void 0:h.mutationKey)&&this.getMutationDefaults(h.mutationKey),...h,_defaulted:!0}}clear(){n(this,C).clear(),n(this,e1).clear()}},C=new WeakMap,e1=new WeakMap,o1=new WeakMap,y1=new WeakMap,b1=new WeakMap,z1=new WeakMap,P1=new WeakMap,R1=new WeakMap,Z2),D,x,F1,P,f1,k1,t1,$1,D1,E1,m1,x1,g1,L1,w1,j1,J1,f2,Z1,m2,Y1,x2,X1,L2,t2,w2,h2,B2,c2,I2,g2,d0,Y2,R0=(Y2=class extends W1{constructor(t,c){super();e(this,w1);e(this,J1);e(this,Z1);e(this,Y1);e(this,X1);e(this,t2);e(this,h2);e(this,c2);e(this,g2);e(this,D,void 0);e(this,x,void 0);e(this,F1,void 0);e(this,P,void 0);e(this,f1,void 0);e(this,k1,void 0);e(this,t1,void 0);e(this,$1,void 0);e(this,D1,void 0);e(this,E1,void 0);e(this,m1,void 0);e(this,x1,void 0);e(this,g1,void 0);e(this,L1,void 0);v(this,x,void 0),v(this,F1,void 0),v(this,P,void 0),v(this,L1,new Set),v(this,D,t),this.options=c,v(this,t1,null),this.bindMethods(),this.setOptions(c)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(n(this,x).addObserver(this),N2(n(this,x),this.options)?M(this,w1,j1).call(this):this.updateResult(),M(this,X1,L2).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return G2(n(this,x),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return G2(n(this,x),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,M(this,t2,w2).call(this),M(this,h2,B2).call(this),n(this,x).removeObserver(this)}setOptions(t,c){const a=this.options,l=n(this,x);if(this.options=n(this,D).defaultQueryOptions(t),e2(a,this.options)||n(this,D).getQueryCache().notify({type:"observerOptionsUpdated",query:n(this,x),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=a.queryKey),M(this,c2,I2).call(this);const i=this.hasListeners();i&&W2(n(this,x),l,this.options,a)&&M(this,w1,j1).call(this),this.updateResult(c),i&&(n(this,x)!==l||this.options.enabled!==a.enabled||this.options.staleTime!==a.staleTime)&&M(this,J1,f2).call(this);const r=M(this,Z1,m2).call(this);i&&(n(this,x)!==l||this.options.enabled!==a.enabled||r!==n(this,g1))&&M(this,Y1,x2).call(this,r)}getOptimisticResult(t){const c=n(this,D).getQueryCache().build(n(this,D),t),a=this.createResult(c,t);return k0(this,a)&&(v(this,P,a),v(this,k1,this.options),v(this,f1,n(this,x).state)),a}getCurrentResult(){return n(this,P)}trackResult(t){const c={};return Object.keys(t).forEach(a=>{Object.defineProperty(c,a,{configurable:!1,enumerable:!0,get:()=>(n(this,L1).add(a),t[a])})}),c}getCurrentQuery(){return n(this,x)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const c=n(this,D).defaultQueryOptions(t),a=n(this,D).getQueryCache().build(n(this,D),c);return a.isFetchingOptimistic=!0,a.fetch().then(()=>this.createResult(a,c))}fetch(t){return M(this,w1,j1).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),n(this,P)))}createResult(t,c){var F;const a=n(this,x),l=this.options,i=n(this,P),r=n(this,f1),z=n(this,k1),p=t!==a?t.state:n(this,F1),{state:o}=t;let{error:L,errorUpdatedAt:b,fetchStatus:H,status:V}=o,B=!1,g;if(c._optimisticResults){const I=this.hasListeners(),w=!I&&N2(t,c),a1=I&&W2(t,a,c,l);(w||a1)&&(H=M2(t.options.networkMode)?"fetching":"paused",o.dataUpdatedAt||(V="pending")),c._optimisticResults==="isRestoring"&&(H="idle")}if(c.select&&typeof o.data<"u")if(i&&o.data===(r==null?void 0:r.data)&&c.select===n(this,$1))g=n(this,D1);else try{v(this,$1,c.select),g=c.select(o.data),g=V2(i==null?void 0:i.data,g,c),v(this,D1,g),v(this,t1,null)}catch(I){v(this,t1,I)}else g=o.data;if(typeof c.placeholderData<"u"&&typeof g>"u"&&V==="pending"){let I;if(i!=null&&i.isPlaceholderData&&c.placeholderData===(z==null?void 0:z.placeholderData))I=i.data;else if(I=typeof c.placeholderData=="function"?c.placeholderData((F=n(this,E1))==null?void 0:F.state.data,n(this,E1)):c.placeholderData,c.select&&typeof I<"u")try{I=c.select(I),v(this,t1,null)}catch(w){v(this,t1,w)}typeof I<"u"&&(V="success",g=V2(i==null?void 0:i.data,I,c),B=!0)}n(this,t1)&&(L=n(this,t1),g=n(this,D1),b=Date.now(),V="error");const u=H==="fetching",G=V==="pending",f=V==="error",m=G&&u;return{status:V,fetchStatus:H,isPending:G,isSuccess:V==="success",isError:f,isInitialLoading:m,isLoading:m,data:g,dataUpdatedAt:o.dataUpdatedAt,error:L,errorUpdatedAt:b,failureCount:o.fetchFailureCount,failureReason:o.fetchFailureReason,errorUpdateCount:o.errorUpdateCount,isFetched:o.dataUpdateCount>0||o.errorUpdateCount>0,isFetchedAfterMount:o.dataUpdateCount>p.dataUpdateCount||o.errorUpdateCount>p.errorUpdateCount,isFetching:u,isRefetching:u&&!G,isLoadingError:f&&o.dataUpdatedAt===0,isPaused:H==="paused",isPlaceholderData:B,isRefetchError:f&&o.dataUpdatedAt!==0,isStale:y2(t,c),refetch:this.refetch}}updateResult(t){const c=n(this,P),a=this.createResult(n(this,x),this.options);if(v(this,f1,n(this,x).state),v(this,k1,this.options),n(this,f1).data!==void 0&&v(this,E1,n(this,x)),e2(a,c))return;v(this,P,a);const l={},i=()=>{if(!c)return!0;const{notifyOnChangeProps:r}=this.options,z=typeof r=="function"?r():r;if(z==="all"||!z&&!n(this,L1).size)return!0;const s=new Set(z??n(this,L1));return this.options.throwOnError&&s.add("error"),Object.keys(n(this,P)).some(p=>{const o=p;return n(this,P)[o]!==c[o]&&s.has(o)})};(t==null?void 0:t.listeners)!==!1&&i()&&(l.listeners=!0),M(this,g2,d0).call(this,{...l,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&M(this,X1,L2).call(this)}},D=new WeakMap,x=new WeakMap,F1=new WeakMap,P=new WeakMap,f1=new WeakMap,k1=new WeakMap,t1=new WeakMap,$1=new WeakMap,D1=new WeakMap,E1=new WeakMap,m1=new WeakMap,x1=new WeakMap,g1=new WeakMap,L1=new WeakMap,w1=new WeakSet,j1=function(t){M(this,c2,I2).call(this);let c=n(this,x).fetch(this.options,t);return t!=null&&t.throwOnError||(c=c.catch(_)),c},J1=new WeakSet,f2=function(){if(M(this,t2,w2).call(this),N1||n(this,P).isStale||!s2(this.options.staleTime))return;const c=h0(n(this,P).dataUpdatedAt,this.options.staleTime)+1;v(this,m1,setTimeout(()=>{n(this,P).isStale||this.updateResult()},c))},Z1=new WeakSet,m2=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(n(this,x)):this.options.refetchInterval)??!1},Y1=new WeakSet,x2=function(t){M(this,h2,B2).call(this),v(this,g1,t),!(N1||this.options.enabled===!1||!s2(n(this,g1))||n(this,g1)===0)&&v(this,x1,setInterval(()=>{(this.options.refetchIntervalInBackground||o2.isFocused())&&M(this,w1,j1).call(this)},n(this,g1)))},X1=new WeakSet,L2=function(){M(this,J1,f2).call(this),M(this,Y1,x2).call(this,M(this,Z1,m2).call(this))},t2=new WeakSet,w2=function(){n(this,m1)&&(clearTimeout(n(this,m1)),v(this,m1,void 0))},h2=new WeakSet,B2=function(){n(this,x1)&&(clearInterval(n(this,x1)),v(this,x1,void 0))},c2=new WeakSet,I2=function(){const t=n(this,D).getQueryCache().build(n(this,D),this.options);if(t===n(this,x))return;const c=n(this,x);v(this,x,t),v(this,F1,t.state),this.hasListeners()&&(c==null||c.removeObserver(this),t.addObserver(this))},g2=new WeakSet,d0=function(t){O.batch(()=>{t.listeners&&this.listeners.forEach(c=>{c(n(this,P))}),n(this,D).getQueryCache().notify({query:n(this,x),type:"observerResultsUpdated"})})},Y2);function F0(h,t){return t.enabled!==!1&&!h.state.dataUpdatedAt&&!(h.state.status==="error"&&t.retryOnMount===!1)}function N2(h,t){return F0(h,t)||h.state.dataUpdatedAt>0&&G2(h,t,t.refetchOnMount)}function G2(h,t,c){if(t.enabled!==!1){const a=typeof c=="function"?c(h):c;return a==="always"||a!==!1&&y2(h,t)}return!1}function W2(h,t,c,a){return c.enabled!==!1&&(h!==t||a.enabled===!1)&&(!c.suspense||h.state.status!=="error")&&y2(h,c)}function y2(h,t){return h.isStaleByTime(t.staleTime)}function k0(h,t){return!e2(h.getCurrentResult(),t)}var M1,k,q,l1,T1,d2,a2,C2,X2,D0=(X2=class extends W1{constructor(t,c){super();e(this,T1);e(this,a2);e(this,M1,void 0);e(this,k,void 0);e(this,q,void 0);e(this,l1,void 0);v(this,k,void 0),v(this,M1,t),this.setOptions(c),this.bindMethods(),M(this,T1,d2).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var a;const c=this.options;this.options=n(this,M1).defaultMutationOptions(t),e2(c,this.options)||n(this,M1).getMutationCache().notify({type:"observerOptionsUpdated",mutation:n(this,q),observer:this}),(a=n(this,q))==null||a.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=n(this,q))==null||t.removeObserver(this)}onMutationUpdate(t){M(this,T1,d2).call(this),M(this,a2,C2).call(this,t)}getCurrentResult(){return n(this,k)}reset(){v(this,q,void 0),M(this,T1,d2).call(this),M(this,a2,C2).call(this)}mutate(t,c){var a;return v(this,l1,c),(a=n(this,q))==null||a.removeObserver(this),v(this,q,n(this,M1).getMutationCache().build(n(this,M1),this.options)),n(this,q).addObserver(this),n(this,q).execute(t)}},M1=new WeakMap,k=new WeakMap,q=new WeakMap,l1=new WeakMap,T1=new WeakSet,d2=function(){var c;const t=((c=n(this,q))==null?void 0:c.state)??v0();v(this,k,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},a2=new WeakSet,C2=function(t){O.batch(()=>{var c,a,l,i,r,z,s,p;n(this,l1)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((a=(c=n(this,l1)).onSuccess)==null||a.call(c,t.data,n(this,k).variables,n(this,k).context),(i=(l=n(this,l1)).onSettled)==null||i.call(l,t.data,null,n(this,k).variables,n(this,k).context)):(t==null?void 0:t.type)==="error"&&((z=(r=n(this,l1)).onError)==null||z.call(r,t.error,n(this,k).variables,n(this,k).context),(p=(s=n(this,l1)).onSettled)==null||p.call(s,void 0,t.error,n(this,k).variables,n(this,k).context))),this.listeners.forEach(o=>{o(n(this,k))})})},X2);var r0=A.createContext(void 0),W=h=>{const t=A.useContext(r0);if(h)return h;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},E0=({client:h,children:t})=>(A.useEffect(()=>(h.mount(),()=>{h.unmount()}),[h]),A.createElement(r0.Provider,{value:h},t)),e0=A.createContext(!1),T0=()=>A.useContext(e0),G4=e0.Provider;function N0(){let h=!1;return{clearReset:()=>{h=!1},reset:()=>{h=!0},isReset:()=>h}}var W0=A.createContext(N0()),j0=()=>A.useContext(W0);function o0(h,t){return typeof h=="function"?h(...t):!!h}var U0=(h,t)=>{(h.suspense||h.throwOnError)&&(t.isReset()||(h.retryOnMount=!1))},Q0=h=>{A.useEffect(()=>{h.clearReset()},[h])},K0=({result:h,errorResetBoundary:t,throwOnError:c,query:a})=>h.isError&&!t.isReset()&&!h.isFetching&&o0(c,[h.error,a]);var q0=h=>{h.suspense&&typeof h.staleTime!="number"&&(h.staleTime=1e3)};var _0=(h,t)=>(h==null?void 0:h.suspense)&&t.isPending,$0=(h,t,c)=>t.fetchOptimistic(h).catch(()=>{c.clearReset()});function J0(h,t,c){if(process.env.NODE_ENV!=="production"&&(typeof h!="object"||Array.isArray(h)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const a=W(c),l=T0(),i=j0(),r=a.defaultQueryOptions(h);r._optimisticResults=l?"isRestoring":"optimistic",q0(r),U0(r,i),Q0(i);const[z]=A.useState(()=>new t(a,r)),s=z.getOptimisticResult(r);if(A.useSyncExternalStore(A.useCallback(p=>{const o=l?()=>{}:z.subscribe(O.batchCalls(p));return z.updateResult(),o},[z,l]),()=>z.getCurrentResult(),()=>z.getCurrentResult()),A.useEffect(()=>{z.setOptions(r,{listeners:!1})},[r,z]),_0(r,s))throw $0(r,z,i);if(K0({result:s,errorResetBoundary:i,throwOnError:r.throwOnError,query:z.getCurrentQuery()}))throw s.error;return r.notifyOnChangeProps?s:z.trackResult(s)}function n2(h,t){return J0(h,R0,t)}function J(h,t){const c=W(t),[a]=A.useState(()=>new D0(c,h));A.useEffect(()=>{a.setOptions(h)},[a,h]);const l=A.useSyncExternalStore(A.useCallback(r=>a.subscribe(O.batchCalls(r)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),i=A.useCallback((r,z)=>{a.mutate(r,z).catch(Z0)},[a]);if(l.error&&o0(a.options.throwOnError,[l.error]))throw l.error;return{...l,mutate:i,mutateAsync:l.mutate}}function Z0(){}function R(){return W().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const H1=()=>{const{data:h,refetch:t}=n2({queryKey:["currentPage"],queryFn:()=>localStorage.getItem("currentPage")||""});return[h,c=>{c&&(localStorage.setItem("currentPage",c||""),t())}]};let j2="";const l2=()=>(j2=localStorage.getItem("__chai_at"),j2);function Y0(h){const t={method:"GET",headers:{"x-chai-access-token":l2()}};return fetch(h,t)}function X0(h,t){const c={method:"POST",headers:{"x-chai-access-token":l2()},body:JSON.stringify(t)};return fetch(h,c)}function t4(h,t){const c={method:"PUT",headers:{"x-chai-access-token":l2()},body:JSON.stringify(t)};return fetch(h,c)}function h4(h,t){const c={method:"DELETE",headers:{"x-chai-access-token":l2()},body:JSON.stringify(t)};return fetch(h,c)}const j={get:Y0,post:X0,put:t4,delete:h4},b2=()=>{const[h,t]=H1(),c=R();return n2({queryKey:["project"],queryFn:async()=>{const{data:a}=await j.get(`${c}/project`).then(l=>l.json());if(!h&&a){const l=localStorage.getItem("currentPage");t(l||(a==null?void 0:a.homepage))}return a}})},P2=()=>{const h=R();return n2({queryKey:["pages"],queryFn:async()=>{const{data:t}=await j.get(`${h}/pages`).then(c=>c.json());return t||[]}})},z0=()=>{const[h]=H1(),t=R();return n2({queryKey:["page_data",h],queryFn:async()=>{const{data:c}=await j.get(`${t}/page?uuid=${h}`).then(a=>a.json());return c},enabled:!!h,staleTime:3e3})},O2=()=>d.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-gray-200",children:d.jsxRuntimeExports.jsxs("div",{className:"flex flex-col h-full w-full justify-center items-center",children:[d.jsxRuntimeExports.jsxs("div",{className:"flex flex-row gap-2",children:[d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-orange-600 animate-bounce [animation-delay:.6s]"}),d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-blue-600 animate-bounce [animation-delay:.4s]"}),d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-green-600 animate-bounce [animation-delay:.2s]"}),d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-yellow-600 animate-bounce [animation-delay:.0s]"})]}),d.jsxRuntimeExports.jsx("div",{className:"text-gray-700 font-thin",children:"Loading Builder..."})]})}),g0=(h="Project updated successfully.")=>{const t=W(),c=R();return J({mutationFn:async a=>await j.put(`${c}/project`,a).then(l=>l.json()),onSuccess:()=>{t.invalidateQueries({queryKey:["project"]}),h1.toast.success(h)}})},M0=()=>{const[h]=["SAVED"],[t,c]=H1(),a=T.useBuilderReset(),{t:l}=s0.useTranslation();return i=>h!=="SAVED"?(h1.toast.error(l("You have unsaved changes. Please save before changing the page.")),!1):t===i.uuid?!1:(a(),setTimeout(()=>c(i.uuid),100),!0)},c4=()=>{const h=W(),t=M0(),c=R();return J({mutationFn:async a=>j.post(`${c}/pages`,a).then(l=>l.json()),onSuccess:a=>{h.invalidateQueries({queryKey:["pages"]}),t({uuid:a.uuid,slug:a.slug}),h1.toast.success("Page added successfully.")}})},H0=()=>{const h=R(),[t]=H1(),c=W();return J({mutationFn:async a=>j.put(`${h}/page`,a).then(l=>l.json()),onSuccess:async a=>{var l;if(a.result==="error"&&((l=a.error)==null?void 0:l.code)=="PAGE_LOCKED"){c.invalidateQueries({queryKey:["page_data",t]});return}h1.toast.success("Page saved successfully.")}})},a4=()=>{const h=R(),{data:t}=P2(),[c]=H1(),{data:a}=b2(),l=W();return J({mutationFn:async()=>{const i=t.find(r=>r.uuid===c).slug;return await j.post(`${h}/publish`,{slug:i,uuid:c,isHomepage:(a==null?void 0:a.homepage)===c}).then(r=>r.json())},onSuccess:async i=>{var r;if(i.result==="error"&&((r=i.error)==null?void 0:r.code)=="PAGE_LOCKED"){l.invalidateQueries({queryKey:["page_data",c]});return}h1.toast.success("Page published successfully.",{position:"bottom-right",duration:2e3})}})},n4=()=>{const h=W(),t=R();return J({mutationFn:async c=>j.delete(`${t}/page`,c).then(a=>a.json()),onSuccess:()=>{h1.toast.success("Page deleted successfully."),h.invalidateQueries({queryKey:["pages"]})}})},l4=()=>{const h=W(),t=R();return J({mutationFn:async c=>j.post(`${t}/take-control`,{uuid:c}).then(a=>a.json()),onSuccess:(c,a)=>{h.invalidateQueries({queryKey:["page_data",a]})}})},i4=()=>{const h=R();return J({mutationFn:async()=>{const{data:t}=await j.get(`${h}/library`).then(c=>c.json());return c1.sortBy(c1.filter(t,c=>!c1.has(c,"hidden")),"group")}})},v4=()=>{const h=R();return J({mutationFn:async t=>{if(!t||!t.uuid)return[];try{const{data:c}=await j.get(`${h}/block?uuid=${t.uuid}&format=${t.format}`).then(async a=>t.format==="html"?p0.getBlocksFromHTML(await a.text()):await a.json());return c1.set(c,"0._name",c1.capitalize(t.group)),c||[]}catch{return[]}}})},d4=()=>{const h=R();return J({mutationFn:async t=>{const c=new FormData;c.append("file",t);const{data:a}=await fetch(`${h}/upload`,{method:"POST",headers:{"x-chai-access-token":l2()},body:c}).then(l=>l.json());return a}})};function u0(h){return t0.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z"},child:[]}]})(h)}function r4(h){return t0.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"},child:[]}]})(h)}const e4=()=>{const{mutate:h,isPending:t}=l4(),[c]=H1(),{data:a}=z0(),l=c1.get(a,"lockedBy.name",""),i=c1.get(a,"lockedBy.email","");return d.jsxRuntimeExports.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg drop-shadow-2xl mx-auto p-10 space-y-4 text-center max-w-xl",children:[d.jsxRuntimeExports.jsxs("h2",{className:"text-2xl font-bold",children:["Page is ",d.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"locked"})]}),d.jsxRuntimeExports.jsxs("div",{className:"text-gray-500 dark:text-gray-400 font-light",children:["This page is currently being edited by ",d.jsxRuntimeExports.jsx("br",{}),d.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-3 w-max mx-auto font-medium text-gray-700 mt-2 text-sm",children:[d.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md",children:[d.jsxRuntimeExports.jsx(r4,{className:"w-4 h-4 text-gray-500"})," ",l]}),d.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md lowercase",children:[d.jsxRuntimeExports.jsx(u0,{className:"w-4 h-4 text-gray-500"})," ",i]})]}),d.jsxRuntimeExports.jsxs("div",{className:"pt-4",children:["If you take control, ",l," will be ",d.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"restricted"})," from making additional edits."]})]}),d.jsxRuntimeExports.jsx(T.Button,{disabled:t,onClick:()=>h(c),className:`w-36 ${t?"bg-transparent shadow-none hover:bg-transparent":""}`,children:t?d.jsxRuntimeExports.jsx(S2.Loader,{className:"text-sm animate-spin text-gray-500"}):"Take Over"})]})},o4=()=>{const h=R(),t=W();return J({mutationFn:async c=>{const a=await fetch(`${h}/login`,{method:"POST",body:JSON.stringify(c)});if(a.ok)return await a.json();throw a.status===401?new Error("Invalid login credentials"):new Error("Invalid")},onSuccess:c=>{const{data:a}=c;if(!a.accessToken){h1.toast.error("Something went wrong. Please try again.",{position:"top-center"});return}localStorage.setItem("__chai_at",a.accessToken),localStorage.setItem("__chai_ur",JSON.stringify(c1.omit(a,["accessToken"]))),t.invalidateQueries({queryKey:["verify"]}),h1.toast.success("Logged in successfully.")},onError:()=>{h1.toast.error("Invalid login credentials. Please try again.",{position:"top-center"})}})},z4=()=>{const h=R();return n2({queryKey:["verify"],queryFn:async()=>{const t=await j.get(`${h}/verify`);return t.ok?(await t.json()).result==="success"?{valid:!0}:(localStorage.removeItem("__chai_at"),{valid:!1}):(localStorage.removeItem("__chai_at"),{valid:!0})}})},g4=()=>{const h=R(),t=W();return J({mutationFn:async()=>{const{result:c}=await j.post(`${h}/logout`).then(a=>a.json());if(c==="success")return localStorage.clear(),t.invalidateQueries({queryKey:["verify"]}),{logout:!0};throw new Error("Invalid session")}})},M4=({children:h})=>{const t=g4();return d.jsxRuntimeExports.jsxs(T.AlertDialog,{children:[d.jsxRuntimeExports.jsx(T.AlertDialogTrigger,{asChild:!0,children:h}),d.jsxRuntimeExports.jsxs(T.AlertDialogContent,{children:[d.jsxRuntimeExports.jsxs(T.AlertDialogHeader,{children:[d.jsxRuntimeExports.jsxs(T.AlertDialogTitle,{children:["Are you sure, you want to ",d.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"Sign Out"}),"?"]}),d.jsxRuntimeExports.jsx(T.AlertDialogDescription,{children:"Kindly ensure that all your data is saved before proceeding with the sign-out process to prevent any potential loss of unsaved information"})]}),d.jsxRuntimeExports.jsxs(T.AlertDialogFooter,{children:[d.jsxRuntimeExports.jsx(T.AlertDialogCancel,{disabled:t.isPending,children:"Cancel"}),d.jsxRuntimeExports.jsxs("button",{disabled:t.isPending,onClick:()=>t.mutate(),className:"rounded-md text-white w-28 text-center justify-center bg-red-600 hover:bg-red-700 flex items-center gap-x-2",children:[t.isPending&&d.jsxRuntimeExports.jsx(S2.Loader2,{className:"animate-spin w-5 h-5"}),"Sign Out"]})]})]})]})},H4=()=>d.jsxRuntimeExports.jsx(M4,{children:d.jsxRuntimeExports.jsx("button",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:d.jsxRuntimeExports.jsx(S2.LogOutIcon,{className:"w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300"})})}),u4=N.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-Nr-908vy.cjs"))),s4=N.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-SuFYN60H.cjs"))),p4=N.lazy(()=>Promise.resolve().then(()=>require("./CurrentPage-sx7KVTmt.cjs"))),V4=()=>d.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),f4=()=>{const{mutate:h}=a4();return T.useBuilderProp("editable",!0)?d.jsxRuntimeExports.jsx(T.Button,{onClick:h,className:"bg-blue-600 text-white",children:"Publish"}):null},m4=h=>{var f;const{data:t,isLoading:c}=b2(),{data:a,isLoading:l}=P2(),{data:i}=z0(),{mutate:r}=g0(),{mutate:z}=H0(),[s]=H1(),p=d4(),o=i4(),L=v4(),b=R(),H=N.useCallback(async m=>await p.mutateAsync(m),[p]),V=N.useCallback(async()=>await o.mutateAsync(),[o]),B=N.useCallback(async m=>await L.mutateAsync(m),[L]),g=async(m=20,y=0)=>{const F=`limit=${m}&offset=${y}`,I=await fetch(`${b}/assets?${F}`).then(w=>w.json());return I.result==="success"?I.data:[]},{logo:u=V4}=h;if(c||!t)return d.jsxRuntimeExports.jsx(O2,{});if(l||!a)return d.jsxRuntimeExports.jsx(O2,{});const G={...h,editable:i!=null&&i.lockedBy?i==null?void 0:i.lockedBy.self:!0,nonEditableComponent:e4,blocks:(i==null?void 0:i.blocks)||[],brandingOptions:t.brandingOptions,darkMode:h.darkMode||!1,dataProviders:(i==null?void 0:i.providers)||[],onSavePage:async({blocks:m,providers:y})=>(await z({blocks:m,providers:y,uuid:s}),!0),onSaveBrandingOptions:async m=>(await r({brandingOptions:m}),!0),topBarComponents:{left:[u],center:[p4],right:[f4]},sideBarComponents:{top:[{icon:r2.FileTextIcon,name:"pages",panel:u4},{icon:r2.GearIcon,name:"settings",panel:s4},...((f=h.sideBarComponents)==null?void 0:f.top)||[]],bottom:[H4]},uploadMediaCallback:H,fetchMediaCallback:g,getUILibraryBlocks:V,getExternalPredefinedBlock:B,getPages:()=>a};return d.jsxRuntimeExports.jsx(T.ChaiBuilderEditor,{...G})},x4=({logo:h})=>{const[t,c]=N.useState(!1),[a,l]=N.useState(""),[i,r]=N.useState(""),{mutate:z,isPending:s}=o4(),p=o=>{o.preventDefault(),z({email:a,password:i})};return d.jsxRuntimeExports.jsx("section",{className:"h-screen w-screen flex items-center justify-center bg-[radial-gradient(#AAA,transparent_0.5px)] duration-300 [background-size:6px_6px]",children:d.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-xl w-96 drop-shadow-2xl duration-300",children:d.jsxRuntimeExports.jsxs("div",{className:"p-12",children:[d.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[d.jsxRuntimeExports.jsx(N.Suspense,{children:h?N.createElement(h):""}),d.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto text-base leading-relaxed text-gray-700 font-thin",children:"Enter your login credential to continue"})]}),d.jsxRuntimeExports.jsx("div",{className:"mt-8",children:d.jsxRuntimeExports.jsxs("form",{method:"POST",onSubmit:p,className:"space-y-5",children:[d.jsxRuntimeExports.jsx("div",{children:d.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[d.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:d.jsxRuntimeExports.jsx(u0,{})}),d.jsxRuntimeExports.jsx("input",{value:a,onChange:o=>l(o.target.value),type:"email",id:"email",placeholder:"Enter email",className:"block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"})]})}),d.jsxRuntimeExports.jsx("div",{children:d.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[d.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:d.jsxRuntimeExports.jsx("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:d.jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 11c0 3.517-1.009 6.799-2.753 9.571m-3.44-2.04l.054-.09A13.916 13.916 0 008 11a4 4 0 118 0c0 1.017-.07 2.019-.203 3m-2.118 6.844A21.88 21.88 0 0015.171 17m3.839 1.132c.645-2.266.99-4.659.99-7.132A8 8 0 008 4.07M3 15.364c.64-1.319 1-2.8 1-4.364 0-1.457.39-2.823 1.07-4"})})}),d.jsxRuntimeExports.jsx("input",{value:i,onChange:o=>r(o.target.value),type:t?"text":"password",id:"pwd",placeholder:"Enter password",className:"block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"}),d.jsxRuntimeExports.jsx("button",{type:"button",className:"absolute inset-y-0 right-4 flex items-center pl-3 cursor-pointer",onClick:()=>c(!t),children:t?d.jsxRuntimeExports.jsx(r2.EyeClosedIcon,{}):d.jsxRuntimeExports.jsx(r2.EyeOpenIcon,{})})]})}),d.jsxRuntimeExports.jsx("div",{children:d.jsxRuntimeExports.jsx("button",{disabled:s||c1.size(a)<2||c1.size(i)<2,type:"submit",className:"inline-flex disabled:bg-gray-400 items-center justify-center w-full px-4 py-4 text-base font-semibold text-white transition-all duration-200 bg-blue-600 border border-transparent rounded-md focus:outline-none hover:bg-blue-700 focus:bg-blue-700",children:s?"Signing in...":"Login"})})]})}),d.jsxRuntimeExports.jsx("div",{className:"mt-4 flex items-center justify-end gap-x-2 text-sm",children:d.jsxRuntimeExports.jsx("a",{href:"https://apps.chaibuilder.com/settings",target:"_blank",className:"text-gray-500 hover:text-blue-400",children:"Forget your password?"})})]})})})},L4=h=>{const{data:t,isLoading:c}=z4(),a=W();return N.useEffect(()=>{a.setQueryData(["apiBaseUrl"],h.apiBaseUrl||"/api/chaibuilder")},[h.apiBaseUrl,a]),c?d.jsxRuntimeExports.jsx(O2,{}):t!=null&&t.valid?d.jsxRuntimeExports.jsx(m4,{...h}):d.jsxRuntimeExports.jsx(x4,{logo:h.logo})},w4=new P0,B4=h=>d.jsxRuntimeExports.jsxs(E0,{client:w4,children:[d.jsxRuntimeExports.jsx(h1.Toaster,{richColors:!0}),d.jsxRuntimeExports.jsx(L4,{...h})]});exports.ChaiBuilderStudio=B4;exports.useAddPage=c4;exports.useChangePage=M0;exports.useCurrentPage=H1;exports.useDeletePage=n4;exports.usePages=P2;exports.useProject=b2;exports.useQueryClient=W;exports.useUpdatePage=H0;exports.useUpdateProject=g0;
1
+ "use strict";var H2=(h,t,c)=>{if(!t.has(h))throw TypeError("Cannot "+c)};var n=(h,t,c)=>(H2(h,t,"read from private field"),c?c.call(h):t.get(h)),e=(h,t,c)=>{if(t.has(h))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(h):t.set(h,c)},v=(h,t,c,a)=>(H2(h,t,"write to private field"),a?a.call(h,c):t.set(h,c),c);var i2=(h,t,c,a)=>({set _(l){v(h,t,l,c)},get _(){return n(h,t,a)}}),M=(h,t,c)=>(H2(h,t,"access private method"),c);const d=require("./jsx-runtime-Z_BpKhVy.cjs"),N=require("react");require("./core.cjs");const r2=require("@radix-ui/react-icons"),T=require("./ChaiBuilderEditor-aY8flOgX.cjs"),h1=require("sonner"),s0=require("react-i18next"),c1=require("lodash-es"),p0=require("./html-to-json-rauxDBi6.cjs"),S2=require("lucide-react"),t0=require("./index--mLLy7QQ.cjs");function V0(h){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const c in h)if(c!=="default"){const a=Object.getOwnPropertyDescriptor(h,c);Object.defineProperty(t,c,a.get?a:{enumerable:!0,get:()=>h[c]})}}return t.default=h,Object.freeze(t)}const A=V0(N);var W1=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(h){return this.listeners.add(h),this.onSubscribe(),()=>{this.listeners.delete(h),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},N1=typeof window>"u"||"Deno"in window;function _(){}function f0(h,t){return typeof h=="function"?h(t):h}function s2(h){return typeof h=="number"&&h>=0&&h!==1/0}function h0(h,t){return Math.max(h+(t||0)-Date.now(),0)}function R2(h,t){const{type:c="all",exact:a,fetchStatus:l,predicate:i,queryKey:r,stale:z}=h;if(r){if(a){if(t.queryHash!==A2(r,t.options))return!1}else if(!Q1(t.queryKey,r))return!1}if(c!=="all"){const s=t.isActive();if(c==="active"&&!s||c==="inactive"&&s)return!1}return!(typeof z=="boolean"&&t.isStale()!==z||typeof l<"u"&&l!==t.state.fetchStatus||i&&!i(t))}function F2(h,t){const{exact:c,status:a,predicate:l,mutationKey:i}=h;if(i){if(!t.options.mutationKey)return!1;if(c){if(U1(t.options.mutationKey)!==U1(i))return!1}else if(!Q1(t.options.mutationKey,i))return!1}return!(a&&t.state.status!==a||l&&!l(t))}function A2(h,t){return((t==null?void 0:t.queryKeyHashFn)||U1)(h)}function U1(h){return JSON.stringify(h,(t,c)=>p2(c)?Object.keys(c).sort().reduce((a,l)=>(a[l]=c[l],a),{}):c)}function Q1(h,t){return h===t?!0:typeof h!=typeof t?!1:h&&t&&typeof h=="object"&&typeof t=="object"?!Object.keys(t).some(c=>!Q1(h[c],t[c])):!1}function c0(h,t){if(h===t)return h;const c=k2(h)&&k2(t);if(c||p2(h)&&p2(t)){const a=c?h.length:Object.keys(h).length,l=c?t:Object.keys(t),i=l.length,r=c?[]:{};let z=0;for(let s=0;s<i;s++){const p=c?s:l[s];r[p]=c0(h[p],t[p]),r[p]===h[p]&&z++}return a===i&&z===a?h:r}return t}function e2(h,t){if(h&&!t||t&&!h)return!1;for(const c in h)if(h[c]!==t[c])return!1;return!0}function k2(h){return Array.isArray(h)&&h.length===Object.keys(h).length}function p2(h){if(!D2(h))return!1;const t=h.constructor;if(typeof t>"u")return!0;const c=t.prototype;return!(!D2(c)||!c.hasOwnProperty("isPrototypeOf"))}function D2(h){return Object.prototype.toString.call(h)==="[object Object]"}function a0(h){return new Promise(t=>{setTimeout(t,h)})}function E2(h){a0(0).then(h)}function V2(h,t,c){return typeof c.structuralSharing=="function"?c.structuralSharing(h,t):c.structuralSharing!==!1?c0(h,t):t}function m0(h,t,c=0){const a=[...h,t];return c&&a.length>c?a.slice(1):a}function x0(h,t,c=0){const a=[t,...h];return c&&a.length>c?a.slice(0,-1):a}var u1,v1,B1,U2,L0=(U2=class extends W1{constructor(){super();e(this,u1,void 0);e(this,v1,void 0);e(this,B1,void 0);v(this,B1,t=>{if(!N1&&window.addEventListener){const c=()=>t();return window.addEventListener("visibilitychange",c,!1),()=>{window.removeEventListener("visibilitychange",c)}}})}onSubscribe(){n(this,v1)||this.setEventListener(n(this,B1))}onUnsubscribe(){var t;this.hasListeners()||((t=n(this,v1))==null||t.call(this),v(this,v1,void 0))}setEventListener(t){var c;v(this,B1,t),(c=n(this,v1))==null||c.call(this),v(this,v1,t(a=>{typeof a=="boolean"?this.setFocused(a):this.onFocus()}))}setFocused(t){n(this,u1)!==t&&(v(this,u1,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof n(this,u1)=="boolean"?n(this,u1):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},u1=new WeakMap,v1=new WeakMap,B1=new WeakMap,U2),o2=new L0,I1,d1,G1,Q2,w0=(Q2=class extends W1{constructor(){super();e(this,I1,!0);e(this,d1,void 0);e(this,G1,void 0);v(this,G1,t=>{if(!N1&&window.addEventListener){const c=()=>t(!0),a=()=>t(!1);return window.addEventListener("online",c,!1),window.addEventListener("offline",a,!1),()=>{window.removeEventListener("online",c),window.removeEventListener("offline",a)}}})}onSubscribe(){n(this,d1)||this.setEventListener(n(this,G1))}onUnsubscribe(){var t;this.hasListeners()||((t=n(this,d1))==null||t.call(this),v(this,d1,void 0))}setEventListener(t){var c;v(this,G1,t),(c=n(this,d1))==null||c.call(this),v(this,d1,t(this.setOnline.bind(this)))}setOnline(t){n(this,I1)!==t&&(v(this,I1,t),this.listeners.forEach(a=>{a(t)}))}isOnline(){return n(this,I1)}},I1=new WeakMap,d1=new WeakMap,G1=new WeakMap,Q2),z2=new w0;function B0(h){return Math.min(1e3*2**h,3e4)}function M2(h){return(h??"online")==="online"?z2.isOnline():!0}var n0=class{constructor(h){this.revert=h==null?void 0:h.revert,this.silent=h==null?void 0:h.silent}};function u2(h){return h instanceof n0}function l0(h){let t=!1,c=0,a=!1,l,i,r;const z=new Promise((g,u)=>{i=g,r=u}),s=g=>{var u;a||(H(new n0(g)),(u=h.abort)==null||u.call(h))},p=()=>{t=!0},o=()=>{t=!1},L=()=>!o2.isFocused()||h.networkMode!=="always"&&!z2.isOnline(),b=g=>{var u;a||(a=!0,(u=h.onSuccess)==null||u.call(h,g),l==null||l(),i(g))},H=g=>{var u;a||(a=!0,(u=h.onError)==null||u.call(h,g),l==null||l(),r(g))},V=()=>new Promise(g=>{var u;l=G=>{const f=a||!L();return f&&g(G),f},(u=h.onPause)==null||u.call(h)}).then(()=>{var g;l=void 0,a||(g=h.onContinue)==null||g.call(h)}),B=()=>{if(a)return;let g;try{g=h.fn()}catch(u){g=Promise.reject(u)}Promise.resolve(g).then(b).catch(u=>{var F;if(a)return;const G=h.retry??(N1?0:3),f=h.retryDelay??B0,m=typeof f=="function"?f(c,u):f,y=G===!0||typeof G=="number"&&c<G||typeof G=="function"&&G(c,u);if(t||!y){H(u);return}c++,(F=h.onFail)==null||F.call(h,c,u),a0(m).then(()=>{if(L())return V()}).then(()=>{t?H(u):B()})})};return M2(h.networkMode)?B():V().then(B),{promise:z,cancel:s,continue:()=>(l==null?void 0:l())?z:Promise.resolve(),cancelRetry:p,continueRetry:o}}function I0(){let h=[],t=0,c=o=>{o()},a=o=>{o()};const l=o=>{let L;t++;try{L=o()}finally{t--,t||z()}return L},i=o=>{t?h.push(o):E2(()=>{c(o)})},r=o=>(...L)=>{i(()=>{o(...L)})},z=()=>{const o=h;h=[],o.length&&E2(()=>{a(()=>{o.forEach(L=>{c(L)})})})};return{batch:l,batchCalls:r,schedule:i,setNotifyFunction:o=>{c=o},setBatchNotifyFunction:o=>{a=o}}}var O=I0(),s1,K2,i0=(K2=class{constructor(){e(this,s1,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),s2(this.gcTime)&&v(this,s1,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(h){this.gcTime=Math.max(this.gcTime||0,h??(N1?1/0:5*60*1e3))}clearGcTimeout(){n(this,s1)&&(clearTimeout(n(this,s1)),v(this,s1,void 0))}},s1=new WeakMap,K2),C1,O1,U,r1,Q,S,K1,p1,S1,v2,$,n1,q2,G0=(q2=class extends i0{constructor(t){super();e(this,S1);e(this,$);e(this,C1,void 0);e(this,O1,void 0);e(this,U,void 0);e(this,r1,void 0);e(this,Q,void 0);e(this,S,void 0);e(this,K1,void 0);e(this,p1,void 0);v(this,p1,!1),v(this,K1,t.defaultOptions),M(this,S1,v2).call(this,t.options),v(this,S,[]),v(this,U,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,v(this,C1,t.state||C0(this.options)),this.state=n(this,C1),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!n(this,S).length&&this.state.fetchStatus==="idle"&&n(this,U).remove(this)}setData(t,c){const a=V2(this.state.data,t,this.options);return M(this,$,n1).call(this,{data:a,type:"success",dataUpdatedAt:c==null?void 0:c.updatedAt,manual:c==null?void 0:c.manual}),a}setState(t,c){M(this,$,n1).call(this,{type:"setState",state:t,setStateOptions:c})}cancel(t){var a;const c=n(this,r1);return(a=n(this,Q))==null||a.cancel(t),c?c.then(_).catch(_):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(n(this,C1))}isActive(){return n(this,S).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||n(this,S).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!h0(this.state.dataUpdatedAt,t)}onFocus(){var c;const t=n(this,S).find(a=>a.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(c=n(this,Q))==null||c.continue()}onOnline(){var c;const t=n(this,S).find(a=>a.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(c=n(this,Q))==null||c.continue()}addObserver(t){n(this,S).includes(t)||(n(this,S).push(t),this.clearGcTimeout(),n(this,U).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){n(this,S).includes(t)&&(v(this,S,n(this,S).filter(c=>c!==t)),n(this,S).length||(n(this,Q)&&(n(this,p1)?n(this,Q).cancel({revert:!0}):n(this,Q).cancelRetry()),this.scheduleGc()),n(this,U).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return n(this,S).length}invalidate(){this.state.isInvalidated||M(this,$,n1).call(this,{type:"invalidate"})}fetch(t,c){var p,o,L,b;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(c!=null&&c.cancelRefetch))this.cancel({silent:!0});else if(n(this,r1))return(p=n(this,Q))==null||p.continueRetry(),n(this,r1)}if(t&&M(this,S1,v2).call(this,t),!this.options.queryFn){const H=n(this,S).find(V=>V.options.queryFn);H&&M(this,S1,v2).call(this,H.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const a=new AbortController,l={queryKey:this.queryKey,meta:this.meta},i=H=>{Object.defineProperty(H,"signal",{enumerable:!0,get:()=>(v(this,p1,!0),a.signal)})};i(l);const r=()=>this.options.queryFn?(v(this,p1,!1),this.options.persister?this.options.persister(this.options.queryFn,l,this):this.options.queryFn(l)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),z={fetchOptions:c,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:r};i(z),(o=this.options.behavior)==null||o.onFetch(z,this),v(this,O1,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((L=z.fetchOptions)==null?void 0:L.meta))&&M(this,$,n1).call(this,{type:"fetch",meta:(b=z.fetchOptions)==null?void 0:b.meta});const s=H=>{var V,B,g,u;u2(H)&&H.silent||M(this,$,n1).call(this,{type:"error",error:H}),u2(H)||((B=(V=n(this,U).config).onError)==null||B.call(V,H,this),(u=(g=n(this,U).config).onSettled)==null||u.call(g,this.state.data,H,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return v(this,Q,l0({fn:z.fetchFn,abort:a.abort.bind(a),onSuccess:H=>{var V,B,g,u;if(typeof H>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),s(new Error(`${this.queryHash} data is undefined`));return}this.setData(H),(B=(V=n(this,U).config).onSuccess)==null||B.call(V,H,this),(u=(g=n(this,U).config).onSettled)==null||u.call(g,H,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:s,onFail:(H,V)=>{M(this,$,n1).call(this,{type:"failed",failureCount:H,error:V})},onPause:()=>{M(this,$,n1).call(this,{type:"pause"})},onContinue:()=>{M(this,$,n1).call(this,{type:"continue"})},retry:z.options.retry,retryDelay:z.options.retryDelay,networkMode:z.options.networkMode})),v(this,r1,n(this,Q).promise),n(this,r1)}},C1=new WeakMap,O1=new WeakMap,U=new WeakMap,r1=new WeakMap,Q=new WeakMap,S=new WeakMap,K1=new WeakMap,p1=new WeakMap,S1=new WeakSet,v2=function(t){this.options={...n(this,K1),...t},this.updateGcTime(this.options.gcTime)},$=new WeakSet,n1=function(t){const c=a=>{switch(t.type){case"failed":return{...a,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...a,fetchStatus:"paused"};case"continue":return{...a,fetchStatus:"fetching"};case"fetch":return{...a,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:M2(this.options.networkMode)?"fetching":"paused",...!a.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...a,data:t.data,dataUpdateCount:a.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const l=t.error;return u2(l)&&l.revert&&n(this,O1)?{...n(this,O1),fetchStatus:"idle"}:{...a,error:l,errorUpdateCount:a.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:a.fetchFailureCount+1,fetchFailureReason:l,fetchStatus:"idle",status:"error"};case"invalidate":return{...a,isInvalidated:!0};case"setState":return{...a,...t.state}}};this.state=c(this.state),O.batch(()=>{n(this,S).forEach(a=>{a.onQueryUpdate()}),n(this,U).notify({query:this,type:"updated",action:t})})},q2);function C0(h){const t=typeof h.initialData=="function"?h.initialData():h.initialData,c=typeof t<"u",a=c?typeof h.initialDataUpdatedAt=="function"?h.initialDataUpdatedAt():h.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:c?a??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:c?"success":"pending",fetchStatus:"idle"}}var Z,_2,O0=(_2=class extends W1{constructor(t={}){super();e(this,Z,void 0);this.config=t,v(this,Z,new Map)}build(t,c,a){const l=c.queryKey,i=c.queryHash??A2(l,c);let r=this.get(i);return r||(r=new G0({cache:this,queryKey:l,queryHash:i,options:t.defaultQueryOptions(c),state:a,defaultOptions:t.getQueryDefaults(l)}),this.add(r)),r}add(t){n(this,Z).has(t.queryHash)||(n(this,Z).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const c=n(this,Z).get(t.queryHash);c&&(t.destroy(),c===t&&n(this,Z).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){O.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return n(this,Z).get(t)}getAll(){return[...n(this,Z).values()]}find(t){const c={exact:!0,...t};return this.getAll().find(a=>R2(c,a))}findAll(t={}){const c=this.getAll();return Object.keys(t).length>0?c.filter(a=>R2(t,a)):c}notify(t){O.batch(()=>{this.listeners.forEach(c=>{c(t)})})}onFocus(){O.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){O.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Z=new WeakMap,_2),Y,q1,E,A1,X,i1,$2,S0=($2=class extends i0{constructor(t){super();e(this,X);e(this,Y,void 0);e(this,q1,void 0);e(this,E,void 0);e(this,A1,void 0);this.mutationId=t.mutationId,v(this,q1,t.defaultOptions),v(this,E,t.mutationCache),v(this,Y,[]),this.state=t.state||v0(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...n(this,q1),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){n(this,Y).includes(t)||(n(this,Y).push(t),this.clearGcTimeout(),n(this,E).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){v(this,Y,n(this,Y).filter(c=>c!==t)),this.scheduleGc(),n(this,E).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){n(this,Y).length||(this.state.status==="pending"?this.scheduleGc():n(this,E).remove(this))}continue(){var t;return((t=n(this,A1))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,i,r,z,s,p,o,L,b,H,V,B,g,u,G,f,m,y,F,I;const c=()=>(v(this,A1,l0({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(w,a1)=>{M(this,X,i1).call(this,{type:"failed",failureCount:w,error:a1})},onPause:()=>{M(this,X,i1).call(this,{type:"pause"})},onContinue:()=>{M(this,X,i1).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),n(this,A1).promise),a=this.state.status==="pending";try{if(!a){M(this,X,i1).call(this,{type:"pending",variables:t}),await((i=(l=n(this,E).config).onMutate)==null?void 0:i.call(l,t,this));const a1=await((z=(r=this.options).onMutate)==null?void 0:z.call(r,t));a1!==this.state.context&&M(this,X,i1).call(this,{type:"pending",context:a1,variables:t})}const w=await c();return await((p=(s=n(this,E).config).onSuccess)==null?void 0:p.call(s,w,t,this.state.context,this)),await((L=(o=this.options).onSuccess)==null?void 0:L.call(o,w,t,this.state.context)),await((H=(b=n(this,E).config).onSettled)==null?void 0:H.call(b,w,null,this.state.variables,this.state.context,this)),await((B=(V=this.options).onSettled)==null?void 0:B.call(V,w,null,t,this.state.context)),M(this,X,i1).call(this,{type:"success",data:w}),w}catch(w){try{throw await((u=(g=n(this,E).config).onError)==null?void 0:u.call(g,w,t,this.state.context,this)),await((f=(G=this.options).onError)==null?void 0:f.call(G,w,t,this.state.context)),await((y=(m=n(this,E).config).onSettled)==null?void 0:y.call(m,void 0,w,this.state.variables,this.state.context,this)),await((I=(F=this.options).onSettled)==null?void 0:I.call(F,void 0,w,t,this.state.context)),w}finally{M(this,X,i1).call(this,{type:"error",error:w})}}}},Y=new WeakMap,q1=new WeakMap,E=new WeakMap,A1=new WeakMap,X=new WeakSet,i1=function(t){const c=a=>{switch(t.type){case"failed":return{...a,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...a,isPaused:!0};case"continue":return{...a,isPaused:!1};case"pending":return{...a,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!M2(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...a,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...a,data:void 0,error:t.error,failureCount:a.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=c(this.state),O.batch(()=>{n(this,Y).forEach(a=>{a.onMutationUpdate(t)}),n(this,E).notify({mutation:this,type:"updated",action:t})})},$2);function v0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var K,_1,V1,J2,A0=(J2=class extends W1{constructor(t={}){super();e(this,K,void 0);e(this,_1,void 0);e(this,V1,void 0);this.config=t,v(this,K,[]),v(this,_1,0)}build(t,c,a){const l=new S0({mutationCache:this,mutationId:++i2(this,_1)._,options:t.defaultMutationOptions(c),state:a});return this.add(l),l}add(t){n(this,K).push(t),this.notify({type:"added",mutation:t})}remove(t){v(this,K,n(this,K).filter(c=>c!==t)),this.notify({type:"removed",mutation:t})}clear(){O.batch(()=>{n(this,K).forEach(t=>{this.remove(t)})})}getAll(){return n(this,K)}find(t){const c={exact:!0,...t};return n(this,K).find(a=>F2(c,a))}findAll(t={}){return n(this,K).filter(c=>F2(t,c))}notify(t){O.batch(()=>{this.listeners.forEach(c=>{c(t)})})}resumePausedMutations(){return v(this,V1,(n(this,V1)??Promise.resolve()).then(()=>{const t=n(this,K).filter(c=>c.state.isPaused);return O.batch(()=>t.reduce((c,a)=>c.then(()=>a.continue().catch(_)),Promise.resolve()))}).then(()=>{v(this,V1,void 0)})),n(this,V1)}},K=new WeakMap,_1=new WeakMap,V1=new WeakMap,J2);function y0(h){return{onFetch:(t,c)=>{const a=async()=>{var V,B,g,u,G;const l=t.options,i=(g=(B=(V=t.fetchOptions)==null?void 0:V.meta)==null?void 0:B.fetchMore)==null?void 0:g.direction,r=((u=t.state.data)==null?void 0:u.pages)||[],z=((G=t.state.data)==null?void 0:G.pageParams)||[],s={pages:[],pageParams:[]};let p=!1;const o=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(t.signal.aborted?p=!0:t.signal.addEventListener("abort",()=>{p=!0}),t.signal)})},L=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),b=async(f,m,y)=>{if(p)return Promise.reject();if(m==null&&f.pages.length)return Promise.resolve(f);const F={queryKey:t.queryKey,pageParam:m,direction:y?"backward":"forward",meta:t.options.meta};o(F);const I=await L(F),{maxPages:w}=t.options,a1=y?x0:m0;return{pages:a1(f.pages,I,w),pageParams:a1(f.pageParams,m,w)}};let H;if(i&&r.length){const f=i==="backward",m=f?b0:T2,y={pages:r,pageParams:z},F=m(l,y);H=await b(y,F,f)}else{H=await b(s,z[0]??l.initialPageParam);const f=h??r.length;for(let m=1;m<f;m++){const y=T2(l,H);H=await b(H,y)}}return H};t.options.persister?t.fetchFn=()=>{var l,i;return(i=(l=t.options).persister)==null?void 0:i.call(l,a,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},c)}:t.fetchFn=a}}}function T2(h,{pages:t,pageParams:c}){const a=t.length-1;return h.getNextPageParam(t[a],t,c[a],c)}function b0(h,{pages:t,pageParams:c}){var a;return(a=h.getPreviousPageParam)==null?void 0:a.call(h,t[0],t,c[0],c)}var C,e1,o1,y1,b1,z1,P1,R1,Z2,P0=(Z2=class{constructor(h={}){e(this,C,void 0);e(this,e1,void 0);e(this,o1,void 0);e(this,y1,void 0);e(this,b1,void 0);e(this,z1,void 0);e(this,P1,void 0);e(this,R1,void 0);v(this,C,h.queryCache||new O0),v(this,e1,h.mutationCache||new A0),v(this,o1,h.defaultOptions||{}),v(this,y1,new Map),v(this,b1,new Map),v(this,z1,0)}mount(){i2(this,z1)._++,n(this,z1)===1&&(v(this,P1,o2.subscribe(()=>{o2.isFocused()&&(this.resumePausedMutations(),n(this,C).onFocus())})),v(this,R1,z2.subscribe(()=>{z2.isOnline()&&(this.resumePausedMutations(),n(this,C).onOnline())})))}unmount(){var h,t;i2(this,z1)._--,n(this,z1)===0&&((h=n(this,P1))==null||h.call(this),v(this,P1,void 0),(t=n(this,R1))==null||t.call(this),v(this,R1,void 0))}isFetching(h){return n(this,C).findAll({...h,fetchStatus:"fetching"}).length}isMutating(h){return n(this,e1).findAll({...h,status:"pending"}).length}getQueryData(h){var t;return(t=n(this,C).find({queryKey:h}))==null?void 0:t.state.data}ensureQueryData(h){const t=this.getQueryData(h.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(h)}getQueriesData(h){return this.getQueryCache().findAll(h).map(({queryKey:t,state:c})=>{const a=c.data;return[t,a]})}setQueryData(h,t,c){const a=n(this,C).find({queryKey:h}),l=a==null?void 0:a.state.data,i=f0(t,l);if(typeof i>"u")return;const r=this.defaultQueryOptions({queryKey:h});return n(this,C).build(this,r).setData(i,{...c,manual:!0})}setQueriesData(h,t,c){return O.batch(()=>this.getQueryCache().findAll(h).map(({queryKey:a})=>[a,this.setQueryData(a,t,c)]))}getQueryState(h){var t;return(t=n(this,C).find({queryKey:h}))==null?void 0:t.state}removeQueries(h){const t=n(this,C);O.batch(()=>{t.findAll(h).forEach(c=>{t.remove(c)})})}resetQueries(h,t){const c=n(this,C),a={type:"active",...h};return O.batch(()=>(c.findAll(h).forEach(l=>{l.reset()}),this.refetchQueries(a,t)))}cancelQueries(h={},t={}){const c={revert:!0,...t},a=O.batch(()=>n(this,C).findAll(h).map(l=>l.cancel(c)));return Promise.all(a).then(_).catch(_)}invalidateQueries(h={},t={}){return O.batch(()=>{if(n(this,C).findAll(h).forEach(a=>{a.invalidate()}),h.refetchType==="none")return Promise.resolve();const c={...h,type:h.refetchType??h.type??"active"};return this.refetchQueries(c,t)})}refetchQueries(h={},t){const c={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},a=O.batch(()=>n(this,C).findAll(h).filter(l=>!l.isDisabled()).map(l=>{let i=l.fetch(void 0,c);return c.throwOnError||(i=i.catch(_)),l.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(a).then(_)}fetchQuery(h){const t=this.defaultQueryOptions(h);typeof t.retry>"u"&&(t.retry=!1);const c=n(this,C).build(this,t);return c.isStaleByTime(t.staleTime)?c.fetch(t):Promise.resolve(c.state.data)}prefetchQuery(h){return this.fetchQuery(h).then(_).catch(_)}fetchInfiniteQuery(h){return h.behavior=y0(h.pages),this.fetchQuery(h)}prefetchInfiniteQuery(h){return this.fetchInfiniteQuery(h).then(_).catch(_)}resumePausedMutations(){return n(this,e1).resumePausedMutations()}getQueryCache(){return n(this,C)}getMutationCache(){return n(this,e1)}getDefaultOptions(){return n(this,o1)}setDefaultOptions(h){v(this,o1,h)}setQueryDefaults(h,t){n(this,y1).set(U1(h),{queryKey:h,defaultOptions:t})}getQueryDefaults(h){const t=[...n(this,y1).values()];let c={};return t.forEach(a=>{Q1(h,a.queryKey)&&(c={...c,...a.defaultOptions})}),c}setMutationDefaults(h,t){n(this,b1).set(U1(h),{mutationKey:h,defaultOptions:t})}getMutationDefaults(h){const t=[...n(this,b1).values()];let c={};return t.forEach(a=>{Q1(h,a.mutationKey)&&(c={...c,...a.defaultOptions})}),c}defaultQueryOptions(h){if(h!=null&&h._defaulted)return h;const t={...n(this,o1).queries,...(h==null?void 0:h.queryKey)&&this.getQueryDefaults(h.queryKey),...h,_defaulted:!0};return t.queryHash||(t.queryHash=A2(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(h){return h!=null&&h._defaulted?h:{...n(this,o1).mutations,...(h==null?void 0:h.mutationKey)&&this.getMutationDefaults(h.mutationKey),...h,_defaulted:!0}}clear(){n(this,C).clear(),n(this,e1).clear()}},C=new WeakMap,e1=new WeakMap,o1=new WeakMap,y1=new WeakMap,b1=new WeakMap,z1=new WeakMap,P1=new WeakMap,R1=new WeakMap,Z2),D,x,F1,P,f1,k1,t1,$1,D1,E1,m1,x1,g1,L1,w1,j1,J1,f2,Z1,m2,Y1,x2,X1,L2,t2,w2,h2,B2,c2,I2,g2,d0,Y2,R0=(Y2=class extends W1{constructor(t,c){super();e(this,w1);e(this,J1);e(this,Z1);e(this,Y1);e(this,X1);e(this,t2);e(this,h2);e(this,c2);e(this,g2);e(this,D,void 0);e(this,x,void 0);e(this,F1,void 0);e(this,P,void 0);e(this,f1,void 0);e(this,k1,void 0);e(this,t1,void 0);e(this,$1,void 0);e(this,D1,void 0);e(this,E1,void 0);e(this,m1,void 0);e(this,x1,void 0);e(this,g1,void 0);e(this,L1,void 0);v(this,x,void 0),v(this,F1,void 0),v(this,P,void 0),v(this,L1,new Set),v(this,D,t),this.options=c,v(this,t1,null),this.bindMethods(),this.setOptions(c)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(n(this,x).addObserver(this),N2(n(this,x),this.options)?M(this,w1,j1).call(this):this.updateResult(),M(this,X1,L2).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return G2(n(this,x),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return G2(n(this,x),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,M(this,t2,w2).call(this),M(this,h2,B2).call(this),n(this,x).removeObserver(this)}setOptions(t,c){const a=this.options,l=n(this,x);if(this.options=n(this,D).defaultQueryOptions(t),e2(a,this.options)||n(this,D).getQueryCache().notify({type:"observerOptionsUpdated",query:n(this,x),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=a.queryKey),M(this,c2,I2).call(this);const i=this.hasListeners();i&&W2(n(this,x),l,this.options,a)&&M(this,w1,j1).call(this),this.updateResult(c),i&&(n(this,x)!==l||this.options.enabled!==a.enabled||this.options.staleTime!==a.staleTime)&&M(this,J1,f2).call(this);const r=M(this,Z1,m2).call(this);i&&(n(this,x)!==l||this.options.enabled!==a.enabled||r!==n(this,g1))&&M(this,Y1,x2).call(this,r)}getOptimisticResult(t){const c=n(this,D).getQueryCache().build(n(this,D),t),a=this.createResult(c,t);return k0(this,a)&&(v(this,P,a),v(this,k1,this.options),v(this,f1,n(this,x).state)),a}getCurrentResult(){return n(this,P)}trackResult(t){const c={};return Object.keys(t).forEach(a=>{Object.defineProperty(c,a,{configurable:!1,enumerable:!0,get:()=>(n(this,L1).add(a),t[a])})}),c}getCurrentQuery(){return n(this,x)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const c=n(this,D).defaultQueryOptions(t),a=n(this,D).getQueryCache().build(n(this,D),c);return a.isFetchingOptimistic=!0,a.fetch().then(()=>this.createResult(a,c))}fetch(t){return M(this,w1,j1).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),n(this,P)))}createResult(t,c){var F;const a=n(this,x),l=this.options,i=n(this,P),r=n(this,f1),z=n(this,k1),p=t!==a?t.state:n(this,F1),{state:o}=t;let{error:L,errorUpdatedAt:b,fetchStatus:H,status:V}=o,B=!1,g;if(c._optimisticResults){const I=this.hasListeners(),w=!I&&N2(t,c),a1=I&&W2(t,a,c,l);(w||a1)&&(H=M2(t.options.networkMode)?"fetching":"paused",o.dataUpdatedAt||(V="pending")),c._optimisticResults==="isRestoring"&&(H="idle")}if(c.select&&typeof o.data<"u")if(i&&o.data===(r==null?void 0:r.data)&&c.select===n(this,$1))g=n(this,D1);else try{v(this,$1,c.select),g=c.select(o.data),g=V2(i==null?void 0:i.data,g,c),v(this,D1,g),v(this,t1,null)}catch(I){v(this,t1,I)}else g=o.data;if(typeof c.placeholderData<"u"&&typeof g>"u"&&V==="pending"){let I;if(i!=null&&i.isPlaceholderData&&c.placeholderData===(z==null?void 0:z.placeholderData))I=i.data;else if(I=typeof c.placeholderData=="function"?c.placeholderData((F=n(this,E1))==null?void 0:F.state.data,n(this,E1)):c.placeholderData,c.select&&typeof I<"u")try{I=c.select(I),v(this,t1,null)}catch(w){v(this,t1,w)}typeof I<"u"&&(V="success",g=V2(i==null?void 0:i.data,I,c),B=!0)}n(this,t1)&&(L=n(this,t1),g=n(this,D1),b=Date.now(),V="error");const u=H==="fetching",G=V==="pending",f=V==="error",m=G&&u;return{status:V,fetchStatus:H,isPending:G,isSuccess:V==="success",isError:f,isInitialLoading:m,isLoading:m,data:g,dataUpdatedAt:o.dataUpdatedAt,error:L,errorUpdatedAt:b,failureCount:o.fetchFailureCount,failureReason:o.fetchFailureReason,errorUpdateCount:o.errorUpdateCount,isFetched:o.dataUpdateCount>0||o.errorUpdateCount>0,isFetchedAfterMount:o.dataUpdateCount>p.dataUpdateCount||o.errorUpdateCount>p.errorUpdateCount,isFetching:u,isRefetching:u&&!G,isLoadingError:f&&o.dataUpdatedAt===0,isPaused:H==="paused",isPlaceholderData:B,isRefetchError:f&&o.dataUpdatedAt!==0,isStale:y2(t,c),refetch:this.refetch}}updateResult(t){const c=n(this,P),a=this.createResult(n(this,x),this.options);if(v(this,f1,n(this,x).state),v(this,k1,this.options),n(this,f1).data!==void 0&&v(this,E1,n(this,x)),e2(a,c))return;v(this,P,a);const l={},i=()=>{if(!c)return!0;const{notifyOnChangeProps:r}=this.options,z=typeof r=="function"?r():r;if(z==="all"||!z&&!n(this,L1).size)return!0;const s=new Set(z??n(this,L1));return this.options.throwOnError&&s.add("error"),Object.keys(n(this,P)).some(p=>{const o=p;return n(this,P)[o]!==c[o]&&s.has(o)})};(t==null?void 0:t.listeners)!==!1&&i()&&(l.listeners=!0),M(this,g2,d0).call(this,{...l,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&M(this,X1,L2).call(this)}},D=new WeakMap,x=new WeakMap,F1=new WeakMap,P=new WeakMap,f1=new WeakMap,k1=new WeakMap,t1=new WeakMap,$1=new WeakMap,D1=new WeakMap,E1=new WeakMap,m1=new WeakMap,x1=new WeakMap,g1=new WeakMap,L1=new WeakMap,w1=new WeakSet,j1=function(t){M(this,c2,I2).call(this);let c=n(this,x).fetch(this.options,t);return t!=null&&t.throwOnError||(c=c.catch(_)),c},J1=new WeakSet,f2=function(){if(M(this,t2,w2).call(this),N1||n(this,P).isStale||!s2(this.options.staleTime))return;const c=h0(n(this,P).dataUpdatedAt,this.options.staleTime)+1;v(this,m1,setTimeout(()=>{n(this,P).isStale||this.updateResult()},c))},Z1=new WeakSet,m2=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(n(this,x)):this.options.refetchInterval)??!1},Y1=new WeakSet,x2=function(t){M(this,h2,B2).call(this),v(this,g1,t),!(N1||this.options.enabled===!1||!s2(n(this,g1))||n(this,g1)===0)&&v(this,x1,setInterval(()=>{(this.options.refetchIntervalInBackground||o2.isFocused())&&M(this,w1,j1).call(this)},n(this,g1)))},X1=new WeakSet,L2=function(){M(this,J1,f2).call(this),M(this,Y1,x2).call(this,M(this,Z1,m2).call(this))},t2=new WeakSet,w2=function(){n(this,m1)&&(clearTimeout(n(this,m1)),v(this,m1,void 0))},h2=new WeakSet,B2=function(){n(this,x1)&&(clearInterval(n(this,x1)),v(this,x1,void 0))},c2=new WeakSet,I2=function(){const t=n(this,D).getQueryCache().build(n(this,D),this.options);if(t===n(this,x))return;const c=n(this,x);v(this,x,t),v(this,F1,t.state),this.hasListeners()&&(c==null||c.removeObserver(this),t.addObserver(this))},g2=new WeakSet,d0=function(t){O.batch(()=>{t.listeners&&this.listeners.forEach(c=>{c(n(this,P))}),n(this,D).getQueryCache().notify({query:n(this,x),type:"observerResultsUpdated"})})},Y2);function F0(h,t){return t.enabled!==!1&&!h.state.dataUpdatedAt&&!(h.state.status==="error"&&t.retryOnMount===!1)}function N2(h,t){return F0(h,t)||h.state.dataUpdatedAt>0&&G2(h,t,t.refetchOnMount)}function G2(h,t,c){if(t.enabled!==!1){const a=typeof c=="function"?c(h):c;return a==="always"||a!==!1&&y2(h,t)}return!1}function W2(h,t,c,a){return c.enabled!==!1&&(h!==t||a.enabled===!1)&&(!c.suspense||h.state.status!=="error")&&y2(h,c)}function y2(h,t){return h.isStaleByTime(t.staleTime)}function k0(h,t){return!e2(h.getCurrentResult(),t)}var M1,k,q,l1,T1,d2,a2,C2,X2,D0=(X2=class extends W1{constructor(t,c){super();e(this,T1);e(this,a2);e(this,M1,void 0);e(this,k,void 0);e(this,q,void 0);e(this,l1,void 0);v(this,k,void 0),v(this,M1,t),this.setOptions(c),this.bindMethods(),M(this,T1,d2).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var a;const c=this.options;this.options=n(this,M1).defaultMutationOptions(t),e2(c,this.options)||n(this,M1).getMutationCache().notify({type:"observerOptionsUpdated",mutation:n(this,q),observer:this}),(a=n(this,q))==null||a.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=n(this,q))==null||t.removeObserver(this)}onMutationUpdate(t){M(this,T1,d2).call(this),M(this,a2,C2).call(this,t)}getCurrentResult(){return n(this,k)}reset(){v(this,q,void 0),M(this,T1,d2).call(this),M(this,a2,C2).call(this)}mutate(t,c){var a;return v(this,l1,c),(a=n(this,q))==null||a.removeObserver(this),v(this,q,n(this,M1).getMutationCache().build(n(this,M1),this.options)),n(this,q).addObserver(this),n(this,q).execute(t)}},M1=new WeakMap,k=new WeakMap,q=new WeakMap,l1=new WeakMap,T1=new WeakSet,d2=function(){var c;const t=((c=n(this,q))==null?void 0:c.state)??v0();v(this,k,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},a2=new WeakSet,C2=function(t){O.batch(()=>{var c,a,l,i,r,z,s,p;n(this,l1)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((a=(c=n(this,l1)).onSuccess)==null||a.call(c,t.data,n(this,k).variables,n(this,k).context),(i=(l=n(this,l1)).onSettled)==null||i.call(l,t.data,null,n(this,k).variables,n(this,k).context)):(t==null?void 0:t.type)==="error"&&((z=(r=n(this,l1)).onError)==null||z.call(r,t.error,n(this,k).variables,n(this,k).context),(p=(s=n(this,l1)).onSettled)==null||p.call(s,void 0,t.error,n(this,k).variables,n(this,k).context))),this.listeners.forEach(o=>{o(n(this,k))})})},X2);var r0=A.createContext(void 0),W=h=>{const t=A.useContext(r0);if(h)return h;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},E0=({client:h,children:t})=>(A.useEffect(()=>(h.mount(),()=>{h.unmount()}),[h]),A.createElement(r0.Provider,{value:h},t)),e0=A.createContext(!1),T0=()=>A.useContext(e0),G4=e0.Provider;function N0(){let h=!1;return{clearReset:()=>{h=!1},reset:()=>{h=!0},isReset:()=>h}}var W0=A.createContext(N0()),j0=()=>A.useContext(W0);function o0(h,t){return typeof h=="function"?h(...t):!!h}var U0=(h,t)=>{(h.suspense||h.throwOnError)&&(t.isReset()||(h.retryOnMount=!1))},Q0=h=>{A.useEffect(()=>{h.clearReset()},[h])},K0=({result:h,errorResetBoundary:t,throwOnError:c,query:a})=>h.isError&&!t.isReset()&&!h.isFetching&&o0(c,[h.error,a]);var q0=h=>{h.suspense&&typeof h.staleTime!="number"&&(h.staleTime=1e3)};var _0=(h,t)=>(h==null?void 0:h.suspense)&&t.isPending,$0=(h,t,c)=>t.fetchOptimistic(h).catch(()=>{c.clearReset()});function J0(h,t,c){if(process.env.NODE_ENV!=="production"&&(typeof h!="object"||Array.isArray(h)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const a=W(c),l=T0(),i=j0(),r=a.defaultQueryOptions(h);r._optimisticResults=l?"isRestoring":"optimistic",q0(r),U0(r,i),Q0(i);const[z]=A.useState(()=>new t(a,r)),s=z.getOptimisticResult(r);if(A.useSyncExternalStore(A.useCallback(p=>{const o=l?()=>{}:z.subscribe(O.batchCalls(p));return z.updateResult(),o},[z,l]),()=>z.getCurrentResult(),()=>z.getCurrentResult()),A.useEffect(()=>{z.setOptions(r,{listeners:!1})},[r,z]),_0(r,s))throw $0(r,z,i);if(K0({result:s,errorResetBoundary:i,throwOnError:r.throwOnError,query:z.getCurrentQuery()}))throw s.error;return r.notifyOnChangeProps?s:z.trackResult(s)}function n2(h,t){return J0(h,R0,t)}function J(h,t){const c=W(t),[a]=A.useState(()=>new D0(c,h));A.useEffect(()=>{a.setOptions(h)},[a,h]);const l=A.useSyncExternalStore(A.useCallback(r=>a.subscribe(O.batchCalls(r)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),i=A.useCallback((r,z)=>{a.mutate(r,z).catch(Z0)},[a]);if(l.error&&o0(a.options.throwOnError,[l.error]))throw l.error;return{...l,mutate:i,mutateAsync:l.mutate}}function Z0(){}function R(){return W().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const H1=()=>{const{data:h,refetch:t}=n2({queryKey:["currentPage"],queryFn:()=>localStorage.getItem("currentPage")||""});return[h,c=>{c&&(localStorage.setItem("currentPage",c||""),t())}]};let j2="";const l2=()=>(j2=localStorage.getItem("__chai_at"),j2);function Y0(h){const t={method:"GET",headers:{"x-chai-access-token":l2()}};return fetch(h,t)}function X0(h,t){const c={method:"POST",headers:{"x-chai-access-token":l2()},body:JSON.stringify(t)};return fetch(h,c)}function t4(h,t){const c={method:"PUT",headers:{"x-chai-access-token":l2()},body:JSON.stringify(t)};return fetch(h,c)}function h4(h,t){const c={method:"DELETE",headers:{"x-chai-access-token":l2()},body:JSON.stringify(t)};return fetch(h,c)}const j={get:Y0,post:X0,put:t4,delete:h4},b2=()=>{const[h,t]=H1(),c=R();return n2({queryKey:["project"],queryFn:async()=>{const{data:a}=await j.get(`${c}/project`).then(l=>l.json());if(!h&&a){const l=localStorage.getItem("currentPage");t(l||(a==null?void 0:a.homepage))}return a}})},P2=()=>{const h=R();return n2({queryKey:["pages"],queryFn:async()=>{const{data:t}=await j.get(`${h}/pages`).then(c=>c.json());return t||[]}})},z0=()=>{const[h]=H1(),t=R();return n2({queryKey:["page_data",h],queryFn:async()=>{const{data:c}=await j.get(`${t}/page?uuid=${h}`).then(a=>a.json());return c},enabled:!!h,staleTime:3e3})},O2=()=>d.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-gray-200",children:d.jsxRuntimeExports.jsxs("div",{className:"flex flex-col h-full w-full justify-center items-center",children:[d.jsxRuntimeExports.jsxs("div",{className:"flex flex-row gap-2",children:[d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-orange-600 animate-bounce [animation-delay:.6s]"}),d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-blue-600 animate-bounce [animation-delay:.4s]"}),d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-green-600 animate-bounce [animation-delay:.2s]"}),d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-yellow-600 animate-bounce [animation-delay:.0s]"})]}),d.jsxRuntimeExports.jsx("div",{className:"text-gray-700 font-thin",children:"Loading Builder..."})]})}),g0=(h="Project updated successfully.")=>{const t=W(),c=R();return J({mutationFn:async a=>await j.put(`${c}/project`,a).then(l=>l.json()),onSuccess:()=>{t.invalidateQueries({queryKey:["project"]}),h1.toast.success(h)}})},M0=()=>{const[h]=["SAVED"],[t,c]=H1(),a=T.useBuilderReset(),{t:l}=s0.useTranslation();return i=>h!=="SAVED"?(h1.toast.error(l("You have unsaved changes. Please save before changing the page.")),!1):t===i.uuid?!1:(a(),setTimeout(()=>c(i.uuid),100),!0)},c4=()=>{const h=W(),t=M0(),c=R();return J({mutationFn:async a=>j.post(`${c}/pages`,a).then(l=>l.json()),onSuccess:a=>{h.invalidateQueries({queryKey:["pages"]}),t({uuid:a.uuid,slug:a.slug}),h1.toast.success("Page added successfully.")}})},H0=()=>{const h=R(),[t]=H1(),c=W();return J({mutationFn:async a=>j.put(`${h}/page`,a).then(l=>l.json()),onSuccess:async a=>{var l;if(a.result==="error"&&((l=a.error)==null?void 0:l.code)=="PAGE_LOCKED"){c.invalidateQueries({queryKey:["page_data",t]});return}h1.toast.success("Page saved successfully.")}})},a4=()=>{const h=R(),{data:t}=P2(),[c]=H1(),{data:a}=b2(),l=W();return J({mutationFn:async()=>{const i=t.find(r=>r.uuid===c).slug;return await j.post(`${h}/publish`,{slug:i,uuid:c,isHomepage:(a==null?void 0:a.homepage)===c}).then(r=>r.json())},onSuccess:async i=>{var r;if(i.result==="error"&&((r=i.error)==null?void 0:r.code)=="PAGE_LOCKED"){l.invalidateQueries({queryKey:["page_data",c]});return}h1.toast.success("Page published successfully.",{position:"bottom-right",duration:2e3})}})},n4=()=>{const h=W(),t=R();return J({mutationFn:async c=>j.delete(`${t}/page`,c).then(a=>a.json()),onSuccess:()=>{h1.toast.success("Page deleted successfully."),h.invalidateQueries({queryKey:["pages"]})}})},l4=()=>{const h=W(),t=R();return J({mutationFn:async c=>j.post(`${t}/take-control`,{uuid:c}).then(a=>a.json()),onSuccess:(c,a)=>{h.invalidateQueries({queryKey:["page_data",a]})}})},i4=()=>{const h=R();return J({mutationFn:async()=>{const{data:t}=await j.get(`${h}/library`).then(c=>c.json());return c1.sortBy(c1.filter(t,c=>!c1.has(c,"hidden")),"group")}})},v4=()=>{const h=R();return J({mutationFn:async t=>{if(!t||!t.uuid)return[];try{const{data:c}=await j.get(`${h}/block?uuid=${t.uuid}&format=${t.format}`).then(async a=>t.format==="html"?p0.getBlocksFromHTML(await a.text()):await a.json());return c1.set(c,"0._name",c1.capitalize(t.group)),c||[]}catch{return[]}}})},d4=()=>{const h=R();return J({mutationFn:async t=>{const c=new FormData;c.append("file",t);const{data:a}=await fetch(`${h}/upload`,{method:"POST",headers:{"x-chai-access-token":l2()},body:c}).then(l=>l.json());return a}})};function u0(h){return t0.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z"},child:[]}]})(h)}function r4(h){return t0.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"},child:[]}]})(h)}const e4=()=>{const{mutate:h,isPending:t}=l4(),[c]=H1(),{data:a}=z0(),l=c1.get(a,"lockedBy.name",""),i=c1.get(a,"lockedBy.email","");return d.jsxRuntimeExports.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg drop-shadow-2xl mx-auto p-10 space-y-4 text-center max-w-xl",children:[d.jsxRuntimeExports.jsxs("h2",{className:"text-2xl font-bold",children:["Page is ",d.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"locked"})]}),d.jsxRuntimeExports.jsxs("div",{className:"text-gray-500 dark:text-gray-400 font-light",children:["This page is currently being edited by ",d.jsxRuntimeExports.jsx("br",{}),d.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-3 w-max mx-auto font-medium text-gray-700 mt-2 text-sm",children:[d.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md",children:[d.jsxRuntimeExports.jsx(r4,{className:"w-4 h-4 text-gray-500"})," ",l]}),d.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md lowercase",children:[d.jsxRuntimeExports.jsx(u0,{className:"w-4 h-4 text-gray-500"})," ",i]})]}),d.jsxRuntimeExports.jsxs("div",{className:"pt-4",children:["If you take control, ",l," will be ",d.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"restricted"})," from making additional edits."]})]}),d.jsxRuntimeExports.jsx(T.Button,{disabled:t,onClick:()=>h(c),className:`w-36 ${t?"bg-transparent shadow-none hover:bg-transparent":""}`,children:t?d.jsxRuntimeExports.jsx(S2.Loader,{className:"text-sm animate-spin text-gray-500"}):"Take Over"})]})},o4=()=>{const h=R(),t=W();return J({mutationFn:async c=>{const a=await fetch(`${h}/login`,{method:"POST",body:JSON.stringify(c)});if(a.ok)return await a.json();throw a.status===401?new Error("Invalid login credentials"):new Error("Invalid")},onSuccess:c=>{const{data:a}=c;if(!a.accessToken){h1.toast.error("Something went wrong. Please try again.",{position:"top-center"});return}localStorage.setItem("__chai_at",a.accessToken),localStorage.setItem("__chai_ur",JSON.stringify(c1.omit(a,["accessToken"]))),t.invalidateQueries({queryKey:["verify"]}),h1.toast.success("Logged in successfully.")},onError:()=>{h1.toast.error("Invalid login credentials. Please try again.",{position:"top-center"})}})},z4=()=>{const h=R();return n2({queryKey:["verify"],queryFn:async()=>{const t=await j.get(`${h}/verify`);return t.ok?(await t.json()).result==="success"?{valid:!0}:(localStorage.removeItem("__chai_at"),{valid:!1}):(localStorage.removeItem("__chai_at"),{valid:!0})}})},g4=()=>{const h=R(),t=W();return J({mutationFn:async()=>{const{result:c}=await j.post(`${h}/logout`).then(a=>a.json());if(c==="success")return localStorage.clear(),t.invalidateQueries({queryKey:["verify"]}),{logout:!0};throw new Error("Invalid session")}})},M4=({children:h})=>{const t=g4();return d.jsxRuntimeExports.jsxs(T.AlertDialog,{children:[d.jsxRuntimeExports.jsx(T.AlertDialogTrigger,{asChild:!0,children:h}),d.jsxRuntimeExports.jsxs(T.AlertDialogContent,{children:[d.jsxRuntimeExports.jsxs(T.AlertDialogHeader,{children:[d.jsxRuntimeExports.jsxs(T.AlertDialogTitle,{children:["Are you sure, you want to ",d.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"Sign Out"}),"?"]}),d.jsxRuntimeExports.jsx(T.AlertDialogDescription,{children:"Kindly ensure that all your data is saved before proceeding with the sign-out process to prevent any potential loss of unsaved information"})]}),d.jsxRuntimeExports.jsxs(T.AlertDialogFooter,{children:[d.jsxRuntimeExports.jsx(T.AlertDialogCancel,{disabled:t.isPending,children:"Cancel"}),d.jsxRuntimeExports.jsxs("button",{disabled:t.isPending,onClick:()=>t.mutate(),className:"rounded-md text-white w-28 text-center justify-center bg-red-600 hover:bg-red-700 flex items-center gap-x-2",children:[t.isPending&&d.jsxRuntimeExports.jsx(S2.Loader2,{className:"animate-spin w-5 h-5"}),"Sign Out"]})]})]})]})},H4=()=>d.jsxRuntimeExports.jsx(M4,{children:d.jsxRuntimeExports.jsx("button",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:d.jsxRuntimeExports.jsx(S2.LogOutIcon,{className:"w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300"})})}),u4=N.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-lIC3kYmS.cjs"))),s4=N.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-0Siyi5YS.cjs"))),p4=N.lazy(()=>Promise.resolve().then(()=>require("./CurrentPage-PjrVzHXR.cjs"))),V4=()=>d.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),f4=()=>{const{mutate:h}=a4();return T.useBuilderProp("editable",!0)?d.jsxRuntimeExports.jsx(T.Button,{onClick:h,className:"bg-blue-600 text-white",children:"Publish"}):null},m4=h=>{var f;const{data:t,isLoading:c}=b2(),{data:a,isLoading:l}=P2(),{data:i}=z0(),{mutate:r}=g0(),{mutate:z}=H0(),[s]=H1(),p=d4(),o=i4(),L=v4(),b=R(),H=N.useCallback(async m=>await p.mutateAsync(m),[p]),V=N.useCallback(async()=>await o.mutateAsync(),[o]),B=N.useCallback(async m=>await L.mutateAsync(m),[L]),g=async(m=20,y=0)=>{const F=`limit=${m}&offset=${y}`,I=await fetch(`${b}/assets?${F}`).then(w=>w.json());return I.result==="success"?I.data:[]},{logo:u=V4}=h;if(c||!t)return d.jsxRuntimeExports.jsx(O2,{});if(l||!a)return d.jsxRuntimeExports.jsx(O2,{});const G={...h,editable:i!=null&&i.lockedBy?i==null?void 0:i.lockedBy.self:!0,nonEditableComponent:e4,blocks:(i==null?void 0:i.blocks)||[],brandingOptions:t.brandingOptions,darkMode:h.darkMode||!1,dataProviders:(i==null?void 0:i.providers)||[],onSavePage:async({blocks:m,providers:y})=>(await z({blocks:m,providers:y,uuid:s}),!0),onSaveBrandingOptions:async m=>(await r({brandingOptions:m}),!0),topBarComponents:{left:[u],center:[p4],right:[f4]},sideBarComponents:{top:[{icon:r2.FileTextIcon,name:"pages",panel:u4},{icon:r2.GearIcon,name:"settings",panel:s4},...((f=h.sideBarComponents)==null?void 0:f.top)||[]],bottom:[H4]},uploadMediaCallback:H,fetchMediaCallback:g,getUILibraryBlocks:V,getExternalPredefinedBlock:B,getPages:()=>a};return d.jsxRuntimeExports.jsx(T.ChaiBuilderEditor,{...G})},x4=({logo:h})=>{const[t,c]=N.useState(!1),[a,l]=N.useState(""),[i,r]=N.useState(""),{mutate:z,isPending:s}=o4(),p=o=>{o.preventDefault(),z({email:a,password:i})};return d.jsxRuntimeExports.jsx("section",{className:"h-screen w-screen flex items-center justify-center bg-[radial-gradient(#AAA,transparent_0.5px)] duration-300 [background-size:6px_6px]",children:d.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-xl w-96 drop-shadow-2xl duration-300",children:d.jsxRuntimeExports.jsxs("div",{className:"p-12",children:[d.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[d.jsxRuntimeExports.jsx(N.Suspense,{children:h?N.createElement(h):""}),d.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto text-base leading-relaxed text-gray-700 font-thin",children:"Enter your login credential to continue"})]}),d.jsxRuntimeExports.jsx("div",{className:"mt-8",children:d.jsxRuntimeExports.jsxs("form",{method:"POST",onSubmit:p,className:"space-y-5",children:[d.jsxRuntimeExports.jsx("div",{children:d.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[d.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:d.jsxRuntimeExports.jsx(u0,{})}),d.jsxRuntimeExports.jsx("input",{value:a,onChange:o=>l(o.target.value),type:"email",id:"email",placeholder:"Enter email",className:"block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"})]})}),d.jsxRuntimeExports.jsx("div",{children:d.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[d.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:d.jsxRuntimeExports.jsx("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:d.jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 11c0 3.517-1.009 6.799-2.753 9.571m-3.44-2.04l.054-.09A13.916 13.916 0 008 11a4 4 0 118 0c0 1.017-.07 2.019-.203 3m-2.118 6.844A21.88 21.88 0 0015.171 17m3.839 1.132c.645-2.266.99-4.659.99-7.132A8 8 0 008 4.07M3 15.364c.64-1.319 1-2.8 1-4.364 0-1.457.39-2.823 1.07-4"})})}),d.jsxRuntimeExports.jsx("input",{value:i,onChange:o=>r(o.target.value),type:t?"text":"password",id:"pwd",placeholder:"Enter password",className:"block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"}),d.jsxRuntimeExports.jsx("button",{type:"button",className:"absolute inset-y-0 right-4 flex items-center pl-3 cursor-pointer",onClick:()=>c(!t),children:t?d.jsxRuntimeExports.jsx(r2.EyeClosedIcon,{}):d.jsxRuntimeExports.jsx(r2.EyeOpenIcon,{})})]})}),d.jsxRuntimeExports.jsx("div",{children:d.jsxRuntimeExports.jsx("button",{disabled:s||c1.size(a)<2||c1.size(i)<2,type:"submit",className:"inline-flex disabled:bg-gray-400 items-center justify-center w-full px-4 py-4 text-base font-semibold text-white transition-all duration-200 bg-blue-600 border border-transparent rounded-md focus:outline-none hover:bg-blue-700 focus:bg-blue-700",children:s?"Signing in...":"Login"})})]})}),d.jsxRuntimeExports.jsx("div",{className:"mt-4 flex items-center justify-end gap-x-2 text-sm",children:d.jsxRuntimeExports.jsx("a",{href:"https://apps.chaibuilder.com/settings",target:"_blank",className:"text-gray-500 hover:text-blue-400",children:"Forget your password?"})})]})})})},L4=h=>{const{data:t,isLoading:c}=z4(),a=W();return N.useEffect(()=>{a.setQueryData(["apiBaseUrl"],h.apiBaseUrl||"/api/chaibuilder")},[h.apiBaseUrl,a]),c?d.jsxRuntimeExports.jsx(O2,{}):t!=null&&t.valid?d.jsxRuntimeExports.jsx(m4,{...h}):d.jsxRuntimeExports.jsx(x4,{logo:h.logo})},w4=new P0,B4=h=>d.jsxRuntimeExports.jsxs(E0,{client:w4,children:[d.jsxRuntimeExports.jsx(h1.Toaster,{richColors:!0}),d.jsxRuntimeExports.jsx(L4,{...h})]});exports.ChaiBuilderStudio=B4;exports.useAddPage=c4;exports.useChangePage=M0;exports.useCurrentPage=H1;exports.useDeletePage=n4;exports.usePages=P2;exports.useProject=b2;exports.useQueryClient=W;exports.useUpdatePage=H0;exports.useUpdateProject=g0;
@@ -20,11 +20,11 @@ import * as b from "react";
20
20
  import H0, { lazy as A2, useCallback as g2, useState as o2, Suspense as u0, useEffect as s0 } from "react";
21
21
  import "./core.js";
22
22
  import { FileTextIcon as p0, GearIcon as V0, EyeClosedIcon as f0, EyeOpenIcon as m0 } from "@radix-ui/react-icons";
23
- import { u as L0, B as Y2, A as x0, a as w0, b as B0, c as C0, d as O0, e as A0, f as S0, g as y0, h as b0, C as P0 } from "./ChaiBuilderEditor-bNZZWYMh.js";
23
+ import { u as L0, B as Y2, A as x0, a as w0, b as B0, c as C0, d as O0, e as A0, f as S0, g as y0, h as b0, C as P0 } from "./ChaiBuilderEditor-tkzS851D.js";
24
24
  import { toast as a1, Toaster as F0 } from "sonner";
25
25
  import { useTranslation as k0 } from "react-i18next";
26
26
  import { sortBy as R0, filter as D0, has as T0, set as E0, capitalize as N0, get as b2, omit as I0, size as P2 } from "lodash-es";
27
- import { g as W0 } from "./html-to-json-ofq1N3tB.js";
27
+ import { g as W0 } from "./html-to-json-OnIZDDXw.js";
28
28
  import { Loader as U0, Loader2 as j0, LogOutIcon as Q0 } from "lucide-react";
29
29
  import { G as X2 } from "./index-VBXQixVm.js";
30
30
  var N1 = class {
@@ -2044,7 +2044,7 @@ const D4 = () => {
2044
2044
  ] })
2045
2045
  ] })
2046
2046
  ] });
2047
- }, W4 = () => /* @__PURE__ */ r.jsx(I4, { children: /* @__PURE__ */ r.jsx("button", { className: "border-gray-200 rounded-md p-2 mb-2 border", children: /* @__PURE__ */ r.jsx(Q0, { className: "w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300" }) }) }), U4 = A2(() => import("./PagesPanel-XiTUaiq_.js")), j4 = A2(() => import("./ProjectPanel-XfknsGkz.js")), Q4 = A2(() => import("./CurrentPage-7NM90y76.js")), K4 = () => /* @__PURE__ */ r.jsx("h2", { children: "Your Logo" }), G4 = () => {
2047
+ }, W4 = () => /* @__PURE__ */ r.jsx(I4, { children: /* @__PURE__ */ r.jsx("button", { className: "border-gray-200 rounded-md p-2 mb-2 border", children: /* @__PURE__ */ r.jsx(Q0, { className: "w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300" }) }) }), U4 = A2(() => import("./PagesPanel-RYBf0Yct.js")), j4 = A2(() => import("./ProjectPanel-Zagx6l3Q.js")), Q4 = A2(() => import("./CurrentPage-IrFGAb7n.js")), K4 = () => /* @__PURE__ */ r.jsx("h2", { children: "Your Logo" }), G4 = () => {
2048
2048
  const { mutate: h } = y4();
2049
2049
  return b0("editable", !0) ? /* @__PURE__ */ r.jsx(Y2, { onClick: h, className: "bg-blue-600 text-white", children: "Publish" }) : null;
2050
2050
  }, q4 = (h) => {