domma-cms 0.36.0 → 0.36.2

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 (65) hide show
  1. package/admin/css/admin.css +1 -1
  2. package/admin/css/dashboard.css +1 -1
  3. package/admin/js/lib/card-builder.js +2 -2
  4. package/admin/js/lib/crud-tutorial.js +1 -1
  5. package/admin/js/lib/effects-builder.js +2 -2
  6. package/admin/js/lib/embed-builder.js +1 -1
  7. package/admin/js/lib/markdown-toolbar.js +15 -15
  8. package/admin/js/lib/project-quick-create.js +2 -2
  9. package/admin/js/lib/scribe-composer.js +3 -3
  10. package/admin/js/lib/shortcode-context-menu.js +6 -6
  11. package/admin/js/lib/shortcode-modal.js +1 -1
  12. package/admin/js/lib/shortcode-registry.js +1 -1
  13. package/admin/js/lib/shortcode-tags.js +1 -1
  14. package/admin/js/lib/sidebar-renderer.js +2 -2
  15. package/admin/js/lib/timeline-builder.js +2 -2
  16. package/admin/js/templates/api-endpoint-editor.html +2 -2
  17. package/admin/js/templates/block-editor.html +1 -1
  18. package/admin/js/templates/component-editor.html +4 -4
  19. package/admin/js/templates/docs/api-actions.html +11 -11
  20. package/admin/js/templates/docs/api-authentication.html +11 -11
  21. package/admin/js/templates/docs/api-collections.html +11 -11
  22. package/admin/js/templates/docs/api-layouts.html +11 -11
  23. package/admin/js/templates/docs/api-media.html +11 -11
  24. package/admin/js/templates/docs/api-navigation.html +11 -11
  25. package/admin/js/templates/docs/api-pages.html +11 -11
  26. package/admin/js/templates/docs/api-plugins.html +11 -11
  27. package/admin/js/templates/docs/api-settings.html +11 -11
  28. package/admin/js/templates/docs/api-users.html +11 -11
  29. package/admin/js/templates/docs/api-views.html +11 -11
  30. package/admin/js/templates/effects.html +752 -752
  31. package/admin/js/templates/form-editor.html +4 -4
  32. package/admin/js/templates/form-submissions.html +1 -1
  33. package/admin/js/templates/forms.html +17 -17
  34. package/admin/js/templates/my-profile.html +17 -17
  35. package/admin/js/templates/navigation.html +3 -3
  36. package/admin/js/templates/notifications.html +1 -1
  37. package/admin/js/templates/page-editor.html +3 -3
  38. package/admin/js/templates/project-detail.html +19 -19
  39. package/admin/js/templates/role-editor.html +70 -70
  40. package/admin/js/templates/roles.html +10 -10
  41. package/admin/js/templates/settings.html +6 -6
  42. package/admin/js/views/action-editor.js +1 -1
  43. package/admin/js/views/api-endpoint-editor.js +3 -3
  44. package/admin/js/views/collection-editor.js +2 -2
  45. package/admin/js/views/collection-entries.js +1 -1
  46. package/admin/js/views/component-editor.js +3 -3
  47. package/admin/js/views/form-editor.js +3 -3
  48. package/admin/js/views/form-submissions.js +1 -1
  49. package/admin/js/views/page-editor.js +4 -4
  50. package/admin/js/views/project-detail.js +1 -1
  51. package/admin/js/views/settings.js +2 -2
  52. package/bin/lib/config-merge.js +44 -44
  53. package/package.json +1 -1
  54. package/public/css/forms.css +1 -1
  55. package/public/css/site.css +1 -1
  56. package/public/js/menu-decor.mjs +1 -1
  57. package/public/js/site.js +1 -1
  58. package/server/middleware/auth.js +253 -253
  59. package/server/routes/api/auth.js +309 -309
  60. package/server/routes/api/navigation.js +42 -42
  61. package/server/routes/api/settings.js +141 -141
  62. package/server/services/email.js +167 -167
  63. package/server/services/userProfiles.js +199 -199
  64. package/server/services/users.js +302 -302
  65. package/config/connections.json.bak +0 -9
@@ -1,16 +1,16 @@
1
- function le(){I.register("bold",{viewBox:"0 0 24 24",path:"M7 5H14a3 3 0 0 1 0 6H7V5zM7 11H15a3 3 0 0 1 0 6H7V11z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("italic",{viewBox:"0 0 24 24",path:"M11 5h4M9 19h4M13 5l-2 14",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("strikethrough",{viewBox:"0 0 24 24",path:"M16 4H9a3 3 0 0 0 0 6h6a3 3 0 0 1 0 6H6M3 12h18",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("quote",{viewBox:"0 0 24 24",path:"M3 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1zM15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("eye",{viewBox:"0 0 24 24",path:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("expand",{viewBox:"0 0 24 24",path:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("columns",{viewBox:"0 0 24 24",path:"M3 4h18a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zM12 4v16",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("card",{viewBox:"0 0 24 24",paths:["M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z","M3 9h18"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("help-circle",{viewBox:"0 0 24 24",path:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10zM12 17h.01M12 13a2 2 0 0 0 2-2 2 2 0 0 0-2-2 2 2 0 0 0-2 2",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("book-open",{viewBox:"0 0 24 24",paths:["M2 4h7a2 2 0 0 1 2 2v14a2 2 0 0 0-2-2H2z","M22 4h-7a2 2 0 0 0-2 2v14a2 2 0 0 1 2-2h7z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("spacer-insert",{viewBox:"0 0 24 24",paths:["M3 8h18","M3 16h18","M12 8v8"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("icon-pick",{viewBox:"0 0 24 24",paths:["M4 4h6v6H4z","M14 4h6v6h-6z","M4 14h6v6H4z","M14 14h6v6h-6z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("colour-picker",{viewBox:"0 0 24 24",paths:["M12 2a5 5 0 0 1 5 5c0 3-5 10-5 10S7 10 7 7a5 5 0 0 1 5-5z","M12 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("btn-insert",{viewBox:"0 0 24 24",paths:["M3 7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z","M8 12h8M12 9v6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("link-shortcode",{viewBox:"0 0 24 24",paths:["M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71","M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("layout-list",{viewBox:"0 0 24 24",paths:["M3 5h18M3 9h18","M3 14h4v6H3zM9 14h12M9 17h8"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("sparkles",{viewBox:"0 0 24 24",paths:["M12 3L13.5 8.5H19L14.5 11.5L16 17L12 14L8 17L9.5 11.5L5 8.5H10.5L12 3Z","M19 3L19.7 5.3H22L20.2 6.6L20.9 9L19 7.7L17.1 9L17.8 6.6L16 5.3H18.3L19 3Z","M5 13L5.5 14.7H7L5.8 15.5L6.3 17.2L5 16.3L3.7 17.2L4.2 15.5L3 14.7H4.5L5 13Z"],stroke:"currentColor",fill:"none",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("accordion-insert",{viewBox:"0 0 24 24",paths:["M3 4h18","M3 8h18","M8 11l4 4 4-4","M3 16h18","M3 20h18"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("banner-insert",{viewBox:"0 0 24 24",paths:["M3 6h18","M3 10h18","M3 14h12"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("hero",{viewBox:"0 0 24 24",paths:["M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5z","M7 8h10M7 11h6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("text-style",{viewBox:"0 0 24 24",paths:["M4 7V5h16v2","M9 19h6","M12 5v14","M5 12h14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("css-code",{viewBox:"0 0 24 24",paths:["M9 9l-6 3 6 3","M15 9l6 3-6 3","M13 5l-2 14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("scribe-insert",{viewBox:"0 0 24 24",paths:["M4 20h3l10-10-3-3L4 17v3z","M14 7l3 3","M4 4h6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("carousel-insert",{viewBox:"0 0 24 24",paths:["M7 5h10v14H7z","M3 8h2v8H3z","M19 8h2v8h-2z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}export function wrapSelection(t,e,m){const i=t.selectionStart,s=t.selectionEnd,o=t.value,r=o.substring(i,s);r?(t.value=o.substring(0,i)+e+r+m+o.substring(s),t.selectionStart=i+e.length,t.selectionEnd=s+e.length):(t.value=o.substring(0,i)+e+m+o.substring(i),t.selectionStart=t.selectionEnd=i+e.length),t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}export function insertAtCursor(t,e){const m=t.selectionStart,i=t.value;t.value=i.substring(0,m)+e+i.substring(m),t.selectionStart=t.selectionEnd=m+e.length,t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}export function attachEditorKeybindings(t){t.addEventListener("keydown",e=>{if(e.key==="Tab"){e.preventDefault();const i=t.selectionStart;if(e.shiftKey){const s=t.value.lastIndexOf(`
2
- `,i-1)+1,o=t.value.substring(s).match(/^ {1,2}/);o&&(t.value=t.value.substring(0,s)+t.value.substring(s+o[0].length),t.selectionStart=t.selectionEnd=Math.max(s,i-o[0].length),t.dispatchEvent(new Event("input",{bubbles:!0})),E.toast("Dedented",{type:"info",duration:800}))}else t.value=t.value.substring(0,i)+" "+t.value.substring(i),t.selectionStart=t.selectionEnd=i+2,t.dispatchEvent(new Event("input",{bubbles:!0})),E.toast("Indented",{type:"info",duration:800});return}if(!(e.ctrlKey||e.metaKey))return;const m=e.key.toLowerCase();if(m==="z")e.preventDefault(),document.execCommand("undo"),E.toast("Undo",{type:"info",duration:1200});else if(m==="y")e.preventDefault(),document.execCommand("redo"),E.toast("Redo",{type:"info",duration:1200});else if(m==="x"&&t.selectionStart===t.selectionEnd){e.preventDefault();const i=t.value.lastIndexOf(`
1
+ function le(){I.register("bold",{viewBox:"0 0 24 24",path:"M7 5H14a3 3 0 0 1 0 6H7V5zM7 11H15a3 3 0 0 1 0 6H7V11z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("italic",{viewBox:"0 0 24 24",path:"M11 5h4M9 19h4M13 5l-2 14",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("strikethrough",{viewBox:"0 0 24 24",path:"M16 4H9a3 3 0 0 0 0 6h6a3 3 0 0 1 0 6H6M3 12h18",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("quote",{viewBox:"0 0 24 24",path:"M3 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1zM15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("eye",{viewBox:"0 0 24 24",path:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("expand",{viewBox:"0 0 24 24",path:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("columns",{viewBox:"0 0 24 24",path:"M3 4h18a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zM12 4v16",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("card",{viewBox:"0 0 24 24",paths:["M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z","M3 9h18"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("help-circle",{viewBox:"0 0 24 24",path:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10zM12 17h.01M12 13a2 2 0 0 0 2-2 2 2 0 0 0-2-2 2 2 0 0 0-2 2",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("book-open",{viewBox:"0 0 24 24",paths:["M2 4h7a2 2 0 0 1 2 2v14a2 2 0 0 0-2-2H2z","M22 4h-7a2 2 0 0 0-2 2v14a2 2 0 0 1 2-2h7z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("spacer-insert",{viewBox:"0 0 24 24",paths:["M3 8h18","M3 16h18","M12 8v8"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("icon-pick",{viewBox:"0 0 24 24",paths:["M4 4h6v6H4z","M14 4h6v6h-6z","M4 14h6v6H4z","M14 14h6v6h-6z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("colour-picker",{viewBox:"0 0 24 24",paths:["M12 2a5 5 0 0 1 5 5c0 3-5 10-5 10S7 10 7 7a5 5 0 0 1 5-5z","M12 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("btn-insert",{viewBox:"0 0 24 24",paths:["M3 7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z","M8 12h8M12 9v6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("link-shortcode",{viewBox:"0 0 24 24",paths:["M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71","M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("layout-list",{viewBox:"0 0 24 24",paths:["M3 5h18M3 9h18","M3 14h4v6H3zM9 14h12M9 17h8"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("sparkles",{viewBox:"0 0 24 24",paths:["M12 3L13.5 8.5H19L14.5 11.5L16 17L12 14L8 17L9.5 11.5L5 8.5H10.5L12 3Z","M19 3L19.7 5.3H22L20.2 6.6L20.9 9L19 7.7L17.1 9L17.8 6.6L16 5.3H18.3L19 3Z","M5 13L5.5 14.7H7L5.8 15.5L6.3 17.2L5 16.3L3.7 17.2L4.2 15.5L3 14.7H4.5L5 13Z"],stroke:"currentColor",fill:"none",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("accordion-insert",{viewBox:"0 0 24 24",paths:["M3 4h18","M3 8h18","M8 11l4 4 4-4","M3 16h18","M3 20h18"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("banner-insert",{viewBox:"0 0 24 24",paths:["M3 6h18","M3 10h18","M3 14h12"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("hero",{viewBox:"0 0 24 24",paths:["M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5z","M7 8h10M7 11h6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("text-style",{viewBox:"0 0 24 24",paths:["M4 7V5h16v2","M9 19h6","M12 5v14","M5 12h14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("css-code",{viewBox:"0 0 24 24",paths:["M9 9l-6 3 6 3","M15 9l6 3-6 3","M13 5l-2 14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("scribe-insert",{viewBox:"0 0 24 24",paths:["M4 20h3l10-10-3-3L4 17v3z","M14 7l3 3","M4 4h6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("carousel-insert",{viewBox:"0 0 24 24",paths:["M7 5h10v14H7z","M3 8h2v8H3z","M19 8h2v8h-2z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}export function replaceRange(t,e,d,i){if(e===d&&!i)return;const s=typeof document<"u"&&typeof t.setSelectionRange=="function"&&typeof document.execCommand=="function";let o=!1;if(s){t.focus(),t.setSelectionRange(e,d);try{o=i?document.execCommand("insertText",!1,i):document.execCommand("delete")}catch{o=!1}}if(!o){const r=t.value;t.value=r.substring(0,e)+i+r.substring(d),t.selectionStart=t.selectionEnd=e+i.length,t.dispatchEvent(new Event("input",{bubbles:!0}))}}export function wrapSelection(t,e,d){const i=t.selectionStart,s=t.selectionEnd,o=t.value.substring(i,s);replaceRange(t,i,s,e+o+d),o?t.setSelectionRange(i+e.length,s+e.length):t.setSelectionRange(i+e.length,i+e.length)}export function insertAtCursor(t,e){const d=t.selectionStart;replaceRange(t,d,d,e),t.setSelectionRange(d+e.length,d+e.length)}export function attachEditorKeybindings(t){t.addEventListener("keydown",e=>{if(e.key==="Tab"){e.preventDefault();const i=t.selectionStart;if(e.shiftKey){const s=t.value.lastIndexOf(`
2
+ `,i-1)+1,o=t.value.substring(s).match(/^ {1,2}/);o&&(replaceRange(t,s,s+o[0].length,""),t.setSelectionRange(Math.max(s,i-o[0].length),Math.max(s,i-o[0].length)),E.toast("Dedented",{type:"info",duration:800}))}else replaceRange(t,i,i," "),E.toast("Indented",{type:"info",duration:800});return}if(!(e.ctrlKey||e.metaKey))return;const d=e.key.toLowerCase();if(d==="z")e.preventDefault(),document.execCommand("undo"),E.toast("Undo",{type:"info",duration:1200});else if(d==="y")e.preventDefault(),document.execCommand("redo"),E.toast("Redo",{type:"info",duration:1200});else if(d==="x"&&t.selectionStart===t.selectionEnd){e.preventDefault();const i=t.value.lastIndexOf(`
3
3
  `,t.selectionStart-1)+1,s=t.value.indexOf(`
4
- `,t.selectionStart),o=s===-1?t.value.length:s+1;t.setSelectionRange(i,o),document.execCommand("cut"),t.dispatchEvent(new Event("input",{bubbles:!0})),E.toast("Line cut",{type:"info",duration:1200})}else if(m==="c"&&t.selectionStart===t.selectionEnd){e.preventDefault();const i=t.selectionStart,s=t.value.lastIndexOf(`
4
+ `,t.selectionStart),o=s===-1?t.value.length:s+1;t.setSelectionRange(i,o),document.execCommand("cut"),t.dispatchEvent(new Event("input",{bubbles:!0})),E.toast("Line cut",{type:"info",duration:1200})}else if(d==="c"&&t.selectionStart===t.selectionEnd){e.preventDefault();const i=t.selectionStart,s=t.value.lastIndexOf(`
5
5
  `,i-1)+1,o=t.value.indexOf(`
6
- `,i),r=o===-1?t.value.length:o+1;t.setSelectionRange(s,r),document.execCommand("copy"),t.setSelectionRange(i,i),E.toast("Line copied",{type:"info",duration:1200})}})}export function insertLine(t,e){const m=t.selectionStart,i=t.value,s=i.lastIndexOf(`
7
- `,m-1)+1,o=i.indexOf(`
8
- `,s),r=i.substring(s,o===-1?i.length:o);if(r.startsWith(e)){const l=o===-1?"":i.substring(o);t.value=i.substring(0,s)+r.substring(e.length)+l,t.selectionStart=t.selectionEnd=Math.max(s,m-e.length)}else t.value=i.substring(0,s)+e+i.substring(s),t.selectionStart=t.selectionEnd=m+e.length;t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}const Z=["activity","airpods","airport","alert-circle","alert-warning","ambulance","angry","annoyed","apartment","arch","archive","arrow-down","arrow-down-left","arrow-down-right","arrow-left","arrow-right","arrow-up","arrow-up-left","arrow-up-right","astonished","at-sign","attachment","award","badge","ban","bandage","bank","banknote","barbell","barcode","barn","baseball","basketball","battery","battery-charging","bauble","bell","bell-off","bells","bicycle","bitcoin","blood-drop","blush","bold","bone","book","book-closed","book-open","bookmark","bookmark-filled","bowling","box","boxing-glove","brain","bridge","briefcase","building","bus","cabin","cake","calculator","calendar","camera","camera-off","candy-cane","capsule","car","cart","cart-add","cash","cast","castle","chart-area","chart-bar","chart-bar-horizontal","chart-candlestick","chart-line","chart-pie","chat","chat-alt","check","check-circle","check-circle-filled","check-square","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-down","chevrons-left","chevrons-right","chevrons-up","church","circle","circle-filled","clear-format","clipboard","clipboard-check","clipboard-list","clock","close","cloud","cloud-download","cloud-drizzle","cloud-lightning","cloud-off","cloud-rain","cloud-sun","cloud-upload","code","code-block","code-inline","cog","coins","columns","comment","compass","component","confused","cool","copy","corner-down-left","corner-down-right","corner-up-left","corner-up-right","court","cpu","credit-card","crown","crutch","cry","currency-dollar","currency-euro","currency-pound","cycling","database","dead","desktop","disappointed","dna","document","document-add","document-check","document-remove","document-text","dollar-sign","dome","dot","dots-horizontal","dots-vertical","download","droplet","droplets","dumbbell","edit","embed","emoji-happy","emoji-sad","euro-sign","exclamation","expand","expressionless","external-link","eye","eye-medical","eye-off","factory","fast-forward","feather","file-code","file-text","file-zip","fill","film","filter","fire","first-aid","fishing","flag","fog","folder","folder-add","folder-minus","folder-open","folder-plus","folder-remove","football","fortress","fuel","gamepad","garage","gauge","gift","git-branch","github","globe","golf","grid","grin","growth","hard-drive","hash","haze","heading-1","heading-2","heading-3","headphones","heart","heart-eyes","heart-filled","heart-pulse","heartbeat","help-circle","holly","home","hospital","hotel","house","image","image-add","images","inbox","indent","info","info-filled","investment","invoice","italic","joy","joystick","key","kettlebell","keyboard","laptop","laugh","layers","layout","library","lighthouse","lightning","link","link-2","link-add","linkedin","list","list-bullet","list-numbered","loader","loading","lock","log-in","log-out","lungs","mail","mail-open","map","map-pin","mask","maximize","medal","medical-cross","menu","menu-alt","message-circle","message-square","mic","mic-off","microscope","minimize","minus","minus-circle","minus-square","monitor","monument","moon","moon-star","more-horizontal","more-vertical","mosque","motorcycle","mountain","mouse","mouse-pointer","move","museum","music","nerd","neutral","notification","obelisk","office","outdent","package","palette","panel-bottom","panel-left","panel-right","panel-top","paperclip","parking","pause","pause-filled","percent","phone","phone-call","phone-incoming","phone-off","phone-outgoing","piggy-bank","pill","pill-bottle","pin","play","play-circle","play-filled","plug","plus","plus-circle","plus-square","podium","pound-sign","printer","pulse","pyramid","qrcode","question","quote","racket","radio","rage","rain","rainbow","receipt","redo","refresh","refresh-cw","reindeer","rewind","road","rotate-ccw","rotate-cw","router","rss","running","sad","safe","save","scale","scale-weight","school","search","send","server","settings","share","share-2","share-alt","shield","shield-alert","shield-check","shield-x","shipping","shocked","shopping-bag","shrink","sick","sidebar-left","sidebar-right","silly","skate","ski","skip-back","skip-forward","skyscraper","sleepy","sleigh","sliders","smartphone","smartwatch","smile","snow","snowflake","snowman","sob","soccer","sort","sparkles","speaker","spinner","square","stadium","star","star-decoration","star-eyes","star-filled","stethoscope","stop","stop-filled","stopwatch","store","strikethrough","sun","sunrise","sunset","surfboard","surprised","swimming","sync","syringe","tablet","tablet-smartphone","tag","tags","target","taxi","temple","tennis","tent","terminal","test-tube","text-center","text-left","text-right","thermometer","thermometer-medical","thermometer-sun","thinking","thumb-down","thumb-up","tongue","tool","tooth","tower","train-station","trash","tree","trending-down","trending-neutral","trending-up","trophy","truck","tv","tv-minimal","twitter","type","umbrella","underline","undo","university","unlink","unlock","upload","usb","user","user-add","user-check","user-group","user-plus","user-remove","users","vaccine","van","vault","video","video-off","volleyball","volume","volume-down","volume-mute","volume-off","volume-up","wallet","warehouse","warning","warning-filled","watch","webcam","wheelchair","whistle","wifi","wifi-off","wind","windmill","wink","wreath","x","x-circle","x-circle-filled","yoga","youtube","zany","zap"];function se(t,e,m){const i=document.querySelector(".editor-spacer-picker");if(i){i.remove();return}const s=document.createElement("div");s.className="editor-spacer-picker";const o=document.createElement("div");o.className="editor-spacer-picker-label",o.textContent="Spacer height",s.appendChild(o);const r=document.createElement("div");r.className="editor-spacer-picker-row";const l=document.createElement("input");l.type="range",l.className="editor-spacer-slider",l.min="4",l.max="200",l.step="4",l.value=m;const p=document.createElement("span");p.className="editor-spacer-slider-value",p.textContent=m+"px",l.addEventListener("input",function(){p.textContent=this.value+"px"}),r.appendChild(l),r.appendChild(p),s.appendChild(r);const d=document.createElement("button");d.type="button",d.className="btn btn-primary btn-sm editor-spacer-insert-btn",d.textContent="Insert",s.appendChild(d);function f(k){!s.contains(k.target)&&k.target!==e&&(s.remove(),document.removeEventListener("click",f,!0))}d.addEventListener("click",function(){s.remove(),document.removeEventListener("click",f,!0),insertAtCursor(t,`[spacer size="${l.value}" /]
9
- `)});const n=e.getBoundingClientRect(),c=e.closest(".editor-toolbar").getBoundingClientRect();s.style.top=n.bottom-c.top+4+"px";const a=n.left-c.left;s.style.left=Math.min(a,c.width-240-8)+"px",e.closest(".editor-toolbar").appendChild(s),setTimeout(function(){document.addEventListener("click",f,!0)},0)}function ce(t,e){const m=document.querySelector(".editor-icon-picker");if(m){m.remove();return}const i=document.createElement("div");i.className="editor-icon-picker";const s=document.createElement("input");s.type="text",s.className="form-input editor-icon-picker-search",s.placeholder="Search icons\u2026",i.appendChild(s);const o=document.createElement("div");o.className="editor-icon-picker-size-row";const r=document.createElement("label");r.textContent="Size (px)";const l=document.createElement("input");l.type="number",l.className="form-input editor-icon-picker-size",l.placeholder="default",l.min="8",l.max="256",o.appendChild(r),o.appendChild(l),i.appendChild(o);const p=document.createElement("div");p.className="editor-icon-picker-grid",i.appendChild(p);function d(w){!i.contains(w.target)&&w.target!==e&&(i.remove(),document.removeEventListener("click",d,!0))}function f(w){p.textContent="";const x=w?Z.filter(S=>S.includes(w.toLowerCase())):Z;if(x.length===0){const S=document.createElement("div");S.className="editor-icon-picker-empty",S.textContent="No icons found",p.appendChild(S);return}x.forEach(function(S){const M=document.createElement("button");M.type="button",M.className="editor-icon-picker-item";const v=document.createElement("span");v.setAttribute("data-icon",S);const h=document.createElement("span");h.textContent=S,M.appendChild(v),M.appendChild(h),M.addEventListener("click",function(){i.remove(),document.removeEventListener("click",d,!0);const C=l.value.trim(),L=C?`[icon name="${S}" size="${C}" /]`:`[icon name="${S}" /]`;insertAtCursor(t,L)}),p.appendChild(M)}),Domma.icons.scan(p)}f(""),s.addEventListener("input",function(){f(this.value.trim())});const n=e.getBoundingClientRect(),c=e.closest(".editor-toolbar").getBoundingClientRect();i.style.top=n.bottom-c.top+4+"px";const a=n.left-c.left,k=320,y=c.width;i.style.left=Math.min(a,y-k-8)+"px",e.closest(".editor-toolbar").appendChild(i),requestAnimationFrame(function(){s.focus()}),setTimeout(function(){document.addEventListener("click",d,!0)},0)}function ae(t,e,m,i){const s=document.querySelector(".editor-toolbar-dropdown");if(s){s.remove();return}const o=document.createElement("div");o.className="editor-toolbar-dropdown",m.forEach(function(f){const n=document.createElement("button");if(n.type="button",n.className="editor-toolbar-dropdown-item",f.icon){const a=document.createElement("span");a.setAttribute("data-icon",f.icon),n.appendChild(a)}const c=document.createElement("span");c.textContent=f.label,n.appendChild(c),n.addEventListener("click",function(){o.remove(),document.removeEventListener("click",d,!0),J(f.action,t,e,i)}),o.appendChild(n)});const r=e.getBoundingClientRect(),l=e.closest(".editor-toolbar").getBoundingClientRect();o.style.top=r.bottom-l.top+4+"px";const p=r.left-l.left;o.style.left=Math.min(p,l.width-180-8)+"px",e.closest(".editor-toolbar").appendChild(o),Domma.icons.scan(o);function d(f){!o.contains(f.target)&&f.target!==e&&(o.remove(),document.removeEventListener("click",d,!0))}setTimeout(function(){document.addEventListener("click",d,!0)},0)}function J(t,e,m,i){const{spacerDefault:s,handlers:o}=i;if(typeof t=="function")t(e);else if(t==="block")if(o.block)o.block(e);else{const r=e.selectionStart,l='[block template="" /]';e.value=e.value.substring(0,r)+l+e.value.substring(r),e.selectionStart=e.selectionEnd=r+17,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="component")o.component?o.component(e):de(e);else if(t==="button")if(o.button)o.button(e);else{const r=e.selectionStart,l=e.selectionEnd,d=`[button href="" variant="primary"]${e.value.substring(r,l)||"Click me"}[/button]`;e.value=e.value.substring(0,r)+d+e.value.substring(l),e.selectionStart=e.selectionEnd=r+14,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="linksc")if(o.linksc)o.linksc(e);else{const r=e.selectionStart,l=e.selectionEnd,d=`[link href=""]${e.value.substring(r,l)||"Link text"}[/link]`;e.value=e.value.substring(0,r)+d+e.value.substring(l),e.selectionStart=e.selectionEnd=r+12,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="colourpick"){const r=e.selectionStart;document.getElementById("dm-colour-overlay")?.remove();const l=document.createElement("div");l.id="dm-colour-overlay",l.style.cssText="position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.5);";const p=document.createElement("div");p.style.cssText="background:var(--dm-surface,#1e1e2e);border:1px solid var(--dm-border,#3a3a5c);border-radius:12px;padding:1.75rem 2rem;display:flex;flex-direction:column;align-items:center;gap:1.25rem;min-width:260px;box-shadow:0 16px 48px rgba(0,0,0,.55);";const d=document.createElement("p");d.textContent="Colour Picker",d.style.cssText="margin:0;font-weight:700;font-size:1rem;letter-spacing:.02em;";const f=document.createElement("input");f.type="color",f.value="#000000",f.style.cssText="width:160px;height:110px;cursor:pointer;border:none;background:none;padding:0;border-radius:6px;overflow:hidden;";const n=document.createElement("div");n.style.cssText="display:flex;align-items:center;gap:.5rem;";const c=document.createElement("input");c.type="text",c.value="#000000",c.className="form-input",c.style.cssText="font-family:monospace;width:100px;text-transform:uppercase;letter-spacing:.05em;";const a=document.createElement("button");a.type="button",a.className="btn btn-ghost btn-sm",a.textContent="Copy";const k=document.createElement("button");k.type="button",k.className="btn btn-primary btn-sm",k.textContent="Insert";const y=()=>l.remove();f.addEventListener("input",()=>{c.value=f.value}),c.addEventListener("input",()=>{/^#[0-9a-f]{6}$/i.test(c.value)&&(f.value=c.value)}),a.addEventListener("click",()=>{const w=document.createElement("input");w.value=c.value,document.body.appendChild(w),w.select(),document.execCommand("copy"),w.remove(),a.textContent="Copied!",setTimeout(()=>{a.textContent="Copy"},1500)}),k.addEventListener("click",()=>{e.selectionStart=e.selectionEnd=r,insertAtCursor(e,c.value),y()}),l.addEventListener("click",w=>{w.target===l&&y()}),n.appendChild(c),n.appendChild(a),n.appendChild(k),p.appendChild(d),p.appendChild(f),p.appendChild(n),l.appendChild(p),document.body.appendChild(l)}else if(t==="link")o.link&&o.link(e);else if(t==="image")o.image&&o.image(e);else if(t==="card")if(o.card)o.card(e);else{const r=e.selectionStart,l=e.selectionEnd,d=`[card title="Card Title"]
6
+ `,i),r=o===-1?t.value.length:o+1;t.setSelectionRange(s,r),document.execCommand("copy"),t.setSelectionRange(i,i),E.toast("Line copied",{type:"info",duration:1200})}})}export function insertLine(t,e){const d=t.selectionStart,i=t.value,s=i.lastIndexOf(`
7
+ `,d-1)+1,o=i.indexOf(`
8
+ `,s);i.substring(s,o===-1?i.length:o).startsWith(e)?(replaceRange(t,s,s+e.length,""),t.setSelectionRange(Math.max(s,d-e.length),Math.max(s,d-e.length))):(replaceRange(t,s,s,e),t.setSelectionRange(d+e.length,d+e.length))}const Z=["activity","airpods","airport","alert-circle","alert-warning","ambulance","angry","annoyed","apartment","arch","archive","arrow-down","arrow-down-left","arrow-down-right","arrow-left","arrow-right","arrow-up","arrow-up-left","arrow-up-right","astonished","at-sign","attachment","award","badge","ban","bandage","bank","banknote","barbell","barcode","barn","baseball","basketball","battery","battery-charging","bauble","bell","bell-off","bells","bicycle","bitcoin","blood-drop","blush","bold","bone","book","book-closed","book-open","bookmark","bookmark-filled","bowling","box","boxing-glove","brain","bridge","briefcase","building","bus","cabin","cake","calculator","calendar","camera","camera-off","candy-cane","capsule","car","cart","cart-add","cash","cast","castle","chart-area","chart-bar","chart-bar-horizontal","chart-candlestick","chart-line","chart-pie","chat","chat-alt","check","check-circle","check-circle-filled","check-square","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-down","chevrons-left","chevrons-right","chevrons-up","church","circle","circle-filled","clear-format","clipboard","clipboard-check","clipboard-list","clock","close","cloud","cloud-download","cloud-drizzle","cloud-lightning","cloud-off","cloud-rain","cloud-sun","cloud-upload","code","code-block","code-inline","cog","coins","columns","comment","compass","component","confused","cool","copy","corner-down-left","corner-down-right","corner-up-left","corner-up-right","court","cpu","credit-card","crown","crutch","cry","currency-dollar","currency-euro","currency-pound","cycling","database","dead","desktop","disappointed","dna","document","document-add","document-check","document-remove","document-text","dollar-sign","dome","dot","dots-horizontal","dots-vertical","download","droplet","droplets","dumbbell","edit","embed","emoji-happy","emoji-sad","euro-sign","exclamation","expand","expressionless","external-link","eye","eye-medical","eye-off","factory","fast-forward","feather","file-code","file-text","file-zip","fill","film","filter","fire","first-aid","fishing","flag","fog","folder","folder-add","folder-minus","folder-open","folder-plus","folder-remove","football","fortress","fuel","gamepad","garage","gauge","gift","git-branch","github","globe","golf","grid","grin","growth","hard-drive","hash","haze","heading-1","heading-2","heading-3","headphones","heart","heart-eyes","heart-filled","heart-pulse","heartbeat","help-circle","holly","home","hospital","hotel","house","image","image-add","images","inbox","indent","info","info-filled","investment","invoice","italic","joy","joystick","key","kettlebell","keyboard","laptop","laugh","layers","layout","library","lighthouse","lightning","link","link-2","link-add","linkedin","list","list-bullet","list-numbered","loader","loading","lock","log-in","log-out","lungs","mail","mail-open","map","map-pin","mask","maximize","medal","medical-cross","menu","menu-alt","message-circle","message-square","mic","mic-off","microscope","minimize","minus","minus-circle","minus-square","monitor","monument","moon","moon-star","more-horizontal","more-vertical","mosque","motorcycle","mountain","mouse","mouse-pointer","move","museum","music","nerd","neutral","notification","obelisk","office","outdent","package","palette","panel-bottom","panel-left","panel-right","panel-top","paperclip","parking","pause","pause-filled","percent","phone","phone-call","phone-incoming","phone-off","phone-outgoing","piggy-bank","pill","pill-bottle","pin","play","play-circle","play-filled","plug","plus","plus-circle","plus-square","podium","pound-sign","printer","pulse","pyramid","qrcode","question","quote","racket","radio","rage","rain","rainbow","receipt","redo","refresh","refresh-cw","reindeer","rewind","road","rotate-ccw","rotate-cw","router","rss","running","sad","safe","save","scale","scale-weight","school","search","send","server","settings","share","share-2","share-alt","shield","shield-alert","shield-check","shield-x","shipping","shocked","shopping-bag","shrink","sick","sidebar-left","sidebar-right","silly","skate","ski","skip-back","skip-forward","skyscraper","sleepy","sleigh","sliders","smartphone","smartwatch","smile","snow","snowflake","snowman","sob","soccer","sort","sparkles","speaker","spinner","square","stadium","star","star-decoration","star-eyes","star-filled","stethoscope","stop","stop-filled","stopwatch","store","strikethrough","sun","sunrise","sunset","surfboard","surprised","swimming","sync","syringe","tablet","tablet-smartphone","tag","tags","target","taxi","temple","tennis","tent","terminal","test-tube","text-center","text-left","text-right","thermometer","thermometer-medical","thermometer-sun","thinking","thumb-down","thumb-up","tongue","tool","tooth","tower","train-station","trash","tree","trending-down","trending-neutral","trending-up","trophy","truck","tv","tv-minimal","twitter","type","umbrella","underline","undo","university","unlink","unlock","upload","usb","user","user-add","user-check","user-group","user-plus","user-remove","users","vaccine","van","vault","video","video-off","volleyball","volume","volume-down","volume-mute","volume-off","volume-up","wallet","warehouse","warning","warning-filled","watch","webcam","wheelchair","whistle","wifi","wifi-off","wind","windmill","wink","wreath","x","x-circle","x-circle-filled","yoga","youtube","zany","zap"];function se(t,e,d){const i=document.querySelector(".editor-spacer-picker");if(i){i.remove();return}const s=document.createElement("div");s.className="editor-spacer-picker";const o=document.createElement("div");o.className="editor-spacer-picker-label",o.textContent="Spacer height",s.appendChild(o);const r=document.createElement("div");r.className="editor-spacer-picker-row";const l=document.createElement("input");l.type="range",l.className="editor-spacer-slider",l.min="4",l.max="200",l.step="4",l.value=d;const m=document.createElement("span");m.className="editor-spacer-slider-value",m.textContent=d+"px",l.addEventListener("input",function(){m.textContent=this.value+"px"}),r.appendChild(l),r.appendChild(m),s.appendChild(r);const p=document.createElement("button");p.type="button",p.className="btn btn-primary btn-sm editor-spacer-insert-btn",p.textContent="Insert",s.appendChild(p);function f(v){!s.contains(v.target)&&v.target!==e&&(s.remove(),document.removeEventListener("click",f,!0))}p.addEventListener("click",function(){s.remove(),document.removeEventListener("click",f,!0),insertAtCursor(t,`[spacer size="${l.value}" /]
9
+ `)});const n=e.getBoundingClientRect(),c=e.closest(".editor-toolbar").getBoundingClientRect();s.style.top=n.bottom-c.top+4+"px";const a=n.left-c.left;s.style.left=Math.min(a,c.width-240-8)+"px",e.closest(".editor-toolbar").appendChild(s),setTimeout(function(){document.addEventListener("click",f,!0)},0)}function ce(t,e){const d=document.querySelector(".editor-icon-picker");if(d){d.remove();return}const i=document.createElement("div");i.className="editor-icon-picker";const s=document.createElement("input");s.type="text",s.className="form-input editor-icon-picker-search",s.placeholder="Search icons\u2026",i.appendChild(s);const o=document.createElement("div");o.className="editor-icon-picker-size-row";const r=document.createElement("label");r.textContent="Size (px)";const l=document.createElement("input");l.type="number",l.className="form-input editor-icon-picker-size",l.placeholder="default",l.min="8",l.max="256",o.appendChild(r),o.appendChild(l),i.appendChild(o);const m=document.createElement("div");m.className="editor-icon-picker-grid",i.appendChild(m);function p(w){!i.contains(w.target)&&w.target!==e&&(i.remove(),document.removeEventListener("click",p,!0))}function f(w){m.textContent="";const x=w?Z.filter(S=>S.includes(w.toLowerCase())):Z;if(x.length===0){const S=document.createElement("div");S.className="editor-icon-picker-empty",S.textContent="No icons found",m.appendChild(S);return}x.forEach(function(S){const M=document.createElement("button");M.type="button",M.className="editor-icon-picker-item";const k=document.createElement("span");k.setAttribute("data-icon",S);const h=document.createElement("span");h.textContent=S,M.appendChild(k),M.appendChild(h),M.addEventListener("click",function(){i.remove(),document.removeEventListener("click",p,!0);const C=l.value.trim(),L=C?`[icon name="${S}" size="${C}" /]`:`[icon name="${S}" /]`;insertAtCursor(t,L)}),m.appendChild(M)}),Domma.icons.scan(m)}f(""),s.addEventListener("input",function(){f(this.value.trim())});const n=e.getBoundingClientRect(),c=e.closest(".editor-toolbar").getBoundingClientRect();i.style.top=n.bottom-c.top+4+"px";const a=n.left-c.left,v=320,y=c.width;i.style.left=Math.min(a,y-v-8)+"px",e.closest(".editor-toolbar").appendChild(i),requestAnimationFrame(function(){s.focus()}),setTimeout(function(){document.addEventListener("click",p,!0)},0)}function ae(t,e,d,i){const s=document.querySelector(".editor-toolbar-dropdown");if(s){s.remove();return}const o=document.createElement("div");o.className="editor-toolbar-dropdown",d.forEach(function(f){const n=document.createElement("button");if(n.type="button",n.className="editor-toolbar-dropdown-item",f.icon){const a=document.createElement("span");a.setAttribute("data-icon",f.icon),n.appendChild(a)}const c=document.createElement("span");c.textContent=f.label,n.appendChild(c),n.addEventListener("click",function(){o.remove(),document.removeEventListener("click",p,!0),J(f.action,t,e,i)}),o.appendChild(n)});const r=e.getBoundingClientRect(),l=e.closest(".editor-toolbar").getBoundingClientRect();o.style.top=r.bottom-l.top+4+"px";const m=r.left-l.left;o.style.left=Math.min(m,l.width-180-8)+"px",e.closest(".editor-toolbar").appendChild(o),Domma.icons.scan(o);function p(f){!o.contains(f.target)&&f.target!==e&&(o.remove(),document.removeEventListener("click",p,!0))}setTimeout(function(){document.addEventListener("click",p,!0)},0)}function J(t,e,d,i){const{spacerDefault:s,handlers:o}=i;if(typeof t=="function")t(e);else if(t==="block")if(o.block)o.block(e);else{const r=e.selectionStart;replaceRange(e,r,r,'[block template="" /]'),e.setSelectionRange(r+17,r+17)}else if(t==="component")o.component?o.component(e):de(e);else if(t==="button")if(o.button)o.button(e);else{const r=e.selectionStart,l=e.selectionEnd,p=`[button href="" variant="primary"]${e.value.substring(r,l)||"Click me"}[/button]`;replaceRange(e,r,l,p),e.setSelectionRange(r+14,r+14)}else if(t==="linksc")if(o.linksc)o.linksc(e);else{const r=e.selectionStart,l=e.selectionEnd,p=`[link href=""]${e.value.substring(r,l)||"Link text"}[/link]`;replaceRange(e,r,l,p),e.setSelectionRange(r+12,r+12)}else if(t==="colourpick"){const r=e.selectionStart;document.getElementById("dm-colour-overlay")?.remove();const l=document.createElement("div");l.id="dm-colour-overlay",l.style.cssText="position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.5);";const m=document.createElement("div");m.style.cssText="background:var(--dm-surface,#1e1e2e);border:1px solid var(--dm-border,#3a3a5c);border-radius:12px;padding:1.75rem 2rem;display:flex;flex-direction:column;align-items:center;gap:1.25rem;min-width:260px;box-shadow:var(--dm-shadow-lg);";const p=document.createElement("p");p.textContent="Colour Picker",p.style.cssText="margin:0;font-weight:700;font-size:1rem;letter-spacing:.02em;";const f=document.createElement("input");f.type="color",f.value="#000000",f.style.cssText="width:160px;height:110px;cursor:pointer;border:none;background:none;padding:0;border-radius:6px;overflow:hidden;";const n=document.createElement("div");n.style.cssText="display:flex;align-items:center;gap:.5rem;";const c=document.createElement("input");c.type="text",c.value="#000000",c.className="form-input",c.style.cssText="font-family:monospace;width:100px;text-transform:uppercase;letter-spacing:.05em;";const a=document.createElement("button");a.type="button",a.className="btn btn-ghost btn-sm",a.textContent="Copy";const v=document.createElement("button");v.type="button",v.className="btn btn-primary btn-sm",v.textContent="Insert";const y=()=>l.remove();f.addEventListener("input",()=>{c.value=f.value}),c.addEventListener("input",()=>{/^#[0-9a-f]{6}$/i.test(c.value)&&(f.value=c.value)}),a.addEventListener("click",()=>{const w=document.createElement("input");w.value=c.value,document.body.appendChild(w),w.select(),document.execCommand("copy"),w.remove(),a.textContent="Copied!",setTimeout(()=>{a.textContent="Copy"},1500)}),v.addEventListener("click",()=>{e.selectionStart=e.selectionEnd=r,insertAtCursor(e,c.value),y()}),l.addEventListener("click",w=>{w.target===l&&y()}),n.appendChild(c),n.appendChild(a),n.appendChild(v),m.appendChild(p),m.appendChild(f),m.appendChild(n),l.appendChild(m),document.body.appendChild(l)}else if(t==="link")o.link&&o.link(e);else if(t==="image")o.image&&o.image(e);else if(t==="card")if(o.card)o.card(e);else{const r=e.selectionStart,l=e.selectionEnd,p=`[card title="Card Title"]
10
10
  ${e.value.substring(r,l)||"Content here"}
11
- [/card]`;e.value=e.value.substring(0,r)+d+e.value.substring(l),e.selectionStart=r+13,e.selectionEnd=r+23,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="hero")if(o.hero)o.hero(e);else{const r=e.selectionStart,l=e.selectionEnd,d=`[hero title="Hero Title" tagline="A short tagline" size="lg"]
11
+ [/card]`;replaceRange(e,r,l,p),e.setSelectionRange(r+13,r+23)}else if(t==="hero")if(o.hero)o.hero(e);else{const r=e.selectionStart,l=e.selectionEnd,p=`[hero title="Hero Title" tagline="A short tagline" size="lg"]
12
12
  ${e.value.substring(r,l)||"Optional body content here."}
13
- [/hero]`;e.value=e.value.substring(0,r)+d+e.value.substring(l),e.selectionStart=e.selectionEnd=r+d.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="grid")if(o.grid)o.grid(e);else{const r=e.selectionStart,l=`[grid cols="2" gap="4"]
13
+ [/hero]`;replaceRange(e,r,l,p)}else if(t==="grid")if(o.grid)o.grid(e);else{const r=e.selectionStart;replaceRange(e,r,r,`[grid cols="2" gap="4"]
14
14
  [col]
15
15
  Column 1
16
16
  [/col]
@@ -18,7 +18,7 @@ Column 1
18
18
  Column 2
19
19
  [/col]
20
20
  [/grid]
21
- `;e.value=e.value.substring(0,r)+l+e.value.substring(r),e.selectionStart=e.selectionEnd=r+l.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="badge"){const r=e.selectionStart,l=e.selectionEnd,d=`[badge variant="primary"]${e.value.substring(r,l)||"New"}[/badge]`;e.value=e.value.substring(0,r)+d+e.value.substring(l),e.selectionStart=r+16,e.selectionEnd=r+23,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="timeline")if(o.timeline)o.timeline(e);else{const r=e.selectionStart,l=`[timeline layout="vertical"]
21
+ `)}else if(t==="badge"){const r=e.selectionStart,l=e.selectionEnd,p=`[badge variant="primary"]${e.value.substring(r,l)||"New"}[/badge]`;replaceRange(e,r,l,p),e.setSelectionRange(r+16,r+23)}else if(t==="timeline")if(o.timeline)o.timeline(e);else{const r=e.selectionStart,l=`[timeline layout="vertical"]
22
22
  [event title="First Event" date="${new Date().toISOString().slice(0,10)}" status="completed"]
23
23
  Describe this event.
24
24
  [/event]
@@ -26,21 +26,21 @@ Describe this event.
26
26
  Describe this event.
27
27
  [/event]
28
28
  [/timeline]
29
- `;e.value=e.value.substring(0,r)+l+e.value.substring(r),e.selectionStart=e.selectionEnd=r+l.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="effects")o.effects&&o.effects(e);else if(t==="embed")import("./embed-builder.js").then(r=>r.EmbedBuilder.open(e)).catch(r=>console.error("Embed builder failed to load",r));else if(t==="spacerpick")se(e,m,s);else if(t==="iconpick")ce(e,m);else if(t==="listgroup")o.listgroup?o.listgroup(e):insertAtCursor(e,`[listgroup]
29
+ `;replaceRange(e,r,r,l)}else if(t==="effects")o.effects&&o.effects(e);else if(t==="embed")import("./embed-builder.js").then(r=>r.EmbedBuilder.open(e)).catch(r=>console.error("Embed builder failed to load",r));else if(t==="spacerpick")se(e,d,s);else if(t==="iconpick")ce(e,d);else if(t==="listgroup")o.listgroup?o.listgroup(e):insertAtCursor(e,`[listgroup]
30
30
  [item]Item 1[/item]
31
31
  [item]Item 2[/item]
32
32
  [item]Item 3[/item]
33
33
  [/listgroup]
34
- `);else if(t==="collection")o.collection?o.collection(e):insertAtCursor(e,'[collection slug="" display="table" /]');else if(t==="view")o.view&&o.view(e);else if(t==="cta")o.cta&&o.cta(e);else if(t==="form")o.form?o.form(e):insertAtCursor(e,'[form slug="" /]');else if(t==="tabs")o.tabs&&o.tabs(e);else if(t==="carousel")o.carousel&&o.carousel(e);else if(t==="banner")o.banner&&o.banner(e);else if(t==="scribe")if(o.scribe)o.scribe(e);else{const r=e.selectionStart,l=`[scribe]
34
+ `);else if(t==="collection")o.collection?o.collection(e):insertAtCursor(e,'[collection slug="" display="table" /]');else if(t==="view")o.view&&o.view(e);else if(t==="cta")o.cta&&o.cta(e);else if(t==="form")o.form?o.form(e):insertAtCursor(e,'[form slug="" /]');else if(t==="tabs")o.tabs&&o.tabs(e);else if(t==="carousel")o.carousel&&o.carousel(e);else if(t==="banner")o.banner&&o.banner(e);else if(t==="scribe")if(o.scribe)o.scribe(e);else{const r=e.selectionStart;replaceRange(e,r,r,`[scribe]
35
35
  [render]Type text here.[/render]
36
36
  [wait]1500[/wait]
37
37
  [undo all="true" /]
38
38
  [render]More text.[/render]
39
39
  [/scribe]
40
- `;e.value=e.value.substring(0,r)+l+e.value.substring(r),e.selectionStart=e.selectionEnd=r+l.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="accordion")if(o.accordion)o.accordion(e);else{const r=e.selectionStart,l=`[accordion]
40
+ `)}else if(t==="accordion")if(o.accordion)o.accordion(e);else{const r=e.selectionStart;replaceRange(e,r,r,`[accordion]
41
41
  [item title="Item 1"]Content here.[/item]
42
42
  [item title="Item 2"]Content here.[/item]
43
43
  [/accordion]
44
- `;e.value=e.value.substring(0,r)+l+e.value.substring(r),e.selectionStart=e.selectionEnd=r+l.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="text"){let n=function(b,u){const g=document.createElement("div"),T=document.createElement("label");return T.style.cssText=d,T.textContent=b,g.appendChild(T),g.appendChild(u),g},c=function(b){const u=document.createElement("select");return u.style.cssText=f,[["","\u2014 default \u2014"],...b].forEach(([g,T])=>{const O=document.createElement("option");O.value=g,O.textContent=T,u.appendChild(O)}),u},a=function(b,u){const g=document.createElement("input");return g.type="text",g.placeholder=b||"",g.value=u||"",g.style.cssText=f,g},k=function(b){const u=document.createElement("label");u.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;";const g=document.createElement("input");g.type="checkbox";const T=document.createElement("span");return T.style.cssText="font-size:.85em;color:var(--dm-text,#eee);",T.textContent=b,u.appendChild(g),u.appendChild(T),{wrap:u,cb:g}},y=function(b,u){const g=document.createElement("div");return g.style.cssText="display:grid;grid-template-columns:1fr 1fr;gap:.5rem;",g.appendChild(b),g.appendChild(u),g},w=function(b){const u=document.createElement("div");return u.style.cssText="border-top:1px solid var(--dm-border,#333);padding-top:.5rem;margin-top:.1rem;font-size:.65rem;font-weight:700;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.08em;",u.textContent=b,u},_=function(){const b=[];M.value&&b.push(`font-size:${ee[M.value]||M.value}`);const u=parseFloat(v.value);!isNaN(u)&&u>0&&b.push(`font-size:${u}pt`),L.checked?b.push("font-weight:700"):h.value&&b.push(`font-weight:${te[h.value]||h.value}`),z.checked&&b.push("font-style:italic");const g=B.value.trim();g&&b.push(`color:${Y[g]||g}`),W.value&&b.push(`font-family:${oe[W.value]}`),P.value&&b.push(`text-transform:${ie[P.value]}`),A.value&&b.push(`text-decoration:${re[A.value]}`),H.value&&b.push(`letter-spacing:${ne[H.value]}`),R.value&&(b.push("display:block"),b.push(`text-align:${R.value}`)),D.value.trim()&&b.push(D.value.trim()),q.style.cssText=b.join(";"),q.textContent=S.value||"Preview text"};const r=e.selectionStart,l=e.selectionEnd,p=e.value.substring(r,l)||"",d="display:block;font-size:.7rem;font-weight:600;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",f="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;",x=document.createElement("div");x.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.6rem;overflow-y:auto;max-height:75vh;";const S=a("Text to style\u2026",p);x.appendChild(n("Content",S)),x.appendChild(w("Typography"));const M=c([["xs","xs \u2014 0.75rem"],["sm","sm \u2014 0.875rem"],["base","base \u2014 1rem"],["lg","lg \u2014 1.125rem"],["xl","xl \u2014 1.25rem"],["2xl","2xl \u2014 1.5rem"],["3xl","3xl \u2014 1.875rem"],["4xl","4xl \u2014 2.25rem"]]),v=a("pt value (overrides Size)");x.appendChild(y(n("Size",M),n("Point Size (pt)",v)));const h=c([["thin","Thin (100)"],["light","Light (300)"],["normal","Normal (400)"],["medium","Medium (500)"],["semibold","Semibold (600)"],["bold","Bold (700)"],["extrabold","Extrabold (800)"],["black","Black (900)"]]),{wrap:C,cb:L}=k("Bold (overrides Weight)"),{wrap:N,cb:z}=k("Italic"),j=document.createElement("div");j.style.cssText="display:flex;flex-direction:column;gap:.4rem;justify-content:flex-end;",j.appendChild(C),j.appendChild(N),x.appendChild(y(n("Weight",h),j)),x.appendChild(w("Appearance"));const B=a("e.g. primary, #ff0000"),W=c([["Georgia","Georgia (serif)"],["Arial","Arial (sans-serif)"],["Verdana","Verdana (sans-serif)"],["Courier New","Courier New (mono)"],["Times New Roman","Times New Roman (serif)"],["Trebuchet MS","Trebuchet MS"]]);x.appendChild(y(n("Colour",B),n("Font",W))),x.appendChild(w("Formatting"));const P=c([["upper","Uppercase"],["lower","Lowercase"],["capitalize","Capitalise"],["none","None"]]),A=c([["underline","Underline"],["line-through","Line-through"],["none","None"]]);x.appendChild(y(n("Transform",P),n("Decoration",A)));const H=c([["tight","Tight"],["normal","Normal"],["wide","Wide"],["wider","Wider"]]),R=c([["left","Left"],["center","Centre"],["right","Right"],["justify","Justify"]]);x.appendChild(y(n("Spacing",H),n("Align",R))),x.appendChild(w("Advanced"));const D=a("e.g. margin-top:1rem;display:block");x.appendChild(n("Style",D));const F=a("CSS class(es)"),G=a("ID");x.appendChild(y(n("Class",F),n("ID",G)));const K=document.createElement("div");K.style.cssText="padding:.75rem;background:var(--dm-surface-subtle,#111);border-radius:4px;min-height:2.5rem;display:flex;align-items:center;";const q=document.createElement("span");q.textContent=p||"Preview text",K.appendChild(q),x.appendChild(n("Preview",K));const Y={primary:"var(--dm-color-primary)",secondary:"var(--dm-color-secondary)",muted:"var(--dm-text-muted)",danger:"var(--dm-color-danger)",success:"var(--dm-color-success)",warning:"var(--dm-color-warning)",info:"var(--dm-color-info)"},ee={xs:".75rem",sm:".875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},te={thin:"100",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},ne={tight:"-0.05em",normal:"0em",wide:"0.05em",wider:"0.1em"},oe={Georgia:"Georgia,serif",Arial:"Arial,sans-serif",Verdana:"Verdana,sans-serif","Courier New":"'Courier New',monospace","Times New Roman":"'Times New Roman',serif","Trebuchet MS":"'Trebuchet MS',sans-serif"},ie={upper:"uppercase",lower:"lowercase",capitalize:"capitalize",none:"none"},re={underline:"underline","line-through":"line-through",none:"none"};L.addEventListener("change",()=>{h.disabled=L.checked,L.checked&&(h.value=""),_()}),[M,h,W,P,A,H,R].forEach(b=>{b.addEventListener("change",_)}),[B,S,D,v].forEach(b=>{b.addEventListener("input",_)}),z.addEventListener("change",_);const V=document.createElement("button");V.type="button",V.className="btn btn-primary",V.textContent="Insert",x.appendChild(V);const U=E.slideover({title:"Style Text",size:"md",position:"right",content:x});U.open(),V.addEventListener("click",()=>{const b=S.value;if(!b.trim())return;const u=[];M.value&&u.push(`size="${M.value}"`);const g=parseFloat(v.value);!isNaN(g)&&g>0&&u.push(`point-size="${g}"`),L.checked?u.push("bold"):h.value&&u.push(`weight="${h.value}"`),z.checked&&u.push("italic"),B.value.trim()&&u.push(`color="${B.value.trim()}"`),W.value&&u.push(`font="${W.value}"`),P.value&&u.push(`transform="${P.value}"`),A.value&&u.push(`decoration="${A.value}"`),H.value&&u.push(`spacing="${H.value}"`),R.value&&u.push(`align="${R.value}"`),D.value.trim()&&u.push(`style="${D.value.trim().replace(/"/g,"&quot;")}"`),F.value.trim()&&u.push(`class="${F.value.trim()}"`),G.value.trim()&&u.push(`id="${G.value.trim()}"`);const O=`[text${u.length?" "+u.join(" "):""}]${b}[/text]`;U.close(),insertAtCursor(e,O),e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()})}else t==="help"?o.help&&o.help(e):t==="tutorial"&&o.tutorial&&o.tutorial(e)}const Q=[{icon:"bold",title:"Bold (Ctrl+B)",action:t=>wrapSelection(t,"**","**")},{icon:"italic",title:"Italic (Ctrl+I)",action:t=>wrapSelection(t,"_","_")},{icon:"strikethrough",title:"Strikethrough",action:t=>wrapSelection(t,"~~","~~")},"|",{type:"dropdown",icon:"heading-1",title:"Headings",items:[{label:"Heading 1",icon:"heading-1",action:t=>insertLine(t,"# ")},{label:"Heading 2",icon:"heading-2",action:t=>insertLine(t,"## ")},{label:"Heading 3",icon:"heading-3",action:t=>insertLine(t,"### ")}]},"|",{icon:"list-bullet",title:"Bullet list",action:t=>insertLine(t,"- ")},{icon:"list-numbered",title:"Numbered list",action:t=>insertLine(t,"1. ")},"|",{type:"dropdown",icon:"quote",title:"Paragraph",items:[{label:"Blockquote",icon:"quote",action:t=>insertLine(t,"> ")},{label:"Horizontal rule",icon:"minus-circle",action:t=>insertAtCursor(t,`
44
+ `)}else if(t==="text"){let n=function(b,u){const g=document.createElement("div"),z=document.createElement("label");return z.style.cssText=p,z.textContent=b,g.appendChild(z),g.appendChild(u),g},c=function(b){const u=document.createElement("select");return u.style.cssText=f,[["","\u2014 default \u2014"],...b].forEach(([g,z])=>{const O=document.createElement("option");O.value=g,O.textContent=z,u.appendChild(O)}),u},a=function(b,u){const g=document.createElement("input");return g.type="text",g.placeholder=b||"",g.value=u||"",g.style.cssText=f,g},v=function(b){const u=document.createElement("label");u.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;";const g=document.createElement("input");g.type="checkbox";const z=document.createElement("span");return z.style.cssText="font-size:.85em;color:var(--dm-text,#eee);",z.textContent=b,u.appendChild(g),u.appendChild(z),{wrap:u,cb:g}},y=function(b,u){const g=document.createElement("div");return g.style.cssText="display:grid;grid-template-columns:1fr 1fr;gap:.5rem;",g.appendChild(b),g.appendChild(u),g},w=function(b){const u=document.createElement("div");return u.style.cssText="border-top:1px solid var(--dm-border,#333);padding-top:.5rem;margin-top:.1rem;font-size:.65rem;font-weight:700;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.08em;",u.textContent=b,u},_=function(){const b=[];M.value&&b.push(`font-size:${ee[M.value]||M.value}`);const u=parseFloat(k.value);!isNaN(u)&&u>0&&b.push(`font-size:${u}pt`),L.checked?b.push("font-weight:700"):h.value&&b.push(`font-weight:${te[h.value]||h.value}`),T.checked&&b.push("font-style:italic");const g=B.value.trim();g&&b.push(`color:${Y[g]||g}`),j.value&&b.push(`font-family:${oe[j.value]}`),W.value&&b.push(`text-transform:${ie[W.value]}`),P.value&&b.push(`text-decoration:${re[P.value]}`),A.value&&b.push(`letter-spacing:${ne[A.value]}`),H.value&&(b.push("display:block"),b.push(`text-align:${H.value}`)),D.value.trim()&&b.push(D.value.trim()),q.style.cssText=b.join(";"),q.textContent=S.value||"Preview text"};const r=e.selectionStart,l=e.selectionEnd,m=e.value.substring(r,l)||"",p="display:block;font-size:.7rem;font-weight:600;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",f="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;",x=document.createElement("div");x.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.6rem;overflow-y:auto;max-height:75vh;";const S=a("Text to style\u2026",m);x.appendChild(n("Content",S)),x.appendChild(w("Typography"));const M=c([["xs","xs \u2014 0.75rem"],["sm","sm \u2014 0.875rem"],["base","base \u2014 1rem"],["lg","lg \u2014 1.125rem"],["xl","xl \u2014 1.25rem"],["2xl","2xl \u2014 1.5rem"],["3xl","3xl \u2014 1.875rem"],["4xl","4xl \u2014 2.25rem"]]),k=a("pt value (overrides Size)");x.appendChild(y(n("Size",M),n("Point Size (pt)",k)));const h=c([["thin","Thin (100)"],["light","Light (300)"],["normal","Normal (400)"],["medium","Medium (500)"],["semibold","Semibold (600)"],["bold","Bold (700)"],["extrabold","Extrabold (800)"],["black","Black (900)"]]),{wrap:C,cb:L}=v("Bold (overrides Weight)"),{wrap:N,cb:T}=v("Italic"),R=document.createElement("div");R.style.cssText="display:flex;flex-direction:column;gap:.4rem;justify-content:flex-end;",R.appendChild(C),R.appendChild(N),x.appendChild(y(n("Weight",h),R)),x.appendChild(w("Appearance"));const B=a("e.g. primary, #ff0000"),j=c([["Georgia","Georgia (serif)"],["Arial","Arial (sans-serif)"],["Verdana","Verdana (sans-serif)"],["Courier New","Courier New (mono)"],["Times New Roman","Times New Roman (serif)"],["Trebuchet MS","Trebuchet MS"]]);x.appendChild(y(n("Colour",B),n("Font",j))),x.appendChild(w("Formatting"));const W=c([["upper","Uppercase"],["lower","Lowercase"],["capitalize","Capitalise"],["none","None"]]),P=c([["underline","Underline"],["line-through","Line-through"],["none","None"]]);x.appendChild(y(n("Transform",W),n("Decoration",P)));const A=c([["tight","Tight"],["normal","Normal"],["wide","Wide"],["wider","Wider"]]),H=c([["left","Left"],["center","Centre"],["right","Right"],["justify","Justify"]]);x.appendChild(y(n("Spacing",A),n("Align",H))),x.appendChild(w("Advanced"));const D=a("e.g. margin-top:1rem;display:block");x.appendChild(n("Style",D));const F=a("CSS class(es)"),G=a("ID");x.appendChild(y(n("Class",F),n("ID",G)));const K=document.createElement("div");K.style.cssText="padding:.75rem;background:var(--dm-background-alt,#111);border-radius:4px;min-height:2.5rem;display:flex;align-items:center;";const q=document.createElement("span");q.textContent=m||"Preview text",K.appendChild(q),x.appendChild(n("Preview",K));const Y={primary:"var(--dm-primary)",secondary:"var(--dm-secondary)",muted:"var(--dm-text-muted)",danger:"var(--dm-danger)",success:"var(--dm-success)",warning:"var(--dm-warning)",info:"var(--dm-info)"},ee={xs:".75rem",sm:".875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},te={thin:"100",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},ne={tight:"-0.05em",normal:"0em",wide:"0.05em",wider:"0.1em"},oe={Georgia:"Georgia,serif",Arial:"Arial,sans-serif",Verdana:"Verdana,sans-serif","Courier New":"'Courier New',monospace","Times New Roman":"'Times New Roman',serif","Trebuchet MS":"'Trebuchet MS',sans-serif"},ie={upper:"uppercase",lower:"lowercase",capitalize:"capitalize",none:"none"},re={underline:"underline","line-through":"line-through",none:"none"};L.addEventListener("change",()=>{h.disabled=L.checked,L.checked&&(h.value=""),_()}),[M,h,j,W,P,A,H].forEach(b=>{b.addEventListener("change",_)}),[B,S,D,k].forEach(b=>{b.addEventListener("input",_)}),T.addEventListener("change",_);const V=document.createElement("button");V.type="button",V.className="btn btn-primary",V.textContent="Insert",x.appendChild(V);const U=E.slideover({title:"Style Text",size:"md",position:"right",content:x});U.open(),V.addEventListener("click",()=>{const b=S.value;if(!b.trim())return;const u=[];M.value&&u.push(`size="${M.value}"`);const g=parseFloat(k.value);!isNaN(g)&&g>0&&u.push(`point-size="${g}"`),L.checked?u.push("bold"):h.value&&u.push(`weight="${h.value}"`),T.checked&&u.push("italic"),B.value.trim()&&u.push(`color="${B.value.trim()}"`),j.value&&u.push(`font="${j.value}"`),W.value&&u.push(`transform="${W.value}"`),P.value&&u.push(`decoration="${P.value}"`),A.value&&u.push(`spacing="${A.value}"`),H.value&&u.push(`align="${H.value}"`),D.value.trim()&&u.push(`style="${D.value.trim().replace(/"/g,"&quot;")}"`),F.value.trim()&&u.push(`class="${F.value.trim()}"`),G.value.trim()&&u.push(`id="${G.value.trim()}"`);const O=`[text${u.length?" "+u.join(" "):""}]${b}[/text]`;U.close(),insertAtCursor(e,O)})}else t==="help"?o.help&&o.help(e):t==="tutorial"&&o.tutorial&&o.tutorial(e)}const Q=[{icon:"bold",title:"Bold (Ctrl+B)",action:t=>wrapSelection(t,"**","**")},{icon:"italic",title:"Italic (Ctrl+I)",action:t=>wrapSelection(t,"_","_")},{icon:"strikethrough",title:"Strikethrough",action:t=>wrapSelection(t,"~~","~~")},"|",{type:"dropdown",icon:"heading-1",title:"Headings",items:[{label:"Heading 1",icon:"heading-1",action:t=>insertLine(t,"# ")},{label:"Heading 2",icon:"heading-2",action:t=>insertLine(t,"## ")},{label:"Heading 3",icon:"heading-3",action:t=>insertLine(t,"### ")}]},"|",{icon:"list-bullet",title:"Bullet list",action:t=>insertLine(t,"- ")},{icon:"list-numbered",title:"Numbered list",action:t=>insertLine(t,"1. ")},"|",{type:"dropdown",icon:"quote",title:"Paragraph",items:[{label:"Blockquote",icon:"quote",action:t=>insertLine(t,"> ")},{label:"Horizontal rule",icon:"minus-circle",action:t=>insertAtCursor(t,`
45
45
  ---
46
- `)}]},"|",{type:"dropdown",icon:"code-inline",title:"Code",items:[{label:"Inline code",icon:"code-inline",action:t=>wrapSelection(t,"`","`")},{label:"Code block",icon:"code-block",action:t=>wrapSelection(t,"\n```\n","\n```\n")}]},"|",{type:"dropdown",icon:"plus-circle",title:"Insert",items:[{label:"Accordion",icon:"accordion-insert",action:"accordion"},{label:"Banner",icon:"banner-insert",action:"banner"},{label:"Badge",icon:"badge",action:"badge"},{label:"Block",icon:"layout",action:"block"},{label:"Button",icon:"btn-insert",action:"button"},{label:"Card",icon:"card",action:"card"},{label:"Carousel",icon:"carousel-insert",action:"carousel"},{label:"Colour Picker",icon:"colour-picker",action:"colourpick"},{label:"Collection",icon:"database",action:"collection"},{label:"Component",icon:"component",action:"component"},{label:"CTA Button",icon:"mouse-pointer",action:"cta"},{label:"Embed",icon:"video",action:"embed"},{label:"Form",icon:"file-text",action:"form"},{label:"Grid",icon:"columns",action:"grid"},{label:"Hero",icon:"hero",action:"hero"},{label:"Icon",icon:"icon-pick",action:"iconpick"},{label:"Image",icon:"image-add",action:"image"},{label:"Link",icon:"link-shortcode",action:"linksc"},{label:"List Group",icon:"list",action:"listgroup"},{label:"Scribe",icon:"scribe-insert",action:"scribe"},{label:"Spacer",icon:"spacer-insert",action:"spacerpick"},{label:"Tabs",icon:"layout-list",action:"tabs"},{label:"Text",icon:"text-style",action:"text"},{label:"Timeline",icon:"activity",action:"timeline"},{label:"View",icon:"eye",action:"view"}]},"|",{icon:"sparkles",title:"Effects",action:"effects"},{icon:"book-open",title:"CRUD tutorial",action:"tutorial"},{icon:"help-circle",title:"Editor help",action:"help"}];export function createToolbar(t,e,m={}){le();const i={link:null,image:null,card:null,grid:null,help:null,tutorial:null,effects:null,collection:null,view:null,cta:null,form:null,button:null,linksc:null,tabs:null,accordion:null,carousel:null,hero:null,banner:null},s=m.spacerDefault??40,o=t.get(0),r=e.get(0);r.textContent="",Q.forEach((n,c)=>{if(n==="|"){const a=document.createElement("span");a.className="editor-toolbar-sep",r.appendChild(a)}else{const a=document.createElement("button");a.className=n.type==="dropdown"?"editor-toolbar-btn editor-toolbar-dropdown-trigger":"editor-toolbar-btn",a.setAttribute("data-tooltip",n.title),a.setAttribute("data-idx",String(c)),a.type="button";const k=document.createElement("span");if(k.setAttribute("data-icon",n.icon),a.appendChild(k),n.type==="dropdown"){const y=document.createElement("span");y.className="editor-toolbar-caret",y.textContent="\u25BE",a.appendChild(y)}r.appendChild(a)}});const l=document.createElement("div");l.className="editor-toolbar-right",[{mode:"split",icon:"columns",label:"Split view",active:!0},{mode:"write",icon:"file-text",label:"Write only",active:!1},{mode:"preview",icon:"eye",label:"Preview only",active:!1}].forEach(n=>{const c=document.createElement("button");c.className="editor-view-btn"+(n.active?" active":""),c.setAttribute("data-mode",n.mode),c.setAttribute("data-tooltip",n.label),c.type="button";const a=document.createElement("span");a.setAttribute("data-icon",n.icon),c.appendChild(a),l.appendChild(c)});const p=document.createElement("span");p.className="editor-toolbar-sep",l.appendChild(p);const d=document.createElement("button");d.id="fullscreen-btn",d.className="editor-toolbar-btn",d.setAttribute("data-tooltip","Toggle fullscreen"),d.type="button";const f=document.createElement("span");return f.setAttribute("data-icon","expand"),d.appendChild(f),l.appendChild(d),r.appendChild(l),Domma.icons.scan(),r.querySelectorAll("[data-tooltip]").forEach(n=>{E.tooltip(n,{content:n.getAttribute("data-tooltip"),position:"top"})}),e.on("click",".editor-toolbar-btn[data-idx]",function(){const n=parseInt($(this).data("idx"),10),c=Q[n];if(!c||c==="|")return;const a=e.get(0).querySelector(`[data-idx="${n}"]`),k={spacerDefault:s,handlers:i};c.type==="dropdown"?ae(o,a,c.items,k):J(c.action,o,a,k)}),attachEditorKeybindings(o),o.addEventListener("keydown",n=>{const c=n.key.toLowerCase();(n.ctrlKey||n.metaKey)&&(c==="b"?(n.preventDefault(),wrapSelection(o,"**","**")):c==="i"?(n.preventDefault(),wrapSelection(o,"_","_")):c==="k"&&(n.preventDefault(),i.link&&i.link(o)))}),{$toolbar:e,onLink(n){i.link=n},onImage(n){i.image=n},onCard(n){i.card=n},onGrid(n){i.grid=n},onHelp(n){i.help=n},onTutorial(n){i.tutorial=n},onEffects(n){i.effects=n},onCollection(n){i.collection=n},onBlock(n){i.block=n},onView(n){i.view=n},onCta(n){i.cta=n},onForm(n){i.form=n},onButton(n){i.button=n},onLinkShortcode(n){i.linksc=n},onTabs(n){i.tabs=n},onCarousel(n){i.carousel=n},onAccordion(n){i.accordion=n},onHero(n){i.hero=n},onBanner(n){i.banner=n},onListGroup(n){i.listgroup=n},onScribe(n){i.scribe=n},onTimeline(n){i.timeline=n}}}async function de(t){const{api:e}=await import("../api.js");let m;try{m=await e.components.list()}catch(v){E.toast(v.message||"Failed to load components.",{type:"error"});return}if(!m?.length){E.toast("No components yet. Create one in Data \u2192 Components first.",{type:"info"});return}const i=E.slideover({title:"Insert Component",size:"lg",position:"right"}),s=document.createElement("div");s.style.cssText="display:flex;flex-direction:column;gap:1rem;padding:.75rem;min-height:100%;";const o=document.createElement("div");o.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",o.textContent="Gallery";const r=document.createElement("div");r.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:.5rem;";const l=document.createElement("div");l.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",l.textContent="Props";const p=document.createElement("div");p.style.cssText="padding:.6rem;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;min-height:40px;",p.textContent="Select a component from the gallery above.";const d=document.createElement("div");d.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",d.textContent="Preview";const f=document.createElement("iframe");f.src="/admin/preview/component-preview.html",f.style.cssText="width:100%;min-height:180px;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;background:#fff;";const n=document.createElement("div");n.style.cssText="display:flex;justify-content:flex-end;gap:.5rem;margin-top:auto;padding-top:.75rem;border-top:1px solid var(--dm-border,rgba(255,255,255,.08));";const c=document.createElement("button");c.className="btn btn-ghost",c.textContent="Cancel";const a=document.createElement("button");a.className="btn btn-primary",a.textContent="Insert",a.disabled=!0,n.appendChild(c),n.appendChild(a),s.appendChild(o),s.appendChild(r),s.appendChild(l),s.appendChild(p),s.appendChild(d),s.appendChild(f),s.appendChild(n),i.setContent(s),i.open();let k=null,y={};function w(){r.replaceChildren();for(const v of m){const h=document.createElement("button");h.type="button",h.className="btn btn-ghost",h.style.cssText="display:flex;flex-direction:column;align-items:flex-start;gap:.25rem;padding:.6rem;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;text-align:left;";const C=document.createElement("strong");C.style.cssText="font-size:.9rem;",C.textContent=v.name;const L=document.createElement("span");L.style.cssText="font-size:.72rem;color:var(--dm-text-muted,#888);",L.textContent=`${Object.keys(v.props||{}).length} prop(s)`,h.appendChild(C),h.appendChild(L),h.addEventListener("click",()=>x(v)),r.appendChild(h)}}function x(v){k=v,y={};for(const[h,C]of Object.entries(v.props||{}))y[h]=C.default!==void 0?C.default:"";a.disabled=!1,S(),M()}function S(){p.replaceChildren();const v=Object.entries(k.props||{});if(v.length===0){const h=document.createElement("p");h.className="text-muted",h.style.margin="0",h.textContent="This component takes no props.",p.appendChild(h);return}for(const[h,C]of v){const L=document.createElement("div");L.style.cssText="display:flex;align-items:center;gap:.5rem;margin-bottom:.4rem;";const N=document.createElement("label");N.style.cssText="font-size:.8rem;min-width:120px;color:var(--dm-text-muted,#aaa);",N.textContent=C.label||h,L.appendChild(N);const z=ue(C);pe(z,C,y[h]),z.addEventListener("input",()=>{y[h]=X(z,C),f.contentWindow?.postMessage({type:"update",payload:{props:y}},"*")}),z.addEventListener("change",()=>{y[h]=X(z,C),f.contentWindow?.postMessage({type:"update",payload:{props:y}},"*")}),L.appendChild(z),p.appendChild(L)}}async function M(){if(k)try{const v=await fetch(`/api/components/${encodeURIComponent(k.name)}.js`);if(!v.ok)throw new Error(`Failed to load component (${v.status})`);const h=await v.text();f.contentWindow?.postMessage({type:"remount",payload:{compiledJs:h,tagName:`dm-${k.name}`,props:y}},"*")}catch(v){E.toast(v.message||"Failed to load preview.",{type:"error"})}}c.addEventListener("click",()=>i.close()),a.addEventListener("click",()=>{if(!k)return;const v=t.selectionStart,h=t.selectionEnd,C=Object.entries(y).map(([N,z])=>{const j=N.replace(/([A-Z])/g,"-$1").toLowerCase(),B=String(z??"").replace(/"/g,"&quot;");return`${j}="${B}"`}).join(" "),L=`[component name="${k.name}"${C?" "+C:""} /]`;t.value=t.value.substring(0,v)+L+t.value.substring(h),t.selectionStart=t.selectionEnd=v+L.length,t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus(),i.close()}),w()}function ue(t){let e;return t.type==="number"?(e=document.createElement("input"),e.type="number",e.className="form-input form-input--sm"):t.type==="boolean"?(e=document.createElement("input"),e.type="checkbox",e.className="form-check"):t.type==="array"||t.type==="object"?(e=document.createElement("textarea"),e.rows=2,e.className="form-input form-input--sm",e.style.fontFamily="var(--dm-font-mono, monospace)"):(e=document.createElement("input"),e.type="text",e.className="form-input form-input--sm"),e.style.flex="1",e}function X(t,e){if(e.type==="number")return t.value===""?null:Number(t.value);if(e.type==="boolean")return!!t.checked;if(e.type==="array"||e.type==="object")try{return JSON.parse(t.value||"null")}catch{return null}return t.value}function pe(t,e,m){e.type==="boolean"?t.checked=!!m:e.type==="array"||e.type==="object"?t.value=JSON.stringify(m??null):t.value=m??""}
46
+ `)}]},"|",{type:"dropdown",icon:"code-inline",title:"Code",items:[{label:"Inline code",icon:"code-inline",action:t=>wrapSelection(t,"`","`")},{label:"Code block",icon:"code-block",action:t=>wrapSelection(t,"\n```\n","\n```\n")}]},"|",{type:"dropdown",icon:"plus-circle",title:"Insert",items:[{label:"Accordion",icon:"accordion-insert",action:"accordion"},{label:"Banner",icon:"banner-insert",action:"banner"},{label:"Badge",icon:"badge",action:"badge"},{label:"Block",icon:"layout",action:"block"},{label:"Button",icon:"btn-insert",action:"button"},{label:"Card",icon:"card",action:"card"},{label:"Carousel",icon:"carousel-insert",action:"carousel"},{label:"Colour Picker",icon:"colour-picker",action:"colourpick"},{label:"Collection",icon:"database",action:"collection"},{label:"Component",icon:"component",action:"component"},{label:"CTA Button",icon:"mouse-pointer",action:"cta"},{label:"Embed",icon:"video",action:"embed"},{label:"Form",icon:"file-text",action:"form"},{label:"Grid",icon:"columns",action:"grid"},{label:"Hero",icon:"hero",action:"hero"},{label:"Icon",icon:"icon-pick",action:"iconpick"},{label:"Image",icon:"image-add",action:"image"},{label:"Link",icon:"link-shortcode",action:"linksc"},{label:"List Group",icon:"list",action:"listgroup"},{label:"Scribe",icon:"scribe-insert",action:"scribe"},{label:"Spacer",icon:"spacer-insert",action:"spacerpick"},{label:"Tabs",icon:"layout-list",action:"tabs"},{label:"Text",icon:"text-style",action:"text"},{label:"Timeline",icon:"activity",action:"timeline"},{label:"View",icon:"eye",action:"view"}]},"|",{icon:"sparkles",title:"Effects",action:"effects"},{icon:"book-open",title:"CRUD tutorial",action:"tutorial"},{icon:"help-circle",title:"Editor help",action:"help"}];export function createToolbar(t,e,d={}){le();const i={link:null,image:null,card:null,grid:null,help:null,tutorial:null,effects:null,collection:null,view:null,cta:null,form:null,button:null,linksc:null,tabs:null,accordion:null,carousel:null,hero:null,banner:null},s=d.spacerDefault??40,o=t.get(0),r=e.get(0);r.textContent="",Q.forEach((n,c)=>{if(n==="|"){const a=document.createElement("span");a.className="editor-toolbar-sep",r.appendChild(a)}else{const a=document.createElement("button");a.className=n.type==="dropdown"?"editor-toolbar-btn editor-toolbar-dropdown-trigger":"editor-toolbar-btn",a.setAttribute("data-tooltip",n.title),a.setAttribute("data-idx",String(c)),a.type="button";const v=document.createElement("span");if(v.setAttribute("data-icon",n.icon),a.appendChild(v),n.type==="dropdown"){const y=document.createElement("span");y.className="editor-toolbar-caret",y.textContent="\u25BE",a.appendChild(y)}r.appendChild(a)}});const l=document.createElement("div");l.className="editor-toolbar-right",[{mode:"split",icon:"columns",label:"Split view",active:!0},{mode:"write",icon:"file-text",label:"Write only",active:!1},{mode:"preview",icon:"eye",label:"Preview only",active:!1}].forEach(n=>{const c=document.createElement("button");c.className="editor-view-btn"+(n.active?" active":""),c.setAttribute("data-mode",n.mode),c.setAttribute("data-tooltip",n.label),c.type="button";const a=document.createElement("span");a.setAttribute("data-icon",n.icon),c.appendChild(a),l.appendChild(c)});const m=document.createElement("span");m.className="editor-toolbar-sep",l.appendChild(m);const p=document.createElement("button");p.id="fullscreen-btn",p.className="editor-toolbar-btn",p.setAttribute("data-tooltip","Toggle fullscreen"),p.type="button";const f=document.createElement("span");return f.setAttribute("data-icon","expand"),p.appendChild(f),l.appendChild(p),r.appendChild(l),Domma.icons.scan(),r.querySelectorAll("[data-tooltip]").forEach(n=>{E.tooltip(n,{content:n.getAttribute("data-tooltip"),position:"top"})}),e.on("click",".editor-toolbar-btn[data-idx]",function(){const n=parseInt($(this).data("idx"),10),c=Q[n];if(!c||c==="|")return;const a=e.get(0).querySelector(`[data-idx="${n}"]`),v={spacerDefault:s,handlers:i};c.type==="dropdown"?ae(o,a,c.items,v):J(c.action,o,a,v)}),attachEditorKeybindings(o),o.addEventListener("keydown",n=>{const c=n.key.toLowerCase();(n.ctrlKey||n.metaKey)&&(c==="b"?(n.preventDefault(),wrapSelection(o,"**","**")):c==="i"?(n.preventDefault(),wrapSelection(o,"_","_")):c==="k"&&(n.preventDefault(),i.link&&i.link(o)))}),{$toolbar:e,onLink(n){i.link=n},onImage(n){i.image=n},onCard(n){i.card=n},onGrid(n){i.grid=n},onHelp(n){i.help=n},onTutorial(n){i.tutorial=n},onEffects(n){i.effects=n},onCollection(n){i.collection=n},onBlock(n){i.block=n},onView(n){i.view=n},onCta(n){i.cta=n},onForm(n){i.form=n},onButton(n){i.button=n},onLinkShortcode(n){i.linksc=n},onTabs(n){i.tabs=n},onCarousel(n){i.carousel=n},onAccordion(n){i.accordion=n},onHero(n){i.hero=n},onBanner(n){i.banner=n},onListGroup(n){i.listgroup=n},onScribe(n){i.scribe=n},onTimeline(n){i.timeline=n}}}async function de(t){const{api:e}=await import("../api.js");let d;try{d=await e.components.list()}catch(k){E.toast(k.message||"Failed to load components.",{type:"error"});return}if(!d?.length){E.toast("No components yet. Create one in Data \u2192 Components first.",{type:"info"});return}const i=E.slideover({title:"Insert Component",size:"lg",position:"right"}),s=document.createElement("div");s.style.cssText="display:flex;flex-direction:column;gap:1rem;padding:.75rem;min-height:100%;";const o=document.createElement("div");o.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",o.textContent="Gallery";const r=document.createElement("div");r.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:.5rem;";const l=document.createElement("div");l.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",l.textContent="Props";const m=document.createElement("div");m.style.cssText="padding:.6rem;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;min-height:40px;",m.textContent="Select a component from the gallery above.";const p=document.createElement("div");p.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",p.textContent="Preview";const f=document.createElement("iframe");f.src="/admin/preview/component-preview.html",f.style.cssText="width:100%;min-height:180px;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;background:#fff;";const n=document.createElement("div");n.style.cssText="display:flex;justify-content:flex-end;gap:.5rem;margin-top:auto;padding-top:.75rem;border-top:1px solid var(--dm-border,rgba(255,255,255,.08));";const c=document.createElement("button");c.className="btn btn-ghost",c.textContent="Cancel";const a=document.createElement("button");a.className="btn btn-primary",a.textContent="Insert",a.disabled=!0,n.appendChild(c),n.appendChild(a),s.appendChild(o),s.appendChild(r),s.appendChild(l),s.appendChild(m),s.appendChild(p),s.appendChild(f),s.appendChild(n),i.setContent(s),i.open();let v=null,y={};function w(){r.replaceChildren();for(const k of d){const h=document.createElement("button");h.type="button",h.className="btn btn-ghost",h.style.cssText="display:flex;flex-direction:column;align-items:flex-start;gap:.25rem;padding:.6rem;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;text-align:left;";const C=document.createElement("strong");C.style.cssText="font-size:.9rem;",C.textContent=k.name;const L=document.createElement("span");L.style.cssText="font-size:.72rem;color:var(--dm-text-muted,#888);",L.textContent=`${Object.keys(k.props||{}).length} prop(s)`,h.appendChild(C),h.appendChild(L),h.addEventListener("click",()=>x(k)),r.appendChild(h)}}function x(k){v=k,y={};for(const[h,C]of Object.entries(k.props||{}))y[h]=C.default!==void 0?C.default:"";a.disabled=!1,S(),M()}function S(){m.replaceChildren();const k=Object.entries(v.props||{});if(k.length===0){const h=document.createElement("p");h.className="text-muted",h.style.margin="0",h.textContent="This component takes no props.",m.appendChild(h);return}for(const[h,C]of k){const L=document.createElement("div");L.style.cssText="display:flex;align-items:center;gap:.5rem;margin-bottom:.4rem;";const N=document.createElement("label");N.style.cssText="font-size:.8rem;min-width:120px;color:var(--dm-text-muted,#aaa);",N.textContent=C.label||h,L.appendChild(N);const T=pe(C);ue(T,C,y[h]),T.addEventListener("input",()=>{y[h]=X(T,C),f.contentWindow?.postMessage({type:"update",payload:{props:y}},"*")}),T.addEventListener("change",()=>{y[h]=X(T,C),f.contentWindow?.postMessage({type:"update",payload:{props:y}},"*")}),L.appendChild(T),m.appendChild(L)}}async function M(){if(v)try{const k=await fetch(`/api/components/${encodeURIComponent(v.name)}.js`);if(!k.ok)throw new Error(`Failed to load component (${k.status})`);const h=await k.text();f.contentWindow?.postMessage({type:"remount",payload:{compiledJs:h,tagName:`dm-${v.name}`,props:y}},"*")}catch(k){E.toast(k.message||"Failed to load preview.",{type:"error"})}}c.addEventListener("click",()=>i.close()),a.addEventListener("click",()=>{if(!v)return;const k=t.selectionStart,h=t.selectionEnd,C=Object.entries(y).map(([N,T])=>{const R=N.replace(/([A-Z])/g,"-$1").toLowerCase(),B=String(T??"").replace(/"/g,"&quot;");return`${R}="${B}"`}).join(" "),L=`[component name="${v.name}"${C?" "+C:""} /]`;replaceRange(t,k,h,L),i.close()}),w()}function pe(t){let e;return t.type==="number"?(e=document.createElement("input"),e.type="number",e.className="form-input form-input--sm"):t.type==="boolean"?(e=document.createElement("input"),e.type="checkbox",e.className="form-check"):t.type==="array"||t.type==="object"?(e=document.createElement("textarea"),e.rows=2,e.className="form-input form-input--sm",e.style.fontFamily="var(--dm-font-mono, monospace)"):(e=document.createElement("input"),e.type="text",e.className="form-input form-input--sm"),e.style.flex="1",e}function X(t,e){if(e.type==="number")return t.value===""?null:Number(t.value);if(e.type==="boolean")return!!t.checked;if(e.type==="array"||e.type==="object")try{return JSON.parse(t.value||"null")}catch{return null}return t.value}function ue(t,e,d){e.type==="boolean"?t.checked=!!d:e.type==="array"||e.type==="object"?t.value=JSON.stringify(d??null):t.value=d??""}
@@ -1,2 +1,2 @@
1
- import{api as g}from"../api.js";const C={pages:"Page",collections:"Collection",menus:"Menu",blocks:"Block"};export const INLINE_TYPES=Object.keys(C);function d(n){return String(n||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function L(n){return String(n??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function l(n,t=""){const e=document.createElement("input");return e.type="text",e.className="form-input",e.placeholder=n,e.value=t,e}function T(n,t,e){const r=document.createElement("div");r.style.cssText="display:flex;flex-direction:column;gap:.35rem;";const a=document.createElement("label");if(a.className="form-label",a.textContent=n,r.appendChild(a),r.appendChild(t),e){const o=document.createElement("small");o.style.cssText="color:var(--text-muted,#888);font-size:.78rem;",o.textContent=e,r.appendChild(o)}return r}function x(n,t){const e=document.createElement("button");return e.type="button",e.className=t,e.textContent=n,e}function v(n,t,e=""){let r=!1;t.addEventListener("input",()=>{r=!0}),n.addEventListener("input",()=>{r||(t.value=e+d(n.value))})}const k={pages(n){const t=l("e.g. Squad List"),e=(n.rootUrl||"").replace(/\/+$/,""),r=l(e?`${e}/squad-list`:"/squad-list");return v(t,r,e+"/"),{rows:[["Title",t,"Shown as the page heading and in the pages list."],["URL path",r,e?`Keeping it under ${e}/ files the page in this project automatically.`:"Where the page lives, e.g. /squad-list."]],async submit(){const a=t.value.trim();if(!a)throw new Error("Title is required.");let o=r.value.trim()||"/"+d(a);return o.startsWith("/")||(o="/"+o),await g.pages.create({urlPath:o,frontmatter:{title:a,project:n.slug},body:""}),{editorHash:"#/pages/edit"+o,label:a}}}},collections(n){const t=l("e.g. Players"),e=l("players");return v(t,e),{rows:[["Title",t,"Display name for the collection."],["Slug",e,"Used in URLs and the API. Lowercase letters, numbers and hyphens."]],note:"Creates an empty collection tagged to this project \u2014 add fields in the editor.",async submit(){const r=t.value.trim();if(!r)throw new Error("Title is required.");const a=d(e.value||r);if(!a)throw new Error("A valid slug is required.");return await g.collections.create({title:r,slug:a,fields:[],meta:{project:n.slug}}),{editorHash:"#/collections/edit/"+encodeURIComponent(a),label:r}}}},menus(n){const t=l("e.g. Tournament Nav"),e=l("tournament-nav");return v(t,e),{rows:[["Name",t,"Display name for the menu."],["Slug",e,'Referenced by [menu slug="\u2026"] and menu locations.']],note:"Creates an empty menu tagged to this project \u2014 add items in the editor.",async submit(){const r=t.value.trim();if(!r)throw new Error("Name is required.");const a=d(e.value||r);if(!a)throw new Error("A valid slug is required.");return await g.menus.create({slug:a,name:r,items:[],meta:{project:n.slug}}),{editorHash:"#/menus/edit/"+encodeURIComponent(a),label:r}}}},blocks(n){const t=l("e.g. score-banner");return{rows:[["Name",t,'Lowercase letters, numbers and hyphens. Embed with [block name="\u2026"].']],note:"Creates a placeholder block tagged to this project \u2014 edit its HTML in the editor.",async submit(){const e=d(t.value);if(!e||!/^[a-z0-9][a-z0-9-]*$/.test(e))throw new Error("Name must be lowercase letters, numbers and hyphens.");return await g.blocks.put(e,{content:`<!-- ${e} -->
2
- `,meta:{project:n.slug}}),{editorHash:"#/blocks/edit/"+encodeURIComponent(e),label:e}}}}};export function openQuickCreate({type:n,project:t,onCreated:e}){const r=k[n];if(!r)return;const a=r(t),o=C[n],f=E.slideover({title:`New ${o}`,size:"lg",position:"right"}),i=document.createElement("div");i.style.cssText="display:flex;flex-direction:column;gap:1rem;padding:1.25rem;";const h=document.createElement("p");if(h.style.cssText="margin:0;color:var(--text-muted,#888);font-size:.9rem;",h.innerHTML=`Filed under <strong>${L(t.name||t.slug)}</strong>.`,i.appendChild(h),a.rows.forEach(([s,c,w])=>i.appendChild(T(s,c,w))),a.note){const s=document.createElement("p");s.style.cssText="margin:0;color:var(--text-muted,#888);font-size:.82rem;",s.textContent=a.note,i.appendChild(s)}const u=document.createElement("div");u.style.cssText="display:flex;gap:.5rem;flex-wrap:wrap;padding-top:.75rem;border-top:1px solid var(--border-color,rgba(255,255,255,.1));";const m=x("Create","btn btn-primary"),p=x("Create & edit","btn btn-secondary");u.appendChild(m),u.appendChild(p),i.appendChild(u);let b=!1;async function y(s){if(!b){b=!0,m.disabled=p.disabled=!0;try{const{editorHash:c,label:w}=await a.submit();E.toast(`${o} \u201C${w}\u201D created.`,{type:"success"}),f.close(),typeof e=="function"&&await e(),s&&c&&(location.hash=c)}catch(c){E.toast(c?.message||`Failed to create ${o.toLowerCase()}.`,{type:"error"}),b=!1,m.disabled=p.disabled=!1}}}m.addEventListener("click",()=>y(!1)),p.addEventListener("click",()=>y(!0)),i.addEventListener("keydown",s=>{s.key==="Enter"&&s.target.tagName==="INPUT"&&(s.preventDefault(),y(!1))}),f.setContent(i),f.open(),setTimeout(()=>{const s=i.querySelector("input");s&&s.focus()},60)}
1
+ import{api as g}from"../api.js";const C={pages:"Page",collections:"Collection",menus:"Menu",blocks:"Block"};export const INLINE_TYPES=Object.keys(C);function d(n){return String(n||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function L(n){return String(n??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function l(n,t=""){const e=document.createElement("input");return e.type="text",e.className="form-input",e.placeholder=n,e.value=t,e}function T(n,t,e){const r=document.createElement("div");r.style.cssText="display:flex;flex-direction:column;gap:.35rem;";const a=document.createElement("label");if(a.className="form-label",a.textContent=n,r.appendChild(a),r.appendChild(t),e){const o=document.createElement("small");o.style.cssText="color:var(--dm-text-muted,#888);font-size:.78rem;",o.textContent=e,r.appendChild(o)}return r}function x(n,t){const e=document.createElement("button");return e.type="button",e.className=t,e.textContent=n,e}function v(n,t,e=""){let r=!1;t.addEventListener("input",()=>{r=!0}),n.addEventListener("input",()=>{r||(t.value=e+d(n.value))})}const k={pages(n){const t=l("e.g. Squad List"),e=(n.rootUrl||"").replace(/\/+$/,""),r=l(e?`${e}/squad-list`:"/squad-list");return v(t,r,e+"/"),{rows:[["Title",t,"Shown as the page heading and in the pages list."],["URL path",r,e?`Keeping it under ${e}/ files the page in this project automatically.`:"Where the page lives, e.g. /squad-list."]],async submit(){const a=t.value.trim();if(!a)throw new Error("Title is required.");let o=r.value.trim()||"/"+d(a);return o.startsWith("/")||(o="/"+o),await g.pages.create({urlPath:o,frontmatter:{title:a,project:n.slug},body:""}),{editorHash:"#/pages/edit"+o,label:a}}}},collections(n){const t=l("e.g. Players"),e=l("players");return v(t,e),{rows:[["Title",t,"Display name for the collection."],["Slug",e,"Used in URLs and the API. Lowercase letters, numbers and hyphens."]],note:"Creates an empty collection tagged to this project \u2014 add fields in the editor.",async submit(){const r=t.value.trim();if(!r)throw new Error("Title is required.");const a=d(e.value||r);if(!a)throw new Error("A valid slug is required.");return await g.collections.create({title:r,slug:a,fields:[],meta:{project:n.slug}}),{editorHash:"#/collections/edit/"+encodeURIComponent(a),label:r}}}},menus(n){const t=l("e.g. Tournament Nav"),e=l("tournament-nav");return v(t,e),{rows:[["Name",t,"Display name for the menu."],["Slug",e,'Referenced by [menu slug="\u2026"] and menu locations.']],note:"Creates an empty menu tagged to this project \u2014 add items in the editor.",async submit(){const r=t.value.trim();if(!r)throw new Error("Name is required.");const a=d(e.value||r);if(!a)throw new Error("A valid slug is required.");return await g.menus.create({slug:a,name:r,items:[],meta:{project:n.slug}}),{editorHash:"#/menus/edit/"+encodeURIComponent(a),label:r}}}},blocks(n){const t=l("e.g. score-banner");return{rows:[["Name",t,'Lowercase letters, numbers and hyphens. Embed with [block name="\u2026"].']],note:"Creates a placeholder block tagged to this project \u2014 edit its HTML in the editor.",async submit(){const e=d(t.value);if(!e||!/^[a-z0-9][a-z0-9-]*$/.test(e))throw new Error("Name must be lowercase letters, numbers and hyphens.");return await g.blocks.put(e,{content:`<!-- ${e} -->
2
+ `,meta:{project:n.slug}}),{editorHash:"#/blocks/edit/"+encodeURIComponent(e),label:e}}}}};export function openQuickCreate({type:n,project:t,onCreated:e}){const r=k[n];if(!r)return;const a=r(t),o=C[n],f=E.slideover({title:`New ${o}`,size:"lg",position:"right"}),i=document.createElement("div");i.style.cssText="display:flex;flex-direction:column;gap:1rem;padding:1.25rem;";const h=document.createElement("p");if(h.style.cssText="margin:0;color:var(--dm-text-muted,#888);font-size:.9rem;",h.innerHTML=`Filed under <strong>${L(t.name||t.slug)}</strong>.`,i.appendChild(h),a.rows.forEach(([s,c,w])=>i.appendChild(T(s,c,w))),a.note){const s=document.createElement("p");s.style.cssText="margin:0;color:var(--dm-text-muted,#888);font-size:.82rem;",s.textContent=a.note,i.appendChild(s)}const u=document.createElement("div");u.style.cssText="display:flex;gap:.5rem;flex-wrap:wrap;padding-top:.75rem;border-top:1px solid var(--dm-border,rgba(255,255,255,.1));";const m=x("Create","btn btn-primary"),p=x("Create & edit","btn btn-secondary");u.appendChild(m),u.appendChild(p),i.appendChild(u);let b=!1;async function y(s){if(!b){b=!0,m.disabled=p.disabled=!0;try{const{editorHash:c,label:w}=await a.submit();E.toast(`${o} \u201C${w}\u201D created.`,{type:"success"}),f.close(),typeof e=="function"&&await e(),s&&c&&(location.hash=c)}catch(c){E.toast(c?.message||`Failed to create ${o.toLowerCase()}.`,{type:"error"}),b=!1,m.disabled=p.disabled=!1}}}m.addEventListener("click",()=>y(!1)),p.addEventListener("click",()=>y(!0)),i.addEventListener("keydown",s=>{s.key==="Enter"&&s.target.tagName==="INPUT"&&(s.preventDefault(),y(!1))}),f.setContent(i),f.open(),setTimeout(()=>{const s=i.querySelector("input");s&&s.focus()},60)}
@@ -1,4 +1,4 @@
1
- import{insertAtCursor as se}from"./markdown-toolbar.js";const le=20,V={render:{label:"Render",icon:"edit-3",color:"#3b82f6"},wait:{label:"Wait",icon:"clock",color:"#f59e0b"},undo:{label:"Undo",icon:"corner-up-left",color:"#a855f7"},redraw:{label:"Redraw",icon:"refresh-cw",color:"#22c55e"}},T="padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;box-sizing:border-box;width:100%;",ce="display:block;font-size:.7rem;font-weight:600;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;margin-bottom:.25rem;",de="display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.85em;";export function openScribeComposer(n){const r=ae(),e=[];let o=null;const u=E.slideover({title:"Scribe Composer",size:"lg",position:"right"});be();const b=document.createElement("div");b.className="scribe-composer",b.style.cssText="display:flex;flex-direction:column;height:100%;";const y=document.createElement("div");y.style.cssText="padding:1rem 1.25rem;border-bottom:1px solid var(--dm-border,#333);background:var(--dm-surface-subtle,#0f0f17);";const g=document.createElement("div");g.style.cssText="min-height:3.5rem;padding:.85rem 1rem;background:var(--dm-surface,#1a1a1a);border:1px dashed var(--dm-border,#333);border-radius:6px;font-size:1.25rem;line-height:1.5;overflow-wrap:anywhere;",y.appendChild(g);const w=document.createElement("div");w.style.cssText="display:flex;gap:.5rem;margin-top:.75rem;align-items:center;";const $=ee("rotate-cw","Replay"),B=ee("code","Show code"),k=document.createElement("span");k.style.cssText="font-size:.8em;color:var(--dm-text-muted,#aaa);flex:1;text-align:right;margin-right:.5rem;",w.appendChild($),w.appendChild(k),w.appendChild(B),y.appendChild(w);const p=document.createElement("pre");p.style.cssText="display:none;margin:.75rem 0 0;padding:.6rem .75rem;background:var(--dm-surface,#0a0a0a);border:1px solid var(--dm-border,#333);border-radius:4px;font-family:monospace;font-size:.78em;white-space:pre-wrap;word-break:break-all;color:var(--dm-text-muted,#bbb);max-height:200px;overflow:auto;",y.appendChild(p),B.addEventListener("click",()=>{const t=p.style.display!=="none";p.style.display=t?"none":"block"}),$.addEventListener("click",()=>X()),b.appendChild(y);const R=document.createElement("div");R.style.cssText="display:flex;flex:1;min-height:0;overflow:hidden;";const F=ue(r,()=>{v(),x()});R.appendChild(F.el);const M=document.createElement("main");M.style.cssText="flex:1;overflow-y:auto;padding:1rem 1.25rem;display:flex;flex-direction:column;";const W=document.createElement("h4");W.textContent="Actions",W.style.cssText="margin:0 0 .75rem;font-size:.75rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--dm-text-muted,#aaa);",M.appendChild(W);const z=document.createElement("div");z.style.cssText="display:flex;flex-direction:column;gap:.6rem;",M.appendChild(z);const H=document.createElement("div");H.style.cssText="display:flex;gap:.4rem;margin-top:.9rem;flex-wrap:wrap;",Object.entries(V).forEach(([t,s])=>{const l=document.createElement("button");l.type="button",l.style.cssText=`padding:.4rem .8rem;background:transparent;border:1px dashed ${s.color}66;border-radius:4px;color:${s.color};cursor:pointer;font-size:.85em;display:inline-flex;align-items:center;gap:.35rem;`;const a=document.createElement("span");a.setAttribute("data-icon",s.icon),l.appendChild(a),l.appendChild(document.createTextNode(` + ${s.label}`)),l.addEventListener("click",()=>{v(),r.actions.push(ie(t)),j(),x()}),H.appendChild(l)}),M.appendChild(H),R.appendChild(M),b.appendChild(R);const L=document.createElement("div");L.style.cssText="display:flex;padding:.75rem 1rem;border-top:1px solid var(--dm-border,#333);background:var(--dm-surface-subtle,#0f0f17);gap:.5rem;align-items:center;";const S=document.createElement("button");S.type="button",S.className="btn btn-ghost btn-sm",S.textContent="Undo (Ctrl+Z)",S.addEventListener("click",()=>J()),L.appendChild(S);const U=document.createElement("span");U.style.cssText="font-size:.75em;color:var(--dm-text-muted,#aaa);",L.appendChild(U);const G=document.createElement("div");G.style.flex="1",L.appendChild(G);const A=document.createElement("button");A.type="button",A.className="btn btn-ghost",A.textContent="Cancel",A.addEventListener("click",()=>u.close()),L.appendChild(A);const D=document.createElement("button");D.type="button",D.className="btn btn-primary",D.textContent="Insert Scribe",D.addEventListener("click",()=>{se(n,Q()),u.close()}),L.appendChild(D),b.appendChild(L),u.setContent(b),b.addEventListener("keydown",t=>{const s=(t.key||"").toLowerCase();(t.ctrlKey||t.metaKey)&&s==="z"&&!t.shiftKey&&e.length>0&&(t.preventDefault(),t.stopPropagation(),J())}),j(),x(),P(),requestAnimationFrame(()=>{Domma.icons.scan()}),u.open();function v(){e.push(JSON.stringify(r)),e.length>le&&e.shift(),P()}function J(){if(e.length===0){E.toast("Nothing to undo",{type:"info",duration:700});return}const t=JSON.parse(e.pop());Object.assign(r.globals,t.globals),r.actions.length=0,t.actions.forEach(s=>r.actions.push(s)),F.sync(),j(),x(),P(),E.toast("Undone",{type:"info",duration:500})}function P(){U.textContent=e.length===0?"":`${e.length} step${e.length===1?"":"s"} stored`,S.disabled=e.length===0,S.style.opacity=e.length===0?".4":"1"}function x(t=150){clearTimeout(o),o=setTimeout(X,t)}function X(){te(g),g.style.color="",g.style.fontStyle="",p.textContent=Q();const t=r.actions.filter(c=>c.type==="render"||c.type==="redraw"?(c.text||"").length>0:!0);if(t.length===0){g.textContent="(add an action to preview)",g.style.color="var(--dm-text-muted,#666)",g.style.fontStyle="italic",k.textContent="";return}const s=document.createElement("span");s.className="dm-fx-scribe",g.appendChild(s);const l=r.globals,a={speed:l.speed,deleteSpeed:l.deleteSpeed,cursor:l.cursor,cursorType:l.cursorType,loop:l.loop,loopDelay:l.loopDelay,pauseOnHover:l.pauseOnHover,actions:pe(t)};l.cursorChar&&(a.cursorChar=l.cursorChar);try{E.scribe(s,a),k.textContent=`${t.length} action${t.length===1?"":"s"}`}catch{k.textContent="Preview error"}}function j(){if(te(z),r.actions.length===0){const t=document.createElement("p");t.textContent="No actions yet \u2014 add one from the buttons below.",t.style.cssText="font-size:.85em;color:var(--dm-text-muted,#888);font-style:italic;margin:.5rem 0;",z.appendChild(t);return}r.actions.forEach((t,s)=>{z.appendChild(oe(t,s))}),requestAnimationFrame(()=>Domma.icons.scan())}function oe(t,s){const l=V[t.type],a=document.createElement("div");a.style.cssText=`border:1px solid var(--dm-border,#333);border-left:3px solid ${l.color};border-radius:4px;padding:.6rem .75rem;background:var(--dm-surface,#15151a);`;const c=document.createElement("div");c.style.cssText="display:flex;align-items:center;gap:.5rem;margin-bottom:.5rem;";const N=document.createElement("span");N.style.cssText=`display:inline-flex;align-items:center;gap:.3rem;font-size:.72rem;font-weight:700;color:${l.color};text-transform:uppercase;letter-spacing:.06em;`;const d=document.createElement("span");d.setAttribute("data-icon",l.icon),N.appendChild(d),N.appendChild(document.createTextNode(l.label)),c.appendChild(N);const f=document.createElement("span");f.textContent=`#${s+1}`,f.style.cssText="font-size:.7rem;color:var(--dm-text-muted,#888);",c.appendChild(f);const m=document.createElement("div");m.style.flex="1",c.appendChild(m);const i=q("chevron-up","Move up");s===0&&(i.disabled=!0,i.style.opacity=".3"),i.addEventListener("click",()=>Z(s,-1)),c.appendChild(i);const h=q("chevron-down","Move down");s===r.actions.length-1&&(h.disabled=!0,h.style.opacity=".3"),h.addEventListener("click",()=>Z(s,1)),c.appendChild(h);const C=q("x","Remove");return C.addEventListener("click",()=>{v(),r.actions.splice(s,1),j(),x()}),c.appendChild(C),a.appendChild(c),a.appendChild(re(t)),a}function Z(t,s){const l=t+s;if(l<0||l>=r.actions.length)return;v();const[a]=r.actions.splice(t,1);r.actions.splice(l,0,a),j(),x()}function re(t){const s=document.createElement("div");if(s.style.cssText="display:flex;flex-direction:column;gap:.5rem;",t.type==="render"||t.type==="redraw"){const d=document.createElement("textarea");d.value=t.text||"",d.placeholder=t.type==="redraw"?"New text \u2014 clears everything first, then types this":"Text to type out",d.rows=2,d.style.cssText=T+"resize:vertical;font-family:inherit;min-height:2.2rem;";let f=d.value;d.addEventListener("input",()=>{t.text=d.value,x()}),d.addEventListener("blur",()=>{d.value!==f&&(v(),f=d.value)}),s.appendChild(d);const m=document.createElement("div");m.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.8em;";const i=document.createElement("label");i.textContent="Effect:",i.style.color="var(--dm-text-muted,#aaa)";const h=document.createElement("select");return h.style.cssText=T+"width:auto;padding:.25rem .4rem;",["none","fade","bounce","glow"].forEach(C=>{const _=document.createElement("option");_.value=C,_.textContent=C.charAt(0).toUpperCase()+C.slice(1),h.appendChild(_)}),h.value=t.effect||"none",h.addEventListener("change",()=>{v(),t.effect=h.value,x()}),m.appendChild(i),m.appendChild(h),s.appendChild(m),s}if(t.type==="wait"){const d=document.createElement("div");d.style.cssText="display:flex;gap:.4rem;align-items:center;";const f=document.createElement("input");f.type="number",f.min="0",f.value=String(t.duration??1e3),f.style.cssText=T+"flex:1;",f.addEventListener("input",()=>{const i=parseInt(f.value,10);!Number.isNaN(i)&&i>=0&&(t.duration=i,x())}),f.addEventListener("blur",()=>v()),d.appendChild(f);const m=document.createElement("select");return m.style.cssText=T+"width:auto;",[["ms","ms"],["s","seconds"]].forEach(([i,h])=>{const C=document.createElement("option");C.value=i,C.textContent=h,m.appendChild(C)}),m.value=t.unit||"ms",m.addEventListener("change",()=>{v(),t.unit=m.value,x()}),d.appendChild(m),s.appendChild(d),s}const l=document.createElement("div");l.style.cssText="display:flex;gap:.75rem;align-items:center;flex-wrap:wrap;font-size:.85em;";const a=document.createElement("input");a.type="number",a.min="1",a.value=String(t.count||5),a.style.cssText=T+"width:5rem;",a.addEventListener("input",()=>{const d=parseInt(a.value,10);!Number.isNaN(d)&&d>0&&(t.count=d,x())}),a.addEventListener("blur",()=>v());const c=`undo-mode-${Math.random().toString(36).slice(2)}`;return[["last","Last render"],["all","All text"],["count","Exactly N chars"]].forEach(([d,f])=>{const m=document.createElement("label");m.style.cssText="display:inline-flex;align-items:center;gap:.3rem;cursor:pointer;";const i=document.createElement("input");i.type="radio",i.name=c,i.value=d,i.checked=(t.mode||"last")===d,i.addEventListener("change",()=>{i.checked&&(v(),t.mode=d,a.style.display=d==="count"?"":"none",x())}),m.appendChild(i),m.appendChild(document.createTextNode(f)),l.appendChild(m),d==="count"&&(l.appendChild(a),a.style.display=(t.mode||"last")==="count"?"":"none")}),s.appendChild(l),s}function Q(){const t=r.globals,s=[];t.speed!==50&&s.push(`speed="${t.speed}"`),t.deleteSpeed!==30&&s.push(`delete-speed="${t.deleteSpeed}"`),t.cursor?(t.cursorType!=="caret"&&s.push(`cursor-type="${t.cursorType}"`),t.cursorChar&&s.push(`cursor-char="${he(t.cursorChar)}"`)):s.push('cursor="false"'),t.loop&&(s.push('loop="true"'),t.loopDelay!==1e3&&s.push(`loop-delay="${t.loopDelay}"`)),t.pauseOnHover&&s.push('pause-on-hover="true"');const l=s.length?" "+s.join(" "):"",a=r.actions.map(c=>c.type==="render"?`[render${c.effect&&c.effect!=="none"?` effect="${c.effect}"`:""}]${c.text||""}[/render]`:c.type==="redraw"?`[redraw${c.effect&&c.effect!=="none"?` effect="${c.effect}"`:""}]${c.text||""}[/redraw]`:c.type==="wait"?`[wait]${c.duration}${c.unit==="s"?"s":""}[/wait]`:c.mode==="all"?'[undo all="true" /]':c.mode==="count"?`[undo count="${c.count}" /]`:"[undo /]");return`[scribe${l}]
2
- ${a.join(`
1
+ import{insertAtCursor as se}from"./markdown-toolbar.js";const le=20,V={render:{label:"Render",icon:"edit-3",color:"var(--dm-info,#3b82f6)"},wait:{label:"Wait",icon:"clock",color:"var(--dm-warning,#f59e0b)"},undo:{label:"Undo",icon:"corner-up-left",color:"var(--dm-secondary,#a855f7)"},redraw:{label:"Redraw",icon:"refresh-cw",color:"var(--dm-success,#22c55e)"}},T="padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;box-sizing:border-box;width:100%;",ce="display:block;font-size:.7rem;font-weight:600;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;margin-bottom:.25rem;",ae="display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.85em;";export function openScribeComposer(n){const r=de(),e=[];let o=null;const u=E.slideover({title:"Scribe Composer",size:"lg",position:"right"});be();const b=document.createElement("div");b.className="scribe-composer",b.style.cssText="display:flex;flex-direction:column;height:100%;";const y=document.createElement("div");y.style.cssText="padding:1rem 1.25rem;border-bottom:1px solid var(--dm-border,#333);background:var(--dm-background-alt,#0f0f17);";const g=document.createElement("div");g.style.cssText="min-height:3.5rem;padding:.85rem 1rem;background:var(--dm-surface,#1a1a1a);border:1px dashed var(--dm-border,#333);border-radius:6px;font-size:1.25rem;line-height:1.5;overflow-wrap:anywhere;",y.appendChild(g);const w=document.createElement("div");w.style.cssText="display:flex;gap:.5rem;margin-top:.75rem;align-items:center;";const $=ee("rotate-cw","Replay"),B=ee("code","Show code"),k=document.createElement("span");k.style.cssText="font-size:.8em;color:var(--dm-text-muted,#aaa);flex:1;text-align:right;margin-right:.5rem;",w.appendChild($),w.appendChild(k),w.appendChild(B),y.appendChild(w);const p=document.createElement("pre");p.style.cssText="display:none;margin:.75rem 0 0;padding:.6rem .75rem;background:var(--dm-surface,#0a0a0a);border:1px solid var(--dm-border,#333);border-radius:4px;font-family:monospace;font-size:.78em;white-space:pre-wrap;word-break:break-all;color:var(--dm-text-muted,#bbb);max-height:200px;overflow:auto;",y.appendChild(p),B.addEventListener("click",()=>{const t=p.style.display!=="none";p.style.display=t?"none":"block"}),$.addEventListener("click",()=>X()),b.appendChild(y);const R=document.createElement("div");R.style.cssText="display:flex;flex:1;min-height:0;overflow:hidden;";const F=ue(r,()=>{v(),x()});R.appendChild(F.el);const M=document.createElement("main");M.style.cssText="flex:1;overflow-y:auto;padding:1rem 1.25rem;display:flex;flex-direction:column;";const W=document.createElement("h4");W.textContent="Actions",W.style.cssText="margin:0 0 .75rem;font-size:.75rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--dm-text-muted,#aaa);",M.appendChild(W);const z=document.createElement("div");z.style.cssText="display:flex;flex-direction:column;gap:.6rem;",M.appendChild(z);const H=document.createElement("div");H.style.cssText="display:flex;gap:.4rem;margin-top:.9rem;flex-wrap:wrap;",Object.entries(V).forEach(([t,s])=>{const l=document.createElement("button");l.type="button",l.style.cssText=`padding:.4rem .8rem;background:transparent;border:1px dashed color-mix(in srgb, ${s.color} 40%, transparent);border-radius:4px;color:${s.color};cursor:pointer;font-size:.85em;display:inline-flex;align-items:center;gap:.35rem;`;const d=document.createElement("span");d.setAttribute("data-icon",s.icon),l.appendChild(d),l.appendChild(document.createTextNode(` + ${s.label}`)),l.addEventListener("click",()=>{v(),r.actions.push(ie(t)),j(),x()}),H.appendChild(l)}),M.appendChild(H),R.appendChild(M),b.appendChild(R);const L=document.createElement("div");L.style.cssText="display:flex;padding:.75rem 1rem;border-top:1px solid var(--dm-border,#333);background:var(--dm-background-alt,#0f0f17);gap:.5rem;align-items:center;";const S=document.createElement("button");S.type="button",S.className="btn btn-ghost btn-sm",S.textContent="Undo (Ctrl+Z)",S.addEventListener("click",()=>J()),L.appendChild(S);const U=document.createElement("span");U.style.cssText="font-size:.75em;color:var(--dm-text-muted,#aaa);",L.appendChild(U);const G=document.createElement("div");G.style.flex="1",L.appendChild(G);const A=document.createElement("button");A.type="button",A.className="btn btn-ghost",A.textContent="Cancel",A.addEventListener("click",()=>u.close()),L.appendChild(A);const D=document.createElement("button");D.type="button",D.className="btn btn-primary",D.textContent="Insert Scribe",D.addEventListener("click",()=>{se(n,Q()),u.close()}),L.appendChild(D),b.appendChild(L),u.setContent(b),b.addEventListener("keydown",t=>{const s=(t.key||"").toLowerCase();(t.ctrlKey||t.metaKey)&&s==="z"&&!t.shiftKey&&e.length>0&&(t.preventDefault(),t.stopPropagation(),J())}),j(),x(),P(),requestAnimationFrame(()=>{Domma.icons.scan()}),u.open();function v(){e.push(JSON.stringify(r)),e.length>le&&e.shift(),P()}function J(){if(e.length===0){E.toast("Nothing to undo",{type:"info",duration:700});return}const t=JSON.parse(e.pop());Object.assign(r.globals,t.globals),r.actions.length=0,t.actions.forEach(s=>r.actions.push(s)),F.sync(),j(),x(),P(),E.toast("Undone",{type:"info",duration:500})}function P(){U.textContent=e.length===0?"":`${e.length} step${e.length===1?"":"s"} stored`,S.disabled=e.length===0,S.style.opacity=e.length===0?".4":"1"}function x(t=150){clearTimeout(o),o=setTimeout(X,t)}function X(){te(g),g.style.color="",g.style.fontStyle="",p.textContent=Q();const t=r.actions.filter(c=>c.type==="render"||c.type==="redraw"?(c.text||"").length>0:!0);if(t.length===0){g.textContent="(add an action to preview)",g.style.color="var(--dm-text-muted,#666)",g.style.fontStyle="italic",k.textContent="";return}const s=document.createElement("span");s.className="dm-fx-scribe",g.appendChild(s);const l=r.globals,d={speed:l.speed,deleteSpeed:l.deleteSpeed,cursor:l.cursor,cursorType:l.cursorType,loop:l.loop,loopDelay:l.loopDelay,pauseOnHover:l.pauseOnHover,actions:pe(t)};l.cursorChar&&(d.cursorChar=l.cursorChar);try{E.scribe(s,d),k.textContent=`${t.length} action${t.length===1?"":"s"}`}catch{k.textContent="Preview error"}}function j(){if(te(z),r.actions.length===0){const t=document.createElement("p");t.textContent="No actions yet \u2014 add one from the buttons below.",t.style.cssText="font-size:.85em;color:var(--dm-text-muted,#888);font-style:italic;margin:.5rem 0;",z.appendChild(t);return}r.actions.forEach((t,s)=>{z.appendChild(oe(t,s))}),requestAnimationFrame(()=>Domma.icons.scan())}function oe(t,s){const l=V[t.type],d=document.createElement("div");d.style.cssText=`border:1px solid var(--dm-border,#333);border-left:3px solid ${l.color};border-radius:4px;padding:.6rem .75rem;background:var(--dm-surface,#15151a);`;const c=document.createElement("div");c.style.cssText="display:flex;align-items:center;gap:.5rem;margin-bottom:.5rem;";const N=document.createElement("span");N.style.cssText=`display:inline-flex;align-items:center;gap:.3rem;font-size:.72rem;font-weight:700;color:${l.color};text-transform:uppercase;letter-spacing:.06em;`;const a=document.createElement("span");a.setAttribute("data-icon",l.icon),N.appendChild(a),N.appendChild(document.createTextNode(l.label)),c.appendChild(N);const f=document.createElement("span");f.textContent=`#${s+1}`,f.style.cssText="font-size:.7rem;color:var(--dm-text-muted,#888);",c.appendChild(f);const m=document.createElement("div");m.style.flex="1",c.appendChild(m);const i=q("chevron-up","Move up");s===0&&(i.disabled=!0,i.style.opacity=".3"),i.addEventListener("click",()=>Z(s,-1)),c.appendChild(i);const h=q("chevron-down","Move down");s===r.actions.length-1&&(h.disabled=!0,h.style.opacity=".3"),h.addEventListener("click",()=>Z(s,1)),c.appendChild(h);const C=q("x","Remove");return C.addEventListener("click",()=>{v(),r.actions.splice(s,1),j(),x()}),c.appendChild(C),d.appendChild(c),d.appendChild(re(t)),d}function Z(t,s){const l=t+s;if(l<0||l>=r.actions.length)return;v();const[d]=r.actions.splice(t,1);r.actions.splice(l,0,d),j(),x()}function re(t){const s=document.createElement("div");if(s.style.cssText="display:flex;flex-direction:column;gap:.5rem;",t.type==="render"||t.type==="redraw"){const a=document.createElement("textarea");a.value=t.text||"",a.placeholder=t.type==="redraw"?"New text \u2014 clears everything first, then types this":"Text to type out",a.rows=2,a.style.cssText=T+"resize:vertical;font-family:inherit;min-height:2.2rem;";let f=a.value;a.addEventListener("input",()=>{t.text=a.value,x()}),a.addEventListener("blur",()=>{a.value!==f&&(v(),f=a.value)}),s.appendChild(a);const m=document.createElement("div");m.style.cssText="display:flex;align-items:center;gap:.5rem;font-size:.8em;";const i=document.createElement("label");i.textContent="Effect:",i.style.color="var(--dm-text-muted,#aaa)";const h=document.createElement("select");return h.style.cssText=T+"width:auto;padding:.25rem .4rem;",["none","fade","bounce","glow"].forEach(C=>{const _=document.createElement("option");_.value=C,_.textContent=C.charAt(0).toUpperCase()+C.slice(1),h.appendChild(_)}),h.value=t.effect||"none",h.addEventListener("change",()=>{v(),t.effect=h.value,x()}),m.appendChild(i),m.appendChild(h),s.appendChild(m),s}if(t.type==="wait"){const a=document.createElement("div");a.style.cssText="display:flex;gap:.4rem;align-items:center;";const f=document.createElement("input");f.type="number",f.min="0",f.value=String(t.duration??1e3),f.style.cssText=T+"flex:1;",f.addEventListener("input",()=>{const i=parseInt(f.value,10);!Number.isNaN(i)&&i>=0&&(t.duration=i,x())}),f.addEventListener("blur",()=>v()),a.appendChild(f);const m=document.createElement("select");return m.style.cssText=T+"width:auto;",[["ms","ms"],["s","seconds"]].forEach(([i,h])=>{const C=document.createElement("option");C.value=i,C.textContent=h,m.appendChild(C)}),m.value=t.unit||"ms",m.addEventListener("change",()=>{v(),t.unit=m.value,x()}),a.appendChild(m),s.appendChild(a),s}const l=document.createElement("div");l.style.cssText="display:flex;gap:.75rem;align-items:center;flex-wrap:wrap;font-size:.85em;";const d=document.createElement("input");d.type="number",d.min="1",d.value=String(t.count||5),d.style.cssText=T+"width:5rem;",d.addEventListener("input",()=>{const a=parseInt(d.value,10);!Number.isNaN(a)&&a>0&&(t.count=a,x())}),d.addEventListener("blur",()=>v());const c=`undo-mode-${Math.random().toString(36).slice(2)}`;return[["last","Last render"],["all","All text"],["count","Exactly N chars"]].forEach(([a,f])=>{const m=document.createElement("label");m.style.cssText="display:inline-flex;align-items:center;gap:.3rem;cursor:pointer;";const i=document.createElement("input");i.type="radio",i.name=c,i.value=a,i.checked=(t.mode||"last")===a,i.addEventListener("change",()=>{i.checked&&(v(),t.mode=a,d.style.display=a==="count"?"":"none",x())}),m.appendChild(i),m.appendChild(document.createTextNode(f)),l.appendChild(m),a==="count"&&(l.appendChild(d),d.style.display=(t.mode||"last")==="count"?"":"none")}),s.appendChild(l),s}function Q(){const t=r.globals,s=[];t.speed!==50&&s.push(`speed="${t.speed}"`),t.deleteSpeed!==30&&s.push(`delete-speed="${t.deleteSpeed}"`),t.cursor?(t.cursorType!=="caret"&&s.push(`cursor-type="${t.cursorType}"`),t.cursorChar&&s.push(`cursor-char="${he(t.cursorChar)}"`)):s.push('cursor="false"'),t.loop&&(s.push('loop="true"'),t.loopDelay!==1e3&&s.push(`loop-delay="${t.loopDelay}"`)),t.pauseOnHover&&s.push('pause-on-hover="true"');const l=s.length?" "+s.join(" "):"",d=r.actions.map(c=>c.type==="render"?`[render${c.effect&&c.effect!=="none"?` effect="${c.effect}"`:""}]${c.text||""}[/render]`:c.type==="redraw"?`[redraw${c.effect&&c.effect!=="none"?` effect="${c.effect}"`:""}]${c.text||""}[/redraw]`:c.type==="wait"?`[wait]${c.duration}${c.unit==="s"?"s":""}[/wait]`:c.mode==="all"?'[undo all="true" /]':c.mode==="count"?`[undo count="${c.count}" /]`:"[undo /]");return`[scribe${l}]
2
+ ${d.join(`
3
3
  `)}
4
- [/scribe]`}}function ae(){return{globals:{speed:50,deleteSpeed:30,cursor:!0,cursorType:"caret",cursorChar:"",loop:!1,loopDelay:1e3,pauseOnHover:!1},actions:[{type:"render",text:"We build things that matter.",effect:"none"},{type:"wait",duration:1500,unit:"ms"},{type:"redraw",text:"We create solutions that last.",effect:"none"},{type:"wait",duration:1500,unit:"ms"}]}}function ie(n){switch(n){case"render":return{type:"render",text:"",effect:"none"};case"wait":return{type:"wait",duration:1e3,unit:"ms"};case"undo":return{type:"undo",mode:"last",count:5};case"redraw":return{type:"redraw",text:"",effect:"none"}}return{type:"render",text:"",effect:"none"}}function pe(n){const r=[];return n.forEach(e=>{if(e.type==="render"){const o={render:e.text||""};e.effect&&e.effect!=="none"&&(o.effect=e.effect),r.push(o)}else if(e.type==="redraw"){r.push({undoRender:"all"});const o={render:e.text||""};e.effect&&e.effect!=="none"&&(o.effect=e.effect),r.push(o)}else e.type==="wait"?r.push({wait:e.unit==="s"?(e.duration||0)*1e3:e.duration||0}):e.type==="undo"&&(e.mode==="all"?r.push({undoRender:"all"}):e.mode==="count"?r.push({undoRender:e.count}):r.push({undoRender:!0}))}),r}function ue(n,r){const e=document.createElement("aside");e.style.cssText="width:240px;flex-shrink:0;padding:1rem 1.25rem;border-right:1px solid var(--dm-border,#333);overflow-y:auto;display:flex;flex-direction:column;gap:.75rem;background:var(--dm-surface-subtle,#0c0c12);";const o=document.createElement("h4");o.textContent="Global settings",o.style.cssText="margin:0 0 .25rem;font-size:.75rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--dm-text-muted,#aaa);",e.appendChild(o);const u=K(n.globals.speed,p=>{n.globals.speed=p,r()}),b=K(n.globals.deleteSpeed,p=>{n.globals.deleteSpeed=p,r()}),y=Y(n.globals.cursor,p=>{n.globals.cursor=p,r()},"Show cursor"),g=fe([["caret","Caret (|)"],["block","Block (\u2588)"],["underline","Underline (_)"]],n.globals.cursorType,p=>{n.globals.cursorType=p,r()}),w=me(n.globals.cursorChar,"\u258C (optional override)",p=>{n.globals.cursorChar=p,r()}),$=Y(n.globals.loop,p=>{n.globals.loop=p,r()},"Loop forever"),B=K(n.globals.loopDelay,p=>{n.globals.loopDelay=p,r()},0),k=Y(n.globals.pauseOnHover,p=>{n.globals.pauseOnHover=p,r()},"Pause on hover");return e.appendChild(O("Speed (ms / char)",u)),e.appendChild(O("Delete speed (ms / char)",b)),e.appendChild(y.wrap),e.appendChild(O("Cursor style",g)),e.appendChild(O("Custom cursor char",w)),e.appendChild($.wrap),e.appendChild(O("Loop delay (ms)",B)),e.appendChild(k.wrap),{el:e,sync(){u.value=String(n.globals.speed),b.value=String(n.globals.deleteSpeed),y.input.checked=n.globals.cursor,g.value=n.globals.cursorType,w.value=n.globals.cursorChar,$.input.checked=n.globals.loop,B.value=String(n.globals.loopDelay),k.input.checked=n.globals.pauseOnHover}}}function O(n,r){const e=document.createElement("div"),o=document.createElement("label");return o.style.cssText=ce,o.textContent=n,e.appendChild(o),e.appendChild(r),e}function K(n,r,e=1){const o=document.createElement("input");return o.type="number",o.min=String(e),o.value=String(n),o.style.cssText=T,o.addEventListener("input",()=>{const u=parseInt(o.value,10);!Number.isNaN(u)&&u>=e&&r(u)}),o}function me(n,r,e){const o=document.createElement("input");return o.type="text",o.value=n,o.placeholder=r,o.style.cssText=T,o.addEventListener("input",()=>e(o.value)),o}function fe(n,r,e){const o=document.createElement("select");return o.style.cssText=T,n.forEach(([u,b])=>{const y=document.createElement("option");y.value=u,y.textContent=b,o.appendChild(y)}),o.value=r,o.addEventListener("change",()=>e(o.value)),o}function Y(n,r,e){const o=document.createElement("label");o.style.cssText=de;const u=document.createElement("input");return u.type="checkbox",u.checked=n,u.addEventListener("change",()=>r(u.checked)),o.appendChild(u),o.appendChild(document.createTextNode(e)),{wrap:o,input:u}}function ee(n,r){const e=document.createElement("button");e.type="button",e.className="btn btn-ghost btn-sm",e.style.cssText="display:inline-flex;align-items:center;gap:.35rem;";const o=document.createElement("span");return o.setAttribute("data-icon",n),e.appendChild(o),e.appendChild(document.createTextNode(r)),e}function q(n,r){const e=document.createElement("button");e.type="button",e.title=r,e.style.cssText="padding:.25rem .4rem;background:transparent;border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text-muted,#aaa);cursor:pointer;display:inline-flex;align-items:center;";const o=document.createElement("span");return o.setAttribute("data-icon",n),e.appendChild(o),e}function te(n){for(;n.firstChild;)n.removeChild(n.firstChild)}function he(n){return String(n).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}let ne=!1;function be(){ne||(ne=!0,I.register("edit-3",{viewBox:"0 0 24 24",paths:["M12 20h9","M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("clock",{viewBox:"0 0 24 24",paths:["M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z","M12 6v6l4 2"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("corner-up-left",{viewBox:"0 0 24 24",paths:["M9 14 4 9l5-5","M20 20v-7a4 4 0 0 0-4-4H4"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("refresh-cw",{viewBox:"0 0 24 24",paths:["M23 4v6h-6","M1 20v-6h6","M3.51 9a9 9 0 0 1 14.85-3.36L23 10","M20.49 15a9 9 0 0 1-14.85 3.36L1 14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("rotate-cw",{viewBox:"0 0 24 24",paths:["M23 4v6h-6","M20.49 15a9 9 0 1 1-2.12-9.36L23 10"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("code",{viewBox:"0 0 24 24",paths:["M16 18l6-6-6-6","M8 6l-6 6 6 6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("chevron-up",{viewBox:"0 0 24 24",path:"M18 15l-6-6-6 6",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("chevron-down",{viewBox:"0 0 24 24",path:"M6 9l6 6 6-6",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("x",{viewBox:"0 0 24 24",paths:["M18 6L6 18","M6 6l12 12"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}))}
4
+ [/scribe]`}}function de(){return{globals:{speed:50,deleteSpeed:30,cursor:!0,cursorType:"caret",cursorChar:"",loop:!1,loopDelay:1e3,pauseOnHover:!1},actions:[{type:"render",text:"We build things that matter.",effect:"none"},{type:"wait",duration:1500,unit:"ms"},{type:"redraw",text:"We create solutions that last.",effect:"none"},{type:"wait",duration:1500,unit:"ms"}]}}function ie(n){switch(n){case"render":return{type:"render",text:"",effect:"none"};case"wait":return{type:"wait",duration:1e3,unit:"ms"};case"undo":return{type:"undo",mode:"last",count:5};case"redraw":return{type:"redraw",text:"",effect:"none"}}return{type:"render",text:"",effect:"none"}}function pe(n){const r=[];return n.forEach(e=>{if(e.type==="render"){const o={render:e.text||""};e.effect&&e.effect!=="none"&&(o.effect=e.effect),r.push(o)}else if(e.type==="redraw"){r.push({undoRender:"all"});const o={render:e.text||""};e.effect&&e.effect!=="none"&&(o.effect=e.effect),r.push(o)}else e.type==="wait"?r.push({wait:e.unit==="s"?(e.duration||0)*1e3:e.duration||0}):e.type==="undo"&&(e.mode==="all"?r.push({undoRender:"all"}):e.mode==="count"?r.push({undoRender:e.count}):r.push({undoRender:!0}))}),r}function ue(n,r){const e=document.createElement("aside");e.style.cssText="width:240px;flex-shrink:0;padding:1rem 1.25rem;border-right:1px solid var(--dm-border,#333);overflow-y:auto;display:flex;flex-direction:column;gap:.75rem;background:var(--dm-background-alt,#0c0c12);";const o=document.createElement("h4");o.textContent="Global settings",o.style.cssText="margin:0 0 .25rem;font-size:.75rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--dm-text-muted,#aaa);",e.appendChild(o);const u=K(n.globals.speed,p=>{n.globals.speed=p,r()}),b=K(n.globals.deleteSpeed,p=>{n.globals.deleteSpeed=p,r()}),y=Y(n.globals.cursor,p=>{n.globals.cursor=p,r()},"Show cursor"),g=fe([["caret","Caret (|)"],["block","Block (\u2588)"],["underline","Underline (_)"]],n.globals.cursorType,p=>{n.globals.cursorType=p,r()}),w=me(n.globals.cursorChar,"\u258C (optional override)",p=>{n.globals.cursorChar=p,r()}),$=Y(n.globals.loop,p=>{n.globals.loop=p,r()},"Loop forever"),B=K(n.globals.loopDelay,p=>{n.globals.loopDelay=p,r()},0),k=Y(n.globals.pauseOnHover,p=>{n.globals.pauseOnHover=p,r()},"Pause on hover");return e.appendChild(O("Speed (ms / char)",u)),e.appendChild(O("Delete speed (ms / char)",b)),e.appendChild(y.wrap),e.appendChild(O("Cursor style",g)),e.appendChild(O("Custom cursor char",w)),e.appendChild($.wrap),e.appendChild(O("Loop delay (ms)",B)),e.appendChild(k.wrap),{el:e,sync(){u.value=String(n.globals.speed),b.value=String(n.globals.deleteSpeed),y.input.checked=n.globals.cursor,g.value=n.globals.cursorType,w.value=n.globals.cursorChar,$.input.checked=n.globals.loop,B.value=String(n.globals.loopDelay),k.input.checked=n.globals.pauseOnHover}}}function O(n,r){const e=document.createElement("div"),o=document.createElement("label");return o.style.cssText=ce,o.textContent=n,e.appendChild(o),e.appendChild(r),e}function K(n,r,e=1){const o=document.createElement("input");return o.type="number",o.min=String(e),o.value=String(n),o.style.cssText=T,o.addEventListener("input",()=>{const u=parseInt(o.value,10);!Number.isNaN(u)&&u>=e&&r(u)}),o}function me(n,r,e){const o=document.createElement("input");return o.type="text",o.value=n,o.placeholder=r,o.style.cssText=T,o.addEventListener("input",()=>e(o.value)),o}function fe(n,r,e){const o=document.createElement("select");return o.style.cssText=T,n.forEach(([u,b])=>{const y=document.createElement("option");y.value=u,y.textContent=b,o.appendChild(y)}),o.value=r,o.addEventListener("change",()=>e(o.value)),o}function Y(n,r,e){const o=document.createElement("label");o.style.cssText=ae;const u=document.createElement("input");return u.type="checkbox",u.checked=n,u.addEventListener("change",()=>r(u.checked)),o.appendChild(u),o.appendChild(document.createTextNode(e)),{wrap:o,input:u}}function ee(n,r){const e=document.createElement("button");e.type="button",e.className="btn btn-ghost btn-sm",e.style.cssText="display:inline-flex;align-items:center;gap:.35rem;";const o=document.createElement("span");return o.setAttribute("data-icon",n),e.appendChild(o),e.appendChild(document.createTextNode(r)),e}function q(n,r){const e=document.createElement("button");e.type="button",e.title=r,e.style.cssText="padding:.25rem .4rem;background:transparent;border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text-muted,#aaa);cursor:pointer;display:inline-flex;align-items:center;";const o=document.createElement("span");return o.setAttribute("data-icon",n),e.appendChild(o),e}function te(n){for(;n.firstChild;)n.removeChild(n.firstChild)}function he(n){return String(n).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}let ne=!1;function be(){ne||(ne=!0,I.register("edit-3",{viewBox:"0 0 24 24",paths:["M12 20h9","M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("clock",{viewBox:"0 0 24 24",paths:["M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z","M12 6v6l4 2"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("corner-up-left",{viewBox:"0 0 24 24",paths:["M9 14 4 9l5-5","M20 20v-7a4 4 0 0 0-4-4H4"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("refresh-cw",{viewBox:"0 0 24 24",paths:["M23 4v6h-6","M1 20v-6h6","M3.51 9a9 9 0 0 1 14.85-3.36L23 10","M20.49 15a9 9 0 0 1-14.85 3.36L1 14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("rotate-cw",{viewBox:"0 0 24 24",paths:["M23 4v6h-6","M20.49 15a9 9 0 1 1-2.12-9.36L23 10"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("code",{viewBox:"0 0 24 24",paths:["M16 18l6-6-6-6","M8 6l-6 6 6 6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("chevron-up",{viewBox:"0 0 24 24",path:"M18 15l-6-6-6 6",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("chevron-down",{viewBox:"0 0 24 24",path:"M6 9l6 6 6-6",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("x",{viewBox:"0 0 24 24",paths:["M18 6L6 18","M6 6l12 12"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}))}
@@ -1,9 +1,9 @@
1
- import{SHORTCODES as f}from"./shortcode-registry.js";import{EFFECTS as p}from"./effect-defs.js";import{findEnclosingShortcode as k,setAttr as g,setAttrs as M,effectAttrKeys as R}from"./shortcode-tags.js";import{insertAtCursor as C}from"./markdown-toolbar.js";const A=f.map(e=>({name:e.name,selfClosing:!!e.selfClosing})),N=new Map(f.map(e=>[e.name,e])),D=["Layout","Content","Components","Data","Media","Effects"],P=new Map(p.map(e=>[e.name,e])),Y=p.map(e=>({name:e.name,selfClosing:!!e.selfClosing})),j=[...A,...Y],w=new Set(["card","hero","banner","col","button"]);let a=null;const y="position:fixed;z-index:10000;min-width:210px;max-height:70vh;overflow-y:auto;background:var(--dm-surface,#1c1c30);border:1px solid var(--dm-border,#2a2a40);border-radius:6px;box-shadow:0 8px 28px rgba(0,0,0,.45);padding:.3rem;font-size:.83rem;color:var(--dm-text,#e5e5e5);",d="display:flex;align-items:center;gap:.5rem;width:100%;text-align:left;padding:.35rem .55rem;border:none;background:transparent;color:inherit;border-radius:4px;cursor:pointer;font-size:.83rem;",z="padding:.3rem .55rem;color:var(--dm-text-muted,#8a8a9a);font-size:.68rem;text-transform:uppercase;letter-spacing:.06em;",F="flex:1;min-width:0;padding:.2rem .4rem;background:var(--dm-input-bg,#12121e);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.8rem;",O="height:1px;background:var(--dm-border,#2a2a40);margin:.3rem .2rem;";function m(e){return e.addEventListener("mouseenter",()=>{e.style.background="var(--dm-primary,#4338ca)",e.style.color="#fff"}),e.addEventListener("mouseleave",()=>{e.style.background="transparent",e.style.color="inherit"}),e}export function attachContextMenu(e){e.addEventListener("contextmenu",t=>{t.preventDefault(),u();const n=k(e,j);W(e,n,t.clientX,t.clientY)})}function u(){a&&(v(),a.root.remove(),document.removeEventListener("mousedown",T,!0),document.removeEventListener("keydown",_,!0),window.removeEventListener("scroll",u,!0),a=null)}const T=e=>{a&&!a.root.contains(e.target)&&!(a.submenu&&a.submenu.contains(e.target))&&u()},_=e=>{e.key==="Escape"&&u()};function W(e,t,n,o){const c=document.createElement("div");c.className="dm-sc-menu",c.style.cssText=y,a={root:c,textarea:e,span:t,submenu:null};const s=t&&(N.get(t.name)||P.get(t.name)),r=t&&w.has(t.name)?p.filter(l=>t.attrs[l.name]===!0):[];s&&B(c,s);for(const l of r)X(c,l);(s||r.length)&&c.appendChild(H()),c.appendChild(E("Add effect\u2026",()=>q())),c.appendChild(E("Insert\u2026",()=>J()));const i=e.selectionStart!==e.selectionEnd;(t||i)&&c.appendChild(E(i?"Wrap selection in\u2026":"Wrap in\u2026",()=>Q())),document.body.appendChild(c),$(c,n,o),document.addEventListener("mousedown",T,!0),document.addEventListener("keydown",_,!0),window.addEventListener("scroll",u,!0),window.I&&I.scan(c)}function H(){const e=document.createElement("div");return e.style.cssText=O,e}function h(e){const t=document.createElement("div");return t.style.cssText=z,t.textContent=e,t}function B(e,t){e.appendChild(h(`${t.label} options`));for(const n of t.attrs||[])e.appendChild(L(n))}function L(e,t=e.name){const n=a.span.attrs[t];switch(e.type){case"checkbox":return K(e,t,n===!0);case"select":return V(e,t,n);case"colour":return G(e,t,n);default:return U(e,t,n)}}function b(e,t){a.span=g(a.textarea,a.span,e,t)}function K(e,t,n){const o=m(document.createElement("label"));o.style.cssText=d;const c=document.createElement("input");return c.type="checkbox",c.checked=n,c.addEventListener("change",()=>b(t,!!c.checked)),o.appendChild(c),o.appendChild(document.createTextNode(e.label)),o}function U(e,t,n){const o=document.createElement("div");o.style.cssText=d+"cursor:default;";const c=document.createElement("span");c.textContent=e.label,c.style.cssText="white-space:nowrap;color:var(--dm-text-muted,#9a9aac);";const s=document.createElement("input");s.type=e.type==="number"?"number":"text",s.value=n===!0||n==null?"":n,s.style.cssText=F;let r=null;return s.addEventListener("input",()=>{clearTimeout(r),r=setTimeout(()=>b(t,s.value.trim()),180)}),s.addEventListener("mousedown",i=>i.stopPropagation()),o.appendChild(c),o.appendChild(s),o}function G(e,t,n){const o=document.createElement("div");o.style.cssText=d+"cursor:default;";const c=document.createElement("span");c.textContent=e.label,c.style.flex="1";const s=document.createElement("input");return s.type="color",typeof n=="string"&&/^#/.test(n)&&(s.value=n),s.addEventListener("input",()=>b(t,s.value)),o.appendChild(c),o.appendChild(s),o}function V(e,t,n){return E(`${e.label}${n&&n!==!0?`: ${n}`:""}`,()=>{const o=x();for(const[c,s]of e.options||[]){const r=m(document.createElement("button"));r.type="button",r.style.cssText=d,r.textContent=s,c===n&&(r.style.fontWeight="700"),r.addEventListener("click",()=>{b(t,c),v()}),o.appendChild(r)}return o})}function X(e,t){e.appendChild(h(`Effect: ${t.label}`));for(const o of t.attrs||[])e.appendChild(L(o,`${t.name}-${o.name}`));const n=m(document.createElement("button"));n.type="button",n.style.cssText=d,n.textContent="\u2715 Remove effect",n.addEventListener("click",()=>{const o={};for(const c of R(a.span.attrs,t.name))o[c]=null;M(a.textarea,a.span,o),u()}),e.appendChild(n)}function q(){const e=x(),t=a.span,n=t&&w.has(t.name)?t.name:null;for(const o of[...new Set(p.map(c=>c.category))]){const c=p.filter(s=>s.category===o);if(c.length){e.appendChild(h(o));for(const s of c){const r=n&&(s.hosts||[]).includes(n)&&t.attrs[s.name]!==!0,i=m(document.createElement("button"));if(i.type="button",i.style.cssText=d+"justify-content:space-between;",i.appendChild(document.createTextNode(s.label)),r){const l=document.createElement("span");l.textContent=`inject \u2192 [${n}]`,l.style.cssText="opacity:.6;font-size:.7rem;",i.appendChild(l)}i.addEventListener("click",()=>{if(r)g(a.textarea,a.span,s.name,!0);else{const l=s.selfClosing?`[${s.name} /]`:`[${s.name}]
1
+ import{SHORTCODES as f}from"./shortcode-registry.js";import{EFFECTS as p}from"./effect-defs.js";import{findEnclosingShortcode as k,setAttr as g,setAttrs as R,effectAttrKeys as M}from"./shortcode-tags.js";import{insertAtCursor as C,replaceRange as A}from"./markdown-toolbar.js";const N=f.map(e=>({name:e.name,selfClosing:!!e.selfClosing})),D=new Map(f.map(e=>[e.name,e])),P=["Layout","Content","Components","Data","Media","Effects"],Y=new Map(p.map(e=>[e.name,e])),j=p.map(e=>({name:e.name,selfClosing:!!e.selfClosing})),z=[...N,...j],y=new Set(["card","hero","banner","col","button"]);let a=null;const w="position:fixed;z-index:10000;min-width:210px;max-height:70vh;overflow-y:auto;background:var(--dm-surface,#1c1c30);border:1px solid var(--dm-border,#2a2a40);border-radius:6px;box-shadow:var(--dm-shadow-lg);padding:.3rem;font-size:.83rem;color:var(--dm-text,#e5e5e5);",d="display:flex;align-items:center;gap:.5rem;width:100%;text-align:left;padding:.35rem .55rem;border:none;background:transparent;color:inherit;border-radius:4px;cursor:pointer;font-size:.83rem;",F="padding:.3rem .55rem;color:var(--dm-text-muted,#8a8a9a);font-size:.68rem;text-transform:uppercase;letter-spacing:.06em;",O="flex:1;min-width:0;padding:.2rem .4rem;background:var(--dm-input-bg,#12121e);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.8rem;",W="height:1px;background:var(--dm-border,#2a2a40);margin:.3rem .2rem;";function m(e){return e.addEventListener("mouseenter",()=>{e.style.background="var(--dm-primary,#4338ca)",e.style.color="var(--dm-primary-text,#fff)"}),e.addEventListener("mouseleave",()=>{e.style.background="transparent",e.style.color="inherit"}),e}export function attachContextMenu(e){e.addEventListener("contextmenu",t=>{t.preventDefault(),u();const n=k(e,z);H(e,n,t.clientX,t.clientY)})}function u(){a&&(v(),a.root.remove(),document.removeEventListener("mousedown",_,!0),document.removeEventListener("keydown",T,!0),window.removeEventListener("scroll",u,!0),a=null)}const _=e=>{a&&!a.root.contains(e.target)&&!(a.submenu&&a.submenu.contains(e.target))&&u()},T=e=>{e.key==="Escape"&&u()};function H(e,t,n,o){const s=document.createElement("div");s.className="dm-sc-menu",s.style.cssText=w,a={root:s,textarea:e,span:t,submenu:null};const c=t&&(D.get(t.name)||Y.get(t.name)),i=t&&y.has(t.name)?p.filter(l=>l.name in t.attrs):[];c&&K(s,c);for(const l of i)Q(s,l);(c||i.length)&&s.appendChild(B()),s.appendChild(E("Add effect\u2026",()=>Z())),s.appendChild(E("Insert\u2026",()=>ee()));const r=e.selectionStart!==e.selectionEnd;(t||r)&&s.appendChild(E(r?"Wrap selection in\u2026":"Wrap in\u2026",()=>te())),document.body.appendChild(s),$(s,n,o),document.addEventListener("mousedown",_,!0),document.addEventListener("keydown",T,!0),window.addEventListener("scroll",u,!0),window.I&&I.scan(s)}function B(){const e=document.createElement("div");return e.style.cssText=W,e}function h(e){const t=document.createElement("div");return t.style.cssText=F,t.textContent=e,t}function K(e,t){e.appendChild(h(`${t.label} options`));for(const n of t.attrs||[])e.appendChild(S(n))}function S(e,t=e.name){const n=a.span.attrs[t];switch(e.type){case"checkbox":return G(e,t,U(n,e.default));case"select":return J(e,t,n);case"colour":return q(e,t,n);default:return X(e,t,n)}}function b(e,t){a.span=g(a.textarea,a.span,e,t)}function U(e,t){return e==null?!!t:!(e===!1||e==="false"||e==="0")}function V(e,t){return t===!!e.default?null:t?"true":"false"}function G(e,t,n){const o=m(document.createElement("label"));o.style.cssText=d;const s=document.createElement("input");return s.type="checkbox",s.checked=n,s.addEventListener("change",()=>b(t,V(e,s.checked))),o.appendChild(s),o.appendChild(document.createTextNode(e.label)),o}function X(e,t,n){const o=document.createElement("div");o.style.cssText=d+"cursor:default;";const s=document.createElement("span");s.textContent=e.label,s.style.cssText="white-space:nowrap;color:var(--dm-text-muted,#9a9aac);";const c=document.createElement("input");c.type=e.type==="number"?"number":"text",c.value=n===!0||n==null?"":n,e.default!=null&&e.default!==""&&(c.placeholder=String(e.default)),c.style.cssText=O;let i=null;return c.addEventListener("input",()=>{clearTimeout(i),i=setTimeout(()=>b(t,c.value.trim()),180)}),c.addEventListener("mousedown",r=>r.stopPropagation()),o.appendChild(s),o.appendChild(c),o}function q(e,t,n){const o=document.createElement("div");o.style.cssText=d+"cursor:default;";const s=document.createElement("span");s.textContent=e.label,s.style.flex="1";const c=document.createElement("input");return c.type="color",typeof n=="string"&&/^#/.test(n)?c.value=n:typeof e.default=="string"&&/^#/.test(e.default)&&(c.value=e.default),c.addEventListener("input",()=>b(t,c.value)),o.appendChild(s),o.appendChild(c),o}function J(e,t,n){const o=n==null||n===!0?e.default??"":n;return E(`${e.label}${o!==""?`: ${o}`:""}`,()=>{const s=x();for(const[c,i]of e.options||[]){const r=m(document.createElement("button"));r.type="button",r.style.cssText=d,r.textContent=i,c===o&&(r.style.fontWeight="700"),r.addEventListener("click",()=>{b(t,c),v()}),s.appendChild(r)}return s})}function Q(e,t){e.appendChild(h(`Effect: ${t.label}`));for(const o of t.attrs||[])e.appendChild(S(o,`${t.name}-${o.name}`));const n=m(document.createElement("button"));n.type="button",n.style.cssText=d,n.textContent="\u2715 Remove effect",n.addEventListener("click",()=>{const o={};for(const s of M(a.span.attrs,t.name))o[s]=null;R(a.textarea,a.span,o),u()}),e.appendChild(n)}function Z(){const e=x(),t=a.span,n=t&&y.has(t.name)?t.name:null;for(const o of[...new Set(p.map(s=>s.category))]){const s=p.filter(c=>c.category===o);if(s.length){e.appendChild(h(o));for(const c of s){const i=n&&(c.hosts||[]).includes(n)&&!(c.name in t.attrs),r=m(document.createElement("button"));if(r.type="button",r.style.cssText=d+"justify-content:space-between;",r.appendChild(document.createTextNode(c.label)),i){const l=document.createElement("span");l.textContent=`inject \u2192 [${n}]`,l.style.cssText="opacity:.6;font-size:.7rem;",r.appendChild(l)}r.addEventListener("click",()=>{if(i)g(a.textarea,a.span,c.name,!0);else{const l=c.selfClosing?`[${c.name} /]`:`[${c.name}]
2
2
  Content
3
- [/${s.name}]`;C(a.textarea,l),a.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}u()}),e.appendChild(i)}}}return e}function E(e,t){const n=m(document.createElement("button"));n.type="button",n.style.cssText=d+"justify-content:space-between;",n.appendChild(document.createTextNode(e));const o=document.createElement("span");return o.textContent="\u25B8",o.style.opacity=".6",n.appendChild(o),n.addEventListener("mouseenter",()=>S(n,t)),n.addEventListener("click",c=>{c.stopPropagation(),S(n,t)}),n}function x(){const e=document.createElement("div");return e.className="dm-sc-submenu",e.style.cssText=y,e}function S(e,t){v();const n=t();a.submenu=n,document.body.appendChild(n);const o=e.getBoundingClientRect();$(n,o.right+2,o.top,o.left-2),window.I&&I.scan(n)}function v(){a&&a.submenu&&(a.submenu.remove(),a.submenu=null)}function J(){const e=x();for(const t of D){const n=f.filter(o=>o.category===t&&!o.child);if(n.length){e.appendChild(h(t));for(const o of n){const c=m(document.createElement("button"));c.type="button",c.style.cssText=d,c.textContent=o.label,c.addEventListener("click",()=>{C(a.textarea,o.template||`[${o.name} /]`),a.textarea.dispatchEvent(new Event("input",{bubbles:!0})),u()}),e.appendChild(c)}}}return e}function Q(){const e=x(),t=f.filter(n=>n.wrappable||n.container);for(const n of t){const o=m(document.createElement("button"));o.type="button",o.style.cssText=d,o.textContent=n.label,o.addEventListener("click",()=>{Z(n),u()}),e.appendChild(o)}return e}function Z(e){const t=a.textarea,n=t.selectionStart,o=t.selectionEnd,c=t.value.slice(n,o)||"Content";let s;e.name==="grid"?s=`[grid cols="2"]
3
+ [/${c.name}]`;C(a.textarea,l)}u()}),e.appendChild(r)}}}return e}function E(e,t){const n=m(document.createElement("button"));n.type="button",n.style.cssText=d+"justify-content:space-between;",n.appendChild(document.createTextNode(e));const o=document.createElement("span");return o.textContent="\u25B8",o.style.opacity=".6",n.appendChild(o),n.addEventListener("mouseenter",()=>L(n,t)),n.addEventListener("click",s=>{s.stopPropagation(),L(n,t)}),n}function x(){const e=document.createElement("div");return e.className="dm-sc-submenu",e.style.cssText=w,e}function L(e,t){v();const n=t();a.submenu=n,document.body.appendChild(n);const o=e.getBoundingClientRect();$(n,o.right+2,o.top,o.left-2),window.I&&I.scan(n)}function v(){a&&a.submenu&&(a.submenu.remove(),a.submenu=null)}function ee(){const e=x();for(const t of P){const n=f.filter(o=>o.category===t&&!o.child);if(n.length){e.appendChild(h(t));for(const o of n){const s=m(document.createElement("button"));s.type="button",s.style.cssText=d,s.textContent=o.label,s.addEventListener("click",()=>{C(a.textarea,o.template||`[${o.name} /]`),u()}),e.appendChild(s)}}}return e}function te(){const e=x(),t=f.filter(n=>n.wrappable||n.container);for(const n of t){const o=m(document.createElement("button"));o.type="button",o.style.cssText=d,o.textContent=n.label,o.addEventListener("click",()=>{ne(n),u()}),e.appendChild(o)}return e}function ne(e){const t=a.textarea,n=t.selectionStart,o=t.selectionEnd,s=t.value.slice(n,o)||"Content";let c;e.name==="grid"?c=`[grid cols="2"]
4
4
  [col]
5
- ${c}
5
+ ${s}
6
6
  [/col]
7
- [/grid]`:s=`[${e.name}]
8
- ${c}
9
- [/${e.name}]`,t.value=t.value.slice(0,n)+s+t.value.slice(o),t.selectionStart=t.selectionEnd=n+s.length,t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}function $(e,t,n,o){e.style.left="0px",e.style.top="0px";const c=e.getBoundingClientRect();let s=t;t+c.width>window.innerWidth-8&&(s=o!=null?o-c.width:t-c.width);let r=n;n+c.height>window.innerHeight-8&&(r=Math.max(8,window.innerHeight-c.height-8)),e.style.left=`${Math.max(8,s)}px`,e.style.top=`${Math.max(8,r)}px`}
7
+ [/grid]`:c=`[${e.name}]
8
+ ${s}
9
+ [/${e.name}]`,A(t,n,o,c)}function $(e,t,n,o){e.style.left="0px",e.style.top="0px";const s=e.getBoundingClientRect();let c=t;t+s.width>window.innerWidth-8&&(c=o!=null?o-s.width:t-s.width);let i=n;n+s.height>window.innerHeight-8&&(i=Math.max(8,window.innerHeight-s.height-8)),e.style.left=`${Math.max(8,c)}px`,e.style.top=`${Math.max(8,i)}px`}
@@ -1 +1 @@
1
- import{openIconPicker as d}from"./card-builder.js";const s="display:block;font-size:.7rem;font-weight:600;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;margin-bottom:.25rem;",a="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;box-sizing:border-box;";export function makeField(r,t){const e=document.createElement("div"),n=document.createElement("label");return n.style.cssText=s,n.textContent=r,e.appendChild(n),e.appendChild(t),e}export function makeSelect(r){const t=document.createElement("select");return t.style.cssText=a,r.forEach(([e,n])=>{const o=document.createElement("option");o.value=e,o.textContent=n,t.appendChild(o)}),t}export function makeTextInput(r="",t=""){const e=document.createElement("input");return e.type="text",e.placeholder=r,e.value=t,e.style.cssText=a,e}export function makeCheckbox(r){const t=document.createElement("label");t.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;";const e=document.createElement("input");e.type="checkbox";const n=document.createElement("span");return n.style.cssText="font-size:.85em;color:var(--dm-text,#eee);",n.textContent=r,t.appendChild(e),t.appendChild(n),t}export function makeIconInput(r="",t=""){const e=document.createElement("div");e.style.cssText="display:flex;gap:.35rem;";const n=makeTextInput(r,t);n.style.flex="1";const o=document.createElement("button");return o.type="button",o.title="Browse icons",o.textContent="\u229E",o.style.cssText="padding:.35rem .55rem;background:transparent;border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text-muted,#aaa);cursor:pointer;font-size:.85em;flex-shrink:0;",o.addEventListener("click",()=>d(c=>{n.value=c,n.dispatchEvent(new Event("input",{bubbles:!0}))})),e.appendChild(n),e.appendChild(o),{el:e,input:n}}export function makeLivePreview(){const r=document.createElement("pre");return r.style.cssText="background:var(--dm-surface-subtle,#111);border:1px solid var(--dm-border,#333);border-radius:4px;padding:.5rem .75rem;font-size:.75em;color:var(--dm-text-muted,#aaa);white-space:pre-wrap;word-break:break-all;margin:0;max-height:120px;overflow:auto;",r.textContent="",{el:r,update(t){r.textContent=t}}}
1
+ import{openIconPicker as d}from"./card-builder.js";const s="display:block;font-size:.7rem;font-weight:600;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;margin-bottom:.25rem;",a="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;box-sizing:border-box;";export function makeField(r,t){const e=document.createElement("div"),n=document.createElement("label");return n.style.cssText=s,n.textContent=r,e.appendChild(n),e.appendChild(t),e}export function makeSelect(r){const t=document.createElement("select");return t.style.cssText=a,r.forEach(([e,n])=>{const o=document.createElement("option");o.value=e,o.textContent=n,t.appendChild(o)}),t}export function makeTextInput(r="",t=""){const e=document.createElement("input");return e.type="text",e.placeholder=r,e.value=t,e.style.cssText=a,e}export function makeCheckbox(r){const t=document.createElement("label");t.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;";const e=document.createElement("input");e.type="checkbox";const n=document.createElement("span");return n.style.cssText="font-size:.85em;color:var(--dm-text,#eee);",n.textContent=r,t.appendChild(e),t.appendChild(n),t}export function makeIconInput(r="",t=""){const e=document.createElement("div");e.style.cssText="display:flex;gap:.35rem;";const n=makeTextInput(r,t);n.style.flex="1";const o=document.createElement("button");return o.type="button",o.title="Browse icons",o.textContent="\u229E",o.style.cssText="padding:.35rem .55rem;background:transparent;border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text-muted,#aaa);cursor:pointer;font-size:.85em;flex-shrink:0;",o.addEventListener("click",()=>d(c=>{n.value=c,n.dispatchEvent(new Event("input",{bubbles:!0}))})),e.appendChild(n),e.appendChild(o),{el:e,input:n}}export function makeLivePreview(){const r=document.createElement("pre");return r.style.cssText="background:var(--dm-background-alt,#111);border:1px solid var(--dm-border,#333);border-radius:4px;padding:.5rem .75rem;font-size:.75em;color:var(--dm-text-muted,#aaa);white-space:pre-wrap;word-break:break-all;margin:0;max-height:120px;overflow:auto;",r.textContent="",{el:r,update(t){r.textContent=t}}}