1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2173],{2079:()=>{},14703:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SafeHtml:()=>r,SandboxedHtml:()=>n});var a=i(54568),l=i(7620),s=i(95832);let r=e=>{let{html:t,className:i,style:r}=e,[n,o]=(0,l.useState)("");return(0,l.useEffect)(()=>{o((0,s.p)(t||""))},[t]),(0,a.jsx)("div",{className:i,style:r,dangerouslySetInnerHTML:{__html:n}})},n=e=>{let{html:t,style:i,minHeight:s=60}=e,r=(0,l.useRef)(null),[n,o]=(0,l.useState)(s),d=(0,l.useRef)("h".concat(Math.random().toString(36).slice(2)));(0,l.useEffect)(()=>{let e=e=>{var t;if(e.source!==(null==(t=r.current)?void 0:t.contentWindow))return;let i=e.data;i&&i.t===d.current&&"number"==typeof i.h&&o(Math.max(s,Math.min(Math.ceil(i.h),5e3)))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[s]);let c='<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><base target="_blank"><style>html,body{margin:0;padding:0;font-family:system-ui,sans-serif}</style></head><body>'.concat(t||"","<script>(function(){function s(){parent.postMessage({t:").concat(JSON.stringify(d.current),",h:document.documentElement.scrollHeight},'*')}window.addEventListener('load',s);new ResizeObserver(s).observe(document.documentElement);s()})()<\/script></body></html>");return(0,a.jsx)("iframe",{ref:r,title:"Embedded content",sandbox:"allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms",srcDoc:c,style:{width:"100%",height:n,border:0,display:"block",...i}})}},22173:(e,t,i)=>{"use strict";i.r(t),i.d(t,{MidnightView:()=>e4});var a=i(54568),l=i(7620),s=i(43002),r=i(28653),n=i(74717),o=i(45234),d=i(70415),c=i(25438),p=i(84990),u=i(38202),m=i(85846),h=i(29038),x=i(58017),b=i(19146),g=i(13679),y=i(3094),f=i(51166),v=i(2934),k=i(32011),j=i(19265),_=i(87551),S=i(99357),w=i(32064),C=i(13119),N=i(74624),A=i(52744),I=i(78317),z=i(18525),R=i(73721),T=i(65202),D=i(64751),W=i(38756),E=i(70783),U=i(38391),B=i(72835),L=i(18080),P=i(74363),O=i(34518),q=i(23140),M=i(47573),F=i(18255),H=i(86936),G=i(77582),Y=i(99648),K=i(61145),V=i(18735),$=i(65087),J=i(75724),X=i(94503),Z=i(65236),Q=i(93129),ee=i(85904),et=i(6158),ei=i(90008);function ea(){let[e,t]=(0,l.useState)(null),[i,a]=(0,l.useState)(!0);return(0,l.useEffect)(()=>{async function e(){a(!0);let{data:{user:e}}=await ei.supabase.auth.getUser();if(!e)return void a(!1);let{data:i}=await ei.supabase.schema("pro").from("sys_user").select("*").eq("auth_user_id",e.id).single();if(i)t(i);else{let{data:i}=await ei.supabase.schema("pro").from("sys_user").select("*").eq("email",e.email).single();i&&t(i)}a(!1)}e();let{data:{subscription:i}}=ei.supabase.auth.onAuthStateChange(()=>e());return()=>i.unsubscribe()},[]),{midnightUser:e,isLoading:i}}let el={incident:{title:"Incident",prefix:"INC",columns:[{key:"number",label:"Number",isLink:!0},{key:"state",label:"State"},{key:"priority",label:"Priority"},{key:"short_description",label:"Short Description"},{key:"assignment_group",label:"Assignment Group"}],fields:[{key:"number",label:"Number",readOnly:!0},{key:"state",label:"State",type:"select",options:[{label:"New",value:"New"},{label:"In Progress",value:"In Progress"},{label:"On Hold",value:"On Hold"},{label:"Resolved",value:"Resolved"},{label:"Closed",value:"Closed"}]},{key:"priority",label:"Priority",type:"select",options:[{label:"1 - Critical",value:"1"},{label:"2 - High",value:"2"},{label:"3 - Moderate",value:"3"},{label:"4 - Low",value:"4"}]},{key:"caller_id",label:"Caller (UUID)",type:"text"},{key:"cmdb_ci",label:"Configuration Item (UUID)",type:"text"},{key:"assignment_group",label:"Assignment Group"},{key:"assigned_to",label:"Assigned To (UUID)",type:"text"},{key:"short_description",label:"Short Description",fullWidth:!0},{key:"description",label:"Description",type:"textarea",fullWidth:!0},{key:"knowledge",label:"Knowledge (true/false)",type:"text"},{key:"close_notes",label:"Resolution Notes",type:"textarea",fullWidth:!0}]},problem:{title:"Problem",prefix:"PRB",columns:[{key:"number",label:"Number",isLink:!0},{key:"state",label:"State"},{key:"priority",label:"Priority"},{key:"short_description",label:"Short Description"}],fields:[{key:"number",label:"Number",readOnly:!0},{key:"state",label:"State",type:"select",options:[{label:"New",value:"New"},{label:"Assess",value:"Assess"},{label:"Root Cause Analysis",value:"Root Cause Analysis"},{label:"Fix in Progress",value:"Fix in Progress"},{label:"Resolved",value:"Resolved"}]},{key:"priority",label:"Priority",type:"select",options:[{label:"1 - Critical",value:"1"},{label:"4 - Low",value:"4"}]},{key:"assignment_group",label:"Assignment Group (UUID)",type:"text"},{key:"assigned_to",label:"Assigned To (UUID)",type:"text"},{key:"short_description",label:"Short Description",fullWidth:!0},{key:"description",label:"Description",type:"textarea",fullWidth:!0},{key:"work_around",label:"Workaround",type:"textarea",fullWidth:!0}]},change_request:{title:"Change Request",prefix:"CHG",columns:[{key:"number",label:"Number",isLink:!0},{key:"state",label:"State"},{key:"priority",label:"Priority"},{key:"short_description",label:"Short Description"}],fields:[{key:"number",label:"Number",readOnly:!0},{key:"state",label:"State",type:"select",options:[{label:"New",value:"New"},{label:"Assess",value:"Assess"},{label:"Authorize",value:"Authorize"},{label:"Scheduled",value:"Scheduled"},{label:"Implement",value:"Implement"},{label:"Review",value:"Review"},{label:"Closed",value:"Closed"}]},{key:"priority",label:"Priority",type:"select",options:[{label:"1 - Critical",value:"1"},{label:"4 - Low",value:"4"}]},{key:"cmdb_ci",label:"Configuration Item (UUID)",type:"text"},{key:"assignment_group",label:"Assignment Group (UUID)",type:"text"},{key:"assigned_to",label:"Assigned To (UUID)",type:"text"},{key:"short_description",label:"Short Description",fullWidth:!0},{key:"description",label:"Description",type:"textarea",fullWidth:!0},{key:"risk_impact",label:"Risk and Impact Analysis",type:"textarea",fullWidth:!0},{key:"implementation_plan",label:"Implementation Plan",type:"textarea",fullWidth:!0},{key:"backout_plan",label:"Backout Plan",type:"textarea",fullWidth:!0}]},sc_req_item:{title:"Requested Item",prefix:"RITM",columns:[{key:"number",label:"Number",isLink:!0},{key:"state",label:"State"},{key:"assignment_group",label:"Assignment Group"},{key:"short_description",label:"Short Description"}],fields:[{key:"number",label:"Number",readOnly:!0},{key:"state",label:"State",type:"select",options:[{label:"Open",value:"Open"},{label:"Work in Progress",value:"Work in Progress"},{label:"Closed Complete",value:"Closed Complete"},{label:"Closed Incomplete",value:"Closed Incomplete"}]},{key:"assignment_group",label:"Assignment Group (UUID)",type:"text"},{key:"assigned_to",label:"Assigned To (UUID)",type:"text"},{key:"short_description",label:"Item Name",fullWidth:!0,readOnly:!0}]},sn_customerservice_case:{title:"Customer Service Case",prefix:"CS",columns:[{key:"number",label:"Number",isLink:!0},{key:"state",label:"State"},{key:"short_description",label:"Subject"},{key:"account",label:"Account"}],fields:[{key:"number",label:"Number",readOnly:!0},{key:"state",label:"State",type:"select",options:[{label:"New",value:"New"},{label:"Open",value:"Open"},{label:"Awaiting Info",value:"Awaiting Info"},{label:"Resolved",value:"Resolved"}]},{key:"account",label:"Account/Company",type:"text"},{key:"contact",label:"Contact Person",type:"text"},{key:"assignment_group",label:"Assignment Group (UUID)",type:"text"},{key:"assigned_to",label:"Assigned To (UUID)",type:"text"},{key:"short_description",label:"Subject",fullWidth:!0},{key:"description",label:"Description",type:"textarea",fullWidth:!0}]},sn_hr_core_case:{title:"HR Case",prefix:"HRC",columns:[{key:"number",label:"Number",isLink:!0},{key:"state",label:"State"},{key:"hr_service",label:"HR Service"},{key:"subject_person",label:"Subject Person"}],fields:[{key:"number",label:"Number",readOnly:!0},{key:"state",label:"State",type:"select",options:[{label:"Draft",value:"Draft"},{label:"Ready",value:"Ready"},{label:"Work in Progress",value:"Work in Progress"},{label:"Closed Complete",value:"Closed Complete"}]},{key:"hr_service",label:"HR Service (e.g. Onboarding)",type:"text"},{key:"subject_person",label:"Subject Person (UUID)",type:"text"},{key:"assignment_group",label:"Assignment Group (UUID)",type:"text"},{key:"assigned_to",label:"Assigned To (UUID)",type:"text"},{key:"short_description",label:"Short Description",fullWidth:!0},{key:"description",label:"Confidential Notes",type:"textarea",fullWidth:!0}]},rm_story:{title:"Agile Story",prefix:"STRY",columns:[{key:"number",label:"Number",isLink:!0},{key:"state",label:"State"},{key:"short_description",label:"Short Description"},{key:"story_points",label:"Story Points"}],fields:[{key:"number",label:"Number",readOnly:!0},{key:"state",label:"State",type:"select",options:[{label:"Draft",value:"Draft"},{label:"Ready",value:"Ready"},{label:"Work in Progress",value:"Work in Progress"},{label:"Testing",value:"Testing"},{label:"Complete",value:"Complete"}]},{key:"story_points",label:"Story Points",type:"text"},{key:"assignment_group",label:"Assignment Group (UUID)",type:"text"},{key:"assigned_to",label:"Assigned To (UUID)",type:"text"},{key:"short_description",label:"Short Description",fullWidth:!0},{key:"description",label:"Acceptance Criteria",type:"textarea",fullWidth:!0}]},idea:{title:"Idea",prefix:"IDEA",columns:[{key:"number",label:"Number",isLink:!0},{key:"state",label:"State"},{key:"short_description",label:"Title"}],fields:[{key:"number",label:"Number",readOnly:!0},{key:"state",label:"State",type:"select",options:[{label:"Submitted",value:"Submitted"},{label:"Under Review",value:"Under Review"},{label:"Accepted",value:"Accepted"},{label:"Rejected",value:"Rejected"}]},{key:"short_description",label:"Title",fullWidth:!0},{key:"description",label:"Business Justification",type:"textarea",fullWidth:!0}]},sn_si_incident:{title:"Security Incident",prefix:"SIR",columns:[{key:"number",label:"Number",isLink:!0},{key:"state",label:"State"},{key:"priority",label:"Priority"},{key:"short_description",label:"Short Description"}],fields:[{key:"number",label:"Number",readOnly:!0},{key:"state",label:"State",type:"select",options:[{label:"Analysis",value:"Analysis"},{label:"Containment",value:"Containment"},{label:"Eradication",value:"Eradication"},{label:"Recovery",value:"Recovery"},{label:"Review",value:"Review"},{label:"Closed",value:"Closed"}]},{key:"priority",label:"Severity",type:"select",options:[{label:"1 - Critical",value:"1"},{label:"2 - High",value:"2"}]},{key:"assignment_group",label:"Assignment Group (UUID)",type:"text"},{key:"assigned_to",label:"Assigned To (UUID)",type:"text"},{key:"short_description",label:"Short Description",fullWidth:!0},{key:"description",label:"Threat Details",type:"textarea",fullWidth:!0}]}
1,cmdb_ci_hardware:{title:"Hardware CI",prefix:"HW",columns:[{key:"name",label:"Name",isLink:!0},{key:"asset_tag",label:"Asset Tag"},{key:"serial_number",label:"Serial Number"},{key:"status",label:"Status"}],fields:[{key:"name",label:"Name",fullWidth:!0},{key:"status",label:"Status",type:"select",options:[{label:"Installed",value:"Installed"},{label:"In Transit",value:"In Transit"},{label:"Retired",value:"Retired"},{label:"Missing",value:"Missing"}]},{key:"asset_tag",label:"Asset Tag",type:"text"},{key:"serial_number",label:"Serial Number",type:"text"},{key:"mac_address",label:"MAC Address",type:"text"},{key:"ip_address",label:"IP Address",type:"text"},{key:"assigned_to",label:"Assigned To (UUID)",type:"text"},{key:"support_group",label:"Support Group (UUID)",type:"text"},{key:"location_id",label:"Location (UUID)",type:"text"},{key:"cost_center",label:"Cost Center (UUID)",type:"text"},{key:"os_version",label:"OS Version",type:"text"}]},cmdb_ci_business_app:{title:"Business Application",prefix:"BAPP",columns:[{key:"name",label:"Name",isLink:!0},{key:"status",label:"Status"},{key:"business_criticality",label:"Criticality"}],fields:[{key:"name",label:"Name",fullWidth:!0},{key:"status",label:"Status",type:"select",options:[{label:"Operational",value:"Operational"},{label:"Retired",value:"Retired"}]},{key:"business_criticality",label:"Business Criticality",type:"select",options:[{label:"1 - High",value:"1"},{label:"2 - Medium",value:"2"},{label:"3 - Low",value:"3"}]},{key:"it_owner",label:"IT Owner (UUID)",type:"text"},{key:"business_owner",label:"Business Owner (UUID)",type:"text"},{key:"description",label:"Description",type:"textarea",fullWidth:!0}]},cmdb_ci_service:{title:"Application Service",prefix:"SVC",columns:[{key:"name",label:"Name",isLink:!0},{key:"status",label:"Status"},{key:"service_classification",label:"Classification"}],fields:[{key:"name",label:"Name",fullWidth:!0},{key:"status",label:"Status",type:"select",options:[{label:"Operational",value:"Operational"},{label:"Retired",value:"Retired"}]},{key:"service_classification",label:"Classification",type:"select",options:[{label:"Application Service",value:"Application Service"},{label:"Technical Service",value:"Technical Service"}]},{key:"support_group",label:"Support Group (UUID)",type:"text"},{key:"description",label:"Description",type:"textarea",fullWidth:!0}]},alm_asset:{title:"Asset",prefix:"AST",columns:[{key:"display_name",label:"Display Name",isLink:!0},{key:"asset_tag",label:"Asset Tag"},{key:"state",label:"State"},{key:"assigned_to",label:"Assigned To"}],fields:[{key:"display_name",label:"Display Name",fullWidth:!0},{key:"state",label:"State",type:"select",options:[{label:"In Use",value:"In Use"},{label:"In Stock",value:"In Stock"},{label:"Retired",value:"Retired"},{label:"Missing",value:"Missing"}]},{key:"asset_tag",label:"Asset Tag",type:"text"},{key:"serial_number",label:"Serial Number",type:"text"},{key:"cost",label:"Cost ($)",type:"text"},{key:"purchased_date",label:"Purchased Date",type:"text"},{key:"assigned_to",label:"Assigned To (UUID)",type:"text"},{key:"ci",label:"Configuration Item (UUID)",type:"text"},{key:"category",label:"Category",type:"text"},{key:"assignment_group",label:"Fulfillment Group (UUID)",type:"text"}]},sc_task:{title:"Catalog Task",prefix:"SCTASK",columns:[{key:"number",label:"Number",isLink:!0},{key:"short_description",label:"Short Description"},{key:"state",label:"State"},{key:"assigned_to",label:"Assigned To"},{key:"parent",label:"Parent Request"}],fields:[{key:"short_description",label:"Short Description",fullWidth:!0},{key:"description",label:"Description",type:"textarea",fullWidth:!0},{key:"state",label:"State",type:"select",options:[{label:"Open",value:"Open"},{label:"Work in Progress",value:"Work in Progress"},{label:"Closed Complete",value:"Closed Complete"}]},{key:"parent",label:"Parent (UUID)",type:"text"},{key:"assignment_group",label:"Assignment Group (UUID)",type:"text"},{key:"assigned_to",label:"Assigned To (UUID)",type:"text"},{key:"work_notes",label:"Work Notes",type:"textarea",fullWidth:!0}]},sys_group:{title:"Assignment Group",prefix:"GRP",columns:[{key:"name",label:"Name",isLink:!0},{key:"type",label:"Type"},{key:"active",label:"Active"}],fields:[{key:"name",label:"Group Name",fullWidth:!0},{key:"type",label:"Type",type:"select",options:[{label:"ITIL",value:"itil"},{label:"HR",value:"hr"},{label:"CSM",value:"csm"},{label:"Security",value:"security"}]},{key:"description",label:"Description",type:"textarea",fullWidth:!0},{key:"active",label:"Active",type:"select",options:[{label:"True",value:"true"},{label:"False",value:"false"}]}]}
1,sysapproval_approver:{title:"Approval",prefix:"APRV",columns:[{key:"number",label:"Number",isLink:!0},{key:"short_description",label:"Context"},{key:"state",label:"State"},{key:"assigned_to",label:"Approver"},{key:"parent",label:"Target Record"}],fields:[{key:"short_description",label:"Context",fullWidth:!0},{key:"state",label:"State",type:"select",options:[{label:"Requested",value:"Requested"},{label:"Approved",value:"Approved"},{label:"Rejected",value:"Rejected"},{label:"Not Yet Requested",value:"Not Yet Requested"}]},{key:"assigned_to",label:"Approver (UUID)",type:"text"},{key:"parent",label:"Target Record (UUID)",type:"text"},{key:"comments",label:"Approval Comments",type:"textarea",fullWidth:!0}]},sys_webhook:{title:"Webhook",prefix:"WH",columns:[{key:"number",label:"Number",isLink:!0},{key:"target_table",label:"Target Table"},{key:"url",label:"Endpoint URL"},{key:"condition_field",label:"Condition Field"},{key:"active",label:"Active"}],fields:[{key:"target_table",label:"Target Table (e.g. incident)",fullWidth:!0},{key:"url",label:"Endpoint URL",fullWidth:!0},{key:"method",label:"HTTP Method",type:"select",options:[{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"GET",value:"GET"}]},{key:"condition_field",label:"Condition Field (e.g. state)"},{key:"condition_value",label:"Condition Value (e.g. Resolved)"}]},sys_report:{title:"Report",prefix:"REP",columns:[{key:"number",label:"Number",isLink:!0},{key:"title",label:"Title"},{key:"target_table",label:"Table"},{key:"type",label:"Type"}],fields:[{key:"title",label:"Report Title",fullWidth:!0},{key:"target_table",label:"Target Table (e.g. incident)"},{key:"type",label:"Type",type:"select",options:[{label:"Bar Chart",value:"bar"},{label:"Pie Chart",value:"pie"},{label:"Single Score",value:"single_score"},{label:"List",value:"list"}]},{key:"group_by",label:"Group By Field (e.g. state)"}]},cmn_cost_center:{title:"Cost Center",prefix:"CC",columns:[{key:"name",label:"Name",isLink:!0},{key:"account_number",label:"Account Number"},{key:"valid_from",label:"Valid From"},{key:"active",label:"Active"}],fields:[{key:"name",label:"Name",fullWidth:!0},{key:"account_number",label:"Account Number",type:"text"},{key:"manager_id",label:"Manager (UUID)",type:"text"},{key:"valid_from",label:"Valid From (Date)",type:"text"},{key:"valid_to",label:"Valid To (Date)",type:"text"},{key:"active",label:"Active",type:"select",options:[{label:"True",value:"true"},{label:"False",value:"false"}]}]},cmn_location:{title:"Location",prefix:"LOC",columns:[{key:"name",label:"Name",isLink:!0},{key:"city",label:"City"},{key:"ownership_type",label:"Ownership"}],fields:[{key:"name",label:"Name",fullWidth:!0},{key:"ownership_type",label:"Ownership Type",type:"select",options:[{label:"Owned",value:"Owned"},{label:"Leased",value:"Leased"}]},{key:"parent_id",label:"Parent Location (UUID)",type:"text"},{key:"cost_center",label:"Cost Center (UUID)",type:"text"},{key:"street",label:"Street",type:"text"},{key:"city",label:"City",type:"text"},{key:"state",label:"State",type:"text"},{key:"zip",label:"Zip/Postal Code",type:"text"},{key:"country",label:"Country",type:"text"}]}};function es(e){if(!e||!e.conditions||0===e.conditions.length)return"";let t=e.conditions.map(e=>{if("group"===e.type)return es(e);{let t=e.value;return("like"===e.operator||"ilike"===e.operator)&&(t="*".concat(t,"*")),"".concat(e.field,".").concat(e.operator,".").concat(t)}}).filter(e=>""!==e);return 0===t.length?"":1===t.length?t[0]:"".concat(e.logical_operator,"(").concat(t.join(","),")")}var er=i(3346);function en(e){let{title:t,data:i,columns:s,basePath:r,onNavigate:n}=e,[o,d]=(0,l.useState)("");return(0,a.jsxs)("div",{className:"midnight-list-container",children:[(0,a.jsxs)("div",{className:"midnight-list-header",children:[(0,a.jsxs)("div",{className:"midnight-list-title-area",children:[(0,a.jsx)("button",{className:"midnight-icon-btn",children:(0,a.jsx)(er.A,{size:16})}),(0,a.jsx)("h2",{className:"midnight-list-title",children:t})]}),(0,a.jsxs)("div",{className:"midnight-list-actions",children:[(0,a.jsxs)("div",{className:"midnight-search-box",children:[(0,a.jsx)(T.A,{size:14}),(0,a.jsx)("input",{type:"text",placeholder:"Search...",value:o,onChange:e=>d(e.target.value)})]}),(0,a.jsx)("button",{className:"midnight-primary-btn",onClick:()=>n("".concat(r,"/new")),children:"New"})]})]}),(0,a.jsx)("div",{className:"midnight-table-container",children:(0,a.jsxs)("table",{className:"midnight-table",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"midnight-checkbox-col",children:(0,a.jsx)("input",{type:"checkbox"})}),s.map(e=>(0,a.jsx)("th",{children:e.label},e.key))]})}),(0,a.jsx)("tbody",{children:0===i.length?(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:s.length+1,style:{textAlign:"center",padding:"40px",color:"var(--midnight-text-muted)"},children:"No records to display"})}):i.map((e,t)=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"midnight-checkbox-col",children:(0,a.jsx)("input",{type:"checkbox"})}),s.map(t=>(0,a.jsx)("td",{children:t.isLink?(0,a.jsx)("button",{className:"midnight-record-link",onClick:()=>n("".concat(r,"/").concat(e.id)),children:e[t.key]}):"state"===t.key?(e=>{if(!e)return null;let t="#4A5568";switch(e.toLowerCase()){case"new":case"requested":case"open":t="#3182ce";break;case"work in progress":case"in progress":t="#d69e2e";break;case"resolved":case"approved":t="#38a169";break;case"closed":case"closed complete":t="#718096";break;case"critical":case"rejected":case"closed incomplete":t="#e53e3e"}return(0,a.jsx)("span",{style:{backgroundColor:t,color:"#FFF",padding:"2px 8px",borderRadius:"12px",fontSize:"11px",fontWeight:"bold",whiteSpace:"nowrap"},children:e})})(e[t.key]):e[t.key]},t.key))]},e.id||t))})]})})]})}i(35743);var eo=i(72116);function ed(e){let{value:t,onChange:i,placeholder:s="Select group..."}=e,[r,n]=(0,l.useState)([]),[o,d]=(0,l.useState)([]),[c,p]=(0,l.useState)(!1),[u,m]=(0,l.useState)(""),[h,x]=(0,l.useState)(""),b=(0,l.useRef)(null);return(0,l.useEffect)(()=>{ei.supabase.schema("pro").from("sys_group").select("id, name, type").eq("active",!0).order("name").then(e=>{let{data:t}=e;t&&(n(t),d(t))})},[]),(0,l.useEffect)(()=>
1{if(t&&r.length>0){let e=r.find(e=>e.id===t);e&&x(e.name)}},[t,r]),(0,l.useEffect)(()=>{let e=u.toLowerCase();d(e?r.filter(t=>t.name.toLowerCase().includes(e)):r)},[u,r]),(0,l.useEffect)(()=>{let e=e=>{b.current&&!b.current.contains(e.target)&&p(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,a.jsxs)("div",{ref:b,style:{position:"relative",width:"100%"},children:[(0,a.jsxs)("button",{type:"button",onClick:()=>p(!c),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderRadius:"4px",border:"1px solid #e2e8f0",background:"#fff",cursor:"pointer",fontSize:"14px",textAlign:"left"},children:[(0,a.jsx)("span",{style:{color:h?"#1a202c":"#a0aec0"},children:h||s}),(0,a.jsx)(eo.A,{size:14,style:{color:"#718096"}})]}),c&&(0,a.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:200,background:"#fff",border:"1px solid #e2e8f0",borderRadius:"6px",boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden",marginTop:"4px"},children:[(0,a.jsxs)("div",{style:{padding:"8px",borderBottom:"1px solid #e2e8f0",display:"flex",alignItems:"center",gap:"8px"},children:[(0,a.jsx)(T.A,{size:14,style:{color:"#a0aec0"}}
1),(0,a.jsx)("input",{autoFocus:!0,type:"text",value:u,onChange:e=>m(e.target.value),placeholder:"Search groups...",style:{border:"none",outline:"none",width:"100%",fontSize:"13px"}})]}),(0,a.jsx)("div",{style:{maxHeight:"220px",overflowY:"auto"},children:0===o.length?(0,a.jsx)("div",{style:{padding:"12px",color:"#a0aec0",fontSize:"13px",textAlign:"center"},children:"No groups found"}):o.map(e=>(0,a.jsxs)("div",{onClick:()=>{x(e.name),i(e.id,e.name),p(!1),m("")},style:{padding:"8px 12px",cursor:"pointer",fontSize:"13px",background:e.id===t?"#ebf8ff":"transparent",color:e.id===t?"#2b6cb0":"#1a202c",display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:e=>e.currentTarget.style.background="#f7fafc",onMouseLeave:i=>i.currentTarget.style.background=e.id===t?"#ebf8ff":"transparent",children:[(0,a.jsx)("span",{children:e.name}),(0,a.jsx)("span",{style:{fontSize:"11px",color:"#718096",background:"#edf2f7",padding:"2px 6px",borderRadius:"10px"},children:e.type})]},e.id))})]})]})}function ec(e){let{title:t,initialData:i,fields:s,onSave:r,basePath:n,onNavigate:o}=e,[d,c]=(0,l.useState)(i||{}),p=(e,t)=>{c(i=>({...i,[e]:t}))};return(0,a.jsxs)("div",{className:"midnight-form-container",children:[(0,a.jsxs)("div",{className:"midnight-form-header",children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"16px"},children:[(0,a.jsx)("button",{onClick:()=>o(n),style:{background:"none",border:"none",color:"var(--midnight-text-muted)",cursor:"pointer",display:"flex"},children:(0,a.jsx)(D.A,{size:24})}),(0,a.jsxs)("h2",{className:"midnight-form-title",children:[t," ",d.number?"- ".concat(d.number):""]})]}),(0,a.jsxs)("div",{className:"midnight-form-actions",children:[(0,a.jsx)("button",{className:"midnight-secondary-btn",onClick:()=>o(n),children:"Cancel"}),(0,a.jsxs)("button",{className:"midnight-primary-btn",onClick:()=>{r(d)},style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,a.jsx)(E.A,{size:16})," Save"]})]})]}),(0,a.jsx)("div",{className:"midnight-form-grid",children:s.map(e=>{var t;return(0,a.jsxs)("div",{className:"midnight-form-group ".concat(e.fullWidth?"full-width":""),children:[(0,a.jsx)("label",{children:e.label}),"select"===e.type?(0,a.jsxs)("select",{value:d[e.key]||"",onChange:t=>p(e.key,t.target.value),disabled:e.readOnly,children:[(0,a.jsx)("option",{value:"",children:"-- None --"}),null==(t=e.options)?void 0:t.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))]}):"group_select"===e.type?(0,a.jsx)(ed,{value:d[e.key]||"",onChange:t=>p(e.key,t),placeholder:"Select group..."}):"textarea"===e.type?(0,a.jsx)("textarea",{rows:4,value:d[e.key]||"",onChange:t=>p(e.key,t.target.value),readOnly:e.readOnly}):(0,a.jsx)("input",{type:e.type||"text",value:d[e.key]||"",onChange:t=>p(e.key,t.target.value),readOnly:e.readOnly,style:e.readOnly?{background:"rgba(255,255,255,0.05)",cursor:"not-allowed",color:"var(--midnight-text-muted)"}:{}})]},e.key)})})]})}var ep=i(12494),eu=i(41365),em=i(12598);function eh(e){let{group:t,onChange:i,targetTable:l}=e,s=el[l],r=s?s.fields:[],n=(e,a)=>{let l={...t};l.conditions=l.conditions.map(t=>"condition"===t.type&&t.id===e?{...t,...a}:t),i(l)},o=e=>{let a={...t};a.conditions=a.conditions.filter(t=>t.id!==e),i(a)};return(0,a.jsxs)("div",{style:{borderLeft:"2px solid #cbd5e0",paddingLeft:"16px",marginBottom:"8px"},children:[(0,a.jsxs)("div",{style:{display:"flex",gap:"8px",marginBottom:"12px",alignItems:"center"},children:[(0,a.jsxs)("select",{value:t.logical_operator,onChange:e=>i({...t,logical_operator:e.target.value}),style:{padding:"4px 8px",borderRadius:"4px",border:"1px solid #e2e8f0",background:"#f7fafc",fontWeight:"bold"},children:[(0,a.jsx)("option",{value:"and",children:"AND"}),(0,a.jsx)("option",{value:"or",children:"OR"})]}),(0,a.jsxs)("button",{onClick:()=>{var e;i({...t,conditions:[...t.conditions,{id:Math.random().toString(36).substr(2,9),type:"condition",field:(null==(e=r[0])?void 0:e.key)||"id",operator:"eq",value:""}]})},style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",padding:"4px 8px",background:"#e2e8f0",borderRadius:"4px"},children:[(0,a.jsx)(ep.A,{size:12})," Condition"]}),(0,a.jsxs)("button",{onClick:()=>{var e;i({...t,conditions:[...t.conditions,{id:Math.random().toString(36).substr(2,9),type:"group",logical_operator:"and"===t.logical_operator?"or":"and",conditions:[{id:Math.random().toString(36).substr(2,9),type:"condition",field:(null==(e=r[0])?void 0:e.key)||"id",operator:"eq",value:""}]}]})},style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",padding:"4px 8px",background:"#e2e8f0",borderRadius:"4px"},children:[(0,a.jsx)(eu.A,{size:12})," Add Group"]})]}),(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.conditions.map(e=>"group"===e.type?(0,a.jsxs)("div",{style:{position:"relative"},children:[(0,a.jsx)("button",{onClick:()=>o(e.id),style:{position:"absolute",left:"-28px",top:"4px",color:"#e53e3e",background:"none",border:"none",cursor:"pointer"},children:(0,a.jsx)(em.A,{size:14})}),(0,a.jsx)(eh,{group:e,onChange:a=>((e,a)=>{let l={...t};l.conditions=l.conditions.map(t=>"group"===t.type&&t.id===e?a:t),i(l)})(e.id,a),targetTable:l})]},e.id):(0,a.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[(0,a.jsxs)("select",{value:e.field,onChange:t=>n(e.id,{field:t.target.value}),style:{padding:"6px",borderRadius:"4px",border:"1px solid #e2e8f0",minWidth:"150px"},children:[r.map(e=>(0,a.jsx)("option",{value:e.key,children:e.label},e.key)),(0,a.jsx)("option",{value:"sys_class_name",children:"Class Name"}),(0,a.jsx)("option",{value:"state",children:"State"}),(0,a.jsx)("option",{value:"assigned_to",children:"Assigned To"})]}),(0,a.jsxs)("select",{value:e.operator,onChange:t=>n(e.id,{operator:t.target.value}),style:{padding:"6px",borderRadius:"4px",border:"1px solid #e2e8f0"},children:[(0,a.jsx)("option",{value:"eq",children:"="}),(0,a.jsx)("option",{value:"neq",children:"!="}),(0,a.jsx)("option",{value:"like",children:"contains"}),(0,a.jsx)("option",{value:"gt",children:">"}),(0,a.jsx)("option",{value:"lt",children:"<"})]}),(0,a.jsx)("input",{type:"text",value:e.value,onChange:t=>n(e.id,{value:t.target.value}),placeholder:"Value",style:{padding:"6px",borderRadius:"4px",border:"1px solid #e2e8f0",flex:1}}),(0,a.jsx)("button",{onClick:()=>o(e.id),style:{color:"#e53e3e",background:"none",border:"none",cursor:"pointer",padding:"4px"},children:(0,a.jsx)(em.A,{size:16})})]},e.id))})]})}var ex=i(20415),eb=i(30866),eg=i(29304);function ey(e){let{taskId:t}=e,[i,s]=(0,l.useState)([]),[r,n]=(0,l.useState)(""),[d,c]=(0,l.useState)("work_notes"),[p,u]=(0,l.useState)(!1),m=async()=>{let{data:e}=await ei.supabase.schema("pro").from("sys_journal_field").select("*, sys_user(first_name, last_name, email)").eq("task_id",t).order("created_at",{ascending:!1});e&&s(e)};(0,l.useEffect)(()=>
1{if(!t)return;m();let e=ei.supabase.channel("journal-".concat(t)).on("postgres_changes",{event:"INSERT",schema:"pro",table:"sys_journal_field",filter:"task_id=eq.".concat(t)},()=>m()).subscribe();return()=>{ei.supabase.removeChannel(e)}},[t]);let h=async()=>{r.trim()&&(u(!0),await ei.supabase.schema("pro").from("sys_journal_field").insert({task_id:t,type:d,value:r.trim()}),n(""),u(!1),m())};return(0,a.jsxs)("div",{style:{marginTop:"32px",borderTop:"1px solid #e2e8f0",paddingTop:"24px"},children:[(0,a.jsxs)("h3",{style:{fontSize:"14px",fontWeight:700,color:"#1a202c",marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,a.jsx)(ex.A,{size:16})," Activity Feed"]}),(0,a.jsxs)("div",{style:{background:"#f7fafc",border:"1px solid #e2e8f0",borderRadius:"8px",padding:"12px",marginBottom:"20px"},children:[(0,a.jsxs)("div",{style:{display:"flex",gap:"8px",marginBottom:"8px"},children:[(0,a.jsx)("button",{onClick:()=>c("work_notes"),style:{padding:"4px 10px",borderRadius:"4px",border:"1px solid #e2e8f0",background:"work_notes"===d?"#3b82f6":"#fff",color:"work_notes"===d?"#fff":"#4a5568",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"Work Notes"}),(0,a.jsx)("button",{onClick:()=>c("comments"),style:{padding:"4px 10px",borderRadius:"4px",border:"1px solid #e2e8f0",background:"comments"===d?"#10b981":"#fff",color:"comments"===d?"#fff":"#4a5568",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"Customer Notes"})]}),(0,a.jsx)("textarea",{value:r,onChange:e=>n(e.target.value),placeholder:"work_notes"===d?"Add a work note (internal only)...":"Add a customer-visible comment...",rows:3,style:{width:"100%",padding:"8px",borderRadius:"4px",border:"1px solid #e2e8f0",fontSize:"13px",resize:"vertical",boxSizing:"border-box"}}),(0,a.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"8px"},children:(0,a.jsxs)("button",{onClick:h,disabled:!r.trim()||p,style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 14px",background:"#3b82f6",color:"#fff",borderRadius:"4px",border:"none",fontSize:"12px",fontWeight:600,cursor:"pointer",opacity:!r.trim()||p?.5:1},children:[(0,a.jsx)(eg.A,{size:12})," Post"]})})]}),(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:0===i.length?(0,a.jsx)("div",{style:{color:"#a0aec0",fontSize:"13px",textAlign:"center",padding:"20px"},children:"No activity yet"}):i.map(e=>{var t,i;return(0,a.jsxs)("div",{style:{background:"state_change"===(t=e.type)?"#fffbeb":"work_notes"===t?"#eff6ff":"#f0fdf4",border:"1px solid #e2e8f0",borderRadius:"6px",padding:"10px 12px"},children:[(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"4px"},children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"12px",color:"#4a5568",fontWeight:600},children:["state_change"===(i=e.type)?(0,a.jsx)(o.A,{size:13,style:{color:"#f59e0b"}}):"work_notes"===i?(0,a.jsx)(ex.A,{size:13,style:{color:"#3b82f6"}}):(0,a.jsx)(eb.A,{size:13,style:{color:"#10b981"}}),e.sys_user?"".concat(e.sys_user.first_name," ").concat(e.sys_user.last_name):"System",(0,a.jsxs)("span",{style:{fontWeight:400,color:"#718096"},children:["\xb7 ",e.type.replace("_"," ")]})]}),(0,a.jsx)("span",{style:{fontSize:"11px",color:"#a0aec0"},children:(e=>{let t=(Date.now()-new Date(e).getTime())/1e3;return t<60?"just now":t<3600?"".concat(Math.floor(t/60),"m ago"):t<86400?"".concat(Math.floor(t/3600),"h ago"):new Date(e).toLocaleDateString()})(e.created_at)})]}),(0,a.jsx)("div",{style:{fontSize:"13px",color:"#2d3748",whiteSpace:"pre-wrap"},children:e.value})]},e.id)})})]})}var ef=i(57982);function ev(e){let{taskId:t}=e,[i,s]=(0,l.useState)(null),[r,n]=(0,l.useState)("");if((0,l.useEffect)(()=>{t&&ei.supabase.schema("pro").from("task_sla").select("planned_resolution_at, is_breached, stage").eq("task_id",t).single().then(e=>{let{data:t}=e;t&&s(t)})},[t]),(0,l.useEffect)(()=>{if(!i||"active"!==i.stage)return;let e=()=>{let e=new Date(i.planned_resolution_at).getTime()-Date.now();if(e<=0)return void n("BREACHED");let t=Math.floor(e/36e5),a=Math.floor(e%36e5/6e4);n(t>0?"".concat(t,"h ").concat(a,"m remaining"):"".concat(a,"m remaining"))};e();let t=setInterval(e,6e4);return()=>clearInterval(t)},[i]),!i)return null;let o=i.is_breached||"BREACHED"===r,d=!o&&"active"===i.stage&&r.includes("m remaining")&&!r.includes("h");return"completed"===i.stage?(0,a.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 8px",borderRadius:"12px",fontSize:"11px",fontWeight:700,background:"#f0fdf4",color:"#16a34a"},children:[(0,a.jsx)(N.A,{size:11})," SLA Met"]}):(0,a.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",borderRadius:"12px",fontSize:"11px",fontWeight:700,background:o?"#fef2f2":d?"#fffbeb":"#eff6ff",color:o?"#dc2626":d?"#d97706":"#2563eb",border:"1px solid ".concat(o?"#fecaca":d?"#fde68a":"#bfdbfe")},children:[o?(0,a.jsx)(ef.A,{size:11}):(0,a.jsx)(N.A,{size:11}),o?"SLA BREACHED":r]})}var ek=i(7571),ej=i(46395);function e_(e){let{onNavigate:t}=e,[i,s]=(0,l.useState)([]),[r,n]=(0,l.useState)(!1),o=(0,l.useRef)(null),d=i.filter(e=>!e.read).length,{midnightUser:c}=ea(),p=async()=>
1{if(!c)return;let{data:e}=await ei.supabase.schema("pro").from("sys_notification").select("*").eq("user_id",c.id).order("created_at",{ascending:!1}).limit(20);e&&s(e)};(0,l.useEffect)(()=>{if(!c)return;p();let e=ei.supabase.channel("notifications-".concat(c.id)).on("postgres_changes",{event:"INSERT",schema:"pro",table:"sys_notification",filter:"user_id=eq.".concat(c.id)},()=>{p()}).subscribe(),t=e=>{o.current&&!o.current.contains(e.target)&&n(!1)};return document.addEventListener("mousedown",t),()=>{ei.supabase.removeChannel(e),document.removeEventListener("mousedown",t)}},[c]);let u=async()=>{await ei.supabase.schema("pro").from("sys_notification").update({read:!0}).eq("read",!1),p()},m=async e=>{await ei.supabase.schema("pro").from("sys_notification").update({read:!0}).eq("id",e),s(t=>t.map(t=>t.id===e?{...t,read:!0}:t))};return(0,a.jsxs)("div",{ref:o,style:{position:"relative"},children:[(0,a.jsxs)("button",{onClick:()=>n(!r),className:"midnight-icon-btn",style:{position:"relative"},title:"Notifications",children:[(0,a.jsx)(ek.A,{size:20}),d>0&&(0,a.jsx)("span",{style:{position:"absolute",top:"-4px",right:"-4px",background:"#e53e3e",color:"#fff",borderRadius:"50%",width:"18px",height:"18px",fontSize:"10px",fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:d>9?"9+":d})]}),r&&(0,a.jsxs)("div",{style:{position:"absolute",right:0,top:"40px",width:"360px",background:"#1e293b",border:"1px solid #334155",borderRadius:"8px",boxShadow:"0 10px 40px rgba(0,0,0,0.4)",zIndex:1e3,overflow:"hidden"},children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid #334155"},children:[(0,a.jsxs)("span",{style:{fontWeight:700,color:"#f1f5f9",fontSize:"14px"},children:["Notifications ",d>0&&(0,a.jsx)("span",{style:{background:"#3b82f6",color:"#fff",borderRadius:"12px",padding:"1px 7px",fontSize:"11px",marginLeft:"6px"},children:d})]}),(0,a.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[d>0&&(0,a.jsxs)("button",{onClick:u,title:"Mark all read",style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px",fontSize:"12px"},children:[(0,a.jsx)(ej.A,{size:14})," All read"]}),(0,a.jsx)("button",{onClick:()=>n(!1),style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer"},children:(0,a.jsx)(em.A,{size:16})})]})]}),(0,a.jsx)("div",{style:{maxHeight:"400px",overflowY:"auto"},children:0===i.length?(0,a.jsx)("div",{style:{padding:"40px",textAlign:"center",color:"#64748b",fontSize:"13px"},children:"No notifications yet"}):i.map(e=>(0,a.jsxs)("div",{onClick:()=>m(e.id),style:{padding:"12px 16px",borderBottom:"1px solid #1e293b",background:e.read?"transparent":"rgba(59,130,246,0.08)",cursor:"pointer",transition:"background 0.2s"},children:[(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"8px"},children:[(0,a.jsxs)("div",{style:{flex:1},children:[(0,a.jsx)("div",{style:{fontSize:"13px",fontWeight:e.read?400:600,color:e.read?"#94a3b8":"#f1f5f9",marginBottom:"2px"},children:e.title}),(0,a.jsx)("div",{style:{fontSize:"12px",color:"#64748b"},children:e.message})]}),(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"4px",flexShrink:0},children:[(0,a.jsx)("span",{style:{fontSize:"11px",color:"#475569"},children:(e=>{let t=(Date.now()-new Date(e).getTime())/1e3;return t<60?"just now":t<3600?"".concat(Math.floor(t/60),"m ago"):t<86400?"".concat(Math.floor(t/3600),"h ago"):"".concat(Math.floor(t/86400),"d ago")})(e.created_at)}),!e.read&&(0,a.jsx)("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"#3b82f6",display:"inline-block"}})]})]}),e.record_table&&e.record_id&&(0,a.jsx)("button",{onClick:i=>{i.stopPropagation(),t("/midnight/task/".concat(e.record_table,"/").concat(e.record_id))},style:{fontSize:"11px",color:"#3b82f6",marginTop:"4px",background:"none",border:"none",padding:0,cursor:"pointer",display:"inline-block"},children:"View record â"})]},e.id))})]})]})}var eS=i(75892);function ew(e){let{onNavigate:t}=e,[i,s]=(0,l.useState)(""),[n,o]=(0,l.useState)([]),[d,c]=(0,l.useState)(!1),[u,m]=(0,l.useState)(!1),[h,b]=(0,l.useState)(-1),g=(0,l.useRef)(null),y=(0,l.useRef)(null),f=(0,l.useRef)(null),v=(0,l.useCallback)(async e=>{if(!e||e.length<2){o([]),c(!1);return}m(!0);let t=ei.supabase.schema("pro"),[i,a,l]=await Promise.all([t.from("task").select("id, number, short_description, sys_class_name, state").or("short_description.ilike.%".concat(e,"%,number.ilike.%").concat(e,"%")).limit(5),t.from("kb_knowledge").select("id, short_description").ilike("short_description","%".concat(e,"%")).limit(3),t.from("cmdb_ci").select("id, name, sys_class_name").ilike("name","%".concat(e,"%")).limit(3)]),s=(i.data||[]).map(e=>({id:e.id,label:"".concat(e.number||""," â ").concat(e.short_description||""),sublabel:"".concat(e.sys_class_name," \xb7 ").concat(e.state),href:"/midnight/task/".concat(e.sys_class_name,"/").concat(e.id),type:"task"}));o([...s,...(a.data||[]).map(e=>({id:e.id,label:e.short_description,sublabel:"Knowledge Article",href:"/midnight/kb/".concat(e.id),type:"kb"})),...(l.data||[]).map(e=>({id:e.id,label:e.name,sublabel:e.sys_class_name,href:"/midnight/cmdb/".concat(e.sys_class_name,"/").concat(e.id),type:"ci"}))]),c(!0),m(!1),b(-1)},[]);return(0,l.useEffect)(()=>(f.current&&clearTimeout(f.current),f.current=setTimeout(()=>v(i),250),()=>{f.current&&clearTimeout(f.current)}),[i,v]),(0,l.useEffect)(()=>{let e=e=>{y.current&&!y.current.contains(e.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,a.jsxs)("div",{ref:y,style:{position:"relative",flex:1,maxWidth:"480px"},children:[(0,a.jsxs)("div",{className:"midnight-search-bar",style:{display:"flex",alignItems:"center",gap:"8px"},children:[u?(0,a.jsx)("div",{style:{width:"18px",height:"18px",border:"2px s
1olid #e2e8f0",borderTopColor:"#3b82f6",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}):(0,a.jsx)(T.A,{size:18,style:{color:"#94a3b8",flexShrink:0}}),(0,a.jsx)("input",{ref:g,type:"text",value:i,onChange:e=>s(e.target.value),onFocus:()=>i.length>=2&&c(!0),onKeyDown:e=>{"ArrowDown"===e.key&&(e.preventDefault(),b(e=>Math.min(e+1,n.length-1))),"ArrowUp"===e.key&&(e.preventDefault(),b(e=>Math.max(e-1,0))),"Escape"===e.key&&(c(!1),s(""))},placeholder:"Search tasks, CIs, articles, users...",style:{flex:1,background:"transparent",border:"none",outline:"none",fontSize:"14px",color:"inherit"}}),i&&(0,a.jsx)("button",{onClick:()=>{s(""),o([]),c(!1)},style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",padding:"0"},children:(0,a.jsx)(em.A,{size:14})})]}),d&&n.length>0&&(0,a.jsxs)("div",{style:{position:"absolute",top:"calc(100% + 8px)",left:0,right:0,zIndex:1e3,background:"#1e293b",border:"1px solid #334155",borderRadius:"8px",boxShadow:"0 10px 40px rgba(0,0,0,0.4)",overflow:"hidden"},children:[n.map((e,i)=>{var l;return(0,a.jsxs)("div",{onClick:()=>{t(e.href),c(!1),s("")},style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",cursor:"pointer",background:h===i?"#334155":"transparent",borderBottom:"1px solid #1e3a5f20",transition:"background 0.15s"},onMouseEnter:()=>b(i),children:["task"===(l=e.type)?(0,a.jsx)(r.A,{size:13,style:{color:"#3b82f6"}}):"kb"===l?(0,a.jsx)(eS.A,{size:13,style:{color:"#10b981"}}):"ci"===l?(0,a.jsx)(x.A,{size:13,style:{color:"#8b5cf6"}}):(0,a.jsx)(p.A,{size:13,style:{color:"#f59e0b"}}),(0,a.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,a.jsx)("div",{style:{fontSize:"13px",color:"#f1f5f9",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label}),(0,a.jsx)("div",{style:{fontSize:"11px",color:"#64748b",marginTop:"1px"},children:e.sublabel})]})]},e.id)}),(0,a.jsxs)("div",{style:{padding:"8px 14px",fontSize:"11px",color:"#475569",borderTop:"1px solid #334155"},children:[n.length," result",1!==n.length?"s":"",' for "',i,'"']})]})]})}i(2079);var eC=i(14703);function eN(e){return e.startsWith("alm_")?"alm_asset":e.startsWith("cmn_")?e:"cmdb_ci"}let eA=[{items:[{href:"/midnight",label:"Dashboard",icon:(0,a.jsx)(s.A,{size:20}),match:"/midnight"}]},{category:"IT SERVICE MANAGEMENT",items:[{href:"/midnight/task/incident",label:"Incidents",icon:(0,a.jsx)(r.A,{size:20}),match:"/task/incident"},{href:"/midnight/task/problem",label:"Problems",icon:(0,a.jsx)(n.A,{size:20}),match:"/task/problem"},{href:"/midnight/task/change_request",label:"Changes",icon:(0,a.jsx)(o.A,{size:20}),match:"/task/change_request"}]},{category:"SERVICE CATALOG",items:[{href:"/midnight/catalog",label:"Catalog Items",icon:(0,a.jsx)(d.A,{size:20}),match:"/catalog"},{href:"/midnight/task/sc_req_item",label:"Requested Items",icon:(0,a.jsx)(c.A,{size:20}),match:"/task/sc_req_item"}]},{category:"BUSINESS OPERATIONS",items:[{href:"/midnight/task/sn_customerservice_case",label:"CSM Cases",icon:(0,a.jsx)(p.A,{size:20}),match:"/task/sn_customerservice_case"},{href:"/midnight/task/sn_hr_core_case",label:"HR Cases",icon:(0,a.jsx)(u.A,{size:20}),match:"/task/sn_hr_core_case"}]},{category:"STRATEGIC PORTFOLIO",items:[{href:"/midnight/task/idea",label:"Ideas",icon:(0,a.jsx)(m.A,{size:20}),match:"/task/idea"},{href:"/midnight/task/rm_story",label:"Agile Stories",icon:(0,a.jsx)(m.A,{size:20}),match:"/task/rm_story"}]},{items:[{href:"/midnight/kb",label:"Articles",icon:(0,a.jsx)(h.A,{size:20}),match:"/kb"}]}
1,{category:"CONFIGURATION (CSDM)",items:[{href:"/midnight/cmdb/cmdb_ci_hardware",label:"Hardware CIs",icon:(0,a.jsx)(x.A,{size:20}),match:"/cmdb/cmdb_ci_hardware"},{href:"/midnight/cmdb/cmdb_ci_business_app",label:"Business Applications",icon:(0,a.jsx)(b.A,{size:20}),match:"/cmdb/cmdb_ci_business_app"},{href:"/midnight/cmdb/cmdb_ci_service",label:"Application Services",icon:(0,a.jsx)(g.A,{size:20}),match:"/cmdb/cmdb_ci_service"}]},{category:"ASSET MANAGEMENT",items:[{href:"/midnight/cmdb/alm_asset",label:"Financial Assets",icon:(0,a.jsx)(y.A,{size:20}),match:"/cmdb/alm_asset"}]},{category:"FOUNDATION DATA",items:[{href:"/midnight/cmdb/cmn_location",label:"Locations",icon:(0,a.jsx)(f.A,{size:20}),match:"/cmdb/cmn_location"},{href:"/midnight/cmdb/cmn_cost_center",label:"Cost Centers",icon:(0,a.jsx)(v.A,{size:20}),match:"/cmdb/cmn_cost_center"}]},{category:"SYSTEM ADMINISTRATION",items:[{href:"/midnight/ire",label:"IRE Import",icon:(0,a.jsx)(k.A,{size:18}),match:"/ire"},{href:"/midnight/task/sys_group",label:"Groups",icon:(0,a.jsx)(p.A,{size:18}),match:"/task/sys_group"},{href:"/midnight/reports",label:"Reports",icon:(0,a.jsx)(j.A,{size:18}),match:"/reports"},{href:"/midnight/users",label:"Users",icon:(0,a.jsx)(p.A,{size:18}),match:"/users"},{href:"/midnight/task/sys_webhook",label:"Webhooks",icon:(0,a.jsx)(_.A,{size:18}),match:"/task/sys_webhook"},{href:"/midnight/branding",label:"Branding",icon:(0,a.jsx)(S.A,{size:18}),match:"/branding"}]},{category:"END USER",items:[{href:"/midnight/portal",label:"Service Portal",icon:(0,a.jsx)(w.A,{size:20}),match:"/portal"}]}],eI=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4"];function ez(){let[e,t]=(0,l.useState)({incidents:0,unassigned:0,changes:0,critical:0}),[i,s]=(0,l.useState)([]),[r,o]=(0,l.useState)({}),d=l.useCallback(async()=>{var e,i,a,l;let s=ei.supabase.schema("pro"),[r,n,o,d]=await Promise.all([s.from("task").select("id",{count:"exact",head:!0}).eq("sys_class_name","incident").not("state","in",'("Resolved","Closed")'),s.from("task").select("id",{count:"exact",head:!0}).is("assigned_to",null),s.from("task").select("id",{count:"exact",head:!0}).eq("sys_class_name","change_request").eq("state","Scheduled"),s.from("task").select("id",{count:"exact",head:!0}).eq("priority","1").not("state","in",'("Resolved","Closed")')]);t({incidents:null!=(e=r.count)?e:0,unassigned:null!=(i=n.count)?i:0,changes:null!=(a=o.count)?a:0,critical:null!=(l=d.count)?l:0})},[]),c=l.useCallback(async e=>{if(!e.sys_report)return;let t=e.sys_report,i=ei.supabase.schema("pro").from("task").select("*").eq("sys_class_name",t.target_table),a=es(t.conditions);a&&(i=i.or(a));let{data:l}=await i.limit(1e3);if(l){let i={};l.forEach(e=>{let a=e[t.group_by]||"(empty)";i[a]=(i[a]||0)+1}),o(t=>({...t,[e.id]:Object.keys(i).map(e=>({name:e,value:i[e]}))}))}},[]);(0,l.useEffect)(()=>{d(),ei.supabase.schema("pro").from("sys_dashboard_widget").select("*, sys_report(*)").eq("active",!0).order("position").then(e=>{let{data:t}=e;t&&(s(t),t.forEach(e=>c(e)))});let e=ei.supabase.channel("midnight-dashboard-stats").on("postgres_changes",{event:"*",schema:"pro",table:"task"},()=>d()).subscribe();return()=>{ei.supabase.removeChannel(e)}},[d,c]);let p=async e=>{await ei.supabase.schema("pro").from("sys_dashboard_widget").update({active:!1}).eq("id",e),s(t=>t.filter(t=>t.id!==e))},u=[{label:"Open Incidents",value:e.incidents,color:"#3b82f6",icon:(0,a.jsx)(C.A,{size:18})},{label:"Unassigned Tasks",value:e.unassigned,color:"#ef4444",icon:(0,a.jsx)(N.A,{size:18})},{label:"Changes Scheduled",value:e.changes,color:"#10b981",icon:(0,a.jsx)(A.A,{size:18})},{label:"Critical Alerts",value:e.critical,color:"#f59e0b",icon:(0,a.jsx)(n.A,{size:18})}];return(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{style:{margin:"0 0 24px 0",fontSize:"1.8rem",fontWeight:800},children:"Midnight Command Center"}),(0,a.jsx)("div",{className:"midnight-dashboard-grid",style:{marginBottom:"32px"},children:u.map(e=>(0,a.jsxs)("div",{className:"midnight-widget",style:{position:"relative",overflow:"hidden"},children:[(0,a.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:(0,a.jsxs)("h3",{style:{display:"flex",alignItems:"center",gap:"6px",color:"#94a3b8",fontSize:"12px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",margin:0},children:[(0,a.jsx)("span",{style:{color:e.color},children:e.icon})," ",e.label]})}),(0,a.jsx)("p",{style:{fontSize:"2.5rem",fontWeight:900,color:e.color,margin:0,lineHeight:1},children:e.value}),(0,a.jsx)("div",{style:{position:"absolute",right:"-10px",bottom:"-10px",opacity:.06,fontSize:"80px",color:e.color},children:e.icon})]},e.label))}),i.length>0&&(0,a.jsxs)("div",{style:{marginBottom:"32px"},children:[(0,a.jsxs)("h2",{style:{fontSize:"1.1rem",fontWeight:700,marginBottom:"16
1px",display:"flex",alignItems:"center",gap:"8px"},children:[(0,a.jsx)(I.A,{size:16})," Pinned Reports"]}),(0,a.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(400px, 1fr))",gap:"20px"},children:i.map(e=>{var t,i;let l=r[e.id]||[],s=(null==(t=e.sys_report)?void 0:t.type)||"bar";return(0,a.jsxs)("div",{className:"midnight-widget",style:{minHeight:"280px"},children:[(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},children:[(0,a.jsxs)("h3",{style:{fontWeight:700,fontSize:"14px",display:"flex",alignItems:"center",gap:"6px",margin:0},children:[(0,a.jsx)(z.A,{size:14,style:{color:"#3b82f6"}}),e.title||(null==(i=e.sys_report)?void 0:i.title)||"Report"]}),(0,a.jsx)("button",{onClick:()=>p(e.id),title:"Unpin",style:{background:"none",border:"none",color:"#64748b",cursor:"pointer"},children:(0,a.jsx)(R.A,{size:14})})]}),0===l.length?(0,a.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"200px",color:"#64748b",fontSize:"13px"},children:"No data"}):"single_score"===s?(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"200px"},children:[(0,a.jsx)("div",{style:{fontSize:"60px",fontWeight:900,color:"#3b82f6"},children:l.reduce((e,t)=>e+t.value,0)}),(0,a.jsx)("div",{style:{fontSize:"14px",color:"#64748b"},children:"Total Records"})]}):"pie"===s?(0,a.jsx)(H.u,{width:"100%",height:220,children:(0,a.jsxs)(G.r,{children:[(0,a.jsx)(Y.Fq,{data:l,cx:"50%",cy:"50%",outerRadius:80,dataKey:"value",label:e=>{var t;return"".concat(null!=(t=e.name)?t:""," (").concat(e.value,")")},children:l.map((e,t)=>(0,a.jsx)(K.f,{fill:eI[t%eI.length]},t))}),(0,a.jsx)(V.m,{})]})}):(0,a.jsx)(H.u,{width:"100%",height:220,children:(0,a.jsxs)($.E,{data:l,margin:{top:5,right:10,left:-20,bottom:5},children:[(0,a.jsx)(J.d,{strokeDasharray:"3 3",stroke:"#334155"}),(0,a.jsx)(X.W,{dataKey:"name",tick:{fontSize:11,fill:"#94a3b8"}}),(0,a.jsx)(Z.h,{tick:{fontSize:11,fill:"#94a3b8"}}),(0,a.jsx)(V.m,{contentStyle:{background:"#1e293b",border:"1px solid #334155",borderRadius:"6px",color:"#f1f5f9"}}),(0,a.jsx)(Q.yP,{dataKey:"value",fill:"#3b82f6",radius:[3,3,0,0]})]})})]},e.id)})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{style:{fontSize:"1.1rem",fontWeight:700,marginBottom:"16px"},children:"My Work"}),(0,a.jsx)("div",{style:{background:"var(--midnight-surface)",border:"1px solid var(--midnight-border)",borderRadius:"8px",padding:"40px",textAlign:"center",color:"var(--midnight-text-muted)"},children:(0,a.jsx)("p",{children:"No tasks currently assigned to you."})})]})]})}function eR(e){let{table:t,onNavigate:i}=e,s=el[t],[r,n]=(0,l.useState)([]),[o,d]=(0,l.useState)(!0);return((0,l.useEffect)(()=>{d(!0),ei.supabase.schema("pro").from("task").select("*").eq("sys_class_name",t).order("created_at",{ascending:!1}).limit(200).then(e=>{let{data:i,error:a}=e;a?console.error("Error fetching ".concat(t,":"),a):i&&n(i),d(!1)})},[t]),s)?o?(0,a.jsxs)("div",{style:{padding:"24px",color:"var(--midnight-text-muted)"},children:["Loading ",s.title,"s..."]}):(0,a.jsx)(en,{title:"".concat(s.title,"s"),data:r,columns:s.columns,basePath:"/midnight/task/".concat(t),onNavigate:i}):(0,a.jsxs)("div",{style:{padding:"24px",color:"red"},children:['Error: Table "',t,'" is not defined in SYS_DICTIONARY.']})}function eT(e){let{table:t,id:i,onNavigate:s}=e,r=el[t],n="new"===i,[o,d]=(0,l.useState)(null),[c,p]=(0,l.useState)(!0);(0,l.useEffect)(()=>{if(r){if(n){var e,a,l;d({state:(null==(l=r.fields.find(e=>"state"===e.key))||null==(a=l.options)||null==(e=a[0])?void 0:e.value)||"New",sys_class_name:t}),p(!1);return}p(!0),ei.supabase.schema("pro").from("task").select("*").eq("id",i).single().then(e=>{let{data:i,error:a}=e;a?console.error("Error fetching ".concat(t," record:"),a):i&&d({...i,...i.variables}),p(!1)})}},[n,i,t,r]);let u=async e=>{let i=["id","sys_class_name","number","state","priority","short_description","description","assignment_group","assigned_to","cmdb_ci","caller_id"],a={sys_class_name:t,variables:{}};for(let t in n&&!e.number&&(a.number=r.prefix+Math.floor(1e7*Math.random()).toString().padStart(7,"0")),e)i.includes(t)?a[t]=e[t]:a.variables[t]=e[t];let{error:l}=await ei.supabase.schema("pro").from("task").upsert(a);l?(console.error("Error saving ".concat(t,":"),l),alert("Failed to save ".concat(r.title,": ")+l.message)):s("/midnight/task/".concat(t))};return r?c?(0,a.jsx)("div",{style:{padding:"24px",color:"var(--midnight-text-muted)"},children:"Loading form..."}):(0,a.jsxs)("div",{style:{maxWidth:"1200px",margin:"0 auto"},children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"24px"},children:[(0,a.jsx)("h1",{style:{fontSize:"24px",fontWeight:"bold",margin:0},children:n?"New ".concat(r.title):"".concat(r.title," - ").concat((null==o?void 0:o.number)||i)}),!n&&(0,a.jsx)(ev,{taskId:i})]}),(0,a.jsx)(ec,{title:n?"New ".concat(r.title):r.title,initialData:o,fields:r.fields,onSave:u,basePath:"/midnight/task/".concat(t),onNavigate:s}),!n&&(0,a.jsx)(ey,{taskId:i})]}):(0,a.jsxs)("div",{style:{padding:"24px",color:"red"},children:['Error: Table "',t,'" is not defined in SYS_DICTIONARY.']})}function eD(e){let{table:t,onNavigate:i}=e,s=el[t],r=eN(t),[n,o]=(0,l.useState)([]),[d,c]=(0,l.useState)(!0);return((0,l.useEffect)(()=>{c(!0),ei.supabase.schema("pro").from(r).select("*").eq("sys_class_name",t).order("created_at",{ascending:!1}).then(e=>{let{data:i,error:a}=e;a?console.error("Error fetching ".concat(t,":"),a):i&&o(i),c(!1)})},[t,r]),s)?d?(0,a.jsxs)("div",{style:{padding:"24px",color:"var(--midnight-text-muted)"},children:["Loading ",s.title,"s..."]}):(0,a.jsx)(en,{title:"".concat(s.title,"s"),data:n,columns:s.columns,basePath:"/midnight/cmdb/".concat(t),onNavigate:i}):(0,a.jsxs)("div",{style:{padding:"24px",color:"red"},children:['Error: Table "',t,'" is not defined in SYS_DICTIONARY.']})}function eW(e){let{table:t,id:i,onNavigate:s}=e,r=el[t],n=eN(t),o="new"===i,[d,c]=(0,l.useState)(null),[p,u]=(0,l.useState)(!0);(0,l.useEffect)(()=>
1{if(r){if(o){var e,a,l;c({status:(null==(l=r.fields.find(e=>"status"===e.key))||null==(a=l.options)||null==(e=a[0])?void 0:e.value)||"Installed",sys_class_name:t}),u(!1);return}u(!0),ei.supabase.schema("pro").from(n).select("*").eq("id",i).single().then(e=>{let{data:i,error:a}=e;a?console.error("Error fetching ".concat(t," record:"),a):i&&c({...i,...i.variables||{}}),u(!1)})}},[o,i,t,n,r]);let m=async e=>{let i={sys_class_name:t};if("cmdb_ci"===n){i.variables={};let t=["id","sys_class_name","name","asset_tag","serial_number","mac_address","ip_address","location","status","assigned_to","support_group"];for(let a in e)t.includes(a)?i[a]=e[a]:i.variables[a]=e[a]}else Object.assign(i,e);let{error:a}=await ei.supabase.schema("pro").from(n).upsert(i);a?(console.error("Error saving ".concat(t,":"),a),alert("Failed to save ".concat(r.title,": ")+a.message)):s("/midnight/cmdb/".concat(t))};return r?p?(0,a.jsx)("div",{style:{padding:"24px",color:"var(--midnight-text-muted)"},children:"Loading form..."}):(0,a.jsx)(ec,{title:o?"New ".concat(r.title):r.title,initialData:d,fields:r.fields,onSave:m,basePath:"/midnight/cmdb/".concat(t),onNavigate:s}):(0,a.jsxs)("div",{style:{padding:"24px",color:"red"},children:['Error: Table "',t,'" is not defined in SYS_DICTIONARY.']})}let eE=[{key:"name",label:"Name",isLink:!0},{key:"category",label:"Category"},{key:"price",label:"Price"},{key:"stock_count",label:"Stock"},{key:"is_orderable",label:"Orderable"},{key:"active",label:"Active"}],eU=[{key:"name",label:"Name",fullWidth:!0},{key:"category",label:"Category",type:"select",options:[{label:"Hardware",value:"Hardware"},{label:"Software",value:"Software"},{label:"Access",value:"Access"},{label:"Services",value:"Services"}]},{key:"price",label:"Price ($)",type:"text"},{key:"active",label:"Active",type:"select",options:[{label:"True",value:"true"},{label:"False",value:"false"}]},{key:"short_description",label:"Short Description",fullWidth:!0},{key:"description",label:"Description",type:"textarea",fullWidth:!0}];function eB(e){let{onNavigate:t}=e,[i,s]=(0,l.useState)([]),[r,n]=(0,l.useState)(!0);return((0,l.useEffect)(()=>{ei.supabase.schema("pro").from("sc_cat_item").select("*").order("created_at",{ascending:!1}).limit(200).then(e=>{let{data:t,error:i}=e;i?console.error("Error fetching catalog:",i):t&&s(t),n(!1)})},[]),r)?(0,a.jsx)("div",{style:{padding:"24px",color:"var(--midnight-text-muted)"},children:"Loading Catalog..."}):(0,a.jsx)(en,{title:"Service Catalog Items",data:i,columns:eE,basePath:"/midnight/catalog",onNavigate:t})}function eL(e){let{id:t,onNavigate:i}=e,s="new"===t,[r,n]=(0,l.useState)(null),[o,d]=(0,l.useState)(!0);(0,l.useEffect)(()=>{if(s){n({active:"true",price:"0.00"}),d(!1);return}ei.supabase.schema("pro").from("sc_cat_item").select("*").eq("id",t).single().then(e=>{let{data:t,error:i}=e;i?console.error("Error fetching item:",i):t&&n({...t,active:t.active?"true":"false"}),d(!1)})},[s,t]);let c=async e=>{let t={...e,active:"true"===e.active},{error:a}=await ei.supabase.schema("pro").from("sc_cat_item").upsert(t);a?(console.error("Error saving item:",a),alert("Failed to save catalog item: "+a.message)):i("/midnight/catalog")};return o?(0,a.jsx)("div",{style:{padding:"24px",color:"var(--midnight-text-muted)"},children:"Loading form..."}):(0,a.jsx)(ec,{title:s?"New Catalog Item":"Catalog Item",initialData:r,fields:eU,onSave:c,basePath:"/midnight/catalog",onNavigate:i})}let eP=[{key:"number",label:"Number",isLink:!0},{key:"short_description",label:"Short Description"},{key:"category",label:"Category"},{key:"workflow_state",label:"Workflow"},{key:"view_count",label:"Views"}],eO=[{key:"number",label:"Number",readOnly:!0},{key:"workflow_state",label:"Workflow State",type:"select",options:[{label:"Draft",value:"Draft"},{label:"Review",value:"Review"},{label:"Published",value:"Published"},{label:"Retired",value:"Retired"}]},{key:"category",label:"Category",type:"select",options:[{label:"IT",value:"IT"},{label:"HR",value:"HR"},{label:"Facilities",value:"Facilities"},{label:"General",value:"General"}]},{key:"author",label:"Author (UUID)",type:"text"},{key:"view_count",label:"View Count",readOnly:!0},{key:"short_description",label:"Short Description",fullWidth:!0},{key:"text",label:"Article Text",type:"textarea",fullWidth:!0}];function eq(e){let{onNavigate:t}=e,[i,s]=(0,l.useState)([]),[r,n]=(0,l.useState)(!0),[o,d]=(0,l.useState)(""),[c,p]=(0,l.useState)(!1),u=l.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";n(!0);let t=ei.supabase.schema("pro");if(e){let{data:i,error:a}=await t.rpc("search_kb",{query:e});!a&&i&&s(i)}else{let{data:e,error:i}=await t.from("kb_knowledge").select("*").order("created_at",{ascending:!1}).limit(200);!i&&e&&s(e)}n(!1),p(!1)},[]);return((0,l.useEffect)(()=>{u()},[u]),(0,l.useEffect)(()=>{let e=setTimeout(()=>{p(!0),u(o)},400);return()=>clearTimeout(e)},[o,u]),r)?(0,a.jsx)("div",{style:{padding:"24px",color:"var(--midnight-text-muted)"},children:"Loading Knowledge Base..."}):(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",gap:"12px",background:"var(--midnight-surface)",padding:"12px",borderRadius:"8px",border:"1px solid var(--midnight-border)"},children:[(0,a.jsx)(T.A,{size:18,color:"#94a3b8"}),(0,a.jsx)("input",{type:"text",placeholder:"Search knowledge base (full-text search)...",value:o,onChange:e=>d(e.target.value),style:{flex:1,border:"none",outline:"none",fontSize:"14px",background:"transparent",color:"var(--midnight-text)"}}),c&&(0,a.jsx)("div",{style:{fontSize:"12px",color:"var(--midnight-text-muted)"},children:"Searching..."})]}),(0,a.jsx)(en,{title:o?'Search Results for "'.concat(o,'"'):"Knowledge Base Articles",data:i,columns:eP,basePath:"/midnight/kb",onNavigate:t})]})}function eM(e){let{id:t,onNavigate:i}=e,s="new"===t,[r,n]=(0,l.useState)(null),[o,d]=(0,l.useState)(!0);(0,l.useEffect)(()=>
1{if(s){n({workflow_state:"Draft",view_count:0}),d(!1);return}ei.supabase.schema("pro").from("kb_knowledge").select("*").eq("id",t).single().then(e=>{let{data:t,error:i}=e;i?console.error("Error fetching article:",i):t&&n(t),d(!1)})},[s,t]);let c=async e=>{let t={...e};s&&!t.number&&(t.number="KB"+Math.floor(1e7*Math.random()).toString().padStart(7,"0"));let{error:a}=await ei.supabase.schema("pro").from("kb_knowledge").upsert(t);a?(console.error("Error saving article:",a),alert("Failed to save article: "+a.message)):i("/midnight/kb")};return o?(0,a.jsx)("div",{style:{padding:"24px",color:"var(--midnight-text-muted)"},children:"Loading form..."}):(0,a.jsx)(ec,{title:s?"New Knowledge Article":"Knowledge Article",initialData:r,fields:eO,onSave:c,basePath:"/midnight/kb",onNavigate:i})}let eF=[{key:"user_name",label:"User ID",isLink:!0},{key:"first_name",label:"First Name"},{key:"last_name",label:"Last Name"},{key:"email",label:"Email"},{key:"department",label:"Department"},{key:"active",label:"Active"}],eH=[{key:"user_name",label:"User ID"},{key:"email",label:"Email"},{key:"first_name",label:"First name"},{key:"language",label:"Language",type:"select",options:[{label:"-- None --",value:""},{label:"English",value:"en"}]},{key:"last_name",label:"Last name"},{key:"notification",label:"Notification",type:"select",options:[{label:"Enable",value:"Enable"},{label:"Disable",value:"Disable"}]},{key:"title",label:"Title"},{key:"calendar_integration",label:"Calendar integration",type:"select",options:[{label:"Outlook",value:"Outlook"},{label:"Google",value:"Google"}]},{key:"department",label:"Department"},{key:"time_zone",label:"Time zone",type:"select",options:[{label:"System (America/Los_Angeles)",value:"America/Los_Angeles"},{label:"America/New_York",value:"America/New_York"}]},{key:"password_needs_reset",label:"Password needs reset",type:"select",options:[{label:"False",value:"false"},{label:"True",value:"true"}]},{key:"date_format",label:"Date format",type:"select",options:[{label:"System (yyyy-MM-dd)",value:"yyyy-MM-dd"}]},{key:"locked_out",label:"Locked out",type:"select",options:[{label:"False",value:"false"},{label:"True",value:"true"}]},{key:"business_phone",label:"Business phone"},{key:"active",label:"Active",type:"select",options:[{label:"True",value:"true"},{label:"False",value:"false"}]},{key:"mobile_phone",label:"Mobile phone"}];function eG(e){let{onNavigate:t}=e,[i,s]=(0,l.useState)([]),[r,n]=(0,l.useState)(!0);return((0,l.useEffect)(()=>{ei.supabase.schema("pro").from("sys_user").select("*").order("created_at",{ascending:!1}).limit(200).then(e=>{let{data:t,error:i}=e;i?console.error("Error fetching users:",i):t&&s(t),n(!1)})},[]),r)?(0,a.jsx)("div",{style:{padding:"24px",color:"var(--midnight-text-muted)"},children:"Loading users..."}):(0,a.jsx)(en,{title:"Users",data:i,columns:eF,basePath:"/midnight/users",onNavigate:t})}function eY(e){let{id:t,onNavigate:i}=e,s="new"===t,[r,n]=(0,l.useState)(null),[o,d]=(0,l.useState)(!0);(0,l.useEffect)(()=>{if(s){n({active:"true",notification:"Enable"}),d(!1);return}ei.supabase.schema("pro").from("sys_user").select("*").eq("id",t).single().then(e=>{let{data:t,error:i}=e;i?console.error("Error fetching user:",i):t&&n({...t,active:t.active?"true":"false",locked_out:t.locked_out?"true":"false",password_needs_reset:t.password_needs_reset?"true":"false"}),d(!1)})},[s,t]);let c=async e=>{let t={...e,active:"true"===e.active,locked_out:"true"===e.locked_out,password_needs_reset:"true"===e.password_needs_reset};s&&alert("Note: Inserting a new user requires a valid auth.users UUID to be generated by Supabase Edge Functions first. This might fail if auth.users enforcement is strict.");let{error:a}=await ei.supabase.schema("pro").from("sys_user").upsert(t);a?(console.error("Error saving user:",a),alert("Failed to save user: "+a.message)):i("/midnight/users")};return o?(0,a.jsx)("div",{style:{padding:"24px",color:"var(--midnight-text-muted)"},children:"Loading form..."}):(0,a.jsx)(ec,{title:s?"New User":"User",initialData:r,fields:eH,onSave:c,basePath:"/midnight/users",onNavigate:i})}function eK(e){let{onNavigate:t}=e,[i,s]=(0,l.useState)([]),r=el.sys_report;return((0,l.useEffect)(()=>{ei.supabase.schema("pro").from("sys_report").select("*").order("created_at",{ascending:!1}).limit(200).then(e=>{let{data:t}=e;t&&s(t)})},[]),r)?(0,a.jsx)(en,{title:r.title+"s",data:i,columns:r.columns,basePath:"/midnight/reports",onNavigate:t}):(0,a.jsx)("div",{children:"Dictionary entry missing for sys_report"})}let eV=["#0088FE","#00C49F","#FFBB28","#FF8042","#8884d8","#82ca9d"];function e$(e){let{id:t,onNavigate:i}=e,s="new"===t,[r,n]=(0,l.useState)("New Report"),[o,d]=(0,l.useState)("incident"),[c,p]=(0,l.useState)("bar"),[u,m]=(0,l.useState)("state"),[h,x]=(0,l.useState)({id:"root",logical_operator:"and",conditions:[],type:"group"}),[b,g]=(0,l.useState)([]),[y,f]=(0,l.useState)(!1);(0,l.useEffect)(()=>{s||ei.supabase.schema("pro").from("sys_report").select("*").eq("id",t).single().then(e=>{let{data:t}=e;t&&(n(t.title),d(t.target_table),p(t.type),m(t.group_by||"state"),t.conditions&&Object.keys(t.conditions).length>0&&x(t.conditions))})},[t,s]);let v=async()=>{f(!0);let e=ei.supabase.schema("pro").from("task").select("*").eq("sys_class_name",o),t=es(h);t&&(e=e.or(t));let{data:i,error:a}=await e.limit(1e3);if(i&&!a){let e={};
1i.forEach(t=>{let i=t[u]||"(empty)";e[i]=(e[i]||0)+1}),g(Object.keys(e).map(t=>({name:t,value:e[t]})))}f(!1)},k=async()=>{let e={title:r,target_table:o,type:c,group_by:u,conditions:h};if(s){let{data:t}=await ei.supabase.schema("pro").from("sys_report").insert(e).select().single();t&&i("/midnight/reports/".concat(t.id))}else await ei.supabase.schema("pro").from("sys_report").update(e).eq("id",t),alert("Report saved successfully")},j=async()=>{if(s)return void alert("Please save the report first before pinning it to the dashboard.");let{error:e}=await ei.supabase.schema("pro").from("sys_dashboard_widget").insert({report_id:t,title:r,widget_type:"chart",position:99,active:!0});e?alert("Error pinning: "+e.message):alert("Report pinned to dashboard!")};return(0,a.jsxs)("div",{style:{padding:"0",maxWidth:"1200px",margin:"0 auto"},children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"24px"},children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"16px"},children:[(0,a.jsx)("button",{onClick:()=>i("/midnight/reports"),style:{background:"none",border:"none",color:"var(--midnight-text-muted)",cursor:"pointer",display:"flex"},children:(0,a.jsx)(D.A,{size:24})}),(0,a.jsx)("h1",{style:{fontSize:"24px",fontWeight:"bold",margin:0},children:"Report Designer"})]}),(0,a.jsxs)("div",{style:{display:"flex",gap:"12px"},children:[(0,a.jsxs)("button",{onClick:v,className:"midnight-secondary-btn",style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,a.jsx)(W.A,{size:16})," Run Report"]}),(0,a.jsxs)("button",{onClick:j,style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 16px",background:"#7c3aed",color:"#fff",borderRadius:"4px",fontWeight:600,border:"none",cursor:"pointer"},children:[(0,a.jsx)(I.A,{size:16})," Pin to Dashboard"]}),(0,a.jsxs)("button",{onClick:k,className:"midnight-primary-btn",style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,a.jsx)(E.A,{size:16})," Save"]})]})]}),(0,a.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:"24px"},children:[(0,a.jsxs)("div",{className:"midnight-widget",children:[(0,a.jsx)("h2",{style:{fontSize:"16px",fontWeight:"bold",marginBottom:"16px",borderBottom:"1px solid var(--midnight-border)",paddingBottom:"8px"},children:"Data Configuration"}),(0,a.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,a.jsx)("label",{style:{display:"block",fontSize:"12px",fontWeight:"bold",color:"var(--midnight-text-muted)",marginBottom:"4px"},children:"Report Title"}),(0,a.jsx)("input",{type:"text",value:r,onChange:e=>n(e.target.value),style:{width:"100%",padding:"8px",borderRadius:"4px",border:"1px solid var(--midnight-border)",background:"var(--midnight-bg)",color:"var(--midnight-text)",boxSizing:"border-box"}})]}),(0,a.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,a.jsx)("label",{style:{display:"block",fontSize:"12px",fontWeight:"bold",color:"var(--midnight-text-muted)",marginBottom:"4px"},children:"Target Table"}),(0,a.jsxs)("select",{value:o,onChange:e=>d(e.target.value),style:{width:"100%",padding:"8px",borderRadius:"4px",border:"1px solid var(--midnight-border)",background:"var(--midnight-bg)",color:"var(--midnight-text)"},children:[(0,a.jsx)("option",{value:"incident",children:"Incident"}),(0,a.jsx)("option",{value:"sc_req_item",children:"Requested Item"}),(0,a.jsx)("option",{value:"sc_task",children:"Catalog Task"}),(0,a.jsx)("option",{value:"sys_user",children:"User"}),(0,a.jsx)("option",{value:"alm_asset",children:"Asset"})]})]}),(0,a.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,a.jsx)("label",{style:{display:"block",fontSize:"12px",fontWeight:"bold",color:"var(--midnight-text-muted)",marginBottom:"4px"},children:"Chart Type"}),(0,a.jsxs)("select",{value:c,onChange:e=>p(e.target.value),style:{width:"100%",padding:"8px",borderRadius:"4px",border:"1px solid var(--midnight-border)",background:"var(--midnight-bg)",color:"var(--midnight-text)"},children:[(0,a.jsx)("option",{value:"bar",children:"Bar Chart"}),(0,a.jsx)("option",{value:"pie",children:"Pie Chart"}),(0,a.jsx)("option",{value:"single_score",children:"Single Score"})]})]}
1),(0,a.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,a.jsx)("label",{style:{display:"block",fontSize:"12px",fontWeight:"bold",color:"var(--midnight-text-muted)",marginBottom:"4px"},children:"Group By"}),(0,a.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),placeholder:"e.g. state, priority, category",style:{width:"100%",padding:"8px",borderRadius:"4px",border:"1px solid var(--midnight-border)",background:"var(--midnight-bg)",color:"var(--midnight-text)",boxSizing:"border-box"}})]}),(0,a.jsx)("h2",{style:{fontSize:"16px",fontWeight:"bold",margin:"24px 0 16px",borderBottom:"1px solid var(--midnight-border)",paddingBottom:"8px"},children:"Filter Conditions"}),(0,a.jsx)(eh,{group:h,onChange:x,targetTable:o})]}),(0,a.jsxs)("div",{className:"midnight-widget",style:{minHeight:"500px",display:"flex",flexDirection:"column"},children:[(0,a.jsxs)("h2",{style:{fontSize:"16px",fontWeight:"bold",marginBottom:"16px",borderBottom:"1px solid var(--midnight-border)",paddingBottom:"8px"},children:["Visualization: ",r]}),(0,a.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:y?(0,a.jsx)("div",{style:{color:"var(--midnight-text-muted)"},children:"Running report..."}):0===b.length?(0,a.jsx)("div",{style:{color:"var(--midnight-text-muted)"},children:'Click "Run Report" to generate visualization'}):(0,a.jsxs)("div",{style:{width:"100%",height:"400px"},children:["bar"===c&&(0,a.jsx)(H.u,{width:"100%",height:"100%",children:(0,a.jsxs)($.E,{data:b,margin:{top:20,right:30,left:20,bottom:5},children:[(0,a.jsx)(J.d,{strokeDasharray:"3 3",stroke:"#334155"}),(0,a.jsx)(X.W,{dataKey:"name",tick:{fill:"#94a3b8"}}),(0,a.jsx)(Z.h,{tick:{fill:"#94a3b8"}}),(0,a.jsx)(V.m,{contentStyle:{background:"#1e293b",border:"1px solid #334155",color:"#f1f5f9"}}),(0,a.jsx)(ee.s,{}),(0,a.jsx)(Q.yP,{dataKey:"value",fill:"#3182ce",name:"Count"})]})}),"pie"===c&&(0,a.jsx)(H.u,{width:"100%",height:"100%",children:(0,a.jsxs)(G.r,{children:[(0,a.jsx)(Y.Fq,{data:b,cx:"50%",cy:"50%",labelLine:!1,label:e=>{var t,i;return"".concat(null!=(t=e.name)?t:""," ").concat(((null!=(i=e.percent)?i:0)*100).toFixed(0),"%")},outerRadius:150,fill:"#8884d8",dataKey:"value",children:b.map((e,t)=>(0,a.jsx)(K.f,{fill:eV[t%eV.length]},"cell-".concat(t)))}),(0,a.jsx)(V.m,{}),(0,a.jsx)(ee.s,{})]})}),"single_score"===c&&(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"},children:[(0,a.jsx)("div",{style:{fontSize:"72px",fontWeight:900,color:"#3182ce"},children:b.reduce((e,t)=>e+t.value,0)}),(0,a.jsx)("div",{style:{fontSize:"18px",color:"var(--midnight-text-muted)",marginTop:"8px"},children:"Total Records"})]})]})})]})]})]})}let eJ={org_name:"My Organization",primary_color:"#3b82f6",secondary_color:"#1e293b",accent_color:"#7c3aed",logo_url:"",platform_name:"MIDNIGHT",platform_subtitle:".IO"};function eX(){let[e,t]=(0,l.useState)(eJ),[i,s]=(0,l.useState)(!1),[r,n]=(0,l.useState)(!1);(0,l.useEffect)(()=>{ei.supabase.schema("pro").from("sys_branding").select("*").eq("is_active",!0).single().then(e=>{let{data:i}=e;i&&t(i)})},[]);let o=async()=>{s(!0);let i={org_name:e.org_name,primary_color:e.primary_color,secondary_color:e.secondary_color,accent_color:e.accent_color,logo_url:e.logo_url,platform_name:e.platform_name,platform_subtitle:e.platform_subtitle,is_active:!0};if(e.id)await ei.supabase.schema("pro").from("sys_branding").update(i).eq("id",e.id);else{let{data:e}=await ei.supabase.schema("pro").from("sys_branding").insert(i).select().single();e&&t(t=>({...t,id:e.id}))}let a=document.querySelector(".midnight-container");null==a||a.style.setProperty("--midnight-primary",e.primary_color),null==a||a.style.setProperty("--midnight-bg",e.secondary_color),s(!1),n(!0),setTimeout(()=>n(!1),3e3)},d=function(i,l){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"text";return(0,a.jsxs)("div",{style:{marginBottom:"20px"},children:[(0,a.jsx)("label",{style:{display:"block",fontSize:"12px",fontWeight:700,color:"var(--midnight-text-muted)",marginBottom:"6px",textTransform:"uppercase",letterSpacing:"0.05em"},children:i}),"color"===s?(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,a.jsx)("input",{type:"color",value:e[l],onChange:e=>t(t=>({...t,[l]:e.target.value})),style:{width:"48px",height:"36px",borderRadius:"4px",border:"1px solid var(--midnight-border)",cursor:"pointer"}}),(0,a.jsx)("input",{type:"text",value:e[l],onChange:e=>t(t=>({...t,[l]:e.target.value})),style:{flex:1,padding:"8px 12px",borderRadius:"4px",border:"1px solid var(--midnight-border)",fontFamily:"monospace",background:"var(--midnight-bg)",color:"var(--midnight-text)"}})]}):(0,a.jsx)("input",{type:s,value:e[l],onChange:e=>t(t=>({...t,[l]:e.target.value})),style:{width:"100%",padding:"8px 12px",borderRadius:"4px",border:"1px solid var(--midnight-border)",boxSizing:"border-box",background:"var(--midnight-bg)",color:"var(--midnight-text)"}})]})};return(0,a.jsxs)("div",{style:{maxWidth:"1100px",margin:"0 auto"},children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"28px"},children:[(0,a.jsx)("h1",{style:{fontSize:"24px",fontWeight:800,margin:0},children:"Platform Branding"}),(0,a.jsxs)("button",{onClick:o,disabled:i,style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 20px",background:r?"#38a169":"#3182ce",color:"#fff",borderRadius:"6px",fontWeight:700,border:"none",cursor:"pointer",transition:"background 0.3s"},children:[(0,a.jsx)(E.A,{size:16})," ",r?"Saved!":i?"Saving...":"Save Branding"]})]}),(0,a.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"32px"},children:[(0,a.jsxs)("div",{className:"midnight-widget",children:[(0,a.jsx)("h2",{style:{fontSize:"16px",fontWeight:700,marginBottom:"24px",borderBottom:"1px solid var(--midnight-border)",paddingBottom:"12px"},children:"Organization Settings"}),d("Organization Name","org_name"),d("Platform Name (e.g. MIDNIGHT)","platform_name"),d("Platform Subtitle (e.g. .IO)","platform_subtitle"),d("Logo URL","logo_url","url"),(0,a.jsx)("h2",{style:{fontSize:"16px",fontWeight:700,margin:"28px 0 24px",borderBottom:"1px solid var(--midnight-border)",paddingBottom:"12px"},children:"Color Scheme"}),d("Primary Color (buttons, links, accents)","primary_color","color"),d("Sidebar/Backgroun
1d Color","secondary_color","color"),d("Accent Color (highlights)","accent_color","color")]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"16px"},children:[(0,a.jsx)(U.A,{size:16}),(0,a.jsx)("span",{style:{fontWeight:700,fontSize:"14px",color:"var(--midnight-text-muted)"},children:"Live Preview"})]}),(0,a.jsxs)("div",{style:{borderRadius:"10px",overflow:"hidden",boxShadow:"0 4px 20px rgba(0,0,0,0.3)",marginBottom:"16px"},children:[(0,a.jsxs)("div",{style:{background:e.secondary_color,padding:"16px 20px",display:"flex",alignItems:"center",gap:"12px"},children:[e.logo_url?(0,a.jsx)("img",{src:e.logo_url,alt:"Logo",style:{height:"32px",objectFit:"contain"}}):(0,a.jsx)("div",{style:{width:"32px",height:"32px",borderRadius:"6px",background:e.primary_color,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontWeight:900,fontSize:"14px"},children:e.platform_name.charAt(0)}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{style:{color:"#fff",fontWeight:900,fontSize:"16px"},children:e.platform_name}),(0,a.jsx)("span",{style:{color:e.primary_color,fontWeight:900,fontSize:"16px"},children:e.platform_subtitle})]})]}),(0,a.jsxs)("div",{style:{background:e.secondary_color,padding:"8px 12px"},children:[["Dashboard","Incidents","Problems","Reports"].map(e=>(0,a.jsx)("div",{style:{padding:"8px 12px",borderRadius:"6px",color:"#94a3b8",fontSize:"13px",marginBottom:"2px"},children:e},e)),(0,a.jsx)("div",{style:{padding:"8px 12px",borderRadius:"6px",background:e.primary_color+"22",color:e.primary_color,fontSize:"13px",fontWeight:600,borderLeft:"3px solid ".concat(e.primary_color)},children:"Active Item"})]})]}),(0,a.jsxs)("div",{className:"midnight-widget",children:[(0,a.jsx)("p",{style:{fontSize:"12px",color:"var(--midnight-text-muted)",marginBottom:"12px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"UI Elements"}),(0,a.jsxs)("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:[(0,a.jsx)("button",{style:{padding:"8px 16px",background:e.primary_color,color:"#fff",borderRadius:"6px",border:"none",fontWeight:600},children:"Primary Button"}),(0,a.jsx)("button",{style:{padding:"8px 16px",background:e.accent_color,color:"#fff",borderRadius:"6px",border:"none",fontWeight:600},children:"Accent Button"}),(0,a.jsx)("span",{style:{padding:"4px 12px",background:e.primary_color+"22",color:e.primary_color,borderRadius:"20px",fontSize:"12px",fontWeight:700},children:"Badge"})]})]}),(0,a.jsx)("p",{style:{marginTop:"16px",fontSize:"12px",color:"var(--midnight-text-muted)"},children:"After saving, refresh the page to apply the new color scheme globally across Midnight."})]})]})]})}function eZ(){let[e,t]=(0,l.useState)(""),[i,s]=(0,l.useState)(!1),[n,o]=(0,l.useState)(null),[d,c]=(0,l.useState)([]),p=async()=>{if(!e.trim())return;s(!0),c([]);let t=(e=>{let t=e.trim().split("\n"),i=t[0].split(",").map(e=>e.trim().toLowerCase().replace(/"/g,""));return t.slice(1).map(e=>{let t=e.split(",").map(e=>e.trim().replace(/"/g,""));return Object.fromEntries(i.map((e,i)=>[e,t[i]||""]))})})(e),i={created:0,updated:0,errors:0},a=[],l=Array.from(new Set(t.map(e=>e.class_name||e.sys_class_name||"cmdb_ci_hardware"))),{data:r}=await ei.supabase.schema("pro").from("cmdb_ci").select("id").in("sys_class_name",l).limit(5e3),n=new Set((r||[]).map(e=>e.id));for(let e=0;e<t.length;e++){let l=t[e];try{let t={sys_class_name:l.class_name||l.sys_class_name||"cmdb_ci_hardware",name:l.name||l.ci_name||"",serial_number:l.serial_number||l.serial||"",mac_address:l.mac_address||l.mac||"",asset_tag:l.asset_tag||"",ip_address:l.ip_address||l.ip||"",location:l.location||""},{data:s,error:r}=await ei.supabase.schema("pro").rpc("midnight_ire_process",{payload:t});if(r)throw Error(r.message);let o=n.has(s)?"updated":"created";n.add(s),a.push({row:e+2,name:l.name||"(unnamed)",result:"".concat(o," (").concat(s,")"),status:o}),i[o]++}catch(t){a.push({row:e+2,name:l.name||"(unnamed)",result:t.message,status:"error"}),i.errors++}}o(i),c(a),s(!1)};return(0,a.jsxs)("div",{style:{maxWidth:"1000px",margin:"0 auto"},children:[(0,a.jsxs)("h1",{style:{fontSize:"24px",fontWeight:800,marginBottom:"8px",display:"flex",alignItems:"center",gap:"10px"},children:[(0,a.jsx)(k.A,{size:24})," IRE Bulk CI Import"]}),(0,a.jsx)("p",{style:{color:"var(--midnight-text-muted)",marginBottom:"24px",fontSize:"14px"},children:"Import CIs in bulk. The Identification & Reconciliation Engine (IRE) will automatically detect duplicates using MAC Address â Serial Number â Name priority matching."}),(0,a.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"24px"},children:[(0,a.jsxs)("div",{className:"midnight-widget",children:[(0,a.jsx)("h2",{style:{fontSize:"15px",fontWeight:700,marginBottom:"16
1px"},children:"1. Upload CSV"}),(0,a.jsxs)("div",{style:{marginBottom:"12px"},children:[(0,a.jsx)("label",{style:{display:"block",fontSize:"12px",fontWeight:600,color:"var(--midnight-text-muted)",marginBottom:"6px",textTransform:"uppercase"},children:"Expected Columns"}),(0,a.jsx)("code",{style:{fontSize:"11px",background:"var(--midnight-bg)",padding:"6px 10px",borderRadius:"4px",display:"block",color:"var(--midnight-text-muted)"},children:"name, serial_number, mac_address, class_name, asset_tag, ip_address, location"})]}),(0,a.jsx)("input",{type:"file",accept:".csv",onChange:e=>{var i;let a=null==(i=e.target.files)?void 0:i[0];if(!a)return;let l=new FileReader;l.onload=e=>{var i;return t(null==(i=e.target)?void 0:i.result)},l.readAsText(a)},style:{marginBottom:"12px",fontSize:"13px"}}),(0,a.jsx)("textarea",{value:e,onChange:e=>t(e.target.value),placeholder:'name,serial_number,mac_address,class_name\n"Server-01","SN12345","AA:BB:CC:DD:EE:FF","cmdb_ci_hardware"',rows:8,style:{width:"100%",padding:"8px",border:"1px solid var(--midnight-border)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",resize:"vertical",boxSizing:"border-box",background:"var(--midnight-bg)",color:"var(--midnight-text)"}}),(0,a.jsxs)("button",{onClick:p,disabled:!e.trim()||i,className:"midnight-primary-btn",style:{marginTop:"12px",display:"flex",alignItems:"center",gap:"8px",width:"100%",justifyContent:"center",opacity:!e.trim()||i?.5:1},children:[(0,a.jsx)(W.A,{size:16})," ",i?"Processing...":"Run IRE Import"]})]}),(0,a.jsxs)("div",{className:"midnight-widget",children:[(0,a.jsx)("h2",{style:{fontSize:"15px",fontWeight:700,marginBottom:"16px"},children:"2. Reconciliation Results"}),n&&(0,a.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"10px",marginBottom:"16px"},children:[{label:"Created",value:n.created,color:"#16a34a",bg:"rgba(22,163,74,0.1)"},{label:"Updated",value:n.updated,color:"#d97706",bg:"rgba(217,119,6,0.1)"},{label:"Errors",value:n.errors,color:"#dc2626",bg:"rgba(220,38,38,0.1)"}].map(e=>(0,a.jsxs)("div",{style:{background:e.bg,borderRadius:"6px",padding:"10px",textAlign:"center"},children:[(0,a.jsx)("div",{style:{fontSize:"24px",fontWeight:900,color:e.color},children:e.value}),(0,a.jsx)("div",{style:{fontSize:"11px",color:e.color,fontWeight:600,textTransform:"uppercase"},children:e.label})]},e.label))}),(0,a.jsx)("div",{style:{maxHeight:"280px",overflowY:"auto"},children:0===d.length?(0,a.jsx)("div",{style:{color:"var(--midnight-text-muted)",textAlign:"center",padding:"40px",fontSize:"13px"},children:"Results will appear here after running the import"}):d.map((e,t)=>{var i;return(0,a.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"6px 0",borderBottom:"1px solid var(--midnight-border)",fontSize:"12px"},children:["created"===(i=e.status)?(0,a.jsx)(A.A,{size:14,style:{color:"#16a34a"}}):"updated"===i?(0,a.jsx)(r.A,{size:14,style:{color:"#d97706"}}):(0,a.jsx)(B.A,{size:14,style:{color:"#dc2626"}}),(0,a.jsxs)("div",{style:{flex:1},children:[(0,a.jsxs)("span",{style:{fontWeight:600},children:["Row ",e.row,": "]}),(0,a.jsx)("span",{style:{color:"var(--midnight-text)"},children:e.name}),(0,a.jsx)("div",{style:{color:"var(--midnight-text-muted)",marginTop:"1px"},children:e.result})]})]},t)})})]})]})]})}function eQ(e){let{onNavigate:t}=e,[i,s]=(0,l.useState)([]),[r,n]=(0,l.useState)([]),[o,d]=(0,l.useState)([]);return(0,l.useEffect)(()=>{let e=ei.supabase.schema("pro");e.from("sc_cat_item").select("*").eq("active",!0).limit(4).then(e=>{let{data:t}=e;t&&s(t)}),e.from("kb_knowledge").select("*").eq("workflow_state","Published").limit(4).then(e=>{let{data:t}=e;t&&n(t)}),e.from("task").select("*").in("state",["New","In Progress","Open"]).order("created_at",{ascending:!1}).limit(5).then(e=>{let{data:t}=e;t&&d(t)})},[]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("section",{className:"midnight-portal-hero",children:[(0,a.jsx)("h1",{children:"How can we help?"}),(0,a.jsx)("p",{children:"Search for answers, request services, or check your open tickets."}),(0,a.jsxs)("div",{className:"midnight-portal-search-bar",children:[(0,a.jsx)(T.A,{className:"midnight-portal-search-icon",size:24}),(0,a.jsx)("input",{type:"text",placeholder:"Search the knowledge base or catalog..."})]})]}),(0,a.jsxs)("section",{className:"midnight-portal-content",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"midnight-portal-section-title",children:"Request Something"}),(0,a.jsx)("div",{className:"midnight-portal-categories",style:{marginBottom:"48px"},children:i.map(e=>(0,a.jsxs)("button",{onClick:()=>
1t("/midnight/portal/catalog/".concat(e.id)),className:"midnight-portal-card",children:[(0,a.jsx)("div",{className:"midnight-portal-card-icon",children:(0,a.jsx)(L.A,{size:24})}),(0,a.jsx)("h3",{children:e.name}),(0,a.jsx)("p",{children:e.short_description}),(0,a.jsxs)("div",{style:{marginTop:"auto",fontWeight:600},children:["$",e.price]})]},e.id))}),(0,a.jsx)("h2",{className:"midnight-portal-section-title",children:"Popular Articles"}),(0,a.jsx)("div",{className:"midnight-portal-categories",children:r.map(e=>(0,a.jsxs)("button",{onClick:()=>t("/midnight/portal/kb/".concat(e.id)),className:"midnight-portal-card",children:[(0,a.jsx)("div",{className:"midnight-portal-card-icon",style:{color:"#e67e22",background:"#fdf2e9"},children:(0,a.jsx)(h.A,{size:24})}),(0,a.jsx)("h3",{children:e.short_description}),(0,a.jsxs)("p",{children:["Knowledge Base ⢠",e.published_date?new Date(e.published_date).toLocaleDateString():"Unpublished"]})]},e.id))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"midnight-portal-section-title",children:"My Tickets"}),(0,a.jsx)("div",{className:"midnight-portal-tickets",children:0===o.length?(0,a.jsx)("p",{style:{color:"#86868b",fontSize:"14px"},children:"You have no open tickets."}):o.map(e=>{var t;return(0,a.jsxs)("div",{className:"midnight-portal-ticket-item",children:[(0,a.jsxs)("div",{className:"midnight-portal-ticket-info",children:[(0,a.jsxs)("h4",{children:[e.number," - ",e.sys_class_name]}),(0,a.jsx)("p",{children:e.short_description})]}),(0,a.jsx)("div",{className:"midnight-portal-ticket-status midnight-portal-status-".concat((null==(t=e.state)?void 0:t.toLowerCase().replace(" ","-"))||"new"),children:e.state||"New"})]},e.id)})})]})]})]})}function e0(e){let{id:t,onNavigate:i}=e,[s,r]=(0,l.useState)(null),[n,o]=(0,l.useState)(!0),[d,c]=(0,l.useState)(""),[p,u]=(0,l.useState)(!1),[m,h]=(0,l.useState)(!1);(0,l.useEffect)(()=>{ei.supabase.schema("pro").from("sc_cat_item").select("*").eq("id",t).single().then(e=>{let{data:t}=e;t&&r(t),o(!1)})},[t]);let x=async e=>{e.preventDefault(),u(!0);let{error:t}=await ei.supabase.schema("pro").from("task").insert({sys_class_name:"sc_req_item",short_description:"Request for: ".concat(s.name),description:"User Justification:\n".concat(d),state:"New",priority:3,variables:{catalog_item_id:s.id}});u(!1),t?alert("Error submitting request."):(h(!0),setTimeout(()=>i("/midnight/portal"),3e3))};return n?(0,a.jsx)("div",{className:"midnight-portal-content",children:"Loading..."}):s?m?(0,a.jsxs)("div",{className:"midnight-portal-content",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"50vh"},children:[(0,a.jsx)(A.A,{size:64,color:"#2e7d32",style:{marginBottom:"24px"}}),(0,a.jsx)("h1",{style:{fontSize:"32px",marginBottom:"16px"},children:"Request Submitted"}),(0,a.jsxs)("p",{style:{color:"#86868b"},children:["Your request for ",(0,a.jsx)("strong",{children:s.name})," has been routed to the fulfillment team."]}),(0,a.jsx)("p",{style:{color:"#86868b",fontSize:"14px"},children:"Redirecting to home..."})]}):(0,a.jsxs)("div",{className:"midnight-portal-content",style:{display:"block",maxWidth:"800px"},children:[(0,a.jsxs)("button",{onClick:()=>i("/midnight/portal"),className:"midnight-portal-back-link",children:[(0,a.jsx)(D.A,{size:16})," Back to Portal"]}),(0,a.jsxs)("div",{className:"midnight-portal-article",children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"24px",marginBottom:"32px"},children:[(0,a.jsx)("div",{className:"midnight-portal-card-icon",style:{width:"80px",height:"80px",borderRadius:"20px"},children:(0,a.jsx)(L.A,{size:40})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{children:s.name}),(0,a.jsx)("p",{style:{fontSize:"20px",color:"#86868b",margin:0},children:s.short_description})]})]}),(0,a.jsxs)("div",{className:"midnight-portal-meta",style:{justifyContent:"space-between",alignItems:"center"}
1,children:[(0,a.jsxs)("span",{children:["Price: ",(0,a.jsxs)("strong",{style:{color:"#1d1d1f",fontSize:"24px"},children:["$",s.price]})]}),(0,a.jsxs)("div",{style:{display:"flex",gap:"16px",alignItems:"center"},children:[(0,a.jsxs)("span",{children:["Category: ",s.category]}),s.stock_count>0&&(0,a.jsxs)("span",{style:{background:"#f0fdf4",color:"#16a34a",padding:"4px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:600},children:[s.stock_count," in stock"]}),(!s.is_orderable||0===s.stock_count)&&(0,a.jsx)("span",{style:{background:"#fef2f2",color:"#dc2626",padding:"4px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:600},children:"Out of Stock"})]})]}),(0,a.jsxs)("div",{className:"midnight-portal-body",children:[(0,a.jsx)("h3",{children:"Description"}),(0,a.jsx)("p",{children:s.description||"No detailed description provided."})]}),(0,a.jsxs)("form",{className:"midnight-portal-checkout-form",onSubmit:x,children:[(0,a.jsxs)("div",{className:"midnight-portal-form-group",children:[(0,a.jsx)("label",{htmlFor:"justification",children:"Business Justification *"}),(0,a.jsx)("textarea",{id:"justification",rows:4,required:!0,value:d,onChange:e=>c(e.target.value),placeholder:"Why do you need this item? This will be sent to your manager for approval."})]}),(0,a.jsx)("button",{type:"submit",className:"midnight-portal-btn-primary",disabled:p||!s.is_orderable||0===s.stock_count,style:s.is_orderable&&0!==s.stock_count?{}:{opacity:.5,cursor:"not-allowed"},children:p?"Submitting...":s.is_orderable&&0!==s.stock_count?"Order Now - $".concat(s.price):"Currently Unavailable"})]})]})]}):(0,a.jsx)("div",{className:"midnight-portal-content",children:"Item not found."})}function e1(e){var t;let{id:i,onNavigate:s}=e,[r,n]=(0,l.useState)(null),[o,d]=(0,l.useState)(!0);return((0,l.useEffect)(()=>{ei.supabase.schema("pro").from("kb_knowledge").select("*").eq("id",i).single().then(e=>{let{data:t}=e;t&&n(t),d(!1)})},[i]),o)?(0,a.jsx)("div",{className:"midnight-portal-content",children:"Loading..."}):r?(0,a.jsxs)("div",{className:"midnight-portal-content",style:{display:"block",maxWidth:"800px"},children:[(0,a.jsxs)("button",{onClick:()=>s("/midnight/portal"),className:"midnight-portal-back-link",children:[(0,a.jsx)(D.A,{size:16})," Back to Portal"]}),(0,a.jsxs)("article",{className:"midnight-portal-article",children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px",color:"#0066cc",fontWeight:600},children:[(0,a.jsx)(h.A,{size:20}),(0,a.jsx)("span",{children:r.category||"General Knowledge"})]}),(0,a.jsx)("h1",{children:r.short_description}),(0,a.jsxs)("div",{className:"midnight-portal-meta",children:[(0,a.jsxs)("span",{children:["Article Number: ",(0,a.jsx)("strong",{children:r.number})]}),(0,a.jsxs)("span",{children:["Published: ",(0,a.jsx)("strong",{children:r.published_date?new Date(r.published_date).toLocaleDateString():"Unpublished"})]}),(0,a.jsxs)("span",{children:["Views: ",(0,a.jsx)("strong",{children:null!=(t=r.view_count)?t:0})]})]}),(0,a.jsx)(eC.SafeHtml,{className:"midnight-portal-body",html:r.text||"<p>No content provided.</p>"}),(0,a.jsxs)("div",{style:{marginTop:"64px",paddingTop:"32px",borderTop:"1px solid #f5f5f7",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,a.jsx)("span",{style:{fontWeight:500},children:"Was this article helpful?"}),(0,a.jsxs)("div",{style:{display:"flex",gap:"16px"},children:[(0,a.jsxs)("button",{className:"midnight-portal-feedback-btn",children:[(0,a.jsx)(P.A,{size:16})," Yes"]}),(0,a.jsxs)("button",{className:"midnight-portal-feedback-btn",children:[(0,a.jsx)(O.A,{size:16})," No"]})]})]})]})]}):(0,a.jsx)("div",{className:"midnight-portal-content",children:"Article not found."})}function e2(e){let{route:t,onNavigate:i,onExit:l}=e;return(0,a.jsxs)("div",{className:"midnight-portal-container",children:[(0,a.jsxs)("header",{className:"midnight-portal-header",children:[(0,a.jsxs)("button",{onClick:()=>i("/midnight/portal"),className:"midnight-portal-logo",children:[(0,a.jsx)(q.A,{size:24,color:"#0066cc"})," Employee Center"]}),(0,a.jsxs)("nav",{className:"midnight-portal-nav",children:[(0,a.jsx)("button",{onClick:()=>i("/midnight/portal"),children:"Home"}),(0,a.jsx)("button",{onClick:()=>i("/midnight/portal"),children:"Requests"}),(0,a.jsx)("button",{onClick:()=>i("/midnight/task/sysapproval_approver"),children:"My Approvals"}),(0,a.jsx)("button",{onClick:()=>i("/midnight/portal"),children:"Knowledge"}),(0,a.jsx)("button",{onClick:()=>i("/midnight/task/incident"),style:{color:"#0066cc",fontWeight:500}
1,children:"Agent Workspace"}),(0,a.jsx)("button",{onClick:l,children:"Exit"})]})]}),(0,a.jsxs)("main",{children:[!t.sub&&(0,a.jsx)(eQ,{onNavigate:i}),"catalog"===t.sub&&t.id&&(0,a.jsx)(e0,{id:t.id,onNavigate:i}),"kb"===t.sub&&t.id&&(0,a.jsx)(e1,{id:t.id,onNavigate:i})]})]})}let e4=()=>{var e;let{setEnv:t}=(0,et.n)(),{midnightUser:i}=ea(),[s,r]=(0,l.useState)("/midnight"),n=function(e){let t=e.replace(/^\/midnight\/?/,"").split("/").filter(Boolean);return 0===t.length?{view:"dashboard"}:"task"===t[0]&&t[1]?{view:"task",table:t[1],id:t[2]}:"cmdb"===t[0]&&t[1]?{view:"cmdb",table:t[1],id:t[2]}:"catalog"===t[0]?{view:"catalog",id:t[1]}:"kb"===t[0]?{view:"kb",id:t[1]}:"users"===t[0]?{view:"users",id:t[1]}:"reports"===t[0]?{view:"reports",id:t[1]}:"branding"===t[0]?{view:"branding"}:"ire"===t[0]?{view:"ire"}:"portal"===t[0]?"catalog"===t[1]&&t[2]?{view:"portal",sub:"catalog",id:t[2]}:"kb"===t[1]&&t[2]?{view:"portal",sub:"kb",id:t[2]}:{view:"portal"}:{view:"placeholder",label:t[0]}}(s),o=e=>r(e);return"portal"===n.view?(0,a.jsx)(e2,{route:n,onNavigate:o,onExit:()=>t("home")}):(0,a.jsxs)("div",{className:"midnight-container",children:[(0,a.jsxs)("aside",{className:"midnight-sidebar",children:[(0,a.jsx)("div",{className:"midnight-sidebar-header",children:(0,a.jsxs)("div",{className:"midnight-logo-text",children:[(0,a.jsx)("span",{style:{color:"#fff",fontWeight:900},children:"MIDNIGHT"}),(0,a.jsx)("span",{style:{color:"#3b82f6"},children:".IO"})]})}),(0,a.jsx)("nav",{className:"midnight-sidebar-nav",children:eA.map((e,t)=>(0,a.jsxs)(l.Fragment,{children:[e.category&&(0,a.jsx)("div",{className:"midnight-nav-category",children:e.category}),e.items.map(e=>(0,a.jsxs)("button",{className:"midnight-nav-item ".concat(s.includes(e.match)&&"/midnight"!==e.match||s===e.href?"active":""),onClick:()=>o(e.href),children:[e.icon,(0,a.jsx)("span",{children:e.label})]},e.href))]},t))})]}),(0,a.jsxs)("main",{className:"midnight-main",children:[(0,a.jsxs)("header",{className:"midnight-topbar",children:[(0,a.jsx)(ew,{onNavigate:o}),(0,a.jsxs)("div",{className:"midnight-topbar-actions",children:[(0,a.jsx)(e_,{onNavigate:o}),(0,a.jsxs)("div",{className:"midnight-user-profile",children:[(0,a.jsx)("div",{className:"midnight-avatar",children:i?null==(e=i.first_name)?void 0:e.charAt(0).toUpperCase():"A"}),(0,a.jsx)("span",{children:i?"".concat(i.first_name," ").concat(i.last_name):"Admin"})]}),(0,a.jsxs)("button",{className:"midnight-exit-btn",onClick:()=>t("home"),children:[(0,a.jsx)(M.A,{size:18})," Exit"]})]})]}),(0,a.jsxs)("div",{className:"midnight-content",children:["dashboard"===n.view&&(0,a.jsx)(ez,{}),"task"===n.view&&!n.id&&(0,a.jsx)(eR,{table:n.table,onNavigate:o}),"task"===n.view&&n.id&&(0,a.jsx)(eT,{table:n.table,id:n.id,onNavigate:o}),"cmdb"===n.view&&!n.id&&(0,a.jsx)(eD,{table:n.table,onNavigate:o}),"cmdb"===n.view&&n.id&&(0,a.jsx)(eW,{table:n.table,id:n.id,onNavigate:o}),"catalog"===n.view&&!n.id&&(0,a.jsx)(eB,{onNavigate:o}),"catalog"===n.view&&n.id&&(0,a.jsx)(eL,{id:n.id,onNavigate:o}),"kb"===n.view&&!n.id&&(0,a.jsx)(eq,{onNavigate:o}),"kb"===n.view&&n.id&&(0,a.jsx)(eM,{id:n.id,onNavigate:o}),"users"===n.view&&!n.id&&(0,a.jsx)(eG,{onNavigate:o}),"users"===n.view&&n.id&&(0,a.jsx)(eY,{id:n.id,onNavigate:o}),"reports"===n.view&&!n.id&&(0,a.jsx)(eK,{onNavigate:o}),"reports"===n.view&&n.id&&(0,a.jsx)(e$,{id:n.id,onNavigate:o}),"branding"===n.view&&(0,a.jsx)(eX,{}),"ire"===n.view&&(0,a.jsx)(eZ,{}),"placeholder"===n.view&&(0,a.jsxs)("div",{style:{padding:"60px 24px",textAlign:"center",color:"var(--midnight-text-muted)"},children:[(0,a.jsx)(F.A,{size:32,style:{marginBottom:16,opacity:.5}}),(0,a.jsx)("h2",{style:{color:"var(--midnight-text)",marginBottom:8},children:n.label}),(0,a.jsx)("p",{children:"This module is coming in the next pass of the 8wivx â xjdn2 port."})]})]})]})]})}},35743:()=>{},95832:(e,t,i)=>{"use strict";i.d(t,{p:()=>o});let a=new Set(["a","b","strong","i","em","u","s","strike","del","mark","sub","sup","small","p","br","hr","div","span","blockquote","pre","code","h1","h2","h3","h4","h5","h6","ul","ol","li","table","thead","tbody","tfoot","tr","th","td","caption","img","figure","figcaption"]),l=new Set(["script","style","iframe","object","embed","noscript","template","svg","math","form","input","button","textarea","select","link","meta","base","frame","frameset"]),s={a:new Set(["href","title"]),img:new Set(["src","alt","title","width","height"]),td:new Set(["colspan","rowspan"]),th:new Set(["colspan","rowspan"]),"*":new Set(["style"])},r=/^(https?:|mailto:|tel:|\/(?!\/)|#)/i,n=/^(https:|data:image\/(png|jpe?g|gif|webp);base64,)/i,o=e=>{if(!e||"undefined"==typeof DOMParser)return"";let t=new DOMParser().parseFromString("<!doctype html><body>".concat(e),"text/html"),i=document.implementation.createHTMLDocument(""),o=i.createElement("div"),d=(e,t)=>{if(e.nodeType===Node.TEXT_NODE)return void t.appendChild(i.createTextNode(e.textContent||""));if(e.nodeType!==Node.ELEMENT_NODE)return;let o=e.tagName.toLowerCase();if(l.has(o))return;
1if(!a.has(o))return void e.childNodes.forEach(e=>d(e,t));let c=i.createElement(o),p=new Set([...s[o]||[],...s["*"]]);Array.from(e.attributes).forEach(e=>{let t=e.name.toLowerCase(),i=e.value.trim();if(p.has(t)&&("href"!==t||r.test(i.replace(/\s/g,"")))&&("src"!==t||n.test(i.replace(/\s/g,"")))){if("style"===t){let e=i.split(";").map(e=>e.trim()).filter(e=>e&&!/(url\s*\(|expression\s*\(|javascript:|behavior\s*:|-moz-binding|@import|position\s*:\s*(fixed|sticky))/i.test(e)).join("; ");e&&c.setAttribute("style",e);return}c.setAttribute(t,i)}}),"a"===o&&(c.setAttribute("target","_blank"),c.setAttribute("rel","noopener noreferrer nofollow")),e.childNodes.forEach(e=>d(e,c)),t.appendChild(c)};return t.body.childNodes.forEach(e=>d(e,o)),o.innerHTML}}}]);
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.