@vertesia/ui 1.5.0-dev.20260714.072725Z → 1.5.0-dev.20260717.131047Z

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 (135) hide show
  1. package/lib/env/index.d.ts +19 -0
  2. package/lib/env/index.d.ts.map +1 -1
  3. package/lib/env/index.js +6 -0
  4. package/lib/env/index.js.map +1 -1
  5. package/lib/features/agent/chat/ArtifactsTab.d.ts.map +1 -1
  6. package/lib/features/agent/chat/ArtifactsTab.js +65 -11
  7. package/lib/features/agent/chat/ArtifactsTab.js.map +1 -1
  8. package/lib/features/agent/chat/ModernAgentConversation.js +51 -48
  9. package/lib/features/agent/chat/ModernAgentConversation.js.map +1 -1
  10. package/lib/features/agent/chat/hooks/useArtifacts.d.ts +8 -1
  11. package/lib/features/agent/chat/hooks/useArtifacts.d.ts.map +1 -1
  12. package/lib/features/agent/chat/hooks/useArtifacts.js +28 -10
  13. package/lib/features/agent/chat/hooks/useArtifacts.js.map +1 -1
  14. package/lib/features/document-viewer/UniversalDocumentViewer.d.ts +73 -0
  15. package/lib/features/document-viewer/UniversalDocumentViewer.d.ts.map +1 -0
  16. package/lib/features/document-viewer/UniversalDocumentViewer.js +415 -0
  17. package/lib/features/document-viewer/UniversalDocumentViewer.js.map +1 -0
  18. package/lib/features/document-viewer/index.d.ts +2 -0
  19. package/lib/features/document-viewer/index.d.ts.map +1 -0
  20. package/lib/features/document-viewer/index.js +2 -0
  21. package/lib/features/document-viewer/index.js.map +1 -0
  22. package/lib/features/index.d.ts +1 -0
  23. package/lib/features/index.d.ts.map +1 -1
  24. package/lib/features/index.js +1 -0
  25. package/lib/features/index.js.map +1 -1
  26. package/lib/features/permissions/UserPermissionsProvider.d.ts +2 -3
  27. package/lib/features/permissions/UserPermissionsProvider.d.ts.map +1 -1
  28. package/lib/features/permissions/UserPermissionsProvider.js +31 -38
  29. package/lib/features/permissions/UserPermissionsProvider.js.map +1 -1
  30. package/lib/features/store/objects/components/ContentOverview.d.ts.map +1 -1
  31. package/lib/features/store/objects/components/ContentOverview.js +73 -13
  32. package/lib/features/store/objects/components/ContentOverview.js.map +1 -1
  33. package/lib/i18n/locales/ar.json +2 -0
  34. package/lib/i18n/locales/de.json +2 -0
  35. package/lib/i18n/locales/en.json +2 -0
  36. package/lib/i18n/locales/es.json +2 -0
  37. package/lib/i18n/locales/fr.json +2 -0
  38. package/lib/i18n/locales/it.json +2 -0
  39. package/lib/i18n/locales/ja.json +2 -0
  40. package/lib/i18n/locales/ko.json +2 -0
  41. package/lib/i18n/locales/pt.json +2 -0
  42. package/lib/i18n/locales/ru.json +2 -0
  43. package/lib/i18n/locales/tr.json +2 -0
  44. package/lib/i18n/locales/zh-TW.json +2 -0
  45. package/lib/i18n/locales/zh.json +2 -0
  46. package/lib/router/HistoryNavigator.d.ts.map +1 -1
  47. package/lib/router/HistoryNavigator.js +4 -1
  48. package/lib/router/HistoryNavigator.js.map +1 -1
  49. package/lib/router/Nav.d.ts.map +1 -1
  50. package/lib/router/Nav.js +7 -1
  51. package/lib/router/Nav.js.map +1 -1
  52. package/lib/router/Router.d.ts.map +1 -1
  53. package/lib/router/Router.js +19 -4
  54. package/lib/router/Router.js.map +1 -1
  55. package/lib/router/path.d.ts +15 -0
  56. package/lib/router/path.d.ts.map +1 -1
  57. package/lib/router/path.js +43 -0
  58. package/lib/router/path.js.map +1 -1
  59. package/lib/session/UserSession.d.ts +6 -0
  60. package/lib/session/UserSession.d.ts.map +1 -1
  61. package/lib/session/UserSession.js +31 -9
  62. package/lib/session/UserSession.js.map +1 -1
  63. package/lib/session/UserSessionProvider.d.ts.map +1 -1
  64. package/lib/session/UserSessionProvider.js +111 -49
  65. package/lib/session/UserSessionProvider.js.map +1 -1
  66. package/lib/session/auth/composable.d.ts.map +1 -1
  67. package/lib/session/auth/composable.js +52 -3
  68. package/lib/session/auth/composable.js.map +1 -1
  69. package/lib/session/auth/domainRouting.d.ts +25 -0
  70. package/lib/session/auth/domainRouting.d.ts.map +1 -1
  71. package/lib/session/auth/domainRouting.js +36 -0
  72. package/lib/session/auth/domainRouting.js.map +1 -1
  73. package/lib/shell/login/SignInRestrictedEnvStep.d.ts +1 -1
  74. package/lib/shell/login/SignInRestrictedEnvStep.js +1 -1
  75. package/lib/shell/login/SigninScreen.js +9 -1
  76. package/lib/shell/login/SigninScreen.js.map +1 -1
  77. package/lib/shell/login/productionUrl.d.ts +0 -14
  78. package/lib/shell/login/productionUrl.d.ts.map +1 -1
  79. package/lib/shell/login/productionUrl.js +14 -5
  80. package/lib/shell/login/productionUrl.js.map +1 -1
  81. package/lib/vertesia-ui-core.js +3 -3
  82. package/lib/vertesia-ui-core.js.map +1 -1
  83. package/lib/vertesia-ui-env.js +1 -1
  84. package/lib/vertesia-ui-env.js.map +1 -1
  85. package/lib/vertesia-ui-features.js +28 -28
  86. package/lib/vertesia-ui-features.js.map +1 -1
  87. package/lib/vertesia-ui-i18n.js +13 -13
  88. package/lib/vertesia-ui-router.js +1 -1
  89. package/lib/vertesia-ui-router.js.map +1 -1
  90. package/lib/vertesia-ui-session.js +1 -1
  91. package/lib/vertesia-ui-session.js.map +1 -1
  92. package/lib/vertesia-ui-shell.js +1 -1
  93. package/lib/vertesia-ui-shell.js.map +1 -1
  94. package/lib/vertesia-ui-widgets.js +2 -2
  95. package/lib/vertesia-ui-widgets.js.map +1 -1
  96. package/llms.txt +70 -70
  97. package/package.json +8 -7
  98. package/src/env/index.ts +24 -0
  99. package/src/features/agent/chat/ArtifactsTab.tsx +155 -21
  100. package/src/features/agent/chat/ModernAgentConversation.tsx +53 -49
  101. package/src/features/agent/chat/hooks/useArtifacts.ts +44 -11
  102. package/src/features/document-viewer/UniversalDocumentViewer.test.tsx +123 -0
  103. package/src/features/document-viewer/UniversalDocumentViewer.tsx +746 -0
  104. package/src/features/document-viewer/index.ts +1 -0
  105. package/src/features/index.ts +1 -0
  106. package/src/features/permissions/UserPermissionsProvider.tsx +36 -39
  107. package/src/features/store/objects/components/ContentOverview.tsx +99 -26
  108. package/src/i18n/locales/ar.json +2 -0
  109. package/src/i18n/locales/de.json +2 -0
  110. package/src/i18n/locales/en.json +2 -0
  111. package/src/i18n/locales/es.json +2 -0
  112. package/src/i18n/locales/fr.json +2 -0
  113. package/src/i18n/locales/it.json +2 -0
  114. package/src/i18n/locales/ja.json +2 -0
  115. package/src/i18n/locales/ko.json +2 -0
  116. package/src/i18n/locales/pt.json +2 -0
  117. package/src/i18n/locales/ru.json +2 -0
  118. package/src/i18n/locales/tr.json +2 -0
  119. package/src/i18n/locales/zh-TW.json +2 -0
  120. package/src/i18n/locales/zh.json +2 -0
  121. package/src/router/HistoryNavigator.ts +4 -1
  122. package/src/router/Nav.tsx +7 -1
  123. package/src/router/Router.tsx +18 -4
  124. package/src/router/path.test.ts +87 -0
  125. package/src/router/path.ts +38 -0
  126. package/src/session/UserSession.ts +32 -9
  127. package/src/session/UserSessionProvider.tsx +138 -62
  128. package/src/session/auth/composable.test.ts +111 -0
  129. package/src/session/auth/composable.ts +58 -3
  130. package/src/session/auth/domainRouting.test.ts +28 -1
  131. package/src/session/auth/domainRouting.ts +38 -0
  132. package/src/shell/login/SignInRestrictedEnvStep.tsx +1 -1
  133. package/src/shell/login/SigninScreen.tsx +9 -1
  134. package/src/shell/login/productionUrl.test.ts +8 -5
  135. package/src/shell/login/productionUrl.ts +15 -5
@@ -2,8 +2,8 @@ import{Fragment as e,jsx as t,jsxs as n}from"react/jsx-runtime";import{Button as
2
2
  `),[i]);return t(`pre`,{className:`h-full overflow-auto rounded-md border bg-background p-3 font-mono text-xs leading-5 text-foreground ${r||``}`,children:t(`code`,{children:a.map((e,t)=>n(`span`,{children:[Dt(e),t<a.length-1?`
3
3
  `:null]},`line-${t}`))})})}const Tt=/("(?:\\.|[^"\\])*"?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,Et=/^\s*:/;function Dt(e){Tt.lastIndex=0;let n=[],r=0,i=Tt.exec(e);for(;i!==null;){i.index>r&&n.push(e.slice(r,i.index));let[a,o,s,c]=i,l=o!==void 0&&Et.test(e.slice(i.index+a.length))?`text-info`:o?`text-success`:s?`text-primary`:c?`text-attention`:void 0;n.push(t(`span`,{className:l,children:a},`${i.index}-${a}`)),r=i.index+a.length,i=Tt.exec(e)}return r<e.length&&n.push(e.slice(r)),n.length?n:e}function Ot({value:e}){return Array.isArray(e)?t(`div`,{className:`flex flex-col gap-4 px-2 h-full overflow-auto`,children:t(jt,{value:e})}):typeof e!=`object`||!e?t(`div`,{className:`flex flex-col gap-4 px-2 h-full overflow-auto`,children:t(At,{name:`value`,value:e})}):t(`div`,{className:`flex flex-col gap-4 px-2 h-full overflow-auto`,children:Object.entries(e).map(([e,n])=>t(At,{name:e,value:n},e))})}function W({name:e}){return t(`div`,{className:`text-md font-semibold`,children:gt(e)})}function kt({children:e,className:n}){return t(`div`,{className:y(`flex flex-col gap-4 py-2 ps-4 border-s-4 border-s-solid border-s-slate-100 dark:border-s-slate-600`,n),children:e})}function At({name:e,value:r}){let i=Nt(r);switch(i.type){case G.Inline:return n(`div`,{className:`w-full flex gap-2`,children:[t(W,{name:`${e}:`}),t(`p`,{children:i.value})]});case G.Paragraph:return n(`div`,{children:[t(W,{name:e}),t(`p`,{children:i.value})]});case G.Prose:return n(`div`,{className:`prose dark:prose-invert`,children:[t(W,{name:e}),t(`div`,{className:`vprose dark:prose-invert`,children:i.value})]});case G.Array:return t(jt,{name:e,value:r});case G.Object:return n(`div`,{children:[t(W,{name:e}),t(kt,{className:`mt-2`,children:Object.entries(r).map(([e,n])=>t(At,{name:e,value:n},e))})]})}}function jt({name:e,value:r}){let a=r.join(` `).length,o=a/r.length,s=typeof r[0]==`string`&&(a<80||a<400&&o<32),c=r.length>9,l=r.map((e,t)=>({item:e,index:t,key:`${t}-${JSON.stringify(e)}`}));return s?n(`div`,{className:`flex gap-2 flex-wrap`,children:[e&&t(W,{name:`${e}:`}),l.map(({item:e,key:n})=>t(i,{children:String(e)},n))]}):n(`div`,{children:[e&&t(W,{name:e}),t(`div`,{className:`flex flex-col gap-2`,children:l.map(({item:e,index:n,key:r})=>t(Mt,{index:n,value:e,useBullet:c},r))})]})}function Mt({index:e,value:r,useBullet:i}){let a=i?t(`span`,{className:`text-xl`,children:`•`}):n(`span`,{children:[e+1,`.`]}),o=Nt(r),s;switch(o.type){case G.Object:s=t(kt,{children:Object.entries(r).map(([e,n])=>t(At,{name:e,value:n},e))});break;case G.Array:s=t(jt,{value:r});break;case G.Prose:s=t(`div`,{className:`prose dark:prose-invert`,children:o.value});break;default:s=t(`div`,{children:o.value});break}return n(`div`,{className:`flex gap-4 hover:bg-slate-50 dark:hover:bg-slate-800 py-2 pe-2 ps-4`,children:[t(`div`,{className:`font-semibold text-gray-600 dark:text-gray-400`,children:a}),t(`div`,{children:s})]})}var G;(function(e){e[e.Inline=0]=`Inline`,e[e.Paragraph=1]=`Paragraph`,e[e.Prose=2]=`Prose`,e[e.Array=3]=`Array`,e[e.Object=4]=`Object`})(G||={});function Nt(e){if(e==null)return{value:`-`,type:G.Inline};if(Array.isArray(e))return{value:e,type:G.Array};if(typeof e==`string`){let t=e.length,n,r=e;return t<80?n=G.Inline:t>400?n=G.Prose:(n=G.Paragraph,r=e.replace(/(?:\n\n)+/g,`
4
4
 
5
- `)),{type:n,value:r}}else if(typeof e==`number`||typeof e==`boolean`)return{value:String(e),type:G.Inline};else return{value:e,type:G.Object}}function Pt({value:e,viewCode:n=!1}){let{t:r}=R();return e?t(`div`,{className:`relative w-full h-full flex flex-col`,children:n||!Ft(e)?t(wt,{data:e}):t(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:t(Ot,{value:e})})}):t(`pre`,{className:`whitespace-pre-wrap`,children:r(`misc.noData`)})}function Ft(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?!0:Array.isArray(e)?e.every(Ft):typeof e==`object`?Object.values(e).every(Ft):!1}const It=new Set;function Lt(e){It.has(`markdown`)||(It.add(`markdown`),e.languages.registerFoldingRangeProvider(`markdown`,{provideFoldingRanges(e){let t=[],n=e.getLinesContent(),r=/^(#{1,6})\s/,i=[];for(let e=0;e<n.length;e++){let a=e+1,o=r.exec(n[e]);if(o){let e=o[1].length;for(;i.length>0&&i[i.length-1].level>=e;){let e=i.pop();e&&a-1>e.line&&t.push({start:e.line,end:a-1})}i.push({level:e,line:a})}}let a=n.length;for(;i.length>0;){let e=i.pop();e&&a>e.line&&t.push({start:e.line,end:a})}return t}}));for(let t of[`javascript`,`typescript`])It.has(t)||(It.add(t),e.languages.registerFoldingRangeProvider(t,{provideFoldingRanges(e){let t=e.getLinesContent(),n=/^(#{1,6})\s/,r=[],i=[],a=[],o=[],s=!1,c=!1,l=``;for(let e=0;e<t.length;e++){let u=e+1,d=t[e],f=s;for(let e=0;e<d.length;e++){let t=d[e];if(t===`\\`){e++;continue}if(c){t===l&&(c=!1);continue}if(s){t==="`"&&(s=!1);continue}if(t==="`"){s=!0;continue}if(t===`"`||t===`'`){c=!0,l=t;continue}if(t===`{`&&a.push(u),t===`}`&&a.length>0){let t=a.pop(),n=d.slice(e+1).trimStart().length>0?u-1:u;t!==void 0&&n>t&&r.push({start:t,end:n})}}if(f){let e=n.exec(d);if(e){let t=e[1].length;for(;o.length>0&&o[o.length-1].level>=t;){let e=o.pop();e&&u-1>e.line&&i.push({start:e.line,end:u-1})}o.push({level:t,line:u})}if(!s)for(;o.length>0;){let e=o.pop();e&&u>e.line&&i.push({start:e.line,end:u})}}}return[...r,...i]}}))}var Rt=class{VgetValue;VsetValue;constructor(e,t){this.VgetValue=e,this.VsetValue=t}getValue(){return this.VgetValue()}setValue(e){this.VsetValue(e||``)}};function zt({onChange:e,value:n,className:r,editorRef:i,language:a=`javascript`,path:o,debounceTimeout:s=0,options:c={},beforeMount:l,onMount:u,defaultValue:d,useCustomFolding:f=!1}){let[p,m]=L(n||d||``),h=I(null),g=I(null),{theme:v}=_(),b=v===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:v,x=n||d||``,S=I(()=>p),C=I(e=>{m(e),h.current&&h.current.setValue(e)});P(()=>{S.current=()=>p},[p]),P(()=>(i&&(i.current=new Rt(()=>S.current(),e=>C.current(e))),()=>{i&&(i.current=void 0)}),[i]);let ee=F(()=>{if(e)return s>0?Se(t=>e(t),s):e},[e,s]),w=M(async(e,t)=>{let n=e.getModel();if(n)for(let r of n.getValue().matchAll(/```[\s\S]*?```/g)){let i=n.getPositionAt(r.index).lineNumber,a=n.getPositionAt(r.index+r[0].length).lineNumber;e.setSelection(new t.Selection(i,1,a,1)),await e.getAction(`editor.createFoldingRangeFromSelection`)?.run()}},[]),te=M(e=>{let t=e||``;m(t),ee&&ee({docChanged:!0,state:{doc:{toString:()=>t,length:t.length}}})},[ee]),T=M((e,t)=>{h.current=e,g.current=t,f&&Lt(t),C.current=t=>{m(t),e.setValue(t)},t.editor.defineTheme(`errorLineTheme`,{base:b===`dark`?`vs-dark`:`vs`,inherit:!0,rules:[],colors:{"editorError.background":`#ffebee`,"editorError.border":`#f44336`}}),t.editor.setTheme(`errorLineTheme`),f&&setTimeout(()=>w(e,t),300),u?.(e,t)},[u,b,f,w]);P(()=>{m(e=>x===e?e:(h.current&&h.current.setValue(x),x))},[x]),P(()=>{if(!x||!f||!h.current||!g.current)return;let e=h.current,t=g.current,n=setTimeout(()=>w(e,t),300);return()=>clearTimeout(n)},[x,f,w]);let E={fontSize:14,fontFamily:`monospace`,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,lineNumbers:`on`,folding:!0,lineDecorationsWidth:10,lineNumbersMinChars:3,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2,insertSpaces:!0,fixedOverflowWidgets:!0,glyphMargin:!0,renderValidationDecorations:`on`,renderLineHighlight:`line`,hover:{enabled:!0,delay:100},quickSuggestions:{other:!0,comments:!0,strings:!0},...c};return t(`div`,{className:y(r,`w-full h-full!`),children:t(xe,{className:`h-full w-full`,height:`100%`,theme:b===`dark`?`vs-dark`:`light`,language:a,path:o,value:p,onChange:te,onMount:T,beforeMount:l,options:E,defaultValue:d||``})})}function Bt({value:e,onChange:r,onValidChange:i,readonly:a=!1,height:o=`200px`,placeholder:s,className:c}){let{theme:l}=_(),u=I(void 0),[d,f]=L(null),p=F(()=>{if(e==null)return s??`{}`;try{return JSON.stringify(e,null,2)}catch{return`{}`}},[e,s]),m=M(()=>{if(!u.current||a)return;let e=u.current.getValue();try{let t=JSON.parse(e);f(null),i?.(t)}catch{f(`Invalid JSON`)}},[a,i]);return n(`div`,{className:c,children:[t(`div`,{className:`border rounded overflow-hidden`,style:{height:o},children:t(zt,{defaultValue:p,editorRef:u,language:`json`,theme:l===`dark`?`vs-dark`:`vs`,onChange:m,options:a?{readOnly:!0,domReadOnly:!0}:void 0})}),d&&t(`p`,{className:`text-xs text-destructive mt-1`,children:d})]})}function Vt(e){if(!e.current)return null;try{return JSON.parse(e.current.getValue())}catch{return null}}function Ht({title:e,viewCode:i,setViewCode:a}){return n(`div`,{className:`flex items-center gap-1 bg-muted mb-2 p-1 rounded`,children:[t(r,{variant:i?`ghost`:`primary`,size:`sm`,alt:`Preview properties`,onClick:()=>a(!1),children:e}),t(r,{variant:i?`primary`:`ghost`,size:`sm`,alt:`View in JSON format`,onClick:()=>a(!0),children:`JSON`})]})}function Ut(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim().replace(/^./,e=>e.toUpperCase())}function Wt(r){return r==null?`Failed to query`:typeof r==`string`?r:Array.isArray(r)?r.length===0?`None`:r.some(e=>e&&typeof e==`object`)?t(e,{children:r.map((e,r)=>n(`div`,{className:`flex gap-1`,children:[n(`span`,{className:`text-xs align-top pe-2 font-medium`,children:[r+1,`:`]}),t(`span`,{className:`text-xs`,children:Wt(e)})]},`item-${r}`))}):r.map(e=>String(e)).join(`, `):typeof r==`object`?t(e,{children:Object.entries(r).map(([e,r])=>n(`div`,{className:`flex gap-1`,children:[n(`span`,{className:`text-xs align-top pe-2 font-medium`,children:[Ut(e),`:`]}),t(`span`,{className:`text-xs`,children:Wt(r)})]},e))}):String(r)}function Gt({data:e,className:r}){let i=e?Object.entries(e):[];return t(`table`,{className:r||`mb-2 text-xs bg-muted rounded-sm w-full`,children:t(`tbody`,{children:i.map(([e,r])=>n(`tr`,{className:`align-top hover:bg-background border-y`,children:[t(`td`,{className:`align-top pe-4 p-2`,children:Ut(e)}),t(`td`,{className:`p-2`,children:Wt(r)})]},e))})})}function Kt(...e){return ke(b(e))}const qt=A(null);function Jt(){return N(qt)}function Yt(e){return e.startsWith(`agents/`)||e.startsWith(`documents/`)}function Xt(e,t,n=`inline`){return`artifact:${e}:${t}:${n}`}function Zt(e){return`file:${e}`}function Qt({error:e,chartTitle:r}){return t(`div`,{className:`flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4`,children:n(`div`,{className:`text-center`,children:[n(`p`,{className:`text-sm font-medium text-red-600 dark:text-red-400`,children:[`Cannot render `,r||`Vega-Lite`,` chart`]}),t(`p`,{className:`text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate`,children:e})]})})}function $t({isOpen:e,onClose:i,title:a,description:o,children:s}){let{t:c}=R();return t(z.Root,{open:e,onOpenChange:e=>!e&&i(),children:n(z.Portal,{children:[t(z.Overlay,{className:`fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),n(z.Content,{className:`fixed inset-2 sm:inset-4 z-50 flex flex-col bg-white dark:bg-gray-900 rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2`,onEscapeKeyDown:i,children:[t(z.Close,{asChild:!0,children:t(r,{variant:`unstyled`,onClick:i,className:`absolute top-3 end-3 z-10 p-2 rounded-lg bg-white/80 dark:bg-gray-800/80 backdrop-blur-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 shadow-sm`,"aria-label":c(`agent.closeFullscreen`),children:t(ge,{className:`w-5 h-5 text-gray-600 dark:text-gray-300`})})}),t(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150`,children:s}),t(`div`,{className:`flex items-center justify-between px-4 sm:px-6 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50 rounded-b-xl`,children:n(`div`,{className:`flex flex-col`,children:[t(z.Title,{className:`text-base font-semibold text-gray-900 dark:text-gray-100`,children:a||c(`agent.dashboard`)}),o&&t(z.Description,{className:`text-sm text-gray-500 dark:text-gray-400 mt-0.5`,children:o})]})})]})]})})}function en(e,t){if(t===`chart`)return 280;let n=1;if(e.vconcat)n=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){let t=e.columns||2,r=Array.isArray(e.concat)?e.concat.length:1;n=Math.ceil(r/t)}else e.facet&&(n=2);return Math.max(500,n*280+40)}const tn={categorical:[`#6366f1`,`#8b5cf6`,`#ec4899`,`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#14b8a6`,`#06b6d4`,`#3b82f6`],blues:[`#dbeafe`,`#93c5fd`,`#3b82f6`,`#1d4ed8`,`#1e3a8a`],purples:[`#f3e8ff`,`#c4b5fd`,`#8b5cf6`,`#6d28d9`,`#4c1d95`],greens:[`#dcfce7`,`#86efac`,`#22c55e`,`#15803d`,`#14532d`],diverging:[`#ef4444`,`#fca5a5`,`#fef3c7`,`#86efac`,`#22c55e`]};function nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rn(e){return nn(e)}function an(e){let t=JSON.parse(JSON.stringify(e)),n=[`vconcat`,`hconcat`,`concat`];if(!n.some(e=>Array.isArray(t[e])))return t;let r=[];if(Array.isArray(t.params))for(let e of t.params)e&&typeof e==`object`&&e.name&&e.select&&r.push({name:e.name,param:e});if(r.length===0)return t;for(let{name:e,param:i}of r){let r=i.select?.fields||[],a=i.select?.bind===`legend`,o=null;for(let e of n)if(Array.isArray(t[e])){o=t[e];break}if(!o||o.length===0)continue;let s=0;for(let e=0;e<o.length;e++){let t=o[e];if(sn(t,r)||a&&cn(t,r)){s=e;break}}let c=o[s];c.params||=[],c.params.push(i),t.params=(t.params??[]).filter(t=>t.name!==e)}return Array.isArray(t.params)&&t.params.length===0&&delete t.params,t}function on(e,t){if(!t||Object.keys(t).length===0)return e;let n=JSON.parse(JSON.stringify(e)),r=e=>{for(let n of e)n.name&&n.name in t&&(n.value=t[n.name])};Array.isArray(n.params)&&r(n.params);let i=e=>{if(Array.isArray(e)){for(let t of e)if(Array.isArray(t.params)&&r(t.params),t.vconcat&&i(t.vconcat),t.hconcat&&i(t.hconcat),t.concat&&i(t.concat),Array.isArray(t.layer))for(let e of t.layer)Array.isArray(e.params)&&r(e.params)}};if(n.vconcat&&i(n.vconcat),n.hconcat&&i(n.hconcat),n.concat&&i(n.concat),Array.isArray(n.layer))for(let e of n.layer)e&&Array.isArray(e.params)&&r(e.params);return n}function sn(e,t){if(!e?.encoding)return!1;for(let n of t)for(let t of Object.values(e.encoding))if(t.field===n)return!0;if(Array.isArray(e.layer)){for(let n of e.layer)if(sn(n,t))return!0}return!1}function cn(e,t){if(!e)return!1;let n=e=>{if(!e)return!1;let n=e.color?.field;return!!n&&t.includes(n)};if(n(e.encoding))return!0;if(Array.isArray(e.layer)){for(let t of e.layer)if(n(t.encoding))return!0}return!1}function ln(e,t=[]){let n=[];if(!e||typeof e!=`object`)return n;if(e.data&&typeof e.data==`object`){let r=e.data.url;typeof r==`string`&&r.startsWith(`artifact:`)&&n.push({path:[...t,`data`],artifactPath:r.replace(/^artifact:/,``).trim()})}for(let r of[`layer`,`vconcat`,`hconcat`,`concat`,`spec`,`repeat`,`facet`])if(r in e){let i=e[r];Array.isArray(i)?i.forEach((e,i)=>{rn(e)&&n.push(...ln(e,[...t,r,String(i)]))}):rn(i)&&n.push(...ln(i,[...t,r]))}return n}function un(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of t){let t=e.split(`.`),i=n;for(let e=0;e<t.length-1;e++){let n=i[t[e]];if(!nn(n))break;i=n}let a=t[t.length-1],o=i[a];nn(o)&&(delete o.url,o.values=r)}return n}function dn(e){let t={background:`transparent`,view:{stroke:`transparent`},range:{category:tn.categorical,diverging:tn.diverging,heatmap:tn.purples,ramp:tn.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:`round`},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80}};return e?{...t,axis:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,gridColor:`#3f3f46`,domainColor:`#52525b`,tickColor:`#52525b`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#fafafa`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}:{...t,axis:{labelColor:`#71717a`,titleColor:`#3f3f46`,gridColor:`#e4e4e7`,domainColor:`#d4d4d8`,tickColor:`#d4d4d8`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#71717a`,titleColor:`#3f3f46`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#18181b`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}}const K=j(function({spec:i,artifactRunId:a}){let{t:o}=R(),{title:s,description:c,options:l}=i,u=i.spec,[d,f]=L(!1),[p,m]=L(!1),[h,g]=L(null),[_,v]=L(!1),y=I(null),b=I(null),x=I(null),{client:S}=Ee(),C=Jt(),w=I(S);w.current=S;let te=I(C);te.current=C;let[T,E]=L(null),[ie,ae]=L(!1),[oe,se]=L(null),ce=l?.mode||`chart`,D=ce===`dashboard`,fe=l?.enableFullscreen??D,O=l?.height||en(u,ce);P(()=>{let e=ln(u);if(e.length===0){E(u),ae(!1),se(null);return}a?console.info(`[VegaLiteChart] resolving artifacts with runId:`,a,e.map(e=>e.artifactPath)):console.warn(`[VegaLiteChart] artifact references found but artifactRunId is missing!`,{references:e.map(e=>e.artifactPath),artifactRunId:a});let t=!1;return ae(!0),se(null),(async()=>{let n=new Map,r=w.current,i=te.current;for(let o of e)try{let e=o.path.join(`.`),t;if(a&&!Yt(o.artifactPath)){let e=Xt(a,o.artifactPath,`inline`);t=i?await i.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(a,o.artifactPath,`inline`)).url):(await r.files.getArtifactDownloadUrl(a,o.artifactPath,`inline`)).url}else{let e=Zt(o.artifactPath);t=i?await i.getOrFetch(e,async()=>(await r.files.getDownloadUrl(o.artifactPath)).url):(await r.files.getDownloadUrl(o.artifactPath)).url}let s=await fetch(t);if(!s.ok)throw Error(`Failed to fetch artifact data: ${s.statusText}`);let c=o.artifactPath.toLowerCase().endsWith(`.csv`),l;if(c){let e=await s.text();l=De.parse(e,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{let e=await s.json();l=Array.isArray(e)?e:[e]}n.set(e,l)}catch(e){console.error(`Failed to resolve artifact: ${o.artifactPath}`,e),t||se(`Failed to load data from artifact: ${o.artifactPath}`);return}t||(E(un(u,n)),ae(!1))})(),()=>{t=!0}},[u,a]);let[pe,me]=L(!1),he=I(!1);P(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`);e!==he.current&&(he.current=e,me(e))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let[ge,_e]=L(0),k=I(0);P(()=>{if(!x.current)return;let e,t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{let e=t[0]?.contentRect.width;e&&e!==k.current&&(k.current=e,_e(e))},100)});t.observe(x.current);let n=x.current.clientWidth;return k.current=n,_e(n),()=>{clearTimeout(e),t.disconnect()}},[]);let A=F(()=>ln(u).length>0,[u]),j=F(()=>{if(A&&!T)return null;let e=T||u;return e?(l?.parameterValues&&(e=on(e,l.parameterValues)),an(e)):null},[T,u,A,l?.parameterValues]),N=M((e,t)=>{if(!e||typeof e!=`object`)return e;if(e.hconcat&&Array.isArray(e.hconcat)){let n=e.hconcat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,hconcat:e.hconcat.map(e=>N(e,i))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>N(e,t))};if(e.concat&&Array.isArray(e.concat)){let n=e.columns??e.concat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,concat:e.concat.map(e=>N(e,i))}}let n=e.width;return n===`container`||typeof n==`number`&&n>t?{...e,width:t}:e},[]),ve=M((e,t=!1)=>{if(!j)return null;let n=dn(pe),r=t?typeof window<`u`?Math.min(window.innerWidth-80,1400):1200:ge>0?ge-24:500,i=`vconcat`in j||`hconcat`in j||`concat`in j,a=i?{type:`pad`,contains:`padding`}:{type:`fit`,contains:`padding`},o=j;i&&r&&(o=N(j,r));let c=o.width,l=i?void 0:c===`container`?r:c??r,{width:u,...d}=o;return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,...!i&&l?{width:l}:{},height:t?void 0:e,autosize:a,...i?o:d,...s&&!j.title?{title:s}:{},config:{...n,...j.config}}},[j,s,pe,ge,N]),ye=M(async()=>{let e=_?b.current:y.current;if(!(!e||p))try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),m(!0),setTimeout(()=>m(!1),2e3))},`image/png`)}catch(e){console.error(`Failed to copy chart:`,e)}},[p,_]),be=M(async()=>{let e=_?b.current:y.current;if(!(!e||d)){f(!0);try{let t=await e.toImageURL(`png`,2),n=document.createElement(`a`);n.download=`${s||`chart`}.png`,n.href=t,n.click()}catch(e){console.error(`Failed to export chart:`,e)}finally{f(!1)}}},[s,d,_]),xe=M(e=>{y.current=e,g(null)},[]),Se=M(e=>{b.current=e},[]),Ce=M(e=>{console.error(`Vega-Lite rendering error:`,e),g(e instanceof Error?e.message:`Unknown error`)},[]),we=M(()=>{v(e=>!e)},[]);P(()=>{g(null)},[u]);let Te=({className:e})=>n(`div`,{className:Kt(`flex items-center gap-2`,e),children:[n(r,{variant:`unstyled`,onClick:ye,disabled:p,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1`,title:o(`agent.copyToClipboard`),children:[t(p?ee:ne,{className:`w-3 h-3`}),o(p?`agent.copied`:`agent.copy`)]}),n(r,{variant:`unstyled`,onClick:be,disabled:d,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1`,title:o(`agent.exportAsPng`),children:[t(re,{className:`w-3 h-3`}),o(d?`agent.exporting`:`agent.export`)]}),fe&&n(r,{variant:`unstyled`,onClick:we,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors flex items-center gap-1`,title:o(_?`agent.exitFullscreen`:`agent.fullscreen`),children:[t(_?de:ue,{className:`w-3 h-3`}),o(_?`agent.exit`:`agent.fullscreen`)]})]});if(ie||A&&!T)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{className:`flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded`,style:{width:`100%`,height:O},children:n(`div`,{className:`flex items-center gap-2 text-gray-500 dark:text-gray-400`,children:[t(le,{className:`w-5 h-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading data from artifacts...`})]})})]})});if(oe)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:O},children:t(Qt,{error:oe,chartTitle:s})})]})});if(h)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:O},children:t(Qt,{error:h,chartTitle:s})})]})});let z=ve(O),ke=ve(0,!0);return z?(typeof window<`u`&&localStorage.getItem(`DEBUG_VEGA_RENDERS`)&&console.log(`VegaLite rendering with spec:`,{title:s,hasData:!!z.data?.values,dataLength:z.data?.values?.length}),n(e,{children:[t(`div`,{className:Kt(`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,D&&`border-2`),children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||(D?`Dashboard`:`Chart`)}),D&&t(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-indigo-100 dark:bg-indigo-900 text-indigo-700 dark:text-indigo-300`,children:`Interactive`})]}),t(Te,{})]}),c&&t(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c}),t(`div`,{ref:x,className:`bg-white dark:bg-gray-900 rounded overflow-hidden`,style:{width:`100%`,height:O,minWidth:0},children:t(Oe,{spec:z,onEmbed:e=>xe(e.view),onError:Ce,options:{renderer:l?.renderer||`canvas`,actions:!1}})})]})}),n($t,{isOpen:_,onClose:()=>v(!1),title:s||(D?`Dashboard`:`Chart`),description:c,children:[t(`div`,{className:`w-full h-full min-h-[calc(100vh-200px)]`,children:ke&&t(Oe,{spec:ke,onEmbed:e=>Se(e.view),onError:Ce,options:{renderer:l?.renderer||`canvas`,actions:!1}})}),t(`div`,{className:`absolute bottom-6 end-6`,children:t(Te,{className:`bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2 border border-gray-200 dark:border-gray-700`})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId),fn=k.createContext({});function pn({children:e,artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}){let o=F(()=>({artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}),[n,r,i,a]);return t(fn.Provider,{value:o,children:e})}function q(){return k.useContext(fn)}const mn={chart:{icon:C,label:`chart`,defaultHeight:200},mermaid:{icon:ae,label:`diagram`,defaultHeight:150},proposal:{icon:D,label:`options`,defaultHeight:100},code:{icon:E,label:`code`,defaultHeight:80},image:{icon:oe,label:`image`,defaultHeight:150},link:{icon:ce,label:`link`,defaultHeight:24},expand:{icon:re,label:`content`,defaultHeight:100},table:{icon:pe,label:`table`,defaultHeight:150},markdown:{icon:ie,label:`content`,defaultHeight:100},"fusion-fragment":{icon:E,label:`fragment`,defaultHeight:150}};function J({type:e,error:i,onRetry:a,message:o,height:s}){let c=mn[e],l=s??c.defaultHeight,u=e===`link`;if(i)return n(`div`,{className:`flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive ${u?`inline-flex px-2 py-1 text-sm`:`p-4`}`,style:u?void 0:{minHeight:l},children:[n(`span`,{className:`text-destructive`,children:[`Failed to load `,c.label]}),a&&t(r,{variant:`unstyled`,onClick:a,className:`ms-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors text-destructive`,children:`Retry`})]});let d=c.icon;return u?n(`span`,{className:`inline-flex items-center gap-1 text-muted animate-pulse`,children:[t(d,{className:`h-3 w-3`}),t(`span`,{children:o||`Loading ${c.label}...`})]}):n(`div`,{className:`flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse`,style:{minHeight:l},children:[t(d,{className:`h-8 w-8 text-muted`}),t(`span`,{className:`text-sm text-muted`,children:o||`Loading ${c.label}...`}),t(`div`,{className:`flex gap-1`,children:[...[,,,]].map((e,n)=>t(`div`,{className:`h-2 w-2 rounded-full bg-muted animate-bounce`,style:{animationDelay:`${n*150}ms`}},`dot-${n}`))})]})}var Y=class extends k.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`CodeBlock rendering error (${this.props.type}):`,e,t),this.props.onError?.(e)}handleRetry=()=>{this.setState({hasError:!1,error:void 0})};render(){if(this.state.hasError){let{type:e,fallbackCode:r}=this.props;return n(`div`,{className:`space-y-2`,children:[t(J,{type:e,error:this.state.error?.message||`Rendering failed`,onRetry:this.handleRetry}),r&&n(`details`,{className:`text-sm`,children:[t(`summary`,{className:`cursor-pointer text-muted hover:text-foreground`,children:`Show raw content`}),t(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs`,children:t(`code`,{children:r})})]})]})}return this.props.children}};function hn(e,t,n){let r=t.split(`.`).pop()?.toLowerCase();if(r===`svg`)return`mockup`;if([`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(r||``))return`image`;if(r===`md`)return`markdown`;if(r===`csv`)return`table`;if(n===`json`&&typeof e==`object`&&e){let t=e;if(typeof t.$schema==`string`&&t.$schema.includes(`vega`)||t.library===`vega-lite`&&`spec`in t)return`vega-lite`;if(`template`in t&&`data`in t)return`fusion-fragment`;if(Array.isArray(e)&&e.length>0&&typeof e[0]==`object`)return`table`}return`code`}function gn(e){if(typeof e!=`object`||!e)return null;let t=e;return t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`&&t.spec!==null?t:typeof t.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}function _n({content:e}){let{headers:r,rows:i}=F(()=>{if(!Array.isArray(e)||e.length===0)return{headers:[],rows:[]};let t=e[0];if(typeof t!=`object`||!t)return{headers:[],rows:[]};let n=Object.keys(t);return{headers:n,rows:e.map(e=>n.map(t=>{let n=e[t];return n==null?``:typeof n==`object`?JSON.stringify(n):String(n)}))}},[e]);return r.length===0?t(J,{type:`table`,error:`No table data found`}):n(`div`,{className:`overflow-x-auto`,children:[n(`table`,{className:`min-w-full text-sm border-collapse`,children:[t(`thead`,{children:t(`tr`,{className:`border-b`,children:r.map(e=>t(`th`,{className:`px-3 py-2 text-start font-medium text-muted`,children:e},e))})}),t(`tbody`,{children:i.slice(0,100).map((e,n)=>t(`tr`,{className:`border-b border-muted/20`,children:e.map((e,n)=>t(`td`,{className:`px-3 py-2`,children:e},`cell-${n}`))},`row-${n}`))})]}),i.length>100&&n(`div`,{className:`text-sm text-muted py-2`,children:[`Showing 100 of `,i.length,` rows`]})]})}function vn({content:e,path:n}){let r=n.split(`.`).pop()?.toLowerCase()||``,i=typeof e==`string`?e:JSON.stringify(e,null,2);return t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{className:`language-${r}`,children:i})})}function yn(e){return Te.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`use`],FORBID_TAGS:[`foreignObject`]})}function bn(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let n=t;if(!/viewBox/i.test(n)){let e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n);e&&t&&(n+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return n=n.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``).replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``),/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}function xn({content:e}){let n=F(()=>{let t=typeof e==`string`?e.trim():``;return t?bn(yn(t)):null},[e]);return n?t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}}):t(J,{type:`expand`,error:`Empty mockup`})}function Sn({content:e,path:n}){return t(`img`,{src:typeof e==`string`?e:``,alt:n.split(`/`).pop()||`Artifact image`,className:`max-w-full h-auto rounded`,loading:`lazy`})}function Cn({content:e,renderType:n,path:r,runId:i,contentType:a}){let{MarkdownRenderer:o}=q();switch(F(()=>n===`auto`?hn(e,r,a):n,[e,r,a,n])){case`chart`:{let n=gn(e);return n?t(Y,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(K,{spec:n,artifactRunId:i})}):t(J,{type:`chart`,error:`Only Vega-Lite charts are supported. Recharts rendering has been retired.`})}case`vega-lite`:{let n=gn(e);return n?t(Y,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(K,{spec:n,artifactRunId:i})}):t(J,{type:`chart`,error:`Invalid Vega-Lite specification`})}case`fusion-fragment`:{let n=e;return console.log(`[ArtifactContentRenderer] fusion-fragment:`,{hasTemplate:!!n.template,hasData:!!n.data,runId:i,hasVegaLiteChart:!!K}),n.template&&n.data?t(Y,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(we,{data:n.data,ChartComponent:K,artifactRunId:i,children:t(Ce,{code:JSON.stringify(n.template),data:n.data})})}):t(Y,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(Ce,{code:JSON.stringify(e)})})}case`table`:return t(Y,{type:`table`,fallbackCode:JSON.stringify(e,null,2),children:t(_n,{content:e})});case`markdown`:{let n=typeof e==`string`?e:String(e);return t(Y,{type:`markdown`,fallbackCode:n,children:o?t(o,{artifactRunId:i,children:n}):t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{children:n})})})}case`mockup`:return t(Y,{type:`expand`,fallbackCode:typeof e==`string`?e:r,children:t(xn,{content:e})});case`image`:return t(Y,{type:`image`,fallbackCode:r,children:t(Sn,{content:e,path:r})});default:return t(vn,{content:e,path:r})}}var wn=class{components={};registerComponent(e,t){this.components[e]=t}getComponent(e){return this.components[e]}};const Tn=A(null);function En({components:e,children:n}){let r=F(()=>{let t=new wn;for(let[n,r]of Object.entries(e))t.registerComponent(n,r);return t},[e]);return t(Tn.Provider,{value:r,children:n})}function Dn(){return N(Tn)}function On(e){let t=N(Tn);if(t)return t.getComponent(e)}const kn=`Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function An(e){let t=e.trim(),n=``,r=!1,i=!1;for(let e=0;e<t.length;e++){let a=t[e],o=e>0?t[e-1]:``;if(a===`"`&&!i&&o!==`\\`){r=!r,n+=a;continue}if(a===`'`&&!r&&o!==`\\`){i=!i,n+=a;continue}if((r||i)&&a===`\\`){let r=e;for(;t[r]===`\\`;)r++;if(t[r]===`n`){n+=`<br/>`,e=r;continue}}n+=a}return n}function jn(e){return e.replace(/<svg([^<>]*)>/i,(e,t)=>{let n=t.replace(/\swidth="[^"]*"/i,``).replace(/\sheight="[^"]*"/i,``);return/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}Ae.initialize({startOnLoad:!1,theme:`default`,securityLevel:`loose`,fontFamily:kn,suppressErrorRendering:!0,flowchart:{htmlLabels:!0,useMaxWidth:!0,nodeSpacing:40,rankSpacing:50,padding:12},sequence:{useMaxWidth:!0},themeVariables:{fontFamily:kn}});function Mn({code:e,className:n}){let r=I(null),[i,a]=L(null),[o,s]=L(null),c=ve().replace(/:/g,`_`);return P(()=>{let t=!1;return(async()=>{if(!e.trim()){a(null),s(null);return}try{s(null);let n=`mermaid-${c}-${Date.now()}`,r=An(e),{svg:i}=await Ae.render(n,r),o=jn(i);t||a(o)}catch(e){t||(s(e instanceof Error?e.message:`Failed to render mermaid diagram`),a(null))}})(),()=>{t=!0}},[e,c]),o?null:i?t(`div`,{ref:r,className:`my-4 w-full overflow-x-auto [&_svg]:mx-auto [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-w-full ${n||``}`,dangerouslySetInnerHTML:{__html:i}}):t(`div`,{className:`my-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg animate-pulse ${n||``}`,children:t(`div`,{className:`h-32 bg-gray-200 dark:bg-gray-700 rounded`})})}function Nn(e){switch(e.split(`.`).pop()?.toLowerCase()){case`json`:return`json`;case`md`:case`txt`:case`csv`:case`yaml`:case`yml`:return`text`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`webp`:case`pdf`:return`binary`;default:return`text`}}function Pn({runId:e,path:t,parseJson:n=!0}){let{client:r}=Ee(),i=Jt(),a=I(r);a.current=r;let o=I(i);o.current=i;let[s,c]=L({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l=M(async()=>{if(!e){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No run ID provided`,contentType:void 0});return}if(!t){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No artifact path provided`,contentType:void 0});return}c(e=>({...e,isLoading:!0,error:void 0}));let r=a.current,i=o.current,s=Nn(t);try{let a=Xt(e,t,`inline`),o;o=i?await i.getOrFetch(a,async()=>(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url):(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url;let l=await fetch(o);if(!l.ok)throw Error(`Failed to fetch artifact: ${l.status} ${l.statusText}`);if(s===`binary`){c({data:o,rawContent:void 0,isLoading:!1,error:void 0,contentType:s});return}let u=await l.text(),d;if(n&&s===`json`)try{d=JSON.parse(u)}catch{d=u}else d=u;c({data:d,rawContent:u,isLoading:!1,error:void 0,contentType:s})}catch(e){let n=e instanceof Error?e.message:`Failed to fetch artifact`;console.error(`Failed to fetch artifact content:`,t,e),c({data:void 0,rawContent:void 0,isLoading:!1,error:n,contentType:s})}},[e,t,n]);P(()=>{l()},[l]);let u=M(()=>{c({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l()},[l]);return{data:s.data,rawContent:s.rawContent,isLoading:s.isLoading,error:s.error,contentType:s.contentType,retry:u}}function Fn(e){let t=e.trim();if(t.length<2)return!0;if(!t.startsWith(`{`))return!1;try{return JSON.parse(t),!1}catch(e){let n=e instanceof Error?e.message:``,r=[`unexpected end`,`unterminated string`,`expected`,`unexpected token`],i=n.toLowerCase();if(r.some(e=>i.includes(e))){let e=0,n=0,r=!1,i=!1;for(let a of t){if(i){i=!1;continue}if(a===`\\`){i=!0;continue}if(a===`"`){r=!r;continue}r||(a===`{`?e++:a===`}`?e--:a===`[`?n++:a===`]`&&n--)}return e>0||n>0||r}return!1}}function In(e){try{let t=e.trim(),n=t.indexOf(`{`),r=t.lastIndexOf(`}`);return n!==-1&&r>n&&(t=t.slice(n,r+1)),JSON.parse(t)}catch{return null}}function Ln(e){let t=typeof e.$schema==`string`&&e.$schema.includes(`vega`),n=e.library===`vega-lite`&&`spec`in e;return t||n?`vega-lite`:null}function Rn({code:e}){let{artifactRunId:n}=q();n||console.warn(`[VegaLiteCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=F(()=>Fn(e),[e]),i=F(()=>{if(r)return null;let t=In(e);return t?{library:`vega-lite`,spec:t}:null},[e,r]);return r?t(J,{type:`chart`,message:`Loading chart...`}):i?t(Y,{type:`chart`,fallbackCode:e,children:t(K,{spec:i,artifactRunId:n})}):t(J,{type:`chart`,error:`Invalid Vega-Lite specification`})}function zn({code:e}){let{artifactRunId:n}=q();n||console.warn(`[ChartCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=F(()=>Fn(e),[e]),i=F(()=>{if(r)return null;let t=In(e);return!t||!Ln(t)?null:t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`?t:{library:`vega-lite`,spec:t}},[e,r]);return r?t(J,{type:`chart`,message:`Loading chart...`}):i?t(Y,{type:`chart`,fallbackCode:e,children:t(K,{spec:i,artifactRunId:n})}):t(J,{type:`chart`,error:`Invalid Vega-Lite chart specification`})}function Bn({code:e}){let n=e.trim();return n?t(Y,{type:`mermaid`,fallbackCode:e,children:t(Mn,{code:n})}):t(J,{type:`mermaid`,error:`Empty diagram`})}function Vn({code:e}){let n=F(()=>{let t=e.trim();return t?bn(yn(t)):null},[e]);return n?t(Y,{type:`code`,fallbackCode:e,children:t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}})}):t(J,{type:`code`,error:`Empty mockup`})}function Hn({code:e,language:n}){let{artifactRunId:r}=q(),i=e.trim(),a=F(()=>{if(!n?.includes(`:`))return`auto`;let e=n.split(`:`)[1];return[`chart`,`vega-lite`,`table`,`markdown`,`fusion-fragment`,`mockup`,`code`,`image`,`auto`].includes(e)?e:`auto`},[n]),{data:o,isLoading:s,error:c,contentType:l}=Pn({runId:r,path:i});return r?s?t(J,{type:`expand`,message:`Loading ${i}...`}):c?t(J,{type:`expand`,error:`Failed to load artifact: ${c}`}):o===void 0?t(J,{type:`expand`,error:`No content found in artifact`}):t(Cn,{content:o,renderType:a,path:i,runId:r,contentType:l}):t(J,{type:`expand`,error:`No artifact run ID available`})}function Un(e){return e?.startsWith(`expand`)??!1}function Wn(){return{chart:zn,"vega-lite":Rn,vegalite:Rn,mermaid:Bn,mockup:Vn,svg:Vn}}function Gn(e){return e.trim().replace(/^\/+/,``)}function X(e){return e.startsWith(`artifact:`)?{scheme:`artifact`,path:e.slice(9).trim()}:e.startsWith(`image:`)?{scheme:`image`,path:e.slice(6).trim()}:e.startsWith(`store:`)?{scheme:`store`,path:Gn(e.slice(6))}:e.startsWith(`document:`)?{scheme:`document`,path:Gn(e.slice(9))}:e.startsWith(`collection:`)?{scheme:`collection`,path:Gn(e.slice(11))}:{scheme:`standard`,path:e}}function Kn(e,t){switch(e){case`store`:return t?`/store/objects/${t}`:null;case`document`:return t?`/store/objects/${t}`:null;case`collection`:return t?`/store/collections/${t}`:null;default:return null}}function qn({rawUrl:e,artifactRunId:t,disposition:n=`inline`}){let{client:r}=Ee(),i=Jt(),a=I(r);a.current=r;let o=I(i);o.current=i;let{scheme:s,path:c}=X(e),l=Kn(s,c),[u,d]=L(()=>{if(l)return{url:l,isLoading:!1,error:void 0};if(s===`standard`)return{url:e,isLoading:!1,error:void 0};if(i&&(s===`artifact`||s===`image`)){let e;e=s===`artifact`&&t&&!Yt(c)?Xt(t,c,n):Zt(c);let r=i.getUrl(e);if(r)return{url:r,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),f=M(async()=>{if(l||s===`standard`)return;if(s!==`artifact`&&s!==`image`){d({url:void 0,isLoading:!1,error:`Unknown scheme: ${s}`});return}d(e=>({...e,isLoading:!0,error:void 0}));let e=a.current,r=o.current;try{let i;if(s===`artifact`)if(t&&!Yt(c)){let a=Xt(t,c,n);i=r?await r.getOrFetch(a,async()=>(await e.files.getArtifactDownloadUrl(t,c,n)).url):(await e.files.getArtifactDownloadUrl(t,c,n)).url}else{let t=Zt(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}else{let t=Zt(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}d({url:i,isLoading:!1,error:void 0})}catch(e){let t=e instanceof Error?e.message:`Failed to resolve URL`;console.error(`Failed to resolve URL:`,c,e),d({url:void 0,isLoading:!1,error:t})}},[s,c,t,n,l]);P(()=>{if(u.url&&!u.error)return;let e=!1;return e||(async()=>{await f()})(),()=>{e=!0}},[f,u.url,u.error]);let p=M(()=>{d({url:void 0,isLoading:!0,error:void 0}),f()},[f]);return{url:u.url,isLoading:u.isLoading,error:u.error,scheme:s,retry:p}}function Jn({src:e,alt:r,caption:i,className:a,artifactRunId:o}){let s=e||``,{scheme:c}=X(s);return c===`standard`?n(`figure`,{className:`my-4`,children:[t(`img`,{src:e,alt:r,className:a}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):t(Yn,{rawSrc:s,alt:r,caption:i,artifactRunId:o,className:a})}function Yn({rawSrc:e,alt:r,caption:i,artifactRunId:a,className:o}){let{url:s,isLoading:c,error:l,retry:u}=qn({rawUrl:e,artifactRunId:a,disposition:`inline`});return c?t(J,{type:`image`,message:r?`Loading ${r}...`:void 0}):l?t(J,{type:`image`,error:l,onRetry:u}):s?n(`figure`,{className:`my-4`,children:[t(`img`,{src:s,alt:r,className:o}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):null}function Xn({node:e,src:n,alt:r,className:i,artifactRunId:a,ExistingImg:o,...s}){let c=n||``,{scheme:l}=X(c);return l===`standard`?typeof o==`function`?t(o,{node:e,src:n,alt:r,...s}):t(`img`,{src:n,alt:r,className:i,...s}):t(Zn,{rawSrc:c,alt:r,artifactRunId:a,className:i,rest:s})}function Zn({rawSrc:e,alt:n,artifactRunId:r,className:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=qn({rawUrl:e,artifactRunId:r,disposition:`inline`});return s?t(J,{type:`image`,message:n?`Loading ${n}...`:void 0}):c?t(J,{type:`image`,error:c,onRetry:l}):o?t(`img`,{src:o,alt:n,className:i,...a}):null}function Qn({node:e,href:n,children:r,className:i,artifactRunId:a,ExistingLink:o,...s}){let c=n||``,{scheme:l,path:u}=X(c),d=Kn(l,u);return d?typeof o==`function`?t(o,{node:e,href:d,...s,children:r}):t(`a`,{href:d,...s,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):l===`standard`?typeof o==`function`?t(o,{node:e,href:n,...s,children:r}):t(`a`,{href:n,...s,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):t($n,{rawHref:c,artifactRunId:a,className:i,rest:s,children:r})}function $n({rawHref:e,artifactRunId:n,className:r,children:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=qn({rawUrl:e,artifactRunId:n,disposition:`attachment`});return s?t(`span`,{className:`inline-flex items-center gap-1 text-muted`,children:t(J,{type:`link`})}):c?t(`span`,{className:`inline-flex items-center gap-1`,children:t(J,{type:`link`,error:c,onRetry:l})}):t(`a`,{href:o||`#`,...a,className:r,target:`_blank`,rel:`noopener noreferrer`,children:i})}const er=[`artifact:`,`image:`,`store:`,`document://`,`collection:`],tr=/(!?\[[^[\]\n]*\]\()((?:artifact:|image:|store:|document:\/\/|collection:)[^)[\n]+)(\))/g,nr=/`[^`\n]*`/g,rr=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,ir=/\s+("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\([^)]*\))\s*$/;function ar(e){return er.some(t=>e.startsWith(t))}function or(e){let t=e.trim();if(t.startsWith(`<`)){let n=t.indexOf(`>`);if(n>0&&ar(t.slice(1,n).trim()))return e}let n=t.match(ir)?.index??-1,r=(n>=0?t.slice(0,n):t).trim(),i=n>=0?t.slice(n):``;return ar(r)?`<${r}>${i}`:e}function sr(e){return e.replace(tr,(e,t,n,r)=>`${t}${or(n)}${r}`)}function cr(e){let t=``,n=0;for(let r of e.matchAll(nr))t+=sr(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=sr(e.slice(n)),t}function lr(e){if(!e||!er.some(t=>e.includes(t)))return e;let t=``,n=0;for(let r of e.matchAll(rr))t+=cr(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=cr(e.slice(n)),t}const ur=/^([ \t]*):::([^\n]*?):::[ \t]*$/gm,dr=/^\w+/;function fr(e){return e?.includes(`:::`)?e.replace(ur,(e,t,n)=>{let r=n.trim(),i=dr.exec(r);if(!i)return e;let a=i[0],o=r.slice(a.length).trim();return o?`${t}:::${a}\n${t}${o}\n${t}:::`:`${t}::${a}`}):e}const pr=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,mr=/`[^`\n]*`/g,hr=/\\\$/g,gr=/\\[^\s]/,_r=/[{}]/,vr=/[_^][\w{]/,yr=/^[a-zA-Z]$/,br=/^[a-zA-Z]\s*=/,xr=/^\s/,Sr=/\s$/,Cr=/[+*/-]$/,wr=/\^[+-]$/;function Tr(e){return gr.test(e)||_r.test(e)||vr.test(e)||yr.test(e)||br.test(e)}function Er(e){return!!(xr.test(e)||Sr.test(e)||Cr.test(e)&&!wr.test(e))}function Dr(e){let t=[];for(let n=0;n<e.length;n++)if(e[n]===`$`&&!(n>0&&e[n-1]===`\\`)){if(n+1<e.length&&e[n+1]===`$`){n++;continue}n>0&&e[n-1]===`$`&&(n<2||e[n-2]!==`\\`)||t.push(n)}return t}function Or(e,t,n){let r=e.slice(t+1,n);return r.length===0||r.includes(`
6
- `)?null:r}function kr(e){let t=Dr(e);if(t.length<2)return e;let n=new Set,r=new Set,i=Array(t.length-1);for(let n=0;n<t.length-1;n++)i[n]=Or(e,t[n],t[n+1]);let a=[];for(let e=0;e<t.length-1;e++){if(n.has(e))continue;let r=i[e];r!==null&&Tr(r)&&(n.add(e),n.add(e+1),a.push([t[e],t[e+1]]))}let o=0;for(;o<t.length;){if(n.has(o)){o++;continue}let e=o+1;for(;e<t.length&&n.has(e);)e++;if(e>=t.length)break;if(e>o+1){r.add(t[o]),o++;continue}let a=i[o];if(a===null){o++;continue}Er(a)&&(r.add(t[o]),r.add(t[e])),n.add(o),n.add(e),o=e+1}for(let e=0;e<t.length;e++)n.has(e)||e+1<t.length&&n.has(e+1)&&r.add(t[e]);if(r.size===0&&a.length===0)return e;let s=[],c=0,l=Array.from(r).sort((e,t)=>e-t),u=0,d=0;for(;u<l.length||d<a.length;){let t=u<l.length?l[u]:1/0;if(t<(d<a.length?a[d][0]:1/0))t>c&&s.push(e.slice(c,t)),s.push(`\\$`),c=t+1,u++;else{let[t,n]=a[d];t>c&&s.push(e.slice(c,t));let r=e.slice(t,n+1);for(s.push(r.replace(hr,`\\text{\\textdollar}`)),c=n+1;u<l.length&&l[u]<=n;)u++;d++}}return c<e.length&&s.push(e.slice(c)),s.join(``)}function Ar(e){let t=[],n=0;for(let r of e.matchAll(mr))t.push(kr(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(kr(e.slice(n))),t.join(``)}function jr(e){if(!e?.includes(`$`))return e;let t=[],n=0;for(let r of e.matchAll(pr))t.push(Ar(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(Ar(e.slice(n))),t.join(``)}const Mr={note:`md-callout-info`,tip:`md-callout-info`,warning:`md-callout-attention`,important:`md-callout-attention`,caution:`md-callout-destructive`},Nr={note:`Note`,tip:`Tip`,warning:`Warning`,important:`Important`,caution:`Caution`};function Pr(){return e=>{He(e,e=>{if(e.type!==`containerDirective`&&e.type!==`leafDirective`&&e.type!==`textDirective`)return;let t=e;t.data||={};let n=t.data,r=t.attributes||{},i=t.name;if(i===`pagebreak`){n.hName=`hr`,n.hProperties={className:`md-pagebreak`};return}if(i===`columns`){n.hName=`div`,n.hProperties={className:`md-columns`};return}if(i===`column`){n.hName=`div`;let e={className:`md-column`};r.width&&(e.style=`flex-basis:${r.width};flex-grow:0;flex-shrink:0`),n.hProperties=e;return}if(i in Mr){n.hName=`div`,n.hProperties={className:`md-callout ${Mr[i]}`,"data-callout-type":i};let e=Nr[i];if(e&&t.children){let n={type:`paragraph`,data:{hName:`p`,hProperties:{className:`md-callout-title`}},children:[{type:`text`,value:e}]};t.children.unshift(n)}return}n.hName=`div`,n.hProperties={className:`md-${i}`,...Object.fromEntries(Object.entries(r).filter(([e])=>e!==`class`))},r.class&&(n.hProperties.className+=` ${r.class}`)})}}const Fr=[`artifact:`,`image:`,`store:`,`document:`,`document://`,`collection:`];function Ir(e){return Fr.some(t=>e.startsWith(t))?e:Me(e)}function Lr(){return e=>{He(e,`html`,(e,t,n)=>{let r=e,i=n;if(typeof r.value==`string`&&/<!--[\s\S]*?-->/.test(r.value)&&i?.children&&typeof t==`number`)return i.children.splice(t,1),[Ve,t]})}}const Rr=Wn();function zr({children:e,components:n,remarkPlugins:r=[],removeComments:i=!0,artifactRunId:a,className:o,codeClassName:s,inlineCodeClassName:c,linkClassName:l,imageClassName:u,onProposalSelect:d,onProposalSubmit:f}){let p=Dn(),m=k.useMemo(()=>fr(lr(jr(e))),[e]),h=t(pn,{artifactRunId:a,onProposalSelect:d,onProposalSubmit:f,MarkdownRenderer:zr,children:t(je,{remarkPlugins:k.useMemo(()=>{let e=[Le,Ie,Pr,Re,Fe,Be,ze,...r];return i&&e.push(Lr),e},[r,i]),rehypePlugins:k.useMemo(()=>[Ne],[]),remarkRehypeOptions:k.useMemo(()=>({handlers:{...Pe}}),[]),components:k.useMemo(()=>{let e=n||{},r=e.code,i=e.a,o=e.img,d=({node:e,className:n,children:i,...a})=>{let o=/language-([\w-]+)/.exec(n||``),l=!o,u=o?o[1]:``;if(!l&&u){if(p){let e=p.getComponent(u);if(e)return t(e,{code:String(i||``).trim(),language:u})}if(Un(u))return t(Hn,{code:String(i||``).trim(),language:u});let e=Rr[u];if(e)return t(e,{code:String(i||``).trim(),language:u})}return typeof r==`function`?t(r,{node:e,className:n,...a,children:i}):t(`code`,{...a,className:l?`px-1.5 py-0.5 rounded ${c||``}`:` ${s||``}`,children:i})},f=e=>{let{node:n,href:r,children:o,...s}=e;return t(Qn,{node:n,href:r,className:l,artifactRunId:a,ExistingLink:typeof i==`function`?i:void 0,...s,children:o})},m=e=>{let{node:n,src:r,alt:i,title:s,...c}=e;return s?t(Jn,{src:r,alt:i,caption:s,className:u,artifactRunId:a}):t(Xn,{node:n,src:r,alt:i,className:u,artifactRunId:a,ExistingImg:typeof o==`function`?o:void 0,...c})};return{...e,code:d,a:f,img:m}},[n,a,p,s,c,l,u]),urlTransform:Ir,children:m})});return o?t(`div`,{className:`md-content ${o}`,children:h}):t(`div`,{className:`md-content`,children:h})}function Br({percent:e}){return t(`div`,{className:`w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700`,children:t(`div`,{className:`bg-blue-600 h-2.5 rounded-full`,style:{width:`${e}%`}})})}function Vr({className:e,properties:r}){return t(f,{className:e,children:t(`tbody`,{children:r.map(e=>n(`tr`,{children:[n(`td`,{className:`w-1/3 font-semibold gap-2`,children:[t(`span`,{children:e.name}),e.description&&t(p,{description:e.description,placement:`top`,children:t(se,{className:`size-3 ms-2 text-muted-foreground`})})]}),t(`td`,{className:`w-2/3`,children:e.value??`undefined`})]},e.name))})})}function Hr({content:e,...n}){let r=I(null);return P(()=>{if(!r.current)return;let t=new DOMParser().parseFromString(e,`image/svg+xml`).querySelector(`svg`);if(!t){console.warn(`SvgIcon: No <svg> element found in provided string`),r.current.innerHTML=``;return}Object.entries(n).forEach(([e,n])=>{if(n==null)return;let r=e===`className`?`class`:e;t.setAttribute(r,String(n))}),r.current.innerHTML=``,r.current.appendChild(t)}),t(`span`,{ref:r})}function Ur(e){return n=>t(Hr,{content:e,...n})}function Wr(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}var Z;(function(e){e.string=`string`,e.number=`number`,e.integer=`integer`,e.boolean=`boolean`,e.object=`object`,e.any=`any`,e.text=`text`,e.media=`media`,e.document=`document`})(Z||={});function Gr(e){e=e.trim();let t=!1,n=!1;e.endsWith(`?`)&&(n=!0,e=e.substring(0,e.length-1).trim()),e.endsWith(`[]`)&&(t=!0,e=e.substring(0,e.length-2).trim());let r=Z[e];if(!r)throw Error(`Unknown type "${e}"`);return{name:r,isArray:t,isNullable:n,isObject:r===Z.object}}function Kr(){let e=Object.values(Z),t=[...e];for(let n of e)t.push(`${n}[]`);return e.sort(),t}const qr=Kr();function Jr({value:e,onChange:i,onCancel:a,onSave:o}){let{t:s}=R(),[c,l]=L(!1);return e?n(`div`,{className:`flex items-center`,children:[t(`div`,{className:`flex-1`,children:t(Yr,{value:e.name,onChange:t=>{i({...e,name:t})},onCancel:a,onSave:o})}),t(`div`,{className:`px-1 font-semibold`,children:`:`}),t(`div`,{className:`flex-1`,children:t(Xr,{value:e.type,onChange:t=>{i({...e,type:t})},onCancel:a,onSave:o})}),n(`div`,{children:[t(r,{variant:`ghost`,size:`xs`,onClick:()=>l(!0),title:s(`widgets.schema.editDescription`),children:t(S,{className:`size-4`})}),t(Zr,{value:e.description,isOpen:c,onClose:t=>{t!==void 0&&typeof t==`string`&&i({...e,description:t},!0),l(!1)}})]})]}):null}function Yr({value:e,onChange:n,onCancel:r,onSave:i}){let a=I(null);return P(()=>{a.current?.focus()},[]),t(`input`,{onKeyUp:e=>{switch(e.key){case`Enter`:i?.();break;case`Escape`:r?.();break}},ref:a,value:e,onChange:e=>{n(e.target.value)},className:d.INPUT_UNSTYLED,style:{fontSize:`inherit`,width:``,display:`inline`}})}function Xr({value:e,onChange:n,onCancel:r,onSave:i}){return t(u,{className:d.INPUT_UNSTYLED,options:qr,value:e||``,onBlur:()=>{i?.()},onChange:n,onKeyDown:(e,t)=>{t||(e.key===`Enter`?i?.():e.key===`Escape`&&r?.())},popupClass:`schema-type-suggest-popup z-90`})}function Zr({value:e,isOpen:r,onClose:i}){let{t:a}=R();return n(o,{isOpen:r,onClose:i,children:[t(l,{children:a(`widgets.schema.editDescription`)}),t(Qr,{value:e,onSave:i})]})}function Qr({value:i,onSave:a}){let{t:o}=R(),l=I(null),[u,d]=L(i||``);return P(()=>{l.current?.focus()},[]),n(e,{children:[t(s,{className:`h-max`,children:t(`textarea`,{ref:l,className:`dark:bg-gray-800 w-full h-full dark:text-white`,value:u,onChange:e=>d(e.target.value)})}),t(c,{children:t(r,{onClick:()=>a(u),children:o(`store.saveChanges`)})})]})}function $r({value:e}){return e?n(`div`,{className:`w-full flex items-baseline`,children:[t(`div`,{children:e.name||``}),t(`div`,{className:`ms-2 text-sm text-muted`,children:e.type||``})]}):null}function ei(e,t,n){if(e.properties){let r=e.properties,i={};for(let e of Object.keys(r)){let a=r[e];e===t?i[n]=a:i[e]=a}e.properties=i}e.required&&=e.required.map(e=>e===t?n:e)}function ti(e,t,n){if(Array.isArray(e.required)){let r=e.required.indexOf(t);n?r<0&&e.required.push(t):r>-1&&e.required.splice(r,1)}else n&&(e.required=[t])}function ni(e,t){let n=t.name===`any`?void 0:t.isNullable?[t.name,`null`]:t.name;if(t.isArray)if(e.type=`array`,e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:n,properties:t.isObject?{}:void 0};else{let r=e.items;r.type=n,t.isObject&&!r.properties&&(r.properties={})}else e.type=n,e.items=void 0,t.isObject?e.properties||={}:e.properties=void 0}function ri(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter(e=>e!==t)))}function ii(e,t,n,r=!1){if(e.type!==`object`)throw Error(`Cannot add property to a non-object schema`);e.properties||={};let i={};return ni(i,n),e.properties[t]=i,r&&(Array.isArray(e.required)?ci(e.required,t):e.required=[t]),i}function ai(e){let t=!1,n=!1,r,i=e.type;if(Array.isArray(i))for(let e of i)e===`null`?t=!0:r||=e;else r=i;r||=`any`,r===`array`&&(n=!0,r=oi(e.items));let a=r;switch(e.editor){case`textarea`:a=`text`;break;case`media`:a=`media`;break;case`document`:a=`document`;break}return{isNullable:t,isArray:n,isObject:r===`object`,name:a}}function oi(e){if(!e)return`any`;let t;return t=si(Array.isArray(e)?e[0].type:e.type),(t===`array`||t===`null`)&&(t=`any`),t}function si(e){return e?Array.isArray(e)?e.find(e=>e!==`null`)||`any`:e:`any`}function ci(e,t){e.includes(t)||e.push(t)}let li=0;var ui=class e{source;onChange=()=>{};schema;root;constructor(e,t){e?typeof e==`string`?this.schema=JSON.parse(e):this.schema=e:this.schema={title:t,type:`object`,properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new di(``,this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||this.root.children.length===0}get children(){return this.root.children??[]}reload(){return this.root=new di(``,this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){e?this.schema=e:this.schema={title:this.schema.title,type:`object`,properties:{}},this.reload()}clone(){let t=new e(this.schema);return t.source=this.source,this.onChange&&t.withChangeListener(this.onChange),t}},di=class e{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,n,r){if(this.schema=t,this.loader=n,this.parent=r,this.name=e,this.type=ai(t),this.parent){let t=this.parent._getPropertiesSchema().required;this.isRequired=t&&Array.isArray(t)?t.includes(e):!1}}get title(){return typeof this.schema.title==`string`?this.schema.title:void 0}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){let e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?``:`?`}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?`[]`:``}${this.type.isNullable?`?`:``}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[];let e=this.schema.items?.properties;this.schema.items&&e?this._loadChildren(e,this.children):this.schema.properties&&this._loadChildren(this.schema.properties,this.children)}_loadChildren(t,n){for(let r of Object.keys(t)){let i=t[r],a=new e(r,i,this.loader,this);n.push(a),a.isParent&&a.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){let t=this._getPropertiesSchema().properties||{},n;do n=e+ ++li;while(t[n]);return n}addChild(t,n,r=!1){if(!this.type.isObject)throw Error(`Cannot add child to a non object node`);this.children||=[];let i=new e(t,ii(this._getPropertiesSchema(),t,n,r),this.loader,this);return this.children.push(i),i}remove(){return this.parent?.type.isObject?(ri(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter(e=>e.name!==this.name)),!0):!1}update(e){let t=!1;e.name!=null&&this.name!==e.name&&(this.parent&&ei(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),e.isRequired!=null&&this.isRequired!==e.isRequired&&(this.parent&&ti(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let n=e.type?.name;n===`any`&&(n=void 0);let r=n!==this.schema.type;return e.type&&(ni(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||=[]:this.children=void 0,t=!0),this.schema.editor&&e.editor===null?(this.schema.editor=void 0,t=!0):e.editor?(this.schema.editor=e.editor,t=!0):r&&(this.schema.editor=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let n=e.trim(),r=!0;n.endsWith(`?`)&&(n=n.substring(0,n.length-1).trim(),r=!1);let i=Gr(t),a;return i.name===`text`?(i.name=Z.string,a=`textarea`):i.name===`media`?(i.name=Z.any,a=`media`):i.name===`document`?(i.name=Z.any,a=`document`):a=null,{name:n,type:i,isRequired:r,editor:a}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){e=e.trim();let t=e.indexOf(`:`);if(t<0)throw Error(`Expecting a name and a type separated by a colon`);let n=e.substring(0,t),r=e.substring(t+1);return this.updateFromNameAndTypeSignature(n,r)}};function fi(e){let[t,n]=L(new ui(e||{type:`object`,properties:{}}).withChangeListener(e=>{n(e.clone())}));return t}const pi=`block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4`,mi=`${pi} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,hi=`${pi} shadow-xs ring-1 ring-inset ring-ring`;function gi({value:e,onChange:r,onDelete:i,outlineOnHover:a=!1,editOnClick:o=!0,placeholder:s,viewer:c,editor:l,skipClickOutside:u,isEditing:d=!1,readonly:f=!1,onValidate:p}){let{on:m,off:h,isOn:_}=g(d),[v,y]=L();return n(`div`,{className:``,children:[_&&!f?t(vi,{value:e,onSave:e=>{if(p){let t=p(e);if(t){y(t);return}else y(void 0)}r(e)&&h()},onCancel:h,editor:l,skipClickOutside:e=>u?u(e):!1}):t(_i,{value:e,onEdit:m,viewer:c,placeholder:s,outlineOnHover:a,editOnClick:o,onDelete:i,readonly:f}),v&&t(`div`,{className:`text-red-500 text-sm`,children:v})]})}function _i({viewer:e,value:i,onEdit:a,editOnClick:o,outlineOnHover:s,placeholder:c,onDelete:l,readonly:u}){let d=()=>{o&&a()},f=e=>{e.key===`Enter`&&a()},p=`invisible group-hover:visible`;return n(`div`,{role:o?`button`:void 0,tabIndex:0,onKeyUp:f,onClick:d,className:y(`flex justify-start items-center group`,s?mi:pi,{"cursor-pointer":o}),children:[t(e,{value:i,placeholder:c}),n(`div`,{className:`ms-auto flex gap-2`,children:[!u&&l&&t(r,{variant:`ghost`,size:`sm`,className:p,onClick:l,children:t(me,{className:`size-4`})}),u?null:t(r,{variant:`ghost`,size:`sm`,className:p,onClick:a,children:t(O,{className:`size-4`})})]})]})}function vi({editor:e,value:n,onSave:r,onCancel:i,skipClickOutside:a}){let[o,s]=L(n),c=I(n),[l,u]=L(null),d=()=>{r(c.current)};return t(`div`,{ref:h(d,a),children:t(`div`,{className:hi,children:t(`div`,{className:`w-full`,onClick:e=>e.stopPropagation(),children:t(e,{value:o,onChange:(e,t=!1)=>{s(e),c.current=e,t&&(l&&clearTimeout(l),u(setTimeout(()=>{r(e)},500)))},onSave:d,onCancel:i})})})})}function yi(e){return!!e.target.closest?.(`.schema-type-suggest-popup`)}function bi({schema:e,readonly:r=!1}){return n(`ul`,{className:``,children:[e.children.map(e=>xi(e,r)),r?null:t(Ei,{parent:e.root})]})}function xi(e,n){return e.isParent?t(Ci,{property:e,readonly:n},e.name):t(Si,{node:e,readonly:n},e.name)}function Si({node:e,readonly:n}){return t(`li`,{children:t(Ti,{property:e,readonly:n})})}function Ci({property:e,readonly:i}){let[a,o]=L(!0),s=a?te:T;return n(`li`,{children:[n(`div`,{className:`flex items-center w-full`,children:[t(r,{variant:`ghost`,size:`icon`,onClick:()=>o(!a),"aria-label":a?`Collapse ${e.name}`:`Expand ${e.name}`,"aria-expanded":a,children:t(s,{className:`size-4 cn-rtl-flip`})}),t(`div`,{className:`flex-1`,children:t(Ti,{property:e,readonly:i})})]}),a&&n(`ul`,{className:`ms-4 border-s border-gray-400 border-dashed`,children:[(e.children||[]).map(e=>xi(e,i)),i?null:t(Ei,{parent:e})]})]})}function wi(e){if(!e)return`Name is required`;if(!/^[a-zA-Z0-9_]+[?]?$/.test(e))return`Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)`}function Ti({property:e,readonly:n}){let{t:r}=R(),i=v(),a=t=>{try{t.description&&typeof t.description!=`string`&&(t.description=void 0);let n=e.getUpdateFromNameAndTypeSignature(t.name,t.type);e.update({...n,description:t.description})&&e.reloadTree()}catch(e){return i({status:`error`,title:r(`widgets.schema.invalidPropertyDeclaration`),description:m(e),duration:9e3}),!1}return!0},o=e.resetIsNew();return t(gi,{value:Wr(e),onChange:a,onDelete:()=>{e.remove(),e.reloadTree()},editor:Jr,viewer:$r,outlineOnHover:!0,isEditing:o,skipClickOutside:yi,readonly:n,onValidate:e=>wi(e.name)})}function Ei({parent:e}){return n(r,{variant:`ghost`,onClick:()=>{let t=e.findAvailableChildName(`new_property_`),n=e.addChild(t,{isObject:!1,isArray:!1,isNullable:!1,name:Z.string},!0);n.isNew=!0,e.reloadTree()},children:[t(fe,{className:`size-4`}),`Add property`]})}function Di(e){return e.isFile}function Oi(e){return e.isDirectory}function ki({onDrop:e,message:i,buttonLabel:a,allowFolders:o=!0,className:s=``}){let{t:c}=R(),l=a??c(`upload.uploadFiles`),[u,d]=L(!1),f=I(null),p=e=>{e.preventDefault(),e.dataTransfer.types.includes(`Files`)&&d(!0)},m=e=>{e.preventDefault(),f.current&&!f.current.contains(e.relatedTarget)&&d(!1)},h=async t=>{if(t.preventDefault(),d(!1),t.dataTransfer.items&&t.dataTransfer.items.length>0){let n=Array.from(t.dataTransfer.items),r=[],i=new Set,a=async e=>{if(Di(e)){let t=await new Promise(t=>{e.file(n=>{Object.defineProperty(n,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(n)})});!t.name.startsWith(`.`)&&t.size>0&&r.push(t);let n=e.fullPath.substring(1).split(`/`).slice(0,-1).join(`/`);n&&i.add(n)}else if(Oi(e)){let t=e.createReader(),n=await new Promise(e=>{t.readEntries(t=>{e(t)})});await Promise.all(n.map(a));let r=e.fullPath.substring(1);r&&i.add(r)}};try{if(await Promise.all(n.map(e=>{let t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?a(t):Promise.resolve()})),r.length>0){let t=new Set(Array.from(i).map(e=>e.split(`/`)[0]).filter(Boolean)).size,n=r.length,a=``;a=t>0?c(`upload.preparingFolder`,{count:t,folderCount:t,fileCount:n}):c(`upload.preparingFiles`,{count:n}),e(r,{count:r.length,message:a})}}catch(n){console.error(`Error processing dropped files:`,n);let r=Array.from(t.dataTransfer.files);r.length>0&&e(r)}}else t.dataTransfer.files&&t.dataTransfer.files.length>0&&e(Array.from(t.dataTransfer.files))},g=t=>{if(t&&t.length>0){let n=Array.from(t);if(n.some(e=>e.webkitRelativePath?.includes(`/`))){let t=new Set(n.map(e=>e.webkitRelativePath.split(`/`)[0]).filter(Boolean)).size,r=n.length,i=c(`upload.preparingFolder`,{count:t,folderCount:t,fileCount:r});e(n,{count:n.length,message:i})}else e(n,{count:n.length,message:c(`upload.preparingFiles`,{count:n.length})})}};return n(`div`,{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${u?`border-color-primary bg-color-primary/10`:`border-dashed border-color-border`} ${s}`,onDragOver:p,onDragLeave:m,onDrop:h,children:[t(he,{className:`h-12 w-12 mb-3 transition-colors ${u?`text-primary`:`text-muted/50`}`}),t(`p`,{className:`text-muted`,children:i}),n(`div`,{className:`flex gap-2 justify-center mt-2`,children:[t(r,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`*`,e?.click(),e.onchange=()=>{g(e.files)}},children:l}),o&&t(r,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`*`,e.webkitdirectory=!0,e?.click(),e.onchange=()=>{g(e.files)}},children:c(`upload.selectFolder`)})]})]})}function Q({title:e,count:r,icon:i=t(w,{className:`h-4 w-4 text-green-500`}),items:a}){let{t:o}=R(),[s,c]=L(!1),l=ve();return n(`div`,{className:`border border-color-border rounded-md overflow-hidden`,children:[n(`button`,{type:`button`,"aria-expanded":s,"aria-controls":l,className:`w-full flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer text-start bg-transparent border-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,onClick:()=>c(!s),children:[n(`span`,{className:`flex items-center`,children:[t(`span`,{className:`me-2`,children:i}),t(`span`,{className:`font-medium`,children:e}),t(`span`,{className:`ms-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs`,children:r})]}),t(`span`,{className:`text-muted`,"aria-hidden":`true`,children:t(`svg`,{className:`h-5 w-5 transition-transform ${s?`transform rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})})]}),s&&t(`div`,{id:l,className:`p-3 border-t border-color-border max-h-48 overflow-y-auto`,children:a.length>0?t(`ul`,{className:`space-y-1`,children:a.map(e=>t(`li`,{className:`text-sm py-1 px-2 rounded hover:bg-color-muted/10`,children:e},e))}):t(`div`,{className:`text-sm text-muted py-2`,children:o(`upload.noItems`)})})]})}function Ai({files:e,className:r=``,location:i,collection:a}){let{t:o}=R(),s=e.filter(e=>e.status===`success`),c=e.filter(e=>e.status===`updated`),l=e.filter(e=>e.status===`skipped`),u=e.filter(e=>e.status===`failed`),d=s.length,f=c.length,p=l.length,m=u.length,h=e.length;return n(`div`,{className:`flex flex-col py-2 ${r}`,children:[n(`div`,{className:`flex items-center mb-4`,children:[t(`div`,{className:`size-8 me-4 rounded-full bg-success/10 flex items-center justify-center`,children:t(w,{className:`size-4 text-success`})}),t(`div`,{children:n(`p`,{className:`text-muted`,children:[o(`upload.filesProcessed`,{count:h}),a?o(`upload.inCollection`,{collection:a}):``,i?o(`upload.inFolder`,{location:i}):``]})})]}),n(`div`,{className:`space-y-3 mt-2`,children:[d>0&&t(Q,{title:o(`upload.successfullyUploaded`),count:d,icon:t(w,{className:`h-4 w-4 text-green-500`}),items:s.map(e=>e.name)}),f>0&&t(Q,{title:o(`upload.successfullyUpdated`),count:f,icon:t(w,{className:`h-4 w-4 text-blue-500`}),items:c.map(e=>e.name)}),p>0&&t(Q,{title:o(`upload.skippedAlreadyExisted`),count:p,icon:t(x,{className:`h-4 w-4 text-amber-500`}),items:l.map(e=>e.name)}),m>0&&t(Q,{title:o(`upload.failedToUpload`),count:m,icon:t(_e,{className:`h-4 w-4 text-red-500`}),items:u.map(e=>e.name)})]})]})}const ji=`#text`,Mi=`#comment`,Ni=`#cdata`,Pi=`DECLARATION_TAG`,Fi={tagColor:`#d43900`,textColor:`#333`,attributeKeyColor:`#2a7ab0`,attributeValueColor:`#008000`,separatorColor:`#333`,commentColor:`#aaa`,cdataColor:`#1d781d`,fontFamily:`monospace`},Ii={attributeKeyColor:`#FFD700`,attributeValueColor:`#FF4500`,tagColor:`#87CEFA`,textColor:`#00FF00`,separatorColor:`#FFD700`,commentColor:`#BEBEBE`,cdataColor:`#33CC66`,fontFamily:`monospace`},Li=A({theme:Fi,collapsible:!1,indentSize:2}),$=()=>N(Li),Ri=new Ue({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:``,allowBooleanAttributes:!0,commentPropName:Mi,cdataPropName:Ni,parseTagValue:!1});function zi(e){return F(()=>{try{let t=We.validate(e);if(t!==!0)throw Error(t.err.msg||`Invalid XML!`);let n=Ri.parse(e);if(typeof e==`string`&&e.trim().length>0&&n.length===0)throw Error(`Invalid XML!`);return{json:n,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}},[e])}function Bi(e){let{indentation:r,children:i,isInline:a}=e,{theme:o}=$();return n(`div`,{style:{color:o.cdataColor},children:[t(`span`,{children:`${r}<![CDATA[`}),i,t(`span`,{children:`${a?``:r}]]>`})]})}function Vi(e){let{collapsible:n,theme:r}=$(),{collapsed:i}=e;return n?t(`span`,{style:{position:`relative`},children:t(`span`,{style:{position:`absolute`,right:`0`,border:0,padding:0,background:`none`},children:t(Hi,{fill:r.separatorColor,style:{transform:`rotate(${i?0:90}deg)`,transition:`transform 0.2s`}})})}):null}function Hi({...e}){return t(`svg`,{width:`16px`,height:`16px`,viewBox:`0 0 24 24`,"aria-hidden":`true`,...e,children:t(`path`,{d:`M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z`})})}function Ui(e){let{collapsible:t,initialCollapsedDepth:n}=$(),[r,i]=L(()=>Ge(n)||!t?!1:e>=n);return P(()=>{i(Ge(n)||!t?!1:e>=n)},[n,e,t]),{collapsed:r,buttonProps:t?{onClick:()=>i(e=>!e),role:`button`,style:{cursor:`pointer`}}:{}}}function Wi(e){let{indentation:r,children:i,isInline:a,level:o}=e,{theme:s}=$(),{collapsed:c,buttonProps:l}=Ui(o);return n(`div`,{style:{color:s.commentColor},children:[n(`span`,{...l,children:[t(`span`,{children:r}),t(Vi,{collapsed:c}),t(`span`,{children:`<!-- `})]}),!c&&i,c&&`...`,t(`span`,{children:`${a||c?` `:r}-->`})]})}function Gi(e){let{attributes:r}=e,{theme:i}=$();return r?t(`span`,{children:Object.entries(r).map(([e,r])=>n(`span`,{children:[t(`span`,{style:{color:i.attributeKeyColor},children:` ${e}`}),t(`span`,{style:{color:i.separatorColor},children:`=`}),t(`span`,{style:{color:i.attributeValueColor},children:`"${r}"`})]},`attribute-${e}`))}):null}function Ki(e){let{indentation:r,tagKey:i,attributes:a}=e,{theme:o}=$();return n(`div`,{children:[t(`span`,{style:{color:o.separatorColor},children:`${r}<?`}),t(`span`,{style:{color:o.tagColor},children:`${i.slice(1)}`}),t(Gi,{attributes:a}),t(`span`,{style:{color:o.separatorColor},children:`?>`})]})}function qi(e,t){return Array(t*e+1).join(` `)}function Ji(e){return typeof e==`string`&&e.includes(`
5
+ `)),{type:n,value:r}}else if(typeof e==`number`||typeof e==`boolean`)return{value:String(e),type:G.Inline};else return{value:e,type:G.Object}}function Pt({value:e,viewCode:n=!1}){let{t:r}=R();return e?t(`div`,{className:`relative w-full h-full flex flex-col`,children:n||!Ft(e)?t(wt,{data:e}):t(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:t(Ot,{value:e})})}):t(`pre`,{className:`whitespace-pre-wrap`,children:r(`misc.noData`)})}function Ft(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?!0:Array.isArray(e)?e.every(Ft):typeof e==`object`?Object.values(e).every(Ft):!1}const It=new Set;function Lt(e){It.has(`markdown`)||(It.add(`markdown`),e.languages.registerFoldingRangeProvider(`markdown`,{provideFoldingRanges(e){let t=[],n=e.getLinesContent(),r=/^(#{1,6})\s/,i=[];for(let e=0;e<n.length;e++){let a=e+1,o=r.exec(n[e]);if(o){let e=o[1].length;for(;i.length>0&&i[i.length-1].level>=e;){let e=i.pop();e&&a-1>e.line&&t.push({start:e.line,end:a-1})}i.push({level:e,line:a})}}let a=n.length;for(;i.length>0;){let e=i.pop();e&&a>e.line&&t.push({start:e.line,end:a})}return t}}));for(let t of[`javascript`,`typescript`])It.has(t)||(It.add(t),e.languages.registerFoldingRangeProvider(t,{provideFoldingRanges(e){let t=e.getLinesContent(),n=/^(#{1,6})\s/,r=[],i=[],a=[],o=[],s=!1,c=!1,l=``;for(let e=0;e<t.length;e++){let u=e+1,d=t[e],f=s;for(let e=0;e<d.length;e++){let t=d[e];if(t===`\\`){e++;continue}if(c){t===l&&(c=!1);continue}if(s){t==="`"&&(s=!1);continue}if(t==="`"){s=!0;continue}if(t===`"`||t===`'`){c=!0,l=t;continue}if(t===`{`&&a.push(u),t===`}`&&a.length>0){let t=a.pop(),n=d.slice(e+1).trimStart().length>0?u-1:u;t!==void 0&&n>t&&r.push({start:t,end:n})}}if(f){let e=n.exec(d);if(e){let t=e[1].length;for(;o.length>0&&o[o.length-1].level>=t;){let e=o.pop();e&&u-1>e.line&&i.push({start:e.line,end:u-1})}o.push({level:t,line:u})}if(!s)for(;o.length>0;){let e=o.pop();e&&u>e.line&&i.push({start:e.line,end:u})}}}return[...r,...i]}}))}var Rt=class{VgetValue;VsetValue;constructor(e,t){this.VgetValue=e,this.VsetValue=t}getValue(){return this.VgetValue()}setValue(e){this.VsetValue(e||``)}};function zt({onChange:e,value:n,className:r,editorRef:i,language:a=`javascript`,path:o,debounceTimeout:s=0,options:c={},beforeMount:l,onMount:u,defaultValue:d,useCustomFolding:f=!1}){let[p,m]=L(n||d||``),h=I(null),g=I(null),{theme:v}=_(),b=v===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:v,x=n||d||``,S=I(()=>p),C=I(e=>{m(e),h.current&&h.current.setValue(e)});P(()=>{S.current=()=>p},[p]),P(()=>(i&&(i.current=new Rt(()=>S.current(),e=>C.current(e))),()=>{i&&(i.current=void 0)}),[i]);let ee=F(()=>{if(e)return s>0?Se(t=>e(t),s):e},[e,s]),w=M(async(e,t)=>{let n=e.getModel();if(n)for(let r of n.getValue().matchAll(/```[\s\S]*?```/g)){let i=n.getPositionAt(r.index).lineNumber,a=n.getPositionAt(r.index+r[0].length).lineNumber;e.setSelection(new t.Selection(i,1,a,1)),await e.getAction(`editor.createFoldingRangeFromSelection`)?.run()}},[]),te=M(e=>{let t=e||``;if(m(t),ee){let e={docChanged:!0,state:{doc:{toString:()=>t,length:t.length}}};ee(e)}},[ee]),T=M((e,t)=>{h.current=e,g.current=t,f&&Lt(t),C.current=t=>{m(t),e.setValue(t)},t.editor.defineTheme(`errorLineTheme`,{base:b===`dark`?`vs-dark`:`vs`,inherit:!0,rules:[],colors:{"editorError.background":`#ffebee`,"editorError.border":`#f44336`}}),t.editor.setTheme(`errorLineTheme`),f&&setTimeout(()=>w(e,t),300),u?.(e,t)},[u,b,f,w]);P(()=>{m(e=>x===e?e:(h.current&&h.current.setValue(x),x))},[x]),P(()=>{if(!x||!f||!h.current||!g.current)return;let e=h.current,t=g.current,n=setTimeout(()=>w(e,t),300);return()=>clearTimeout(n)},[x,f,w]);let E={fontSize:14,fontFamily:`monospace`,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,lineNumbers:`on`,folding:!0,lineDecorationsWidth:10,lineNumbersMinChars:3,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,tabSize:2,insertSpaces:!0,fixedOverflowWidgets:!0,glyphMargin:!0,renderValidationDecorations:`on`,renderLineHighlight:`line`,hover:{enabled:!0,delay:100},quickSuggestions:{other:!0,comments:!0,strings:!0},...c};return t(`div`,{className:y(r,`w-full h-full!`),children:t(xe,{className:`h-full w-full`,height:`100%`,theme:b===`dark`?`vs-dark`:`light`,language:a,path:o,value:p,onChange:te,onMount:T,beforeMount:l,options:E,defaultValue:d||``})})}function Bt({value:e,onChange:r,onValidChange:i,readonly:a=!1,height:o=`200px`,placeholder:s,className:c}){let{theme:l}=_(),u=I(void 0),[d,f]=L(null),p=F(()=>{if(e==null)return s??`{}`;try{return JSON.stringify(e,null,2)}catch{return`{}`}},[e,s]),m=M(()=>{if(!u.current||a)return;let e=u.current.getValue();try{let t=JSON.parse(e);f(null),i?.(t)}catch{f(`Invalid JSON`)}},[a,i]);return n(`div`,{className:c,children:[t(`div`,{className:`border rounded overflow-hidden`,style:{height:o},children:t(zt,{defaultValue:p,editorRef:u,language:`json`,theme:l===`dark`?`vs-dark`:`vs`,onChange:m,options:a?{readOnly:!0,domReadOnly:!0}:void 0})}),d&&t(`p`,{className:`text-xs text-destructive mt-1`,children:d})]})}function Vt(e){if(!e.current)return null;try{return JSON.parse(e.current.getValue())}catch{return null}}function Ht({title:e,viewCode:i,setViewCode:a}){return n(`div`,{className:`flex items-center gap-1 bg-muted mb-2 p-1 rounded`,children:[t(r,{variant:i?`ghost`:`primary`,size:`sm`,alt:`Preview properties`,onClick:()=>a(!1),children:e}),t(r,{variant:i?`primary`:`ghost`,size:`sm`,alt:`View in JSON format`,onClick:()=>a(!0),children:`JSON`})]})}function Ut(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim().replace(/^./,e=>e.toUpperCase())}function Wt(r){return r==null?`Failed to query`:typeof r==`string`?r:Array.isArray(r)?r.length===0?`None`:r.some(e=>e&&typeof e==`object`)?t(e,{children:r.map((e,r)=>n(`div`,{className:`flex gap-1`,children:[n(`span`,{className:`text-xs align-top pe-2 font-medium`,children:[r+1,`:`]}),t(`span`,{className:`text-xs`,children:Wt(e)})]},`item-${r}`))}):r.map(e=>String(e)).join(`, `):typeof r==`object`?t(e,{children:Object.entries(r).map(([e,r])=>n(`div`,{className:`flex gap-1`,children:[n(`span`,{className:`text-xs align-top pe-2 font-medium`,children:[Ut(e),`:`]}),t(`span`,{className:`text-xs`,children:Wt(r)})]},e))}):String(r)}function Gt({data:e,className:r}){let i=e?Object.entries(e):[];return t(`table`,{className:r||`mb-2 text-xs bg-muted rounded-sm w-full`,children:t(`tbody`,{children:i.map(([e,r])=>n(`tr`,{className:`align-top hover:bg-background border-y`,children:[t(`td`,{className:`align-top pe-4 p-2`,children:Ut(e)}),t(`td`,{className:`p-2`,children:Wt(r)})]},e))})})}function Kt(...e){return ke(b(e))}const qt=A(null);function Jt(){return N(qt)}function Yt(e){return e.startsWith(`agents/`)||e.startsWith(`documents/`)}function Xt(e,t,n=`inline`){return`artifact:${e}:${t}:${n}`}function Zt(e){return`file:${e}`}function Qt({error:e,chartTitle:r}){return t(`div`,{className:`flex items-center justify-center h-full bg-red-50 dark:bg-red-950 rounded-md p-4`,children:n(`div`,{className:`text-center`,children:[n(`p`,{className:`text-sm font-medium text-red-600 dark:text-red-400`,children:[`Cannot render `,r||`Vega-Lite`,` chart`]}),t(`p`,{className:`text-xs text-red-500 dark:text-red-500 mt-1 max-w-xs truncate`,children:e})]})})}function $t({isOpen:e,onClose:i,title:a,description:o,children:s}){let{t:c}=R();return t(z.Root,{open:e,onOpenChange:e=>!e&&i(),children:n(z.Portal,{children:[t(z.Overlay,{className:`fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),n(z.Content,{className:`fixed inset-2 sm:inset-4 z-50 flex flex-col bg-white dark:bg-gray-900 rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2`,onEscapeKeyDown:i,children:[t(z.Close,{asChild:!0,children:t(r,{variant:`unstyled`,onClick:i,className:`absolute top-3 end-3 z-10 p-2 rounded-lg bg-white/80 dark:bg-gray-800/80 backdrop-blur-sm hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150 shadow-sm`,"aria-label":c(`agent.closeFullscreen`),children:t(ge,{className:`w-5 h-5 text-gray-600 dark:text-gray-300`})})}),t(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150`,children:s}),t(`div`,{className:`flex items-center justify-between px-4 sm:px-6 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50 rounded-b-xl`,children:n(`div`,{className:`flex flex-col`,children:[t(z.Title,{className:`text-base font-semibold text-gray-900 dark:text-gray-100`,children:a||c(`agent.dashboard`)}),o&&t(z.Description,{className:`text-sm text-gray-500 dark:text-gray-400 mt-0.5`,children:o})]})})]})]})})}function en(e,t){if(t===`chart`)return 280;let n=1;if(e.vconcat)n=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){let t=e.columns||2,r=Array.isArray(e.concat)?e.concat.length:1;n=Math.ceil(r/t)}else e.facet&&(n=2);return Math.max(500,n*280+40)}const tn={categorical:[`#6366f1`,`#8b5cf6`,`#ec4899`,`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#14b8a6`,`#06b6d4`,`#3b82f6`],blues:[`#dbeafe`,`#93c5fd`,`#3b82f6`,`#1d4ed8`,`#1e3a8a`],purples:[`#f3e8ff`,`#c4b5fd`,`#8b5cf6`,`#6d28d9`,`#4c1d95`],greens:[`#dcfce7`,`#86efac`,`#22c55e`,`#15803d`,`#14532d`],diverging:[`#ef4444`,`#fca5a5`,`#fef3c7`,`#86efac`,`#22c55e`]};function nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rn(e){return nn(e)}function an(e){let t=JSON.parse(JSON.stringify(e)),n=[`vconcat`,`hconcat`,`concat`];if(!n.some(e=>Array.isArray(t[e])))return t;let r=[];if(Array.isArray(t.params))for(let e of t.params)e&&typeof e==`object`&&e.name&&e.select&&r.push({name:e.name,param:e});if(r.length===0)return t;for(let{name:e,param:i}of r){let r=i.select?.fields||[],a=i.select?.bind===`legend`,o=null;for(let e of n)if(Array.isArray(t[e])){o=t[e];break}if(!o||o.length===0)continue;let s=0;for(let e=0;e<o.length;e++){let t=o[e];if(sn(t,r)||a&&cn(t,r)){s=e;break}}let c=o[s];c.params||=[],c.params.push(i),t.params=(t.params??[]).filter(t=>t.name!==e)}return Array.isArray(t.params)&&t.params.length===0&&delete t.params,t}function on(e,t){if(!t||Object.keys(t).length===0)return e;let n=JSON.parse(JSON.stringify(e)),r=e=>{for(let n of e)n.name&&n.name in t&&(n.value=t[n.name])};Array.isArray(n.params)&&r(n.params);let i=e=>{if(Array.isArray(e)){for(let t of e)if(Array.isArray(t.params)&&r(t.params),t.vconcat&&i(t.vconcat),t.hconcat&&i(t.hconcat),t.concat&&i(t.concat),Array.isArray(t.layer))for(let e of t.layer)Array.isArray(e.params)&&r(e.params)}};if(n.vconcat&&i(n.vconcat),n.hconcat&&i(n.hconcat),n.concat&&i(n.concat),Array.isArray(n.layer))for(let e of n.layer)e&&Array.isArray(e.params)&&r(e.params);return n}function sn(e,t){if(!e?.encoding)return!1;for(let n of t)for(let t of Object.values(e.encoding))if(t.field===n)return!0;if(Array.isArray(e.layer)){for(let n of e.layer)if(sn(n,t))return!0}return!1}function cn(e,t){if(!e)return!1;let n=e=>{if(!e)return!1;let n=e.color?.field;return!!n&&t.includes(n)};if(n(e.encoding))return!0;if(Array.isArray(e.layer)){for(let t of e.layer)if(n(t.encoding))return!0}return!1}function ln(e,t=[]){let n=[];if(!e||typeof e!=`object`)return n;if(e.data&&typeof e.data==`object`){let r=e.data.url;typeof r==`string`&&r.startsWith(`artifact:`)&&n.push({path:[...t,`data`],artifactPath:r.replace(/^artifact:/,``).trim()})}for(let r of[`layer`,`vconcat`,`hconcat`,`concat`,`spec`,`repeat`,`facet`])if(r in e){let i=e[r];Array.isArray(i)?i.forEach((e,i)=>{rn(e)&&n.push(...ln(e,[...t,r,String(i)]))}):rn(i)&&n.push(...ln(i,[...t,r]))}return n}function un(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of t){let t=e.split(`.`),i=n;for(let e=0;e<t.length-1;e++){let n=i[t[e]];if(!nn(n))break;i=n}let a=t[t.length-1],o=i[a];nn(o)&&(delete o.url,o.values=r)}return n}function dn(e){let t={background:`transparent`,view:{stroke:`transparent`},range:{category:tn.categorical,diverging:tn.diverging,heatmap:tn.purples,ramp:tn.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:`round`},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80}};return e?{...t,axis:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,gridColor:`#3f3f46`,domainColor:`#52525b`,tickColor:`#52525b`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#a1a1aa`,titleColor:`#e4e4e7`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#fafafa`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}:{...t,axis:{labelColor:`#71717a`,titleColor:`#3f3f46`,gridColor:`#e4e4e7`,domainColor:`#d4d4d8`,tickColor:`#d4d4d8`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:`#71717a`,titleColor:`#3f3f46`,labelFont:`Inter, system-ui, sans-serif`,titleFont:`Inter, system-ui, sans-serif`,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:`#18181b`,font:`Inter, system-ui, sans-serif`,fontSize:14,fontWeight:600}}}const K=j(function({spec:i,artifactRunId:a}){let{t:o}=R(),{title:s,description:c,options:l}=i,u=i.spec,[d,f]=L(!1),[p,m]=L(!1),[h,g]=L(null),[_,v]=L(!1),y=I(null),b=I(null),x=I(null),{client:S}=Ee(),C=Jt(),w=I(S);w.current=S;let te=I(C);te.current=C;let[T,E]=L(null),[ie,ae]=L(!1),[oe,se]=L(null),ce=l?.mode||`chart`,D=ce===`dashboard`,fe=l?.enableFullscreen??D,O=l?.height||en(u,ce);P(()=>{let e=ln(u);if(e.length===0){E(u),ae(!1),se(null);return}a?console.info(`[VegaLiteChart] resolving artifacts with runId:`,a,e.map(e=>e.artifactPath)):console.warn(`[VegaLiteChart] artifact references found but artifactRunId is missing!`,{references:e.map(e=>e.artifactPath),artifactRunId:a});let t=!1;return ae(!0),se(null),(async()=>{let n=new Map,r=w.current,i=te.current;for(let o of e)try{let e=o.path.join(`.`),t;if(a&&!Yt(o.artifactPath)){let e=Xt(a,o.artifactPath,`inline`);t=i?await i.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(a,o.artifactPath,`inline`)).url):(await r.files.getArtifactDownloadUrl(a,o.artifactPath,`inline`)).url}else{let e=Zt(o.artifactPath);t=i?await i.getOrFetch(e,async()=>(await r.files.getDownloadUrl(o.artifactPath)).url):(await r.files.getDownloadUrl(o.artifactPath)).url}let s=await fetch(t);if(!s.ok)throw Error(`Failed to fetch artifact data: ${s.statusText}`);let c=o.artifactPath.toLowerCase().endsWith(`.csv`),l;if(c){let e=await s.text();l=De.parse(e,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{let e=await s.json();l=Array.isArray(e)?e:[e]}n.set(e,l)}catch(e){console.error(`Failed to resolve artifact: ${o.artifactPath}`,e),t||se(`Failed to load data from artifact: ${o.artifactPath}`);return}if(!t){let e=un(u,n);E(e),ae(!1)}})(),()=>{t=!0}},[u,a]);let[pe,me]=L(!1),he=I(!1);P(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`);e!==he.current&&(he.current=e,me(e))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let[ge,_e]=L(0),k=I(0);P(()=>{if(!x.current)return;let e,t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{let e=t[0]?.contentRect.width;e&&e!==k.current&&(k.current=e,_e(e))},100)});t.observe(x.current);let n=x.current.clientWidth;return k.current=n,_e(n),()=>{clearTimeout(e),t.disconnect()}},[]);let A=F(()=>ln(u).length>0,[u]),j=F(()=>{if(A&&!T)return null;let e=T||u;return e?(l?.parameterValues&&(e=on(e,l.parameterValues)),an(e)):null},[T,u,A,l?.parameterValues]),N=M((e,t)=>{if(!e||typeof e!=`object`)return e;if(e.hconcat&&Array.isArray(e.hconcat)){let n=e.hconcat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,hconcat:e.hconcat.map(e=>N(e,i))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>N(e,t))};if(e.concat&&Array.isArray(e.concat)){let n=e.columns??e.concat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,concat:e.concat.map(e=>N(e,i))}}let n=e.width;return n===`container`||typeof n==`number`&&n>t?{...e,width:t}:e},[]),ve=M((e,t=!1)=>{if(!j)return null;let n=dn(pe),r=t?typeof window<`u`?Math.min(window.innerWidth-80,1400):1200:ge>0?ge-24:500,i=`vconcat`in j||`hconcat`in j||`concat`in j,a=i?{type:`pad`,contains:`padding`}:{type:`fit`,contains:`padding`},o=j;i&&r&&(o=N(j,r));let c=o.width,l=i?void 0:c===`container`?r:c??r,{width:u,...d}=o;return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,...!i&&l?{width:l}:{},height:t?void 0:e,autosize:a,...i?o:d,...s&&!j.title?{title:s}:{},config:{...n,...j.config}}},[j,s,pe,ge,N]),ye=M(async()=>{let e=_?b.current:y.current;if(!(!e||p))try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),m(!0),setTimeout(()=>m(!1),2e3))},`image/png`)}catch(e){console.error(`Failed to copy chart:`,e)}},[p,_]),be=M(async()=>{let e=_?b.current:y.current;if(!(!e||d)){f(!0);try{let t=await e.toImageURL(`png`,2),n=document.createElement(`a`);n.download=`${s||`chart`}.png`,n.href=t,n.click()}catch(e){console.error(`Failed to export chart:`,e)}finally{f(!1)}}},[s,d,_]),xe=M(e=>{y.current=e,g(null)},[]),Se=M(e=>{b.current=e},[]),Ce=M(e=>{console.error(`Vega-Lite rendering error:`,e),g(e instanceof Error?e.message:`Unknown error`)},[]),we=M(()=>{v(e=>!e)},[]);P(()=>{g(null)},[u]);let Te=({className:e})=>n(`div`,{className:Kt(`flex items-center gap-2`,e),children:[n(r,{variant:`unstyled`,onClick:ye,disabled:p,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1`,title:o(`agent.copyToClipboard`),children:[t(p?ee:ne,{className:`w-3 h-3`}),o(p?`agent.copied`:`agent.copy`)]}),n(r,{variant:`unstyled`,onClick:be,disabled:d,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1`,title:o(`agent.exportAsPng`),children:[t(re,{className:`w-3 h-3`}),o(d?`agent.exporting`:`agent.export`)]}),fe&&n(r,{variant:`unstyled`,onClick:we,className:`text-xs px-2 py-1 rounded border border-gray-300 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer transition-colors flex items-center gap-1`,title:o(_?`agent.exitFullscreen`:`agent.fullscreen`),children:[t(_?de:ue,{className:`w-3 h-3`}),o(_?`agent.exit`:`agent.fullscreen`)]})]});if(ie||A&&!T)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{className:`flex items-center justify-center bg-gray-50 dark:bg-gray-800 rounded`,style:{width:`100%`,height:O},children:n(`div`,{className:`flex items-center gap-2 text-gray-500 dark:text-gray-400`,children:[t(le,{className:`w-5 h-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading data from artifacts...`})]})})]})});if(oe)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:O},children:t(Qt,{error:oe,chartTitle:s})})]})});if(h)return t(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:O},children:t(Qt,{error:h,chartTitle:s})})]})});let z=ve(O),ke=ve(0,!0);return z?(typeof window<`u`&&localStorage.getItem(`DEBUG_VEGA_RENDERS`)&&console.log(`VegaLite rendering with spec:`,{title:s,hasData:!!z.data?.values,dataLength:z.data?.values?.length}),n(e,{children:[t(`div`,{className:Kt(`bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-800 shadow-sm`,D&&`border-2`),children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:s||(D?`Dashboard`:`Chart`)}),D&&t(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-indigo-100 dark:bg-indigo-900 text-indigo-700 dark:text-indigo-300`,children:`Interactive`})]}),t(Te,{})]}),c&&t(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c}),t(`div`,{ref:x,className:`bg-white dark:bg-gray-900 rounded overflow-hidden`,style:{width:`100%`,height:O,minWidth:0},children:t(Oe,{spec:z,onEmbed:e=>xe(e.view),onError:Ce,options:{renderer:l?.renderer||`canvas`,actions:!1}})})]})}),n($t,{isOpen:_,onClose:()=>v(!1),title:s||(D?`Dashboard`:`Chart`),description:c,children:[t(`div`,{className:`w-full h-full min-h-[calc(100vh-200px)]`,children:ke&&t(Oe,{spec:ke,onEmbed:e=>Se(e.view),onError:Ce,options:{renderer:l?.renderer||`canvas`,actions:!1}})}),t(`div`,{className:`absolute bottom-6 end-6`,children:t(Te,{className:`bg-white dark:bg-gray-800 rounded-lg shadow-lg p-2 border border-gray-200 dark:border-gray-700`})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId),fn=k.createContext({});function pn({children:e,artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}){let o=F(()=>({artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}),[n,r,i,a]);return t(fn.Provider,{value:o,children:e})}function q(){return k.useContext(fn)}const mn={chart:{icon:C,label:`chart`,defaultHeight:200},mermaid:{icon:ae,label:`diagram`,defaultHeight:150},proposal:{icon:D,label:`options`,defaultHeight:100},code:{icon:E,label:`code`,defaultHeight:80},image:{icon:oe,label:`image`,defaultHeight:150},link:{icon:ce,label:`link`,defaultHeight:24},expand:{icon:re,label:`content`,defaultHeight:100},table:{icon:pe,label:`table`,defaultHeight:150},markdown:{icon:ie,label:`content`,defaultHeight:100},"fusion-fragment":{icon:E,label:`fragment`,defaultHeight:150}};function J({type:e,error:i,onRetry:a,message:o,height:s}){let c=mn[e],l=s??c.defaultHeight,u=e===`link`;if(i)return n(`div`,{className:`flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive ${u?`inline-flex px-2 py-1 text-sm`:`p-4`}`,style:u?void 0:{minHeight:l},children:[n(`span`,{className:`text-destructive`,children:[`Failed to load `,c.label]}),a&&t(r,{variant:`unstyled`,onClick:a,className:`ms-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors text-destructive`,children:`Retry`})]});let d=c.icon;return u?n(`span`,{className:`inline-flex items-center gap-1 text-muted animate-pulse`,children:[t(d,{className:`h-3 w-3`}),t(`span`,{children:o||`Loading ${c.label}...`})]}):n(`div`,{className:`flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse`,style:{minHeight:l},children:[t(d,{className:`h-8 w-8 text-muted`}),t(`span`,{className:`text-sm text-muted`,children:o||`Loading ${c.label}...`}),t(`div`,{className:`flex gap-1`,children:[...[,,,]].map((e,n)=>t(`div`,{className:`h-2 w-2 rounded-full bg-muted animate-bounce`,style:{animationDelay:`${n*150}ms`}},`dot-${n}`))})]})}var Y=class extends k.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`CodeBlock rendering error (${this.props.type}):`,e,t),this.props.onError?.(e)}handleRetry=()=>{this.setState({hasError:!1,error:void 0})};render(){if(this.state.hasError){let{type:e,fallbackCode:r}=this.props;return n(`div`,{className:`space-y-2`,children:[t(J,{type:e,error:this.state.error?.message||`Rendering failed`,onRetry:this.handleRetry}),r&&n(`details`,{className:`text-sm`,children:[t(`summary`,{className:`cursor-pointer text-muted hover:text-foreground`,children:`Show raw content`}),t(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs`,children:t(`code`,{children:r})})]})]})}return this.props.children}};function hn(e,t,n){let r=t.split(`.`).pop()?.toLowerCase();if(r===`svg`)return`mockup`;if([`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(r||``))return`image`;if(r===`md`)return`markdown`;if(r===`csv`)return`table`;if(n===`json`&&typeof e==`object`&&e){let t=e;if(typeof t.$schema==`string`&&t.$schema.includes(`vega`)||t.library===`vega-lite`&&`spec`in t)return`vega-lite`;if(`template`in t&&`data`in t)return`fusion-fragment`;if(Array.isArray(e)&&e.length>0&&typeof e[0]==`object`)return`table`}return`code`}function gn(e){if(typeof e!=`object`||!e)return null;let t=e;return t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`&&t.spec!==null?t:typeof t.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}function _n({content:e}){let{headers:r,rows:i}=F(()=>{if(!Array.isArray(e)||e.length===0)return{headers:[],rows:[]};let t=e[0];if(typeof t!=`object`||!t)return{headers:[],rows:[]};let n=Object.keys(t);return{headers:n,rows:e.map(e=>n.map(t=>{let n=e[t];return n==null?``:typeof n==`object`?JSON.stringify(n):String(n)}))}},[e]);return r.length===0?t(J,{type:`table`,error:`No table data found`}):n(`div`,{className:`overflow-x-auto`,children:[n(`table`,{className:`min-w-full text-sm border-collapse`,children:[t(`thead`,{children:t(`tr`,{className:`border-b`,children:r.map(e=>t(`th`,{className:`px-3 py-2 text-start font-medium text-muted`,children:e},e))})}),t(`tbody`,{children:i.slice(0,100).map((e,n)=>t(`tr`,{className:`border-b border-muted/20`,children:e.map((e,n)=>t(`td`,{className:`px-3 py-2`,children:e},`cell-${n}`))},`row-${n}`))})]}),i.length>100&&n(`div`,{className:`text-sm text-muted py-2`,children:[`Showing 100 of `,i.length,` rows`]})]})}function vn({content:e,path:n}){let r=n.split(`.`).pop()?.toLowerCase()||``,i=typeof e==`string`?e:JSON.stringify(e,null,2);return t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{className:`language-${r}`,children:i})})}function yn(e){return Te.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`use`],FORBID_TAGS:[`foreignObject`]})}function bn(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let n=t;if(!/viewBox/i.test(n)){let e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n);e&&t&&(n+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return n=n.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``).replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``),/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}function xn({content:e}){let n=F(()=>{let t=typeof e==`string`?e.trim():``;return t?bn(yn(t)):null},[e]);return n?t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}}):t(J,{type:`expand`,error:`Empty mockup`})}function Sn({content:e,path:n}){return t(`img`,{src:typeof e==`string`?e:``,alt:n.split(`/`).pop()||`Artifact image`,className:`max-w-full h-auto rounded`,loading:`lazy`})}function Cn({content:e,renderType:n,path:r,runId:i,contentType:a}){let{MarkdownRenderer:o}=q();switch(F(()=>n===`auto`?hn(e,r,a):n,[e,r,a,n])){case`chart`:{let n=gn(e);return n?t(Y,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(K,{spec:n,artifactRunId:i})}):t(J,{type:`chart`,error:`Only Vega-Lite charts are supported. Recharts rendering has been retired.`})}case`vega-lite`:{let n=gn(e);return n?t(Y,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(K,{spec:n,artifactRunId:i})}):t(J,{type:`chart`,error:`Invalid Vega-Lite specification`})}case`fusion-fragment`:{let n=e;return console.log(`[ArtifactContentRenderer] fusion-fragment:`,{hasTemplate:!!n.template,hasData:!!n.data,runId:i,hasVegaLiteChart:!!K}),n.template&&n.data?t(Y,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(we,{data:n.data,ChartComponent:K,artifactRunId:i,children:t(Ce,{code:JSON.stringify(n.template),data:n.data})})}):t(Y,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(Ce,{code:JSON.stringify(e)})})}case`table`:return t(Y,{type:`table`,fallbackCode:JSON.stringify(e,null,2),children:t(_n,{content:e})});case`markdown`:{let n=typeof e==`string`?e:String(e);return t(Y,{type:`markdown`,fallbackCode:n,children:o?t(o,{artifactRunId:i,children:n}):t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{children:n})})})}case`mockup`:return t(Y,{type:`expand`,fallbackCode:typeof e==`string`?e:r,children:t(xn,{content:e})});case`image`:return t(Y,{type:`image`,fallbackCode:r,children:t(Sn,{content:e,path:r})});default:return t(vn,{content:e,path:r})}}var wn=class{components={};registerComponent(e,t){this.components[e]=t}getComponent(e){return this.components[e]}};const Tn=A(null);function En({components:e,children:n}){let r=F(()=>{let t=new wn;for(let[n,r]of Object.entries(e))t.registerComponent(n,r);return t},[e]);return t(Tn.Provider,{value:r,children:n})}function Dn(){return N(Tn)}function On(e){let t=N(Tn);if(t)return t.getComponent(e)}const kn=`Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function An(e){let t=e.trim(),n=``,r=!1,i=!1;for(let e=0;e<t.length;e++){let a=t[e],o=e>0?t[e-1]:``;if(a===`"`&&!i&&o!==`\\`){r=!r,n+=a;continue}if(a===`'`&&!r&&o!==`\\`){i=!i,n+=a;continue}if((r||i)&&a===`\\`){let r=e;for(;t[r]===`\\`;)r++;if(t[r]===`n`){n+=`<br/>`,e=r;continue}}n+=a}return n}function jn(e){return e.replace(/<svg([^<>]*)>/i,(e,t)=>{let n=t.replace(/\swidth="[^"]*"/i,``).replace(/\sheight="[^"]*"/i,``);return/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}Ae.initialize({startOnLoad:!1,theme:`default`,securityLevel:`loose`,fontFamily:kn,suppressErrorRendering:!0,flowchart:{htmlLabels:!0,useMaxWidth:!0,nodeSpacing:40,rankSpacing:50,padding:12},sequence:{useMaxWidth:!0},themeVariables:{fontFamily:kn}});function Mn({code:e,className:n}){let r=I(null),[i,a]=L(null),[o,s]=L(null),c=ve().replace(/:/g,`_`);return P(()=>{let t=!1;return(async()=>{if(!e.trim()){a(null),s(null);return}try{s(null);let n=`mermaid-${c}-${Date.now()}`,r=An(e),{svg:i}=await Ae.render(n,r),o=jn(i);t||a(o)}catch(e){if(!t){let t=e instanceof Error?e.message:`Failed to render mermaid diagram`;s(t),a(null)}}})(),()=>{t=!0}},[e,c]),o?null:i?t(`div`,{ref:r,className:`my-4 w-full overflow-x-auto [&_svg]:mx-auto [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-w-full ${n||``}`,dangerouslySetInnerHTML:{__html:i}}):t(`div`,{className:`my-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg animate-pulse ${n||``}`,children:t(`div`,{className:`h-32 bg-gray-200 dark:bg-gray-700 rounded`})})}function Nn(e){switch(e.split(`.`).pop()?.toLowerCase()){case`json`:return`json`;case`md`:case`txt`:case`csv`:case`yaml`:case`yml`:return`text`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`webp`:case`pdf`:return`binary`;default:return`text`}}function Pn({runId:e,path:t,parseJson:n=!0}){let{client:r}=Ee(),i=Jt(),a=I(r);a.current=r;let o=I(i);o.current=i;let[s,c]=L({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l=M(async()=>{if(!e){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No run ID provided`,contentType:void 0});return}if(!t){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No artifact path provided`,contentType:void 0});return}c(e=>({...e,isLoading:!0,error:void 0}));let r=a.current,i=o.current,s=Nn(t);try{let a=Xt(e,t,`inline`),o;o=i?await i.getOrFetch(a,async()=>(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url):(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url;let l=await fetch(o);if(!l.ok)throw Error(`Failed to fetch artifact: ${l.status} ${l.statusText}`);if(s===`binary`){c({data:o,rawContent:void 0,isLoading:!1,error:void 0,contentType:s});return}let u=await l.text(),d;if(n&&s===`json`)try{d=JSON.parse(u)}catch{d=u}else d=u;c({data:d,rawContent:u,isLoading:!1,error:void 0,contentType:s})}catch(e){let n=e instanceof Error?e.message:`Failed to fetch artifact`;console.error(`Failed to fetch artifact content:`,t,e),c({data:void 0,rawContent:void 0,isLoading:!1,error:n,contentType:s})}},[e,t,n]);P(()=>{l()},[l]);let u=M(()=>{c({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l()},[l]);return{data:s.data,rawContent:s.rawContent,isLoading:s.isLoading,error:s.error,contentType:s.contentType,retry:u}}function Fn(e){let t=e.trim();if(t.length<2)return!0;if(!t.startsWith(`{`))return!1;try{return JSON.parse(t),!1}catch(e){let n=e instanceof Error?e.message:``,r=[`unexpected end`,`unterminated string`,`expected`,`unexpected token`],i=n.toLowerCase();if(r.some(e=>i.includes(e))){let e=0,n=0,r=!1,i=!1;for(let a of t){if(i){i=!1;continue}if(a===`\\`){i=!0;continue}if(a===`"`){r=!r;continue}r||(a===`{`?e++:a===`}`?e--:a===`[`?n++:a===`]`&&n--)}return e>0||n>0||r}return!1}}function In(e){try{let t=e.trim(),n=t.indexOf(`{`),r=t.lastIndexOf(`}`);return n!==-1&&r>n&&(t=t.slice(n,r+1)),JSON.parse(t)}catch{return null}}function Ln(e){let t=typeof e.$schema==`string`&&e.$schema.includes(`vega`),n=e.library===`vega-lite`&&`spec`in e;return t||n?`vega-lite`:null}function Rn({code:e}){let{artifactRunId:n}=q();n||console.warn(`[VegaLiteCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=F(()=>Fn(e),[e]),i=F(()=>{if(r)return null;let t=In(e);return t?{library:`vega-lite`,spec:t}:null},[e,r]);return r?t(J,{type:`chart`,message:`Loading chart...`}):i?t(Y,{type:`chart`,fallbackCode:e,children:t(K,{spec:i,artifactRunId:n})}):t(J,{type:`chart`,error:`Invalid Vega-Lite specification`})}function zn({code:e}){let{artifactRunId:n}=q();n||console.warn(`[ChartCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=F(()=>Fn(e),[e]),i=F(()=>{if(r)return null;let t=In(e);return!t||!Ln(t)?null:t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`?t:{library:`vega-lite`,spec:t}},[e,r]);return r?t(J,{type:`chart`,message:`Loading chart...`}):i?t(Y,{type:`chart`,fallbackCode:e,children:t(K,{spec:i,artifactRunId:n})}):t(J,{type:`chart`,error:`Invalid Vega-Lite chart specification`})}function Bn({code:e}){let n=e.trim();return n?t(Y,{type:`mermaid`,fallbackCode:e,children:t(Mn,{code:n})}):t(J,{type:`mermaid`,error:`Empty diagram`})}function Vn({code:e}){let n=F(()=>{let t=e.trim();return t?bn(yn(t)):null},[e]);return n?t(Y,{type:`code`,fallbackCode:e,children:t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}})}):t(J,{type:`code`,error:`Empty mockup`})}function Hn({code:e,language:n}){let{artifactRunId:r}=q(),i=e.trim(),a=F(()=>{if(!n?.includes(`:`))return`auto`;let e=n.split(`:`)[1];return[`chart`,`vega-lite`,`table`,`markdown`,`fusion-fragment`,`mockup`,`code`,`image`,`auto`].includes(e)?e:`auto`},[n]),{data:o,isLoading:s,error:c,contentType:l}=Pn({runId:r,path:i});return r?s?t(J,{type:`expand`,message:`Loading ${i}...`}):c?t(J,{type:`expand`,error:`Failed to load artifact: ${c}`}):o===void 0?t(J,{type:`expand`,error:`No content found in artifact`}):t(Cn,{content:o,renderType:a,path:i,runId:r,contentType:l}):t(J,{type:`expand`,error:`No artifact run ID available`})}function Un(e){return e?.startsWith(`expand`)??!1}function Wn(){return{chart:zn,"vega-lite":Rn,vegalite:Rn,mermaid:Bn,mockup:Vn,svg:Vn}}function Gn(e){return e.trim().replace(/^\/+/,``)}function X(e){return e.startsWith(`artifact:`)?{scheme:`artifact`,path:e.slice(9).trim()}:e.startsWith(`image:`)?{scheme:`image`,path:e.slice(6).trim()}:e.startsWith(`store:`)?{scheme:`store`,path:Gn(e.slice(6))}:e.startsWith(`document:`)?{scheme:`document`,path:Gn(e.slice(9))}:e.startsWith(`collection:`)?{scheme:`collection`,path:Gn(e.slice(11))}:{scheme:`standard`,path:e}}function Kn(e,t){switch(e){case`store`:return t?`/store/objects/${t}`:null;case`document`:return t?`/store/objects/${t}`:null;case`collection`:return t?`/store/collections/${t}`:null;default:return null}}function qn({rawUrl:e,artifactRunId:t,disposition:n=`inline`}){let{client:r}=Ee(),i=Jt(),a=I(r);a.current=r;let o=I(i);o.current=i;let{scheme:s,path:c}=X(e),l=Kn(s,c),[u,d]=L(()=>{if(l)return{url:l,isLoading:!1,error:void 0};if(s===`standard`)return{url:e,isLoading:!1,error:void 0};if(i&&(s===`artifact`||s===`image`)){let e;e=s===`artifact`&&t&&!Yt(c)?Xt(t,c,n):Zt(c);let r=i.getUrl(e);if(r)return{url:r,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),f=M(async()=>{if(l||s===`standard`)return;if(s!==`artifact`&&s!==`image`){d({url:void 0,isLoading:!1,error:`Unknown scheme: ${s}`});return}d(e=>({...e,isLoading:!0,error:void 0}));let e=a.current,r=o.current;try{let i;if(s===`artifact`)if(t&&!Yt(c)){let a=Xt(t,c,n);i=r?await r.getOrFetch(a,async()=>(await e.files.getArtifactDownloadUrl(t,c,n)).url):(await e.files.getArtifactDownloadUrl(t,c,n)).url}else{let t=Zt(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}else{let t=Zt(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}d({url:i,isLoading:!1,error:void 0})}catch(e){let t=e instanceof Error?e.message:`Failed to resolve URL`;console.error(`Failed to resolve URL:`,c,e),d({url:void 0,isLoading:!1,error:t})}},[s,c,t,n,l]);P(()=>{if(u.url&&!u.error)return;let e=!1;return e||(async()=>{await f()})(),()=>{e=!0}},[f,u.url,u.error]);let p=M(()=>{d({url:void 0,isLoading:!0,error:void 0}),f()},[f]);return{url:u.url,isLoading:u.isLoading,error:u.error,scheme:s,retry:p}}function Jn({src:e,alt:r,caption:i,className:a,artifactRunId:o}){let s=e||``,{scheme:c}=X(s);return c===`standard`?n(`figure`,{className:`my-4`,children:[t(`img`,{src:e,alt:r,className:a}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):t(Yn,{rawSrc:s,alt:r,caption:i,artifactRunId:o,className:a})}function Yn({rawSrc:e,alt:r,caption:i,artifactRunId:a,className:o}){let{url:s,isLoading:c,error:l,retry:u}=qn({rawUrl:e,artifactRunId:a,disposition:`inline`});return c?t(J,{type:`image`,message:r?`Loading ${r}...`:void 0}):l?t(J,{type:`image`,error:l,onRetry:u}):s?n(`figure`,{className:`my-4`,children:[t(`img`,{src:s,alt:r,className:o}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):null}function Xn({node:e,src:n,alt:r,className:i,artifactRunId:a,ExistingImg:o,...s}){let c=n||``,{scheme:l}=X(c);return l===`standard`?typeof o==`function`?t(o,{node:e,src:n,alt:r,...s}):t(`img`,{src:n,alt:r,className:i,...s}):t(Zn,{rawSrc:c,alt:r,artifactRunId:a,className:i,rest:s})}function Zn({rawSrc:e,alt:n,artifactRunId:r,className:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=qn({rawUrl:e,artifactRunId:r,disposition:`inline`});return s?t(J,{type:`image`,message:n?`Loading ${n}...`:void 0}):c?t(J,{type:`image`,error:c,onRetry:l}):o?t(`img`,{src:o,alt:n,className:i,...a}):null}function Qn({node:e,href:n,children:r,className:i,artifactRunId:a,ExistingLink:o,...s}){let c=n||``,{scheme:l,path:u}=X(c),d=Kn(l,u);return d?typeof o==`function`?t(o,{node:e,href:d,...s,children:r}):t(`a`,{href:d,...s,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):l===`standard`?typeof o==`function`?t(o,{node:e,href:n,...s,children:r}):t(`a`,{href:n,...s,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):t($n,{rawHref:c,artifactRunId:a,className:i,rest:s,children:r})}function $n({rawHref:e,artifactRunId:n,className:r,children:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=qn({rawUrl:e,artifactRunId:n,disposition:`attachment`});return s?t(`span`,{className:`inline-flex items-center gap-1 text-muted`,children:t(J,{type:`link`})}):c?t(`span`,{className:`inline-flex items-center gap-1`,children:t(J,{type:`link`,error:c,onRetry:l})}):t(`a`,{href:o||`#`,...a,className:r,target:`_blank`,rel:`noopener noreferrer`,children:i})}const er=[`artifact:`,`image:`,`store:`,`document://`,`collection:`],tr=/(!?\[[^[\]\n]*\]\()((?:artifact:|image:|store:|document:\/\/|collection:)[^)[\n]+)(\))/g,nr=/`[^`\n]*`/g,rr=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,ir=/\s+("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\([^)]*\))\s*$/;function ar(e){return er.some(t=>e.startsWith(t))}function or(e){let t=e.trim();if(t.startsWith(`<`)){let n=t.indexOf(`>`);if(n>0&&ar(t.slice(1,n).trim()))return e}let n=t.match(ir)?.index??-1,r=(n>=0?t.slice(0,n):t).trim(),i=n>=0?t.slice(n):``;return ar(r)?`<${r}>${i}`:e}function sr(e){return e.replace(tr,(e,t,n,r)=>`${t}${or(n)}${r}`)}function cr(e){let t=``,n=0;for(let r of e.matchAll(nr))t+=sr(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=sr(e.slice(n)),t}function lr(e){if(!e||!er.some(t=>e.includes(t)))return e;let t=``,n=0;for(let r of e.matchAll(rr))t+=cr(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=cr(e.slice(n)),t}const ur=/^([ \t]*):::([^\n]*?):::[ \t]*$/gm,dr=/^\w+/;function fr(e){return e?.includes(`:::`)?e.replace(ur,(e,t,n)=>{let r=n.trim(),i=dr.exec(r);if(!i)return e;let a=i[0],o=r.slice(a.length).trim();return o?`${t}:::${a}\n${t}${o}\n${t}:::`:`${t}::${a}`}):e}const pr=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,mr=/`[^`\n]*`/g,hr=/\\\$/g,gr=/\\[^\s]/,_r=/[{}]/,vr=/[_^][\w{]/,yr=/^[a-zA-Z]$/,br=/^[a-zA-Z]\s*=/,xr=/^\s/,Sr=/\s$/,Cr=/[+*/-]$/,wr=/\^[+-]$/;function Tr(e){return gr.test(e)||_r.test(e)||vr.test(e)||yr.test(e)||br.test(e)}function Er(e){return!!(xr.test(e)||Sr.test(e)||Cr.test(e)&&!wr.test(e))}function Dr(e){let t=[];for(let n=0;n<e.length;n++)if(e[n]===`$`&&!(n>0&&e[n-1]===`\\`)){if(n+1<e.length&&e[n+1]===`$`){n++;continue}n>0&&e[n-1]===`$`&&(n<2||e[n-2]!==`\\`)||t.push(n)}return t}function Or(e,t,n){let r=e.slice(t+1,n);return r.length===0||r.includes(`
6
+ `)?null:r}function kr(e){let t=Dr(e);if(t.length<2)return e;let n=new Set,r=new Set,i=Array(t.length-1);for(let n=0;n<t.length-1;n++)i[n]=Or(e,t[n],t[n+1]);let a=[];for(let e=0;e<t.length-1;e++){if(n.has(e))continue;let r=i[e];r!==null&&Tr(r)&&(n.add(e),n.add(e+1),a.push([t[e],t[e+1]]))}let o=0;for(;o<t.length;){if(n.has(o)){o++;continue}let e=o+1;for(;e<t.length&&n.has(e);)e++;if(e>=t.length)break;if(e>o+1){r.add(t[o]),o++;continue}let a=i[o];if(a===null){o++;continue}Er(a)&&(r.add(t[o]),r.add(t[e])),n.add(o),n.add(e),o=e+1}for(let e=0;e<t.length;e++)n.has(e)||e+1<t.length&&n.has(e+1)&&r.add(t[e]);if(r.size===0&&a.length===0)return e;let s=[],c=0,l=Array.from(r).sort((e,t)=>e-t),u=0,d=0;for(;u<l.length||d<a.length;){let t=u<l.length?l[u]:1/0;if(t<(d<a.length?a[d][0]:1/0))t>c&&s.push(e.slice(c,t)),s.push(`\\$`),c=t+1,u++;else{let[t,n]=a[d];t>c&&s.push(e.slice(c,t));let r=e.slice(t,n+1);for(s.push(r.replace(hr,`\\text{\\textdollar}`)),c=n+1;u<l.length&&l[u]<=n;)u++;d++}}return c<e.length&&s.push(e.slice(c)),s.join(``)}function Ar(e){let t=[],n=0;for(let r of e.matchAll(mr))t.push(kr(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(kr(e.slice(n))),t.join(``)}function jr(e){if(!e?.includes(`$`))return e;let t=[],n=0;for(let r of e.matchAll(pr))t.push(Ar(e.slice(n,r.index))),t.push(r[0]),n=r.index+r[0].length;return t.push(Ar(e.slice(n))),t.join(``)}const Mr={note:`md-callout-info`,tip:`md-callout-info`,warning:`md-callout-attention`,important:`md-callout-attention`,caution:`md-callout-destructive`},Nr={note:`Note`,tip:`Tip`,warning:`Warning`,important:`Important`,caution:`Caution`};function Pr(){return e=>{He(e,e=>{if(e.type!==`containerDirective`&&e.type!==`leafDirective`&&e.type!==`textDirective`)return;let t=e;t.data||={};let n=t.data,r=t.attributes||{},i=t.name;if(i===`pagebreak`){n.hName=`hr`,n.hProperties={className:`md-pagebreak`};return}if(i===`columns`){n.hName=`div`,n.hProperties={className:`md-columns`};return}if(i===`column`){n.hName=`div`;let e={className:`md-column`};r.width&&(e.style=`flex-basis:${r.width};flex-grow:0;flex-shrink:0`),n.hProperties=e;return}if(i in Mr){n.hName=`div`,n.hProperties={className:`md-callout ${Mr[i]}`,"data-callout-type":i};let e=Nr[i];if(e&&t.children){let n={type:`paragraph`,data:{hName:`p`,hProperties:{className:`md-callout-title`}},children:[{type:`text`,value:e}]};t.children.unshift(n)}return}n.hName=`div`,n.hProperties={className:`md-${i}`,...Object.fromEntries(Object.entries(r).filter(([e])=>e!==`class`))},r.class&&(n.hProperties.className+=` ${r.class}`)})}}const Fr=[`artifact:`,`image:`,`store:`,`document:`,`document://`,`collection:`];function Ir(e){return Fr.some(t=>e.startsWith(t))?e:Me(e)}function Lr(){return e=>{He(e,`html`,(e,t,n)=>{let r=e,i=n;if(typeof r.value==`string`&&/<!--[\s\S]*?-->/.test(r.value)&&i?.children&&typeof t==`number`)return i.children.splice(t,1),[Ve,t]})}}const Rr=Wn();function zr({children:e,components:n,remarkPlugins:r=[],removeComments:i=!0,artifactRunId:a,className:o,codeClassName:s,inlineCodeClassName:c,linkClassName:l,imageClassName:u,onProposalSelect:d,onProposalSubmit:f}){let p=Dn(),m=k.useMemo(()=>fr(lr(jr(e))),[e]),h=t(pn,{artifactRunId:a,onProposalSelect:d,onProposalSubmit:f,MarkdownRenderer:zr,children:t(je,{remarkPlugins:k.useMemo(()=>{let e=[Le,Ie,Pr,Re,Fe,Be,ze,...r];return i&&e.push(Lr),e},[r,i]),rehypePlugins:k.useMemo(()=>[Ne],[]),remarkRehypeOptions:k.useMemo(()=>({handlers:{...Pe}}),[]),components:k.useMemo(()=>{let e=n||{},r=e.code,i=e.a,o=e.img,d=({node:e,className:n,children:i,...a})=>{let o=/language-([\w-]+)/.exec(n||``),l=!o,u=o?o[1]:``;if(!l&&u){if(p){let e=p.getComponent(u);if(e)return t(e,{code:String(i||``).trim(),language:u})}if(Un(u))return t(Hn,{code:String(i||``).trim(),language:u});let e=Rr[u];if(e)return t(e,{code:String(i||``).trim(),language:u})}return typeof r==`function`?t(r,{node:e,className:n,...a,children:i}):t(`code`,{...a,className:l?`px-1.5 py-0.5 rounded ${c||``}`:` ${s||``}`,children:i})},f=e=>{let{node:n,href:r,children:o,...s}=e;return t(Qn,{node:n,href:r,className:l,artifactRunId:a,ExistingLink:typeof i==`function`?i:void 0,...s,children:o})},m=e=>{let{node:n,src:r,alt:i,title:s,...c}=e;return s?t(Jn,{src:r,alt:i,caption:s,className:u,artifactRunId:a}):t(Xn,{node:n,src:r,alt:i,className:u,artifactRunId:a,ExistingImg:typeof o==`function`?o:void 0,...c})};return{...e,code:d,a:f,img:m}},[n,a,p,s,c,l,u]),urlTransform:Ir,children:m})});return o?t(`div`,{className:`md-content ${o}`,children:h}):t(`div`,{className:`md-content`,children:h})}function Br({percent:e}){return t(`div`,{className:`w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700`,children:t(`div`,{className:`bg-blue-600 h-2.5 rounded-full`,style:{width:`${e}%`}})})}function Vr({className:e,properties:r}){return t(f,{className:e,children:t(`tbody`,{children:r.map(e=>n(`tr`,{children:[n(`td`,{className:`w-1/3 font-semibold gap-2`,children:[t(`span`,{children:e.name}),e.description&&t(p,{description:e.description,placement:`top`,children:t(se,{className:`size-3 ms-2 text-muted-foreground`})})]}),t(`td`,{className:`w-2/3`,children:e.value??`undefined`})]},e.name))})})}function Hr({content:e,...n}){let r=I(null);return P(()=>{if(!r.current)return;let t=new DOMParser().parseFromString(e,`image/svg+xml`).querySelector(`svg`);if(!t){console.warn(`SvgIcon: No <svg> element found in provided string`),r.current.innerHTML=``;return}Object.entries(n).forEach(([e,n])=>{if(n==null)return;let r=e===`className`?`class`:e;t.setAttribute(r,String(n))}),r.current.innerHTML=``,r.current.appendChild(t)}),t(`span`,{ref:r})}function Ur(e){return n=>t(Hr,{content:e,...n})}function Wr(e){return{name:e.getNameSignature(),type:e.getTypeSignature(),description:e.description}}var Z;(function(e){e.string=`string`,e.number=`number`,e.integer=`integer`,e.boolean=`boolean`,e.object=`object`,e.any=`any`,e.text=`text`,e.media=`media`,e.document=`document`})(Z||={});function Gr(e){e=e.trim();let t=!1,n=!1;e.endsWith(`?`)&&(n=!0,e=e.substring(0,e.length-1).trim()),e.endsWith(`[]`)&&(t=!0,e=e.substring(0,e.length-2).trim());let r=Z[e];if(!r)throw Error(`Unknown type "${e}"`);return{name:r,isArray:t,isNullable:n,isObject:r===Z.object}}function Kr(){let e=Object.values(Z),t=[...e];for(let n of e)t.push(`${n}[]`);return e.sort(),t}const qr=Kr();function Jr({value:e,onChange:i,onCancel:a,onSave:o}){let{t:s}=R(),[c,l]=L(!1);return e?n(`div`,{className:`flex items-center`,children:[t(`div`,{className:`flex-1`,children:t(Yr,{value:e.name,onChange:t=>{i({...e,name:t})},onCancel:a,onSave:o})}),t(`div`,{className:`px-1 font-semibold`,children:`:`}),t(`div`,{className:`flex-1`,children:t(Xr,{value:e.type,onChange:t=>{i({...e,type:t})},onCancel:a,onSave:o})}),n(`div`,{children:[t(r,{variant:`ghost`,size:`xs`,onClick:()=>l(!0),title:s(`widgets.schema.editDescription`),children:t(S,{className:`size-4`})}),t(Zr,{value:e.description,isOpen:c,onClose:t=>{t!==void 0&&typeof t==`string`&&i({...e,description:t},!0),l(!1)}})]})]}):null}function Yr({value:e,onChange:n,onCancel:r,onSave:i}){let a=I(null);return P(()=>{a.current?.focus()},[]),t(`input`,{onKeyUp:e=>{switch(e.key){case`Enter`:i?.();break;case`Escape`:r?.();break}},ref:a,value:e,onChange:e=>{n(e.target.value)},className:d.INPUT_UNSTYLED,style:{fontSize:`inherit`,width:``,display:`inline`}})}function Xr({value:e,onChange:n,onCancel:r,onSave:i}){return t(u,{className:d.INPUT_UNSTYLED,options:qr,value:e||``,onBlur:()=>{i?.()},onChange:n,onKeyDown:(e,t)=>{t||(e.key===`Enter`?i?.():e.key===`Escape`&&r?.())},popupClass:`schema-type-suggest-popup z-90`})}function Zr({value:e,isOpen:r,onClose:i}){let{t:a}=R();return n(o,{isOpen:r,onClose:i,children:[t(l,{children:a(`widgets.schema.editDescription`)}),t(Qr,{value:e,onSave:i})]})}function Qr({value:i,onSave:a}){let{t:o}=R(),l=I(null),[u,d]=L(i||``);return P(()=>{l.current?.focus()},[]),n(e,{children:[t(s,{className:`h-max`,children:t(`textarea`,{ref:l,className:`dark:bg-gray-800 w-full h-full dark:text-white`,value:u,onChange:e=>d(e.target.value)})}),t(c,{children:t(r,{onClick:()=>a(u),children:o(`store.saveChanges`)})})]})}function $r({value:e}){return e?n(`div`,{className:`w-full flex items-baseline`,children:[t(`div`,{children:e.name||``}),t(`div`,{className:`ms-2 text-sm text-muted`,children:e.type||``})]}):null}function ei(e,t,n){if(e.properties){let r=e.properties,i={};for(let e of Object.keys(r)){let a=r[e];e===t?i[n]=a:i[e]=a}e.properties=i}e.required&&=e.required.map(e=>e===t?n:e)}function ti(e,t,n){if(Array.isArray(e.required)){let r=e.required.indexOf(t);n?r<0&&e.required.push(t):r>-1&&e.required.splice(r,1)}else n&&(e.required=[t])}function ni(e,t){let n=t.name===`any`?void 0:t.isNullable?[t.name,`null`]:t.name;if(t.isArray)if(e.type=`array`,e.properties=void 0,!e.items||Array.isArray(e.items))e.items={type:n,properties:t.isObject?{}:void 0};else{let r=e.items;r.type=n,t.isObject&&!r.properties&&(r.properties={})}else e.type=n,e.items=void 0,t.isObject?e.properties||={}:e.properties=void 0}function ri(e,t){e.properties&&(delete e.properties[t],Array.isArray(e.required)&&(e.required=e.required.filter(e=>e!==t)))}function ii(e,t,n,r=!1){if(e.type!==`object`)throw Error(`Cannot add property to a non-object schema`);e.properties||={};let i={};return ni(i,n),e.properties[t]=i,r&&(Array.isArray(e.required)?ci(e.required,t):e.required=[t]),i}function ai(e){let t=!1,n=!1,r,i=e.type;if(Array.isArray(i))for(let e of i)e===`null`?t=!0:r||=e;else r=i;r||=`any`,r===`array`&&(n=!0,r=oi(e.items));let a=r;switch(e.editor){case`textarea`:a=`text`;break;case`media`:a=`media`;break;case`document`:a=`document`;break}return{isNullable:t,isArray:n,isObject:r===`object`,name:a}}function oi(e){if(!e)return`any`;let t;return t=si(Array.isArray(e)?e[0].type:e.type),(t===`array`||t===`null`)&&(t=`any`),t}function si(e){return e?Array.isArray(e)?e.find(e=>e!==`null`)||`any`:e:`any`}function ci(e,t){e.includes(t)||e.push(t)}let li=0;var ui=class e{source;onChange=()=>{};schema;root;constructor(e,t){e?typeof e==`string`?this.schema=JSON.parse(e):this.schema=e:this.schema={title:t,type:`object`,properties:{}},this.schema.properties||(this.schema.properties={}),this.root=new di(``,this.schema,this),this.root.loadChildren()}get isEmpty(){return!this.root.children||this.root.children.length===0}get children(){return this.root.children??[]}reload(){return this.root=new di(``,this.schema,this),this.root.loadChildren(),this.onChange?.(this),this}withSource(e,t){return this.source={uri:t,name:e},this}withChangeListener(e){return this.onChange=e,this}replaceSchema(e){e?this.schema=e:this.schema={title:this.schema.title,type:`object`,properties:{}},this.reload()}clone(){let t=new e(this.schema);return t.source=this.source,this.onChange&&t.withChangeListener(this.onChange),t}},di=class e{schema;loader;parent;name;isRequired=!1;type;children;constructor(e,t,n,r){if(this.schema=t,this.loader=n,this.parent=r,this.name=e,this.type=ai(t),this.parent){let t=this.parent._getPropertiesSchema().required;this.isRequired=t&&Array.isArray(t)?t.includes(e):!1}}get title(){return typeof this.schema.title==`string`?this.schema.title:void 0}set title(e){this.schema.title=e}get description(){return this.schema.description}set description(e){this.schema.description=e}get isParent(){return this.type.isObject}get isNew(){return!!this.schema.isNew}set isNew(e){e?this.schema.isNew=!0:delete this.schema.isNew}resetIsNew(){let e=this.isNew;return this.isNew=!1,e}getNameSignature(){return`${this.name}${this.isRequired?``:`?`}`}getTypeSignature(){return`${this.type.name}${this.type.isArray?`[]`:``}${this.type.isNullable?`?`:``}`}getSignature(){return`${this.getNameSignature()}: ${this.getTypeSignature()}`}reloadTree(){this.loader.reload()}loadChildren(){this.children=[];let e=this.schema.items?.properties;this.schema.items&&e?this._loadChildren(e,this.children):this.schema.properties&&this._loadChildren(this.schema.properties,this.children)}_loadChildren(t,n){for(let r of Object.keys(t)){let i=t[r],a=new e(r,i,this.loader,this);n.push(a),a.isParent&&a.loadChildren()}}_getPropertiesSchema(){return this.type.isArray&&this.type.isObject?this.schema.items:this.schema}findAvailableChildName(e){let t=this._getPropertiesSchema().properties||{},n;do n=e+ ++li;while(t[n]);return n}addChild(t,n,r=!1){if(!this.type.isObject)throw Error(`Cannot add child to a non object node`);this.children||=[];let i=ii(this._getPropertiesSchema(),t,n,r),a=new e(t,i,this.loader,this);return this.children.push(a),a}remove(){return this.parent?.type.isObject?(ri(this.parent._getPropertiesSchema(),this.name),this.parent.children&&(this.parent.children=this.parent.children.filter(e=>e.name!==this.name)),!0):!1}update(e){let t=!1;e.name!=null&&this.name!==e.name&&(this.parent&&ei(this.parent._getPropertiesSchema(),this.name,e.name),this.name=e.name,t=!0),e.isRequired!=null&&this.isRequired!==e.isRequired&&(this.parent&&ti(this.parent._getPropertiesSchema(),this.name,e.isRequired),this.isRequired=e.isRequired,t=!0);let n=e.type?.name;n===`any`&&(n=void 0);let r=n!==this.schema.type;return e.type&&(ni(this.schema,e.type),this.type=e.type,this.type.isObject?this.children||=[]:this.children=void 0,t=!0),this.schema.editor&&e.editor===null?(this.schema.editor=void 0,t=!0):e.editor?(this.schema.editor=e.editor,t=!0):r&&(this.schema.editor=void 0,t=!0),e.description!==this.description&&(this.description=e.description,t=!0),t}getUpdateFromNameAndTypeSignature(e,t){let n=e.trim(),r=!0;n.endsWith(`?`)&&(n=n.substring(0,n.length-1).trim(),r=!1);let i=Gr(t),a;return i.name===`text`?(i.name=Z.string,a=`textarea`):i.name===`media`?(i.name=Z.any,a=`media`):i.name===`document`?(i.name=Z.any,a=`document`):a=null,{name:n,type:i,isRequired:r,editor:a}}updateFromNameAndTypeSignature(e,t){return this.update(this.getUpdateFromNameAndTypeSignature(e,t))}updateFromSignature(e){e=e.trim();let t=e.indexOf(`:`);if(t<0)throw Error(`Expecting a name and a type separated by a colon`);let n=e.substring(0,t),r=e.substring(t+1);return this.updateFromNameAndTypeSignature(n,r)}};function fi(e){let[t,n]=L(new ui(e||{type:`object`,properties:{}}).withChangeListener(e=>{n(e.clone())}));return t}const pi=`block text-sm sm:leading-6 rounded-md border-0 py-1.5 px-4`,mi=`${pi} hover:shadow-xs hover:ring-1 hover:ring-inset hover:ring-ring`,hi=`${pi} shadow-xs ring-1 ring-inset ring-ring`;function gi({value:e,onChange:r,onDelete:i,outlineOnHover:a=!1,editOnClick:o=!0,placeholder:s,viewer:c,editor:l,skipClickOutside:u,isEditing:d=!1,readonly:f=!1,onValidate:p}){let{on:m,off:h,isOn:_}=g(d),[v,y]=L();return n(`div`,{className:``,children:[_&&!f?t(vi,{value:e,onSave:e=>{if(p){let t=p(e);if(t){y(t);return}else y(void 0)}r(e)&&h()},onCancel:h,editor:l,skipClickOutside:e=>u?u(e):!1}):t(_i,{value:e,onEdit:m,viewer:c,placeholder:s,outlineOnHover:a,editOnClick:o,onDelete:i,readonly:f}),v&&t(`div`,{className:`text-red-500 text-sm`,children:v})]})}function _i({viewer:e,value:i,onEdit:a,editOnClick:o,outlineOnHover:s,placeholder:c,onDelete:l,readonly:u}){let d=()=>{o&&a()},f=e=>{e.key===`Enter`&&a()},p=`invisible group-hover:visible`;return n(`div`,{role:o?`button`:void 0,tabIndex:0,onKeyUp:f,onClick:d,className:y(`flex justify-start items-center group`,s?mi:pi,{"cursor-pointer":o}),children:[t(e,{value:i,placeholder:c}),n(`div`,{className:`ms-auto flex gap-2`,children:[!u&&l&&t(r,{variant:`ghost`,size:`sm`,className:p,onClick:l,children:t(me,{className:`size-4`})}),u?null:t(r,{variant:`ghost`,size:`sm`,className:p,onClick:a,children:t(O,{className:`size-4`})})]})]})}function vi({editor:e,value:n,onSave:r,onCancel:i,skipClickOutside:a}){let[o,s]=L(n),c=I(n),[l,u]=L(null),d=()=>{r(c.current)};return t(`div`,{ref:h(d,a),children:t(`div`,{className:hi,children:t(`div`,{className:`w-full`,onClick:e=>e.stopPropagation(),children:t(e,{value:o,onChange:(e,t=!1)=>{s(e),c.current=e,t&&(l&&clearTimeout(l),u(setTimeout(()=>{r(e)},500)))},onSave:d,onCancel:i})})})})}function yi(e){return!!e.target.closest?.(`.schema-type-suggest-popup`)}function bi({schema:e,readonly:r=!1}){return n(`ul`,{className:``,children:[e.children.map(e=>xi(e,r)),r?null:t(Ei,{parent:e.root})]})}function xi(e,n){return e.isParent?t(Ci,{property:e,readonly:n},e.name):t(Si,{node:e,readonly:n},e.name)}function Si({node:e,readonly:n}){return t(`li`,{children:t(Ti,{property:e,readonly:n})})}function Ci({property:e,readonly:i}){let[a,o]=L(!0),s=a?te:T;return n(`li`,{children:[n(`div`,{className:`flex items-center w-full`,children:[t(r,{variant:`ghost`,size:`icon`,onClick:()=>o(!a),"aria-label":a?`Collapse ${e.name}`:`Expand ${e.name}`,"aria-expanded":a,children:t(s,{className:`size-4 cn-rtl-flip`})}),t(`div`,{className:`flex-1`,children:t(Ti,{property:e,readonly:i})})]}),a&&n(`ul`,{className:`ms-4 border-s border-gray-400 border-dashed`,children:[(e.children||[]).map(e=>xi(e,i)),i?null:t(Ei,{parent:e})]})]})}function wi(e){if(!e)return`Name is required`;if(!/^[a-zA-Z0-9_]+[?]?$/.test(e))return`Only letters, numbers, underscores or question mark are allowed (a-zA-Z0-9_?)`}function Ti({property:e,readonly:n}){let{t:r}=R(),i=v(),a=t=>{try{t.description&&typeof t.description!=`string`&&(t.description=void 0);let n=e.getUpdateFromNameAndTypeSignature(t.name,t.type);e.update({...n,description:t.description})&&e.reloadTree()}catch(e){return i({status:`error`,title:r(`widgets.schema.invalidPropertyDeclaration`),description:m(e),duration:9e3}),!1}return!0},o=e.resetIsNew();return t(gi,{value:Wr(e),onChange:a,onDelete:()=>{e.remove(),e.reloadTree()},editor:Jr,viewer:$r,outlineOnHover:!0,isEditing:o,skipClickOutside:yi,readonly:n,onValidate:e=>wi(e.name)})}function Ei({parent:e}){return n(r,{variant:`ghost`,onClick:()=>{let t=e.findAvailableChildName(`new_property_`),n=e.addChild(t,{isObject:!1,isArray:!1,isNullable:!1,name:Z.string},!0);n.isNew=!0,e.reloadTree()},children:[t(fe,{className:`size-4`}),`Add property`]})}function Di(e){return e.isFile}function Oi(e){return e.isDirectory}function ki({onDrop:e,message:i,buttonLabel:a,allowFolders:o=!0,className:s=``}){let{t:c}=R(),l=a??c(`upload.uploadFiles`),[u,d]=L(!1),f=I(null),p=e=>{e.preventDefault(),e.dataTransfer.types.includes(`Files`)&&d(!0)},m=e=>{e.preventDefault(),f.current&&!f.current.contains(e.relatedTarget)&&d(!1)},h=async t=>{if(t.preventDefault(),d(!1),t.dataTransfer.items&&t.dataTransfer.items.length>0){let n=Array.from(t.dataTransfer.items),r=[],i=new Set,a=async e=>{if(Di(e)){let t=await new Promise(t=>{e.file(n=>{Object.defineProperty(n,"webkitRelativePath",{writable:!0,value:e.fullPath.substring(1)}),t(n)})});!t.name.startsWith(`.`)&&t.size>0&&r.push(t);let n=e.fullPath.substring(1).split(`/`).slice(0,-1).join(`/`);n&&i.add(n)}else if(Oi(e)){let t=e.createReader(),n=await new Promise(e=>{t.readEntries(t=>{e(t)})});await Promise.all(n.map(a));let r=e.fullPath.substring(1);r&&i.add(r)}};try{if(await Promise.all(n.map(e=>{let t=e.webkitGetAsEntry?e.webkitGetAsEntry():e;return t?a(t):Promise.resolve()})),r.length>0){let t=new Set(Array.from(i).map(e=>e.split(`/`)[0]).filter(Boolean)).size,n=r.length,a=``;a=t>0?c(`upload.preparingFolder`,{count:t,folderCount:t,fileCount:n}):c(`upload.preparingFiles`,{count:n}),e(r,{count:r.length,message:a})}}catch(n){console.error(`Error processing dropped files:`,n);let r=Array.from(t.dataTransfer.files);r.length>0&&e(r)}}else t.dataTransfer.files&&t.dataTransfer.files.length>0&&e(Array.from(t.dataTransfer.files))},g=t=>{if(t&&t.length>0){let n=Array.from(t);if(n.some(e=>e.webkitRelativePath?.includes(`/`))){let t=new Set(n.map(e=>e.webkitRelativePath.split(`/`)[0]).filter(Boolean)).size,r=n.length,i=c(`upload.preparingFolder`,{count:t,folderCount:t,fileCount:r});e(n,{count:n.length,message:i})}else e(n,{count:n.length,message:c(`upload.preparingFiles`,{count:n.length})})}};return n(`div`,{className:`flex flex-col items-center justify-center py-12 border-2 rounded-lg transition-colors ${u?`border-color-primary bg-color-primary/10`:`border-dashed border-color-border`} ${s}`,onDragOver:p,onDragLeave:m,onDrop:h,children:[t(he,{className:`h-12 w-12 mb-3 transition-colors ${u?`text-primary`:`text-muted/50`}`}),t(`p`,{className:`text-muted`,children:i}),n(`div`,{className:`flex gap-2 justify-center mt-2`,children:[t(r,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`*`,e?.click(),e.onchange=()=>{g(e.files)}},children:l}),o&&t(r,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`*`,e.webkitdirectory=!0,e?.click(),e.onchange=()=>{g(e.files)}},children:c(`upload.selectFolder`)})]})]})}function Q({title:e,count:r,icon:i=t(w,{className:`h-4 w-4 text-green-500`}),items:a}){let{t:o}=R(),[s,c]=L(!1),l=ve();return n(`div`,{className:`border border-color-border rounded-md overflow-hidden`,children:[n(`button`,{type:`button`,"aria-expanded":s,"aria-controls":l,className:`w-full flex items-center justify-between p-3 bg-color-muted/10 cursor-pointer text-start bg-transparent border-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,onClick:()=>c(!s),children:[n(`span`,{className:`flex items-center`,children:[t(`span`,{className:`me-2`,children:i}),t(`span`,{className:`font-medium`,children:e}),t(`span`,{className:`ms-2 px-2 py-0.5 bg-color-muted/20 rounded-full text-xs`,children:r})]}),t(`span`,{className:`text-muted`,"aria-hidden":`true`,children:t(`svg`,{className:`h-5 w-5 transition-transform ${s?`transform rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})})]}),s&&t(`div`,{id:l,className:`p-3 border-t border-color-border max-h-48 overflow-y-auto`,children:a.length>0?t(`ul`,{className:`space-y-1`,children:a.map(e=>t(`li`,{className:`text-sm py-1 px-2 rounded hover:bg-color-muted/10`,children:e},e))}):t(`div`,{className:`text-sm text-muted py-2`,children:o(`upload.noItems`)})})]})}function Ai({files:e,className:r=``,location:i,collection:a}){let{t:o}=R(),s=e.filter(e=>e.status===`success`),c=e.filter(e=>e.status===`updated`),l=e.filter(e=>e.status===`skipped`),u=e.filter(e=>e.status===`failed`),d=s.length,f=c.length,p=l.length,m=u.length,h=e.length;return n(`div`,{className:`flex flex-col py-2 ${r}`,children:[n(`div`,{className:`flex items-center mb-4`,children:[t(`div`,{className:`size-8 me-4 rounded-full bg-success/10 flex items-center justify-center`,children:t(w,{className:`size-4 text-success`})}),t(`div`,{children:n(`p`,{className:`text-muted`,children:[o(`upload.filesProcessed`,{count:h}),a?o(`upload.inCollection`,{collection:a}):``,i?o(`upload.inFolder`,{location:i}):``]})})]}),n(`div`,{className:`space-y-3 mt-2`,children:[d>0&&t(Q,{title:o(`upload.successfullyUploaded`),count:d,icon:t(w,{className:`h-4 w-4 text-green-500`}),items:s.map(e=>e.name)}),f>0&&t(Q,{title:o(`upload.successfullyUpdated`),count:f,icon:t(w,{className:`h-4 w-4 text-blue-500`}),items:c.map(e=>e.name)}),p>0&&t(Q,{title:o(`upload.skippedAlreadyExisted`),count:p,icon:t(x,{className:`h-4 w-4 text-amber-500`}),items:l.map(e=>e.name)}),m>0&&t(Q,{title:o(`upload.failedToUpload`),count:m,icon:t(_e,{className:`h-4 w-4 text-red-500`}),items:u.map(e=>e.name)})]})]})}const ji=`#text`,Mi=`#comment`,Ni=`#cdata`,Pi=`DECLARATION_TAG`,Fi={tagColor:`#d43900`,textColor:`#333`,attributeKeyColor:`#2a7ab0`,attributeValueColor:`#008000`,separatorColor:`#333`,commentColor:`#aaa`,cdataColor:`#1d781d`,fontFamily:`monospace`},Ii={attributeKeyColor:`#FFD700`,attributeValueColor:`#FF4500`,tagColor:`#87CEFA`,textColor:`#00FF00`,separatorColor:`#FFD700`,commentColor:`#BEBEBE`,cdataColor:`#33CC66`,fontFamily:`monospace`},Li=A({theme:Fi,collapsible:!1,indentSize:2}),$=()=>N(Li),Ri=new Ue({preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:``,allowBooleanAttributes:!0,commentPropName:Mi,cdataPropName:Ni,parseTagValue:!1});function zi(e){return F(()=>{try{let t=We.validate(e);if(t!==!0)throw Error(t.err.msg||`Invalid XML!`);let n=Ri.parse(e);if(typeof e==`string`&&e.trim().length>0&&n.length===0)throw Error(`Invalid XML!`);return{json:n,valid:!0}}catch(e){return{json:null,valid:!1,errorMessage:`Fail to parse: ${e.message}`}}},[e])}function Bi(e){let{indentation:r,children:i,isInline:a}=e,{theme:o}=$();return n(`div`,{style:{color:o.cdataColor},children:[t(`span`,{children:`${r}<![CDATA[`}),i,t(`span`,{children:`${a?``:r}]]>`})]})}function Vi(e){let{collapsible:n,theme:r}=$(),{collapsed:i}=e;return n?t(`span`,{style:{position:`relative`},children:t(`span`,{style:{position:`absolute`,right:`0`,border:0,padding:0,background:`none`},children:t(Hi,{fill:r.separatorColor,style:{transform:`rotate(${i?0:90}deg)`,transition:`transform 0.2s`}})})}):null}function Hi({...e}){return t(`svg`,{width:`16px`,height:`16px`,viewBox:`0 0 24 24`,"aria-hidden":`true`,...e,children:t(`path`,{d:`M9 17.898C9 18.972 10.2649 19.546 11.0731 18.8388L17.3838 13.3169C18.1806 12.6197 18.1806 11.3801 17.3838 10.6829L11.0731 5.16108C10.2649 4.45388 9 5.02785 9 6.1018V17.898Z`})})}function Ui(e){let{collapsible:t,initialCollapsedDepth:n}=$(),[r,i]=L(()=>Ge(n)||!t?!1:e>=n);return P(()=>{i(Ge(n)||!t?!1:e>=n)},[n,e,t]),{collapsed:r,buttonProps:t?{onClick:()=>i(e=>!e),role:`button`,style:{cursor:`pointer`}}:{}}}function Wi(e){let{indentation:r,children:i,isInline:a,level:o}=e,{theme:s}=$(),{collapsed:c,buttonProps:l}=Ui(o);return n(`div`,{style:{color:s.commentColor},children:[n(`span`,{...l,children:[t(`span`,{children:r}),t(Vi,{collapsed:c}),t(`span`,{children:`<!-- `})]}),!c&&i,c&&`...`,t(`span`,{children:`${a||c?` `:r}-->`})]})}function Gi(e){let{attributes:r}=e,{theme:i}=$();return r?t(`span`,{children:Object.entries(r).map(([e,r])=>n(`span`,{children:[t(`span`,{style:{color:i.attributeKeyColor},children:` ${e}`}),t(`span`,{style:{color:i.separatorColor},children:`=`}),t(`span`,{style:{color:i.attributeValueColor},children:`"${r}"`})]},`attribute-${e}`))}):null}function Ki(e){let{indentation:r,tagKey:i,attributes:a}=e,{theme:o}=$();return n(`div`,{children:[t(`span`,{style:{color:o.separatorColor},children:`${r}<?`}),t(`span`,{style:{color:o.tagColor},children:`${i.slice(1)}`}),t(Gi,{attributes:a}),t(`span`,{style:{color:o.separatorColor},children:`?>`})]})}function qi(e,t){return Array(t*e+1).join(` `)}function Ji(e){return typeof e==`string`&&e.includes(`
7
7
  `)}function Yi(e){return typeof e==`string`?!1:e.length===1&&`#text`in e[0]&&!Ji(e[0][`#text`])}function Xi(e){switch(e){case ji:case Ni:case Mi:return e;default:return e.startsWith(`?`)?Pi:`TAG`}}function Zi(e){let t=e[`:@`],n=Ke(e,`:@`),[[r,i]]=Object.entries(n);return{attributes:t,tagKey:r,subElements:i,type:Xi(r)}}function Qi(e){return e?Object.keys(e).length>0:!1}function $i(r){let{indentation:i,tagKey:a,attributes:o,children:s,isInline:c,hasChildren:l,level:u}=r,{collapsed:d,buttonProps:f}=Ui(u),{theme:p}=$();return n(`div`,{children:[n(`span`,{...f,children:[t(`span`,{children:i}),t(Vi,{collapsed:d}),t(`span`,{style:{color:p.separatorColor},children:`<`}),t(`span`,{style:{color:p.tagColor},children:`${a}`}),!d&&t(Gi,{attributes:o}),d&&Qi(o)&&` ...`,t(`span`,{style:{color:p.separatorColor},children:l?`>`:` />`})]}),l&&n(e,{children:[!d&&s,d&&`...`,t(`span`,{style:{color:p.separatorColor},children:`${c||d?``:i}</`}),t(`span`,{style:{color:p.tagColor},children:`${a}`}),t(`span`,{style:{color:p.separatorColor},children:`>`})]})]})}function ea(e){let{hasSiblings:n,text:r,indentation:i,isText:a}=e,{theme:o}=$(),s=a?{color:o.textColor}:void 0;return Ji(r)||n?t(`div`,{style:s,children:r.split(`
8
8
  `).filter(e=>!!e.trim()).map((e,n)=>t(`div`,{children:`${i}${e.trim()}`},`line-${n}`))}):t(`span`,{style:s,children:r})}function ta(n){let{elements:r,level:i=0,isText:a=!0}=n,{indentSize:o}=$();return!Array.isArray(r)||r.length===0?null:t(e,{children:r.map((e,n)=>{let{tagKey:s,attributes:c,subElements:l,type:u}=Zi(e),d=r.length>1,f=qi(o,i),p=`${i}-${n}`,m=Yi(l);switch(u){case ji:return t(ea,{text:l,indentation:f,hasSiblings:d,isText:a},p);case Mi:return t(Wi,{isInline:m,indentation:f,level:i,children:t(ta,{elements:l,level:i+1,isText:!1})},p);case Ni:return t(Bi,{indentation:f,isInline:m,children:t(ta,{elements:l,level:i+1,isText:!1})},p);case Pi:return t(Ki,{indentation:f,tagKey:s,attributes:c},p);default:return t($i,{indentation:f,tagKey:s,attributes:c,isInline:m,hasChildren:l.length>0,level:i,children:t(ta,{elements:l,level:i+1})},p)}})})}function na(){return t(`div`,{children:`Invalid XML!`})}function ra(e){let{theme:n,xml:r,collapsible:i=!1,indentSize:a=2,invalidXml:o,initalCollapsedDepth:s,initialCollapsedDepth:c}=e,[l,u]=L(()=>document.documentElement.classList.contains(`dark`));P(()=>{let e=document.documentElement,t=new MutationObserver(()=>{u(e.classList.contains(`dark`))});return t.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let d=F(()=>({...l?Ii:Fi,...n}),[l,n]),{json:f,valid:p}=zi(r),m=F(()=>({theme:d,collapsible:i,indentSize:a,initialCollapsedDepth:c??s}),[d,i,a,s,c]);return p?t(Li.Provider,{value:m,children:t(`div`,{className:`rxv-container`,style:{whiteSpace:`pre-wrap`,fontFamily:d.fontFamily,overflowWrap:`break-word`},children:t(ta,{elements:f})})}):o||t(na,{})}export{ht as ArrayPropertySchema,Cn as ArtifactContentRenderer,zn as ChartCodeBlockHandler,Y as CodeBlockErrorBoundary,pn as CodeBlockHandlerProvider,J as CodeBlockPlaceholder,En as CodeBlockRendererProvider,ki as DropZone,Hn as ExpandCodeBlockHandler,Je as FieldSetContextProvider,et as Form,Xe as FormContext,Qe as FormContextProvider,dt as FormError,ut as FormHelper,lt as FormLabel,nt as GeneratedForm,$e as Input,wt as JSONCode,Pt as JSONDisplay,Bt as JSONEditor,Ht as JSONSwitcher,Gt as JSONTable,Ot as JSONView,St as ManageObjectEntry,xt as ManagedListProperty,vt as ManagedObject,U as ManagedObjectBase,yt as ManagedObjectProperty,bt as ManagedProperty,Ct as ManagedScalarEntry,ui as ManagedSchema,Jn as MarkdownFigure,Xn as MarkdownImage,Qn as MarkdownLink,zr as MarkdownRenderer,Bn as MermaidCodeBlockHandler,Mn as MermaidDiagram,zt as MonacoEditor,H as Node,Br as Progress,Vr as PropertiesView,Jr as PropertyEditor,Yr as PropertyNameEditor,pt as PropertySchema,$r as PropertyViewer,at as ScalarField,V as Schema,bi as SchemaEditor,di as SchemaNode,Hr as SvgIcon,Q as UploadResultCategory,Ai as UploadSummary,Rt as VEditorApi,ra as XMLViewer,gt as computeTitleFromName,Wn as createDefaultCodeBlockHandlers,Ur as createSvgIcon,Wr as getEditableSchemaProperty,Vt as getJSONEditorValue,Un as isExpandLanguage,Fn as isIncompleteJson,Kn as mapSchemeToRoute,X as parseUrlScheme,Dt as renderJsonLine,Pn as useArtifactContent,On as useCodeBlockComponent,q as useCodeBlockContext,Dn as useCodeBlockRendererRegistry,Ye as useFieldSet,B as useForm,qn as useResolvedUrl,fi as useSchema,wi as validatePropertyName};
9
9
  //# sourceMappingURL=vertesia-ui-widgets.js.map