1try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a240ed43-25d3-4729-9965-be5cc5fb198e",e._sentryDebugIdIdentifier="sentry-dbid-a240ed43-25d3-4729-9965-be5cc5fb198e")}catch(e){}"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5516],{20016:(e,t,s)=>{s.d(t,{A:()=>l}),s(83225);var a=s(21338),r=s(66609);let n=a.A.create({baseURL:"https://platform.socbyte.ai/api/assetmanagement"});n.interceptors.request.use(e=>{e.withCredentials=!0;try{{let t=localStorage.getItem("sb:lastActivityAtMs"),s=t?Number(t):NaN;Number.isFinite(s)&&Date.now()-s<15e3&&(e.headers=e.headers||{},e.headers["X-SB-User-Active"]="1")}}catch(e){}return e}),n.interceptors.response.use(e=>e,e=>{var t,s,a;return(null==(t=e.response)?void 0:t.status)===403&&r.oR.error(null==(a=e.response)||null==(s=a.data)?void 0:s.message),Promise.reject(e)});let l=n},44715:(e,t,s)=>{s.d(t,{Jv:()=>
1u,Ot:()=>p,W_:()=>d,ZJ:()=>o,mW:()=>y});var a=s(20016),r=s(34686);let n="/asset-management/asset-type",l=e=>e?(0,r.vH)(e):["all"],i=(e,t)=>{var s,a;return(null==e||null==(a=e.response)||null==(s=a.data)?void 0:s.message)||(null==e?void 0:e.message)||t},c=e=>{var t;let s=null==e?void 0:e.data,a=null!=(t=null==s?void 0:s.data)?t:s;return{success:(null==s?void 0:s.success)!==!1,message:null==s?void 0:s.message,item:null==a?void 0:a.item}},d=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;try{var s;let r=await a.A.post("".concat(n,"/list"),{requestedTenant:l(t),...void 0===e.page?{}:{page:e.page},...void 0===e.size?{}:{size:e.size},...(null==(s=e.search)?void 0:s.trim())?{search:e.search.trim()}:{},...e.includeInactive?{includeInactive:!0}:{},...e.category?{category:e.category}:{}});return(e=>{var t,s,a;let r=null==e?void 0:e.data,n=null!=(t=null==r?void 0:r.data)?t:r;return{success:(null==r?void 0:r.success)!==!1,message:null==r?void 0:r.message,results:null!=(s=null==n?void 0:n.results)?s:[],total:Number(null!=(a=null==n?void 0:n.total)?a:0)}})(r)}catch(e){return{success:!1,message:i(e,"Failed to fetch asset types"),results:[],total:0}}},o=async(e,t)=>{let s=[];for(let a=0;a<20;a+=1){let r=await d({page:a,size:100,category:t},e);if(!r.success)return 0===a?[]:s;if(s.push(...r.results.filter(e=>!1!==e.isActive).map(e=>e.name).filter(Boolean)),r.results.length<100||(a+1)*100>=r.total)break}return s},u=async(e,t)=>{try{let s=await a.A.post("".concat(n,"/create"),{...e,requestedTenant:l(t)});return c(s)}catch(e){return{success:!1,message:i(e,"Failed to create asset type")}}},y=async(e,t,s)=>{try{let r=await a.A.patch("".concat(n,"/update/").concat(encodeURIComponent(e)),{...t,requestedTenant:l(s)});return c(r)}catch(e){return{success:!1,message:i(e,"Failed to update asset type")}}},p=async(e,t)=>{try{let s=await a.A.patch("".concat(n,"/disable/").concat(encodeURIComponent(e)),{requestedTenant:l(t)});return c(s)}catch(e){return{success:!1,message:i(e,"Failed to delete asset type")}}}},45516:(e,t,s)=>{s.r(t),s.d(t,{default:()=>k});var a=s(95155),r=s(12115),n=s(60002),l=s(3134),i=s(60285),c=s(61094),d=s(65957),o=s(15007);let u=(0,s(98422).A)("outline","device-desktop","DeviceDesktop",[["path",{d:"M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10",key:"svg-0"}],["path",{d:"M7 20h10",key:"svg-1"}],["path",{d:"M9 16v4",key:"svg-2"}],["path",{d:"M15 16v4",key:"svg-3"}]]);var y=s(80069),p=s(70747),m=s(37911),h=s(73124),g=s(33936),x=s(8213),v=s(76426),f=s(57828),j=s(73344),w=s(28438),A=s(83548),S=s(25475),b=s(51588),C=s(31376),T=s(22980),N=s(44715);function k(){let{user:e}=(0,T.J)(),t=(null==e?void 0:e.tenantType)==="platform",[s,k]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),[M,_]=(0,r.useState)(!1),[F,q]=(0,r.useState)([]),[O,z]=(0,r.useState)(0),[V,E]=(0,r.useState)(!1),[P,R]=(0,r.useState)(null),[U,W]=(0,r.useState)(!1),[B,J]=(0,r.useState)({pageIndex:0,pageSize:10}),[$,K]=(0,r.useState)([]),[H,L]=(0,r.useState)(!0),[Q,X]=(0,r.useState)(""),[Z,G]=(0,r.useState)(""),[Y,ee]=(0,r.useState)(null),[et,es]=(0,r.useState)(null),[ea,er]=(0,r.useState)(null),[en,el]=(0,r.useState)(!1),[ei,ec]=(0,r.useState)(""),[ed,eo]=(0,r.useState)(""),[eu,ey]=(0,r.useState)(""),[ep,em]=(0,r.useState)({}),eh=(0,r.useCallback)(async()=>{if(!s)return;E(!0),R(null);let t=await (0,N.W_)({page:B.pageIndex,size:B.pageSize,search:Z.trim()||void 0},e);t.success?(q(t.results),z(t.total)):(R(t.message||"Failed to fetch asset types"),q([]),z(0)),E(!1)},[s,B.pageIndex,B.pageSize,Z,e]);(0,r.useEffect)(()=>{eh()},[eh]);let eg=()=>{X(""),G(""),J(e=>({...e,pageIndex:0}))},ex=()=>{ee(null),ec(""),eo(""),ey(""),em({})},ev=async s=>{if(s.preventDefault(),!t)return void C.toast.error("Only platform users can manage asset types.");let a={name:!ei.trim(),category:!eu};if(em(a),a.name||a.category)return void C.toast.error("Please fill in all required fields");W(!0);let r={name:ei.trim(),description:ed.trim()||void 0,category:eu},n=Y?await (0,N.mW)(Y.id,r,e):await (0,N.Jv)(r,e);if(W(!1),!n.success)return void C.toast.error(n.message||(Y?"Failed to update asset type":"Failed to create asset type"));C.toast.success(n.message||(Y?"Asset type updated successfully":"Asset type created successfully")),D(!1),ex(),eh()},ef=async()=>
1{if(!ea)return;el(!0);let t=await (0,N.Ot)(ea.id,e);if(el(!1),!t.success)return void C.toast.error(t.message||"Failed to delete asset type");C.toast.success(t.message||"Asset type deleted successfully"),er(null),eh()},ej=(0,r.useMemo)(()=>[{accessorKey:"name",header:e=>{let{column:t}=e;return(0,a.jsx)(g.w,{column:t,title:"Asset Type"})},cell:e=>{let{cell:t}=e;return t.getValue()}},{accessorKey:"description",header:"Description",cell:e=>{let{row:t}=e;return t.original.description||"â"}},{accessorKey:"category",header:"Category",cell:e=>{let{row:t}=e;return t.original.category||"â"}},{id:"actions",header:"Actions",cell:e=>{let{row:s}=e;return(0,a.jsxs)(b.rI,{children:[(0,a.jsx)(b.ty,{asChild:!0,children:(0,a.jsxs)(p.$,{variant:"ghost",className:"h-8 w-4 p-0",children:[(0,a.jsx)("span",{className:"sr-only",children:"Open menu"}),(0,a.jsx)(i.A,{className:"h-4 w-4"})]})}),(0,a.jsxs)(b.SQ,{align:"end",children:[(0,a.jsxs)(b._2,{onClick:()=>{es(s.original),_(!0)},children:[(0,a.jsx)(c.A,{className:"h-4 w-4 text-[var(--editIcon)]"}),"View"]}
1),t&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(b._2,{onClick:()=>{var e,t;ee(e=s.original),ec(e.name),eo(null!=(t=e.description)?t:""),ey(e.category),em({}),D(!0)},children:[(0,a.jsx)(d.A,{className:"h-4 w-4 text-[var(--editIcon)]"}),"Edit"]}),(0,a.jsxs)(b._2,{onClick:()=>er(s.original),children:[(0,a.jsx)(o.A,{className:"h-4 w-4 text-[var(--deleteIcon)]"}),"Delete"]})]})]})]})}}],[t]),ew=(0,n.N4)({data:F,columns:ej,getCoreRowModel:(0,l.HT)(),getSortedRowModel:(0,l.h5)(),getPaginationRowModel:(0,l.kW)(),onPaginationChange:J,onSortingChange:K,manualPagination:!0,pageCount:O>0?Math.ceil(O/B.pageSize):1,meta:{totalRows:O},state:{pagination:B,sorting:$}});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(p.$,{onClick:()=>k(!0),variant:"icon","data-sentry-element":"Button","data-sentry-source-file":"AssetType.tsx",children:[(0,a.jsx)(u,{className:"text-primary !h-6 !w-6","data-sentry-element":"IconDeviceDesktop","data-sentry-source-file":"AssetType.tsx"}),(0,a.jsx)("span",{className:"text-[11px] font-medium text-gray-100",children:"Asset Type"})]}),(0,a.jsx)(m.a,{heading:"Asset Type Management",open:s,onOpenChange:k,showClose:!0,className:"mx-auto w-full max-w-4xl","data-sentry-element":"Modal","data-sentry-source-file":"AssetType.tsx",children:(0,a.jsxs)("div",{className:"space-y-4",children:[P&&(0,a.jsx)("div",{className:"rounded border border-red-400 bg-red-100 px-4 py-3 text-red-700",children:P}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[t&&(0,a.jsxs)(p.$,{onClick:()=>{ex(),D(!0)},children:[(0,a.jsx)(y.A,{className:"!h-5 !w-5 text-white"}),(0,a.jsx)("span",{className:"text-sm font-medium text-white",children:"Create Asset Type"})]}),(0,a.jsx)(v.i,{searchOpen:H,onToggleOpen:()=>L(e=>!e),searchInput:Q,onSearchInputChange:X,onSearch:()=>{Q.trim()&&(G(Q.trim()),J(e=>({...e,pageIndex:0})))},onClear:eg,onEmptied:eg,placeholder:"Search asset types...","data-sentry-element":"TableSearchBox","data-sentry-source-file":"AssetType.tsx"})]}),V?(0,a.jsx)(x.O,{columnCount:4,rowCount:5,withPagination:!0}):(0,a.jsx)(h.b,{table:ew})]})}),(0,a.jsx)(m.a,{heading:"View Asset Type",open:M,onOpenChange:e=>{_(e),e||es(null)},showClose:!0,"data-sentry-element":"Modal","data-sentry-source-file":"AssetType.tsx",children:et?(0,a.jsxs)("div",{className:"space-y-2 text-sm text-gray-200",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-gray-400",children:"Name: "}),et.name]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-gray-400",children:"Description: "}),et.description||"â"]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-gray-400",children:"Category: "}),et.category||"â"]})]}):null}),(0,a.jsx)(m.a,{heading:Y?"Edit Asset Type":"Create Asset Type",open:I,onOpenChange:e=>{D(e),e||ex()},showClose:!0,className:"max-w-md","data-sentry-element":"Modal","data-sentry-source-file":"AssetType.tsx",children:(0,a.jsxs)("form",{onSubmit:ev,className:"space-y-4",children:[(0,a.jsx)(j.D,{id:"asset-type-name",label:"Asset Type",required:!0,value:ei,onChange:e=>{ec(e.target.value),e.target.value.trim()&&em(e=>({...e,name:!1}))},placeholder:"e.g. Firewall",error:ep.name?"Asset type is required":void 0,"data-sentry-element":"ValidatedInput","data-sentry-source-file":"AssetType.tsx"}),(0,a.jsx)(A.P,{id:"asset-type-category",label:"Category",required:!0,error:ep.category?"Category is required":void 0,value:eu,onValueChange:e=>{ey(e),e&&em(e=>({...e,category:!1}))},placeholder:"Which asset tab this type appears under","data-sentry-element":"ValidatedSelect","data-sentry-source-file":"AssetType.tsx",children:(0,a.jsxs)(S.gC,{"data-sentry-element":"SelectContent","data-sentry-source-file":"AssetType.tsx",children:[(0,a.jsx)(S.eb,{value:"Network","data-sentry-element":"SelectItem","data-sentry-source-file":"AssetType.tsx",children:"Network"}),(0,a.jsx)(S.eb,{value:"Software","data-sentry-element":"SelectItem","data-sentry-source-file":"AssetType.tsx",children:"Software"})]})}),(0,a.jsx)(w.r,{id:"asset-type-description",label:"Description",value:ed,onChange:e=>eo(e.target.value),placeholder:"Optional description","data-sentry-element":"ValidatedTextarea","data-sentry-source-file":"AssetType.tsx"}),(0,a.jsx)("div",{className:"flex justify-end space-y-2",children:(0,a.jsx)(p.$,{type:"submit",disabled:U,"data-sentry-element":"Button","data-sentry-source-file":"AssetType.tsx",children:U?Y?"Updating...":"Creating...":Y?"Update":"Create"})})]})}),(0,a.jsx)(f.T,{open:!!ea,onOpenChange:e=>!e&&er(null),title:"Are you sure?",description:"This will remove '".concat((null==ea?void 0:ea.name)||"this asset type","' from the asset type dropdowns. Assets already using it keep their current value."),confirmText:en?"Deleting...":"Delete",cancelText:"Cancel",variant:"destructive",onConfirm:ef,"data-sentry-element":"ConfirmDialog","data-sentry-source-file":"AssetType.tsx"})]})}},61094:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(98422).A)("outline","eye","Eye",[["path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0",key:"svg-0"}],["path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6",key:"svg-1"}]])},83548:(e,t,s)=>{s.d(t,{P:()=>c});var a=s(95155);s(12115);var r=s(20363),n=s(25475),l=s(40980),i=s(45981);function c(e){let{label:t,required:s=!1,error:c,id:d,placeholder:o,triggerClassName:u,wrapperClassName:y,children:p,...m}=e,{t:h}=(0,i.ok)(),g=!!c,x="string"==typeof c?h(c):g?h("This field is required"):void 0;return(0,a.jsxs)("div",{className:(0,l.cn)("space-y-2",y),"data-sentry-component":"ValidatedSelect","data-sentry-source-file":"validated-select.tsx",children:[(0,a.jsxs)(r.J,{htmlFor:d,"data-sentry-element":"Label","data-sentry-source-file":"validated-select.tsx",children:[t,s&&(0,a.jsx)("span",{className:g?"text-red-400":"text-white",children:" *"})]}),(0,a.jsxs)(n.l6,{...m,"data-sentry-element":"Select","data-sentry-source-file":"validated-select.tsx",children:[(0,a.jsx)(n.bq,{id:d,className:(0,l.cn)("w-full",g?"border-red-500 focus:ring-red-500":"",u),"data-sentry-element":"SelectTrigger","data-sentry-source-file":"validated-select.tsx",children:(0,a.jsx)(n.yv,{placeholder:o,"data-sentry-element":"SelectValue","data-sentry-source-file":"validated-select.tsx"})}),p]}),x&&(0,a.jsx)("p",{className:"text-xs text-red-400",children:x})]})}}}]);
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.