@e-llm-studio/instant-learning 0.0.296 → 0.0.297

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("react"),s=require("lucide-react"),r=require("./TooltipComponent.js");exports.default=function(t){var o,d,l=t.title,a=t.subtitle,p=t.children,x=t.defaultOpen,c=void 0===x||x,g=t.footerData,f=t.readOnly,u=void 0!==f&&f,h=t.variant,_=void 0===h?"default":h,v=t.expanded,j=t.onToggle,y=t.actionButtons,b=t.isAiStreaming,F=t.editFlow,m=void 0!==F&&F,w=n.useState(c),C=w[0],D=w[1];n.useEffect(function(){D(c)},[c]);var E=void 0!==v,S=E?v:C,z=function(){E?null==j||j():D(!S)},k="variant"===l.type,I="other"===l.type,B="tier-header"===_,R="rule-behavior"===_,T={padding:"12px 14px 0px 14px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",borderRadius:B?"0px":"8px",borderBottom:B?"1px solid #E2E8F0":"none"},A={alignItems:"center",gap:"8px",margin:0,fontSize:"12px",fontWeight:600,padding:I?"":"6px 10px",borderRadius:"4px",color:u?"#717b8c":B&&S?"#2563EB":"#19213D",backgroundColor:R&&!l.isNewVariant?"#F7F8FA":k?"#FDF2F8":l.isDefault?"#F7F8FA":"transparent",border:k?"1px solid #FCE7F3":l.isDefault?"1px solid #F0F2F5":"none"},W={fontSize:"12px",fontWeight:400,color:"#666F8D",paddingLeft:I?"0px":"10px"},q={badge:{display:"inline-flex",alignItems:"center",gap:"8px",backgroundColor:"#f0fdf4",color:"#367c46",padding:"6px 10px",borderRadius:"8px",border:"1px solid #e1f6e8",fontSize:"12px",fontWeight:"600",lineHeight:"1.2",width:"fit-content"},defaultTag:{backgroundColor:"#f0f4f8",color:"#475569",fontSize:"11px",fontWeight:"600",padding:"2px 8px",borderRadius:"4px",textTransform:"uppercase",border:"1px solid #cbd5e1"},modifiedTag:{boxSizing:"border-box",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",padding:"2px 8px",backgroundColor:"#FFFAE3",border:"1px solid #FDEDAA",borderRadius:"4px",color:"#854D0E",fontSize:"11px",fontWeight:"700",letterSpacing:"0.5px"}},L={width:"100%",backgroundColor:"#ffffff",overflow:"hidden",border:B?"none":R&&S?"1px solid #2563EB":"1px solid #E2E8F0",borderRadius:"8px",marginBottom:"0px"};return i.jsxs("div",e.__assign({style:L},{children:[i.jsxs("div",e.__assign({onClick:z,style:T},{children:[i.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"4px",margin:0,fontSize:"12px",fontWeight:600,borderRadius:"4px"}},{children:[!l.isNewVariant&&i.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[i.jsx("div",e.__assign({style:A},{children:l.label})),l.isDefault&&i.jsx("span",e.__assign({style:q.defaultTag},{children:"Default"})),l.isModified&&i.jsx("span",e.__assign({style:q.modifiedTag},{children:"MODIFIED"}))]})),i.jsx("div",{children:l.isNewVariant&&i.jsxs("div",e.__assign({style:q.badge},{children:[i.jsx("svg",e.__assign({width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},{children:i.jsx("path",{d:"M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"})})),i.jsx("div",{children:"New Variant"})]}))}),a&&i.jsx("div",e.__assign({style:W},{children:a}))]})),i.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"12px",paddingRight:"4px"}},{children:[y&&!b&&(m?i.jsx(r.default,e.__assign({description:"Coming Soon"},{children:i.jsx("div",e.__assign({onClick:function(e){return e.stopPropagation()},style:{cursor:"not-allowed",opacity:.6}},{children:i.jsx("div",e.__assign({style:{pointerEvents:"none"}},{children:y(S,function(){})}))}))})):i.jsx("div",e.__assign({onClick:function(e){return e.stopPropagation()}},{children:y(S,z)}))),i.jsx("div",e.__assign({onClick:z,style:{cursor:"pointer",display:"flex",alignItems:"center"}},{children:S?i.jsx(s.ChevronUp,{size:18,color:B?"#2563EB":"#64748B"}):i.jsx(s.ChevronDown,{size:18,color:"#64748B"})}))]}))]})),!S&&g&&i.jsx("div",e.__assign({style:{fontSize:"12px",color:"#475569",fontWeight:400,padding:"0 16px 12px 16px",display:"flex",alignItems:"center",gap:"8px"}},{children:I?i.jsxs(i.Fragment,{children:[i.jsx("span",e.__assign({style:{fontWeight:500,color:"#475569"}},{children:g.ruleTitle||"No Title"})),(null!==(d=null===(o=g.tiers)||void 0===o?void 0:o.length)&&void 0!==d?d:0)>0&&i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{width:"4px",height:"4px",backgroundColor:"#676970",borderRadius:"50%"}}),i.jsx("span",{children:Array.isArray(g.tiers)?g.tiers.join(", "):g.tiers})]})]}):i.jsx("span",e.__assign({style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:g.description}))})),S&&i.jsx("div",e.__assign({style:{padding:"12px"}},{children:p}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),n=require("react"),s=require("lucide-react"),r=require("./TooltipComponent.js");exports.default=function(t){var o,d,l=t.title,a=t.subtitle,p=t.children,x=t.defaultOpen,c=void 0===x||x,g=t.footerData,f=t.readOnly,u=void 0!==f&&f,h=t.variant,_=void 0===h?"default":h,v=t.expanded,j=t.onToggle,y=t.actionButtons,b=t.isAiStreaming,F=t.editFlow,m=void 0!==F&&F,w=n.useState(c),C=w[0],D=w[1];n.useEffect(function(){D(c)},[c]);var E=void 0!==v,S=E?v:C,z=function(){E?null==j||j():D(!S)},k="variant"===l.type,I="other"===l.type,B="tier-header"===_,R="rule-behavior"===_,A={padding:"12px 14px 0px 14px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",borderRadius:B?"0px":"8px",borderBottom:B?"1px solid #E2E8F0":"none"},T={alignItems:"center",gap:"8px",margin:0,fontSize:"12px",fontWeight:600,padding:I?"":"6px 10px",borderRadius:"4px",color:u?"#717b8c":B&&S?"#2563EB":"#19213D",backgroundColor:R&&!l.isNewVariant?"#F7F8FA":k?"#FDF2F8":l.isDefault?"#F7F8FA":"transparent",border:k?"1px solid #FCE7F3":l.isDefault?"1px solid #F0F2F5":"none"},W={fontSize:"12px",fontWeight:400,color:"#666F8D",paddingLeft:I?"0px":"10px"},q={badge:{display:"inline-flex",alignItems:"center",gap:"8px",backgroundColor:"#f0fdf4",color:"#367c46",padding:"6px 10px",borderRadius:"8px",border:"1px solid #e1f6e8",fontSize:"12px",fontWeight:"600",lineHeight:"1.2",width:"fit-content"},defaultTag:{backgroundColor:"#f0f4f8",color:"#475569",fontSize:"11px",fontWeight:"600",padding:"2px 8px",borderRadius:"4px",textTransform:"uppercase",border:"1px solid #cbd5e1"},modifiedTag:{boxSizing:"border-box",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",padding:"2px 8px",backgroundColor:"#FFFAE3",border:"1px solid #FDEDAA",borderRadius:"4px",color:"#854D0E",fontSize:"11px",fontWeight:"700",letterSpacing:"0.5px"}},L={width:"100%",backgroundColor:"#ffffff",overflow:"hidden",border:B?"none":R&&S?"1px solid #2563EB":"1px solid #E2E8F0",borderRadius:"8px",marginBottom:"0px"};return i.jsxs("div",e.__assign({style:L},{children:[i.jsxs("div",e.__assign({onClick:z,style:A},{children:[i.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"4px",margin:0,fontSize:"12px",fontWeight:600,borderRadius:"4px"}},{children:[!l.isNewVariant&&i.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[i.jsx("div",e.__assign({style:T},{children:l.label})),l.isDefault&&i.jsx("span",e.__assign({style:q.defaultTag},{children:"Default"})),l.isModified&&i.jsx("span",e.__assign({style:q.modifiedTag},{children:"MODIFIED"}))]})),i.jsx("div",{children:l.isNewVariant&&i.jsxs("div",e.__assign({style:q.badge},{children:[i.jsx("svg",e.__assign({width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},{children:i.jsx("path",{d:"M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"})})),i.jsx("div",{children:"New Variant"})]}))}),a&&i.jsx("div",e.__assign({style:W},{children:a}))]})),i.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"12px",paddingRight:"4px"}},{children:[y&&!b&&(m?i.jsx(r.default,e.__assign({description:"Coming Soon"},{children:i.jsx("div",e.__assign({onClick:function(e){return e.stopPropagation()},style:{cursor:"not-allowed",opacity:.6}},{children:i.jsx("div",e.__assign({style:{pointerEvents:"none"}},{children:y(S,function(){})}))}))})):i.jsx("div",e.__assign({onClick:function(e){return e.stopPropagation()}},{children:y(S,z)}))),i.jsx("div",e.__assign({onClick:z,style:{cursor:"pointer",display:"flex",alignItems:"center"}},{children:S?i.jsx(s.ChevronUp,{size:18,color:B?"#2563EB":"#64748B"}):i.jsx(s.ChevronDown,{size:18,color:"#64748B"})}))]}))]})),!S&&g&&i.jsx("div",e.__assign({style:{fontSize:"12px",color:"#475569",fontWeight:400,padding:"0 16px 12px 16px",display:"flex",alignItems:"center",gap:"8px"}},{children:I?i.jsxs(i.Fragment,{children:[i.jsx("span",e.__assign({style:{fontWeight:500,color:"#475569"}},{children:g.ruleTitle||""})),(null!==(d=null===(o=g.tiers)||void 0===o?void 0:o.length)&&void 0!==d?d:0)>0&&i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{width:"4px",height:"4px",backgroundColor:"#676970",borderRadius:"50%"}}),i.jsx("span",{children:Array.isArray(g.tiers)?g.tiers.join(", "):g.tiers})]})]}):i.jsx("span",e.__assign({style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:g.description}))})),S&&i.jsx("div",e.__assign({style:{padding:"12px"}},{children:p}))]}))};
2
2
  //# sourceMappingURL=AccordianSection.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),s=require("../../molecules/Sections/SectionWrapper.js"),n=require("../../_svg/CognitiveDecisioning.js"),t=require("lucide-react"),o=require("../../TooltipComponent.js");exports.ScopeSection=function(r){var l=r.id,a=r.title,c=void 0===a?"Scope":a,d=r.required,p=void 0!==d&&d,g=r.openSections,x=r.setOpenSections,h=r.scopeData,u=r.onScopeChange;r.stationOptions;var v=r.tierOptions,_=void 0===v?[]:v;r.stationLabel;var y=r.tierLabel,f=void 0===y?"Where should this rule apply?":y,j=r.highlights,m=void 0===j?{}:j,b=r.isOpen,C=r.onToggle,w=r.showCognitiveIcon,S=r.cognitiveIcon,k=r.tooltipDescription,O=r.errorMessage,I=r.stationErrorMessage,L=r.tierErrorMessage,q=e.__rest(r,["id","title","required","openSections","setOpenSections","scopeData","onScopeChange","stationOptions","tierOptions","stationLabel","tierLabel","highlights","isOpen","onToggle","showCognitiveIcon","cognitiveIcon","tooltipDescription","errorMessage","stationErrorMessage","tierErrorMessage"]);return i.jsx(s.SectionWrapper,e.__assign({id:l,title:c,required:p,openSections:g,setOpenSections:x},q,{children:i.jsxs("div",e.__assign({className:"scope-content"},{children:[_.length>0&&i.jsxs("div",e.__assign({className:"form-group"},{children:[i.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"4px",marginBottom:"4px"}},{children:[i.jsx("span",e.__assign({style:{color:"#8F2C23",lineHeight:1}},{children:"*"})),i.jsx("label",e.__assign({className:(null==q?void 0:q.readOnly)?"readOnly":"form-label",style:{margin:0}},{children:f}))]})),i.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}},{children:[i.jsx("div",e.__assign({className:"checkbox-group",style:{display:"flex",gap:"16px"}},{children:_.map(function(s){var n,t,o=m["scope_".concat(s)],r="tier-".concat(l,"-").concat(s.replace(/\s+/g,"-").toLowerCase());return i.jsxs("div",e.__assign({className:"checkbox-item",style:{display:"flex",alignItems:"center",gap:"6px",position:"relative"}},{children:[i.jsx("input",{type:"checkbox",id:r,checked:null===(n=h.tiers)||void 0===n?void 0:n.includes(s),onChange:function(){var i=h.tiers||[],n=i.includes(s)?i.filter(function(e){return e!==s}):e.__spreadArray(e.__spreadArray([],i,!0),[s],!1);u("tiers",n)},disabled:(null==q?void 0:q.readOnly)||!1,style:{position:"absolute",opacity:0,cursor:"pointer",width:"16px",height:"16px",zIndex:1}}),i.jsx("div",e.__assign({style:{width:"16px",height:"16px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",boxShadow:o?"0 0 14px 4px rgba(37, 99, 235, 0.35)":"none"}},{children:(null===(t=h.tiers)||void 0===t?void 0:t.includes(s))?i.jsxs("svg",e.__assign({width:"16",height:"16",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[i.jsx("path",{d:"M4 0.25H10C12.0711 0.25 13.75 1.92893 13.75 4V10C13.75 12.0711 12.0711 13.75 10 13.75H4C1.92893 13.75 0.25 12.0711 0.25 10V4C0.25 1.92893 1.92893 0.25 4 0.25Z",fill:"#2563EB",stroke:"#2563EB","stroke-width":"0.5"}),i.jsx("path",{d:"M4 7L6 9L10 5",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})):i.jsx("div",{style:{width:"14px",height:"14px",border:"1px solid #64748B",borderRadius:"4px",backgroundColor:"white"}})})),i.jsx("label",e.__assign({style:{color:(null==q?void 0:q.readOnly)?"#9CA3AF":void 0,cursor:(null==q?void 0:q.readOnly)?"not-allowed":"pointer",margin:0,fontSize:"14px"},htmlFor:"tier-".concat(l,"-").concat(s.toLowerCase().replace(/\s+/g,"-"))},{children:s}))]}),r)})})),i.jsx("div",e.__assign({style:{width:"fit-content"}},{children:i.jsx(o.default,e.__assign({description:null!=k?k:""},{children:w&&i.jsxs("button",e.__assign({onClick:function(e){e.preventDefault(),null==C||C()},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"2px",padding:"2px 6px ",flexShrink:0,border:"none",backgroundColor:"transparent",borderRadius:"4px",cursor:"pointer",outline:"none",maxWidth:"fit-content",transition:"background-color 0.2s ease",marginTop:"6px",marginLeft:"6px"}},{children:[S||i.jsx(n.default,{}),b?i.jsx(t.ChevronUpIcon,{size:16}):i.jsx(t.ChevronDownIcon,{size:16})]}))}))}))]})),L&&i.jsx("div",e.__assign({style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"}},{children:L}))]})),O&&!I&&!L&&i.jsx("div",e.__assign({style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"}},{children:O}))]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),s=require("../../molecules/Sections/SectionWrapper.js"),n=require("../../_svg/CognitiveDecisioning.js"),o=require("lucide-react"),t=require("../../TooltipComponent.js");exports.ScopeSection=function(r){var l=r.id,a=r.title,c=void 0===a?"Scope":a,d=r.required,p=void 0!==d&&d,g=r.openSections,x=r.setOpenSections,h=r.scopeData,u=r.onScopeChange;r.stationOptions;var v=r.tierOptions,_=void 0===v?[]:v;r.stationLabel;var b=r.tierLabel,y=void 0===b?"Where should this rule apply?":b,j=r.highlights,f=void 0===j?{}:j,m=r.isOpen,S=r.onToggle,C=r.showCognitiveIcon,O=r.cognitiveIcon,w=r.tooltipDescription,I=r.errorMessage,k=r.stationErrorMessage,q=r.tierErrorMessage,z=e.__rest(r,["id","title","required","openSections","setOpenSections","scopeData","onScopeChange","stationOptions","tierOptions","stationLabel","tierLabel","highlights","isOpen","onToggle","showCognitiveIcon","cognitiveIcon","tooltipDescription","errorMessage","stationErrorMessage","tierErrorMessage"]);return i.jsx(s.SectionWrapper,e.__assign({id:l,title:c,required:p,openSections:g,setOpenSections:x},z,{children:i.jsxs("div",e.__assign({className:"scope-content"},{children:[_.length>0&&i.jsxs("div",e.__assign({className:"form-group"},{children:[i.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"4px",marginBottom:"4px"}},{children:[i.jsx("span",e.__assign({style:{color:"#8F2C23",lineHeight:1}},{children:"*"})),i.jsx("label",e.__assign({className:(null==z?void 0:z.readOnly)?"readOnly":"form-label",style:{margin:0}},{children:y}))]})),i.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}},{children:[i.jsx("div",e.__assign({className:"checkbox-group",style:{display:"flex",gap:"16px"}},{children:_.map(function(s){var n,o,t=f["scope_".concat(s)],r="tier-".concat(l,"-").concat(s.replace(/\s+/g,"-").toLowerCase());return i.jsxs("div",e.__assign({className:"checkbox-item",style:{display:"flex",alignItems:"center",gap:"6px",position:"relative"}},{children:[i.jsx("input",{type:"radio",name:"scope-tiers-".concat(l),id:r,checked:null===(n=h.tiers)||void 0===n?void 0:n.includes(s),onChange:function(){u("tiers",[s])},disabled:(null==z?void 0:z.readOnly)||!1,style:{position:"absolute",opacity:0,cursor:"pointer",width:"16px",height:"16px",zIndex:1}}),i.jsx("div",e.__assign({style:{width:"16px",height:"16px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",boxShadow:t?"0 0 14px 4px rgba(37, 99, 235, 0.35)":"none",borderRadius:"50%"}},{children:(null===(o=h.tiers)||void 0===o?void 0:o.includes(s))?i.jsx("div",{style:{width:"16px",height:"16px",borderRadius:"50%",border:"5px solid #2563EB",backgroundColor:"white",boxSizing:"border-box"}}):i.jsx("div",{style:{width:"16px",height:"16px",border:"1px solid #64748B",borderRadius:"50%",backgroundColor:"white",boxSizing:"border-box"}})})),i.jsx("label",e.__assign({style:{color:(null==z?void 0:z.readOnly)?"#9CA3AF":void 0,cursor:(null==z?void 0:z.readOnly)?"not-allowed":"pointer",margin:0,fontSize:"14px"},htmlFor:r},{children:s}))]}),r)})})),i.jsx("div",e.__assign({style:{width:"fit-content"}},{children:i.jsx(t.default,e.__assign({description:null!=w?w:""},{children:C&&i.jsxs("button",e.__assign({onClick:function(e){e.preventDefault(),null==S||S()},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"2px",padding:"2px 6px ",flexShrink:0,border:"none",backgroundColor:"transparent",borderRadius:"4px",cursor:"pointer",outline:"none",maxWidth:"fit-content",transition:"background-color 0.2s ease",marginTop:"6px",marginLeft:"6px"}},{children:[O||i.jsx(n.default,{}),m?i.jsx(o.ChevronUpIcon,{size:16}):i.jsx(o.ChevronDownIcon,{size:16})]}))}))}))]})),q&&i.jsx("div",e.__assign({style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"}},{children:q}))]})),I&&!k&&!q&&i.jsx("div",e.__assign({style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"}},{children:I}))]}))}))};
2
2
  //# sourceMappingURL=ScopeSection.js.map
@@ -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"),o=require("../../organisms/ConditionSection/ConditionSection.js"),l=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(n){var t=n.children,o=n.onAddVariant,l=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:l?void 0:o,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:l?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:l?"not-allowed":"pointer",backgroundColor:l?"#f8fafc":"#FFFFFF",opacity:l?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))};exports.CreateRule=function(c){var g,f,h,x,y,_,T,S,m,D,C,I,A=c.state,j=c.handlers,b=c.uiState,O=(null==b?void 0:b.highlights)||new Map,E=O.get("global_0")||{},w=n.useState({}),R=w[0],V=w[1],N=n.useState(null),W=N[0],q=N[1],B="rule-setup"===(null==b?void 0:b.activeEditId),M=v.default.useRef(new Map),F=n.useState(null),k=F[0],L=F[1],z=n.useState(null),P=z[0],J=z[1],H=n.useState(!1),K=H[0],$=H[1],U=v.default.useRef(null==b?void 0:b.isAiStreaming);n.useEffect(function(){U.current&&!(null==b?void 0:b.isAiStreaming)&&K&&$(!1),U.current=null==b?void 0:b.isAiStreaming},[null==b?void 0:b.isAiStreaming,K]);var Z=function(){var i;L(null),J(null),null===(i=null==b?void 0:b.setActiveEditId)||void 0===i||i.call(b,null)},G=function(){var i,e,n=null!=k?k:A.ruleTitle,t=null!=P?P:A.scopeData,o=n!==A.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(A.scopeData);if(!o&&!l)return L(null),J(null),void(null===(i=null==b?void 0:b.setActiveEditId)||void 0===i||i.call(b,null));if(null==b?void 0:b.setSendMessageInChat){var a="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),r=[];if(o&&r.push((null==n?void 0:n.trim())?"Title with ".concat(n):"No Title"),l){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 ");b.setSendMessageInChat("__SKELETON__:".concat(a,":Update Rule Setup ").concat(u))}$(!0),L(null),J(null),null===(e=null==b?void 0:b.setActiveEditId)||void 0===e||e.call(b,null)},Q=null!==k?null==k?void 0:k.trim():(A.ruleTitle||"").trim(),X=null!=P?P:A.scopeData,Y=Q!==(A.ruleTitle||"").trim(),ii=JSON.stringify(X)!==JSON.stringify(A.scopeData),ei=!Y&&!ii||""===Q,ni=v.default.useRef(null==b?void 0:b.defaultVariantOpen),ti=v.default.useRef(null==b?void 0:b.activeVariantAccordionIndex),oi=v.default.useRef(null==b?void 0:b.defaultTierOpen),li=v.default.useRef(null===(g=A.scopeData)||void 0===g?void 0:g.tiers),ai=v.default.useRef(A.variantsByTier);v.default.useEffect(function(){var i,e,n,t,o,l,a=null,r=!1;ni.current!==(null==b?void 0:b.defaultVariantOpen)&&(r=!0,ni.current=null==b?void 0:b.defaultVariantOpen),ti.current!==(null==b?void 0:b.activeVariantAccordionIndex)&&(r=!0,ti.current=null==b?void 0:b.activeVariantAccordionIndex),oi.current!==(null==b?void 0:b.defaultTierOpen)&&(r=!0,oi.current=null==b?void 0:b.defaultTierOpen);var d=(null===(i=A.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(li.current)!==JSON.stringify(d)&&(r=!0,li.current=d);var s=(null===(e=null==b?void 0:b.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,o,l=i.toLowerCase().replace(/ /g,"_");return((null===(n=null===(e=ai.current)||void 0===e?void 0:e[l])||void 0===n?void 0:n.length)||0)!==((null===(o=null===(t=A.variantsByTier)||void 0===t?void 0:t[l])||void 0===o?void 0:o.length)||0)});if(u&&(r=!0),r){var c=null!==(n=null==b?void 0:b.activeVariantAccordionIndex)&&void 0!==n?n:null==b?void 0:b.defaultVariantOpen;if(null==c||c<0)return q(null),void(ai.current=A.variantsByTier);s.forEach(function(i,e){var n;if(!((null==b?void 0:b.defaultTierOpen)>=0&&e!==b.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(n=A.variantsByTier)||void 0===n?void 0:n[t])||[];o[c]&&(a="".concat(t,"-variant-").concat(c)),null!=(null==b?void 0:b.autoScrollVariantIndex)&&o[b.autoScrollVariantIndex]&&(a="".concat(t,"-variant-").concat(b.autoScrollVariantIndex))}}),a&&q(a)}if(null===W){var v=null!==(t=null==b?void 0:b.activeVariantAccordionIndex)&&void 0!==t?t:null==b?void 0:b.defaultVariantOpen;null!=v&&v>=0&&(null===(l=null===(o=null==b?void 0:b.tierOptions)||void 0===o?void 0:o.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===l||l.forEach(function(i,e){var n;if(!((null==b?void 0:b.defaultTierOpen)>=0&&e!==b.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=A.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&q("".concat(t,"-variant-").concat(v))}}))}ai.current=A.variantsByTier},[A.variantsByTier,null==b?void 0:b.defaultVariantOpen,null==b?void 0:b.activeVariantAccordionIndex,null===(f=A.scopeData)||void 0===f?void 0:f.tiers,null==b?void 0:b.tierOptions,null==b?void 0:b.autoScrollVariantIndex,null==b?void 0:b.defaultTierOpen]);var ri=function(e){V(function(n){var t;return i.__assign(i.__assign({},n),((t={})[e]=!n[e],t))})},di=function(i){var e,n,t,o=i.split("_"),l=o[o.length-1],a=/^\d+$/.test(l)?o.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:[]},si={marginTop:"-17px",position:"relative",zIndex:1};n.useEffect(function(){var i,e;null!=(null==b?void 0:b.autoScrollVariantIndex)&&(null===(e=null===(i=null==b?void 0:b.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(b.autoScrollVariantIndex),t=M.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==b?void 0:b.scrollTrigger]),console.log("CreateRule state:",A),console.log("CreateRule uiState:",b);var ui=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"},ci=!!(null==b?void 0:b.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==b?void 0:b.setupLabel)||"Rule Setup"},actionButtons:function(n,t){if(B)return null;var o=!!(null==b?void 0:b.activeEditId)&&"rule-setup"!==b.activeEditId;return e.jsx("div",i.__assign({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:e.jsx("button",i.__assign({title:o?"Save active edits first":"Edit",onClick:function(e){e.stopPropagation(),o?(null==b?void 0:b.setPendingEditId)&&b.setPendingEditId(b.activeEditId||null):(!function(){var e,n;(null==b?void 0:b.activeEditId)&&"rule-setup"!==b.activeEditId||(null===(e=null==b?void 0:b.setActiveEditId)||void 0===e||e.call(b,"rule-setup"),L(null!==(n=A.ruleTitle)&&void 0!==n?n:""),J(A.scopeData?i.__assign({},A.scopeData):{}))}(),(null==b?void 0:b.setPendingEditId)&&b.setPendingEditId(null),n||t())},disabled:K,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:K?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:K?.5:1}},{children:e.jsx(u.Pencil,{size:14})}))}))},footerData:{ruleTitle:A.ruleTitle,stations:[A.scopeData.station],tiers:null===(h=A.scopeData)||void 0===h?void 0:h.tiers},defaultOpen:"Create"===(null==b?void 0:b.usedFor),readOnly:"Create"!==(null==b?void 0:b.usedFor),isAiStreaming:null==b?void 0:b.isAiStreaming,editFlow:"Edit"===(null==b?void 0:b.usedFor)},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[K&&(null==b?void 0:b.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:b.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:B&&null!==k?k:A.ruleTitle,onChange:function(i){return B?L(i):j.setRuleTitle(i)},readOnly:(null==b?void 0:b.isAiStreaming)||!B,isOpen:R.ruleTitle,onToggle:function(){return ri("ruleTitle")},isHighlighted:E.ruleTitle||!1,showCognitiveIcon:A.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(x=b.validationErrors)||void 0===x?void 0:x.ruleTitle},b)),A.citation.ruleTitle&&e.jsx("div",i.__assign({style:si},{children:e.jsx(t.InputDataReasoningCard,{isVisible:R.ruleTitle,citation:A.citation.ruleTitle,citations:di("ruleTitle"),fieldName:"Rule Title",fieldValue:A.ruleTitle})})),e.jsx(a.ScopeSection,i.__assign({id:"scope",title:"",required:!1,scopeData:B&&null!==P?P:A.scopeData,onScopeChange:function(e,n){B?J(function(t){var o;return i.__assign(i.__assign({},null!=t?t:A.scopeData),((o={})[e]=n,o))}):j.onScopeChange(e,n)},tierLabel:"Which tiers should this learning apply to?",stationLabel:"Which scope should this learning belong to?",highlights:E,isOpen:R.scopeData,onToggle:function(){return ri("scopeData")},showCognitiveIcon:A.citation.scopeData,cognitiveIcon:e.jsx(s.ButtonCognitiveIcon,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(y=b.validationErrors)||void 0===y?void 0:y.station)||(null===(_=b.validationErrors)||void 0===_?void 0:_.tiers),stationErrorMessage:null===(T=b.validationErrors)||void 0===T?void 0:T.station,tierErrorMessage:null===(S=b.validationErrors)||void 0===S?void 0:S.tiers,readOnly:(null==b?void 0:b.isAiStreaming)||!B},b)),A.citation.scopeData&&e.jsx("div",i.__assign({style:si},{children:e.jsx(t.InputDataReasoningCard,{isVisible:R.scopeData,citation:A.citation.scopeData,citations:di("scopeData"),fieldName:"Scope",fieldValue:null===(D=null===(m=A.scopeData)||void 0===m?void 0:m.tiers)||void 0===D?void 0:D.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:Z,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e.jsxs("button",i.__assign({onClick:G,disabled:ei,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:ei?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:ei?.5:1}},{children:[e.jsx(u.Check,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==b?void 0:b.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===(I=null===(C=null==b?void 0:b.tierOptions)||void 0===C?void 0:C.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===I?void 0:I.map(function(n,a,s){var u,c,v,g,f=n.toLowerCase().replace(/ /g,"_"),h=(null===(u=A.variantsByTier)||void 0===u?void 0:u[f])||[],x=h.length,y=!1;if(1===x){var _=h[0],T=!(null===(c=null==_?void 0:_.ruleDescription)||void 0===c?void 0:c.trim()),S=(null===(v=null==_?void 0:_.whenToApplyConditions)||void 0===v?void 0:v.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,m=(null===(g=null==_?void 0:_.whenNotToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;T&&!S&&!m&&(y=!0)}var D=y?void 0:"".concat(x," ").concat(1===x?"variant":"variants"," configured for this tier"),C=!((null==b?void 0:b.defaultTierOpen)>=0)||a===b.defaultTierOpen;return console.log("Rendering tier : ",n),e.jsx(d.default,i.__assign({variant:"tier-header",title:{type:"other",label:n},subtitle:D,defaultOpen:C,footerData:{description:"Variants for ".concat(n)}},{children:e.jsx(p,i.__assign({onAddVariant:function(){var i;return null===(i=j.addNewVariant)||void 0===i?void 0:i.call(j,f)},isDisabled:null==b?void 0:b.isAiStreaming,showAddVariantBtn:"Edit"!==(null==b?void 0:b.usedFor)},{children:h.map(function(n,a){var s,u,c,v,p,g,h,x,y,_,T,S=n.variantType||"default",m="".concat(f,"-variant-").concat(a),D=!0===n.is_variant,C="default"===S||"default_variant"===S;(null==b?void 0:b.defaultVariantOpen)>=0&&b.defaultVariantOpen;var I="".concat(f,"_").concat(a),E=O.get(I)||{},w=(null===(u=null===(s=b.separationItemsByTier)||void 0===s?void 0:s[f])||void 0===u?void 0:u.get(a))||[],V=(null===(v=null===(c=b.togglesByTier)||void 0===c?void 0:c[f])||void 0===v?void 0:v.get(a))||[];(null==b?void 0:b.autoScrollVariantIndex)===a||n.is_variant,console.log("Rendering ".concat(f," variant ").concat(a,":"),n),console.log("Rendering Variant : ",n),console.log("Open Accordion ID:",W,"Current Variant ID:",m);var N=null===(p=null==b?void 0:b.activeEditId)||void 0===p?void 0:p.startsWith("condition-wta-".concat(f,"-").concat(a)),B=null===(g=null==b?void 0:b.activeEditId)||void 0===g?void 0:g.startsWith("condition-wnta-".concat(f,"-").concat(a));return e.jsx("div",i.__assign({ref:function(i){i?M.current.set(m,i):M.current.delete(m)},style:{width:"100%"}},{children:e.jsx(d.default,i.__assign({title:{type:C?"default":"variant",label:ui(S),number:a+1,isNewVariant:D,isDefault:n.isDefault,isModified:n.isModified},defaultOpen:!0,expanded:W===m,onToggle:function(){var i,e=W===m;console.log("is closing:",e),q(e?null:m),null===(i=null==b?void 0:b.setActiveVariantAccordionIndex)||void 0===i||i.call(b,e?null:a)},variant:"rule-behavior",footerData:{ruleTitle:S,description:n.ruleDescription||""}},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[e.jsx(r.TextSection,i.__assign({id:"rule-description-".concat(f,"-").concat(a),title:b.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:n.isReadOnly||(null==b?void 0:b.isAiStreaming)||ci&&(null==b?void 0:b.activeEditId)!=="rule-description-".concat(f,"-").concat(a),value:n.ruleDescription||"",onChange:function(i){return j.setRuleDescription(f,a,i)},isOpen:R["ruleDescription-".concat(f)],onToggle:function(){return ri("ruleDescription-".concat(f))},isHighlighted:E.ruleDescription||!1,showCognitiveIcon:null===(h=A.citation)||void 0===h?void 0:h["ruleDescription_".concat(f)],tooltipDescription:"Why this Description?",errorMessage:null===(x=b.validationErrors)||void 0===x?void 0:x["ruleDescription-".concat(f,"-").concat(a)],enableInlineEdit:!0,setSendMessageInChat:null==b?void 0:b.setSendMessageInChat,isAiStreaming:null==b?void 0:b.isAiStreaming,fieldName:"Rule Description"},b)),(null===(y=A.citation)||void 0===y?void 0:y["ruleDescription_".concat(f)])&&e.jsx("div",i.__assign({style:si},{children:e.jsx(t.InputDataReasoningCard,{isVisible:R["ruleDescription-".concat(f)],citation:A.citation["ruleDescription_".concat(f)],citations:di("ruleDescription_".concat(f,"_").concat(a)),fieldName:"Rule Description",fieldValue:n.ruleDescription})})),e.jsx(o.ConditionSection,i.__assign({id:"when-to-apply-".concat(f,"-").concat(a),idPrefix:"condition-wta",title:b.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:n.isReadOnly||(null==b?void 0:b.isAiStreaming)||ci&&!N,conditions:n.whenToApplyConditions||[],onAdd:function(){return j.addWhenToApply(f,a)},onRemove:function(i,e,n){return j.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return j.editWhenToApply(i,e,n,t)},index:a,tierKey:f,isHighlighted:E.wta||!1,highlightedIds:null==b?void 0:b.highlightedIds,tooltipDescription:"Why this Condition?",citations:di("whenToApply_".concat(f,"_").concat(a)),bordered:!0,addLabel:"Add When to apply",isAiStreaming:b.isAiStreaming,errorMessage:(null===(_=b.validationErrors)||void 0===_?void 0:_["whenToApply-".concat(f,"-").concat(a)])||(null==b?void 0:b.conflictReason)},b)),e.jsx(o.ConditionSection,i.__assign({id:"when-not-to-apply-".concat(f,"-").concat(a),idPrefix:"condition-wnta",title:b.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:n.isReadOnly||(null==b?void 0:b.isAiStreaming)||ci&&!B,conditions:n.whenNotToApplyConditions||[],onAdd:function(){return j.addWhenNotToApply(f,a)},onRemove:function(i,e,n){return j.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return j.editWhenNotToApply(i,e,n,t)},index:a,tierKey:f,isHighlighted:E.wnta||!1,highlightedIds:null==b?void 0:b.highlightedIds,tooltipDescription:"Why this Condition?",citations:di("whenNotToApply_".concat(f,"_").concat(a)),bordered:!0,addLabel:"Add When NOT to apply",isAiStreaming:b.isAiStreaming},b)),e.jsx(l.ConfigSection,i.__assign({id:"config-".concat(f,"-").concat(a),title:b.configTitle||"Configuration",required:!1,highlights:E,bordered:!0,readOnly:n.isReadOnly||(null==b?void 0:b.isAiStreaming)||ci&&(null==b?void 0:b.activeEditId)!=="config-".concat(f,"-").concat(a),onConfigChange:function(i,e){return j.onConfigChange(f,a,i,e)},separationItems:w,toggles:V,index:a},b)),(null===(T=n.reasoning)||void 0===T?void 0:T.configData)&&e.jsx("div",i.__assign({style:si},{children:e.jsx(t.InputDataReasoningCard,{citation:n.reasoning.configData,citations:di("configData_".concat(f,"_").concat(a)),fieldName:"Configuration",fieldValue:"Proposed Configuration"})}))]}))}),m)}),"".concat(f,"-variant-").concat(a))})}))}),"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"),o=require("../../organisms/ConditionSection/ConditionSection.js"),l=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(n){var t=n.children,o=n.onAddVariant,l=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:l?void 0:o,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:l?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:l?"not-allowed":"pointer",backgroundColor:l?"#f8fafc":"#FFFFFF",opacity:l?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))};exports.CreateRule=function(c){var f,g,h,x,y,_,T,S,m,C,D,I=c.state,A=c.handlers,j=c.uiState,b=(null==j?void 0:j.highlights)||new Map,E=b.get("global_0")||{},O=n.useState({}),w=O[0],R=O[1],V=n.useState(null),N=V[0],W=V[1],q=n.useState(function(){var i,e,n;if((null==j?void 0:j.defaultTierOpen)>=0&&(null===(i=null==j?void 0:j.tierOptions)||void 0===i?void 0:i[j.defaultTierOpen]))return j.tierOptions[j.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=I.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n[0];return t?t.toLowerCase().replace(/ /g,"_"):null});q[0];var L=q[1],B="rule-setup"===(null==j?void 0:j.activeEditId),M=v.default.useRef(new Map),F=n.useState(null),k=F[0],z=F[1],P=n.useState(null),J=P[0],H=P[1],K=n.useState(!1),$=K[0],U=K[1],Z=v.default.useRef(null==j?void 0:j.isAiStreaming);n.useEffect(function(){Z.current&&!(null==j?void 0:j.isAiStreaming)&&$&&U(!1),Z.current=null==j?void 0:j.isAiStreaming},[null==j?void 0:j.isAiStreaming,$]);var G=function(){var i;z(null),H(null),null===(i=null==j?void 0:j.setActiveEditId)||void 0===i||i.call(j,null)},Q=function(){var i,e,n=null!=k?k:I.ruleTitle,t=null!=J?J:I.scopeData,o=n!==I.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(I.scopeData);if(!o&&!l)return z(null),H(null),void(null===(i=null==j?void 0:j.setActiveEditId)||void 0===i||i.call(j,null));if(null==j?void 0:j.setSendMessageInChat){var a="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),r=[];if(o&&r.push((null==n?void 0:n.trim())?"Title with ".concat(n):"No Title"),l){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 ");j.setSendMessageInChat("__SKELETON__:".concat(a,":Update Rule Setup ").concat(u))}U(!0),z(null),H(null),null===(e=null==j?void 0:j.setActiveEditId)||void 0===e||e.call(j,null)},X=null!==k?null==k?void 0:k.trim():(I.ruleTitle||"").trim(),Y=null!=J?J:I.scopeData,ii=X!==(I.ruleTitle||"").trim(),ei=JSON.stringify(Y)!==JSON.stringify(I.scopeData),ni=!ii&&!ei||""===X,ti=v.default.useRef(null==j?void 0:j.defaultVariantOpen),oi=v.default.useRef(null==j?void 0:j.activeVariantAccordionIndex),li=v.default.useRef(null==j?void 0:j.defaultTierOpen),ai=v.default.useRef(null===(f=I.scopeData)||void 0===f?void 0:f.tiers),ri=v.default.useRef(I.variantsByTier);v.default.useEffect(function(){var i,e,n,t,o,l,a=null,r=!1;ti.current!==(null==j?void 0:j.defaultVariantOpen)&&(r=!0,ti.current=null==j?void 0:j.defaultVariantOpen),oi.current!==(null==j?void 0:j.activeVariantAccordionIndex)&&(r=!0,oi.current=null==j?void 0:j.activeVariantAccordionIndex),li.current!==(null==j?void 0:j.defaultTierOpen)&&(r=!0,li.current=null==j?void 0:j.defaultTierOpen);var d=(null===(i=I.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(ai.current)!==JSON.stringify(d)&&(r=!0,ai.current=d,d.length>0&&L(d[0].toLowerCase().replace(/ /g,"_")));var s=(null===(e=null==j?void 0:j.tierOptions)||void 0===e?void 0:e.filter(function(i){var e,n;return null===(n=null===(e=I.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,o,l=i.toLowerCase().replace(/ /g,"_");return((null===(n=null===(e=ri.current)||void 0===e?void 0:e[l])||void 0===n?void 0:n.length)||0)!==((null===(o=null===(t=I.variantsByTier)||void 0===t?void 0:t[l])||void 0===o?void 0:o.length)||0)});if(u&&(r=!0),r){var c=null!==(n=null==j?void 0:j.activeVariantAccordionIndex)&&void 0!==n?n:null==j?void 0:j.defaultVariantOpen;if(null==c||c<0)return W(null),void(ri.current=I.variantsByTier);s.forEach(function(i,e){var n;if(!((null==j?void 0:j.defaultTierOpen)>=0&&e!==j.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(n=I.variantsByTier)||void 0===n?void 0:n[t])||[];o[c]&&(a="".concat(t,"-variant-").concat(c)),null!=(null==j?void 0:j.autoScrollVariantIndex)&&o[j.autoScrollVariantIndex]&&(a="".concat(t,"-variant-").concat(j.autoScrollVariantIndex))}}),a&&W(a)}if(null===N){var v=null!==(t=null==j?void 0:j.activeVariantAccordionIndex)&&void 0!==t?t:null==j?void 0:j.defaultVariantOpen;null!=v&&v>=0&&(null===(l=null===(o=null==j?void 0:j.tierOptions)||void 0===o?void 0:o.filter(function(i){var e,n;return null===(n=null===(e=I.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===l||l.forEach(function(i,e){var n;if(!((null==j?void 0:j.defaultTierOpen)>=0&&e!==j.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=I.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&W("".concat(t,"-variant-").concat(v))}}))}ri.current=I.variantsByTier},[I.variantsByTier,null==j?void 0:j.defaultVariantOpen,null==j?void 0:j.activeVariantAccordionIndex,null===(g=I.scopeData)||void 0===g?void 0:g.tiers,null==j?void 0:j.tierOptions,null==j?void 0:j.autoScrollVariantIndex,null==j?void 0:j.defaultTierOpen]);var di=function(e){R(function(n){var t;return i.__assign(i.__assign({},n),((t={})[e]=!n[e],t))})},si=function(i){var e,n,t,o=i.split("_"),l=o[o.length-1],a=/^\d+$/.test(l)?o.slice(0,-1).join("_"):i,r=null===(e=I.fieldCitations)||void 0===e?void 0:e[a];if(Array.isArray(r)&&r.length>0)return r;var d=null===(n=I.fieldCitations)||void 0===n?void 0:n[i];return Array.isArray(d)&&d.length>0?d:null!==(t=I.citations)&&void 0!==t?t:[]},ui={marginTop:"-17px",position:"relative",zIndex:1};n.useEffect(function(){var i,e;null!=(null==j?void 0:j.autoScrollVariantIndex)&&(null===(e=null===(i=null==j?void 0:j.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,n;return null===(n=null===(e=I.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(j.autoScrollVariantIndex),t=M.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==j?void 0:j.scrollTrigger]),console.log("CreateRule state:",I),console.log("CreateRule uiState:",j);var ci=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"},vi=!!(null==j?void 0:j.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==j?void 0:j.setupLabel)||"Rule Setup"},actionButtons:function(n,t){if(B)return null;var o=!!(null==j?void 0:j.activeEditId)&&"rule-setup"!==j.activeEditId;return e.jsx("div",i.__assign({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:e.jsx("button",i.__assign({title:o?"Save active edits first":"Edit",onClick:function(e){e.stopPropagation(),o?(null==j?void 0:j.setPendingEditId)&&j.setPendingEditId(j.activeEditId||null):(!function(){var e,n;(null==j?void 0:j.activeEditId)&&"rule-setup"!==j.activeEditId||(null===(e=null==j?void 0:j.setActiveEditId)||void 0===e||e.call(j,"rule-setup"),z(null!==(n=I.ruleTitle)&&void 0!==n?n:""),H(I.scopeData?i.__assign({},I.scopeData):{}))}(),(null==j?void 0:j.setPendingEditId)&&j.setPendingEditId(null),n||t())},disabled:$,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:$?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:$?.5:1}},{children:e.jsx(u.Pencil,{size:14})}))}))},footerData:{ruleTitle:I.ruleTitle,stations:[I.scopeData.station],tiers:null===(h=I.scopeData)||void 0===h?void 0:h.tiers},defaultOpen:"Create"===(null==j?void 0:j.usedFor),readOnly:"Create"!==(null==j?void 0:j.usedFor),isAiStreaming:null==j?void 0:j.isAiStreaming,editFlow:"Edit"===(null==j?void 0:j.usedFor)},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[$&&(null==j?void 0:j.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:j.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:B&&null!==k?k:I.ruleTitle,onChange:function(i){return B?z(i):A.setRuleTitle(i)},readOnly:(null==j?void 0:j.isAiStreaming)||!B,isOpen:w.ruleTitle,onToggle:function(){return di("ruleTitle")},isHighlighted:E.ruleTitle||!1,showCognitiveIcon:I.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(x=j.validationErrors)||void 0===x?void 0:x.ruleTitle},j)),I.citation.ruleTitle&&e.jsx("div",i.__assign({style:ui},{children:e.jsx(t.InputDataReasoningCard,{isVisible:w.ruleTitle,citation:I.citation.ruleTitle,citations:si("ruleTitle"),fieldName:"Rule Title",fieldValue:I.ruleTitle})})),e.jsx(a.ScopeSection,i.__assign({id:"scope",title:"",required:!1,scopeData:B&&null!==J?J:I.scopeData,onScopeChange:function(e,n){B?H(function(t){var o;return i.__assign(i.__assign({},null!=t?t:I.scopeData),((o={})[e]=n,o))}):A.onScopeChange(e,n)},tierLabel:"Which tiers should this learning apply to?",stationLabel:"Which scope should this learning belong to?",highlights:E,isOpen:w.scopeData,onToggle:function(){return di("scopeData")},showCognitiveIcon:I.citation.scopeData,cognitiveIcon:e.jsx(s.ButtonCognitiveIcon,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(y=j.validationErrors)||void 0===y?void 0:y.station)||(null===(_=j.validationErrors)||void 0===_?void 0:_.tiers),stationErrorMessage:null===(T=j.validationErrors)||void 0===T?void 0:T.station,tierErrorMessage:null===(S=j.validationErrors)||void 0===S?void 0:S.tiers,readOnly:(null==j?void 0:j.isAiStreaming)||!B},j)),I.citation.scopeData&&e.jsx("div",i.__assign({style:ui},{children:e.jsx(t.InputDataReasoningCard,{isVisible:w.scopeData,citation:I.citation.scopeData,citations:si("scopeData"),fieldName:"Scope",fieldValue:null===(C=null===(m=I.scopeData)||void 0===m?void 0:m.tiers)||void 0===C?void 0:C.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:G,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e.jsxs("button",i.__assign({onClick:Q,disabled:ni,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:ni?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:ni?.5:1}},{children:[e.jsx(u.Check,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==j?void 0:j.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=null==j?void 0:j.tierOptions)||void 0===D?void 0:D.map(function(n,a){var s,u,c,v,f,g,h=n.toLowerCase().replace(/ /g,"_"),x=(null===(s=I.variantsByTier)||void 0===s?void 0:s[h])||[],y=null===(c=null===(u=I.scopeData)||void 0===u?void 0:u.tiers)||void 0===c?void 0:c.includes(n),_=x.length,T=!1;if(1===_){var S=x[0],m=!(null===(v=null==S?void 0:S.ruleDescription)||void 0===v?void 0:v.trim()),C=(null===(f=null==S?void 0:S.whenToApplyConditions)||void 0===f?void 0:f.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,D=(null===(g=null==S?void 0:S.whenNotToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!m||C||D||(T=!0)}var E=T?void 0:"".concat(_," ").concat(1===_?"variant":"variants"," configured for this tier");return console.log("Rendering tier : ",n),e.jsx(d.default,i.__assign({variant:"tier-header",title:{type:"other",label:n},subtitle:E,defaultOpen:!0,footerData:{description:"Variants for ".concat(n)}},{children:e.jsx(p,i.__assign({onAddVariant:function(){var i;return null===(i=A.addNewVariant)||void 0===i?void 0:i.call(A,h)},isDisabled:!y||(null==j?void 0:j.isAiStreaming),showAddVariantBtn:"Edit"!==(null==j?void 0:j.usedFor)},{children:x.map(function(n,a){var s,u,c,v,p,f,g,x,_,T,S=n.variantType||"default",m="".concat(h,"-variant-").concat(a),C=!0===n.is_variant,D="default"===S||"default_variant"===S,E="".concat(h,"_").concat(a),O=b.get(E)||{},R=(null===(u=null===(s=j.separationItemsByTier)||void 0===s?void 0:s[h])||void 0===u?void 0:u.get(a))||[],V=(null===(v=null===(c=j.togglesByTier)||void 0===c?void 0:c[h])||void 0===v?void 0:v.get(a))||[],q=null===(p=null==j?void 0:j.activeEditId)||void 0===p?void 0:p.startsWith("condition-wta-".concat(h,"-").concat(a)),L=null===(f=null==j?void 0:j.activeEditId)||void 0===f?void 0:f.startsWith("condition-wnta-".concat(h,"-").concat(a)),B=!y||n.isReadOnly||(null==j?void 0:j.isAiStreaming);return e.jsx("div",i.__assign({ref:function(i){i?M.current.set(m,i):M.current.delete(m)},style:{width:"100%",opacity:y?1:.7}},{children:e.jsx(d.default,i.__assign({title:{type:D?"default":"variant",label:ci(S),number:a+1,isNewVariant:C,isDefault:n.isDefault,isModified:n.isModified},defaultOpen:!0,expanded:N===m,onToggle:function(){var i,e=N===m;W(e?null:m),null===(i=null==j?void 0:j.setActiveVariantAccordionIndex)||void 0===i||i.call(j,e?null:a)},variant:"rule-behavior",footerData:{ruleTitle:S,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(h,"-").concat(a),title:j.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:B||vi&&(null==j?void 0:j.activeEditId)!=="rule-description-".concat(h,"-").concat(a),value:n.ruleDescription||"",onChange:function(i){return A.setRuleDescription(h,a,i)},isOpen:w["ruleDescription-".concat(h)],onToggle:function(){return di("ruleDescription-".concat(h))},isHighlighted:O.ruleDescription||!1,showCognitiveIcon:null===(g=I.citation)||void 0===g?void 0:g["ruleDescription_".concat(h)],tooltipDescription:"Why this Description?",errorMessage:null===(x=j.validationErrors)||void 0===x?void 0:x["ruleDescription-".concat(h,"-").concat(a)],enableInlineEdit:!0,setSendMessageInChat:null==j?void 0:j.setSendMessageInChat,isAiStreaming:null==j?void 0:j.isAiStreaming,fieldName:"Rule Description"},j)),(null===(_=I.citation)||void 0===_?void 0:_["ruleDescription_".concat(h)])&&e.jsx("div",i.__assign({style:ui},{children:e.jsx(t.InputDataReasoningCard,{isVisible:w["ruleDescription-".concat(h)],citation:I.citation["ruleDescription_".concat(h)],citations:si("ruleDescription_".concat(h,"_").concat(a)),fieldName:"Rule Description",fieldValue:n.ruleDescription})})),e.jsx(o.ConditionSection,i.__assign({id:"when-to-apply-".concat(h,"-").concat(a),idPrefix:"condition-wta",title:j.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:B||vi&&!q,conditions:n.whenToApplyConditions||[],onAdd:function(){return A.addWhenToApply(h,a)},onRemove:function(i,e,n){return A.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return A.editWhenToApply(i,e,n,t)},index:a,tierKey:h,isHighlighted:O.wta||!1,highlightedIds:null==j?void 0:j.highlightedIds,tooltipDescription:"Why this Condition?",citations:si("whenToApply_".concat(h,"_").concat(a)),bordered:!0,addLabel:"Add When to apply",isAiStreaming:j.isAiStreaming,errorMessage:(null===(T=j.validationErrors)||void 0===T?void 0:T["whenToApply-".concat(h,"-").concat(a)])||(null==j?void 0:j.conflictReason)},j)),e.jsx(o.ConditionSection,i.__assign({id:"when-not-to-apply-".concat(h,"-").concat(a),idPrefix:"condition-wnta",title:j.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:B||vi&&!L,conditions:n.whenNotToApplyConditions||[],onAdd:function(){return A.addWhenNotToApply(h,a)},onRemove:function(i,e,n){return A.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return A.editWhenNotToApply(i,e,n,t)},index:a,tierKey:h,isHighlighted:O.wnta||!1,highlightedIds:null==j?void 0:j.highlightedIds,tooltipDescription:"Why this Condition?",citations:si("whenNotToApply_".concat(h,"_").concat(a)),bordered:!0,addLabel:"Add When NOT to apply",isAiStreaming:j.isAiStreaming},j)),e.jsx(l.ConfigSection,i.__assign({id:"config-".concat(h,"-").concat(a),title:j.configTitle||"Configuration",required:!1,highlights:O,bordered:!0,readOnly:B||vi&&(null==j?void 0:j.activeEditId)!=="config-".concat(h,"-").concat(a),onConfigChange:function(i,e){return A.onConfigChange(h,a,i,e)},separationItems:R,toggles:V,index:a},j))]}))}),m)}),"".concat(h,"-variant-").concat(a))})}))}),"tier-".concat(a))})]}))};
2
2
  //# sourceMappingURL=CreateRule.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as i,jsx as o,Fragment as r}from"react/jsx-runtime";import{useState as t,useEffect as n}from"react";import{ChevronUp as d,ChevronDown as l}from"lucide-react";import a from"./TooltipComponent.js";var p=function(p){var s,c,f=p.title,x=p.subtitle,g=p.children,h=p.defaultOpen,u=void 0===h||h,v=p.footerData,y=p.readOnly,b=void 0!==y&&y,m=p.variant,F=void 0===m?"default":m,w=p.expanded,C=p.onToggle,D=p.actionButtons,E=p.isAiStreaming,S=p.editFlow,z=void 0!==S&&S,k=t(u),I=k[0],B=k[1];n(function(){B(u)},[u]);var R=void 0!==w,T=R?w:I,A=function(){R?null==C||C():B(!T)},W="variant"===f.type,j="other"===f.type,L="tier-header"===F,N="rule-behavior"===F,O={padding:"12px 14px 0px 14px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",borderRadius:L?"0px":"8px",borderBottom:L?"1px solid #E2E8F0":"none"},V={alignItems:"center",gap:"8px",margin:0,fontSize:"12px",fontWeight:600,padding:j?"":"6px 10px",borderRadius:"4px",color:b?"#717b8c":L&&T?"#2563EB":"#19213D",backgroundColor:N&&!f.isNewVariant?"#F7F8FA":W?"#FDF2F8":f.isDefault?"#F7F8FA":"transparent",border:W?"1px solid #FCE7F3":f.isDefault?"1px solid #F0F2F5":"none"},M={fontSize:"12px",fontWeight:400,color:"#666F8D",paddingLeft:j?"0px":"10px"},P={badge:{display:"inline-flex",alignItems:"center",gap:"8px",backgroundColor:"#f0fdf4",color:"#367c46",padding:"6px 10px",borderRadius:"8px",border:"1px solid #e1f6e8",fontSize:"12px",fontWeight:"600",lineHeight:"1.2",width:"fit-content"},defaultTag:{backgroundColor:"#f0f4f8",color:"#475569",fontSize:"11px",fontWeight:"600",padding:"2px 8px",borderRadius:"4px",textTransform:"uppercase",border:"1px solid #cbd5e1"},modifiedTag:{boxSizing:"border-box",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",padding:"2px 8px",backgroundColor:"#FFFAE3",border:"1px solid #FDEDAA",borderRadius:"4px",color:"#854D0E",fontSize:"11px",fontWeight:"700",letterSpacing:"0.5px"}};return i("div",e({style:{width:"100%",backgroundColor:"#ffffff",overflow:"hidden",border:L?"none":N&&T?"1px solid #2563EB":"1px solid #E2E8F0",borderRadius:"8px",marginBottom:"0px"}},{children:[i("div",e({onClick:A,style:O},{children:[i("div",e({style:{display:"flex",flexDirection:"column",gap:"4px",margin:0,fontSize:"12px",fontWeight:600,borderRadius:"4px"}},{children:[!f.isNewVariant&&i("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[o("div",e({style:V},{children:f.label})),f.isDefault&&o("span",e({style:P.defaultTag},{children:"Default"})),f.isModified&&o("span",e({style:P.modifiedTag},{children:"MODIFIED"}))]})),o("div",{children:f.isNewVariant&&i("div",e({style:P.badge},{children:[o("svg",e({width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},{children:o("path",{d:"M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"})})),o("div",{children:"New Variant"})]}))}),x&&o("div",e({style:M},{children:x}))]})),i("div",e({style:{display:"flex",alignItems:"center",gap:"12px",paddingRight:"4px"}},{children:[D&&!E&&(z?o(a,e({description:"Coming Soon"},{children:o("div",e({onClick:function(e){return e.stopPropagation()},style:{cursor:"not-allowed",opacity:.6}},{children:o("div",e({style:{pointerEvents:"none"}},{children:D(T,function(){})}))}))})):o("div",e({onClick:function(e){return e.stopPropagation()}},{children:D(T,A)}))),o("div",e({onClick:A,style:{cursor:"pointer",display:"flex",alignItems:"center"}},{children:T?o(d,{size:18,color:L?"#2563EB":"#64748B"}):o(l,{size:18,color:"#64748B"})}))]}))]})),!T&&v&&o("div",e({style:{fontSize:"12px",color:"#475569",fontWeight:400,padding:"0 16px 12px 16px",display:"flex",alignItems:"center",gap:"8px"}},{children:j?i(r,{children:[o("span",e({style:{fontWeight:500,color:"#475569"}},{children:v.ruleTitle||"No Title"})),(null!==(c=null===(s=v.tiers)||void 0===s?void 0:s.length)&&void 0!==c?c:0)>0&&i(r,{children:[o("div",{style:{width:"4px",height:"4px",backgroundColor:"#676970",borderRadius:"50%"}}),o("span",{children:Array.isArray(v.tiers)?v.tiers.join(", "):v.tiers})]})]}):o("span",e({style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:v.description}))})),T&&o("div",e({style:{padding:"12px"}},{children:g}))]}))};export{p as default};
1
+ import{__assign as e}from"tslib";import{jsxs as i,jsx as o,Fragment as r}from"react/jsx-runtime";import{useState as t,useEffect as n}from"react";import{ChevronUp as d,ChevronDown as l}from"lucide-react";import a from"./TooltipComponent.js";var p=function(p){var s,c,f=p.title,x=p.subtitle,g=p.children,h=p.defaultOpen,u=void 0===h||h,v=p.footerData,y=p.readOnly,b=void 0!==y&&y,m=p.variant,F=void 0===m?"default":m,w=p.expanded,C=p.onToggle,D=p.actionButtons,E=p.isAiStreaming,S=p.editFlow,z=void 0!==S&&S,k=t(u),I=k[0],B=k[1];n(function(){B(u)},[u]);var R=void 0!==w,A=R?w:I,T=function(){R?null==C||C():B(!A)},W="variant"===f.type,j="other"===f.type,L="tier-header"===F,N="rule-behavior"===F,O={padding:"12px 14px 0px 14px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",borderRadius:L?"0px":"8px",borderBottom:L?"1px solid #E2E8F0":"none"},V={alignItems:"center",gap:"8px",margin:0,fontSize:"12px",fontWeight:600,padding:j?"":"6px 10px",borderRadius:"4px",color:b?"#717b8c":L&&A?"#2563EB":"#19213D",backgroundColor:N&&!f.isNewVariant?"#F7F8FA":W?"#FDF2F8":f.isDefault?"#F7F8FA":"transparent",border:W?"1px solid #FCE7F3":f.isDefault?"1px solid #F0F2F5":"none"},M={fontSize:"12px",fontWeight:400,color:"#666F8D",paddingLeft:j?"0px":"10px"},P={badge:{display:"inline-flex",alignItems:"center",gap:"8px",backgroundColor:"#f0fdf4",color:"#367c46",padding:"6px 10px",borderRadius:"8px",border:"1px solid #e1f6e8",fontSize:"12px",fontWeight:"600",lineHeight:"1.2",width:"fit-content"},defaultTag:{backgroundColor:"#f0f4f8",color:"#475569",fontSize:"11px",fontWeight:"600",padding:"2px 8px",borderRadius:"4px",textTransform:"uppercase",border:"1px solid #cbd5e1"},modifiedTag:{boxSizing:"border-box",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",padding:"2px 8px",backgroundColor:"#FFFAE3",border:"1px solid #FDEDAA",borderRadius:"4px",color:"#854D0E",fontSize:"11px",fontWeight:"700",letterSpacing:"0.5px"}};return i("div",e({style:{width:"100%",backgroundColor:"#ffffff",overflow:"hidden",border:L?"none":N&&A?"1px solid #2563EB":"1px solid #E2E8F0",borderRadius:"8px",marginBottom:"0px"}},{children:[i("div",e({onClick:T,style:O},{children:[i("div",e({style:{display:"flex",flexDirection:"column",gap:"4px",margin:0,fontSize:"12px",fontWeight:600,borderRadius:"4px"}},{children:[!f.isNewVariant&&i("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[o("div",e({style:V},{children:f.label})),f.isDefault&&o("span",e({style:P.defaultTag},{children:"Default"})),f.isModified&&o("span",e({style:P.modifiedTag},{children:"MODIFIED"}))]})),o("div",{children:f.isNewVariant&&i("div",e({style:P.badge},{children:[o("svg",e({width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},{children:o("path",{d:"M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"})})),o("div",{children:"New Variant"})]}))}),x&&o("div",e({style:M},{children:x}))]})),i("div",e({style:{display:"flex",alignItems:"center",gap:"12px",paddingRight:"4px"}},{children:[D&&!E&&(z?o(a,e({description:"Coming Soon"},{children:o("div",e({onClick:function(e){return e.stopPropagation()},style:{cursor:"not-allowed",opacity:.6}},{children:o("div",e({style:{pointerEvents:"none"}},{children:D(A,function(){})}))}))})):o("div",e({onClick:function(e){return e.stopPropagation()}},{children:D(A,T)}))),o("div",e({onClick:T,style:{cursor:"pointer",display:"flex",alignItems:"center"}},{children:A?o(d,{size:18,color:L?"#2563EB":"#64748B"}):o(l,{size:18,color:"#64748B"})}))]}))]})),!A&&v&&o("div",e({style:{fontSize:"12px",color:"#475569",fontWeight:400,padding:"0 16px 12px 16px",display:"flex",alignItems:"center",gap:"8px"}},{children:j?i(r,{children:[o("span",e({style:{fontWeight:500,color:"#475569"}},{children:v.ruleTitle||""})),(null!==(c=null===(s=v.tiers)||void 0===s?void 0:s.length)&&void 0!==c?c:0)>0&&i(r,{children:[o("div",{style:{width:"4px",height:"4px",backgroundColor:"#676970",borderRadius:"50%"}}),o("span",{children:Array.isArray(v.tiers)?v.tiers.join(", "):v.tiers})]})]}):o("span",e({style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},{children:v.description}))})),A&&o("div",e({style:{padding:"12px"}},{children:g}))]}))};export{p as default};
2
2
  //# sourceMappingURL=AccordianSection.js.map
@@ -1,2 +1,2 @@
1
- import{__rest as e,__assign as i,__spreadArray as t}from"tslib";import{jsx as o,jsxs as n}from"react/jsx-runtime";import{SectionWrapper as r}from"../../molecules/Sections/SectionWrapper.js";import l from"../../_svg/CognitiveDecisioning.js";import{ChevronUpIcon as s,ChevronDownIcon as a}from"lucide-react";import c from"../../TooltipComponent.js";var p=function(p){var d=p.id,h=p.title,g=void 0===h?"Scope":h,u=p.required,x=void 0!==u&&u,v=p.openSections,m=p.setOpenSections,f=p.scopeData,y=p.onScopeChange;p.stationOptions;var b=p.tierOptions,w=void 0===b?[]:b;p.stationLabel;var C=p.tierLabel,S=void 0===C?"Where should this rule apply?":C,k=p.highlights,O=void 0===k?{}:k,L=p.isOpen,I=p.onToggle,M=p.showCognitiveIcon,j=p.cognitiveIcon,D=p.tooltipDescription,E=p.errorMessage,T=p.stationErrorMessage,z=p.tierErrorMessage,B=e(p,["id","title","required","openSections","setOpenSections","scopeData","onScopeChange","stationOptions","tierOptions","stationLabel","tierLabel","highlights","isOpen","onToggle","showCognitiveIcon","cognitiveIcon","tooltipDescription","errorMessage","stationErrorMessage","tierErrorMessage"]);return o(r,i({id:d,title:g,required:x,openSections:v,setOpenSections:m},B,{children:n("div",i({className:"scope-content"},{children:[w.length>0&&n("div",i({className:"form-group"},{children:[n("div",i({style:{display:"flex",alignItems:"center",gap:"4px",marginBottom:"4px"}},{children:[o("span",i({style:{color:"#8F2C23",lineHeight:1}},{children:"*"})),o("label",i({className:(null==B?void 0:B.readOnly)?"readOnly":"form-label",style:{margin:0}},{children:S}))]})),n("div",i({style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}},{children:[o("div",i({className:"checkbox-group",style:{display:"flex",gap:"16px"}},{children:w.map(function(e){var r,l,s=O["scope_".concat(e)],a="tier-".concat(d,"-").concat(e.replace(/\s+/g,"-").toLowerCase());return n("div",i({className:"checkbox-item",style:{display:"flex",alignItems:"center",gap:"6px",position:"relative"}},{children:[o("input",{type:"checkbox",id:a,checked:null===(r=f.tiers)||void 0===r?void 0:r.includes(e),onChange:function(){var i=f.tiers||[],o=i.includes(e)?i.filter(function(i){return i!==e}):t(t([],i,!0),[e],!1);y("tiers",o)},disabled:(null==B?void 0:B.readOnly)||!1,style:{position:"absolute",opacity:0,cursor:"pointer",width:"16px",height:"16px",zIndex:1}}),o("div",i({style:{width:"16px",height:"16px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",boxShadow:s?"0 0 14px 4px rgba(37, 99, 235, 0.35)":"none"}},{children:(null===(l=f.tiers)||void 0===l?void 0:l.includes(e))?n("svg",i({width:"16",height:"16",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[o("path",{d:"M4 0.25H10C12.0711 0.25 13.75 1.92893 13.75 4V10C13.75 12.0711 12.0711 13.75 10 13.75H4C1.92893 13.75 0.25 12.0711 0.25 10V4C0.25 1.92893 1.92893 0.25 4 0.25Z",fill:"#2563EB",stroke:"#2563EB","stroke-width":"0.5"}),o("path",{d:"M4 7L6 9L10 5",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})):o("div",{style:{width:"14px",height:"14px",border:"1px solid #64748B",borderRadius:"4px",backgroundColor:"white"}})})),o("label",i({style:{color:(null==B?void 0:B.readOnly)?"#9CA3AF":void 0,cursor:(null==B?void 0:B.readOnly)?"not-allowed":"pointer",margin:0,fontSize:"14px"},htmlFor:"tier-".concat(d,"-").concat(e.toLowerCase().replace(/\s+/g,"-"))},{children:e}))]}),a)})})),o("div",i({style:{width:"fit-content"}},{children:o(c,i({description:null!=D?D:""},{children:M&&n("button",i({onClick:function(e){e.preventDefault(),null==I||I()},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"2px",padding:"2px 6px ",flexShrink:0,border:"none",backgroundColor:"transparent",borderRadius:"4px",cursor:"pointer",outline:"none",maxWidth:"fit-content",transition:"background-color 0.2s ease",marginTop:"6px",marginLeft:"6px"}},{children:[j||o(l,{}),o(L?s:a,{size:16})]}))}))}))]})),z&&o("div",i({style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"}},{children:z}))]})),E&&!T&&!z&&o("div",i({style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"}},{children:E}))]}))}))};export{p as ScopeSection};
1
+ import{__rest as e,__assign as i}from"tslib";import{jsx as o,jsxs as t}from"react/jsx-runtime";import{SectionWrapper as n}from"../../molecules/Sections/SectionWrapper.js";import r from"../../_svg/CognitiveDecisioning.js";import{ChevronUpIcon as l,ChevronDownIcon as s}from"lucide-react";import a from"../../TooltipComponent.js";var d=function(d){var p=d.id,c=d.title,g=void 0===c?"Scope":c,h=d.required,x=void 0!==h&&h,u=d.openSections,m=d.setOpenSections,v=d.scopeData,b=d.onScopeChange;d.stationOptions;var f=d.tierOptions,y=void 0===f?[]:f;d.stationLabel;var S=d.tierLabel,C=void 0===S?"Where should this rule apply?":S,O=d.highlights,w=void 0===O?{}:O,I=d.isOpen,k=d.onToggle,z=d.showCognitiveIcon,j=d.cognitiveIcon,D=d.tooltipDescription,L=d.errorMessage,M=d.stationErrorMessage,T=d.tierErrorMessage,E=e(d,["id","title","required","openSections","setOpenSections","scopeData","onScopeChange","stationOptions","tierOptions","stationLabel","tierLabel","highlights","isOpen","onToggle","showCognitiveIcon","cognitiveIcon","tooltipDescription","errorMessage","stationErrorMessage","tierErrorMessage"]);return o(n,i({id:p,title:g,required:x,openSections:u,setOpenSections:m},E,{children:t("div",i({className:"scope-content"},{children:[y.length>0&&t("div",i({className:"form-group"},{children:[t("div",i({style:{display:"flex",alignItems:"center",gap:"4px",marginBottom:"4px"}},{children:[o("span",i({style:{color:"#8F2C23",lineHeight:1}},{children:"*"})),o("label",i({className:(null==E?void 0:E.readOnly)?"readOnly":"form-label",style:{margin:0}},{children:C}))]})),t("div",i({style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"}},{children:[o("div",i({className:"checkbox-group",style:{display:"flex",gap:"16px"}},{children:y.map(function(e){var n,r,l=w["scope_".concat(e)],s="tier-".concat(p,"-").concat(e.replace(/\s+/g,"-").toLowerCase());return t("div",i({className:"checkbox-item",style:{display:"flex",alignItems:"center",gap:"6px",position:"relative"}},{children:[o("input",{type:"radio",name:"scope-tiers-".concat(p),id:s,checked:null===(n=v.tiers)||void 0===n?void 0:n.includes(e),onChange:function(){b("tiers",[e])},disabled:(null==E?void 0:E.readOnly)||!1,style:{position:"absolute",opacity:0,cursor:"pointer",width:"16px",height:"16px",zIndex:1}}),o("div",i({style:{width:"16px",height:"16px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",boxShadow:l?"0 0 14px 4px rgba(37, 99, 235, 0.35)":"none",borderRadius:"50%"}},{children:(null===(r=v.tiers)||void 0===r?void 0:r.includes(e))?o("div",{style:{width:"16px",height:"16px",borderRadius:"50%",border:"5px solid #2563EB",backgroundColor:"white",boxSizing:"border-box"}}):o("div",{style:{width:"16px",height:"16px",border:"1px solid #64748B",borderRadius:"50%",backgroundColor:"white",boxSizing:"border-box"}})})),o("label",i({style:{color:(null==E?void 0:E.readOnly)?"#9CA3AF":void 0,cursor:(null==E?void 0:E.readOnly)?"not-allowed":"pointer",margin:0,fontSize:"14px"},htmlFor:s},{children:e}))]}),s)})})),o("div",i({style:{width:"fit-content"}},{children:o(a,i({description:null!=D?D:""},{children:z&&t("button",i({onClick:function(e){e.preventDefault(),null==k||k()},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"2px",padding:"2px 6px ",flexShrink:0,border:"none",backgroundColor:"transparent",borderRadius:"4px",cursor:"pointer",outline:"none",maxWidth:"fit-content",transition:"background-color 0.2s ease",marginTop:"6px",marginLeft:"6px"}},{children:[j||o(r,{}),o(I?l:s,{size:16})]}))}))}))]})),T&&o("div",i({style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"}},{children:T}))]})),L&&!M&&!T&&o("div",i({style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"}},{children:L}))]}))}))};export{d as ScopeSection};
2
2
  //# sourceMappingURL=ScopeSection.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as i}from"tslib";import{jsxs as n,jsx as e}from"react/jsx-runtime";import t,{useState as o,useEffect as l}from"react";import{InputDataReasoningCard as r}from"../../InputDataReasoningCard.js";import{ConditionSection as a}from"../../organisms/ConditionSection/ConditionSection.js";import{ConfigSection as d}from"../../organisms/ConfigSection/ConfigSection.js";import{ScopeSection as c}from"../../organisms/ScopeSection/ScopeSection.js";import{TextSection as u}from"../../organisms/TextSection/TextSection.js";import s from"../../AccordianSection.js";import{ButtonCognitiveIcon as v}from"../../_svg/ButtonCognitiveIcon.js";import{Loader2Icon as p,Pencil as f,Check as g,AlertTriangle as h}from"lucide-react";var y=function(o){var l=o.children,r=o.onAddVariant,a=o.isDisabled,d=o.showAddVariantBtn,c=void 0===d||d,u=t.Children.toArray(l);return n("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[u.map(function(i,o){var l=!(o===u.length-1)||c;return n(t.Fragment,{children:[i,l&&e("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},o)}),c&&e("div",i({onClick:a?void 0:r,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:a?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:a?"not-allowed":"pointer",backgroundColor:a?"#f8fafc":"#FFFFFF",opacity:a?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))},m=function(m){var x,T,D,S,A,C,I,b,O,E,w,V,R=m.state,_=m.handlers,N=m.uiState,W=(null==N?void 0:N.highlights)||new Map,B=W.get("global_0")||{},F=o({}),M=F[0],j=F[1],k=o(null),L=k[0],z=k[1],q="rule-setup"===(null==N?void 0:N.activeEditId),P=t.useRef(new Map),J=o(null),H=J[0],K=J[1],$=o(null),U=$[0],Z=$[1],G=o(!1),Q=G[0],X=G[1],Y=t.useRef(null==N?void 0:N.isAiStreaming);l(function(){Y.current&&!(null==N?void 0:N.isAiStreaming)&&Q&&X(!1),Y.current=null==N?void 0:N.isAiStreaming},[null==N?void 0:N.isAiStreaming,Q]);var ii=function(){var i;K(null),Z(null),null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null)},ni=function(){var i,n,e=null!=H?H:R.ruleTitle,t=null!=U?U:R.scopeData,o=e!==R.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(R.scopeData);if(!o&&!l)return K(null),Z(null),void(null===(i=null==N?void 0:N.setActiveEditId)||void 0===i||i.call(N,null));if(null==N?void 0:N.setSendMessageInChat){var r="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),a=[];if(o&&a.push((null==e?void 0:e.trim())?"Title with ".concat(e):"No Title"),l){var d=null==t?void 0:t.tiers,c=d&&d.length>0?"tiers: ".concat(d.join(", ")):"No Tier Selected";a.push(c)}var u=a.join(" and ");N.setSendMessageInChat("__SKELETON__:".concat(r,":Update Rule Setup ").concat(u))}X(!0),K(null),Z(null),null===(n=null==N?void 0:N.setActiveEditId)||void 0===n||n.call(N,null)},ei=null!==H?null==H?void 0:H.trim():(R.ruleTitle||"").trim(),ti=null!=U?U:R.scopeData,oi=ei!==(R.ruleTitle||"").trim(),li=JSON.stringify(ti)!==JSON.stringify(R.scopeData),ri=!oi&&!li||""===ei,ai=t.useRef(null==N?void 0:N.defaultVariantOpen),di=t.useRef(null==N?void 0:N.activeVariantAccordionIndex),ci=t.useRef(null==N?void 0:N.defaultTierOpen),ui=t.useRef(null===(x=R.scopeData)||void 0===x?void 0:x.tiers),si=t.useRef(R.variantsByTier);t.useEffect(function(){var i,n,e,t,o,l,r=null,a=!1;ai.current!==(null==N?void 0:N.defaultVariantOpen)&&(a=!0,ai.current=null==N?void 0:N.defaultVariantOpen),di.current!==(null==N?void 0:N.activeVariantAccordionIndex)&&(a=!0,di.current=null==N?void 0:N.activeVariantAccordionIndex),ci.current!==(null==N?void 0:N.defaultTierOpen)&&(a=!0,ci.current=null==N?void 0:N.defaultTierOpen);var d=(null===(i=R.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(ui.current)!==JSON.stringify(d)&&(a=!0,ui.current=d);var c=(null===(n=null==N?void 0:N.tierOptions)||void 0===n?void 0:n.filter(function(i){var n,e;return null===(e=null===(n=R.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e.includes(i)}))||[],u=c.some(function(i){var n,e,t,o,l=i.toLowerCase().replace(/ /g,"_");return((null===(e=null===(n=si.current)||void 0===n?void 0:n[l])||void 0===e?void 0:e.length)||0)!==((null===(o=null===(t=R.variantsByTier)||void 0===t?void 0:t[l])||void 0===o?void 0:o.length)||0)});if(u&&(a=!0),a){var s=null!==(e=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==e?e:null==N?void 0:N.defaultVariantOpen;if(null==s||s<0)return z(null),void(si.current=R.variantsByTier);c.forEach(function(i,n){var e;if(!((null==N?void 0:N.defaultTierOpen)>=0&&n!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(e=R.variantsByTier)||void 0===e?void 0:e[t])||[];o[s]&&(r="".concat(t,"-variant-").concat(s)),null!=(null==N?void 0:N.autoScrollVariantIndex)&&o[N.autoScrollVariantIndex]&&(r="".concat(t,"-variant-").concat(N.autoScrollVariantIndex))}}),r&&z(r)}if(null===L){var v=null!==(t=null==N?void 0:N.activeVariantAccordionIndex)&&void 0!==t?t:null==N?void 0:N.defaultVariantOpen;null!=v&&v>=0&&(null===(l=null===(o=null==N?void 0:N.tierOptions)||void 0===o?void 0:o.filter(function(i){var n,e;return null===(e=null===(n=R.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e.includes(i)}))||void 0===l||l.forEach(function(i,n){var e;if(!((null==N?void 0:N.defaultTierOpen)>=0&&n!==N.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(e=R.variantsByTier)||void 0===e?void 0:e[t])||[])[v]&&z("".concat(t,"-variant-").concat(v))}}))}si.current=R.variantsByTier},[R.variantsByTier,null==N?void 0:N.defaultVariantOpen,null==N?void 0:N.activeVariantAccordionIndex,null===(T=R.scopeData)||void 0===T?void 0:T.tiers,null==N?void 0:N.tierOptions,null==N?void 0:N.autoScrollVariantIndex,null==N?void 0:N.defaultTierOpen]);var vi=function(n){j(function(e){var t;return i(i({},e),((t={})[n]=!e[n],t))})},pi=function(i){var n,e,t,o=i.split("_"),l=o[o.length-1],r=/^\d+$/.test(l)?o.slice(0,-1).join("_"):i,a=null===(n=R.fieldCitations)||void 0===n?void 0:n[r];if(Array.isArray(a)&&a.length>0)return a;var d=null===(e=R.fieldCitations)||void 0===e?void 0:e[i];return Array.isArray(d)&&d.length>0?d:null!==(t=R.citations)&&void 0!==t?t:[]},fi={marginTop:"-17px",position:"relative",zIndex:1};l(function(){var i,n;null!=(null==N?void 0:N.autoScrollVariantIndex)&&(null===(n=null===(i=null==N?void 0:N.tierOptions)||void 0===i?void 0:i.filter(function(i){var n,e;return null===(e=null===(n=R.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e.includes(i)}))||void 0===n||n.forEach(function(i){var n=i.toLowerCase().replace(/ /g,"_"),e="".concat(n,"-variant-").concat(N.autoScrollVariantIndex),t=P.current.get(e);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==N?void 0:N.scrollTrigger]),console.log("CreateRule state:",R),console.log("CreateRule uiState:",N);var gi=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"},hi=!!(null==N?void 0:N.activeEditId);return n("div",i({className:"traffic-manager-template"},{children:[e("div",i({"data-edit-id":"rule-setup"},{children:e(s,i({title:{type:"other",label:(null==N?void 0:N.setupLabel)||"Rule Setup"},actionButtons:function(n,t){if(q)return null;var o=!!(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId;return e("div",i({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:e("button",i({title:o?"Save active edits first":"Edit",onClick:function(e){e.stopPropagation(),o?(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(N.activeEditId||null):(!function(){var n,e;(null==N?void 0:N.activeEditId)&&"rule-setup"!==N.activeEditId||(null===(n=null==N?void 0:N.setActiveEditId)||void 0===n||n.call(N,"rule-setup"),K(null!==(e=R.ruleTitle)&&void 0!==e?e:""),Z(R.scopeData?i({},R.scopeData):{}))}(),(null==N?void 0:N.setPendingEditId)&&N.setPendingEditId(null),n||t())},disabled:Q,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:Q?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:Q?.5:1}},{children:e(f,{size:14})}))}))},footerData:{ruleTitle:R.ruleTitle,stations:[R.scopeData.station],tiers:null===(D=R.scopeData)||void 0===D?void 0:D.tiers},defaultOpen:"Create"===(null==N?void 0:N.usedFor),readOnly:"Create"!==(null==N?void 0:N.usedFor),isAiStreaming:null==N?void 0:N.isAiStreaming,editFlow:"Edit"===(null==N?void 0:N.usedFor)},{children:n("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[Q&&(null==N?void 0:N.isAiStreaming)&&n("div",i({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[e(p,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),e(u,i({id:"rule-title",title:N.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:q&&null!==H?H:R.ruleTitle,onChange:function(i){return q?K(i):_.setRuleTitle(i)},readOnly:(null==N?void 0:N.isAiStreaming)||!q,isOpen:M.ruleTitle,onToggle:function(){return vi("ruleTitle")},isHighlighted:B.ruleTitle||!1,showCognitiveIcon:R.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(S=N.validationErrors)||void 0===S?void 0:S.ruleTitle},N)),R.citation.ruleTitle&&e("div",i({style:fi},{children:e(r,{isVisible:M.ruleTitle,citation:R.citation.ruleTitle,citations:pi("ruleTitle"),fieldName:"Rule Title",fieldValue:R.ruleTitle})})),e(c,i({id:"scope",title:"",required:!1,scopeData:q&&null!==U?U:R.scopeData,onScopeChange:function(n,e){q?Z(function(t){var o;return i(i({},null!=t?t:R.scopeData),((o={})[n]=e,o))}):_.onScopeChange(n,e)},tierLabel:"Which tiers should this learning apply to?",stationLabel:"Which scope should this learning belong to?",highlights:B,isOpen:M.scopeData,onToggle:function(){return vi("scopeData")},showCognitiveIcon:R.citation.scopeData,cognitiveIcon:e(v,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(A=N.validationErrors)||void 0===A?void 0:A.station)||(null===(C=N.validationErrors)||void 0===C?void 0:C.tiers),stationErrorMessage:null===(I=N.validationErrors)||void 0===I?void 0:I.station,tierErrorMessage:null===(b=N.validationErrors)||void 0===b?void 0:b.tiers,readOnly:(null==N?void 0:N.isAiStreaming)||!q},N)),R.citation.scopeData&&e("div",i({style:fi},{children:e(r,{isVisible:M.scopeData,citation:R.citation.scopeData,citations:pi("scopeData"),fieldName:"Scope",fieldValue:null===(E=null===(O=R.scopeData)||void 0===O?void 0:O.tiers)||void 0===E?void 0:E.join(", ")})})),q?n("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[n("div",i({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[e("button",i({onClick:ii,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),n("button",i({onClick:ni,disabled:ri,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:ri?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:ri?.5:1}},{children:[e(g,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==N?void 0:N.pendingEditId)&&n("div",i({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"10px"}},{children:[e(h,{size:14,style:{color:"#C2410C"}}),e("div",i({style:{color:"#C2410C",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]})):null]}))}))})),null===(V=null===(w=null==N?void 0:N.tierOptions)||void 0===w?void 0:w.filter(function(i){var n,e;return null===(e=null===(n=R.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e.includes(i)}))||void 0===V?void 0:V.map(function(t,o,l){var c,v,p,f,g=t.toLowerCase().replace(/ /g,"_"),h=(null===(c=R.variantsByTier)||void 0===c?void 0:c[g])||[],m=h.length,x=!1;if(1===m){var T=h[0],D=!(null===(v=null==T?void 0:T.ruleDescription)||void 0===v?void 0:v.trim()),S=(null===(p=null==T?void 0:T.whenToApplyConditions)||void 0===p?void 0:p.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,A=(null===(f=null==T?void 0:T.whenNotToApplyConditions)||void 0===f?void 0:f.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;D&&!S&&!A&&(x=!0)}var C=x?void 0:"".concat(m," ").concat(1===m?"variant":"variants"," configured for this tier"),I=!((null==N?void 0:N.defaultTierOpen)>=0)||o===N.defaultTierOpen;return console.log("Rendering tier : ",t),e(s,i({variant:"tier-header",title:{type:"other",label:t},subtitle:C,defaultOpen:I,footerData:{description:"Variants for ".concat(t)}},{children:e(y,i({onAddVariant:function(){var i;return null===(i=_.addNewVariant)||void 0===i?void 0:i.call(_,g)},isDisabled:null==N?void 0:N.isAiStreaming,showAddVariantBtn:"Edit"!==(null==N?void 0:N.usedFor)},{children:h.map(function(t,o){var l,c,v,p,f,h,y,m,x,T,D,S=t.variantType||"default",A="".concat(g,"-variant-").concat(o),C=!0===t.is_variant,I="default"===S||"default_variant"===S;(null==N?void 0:N.defaultVariantOpen)>=0&&N.defaultVariantOpen;var b="".concat(g,"_").concat(o),O=W.get(b)||{},E=(null===(c=null===(l=N.separationItemsByTier)||void 0===l?void 0:l[g])||void 0===c?void 0:c.get(o))||[],w=(null===(p=null===(v=N.togglesByTier)||void 0===v?void 0:v[g])||void 0===p?void 0:p.get(o))||[];(null==N?void 0:N.autoScrollVariantIndex)===o||t.is_variant,console.log("Rendering ".concat(g," variant ").concat(o,":"),t),console.log("Rendering Variant : ",t),console.log("Open Accordion ID:",L,"Current Variant ID:",A);var V=null===(f=null==N?void 0:N.activeEditId)||void 0===f?void 0:f.startsWith("condition-wta-".concat(g,"-").concat(o)),B=null===(h=null==N?void 0:N.activeEditId)||void 0===h?void 0:h.startsWith("condition-wnta-".concat(g,"-").concat(o));return e("div",i({ref:function(i){i?P.current.set(A,i):P.current.delete(A)},style:{width:"100%"}},{children:e(s,i({title:{type:I?"default":"variant",label:gi(S),number:o+1,isNewVariant:C,isDefault:t.isDefault,isModified:t.isModified},defaultOpen:!0,expanded:L===A,onToggle:function(){var i,n=L===A;console.log("is closing:",n),z(n?null:A),null===(i=null==N?void 0:N.setActiveVariantAccordionIndex)||void 0===i||i.call(N,n?null:o)},variant:"rule-behavior",footerData:{ruleTitle:S,description:t.ruleDescription||""}},{children:n("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[e(u,i({id:"rule-description-".concat(g,"-").concat(o),title:N.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:t.isReadOnly||(null==N?void 0:N.isAiStreaming)||hi&&(null==N?void 0:N.activeEditId)!=="rule-description-".concat(g,"-").concat(o),value:t.ruleDescription||"",onChange:function(i){return _.setRuleDescription(g,o,i)},isOpen:M["ruleDescription-".concat(g)],onToggle:function(){return vi("ruleDescription-".concat(g))},isHighlighted:O.ruleDescription||!1,showCognitiveIcon:null===(y=R.citation)||void 0===y?void 0:y["ruleDescription_".concat(g)],tooltipDescription:"Why this Description?",errorMessage:null===(m=N.validationErrors)||void 0===m?void 0:m["ruleDescription-".concat(g,"-").concat(o)],enableInlineEdit:!0,setSendMessageInChat:null==N?void 0:N.setSendMessageInChat,isAiStreaming:null==N?void 0:N.isAiStreaming,fieldName:"Rule Description"},N)),(null===(x=R.citation)||void 0===x?void 0:x["ruleDescription_".concat(g)])&&e("div",i({style:fi},{children:e(r,{isVisible:M["ruleDescription-".concat(g)],citation:R.citation["ruleDescription_".concat(g)],citations:pi("ruleDescription_".concat(g,"_").concat(o)),fieldName:"Rule Description",fieldValue:t.ruleDescription})})),e(a,i({id:"when-to-apply-".concat(g,"-").concat(o),idPrefix:"condition-wta",title:N.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:t.isReadOnly||(null==N?void 0:N.isAiStreaming)||hi&&!V,conditions:t.whenToApplyConditions||[],onAdd:function(){return _.addWhenToApply(g,o)},onRemove:function(i,n,e){return _.removeWhenToApply(i,n,e)},onEdit:function(i,n,e,t){return _.editWhenToApply(i,n,e,t)},index:o,tierKey:g,isHighlighted:O.wta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:pi("whenToApply_".concat(g,"_").concat(o)),bordered:!0,addLabel:"Add When to apply",isAiStreaming:N.isAiStreaming,errorMessage:(null===(T=N.validationErrors)||void 0===T?void 0:T["whenToApply-".concat(g,"-").concat(o)])||(null==N?void 0:N.conflictReason)},N)),e(a,i({id:"when-not-to-apply-".concat(g,"-").concat(o),idPrefix:"condition-wnta",title:N.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:t.isReadOnly||(null==N?void 0:N.isAiStreaming)||hi&&!B,conditions:t.whenNotToApplyConditions||[],onAdd:function(){return _.addWhenNotToApply(g,o)},onRemove:function(i,n,e){return _.removeWhenNotToApply(i,n,e)},onEdit:function(i,n,e,t){return _.editWhenNotToApply(i,n,e,t)},index:o,tierKey:g,isHighlighted:O.wnta||!1,highlightedIds:null==N?void 0:N.highlightedIds,tooltipDescription:"Why this Condition?",citations:pi("whenNotToApply_".concat(g,"_").concat(o)),bordered:!0,addLabel:"Add When NOT to apply",isAiStreaming:N.isAiStreaming},N)),e(d,i({id:"config-".concat(g,"-").concat(o),title:N.configTitle||"Configuration",required:!1,highlights:O,bordered:!0,readOnly:t.isReadOnly||(null==N?void 0:N.isAiStreaming)||hi&&(null==N?void 0:N.activeEditId)!=="config-".concat(g,"-").concat(o),onConfigChange:function(i,n){return _.onConfigChange(g,o,i,n)},separationItems:E,toggles:w,index:o},N)),(null===(D=t.reasoning)||void 0===D?void 0:D.configData)&&e("div",i({style:fi},{children:e(r,{citation:t.reasoning.configData,citations:pi("configData_".concat(g,"_").concat(o)),fieldName:"Configuration",fieldValue:"Proposed Configuration"})}))]}))}),A)}),"".concat(g,"-variant-").concat(o))})}))}),"tier-".concat(o))})]}))};export{m as CreateRule};
1
+ import{__assign as i}from"tslib";import{jsxs as e,jsx as n}from"react/jsx-runtime";import t,{useState as o,useEffect as l}from"react";import{InputDataReasoningCard as r}from"../../InputDataReasoningCard.js";import{ConditionSection as a}from"../../organisms/ConditionSection/ConditionSection.js";import{ConfigSection as d}from"../../organisms/ConfigSection/ConfigSection.js";import{ScopeSection as c}from"../../organisms/ScopeSection/ScopeSection.js";import{TextSection as u}from"../../organisms/TextSection/TextSection.js";import s from"../../AccordianSection.js";import{ButtonCognitiveIcon as v}from"../../_svg/ButtonCognitiveIcon.js";import{Loader2Icon as p,Pencil as f,Check as g,AlertTriangle as h}from"lucide-react";var y=function(o){var l=o.children,r=o.onAddVariant,a=o.isDisabled,d=o.showAddVariantBtn,c=void 0===d||d,u=t.Children.toArray(l);return e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[u.map(function(i,o){var l=!(o===u.length-1)||c;return e(t.Fragment,{children:[i,l&&n("div",{style:{width:"2px",height:"20px",backgroundColor:"#E2E8F0",marginLeft:"30px"}})]},o)}),c&&n("div",i({onClick:a?void 0:r,style:{padding:"8px 16px",border:"1px solid #E2E8F0",borderRadius:"8px",color:a?"#94a3b8":"#475569",fontSize:"14px",fontWeight:"500",cursor:a?"not-allowed":"pointer",backgroundColor:a?"#f8fafc":"#FFFFFF",opacity:a?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))},m=function(m){var T,x,D,S,A,C,I,b,O,w,E,V=m.state,R=m.handlers,_=m.uiState,N=(null==_?void 0:_.highlights)||new Map,W=N.get("global_0")||{},L=o({}),B=L[0],F=L[1],M=o(null),j=M[0],k=M[1],z=o(function(){var i,e,n;if((null==_?void 0:_.defaultTierOpen)>=0&&(null===(i=null==_?void 0:_.tierOptions)||void 0===i?void 0:i[_.defaultTierOpen]))return _.tierOptions[_.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=V.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 q=z[1],P="rule-setup"===(null==_?void 0:_.activeEditId),J=t.useRef(new Map),H=o(null),K=H[0],$=H[1],U=o(null),Z=U[0],G=U[1],Q=o(!1),X=Q[0],Y=Q[1],ii=t.useRef(null==_?void 0:_.isAiStreaming);l(function(){ii.current&&!(null==_?void 0:_.isAiStreaming)&&X&&Y(!1),ii.current=null==_?void 0:_.isAiStreaming},[null==_?void 0:_.isAiStreaming,X]);var ei=function(){var i;$(null),G(null),null===(i=null==_?void 0:_.setActiveEditId)||void 0===i||i.call(_,null)},ni=function(){var i,e,n=null!=K?K:V.ruleTitle,t=null!=Z?Z:V.scopeData,o=n!==V.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(V.scopeData);if(!o&&!l)return $(null),G(null),void(null===(i=null==_?void 0:_.setActiveEditId)||void 0===i||i.call(_,null));if(null==_?void 0:_.setSendMessageInChat){var r="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),a=[];if(o&&a.push((null==n?void 0:n.trim())?"Title with ".concat(n):"No Title"),l){var d=null==t?void 0:t.tiers,c=d&&d.length>0?"tiers: ".concat(d.join(", ")):"No Tier Selected";a.push(c)}var u=a.join(" and ");_.setSendMessageInChat("__SKELETON__:".concat(r,":Update Rule Setup ").concat(u))}Y(!0),$(null),G(null),null===(e=null==_?void 0:_.setActiveEditId)||void 0===e||e.call(_,null)},ti=null!==K?null==K?void 0:K.trim():(V.ruleTitle||"").trim(),oi=null!=Z?Z:V.scopeData,li=ti!==(V.ruleTitle||"").trim(),ri=JSON.stringify(oi)!==JSON.stringify(V.scopeData),ai=!li&&!ri||""===ti,di=t.useRef(null==_?void 0:_.defaultVariantOpen),ci=t.useRef(null==_?void 0:_.activeVariantAccordionIndex),ui=t.useRef(null==_?void 0:_.defaultTierOpen),si=t.useRef(null===(T=V.scopeData)||void 0===T?void 0:T.tiers),vi=t.useRef(V.variantsByTier);t.useEffect(function(){var i,e,n,t,o,l,r=null,a=!1;di.current!==(null==_?void 0:_.defaultVariantOpen)&&(a=!0,di.current=null==_?void 0:_.defaultVariantOpen),ci.current!==(null==_?void 0:_.activeVariantAccordionIndex)&&(a=!0,ci.current=null==_?void 0:_.activeVariantAccordionIndex),ui.current!==(null==_?void 0:_.defaultTierOpen)&&(a=!0,ui.current=null==_?void 0:_.defaultTierOpen);var d=(null===(i=V.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(si.current)!==JSON.stringify(d)&&(a=!0,si.current=d,d.length>0&&q(d[0].toLowerCase().replace(/ /g,"_")));var c=(null===(e=null==_?void 0:_.tierOptions)||void 0===e?void 0:e.filter(function(i){var e,n;return null===(n=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||[],u=c.some(function(i){var e,n,t,o,l=i.toLowerCase().replace(/ /g,"_");return((null===(n=null===(e=vi.current)||void 0===e?void 0:e[l])||void 0===n?void 0:n.length)||0)!==((null===(o=null===(t=V.variantsByTier)||void 0===t?void 0:t[l])||void 0===o?void 0:o.length)||0)});if(u&&(a=!0),a){var s=null!==(n=null==_?void 0:_.activeVariantAccordionIndex)&&void 0!==n?n:null==_?void 0:_.defaultVariantOpen;if(null==s||s<0)return k(null),void(vi.current=V.variantsByTier);c.forEach(function(i,e){var n;if(!((null==_?void 0:_.defaultTierOpen)>=0&&e!==_.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(n=V.variantsByTier)||void 0===n?void 0:n[t])||[];o[s]&&(r="".concat(t,"-variant-").concat(s)),null!=(null==_?void 0:_.autoScrollVariantIndex)&&o[_.autoScrollVariantIndex]&&(r="".concat(t,"-variant-").concat(_.autoScrollVariantIndex))}}),r&&k(r)}if(null===j){var v=null!==(t=null==_?void 0:_.activeVariantAccordionIndex)&&void 0!==t?t:null==_?void 0:_.defaultVariantOpen;null!=v&&v>=0&&(null===(l=null===(o=null==_?void 0:_.tierOptions)||void 0===o?void 0:o.filter(function(i){var e,n;return null===(n=null===(e=V.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n.includes(i)}))||void 0===l||l.forEach(function(i,e){var n;if(!((null==_?void 0:_.defaultTierOpen)>=0&&e!==_.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=V.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&k("".concat(t,"-variant-").concat(v))}}))}vi.current=V.variantsByTier},[V.variantsByTier,null==_?void 0:_.defaultVariantOpen,null==_?void 0:_.activeVariantAccordionIndex,null===(x=V.scopeData)||void 0===x?void 0:x.tiers,null==_?void 0:_.tierOptions,null==_?void 0:_.autoScrollVariantIndex,null==_?void 0:_.defaultTierOpen]);var pi=function(e){F(function(n){var t;return i(i({},n),((t={})[e]=!n[e],t))})},fi=function(i){var e,n,t,o=i.split("_"),l=o[o.length-1],r=/^\d+$/.test(l)?o.slice(0,-1).join("_"):i,a=null===(e=V.fieldCitations)||void 0===e?void 0:e[r];if(Array.isArray(a)&&a.length>0)return a;var d=null===(n=V.fieldCitations)||void 0===n?void 0:n[i];return Array.isArray(d)&&d.length>0?d:null!==(t=V.citations)&&void 0!==t?t:[]},gi={marginTop:"-17px",position:"relative",zIndex:1};l(function(){var i,e;null!=(null==_?void 0:_.autoScrollVariantIndex)&&(null===(e=null===(i=null==_?void 0:_.tierOptions)||void 0===i?void 0:i.filter(function(i){var e,n;return null===(n=null===(e=V.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(_.autoScrollVariantIndex),t=J.current.get(n);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==_?void 0:_.scrollTrigger]),console.log("CreateRule state:",V),console.log("CreateRule uiState:",_);var hi=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"},yi=!!(null==_?void 0:_.activeEditId);return e("div",i({className:"traffic-manager-template"},{children:[n("div",i({"data-edit-id":"rule-setup"},{children:n(s,i({title:{type:"other",label:(null==_?void 0:_.setupLabel)||"Rule Setup"},actionButtons:function(e,t){if(P)return null;var o=!!(null==_?void 0:_.activeEditId)&&"rule-setup"!==_.activeEditId;return n("div",i({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:n("button",i({title:o?"Save active edits first":"Edit",onClick:function(n){n.stopPropagation(),o?(null==_?void 0:_.setPendingEditId)&&_.setPendingEditId(_.activeEditId||null):(!function(){var e,n;(null==_?void 0:_.activeEditId)&&"rule-setup"!==_.activeEditId||(null===(e=null==_?void 0:_.setActiveEditId)||void 0===e||e.call(_,"rule-setup"),$(null!==(n=V.ruleTitle)&&void 0!==n?n:""),G(V.scopeData?i({},V.scopeData):{}))}(),(null==_?void 0:_.setPendingEditId)&&_.setPendingEditId(null),e||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:n(f,{size:14})}))}))},footerData:{ruleTitle:V.ruleTitle,stations:[V.scopeData.station],tiers:null===(D=V.scopeData)||void 0===D?void 0:D.tiers},defaultOpen:"Create"===(null==_?void 0:_.usedFor),readOnly:"Create"!==(null==_?void 0:_.usedFor),isAiStreaming:null==_?void 0:_.isAiStreaming,editFlow:"Edit"===(null==_?void 0:_.usedFor)},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[X&&(null==_?void 0:_.isAiStreaming)&&e("div",i({style:{display:"flex",alignItems:"center",color:"#141414ff",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[n(p,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),n(u,i({id:"rule-title",title:_.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:P&&null!==K?K:V.ruleTitle,onChange:function(i){return P?$(i):R.setRuleTitle(i)},readOnly:(null==_?void 0:_.isAiStreaming)||!P,isOpen:B.ruleTitle,onToggle:function(){return pi("ruleTitle")},isHighlighted:W.ruleTitle||!1,showCognitiveIcon:V.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(S=_.validationErrors)||void 0===S?void 0:S.ruleTitle},_)),V.citation.ruleTitle&&n("div",i({style:gi},{children:n(r,{isVisible:B.ruleTitle,citation:V.citation.ruleTitle,citations:fi("ruleTitle"),fieldName:"Rule Title",fieldValue:V.ruleTitle})})),n(c,i({id:"scope",title:"",required:!1,scopeData:P&&null!==Z?Z:V.scopeData,onScopeChange:function(e,n){P?G(function(t){var o;return i(i({},null!=t?t:V.scopeData),((o={})[e]=n,o))}):R.onScopeChange(e,n)},tierLabel:"Which tiers should this learning apply to?",stationLabel:"Which scope should this learning belong to?",highlights:W,isOpen:B.scopeData,onToggle:function(){return pi("scopeData")},showCognitiveIcon:V.citation.scopeData,cognitiveIcon:n(v,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(A=_.validationErrors)||void 0===A?void 0:A.station)||(null===(C=_.validationErrors)||void 0===C?void 0:C.tiers),stationErrorMessage:null===(I=_.validationErrors)||void 0===I?void 0:I.station,tierErrorMessage:null===(b=_.validationErrors)||void 0===b?void 0:b.tiers,readOnly:(null==_?void 0:_.isAiStreaming)||!P},_)),V.citation.scopeData&&n("div",i({style:gi},{children:n(r,{isVisible:B.scopeData,citation:V.citation.scopeData,citations:fi("scopeData"),fieldName:"Scope",fieldValue:null===(w=null===(O=V.scopeData)||void 0===O?void 0:O.tiers)||void 0===w?void 0:w.join(", ")})})),P?e("div",i({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e("div",i({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[n("button",i({onClick:ei,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e("button",i({onClick:ni,disabled:ai,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:ai?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:ai?.5:1}},{children:[n(g,{size:18,strokeWidth:2.5,color:"#ffffff"}),"Save Changes"]}))]})),"rule-setup"===(null==_?void 0:_.pendingEditId)&&e("div",i({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"10px"}},{children:[n(h,{size:14,style:{color:"#C2410C"}}),n("div",i({style:{color:"#C2410C",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]})):null]}))}))})),null===(E=null==_?void 0:_.tierOptions)||void 0===E?void 0:E.map(function(t,o){var l,c,v,p,f,g,h=t.toLowerCase().replace(/ /g,"_"),m=(null===(l=V.variantsByTier)||void 0===l?void 0:l[h])||[],T=null===(v=null===(c=V.scopeData)||void 0===c?void 0:c.tiers)||void 0===v?void 0:v.includes(t),x=m.length,D=!1;if(1===x){var S=m[0],A=!(null===(p=null==S?void 0:S.ruleDescription)||void 0===p?void 0:p.trim()),C=(null===(f=null==S?void 0:S.whenToApplyConditions)||void 0===f?void 0:f.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,I=(null===(g=null==S?void 0:S.whenNotToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!A||C||I||(D=!0)}var b=D?void 0:"".concat(x," ").concat(1===x?"variant":"variants"," configured for this tier");return console.log("Rendering tier : ",t),n(s,i({variant:"tier-header",title:{type:"other",label:t},subtitle:b,defaultOpen:!0,footerData:{description:"Variants for ".concat(t)}},{children:n(y,i({onAddVariant:function(){var i;return null===(i=R.addNewVariant)||void 0===i?void 0:i.call(R,h)},isDisabled:!T||(null==_?void 0:_.isAiStreaming),showAddVariantBtn:"Edit"!==(null==_?void 0:_.usedFor)},{children:m.map(function(t,o){var l,c,v,p,f,g,y,m,x,D,S=t.variantType||"default",A="".concat(h,"-variant-").concat(o),C=!0===t.is_variant,I="default"===S||"default_variant"===S,b="".concat(h,"_").concat(o),O=N.get(b)||{},w=(null===(c=null===(l=_.separationItemsByTier)||void 0===l?void 0:l[h])||void 0===c?void 0:c.get(o))||[],E=(null===(p=null===(v=_.togglesByTier)||void 0===v?void 0:v[h])||void 0===p?void 0:p.get(o))||[],W=null===(f=null==_?void 0:_.activeEditId)||void 0===f?void 0:f.startsWith("condition-wta-".concat(h,"-").concat(o)),L=null===(g=null==_?void 0:_.activeEditId)||void 0===g?void 0:g.startsWith("condition-wnta-".concat(h,"-").concat(o)),F=!T||t.isReadOnly||(null==_?void 0:_.isAiStreaming);return n("div",i({ref:function(i){i?J.current.set(A,i):J.current.delete(A)},style:{width:"100%",opacity:T?1:.7}},{children:n(s,i({title:{type:I?"default":"variant",label:hi(S),number:o+1,isNewVariant:C,isDefault:t.isDefault,isModified:t.isModified},defaultOpen:!0,expanded:j===A,onToggle:function(){var i,e=j===A;k(e?null:A),null===(i=null==_?void 0:_.setActiveVariantAccordionIndex)||void 0===i||i.call(_,e?null:o)},variant:"rule-behavior",footerData:{ruleTitle:S,description:t.ruleDescription||""},readOnly:F},{children:e("div",i({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[n(u,i({id:"rule-description-".concat(h,"-").concat(o),title:_.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:F||yi&&(null==_?void 0:_.activeEditId)!=="rule-description-".concat(h,"-").concat(o),value:t.ruleDescription||"",onChange:function(i){return R.setRuleDescription(h,o,i)},isOpen:B["ruleDescription-".concat(h)],onToggle:function(){return pi("ruleDescription-".concat(h))},isHighlighted:O.ruleDescription||!1,showCognitiveIcon:null===(y=V.citation)||void 0===y?void 0:y["ruleDescription_".concat(h)],tooltipDescription:"Why this Description?",errorMessage:null===(m=_.validationErrors)||void 0===m?void 0:m["ruleDescription-".concat(h,"-").concat(o)],enableInlineEdit:!0,setSendMessageInChat:null==_?void 0:_.setSendMessageInChat,isAiStreaming:null==_?void 0:_.isAiStreaming,fieldName:"Rule Description"},_)),(null===(x=V.citation)||void 0===x?void 0:x["ruleDescription_".concat(h)])&&n("div",i({style:gi},{children:n(r,{isVisible:B["ruleDescription-".concat(h)],citation:V.citation["ruleDescription_".concat(h)],citations:fi("ruleDescription_".concat(h,"_").concat(o)),fieldName:"Rule Description",fieldValue:t.ruleDescription})})),n(a,i({id:"when-to-apply-".concat(h,"-").concat(o),idPrefix:"condition-wta",title:_.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:F||yi&&!W,conditions:t.whenToApplyConditions||[],onAdd:function(){return R.addWhenToApply(h,o)},onRemove:function(i,e,n){return R.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return R.editWhenToApply(i,e,n,t)},index:o,tierKey:h,isHighlighted:O.wta||!1,highlightedIds:null==_?void 0:_.highlightedIds,tooltipDescription:"Why this Condition?",citations:fi("whenToApply_".concat(h,"_").concat(o)),bordered:!0,addLabel:"Add When to apply",isAiStreaming:_.isAiStreaming,errorMessage:(null===(D=_.validationErrors)||void 0===D?void 0:D["whenToApply-".concat(h,"-").concat(o)])||(null==_?void 0:_.conflictReason)},_)),n(a,i({id:"when-not-to-apply-".concat(h,"-").concat(o),idPrefix:"condition-wnta",title:_.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:F||yi&&!L,conditions:t.whenNotToApplyConditions||[],onAdd:function(){return R.addWhenNotToApply(h,o)},onRemove:function(i,e,n){return R.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return R.editWhenNotToApply(i,e,n,t)},index:o,tierKey:h,isHighlighted:O.wnta||!1,highlightedIds:null==_?void 0:_.highlightedIds,tooltipDescription:"Why this Condition?",citations:fi("whenNotToApply_".concat(h,"_").concat(o)),bordered:!0,addLabel:"Add When NOT to apply",isAiStreaming:_.isAiStreaming},_)),n(d,i({id:"config-".concat(h,"-").concat(o),title:_.configTitle||"Configuration",required:!1,highlights:O,bordered:!0,readOnly:F||yi&&(null==_?void 0:_.activeEditId)!=="config-".concat(h,"-").concat(o),onConfigChange:function(i,e){return R.onConfigChange(h,o,i,e)},separationItems:w,toggles:E,index:o},_))]}))}),A)}),"".concat(h,"-variant-").concat(o))})}))}),"tier-".concat(o))})]}))};export{m as CreateRule};
2
2
  //# sourceMappingURL=CreateRule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScopeSection.d.ts","sourceRoot":"","sources":["../../../../../../../../src/features/IL-OTJ/_components/organisms/ScopeSection/ScopeSection.tsx"],"names":[],"mappings":";AAMA,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,iBAAiB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACnE,SAAS,EAAE;QACT,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;IACF,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACnD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAChC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,YAAY,8RAsBtB,iBAAiB,4CAmLnB,CAAC"}
1
+ {"version":3,"file":"ScopeSection.d.ts","sourceRoot":"","sources":["../../../../../../../../src/features/IL-OTJ/_components/organisms/ScopeSection/ScopeSection.tsx"],"names":[],"mappings":";AAMA,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,iBAAiB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACnE,SAAS,EAAE;QACT,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;IACF,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACnD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAChC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,YAAY,8RAsBtB,iBAAiB,4CAuLnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CreateRule.d.ts","sourceRoot":"","sources":["../../../../../../../../src/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.tsx"],"names":[],"mappings":"AA6DA,eAAO,MAAM,UAAU,iCAAkC,GAAG,4CAosB3D,CAAC"}
1
+ {"version":3,"file":"CreateRule.d.ts","sourceRoot":"","sources":["../../../../../../../../src/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.tsx"],"names":[],"mappings":"AA6DA,eAAO,MAAM,UAAU,iCAAkC,GAAG,4CAwqB3D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-llm-studio/instant-learning",
3
- "version": "0.0.296",
3
+ "version": "0.0.297",
4
4
  "author": "Devesh Patel",
5
5
  "description": "",
6
6
  "license": "MIT",