@json-to-office/jto 0.2.0 → 0.2.1

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 (40) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/client/assets/HomePage-DX_EbLqY.js +99 -0
  3. package/dist/client/assets/HomePage-DX_EbLqY.js.map +1 -0
  4. package/dist/client/assets/{JsonEditorPage-y7DXYaWc.js → JsonEditorPage-C8a43kG2.js} +3 -3
  5. package/dist/client/assets/{JsonEditorPage-y7DXYaWc.js.map → JsonEditorPage-C8a43kG2.js.map} +1 -1
  6. package/dist/client/assets/{MonacoPluginProvider-B4-PgJ0r.js → MonacoPluginProvider-C_k1zpkx.js} +3 -3
  7. package/dist/client/assets/{MonacoPluginProvider-B4-PgJ0r.js.map → MonacoPluginProvider-C_k1zpkx.js.map} +1 -1
  8. package/dist/client/assets/{NotFoundPage-Et1QhbQw.js → NotFoundPage-ILCklaD-.js} +2 -2
  9. package/dist/client/assets/{NotFoundPage-Et1QhbQw.js.map → NotFoundPage-ILCklaD-.js.map} +1 -1
  10. package/dist/client/assets/{button-Bf6x7Zjh.js → button-DLt0WPRa.js} +2 -2
  11. package/dist/client/assets/{button-Bf6x7Zjh.js.map → button-DLt0WPRa.js.map} +1 -1
  12. package/dist/client/assets/{docx-preview-CUjVWdSJ.js → docx-preview-DkKCgwb-.js} +2 -2
  13. package/dist/client/assets/{docx-preview-CUjVWdSJ.js.map → docx-preview-DkKCgwb-.js.map} +1 -1
  14. package/dist/client/assets/{editor-Bwuq290w.js → editor-LsSIrw3S.js} +2 -2
  15. package/dist/client/assets/{editor-Bwuq290w.js.map → editor-LsSIrw3S.js.map} +1 -1
  16. package/dist/client/assets/{editor-monaco-json-BrfKPhHP.js → editor-monaco-json-CTzuM8w2.js} +3 -3
  17. package/dist/client/assets/{editor-monaco-json-BrfKPhHP.js.map → editor-monaco-json-CTzuM8w2.js.map} +1 -1
  18. package/dist/client/assets/index-Cph82KFG.css +1 -0
  19. package/dist/client/assets/{index-uE8YOnrS.js → index-CslfgN2g.js} +3 -3
  20. package/dist/client/assets/{index-uE8YOnrS.js.map → index-CslfgN2g.js.map} +1 -1
  21. package/dist/client/assets/{monaco-editor-DzeBDgmk.js → monaco-editor-B-NlkJ5A.js} +2 -2
  22. package/dist/client/assets/{monaco-editor-DzeBDgmk.js.map → monaco-editor-B-NlkJ5A.js.map} +1 -1
  23. package/dist/client/assets/{preview-kcqt_5hb.js → preview-CeZ8u4Ec.js} +3 -3
  24. package/dist/client/assets/{preview-kcqt_5hb.js.map → preview-CeZ8u4Ec.js.map} +1 -1
  25. package/dist/client/assets/{query-vendor-UL64zsGL.js → query-vendor-CT0SoqJh.js} +2 -2
  26. package/dist/client/assets/{query-vendor-UL64zsGL.js.map → query-vendor-CT0SoqJh.js.map} +1 -1
  27. package/dist/client/assets/{radix-ui-CXavUarI.js → radix-ui-DkKm4m5M.js} +2 -2
  28. package/dist/client/assets/{radix-ui-CXavUarI.js.map → radix-ui-DkKm4m5M.js.map} +1 -1
  29. package/dist/client/assets/{react-vendor-DhdcN9D5.js → react-vendor-B_QXlk-T.js} +4 -4
  30. package/dist/client/assets/{react-vendor-DhdcN9D5.js.map → react-vendor-B_QXlk-T.js.map} +1 -1
  31. package/dist/client/assets/{state-vendor-DypmJYNT.js → state-vendor-Az8redj0.js} +2 -2
  32. package/dist/client/assets/{state-vendor-DypmJYNT.js.map → state-vendor-Az8redj0.js.map} +1 -1
  33. package/dist/client/assets/{ui-vendor-BFdEgxEg.js → ui-vendor-ChWVh3T-.js} +48 -43
  34. package/dist/client/assets/ui-vendor-ChWVh3T-.js.map +1 -0
  35. package/dist/client/index.html +7 -7
  36. package/package.json +1 -1
  37. package/dist/client/assets/HomePage-BuV1dGoc.js +0 -99
  38. package/dist/client/assets/HomePage-BuV1dGoc.js.map +0 -1
  39. package/dist/client/assets/index-Dmrqj1a7.css +0 -1
  40. package/dist/client/assets/ui-vendor-BFdEgxEg.js.map +0 -1
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-monaco-json-BrfKPhHP.js","assets/query-vendor-UL64zsGL.js","assets/react-vendor-DhdcN9D5.js","assets/radix-ui-CXavUarI.js","assets/index-uE8YOnrS.js","assets/ui-vendor-BFdEgxEg.js","assets/monaco-editor-DzeBDgmk.js","assets/index-Dmrqj1a7.css","assets/MonacoPluginProvider-B4-PgJ0r.js","assets/state-vendor-DypmJYNT.js","assets/button-Bf6x7Zjh.js"])))=>i.map(i=>d[i]);
2
- import{j as e}from"./query-vendor-UL64zsGL.js";import{r}from"./react-vendor-DhdcN9D5.js";import{S as o,_ as i}from"./index-uE8YOnrS.js";import{S as n,O as a,e as l,M as d,D as c}from"./MonacoPluginProvider-B4-PgJ0r.js";import"./radix-ui-CXavUarI.js";import"./ui-vendor-BFdEgxEg.js";import"./monaco-editor-DzeBDgmk.js";import"./state-vendor-DypmJYNT.js";const m=r.lazy(()=>i(()=>import("./editor-monaco-json-BrfKPhHP.js").then(s=>s.e),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(s=>({default:s.EditorMonacoJsonMemoized})));function x(s){return e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(o,{className:"w-8 h-8 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:e.jsx(m,{...s})})}function E(){const[s,t]=r.useState(!0);return r.useEffect(()=>{t(!1)},[]),s?e.jsx("div",{className:"flex items-center justify-center h-screen",children:e.jsx("div",{children:"Loading JSON Editor..."})}):e.jsx(n,{children:e.jsx(a,{children:e.jsx(l,{children:e.jsx(d,{children:e.jsx(c,{children:e.jsx("section",{className:"flex h-screen w-full flex-col",children:e.jsx("div",{className:"grow overflow-hidden",children:e.jsxs("div",{className:"p-4 h-full",children:[e.jsx("h1",{className:"text-2xl font-bold mb-4",children:"JSON Editor"}),e.jsx("div",{className:"h-full",children:e.jsx(x,{name:"untitled",defaultValue:"",saveDocumentDebounceWait:1e3})})]})})})})})})})})}export{E as JsonEditorPage};
3
- //# sourceMappingURL=JsonEditorPage-y7DXYaWc.js.map
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-monaco-json-CTzuM8w2.js","assets/query-vendor-CT0SoqJh.js","assets/react-vendor-B_QXlk-T.js","assets/radix-ui-DkKm4m5M.js","assets/index-CslfgN2g.js","assets/ui-vendor-ChWVh3T-.js","assets/monaco-editor-B-NlkJ5A.js","assets/index-Cph82KFG.css","assets/MonacoPluginProvider-C_k1zpkx.js","assets/state-vendor-Az8redj0.js","assets/button-DLt0WPRa.js"])))=>i.map(i=>d[i]);
2
+ import{j as e}from"./query-vendor-CT0SoqJh.js";import{r}from"./react-vendor-B_QXlk-T.js";import{S as o,_ as i}from"./index-CslfgN2g.js";import{S as n,O as a,e as l,M as d,D as c}from"./MonacoPluginProvider-C_k1zpkx.js";import"./radix-ui-DkKm4m5M.js";import"./ui-vendor-ChWVh3T-.js";import"./monaco-editor-B-NlkJ5A.js";import"./state-vendor-Az8redj0.js";const m=r.lazy(()=>i(()=>import("./editor-monaco-json-CTzuM8w2.js").then(s=>s.e),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(s=>({default:s.EditorMonacoJsonMemoized})));function x(s){return e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(o,{className:"w-8 h-8 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:e.jsx(m,{...s})})}function E(){const[s,t]=r.useState(!0);return r.useEffect(()=>{t(!1)},[]),s?e.jsx("div",{className:"flex items-center justify-center h-screen",children:e.jsx("div",{children:"Loading JSON Editor..."})}):e.jsx(n,{children:e.jsx(a,{children:e.jsx(l,{children:e.jsx(d,{children:e.jsx(c,{children:e.jsx("section",{className:"flex h-screen w-full flex-col",children:e.jsx("div",{className:"grow overflow-hidden",children:e.jsxs("div",{className:"p-4 h-full",children:[e.jsx("h1",{className:"text-2xl font-bold mb-4",children:"JSON Editor"}),e.jsx("div",{className:"h-full",children:e.jsx(x,{name:"untitled",defaultValue:"",saveDocumentDebounceWait:1e3})})]})})})})})})})})}export{E as JsonEditorPage};
3
+ //# sourceMappingURL=JsonEditorPage-C8a43kG2.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";iWAIA,MAAMA,EAA4BC,OAAK,UACrC,OAAO,kCAAsB,0DAAE,KAAMC,IAAY,CAC/C,QAASA,EAAO,0BAChB,CACJ,EAQO,SAASC,EAAqBC,EAAkC,CACrE,OACEC,MAACC,WAAA,CACC,eACG,OAAI,UAAU,0CACb,SAAAC,OAAC,OAAI,UAAU,cACb,UAAAF,MAACG,EAAA,CAAQ,UAAU,uBAAuB,EAC1CH,MAAC,KAAE,UAAU,gCAAgC,6BAAiB,GAChE,EACF,EAGF,SAAAA,MAACL,EAAA,CAA2B,GAAGI,CAAA,CAAO,GAG5C,CCvBO,SAASK,GAAiB,CAC/B,KAAM,CAACC,EAASC,CAAU,EAAIC,WAAS,EAAI,EAO3C,OALAC,YAAU,IAAM,CAEdF,EAAW,EAAK,CAClB,EAAG,EAAE,EAEDD,QAEC,OAAI,UAAU,4CACb,SAAAL,MAAC,OAAI,kCAAsB,EAC7B,EAKFA,MAACS,GACC,SAAAT,MAACU,EAAA,CACC,eAACC,EAAA,CACC,SAAAX,MAACY,GACC,SAAAZ,MAACa,EAAA,CACC,eAAC,WAAQ,UAAU,gCACjB,SAAAb,MAAC,OAAI,UAAU,uBACb,SAAAE,OAAC,OAAI,UAAU,aACb,UAAAF,MAAC,MAAG,UAAU,0BAA0B,uBAAW,EACnDA,MAAC,OAAI,UAAU,SACb,SAAAA,MAACc,EAAA,CACC,KAAK,WACL,aAAa,GACb,yBAA0B,KAC5B,CACF,GACF,EACF,EACF,EACF,EACF,EACF,EACF,EACF,CAEJ","names":["EditorMonacoJsonComponent","lazy","module","EditorMonacoJsonLazy","props","jsx","Suspense","jsxs","Spinner","JsonEditorPage","loading","setLoading","useState","useEffect","SettingsStoreProvider","OutputStoreProvider","ThemesStoreProvider","MonacoPluginProvider","DocumentsStoreProvider","EditorMonacoJsonMemoized"],"ignoreList":[],"sources":["../../../src/client/components/json-editor/editor-monaco-json-lazy.tsx","../../../src/client/pages/JsonEditorPage.tsx"],"sourcesContent":["import { lazy, Suspense } from 'react';\nimport { Spinner } from '../ui/spinner';\n\n// Lazy load the Monaco editor component\nconst EditorMonacoJsonComponent = lazy(() =>\n import('./editor-monaco-json').then((module) => ({\n default: module.EditorMonacoJsonMemoized,\n }))\n);\n\ninterface EditorMonacoJsonLazyProps {\n name: string;\n defaultValue: string;\n saveDocumentDebounceWait: number;\n}\n\nexport function EditorMonacoJsonLazy(props: EditorMonacoJsonLazyProps) {\n return (\n <Suspense\n fallback={\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"text-center\">\n <Spinner className=\"w-8 h-8 mx-auto mb-2\" />\n <p className=\"text-sm text-muted-foreground\">Loading editor...</p>\n </div>\n </div>\n }\n >\n <EditorMonacoJsonComponent {...props} />\n </Suspense>\n );\n}\n\nexport { EditorMonacoJsonLazy as EditorMonacoJsonMemoized };\n","import { useEffect, useState } from 'react';\nimport { EditorMonacoJsonMemoized } from '../components/json-editor/editor-monaco-json-lazy';\nimport { DocumentsStoreProvider } from '../store/documents-store-provider';\nimport { OutputStoreProvider } from '../store/output-store-provider';\nimport { SettingsStoreProvider } from '../store/settings-store-provider';\nimport { ThemesStoreProvider } from '../store/themes-store-provider';\nimport { MonacoPluginProvider } from '../components/MonacoPluginProvider';\n\nexport function JsonEditorPage() {\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n // Initialize any necessary data\n setLoading(false);\n }, []);\n\n if (loading) {\n return (\n <div className=\"flex items-center justify-center h-screen\">\n <div>Loading JSON Editor...</div>\n </div>\n );\n }\n\n return (\n <SettingsStoreProvider>\n <OutputStoreProvider>\n <ThemesStoreProvider>\n <MonacoPluginProvider>\n <DocumentsStoreProvider>\n <section className=\"flex h-screen w-full flex-col\">\n <div className=\"grow overflow-hidden\">\n <div className=\"p-4 h-full\">\n <h1 className=\"text-2xl font-bold mb-4\">JSON Editor</h1>\n <div className=\"h-full\">\n <EditorMonacoJsonMemoized\n name=\"untitled\"\n defaultValue=\"\"\n saveDocumentDebounceWait={1000}\n />\n </div>\n </div>\n </div>\n </section>\n </DocumentsStoreProvider>\n </MonacoPluginProvider>\n </ThemesStoreProvider>\n </OutputStoreProvider>\n </SettingsStoreProvider>\n );\n}\n"],"file":"assets/JsonEditorPage-y7DXYaWc.js"}
1
+ {"version":3,"mappings":";iWAIA,MAAMA,EAA4BC,OAAK,UACrC,OAAO,kCAAsB,0DAAE,KAAMC,IAAY,CAC/C,QAASA,EAAO,0BAChB,CACJ,EAQO,SAASC,EAAqBC,EAAkC,CACrE,OACEC,MAACC,WAAA,CACC,eACG,OAAI,UAAU,0CACb,SAAAC,OAAC,OAAI,UAAU,cACb,UAAAF,MAACG,EAAA,CAAQ,UAAU,uBAAuB,EAC1CH,MAAC,KAAE,UAAU,gCAAgC,6BAAiB,GAChE,EACF,EAGF,SAAAA,MAACL,EAAA,CAA2B,GAAGI,CAAA,CAAO,GAG5C,CCvBO,SAASK,GAAiB,CAC/B,KAAM,CAACC,EAASC,CAAU,EAAIC,WAAS,EAAI,EAO3C,OALAC,YAAU,IAAM,CAEdF,EAAW,EAAK,CAClB,EAAG,EAAE,EAEDD,QAEC,OAAI,UAAU,4CACb,SAAAL,MAAC,OAAI,kCAAsB,EAC7B,EAKFA,MAACS,GACC,SAAAT,MAACU,EAAA,CACC,eAACC,EAAA,CACC,SAAAX,MAACY,GACC,SAAAZ,MAACa,EAAA,CACC,eAAC,WAAQ,UAAU,gCACjB,SAAAb,MAAC,OAAI,UAAU,uBACb,SAAAE,OAAC,OAAI,UAAU,aACb,UAAAF,MAAC,MAAG,UAAU,0BAA0B,uBAAW,EACnDA,MAAC,OAAI,UAAU,SACb,SAAAA,MAACc,EAAA,CACC,KAAK,WACL,aAAa,GACb,yBAA0B,KAC5B,CACF,GACF,EACF,EACF,EACF,EACF,EACF,EACF,EACF,CAEJ","names":["EditorMonacoJsonComponent","lazy","module","EditorMonacoJsonLazy","props","jsx","Suspense","jsxs","Spinner","JsonEditorPage","loading","setLoading","useState","useEffect","SettingsStoreProvider","OutputStoreProvider","ThemesStoreProvider","MonacoPluginProvider","DocumentsStoreProvider","EditorMonacoJsonMemoized"],"ignoreList":[],"sources":["../../../src/client/components/json-editor/editor-monaco-json-lazy.tsx","../../../src/client/pages/JsonEditorPage.tsx"],"sourcesContent":["import { lazy, Suspense } from 'react';\nimport { Spinner } from '../ui/spinner';\n\n// Lazy load the Monaco editor component\nconst EditorMonacoJsonComponent = lazy(() =>\n import('./editor-monaco-json').then((module) => ({\n default: module.EditorMonacoJsonMemoized,\n }))\n);\n\ninterface EditorMonacoJsonLazyProps {\n name: string;\n defaultValue: string;\n saveDocumentDebounceWait: number;\n}\n\nexport function EditorMonacoJsonLazy(props: EditorMonacoJsonLazyProps) {\n return (\n <Suspense\n fallback={\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"text-center\">\n <Spinner className=\"w-8 h-8 mx-auto mb-2\" />\n <p className=\"text-sm text-muted-foreground\">Loading editor...</p>\n </div>\n </div>\n }\n >\n <EditorMonacoJsonComponent {...props} />\n </Suspense>\n );\n}\n\nexport { EditorMonacoJsonLazy as EditorMonacoJsonMemoized };\n","import { useEffect, useState } from 'react';\nimport { EditorMonacoJsonMemoized } from '../components/json-editor/editor-monaco-json-lazy';\nimport { DocumentsStoreProvider } from '../store/documents-store-provider';\nimport { OutputStoreProvider } from '../store/output-store-provider';\nimport { SettingsStoreProvider } from '../store/settings-store-provider';\nimport { ThemesStoreProvider } from '../store/themes-store-provider';\nimport { MonacoPluginProvider } from '../components/MonacoPluginProvider';\n\nexport function JsonEditorPage() {\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n // Initialize any necessary data\n setLoading(false);\n }, []);\n\n if (loading) {\n return (\n <div className=\"flex items-center justify-center h-screen\">\n <div>Loading JSON Editor...</div>\n </div>\n );\n }\n\n return (\n <SettingsStoreProvider>\n <OutputStoreProvider>\n <ThemesStoreProvider>\n <MonacoPluginProvider>\n <DocumentsStoreProvider>\n <section className=\"flex h-screen w-full flex-col\">\n <div className=\"grow overflow-hidden\">\n <div className=\"p-4 h-full\">\n <h1 className=\"text-2xl font-bold mb-4\">JSON Editor</h1>\n <div className=\"h-full\">\n <EditorMonacoJsonMemoized\n name=\"untitled\"\n defaultValue=\"\"\n saveDocumentDebounceWait={1000}\n />\n </div>\n </div>\n </div>\n </section>\n </DocumentsStoreProvider>\n </MonacoPluginProvider>\n </ThemesStoreProvider>\n </OutputStoreProvider>\n </SettingsStoreProvider>\n );\n}\n"],"file":"assets/JsonEditorPage-C8a43kG2.js"}
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-editor-DzeBDgmk.js","assets/react-vendor-DhdcN9D5.js","assets/radix-ui-CXavUarI.js","assets/query-vendor-UL64zsGL.js","assets/index-uE8YOnrS.js","assets/ui-vendor-BFdEgxEg.js","assets/index-Dmrqj1a7.css"])))=>i.map(i=>d[i]);
2
- var B=Object.defineProperty;var k=(n,e,t)=>e in n?B(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var E=(n,e,t)=>k(n,typeof e!="symbol"?e+"":e,t);import{j as p}from"./query-vendor-UL64zsGL.js";import{r as u}from"./react-vendor-DhdcN9D5.js";import{c as h,d as S,p as v,a as j,u as T,e as G}from"./state-vendor-DypmJYNT.js";import{_ as C,F as q,i as I}from"./index-uE8YOnrS.js";import{loader as $}from"./monaco-editor-DzeBDgmk.js";function P(n){return new Promise((e,t)=>{n.oncomplete=n.onsuccess=()=>e(n.result),n.onabort=n.onerror=()=>t(n.error)})}function H(n,e){let t;const s=()=>{if(t)return t;const r=indexedDB.open(n);return r.onupgradeneeded=()=>r.result.createObjectStore(e),t=P(r),t.then(o=>{o.onclose=()=>t=void 0},()=>{}),t};return(r,o)=>s().then(c=>o(c.transaction(e,r).objectStore(e)))}let w;function D(){return w||(w=H("keyval-store","keyval")),w}function U(n,e=D()){return e("readonly",t=>P(t.get(n)))}function X(n,e,t=D()){return t("readwrite",s=>(s.put(e,n),P(s.transaction)))}function K(n,e=D()){return e("readwrite",t=>(t.delete(n),P(t.transaction)))}const N={getItem:async n=>await U(n)??null,setItem:async(n,e)=>{await X(n,e)},removeItem:async n=>{await K(n)}},Q=3,_=()=>({documents:[],openTabs:[],activeTab:"",buildErrors:{},documentTypes:{},pendingDiffs:{},acceptedApplyIds:[]}),Y={..._()},Z=(n=Y)=>h()(S(v(e=>({...n,createDocument:(t,s)=>e(r=>{if(r.documents.findIndex(c=>c.name===t)===-1){let c="application/json+report";if(t.toLowerCase().includes("theme")||t.toLowerCase().includes(".theme."))c="application/json+theme";else try{const i=JSON.parse(s);i.colors&&i.fonts&&i.styles&&(c="application/json+theme")}catch{}const a={name:t,type:"application/json",text:s,mtime:new Date,ctime:new Date,atime:new Date};return{documents:[...r.documents,a],documentTypes:{...r.documentTypes,[t]:c}}}return r}),deleteDocument:t=>e(s=>{const r={...s.documentTypes};return delete r[t],{documents:s.documents.filter(o=>o.name!==t),documentTypes:r,pendingDiffs:Object.fromEntries(Object.entries(s.pendingDiffs).filter(([o])=>o!==t))}}),saveDocument:(t,s)=>e(r=>{const o=r.documents.findIndex(a=>a.name===t);return o===-1||r.documents[o].text===s?r:{documents:r.documents.map((a,i)=>i===o?{...a,text:s,mtime:new Date}:a)}}),renameDocument:(t,s)=>e(r=>{const o=r.documents.findIndex(i=>i.name===t);if(o===-1)return r;const c=r.documents.map((i,l)=>l===o?{...i,name:s,ctime:new Date}:i),a=r.documentTypes[t];if(a){const i={...r.documentTypes};return delete i[t],i[s]=a,{documents:c,documentTypes:i}}return{documents:c}}),openDocument:t=>e(s=>{const r=s.documents.findIndex(a=>a.name===t);if(r===-1)return s;const o=s.documents.map((a,i)=>i===r?{...a,atime:new Date}:a);let c=s.openTabs;return c.includes(t)||(c=c.length>=Q?[...c.slice(1),t]:[...c,t]),{documents:o,openTabs:c,activeTab:t}}),closeDocument:t=>e(s=>{const r=s.openTabs.indexOf(t);if(r===-1)return s;const o=s.openTabs.filter(a=>a!==t);let c=s.activeTab;return c===t&&(o.length?c=r===0?o[0]:o[r-1]:c=""),{openTabs:o,activeTab:c}}),setActiveTab:t=>e({activeTab:t}),setBuildError:(t,s)=>e(r=>{if(r.buildErrors[t]===s)return r;const o={...r.buildErrors};return s?o[t]=s:delete o[t],{buildErrors:o}}),setPendingDiff:(t,s,r,o)=>e(c=>({pendingDiffs:{...c.pendingDiffs,[t]:{original:s,modified:r,applyId:o}}})),clearPendingDiff:(t,s)=>e(r=>{const o=r.pendingDiffs[t];if(!o)return r;const c={...r.pendingDiffs};delete c[t];const a=r.acceptedApplyIds||[],i=s&&o.applyId?[...a.slice(-199),o.applyId]:a;return{pendingDiffs:c,acceptedApplyIds:i}})}),{name:"documents-storage",version:1,storage:j(()=>N),partialize:e=>({documents:e.documents,openTabs:e.openTabs,activeTab:e.activeTab,documentTypes:e.documentTypes}),onRehydrateStorage:()=>e=>{if(e!=null&&e.documents)for(const t of e.documents)for(const s of["mtime","ctime","atime"])t[s]&&typeof t[s]=="string"&&(t[s]=new Date(t[s]))}}))),F=u.createContext(void 0),ve=({children:n})=>{const e=u.useRef(null);return e.current||(e.current=Z(_())),p.jsx(F.Provider,{value:e.current,children:n})},Te=n=>{const e=u.useContext(F);if(!e)throw new Error("useDocumentsStore must be used within DocumentsStoreProvider");return T(e,n)};function ee(n){try{const e=JSON.parse(n);return!e||typeof e!="object"?{valid:!1,errors:[{message:"Theme must be a JSON object"}]}:typeof e.name!="string"||!e.name.trim()?{valid:!1,errors:[{message:'Theme must have a non-empty "name" property'}]}:{valid:!0}}catch(e){return{valid:!1,errors:[{message:e instanceof SyntaxError?`Invalid JSON: ${e.message}`:"Failed to parse theme JSON"}]}}}function te(n){try{return n&&typeof n=="object"&&"name"in n&&typeof n.name=="string"?n.name:null}catch{return null}}const f=class f extends EventTarget{constructor(){super()}static getInstance(){return f.instance||(f.instance=new f),f.instance}emitThemeChange(e){this.dispatchEvent(new CustomEvent("themechange",{detail:e}))}onThemeChange(e){const t=s=>{e(s.detail)};return this.addEventListener("themechange",t),this._listenerCount=(this._listenerCount||0)+1,()=>{this.removeEventListener("themechange",t),this._listenerCount=Math.max(0,(this._listenerCount||1)-1)}}};E(f,"instance");let b=f;const O=b.getInstance(),L=()=>({customThemes:{}}),ne={...L()},se=(n=ne)=>h()(S(v((e,t)=>({...n,updateTheme:(s,r)=>e(o=>{const c=ee(r);let a,i=s;if(c.valid)try{const x=JSON.parse(r);a=x;const M=te(x);M&&(i=M)}catch{}const l=o.customThemes[s],d=!!l,m=(l==null?void 0:l.content)!==r,g={name:i,content:r,parsed:a,valid:c.valid,lastModified:new Date};return(m||!(l!=null&&l.valid)&&c.valid)&&c.valid&&setTimeout(()=>{O.emitThemeChange({themeName:i,timestamp:Date.now(),changeType:d?"update":"create"})},0),{customThemes:{...o.customThemes,[s]:g}}}),removeTheme:s=>e(r=>{const o=r.customThemes[s],c={...r.customThemes};return delete c[s],o&&setTimeout(()=>{O.emitThemeChange({themeName:o.name,timestamp:Date.now(),changeType:"delete"})},0),{customThemes:c}}),getTheme:s=>{const r=t();for(const o of Object.values(r.customThemes))if(o.valid&&o.name===s&&o.parsed)return o.parsed;return null},getAllThemeNames:()=>{const s=t(),r=[];for(const o of Object.values(s.customThemes))o.valid&&o.name&&r.push(o.name);return r},isThemeValid:s=>{const r=t();for(const o of Object.values(r.customThemes))if(o.name===s)return o.valid;return!1}}),{name:"themes-storage",version:4,storage:j(()=>N),partialize:e=>({customThemes:e.customThemes}),onRehydrateStorage:()=>e=>{e&&e.customThemes&&Object.keys(e.customThemes).forEach(t=>{const s=e.customThemes[t];s.lastModified&&typeof s.lastModified=="string"&&(s.lastModified=new Date(s.lastModified))})}}))),y=u.createContext(void 0),Pe=({children:n})=>{const e=u.useRef(void 0);return e.current||(e.current=se(L())),p.jsx(y.Provider,{value:e.current,children:n})},ye=n=>{const e=u.useContext(y);if(!e)throw new Error("useThemesStore must be used within ThemesStoreProvider");return T(e,n)},W=()=>({name:void 0,text:void 0,blob:void 0,globalError:void 0,isGenerating:!1,generationProgress:void 0,isRendering:!1,isPreviewStale:!1,editSequence:0,lastBuiltSequence:0}),re={...W()},oe=(n=re)=>h()(S(e=>({...n,setOutput:t=>e({...t}),bumpEditSequence:()=>e(t=>({editSequence:(t.editSequence??0)+1,editTimestamp:Date.now()}))}))),z=u.createContext(void 0),we=({children:n})=>{const e=u.useRef(null);return e.current||(e.current=oe(W())),p.jsx(z.Provider,{value:e.current,children:n})},be=n=>{const e=u.useContext(z);if(!e)throw new Error("useOutputStore must be used within OutputStoreProvider");return T(e,n)},A=G()(v((n,e)=>({selectedPlugins:new Set,selectedPluginMetadata:new Map,isApplyingPlugins:!1,lastApplyError:null,selectPlugin:t=>{n(s=>{const r=new Set(s.selectedPlugins),o=new Map(s.selectedPluginMetadata);return r.add(t.name),o.set(t.name,t),{selectedPlugins:r,selectedPluginMetadata:o}})},deselectPlugin:t=>{n(s=>{const r=new Set(s.selectedPlugins),o=new Map(s.selectedPluginMetadata);return r.delete(t),o.delete(t),{selectedPlugins:r,selectedPluginMetadata:o}})},togglePlugin:t=>{e().isPluginSelected(t.name)?e().deselectPlugin(t.name):e().selectPlugin(t),e().applyPluginsWithValidation().catch(console.error)},clearSelections:()=>{n({selectedPlugins:new Set,selectedPluginMetadata:new Map}),e().applyPluginsWithValidation().catch(console.error)},isPluginSelected:t=>e().selectedPlugins.has(t),getSelectedPluginsList:()=>Array.from(e().selectedPluginMetadata.values()),getSelectedPluginNames:()=>Array.from(e().selectedPlugins),applyPluginsWithValidation:async(t,s)=>{n({isApplyingPlugins:!0,lastApplyError:null});try{const r=Array.from(e().selectedPlugins),{loader:o}=await C(async()=>{const{loader:l}=await import("./monaco-editor-DzeBDgmk.js");return{loader:l}},__vite__mapDeps([0,1,2,3])),{updateMonacoWithPlugins:c}=await C(async()=>{const{updateMonacoWithPlugins:l}=await import("./index-uE8YOnrS.js").then(d=>d.m);return{updateMonacoWithPlugins:l}},__vite__mapDeps([4,3,1,2,5,0,6])),a=await o.init();if(!await c(a,r))throw new Error("Schema validation failed");return n({isApplyingPlugins:!1,lastApplyError:null}),t&&t(),!0}catch(r){const o=r instanceof Error?r.message:"Failed to apply plugin schemas";return n({isApplyingPlugins:!1,lastApplyError:o}),s&&s(o),console.error("Failed to apply plugins with validation:",r),!1}}}),{name:"jtp-selected-plugins",storage:{getItem:n=>{const e=localStorage.getItem(n);if(!e)return null;const{state:t}=JSON.parse(e);return{state:{...t,selectedPlugins:new Set(t.selectedPlugins||[]),selectedPluginMetadata:new Map(t.selectedPluginMetadata||[])}}},setItem:(n,e)=>{const{state:t}=e,s=JSON.stringify({state:{...t,selectedPlugins:Array.from(t.selectedPlugins),selectedPluginMetadata:Array.from(t.selectedPluginMetadata.entries())}});localStorage.setItem(n,s)},removeItem:n=>localStorage.removeItem(n)}})),J=()=>({saveDocumentDebounceWait:300,autoReload:!0,renderingLibrary:q==="docx"?"docxjs":"LibreOffice",useGlobalPreviewHeader:!0}),ce={...J()},ie=(n=ce)=>h()(S(v(e=>({...n,setSettings:t=>e({...t})}),{name:"settings-storage"}))),V=u.createContext(void 0),De=({children:n})=>{const e=u.useRef(null);return e.current||(e.current=ie(J())),p.jsx(V.Provider,{value:e.current,children:n})},xe=n=>{const e=u.useContext(V);if(!e)throw new Error("useSettingsStore must be used within SettingsStoreProvider");return T(e,n)},R=[],ae=()=>()=>{};function ue(){const n=u.useContext(y),e=u.useRef(R),t=n?()=>{const s=n.getState().getAllThemeNames();return(s.length!==e.current.length||s.some((r,o)=>r!==e.current[o]))&&(e.current=s),e.current}:()=>R;return u.useSyncExternalStore(n?n.subscribe:ae,t)}function le(){const n=u.useRef(null),e=A(i=>i.selectedPlugins),t=Array.from(e),s=ue(),r=u.useContext(y),o=u.useRef(r);o.current=r;const c=u.useRef([]),a=u.useRef([]);return u.useEffect(()=>{$.init().then(i=>{var m;n.current=i;const l=Array.from(A.getState().selectedPlugins),d=((m=o.current)==null?void 0:m.getState().getAllThemeNames())??[];I(i,l,d).then(g=>{g?console.log("[useMonacoPlugins] Monaco initialized with plugins:",l):console.warn("[useMonacoPlugins] Monaco initialization completed with warnings")}).catch(g=>{console.error("[useMonacoPlugins] Failed to update Monaco with plugins:",g)}),c.current=[...l],a.current=[...d]}).catch(i=>{console.error("Failed to initialize Monaco:",i)})},[]),u.useEffect(()=>{const i=t.length!==c.current.length||t.some((d,m)=>d!==c.current[m]),l=s.length!==a.current.length||s.some((d,m)=>d!==a.current[m]);!i&&!l||n.current&&(I(n.current,t,s).catch(d=>{console.error("[useMonacoPlugins] Failed to update Monaco schemas:",d)}),c.current=[...t],a.current=[...s])},[t,s]),{monaco:n.current,selectedPlugins:t}}function Me({children:n}){return le(),p.jsx(p.Fragment,{children:n})}export{ve as D,Me as M,we as O,De as S,y as T,ye as a,be as b,A as c,xe as d,Pe as e,z as f,te as g,F as h,N as i,O as t,Te as u,ee as v};
3
- //# sourceMappingURL=MonacoPluginProvider-B4-PgJ0r.js.map
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-editor-B-NlkJ5A.js","assets/react-vendor-B_QXlk-T.js","assets/radix-ui-DkKm4m5M.js","assets/query-vendor-CT0SoqJh.js","assets/index-CslfgN2g.js","assets/ui-vendor-ChWVh3T-.js","assets/index-Cph82KFG.css"])))=>i.map(i=>d[i]);
2
+ var B=Object.defineProperty;var k=(n,e,t)=>e in n?B(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var E=(n,e,t)=>k(n,typeof e!="symbol"?e+"":e,t);import{j as p}from"./query-vendor-CT0SoqJh.js";import{r as u}from"./react-vendor-B_QXlk-T.js";import{c as h,d as S,p as v,a as j,u as T,e as G}from"./state-vendor-Az8redj0.js";import{_ as C,F as q,i as I}from"./index-CslfgN2g.js";import{loader as $}from"./monaco-editor-B-NlkJ5A.js";function P(n){return new Promise((e,t)=>{n.oncomplete=n.onsuccess=()=>e(n.result),n.onabort=n.onerror=()=>t(n.error)})}function H(n,e){let t;const s=()=>{if(t)return t;const r=indexedDB.open(n);return r.onupgradeneeded=()=>r.result.createObjectStore(e),t=P(r),t.then(o=>{o.onclose=()=>t=void 0},()=>{}),t};return(r,o)=>s().then(c=>o(c.transaction(e,r).objectStore(e)))}let w;function D(){return w||(w=H("keyval-store","keyval")),w}function U(n,e=D()){return e("readonly",t=>P(t.get(n)))}function X(n,e,t=D()){return t("readwrite",s=>(s.put(e,n),P(s.transaction)))}function K(n,e=D()){return e("readwrite",t=>(t.delete(n),P(t.transaction)))}const N={getItem:async n=>await U(n)??null,setItem:async(n,e)=>{await X(n,e)},removeItem:async n=>{await K(n)}},Q=3,_=()=>({documents:[],openTabs:[],activeTab:"",buildErrors:{},documentTypes:{},pendingDiffs:{},acceptedApplyIds:[]}),Y={..._()},Z=(n=Y)=>h()(S(v(e=>({...n,createDocument:(t,s)=>e(r=>{if(r.documents.findIndex(c=>c.name===t)===-1){let c="application/json+report";if(t.toLowerCase().includes("theme")||t.toLowerCase().includes(".theme."))c="application/json+theme";else try{const i=JSON.parse(s);i.colors&&i.fonts&&i.styles&&(c="application/json+theme")}catch{}const a={name:t,type:"application/json",text:s,mtime:new Date,ctime:new Date,atime:new Date};return{documents:[...r.documents,a],documentTypes:{...r.documentTypes,[t]:c}}}return r}),deleteDocument:t=>e(s=>{const r={...s.documentTypes};return delete r[t],{documents:s.documents.filter(o=>o.name!==t),documentTypes:r,pendingDiffs:Object.fromEntries(Object.entries(s.pendingDiffs).filter(([o])=>o!==t))}}),saveDocument:(t,s)=>e(r=>{const o=r.documents.findIndex(a=>a.name===t);return o===-1||r.documents[o].text===s?r:{documents:r.documents.map((a,i)=>i===o?{...a,text:s,mtime:new Date}:a)}}),renameDocument:(t,s)=>e(r=>{const o=r.documents.findIndex(i=>i.name===t);if(o===-1)return r;const c=r.documents.map((i,l)=>l===o?{...i,name:s,ctime:new Date}:i),a=r.documentTypes[t];if(a){const i={...r.documentTypes};return delete i[t],i[s]=a,{documents:c,documentTypes:i}}return{documents:c}}),openDocument:t=>e(s=>{const r=s.documents.findIndex(a=>a.name===t);if(r===-1)return s;const o=s.documents.map((a,i)=>i===r?{...a,atime:new Date}:a);let c=s.openTabs;return c.includes(t)||(c=c.length>=Q?[...c.slice(1),t]:[...c,t]),{documents:o,openTabs:c,activeTab:t}}),closeDocument:t=>e(s=>{const r=s.openTabs.indexOf(t);if(r===-1)return s;const o=s.openTabs.filter(a=>a!==t);let c=s.activeTab;return c===t&&(o.length?c=r===0?o[0]:o[r-1]:c=""),{openTabs:o,activeTab:c}}),setActiveTab:t=>e({activeTab:t}),setBuildError:(t,s)=>e(r=>{if(r.buildErrors[t]===s)return r;const o={...r.buildErrors};return s?o[t]=s:delete o[t],{buildErrors:o}}),setPendingDiff:(t,s,r,o)=>e(c=>({pendingDiffs:{...c.pendingDiffs,[t]:{original:s,modified:r,applyId:o}}})),clearPendingDiff:(t,s)=>e(r=>{const o=r.pendingDiffs[t];if(!o)return r;const c={...r.pendingDiffs};delete c[t];const a=r.acceptedApplyIds||[],i=s&&o.applyId?[...a.slice(-199),o.applyId]:a;return{pendingDiffs:c,acceptedApplyIds:i}})}),{name:"documents-storage",version:1,storage:j(()=>N),partialize:e=>({documents:e.documents,openTabs:e.openTabs,activeTab:e.activeTab,documentTypes:e.documentTypes}),onRehydrateStorage:()=>e=>{if(e!=null&&e.documents)for(const t of e.documents)for(const s of["mtime","ctime","atime"])t[s]&&typeof t[s]=="string"&&(t[s]=new Date(t[s]))}}))),F=u.createContext(void 0),ve=({children:n})=>{const e=u.useRef(null);return e.current||(e.current=Z(_())),p.jsx(F.Provider,{value:e.current,children:n})},Te=n=>{const e=u.useContext(F);if(!e)throw new Error("useDocumentsStore must be used within DocumentsStoreProvider");return T(e,n)};function ee(n){try{const e=JSON.parse(n);return!e||typeof e!="object"?{valid:!1,errors:[{message:"Theme must be a JSON object"}]}:typeof e.name!="string"||!e.name.trim()?{valid:!1,errors:[{message:'Theme must have a non-empty "name" property'}]}:{valid:!0}}catch(e){return{valid:!1,errors:[{message:e instanceof SyntaxError?`Invalid JSON: ${e.message}`:"Failed to parse theme JSON"}]}}}function te(n){try{return n&&typeof n=="object"&&"name"in n&&typeof n.name=="string"?n.name:null}catch{return null}}const f=class f extends EventTarget{constructor(){super()}static getInstance(){return f.instance||(f.instance=new f),f.instance}emitThemeChange(e){this.dispatchEvent(new CustomEvent("themechange",{detail:e}))}onThemeChange(e){const t=s=>{e(s.detail)};return this.addEventListener("themechange",t),this._listenerCount=(this._listenerCount||0)+1,()=>{this.removeEventListener("themechange",t),this._listenerCount=Math.max(0,(this._listenerCount||1)-1)}}};E(f,"instance");let b=f;const O=b.getInstance(),L=()=>({customThemes:{}}),ne={...L()},se=(n=ne)=>h()(S(v((e,t)=>({...n,updateTheme:(s,r)=>e(o=>{const c=ee(r);let a,i=s;if(c.valid)try{const x=JSON.parse(r);a=x;const M=te(x);M&&(i=M)}catch{}const l=o.customThemes[s],d=!!l,m=(l==null?void 0:l.content)!==r,g={name:i,content:r,parsed:a,valid:c.valid,lastModified:new Date};return(m||!(l!=null&&l.valid)&&c.valid)&&c.valid&&setTimeout(()=>{O.emitThemeChange({themeName:i,timestamp:Date.now(),changeType:d?"update":"create"})},0),{customThemes:{...o.customThemes,[s]:g}}}),removeTheme:s=>e(r=>{const o=r.customThemes[s],c={...r.customThemes};return delete c[s],o&&setTimeout(()=>{O.emitThemeChange({themeName:o.name,timestamp:Date.now(),changeType:"delete"})},0),{customThemes:c}}),getTheme:s=>{const r=t();for(const o of Object.values(r.customThemes))if(o.valid&&o.name===s&&o.parsed)return o.parsed;return null},getAllThemeNames:()=>{const s=t(),r=[];for(const o of Object.values(s.customThemes))o.valid&&o.name&&r.push(o.name);return r},isThemeValid:s=>{const r=t();for(const o of Object.values(r.customThemes))if(o.name===s)return o.valid;return!1}}),{name:"themes-storage",version:4,storage:j(()=>N),partialize:e=>({customThemes:e.customThemes}),onRehydrateStorage:()=>e=>{e&&e.customThemes&&Object.keys(e.customThemes).forEach(t=>{const s=e.customThemes[t];s.lastModified&&typeof s.lastModified=="string"&&(s.lastModified=new Date(s.lastModified))})}}))),y=u.createContext(void 0),Pe=({children:n})=>{const e=u.useRef(void 0);return e.current||(e.current=se(L())),p.jsx(y.Provider,{value:e.current,children:n})},ye=n=>{const e=u.useContext(y);if(!e)throw new Error("useThemesStore must be used within ThemesStoreProvider");return T(e,n)},W=()=>({name:void 0,text:void 0,blob:void 0,globalError:void 0,isGenerating:!1,generationProgress:void 0,isRendering:!1,isPreviewStale:!1,editSequence:0,lastBuiltSequence:0}),re={...W()},oe=(n=re)=>h()(S(e=>({...n,setOutput:t=>e({...t}),bumpEditSequence:()=>e(t=>({editSequence:(t.editSequence??0)+1,editTimestamp:Date.now()}))}))),z=u.createContext(void 0),we=({children:n})=>{const e=u.useRef(null);return e.current||(e.current=oe(W())),p.jsx(z.Provider,{value:e.current,children:n})},be=n=>{const e=u.useContext(z);if(!e)throw new Error("useOutputStore must be used within OutputStoreProvider");return T(e,n)},A=G()(v((n,e)=>({selectedPlugins:new Set,selectedPluginMetadata:new Map,isApplyingPlugins:!1,lastApplyError:null,selectPlugin:t=>{n(s=>{const r=new Set(s.selectedPlugins),o=new Map(s.selectedPluginMetadata);return r.add(t.name),o.set(t.name,t),{selectedPlugins:r,selectedPluginMetadata:o}})},deselectPlugin:t=>{n(s=>{const r=new Set(s.selectedPlugins),o=new Map(s.selectedPluginMetadata);return r.delete(t),o.delete(t),{selectedPlugins:r,selectedPluginMetadata:o}})},togglePlugin:t=>{e().isPluginSelected(t.name)?e().deselectPlugin(t.name):e().selectPlugin(t),e().applyPluginsWithValidation().catch(console.error)},clearSelections:()=>{n({selectedPlugins:new Set,selectedPluginMetadata:new Map}),e().applyPluginsWithValidation().catch(console.error)},isPluginSelected:t=>e().selectedPlugins.has(t),getSelectedPluginsList:()=>Array.from(e().selectedPluginMetadata.values()),getSelectedPluginNames:()=>Array.from(e().selectedPlugins),applyPluginsWithValidation:async(t,s)=>{n({isApplyingPlugins:!0,lastApplyError:null});try{const r=Array.from(e().selectedPlugins),{loader:o}=await C(async()=>{const{loader:l}=await import("./monaco-editor-B-NlkJ5A.js");return{loader:l}},__vite__mapDeps([0,1,2,3])),{updateMonacoWithPlugins:c}=await C(async()=>{const{updateMonacoWithPlugins:l}=await import("./index-CslfgN2g.js").then(d=>d.m);return{updateMonacoWithPlugins:l}},__vite__mapDeps([4,3,1,2,5,0,6])),a=await o.init();if(!await c(a,r))throw new Error("Schema validation failed");return n({isApplyingPlugins:!1,lastApplyError:null}),t&&t(),!0}catch(r){const o=r instanceof Error?r.message:"Failed to apply plugin schemas";return n({isApplyingPlugins:!1,lastApplyError:o}),s&&s(o),console.error("Failed to apply plugins with validation:",r),!1}}}),{name:"jtp-selected-plugins",storage:{getItem:n=>{const e=localStorage.getItem(n);if(!e)return null;const{state:t}=JSON.parse(e);return{state:{...t,selectedPlugins:new Set(t.selectedPlugins||[]),selectedPluginMetadata:new Map(t.selectedPluginMetadata||[])}}},setItem:(n,e)=>{const{state:t}=e,s=JSON.stringify({state:{...t,selectedPlugins:Array.from(t.selectedPlugins),selectedPluginMetadata:Array.from(t.selectedPluginMetadata.entries())}});localStorage.setItem(n,s)},removeItem:n=>localStorage.removeItem(n)}})),J=()=>({saveDocumentDebounceWait:300,autoReload:!0,renderingLibrary:q==="docx"?"docxjs":"LibreOffice",useGlobalPreviewHeader:!0}),ce={...J()},ie=(n=ce)=>h()(S(v(e=>({...n,setSettings:t=>e({...t})}),{name:"settings-storage"}))),V=u.createContext(void 0),De=({children:n})=>{const e=u.useRef(null);return e.current||(e.current=ie(J())),p.jsx(V.Provider,{value:e.current,children:n})},xe=n=>{const e=u.useContext(V);if(!e)throw new Error("useSettingsStore must be used within SettingsStoreProvider");return T(e,n)},R=[],ae=()=>()=>{};function ue(){const n=u.useContext(y),e=u.useRef(R),t=n?()=>{const s=n.getState().getAllThemeNames();return(s.length!==e.current.length||s.some((r,o)=>r!==e.current[o]))&&(e.current=s),e.current}:()=>R;return u.useSyncExternalStore(n?n.subscribe:ae,t)}function le(){const n=u.useRef(null),e=A(i=>i.selectedPlugins),t=Array.from(e),s=ue(),r=u.useContext(y),o=u.useRef(r);o.current=r;const c=u.useRef([]),a=u.useRef([]);return u.useEffect(()=>{$.init().then(i=>{var m;n.current=i;const l=Array.from(A.getState().selectedPlugins),d=((m=o.current)==null?void 0:m.getState().getAllThemeNames())??[];I(i,l,d).then(g=>{g?console.log("[useMonacoPlugins] Monaco initialized with plugins:",l):console.warn("[useMonacoPlugins] Monaco initialization completed with warnings")}).catch(g=>{console.error("[useMonacoPlugins] Failed to update Monaco with plugins:",g)}),c.current=[...l],a.current=[...d]}).catch(i=>{console.error("Failed to initialize Monaco:",i)})},[]),u.useEffect(()=>{const i=t.length!==c.current.length||t.some((d,m)=>d!==c.current[m]),l=s.length!==a.current.length||s.some((d,m)=>d!==a.current[m]);!i&&!l||n.current&&(I(n.current,t,s).catch(d=>{console.error("[useMonacoPlugins] Failed to update Monaco schemas:",d)}),c.current=[...t],a.current=[...s])},[t,s]),{monaco:n.current,selectedPlugins:t}}function Me({children:n}){return le(),p.jsx(p.Fragment,{children:n})}export{ve as D,Me as M,we as O,De as S,y as T,ye as a,be as b,A as c,xe as d,Pe as e,z as f,te as g,F as h,N as i,O as t,Te as u,ee as v};
3
+ //# sourceMappingURL=MonacoPluginProvider-C_k1zpkx.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";+bAAA,SAASA,EAAiBC,EAAS,CAC/B,OAAO,IAAI,QAAQ,CAACC,EAASC,IAAW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AC,GAAGG,CAAa,CAC/C,CAAC,EACA,MAAO7B,GAAU,CAChB,QAAQ,MAAM,+BAAgCA,CAAK,CACrD,CAAC,CACL,EAAG,EAAE,EAEL2B,YAAU,IAAM,CACd,MAAMK,EACJtC,EAAoB,SAAW+B,EAAmB,QAAQ,QAC1D/B,EAAoB,KAClB,CAAChG,EAAMsB,IAAUtB,IAAS+H,EAAmB,QAAQzG,CAAK,GAGxDiH,EACJX,EAAiB,SAAWI,EAAkB,QAAQ,QACtDJ,EAAiB,KACf,CAAC5H,EAAMsB,IAAUtB,IAASgI,EAAkB,QAAQ1G,CAAK,GAGzD,CAACgH,GAAkB,CAACC,GAIpBb,EAAU,UACZvB,EACEuB,EAAU,QACV1B,EACA4B,CAAA,EACA,MAAOtB,GAAU,CACjB,QAAQ,MACN,sDACAA,CAAA,CAEJ,CAAC,EACDyB,EAAmB,QAAU,CAAC,GAAG/B,CAAmB,EACpDgC,EAAkB,QAAU,CAAC,GAAGJ,CAAgB,EAEpD,EAAG,CAAC5B,EAAqB4B,CAAgB,CAAC,EAEnC,CACL,OAAQF,EAAU,QAClB,gBAAiB1B,CAAA,CAErB,CC5HO,SAASwC,GAAqB,CACnC,SAAAjG,CACF,EAEG,CAED,OAAAkF,GAAA,oBAEU,SAAAlF,EAAS,CACrB","names":["promisifyRequest","request","resolve","reject","createStore","dbName","storeName","dbp","getDB","db","txMode","callback","defaultGetStoreFunc","defaultGetStore","get","key","customStore","store","set","value","del","idbStorage","name","MAX_OPEN_TABS","initDocumentsStore","defaultInitDocumentsState","createDocumentsStore","initState","devtools","persist","text","state","doc","docType","parsed","newDoc","newDocumentTypes","k","docIndex","oldName","newName","documents","i","openTabs","index","tab","activeTab","buildError","buildErrors","original","modified","applyId","accepted","diff","next","ids","acceptedApplyIds","createJSONStorage","DocumentsStoreContext","createContext","DocumentsStoreProvider","children","storeRef","useRef","useDocumentsStore","selector","documentsStoreContext","useContext","useStore","validateThemeJson","jsonString","getThemeName","themeJson","_ThemeChangeEmitter","event","handler","e","__publicField","ThemeChangeEmitter","themeChangeEmitter","initThemesStore","defaultInitThemesState","createThemesStore","documentName","content","validation","themeName","parsedContent","extractedName","existingTheme","isUpdate","hasContentChanged","customTheme","removedTheme","newCustomThemes","names","theme","ThemesStoreContext","ThemesStoreProvider","useThemesStore","themesStoreContext","initOutputStore","defaultInitOutputState","createOutputStore","partialState","s","OutputStoreContext","OutputStoreProvider","useOutputStore","outputStoreContext","usePluginsStore","create","plugin","newSelectedPlugins","newMetadata","pluginName","onSuccess","onError","selectedPluginNames","loader","__vitePreload","updateMonacoWithPlugins","n","monaco","error","errorMessage","str","serialized","initSettingsStore","FORMAT","defaultInitSettingsState","createSettingsStore","settings","SettingsStoreContext","SettingsStoreProvider","useSettingsStore","settingsStoreContext","emptyNames","subscribe","useCustomThemeNames","cachedRef","getSnapshot","useSyncExternalStore","useMonacoPlugins","monacoRef","selectedPlugins","customThemeNames","themesStore","themesStoreRef","previousPluginsRef","previousThemesRef","useEffect","currentPlugins","currentThemes","_a","success","pluginsChanged","themesChanged","MonacoPluginProvider"],"ignoreList":[0],"sources":["../../../../../node_modules/.pnpm/idb-keyval@6.2.2/node_modules/idb-keyval/dist/index.js","../../../src/client/lib/idb-storage.ts","../../../src/client/store/documents-store.ts","../../../src/client/store/documents-store-provider.tsx","../../../src/client/lib/theme-validation.ts","../../../src/client/utils/theme-change-emitter.ts","../../../src/client/store/themes-store.ts","../../../src/client/store/themes-store-provider.tsx","../../../src/client/store/output-store.ts","../../../src/client/store/output-store-provider.tsx","../../../src/client/store/plugins-store.ts","../../../src/client/store/settings-store.ts","../../../src/client/store/settings-store-provider.tsx","../../../src/client/hooks/useMonacoPlugins.ts","../../../src/client/components/MonacoPluginProvider.tsx"],"sourcesContent":["function promisifyRequest(request) {\n return new Promise((resolve, reject) => {\n // @ts-ignore - file size hacks\n request.oncomplete = request.onsuccess = () => resolve(request.result);\n // @ts-ignore - file size hacks\n request.onabort = request.onerror = () => reject(request.error);\n });\n}\nfunction createStore(dbName, storeName) {\n let dbp;\n const getDB = () => {\n if (dbp)\n return dbp;\n const request = indexedDB.open(dbName);\n request.onupgradeneeded = () => request.result.createObjectStore(storeName);\n dbp = promisifyRequest(request);\n dbp.then((db) => {\n // It seems like Safari sometimes likes to just close the connection.\n // It's supposed to fire this event when that happens. Let's hope it does!\n db.onclose = () => (dbp = undefined);\n }, () => { });\n return dbp;\n };\n return (txMode, callback) => getDB().then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName)));\n}\nlet defaultGetStoreFunc;\nfunction defaultGetStore() {\n if (!defaultGetStoreFunc) {\n defaultGetStoreFunc = createStore('keyval-store', 'keyval');\n }\n return defaultGetStoreFunc;\n}\n/**\n * Get a value by its key.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction get(key, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => promisifyRequest(store.get(key)));\n}\n/**\n * Set a value with a key.\n *\n * @param key\n * @param value\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction set(key, value, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.put(value, key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Set multiple values at once. This is faster than calling set() multiple times.\n * It's also atomic – if one of the pairs can't be added, none will be added.\n *\n * @param entries Array of entries, where each entry is an array of `[key, value]`.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction setMany(entries, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n entries.forEach((entry) => store.put(entry[1], entry[0]));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Get multiple values by their keys\n *\n * @param keys\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction getMany(keys, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => Promise.all(keys.map((key) => promisifyRequest(store.get(key)))));\n}\n/**\n * Update a value. This lets you see the old value and update it as an atomic operation.\n *\n * @param key\n * @param updater A callback that takes the old value and returns a new value.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction update(key, updater, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => \n // Need to create the promise manually.\n // If I try to chain promises, the transaction closes in browsers\n // that use a promise polyfill (IE10/11).\n new Promise((resolve, reject) => {\n store.get(key).onsuccess = function () {\n try {\n store.put(updater(this.result), key);\n resolve(promisifyRequest(store.transaction));\n }\n catch (err) {\n reject(err);\n }\n };\n }));\n}\n/**\n * Delete a particular key from the store.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction del(key, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.delete(key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Delete multiple keys at once.\n *\n * @param keys List of keys to delete.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction delMany(keys, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n keys.forEach((key) => store.delete(key));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Clear all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction clear(customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.clear();\n return promisifyRequest(store.transaction);\n });\n}\nfunction eachCursor(store, callback) {\n store.openCursor().onsuccess = function () {\n if (!this.result)\n return;\n callback(this.result);\n this.result.continue();\n };\n return promisifyRequest(store.transaction);\n}\n/**\n * Get all keys in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction keys(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAllKeys) {\n return promisifyRequest(store.getAllKeys());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items);\n });\n}\n/**\n * Get all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction values(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAll) {\n return promisifyRequest(store.getAll());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.value)).then(() => items);\n });\n}\n/**\n * Get all entries in the store. Each entry is an array of `[key, value]`.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction entries(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n // (although, hopefully we'll get a simpler path some day)\n if (store.getAll && store.getAllKeys) {\n return Promise.all([\n promisifyRequest(store.getAllKeys()),\n promisifyRequest(store.getAll()),\n ]).then(([keys, values]) => keys.map((key, i) => [key, values[i]]));\n }\n const items = [];\n return customStore('readonly', (store) => eachCursor(store, (cursor) => items.push([cursor.key, cursor.value])).then(() => items));\n });\n}\n\nexport { clear, createStore, del, delMany, entries, get, getMany, keys, promisifyRequest, set, setMany, update, values };\n","/**\n * IndexedDB storage adapter for Zustand persist middleware using idb-keyval.\n */\nimport { get, set, del } from 'idb-keyval';\nimport type { StateStorage } from 'zustand/middleware';\n\nexport const idbStorage: StateStorage = {\n getItem: async (name: string): Promise<string | null> => {\n return (await get(name)) ?? null;\n },\n setItem: async (name: string, value: string): Promise<void> => {\n await set(name, value);\n },\n removeItem: async (name: string): Promise<void> => {\n await del(name);\n },\n};\n","import { persist, devtools, createJSONStorage } from 'zustand/middleware';\nimport { createStore } from 'zustand/vanilla';\nimport type { TextFile } from '../lib/types';\nimport { idbStorage } from '../lib/idb-storage';\n\nconst MAX_OPEN_TABS = 3;\n\nexport type DocumentType = 'application/json+report' | 'application/json+theme';\n\nexport type DocumentsState = {\n documents: TextFile[];\n openTabs: string[];\n activeTab: string;\n buildErrors: { [key: string]: string };\n documentTypes: { [key: string]: DocumentType };\n pendingDiffs: { [key: string]: { original: string; modified: string; applyId?: string } };\n acceptedApplyIds: string[];\n};\n\nexport type DocumentsActions = {\n createDocument: (name: string, text: string) => void;\n deleteDocument: (name: string) => void;\n saveDocument: (name: string, text: string) => void;\n renameDocument: (oldName: string, newName: string) => void;\n openDocument: (name: string) => void;\n closeDocument: (name: string) => void;\n setActiveTab: (name: string) => void;\n setBuildError: (name: string, buildError?: string) => void;\n setPendingDiff: (name: string, original: string, modified: string, applyId?: string) => void;\n clearPendingDiff: (name: string, accepted?: boolean) => void;\n};\n\nexport type DocumentsStore = DocumentsState & DocumentsActions;\n\nexport const initDocumentsStore = (): DocumentsState => {\n return {\n documents: [],\n openTabs: [],\n activeTab: '',\n buildErrors: {},\n documentTypes: {},\n pendingDiffs: {},\n acceptedApplyIds: [],\n };\n};\n\nexport const defaultInitDocumentsState: DocumentsState = {\n ...initDocumentsStore(),\n};\n\nexport const createDocumentsStore = (\n initState: DocumentsState = defaultInitDocumentsState\n) => {\n return createStore<DocumentsStore>()(\n devtools(\n persist(\n (set) => ({\n ...initState,\n createDocument: (name, text) =>\n set((state) => {\n const docIndex = state.documents.findIndex(\n (doc) => doc.name === name\n );\n if (docIndex === -1) {\n // if the document does not exist\n // Determine document type based on file name and content\n let docType: DocumentType = 'application/json+report';\n if (\n name.toLowerCase().includes('theme') ||\n name.toLowerCase().includes('.theme.')\n ) {\n docType = 'application/json+theme';\n } else {\n // Try to parse JSON to check if it's a theme\n try {\n const parsed = JSON.parse(text);\n if (parsed.colors && parsed.fonts && parsed.styles) {\n docType = 'application/json+theme';\n }\n } catch {\n // If not valid JSON, default to report\n }\n }\n\n const newDoc = {\n name,\n type: 'application/json',\n text,\n mtime: new Date(),\n ctime: new Date(),\n atime: new Date(),\n };\n return {\n documents: [...state.documents, newDoc],\n documentTypes: { ...state.documentTypes, [name]: docType },\n };\n }\n return state;\n }),\n deleteDocument: (name) =>\n set((state) => {\n const newDocumentTypes = { ...state.documentTypes };\n delete newDocumentTypes[name];\n return {\n documents: state.documents.filter((doc) => doc.name !== name),\n documentTypes: newDocumentTypes,\n pendingDiffs: Object.fromEntries(\n Object.entries(state.pendingDiffs).filter(([k]) => k !== name)\n ),\n };\n }),\n saveDocument: (name, text) =>\n set((state) => {\n const docIndex = state.documents.findIndex(\n (doc) => doc.name === name\n );\n if (docIndex === -1) return state;\n // Skip update if text is unchanged to avoid spurious re-renders\n if (state.documents[docIndex].text === text) return state;\n const documents = state.documents.map((doc, i) =>\n i === docIndex ? { ...doc, text, mtime: new Date() } : doc\n );\n return { documents };\n }),\n renameDocument: (oldName, newName) =>\n set((state) => {\n const docIndex = state.documents.findIndex(\n (doc) => doc.name === oldName\n );\n if (docIndex === -1) return state;\n const documents = state.documents.map((doc, i) =>\n i === docIndex ? { ...doc, name: newName, ctime: new Date() } : doc\n );\n const docType = state.documentTypes[oldName];\n if (docType) {\n const newDocumentTypes = { ...state.documentTypes };\n delete newDocumentTypes[oldName];\n newDocumentTypes[newName] = docType;\n return { documents, documentTypes: newDocumentTypes };\n }\n return { documents };\n }),\n openDocument: (name) =>\n set((state) => {\n const docIndex = state.documents.findIndex(\n (doc) => doc.name === name\n );\n if (docIndex === -1) return state;\n const documents = state.documents.map((doc, i) =>\n i === docIndex ? { ...doc, atime: new Date() } : doc\n );\n let openTabs = state.openTabs;\n if (!openTabs.includes(name)) {\n openTabs = openTabs.length >= MAX_OPEN_TABS\n ? [...openTabs.slice(1), name]\n : [...openTabs, name];\n }\n return { documents, openTabs, activeTab: name };\n }),\n closeDocument: (name) =>\n set((state) => {\n const index = state.openTabs.indexOf(name);\n if (index === -1) return state;\n const openTabs = state.openTabs.filter((tab) => tab !== name);\n let activeTab = state.activeTab;\n if (activeTab === name) {\n if (openTabs.length) {\n activeTab = index === 0 ? openTabs[0] : openTabs[index - 1];\n } else {\n activeTab = '';\n }\n }\n return { openTabs, activeTab };\n }),\n setActiveTab: (name) => set({ activeTab: name }),\n setBuildError: (name, buildError) =>\n set((state) => {\n if (state.buildErrors[name] === buildError) return state;\n const buildErrors = { ...state.buildErrors };\n if (buildError) buildErrors[name] = buildError;\n else delete buildErrors[name];\n return { buildErrors };\n }),\n setPendingDiff: (name, original, modified, applyId) =>\n set((state) => {\n return {\n pendingDiffs: {\n ...state.pendingDiffs,\n [name]: { original, modified, applyId },\n },\n };\n }),\n clearPendingDiff: (name, accepted) =>\n set((state) => {\n const diff = state.pendingDiffs[name];\n if (!diff) return state;\n const next = { ...state.pendingDiffs };\n delete next[name];\n const ids = state.acceptedApplyIds || [];\n const acceptedApplyIds =\n accepted && diff.applyId\n ? [...ids.slice(-(200 - 1)), diff.applyId]\n : ids;\n return { pendingDiffs: next, acceptedApplyIds };\n }),\n }),\n {\n name: 'documents-storage',\n version: 1,\n storage: createJSONStorage(() => idbStorage),\n partialize: (state) => ({\n documents: state.documents,\n openTabs: state.openTabs,\n activeTab: state.activeTab,\n documentTypes: state.documentTypes,\n // buildErrors + pendingDiffs + acceptedApplyIds excluded — transient UI state\n }),\n onRehydrateStorage: () => (state) => {\n if (state?.documents) {\n for (const doc of state.documents) {\n for (const key of ['mtime', 'ctime', 'atime'] as const) {\n if (doc[key] && typeof doc[key] === 'string') {\n (doc as Record<string, unknown>)[key] = new Date(doc[key] as unknown as string);\n }\n }\n }\n }\n },\n }\n )\n )\n );\n};\n","import { type ReactNode, createContext, useRef, useContext } from 'react';\nimport { useStore } from 'zustand';\nimport {\n type DocumentsStore,\n createDocumentsStore,\n initDocumentsStore,\n} from './documents-store';\n\nexport type DocumentsStoreApi = ReturnType<typeof createDocumentsStore>;\n\nexport const DocumentsStoreContext = createContext<\n DocumentsStoreApi | undefined\n>(undefined);\n\nexport interface DocumentsStoreProviderProps {\n children: ReactNode;\n}\n\nexport const DocumentsStoreProvider = ({\n children,\n}: DocumentsStoreProviderProps) => {\n const storeRef = useRef<DocumentsStoreApi | null>(null);\n if (!storeRef.current) {\n storeRef.current = createDocumentsStore(initDocumentsStore());\n }\n\n return (\n <DocumentsStoreContext.Provider value={storeRef.current}>\n {children}\n </DocumentsStoreContext.Provider>\n );\n};\n\nexport const useDocumentsStore = <T,>(\n selector: (store: DocumentsStore) => T\n): T => {\n const documentsStoreContext = useContext(DocumentsStoreContext);\n\n if (!documentsStoreContext) {\n throw new Error(\n 'useDocumentsStore must be used within DocumentsStoreProvider'\n );\n }\n\n return useStore(documentsStoreContext, selector);\n};\n","export interface ThemeValidationError {\n message: string;\n line?: number;\n column?: number;\n path?: string;\n}\n\nexport interface ThemeValidationResult {\n valid: boolean;\n errors?: ThemeValidationError[];\n}\n\n/**\n * Validates a theme JSON string - checks structure without requiring format-specific schemas\n */\nexport function validateThemeJson(jsonString: string): ThemeValidationResult {\n try {\n const parsed = JSON.parse(jsonString);\n\n if (!parsed || typeof parsed !== 'object') {\n return {\n valid: false,\n errors: [{ message: 'Theme must be a JSON object' }],\n };\n }\n\n if (typeof parsed.name !== 'string' || !parsed.name.trim()) {\n return {\n valid: false,\n errors: [{ message: 'Theme must have a non-empty \"name\" property' }],\n };\n }\n\n return { valid: true };\n } catch (e) {\n return {\n valid: false,\n errors: [\n {\n message:\n e instanceof SyntaxError\n ? `Invalid JSON: ${e.message}`\n : 'Failed to parse theme JSON',\n },\n ],\n };\n }\n}\n\n/**\n * Gets theme name from a theme JSON object\n */\nexport function getThemeName(themeJson: unknown): string | null {\n try {\n if (\n themeJson &&\n typeof themeJson === 'object' &&\n 'name' in (themeJson as any) &&\n typeof (themeJson as any).name === 'string'\n ) {\n return (themeJson as any).name as string;\n }\n return null;\n } catch {\n return null;\n }\n}\n","// Theme change event emitter for coordinating theme updates across components\nexport interface ThemeChangeEvent {\n themeName: string;\n timestamp: number;\n changeType: 'create' | 'update' | 'delete';\n}\n\nexport class ThemeChangeEmitter extends EventTarget {\n private static instance: ThemeChangeEmitter;\n\n private constructor() {\n super();\n }\n\n static getInstance(): ThemeChangeEmitter {\n if (!ThemeChangeEmitter.instance) {\n ThemeChangeEmitter.instance = new ThemeChangeEmitter();\n }\n return ThemeChangeEmitter.instance;\n }\n\n emitThemeChange(event: ThemeChangeEvent): void {\n this.dispatchEvent(new CustomEvent('themechange', { detail: event }));\n }\n\n onThemeChange(callback: (event: ThemeChangeEvent) => void): () => void {\n const handler = (e: Event) => {\n const customEvent = e as CustomEvent<ThemeChangeEvent>;\n callback(customEvent.detail);\n };\n\n this.addEventListener('themechange', handler);\n\n // Track listener count\n (this as any)._listenerCount = ((this as any)._listenerCount || 0) + 1;\n\n // Return unsubscribe function\n return () => {\n this.removeEventListener('themechange', handler);\n (this as any)._listenerCount = Math.max(\n 0,\n ((this as any)._listenerCount || 1) - 1\n );\n };\n }\n}\n\nexport const themeChangeEmitter = ThemeChangeEmitter.getInstance();\n","import { persist, devtools, createJSONStorage } from 'zustand/middleware';\nimport { createStore } from 'zustand/vanilla';\nimport type { ThemeConfigJson } from '@json-to-office/shared-pptx';\nimport { validateThemeJson, getThemeName } from '../lib/theme-validation';\nimport { themeChangeEmitter } from '../utils/theme-change-emitter';\nimport { idbStorage } from '../lib/idb-storage';\n\nexport type CustomTheme = {\n name: string;\n content: string;\n parsed?: ThemeConfigJson;\n valid: boolean;\n lastModified: Date;\n};\n\nexport type ThemesState = {\n customThemes: { [name: string]: CustomTheme };\n};\n\nexport type ThemesActions = {\n updateTheme: (documentName: string, content: string) => void;\n removeTheme: (documentName: string) => void;\n getTheme: (themeName: string) => ThemeConfigJson | null;\n getAllThemeNames: () => string[];\n isThemeValid: (themeName: string) => boolean;\n};\n\nexport type ThemesStore = ThemesState & ThemesActions;\n\nexport const initThemesStore = (): ThemesState => {\n return {\n customThemes: {},\n };\n};\n\nexport const defaultInitThemesState: ThemesState = {\n ...initThemesStore(),\n};\n\nexport const createThemesStore = (\n initState: ThemesState = defaultInitThemesState\n) => {\n return createStore<ThemesStore>()(\n devtools(\n persist(\n (set, get) => ({\n ...initState,\n\n updateTheme: (documentName, content) =>\n set((state) => {\n const validation = validateThemeJson(content);\n\n let parsed: ThemeConfigJson | undefined;\n let themeName = documentName;\n\n if (validation.valid) {\n try {\n const parsedContent = JSON.parse(content);\n parsed = parsedContent;\n const extractedName = getThemeName(parsedContent);\n if (extractedName) {\n themeName = extractedName;\n }\n } catch {\n // Keep the document name if parsing fails\n }\n }\n\n const existingTheme = state.customThemes[documentName];\n const isUpdate = !!existingTheme;\n const hasContentChanged = existingTheme?.content !== content;\n\n const customTheme: CustomTheme = {\n name: themeName,\n content,\n parsed,\n valid: validation.valid,\n lastModified: new Date(),\n };\n\n // Emit theme change if content changed OR if this is a newly valid theme\n const shouldEmitEvent =\n (hasContentChanged ||\n (!existingTheme?.valid && validation.valid)) &&\n validation.valid;\n\n if (shouldEmitEvent) {\n // Use setTimeout to ensure state is updated before event is processed\n setTimeout(() => {\n themeChangeEmitter.emitThemeChange({\n themeName,\n timestamp: Date.now(),\n changeType: isUpdate ? 'update' : 'create',\n });\n }, 0);\n }\n\n return {\n customThemes: {\n ...state.customThemes,\n [documentName]: customTheme,\n },\n };\n }),\n\n removeTheme: (documentName) =>\n set((state) => {\n const removedTheme = state.customThemes[documentName];\n const newCustomThemes = { ...state.customThemes };\n delete newCustomThemes[documentName];\n\n // Emit theme deletion event\n if (removedTheme) {\n setTimeout(() => {\n themeChangeEmitter.emitThemeChange({\n themeName: removedTheme.name,\n timestamp: Date.now(),\n changeType: 'delete',\n });\n }, 0);\n }\n\n return {\n customThemes: newCustomThemes,\n };\n }),\n\n getTheme: (themeName) => {\n const state = get();\n\n // First check custom themes by theme name\n for (const customTheme of Object.values(state.customThemes)) {\n if (\n customTheme.valid &&\n customTheme.name === themeName &&\n customTheme.parsed\n ) {\n return customTheme.parsed;\n }\n }\n\n // Theme not found in custom themes\n return null;\n },\n\n getAllThemeNames: () => {\n const state = get();\n const names: string[] = [];\n\n // Add custom theme names\n for (const customTheme of Object.values(state.customThemes)) {\n if (customTheme.valid && customTheme.name) {\n names.push(customTheme.name);\n }\n }\n\n return names;\n },\n\n isThemeValid: (themeName) => {\n const state = get();\n\n // Check custom themes\n for (const customTheme of Object.values(state.customThemes)) {\n if (customTheme.name === themeName) {\n return customTheme.valid;\n }\n }\n\n return false;\n },\n }),\n {\n name: 'themes-storage',\n version: 4, // v4: migrate from localStorage to IndexedDB\n storage: createJSONStorage(() => idbStorage),\n // Only persist the themes data, not the functions\n partialize: (state) => ({ customThemes: state.customThemes }),\n // Handle date deserialization when loading from storage\n onRehydrateStorage: () => (state) => {\n if (state && state.customThemes) {\n // Convert lastModified strings back to Date objects\n Object.keys(state.customThemes).forEach((key) => {\n const theme = state.customThemes[key];\n if (\n theme.lastModified &&\n typeof theme.lastModified === 'string'\n ) {\n theme.lastModified = new Date(theme.lastModified);\n }\n });\n }\n },\n }\n )\n )\n );\n};\n","import { type ReactNode, createContext, useRef, useContext } from 'react';\nimport { useStore } from 'zustand';\n\nimport {\n type ThemesStore,\n createThemesStore,\n initThemesStore,\n} from './themes-store';\n\nexport type ThemesStoreApi = ReturnType<typeof createThemesStore>;\n\nexport const ThemesStoreContext = createContext<ThemesStoreApi | undefined>(\n undefined\n);\n\nexport interface ThemesStoreProviderProps {\n children: ReactNode;\n}\n\nexport const ThemesStoreProvider = ({ children }: ThemesStoreProviderProps) => {\n const storeRef = useRef<ThemesStoreApi>(undefined);\n if (!storeRef.current) {\n storeRef.current = createThemesStore(initThemesStore());\n }\n\n return (\n <ThemesStoreContext.Provider value={storeRef.current}>\n {children}\n </ThemesStoreContext.Provider>\n );\n};\n\nexport const useThemesStore = <T,>(selector: (store: ThemesStore) => T): T => {\n const themesStoreContext = useContext(ThemesStoreContext);\n\n if (!themesStoreContext) {\n throw new Error('useThemesStore must be used within ThemesStoreProvider');\n }\n\n return useStore(themesStoreContext, selector);\n};\n","import { devtools } from 'zustand/middleware';\nimport { createStore } from 'zustand/vanilla';\n\nexport interface GenerationWarning {\n component: string;\n message: string;\n severity?: 'warning' | 'info';\n context?: Record<string, unknown>;\n}\n\nexport type OutputState = {\n name?: string; // last success => document name\n text?: string; // last success => code used to generate the pptx\n blob?: Blob; // last success => generated pptx\n globalError?: string; // last failed => global error message\n isGenerating?: boolean; // presentation generation in progress\n generationProgress?: {\n stage: 'parsing' | 'building' | 'rendering' | 'finalizing';\n message?: string;\n };\n cacheStatus?: 'HIT' | 'MISS' | 'UNKNOWN'; // cache hit/miss status\n cacheHitRate?: string; // cache hit rate percentage\n warnings?: GenerationWarning[] | null; // warnings from custom component processing\n isRendering?: boolean; // preview rendering in progress (iframe/LibreOffice)\n isPreviewStale?: boolean; // preview outdated (new blob generated but not yet rendered)\n editSequence?: number; // incremented on every Monaco keystroke (init 0)\n lastBuiltSequence?: number; // stamped when generation completes (init 0)\n editTimestamp?: number; // Date.now() of the last edit (for debounce countdown)\n // ⚠️ name doesn't necessarily correspond to the global error message\n};\n\nexport type OutputActions = {\n setOutput: (partialState: OutputState) => void;\n bumpEditSequence: () => void;\n};\n\nexport type OutputStore = OutputState & OutputActions;\n\nexport const initOutputStore = (): OutputState => {\n return {\n name: undefined,\n text: undefined,\n blob: undefined,\n globalError: undefined,\n isGenerating: false,\n generationProgress: undefined,\n isRendering: false,\n isPreviewStale: false,\n editSequence: 0,\n lastBuiltSequence: 0,\n };\n};\n\nexport const defaultInitOutputState: OutputState = {\n ...initOutputStore(),\n};\n\nexport const createOutputStore = (\n initState: OutputState = defaultInitOutputState\n) => {\n return createStore<OutputStore>()(\n devtools((set) => ({\n ...initState,\n setOutput: (partialState) => set({ ...partialState }),\n bumpEditSequence: () =>\n set((s) => ({\n editSequence: (s.editSequence ?? 0) + 1,\n editTimestamp: Date.now(),\n })),\n }))\n );\n};\n","import { type ReactNode, createContext, useRef, useContext } from 'react';\nimport { useStore } from 'zustand';\nimport {\n type OutputStore,\n createOutputStore,\n initOutputStore,\n} from './output-store';\n\nexport type OutputStoreApi = ReturnType<typeof createOutputStore>;\n\nexport const OutputStoreContext = createContext<OutputStoreApi | undefined>(\n undefined\n);\n\nexport interface OutputStoreProviderProps {\n children: ReactNode;\n}\n\nexport const OutputStoreProvider = ({ children }: OutputStoreProviderProps) => {\n const storeRef = useRef<OutputStoreApi | null>(null);\n if (!storeRef.current) {\n storeRef.current = createOutputStore(initOutputStore());\n }\n\n return (\n <OutputStoreContext.Provider value={storeRef.current}>\n {children}\n </OutputStoreContext.Provider>\n );\n};\n\nexport const useOutputStore = <T,>(selector: (store: OutputStore) => T): T => {\n const outputStoreContext = useContext(OutputStoreContext);\n\n if (!outputStoreContext) {\n throw new Error('useOutputStore must be used within OutputStoreProvider');\n }\n\n return useStore(outputStoreContext, selector);\n};\n","import { create } from 'zustand';\nimport { persist } from 'zustand/middleware';\nimport type { PluginMetadata } from '../hooks/useDiscovery';\n\ninterface PluginsState {\n // Selected plugin names (used for schema generation)\n selectedPlugins: Set<string>;\n\n // Full plugin metadata for selected plugins\n selectedPluginMetadata: Map<string, PluginMetadata>;\n\n // Schema application state\n isApplyingPlugins: boolean;\n lastApplyError: string | null;\n\n // Actions\n selectPlugin: (plugin: PluginMetadata) => void;\n deselectPlugin: (pluginName: string) => void;\n togglePlugin: (plugin: PluginMetadata) => void;\n clearSelections: () => void;\n isPluginSelected: (pluginName: string) => boolean;\n getSelectedPluginsList: () => PluginMetadata[];\n getSelectedPluginNames: () => string[];\n applyPluginsWithValidation: (\n onSuccess?: () => void,\n onError?: (error: string) => void\n ) => Promise<boolean>;\n}\n\nexport const usePluginsStore = create<PluginsState>()(\n persist(\n (set, get) => ({\n selectedPlugins: new Set<string>(),\n selectedPluginMetadata: new Map<string, PluginMetadata>(),\n isApplyingPlugins: false,\n lastApplyError: null,\n\n selectPlugin: (plugin: PluginMetadata) => {\n set((state) => {\n const newSelectedPlugins = new Set(state.selectedPlugins);\n const newMetadata = new Map(state.selectedPluginMetadata);\n\n newSelectedPlugins.add(plugin.name);\n newMetadata.set(plugin.name, plugin);\n\n return {\n selectedPlugins: newSelectedPlugins,\n selectedPluginMetadata: newMetadata,\n };\n });\n },\n\n deselectPlugin: (pluginName: string) => {\n set((state) => {\n const newSelectedPlugins = new Set(state.selectedPlugins);\n const newMetadata = new Map(state.selectedPluginMetadata);\n\n newSelectedPlugins.delete(pluginName);\n newMetadata.delete(pluginName);\n\n return {\n selectedPlugins: newSelectedPlugins,\n selectedPluginMetadata: newMetadata,\n };\n });\n },\n\n togglePlugin: (plugin: PluginMetadata) => {\n const isSelected = get().isPluginSelected(plugin.name);\n if (isSelected) {\n get().deselectPlugin(plugin.name);\n } else {\n get().selectPlugin(plugin);\n }\n // Auto-apply schema changes\n get().applyPluginsWithValidation().catch(console.error);\n },\n\n clearSelections: () => {\n set({\n selectedPlugins: new Set<string>(),\n selectedPluginMetadata: new Map<string, PluginMetadata>(),\n });\n // Auto-apply schema changes\n get().applyPluginsWithValidation().catch(console.error);\n },\n\n isPluginSelected: (pluginName: string) => {\n return get().selectedPlugins.has(pluginName);\n },\n\n getSelectedPluginsList: () => {\n return Array.from(get().selectedPluginMetadata.values());\n },\n\n getSelectedPluginNames: () => {\n return Array.from(get().selectedPlugins);\n },\n\n applyPluginsWithValidation: async (onSuccess, onError) => {\n set({ isApplyingPlugins: true, lastApplyError: null });\n\n try {\n // Get the current selected plugins\n const selectedPluginNames = Array.from(get().selectedPlugins);\n\n // Import Monaco and schema update function dynamically\n const { loader } = await import('@monaco-editor/react');\n const { updateMonacoWithPlugins } = await import(\n '../lib/monaco-config'\n );\n\n // Get Monaco instance\n const monaco = await loader.init();\n\n // Apply the plugins and wait for validation\n const success = await updateMonacoWithPlugins(\n monaco,\n selectedPluginNames\n );\n\n if (!success) {\n throw new Error('Schema validation failed');\n }\n\n // Success - schema has been applied and validated\n set({ isApplyingPlugins: false, lastApplyError: null });\n\n if (onSuccess) {\n onSuccess();\n }\n\n return true;\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to apply plugin schemas';\n\n set({\n isApplyingPlugins: false,\n lastApplyError: errorMessage,\n });\n\n if (onError) {\n onError(errorMessage);\n }\n\n console.error('Failed to apply plugins with validation:', error);\n return false;\n }\n },\n }),\n {\n name: 'jtp-selected-plugins',\n // Custom storage to handle Set and Map serialization\n storage: {\n getItem: (name) => {\n const str = localStorage.getItem(name);\n if (!str) return null;\n\n const { state } = JSON.parse(str);\n return {\n state: {\n ...state,\n selectedPlugins: new Set(state.selectedPlugins || []),\n selectedPluginMetadata: new Map(\n state.selectedPluginMetadata || []\n ),\n },\n };\n },\n setItem: (name, value) => {\n const { state } = value as { state: PluginsState };\n const serialized = JSON.stringify({\n state: {\n ...state,\n selectedPlugins: Array.from(state.selectedPlugins),\n selectedPluginMetadata: Array.from(\n state.selectedPluginMetadata.entries()\n ),\n },\n });\n localStorage.setItem(name, serialized);\n },\n removeItem: (name) => localStorage.removeItem(name),\n },\n }\n )\n);\n","import { devtools, persist } from 'zustand/middleware';\nimport { createStore } from 'zustand/vanilla';\nimport type { Settings } from '../lib/types';\nimport { FORMAT } from '../lib/env';\n\nexport type SettingsState = Settings;\n\nexport type SettingsActions = {\n setSettings: (settings: Partial<Settings>) => void;\n};\n\nexport type SettingsStore = SettingsState & SettingsActions;\n\nexport const initSettingsStore = (): SettingsState => {\n return {\n saveDocumentDebounceWait: 300,\n autoReload: true,\n renderingLibrary: FORMAT === 'docx' ? 'docxjs' : 'LibreOffice',\n // UI preference to use a single preview header spanning editor + preview\n useGlobalPreviewHeader: true,\n };\n};\n\nexport const defaultInitSettingsState: SettingsState = {\n ...initSettingsStore(),\n};\n\nexport const createSettingsStore = (\n initState: SettingsState = defaultInitSettingsState\n) => {\n return createStore<SettingsStore>()(\n devtools(\n persist(\n (set) => ({\n ...initState,\n setSettings: (settings) => set({ ...settings }),\n }),\n {\n name: 'settings-storage', // name of the item in the storage (must be unique)\n // (optional) by default, 'localStorage' is used as storage\n }\n )\n )\n );\n};\n","import { type ReactNode, createContext, useRef, useContext } from 'react';\nimport { useStore } from 'zustand';\nimport {\n type SettingsStore,\n createSettingsStore,\n initSettingsStore,\n} from './settings-store';\n\nexport type SettingsStoreApi = ReturnType<typeof createSettingsStore>;\n\nexport const SettingsStoreContext = createContext<SettingsStoreApi | undefined>(\n undefined\n);\n\nexport interface SettingsStoreProviderProps {\n children: ReactNode;\n}\n\nexport const SettingsStoreProvider = ({\n children,\n}: SettingsStoreProviderProps) => {\n const storeRef = useRef<SettingsStoreApi | null>(null);\n if (!storeRef.current) {\n storeRef.current = createSettingsStore(initSettingsStore());\n }\n\n return (\n <SettingsStoreContext.Provider value={storeRef.current}>\n {children}\n </SettingsStoreContext.Provider>\n );\n};\n\nexport const useSettingsStore = <T,>(\n selector: (store: SettingsStore) => T\n): T => {\n const settingsStoreContext = useContext(SettingsStoreContext);\n\n if (!settingsStoreContext) {\n throw new Error(\n 'useSettingsStore must be used within SettingsStoreProvider'\n );\n }\n\n return useStore(settingsStoreContext, selector);\n};\n","import { useEffect, useRef, useContext, useSyncExternalStore } from 'react';\nimport { loader } from '@monaco-editor/react';\nimport type { Monaco } from '@monaco-editor/react';\nimport { usePluginsStore } from '../store/plugins-store';\nimport { ThemesStoreContext } from '../store/themes-store-provider';\nimport { updateMonacoWithPlugins } from '../lib/monaco-config';\n\nconst emptyNames: string[] = [];\nconst subscribe = () => () => {};\n\n/**\n * Read custom theme names from the ThemesStore if available,\n * returning [] when outside a ThemesStoreProvider.\n *\n * getSnapshot must return a referentially stable value to avoid\n * infinite re-renders with useSyncExternalStore.\n */\nfunction useCustomThemeNames(): string[] {\n const store = useContext(ThemesStoreContext);\n const cachedRef = useRef<string[]>(emptyNames);\n\n const getSnapshot = store\n ? () => {\n const next = store.getState().getAllThemeNames();\n // Only update the cached reference when the list actually changes\n if (\n next.length !== cachedRef.current.length ||\n next.some((n, i) => n !== cachedRef.current[i])\n ) {\n cachedRef.current = next;\n }\n return cachedRef.current;\n }\n : () => emptyNames;\n\n return useSyncExternalStore(store ? store.subscribe : subscribe, getSnapshot);\n}\n\n/**\n * Hook to synchronize selected plugins and custom themes with Monaco editor schemas.\n * Ensures real-time validation and autocomplete include plugin-specific schemas\n * and custom theme names.\n */\nexport function useMonacoPlugins() {\n const monacoRef = useRef<Monaco | null>(null);\n const selectedPlugins = usePluginsStore((state) => state.selectedPlugins);\n const selectedPluginNames = Array.from(selectedPlugins);\n const customThemeNames = useCustomThemeNames();\n const themesStore = useContext(ThemesStoreContext);\n const themesStoreRef = useRef(themesStore);\n themesStoreRef.current = themesStore;\n const previousPluginsRef = useRef<string[]>([]);\n const previousThemesRef = useRef<string[]>([]);\n\n useEffect(() => {\n loader\n .init()\n .then((monaco) => {\n monacoRef.current = monaco;\n // Read current state from stores (not stale closure) since\n // zustand persist may have hydrated while loader.init() was pending\n const currentPlugins = Array.from(\n usePluginsStore.getState().selectedPlugins\n );\n const currentThemes =\n themesStoreRef.current?.getState().getAllThemeNames() ?? [];\n updateMonacoWithPlugins(monaco, currentPlugins, currentThemes)\n .then((success) => {\n if (success) {\n console.log(\n '[useMonacoPlugins] Monaco initialized with plugins:',\n currentPlugins\n );\n } else {\n console.warn(\n '[useMonacoPlugins] Monaco initialization completed with warnings'\n );\n }\n })\n .catch((error) => {\n console.error(\n '[useMonacoPlugins] Failed to update Monaco with plugins:',\n error\n );\n });\n previousPluginsRef.current = [...currentPlugins];\n previousThemesRef.current = [...currentThemes];\n })\n .catch((error) => {\n console.error('Failed to initialize Monaco:', error);\n });\n }, []); // Keep empty dependency to run only once\n\n useEffect(() => {\n const pluginsChanged =\n selectedPluginNames.length !== previousPluginsRef.current.length ||\n selectedPluginNames.some(\n (name, index) => name !== previousPluginsRef.current[index]\n );\n\n const themesChanged =\n customThemeNames.length !== previousThemesRef.current.length ||\n customThemeNames.some(\n (name, index) => name !== previousThemesRef.current[index]\n );\n\n if (!pluginsChanged && !themesChanged) {\n return;\n }\n\n if (monacoRef.current) {\n updateMonacoWithPlugins(\n monacoRef.current,\n selectedPluginNames,\n customThemeNames\n ).catch((error) => {\n console.error(\n '[useMonacoPlugins] Failed to update Monaco schemas:',\n error\n );\n });\n previousPluginsRef.current = [...selectedPluginNames];\n previousThemesRef.current = [...customThemeNames];\n }\n }, [selectedPluginNames, customThemeNames]);\n\n return {\n monaco: monacoRef.current,\n selectedPlugins: selectedPluginNames,\n };\n}\n","import { useMonacoPlugins } from '../hooks/useMonacoPlugins';\n\n/**\n * Provider component that manages Monaco plugin synchronization\n * This must be rendered within the app after stores are initialized\n */\nexport function MonacoPluginProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n // Initialize Mon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,IACN,sDACAH,CAAA,EAGF,QAAQ,KACN,mEAGN,CAAC,EACA,MAAO5B,GAAU,CAChB,QAAQ,MACN,2DACAA,CAAA,CAEJ,CAAC,EACHyB,EAAmB,QAAU,CAAC,GAAGG,CAAc,EAC/CF,EAAkB,QAAU,CAAC,GAAGG,CAAa,CAC/C,CAAC,EACA,MAAO7B,GAAU,CAChB,QAAQ,MAAM,+BAAgCA,CAAK,CACrD,CAAC,CACL,EAAG,EAAE,EAEL2B,YAAU,IAAM,CACd,MAAMK,EACJtC,EAAoB,SAAW+B,EAAmB,QAAQ,QAC1D/B,EAAoB,KAClB,CAAChG,EAAMsB,IAAUtB,IAAS+H,EAAmB,QAAQzG,CAAK,GAGxDiH,EACJX,EAAiB,SAAWI,EAAkB,QAAQ,QACtDJ,EAAiB,KACf,CAAC5H,EAAMsB,IAAUtB,IAASgI,EAAkB,QAAQ1G,CAAK,GAGzD,CAACgH,GAAkB,CAACC,GAIpBb,EAAU,UACZvB,EACEuB,EAAU,QACV1B,EACA4B,CAAA,EACA,MAAOtB,GAAU,CACjB,QAAQ,MACN,sDACAA,CAAA,CAEJ,CAAC,EACDyB,EAAmB,QAAU,CAAC,GAAG/B,CAAmB,EACpDgC,EAAkB,QAAU,CAAC,GAAGJ,CAAgB,EAEpD,EAAG,CAAC5B,EAAqB4B,CAAgB,CAAC,EAEnC,CACL,OAAQF,EAAU,QAClB,gBAAiB1B,CAAA,CAErB,CC5HO,SAASwC,GAAqB,CACnC,SAAAjG,CACF,EAEG,CAED,OAAAkF,GAAA,oBAEU,SAAAlF,EAAS,CACrB","names":["promisifyRequest","request","resolve","reject","createStore","dbName","storeName","dbp","getDB","db","txMode","callback","defaultGetStoreFunc","defaultGetStore","get","key","customStore","store","set","value","del","idbStorage","name","MAX_OPEN_TABS","initDocumentsStore","defaultInitDocumentsState","createDocumentsStore","initState","devtools","persist","text","state","doc","docType","parsed","newDoc","newDocumentTypes","k","docIndex","oldName","newName","documents","i","openTabs","index","tab","activeTab","buildError","buildErrors","original","modified","applyId","accepted","diff","next","ids","acceptedApplyIds","createJSONStorage","DocumentsStoreContext","createContext","DocumentsStoreProvider","children","storeRef","useRef","useDocumentsStore","selector","documentsStoreContext","useContext","useStore","validateThemeJson","jsonString","getThemeName","themeJson","_ThemeChangeEmitter","event","handler","e","__publicField","ThemeChangeEmitter","themeChangeEmitter","initThemesStore","defaultInitThemesState","createThemesStore","documentName","content","validation","themeName","parsedContent","extractedName","existingTheme","isUpdate","hasContentChanged","customTheme","removedTheme","newCustomThemes","names","theme","ThemesStoreContext","ThemesStoreProvider","useThemesStore","themesStoreContext","initOutputStore","defaultInitOutputState","createOutputStore","partialState","s","OutputStoreContext","OutputStoreProvider","useOutputStore","outputStoreContext","usePluginsStore","create","plugin","newSelectedPlugins","newMetadata","pluginName","onSuccess","onError","selectedPluginNames","loader","__vitePreload","updateMonacoWithPlugins","n","monaco","error","errorMessage","str","serialized","initSettingsStore","FORMAT","defaultInitSettingsState","createSettingsStore","settings","SettingsStoreContext","SettingsStoreProvider","useSettingsStore","settingsStoreContext","emptyNames","subscribe","useCustomThemeNames","cachedRef","getSnapshot","useSyncExternalStore","useMonacoPlugins","monacoRef","selectedPlugins","customThemeNames","themesStore","themesStoreRef","previousPluginsRef","previousThemesRef","useEffect","currentPlugins","currentThemes","_a","success","pluginsChanged","themesChanged","MonacoPluginProvider"],"ignoreList":[0],"sources":["../../../../../node_modules/.pnpm/idb-keyval@6.2.2/node_modules/idb-keyval/dist/index.js","../../../src/client/lib/idb-storage.ts","../../../src/client/store/documents-store.ts","../../../src/client/store/documents-store-provider.tsx","../../../src/client/lib/theme-validation.ts","../../../src/client/utils/theme-change-emitter.ts","../../../src/client/store/themes-store.ts","../../../src/client/store/themes-store-provider.tsx","../../../src/client/store/output-store.ts","../../../src/client/store/output-store-provider.tsx","../../../src/client/store/plugins-store.ts","../../../src/client/store/settings-store.ts","../../../src/client/store/settings-store-provider.tsx","../../../src/client/hooks/useMonacoPlugins.ts","../../../src/client/components/MonacoPluginProvider.tsx"],"sourcesContent":["function promisifyRequest(request) {\n return new Promise((resolve, reject) => {\n // @ts-ignore - file size hacks\n request.oncomplete = request.onsuccess = () => resolve(request.result);\n // @ts-ignore - file size hacks\n request.onabort = request.onerror = () => reject(request.error);\n });\n}\nfunction createStore(dbName, storeName) {\n let dbp;\n const getDB = () => {\n if (dbp)\n return dbp;\n const request = indexedDB.open(dbName);\n request.onupgradeneeded = () => request.result.createObjectStore(storeName);\n dbp = promisifyRequest(request);\n dbp.then((db) => {\n // It seems like Safari sometimes likes to just close the connection.\n // It's supposed to fire this event when that happens. Let's hope it does!\n db.onclose = () => (dbp = undefined);\n }, () => { });\n return dbp;\n };\n return (txMode, callback) => getDB().then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName)));\n}\nlet defaultGetStoreFunc;\nfunction defaultGetStore() {\n if (!defaultGetStoreFunc) {\n defaultGetStoreFunc = createStore('keyval-store', 'keyval');\n }\n return defaultGetStoreFunc;\n}\n/**\n * Get a value by its key.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction get(key, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => promisifyRequest(store.get(key)));\n}\n/**\n * Set a value with a key.\n *\n * @param key\n * @param value\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction set(key, value, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.put(value, key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Set multiple values at once. This is faster than calling set() multiple times.\n * It's also atomic – if one of the pairs can't be added, none will be added.\n *\n * @param entries Array of entries, where each entry is an array of `[key, value]`.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction setMany(entries, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n entries.forEach((entry) => store.put(entry[1], entry[0]));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Get multiple values by their keys\n *\n * @param keys\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction getMany(keys, customStore = defaultGetStore()) {\n return customStore('readonly', (store) => Promise.all(keys.map((key) => promisifyRequest(store.get(key)))));\n}\n/**\n * Update a value. This lets you see the old value and update it as an atomic operation.\n *\n * @param key\n * @param updater A callback that takes the old value and returns a new value.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction update(key, updater, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => \n // Need to create the promise manually.\n // If I try to chain promises, the transaction closes in browsers\n // that use a promise polyfill (IE10/11).\n new Promise((resolve, reject) => {\n store.get(key).onsuccess = function () {\n try {\n store.put(updater(this.result), key);\n resolve(promisifyRequest(store.transaction));\n }\n catch (err) {\n reject(err);\n }\n };\n }));\n}\n/**\n * Delete a particular key from the store.\n *\n * @param key\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction del(key, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.delete(key);\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Delete multiple keys at once.\n *\n * @param keys List of keys to delete.\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction delMany(keys, customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n keys.forEach((key) => store.delete(key));\n return promisifyRequest(store.transaction);\n });\n}\n/**\n * Clear all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction clear(customStore = defaultGetStore()) {\n return customStore('readwrite', (store) => {\n store.clear();\n return promisifyRequest(store.transaction);\n });\n}\nfunction eachCursor(store, callback) {\n store.openCursor().onsuccess = function () {\n if (!this.result)\n return;\n callback(this.result);\n this.result.continue();\n };\n return promisifyRequest(store.transaction);\n}\n/**\n * Get all keys in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction keys(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAllKeys) {\n return promisifyRequest(store.getAllKeys());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items);\n });\n}\n/**\n * Get all values in the store.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction values(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n if (store.getAll) {\n return promisifyRequest(store.getAll());\n }\n const items = [];\n return eachCursor(store, (cursor) => items.push(cursor.value)).then(() => items);\n });\n}\n/**\n * Get all entries in the store. Each entry is an array of `[key, value]`.\n *\n * @param customStore Method to get a custom store. Use with caution (see the docs).\n */\nfunction entries(customStore = defaultGetStore()) {\n return customStore('readonly', (store) => {\n // Fast path for modern browsers\n // (although, hopefully we'll get a simpler path some day)\n if (store.getAll && store.getAllKeys) {\n return Promise.all([\n promisifyRequest(store.getAllKeys()),\n promisifyRequest(store.getAll()),\n ]).then(([keys, values]) => keys.map((key, i) => [key, values[i]]));\n }\n const items = [];\n return customStore('readonly', (store) => eachCursor(store, (cursor) => items.push([cursor.key, cursor.value])).then(() => items));\n });\n}\n\nexport { clear, createStore, del, delMany, entries, get, getMany, keys, promisifyRequest, set, setMany, update, values };\n","/**\n * IndexedDB storage adapter for Zustand persist middleware using idb-keyval.\n */\nimport { get, set, del } from 'idb-keyval';\nimport type { StateStorage } from 'zustand/middleware';\n\nexport const idbStorage: StateStorage = {\n getItem: async (name: string): Promise<string | null> => {\n return (await get(name)) ?? null;\n },\n setItem: async (name: string, value: string): Promise<void> => {\n await set(name, value);\n },\n removeItem: async (name: string): Promise<void> => {\n await del(name);\n },\n};\n","import { persist, devtools, createJSONStorage } from 'zustand/middleware';\nimport { createStore } from 'zustand/vanilla';\nimport type { TextFile } from '../lib/types';\nimport { idbStorage } from '../lib/idb-storage';\n\nconst MAX_OPEN_TABS = 3;\n\nexport type DocumentType = 'application/json+report' | 'application/json+theme';\n\nexport type DocumentsState = {\n documents: TextFile[];\n openTabs: string[];\n activeTab: string;\n buildErrors: { [key: string]: string };\n documentTypes: { [key: string]: DocumentType };\n pendingDiffs: { [key: string]: { original: string; modified: string; applyId?: string } };\n acceptedApplyIds: string[];\n};\n\nexport type DocumentsActions = {\n createDocument: (name: string, text: string) => void;\n deleteDocument: (name: string) => void;\n saveDocument: (name: string, text: string) => void;\n renameDocument: (oldName: string, newName: string) => void;\n openDocument: (name: string) => void;\n closeDocument: (name: string) => void;\n setActiveTab: (name: string) => void;\n setBuildError: (name: string, buildError?: string) => void;\n setPendingDiff: (name: string, original: string, modified: string, applyId?: string) => void;\n clearPendingDiff: (name: string, accepted?: boolean) => void;\n};\n\nexport type DocumentsStore = DocumentsState & DocumentsActions;\n\nexport const initDocumentsStore = (): DocumentsState => {\n return {\n documents: [],\n openTabs: [],\n activeTab: '',\n buildErrors: {},\n documentTypes: {},\n pendingDiffs: {},\n acceptedApplyIds: [],\n };\n};\n\nexport const defaultInitDocumentsState: DocumentsState = {\n ...initDocumentsStore(),\n};\n\nexport const createDocumentsStore = (\n initState: DocumentsState = defaultInitDocumentsState\n) => {\n return createStore<DocumentsStore>()(\n devtools(\n persist(\n (set) => ({\n ...initState,\n createDocument: (name, text) =>\n set((state) => {\n const docIndex = state.documents.findIndex(\n (doc) => doc.name === name\n );\n if (docIndex === -1) {\n // if the document does not exist\n // Determine document type based on file name and content\n let docType: DocumentType = 'application/json+report';\n if (\n name.toLowerCase().includes('theme') ||\n name.toLowerCase().includes('.theme.')\n ) {\n docType = 'application/json+theme';\n } else {\n // Try to parse JSON to check if it's a theme\n try {\n const parsed = JSON.parse(text);\n if (parsed.colors && parsed.fonts && parsed.styles) {\n docType = 'application/json+theme';\n }\n } catch {\n // If not valid JSON, default to report\n }\n }\n\n const newDoc = {\n name,\n type: 'application/json',\n text,\n mtime: new Date(),\n ctime: new Date(),\n atime: new Date(),\n };\n return {\n documents: [...state.documents, newDoc],\n documentTypes: { ...state.documentTypes, [name]: docType },\n };\n }\n return state;\n }),\n deleteDocument: (name) =>\n set((state) => {\n const newDocumentTypes = { ...state.documentTypes };\n delete newDocumentTypes[name];\n return {\n documents: state.documents.filter((doc) => doc.name !== name),\n documentTypes: newDocumentTypes,\n pendingDiffs: Object.fromEntries(\n Object.entries(state.pendingDiffs).filter(([k]) => k !== name)\n ),\n };\n }),\n saveDocument: (name, text) =>\n set((state) => {\n const docIndex = state.documents.findIndex(\n (doc) => doc.name === name\n );\n if (docIndex === -1) return state;\n // Skip update if text is unchanged to avoid spurious re-renders\n if (state.documents[docIndex].text === text) return state;\n const documents = state.documents.map((doc, i) =>\n i === docIndex ? { ...doc, text, mtime: new Date() } : doc\n );\n return { documents };\n }),\n renameDocument: (oldName, newName) =>\n set((state) => {\n const docIndex = state.documents.findIndex(\n (doc) => doc.name === oldName\n );\n if (docIndex === -1) return state;\n const documents = state.documents.map((doc, i) =>\n i === docIndex ? { ...doc, name: newName, ctime: new Date() } : doc\n );\n const docType = state.documentTypes[oldName];\n if (docType) {\n const newDocumentTypes = { ...state.documentTypes };\n delete newDocumentTypes[oldName];\n newDocumentTypes[newName] = docType;\n return { documents, documentTypes: newDocumentTypes };\n }\n return { documents };\n }),\n openDocument: (name) =>\n set((state) => {\n const docIndex = state.documents.findIndex(\n (doc) => doc.name === name\n );\n if (docIndex === -1) return state;\n const documents = state.documents.map((doc, i) =>\n i === docIndex ? { ...doc, atime: new Date() } : doc\n );\n let openTabs = state.openTabs;\n if (!openTabs.includes(name)) {\n openTabs = openTabs.length >= MAX_OPEN_TABS\n ? [...openTabs.slice(1), name]\n : [...openTabs, name];\n }\n return { documents, openTabs, activeTab: name };\n }),\n closeDocument: (name) =>\n set((state) => {\n const index = state.openTabs.indexOf(name);\n if (index === -1) return state;\n const openTabs = state.openTabs.filter((tab) => tab !== name);\n let activeTab = state.activeTab;\n if (activeTab === name) {\n if (openTabs.length) {\n activeTab = index === 0 ? openTabs[0] : openTabs[index - 1];\n } else {\n activeTab = '';\n }\n }\n return { openTabs, activeTab };\n }),\n setActiveTab: (name) => set({ activeTab: name }),\n setBuildError: (name, buildError) =>\n set((state) => {\n if (state.buildErrors[name] === buildError) return state;\n const buildErrors = { ...state.buildErrors };\n if (buildError) buildErrors[name] = buildError;\n else delete buildErrors[name];\n return { buildErrors };\n }),\n setPendingDiff: (name, original, modified, applyId) =>\n set((state) => {\n return {\n pendingDiffs: {\n ...state.pendingDiffs,\n [name]: { original, modified, applyId },\n },\n };\n }),\n clearPendingDiff: (name, accepted) =>\n set((state) => {\n const diff = state.pendingDiffs[name];\n if (!diff) return state;\n const next = { ...state.pendingDiffs };\n delete next[name];\n const ids = state.acceptedApplyIds || [];\n const acceptedApplyIds =\n accepted && diff.applyId\n ? [...ids.slice(-(200 - 1)), diff.applyId]\n : ids;\n return { pendingDiffs: next, acceptedApplyIds };\n }),\n }),\n {\n name: 'documents-storage',\n version: 1,\n storage: createJSONStorage(() => idbStorage),\n partialize: (state) => ({\n documents: state.documents,\n openTabs: state.openTabs,\n activeTab: state.activeTab,\n documentTypes: state.documentTypes,\n // buildErrors + pendingDiffs + acceptedApplyIds excluded — transient UI state\n }),\n onRehydrateStorage: () => (state) => {\n if (state?.documents) {\n for (const doc of state.documents) {\n for (const key of ['mtime', 'ctime', 'atime'] as const) {\n if (doc[key] && typeof doc[key] === 'string') {\n (doc as Record<string, unknown>)[key] = new Date(doc[key] as unknown as string);\n }\n }\n }\n }\n },\n }\n )\n )\n );\n};\n","import { type ReactNode, createContext, useRef, useContext } from 'react';\nimport { useStore } from 'zustand';\nimport {\n type DocumentsStore,\n createDocumentsStore,\n initDocumentsStore,\n} from './documents-store';\n\nexport type DocumentsStoreApi = ReturnType<typeof createDocumentsStore>;\n\nexport const DocumentsStoreContext = createContext<\n DocumentsStoreApi | undefined\n>(undefined);\n\nexport interface DocumentsStoreProviderProps {\n children: ReactNode;\n}\n\nexport const DocumentsStoreProvider = ({\n children,\n}: DocumentsStoreProviderProps) => {\n const storeRef = useRef<DocumentsStoreApi | null>(null);\n if (!storeRef.current) {\n storeRef.current = createDocumentsStore(initDocumentsStore());\n }\n\n return (\n <DocumentsStoreContext.Provider value={storeRef.current}>\n {children}\n </DocumentsStoreContext.Provider>\n );\n};\n\nexport const useDocumentsStore = <T,>(\n selector: (store: DocumentsStore) => T\n): T => {\n const documentsStoreContext = useContext(DocumentsStoreContext);\n\n if (!documentsStoreContext) {\n throw new Error(\n 'useDocumentsStore must be used within DocumentsStoreProvider'\n );\n }\n\n return useStore(documentsStoreContext, selector);\n};\n","export interface ThemeValidationError {\n message: string;\n line?: number;\n column?: number;\n path?: string;\n}\n\nexport interface ThemeValidationResult {\n valid: boolean;\n errors?: ThemeValidationError[];\n}\n\n/**\n * Validates a theme JSON string - checks structure without requiring format-specific schemas\n */\nexport function validateThemeJson(jsonString: string): ThemeValidationResult {\n try {\n const parsed = JSON.parse(jsonString);\n\n if (!parsed || typeof parsed !== 'object') {\n return {\n valid: false,\n errors: [{ message: 'Theme must be a JSON object' }],\n };\n }\n\n if (typeof parsed.name !== 'string' || !parsed.name.trim()) {\n return {\n valid: false,\n errors: [{ message: 'Theme must have a non-empty \"name\" property' }],\n };\n }\n\n return { valid: true };\n } catch (e) {\n return {\n valid: false,\n errors: [\n {\n message:\n e instanceof SyntaxError\n ? `Invalid JSON: ${e.message}`\n : 'Failed to parse theme JSON',\n },\n ],\n };\n }\n}\n\n/**\n * Gets theme name from a theme JSON object\n */\nexport function getThemeName(themeJson: unknown): string | null {\n try {\n if (\n themeJson &&\n typeof themeJson === 'object' &&\n 'name' in (themeJson as any) &&\n typeof (themeJson as any).name === 'string'\n ) {\n return (themeJson as any).name as string;\n }\n return null;\n } catch {\n return null;\n }\n}\n","// Theme change event emitter for coordinating theme updates across components\nexport interface ThemeChangeEvent {\n themeName: string;\n timestamp: number;\n changeType: 'create' | 'update' | 'delete';\n}\n\nexport class ThemeChangeEmitter extends EventTarget {\n private static instance: ThemeChangeEmitter;\n\n private constructor() {\n super();\n }\n\n static getInstance(): ThemeChangeEmitter {\n if (!ThemeChangeEmitter.instance) {\n ThemeChangeEmitter.instance = new ThemeChangeEmitter();\n }\n return ThemeChangeEmitter.instance;\n }\n\n emitThemeChange(event: ThemeChangeEvent): void {\n this.dispatchEvent(new CustomEvent('themechange', { detail: event }));\n }\n\n onThemeChange(callback: (event: ThemeChangeEvent) => void): () => void {\n const handler = (e: Event) => {\n const customEvent = e as CustomEvent<ThemeChangeEvent>;\n callback(customEvent.detail);\n };\n\n this.addEventListener('themechange', handler);\n\n // Track listener count\n (this as any)._listenerCount = ((this as any)._listenerCount || 0) + 1;\n\n // Return unsubscribe function\n return () => {\n this.removeEventListener('themechange', handler);\n (this as any)._listenerCount = Math.max(\n 0,\n ((this as any)._listenerCount || 1) - 1\n );\n };\n }\n}\n\nexport const themeChangeEmitter = ThemeChangeEmitter.getInstance();\n","import { persist, devtools, createJSONStorage } from 'zustand/middleware';\nimport { createStore } from 'zustand/vanilla';\nimport type { ThemeConfigJson } from '@json-to-office/shared-pptx';\nimport { validateThemeJson, getThemeName } from '../lib/theme-validation';\nimport { themeChangeEmitter } from '../utils/theme-change-emitter';\nimport { idbStorage } from '../lib/idb-storage';\n\nexport type CustomTheme = {\n name: string;\n content: string;\n parsed?: ThemeConfigJson;\n valid: boolean;\n lastModified: Date;\n};\n\nexport type ThemesState = {\n customThemes: { [name: string]: CustomTheme };\n};\n\nexport type ThemesActions = {\n updateTheme: (documentName: string, content: string) => void;\n removeTheme: (documentName: string) => void;\n getTheme: (themeName: string) => ThemeConfigJson | null;\n getAllThemeNames: () => string[];\n isThemeValid: (themeName: string) => boolean;\n};\n\nexport type ThemesStore = ThemesState & ThemesActions;\n\nexport const initThemesStore = (): ThemesState => {\n return {\n customThemes: {},\n };\n};\n\nexport const defaultInitThemesState: ThemesState = {\n ...initThemesStore(),\n};\n\nexport const createThemesStore = (\n initState: ThemesState = defaultInitThemesState\n) => {\n return createStore<ThemesStore>()(\n devtools(\n persist(\n (set, get) => ({\n ...initState,\n\n updateTheme: (documentName, content) =>\n set((state) => {\n const validation = validateThemeJson(content);\n\n let parsed: ThemeConfigJson | undefined;\n let themeName = documentName;\n\n if (validation.valid) {\n try {\n const parsedContent = JSON.parse(content);\n parsed = parsedContent;\n const extractedName = getThemeName(parsedContent);\n if (extractedName) {\n themeName = extractedName;\n }\n } catch {\n // Keep the document name if parsing fails\n }\n }\n\n const existingTheme = state.customThemes[documentName];\n const isUpdate = !!existingTheme;\n const hasContentChanged = existingTheme?.content !== content;\n\n const customTheme: CustomTheme = {\n name: themeName,\n content,\n parsed,\n valid: validation.valid,\n lastModified: new Date(),\n };\n\n // Emit theme change if content changed OR if this is a newly valid theme\n const shouldEmitEvent =\n (hasContentChanged ||\n (!existingTheme?.valid && validation.valid)) &&\n validation.valid;\n\n if (shouldEmitEvent) {\n // Use setTimeout to ensure state is updated before event is processed\n setTimeout(() => {\n themeChangeEmitter.emitThemeChange({\n themeName,\n timestamp: Date.now(),\n changeType: isUpdate ? 'update' : 'create',\n });\n }, 0);\n }\n\n return {\n customThemes: {\n ...state.customThemes,\n [documentName]: customTheme,\n },\n };\n }),\n\n removeTheme: (documentName) =>\n set((state) => {\n const removedTheme = state.customThemes[documentName];\n const newCustomThemes = { ...state.customThemes };\n delete newCustomThemes[documentName];\n\n // Emit theme deletion event\n if (removedTheme) {\n setTimeout(() => {\n themeChangeEmitter.emitThemeChange({\n themeName: removedTheme.name,\n timestamp: Date.now(),\n changeType: 'delete',\n });\n }, 0);\n }\n\n return {\n customThemes: newCustomThemes,\n };\n }),\n\n getTheme: (themeName) => {\n const state = get();\n\n // First check custom themes by theme name\n for (const customTheme of Object.values(state.customThemes)) {\n if (\n customTheme.valid &&\n customTheme.name === themeName &&\n customTheme.parsed\n ) {\n return customTheme.parsed;\n }\n }\n\n // Theme not found in custom themes\n return null;\n },\n\n getAllThemeNames: () => {\n const state = get();\n const names: string[] = [];\n\n // Add custom theme names\n for (const customTheme of Object.values(state.customThemes)) {\n if (customTheme.valid && customTheme.name) {\n names.push(customTheme.name);\n }\n }\n\n return names;\n },\n\n isThemeValid: (themeName) => {\n const state = get();\n\n // Check custom themes\n for (const customTheme of Object.values(state.customThemes)) {\n if (customTheme.name === themeName) {\n return customTheme.valid;\n }\n }\n\n return false;\n },\n }),\n {\n name: 'themes-storage',\n version: 4, // v4: migrate from localStorage to IndexedDB\n storage: createJSONStorage(() => idbStorage),\n // Only persist the themes data, not the functions\n partialize: (state) => ({ customThemes: state.customThemes }),\n // Handle date deserialization when loading from storage\n onRehydrateStorage: () => (state) => {\n if (state && state.customThemes) {\n // Convert lastModified strings back to Date objects\n Object.keys(state.customThemes).forEach((key) => {\n const theme = state.customThemes[key];\n if (\n theme.lastModified &&\n typeof theme.lastModified === 'string'\n ) {\n theme.lastModified = new Date(theme.lastModified);\n }\n });\n }\n },\n }\n )\n )\n );\n};\n","import { type ReactNode, createContext, useRef, useContext } from 'react';\nimport { useStore } from 'zustand';\n\nimport {\n type ThemesStore,\n createThemesStore,\n initThemesStore,\n} from './themes-store';\n\nexport type ThemesStoreApi = ReturnType<typeof createThemesStore>;\n\nexport const ThemesStoreContext = createContext<ThemesStoreApi | undefined>(\n undefined\n);\n\nexport interface ThemesStoreProviderProps {\n children: ReactNode;\n}\n\nexport const ThemesStoreProvider = ({ children }: ThemesStoreProviderProps) => {\n const storeRef = useRef<ThemesStoreApi>(undefined);\n if (!storeRef.current) {\n storeRef.current = createThemesStore(initThemesStore());\n }\n\n return (\n <ThemesStoreContext.Provider value={storeRef.current}>\n {children}\n </ThemesStoreContext.Provider>\n );\n};\n\nexport const useThemesStore = <T,>(selector: (store: ThemesStore) => T): T => {\n const themesStoreContext = useContext(ThemesStoreContext);\n\n if (!themesStoreContext) {\n throw new Error('useThemesStore must be used within ThemesStoreProvider');\n }\n\n return useStore(themesStoreContext, selector);\n};\n","import { devtools } from 'zustand/middleware';\nimport { createStore } from 'zustand/vanilla';\n\nexport interface GenerationWarning {\n component: string;\n message: string;\n severity?: 'warning' | 'info';\n context?: Record<string, unknown>;\n}\n\nexport type OutputState = {\n name?: string; // last success => document name\n text?: string; // last success => code used to generate the pptx\n blob?: Blob; // last success => generated pptx\n globalError?: string; // last failed => global error message\n isGenerating?: boolean; // presentation generation in progress\n generationProgress?: {\n stage: 'parsing' | 'building' | 'rendering' | 'finalizing';\n message?: string;\n };\n cacheStatus?: 'HIT' | 'MISS' | 'UNKNOWN'; // cache hit/miss status\n cacheHitRate?: string; // cache hit rate percentage\n warnings?: GenerationWarning[] | null; // warnings from custom component processing\n isRendering?: boolean; // preview rendering in progress (iframe/LibreOffice)\n isPreviewStale?: boolean; // preview outdated (new blob generated but not yet rendered)\n editSequence?: number; // incremented on every Monaco keystroke (init 0)\n lastBuiltSequence?: number; // stamped when generation completes (init 0)\n editTimestamp?: number; // Date.now() of the last edit (for debounce countdown)\n // ⚠️ name doesn't necessarily correspond to the global error message\n};\n\nexport type OutputActions = {\n setOutput: (partialState: OutputState) => void;\n bumpEditSequence: () => void;\n};\n\nexport type OutputStore = OutputState & OutputActions;\n\nexport const initOutputStore = (): OutputState => {\n return {\n name: undefined,\n text: undefined,\n blob: undefined,\n globalError: undefined,\n isGenerating: false,\n generationProgress: undefined,\n isRendering: false,\n isPreviewStale: false,\n editSequence: 0,\n lastBuiltSequence: 0,\n };\n};\n\nexport const defaultInitOutputState: OutputState = {\n ...initOutputStore(),\n};\n\nexport const createOutputStore = (\n initState: OutputState = defaultInitOutputState\n) => {\n return createStore<OutputStore>()(\n devtools((set) => ({\n ...initState,\n setOutput: (partialState) => set({ ...partialState }),\n bumpEditSequence: () =>\n set((s) => ({\n editSequence: (s.editSequence ?? 0) + 1,\n editTimestamp: Date.now(),\n })),\n }))\n );\n};\n","import { type ReactNode, createContext, useRef, useContext } from 'react';\nimport { useStore } from 'zustand';\nimport {\n type OutputStore,\n createOutputStore,\n initOutputStore,\n} from './output-store';\n\nexport type OutputStoreApi = ReturnType<typeof createOutputStore>;\n\nexport const OutputStoreContext = createContext<OutputStoreApi | undefined>(\n undefined\n);\n\nexport interface OutputStoreProviderProps {\n children: ReactNode;\n}\n\nexport const OutputStoreProvider = ({ children }: OutputStoreProviderProps) => {\n const storeRef = useRef<OutputStoreApi | null>(null);\n if (!storeRef.current) {\n storeRef.current = createOutputStore(initOutputStore());\n }\n\n return (\n <OutputStoreContext.Provider value={storeRef.current}>\n {children}\n </OutputStoreContext.Provider>\n );\n};\n\nexport const useOutputStore = <T,>(selector: (store: OutputStore) => T): T => {\n const outputStoreContext = useContext(OutputStoreContext);\n\n if (!outputStoreContext) {\n throw new Error('useOutputStore must be used within OutputStoreProvider');\n }\n\n return useStore(outputStoreContext, selector);\n};\n","import { create } from 'zustand';\nimport { persist } from 'zustand/middleware';\nimport type { PluginMetadata } from '../hooks/useDiscovery';\n\ninterface PluginsState {\n // Selected plugin names (used for schema generation)\n selectedPlugins: Set<string>;\n\n // Full plugin metadata for selected plugins\n selectedPluginMetadata: Map<string, PluginMetadata>;\n\n // Schema application state\n isApplyingPlugins: boolean;\n lastApplyError: string | null;\n\n // Actions\n selectPlugin: (plugin: PluginMetadata) => void;\n deselectPlugin: (pluginName: string) => void;\n togglePlugin: (plugin: PluginMetadata) => void;\n clearSelections: () => void;\n isPluginSelected: (pluginName: string) => boolean;\n getSelectedPluginsList: () => PluginMetadata[];\n getSelectedPluginNames: () => string[];\n applyPluginsWithValidation: (\n onSuccess?: () => void,\n onError?: (error: string) => void\n ) => Promise<boolean>;\n}\n\nexport const usePluginsStore = create<PluginsState>()(\n persist(\n (set, get) => ({\n selectedPlugins: new Set<string>(),\n selectedPluginMetadata: new Map<string, PluginMetadata>(),\n isApplyingPlugins: false,\n lastApplyError: null,\n\n selectPlugin: (plugin: PluginMetadata) => {\n set((state) => {\n const newSelectedPlugins = new Set(state.selectedPlugins);\n const newMetadata = new Map(state.selectedPluginMetadata);\n\n newSelectedPlugins.add(plugin.name);\n newMetadata.set(plugin.name, plugin);\n\n return {\n selectedPlugins: newSelectedPlugins,\n selectedPluginMetadata: newMetadata,\n };\n });\n },\n\n deselectPlugin: (pluginName: string) => {\n set((state) => {\n const newSelectedPlugins = new Set(state.selectedPlugins);\n const newMetadata = new Map(state.selectedPluginMetadata);\n\n newSelectedPlugins.delete(pluginName);\n newMetadata.delete(pluginName);\n\n return {\n selectedPlugins: newSelectedPlugins,\n selectedPluginMetadata: newMetadata,\n };\n });\n },\n\n togglePlugin: (plugin: PluginMetadata) => {\n const isSelected = get().isPluginSelected(plugin.name);\n if (isSelected) {\n get().deselectPlugin(plugin.name);\n } else {\n get().selectPlugin(plugin);\n }\n // Auto-apply schema changes\n get().applyPluginsWithValidation().catch(console.error);\n },\n\n clearSelections: () => {\n set({\n selectedPlugins: new Set<string>(),\n selectedPluginMetadata: new Map<string, PluginMetadata>(),\n });\n // Auto-apply schema changes\n get().applyPluginsWithValidation().catch(console.error);\n },\n\n isPluginSelected: (pluginName: string) => {\n return get().selectedPlugins.has(pluginName);\n },\n\n getSelectedPluginsList: () => {\n return Array.from(get().selectedPluginMetadata.values());\n },\n\n getSelectedPluginNames: () => {\n return Array.from(get().selectedPlugins);\n },\n\n applyPluginsWithValidation: async (onSuccess, onError) => {\n set({ isApplyingPlugins: true, lastApplyError: null });\n\n try {\n // Get the current selected plugins\n const selectedPluginNames = Array.from(get().selectedPlugins);\n\n // Import Monaco and schema update function dynamically\n const { loader } = await import('@monaco-editor/react');\n const { updateMonacoWithPlugins } = await import(\n '../lib/monaco-config'\n );\n\n // Get Monaco instance\n const monaco = await loader.init();\n\n // Apply the plugins and wait for validation\n const success = await updateMonacoWithPlugins(\n monaco,\n selectedPluginNames\n );\n\n if (!success) {\n throw new Error('Schema validation failed');\n }\n\n // Success - schema has been applied and validated\n set({ isApplyingPlugins: false, lastApplyError: null });\n\n if (onSuccess) {\n onSuccess();\n }\n\n return true;\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to apply plugin schemas';\n\n set({\n isApplyingPlugins: false,\n lastApplyError: errorMessage,\n });\n\n if (onError) {\n onError(errorMessage);\n }\n\n console.error('Failed to apply plugins with validation:', error);\n return false;\n }\n },\n }),\n {\n name: 'jtp-selected-plugins',\n // Custom storage to handle Set and Map serialization\n storage: {\n getItem: (name) => {\n const str = localStorage.getItem(name);\n if (!str) return null;\n\n const { state } = JSON.parse(str);\n return {\n state: {\n ...state,\n selectedPlugins: new Set(state.selectedPlugins || []),\n selectedPluginMetadata: new Map(\n state.selectedPluginMetadata || []\n ),\n },\n };\n },\n setItem: (name, value) => {\n const { state } = value as { state: PluginsState };\n const serialized = JSON.stringify({\n state: {\n ...state,\n selectedPlugins: Array.from(state.selectedPlugins),\n selectedPluginMetadata: Array.from(\n state.selectedPluginMetadata.entries()\n ),\n },\n });\n localStorage.setItem(name, serialized);\n },\n removeItem: (name) => localStorage.removeItem(name),\n },\n }\n )\n);\n","import { devtools, persist } from 'zustand/middleware';\nimport { createStore } from 'zustand/vanilla';\nimport type { Settings } from '../lib/types';\nimport { FORMAT } from '../lib/env';\n\nexport type SettingsState = Settings;\n\nexport type SettingsActions = {\n setSettings: (settings: Partial<Settings>) => void;\n};\n\nexport type SettingsStore = SettingsState & SettingsActions;\n\nexport const initSettingsStore = (): SettingsState => {\n return {\n saveDocumentDebounceWait: 300,\n autoReload: true,\n renderingLibrary: FORMAT === 'docx' ? 'docxjs' : 'LibreOffice',\n // UI preference to use a single preview header spanning editor + preview\n useGlobalPreviewHeader: true,\n };\n};\n\nexport const defaultInitSettingsState: SettingsState = {\n ...initSettingsStore(),\n};\n\nexport const createSettingsStore = (\n initState: SettingsState = defaultInitSettingsState\n) => {\n return createStore<SettingsStore>()(\n devtools(\n persist(\n (set) => ({\n ...initState,\n setSettings: (settings) => set({ ...settings }),\n }),\n {\n name: 'settings-storage', // name of the item in the storage (must be unique)\n // (optional) by default, 'localStorage' is used as storage\n }\n )\n )\n );\n};\n","import { type ReactNode, createContext, useRef, useContext } from 'react';\nimport { useStore } from 'zustand';\nimport {\n type SettingsStore,\n createSettingsStore,\n initSettingsStore,\n} from './settings-store';\n\nexport type SettingsStoreApi = ReturnType<typeof createSettingsStore>;\n\nexport const SettingsStoreContext = createContext<SettingsStoreApi | undefined>(\n undefined\n);\n\nexport interface SettingsStoreProviderProps {\n children: ReactNode;\n}\n\nexport const SettingsStoreProvider = ({\n children,\n}: SettingsStoreProviderProps) => {\n const storeRef = useRef<SettingsStoreApi | null>(null);\n if (!storeRef.current) {\n storeRef.current = createSettingsStore(initSettingsStore());\n }\n\n return (\n <SettingsStoreContext.Provider value={storeRef.current}>\n {children}\n </SettingsStoreContext.Provider>\n );\n};\n\nexport const useSettingsStore = <T,>(\n selector: (store: SettingsStore) => T\n): T => {\n const settingsStoreContext = useContext(SettingsStoreContext);\n\n if (!settingsStoreContext) {\n throw new Error(\n 'useSettingsStore must be used within SettingsStoreProvider'\n );\n }\n\n return useStore(settingsStoreContext, selector);\n};\n","import { useEffect, useRef, useContext, useSyncExternalStore } from 'react';\nimport { loader } from '@monaco-editor/react';\nimport type { Monaco } from '@monaco-editor/react';\nimport { usePluginsStore } from '../store/plugins-store';\nimport { ThemesStoreContext } from '../store/themes-store-provider';\nimport { updateMonacoWithPlugins } from '../lib/monaco-config';\n\nconst emptyNames: string[] = [];\nconst subscribe = () => () => {};\n\n/**\n * Read custom theme names from the ThemesStore if available,\n * returning [] when outside a ThemesStoreProvider.\n *\n * getSnapshot must return a referentially stable value to avoid\n * infinite re-renders with useSyncExternalStore.\n */\nfunction useCustomThemeNames(): string[] {\n const store = useContext(ThemesStoreContext);\n const cachedRef = useRef<string[]>(emptyNames);\n\n const getSnapshot = store\n ? () => {\n const next = store.getState().getAllThemeNames();\n // Only update the cached reference when the list actually changes\n if (\n next.length !== cachedRef.current.length ||\n next.some((n, i) => n !== cachedRef.current[i])\n ) {\n cachedRef.current = next;\n }\n return cachedRef.current;\n }\n : () => emptyNames;\n\n return useSyncExternalStore(store ? store.subscribe : subscribe, getSnapshot);\n}\n\n/**\n * Hook to synchronize selected plugins and custom themes with Monaco editor schemas.\n * Ensures real-time validation and autocomplete include plugin-specific schemas\n * and custom theme names.\n */\nexport function useMonacoPlugins() {\n const monacoRef = useRef<Monaco | null>(null);\n const selectedPlugins = usePluginsStore((state) => state.selectedPlugins);\n const selectedPluginNames = Array.from(selectedPlugins);\n const customThemeNames = useCustomThemeNames();\n const themesStore = useContext(ThemesStoreContext);\n const themesStoreRef = useRef(themesStore);\n themesStoreRef.current = themesStore;\n const previousPluginsRef = useRef<string[]>([]);\n const previousThemesRef = useRef<string[]>([]);\n\n useEffect(() => {\n loader\n .init()\n .then((monaco) => {\n monacoRef.current = monaco;\n // Read current state from stores (not stale closure) since\n // zustand persist may have hydrated while loader.init() was pending\n const currentPlugins = Array.from(\n usePluginsStore.getState().selectedPlugins\n );\n const currentThemes =\n themesStoreRef.current?.getState().getAllThemeNames() ?? [];\n updateMonacoWithPlugins(monaco, currentPlugins, currentThemes)\n .then((success) => {\n if (success) {\n console.log(\n '[useMonacoPlugins] Monaco initialized with plugins:',\n currentPlugins\n );\n } else {\n console.warn(\n '[useMonacoPlugins] Monaco initialization completed with warnings'\n );\n }\n })\n .catch((error) => {\n console.error(\n '[useMonacoPlugins] Failed to update Monaco with plugins:',\n error\n );\n });\n previousPluginsRef.current = [...currentPlugins];\n previousThemesRef.current = [...currentThemes];\n })\n .catch((error) => {\n console.error('Failed to initialize Monaco:', error);\n });\n }, []); // Keep empty dependency to run only once\n\n useEffect(() => {\n const pluginsChanged =\n selectedPluginNames.length !== previousPluginsRef.current.length ||\n selectedPluginNames.some(\n (name, index) => name !== previousPluginsRef.current[index]\n );\n\n const themesChanged =\n customThemeNames.length !== previousThemesRef.current.length ||\n customThemeNames.some(\n (name, index) => name !== previousThemesRef.current[index]\n );\n\n if (!pluginsChanged && !themesChanged) {\n return;\n }\n\n if (monacoRef.current) {\n updateMonacoWithPlugins(\n monacoRef.current,\n selectedPluginNames,\n customThemeNames\n ).catch((error) => {\n console.error(\n '[useMonacoPlugins] Failed to update Monaco schemas:',\n error\n );\n });\n previousPluginsRef.current = [...selectedPluginNames];\n previousThemesRef.current = [...customThemeNames];\n }\n }, [selectedPluginNames, customThemeNames]);\n\n return {\n monaco: monacoRef.current,\n selectedPlugins: selectedPluginNames,\n };\n}\n","import { useMonacoPlugins } from '../hooks/useMonacoPlugins';\n\n/**\n * Provider component that manages Monaco plugin synchronization\n * This must be rendered within the app after stores are initialized\n */\nexport function MonacoPluginProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n // Initialize Monaco plugin synchronization\n useMonacoPlugins();\n\n return <>{children}</>;\n}\n"],"file":"assets/MonacoPluginProvider-C_k1zpkx.js"}
@@ -1,2 +1,2 @@
1
- import{j as e}from"./query-vendor-UL64zsGL.js";import{aq as o}from"./react-vendor-DhdcN9D5.js";import"./radix-ui-CXavUarI.js";function i(){return e.jsxs("div",{style:{textAlign:"center",padding:"2rem"},children:[e.jsx("h1",{children:"404 - Page Not Found"}),e.jsx("p",{children:"The page you're looking for doesn't exist."}),e.jsx(o,{to:"/",children:"Go back home"})]})}export{i as NotFoundPage};
2
- //# sourceMappingURL=NotFoundPage-Et1QhbQw.js.map
1
+ import{j as e}from"./query-vendor-CT0SoqJh.js";import{aq as o}from"./react-vendor-B_QXlk-T.js";import"./radix-ui-DkKm4m5M.js";function i(){return e.jsxs("div",{style:{textAlign:"center",padding:"2rem"},children:[e.jsx("h1",{children:"404 - Page Not Found"}),e.jsx("p",{children:"The page you're looking for doesn't exist."}),e.jsx(o,{to:"/",children:"Go back home"})]})}export{i as NotFoundPage};
2
+ //# sourceMappingURL=NotFoundPage-ILCklaD-.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotFoundPage-Et1QhbQw.js","sources":["../../../src/client/pages/NotFoundPage.tsx"],"sourcesContent":["import { Link } from 'react-router-dom';\n\nexport function NotFoundPage() {\n return (\n <div style={{ textAlign: 'center', padding: '2rem' }}>\n <h1>404 - Page Not Found</h1>\n <p>The page you're looking for doesn't exist.</p>\n <Link to=\"/\">Go back home</Link>\n </div>\n );\n}\n"],"names":["NotFoundPage","jsxs","jsx","Link"],"mappings":"8HAEO,SAASA,GAAe,CAC7B,OACEC,EAAAA,KAAC,OAAI,MAAO,CAAE,UAAW,SAAU,QAAS,QAC1C,SAAA,CAAAC,EAAAA,IAAC,MAAG,SAAA,sBAAA,CAAoB,EACxBA,EAAAA,IAAC,KAAE,SAAA,4CAAA,CAA0C,EAC7CA,EAAAA,IAACC,EAAA,CAAK,GAAG,IAAI,SAAA,cAAA,CAAY,CAAA,EAC3B,CAEJ"}
1
+ {"version":3,"file":"NotFoundPage-ILCklaD-.js","sources":["../../../src/client/pages/NotFoundPage.tsx"],"sourcesContent":["import { Link } from 'react-router-dom';\n\nexport function NotFoundPage() {\n return (\n <div style={{ textAlign: 'center', padding: '2rem' }}>\n <h1>404 - Page Not Found</h1>\n <p>The page you're looking for doesn't exist.</p>\n <Link to=\"/\">Go back home</Link>\n </div>\n );\n}\n"],"names":["NotFoundPage","jsxs","jsx","Link"],"mappings":"8HAEO,SAASA,GAAe,CAC7B,OACEC,EAAAA,KAAC,OAAI,MAAO,CAAE,UAAW,SAAU,QAAS,QAC1C,SAAA,CAAAC,EAAAA,IAAC,MAAG,SAAA,sBAAA,CAAoB,EACxBA,EAAAA,IAAC,KAAE,SAAA,4CAAA,CAA0C,EAC7CA,EAAAA,IAACC,EAAA,CAAK,GAAG,IAAI,SAAA,cAAA,CAAY,CAAA,EAC3B,CAEJ"}
@@ -1,2 +1,2 @@
1
- import{j as i}from"./query-vendor-UL64zsGL.js";import{r as d}from"./react-vendor-DhdcN9D5.js";import{S as c}from"./radix-ui-CXavUarI.js";import{a as u}from"./ui-vendor-BFdEgxEg.js";import{c as m}from"./index-uE8YOnrS.js";const f=u("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 cursor-pointer",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),p=d.forwardRef(({className:e,variant:r,size:t,asChild:o=!1,...n},s)=>{const a=o?c:"button";return i.jsx(a,{className:m(f({variant:r,size:t,className:e})),ref:s,...n})});p.displayName="Button";export{p as B};
2
- //# sourceMappingURL=button-Bf6x7Zjh.js.map
1
+ import{j as i}from"./query-vendor-CT0SoqJh.js";import{r as d}from"./react-vendor-B_QXlk-T.js";import{S as c}from"./radix-ui-DkKm4m5M.js";import{a as u}from"./ui-vendor-ChWVh3T-.js";import{c as m}from"./index-CslfgN2g.js";const f=u("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 cursor-pointer",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),p=d.forwardRef(({className:e,variant:r,size:t,asChild:o=!1,...n},s)=>{const a=o?c:"button";return i.jsx(a,{className:m(f({variant:r,size:t,className:e})),ref:s,...n})});p.displayName="Button";export{p as B};
2
+ //# sourceMappingURL=button-DLt0WPRa.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"button-Bf6x7Zjh.js","sources":["../../../src/client/components/ui/button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport { type VariantProps, cva } from 'class-variance-authority';\nimport { cn } from '@/lib/utils';\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 cursor-pointer',\n {\n variants: {\n variant: {\n default:\n 'bg-primary text-primary-foreground shadow hover:bg-primary/90',\n destructive:\n 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',\n outline:\n 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',\n secondary:\n 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',\n ghost: 'hover:bg-accent hover:text-accent-foreground',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n size: {\n default: 'h-9 px-4 py-2',\n sm: 'h-8 rounded-md px-3 text-xs',\n lg: 'h-10 rounded-md px-8',\n icon: 'h-9 w-9',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : 'button';\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n {...props}\n />\n );\n }\n);\nButton.displayName = 'Button';\n\nexport { Button, buttonVariants };\n"],"names":["buttonVariants","cva","Button","React.forwardRef","className","variant","size","asChild","props","ref","Comp","Slot","jsx","cn"],"mappings":"6NAKA,MAAMA,EAAiBC,EACrB,uTACA,CACE,SAAU,CACR,QAAS,CACP,QACE,gEACF,YACE,+EACF,QACE,2FACF,UACE,yEACF,MAAO,+CACP,KAAM,iDAAA,EAER,KAAM,CACJ,QAAS,gBACT,GAAI,8BACJ,GAAI,uBACJ,KAAM,SAAA,CACR,EAEF,gBAAiB,CACf,QAAS,UACT,KAAM,SAAA,CACR,CAEJ,EAQMC,EAASC,EAAAA,WACb,CAAC,CAAE,UAAAC,EAAW,QAAAC,EAAS,KAAAC,EAAM,QAAAC,EAAU,GAAO,GAAGC,CAAA,EAASC,IAAQ,CAChE,MAAMC,EAAOH,EAAUI,EAAO,SAC9B,OACEC,EAAAA,IAACF,EAAA,CACC,UAAWG,EAAGb,EAAe,CAAE,QAAAK,EAAS,KAAAC,EAAM,UAAAF,CAAA,CAAW,CAAC,EAC1D,IAAAK,EACC,GAAGD,CAAA,CAAA,CAGV,CACF,EACAN,EAAO,YAAc"}
1
+ {"version":3,"file":"button-DLt0WPRa.js","sources":["../../../src/client/components/ui/button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport { type VariantProps, cva } from 'class-variance-authority';\nimport { cn } from '@/lib/utils';\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 cursor-pointer',\n {\n variants: {\n variant: {\n default:\n 'bg-primary text-primary-foreground shadow hover:bg-primary/90',\n destructive:\n 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',\n outline:\n 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',\n secondary:\n 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',\n ghost: 'hover:bg-accent hover:text-accent-foreground',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n size: {\n default: 'h-9 px-4 py-2',\n sm: 'h-8 rounded-md px-3 text-xs',\n lg: 'h-10 rounded-md px-8',\n icon: 'h-9 w-9',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : 'button';\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n {...props}\n />\n );\n }\n);\nButton.displayName = 'Button';\n\nexport { Button, buttonVariants };\n"],"names":["buttonVariants","cva","Button","React.forwardRef","className","variant","size","asChild","props","ref","Comp","Slot","jsx","cn"],"mappings":"6NAKA,MAAMA,EAAiBC,EACrB,uTACA,CACE,SAAU,CACR,QAAS,CACP,QACE,gEACF,YACE,+EACF,QACE,2FACF,UACE,yEACF,MAAO,+CACP,KAAM,iDAAA,EAER,KAAM,CACJ,QAAS,gBACT,GAAI,8BACJ,GAAI,uBACJ,KAAM,SAAA,CACR,EAEF,gBAAiB,CACf,QAAS,UACT,KAAM,SAAA,CACR,CAEJ,EAQMC,EAASC,EAAAA,WACb,CAAC,CAAE,UAAAC,EAAW,QAAAC,EAAS,KAAAC,EAAM,QAAAC,EAAU,GAAO,GAAGC,CAAA,EAASC,IAAQ,CAChE,MAAMC,EAAOH,EAAUI,EAAO,SAC9B,OACEC,EAAAA,IAACF,EAAA,CACC,UAAWG,EAAGb,EAAe,CAAE,QAAAK,EAAS,KAAAC,EAAM,UAAAF,CAAA,CAAW,CAAC,EAC1D,IAAAK,EACC,GAAGD,CAAA,CAAA,CAGV,CACF,EACAN,EAAO,YAAc"}
@@ -1,4 +1,4 @@
1
- import{c as Mt,g as _e}from"./react-vendor-DhdcN9D5.js";import"./radix-ui-CXavUarI.js";import"./query-vendor-UL64zsGL.js";function Rt(c){throw new Error('Could not dynamically require "'+c+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Lt={exports:{}};/*!
1
+ import{c as Mt,g as _e}from"./react-vendor-B_QXlk-T.js";import"./radix-ui-DkKm4m5M.js";import"./query-vendor-CT0SoqJh.js";function Rt(c){throw new Error('Could not dynamically require "'+c+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Lt={exports:{}};/*!
2
2
 
3
3
  JSZip v3.10.1 - A JavaScript class for generating and reading zip files
4
4
  <http://stuartk.com/jszip>
@@ -31,4 +31,4 @@ section.${e}>footer { z-index: 1; }
31
31
  `;for(const a in t)a.startsWith("$")||(n+=` ${a}: ${t[a]};\r
32
32
  `);return r&&(n+=r),n+`}\r
33
33
  `}numberingCounter(e,t){return`${this.className}-num-${e}-${t}`}levelTextToContent(e,t,r,n){const a={tab:"\\9",space:"\\a0"};var o=e.replace(/%\d*/g,i=>{let h=parseInt(i.substring(1),10)-1;return`"counter(${this.numberingCounter(r,h)}, ${n})"`});return`"${o}${a[t]??""}"`}numFormatToCssValue(e){var t={none:"none",bullet:"disc",decimal:"decimal",lowerLetter:"lower-alpha",upperLetter:"upper-alpha",lowerRoman:"lower-roman",upperRoman:"upper-roman",decimalZero:"decimal-leading-zero",aiueo:"katakana",aiueoFullWidth:"katakana",chineseCounting:"simp-chinese-informal",chineseCountingThousand:"simp-chinese-informal",chineseLegalSimplified:"simp-chinese-formal",chosung:"hangul-consonant",ideographDigital:"cjk-ideographic",ideographTraditional:"cjk-heavenly-stem",ideographLegalTraditional:"trad-chinese-formal",ideographZodiac:"cjk-earthly-branch",iroha:"katakana-iroha",irohaFullWidth:"katakana-iroha",japaneseCounting:"japanese-informal",japaneseDigitalTenThousand:"cjk-decimal",japaneseLegal:"japanese-formal",thaiNumbers:"thai",koreanCounting:"korean-hangul-formal",koreanDigital:"korean-hangul-formal",koreanDigital2:"korean-hanja-informal",hebrew1:"hebrew",hebrew2:"hebrew",hindiNumbers:"devanagari",ganada:"hangul",taiwaneseCounting:"cjk-ideographic",taiwaneseCountingThousand:"cjk-ideographic",taiwaneseDigital:"cjk-decimal"};return t[e]??e}refreshTabStops(){this.options.experimental&&setTimeout(()=>{const e=Lr();for(let t of this.currentTabs)jr(t.span,t.stops,this.defaultTabSize,e)},500)}createElementNS(e,t,r,n){var a=e?this.htmlDocument.createElementNS(e,t):this.htmlDocument.createElement(t);return Object.assign(a,r),n&&$t(a,n),a}createElement(e,t,r){return this.createElementNS(void 0,e,t,r)}createSvgElement(e,t,r){return this.createElementNS(at.svg,e,t,r)}createStyleElement(e){return this.createElement("style",{innerHTML:e})}createComment(e){return this.htmlDocument.createComment(e)}later(e){this.postRenderTasks.push(e)}}function ae(c){c.innerHTML=""}function $t(c,e){e.forEach(t=>c.appendChild(De(t)?document.createTextNode(t):t))}function $r(c,e){for(var t=c.parent;t!=null&&t.type!=e;)t=t.parent;return t}const be={ignoreHeight:!1,ignoreWidth:!1,ignoreFonts:!1,breakPages:!0,debug:!1,experimental:!1,className:"docx",inWrapper:!0,trimXmlDeclaration:!0,ignoreLastRenderedPageBreak:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,renderEndnotes:!0,useBase64URL:!1,renderChanges:!1,renderComments:!1};function Wr(c,e){const t={...be,...e};return Zt.load(c,new Fr(t),t)}async function Hr(c,e,t,r){const n={...be,...r};return await new Ur(window.document).render(c,e,t,n)}async function Gr(c,e,t,r){const n=await Wr(c,r);return await Hr(n,e,t,r),n}export{be as defaultOptions,Wr as parseAsync,Gr as renderAsync,Hr as renderDocument};
34
- //# sourceMappingURL=docx-preview-CUjVWdSJ.js.map
34
+ //# sourceMappingURL=docx-preview-DkKCgwb-.js.map