@e-llm-studio/instant-learning 1.3.0-alpha.111 → 1.3.0-alpha.113

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 (75) hide show
  1. package/dist/cjs/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
  2. package/dist/cjs/features/LSCGuidelinesCart/Cart/Cart.js +1 -1
  3. package/dist/cjs/features/LSCGuidelinesCart/GuidelineCard.js +1 -1
  4. package/dist/cjs/features/LSCGuidelinesCart/GuidelinesLandingPage.js +1 -1
  5. package/dist/cjs/features/LSCGuidelinesCart/GuidelinesLandingPage.styles.js +1 -1
  6. package/dist/cjs/features/LSCGuidelinesCart/LearningManagementWrapper.js +1 -1
  7. package/dist/cjs/features/LSCGuidelinesCart/api.js +1 -1
  8. package/dist/cjs/features/LSCGuidelinesCart/endpoints.js +1 -1
  9. package/dist/cjs/features/LSCGuidelinesCart/transformSelectedGuidelineData.js +2 -0
  10. package/dist/cjs/features/LSCGuidelinesCart/transformSelectedGuidelineData.js.map +1 -0
  11. package/dist/cjs/features/LearningManagement/LearningManagementTest.js +1 -1
  12. package/dist/cjs/features/LearningManagement/LearningTemplateLayout.js +1 -1
  13. package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js +1 -1
  14. package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
  15. package/dist/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
  16. package/dist/features/LSCGuidelinesCart/Cart/Cart.js +1 -1
  17. package/dist/features/LSCGuidelinesCart/GuidelineCard.js +1 -1
  18. package/dist/features/LSCGuidelinesCart/GuidelinesLandingPage.js +1 -1
  19. package/dist/features/LSCGuidelinesCart/GuidelinesLandingPage.styles.js +1 -1
  20. package/dist/features/LSCGuidelinesCart/LearningManagementWrapper.js +1 -1
  21. package/dist/features/LSCGuidelinesCart/api.js +1 -1
  22. package/dist/features/LSCGuidelinesCart/endpoints.js +1 -1
  23. package/dist/features/LSCGuidelinesCart/transformSelectedGuidelineData.js +2 -0
  24. package/dist/features/LSCGuidelinesCart/transformSelectedGuidelineData.js.map +1 -0
  25. package/dist/features/LearningManagement/LearningManagementTest.js +1 -1
  26. package/dist/features/LearningManagement/LearningTemplateLayout.js +1 -1
  27. package/dist/features/LearningManagement/RuleContent/RuleContent.js +1 -1
  28. package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
  29. package/dist/types/src/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.d.ts.map +1 -1
  30. package/dist/types/src/features/LSCGuidelinesCart/Cart/Cart.d.ts +1 -1
  31. package/dist/types/src/features/LSCGuidelinesCart/Cart/Cart.d.ts.map +1 -1
  32. package/dist/types/src/features/LSCGuidelinesCart/GuidelinesLandingPage.d.ts +6 -1
  33. package/dist/types/src/features/LSCGuidelinesCart/GuidelinesLandingPage.d.ts.map +1 -1
  34. package/dist/types/src/features/LSCGuidelinesCart/GuidelinesLandingPage.styles.d.ts.map +1 -1
  35. package/dist/types/src/features/LSCGuidelinesCart/LearningManagementWrapper.d.ts +6 -1
  36. package/dist/types/src/features/LSCGuidelinesCart/LearningManagementWrapper.d.ts.map +1 -1
  37. package/dist/types/src/features/LSCGuidelinesCart/api.d.ts +1 -0
  38. package/dist/types/src/features/LSCGuidelinesCart/api.d.ts.map +1 -1
  39. package/dist/types/src/features/LSCGuidelinesCart/endpoints.d.ts +1 -0
  40. package/dist/types/src/features/LSCGuidelinesCart/endpoints.d.ts.map +1 -1
  41. package/dist/types/src/features/LSCGuidelinesCart/transformSelectedGuidelineData.d.ts +18 -0
  42. package/dist/types/src/features/LSCGuidelinesCart/transformSelectedGuidelineData.d.ts.map +1 -0
  43. package/dist/types/src/features/LearningManagement/LearningTemplateLayout.d.ts.map +1 -1
  44. package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
  45. package/package.json +1 -2
  46. package/dist/cjs/features/IL-OTJ/_components/templates/BaseTemplate/BaseTemplate.js +0 -2
  47. package/dist/cjs/features/IL-OTJ/_components/templates/BaseTemplate/BaseTemplate.js.map +0 -1
  48. package/dist/cjs/features/IL-OTJ/_components/templates/CreateCategory/CreateCategory.js +0 -2
  49. package/dist/cjs/features/IL-OTJ/_components/templates/CreateCategory/CreateCategory.js.map +0 -1
  50. package/dist/cjs/features/IL-OTJ/_components/templates/WorkflowComposer/WorkflowComposer.js +0 -2
  51. package/dist/cjs/features/IL-OTJ/_components/templates/WorkflowComposer/WorkflowComposer.js.map +0 -1
  52. package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js +0 -2
  53. package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js.map +0 -1
  54. package/dist/cjs/features/LearningManagement/components/CreateLearningSetModal.js +0 -2
  55. package/dist/cjs/features/LearningManagement/components/CreateLearningSetModal.js.map +0 -1
  56. package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +0 -2
  57. package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +0 -1
  58. package/dist/cjs/features/LearningManagement/styles/CreateLearningSetModal.module.css.js +0 -2
  59. package/dist/cjs/features/LearningManagement/styles/CreateLearningSetModal.module.css.js.map +0 -1
  60. package/dist/features/IL-OTJ/_components/templates/BaseTemplate/BaseTemplate.js +0 -2
  61. package/dist/features/IL-OTJ/_components/templates/BaseTemplate/BaseTemplate.js.map +0 -1
  62. package/dist/features/IL-OTJ/_components/templates/CreateCategory/CreateCategory.js +0 -2
  63. package/dist/features/IL-OTJ/_components/templates/CreateCategory/CreateCategory.js.map +0 -1
  64. package/dist/features/IL-OTJ/_components/templates/WorkflowComposer/WorkflowComposer.js +0 -2
  65. package/dist/features/IL-OTJ/_components/templates/WorkflowComposer/WorkflowComposer.js.map +0 -1
  66. package/dist/features/LearningManagement/assets/Search-result(add new).svg.js +0 -2
  67. package/dist/features/LearningManagement/assets/Search-result(add new).svg.js.map +0 -1
  68. package/dist/features/LearningManagement/components/CreateLearningSetModal.js +0 -2
  69. package/dist/features/LearningManagement/components/CreateLearningSetModal.js.map +0 -1
  70. package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +0 -2
  71. package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +0 -1
  72. package/dist/features/LearningManagement/styles/CreateLearningSetModal.module.css.js +0 -2
  73. package/dist/features/LearningManagement/styles/CreateLearningSetModal.module.css.js.map +0 -1
  74. package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts +0 -12
  75. package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),e=require("react/jsx-runtime"),n=require("react"),t=require("../../InputDataReasoningCard.js"),l=require("../../organisms/ConditionSection/ConditionSection.js"),o=require("../../organisms/ConfigSection/ConfigSection.js"),a=require("../../organisms/ScopeSection/ScopeSection.js"),r=require("../../organisms/TextSection/TextSection.js"),d=require("../../AccordianSection.js"),s=require("../../_svg/ButtonCognitiveIcon.js"),u=require("lucide-react");function c(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var v=c(n),p=function(t){var l=t.LazyPromptEditor,o=t.value,a=t.onChange,r=t.title,d=t.tierKey,s=t.variantIndex,c=t.uiState,v=t.isHighlighted,p="instruction-prompt-".concat(d,"-").concat(s),g=(null==c?void 0:c.activeEditId)===p,f=!!(null==c?void 0:c.activeEditId)&&c.activeEditId!==p,h=n.useState(null),x=h[0],_=h[1],y=(null==x?void 0:x.trim())||"",m=y===((null==o?void 0:o.trim())||"")||null!==x&&""===y,S={display:"flex",alignItems:"center",justifyContent:"center",padding:"8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:"pointer",width:"36px",height:"36px",backgroundColor:"#ffffff"},C={cursor:m?"not-allowed":"pointer",opacity:m?.5:1};return e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"4px",width:"100%",marginBottom:"12px",margin:"0 0.2rem"},"data-edit-id":p},{children:[e.jsx("div",i.__assign({style:{display:"flex",alignItems:"center",width:"100%",justifyContent:"space-between",marginBottom:"4px"}},{children:e.jsx("span",i.__assign({style:{fontSize:"14px",fontWeight:500,color:"#19213D",fontFamily:'"Plus Jakarta Sans", sans-serif'}},{children:r}))})),e.jsxs("div",i.__assign({style:{display:"flex",alignItems:"flex-start",gap:"8px",width:"100%"}},{children:[e.jsx("div",i.__assign({style:{flex:1,minWidth:0,border:v?"1px solid #2563EB":"none",borderRadius:"8px",boxShadow:v?"0 0 12px 3px rgba(37, 99, 235, 0.3)":"none",transition:"all 0.3s"}},{children:e.jsx(n.Suspense,i.__assign({fallback:e.jsx("div",i.__assign({style:{padding:"12px",fontSize:"13px",color:"#6b7280"}},{children:"Loading editor..."}))},{children:e.jsx("div",i.__assign({style:{pointerEvents:g?"auto":"none",opacity:g?1:.75}},{children:e.jsx(l,{value:g&&null!==x?x:o,onChange:function(i){g?_(i):a&&a(i)},title:r,minHeight:"220px",maxHeight:"400px"})}))}))})),!(null==c?void 0:c.isEffectivelyReadOnly)&&e.jsx("div",i.__assign({style:{display:"flex",flexDirection:"row",gap:"8px",marginTop:"0px"}},{children:g?e.jsxs(e.Fragment,{children:[e.jsxs("button",i.__assign({title:"Apply",onClick:function(){var i,e;if(null!==x){if(x===(null!=o?o:""))return _(null),void(null===(i=null==c?void 0:c.setActiveEditId)||void 0===i||i.call(c,null));if(null==a||a(x),null==c?void 0:c.setSendMessageInChat){var n="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8));c.setSendMessageInChat("__SKELETON__:".concat(n,":The Instruction Prompt has been updated through the Learning Form"))}_(null),null===(e=null==c?void 0:c.setActiveEditId)||void 0===e||e.call(c,null)}},disabled:m,style:i.__assign(i.__assign(i.__assign({},S),C),{backgroundColor:"#2563EB",color:"white",width:"auto",padding:"8px 12px"})},{children:[e.jsx(u.Check,{size:20,strokeWidth:2.5})," Apply"]})),e.jsx("button",i.__assign({title:"Cancel",onClick:function(){var i;_(null),null===(i=null==c?void 0:c.setActiveEditId)||void 0===i||i.call(c,null)},style:i.__assign(i.__assign({},S),{borderColor:"#E3E8E9",color:"#dc2626"})},{children:e.jsx(u.X,{size:20,strokeWidth:2.5})}))]}):e.jsx("button",i.__assign({title:f?"Save active edits first":"Edit",onClick:function(){var i;(null==c?void 0:c.activeEditId)&&c.activeEditId!==p||(null===(i=null==c?void 0:c.setActiveEditId)||void 0===i||i.call(c,p),_(null!=o?o:""))},disabled:(null==c?void 0:c.isAiStreaming)||f,style:i.__assign(i.__assign({},S),{color:"#6b7280",cursor:(null==c?void 0:c.isAiStreaming)||f?"not-allowed":"pointer",opacity:(null==c?void 0:c.isAiStreaming)||f?.5:1})},{children:e.jsx(u.Pencil,{size:20})}))}))]})),(null==c?void 0:c.pendingEditId)===p&&g&&e.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"6px"}},{children:[e.jsx(u.AlertTriangle,{size:14,style:{color:"#C2410C"}}),e.jsx("div",i.__assign({style:{color:"#C2410C",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]}))},g=function(n){var t=n.children,l=n.onAddVariant,o=n.isDisabled,a=n.showAddVariantBtn,r=void 0===a||a,d=v.default.Children.toArray(t);return e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[d.map(function(i,n){var t=!(n===d.length-1)||r;return e.jsxs(v.default.Fragment,{children:[i,t&&e.jsx("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},n)}),r&&e.jsx("div",i.__assign({onClick:o?void 0:l,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:o?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:o?"not-allowed":"pointer",backgroundColor:o?"#f8fafc":"#FFFFFF",opacity:o?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))};exports.CreateRule=function(c){var f,h,x,_,y,m,S,C,T,I,j,b,A=c.state,E=c.handlers,D=c.uiState,w=(null==D?void 0:D.highlights)||new Map,O=w.get("global_0")||{},R=n.useState({}),V=R[0],W=R[1],N=n.useState(null),k=N[0],L=N[1],z=n.useState(function(){var i,e,n;if((null==D?void 0:D.defaultTierOpen)>=0&&(null===(i=null==D?void 0:D.tierOptions)||void 0===i?void 0:i[D.defaultTierOpen]))return D.tierOptions[D.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=A.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n[0];return t?t.toLowerCase().replace(/ /g,"_"):null});z[0];var F=z[1],B="rule-setup"===(null==D?void 0:D.activeEditId),P=v.default.useRef(new Map),q=n.useState(null),M=q[0],H=q[1],J=n.useState(null),K=J[0],$=J[1],U=n.useState(!1),X=U[0],Z=U[1],G=v.default.useRef(null==D?void 0:D.isAiStreaming);n.useEffect(function(){G.current&&!(null==D?void 0:D.isAiStreaming)&&X&&Z(!1),G.current=null==D?void 0:D.isAiStreaming},[null==D?void 0:D.isAiStreaming,X]);var Q=function(){var i;H(null),$(null),null===(i=null==D?void 0:D.setActiveEditId)||void 0===i||i.call(D,null)},Y=function(){var i,e,n=null!=M?M:A.ruleTitle,t=null!=K?K:A.scopeData,l=n!==A.ruleTitle,o=JSON.stringify(t)!==JSON.stringify(A.scopeData);if(!l&&!o)return H(null),$(null),void(null===(i=null==D?void 0:D.setActiveEditId)||void 0===i||i.call(D,null));if(null==D?void 0:D.setSendMessageInChat){var a="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),r=[];if(l&&r.push((null==n?void 0:n.trim())?"Title with ".concat(n):"No Title"),o){var d=null==t?void 0:t.tiers,s=d&&d.length>0?"tiers: ".concat(d.join(", ")):"No Tier Selected";r.push(s)}var u=r.join(" and ");D.setSendMessageInChat("__SKELETON__:".concat(a,":Update Rule Setup ").concat(u))}Z(!0),H(null),$(null),null===(e=null==D?void 0:D.setActiveEditId)||void 0===e||e.call(D,null)},ii=null!==M?null==M?void 0:M.trim():(A.ruleTitle||"").trim(),ei=null!=K?K:A.scopeData,ni=ii!==(A.ruleTitle||"").trim(),ti=JSON.stringify(ei)!==JSON.stringify(A.scopeData),li=!ni&&!ti||""===ii,oi=v.default.useRef(null==D?void 0:D.defaultVariantOpen),ai=v.default.useRef(null==D?void 0:D.activeVariantAccordionIndex),ri=v.default.useRef(null==D?void 0:D.defaultTierOpen),di=v.default.useRef(null===(f=A.scopeData)||void 0===f?void 0:f.tiers),si=v.default.useRef(A.variantsByTier);v.default.useEffect(function(){var i,e,n,t,l,o,a=null,r=!1;oi.current!==(null==D?void 0:D.defaultVariantOpen)&&(r=!0,oi.current=null==D?void 0:D.defaultVariantOpen),ai.current!==(null==D?void 0:D.activeVariantAccordionIndex)&&(r=!0,ai.current=null==D?void 0:D.activeVariantAccordionIndex),ri.current!==(null==D?void 0:D.defaultTierOpen)&&(r=!0,ri.current=null==D?void 0:D.defaultTierOpen);var d=(null===(i=A.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(di.current)!==JSON.stringify(d)&&(r=!0,di.current=d,d.length>0&&F(d[0].toLowerCase().replace(/ /g,"_")));var s=(null===(e=null==D?void 0:D.tierOptions)||void 0===e?void 0:e.filter(function(i){var e,n;return null===(n=null===(e=A.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||[],u=s.some(function(i){var e,n,t,l,o=i.toLowerCase().replace(/ /g,"_");return((null===(n=null===(e=si.current)||void 0===e?void 0:e[o])||void 0===n?void 0:n.length)||0)!==((null===(l=null===(t=A.variantsByTier)||void 0===t?void 0:t[o])||void 0===l?void 0:l.length)||0)});if(u&&(r=!0),r){var c=null!==(n=null==D?void 0:D.activeVariantAccordionIndex)&&void 0!==n?n:null==D?void 0:D.defaultVariantOpen;if(null==c||c<0)return L(null),void(si.current=A.variantsByTier);s.forEach(function(i,e){var n;if(!((null==D?void 0:D.defaultTierOpen)>=0&&e!==D.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),l=(null===(n=A.variantsByTier)||void 0===n?void 0:n[t])||[];l[c]&&(a="".concat(t,"-variant-").concat(c)),null!=(null==D?void 0:D.autoScrollVariantIndex)&&l[D.autoScrollVariantIndex]&&(a="".concat(t,"-variant-").concat(D.autoScrollVariantIndex))}}),a&&L(a)}if(null===k){var v=null!==(t=null==D?void 0:D.activeVariantAccordionIndex)&&void 0!==t?t:null==D?void 0:D.defaultVariantOpen;null!=v&&v>=0&&(null===(o=null===(l=null==D?void 0:D.tierOptions)||void 0===l?void 0:l.filter(function(i){var e,n;return null===(n=null===(e=A.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===o||o.forEach(function(i,e){var n;if(!((null==D?void 0:D.defaultTierOpen)>=0&&e!==D.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=A.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&L("".concat(t,"-variant-").concat(v))}}))}si.current=A.variantsByTier},[A.variantsByTier,null==D?void 0:D.defaultVariantOpen,null==D?void 0:D.activeVariantAccordionIndex,null===(h=A.scopeData)||void 0===h?void 0:h.tiers,null==D?void 0:D.tierOptions,null==D?void 0:D.autoScrollVariantIndex,null==D?void 0:D.defaultTierOpen]);var ui=function(e){W(function(n){var t;return i.__assign(i.__assign({},n),((t={})[e]=!n[e],t))})},ci=function(i){var e,n,t,l=i.split("_"),o=l[l.length-1],a=/^\d+$/.test(o)?l.slice(0,-1).join("_"):i,r=null===(e=A.fieldCitations)||void 0===e?void 0:e[a];if(Array.isArray(r)&&r.length>0)return r;var d=null===(n=A.fieldCitations)||void 0===n?void 0:n[i];return Array.isArray(d)&&d.length>0?d:null!==(t=A.citations)&&void 0!==t?t:[]},vi={marginTop:"-17px",position:"relative",zIndex:1};n.useEffect(function(){var i,e;null!=(null==D?void 0:D.autoScrollVariantIndex)&&(null===(e=null===(i=null==D?void 0:D.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,n;return null===(n=null===(e=A.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===e||e.forEach(function(i){var e=i.toLowerCase().replace(/ /g,"_"),n="".concat(e,"-variant-").concat(D.autoScrollVariantIndex),t=P.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==D?void 0:D.scrollTrigger]),console.log("CreateRule state:",A),console.log("CreateRule uiState:",D);var pi=function(i){return i?i.replace(/_/g," ").replace(/([a-zA-Z])(\d)/g,"$1 $2").replace(/\b\w/g,function(i){return i.toUpperCase()}):"Variant 1"},gi=!!(null==D?void 0:D.activeEditId);return e.jsxs("div",i.__assign({className:"traffic-manager-template"},{children:[e.jsx("div",i.__assign({"data-edit-id":"rule-setup"},{children:e.jsx(d.default,i.__assign({title:{type:"other",label:(null==D?void 0:D.setupLabel)||"Rule Setup"},actionButtons:function(n,t){if(B)return null;var l=!!(null==D?void 0:D.activeEditId)&&"rule-setup"!==D.activeEditId;return e.jsx("div",i.__assign({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:e.jsx("button",i.__assign({title:l?"Save active edits first":"Edit",onClick:function(e){e.stopPropagation(),l?(null==D?void 0:D.setPendingEditId)&&D.setPendingEditId(D.activeEditId||null):(!function(){var e,n;(null==D?void 0:D.activeEditId)&&"rule-setup"!==D.activeEditId||(null===(e=null==D?void 0:D.setActiveEditId)||void 0===e||e.call(D,"rule-setup"),H(null!==(n=A.ruleTitle)&&void 0!==n?n:""),$(A.scopeData?i.__assign({},A.scopeData):{}))}(),(null==D?void 0:D.setPendingEditId)&&D.setPendingEditId(null),n||t())},disabled:X,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:X?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:X?.5:1}},{children:e.jsx(u.Pencil,{size:14})}))}))},footerData:{ruleTitle:A.ruleTitle,stations:[A.scopeData.station],tiers:null===(x=A.scopeData)||void 0===x?void 0:x.tiers},defaultOpen:"Create"===(null==D?void 0:D.usedFor),readOnly:"Create"!==(null==D?void 0:D.usedFor),isAiStreaming:null==D?void 0:D.isAiStreaming,editFlow:"Edit"===(null==D?void 0:D.usedFor)},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[X&&(null==D?void 0:D.isAiStreaming)&&e.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[e.jsx(u.Loader2Icon,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),e.jsx(r.TextSection,i.__assign({id:"rule-title",title:D.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:B&&null!==M?M:A.ruleTitle,onChange:function(i){return B?H(i):E.setRuleTitle(i)},readOnly:(null==D?void 0:D.isAiStreaming)||!B,isOpen:V.ruleTitle,onToggle:function(){return ui("ruleTitle")},isHighlighted:O.ruleTitle||!1,showCognitiveIcon:A.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(_=D.validationErrors)||void 0===_?void 0:_.ruleTitle},D)),A.citation.ruleTitle&&e.jsx("div",i.__assign({style:vi},{children:e.jsx(t.InputDataReasoningCard,{isVisible:V.ruleTitle,citation:A.citation.ruleTitle,citations:ci("ruleTitle"),fieldName:"Rule Title",fieldValue:A.ruleTitle})})),(null===(y=null==D?void 0:D.tierOptions)||void 0===y?void 0:y.length)>1&&e.jsx(a.ScopeSection,i.__assign({id:"scope",title:"",required:!1,scopeData:B&&null!==K?K:A.scopeData,onScopeChange:function(e,n){B?$(function(t){var l;return i.__assign(i.__assign({},null!=t?t:A.scopeData),((l={})[e]=n,l))}):E.onScopeChange(e,n)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:O,isOpen:V.scopeData,onToggle:function(){return ui("scopeData")},showCognitiveIcon:A.citation.scopeData,cognitiveIcon:e.jsx(s.ButtonCognitiveIcon,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(m=D.validationErrors)||void 0===m?void 0:m.station)||(null===(S=D.validationErrors)||void 0===S?void 0:S.tiers),stationErrorMessage:null===(C=D.validationErrors)||void 0===C?void 0:C.station,tierErrorMessage:null===(T=D.validationErrors)||void 0===T?void 0:T.tiers,readOnly:(null==D?void 0:D.isAiStreaming)||!B},D)),A.citation.scopeData&&e.jsx("div",i.__assign({style:vi},{children:e.jsx(t.InputDataReasoningCard,{isVisible:V.scopeData,citation:A.citation.scopeData,citations:ci("scopeData"),fieldName:"Scope",fieldValue:null===(j=null===(I=A.scopeData)||void 0===I?void 0:I.tiers)||void 0===j?void 0:j.join(", ")})})),B?e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e.jsxs("div",i.__assign({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[e.jsx("button",i.__assign({onClick:Q,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e.jsxs("button",i.__assign({onClick:Y,disabled:li,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:li?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:li?.5:1}},{children:[e.jsx(u.Check,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==D?void 0:D.pendingEditId)&&e.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"10px"}},{children:[e.jsx(u.AlertTriangle,{size:14,style:{color:"#C2410C"}}),e.jsx("div",i.__assign({style:{color:"#C2410C",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]})):null]}))}))})),(!(null==D?void 0:D.tierOptions)||0===D.tierOptions.length)&&e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",padding:"32px 16px",marginTop:"8px",backgroundColor:"#FAFAFA",border:"1px dashed #E2E8F0",borderRadius:"12px",color:"#94a3b8"}},{children:[e.jsx(u.AlertTriangle,{size:20,style:{color:"#94a3b8"}}),e.jsx("span",i.__assign({style:{fontSize:"13px",fontWeight:500,color:"#64748b"}},{children:"No tiers found"}))]})),null===(b=null==D?void 0:D.tierOptions)||void 0===b?void 0:b.map(function(n,a){var s,u,c,f,h,x,_,y=n.toLowerCase().replace(/ /g,"_"),m=(null===(s=A.variantsByTier)||void 0===s?void 0:s[y])||[],S=null===(c=null===(u=A.scopeData)||void 0===u?void 0:u.tiers)||void 0===c?void 0:c.includes(n),C=m.length,T=!1;if(1===C){var I=m[0],j=!(null===(f=null==I?void 0:I.ruleDescription)||void 0===f?void 0:f.trim()),b=(null===(h=null==I?void 0:I.whenToApplyConditions)||void 0===h?void 0:h.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,O=(null===(x=null==I?void 0:I.whenNotToApplyConditions)||void 0===x?void 0:x.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!j||b||O||(T=!0)}var R=T?void 0:"".concat(C," ").concat(1===C?"variant":"variants"," configured for this tier"),W=e.jsx(g,i.__assign({onAddVariant:function(){var i;return null===(i=E.addNewVariant)||void 0===i?void 0:i.call(E,y)},isDisabled:!S||(null==D?void 0:D.isAiStreaming),showAddVariantBtn:"Edit"!==(null==D?void 0:D.usedFor)},{children:m.map(function(n,a){var s,u,c,v,g,f,h,x,_,m,C,T=n.variantType||"default",I="".concat(y,"-variant-").concat(a),j=!0===n.is_variant,b="default"===T||"default_variant"===T,O="".concat(y,"_").concat(a),R=w.get(O)||{},W=(null===(u=null===(s=D.separationItemsByTier)||void 0===s?void 0:s[y])||void 0===u?void 0:u.get(a))||[],N=(null===(v=null===(c=D.togglesByTier)||void 0===c?void 0:c[y])||void 0===v?void 0:v.get(a))||[],z=null===(g=null==D?void 0:D.activeEditId)||void 0===g?void 0:g.startsWith("condition-wta-".concat(y,"-").concat(a)),F=null===(f=null==D?void 0:D.activeEditId)||void 0===f?void 0:f.startsWith("condition-wnta-".concat(y,"-").concat(a)),B=!S||n.isReadOnly||(null==D?void 0:D.isAiStreaming);return e.jsx("div",i.__assign({ref:function(i){i?P.current.set(I,i):P.current.delete(I)},style:{width:"100%",opacity:S?1:.7}},{children:e.jsx(d.default,i.__assign({title:{type:b?"default":"variant",label:pi(T),number:a+1,isNewVariant:j,isDefault:n.isDefault,isModified:n.isModified},defaultOpen:!0,expanded:k===I,onToggle:function(){var i,e=k===I;L(e?null:I),null===(i=null==D?void 0:D.setActiveVariantAccordionIndex)||void 0===i||i.call(D,e?null:a)},variant:"rule-behavior",footerData:{ruleTitle:T,description:n.ruleDescription||""},readOnly:B},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[e.jsx(r.TextSection,i.__assign({id:"rule-description-".concat(y,"-").concat(a),title:D.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:B||gi&&(null==D?void 0:D.activeEditId)!=="rule-description-".concat(y,"-").concat(a),value:n.ruleDescription||"",onChange:function(i){return E.setRuleDescription(y,a,i)},isOpen:V["ruleDescription-".concat(y)],onToggle:function(){return ui("ruleDescription-".concat(y))},isHighlighted:R.ruleDescription||!1,showCognitiveIcon:null===(h=A.citation)||void 0===h?void 0:h["ruleDescription_".concat(y)],tooltipDescription:"Why this Description?",errorMessage:null===(x=D.validationErrors)||void 0===x?void 0:x["ruleDescription-".concat(y,"-").concat(a)],enableInlineEdit:!0,setSendMessageInChat:null==D?void 0:D.setSendMessageInChat,isAiStreaming:null==D?void 0:D.isAiStreaming,fieldName:"Rule Description"},D)),(null===(_=A.citation)||void 0===_?void 0:_["ruleDescription_".concat(y)])&&e.jsx("div",i.__assign({style:vi},{children:e.jsx(t.InputDataReasoningCard,{isVisible:V["ruleDescription-".concat(y)],citation:A.citation["ruleDescription_".concat(y)],citations:ci("ruleDescription_".concat(y,"_").concat(a)),fieldName:"Rule Description",fieldValue:n.ruleDescription})})),(null==D?void 0:D.LazyPromptEditor)&&e.jsx(p,{LazyPromptEditor:D.LazyPromptEditor,value:null!==(m=n.instructionPrompt)&&void 0!==m?m:D.instructionPrompt,onChange:D.setInstructionPrompt,title:D.instructionPromptTitle,tierKey:y,variantIndex:a,uiState:i.__assign(i.__assign({},D),{isEffectivelyReadOnly:B}),isHighlighted:R.instruction_prompt||!1}),e.jsx(l.ConditionSection,i.__assign({id:"when-to-apply-".concat(y,"-").concat(a),idPrefix:"condition-wta",title:D.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:B||gi&&!z,conditions:n.whenToApplyConditions||[],onAdd:function(){return E.addWhenToApply(y,a)},onRemove:function(i,e,n){return E.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return E.editWhenToApply(i,e,n,t)},index:a,tierKey:y,isHighlighted:R.wta||!1,highlightedIds:null==D?void 0:D.highlightedIds,tooltipDescription:"Why this Condition?",citations:ci("whenToApply_".concat(y,"_").concat(a)),bordered:!0,addLabel:(null==D?void 0:D.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:D.isAiStreaming,errorMessage:(null===(C=D.validationErrors)||void 0===C?void 0:C["whenToApply-".concat(y,"-").concat(a)])||(null==D?void 0:D.conflictReason)},D)),e.jsx(l.ConditionSection,i.__assign({id:"when-not-to-apply-".concat(y,"-").concat(a),idPrefix:"condition-wnta",title:D.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:B||gi&&!F,conditions:n.whenNotToApplyConditions||[],onAdd:function(){return E.addWhenNotToApply(y,a)},onRemove:function(i,e,n){return E.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return E.editWhenNotToApply(i,e,n,t)},index:a,tierKey:y,isHighlighted:R.wnta||!1,highlightedIds:null==D?void 0:D.highlightedIds,tooltipDescription:"Why this Condition?",citations:ci("whenNotToApply_".concat(y,"_").concat(a)),bordered:!0,addLabel:(null==D?void 0:D.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:D.isAiStreaming},D)),(null==D?void 0:D.showConfiguration)&&e.jsx(o.ConfigSection,i.__assign({id:"config-".concat(y,"-").concat(a),title:D.configTitle||"Configuration",required:!1,highlights:R,bordered:!0,readOnly:B||gi&&(null==D?void 0:D.activeEditId)!=="config-".concat(y,"-").concat(a),onConfigChange:function(i,e){return E.onConfigChange(y,a,i,e)},separationItems:W,toggles:N,index:a},D))]}))}),I)}),"".concat(y,"-variant-").concat(a))})}));return 1===(null===(_=null==D?void 0:D.tierOptions)||void 0===_?void 0:_.length)?e.jsx(v.default.Fragment,{children:W},"tier-".concat(a)):e.jsx(d.default,i.__assign({variant:"tier-header",title:{type:"other",label:n},subtitle:R,defaultOpen:!0,footerData:{description:"Variants for ".concat(n)}},{children:W}),"tier-".concat(a))})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),e=require("react/jsx-runtime"),n=require("react"),t=require("../../InputDataReasoningCard.js"),l=require("../../organisms/ConditionSection/ConditionSection.js"),o=require("../../organisms/ConfigSection/ConfigSection.js"),a=require("../../organisms/ScopeSection/ScopeSection.js"),r=require("../../organisms/TextSection/TextSection.js"),d=require("../../AccordianSection.js"),s=require("../../_svg/ButtonCognitiveIcon.js"),u=require("lucide-react");function c(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var v=c(n),p=function(t){var l=t.LazyPromptEditor,o=t.value,a=t.onChange,r=t.title,d=t.tierKey,s=t.variantIndex,c=t.uiState,p=t.isHighlighted,g="instruction-prompt-".concat(d,"-").concat(s),f=(null==c?void 0:c.activeEditId)===g,h=!!(null==c?void 0:c.activeEditId)&&c.activeEditId!==g,x=n.useState(null),y=x[0],_=x[1],m=v.default.useRef(null);n.useEffect(function(){var i=m.current;if(i){var e=function(e){if(!f){var n=e.target;n&&i.contains(n)&&n.blur()}};return i.addEventListener("focusin",e),function(){return i.removeEventListener("focusin",e)}}},[f]);var S=(null==y?void 0:y.trim())||"",C=S===((null==o?void 0:o.trim())||"")||null!==y&&""===S,T={display:"flex",alignItems:"center",justifyContent:"center",padding:"8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:"pointer",width:"36px",height:"36px",backgroundColor:"#ffffff"},j={cursor:C?"not-allowed":"pointer",opacity:C?.5:1};return e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"4px",width:"100%",marginBottom:"12px",margin:"0 0.2rem"},"data-edit-id":g},{children:[e.jsx("div",i.__assign({style:{display:"flex",alignItems:"center",width:"100%",justifyContent:"space-between",marginBottom:"4px"}},{children:e.jsx("span",i.__assign({style:{fontSize:"14px",fontWeight:500,color:"#19213D",fontFamily:'"Plus Jakarta Sans", sans-serif'}},{children:r}))})),e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"8px",width:"100%"}},{children:[!(null==c?void 0:c.isEffectivelyReadOnly)&&e.jsx("div",i.__assign({style:{display:"flex",flexDirection:"row",gap:"8px",justifyContent:"flex-end"}},{children:f?e.jsxs(e.Fragment,{children:[e.jsxs("button",i.__assign({title:"Apply",onClick:function(){var i,e;if(null!==y){if(y===(null!=o?o:""))return _(null),void(null===(i=null==c?void 0:c.setActiveEditId)||void 0===i||i.call(c,null));if(null==a||a(y),null==c?void 0:c.setSendMessageInChat){var n="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8));c.setSendMessageInChat("__SKELETON__:".concat(n,":The Instruction Prompt has been updated through the Learning Form"))}_(null),null===(e=null==c?void 0:c.setActiveEditId)||void 0===e||e.call(c,null)}},disabled:C,style:i.__assign(i.__assign(i.__assign({},T),j),{backgroundColor:"#2563EB",color:"white",width:"auto",padding:"8px 12px"})},{children:[e.jsx(u.Check,{size:20,strokeWidth:2.5})," Apply"]})),e.jsx("button",i.__assign({title:"Cancel",onClick:function(){var i;_(null),null===(i=null==c?void 0:c.setActiveEditId)||void 0===i||i.call(c,null)},style:i.__assign(i.__assign({},T),{borderColor:"#E3E8E9",color:"#dc2626"})},{children:e.jsx(u.X,{size:20,strokeWidth:2.5})}))]}):e.jsx("button",i.__assign({title:h?"Save active edits first":"Edit",onClick:function(){var i;(null==c?void 0:c.activeEditId)&&c.activeEditId!==g||(null===(i=null==c?void 0:c.setActiveEditId)||void 0===i||i.call(c,g),_(null!=o?o:""))},disabled:(null==c?void 0:c.isAiStreaming)||h,style:i.__assign(i.__assign({},T),{color:"#6b7280",cursor:(null==c?void 0:c.isAiStreaming)||h?"not-allowed":"pointer",opacity:(null==c?void 0:c.isAiStreaming)||h?.5:1})},{children:e.jsx(u.Pencil,{size:20})}))})),e.jsx("div",i.__assign({style:{width:"100%",minWidth:0,border:p?"1px solid #2563EB":"none",borderRadius:"8px",boxShadow:p?"0 0 12px 3px rgba(37, 99, 235, 0.3)":"none",transition:"all 0.3s"}},{children:e.jsx(n.Suspense,i.__assign({fallback:e.jsx("div",i.__assign({style:{padding:"12px",fontSize:"13px",color:"#6b7280"}},{children:"Loading editor..."}))},{children:e.jsx("div",i.__assign({ref:m,style:{pointerEvents:f?"auto":"none",opacity:f?1:.75},onKeyDownCapture:function(i){f||(i.preventDefault(),i.stopPropagation())}},{children:e.jsx(l,{value:f&&null!==y?y:o,onChange:function(i){f?_(i):a&&a(i)},title:r,minHeight:"220px",maxHeight:"400px"})}))}))}))]})),(null==c?void 0:c.pendingEditId)===g&&f&&e.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"6px"}},{children:[e.jsx(u.AlertTriangle,{size:14,style:{color:"#C2410C"}}),e.jsx("div",i.__assign({style:{color:"#C2410C",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]}))},g=function(n){var t=n.children,l=n.onAddVariant,o=n.isDisabled,a=n.showAddVariantBtn,r=void 0===a||a,d=v.default.Children.toArray(t);return e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[d.map(function(i,n){var t=!(n===d.length-1)||r;return e.jsxs(v.default.Fragment,{children:[i,t&&e.jsx("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},n)}),r&&e.jsx("div",i.__assign({onClick:o?void 0:l,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:o?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:o?"not-allowed":"pointer",backgroundColor:o?"#f8fafc":"#FFFFFF",opacity:o?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))};exports.CreateRule=function(c){var f,h,x,y,_,m,S,C,T,j,I,b,A=c.state,E=c.handlers,D=c.uiState,w=(null==D?void 0:D.highlights)||new Map,O=w.get("global_0")||{},R=n.useState({}),V=R[0],W=R[1],L=n.useState(null),N=L[0],k=L[1],z=n.useState(function(){var i,e,n;if((null==D?void 0:D.defaultTierOpen)>=0&&(null===(i=null==D?void 0:D.tierOptions)||void 0===i?void 0:i[D.defaultTierOpen]))return D.tierOptions[D.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=A.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n[0];return t?t.toLowerCase().replace(/ /g,"_"):null});z[0];var F=z[1],P="rule-setup"===(null==D?void 0:D.activeEditId),B=v.default.useRef(new Map),q=n.useState(null),M=q[0],H=q[1],J=n.useState(null),K=J[0],$=J[1],U=n.useState(!1),X=U[0],Z=U[1],G=v.default.useRef(null==D?void 0:D.isAiStreaming);n.useEffect(function(){G.current&&!(null==D?void 0:D.isAiStreaming)&&X&&Z(!1),G.current=null==D?void 0:D.isAiStreaming},[null==D?void 0:D.isAiStreaming,X]);var Q=function(){var i;H(null),$(null),null===(i=null==D?void 0:D.setActiveEditId)||void 0===i||i.call(D,null)},Y=function(){var i,e,n=null!=M?M:A.ruleTitle,t=null!=K?K:A.scopeData,l=n!==A.ruleTitle,o=JSON.stringify(t)!==JSON.stringify(A.scopeData);if(!l&&!o)return H(null),$(null),void(null===(i=null==D?void 0:D.setActiveEditId)||void 0===i||i.call(D,null));if(null==D?void 0:D.setSendMessageInChat){var a="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),r=[];if(l&&r.push((null==n?void 0:n.trim())?"Title with ".concat(n):"No Title"),o){var d=null==t?void 0:t.tiers,s=d&&d.length>0?"tiers: ".concat(d.join(", ")):"No Tier Selected";r.push(s)}var u=r.join(" and ");D.setSendMessageInChat("__SKELETON__:".concat(a,":Update Rule Setup ").concat(u))}Z(!0),H(null),$(null),null===(e=null==D?void 0:D.setActiveEditId)||void 0===e||e.call(D,null)},ii=null!==M?null==M?void 0:M.trim():(A.ruleTitle||"").trim(),ei=null!=K?K:A.scopeData,ni=ii!==(A.ruleTitle||"").trim(),ti=JSON.stringify(ei)!==JSON.stringify(A.scopeData),li=!ni&&!ti||""===ii,oi=v.default.useRef(null==D?void 0:D.defaultVariantOpen),ai=v.default.useRef(null==D?void 0:D.activeVariantAccordionIndex),ri=v.default.useRef(null==D?void 0:D.defaultTierOpen),di=v.default.useRef(null===(f=A.scopeData)||void 0===f?void 0:f.tiers),si=v.default.useRef(A.variantsByTier);v.default.useEffect(function(){var i,e,n,t,l,o,a=null,r=!1;oi.current!==(null==D?void 0:D.defaultVariantOpen)&&(r=!0,oi.current=null==D?void 0:D.defaultVariantOpen),ai.current!==(null==D?void 0:D.activeVariantAccordionIndex)&&(r=!0,ai.current=null==D?void 0:D.activeVariantAccordionIndex),ri.current!==(null==D?void 0:D.defaultTierOpen)&&(r=!0,ri.current=null==D?void 0:D.defaultTierOpen);var d=(null===(i=A.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(di.current)!==JSON.stringify(d)&&(r=!0,di.current=d,d.length>0&&F(d[0].toLowerCase().replace(/ /g,"_")));var s=(null===(e=null==D?void 0:D.tierOptions)||void 0===e?void 0:e.filter(function(i){var e,n;return null===(n=null===(e=A.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||[],u=s.some(function(i){var e,n,t,l,o=i.toLowerCase().replace(/ /g,"_");return((null===(n=null===(e=si.current)||void 0===e?void 0:e[o])||void 0===n?void 0:n.length)||0)!==((null===(l=null===(t=A.variantsByTier)||void 0===t?void 0:t[o])||void 0===l?void 0:l.length)||0)});if(u&&(r=!0),r){var c=null!==(n=null==D?void 0:D.activeVariantAccordionIndex)&&void 0!==n?n:null==D?void 0:D.defaultVariantOpen;if(null==c||c<0)return k(null),void(si.current=A.variantsByTier);s.forEach(function(i,e){var n;if(!((null==D?void 0:D.defaultTierOpen)>=0&&e!==D.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),l=(null===(n=A.variantsByTier)||void 0===n?void 0:n[t])||[];l[c]&&(a="".concat(t,"-variant-").concat(c)),null!=(null==D?void 0:D.autoScrollVariantIndex)&&l[D.autoScrollVariantIndex]&&(a="".concat(t,"-variant-").concat(D.autoScrollVariantIndex))}}),a&&k(a)}if(null===N){var v=null!==(t=null==D?void 0:D.activeVariantAccordionIndex)&&void 0!==t?t:null==D?void 0:D.defaultVariantOpen;null!=v&&v>=0&&(null===(o=null===(l=null==D?void 0:D.tierOptions)||void 0===l?void 0:l.filter(function(i){var e,n;return null===(n=null===(e=A.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===o||o.forEach(function(i,e){var n;if(!((null==D?void 0:D.defaultTierOpen)>=0&&e!==D.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=A.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&k("".concat(t,"-variant-").concat(v))}}))}si.current=A.variantsByTier},[A.variantsByTier,null==D?void 0:D.defaultVariantOpen,null==D?void 0:D.activeVariantAccordionIndex,null===(h=A.scopeData)||void 0===h?void 0:h.tiers,null==D?void 0:D.tierOptions,null==D?void 0:D.autoScrollVariantIndex,null==D?void 0:D.defaultTierOpen]);var ui=function(e){W(function(n){var t;return i.__assign(i.__assign({},n),((t={})[e]=!n[e],t))})},ci=function(i){var e,n,t,l=i.split("_"),o=l[l.length-1],a=/^\d+$/.test(o)?l.slice(0,-1).join("_"):i,r=null===(e=A.fieldCitations)||void 0===e?void 0:e[a];if(Array.isArray(r)&&r.length>0)return r;var d=null===(n=A.fieldCitations)||void 0===n?void 0:n[i];return Array.isArray(d)&&d.length>0?d:null!==(t=A.citations)&&void 0!==t?t:[]},vi={marginTop:"-17px",position:"relative",zIndex:1};n.useEffect(function(){var i,e;null!=(null==D?void 0:D.autoScrollVariantIndex)&&(null===(e=null===(i=null==D?void 0:D.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,n;return null===(n=null===(e=A.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===e||e.forEach(function(i){var e=i.toLowerCase().replace(/ /g,"_"),n="".concat(e,"-variant-").concat(D.autoScrollVariantIndex),t=B.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==D?void 0:D.scrollTrigger]),console.log("CreateRule state:",A),console.log("CreateRule uiState:",D);var pi=function(i){return i?i.replace(/_/g," ").replace(/([a-zA-Z])(\d)/g,"$1 $2").replace(/\b\w/g,function(i){return i.toUpperCase()}):"Variant 1"},gi=!!(null==D?void 0:D.activeEditId);return e.jsxs("div",i.__assign({className:"traffic-manager-template"},{children:[e.jsx("div",i.__assign({"data-edit-id":"rule-setup"},{children:e.jsx(d.default,i.__assign({title:{type:"other",label:(null==D?void 0:D.setupLabel)||"Rule Setup"},actionButtons:function(n,t){if(P)return null;var l=!!(null==D?void 0:D.activeEditId)&&"rule-setup"!==D.activeEditId;return e.jsx("div",i.__assign({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:e.jsx("button",i.__assign({title:l?"Save active edits first":"Edit",onClick:function(e){e.stopPropagation(),l?(null==D?void 0:D.setPendingEditId)&&D.setPendingEditId(D.activeEditId||null):(!function(){var e,n;(null==D?void 0:D.activeEditId)&&"rule-setup"!==D.activeEditId||(null===(e=null==D?void 0:D.setActiveEditId)||void 0===e||e.call(D,"rule-setup"),H(null!==(n=A.ruleTitle)&&void 0!==n?n:""),$(A.scopeData?i.__assign({},A.scopeData):{}))}(),(null==D?void 0:D.setPendingEditId)&&D.setPendingEditId(null),n||t())},disabled:X,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:X?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:X?.5:1}},{children:e.jsx(u.Pencil,{size:14})}))}))},footerData:{ruleTitle:A.ruleTitle,stations:[A.scopeData.station],tiers:null===(x=A.scopeData)||void 0===x?void 0:x.tiers},defaultOpen:"Create"===(null==D?void 0:D.usedFor),readOnly:"Create"!==(null==D?void 0:D.usedFor),isAiStreaming:null==D?void 0:D.isAiStreaming,editFlow:"Edit"===(null==D?void 0:D.usedFor)},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[X&&(null==D?void 0:D.isAiStreaming)&&e.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[e.jsx(u.Loader2Icon,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),e.jsx(r.TextSection,i.__assign({id:"rule-title",title:D.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:P&&null!==M?M:A.ruleTitle,onChange:function(i){return P?H(i):E.setRuleTitle(i)},readOnly:(null==D?void 0:D.isAiStreaming)||!P,isOpen:V.ruleTitle,onToggle:function(){return ui("ruleTitle")},isHighlighted:O.ruleTitle||!1,showCognitiveIcon:A.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(y=D.validationErrors)||void 0===y?void 0:y.ruleTitle},D)),A.citation.ruleTitle&&e.jsx("div",i.__assign({style:vi},{children:e.jsx(t.InputDataReasoningCard,{isVisible:V.ruleTitle,citation:A.citation.ruleTitle,citations:ci("ruleTitle"),fieldName:"Rule Title",fieldValue:A.ruleTitle})})),(null===(_=null==D?void 0:D.tierOptions)||void 0===_?void 0:_.length)>1&&e.jsx(a.ScopeSection,i.__assign({id:"scope",title:"",required:!1,scopeData:P&&null!==K?K:A.scopeData,onScopeChange:function(e,n){P?$(function(t){var l;return i.__assign(i.__assign({},null!=t?t:A.scopeData),((l={})[e]=n,l))}):E.onScopeChange(e,n)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:O,isOpen:V.scopeData,onToggle:function(){return ui("scopeData")},showCognitiveIcon:A.citation.scopeData,cognitiveIcon:e.jsx(s.ButtonCognitiveIcon,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(m=D.validationErrors)||void 0===m?void 0:m.station)||(null===(S=D.validationErrors)||void 0===S?void 0:S.tiers),stationErrorMessage:null===(C=D.validationErrors)||void 0===C?void 0:C.station,tierErrorMessage:null===(T=D.validationErrors)||void 0===T?void 0:T.tiers,readOnly:(null==D?void 0:D.isAiStreaming)||!P},D)),A.citation.scopeData&&e.jsx("div",i.__assign({style:vi},{children:e.jsx(t.InputDataReasoningCard,{isVisible:V.scopeData,citation:A.citation.scopeData,citations:ci("scopeData"),fieldName:"Scope",fieldValue:null===(I=null===(j=A.scopeData)||void 0===j?void 0:j.tiers)||void 0===I?void 0:I.join(", ")})})),P?e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e.jsxs("div",i.__assign({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[e.jsx("button",i.__assign({onClick:Q,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e.jsxs("button",i.__assign({onClick:Y,disabled:li,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:li?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:li?.5:1}},{children:[e.jsx(u.Check,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==D?void 0:D.pendingEditId)&&e.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"10px"}},{children:[e.jsx(u.AlertTriangle,{size:14,style:{color:"#C2410C"}}),e.jsx("div",i.__assign({style:{color:"#C2410C",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]})):null]}))}))})),(!(null==D?void 0:D.tierOptions)||0===D.tierOptions.length)&&e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",padding:"32px 16px",marginTop:"8px",backgroundColor:"#FAFAFA",border:"1px dashed #E2E8F0",borderRadius:"12px",color:"#94a3b8"}},{children:[e.jsx(u.AlertTriangle,{size:20,style:{color:"#94a3b8"}}),e.jsx("span",i.__assign({style:{fontSize:"13px",fontWeight:500,color:"#64748b"}},{children:"No tiers found"}))]})),null===(b=null==D?void 0:D.tierOptions)||void 0===b?void 0:b.map(function(n,a){var s,u,c,f,h,x,y,_=n.toLowerCase().replace(/ /g,"_"),m=(null===(s=A.variantsByTier)||void 0===s?void 0:s[_])||[],S=null===(c=null===(u=A.scopeData)||void 0===u?void 0:u.tiers)||void 0===c?void 0:c.includes(n),C=m.length,T=!1;if(1===C){var j=m[0],I=!(null===(f=null==j?void 0:j.ruleDescription)||void 0===f?void 0:f.trim()),b=(null===(h=null==j?void 0:j.whenToApplyConditions)||void 0===h?void 0:h.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,O=(null===(x=null==j?void 0:j.whenNotToApplyConditions)||void 0===x?void 0:x.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!I||b||O||(T=!0)}var R=T?void 0:"".concat(C," ").concat(1===C?"variant":"variants"," configured for this tier"),W=e.jsx(g,i.__assign({onAddVariant:function(){var i;return null===(i=E.addNewVariant)||void 0===i?void 0:i.call(E,_)},isDisabled:!S||(null==D?void 0:D.isAiStreaming),showAddVariantBtn:"Edit"!==(null==D?void 0:D.usedFor)},{children:m.map(function(n,a){var s,u,c,v,g,f,h,x,y,m,C,T=n.variantType||"default",j="".concat(_,"-variant-").concat(a),I=!0===n.is_variant,b="default"===T||"default_variant"===T,O="".concat(_,"_").concat(a),R=w.get(O)||{},W=(null===(u=null===(s=D.separationItemsByTier)||void 0===s?void 0:s[_])||void 0===u?void 0:u.get(a))||[],L=(null===(v=null===(c=D.togglesByTier)||void 0===c?void 0:c[_])||void 0===v?void 0:v.get(a))||[],z=null===(g=null==D?void 0:D.activeEditId)||void 0===g?void 0:g.startsWith("condition-wta-".concat(_,"-").concat(a)),F=null===(f=null==D?void 0:D.activeEditId)||void 0===f?void 0:f.startsWith("condition-wnta-".concat(_,"-").concat(a)),P=!S||n.isReadOnly||(null==D?void 0:D.isAiStreaming);return e.jsx("div",i.__assign({ref:function(i){i?B.current.set(j,i):B.current.delete(j)},style:{width:"100%",opacity:S?1:.7}},{children:e.jsx(d.default,i.__assign({title:{type:b?"default":"variant",label:pi(T),number:a+1,isNewVariant:I,isDefault:n.isDefault,isModified:n.isModified},defaultOpen:!0,expanded:N===j,onToggle:function(){var i,e=N===j;k(e?null:j),null===(i=null==D?void 0:D.setActiveVariantAccordionIndex)||void 0===i||i.call(D,e?null:a)},variant:"rule-behavior",footerData:{ruleTitle:T,description:n.ruleDescription||""},readOnly:P},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[e.jsx(r.TextSection,i.__assign({id:"rule-description-".concat(_,"-").concat(a),title:D.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:P||gi&&(null==D?void 0:D.activeEditId)!=="rule-description-".concat(_,"-").concat(a),value:n.ruleDescription||"",onChange:function(i){return E.setRuleDescription(_,a,i)},isOpen:V["ruleDescription-".concat(_)],onToggle:function(){return ui("ruleDescription-".concat(_))},isHighlighted:R.ruleDescription||!1,showCognitiveIcon:null===(h=A.citation)||void 0===h?void 0:h["ruleDescription_".concat(_)],tooltipDescription:"Why this Description?",errorMessage:null===(x=D.validationErrors)||void 0===x?void 0:x["ruleDescription-".concat(_,"-").concat(a)],enableInlineEdit:!0,setSendMessageInChat:null==D?void 0:D.setSendMessageInChat,isAiStreaming:null==D?void 0:D.isAiStreaming,fieldName:"Rule Description"},D)),(null===(y=A.citation)||void 0===y?void 0:y["ruleDescription_".concat(_)])&&e.jsx("div",i.__assign({style:vi},{children:e.jsx(t.InputDataReasoningCard,{isVisible:V["ruleDescription-".concat(_)],citation:A.citation["ruleDescription_".concat(_)],citations:ci("ruleDescription_".concat(_,"_").concat(a)),fieldName:"Rule Description",fieldValue:n.ruleDescription})})),(null==D?void 0:D.LazyPromptEditor)&&e.jsx(p,{LazyPromptEditor:D.LazyPromptEditor,value:null!==(m=n.instructionPrompt)&&void 0!==m?m:D.instructionPrompt,onChange:D.setInstructionPrompt,title:D.instructionPromptTitle,tierKey:_,variantIndex:a,uiState:i.__assign(i.__assign({},D),{isEffectivelyReadOnly:P}),isHighlighted:R.instruction_prompt||!1}),e.jsx(l.ConditionSection,i.__assign({id:"when-to-apply-".concat(_,"-").concat(a),idPrefix:"condition-wta",title:D.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:P||gi&&!z,conditions:n.whenToApplyConditions||[],onAdd:function(){return E.addWhenToApply(_,a)},onRemove:function(i,e,n){return E.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return E.editWhenToApply(i,e,n,t)},index:a,tierKey:_,isHighlighted:R.wta||!1,highlightedIds:null==D?void 0:D.highlightedIds,tooltipDescription:"Why this Condition?",citations:ci("whenToApply_".concat(_,"_").concat(a)),bordered:!0,addLabel:(null==D?void 0:D.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:D.isAiStreaming,errorMessage:(null===(C=D.validationErrors)||void 0===C?void 0:C["whenToApply-".concat(_,"-").concat(a)])||(null==D?void 0:D.conflictReason)},D)),e.jsx(l.ConditionSection,i.__assign({id:"when-not-to-apply-".concat(_,"-").concat(a),idPrefix:"condition-wnta",title:D.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:P||gi&&!F,conditions:n.whenNotToApplyConditions||[],onAdd:function(){return E.addWhenNotToApply(_,a)},onRemove:function(i,e,n){return E.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return E.editWhenNotToApply(i,e,n,t)},index:a,tierKey:_,isHighlighted:R.wnta||!1,highlightedIds:null==D?void 0:D.highlightedIds,tooltipDescription:"Why this Condition?",citations:ci("whenNotToApply_".concat(_,"_").concat(a)),bordered:!0,addLabel:(null==D?void 0:D.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:D.isAiStreaming},D)),(null==D?void 0:D.showConfiguration)&&e.jsx(o.ConfigSection,i.__assign({id:"config-".concat(_,"-").concat(a),title:D.configTitle||"Configuration",required:!1,highlights:R,bordered:!0,readOnly:P||gi&&(null==D?void 0:D.activeEditId)!=="config-".concat(_,"-").concat(a),onConfigChange:function(i,e){return E.onConfigChange(_,a,i,e)},separationItems:W,toggles:L,index:a},D))]}))}),j)}),"".concat(_,"-variant-").concat(a))})}));return 1===(null===(y=null==D?void 0:D.tierOptions)||void 0===y?void 0:y.length)?e.jsx(v.default.Fragment,{children:W},"tier-".concat(a)):e.jsx(d.default,i.__assign({variant:"tier-header",title:{type:"other",label:n},subtitle:R,defaultOpen:!0,footerData:{description:"Variants for ".concat(n)}},{children:W}),"tier-".concat(a))})]}))};
2
2
  //# sourceMappingURL=CreateRule.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),i=require("lucide-react"),s=require("./Cart.styles.js");function a(e){try{var t=new Date(e),n=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),i=t.toLocaleDateString("en-GB").replace(/\//g,"/");return"Added on - ".concat(n," | ").concat(i)}catch(t){return e}}function r(r){var l,d=r.items,c=r.onRemove,u=r.onProceed,o=n.useState(null),_=o[0],f=o[1];var g=null!==(l=d.find(function(e){return e.instant_learning_id===_}))&&void 0!==l?l:null;return t.jsxs("section",e.__assign({style:s.default.cartSection},{children:[t.jsxs("div",e.__assign({style:s.default.cartHeaderRow},{children:[t.jsx("p",e.__assign({style:s.default.cartTitle},{children:"Guideline Cart"})),t.jsxs("span",e.__assign({style:s.default.cartBadge},{children:[d.length," Added"]}))]})),t.jsx("p",e.__assign({style:s.default.cartDescription},{children:"Click an item to select it for this session"})),t.jsx("div",e.__assign({style:s.default.cartBody},{children:t.jsx("div",e.__assign({style:s.default.cartList},{children:0===d.length?t.jsx("div",e.__assign({style:s.default.emptyState},{children:"No guidelines added yet"})):d.map(function(n){var r=n.instant_learning_id===_;return t.jsxs("div",e.__assign({style:r?s.default.cartItemSelected:s.default.cartItem,onClick:function(){return e=n.instant_learning_id,void f(function(t){return t===e?null:e});var e}},{children:[t.jsxs("div",e.__assign({style:s.default.cartItemTop},{children:[t.jsxs("div",e.__assign({style:s.default.cartItemTopLeft},{children:[t.jsx("span",e.__assign({style:r?s.default.cartCheckbox:s.default.cartCheckboxEmpty},{children:r&&t.jsx(i.Check,{size:12,strokeWidth:3})})),t.jsx("p",e.__assign({style:s.default.cartItemName},{children:n.instant_learning_title}))]})),t.jsxs("div",e.__assign({style:s.default.cartItemIcons},{children:[t.jsx(i.Eye,{size:16,strokeWidth:2}),t.jsx("button",e.__assign({type:"button",style:s.default.removeBtn,onClick:function(e){return function(e,t){e.stopPropagation(),_===t&&f(null),c(t)}(e,n.instant_learning_id)}},{children:t.jsx(i.X,{size:16,strokeWidth:2})}))]}))]})),t.jsx("p",e.__assign({style:s.default.cartItemDescription},{children:n.instant_learning_description})),t.jsx("p",e.__assign({style:s.default.cartItemDate},{children:a(n.created_at)}))]}),n.instant_learning_id)})}))})),t.jsx("button",e.__assign({type:"button",style:g?s.default.proceedButton:s.default.proceedButtonDisabled,disabled:!g,onClick:function(){return g&&u(g)}},{children:t.jsx("span",{children:"Proceed with Selected"})}))]}))}exports.Cart=r,exports.default=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),s=require("lucide-react"),i=require("./Cart.styles.js");function r(e){try{var t=new Date(e),n=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),s=t.toLocaleDateString("en-GB").replace(/\//g,"/");return"Added on - ".concat(n," | ").concat(s)}catch(t){return e}}function a(a){var l=a.items,d=a.onRemove,c=a.onProceed,u=n.useState(new Set),o=u[0],_=u[1];n.useEffect(function(){1!==l.length?_(function(t){var n=new Set(l.map(function(e){return e.instant_learning_id})),s=new Set(e.__spreadArray([],t,!0).filter(function(e){return n.has(e)}));return s.size===t.size?t:s}):_(new Set([l[0].instant_learning_id]))},[l]);var f=l.filter(function(e){return o.has(e.instant_learning_id)});return t.jsxs("section",e.__assign({style:i.default.cartSection},{children:[t.jsxs("div",e.__assign({style:i.default.cartHeaderRow},{children:[t.jsx("p",e.__assign({style:i.default.cartTitle},{children:"Guideline Cart"})),t.jsxs("span",e.__assign({style:i.default.cartBadge},{children:[l.length," Added"]}))]})),t.jsx("p",e.__assign({style:i.default.cartDescription},{children:l.length>1?"Click items to select them for this session":"Selected for this session"})),t.jsx("div",e.__assign({style:i.default.cartBody},{children:t.jsx("div",e.__assign({style:i.default.cartList},{children:0===l.length?t.jsx("div",e.__assign({style:i.default.emptyState},{children:"No guidelines added yet"})):l.map(function(n){var a=o.has(n.instant_learning_id);return t.jsxs("div",e.__assign({style:a?i.default.cartItemSelected:i.default.cartItem,onClick:function(){return e=n.instant_learning_id,void _(function(t){var n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});var e}},{children:[t.jsxs("div",e.__assign({style:i.default.cartItemTop},{children:[t.jsxs("div",e.__assign({style:i.default.cartItemTopLeft},{children:[t.jsx("span",e.__assign({style:a?i.default.cartCheckbox:i.default.cartCheckboxEmpty},{children:a&&t.jsx(s.Check,{size:12,strokeWidth:3})})),t.jsx("p",e.__assign({style:i.default.cartItemName},{children:n.instant_learning_title}))]})),t.jsxs("div",e.__assign({style:i.default.cartItemIcons},{children:[t.jsx(s.Eye,{size:16,strokeWidth:2}),t.jsx("button",e.__assign({type:"button",style:i.default.removeBtn,onClick:function(e){return function(e,t){e.stopPropagation(),_(function(e){if(!e.has(t))return e;var n=new Set(e);return n.delete(t),n}),d(t)}(e,n.instant_learning_id)}},{children:t.jsx(s.X,{size:16,strokeWidth:2})}))]}))]})),t.jsx("p",e.__assign({style:i.default.cartItemDescription},{children:n.instant_learning_description})),t.jsx("p",e.__assign({style:i.default.cartItemDate},{children:r(n.created_at)}))]}),n.instant_learning_id)})}))})),t.jsx("button",e.__assign({type:"button",style:f.length>0?i.default.proceedButton:i.default.proceedButtonDisabled,disabled:0===f.length,onClick:function(){return f.length>0&&c(f)}},{children:t.jsxs("span",{children:["Proceed with Selected",f.length>1?" (".concat(f.length,")"):""]})}))]}))}exports.Cart=a,exports.default=a;
2
2
  //# sourceMappingURL=Cart.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),s=require("lucide-react"),i=require("./GuidelineCard.styles.js");function n(e){try{var t=new Date(e),s=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),i=t.toLocaleDateString("en-GB").replace(/\//g,"/");return"Added on - ".concat(s," | ").concat(i)}catch(t){return e}}function r(r){var d=r.guideline,a=r.inCart,l=r.onToggleCart,o=r.onExplore;return t.jsxs("div",e.__assign({style:i.default.card},{children:[t.jsxs("div",e.__assign({style:i.default.cardTop},{children:[t.jsxs("div",e.__assign({style:i.default.cardTopLeft},{children:[t.jsx(s.BookOpen,{size:18,strokeWidth:2,color:"#6D5BFF"}),t.jsx("p",e.__assign({style:i.default.cardTitle},{children:d.instant_learning_title}))]})),t.jsxs("div",e.__assign({style:i.default.cardTopIcons},{children:[t.jsx(s.Eye,{size:16,strokeWidth:2}),t.jsx(s.MoreVertical,{size:16,strokeWidth:2}),t.jsx(s.UserCheck,{size:16,strokeWidth:2})]}))]})),t.jsx("p",e.__assign({style:i.default.cardDescription},{children:d.instant_learning_description})),t.jsx("p",e.__assign({style:i.default.cardDate},{children:n(d.created_at)})),t.jsxs("div",e.__assign({style:i.default.cardActionsRow},{children:[t.jsxs("button",e.__assign({type:"button",style:i.default.exploreButton,onClick:function(){return null==o?void 0:o(d)}},{children:[t.jsx(s.Compass,{size:15,strokeWidth:2.4}),t.jsx("span",{children:"Explore"})]})),a?t.jsxs("button",e.__assign({type:"button",style:i.default.cardAddedButton,onClick:function(){return l(d)}},{children:[t.jsx(s.Check,{size:16,strokeWidth:2.4}),t.jsx("span",{children:"Added to Cart"})]})):t.jsxs("button",e.__assign({type:"button",style:i.default.cardAddButton,onClick:function(){return l(d)}},{children:[t.jsx(s.Plus,{size:16,strokeWidth:2.4}),t.jsx("span",{children:"Add to Cart"})]}))]}))]}))}exports.GuidelineCard=r,exports.default=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),s=require("lucide-react"),i=require("./GuidelineCard.styles.js");function n(e){try{var t=new Date(e),s=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),i=t.toLocaleDateString("en-GB").replace(/\//g,"/");return"Added on - ".concat(s," | ").concat(i)}catch(t){return e}}function r(r){var d=r.guideline,l=r.inCart,a=r.onToggleCart,o=r.onExplore;return t.jsxs("div",e.__assign({style:i.default.card},{children:[t.jsxs("div",e.__assign({style:i.default.cardTop},{children:[t.jsxs("div",e.__assign({style:i.default.cardTopLeft},{children:[t.jsx(s.BookOpen,{size:18,strokeWidth:2,color:"#6D5BFF"}),t.jsx("p",e.__assign({style:i.default.cardTitle},{children:d.instant_learning_title}))]})),t.jsxs("div",e.__assign({style:i.default.cardTopIcons},{children:[t.jsx(s.Eye,{size:16,strokeWidth:2}),t.jsx(s.MoreVertical,{size:16,strokeWidth:2}),t.jsx(s.UserCheck,{size:16,strokeWidth:2})]}))]})),t.jsx("p",e.__assign({style:i.default.cardDescription},{children:d.instant_learning_description})),t.jsx("p",e.__assign({style:i.default.cardDate},{children:n(d.created_at)})),t.jsxs("div",e.__assign({style:i.default.cardActionsRow},{children:[t.jsxs("button",e.__assign({type:"button",style:i.default.exploreButton,onClick:function(){return null==o?void 0:o(d)}},{children:[t.jsx(s.Compass,{size:15,strokeWidth:2.4}),t.jsx("span",{children:"Explore"})]})),l?t.jsxs("button",e.__assign({type:"button",style:i.default.cardAddedButton,onClick:function(){return a(d)}},{children:[t.jsx(s.Check,{size:16,strokeWidth:2.4}),t.jsx("span",{children:"Selected"})]})):t.jsxs("button",e.__assign({type:"button",style:i.default.cardAddButton,onClick:function(){return a(d)}},{children:[t.jsx(s.Plus,{size:16,strokeWidth:2.4}),t.jsx("span",{children:"Select"})]}))]}))]}))}exports.GuidelineCard=r,exports.default=r;
2
2
  //# sourceMappingURL=GuidelineCard.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("lucide-react"),s=require("./api.js"),r=require("./GuidelineCard.js"),a=require("./Cart/Cart.js"),l=require("./LearningManagementWrapper.js"),d=require("./GuidelinesLandingPage.styles.js");function u(e,n){var t,i,s,r;return n?null!==(r=null===(s=e.mode_mappings.find(function(e){return e.mode_id===n}))||void 0===s?void 0:s.application_integration_id)&&void 0!==r?r:"":null!==(i=null===(t=e.mode_mappings[0])||void 0===t?void 0:t.application_integration_id)&&void 0!==i?i:""}function o(o){var c=o.baseUrl,_=o.token,g=o.userDetails,h=o.modeId,p=t.useState([]),f=p[0],j=p[1],x=t.useState(6),y=x[0],b=x[1],m=t.useState([]),v=m[0],k=m[1],S=t.useState(!0),C=S[0],q=S[1],W=t.useState(null),G=W[0],w=W[1],z=t.useState(null),A=z[0],I=z[1];t.useEffect(function(){q(!0),w(null),s.fetchGuidelineInstances(c,_).then(function(e){j(e.data)}).catch(function(e){return w(e.message)}).finally(function(){return q(!1)})},[c,_]);var L=new Set(v.map(function(e){return e.instant_learning_id}));function M(n){k(function(t){return t.some(function(e){return e.instant_learning_id===n.instant_learning_id})?t.filter(function(e){return e.instant_learning_id!==n.instant_learning_id}):e.__spreadArray(e.__spreadArray([],t,!0),[n],!1)})}var P=f.slice(0,y),B=f.length-y,D=y>6;return n.jsx("div",e.__assign({style:d.default.page},{children:n.jsxs("main",e.__assign({style:d.default.main},{children:[n.jsxs("section",e.__assign({style:d.default.headerSection},{children:[n.jsxs("div",e.__assign({style:d.default.intro},{children:[n.jsx("h1",e.__assign({style:d.default.title},{children:"Add Guidelines"})),n.jsx("p",e.__assign({style:d.default.description},{children:"Add guidelines that shape how your agent behaves, responds, and interprets."})),n.jsxs("button",e.__assign({type:"button",style:d.default.debugLink},{children:[n.jsx("span",{children:"Know more about debug mode"}),n.jsx(i.CircleHelp,{size:18,strokeWidth:2})]}))]})),n.jsxs("button",e.__assign({type:"button",style:d.default.addButton},{children:[n.jsx(i.Plus,{size:20,strokeWidth:2.4}),n.jsx("span",{children:"Add Guideline"})]}))]})),n.jsxs("section",e.__assign({style:d.default.bodySection},{children:[n.jsxs("section",e.__assign({style:d.default.librarySection},{children:[n.jsxs("div",e.__assign({style:d.default.libraryTabs},{children:[n.jsxs("button",e.__assign({type:"button",style:e.__assign(e.__assign({},d.default.tab),d.default.tabActive)},{children:[n.jsx(i.UserCheck,{size:18,strokeWidth:2}),n.jsx("span",{children:"Saved"})]})),n.jsxs("button",e.__assign({type:"button",style:d.default.tab},{children:[n.jsx(i.Clock3,{size:18,strokeWidth:2}),n.jsx("span",{children:"Recently used"})]})),n.jsxs("button",e.__assign({type:"button",style:d.default.tab},{children:[n.jsx(i.ShoppingBag,{size:18,strokeWidth:2}),n.jsx("span",{children:"Marketplace"})]}))]})),A?n.jsx(l.LearningManagementWrapper,{userDetails:g,appIntegrationId:u(A,h),modeId:h,guidelineTitle:A.instant_learning_title,onBack:function(){return I(null)}}):n.jsxs(n.Fragment,{children:[C&&n.jsx("p",e.__assign({style:d.default.loadingState},{children:"Loading guidelines..."})),G&&n.jsxs("p",e.__assign({style:d.default.errorState},{children:["Error: ",G]})),!C&&!G&&n.jsxs(n.Fragment,{children:[n.jsx("div",e.__assign({style:d.default.libraryGrid},{children:P.map(function(e){return n.jsx(r.GuidelineCard,{guideline:e,inCart:L.has(e.instant_learning_id),onToggleCart:M,onExplore:I},e.instant_learning_id)})})),n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:16}},{children:[B>0&&n.jsxs("button",e.__assign({type:"button",style:d.default.showMore,onClick:function(){return b(function(e){return e+6})}},{children:[n.jsxs("span",{children:["Show more guidelines (",B,")"]}),n.jsx(i.ChevronDown,{size:16,strokeWidth:2.4})]})),D&&n.jsxs("button",e.__assign({type:"button",style:d.default.showMore,onClick:function(){return b(6)}},{children:[n.jsx("span",{children:"Hide"}),n.jsx(i.ChevronUp,{size:16,strokeWidth:2.4})]}))]}))]})]})]})),n.jsx(a.Cart,{items:v,onRemove:function(e){k(function(n){return n.filter(function(n){return n.instant_learning_id!==e})})},onProceed:function(){}})]}))]}))}))}exports.GuidelineLandingPage=o,exports.default=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("lucide-react"),s=require("./api.js"),r=require("./GuidelineCard.js"),a=require("./Cart/Cart.js"),l=require("./LearningManagementWrapper.js"),d=require("./GuidelinesLandingPage.styles.js"),o=require("@mui/material"),u=require("./transformSelectedGuidelineData.js");function c(e,n){var t,i,s,r;return n?null!==(r=null===(s=e.mode_mappings.find(function(e){return e.mode_id===n}))||void 0===s?void 0:s.application_integration_id)&&void 0!==r?r:"":null!==(i=null===(t=e.mode_mappings[0])||void 0===t?void 0:t.application_integration_id)&&void 0!==i?i:""}function _(_){var g=_.baseUrl,h=_.baseWebsocketUrl,p=_.token,f=_.userDetails,x=_.modeId,j=_.assistantName,b=_.appsecRbacUrl,y=_.appsecBaseUrl,m=_.onProceedSelected,v=t.useState([]),C=v[0],k=v[1],S=t.useState(6),w=S[0],z=S[1],A=t.useState([]),W=A[0],I=A[1],q=t.useState(!1),F=q[0],G=q[1],L=t.useState(null),U=L[0],B=L[1],E=t.useState(null),D=E[0],M=E[1],P=t.useState(""),T=P[0],O=P[1],R=t.useState(""),N=R[0],H=R[1];t.useEffect(function(){var e=setTimeout(function(){H(T.trim())},750);return function(){return clearTimeout(e)}},[T]),t.useEffect(function(){z(6)},[N]),t.useEffect(function(){G(!0),B(null),s.fetchGuidelineInstances(g,p).then(function(e){k(e.data)}).catch(function(e){return B(e.message)}).finally(function(){return G(!1)})},[g,p]);var K=new Set(W.map(function(e){return e.instant_learning_id}));function J(e){I(function(n){return n.some(function(n){return n.instant_learning_id===e.instant_learning_id})?n.filter(function(n){return n.instant_learning_id!==e.instant_learning_id}):[e]})}var Q=N.length>=2?C.filter(function(e){var n,t,i=N.toLowerCase();return(null===(n=e.instant_learning_title)||void 0===n?void 0:n.toLowerCase().includes(i))||(null===(t=e.instant_learning_description)||void 0===t?void 0:t.toLowerCase().includes(i))}):C,V=Q.slice(0,w),X=Q.length-w,Y=w>6;return n.jsx("div",e.__assign({style:d.default.page},{children:n.jsxs("main",e.__assign({style:d.default.main},{children:[n.jsxs("section",e.__assign({style:d.default.headerSection},{children:[n.jsxs("div",e.__assign({style:d.default.intro},{children:[n.jsx("h1",e.__assign({style:d.default.title},{children:"Add Guidelines"})),n.jsx("p",e.__assign({style:d.default.description},{children:"Add guidelines that shape how your agent behaves, responds, and interprets."})),n.jsxs("button",e.__assign({type:"button",style:d.default.debugLink},{children:[n.jsx("span",{children:"Know more about debug mode"}),n.jsx(i.CircleHelp,{size:18,strokeWidth:2})]}))]})),n.jsxs("button",e.__assign({type:"button",style:d.default.addButton},{children:[n.jsx(i.Plus,{size:20,strokeWidth:2.4}),n.jsx("span",{children:"Add Guideline"})]}))]})),n.jsxs("section",e.__assign({style:d.default.bodySection},{children:[n.jsxs("section",e.__assign({style:d.default.librarySection},{children:[n.jsxs("div",e.__assign({style:d.default.libraryTabs},{children:[n.jsxs("button",e.__assign({type:"button",style:e.__assign(e.__assign({},d.default.tab),d.default.tabActive)},{children:[n.jsx(i.UserCheck,{size:18,strokeWidth:2}),n.jsx("span",{children:"Saved"})]})),n.jsxs("button",e.__assign({type:"button",style:d.default.tab},{children:[n.jsx(i.Clock3,{size:18,strokeWidth:2}),n.jsx("span",{children:"Recently used"})]})),n.jsxs("button",e.__assign({type:"button",style:d.default.tab},{children:[n.jsx(i.ShoppingBag,{size:18,strokeWidth:2}),n.jsx("span",{children:"Marketplace"})]}))]})),!D&&n.jsx("div",e.__assign({style:{position:"sticky",top:0,zIndex:10,backgroundColor:"#FFFFFF",paddingTop:12,backdropFilter:"blur(8px)"}},{children:n.jsx(o.OutlinedInput,{placeholder:"Search Guideline",value:T,onChange:function(e){return O(e.target.value)},size:"small",startAdornment:n.jsx(o.InputAdornment,e.__assign({position:"start"},{children:n.jsx(i.Search,{size:16,color:"#9CA3AF"})})),sx:{width:"280px",borderRadius:"8px",fontSize:"14px","& .MuiOutlinedInput-notchedOutline":{borderColor:"#E5E7EB"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#D1D5DB"},bgcolor:"#fff"}})})),D?n.jsx(l.LearningManagementWrapper,{userDetails:f,baseUrl:g,baseWebsocketUrl:h,assistantName:j,appsecRbacUrl:b,appsecBaseUrl:y,appIntegrationId:c(D,x),modeId:x,guidelineTitle:D.instant_learning_title,onBack:function(){return M(null)},headerActions:K.has(D.instant_learning_id)?n.jsxs("button",e.__assign({type:"button",style:d.default.cardAddedButton,onClick:function(){return J(D)}},{children:[n.jsx(i.Check,{size:16,strokeWidth:2.4}),n.jsx("span",{children:"Added to Cart"})]})):n.jsxs("button",e.__assign({type:"button",style:d.default.cardAddButton,onClick:function(){return J(D)}},{children:[n.jsx(i.Plus,{size:16,strokeWidth:2.4}),n.jsx("span",{children:"Add to Cart"})]}))}):n.jsxs(n.Fragment,{children:[F&&n.jsx("p",e.__assign({style:d.default.loadingState},{children:"Loading guidelines..."})),U&&n.jsxs("p",e.__assign({style:d.default.errorState},{children:["Error: ",U]})),!F&&!U&&n.jsx(n.Fragment,{children:0===Q.length?n.jsx("p",e.__assign({style:d.default.loadingState},{children:N.length>=2?"No guidelines match your search.":"No guidelines found."})):n.jsxs(n.Fragment,{children:[n.jsx("div",e.__assign({style:d.default.libraryGrid},{children:V.map(function(e){return n.jsx(r.GuidelineCard,{guideline:e,inCart:K.has(e.instant_learning_id),onToggleCart:J,onExplore:M},e.instant_learning_id)})})),n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:16}},{children:[X>0&&n.jsxs("button",e.__assign({type:"button",style:d.default.showMore,onClick:function(){return z(function(e){return e+6})}},{children:[n.jsxs("span",{children:["Show more guidelines (",X,")"]}),n.jsx(i.ChevronDown,{size:16,strokeWidth:2.4})]})),Y&&n.jsxs("button",e.__assign({type:"button",style:d.default.showMore,onClick:function(){return z(6)}},{children:[n.jsx("span",{children:"Hide"}),n.jsx(i.ChevronUp,{size:16,strokeWidth:2.4})]}))]}))]})})]})]})),n.jsx(a.Cart,{items:W,onRemove:function(e){I(function(n){return n.filter(function(n){return n.instant_learning_id!==e})})},onProceed:function(n){return e.__awaiter(this,void 0,void 0,function(){var t,i;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,u.transformSelectedToILData(n,x,f.accessToken)];case 1:return t=e.sent(),console.log("Proceeding with il_data:",t),m(t),[3,3];case 2:return i=e.sent(),console.error("Error building il_data for selected guidelines:",i),[3,3];case 3:return[2]}})})}})]}))]}))}))}exports.GuidelineLandingPage=_,exports.default=_;
2
2
  //# sourceMappingURL=GuidelinesLandingPage.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.default={page:{height:"100%",width:"100%",background:"#ffffff",fontFamily:"Inter, sans-serif"},main:{height:"100%",overflow:"auto",padding:40},headerSection:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:24,justifyContent:"space-between",alignItems:"flex-start"},intro:{minWidth:280,flex:"1 1 0%"},title:{fontSize:30,fontWeight:700,lineHeight:"38px",color:"#6D35F2",margin:0},description:{marginTop:8,fontSize:19,lineHeight:"28px",color:"#1F2937"},debugLink:{marginTop:12,display:"inline-flex",alignItems:"center",gap:8,fontSize:14,fontWeight:500,color:"#53657D",background:"none",border:"none",padding:0,cursor:"pointer"},addButton:{display:"inline-flex",height:44,minWidth:210,flexShrink:0,alignItems:"center",justifyContent:"center",gap:12,borderRadius:6,background:"#4438F5",padding:"0 20px",fontSize:15,fontWeight:600,color:"#ffffff",border:"none",boxShadow:"0 1px 2px rgba(16,24,40,0.08)",cursor:"pointer",marginLeft:"auto"},bodySection:{marginTop:48,display:"grid",width:"100%",gridTemplateColumns:"minmax(0,1fr) minmax(300px,360px)",alignItems:"start",gap:24},librarySection:{minWidth:0},libraryTabs:{display:"flex",borderBottom:"1px solid #EAECF0"},tab:{position:"relative",display:"inline-flex",height:40,alignItems:"center",gap:8,padding:"0 16px",fontSize:14,fontWeight:500,background:"none",border:"none",cursor:"pointer",color:"#B5BDC8"},tabActive:{color:"#1F2937",boxShadow:"inset 0 -3px 0 0 #6D5BFF"},libraryGrid:{marginTop:24,display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:20},showMore:{marginTop:28,display:"inline-flex",alignItems:"center",gap:8,fontSize:14,fontWeight:600,color:"#5B2CF4",background:"none",border:"none",cursor:"pointer"},loadingState:{marginTop:24,fontSize:14,color:"#667085"},errorState:{marginTop:24,fontSize:14,color:"#F04438"}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.default={page:{height:"100%",width:"100%",background:"#ffffff",fontFamily:"Inter, sans-serif"},main:{height:"100%",overflow:"auto",padding:40},headerSection:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:24,justifyContent:"space-between",alignItems:"flex-start"},intro:{minWidth:280,flex:"1 1 0%"},title:{fontSize:30,fontWeight:700,lineHeight:"38px",color:"#6D35F2",margin:0},description:{marginTop:8,fontSize:19,lineHeight:"28px",color:"#1F2937"},debugLink:{marginTop:12,display:"inline-flex",alignItems:"center",gap:8,fontSize:14,fontWeight:500,color:"#53657D",background:"none",border:"none",padding:0,cursor:"pointer"},addButton:{display:"inline-flex",height:44,minWidth:210,flexShrink:0,alignItems:"center",justifyContent:"center",gap:12,borderRadius:6,background:"#4438F5",padding:"0 20px",fontSize:15,fontWeight:600,color:"#ffffff",border:"none",boxShadow:"0 1px 2px rgba(16,24,40,0.08)",cursor:"pointer",marginLeft:"auto"},bodySection:{marginTop:48,display:"grid",width:"100%",gridTemplateColumns:"minmax(0,1fr) minmax(300px,360px)",alignItems:"start",gap:24},librarySection:{minWidth:0},libraryTabs:{display:"flex",borderBottom:"1px solid #EAECF0"},tab:{position:"relative",display:"inline-flex",height:40,alignItems:"center",gap:8,padding:"0 16px",fontSize:14,fontWeight:500,background:"none",border:"none",cursor:"pointer",color:"#B5BDC8"},tabActive:{color:"#1F2937",boxShadow:"inset 0 -3px 0 0 #6D5BFF"},libraryGrid:{marginTop:24,display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:20},cardAddButton:{display:"inline-flex",height:36,flex:1,alignItems:"center",justifyContent:"center",gap:8,borderRadius:6,border:"1px solid #4438F5",background:"#ffffff",fontSize:13,fontWeight:600,color:"#4438F5",cursor:"pointer"},cardAddedButton:{display:"inline-flex",height:36,flex:1,alignItems:"center",justifyContent:"center",gap:8,borderRadius:6,border:"1px solid #EAE7FF",background:"#EDE9FE",fontSize:13,fontWeight:600,color:"#4438F5",cursor:"pointer"},showMore:{marginTop:28,display:"inline-flex",alignItems:"center",gap:8,fontSize:14,fontWeight:600,color:"#5B2CF4",background:"none",border:"none",cursor:"pointer"},loadingState:{marginTop:24,fontSize:14,color:"#667085"},errorState:{marginTop:24,fontSize:14,color:"#F04438"}};
2
2
  //# sourceMappingURL=GuidelinesLandingPage.styles.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),a=require("lucide-react"),t=require("@tanstack/react-query"),r=require("../LearningManagement/LearningManagement.js"),n={config:{CUSTOM_SCOPE_GROUP_NAME:"Preview",INSTANT_LEARNING_TYPE:"iL",MODEL:"claude-3.5-sonnet",CONFIG_MASTER_NAME:"preview-config",SCOPE_NAME:"Custom",ASSISTANT_NAME:"preview",ORGANIZATION_NAME:"techolution",BASE_URL:"https://devllmstudio.creativeworkspace.ai",BASE_WEBSOCKET_URL:"wss://devllmstudio.creativeworkspace.ai/graphql",CHAT_TITLE:"Preview",CHAT_TITLE_EDIT:"Preview Edit",FORM_TITLE:"Learning Details",INITIAL_CHAT_MESSAGE:"Hi",CATEGORY:"Global-Template",SOCKET_TIMEOUT:24e4},llmStudioUrl:"https://devllmstudio.creativeworkspace.ai",audacyBackendUrl:"https://dev-audacy-traffic-manager.techo.camp",auditLogConfig:{configId:"6a1825e9fb722c37637b9490"},ilLabels:{setupLabel:"Learning Setup",ruleTitle:"Learning Title",ruleDescriptionTitle:"Learning Description"},rbacConfig:{applicationName:"IL Mode - ILOTJ",applicationId:"6a22c19581f05dc3afc8ad57",moduleId:"6a22c19581f05dc3afc8ad8e",applicationModuleId:"6a22c19581f05dc3afc8ad88",applicationResourceId:"6a22c19681f05dc3afc8ad94",appsecRbacUrl:"https://dev-cw-appsec.techo.camp/granularApi",appsecBaseUrl:"https://dev-cw-appsec.techo.camp"}},s=new t.QueryClient,l={wrapper:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},header:{display:"flex",alignItems:"center",gap:12,padding:"10px 0",borderBottom:"1px solid #EAECF0",flexShrink:0},backButton:{display:"inline-flex",alignItems:"center",gap:6,background:"none",border:"none",cursor:"pointer",fontSize:14,fontWeight:500,color:"#344054",padding:"4px 8px",borderRadius:6},headerTitle:{fontSize:14,fontWeight:600,color:"#1F2937",margin:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},headerActions:{display:"flex",alignItems:"center",gap:8,marginLeft:"auto"},lmsContainer:{flex:1,minHeight:0,overflow:"hidden"}};function o(o){var c=o.userDetails,d=o.appIntegrationId,p=o.modeId,u=o.guidelineTitle,g=o.onBack,_=o.headerActions;return i.jsx(t.QueryClientProvider,e.__assign({client:s},{children:i.jsxs("div",e.__assign({style:l.wrapper},{children:[i.jsxs("div",e.__assign({style:l.header},{children:[i.jsxs("button",e.__assign({type:"button",style:l.backButton,onClick:g},{children:[i.jsx(a.ArrowLeft,{size:16,strokeWidth:2}),"Back"]})),u&&i.jsx("p",e.__assign({style:l.headerTitle},{children:u})),_&&i.jsx("div",e.__assign({style:l.headerActions},{children:_}))]})),i.jsx("div",e.__assign({style:l.lmsContainer},{children:i.jsx(r.default,e.__assign({},n,{userDetails:c,app_integration_id:d,modeId:p}),"lms-explore")}))]}))}))}exports.LearningManagementWrapper=o,exports.default=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),a=require("react/jsx-runtime"),i=require("react"),n=require("lucide-react"),t=require("@tanstack/react-query"),r=require("../LearningManagement/LearningManagement.js"),s=require("./api.js"),l={config:{CUSTOM_SCOPE_GROUP_NAME:"Preview",INSTANT_LEARNING_TYPE:"iL",MODEL:"claude-3.5-sonnet",CONFIG_MASTER_NAME:"preview-config",SCOPE_NAME:"Custom",ASSISTANT_NAME:"preview",ORGANIZATION_NAME:"techolution",BASE_URL:"https://devllmstudio.creativeworkspace.ai",BASE_WEBSOCKET_URL:"wss://devllmstudio.creativeworkspace.ai/graphql",CHAT_TITLE:"Preview",CHAT_TITLE_EDIT:"Preview Edit",FORM_TITLE:"Learning Details",INITIAL_CHAT_MESSAGE:"Hi",CATEGORY:"Global-Template",SOCKET_TIMEOUT:24e4},llmStudioUrl:"https://devllmstudio.creativeworkspace.ai",audacyBackendUrl:"https://dev-audacy-traffic-manager.techo.camp",ilLabels:{setupLabel:"Learning Setup",ruleTitle:"Learning Title",ruleDescriptionTitle:"Learning Description"}},o={applicationName:"IL Mode - ILOTJ",applicationId:"6a22c19581f05dc3afc8ad57",moduleId:"6a22c19581f05dc3afc8ad8e",applicationModuleId:"6a22c19581f05dc3afc8ad88",applicationResourceId:"6a22c19681f05dc3afc8ad94",appsecRbacUrl:"https://dev-cw-appsec.techo.camp/granularApi",appsecBaseUrl:"https://dev-cw-appsec.techo.camp"},c={configId:"6a1825e9fb722c37637b9490"},d=new t.QueryClient,p={wrapper:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},header:{display:"flex",alignItems:"center",gap:12,padding:"10px 0",borderBottom:"1px solid #EAECF0",flexShrink:0},backButton:{display:"inline-flex",alignItems:"center",gap:6,background:"none",border:"none",cursor:"pointer",fontSize:14,fontWeight:500,color:"#344054",padding:"4px 8px",borderRadius:6},headerTitle:{fontSize:14,fontWeight:600,color:"#1F2937",margin:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},headerActions:{display:"flex",alignItems:"center",gap:8,marginLeft:"auto"},lmsContainer:{flex:1,minHeight:0,overflow:"hidden"},loadingState:{padding:24,fontSize:14,color:"#667085"}};function g(g){var _=g.userDetails,u=g.baseUrl,f=g.baseWebsocketUrl,h=g.assistantName,m=g.appsecRbacUrl,v=g.appsecBaseUrl,T=g.appIntegrationId,I=g.modeId,A=g.guidelineTitle,E=g.onBack,S=g.headerActions,x=i.useState(null),L=x[0],b=x[1];return i.useEffect(function(){if(T){var a=e.__assign(e.__assign({},l),{config:e.__assign(e.__assign({},l.config),{ASSISTANT_NAME:h,BASE_URL:u,BASE_WEBSOCKET_URL:f}),llmStudioUrl:u}),i=e.__assign(e.__assign({},o),{appsecRbacUrl:m,appsecBaseUrl:v}),n=!1;return b(null),s.fetchRBACConfig(u,_.accessToken,T).then(function(t){var r,s,l,o;if(!n){var d=t?{applicationName:t.application_name,applicationId:t.application_id,moduleId:null===(r=t.module_data)||void 0===r?void 0:r.Scopes,applicationModuleId:null===(s=t.module_data)||void 0===s?void 0:s.General,applicationResourceId:null===(l=t.resource_data)||void 0===l?void 0:l["Learning Management"],appsecRbacUrl:m,appsecBaseUrl:v}:i;b(e.__assign(e.__assign({},a),{auditLogConfig:{configId:null!==(o=null==t?void 0:t.change_log_config_id)&&void 0!==o?o:c.configId},rbacConfig:d}))}}).catch(function(){n||(console.warn("RBAC config fetch failed, using fallback."),b(e.__assign(e.__assign({},a),{auditLogConfig:c,rbacConfig:i})))}),function(){n=!0}}},[T,u,f,h,m,v]),a.jsx(t.QueryClientProvider,e.__assign({client:d},{children:a.jsxs("div",e.__assign({style:p.wrapper},{children:[a.jsxs("div",e.__assign({style:p.header},{children:[a.jsxs("button",e.__assign({type:"button",style:p.backButton,onClick:E},{children:[a.jsx(n.ArrowLeft,{size:16,strokeWidth:2}),"Back"]})),A&&a.jsx("p",e.__assign({style:p.headerTitle},{children:A})),S&&a.jsx("div",e.__assign({style:p.headerActions},{children:S}))]})),a.jsx("div",e.__assign({style:p.lmsContainer},{children:L?a.jsx(r.default,e.__assign({},L,{userDetails:_,app_integration_id:T,modeId:I}),"lms-explore"):a.jsx("p",e.__assign({style:p.loadingState},{children:"Loading..."}))}))]}))}))}exports.LearningManagementWrapper=g,exports.default=g;
2
2
  //# sourceMappingURL=LearningManagementWrapper.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("./endpoints.js");exports.fetchGuidelineInstances=function(n,r){return e.__awaiter(this,void 0,void 0,function(){var i;return e.__generator(this,function(e){switch(e.label){case 0:return[4,fetch(t.endpoints.listInstances(n),{headers:{accept:"application/json, text/plain, */*",authorization:"Bearer ".concat(r)}})];case 1:if(!(i=e.sent()).ok)throw new Error("Failed to fetch guidelines: ".concat(i.status));return[2,i.json()]}})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),e=require("./endpoints.js");exports.fetchGuidelineInstances=function(n,r){return t.__awaiter(this,void 0,void 0,function(){var i;return t.__generator(this,function(t){switch(t.label){case 0:return[4,fetch(e.endpoints.listInstances(n),{headers:{accept:"application/json, text/plain, */*",authorization:"Bearer ".concat(r)}})];case 1:if(!(i=t.sent()).ok)throw new Error("Failed to fetch guidelines: ".concat(i.status));return[2,i.json()]}})})},exports.fetchRBACConfig=function(n,r,i){return t.__awaiter(this,void 0,void 0,function(){var a;return t.__generator(this,function(t){switch(t.label){case 0:return[4,fetch(e.endpoints.getRbacConfig(n,i),{headers:{accept:"application/json, text/plain, */*",authorization:"Bearer ".concat(r)}})];case 1:if(!(a=t.sent()).ok)throw new Error("Failed to fetch RBAC config: ".concat(a.status));return[4,a.json()];case 2:return[2,t.sent().data]}})})};
2
2
  //# sourceMappingURL=api.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.endpoints={listInstances:function(t){return"".concat(t,"/instant_learning/ilotj/listInstances?createdAt=desc")}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.endpoints={listInstances:function(t){return"".concat(t,"/instant_learning/ilotj/listInstances?createdAt=desc")},getRbacConfig:function(t,n){return"".concat(t,"/instant_learning/ilotj/application/getRBACAuditConfig/").concat(n)}};
2
2
  //# sourceMappingURL=endpoints.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("../LearningManagement/apis/apiConfig.js"),r=require("../LearningManagement/apis/scopeApis.js");function n(n,i){var o;return e.__awaiter(this,void 0,void 0,function(){var a,s;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,r.llmApiWithToken(i).get(t.API_ENDPOINTS.getTiers.replace("{appIntegrationId}",n))];case 1:return a=e.sent(),"success"===(null===(o=a.data)||void 0===o?void 0:o.status)?[2,a.data.data.map(function(e){return e.id})]:[2,[]];case 2:throw s=e.sent(),console.error("Error fetching tiers:",s),s;case 3:return[2]}})})}function i(n,i){var o,a,s;return e.__awaiter(this,void 0,void 0,function(){var c,u,l;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,r.llmApiWithToken(i).get("".concat(t.API_ENDPOINTS.fetchScopes,"/").concat(n))];case 1:return c=e.sent(),console.log("fetchScopeIds response:",c),[2,(u=null===(s=null===(a=null===(o=c.data)||void 0===o?void 0:o.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.id)?[u]:[]];case 2:throw l=e.sent(),console.error("Error fetching rule sets:",l),l;case 3:return[2]}})})}exports.transformSelectedToILData=function(t,r,o){return e.__awaiter(this,void 0,void 0,function(){var a=this;return e.__generator(this,function(s){switch(s.label){case 0:return console.log(t,"selected",r,"modeId"),[4,Promise.all(t.map(function(t){return e.__awaiter(a,void 0,void 0,function(){var a,s,c,u;return e.__generator(this,function(e){switch(e.label){case 0:return a=function(e,t){var r,n,i,o;return t?null!==(o=null===(i=e.mode_mappings.find(function(e){return e.mode_id===t}))||void 0===i?void 0:i.application_integration_id)&&void 0!==o?o:"":null!==(n=null===(r=e.mode_mappings[0])||void 0===r?void 0:r.application_integration_id)&&void 0!==n?n:""}(t,r),[4,Promise.all([a?i(a,o):Promise.resolve([]),a?n(a,o):Promise.resolve([])])];case 1:return s=e.sent(),c=s[0],u=s[1],[2,{app_map_id:a,scope_ids:c,tier_ids:u}]}})})}))];case 1:return[2,{il_data:{selected_guidelines:s.sent()}}]}})})};
2
+ //# sourceMappingURL=transformSelectedGuidelineData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformSelectedGuidelineData.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";require("tslib"),require("react/jsx-runtime"),require("react"),require("lucide-react"),require("./store/useLearningTemplateStore.js"),require("primereact/toast"),require("./apis/scopeApis.js"),require("./store/usePermissionsStore.js"),require("./store/useLMSConfigStore.js"),require("./components/ToolTip.js"),require("./store/useAuthStore.js"),require("@mui/material"),require("@mui/icons-material/Check"),require("@mui/icons-material/CloseRounded");var e=require("@tanstack/react-query");require("./store/useEnvStore.js"),require("date-fns/format"),require("date-fns/isValid"),require("date-fns/parseISO"),require("framer-motion"),require("../IL-OTJ/_components/atoms/Textarea/Textarea.js"),require("../IL-OTJ/_components/InputDataReasoningCard.js"),require("../IL-OTJ/_components/TooltipComponent.js"),require("../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js"),require("../IL-OTJ/store/CitationsContext.js"),require("uuid"),require("@mui/material/Tooltip"),require("react-markdown"),require("rehype-raw"),require("axios"),require("@e-llm-studio/streaming-response"),require("@e-llm-studio/watch-me-work"),require("../IL-OTJ/_components/ChatComponents/ChatHeader.js"),require("remark-gfm"),require("../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js"),require("../IL-OTJ/_components/CitationLink.js"),require("@e-llm-studio/citation"),require("../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js"),require("./store/useConfigStore.js"),require("appsec-ui"),require("@radix-ui/react-tooltip"),require("./components/StationOnboarding/InputField.js"),require("./config.js"),require("./store/useAppSecRolesStore.js"),require("@e-llm-studio/audit-log"),require("@e-llm-studio/audit-log/dist/styles.css"),require("./AuditLog/ChangeLogDiff.js"),require("react-router-dom"),new e.QueryClient;
1
+ "use strict";require("tslib"),require("react/jsx-runtime"),require("react"),require("lucide-react"),require("./store/useLearningTemplateStore.js"),require("primereact/toast"),require("./apis/scopeApis.js"),require("./store/usePermissionsStore.js"),require("./store/useLMSConfigStore.js"),require("./components/ToolTip.js"),require("./store/useAuthStore.js"),require("@mui/material"),require("@mui/icons-material/Check"),require("@mui/icons-material/CloseRounded");var e=require("@tanstack/react-query");require("./store/useEnvStore.js"),require("date-fns/format"),require("date-fns/isValid"),require("date-fns/parseISO"),require("framer-motion"),require("../IL-OTJ/_components/atoms/Textarea/Textarea.js"),require("../IL-OTJ/_components/InputDataReasoningCard.js"),require("../IL-OTJ/_components/TooltipComponent.js"),require("../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js"),require("../IL-OTJ/store/CitationsContext.js"),require("uuid"),require("@mui/material/Tooltip"),require("react-markdown"),require("rehype-raw"),require("axios"),require("@e-llm-studio/streaming-response"),require("@e-llm-studio/watch-me-work"),require("../IL-OTJ/_components/ChatComponents/ChatHeader.js"),require("remark-gfm"),require("../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js"),require("../IL-OTJ/_components/CitationLink.js"),require("@e-llm-studio/citation"),require("../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js"),require("./store/useConfigStore.js"),require("appsec-ui"),require("@radix-ui/react-tooltip"),require("./components/StationOnboarding/InputField.js"),require("./config.js"),require("./store/useAppSecRolesStore.js"),require("react-router-dom"),new e.QueryClient;
2
2
  //# sourceMappingURL=LearningManagementTest.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),o=require("./RuleContent/RuleContent.js"),s=require("./StationsContent/StationsContent.js"),i=require("./RBAC/AccessManagementPanel.js");require("appsec-ui"),require("./store/useAuthStore.js"),require("./store/usePermissionsStore.js");var a=require("./store/useLearningTemplateStore.js"),r=require("./store/useEnvStore.js"),c=require("./styles/LearningTemplateLayout.module.css.js"),u=require("./utils/treeUtils.js"),d=require("./SidebarWrapper.js"),l=require("./components/StationOnboarding/StationOnboardModal.js"),S=require("./AuditLog/AuditLog.js"),p=require("./components/EmptyLearningState.js"),T=require("./store/useLMSConfigStore.js"),f=require("./constants.js");exports.default=function(g){var A,m,v=g.onOpenCreateModal,q=g.onRefreshRuleSets,_=g.scopeTreeData,C=g.onAddChild,j=g.onRenameChild,R=g.onDeleteChild,h=g.canDeleteScope,D=g.canEditScope,E=g.canCreateScope,M=g.onSectionSelect,L=g.onViewStation,P=g.activeSectionId,x=void 0===P?"learnings":P,I=g.sectionsConfig,O=g.nodeTypesConfig,w=g.app_integration_id,y=g.token,b=g.modeId,B=g.onRequestAccess,Y=g.isRequestingAccess,k=g.isAccessRequested,H=a.useLearningTemplateStore(function(e){return e.isStationModalOpen}),N=a.useLearningTemplateStore(function(e){return e.setStationModalOpen}),U=a.useLearningTemplateStore(function(e){return e.isStationOnboardModalTriggered}),V=a.useLearningTemplateStore(function(e){return e.setIsStationOnboardModalTriggered}),W=a.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),z=a.useLearningTemplateStore(function(e){return e.rawAuditRuleData}),F=r.default(function(e){return e.auditLogConfig});a.useLearningTemplateStore(function(e){return e.ruleData});var G=W?u.findNodeById((null==_?void 0:_.data)||null,W):null;return Boolean((null===(A=null==_?void 0:_.data)||void 0===A?void 0:A.id)&&W===_.data.id),n.useEffect(function(){U&&N(!0)},[U,N,V]),t.jsxs("div",e.__assign({className:c.default.container},{children:[t.jsx(d.default,{onOpenCreateModal:v,onRefreshRuleSets:q,scopeTreeData:_,onAddChild:C,onRenameChild:j,onDeleteChild:R,canDeleteScope:h,canEditScope:D,canCreateScope:E,onSectionSelect:M,activeSectionId:x,sectionsConfig:I,nodeTypesConfig:O}),t.jsx("div",e.__assign({id:"rule-template-layout-content",className:"".concat(c.default.content," relative flex-1 overflow-hidden")},{children:"stations"===x?t.jsx(s.default,{scopeId:W||"",scopeName:(null==G?void 0:G.name)||"Unknown Scope",stationsCount:null===(m=null==G?void 0:G.metrics)||void 0===m?void 0:m.stationsCount,stations:u.mapScopeChildrenToStations(G),onViewStation:L}):"access"===x?t.jsx(i.default,{selectedRuleSetId:W,scopeName:(null==G?void 0:G.name)||"Unknown Scope"}):"history"===x?(null==F?void 0:F.configId)?t.jsx(S.default,{configId:F.configId,scopeId:W||void 0,scopeName:(null==G?void 0:G.name)||"Unknown Scope",ruleData:z}):null:G&&!1===G.hasAccess?t.jsx(p.default,{onCreate:function(){},title:T.dt("".concat(f.EMPTY_STATE_DT_PATH,".noAccessTitle"),"Access Restricted"),desc:T.dt("".concat(f.EMPTY_STATE_DT_PATH,".noAccessDesc"),"You do not have access to view this ".concat(null==G?void 0:G.name," learnings.")),button:"",canCreateRule:!1,noAccessTitle:T.dt("".concat(f.EMPTY_STATE_DT_PATH,".noAccessTitle"),"Access Restricted"),noAccessDesc:T.dt("".concat(f.EMPTY_STATE_DT_PATH,".noAccessDesc"),"You do not have access to view this ".concat(null==G?void 0:G.name," learnings.")),requestAccessButton:T.dt("".concat(f.EMPTY_STATE_DT_PATH,".requestAccessButton"),"Request Access"),requestSentButton:T.dt("".concat(f.EMPTY_STATE_DT_PATH,".requestSentButton"),"Request Sent"),onRequestAccess:function(){return null==B?void 0:B(W)},isRequestingAccess:Y,isAccessRequested:k}):t.jsx(o.default,{onRefreshRuleSets:q,app_integration_id:w,token:y,modeId:b})})),t.jsx(l.default,{isOpen:H,onClose:function(){N(!1),V(!1)},onBoardStation:function(e){q(!0,e)},app_integration_id:w,token:y})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),o=require("./RuleContent/RuleContent.js"),s=require("./StationsContent/StationsContent.js"),i=require("./RBAC/AccessManagementPanel.js");require("appsec-ui"),require("./store/useAuthStore.js"),require("./store/usePermissionsStore.js");var a=require("./store/useLearningTemplateStore.js"),r=require("./store/useEnvStore.js"),c=require("./styles/LearningTemplateLayout.module.css.js"),u=require("./utils/treeUtils.js"),l=require("./SidebarWrapper.js"),d=require("./components/StationOnboarding/StationOnboardModal.js"),S=require("./components/EmptyLearningState.js"),T=require("./store/useLMSConfigStore.js"),p=require("./constants.js");exports.default=function(f){var A,g,m=f.onOpenCreateModal,v=f.onRefreshRuleSets,q=f.scopeTreeData,_=f.onAddChild,C=f.onRenameChild,j=f.onDeleteChild,R=f.canDeleteScope,h=f.canEditScope,D=f.canCreateScope,E=f.onSectionSelect,M=f.onViewStation,P=f.activeSectionId,x=void 0===P?"learnings":P,L=f.sectionsConfig,I=f.nodeTypesConfig,O=f.app_integration_id,y=f.token,b=f.modeId,w=f.onRequestAccess,B=f.isRequestingAccess,Y=f.isAccessRequested,H=a.useLearningTemplateStore(function(e){return e.isStationModalOpen}),k=a.useLearningTemplateStore(function(e){return e.setStationModalOpen}),N=a.useLearningTemplateStore(function(e){return e.isStationOnboardModalTriggered}),U=a.useLearningTemplateStore(function(e){return e.setIsStationOnboardModalTriggered}),V=a.useLearningTemplateStore(function(e){return e.selectedRuleSetId});a.useLearningTemplateStore(function(e){return e.rawAuditRuleData});var F=r.default(function(e){return e.auditLogConfig});a.useLearningTemplateStore(function(e){return e.ruleData});var W=V?u.findNodeById((null==q?void 0:q.data)||null,V):null;return Boolean((null===(A=null==q?void 0:q.data)||void 0===A?void 0:A.id)&&V===q.data.id),n.useEffect(function(){N&&k(!0)},[N,k,U]),t.jsxs("div",e.__assign({className:c.default.container},{children:[t.jsx(l.default,{onOpenCreateModal:m,onRefreshRuleSets:v,scopeTreeData:q,onAddChild:_,onRenameChild:C,onDeleteChild:j,canDeleteScope:R,canEditScope:h,canCreateScope:D,onSectionSelect:E,activeSectionId:x,sectionsConfig:L,nodeTypesConfig:I}),t.jsx("div",e.__assign({id:"rule-template-layout-content",className:"".concat(c.default.content," relative flex-1 overflow-hidden")},{children:"stations"===x?t.jsx(s.default,{scopeId:V||"",scopeName:(null==W?void 0:W.name)||"Unknown Scope",stationsCount:null===(g=null==W?void 0:W.metrics)||void 0===g?void 0:g.stationsCount,stations:u.mapScopeChildrenToStations(W),onViewStation:M}):"access"===x?t.jsx(i.default,{selectedRuleSetId:V,scopeName:(null==W?void 0:W.name)||"Unknown Scope"}):"history"===x?(null==F?void 0:F.configId)?t.jsx(t.Fragment,{}):null:W&&!1===W.hasAccess?t.jsx(S.default,{onCreate:function(){},title:T.dt("".concat(p.EMPTY_STATE_DT_PATH,".noAccessTitle"),"Access Restricted"),desc:T.dt("".concat(p.EMPTY_STATE_DT_PATH,".noAccessDesc"),"You do not have access to view this ".concat(null==W?void 0:W.name," learnings.")),button:"",canCreateRule:!1,noAccessTitle:T.dt("".concat(p.EMPTY_STATE_DT_PATH,".noAccessTitle"),"Access Restricted"),noAccessDesc:T.dt("".concat(p.EMPTY_STATE_DT_PATH,".noAccessDesc"),"You do not have access to view this ".concat(null==W?void 0:W.name," learnings.")),requestAccessButton:T.dt("".concat(p.EMPTY_STATE_DT_PATH,".requestAccessButton"),"Request Access"),requestSentButton:T.dt("".concat(p.EMPTY_STATE_DT_PATH,".requestSentButton"),"Request Sent"),onRequestAccess:function(){return null==w?void 0:w(V)},isRequestingAccess:B,isAccessRequested:Y}):t.jsx(o.default,{onRefreshRuleSets:v,app_integration_id:O,token:y,modeId:b})})),t.jsx(d.default,{isOpen:H,onClose:function(){k(!1),U(!1)},onBoardStation:function(e){v(!0,e)},app_integration_id:O,token:y})]}))};
2
2
  //# sourceMappingURL=LearningTemplateLayout.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("../store/useLearningTemplateStore.js"),i=require("../components/EmptyLearningState.js"),a=require("../apis/scopeApis.js"),o=require("../components/RuleContentSkeleton.js"),l=require("primereact/toast"),s=require("./ContentLogic.js"),u=require("../components/ErrorStateDisplay.js"),d=require("../shared/SuccessToastContent.js"),c=require("../shared/ErrorToastContent.js"),f=require("../utils/treeUtils.js"),v=require("../styles/LearningContent.module.css.js"),p=require("../components/ConfirmationModal.js"),g=require("../store/useLMSConfigStore.js");require("../../IL-OTJ/_components/atoms/Textarea/Textarea.js"),require("lucide-react"),require("../../IL-OTJ/_components/InputDataReasoningCard.js"),require("../../IL-OTJ/_components/TooltipComponent.js"),require("../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js");var m=require("../../IL-OTJ/store/CitationsContext.js");require("@mui/material"),require("uuid"),require("@mui/material/Tooltip"),require("react-markdown"),require("rehype-raw"),require("axios"),require("@e-llm-studio/streaming-response"),require("@e-llm-studio/watch-me-work"),require("../../IL-OTJ/_components/ChatComponents/ChatHeader.js"),require("remark-gfm"),require("../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js"),require("../../IL-OTJ/_components/CitationLink.js"),require("@e-llm-studio/citation");var T=require("../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js"),_=require("../constants.js"),h=require("../store/useConfigStore.js");require("../store/usePermissionsStore.js"),require("appsec-ui"),require("../store/useAuthStore.js"),require("../store/useEnvStore.js"),require("@radix-ui/react-tooltip"),require("../components/StationOnboarding/InputField.js"),require("../config.js"),require("../store/useAppSecRolesStore.js"),require("@tanstack/react-query"),require("@e-llm-studio/audit-log"),require("@e-llm-studio/audit-log/dist/styles.css"),require("../AuditLog/ChangeLogDiff.js"),require("../components/ToolTip.js"),require("react-router-dom"),require("../LearningManagementTest.js");exports.default=function(S){var y,j=S.noRulesTitle,x=void 0===j?"No rules have been added !":j,R=S.noRulesDesc,q=void 0===R?"Start by adding rules that should apply across all stations.":R,w=S.noRulesButtonText,I=void 0===w?"Create New Rule":w,A=S.deleteRuleSuccessMessage,D=void 0===A?"Rule deleted successfully!":A,C=S.deleteVariantSuccessMessage,L=void 0===C?"Variant deleted successfully!":C,b=S.deleteRuleErrorMessage,N=void 0===b?"Failed to delete rule. Please try again.":b,P=S.deleteVariantErrorMessage,O=void 0===P?"Failed to delete variant. Please try again.":P,k=S.deleteModalTitle,E=void 0===k?"Delete":k,M=S.deleteRuleModalWarning,V=void 0===M?"This will permanently delete the rule configuration.":M,F=S.deleteVariantModalWarning,H=void 0===F?"This will permanently delete the variant configuration.":F,B=S.deleteConfirmText,J=void 0===B?"Delete":B,U=S.onRefreshRuleSets,G=S.app_integration_id,W=S.token,Q=S.modeId,$=r.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),z=r.useLearningTemplateStore(function(e){return e.scopeTreeData}),K=r.useLearningTemplateStore(function(e){return e.sidebarTab}),X=r.useLearningTemplateStore(function(e){return e.setInitialRules}),Y=r.useLearningTemplateStore(function(e){return e.currentRules}),Z=r.useLearningTemplateStore(function(e){return e.setRawAuditRuleData});r.useLearningTemplateStore(function(e){return e.createdVariantInfo});var ee=r.useLearningTemplateStore(function(e){return e.resetCreatedVariantInfo}),te=r.useLearningTemplateStore(function(e){return e.isILModalTriggered}),ne=r.useLearningTemplateStore(function(e){return e.setIsILModalTriggered}),re=n.useRef(null),ie=h.useConfigStore.getState().configuration,ae=n.useState(!1),oe=ae[0],le=ae[1],se=n.useState(null),ue=se[0],de=se[1],ce=n.useState(null),fe=ce[0],ve=ce[1],pe=n.useState(null),ge=pe[0],me=pe[1],Te=n.useState(null),_e=Te[0],he=Te[1],Se=n.useState(!1),ye=Se[0],je=Se[1],xe=n.useState(null),Re=xe[0],qe=xe[1],we=n.useState(!1),Ie=we[0],Ae=we[1],De=n.useState(""),Ce=De[0],Le=De[1],be=n.useState(null),Ne=be[0],Pe=be[1],Oe=n.useState(!1),ke=Oe[0],Ee=Oe[1],Me=n.useState(!1),Ve=Me[0],Fe=Me[1],He=n.useState("ruleDeletion"),Be=He[0],Je=He[1],Ue=n.useState(null),Ge=Ue[0],We=Ue[1],Qe=n.useState(!1),$e=Qe[0],ze=Qe[1],Ke=n.useState(!1),Xe=Ke[0],Ye=Ke[1],Ze=r.useLearningTemplateStore.getState().tiers,et=n.useState(null),tt=et[0],nt=et[1],rt=n.useState(null),it=rt[0],at=rt[1],ot=n.useState(null),lt=ot[0],st=ot[1],ut=function(){de(null),ve(null),le(!0),he(0)},dt=function(){le(!1),ne(!1),de(null),ve(null),me(null),he(null),Fe(!1),Ye(!1),ct(),nt(null),at(null),st(null),U&&U(!1,$||void 0)};n.useEffect(function(){ct()},[$,X]),n.useEffect(function(){te&&le(!0)},[te]);var ct=function(t){return void 0===t&&(t=!1),e.__awaiter(void 0,void 0,void 0,function(){var n,i,o,l,s,u,d,c,f,v,p,m,T,_,h,S,y,j,x;return e.__generator(this,function(R){switch(R.label){case 0:if(!$)return X([]),[2];t||je(!0),qe(null),R.label=1;case 1:return R.trys.push([1,3,4,5]),[4,a.getRulesInRuleSetById($,W)];case 2:return n=R.sent(),console.log("response==",n),(null==n?void 0:n.data)&&0!==Object.keys(n.data).length?(Z(n),i=n.data,console.log("rulesData==",i),o=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),l=Array.isArray(i.tiers)?e.__spreadArray([],i.tiers,!0).sort(function(e,t){var n,r;return(null!==(n=e.tier_priority)&&void 0!==n?n:0)-(null!==(r=t.tier_priority)&&void 0!==r?r:0)}).map(function(e){return[e.name,e.value]}):Object.entries(i).filter(function(e){var t=e[0],n=e[1];return!o.has(t)&&Array.isArray(n)}),s=l.map(function(e){var t=e[1];return new Set(t.flatMap(function(e){var t,n;return null!==(n=null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==n?n:[]}))}),u=s.flatMap(function(e){return Array.from(e)}),d=u.reduce(function(e,t){var n;return e[t]=(null!==(n=e[t])&&void 0!==n?n:0)+1,e},{}),c=new Set(Object.entries(d).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),f=function(t){return t.map(function(t){var n;return e.__assign(e.__assign({},t),{variants:null===(n=t.variants)||void 0===n?void 0:n.map(function(t){return e.__assign(e.__assign({},t),{isLinked:!!t.link_id&&c.has(t.link_id)})})})})},v=l.map(function(e,t){var n,r=e[0],i=e[1],a=Ze.find(function(e){return e.tier_name===r}),o=r.replace(/tier(\d+)/i,"tier_$1");return{id:null!==(n=null==a?void 0:a.tier_id)&&void 0!==n?n:String(t+1),name:o.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:i.length,description:0===t?"".concat(g.dt("tier.subtitle","These are the system-wide learnings applied across all stations.")):"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===t,rules:f(i)}}),(p=r.useLearningTemplateStore.getState().createdVariantInfo)&&p.length>0?(m=Object.fromEntries(l.map(function(e,t){return[e[0],String(t+1)]})),T=new Set(p.map(function(e){return m[e.tierName]}).filter(Boolean)),_=v.map(function(t){return e.__assign(e.__assign({},t),{isOpen:t.isOpen||T.has(t.id)})}),X(_),(h=null===(x=null===(j=null===(y=p[0])||void 0===y?void 0:y.variants)||void 0===j?void 0:j[0])||void 0===x?void 0:x.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(h,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return ee()},1e4)},500):ee()):X(v),[3,5]):(X([]),[2]);case 3:return S=R.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&qe((null==S?void 0:S.message)||"Failed to load rules. Please try again."),X([]),[3,5];case 4:return t||je(!1),[7];case 5:return[2]}})})},ft=$?f.findNodeById((null==z?void 0:z.data)||null,$):null,vt=ft?{ruleSetId:ft.id,ruleSetName:ft.name,ruleSetDesc:"",ruleCount:null===(y=null==ft?void 0:ft.metrics)||void 0===y?void 0:y.learningsCount}:void 0,pt=Boolean(null==z?void 0:z.data),gt=Boolean($&&!ft&&pt),mt=function(){if("stations"===K)return"custom";if(!ft)return"global";switch(ft.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},Tt=function(e){var n;if(!e)return t.jsx("p",{children:g.dt("".concat(_.TIER_DT_PATH,".deleteDialog.description"),"Are you sure you want to delete this rule? This action cannot be undone.")});var r=null==Y?void 0:Y.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return t.jsx("p",{children:g.dt("".concat(_.TIER_DT_PATH,".deleteDialog.description"),"Are you sure you want to delete ".concat(null==r?void 0:r.ruleTitle," rule? This action cannot be undone."),{rule_title:null!==(n=null==r?void 0:r.ruleTitle)&&void 0!==n?n:""})})},_t={editingRule:ue,editingTier:fe,editingVariants:ge,focusedVariantIndex:_e,setFocusedVariantIndex:he,triggerAddVariant:Ve,triggerFixGaps:Xe,copiedRule:tt,copiedSourceTier:it,copiedTargetTier:lt,initialDraftMessage:Ce,app_integration_id:G,modeId:Q};return vt?t.jsxs(t.Fragment,{children:[t.jsx(l.Toast,{ref:re}),t.jsx("div",e.__assign({className:v.default.container},{children:ye?t.jsx(o.default,{}):Re?t.jsx(u.default,{errorMessage:Re,onRetry:ct}):t.jsx(s.default,{onAddRule:ut,onDeleteRule:function(e){Pe(e)},onEditRule:function(e,t){de(e),ve(t||null),me(e.variants||null),he(null),Fe(!0),le(!0)},onEditVariant:function(e,t,n,r){var i,a,o,l,s=null!==(o=null===(a=null===(i=null==Y?void 0:Y.find(function(e){return e.name===n}))||void 0===i?void 0:i.rules)||void 0===a?void 0:a.find(function(e){return e.ruleId===t}))&&void 0!==o?o:null==Y?void 0:Y.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===t});if(s){var u=null===(l=s.variants)||void 0===l?void 0:l.findIndex(function(t){return t.variantId===e.variantId}),d=void 0!==u&&-1!==u?u:0;de(s),ve(n||null),me(s.variants||null),he(d),le(!0),"resolve_gaps"===r&&Ye(!0)}},onDeleteVariant:function(e,t){We({variantId:e,ruleId:t})},onExportRule:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,r,i,o,l,s,u;return e.__generator(this,function(e){switch(e.label){case 0:if(!$)return[2];Ae(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,a.exportRuleSet($)];case 2:return n=e.sent(),r=window.URL.createObjectURL(n),(i=document.createElement("a")).href=r,o=(null==vt?void 0:vt.ruleSetName)?"".concat(vt.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat($,".csv"),i.download=o,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(r),null===(s=re.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:v.default.successToast,content:t.jsx(d.default,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=e.sent(),console.error("Export error:",l),null===(u=re.current)||void 0===u||u.show({severity:"error",sticky:!1,className:v.default.errorToast,content:t.jsx(c.default,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Ae(!1),[7];case 5:return[2]}})})},isExporting:Ie,onToggleSuccess:function(){return ct(!0)},onReorderRules:function(n,r,i,o,l){return e.__awaiter(void 0,void 0,void 0,function(){var s,u,f;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a.alterQuestionPriority(n,r,i,o,l)];case 1:return e.sent(),ct(!0),null===(u=re.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:v.default.successToast,content:t.jsx(d.default,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return s=e.sent(),console.error("Failed to reorder rules:",s),ct(!0),null===(f=re.current)||void 0===f||f.show({severity:"error",sticky:!1,className:v.default.errorToast,content:t.jsx(c.default,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:U,setDeleteConfirmationUsedFor:Je,onCopyToTier:function(e,t,n,r,i){var a,o,l=null===(o=null===(a=null==Y?void 0:Y.find(function(e){return e.name===r}))||void 0===a?void 0:a.rules)||void 0===o?void 0:o.find(function(e){return e.ruleId===t});if(l){var s=["Add a new learning with the following details:","- Rule Title: ".concat(n),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(i)].join("\n");Le(s),nt(l),at(r),st(i),de(null),ve(null),me(null),he(null),le(!0)}}})})),oe&&t.jsx(m.CitationProvider,{children:t.jsx(T.default,{isOpen:oe,onClose:dt,app_integration_id:G,token:W,mode:"ADD",config:ie,pluginPayload:e.__assign(e.__assign({},_t),{initialScope:mt(),ruleSet:vt})})}),t.jsx(p.default,{isOpen:!!Ne,title:g.dt("".concat(_.LEARNING_DT_PATH,".deleteDialog.title"),E),description:Tt(Ne),warning:g.dt("".concat(_.LEARNING_DT_PATH,".deleteDialog.warningText"),V),confirmText:g.dt("".concat(_.LEARNING_DT_PATH,".deleteDialog.deleteText"),J),cancelText:g.dt("".concat(_.LEARNING_DT_PATH,".deleteDialog.cancelText"),"Cancel"),loadingText:g.dt("".concat(_.LEARNING_DT_PATH,".deleteDialog.loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,r,i,o,l;return e.__generator(this,function(e){switch(e.label){case 0:if(!Ne)return[2];Ee(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,a.deleteRule(Ne)];case 2:return e.sent(),Pe(null),null===(r=re.current)||void 0===r||r.show({severity:"success",sticky:!1,life:3e3,className:v.default.successToast,content:t.jsx(d.default,{message:D})}),ct(),U&&U(!1,$||void 0),[3,5];case 3:return n=e.sent(),console.error("Failed to delete rule",n),null===(i=re.current)||void 0===i||i.show({severity:"error",sticky:!1,className:v.default.errorToast,content:t.jsx(c.default,{message:(null===(l=null===(o=null==n?void 0:n.response)||void 0===o?void 0:o.data)||void 0===l?void 0:l.detail)||N})}),[3,5];case 4:return Ee(!1),[7];case 5:return[2]}})})},onCancel:function(){return Pe(null)},isLoading:ke}),t.jsx(p.default,{isOpen:!!Ge,title:g.dt("".concat(_.VARIANT_DT_PATH,".deleteVariant.title"),E),description:"variantDeletion"===Be?t.jsx("span",{children:g.dt("".concat(_.VARIANT_DT_PATH,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):Tt((null==Ge?void 0:Ge.ruleId)||null),warning:g.dt("".concat(_.VARIANT_DT_PATH,".deleteVariant.warningText"),"ruleDeletion"===Be?V:H),confirmText:g.dt("".concat(_.VARIANT_DT_PATH,".deleteDialog.deleteText"),J),cancelText:g.dt("".concat(_.VARIANT_DT_PATH,".cancelText"),"Cancel"),loadingText:g.dt("".concat(_.VARIANT_DT_PATH,".loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,r,i,o,l;return e.__generator(this,function(e){switch(e.label){case 0:if(!Ge)return[2];ze(!0),e.label=1;case 1:return e.trys.push([1,6,7,8]),"ruleDeletion"!==Be?[3,3]:[4,a.deleteQuestion(Ge.ruleId)];case 2:return e.sent(),[3,5];case 3:return[4,a.deleteRule(Ge.variantId)];case 4:e.sent(),e.label=5;case 5:return We(null),null===(r=re.current)||void 0===r||r.show({severity:"success",sticky:!1,life:3e3,className:v.default.successToast,content:t.jsx(d.default,{message:"ruleDeletion"===Be?D:L})}),ct(),U&&U(!1,$||void 0),[3,8];case 6:return n=e.sent(),console.error("Failed to delete variant",n),null===(i=re.current)||void 0===i||i.show({severity:"error",sticky:!1,className:v.default.errorToast,content:t.jsx(c.default,{message:(null===(l=null===(o=null==n?void 0:n.response)||void 0===o?void 0:o.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===Be?N:O)})}),[3,8];case 7:return ze(!1),[7];case 8:return[2]}})})},onCancel:function(){return We(null)},isLoading:$e})]}):gt?t.jsx(u.default,{title:"Scope Not Found",errorMessage:"The selected scope does not exist. Please refresh the page or choose a valid scope.",onRetry:function(){return null==U?void 0:U(!0)},retryButtonText:"Refresh"}):t.jsxs(t.Fragment,{children:[t.jsx(i.default,{onCreate:ut,title:x,desc:q,button:I}),oe&&t.jsx(m.CitationProvider,{children:t.jsx(T.default,{isOpen:oe,onClose:dt,app_integration_id:G,token:W,mode:"ADD",config:ie,pluginPayload:e.__assign(e.__assign({},_t),{initialScope:mt(),ruleSet:vt})})})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("../store/useLearningTemplateStore.js"),i=require("../components/EmptyLearningState.js"),a=require("../apis/scopeApis.js"),o=require("../components/RuleContentSkeleton.js"),l=require("primereact/toast"),s=require("./ContentLogic.js"),u=require("../components/ErrorStateDisplay.js"),d=require("../shared/SuccessToastContent.js"),c=require("../shared/ErrorToastContent.js"),f=require("../utils/treeUtils.js"),v=require("../styles/LearningContent.module.css.js"),p=require("../components/ConfirmationModal.js"),g=require("../store/useLMSConfigStore.js");require("../../IL-OTJ/_components/atoms/Textarea/Textarea.js"),require("lucide-react"),require("../../IL-OTJ/_components/InputDataReasoningCard.js"),require("../../IL-OTJ/_components/TooltipComponent.js"),require("../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js");var m=require("../../IL-OTJ/store/CitationsContext.js");require("@mui/material"),require("uuid"),require("@mui/material/Tooltip"),require("react-markdown"),require("rehype-raw"),require("axios"),require("@e-llm-studio/streaming-response"),require("@e-llm-studio/watch-me-work"),require("../../IL-OTJ/_components/ChatComponents/ChatHeader.js"),require("remark-gfm"),require("../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js"),require("../../IL-OTJ/_components/CitationLink.js"),require("@e-llm-studio/citation");var T=require("../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js"),_=require("../constants.js"),h=require("../store/useConfigStore.js");require("../store/usePermissionsStore.js"),require("appsec-ui"),require("../store/useAuthStore.js"),require("../store/useEnvStore.js"),require("@radix-ui/react-tooltip"),require("../components/StationOnboarding/InputField.js"),require("../config.js"),require("../store/useAppSecRolesStore.js"),require("@tanstack/react-query"),require("../components/ToolTip.js"),require("react-router-dom"),require("../LearningManagementTest.js");exports.default=function(S){var y,j=S.noRulesTitle,x=void 0===j?"No rules have been added !":j,R=S.noRulesDesc,w=void 0===R?"Start by adding rules that should apply across all stations.":R,I=S.noRulesButtonText,q=void 0===I?"Create New Rule":I,A=S.deleteRuleSuccessMessage,D=void 0===A?"Rule deleted successfully!":A,C=S.deleteVariantSuccessMessage,L=void 0===C?"Variant deleted successfully!":C,b=S.deleteRuleErrorMessage,N=void 0===b?"Failed to delete rule. Please try again.":b,P=S.deleteVariantErrorMessage,O=void 0===P?"Failed to delete variant. Please try again.":P,k=S.deleteModalTitle,E=void 0===k?"Delete":k,M=S.deleteRuleModalWarning,V=void 0===M?"This will permanently delete the rule configuration.":M,F=S.deleteVariantModalWarning,H=void 0===F?"This will permanently delete the variant configuration.":F,B=S.deleteConfirmText,J=void 0===B?"Delete":B,U=S.onRefreshRuleSets,G=S.app_integration_id,W=S.token,Q=S.modeId,$=r.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),z=r.useLearningTemplateStore(function(e){return e.scopeTreeData}),K=r.useLearningTemplateStore(function(e){return e.sidebarTab}),X=r.useLearningTemplateStore(function(e){return e.setInitialRules}),Y=r.useLearningTemplateStore(function(e){return e.currentRules}),Z=r.useLearningTemplateStore(function(e){return e.setRawAuditRuleData});r.useLearningTemplateStore(function(e){return e.createdVariantInfo});var ee=r.useLearningTemplateStore(function(e){return e.resetCreatedVariantInfo}),te=r.useLearningTemplateStore(function(e){return e.isILModalTriggered}),ne=r.useLearningTemplateStore(function(e){return e.setIsILModalTriggered}),re=n.useRef(null),ie=h.useConfigStore.getState().configuration,ae=n.useState(!1),oe=ae[0],le=ae[1],se=n.useState(null),ue=se[0],de=se[1],ce=n.useState(null),fe=ce[0],ve=ce[1],pe=n.useState(null),ge=pe[0],me=pe[1],Te=n.useState(null),_e=Te[0],he=Te[1],Se=n.useState(!1),ye=Se[0],je=Se[1],xe=n.useState(null),Re=xe[0],we=xe[1],Ie=n.useState(!1),qe=Ie[0],Ae=Ie[1],De=n.useState(""),Ce=De[0],Le=De[1],be=n.useState(null),Ne=be[0],Pe=be[1],Oe=n.useState(!1),ke=Oe[0],Ee=Oe[1],Me=n.useState(!1),Ve=Me[0],Fe=Me[1],He=n.useState("ruleDeletion"),Be=He[0],Je=He[1],Ue=n.useState(null),Ge=Ue[0],We=Ue[1],Qe=n.useState(!1),$e=Qe[0],ze=Qe[1],Ke=n.useState(!1),Xe=Ke[0],Ye=Ke[1],Ze=r.useLearningTemplateStore.getState().tiers,et=n.useState(null),tt=et[0],nt=et[1],rt=n.useState(null),it=rt[0],at=rt[1],ot=n.useState(null),lt=ot[0],st=ot[1],ut=function(){de(null),ve(null),le(!0),he(0)},dt=function(){le(!1),ne(!1),de(null),ve(null),me(null),he(null),Fe(!1),Ye(!1),ct(),nt(null),at(null),st(null),U&&U(!1,$||void 0)};n.useEffect(function(){ct()},[$,X]),n.useEffect(function(){te&&le(!0)},[te]);var ct=function(t){return void 0===t&&(t=!1),e.__awaiter(void 0,void 0,void 0,function(){var n,i,o,l,s,u,d,c,f,v,p,m,T,_,h,S,y,j,x;return e.__generator(this,function(R){switch(R.label){case 0:if(!$)return X([]),[2];t||je(!0),we(null),R.label=1;case 1:return R.trys.push([1,3,4,5]),[4,a.getRulesInRuleSetById($,W)];case 2:return n=R.sent(),console.log("response==",n),(null==n?void 0:n.data)&&0!==Object.keys(n.data).length?(Z(n),i=n.data,console.log("rulesData==",i),o=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),l=Array.isArray(i.tiers)?e.__spreadArray([],i.tiers,!0).sort(function(e,t){var n,r;return(null!==(n=e.tier_priority)&&void 0!==n?n:0)-(null!==(r=t.tier_priority)&&void 0!==r?r:0)}).map(function(e){return[e.name,e.value]}):Object.entries(i).filter(function(e){var t=e[0],n=e[1];return!o.has(t)&&Array.isArray(n)}),s=l.map(function(e){var t=e[1];return new Set(t.flatMap(function(e){var t,n;return null!==(n=null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==n?n:[]}))}),u=s.flatMap(function(e){return Array.from(e)}),d=u.reduce(function(e,t){var n;return e[t]=(null!==(n=e[t])&&void 0!==n?n:0)+1,e},{}),c=new Set(Object.entries(d).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),f=function(t){return t.map(function(t){var n;return e.__assign(e.__assign({},t),{variants:null===(n=t.variants)||void 0===n?void 0:n.map(function(t){return e.__assign(e.__assign({},t),{isLinked:!!t.link_id&&c.has(t.link_id)})})})})},v=l.map(function(e,t){var n,r=e[0],i=e[1],a=Ze.find(function(e){return e.tier_name===r}),o=r.replace(/tier(\d+)/i,"tier_$1");return{id:null!==(n=null==a?void 0:a.tier_id)&&void 0!==n?n:String(t+1),name:o.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:i.length,description:0===t?"".concat(g.dt("tier.subtitle","These are the system-wide learnings applied across all stations.")):"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===t,rules:f(i)}}),(p=r.useLearningTemplateStore.getState().createdVariantInfo)&&p.length>0?(m=Object.fromEntries(l.map(function(e,t){return[e[0],String(t+1)]})),T=new Set(p.map(function(e){return m[e.tierName]}).filter(Boolean)),_=v.map(function(t){return e.__assign(e.__assign({},t),{isOpen:t.isOpen||T.has(t.id)})}),X(_),(h=null===(x=null===(j=null===(y=p[0])||void 0===y?void 0:y.variants)||void 0===j?void 0:j[0])||void 0===x?void 0:x.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(h,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return ee()},1e4)},500):ee()):X(v),[3,5]):(X([]),[2]);case 3:return S=R.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&we((null==S?void 0:S.message)||"Failed to load rules. Please try again."),X([]),[3,5];case 4:return t||je(!1),[7];case 5:return[2]}})})},ft=$?f.findNodeById((null==z?void 0:z.data)||null,$):null,vt=ft?{ruleSetId:ft.id,ruleSetName:ft.name,ruleSetDesc:"",ruleCount:null===(y=null==ft?void 0:ft.metrics)||void 0===y?void 0:y.learningsCount}:void 0,pt=Boolean(null==z?void 0:z.data),gt=Boolean($&&!ft&&pt),mt=function(){if("stations"===K)return"custom";if(!ft)return"global";switch(ft.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},Tt=function(e){var n;if(!e)return t.jsx("p",{children:g.dt("".concat(_.TIER_DT_PATH,".deleteDialog.description"),"Are you sure you want to delete this rule? This action cannot be undone.")});var r=null==Y?void 0:Y.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return t.jsx("p",{children:g.dt("".concat(_.TIER_DT_PATH,".deleteDialog.description"),"Are you sure you want to delete ".concat(null==r?void 0:r.ruleTitle," rule? This action cannot be undone."),{rule_title:null!==(n=null==r?void 0:r.ruleTitle)&&void 0!==n?n:""})})},_t={editingRule:ue,editingTier:fe,editingVariants:ge,focusedVariantIndex:_e,setFocusedVariantIndex:he,triggerAddVariant:Ve,triggerFixGaps:Xe,copiedRule:tt,copiedSourceTier:it,copiedTargetTier:lt,initialDraftMessage:Ce,app_integration_id:G,modeId:Q};return vt?t.jsxs(t.Fragment,{children:[t.jsx(l.Toast,{ref:re}),t.jsx("div",e.__assign({className:v.default.container},{children:ye?t.jsx(o.default,{}):Re?t.jsx(u.default,{errorMessage:Re,onRetry:ct}):t.jsx(s.default,{onAddRule:ut,onDeleteRule:function(e){Pe(e)},onEditRule:function(e,t){de(e),ve(t||null),me(e.variants||null),he(null),Fe(!0),le(!0)},onEditVariant:function(e,t,n,r){var i,a,o,l,s=null!==(o=null===(a=null===(i=null==Y?void 0:Y.find(function(e){return e.name===n}))||void 0===i?void 0:i.rules)||void 0===a?void 0:a.find(function(e){return e.ruleId===t}))&&void 0!==o?o:null==Y?void 0:Y.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===t});if(s){var u=null===(l=s.variants)||void 0===l?void 0:l.findIndex(function(t){return t.variantId===e.variantId}),d=void 0!==u&&-1!==u?u:0;de(s),ve(n||null),me(s.variants||null),he(d),le(!0),"resolve_gaps"===r&&Ye(!0)}},onDeleteVariant:function(e,t){We({variantId:e,ruleId:t})},onExportRule:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,r,i,o,l,s,u;return e.__generator(this,function(e){switch(e.label){case 0:if(!$)return[2];Ae(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,a.exportRuleSet($)];case 2:return n=e.sent(),r=window.URL.createObjectURL(n),(i=document.createElement("a")).href=r,o=(null==vt?void 0:vt.ruleSetName)?"".concat(vt.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat($,".csv"),i.download=o,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(r),null===(s=re.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:v.default.successToast,content:t.jsx(d.default,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=e.sent(),console.error("Export error:",l),null===(u=re.current)||void 0===u||u.show({severity:"error",sticky:!1,className:v.default.errorToast,content:t.jsx(c.default,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Ae(!1),[7];case 5:return[2]}})})},isExporting:qe,onToggleSuccess:function(){return ct(!0)},onReorderRules:function(n,r,i,o,l){return e.__awaiter(void 0,void 0,void 0,function(){var s,u,f;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a.alterQuestionPriority(n,r,i,o,l)];case 1:return e.sent(),ct(!0),null===(u=re.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:v.default.successToast,content:t.jsx(d.default,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return s=e.sent(),console.error("Failed to reorder rules:",s),ct(!0),null===(f=re.current)||void 0===f||f.show({severity:"error",sticky:!1,className:v.default.errorToast,content:t.jsx(c.default,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:U,setDeleteConfirmationUsedFor:Je,onCopyToTier:function(e,t,n,r,i){var a,o,l=null===(o=null===(a=null==Y?void 0:Y.find(function(e){return e.name===r}))||void 0===a?void 0:a.rules)||void 0===o?void 0:o.find(function(e){return e.ruleId===t});if(l){var s=["Add a new learning with the following details:","- Rule Title: ".concat(n),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(i)].join("\n");Le(s),nt(l),at(r),st(i),de(null),ve(null),me(null),he(null),le(!0)}}})})),oe&&t.jsx(m.CitationProvider,{children:t.jsx(T.default,{isOpen:oe,onClose:dt,app_integration_id:G,token:W,mode:"ADD",config:ie,pluginPayload:e.__assign(e.__assign({},_t),{initialScope:mt(),ruleSet:vt})})}),t.jsx(p.default,{isOpen:!!Ne,title:g.dt("".concat(_.LEARNING_DT_PATH,".deleteDialog.title"),E),description:Tt(Ne),warning:g.dt("".concat(_.LEARNING_DT_PATH,".deleteDialog.warningText"),V),confirmText:g.dt("".concat(_.LEARNING_DT_PATH,".deleteDialog.deleteText"),J),cancelText:g.dt("".concat(_.LEARNING_DT_PATH,".deleteDialog.cancelText"),"Cancel"),loadingText:g.dt("".concat(_.LEARNING_DT_PATH,".deleteDialog.loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,r,i,o,l;return e.__generator(this,function(e){switch(e.label){case 0:if(!Ne)return[2];Ee(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,a.deleteRule(Ne)];case 2:return e.sent(),Pe(null),null===(r=re.current)||void 0===r||r.show({severity:"success",sticky:!1,life:3e3,className:v.default.successToast,content:t.jsx(d.default,{message:D})}),ct(),U&&U(!1,$||void 0),[3,5];case 3:return n=e.sent(),console.error("Failed to delete rule",n),null===(i=re.current)||void 0===i||i.show({severity:"error",sticky:!1,className:v.default.errorToast,content:t.jsx(c.default,{message:(null===(l=null===(o=null==n?void 0:n.response)||void 0===o?void 0:o.data)||void 0===l?void 0:l.detail)||N})}),[3,5];case 4:return Ee(!1),[7];case 5:return[2]}})})},onCancel:function(){return Pe(null)},isLoading:ke}),t.jsx(p.default,{isOpen:!!Ge,title:g.dt("".concat(_.VARIANT_DT_PATH,".deleteVariant.title"),E),description:"variantDeletion"===Be?t.jsx("span",{children:g.dt("".concat(_.VARIANT_DT_PATH,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):Tt((null==Ge?void 0:Ge.ruleId)||null),warning:g.dt("".concat(_.VARIANT_DT_PATH,".deleteVariant.warningText"),"ruleDeletion"===Be?V:H),confirmText:g.dt("".concat(_.VARIANT_DT_PATH,".deleteDialog.deleteText"),J),cancelText:g.dt("".concat(_.VARIANT_DT_PATH,".cancelText"),"Cancel"),loadingText:g.dt("".concat(_.VARIANT_DT_PATH,".loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,r,i,o,l;return e.__generator(this,function(e){switch(e.label){case 0:if(!Ge)return[2];ze(!0),e.label=1;case 1:return e.trys.push([1,6,7,8]),"ruleDeletion"!==Be?[3,3]:[4,a.deleteQuestion(Ge.ruleId)];case 2:return e.sent(),[3,5];case 3:return[4,a.deleteRule(Ge.variantId)];case 4:e.sent(),e.label=5;case 5:return We(null),null===(r=re.current)||void 0===r||r.show({severity:"success",sticky:!1,life:3e3,className:v.default.successToast,content:t.jsx(d.default,{message:"ruleDeletion"===Be?D:L})}),ct(),U&&U(!1,$||void 0),[3,8];case 6:return n=e.sent(),console.error("Failed to delete variant",n),null===(i=re.current)||void 0===i||i.show({severity:"error",sticky:!1,className:v.default.errorToast,content:t.jsx(c.default,{message:(null===(l=null===(o=null==n?void 0:n.response)||void 0===o?void 0:o.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===Be?N:O)})}),[3,8];case 7:return ze(!1),[7];case 8:return[2]}})})},onCancel:function(){return We(null)},isLoading:$e})]}):gt?t.jsx(u.default,{title:"Scope Not Found",errorMessage:"The selected scope does not exist. Please refresh the page or choose a valid scope.",onRetry:function(){return null==U?void 0:U(!0)},retryButtonText:"Refresh"}):t.jsxs(t.Fragment,{children:[t.jsx(i.default,{onCreate:ut,title:x,desc:w,button:q}),oe&&t.jsx(m.CitationProvider,{children:t.jsx(T.default,{isOpen:oe,onClose:dt,app_integration_id:G,token:W,mode:"ADD",config:ie,pluginPayload:e.__assign(e.__assign({},_t),{initialScope:mt(),ruleSet:vt})})})]})};
2
2
  //# sourceMappingURL=RuleContent.js.map