1import{A as Z}from"./Authenticated-DlhMWzrR.js";import{B as $}from"./Badge-D3jgYO5N.js";import{u as q,h as ee,a as te}from"./app-AsY-L5Ba.js";import{F as H}from"./FormErrors-CkjmD7b9.js";import{S as W}from"./SelectInput-BnnJbla_.js";import{B as Y}from"./BaseInput-DAkIC6Yq.js";import{B as A,M as R,S as se,u as re}from"./EnterpriseFeatureModal-BqM0ywGh.js";import{B as oe}from"./Breadcrumbs-DAPr6ysY.js";import{r as S,k as D,w as de,v as m,B as p,E as e,F as u,G as w,H as v,C as o,D as i,q as _,I as C,K as U,Q as M,V as ie,L as z,N as B,J as h,p as ne,O as ae}from"./vendor-BGNTgfwa.js";import{_ as le}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./MaintenanceBanner-DdW4KUFA.js";import"./EchoNotificationMixin-Dvt0vDZP.js";import"./analytics-HljD2eR7.js";/* empty css */import"./BrandLogo-CqstKVyN.js";const ue={class:"my-3 rounded-sm bg-card text-foreground shadow-sm"},ce={class:"rounded-t border border-b-0 border-border p-6"},me={class:"flex items-center text-lg leading-6 font-medium"},pe={class:"mt-6 grid grid-cols-1 place-items-center gap-6 p-4"},be=["max"],fe={class:"mt-6 grid grid-cols-1 place-items-center gap-6 p-4"},ve=["max"],ge={class:"mt-6 grid grid-cols-4 gap-6"},xe={class:"col-span-2"},he={class:"col-span-2 pt-8"},ye={class:"col-span-2"},_e={key:0,class:"mt-1 text-xs text-destructive italic"},we={class:"col-span-4"},Ce={class:"relative mt-3 flex items-start"},ke={class:"flex h-5 items-center pl-3"},Ue={class:"flex justify-end rounded-b border border-border bg-muted px-6 py-3 text-right"},O=16777215,Fe={__name:"UserCreditTrackingForm",props:{userCreditTracking:{type:Object,default:null},userId:{type:Number,required:!0}},emits:["submitted"],setup(g,{emit:s}){const d=g,y=s,r=S(!1),c=S(!1),F=S(!1),V=S(!1),I=D(()=>{const x=d.userCreditTracking?.balance||0;return Math.max(0,O-x)}),T=D(()=>b.credits==null||b.reason==null),k=D(()=>f.credits==null||f.reason==null),P=[{label:"Monthly",value:"MONTHLY"}],n=q({user_id:d.userId,allotment:d.userCreditTracking?.allotment||0,balance:d.userCreditTracking?.balance||0,frequency:d.userCreditTracking?.frequency||"MONTHLY",accumulate:d.userCreditTracking?.accumulate_credits||!1}),b=q({credits:null,reason:null,user_id:d.userId}),f=q({credits:null,reason:null,user_id:d.userId});de(()=>d.userCreditTracking,x=>{x&&(n.user_id=d.userId,n.allotment=x.allotment||0,n.balance=x.balance||0,n.frequency=x.frequency||"MONTHLY")},{immediate:!0});const L=()=>{c.value=!0},l=()=>{F.value=!0},E=()=>{c.value=!1,b.reset()},N=()=>{F.value=!1,f.reset()},G=()=>{V.value=!0},j=()=>{V.value=!1},J=()=>{r.value=!0;const x=route("credit-management.user.update.credit",{user:d.userId,creditTracking:d.userCreditTracking?.id});n.post(x,{onFinish:()=>{r.value=!1},onSuccess:()=>{y("submitted")}})},K=()=>{f.post(route("credit-management.user.deduct-credits"),{onSuccess:()=>{N(),y("submitted")}})},Q=()=>{b.post(route("credit-management.user.add-credits"),{onSuccess:()=>{E(),y("submitted")}})},X=()=>{q({user_id:d.userId}).delete(route("credit-management.user.remove-limit"),{preserveScroll:!0,preserveState:!1,onSuccess:()=>{j(),y("submitted")}})};return(x,t)=>(m(),p("div",ue,[e("div",ce,[e("div",null,[e("h2",me,[u(w(g.userCreditTracking?.id?"Edit":"Create")+" Credit Tracking ",1),g.userCreditTracking?.id?(m(),p("button",{key:0,class:"ml-2 rounded bg-green-500 px-2 py-1 text-xs font-bold text-white hover:bg-green-700",onClick:L}," Add Credits ")):v("",!0),g.userCreditTracking?.id?(m(),p("button",{key:1,class:"ml-2 rounded bg-red-500 px-2 py-1 text-xs font-bold text-white hover:bg-red-700",onClick:l}," Deduct Credits ")):v("",!0),g.userCreditTracking?.id?(m(),p("button",{key:2,class:"ml-2 rounded bg-orange-500 px-2 py-1 text-xs font-bold text-white hover:bg-orange-700",onClick:G}," Remove User Limit ")):v("",!0)])]),o(H,{errors:i(n).errors},null,8,["errors"]),o(R,{"max-height":"60vh",open:F.value,"display-cancel":!0,"display-confirm":!1,"display-close-icon":!1,"cancel-text":"Close",title:"Deduct Credits from User",onClose:t[3]||(t[3]=a=>N())},{default:_(()=>[e("div",pe,[e("form",{novalidate:"",onSubmit:t[2]||(t[2]=C(a=>K(),["prevent"]))},[t[13]||(t[13]=e("label",{for:"deduct_credits"},[u("Enter the amount of credits to deduct from the user"),e("span",{class:"ml-2 text-xs text-red-700"},"*")],-1)),U(e("input",{class:"mb-8",type:"number",min:"0",max:i(n).balance,step:"1",oninput:"validity.valid || (value = '')",id:"deduct_credits","onUpdate:modelValue":t[0]||(t[0]=a=>i(f).credits=a)},null,8,be),[[M,i(f).credits]]),t[14]||(t[14]=e("label",{for:"deduct_reason"},[u("Please note the reason for deducting credits"),e("span",{class:"ml-2 text-xs text-red-700"},"* Required")],-1)),U(e("textarea",{required:"","aria-required":"true",class:"mb-8",id:"deduct_reason","onUpdate:modelValue":t[1]||(t[1]=a=>i(f).reason=a)},null,512),[[M,i(f).reason]]),o(A,{text:"Deduct Credits",type:"submit",disabled:i(f).processing||k.value},null,8,["disabled"])],32)])]),_:1},8,["open"]),o(R,{"max-height":"60vh",open:c.value,"display-cancel":!0,"display-confirm":!1,"display-close-icon":!1,"cancel-text":"Close",title:"Add Credits to User",onClose:t[7]||(t[7]=a=>E())},{default:_(()=>[e("div",fe,[e("form",{onSubmit:t[6]||(t[6]=C(a=>Q(),["prevent"]))},[t[15]||(t[15]=e("label",{for:"add_credits"},[u("Enter the amount of credits to apply to the user"),e("span",{class:"ml-2 text-xs text-red-700"},"*")],-1)),U(e("input",{class:"mb-8",type:"number",min:"0",max:I.value,step:"1",oninput:"validity.valid || (value = '')",id:"add_credits","onUpdate:modelValue":t[4]||(t[4]=a=>i(b).credits=a)}
1,null,8,ve),[[M,i(b).credits]]),t[16]||(t[16]=e("label",{for:"add_reason"},[u("Please note the reason for adding credits"),e("span",{class:"ml-2 text-xs text-red-700"},"* Required")],-1)),U(e("textarea",{required:"","aria-required":"true",class:"mb-8",id:"add_reason","onUpdate:modelValue":t[5]||(t[5]=a=>i(b).reason=a)},null,512),[[M,i(b).reason]]),o(A,{text:"Add Credits",type:"submit",disabled:i(b).processing||T.value},null,8,["disabled"])],32)])]),_:1},8,["open"]),o(R,{"max-height":"60vh",open:V.value,"display-cancel":!0,"display-confirm":!0,"display-close-icon":!1,"cancel-text":"Cancel","confirm-text":"Remove Limit",title:"Remove User Credit Limit",onClose:t[8]||(t[8]=a=>j()),onSubmit:t[9]||(t[9]=a=>X())},{default:_(()=>[...t[17]||(t[17]=[e("div",{class:"mt-6 p-4"},[e("div",{class:"text-center"},[e("div",{class:"mb-4 text-yellow-600"},[e("svg",{class:"mx-auto h-12 w-12",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})])]),e("h3",{class:"mb-2 text-lg font-medium text-foreground"}," Remove Credit Limit "),e("p",{class:"mb-4 text-sm text-muted-foreground"}," This will permanently remove the credit tracking for this user, giving them unlimited access. "),e("p",{class:"text-sm font-medium text-destructive"}," This action cannot be undone. ")])],-1)])]),_:1},8,["open"]),e("div",ge,[t[20]||(t[20]=ie('<div class="relative col-span-4"><div class="absolute inset-0 flex items-center" aria-hidden="true"><div class="w-full border-t border-border"></div></div><div class="relative flex justify-start"><span class="bg-card pr-2">Credit Information</span></div></div>',1)),e("div",xe,[o(Y,{id:"allotment",modelValue:i(n).allotment,"onUpdate:modelValue":t[10]||(t[10]=a=>i(n).allotment=a),label:"Credit Allotment",type:"number",min:"0",max:O,autocomplete:"off",error:i(n).errors.allotment},null,8,["modelValue","error"])]),e("div",he," Current Balance: "+w(d.userCreditTracking?.balance??0),1),e("div",ye,[t[18]||(t[18]=e("label",{for:"frequency",class:"mb-1 block font-medium"},[u(" Frequency "),e("span",{class:"text-destructive"},"*")],-1)),o(W,{modelValue:i(n).frequency,"onUpdate:modelValue":t[11]||(t[11]=a=>i(n).frequency=a),placeholder:"Select frequency...",options:P},null,8,["modelValue"]),i(n).errors.frequency?(m(),p("div",_e,w(i(n).errors.frequency),1)):v("",!0)]),e("div",we,[e("div",Ce,[t[19]||(t[19]=e("div",{class:"ml-3 text-sm"},[e("label",{for:"accumulate",class:"mb-1 block font-medium"},"User can accumulate credits")],-1)),e("div",ke,[U(e("input",{id:"accumulate","onUpdate:modelValue":t[12]||(t[12]=a=>i(n).accumulate=a),type:"checkbox",class:"h-4 w-4 cursor-pointer rounded-sm border-input text-primary focus:ring-ring"},null,512),[[z,i(n).accumulate]])])])])])]),e("div",Ue,[o(A,{type:"submit","is-loading":r.value,class:B({"pointer-events-none":r.value}),onClick:C(J,["prevent"])},{default:_(()=>[u(w(g.userCreditTracking?.id?"Update":"Create")+" Credit Tracking ",1)]),_:1},8,["is-loading","class"])])]))}},Ve={components:{UserCreditTrackingForm:Fe,FormErrors:H,AuthenticatedLayout:Z,Badge:$,Head:ee,SelectInput:W,BaseButton:A,BaseInput:Y,Spinner:se,Breadcrumbs:oe},props:{user:{type:Object},accounts:{type:Object},roles:{type:Array}},setup(){const{isAdminUser:g,can:s}=re(te().props.auth);return{isAdminUser:g,can:s}},data(){return{updateUserForm:this.$inertia.form({name:this.user.name,email:this.user.email,active:!!this.user.active,account_ids:this.user.accounts.length?this.user.accounts[0].id:null,role_ids:this.user.roles.length?this.user.roles[0].id:null}),updatePasswordForm:this.$inertia.form({new_password:"",new_password_confirmation:""}),submitted:!1,confirmOpened:!1,sending:!1}},computed:{activationDisabled(){return this.$page.props.auth.user.id===this.user.id}},methods:{updateUser(){this.submitted="update",this.updateUserForm.post(this.route("management.users.update",this.user.id),{onFinish:()=>{this.submitted=!1}})},updatePassword(){this.submitted="password",this.updatePasswordForm.post(this.route("profile.password.update",this.user.id),{onFinish:()=>{this.submitted=!1},onSuccess:()=>{this.updatePasswordForm.reset()}})},sendPasswordReset(){if(this.sending)return!1;this.sending=!0,this.$inertia.post(this.route("management.users.reset-password-email",this.user.id),{},{onFinish:()=>{this.sending=!1}})},resendWelcomeEmail(){this.submitted="resend",this.$inertia.post(this.route("management.users.resend-welcome-email",this.user.id),{},{onFinish:()=>{this.submitted=!1}})}}},Be={class:"my-3 bg-card rounded-sm shadow-sm"},Te={class:"p-6 border border-b-0 border-border rounded-t"},Pe={class:"relative"},qe={class:"flex items-center text-lg font-medium leading-6"},Se={class:"grid grid-cols-4 gap-6 mt-6"},Me={class:"col-span-2"},Ae={class:"col-span-2"},Ie={class:"col-span-2"},Le={key:0,class:"mt-1 text-xs text-red-500 dark:text-red-400"},Re={key:0,class:"col-span-2"},De={key:0,class:"mt-1 text-xs text-red-500 dark:text-red-400"},Ee={class:"col-span-4"},Ne={class:"block font-medium"},je={key:0,class:"text-xs italic text-muted-foreground"},Oe={class:"flex items-center h-5"},He=["disabled"],We={class:"flex justify-end rounded-b border border-border bg-muted px-6 py-3 text-right"},Ye={key:0,class:"my-6 bg-card rounded-sm shadow-sm"},ze={class:"p-6 border border-b-0 border-border rounded-t"},Ge={class:"relative"},Je={class:"mt-2"},Ke={key:0,class:"ml-3"},Qe={class:"grid grid-cols-4 gap-6 mt-6"},Xe={class:"col-span-2"},Ze={class:"col-span-2"},$e={class:"flex justify-end rounded-b border border-border bg-muted px-6 py-3 text-right"};function et(g,s,d,y,r,c){const F=h("Head"),V=h("Breadcrumbs"),I=h("Badge"),T=h("FormErrors"),k=h("BaseInput"),P=h("SelectInput"),n=h("BaseButton"),b=h("UserCreditTrackingForm"),f=h("Spinner"),L=h("AuthenticatedLayout");return m(),p(ae,null,[o(F,{title:"Biscred Management"}),o(L,null,{default:_(()=>[o(V,{pages:g.$page.props.breadcrumbs},null,8,["pages"]),e("div",Be,[e("div",Te,[e("div",Pe,[e("h2",qe,[u(w(d.user.name)+" ",1),o(I,{class:"ml-4",label:d.user.active?"Active":"Inactive","bg-color":d.user.active?"bg-success/10":"bg-warning/10","text-color":d.user.active?"text-success":"text-warning"},null,8,["label","bg-color","text-color"])])]),o(T,{errors:r.updateUserForm.errors},null,8,["errors"]),e("div",Se,[s[12]||(s[12]=e("div",{class:"relative col-span-4"},[e("div",{class:"absolute inset-0 flex items-center","aria-hidden":"true"},[e("div",{class:"w-full border-t border-border"})]),e("div",{class:"relative flex justify-start"},[e("span",{class:"bg-card pr-2"},"User Information")])],-1)),e("div",Me,[o(k,{id:"name",modelValue:r.updateUserForm.name,"onUpdate:modelValue":s[0]||(s[0]=l=>r.updateUserForm.name=l),label:"Name",required:!0,type:"text",autocomplete:"off",error:r.updateUserForm.errors.name},null,8,["modelValue","error"])]),e("div",Ae,[o(k,{id:"email",modelValue:r.updateUserForm.email,"onUpdate:modelValue":s[1]||(s[1]=l=>r.updateUserForm.email=l),label:"Email",required:!0,type:"text",autocomplete:"off",error:r.updateUserForm.errors.email},null,8,["modelValue","error"])]),e("div",Ie,[s[8]||(s[8]=e("label",{for:"accounts",class:"block font-medium mb-1"},[u("Account "),e("span",{class:"text-red-500 dark:text-red-400"},"*")],-1)),o(P,{modelValue:r.updateUserForm.account_ids,"onUpdate:modelValue":s[2]||(s[2]=l=>r.updateUserForm.account_ids=l),placeholder:"Select an Account...",searchable:!0,options:d.accounts.data},null,8,["modelValue","options"]),r.updateUserForm.errors.account_ids?(m(),p("div",Le,w(r.updateUserForm.errors.account_ids),1)):v("",!0)]),y.can("Manage User Roles")?(m(),p("div",Re,[s[9]||(s[9]=e("label",{for:"roles",class:"block font-medium mb-1"},[u("Role "),e("span",{class:"text-red-500 dark:text-red-400"},"*")],-1)),o(P,{modelValue:r.updateUserForm.role_ids,"onUpdate:modelValue":s[3]||(s[3]=l=>r.updateUserForm.role_ids=l),placeholder:"Select a Role...",options:d.roles},null,8,["modelValue","options"]),r.updateUserForm.errors.role_ids?(m(),p("div",De," A valid role is required. ")):v("",!0)])):v("",!0),e("div",Ee,[e("label",Ne,[s[10]||(s[10]=u("User Active ",-1)),c.activationDisabled?(m(),p("span",je," (You cannot update your own active status.) ")):v("",!0)]),e("div",{class:B(["relative flex items-start mt-3",{"opacity-50":c.activationDisabled}])},[e("div",Oe,[U(e("input",{id:"active","onUpdate:modelValue":s[4]||(s[4]=l=>r.updateUserForm.active=l),type:"checkbox",class:B(["w-4 h-4 border-input rounded-sm cursor-pointer",[c.activationDisabled?"text-muted-foreground focus:ring-ring":"text-success focus:ring-success"]]),disabled:c.activationDisabled},null,10,He),[[z,r.updateUserForm.active]])]),s[11]||(s[11]=e("div",{class:"ml-3 text-sm"},[e("label",null,"Activated"),e("span",{class:"italic font-light"}," This user will be set to Inactive, if left unchecked.")],-1))],2)])])]),e("div",We,[y.can("Resend Welcome Email")?(m(),ne(n,{key:0,theme:"light",class:B(["mr-2",{"pointer-events-none":r.submitted==="resend"}]),"is-loading":r.submitted==="resend",onClick:C(c.resendWelcomeEmail,["prevent"])},{default:_(()=>[...s[13]||(s[13]=[u(" Resend Welcome Email ",-1)])]),_:1},8,["class","is-loading","onClick"])):v("",!0),o(n,{type:"submit",theme:"dark",disabled:r.updateUserForm.processing||!r.updateUserForm.isDirty,"is-loading":r.updateUserForm.processing,onClick:C(c.updateUser,["prevent"])},{default:_(()=>[...s[14]||(s[14]=[u(" Update User ",-1)])]),_:1},8,["disabled","is-loading","onClick"])])]),o(b,{"user-id":d.user.id,"user-credit-tracking":d.user.credits},null,8,["user-id","user-credit-tracking"]),y.can("Manage User Passwords")?(m(),p("div",Ye,[e("div",ze,[e("div",Ge,[s[15]||(s[15]=e("h2",{class:"text-lg font-medium leading-6 text-foreground"}," Update Password ",-1)),e("p",Je,[e("a",{class:B(["inline-flex underline transition-colors duration-300 ease-in-out cursor-pointer text-primary hover:text-foreground",{"pointer-events-none text-muted-foreground":r.sending}
1]),onClick:s[5]||(s[5]=C((...l)=>c.sendPasswordReset&&c.sendPasswordReset(...l),["prevent"]))},[u(" Send password reset email to "+w(d.user.name)+" ",1),r.sending?(m(),p("span",Ke,[o(f,{color:"text-primary"})])):v("",!0)],2)])]),o(T,{errors:r.updatePasswordForm.errors},null,8,["errors"]),e("div",Qe,[e("div",Xe,[o(k,{id:"new_password",modelValue:r.updatePasswordForm.new_password,"onUpdate:modelValue":s[6]||(s[6]=l=>r.updatePasswordForm.new_password=l),label:"New Password",required:!0,type:"password",autocomplete:"off",error:r.updatePasswordForm.errors.new_password},null,8,["modelValue","error"])]),e("div",Ze,[o(k,{id:"new_password_confirmation",modelValue:r.updatePasswordForm.new_password_confirmation,"onUpdate:modelValue":s[7]||(s[7]=l=>r.updatePasswordForm.new_password_confirmation=l),label:"Confirm New Password",required:!0,type:"password",autocomplete:"off",error:r.updatePasswordForm.errors.new_password_confirmation},null,8,["modelValue","error"])])])]),e("div",$e,[o(n,{type:"submit",theme:"dark",disabled:r.updatePasswordForm.processing||!r.updatePasswordForm.isDirty,"is-loading":r.updatePasswordForm.processing,onClick:C(c.updatePassword,["prevent"])},{default:_(()=>[...s[16]||(s[16]=[u(" Update Password ",-1)])]),_:1},8,["disabled","is-loading","onClick"])])])):v("",!0)]),_:1})],64)}const vt=le(Ve,[["render",et]]);export{vt as default};
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.