1"use strict";(self.webpackChunk_fleetdm_fleet=self.webpackChunk_fleetdm_fleet||[]).push([[365],{512:function(e,t,a){var l=a(96540),n=a(32485),i=a.n(n),o=a(52978),r=a(52603);const s="status-indicator-with-icon",c={success:"success",successPartial:"success-outline",pending:"pending",pendingPartial:"pending-outline",error:"error",failure:"error-outline",actionRequired:"error"};t.A=({status:e,value:t,tooltip:a,layout:n="horizontal",className:u,valueClassName:d})=>{const m=i()(s,u),p=i()(`${s}__value`,d,{[`${s}__value-vertical`]:"vertical"===n}),y=l.createElement("span",{className:p},l.createElement(o.A,{name:c[e],color:"failure"===e?"ui-fleet-black-50":void 0}),l.createElement("span",null,t)),f=a?l.createElement(r.A,{className:`${s}__tooltip`,tooltipClass:"indicator-tip-text",position:"top",tipContent:a.tooltipText,tipOffset:10,showArrow:!0,underline:!1,fixedPositionStrategy:!0},y):l.createElement("span",null,y);return l.createElement("div",{className:m},f)}},59555:function(e,t,a){a.d(t,{A:function(){return l.A}});var l=a(512)},51248:function(e,t){t.A={pass:["success","Pass"],fail:["failure","Fail"],actionRequired:["actionRequired","Action required"]}},77906:function(e,t,a){a.d(t,{Wf:function(){return n},Xh:function(){return i},fx:function(){return l}});const l=30,n=e=>{const t=null==e?void 0:e.conditional_access;return!!((null==t?void 0:t.okta_idp_id)&&(null==t?void 0:t.okta_assertion_consumer_service_url)&&(null==t?void 0:t.okta_audience_uri)&&(null==t?void 0:t.okta_certificate))},i=e=>n(e)||(e=>{var t,a;return null!=(a=null==(t=null==e?void 0:e.conditional_access)?void 0:t.microsoft_entra_connection_configured)&&a})(e)},66081:function(e,t,a){a.d(t,{dw:function(){return c},Yw:function(){return u},kl:function(){return s}});var l=a(96540),n=a(5410),i=a(48862),o=a(38021);const r="software-deploy-selector",s=e=>({patch_when_closed:"closed"===e,continuous_automations_enabled:"closed"===e}),c=({patchOption:e,onSelectPatchOption:t,disabled:a=!1,showPatchWhenClosedNotice:n=!1})=>{const s=e=>t(e);return l.createElement(l.Fragment,null,l.createElement("div",{className:`${r}__patch-options`,role:"radiogroup","aria-label":"Patch options"},l.createElement(i.A,{id:"patch-when-closed",name:"patch-option",value:"closed",label:"Patch when app is closed",checked:"closed"===e,onChange:s,disabled:a}),l.createElement(i.A,{id:"force-patch",name:"patch-option",value:"force",label:"Force patch",checked:"force"===e,onChange:s,disabled:a}),l.createElement(i.A,{id:"manual-patch",name:"patch-option",value:"manual",label:"End user initiated (manual)",checked:"manual"===e,onChange:s,disabled:a}),"force"===e&&l.createElement(o.A,{icon:"error-outline",iconColor:"ui-fleet-black-50"},"End user is not notified. Patch is forced as soon as policy fails. Notifications are coming soon.")),"closed"===e&&n&&l.createElement("p",{className:`${r}__patch-when-closed-notice`},l.createElement("b",null,"Patch when app is closed")," overrides the pre-install query (advanced option) to check if the app is closed."))};var u=({forceInstall:e,patch:t,patchOption:a,onToggleForceInstall:i,onTogglePatch:o,onSelectPatchOption:s,disabled:u=!1,showPatchWhenClosedNotice:d=!1,hideLabel:m=!1})=>l.createElement("div",{className:`form-field ${r}`},!m&&l.createElement("div",{className:"form-field__label"},"Deploy"),l.createElement("div",{className:`${r}__checkboxes`},l.createElement(n.A,{name:"force-install",value:e,onChange:i,disabled:u},"Force install"),l.createElement(n.A,{name:"patch",value:t,onChange:o,disabled:u},"Patch")),t&&l.createElement(c,{patchOption:a,onSelectPatchOption:s,disabled:u,showPatchWhenClosedNotice:d}))},13930:function(e,t,a){a.r(t),a.d(t,{default:function(){return Ut}});var l=a(96540),n=a(75942),i=a(78263),o=a(2543),r=a(9467),s=a(68774),c=a(59593),u=a(69807),d=a(46157),m=a(38944),p=a(62131),y=a(43015),f=a(98544),h=a(39414),_=a(80396),v=a(19677),E=a(46692),b=a(74953),g=a(85396),A=a(41995),w=a(45584),S=a(82196),C=a(79519),k=a(827),N=a(29448),T=a(431),P=a(52603),O=a(41820),L=a(34724),I=a(2367),x=a(2940);var D=a(32485),M=a.n(D),R=a(5410),$=a(40925),F=a(42690),q=a(61172),Q=a(16240),W=a(52978),H=a(20881),j=a(69906),B=a(12968),U=a(81302),z=a(89937),G=a(63840),Y=a(42619),K=a(77823),V=a(59227),X=a(59333),J=a(30104),Z=a(51248),ee=a(59555),te=({isPassing:e})=>{const[t,a]=Z.A[e?"pass":"fail"];return l.createElement(ee.A,{value:a,status:t})},ae=Object.defineProperty,le=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable,oe=(e,t,a)=>t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,re=(e,t)=>
1{for(var a in t||(t={}))ne.call(t,a)&&oe(e,a,t[a]);if(le)for(var a of le(t))ie.call(t,a)&&oe(e,a,t[a]);return e};const se={software:({name:e,iconName:t,iconUrl:a})=>l.createElement("span",{className:"automations__software-icon"},l.createElement(j.A,{name:null!=t?t:e,url:a,size:"small"})),script:({name:e})=>l.createElement(H.A,{name:e.endsWith(".sh")?"file-sh":"file-ps1",className:"scale-40-24"}),profile:()=>l.createElement(H.A,{name:"file-configuration-profile",className:"scale-40-24"}),calendar:()=>l.createElement(H.A,{name:"calendar"}),conditional_access:()=>l.createElement(H.A,{name:"lock"}),other:()=>l.createElement(W.A,{name:"settings"})},ce=({ariaLabel:e,onEdit:t,className:a,children:n})=>l.createElement("div",{role:"button",tabIndex:0,className:M()("automations__cell-content",a),onClick:t,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),t())},"aria-label":e},n,l.createElement("span",{className:"automations__edit-button","aria-hidden":"true"},l.createElement(W.A,{name:"pencil"}))),ue=({policy:e,otherAutomationType:t,onOpenManageAutomationsModal:a})=>{const n=((e,t)=>{const a=[];return e.install_software&&a.push({type:"software",name:(0,J.Yd)(e.install_software.name,e.install_software.display_name),iconName:e.install_software.name,softwareTitleId:e.install_software.software_title_id,iconUrl:e.install_software.icon_url}),e.run_script&&a.push({type:"script",name:e.run_script.name}),e.resend_configuration_profile&&a.push({type:"profile",name:e.resend_configuration_profile.name}),e.calendar_events_enabled&&a.push({type:"calendar",name:"Maintenance window"}),e.conditional_access_enabled&&a.push({type:"conditional_access",name:"Conditional access"}),"On"===e.webhook&&a.push({type:"other",name:"ticket"===t?"Ticket":"Webhook"}),a})(e,t),i=!!a,o=e=>{var t;return se[e.type]({name:e.name,iconName:"software"===e.type?e.iconName:void 0,iconUrl:null!=(t=e.iconUrl)?t:void 0})},r=0===n.length;let s,c;if(r)s="Add automation",c=l.createElement("span",{className:"automations__name"},z.r2);else if(1===n.length){const e=n[0];s=`Edit automation: ${e.name}`,c=l.createElement(Q.A,{prefix:o(e),value:e.name,className:"automations__name"})}else s="Edit automations",c=l.createElement(P.A,{className:"automations__count",position:"top",underline:!1,fixedPositionStrategy:!0,tipOffset:8,tipContent:n.map(({name:e})=>e).join(", "),showArrow:!0},n.length," automations");return i?l.createElement(ce,{ariaLabel:s,onEdit:()=>null==a?void 0:a(e),className:M()({"automations__cell-content--none":r})},c):l.createElement("span",{className:M()("automations__cell-content","automations__cell-content--readonly",{"automations__cell-content--none":r})},c)},de=e=>l.createElement(l.Fragment,null,"Fleet is collecting policy results. Try again",l.createElement("br",null),"in about ",(e=>{const t=e/1e3;if(t<60)return`${t} seconds`;if(t<3600){const t=function(e){const t=e/x.Cg;return Math.trunc(t)}(e);return`${t} minute${t>1?"s":""}`}const a=function(e){const t=e/x.s0;return Math.trunc(t)}(e);return`${a} hour${a>1?"s":""}`})(e)," as the system catches up."),me=(e,t,a)=>{const{selectedTeamId:n,hasPermissionAndPoliciesToDelete:o,otherAutomationType:r,onOpenManageAutomationsModal:s}=e,c=-1!==n,u=[{title:"Name",Header:e=>l.createElement($.A,{value:e.column.title,isSortedDesc:e.column.isSortedDesc}),accessor:"name",Cell:e=>{const{critical:a,id:o,team_id:r,type:s}=e.row.original;return l.createElement(F.A,{className:"w250",tooltipTruncate:!0,value:e.cell.value,suffix:l.createElement(l.Fragment,null,t&&a&&l.createElement(G.A,null),"patch"===s&&l.createElement(Y.A,{tooltip:K.N,size:"small"},"Patch"),c&&null===r&&l.createElement(Y.A,{tooltip:"This policy runs on all hosts.",size:"small"},"Inherited")),path:(0,B.M8)(i.A.POLICY_DETAILS(o),{fleet_id:null!=r?r:-1!==n?n:null})})},sortType:"caseInsensitive"},{title:"Targeted platforms",Header:"Targeted platforms",disableSortBy:!0,accessor:"platform",Cell:e=>{const t=e.cell.value.split(",").map(e=>e.trim()).filter(y.ek);return l.createElement(q.A,{platforms:t})}},{title:"Automations",Header:"Automations",accessor:"automations",disableSortBy:!0,Cell:e=>l.createElement(ue,{policy:e.row.original,otherAutomationType:r,onOpenM
1anageAutomationsModal:s})},{title:"Pass",Header:e=>l.createElement($.A,{value:l.createElement(te,{isPassing:!0}),isSortedDesc:e.column.isSortedDesc}),accessor:"passing_host_count",Cell:e=>{const{has_run:t,id:a,next_update_ms:o}=e.row.original;return t?l.createElement(F.A,{value:`${e.cell.value} host${"1"===e.cell.value.toString()?"":"s"}`,path:(0,B.M8)(i.A.MANAGE_HOSTS,{policy_id:a,policy_response:z.iI.PASSING,fleet_id:n})}):l.createElement("div",{className:"policy-has-not-run"},l.createElement(P.A,{tooltipClass:"policy-has-not-run-tooltip",position:"top",underline:!1,fixedPositionStrategy:!0,tipOffset:8,tipContent:de(o)},"---"))}},{title:"Fail",Header:e=>l.createElement($.A,{value:l.createElement(te,{isPassing:!1}),isSortedDesc:e.column.isSortedDesc}),accessor:"failing_host_count",Cell:e=>{const{has_run:t,id:a,next_update_ms:o}=e.row.original;return t?l.createElement(F.A,{value:`${e.cell.value} host${"1"===e.cell.value.toString()?"":"s"}`,path:(0,B.M8)(i.A.MANAGE_HOSTS,{policy_id:a,policy_response:z.iI.FAILING,fleet_id:n})}):l.createElement("div",{className:"policy-has-not-run"},l.createElement(P.A,{tooltipClass:"policy-has-not-run-tooltip",position:"top",underline:!1,fixedPositionStrategy:!0,tipOffset:8,tipContent:de(o)},"---"))},sortType:"caseInsensitive"}];return o&&u.unshift({id:"selection",Header:e=>{const t=(0,V.V)({headerProps:e,checkIfRowIsSelectable:e=>a||null!==e.original.team_id}),{getToggleAllRowsSelectedProps:n,toggleAllRowsSelected:i}=e,{checked:o,indeterminate:r}=n(),s=c?t:{value:o,indeterminate:r,onChange:()=>{i()}};return l.createElement(X.A,{position:"right",tipOffset:8,fixedPositionStrategy:!0,renderChildren:e=>l.createElement(R.A,re({disabled:e,enableEnterToCheck:!0},s))})},Cell:e=>{const t=null===e.row.original.team_id,n={value:e.row.getToggleRowSelectedProps().checked,onChange:()=>e.row.toggleRowSelected()};return c&&t&&!a?l.createElement(l.Fragment,null):l.createElement(X.A,{position:"right",tipOffset:8,fixedPositionStrategy:!0,renderChildren:e=>l.createElement(R.A,re({disabled:e,enableEnterToCheck:!0},n))})},disableHidden:!0}),u},pe=(e=[],t,a)=>{var l;let n;e=e.sort((e,t)=>U.A.caseInsensitiveAsc(e.name,t.name));let i=0;const o=(null==(l=e.find(e=>!!e.host_count_updated_at))?void 0:l.host_count_updated_at)||"",r=36e5,s=o?new Date(o):new Date(Date.now()-r);a?(i=a/1e6,n=new Date(s.getTime()-i)):n=s;const c=r-(o?(Date.now()-s.getTime())%r:0);return e.forEach(e=>{e.webhook=t&&t.includes(e.id)?"On":"Off";const a=new Date(e.updated_at);e.has_run=!!e.host_count_updated_at,e.has_run||(e.next_update_ms=((e,t,a,l)=>{let n=Date.now()-e.getTime()+t,i=0;for(;n<=l;)i+=a,n+=a;return t+i})(a,c,r,i))}),e};var ye=Object.defineProperty,fe=Object.defineProperties,he=Object.getOwnPropertyDescriptors,_e=Object.getOwnPropertySymbols,ve=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,be=(e,t,a)=>t in e?ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,ge=(e,t)=>{for(var a in t||(t={}))ve.call(t,a)&&be(e,a,t[a]);if(_e)for(var a of _e(t))Ee.call(t,a)&&be(e,a,t[a]);return e};const Ae=(e,t,a)=>e<=t*(a+1),we="policies-table",Se=[{disabled:!1,label:"All platforms",value:"all"},{disabled:!1,label:"macOS",value:"darwin"},{disabled:!1,label:"Windows",value:"windows"},{disabled:!1,label:"Linux",value:"linux"},{disabled:!1,label:"ChromeOS",value:"chrome"}];var Ce=({policiesList:e,isLoading:t,onDeletePoliciesClick:a,onAddPolicyClick:n,canAddOrDeletePolicies:o,hasPoliciesToDelete:c,currentTeam:u,currentAutomatedPolicies:d,isPremiumTier:m,onQueryChange:y,renderPoliciesCount:f,searchQuery:h,sortHeader:_,sortDirection:v,page:E,count:g,customControl:w,isFiltered:S,router:C,queryParams:k,platform:N="all",otherAutomationType:T,onOpenManageAutomationsModal:P})=>{var O,x,D,M;const{config:R}=(0,l.useContext)(s.BR),$=(0,l.useCallback)(e=>{var t,a;C.push((0,r.g2)({pathPrefix:i.A.MANAGE_POLICIES,queryParams:(t=ge({},k),a={page:0,platform:"all"===(null==e?void 0:e.value)||null==e?void 0:e.value},fe(t,he(a)))}))},[k,C]),F=(0,l.useCallback)(()=>l.createElement(A.A,{name:"platform-dropdown",value:N,className:`${we}__platform-dropdown`,options:Se,onChange:$,variant:"table-filter",iconName:"filter-alt"}),[N,$]),q=m&&(null===(null==u?void 0:u.id)||(null==u?void 0:u.id)===p.jc);let Q="No policies yet";m&&!(null==(O=null==R?void 0:R.partnerships)?void 0:O.enable_primo)&&(Q=q?"No policies apply to all fleets":"No policies for this fleet");const W={header:Q,info:"Policies are queries that return a pass or fail result. Failures trigger fixes or prompt end users to solve them on their own.",primaryButton:o?l.createElement(b.A,{onClick:n,type:"button"},"Add policy"):void 0};(h||S)&&(delete W.primaryButton,W.header="No matching policies",W.info="No policies match the current filters.");const H=0===(null==e?void 0:e.length)&&""===h&&!S,j=(null==(x=null==R?void 0:R.partnerships)?void 0:x.enable_primo)||
1!1,B=!(void 0!==(null==u?void 0:u.id)&&null!==(null==u?void 0:u.id)&&(null==u?void 0:u.id)!==p.jc)||j||e.some(e=>null!==e.team_id),U=o&&c&&B;return l.createElement("div",{className:we},l.createElement(L.A,{resultsTitle:"policies",columnConfigs:me({selectedTeamId:null==u?void 0:u.id,hasPermissionAndPoliciesToDelete:U,otherAutomationType:T,onOpenManageAutomationsModal:P},m,null==(D=null==R?void 0:R.partnerships)?void 0:D.enable_primo),data:pe(e,d,null==(M=null==R?void 0:R.update_interval)?void 0:M.osquery_policy),isLoading:t,defaultSortHeader:_||Qt,defaultSortDirection:v||Ft,defaultSearchQuery:h,pageIndex:E,disableNextPage:Ae(g,qt,E),showMarkAllPages:!1,isAllPagesSelected:!1,primarySelectAction:{name:"delete policy",buttonText:"Delete",iconSvg:"trash",variant:"secondary",onClick:a},emptyComponent:()=>l.createElement(I.A,{header:W.header,info:W.info,additionalInfo:W.additionalInfo,primaryButton:W.primaryButton}),renderCount:f,onQueryChange:y,inputPlaceHolder:"Search by name",searchable:!0,disableSearch:H,customControl:()=>l.createElement("div",{className:`${we}__filter-dropdowns`},null==w?void 0:w(),F()),selectedDropdownFilter:N}))},ke=a(99958);const Ne="delete-policy-modal";var Te=({isUpdatingPolicies:e,onCancel:t,onSubmit:a})=>l.createElement(ke.A,{title:"Delete policies",onExit:t,onEnter:a,className:Ne},l.createElement("div",{className:Ne},"Deleting these policies will disable any associated automations, such as automatic software install or automatic script run.",l.createElement("div",{className:"modal-cta-wrap"},l.createElement(b.A,{type:"button",variant:"alert",onClick:a,className:"delete-loading",isLoading:e},"Delete"),l.createElement(b.A,{onClick:t,variant:"secondary"},"Cancel")))),Pe=a(14648),Oe=a(77906),Le=a(26806),Ie=a(79973),xe=a(80717),De=a(48862),Me=a(90879),Re=a(25087),$e=a(24432),Fe=a(81766),qe=a.p+"jira-policy-automation-preview-400x419@[email protected]",Qe=a.p+"zendesk-policy-automation-preview-400x515@[email protected]",We=a.p+"jira-policy-automation-preview-premium-400x316@[email protected]",He=a.p+"zendesk-policy-automation-preview-premium-400x483@[email protected]";const je="example-ticket";var Be=({integrationType:e})=>{const{isPremiumTier:t}=(0,l.useContext)(s.BR),a="jira"===e?l.createElement("img",{src:t?We:qe,alt:"Jira example policy automation ticket",className:`${je}__screenshot`}):l.createElement("img",{src:t?He:Qe,alt:"Zendesk example policy automation ticket",className:`${je}__screenshot`});return l.createElement(Fe.A,{className:je,color:"grey"},a)},Ue=()=>{const{isFreeTier:e}=(0,l.useContext)(s.BR),t={timestamp:"0000-00-00T00:00:00Z",policy:{id:1,name:"Is Gatekeeper enabled?",query:"SELECT 1 FROM gatekeeper WHERE assessments_enabled = 1;",description:"Checks if gatekeeper is enabled on macOS devices.",author_id:1,author_name:"John",author_email:"[email protected]",resolution:"Turn on Gatekeeper feature in System Preferences.",passing_host_count:2e3,failing_host_count:300,critical:!1},hosts:[{id:1,display_name:"macbook-1",url:"https://fleet.example.com/hosts/1"},{id:2,display_name:"macbbook-2",url:"https://fleet.example.com/hosts/2"}]};return e&&delete t.policy.critical,l.createElement("div",{className:"example-payload"},l.createElement("pre",null,"POST https://server.com/example"),l.createElement("pre",{dangerouslySetInnerHTML:{__html:(0,r._j)(t)}}))},ze=Object.defineProperty,Ge=Object.defineProperties,Ye=Object.getOwnPropertyDescriptors,Ke=Object.getOwnPropertySymbols,Ve=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,Je=(e,t,a)=>t in e?ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Ze=(e,t)=>{for(var a in t||(t={}))Ve.call(t,a)&&Je(e,a,t[a]);if(Ke)for(var a of Ke(t))Xe.call(t,a)&&Je(e,a,t[a]);return e},et=(e,t)=>Ge(e,Ye(t));const tt="other-workflows-modal",at=e=>e?(0,Me.A)({url:e})?void 0:"Destination URL is not a valid URL":"Please add a destination URL",lt=(0,l.forwardRef)(({router:e,automationsConfig:t,availableIntegrations:a,gitOpsModeEnabled:n=!1},r)=>{const{webhook_settings:{failing_policies_webhook:s}}=t,{jira:c,zendesk:u}=a||{},d=[];c&&d.push(...c),u&&d.push(...u);const m=d.length>0,p=d.map(({group_id:e,project_key:t,url:a})=>({value:e||t,label:`${a} - ${e||t}`})),y=(({jira:e,zendesk:t})=>(null==e?void 0:e.find(e=>e.enable_failing_policies))||(null==t?void 0:t.find(e=>e.enable_failing_policies)))(t.integrations),f=!!s.enable_failing_policies_webhook||!!y,h=!f||s.enable_failing_policies_webhook,_=s.destination_url||"",[v,E]=(0,l.useState)(f),[g,A]=(0,l.useState)(h),[w,S]=(0,l.useState)(_),[C,k]=(0,l.useState)(y),[N,T]=(0,l.useState)(!1),[P,O]=(0,l.useState)(!1),[L,I]=(0,l.useState)({});(0,l.useImperativeHandle)(r,()=>({getFormData:()=>(()=>{var e,t;const l=(null==(e=a.jira)?void 0:e.map(e=>et(Ze({},e),{enable_failing_policies:v&&!g&&e.project_key===(null==C?void 0:C.project_key)})))||null,n=(null==(t=a.zendesk)?void 0:t.map(e=>et(Ze({},e),{enable_failing_policies:v&&!g&&e.group_id===(null==C?void 0:C.group_id)})))||null;return{webhook_settings:{failing_policies_webhook:{destination_url:w,policy_ids:s.policy_ids||[],enable_failing_policies_webhook:v&&g}},integrations:{jira:l,zendesk:n,google_calendar:null}}})(),validate:()=>{const e=(()=>{const e={};if(v&&(g||C||(e.integration=m?"Please enable at least one integration:":"Add an integration to create tickets for policy automations."),g)){const t=at(w);t&&(e.url=t)}return e})();return I(e),(0,o.isEmpty)(e)},isDirty:()=>
1{if(v!==f)return!0;if(v){if(g!==!!h)return!0;if(g&&w!==_)return!0;if(!g&&((null==C?void 0:C.project_key)!==(null==y?void 0:y.project_key)||(null==C?void 0:C.group_id)!==(null==y?void 0:y.group_id)))return!0}return!1}}));const x=e=>{switch(e){case"webhook":A(!0),k(void 0);break;case"ticket":A(!1);break;default:(0,o.noop)()}};return l.createElement("div",{className:`${tt} form`},l.createElement("p",{className:`${tt}__description`},"Create tickets or fire webhooks when hosts fail policies."," ",l.createElement($e.A,{url:"https://www.fleetdm.com/learn-more-about/policy-automations",text:"Learn more",newTab:!0})),l.createElement(Le.A,{value:v,onChange:()=>{E(!v),I({})},inactiveText:"Disabled",activeText:"Enabled",disabled:n}),l.createElement("div",{className:`form ${tt}__policy-automations__${v?"enabled":"disabled"}`},l.createElement("div",{className:`form-field ${tt}__workflow`},l.createElement("div",{className:"form-field__label"},"Workflow"),l.createElement(De.A,{className:`${tt}__radio-input`,label:"Ticket",id:"ticket-radio-btn",checked:!g,value:"ticket",name:"workflow-type",onChange:x,disabled:!v||n}),l.createElement(De.A,{className:`${tt}__radio-input`,label:"Webhook",id:"webhook-radio-btn",checked:g,value:"webhook",name:"workflow-type",onChange:x,disabled:!v||n})),g?l.createElement(l.Fragment,null,l.createElement(xe.A,{inputWrapperClass:`${tt}__url-input`,name:"webhook-url",label:"Destination URL",type:"text",value:w,onChange:e=>{S(e),I(e=>(0,o.omit)(e,"url"))},onBlur:()=>{if(!v||n)return;const e=at(w);I(t=>{const a=(0,o.omit)(t,"url");return e?et(Ze({},a),{url:e}):a})},error:L.url,helpText:"For configured policies, Fleet will send a JSON payload to this URL with a list of hosts whose statuses changed from pass to fail.",placeholder:"https://server.com/example",tooltip:"Provide a URL to deliver a webhook request to.",disabled:!v||n})):m?l.createElement(l.Fragment,null,l.createElement("div",{className:`${tt}__integrations`},l.createElement(Ie.A,{options:p,onChange:e=>{k(d.find(({group_id:t,project_key:a})=>t===e||a===e))},placeholder:"Select integration",value:(null==C?void 0:C.group_id)||(null==C?void 0:C.project_key),label:"Integration",error:L.integration,wrapperClassName:`${tt}__form-field ${tt}__form-field--frequency`,hint:"For each policy, Fleet will create a ticket with a list of the failing hosts."})),l.createElement(Re.A,{isShowing:P,className:tt,hideText:"Hide example ticket",showText:"Show example ticket",caretPosition:"after",onClick:()=>O(!P)}),P&&l.createElement(Be,{integrationType:(D=C,((null==D?void 0:D.group_id)?"zendesk":!!(null==D?void 0:D.project_key)&&"jira")||void 0)})):l.createElement("div",{className:`form-field ${tt}__no-integrations`},l.createElement("div",{className:"form-field__label"},"You have no integrations."),l.createElement("div",null,l.createElement(b.A,{onClick:()=>{e.push(i.A.ADMIN_INTEGRATIONS)},disabled:n||!v},"Add integration")),L.integration&&l.createElement("div",{className:`${tt}__error`},L.integration))),g&&l.createElement(l.Fragment,null,l.createElement(Re.A,{isShowing:N,className:tt,hideText:"Example payload",showText:"Example payload",caretPosition:"after",onClick:()=>T(!N)}),N&&l.createElement(Ue,null)));var D});lt.displayName="OtherWorkflowsModal";var nt=lt,it=a(36321),ot=Object.defineProperty,rt=Object.defineProperties,st=Object.getOwnPropertyDescriptors,ct=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,dt=Object.prototype.propertyIsEnumerable,mt=(e,t,a)=>t in e?ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,pt=(e,t)=>{for(var a in t||(t={}))ut.call(t,a)&&mt(e,a,t[a]);if(ct)for(var a of ct(t))dt.call(t,a)&&mt(e,a,t[a]);return e},yt=(e,t)=>rt(e,st(t));const ft="calendar-events-modal",ht=(0,l.forwardRef)(({configured:e,enabled:t,url:a,gitOpsModeEnabled:n=!1},o)=>{const{isGlobalAdmin:c}=(0,l.useContext)(s.BR),[u,d]=(0,l.useState)({enabled:t,url:a}),[m,p]=(0,l.useState)({}),[y,f]=(0,l.useState)(!1),h=e=>{const t={},{url:a}=e;if(e.enabled&&!(0,Me.A)({url:a||"",protocols:["http","https"]})){const e=a?`${a} is not`:"Please enter";t.url=`${e} a valid resolution webhook URL`}return t};return(0,l.useImperativeHandle)(o,()=>({getFormData:()=>e?u:null,validate:()=>{if(!e)return!0;const t=h(u);return p(t),0===Object.keys(t).length},isDirty:()=>e&&(u.enabled!==t||u.url!==a)})),l.createElement(l.Fragment,null,l.createElement("div",{className:`${ft} form`},l.createElement("div",{className:`${ft}__header`},l.createElement("p",{className:`${ft}__description`},"Schedule maintenance windows for end users failing policies."," ",l.createElement($e.A,{url:"https://www.fleetdm.com/learn-more-about/calendar-events",text:"Learn more",newTab:!0}))),!e&&l.createElement(it.A,{className:ft},c?l.createElement($e.A,{url:i.A.ADMIN_INTEGRATIONS_CALENDARS,text:"Connect Fleet to Google Worksp
1ace",emphasized:!0}):l.createElement(l.Fragment,null,"Admin can connect Fleet to Google Workspace via"," ",l.createElement("b",null,"Settings")," > ",l.createElement("b",null,"Integrations")," > ",l.createElement("b",null,"Calendars"))," ","to use calendar automations."),e&&l.createElement(l.Fragment,null,l.createElement(Le.A,{value:u.enabled,onChange:()=>{const e=yt(pt({},u),{enabled:!u.enabled});!1===e.enabled&&h(e).url&&(e.url="",p(e=>{const t=pt({},e);return delete t.url,t})),d(e)},inactiveText:"Disabled",activeText:"Enabled",disabled:n}),l.createElement("div",{className:"form "+(u.enabled?"":"form-fields--disabled")},l.createElement(xe.A,{placeholder:"https://server.com/example",label:"Resolution webhook URL",onChange:e=>{const t=yt(pt({},u),{url:e});m.url&&p(h(t)),d(t)},name:"url",value:u.url,error:m.url,tooltip:"Provide a URL to deliver a webhook request to.",helpText:"A request will be sent to this URL during the calendar event. Use it to trigger auto-remediation.",disabled:!u.enabled||n})),l.createElement(Re.A,{isShowing:y,className:`${ft}__show-example-payload-toggle`,hideText:"Example payload",showText:"Example payload",caretPosition:"after",onClick:()=>f(!y)}),y&&l.createElement(l.Fragment,null,l.createElement("pre",null,"POST https://server.com/example"),l.createElement("pre",{dangerouslySetInnerHTML:{__html:(0,r._j)({timestamp:"0000-00-00T00:00:00Z",host_id:1,host_display_name:"Anna's MacBook Pro",host_serial_number:"ABCD1234567890",failing_policies:[{id:123,name:"macOS - Disable guest account"}]})}})))))});ht.displayName="CalendarEventsModal";var _t=ht;const vt=(0,l.forwardRef)(({configured:e,enabled:t,gitOpsModeEnabled:a=!1,providerText:n},o)=>{const{isGlobalAdmin:r}=(0,l.useContext)(s.BR),[c,u]=(0,l.useState)(t);return(0,l.useImperativeHandle)(o,()=>({getFormData:()=>e?{enabled:c}:null,validate:()=>!0,isDirty:()=>e&&c!==t})),l.createElement("div",{className:"form"},l.createElement("p",null,"Block single sign-on for end users failing policies."," ",l.createElement($e.A,{text:"Learn more",url:`${z.CW}/conditional-access`,newTab:!0})),!e&&l.createElement(it.A,null,r?l.createElement($e.A,{url:i.A.ADMIN_INTEGRATIONS_CONDITIONAL_ACCESS,text:`Connect Fleet to ${n}`,emphasized:!0}):l.createElement(l.Fragment,null,"Admin can connect Fleet to ",n," via ",l.createElement("b",null,"Settings")," ","> ",l.createElement("b",null,"Integrations")," > ",l.createElement("b",null,"Conditional access"))," ","to use conditional access automations."),e&&l.createElement(Le.A,{value:c,onChange:()=>u(!c),inactiveText:"Disabled",activeText:"Enabled",disabled:a}))});vt.displayName="ConditionalAccessModal";var Et=vt;const bt="calendar-event-preview-modal";var gt=({onCancel:e,policy:t})=>{const{config:a}=(0,l.useContext)(s.BR),n=!(null==t?void 0:t.description)||!(null==t?void 0:t.resolution),i=null==a?void 0:a.org_info.org_name;return l.createElement(ke.A,{title:"Calendar event preview",width:"large",onExit:e,className:bt},l.createElement("span",null,n?"What end users see:":l.createElement(l.Fragment,null,"End users failing only ",l.createElement("strong",null,t.name)," policy will see:")),l.createElement("div",{className:`${bt}__preview`},l.createElement("div",{className:`${bt}__preview-header`},l.createElement("div",{className:`${bt}__preview-header__square-wrapper`},l.createElement("div",{className:`${bt}__preview-header__square`})),l.createElement("div",{className:`${bt}__preview-header__info`},l.createElement("div",{className:`${bt}__preview-header__title`},"ð» ð« Scheduled maintenance"),l.createElement("div",{className:`${bt}__preview-header__time`},l.createElement("span",null,"Tuesday, June 18"),l.createElement("span",null,"â
"),l.createElement("span",null,"5-5:30pm")))),l.createElement("div",{className:`${bt}__preview-info`},l.createElement("div",{className:`${bt}__preview-info__icon`},l.createElement(W.A,{name:"text"})),l.createElement("div",{className:`${bt}__preview-info__text`},i," reserved this time to make some changes to your work computer (Anna's MacBook Pro).",l.createElement("br",null),l.createElement("br",null),"Please leave your device on and connected to power.",l.createElement("br",null)," ",l.createElement("br",null),l.createElement("strong",null,"Why it matters"),l.createElement("br",null),l.createElement("div",{className:`${bt}__preview-info__text__user-text`},n?`${i} needs to make sure your device meets the organization's requirements.`:t.description),l.createElement("br",null)," ",l.createElement("br",null),l.createElement("strong",null,"Maintenance required"),l.createElement("br",null),l.createElement("div",{className:`${bt}__preview-info__text__user-text`},n?l.createElement("ul",null,l.createElement("li",null,"Click the"," ",l.createElement("a",{href:z.qe,rel:"noreferrer",target:"_blank"},"Fleet")," ","icon in your computer's menu and select"," ",l.createElement("b",null,"My device")),l.createElement("li",null,"Navigate to the ",l.createElement("b",null,"Policies")," tab"),l.createElement("li",null,"Follow instructions to resolve any policies marked"," ",'"Fail"'),l.createElement("li",null,"Click ",l.createElement("b",null,"Refetch"))):t.resolution))),l.createElement("div",{className:`${bt}__preview-invitee`},l.createElement("div",{className:`${bt}__preview-invitee__icon`},l.createElement(W.A,{name:"calendar"})),l.createElement("div",{className:`${bt}__preview-invitee__text`},"Anna Chao"))),l.createElement("div",{className:`${bt}__footer`},n?l.createElement(l.Fragment,null,"Users failing only a single policy will see a more specific explanation."):l.createElement(l.Fragment,null,l.createElement("strong",null,"Why it matters")," and"," ",l.createElement("strong",null,"Maintenance required")," are populated by the policy's ",l.createElement("strong",null,"Description")," and"," ",l.createElement("strong",null,"Resolution")," respectively.")),l.createElement("div",{className:"modal-cta-wrap"},l.createElement(b.A,{onClick:e},"Close")))};const At="automations-modal";var wt=({router:e,isAllTeamsSelected:t,teamIdForApi:a,globalConfig:i,teamConfig:o,gitOpsModeEnabled:r=!1,refetchPolicies:c,onExit:u})=>{var m,y,h,_,E,g;const A=(0,n.useQueryClient)(),{setConfig:w,isPremiumTier:S}=(0,l.useContext)(s.BR),C=(0,l.useRef)(null),k=(0,l.useRef)(null),N=(0,l.useRef)(null),[T,P]=(0,l.useState)(!1),O
1=t?i:o,L=null!=(m=null==i?void 0:i.integrations)?m:null==O?void 0:O.integrations,I=!t&&a!==p.Rp,x=null!=(y=(null==i?void 0:i.integrations.google_calendar)&&(null==i?void 0:i.integrations.google_calendar.length)>0)&&y,D=null!=(_=null==(h=null==o?void 0:o.integrations.google_calendar)?void 0:h.enable_calendar_events)&&_,M=(null==(E=null==o?void 0:o.integrations.google_calendar)?void 0:E.webhook_url)||"",[R,$]=(0,l.useState)(!1),F=()=>$(!R),q=(0,Oe.Xh)(i),Q=null!=(g=a===p.Rp?null==i?void 0:i.integrations.conditional_access_enabled:null==o?void 0:o.integrations.conditional_access_enabled)&&g,W=S?"Okta or Microsoft Entra":"Okta",H=e=>{A.setQueryData(["config"],e),w(e)},j=e=>{A.setQueryData(["teams",a],e)};return O&&L?l.createElement(ke.A,{title:"Automations",onExit:u,className:At,width:"large",isContentDisabled:T},l.createElement("form",{onSubmit:e=>{return l=function*(){var l,n,i,o,r,s,m,y,h,_,E,b,g,A,w,S;e.preventDefault();const T=null==(n=null==(l=C.current)?void 0:l.validate())||n,O=null==(o=null==(i=k.current)?void 0:i.validate())||o,L=null==(s=null==(r=N.current)?void 0:r.validate())||s;if(!T||!O||!L)return;const I=null!=(y=null==(m=C.current)?void 0:m.getFormData())?y:null,x=null!=(_=null==(h=k.current)?void 0:h.getFormData())?_:null,D=null!=(b=null==(E=N.current)?void 0:E.getFormData())?b:null;P(!0);try{if(t){if(I){const e=yield f.A.update(I);H(e)}}else if(a===p.Rp){const e={integrations:{jira:null!=(g=null==I?void 0:I.integrations.jira)?g:[],zendesk:null!=(A=null==I?void 0:I.integrations.zendesk)?A:[]}};I&&(e.webhook_settings=I.webhook_settings);const t=[];I&&t.push(v.A.update(e,a).then(j)),D&&t.push(f.A.update({integrations:{conditional_access_enabled:D.enabled}}).then(H)),yield Promise.all(t)}else if(void 0!==a){const e={jira:null!=(w=null==I?void 0:I.integrations.jira)?w:[],zendesk:null!=(S=null==I?void 0:I.integrations.zendesk)?S:[]};x&&(e.google_calendar={enable_calendar_events:x.enabled,webhook_url:x.url}),D&&(e.conditional_access_enabled=D.enabled);const t={integrations:e};if(I&&(t.webhook_settings=I.webhook_settings),I||x||D){const e=yield v.A.update(t,a);j(e)}}d.me.success("Successfully updated policy automations."),c(),u()}catch(e){d.me.error("Could not update policy automations.",{response:e})}finally{P(!1)}},new Promise((e,t)=>{var a=e=>{try{i(l.next(e))}catch(e){t(e)}},n=e=>{try{i(l.throw(e))}catch(e){t(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(a,n);i((l=l.apply(null,null)).next())});var l}},l.createElement("div",{className:`${At}__body`},l.createElement("section",{className:`${At}__section`},!t&&l.createElement("h2",{className:`${At}__section-title`},"Webhooks or tickets"),l.createElement(nt,{ref:C,router:e,automationsConfig:O,availableIntegrations:L,gitOpsModeEnabled:r})),I&&l.createElement(l.Fragment,null,l.createElement("hr",{className:`${At}__divider`}),l.createElement("section",{className:`${At}__section`},l.createElement("div",{className:`${At}__calendar-events-title-wrapper`},l.createElement("h2",{className:`${At}__section-title`},"Calendar events"),x&&l.createElement(l.Fragment,null,l.createElement(b.A,{type:"button",variant:"secondary",onClick:F},"Preview calendar event"),R&&l.createElement(gt,{onCancel:F}))),l.createElement(_t,{ref:k,configured:x,enabled:D,url:M,gitOpsModeEnabled:r}))),!t&&l.createElement(l.Fragment,null,l.createElement("hr",{className:`${At}__divider`}),l.createElement("section",{className:`${At}__section`},l.createElement("h2",{className:`${At}__section-title`},"Conditional access"),l.createElement(Et,{ref:N,configured:q,enabled:Q,gitOpsModeEnabled:r,providerText:W})))),l.createElement("div",{className:"modal-cta-wrap"},l.createElement(b.A,{type:"submit",isLoading:T,disabled:T},"Save"),l.createElement(b.A,{type:"button",onClick:u,variant:"secondary"},"Cancel")))):null},St=a(17244),Ct=a(83844);const kt="manage-automations-modal",Nt=["darwin","windows","linux","chrome"];var Tt=({policy:e,fleetName:t,isGlobalPolicy:a,teamIdForApi:n,automationsConfig:i,globalConfig:o,refetchPolicies:r,onExit:s})=>{var c;const u=(0,l.useRef)(null),{mutate:m,isLoading:p}=(0,Ct.p)({policy:e,teamIdForApi:n,isGlobalPolicy:a,automationsConfig:i,onSuccess:()=>{d.me.success("Successfully updated policy automations."),r(),s()},onError:()=>d.me.error("Could not update policy automations.")}),f=(null!=(c=e.platform)?c:"").split(",").map(e=>e.trim()).filter(e=>
1Nt.includes(e)),h=Nt.filter(e=>f.includes(e));return l.createElement(ke.A,{title:"Manage automations",onExit:s,className:kt,width:"large",isContentDisabled:p},l.createElement("form",{onSubmit:e=>{var t;e.preventDefault();const a=null==(t=u.current)?void 0:t.getAutomationsPayload();a&&a.isValid&&(a.isDirty?m({policyUpdate:a.policyUpdate,webhookOrTicketUpdate:a.webhookOrTicketUpdate}):s())}},l.createElement("div",{className:`${kt}__body`},l.createElement("div",{className:`${kt}__header`},"Manage automations for the ",l.createElement("b",null,e.name)," policy on"," ",l.createElement("b",null,t),"."),h.length>0&&l.createElement("section",{className:`${kt}__section`},l.createElement("h2",{className:`${kt}__section-title`},"Platforms"),l.createElement("div",{className:`${kt}__platforms`},h.map(e=>l.createElement("span",{key:e,className:`${kt}__platform`},l.createElement(W.A,{name:e,size:"small"}),y.uc[e])))),l.createElement("section",{className:`${kt}__section`},l.createElement("h2",{className:`${kt}__section-title`},"Automations"),l.createElement(St.A,{ref:u,policy:e,isGlobalPolicy:a,teamIdForApi:n,automationsConfig:i,globalConfig:o,fleetName:t,selectedPlatforms:f}))),l.createElement("div",{className:"modal-cta-wrap"},l.createElement(b.A,{type:"submit",isLoading:p,disabled:p},"Save"),l.createElement(b.A,{type:"button",onClick:s,variant:"secondary"},"Cancel"))))},Pt=Object.defineProperty,Ot=Object.defineProperties,Lt=Object.getOwnPropertyDescriptors,It=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable,Mt=(e,t,a)=>t in e?Pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Rt=(e,t)=>{for(var a in t||(t={}))xt.call(t,a)&&Mt(e,a,t[a]);if(It)for(var a of It(t))Dt.call(t,a)&&Mt(e,a,t[a]);return e},$t=(e,t,a)=>new Promise((l,n)=>{var i=e=>{try{r(a.next(e))}catch(e){n(e)}},o=e=>{try{r(a.throw(e))}catch(e){n(e)}},r=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,o);r((a=a.apply(e,t)).next())});const Ft="asc",qt=20,Qt="name",Wt=["software","patch","scripts","profiles","calendar","conditional_access","other"],Ht=["other"],jt=e=>void 0===e?Ht:e===p.Rp?Wt.filter(e=>"calendar"!==e):Wt,Bt="manage-policies-page";var Ut=({router:e,location:t})=>{var a,L,I,x,D;const M=t.query,{isGlobalAdmin:R,isGlobalMaintainer:$,isOnGlobalTeam:F,isPremiumTier:q,config:Q,setConfig:W,setFilteredPoliciesPath:H,filteredPoliciesPath:j}=(0,l.useContext)(s.BR),B=(null==(a=null==Q?void 0:Q.partnerships)?void 0:a.enable_primo)||!1,{setResetSelectedRows:U}=(0,l.useContext)(u.G),{setLastEditedQueryName:z,setLastEditedQueryDescription:G,setLastEditedQueryResolution:Y,setLastEditedQueryCritical:K,setLastEditedQueryPlatform:V,setLastEditedQueryBody:X,setLastEditedQueryId:J,setPolicyTeamId:Z}=(0,l.useContext)(c.q),{currentTeamId:ee,currentTeamSummary:te,isAllTeamsSelected:ae,isTeamAdmin:le,isTeamMaintainer:ne,isRouteOk:ie,teamIdForApi:oe,userTeams:re,handleTeamChange:se}=(0,m.Ay)({location:t,router:e,includeAllTeams:!0,includeNoTeam:!0,permittedAccessByTeamRole:{admin:!0,maintainer:!0,observer:!0,observer_plus:!0,technician:!0}}),[ce,ue]=(0,l.useState)(!1),[de,me]=(0,l.useState)([]),[pe,ye]=(0,l.useState)(!1),[fe,he]=(0,l.useState)(!1),[_e,ve]=(0,l.useState)(null),Ee=null!=(be=M.query)?be:"";var be;const ge=(()=>{var e;return null!=(e=null==M?void 0:M.order_key)?e:Qt})(),Ae=(()=>{var e;return null!=(e=null==M?void 0:M.order_direction)?e:Ft})(),we=M&&M.page?parseInt(null==M?void 0:M.page,10):0,Se=(0,y.ek)(null==M?void 0:M.platform)?null==M?void 0:M.platform:void 0,ke=(()=>{const e=M.automation_type;return e&&jt(oe).includes(e)?e:null})(),Ne=(0,l.useRef)(!0),[Oe,Le]=(0,l.useState)(Ee),[Ie,xe]=(0,l.useState)(),[De,Me]=(0,l.useState)(ge),[Re,$e]=(0,l.useState)(Ae),[Fe,qe]=(0,l.useState)(ke);(0,l.useEffect)(()=>{V(null)},[V]),(0,l.useEffect)(()=>{ie&&(Le(Ee),Me(ge),$e(Ae),qe(ke))},[t,ie,Ee,ge,Ae,ke]),(0,l.useEffect)(()=>{if(!ie)return;const e=t.pathname+t.search;t.search&&j!==e&&H(e)},[t.pathname,t.search,j,H,ie]);const{data:Qe,error:We,isFetching:He,refetch:je}=(0,n.useQuery)([{scope:"globalPolicies",page:we,perPage:qt,query:Oe,orderDirection:Re,orderKey:De,automationType:Fe,platform:Se}],({queryKey:e})=>h.A.loadAllNew(e[0]),{enabled:ie&&ae,select:e=>e.policies||[],staleTime:5e3,refetchOnWindowFocus:!1}),{data:Be,isFetching:Ue,isError:ze,refetch:Ge}=(0,n.useQuery)([{scope:"policiesCount",query:ae?Oe:"",automationType:Fe,platform:Se}],({queryKey:e})=>h.A.getCount(e[0]),{enabled:ie&&ae,keepPreviousData:!0,refetchOnWindowFocus:!1,retry:1,select:e=>e.count}),{data:Ye,error:Ke,isFetching:Ve,refetch:Xe}=(0,n.useQuery)([{scope:"teamPolicies",page:we,perPage:qt,query:Oe,orderDirection:Re,orderKey:De,teamId:oe||0,mergeInherited:!0,automationType:Fe,platform:Se}],({queryKey:e})=>
1_.A.loadAllNew(e[0]),{enabled:ie&&q&&!ae,select:e=>e.policies||[],refetchOnWindowFocus:!1}),{data:Je,isFetching:Ze,isError:et,refetch:tt}=(0,n.useQuery)([{scope:"teamPoliciesCountMergeInherited",query:Oe,teamId:oe||0,mergeInherited:!0,automationType:Fe,platform:Se}],({queryKey:e})=>_.A.getCount(e[0]),{enabled:ie&&q&&!ae,keepPreviousData:!0,refetchOnWindowFocus:!1,retry:1}),at=null==Je?void 0:Je.count,lt=R||$||ne||le,nt=R||le,{data:it,isFetching:ot}=(0,n.useQuery)(["config"],()=>f.A.loadAll(),{enabled:ie,onSuccess:e=>{W(e)},staleTime:5e3,refetchOnWindowFocus:!1}),{data:rt,isFetching:st}=(0,n.useQuery)(["teams",oe],()=>v.A.load(oe),{enabled:ie&&void 0!==oe,staleTime:5e3,refetchOnWindowFocus:!1}),ct=null==rt?void 0:rt.team,ut=ae?it:ct,dt=e=>{void 0!==e?(Xe(),tt()):(je(),Ge())},mt=(0,l.useCallback)(e=>{me([]),se(e)},[se]),pt=(0,l.useCallback)(t=>$t(null,null,function*(){if(!ie||(0,o.isEqual)(t,Ie))return;xe(Rt({},t));const{pageIndex:a,searchQuery:l,sortDirection:n,sortHeader:s}=t,c={};c.query=l,c.order_key=s,c.order_direction=n,c.page=a.toString(),n===Re&&s===De&&l===Oe||(c.page="0"),ie&&void 0!==oe&&(c.fleet_id=oe);const u=(0,r.g2)({pathPrefix:i.A.MANAGE_POLICIES,queryParams:Rt(Rt({},M),c)});Ne.current?(Ne.current=!1,null==e||e.replace(u)):null==e||e.push(u)}),[ie,Ie,Re,De,Oe,oe,M,e]),yt=()=>ye(!pe),ft=()=>he(!fe),ht=e=>ve(e),_t=()=>ve(null),vt=()=>{z(""),G(""),Y(""),K(!1),Z(ee===p.s_?p.jc:ee),X(Pe.zj.query),J(null),e.push(ee===p.s_?i.A.NEW_POLICY:`${i.A.NEW_POLICY}?fleet_id=${ee}`)},Et=e=>{yt(),me(e)},bt=(0,l.useCallback)(()=>$t(null,null,function*(){ue(!0);try{const e=[];if(B){const t=new Set(de),[a,l]=(null!=Ye?Ye:[]).reduce((e,a)=>(t.has(a.id)&&(null===a.team_id?e[0].push(a.id):e[1].push(a.id)),e),[[],[]]);a.length&&e.push(h.A.destroy(a)),l.length&&e.push(_.A.destroy(oe,l))}else e.push(ae?h.A.destroy(de):_.A.destroy(oe,de));yield Promise.all(e),d.me.success("Successfully deleted policies."),U(!0),dt(oe)}catch(e){d.me.error("Unable to delete policies. Please try again.",{response:e})}finally{yt(),ue(!1)}}),[ae,B,dt,de,U,oe,Ye,yt]),gt=t=>{const a=null==t?void 0:t.value,l=(0,r.g2)({pathPrefix:i.A.MANAGE_POLICIES,queryParams:(n=Rt({},M),o={page:"0",automation_type:"all"===a?void 0:a},Ot(n,Lt(o)))});var n,o;null==e||e.push(l)},At=ae?We:Ke,St=ae?void 0!==Qe:void 0!==Ye,Ct=!At,kt=ae?(null!=Be?Be:0)>0:(null!=at?at:0)>(null!=(L=null==Je?void 0:Je.inherited_policy_count)?L:0),Nt=kt||B&&(null!=(I=null==Ye?void 0:Ye.length)?I:0)>0;(0,l.useEffect)(()=>{if("1"!==t.query.manage_automations)return;if(!(ae?void 0!==Be||ze:void 0!==Je||et))return;nt&&kt&&he(!0);const a=t.query,{manage_automations:l}=a,n=((e,t)=>{var a={};for(var l in e)xt.call(e,l)&&t.indexOf(l)<0&&(a[l]=e[l]);if(null!=e&&It)for(var l of It(e))t.indexOf(l)<0&&Dt.call(e,l)&&(a[l]=e[l]);return a})(a,["manage_automations"]);e.replace({pathname:t.pathname,query:n})},[t.query,t.pathname,e,nt,kt,ae,Be,Je,ze,et]);const Pt=(0,O.LM)(ut),Mt=ae?{state:"disabled",policyIds:[]}:(0,O.LM)(it),Wt=Array.from(new Set([...Pt.policyIds,...Mt.policyIds])),Ht="disabled"!==Pt.state?Pt.state:Mt.state,Ut="disabled"===Ht?void 0:Ht,zt=(e,t)=>{var a;if((ae?Ue:Ze)||At||!St&&""===Oe&&!Fe&&!Se)return null;const n=(null==(a=null==t?void 0:t.find(e=>!!e.host_count_updated_at))?void 0:a.host_count_updated_at)||"";return l.createElement(l.Fragment,null,l.createElement(E.A,{name:"policies",count:e}),l.createElement(T.A,{lastUpdatedAt:n,customTooltipText:l.createElement(l.Fragment,null,"Counts are updated hourly. Click host counts for the most up-to-date count.")}))},Gt=[{label:"All automations",value:"all",helpText:"All policies added to Fleet."},{label:"Software",value:"software",helpText:"Policies with software automation enabled."},{label:"Patch",value:"patch",helpText:"Patch policies for Fleet-maintained apps."},{label:"Scripts",value:"scripts",helpText:"Policies with script automation enabled."},{label:"Profiles",value:"profiles",helpText:"Policies with configuration profile automation enabled."},{label:"Calendar",value:"calendar",helpText:"Policies with calendar event automation enabled."},{label:"Conditional access",value:"conditional_access",helpText:"Policies with conditional access automation enabled."},{label:"Webhooks or tickets",value:"other",helpText:"Policies with webhook or ticket automation enabled."}],Yt=Gt[0],Kt=q?()=>{if(At)return null;const e=ae?Be:at,t=0===(null!=e?e:0)&&""===Oe&&!Fe&&!Se,a=jt(oe),n=Gt.filter(e=>"all"===e.value||a.includes(e.value));return l.createElement(A.A,{className:`${Bt}
1__filter-automation-dropdown`,name:"filter-by-automation",value:Fe?Gt.find(e=>e.value===Fe):Yt,onChange:gt,placeholder:"Filter by automation",options:n,variant:"table-filter",isDisabled:t})}:void 0;let Vt=null;if(nt&&(Vt=l.createElement(g.A,{onClick:ft,disabled:!kt}),!kt)){const e=q&&ee!==p.jc&&!(null==(x=null==Q?void 0:Q.partnerships)?void 0:x.enable_primo)?l.createElement("div",{className:`${Bt}__header__tooltip`},"To manage automations add a policy to this fleet.",l.createElement("br",null),"For inherited policies select âAll fleetsâ."):l.createElement("div",{className:`${Bt}__header__tooltip`},"To manage automations add a policy.");Vt=l.createElement(P.A,{underline:!1,tipContent:e,position:"top",showArrow:!0},Vt)}return ie?l.createElement(k.A,{className:Bt},l.createElement(l.Fragment,null,l.createElement("div",{className:`${Bt}__header-wrap`},l.createElement("div",{className:`${Bt}__header`},l.createElement("div",{className:`${Bt}__text`},l.createElement("div",{className:`${Bt}__title`},(()=>{if(q&&!B){if(re&&re.length>1||F)return l.createElement(S.A,{currentUserFleets:re||[],selectedFleetId:ee,onChange:mt,includeUnassigned:!0});if(!F&&re&&1===re.length)return l.createElement("h1",null,re[0].name)}return l.createElement("h1",null,"Policies")})())),Ct&&l.createElement("div",{className:`${Bt} button-wrap`},Vt,lt&&l.createElement("div",{className:`${Bt}__action-button-container`},l.createElement(b.A,{className:`${Bt}__select-policy-button`,onClick:vt},"Add policy")))),l.createElement(N.A,{content:"Detect device health issues."})),(()=>{if(!ie||q&&!re)return l.createElement(w.A,null);if(ae)return We?l.createElement(C.A,{verticalPaddingSize:"pad-xxxlarge"}):l.createElement(Ce,{policiesList:Qe||[],isLoading:He||ot,onDeletePoliciesClick:Et,onAddPolicyClick:vt,canAddOrDeletePolicies:lt,hasPoliciesToDelete:Nt,currentTeam:te,currentAutomatedPolicies:Wt,isPremiumTier:q,renderPoliciesCount:()=>zt(Be,Qe),count:Be||0,searchQuery:Oe,sortHeader:De,sortDirection:Re,page:we,onQueryChange:pt,customControl:Kt,isFiltered:!!Fe||!!Se,router:e,queryParams:M,platform:Se,otherAutomationType:Ut,onOpenManageAutomationsModal:lt?ht:void 0});if(Ke)return l.createElement(C.A,{verticalPaddingSize:"pad-xxxlarge"});const t=Ye||[];return l.createElement("div",null,l.createElement(Ce,{policiesList:t,isLoading:Ve||st||ot,onDeletePoliciesClick:Et,onAddPolicyClick:vt,canAddOrDeletePolicies:lt,hasPoliciesToDelete:Nt,currentTeam:te,currentAutomatedPolicies:Wt,renderPoliciesCount:()=>zt(at,t),isPremiumTier:q,count:at||0,searchQuery:Oe,sortHeader:De,sortDirection:Re,page:we,onQueryChange:pt,customControl:Kt,isFiltered:!!Fe||!!Se,router:e,queryParams:M,platform:Se,otherAutomationType:Ut,onOpenManageAutomationsModal:lt?ht:void 0}))})(),pe&&l.createElement(Te,{isUpdatingPolicies:ce,onCancel:yt,onSubmit:bt}),fe&&l.createElement(wt,{router:e,isAllTeamsSelected:ae,teamIdForApi:oe,globalConfig:it,teamConfig:ct,gitOpsModeEnabled:null!=(D=null==it?void 0:it.gitops.gitops_mode_enabled)&&D,refetchPolicies:()=>dt(oe),onExit:ft}),_e&&(()=>{var e;const t=null===_e.team_id,a=t?it:ut;return l.createElement(Tt,{policy:_e,fleetName:t?"All fleets":null!=(e=null==te?void 0:te.name)?e:"",isGlobalPolicy:t,teamIdForApi:oe,automationsConfig:a,globalConfig:it,refetchPolicies:()=>dt(oe),onExit:_t})})())):l.createElement(w.A,null)}},17244:function(e,t,a){a.d(t,{A:function(){return D}});var l=a(96540),n=a(68774),i=a(62131),o=a(65913),r=a(89937),s=a(4346),c=a(5410),u=a(24432),d=a(78131),m=a(59333),p=a(52603),y=a(41820),f=a(30104),h=a(75942),_=a(2543),v=a(87844),E=a(77931),b=a(31332);const g=e=>{switch(e){case"darwin":return"macOS";case"windows":return"Windows";default:return"Unsupported"}},A=["darwin","windows"],w=e=>!!A.includes(e.platform)&&!e.profile_uuid.startsWith("d");var S=Object.defineProperty,C=Object.defineProperties,k=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,O=(e,t,a)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,L=(e,t)=>{for(var a in t||(t={}))T.call(t,a)&&O(e,a,t[a]);if(N)for(var a of N(t))P.call(t,a)&&O(e,a,t[a]);return e};const I="policy-automations-fields";function x({text:e,learnMoreUrl:t}){return l.createElement(l.Fragment,null,e," ",l.createElement(u.A,{url:t,text:"Learn more",newTab:!0,variant:"tooltip-link"}))}var D=(0,l.forwardRef)(({policy:e,isGlobalPolicy:t,teamIdForApi:a,automationsConfig:S,globalConfig:N,fleetName:T,patchOption:P,patchSlot:O,selectedPlatforms:D},M)=>{var R,$,F,q,Q,W,H,j,B,U,z,G,Y,K,V,X,J,Z,ee,te;const{gitOpsModeEnabled:ae}=(0,s.A)(),{currentUser:le,isGlobalAdmin:ne}=(0,l.useContext)(n.BR),{state:ie,policyIds:oe}=(0,y.LM)(S),re="disabled"!==ie,se=!!ne||void 0!==a&&a!==i.Rp&&!!le&&o.A.isTeamAdmin(le,a),ce=!t&&a!==i.Rp&&null!=(F=null==($=null==(R=null==S?void 0:S.integrations)?void 0:R.google_calendar)?void 0:$.enable_calendar_events)&&F,ue=!t&&(
1a===i.Rp?null!=(me=null==(de=null==N?void 0:N.integrations)?void 0:de.conditional_access_enabled)&&me:null!=(ye=null==(pe=null==S?void 0:S.integrations)?void 0:pe.conditional_access_enabled)&&ye);var de,me,pe,ye;const fe=oe.includes(e.id),he=!!e.install_software,_e=!!e.run_script,ve=!!e.resend_configuration_profile,Ee=e.calendar_events_enabled,be=e.conditional_access_enabled,ge=null!=(q=e.continuous_automations_enabled)&&q,Ae=null!=(Q=e.patch_when_closed)&&Q,[we,Se]=(0,l.useState)(fe),[Ce,ke]=(0,l.useState)(he),[Ne,Te]=(0,l.useState)(_e),[Pe,Oe]=(0,l.useState)(ve),[Le,Ie]=(0,l.useState)(Ee),[xe,De]=(0,l.useState)(be),[Me,Re]=(0,l.useState)(!Ae&&ge),$e=P?"closed"===P:Ae;let Fe=Me;$e?Fe=!0:"manual"===P&&(Fe=!1);const[qe,Qe]=(0,l.useState)(null!=(H=null==(W=e.install_software)?void 0:W.software_title_id)?H:null),[We,He]=(0,l.useState)(null!=(B=null==(j=e.install_software)?void 0:j.software_package_id)?B:null),je=null!=(z=null==(U=e.patch_software)?void 0:U.software_title_id)?z:null,Be=void 0===P?Ce:"manual"!==P;let Ue=qe,ze=We;void 0!==P&&(Ue=Be?je:null,ze=Be&&(null==(G=e.install_software)?void 0:G.software_title_id)===je?We:null);const[Ge,Ye]=(0,l.useState)(null!=(K=null==(Y=e.run_script)?void 0:Y.id)?K:null),[Ke,Ve]=(0,l.useState)(null!=(X=null==(V=e.resend_configuration_profile)?void 0:V.profile_uuid)?X:null),Xe=D.some(e=>A.includes(e)),Je=!Xe,[Ze,et]=(0,l.useState)({}),tt=(0,l.useCallback)(e=>et(t=>{if(!t[e])return t;const a=L({},t);return delete a[e],a}),[et]),at=D.length>0;(0,l.useEffect)(()=>{at&&!Xe&&(Ve(null),Oe(!1),tt("resend_configuration_profile"))},[at,Xe,tt]);const lt=e=>{Re(e)},nt=!t&&void 0!==a,{data:it}=(({fleetId:e,enabled:t})=>(0,h.useQuery)([{scope:"software-titles",page:0,perPage:1e3,query:"",orderDirection:"desc",orderKey:"hosts_count",teamId:e,availableForInstall:!0,platform:"darwin,windows,linux"}],({queryKey:[e]})=>E.A.getSoftwareTitles((0,_.omit)(e,"scope")),{enabled:t,staleTime:3e4}))({fleetId:null!=a?a:0,enabled:nt&&Be&&void 0===P}),{data:ot}=(({fleetId:e,enabled:t})=>(0,h.useQuery)([{scope:"scripts",page:0,per_page:1e3,fleet_id:e}],({queryKey:[e]})=>v.A.getScripts((0,_.omit)(e,"scope")),{enabled:t,staleTime:3e4}))({fleetId:null!=a?a:0,enabled:nt&&Ne}),{data:rt}=(({fleetId:e,enabled:t})=>(0,h.useQuery)([{scope:"profiles",page:0,per_page:1e3,fleet_id:e}],({queryKey:[e]})=>b.A.getProfiles((0,_.omit)(e,"scope")),{enabled:t,staleTime:3e4}))({fleetId:null!=a?a:0,enabled:nt&&Pe}),st=(0,l.useMemo)(()=>{var e;return(null!=(e=null==it?void 0:it.software_titles)?e:[]).map(e=>({label:(0,f.Yd)(e.name,e.display_name),value:String(e.id),helpText:(0,y.IQ)(e)}))},[it]),ct=(0,l.useMemo)(()=>{var e,t;if(null===qe)return null;const a=null==(e=null==it?void 0:it.software_titles)?void 0:e.find(e=>e.id===qe);return null!=(t=null==a?void 0:a.packages)?t:null},[qe,it]),ut=(0,l.useMemo)(()=>(null!=ct?ct:[]).map(e=>({label:e.name,value:String(e.installer_id),helpText:(0,y.ic)(e)})),[ct]);(0,l.useEffect)(()=>{if(!ct||0===ct.length)return;if(null!==We&&ct.some(e=>e.installer_id===We))return;const e=(0,y.Or)(ct);e&&He(e.installer_id)},[ct,We]);const dt=(0,l.useMemo)(()=>{var e;return(null!=(e=null==ot?void 0:ot.scripts)?e:[]).map(e=>({label:e.name,value:String(e.id)}))},[ot]),mt=(0,l.useMemo)(()=>{var e;return(null!=(e=null==rt?void 0:rt.profiles)?e:[]).filter(w).map(e=>({label:e.name,value:e.profile_uuid,helpText:g(e.platform)}))},[rt]);(0,l.useImperativeHandle)(M,()=>({getAutomationsPayload:()=>{var a,l,n,i,o,r,s,c;const u=(()=>{var e;const t={};return Be&&null===Ue?t.install_software="Please select software to install.":void 0===P&&Be&&null!==Ue&&(null!=(e=null==ct?void 0:ct.length)?e:0)>0&&null===ze&&(t.install_software="Please select a package to install."),Ne&&null===Ge&&(t.run_script="Please select a script to run."),Pe&&null===Ke&&(t.resend_configuration_profile="Please select a configuration profile to resend."),t})();if(et(u),Object.keys(u).length>0)return{isValid:!1,isDirty:!1};const d=!t&&(Be!==he||Ue!==(null!=(l=null==(a=e.install_software)?void 0:a.software_title_id)?l:null)||ze!==(null!=(i=null==(n=e.install_software)?void 0:n.software_package_id)?i:null)||Ne!==_e||Ge!==(null!=(r=null==(o=e.run_script)?void 0:o.id)?r:null)||Pe!==ve||Ke!==(null!=(c=null==(s=e.resend_configuration_profile)?void 0:s.profile_uuid)?c:null)||Le!==Ee||xe!==be||Fe!==ge||void 0!==P&&$e!==Ae),m=we!==fe;return{isValid:!0,isDirty:d||m,policyUpdate:d?L((p=L(L({software_title_id:Be?Ue:null,software_package_id:Be?ze:null,script_id:Ne?Ge:null,profile_uuid:Pe?Ke:null},ce&&{calendar_events_enabled:Le}),ue&&{conditional_access_enabled:xe}),y={continuous_automations_enabled:Fe},C(p,k(y))),void 0!==P&&$e!==Ae&&{patch_when_closed:$e}):void 0,webhookOrTicketUpdate:m?{enabled:we}:void 0};var p,y}}));const pt=[{key:"ticket_webhook",label:(0,y.NH)(ie),checked:we&&re,onToggle:Se,isDisabled:!re,isLocked:!se}];t||pt.push({key:"install_software",label:"Install software",tooltip:l.createElement(x,{text:"The selected software will be installed when hosts fail the policy. Host counts will reset when new software is selected.",learnMoreUrl:"https://fleetdm.com/learn-more-about/policy-automation-install-software"}),checked:Be,onToggle:e=>{ke(e),e||tt("install_software")},isDisabled:!1,isLocked:void 0!==P,picker:Be&&void 0===P?l.createElement("div",{className:`${I}__software-pickers`},l.createElement(d.Ay,{name:"software-title",className:`${I}__row-picker`,isDisabled:ae,value:null!=(J=st.find(e=>e.value===String(null!=qe?qe:"")))?J:null,options:st,placeholder:"Select software",onCh
1ange:e=>{return t=e?Number(e.value):null,Qe(t),He(null),void(null!==t&&tt("install_software"));var t}}),ut.length>1&&l.createElement(d.Ay,{name:"software-package",className:`${I}__row-picker`,isDisabled:ae,value:null!=(Z=ut.find(e=>e.value===String(null!=We?We:"")))?Z:null,options:ut,placeholder:"Select package",onChange:e=>{return t=e?Number(e.value):null,He(t),void(null!==t&&tt("install_software"));var t}})):void 0},{key:"run_script",label:"Run script",tooltip:l.createElement(x,{text:"The selected script will run when hosts fail the policy. Host counts will reset when new scripts are selected.",learnMoreUrl:"https://fleetdm.com/learn-more-about/policy-automation-run-script"}),checked:Ne,onToggle:e=>{Te(e),e||tt("run_script")},isDisabled:!1,picker:Ne?l.createElement(d.Ay,{name:"script",className:`${I}__row-picker`,isDisabled:ae,value:null!=(ee=dt.find(e=>e.value===String(null!=Ge?Ge:"")))?ee:null,options:dt,placeholder:"Select script",onChange:e=>{return t=e?Number(e.value):null,Ye(t),void(null!==t&&tt("run_script"));var t}}):void 0},{key:"resend_configuration_profile",label:"Resend configuration profile",tooltip:l.createElement(x,{text:"The selected configuration profile will be resent when hosts fail the policy. Host counts will reset when new configuration profile is selected.",learnMoreUrl:`${r.CW}/policy-automation-resend-configuration-profile`}),checked:Pe,onToggle:e=>{Oe(e),e||tt("resend_configuration_profile")},isDisabled:!1,isLocked:Je,picker:Pe?l.createElement(d.Ay,{name:"profile",className:`${I}__row-picker`,isDisabled:ae,value:null!=(te=mt.find(e=>e.value===(null!=Ke?Ke:"")))?te:null,options:mt,placeholder:"Select profile",onChange:e=>{return t=e?String(e.value):null,Ve(t),void(null!==t&&tt("resend_configuration_profile"));var t}}):void 0},{key:"calendar_event",label:"Calendar event",tooltip:l.createElement(x,{text:"A calendar event will be created for end users if one of their hosts fail the policy.",learnMoreUrl:"https://www.fleetdm.com/learn-more-about/calendar-events"}),checked:Le&&ce,onToggle:Ie,isDisabled:!ce},{key:"conditional_access",label:"Conditional access",tooltip:l.createElement(x,{text:"Single sign-on will be blocked for end users whose hosts fail the policy.",learnMoreUrl:"https://fleetdm.com/learn-more-about/conditional-access"}),checked:xe&&ue,onToggle:De,isDisabled:!ue});const yt=Object.values(Ze).filter(e=>!!e);return l.createElement("div",{className:I},l.createElement("div",{className:`${I}__section`},yt.length>0&&l.createElement("div",{className:`${I}__errors`,role:"alert"},yt.map(e=>l.createElement("span",{key:e,className:`${I}__error`},e))),l.createElement("table",{className:`${I}__table`},l.createElement("tbody",null,pt.map(e=>l.createElement("tr",{key:e.key,className:`${I}__row${e.isDisabled||e.isLocked?` ${I}__row--disabled`:""}`},l.createElement("td",{id:"install_software"===e.key?"install-software-row-label":void 0,className:`${I}__row-label`},l.createElement(m.A,{renderChildren:t=>l.createElement(c.A,{name:e.key,value:e.checked,disabled:e.isDisabled||e.isLocked||t,onChange:e.onToggle},e.tooltip?l.createElement(p.A,{tipContent:e.tooltip,clickable:!0},e.label):e.label)})),l.createElement("td",{className:`${I}__row-trailing`},e.isDisabled?l.createElement("span",{className:`${I}__row-disabled-hint`},"Not enabled for ",T):e.picker))))),l.createElement("div",{className:`${I}__learn-more`},l.createElement(u.A,{url:"https://fleetdm.com/learn-more-about/policy-automations",text:"Learn more",newTab:!0})," ","about automation types and their supported platforms.")),O,!t&&"manual"!==P&&l.createElement("div",{className:`${I}__section`},l.createElement(m.A,{renderChildren:e=>l.createElement(c.A,{name:"continuous-automations-enabled",value:Fe,disabled:e||$e,onChange:lt,iconTooltipContent:$e?"Continuous automation can't be disabled when Patch when app is closed is selected.":void 0,helpText:l.createElement(l.Fragment,null,"If the install software automation does not resolve the policy after"," ",l.createElement(p.A,{tipContent:"Count does not include skipped installs and failed pre-install queries."},"10 attempts"),", Fleet will wait 24 hours before retrying.")},l.createElement(p.A,{tipContent:"Automations run on a host's first failure, and when a host's response changes from pass to fail. If enabled, script & software automations will also run on every subsequent failure.",clickable:!1},"Continuous")," ","software & script automations")})))})},5167:function(e,t,a){a.d(t,{S_:function(){return c},N:function(){return v},Fx:function(){return _}});var l=a(96540),n=a(74953),i=a(59333),o=a(52978),r=a(30104);const s="patch-automation-cta";var c=({storedPolicy:e,canEditPolicy:t,onAddAutomation:a,isAddingAutomation:c})=>{const u="patch"===e.type,d=!!e.install_software;if(!u||!e.patch_software||d||!t)return null;const m=(0,r.Yd)(e.patch_software.name,e.patch_software.display_name);return l.createElement("div",{className:s},l.createElement("span",{className:`${s}__label`},"Automatically patch ",m),l.createElement(i.A,{position:"top",renderChildren:e=>l.createElement(n.A,{onClick:a,variant:"secondary",disabled:e||c},c?"Adding...":l.createElement(l.Fragment,null,l.createElement(o.A,{name:"plus"})," Add automation"))}))},u=a(24179),d=a(78263),m=a(12968),p=a(20881),y=a(69906);const f="policy-automations-list",h={webhook:"Webhook",ticket:"Ticket"},_=(e,t,a)=>{const l=[];
1if(e.install_software){const t=(0,r.Yd)(e.install_software.name,e.install_software.display_name);l.push({name:t,iconName:e.install_software.name,type:"Software",isSoftware:!0,iconUrl:e.install_software.icon_url,link:(0,m.M8)(d.A.SOFTWARE_TITLE_DETAILS(e.install_software.software_title_id.toString()),{fleet_id:e.team_id}),sortOrder:0,sortName:t.toLowerCase()})}if(e.run_script&&l.push({name:e.run_script.name,type:"Script",graphicName:e.run_script.name.endsWith(".sh")?"file-sh":"file-ps1",sortOrder:1,sortName:e.run_script.name.toLowerCase()}),e.resend_configuration_profile&&l.push({name:e.resend_configuration_profile.name,type:"Profile",graphicName:"file-configuration-profile",sortOrder:2,sortName:e.resend_configuration_profile.name.toLowerCase()}),e.calendar_events_enabled&&l.push({name:"Maintenance window",type:"Calendar",graphicName:"calendar",sortOrder:3,sortName:""}),e.conditional_access_enabled&&l.push({name:"Block single sign-on",type:"Conditional access",graphicName:"lock",sortOrder:4,sortName:""}),t.includes(e.id)){const e=a?h[a]:"Webhook or ticket";l.push({name:e,type:"Other",graphicName:"settings",sortOrder:5,sortName:""})}return l.sort((e,t)=>e.sortOrder!==t.sortOrder?e.sortOrder-t.sortOrder:e.sortName.localeCompare(t.sortName)),l};var v=({storedPolicy:e,currentAutomatedPolicies:t,otherAutomationType:a})=>{const n=_(e,t,a);return 0===n.length?l.createElement("div",{className:`${f}__empty-state`},"No automations"):l.createElement("div",{className:f},n.map(e=>{var t;return l.createElement("div",{key:`${e.type}-${e.name}`,className:`${f}__row`},l.createElement("div",{className:`${f}__row-name`},e.isSoftware?l.createElement(y.A,{name:null!=(t=e.iconName)?t:e.name,url:e.iconUrl,size:"small"}):e.graphicName&&l.createElement(p.A,{name:e.graphicName,key:`${e.graphicName}-graphic`,className:`${f}__row-graphic ${"file-sh"===e.graphicName||"file-ps1"===e.graphicName||"file-configuration-profile"===e.graphicName?"scale-40-24":""}`}),e.link?l.createElement(u.N_,{to:e.link},e.name):e.name))}))}},14648:function(e,t,a){a.d(t,{fb:function(){return i},gd:function(){return l},zj:function(){return n}});const l="Add a label to target a group of hosts.",n={id:1,name:"Is osquery running?",query:"SELECT 1 FROM osquery_info WHERE start_time > 1;",description:"Checks if the osquery process has started on the host.",author_id:42,author_name:"John",author_email:"[email protected]",resolution:"Resolution steps",platform:"",passing_host_count:2e3,failing_host_count:300,created_at:"",updated_at:"",critical:!1},i=[{key:1,query:"SELECT score FROM (SELECT case when COUNT(*) = 2 then 1 ELSE 0 END AS score FROM processes WHERE (name = 'clamd') OR (name = 'freshclam')) WHERE score == 1;",name:"Antivirus healthy (Linux)",description:"If ClamAV and Freshclam are not running, the workstation lacks active virus scanning, increasing malware infection risk.",resolution:"ClamAV and Freshclam will be checked and restarted if necessary, restoring virus protection.",critical:!1,platform:"linux"},{key:2,query:"SELECT score FROM (SELECT case when COUNT(*) = 2 then 1 ELSE 0 END AS score FROM plist WHERE (key = 'CFBundleShortVersionString' AND path = '/Library/Apple/System/Library/CoreServices/XProtect.bundle/Contents/Info.plist' AND value>=2162) OR (key = 'CFBundleShortVersionString' AND path = '/Library/Apple/System/Library/CoreServices/MRT.app/Contents/Info.plist' and value>=1.93)) WHERE score == 1;",name:"Antivirus healthy (macOS)",description:"If XProtect or MRT are not updated, the system risks exposure to malware not covered by older definitions.",resolution:"Update XProtect and MRT to the latest versions, bolstering your system's defense against new threats.",critical:!1,platform:"darwin"},{key:3,query:"SELECT 1 from windows_security_center wsc CROSS JOIN windows_security_products wsp WHERE antivirus = 'Good' AND type = 'Antivirus' AND signatures_up_to_date=1;",name:"Antivirus healthy (Windows)",description:"Lack of active, updated antivirus exposes the workstation to malware and security threats.",resolution:"Ensure Windows Defender or your third-party antivirus is running, up to date, and visible in the Windows Security Center.",critical:!1,platform:"windows"},{key:4,query:"SELECT 1 FROM managed_policies WHERE domain = 'com.apple.loginwindow' AND name = 'com.apple.login.mcx.DisableAutoLoginClient' AND value = 1 LIMIT 1;",name:"Automatic login disabled (macOS)",description:"Auto-login being enabled increases risk of unauthorized access if the workstation is compromised.",resolution:"Auto-login will be disabled to secure the workstation against unauthorized use.",critical:!1,platform:"darwin",mdm_required:!0},{key:5,query:"SELECT 1 FROM (SELECT encrypted, path FROM disk_encryption FULL OUTER JOIN mounts ON mounts.device_alias = disk_encryption.name) WHERE encrypted = 1 AND path = '/';",name:"Full disk encryption enabled (Linux)",description:"Unencrypted root filesystem means
1sensitive data might be easily accessible to unauthorized parties, increasing data breach risks.",resolution:"Ensure the image deployed to your Linux workstation includes full disk encryption.",critical:!1,platform:"linux"},{key:6,query:"SELECT 1 FROM disk_encryption WHERE user_uuid IS NOT '' AND filevault_status = 'on' LIMIT 1;",name:"Full disk encryption enabled (macOS)",description:"If FileVault is off, the user's data is vulnerable to unauthorized access and potential data breaches.",resolution:"FileVault will be turned on to enable full disk encryption.",critical:!1,platform:"darwin"},{key:7,query:"SELECT 1 FROM bitlocker_info WHERE drive_letter='C:' AND protection_status=1;",name:"Full disk encryption enabled (Windows)",description:"If BitLocker is disabled, the workstation's data is at risk of unauthorized access and theft.",resolution:"Full disk encryption will be enabled to secure data.",critical:!1,platform:"windows"},{key:8,query:"SELECT 1 FROM gatekeeper WHERE assessments_enabled = 1;",name:"Gatekeeper enabled (macOS)",description:"Disabled Gatekeeper increases risk of installing potentially malicious apps.",resolution:"Gatekeeper will be enabled to ensure only trusted software is run on the device.",critical:!1,platform:"darwin"},{key:9,query:"SELECT 1 FROM mdm WHERE enrolled='true';",name:"MDM enrolled (macOS)",description:"Workstations not enrolled to MDM miss critical security updates and remote management capabilities.",resolution:"Enroll device to MDM.",critical:!1,platform:"darwin"},{key:10,query:"SELECT 1 FROM managed_policies WHERE domain = 'com.apple.Terminal' AND name = 'SecureKeyboardEntry' AND value = 1 LIMIT 1;",name:"Secure keyboard entry for Terminal application enabled (macOS)",description:"If secure keyboard entry is disabled, it increases vulnerability to keyloggers and other snooping software.",resolution:"Secure keyboard entry will be enabled to enhance protection against keystroke logging.",critical:!1,platform:"darwin",mdm_required:!0},{key:11,query:"SELECT 1 FROM sip_config WHERE config_flag = 'sip' AND enabled = 1;",name:"System Integrity Protection enabled (macOS)",description:"Disabled System Integrity Protection increases risk of unauthorized system modifications and malware.",resolution:"System Integrity Protection will be enabled by running the following command: /usr/sbin/spctl --master-enable.",critical:!1,platform:"darwin"},{key:12,query:"SELECT 1 FROM alf WHERE global_state >= 1;",name:"Firewall enabled (macOS)",description:"If the firewall is disabled, the workstation is vulnerable to unauthorized network access and attacks.",resolution:"The firewall will be enabled to protect against external threats.",critical:!1,platform:"darwin"},{key:13,query:"SELECT 1 FROM managed_policies WHERE name='askForPassword' AND value='1';",name:"Screen lock enabled (macOS)",description:"Disabling password prompts increases the risk of unauthorized system access.",resolution:"Configuration changes will enforce immediate password prompts to mitigate unauthorized access risks.",critical:!1,platform:"darwin",mdm_required:!0},{key:14,query:"SELECT 1 FROM registry WHERE path = 'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\InactivityTimeoutSecs' AND CAST(data as INTEGER) <= 1800;",name:"Screen lock enabled (Windows)",description:"Devices with inactive timeout settings over 30 minutes risk prolonged unauthorized access if left unattended, exposing sensitive data.",resolution:"Enable the Interactive Logon: Machine inactivity limit setting with a value of 1800 seconds or lower.",critical:!1,platform:"windows"},{key:15,query:"SELECT 1 FROM (SELECT cast(lengthtxt as integer(2)) minlength FROM (SELECT SUBSTRING(length, 1, 2) AS lengthtxt FROM (SELECT policy_description, policy_identifier, split(policy_content, '{', 1) AS length FROM password_policy WHERE policy_identifier LIKE '%minLength')) WHERE minlength >= 10);",name:"Password requires 10 or more characters (macOS)",description:"Password policies requiring less than 10 characters increase vulnerability to brute-force attacks",resolution:"Password requirements will be strengthened to a minimum of 10 characters.",critical:!1,platform:"darwin"},{key:16,query:"SELECT 1 FROM os_version WHERE version >= '14.6.1' OR version >= '15.0';",name:"Operating system up to date (macOS)",description:"Using an outdated macOS version risks exposure to security vulnerabilities and potential system instability.",resolution:"We will update your macOS to the latest version to enhance security and stability.",critical:!1,platform:"darwin"},{key:17,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.SoftwareUpdate' AN
1D name='AutomaticCheckEnabled' AND value=1 LIMIT 1;",name:"Automatic updates enabled (macOS)",description:"Checks that a mobile device management (MDM) solution configures the Mac to automatically check for updates.",resolution:"Contact your IT administrator to ensure your Mac is receiving a profile that enables automatic updates.",critical:!1,platform:"darwin",mdm_required:!0},{key:18,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.SoftwareUpdate' AND name='AutomaticDownload' AND value=1 LIMIT 1;",name:"Automatic update downloads enabled (macOS)",description:"Checks that a mobile device management (MDM) solution configures the Mac to automatically download updates.",resolution:"Contact your IT administrator to ensure your Mac is receiving a profile that enables automatic update downloads.",critical:!1,platform:"darwin"},{key:19,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.SoftwareUpdate' AND name='AutomaticallyInstallAppUpdates' AND value=1 LIMIT 1;",name:"Installation of application updates is enabled (macOS)",description:"When the Mac is not configureed to automatically install updates to Apple applications, this risks security vulnerabilities and potential exploitation.",resolution:"The automatic software update feature will be enabled to ensure that the workstation receives timely updates.",critical:!1,platform:"darwin"},{key:20,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.SoftwareUpdate' AND name='CriticalUpdateInstall' AND value=1 LIMIT 1;",name:"Automatic security and data file updates is enabled (macOS)",description:"If the Mac is not automatically downloading updates to built-in macOS security tools, critical updates may not be installed, leaving the device vulnerable to potential exploitation.",resolution:"Enable automatic security and data update installation.",critical:!1,platform:"darwin",mdm_required:!0},{key:21,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.SoftwareUpdate' AND name='AutomaticallyInstallMacOSUpdates' AND value=1 LIMIT 1;",name:"Automatic installation of operating system updates is enabled (macOS)",description:"If automatic macOS updates are not enabled, critical updates may not be installed, leaving the device vulnerable to potential exploitation.",resolution:"Enable automatic installation of operating system updates.",critical:!1,platform:"darwin",mdm_required:!0},{key:22,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.applicationaccess' AND name='forceAutomaticDateAndTime' AND value=1 LIMIT 1;",name:"Time and date are configured to be updated automatically (macOS)",description:"If the automatic setting of date and time is disabled, there could be synchronization issues with other systems, services, or applications.",resolution:"Enable automatic time and date configuration.",critical:!1,platform:"darwin",mdm_required:!0},{key:23,query:"SELECT 1 WHERE EXISTS (SELECT CAST(value as integer(4)) valueint from managed_policies WHERE domain = 'com.apple.screensaver' AND name = 'askForPasswordDelay' AND valueint <= 60 LIMIT 1) AND EXISTS (SELECT CAST(value as integer(4)) valueint from managed_policies WHERE domain = 'com.apple.screensaver' AND name = 'idleTime' AND valueint <= 1140 LIMIT 1) AND EXISTS (SELECT 1 from managed_policies WHERE domain='com.apple.screensaver' AND name='askForPassword' AND value=1 LIMIT 1);",name:"Lock screen after inactivity of 20 minutes or less (macOS)",description:"Inadequate screen saver security settings could potentially allow unauthorized access to the workstation if left unattended for extended periods.",resolution:"Ensure screen saver is enabled after inactivity of 20 minutes or less.",critical:!1,platform:"darwin",mdm_required:!0},{key:24,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.MCX' AND name='forceInternetSharingOff' AND value='1' LIMIT 1;",name:"Internet sharing blocked (macOS)",description:"Unauthorized Internet sharing could potentially expose sensitive network resources to external threats.",resolution:"The Internet sharing setting will be disabled",critical:!1,platform:"darwin",mdm_required:!0},{key:25,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.applicationaccess' AND name='allowContentCaching' AND value='0' LIMIT 1;",name:"Content caching is disabled (macOS)",description:"Enabling content caching could lead to unauthorized caching of sensitive data, potentially exposing it to unauthorized access.",resolution:"Content caching will be disabled.",critical:!1,platform:"darwin",mdm_required:!0},{key:26,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.AdLib' AND name='forceLimitAdTracking' AND value='1' LIMIT 1;",name:"Ad tracking is limited (macOS)",description:"Failure to limit ad tracking could result in excessive tracking of user behavior and preferences by advertisers, compromising privacy.",resolution:"Advertisement tracking will be disabled.",critical:!1,platform:"darwin"},{key:27,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.icloud.managed' AND name='DisableCloudSync' AND value='1' LIMIT 1;",name:"iCloud Desktop and Document sync is disabled (macOS)",description:"Checks that a mobile device management (MDM) solution configures the Mac to prevent iCloud Desktop and Documents sync.",resolution:"Contact your IT administrator to ensure your Mac is receiving a profile to prevent iCloud Desktop and Documents sync.",critical:!1,platform:"darwin",mdm_required:!0},{key:28,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.security.firewall' AND name='EnableLogging' AND value='1' LIMIT 1;",name:"Firewall logging is enabled (macOS)",description:"Without firewall logging enabled, it becomes difficult to monitor and track network traffic, increasing the risk of undetected malicious activities or unauthorized access.",resolution:"Firewall logging will be enabled on the workstation.",critical:!1,platform:"darwin",mdm_required:!0},{key:29,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.mcx' AND name='DisableGuestAccount' AND value='1' LIMIT 1;",name:"Guest account disabled (macOS)",description:"Use of the guest account could allow unauthorized users to access the system, potentially leading to unauthorized access to sensitive data and security breaches.",resolution:"The guest account will be disabled.",critical:!1,platform:"darwin",mdm_required:!0},{key:30,query:"SELECT 1 FROM managed_policies WHERE domain='com.apple.AppleFileServer' AND name='guestAccess' AND value='0' LIMIT 1;",name:"Guest access to shared folders is disabled (macOS)",description:"Guest access to shared folders could allow unauthorized users to access sensitive files and data, potentially leading to data breaches or unauthorized modifications.",resolution:"Guest access to shared folders will be disabled.",critical:!1,platform:"darwin",mdm_required:!0},{key:31,query:"SELECT 1 FROM registry WHERE path LIKE 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\DomainProfile\\EnableFirewall' AND CAST(data as integer) = 1;",name:"Windows Firewall, domain profile enabled (Windows)",description:"If the Windows Firewall is not enabled for the domain profile, the workstation may be more vulnerable to unauthorized network access and potential security breaches.",resolution:"The Windows Firewall will be enabled for the domain profile.",critical:!1,platform:"windows"},{key:32,query:"SELECT 1 FROM registry WHERE path LIKE 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\EnableFirewall' AND CAST(data as integer) = 1;",name:"Windows Firewall, private profile enabled (Windows)",description:"If the Windows Firewall is not enabled for the private profile, the workstation may be more susceptible to unauthorized access and potential security breaches, particularly when connected to private networks.",resolution:"The Windows Firewall will be enabled for the private profile",critical:!1,platform:"windows"},{key:33,query:"SELECT 1 FROM registry WHERE path LIKE 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\PublicProfile\\EnableFirewall' AND CAST(data as integer) = 1;",name:"Windows Firewall, public profile enabled (Windows)",description:"If the Windows Firewall is not enabled for the public profile, the workstation may be more vulnerable to unauthorized access and potential security threats, especially when connected to public networks.",resolution:"The Windows Firewall will be enabled for the public profile.",critical:!1,platform:"windows"},{key:34,query:"SELECT 1 FROM windows_optional_features WHERE name = 'SMB1Protocol-Client' AND state != 1;",name:"SMBv1 client driver disabled (Windows)",description:"Leaving the SMBv1 client enabled increases vulnerability to security threats and potential exploitation by malicious actors.",resolution:"The SMBv1 client will be disabled.",critical:!1,platform:"windows"},{key:35,query:"SELECT 1 FROM windows_optional_features WHERE name = 'SMB1Protocol-Server' AND state != 1",name:"SMBv1 server disabled (Windows)",description:"Leaving the SMBv1 server enabled exposes the workstation to potential security vulnerabilities and exploitation by malicious actors.",resolution:"The SMBv1 server will be disabled.",critical:!1,platform:"windows"},{key:36,query:"SELECT 1 FROM registry WHERE path LIKE 'HKEY_LOCAL_MACHINE\\S
1oftware\\Policies\\Microsoft\\Windows NT\\DNSClient\\EnableMulticast' AND CAST(data as integer) = 0;",name:"LLMNR disabled (Windows)",description:"If the workstation does not have LLMNR disabled, it could be vulnerable to DNS spoofing attacks, potentially leading to unauthorized access or data interception.",resolution:"LLMNR will be disabled on your system.",critical:!1,platform:"windows"},{key:37,query:"SELECT 1 FROM registry WHERE path LIKE 'HKEY_LOCAL_MACHINE\\Software\\Policies\\Microsoft\\Windows\\Windows\\Update\\AU\\NoAutoUpdate' AND CAST(data as integer) = 0;",name:"Automatic updates enabled (Windows)",description:"Enabling automatic updates ensures the computer downloads and installs security and other important updates automatically.",resolution:"Automatic updates will be enabled.",critical:!1,platform:"windows"},{key:38,query:"SELECT EXISTS(SELECT 1 FROM file WHERE filename like '%Emergency Kit%.pdf' AND (path LIKE '/Users/%%/Downloads/%%' OR path LIKE '/Users/%%/Desktop/%%')) as does_1p_ek_exist;",name:"No 1Password emergency kit stored on desktop or in downloads (macOS)",description:"Storing the 1Password emergency kit on the desktop or in the downloads folder increases the risk of unauthorized access to sensitive credentials if the workstation is compromised or accessed by unauthorized users.",resolution:"1Password emergency kits must be printed and stored in a physically secure location.",critical:!1,platform:"darwin"},{key:39,query:"SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM users CROSS JOIN user_ssh_keys USING (uid) WHERE encrypted='0');",name:"No unencrypted SSH keys present",description:"Having unencrypted SSH keys poses the risk of unauthorized access to sensitive systems and data if the workstation is compromised.",resolution:"Any unencrypted SSH keys will be encrypted or removed from the workstation.",critical:!1,platform:"darwin"},{key:40,query:"SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM keychain_items WHERE label LIKE '%ABCDEFG%' LIMIT 1);",name:"No Apple signing or notarization credentials secrets stored (macOS)",description:"Storing Apple signing or notarization credentials poses the risk of unauthorized access to sensitive development assets and potential compromise of software integrity.",resolution:"Apple signing or notarization credentials secrets will be removed from the workstation.",critical:!1,platform:"darwin"}]},74496:function(e,t,a){a.r(t),a.d(t,{default:function(){return Se}});var l=a(96540),n=a(75942),i=a(24740),o=a(78263),r=a(68774),s=a(62131),c=a(43015),u=a(10664),d=a(19677),m=a(9467),p=a(89937),y=a(12968),f=a(38944),h=a(84945),_=a(74953),v=a(83573),E=a(20881),b=a(52978),g=a(827),A=a(29448),w=a(45584),S=a(52603),C=a(25809),k=a(24039),N=a(17047),T=a(67310),P=a(41820),O=a(69906),L=a(5167),I=a(24179),x=a(99958);const D="policy-label-modal",M=({labels:e,scopeLabel:t,description:a,getLabelPath:n})=>l.createElement("div",{className:`${D}__section`},l.createElement("span",null,a," ",l.createElement("b",null,t)," of these labels:"),l.createElement("ul",{className:`${D}__label-list`},e.map(e=>l.createElement("li",{key:e.id,className:`${D}__label-item`},n?l.createElement(I.N_,{to:n(e.id)},e.name):l.createElement("span",null,e.name)))));var R=({includeLabels:e,includeScopeLabel:t,excludeLabels:a,excludeScopeLabel:n,getLabelPath:i,onClose:o})=>l.createElement(x.A,{title:"Labels",onExit:o,onEnter:o,className:D},l.createElement("div",{className:`${D}__body`},e&&t&&l.createElement(M,{labels:e,scopeLabel:t,description:"Policy targets hosts that",getLabelPath:i}),a&&n&&l.createElement(M,{labels:a,scopeLabel:n,description:"Policy excludes hosts that",getLabelPath:i}),l.createElement("div",{className:"modal-cta-wrap"},l.createElement(_.A,{onClick:o},"Done"))));const $="policy-automations-modal";var F=({storedPolicy:e,currentAutomatedPolicies:t,otherAutomationType:a,onClose:n})=>l.createElement(x.A,{title:"Automations",onExit:n,onEnter:n,className:$},l.createElement("div",{className:$},l.createElement("div",{className:`${$}__automations`},l.createElement(L.N,{storedPolicy:e,currentAutomatedPolicies:t,otherAutomationType:a}),l.createElement("p",{className:`${$}__footer-text`},e.continuous_automations_enabled?l.createElement(l.Fragment,null,"Software and script automations run ",l.createElement("b",null,"every time")," Fleet receives a failing response.",l.createElement("br",null),"All other automations run on a host's first failure, or when a host's response changes from pass to fail."):"Automations run on a host's first failure, or when a host's response changes from pass to fail.")),l.createElement("div",{className:"modal-cta-wrap"},l.createElement(_.A,{onClick:n},"Done")))),q=a(32485),Q=a.n(q),W=a(46157),H=a(18165),j=a(34724),B=a(2367),U=a(79519),z=a(90710),G=a(41995),Y=a(40925),K=a(75679),V=a(24228),X=a(24292),J=a(47721),Z=a(86695);const ee=(e,t)=>
1t?`${e} (${t})`:e,te=e=>{const{type:t,status:a,details:l}=e,n="error"===a;switch(t){case J.M.InstalledSoftware:case J.M.InstalledAppStoreApp:return(null==l?void 0:l.skipped_install)?ee("Patch skipped",null==l?void 0:l.software_title):ee(n?"Software failed":"Software installed",null==l?void 0:l.software_title);case J.M.RanScript:return ee(n?"Script failed":"Script ran",null==l?void 0:l.script_name);case J.M.RanAutomationCalendarEvent:return"Calendar event created";case J.M.FailedAutomationCalendarEvent:return"Calendar event failed";case J.M.RanAutomationConditionalAccess:return"Single sign-on blocked";case J.M.FailedAutomationConditionalAccess:return"Single sign-on failed";case J.M.RanAutomationWebhook:return"Webhook queued";case J.M.FailedAutomationWebhook:return"Webhook failed";case J.M.RanAutomationTicket:return"Ticket queued";case J.M.FailedAutomationTicket:return"Ticket failed";case J.M.ResentConfigurationProfile:return ee("Configuration profile resent",null==l?void 0:l.profile_name);default:return n?"Automation failed":"Automation ran"}},ae=e=>{var t;return(null==(t=e.details)?void 0:t.skipped_install)?{name:"error-outline",color:"ui-fleet-black-50"}:"error"===e.status?{name:"error-outline"}:{name:"success-outline"}},le=e=>{var t,a;return(null==(t=e.details)?void 0:t.skipped_install)?Z.kU:"error"===e.status&&(null==(a=e.details)?void 0:a.error_response)?e.details.error_response:e.output||e.post_install_output||e.pre_install_output||""};var ne=a(57390),ie=a(24432),oe=a(10146);const re="policy-automation-activity-details-modal";var se=({activity:e,onCancel:t,onResetPolicy:a})=>{var n;const{created_at:i,host_id:r,host_display_name:s}=e,c=le(e),u=e.type===J.M.InstalledSoftware,d=(e,t)=>t?l.createElement(oe.A,{key:e,variant:"code",label:l.createElement("div",{className:`${re}__details-label`},l.createElement("span",null,e),l.createElement(ne.A,{copyText:t,size:"small",ariaLabel:`Copy ${e.toLowerCase()}`}))},t):null;return l.createElement(x.A,{title:"Details",onExit:t,className:re},l.createElement("div",{className:`${re}__modal-content`},l.createElement("div",{className:`${re}__row`},l.createElement(v.A,{title:"Host",value:s?l.createElement(ie.A,{url:o.A.HOST_DETAILS(r),text:s}):"---"}),l.createElement(v.A,{title:"Time",value:l.createElement(X.T,{timeString:i})})),l.createElement(v.A,{title:"Status",value:l.createElement("span",{className:`${re}__status`},l.createElement(b.A,{name:ae(e).name,color:ae(e).color}),te(e))}),u?l.createElement(l.Fragment,null,d("Pre-install query output",(null==(n=e.details)?void 0:n.skipped_install)?Z.JH:e.pre_install_output),d("Details",e.output),d("Post-install script output",e.post_install_output)):d("Details",c||null),l.createElement("div",{className:"modal-cta-wrap"},l.createElement(_.A,{onClick:t},"Done"),a&&l.createElement(_.A,{variant:"secondary",onClick:a,className:`${re}__reset`,icon:"refresh"},"Reset policy"))))};const ce="policy-reset-modal";var ue=({policy:e,hostDisplayName:t,currentAutomatedPolicies:a,otherAutomationType:n,isResetting:i,onSubmit:o,onCancel:r})=>{const s=!!t&&(0,L.Fx)(e,a,n).length>0;return l.createElement(x.A,{title:"Reset policy",onExit:r,className:ce},l.createElement("div",{className:`${ce}__modal-content`},l.createElement("p",null,"Resetting this policy will clear pass/fail results for"," ",t?l.createElement("b",null,t):"all hosts"," until its next check in."),l.createElement("div",null,s?l.createElement(l.Fragment,null,l.createElement("span",null,"Automations will re-run if the host fails the policy:"),l.createElement(L.N,{storedPolicy:e,currentAutomatedPolicies:a,otherAutomationType:n})):l.createElement("span",null,"Automations will re-run if the host fails the policy.")),l.createElement("div",{className:"modal-cta-wrap"},l.createElement(_.A,{onClick:o,isLoading:i,disabled:i},"Reset"),l.createElement(_.A,{variant:"secondary",onClick:r},"Cancel"))))},de=Object.defineProperty,me=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,ye=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,_e=(e,t,a)=>t in e?de(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;const ve="policy-automations-activities-table",Ee="created_at",be="desc",ge=[{label:"All",value:""},{label:"Successful",value:"success"},{label:"Failed",value:"error"}];var Ae=({policy:e,currentAutomatedPolicies:t,otherAutomationType:a,canResetPolicy:i})=>{var s,c,d;const{id:m}=e,y=(0,n.useQueryClient)(),{config:f}=(0,l.useContext)(r.BR),{activity_expiry_enabled:h,activity_expiry_window:v}=null!=(s=null==f?void 0:f.activity_expiry_settings)?s:{},[E,g]=(0,l.useState)(0),[A,w]=(0,l.useState)(""),[S,k]=(0,l.useState)(""),[N,T]=(0,l.useState)(Ee),[P,O]=(0,l.useState)(be),[L,I]=(0,l.useState)(null),[x,D]=(0,l.useState)(!1),[M,R]=(0,l.useState)(void 0),{data:$,isLoading:F,isError:q}
1=(0,n.useQuery)(["policyAutomationActivities",m,E,50,N,P,A,S],()=>u.A.getAutomationActivities({policyId:m,page:E,perPage:50,orderKey:N,orderDirection:P,query:A,status:S}),(J=((e,t)=>{for(var a in t||(t={}))fe.call(t,a)&&_e(e,a,t[a]);if(ye)for(var a of ye(t))he.call(t,a)&&_e(e,a,t[a]);return e})({},p.QL),me(J,pe({keepPreviousData:!0}))));var J;const{mutateAsync:Z,isLoading:ee}=(0,n.useMutation)(()=>u.A.reset(m),{onSuccess:()=>{W.me.success("Policy reset successfully."),y.invalidateQueries(["policyAutomationActivities",m]),y.invalidateQueries(["policy",m]),D(!1)},onError:e=>{W.me.error("Couldn't reset policy. Please try again.",{response:e})}}),ne=(0,l.useCallback)(e=>{const{pageIndex:t,sortHeader:a,sortDirection:l}=e;T(a),O(l),g(t)},[]),ie=(0,l.useCallback)(e=>{w(e),g(0)},[]),oe=(0,l.useCallback)(e=>{var t;k(null!=(t=null==e?void 0:e.value)?t:""),g(0)},[]),re=(0,l.useCallback)(()=>{R(void 0),D(!0)},[]),ce=(0,l.useCallback)(()=>{R(null==L?void 0:L.host_display_name),I(null),D(!0)},[L]),de=""!==A||""!==S,Ae=(0,l.useCallback)(()=>{if(de)return l.createElement(B.A,{header:"No automation runs match your filters",info:"Try changing your search or status filter."});const e=h&&v?`Automation history is retained for ${v} ${(0,H.td)(v,"day")}.`:"Automation history will appear here.";return l.createElement(B.A,{header:"No automation runs",info:e})},[de,h,v]),we=(0,l.useMemo)(()=>((e,t)=>[{Header:e=>l.createElement(Y.A,{value:"Automation",isSortedDesc:e.column.isSortedDesc}),id:"activity_type",accessor:e=>e.type,Cell:t=>{const a=t.row.original,n=ae(a);return l.createElement("div",{className:`${e}__automation-cell`},l.createElement(b.A,{name:n.name,color:n.color}),l.createElement(C.A,{value:te(a)}))}},{Header:"Host",disableSortBy:!0,id:"host_display_name",accessor:"host_display_name",Cell:e=>{const{host_id:t,host_display_name:a}=e.row.original;return a?l.createElement(V.A,{value:a,path:o.A.HOST_DETAILS(t),customOnClick:e=>e.stopPropagation()}):l.createElement(K.A,{value:"Host deleted",grey:!0,italic:!0})}},{Header:e=>l.createElement(Y.A,{value:"Time",isSortedDesc:e.column.isSortedDesc}),id:"created_at",accessor:"created_at",Cell:e=>l.createElement(K.A,{value:l.createElement(X.T,{timeString:e.row.original.created_at})})},{Header:"Details",disableSortBy:!0,id:"details",accessor:e=>e.id,Cell:a=>{const n=a.row.original,i=le(n);return l.createElement(_.A,{className:`${e}__details-cell`,variant:"subdued",onClick:()=>t(n)},l.createElement("span",{className:`${e}__details-text`},i||"---"),l.createElement(b.A,{name:"info-outline",className:"row-hover-button",color:"ui-fleet-black-50"}))}}])(ve,I),[]),Se=null!=(c=null==$?void 0:$.count)?c:0,Ce=Se>0||de;return q?l.createElement(U.A,{description:"Could not load automation runs."}):l.createElement("div",{className:ve},l.createElement("div",{className:Q()(`${ve}__header`,{[`${ve}__header--inline`]:!Ce})},l.createElement("h2",{className:`${ve}__title`},"Automation runs"),l.createElement("div",{className:`${ve}__controls-row`},Ce&&l.createElement("span",{className:`${ve}__count`},Se," ",(0,H.td)(Se,"run")),l.createElement("div",{className:`${ve}__controls`},i&&l.createElement(_.A,{variant:"subdued",onClick:re,icon:"refresh",iconPosition:"right"},"Reset policy"),Ce&&l.createElement(l.Fragment,null,l.createElement(G.A,{name:"automation-status-filter",className:`${ve}__status-filter`,options:ge,value:S,onChange:oe,variant:"table-filter",isSearchable:!1}),l.createElement("div",{className:`${ve}__search`},l.createElement(z.A,{placeholder:"Search hosts",defaultValue:A,onChange:ie})))))),l.createElement(j.A,{columnConfigs:we,data:null!=(d=null==$?void 0:$.activities)?d:[],getRowId:e=>`${e.id}-${e.host_id}`,isLoading:F,manualSortBy:!0,pageIndex:E,pageSize:50,disableNextPage:!(null==$?void 0:$.meta.has_next_results),defaultSortHeader:Ee,defaultSortDirection:be,disableTableHeader:!0,searchable:!1,onQueryChange:ne,emptyComponent:Ae,showMarkAllPages:!1,isAllPagesSelected:!1,disableMultiRowSelect:!0,onClickRow:e=>I(e.original)}),L&&l.createElement(se,{activity:L,onCancel:()=>I(null),onResetPolicy:i?ce:void 0}),x&&l.createElement(ue,{policy:e,hostDisplayName:M,currentAutomatedPolicies:t,otherAutomationType:a,isResetting:ee,onSubmit:Z,onCancel:()=>D(!1)}))};
1const we="policy-details-page";var Se=({router:e,params:{id:t},location:a})=>{const I=t?parseInt(t,10):null,x=(0,i.useErrorHandler)(),{currentUser:D,isGlobalAdmin:M,isGlobalMaintainer:$,isGlobalTechnician:q,isOnGlobalTeam:Q,config:W}=(0,l.useContext)(r.BR),{isRouteOk:H,teamIdForApi:j,isTeamMaintainerOrTeamAdmin:B,isTeamTechnician:U,isObserverPlus:z}=(0,f.Ay)({location:a,router:e,includeAllTeams:!0,includeNoTeam:!0,permittedAccessByTeamRole:{admin:!0,maintainer:!0,observer:!0,observer_plus:!0,technician:!0}}),[G,Y]=(0,l.useState)(!1),[K,V]=(0,l.useState)(!1),[X,J]=(0,l.useState)(!1);(null===I||isNaN(I))&&e.push(o.A.MANAGE_POLICIES);const{isLoading:Z,data:ee,error:te}=(0,n.useQuery)(["policy",I],()=>u.A.load(I),{enabled:H&&!!I,refetchOnWindowFocus:!1,retry:!1,select:e=>e.policy,onError:e=>x(e)}),ae=null==ee?void 0:ee.team_id,{data:le}=(0,n.useQuery)(["team",ae],()=>d.A.load(ae),{enabled:null!=ae&&ae>=s.Rp,refetchOnWindowFocus:!1}),ne=((e,t)=>{var a,l;return e?null===e.team_id?s.Op.name:0===e.team_id?s.bn.name:null!=(l=null==(a=null==t?void 0:t.team)?void 0:a.name)?l:null:null})(ee,le),ie=ee?(e=>{var t,a,l,n;let i,o,r,s;return(null==(t=e.labels_include_any)?void 0:t.length)?(i=e.labels_include_any,o="have any"):(null==(a=e.labels_include_all)?void 0:a.length)&&(i=e.labels_include_all,o="have all"),(null==(l=e.labels_exclude_any)?void 0:l.length)?(r=e.labels_exclude_any,s="exclude any"):(null==(n=e.labels_exclude_all)?void 0:n.length)&&(r=e.labels_exclude_all,s="exclude all"),{includeLabels:i,includeScopeLabel:o,excludeLabels:r,excludeScopeLabel:s}})(ee):null,{state:oe,policyIds:re}=(0,P.LM)(null==(null==ee?void 0:ee.team_id)?null!=W?W:void 0:null==le?void 0:le.team),se="disabled"===oe?void 0:oe;(0,l.useEffect)(()=>{(null==ee?void 0:ee.name)?document.title=`${ee.name} | Policies | ${p.DI}`:document.title=`Policies | ${p.DI}`},[a.pathname,null==ee?void 0:ee.name]);const ce=null===(null==ee?void 0:ee.team_id),ue=(M||$||B)&&!(ce&&!Q),de=M||$||q||B||U,me=z||B||M||$||q||U,pe
1=null==W?void 0:W.server_settings.live_query_disabled,ye=(0,y.M8)(o.A.MANAGE_POLICIES,{fleet_id:j}),fe=()=>V(!0),he=()=>J(!0);return H?l.createElement(g.A,{className:we},Z?l.createElement(w.A,null):l.createElement(l.Fragment,null,l.createElement("div",{className:`${we}__header-links`},l.createElement(h.A,{text:"Back to policies",path:ye})),!Z&&!te&&l.createElement(l.Fragment,null,l.createElement("div",{className:`${we}__title-bar`},l.createElement("div",{className:`${we}__name-description`},l.createElement("h1",{className:`${we}__policy-name`},l.createElement(C.A,{value:null==ee?void 0:ee.name,fixedPositionStrategy:!0}),(null==ee?void 0:ee.critical)&&l.createElement(S.A,{tipContent:"This policy has been marked as critical.",showArrow:!0,underline:!1},l.createElement(b.A,{className:"critical-policy-icon",name:"policy",color:"ui-fleet-black-50"}))),l.createElement(A.A,{className:`${we}__policy-description`,content:null==ee?void 0:ee.description})),l.createElement("div",{className:`${we}__action-button-container`},l.createElement(_.A,{className:`${we}__show-query-btn`,onClick:()=>Y(!0),variant:"secondary"},"Show query"),me&&l.createElement(_.A,{className:`${we}__run`,variant:"secondary",onClick:()=>{I&&e.push((0,y.M8)(o.A.LIVE_POLICY(I),{fleet_id:j}))},disabled:!!pe,icon:"run",iconPosition:"right"},"Run policy"),ue&&l.createElement(_.A,{onClick:()=>{I&&e.push((0,y.M8)(o.A.EDIT_POLICY(I),{fleet_id:j}))},className:`${we}__edit-policy-btn`},"Edit policy"))),l.createElement("div",{className:`${we}__details`},l.createElement("div",{className:`${we}__properties`},ne?l.createElement(v.A,{className:`${we}__fleet`,title:"Fleet",value:ne}):null,(()=>{if(!(null==ee?void 0:ee.platform))return null;const e=ee.platform.split(",").map(e=>e.trim()).filter(e=>e in c.uc);return 0===e.length?null:l.createElement(v.A,{className:`${we}__platforms`,title:"Platforms",value:l.createElement("div",{className:`${we}__platform-list`},e.map(e=>l.createElement("span",{key:e,className:`${we}__platform-item`},l.createElement(b.A,{name:e,color:"ui-fleet-black-75"}),c.uc[e]||e)))})})(),(()=>{if(!ie)return null;const{includeLabels:e,excludeLabels:t}=ie,a=[...null!=e?e:[],...null!=t?t:[]];return a.length?l.createElement(v.A,{className:`${we}__labels`,title:"Labels",value:l.createElement(k.A,{items:a.map(e=>e.name),onClick:fe})}):null})(),(()=>{var e;const t=l.createElement(v.A,{className:`${we}__automations`,title:"Automations",value:p.r2});if(!ee)return t;const a=(0,L.Fx)(ee,re,se);if(!a.length)return t;const n=a[0];return l.createElement(v.A,{className:`${we}__automations${a.length>1?` ${we}__automations--multi`:""}`,title:"Automations",value:l.createElement(l.Fragment,null,n.isSoftware?l.createElement(O.A,{name:null!=(e=n.iconName)?e:n.name,url:n.iconUrl,size:"small"}):n.graphicName&&l.createElement(E.A,{name:n.graphicName,className:"file-sh"===n.graphicName||"file-ps1"===n.graphicName||"file-configuration-profile"===n.graphicName?"scale-40-24":""}),l.createElement(k.A,{items:a.map(e=>e.name),onClick:he}))})})(),ee?l.createElement(v.A,{className:`${we}__author`,title:"Author",value:l.createElement("div",{className:`${we}__author-info`},l.createElement(N.A,{user:(0,m.O2)({email:ee.author_email}),size:"xsmall"}),l.createElement("span",null,ee.author_name===(null==D?void 0:D.name)?"You":ee.author_name))}):null),(null==ee?void 0:ee.resolution)?l.createElement(v.A,{className:`${we}__resolve`,title:"Resolve",value:ee.resolution,multiline:!0}):null))),!Z&&!te&&ee&&l.createElement(Ae,{policy:ee,currentAutomatedPolicies:re,otherAutomationType:se,canResetPolicy:ue}),G&&l.createElement(T.A,{query:null==ee?void 0:ee.query,onCancel:()=>Y(!1)}),K&&ie&&l.createElement(R,{includeLabels:ie.includeLabels,includeScopeLabel:ie.includeScopeLabel,excludeLabels:ie.excludeLabels,excludeScopeLabel:ie.excludeScopeLabel,getLabelPath:de?o.A.LABEL_EDIT:void 0,onClose:()=>V(!1)}),X&&ee&&l.createElement(F,{storedPolicy:ee,currentAutomatedPolicies:re,otherAutomationType:se,onClose:()=>J(!1)})):l.createElement(w.A,null)}},30871:function(e,t,a){a.r(t),a.d(t,{default:function(){return We}});var l=a(96540),n=a(75942),i=a(24740),o=a(68774),r=a(59593),s=a(38944),c=a(62131),u=a(39414),d=a(80396),m=a(10664),p=a(68612),y=a(78263),f=a(89937),h=a(12968),_=a(56118),v=a(37863),E=a(97126),b=a(90508),g=e=>{const{AUTOFILL_POLICY:t}=b.A;return(0,E.Ay)("POST",t,{sql:e})},A=a(46157),w=a(14332),S=a(65273),C=a(12755),k=a(84945),N=a(81591),T=a(2543),P=a(19984),O=a(64933),L=a(14648),I=a(98220),x=a(22184),D=a(74953),M=a(5410),R=a(52603),$=a(45584),F=a(45847),q=a(80717),Q=a(59333),W=a(24432),H=a(22676),j=a(19677),B=a(17244),U=a(5167),z=a(66081),G=a(83844),Y=a(32485),K=a.n(Y),V=a(98598),X=a(98544),J=a(99958),Z=a(52978),ee=Object.defineProperty,te=Object.defineProperties,ae=Object.getOwnPropertyDescriptors,le=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable,oe=(e,t,a)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,re=(e,t)=>
1{for(var a in t||(t={}))ne.call(t,a)&&oe(e,a,t[a]);if(le)for(var a of le(t))ie.call(t,a)&&oe(e,a,t[a]);return e},se=(e,t)=>te(e,ae(t)),ce=({baseClass:e,queryValue:t,onCreatePolicy:a,setIsSaveNewPolicyModalOpen:i,backendValidators:s,platformSelector:c,isUpdatingPolicy:u,aiFeaturesDisabled:m,isFetchingAutofillDescription:p,isFetchingAutofillResolution:h,onClickAutofillDescription:_,onClickAutofillResolution:v,isGlobalPolicy:E,policyTeamId:b,automationsConfig:g,globalConfig:A,fleetName:w,router:S})=>{const{isPremiumTier:C,setConfig:k}=(0,l.useContext)(o.BR),N=(0,n.useQueryClient)(),{lastEditedQueryName:P,lastEditedQueryDescription:O,lastEditedQueryResolution:I,lastEditedQueryCritical:x,setLastEditedQueryName:$,setLastEditedQueryPlatform:F,setLastEditedQueryDescription:Q,setLastEditedQueryResolution:W,setLastEditedQueryCritical:U}=(0,l.useContext)(r.q),[z,Y]=(0,l.useState)(s),{selectorProps:ee,selectedTargetType:te,hasCustomLabels:ae,getLabelsPayload:le}=(0,G.a)(),[ne,ie]=(0,l.useState)(!1),oe=(0,l.useRef)(null),ce=(0,l.useMemo)(()=>({id:-1,team_id:null!=b?b:null,calendar_events_enabled:!1,conditional_access_enabled:!1,continuous_automations_enabled:!1}),[b]),ue=p||h,de=!c.isAnyPlatformSelected||ue||"Custom"===te&&!ae;(0,V.A)(()=>{P&&Y({})},[P]),(0,l.useEffect)(()=>{Y(s)},[s]);const me=(0,l.useCallback)(e=>{const t="Description"===e&&p||"Resolution"===e&&h;return l.createElement(R.A,{tipContent:m?"AI features are disabled in organization settings":l.createElement(l.Fragment,null,"Policy queries (SQL) will be sent to a ",l.createElement("br",null),"large language model (LLM). Fleet ",l.createElement("br",null),"doesn't use this data to train models."),position:"top",disableTooltip:ue,underline:!1},l.createElement("div",{className:"autofill-tooltip-wrapper"},l.createElement(D.A,{variant:"subdued",disabled:m||ue,onClick:"Description"===e?_:v,size:"small"},t?"Thinking...":l.createElement(l.Fragment,null,l.createElement(Z.A,{name:"sparkles"})," Autofill"))))},[p,h,ue]),pe=(0,l.useCallback)(t=>{const a=K()(`${e}__autofill-label`,{[`${e}__label--${t}`]:!!t});return l.createElement("div",{className:a},t,me(t))},[me]);return l.createElement(J.A,{title:"Save policy",onExit:()=>i(!1),width:"large"},l.createElement("form",{onSubmit:e=>{var l;e.preventDefault();const n=c.getSelectedPlatforms().join(",");F(n);const{valid:i,errors:o}=(e=>{const t={};return e||(t.name="Policy name must be present"),{valid:!(0,T.size)(t),errors:t}})(P);if(Y(re(re({},z),o)),de||!i)return;const r=ne?null==(l=oe.current)?void 0:l.getAutomationsPayload():void 0;if(r&&!r.isValid)return;const s={description:O,name:P,query:t,resolution:I,platform:n,critical:x};C&&Object.assign(s,le());const u=(null==r?void 0:r.isDirty)?e=>{return t=function*(){var t,a,l,n;const i=[];if(r.policyUpdate&&!E&&i.push(d.A.update(e.id,re({team_id:b},r.policyUpdate))),null==(t=r.webhookOrTicketUpdate)?void 0:t.enabled){const t=null!=(l=null==(a=null==g?void 0:g.webhook_settings)?void 0:a.failing_policies_webhook)?l:{},o=null!=(n=t.policy_ids)?n:[],r=Array.from(new Set([...o,e.id])),s={webhook_settings:{failing_policies_webhook:se(re({},t),{policy_ids:r})}};E?i.push(X.A.update(s).then(e=>{N.setQueryData(["config"],e),k(e)})):void 0!==b&&i.push(j.A.update(s,b).then(e=>{N.setQueryData(["teams",b],e)}))}yield Promise.all(i)},new Promise((e,a)=>{var l=e=>{try{i(t.next(e))}catch(e){a(e)}},n=e=>{try{i(t.throw(e))}catch(e){a(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(l,n);i((t=t.apply(null,null)).next())});var t}:void 0;a(s,u)},className:`${e}__save-modal-form`,autoComplete:"off"},l.createElement(q.A,{name:"name",onChange:e=>$(e),value:P,error:z.name,inputClassName:`${e}__policy-save-modal-name`,label:"Name",autofocus:!0,disabled:ue,inputOptions:{maxLength:f.fQ}}),l.createElement(q.A,{name:"description",onChange:e=>Q(e),value:O,inputClassName:`${e}__policy-save-modal-description`,label:pe("Description"),helpText:"How does this policy's failure put the organization at risk?",type:"textarea",disabled:ue}),l.createElement(q.A,{name:"resolution",onChange:e=>W(e),value:I,inputClassName:`${e}__policy-save-modal-resolution`,label:pe("Resolution"),type:"textarea",helpText:"If this policy fail
1s, what should the end user expect?",disabled:ue}),c.render(),C&&l.createElement(H.Z,se(re({},ee),{className:`${e}__target`,emptyStateDescription:L.gd,onAddLabel:()=>S.push(y.A.LABEL_NEW_DYNAMIC),disableOptions:ue})),ne?l.createElement("div",{className:"form-field"},l.createElement("div",{className:"form-field__label"},"Automations"),l.createElement(B.A,{ref:oe,policy:ce,isGlobalPolicy:E,teamIdForApi:b,automationsConfig:g,globalConfig:A,fleetName:w,selectedPlatforms:c.getSelectedPlatforms()})):l.createElement("div",{className:`${e}__add-automations`},l.createElement(D.A,{variant:"secondary",type:"button",onClick:()=>ie(!0),icon:"plus"},"Add automations")),C&&l.createElement("div",{className:"critical-checkbox-wrapper"},l.createElement(M.A,{name:"critical-policy",onChange:e=>U(e),value:x,disabled:ue},l.createElement(R.A,{tipContent:l.createElement("p",null,"If automations are turned on, this information is included. If Okta conditional access is configured, end users can never bypass critical policies.")},"Critical"))),l.createElement("div",{className:"modal-cta-wrap"},l.createElement(R.A,{tipContent:l.createElement(l.Fragment,null,"Select the platforms this",l.createElement("br",null),"policy will be checked on",l.createElement("br",null),"to save the policy."),tooltipClass:`${e}__button--modal-save-tooltip`,position:"top",disableTooltip:!de,underline:!1,showArrow:!0,tipOffset:8},l.createElement("span",{className:`${e}__button-wrap--modal-save`},l.createElement(D.A,{type:"submit",disabled:de,className:"save-policy-loading",isLoading:u},"Save"))),l.createElement(D.A,{className:`${e}__button--modal-cancel`,type:"button",onClick:()=>i(!1),variant:"secondary"},"Cancel"))))};const ue=e=>{const t=(0,C.F3)(e,{reasonIncludes:"resend declaration (DDM)"});return""!==t?t:""!==(0,C.F3)(e,{reasonIncludes:"has an invalid prefix"})?"Only Apple and Windows configuration profiles are supported. Please select a valid profile.":"Could not update policy automations."};var de=Object.defineProperty,me=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,ye=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,_e=(e,t,a)=>t in e?de(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,ve=(e,t)=>{for(var a in t||(t={}))fe.call(t,a)&&_e(e,a,t[a]);if(ye)for(var a of ye(t))he.call(t,a)&&_e(e,a,t[a]);return e},Ee=(e,t)=>me(e,pe(t)),be=(e,t,a)=>new Promise((l,n)=>{var i=e=>{try{r(a.next(e))}catch(e){n(e)}},o=e=>{try{r(a.throw(e))}catch(e){n(e)}},r=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,o);r((a=a.apply(e,t)).next())});const ge="policy-form";var Ae=({router:e,teamIdForApi:t,policyIdForEdit:a,showOpenSchemaActionText:i,storedPolicy:s,isStoredPolicyLoading:u,isTeamObserver:m,isUpdatingPolicy:p,onCreatePolicy:_,onOsqueryTableSelect:v,goToSelectTargets:E,onUpdate:b,onOpenSchemaSidebar:g,renderLiveQueryWarning:w,backendValidators:S,isFetchingAutofillDescription:C,isFetchingAutofillResolution:k,onClickAutofillDescription:Y,onClickAutofillResolution:K,resetAiAutofillData:V})=>{var X,J,Z,ee,te,ae;const[le,ne]=(0,l.useState)({}),[ie,oe]=(0,l.useState)(!1),re="patch"===(null==s?void 0:s.type),[se,de]=(0,l.useState)(!1),[me,pe]=(0,l.useState)("manual"),ye=null==s?void 0:s.id,fe=null==s?void 0:s.patch_when_closed,he=null==(X=null==s?void 0:s.install_software)?void 0:X.software_title_id;(0,l.useEffect)(()=>{if(!re||!ye)return;let e="manual";fe?e="closed":he&&(e="force"),pe(e)},[re,ye,fe,he]);const{lastEditedQueryId:_e,lastEditedQueryName:Ae,lastEditedQueryDescription:we,lastEditedQueryBody:Se,lastEditedQueryResolution:Ce,lastEditedQueryCritical:ke,lastEditedQueryPlatform:Ne,lastEditedQueryLabelsIncludeAny:Te,lastEditedQueryLabelsIncludeAll:Pe,lastEditedQueryLabelsExcludeAny:Oe,lastEditedQueryLabelsExcludeAll:Le,defaultPolicy:Ie,setLastEditedQueryName:xe,setLastEditedQueryDescription:De,setLastEditedQueryBody:Me,setLastEditedQueryResolution:Re,setLastEditedQueryCritical:$e,setLastEditedQueryPlatform:Fe}=(0,l.useContext)(r.q),{selectorProps:qe,selectedTargetType:Qe,hasCustomLabels:We,getLabelsPayload:He}=(0,G.a)({includeAny:Te,includeAll:Pe,excludeAny:Oe,excludeAll:Le}),je=(0,n.useQueryClient)(),{currentTeam:Be,isGlobalObserver:Ue,isTeamTechnician:ze,isGlobalTechnician:Ge,isOnGlobalTeam:Ye,isPremiumTier:Ke,config:Ve,isFreeTier:Xe}=(0,l.useContext)(o.BR),Je=null==Ve?void 0:Ve.server_settings.live_query_disabled,Ze=(null==Ve?void 0:Ve.server_settings.ai_features_disabled)||!1,et=null==Ve?void 0:Ve.gitops.gitops_mode_enabled,tt=(0,N.YQ)(e=>{const{errors:t}=(e=>{const t={},{error:a,valid:l}=(0,x.B4)(e);return l||(t.query=a),{valid:!(0,T.size)(t),errors:t}})(e);ne(ve({},t))},500),at=(0,P.A)(),{getCompatiblePlatforms:lt,setCompatiblePlatforms:nt}=at,it=C||k||et,ot=(0,O.A)(Ne,ge,it,null==s?void 0:s.install_software,null==Be?void 0:Be.id),{getSelectedPlatforms:rt,setSelectedPlatforms:st,isAnyPlatformSelected:ct}=ot,ut=!!(a=a||0)&&!m&&!Ue,dt=!a&&L.fb.find(e=>e.name===Ae),mt=void 0!==(null==Be?void 0:Be.id)&&Be.id!==c.jc?Be.id:void 0,pt=ut?null==(null==s?void 0:s.team_id):void 0===mt,yt=ut?null!=(J=null==s?void 0:s.team_id)?J:void 0:mt,{data:ft}=(0,n.useQuery)(["teams",yt],()=>j.A.load(yt),{enabled:!pt&&void 0!==yt,staleTime:5e3}),ht=null!=(Z=pt?Ve:null==ft?void 0:ft.team)?Z:void 0;let _t="";_t=pt?c.Op.name:yt===c.Gl?c.bn.name:null!=(ae=null!=(te=null==(ee=null==ft?void 0:ft.team)?void 0:ee.name)?te:null==Be?void 0:Be.name)?ae:"";const vt=(0,l.useRef)(null),{mutate:Et,isLoading:bt}=(0,G.p)({policy:s,teamIdForApi:yt,isGlobalPolicy:pt,automationsConfig:ht,onSuccess:()=>{je.invalidateQueries(["policy",a])},onError:e=>{A.me.error(ue(e),{response:e})}});(0,l.useEffect)(()=>{const l=ut&&null===(null==s?void 0:s.team_id);!u&&a&&a>0&&(m||Ue||ze||Ge||!Ye&&l)&&e.push((0,h.M8)(y.A.POLICY_DETAILS(a),{fleet_id:t}))},[a,ut,u,m,Ue,ze,Ge,Ye,null==s?void 0:s.team_id,e,t]),(0,l.useEffect)(()=>{dt&&nt(Se)},[]),(0,l.useEffect)(()=>{tt(Se),a&&a!==_e||dt&&!Se||nt(Se)},[Se,_e]);const gt=e=>{e.setOptions({enableLinking:!0,enableMultiselect:!1}),e.on("linkClick",e=>{const{type:t,value:a}=e.token;return"osquery-token"===t&&v(a)})},At=e=>{Me(e),V()},wt=()=>be(null,null,function*(){var e;if((null==(e=null==s?void 0:s.patch_software)?void 0:e.software_title_id)&&null!=(null==s?void 0:s.team_id)){de(!0);try{yield d.A.update(a,{team_id:s.team_id,software_title_id:s.patch_software.software_title_id}),je.invalidateQueries(["policy",a]),A.me.success("Automation added.")}catch(e){A.me.error("Couldn't set automation. Please try again.",{response:e})}finally{de(!1)}}}),St=()=>e=>be(null,null,function*(){var t,a,l;if(e.preventDefault(),ut&&!Ae)return void ne(Ee(ve({},le),{name:"Policy name must be present"}));if(ut&&!re&&!ct)return void ne(Ee(ve({},le),{name:"At least one platform must be selected"}));let n;if(ut&&(n=null==(t=vt.current)?void 0:t.getAutomationsPayload(),!n&&Ke&&re&&(n={isValid:!0,isDirty:!0,policyUpdate:ve({software_title_id:"manual"===me?null:null!=(l=null==(a=null==s?void 0:s.patch_software)?void 0:a.software_title_id)?l:null},(0,z.kl)(me))}),n&&!n.isValid))return;const i=()=>{(null==n?void 0:n.isDirty)&&Et({policyUpdate:n.policyUpdate,webhookOrTicketUpdate:n.webhookOrTicketUpdate})};if(re&&ut){const e={name:Ae,description:we,resolution:Ce};return Ke&&(e.critical=ke),yield b(e),void i()}if(!(null==Se?void 0:Se.trim()))return void ne(Ee(ve({},le),{query:x.Ni}));let o=rt();0!==o.length||ut||Ie||(o=lt(),st(o));const r=o.join(",");if(Ie||Fe(r),ut){const e={name:Ae,description:we,query:Se,resolution:Ce,platform:r};Ke&&(Object.assign(e,He()),e.critical=ke),yield b(e),i()}else oe(!0)}),Ct=()=>ut?l.createElement(q.A,{name:"policy-name",label:"Name",placeholder:"Add name here",value:Ae,error:le&&le.name,onChange:e=>xe(e),disabled:et,inputOptions:{maxLength:f.fQ}}):l.createElement("h1",{className:`${ge}__policy-name ${ge}__policy-name--new no-hover`},"New policy"),kt=()=>{if(Xe)return null;let e;return e=ut?null===(null==s?void 0:s.team_id)?c.Op.name:0===(null==s?void 0:s.team_id)?c.bn.name:null==Be?void 0:Be.name:null==Be?void 0:Be.name,e?ut?l.createElement("p",null,"Editing policy for ",l.createElement("strong",null,e),"."):l.createElement("p",null,"Creating a new policy for ",l.createElement("strong",null,e),"."):null};return u?l.createElement($.A,null):(()=>{const t=se||ut&&!re&&!ct||""===Ae&&!!_e||"Custom"===Qe&&!We||le.query===x.Ni,n=ut&&!!s&&!!ht,o=ut&&Ke&&re&&l.createElement("div",{className:"form-field"},l.createElement("div",{className:"form-field__label"},"Patch"),l.createElement(Q.A,{renderChildren:e=>l.createElement(z.dw,{patchOption:me,onSelectPatchOption:pe,disabled:e})}));return l.createElement(l.Fragment,null,l.createElement("form",{className:`${ge}__wrapper`,autoComplete:"off"},ut?l.createElement("div",{className:`${ge}__page-header`},l.createElement("h1",{className:`${ge}__page-title`},"Edit policy"),kt()):l.createElement("div",{className:`${ge}__title-bar`},l.createElement("div",{className:`${ge}__policy-name-fleet-name`},Ct(),kt())),ut&&Ct(),ut?l.createElement(q.A,{name:"policy-description",label:"Description",placeholder:"Add description here.",value:we,type:"textarea",helpText:"How does this policy's failure put the organization at risk?",onChange:e=>De(e),disabled:et}):null,ut?l.createElement(q.A,{name:"policy-resolution",label:"Resolution",placeholder:"Add resolution here.",value:Ce,type:"textarea",helpText:"If this policy fail
1s, what should the end user expect?",onChange:e=>Re(e),disabled:et}):null,ut&&!re&&ot.render(),ut&&Ke&&!re&&l.createElement(H.Z,Ee(ve({},qe),{className:`${ge}__target`,emptyStateDescription:L.gd,onAddLabel:()=>e.push(y.A.LABEL_NEW_DYNAMIC),disableOptions:et})),n&&l.createElement("div",{className:"form-field"},l.createElement("div",{className:"form-field__label"},"Automations"),!(Ke&&re)&&l.createElement(U.S_,{storedPolicy:s,canEditPolicy:ut,onAddAutomation:wt,isAddingAutomation:se}),l.createElement(B.A,{key:s.updated_at,ref:vt,policy:s,isGlobalPolicy:pt,teamIdForApi:yt,automationsConfig:ht,globalConfig:null!=Ve?Ve:void 0,fleetName:_t,patchOption:Ke&&re?me:void 0,patchSlot:o,selectedPlatforms:rt()})),!n&&o,ut&&Ke&&!re&&l.createElement("div",{className:`${ge}__critical-checkbox-wrapper`},l.createElement(M.A,{name:"critical-policy",className:"critical-policy",onChange:e=>$e(e),value:ke,isLeftLabel:!0,disabled:et},l.createElement(R.A,{tipContent:l.createElement("p",null,"If automations are turned on, this information is included. If Okta conditional access is configured, end users can never bypass critical policies.")},"Critical"))),l.createElement(I.A,{value:Se,error:le.query,label:"Query",labelActionComponent:re?l.createElement(R.A,{tipContent:"Query is read-only for patch policies.",position:"top",underline:!1,showArrow:!0,tipOffset:12},l.createElement(F.A,{name:"info",size:"small"})):l.createElement("div",{className:`${ge}__sql-editor-label-actions`},i&&l.createElement(D.A,{variant:"subdued",onClick:g,icon:"info",iconPosition:"right"},"Schema"),!a&&l.createElement(W.A,{text:"Examples",url:`${f.CW}/policy-templates`,newTab:!0})),name:"query editor",onLoad:gt,wrapperClassName:`${ge}__text-editor-wrapper form-field`,onChange:At,handleSubmit:St,wrapEnabled:!0,focus:!ut,readOnly:re}),ut&&(u||a!==_e)?null:at.render(),w(),l.createElement("div",{className:"button-wrap"},l.createElement(Q.A,{renderChildren:e=>l.createElement(R.A,{tipContent:"Select the platforms this policy will be checked on to save or run the policy.",tooltipClass:`${ge}__button-wrap--tooltip`,position:"top",disableTooltip:!ut||ct,underline:!1},l.createElement("span",{className:`${ge}__button-wrap--tooltip`},l.createElement(D.A,{onClick:St(),disabled:t||e,className:"save-loading",isLoading:p||bt},"Save")))}),l.createElement(R.A,{tipContent:Je?l.createElement(l.Fragment,null,"Live reports are disabled in organization settings."):l.createElement(l.Fragment,null,"Select the platforms this policy will be checked on to save or run the policy."),disableTooltip:(!ut||ct)&&!Je,underline:!1,showArrow:!0,position:"top"},l.createElement("span",{className:`${ge}__button-wrap--tooltip`},l.createElement(D.A,{onClick:E,disabled:se||ut&&!ct||Je,variant:"secondary",icon:"run",iconPosition:"right"},"Run policy"))))),ie&&l.createElement(ce,{baseClass:ge,queryValue:Se,onCreatePolicy:_,setIsSaveNewPolicyModalOpen:oe,backendValidators:S,platformSelector:ot,isUpdatingPolicy:p,aiFeaturesDisabled:Ze,isFetchingAutofillDescription:C,isFetchingAutofillResolution:k,onClickAutofillDescription:Y,onClickAutofillResolution:K,isGlobalPolicy:pt,policyTeamId:yt,automationsConfig:ht,globalConfig:null!=Ve?Ve:void 0,fleetName:_t,router:e}))})()},we=Object.defineProperty,Se=Object.defineProperties,Ce=Object.getOwnPropertyDescriptors,ke=Object.getOwnPropertySymbols,Ne=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable,Pe=(e,t,a)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Oe=(e,t,a)=>new Promise((l,n)=>{var i=e=>{try{r(a.next(e))}catch(e){n(e)}},o=e=>{try{r(a.throw(e))}catch(e){n(e)}},r=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,o);r((a=a.apply(e,t)).next())}),Le=({router:e,baseClass:t,policyIdForEdit:a,storedPolicy:n,storedPolicyError:i,showOpenSchemaActionText:s,isStoredPolicyLoading:m,isTeamObserver:p,createPolicy:f,onOsqueryTableSelect:_,goToSelectTargets:v,onOpenSchemaSidebar:E,renderLiveQueryWarning:b,teamIdForApi:N})=>{const{currentUser:T,isPremiumTier:P,filteredPoliciesPath:O}=(0,l.useContext)(o.BR),{lastEditedQueryName:L,lastEditedQueryDescription:I,lastEditedQueryBody:x,lastEditedQueryResolution:D,lastEditedQueryCritical:M,lastEditedQueryPlatform:R,policyTeamId:$,setLastEditedQueryDescription:F,setLastEditedQueryResolution:q}=(0,l.useContext)(r.q);(0,l.useEffect)(()=>{i&&A.me.error("Something went wrong retrieving your policy. Please try again.",{response:i})},[]);const[Q,W]=(0,l.useState)(!1),[H,j]=(0,l.useState)({}),[B,U]=(0,l.useState)(null),[z,G]=(0,l.useState)(!1),[Y,K]=(0,l.useState)(!1),V=(0,w.A)((t,a)=>Oe(null,null,function*(){$!==c.jc&&(t.team_id=$),W(!0);const l={name:t.name,description:t.description,query:t.query,resolution:t.resolution,platform:t.platform,labels_include_any:t.labels_include_any,labels_include_all:t.labels_include_all,labels_exclude_any:t.labels_exclude_any,labels_exclude_all:t.labels_exclude_all};P&&(l.critical=t.critical,l.team_id=t.team_id);try{const t=yield f(l).then(e=>e.policy);if(a)try{yield a(t)}catch(e){A.me.error("Policy was created, but its automations couldn't be saved.",{response:e})}A.me.success("Policy created."),e.push((0,h.M8)(y.A.POLICY_DETAILS(t.id),{fleet_id:t.team_id}))}catch(e){(0,C.F3)(e).includes("already exists")?j({name:"A policy with this name already exists"}):A.me.error("Something went wrong creating your policy. Please try again.",{response:e})}finally{W(!1)}}));if(!T)return null;const X=a?(0,h.M8)(y.A.POLICY_DETAILS(a),{fleet_id:N}):(()=>{const e={fleet_id:N};return O||(0,h.M8)(y.A.MANAGE_POLICIES,e)})(),J=a?"Back to policy":"Back to policies";return l.createElement("div",{className:`${t}__form`},l.createElement("div",{className:`${t}__header-links`},l.createElement(k.A,{text:J,path:X})),l.createElement(Ae,{router:e,teamIdForApi:N,onCreatePolicy:V,goToSelectTargets:v,onOsqueryTableSelect:_,onUpdate:e=>Oe(null,null,function*(){if(!a)return!1;W(!0);const t=(0,S.A)(e,{lastEditedQueryName:L,lastEditedQueryDescription:I,lastEditedQueryBody:x,lastEditedQueryResolution:D,lastEditedQueryCritical:M,lastEditedQueryPlatform:R});"patch"===(null==n?void 0:n.type)&&(delete t.query,delete t.platform);try{yield(()=>{var e;const l=null!=(e=null==n?void 0:n.team_id)?e:void 0;return void 0!==l?d.A.update(a,(i=((e,t)=>{for(var a in t||(t={}))Ne.call(t,a)&&Pe(e,a,t[a]);if(ke)for(var a of ke(t))Te.call(t,a)&&Pe(e,a,t[a]);return e})({},t),Se(i,Ce({team_id:l})))):u.A.update(a,t);var i})(),A.me.success("Policy updated.")}catch(e){console.error(e),(0,C.F3)(e).includes("Duplicate")?A.me.error("A policy with this name already exists.",{response:e}):A.me.error("Something went wrong updating your policy. Please try again.",{response:e})}finally{W(!1)}return!1}),storedPolicy:n,policyIdForEdit:a,isStoredPolicyLoading:m,showOpenSchemaActionText:s,onOpenSchemaSidebar:E,renderLiveQueryWarning:b,backendValidators:H,isTeamObserver:p,isUpdatingPolicy:Q,isFetchingAutofillDescription:z,isFetchingAutofillResolution:Y,onClickAutofillDescription:()=>Oe(null,null,function*(){if(B)F(B.description);else{G(!0);try{const e=yield g(x);U(e),F(e.description)}catch(e){console.log(e),A.me.error("Couldn't autofill policy data.",{response:e})}G(!1)}}),onClickAutofillResolution:()=>Oe(null,null,function*(){if(B)q(B.resolution);else{K(!0);try{const e=yield g(x);U(e),q(e.resolution)}catch(e){console.log(e),A.me.error("Couldn't autofill policy data.",{response:e})}K(!1)}}),resetAiAutofillData:()=>U(null)}))},Ie=a(827),xe=a(90125),De=a(95163),Me=Object.defineProperty,Re=Object.getOwnPropertySymbols,$e=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable,qe=(e,t,a)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;const Qe="edit-policy-page";var We=({router:e,params:{id:t},location:a})=>{var E,b;const g=t?parseInt(t,10):null,A=(0,i.useErrorHandler)(),{isOnGlobalTeam:w,isGlobalAdmin:S,isGlobalMaintainer:C,isAnyTeamMaintainerOrTeamAdmin:k,config:N}=(0,l.useContext)(o.BR),{lastEditedQueryBody:T,policyTeamId:P,selectedOsqueryTable:O,setSelectedOsqueryTable:I,setLastEditedQueryId:x,set
1LastEditedQueryName:D,setLastEditedQueryDescription:M,setLastEditedQueryBody:R,setLastEditedQueryResolution:$,setLastEditedQueryCritical:F,setLastEditedQueryPlatform:q,setLastEditedQueryLabelsIncludeAny:Q,setLastEditedQueryLabelsIncludeAll:H,setLastEditedQueryLabelsExcludeAny:j,setLastEditedQueryLabelsExcludeAll:B,setPolicyTeamId:U}=(0,l.useContext)(r.q),{isRouteOk:z,isTeamAdmin:G,isTeamMaintainer:Y,isTeamObserver:K,teamIdForApi:V,isObserverPlus:X}=(0,s.Ay)({location:a,router:e,includeAllTeams:!0,includeNoTeam:!0,permittedAccessByTeamRole:{admin:!0,maintainer:!0,observer:!0,observer_plus:!0,technician:!0}});(0,l.useEffect)(()=>{z&&P!==V&&U(V===c.s_?c.jc:V)},[z,V,P,U]),(0,l.useEffect)(()=>{""===T&&R(L.zj.query)},[]),(0,l.useEffect)(()=>()=>{F(!1),q(null)},[]);const[J,Z]=(0,l.useState)(!0),[ee,te]=(0,l.useState)(!0),[ae,le]=(0,l.useState)(!1),{isLoading:ne,data:ie,error:oe}=(0,n.useQuery)(["policy",g,V],()=>m.A.load(g),{enabled:z&&!!g,refetchOnWindowFocus:!1,retry:!1,select:e=>e.policy,onSuccess:e=>{var t;const a=null!=(t=e.team_id)?t:void 0;x(e.id),D(e.name),M(e.description),R(e.query),$(e.resolution),F(e.critical),q(e.platform),Q(e.labels_include_any||[]),H(e.labels_include_all||[]),j(e.labels_exclude_any||[]),B(e.labels_exclude_all||[]),U(a===c.s_?c.jc:a)},onError:e=>A(e)});w||ne||void 0===(null==ie?void 0:ie.team_id)||null===(null==ie?void 0:ie.team_id)||(null==(E=null==ie?void 0:ie.team_id)?void 0:E.toString())===a.query.fleet_id||e.push((0,h.M8)(a.pathname,{fleet_id:null==(b=null==ie?void 0:ie.team_id)?void 0:b.toString()}));const{mutateAsync:re}=(0,n.useMutation)(e=>void 0!==e.team_id?d.A.create(e):u.A.create(e));(0,l.useEffect)(()=>{p.A.live_query().catch(()=>{Z(!1)})},[]),(0,l.useEffect)(()=>{(null==ie?void 0:ie.name)?document.title=`${ie.name} | Policies | ${f.DI}`:document.title=`Policies | ${f.DI}`},[a.pathname,null==ie?void 0:ie.name]),(0,l.useEffect)(()=>{le(!ee)},[ee]);const se=e=>{I(e)},ce=()=>{te(!0)},ue=()=>J||(null==N?void 0:N.server_settings.live_query_disabled)?null:l.createElement("div",{className:`${Qe}__warning`},l.createElement("div",{className:`${Qe}__message`},l.createElement("p",null,"Fleet is unable to run a live report. Refresh the page or log in again. If this keeps happening please"," ",l.createElement(W.A,{url:"https://github.com/fleetdm/fleet/issues/new/choose",text:"file an issue",newTab:!0})))),de=ee&&(S||C||k);return z?l.createElement(_.A,null,l.createElement(l.Fragment,null,l.createElement(Ie.A,{className:Qe},(()=>{const t={router:e,baseClass:Qe,policyIdForEdit:g,showOpenSchemaActionText:ae,storedPolicy:ie,isStoredPolicyLoading:ne,isTeamAdmin:G,isTeamMaintainer:Y,isTeamObserver:K,isObserverPlus:X,storedPolicyError:oe,createPolicy:re,onOsqueryTableSelect:se,goToSelectTargets:()=>e.push((0,h.M8)(y.A.LIVE_POLICY(g),{fleet_id:V})),onOpenSchemaSidebar:ce,renderLiveQueryWarning:ue,teamIdForApi:V};return l.createElement(Le,((e,t)=>{for(var a in t||(t={}))$e.call(t,a)&&qe(e,a,t[a]);if(Re)for(var a of Re(t))Fe.call(t,a)&&qe(e,a,t[a]);return e})({},t))})()),de&&l.createElement(xe.A,null,l.createElement(v.A,{onOsqueryTableSelect:se,selectedOsqueryTable:O,onClose:()=>{te(!1)}})))):l.createElement(De.A,null)}},41820:function(e,t,a){a.d(t,{IQ:function(){return u},LM:function(){return s},NH:function(){return c},Or:function(){return m},ic:function(){return d}});var l=a(43015),n=a(56906),i=a(30178),o=a(9106),r=a(18165);const s=e=>{var t,a,l,n,i,o,r,s;if(!e)return{state:"disabled",policyIds:[]};const c=null!=(l=null==(a=null==(t=e.webhook_settings)?void 0:t.failing_policies_webhook)?void 0:a.enable_failing_policies_webhook)&&l,u=e.integrations,d=!!(null==(n=null==u?void 0:u.jira)?void 0:n.some(e=>e.enable_failing_policies))||!!(null==(i=null==u?void 0:u.zendesk)?void 0:i.some(e=>e.enable_failing_policies));let m="disabled";return c?m="webhook":d&&(m="ticket"),{state:m,policyIds:"disabled"===m?[]:null!=(s=null==(r=null==(o=e.webhook_settings)?void 0:o.failing_policies_webhook)?void 0:r.policy_ids)?s:[]}},c=e=>"webhook"===e?"Send webhook":"ticket"===e?"Create ticket":"Send webhook or create ticket",u=e=>{var t,a,i,s,c,u,d;if("apps"===e.source&&e.app_store_app)return"macOS (App Store)"+((null==(t=e.app_store_app)?void 0:t.ver
1sion)?` ⢠${e.app_store_app.version}`:"");const m=n.VP[e.source]||null,p=(0,o.bv)(null!=(i=null==(a=e.software_package)?void 0:a.name)?i:""),y=m&&p?`${l.uc[m]} (.${p})`:"",f=null!=(c=null==(s=e.packages)?void 0:s.length)?c:0,h=f>1?`${f} ${(0,r.td)(f,"version")}`:null!=(d=null==(u=e.software_package)?void 0:u.version)?d:"";return`${y}${y&&h?" ⢠":""}${h}`},d=e=>{var t;const a=e.version&&e.uploaded_at?" ⢠":"",l=e.uploaded_at?(0,i.PI)(e.uploaded_at):"";return`${null!=(t=e.version)?t:""}${a}${l}`},m=e=>e&&0!==e.length?e.reduce((e,t)=>t.installer_id<e.installer_id?t:e):null},83844:function(e,t,a){a.d(t,{a:function(){return O},p:function(){return _}});var l=a(96540),n=a(75942),i=a(68774),o=a(98544),r=a(80396),s=a(19677),c=Object.defineProperty,u=Object.defineProperties,d=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,f=(e,t,a)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,h=(e,t)=>{for(var a in t||(t={}))p.call(t,a)&&f(e,a,t[a]);if(m)for(var a of m(t))y.call(t,a)&&f(e,a,t[a]);return e},_=({policy:e,teamIdForApi:t,isGlobalPolicy:a,automationsConfig:c,onSuccess:m,onError:p})=>{const y=(0,n.useQueryClient)(),{setConfig:f}=(0,l.useContext)(i.BR);if(!a&&void 0===t)throw new Error("Missing fleet id for team-scoped policy automations.");return(0,n.useMutation)(({policyUpdate:l,webhookOrTicketUpdate:n})=>{if(!e)return Promise.reject(new Error("Cannot update automations without a policy."));const{id:i}=e,m=[];return l&&m.push(r.A.update(i,h({team_id:t},l))),n&&m.push(((e,l)=>{return n=function*(){var n,i,r;const m=null!=(i=null==(n=null==c?void 0:c.webhook_settings)?void 0:n.failing_policies_webhook)?i:{},p=null!=(r=m.policy_ids)?r:[],_=l?Array.from(new Set([...p,e])):p.filter(t=>t!==e),v={webhook_settings:{failing_policies_webhook:(E=h({},m),b={policy_ids:_},u(E,d(b)))}};var E,b;if(a){const e=yield o.A.update(v);y.setQueryData(["config"],e),f(e)}else{const e=yield s.A.update(v,t);y.setQueryData(["teams",t],e)}},new Promise((e,t)=>{var a=e=>{try{i(n.next(e))}catch(e){t(e)}},l=e=>{try{i(n.throw(e))}catch(e){t(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(a,l);i((n=n.apply(null,null)).next())});var n})(i,n.enabled)),Promise.all(m)},{onSuccess:m,onError:e=>{a?y.invalidateQueries(["config"]):y.invalidateQueries(["teams",t]),null==p||p(e)}})},v=a(97873),E=a(89937),b=Object.defineProperty,g=Object.defineProperties,A=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,k=(e,t,a)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,N=(e,t)=>{for(var a in t||(t={}))S.call(t,a)&&k(e,a,t[a]);if(w)for(var a of w(t))C.call(t,a)&&k(e,a,t[a]);return e},T=(e,t)=>
1g(e,A(t));const P=e=>e.reduce((e,t)=>(e[t.name]=!0,e),{});var O=({includeAny:e,includeAll:t,excludeAny:a,excludeAll:o}={})=>{const{isPremiumTier:r,currentTeam:s}=(0,l.useContext)(i.BR),[c,u]=(0,l.useState)("All hosts"),[d,m]=(0,l.useState)("any"),[p,y]=(0,l.useState)("any"),[f,h]=(0,l.useState)({}),[_,b]=(0,l.useState)({}),{data:g=[],isLoading:A,isError:w}=(0,n.useQuery)(["custom_labels",s],()=>v.Ay.summary(null==s?void 0:s.id,!0),T(N({},E.QL),{enabled:r&&!!s,staleTime:1e4,select:e=>(0,v.f2)(e.labels)}));(0,l.useEffect)(()=>{const l=(({includeAny:e=[],includeAll:t=[],excludeAny:a=[],excludeAll:l=[]})=>{const n=!!(e.length||t.length||a.length||l.length),i=t.length?"all":"any",o=l.length?"all":"any";return{targetType:n?"Custom":"All hosts",includeMode:i,includeLabels:P("all"===i?t:e),excludeMode:o,excludeLabels:P("all"===o?l:a)}})({includeAny:e,includeAll:t,excludeAny:a,excludeAll:o});u(l.targetType),m(l.includeMode),h(l.includeLabels),y(l.excludeMode),b(l.excludeLabels)},[e,t,a,o]);const S={selectedLabels:f,onSelectLabel:({name:e,value:t})=>h(a=>T(N({},a),{[e]:t})),showModeToggle:!0,mode:d,onSelectMode:m,anyTooltip:l.createElement(l.Fragment,null,"Will only target hosts that have"," ",l.createElement("em",null,l.createElement("b",null,"any"))," ","of these labels."),allTooltip:l.createElement(l.Fragment,null,"Will only target hosts that have"," ",l.createElement("em",null,l.createElement("b",null,"all"))," ","of these labels.")},C={selectedLabels:_,onSelectLabel:({name:e,value:t})=>b(a=>T(N({},a),{[e]:t})),showModeToggle:!0,mode:p,onSelectMode:y,anyTooltip:l.createElement(l.Fragment,null,"Will not target hosts that have"," ",l.createElement("em",null,l.createElement("b",null,"any"))," ","of these labels."),allTooltip:l.createElement(l.Fragment,null,"Will not target hosts that have"," ",l.createElement("em",null,l.createElement("b",null,"all"))," ","of these labels.")},k=(0,v.XX)(f).length>0||(0,v.XX)(_).length>0,O=(0,l.useCallback)(()=>(({targetType:e,includeMode:t,includeLabels:a,excludeMode:l,excludeLabels:n})=>{const i="Custom"===e?(0,v.XX)(a):[],o="Custom"===e?(0,v.XX)(n):[];return{labels_include_any:"any"===t?i:[],labels_include_all:"all"===t?i:[],labels_exclude_any:"any"===l?o:[],labels_exclude_all:"all"===l?o:[]}})({targetType:c,includeMode:d,includeLabels:f,excludeMode:p,excludeLabels:_}),[c,d,f,p,_]);return{selectorProps:{selectedTargetType:c,onSelectTargetType:u,labels:g,isLoadingLabels:A,isErrorLabels:w,includeConfig:S,excludeConfig:C},selectedTargetType:c,hasCustomLabels:k,getLabelsPayload:O}}},20424:function(e,t,a){a.r(t),a.d(t,{default:function(){return fe}});var l=a(96540),n=a(75942),i=a(24740),o=a(78263),r=a(38944),s=a(68774),c=a(59593),u=a(89937),d=a(12968),m=a(10664),p=a(42235),y=a(827),f=a(6514),h=a(10162),_=a.n(h),v=a(46157),E=a(9467),b=a(77803),g=a(43788),A=a(14332),w=a(47936),S=a(53806),C=a(32485),k=a.n(C),N=a(91936),T=a.n(N),P=a(37706),O=a(74953),L=a(2367),I=a(15570),x=a(37738),D=a(38021),M=a(67310),R=a(52603),$=a(5534),F=a(49915),q=a(2543),Q=a(34724),W=a(45847),H=a(3728),j=a(72828),B=a(81302);const U=(0,q.memoize)((e=[])=>e.sort((e,t)=>B.A.caseInsensitiveAsc(e.display_name,t.display_name)));var z=({hostResponses:e,isLoading:t,resultsTitle:a})=>l.createElement("div",{className:"policy-results-table"},l.createElement(Q.A,{resultsTitle:a||"policies",columnConfigs:[{title:"Host",Header:e=>l.createElement(j.A,{value:e.column.title||e.column.id,isSortedDesc:e.column.isSortedDesc}),disableSortBy:!1,accessor:"display_name",Cell:e=>l.createElement(H.A,{value:e.cell.value}),sortType:"caseInsensitive"},{title:"Status",Header:e=>l.createElement(j.A,{value:e.column.title||e.column.id,isSortedDesc:e.column.isSortedDesc}),disableSortBy:!1,sortType:"hasLength",accessor:"query_results",Cell:e=>l.createElement(l.Fragment,null,e.cell.value.length?l.createElement(l.Fragment,null,l.createElement(W.A,{name:"success"}),l.createElement("span",{className:"status-header-text"},"Pass")):l.createElement(l.Fragment,null,l.createElement(W.A,{name:"error"}),l.createElement("span",{className:"status-header-text"},"Fail")))}],data:U(e),isLoading:t,defaultSortHeader:"query_results",defaultSortDirection:"asc",showMarkAllPages:!1,isAllPagesSelected:!1,isClientSidePagination:!0,primarySelectAction:{name:"delete policy",buttonText:"Delete",iconSvg:"trash",variant:"secondary"},emptyComponent:()=>l.createElement(L.A,{header:"No hosts are online"}),onQueryChange:q.noop,disableCount:!0}));const G=(0,q.memoize)((e=[])=>e.sort((e,t)=>
1B.A.caseInsensitiveAsc(e.host_display_name,t.host_display_name)));var Y=({errorsList:e,isLoading:t,resultsTitle:a})=>l.createElement("div",{className:"policy-results-table"},l.createElement(Q.A,{resultsTitle:a||"policies",columnConfigs:[{title:"Host",Header:"Host",disableSortBy:!0,accessor:"host_display_name",Cell:e=>l.createElement(H.A,{value:e.cell.value})},{title:"Osquery version",Header:"Osquery version",disableSortBy:!0,accessor:"osquery_version",Cell:e=>l.createElement(H.A,{value:e.cell.value})},{title:"Error",Header:"Error",disableSortBy:!0,accessor:"error",Cell:e=>l.createElement(H.A,{value:e.cell.value})}],data:G(e),isLoading:t,defaultSortHeader:"name",defaultSortDirection:"asc",manualSortBy:!0,showMarkAllPages:!1,isAllPagesSelected:!1,disablePagination:!0,primarySelectAction:{name:"delete policy",buttonText:"Delete",iconSvg:"trash",variant:"secondary"},emptyComponent:()=>l.createElement(L.A,{header:"No hosts are online"}),onQueryChange:q.noop,disableCount:!0}));const K="query-results",V="New Policy";var X=({campaign:e,isQueryFinished:t,policyName:a,onRunQuery:n,onStopQuery:i,setSelectedTargets:o,goToQueryEditor:r,targetsTotalCount:s})=>{const{lastEditedQueryBody:u}=(0,l.useContext)(c.q),{hosts:d,uiHostCounts:m,serverHostCounts:p,errors:y}=e||{},[f,h]=(0,l.useState)(0),[_,v]=(0,l.useState)(!1),E=e=>{if(e.preventDefault(),d){const e=d.map(e=>({host:e.display_name,status:e.query_results&&e.query_results.length?"yes":"no"}));T().saveAs((0,P.yP)(e,(0,P.$e)(`${a||V} - Results`)))}},b=e=>{e.preventDefault(),y&&T().saveAs((0,P.$U)(y,(0,P.$e)(`${a||V} - Errors`)))},g=()=>{v(!_)},A=e=>l.createElement("div",{className:`${K}__results-cta`},l.createElement(O.A,{className:`${K}__show-query-btn`,onClick:g,variant:"secondary",icon:"eye",iconPosition:"right"},"Show query"),l.createElement(O.A,{className:`${K}__export-btn`,onClick:"errors"===e?b:E,variant:"secondary",icon:"download",iconPosition:"right"},"Export ",e)),w=k()("react-tabs__tab","no-count",{"errors-empty":!y||0===(null==y?void 0:y.length)});return l.createElement("div",{className:`${K} notranslate`},l.createElement($.A,{numHostsTargeted:s,numHostsResponded:m.total,numHostsRespondedResults:p.countOfHostsWithResults,numHostsRespondedNoErrorsAndNoResults:p.countOfHostsWithNoResults,numHostsRespondedErrors:m.failed,isFinished:t,onClickClose:()=>{o([]),r()},onClickRunAgain:n,onClickStop:i,resultsType:"policy"}),l.createElement(I.A,null,l.createElement(S.tU,{selectedIndex:f,onSelect:e=>h(e)},l.createElement(S.wb,null,l.createElement(S.oz,{className:w},l.createElement(x.A,null,"Results")),l.createElement(S.oz,{disabled:!(null==y?void 0:y.length)},l.createElement(x.A,{count:null==y?void 0:y.length,countVariant:"alert"},"Errors"))),l.createElement(S.Kp,null,(()=>{const e=!d||!d.length||!m.successful,a=!t&&e,n=t&&(!m.successful||e);if(a)return l.createElement(F.A,null);if(n){const e=1===s?"host is":"hosts are",t=(null==y?void 0:y.length)?l.createElement(l.Fragment,null," ","or review the ",l.createElement("strong",null,"Errors")," tab for details"):null;return l.createElement(L.A,{header:"No results returned",info:l.createElement(l.Fragment,null,"Check whether the ",e," online",t,".")})}return l.createElement("div",{className:`${K}__results-table-container`},l.createElement(D.A,null,"Hosts that responded with results are marked ",l.createElement("strong",null,"Pass"),". Hosts that responded with no results are marked ",l.createElement("strong",null,"Fail"),"."),l.createElement("div",{className:`${K}__results-table-header`},l.createElement("span",{className:`${K}__results-meta`},l.createElement("span",{className:`${K}__results-count`},m.successful," result",1!==m.successful&&"s"),t&&(()=>{const{yes:e,no:t}=(e=>e.reduce((e,t)=>{var a;return(null==(a=t.query_results)?void 0:a.length)?e.yes+=1:e.no+=1,e},{yes:0,no:0}))(d);return l.createElement("span",{className:`${K}__results-pass-fail-pct`}," ","(Yes:"," ",l.createElement(R.A,{tipContent:`${e} host${1!==e?"s":""}`},Math.round(e/m.successful*100),"%"),", No:"," ",l.createElement(R.A,{tipContent:`${t} host${1!==t?"s":""}`},Math.round(t/m.successful*100),"%"),")")})()),l.createElement("div",{className:`${K}__results-cta`},A("results"))),l.createElement(z,{isLoading:!1,hostResponses:d,resultsTitle:"hosts"}))})()),l.createElement(S.Kp,null,l.createElement("div",{className:`${K}__error-table-container`},l.createElement("div",{className:`${K}__errors-table-header`},y&&l.createElement("span",{className:`${K}__error-count`},y.length," error",1!==y.length&&"s"),l.createElement("div",{className:`${K}__errors-cta`},A("errors"))),l.createElement(Y,{isLoading:!1,errorsList:y,resultsTitle:"errors"}))))),_&&l.createElement(M.A,{query:u,onCancel:g}))},J=Object.defineProperty,Z=Object.defineProperties,ee=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertySymbols,ae=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,ne=(e,t,a)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,ie=(e,t)=>{for(var a in t||(t={}))ae.call(t,a)&&ne(e,a,t[a]);if(te)for(var a of te(t))le.call(t,a)&&ne(e,a,t[a]);return e},oe=(e,t)=>Z(e,ee(t)),re=({storedPolicy:e,selectedTargets:t,setSelectedTargets:a,goToQueryEditor:n,targetsTotalCount:i})=>{const[o,r]=(0,l.useState)(!1),[s,d]=(0,l.useState)(u.LY),{lastEditedQueryBody:m}=(0,l.useContext)(c.q),p=(0,l.useRef)(null),y=(0,l.useRef)(null),f=(0,l.useRef)(null),h=(0,l.useRef)(null),S=()=>{f.current&&(f.current.close(),f.current=null,h.current=null)},C=()=>{y.current&&(clearInterval(y.current),y.current=null),d(e=>oe(ie({},e),{queryIsRunning:!1,runQueryMilliseconds:0})),r(!0),S()},k=(0,A.A)(()=>{return e=function*(){if(!m)return void v.me.error("Something went wrong running your report. Please try again.");const e=(0,E.yp)(t);r(!1),S(),d(u.LY);try{const t=null;(e=>{let{current:t}
1=p;t=new(_())(`${u.C1}/v1/fleet/results`,void 0,{}),t.onopen=()=>{var a;a=t,f.current=a,y.current||(y.current=setInterval(()=>{d(e=>oe(ie({},e),{runQueryMilliseconds:e.runQueryMilliseconds+1e3}))},1e3)),d(t=>oe(ie({},t),{campaign:oe(ie({},t.campaign),{returnedCampaign:e}),queryIsRunning:!0})),null==t||t.send(JSON.stringify({type:"auth",data:{token:w.A.get()}})),null==t||t.send(JSON.stringify({type:"select_campaign",data:{campaign_id:e.id}}))},t.onmessage=({data:e})=>{if(e===h.current)return;h.current=e;const t=JSON.parse(e);return d(e=>ie(ie({},e),b.A.updateCampaignState(t)(e))),"status"===t.type&&"finished"===t.data.status?C():void 0}})(yield g.A.run({query:m,queryId:t,selected:e}))}catch(e){if("resource already created"===e&&v.me.error("A campaign with the provided query text has already been created",{response:e}),"object"==typeof e&&null!==e&&"message"in e){const{message:t}=e;"forbidden"===t?v.me.error("It seems you do not have the rights to run this report. If you believe this is an error, please contact your administrator.",{response:e}):v.me.error("Something has gone wrong. Please try again.",{response:e})}return C()}},new Promise((t,a)=>{var l=t=>{try{i(e.next(t))}catch(e){a(e)}},n=t=>{try{i(e.throw(t))}catch(e){a(e)}},i=e=>e.done?t(e.value):Promise.resolve(e.value).then(l,n);i((e=e.apply(null,null)).next())});var e});(0,l.useEffect)(()=>{k()},[]);const{campaign:N}=s;return l.createElement(X,{campaign:N,isQueryFinished:o,onRunQuery:k,onStopQuery:e=>(e.preventDefault(),C()),setSelectedTargets:a,goToQueryEditor:n,policyName:null==e?void 0:e.name,targetsTotalCount:i})},se=Object.defineProperty,ce=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,me=(e,t,a)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,pe=(e,t)=>{for(var a in t||(t={}))ue.call(t,a)&&me(e,a,t[a]);if(ce)for(var a of ce(t))de.call(t,a)&&me(e,a,t[a]);return e};const ye="live-policy-page";var fe=({router:e,params:{id:t},location:a})=>{const h=t?parseInt(t,10):null,_=(0,i.useErrorHandler)(),{currentTeamId:v}=(0,r.Ay)({location:a,router:e,includeAllTeams:!0,includeNoTeam:!0}),{config:E}=(0,l.useContext)(s.BR),{setLastEditedQueryId:b,setLastEditedQueryName:g,setLastEditedQueryDescription:A,setLastEditedQueryBody:w,setLastEditedQueryResolution:S,setLastEditedQueryCritical:C,setLastEditedQueryPlatform:k,setLastEditedQueryLabelsIncludeAny:N,setLastEditedQueryLabelsIncludeAll:T,setLastEditedQueryLabelsExcludeAny:P}=(0,l.useContext)(c.q),[O,L]=(0,l.useState)(!1),[I,x]=(0,l.useState)(u.oV[1]),[D,M]=(0,l.useState)([]),[R,$]=(0,l.useState)([]),[F,q]=(0,l.useState)([]),[Q,W]=(0,l.useState)([]),[H,j]=(0,l.useState)(0),B=null==E?void 0:E.server_settings.live_query_disabled,U=-1===v?void 0:v;(0,l.useEffect)(()=>{if(B){const t=h?o.A.POLICY_DETAILS(h):o.A.MANAGE_POLICIES;e.push((0,d.M8)(t,{fleet_id:U}))}},[B,h,e,U]);const{data:z}=(0,n.useQuery)(["policy",h,U],()=>m.A.load(h),{enabled:!!h,refetchOnWindowFocus:!1,select:e=>e.policy,onSuccess:e=>{b(e.id),g(e.name),A(e.description),w(e.query),S(e.resolution),C(e.critical),k(e.platform),N(e.labels_include_any||[]),T(e.labels_include_all||[]),P(e.labels_exclude_any||[])},onError:e=>_(e)}),G=a.query.host_ids?parseInt(a.query.host_ids,10):null;(0,n.useQuery)(["hostFromURL",G,U],()=>p.A.loadHostDetails(G),{enabled:!!G&&!O,select:e=>e.host,onSuccess:t=>{$(e=>e.filter(e=>e.id!==t.id).concat(t));const l=D;t.target_type="hosts",l.push(t),M([...l]),O||L(!0),e.replace(a.pathname)}}),(0,l.useEffect)(()=>{(null==z?void 0:z.name)?document.title=`Run ${z.name} | Policies | ${u.DI}`:document.title=`Policies | ${u.DI}`},[a.pathname,null==z?void 0:z.name]);const Y=(0,l.useCallback)(()=>{const t=h?o.A.EDIT_POLICY(h):o.A.NEW_POLICY;e.push((0,d.M8)(t,{fleet_id:U}))},[h,e,U]);return l.createElement(y.A,{className:ye},l.createElement("div",{className:`${ye}_wrapper`},(()=>{const e={baseClass:ye,selectedTargets:D,targetedHosts:R,targetedLabels:F,targetedTeams:Q,targetsTotalCount:H,goToQueryEditor:Y,goToRunQuery:()=>x(u.oV[2]),setSelectedTargets:M,setTargetedHosts:$,setTargetedLabels:q,setTargetedTeams:W,setTargetsTotalCount:j,isLivePolicy:!0},t={selectedTargets:D,storedPolicy:z,setSelectedTargets:M,goToQueryEditor:Y,targetsTotalCount:H};return I===u.oV[2]?l.createElement(re,pe({},t)):l.createElement(f.A,pe({},e))})()))}},10664:function(e,t,a){var l=a(97126),n=a(90508),i=a(12968);t.A={load:e=>{const{GLOBAL_POLICIES:t}=n.A,a=`${t}/${e}`;return(0,l.Ay)("GET",a)},getAutomationActivities:({policyId:e,page:t,perPage:a,orderKey:o,orderDirection:r,query:s,status:c})=>{const{POLICY_AUTOMATION_ACTIVITIES:u}=n.A,d=(0,i.IM)({page:t,per_page:a,order_key:o,order_direction:r,query:s||void 0,status:c||void 0}),m=`${u(e)}?${d}`;return(0,l.Ay)("GET",m)},reset:e=>{const{POLICY_RESET:t}=n.A;return(0,l.Ay)("POST",t(e))}}},9106:function(e,t,a){a.d(t,{HZ:function(){return i},P$:function(){return u},bv:function(){return s},v7:function(){return y}});var l=a(96540),n=a(52603);const i={json:"macOS",pkg:"macOS",mobileconfig:"macOS",exe:"Windows",msi:"Windows",xml:"Windows",deb:"Linux",rpm:"Linux","tar.gz":"Linux",sh:"macOS & Linux",ps1:"Windows",py:"macOS & Linux",ipa:"iOS/iPadOS"},o=["tar.gz","tar.xz","tar.bz2","tar.zst"],r={tgz:"tar.gz",tbz2:"tar.bz2",tzst:"tar.zst",txz:"tar.xz"},s=e=>{const t=e.toLowerCase().split("."),a=o.find(e=>{const a=e.split(".");return t.slice(-a.length).join(".")===e});let l;return a?l=a:t.length>1&&(l=t.pop()),l&&r[l]&&(l=r[l]),l},c=e=>{const t=s(e.name);if(t)return"ipa"===t?l.createElement(n.A,{tipContent:"Software will be added for both platforms."},i[t]):i[t]},u=e=>({name:e.name,description:c(e)}),d=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],m=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],p=(e,t,a)=>{let l=e,n=0;for(;l>=t&&n<a.length-1;)l/=t,n+=1;return`${Number(l.toPrecision(4))}${a[n]}`},y=e=>{const t=p(e,1e3,d),a=p(e,1024,m);return a.length<t.length?a:t}}}]);
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.