@chaibuilder/pages 0.15.22 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/{2AITGKQY-BQI4o1xG.js → 2AITGKQY-BFankGad.js} +2 -2
  2. package/dist/{2AITGKQY-DXm3iqhg.cjs → 2AITGKQY-BxEty5Ow.cjs} +1 -1
  3. package/dist/{NCMVHL6D-B3kd8MpE.js → NCMVHL6D-DFMKkQPN.js} +4 -4
  4. package/dist/{NCMVHL6D-C0TW9XJH.cjs → NCMVHL6D-DP-qw6yT.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-DzyqbIEt.cjs → ZDWCUMSJ-Cu1VTliO.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-IN3g-SXd.js → ZDWCUMSJ-DU81uAQq.js} +1 -1
  7. package/dist/{add-new-language-page-NXyJYXG-.js → add-new-language-page-0zC1CJZK.js} +2 -2
  8. package/dist/{add-new-language-page-zZoQgh6M.cjs → add-new-language-page-DQ46xqnc.cjs} +1 -1
  9. package/dist/{add-new-page-C7Kw3sZO.js → add-new-page-CUtZhDvi.js} +1 -1
  10. package/dist/{add-new-page-Cf_zoJPL.cjs → add-new-page-Ca2H2J-2.cjs} +1 -1
  11. package/dist/ai-panel-content-CV-HTsAs.cjs +1 -0
  12. package/dist/ai-panel-content-r2jlUBoR.js +52 -0
  13. package/dist/ai-panel-default-lang-D6RAQW1X.js +173 -0
  14. package/dist/ai-panel-default-lang-EH3w6g25.cjs +1 -0
  15. package/dist/ai-panel-message-bubble-Bl-aUeU4.cjs +1 -0
  16. package/dist/ai-panel-message-bubble-DPAaAMAZ.js +38 -0
  17. package/dist/ai-panel-other-lang-BeTdv7yM.js +133 -0
  18. package/dist/ai-panel-other-lang-_gGQTjZQ.cjs +1 -0
  19. package/dist/ai-panel-quick-prompts-CpzN48cl.js +46 -0
  20. package/dist/ai-panel-quick-prompts-DiNVPPAn.cjs +1 -0
  21. package/dist/ai-prompt-input-D-F23bdc.cjs +1 -0
  22. package/dist/ai-prompt-input-vAcIZSB1.js +133 -0
  23. package/dist/ai-translation-prompt-AImJlmDg.cjs +1 -0
  24. package/dist/ai-translation-prompt-BKyp1IW2.js +63 -0
  25. package/dist/{delete-page-CyqJ6iqb.js → delete-page-BS10zPLU.js} +1 -1
  26. package/dist/{delete-page-qrzBuLu5.cjs → delete-page-ClgtvB6n.cjs} +1 -1
  27. package/dist/{digital-asset-manager-BxM02CBp.js → digital-asset-manager-D_FFLECK.js} +1 -1
  28. package/dist/{digital-asset-manager-BfDE0iUu.cjs → digital-asset-manager-MK8ZL6Nd.cjs} +1 -1
  29. package/dist/{duplicate-page-CGKrJ-pm.cjs → duplicate-page-BaZrekqu.cjs} +1 -1
  30. package/dist/{duplicate-page-BGXDNCfU.js → duplicate-page-C1r4cCIJ.js} +9 -9
  31. package/dist/{dynamic-page-selector-C1ENQo3c.cjs → dynamic-page-selector-C4R_vhhz.cjs} +1 -1
  32. package/dist/{dynamic-page-selector-D0H0U30o.js → dynamic-page-selector-CjtnFkxO.js} +1 -1
  33. package/dist/index-C64wG61b.cjs +5 -0
  34. package/dist/{index-D2g32O6h.js → index-D_qadcqD.js} +869 -862
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.d.ts +5 -3
  37. package/dist/index.js +7 -7
  38. package/dist/{json-diff-viewer-XF3MMhkA.js → json-diff-viewer-BURQmaIL.js} +1 -1
  39. package/dist/{json-diff-viewer-D03TdwEh.cjs → json-diff-viewer-CyZVbnpL.cjs} +1 -1
  40. package/dist/{lang-panel-8pMYi4Fn.js → lang-panel-C8yx7PSU.js} +33 -33
  41. package/dist/{lang-panel-BQiWaq2_.cjs → lang-panel-SUARS5YU.cjs} +1 -1
  42. package/dist/{mark-as-template-BGe_QmNY.js → mark-as-template-CUHypMlj.js} +1 -1
  43. package/dist/{mark-as-template-DwgrP1Vj.cjs → mark-as-template-DS-nfI06.cjs} +1 -1
  44. package/dist/{no-language-page-content-BiiD91y6.cjs → no-language-page-content-DZj3cmtM.cjs} +1 -1
  45. package/dist/{no-language-page-content-Cr6wq4o8.js → no-language-page-content-qoHrlxwD.js} +1 -1
  46. package/dist/{page-creator-PSrGtRIm.js → page-creator-C8VQGfap.js} +2 -2
  47. package/dist/{page-creator-Di9A1gxS.cjs → page-creator-HwE9ST54.cjs} +1 -1
  48. package/dist/{page-lock-request-DQT5Ur0g.js → page-lock-request-CBVKtxVj.js} +10 -10
  49. package/dist/{page-lock-request-Reyb6vZo.cjs → page-lock-request-Db7-x_EI.cjs} +1 -1
  50. package/dist/{page-locked-by-dialog-DF1_jPao.cjs → page-locked-by-dialog-CvRDaBcN.cjs} +1 -1
  51. package/dist/{page-locked-by-dialog-DgIr4-Gd.js → page-locked-by-dialog-DEC58QPA.js} +1 -1
  52. package/dist/{page-manager-new-BuLz6042.js → page-manager-new-B1PDwz2w.js} +67 -67
  53. package/dist/{page-manager-new-COui-em5.cjs → page-manager-new-CBxSkcYY.cjs} +1 -1
  54. package/dist/{page-manager-search-and-filter-DxqVJw_A.js → page-manager-search-and-filter-0eTSE1C1.js} +1 -1
  55. package/dist/{page-manager-search-and-filter-6_CVqZc_.cjs → page-manager-search-and-filter-BRLPHE64.cjs} +1 -1
  56. package/dist/{page-revisions-content-DagDCr7w.js → page-revisions-content-CKcp4He4.js} +10 -10
  57. package/dist/{page-revisions-content-BlM1X20k.cjs → page-revisions-content-CTrVTQ_s.cjs} +1 -1
  58. package/dist/prompt-helper-BtijECyh.cjs +51 -0
  59. package/dist/prompt-helper-CfyAlam9.js +175 -0
  60. package/dist/{publish-pages-content-6L8onxVt.cjs → publish-pages-content-B6HGaUtO.cjs} +1 -1
  61. package/dist/{publish-pages-content-eAcMLyLi.js → publish-pages-content-BMaeNHV2.js} +2 -2
  62. package/dist/{save-to-lib-BUen2a0-.cjs → save-to-lib-BKKTPv4h.cjs} +1 -1
  63. package/dist/{save-to-lib-C43iGfOH.js → save-to-lib-CccnzwO8.js} +1 -1
  64. package/dist/{seo-panel-DdE8DfMt.js → seo-panel-4KK4r-BP.js} +1 -1
  65. package/dist/{seo-panel-BseSTxFf.cjs → seo-panel-DL_rcWwC.cjs} +1 -1
  66. package/dist/server.cjs +238 -1
  67. package/dist/server.d.ts +50 -6
  68. package/dist/server.js +10324 -290
  69. package/dist/{shared-json-ld-D-S-SwbU.cjs → shared-json-ld-BuYzbmKx.cjs} +1 -1
  70. package/dist/{shared-json-ld-OwSauSop.js → shared-json-ld-DGW40Ccy.js} +41 -41
  71. package/dist/{slug-input-DYne39yC.cjs → slug-input--8SgDwYu.cjs} +1 -1
  72. package/dist/{slug-input-Bh4d19p2.js → slug-input-DH5w0H22.js} +1 -1
  73. package/dist/{theme-panel-footer-BnxQBiM2.js → theme-panel-footer-CHR7J97n.js} +1 -1
  74. package/dist/{theme-panel-footer-DLSf7QAN.cjs → theme-panel-footer-Co5VI_i9.cjs} +1 -1
  75. package/dist/{unmark-as-template-BTY-g4LE.cjs → unmark-as-template-B3h10oHA.cjs} +1 -1
  76. package/dist/{unmark-as-template-B9xuxdYK.js → unmark-as-template-DlA879QF.js} +1 -1
  77. package/dist/{unpublish-page-D0FunHFp.cjs → unpublish-page-Bfo_DuW5.cjs} +1 -1
  78. package/dist/{unpublish-page-CYmJyQH9.js → unpublish-page-JzGl35pF.js} +1 -1
  79. package/dist/{web-preview-y7dB2S91.js → web-preview-CJ6JyhJD.js} +1 -1
  80. package/dist/{web-preview-DDnJlhVc.cjs → web-preview-oG2epixb.cjs} +1 -1
  81. package/package.json +12 -12
  82. package/dist/ai-panel-content-BXnMSm-N.js +0 -614
  83. package/dist/ai-panel-content-xcOgRnxG.cjs +0 -142
  84. package/dist/index-CZxeSGRk.cjs +0 -5
@@ -1,142 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("@chaibuilder/sdk"),Z=require("@chaibuilder/sdk/ui"),C=require("lodash-es"),b=require("lucide-react"),m=require("react"),Y=require("sonner"),ee=require("./index-CZxeSGRk.cjs"),V=["Box","Button","Heading","Paragraph","Text","Span","Link","Image","Video","Icon","List","ListItem","Row","Column","Form","Input","FormButton","Checkbox","Radio","Select","TextArea","Label","RichText","Divider","EmptyBox","LineBreak","Table","EmptySlot"];function te(r){if(!r)return"";let t=r.trim();return t=t.replace(/^```html\n?/i,""),t=t.replace(/^```\n?/,""),t=t.replace(/\n?```$/,""),t=t.trim(),t}function re(r){if(!r)return"";const t=te(r);return t.length===0||!t.includes("<")||!t.includes(">")?"":t}const ne=r=>{const t=document.getElementById("canvas-iframe");if(!t)return null;const n=t==null?void 0:t.contentDocument;if(!n)return null;const l=n.querySelector(`[data-block-id="${r}"]`);return l||null},se=(r,t)=>{var v;const n=ne(r);if(!n)return{position:0,currentHTML:""};n.style.opacity="0.4";const l=((v=n==null?void 0:n.parentNode)==null?void 0:v.childNodes)||[],o=Array.from(l).indexOf(n),p=n.outerHTML,d=new DOMParser().parseFromString(p,"text/html");return d.querySelectorAll("[data-block-id]").forEach(a=>{const w=a.getAttribute("data-block-id"),c=C.find(t,{_id:w}),E=c==null?void 0:c._type;if(V.includes(E)){const u=JSON.stringify(c);if(u!=null&&u.includes("{{")&&(u!=null&&u.includes("}}"))){const T=Object.keys(c).filter(A=>{const s=c[A],f=typeof s=="string"?s:JSON.stringify(s);return f.includes("{{")&&f.includes("}}")});T.length>0&&(a.setAttribute("data-binding-key",T[0]),a.innerHTML=C.get(c,T[0],""))}a.removeAttribute("data-block-type"),a.removeAttribute("data-style-prop"),a.removeAttribute("data-block-parent"),a.removeAttribute("data-style-id"),a.removeAttribute("data-block-id"),a.removeAttribute("data-block-index"),a.removeAttribute("data-highlighted")}else a.innerHTML=E}),{position:o,currentHTML:d.body.innerHTML}};function $(){return`You are an expert HTML/CSS developer specializing in Tailwind CSS and shadcn/ui design patterns.
2
-
3
- Create pure HTML code only. Make it fully responsive using Tailwind CSS v3 classes exclusively - no custom CSS or classes allowed. Implement container queries (@container) where appropriate for enhanced responsive behavior.
4
-
5
- ### CRITICAL REQUIREMENTS:
6
- 1. Return ONLY the HTML code without any markdown formatting, code blocks, or explanations
7
- 2. Use ONLY Tailwind CSS v3+ utility classes - absolutely no custom CSS or classes
8
- 3. Use shadcn/ui design system theming and styling patterns (neutral colors, proper spacing, modern aesthetics)
9
- 4. Apply semantic HTML structure with proper accessibility attributes (ARIA labels, alt texts, proper heading hierarchy)
10
- 5. Add 'chai-name' attributes to parent containers only - use concise, descriptive labels that clearly indicate content purpose (e.g., "Navigation", "Hero Section", "Footer", "Product Grid", "Testimonials"). These help identify sections during editing and AI-assisted modifications.
11
- 6. Ensure mobile-first responsive design approach
12
- 7. Implement container queries using @container classes where appropriate for enhanced responsive behavior
13
- 8. Do NOT include <!DOCTYPE>, <html>, <head>, or <body> tags - only the content HTML
14
- 9. Use proper contrast ratios for accessibility
15
- 10. Keep the code clean, well-structured, and semantic
16
- 11. Think about UI randomly. Do not generate the same layout every time.
17
- 12. For accordion style ui, use html details and summary tags. eg: accordions, mobile menu etc.
18
- 13. If UI generated based on provided image, make sure to make it responsive for all screens.
19
- 14. In Tailwindcss, '@container' is not valid class. Use tailwindcss classes only
20
-
21
- ### HTML Tags (EXTREMELY IMPORTANT):
22
- - For mobile menu (<details><summary>) visible only on smaller screen:
23
- * Hamburger icon in summary (proper SVG with width/height)
24
- * Menu overlay example: 'absolute right-1 mt-2 min-w-64 bg-card border border-border rounded-lg shadow-lg z-50 p-4'
25
- * Vertical menu items example: 'block py-2 px-4 hover:bg-accent rounded-md transition-colors'
26
- * Proper spacing and touch targets (min 44px height)
27
- - For accordion, faq style ui, use html details and summary tags.
28
- - For nested menu, use html details and summary tags with dropdown style menu items.
29
- - For SVG, always add tailwind class with width and height. eg: 'w-6 h-6'
30
- - For summary add list-none where not needed, like mobile-menu summary.
31
- - For input tags, add bg-background if want to make it look like shadcn/ui input.
32
-
33
- ## THEME RULES (MANDATORY - SHADCN + TAILWIND ONLY) [EXTREMELY IMPORTANT]
34
- - MANDATORY: Use ONLY ShadCN semantic tokens + Tailwind utilities for ALL colors.
35
- * COLOR TOKENS (Light Mode Reference):
36
- - bg-background (#ffffff) + text-foreground (#0a0a0a) - Default page
37
- - bg-card (#ffffff) + text-card-foreground (#0a0a0a) - Elevated containers
38
- - bg-primary (#171717) + text-primary-foreground (#fafafa) - Primary actions
39
- - bg-secondary (#f5f5f5) + text-secondary-foreground (#171717) - Secondary actions
40
- - bg-muted (#f5f5f5) + text-muted-foreground (#737373) - Subdued elements
41
- - bg-accent (#f5f5f5) + text-accent-foreground (#171717) - Hover/focus states
42
- - bg-destructive (#e7000b) + text-destructive-foreground (#ffffff) - Errors/warnings
43
- - border-border (#e5e5e5), border-input (#e5e5e5) - Borders
44
- - ring-ring (#a1a1a1) - Focus rings
45
-
46
- * CONTRAST RULES (CRITICAL):
47
- - ALWAYS pair background with correct foreground token
48
- - bg-background → text-foreground (NOT text-card-foreground)
49
- - bg-card → text-card-foreground (NOT text-foreground)
50
- - bg-primary → text-primary-foreground (NOT text-foreground)
51
- - bg-accent → text-accent-foreground
52
- - NEVER use same token family for bg and text (e.g., bg-primary + text-primary)
53
-
54
- * HOVER STATE RULES:
55
- - Primary buttons: bg-primary hover:bg-primary/90 text-primary-foreground (NO hover text change)
56
- - Card hovers: hover:bg-accent hover:text-accent-foreground transition-colors
57
- - Link hovers: text-muted-foreground hover:text-foreground transition-colors
58
- - Nav links: text-foreground/80 hover:text-foreground transition-colors
59
- - NEVER use hover:text-primary-foreground on bg-primary (already same color)
60
- - Hover text must be visibly different and contrast well
61
-
62
- * USAGE EXAMPLES:
63
- ✓ bg-background text-foreground
64
- ✓ bg-card text-card-foreground border-border
65
- ✓ bg-primary text-primary-foreground hover:bg-primary/90
66
- ✓ bg-accent text-accent-foreground
67
- ✓ text-muted-foreground hover:text-foreground transition-colors
68
-
69
- * STRICTLY AVOID:
70
- ✗ bg-muted text-muted (low contrast)
71
- ✗ bg-primary hover:text-primary-foreground (redundant, no visible change)
72
- ✗ Arbitrary colors (bg-blue-500, text-red-600, etc.)
73
- ✗ Same token for bg and text (bg-foreground text-foreground)
74
-
75
- # MOBILE-FIRST APPROACH:
76
- - Mobile-first design with proper breakpoints (sm:640px, md:768px, lg:1024px, xl:1280px)
77
- - Smooth responsive transitions between breakpoints
78
- - MD breakpoint (768px-1023px) needs special attention:
79
- * Reduce grid columns gracefully (lg:4 → md:2 → sm:1)
80
- * Adjust padding/spacing for tablet view
81
- * Test navigation menu behavior at md breakpoint
82
- * Ensure cards don't break layout at md size
83
-
84
- IMAGE USAGE RULES:
85
- - VERY IMPORTANT*: Do not use broken or non available images
86
- - Use royalty-free or non-copyrighted images from Unsplash or picsum photos
87
- - Choose images that are relevant to the content context
88
- - Always include descriptive alt text for accessibility
89
- - Use appropriate image dimensions (e.g., w=1200 for hero images, w=800 for cards, w=400 for thumbnails)
90
-
91
- OUTPUT
92
- - The final output should be clean, semantic HTML that works across all devices and screen sizes.
93
- - Return the complete updated HTML (not just modified parts)
94
- - Focus only on the user's request without adding extra features or elements or sections
95
- - Do not add any comments in the code
96
- - Keep the output simple, minimal and precisely targeted to the request
97
- - NO EXPLANATION - JUST HTML!`.trim()}function oe({userInput:r,language:t="en",currentHtml:n}){const l=ee.LANGUAGES[t]||"English";return n&&n.trim().length>0?`
98
- MODE: EDIT
99
- CURRENT HTML:
100
- ${n}
101
-
102
- USER REQUEST: ${r}
103
-
104
- EDIT MODE INSTRUCTIONS:
105
- - Modify the existing HTML based on the user's request
106
- - IMPORTANT: If asked for updating content, do not change layout just update same HTML with updated content
107
- - CRITICAL: THINGS TO PREVENT
108
- - Preserve ALL data binding placeholders in format '{{dataBindingId}}' - never remove or modify these dynamic content markers
109
- - Preserve html tag with attributes data-block-type="PartialBlock" or data-block-type="CustomBlock" - never remove or modify these tag
110
- - Preserve the overall structure unless specifically asked to change it
111
- - Update content, styling, or layout as requested
112
- - Maintain responsive design and accessibility
113
- - Keep using shadcn/ui theme classes and Tailwind CSS
114
- - Ensure all chai-name attributes remain descriptive and accurate
115
- - Generate content in specified language: ${l}
116
- - Apply the same design principles from the system prompt
117
- - Make sure the edited HTML is clean and semantic`.trim():`
118
- USER REQUEST: ${r}
119
-
120
- CREATE MODE INSTRUCTIONS:
121
- - Generate complete HTML structure based on user request
122
- - Use creative, modern, and responsive design
123
- - Apply Tailwind CSS v3+ classes exclusively
124
- - Follow shadcn/ui design patterns and theming
125
- - Include proper accessibility attributes
126
- - Add chai-name attributes to all wrapper/container elements
127
- - Use semantic HTML structure
128
- - Generate contextually appropriate content in ${l}
129
- - Make each element unique and meaningful
130
- - Create realistic, professional content that fits the request
131
- - Avoid generic placeholder text
132
- - Use strategic image placement where appropriate
133
- - Ensure mobile-first responsive design
134
- - Apply proper hover and focus states
135
-
136
- DESIGN REQUIREMENTS:
137
- - Choose creative layout patterns that are visually striking
138
- - Apply modern spacing and typography
139
- - Use proper color contrast with shadcn/ui theme classes
140
- - Make it responsive across all device sizes
141
- - Include interactive elements with proper states
142
- - Ensure accessibility compliance`.trim()}const ae=[{label:"Navbar",prompt:"Create stunning, fully responsive navbar with"},{label:"Hero section",prompt:"Create visually compelling hero section with"},{label:"Features grid",prompt:"Create comprehensive features section with"},{label:"Contact form",prompt:"Create professional contact form with"},{label:"Testimonials",prompt:"Create engaging testimonials section with"},{label:"Pricing table",prompt:"Create modern pricing table with"},{label:"FAQ section",prompt:"Create informative FAQ section with"},{label:"Footer",prompt:"Create comprehensive footer section with"},{label:"Call to action",prompt:"Create compelling call to action section with"},{label:"Team section",prompt:"Create professional team section with"},{label:"Blog grid",prompt:"Create attractive blog grid section with"},{label:"Stats section",prompt:"Create impactful statistics section with"}],ie=[{label:"Update styles",prompt:"Update styles"},{label:"Update content",prompt:"Update text content"},{label:"Update layout",prompt:"Update layout"},{label:"Improve content",prompt:"Improve text content grammar and spelling"},{label:"Make content longer",prompt:"Make text content longer"},{label:"Make content shorter",prompt:"Make text content shorter"},{label:"Fix grammar",prompt:"Fix grammar of the text content"}],le=({onSelect:r,currentBlock:t,selectedImage:n})=>{const[l,o]=m.useState(!1),p=t?ie:ae;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:()=>o(!l),className:N.mergeClasses("flex h-6 w-full cursor-pointer items-center justify-between gap-2 px-2",t?"bg-green-50/80 text-green-500 hover:bg-green-50":"text-primary hover:bg-primary/5"),children:[e.jsx("span",{className:"truncate whitespace-nowrap text-xs font-medium leading-none",children:n?"Image actions":t?"Edit : "+(t._name||t._type):"Quick Prompts"}),e.jsx(b.ChevronsUpDown,{className:"h-3 w-3"})]}),l&&e.jsx("div",{className:"max-h-60 w-full overflow-y-auto bg-white px-1 pb-1",children:p.map((y,d)=>e.jsx("div",{className:"flex cursor-pointer items-center gap-x-1 p-1 text-xs leading-none hover:text-blue-700",onClick:()=>{r(`${n||t?"Update":"Add New"} ${y.label}`,y.prompt),o(!1)},children:e.jsxs("span",{className:"truncate whitespace-nowrap",children:[t?null:e.jsx("span",{className:"font-thin text-muted-foreground",children:"Add New"})," ",y.label]})},d))})]})},ce=({message:r})=>{var t;return((t=r==null?void 0:r.content)==null?void 0:t.length)<100?e.jsx("div",{className:"relative z-50 mb-3 flex w-full flex-col gap-2 overflow-hidden",children:e.jsxs("div",{className:"flex w-max items-center justify-center gap-1 rounded-md p-1 px-2 text-xs font-medium text-blue-500",children:[e.jsx(b.Loader,{className:"h-3 w-3 animate-spin"})," Processing"]})}):e.jsx("div",{className:"relative z-50 mb-3 flex w-full flex-col gap-2 overflow-hidden",children:e.jsxs("div",{className:"flex w-max items-center justify-center gap-1 rounded-md p-1 px-2 text-xs font-medium text-blue-500",children:[e.jsx(b.Loader,{className:"h-3 w-3 animate-spin"})," Generating"]})})},de=({message:r,isUser:t,isLoading:n})=>t?e.jsx("div",{className:"relative mb-3 flex w-full justify-end overflow-hidden",children:e.jsx("div",{className:"flex max-w-[95%] flex-row-reverse rounded-lg rounded-br-sm bg-blue-500 px-2 py-1.5 text-xs text-white",children:r.userMessage})}):n?e.jsx(ce,{message:r}):e.jsx("div",{className:`relative mb-3 flex w-full overflow-hidden ${t?"justify-end":n?"max-h-48 min-h-24 justify-start":"max-h-16"}`,children:e.jsxs("div",{className:"flex w-max items-center justify-center gap-1 rounded-md p-1 px-2 text-xs font-medium text-green-500",children:[e.jsx(b.CheckCircle,{className:"h-3 w-3"})," Completed"]})}),ue=({input:r,setInput:t,onSend:n,onStop:l,isLoading:o,disabled:p,currentBlock:y})=>{const d=m.useRef(null),v=m.useRef(null),[a,w]=m.useState(null),c=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),r.trim()&&!o&&(n(r==null?void 0:r.trim(),void 0,a||void 0),w(null)))},E=()=>{const s=d.current;s&&(s.style.height="auto",s.style.height=Math.min(s.scrollHeight,120)+"px")},u=s=>{var S;const f=(S=s.target.files)==null?void 0:S[0];if(f&&f.type.startsWith("image/")){const j=new FileReader;j.onload=L=>{var i,g;const O=(i=L.target)==null?void 0:i.result;w(O),t("Generate UI based on given image "),(g=d.current)==null||g.focus()},j.readAsDataURL(f)}s.target.value=""},T=()=>{var s;(s=v.current)==null||s.click()},A=()=>{n(r==null?void 0:r.trim(),void 0,a||void 0),w(null)};return m.useEffect(()=>{E()},[r]),e.jsxs("div",{children:[!a&&e.jsx("div",{className:`mx-auto flex w-full max-w-[95%] flex-col items-center overflow-hidden rounded-t-md border-x border-t border-gray-200 bg-gray-100 ${o?"pointer-events-none opacity-50":""}`,children:e.jsx(le,{currentBlock:y,selectedImage:a,onSelect:(s,f)=>{var S;t(f+" "),(S=d.current)==null||S.focus()}})}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white",children:[a&&e.jsxs("div",{className:"relative flex w-max items-center justify-start gap-x-2 px-2 pt-2",children:[e.jsx("img",{src:a,alt:"Selected attachment",className:"max-h-16 max-w-full rounded-md border"}),e.jsx("button",{onClick:()=>w(null),className:"absolute -right-0 -top-0 flex items-center rounded-full bg-red-400 p-1 text-xs text-white hover:bg-red-500",title:"Remove image",children:e.jsx(b.X,{className:"h-2 w-2"})})]}),e.jsx("textarea",{ref:d,value:r,onChange:s=>t(s.target.value),onKeyDown:c,placeholder:"Ask me anything...",className:`max-h-[200px] min-h-[60px] w-full resize-none rounded-lg border-none px-3 py-2 text-sm outline-none ${o?"cursor-not-allowed opacity-50":""}`,rows:3,disabled:o}),e.jsxs("div",{className:"flex items-center justify-between p-2",children:[e.jsx("button",{disabled:o,onClick:T,className:`p-1.5 text-gray-400 hover:text-gray-500 ${o?"cursor-not-allowed opacity-50":""}`,title:"Attach Image",children:e.jsx(b.Paperclip,{size:16})}),e.jsx("input",{disabled:o,ref:v,type:"file",accept:"image/*",onChange:u,className:"hidden"}),o?e.jsx("button",{onClick:l,className:"z-50 rounded-md bg-red-500 p-1.5 text-white transition-colors hover:bg-red-600",title:"Stop generation",children:e.jsx(b.Square,{size:16})}):e.jsx("button",{onClick:A,disabled:!r.trim()||p,className:`rounded-md bg-blue-500 p-1.5 text-white transition-colors hover:bg-blue-600 ${!r.trim()||p?"cursor-not-allowed opacity-50":""}`,children:e.jsx(b.Send,{size:16})})]})]})]})},me=()=>{const[r,t]=m.useState(""),[n,l]=m.useState([{role:"system",content:$(),id:"system"}]),[o,p]=m.useState(!1),[y,d]=m.useState(null),v=m.useRef(null),{addPredefinedBlock:a}=N.useAddBlock(),w=N.useRemoveBlocks(),c=N.useSelectedBlock(),[E,u]=m.useState(null),[T]=N.useBlocksStore(),{selectedLang:A,fallbackLang:s}=N.useLanguages(),f=A||s,S=()=>{var i;(i=v.current)==null||i.scrollIntoView({behavior:"smooth"})};m.useEffect(()=>{S()},[n,o]);const j=()=>{y&&(y.abort(),d(null)),p(!1),t(""),u(null),l(i=>{const g=i[i.length-1];return g&&g.role==="assistant"&&!g.content.trim()?i.slice(0,-1):i}),Y.toast.info("Generation stopped")},L=async(i,g,D)=>{var G;if(!i||o)return;const x=c;u(c);const{position:K,currentHTML:F}=se((c==null?void 0:c._id)||"",T);if(c&&!F){Y.toast.error("Something went wrong. Please try again.");return}const B={id:Date.now().toString(),role:"user",content:oe({userInput:g||i,language:f,currentHtml:c?F:""}),userMessage:i},q={id:Date.now().toString(),role:"assistant",content:""};l(k=>[...k,B,q]),p(!0);const _=new AbortController;d(_);try{const k={messages:[...n,B].map(h=>({role:h.role,content:h.content}))};D&&(k.image=D);const M=await fetch("/chai/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k),signal:_.signal});if(!M.ok)throw new Error("Failed to get AI response");const R=(G=M.body)==null?void 0:G.getReader(),Q=new TextDecoder;let U="";if(!R)throw new Error("Response body is not readable");for(;;){const{done:h,value:I}=await R.read();if(h)break;const H=Q.decode(I,{stream:!0});U+=H,l(z=>z.map(P=>P.id===q.id?{...P,content:U}:P))}const X=re(U),J=N.getBlocksFromHTML(X),W=C.map(J,h=>{const I=C.get(h,"styles_attrs.data-block-type");if(I&&!V.includes(I)){const H=C.get(h,"styles_attrs.data-block-id");return{...C.find(T,{_id:H}),_parent:h==null?void 0:h._parent}}return h});x!=null&&x._id&&w([x==null?void 0:x._id]),a([...W],x==null?void 0:x._parent,x?K:-1)}catch(k){if(k.name!=="AbortError"){const M={id:(Date.now()+1).toString(),role:"assistant",content:"Sorry, I encountered an error. Please try again."};l(R=>[...R,M])}}finally{t(""),p(!1),u(null),d(null)}},O=()=>{l([{role:"system",content:$(),id:"system"}]),t(""),u(null),d(null),p(!1)};return e.jsxs(e.Fragment,{children:[o&&e.jsx("div",{className:"fixed inset-0 left-0 top-0 z-40 flex h-screen w-screen flex-col items-center justify-center bg-transparent"}),e.jsxs("div",{className:"flex h-full w-full flex-col bg-white",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Your conversation will not be saved"}),(n==null?void 0:n.length)>1&&e.jsx(Z.Button,{variant:"outline",size:"icon",onClick:O,className:"h-6 w-6",children:e.jsx(b.Plus,{})})]}),e.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto py-4",children:[n.length===1&&e.jsx("div",{className:"flex-1 space-y-3 overflow-y-auto py-4",children:e.jsxs("div",{className:"mx-auto mt-8 text-center text-gray-500",children:[e.jsx(b.Bot,{size:48,className:"mx-auto mb-4 text-gray-300"}),e.jsx("p",{className:"mx-auto max-w-[75%] text-sm",children:"Start a conversation with the AI assistant to generate and update your sections"})]})}),n.map((i,g)=>i.role!=="system"&&e.jsx(de,{message:i,isUser:i.role==="user",isLoading:i.role==="assistant"&&o&&g===n.length-1},g)),e.jsx("div",{ref:v})]}),e.jsx("div",{className:"border-gray-200 pb-2",children:e.jsx(ue,{input:r,setInput:t,onSend:L,onStop:j,isLoading:o,currentBlock:c||E,disabled:(r==null?void 0:r.length)===0})})]})]})};exports.default=me;
@@ -1,5 +0,0 @@
1
- "use strict";var Wn=Object.defineProperty;var ms=e=>{throw TypeError(e)};var Yn=(e,t,s)=>t in e?Wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var he=(e,t,s)=>Yn(e,typeof t!="symbol"?t+"":t,s),Es=(e,t,s)=>t.has(e)||ms("Cannot "+s);var v=(e,t,s)=>(Es(e,t,"read from private field"),s?s.call(e):t.get(e)),M=(e,t,s)=>t.has(e)?ms("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),G=(e,t,s,n)=>(Es(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);const o=require("react/jsx-runtime"),p=require("lodash-es"),h=require("react"),Q=require("jotai"),P=require("@tanstack/react-query"),_=require("@chaibuilder/sdk"),F=require("sonner"),m=require("@chaibuilder/sdk/ui"),w=require("lucide-react"),Ls=require("@chaibuilder/runtime"),Jn=require("@chaibuilder/sdk/web-blocks");function Xn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const z=Xn(h),y={GET_GLOBAL_JSONLD_ITEMS:"GET_GLOBAL_JSONLD_ITEMS",GENERATE_SEO_FIELD:"GENERATE_SEO_FIELD",UPDATE_PAGE_METADATA:"UPDATE_PAGE_METADATA",GET_BLOCK_ASYNC_PROPS:"GET_BLOCK_ASYNC_PROPS",ASK_AI:"ASK_AI",GET_DRAFT_PAGE:"GET_DRAFT_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",DUPLICATE_PAGE:"DUPLICATE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_SETTINGS:"UPDATE_WEBSITE_SETTINGS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_DRAFT_SETTINGS:"GET_WEBSITE_DRAFT_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA",GET_PAGE_REVISIONS:"GET_PAGE_REVISIONS",DELETE_PAGE_REVISION:"DELETE_PAGE_REVISION",RESTORE_PAGE_REVISION:"RESTORE_PAGE_REVISION",GET_REVISION_DATA:"GET_REVISION_DATA",GET_PAGE_DATA:"GET_PAGE_DATA",GET_COMPARE_DATA:"GET_COMPARE_DATA",GET_ROLE_AND_PERMISSIONS:"GET_ROLE_AND_PERMISSIONS",UPSERT_LIBRARY_ITEM:"UPSERT_LIBRARY_ITEM",GET_LIBRARIES:"GET_LIBRARIES",GET_LIBRARY_ITEM:"GET_LIBRARY_ITEM",GET_LIBRARY_ITEMS:"GET_LIBRARY_ITEMS",DELETE_LIBRARY_ITEM:"DELETE_LIBRARY_ITEM",MARK_AS_TEMPLATE:"MARK_AS_TEMPLATE",UNMARK_AS_TEMPLATE:"UNMARK_AS_TEMPLATE",GET_TEMPLATES_BY_TYPE:"GET_TEMPLATES_BY_TYPE",GET_DYNAMIC_PAGES:"GET_DYNAMIC_PAGES",GET_APP_SHARED_JSONLD:"GET_APP_SHARED_JSONLD",UPDATE_APP_SHARED_JSONLD:"UPDATE_APP_SHARED_JSONLD",ADD_GLOBAL_SCHEMA:"ADD_GLOBAL_SCHEMA",UPDATE_GLOBAL_SCHEMA:"UPDATE_GLOBAL_SCHEMA",DELETE_GLOBAL_SCHEMA:"DELETE_GLOBAL_SCHEMA",TOGGLE_PAGE_GLOBAL_SCHEMA:"TOGGLE_PAGE_GLOBAL_SCHEMA",APPLY_SCHEMA_TO_ALL_PAGES:"APPLY_SCHEMA_TO_ALL_PAGES",REMOVE_SCHEMA_FROM_ALL_PAGES:"REMOVE_SCHEMA_FROM_ALL_PAGES",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},Zn=Q.atom({}),jt=()=>Q.useAtom(Zn),se=(e,t)=>{const[s]=jt();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},k=()=>se("apiUrl","/chai/api"),js=()=>se("usersApiUrl","/chai/users"),er=()=>se("assetsApiUrl","/chai/assets"),tr=()=>se("websocket",null),sr=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),nr=()=>{const e=j(),t=k();return h.useCallback(async({body:s,headers:n={},url:r=t})=>e(r,s,n),[e])},j=()=>{const e=se("onLogout"),t=se("getAccessToken"),s=k();return h.useCallback(async(n=s,r,a={})=>{const i=await t();if(!i)return console.error("No auth token found"),null;try{const l=p.get(r,"action","").toLowerCase(),c=await sr(n+(l?`?action=${l}`:""),r,{...a,Authorization:`Bearer ${i}`});if(c.status===401)return console.log("401 Response",c),e(),window.location.reload(),null;if(!c.ok){const u=await c.json();throw console.error(`API Error (${c.status}):`,u),{status:c.status,statusText:c.statusText,...u,message:u.error||u.message||`Server error: ${c.status}`}}return await c.json()}catch(l){throw console.error("API request failed:",r,l),l}},[e,t])};function ee(){const[e,t]=h.useState(new URLSearchParams(window.location.search));return h.useEffect(()=>{const s=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[]),[e,t]}const pe=e=>{const t=k(),[s]=ee(),n=e??s.get("page"),r=j();return P.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,n],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!n)return null;const a=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:n}});return p.reverse(p.sortBy(a,"primaryPage"))},enabled:!!n})},ye=()=>{const e=k(),t=j();return P.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:5*60*1e3,placeholderData:{languages:[],theme:{fontFamily:"",borderRadius:"",colors:{}},appKey:"",fallbackLang:""},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},ts=e=>{const{fallbackLang:t}=_.useLanguages(),{data:s}=ye(),{data:n,isFetching:r}=pe(),a=h.useMemo(()=>{const i={[t]:!0};return p.each(p.get(s,"languages"),l=>{const c=p.find(n,{lang:l});i[l]=!!c}),i},[t,n,s]);return r||p.isEmpty(e)||e&&a[e]};class ks{constructor(t,s,n,r){he(this,"channelId");he(this,"websocket");he(this,"channel",null);he(this,"userId",null);he(this,"clientId",null);he(this,"pageId",null);he(this,"callback");var a,i,l,c,u,f;this.userId=n,this.websocket=t,this.clientId=this.getClientId(),this.channelId=`WEBSITE:${s}`,this.callback=r,this.channel=this.websocket.channel(this.channelId,{config:{presence:{key:this.clientId}}}),(f=(u=(c=(l=(i=(a=this.channel)==null?void 0:a.on("presence",{event:"sync"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:i.on("presence",{event:"leave"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:l.on("presence",{event:"join"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:c.on("broadcast",{event:"TAKE_OVER_REQUESTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUESTED",d)))==null?void 0:u.on("broadcast",{event:"TAKE_OVER_REQUEST_ACCEPTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUEST_ACCEPTED",d)))==null||f.on("broadcast",{event:"TAKE_OVER_REQUEST_REJECTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUEST_REJECTED",d)).subscribe()}getClientId(){return crypto.randomUUID()}getOnlineUsers({pageId:t,userId:s}){var a;const n=(a=this.channel)==null?void 0:a.presenceState();let r=Object.values(n||{}).map(i=>i[0]).filter(Boolean);return t?r=r.filter(i=>i.pageId===t):s&&(r=r.filter(i=>i.userId===s)),r.sort((i,l)=>i.onlineAt-l.onlineAt)}getPageOwner(){const t=this.getOnlineUsers({pageId:this.pageId});return t.length>0?t[0]:null}getPageUserMapping(){const t=this.getOnlineUsers({}),s=p.groupBy(t,"pageId"),n={};return Object.keys(s).forEach(r=>{var i;const a=(i=p.minBy(s[r],"onlineAt"))==null?void 0:i.userId;a!==this.userId&&(n[r]=a)}),n}onReceiveEvent(t,s){if(!this.pageId)return;const n=this.getPageOwner();if(!n||n.clientId===this.clientId?this.callback("USER_JOINED",{isActiveInOtherTab:!1}):this.callback("PAGE_LOCKED",{isActiveInOtherTab:(n==null?void 0:n.userId)===this.userId&&(n==null?void 0:n.clientId)!==this.clientId}),s.targetClientId===this.clientId)switch(t){case"TAKE_OVER_REQUESTED":this.callback("TAKE_OVER_REQUESTED",{requestedBy:s==null?void 0:s.userId,requestingClientId:s==null?void 0:s.senderClientId,isRequestedFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_ACCEPTED":this.channel.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:n?n.onlineAt-10:+new Date}),this.callback("TAKE_OVER_REQUEST_ACCEPTED",{isTakingOverFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_REJECTED":this.callback("TAKE_OVER_REQUEST_REJECTED");break}}async joinPage(t){var s;this.pageId=t,(s=this.channel)==null||s.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:+new Date})}async leavePage(){var t;this.channel&&((t=this.channel)==null||t.untrack())}async sendEvent(t,s){var n,r;if(this.channel){const a={pageId:this.pageId,userId:this.userId,senderClientId:this.clientId};t==="TAKE_OVER_REQUESTED"?a.targetClientId=(n=this.getPageOwner())==null?void 0:n.clientId:(t==="TAKE_OVER_REQUEST_ACCEPTED"||t==="TAKE_OVER_REQUEST_REJECTED")&&(a.targetClientId=s==null?void 0:s.requestingClientId),await((r=this.channel)==null?void 0:r.send({event:t,payload:a,type:"broadcast"}))}}}const rr=Q.atom(null),Ds=()=>Q.useAtom(rr),ss=()=>{const[e]=Ds();return(e==null?void 0:e.slug)||""};function ar(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const ir=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=_.useLanguages(),{data:r}=X(),a=r==null?void 0:r.pageType,i=k(),l=j(),{data:c,isFetching:u}=P.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:60*60*1e3,placeholderData:[],queryFn:async()=>await l(i,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),f=h.useMemo(()=>s===""?c.filter(d=>d.lang===""||d.lang===n):c.filter(d=>d.lang===s),[s,n,c]);return{allLangPages:c,data:f,isFetching:u}},Os=()=>{const{selectedLang:e,fallbackLang:t}=_.useLanguages(),[s,n]=Ds(),[r,a]=h.useState(""),i=ar(r,500),{allLangPages:l,data:c,isFetching:u}=ir({query:i}),f=h.useCallback(E=>n(E),[n]),d=h.useCallback(E=>a(E),[a]),g=h.useCallback(()=>{if(!s)return;const E=!(s!=null&&s.primaryPage),S=e.length===0,x=E?s==null?void 0:s.id:s==null?void 0:s.primaryPage,T=l.filter(C=>(C==null?void 0:C.primaryPage)===x||C.id===x).find(C=>S?C.lang===e||C.lang===t:C.lang===e);n(T||s)},[s,e,l,n,t]);return{isFetching:u,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:f,updateSearchQuery:d,onChangeLanguage:g}},or=Q.atom({lastSaved:void 0}),kt=()=>Q.useAtom(or),X=()=>{const[e]=ee(),t=e.get("page"),{data:s,isFetching:n}=pe();return{data:h.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},ue=()=>{const[e]=ee(),t=e.get("lang")??"",{data:s,isFetching:n}=pe();return{data:h.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},lr=Q.atom({}),cr=()=>Q.useAtom(lr),ur=()=>{const{data:e}=ue(),t=ss(),s=se("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},gt=()=>{const e=se("currentUser"),t=se("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},Gs=e=>{const t=js(),s=j();return P.useQuery({queryKey:[y.GET_CHAI_USER,e],queryFn:async()=>{const r=await s(t,{action:y.GET_CHAI_USER,data:{userId:e}});return{...r,name:r.name||r.email}},enabled:!p.isEmpty(e),staleTime:"static"})},dr=Q.atom({status:"checking",requestedBy:"",isTakeOverRequested:!1,requestingClientId:"",isActiveInOtherTab:!1}),fr=Q.atom(""),hr=Q.atom(null),ns=Q.atom({}),gr=()=>Q.useAtom(ns),Ae=()=>{const[e]=ee(),t=e.get("page"),[s,n]=Q.useAtom(dr),[r,a]=Q.useAtom(hr),[i,l]=Q.useAtom(fr),[c]=Q.useAtom(ns);return{pageLock:s,pageToUser:c,lockingStatus:i,realtimeInstance:r,setPageLock:n,setLockingStatus:l,setRealtimeInstance:a,realtimePageLockEnabled:!!r,currentEditor:c[t||""],isLocked:t&&s.status==="locked"}},mr=()=>{const e=tr(),{data:t}=X(),{user:s}=gt(),n=t==null?void 0:t.id,{data:r}=ye(),{pageLock:a,setPageLock:i,setLockingStatus:l,realtimeInstance:c,setRealtimeInstance:u}=Ae(),[,f]=Q.useAtom(ns),d=h.useRef(!1),g=h.useRef(a),E=h.useRef(!1);return h.useEffect(()=>{if(s!=null&&s.id&&e&&!c&&(r!=null&&r.appKey)&&!E.current){E.current=!0;const S=async(A,T)=>{var C,N;switch(A){case"UPDATE_ONLINE_USERS":f((T==null?void 0:T.pageToUser)||{});break;case"PAGE_LOCKED":i({...g==null?void 0:g.current,requestedBy:"",status:"locked",isActiveInOtherTab:T==null?void 0:T.isActiveInOtherTab});break;case"USER_JOINED":if(((C=g==null?void 0:g.current)==null?void 0:C.status)==="editing")return;((N=g==null?void 0:g.current)==null?void 0:N.status)==="locked"&&l("can_edit_now"),i({...g==null?void 0:g.current,requestedBy:"",status:"editing",isActiveInOtherTab:T==null?void 0:T.isActiveInOtherTab});break;case"TAKE_OVER_REQUESTED":i({...g==null?void 0:g.current,requestingClientId:T==null?void 0:T.requestingClientId,requestedBy:T!=null&&T.isRequestedFromAnotherTab?"ANOTHER_TAB":T==null?void 0:T.requestedBy});break;case"TAKE_OVER_REQUEST_ACCEPTED":T!=null&&T.isTakingOverFromAnotherTab||(l("take_over_request_accepted"),F.toast.success("Your Page Take Over Request Accepted",{position:"top-center"})),i({...g==null?void 0:g.current,status:"editing",requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break;case"TAKE_OVER_REQUEST_REJECTED":l("take_over_request_rejected"),i({...g==null?void 0:g.current,requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break}},x=new ks(e,r==null?void 0:r.appKey,s==null?void 0:s.id,S);u(x)}},[u,e,r==null?void 0:r.appKey]),h.useEffect(()=>{g.current=a},[a]),h.useEffect(()=>{if(!(!c||!n||!(s!=null&&s.id)||d.current))return d.current=!0,c==null||c.joinPage(n),()=>{c&&d.current&&(d.current=!1,g.current={requestedBy:"",status:"checking",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1},l(""),i(g.current),c==null||c.leavePage())}},[n,c]),a==null?void 0:a.status},Rs=()=>{const{data:e}=X(),{user:t}=gt(),s=e==null?void 0:e.id,{pageLock:n,setPageLock:r,realtimeInstance:a}=Ae(),{savePageAsync:i}=_.useSavePage(),l=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(r({...n,isTakeOverRequested:!0}),a==null||a.sendEvent("TAKE_OVER_REQUESTED"))},[a,s,t==null?void 0:t.id,r,n]),c=h.useCallback(async()=>{!a||!s||!(t!=null&&t.id)||(await i(),a==null||a.sendEvent("TAKE_OVER_REQUEST_ACCEPTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({requestedBy:"",status:"locked",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,i,n]),u=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(a==null||a.sendEvent("TAKE_OVER_REQUEST_REJECTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({...n,requestedBy:"",status:"editing",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,n]);return{pageLock:n,acceptTakeOver:c,rejectTakeOver:u,requestTakeOver:l}},Er=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-BiiD91y6.cjs"))),pr=h.lazy(()=>Promise.resolve().then(()=>require("./page-locked-by-dialog-DF1_jPao.cjs"))),Ut=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-request-Reyb6vZo.cjs"))),yr=({isFetchingPage:e})=>{const{pageLock:t,requestTakeOver:s}=Rs(),{currentEditor:n,lockingStatus:r,setLockingStatus:a,realtimePageLockEnabled:i}=Ae(),{data:l,isFetching:c}=Gs(n),[u]=ee(),f=u.get("page"),[d]=kt(),g=P.useQueryClient(),E=h.useCallback(()=>{s()},[s]);return!f||e||!i||(t==null?void 0:t.status)==="checking"?null:t!=null&&t.requestedBy?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:"",onContinue:()=>{s()}})}):(t==null?void 0:t.status)!=="locked"?r==="take_over_request_accepted"||r==="can_edit_now"?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:r,onContinue:()=>{g.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),a("")}})}):null:t!=null&&t.isActiveInOtherTab?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:"page_is_active_in_other_tab",onContinue:s})}):o.jsx(h.Suspense,{children:o.jsx(pr,{...l,isFetchingUserInfo:c,name:(l==null?void 0:l.name)||"Unknown User",email:(l==null?void 0:l.email)||"",lastSaved:(d==null?void 0:d.lastSaved)||"",onTakeOver:E,realtimePageLockEnabled:i,isRequestRejected:r==="take_over_request_rejected"})})},Ar=()=>{const[e]=ee(),t=e.get("lang");return ts(t)?null:o.jsx(h.Suspense,{children:o.jsx(Er,{})})},Qe={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"};function rs(e,t,s=!1){const n=e.toString()?`?${e.toString()}`:"/";s?window.history.replaceState(null,"",n):window.history.pushState({},"",n),t(e),window.dispatchEvent(new PopStateEvent("popstate"))}const Dt=Q.atom(null),Ot=()=>{const{data:e}=ye();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},as=()=>{const e=j(),t=k();return P.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},Tr=e=>{const t=j(),s=k(),n=Ot();return P.useQuery({queryKey:[y.GET_WEBSITE_PAGES,e,n],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(n===e)return{};const r=await t(s,{action:y.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})},Sr=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-COui-em5.cjs"))),Ms=({children:e})=>{const{t}=_.useTranslation(),[s,n]=ee(),r=s.get("page"),{data:a,isFetching:i}=X(),{data:l,isFetching:c}=as(),[u,f]=h.useState(!1),[d,g]=h.useState(!0),{savePage:E}=_.useSavePage(),S=!!r&&!p.isEmpty(a),x=h.useMemo(()=>{if(!l||c)return!1;const N=l.find(R=>R.slug==="/");return N==null?void 0:N.id},[l,c]);h.useEffect(()=>{if(c||!x||l.some(K=>K.id===r))return;const R=new URLSearchParams({page:x});rs(R,n),!c&&l&&g(!1)},[r,c,l,x,n]);const A=!d&&!r,T=!d&&!i&&p.isEmpty(a),C=u||A||T;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex items-center gap-x-1",children:o.jsx("div",{className:"relative",children:o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,onClick:()=>{E(),f(!0)},children:e||o.jsx(m.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:o.jsx(w.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),o.jsx(m.TooltipContent,{side:"right",children:o.jsx("p",{children:t("Open pages manager")})})]})})}),o.jsx(m.Sheet,{open:C,onOpenChange:N=>!N&&S&&f(!1),children:o.jsxs(m.SheetContent,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[50vh] !max-w-[800px] border-border p-0 ${S?"":"sheet-hide-close-btn"}`,children:[o.jsxs(m.SheetHeader,{className:"mb-3 px-4 pt-4",children:[o.jsxs(m.SheetTitle,{className:"flex items-center gap-2 text-sm font-semibold",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:o.jsx(w.Folder,{className:"h-4 w-4"})}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold",children:t("Pages")}),o.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:t("Manage your site structure")})]})]}),o.jsx(m.SheetDescription,{className:"sr-only",children:t("Manage your site structure")})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:C&&o.jsx(h.Suspense,{children:o.jsx(Sr,{close:()=>f(!1)})})})]})})]})},Pr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-zZoQgh6M.cjs"))),xr=()=>{const e=se("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},Bs=({showAdd:e=!0,variant:t="ghost"})=>{const{fallbackLang:s,languages:n,selectedLang:r,setSelectedLang:a}=_.useLanguages(),i=p.isEmpty(r)?s:r,[,l]=ee(),{isLocked:c}=Ae();h.useEffect(()=>{const A=new URLSearchParams(window.location.search),T=A.get("lang");T&&(n.includes(T)?a(T):(A.delete("lang"),l(A),a("")))},[n,l,a]);const[,u]=Q.useAtom(Dt),{data:f}=X(),{data:d}=ye(),{data:g}=pe(),E=h.useMemo(()=>{const A=p.compact(p.map(p.get(d,"languages"),T=>{const C=p.find(g,{lang:T});return{key:T,value:p.get(Qe,T,T),isLangPageAdded:!!C}})).filter(Boolean);return[{key:s,value:p.get(Qe,s),isLangPageAdded:!0},...A]},[s,g,d]),S=A=>{if(document.querySelector('[data-panel-id="seo"]')){const C=new CustomEvent("seo-language-switch-check",{detail:{fromLang:i,toLang:A,switchHandler:()=>x(A)}});window.dispatchEvent(C);return}x(A)},x=A=>{a(A);const T=new URLSearchParams(window.location.search);A===s?T.delete("lang"):T.set("lang",A),rs(T,l)};return p.isEmpty(n)?null:c?o.jsxs(m.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[o.jsx(w.Languages,{className:"h-4 w-4"}),p.get(Qe,i,i),o.jsx(w.ChevronDown,{className:"h-4 w-4"})]}):o.jsx(o.Fragment,{children:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:o.jsxs(m.Button,{disabled:!!c,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[o.jsx(w.Languages,{className:"h-4 w-4"}),p.get(Qe,i,i),o.jsx(w.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(m.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(E.filter(A=>A.isLangPageAdded),A=>o.jsxs(m.DropdownMenuItem,{className:_.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",A.key===i&&"!bg-gray-200 text-gray-700"),onClick:()=>S(A.key),children:[o.jsx("div",{className:"text-slate-600",children:A.value}),A.key===s&&o.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[o.jsx(w.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},A.value)),e&&!p.isEmpty(E.filter(A=>!A.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(m.Separator,{}),o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:()=>{f&&u({edit:!1,primaryPage:f.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(w.Plus,{className:"mr-1 h-3 w-3"})," Add Langauge"]})]})]})]})})};function _r(){const[e,t]=Q.useAtom(Dt);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(xr,{}),o.jsx(Ms,{}),e&&o.jsx(h.Suspense,{children:o.jsx(Pr,{isOpen:!0,id:e==null?void 0:e.id,edit:!!(e!=null&&e.id),primaryPage:e==null?void 0:e.primaryPage,preselectedLang:e==null?void 0:e.preselectedLang,onClose:()=>t(null)})})]})}function vr(){return o.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>o.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsx(m.Skeleton,{className:"h-4 w-3/4"}),o.jsx(m.Skeleton,{className:"h-3 w-1/2"}),o.jsx(m.Skeleton,{className:"mt-1 h-5 w-20"})]}),o.jsx(m.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const wr=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-BlM1X20k.cjs")));function br(){const[e,t]=z.useState(!1);return o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:0,children:[o.jsxs(m.Sheet,{open:e,onOpenChange:t,children:[o.jsx(m.SheetTrigger,{asChild:!0,children:o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs(m.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[o.jsx(w.History,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"View revision history"})]}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})})}),o.jsx(m.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&o.jsx(h.Suspense,{fallback:o.jsx(vr,{}),children:o.jsx(wr,{isOpen:e})})})]}),o.jsx(m.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const Tt=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=_.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},Cr={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},de=()=>{const e=k(),t=j();return P.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Us=e=>{const{data:t}=de();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},Ir=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async({pageType:s,query:n})=>{try{return t(e,{action:y.SEARCH_PAGES,data:{pageType:s,query:Array.isArray(n)&&n.length>0?n[0]:n}})||[]}catch(r){return console.error(r),[]}}})},Nr=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=de();return P.useMutation({mutationFn:async r=>await s(e,{action:y.CREATE_PAGE,data:r}),onSuccess:(r,a)=>{var l;a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+((l=p.find(n,{key:a.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";F.toast.success(i)},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to add new ${i!=null&&i.hasSlug?"page":i.name}.`,{description:p.get(Cr,r.message,r.message)})}})},Lr=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=ue(),{data:r}=de();return P.useMutation({mutationFn:async a=>await s(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,i)=>{(n==null?void 0:n.id)===(i==null?void 0:i.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),i&&(i!=null&&i.primaryPage||i!=null&&i.seo)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const l=p.find(r,{key:i.pageType});F.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},jr=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=de();return P.useMutation({mutationFn:async r=>s(e,{action:y.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{if(r.code==="PAGE_LOCKED"){F.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to delete ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},kr=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=de();return P.useMutation({mutationFn:async r=>s(e,{action:y.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=p.find(n,{key:a.pageType});F.toast.success(i!=null&&i.hasSlug?"Page unpublished successfully.":"New "+i.name+" added successfully.")},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to take offline ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},is=()=>{const e=k(),t=j(),s=P.useQueryClient(),{data:n}=X(),{savePageAsync:r}=_.useSavePage();return P.useMutation({mutationFn:async({ids:a})=>(await r(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:a}})),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_CHANGES]}),s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,n==null?void 0:n.id]})},onError:a=>{console.log("##",a),F.toast.error("Failed to publish pages.")}})},Dr=()=>{const e=k(),t=j(),s=P.useQueryClient();return P.useMutation({mutationFn:async n=>{var r;return t(e,{action:y.MARK_AS_TEMPLATE,data:{id:(r=n.page)==null?void 0:r.id,name:n.name,description:n.description,pageType:n.pageType,previewImage:n.previewImage}})},onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page marked as template successfully.")},onError:()=>{F.toast.error("Failed to mark page as template.")}})},Or=()=>{const e=k(),t=j(),s=P.useQueryClient();return P.useMutation({mutationFn:async n=>t(e,{action:y.UNMARK_AS_TEMPLATE,data:{id:n==null?void 0:n.id}}),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page unmarked as template successfully.")},onError:()=>{F.toast.error("Failed to unmark page as template.")}})},Gr=()=>{const e=k(),t=j(),s=P.useQueryClient();return P.useMutation({mutationFn:async({id:n,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:n,slug:r}}),onSuccess:(n,{primaryPage:r})=>{F.toast.success("Slug changed successfully."),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{F.toast.error("Failed to change slug")}})},Rr=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-6L8onxVt.cjs")));function Mr({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=is();return o.jsx(m.Dialog,{open:e,onOpenChange:n?()=>{}:t,children:e&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:o.jsx(Rr,{onClose:t,isPending:n,publishPage:s})})})}const te={..._.PERMISSIONS,ADD_PAGE:"add_page",EDIT_PAGE:"edit_page",EDIT_SLUG:"edit_slug",DELETE_PAGE:"delete_page",CHANGE_PAGE_TYPE:"change_page_type",PUBLISH_PAGE:"publish_page",UNPUBLISH_PAGE:"unpublish_page",MARK_AS_TEMPLATE:"mark_as_template",UNMARK_AS_TEMPLATE:"unmark_as_template",ADD_PARTIAL:"add_partial",EDIT_PARTIAL:"edit_partial",DELETE_PARTIAL:"delete_partial",PUBLISH_PARTIAL:"publish_partial",UNPUBLISH_PARTIAL:"unpublish_partial",EDIT_SEO:"edit_seo",RESTORE_REVISION:"restore_revision",DELETE_REVISION:"delete_revision",PUBLISH_THEME:"publish_theme",EDIT_SETTINGS:"edit_settings",ADD_LIBRARY_BLOCK:"create_library_block",ADD_LIBRARY_TEMPLATE:"add_library_template",EDIT_LIBRARY_BLOCK:"edit_library_block",EDIT_LIBRARY_TEMPLATE:"edit_library_template",DELETE_LIBRARY_BLOCK:"delete_library_block",DELETE_LIBRARY_TEMPLATE:"delete_library_template",ADD_MEDIA:"add_media",EDIT_MEDIA:"edit_media",DELETE_MEDIA:"delete_media"},Br={particleCount:350,spread:120,origin:{y:.6},angle:90},Ur={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Fr=async()=>{const{default:e}=await Promise.resolve().then(()=>require("./confetti.module-BuUnQuWk.cjs"));return e},St=e=>{let t=Ur[e];t||(t={});const s={...Br,...t};Fr().then(n=>n(s))};function Gt({children:e,content:t,side:s="bottom",delayDuration:n=700,showTooltip:r=!0}){return r?o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:n,children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:e}),o.jsx(m.TooltipContent,{side:s,sideOffset:10,children:o.jsx("p",{children:t})})]})}):e}const qr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-D0FunHFp.cjs"))),Kr=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-Kctu12rQ.cjs"))),Vr=()=>{const{t:e}=_.useTranslation(),{selectedLang:t,fallbackLang:s}=_.useLanguages(),n=se("getPreviewUrl",async g=>g),[r,a]=h.useState(""),{data:i}=X(),{data:l}=pe(),{data:c}=de(),u=h.useMemo(()=>{var g;return(g=l==null?void 0:l.find(E=>(E==null?void 0:E.lang)===t))==null?void 0:g.slug},[t,l]),f=h.useCallback(g=>{var E;return(E=p.find(c,{key:g}))==null?void 0:E.hasSlug},[c]),d=t===s?"":t;return h.useEffect(()=>{(async()=>{if(typeof n=="function"){const g=!f(i==null?void 0:i.pageType),E=await n(g?`${d!==""?d+"/":""}${i==null?void 0:i.id}`:u||"");a(E)}else a("")})()},[n,u,i==null?void 0:i.pageType,f,i==null?void 0:i.id,d]),o.jsx(o.Fragment,{children:o.jsx(Gt,{content:e("Open preview in new tab"),delayDuration:0,children:o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:o.jsx(m.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(w.Play,{className:"h-4 w-4"})})})})})},Qr=()=>{const{t:e}=_.useTranslation(),[t,s]=_.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Gt,{content:e("Theme"),delayDuration:0,children:o.jsx(m.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>s(t==="theme"?"block":"theme"),children:o.jsx(w.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},Hr=()=>{const{t:e}=_.useTranslation(),[t,s]=h.useState(!1),{isLocked:n}=Ae(),{savePageAsync:r,saveState:a}=_.useSavePage();h.useEffect(()=>{const f=d=>{a==="UNSAVED"&&(d.preventDefault(),d.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",f),()=>{window.removeEventListener("beforeunload",f)}},[a]);const i=h.useCallback(async()=>{t||(s(!0),await r(),s(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:u}=h.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:o.jsx(w.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:o.jsx(w.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:o.jsx(w.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return n?null:o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:i,className:`${c} w-24 max-w-24`,children:[l," ",u]})},zr=()=>{const{t:e}=_.useTranslation(),{selectedLang:t}=_.useLanguages(),{data:s}=ue(),{data:n}=pe(),[r,a]=h.useState(!1),[i,l]=h.useState(!1),[c,u]=h.useState(null),{savePageAsync:f}=_.useSavePage(),[d,g]=h.useState(!1),{data:E}=X(),{mutate:S,isPending:x}=is(),{needTranslations:A}=_.useSavePage(),T=A(),{buttonText:C,buttonClassName:N,isPublished:R}=h.useMemo(()=>{const I=E&&(E==null?void 0:E.online);return{buttonClassName:I?"hover:bg-green-600 bg-green-500":"",isPublished:I,buttonText:e(I?"Published":"Publish")}},[E,e]),K=async()=>{if(T){g(!0);return}O()},O=()=>{const I=[s==null?void 0:s.id,s==null?void 0:s.primaryPage];S({ids:p.compact(I)},{onSuccess:()=>St("TOP_RIGHT")})},ie=()=>{g(!1),O()},oe=async()=>{g(!1),await f()},q=h.useMemo(()=>p.map(n??[],"id"),[n]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(m.Button,{size:"sm",onClick:K,disabled:x||!(E!=null&&E.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${N}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[o.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${i?"-translate-y-10":""}`,children:R?o.jsx(w.Send,{className:"h-4 w-4"}):o.jsx(w.Rocket,{className:"h-4 w-4"})}),o.jsx("span",{className:`absolute inset-0 left-3 flex items-center transition-transform duration-300 ease-in-out ${i?"":"translate-y-10"}`,children:R?o.jsx(w.Rocket,{className:"h-4 w-4"}):o.jsx(w.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:C}),t?`(${p.upperCase(t)})`:""]}),o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",disabled:x||!(E!=null&&E.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${N}`,children:o.jsx(w.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(m.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(m.DropdownMenuItem,{disabled:x,className:"cursor-pointer text-xs",onClick:()=>S({ids:q},{onSuccess:()=>St("TOP_RIGHT")}),children:[e("Publish")," with translation pages"]}),!R&&o.jsxs(m.DropdownMenuItem,{disabled:x,className:"cursor-pointer text-xs",onClick:()=>S({ids:[E==null?void 0:E.id]},{onSuccess:()=>St("TOP_RIGHT")}),children:[e("Publish")," page"]}),o.jsxs(m.DropdownMenuItem,{onClick:()=>a(!0),className:"cursor-pointer text-xs",children:[e("Open")," publish menu"]}),R&&o.jsxs(m.DropdownMenuItem,{onClick:()=>u(s),className:"cursor-pointer text-xs",children:[e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]})]})]})]}),o.jsx(Mr,{showModal:r,onClose:()=>a(!1)}),c&&o.jsx(h.Suspense,{children:o.jsx(qr,{page:c,onClose:()=>u(null)})}),d&&o.jsx(h.Suspense,{children:o.jsx(Kr,{isOpen:d,onClose:oe,onContinue:ie,isPending:x})})]})};function $r(){const{isLocked:e}=Ae(),[t]=ee(),s=t.get("lang"),n=ts(s);return e||!n?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsx(br,{}),o.jsx(Tt,{permission:te.EDIT_THEME,children:o.jsx(Qr,{})}),o.jsx(Vr,{}),o.jsx(Tt,{permission:te.SAVE_PAGE,children:o.jsx(Hr,{})}),o.jsx(Tt,{permission:te.PUBLISH_PAGE,children:o.jsx(zr,{})})]})}const Fs=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{t:u}=_.useTranslation(),{hasPermission:f}=_.usePermissions(),{data:d}=de(),g=h.useMemo(()=>p.find(d,{key:e.pageType}),[d,e.pageType]),E=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),S=h.useMemo(()=>!!(g!=null&&g.hasSlug),[g==null?void 0:g.hasSlug]);return!f(te.EDIT_PAGE)&&!f(te.DELETE_PAGE)&&!f(te.UNPUBLISH_PAGE)||!e?null:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,onClick:A=>A.stopPropagation(),children:l}),o.jsxs(m.DropdownMenuContent,{align:"center",className:"text-sm",children:[f(te.ADD_PAGE)&&!c&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),t(e)},children:[o.jsx(w.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),f(te.EDIT_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),s({...e,global:!(g!=null&&g.hasSlug)})},children:[o.jsx(w.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&f(te.UNPUBLISH_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),n(e)},children:[o.jsx(w.Power,{className:"size-3"}),u("Unpublish")]}),f(te.DELETE_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),r(e)},children:[o.jsx(w.Trash,{className:"size-3"}),u("Delete")]}),f(te.MARK_AS_TEMPLATE)&&S&&!c&&o.jsx(o.Fragment,{children:E?o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),i(e)},children:[o.jsx(w.SquareLibrary,{className:"size-3"}),u("Unmark as template")]}):o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),a(e)},children:[o.jsx(w.SquareLibrary,{className:"size-3"}),u("Mark as template")]})})]})]})},Wr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-Cf_zoJPL.cjs"))),Yr=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-qrzBuLu5.cjs"))),Jr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CGKrJ-pm.cjs"))),Xr=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DwgrP1Vj.cjs"))),Zr=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-BTY-g4LE.cjs"))),ea=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-D0FunHFp.cjs"))),ta=()=>{const[e,t]=h.useState(null),[s,n]=h.useState(null),[r,a]=h.useState(null),[i,l]=h.useState(null),[c,u]=h.useState(null),[f,d]=h.useState(null),{data:g,isFetching:E}=ue(),{selectedLang:S,fallbackLang:x}=_.useLanguages(),{data:A}=pe(),T=A==null?void 0:A.find(O=>O.lang===S),{isLocked:C}=Ae(),N=!(g!=null&&g.slug),[,R]=Q.useAtom(Dt);if(!g)return null;const K=O=>{S.length>0&&S!==x?R({edit:!0,id:O==null?void 0:O.id,primaryPage:O==null?void 0:O.primaryPage}):d(O)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between rounded px-[2px] transition-colors duration-200",children:[o.jsx(Ms,{children:o.jsx(m.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:E?o.jsx(w.Loader,{className:"h-4 w-4 animate-spin text-slate-400"}):o.jsxs("span",{className:"flex w-full cursor-pointer items-end overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-xs font-medium",children:[N?o.jsx(w.Hash,{className:"mr-1 h-4 w-4"}):o.jsx(w.File,{className:"mr-1 h-4 w-4"}),p.get(T||g,"name")??""]})})}),C?o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:o.jsx(w.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx(Fs,{page:g,setDuplicatePage:O=>u(O),setAddEditPage:O=>K(O),setUnpublishPage:O=>n(O),setDeletePage:O=>t(O),setMarkAsTemplate:O=>a(O),setUnmarkAsTemplate:O=>l(O),isLanguagePage:S.length>0&&S!==x,children:o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(w.MoreHorizontal,{className:"h-4 w-4"})})})]}),f&&o.jsx(h.Suspense,{children:o.jsx(Wr,{closePanel:()=>d(null),editPage:()=>{},addEditPage:f,setAddEditPage:d})}),e&&o.jsx(h.Suspense,{children:o.jsx(Yr,{page:e,onClose:()=>t(null)})}),s&&o.jsx(h.Suspense,{children:o.jsx(ea,{page:s,onClose:()=>n(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx(Xr,{page:r,onClose:()=>a(null)})}),i&&o.jsx(h.Suspense,{children:o.jsx(Zr,{page:i,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(Jr,{page:c,onClose:()=>u(null),closePanel:()=>d(null)})})]})},os=({children:e,className:t=""})=>o.jsx("div",{className:_.mergeClasses("fixed bottom-0 left-0 right-0 top-[50px] z-[20] flex w-screen flex-col items-center justify-center bg-black/40 transition-all",t),children:e}),sa=({hasDynamicPage:e})=>o.jsx(os,{children:o.jsxs("div",{className:"flex min-w-[300px] max-w-[400px] flex-col items-center justify-center rounded-lg border bg-white p-4 shadow-lg",children:[o.jsx("h1",{className:"text-lg font-medium",children:e?"Select a page":"No pages found"}),o.jsx("p",{className:"pt-2 text-center text-sm font-light text-gray-600",children:e?"Please select a page from the list in the top header. This will enable you to edit the page.":"Please add a new page"})]})}),na=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-C1ENQo3c.cjs"))),ra=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=Os(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(sa,{hasDynamicPage:n}),o.jsx(h.Suspense,{children:o.jsx(na,{})})]})},aa=()=>{const{data:e,isFetching:t}=ue(),{data:s,isFetching:n}=X(),r=p.get(s,"dynamic",!1),a=ss(),i=_.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,u=ur(),f=t||n,g=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return o.jsxs("div",{className:"relative flex items-center gap-x-1",children:[o.jsx("div",{className:_.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",f&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(ta,{})}),o.jsxs("div",{className:_.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800"+(c?" pr-2":""),f&&"max-w-0 overflow-hidden opacity-0"),children:[o.jsx(Bs,{}),o.jsxs("div",{className:"flex w-full items-center overflow-hidden",children:[o.jsx("div",{className:`w-full max-w-[200px] overflow-hidden overflow-ellipsis whitespace-nowrap pl-1 text-xs ${c?"italic text-gray-400":"font-mono text-gray-500"}`,children:g==="/"?o.jsxs("span",{className:"text-gray-900",children:["/",o.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):g}),!c&&o.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:o.jsx("div",{className:"ml-2 mr-px flex-shrink-0 rounded-sm p-1.5 text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",children:o.jsx(w.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&i&&o.jsx(ra,{})]})},ia=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(_r,{}),o.jsx(aa,{}),o.jsx($r,{})]}),qs=()=>{const e=P.useQueryClient(),{data:t}=P.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},oa=()=>{const e=k(),{aiContext:t}=qs(),s=j();return h.useCallback(async(n,r,a,i)=>s(e,{action:y.ASK_AI,data:{type:n,prompt:r,blocks:a,context:t,lang:i}}),[e,t,s])},la=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=Ls.getDefaultBlockProps(s._type);return{...n,...p.pick(s,[...p.keys(n),"_type","_id","_name","_parent","_bindings"]),...p.pickBy(s,(r,a)=>p.endsWith(a,"_attrs")),...s}}return s}),ca=e=>{const t=Ls.useRegisteredChaiBlocks();return h.useMemo(()=>{if(!e||p.isEmpty(e))return{blocks:[]};const s=p.filter(e,n=>!p.includes(n==null?void 0:n._type,"@chai/"));return{blocks:la(t,s)}},[e,t])},ua=()=>{const[e]=ee(),t=e.get("page"),s=k(),{setAiContext:n}=qs(),[,r]=kt(),[,a]=cr(),[,i]=_.useIsPageLoaded(),l=j();return P.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{i(!1);const c=await l(s,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),u=c.blocks??[],f=p.find(u,{_type:"@chai/ai-context"});return n(p.get(f,"_value","")||""),r(d=>({...d,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),u},enabled:!!t})},Ks=()=>{const{data:e}=X(),{data:t}=ue(),s=k(),n=j(),r=Ot(),a=ss();return P.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>n(s,{action:y.GET_BUILDER_PAGE_DATA,data:{pageType:e==null?void 0:e.pageType,lang:(t==null?void 0:t.lang)||r,dynamic:e==null?void 0:e.dynamic,pageProps:{slug:(t==null?void 0:t.slug)+a,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:r,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id,metadata:e.metadata||{}}}}),enabled:!!(e!=null&&e.pageType)&&!!t.id})},Vs=()=>{const e=k(),t=P.useQueryClient(),s=j();return P.useMutation({mutationFn:async n=>s(e,{action:y.UPDATE_WEBSITE_SETTINGS,data:n}),onSuccess:(n,r)=>{var a;t.invalidateQueries({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS]}),(a=r==null?void 0:r.settings)!=null&&a.theme||F.toast.success("Website settings updated successfully.")},onError:n=>{F.toast.error("Failed to update website settings",{description:n.message})}})},da=()=>{const e=k(),t=P.useQueryClient(),s=j(),{selectedLang:n}=_.useLanguages();return P.useMutation({mutationFn:async r=>s(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema added successfully.")},onError:r=>{F.toast.error("Failed to add schema",{description:r.message})}})},fa=()=>{const e=k(),t=P.useQueryClient(),s=j(),{selectedLang:n}=_.useLanguages();return P.useMutation({mutationFn:async r=>s(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema updated successfully.")},onError:r=>{F.toast.error("Failed to update schema",{description:r.message})}})},ha=()=>{const e=k(),t=P.useQueryClient(),s=j();return P.useMutation({mutationFn:async n=>s(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema deleted successfully.")},onError:n=>{F.toast.error("Failed to delete schema",{description:n.message})}})},ga=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async s=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:s}),onError:s=>{F.toast.error("Failed to toggle schema",{description:s.message})}})},ma=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async s=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema applied to ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to apply schema to all pages",{description:s.message})}})},Ea=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async s=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema removed from ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to remove schema from all pages",{description:s.message})}})},ps={async getUILibraryBlock(e,t,s){const n=await t(s,{action:"GET_LIBRARY_ITEM",data:{id:e.id}}),r=p.get(n,"html",""),a=p.get(n,"blocks",[]);return p.isArray(a)?a:_.getBlocksFromHTML(r)},async getUILibraryBlocks(e,t,s){try{return(await t(s,{action:"GET_LIBRARY_ITEMS",data:{id:e.id}})).map(r=>({...r}))}catch(n){return console.error(n),[]}}},pa=()=>{const e=k(),t=j();return P.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{_.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>ps.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>ps.getUILibraryBlock(a,t,e)})}),n}})},Qs=()=>{const e=js(),t=j(),{user:s}=gt(),n=s==null?void 0:s.id;return P.useQuery({queryKey:[y.GET_ROLE_AND_PERMISSIONS,n],queryFn:()=>t(e,{action:y.GET_ROLE_AND_PERMISSIONS,data:{userId:n}}),enabled:!!n,staleTime:1/0})},ya=()=>{const e=k(),t=j(),[,s]=kt();return{onSave:async({page:r,blocks:a,needTranslations:i})=>{try{const l=await t(e,{action:"UPDATE_PAGE",data:{id:r,blocks:a,needTranslations:i}});return l.code==="PAGE_LOCKED"?!0:(s(c=>({...c,lastSaved:new Date().toISOString()})),l)}catch(l){return console.error(l),new Error("Failed to save blocks")}}}},Aa=()=>{const{data:e}=as(),t=k(),s=j();return{getPartialBlocks:h.useCallback(async()=>{const n={};for(const r of e??[])p.isEmpty(r==null?void 0:r.slug)&&(n[r.id]={type:r.pageType,name:p.startCase(r.name??r.slug),description:""});return n},[e]),getPartialBlockBlocks:h.useCallback(async n=>{if(!n)return[];try{const r=await s(t,{action:"GET_DRAFT_PAGE",data:{id:n,draft:!0,editor:!1}});return p.filter(r.blocks,a=>p.has(a,"_id"))}catch(r){return console.error(r),[]}},[s,t])}},Ta=h.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-content-xcOgRnxG.cjs"))),Hs="chaibuilder-ai",Sa=({className:e="h-full w-full"})=>o.jsx("svg",{className:e,viewBox:"0 0 256 256",fill:"currentColor",children:o.jsx("path",{d:"m198.39 128.986-52.16-19.216-19.216-52.16a16 16 0 0 0-30.028 0L77.77 109.77l-52.16 19.216a16 16 0 0 0 0 30.028l52.16 19.216 19.216 52.16a16 16 0 0 0 30.028 0l19.216-52.16 52.16-19.216a16 16 0 0 0 0-30.028m-57.69 34.23a15.97 15.97 0 0 0-9.483 9.483l-19.22 52.152-19.214-52.15a15.97 15.97 0 0 0-9.482-9.484l-52.152-19.22 52.15-19.214a15.97 15.97 0 0 0 9.484-9.482l19.22-52.152 19.214 52.15a15.97 15.97 0 0 0 9.482 9.484l52.152 19.22ZM144 40a8 8 0 0 1 8-8h16V16a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16h-16v16a8 8 0 0 1-16 0V48h-16a8 8 0 0 1-8-8m104 48a8 8 0 0 1-8 8h-8v8a8 8 0 0 1-16 0v-8h-8a8 8 0 0 1 0-16h8v-8a8 8 0 0 1 16 0v8h8a8 8 0 0 1 8 8"})}),Pa=({isActive:e,show:t})=>_.useChaiFeatureFlag("enable-ai-chat-panel")?o.jsx(m.Button,{size:"icon",onClick:t,variant:e?"default":"ghost",children:o.jsx(Sa,{className:"h-4 w-4"})}):null,xa={id:Hs,label:"AI Assistant",button:Pa,panel:Ta,position:"top"},_a=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-BQiWaq2_.cjs"))),va=({isActive:e,show:t})=>{const{data:s}=ye();return!p.has(s,"languages")||!p.get(s,"languages",[]).length?null:o.jsx(m.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:o.jsx(w.LanguagesIcon,{className:"h-4 w-4"})})},zs="lang",wa={id:zs,label:"Languages",position:"top",panel:_a,button:va,view:"modal",width:400},ba=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-BseSTxFf.cjs"))),$s="seo",Ca=({isActive:e,show:t})=>{const{data:s}=X(),n=Us(s==null?void 0:s.pageType);return!p.has(n,"hasSlug")||!n.hasSlug?null:o.jsx(m.Button,{size:"icon",className:"my-1 p-0",onClick:t,variant:e?"default":"ghost",children:o.jsxs("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M7 8h-3a1 1 0 0 0 -1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-3"}),o.jsx("path",{d:"M14 16h-4v-8h4"}),o.jsx("path",{d:"M11 12h2"}),o.jsx("path",{d:"M17 8m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]})})},Ia={id:$s,label:"SEO",panel:ba,button:Ca,position:"top",width:600,view:"modal"},Ws="user-info",Na=()=>{const{t:e}=_.useTranslation(),{user:t,logout:s}=gt(),n=se("onLogout",p.noop);return t?o.jsxs(m.HoverCard,{children:[o.jsx(m.HoverCardTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"ghost",className:"text-sm font-medium",children:o.jsx(w.User,{className:"h-4 w-4"})})}),o.jsxs(m.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[o.jsx("div",{className:"text-sm font-medium",children:t.name??t.email}),o.jsx("div",{className:"text-xs text-muted-foreground",children:t.email}),o.jsxs(m.AlertDialog,{children:[o.jsx(m.AlertDialogTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),o.jsxs(m.AlertDialogContent,{children:[o.jsxs(m.AlertDialogHeader,{children:[o.jsx(m.AlertDialogTitle,{children:e("Are you sure you want to logout?")}),o.jsx(m.AlertDialogDescription,{children:e("You will be redirected to the login page.")})]}),o.jsxs(m.AlertDialogFooter,{children:[o.jsx(m.AlertDialogCancel,{children:e("Cancel")}),o.jsx(m.AlertDialogAction,{onClick:()=>{s(),p.isFunction(n)&&n()},children:e("Logout")})]})]})]})]})]}):null},La={id:Ws,label:"User Info",button:Na,position:"bottom"},ja=()=>{_.registerChaiSidebarPanel($s,Ia),_.registerChaiSidebarPanel(zs,wa),_.registerChaiSidebarPanel(Ws,La),_.registerChaiSidebarPanel(Hs,xa)};var b={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return ys(this.context.count)},getNextContextId(){return ys(this.context.count++)}};function ys(e){const t=String(e),s=t.length-1;return b.context.id+(s?String.fromCharCode(96+s):"")+t}function He(e){b.context=e}var Ys=!1,ka=(e,t)=>e===t,_t=Symbol("solid-proxy"),Js=typeof Proxy=="function",ls=Symbol("solid-track"),vt={equals:ka},Xs=on,fe=1,wt=2,Zs={owned:null,cleanups:null,context:null,owner:null},Ft={},D=null,qt=null,Da=null,B=null,J=null,ce=null,Rt=0;function ge(e,t){const s=B,n=D,r=e.length===0,a=t===void 0?n:t,i=r?Zs:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>Y(()=>Je(i)));D=i,B=null;try{return ae(l,!0)}finally{B=s,D=n}}function V(e,t){t=t?Object.assign({},vt,t):vt;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),an(s,r));return[rn.bind(s),n]}function en(e,t,s){const n=Mt(e,t,!0,fe);Ve(n)}function me(e,t,s){const n=Mt(e,t,!1,fe);Ve(n)}function cs(e,t,s){Xs=za;const n=Mt(e,t,!1,fe);(!s||!s.render)&&(n.user=!0),ce?ce.push(n):Ve(n)}function $(e,t,s){s=s?Object.assign({},vt,s):vt;const n=Mt(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,Ve(n),rn.bind(n)}function Oa(e){return e&&typeof e=="object"&&"then"in e}function Ga(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=Ft,c=null,u=!1,f="initialValue"in a,d=typeof n=="function"&&$(n);const g=new Set,[E,S]=(a.storage||V)(a.initialValue),[x,A]=V(void 0),[T,C]=V(void 0,{equals:!1}),[N,R]=V(f?"ready":"unresolved");b.context&&(c=b.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function K(I,L,W,H){return i===I&&(i=null,H!==void 0&&(f=!0),(I===l||L===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(H,{value:L})),l=Ft,O(L,W)),L}function O(I,L){ae(()=>{L===void 0&&S(()=>I),R(L!==void 0?"errored":f?"ready":"unresolved"),A(L);for(const W of g.keys())W.decrement();g.clear()},!1)}function ie(){const I=Va,L=E(),W=x();if(W!==void 0&&!i)throw W;return B&&B.user,L}function oe(I=!0){if(I!==!1&&u)return;u=!1;const L=d?d():n;if(L==null||L===!1){K(i,Y(E));return}let W;const H=l!==Ft?l:Y(()=>{try{return r(L,{value:E(),refetching:I})}catch(ne){W=ne}});if(W!==void 0){K(i,void 0,Pt(W),L);return}else if(!Oa(H))return K(i,H,void 0,L),H;return i=H,"v"in H?(H.s===1?K(i,H.v,void 0,L):K(i,void 0,Pt(H.v),L),H):(u=!0,queueMicrotask(()=>u=!1),ae(()=>{R(f?"refreshing":"pending"),C()},!1),H.then(ne=>K(H,ne,void 0,L),ne=>K(H,void 0,Pt(ne),L)))}Object.defineProperties(ie,{state:{get:()=>N()},error:{get:()=>x()},loading:{get(){const I=N();return I==="pending"||I==="refreshing"}},latest:{get(){if(!f)return ie();const I=x();if(I&&!i)throw I;return E()}}});let q=D;return d?en(()=>(q=D,oe(!1))):oe(!1),[ie,{refetch:I=>sn(q,()=>oe(I)),mutate:S}]}function Ra(e){return ae(e,!1)}function Y(e){if(B===null)return e();const t=B;B=null;try{return e()}finally{B=t}}function Ma(e,t,s){const n=Array.isArray(e);let r,a=s&&s.defer;return i=>{let l;if(n){l=Array(e.length);for(let u=0;u<e.length;u++)l[u]=e[u]()}else l=e();if(a)return a=!1,i;const c=Y(()=>t(l,r,i));return r=l,c}}function tn(e){cs(()=>Y(e))}function qe(e){return D===null||(D.cleanups===null?D.cleanups=[e]:D.cleanups.push(e)),e}function As(){return D}function sn(e,t){const s=D,n=B;D=e,B=null;try{return ae(t,!0)}catch(r){us(r)}finally{D=s,B=n}}function Ba(e){const t=B,s=D;return Promise.resolve().then(()=>{B=t,D=s;let n;return ae(e,!1),B=D=null,n?n.done:void 0})}var[Ua,$o]=V(!1);function Fa(){return[Ua,Ba]}function qa(e,t){const s=Symbol("context");return{id:s,Provider:$a(s),defaultValue:e}}function Ka(e){let t;return D&&D.context&&(t=D.context[e.id])!==void 0?t:e.defaultValue}function nn(e){const t=$(e),s=$(()=>Ht(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var Va;function rn(){if(this.sources&&this.state)if(this.state===fe)Ve(this);else{const e=J;J=null,ae(()=>Ct(this),!1),J=e}if(B){const e=this.observers?this.observers.length:0;B.sources?(B.sources.push(this),B.sourceSlots.push(e)):(B.sources=[this],B.sourceSlots=[e]),this.observers?(this.observers.push(B),this.observerSlots.push(B.sources.length-1)):(this.observers=[B],this.observerSlots=[B.sources.length-1])}return this.value}function an(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&ae(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],i=qt&&qt.running;i&&qt.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?J.push(a):ce.push(a),a.observers&&ln(a)),i||(a.state=fe)}if(J.length>1e6)throw J=[],new Error},!1)),t}function Ve(e){if(!e.fn)return;Je(e);const t=Rt;Qa(e,e.value,t)}function Qa(e,t,s){let n;const r=D,a=B;B=D=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=fe,e.owned&&e.owned.forEach(Je),e.owned=null),e.updatedAt=s+1,us(i)}finally{B=a,D=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?an(e,n):e.value=n,e.updatedAt=s)}function Mt(e,t,s,n=fe,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:D,context:D?D.context:null,pure:s};return D===null||D!==Zs&&(D.owned?D.owned.push(a):D.owned=[a]),a}function bt(e){if(e.state===0)return;if(e.state===wt)return Ct(e);if(e.suspense&&Y(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Rt);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===fe)Ve(e);else if(e.state===wt){const n=J;J=null,ae(()=>Ct(e,t[0]),!1),J=n}}function ae(e,t){if(J)return e();let s=!1;t||(J=[]),ce?s=!0:ce=[],Rt++;try{const n=e();return Ha(s),n}catch(n){s||(ce=null),J=null,us(n)}}function Ha(e){if(J&&(on(J),J=null),e)return;const t=ce;ce=null,t.length&&ae(()=>Xs(t),!1)}function on(e){for(let t=0;t<e.length;t++)bt(e[t])}function za(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:bt(n)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,s));return}He()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],s+=b.effects.length,delete b.effects),t=0;t<s;t++)bt(e[t])}function Ct(e,t){e.state=0;for(let s=0;s<e.sources.length;s+=1){const n=e.sources[s];if(n.sources){const r=n.state;r===fe?n!==t&&(!n.updatedAt||n.updatedAt<Rt)&&bt(n):r===wt&&Ct(n,t)}}}function ln(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=wt,s.pure?J.push(s):ce.push(s),s.observers&&ln(s))}}function Je(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),r=s.observers;if(r&&r.length){const a=r.pop(),i=s.observerSlots.pop();n<r.length&&(a.sourceSlots[i]=n,r[n]=a,s.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)Je(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)Je(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Pt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function us(e,t=D){throw Pt(e)}function Ht(e){if(typeof e=="function"&&!e.length)return Ht(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Ht(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function $a(e,t){return function(n){let r;return me(()=>r=Y(()=>(D.context={...D.context,[e]:n.value},nn(()=>n.children))),void 0),r}}var zt=Symbol("fallback");function It(e){for(let t=0;t<e.length;t++)e[t]()}function Wa(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return qe(()=>It(a)),()=>{let c=e()||[],u=c.length,f,d;return c[ls],Y(()=>{let E,S,x,A,T,C,N,R,K;if(u===0)i!==0&&(It(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[zt],r[0]=ge(O=>(a[0]=O,s.fallback())),i=1);else if(i===0){for(r=new Array(u),d=0;d<u;d++)n[d]=c[d],r[d]=ge(g);i=u}else{for(x=new Array(u),A=new Array(u),l&&(T=new Array(u)),C=0,N=Math.min(i,u);C<N&&n[C]===c[C];C++);for(N=i-1,R=u-1;N>=C&&R>=C&&n[N]===c[R];N--,R--)x[R]=r[N],A[R]=a[N],l&&(T[R]=l[N]);for(E=new Map,S=new Array(R+1),d=R;d>=C;d--)K=c[d],f=E.get(K),S[d]=f===void 0?-1:f,E.set(K,d);for(f=C;f<=N;f++)K=n[f],d=E.get(K),d!==void 0&&d!==-1?(x[d]=r[f],A[d]=a[f],l&&(T[d]=l[f]),d=S[d],E.set(K,d)):a[f]();for(d=C;d<u;d++)d in x?(r[d]=x[d],a[d]=A[d],l&&(l[d]=T[d],l[d](d))):r[d]=ge(g);r=r.slice(0,i=u),n=c.slice(0)}return r});function g(E){if(a[d]=E,l){const[S,x]=V(d);return l[d]=x,t(c[d],S)}return t(c[d])}}}function Ya(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return qe(()=>It(a)),()=>{const u=e()||[],f=u.length;return u[ls],Y(()=>{if(f===0)return l!==0&&(It(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[zt],r[0]=ge(g=>(a[0]=g,s.fallback())),l=1),r;for(n[0]===zt&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<f;c++)c<n.length&&n[c]!==u[c]?i[c](()=>u[c]):c>=n.length&&(r[c]=ge(d));for(;c<n.length;c++)a[c]();return l=i.length=a.length=f,n=u.slice(0),r=r.slice(0,l)});function d(g){a[c]=g;const[E,S]=V(u[c]);return i[c]=S,t(E,c)}}}function ds(e,t){return Y(()=>e(t||{}))}function pt(){return!0}var $t={get(e,t,s){return t===_t?s:e.get(t)},has(e,t){return t===_t?!0:e.has(t)},set:pt,deleteProperty:pt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:pt,deleteProperty:pt}},ownKeys(e){return e.keys()}};function Kt(e){return(e=typeof e=="function"?e():e)?e:{}}function Ja(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function fs(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&_t in l,e[i]=typeof l=="function"?(t=!0,$(l)):l}if(Js&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=Kt(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in Kt(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(Kt(e[l])));return[...new Set(i)]}},$t);const s={},n=Object.create(null);for(let i=e.length-1;i>=0;i--){const l=e[i];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let u=c.length-1;u>=0;u--){const f=c[u];if(f==="__proto__"||f==="constructor")continue;const d=Object.getOwnPropertyDescriptor(l,f);if(!n[f])n[f]=d.get?{enumerable:!0,configurable:!0,get:Ja.bind(s[f]=[d.get.bind(l)])}:d.value!==void 0?d:void 0;else{const g=s[f];g&&(d.get?g.push(d.get.bind(l)):d.value!==void 0&&g.push(()=>d.value))}}}const r={},a=Object.keys(n);for(let i=a.length-1;i>=0;i--){const l=a[i],c=n[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function cn(e,...t){if(Js&&_t in e){const r=new Set(t.length>1?t.flat():t[0]),a=t.map(i=>new Proxy({get(l){return i.includes(l)?e[l]:void 0},has(l){return i.includes(l)&&l in e},keys(){return i.filter(l=>l in e)}},$t));return a.push(new Proxy({get(i){return r.has(i)?void 0:e[i]},has(i){return r.has(i)?!1:i in e},keys(){return Object.keys(e).filter(i=>!r.has(i))}},$t)),a}const s={},n=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),i=!a.get&&!a.set&&a.enumerable&&a.writable&&a.configurable;let l=!1,c=0;for(const u of t)u.includes(r)&&(l=!0,i?n[c][r]=a.value:Object.defineProperty(n[c],r,a)),++c;l||(i?s[r]=a.value:Object.defineProperty(s,r,a))}return[...n,s]}function un(e){let t,s;const n=r=>{const a=b.context;if(a){const[l,c]=V();b.count||(b.count=0),b.count++,(s||(s=e())).then(u=>{!b.done&&He(a),b.count--,c(()=>u.default),He()}),t=l}else if(!t){const[l]=Ga(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return $(()=>(i=t())?Y(()=>{if(!a||b.done)return i(r);const l=b.context;He(a);const c=i(r);return He(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var Xa=0;function Za(){return b.context?b.getNextContextId():`cl-${Xa++}`}var dn=e=>`Stale read from <${e}>.`;function ei(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Wa(()=>e.each,e.children,t||void 0))}function ti(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Ya(()=>e.each,e.children,t||void 0))}function si(e){const t=e.keyed,s=$(()=>e.when,void 0,void 0),n=t?s:$(s,void 0,{equals:(r,a)=>!r==!a});return $(()=>{const r=n();if(r){const a=e.children;return typeof a=="function"&&a.length>0?Y(()=>a(t?r:()=>{if(!Y(n))throw dn("Show");return s()})):a}return e.fallback},void 0,void 0)}function ni(e){const t=nn(()=>e.children),s=$(()=>{const n=t(),r=Array.isArray(n)?n:[n];let a=()=>{};for(let i=0;i<r.length;i++){const l=i,c=r[i],u=a,f=$(()=>u()?void 0:c.when,void 0,void 0),d=c.keyed?f:$(f,void 0,{equals:(g,E)=>!g==!E});a=()=>u()||(d()?[l,f,c]:void 0)}return a});return $(()=>{const n=s()();if(!n)return e.fallback;const[r,a,i]=n,l=i.children;return typeof l=="function"&&l.length>0?Y(()=>l(i.keyed?a():()=>{var u;if(((u=Y(s)())==null?void 0:u[0])!==r)throw dn("Match");return a()})):l},void 0,void 0)}function ri(e){return e}var ai=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],ii=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...ai]),oi=new Set(["innerHTML","textContent","innerText","children"]),li=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),ci=Object.assign(Object.create(null),{class:"className",novalidate:{$:"noValidate",FORM:1},formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function ui(e,t){const s=ci[e];return typeof s=="object"?s[t]?s.$:void 0:s}var di=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),fi=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),hi={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},gi=e=>$(()=>e());function mi(e,t,s){let n=s.length,r=t.length,a=n,i=0,l=0,c=t[r-1].nextSibling,u=null;for(;i<r||l<a;){if(t[i]===s[l]){i++,l++;continue}for(;t[r-1]===s[a-1];)r--,a--;if(r===i){const f=a<n?l?s[l-1].nextSibling:s[a-l]:c;for(;l<a;)e.insertBefore(s[l++],f)}else if(a===l)for(;i<r;)(!u||!u.has(t[i]))&&t[i].remove(),i++;else if(t[i]===s[a-1]&&s[l]===t[r-1]){const f=t[--r].nextSibling;e.insertBefore(s[l++],t[i++].nextSibling),e.insertBefore(s[--a],f),t[r]=s[a]}else{if(!u){u=new Map;let d=l;for(;d<a;)u.set(s[d],d++)}const f=u.get(t[i]);if(f!=null)if(l<f&&f<a){let d=i,g=1,E;for(;++d<r&&d<a&&!((E=u.get(t[d]))==null||E!==f+g);)g++;if(g>f-l){const S=t[i];for(;l<f;)e.insertBefore(s[l++],S)}else e.replaceChild(s[l++],t[i++])}else i++;else t[i++].remove()}}}var We="_$DX_DELEGATE";function fn(e,t,s,n={}){let r;return ge(a=>{r=a,t===document?e():Lt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function Ei(e,t,s,n){let r;const a=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},i=()=>(r||(r=a())).cloneNode(!0);return i.cloneNode=i,i}function hn(e,t=window.document){const s=t[We]||(t[We]=new Set);for(let n=0,r=e.length;n<r;n++){const a=e[n];s.has(a)||(s.add(a),t.addEventListener(a,yn))}}function pi(e=window.document){if(e[We]){for(let t of e[We].keys())e.removeEventListener(t,yn);delete e[We]}}function Nt(e,t,s){xe(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function yi(e,t,s,n){xe(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function Ai(e,t,s){xe(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function gn(e,t){xe(e)||(t==null?e.removeAttribute("class"):e.className=t)}function mn(e,t,s,n){if(n)Array.isArray(s)?(e[`$$${t}`]=s[0],e[`$$${t}Data`]=s[1]):e[`$$${t}`]=s;else if(Array.isArray(s)){const r=s[0];e.addEventListener(t,s[0]=a=>r.call(e,s[1],a))}else e.addEventListener(t,s,typeof s!="function"&&s)}function Ti(e,t,s={}){const n=Object.keys(t||{}),r=Object.keys(s);let a,i;for(a=0,i=r.length;a<i;a++){const l=r[a];!l||l==="undefined"||t[l]||(Ts(e,l,!1),delete s[l])}for(a=0,i=n.length;a<i;a++){const l=n[a],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(Ts(e,l,!0),s[l]=c)}return s}function Si(e,t,s){if(!t)return s?Nt(e,"style"):t;const n=e.style;if(typeof t=="string")return n.cssText=t;typeof s=="string"&&(n.cssText=s=void 0),s||(s={}),t||(t={});let r,a;for(a in s)t[a]==null&&n.removeProperty(a),delete s[a];for(a in t)r=t[a],r!==s[a]&&(n.setProperty(a,r),s[a]=r);return s}function En(e,t={},s,n){const r={};return n||me(()=>r.children=Xe(e,t.children,r.children)),me(()=>typeof t.ref=="function"&&pn(t.ref,e)),me(()=>Pi(e,t,s,!0,r,!0)),r}function pn(e,t,s){return Y(()=>e(t,s))}function Lt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return Xe(e,t,n,s);me(r=>Xe(e,t(),r,s),n)}function Pi(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Ss(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Ss(e,i,l,r[i],s,a,t)}}function xi(e){let t,s;return!xe()||!(t=b.registry.get(s=vi()))?e():(b.completed&&b.completed.add(t),b.registry.delete(s),t)}function xe(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function _i(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Ts(e,t,s){const n=t.trim().split(/\s+/);for(let r=0,a=n.length;r<a;r++)e.classList.toggle(n[r],s)}function Ss(e,t,s,n,r,a,i){let l,c,u,f,d;if(t==="style")return Si(e,s,n);if(t==="classList")return Ti(e,s,n);if(s===n)return n;if(t==="ref")a||s(e);else if(t.slice(0,3)==="on:"){const g=t.slice(3);n&&e.removeEventListener(g,n,typeof n!="function"&&n),s&&e.addEventListener(g,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const g=t.slice(10);n&&e.removeEventListener(g,n,!0),s&&e.addEventListener(g,s,!0)}else if(t.slice(0,2)==="on"){const g=t.slice(2).toLowerCase(),E=di.has(g);if(!E&&n){const S=Array.isArray(n)?n[0]:n;e.removeEventListener(g,S)}(E||s)&&(mn(e,g,s,E),E&&hn([g]))}else if(t.slice(0,5)==="attr:")Nt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")Ai(e,t.slice(5),s);else if((d=t.slice(0,5)==="prop:")||(u=oi.has(t))||!r&&((f=ui(t,e.tagName))||(c=ii.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(d)t=t.slice(5),c=!0;else if(xe(e))return s;t==="class"||t==="className"?gn(e,s):l&&!c&&!u?e[_i(t)]=s:e[f||t]=s}else{const g=r&&t.indexOf(":")>-1&&hi[t.split(":")[0]];g?yi(e,g,t,s):Nt(e,li[t]||t,s)}return s}function yn(e){if(b.registry&&b.events&&b.events.find(([c,u])=>u===e))return;let t=e.target;const s=`$$${e.type}`,n=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),i=()=>{const c=t[s];if(c&&!t.disabled){const u=t[`${s}Data`];if(u!==void 0?c.call(t,u,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},l=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),b.registry&&!b.done&&(b.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let u=0;u<c.length-2&&(t=c[u],!!i());u++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function Xe(e,t,s,n,r){const a=xe(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let u=0;u<s.length;u++){const f=s[u];f.nodeType===8&&f.data.slice(0,2)==="!$"?f.remove():c.push(f)}s=c}for(;typeof s=="function";)s=s();if(t===s)return s;const i=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,i==="string"||i==="number"){if(a||i==="number"&&(t=t.toString(),t===s))return s;if(l){let c=s[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),s=ve(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||i==="boolean"){if(a)return s;s=ve(e,s,n)}else{if(i==="function")return me(()=>{let c=t();for(;typeof c=="function";)c=c();s=Xe(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],u=s&&Array.isArray(s);if(Wt(c,t,s,r))return me(()=>s=Xe(e,c,s,n,!0)),()=>s;if(a){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let f=c[0];if(f.parentNode!==e)return s;const d=[f];for(;(f=f.nextSibling)!==n;)d.push(f);return s=d}if(c.length===0){if(s=ve(e,s,n),l)return s}else u?s.length===0?Ps(e,c,n):mi(e,s,c):(s&&ve(e),Ps(e,c));s=c}else if(t.nodeType){if(a&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=ve(e,s,n,t);ve(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function Wt(e,t,s,n){let r=!1;for(let a=0,i=t.length;a<i;a++){let l=t[a],c=s&&s[e.length],u;if(!(l==null||l===!0||l===!1))if((u=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=Wt(e,l,c)||r;else if(u==="function")if(n){for(;typeof l=="function";)l=l();r=Wt(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const f=String(l);c&&c.nodeType===3&&c.data===f?e.push(c):e.push(document.createTextNode(f))}}return r}function Ps(e,t,s=null){for(let n=0,r=t.length;n<r;n++)e.insertBefore(t[n],s)}function ve(e,t,s,n){if(s===void 0)return e.textContent="";const r=n||document.createTextNode("");if(t.length){let a=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(r!==l){const c=l.parentNode===e;!a&&!i?c?e.replaceChild(r,l):e.insertBefore(r,s):c&&l.remove()}else a=!0}}else e.insertBefore(r,s);return[r]}function vi(){return b.getNextContextId()}var wi="http://www.w3.org/2000/svg";function An(e,t=!1){return t?document.createElementNS(wi,e):document.createElement(e)}function bi(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=As();let a,i=!!b.context;return cs(()=>{i&&(As().user=i=!1),a||(a=sn(r,()=>$(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,u]=V(!1),f=()=>u(!0);ge(d=>Lt(l,()=>c()?d():a(),null)),qe(f)}else{const c=An(e.isSVG?"g":"div",e.isSVG),u=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Lt(u,a),l.appendChild(c),e.ref&&e.ref(c),qe(()=>l.removeChild(c))}},void 0,{render:!i}),s}function Ci(e,t){const s=$(e);return $(()=>{const n=s();switch(typeof n){case"function":return Y(()=>n(t));case"string":const r=fi.has(n),a=b.context?xi():An(n,r);return En(a,t,r),a}})}function Ii(e){const[,t]=cn(e,["component"]);return Ci(()=>e.component,t)}var Ni=class{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}},Tn=class{constructor(e){this.generateIdentifier=e,this.kv=new Ni}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}},Li=class extends Tn{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t=="object"?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}};function ji(e){if("values"in Object)return Object.values(e);const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t}function ki(e,t){const s=ji(e);if("find"in s)return s.find(t);const n=s;for(let r=0;r<n.length;r++){const a=n[r];if(t(a))return a}}function Ke(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function xt(e,t){return e.indexOf(t)!==-1}function xs(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var Di=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return ki(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Oi=e=>Object.prototype.toString.call(e).slice(8,-1),Sn=e=>typeof e>"u",Gi=e=>e===null,Ze=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Yt=e=>Ze(e)&&Object.keys(e).length===0,Ee=e=>Array.isArray(e),Ri=e=>typeof e=="string",Mi=e=>typeof e=="number"&&!isNaN(e),Bi=e=>typeof e=="boolean",Ui=e=>e instanceof RegExp,et=e=>e instanceof Map,tt=e=>e instanceof Set,Pn=e=>Oi(e)==="Symbol",Fi=e=>e instanceof Date&&!isNaN(e.valueOf()),qi=e=>e instanceof Error,_s=e=>typeof e=="number"&&isNaN(e),Ki=e=>Bi(e)||Gi(e)||Sn(e)||Mi(e)||Ri(e)||Pn(e),Vi=e=>typeof e=="bigint",Qi=e=>e===1/0||e===-1/0,Hi=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),zi=e=>e instanceof URL,xn=e=>e.replace(/\./g,"\\."),Vt=e=>e.map(String).map(xn).join("."),Ye=e=>{const t=[];let s="";for(let r=0;r<e.length;r++){let a=e.charAt(r);if(a==="\\"&&e.charAt(r+1)==="."){s+=".",r++;continue}if(a==="."){t.push(s),s="";continue}s+=a}const n=s;return t.push(n),t};function re(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var _n=[re(Sn,"undefined",()=>null,()=>{}),re(Vi,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),re(Fi,"Date",e=>e.toISOString(),e=>new Date(e)),re(qi,"Error",(e,t)=>{const s={name:e.name,message:e.message};return t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s},(e,t)=>{const s=new Error(e.message);return s.name=e.name,s.stack=e.stack,t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s}),re(Ui,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),re(tt,"set",e=>[...e.values()],e=>new Set(e)),re(et,"map",e=>[...e.entries()],e=>new Map(e)),re(e=>_s(e)||Qi(e),"number",e=>_s(e)?"NaN":e>0?"Infinity":"-Infinity",Number),re(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),re(zi,"URL",e=>e.toString(),e=>new URL(e))];function Bt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var vn=Bt((e,t)=>Pn(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,s)=>{const n=s.symbolRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),$i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),wn=Bt(Hi,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=$i[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function bn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Cn=Bt(bn,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const s=t.classRegistry.getAllowedProps(e.constructor);if(!s)return{...e};const n={};return s.forEach(r=>{n[r]=e[r]}),n},(e,t,s)=>{const n=s.classRegistry.getValue(t[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),e)}),In=Bt((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,s)=>{const n=s.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),Wi=[Cn,vn,In,wn],vs=(e,t)=>{const s=xs(Wi,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=xs(_n,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Nn={};_n.forEach(e=>{Nn[e.annotation]=e});var Yi=(e,t,s)=>{if(Ee(t))switch(t[0]){case"symbol":return vn.untransform(e,t,s);case"class":return Cn.untransform(e,t,s);case"custom":return In.untransform(e,t,s);case"typed-array":return wn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=Nn[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},we=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const s=e.keys();for(;t>0;)s.next(),t--;return s.next().value};function Ln(e){if(xt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(xt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(xt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var Ji=(e,t)=>{Ln(t);for(let s=0;s<t.length;s++){const n=t[s];if(tt(e))e=we(e,+n);else if(et(e)){const r=+n,a=+t[++s]==0?"key":"value",i=we(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},Jt=(e,t,s)=>{if(Ln(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(Ee(n)){const l=+i;n=n[l]}else if(Ze(n))n=n[i];else if(tt(n)){const l=+i;n=we(n,l)}else if(et(n)){if(a===t.length-2)break;const c=+i,u=+t[++a]==0?"key":"value",f=we(n,c);switch(u){case"key":n=f;break;case"value":n=n.get(f);break}}}const r=t[t.length-1];if(Ee(n)?n[+r]=s(n[+r]):Ze(n)&&(n[r]=s(n[r])),tt(n)){const a=we(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(et(n)){const a=+t[t.length-2],i=we(n,a);switch(+r==0?"key":"value"){case"key":{const c=s(i);n.set(c,n.get(i)),c!==i&&n.delete(i);break}case"value":{n.set(i,s(n.get(i)));break}}}return e};function Xt(e,t,s=[]){if(!e)return;if(!Ee(e)){Ke(e,(a,i)=>Xt(a,t,[...s,...Ye(i)]));return}const[n,r]=e;r&&Ke(r,(a,i)=>{Xt(a,t,[...s,...Ye(i)])}),t(n,s)}function Xi(e,t,s){return Xt(t,(n,r)=>{e=Jt(e,r,a=>Yi(a,n,s))}),e}function Zi(e,t){function s(n,r){const a=Ji(e,Ye(r));n.map(Ye).forEach(i=>{e=Jt(e,i,()=>a)})}if(Ee(t)){const[n,r]=t;n.forEach(a=>{e=Jt(e,Ye(a),()=>e)}),r&&Ke(r,s)}else Ke(t,s);return e}var eo=(e,t)=>Ze(e)||Ee(e)||et(e)||tt(e)||bn(e,t);function to(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function so(e,t){const s={};let n;return e.forEach(r=>{if(r.length<=1)return;t||(r=r.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...i]=r;a.length===0?n=i.map(Vt):s[Vt(a)]=i.map(Vt)}),n?Yt(s)?[n]:[n,s]:Yt(s)?void 0:s}var jn=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=Ki(e);if(!l){to(e,r,t);const E=i.get(e);if(E)return n?{transformedValue:null}:E}if(!eo(e,s)){const E=vs(e,s),S=E?{transformedValue:E.value,annotations:[E.type]}:{transformedValue:e};return l||i.set(e,S),S}if(xt(a,e))return{transformedValue:null};const c=vs(e,s),u=(c==null?void 0:c.value)??e,f=Ee(u)?[]:{},d={};Ke(u,(E,S)=>{if(S==="__proto__"||S==="constructor"||S==="prototype")throw new Error(`Detected property ${S}. This is a prototype pollution risk, please remove it from your object.`);const x=jn(E,t,s,n,[...r,S],[...a,e],i);f[S]=x.transformedValue,Ee(x.annotations)?d[S]=x.annotations:Ze(x.annotations)&&Ke(x.annotations,(A,T)=>{d[xn(S)+"."+T]=A})});const g=Yt(d)?{transformedValue:f,annotations:c?[c.type]:void 0}:{transformedValue:f,annotations:c?[c.type,d]:d};return l||i.set(e,g),g};function kn(e){return Object.prototype.toString.call(e).slice(8,-1)}function ws(e){return kn(e)==="Array"}function no(e){if(kn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function ro(e,t,s,n,r){const a={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=s),r&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function Zt(e,t={}){if(ws(e))return e.map(r=>Zt(r,t));if(!no(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(ws(t.props)&&!t.props.includes(a))return r;const i=e[a],l=Zt(i,t);return ro(r,a,l,e,t.nonenumerable),r},{})}var U=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Li,this.symbolRegistry=new Tn(t=>t.description??""),this.customTransformerRegistry=new Di,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=jn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=so(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=Zt(t);return s!=null&&s.values&&(n=Xi(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=Zi(n,s.referentialEqualities)),n}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};U.defaultInstance=new U;U.serialize=U.defaultInstance.serialize.bind(U.defaultInstance);U.deserialize=U.defaultInstance.deserialize.bind(U.defaultInstance);U.stringify=U.defaultInstance.stringify.bind(U.defaultInstance);U.parse=U.defaultInstance.parse.bind(U.defaultInstance);U.registerClass=U.defaultInstance.registerClass.bind(U.defaultInstance);U.registerSymbol=U.defaultInstance.registerSymbol.bind(U.defaultInstance);U.registerCustom=U.defaultInstance.registerCustom.bind(U.defaultInstance);U.allowErrorProps=U.defaultInstance.allowErrorProps.bind(U.defaultInstance);var Dn=U.serialize,ao=U.stringify;function io(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function oo(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function lo({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function co({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function uo(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var fo=(e,t=!1)=>{const{json:s}=Dn(e);return JSON.stringify(s,null,t?2:void 0)},yt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,ho=(e,t)=>e.queryHash.localeCompare(t.queryHash),On=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,go=(e,t)=>yt(e)===yt(t)?On(e,t):yt(e)>yt(t)?1:-1,mo={status:go,"query hash":ho,"last updated":On},At=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,Gn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,Eo=(e,t)=>At(e)===At(t)?Gn(e,t):At(e)>At(t)?1:-1,po={status:Eo,"last updated":Gn},yo=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),Ao=()=>{const[e,t]=V("dark");return tn(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)");t(s.matches?"dark":"light");const n=r=>{t(r.matches?"dark":"light")};s.addEventListener("change",n),qe(()=>s.removeEventListener("change",n))}),e},ze=(e,t,s)=>{if(t.length===0)return s;if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.set(t[0],s),n;const[r,...a]=t;return n.set(r,ze(n.get(r),a,s)),n}if(e instanceof Set){const n=ze(Array.from(e),t,s);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=ze(n[r],a,s),n}if(e instanceof Object){const n={...e};if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=ze(n[r],a,s),n}return e},$e=(e,t)=>{if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.delete(t[0]),s;const[n,...r]=t;return s.set(n,$e(s.get(n),r)),s}if(e instanceof Set){const s=$e(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((a,i)=>i.toString()!==t[0]);const[n,...r]=t;return s[n]=$e(s[n],r),s}if(e instanceof Object){const s={...e};if(t.length===1)return delete s[t[0]],s;const[n,...r]=t;return s[n]=$e(s[n],r),s}return e},Rn=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const n=document.createElement("style"),r=document.createTextNode("");n.appendChild(r),n.id="_goober",n.setAttribute("nonce",e),t?t.appendChild(n):document.head.appendChild(n)},be,st,nt,rt,Se,at,Ce,Ie,Ne,Le,je,it,ke,ot,Is,To=(Is=class{constructor(e){M(this,be);M(this,st);M(this,nt);M(this,rt);M(this,Se,!1);M(this,at);M(this,Ce);M(this,Ie);M(this,Ne);M(this,Le);M(this,je);M(this,it);M(this,ke);M(this,ot);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:u,shadowDOMTarget:f,hideDisabledQueries:d}=e;G(this,be,V(t)),G(this,nt,s),G(this,rt,n),G(this,st,r),G(this,at,u),G(this,Ce,f),G(this,Ie,V(a)),G(this,Ne,V(i)),G(this,Le,V(l)),G(this,je,V(c)),G(this,it,V(d))}setButtonPosition(e){v(this,Ie)[1](e)}setPosition(e){v(this,Ne)[1](e)}setInitialIsOpen(e){v(this,Le)[1](e)}setErrorTypes(e){v(this,je)[1](e)}setClient(e){v(this,be)[1](e)}mount(e){if(v(this,Se))throw new Error("Devtools is already mounted");const t=fn(()=>{const s=this,[n]=v(this,Ie),[r]=v(this,Ne),[a]=v(this,Le),[i]=v(this,je),[l]=v(this,it),[c]=v(this,be);let u;return v(this,ke)?u=v(this,ke):(u=un(()=>Promise.resolve().then(()=>require("./NCMVHL6D-C0TW9XJH.cjs"))),G(this,ke,u)),Rn(v(this,at),v(this,Ce)),ds(u,fs({get queryFlavor(){return v(s,nt)},get version(){return v(s,rt)},get onlineManager(){return v(s,st)},get shadowDOMTarget(){return v(s,Ce)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()}}))},e);G(this,Se,!0),G(this,ot,t)}unmount(){var e;if(!v(this,Se))throw new Error("Devtools is not mounted");(e=v(this,ot))==null||e.call(this),G(this,Se,!1)}},be=new WeakMap,st=new WeakMap,nt=new WeakMap,rt=new WeakMap,Se=new WeakMap,at=new WeakMap,Ce=new WeakMap,Ie=new WeakMap,Ne=new WeakMap,Le=new WeakMap,je=new WeakMap,it=new WeakMap,ke=new WeakMap,ot=new WeakMap,Is),De,lt,ct,ut,Pe,dt,Oe,Ge,Re,Me,Be,ft,Ue,Fe,ht,Ns,So=(Ns=class{constructor(e){M(this,De);M(this,lt);M(this,ct);M(this,ut);M(this,Pe,!1);M(this,dt);M(this,Oe);M(this,Ge);M(this,Re);M(this,Me);M(this,Be);M(this,ft);M(this,Ue);M(this,Fe);M(this,ht);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:u,shadowDOMTarget:f,onClose:d,hideDisabledQueries:g}=e;G(this,De,V(t)),G(this,ct,s),G(this,ut,n),G(this,lt,r),G(this,dt,u),G(this,Oe,f),G(this,Ge,V(a)),G(this,Re,V(i)),G(this,Me,V(l)),G(this,Be,V(c)),G(this,ft,V(g)),G(this,Ue,V(d))}setButtonPosition(e){v(this,Ge)[1](e)}setPosition(e){v(this,Re)[1](e)}setInitialIsOpen(e){v(this,Me)[1](e)}setErrorTypes(e){v(this,Be)[1](e)}setClient(e){v(this,De)[1](e)}setOnClose(e){v(this,Ue)[1](()=>e)}mount(e){if(v(this,Pe))throw new Error("Devtools is already mounted");const t=fn(()=>{const s=this,[n]=v(this,Ge),[r]=v(this,Re),[a]=v(this,Me),[i]=v(this,Be),[l]=v(this,ft),[c]=v(this,De),[u]=v(this,Ue);let f;return v(this,Fe)?f=v(this,Fe):(f=un(()=>Promise.resolve().then(()=>require("./2AITGKQY-DXm3iqhg.cjs"))),G(this,Fe,f)),Rn(v(this,dt),v(this,Oe)),ds(f,fs({get queryFlavor(){return v(s,ct)},get version(){return v(s,ut)},get onlineManager(){return v(s,lt)},get shadowDOMTarget(){return v(s,Oe)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get onClose(){return u()}}))},e);G(this,Pe,!0),G(this,ht,t)}unmount(){var e;if(!v(this,Pe))throw new Error("Devtools is not mounted");(e=v(this,ht))==null||e.call(this),G(this,Pe,!1)}},De=new WeakMap,lt=new WeakMap,ct=new WeakMap,ut=new WeakMap,Pe=new WeakMap,dt=new WeakMap,Oe=new WeakMap,Ge=new WeakMap,Re=new WeakMap,Me=new WeakMap,Be=new WeakMap,ft=new WeakMap,Ue=new WeakMap,Fe=new WeakMap,ht=new WeakMap,Ns);function Po(e){const t=P.useQueryClient(e.client),s=z.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:u}=e,[f]=z.useState(new To({client:t,queryFlavor:"React Query",version:"5",onlineManager:P.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:u}));return z.useEffect(()=>{f.setClient(t)},[t,f]),z.useEffect(()=>{n&&f.setButtonPosition(n)},[n,f]),z.useEffect(()=>{r&&f.setPosition(r)},[r,f]),z.useEffect(()=>{f.setInitialIsOpen(a||!1)},[a,f]),z.useEffect(()=>{f.setErrorTypes(i||[])},[i,f]),z.useEffect(()=>(s.current&&f.mount(s.current),()=>{f.unmount()}),[f]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function xo(e){const t=P.useQueryClient(e.client),s=z.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i}=e,[l]=z.useState(new So({client:t,queryFlavor:"React Query",version:"5",onlineManager:P.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:n,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:i}));return z.useEffect(()=>{l.setClient(t)},[t,l]),z.useEffect(()=>{l.setOnClose(e.onClose??(()=>{}))},[e.onClose,l]),z.useEffect(()=>{l.setErrorTypes(n||[])},[n,l]),z.useEffect(()=>(s.current&&l.mount(s.current),()=>{l.unmount()}),[l]),o.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:s})}var bs=process.env.NODE_ENV!=="development"?function(){return null}:Po;process.env.NODE_ENV;const Mn=Q.atom(""),_o=()=>{_.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),_.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"}),_.registerChaiFeatureFlag("enable-ai-chat-panel",{description:"Enable AI chat panel"})},vo=()=>{const e=k(),t=j();return P.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},wo=()=>{const{data:e}=X(),{data:t}=ue(),{data:s}=ye(),n=k(),r=j(),a=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]);return P.useMutation({mutationFn:async({block:i})=>r(n,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:i,lang:(t==null?void 0:t.lang)||a,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:a,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id}}})})},Bn=()=>{const[,e]=ee();return h.useCallback((t,s)=>{const r=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});r&&a.set("lang",r),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),s==null||s()},[e])},Un=()=>{const e=Bn();return h.useCallback(({pageId:t})=>{e(t)},[e])},bo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-BfDE0iUu.cjs"))),Co=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-BUen2a0-.cjs"))),Io=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-DLSf7QAN.cjs"))),No=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-DDnJlhVc.cjs")));_o();Jn.loadWebBlocks();_.registerChaiTopBar(ia);ja();_.registerChaiMediaManager(bo);_.registerChaiSaveToLibrary(Co);const Lo={role:"",permissions:null},Cs=e=>{const{data:t}=pa();mr();const s=Ot(),{data:n=Lo,isFetching:r}=Qs(),{data:a,isFetching:i}=de(),{data:l,isFetching:c}=vo(),{data:u,isFetching:f}=ye(),d=r||i||c||f,[g]=ee(),E=g.get("page"),{data:S}=X(),{data:x,isFetching:A}=ua(),{blocks:T}=ca(x),{lockingStatus:C,pageLock:N}=Ae(),{data:R,isFetching:K}=Ks(),O=oa(),{onSave:ie}=ya(),{mutateAsync:oe}=wo(),{getPartialBlocks:q,getPartialBlockBlocks:I}=Aa(),{mutateAsync:L}=Ir(),{mutateAsync:W}=Vs(),H=Un(),[ne,mt]=h.useState(!1),le=h.useRef([]),_e=h.useMemo(()=>p.get(u,"theme",{})||{},[u]),Te=p.isEmpty(C)&&(N==null?void 0:N.status)==="editing",Kn=(N==null?void 0:N.status)==="checking",hs=A||Kn||K;le.current=T;const[Vn]=Q.useAtom(Mn);h.useEffect(()=>{const Z=()=>{document.hidden?mt(!0):mt(!1)};return window.addEventListener("visibilitychange",Z),()=>window.removeEventListener("visibilitychange",Z)},[]);const Qn=h.useMemo(()=>{const Z={};return n&&(Z.permissions=p.get(n,"permissions",null),Z.role=p.get(n,"role","user")),Z},[n]),Hn=h.useMemo(()=>t==null?void 0:t.some(Z=>Z.isSiteLibrary),[t]),zn=h.useCallback(async(Z,Et)=>await L({pageType:Z,query:Et}),[L]);return o.jsxs(o.Fragment,{children:[hs&&o.jsx(os,{className:d?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(w.Loader,{className:`animate-spin text-primary ${d?"h-6 w-6":"h-5 w-5"}`})}),Vn&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:o.jsx(w.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(No,{})}),o.jsx(_.ChaiBuilderEditor,{_tempProps:{librarySite:Hn},gotoPage:H,collections:l??[],getBlockAsyncProps:oe,pageExternalData:R,themePresets:e.themePresets??[],pageId:S==null?void 0:S.id,loading:A,fallbackLang:s,languages:(u==null?void 0:u.languages)||[],brandingOptions:(u==null?void 0:u.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!ne&&Te&&(e.autoSave??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:I,getPartialBlocks:q,blocks:A?[]:T,theme:p.cloneDeep(_e),pageTypes:a,searchPageTypeItems:zn,askAiCallBack:O,onSave:async({blocks:Z,theme:Et,needTranslations:$n})=>{if(!E)return!0;le.current=Z;const gs=[...Z];return await ie({page:E,blocks:gs,needTranslations:$n}),le.current=gs,p.isEqual(Et,_e)||await W({settings:{theme:Et}}),!0},themePanelComponent:Io,...Qn}),o.jsxs("div",{children:[o.jsx(yr,{isFetchingPage:hs}),o.jsx(Ar,{})]})]})},jo=new P.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),ko=e=>{const[,t]=jt(),[s,n]=h.useState(!1);return h.useEffect(()=>(t(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","websocket","getLoggedInUser","features","currentUser"])),setTimeout(()=>{n(!0)},200),()=>{n(!1),t({})}),[e,t]),s?p.get(e,"hasReactQueryProvider",!1)===!0?o.jsxs(o.Fragment,{children:[o.jsx(Cs,{...e}),o.jsx(bs,{})]}):o.jsxs(P.QueryClientProvider,{client:jo,children:[o.jsx(Cs,{...e}),o.jsx(bs,{})]}):o.jsx("div",{})},Do=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-D_iF9Sm3.cjs")));function Fn({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=z.useState(!1);return o.jsxs(m.Popover,{open:r,onOpenChange:a,children:[o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsx(m.PopoverTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,disabled:n,children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:o.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),o.jsx(m.TooltipContent,{children:"Add field"})]}),r&&o.jsx(z.Suspense,{children:o.jsx(Do,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const Oo=()=>{const{savePageAsync:e}=_.useSavePage(),t=P.useQueryClient();return h.useCallback(async()=>{await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t])},Go=()=>{const e=P.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},Ro=()=>{const e=k(),t=j(),{data:s}=ue(),n=P.useQueryClient();return P.useMutation({mutationFn:async r=>{if(!(s!=null&&s.id))throw new Error("No active page found");return await t(`${e}`,{action:y.UPDATE_PAGE_METADATA,data:{id:s.id,metadata:r}})},onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]}),n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})},Mo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-BfDE0iUu.cjs"))),Bo=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:i}=_.useTranslation(),[l,c]=h.useState(!1),u=()=>{a||c(!0)},f=()=>{c(!1)},d=S=>{const x=Array.isArray(S)?S[0]:S;x!=null&&x.url&&s(p.pick(x,["url","id"])),c(!1)},g=()=>{s({url:"",id:""})},E=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return o.jsxs("div",{className:`w-full ${n}`,children:[t?o.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[E?o.jsx("div",{className:"flex h-12 items-center bg-gray-100 px-4",children:o.jsx("p",{className:"text-xs text-gray-500",children:t})}):o.jsx("img",{onClick:u,src:t,alt:i("Selected image"),className:"h-auto max-h-[100px] w-full bg-gray-100 object-contain"}),o.jsxs("div",{className:"absolute right-2 top-2 flex gap-2",children:[o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:g,disabled:a,children:E?o.jsx(w.X,{className:"h-4 w-4"}):o.jsx(w.Trash2,{className:"h-4 w-4"})}),!E&&o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:u,disabled:a,children:o.jsx(w.ImageIcon,{className:"h-4 w-4"})})]})]}):o.jsx("div",{className:`flex cursor-pointer items-center justify-center rounded-md border border-dashed p-6 ${a?"cursor-not-allowed opacity-50":"hover:border-gray-400"}`,onClick:u,children:o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx(w.ImageIcon,{className:"h-10 w-10 text-gray-400"}),o.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),o.jsx(m.Dialog,{open:l,onOpenChange:c,children:o.jsxs(m.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[o.jsxs(m.DialogHeader,{className:"hidden border-b px-4 py-2",children:[o.jsx(m.DialogTitle,{children:i("Select Image")}),o.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:f,children:o.jsx(w.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(h.Suspense,{children:o.jsx(Mo,{close:f,onSelect:d,mode:"image",assetId:e})})})]})})]})},Uo=h.createContext(null),Qt={didCatch:!1,error:null};class qn extends h.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Qt}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var s,n,r=arguments.length,a=new Array(r),i=0;i<r;i++)a[i]=arguments[i];(s=(n=this.props).onReset)===null||s===void 0||s.call(n,{args:a,reason:"imperative-api"}),this.setState(Qt)}}componentDidCatch(t,s){var n,r;(n=(r=this.props).onError)===null||n===void 0||n.call(r,t,s)}componentDidUpdate(t,s){const{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&s.error!==null&&Fo(t.resetKeys,r)){var a,i;(a=(i=this.props).onReset)===null||a===void 0||a.call(i,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(Qt)}}render(){const{children:t,fallbackRender:s,FallbackComponent:n,fallback:r}=this.props,{didCatch:a,error:i}=this.state;let l=t;if(a){const c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof s=="function")l=s(c);else if(n)l=h.createElement(n,c);else if(r!==void 0)l=r;else throw i}return h.createElement(Uo.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},l)}}function Fo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((s,n)=>!Object.is(s,t[n]))}const qo=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),es=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};try{return{isValid:!0,parsed:JSON.parse(e),error:null,placeholders:[]}}catch{}const t=/{{([^{}]+)}}/g,s=[];let n=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],i=r.index,l=`"__placeholder_${s.length}__"`;s.push({original:a,replaced:l,position:i}),n=n.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(n),error:null,placeholders:s}}catch(a){const i=a,l=i.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let u,f;if(c!==void 0){const d=n.substring(0,c).split(`
2
- `);u=d.length,f=d[d.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:u,column:f,position:c}}}},Ko=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(qo(i),"g");n=n.replace(l,r)}),n},Vo=(e,t)=>{if(!e)return"";let s=JSON.stringify(e,null,2);const n=/{{([^{}]+)}}/g;let r;for(;(r=n.exec(s))!==null;){const a=r[1],i=p.get(t,a,null);s=s.replace(r[0],i)}return s},Qo=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-D-S-SwbU.cjs"))),Ho=({value:e,onChange:t,disabled:s=!1,readOnly:n=!1,placeholder:r="Enter JSON",rows:a=6,id:i="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:u,copyJsonLDFromDefaultPage:f})=>{const[d,g]=h.useState("edit"),[E,S]=h.useState(null),[x,A]=h.useState(""),T=h.useRef(null),[C]=jt(),N=i==="jsonLD"&&p.get(C,"features.sharedJsonLD",!1),R=i==="jsonLD"&&!u&&!!f;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const K=q=>{if(n)return;const I=q.target.value;t(I)},O=q=>{if(q.key==="Tab"){q.preventDefault();const I=q.currentTarget,L=I.selectionStart,W=I.selectionEnd;if(L!==W){const ne=e.substring(L,W).split(`
3
- `);if(q.shiftKey){const le=ne.map(Te=>Te.startsWith(" ")?Te.substring(2):Te).join(`
4
- `),_e=e.substring(0,L)+le+e.substring(W);t(_e),setTimeout(()=>{I.selectionStart=L,I.selectionEnd=L+le.length},0)}else{const le=ne.map(Te=>` ${Te}`).join(`
5
- `),_e=e.substring(0,L)+le+e.substring(W);t(_e),setTimeout(()=>{I.selectionStart=L,I.selectionEnd=L+le.length},0)}}else{const H=e.substring(0,L)+" "+e.substring(W);t(H),setTimeout(()=>{I.selectionStart=I.selectionEnd=L+2},0)}}};h.useEffect(()=>{const q=es(e);if(q.isValid)if(S(null),q.parsed){const I=Vo(q.parsed,l);A(I)}else A("");else S(q.error),A("")},[e,l]);const ie=()=>{const q=es(e);if(q.isValid&&q.parsed){const I=Ko(q.parsed,q.placeholders);t(I)}},oe=()=>{E!=null&&E.position&&T.current&&(T.current.focus(),T.current.setSelectionRange(E.position,E.position+1))};return o.jsx(qn,{fallback:o.jsx("div",{children:"Some error"}),children:o.jsx("div",{className:"space-y-2",children:o.jsxs(m.Tabs,{value:d,onValueChange:g,className:"w-full",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs(m.TabsList,{className:"w-max",children:[o.jsxs(m.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[o.jsx(w.Code,{className:"h-4 w-4"}),o.jsx("span",{children:"Edit"})]}),o.jsxs(m.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||E!==null||R,children:[o.jsx(w.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),N&&o.jsxs(m.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||E!==null,children:[o.jsx(w.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),R?null:d==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(Fn,{dataType:"value",data:l??{},onSelect:q=>c&&c(q,i)})})]}),o.jsxs(m.TabsContent,{value:"edit",className:"relative mt-0",children:[!R&&d==="edit"&&o.jsx(Gt,{content:"Format JSON",side:"right",showTooltip:!s&&!E,children:o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",onClick:ie,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||E!==null,children:o.jsx(w.FileCode2,{})})}),R?o.jsx("div",{className:"flex h-40 items-center justify-center rounded-md bg-black/20",children:o.jsxs("div",{className:"flex max-w-[400px] flex-col items-center gap-2 rounded-md bg-white p-4 shadow-lg",children:[o.jsx("div",{className:"max-w-xl text-center text-xs text-gray-500",children:"JSON-LD for is not added for selected language. JSON LD will be used from default language."}),o.jsxs(m.Button,{type:"button",variant:"default",size:"sm",onClick:f,children:[o.jsx(w.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(m.Textarea,{ref:T,id:i,name:i,className:`rounded-md border border-input text-xs ${E?"border-red-500":""}`,onChange:K,onKeyDown:O,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),E&&o.jsxs(m.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(w.AlertTriangle,{className:"h-4 w-4"}),o.jsxs(m.AlertDescription,{className:"flex flex-col",children:[o.jsx("span",{className:"font-medium",children:"Invalid JSON"}),o.jsx("span",{className:"text-sm",children:E.message}),E.line&&E.column&&o.jsxs("span",{className:"text-sm",children:["Error at line ",E.line,", column ",E.column]}),o.jsx(m.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:oe,children:"Show position"})]})]})]}),o.jsxs(m.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(m.Textarea,{rows:a,value:x,readOnly:!0,className:"cursor-default bg-muted font-mono text-sm"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This is how the JSON will look after placeholder substitution."})]}),N&&o.jsx(m.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(Qo,{})})})]})})})};if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=ls;exports.ACTIONS=y;exports.BlurContainer=os;exports.ChaiBuilderPages=ko;exports.ChaiBuilderPagesRealtime=ks;exports.Dynamic=Ii;exports.ErrorBoundary=qn;exports.For=ei;exports.ImagePicker=Bo;exports.Index=ti;exports.LANGUAGES=Qe;exports.LanguageSwitcher=Bs;exports.Match=ri;exports.NestedPathSelector=Fn;exports.PAGES_PERMISSIONS=te;exports.PageActionsDropdown=Fs;exports.PermissionChecker=Tt;exports.Portal=bi;exports.Show=si;exports.SmartJsonInput=Ho;exports.Switch=ni;exports.Tooltip=Gt;exports.addEventListener=mn;exports.addNewLangAtom=Dt;exports.batch=Ra;exports.className=gn;exports.clearDelegatedEvents=pi;exports.convertRemToPixels=yo;exports.createComponent=ds;exports.createComputed=en;exports.createContext=qa;exports.createEffect=cs;exports.createMemo=$;exports.createRenderEffect=me;exports.createRoot=ge;exports.createSignal=V;exports.createUniqueId=Za;exports.delegateEvents=hn;exports.deleteNestedDataByPath=$e;exports.displayValue=fo;exports.getMutationStatusColor=co;exports.getPreferredColorScheme=Ao;exports.getQueryStatusColor=lo;exports.getQueryStatusColorByLabel=uo;exports.getQueryStatusLabel=io;exports.getSidedProp=oo;exports.insert=Lt;exports.memo=gi;exports.mergeProps=fs;exports.mutationSortFns=po;exports.navigateToPage=rs;exports.on=Ma;exports.onCleanup=qe;exports.onMount=tn;exports.parseJSONWithPlaceholders=es;exports.previewUrlAtom=Mn;exports.serialize=Dn;exports.setAttribute=Nt;exports.sortFns=mo;exports.splitProps=cn;exports.spread=En;exports.stringify=ao;exports.template=Ei;exports.throwConfetti=St;exports.untrack=Y;exports.updateNestedDataByPath=ze;exports.use=pn;exports.useActivePage=ue;exports.useAddGlobalSchema=da;exports.useApiUrl=k;exports.useApplySchemaToAllPages=ma;exports.useAssetsApiUrl=er;exports.useBuilderFetch=nr;exports.useBuilderPageData=Ks;exports.useChaiAuth=gt;exports.useChaiUserInfo=Gs;exports.useChangePage=Bn;exports.useChangeSlug=Gr;exports.useClearAll=Go;exports.useContext=Ka;exports.useCreatePage=Nr;exports.useCurrentPage=X;exports.useDeleteGlobalSchema=ha;exports.useDeletePage=jr;exports.useDynamicPageSelector=Os;exports.useFallbackLang=Ot;exports.useFetch=j;exports.useGotoPage=Un;exports.useIsLanguagePageCreated=ts;exports.useLanguagePages=pe;exports.useMarkAsTemplate=Dr;exports.usePageEditInfo=kt;exports.usePageLockRequestTakeOver=Rs;exports.usePageType=Us;exports.usePageTypes=de;exports.usePageUserMapping=gr;exports.usePagesProps=jt;exports.usePublishPages=is;exports.useReloadPage=Oo;exports.useRemoveSchemaFromAllPages=Ea;exports.useSearchParams=ee;exports.useTogglePageGlobalSchema=ga;exports.useTransition=Fa;exports.useUnmarkAsTemplate=Or;exports.useUnpublishPage=kr;exports.useUpdateActivePageMetadata=Ro;exports.useUpdateGlobalSchema=fa;exports.useUpdatePage=Lr;exports.useUpdateWebsiteSettings=Vs;exports.useUserRoleAndPermissions=Qs;exports.useWebsiteLanguagePages=Tr;exports.useWebsitePages=as;exports.useWebsiteSetting=ye;