@e-llm-studio/instant-learning 1.3.0-alpha.21 → 1.3.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/dist/cjs/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
  2. package/dist/cjs/features/LearningManagement/RuleContent/AddScopeModal.js +1 -1
  3. package/dist/cjs/features/LearningManagement/components/CreateLearningSetModal.js +1 -1
  4. package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
  5. package/dist/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.js +1 -1
  6. package/dist/features/LearningManagement/RuleContent/AddScopeModal.js +1 -1
  7. package/dist/features/LearningManagement/components/CreateLearningSetModal.js +1 -1
  8. package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
  9. package/dist/types/src/features/IL-OTJ/_components/templates/TrafficManager/CreateRule.d.ts.map +1 -1
  10. package/dist/types/src/features/LearningManagement/RuleContent/AddScopeModal.d.ts.map +1 -1
  11. package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
  12. package/package.json +1 -1
  13. package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js +0 -2
  14. package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js.map +0 -1
  15. package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +0 -2
  16. package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +0 -1
  17. package/dist/features/LearningManagement/assets/Search-result(add new).svg.js +0 -2
  18. package/dist/features/LearningManagement/assets/Search-result(add new).svg.js.map +0 -1
  19. package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +0 -2
  20. package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +0 -1
  21. package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts +0 -12
  22. package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),e=require("react/jsx-runtime"),n=require("react"),t=require("../../InputDataReasoningCard.js"),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,A=c.state,I=c.handlers,b=c.uiState,j=(null==b?void 0:b.highlights)||new Map,E=j.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==b?void 0:b.defaultTierOpen)>=0&&(null===(i=null==b?void 0:b.tierOptions)||void 0===i?void 0:i[b.defaultTierOpen]))return b.tierOptions[b.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(n=null===(e=A.scopeData)||void 0===e?void 0:e.tiers)||void 0===n?void 0:n[0];return t?t.toLowerCase().replace(/ /g,"_"):null});q[0];var L=q[1],B="rule-setup"===(null==b?void 0:b.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==b?void 0:b.isAiStreaming);n.useEffect(function(){Z.current&&!(null==b?void 0:b.isAiStreaming)&&$&&U(!1),Z.current=null==b?void 0:b.isAiStreaming},[null==b?void 0:b.isAiStreaming,$]);var G=function(){var i;z(null),H(null),null===(i=null==b?void 0:b.setActiveEditId)||void 0===i||i.call(b,null)},Q=function(){var i,e,n=null!=k?k:A.ruleTitle,t=null!=J?J:A.scopeData,o=n!==A.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(A.scopeData);if(!o&&!l)return z(null),H(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))}U(!0),z(null),H(null),null===(e=null==b?void 0:b.setActiveEditId)||void 0===e||e.call(b,null)},X=null!==k?null==k?void 0:k.trim():(A.ruleTitle||"").trim(),Y=null!=J?J:A.scopeData,ii=X!==(A.ruleTitle||"").trim(),ei=JSON.stringify(Y)!==JSON.stringify(A.scopeData),ni=!ii&&!ei||""===X,ti=v.default.useRef(null==b?void 0:b.defaultVariantOpen),oi=v.default.useRef(null==b?void 0:b.activeVariantAccordionIndex),li=v.default.useRef(null==b?void 0:b.defaultTierOpen),ai=v.default.useRef(null===(f=A.scopeData)||void 0===f?void 0:f.tiers),ri=v.default.useRef(A.variantsByTier);v.default.useEffect(function(){var i,e,n,t,o,l,a=null,r=!1;ti.current!==(null==b?void 0:b.defaultVariantOpen)&&(r=!0,ti.current=null==b?void 0:b.defaultVariantOpen),oi.current!==(null==b?void 0:b.activeVariantAccordionIndex)&&(r=!0,oi.current=null==b?void 0:b.activeVariantAccordionIndex),li.current!==(null==b?void 0:b.defaultTierOpen)&&(r=!0,li.current=null==b?void 0:b.defaultTierOpen);var d=(null===(i=A.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==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=ri.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 W(null),void(ri.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&&W(a)}if(null===N){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]&&W("".concat(t,"-variant-").concat(v))}}))}ri.current=A.variantsByTier},[A.variantsByTier,null==b?void 0:b.defaultVariantOpen,null==b?void 0:b.activeVariantAccordionIndex,null===(g=A.scopeData)||void 0===g?void 0:g.tiers,null==b?void 0:b.tierOptions,null==b?void 0:b.autoScrollVariantIndex,null==b?void 0:b.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=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:[]},ui={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 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==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"),z(null!==(n=A.ruleTitle)&&void 0!==n?n:""),H(A.scopeData?i.__assign({},A.scopeData):{}))}(),(null==b?void 0:b.setPendingEditId)&&b.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: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:[$&&(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?z(i):I.setRuleTitle(i)},readOnly:(null==b?void 0:b.isAiStreaming)||!B,isOpen:w.ruleTitle,onToggle:function(){return di("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:ui},{children:e.jsx(t.InputDataReasoningCard,{isVisible:w.ruleTitle,citation:A.citation.ruleTitle,citations:si("ruleTitle"),fieldName:"Rule Title",fieldValue:A.ruleTitle})})),e.jsx(a.ScopeSection,i.__assign({id:"scope",title:"",required:!1,scopeData:B&&null!==J?J:A.scopeData,onScopeChange:function(e,n){B?H(function(t){var o;return i.__assign(i.__assign({},null!=t?t:A.scopeData),((o={})[e]=n,o))}):I.onScopeChange(e,n)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:E,isOpen:w.scopeData,onToggle:function(){return di("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:ui},{children:e.jsx(t.InputDataReasoningCard,{isVisible:w.scopeData,citation:A.citation.scopeData,citations:si("scopeData"),fieldName:"Scope",fieldValue:null===(C=null===(m=A.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==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===(D=null==b?void 0:b.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=A.variantsByTier)||void 0===s?void 0:s[h])||[],y=null===(c=null===(u=A.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=I.addNewVariant)||void 0===i?void 0:i.call(I,h)},isDisabled:!y||(null==b?void 0:b.isAiStreaming),showAddVariantBtn:"Edit"!==(null==b?void 0:b.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=j.get(E)||{},R=(null===(u=null===(s=b.separationItemsByTier)||void 0===s?void 0:s[h])||void 0===u?void 0:u.get(a))||[],V=(null===(v=null===(c=b.togglesByTier)||void 0===c?void 0:c[h])||void 0===v?void 0:v.get(a))||[],q=null===(p=null==b?void 0:b.activeEditId)||void 0===p?void 0:p.startsWith("condition-wta-".concat(h,"-").concat(a)),L=null===(f=null==b?void 0:b.activeEditId)||void 0===f?void 0:f.startsWith("condition-wnta-".concat(h,"-").concat(a)),B=!y||n.isReadOnly||(null==b?void 0:b.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==b?void 0:b.setActiveVariantAccordionIndex)||void 0===i||i.call(b,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:b.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:B||vi&&(null==b?void 0:b.activeEditId)!=="rule-description-".concat(h,"-").concat(a),value:n.ruleDescription||"",onChange:function(i){return I.setRuleDescription(h,a,i)},isOpen:w["ruleDescription-".concat(h)],onToggle:function(){return di("ruleDescription-".concat(h))},isHighlighted:O.ruleDescription||!1,showCognitiveIcon:null===(g=A.citation)||void 0===g?void 0:g["ruleDescription_".concat(h)],tooltipDescription:"Why this Description?",errorMessage:null===(x=b.validationErrors)||void 0===x?void 0:x["ruleDescription-".concat(h,"-").concat(a)],enableInlineEdit:!0,setSendMessageInChat:null==b?void 0:b.setSendMessageInChat,isAiStreaming:null==b?void 0:b.isAiStreaming,fieldName:"Rule Description"},b)),(null===(_=A.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:A.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:b.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:B||vi&&!q,conditions:n.whenToApplyConditions||[],onAdd:function(){return I.addWhenToApply(h,a)},onRemove:function(i,e,n){return I.removeWhenToApply(i,e,n)},onEdit:function(i,e,n,t){return I.editWhenToApply(i,e,n,t)},index:a,tierKey:h,isHighlighted:O.wta||!1,highlightedIds:null==b?void 0:b.highlightedIds,tooltipDescription:"Why this Condition?",citations:si("whenToApply_".concat(h,"_").concat(a)),bordered:!0,addLabel:(null==b?void 0:b.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:b.isAiStreaming,errorMessage:(null===(T=b.validationErrors)||void 0===T?void 0:T["whenToApply-".concat(h,"-").concat(a)])||(null==b?void 0:b.conflictReason)},b)),e.jsx(o.ConditionSection,i.__assign({id:"when-not-to-apply-".concat(h,"-").concat(a),idPrefix:"condition-wnta",title:b.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:B||vi&&!L,conditions:n.whenNotToApplyConditions||[],onAdd:function(){return I.addWhenNotToApply(h,a)},onRemove:function(i,e,n){return I.removeWhenNotToApply(i,e,n)},onEdit:function(i,e,n,t){return I.editWhenNotToApply(i,e,n,t)},index:a,tierKey:h,isHighlighted:O.wnta||!1,highlightedIds:null==b?void 0:b.highlightedIds,tooltipDescription:"Why this Condition?",citations:si("whenNotToApply_".concat(h,"_").concat(a)),bordered:!0,addLabel:(null==b?void 0:b.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:b.isAiStreaming},b)),(null==b?void 0:b.showConfiguration)&&e.jsx(l.ConfigSection,i.__assign({id:"config-".concat(h,"-").concat(a),title:b.configTitle||"Configuration",required:!1,highlights:O,bordered:!0,readOnly:B||vi&&(null==b?void 0:b.activeEditId)!=="config-".concat(h,"-").concat(a),onConfigChange:function(i,e){return I.onConfigChange(h,a,i,e)},separationItems:R,toggles:V,index:a},b))]}))}),m)}),"".concat(h,"-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,A,I=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({}),V=w[0],R=w[1],N=n.useState(null),W=N[0],q=N[1],L=n.useState(function(){var i,e,n;if((null==b?void 0:b.defaultTierOpen)>=0&&(null===(i=null==b?void 0:b.tierOptions)||void 0===i?void 0:i[b.defaultTierOpen]))return b.tierOptions[b.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});L[0];var B=L[1],F="rule-setup"===(null==b?void 0:b.activeEditId),M=v.default.useRef(new Map),k=n.useState(null),z=k[0],P=k[1],J=n.useState(null),H=J[0],K=J[1],$=n.useState(!1),U=$[0],Z=$[1],G=v.default.useRef(null==b?void 0:b.isAiStreaming);n.useEffect(function(){G.current&&!(null==b?void 0:b.isAiStreaming)&&U&&Z(!1),G.current=null==b?void 0:b.isAiStreaming},[null==b?void 0:b.isAiStreaming,U]);var Q=function(){var i;P(null),K(null),null===(i=null==b?void 0:b.setActiveEditId)||void 0===i||i.call(b,null)},X=function(){var i,e,n=null!=z?z:I.ruleTitle,t=null!=H?H:I.scopeData,o=n!==I.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(I.scopeData);if(!o&&!l)return P(null),K(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))}Z(!0),P(null),K(null),null===(e=null==b?void 0:b.setActiveEditId)||void 0===e||e.call(b,null)},Y=null!==z?null==z?void 0:z.trim():(I.ruleTitle||"").trim(),ii=null!=H?H:I.scopeData,ei=Y!==(I.ruleTitle||"").trim(),ni=JSON.stringify(ii)!==JSON.stringify(I.scopeData),ti=!ei&&!ni||""===Y,oi=v.default.useRef(null==b?void 0:b.defaultVariantOpen),li=v.default.useRef(null==b?void 0:b.activeVariantAccordionIndex),ai=v.default.useRef(null==b?void 0:b.defaultTierOpen),ri=v.default.useRef(null===(f=I.scopeData)||void 0===f?void 0:f.tiers),di=v.default.useRef(I.variantsByTier);v.default.useEffect(function(){var i,e,n,t,o,l,a=null,r=!1;oi.current!==(null==b?void 0:b.defaultVariantOpen)&&(r=!0,oi.current=null==b?void 0:b.defaultVariantOpen),li.current!==(null==b?void 0:b.activeVariantAccordionIndex)&&(r=!0,li.current=null==b?void 0:b.activeVariantAccordionIndex),ai.current!==(null==b?void 0:b.defaultTierOpen)&&(r=!0,ai.current=null==b?void 0:b.defaultTierOpen);var d=(null===(i=I.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(ri.current)!==JSON.stringify(d)&&(r=!0,ri.current=d,d.length>0&&B(d[0].toLowerCase().replace(/ /g,"_")));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=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=di.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==b?void 0:b.activeVariantAccordionIndex)&&void 0!==n?n:null==b?void 0:b.defaultVariantOpen;if(null==c||c<0)return q(null),void(di.current=I.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=I.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=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==b?void 0:b.defaultTierOpen)>=0&&e!==b.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(n=I.variantsByTier)||void 0===n?void 0:n[t])||[])[v]&&q("".concat(t,"-variant-").concat(v))}}))}di.current=I.variantsByTier},[I.variantsByTier,null==b?void 0:b.defaultVariantOpen,null==b?void 0:b.activeVariantAccordionIndex,null===(g=I.scopeData)||void 0===g?void 0:g.tiers,null==b?void 0:b.tierOptions,null==b?void 0:b.autoScrollVariantIndex,null==b?void 0:b.defaultTierOpen]);var si=function(e){R(function(n){var t;return i.__assign(i.__assign({},n),((t={})[e]=!n[e],t))})},ui=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:[]},ci={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=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(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:",I),console.log("CreateRule uiState:",b);var vi=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"},pi=!!(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(F)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"),P(null!==(n=I.ruleTitle)&&void 0!==n?n:""),K(I.scopeData?i.__assign({},I.scopeData):{}))}(),(null==b?void 0:b.setPendingEditId)&&b.setPendingEditId(null),n||t())},disabled:U,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid #e5e7eb",borderRadius:"8px",cursor:U?"not-allowed":"pointer",backgroundColor:"#ffffff",color:"#6b7280",opacity:U?.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==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:[U&&(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:F&&null!==z?z:I.ruleTitle,onChange:function(i){return F?P(i):j.setRuleTitle(i)},readOnly:(null==b?void 0:b.isAiStreaming)||!F,isOpen:V.ruleTitle,onToggle:function(){return si("ruleTitle")},isHighlighted:E.ruleTitle||!1,showCognitiveIcon:I.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(x=b.validationErrors)||void 0===x?void 0:x.ruleTitle},b)),I.citation.ruleTitle&&e.jsx("div",i.__assign({style:ci},{children:e.jsx(t.InputDataReasoningCard,{isVisible:V.ruleTitle,citation:I.citation.ruleTitle,citations:ui("ruleTitle"),fieldName:"Rule Title",fieldValue:I.ruleTitle})})),(null===(y=null==b?void 0:b.tierOptions)||void 0===y?void 0:y.length)>1&&e.jsx(a.ScopeSection,i.__assign({id:"scope",title:"",required:!1,scopeData:F&&null!==H?H:I.scopeData,onScopeChange:function(e,n){F?K(function(t){var o;return i.__assign(i.__assign({},null!=t?t:I.scopeData),((o={})[e]=n,o))}):j.onScopeChange(e,n)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:E,isOpen:V.scopeData,onToggle:function(){return si("scopeData")},showCognitiveIcon:I.citation.scopeData,cognitiveIcon:e.jsx(s.ButtonCognitiveIcon,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(_=b.validationErrors)||void 0===_?void 0:_.station)||(null===(T=b.validationErrors)||void 0===T?void 0:T.tiers),stationErrorMessage:null===(S=b.validationErrors)||void 0===S?void 0:S.station,tierErrorMessage:null===(m=b.validationErrors)||void 0===m?void 0:m.tiers,readOnly:(null==b?void 0:b.isAiStreaming)||!F},b)),I.citation.scopeData&&e.jsx("div",i.__assign({style:ci},{children:e.jsx(t.InputDataReasoningCard,{isVisible:V.scopeData,citation:I.citation.scopeData,citations:ui("scopeData"),fieldName:"Scope",fieldValue:null===(D=null===(C=I.scopeData)||void 0===C?void 0:C.tiers)||void 0===D?void 0:D.join(", ")})})),F?e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[e.jsxs("div",i.__assign({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[e.jsx("button",i.__assign({onClick:Q,style:{background:"none",border:"none",color:"#6b7280",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),e.jsxs("button",i.__assign({onClick:X,disabled:ti,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"#2563eb",color:"#ffffff",fontSize:"14px",fontWeight:"500",cursor:ti?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:ti?.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===(A=null==b?void 0:b.tierOptions)||void 0===A?void 0:A.map(function(n,a){var s,u,c,f,g,h,x,y=n.toLowerCase().replace(/ /g,"_"),_=(null===(s=I.variantsByTier)||void 0===s?void 0:s[y])||[],T=null===(c=null===(u=I.scopeData)||void 0===u?void 0:u.tiers)||void 0===c?void 0:c.includes(n),S=_.length,m=!1;if(1===S){var C=_[0],D=!(null===(f=null==C?void 0:C.ruleDescription)||void 0===f?void 0:f.trim()),A=(null===(g=null==C?void 0:C.whenToApplyConditions)||void 0===g?void 0:g.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,E=(null===(h=null==C?void 0:C.whenNotToApplyConditions)||void 0===h?void 0:h.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!D||A||E||(m=!0)}var w=m?void 0:"".concat(S," ").concat(1===S?"variant":"variants"," configured for this tier"),R=e.jsx(p,i.__assign({onAddVariant:function(){var i;return null===(i=j.addNewVariant)||void 0===i?void 0:i.call(j,y)},isDisabled:!T||(null==b?void 0:b.isAiStreaming),showAddVariantBtn:"Edit"!==(null==b?void 0:b.usedFor)},{children:_.map(function(n,a){var s,u,c,v,p,f,g,h,x,_,S=n.variantType||"default",m="".concat(y,"-variant-").concat(a),C=!0===n.is_variant,D="default"===S||"default_variant"===S,A="".concat(y,"_").concat(a),E=O.get(A)||{},w=(null===(u=null===(s=b.separationItemsByTier)||void 0===s?void 0:s[y])||void 0===u?void 0:u.get(a))||[],R=(null===(v=null===(c=b.togglesByTier)||void 0===c?void 0:c[y])||void 0===v?void 0:v.get(a))||[],N=null===(p=null==b?void 0:b.activeEditId)||void 0===p?void 0:p.startsWith("condition-wta-".concat(y,"-").concat(a)),L=null===(f=null==b?void 0:b.activeEditId)||void 0===f?void 0:f.startsWith("condition-wnta-".concat(y,"-").concat(a)),B=!T||n.isReadOnly||(null==b?void 0:b.isAiStreaming);return e.jsx("div",i.__assign({ref:function(i){i?M.current.set(m,i):M.current.delete(m)},style:{width:"100%",opacity:T?1:.7}},{children:e.jsx(d.default,i.__assign({title:{type:D?"default":"variant",label:vi(S),number:a+1,isNewVariant:C,isDefault:n.isDefault,isModified:n.isModified},defaultOpen:!0,expanded:W===m,onToggle:function(){var i,e=W===m;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||""},readOnly:B},{children:e.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[e.jsx(r.TextSection,i.__assign({id:"rule-description-".concat(y,"-").concat(a),title:b.ruleDescriptionTitle||"Rule Description",rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:B||pi&&(null==b?void 0:b.activeEditId)!=="rule-description-".concat(y,"-").concat(a),value:n.ruleDescription||"",onChange:function(i){return j.setRuleDescription(y,a,i)},isOpen:V["ruleDescription-".concat(y)],onToggle:function(){return si("ruleDescription-".concat(y))},isHighlighted:E.ruleDescription||!1,showCognitiveIcon:null===(g=I.citation)||void 0===g?void 0:g["ruleDescription_".concat(y)],tooltipDescription:"Why this Description?",errorMessage:null===(h=b.validationErrors)||void 0===h?void 0:h["ruleDescription-".concat(y,"-").concat(a)],enableInlineEdit:!0,setSendMessageInChat:null==b?void 0:b.setSendMessageInChat,isAiStreaming:null==b?void 0:b.isAiStreaming,fieldName:"Rule Description"},b)),(null===(x=I.citation)||void 0===x?void 0:x["ruleDescription_".concat(y)])&&e.jsx("div",i.__assign({style:ci},{children:e.jsx(t.InputDataReasoningCard,{isVisible:V["ruleDescription-".concat(y)],citation:I.citation["ruleDescription_".concat(y)],citations:ui("ruleDescription_".concat(y,"_").concat(a)),fieldName:"Rule Description",fieldValue:n.ruleDescription})})),e.jsx(o.ConditionSection,i.__assign({id:"when-to-apply-".concat(y,"-").concat(a),idPrefix:"condition-wta",title:b.whenToApplyTitle||"When to apply",required:!0,dividerRequired:!0,readOnly:B||pi&&!N,conditions:n.whenToApplyConditions||[],onAdd:function(){return j.addWhenToApply(y,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:y,isHighlighted:E.wta||!1,highlightedIds:null==b?void 0:b.highlightedIds,tooltipDescription:"Why this Condition?",citations:ui("whenToApply_".concat(y,"_").concat(a)),bordered:!0,addLabel:(null==b?void 0:b.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:b.isAiStreaming,errorMessage:(null===(_=b.validationErrors)||void 0===_?void 0:_["whenToApply-".concat(y,"-").concat(a)])||(null==b?void 0:b.conflictReason)},b)),e.jsx(o.ConditionSection,i.__assign({id:"when-not-to-apply-".concat(y,"-").concat(a),idPrefix:"condition-wnta",title:b.whenNotToApplyTitle||"When NOT to apply",required:!1,dividerRequired:!0,readOnly:B||pi&&!L,conditions:n.whenNotToApplyConditions||[],onAdd:function(){return j.addWhenNotToApply(y,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:y,isHighlighted:E.wnta||!1,highlightedIds:null==b?void 0:b.highlightedIds,tooltipDescription:"Why this Condition?",citations:ui("whenNotToApply_".concat(y,"_").concat(a)),bordered:!0,addLabel:(null==b?void 0:b.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:b.isAiStreaming},b)),(null==b?void 0:b.showConfiguration)&&e.jsx(l.ConfigSection,i.__assign({id:"config-".concat(y,"-").concat(a),title:b.configTitle||"Configuration",required:!1,highlights:E,bordered:!0,readOnly:B||pi&&(null==b?void 0:b.activeEditId)!=="config-".concat(y,"-").concat(a),onConfigChange:function(i,e){return j.onConfigChange(y,a,i,e)},separationItems:w,toggles:R,index:a},b))]}))}),m)}),"".concat(y,"-variant-").concat(a))})}));return 1===(null===(x=null==b?void 0:b.tierOptions)||void 0===x?void 0:x.length)?e.jsx(v.default.Fragment,{children:R},"tier-".concat(a)):e.jsx(d.default,i.__assign({variant:"tier-header",title:{type:"other",label:n},subtitle:w,defaultOpen:!0,footerData:{description:"Variants for ".concat(n)}},{children:R}),"tier-".concat(a))})]}))};
2
2
  //# sourceMappingURL=CreateRule.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),r=require("@tanstack/react-query"),i=require("lucide-react"),o=require("primereact/toast"),s=require("uuid"),a=require("../components/StationOnboarding/StationAutocomplete.js"),l=require("./AddScopeApprovalSearchComponent.js"),u=require("../components/ScopeSkeletonLoader.js"),c=require("@mui/material"),d=require("../store/useAuthStore.js"),p=require("../store/useAppSecRolesStore.js"),_=require("../store/useEnvStore.js"),g=require("../apis/scopeApis.js"),h=require("../store/useLearningTemplateStore.js"),f=require("../config.js"),m=require("../store/useLMSConfigStore.js"),v=require("../constants.js");exports.default=function(S){var x=S.isOpen,y=S.onClose,b=S.onCreate,D=S.hasGlobalRuleSet,A=S.parentId,j=t.useState(""),C=j[0],R=j[1],E=t.useState(""),T=E[0],q=E[1],I=t.useState({}),L=I[0],P=I[1],w=t.useRef(null),k=d.default().user,W=p.useAppSecRolesStore(function(e){return e.roles}),N=_.default(function(e){return e.rbacConfig}),O=t.useState(null),F=O[0],M=O[1],z=t.useState("approval_required"),G=z[0],B=z[1],H=t.useState([]),V=H[0],K=H[1],U=t.useState([]),X=U[0],J=U[1],Q=t.useState(""),Y=Q[0],Z=Q[1],$=r.useMutation({mutationFn:function(n){return e.__awaiter(void 0,void 0,void 0,function(){var t;return e.__generator(this,function(e){switch(e.label){case 0:return[4,g.createRuleSet(n,null!==(t=null==k?void 0:k.accessToken)&&void 0!==t?t:"")];case 1:return[2,e.sent()]}})})},onSuccess:function(n){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){return console.log("Rule Set Created Successfully",n),[2]})})}});$.data;var ee=$.isPending,ne=$.mutateAsync;return t.useEffect(function(){x&&(R(""),q(""),P({}),M(null),B("approval_required"),K([]),J([]),Z(""))},[x]),x?ee?n.jsx(u.default,{isLoading:ee}):n.jsxs("div",e.__assign({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[n.jsx(o.Toast,{ref:w}),n.jsxs("div",e.__assign({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[n.jsxs("div",e.__assign({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[n.jsxs("div",{children:[n.jsx("h2",e.__assign({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".title"),"Add Scope")})),n.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".subtitle"),"This scope will be created under Global and will inherit its Learnings by default.",{parent:"Global"})}))]}),n.jsx("button",e.__assign({onClick:y,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:n.jsx(i.X,{size:24})}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:20}},{children:[n.jsxs("div",e.__assign({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[n.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".scopeName"),"Scope Name")]})),"Custom"===C?n.jsx(a.default,{value:T,onChange:function(n){if(n.length>50)return q(n.slice(0,50)),void P(function(n){return e.__assign(e.__assign({},n),{name:"Scope Name must be 50 characters or fewer"})});q(n),P(function(n){return e.__assign(e.__assign({},n),{name:void 0})})},onStationSelect:function(e){M(e)},style:{border:L.name?"1px solid #8F2C23":void 0}}):n.jsx(c.Input,{value:T,onChange:function(n){var t=n.target.value;if(t.length>50)return q(t.slice(0,50)),void P(function(n){return e.__assign(e.__assign({},n),{name:"Scope Name must be 50 characters or fewer"})});q(t),P(function(n){return e.__assign(e.__assign({},n),{name:void 0})})},style:{border:"1px solid ".concat(L.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),L.name&&n.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:L.name}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:12}},{children:[n.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".title"),"Learning Approval Settings")]})),n.jsxs("div",e.__assign({role:"radio","aria-checked":"approval_required"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return B("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||B("approval_required")}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===G?"#2563EB":"#CBD5E1")}},{children:"approval_required"===G&&n.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===G&&n.jsx(l.default,{selectedApprovers:V,selectedGroupOfApprovers:X,onApproversChange:K,onGroupsChange:J}),Y&&n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:Y})),n.jsxs("div",e.__assign({role:"radio","aria-checked":"publish_without"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){B("publish_without"),Z("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(B("publish_without"),Z(""))}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===G?"#2563EB":"#CBD5E1")}},{children:"publish_without"===G&&n.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),n.jsxs("div",e.__assign({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[n.jsx("button",e.__assign({onClick:y,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:ee?.5:1},disabled:ee},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".cancel"),"Cancel")})),n.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,t,r,i,o,a,l,u,c,d,p,_,g,m;return e.__generator(this,function(v){switch(v.label){case 0:if(n={},T.trim()?T.length>50&&(n.name="Scope Name must be 50 characters or fewer"):n.name="Scope Name is required","approval_required"===G&&0===V.length&&0===X.length&&Z("Please select at least one approver or approver group."),n.name)return P(n),[2];if("approval_required"===G&&0===V.length&&0===X.length)return[2];Z(""),v.label=1;case 1:return v.trys.push([1,3,,4]),t="approval_required"===G,r=h.useLearningTemplateStore.getState().backwardCompatibility,i=r?{topic:D?"genreRuleSet":"globalRuleSet",customScopeGroupName:f.IL_CONFIG_CONSTANTS.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:T,parentScopeId:null,customScopeName:T,customScopeId:s.v4(),createByName:(null==k?void 0:k.firstname)||"System",createdBy:(null==k?void 0:k.email)||"system@audacy.com",approvalRequired:t,appsecData:{application:null==N?void 0:N.applicationId,module:null==N?void 0:N.moduleId,roles:e.__spreadArray(e.__spreadArray([],t?[{users:V.map(function(e){return e.email}),groups:X.map(function(e){return e._id}),role:null!==(u=null===(l=W.find(function(e){return"Learning Manager"===e.name}))||void 0===l?void 0:l._id)&&void 0!==u?u:""}]:[],!0),[{users:[null==k?void 0:k.email],groups:[],role:null!==(d=null===(c=W.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===c?void 0:c._id)&&void 0!==d?d:""}],!1)}}:{topic:D?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:T,parentScopeId:null!=A?A:null,scopeName:T,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:h.useLearningTemplateStore.getState().app_integration_id},console.log("Add Scope payload:",i),[4,ne(i)];case 2:return o=v.sent(),b(null===(p=null==o?void 0:o.data)||void 0===p?void 0:p.scopeId),y(),[3,4];case 3:return a=v.sent(),console.error("An error occurred during scope creation.",a),null===(_=w.current)||void 0===_||_.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(m=null===(g=null==a?void 0:a.response)||void 0===g?void 0:g.data)||void 0===m?void 0:m.message)||"There was an error creating the scope. Please try again."}),[3,4];case 4:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:ee||"Custom"===C&&!F?.5:1},disabled:ee||"Custom"===C&&!F},{children:ee?n.jsxs(n.Fragment,{children:[n.jsx(i.Loader2,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),r=require("react"),n=require("@tanstack/react-query"),i=require("lucide-react"),o=require("primereact/toast"),s=require("uuid"),a=require("../components/StationOnboarding/StationAutocomplete.js"),l=require("./AddScopeApprovalSearchComponent.js"),c=require("../components/ScopeSkeletonLoader.js"),u=require("@mui/material"),d=require("../store/useAuthStore.js"),p=require("../store/useAppSecRolesStore.js"),_=require("../store/useEnvStore.js"),g=require("../apis/scopeApis.js"),h=require("../store/useLearningTemplateStore.js"),f=require("../config.js"),m=require("../store/useLMSConfigStore.js"),v=require("../constants.js");exports.default=function(S){var x=S.isOpen,y=S.onClose,b=S.onCreate,D=S.hasGlobalRuleSet,A=S.parentId,j=r.useState(""),C=j[0],R=j[1],E=r.useState(""),T=E[0],q=E[1],I=r.useState({}),L=I[0],w=I[1],P=r.useRef(null),k=d.default().user,W=p.useAppSecRolesStore(function(e){return e.roles}),N=_.default(function(e){return e.rbacConfig}),F=r.useState(null),O=F[0],M=F[1],z=r.useState("approval_required"),G=z[0],B=z[1],H=r.useState([]),V=H[0],K=H[1],U=r.useState([]),X=U[0],J=U[1],Q=r.useState(""),Y=Q[0],Z=Q[1],$=n.useMutation({mutationFn:function(t){return e.__awaiter(void 0,void 0,void 0,function(){var r;return e.__generator(this,function(e){switch(e.label){case 0:return[4,g.createRuleSet(t,null!==(r=null==k?void 0:k.accessToken)&&void 0!==r?r:"")];case 1:return[2,e.sent()]}})})},onSuccess:function(t){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){return console.log("Rule Set Created Successfully",t),[2]})})}});$.data;var ee=$.isPending,te=$.mutateAsync;return r.useEffect(function(){x&&(R(""),q(""),w({}),M(null),B("approval_required"),K([]),J([]),Z(""))},[x]),x?ee?t.jsx(c.default,{isLoading:ee}):t.jsxs("div",e.__assign({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[t.jsx(o.Toast,{ref:P}),t.jsxs("div",e.__assign({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[t.jsxs("div",e.__assign({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[t.jsxs("div",{children:[t.jsx("h2",e.__assign({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".title"),"Add Scope")})),t.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".subtitle"),"This scope will be created under Global and will inherit its Learnings by default.",{parent:"Global"})}))]}),t.jsx("button",e.__assign({onClick:y,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:t.jsx(i.X,{size:24})}))]})),t.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:20}},{children:[t.jsxs("div",e.__assign({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[t.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".scopeName"),"Scope Name")]})),"Custom"===C?t.jsx(a.default,{value:T,onChange:function(t){if(t.length>50)return q(t.slice(0,50)),void w(function(t){return e.__assign(e.__assign({},t),{name:"Scope Name must be 50 characters or fewer"})});q(t),w(function(t){return e.__assign(e.__assign({},t),{name:void 0})})},onStationSelect:function(e){M(e)},style:{border:L.name?"1px solid #8F2C23":void 0}}):t.jsx(u.Input,{value:T,onChange:function(t){var r=t.target.value;if(r.length>50)return q(r.slice(0,50)),void w(function(t){return e.__assign(e.__assign({},t),{name:"Scope Name must be 50 characters or fewer"})});q(r),w(function(t){return e.__assign(e.__assign({},t),{name:void 0})})},style:{border:"1px solid ".concat(L.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),L.name&&t.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:L.name}))]})),t.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:12}},{children:[t.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".title"),"Learning Approval Settings")]})),t.jsxs("div",e.__assign({role:"radio","aria-checked":"approval_required"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return B("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||B("approval_required")}},{children:[t.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[t.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===G?"#2563EB":"#CBD5E1")}},{children:"approval_required"===G&&t.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),t.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===G&&t.jsx(l.default,{selectedApprovers:V,selectedGroupOfApprovers:X,onApproversChange:K,onGroupsChange:J}),Y&&t.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:Y})),t.jsxs("div",e.__assign({role:"radio","aria-checked":"publish_without"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){B("publish_without"),Z("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(B("publish_without"),Z(""))}},{children:[t.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[t.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===G?"#2563EB":"#CBD5E1")}},{children:"publish_without"===G&&t.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),t.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),t.jsxs("div",e.__assign({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[t.jsx("button",e.__assign({onClick:y,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:ee?.5:1},disabled:ee},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".cancel"),"Cancel")})),t.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var t,r,n,i,o,a,l,c,u,d,p,_,m,v,S,x;return e.__generator(this,function(j){switch(j.label){case 0:if(t={},T.trim()?T.length>50&&(t.name="Scope Name must be 50 characters or fewer"):t.name="Scope Name is required","approval_required"===G&&0===V.length&&0===X.length&&Z("Please select at least one approver or approver group."),t.name)return w(t),[2];if("approval_required"===G&&0===V.length&&0===X.length)return[2];Z(""),j.label=1;case 1:return j.trys.push([1,7,,8]),r="approval_required"===G,n=h.useLearningTemplateStore.getState().backwardCompatibility,i=n?{topic:D?"genreRuleSet":"globalRuleSet",customScopeGroupName:f.IL_CONFIG_CONSTANTS.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:T,parentScopeId:null,customScopeName:T,customScopeId:s.v4(),createByName:(null==k?void 0:k.firstname)||"System",createdBy:(null==k?void 0:k.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==N?void 0:N.applicationId,module:null==N?void 0:N.moduleId,roles:e.__spreadArray(e.__spreadArray([],r?[{users:V.map(function(e){return e.email}),groups:X.map(function(e){return e._id}),role:null!==(d=null===(u=W.find(function(e){return"Learning Manager"===e.name}))||void 0===u?void 0:u._id)&&void 0!==d?d:""}]:[],!0),[{users:[null==k?void 0:k.email],groups:[],role:null!==(_=null===(p=W.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===p?void 0:p._id)&&void 0!==_?_:""}],!1)}}:{topic:D?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:T,parentScopeId:null!=A?A:null,scopeName:T,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:h.useLearningTemplateStore.getState().app_integration_id},console.log("Add Scope payload:",i),[4,te(i)];case 2:if(o=j.sent(),a=null===(m=null==o?void 0:o.data)||void 0===m?void 0:m.scopeId,n||!a||!A)return[3,6];j.label=3;case 3:return j.trys.push([3,5,,6]),[4,g.inheritScope({source_scope_id:A,target_scope_id:a,application_mapping_id:h.useLearningTemplateStore.getState().app_integration_id||"",is_copy_parent_variant_id:!1})];case 4:return j.sent(),[3,6];case 5:return l=j.sent(),console.error("Failed to inherit rules for the new scope:",l),[3,6];case 6:return b(a),y(),[3,8];case 7:return c=j.sent(),console.error("An error occurred during scope creation.",c),null===(v=P.current)||void 0===v||v.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(x=null===(S=null==c?void 0:c.response)||void 0===S?void 0:S.data)||void 0===x?void 0:x.message)||"There was an error creating the scope. Please try again."}),[3,8];case 8:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:ee||"Custom"===C&&!O?.5:1},disabled:ee||"Custom"===C&&!O},{children:ee?t.jsxs(t.Fragment,{children:[t.jsx(i.Loader2,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};
2
2
  //# sourceMappingURL=AddScopeModal.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),s=require("react/jsx-runtime"),a=require("react"),l=require("lucide-react"),i=require("../styles/CreateLearningSetModal.module.css.js");exports.default=function(n){var t=n.isOpen,r=n.onClose,c=n.onSubmit,d=n.title,u=n.description,o=n.inputLabel,_=n.submitLabel,f=n.placeholder,m=void 0===f?"":f,g=n.initialValue,h=void 0===g?"":g,v=n.isLoading,x=void 0!==v&&v,j=a.useState(""),p=j[0],b=j[1],N=a.useState(null),C=N[0],q=N[1];if(a.useEffect(function(){t&&(b(h),q(null))},[t,h]),!t)return null;return s.jsx("div",e.__assign({className:i.default.overlay},{children:s.jsxs("div",e.__assign({className:i.default.modal},{children:[s.jsxs("div",e.__assign({className:i.default.header},{children:[s.jsxs("div",e.__assign({className:i.default.headerContent},{children:[s.jsx("h2",e.__assign({className:i.default.title},{children:d})),u&&s.jsx("p",e.__assign({className:i.default.description},{children:u}))]})),s.jsx("button",e.__assign({onClick:r,className:i.default.closeBtn,disabled:x},{children:s.jsx(l.X,{size:24})}))]})),s.jsx("div",e.__assign({className:i.default.form},{children:s.jsxs("div",e.__assign({className:i.default.formGroup},{children:[s.jsxs("label",e.__assign({className:i.default.label},{children:[s.jsx("span",e.__assign({className:i.default.asterisk},{children:"*"})),o]})),s.jsx("input",{type:"text",value:p,onChange:function(e){b(e.target.value),C&&q(null)},className:"".concat(i.default.inputField," ").concat(C?i.default.inputError:""),placeholder:m,disabled:x}),C&&s.jsx("p",e.__assign({className:i.default.errorMessage},{children:C}))]}))})),s.jsxs("div",e.__assign({className:i.default.footer},{children:[s.jsx("button",e.__assign({onClick:r,className:i.default.cancelBtn,disabled:x},{children:"Cancel"})),s.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var s;return e.__generator(this,function(e){switch(e.label){case 0:if(!(p.trim()?(q(null),1):(q("".concat(o.replace("*","").trim()," is required")),0)))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c(p)];case 2:return e.sent(),r(),[3,4];case 3:return s=e.sent(),q((null==s?void 0:s.message)||"An error occurred. Please try again."),[3,4];case 4:return[2]}})})},className:i.default.confirmBtn,disabled:x},{children:x?s.jsxs(s.Fragment,{children:[s.jsx(l.Loader2,{className:i.default.spinner}),"Save"===_?"Saving...":"Creating..."]}):_}))]}))]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),s=require("react/jsx-runtime"),a=require("react"),l=require("lucide-react"),i=require("../styles/CreateLearningSetModal.module.css.js");exports.default=function(n){var r=n.isOpen,t=n.onClose,d=n.onSubmit,c=n.title,u=n.description,o=n.inputLabel,_=n.submitLabel,f=n.placeholder,m=void 0===f?"":f,v=n.initialValue,g=void 0===v?"":v,h=n.isLoading,x=void 0!==h&&h,j=a.useState(""),p=j[0],b=j[1],N=a.useState(null),C=N[0],q=N[1];if(a.useEffect(function(){r&&(b(g),q(null))},[r,g]),!r)return null;return s.jsx("div",e.__assign({className:i.default.overlay},{children:s.jsxs("div",e.__assign({className:i.default.modal},{children:[s.jsxs("div",e.__assign({className:i.default.header},{children:[s.jsxs("div",e.__assign({className:i.default.headerContent},{children:[s.jsx("h2",e.__assign({className:i.default.title},{children:c})),u&&s.jsx("p",e.__assign({className:i.default.description},{children:u}))]})),s.jsx("button",e.__assign({onClick:t,className:i.default.closeBtn,disabled:x},{children:s.jsx(l.X,{size:24})}))]})),s.jsx("div",e.__assign({className:i.default.form},{children:s.jsxs("div",e.__assign({className:i.default.formGroup},{children:[s.jsxs("label",e.__assign({className:i.default.label},{children:[s.jsx("span",e.__assign({className:i.default.asterisk},{children:"*"})),o]})),s.jsx("input",{type:"text",value:p,onChange:function(e){var s=e.target.value;if(s.length>50)return b(s.slice(0,50)),void q("Maximum 50 characters allowed");b(s),C&&q(null)},className:"".concat(i.default.inputField," ").concat(C?i.default.inputError:""),placeholder:m,disabled:x}),C&&s.jsx("p",e.__assign({className:i.default.errorMessage},{children:C}))]}))})),s.jsxs("div",e.__assign({className:i.default.footer},{children:[s.jsx("button",e.__assign({onClick:t,className:i.default.cancelBtn,disabled:x},{children:"Cancel"})),s.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var s,a,l;return e.__generator(this,function(e){switch(e.label){case 0:if(!(p.trim()?(q(null),1):(q("".concat(o.replace("*","").trim()," is required")),0)))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,d(p)];case 2:return e.sent(),t(),[3,4];case 3:return s=e.sent(),console.error("Error in submission",s),409===(null==s?void 0:s.status)?(q(null===(l=null===(a=null==s?void 0:s.response)||void 0===a?void 0:a.data)||void 0===l?void 0:l.message),[2]):(q((null==s?void 0:s.message)||"An error occurred. Please try again."),[3,4]);case 4:return[2]}})})},className:i.default.confirmBtn,disabled:x},{children:x?s.jsxs(s.Fragment,{children:[s.jsx(l.Loader2,{className:i.default.spinner}),"Save"===_?"Saving...":"Creating..."]}):_}))]}))]}))}))};
2
2
  //# sourceMappingURL=CreateLearningSetModal.js.map