@e-llm-studio/citation 0.0.233 → 0.0.234-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/cjs/features/CognitiveCompare/CitationAnchor.js +1 -1
  2. package/dist/cjs/features/CognitiveCompare/CognitiveCompare.js +1 -1
  3. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/helper.js +1 -1
  4. package/dist/cjs/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  5. package/dist/cjs/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  6. package/dist/cjs/features/CognitiveCompare/components/SvgConnectors.js +1 -1
  7. package/dist/cjs/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  8. package/dist/cjs/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  9. package/dist/cjs/features/PromptemonBlockViewer/PromptemonBlockViewer.js +1 -1
  10. package/dist/cjs/features/PromptemonViewer/PromptemonViewer.js +1 -1
  11. package/dist/features/CognitiveCompare/CitationAnchor.js +1 -1
  12. package/dist/features/CognitiveCompare/CognitiveCompare.js +1 -1
  13. package/dist/features/CognitiveCompare/Guidelines/utils/helper.js +1 -1
  14. package/dist/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.js +1 -1
  15. package/dist/features/CognitiveCompare/components/SectionAccordion.js +1 -1
  16. package/dist/features/CognitiveCompare/components/SvgConnectors.js +1 -1
  17. package/dist/features/CognitiveCompare/hooks/useCompareData.js +1 -1
  18. package/dist/features/CognitiveCompare/hooks/useLinesCalculator.js +1 -1
  19. package/dist/features/PromptemonBlockViewer/PromptemonBlockViewer.js +1 -1
  20. package/dist/features/PromptemonViewer/PromptemonViewer.js +1 -1
  21. package/dist/types/src/CognitiveCompareTest.d.ts.map +1 -1
  22. package/dist/types/src/features/CognitiveCompare/CitationAnchor.d.ts.map +1 -1
  23. package/dist/types/src/features/CognitiveCompare/CognitiveCompare.d.ts.map +1 -1
  24. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts +0 -13
  25. package/dist/types/src/features/CognitiveCompare/CognitiveCompareTypes.d.ts.map +1 -1
  26. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts +899 -1422
  27. package/dist/types/src/features/CognitiveCompare/Guidelines/constants/guidelines.mockData.d.ts.map +1 -1
  28. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/helper.d.ts.map +1 -1
  29. package/dist/types/src/features/CognitiveCompare/Guidelines/utils/processGuidelinesMarkdown.d.ts.map +1 -1
  30. package/dist/types/src/features/CognitiveCompare/components/SectionAccordion.d.ts.map +1 -1
  31. package/dist/types/src/features/CognitiveCompare/components/SvgConnectors.d.ts.map +1 -1
  32. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts +1 -2
  33. package/dist/types/src/features/CognitiveCompare/hooks/useCompareData.d.ts.map +1 -1
  34. package/dist/types/src/features/CognitiveCompare/hooks/useLinesCalculator.d.ts.map +1 -1
  35. package/package.json +2 -2
  36. package/dist/cjs/features/CognitiveCompare/utils/buildComparisonRows.js +0 -2
  37. package/dist/cjs/features/CognitiveCompare/utils/buildComparisonRows.js.map +0 -1
  38. package/dist/features/CognitiveCompare/utils/buildComparisonRows.js +0 -2
  39. package/dist/features/CognitiveCompare/utils/buildComparisonRows.js.map +0 -1
  40. package/dist/types/src/features/CognitiveCompare/utils/buildComparisonRows.d.ts +0 -11
  41. package/dist/types/src/features/CognitiveCompare/utils/buildComparisonRows.d.ts.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var i=n.containerRef,r=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var l=n.pathRefs,o=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,s=n.visibleFields,v=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,p=n.subSectionLeftRefs,b=n.subSectionRightRefs,A=n.lhsBadgeRefs,y=n.rhsBadgeRefs,R=n.sectionRowRefs,x=n.expandedSections,m=n.expandedSubSections,B=n.connectedSections,S=n.isSideBySide,I=n.activeSideBySideSection,T=n.maintainRelativeOrder,C=n.isGuidelineMode,E=n.cognitiveMap,M=n.getSectionCompareStyle,D=n.getSubSectionCompareStyle,O=n.getDeviationStyleByKey,L=n.isArrowVisible,_=n.isAnimatingRef,F=n.isSideBySideRef,N=n.sideBySideCacheRef,H=n.sideBySideLineRef,P=n.activeSideBySideSectionRef,k=n.activeSideBySideRightSectionRef,w=n.connectedLines,G=n.setConnectedLines,V=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,z=n.scrollLock,Q=n.scrollSyncLocked,X=n.handleResizeRef,q=n.activeProposed,K=n.existingRule,J=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,Z=n.resolvedComparisonConfig,$=n.getFieldData,tt=t.useState([]),et=tt[0],nt=tt[1],it=t.useState(null),rt=it[0],ct=it[1],lt=t.useState([]),ot=lt[0],ut=lt[1],at=null!=w?w:ot,dt=null!=G?G:ut,st=t.useState({width:0,height:0}),vt=st[0],ht=st[1],gt=t.useRef(!1),ft=t.useRef(!1),pt=t.useRef(!1),bt=t.useRef(null),At=t.useRef([]),yt=null!=V?V:At,Rt=function(t,e,n,i,r,c,l){if(Math.abs(i-e)<=1)return c&&l?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&l?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var o=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?o:-o,d=i>e?u:-u,s=n>r?u:-u;return c&&l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&l?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},xt=t.useCallback(function(){var t,n,l,R,L,F,N,H,P,k,w,G,V,Y,j,z,Q,X;if(!gt.current&&!_.current){gt.current=!0;try{if(!i.current)return;var q=function(t){var e=t.split("-"),n=e[0];if(!x[n]&&!1===T)return!1;if(T&&!x["left-".concat(n)]&&!x["right-".concat(n)]&&!x[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!m[i])return!1;return!0},K=i.current.getBoundingClientRect();ht({width:K.width,height:K.height});var J=[];if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!_.current){for(var U=0;U<Math.max(a.length,d.length);U++){var W=null===(t=g.current[U])||void 0===t?void 0:t.current,Z=null===(n=f.current[U])||void 0===n?void 0:n.current;W&&(W.style.height="auto",W.style.minHeight="0px"),Z&&(Z.style.height="auto",Z.style.minHeight="0px")}T||Object.keys(p.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=b.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var $={};s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),o=c.getBoundingClientRect();$[i]=Math.max(l.height,o.height)}});var tt={left:{},right:{}},et={};if(!_.current)if(T){if(S&&null!==I)if("number"==typeof I){var it=I,rt=a[it],lt=null===(L=g.current[it])||void 0===L?void 0:L.current;lt&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),i=null===(e=f.current[n])||void 0===e?void 0:e.current;if(i&&(x["left-".concat(it)]||x["right-".concat(n)])){var r=Math.max(lt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[it]=Math.max(tt.left[it]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=I.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ot){W=null===(F=p.current[ot])||void 0===F?void 0:F.current,Z=null===(N=b.current[ot])||void 0===N?void 0:N.current;if(W&&Z){ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,ut)}}}}else{Object.keys(p.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=b.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),l=r.getBoundingClientRect(),o=Math.max(c.height,l.height);et[t]=o,i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}}});for(U=0;U<Math.min(a.length,d.length);U++){var W=null===(l=g.current[U])||void 0===l?void 0:l.current,Z=null===(R=f.current[U])||void 0===R?void 0:R.current;if(W&&Z){var ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);tt.left[U]=ut,tt.right[U]=ut}}}if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=$[i];r.style.minHeight="".concat(l,"px"),c.style.minHeight="".concat(l,"px")}}),_.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=g.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),T||Object.keys(et).forEach(function(t){var e,n,i=null===(e=p.current[t])||void 0===e?void 0:e.current,r=null===(n=b.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!C){a.forEach(function(t,e){var n,i=t.continuationSourceRowId?a.findIndex(function(e){return e.comparisonRowId===t.continuationSourceRowId}):-1,l=i>=0?i:e,o=null===(n=g.current[l])||void 0===n?void 0:n.current;if(o){var u=function(t,e){if(!T)return d[e]?[e]:[];var n=(t.refIndexes||[]).map(function(t){return d.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&d[e]?[e]:Array.from(new Set(n))}(t,e);u.forEach(function(t){var n,u,s,v,h,g,p,b,A,y,R,x,m=null===(n=f.current[t])||void 0===n?void 0:n.current;if(m){var B=o.getBoundingClientRect(),C=m.getBoundingClientRect(),D=B.right-K.left,O=C.left-K.left,L=B.top+18-K.top,_=C.top+18-K.top;if(T&&S&&I===e){var F=null!==(s=null===(u=r.current)||void 0===u?void 0:u.getBoundingClientRect().top)&&void 0!==s?s:0,N=null!==(h=null===(v=c.current)||void 0===v?void 0:v.getBoundingClientRect().top)&&void 0!==h?h:0,H=F+(null!==(p=null===(g=r.current)||void 0===g?void 0:g.clientHeight)&&void 0!==p?p:1/0),P=N+(null!==(A=null===(b=c.current)||void 0===b?void 0:b.clientHeight)&&void 0!==A?A:1/0),k=function(t,e,n){return Math.max(e,Math.min(n,t))};L=k(B.top+18,F,H)-K.top,_=k(C.top+18,N,P)-K.top}var w=M(l);w&&J.push({id:"line-".concat(l,"-").concat(t),x1:D,y1:L,x2:O,y2:_,style:w,sectionIdx:l,targetRightIdx:t,isSubSection:!1,isMappingContinuation:i>=0,hasCognitive:!!((null===(y=a[l])||void 0===y?void 0:y.cognitiveData)||(null===(R=d[t])||void 0===R?void 0:R.cognitiveData)||(null===(x=a[l])||void 0===x?void 0:x.nodeId)&&E[a[l].nodeId])})}})}})}if(!C&&S&&"string"==typeof I&&I.includes(e.DEVIATION_BADGE_SEPARATOR)){var at=I.split(e.DEVIATION_BADGE_SEPARATOR),st=at[0],vt=at[1],ft=at[2],pt=(at[3],"".concat(st).concat(e.DEVIATION_BADGE_SEPARATOR).concat(vt)),bt=null===(H=A.current[pt])||void 0===H?void 0:H.current,At=null===(P=y.current[pt])||void 0===P?void 0:P.current;if(bt&&At){var xt=bt.getBoundingClientRect(),Bt=At.getBoundingClientRect(),St=xt.right-K.left,It=Bt.left-K.left,Tt=xt.top+xt.height/2-K.top,Ct=Bt.top+Bt.height/2-K.top;if(T){var Et=null!==(w=null===(k=r.current)||void 0===k?void 0:k.getBoundingClientRect().top)&&void 0!==w?w:0,Mt=null!==(V=null===(G=c.current)||void 0===G?void 0:G.getBoundingClientRect().top)&&void 0!==V?V:0,Dt=Et+(null!==(j=null===(Y=r.current)||void 0===Y?void 0:Y.clientHeight)&&void 0!==j?j:1/0),Ot=Mt+(null!==(Q=null===(z=c.current)||void 0===z?void 0:z.clientHeight)&&void 0!==Q?Q:1/0),Lt=function(t,e,n){return Math.max(e,Math.min(n,t))};Tt=Lt(xt.top+xt.height/2,Et,Dt)-K.top,Ct=Lt(Bt.top+Bt.height/2,Mt,Ot)-K.top}var _t=null!==(X=O(st,vt))&&void 0!==X?X:D(ft);_t&&J.push({id:"line-subsec-".concat(pt),x1:St,y1:Tt,x2:It,y2:Ct,style:_t,sectionIdx:Number(ft.split("-")[0]),isSubSection:!0,subSectionKeyPath:I})}}if(nt(J),o.current&&u.current){var Ft=o.current.getBoundingClientRect(),Nt=u.current.getBoundingClientRect(),Ht=(Ft.top+Ft.height/2-K.top+Nt.top+Nt.height/2-K.top)/2;ct({x1:Ft.right-K.left,x2:Nt.left-K.left,y:Ht})}else ct(null);if(B.size>0){var Pt=[],kt=r.current,wt=c.current;if(kt&&wt){var Gt=[],Vt=kt.getBoundingClientRect().top,Yt=wt.getBoundingClientRect().top,jt=Vt+kt.clientHeight,zt=Yt+wt.clientHeight,Qt=kt.scrollTop,Xt=wt.scrollTop,qt=K.top,Kt=function(t,e,n){return Math.max(e,Math.min(n,t))};B.forEach(function(t){var n,i,r,c,l,o,u,s,v;if(C){var h=null,g=null,f=null;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var p=t.split(e.DEVIATION_BADGE_SEPARATOR),b=p[0],R=p[1],x=p[2],m="".concat(b).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R);h=null===(n=A.current[m])||void 0===n?void 0:n.current,f=null!==(i=O(b,R))&&void 0!==i?i:D(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),h=null===(r=A.current[g])||void 0===r?void 0:r.current,f=M(g);if(!h)return;var B=document.querySelectorAll('[id^="guideline-target-"]');B.forEach(function(n,i){var r=h.getBoundingClientRect(),c=n.getBoundingClientRect(),l=r.right-K.left,o=c.left-K.left-0,u=l+75,a=r.top+r.height/2,d=c.top+c.height/2,s=a-Vt+Qt,v=d-Yt+Xt,g="conn-guide-".concat(t,"-").concat(i),p="";"string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)?p=(t.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):p=String(Number(t)+1);var b=String.fromCharCode(97+i),A=1===B.length?null:"".concat(p,"(").concat(b,")");Gt.push({lhsScrollY:s,rhsScrollY:v,x1:l,x2:o,containerTop:qt,leftIdx:t,rhsArrayIdx:i,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var y=Kt(a,Vt,jt),R=Kt(d,Yt,zt),x=y-qt,m=R-qt,S=Rt(l,x,o,m,u,a>=Vt-4&&a<=jt+4,d>=Yt-4&&d<=zt+4);Pt.push({id:g,pathD:S,style:f,leftIdx:t,rhsArrayIdx:i,x1:l,x2:o,y1:x,y2:m,centerX:u,matchLabel:A,isGuideline:!0})})}else if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var S=t.split(e.DEVIATION_BADGE_SEPARATOR),I=(b=S[0],R=S[1],x=S[2],S[3],m="".concat(b).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R),null===(c=A.current[m])||void 0===c?void 0:c.current),E=null===(l=y.current[m])||void 0===l?void 0:l.current;if(!I||!E)return;var L=I.getBoundingClientRect(),_=E.getBoundingClientRect(),F=null!==(o=O(b,R))&&void 0!==o?o:D(x),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,w=_.top+_.height/2,G=k-Vt+Qt,V=w-Yt+Xt,Y="conn-subsec-".concat(m),j=((x||"").split("-").map(function(t){return Number(t)+1}).join("."),null);Gt.push({lhsScrollY:G,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var z=Kt(k,Vt,jt),Q=Kt(w,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,w>=Yt-4&&w<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:t,rhsArrayIdx:t,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}else if(T){var q=t,J=a[q];if(!(null===(v=null==J?void 0:J.refIndexes)||void 0===v?void 0:v.length))return;J.refIndexes.forEach(function(e,n){var i,r,c=d.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var l=null===(i=A.current[q])||void 0===i?void 0:i.current,o=null===(r=y.current[c])||void 0===r?void 0:r.current;if(l&&o){var u=l.getBoundingClientRect(),a=o.getBoundingClientRect(),s=M(q),v=u.right-K.left,h=a.left-K.left-0,g=v+75,f=u.top+u.height/2,p=a.top+a.height/2,b=f-Vt+Qt,R=p-Yt+Xt,x="conn-".concat(q,"-").concat(c),m=String(Number(t)+1),B=String.fromCharCode(97+n),S=1===J.refIndexes.length?null:"".concat(m,"(").concat(B,")");Gt.push({lhsScrollY:b,rhsScrollY:R,x1:v,x2:h,containerTop:qt,leftIdx:q,rhsArrayIdx:c,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleBg:(null==s?void 0:s.badgeBg)||"#FFFFFF",styleText:(null==s?void 0:s.badgeText)||"#A16207",styleId:x,centerX:g});var I=Kt(f,Vt,jt),T=Kt(p,Yt,zt),C=I-qt,E=T-qt,D=Rt(v,C,h,E,g,f>=Vt-4&&f<=jt+4,p>=Yt-4&&p<=zt+4);Pt.push({id:x,pathD:D,style:s,leftIdx:q,rhsArrayIdx:c,x1:v,x2:h,y1:C,y2:E,matchLabel:S})}}})}else{var U=t,W=U;I=null===(u=A.current[U])||void 0===u?void 0:u.current,E=null===(s=y.current[W])||void 0===s?void 0:s.current;if(!I||!E)return;L=I.getBoundingClientRect(),_=E.getBoundingClientRect(),F=M(U),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,w=_.top+_.height/2,G=k-Vt+Qt,V=w-Yt+Xt,Y="conn-".concat(U,"-").concat(W),String(Number(t)+1),j=null;Gt.push({lhsScrollY:G,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:U,rhsArrayIdx:W,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var Z,$;z=Kt(k,Vt,jt),Q=Kt(w,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,w>=Yt-4&&w<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:U,rhsArrayIdx:W,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}}),yt.current=Gt}dt(Pt),setTimeout(function(){return mt()},10)}else dt([]),yt.current=[],setTimeout(function(){return mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{gt.current=!1}}},[s,a,d,E,Z,$,M,O,T,S,I,B,x,m,C]),mt=t.useCallback(function(){var t,e,n,o,u,a,d,s,v,h,g,f,p,b,A,y,R,x,m,B=yt.current;if(!B.length)return null===(t=l.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=l.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=l.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(o=l.current["guideline-down-badge"])||void 0===o||o.setAttribute("visibility","hidden"));if(!_.current){var S=null!==(a=null===(u=r.current)||void 0===u?void 0:u.scrollTop)&&void 0!==a?a:0,I=null!==(s=null===(d=c.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,T=null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,C=null!==(f=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,E=null!==(b=null===(p=r.current)||void 0===p?void 0:p.getBoundingClientRect().top)&&void 0!==b?b:0,M=null!==(y=null===(A=c.current)||void 0===A?void 0:A.getBoundingClientRect().top)&&void 0!==y?y:0,D=E+T,O=M+C,L=null===(R=i.current)||void 0===R?void 0:R.getBoundingClientRect(),F=null!==(x=null==L?void 0:L.top)&&void 0!==x?x:0,N=null!==(m=null==L?void 0:L.height)&&void 0!==m?m:1/0,H=function(t,e,n){return Math.max(e,Math.min(n,t))},P=0,k=0,w=0,G=0,V="#6366F1",Y="#A16207",j=!1,z=0;if(B.forEach(function(t){var e=t.lhsScrollY-S+E,n=t.rhsScrollY-I+M,i=l.current[t.styleId+"-stroke"],r=l.current[t.styleId+"-bg"],c=l.current[t.styleId+"-btn"],o=l.current[t.styleId+"-number"];if(i||r){var u=H(e,E,D),a=H(n,M,O),d=u-F,s=a-F,v=e>=E-4&&e<=D+4,h=n>=M-4&&n<=O+4,g=!0;j=!0;var f=t.centerX||t.x1+75;0===w&&(w=t.x1,G=d,z=f,V=t.styleColor,t.styleBg,Y=t.styleText||"#A16207"),n<M-4?(P++,g=!1):n>O+4&&(k++,g=!1);var p=Rt(t.x1,d,t.x2,s,z,v,h);i&&(g&&p?(i.setAttribute("visibility","visible"),i.setAttribute("d",p)):i.setAttribute("visibility","hidden")),r&&(g&&p?(r.setAttribute("visibility","visible"),r.setAttribute("d",p)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),j&&z>0){var Q=l.current["guideline-up-stroke"],X=l.current["guideline-up-badge"],q=l.current["guideline-up-arrow"],K=l.current["guideline-up-text"],J=l.current["guideline-up-badge-rect"];if(P>0){var U=Math.max(15,M-F+15),W=Math.min(15,Math.abs(z-w),Math.max(0,G-U)),Z="M ".concat(w,",").concat(G," L ").concat(z-W,",").concat(G," Q ").concat(z,",").concat(G," ").concat(z,",").concat(G-W," L ").concat(z,",").concat(U);null==Q||Q.setAttribute("visibility","visible"),null==Q||Q.setAttribute("d",Z),null==Q||Q.setAttribute("stroke",V),null==X||X.setAttribute("visibility","visible"),null==X||X.setAttribute("transform","translate(".concat(z,", ").concat(U,")")),q&&q.setAttribute("fill",V),K&&(K.textContent="+".concat(P),K.setAttribute("fill",Y)),J&&J.setAttribute("stroke",V)}else null==Q||Q.setAttribute("visibility","hidden"),null==X||X.setAttribute("visibility","hidden");var $=l.current["guideline-down-stroke"],tt=l.current["guideline-down-badge"],et=l.current["guideline-down-arrow"],nt=l.current["guideline-down-text"],it=l.current["guideline-down-badge-rect"];if(k>0){var rt=Math.min(N-15,O-F-15);W=Math.min(15,Math.abs(z-w),Math.max(0,rt-G)),Z="M ".concat(w,",").concat(G," L ").concat(z-W,",").concat(G," Q ").concat(z,",").concat(G," ").concat(z,",").concat(G+W," L ").concat(z,",").concat(rt);null==$||$.setAttribute("visibility","visible"),null==$||$.setAttribute("d",Z),null==$||$.setAttribute("stroke",V),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(z,", ").concat(rt,")")),et&&et.setAttribute("fill",V),nt&&(nt.textContent="+".concat(k),nt.setAttribute("fill",Y)),it&&it.setAttribute("stroke",V)}else null==$||$.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Bt=t.useCallback(function(){yt.current.length>0&&!_.current||(null!==bt.current&&clearTimeout(bt.current),bt.current=setTimeout(function(){Y.current(),bt.current=null},50))},[]),St=t.useCallback(function(t){if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){var n=W.current;U.current=null,W.current=null,n()}if(!pt.current&&!z.current){if(T&&Q&&(F.current||B.size>0)){var l=t.currentTarget,o=r.current,u=c.current,a=l===o?u:l===u?o:null;if(l&&a){var d=function(){var t,n,i,r,c,l,o,u,a,d,s,v=P.current,h=k.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(e.DEVIATION_BADGE_SEPARATOR)){var x=v.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x[1]);return{leftAnchor:(null===(t=A.current[m])||void 0===t?void 0:t.current)||(null===(n=p.current[x[2]])||void 0===n?void 0:n.current)||(null===(i=g.current[Number(x[2])])||void 0===i?void 0:i.current)||null,rightAnchor:(null===(r=y.current[m])||void 0===r?void 0:r.current)||(null===(c=b.current[x[3]])||void 0===c?void 0:c.current)||(null===(l=f.current[Number(x[3])])||void 0===l?void 0:l.current)||null}}var B=Number(v),S=null!==h?Number(h):B;return{leftAnchor:(null===(o=A.current[B])||void 0===o?void 0:o.current)||(null===(u=R.current[B])||void 0===u?void 0:u.current)||(null===(a=g.current[B])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(s=f.current[S])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=l===o?s:v,x=l===o?v:s,m=null;if(h&&x){var S=h.getBoundingClientRect(),I=x.getBoundingClientRect(),C=a.getBoundingClientRect(),E=S.top+S.height/2;m=I.top-C.top+a.scrollTop+I.height/2-(E-C.top)}else{var M=Math.max(0,l.scrollHeight-l.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?l.scrollTop/M*D:l.scrollTop}var O=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,O)),Math.abs(a.scrollTop-m)>1&&(pt.current=!0,a.scrollTop=m,requestAnimationFrame(function(){pt.current=!1}))}}T||Bt(),ft.current||(ft.current=!0,requestAnimationFrame(function(){var t,n,l,o,u,a,d;if(F.current){var s=r.current,v=c.current;if(s&&v&&H.current){if(!N.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=h.split(e.DEVIATION_BADGE_SEPARATOR),p="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);g=null===(t=A.current[p])||void 0===t?void 0:t.current}else g=null===(n=A.current[h])||void 0===n?void 0:n.current;if(g){var b=g.getBoundingClientRect();N.current={badgeScreenY:b.top+b.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(o=null===(l=i.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==o?o:0}}}if(N.current){var y=N.current,R=s.scrollTop-y.initialScrollTop,x=y.badgeScreenY-R,m=((u=x,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),B=x>=y.leftTop-4&&x<=y.leftBottom+4;H.current.setAttribute("y1",m),H.current.setAttribute("y2",m),H.current.setAttribute("visibility",B?"visible":"hidden")}}}mt(),ft.current=!1}))}},[mt,T,Q,B,Bt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==bt.current&&clearTimeout(bt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[q,K,J,s,x,m,a,d,Z,Bt,S,I,L,B]),{lines:et,setLines:nt,overallConnector:rt,setOverallConnector:ct,connectedLines:at,setConnectedLines:dt,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:St}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("../CognitiveComparehelpers.js");exports.useLinesCalculator=function(n){var i=n.containerRef,r=n.leftContainerRef,c=n.rightContainerRef;n.svgContainerRef;var l=n.pathRefs,o=n.leftHeaderRef,u=n.rightHeaderRef,a=n.proposedSections,d=n.existingSections,s=n.visibleFields,v=n.leftRefs,h=n.rightRefs,g=n.sectionLeftRefs,f=n.sectionRightRefs,b=n.subSectionLeftRefs,p=n.subSectionRightRefs,A=n.lhsBadgeRefs,y=n.rhsBadgeRefs,R=n.sectionRowRefs,x=n.expandedSections,m=n.expandedSubSections,B=n.connectedSections,S=n.isSideBySide,T=n.activeSideBySideSection,C=n.maintainRelativeOrder,I=n.isGuidelineMode,E=n.cognitiveMap,M=n.getSectionCompareStyle,D=n.getSubSectionCompareStyle,O=n.getDeviationStyleByKey,L=n.isArrowVisible,_=n.isAnimatingRef,F=n.isSideBySideRef,N=n.sideBySideCacheRef,H=n.sideBySideLineRef,P=n.activeSideBySideSectionRef,k=n.activeSideBySideRightSectionRef,G=n.connectedLines,w=n.setConnectedLines,V=n.cachedConnectedPositions,Y=n.calculateLinesRef,j=n.resizeTimerRef,z=n.scrollLock,Q=n.scrollSyncLocked,X=n.handleResizeRef,q=n.activeProposed,K=n.existingRule,J=n.analysisData,U=n.pendingScrollTargetRef,W=n.pendingScrollCallbackRef,Z=n.resolvedComparisonConfig,$=n.getFieldData,tt=t.useState([]),et=tt[0],nt=tt[1],it=t.useState(null),rt=it[0],ct=it[1],lt=t.useState([]),ot=lt[0],ut=lt[1],at=null!=G?G:ot,dt=null!=w?w:ut,st=t.useState({width:0,height:0}),vt=st[0],ht=st[1],gt=t.useRef(!1),ft=t.useRef(!1),bt=t.useRef(!1),pt=t.useRef(null),At=t.useRef([]),yt=null!=V?V:At,Rt=function(t,e,n,i,r,c,l){if(Math.abs(i-e)<=1)return c&&l?"M ".concat(t,",").concat(e," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r,",").concat(e):!c&&l?"M ".concat(r,",").concat(e," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i);var o=Math.min(15,Math.abs(r-t),Math.abs(i-e)/2),u=Math.min(15,Math.abs(n-r),Math.abs(i-e)/2),a=i>e?o:-o,d=i>e?u:-u,s=n>r?u:-u;return c&&l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):c&&!l?"M ".concat(t,",").concat(e," L ").concat(r-o,",").concat(e," Q ").concat(r,",").concat(e," ").concat(r,",").concat(e+a," L ").concat(r,",").concat(i):!c&&l?"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i-d," Q ").concat(r,",").concat(i," ").concat(r+s,",").concat(i," L ").concat(n,",").concat(i):"M ".concat(r,",").concat(e," L ").concat(r,",").concat(i)},xt=t.useCallback(function(){var t,n,l,R,L,F,N,H,P,k,G,w,V,Y,j,z,Q,X;if(!gt.current&&!_.current){gt.current=!0;try{if(!i.current)return;var q=function(t){var e=t.split("-"),n=e[0];if(!x[n]&&!1===C)return!1;if(C&&!x["left-".concat(n)]&&!x["right-".concat(n)]&&!x[n])return!1;for(var i=n,r=1;r<e.length-1;r++)if(i+="-".concat(e[r]),!m[i])return!1;return!0},K=i.current.getBoundingClientRect();ht({width:K.width,height:K.height});var J=[];if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;r&&c&&(r.style.height="auto",c.style.height="auto",r.style.minHeight="0px",c.style.minHeight="0px")}),!_.current){for(var U=0;U<Math.max(a.length,d.length);U++){var W=null===(t=g.current[U])||void 0===t?void 0:t.current,Z=null===(n=f.current[U])||void 0===n?void 0:n.current;W&&(W.style.height="auto",W.style.minHeight="0px"),Z&&(Z.style.height="auto",Z.style.minHeight="0px")}C||Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;i&&r&&(i.style.height="auto",r.style.height="auto",i.style.minHeight="0px",r.style.minHeight="0px")}})}var $={};s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=r.getBoundingClientRect(),o=c.getBoundingClientRect();$[i]=Math.max(l.height,o.height)}});var tt={left:{},right:{}},et={};if(!_.current)if(C){if(S&&null!==T)if("number"==typeof T){var it=T,rt=a[it],lt=null===(L=g.current[it])||void 0===L?void 0:L.current;lt&&rt&&(rt.refIndexes||[]).forEach(function(t){var e,n=d.findIndex(function(e){return e.selfIndex===t}),i=null===(e=f.current[n])||void 0===e?void 0:e.current;if(i&&(x["left-".concat(it)]||x["right-".concat(n)])){var r=Math.max(lt.getBoundingClientRect().height,i.getBoundingClientRect().height);tt.left[it]=Math.max(tt.left[it]||0,r),tt.right[n]=Math.max(tt.right[n]||0,r)}})}else{var ot=T.split(e.DEVIATION_BADGE_SEPARATOR)[2];if(ot){W=null===(F=b.current[ot])||void 0===F?void 0:F.current,Z=null===(N=p.current[ot])||void 0===N?void 0:N.current;if(W&&Z){ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);et[ot]=Math.max(et[ot]||0,ut)}}}}else{Object.keys(b.current).forEach(function(t){var e,n;if(q(t)){var i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&null!==i.offsetParent&&null!==r.offsetParent){var c=i.getBoundingClientRect(),l=r.getBoundingClientRect(),o=Math.max(c.height,l.height);et[t]=o,i.style.minHeight="".concat(o,"px"),r.style.minHeight="".concat(o,"px")}}});for(U=0;U<Math.min(a.length,d.length);U++){var W=null===(l=g.current[U])||void 0===l?void 0:l.current,Z=null===(R=f.current[U])||void 0===R?void 0:R.current;if(W&&Z){var ut=Math.max(W.getBoundingClientRect().height,Z.getBoundingClientRect().height);tt.left[U]=ut,tt.right[U]=ut}}}if(s.forEach(function(t){var e,n,i=t.key,r=null===(e=v.current[i])||void 0===e?void 0:e.current,c=null===(n=h.current[i])||void 0===n?void 0:n.current;if(r&&c){var l=$[i];r.style.minHeight="".concat(l,"px"),c.style.minHeight="".concat(l,"px")}}),_.current||(Object.entries(tt.left).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=g.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),Object.entries(tt.right).forEach(function(t){var e,n=t[0],i=t[1],r=null===(e=f.current[Number(n)])||void 0===e?void 0:e.current;r&&(r.style.minHeight="".concat(i,"px"))}),C||Object.keys(et).forEach(function(t){var e,n,i=null===(e=b.current[t])||void 0===e?void 0:e.current,r=null===(n=p.current[t])||void 0===n?void 0:n.current;if(i&&r&&et[t]){var c=et[t];i.style.minHeight="".concat(c,"px"),r.style.minHeight="".concat(c,"px")}})),!I){a.forEach(function(t,e){var n,i=null===(n=g.current[e])||void 0===n?void 0:n.current;if(i){var l=function(t,e){var n=(t.refIndexes||[]).map(function(t){return d.findIndex(function(e){return e.selfIndex===t})}).filter(function(t){return-1!==t});return!n.length&&d[e]?[e]:Array.from(new Set(n))}(t,e);l.forEach(function(n){var l,o,u,a,s,v,h,g,b,p,A=null===(l=f.current[n])||void 0===l?void 0:l.current;if(A){var y=i.getBoundingClientRect(),R=A.getBoundingClientRect(),x=y.right-K.left,m=R.left-K.left,B=y.top+18-K.top,I=R.top+18-K.top;if(C&&S&&T===e){var D=null!==(u=null===(o=r.current)||void 0===o?void 0:o.getBoundingClientRect().top)&&void 0!==u?u:0,O=null!==(s=null===(a=c.current)||void 0===a?void 0:a.getBoundingClientRect().top)&&void 0!==s?s:0,L=D+(null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0),_=O+(null!==(b=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==b?b:1/0),F=function(t,e,n){return Math.max(e,Math.min(n,t))};B=F(y.top+18,D,L)-K.top,I=F(R.top+18,O,_)-K.top}var N=M(e);N&&J.push({id:"line-".concat(e,"-").concat(n),x1:x,y1:B,x2:m,y2:I,style:N,sectionIdx:e,targetRightIdx:n,isSubSection:!1,hasCognitive:!!((null==t?void 0:t.cognitiveData)||(null===(p=d[n])||void 0===p?void 0:p.cognitiveData)||(null==t?void 0:t.nodeId)&&E[t.nodeId])})}})}})}if(!I&&S&&"string"==typeof T&&T.includes(e.DEVIATION_BADGE_SEPARATOR)){var at=T.split(e.DEVIATION_BADGE_SEPARATOR),st=at[0],vt=at[1],ft=at[2],bt=(at[3],"".concat(st).concat(e.DEVIATION_BADGE_SEPARATOR).concat(vt)),pt=null===(H=A.current[bt])||void 0===H?void 0:H.current,At=null===(P=y.current[bt])||void 0===P?void 0:P.current;if(pt&&At){var xt=pt.getBoundingClientRect(),Bt=At.getBoundingClientRect(),St=xt.right-K.left,Tt=Bt.left-K.left,Ct=xt.top+xt.height/2-K.top,It=Bt.top+Bt.height/2-K.top;if(C){var Et=null!==(G=null===(k=r.current)||void 0===k?void 0:k.getBoundingClientRect().top)&&void 0!==G?G:0,Mt=null!==(V=null===(w=c.current)||void 0===w?void 0:w.getBoundingClientRect().top)&&void 0!==V?V:0,Dt=Et+(null!==(j=null===(Y=r.current)||void 0===Y?void 0:Y.clientHeight)&&void 0!==j?j:1/0),Ot=Mt+(null!==(Q=null===(z=c.current)||void 0===z?void 0:z.clientHeight)&&void 0!==Q?Q:1/0),Lt=function(t,e,n){return Math.max(e,Math.min(n,t))};Ct=Lt(xt.top+xt.height/2,Et,Dt)-K.top,It=Lt(Bt.top+Bt.height/2,Mt,Ot)-K.top}var _t=null!==(X=O(st,vt))&&void 0!==X?X:D(ft);_t&&J.push({id:"line-subsec-".concat(bt),x1:St,y1:Ct,x2:Tt,y2:It,style:_t,sectionIdx:Number(ft.split("-")[0]),isSubSection:!0,subSectionKeyPath:T})}}if(nt(J),o.current&&u.current){var Ft=o.current.getBoundingClientRect(),Nt=u.current.getBoundingClientRect(),Ht=(Ft.top+Ft.height/2-K.top+Nt.top+Nt.height/2-K.top)/2;ct({x1:Ft.right-K.left,x2:Nt.left-K.left,y:Ht})}else ct(null);if(B.size>0){var Pt=[],kt=r.current,Gt=c.current;if(kt&&Gt){var wt=[],Vt=kt.getBoundingClientRect().top,Yt=Gt.getBoundingClientRect().top,jt=Vt+kt.clientHeight,zt=Yt+Gt.clientHeight,Qt=kt.scrollTop,Xt=Gt.scrollTop,qt=K.top,Kt=function(t,e,n){return Math.max(e,Math.min(n,t))};B.forEach(function(t){var n,i,r,c,l,o,u,s,v;if(I){var h=null,g=null,f=null;if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var b=t.split(e.DEVIATION_BADGE_SEPARATOR),p=b[0],R=b[1],x=b[2],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R);h=null===(n=A.current[m])||void 0===n?void 0:n.current,f=null!==(i=O(p,R))&&void 0!==i?i:D(x),g=Number((null==x?void 0:x.split("-")[0])||0)}else g=Number(t),h=null===(r=A.current[g])||void 0===r?void 0:r.current,f=M(g);if(!h)return;var B=document.querySelectorAll('[id^="guideline-target-"]');B.forEach(function(n,i){var r=h.getBoundingClientRect(),c=n.getBoundingClientRect(),l=r.right-K.left,o=c.left-K.left-0,u=l+75,a=r.top+r.height/2,d=c.top+c.height/2,s=a-Vt+Qt,v=d-Yt+Xt,g="conn-guide-".concat(t,"-").concat(i),b="";"string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)?b=(t.split(e.DEVIATION_BADGE_SEPARATOR)[2]||"").split("-").map(function(t){return Number(t)+1}).join("."):b=String(Number(t)+1);var p=String.fromCharCode(97+i),A=1===B.length?null:"".concat(b,"(").concat(p,")");wt.push({lhsScrollY:s,rhsScrollY:v,x1:l,x2:o,containerTop:qt,leftIdx:t,rhsArrayIdx:i,styleColor:(null==f?void 0:f.badgeBorder)||"#6366F1",styleBg:(null==f?void 0:f.badgeBg)||"#FFFFFF",styleText:(null==f?void 0:f.badgeText)||"#A16207",styleId:g,centerX:u});var y=Kt(a,Vt,jt),R=Kt(d,Yt,zt),x=y-qt,m=R-qt,S=Rt(l,x,o,m,u,a>=Vt-4&&a<=jt+4,d>=Yt-4&&d<=zt+4);Pt.push({id:g,pathD:S,style:f,leftIdx:t,rhsArrayIdx:i,x1:l,x2:o,y1:x,y2:m,centerX:u,matchLabel:A,isGuideline:!0})})}else if("string"==typeof t&&t.includes(e.DEVIATION_BADGE_SEPARATOR)){var S=t.split(e.DEVIATION_BADGE_SEPARATOR),T=(p=S[0],R=S[1],x=S[2],S[3],m="".concat(p).concat(e.DEVIATION_BADGE_SEPARATOR).concat(R),null===(c=A.current[m])||void 0===c?void 0:c.current),E=null===(l=y.current[m])||void 0===l?void 0:l.current;if(!T||!E)return;var L=T.getBoundingClientRect(),_=E.getBoundingClientRect(),F=null!==(o=O(p,R))&&void 0!==o?o:D(x),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,G=_.top+_.height/2,w=k-Vt+Qt,V=G-Yt+Xt,Y="conn-subsec-".concat(m),j=((x||"").split("-").map(function(t){return Number(t)+1}).join("."),null);wt.push({lhsScrollY:w,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:t,rhsArrayIdx:t,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var z=Kt(k,Vt,jt),Q=Kt(G,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,G>=Yt-4&&G<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:t,rhsArrayIdx:t,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}else if(C){var q=t,J=a[q];if(!(null===(v=null==J?void 0:J.refIndexes)||void 0===v?void 0:v.length))return;J.refIndexes.forEach(function(e,n){var i,r,c=d.findIndex(function(t){return t.selfIndex===e});if(-1!==c){var l=null===(i=A.current[q])||void 0===i?void 0:i.current,o=null===(r=y.current[c])||void 0===r?void 0:r.current;if(l&&o){var u=l.getBoundingClientRect(),a=o.getBoundingClientRect(),s=M(q),v=u.right-K.left,h=a.left-K.left-0,g=v+75,f=u.top+u.height/2,b=a.top+a.height/2,p=f-Vt+Qt,R=b-Yt+Xt,x="conn-".concat(q,"-").concat(c),m=String(Number(t)+1),B=String.fromCharCode(97+n),S=1===J.refIndexes.length?null:"".concat(m,"(").concat(B,")");wt.push({lhsScrollY:p,rhsScrollY:R,x1:v,x2:h,containerTop:qt,leftIdx:q,rhsArrayIdx:c,styleColor:(null==s?void 0:s.badgeBorder)||"#6366F1",styleBg:(null==s?void 0:s.badgeBg)||"#FFFFFF",styleText:(null==s?void 0:s.badgeText)||"#A16207",styleId:x,centerX:g});var T=Kt(f,Vt,jt),C=Kt(b,Yt,zt),I=T-qt,E=C-qt,D=Rt(v,I,h,E,g,f>=Vt-4&&f<=jt+4,b>=Yt-4&&b<=zt+4);Pt.push({id:x,pathD:D,style:s,leftIdx:q,rhsArrayIdx:c,x1:v,x2:h,y1:I,y2:E,matchLabel:S})}}})}else{var U=t,W=U;T=null===(u=A.current[U])||void 0===u?void 0:u.current,E=null===(s=y.current[W])||void 0===s?void 0:s.current;if(!T||!E)return;L=T.getBoundingClientRect(),_=E.getBoundingClientRect(),F=M(U),N=L.right-K.left,H=_.left-K.left-0,P=N+75,k=L.top+L.height/2,G=_.top+_.height/2,w=k-Vt+Qt,V=G-Yt+Xt,Y="conn-".concat(U,"-").concat(W),String(Number(t)+1),j=null;wt.push({lhsScrollY:w,rhsScrollY:V,x1:N,x2:H,containerTop:qt,leftIdx:U,rhsArrayIdx:W,styleColor:(null==F?void 0:F.badgeBorder)||"#6366F1",styleBg:(null==F?void 0:F.badgeBg)||"#FFFFFF",styleText:(null==F?void 0:F.badgeText)||"#A16207",styleId:Y,centerX:P});var Z,$;z=Kt(k,Vt,jt),Q=Kt(G,Yt,zt),X=Rt(N,Z=z-qt,H,$=Q-qt,P,k>=Vt-4&&k<=jt+4,G>=Yt-4&&G<=zt+4);Pt.push({id:Y,pathD:X,style:F,leftIdx:U,rhsArrayIdx:W,x1:N,x2:H,y1:Z,y2:$,matchLabel:j})}}),yt.current=wt}dt(Pt),setTimeout(function(){return mt()},10)}else dt([]),yt.current=[],setTimeout(function(){return mt()},10)}catch(t){console.error("Line render safe fail: ",t)}finally{gt.current=!1}}},[s,a,d,E,Z,$,M,O,C,S,T,B,x,m,I]),mt=t.useCallback(function(){var t,e,n,o,u,a,d,s,v,h,g,f,b,p,A,y,R,x,m,B=yt.current;if(!B.length)return null===(t=l.current["guideline-up-stroke"])||void 0===t||t.setAttribute("visibility","hidden"),null===(e=l.current["guideline-up-badge"])||void 0===e||e.setAttribute("visibility","hidden"),null===(n=l.current["guideline-down-stroke"])||void 0===n||n.setAttribute("visibility","hidden"),void(null===(o=l.current["guideline-down-badge"])||void 0===o||o.setAttribute("visibility","hidden"));if(!_.current){var S=null!==(a=null===(u=r.current)||void 0===u?void 0:u.scrollTop)&&void 0!==a?a:0,T=null!==(s=null===(d=c.current)||void 0===d?void 0:d.scrollTop)&&void 0!==s?s:0,C=null!==(h=null===(v=r.current)||void 0===v?void 0:v.clientHeight)&&void 0!==h?h:1/0,I=null!==(f=null===(g=c.current)||void 0===g?void 0:g.clientHeight)&&void 0!==f?f:1/0,E=null!==(p=null===(b=r.current)||void 0===b?void 0:b.getBoundingClientRect().top)&&void 0!==p?p:0,M=null!==(y=null===(A=c.current)||void 0===A?void 0:A.getBoundingClientRect().top)&&void 0!==y?y:0,D=E+C,O=M+I,L=null===(R=i.current)||void 0===R?void 0:R.getBoundingClientRect(),F=null!==(x=null==L?void 0:L.top)&&void 0!==x?x:0,N=null!==(m=null==L?void 0:L.height)&&void 0!==m?m:1/0,H=function(t,e,n){return Math.max(e,Math.min(n,t))},P=0,k=0,G=0,w=0,V="#6366F1",Y="#A16207",j=!1,z=0;if(B.forEach(function(t){var e=t.lhsScrollY-S+E,n=t.rhsScrollY-T+M,i=l.current[t.styleId+"-stroke"],r=l.current[t.styleId+"-bg"],c=l.current[t.styleId+"-btn"],o=l.current[t.styleId+"-number"];if(i||r){var u=H(e,E,D),a=H(n,M,O),d=u-F,s=a-F,v=e>=E-4&&e<=D+4,h=n>=M-4&&n<=O+4,g=!0;j=!0;var f=t.centerX||t.x1+75;0===G&&(G=t.x1,w=d,z=f,V=t.styleColor,t.styleBg,Y=t.styleText||"#A16207"),n<M-4?(P++,g=!1):n>O+4&&(k++,g=!1);var b=Rt(t.x1,d,t.x2,s,z,v,h);i&&(g&&b?(i.setAttribute("visibility","visible"),i.setAttribute("d",b)):i.setAttribute("visibility","hidden")),r&&(g&&b?(r.setAttribute("visibility","visible"),r.setAttribute("d",b)):r.setAttribute("visibility","hidden")),c&&(v&&g?(c.setAttribute("visibility","visible"),c.setAttribute("y",String(d-12))):c.setAttribute("visibility","hidden")),o&&(v&&g?(o.setAttribute("visibility","visible"),o.setAttribute("transform","translate(".concat(t.x2-42,", ").concat(s,")"))):o.setAttribute("visibility","hidden"))}}),j&&z>0){var Q=l.current["guideline-up-stroke"],X=l.current["guideline-up-badge"],q=l.current["guideline-up-arrow"],K=l.current["guideline-up-text"],J=l.current["guideline-up-badge-rect"];if(P>0){var U=Math.max(15,M-F+15),W=Math.min(15,Math.abs(z-G),Math.max(0,w-U)),Z="M ".concat(G,",").concat(w," L ").concat(z-W,",").concat(w," Q ").concat(z,",").concat(w," ").concat(z,",").concat(w-W," L ").concat(z,",").concat(U);null==Q||Q.setAttribute("visibility","visible"),null==Q||Q.setAttribute("d",Z),null==Q||Q.setAttribute("stroke",V),null==X||X.setAttribute("visibility","visible"),null==X||X.setAttribute("transform","translate(".concat(z,", ").concat(U,")")),q&&q.setAttribute("fill",V),K&&(K.textContent="+".concat(P),K.setAttribute("fill",Y)),J&&J.setAttribute("stroke",V)}else null==Q||Q.setAttribute("visibility","hidden"),null==X||X.setAttribute("visibility","hidden");var $=l.current["guideline-down-stroke"],tt=l.current["guideline-down-badge"],et=l.current["guideline-down-arrow"],nt=l.current["guideline-down-text"],it=l.current["guideline-down-badge-rect"];if(k>0){var rt=Math.min(N-15,O-F-15);W=Math.min(15,Math.abs(z-G),Math.max(0,rt-w)),Z="M ".concat(G,",").concat(w," L ").concat(z-W,",").concat(w," Q ").concat(z,",").concat(w," ").concat(z,",").concat(w+W," L ").concat(z,",").concat(rt);null==$||$.setAttribute("visibility","visible"),null==$||$.setAttribute("d",Z),null==$||$.setAttribute("stroke",V),null==tt||tt.setAttribute("visibility","visible"),null==tt||tt.setAttribute("transform","translate(".concat(z,", ").concat(rt,")")),et&&et.setAttribute("fill",V),nt&&(nt.textContent="+".concat(k),nt.setAttribute("fill",Y)),it&&it.setAttribute("stroke",V)}else null==$||$.setAttribute("visibility","hidden"),null==tt||tt.setAttribute("visibility","hidden")}}},[]),Bt=t.useCallback(function(){yt.current.length>0&&!_.current||(null!==pt.current&&clearTimeout(pt.current),pt.current=setTimeout(function(){Y.current(),pt.current=null},50))},[]),St=t.useCallback(function(t){if(null!==U.current&&W.current&&Math.abs(t.currentTarget.scrollTop-U.current)<=2){var n=W.current;U.current=null,W.current=null,n()}if(!bt.current&&!z.current){if(C&&Q&&(F.current||B.size>0)){var l=t.currentTarget,o=r.current,u=c.current,a=l===o?u:l===u?o:null;if(l&&a){var d=function(){var t,n,i,r,c,l,o,u,a,d,s,v=P.current,h=k.current;if(null===v)return{leftAnchor:null,rightAnchor:null};if("string"==typeof v&&v.includes(e.DEVIATION_BADGE_SEPARATOR)){var x=v.split(e.DEVIATION_BADGE_SEPARATOR),m="".concat(x[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(x[1]);return{leftAnchor:(null===(t=A.current[m])||void 0===t?void 0:t.current)||(null===(n=b.current[x[2]])||void 0===n?void 0:n.current)||(null===(i=g.current[Number(x[2])])||void 0===i?void 0:i.current)||null,rightAnchor:(null===(r=y.current[m])||void 0===r?void 0:r.current)||(null===(c=p.current[x[3]])||void 0===c?void 0:c.current)||(null===(l=f.current[Number(x[3])])||void 0===l?void 0:l.current)||null}}var B=Number(v),S=null!==h?Number(h):B;return{leftAnchor:(null===(o=A.current[B])||void 0===o?void 0:o.current)||(null===(u=R.current[B])||void 0===u?void 0:u.current)||(null===(a=g.current[B])||void 0===a?void 0:a.current)||null,rightAnchor:(null===(d=y.current[S])||void 0===d?void 0:d.current)||(null===(s=f.current[S])||void 0===s?void 0:s.current)||null}}(),s=d.leftAnchor,v=d.rightAnchor,h=l===o?s:v,x=l===o?v:s,m=null;if(h&&x){var S=h.getBoundingClientRect(),T=x.getBoundingClientRect(),I=a.getBoundingClientRect(),E=S.top+S.height/2;m=T.top-I.top+a.scrollTop+T.height/2-(E-I.top)}else{var M=Math.max(0,l.scrollHeight-l.clientHeight),D=Math.max(0,a.scrollHeight-a.clientHeight);m=M>0?l.scrollTop/M*D:l.scrollTop}var O=Math.max(0,a.scrollHeight-a.clientHeight);m=Math.max(0,Math.min(m,O)),Math.abs(a.scrollTop-m)>1&&(bt.current=!0,a.scrollTop=m,requestAnimationFrame(function(){bt.current=!1}))}}C||Bt(),ft.current||(ft.current=!0,requestAnimationFrame(function(){var t,n,l,o,u,a,d;if(F.current){var s=r.current,v=c.current;if(s&&v&&H.current){if(!N.current){var h=P.current,g=void 0;if("string"==typeof h&&h.includes(e.DEVIATION_BADGE_SEPARATOR)){var f=h.split(e.DEVIATION_BADGE_SEPARATOR),b="".concat(f[0]).concat(e.DEVIATION_BADGE_SEPARATOR).concat(f[1]);g=null===(t=A.current[b])||void 0===t?void 0:t.current}else g=null===(n=A.current[h])||void 0===n?void 0:n.current;if(g){var p=g.getBoundingClientRect();N.current={badgeScreenY:p.top+p.height/2,initialScrollTop:s.scrollTop,leftTop:s.getBoundingClientRect().top,leftBottom:s.getBoundingClientRect().top+s.clientHeight,cTop:null!==(o=null===(l=i.current)||void 0===l?void 0:l.getBoundingClientRect().top)&&void 0!==o?o:0}}}if(N.current){var y=N.current,R=s.scrollTop-y.initialScrollTop,x=y.badgeScreenY-R,m=((u=x,a=y.leftTop,d=y.leftBottom,Math.max(a,Math.min(d,u)))-y.cTop).toString(),B=x>=y.leftTop-4&&x<=y.leftBottom+4;H.current.setAttribute("y1",m),H.current.setAttribute("y2",m),H.current.setAttribute("visibility",B?"visible":"hidden")}}}mt(),ft.current=!1}))}},[mt,C,Q,B,Bt]);return t.useEffect(function(){Y.current=xt},[xt]),t.useEffect(function(){var t=setTimeout(Bt,250),e=function(){return X.current()};return window.addEventListener("resize",e),function(){clearTimeout(t),null!==pt.current&&clearTimeout(pt.current),null!==j.current&&clearTimeout(j.current),window.removeEventListener("resize",e)}},[q,K,J,s,x,m,a,d,Z,Bt,S,T,L,B]),{lines:et,setLines:nt,overallConnector:rt,setOverallConnector:ct,connectedLines:at,setConnectedLines:dt,svgDimensions:vt,cachedConnectedPositions:yt,calculateLines:xt,calculateLinesRef:Y,calculateLinesDebounced:Bt,handleColumnScroll:St}};
2
2
  //# sourceMappingURL=useLinesCalculator.js.map
@@ -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("monaco-editor"),l=require("@mui/icons-material/DarkMode"),d=require("@mui/icons-material/LightMode");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(o){if("default"!==o){var t=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,t.get?t:{enumerable:!0,get:function(){return e[o]}})}}),r.default=e,Object.freeze(r)}var c=g(i),f=g(n),h=g(s),x=u(a),p=g(l),m=g(d),b={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"}},_={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"}},v=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(p.default,{sx:{fontSize:11,color:"#fff"}}):r.jsx(m.default,{sx:{fontSize:11,color:"#fff"}})}))}))},j=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,c=void 0===u?12:u,f=o.useRef(),p=o.useRef();return o.useEffect(function(){if(s&&f.current&&p.current){var e=f.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 p.current.Selection(t,1,t,1)),e.trigger(null,"editor.unfold",{}),e.revealLineInCenterIfOutsideViewport(t);var d=e.deltaDecorations([],[{range:new p.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&&f.current&&p.current){var e=f.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 x.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(){p.current&&p.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(h.default,{onMount:function(e,r){f.current=e,p.current=r,r.editor.defineTheme("promptemonDark",b),r.editor.defineTheme("promptemonLight",_),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",b),e.editor.defineTheme("promptemonLight",_),e.editor.setTheme(l?"promptemonDark":"promptemonLight")},theme:l?"promptemonDark":"promptemonLight",value:n,language:"promptemonLang",onChange:function(){},options:{fontSize:c,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,g=i.selectedTag,u=i.highlightVariable,h=o.useState(!0),x=h[0],p=h[1],m=o.useState(!1),b=m[0],_=m[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(v,{isDarkMode:x,onChange:p}),r.jsx(t.Tooltip,e.__assign({title:"Fullscreen",placement:"top"},{children:r.jsx(t.Box,e.__assign({onClick:function(){return _(!0)},sx:{cursor:"pointer",display:"flex",alignItems:"center",p:.3,borderRadius:"4px","&:hover":{bgcolor:"#e5e7eb"}}},{children:r.jsx(f.default,{sx:{fontSize:"0.9rem",color:"#6b7280"}})}))}))]}))]})),r.jsx(t.Box,e.__assign({sx:{height:d,bgcolor:x?"#030202":"#fff"}},{children:r.jsx(j,{content:a,selectedTag:g,highlightVariable:u,isDarkMode:x,height:d,fontSize:12})}))]})),r.jsxs(t.Dialog,e.__assign({open:b,onClose:function(){return _(!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 _(!1)}},{children:r.jsx(c.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(v,{isDarkMode:x,onChange:p})]})),r.jsx(t.Box,e.__assign({sx:{flex:1,minHeight:0,p:1.5}},{children:r.jsx(j,{content:a,selectedTag:g,highlightVariable:u,isDarkMode:x,height:"100%",fontSize:13})}))]}))]}))]}))]})};
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 i,__awaiter as n,__generator as t}from"tslib";import{jsxs as o,jsx as e,Fragment as l}from"react/jsx-runtime";import{Globe as r,ChevronUp as a,ChevronDown as d,Maximize2 as u,X as c,ExternalLink as s}from"lucide-react";import{useState as v,useEffect as p,useMemo as m,useRef as h}from"react";import g from"./ResizableSplitPane.js";import f from"../PdfViewer/PdfViewer.js";import{DefaultFullScreenCloseIcon as b,DefaultFullScreenIcon as x}from"../../assests/svg/PdfViewerIcons.js";import _ from"react-markdown";import y from"rehype-raw";import{Dialog as w,Box as C}from"@mui/material";import{SHARED_MARKDOWN_STYLES as F}from"./CognitiveCompareConfig.js";import"react-dom";import{useCompareContext as D}from"./CompareContext.js";import{processGuidelinesMarkdown as P}from"./Guidelines/utils/processGuidelinesMarkdown.js";import T from"../GptWebCitation/GptWebCitation.js";import{CitationType as S}from"../GptWebCitation/types.js";import"./MoreFunctionsPopup.js";import"./components/SubSectionAccordion.js";import"./components/LHSSectionRow.js";import"./components/RHSSectionRow.js";var k=function(i){var n,t,o;return(null===(o=null===(t=null===(n=(null==i?void 0:i.extraMetaData)||i)||void 0===n?void 0:n.aiReasoningCitation)||void 0===t?void 0:t.gpt_citation)||void 0===o?void 0:o[0])||null},N="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",j="sai.siddhartha@techolution.com",I="672e32f7a0e8fe2e8e50bcba",R="TNV Sai Siddhartha",G="90vh",U="calc(".concat(G," - 120px)"),E=function(){var i;return"function"==typeof(null===(i=globalThis.crypto)||void 0===i?void 0:i.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var n=Math.floor(16*Math.random());return("x"===i?n:n%4+8).toString(16)})},M=function(i,n){var t=function(i){var n;return(null==i?void 0:i.payloadCitationId)||(null===(n=null==i?void 0:i.extraMetaData)||void 0===n?void 0:n.payloadCitationId)||""}(i)||n||E();return function(i,n){i&&"object"==typeof i&&(i.payloadCitationId=n,i.extraMetaData&&"object"==typeof i.extraMetaData&&(i.extraMetaData.payloadCitationId=n))}(i,t),t},A=function(o){var l,r=o.metaData,g=o.isFullscreen,f=void 0!==g&&g,b=D().gptWebCitationConfig,x=m(function(){return function(i){return{endpoint:(null==i?void 0:i.endpoint)||N,userEmail:(null==i?void 0:i.userEmail)||j,userId:(null==i?void 0:i.userId)||I,userName:(null==i?void 0:i.userName)||R,headers:null==i?void 0:i.headers}}(b)},[b]),_=null==r?void 0:r.webGpt,y=h(null);y.current||(y.current=E());var w=m(function(){return function(i,n,t){var o,e,l=k(i),r=(null==l?void 0:l.customMetaData)||{},a=(null==r?void 0:r.value)||{},d=(null==i?void 0:i.webSearchAnswer)||{},u=(null==i?void 0:i.extraMetaData)||i||{};return{userEmail:(null==i?void 0:i.userEmail)||(null==d?void 0:d.userEmail)||(null==n?void 0:n.userEmail)||"",userId:(null==i?void 0:i.userId)||(null==d?void 0:d.userId)||(null==n?void 0:n.userId)||"",userName:(null==i?void 0:i.userName)||(null==d?void 0:d.userName)||(null==n?void 0:n.userName)||"",citationId:M(i,t),citationUrl:(null==a?void 0:a.citationUrl)||(null==d?void 0:d.citationUrl)||"",content:(null==u?void 0:u.Reasoning)||(null==d?void 0:d.enhanced_content)||"",citationType:(null==a?void 0:a.citationType)||"web",citatioNumber:null!==(e=null!==(o=null==r?void 0:r.citation_number)&&void 0!==o?o:null==l?void 0:l.citation_number)&&void 0!==e?e:Number((null==i?void 0:i.reasoningId)||0)}}(_,x,y.current||void 0)},[_,x]),C=m(function(){return k(_)},[_]),F=(null===(l=null==C?void 0:C.customMetaData)||void 0===l?void 0:l.value)||{},P=(null==_?void 0:_.extraMetaData)||_||{},G=v(),A=G[0],H=G[1],W=v("pending"),z=W[0],O=W[1],V=v(!0),B=V[0],L=V[1];p(function(){var o=!0;return n(void 0,void 0,void 0,function(){var n,e,l,r;return t(this,function(t){switch(t.label){case 0:if(!x.endpoint||!(null==w?void 0:w.citationUrl)||!(null==w?void 0:w.content))return O("error"),[2];O("pending"),t.label=1;case 1:return t.trys.push([1,4,,5]),[4,fetch(x.endpoint,{method:"POST",headers:i({"actor-id":w.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},x.headers||{}),body:JSON.stringify(w)})];case 2:if(!(n=t.sent()).ok)throw new Error("Failed to fetch GPT web citation (".concat(n.status,")"));return[4,n.json()];case 3:return e=t.sent(),l=(null==e?void 0:e.responseData)||(null==e?void 0:e.result)||(null==e?void 0:e.data)||e,o?(H(l),O("success"),[3,5]):[2];case 4:return r=t.sent(),o?(console.error("Failed to load GPT web citation",r),O("error"),[3,5]):[2];case 5:return[2]}})}),function(){o=!1}},[w,x]);var J=m(function(){return{item:{confidence_score:Number((null==P?void 0:P.Confidence_score)||0),text:(null==F?void 0:F.paraphrase)||"Web citation reasoning",dataSource:(null==F?void 0:F.text)||(null==P?void 0:P.Reasoning)||"",paraphrase:(null==F?void 0:F.paraphrase)||""},headerTitle:"GPT Web Citation",index:Number((null==w?void 0:w.citatioNumber)||1)-1,iconsConfig:{ChevronDownIcon:d,ChevronUpIcon:a,MaximizeIcon:u,CloseIcon:c}}},[F,null==w?void 0:w.citatioNumber,P]),$=m(function(){return i(i({},J),f?{bodyHeight:U}:{})},[J,f]);return e(T,{gptCitation:$,defaultCitationUrl:(null==w?void 0:w.citationUrl)||"",citationType:S.GPT_WEB,webCitationData:A,webCitationStatus:z,showWebCitation:B,onToggleCitationView:function(){return L(function(i){return!i})},iconsConfig:{MaximizeIcon:u,ExternalLinkIcon:s},isFixedHeight:!0})},H=function(n){var t,o,r,a,d,u,c,s=n.href,v=n.metaData,p=n.citationTitle,h=n.citationType,b=n.citationReason,x=n.isFullscreen,w=D().guidelinesData,T=function(i){try{var n=function(i){var n=i.match(/^(?:pdf_citation|deviation_summary)\$(\d+)/);if(n)try{var t=i.indexOf("?"),o=t>=0?i.slice(t):"";return{citationNumber:n[1],parsedUrl:new URL(o||"./",window.location.origin)}}catch(i){return{citationNumber:n[1],parsedUrl:null}}try{var e=new URL(i,window.location.origin);return{citationNumber:e.searchParams.get("citationNumber")||e.searchParams.get("citation_number"),parsedUrl:e}}catch(i){return{citationNumber:null,parsedUrl:null}}}(i),t=n.citationNumber,o=n.parsedUrl;return{citationNumber:t,phraseToHighlight:(null==o?void 0:o.searchParams.get("phrase_to_highlight"))||null,citationTypeFromHref:(null==o?void 0:o.searchParams.get("citation_type"))||null}}catch(i){return{citationNumber:null,phraseToHighlight:null,citationTypeFromHref:null}}}(s),S=T.citationNumber,k=T.phraseToHighlight,N=T.citationTypeFromHref,j=h||N||void 0,I="il_rulebook_citation"===j?"rulebook_citation":j,R=S&&(null===(t=null==v?void 0:v.citations)||void 0===t?void 0:t[S])||{},G=(null===(o=null==v?void 0:v.docData)||void 0===o?void 0:o.documents)||{},U=(null===(r=null==v?void 0:v.docData)||void 0===r?void 0:r.input_index_map)||{},E=Object.keys((null==v?void 0:v.citations)||{}).length>0||Object.keys((null==v?void 0:v.docData)||{}).length>0,M=null==U?void 0:U[0],H=null==U?void 0:U[1],W=M?G[M]:null,z=H?G[H]:null,O=M?R[M]:null,V=H?R[H]:null,B=m(function(){var i,n,t,o;return O&&W?e(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==W?void 0:W.title,pdfUrl:null==W?void 0:W.signed_url,highlightText:[null!==(i=null==O?void 0:O.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==O?void 0:O.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==O?void 0:O.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==O?void 0:O.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==W?void 0:W.title,null==W?void 0:W.signed_url,null==O?void 0:O.highlighted_text,null===(a=null==O?void 0:O.custom_metadata)||void 0===a?void 0:a.pdf_start_page_number,null===(d=null==O?void 0:O.custom_metadata)||void 0===d?void 0:d.pdf_end_page_number]),L=m(function(){var i,n,t,o;return V&&z?e(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==z?void 0:z.title,pdfUrl:null==z?void 0:z.signed_url,jumpToPageValue:1,highlightText:[null!==(i=null==V?void 0:V.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==V?void 0:V.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(t=null==V?void 0:V.custom_metadata)||void 0===t?void 0:t.pdf_start_page_number,null===(o=null==V?void 0:V.custom_metadata)||void 0===o?void 0:o.pdf_end_page_number]}):null},[null==z?void 0:z.title,null==z?void 0:z.signed_url,null==V?void 0:V.highlighted_text,null===(u=null==V?void 0:V.custom_metadata)||void 0===u?void 0:u.pdf_start_page_number,null===(c=null==V?void 0:V.custom_metadata)||void 0===c?void 0:c.pdf_end_page_number]),J="dual_citation"===I,$=J&&!!(null==v?void 0:v.webGpt),q=m(function(){if(!B)return null;var n=$?e(A,{metaData:v,isFullscreen:x}):"rulebook_citation"===I?e(l,{children:e(C,i({sx:i(i({padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px"},F),{overflow:"auto"})},{children:e(_,i({rehypePlugins:[y]},{children:P({guidelinesData:w,targetHighlights:[k],labelColor:"#FEF08A"})}))}))}):L;return n?e(g,{leftComponent:B,rightComponent:n,isFullscreen:x}):B},[B,L,I,$,v,x,w,k]);return(null==v?void 0:v.webGpt)&&!E?e(A,{metaData:v,isFullscreen:x}):S?"rulebook_citation"===I?e("div",O?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q}):i({style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5}},{children:b||"Rulebook citation selected."})):J?O||V?e("div",i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q})):(null==v?void 0:v.webGpt)?e(A,{metaData:v,isFullscreen:x}):e("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(p)?e("div",O||V?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:q}):{children:"Missing PDF Citation. Please try again later"}):e("div",{children:"No Citation Found. Please try again later"}):null},W=function(n){var t,l,u,c,s,m,h,g=n.href,f=n.children,_=n.citationType,y=n.citationReason,C=n.metaData,F=n.chevronUpComponent,D=void 0===F?null:F,P=n.chevronDownComponent,T=void 0===P?null:P,S=n.customStyle,k=void 0===S?{}:S,N=n.defaultState,j=void 0!==N&&N,I=n.onFullscreenChange,R=v(j),U=R[0],E=R[1],M=v(!1),A=M[0],W=M[1],z="string"==typeof f&&(null===(t=null==f?void 0:f.split("\n"))||void 0===t?void 0:t.length)>1?f.split("\n").join(" "):f;p(function(){if(null==I||I(A),A)return function(){null==I||I(!1)}},[A,I]);var O="string"==typeof f?f:f[0],V=null!=D?D:function(i){var n,t;return e(a,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(t=null==i?void 0:i.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(l=null==k?void 0:k.arrow)&&void 0!==l?l:{}),B=null!=T?T:function(i){var n,t;return e(d,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(t=null==i?void 0:i.color)&&void 0!==t?t:"rgb(214, 51, 132)"})}(null!==(u=null==k?void 0:k.arrow)&&void 0!==u?u:{}),L=o("div",i({style:{boxSizing:"border-box",border:A?"none":"1px solid #E4E7EC",borderRadius:A?0:"8px",overflow:"hidden",marginTop:A?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:A?"100%":void 0,backgroundColor:"#FAFAFA"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:e("button",i({onClick:function(){W(function(i){return!i})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:e(A?b:x,{})}))})),e("div",i({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:e(H,{href:g,children:f,metaData:C,citationTitle:O,citationType:_,citationReason:y,isFullscreen:A})}))]}));return o("span",i({style:i({display:"inline"},k.relativeWrapper||{})},{children:[e("div",i({style:i({display:"inline",marginTop:0},k.citationButtonWrapper||{})},{children:o("button",i({type:"button",onClick:function(){return E(function(i){return!i})},style:i({display:(null==C?void 0:C.webGpt)?"inline":"inline-flex",alignItems:(null==C?void 0:C.webGpt)?void 0:"center",gap:(null==C?void 0:C.webGpt)?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:(null==C?void 0:C.webGpt)?600:700,color:(null==C?void 0:C.webGpt)?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},k.citationButton||{})},{children:[(null==C?void 0:C.webGpt)&&e(r,{size:null!==(s=null===(c=k.arrow)||void 0===c?void 0:c.fontSize)&&void 0!==s?s:"1em",color:null!==(h=null===(m=k.arrow)||void 0===m?void 0:m.color)&&void 0!==h?h:"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),e("span",{children:z}),e("span",i({style:{display:"inline-flex",alignItems:"center",marginLeft:(null==C?void 0:C.webGpt)?"3px":void 0,verticalAlign:(null==C?void 0:C.webGpt)?"-0.125em":void 0}},{children:U?V:B}))]}))})),U&&(A?e(w,i({open:A,onClose:function(){return W(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:G,m:0,maxHeight:G,maxWidth:"95vw",overflow:"hidden",width:"95vw"}}},{children:L})):L)]}))};export{W as default};
1
+ import{__assign as i,__awaiter as n,__generator as o}from"tslib";import{jsxs as t,jsx as e,Fragment as l}from"react/jsx-runtime";import{Globe as r,ChevronUp as a,ChevronDown as d,Maximize2 as u,X as c,ExternalLink as s}from"lucide-react";import{useState as v,useEffect as p,useMemo as h,useRef as m}from"react";import g from"./ResizableSplitPane.js";import f from"../PdfViewer/PdfViewer.js";import{DefaultFullScreenCloseIcon as x,DefaultFullScreenIcon as b}from"../../assests/svg/PdfViewerIcons.js";import _ from"react-markdown";import y from"rehype-raw";import{Dialog as w,Box as C}from"@mui/material";import{SHARED_MARKDOWN_STYLES as F}from"./CognitiveCompareConfig.js";import"react-dom";import{useCompareContext as D}from"./CompareContext.js";import{processGuidelinesMarkdown as P}from"./Guidelines/utils/processGuidelinesMarkdown.js";import S from"../GptWebCitation/GptWebCitation.js";import{CitationType as T}from"../GptWebCitation/types.js";import"./MoreFunctionsPopup.js";import"./components/SubSectionAccordion.js";import"./components/LHSSectionRow.js";import"./components/RHSSectionRow.js";var k=function(i){var n,o,t;return(null===(t=null===(o=null===(n=(null==i?void 0:i.extraMetaData)||i)||void 0===n?void 0:n.aiReasoningCitation)||void 0===o?void 0:o.gpt_citation)||void 0===t?void 0:t[0])||null},j="https://dev-proposals-ai.techo.camp/utility/ca-workflow-composer-agent/get_citation",I="sai.siddhartha@techolution.com",G="672e32f7a0e8fe2e8e50bcba",N="TNV Sai Siddhartha",R="90vh",E="calc(".concat(R," - 120px)"),M=function(){var i;return"function"==typeof(null===(i=globalThis.crypto)||void 0===i?void 0:i.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var n=Math.floor(16*Math.random());return("x"===i?n:n%4+8).toString(16)})},A=function(i,n){var o=function(i){var n;return(null==i?void 0:i.payloadCitationId)||(null===(n=null==i?void 0:i.extraMetaData)||void 0===n?void 0:n.payloadCitationId)||""}(i)||n||M();return function(i,n){i&&"object"==typeof i&&(i.payloadCitationId=n,i.extraMetaData&&"object"==typeof i.extraMetaData&&(i.extraMetaData.payloadCitationId=n))}(i,o),o},U=function(t){var l,r=t.metaData,g=t.isFullscreen,f=void 0!==g&&g,x=D().gptWebCitationConfig,b=h(function(){return function(i){return{endpoint:(null==i?void 0:i.endpoint)||j,userEmail:(null==i?void 0:i.userEmail)||I,userId:(null==i?void 0:i.userId)||G,userName:(null==i?void 0:i.userName)||N,headers:null==i?void 0:i.headers}}(x)},[x]),_=null==r?void 0:r.webGpt,y=m(null);y.current||(y.current=M());var w=h(function(){return function(i,n,o){var t,e,l=k(i),r=(null==l?void 0:l.customMetaData)||{},a=(null==r?void 0:r.value)||{},d=(null==i?void 0:i.webSearchAnswer)||{},u=(null==i?void 0:i.extraMetaData)||i||{};return{userEmail:(null==i?void 0:i.userEmail)||(null==d?void 0:d.userEmail)||(null==n?void 0:n.userEmail)||"",userId:(null==i?void 0:i.userId)||(null==d?void 0:d.userId)||(null==n?void 0:n.userId)||"",userName:(null==i?void 0:i.userName)||(null==d?void 0:d.userName)||(null==n?void 0:n.userName)||"",citationId:A(i,o),citationUrl:(null==a?void 0:a.citationUrl)||(null==d?void 0:d.citationUrl)||"",content:(null==u?void 0:u.Reasoning)||(null==d?void 0:d.enhanced_content)||"",citationType:(null==a?void 0:a.citationType)||"web",citatioNumber:null!==(e=null!==(t=null==r?void 0:r.citation_number)&&void 0!==t?t:null==l?void 0:l.citation_number)&&void 0!==e?e:Number((null==i?void 0:i.reasoningId)||0)}}(_,b,y.current||void 0)},[_,b]),C=h(function(){return k(_)},[_]),F=(null===(l=null==C?void 0:C.customMetaData)||void 0===l?void 0:l.value)||{},P=(null==_?void 0:_.extraMetaData)||_||{},R=v(),U=R[0],W=R[1],H=v("pending"),z=H[0],V=H[1],B=v(!0),O=B[0],L=B[1];p(function(){var t=!0;return n(void 0,void 0,void 0,function(){var n,e,l,r;return o(this,function(o){switch(o.label){case 0:if(!b.endpoint||!(null==w?void 0:w.citationUrl)||!(null==w?void 0:w.content))return V("error"),[2];V("pending"),o.label=1;case 1:return o.trys.push([1,4,,5]),[4,fetch(b.endpoint,{method:"POST",headers:i({"actor-id":w.userEmail,Accept:"application/json, text/plain, */*","Content-Type":"application/json"},b.headers||{}),body:JSON.stringify(w)})];case 2:if(!(n=o.sent()).ok)throw new Error("Failed to fetch GPT web citation (".concat(n.status,")"));return[4,n.json()];case 3:return e=o.sent(),l=(null==e?void 0:e.responseData)||(null==e?void 0:e.result)||(null==e?void 0:e.data)||e,t?(W(l),V("success"),[3,5]):[2];case 4:return r=o.sent(),t?(console.error("Failed to load GPT web citation",r),V("error"),[3,5]):[2];case 5:return[2]}})}),function(){t=!1}},[w,b]);var J=h(function(){return{item:{confidence_score:Number((null==P?void 0:P.Confidence_score)||0),text:(null==F?void 0:F.paraphrase)||"Web citation reasoning",dataSource:(null==F?void 0:F.text)||(null==P?void 0:P.Reasoning)||"",paraphrase:(null==F?void 0:F.paraphrase)||""},headerTitle:"GPT Web Citation",index:Number((null==w?void 0:w.citatioNumber)||1)-1,iconsConfig:{ChevronDownIcon:d,ChevronUpIcon:a,MaximizeIcon:u,CloseIcon:c}}},[F,null==w?void 0:w.citatioNumber,P]),q=h(function(){return i(i({},J),f?{bodyHeight:E}:{})},[J,f]);return e(S,{gptCitation:q,defaultCitationUrl:(null==w?void 0:w.citationUrl)||"",citationType:T.GPT_WEB,webCitationData:U,webCitationStatus:z,showWebCitation:O,onToggleCitationView:function(){return L(function(i){return!i})},iconsConfig:{MaximizeIcon:u,ExternalLinkIcon:s},isFixedHeight:!0})},W=function(n){var o,t,r,a,d,u,c,s=n.href,v=n.metaData,p=n.citationTitle,m=n.citationType,x=n.citationReason,b=n.isFullscreen,w=D().guidelinesData,S=function(i){try{var n=new URL(i,window.location.origin);return{citationNumber:n.searchParams.get("citationNumber"),phraseToHighlight:n.searchParams.get("phrase_to_highlight")}}catch(i){return{citationNumber:null,phraseToHighlight:null}}}(s),T=S.citationNumber,k=S.phraseToHighlight,j=T&&(null===(o=null==v?void 0:v.citations)||void 0===o?void 0:o[T])||{},I=(null===(t=null==v?void 0:v.docData)||void 0===t?void 0:t.documents)||{},G=(null===(r=null==v?void 0:v.docData)||void 0===r?void 0:r.input_index_map)||{},N=Object.keys((null==v?void 0:v.citations)||{}).length>0||Object.keys((null==v?void 0:v.docData)||{}).length>0,R=null==G?void 0:G[0],E=null==G?void 0:G[1],M=R?I[R]:null,A=E?I[E]:null,W=R?j[R]:null,H=E?j[E]:null,z=h(function(){var i,n,o,t;return W&&M?e(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==M?void 0:M.title,pdfUrl:null==M?void 0:M.signed_url,highlightText:[null!==(i=null==W?void 0:W.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==W?void 0:W.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},jumpToPageValue:1,highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(o=null==W?void 0:W.custom_metadata)||void 0===o?void 0:o.pdf_start_page_number,null===(t=null==W?void 0:W.custom_metadata)||void 0===t?void 0:t.pdf_end_page_number]}):null},[null==M?void 0:M.title,null==M?void 0:M.signed_url,null==W?void 0:W.highlighted_text,null===(a=null==W?void 0:W.custom_metadata)||void 0===a?void 0:a.pdf_start_page_number,null===(d=null==W?void 0:W.custom_metadata)||void 0===d?void 0:d.pdf_end_page_number]),V=h(function(){var i,n,o,t;return H&&A?e(f,{defaultScale:"PageWidth",showFullScreenAction:!1,showHighlightsAction:!1,pdfName:null==A?void 0:A.title,pdfUrl:null==A?void 0:A.signed_url,jumpToPageValue:1,highlightText:[null!==(i=null==H?void 0:H.highlighted_text)&&void 0!==i?i:""],highlightPages:{1:null===(n=null==H?void 0:H.custom_metadata)||void 0===n?void 0:n.pdf_start_page_number},highlightCordinatePages:[],useCoordinates:!1,useRange:!0,rangeOfPages:[null===(o=null==H?void 0:H.custom_metadata)||void 0===o?void 0:o.pdf_start_page_number,null===(t=null==H?void 0:H.custom_metadata)||void 0===t?void 0:t.pdf_end_page_number]}):null},[null==A?void 0:A.title,null==A?void 0:A.signed_url,null==H?void 0:H.highlighted_text,null===(u=null==H?void 0:H.custom_metadata)||void 0===u?void 0:u.pdf_start_page_number,null===(c=null==H?void 0:H.custom_metadata)||void 0===c?void 0:c.pdf_end_page_number]),B="dual_citation"===m,O=B&&!!(null==v?void 0:v.webGpt),L=h(function(){if(!z)return null;var n=O?e(U,{metaData:v,isFullscreen:b}):"rulebook_citation"===m?e(l,{children:e(C,i({sx:i(i({padding:"0px 20px",backgroundColor:"#FFFFFF",borderRadius:"8px"},F),{overflow:"auto"})},{children:e(_,i({rehypePlugins:[y]},{children:P({guidelinesData:w,targetHighlights:[k],labelColor:"#FEF08A"})}))}))}):V;return n?e(g,{leftComponent:z,rightComponent:n,isFullscreen:b}):z},[z,V,m,O,v,b]);return(null==v?void 0:v.webGpt)&&!N?e(U,{metaData:v,isFullscreen:b}):T?"rulebook_citation"===m?e("div",W?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:L}):i({style:{padding:"12px",fontSize:"13px",color:"#344054",lineHeight:1.5}},{children:x||"Rulebook citation selected."})):B?W||H?e("div",i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:L})):(null==v?void 0:v.webGpt)?e(U,{metaData:v,isFullscreen:b}):e("div",{children:"Missing PDF Citation. Please try again later"}):["contract","clause"].includes(p)?e("div",W||H?i({style:{height:"100%",display:"flex",flexDirection:"column"}},{children:L}):{children:"Missing PDF Citation. Please try again later"}):e("div",{children:"No Citation Found. Please try again later"}):null},H=function(n){var o,l,u,c,s,h,m,g=n.href,f=n.children,_=n.citationType,y=n.citationReason,C=n.metaData,F=n.chevronUpComponent,D=void 0===F?null:F,P=n.chevronDownComponent,S=void 0===P?null:P,T=n.customStyle,k=void 0===T?{}:T,j=n.defaultState,I=void 0!==j&&j,G=n.onFullscreenChange,N=v(I),E=N[0],M=N[1],A=v(!1),U=A[0],H=A[1],z="string"==typeof f&&(null===(o=null==f?void 0:f.split("\n"))||void 0===o?void 0:o.length)>1?f.split("\n").join(" "):f;p(function(){if(null==G||G(U),U)return function(){null==G||G(!1)}},[U,G]);var V="string"==typeof f?f:f[0],B=null!=D?D:function(i){var n,o;return e(a,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(o=null==i?void 0:i.color)&&void 0!==o?o:"rgb(214, 51, 132)"})}(null!==(l=null==k?void 0:k.arrow)&&void 0!==l?l:{}),O=null!=S?S:function(i){var n,o;return e(d,{size:null!==(n=null==i?void 0:i.fontSize)&&void 0!==n?n:16,color:null!==(o=null==i?void 0:i.color)&&void 0!==o?o:"rgb(214, 51, 132)"})}(null!==(u=null==k?void 0:k.arrow)&&void 0!==u?u:{}),L=t("div",i({style:{boxSizing:"border-box",border:U?"none":"1px solid #E4E7EC",borderRadius:U?0:"8px",overflow:"hidden",marginTop:U?0:"8px",display:"flex",flexDirection:"column",width:"100%",height:U?"100%":void 0,backgroundColor:"#FAFAFA"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-end",padding:"6px 10px",borderBottom:"1px solid #E4E7EC",backgroundColor:"#FFFFFF",flexShrink:0}},{children:e("button",i({onClick:function(){H(function(i){return!i})},style:{background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"6px",color:"#475467",marginRight:"9px"}},{children:e(U?x:b,{})}))})),e("div",i({style:{flex:1,minHeight:0,height:"100%",overflow:"hidden"}},{children:e(W,{href:g,children:f,metaData:C,citationTitle:V,citationType:_,citationReason:y,isFullscreen:U})}))]}));return t("span",i({style:i({display:"inline"},k.relativeWrapper||{})},{children:[e("div",i({style:i({display:"inline",marginTop:0},k.citationButtonWrapper||{})},{children:t("button",i({type:"button",onClick:function(){return M(function(i){return!i})},style:i({display:(null==C?void 0:C.webGpt)?"inline":"inline-flex",alignItems:(null==C?void 0:C.webGpt)?void 0:"center",gap:(null==C?void 0:C.webGpt)?void 0:"3px",fontFamily:'"Inter", sans-serif',backgroundColor:"transparent",padding:0,margin:0,fontSize:"13px",borderRadius:9999,cursor:"pointer",fontWeight:(null==C?void 0:C.webGpt)?600:700,color:(null==C?void 0:C.webGpt)?"#6D28D9":"rgb(214, 51, 132)",border:"none",textDecoration:"none",wordBreak:"break-word",whiteSpace:"normal"},k.citationButton||{})},{children:[(null==C?void 0:C.webGpt)&&e(r,{size:null!==(s=null===(c=k.arrow)||void 0===c?void 0:c.fontSize)&&void 0!==s?s:"1em",color:null!==(m=null===(h=k.arrow)||void 0===h?void 0:h.color)&&void 0!==m?m:"#6D28D9",style:{display:"inline-block",width:"1em",height:"1em",marginRight:"3px",verticalAlign:"-0.125em",flexShrink:0}}),e("span",{children:z}),e("span",i({style:{display:"inline-flex",alignItems:"center",marginLeft:(null==C?void 0:C.webGpt)?"3px":void 0,verticalAlign:(null==C?void 0:C.webGpt)?"-0.125em":void 0}},{children:E?B:O}))]}))})),E&&(U?e(w,i({open:U,onClose:function(){return H(!1)},maxWidth:!1,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"}},PaperProps:{sx:{backgroundColor:"#FAFAFA",borderRadius:"16px",height:R,m:0,maxHeight:R,maxWidth:"95vw",overflow:"hidden",width:"95vw"}}},{children:L})):L)]}))};export{H as default};
2
2
  //# sourceMappingURL=CitationAnchor.js.map