1import{u as _,a as H,c as A,r as a,j as e,b as V,i as G}from"./index-BgCxCLoX.js";import{u as $}from"./use-toast-jDi2dAaq.js";import{B as I}from"./button-OUzJbjEB.js";import{S as j,a as g,b as f,c as y,d as p}from"./select-ajKkFKdu.js";import{T as B}from"./TicketList--X2ngknI.js";import{D as q,a as Q,b as W,c as z,d as J,e as K}from"./dialog-C8Uh6DUq.js";import{I as X}from"./input-biuaiVtC.js";import{L as x}from"./label-CHiPhoyb.js";import{T as Y}from"./textarea-FTx9FW5Q.js";import{L as F}from"./loader-circle-BKVB3e40.js";import{a as Z,c as ee}from"./tickets-BIT7AfFy.js";import{P as te}from"./plus-BhMiifqV.js";import"./index-B1UNk8be.js";import"./index-dSc6CJZX.js";import"./utils-DgWKjmuI.js";import"./index-BDUGx-_n.js";import"./index-Dc_FVRD7.js";import"./index-DmNBmVBG.js";import"./index-CKuaslEW.js";import"./Combination-CWbpKF4j.js";import"./index-ByYKhLRC.js";import"./index-B5Udi-Gm.js";import"./index-Do60xCcZ.js";import"./index-ChVTs70w.js";import"./index-DpYD-kU9.js";import"./index-Df-Fbxu-.js";import"./chevron-down-vWsre9dR.js";import"./check-BMqOOrdh.js";import"./card-CqIKthb8.js";import"./TicketProductBadge-CFkazx9b.js";import"./badge-CTt-xE4W.js";import"./index-zLaDunCl.js";import"./index-CTJLTKCj.js";import"./x-CrBELYJ7.js";const se=["LOW","MEDIUM","HIGH","URGENT"],re=["TECHNICAL","BILLING","FEATURE_REQUEST","OTHER"],R=["digital_signage","remote_desktop","disk_health"];function ae({open:i,onClose:c,onCreate:E}){const{t:r}=_(),{user:k,availableProducts:P}=H(),[w]=A(),S=k?.user_type==="ADMIN"?R:null,v=(P??[]).map(t=>t.type).filter(t=>R.includes(t)),n=S??v,m=w.get("product"),d=n.includes(m)?m:null,[b,u]=a.useState(""),[T,N]=a.useState(""),[h,C]=a.useState(d||n[0]||""),[s,o]=a.useState("MEDIUM"),[L,D]=a.useState("TECHNICAL"),[l,O]=a.useState(!1);a.useEffect(()=>{i&&(u(""),N(""),C(d||n[0]||""),o("MEDIUM"),D("TECHNICAL"))},[i]);const U=async t=>{if(t.preventDefault(),!l){O(!0);try{await E({subject:b,body:T,productType:h,priority:s,category:L}),c()}finally{O(!1)}}},M=n.length<=1;return e.jsx(q,{open:i,onOpenChange:t=>!t&&c(),children:e.jsxs(Q,{className:"sm:max-w-lg",children:[e.jsxs(W,{children:[e.jsx(z,{children:r("support.newTicket")}),e.jsx(J,{children:r("support.subtitle")})]}),e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"ticket-product",children:r("support.product")}),e.jsxs(j,{value:h,onValueChange:C,disabled:M||l,children:[e.jsx(g,{id:"ticket-product",children:e.jsx(f,{placeholder:r("support.productPlaceholder")})}),e.jsx(y,{children:n.map(t=>e.jsx(p,{value:t,children:r(`support.products.${t}`,t)},t))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"ticket-subject",children:r("support.subject")}),e.jsx(X,{id:"ticket-subject",value:b,onChange:t=>u(t.target.value),placeholder:r("support.subjectPlaceholder"),minLength:3,maxLength:255,required:!0,disabled:l})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"ticket-priority",children:r("support.priority")}),e.jsxs(j,{value:s,onValueChange:o,disabled:l,children:[e.jsx(g,{id:"ticket-priority",children:e.jsx(f,{})}),e.jsx(y,{children:se.map(t=>e.jsx(p,{value:t,children:r(`support.priorities.${t}`)},t))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"ticket-category",children:r("support.category")}),e.jsxs(j,{value:L,onValueChange:D,disabled:l,children:[e.jsx(g,{id:"ticket-category",children:e.jsx(f,{})}),e.jsx(y,{children:re.map(t=>e.jsx(p,{value:t,children:r(`support.categories.${t}`)},t))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"ticket-body",children:r("support.body")}),e.jsx(Y,{id:"ticket-body",value:T,onChange:t=>N(t.target.value),placeholder:r("support.bodyPlaceholder"),rows:5,minLength:1,required:!0,disabled:l})]}),e.jsxs(K,{children:[e.jsx(I,{type:"button",variant:"outline",onClick:c,disabled:l,children:r("support.cancel")}),e.jsxs(I,{type:"submit",disabled:l||!h,children:[l&&e.jsx(F,{className:"h-4 w-4 mr-1 animate-spin"}),r("support.submit")]})]})]})]})})}const ie=["OPEN","IN_PROGRESS","WAITING_CUSTOMER","RESOLVED","CLOSED"],oe=["digital_signage","remote_desktop","disk_health"];function Ve(){const{t:i}=_(),{toast:c}=$(),E=V(),[r]=A(),[k,P]=a.useState([]),[w,S]=a.useState(!0),[,v]=a.useState(null),[n,m]=a.useState(!1),[d,b]=a.useState("all"),[u,T]=a.useState("all"),{isImpersonating:N}=G(),h=a.useCallback(async()=>{S(!0),v(null);try{const s={};d!=="all"&&(s.status=d),u!=="all"&&(s.product_type=u);const o=await Z(s);P(o.items||[])}catch(s){v(s),c({variant:"destructive",title:i("support.errorLoading"),description:s?.response?.data?.detail||s.message})}finally{S(!1)}},[d,u,i,c]);a.useEffect(()=>{h()}
1,[h]),a.useEffect(()=>{r.get("new")==="1"&&m(!0)},[r]);const C=async s=>{try{const o=await ee(s);c({title:i("support.ticketCreated")}),E(`/support/${o.id}`)}catch(o){throw c({variant:"destructive",title:"Error",description:o?.response?.data?.detail||o.message}),o}};return e.jsxs("div",{className:"space-y-4 max-w-5xl mx-auto p-4",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:i("support.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i("support.subtitle")})]}),!N&&e.jsxs(I,{onClick:()=>m(!0),children:[e.jsx(te,{className:"h-4 w-4 mr-1"}),i("support.newTicket")]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(j,{value:d,onValueChange:b,children:[e.jsx(g,{className:"w-48",children:e.jsx(f,{})}),e.jsxs(y,{children:[e.jsx(p,{value:"all",children:i("support.filters.all")}),ie.map(s=>e.jsx(p,{value:s,children:i(`support.statuses.${s}`)},s))]})]}),e.jsxs(j,{value:u,onValueChange:T,children:[e.jsx(g,{className:"w-48",children:e.jsx(f,{})}),e.jsxs(y,{children:[e.jsx(p,{value:"all",children:i("support.filters.all")}),oe.map(s=>e.jsx(p,{value:s,children:i(`support.products.${s}`)},s))]})]})]}),w?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(F,{className:"h-6 w-6 animate-spin opacity-60"})}):e.jsx(B,{tickets:k}),e.jsx(ae,{open:n,onClose:()=>m(!1),onCreate:C})]})}export{Ve 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.