1"use strict";(self.webpackChunkmy_webpack_project=self.webpackChunkmy_webpack_project||[]).push([[3629],{62945(e,t,n){n.d(t,{A:()=>z});var i=n(39471),a=n(91492),r=n(87073),l=n.n(r),o=n(82195),c=n(53718),s=n(96046),d=n(30462),u=n(39474),m=n(83282),h=["prefixCls","className","checked","defaultChecked","disabled","loadingIcon","checkedChildren","unCheckedChildren","onClick","onChange","onKeyDown"],g=i.forwardRef(function(e,t){var n,a=e.prefixCls,r=void 0===a?"rc-switch":a,g=e.className,p=e.checked,f=e.defaultChecked,b=e.disabled,y=e.loadingIcon,v=e.checkedChildren,$=e.unCheckedChildren,S=e.onClick,k=e.onChange,C=e.onKeyDown,x=(0,d.A)(e,h),E=(0,u.A)(!1,{value:p,defaultValue:f}),I=(0,s.A)(E,2),A=I[0],w=I[1];function M(e,t){var n=A;return b||(w(n=e),null==k||k(n,t)),n}var N=l()(r,g,(n={},(0,c.A)(n,"".concat(r,"-checked"),A),(0,c.A)(n,"".concat(r,"-disabled"),b),n));return i.createElement("button",(0,o.A)({},x,{type:"button",role:"switch","aria-checked":A,disabled:b,className:N,ref:t,onKeyDown:function(e){e.which===m.A.LEFT?M(!1,e):e.which===m.A.RIGHT&&M(!0,e),null==C||C(e)},onClick:function(e){var t=M(!A,e);null==S||S(t,e)}}),y,i.createElement("span",{className:"".concat(r,"-inner")},i.createElement("span",{className:"".concat(r,"-inner-checked")},v),i.createElement("span",{className:"".concat(r,"-inner-unchecked")},$)))});g.displayName="Switch";const p=g;var f=n(74569),b=n(11092),y=n(25564),v=n(47374),$=n(30348),S=n(19379),k=n(93042),C=n(67403),x=n(85391);const E=e=>{const{componentCls:t,trackHeightSM:n,trackPadding:i,trackMinWidthSM:a,innerMinMarginSM:r,innerMaxMarginSM:l,handleSizeSM:o,calc:c}=e,s=`${t}-inner`,d=(0,$.zA)(c(o).add(c(i).mul(2)).equal()),u=(0,$.zA)(c(l).mul(2).equal());return{[t]:{[`&${t}-small`]:{minWidth:a,height:n,lineHeight:(0,$.zA)(n),[`${t}-inner`]:{paddingInlineStart:l,paddingInlineEnd:r,[`${s}-checked, ${s}-unchecked`]:{minHeight:n},[`${s}-checked`]:{marginInlineStart:`calc(-100% + ${d} - ${u})`,marginInlineEnd:`calc(100% - ${d} + ${u})`},[`${s}-unchecked`]:{marginTop:c(n).mul(-1).equal(),marginInlineStart:0,marginInlineEnd:0}},[`${t}-handle`]:{width:o,height:o},[`${t}-loading-icon`]:{top:c(c(o).sub(e.switchLoadingIconSize)).div(2).equal(),fontSize:e.switchLoadingIconSize},[`&${t}-checked`]:{[`${t}-inner`]:{paddingInlineStart:r,paddingInlineEnd:l,[`${s}-checked`]:{marginInlineStart:0,marginInlineEnd:0},[`${s}-unchecked`]:{marginInlineStart:`calc(100% - ${d} + ${u})`,marginInlineEnd:`calc(-100% + ${d} - ${u})`}},[`${t}-handle`]:{insetInlineStart:`calc(100% - ${(0,$.zA)(c(o).add(i).equal())})`}},[`&:not(${t}-disabled):active`]:{[`&:not(${t}-checked) ${s}`]:{[`${s}-unchecked`]:{marginInlineStart:c(e.marginXXS).div(2).equal(),marginInlineEnd:c(e.marginXXS).mul(-1).div(2).equal()}},[`&${t}-checked ${s}`]:{[`${s}-checked`]:{marginInlineStart:c(e.marginXXS).mul(-1).div(2).equal(),marginInlineEnd:c(e.marginXXS).div(2).equal()}}}}}}},I=e=>{const{componentCls:t,handleSize:n,calc:i}=e;return{[t]:{[`${t}-loading-icon${e.iconCls}`]:{position:"relative",top:i(i(n).sub(e.fontSize)).div(2).equal(),color:e.switchLoadingIconColor,verticalAlign:"top"},[`&${t}-checked ${t}-loading-icon`]:{color:e.switchColor}}}},A=e=>{const{componentCls:t,trackPadding:n,handleBg:i,handleShadow:a,handleSize:r,calc:l}=e,o=`${t}-handle`;return{[t]:{[o]:{position:"absolute",top:n,insetInlineStart:n,width:r,height:r,transition:`all ${e.switchDuration} ease-in-out`,"&::before":{position:"absolute",top:0,insetInlineEnd:0,bottom:0,insetInlineStart:0,backgroundColor:i,borderRadius:l(r).div(2).equal(),boxShadow:a,transition:`all ${e.switchDuration} ease-in-out`,content:'""'}},[`&${t}-checked ${o}`]:{insetInlineStart:`calc(100% - ${(0,$.zA)(l(r).add(n).equal())})`},[`&:not(${t}-disabled):active`]:{[`${o}::before`]:{insetInlineEnd:e.switchHandleActiveInset,insetInlineStart:0},[`&${t}-checked ${o}::before`]:{insetInlineEnd:0,insetInlineStart:e.switchHandleActiveInset}}}}},w=e=>{const{componentCls:t,trackHeight:n,trackPadding:i,innerMinMargin:a,innerMaxMargin:r,handleSize:l,calc:o}=e,c=`${t}-inner`,s=(0,$.zA)(o(l).add(o(i).mul(2)).equal()),d=(0,$.zA)(o(r).mul(2).equal());return{[t]:{[c]:{display:"block",overflow:"hidden",borderRadius:100,height:"100%",paddingInlineStart:r,paddingInlineEnd:a,transition:`padding-inline-start ${e.switchDuration} ease-in-out, padding-inline-end ${e.switchDuration} ease-in-out`,[`${c}-checked, ${c}-unchecked`]:{display:"block",color:e.colorTextLightSolid,fontSize:e.fontSizeSM,transition:`margin-inline-start ${e.switchDuration} ease-in-out, margin-inline-end ${e.switchDuration} ease-in-out`,pointerEvents:"none",minHeight:n},[`${c}-checked`]:{marginInlineStart:`calc(-100% + ${s} - ${d})`,marginInlineEnd:`calc(100% - ${s} + ${d})`},[`${c}-unchecked`]:{marginTop:o(n).mul(-1).equal(),marginInlineStart:0,marginInlineEnd:0}},[`&${t}-checked ${c}`]:{paddingInlineStart:a,paddingInlineEnd:r,[`${c}-checked`]:{marginInlineStart:0,marginInlineEnd:0},[`${c}-unchecked`]:{marginInlineStart:`calc(100% - ${s} + ${d})`,marginInlineEnd:`calc(-100% + ${s} - ${d})`}},[`&:not(${t}-disabled):active`]:{[`&:not(${t}-checked) ${c}`]:{[`${c}-unchecked`]:{marginInlineStart:o(i).mul(2).equal(),marginInlineEnd:o(i).mul(-1).mul(2).equal()}},[`&${t}-checked ${c}`]:{[`${c}-checked`]:{marginInlineStart:o(i).mul(-1).mul(2).equal(),marginInlineEnd:o(i).mul(2).equal()}}}}}},M=e=>{const{componentCls:t,trackHeight:n,trackMinWidth:i}=e;return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},(0,k.dF)(e)),{position:"relative",display:"inline-block",boxSizing:"border-box",minWidth:i,height:n,lineHeight:(0,$.zA)(n),verticalAlign:"middle",background:e.colorTextQuaternary,border:"0",borderRadius:100,cursor:"pointer",transition:`all ${e.motionDurationMid}`,userSelect:"none",[`&:hover:not(${t}-disabled)`]:{background:e.colorTextTertiary}}),(0,k.K8)(e)),{[`&${t}-checked`]:{background:e.switchColor,[`&:hover:not(${t}-disabled)`]:{background:e.colorPrimaryHover}},[`&${t}-loading, &${t}-disabled`]:{cursor:"not-allowed",opacity:e.switchDisabledOpacity,"*":{boxShadow:"none",cursor:"not-allowed"}},[`&${t}-rtl`]:{direction:"rtl"}})}},N=(0,C.OF)("Switch",e=>{const t=(0,x.oX)(e,{switchDuration:e.motionDurationMid,switchColor:e.colorPrimary,switchDisabledOpacity:e.opacityLoading,switchLoadingIconSize:e.calc(e.fontSizeIcon).mul(.75).equal(),switchLoadingIconColor:`rgba(0, 0, 0, ${e.opacityLoading})`,switchHandleActiveInset:"-30%"});return[M(t),w(t),A(t),I(t),E(t)]},e=>
1{const{fontSize:t,lineHeight:n,controlHeight:i,colorWhite:a}=e,r=t*n,l=i/2,o=r-4,c=l-4;return{trackHeight:r,trackHeightSM:l,trackMinWidth:2*o+8,trackMinWidthSM:2*c+4,trackPadding:2,handleBg:a,handleSize:o,handleSizeSM:c,handleShadow:`0 2px 4px 0 ${new S.Y("#00230b").setA(.2).toRgbString()}`,innerMinMargin:o/2,innerMaxMargin:o+2+4,innerMinMarginSM:c/2,innerMaxMarginSM:c+2+4}});const F=i.forwardRef((e,t)=>{const{prefixCls:n,size:r,disabled:o,loading:c,className:s,rootClassName:d,style:m,checked:h,value:g,defaultChecked:$,defaultValue:S,onChange:k}=e,C=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]])}return n}(e,["prefixCls","size","disabled","loading","className","rootClassName","style","checked","value","defaultChecked","defaultValue","onChange"]),[x,E]=(0,u.A)(!1,{value:null!=h?h:g,defaultValue:null!=$?$:S}),{getPrefixCls:I,direction:A,switch:w}=i.useContext(b.QO),M=i.useContext(y.A),F=(null!=o?o:M)||c,P=I("switch",n),z=i.createElement("div",{className:`${P}-handle`},c&&i.createElement(a.A,{className:`${P}-loading-icon`})),[j,D,H]=N(P),O=(0,v.A)(r),q=l()(null==w?void 0:w.className,{[`${P}-small`]:"small"===O,[`${P}-loading`]:c,[`${P}-rtl`]:"rtl"===A},s,d,D,H),_=Object.assign(Object.assign({},null==w?void 0:w.style),m);return j(i.createElement(f.A,{component:"Switch",disabled:F},i.createElement(p,Object.assign({},C,{checked:x,onChange:(...e)=>{E(e[0]),null==k||k.apply(void 0,e)},prefixCls:P,className:q,style:_,disabled:F,ref:t,loadingIcon:z}))))}),P=F;P.__ANT_SWITCH=!0;const z=P},63629(e,t,n){n.r(t);var i=n(39471),a=n(53836),r=n(50256),l=n(71757),o=n(49482),c=n(62945),s=n(51794);function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,a,r,l,o=[],c=!0,s=!1;try{if(r=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=r.call(n)).done)&&(o.push(i.value),o.length!==t);c=!0);}catch(e){s=!0,a=e}finally{try{if(!c&&null!=n.return&&(l=n.return(),Object(l)!==l))return}finally{if(s)throw a}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}n.d(t,["default",0,e=>{let t=e.isModalVisible,n=e.onCancel,u=e.confirmButtonText,m=void 0===u?"Save":u,h=e.modalContent,g=e.onConfirm,p=e.initialData,f=void 0===p?{}:p,b=e.isEditMode,y=void 0!==b&&b,v=e.setNotification,$=e.refetch,S=void 0===$?()=>{}:$;const k=d(a.A.useForm(),1)[0],C=d((0,i.useState)(null),2),x=C[0],E=C[1],I=d((0,i.useState)(null),2),A=I[0],w=I[1];(0,i.useEffect)(()=>{let e=!1;return(0,s.SU)().then(t=>{var n;if(e)return;const i=null===(n=t.data)||void 0===n?void 0:n.cost_per_token,a=parseFloat("string"==typeof i?i.replace(/[^0-9.\-]/g,""):i);Number.isFinite(a)&&a>0&&E(a)}).catch(()=>{}),()=>{e=!0}},[]),(0,i.useEffect)(()=>{var e,n,i,a;t?(k.setFieldsValue({name:f.name||"",cost:f.cost||"",credits:f.credits||"",isActive:void 0===f.isActive||f.isActive,durationDays:null!==(e=f.durationDays)&&void 0!==e?e:0,durationHours:null!==(n=f.durationHours)&&void 0!==n?n:0,durationMinutes:null!==(i=f.durationMinutes)&&void 0!==i?i:0}),w(null!==(a=f.cost)&&void 0!==a?a:null)):(k.resetFields(),w(null))},[t,f,k]);const M=null!=(N=(e=>{if(null==x)return null;const t=parseFloat(e);return!Number.isFinite(t)||t<=0?null:t*x})(A))&&Number.isFinite(N)?parseFloat(N.toFixed(4)).toString():null;var N;const F=()=>{k.resetFields(),n()};return i.createElement(o.A,{open:t,onCancel:F,centered:!0,className:"plans-modal",footer:i.createElement("div",{className:"custom-footer"},i.createElement("button",{className:"delete-button",onClick:async()=>{try{const e=await k.validateFields(),t=Number(e.durationDays||0),n=Number(e.durationHours||0),i=Number(e.durationMinutes||0);if(1440*t+60*n+i<1)return void v({message:"Cycle length must be at least 1 minute (Days + Hours + Minutes).",severity:"error",backgroundColor:"#FFFFFF",textColor:"#000000"});const a={name:e.name,no_of_token:Number(e.credits),cost_of_token:Number(e.cost),duration_days:t,duration_hours:n,duration_minutes:i,is_active:e.isActive};let r;if(y){if(!f.id)throw new Error("Plan ID is required for editing");
1r=await s.tY.EditCreditPlan(f.id,a)}else r=await s.tY.AddCreditPlan(a);v({message:y?"Credit Plan updated successfully":"Credit Plan created successfully",severity:"success",backgroundColor:"#FFFFFF",textColor:"#000000"}),g(r.data||r,S),k.resetFields()}catch(t){var e;if(null!=t&&null!==(e=t.response)&&void 0!==e&&e.data){const e=Object.entries(t.response.data).map(e=>{let t=d(e,2),n=t[0],i=t[1];return"".concat(n,": ").concat(Array.isArray(i)?i.join(", "):i)}).join("; ");v({message:e||"Failed to save",severity:"error",backgroundColor:"#FDEDED",textColor:"#D32F2F"})}else"ValidationError"!==t.name&&console.error("An error occurred:",t)}},disabled:k.isFieldsValidating()||k.getFieldsError().some(e=>e.errors.length)},k.isFieldsValidating()?"Processing...":m),i.createElement("button",{className:"cancel-button",onClick:F,disabled:k.isFieldsValidating()},"No, Cancel"))},i.createElement("div",{className:"modal-content-center"},h&&i.createElement("p",{className:"modal-text",style:{fontSize:"20px",fontWeight:500,marginBottom:"20px",textAlign:"center"}},h),i.createElement(a.A,{form:k,layout:"vertical",initialValues:{name:"",cost:"",credits:"",isActive:!0,durationDays:0,durationHours:0,durationMinutes:0}},i.createElement("div",{className:"form-container"},i.createElement(a.A.Item,{label:"Name (Optional)",name:"name",required:!1,rules:[{max:100,message:"Name cannot be more than 100 characters"}],style:{marginBottom:"16px"},labelCol:{style:{fontWeight:500,fontSize:"16px"}}},i.createElement(r.A,{style:{height:"50px",borderRadius:"12px"},placeholder:"Name of Credit Plan (e.g. Starter, Pro)"})),i.createElement("div",{style:{display:"flex",alignItems:"flex-start",gap:"16px",marginBottom:"16px"}},i.createElement(a.A.Item,{label:"Cost",name:"cost",labelCol:{style:{fontWeight:500,fontSize:"16px"}},required:!1,rules:[{validator:(e,t)=>{if(null==t||""===t)return Promise.reject("Please enter a cost");const n=parseFloat(t);return isNaN(n)||n<=0?Promise.reject("Cost must be a positive number"):Promise.resolve()}}],style:{marginBottom:0,flex:1}},i.createElement(l.A,{style:{height:"50px",width:"100%",borderRadius:"12px",display:"flex",alignItems:"center"},min:0,step:.01,precision:2,controls:!1,prefix:i.createElement("span",{style:{fontWeight:500,fontSize:"20px"}},"$"),onChange:e=>{w(e),k.validateFields(["credits"]).catch(()=>{})},parser:e=>(e||"").replace(/[^0-9.]/g,"")})),i.createElement(a.A.Item,{label:i.createElement("span",null,"Credits per Cycle",null!=M&&i.createElement("span",{style:{fontWeight:400,color:"#666",marginLeft:6}},"(min: ",M,")")),name:"credits",labelCol:{style:{fontWeight:500,fontSize:"16px"}},required:!1,tooltip:x?"Minimum is cost à current rate (".concat(x," credits / $1). Anything above the minimum becomes bonus credits."):"How many credits the user gets per cycle.",rules:[{validator:(e,t)=>{if(null==t||""===t)return Promise.reject("Please enter credits");const n=parseFloat(t);if(isNaN(n)||n<=0)return Promise.reject("Credits must be a positive number");const i=parseFloat(k.getFieldValue("cost"));if(x&&Number.isFinite(i)&&i>0){const e=i*x;if(n<e-1e-4)return Promise.reject("Credits cannot be less than the cost à current rate (minimum: ".concat(e,")."))}return Promise.resolve()}}],style:{marginBottom:0,flex:1}},i.createElement(l.A,{style:{height:"50px",width:"100%",borderRadius:"12px",display:"flex",alignItems:"center"},min:0,step:1,controls:!1,placeholder:"e.g. 100",parser:e=>{const t=(e||"").toString().replace(/[^0-9.]/g,"").split(".");return 1===t.length?t[0]:t[0]+"."+t.slice(1).join("").slice(0,4)}}))),i.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:"16px"}},i.createElement("span",{style:{fontWeight:500,fontSize:"16px",marginBottom:4}},"Cycle Length"),i.createElement("div",{style:{display:"flex",gap:8}},i.createElement(a.A.Item,{name:"durationDays",rules:[{validator:(e,t)=>""===t||null==t||Number(t)>=0?Promise.resolve():Promise.reject("Days must be ⥠0")}],style:{marginBottom:0}},i.createElement(r.A,{style:{height:"50px",borderRadius:"12px",width:90},type:"number",min:0,step:1,placeholder:"Days",addonAfter:"d"})),i.createElement(a.A.Item,{name:"durationHours",rules:[{validator:(e,t)=>
1{if(""===t||null==t)return Promise.resolve();const n=Number(t);return n<0||n>23?Promise.reject("Hours: 0â23"):Promise.resolve()}}],style:{marginBottom:0}},i.createElement(r.A,{style:{height:"50px",borderRadius:"12px",width:90},type:"number",min:0,max:23,step:1,placeholder:"Hrs",addonAfter:"h"})),i.createElement(a.A.Item,{name:"durationMinutes",rules:[{validator:(e,t)=>{if(""===t||null==t)return Promise.resolve();const n=Number(t);return n<0||n>59?Promise.reject("Minutes: 0â59"):Promise.resolve()}}],style:{marginBottom:0}},i.createElement(r.A,{style:{height:"50px",borderRadius:"12px",width:90},type:"number",min:0,max:59,step:1,placeholder:"Min",addonAfter:"m"}))),i.createElement("span",{style:{fontSize:12,color:"#444",marginTop:4}},"Total must be ⥠1 minute (e.g. 30 days for monthly, 365 days for yearly)")),i.createElement("div",{style:{display:"flex",justifyContent:"flex-start",margin:"0 4rem"}},i.createElement(a.A.Item,{label:"Activate",name:"isActive",valuePropName:"checked",style:{marginBottom:"16px"},labelCol:{style:{fontWeight:500,fontSize:"16px"}}},i.createElement(c.A,null)))))))}])}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.