1import{r as a,cm as ge,aR as m,cn as be,m as e,C as je,ag as fe,ah as pe,Z as ve,a5 as N,a6 as z,b0 as B,b1 as H,b2 as V,b3 as M,b4 as Y,y as o,L as _,co as O,cp as Ne,bb as q,bl as Z,ba as G,bc as J,bd as K,be as Q,bf as U,bg as X,bh as ee,bi as se,$ as _e,br as ye,cq as Ce,cr as Pe}from"./index-CZNXzO70.js";import{T as Te,a as ke,b as ae,c as re}from"./tabs-vWwcfo1T.js";import{T as te,a as ne,b as y,c as r,d as le,e as t}from"./table-phobFKUl.js";import{R as ie}from"./refresh-cw-BB70piSI.js";import{C as Se}from"./chevron-left-BKKoo3oE.js";function we({value:l}){return l==null?e.jsx("span",{className:"text-muted-foreground",children:"â"}):e.jsx(_e,{variant:l?"secondary":"outline",className:"text-[10px]",children:l?"Yes":"No"})}function ce({page:l,totalPages:C,totalLabel:n,loading:x,onPrev:d,onNext:g}){return e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:n}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(o,{variant:"outline",size:"sm",disabled:l<=1||x,onClick:d,children:[e.jsx(Se,{className:"h-4 w-4"}),"Previous"]}),e.jsxs(o,{variant:"outline",size:"sm",disabled:l>=C||x,onClick:g,children:["Next",e.jsx(ye,{className:"h-4 w-4"})]})]})]})}function $e(){var W,E;const[l,C]=a.useState("numbers"),[n,x]=a.useState(null),[d,g]=a.useState(!0),[k,b]=a.useState(1),[P,oe]=a.useState(25),[j,de]=a.useState(""),[S,w]=a.useState(null),[i,D]=a.useState(null),[f,F]=a.useState(!0),[A,p]=a.useState(1),[T,me]=a.useState(25),[v,xe]=a.useState(""),[L,I]=a.useState(null),u=a.useCallback(async()=>{g(!0);try{const s=j.trim()?Number(j.trim()):void 0,c=await ge({page_number:k,numbers_per_page:P,...s!=null&&Number.isFinite(s)?{profile_id:s}:{}});x(c)}catch(s){x(null),m.error(s instanceof Error?s.message:"Could not load phone numbers.")}finally{g(!1)}},[k,P,j]),h=a.useCallback(async()=>{F(!0);try{const s=v.trim()?Number(v.trim()):void 0,c=await be({page_number:A,forms_per_page:T,...s!=null&&Number.isFinite(s)?{profile_id:s}:{}});D(c)}catch(s){D(null),m.error(s instanceof Error?s.message:"Could not load web forms.")}finally{F(!1)}},[A,T,v]);a.useEffect(()=>{l==="numbers"&&u()},[l,u]),a.useEffect(()=>{l==="forms"&&h()},[l,h]);const ue=async s=>{w(s);try{await Ce(s),m.success("Phone number deleted."),u()}catch(c){m.error(c instanceof Error?c.message:"Could not delete phone number.")}finally{w(null)}},he=async s=>{I(s);try{await Pe(s),m.success("Web form deleted."),h()}catch(c){m.error(c instanceof Error?c.message:"Could not delete web form.")}finally{I(null)}},$=(n==null?void 0:n.total_pages)??1,R=(i==null?void 0:i.total_pages)??1;return e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(pe,{className:"text-lg",children:"Tracking"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage tracking phone numbers and web forms linked to your account."})]}),e.jsx(ve,{children:e.jsxs(Te,{value:l,onValueChange:s=>C(s),className:"space-y-4",children:[e.jsxs(ke,{children:[e.jsx(ae,{value:"numbers",children:"Phone numbers"}),e.jsx(ae,{value:"forms",children:"Web forms"})]}),e.jsxs(re,{value:"numbers",className:"space-y-4",children:[e.jsx("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"wc-numbers-profile",children:"Profile ID"}),e.jsx(z,{id:"wc-numbers-profile",type:"number",min:1,value:j,onChange:s=>de(s.target.value),placeholder:"Optional (agency key)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Per page"}),e.jsxs(B,{value:String(P),onValueChange:s=>{oe(Number(s)),b(1)},children:[e.jsx(H,{children:e.jsx(V,{})}),e.jsx(M,{children:[25,50,100,250].map(s=>e.jsx(Y,{value:String(s),children:s},s))})]})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(o,{className:"flex-1",variant:"secondary",onClick:()=>{b(1),u()},children:"Apply"}),e.jsx(o,{variant:"outline",size:"icon",onClick:()=>
1void u(),disabled:d,"aria-label":"Refresh phone numbers",children:e.jsx(ie,{className:`h-4 w-4 ${d?"animate-spin":""}`})})]})]})}),d&&!n?e.jsxs("div",{className:"flex items-center justify-center py-16 text-muted-foreground",children:[e.jsx(_,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading phone numbersâ¦"]}):(W=n==null?void 0:n.numbers)!=null&&W.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto rounded-lg border",children:e.jsxs(te,{children:[e.jsx(ne,{children:e.jsxs(y,{children:[e.jsx(r,{children:"Name"}),e.jsx(r,{children:"Tracking #"}),e.jsx(r,{children:"Destination"}),e.jsx(r,{children:"Profile"}),e.jsx(r,{children:"Trigger"}),e.jsx(r,{children:"Recording"}),e.jsx(r,{children:"Last used"}),e.jsx(r,{className:"w-[70px]"})]})}),e.jsx(le,{children:n.numbers.map(s=>e.jsxs(y,{children:[e.jsx(t,{className:"font-medium",children:s.phone_name??"â"}),e.jsx(t,{className:"whitespace-nowrap text-xs",children:O(s.tracking_number,s.tracking_number_iso_country)}),e.jsx(t,{className:"whitespace-nowrap text-xs",children:O(s.destination_number,s.destination_number_iso_country)}),e.jsx(t,{className:"text-xs",children:s.profile??"â"}),e.jsx(t,{className:"max-w-[140px] truncate text-xs",children:s.trigger??"â"}),e.jsx(t,{children:e.jsx(we,{value:s.call_recording})}),e.jsx(t,{className:"whitespace-nowrap text-xs",children:Ne(s.last_used)}),e.jsx(t,{children:e.jsxs(q,{children:[e.jsx(Z,{asChild:!0,children:e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",disabled:S===s.phone_number_id,"aria-label":`Delete ${s.phone_name??s.phone_number_id}`,children:S===s.phone_number_id?e.jsx(_,{className:"h-4 w-4 animate-spin"}):e.jsx(G,{className:"h-4 w-4"})})}),e.jsxs(J,{children:[e.jsxs(K,{children:[e.jsx(Q,{children:"Delete tracking number?"}),e.jsxs(U,{children:["This removes"," ",e.jsx("strong",{children:s.phone_name??"this number"}),". You will no longer track calls for this number."]})]}),e.jsxs(X,{children:[e.jsx(ee,{children:"Cancel"}),e.jsx(se,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>void ue(s.phone_number_id),children:"Delete"})]})]})]})})]},s.phone_number_id))})]})}),e.jsx(ce,{page:n.page_number,totalPages:$,totalLabel:`Page ${n.page_number} of ${$} · ${n.total_numbers} numbers`,loading:d,onPrev:()=>b(s=>Math.max(1,s-1)),onNext:()=>b(s=>s+1)})]}):e.jsx("div",{className:"rounded-lg border border-dashed py-16 text-center text-sm text-muted-foreground",children:"No tracking phone numbers found."})]}),e.jsxs(re,{value:"forms",className:"space-y-4",children:[e.jsx("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"wc-forms-profile",children:"Profile ID"}),e.jsx(z,{id:"wc-forms-profile",type:"number",min:1,value:v,onChange:s=>xe(s.target.value),placeholder:"Optional (agency key)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Per page"}),e.jsxs(B,{value:String(T),onValueChange:s=>{me(Number(s)),p(1)},children:[e.jsx(H,{children:e.jsx(V,{})}),e.jsx(M,{children:[25,50,100,250].map(s=>e.jsx(Y,{value:String(s),children:s},s))})]})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(o,{className:"flex-1",variant:"secondary",onClick:()=>{p(1),h()},children:"Apply"}),e.jsx(o,{variant:"outline",size:"icon",onClick:()=>void h(),disabled:f,"aria-label":"Refresh web forms",children:e.jsx(ie,{className:`h-4 w-4 ${f?"animate-spin":""}`})})]})]})}),f&&!i?e.jsxs("div",{className:"flex items-center justify-center py-16 text-muted-foreground",children:[e.jsx(_,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading web formsâ¦"]}):(E=i==null?void 0:i.forms)!=null&&E.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto rounded-lg border",children:e.jsxs(te,{children:[e.jsx(ne,{children:e.jsxs(y,{children:[e.jsx(r,{children:"Form name"}),e.jsx(r,{children:"Profile"}),e.jsx(r,{children:"Attribute"}),e.jsx(r,{children:"Attribute value"}),e.jsx(r,{children:"Submit attribute"}),e.jsx(r,{children:"Submit value"}),e.jsx(r,{className:"w-[70px]"})]})}),e.jsx(le,{children:i.forms.map(s=>e.jsxs(y,{children:[e.jsx(t,{className:"font-medium",children:s.form_name??"â"}),e.jsx(t,{className:"text-xs",children:s.profile??"â"}),e.jsx(t,{className:"text-xs",children:s.attribute_type??"â"}),e.jsx(t,{className:"max-w-[140px] truncate font-mono text-xs",children:s.attribute_type_value??"â"}),e.jsx(t,{className:"text-xs",children:s.submit_attribute_type??"â"}),e.jsx(t,{className:"max-w-[140px] truncate font-mono text-xs",children:s.submit_attribute_type_value??"â"}),e.jsx(t,{children:e.jsxs(q,{children:[e.jsx(Z,{asChild:!0,children:e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",disabled:L===s.form_id,"aria-label":`Delete ${s.form_name??s.form_id}`,children:L===s.form_id?e.jsx(_,{className:"h-4 w-4 animate-spin"}):e.jsx(G,{className:"h-4 w-4"})})}),e.jsxs(J,{children:[e.jsxs(K,{children:[e.jsx(Q,{children:"Delete web form?"}),e.jsxs(U,{children:["This removes"," ",e.jsx("strong",{children:s.form_name??"this form"}),". You will no longer track submissions for this form."]})]}),e.jsxs(X,{children:[e.jsx(ee,{children:"Cancel"}),e.jsx(se,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>void he(s.form_id),children:"Delete"})]})]})]})})]},s.form_id))})]})}),e.jsx(ce,{page:i.page_number,totalPages:R,totalLabel:`Page ${i.page_number} of ${R} · ${i.total_forms} forms`,loading:f,onPrev:()=>p(s=>Math.max(1,s-1)),onNext:()=>p(s=>s+1)})]}):e.jsx("div",{className:"rounded-lg border border-dashed py-16 text-center text-sm text-muted-foreground",children:"No tracking web forms found."})]})]})})]})}export{$e 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.