1import{a as h}from"./chunk-IR3IXP4R.js";import{a as i,c as p}from"./chunk-KKTVKEJB.js";import{N as d,R as s,aa as v,bc as a,ia as c,l as u}from"./chunk-IIXPTABD.js";import{a as m,b as y}from"./chunk-7CGTOI24.js";var g=class o{constructor(r){this.document=r}document;loadStylesheet(r,e){if(!this.isValidRelativeUrl(e))throw console.error(`Invalid CSS URL rejected: ${e}. Only relative URLs starting with '/' are allowed.`),new Error("Invalid CSS URL: Only relative URLs starting with '/' are allowed");let n=this.document.getElementById(r);if(n){n.href=e;return}let t=this.document.createElement("link");t.id=r,t.rel="stylesheet",t.type="text/css",t.href=e,this.document.head.appendChild(t)}isValidRelativeUrl(r){return!(!r?.startsWith("/")||r.startsWith("//")||r.includes("://"))}removeStylesheet(r){let e=this.document.getElementById(r);e&&e.remove()}static \u0275fac=function(e){return new(e||o)(s(v))};static \u0275prov=d({token:o,factory:o.\u0275fac,providedIn:"root"})};var b=class o{constructor(r,e,n){this.apiService=r;this.brandService=e;this.domStylesheet=n}apiService;brandService;domStylesheet;_agencyBrand=c(null);_isLoading=c(!1);_error=c(null);agencyBrand=this._agencyBrand.asReadonly();isLoading=this._isLoading.asReadonly();error=this._error.asReadonly();logoUrl=a(()=>this._agencyBrand()?.logoUrl??null);primaryColor=a(()=>this._agencyBrand()?.primaryColor??i.GovernmentJobs.primary);primaryHoverColor=a(()=>this._agencyBrand()?.primaryHoverColor??i.GovernmentJobs.primaryHover);brandNameTitle=a(()=>this._agencyBrand()?.brandNameTitle??"Government Jobs");brandNameSubTitle=a(()=>this._agencyBrand()?.brandNameSubTitle??"");agencySlug=a(()=>this._agencyBrand()?.agencySlug??null);departmentSlug=a(()=>this._agencyBrand()?.departmentSlug??null);customCssUrl=a(()=>this._agencyBrand()?.customCssUrl??null);hasAgencyBranding=a(()=>this._agencyBrand()!==null);async loadAgencyBrand(r,e){this.validateSlug(r,"Agency slug"),e&&this.validateSlug(e,"Department slug"),this._isLoading.set(!0),this._error.set(null);try{let n=this.buildBrandUrl(r,e),t=await u(this.apiService.get(n));if(!t.agencySlug)throw new Error("Invalid agency brand configuration: missing agencySlug");let l=this.normalizeBrand(t);return this.applyBrandConfiguration(l),l}catch(n){return this.handleLoadError(n,r,e)}finally{this._isLoading.set(!1)}}validateSlug(r,e){if(!r||typeof r!="string")throw new Error(`${e} is required`);if(!/^[a-zA-Z0-9_-]+$/.test(r))throw new Error(`${e} contains invalid characters. Only alphanumeric, hyphens, and underscores are allowed.`);if(r.includes("..")||r.includes("/")||r.includes("\\"))throw new Error(`${e} cannot contain path traversal characters`)}buildBrandUrl(r,e){return e?`/api/v2/agencies/${r}/departments/${e}/brand`:`/api/v2/agencies/${r}/brand`}normalizeBrand(r){return y(m({},r),{primaryColor:r.primaryColor||i.GovernmentJobs.primary,primaryHoverColor:r.primaryHoverColor||i.GovernmentJobs.primaryHover})}applyBrandConfiguration(r){this._agencyBrand.set(r),this.brandService.setAgencyBrandOverride({logoUrl:r.logoUrl,primaryColor:r.primaryColor,primaryHoverColor:r.primaryHoverColor,brandNameTitle:r.brandNameTitle,brandNameSubTitle:r.brandNameSubTitle}),r.customCssUrl?this.loadCustomCss(r.customCssUrl):this.domStylesheet.removeStylesheet("agency-custom-css")}handleLoadError(r,e,n){let t=r instanceof Error?r.message:"Unknown error";console.error(`Failed to load agency brand for '${e}':`,t),this._error.set(t),this.domStylesheet.removeStylesheet("agency-custom-css");let l={agencySlug:e,logoUrl:null,primaryColor:i.GovernmentJobs.primary,primaryHoverColor:i.GovernmentJobs.primaryHover,brandNameTitle:e,brandNameSubTitle:"",departmentSlug:n};return this._agencyBrand.set(l),l}loadCustomCss(r){try{this.domStylesheet.loadStylesheet("agency-custom-css",r)}catch(e){console.error("Failed to load custom agency CSS:",e)}}reset(){this._agencyBrand.set(null),this._error.set(null),this.brandService.setAgencyBrandOverride(null),this.domStylesheet.removeStylesheet("agency-custom-css")}getAgencyHomeUrl(){let r=this.agencySlug(),e=this.departmentSlug();return r?e?`/careers/${r}/${e}`:`/careers/${r}`:"/"}getAgencyUrl(r){let e=this.agencySlug();if(!e)return r;let n=r.startsWith("/")?r:`/${r}`;return`/careers/${e}${n}`}static \u0275fac=function(e){return new(e||o)(s(h),s(p),s(g))};static \u0275prov=d({token:o,factory:o.\u0275fac,providedIn:"root"})};export{b as a};
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.