@e-llm-studio/citation 0.0.234 → 0.0.235
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.
- package/dist/cjs/features/PromptemonBlockViewer/PromptemonBlockViewer.js +1 -1
- package/dist/cjs/features/PromptemonViewer/PromptemonViewer.js +1 -1
- package/dist/features/PromptemonBlockViewer/PromptemonBlockViewer.js +1 -1
- package/dist/features/PromptemonViewer/PromptemonViewer.js +1 -1
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts +1 -0
- package/dist/types/src/features/CognitiveCompare/hooks/useCompareLayout.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),o=require("react"),t=require("@mui/material"),i=require("@mui/icons-material/Close"),n=require("@mui/icons-material/Fullscreen"),s=require("@monaco-editor/react"),a=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),o=require("react"),t=require("@mui/material"),i=require("@mui/icons-material/Close"),n=require("@mui/icons-material/Fullscreen"),s=require("@monaco-editor/react"),a=require("@mui/icons-material/DarkMode"),l=require("@mui/icons-material/LightMode");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=d(i),u=d(n),c=d(s),f=d(a),h=d(l),x={base:"vs-dark",inherit:!0,rules:[{token:"tag",foreground:"714be3",fontStyle:"bold"},{token:"attribute.name",foreground:"87CEFA"},{token:"attribute.value",foreground:"98FB98"},{token:"variable",foreground:"00FFFF"},{token:"delimiter",foreground:"888888"},{token:"white",foreground:"AAAAAA"}],colors:{"editor.foreground":"#FFFFFF","editor.background":"#030202","editorLineNumber.foreground":"#858585","editorCursor.foreground":"#FFFFFF","editorIndentGuide.background":"#404040","editorIndentGuide.activeBackground":"#707070"}},p={base:"vs",inherit:!0,rules:[{token:"tag",foreground:"5928ED",fontStyle:"bold"},{token:"attribute.name",foreground:"AF00DB"},{token:"attribute.value",foreground:"008000"},{token:"variable",foreground:"B000B0"},{token:"delimiter",foreground:"808080"},{token:"white",foreground:"000000"}],colors:{"editor.foreground":"#000000","editor.background":"#FFFFFF","editorLineNumber.foreground":"#999999","editorCursor.foreground":"#000000","editorIndentGuide.background":"#CCCCCC","editorIndentGuide.activeBackground":"#999999"}},m=function(o){var i=o.isDarkMode,n=o.onChange;return r.jsx(t.Box,e.__assign({onClick:function(){return n(!i)},sx:{width:52,height:24,borderRadius:"12px",bgcolor:i?"#5928ed":"#f0f0f0",border:"1px solid",borderColor:i?"#5928ed":"#d1d5db",display:"flex",alignItems:"center",px:.4,cursor:"pointer",transition:"all 0.2s",justifyContent:i?"flex-end":"flex-start"}},{children:r.jsx(t.Box,e.__assign({sx:{width:18,height:18,borderRadius:"50%",bgcolor:i?"#1e1e2e":"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"}},{children:i?r.jsx(f.default,{sx:{fontSize:11,color:"#fff"}}):r.jsx(h.default,{sx:{fontSize:11,color:"#fff"}})}))}))},b=function(i){var n=i.content,s=i.selectedTag,a=i.highlightVariable,l=i.isDarkMode,d=i.height,g=void 0===d?250:d,u=i.fontSize,f=void 0===u?12:u,h=o.useRef(),m=o.useRef();return o.useEffect(function(){if(s&&h.current&&m.current){var e=h.current,r=e.getModel();if(r){for(var o=r.getValue().split("\n"),t=-1,i=0;i<o.length;i++){var n=o[i].match(/<([^\s>\/]+(?:\s[^\s>\/]+)*)/);if(n&&n[1].trim().toLowerCase()===s.toLowerCase()){t=i+1;break}}if(t>0){var a=t,l="</".concat(s.toLowerCase(),">");for(i=t;i<o.length;i++)if(o[i].toLowerCase().includes(l)){a=i+1;break}e.setSelection(new m.current.Selection(t,1,t,1)),e.trigger(null,"editor.unfold",{}),e.revealLineInCenterIfOutsideViewport(t);var d=e.deltaDecorations([],[{range:new m.current.Range(t,1,a,o[a-1].length+1),options:{isWholeLine:!0,className:"promptemon-highlight",inlineClassName:"promptemon-highlight"}}]);setTimeout(function(){return e.deltaDecorations(d,[])},2e3)}}}},[s]),o.useEffect(function(){if(a&&h.current&&m.current){var e=h.current,r=e.getModel();if(r){for(var o=r.getValue().split("\n"),t=[],i=0;i<o.length;i++)for(var n=o[i].indexOf(a);-1!==n;)t.push(new m.current.Range(i+1,n+1,i+1,n+a.length+1)),n=o[i].indexOf(a,n+1);if(0!==t.length){e.revealLineInCenterIfOutsideViewport(t[0].startLineNumber);var s=e.deltaDecorations([],t.map(function(e){return{range:e,options:{inlineClassName:"promptemon-variable-highlight"}}}));setTimeout(function(){return e.deltaDecorations(s,[])},2e3)}}}},[a]),o.useEffect(function(){m.current&&m.current.editor.setTheme(l?"promptemonDark":"promptemonLight")},[l]),r.jsxs(r.Fragment,{children:[r.jsx("style",{children:"\n .promptemon-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-variable-highlight { background-color: rgba(0, 255, 255, 0.2); border-radius: 2px; }\n "}),r.jsxs(t.Box,e.__assign({sx:{width:"100%",height:g,display:"flex",flexDirection:"column"}},{children:[r.jsx(t.Box,{sx:{width:"100%",height:20,bgcolor:l?"#030202":"#fff",borderTopLeftRadius:8,borderTopRightRadius:8}}),r.jsx(t.Box,e.__assign({sx:{flex:1,minHeight:0,overflow:"hidden"}},{children:r.jsx(c.default,{onMount:function(e,r){h.current=e,m.current=r,r.editor.defineTheme("promptemonDark",x),r.editor.defineTheme("promptemonLight",p),r.editor.setTheme(l?"promptemonDark":"promptemonLight"),r.languages.register({id:"promptemonLang"}),r.languages.setMonarchTokensProvider("promptemonLang",{tokenizer:{root:[[/(<)([a-zA-Z0-9\-]+)(\s*)/,["delimiter","tag","white"],"@tagBody"],[/(<\/)([a-zA-Z0-9\-]+)(\s*)(>)/,["delimiter","tag","white","delimiter"]],[/{{[^}]+}}/,"variable"]],tagBody:[[/[a-zA-Z0-9\:\-]+(?=\=)/,"attribute.name"],[/=/,"delimiter"],[/(".*?"|'.*?')/,"attribute.value"],[/\s+/,"white"],[/(\/?>)/,{token:"delimiter",next:"@pop"}]]}}),r.languages.registerFoldingRangeProvider("promptemonLang",{provideFoldingRanges:function(e){var r=e.getLinesContent(),o=[],t=[];return r.forEach(function(e,r){var i=r+1,n=e.match(/<([a-zA-Z0-9\-]+)(\s[^>]*)?>/),s=e.match(/<\/([a-zA-Z0-9\-]+)>/);if(n&&!e.includes("/>")&&t.push({tag:n[1],start:i}),s)for(var a=s[1],l=t.length-1;l>=0;l--)if(t[l].tag===a){o.push({start:t[l].start,end:i}),t.splice(l,1);break}}),o}})},beforeMount:function(e){e.editor.defineTheme("promptemonDark",x),e.editor.defineTheme("promptemonLight",p),e.editor.setTheme(l?"promptemonDark":"promptemonLight")},theme:l?"promptemonDark":"promptemonLight",value:n,language:"promptemonLang",onChange:function(){},options:{fontSize:f,minimap:{enabled:!1},wordWrap:"on",lineNumbers:"on",readOnly:!0,domReadOnly:!0,scrollBeyondLastLine:!1,padding:{top:4,bottom:12},folding:!0,automaticLayout:!0,scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:8}}})})),r.jsx(t.Box,{sx:{width:"100%",height:20,bgcolor:l?"#030202":"#fff",borderBottomLeftRadius:8,borderBottomRightRadius:8}})]}))]})};exports.default=function(i){var n=i.title,s=i.description,a=i.content,l=i.height,d=void 0===l?250:l,c=i.selectedTag,f=i.highlightVariable,h=o.useState(!0),x=h[0],p=h[1],_=o.useState(!1),v=_[0],j=_[1];return r.jsxs(r.Fragment,{children:[r.jsxs(t.Box,e.__assign({sx:{border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden"}},{children:[r.jsxs(t.Box,e.__assign({sx:{px:1.5,py:.75,bgcolor:"#f9fafb",borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[r.jsx(t.Typography,e.__assign({sx:{fontSize:"0.72rem",color:"#374151",fontWeight:600}},{children:n})),r.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:.75}},{children:[r.jsx(m,{isDarkMode:x,onChange:p}),r.jsx(t.Tooltip,e.__assign({title:"Fullscreen",placement:"top"},{children:r.jsx(t.Box,e.__assign({onClick:function(){return j(!0)},sx:{cursor:"pointer",display:"flex",alignItems:"center",p:.3,borderRadius:"4px","&:hover":{bgcolor:"#e5e7eb"}}},{children:r.jsx(u.default,{sx:{fontSize:"0.9rem",color:"#6b7280"}})}))}))]}))]})),r.jsx(t.Box,e.__assign({sx:{height:d,bgcolor:x?"#030202":"#fff"}},{children:r.jsx(b,{content:a,selectedTag:c,highlightVariable:f,isDarkMode:x,height:d,fontSize:12})}))]})),r.jsxs(t.Dialog,e.__assign({open:v,onClose:function(){return j(!1)},maxWidth:!1,PaperProps:{sx:{width:"82vw",height:"80vh",maxWidth:"none",borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column"}}},{children:[r.jsxs(t.Box,e.__assign({sx:{px:2.5,py:1.5,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0}},{children:[r.jsx(t.Typography,e.__assign({sx:{fontWeight:700,fontSize:"1rem",color:"#111827"}},{children:n})),r.jsx(t.IconButton,e.__assign({size:"small",onClick:function(){return j(!1)}},{children:r.jsx(g.default,{sx:{fontSize:"1.1rem",color:"#6B7280"}})}))]})),r.jsxs(t.Box,e.__assign({sx:{flex:1,display:"flex",overflow:"hidden",minHeight:0}},{children:[s&&r.jsxs(t.Box,e.__assign({sx:{width:"35%",flexShrink:0,borderRight:"1px solid #E5E7EB",display:"flex",flexDirection:"column",overflow:"hidden"}},{children:[r.jsxs(t.Box,e.__assign({sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",gap:1}},{children:[r.jsx(t.Chip,{label:"APB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:10,height:20,borderRadius:1}}),r.jsx(t.Typography,e.__assign({sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827"}},{children:n}))]})),r.jsx(t.Box,e.__assign({sx:{flex:1,p:2,overflowY:"auto"}},{children:r.jsxs(t.Box,e.__assign({sx:{border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5}},{children:[r.jsx(t.Typography,e.__assign({sx:{fontWeight:600,fontSize:"0.8rem",color:"#111827",mb:.75}},{children:"Description"})),r.jsx(t.Typography,e.__assign({sx:{fontSize:"0.73rem",color:"#6B7280",lineHeight:1.6}},{children:s}))]}))}))]})),r.jsxs(t.Box,e.__assign({sx:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"}},{children:[r.jsxs(t.Box,e.__assign({sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[r.jsx(t.Typography,e.__assign({sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827"}},{children:"Prompt Preview"})),r.jsx(m,{isDarkMode:x,onChange:p})]})),r.jsx(t.Box,e.__assign({sx:{flex:1,minHeight:0,p:1.5}},{children:r.jsx(b,{content:a,selectedTag:c,highlightVariable:f,isDarkMode:x,height:"100%",fontSize:13})}))]}))]}))]}))]})};
|
|
2
2
|
//# sourceMappingURL=PromptemonBlockViewer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),t=require("@mui/icons-material/ExpandMore"),r=require("@mui/icons-material/EditOutlined"),s=require("@mui/icons-material/Close"),a=require("@mui/icons-material/ArrowBack"),l=require("@mui/icons-material/NavigateBefore"),d=require("@mui/icons-material/NavigateNext"),c=require("@mui/icons-material/InfoOutlined"),u=require("@mui/icons-material/AutoFixHighOutlined"),x=require("@mui/icons-material/Check"),g=require("@mui/icons-material/Add"),f=require("@mui/icons-material/DeleteOutline"),p=require("@monaco-editor/react"),h=require("monaco-editor"),_=require("@mui/icons-material/DarkMode"),m=require("@mui/icons-material/LightMode");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function y(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach(function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}}),n.default=e,Object.freeze(n)}var j=b(t),S=b(r),v=b(s),w=b(a),z=b(l),C=b(d),k=b(c),B=b(u),I=b(x),A=b(g),T=b(f),R=b(p),W=y(h),F=b(_),D=b(m),L={base:"vs-dark",inherit:!0,rules:[{token:"tag",foreground:"714be3",fontStyle:"bold"},{token:"attribute.name",foreground:"87CEFA"},{token:"attribute.value",foreground:"98FB98"},{token:"variable",foreground:"00FFFF"},{token:"delimiter",foreground:"888888"},{token:"white",foreground:"AAAAAA"}],colors:{"editor.foreground":"#FFFFFF","editor.background":"#030202","editorLineNumber.foreground":"#858585","editorCursor.foreground":"#FFFFFF","editorIndentGuide.background":"#404040","editorIndentGuide.activeBackground":"#707070"}},M={base:"vs",inherit:!0,rules:[{token:"tag",foreground:"5928ED",fontStyle:"bold"},{token:"attribute.name",foreground:"AF00DB"},{token:"attribute.value",foreground:"008000"},{token:"variable",foreground:"B000B0"},{token:"delimiter",foreground:"808080"},{token:"white",foreground:"000000"}],colors:{"editor.foreground":"#000000","editor.background":"#FFFFFF","editorLineNumber.foreground":"#999999","editorCursor.foreground":"#000000","editorIndentGuide.background":"#CCCCCC","editorIndentGuide.activeBackground":"#999999"}},O=function(t){var r=t.description,s=i.useState(!1),a=s[0],l=s[1],d=i.useState(!1),c=d[0],u=d[1],x=i.useRef(null);return i.useEffect(function(){var e=x.current;e&&u(e.scrollHeight>e.clientHeight+1)},[r,a]),n.jsxs(o.Box,e.__assign({sx:{mt:1.5,border:"1px solid #e5e7eb",borderRadius:2,bgcolor:"#fff",display:"flex",flexDirection:"column",px:1.25,py:1}},{children:[n.jsx(o.Typography,e.__assign({ref:x,component:"div",sx:e.__assign({fontSize:11,color:"#6b7280",lineHeight:1.5,overflowY:a?"auto":"hidden",maxHeight:a?"calc(1.6em * 5)":"calc(1.6em * 3)",whiteSpace:"normal",display:a?"block":"-webkit-box"},a?{}:{WebkitBoxOrient:"vertical",WebkitLineClamp:3})},{children:r})),c&&n.jsx(o.Typography,e.__assign({component:"span",onClick:function(){return l(function(e){return!e})},sx:{mt:.75,alignSelf:"flex-end",fontSize:10,color:"#7c3aed",cursor:"pointer",fontWeight:500}},{children:a?"View less":"View more"}))]}))},E=function(t){var r=t.value,s=t.onChange,a=t.onDelete,l=i.useState(!1),d=l[0],c=l[1];return n.jsxs(o.Box,e.__assign({sx:{display:"flex",alignItems:"flex-start",gap:1,p:1,border:"1px solid #e5e7eb",borderRadius:"8px",bgcolor:"#fff"}},{children:[n.jsx(o.Box,e.__assign({sx:{width:18,height:18,borderRadius:"4px",bgcolor:"#f1f5f9",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,color:"#64748b",flexShrink:0,mt:.1}},{children:"a"})),d?n.jsx(o.TextField,{autoFocus:!0,value:r,onChange:function(e){return s(e.target.value)},onBlur:function(){return c(!1)},size:"small",fullWidth:!0,multiline:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:12.5}}}):n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55,flex:1}},{children:r})),n.jsxs(o.Stack,e.__assign({direction:"row",gap:.25,sx:{flexShrink:0}},{children:[n.jsx(o.IconButton,e.__assign({size:"small",onClick:function(){return c(!0)},sx:{color:"#6b7280"}},{children:n.jsx(S.default,{sx:{fontSize:14}})})),n.jsx(o.IconButton,e.__assign({size:"small",onClick:a,sx:{color:"#dc2626"}},{children:n.jsx(T.default,{sx:{fontSize:14}})}))]}))]}))},V=function(i){var t=i.isDarkMode,r=i.onChange;return n.jsx(o.Box,e.__assign({onClick:function(){return r(!t)},sx:{width:52,height:24,borderRadius:"12px",bgcolor:t?"#5928ed":"#f0f0f0",border:"1px solid",borderColor:t?"#5928ed":"#d1d5db",display:"flex",alignItems:"center",px:.4,cursor:"pointer",transition:"all 0.2s",justifyContent:t?"flex-end":"flex-start"}},{children:n.jsx(o.Box,e.__assign({sx:{width:18,height:18,borderRadius:"50%",bgcolor:t?"#1e1e2e":"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"}},{children:t?n.jsx(F.default,{sx:{fontSize:11,color:"#fff"}}):n.jsx(D.default,{sx:{fontSize:11,color:"#fff"}})}))}))},P=function(t){var r=t.content,s=t.selectedTag,a=t.highlightVariable,l=t.isDarkMode,d=t.height,c=void 0===d?250:d,u=t.fontSize,x=void 0===u?12:u,g=i.useRef(),f=i.useRef();return i.useEffect(function(){if(s&&g.current&&f.current){var e=g.current,n=e.getModel();if(n){for(var i=n.getValue().split("\n"),o=-1,t=0;t<i.length;t++){var r=i[t].match(/<([^\s>\/]+(?:\s[^\s>\/]+)*)/);if(r&&r[1].trim().toLowerCase()===s.toLowerCase()){o=t+1;break}}if(o>0){var a=o,l="</".concat(s.toLowerCase(),">");for(t=o;t<i.length;t++)if(i[t].toLowerCase().includes(l)){a=t+1;break}e.setSelection(new f.current.Selection(o,1,o,1)),e.trigger(null,"editor.unfold",{}),e.revealLineInCenterIfOutsideViewport(o);var d=e.deltaDecorations([],[{range:new f.current.Range(o,1,a,i[a-1].length+1),options:{isWholeLine:!0,className:"promptemon-viewer-highlight",inlineClassName:"promptemon-viewer-highlight"}}]);setTimeout(function(){return e.deltaDecorations(d,[])},2e3)}}}},[s]),i.useEffect(function(){if(a&&g.current&&f.current){var e=g.current,n=e.getModel();if(n){for(var i=n.getValue().split("\n"),o=[],t=0;t<i.length;t++)for(var r=i[t].indexOf(a);-1!==r;)o.push(new W.Range(t+1,r+1,t+1,r+a.length+1)),r=i[t].indexOf(a,r+1);if(0!==o.length){e.revealLineInCenterIfOutsideViewport(o[0].startLineNumber);var s=e.deltaDecorations([],o.map(function(e){return{range:e,options:{inlineClassName:"promptemon-viewer-variable-highlight"}}}));setTimeout(function(){return e.deltaDecorations(s,[])},2e3)}}}},[a]),i.useEffect(function(){f.current&&f.current.editor.setTheme(l?"promptemonViewerDark":"promptemonViewerLight")},[l]),n.jsxs(n.Fragment,{children:[n.jsx("style",{children:"\n .promptemon-viewer-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-viewer-variable-highlight { background-color: rgba(0, 255, 255, 0.2); border-radius: 2px; }\n "}),n.jsxs(o.Box,e.__assign({sx:{width:"100%",height:c,display:"flex",flexDirection:"column"}},{children:[n.jsx(o.Box,{sx:{width:"100%",height:20,bgcolor:l?"#030202":"#fff",borderTopLeftRadius:8,borderTopRightRadius:8}}),n.jsx(o.Box,e.__assign({sx:{flex:1,minHeight:0,overflow:"hidden"}},{children:n.jsx(R.default,{onMount:function(e,n){g.current=e,f.current=n,n.editor.defineTheme("promptemonViewerDark",L),n.editor.defineTheme("promptemonViewerLight",M),n.editor.setTheme(l?"promptemonViewerDark":"promptemonViewerLight"),n.languages.register({id:"promptemonViewerLang"}),n.languages.setMonarchTokensProvider("promptemonViewerLang",{tokenizer:{root:[[/(<)([a-zA-Z0-9\-]+)(\s*)/,["delimiter","tag","white"],"@tagBody"],[/(<\/)([a-zA-Z0-9\-]+)(\s*)(>)/,["delimiter","tag","white","delimiter"]],[/{{[^}]+}}/,"variable"]],tagBody:[[/[a-zA-Z0-9\:\-]+(?=\=)/,"attribute.name"],[/=/,"delimiter"],[/(".*?"|'.*?')/,"attribute.value"],[/\s+/,"white"],[/(\/?>)/,{token:"delimiter",next:"@pop"}]]}}),n.languages.registerFoldingRangeProvider("promptemonViewerLang",{provideFoldingRanges:function(e){var n=e.getLinesContent(),i=[],o=[];return n.forEach(function(e,n){var t=n+1,r=e.match(/<([a-zA-Z0-9\-]+)(\s[^>]*)?>/),s=e.match(/<\/([a-zA-Z0-9\-]+)>/);if(r&&!e.includes("/>")&&o.push({tag:r[1],start:t}),s)for(var a=s[1],l=o.length-1;l>=0;l--)if(o[l].tag===a){i.push({start:o[l].start,end:t}),o.splice(l,1);break}}),i}})},beforeMount:function(e){e.editor.defineTheme("promptemonViewerDark",L),e.editor.defineTheme("promptemonViewerLight",M),e.editor.setTheme(l?"promptemonViewerDark":"promptemonViewerLight")},theme:l?"promptemonViewerDark":"promptemonViewerLight",value:r,language:"promptemonViewerLang",onChange:function(){},options:{fontSize:x,minimap:{enabled:!1},wordWrap:"on",lineNumbers:"on",readOnly:!0,domReadOnly:!0,scrollBeyondLastLine:!1,padding:{top:4,bottom:12},folding:!0,automaticLayout:!0,scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:8}}})})),n.jsx(o.Box,{sx:{width:"100%",height:20,bgcolor:l?"#030202":"#fff",borderBottomLeftRadius:8,borderBottomRightRadius:8}})]}))]})},q=function(t){var r,s,a,l,d=t.block,c=t.isExtracted,u=t.isSaved,x=t.showEditMode,g=t.onBlockUpdate,f=t.onTagSelect,p=t.onVariableSelect,h=t.categories,_=t.subCategories,m=t.selectedCategoryId,b=t.selectedSubCategoryId,y=t.onCategoryChange,w=t.onSubCategoryChange,z=i.useState(!0),C=z[0],B=z[1],R=i.useState(!0),W=R[0],F=R[1],D=i.useState(!0),L=D[0],M=D[1],V=i.useState(!0),P=V[0],q=V[1],N=i.useState(!1),G=N[0],H=N[1],Z=i.useState(!0),U=Z[0],Y=Z[1],J=i.useState(!0),K=J[0],Q=J[1],X=i.useState(!1),$=X[0],ee=X[1],ne=i.useState(!1),ie=ne[0],oe=ne[1],te=i.useState(!1),re=te[0],se=te[1],ae=i.useState((null==d?void 0:d.title)||""),le=ae[0],de=ae[1],ce=i.useState((null==d?void 0:d.short_description)||""),ue=ce[0],xe=ce[1],ge=i.useState((null==d?void 0:d.members)||[]),fe=ge[0],pe=ge[1],he=i.useState(Array.isArray(null==d?void 0:d.when_to_apply)?d.when_to_apply:(null==d?void 0:d.when_to_apply)?[d.when_to_apply]:[]),_e=he[0],me=he[1],be=i.useState(Array.isArray(null==d?void 0:d.when_not_to_apply)?d.when_not_to_apply:(null==d?void 0:d.when_not_to_apply)?[d.when_not_to_apply]:[]),ye=be[0],je=be[1],Se=i.useState(!1),ve=Se[0],we=Se[1],ze=i.useState(""),Ce=ze[0],ke=ze[1],Be=i.useState(""),Ie=Be[0],Ae=Be[1],Te={boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"8px !important",mb:1.5,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 12px 0"}},Re={minHeight:44,px:2,borderRadius:2,"&.Mui-expanded":{minHeight:44},"& .MuiAccordionSummary-content":{my:"10px"}};return n.jsxs(o.Box,e.__assign({sx:{width:820,flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden",borderRight:"1px solid #e5e7eb"}},{children:[n.jsxs(o.Box,e.__assign({sx:{px:2.5,py:2,borderBottom:"1px solid #e5e7eb"}},{children:[n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",justifyContent:"space-between"},{children:[n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1,sx:{flex:1,minWidth:0}},{children:[n.jsx(o.Tooltip,e.__assign({title:"Functional Prompt Block",placement:"top"},{children:n.jsx(o.Chip,{label:"FPB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:11,height:22,borderRadius:1}})})),re?n.jsx(o.TextField,{value:le,onChange:function(e){return de(e.target.value)},size:"small",fullWidth:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:15,fontWeight:700,py:.5}}}):n.jsx(o.Typography,e.__assign({sx:{fontWeight:700,fontSize:15,color:"#111827"}},{children:(null==d?void 0:d.title)||"—"}))]})),re?n.jsxs(o.Stack,e.__assign({direction:"row",gap:.5},{children:[n.jsx(o.IconButton,e.__assign({size:"small",sx:{color:"#6b7280"},onClick:function(){return se(!1)}},{children:n.jsx(v.default,{sx:{fontSize:16}})})),n.jsx(o.IconButton,e.__assign({size:"small",sx:{color:"#16a34a"},onClick:function(){g(e.__assign(e.__assign({},d),{title:le,short_description:ue,members:fe,when_to_apply:_e,when_not_to_apply:ye})),se(!1)}},{children:n.jsx(I.default,{sx:{fontSize:16}})}))]})):!u&&x&&n.jsx(o.IconButton,e.__assign({size:"small",sx:{color:"#6b7280"},onClick:function(){de((null==d?void 0:d.title)||""),xe((null==d?void 0:d.short_description)||""),pe((null==d?void 0:d.members)||[]),me(Array.isArray(null==d?void 0:d.when_to_apply)?d.when_to_apply:(null==d?void 0:d.when_to_apply)?[d.when_to_apply]:[]),je(Array.isArray(null==d?void 0:d.when_not_to_apply)?d.when_not_to_apply:(null==d?void 0:d.when_not_to_apply)?[d.when_not_to_apply]:[]),se(!0)}},{children:n.jsx(S.default,{sx:{fontSize:16}})}))]})),re&&n.jsx(o.Typography,e.__assign({sx:{fontSize:11,color:"#5928ed",mt:.5}},{children:"Editing — changes won't be saved until you confirm"})),re?n.jsx(o.TextField,{value:ue,onChange:function(e){return xe(e.target.value)},size:"small",fullWidth:!0,multiline:!0,minRows:3,sx:{mt:1.5,"& .MuiOutlinedInput-input":{fontSize:12}}}):n.jsx(O,{description:(null==d?void 0:d.short_description)||"—"}),n.jsxs(o.Box,e.__assign({sx:{mt:1.5,border:"0.5px solid #d1d5db",borderRadius:"8px",display:"flex",overflow:"hidden"}},{children:[n.jsx(o.Box,e.__assign({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",borderRight:"1px solid #d1d5db",p:.5}},{children:n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1},{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:10,color:"#87898d"}},{children:"Total APBs :"})),n.jsx(o.Typography,e.__assign({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(r=null==d?void 0:d.members)||void 0===r?void 0:r.length)||0}))]}))})),n.jsx(o.Box,e.__assign({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",p:.5}},{children:n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1},{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:10,color:"#87898d"}},{children:"Total Lines :"})),n.jsx(o.Typography,e.__assign({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(s=null==d?void 0:d.members)||void 0===s?void 0:s.reduce(function(e,n){var i,o;return e+((null!==(i=n.end_line)&&void 0!==i?i:0)-(null!==(o=n.start_line)&&void 0!==o?o:0)+1)},0))||0}))]}))}))]}))]})),n.jsxs(o.Box,e.__assign({sx:{flex:1,overflow:"auto",px:2,py:2,"&::-webkit-scrollbar":{width:4},"&::-webkit-scrollbar-thumb":{bgcolor:"#e5e7eb",borderRadius:2}}},{children:[n.jsxs(o.Accordion,e.__assign({expanded:C,onChange:function(){return B(function(e){return!e})},sx:Te,disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(j.default,{sx:{fontSize:18}}),sx:Re},{children:n.jsx(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Categories"}))})),n.jsx(o.AccordionDetails,e.__assign({sx:{pt:0,px:2,pb:2}},{children:n.jsxs(o.Stack,e.__assign({gap:1.5},{children:[n.jsxs(o.Box,{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Category"})),re?n.jsx(o.Select,e.__assign({fullWidth:!0,size:"small",value:m,onChange:function(e){y(e.target.value),w("")},sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:h.map(function(i){return n.jsx(o.MenuItem,e.__assign({value:i.category_id},{children:i.category_name}),i.category_id)})})):n.jsx(o.TextField,{fullWidth:!0,size:"small",value:(null===(a=h.find(function(e){return e.category_id===m}))||void 0===a?void 0:a.category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]}),n.jsxs(o.Box,{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Sub-Category"})),re?n.jsx(o.Select,e.__assign({fullWidth:!0,size:"small",value:b,onChange:function(e){return w(e.target.value)},disabled:!m,sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:_.filter(function(e){return e.category_id===m}).map(function(i){return n.jsx(o.MenuItem,e.__assign({value:i.sub_category_id},{children:i.sub_category_name}),i.sub_category_id)})})):n.jsx(o.TextField,{fullWidth:!0,size:"small",value:(null===(l=_.find(function(e){return e.sub_category_id===b}))||void 0===l?void 0:l.sub_category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]})]}))}))]})),n.jsxs(o.Accordion,e.__assign({expanded:W,onChange:function(){return F(function(e){return!e})},sx:Te,disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(j.default,{sx:{fontSize:18}}),sx:Re},{children:n.jsx(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Atomic Prompt Blocks (APBs)"}))})),n.jsxs(o.AccordionDetails,e.__assign({sx:{pt:0,px:1,pb:2}},{children:[n.jsx(o.Stack,e.__assign({gap:1},{children:(re?fe:(null==d?void 0:d.members)||[]).map(function(i,t){return n.jsxs(o.Box,e.__assign({sx:{px:2,py:1,borderRadius:2,bgcolor:"#fff"}},{children:[n.jsxs(o.Box,e.__assign({sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1,gap:1}},{children:[n.jsxs(o.Typography,e.__assign({sx:{fontSize:14,fontWeight:500,color:"#111827"}},{children:[t+1,". ",i.section_name]})),re?n.jsx(o.IconButton,e.__assign({size:"small",onClick:function(){return pe(function(e){return e.filter(function(e,n){return n!==t})})},sx:{color:"#dc2626",flexShrink:0}},{children:n.jsx(T.default,{sx:{fontSize:16}})})):n.jsx(o.Box,e.__assign({onClick:function(){return f(i.section_name.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join("_"))},sx:{fontSize:14,color:"#475569",cursor:"pointer",flexShrink:0}},{children:"↗"}))]})),n.jsx(o.Typography,e.__assign({sx:{fontSize:12,lineHeight:1.5,color:"#64748b"}},{children:i.reason_for_inclusion})),c&&(r=i.segments||[],0===r.length?null:n.jsx(o.Box,e.__assign({sx:{mt:1}},{children:n.jsx(o.Box,e.__assign({sx:{display:"flex",flexWrap:"wrap",gap:1}},{children:r.map(function(e,i){return n.jsx(o.Chip,{clickable:!0,onClick:function(){return p(e.segmentized_text)},label:e.segmentized_text,sx:{borderRadius:1,bgcolor:"#eff6ff",color:"#3b82f6",border:"1px dashed #bfdbfe"}},i)})}))}))),n.jsx(o.Divider,{sx:{mt:2}})]}),t);var r})})),re&&n.jsxs(o.Box,e.__assign({onClick:function(){ke(""),Ae(""),we(!0)},sx:{mt:1,display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:1,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:13,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[n.jsx(A.default,{sx:{fontSize:16}})," Add APB"]}))]}))]})),n.jsxs(o.Accordion,e.__assign({expanded:L,onChange:function(){return M(function(e){return!e})},sx:Te,disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(j.default,{sx:{fontSize:18}}),sx:Re},{children:n.jsxs(o.Typography,e.__assign({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Applicability ",n.jsx("span",e.__assign({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• When to apply / When not to apply"}))]}))})),n.jsxs(o.AccordionDetails,e.__assign({sx:{pt:0,px:1.5,pb:1.5}},{children:[n.jsxs(o.Accordion,e.__assign({expanded:P,onChange:function(){return q(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:1,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 8px 0"}},disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(j.default,{sx:{fontSize:16}}),sx:e.__assign(e.__assign({},Re),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When to Apply this FPB"}))})),n.jsx(o.AccordionDetails,e.__assign({sx:{pt:.5,px:2,pb:1.5}},{children:n.jsxs(o.Stack,e.__assign({gap:.75},{children:[(re?_e:Array.isArray(null==d?void 0:d.when_to_apply)?d.when_to_apply:(null==d?void 0:d.when_to_apply)?[d.when_to_apply]:["— Not yet available"]).map(function(i,t){return re?n.jsx(E,{value:i,onChange:function(e){return me(function(n){return n.map(function(n,i){return i===t?e:n})})},onDelete:function(){return me(function(e){return e.filter(function(e,n){return n!==t})})}},t):n.jsxs(o.Stack,e.__assign({direction:"row",gap:1,alignItems:"flex-start"},{children:[n.jsxs(o.Typography,e.__assign({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[t+1,"."]})),n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:i}))]}),t)}),re&&n.jsxs(o.Box,e.__assign({onClick:function(){return me(function(n){return e.__spreadArray(e.__spreadArray([],n,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[n.jsx(A.default,{sx:{fontSize:15}})," Add When to Apply"]}))]}))}))]})),n.jsxs(o.Accordion,e.__assign({expanded:G,onChange:function(){return H(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important","&:before":{display:"none"}},disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(j.default,{sx:{fontSize:16}}),sx:e.__assign(e.__assign({},Re),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When NOT to Apply this FPB"}))})),n.jsx(o.AccordionDetails,e.__assign({sx:{pt:.5,px:2,pb:1.5}},{children:re?n.jsxs(o.Stack,e.__assign({gap:.75},{children:[ye.map(function(e,i){return n.jsx(E,{value:e,onChange:function(e){return je(function(n){return n.map(function(n,o){return o===i?e:n})})},onDelete:function(){return je(function(e){return e.filter(function(e,n){return n!==i})})}},i)}),n.jsxs(o.Box,e.__assign({onClick:function(){return je(function(n){return e.__spreadArray(e.__spreadArray([],n,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[n.jsx(A.default,{sx:{fontSize:15}})," Add When NOT to Apply"]}))]})):Array.isArray(null==d?void 0:d.when_not_to_apply)||(null==d?void 0:d.when_not_to_apply)?n.jsx(o.Stack,e.__assign({gap:.75},{children:(Array.isArray(null==d?void 0:d.when_not_to_apply)?d.when_not_to_apply:[d.when_not_to_apply]).map(function(i,t){return n.jsxs(o.Stack,e.__assign({direction:"row",gap:1,alignItems:"flex-start"},{children:[n.jsxs(o.Typography,e.__assign({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[t+1,"."]})),n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:i}))]}),t)})})):n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#9ca3af",fontStyle:"italic"}},{children:"No conditions defined yet."}))}))]}))]}))]})),n.jsxs(o.Accordion,e.__assign({expanded:U,onChange:function(){return Y(function(e){return!e})},sx:Te,disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(j.default,{sx:{fontSize:18}}),sx:Re},{children:n.jsxs(o.Typography,e.__assign({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Specifications ",n.jsx("span",e.__assign({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• Strict Rules / Input / Output"}))]}))})),n.jsx(o.AccordionDetails,e.__assign({sx:{pt:0,px:1.5,pb:1.5}},{children:[{label:"Guidelines",expanded:K,setExpanded:Q,content:null==d?void 0:d.additional_guidelines},{label:"Input",expanded:$,setExpanded:ee,content:null},{label:"Output",expanded:ie,setExpanded:oe,content:null}].map(function(i,t){var r=i.label,s=i.expanded,a=i.setExpanded,l=i.content;return n.jsxs(o.Accordion,e.__assign({expanded:s,onChange:function(){return a(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:t<2?1:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:t<2?"0 0 8px 0":0}},disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(j.default,{sx:{fontSize:16}}),sx:e.__assign(e.__assign({},Re),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:.5},{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:r})),"Guidelines"!==r&&n.jsx(k.default,{sx:{fontSize:13,color:"#9ca3af"}})]}))})),n.jsx(o.AccordionDetails,e.__assign({sx:{pt:.5,px:2,pb:1.5}},{children:n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:l?"#374151":"#9ca3af",fontStyle:l?"normal":"italic"}},{children:l||"No ".concat(r.toLowerCase()," defined yet.")}))}))]}),r)})}))]}))]})),n.jsxs(o.Dialog,e.__assign({open:ve,onClose:function(){return we(!1)},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px"}}},{children:[n.jsxs(o.Box,e.__assign({sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e5e7eb"}},{children:[n.jsx(o.Typography,e.__assign({sx:{fontWeight:700,fontSize:"1rem",color:"#111827"}},{children:"Add new APB"})),n.jsx(o.IconButton,e.__assign({size:"small",onClick:function(){return we(!1)}},{children:n.jsx(v.default,{sx:{fontSize:"1.1rem",color:"#6b7280"}})}))]})),n.jsxs(o.Box,e.__assign({sx:{px:3,py:2.5,display:"flex",flexDirection:"column",gap:2}},{children:[n.jsxs(o.Box,{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Title"})),n.jsx(o.TextField,{fullWidth:!0,size:"small",placeholder:"Specify the title of APB",value:Ce,onChange:function(e){return ke(e.target.value)}})]}),n.jsxs(o.Box,{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Description"})),n.jsx(o.TextField,{fullWidth:!0,size:"small",multiline:!0,minRows:3,placeholder:"Describe the APB",value:Ie,onChange:function(e){return Ae(e.target.value)}})]})]})),n.jsxs(o.Box,e.__assign({sx:{px:3,py:2,display:"flex",justifyContent:"flex-end",gap:1,borderTop:"1px solid #e5e7eb"}},{children:[n.jsx(o.Button,e.__assign({variant:"outlined",onClick:function(){return we(!1)},sx:{textTransform:"none",borderColor:"#d1d5db",color:"#374151"}},{children:"Cancel"})),n.jsx(o.Button,e.__assign({variant:"contained",onClick:function(){pe(function(n){return e.__spreadArray(e.__spreadArray([],n,!0),[{section_name:Ce,reason_for_inclusion:Ie,content:""}],!1)}),we(!1)},sx:{textTransform:"none",bgcolor:"#5928ed","&:hover":{bgcolor:"#4c1d95"}}},{children:"Save"}))]}))]}))]}))};exports.default=function(t){var r,s,a,l,d,c=t.block,u=t.onBlockUpdate,x=t.isExtracting,g=t.isExtracted,f=t.onExtractSegments,p=t.isSaving,h=t.isSaved,_=t.onSave,m=t.onBack,b=t.title,y=void 0===b?"FPB Promptemon":b,j=t.categories,S=t.subCategories,k=t.selectedCategoryId,I=t.selectedSubCategoryId,A=t.onCategoryChange,T=t.onSubCategoryChange,R=t.showEditMode,W=void 0===R||R,F=t.showExtractSegments,D=void 0===F||F,L=i.useState(1),M=L[0],O=L[1],E=i.useState(!0),N=E[0],G=E[1],H=i.useState(""),Z=H[0],U=H[1],Y=i.useState(""),J=Y[0],K=Y[1],Q=(null===(r=null==c?void 0:c.members)||void 0===r?void 0:r.map(function(e){if(!g||!e.segments||0===e.segments.length)return e.content||"";var n=e.content||"";return e.segments.forEach(function(e){e.raw_text&&e.segmentized_text&&(n=n.split(e.raw_text).join(e.segmentized_text))}),n}).join("\n\n"))||"";return n.jsxs(o.Box,e.__assign({sx:{width:"100%",height:"100%",display:"flex",flexDirection:"column",bgcolor:"#fff",overflow:"hidden"}},{children:[n.jsxs(o.Box,e.__assign({sx:{px:2.5,py:1.5,borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#fff",flexShrink:0}},{children:[n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1},{children:[n.jsx(o.IconButton,e.__assign({size:"small",sx:{color:"#6b7280"},onClick:m},{children:n.jsx(w.default,{sx:{fontSize:18}})})),n.jsx(o.Typography,e.__assign({sx:{fontSize:14,fontWeight:600,color:"#111827"}},{children:y}))]})),n.jsxs(o.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:[n.jsx(o.Button,e.__assign({variant:"contained",size:"small",disabled:!g||p||h,onClick:_,sx:{textTransform:"none",fontSize:"0.78rem",fontWeight:600,bgcolor:"#5928ed",px:2,py:.6,"&:hover":{bgcolor:"#4c1d95"},"&.Mui-disabled":{bgcolor:"#5928ed",color:"#fff",opacity:.4}}},{children:p?"Saving...":h?"Saved ✓":"Save FPB"})),n.jsx(o.IconButton,e.__assign({size:"small",sx:{color:"#6b7280"},onClick:m},{children:n.jsx(v.default,{sx:{fontSize:18}})}))]}))]})),n.jsxs(o.Box,e.__assign({sx:{display:"flex",flex:1,overflow:"hidden"}},{children:[n.jsx(q,{block:c,isExtracted:g,isSaved:h,showEditMode:W,onBlockUpdate:u,onTagSelect:function(e){U(""),setTimeout(function(){return U(e)},50)},onVariableSelect:function(e){K(""),setTimeout(function(){return K(e)},50)},categories:j,subCategories:S,selectedCategoryId:k,selectedSubCategoryId:I,onCategoryChange:A,onSubCategoryChange:T}),n.jsxs(o.Box,e.__assign({sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",p:2,gap:1.5}},{children:[n.jsxs(o.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0}},{children:[n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1},{children:[n.jsxs(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:[(null==c?void 0:c.title)||"—"," APBs"]})),n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:.5},{children:[n.jsx(o.IconButton,e.__assign({size:"small",onClick:function(){return O(function(e){return Math.max(1,e-1)})},disabled:1===M,sx:{color:"#6b7280",p:.4}},{children:n.jsx(z.default,{sx:{fontSize:16}})})),n.jsxs(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#6b7280"}},{children:[M," of ",(null===(s=null==c?void 0:c.members)||void 0===s?void 0:s.length)||0]})),n.jsx(o.IconButton,e.__assign({size:"small",onClick:function(){return O(function(e){var n;return Math.min((null===(n=null==c?void 0:c.members)||void 0===n?void 0:n.length)||0,e+1)})},disabled:M===((null===(a=null==c?void 0:c.members)||void 0===a?void 0:a.length)||0),sx:{color:"#6b7280",p:.4}},{children:n.jsx(C.default,{sx:{fontSize:16}})}))]}))]})),n.jsx(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1.5},{children:D&&(g?n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1},{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#6b7280"}},{children:"Show Segments"})),n.jsx(o.Box,e.__assign({sx:{width:36,height:20,borderRadius:"10px",bgcolor:"#7c3aed",display:"flex",alignItems:"center",px:.3,cursor:"pointer"}},{children:n.jsx(o.Box,{sx:{width:14,height:14,borderRadius:"50%",bgcolor:"#fff",ml:"auto"}})}))]})):n.jsxs(o.Box,e.__assign({onClick:f,sx:{display:"flex",alignItems:"center",gap:1,px:2,py:.85,borderRadius:1.5,bgcolor:"#7c3aed",cursor:x?"default":"pointer","&:hover":{bgcolor:"#6d28d9"},userSelect:"none",opacity:x?.7:1}},{children:[n.jsx(B.default,{sx:{fontSize:15,color:"#fff"}}),n.jsx(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#fff"}},{children:x?"Extracting...":"Extract Segments"}))]})))}))]})),n.jsxs(o.Box,e.__assign({sx:{flex:1,minHeight:0,position:"relative"}},{children:[x&&n.jsx(o.Box,e.__assign({sx:{position:"absolute",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0,0,0,0.6)",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:1}},{children:n.jsx(o.Typography,e.__assign({sx:{color:"#fff",fontSize:14,fontWeight:600}},{children:"Extracting segments..."}))})),n.jsxs(o.Box,e.__assign({sx:{border:"1px solid #30363d",borderRadius:1,overflow:"hidden",height:"100%"}},{children:[n.jsxs(o.Box,e.__assign({sx:{px:2,py:1,borderBottom:"1px solid #30363d",display:"flex",alignItems:"center",gap:1,bgcolor:"#161b22",flexShrink:0}},{children:[n.jsx(o.Box,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#ff5f57"}}),n.jsx(o.Box,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#febc2e"}}),n.jsx(o.Box,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#28c840"}}),n.jsxs(o.Typography,e.__assign({sx:{ml:1,fontSize:11,color:"#8b949e",fontFamily:"monospace"}},{children:[(null===(d=null===(l=null==c?void 0:c.members)||void 0===l?void 0:l[M-1])||void 0===d?void 0:d.section_name)||"—",".xml"]})),n.jsx(o.Box,{sx:{flex:1}}),n.jsx(V,{isDarkMode:N,onChange:G})]})),n.jsx(P,{content:Q,selectedTag:Z,highlightVariable:J,isDarkMode:N,height:"100%",fontSize:14})]}))]}))]}))]}))]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),i=require("react"),o=require("@mui/material"),t=require("@mui/icons-material/ExpandMore"),r=require("@mui/icons-material/EditOutlined"),s=require("@mui/icons-material/Close"),a=require("@mui/icons-material/ArrowBack"),l=require("@mui/icons-material/NavigateBefore"),d=require("@mui/icons-material/NavigateNext"),c=require("@mui/icons-material/InfoOutlined"),u=require("@mui/icons-material/AutoFixHighOutlined"),x=require("@mui/icons-material/Check"),g=require("@mui/icons-material/Add"),f=require("@mui/icons-material/DeleteOutline"),p=require("@monaco-editor/react"),h=require("@mui/icons-material/DarkMode"),_=require("@mui/icons-material/LightMode");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=m(t),y=m(r),j=m(s),S=m(a),v=m(l),w=m(d),z=m(c),C=m(u),k=m(x),B=m(g),I=m(f),A=m(p),T=m(h),R=m(_),W={base:"vs-dark",inherit:!0,rules:[{token:"tag",foreground:"714be3",fontStyle:"bold"},{token:"attribute.name",foreground:"87CEFA"},{token:"attribute.value",foreground:"98FB98"},{token:"variable",foreground:"00FFFF"},{token:"delimiter",foreground:"888888"},{token:"white",foreground:"AAAAAA"}],colors:{"editor.foreground":"#FFFFFF","editor.background":"#030202","editorLineNumber.foreground":"#858585","editorCursor.foreground":"#FFFFFF","editorIndentGuide.background":"#404040","editorIndentGuide.activeBackground":"#707070"}},F={base:"vs",inherit:!0,rules:[{token:"tag",foreground:"5928ED",fontStyle:"bold"},{token:"attribute.name",foreground:"AF00DB"},{token:"attribute.value",foreground:"008000"},{token:"variable",foreground:"B000B0"},{token:"delimiter",foreground:"808080"},{token:"white",foreground:"000000"}],colors:{"editor.foreground":"#000000","editor.background":"#FFFFFF","editorLineNumber.foreground":"#999999","editorCursor.foreground":"#000000","editorIndentGuide.background":"#CCCCCC","editorIndentGuide.activeBackground":"#999999"}},D=function(t){var r=t.description,s=i.useState(!1),a=s[0],l=s[1],d=i.useState(!1),c=d[0],u=d[1],x=i.useRef(null);return i.useEffect(function(){var e=x.current;e&&u(e.scrollHeight>e.clientHeight+1)},[r,a]),n.jsxs(o.Box,e.__assign({sx:{mt:1.5,border:"1px solid #e5e7eb",borderRadius:2,bgcolor:"#fff",display:"flex",flexDirection:"column",px:1.25,py:1}},{children:[n.jsx(o.Typography,e.__assign({ref:x,component:"div",sx:e.__assign({fontSize:11,color:"#6b7280",lineHeight:1.5,overflowY:a?"auto":"hidden",maxHeight:a?"calc(1.6em * 5)":"calc(1.6em * 3)",whiteSpace:"normal",display:a?"block":"-webkit-box"},a?{}:{WebkitBoxOrient:"vertical",WebkitLineClamp:3})},{children:r})),c&&n.jsx(o.Typography,e.__assign({component:"span",onClick:function(){return l(function(e){return!e})},sx:{mt:.75,alignSelf:"flex-end",fontSize:10,color:"#7c3aed",cursor:"pointer",fontWeight:500}},{children:a?"View less":"View more"}))]}))},L=function(t){var r=t.value,s=t.onChange,a=t.onDelete,l=i.useState(!1),d=l[0],c=l[1];return n.jsxs(o.Box,e.__assign({sx:{display:"flex",alignItems:"flex-start",gap:1,p:1,border:"1px solid #e5e7eb",borderRadius:"8px",bgcolor:"#fff"}},{children:[n.jsx(o.Box,e.__assign({sx:{width:18,height:18,borderRadius:"4px",bgcolor:"#f1f5f9",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,color:"#64748b",flexShrink:0,mt:.1}},{children:"a"})),d?n.jsx(o.TextField,{autoFocus:!0,value:r,onChange:function(e){return s(e.target.value)},onBlur:function(){return c(!1)},size:"small",fullWidth:!0,multiline:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:12.5}}}):n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55,flex:1}},{children:r})),n.jsxs(o.Stack,e.__assign({direction:"row",gap:.25,sx:{flexShrink:0}},{children:[n.jsx(o.IconButton,e.__assign({size:"small",onClick:function(){return c(!0)},sx:{color:"#6b7280"}},{children:n.jsx(y.default,{sx:{fontSize:14}})})),n.jsx(o.IconButton,e.__assign({size:"small",onClick:a,sx:{color:"#dc2626"}},{children:n.jsx(I.default,{sx:{fontSize:14}})}))]}))]}))},M=function(i){var t=i.isDarkMode,r=i.onChange;return n.jsx(o.Box,e.__assign({onClick:function(){return r(!t)},sx:{width:52,height:24,borderRadius:"12px",bgcolor:t?"#5928ed":"#f0f0f0",border:"1px solid",borderColor:t?"#5928ed":"#d1d5db",display:"flex",alignItems:"center",px:.4,cursor:"pointer",transition:"all 0.2s",justifyContent:t?"flex-end":"flex-start"}},{children:n.jsx(o.Box,e.__assign({sx:{width:18,height:18,borderRadius:"50%",bgcolor:t?"#1e1e2e":"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"}},{children:t?n.jsx(T.default,{sx:{fontSize:11,color:"#fff"}}):n.jsx(R.default,{sx:{fontSize:11,color:"#fff"}})}))}))},E=function(t){var r=t.content,s=t.selectedTag,a=t.highlightVariable,l=t.isDarkMode,d=t.height,c=void 0===d?250:d,u=t.fontSize,x=void 0===u?12:u,g=i.useRef(),f=i.useRef();return i.useEffect(function(){if(s&&g.current&&f.current){var e=g.current,n=e.getModel();if(n){for(var i=n.getValue().split("\n"),o=-1,t=0;t<i.length;t++){var r=i[t].match(/<([^\s>\/]+(?:\s[^\s>\/]+)*)/);if(r&&r[1].trim().toLowerCase()===s.toLowerCase()){o=t+1;break}}if(o>0){var a=o,l="</".concat(s.toLowerCase(),">");for(t=o;t<i.length;t++)if(i[t].toLowerCase().includes(l)){a=t+1;break}e.setSelection(new f.current.Selection(o,1,o,1)),e.trigger(null,"editor.unfold",{}),e.revealLineInCenterIfOutsideViewport(o);var d=e.deltaDecorations([],[{range:new f.current.Range(o,1,a,i[a-1].length+1),options:{isWholeLine:!0,className:"promptemon-viewer-highlight",inlineClassName:"promptemon-viewer-highlight"}}]);setTimeout(function(){return e.deltaDecorations(d,[])},2e3)}}}},[s]),i.useEffect(function(){if(a&&g.current&&f.current){var e=g.current,n=e.getModel();if(n){for(var i=n.getValue().split("\n"),o=[],t=0;t<i.length;t++)for(var r=i[t].indexOf(a);-1!==r;)o.push(new f.current.Range(t+1,r+1,t+1,r+a.length+1)),r=i[t].indexOf(a,r+1);if(0!==o.length){e.revealLineInCenterIfOutsideViewport(o[0].startLineNumber);var s=e.deltaDecorations([],o.map(function(e){return{range:e,options:{inlineClassName:"promptemon-viewer-variable-highlight"}}}));setTimeout(function(){return e.deltaDecorations(s,[])},2e3)}}}},[a]),i.useEffect(function(){f.current&&f.current.editor.setTheme(l?"promptemonViewerDark":"promptemonViewerLight")},[l]),n.jsxs(n.Fragment,{children:[n.jsx("style",{children:"\n .promptemon-viewer-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-viewer-variable-highlight { background-color: rgba(0, 255, 255, 0.2); border-radius: 2px; }\n "}),n.jsxs(o.Box,e.__assign({sx:{width:"100%",height:c,display:"flex",flexDirection:"column"}},{children:[n.jsx(o.Box,{sx:{width:"100%",height:20,bgcolor:l?"#030202":"#fff",borderTopLeftRadius:8,borderTopRightRadius:8}}),n.jsx(o.Box,e.__assign({sx:{flex:1,minHeight:0,overflow:"hidden"}},{children:n.jsx(A.default,{onMount:function(e,n){g.current=e,f.current=n,n.editor.defineTheme("promptemonViewerDark",W),n.editor.defineTheme("promptemonViewerLight",F),n.editor.setTheme(l?"promptemonViewerDark":"promptemonViewerLight"),n.languages.register({id:"promptemonViewerLang"}),n.languages.setMonarchTokensProvider("promptemonViewerLang",{tokenizer:{root:[[/(<)([a-zA-Z0-9\-]+)(\s*)/,["delimiter","tag","white"],"@tagBody"],[/(<\/)([a-zA-Z0-9\-]+)(\s*)(>)/,["delimiter","tag","white","delimiter"]],[/{{[^}]+}}/,"variable"]],tagBody:[[/[a-zA-Z0-9\:\-]+(?=\=)/,"attribute.name"],[/=/,"delimiter"],[/(".*?"|'.*?')/,"attribute.value"],[/\s+/,"white"],[/(\/?>)/,{token:"delimiter",next:"@pop"}]]}}),n.languages.registerFoldingRangeProvider("promptemonViewerLang",{provideFoldingRanges:function(e){var n=e.getLinesContent(),i=[],o=[];return n.forEach(function(e,n){var t=n+1,r=e.match(/<([a-zA-Z0-9\-]+)(\s[^>]*)?>/),s=e.match(/<\/([a-zA-Z0-9\-]+)>/);if(r&&!e.includes("/>")&&o.push({tag:r[1],start:t}),s)for(var a=s[1],l=o.length-1;l>=0;l--)if(o[l].tag===a){i.push({start:o[l].start,end:t}),o.splice(l,1);break}}),i}})},beforeMount:function(e){e.editor.defineTheme("promptemonViewerDark",W),e.editor.defineTheme("promptemonViewerLight",F),e.editor.setTheme(l?"promptemonViewerDark":"promptemonViewerLight")},theme:l?"promptemonViewerDark":"promptemonViewerLight",value:r,language:"promptemonViewerLang",onChange:function(){},options:{fontSize:x,minimap:{enabled:!1},wordWrap:"on",lineNumbers:"on",readOnly:!0,domReadOnly:!0,scrollBeyondLastLine:!1,padding:{top:4,bottom:12},folding:!0,automaticLayout:!0,scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:8}}})})),n.jsx(o.Box,{sx:{width:"100%",height:20,bgcolor:l?"#030202":"#fff",borderBottomLeftRadius:8,borderBottomRightRadius:8}})]}))]})},V=function(t){var r,s,a,l,d=t.block,c=t.isExtracted,u=t.isSaved,x=t.showEditMode,g=t.onBlockUpdate,f=t.onTagSelect,p=t.onVariableSelect,h=t.categories,_=t.subCategories,m=t.selectedCategoryId,S=t.selectedSubCategoryId,v=t.onCategoryChange,w=t.onSubCategoryChange,C=i.useState(!0),A=C[0],T=C[1],R=i.useState(!0),W=R[0],F=R[1],M=i.useState(!0),E=M[0],V=M[1],O=i.useState(!0),P=O[0],q=O[1],N=i.useState(!1),G=N[0],H=N[1],Z=i.useState(!0),U=Z[0],Y=Z[1],J=i.useState(!0),K=J[0],Q=J[1],X=i.useState(!1),$=X[0],ee=X[1],ne=i.useState(!1),ie=ne[0],oe=ne[1],te=i.useState(!1),re=te[0],se=te[1],ae=i.useState((null==d?void 0:d.title)||""),le=ae[0],de=ae[1],ce=i.useState((null==d?void 0:d.short_description)||""),ue=ce[0],xe=ce[1],ge=i.useState((null==d?void 0:d.members)||[]),fe=ge[0],pe=ge[1],he=i.useState(Array.isArray(null==d?void 0:d.when_to_apply)?d.when_to_apply:(null==d?void 0:d.when_to_apply)?[d.when_to_apply]:[]),_e=he[0],me=he[1],be=i.useState(Array.isArray(null==d?void 0:d.when_not_to_apply)?d.when_not_to_apply:(null==d?void 0:d.when_not_to_apply)?[d.when_not_to_apply]:[]),ye=be[0],je=be[1],Se=i.useState(!1),ve=Se[0],we=Se[1],ze=i.useState(""),Ce=ze[0],ke=ze[1],Be=i.useState(""),Ie=Be[0],Ae=Be[1],Te={boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"8px !important",mb:1.5,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 12px 0"}},Re={minHeight:44,px:2,borderRadius:2,"&.Mui-expanded":{minHeight:44},"& .MuiAccordionSummary-content":{my:"10px"}};return n.jsxs(o.Box,e.__assign({sx:{width:820,flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden",borderRight:"1px solid #e5e7eb"}},{children:[n.jsxs(o.Box,e.__assign({sx:{px:2.5,py:2,borderBottom:"1px solid #e5e7eb"}},{children:[n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",justifyContent:"space-between"},{children:[n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1,sx:{flex:1,minWidth:0}},{children:[n.jsx(o.Tooltip,e.__assign({title:"Functional Prompt Block",placement:"top"},{children:n.jsx(o.Chip,{label:"FPB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:11,height:22,borderRadius:1}})})),re?n.jsx(o.TextField,{value:le,onChange:function(e){return de(e.target.value)},size:"small",fullWidth:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:15,fontWeight:700,py:.5}}}):n.jsx(o.Typography,e.__assign({sx:{fontWeight:700,fontSize:15,color:"#111827"}},{children:(null==d?void 0:d.title)||"—"}))]})),re?n.jsxs(o.Stack,e.__assign({direction:"row",gap:.5},{children:[n.jsx(o.IconButton,e.__assign({size:"small",sx:{color:"#6b7280"},onClick:function(){return se(!1)}},{children:n.jsx(j.default,{sx:{fontSize:16}})})),n.jsx(o.IconButton,e.__assign({size:"small",sx:{color:"#16a34a"},onClick:function(){g(e.__assign(e.__assign({},d),{title:le,short_description:ue,members:fe,when_to_apply:_e,when_not_to_apply:ye})),se(!1)}},{children:n.jsx(k.default,{sx:{fontSize:16}})}))]})):!u&&x&&n.jsx(o.IconButton,e.__assign({size:"small",sx:{color:"#6b7280"},onClick:function(){de((null==d?void 0:d.title)||""),xe((null==d?void 0:d.short_description)||""),pe((null==d?void 0:d.members)||[]),me(Array.isArray(null==d?void 0:d.when_to_apply)?d.when_to_apply:(null==d?void 0:d.when_to_apply)?[d.when_to_apply]:[]),je(Array.isArray(null==d?void 0:d.when_not_to_apply)?d.when_not_to_apply:(null==d?void 0:d.when_not_to_apply)?[d.when_not_to_apply]:[]),se(!0)}},{children:n.jsx(y.default,{sx:{fontSize:16}})}))]})),re&&n.jsx(o.Typography,e.__assign({sx:{fontSize:11,color:"#5928ed",mt:.5}},{children:"Editing — changes won't be saved until you confirm"})),re?n.jsx(o.TextField,{value:ue,onChange:function(e){return xe(e.target.value)},size:"small",fullWidth:!0,multiline:!0,minRows:3,sx:{mt:1.5,"& .MuiOutlinedInput-input":{fontSize:12}}}):n.jsx(D,{description:(null==d?void 0:d.short_description)||"—"}),n.jsxs(o.Box,e.__assign({sx:{mt:1.5,border:"0.5px solid #d1d5db",borderRadius:"8px",display:"flex",overflow:"hidden"}},{children:[n.jsx(o.Box,e.__assign({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",borderRight:"1px solid #d1d5db",p:.5}},{children:n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1},{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:10,color:"#87898d"}},{children:"Total APBs :"})),n.jsx(o.Typography,e.__assign({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(r=null==d?void 0:d.members)||void 0===r?void 0:r.length)||0}))]}))})),n.jsx(o.Box,e.__assign({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",p:.5}},{children:n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1},{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:10,color:"#87898d"}},{children:"Total Lines :"})),n.jsx(o.Typography,e.__assign({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(s=null==d?void 0:d.members)||void 0===s?void 0:s.reduce(function(e,n){var i,o;return e+((null!==(i=n.end_line)&&void 0!==i?i:0)-(null!==(o=n.start_line)&&void 0!==o?o:0)+1)},0))||0}))]}))}))]}))]})),n.jsxs(o.Box,e.__assign({sx:{flex:1,overflow:"auto",px:2,py:2,"&::-webkit-scrollbar":{width:4},"&::-webkit-scrollbar-thumb":{bgcolor:"#e5e7eb",borderRadius:2}}},{children:[n.jsxs(o.Accordion,e.__assign({expanded:A,onChange:function(){return T(function(e){return!e})},sx:Te,disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(b.default,{sx:{fontSize:18}}),sx:Re},{children:n.jsx(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Categories"}))})),n.jsx(o.AccordionDetails,e.__assign({sx:{pt:0,px:2,pb:2}},{children:n.jsxs(o.Stack,e.__assign({gap:1.5},{children:[n.jsxs(o.Box,{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Category"})),re?n.jsx(o.Select,e.__assign({fullWidth:!0,size:"small",value:m,onChange:function(e){v(e.target.value),w("")},sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:h.map(function(i){return n.jsx(o.MenuItem,e.__assign({value:i.category_id},{children:i.category_name}),i.category_id)})})):n.jsx(o.TextField,{fullWidth:!0,size:"small",value:(null===(a=h.find(function(e){return e.category_id===m}))||void 0===a?void 0:a.category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]}),n.jsxs(o.Box,{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Sub-Category"})),re?n.jsx(o.Select,e.__assign({fullWidth:!0,size:"small",value:S,onChange:function(e){return w(e.target.value)},disabled:!m,sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:_.filter(function(e){return e.category_id===m}).map(function(i){return n.jsx(o.MenuItem,e.__assign({value:i.sub_category_id},{children:i.sub_category_name}),i.sub_category_id)})})):n.jsx(o.TextField,{fullWidth:!0,size:"small",value:(null===(l=_.find(function(e){return e.sub_category_id===S}))||void 0===l?void 0:l.sub_category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]})]}))}))]})),n.jsxs(o.Accordion,e.__assign({expanded:W,onChange:function(){return F(function(e){return!e})},sx:Te,disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(b.default,{sx:{fontSize:18}}),sx:Re},{children:n.jsx(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Atomic Prompt Blocks (APBs)"}))})),n.jsxs(o.AccordionDetails,e.__assign({sx:{pt:0,px:1,pb:2}},{children:[n.jsx(o.Stack,e.__assign({gap:1},{children:(re?fe:(null==d?void 0:d.members)||[]).map(function(i,t){return n.jsxs(o.Box,e.__assign({sx:{px:2,py:1,borderRadius:2,bgcolor:"#fff"}},{children:[n.jsxs(o.Box,e.__assign({sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1,gap:1}},{children:[n.jsxs(o.Typography,e.__assign({sx:{fontSize:14,fontWeight:500,color:"#111827"}},{children:[t+1,". ",i.section_name]})),re?n.jsx(o.IconButton,e.__assign({size:"small",onClick:function(){return pe(function(e){return e.filter(function(e,n){return n!==t})})},sx:{color:"#dc2626",flexShrink:0}},{children:n.jsx(I.default,{sx:{fontSize:16}})})):n.jsx(o.Box,e.__assign({onClick:function(){return f(i.section_name.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join("_"))},sx:{fontSize:14,color:"#475569",cursor:"pointer",flexShrink:0}},{children:"↗"}))]})),n.jsx(o.Typography,e.__assign({sx:{fontSize:12,lineHeight:1.5,color:"#64748b"}},{children:i.reason_for_inclusion})),c&&(r=i.segments||[],0===r.length?null:n.jsx(o.Box,e.__assign({sx:{mt:1}},{children:n.jsx(o.Box,e.__assign({sx:{display:"flex",flexWrap:"wrap",gap:1}},{children:r.map(function(e,i){return n.jsx(o.Chip,{clickable:!0,onClick:function(){return p(e.segmentized_text)},label:e.segmentized_text,sx:{borderRadius:1,bgcolor:"#eff6ff",color:"#3b82f6",border:"1px dashed #bfdbfe"}},i)})}))}))),n.jsx(o.Divider,{sx:{mt:2}})]}),t);var r})})),re&&n.jsxs(o.Box,e.__assign({onClick:function(){ke(""),Ae(""),we(!0)},sx:{mt:1,display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:1,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:13,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[n.jsx(B.default,{sx:{fontSize:16}})," Add APB"]}))]}))]})),n.jsxs(o.Accordion,e.__assign({expanded:E,onChange:function(){return V(function(e){return!e})},sx:Te,disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(b.default,{sx:{fontSize:18}}),sx:Re},{children:n.jsxs(o.Typography,e.__assign({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Applicability ",n.jsx("span",e.__assign({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• When to apply / When not to apply"}))]}))})),n.jsxs(o.AccordionDetails,e.__assign({sx:{pt:0,px:1.5,pb:1.5}},{children:[n.jsxs(o.Accordion,e.__assign({expanded:P,onChange:function(){return q(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:1,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 8px 0"}},disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(b.default,{sx:{fontSize:16}}),sx:e.__assign(e.__assign({},Re),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When to Apply this FPB"}))})),n.jsx(o.AccordionDetails,e.__assign({sx:{pt:.5,px:2,pb:1.5}},{children:n.jsxs(o.Stack,e.__assign({gap:.75},{children:[(re?_e:Array.isArray(null==d?void 0:d.when_to_apply)?d.when_to_apply:(null==d?void 0:d.when_to_apply)?[d.when_to_apply]:["— Not yet available"]).map(function(i,t){return re?n.jsx(L,{value:i,onChange:function(e){return me(function(n){return n.map(function(n,i){return i===t?e:n})})},onDelete:function(){return me(function(e){return e.filter(function(e,n){return n!==t})})}},t):n.jsxs(o.Stack,e.__assign({direction:"row",gap:1,alignItems:"flex-start"},{children:[n.jsxs(o.Typography,e.__assign({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[t+1,"."]})),n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:i}))]}),t)}),re&&n.jsxs(o.Box,e.__assign({onClick:function(){return me(function(n){return e.__spreadArray(e.__spreadArray([],n,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[n.jsx(B.default,{sx:{fontSize:15}})," Add When to Apply"]}))]}))}))]})),n.jsxs(o.Accordion,e.__assign({expanded:G,onChange:function(){return H(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important","&:before":{display:"none"}},disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(b.default,{sx:{fontSize:16}}),sx:e.__assign(e.__assign({},Re),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When NOT to Apply this FPB"}))})),n.jsx(o.AccordionDetails,e.__assign({sx:{pt:.5,px:2,pb:1.5}},{children:re?n.jsxs(o.Stack,e.__assign({gap:.75},{children:[ye.map(function(e,i){return n.jsx(L,{value:e,onChange:function(e){return je(function(n){return n.map(function(n,o){return o===i?e:n})})},onDelete:function(){return je(function(e){return e.filter(function(e,n){return n!==i})})}},i)}),n.jsxs(o.Box,e.__assign({onClick:function(){return je(function(n){return e.__spreadArray(e.__spreadArray([],n,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[n.jsx(B.default,{sx:{fontSize:15}})," Add When NOT to Apply"]}))]})):Array.isArray(null==d?void 0:d.when_not_to_apply)||(null==d?void 0:d.when_not_to_apply)?n.jsx(o.Stack,e.__assign({gap:.75},{children:(Array.isArray(null==d?void 0:d.when_not_to_apply)?d.when_not_to_apply:[d.when_not_to_apply]).map(function(i,t){return n.jsxs(o.Stack,e.__assign({direction:"row",gap:1,alignItems:"flex-start"},{children:[n.jsxs(o.Typography,e.__assign({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[t+1,"."]})),n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:i}))]}),t)})})):n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#9ca3af",fontStyle:"italic"}},{children:"No conditions defined yet."}))}))]}))]}))]})),n.jsxs(o.Accordion,e.__assign({expanded:U,onChange:function(){return Y(function(e){return!e})},sx:Te,disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(b.default,{sx:{fontSize:18}}),sx:Re},{children:n.jsxs(o.Typography,e.__assign({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Specifications ",n.jsx("span",e.__assign({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• Strict Rules / Input / Output"}))]}))})),n.jsx(o.AccordionDetails,e.__assign({sx:{pt:0,px:1.5,pb:1.5}},{children:[{label:"Guidelines",expanded:K,setExpanded:Q,content:null==d?void 0:d.additional_guidelines},{label:"Input",expanded:$,setExpanded:ee,content:null},{label:"Output",expanded:ie,setExpanded:oe,content:null}].map(function(i,t){var r=i.label,s=i.expanded,a=i.setExpanded,l=i.content;return n.jsxs(o.Accordion,e.__assign({expanded:s,onChange:function(){return a(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:t<2?1:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:t<2?"0 0 8px 0":0}},disableGutters:!0},{children:[n.jsx(o.AccordionSummary,e.__assign({expandIcon:n.jsx(b.default,{sx:{fontSize:16}}),sx:e.__assign(e.__assign({},Re),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:.5},{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:r})),"Guidelines"!==r&&n.jsx(z.default,{sx:{fontSize:13,color:"#9ca3af"}})]}))})),n.jsx(o.AccordionDetails,e.__assign({sx:{pt:.5,px:2,pb:1.5}},{children:n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:l?"#374151":"#9ca3af",fontStyle:l?"normal":"italic"}},{children:l||"No ".concat(r.toLowerCase()," defined yet.")}))}))]}),r)})}))]}))]})),n.jsxs(o.Dialog,e.__assign({open:ve,onClose:function(){return we(!1)},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px"}}},{children:[n.jsxs(o.Box,e.__assign({sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e5e7eb"}},{children:[n.jsx(o.Typography,e.__assign({sx:{fontWeight:700,fontSize:"1rem",color:"#111827"}},{children:"Add new APB"})),n.jsx(o.IconButton,e.__assign({size:"small",onClick:function(){return we(!1)}},{children:n.jsx(j.default,{sx:{fontSize:"1.1rem",color:"#6b7280"}})}))]})),n.jsxs(o.Box,e.__assign({sx:{px:3,py:2.5,display:"flex",flexDirection:"column",gap:2}},{children:[n.jsxs(o.Box,{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Title"})),n.jsx(o.TextField,{fullWidth:!0,size:"small",placeholder:"Specify the title of APB",value:Ce,onChange:function(e){return ke(e.target.value)}})]}),n.jsxs(o.Box,{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Description"})),n.jsx(o.TextField,{fullWidth:!0,size:"small",multiline:!0,minRows:3,placeholder:"Describe the APB",value:Ie,onChange:function(e){return Ae(e.target.value)}})]})]})),n.jsxs(o.Box,e.__assign({sx:{px:3,py:2,display:"flex",justifyContent:"flex-end",gap:1,borderTop:"1px solid #e5e7eb"}},{children:[n.jsx(o.Button,e.__assign({variant:"outlined",onClick:function(){return we(!1)},sx:{textTransform:"none",borderColor:"#d1d5db",color:"#374151"}},{children:"Cancel"})),n.jsx(o.Button,e.__assign({variant:"contained",onClick:function(){pe(function(n){return e.__spreadArray(e.__spreadArray([],n,!0),[{section_name:Ce,reason_for_inclusion:Ie,content:""}],!1)}),we(!1)},sx:{textTransform:"none",bgcolor:"#5928ed","&:hover":{bgcolor:"#4c1d95"}}},{children:"Save"}))]}))]}))]}))};exports.default=function(t){var r,s,a,l,d,c=t.block,u=t.onBlockUpdate,x=t.isExtracting,g=t.isExtracted,f=t.onExtractSegments,p=t.isSaving,h=t.isSaved,_=t.onSave,m=t.onBack,b=t.title,y=void 0===b?"FPB Promptemon":b,z=t.categories,k=t.subCategories,B=t.selectedCategoryId,I=t.selectedSubCategoryId,A=t.onCategoryChange,T=t.onSubCategoryChange,R=t.showEditMode,W=void 0===R||R,F=t.showExtractSegments,D=void 0===F||F,L=i.useState(1),O=L[0],P=L[1],q=i.useState(!0),N=q[0],G=q[1],H=i.useState(""),Z=H[0],U=H[1],Y=i.useState(""),J=Y[0],K=Y[1],Q=(null===(r=null==c?void 0:c.members)||void 0===r?void 0:r.map(function(e){if(!g||!e.segments||0===e.segments.length)return e.content||"";var n=e.content||"";return e.segments.forEach(function(e){e.raw_text&&e.segmentized_text&&(n=n.split(e.raw_text).join(e.segmentized_text))}),n}).join("\n\n"))||"";return n.jsxs(o.Box,e.__assign({sx:{width:"100%",height:"100%",display:"flex",flexDirection:"column",bgcolor:"#fff",overflow:"hidden"}},{children:[n.jsxs(o.Box,e.__assign({sx:{px:2.5,py:1.5,borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#fff",flexShrink:0}},{children:[n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1},{children:[n.jsx(o.IconButton,e.__assign({size:"small",sx:{color:"#6b7280"},onClick:m},{children:n.jsx(S.default,{sx:{fontSize:18}})})),n.jsx(o.Typography,e.__assign({sx:{fontSize:14,fontWeight:600,color:"#111827"}},{children:y}))]})),n.jsxs(o.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:1}},{children:[n.jsx(o.Button,e.__assign({variant:"contained",size:"small",disabled:!g||p||h,onClick:_,sx:{textTransform:"none",fontSize:"0.78rem",fontWeight:600,bgcolor:"#5928ed",px:2,py:.6,"&:hover":{bgcolor:"#4c1d95"},"&.Mui-disabled":{bgcolor:"#5928ed",color:"#fff",opacity:.4}}},{children:p?"Saving...":h?"Saved ✓":"Save FPB"})),n.jsx(o.IconButton,e.__assign({size:"small",sx:{color:"#6b7280"},onClick:m},{children:n.jsx(j.default,{sx:{fontSize:18}})}))]}))]})),n.jsxs(o.Box,e.__assign({sx:{display:"flex",flex:1,overflow:"hidden"}},{children:[n.jsx(V,{block:c,isExtracted:g,isSaved:h,showEditMode:W,onBlockUpdate:u,onTagSelect:function(e){U(""),setTimeout(function(){return U(e)},50)},onVariableSelect:function(e){K(""),setTimeout(function(){return K(e)},50)},categories:z,subCategories:k,selectedCategoryId:B,selectedSubCategoryId:I,onCategoryChange:A,onSubCategoryChange:T}),n.jsxs(o.Box,e.__assign({sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",p:2,gap:1.5}},{children:[n.jsxs(o.Box,e.__assign({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0}},{children:[n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1},{children:[n.jsxs(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:[(null==c?void 0:c.title)||"—"," APBs"]})),n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:.5},{children:[n.jsx(o.IconButton,e.__assign({size:"small",onClick:function(){return P(function(e){return Math.max(1,e-1)})},disabled:1===O,sx:{color:"#6b7280",p:.4}},{children:n.jsx(v.default,{sx:{fontSize:16}})})),n.jsxs(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#6b7280"}},{children:[O," of ",(null===(s=null==c?void 0:c.members)||void 0===s?void 0:s.length)||0]})),n.jsx(o.IconButton,e.__assign({size:"small",onClick:function(){return P(function(e){var n;return Math.min((null===(n=null==c?void 0:c.members)||void 0===n?void 0:n.length)||0,e+1)})},disabled:O===((null===(a=null==c?void 0:c.members)||void 0===a?void 0:a.length)||0),sx:{color:"#6b7280",p:.4}},{children:n.jsx(w.default,{sx:{fontSize:16}})}))]}))]})),n.jsx(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1.5},{children:D&&(g?n.jsxs(o.Stack,e.__assign({direction:"row",alignItems:"center",gap:1},{children:[n.jsx(o.Typography,e.__assign({sx:{fontSize:12.5,color:"#6b7280"}},{children:"Show Segments"})),n.jsx(o.Box,e.__assign({sx:{width:36,height:20,borderRadius:"10px",bgcolor:"#7c3aed",display:"flex",alignItems:"center",px:.3,cursor:"pointer"}},{children:n.jsx(o.Box,{sx:{width:14,height:14,borderRadius:"50%",bgcolor:"#fff",ml:"auto"}})}))]})):n.jsxs(o.Box,e.__assign({onClick:f,sx:{display:"flex",alignItems:"center",gap:1,px:2,py:.85,borderRadius:1.5,bgcolor:"#7c3aed",cursor:x?"default":"pointer","&:hover":{bgcolor:"#6d28d9"},userSelect:"none",opacity:x?.7:1}},{children:[n.jsx(C.default,{sx:{fontSize:15,color:"#fff"}}),n.jsx(o.Typography,e.__assign({sx:{fontSize:13,fontWeight:600,color:"#fff"}},{children:x?"Extracting...":"Extract Segments"}))]})))}))]})),n.jsxs(o.Box,e.__assign({sx:{flex:1,minHeight:0,position:"relative"}},{children:[x&&n.jsx(o.Box,e.__assign({sx:{position:"absolute",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0,0,0,0.6)",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:1}},{children:n.jsx(o.Typography,e.__assign({sx:{color:"#fff",fontSize:14,fontWeight:600}},{children:"Extracting segments..."}))})),n.jsxs(o.Box,e.__assign({sx:{border:"1px solid #30363d",borderRadius:1,overflow:"hidden",height:"100%"}},{children:[n.jsxs(o.Box,e.__assign({sx:{px:2,py:1,borderBottom:"1px solid #30363d",display:"flex",alignItems:"center",gap:1,bgcolor:"#161b22",flexShrink:0}},{children:[n.jsx(o.Box,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#ff5f57"}}),n.jsx(o.Box,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#febc2e"}}),n.jsx(o.Box,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#28c840"}}),n.jsxs(o.Typography,e.__assign({sx:{ml:1,fontSize:11,color:"#8b949e",fontFamily:"monospace"}},{children:[(null===(d=null===(l=null==c?void 0:c.members)||void 0===l?void 0:l[O-1])||void 0===d?void 0:d.section_name)||"—",".xml"]})),n.jsx(o.Box,{sx:{flex:1}}),n.jsx(M,{isDarkMode:N,onChange:G})]})),n.jsx(E,{content:Q,selectedTag:Z,highlightVariable:J,isDarkMode:N,height:"100%",fontSize:14})]}))]}))]}))]}))]}))};
|
|
2
2
|
//# sourceMappingURL=PromptemonViewer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsxs as r,Fragment as o,jsx as t}from"react/jsx-runtime";import{useState as i,useRef as n,useEffect as l}from"react";import{Box as a,Typography as d,Tooltip as s,Dialog as c,IconButton as f,Chip as h}from"@mui/material";import g from"@mui/icons-material/Close";import m from"@mui/icons-material/Fullscreen";import u from"@monaco-editor/react";import
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as r,Fragment as o,jsx as t}from"react/jsx-runtime";import{useState as i,useRef as n,useEffect as l}from"react";import{Box as a,Typography as d,Tooltip as s,Dialog as c,IconButton as f,Chip as h}from"@mui/material";import g from"@mui/icons-material/Close";import m from"@mui/icons-material/Fullscreen";import u from"@monaco-editor/react";import p from"@mui/icons-material/DarkMode";import b from"@mui/icons-material/LightMode";var x={base:"vs-dark",inherit:!0,rules:[{token:"tag",foreground:"714be3",fontStyle:"bold"},{token:"attribute.name",foreground:"87CEFA"},{token:"attribute.value",foreground:"98FB98"},{token:"variable",foreground:"00FFFF"},{token:"delimiter",foreground:"888888"},{token:"white",foreground:"AAAAAA"}],colors:{"editor.foreground":"#FFFFFF","editor.background":"#030202","editorLineNumber.foreground":"#858585","editorCursor.foreground":"#FFFFFF","editorIndentGuide.background":"#404040","editorIndentGuide.activeBackground":"#707070"}},v={base:"vs",inherit:!0,rules:[{token:"tag",foreground:"5928ED",fontStyle:"bold"},{token:"attribute.name",foreground:"AF00DB"},{token:"attribute.value",foreground:"008000"},{token:"variable",foreground:"B000B0"},{token:"delimiter",foreground:"808080"},{token:"white",foreground:"000000"}],colors:{"editor.foreground":"#000000","editor.background":"#FFFFFF","editorLineNumber.foreground":"#999999","editorCursor.foreground":"#000000","editorIndentGuide.background":"#CCCCCC","editorIndentGuide.activeBackground":"#999999"}},k=function(r){var o=r.isDarkMode,i=r.onChange;return t(a,e({onClick:function(){return i(!o)},sx:{width:52,height:24,borderRadius:"12px",bgcolor:o?"#5928ed":"#f0f0f0",border:"1px solid",borderColor:o?"#5928ed":"#d1d5db",display:"flex",alignItems:"center",px:.4,cursor:"pointer",transition:"all 0.2s",justifyContent:o?"flex-end":"flex-start"}},{children:t(a,e({sx:{width:18,height:18,borderRadius:"50%",bgcolor:o?"#1e1e2e":"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"}},{children:t(o?p:b,{sx:{fontSize:11,color:"#fff"}})}))}))},w=function(i){var d=i.content,s=i.selectedTag,c=i.highlightVariable,f=i.isDarkMode,h=i.height,g=void 0===h?250:h,m=i.fontSize,p=void 0===m?12:m,b=n(),k=n();return l(function(){if(s&&b.current&&k.current){var e=b.current,r=e.getModel();if(r){for(var o=r.getValue().split("\n"),t=-1,i=0;i<o.length;i++){var n=o[i].match(/<([^\s>\/]+(?:\s[^\s>\/]+)*)/);if(n&&n[1].trim().toLowerCase()===s.toLowerCase()){t=i+1;break}}if(t>0){var l=t,a="</".concat(s.toLowerCase(),">");for(i=t;i<o.length;i++)if(o[i].toLowerCase().includes(a)){l=i+1;break}e.setSelection(new k.current.Selection(t,1,t,1)),e.trigger(null,"editor.unfold",{}),e.revealLineInCenterIfOutsideViewport(t);var d=e.deltaDecorations([],[{range:new k.current.Range(t,1,l,o[l-1].length+1),options:{isWholeLine:!0,className:"promptemon-highlight",inlineClassName:"promptemon-highlight"}}]);setTimeout(function(){return e.deltaDecorations(d,[])},2e3)}}}},[s]),l(function(){if(c&&b.current&&k.current){var e=b.current,r=e.getModel();if(r){for(var o=r.getValue().split("\n"),t=[],i=0;i<o.length;i++)for(var n=o[i].indexOf(c);-1!==n;)t.push(new k.current.Range(i+1,n+1,i+1,n+c.length+1)),n=o[i].indexOf(c,n+1);if(0!==t.length){e.revealLineInCenterIfOutsideViewport(t[0].startLineNumber);var l=e.deltaDecorations([],t.map(function(e){return{range:e,options:{inlineClassName:"promptemon-variable-highlight"}}}));setTimeout(function(){return e.deltaDecorations(l,[])},2e3)}}}},[c]),l(function(){k.current&&k.current.editor.setTheme(f?"promptemonDark":"promptemonLight")},[f]),r(o,{children:[t("style",{children:"\n .promptemon-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-variable-highlight { background-color: rgba(0, 255, 255, 0.2); border-radius: 2px; }\n "}),r(a,e({sx:{width:"100%",height:g,display:"flex",flexDirection:"column"}},{children:[t(a,{sx:{width:"100%",height:20,bgcolor:f?"#030202":"#fff",borderTopLeftRadius:8,borderTopRightRadius:8}}),t(a,e({sx:{flex:1,minHeight:0,overflow:"hidden"}},{children:t(u,{onMount:function(e,r){b.current=e,k.current=r,r.editor.defineTheme("promptemonDark",x),r.editor.defineTheme("promptemonLight",v),r.editor.setTheme(f?"promptemonDark":"promptemonLight"),r.languages.register({id:"promptemonLang"}),r.languages.setMonarchTokensProvider("promptemonLang",{tokenizer:{root:[[/(<)([a-zA-Z0-9\-]+)(\s*)/,["delimiter","tag","white"],"@tagBody"],[/(<\/)([a-zA-Z0-9\-]+)(\s*)(>)/,["delimiter","tag","white","delimiter"]],[/{{[^}]+}}/,"variable"]],tagBody:[[/[a-zA-Z0-9\:\-]+(?=\=)/,"attribute.name"],[/=/,"delimiter"],[/(".*?"|'.*?')/,"attribute.value"],[/\s+/,"white"],[/(\/?>)/,{token:"delimiter",next:"@pop"}]]}}),r.languages.registerFoldingRangeProvider("promptemonLang",{provideFoldingRanges:function(e){var r=e.getLinesContent(),o=[],t=[];return r.forEach(function(e,r){var i=r+1,n=e.match(/<([a-zA-Z0-9\-]+)(\s[^>]*)?>/),l=e.match(/<\/([a-zA-Z0-9\-]+)>/);if(n&&!e.includes("/>")&&t.push({tag:n[1],start:i}),l)for(var a=l[1],d=t.length-1;d>=0;d--)if(t[d].tag===a){o.push({start:t[d].start,end:i}),t.splice(d,1);break}}),o}})},beforeMount:function(e){e.editor.defineTheme("promptemonDark",x),e.editor.defineTheme("promptemonLight",v),e.editor.setTheme(f?"promptemonDark":"promptemonLight")},theme:f?"promptemonDark":"promptemonLight",value:d,language:"promptemonLang",onChange:function(){},options:{fontSize:p,minimap:{enabled:!1},wordWrap:"on",lineNumbers:"on",readOnly:!0,domReadOnly:!0,scrollBeyondLastLine:!1,padding:{top:4,bottom:12},folding:!0,automaticLayout:!0,scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:8}}})})),t(a,{sx:{width:"100%",height:20,bgcolor:f?"#030202":"#fff",borderBottomLeftRadius:8,borderBottomRightRadius:8}})]}))]})},C=function(n){var l=n.title,u=n.description,p=n.content,b=n.height,x=void 0===b?250:b,v=n.selectedTag,C=n.highlightVariable,y=i(!0),F=y[0],L=y[1],z=i(!1),D=z[0],B=z[1];return r(o,{children:[r(a,e({sx:{border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden"}},{children:[r(a,e({sx:{px:1.5,py:.75,bgcolor:"#f9fafb",borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[t(d,e({sx:{fontSize:"0.72rem",color:"#374151",fontWeight:600}},{children:l})),r(a,e({sx:{display:"flex",alignItems:"center",gap:.75}},{children:[t(k,{isDarkMode:F,onChange:L}),t(s,e({title:"Fullscreen",placement:"top"},{children:t(a,e({onClick:function(){return B(!0)},sx:{cursor:"pointer",display:"flex",alignItems:"center",p:.3,borderRadius:"4px","&:hover":{bgcolor:"#e5e7eb"}}},{children:t(m,{sx:{fontSize:"0.9rem",color:"#6b7280"}})}))}))]}))]})),t(a,e({sx:{height:x,bgcolor:F?"#030202":"#fff"}},{children:t(w,{content:p,selectedTag:v,highlightVariable:C,isDarkMode:F,height:x,fontSize:12})}))]})),r(c,e({open:D,onClose:function(){return B(!1)},maxWidth:!1,PaperProps:{sx:{width:"82vw",height:"80vh",maxWidth:"none",borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column"}}},{children:[r(a,e({sx:{px:2.5,py:1.5,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0}},{children:[t(d,e({sx:{fontWeight:700,fontSize:"1rem",color:"#111827"}},{children:l})),t(f,e({size:"small",onClick:function(){return B(!1)}},{children:t(g,{sx:{fontSize:"1.1rem",color:"#6B7280"}})}))]})),r(a,e({sx:{flex:1,display:"flex",overflow:"hidden",minHeight:0}},{children:[u&&r(a,e({sx:{width:"35%",flexShrink:0,borderRight:"1px solid #E5E7EB",display:"flex",flexDirection:"column",overflow:"hidden"}},{children:[r(a,e({sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",gap:1}},{children:[t(h,{label:"APB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:10,height:20,borderRadius:1}}),t(d,e({sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827"}},{children:l}))]})),t(a,e({sx:{flex:1,p:2,overflowY:"auto"}},{children:r(a,e({sx:{border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5}},{children:[t(d,e({sx:{fontWeight:600,fontSize:"0.8rem",color:"#111827",mb:.75}},{children:"Description"})),t(d,e({sx:{fontSize:"0.73rem",color:"#6B7280",lineHeight:1.6}},{children:u}))]}))}))]})),r(a,e({sx:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"}},{children:[r(a,e({sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[t(d,e({sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827"}},{children:"Prompt Preview"})),t(k,{isDarkMode:F,onChange:L})]})),t(a,e({sx:{flex:1,minHeight:0,p:1.5}},{children:t(w,{content:p,selectedTag:v,highlightVariable:C,isDarkMode:F,height:"100%",fontSize:13})}))]}))]}))]}))]})};export{C as default};
|
|
2
2
|
//# sourceMappingURL=PromptemonBlockViewer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as o,jsx as t,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as l,useEffect as d}from"react";import{Box as a,Stack as c,IconButton as s,Typography as u,Button as f,Tooltip as p,Chip as h,TextField as g,Accordion as m,AccordionSummary as x,AccordionDetails as b,Select as v,MenuItem as y,Divider as w,Dialog as S}from"@mui/material";import z from"@mui/icons-material/ExpandMore";import C from"@mui/icons-material/EditOutlined";import _ from"@mui/icons-material/Close";import k from"@mui/icons-material/ArrowBack";import I from"@mui/icons-material/NavigateBefore";import W from"@mui/icons-material/NavigateNext";import R from"@mui/icons-material/InfoOutlined";import A from"@mui/icons-material/AutoFixHighOutlined";import B from"@mui/icons-material/Check";import F from"@mui/icons-material/Add";import L from"@mui/icons-material/DeleteOutline";import D from"@monaco-editor/react";import*as M from"monaco-editor";import T from"@mui/icons-material/DarkMode";import V from"@mui/icons-material/LightMode";var E={base:"vs-dark",inherit:!0,rules:[{token:"tag",foreground:"714be3",fontStyle:"bold"},{token:"attribute.name",foreground:"87CEFA"},{token:"attribute.value",foreground:"98FB98"},{token:"variable",foreground:"00FFFF"},{token:"delimiter",foreground:"888888"},{token:"white",foreground:"AAAAAA"}],colors:{"editor.foreground":"#FFFFFF","editor.background":"#030202","editorLineNumber.foreground":"#858585","editorCursor.foreground":"#FFFFFF","editorIndentGuide.background":"#404040","editorIndentGuide.activeBackground":"#707070"}},O={base:"vs",inherit:!0,rules:[{token:"tag",foreground:"5928ED",fontStyle:"bold"},{token:"attribute.name",foreground:"AF00DB"},{token:"attribute.value",foreground:"008000"},{token:"variable",foreground:"B000B0"},{token:"delimiter",foreground:"808080"},{token:"white",foreground:"000000"}],colors:{"editor.foreground":"#000000","editor.background":"#FFFFFF","editorLineNumber.foreground":"#999999","editorCursor.foreground":"#000000","editorIndentGuide.background":"#CCCCCC","editorIndentGuide.activeBackground":"#999999"}},P=function(n){var i=n.description,c=r(!1),s=c[0],f=c[1],p=r(!1),h=p[0],g=p[1],m=l(null);return d(function(){var e=m.current;e&&g(e.scrollHeight>e.clientHeight+1)},[i,s]),o(a,e({sx:{mt:1.5,border:"1px solid #e5e7eb",borderRadius:2,bgcolor:"#fff",display:"flex",flexDirection:"column",px:1.25,py:1}},{children:[t(u,e({ref:m,component:"div",sx:e({fontSize:11,color:"#6b7280",lineHeight:1.5,overflowY:s?"auto":"hidden",maxHeight:s?"calc(1.6em * 5)":"calc(1.6em * 3)",whiteSpace:"normal",display:s?"block":"-webkit-box"},s?{}:{WebkitBoxOrient:"vertical",WebkitLineClamp:3})},{children:i})),h&&t(u,e({component:"span",onClick:function(){return f(function(e){return!e})},sx:{mt:.75,alignSelf:"flex-end",fontSize:10,color:"#7c3aed",cursor:"pointer",fontWeight:500}},{children:s?"View less":"View more"}))]}))},j=function(n){var i=n.value,l=n.onChange,d=n.onDelete,f=r(!1),p=f[0],h=f[1];return o(a,e({sx:{display:"flex",alignItems:"flex-start",gap:1,p:1,border:"1px solid #e5e7eb",borderRadius:"8px",bgcolor:"#fff"}},{children:[t(a,e({sx:{width:18,height:18,borderRadius:"4px",bgcolor:"#f1f5f9",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,color:"#64748b",flexShrink:0,mt:.1}},{children:"a"})),p?t(g,{autoFocus:!0,value:i,onChange:function(e){return l(e.target.value)},onBlur:function(){return h(!1)},size:"small",fullWidth:!0,multiline:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:12.5}}}):t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55,flex:1}},{children:i})),o(c,e({direction:"row",gap:.25,sx:{flexShrink:0}},{children:[t(s,e({size:"small",onClick:function(){return h(!0)},sx:{color:"#6b7280"}},{children:t(C,{sx:{fontSize:14}})})),t(s,e({size:"small",onClick:d,sx:{color:"#dc2626"}},{children:t(L,{sx:{fontSize:14}})}))]}))]}))},N=function(n){var o=n.isDarkMode,i=n.onChange;return t(a,e({onClick:function(){return i(!o)},sx:{width:52,height:24,borderRadius:"12px",bgcolor:o?"#5928ed":"#f0f0f0",border:"1px solid",borderColor:o?"#5928ed":"#d1d5db",display:"flex",alignItems:"center",px:.4,cursor:"pointer",transition:"all 0.2s",justifyContent:o?"flex-end":"flex-start"}},{children:t(a,e({sx:{width:18,height:18,borderRadius:"50%",bgcolor:o?"#1e1e2e":"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"}},{children:t(o?T:V,{sx:{fontSize:11,color:"#fff"}})}))}))},G=function(n){var r=n.content,c=n.selectedTag,s=n.highlightVariable,u=n.isDarkMode,f=n.height,p=void 0===f?250:f,h=n.fontSize,g=void 0===h?12:h,m=l(),x=l();return d(function(){if(c&&m.current&&x.current){var e=m.current,n=e.getModel();if(n){for(var o=n.getValue().split("\n"),t=-1,i=0;i<o.length;i++){var r=o[i].match(/<([^\s>\/]+(?:\s[^\s>\/]+)*)/);if(r&&r[1].trim().toLowerCase()===c.toLowerCase()){t=i+1;break}}if(t>0){var l=t,d="</".concat(c.toLowerCase(),">");for(i=t;i<o.length;i++)if(o[i].toLowerCase().includes(d)){l=i+1;break}e.setSelection(new x.current.Selection(t,1,t,1)),e.trigger(null,"editor.unfold",{}),e.revealLineInCenterIfOutsideViewport(t);var a=e.deltaDecorations([],[{range:new x.current.Range(t,1,l,o[l-1].length+1),options:{isWholeLine:!0,className:"promptemon-viewer-highlight",inlineClassName:"promptemon-viewer-highlight"}}]);setTimeout(function(){return e.deltaDecorations(a,[])},2e3)}}}},[c]),d(function(){if(s&&m.current&&x.current){var e=m.current,n=e.getModel();if(n){for(var o=n.getValue().split("\n"),t=[],i=0;i<o.length;i++)for(var r=o[i].indexOf(s);-1!==r;)t.push(new M.Range(i+1,r+1,i+1,r+s.length+1)),r=o[i].indexOf(s,r+1);if(0!==t.length){e.revealLineInCenterIfOutsideViewport(t[0].startLineNumber);var l=e.deltaDecorations([],t.map(function(e){return{range:e,options:{inlineClassName:"promptemon-viewer-variable-highlight"}}}));setTimeout(function(){return e.deltaDecorations(l,[])},2e3)}}}},[s]),d(function(){x.current&&x.current.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight")},[u]),o(i,{children:[t("style",{children:"\n .promptemon-viewer-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-viewer-variable-highlight { background-color: rgba(0, 255, 255, 0.2); border-radius: 2px; }\n "}),o(a,e({sx:{width:"100%",height:p,display:"flex",flexDirection:"column"}},{children:[t(a,{sx:{width:"100%",height:20,bgcolor:u?"#030202":"#fff",borderTopLeftRadius:8,borderTopRightRadius:8}}),t(a,e({sx:{flex:1,minHeight:0,overflow:"hidden"}},{children:t(D,{onMount:function(e,n){m.current=e,x.current=n,n.editor.defineTheme("promptemonViewerDark",E),n.editor.defineTheme("promptemonViewerLight",O),n.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight"),n.languages.register({id:"promptemonViewerLang"}),n.languages.setMonarchTokensProvider("promptemonViewerLang",{tokenizer:{root:[[/(<)([a-zA-Z0-9\-]+)(\s*)/,["delimiter","tag","white"],"@tagBody"],[/(<\/)([a-zA-Z0-9\-]+)(\s*)(>)/,["delimiter","tag","white","delimiter"]],[/{{[^}]+}}/,"variable"]],tagBody:[[/[a-zA-Z0-9\:\-]+(?=\=)/,"attribute.name"],[/=/,"delimiter"],[/(".*?"|'.*?')/,"attribute.value"],[/\s+/,"white"],[/(\/?>)/,{token:"delimiter",next:"@pop"}]]}}),n.languages.registerFoldingRangeProvider("promptemonViewerLang",{provideFoldingRanges:function(e){var n=e.getLinesContent(),o=[],t=[];return n.forEach(function(e,n){var i=n+1,r=e.match(/<([a-zA-Z0-9\-]+)(\s[^>]*)?>/),l=e.match(/<\/([a-zA-Z0-9\-]+)>/);if(r&&!e.includes("/>")&&t.push({tag:r[1],start:i}),l)for(var d=l[1],a=t.length-1;a>=0;a--)if(t[a].tag===d){o.push({start:t[a].start,end:i}),t.splice(a,1);break}}),o}})},beforeMount:function(e){e.editor.defineTheme("promptemonViewerDark",E),e.editor.defineTheme("promptemonViewerLight",O),e.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight")},theme:u?"promptemonViewerDark":"promptemonViewerLight",value:r,language:"promptemonViewerLang",onChange:function(){},options:{fontSize:g,minimap:{enabled:!1},wordWrap:"on",lineNumbers:"on",readOnly:!0,domReadOnly:!0,scrollBeyondLastLine:!1,padding:{top:4,bottom:12},folding:!0,automaticLayout:!0,scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:8}}})})),t(a,{sx:{width:"100%",height:20,bgcolor:u?"#030202":"#fff",borderBottomLeftRadius:8,borderBottomRightRadius:8}})]}))]})},H=function(i){var l,d,k,I,W=i.block,A=i.isExtracted,D=i.isSaved,M=i.showEditMode,T=i.onBlockUpdate,V=i.onTagSelect,E=i.onVariableSelect,O=i.categories,N=i.subCategories,G=i.selectedCategoryId,H=i.selectedSubCategoryId,Z=i.onCategoryChange,U=i.onSubCategoryChange,Y=r(!0),q=Y[0],J=Y[1],K=r(!0),Q=K[0],X=K[1],$=r(!0),ee=$[0],ne=$[1],oe=r(!0),te=oe[0],ie=oe[1],re=r(!1),le=re[0],de=re[1],ae=r(!0),ce=ae[0],se=ae[1],ue=r(!0),fe=ue[0],pe=ue[1],he=r(!1),ge=he[0],me=he[1],xe=r(!1),be=xe[0],ve=xe[1],ye=r(!1),we=ye[0],Se=ye[1],ze=r((null==W?void 0:W.title)||""),Ce=ze[0],_e=ze[1],ke=r((null==W?void 0:W.short_description)||""),Ie=ke[0],We=ke[1],Re=r((null==W?void 0:W.members)||[]),Ae=Re[0],Be=Re[1],Fe=r(Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:[]),Le=Fe[0],De=Fe[1],Me=r(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:(null==W?void 0:W.when_not_to_apply)?[W.when_not_to_apply]:[]),Te=Me[0],Ve=Me[1],Ee=r(!1),Oe=Ee[0],Pe=Ee[1],je=r(""),Ne=je[0],Ge=je[1],He=r(""),Ze=He[0],Ue=He[1],Ye={boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"8px !important",mb:1.5,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 12px 0"}},qe={minHeight:44,px:2,borderRadius:2,"&.Mui-expanded":{minHeight:44},"& .MuiAccordionSummary-content":{my:"10px"}};return o(a,e({sx:{width:820,flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden",borderRight:"1px solid #e5e7eb"}},{children:[o(a,e({sx:{px:2.5,py:2,borderBottom:"1px solid #e5e7eb"}},{children:[o(c,e({direction:"row",alignItems:"center",justifyContent:"space-between"},{children:[o(c,e({direction:"row",alignItems:"center",gap:1,sx:{flex:1,minWidth:0}},{children:[t(p,e({title:"Functional Prompt Block",placement:"top"},{children:t(h,{label:"FPB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:11,height:22,borderRadius:1}})})),we?t(g,{value:Ce,onChange:function(e){return _e(e.target.value)},size:"small",fullWidth:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:15,fontWeight:700,py:.5}}}):t(u,e({sx:{fontWeight:700,fontSize:15,color:"#111827"}},{children:(null==W?void 0:W.title)||"—"}))]})),we?o(c,e({direction:"row",gap:.5},{children:[t(s,e({size:"small",sx:{color:"#6b7280"},onClick:function(){return Se(!1)}},{children:t(_,{sx:{fontSize:16}})})),t(s,e({size:"small",sx:{color:"#16a34a"},onClick:function(){T(e(e({},W),{title:Ce,short_description:Ie,members:Ae,when_to_apply:Le,when_not_to_apply:Te})),Se(!1)}},{children:t(B,{sx:{fontSize:16}})}))]})):!D&&M&&t(s,e({size:"small",sx:{color:"#6b7280"},onClick:function(){_e((null==W?void 0:W.title)||""),We((null==W?void 0:W.short_description)||""),Be((null==W?void 0:W.members)||[]),De(Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:[]),Ve(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:(null==W?void 0:W.when_not_to_apply)?[W.when_not_to_apply]:[]),Se(!0)}},{children:t(C,{sx:{fontSize:16}})}))]})),we&&t(u,e({sx:{fontSize:11,color:"#5928ed",mt:.5}},{children:"Editing — changes won't be saved until you confirm"})),we?t(g,{value:Ie,onChange:function(e){return We(e.target.value)},size:"small",fullWidth:!0,multiline:!0,minRows:3,sx:{mt:1.5,"& .MuiOutlinedInput-input":{fontSize:12}}}):t(P,{description:(null==W?void 0:W.short_description)||"—"}),o(a,e({sx:{mt:1.5,border:"0.5px solid #d1d5db",borderRadius:"8px",display:"flex",overflow:"hidden"}},{children:[t(a,e({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",borderRight:"1px solid #d1d5db",p:.5}},{children:o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:10,color:"#87898d"}},{children:"Total APBs :"})),t(u,e({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(l=null==W?void 0:W.members)||void 0===l?void 0:l.length)||0}))]}))})),t(a,e({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",p:.5}},{children:o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:10,color:"#87898d"}},{children:"Total Lines :"})),t(u,e({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(d=null==W?void 0:W.members)||void 0===d?void 0:d.reduce(function(e,n){var o,t;return e+((null!==(o=n.end_line)&&void 0!==o?o:0)-(null!==(t=n.start_line)&&void 0!==t?t:0)+1)},0))||0}))]}))}))]}))]})),o(a,e({sx:{flex:1,overflow:"auto",px:2,py:2,"&::-webkit-scrollbar":{width:4},"&::-webkit-scrollbar-thumb":{bgcolor:"#e5e7eb",borderRadius:2}}},{children:[o(m,e({expanded:q,onChange:function(){return J(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Categories"}))})),t(b,e({sx:{pt:0,px:2,pb:2}},{children:o(c,e({gap:1.5},{children:[o(a,{children:[t(u,e({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Category"})),we?t(v,e({fullWidth:!0,size:"small",value:G,onChange:function(e){Z(e.target.value),U("")},sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:O.map(function(n){return t(y,e({value:n.category_id},{children:n.category_name}),n.category_id)})})):t(g,{fullWidth:!0,size:"small",value:(null===(k=O.find(function(e){return e.category_id===G}))||void 0===k?void 0:k.category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]}),o(a,{children:[t(u,e({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Sub-Category"})),we?t(v,e({fullWidth:!0,size:"small",value:H,onChange:function(e){return U(e.target.value)},disabled:!G,sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:N.filter(function(e){return e.category_id===G}).map(function(n){return t(y,e({value:n.sub_category_id},{children:n.sub_category_name}),n.sub_category_id)})})):t(g,{fullWidth:!0,size:"small",value:(null===(I=N.find(function(e){return e.sub_category_id===H}))||void 0===I?void 0:I.sub_category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]})]}))}))]})),o(m,e({expanded:Q,onChange:function(){return X(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Atomic Prompt Blocks (APBs)"}))})),o(b,e({sx:{pt:0,px:1,pb:2}},{children:[t(c,e({gap:1},{children:(we?Ae:(null==W?void 0:W.members)||[]).map(function(n,i){return o(a,e({sx:{px:2,py:1,borderRadius:2,bgcolor:"#fff"}},{children:[o(a,e({sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1,gap:1}},{children:[o(u,e({sx:{fontSize:14,fontWeight:500,color:"#111827"}},{children:[i+1,". ",n.section_name]})),we?t(s,e({size:"small",onClick:function(){return Be(function(e){return e.filter(function(e,n){return n!==i})})},sx:{color:"#dc2626",flexShrink:0}},{children:t(L,{sx:{fontSize:16}})})):t(a,e({onClick:function(){return V(n.section_name.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join("_"))},sx:{fontSize:14,color:"#475569",cursor:"pointer",flexShrink:0}},{children:"↗"}))]})),t(u,e({sx:{fontSize:12,lineHeight:1.5,color:"#64748b"}},{children:n.reason_for_inclusion})),A&&(r=n.segments||[],0===r.length?null:t(a,e({sx:{mt:1}},{children:t(a,e({sx:{display:"flex",flexWrap:"wrap",gap:1}},{children:r.map(function(e,n){return t(h,{clickable:!0,onClick:function(){return E(e.segmentized_text)},label:e.segmentized_text,sx:{borderRadius:1,bgcolor:"#eff6ff",color:"#3b82f6",border:"1px dashed #bfdbfe"}},n)})}))}))),t(w,{sx:{mt:2}})]}),i);var r})})),we&&o(a,e({onClick:function(){Ge(""),Ue(""),Pe(!0)},sx:{mt:1,display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:1,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:13,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:16}})," Add APB"]}))]}))]})),o(m,e({expanded:ee,onChange:function(){return ne(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:o(u,e({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Applicability ",t("span",e({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• When to apply / When not to apply"}))]}))})),o(b,e({sx:{pt:0,px:1.5,pb:1.5}},{children:[o(m,e({expanded:te,onChange:function(){return ie(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:1,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 8px 0"}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When to Apply this FPB"}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:o(c,e({gap:.75},{children:[(we?Le:Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:["— Not yet available"]).map(function(n,i){return we?t(j,{value:n,onChange:function(e){return De(function(n){return n.map(function(n,o){return o===i?e:n})})},onDelete:function(){return De(function(e){return e.filter(function(e,n){return n!==i})})}},i):o(c,e({direction:"row",gap:1,alignItems:"flex-start"},{children:[o(u,e({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[i+1,"."]})),t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:n}))]}),i)}),we&&o(a,e({onClick:function(){return De(function(e){return n(n([],e,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:15}})," Add When to Apply"]}))]}))}))]})),o(m,e({expanded:le,onChange:function(){return de(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important","&:before":{display:"none"}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When NOT to Apply this FPB"}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:we?o(c,e({gap:.75},{children:[Te.map(function(e,n){return t(j,{value:e,onChange:function(e){return Ve(function(o){return o.map(function(o,t){return t===n?e:o})})},onDelete:function(){return Ve(function(e){return e.filter(function(e,o){return o!==n})})}},n)}),o(a,e({onClick:function(){return Ve(function(e){return n(n([],e,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:15}})," Add When NOT to Apply"]}))]})):Array.isArray(null==W?void 0:W.when_not_to_apply)||(null==W?void 0:W.when_not_to_apply)?t(c,e({gap:.75},{children:(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:[W.when_not_to_apply]).map(function(n,i){return o(c,e({direction:"row",gap:1,alignItems:"flex-start"},{children:[o(u,e({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[i+1,"."]})),t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:n}))]}),i)})})):t(u,e({sx:{fontSize:12.5,color:"#9ca3af",fontStyle:"italic"}},{children:"No conditions defined yet."}))}))]}))]}))]})),o(m,e({expanded:ce,onChange:function(){return se(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:o(u,e({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Specifications ",t("span",e({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• Strict Rules / Input / Output"}))]}))})),t(b,e({sx:{pt:0,px:1.5,pb:1.5}},{children:[{label:"Guidelines",expanded:fe,setExpanded:pe,content:null==W?void 0:W.additional_guidelines},{label:"Input",expanded:ge,setExpanded:me,content:null},{label:"Output",expanded:be,setExpanded:ve,content:null}].map(function(n,i){var r=n.label,l=n.expanded,d=n.setExpanded,a=n.content;return o(m,e({expanded:l,onChange:function(){return d(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:i<2?1:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:i<2?"0 0 8px 0":0}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:o(c,e({direction:"row",alignItems:"center",gap:.5},{children:[t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:r})),"Guidelines"!==r&&t(R,{sx:{fontSize:13,color:"#9ca3af"}})]}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:t(u,e({sx:{fontSize:12.5,color:a?"#374151":"#9ca3af",fontStyle:a?"normal":"italic"}},{children:a||"No ".concat(r.toLowerCase()," defined yet.")}))}))]}),r)})}))]}))]})),o(S,e({open:Oe,onClose:function(){return Pe(!1)},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px"}}},{children:[o(a,e({sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e5e7eb"}},{children:[t(u,e({sx:{fontWeight:700,fontSize:"1rem",color:"#111827"}},{children:"Add new APB"})),t(s,e({size:"small",onClick:function(){return Pe(!1)}},{children:t(_,{sx:{fontSize:"1.1rem",color:"#6b7280"}})}))]})),o(a,e({sx:{px:3,py:2.5,display:"flex",flexDirection:"column",gap:2}},{children:[o(a,{children:[t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Title"})),t(g,{fullWidth:!0,size:"small",placeholder:"Specify the title of APB",value:Ne,onChange:function(e){return Ge(e.target.value)}})]}),o(a,{children:[t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Description"})),t(g,{fullWidth:!0,size:"small",multiline:!0,minRows:3,placeholder:"Describe the APB",value:Ze,onChange:function(e){return Ue(e.target.value)}})]})]})),o(a,e({sx:{px:3,py:2,display:"flex",justifyContent:"flex-end",gap:1,borderTop:"1px solid #e5e7eb"}},{children:[t(f,e({variant:"outlined",onClick:function(){return Pe(!1)},sx:{textTransform:"none",borderColor:"#d1d5db",color:"#374151"}},{children:"Cancel"})),t(f,e({variant:"contained",onClick:function(){Be(function(e){return n(n([],e,!0),[{section_name:Ne,reason_for_inclusion:Ze,content:""}],!1)}),Pe(!1)},sx:{textTransform:"none",bgcolor:"#5928ed","&:hover":{bgcolor:"#4c1d95"}}},{children:"Save"}))]}))]}))]}))},Z=function(n){var i,l,d,p,h,g=n.block,m=n.onBlockUpdate,x=n.isExtracting,b=n.isExtracted,v=n.onExtractSegments,y=n.isSaving,w=n.isSaved,S=n.onSave,z=n.onBack,C=n.title,R=void 0===C?"FPB Promptemon":C,B=n.categories,F=n.subCategories,L=n.selectedCategoryId,D=n.selectedSubCategoryId,M=n.onCategoryChange,T=n.onSubCategoryChange,V=n.showEditMode,E=void 0===V||V,O=n.showExtractSegments,P=void 0===O||O,j=r(1),Z=j[0],U=j[1],Y=r(!0),q=Y[0],J=Y[1],K=r(""),Q=K[0],X=K[1],$=r(""),ee=$[0],ne=$[1],oe=(null===(i=null==g?void 0:g.members)||void 0===i?void 0:i.map(function(e){if(!b||!e.segments||0===e.segments.length)return e.content||"";var n=e.content||"";return e.segments.forEach(function(e){e.raw_text&&e.segmentized_text&&(n=n.split(e.raw_text).join(e.segmentized_text))}),n}).join("\n\n"))||"";return o(a,e({sx:{width:"100%",height:"100%",display:"flex",flexDirection:"column",bgcolor:"#fff",overflow:"hidden"}},{children:[o(a,e({sx:{px:2.5,py:1.5,borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#fff",flexShrink:0}},{children:[o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(s,e({size:"small",sx:{color:"#6b7280"},onClick:z},{children:t(k,{sx:{fontSize:18}})})),t(u,e({sx:{fontSize:14,fontWeight:600,color:"#111827"}},{children:R}))]})),o(a,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:[t(f,e({variant:"contained",size:"small",disabled:!b||y||w,onClick:S,sx:{textTransform:"none",fontSize:"0.78rem",fontWeight:600,bgcolor:"#5928ed",px:2,py:.6,"&:hover":{bgcolor:"#4c1d95"},"&.Mui-disabled":{bgcolor:"#5928ed",color:"#fff",opacity:.4}}},{children:y?"Saving...":w?"Saved ✓":"Save FPB"})),t(s,e({size:"small",sx:{color:"#6b7280"},onClick:z},{children:t(_,{sx:{fontSize:18}})}))]}))]})),o(a,e({sx:{display:"flex",flex:1,overflow:"hidden"}},{children:[t(H,{block:g,isExtracted:b,isSaved:w,showEditMode:E,onBlockUpdate:m,onTagSelect:function(e){X(""),setTimeout(function(){return X(e)},50)},onVariableSelect:function(e){ne(""),setTimeout(function(){return ne(e)},50)},categories:B,subCategories:F,selectedCategoryId:L,selectedSubCategoryId:D,onCategoryChange:M,onSubCategoryChange:T}),o(a,e({sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",p:2,gap:1.5}},{children:[o(a,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0}},{children:[o(c,e({direction:"row",alignItems:"center",gap:1},{children:[o(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:[(null==g?void 0:g.title)||"—"," APBs"]})),o(c,e({direction:"row",alignItems:"center",gap:.5},{children:[t(s,e({size:"small",onClick:function(){return U(function(e){return Math.max(1,e-1)})},disabled:1===Z,sx:{color:"#6b7280",p:.4}},{children:t(I,{sx:{fontSize:16}})})),o(u,e({sx:{fontSize:12.5,color:"#6b7280"}},{children:[Z," of ",(null===(l=null==g?void 0:g.members)||void 0===l?void 0:l.length)||0]})),t(s,e({size:"small",onClick:function(){return U(function(e){var n;return Math.min((null===(n=null==g?void 0:g.members)||void 0===n?void 0:n.length)||0,e+1)})},disabled:Z===((null===(d=null==g?void 0:g.members)||void 0===d?void 0:d.length)||0),sx:{color:"#6b7280",p:.4}},{children:t(W,{sx:{fontSize:16}})}))]}))]})),t(c,e({direction:"row",alignItems:"center",gap:1.5},{children:P&&(b?o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:12.5,color:"#6b7280"}},{children:"Show Segments"})),t(a,e({sx:{width:36,height:20,borderRadius:"10px",bgcolor:"#7c3aed",display:"flex",alignItems:"center",px:.3,cursor:"pointer"}},{children:t(a,{sx:{width:14,height:14,borderRadius:"50%",bgcolor:"#fff",ml:"auto"}})}))]})):o(a,e({onClick:v,sx:{display:"flex",alignItems:"center",gap:1,px:2,py:.85,borderRadius:1.5,bgcolor:"#7c3aed",cursor:x?"default":"pointer","&:hover":{bgcolor:"#6d28d9"},userSelect:"none",opacity:x?.7:1}},{children:[t(A,{sx:{fontSize:15,color:"#fff"}}),t(u,e({sx:{fontSize:13,fontWeight:600,color:"#fff"}},{children:x?"Extracting...":"Extract Segments"}))]})))}))]})),o(a,e({sx:{flex:1,minHeight:0,position:"relative"}},{children:[x&&t(a,e({sx:{position:"absolute",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0,0,0,0.6)",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:1}},{children:t(u,e({sx:{color:"#fff",fontSize:14,fontWeight:600}},{children:"Extracting segments..."}))})),o(a,e({sx:{border:"1px solid #30363d",borderRadius:1,overflow:"hidden",height:"100%"}},{children:[o(a,e({sx:{px:2,py:1,borderBottom:"1px solid #30363d",display:"flex",alignItems:"center",gap:1,bgcolor:"#161b22",flexShrink:0}},{children:[t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#ff5f57"}}),t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#febc2e"}}),t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#28c840"}}),o(u,e({sx:{ml:1,fontSize:11,color:"#8b949e",fontFamily:"monospace"}},{children:[(null===(h=null===(p=null==g?void 0:g.members)||void 0===p?void 0:p[Z-1])||void 0===h?void 0:h.section_name)||"—",".xml"]})),t(a,{sx:{flex:1}}),t(N,{isDarkMode:q,onChange:J})]})),t(G,{content:oe,selectedTag:Q,highlightVariable:ee,isDarkMode:q,height:"100%",fontSize:14})]}))]}))]}))]}))]}))};export{Z as default};
|
|
1
|
+
import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as o,jsx as t,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as l,useEffect as d}from"react";import{Box as a,Stack as c,IconButton as s,Typography as u,Button as f,Tooltip as p,Chip as h,TextField as g,Accordion as m,AccordionSummary as x,AccordionDetails as b,Select as v,MenuItem as y,Divider as w,Dialog as S}from"@mui/material";import z from"@mui/icons-material/ExpandMore";import C from"@mui/icons-material/EditOutlined";import _ from"@mui/icons-material/Close";import k from"@mui/icons-material/ArrowBack";import I from"@mui/icons-material/NavigateBefore";import W from"@mui/icons-material/NavigateNext";import R from"@mui/icons-material/InfoOutlined";import A from"@mui/icons-material/AutoFixHighOutlined";import B from"@mui/icons-material/Check";import F from"@mui/icons-material/Add";import L from"@mui/icons-material/DeleteOutline";import D from"@monaco-editor/react";import M from"@mui/icons-material/DarkMode";import T from"@mui/icons-material/LightMode";var V={base:"vs-dark",inherit:!0,rules:[{token:"tag",foreground:"714be3",fontStyle:"bold"},{token:"attribute.name",foreground:"87CEFA"},{token:"attribute.value",foreground:"98FB98"},{token:"variable",foreground:"00FFFF"},{token:"delimiter",foreground:"888888"},{token:"white",foreground:"AAAAAA"}],colors:{"editor.foreground":"#FFFFFF","editor.background":"#030202","editorLineNumber.foreground":"#858585","editorCursor.foreground":"#FFFFFF","editorIndentGuide.background":"#404040","editorIndentGuide.activeBackground":"#707070"}},E={base:"vs",inherit:!0,rules:[{token:"tag",foreground:"5928ED",fontStyle:"bold"},{token:"attribute.name",foreground:"AF00DB"},{token:"attribute.value",foreground:"008000"},{token:"variable",foreground:"B000B0"},{token:"delimiter",foreground:"808080"},{token:"white",foreground:"000000"}],colors:{"editor.foreground":"#000000","editor.background":"#FFFFFF","editorLineNumber.foreground":"#999999","editorCursor.foreground":"#000000","editorIndentGuide.background":"#CCCCCC","editorIndentGuide.activeBackground":"#999999"}},O=function(n){var i=n.description,c=r(!1),s=c[0],f=c[1],p=r(!1),h=p[0],g=p[1],m=l(null);return d(function(){var e=m.current;e&&g(e.scrollHeight>e.clientHeight+1)},[i,s]),o(a,e({sx:{mt:1.5,border:"1px solid #e5e7eb",borderRadius:2,bgcolor:"#fff",display:"flex",flexDirection:"column",px:1.25,py:1}},{children:[t(u,e({ref:m,component:"div",sx:e({fontSize:11,color:"#6b7280",lineHeight:1.5,overflowY:s?"auto":"hidden",maxHeight:s?"calc(1.6em * 5)":"calc(1.6em * 3)",whiteSpace:"normal",display:s?"block":"-webkit-box"},s?{}:{WebkitBoxOrient:"vertical",WebkitLineClamp:3})},{children:i})),h&&t(u,e({component:"span",onClick:function(){return f(function(e){return!e})},sx:{mt:.75,alignSelf:"flex-end",fontSize:10,color:"#7c3aed",cursor:"pointer",fontWeight:500}},{children:s?"View less":"View more"}))]}))},P=function(n){var i=n.value,l=n.onChange,d=n.onDelete,f=r(!1),p=f[0],h=f[1];return o(a,e({sx:{display:"flex",alignItems:"flex-start",gap:1,p:1,border:"1px solid #e5e7eb",borderRadius:"8px",bgcolor:"#fff"}},{children:[t(a,e({sx:{width:18,height:18,borderRadius:"4px",bgcolor:"#f1f5f9",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,color:"#64748b",flexShrink:0,mt:.1}},{children:"a"})),p?t(g,{autoFocus:!0,value:i,onChange:function(e){return l(e.target.value)},onBlur:function(){return h(!1)},size:"small",fullWidth:!0,multiline:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:12.5}}}):t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55,flex:1}},{children:i})),o(c,e({direction:"row",gap:.25,sx:{flexShrink:0}},{children:[t(s,e({size:"small",onClick:function(){return h(!0)},sx:{color:"#6b7280"}},{children:t(C,{sx:{fontSize:14}})})),t(s,e({size:"small",onClick:d,sx:{color:"#dc2626"}},{children:t(L,{sx:{fontSize:14}})}))]}))]}))},j=function(n){var o=n.isDarkMode,i=n.onChange;return t(a,e({onClick:function(){return i(!o)},sx:{width:52,height:24,borderRadius:"12px",bgcolor:o?"#5928ed":"#f0f0f0",border:"1px solid",borderColor:o?"#5928ed":"#d1d5db",display:"flex",alignItems:"center",px:.4,cursor:"pointer",transition:"all 0.2s",justifyContent:o?"flex-end":"flex-start"}},{children:t(a,e({sx:{width:18,height:18,borderRadius:"50%",bgcolor:o?"#1e1e2e":"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"}},{children:t(o?M:T,{sx:{fontSize:11,color:"#fff"}})}))}))},N=function(n){var r=n.content,c=n.selectedTag,s=n.highlightVariable,u=n.isDarkMode,f=n.height,p=void 0===f?250:f,h=n.fontSize,g=void 0===h?12:h,m=l(),x=l();return d(function(){if(c&&m.current&&x.current){var e=m.current,n=e.getModel();if(n){for(var o=n.getValue().split("\n"),t=-1,i=0;i<o.length;i++){var r=o[i].match(/<([^\s>\/]+(?:\s[^\s>\/]+)*)/);if(r&&r[1].trim().toLowerCase()===c.toLowerCase()){t=i+1;break}}if(t>0){var l=t,d="</".concat(c.toLowerCase(),">");for(i=t;i<o.length;i++)if(o[i].toLowerCase().includes(d)){l=i+1;break}e.setSelection(new x.current.Selection(t,1,t,1)),e.trigger(null,"editor.unfold",{}),e.revealLineInCenterIfOutsideViewport(t);var a=e.deltaDecorations([],[{range:new x.current.Range(t,1,l,o[l-1].length+1),options:{isWholeLine:!0,className:"promptemon-viewer-highlight",inlineClassName:"promptemon-viewer-highlight"}}]);setTimeout(function(){return e.deltaDecorations(a,[])},2e3)}}}},[c]),d(function(){if(s&&m.current&&x.current){var e=m.current,n=e.getModel();if(n){for(var o=n.getValue().split("\n"),t=[],i=0;i<o.length;i++)for(var r=o[i].indexOf(s);-1!==r;)t.push(new x.current.Range(i+1,r+1,i+1,r+s.length+1)),r=o[i].indexOf(s,r+1);if(0!==t.length){e.revealLineInCenterIfOutsideViewport(t[0].startLineNumber);var l=e.deltaDecorations([],t.map(function(e){return{range:e,options:{inlineClassName:"promptemon-viewer-variable-highlight"}}}));setTimeout(function(){return e.deltaDecorations(l,[])},2e3)}}}},[s]),d(function(){x.current&&x.current.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight")},[u]),o(i,{children:[t("style",{children:"\n .promptemon-viewer-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-viewer-variable-highlight { background-color: rgba(0, 255, 255, 0.2); border-radius: 2px; }\n "}),o(a,e({sx:{width:"100%",height:p,display:"flex",flexDirection:"column"}},{children:[t(a,{sx:{width:"100%",height:20,bgcolor:u?"#030202":"#fff",borderTopLeftRadius:8,borderTopRightRadius:8}}),t(a,e({sx:{flex:1,minHeight:0,overflow:"hidden"}},{children:t(D,{onMount:function(e,n){m.current=e,x.current=n,n.editor.defineTheme("promptemonViewerDark",V),n.editor.defineTheme("promptemonViewerLight",E),n.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight"),n.languages.register({id:"promptemonViewerLang"}),n.languages.setMonarchTokensProvider("promptemonViewerLang",{tokenizer:{root:[[/(<)([a-zA-Z0-9\-]+)(\s*)/,["delimiter","tag","white"],"@tagBody"],[/(<\/)([a-zA-Z0-9\-]+)(\s*)(>)/,["delimiter","tag","white","delimiter"]],[/{{[^}]+}}/,"variable"]],tagBody:[[/[a-zA-Z0-9\:\-]+(?=\=)/,"attribute.name"],[/=/,"delimiter"],[/(".*?"|'.*?')/,"attribute.value"],[/\s+/,"white"],[/(\/?>)/,{token:"delimiter",next:"@pop"}]]}}),n.languages.registerFoldingRangeProvider("promptemonViewerLang",{provideFoldingRanges:function(e){var n=e.getLinesContent(),o=[],t=[];return n.forEach(function(e,n){var i=n+1,r=e.match(/<([a-zA-Z0-9\-]+)(\s[^>]*)?>/),l=e.match(/<\/([a-zA-Z0-9\-]+)>/);if(r&&!e.includes("/>")&&t.push({tag:r[1],start:i}),l)for(var d=l[1],a=t.length-1;a>=0;a--)if(t[a].tag===d){o.push({start:t[a].start,end:i}),t.splice(a,1);break}}),o}})},beforeMount:function(e){e.editor.defineTheme("promptemonViewerDark",V),e.editor.defineTheme("promptemonViewerLight",E),e.editor.setTheme(u?"promptemonViewerDark":"promptemonViewerLight")},theme:u?"promptemonViewerDark":"promptemonViewerLight",value:r,language:"promptemonViewerLang",onChange:function(){},options:{fontSize:g,minimap:{enabled:!1},wordWrap:"on",lineNumbers:"on",readOnly:!0,domReadOnly:!0,scrollBeyondLastLine:!1,padding:{top:4,bottom:12},folding:!0,automaticLayout:!0,scrollbar:{vertical:"visible",horizontal:"visible",verticalScrollbarSize:8}}})})),t(a,{sx:{width:"100%",height:20,bgcolor:u?"#030202":"#fff",borderBottomLeftRadius:8,borderBottomRightRadius:8}})]}))]})},G=function(i){var l,d,k,I,W=i.block,A=i.isExtracted,D=i.isSaved,M=i.showEditMode,T=i.onBlockUpdate,V=i.onTagSelect,E=i.onVariableSelect,j=i.categories,N=i.subCategories,G=i.selectedCategoryId,H=i.selectedSubCategoryId,Z=i.onCategoryChange,U=i.onSubCategoryChange,Y=r(!0),q=Y[0],J=Y[1],K=r(!0),Q=K[0],X=K[1],$=r(!0),ee=$[0],ne=$[1],oe=r(!0),te=oe[0],ie=oe[1],re=r(!1),le=re[0],de=re[1],ae=r(!0),ce=ae[0],se=ae[1],ue=r(!0),fe=ue[0],pe=ue[1],he=r(!1),ge=he[0],me=he[1],xe=r(!1),be=xe[0],ve=xe[1],ye=r(!1),we=ye[0],Se=ye[1],ze=r((null==W?void 0:W.title)||""),Ce=ze[0],_e=ze[1],ke=r((null==W?void 0:W.short_description)||""),Ie=ke[0],We=ke[1],Re=r((null==W?void 0:W.members)||[]),Ae=Re[0],Be=Re[1],Fe=r(Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:[]),Le=Fe[0],De=Fe[1],Me=r(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:(null==W?void 0:W.when_not_to_apply)?[W.when_not_to_apply]:[]),Te=Me[0],Ve=Me[1],Ee=r(!1),Oe=Ee[0],Pe=Ee[1],je=r(""),Ne=je[0],Ge=je[1],He=r(""),Ze=He[0],Ue=He[1],Ye={boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"8px !important",mb:1.5,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 12px 0"}},qe={minHeight:44,px:2,borderRadius:2,"&.Mui-expanded":{minHeight:44},"& .MuiAccordionSummary-content":{my:"10px"}};return o(a,e({sx:{width:820,flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden",borderRight:"1px solid #e5e7eb"}},{children:[o(a,e({sx:{px:2.5,py:2,borderBottom:"1px solid #e5e7eb"}},{children:[o(c,e({direction:"row",alignItems:"center",justifyContent:"space-between"},{children:[o(c,e({direction:"row",alignItems:"center",gap:1,sx:{flex:1,minWidth:0}},{children:[t(p,e({title:"Functional Prompt Block",placement:"top"},{children:t(h,{label:"FPB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:11,height:22,borderRadius:1}})})),we?t(g,{value:Ce,onChange:function(e){return _e(e.target.value)},size:"small",fullWidth:!0,sx:{"& .MuiOutlinedInput-input":{fontSize:15,fontWeight:700,py:.5}}}):t(u,e({sx:{fontWeight:700,fontSize:15,color:"#111827"}},{children:(null==W?void 0:W.title)||"—"}))]})),we?o(c,e({direction:"row",gap:.5},{children:[t(s,e({size:"small",sx:{color:"#6b7280"},onClick:function(){return Se(!1)}},{children:t(_,{sx:{fontSize:16}})})),t(s,e({size:"small",sx:{color:"#16a34a"},onClick:function(){T(e(e({},W),{title:Ce,short_description:Ie,members:Ae,when_to_apply:Le,when_not_to_apply:Te})),Se(!1)}},{children:t(B,{sx:{fontSize:16}})}))]})):!D&&M&&t(s,e({size:"small",sx:{color:"#6b7280"},onClick:function(){_e((null==W?void 0:W.title)||""),We((null==W?void 0:W.short_description)||""),Be((null==W?void 0:W.members)||[]),De(Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:[]),Ve(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:(null==W?void 0:W.when_not_to_apply)?[W.when_not_to_apply]:[]),Se(!0)}},{children:t(C,{sx:{fontSize:16}})}))]})),we&&t(u,e({sx:{fontSize:11,color:"#5928ed",mt:.5}},{children:"Editing — changes won't be saved until you confirm"})),we?t(g,{value:Ie,onChange:function(e){return We(e.target.value)},size:"small",fullWidth:!0,multiline:!0,minRows:3,sx:{mt:1.5,"& .MuiOutlinedInput-input":{fontSize:12}}}):t(O,{description:(null==W?void 0:W.short_description)||"—"}),o(a,e({sx:{mt:1.5,border:"0.5px solid #d1d5db",borderRadius:"8px",display:"flex",overflow:"hidden"}},{children:[t(a,e({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",borderRight:"1px solid #d1d5db",p:.5}},{children:o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:10,color:"#87898d"}},{children:"Total APBs :"})),t(u,e({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(l=null==W?void 0:W.members)||void 0===l?void 0:l.length)||0}))]}))})),t(a,e({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",p:.5}},{children:o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:10,color:"#87898d"}},{children:"Total Lines :"})),t(u,e({sx:{fontSize:10,fontWeight:700,color:"#5f5f5f"}},{children:(null===(d=null==W?void 0:W.members)||void 0===d?void 0:d.reduce(function(e,n){var o,t;return e+((null!==(o=n.end_line)&&void 0!==o?o:0)-(null!==(t=n.start_line)&&void 0!==t?t:0)+1)},0))||0}))]}))}))]}))]})),o(a,e({sx:{flex:1,overflow:"auto",px:2,py:2,"&::-webkit-scrollbar":{width:4},"&::-webkit-scrollbar-thumb":{bgcolor:"#e5e7eb",borderRadius:2}}},{children:[o(m,e({expanded:q,onChange:function(){return J(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Categories"}))})),t(b,e({sx:{pt:0,px:2,pb:2}},{children:o(c,e({gap:1.5},{children:[o(a,{children:[t(u,e({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Category"})),we?t(v,e({fullWidth:!0,size:"small",value:G,onChange:function(e){Z(e.target.value),U("")},sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:j.map(function(n){return t(y,e({value:n.category_id},{children:n.category_name}),n.category_id)})})):t(g,{fullWidth:!0,size:"small",value:(null===(k=j.find(function(e){return e.category_id===G}))||void 0===k?void 0:k.category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]}),o(a,{children:[t(u,e({sx:{fontSize:12,color:"#6b7280",mb:.5}},{children:"Sub-Category"})),we?t(v,e({fullWidth:!0,size:"small",value:H,onChange:function(e){return U(e.target.value)},disabled:!G,sx:{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}},{children:N.filter(function(e){return e.category_id===G}).map(function(n){return t(y,e({value:n.sub_category_id},{children:n.sub_category_name}),n.sub_category_id)})})):t(g,{fullWidth:!0,size:"small",value:(null===(I=N.find(function(e){return e.sub_category_id===H}))||void 0===I?void 0:I.sub_category_name)||"—",InputProps:{readOnly:!0},sx:{"& .MuiOutlinedInput-root":{fontSize:13,borderRadius:1.5,"& fieldset":{borderColor:"#e5e7eb"}}}})]})]}))}))]})),o(m,e({expanded:Q,onChange:function(){return X(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:"Atomic Prompt Blocks (APBs)"}))})),o(b,e({sx:{pt:0,px:1,pb:2}},{children:[t(c,e({gap:1},{children:(we?Ae:(null==W?void 0:W.members)||[]).map(function(n,i){return o(a,e({sx:{px:2,py:1,borderRadius:2,bgcolor:"#fff"}},{children:[o(a,e({sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1,gap:1}},{children:[o(u,e({sx:{fontSize:14,fontWeight:500,color:"#111827"}},{children:[i+1,". ",n.section_name]})),we?t(s,e({size:"small",onClick:function(){return Be(function(e){return e.filter(function(e,n){return n!==i})})},sx:{color:"#dc2626",flexShrink:0}},{children:t(L,{sx:{fontSize:16}})})):t(a,e({onClick:function(){return V(n.section_name.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join("_"))},sx:{fontSize:14,color:"#475569",cursor:"pointer",flexShrink:0}},{children:"↗"}))]})),t(u,e({sx:{fontSize:12,lineHeight:1.5,color:"#64748b"}},{children:n.reason_for_inclusion})),A&&(r=n.segments||[],0===r.length?null:t(a,e({sx:{mt:1}},{children:t(a,e({sx:{display:"flex",flexWrap:"wrap",gap:1}},{children:r.map(function(e,n){return t(h,{clickable:!0,onClick:function(){return E(e.segmentized_text)},label:e.segmentized_text,sx:{borderRadius:1,bgcolor:"#eff6ff",color:"#3b82f6",border:"1px dashed #bfdbfe"}},n)})}))}))),t(w,{sx:{mt:2}})]}),i);var r})})),we&&o(a,e({onClick:function(){Ge(""),Ue(""),Pe(!0)},sx:{mt:1,display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:1,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:13,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:16}})," Add APB"]}))]}))]})),o(m,e({expanded:ee,onChange:function(){return ne(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:o(u,e({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Applicability ",t("span",e({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• When to apply / When not to apply"}))]}))})),o(b,e({sx:{pt:0,px:1.5,pb:1.5}},{children:[o(m,e({expanded:te,onChange:function(){return ie(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:1,"&:before":{display:"none"},"&.Mui-expanded":{margin:"0 0 8px 0"}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When to Apply this FPB"}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:o(c,e({gap:.75},{children:[(we?Le:Array.isArray(null==W?void 0:W.when_to_apply)?W.when_to_apply:(null==W?void 0:W.when_to_apply)?[W.when_to_apply]:["— Not yet available"]).map(function(n,i){return we?t(P,{value:n,onChange:function(e){return De(function(n){return n.map(function(n,o){return o===i?e:n})})},onDelete:function(){return De(function(e){return e.filter(function(e,n){return n!==i})})}},i):o(c,e({direction:"row",gap:1,alignItems:"flex-start"},{children:[o(u,e({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[i+1,"."]})),t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:n}))]}),i)}),we&&o(a,e({onClick:function(){return De(function(e){return n(n([],e,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:15}})," Add When to Apply"]}))]}))}))]})),o(m,e({expanded:le,onChange:function(){return de(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important","&:before":{display:"none"}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:"When NOT to Apply this FPB"}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:we?o(c,e({gap:.75},{children:[Te.map(function(e,n){return t(P,{value:e,onChange:function(e){return Ve(function(o){return o.map(function(o,t){return t===n?e:o})})},onDelete:function(){return Ve(function(e){return e.filter(function(e,o){return o!==n})})}},n)}),o(a,e({onClick:function(){return Ve(function(e){return n(n([],e,!0),[""],!1)})},sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.5,py:.75,border:"1px dashed #d1d5db",borderRadius:1.5,cursor:"pointer",color:"#5928ed",fontSize:12.5,fontWeight:600,"&:hover":{bgcolor:"#f5f0ff"}}},{children:[t(F,{sx:{fontSize:15}})," Add When NOT to Apply"]}))]})):Array.isArray(null==W?void 0:W.when_not_to_apply)||(null==W?void 0:W.when_not_to_apply)?t(c,e({gap:.75},{children:(Array.isArray(null==W?void 0:W.when_not_to_apply)?W.when_not_to_apply:[W.when_not_to_apply]).map(function(n,i){return o(c,e({direction:"row",gap:1,alignItems:"flex-start"},{children:[o(u,e({sx:{fontSize:12,color:"#374151",fontWeight:700,mt:.1}},{children:[i+1,"."]})),t(u,e({sx:{fontSize:12.5,color:"#374151",lineHeight:1.55}},{children:n}))]}),i)})})):t(u,e({sx:{fontSize:12.5,color:"#9ca3af",fontStyle:"italic"}},{children:"No conditions defined yet."}))}))]}))]}))]})),o(m,e({expanded:ce,onChange:function(){return se(function(e){return!e})},sx:Ye,disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:18}}),sx:qe},{children:o(u,e({sx:{fontSize:14,fontWeight:600,color:"#374151",display:"flex",alignItems:"center",flexDirection:"row"}},{children:["Specifications ",t("span",e({style:{color:"#94a3b8",fontWeight:400,fontSize:10,marginLeft:"12px"}},{children:"• Strict Rules / Input / Output"}))]}))})),t(b,e({sx:{pt:0,px:1.5,pb:1.5}},{children:[{label:"Guidelines",expanded:fe,setExpanded:pe,content:null==W?void 0:W.additional_guidelines},{label:"Input",expanded:ge,setExpanded:me,content:null},{label:"Output",expanded:be,setExpanded:ve,content:null}].map(function(n,i){var r=n.label,l=n.expanded,d=n.setExpanded,a=n.content;return o(m,e({expanded:l,onChange:function(){return d(function(e){return!e})},sx:{boxShadow:"none",border:"1px solid #e5e7eb",borderRadius:"6px !important",mb:i<2?1:0,"&:before":{display:"none"},"&.Mui-expanded":{margin:i<2?"0 0 8px 0":0}},disableGutters:!0},{children:[t(x,e({expandIcon:t(z,{sx:{fontSize:16}}),sx:e(e({},qe),{bgcolor:"#f9fafb",borderRadius:"6px"})},{children:o(c,e({direction:"row",alignItems:"center",gap:.5},{children:[t(u,e({sx:{fontSize:12.5,fontWeight:500,color:"#374151"}},{children:r})),"Guidelines"!==r&&t(R,{sx:{fontSize:13,color:"#9ca3af"}})]}))})),t(b,e({sx:{pt:.5,px:2,pb:1.5}},{children:t(u,e({sx:{fontSize:12.5,color:a?"#374151":"#9ca3af",fontStyle:a?"normal":"italic"}},{children:a||"No ".concat(r.toLowerCase()," defined yet.")}))}))]}),r)})}))]}))]})),o(S,e({open:Oe,onClose:function(){return Pe(!1)},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px"}}},{children:[o(a,e({sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e5e7eb"}},{children:[t(u,e({sx:{fontWeight:700,fontSize:"1rem",color:"#111827"}},{children:"Add new APB"})),t(s,e({size:"small",onClick:function(){return Pe(!1)}},{children:t(_,{sx:{fontSize:"1.1rem",color:"#6b7280"}})}))]})),o(a,e({sx:{px:3,py:2.5,display:"flex",flexDirection:"column",gap:2}},{children:[o(a,{children:[t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Title"})),t(g,{fullWidth:!0,size:"small",placeholder:"Specify the title of APB",value:Ne,onChange:function(e){return Ge(e.target.value)}})]}),o(a,{children:[t(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151",mb:.75}},{children:"Description"})),t(g,{fullWidth:!0,size:"small",multiline:!0,minRows:3,placeholder:"Describe the APB",value:Ze,onChange:function(e){return Ue(e.target.value)}})]})]})),o(a,e({sx:{px:3,py:2,display:"flex",justifyContent:"flex-end",gap:1,borderTop:"1px solid #e5e7eb"}},{children:[t(f,e({variant:"outlined",onClick:function(){return Pe(!1)},sx:{textTransform:"none",borderColor:"#d1d5db",color:"#374151"}},{children:"Cancel"})),t(f,e({variant:"contained",onClick:function(){Be(function(e){return n(n([],e,!0),[{section_name:Ne,reason_for_inclusion:Ze,content:""}],!1)}),Pe(!1)},sx:{textTransform:"none",bgcolor:"#5928ed","&:hover":{bgcolor:"#4c1d95"}}},{children:"Save"}))]}))]}))]}))},H=function(n){var i,l,d,p,h,g=n.block,m=n.onBlockUpdate,x=n.isExtracting,b=n.isExtracted,v=n.onExtractSegments,y=n.isSaving,w=n.isSaved,S=n.onSave,z=n.onBack,C=n.title,R=void 0===C?"FPB Promptemon":C,B=n.categories,F=n.subCategories,L=n.selectedCategoryId,D=n.selectedSubCategoryId,M=n.onCategoryChange,T=n.onSubCategoryChange,V=n.showEditMode,E=void 0===V||V,O=n.showExtractSegments,P=void 0===O||O,H=r(1),Z=H[0],U=H[1],Y=r(!0),q=Y[0],J=Y[1],K=r(""),Q=K[0],X=K[1],$=r(""),ee=$[0],ne=$[1],oe=(null===(i=null==g?void 0:g.members)||void 0===i?void 0:i.map(function(e){if(!b||!e.segments||0===e.segments.length)return e.content||"";var n=e.content||"";return e.segments.forEach(function(e){e.raw_text&&e.segmentized_text&&(n=n.split(e.raw_text).join(e.segmentized_text))}),n}).join("\n\n"))||"";return o(a,e({sx:{width:"100%",height:"100%",display:"flex",flexDirection:"column",bgcolor:"#fff",overflow:"hidden"}},{children:[o(a,e({sx:{px:2.5,py:1.5,borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#fff",flexShrink:0}},{children:[o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(s,e({size:"small",sx:{color:"#6b7280"},onClick:z},{children:t(k,{sx:{fontSize:18}})})),t(u,e({sx:{fontSize:14,fontWeight:600,color:"#111827"}},{children:R}))]})),o(a,e({sx:{display:"flex",alignItems:"center",gap:1}},{children:[t(f,e({variant:"contained",size:"small",disabled:!b||y||w,onClick:S,sx:{textTransform:"none",fontSize:"0.78rem",fontWeight:600,bgcolor:"#5928ed",px:2,py:.6,"&:hover":{bgcolor:"#4c1d95"},"&.Mui-disabled":{bgcolor:"#5928ed",color:"#fff",opacity:.4}}},{children:y?"Saving...":w?"Saved ✓":"Save FPB"})),t(s,e({size:"small",sx:{color:"#6b7280"},onClick:z},{children:t(_,{sx:{fontSize:18}})}))]}))]})),o(a,e({sx:{display:"flex",flex:1,overflow:"hidden"}},{children:[t(G,{block:g,isExtracted:b,isSaved:w,showEditMode:E,onBlockUpdate:m,onTagSelect:function(e){X(""),setTimeout(function(){return X(e)},50)},onVariableSelect:function(e){ne(""),setTimeout(function(){return ne(e)},50)},categories:B,subCategories:F,selectedCategoryId:L,selectedSubCategoryId:D,onCategoryChange:M,onSubCategoryChange:T}),o(a,e({sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",p:2,gap:1.5}},{children:[o(a,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0}},{children:[o(c,e({direction:"row",alignItems:"center",gap:1},{children:[o(u,e({sx:{fontSize:13,fontWeight:600,color:"#374151"}},{children:[(null==g?void 0:g.title)||"—"," APBs"]})),o(c,e({direction:"row",alignItems:"center",gap:.5},{children:[t(s,e({size:"small",onClick:function(){return U(function(e){return Math.max(1,e-1)})},disabled:1===Z,sx:{color:"#6b7280",p:.4}},{children:t(I,{sx:{fontSize:16}})})),o(u,e({sx:{fontSize:12.5,color:"#6b7280"}},{children:[Z," of ",(null===(l=null==g?void 0:g.members)||void 0===l?void 0:l.length)||0]})),t(s,e({size:"small",onClick:function(){return U(function(e){var n;return Math.min((null===(n=null==g?void 0:g.members)||void 0===n?void 0:n.length)||0,e+1)})},disabled:Z===((null===(d=null==g?void 0:g.members)||void 0===d?void 0:d.length)||0),sx:{color:"#6b7280",p:.4}},{children:t(W,{sx:{fontSize:16}})}))]}))]})),t(c,e({direction:"row",alignItems:"center",gap:1.5},{children:P&&(b?o(c,e({direction:"row",alignItems:"center",gap:1},{children:[t(u,e({sx:{fontSize:12.5,color:"#6b7280"}},{children:"Show Segments"})),t(a,e({sx:{width:36,height:20,borderRadius:"10px",bgcolor:"#7c3aed",display:"flex",alignItems:"center",px:.3,cursor:"pointer"}},{children:t(a,{sx:{width:14,height:14,borderRadius:"50%",bgcolor:"#fff",ml:"auto"}})}))]})):o(a,e({onClick:v,sx:{display:"flex",alignItems:"center",gap:1,px:2,py:.85,borderRadius:1.5,bgcolor:"#7c3aed",cursor:x?"default":"pointer","&:hover":{bgcolor:"#6d28d9"},userSelect:"none",opacity:x?.7:1}},{children:[t(A,{sx:{fontSize:15,color:"#fff"}}),t(u,e({sx:{fontSize:13,fontWeight:600,color:"#fff"}},{children:x?"Extracting...":"Extract Segments"}))]})))}))]})),o(a,e({sx:{flex:1,minHeight:0,position:"relative"}},{children:[x&&t(a,e({sx:{position:"absolute",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0,0,0,0.6)",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:1}},{children:t(u,e({sx:{color:"#fff",fontSize:14,fontWeight:600}},{children:"Extracting segments..."}))})),o(a,e({sx:{border:"1px solid #30363d",borderRadius:1,overflow:"hidden",height:"100%"}},{children:[o(a,e({sx:{px:2,py:1,borderBottom:"1px solid #30363d",display:"flex",alignItems:"center",gap:1,bgcolor:"#161b22",flexShrink:0}},{children:[t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#ff5f57"}}),t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#febc2e"}}),t(a,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"#28c840"}}),o(u,e({sx:{ml:1,fontSize:11,color:"#8b949e",fontFamily:"monospace"}},{children:[(null===(h=null===(p=null==g?void 0:g.members)||void 0===p?void 0:p[Z-1])||void 0===h?void 0:h.section_name)||"—",".xml"]})),t(a,{sx:{flex:1}}),t(j,{isDarkMode:q,onChange:J})]})),t(N,{content:oe,selectedTag:Q,highlightVariable:ee,isDarkMode:q,height:"100%",fontSize:14})]}))]}))]}))]}))]}))};export{H as default};
|
|
2
2
|
//# sourceMappingURL=PromptemonViewer.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const useCompareLayout: (initialMaintainOrder: boolean, scrollContainerRef: React.RefObject<HTMLDivElement>, lhsBadgeRefs: any, rhsBadgeRefs: any, proposedSections: any[], existingSections: any[]) => {
|
|
2
3
|
maintainRelativeOrder: boolean;
|
|
3
4
|
setMaintainRelativeOrder: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompareLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/hooks/useCompareLayout.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,yBACL,OAAO,sBACT,MAAM,SAAS,CAAC,cAAc,CAAC,gBACrC,GAAG,gBACH,GAAG,oBACC,GAAG,EAAE,oBACL,GAAG,EAAE;;;;;;;;;;;;;;;;;;;;;;CAkFxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"useCompareLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/features/CognitiveCompare/hooks/useCompareLayout.tsx"],"names":[],"mappings":";AAGA,eAAO,MAAM,gBAAgB,yBACL,OAAO,sBACT,MAAM,SAAS,CAAC,cAAc,CAAC,gBACrC,GAAG,gBACH,GAAG,oBACC,GAAG,EAAE,oBACL,GAAG,EAAE;;;;;;;;;;;;;;;;;;;;;;CAkFxB,CAAC"}
|