@inploi/sdk 3.1.1 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{a as Tt}from"./chunk-KC7FKSIJ.mjs";var te="%c[inploi SDK]",ne="color: #65BC67; font-weight: bold;",fe={warn:(...t)=>console.warn(te,ne,...t),error:(...t)=>console.error(te,ne,...t),info:(...t)=>console.info(te,ne,...t),log:(...t)=>console.log(te,ne,...t)},ye={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Et=t=>t;function Se(t,n){if(!t)throw new Error(n)}function M(t,n){return n in t}var Hn=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var xt="Unauthenticated",It="This action is unauthorized.",O=class extends Error{constructor(r,i){super(r);this.status=i,this.name="ErrorWithStatus"}},G=class extends O{constructor(n){super(n??"Not found"),this.name="NotFoundError",this.status=404}},q=class extends O{constructor(n,r){super(n??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=r??401}},w=class extends O{constructor(r,i){let l=i?` in ${i}`:"";super(`Schema validation failed${l}`);this.issues=r;this.source=i;this.name="SchemaValidationError",this.status=400}},V=class extends O{constructor(r,i,l){super(r);this.data=l;this.name="ApiError",this.status=i??500}},Rt=t=>t instanceof V&&t.data!==void 0,$=class extends O{constructor(r){super("Error parsing response into JSON.");this.response=r;this.name="ParsingError",this.status=r&&r.status>=300?r.status:500,this.contentType=new Headers(r?.headers).get("content-type")??void 0}};async function be(t){let r=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(r&&r!=="application/json"&&!r.endsWith("+json"))throw new $(t);return t.json().catch(()=>{throw new $(t)})}var wt=["message","error","errors","exception","exceptions"];function Pt(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of wt)if(M(t,r)){let i=t[r];typeof i=="string"&&n.push(i),Array.isArray(i)&&i.every(l=>typeof l=="string")&&n.push(...i)}M(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&M(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&M(t.integration_response.error,"message")&&typeof t.integration_response.error.message=="string"&&n.push(t.integration_response.error.message)}return n.length===0&&n.push("Unknown error"),[...new Set(n)].join(", ")}function _e(t,n){if(n>=300){let r=Pt(t);throw n===404?new G(r):r===xt?new q("You are not authenticated.",n):r===It?new q(r,n):new V(r,n,t)}}var je=t=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(r,i={})=>{let l={...i,headers:{...i.headers,...n}},c=await fetch(`${t.baseUrl}${r}`,l);if(c.status===404)throw new G;let d=await be(c);return _e(d,c.status),d}}},Ne={NotFound:G,Unauthorised:q,SchemaValidation:w,Api:V,JsonParsing:$};function kt(t){return Object.values(Ne).some(n=>t instanceof n)}var Fe="3.1.1";var re={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},Ue={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},Be=Fe;var P="isdk_session",Me=`${P}-candidate_id`,Ge=`${P}-consent`;var oe=new Map,Ae={get:t=>{if(oe.has(t))return oe.get(t)??null;try{return window.sessionStorage.getItem(t)}catch{return null}},set:(t,n)=>{try{window.sessionStorage.setItem(t,n),oe.delete(t)}catch{oe.set(t,n)}}};var J=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+t/4).toString(16));var Ve=7*24*60*60*1e3,$e=t=>{let n=new Date;return n.setTime(n.getTime()+Ve),`${P}=${t};expires=${n.toUTCString()};path=/`},Lt=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let i=Ae.get(`${P}-session_id`);return typeof i=="string"?i:null},Dt=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(Me);return typeof t=="string"&&t!==""?t:null}catch{return null}},Ot=new RegExp(`(?:^|;\\s*)${P}=([^;]+)`),Y=t=>{let n=t?t.headers.get("cookie"):document.cookie;return n?Ot.exec(n)?.[1]??null:null},He=()=>{try{let t=JSON.parse(window.localStorage.getItem(P)??"null");return typeof t!="object"||t===null||!("id"in t)||!("expires"in t)||typeof t.id!="string"||typeof t.expires!="number"?null:t.id!==""&&t.expires>Date.now()?t.id:null}catch{return null}},qe=()=>Y()??(new URL(location.href).searchParams.get("anonymous_id")?null:He()),jt=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",Ke=t=>{if(document.cookie=$e(t)+jt(),Y()!==t)try{window.localStorage.setItem(P,JSON.stringify({id:t,expires:Date.now()+Ve}))}catch{}},Te=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:t?Y(t)??r.get("anonymous_id"):Y()??r.get("anonymous_id")??He(),session_id:Lt(r,typeof window>"u")}},We=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=Te().anonymous_id;if(t)return t;let n=J(),r=Te().anonymous_id;return r||(Ke(n),n)},Nt=t=>typeof t!="object"||t===null?null:{anonymous_id:"anonymous_id"in t&&typeof t.anonymous_id=="string"?t.anonymous_id:null,session_id:"session_id"in t&&typeof t.session_id=="string"?t.session_id:null},Ft=t=>t==="about:client"?"":t,Ut={pathname:"/log",method:"POST",schema:{response:C(),body:C()}},Je=({rpcClient:t,logger:n,onEvent:r,persistence:i="device",siteKind:l})=>{let c=null,d=null,u=0,S=0,E=p=>i==="none"?{anonymous_id:null,session_id:p?null:c}:Te(p),U=async(p,h,X)=>{try{let B={library:{name:"inploi-sdk",version:Be},page:h},W=E(p.request),ee=i==="none"?null:Dt(),f={anonymous_id:W.anonymous_id,session_id:W.session_id,candidate_id:ee,event:p.event,sent_at:new Date().toISOString(),context:B,properties:p.properties,custom_properties:{...p.customProperties,...X}},ve=i==="none"?null:p.request?Y(p.request):qe(),De=++u,_t=await t.request(Ut,{body:f,...p.keepalive&&{keepalive:!0}}),x=Nt(_t);if(i==="none")return!p.request&&x?.session_id&&De>S&&(S=De,x.session_id!==f.session_id&&(c=x.session_id)),f.session_id=p.request?x?.session_id||null:c,r?.(f),{success:!0,data:f};let ge=p.request?ve:qe(),At=ge!==null&&ge!==ve,he=ge??ve,Oe=!At&&(!he||!x?.anonymous_id||he===x.anonymous_id);return Oe?(x?.anonymous_id&&(f.anonymous_id=x.anonymous_id),x?.session_id&&(f.session_id=x.session_id)):f.anonymous_id=he,!p.request&&typeof window<"u"&&f.anonymous_id&&(Oe&&f.session_id&&Ae.set(`${P}-session_id`,f.session_id.toString()),Ke(f.anonymous_id)),r?.(f),{success:!0,data:f}}catch(B){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:B}}},D=Promise.resolve();return{log:async p=>{Se(p.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let h="request"in p&&p.request?{href:p.request.url,referrer:Ft(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(p.page_context==="no_query"){let ee=new URL(h.href),f=h.referrer?new URL(h.referrer):void 0;h={href:ee.origin+ee.pathname,referrer:f?f.origin+f.pathname:""}}i==="none"&&p.event==="FLOW_NODE"&&p.properties&&"trigger"in p.properties&&(p.properties.trigger==="pagehide"||p.properties.trigger==="hidden")&&(p={...p,keepalive:!0});let X={event_id:J(),consent_lane:i,site_kind:l};if(i==="device"||p.request||c||p.keepalive)return U(p,h,X);let B=()=>U(p,h,X),W=D.then(B,B);return D=W,W},supportsNoQueryPageContext:!0,getHeaders:p=>{let h=new Headers;return i==="none"||!p?.anonymous_id||h.append("Set-Cookie",$e(p.anonymous_id)),h},getSessionInfo:E,getOrCreateAnonymousId:()=>i==="none"?d??(d=J()):We()}};import{stringify as Bt}from"neoqs";function Ee(t,n,r){let i=t["~standard"].validate(n);if(i instanceof Promise)throw new TypeError("Async schema");if(i.issues)throw new w(i.issues,r);return i.value}function Mt(t,n,r){try{return{success:!0,output:Ee(t,n,r)}}catch(i){if(i instanceof w)return{success:!1,issues:i.issues,source:i.source};throw i}}var z=class{constructor(n){if(this.baseUrl=re[n.environment],this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json"}),n.apiKey.type==="secret"){if(typeof window<"u")throw new Error("Secret key cannot be used in a browser environment");this.headers.set("x-secret-key",n.apiKey.key)}else this.headers.set("x-publishable-key",n.apiKey.key);this.logger=n.logger,this._environment=n.environment}get environment(){return this._environment}getFetchParams(n,r){let i=r.validateIn??!0,{searchParams:l,body:c}=i?Ye(n,r):r,d=new URL(this.baseUrl),u=n.pathname;if("params"in r&&r.params)for(let[S,E]of Object.entries(r.params))u=u.replace(`:${S}`,String(E));return d.pathname=u,n.schema.searchParams&&(d.search=Bt(l)),[d.toString(),{method:n.method,body:c?JSON.stringify(c):void 0,headers:this.headers,signal:r.signal,...r.keepalive&&{keepalive:!0}}]}async parseResponse(n,r){let i=await be(r.response);if(_e(i,r.response.status),!(r.validateOut??!0))return i;let c=Mt(n.schema.response,i,"response");if(!c.success)throw new w(c.issues,c.source);return c.output}async request(n,r){try{let i=this.getFetchParams(n,r),l=await fetch(...i);return await this.parseResponse(n,{response:l,validateOut:r.validateOut})}catch(i){throw i instanceof w?this.logger.error(i.message,i.issues):this.logger.error(i),i}}};function C(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function ie(t){return t}function Ye(t,n){let r={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(r.searchParams=Ee(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=Ee(t.schema.body,"body"in n?n.body:{})),r}function Gt({publishableKey:t,env:n,logger:r=fe,onEvent:i,persistence:l,siteKind:c}){let d=je({baseUrl:re[n],publishableKey:t}),u=r===!1?ye:r,S=new z({environment:n,apiKey:{type:"publishable",key:t},logger:u}),E=Je({rpcClient:S,logger:u,onEvent:i,persistence:l,siteKind:c});return{register:D=>D({logger:u,apiClient:d,analytics:E,rpcClient:S,publishableKey:t,env:n}),analytics:E,apiClient:d}}var qt={VIEW_PAGE:"A careers-site page shown (not a job page).",VIEW_JOB:"A job's own page shown; one per job id the page names.",PAGE_ENGAGEMENT:"A page view's attention summary, sent when the view is hidden or left.",VIEW_SEARCH:"A job search seen for two seconds.",SEARCH_SETTLE:"A searched query or filter with results, unchanged for five seconds.",SEARCH_RESULTS:"A search whose results returned, zero included; once per distinct query, filters, place and order.",SEARCH_PAGINATE:"A move to another page of search results.",SEARCH_JOB_CLICK:"A job opened from search results.",SAVE_JOB:"A job saved or unsaved by the candidate.",LINK_CLICK:"A tracked link clicked.",INTERACTION:"A tagged interaction (`tag` names it).",FLOW_START:"An application flow started.",FLOW_INTERACT:"The candidate's first answer in a flow.",FLOW_END:"An application flow ended.",FLOW_NODE:"The candidate's path through an application, summarised when it pauses or ends.",FLOW_SUBMIT:"An application submitted, with the outcome.",FLOW_REDIRECT:"A flow sent the candidate to an external apply page.",FEEDBACK:"A rating or comment.",ADDRESS_SHADOW_COMPARED:"Engineering telemetry: the address lookup's shadow comparison.",SUBMIT_FORM:"Declared but sent by nothing."};function xe(t){let n=JSON.stringify({message:t.message,acceptLabel:t.acceptLabel??"",declineLabel:t.declineLabel??""}),r=5381;for(let i=0;i<n.length;i++)r=r*33^n.charCodeAt(i);return(r>>>0).toString(36)}function Ie(t,n){return`${Ge}:${t}:${n}`}function Vt(t,n){if(typeof window>"u")return!1;try{let r=Ie(t,xe(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function $t(t,n){if(!(typeof window>"u"))try{let r=Ie(t,xe(n));window.localStorage.setItem(r,"accepted")}catch{}}import*as s from"valibot";var Ht=["agent","sdk","form","integration","migration"],Kt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var Wt=["screening","cv_match","interview","overall"],Jt=["PENDING","IN_PROGRESS","COMPLETED","CANCELLED"],Yt=["agent"],zt=["job","company"],Qt=["created_at","updated_at","score","interview_score"],Zt=["asc","desc"],Xt=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],en=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written","ats_submission_attempted","ats_submission_succeeded","ats_submission_failed","ats_retry_payload_purged"],tn=["pending","submitted","failed","not_required"],nn=["user","system","automation","integration","candidate"],se=s.picklist(Ht),I=s.picklist(Kt),T=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ae=s.picklist(Wt),ze=s.picklist(Jt),Qe=s.picklist(Yt),xr=s.picklist(zt),Ze=s.picklist(Qt),Xe=s.picklist(Zt),Q=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ce=s.picklist(Xt),et=s.picklist(en),tt=s.picklist(nn),j=s.picklist(tn);var _=s.variant("type",[s.object({type:s.literal("user"),id:s.pipe(s.string(),s.minLength(1)),email:s.pipe(s.string(),s.minLength(1)),name:s.pipe(s.string(),s.minLength(1))}),s.object({type:s.literal("system"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("automation"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("integration"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("candidate"),id:s.pipe(s.string(),s.minLength(1)),email:s.optional(s.string())})]);import*as R from"valibot";var rn=R.object({total:R.number(),page:R.number(),perPage:R.number(),lastPage:R.number()});function nt(t){return R.object({data:R.array(t),pagination:rn})}import*as y from"valibot";var Re=y.object({id:y.string(),email:y.nullable(y.string()),firstName:y.nullable(y.string()),lastName:y.nullable(y.string()),phone:y.nullable(y.string()),source:y.nullable(se),identifiedAt:y.nullable(y.string()),createdAt:y.string(),updatedAt:y.string()});import*as o from"valibot";import*as g from"valibot";var L=g.pipe(g.string(),g.minLength(1)),Z=g.pipe(g.number(),g.integer(),g.minValue(1)),k=g.record(g.string(),g.unknown()),on="(?!\\.{1,2}(?:/|$))[A-Za-z0-9._-]{1,128}",kr=g.pipe(g.string(),g.regex(new RegExp(`^${on}$`)));import*as b from"valibot";var rt=b.object({id:b.string(),applicationId:b.string(),status:ze,conductedBy:Qe,agentInterviewId:b.nullable(b.string()),generatedScore:b.nullable(b.number()),completedAt:b.nullable(b.string()),meta:b.nullable(k),createdAt:b.string(),updatedAt:b.string()});var sn=o.object({quote:o.string(),source:o.picklist(["cv","answer"])}),we=o.object({score:o.number(),reason:o.string(),confidence:o.number(),share:o.optional(o.number()),evidence:o.optional(o.array(sn))}),Pe=o.object({categoryId:o.string(),answerKey:o.string(),reason:o.picklist(["unanswered","unrecognised"])}),ot=o.object({id:o.string(),candidateId:o.string(),jobId:o.number(),stage:T,stageGroup:I,stageEnteredAt:o.string(),rating:o.nullable(o.number()),disqualifiedAt:o.nullable(o.string()),disqualificationReason:o.nullable(Q),disqualificationNote:o.nullable(o.string()),source:ce,sourceDetail:o.nullable(o.string()),sessionId:o.nullable(o.number()),externalApplicationId:o.nullable(o.string()),meta:o.nullable(k),context:o.nullable(k),scoredAt:o.nullable(o.string()),atsSubmissionStatus:o.optional(o.nullable(j)),atsSubmissionAttempts:o.optional(o.number()),atsNextAttemptAt:o.optional(o.nullable(o.string())),atsSubmittedAt:o.optional(o.nullable(o.string())),atsLastErrorCode:o.optional(o.nullable(o.string())),atsLastErrorMessage:o.optional(o.nullable(o.string())),createdAt:o.string(),updatedAt:o.string()}),an=o.object({id:o.string(),applicationId:o.string(),scoreType:ae,score:o.nullable(o.number()),reason:o.nullable(o.string()),categories:o.nullable(o.record(o.string(),we)),leftOut:o.optional(o.array(Pe)),scoredBy:o.nullable(o.string()),createdAt:o.string()}),N=o.object({...ot.entries,candidate:o.nullable(Re),score:o.nullable(an),interview:o.nullable(rt)}),Br=o.object({...Re.entries,applications:o.array(ot)}),it=o.object({id:o.string(),applicationId:o.string(),action:et,fromStage:o.nullable(T),fromStageGroup:o.nullable(I),toStage:o.nullable(T),toStageGroup:o.nullable(I),disqualificationReason:o.nullable(Q),disqualificationNote:o.nullable(o.string()),actorId:o.nullable(o.string()),actorType:tt,actorEmail:o.nullable(o.string()),actorName:o.nullable(o.string()),meta:o.nullable(k),schemaVersion:o.number(),createdAt:o.string()});import*as v from"valibot";var st=v.object({anonymousId:L,email:L,firstName:v.nullish(v.string()),lastName:v.nullish(v.string()),phone:v.nullish(v.string()),source:v.nullish(se),updateExisting:v.optional(v.boolean())}),ke=v.object({candidateId:v.string(),isNew:v.boolean()}),Vr=v.union([v.object({ok:v.literal(!0)}),ke]);import*as e from"valibot";var cn=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],pe=e.picklist(cn),Ce=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),ln=e.pipe(Ce,e.array(T)),pn=e.pipe(Ce,e.array(I)),at=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),dn=e.pipe(Ce,e.array(j)),ct=e.object({stages:e.optional(ln),stage_groups:e.optional(pn),job_id:e.optional(e.string()),job_ids:e.optional(at),candidate_id:e.optional(e.string()),is_disqualified:e.optional(e.picklist(["true","false"])),created_from:e.optional(e.string()),created_to:e.optional(e.string()),updated_from:e.optional(e.string()),updated_to:e.optional(e.string()),entered_stage_from:e.optional(e.string()),entered_stage_to:e.optional(e.string()),from:e.optional(e.string()),to:e.optional(e.string()),q:e.optional(e.string()),scored:e.optional(e.picklist(["true","false"])),ats_submission_status:e.optional(dn),sort:e.optional(Ze),order:e.optional(Xe),page:e.optional(e.string()),per_page:e.optional(e.string())}),H=e.pipe(L,e.maxLength(255)),un=e.object({status:e.picklist(["pending","not_required"]),integrationId:e.nullish(H)}),Yr=e.pipe(e.object({candidateId:L,jobId:Z,meta:e.nullish(k),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),externalJobId:e.nullish(e.pipe(L,e.maxLength(255))),context:e.nullish(k),source:e.nullish(ce),sourceDetail:e.nullish(e.string()),stage:e.nullish(T),stageGroup:e.nullish(I),actor:e.nullish(_),atsSubmission:e.nullish(un),duplicateScope:e.nullish(e.picklist(["job","attempt"]))}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together"),e.check(t=>t.duplicateScope!=="attempt"||typeof t.meta?.attempt_id=="string"&&t.meta.attempt_id!=="","duplicateScope attempt needs meta.attempt_id")),lt=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),zr=e.union([e.object({ok:e.literal(!0),duplicate:e.literal(!1),applicationId:e.string(),candidateId:e.string(),atsHeld:e.optional(e.boolean())}),e.object({ok:e.literal(!0),duplicate:e.literal(!0),existingApplication:lt,atsHeld:e.optional(e.boolean())})]),pt=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(lt)}),mn=Date.UTC(1e4,0,1),vn=e.pipe(e.string(),e.regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?(Z|[+-]\d{2}:\d{2})$/),e.check(t=>{let[n,r,i]=t.slice(0,10).split("-").map(Number),l=new Date(Date.UTC(n,r-1,i)),c=Date.parse(t);return l.getUTCMonth()===r-1&&l.getUTCDate()===i&&c>=0&&c<mn},"must be a real time")),Le=e.pipe(e.string(),e.regex(/^[A-Za-z0-9_.:-]{1,100}$/)),Qr=e.object({status:e.picklist(["pending","submitted","failed"]),nextAttemptAt:e.nullish(vn),errorCode:e.nullish(Le),errorMessage:e.nullish(e.pipe(e.string(),e.maxLength(1e4))),externalApplicationId:e.nullish(H),externalRunId:e.nullish(H),integrationId:e.nullish(H),answeredPending:e.optional(e.boolean())}),gn=e.picklist(["invalid_transition","next_attempt_required","retry_hold_expired"]),Zr=e.variant("kind",[e.object({kind:e.literal("recorded"),application:N}),e.object({kind:e.literal("rejected"),applicationId:e.string(),from:e.nullable(j),to:j,reason:gn})]),hn=e.object({integrationId:e.string(),state:e.picklist(["closed","open","half_open"]),coolingUntil:e.nullable(e.string()),transientCount:e.number(),held:e.boolean()}),Xr=e.object({groups:e.array(e.object({integrationId:e.nullable(e.string()),status:e.picklist(["pending","failed"]),errorCode:e.nullable(e.string()),count:e.number(),retryable:e.number(),sendable:e.optional(e.number()),nextRetryUntil:e.optional(e.nullable(e.string()))})),oldestPendingAgeSeconds:e.nullable(e.number()),breakers:e.array(hn),restoreHold:e.optional(e.boolean())}),eo=e.object({status:e.picklist(["pending","failed"]),integrationId:e.nullable(H),errorCode:e.nullable(Le)}),to=e.object({rows:e.array(e.object({id:e.string(),jobId:e.number(),status:e.picklist(["pending","failed"]),errorCode:e.nullable(e.string()),errorMessage:e.nullable(e.string()),attempts:e.number(),nextAttemptAt:e.nullable(e.string()),payloadHeld:e.boolean(),receivedAt:e.nullable(e.string()),retryUntil:e.nullable(e.string()),updatedAt:e.string()})),truncated:e.boolean()}),no=e.object({actor:_,expectedAtsLogCount:e.optional(e.pipe(e.number(),e.integer(),e.minValue(0)))}),fn=e.picklist(["invalid_transition","retry_payload_missing","retry_hold_expired","stale"]),ro=e.variant("kind",[e.object({kind:e.literal("retried"),application:N}),e.object({kind:e.literal("rejected"),applicationId:e.string(),from:e.nullable(j),reason:fn})]),oo=e.object({status:e.optional(e.picklist(["pending","failed"])),integrationId:e.nullable(H),errorCode:e.nullable(Le),actor:_}),io=e.object({retried:e.number()});var so=e.object({integrationId:e.string(),wasOpen:e.boolean()}),ao=e.object({integrationId:e.string(),wasHeld:e.boolean()}),co=e.object({applicationId:L,scoreType:ae,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),we)),leftOut:e.nullish(e.array(Pe)),scoredBy:e.nullish(e.string()),actor:e.nullish(_),idempotencyKey:e.nullish(e.pipe(e.string(),e.maxLength(255)))}),lo=e.object({scoreId:e.string()}),po=nt(N);var uo=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),mo=e.array(it),le=e.object({stage:e.nullish(T),note:e.nullish(e.string())}),yn=e.object({stage:e.nullish(T),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),Sn=e.variant("action",[e.object({action:e.literal("shortlist"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("move_to_interview"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("make_offer"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("hire"),actor:_,meta:e.nullish(yn)}),e.object({action:e.literal("withdraw"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("move_to_stage"),actor:_,meta:e.object({stage:T,stageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:_,meta:e.object({toStage:T,toStageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:_,meta:e.object({reason:Q,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:_,meta:e.object({toStage:T,toStageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:_,meta:e.object({rating:e.nullable(e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(5)))})})]),vo=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:Sn}),dt=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),go=e.variant("kind",[e.object({kind:e.literal("updated"),action:pe,application:N}),e.object({kind:e.literal("skipped"),action:pe,applicationId:e.string(),reason:dt})]),ho=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:pe,application:N})),skipped:e.array(e.object({kind:e.literal("skipped"),action:pe,applicationId:e.string(),reason:dt})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),m=e.pipe(e.number(),e.integer(),e.minValue(0)),ut=e.object({APPLIED:m,SHORTLISTED:m,INTERVIEWED:m,OFFERED:m,HIRED:m,REJECTED:m,WITHDRAWN:m}),fo=e.object({job_ids:at}),yo=e.object({counts:e.record(e.string(),ut)}),So=e.omit(ct,["sort","order","page","per_page"]),bo=e.object({counts:ut}),mt=92,bn=864e5,K=e.pipe(e.string(),e.regex(/^\d{4}-\d{2}-\d{2}$/),e.check(t=>{let n=new Date(`${t}T00:00:00Z`);return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t},"must be a real calendar day"));function vt({from:t,to:n}){let r=(Date.parse(`${n}T00:00:00Z`)-Date.parse(`${t}T00:00:00Z`))/bn+1;return r>=1&&r<=mt}var gt=`to must be on or after from, and the range must span at most ${mt} days`,_o=e.pipe(e.object({from:K,to:K}),e.check(vt,gt)),_n=e.object({job_id:Z,date:K,received:m,scored:m,shortlisted:m}),Ao=e.object({rows:e.array(_n)}),An=5e3,Tn=e.pipe(e.object({from:K,to:K,jobIds:e.optional(e.pipe(e.array(Z),e.maxLength(An)))}),e.check(vt,gt)),To=e.pipe(e.object({from:e.string(),to:e.string(),job_ids:e.optional(e.string())}),e.transform(({from:t,to:n,job_ids:r})=>({from:t,to:n,jobIds:r===void 0?void 0:r===""?[]:r.split(",").map(i=>/^\d+$/.test(i.trim())?Number(i):Number.NaN)})),Tn),ht=e.pipe(e.array(m),e.length(5)),En=e.object({received:m,scored:m,shortlisted:m,histogram:e.pipe(e.array(m),e.length(101)),median_lag_minutes:e.nullable(e.number()),scored_same_day:m}),xn=e.object({job_id:Z,received:m,scored:m,shortlisted:m,score_sum:e.number(),bands:ht}),In=e.object({date:K,received:m,scored:m,score_sum:e.number(),bands:ht,scored_on_day:m}),Rn=e.object({id:e.string(),label:e.nullable(e.string()),sum:e.number(),count:m}),wn=e.object({template_id:e.string(),scored:m,criteria:e.array(Rn)}),Eo=e.object({totals:En,by_job:e.array(xn),by_day:e.array(In),criteria:e.array(wn)});var xo=e.object({...e.omit(ct,["page","per_page"]).entries,per_group:e.optional(e.string())}),F=e.object({data:e.array(N),total:m}),Io=e.object({board:e.object({APPLIED:F,SHORTLISTED:F,INTERVIEWED:F,OFFERED:F,HIRED:F,REJECTED:F,WITHDRAWN:F})});import*as de from"valibot";var Pn=({environment:t,publishableKey:n,logger:r})=>{let i=Ue[t];return{async checkDuplicate(l){try{let c=new URLSearchParams({email:l.email,scope:l.scope});l.scope==="job"&&l.jobId!=null&&c.set("job_id",String(l.jobId));let d=await fetch(`${i}/applications/check-duplicate?${c}`,{method:"GET",headers:{Accept:"application/json","x-publishable-key":n}});if(!d.ok)return r.error(`[TalentBankClient] checkDuplicate failed with status ${d.status}`),{isDuplicate:!1};let u=await d.json(),S=de.safeParse(pt,u);return S.success?S.output:(r.error("[TalentBankClient] checkDuplicate response failed strict validation; falling back to isDuplicate flag"),typeof u=="object"&&u!=null&&typeof u.isDuplicate=="boolean"?{isDuplicate:u.isDuplicate}:{isDuplicate:!1})}catch(c){return r.error("[TalentBankClient] checkDuplicate failed:",c),{isDuplicate:!1}}},async identify(l){try{if(!l.anonymousId)return r.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let c={email:l.email,firstName:l.firstName,lastName:l.lastName,phone:l.phone,anonymousId:l.anonymousId,source:l.source??"sdk"},d=de.safeParse(st,c);if(!d.success)return r.error("[TalentBankClient] identify received invalid input"),null;let u=await fetch(`${i}/identify`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-publishable-key":n},body:JSON.stringify(d.output)});if(!u.ok)return r.error(`[TalentBankClient] identify failed with status ${u.status}`),null;let S=de.safeParse(ke,await u.json());return S.success?S.output:(r.error("[TalentBankClient] identify returned an invalid response"),null)}catch(c){return r.error("[TalentBankClient] identify failed:",c),null}}}};function kn(t){if(!(typeof document>"u")){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",t,{once:!0});return}Promise.resolve().then(t)}}import*as a from"valibot";var ft=["DAILY","WEEKLY","MONTHLY"],Cn=a.record(a.string(),a.union([a.string(),a.array(a.string()),a.object({type:a.literal("provided"),lat:a.number(),lng:a.number(),radius:a.number(),unit:a.optional(a.picklist(["miles","km"])),label:a.optional(a.string())})])),Ln={pathname:"/job/:id",method:"GET",schema:{response:a.object({id:a.number(),external_id:a.nullish(a.string()),city:a.nullish(a.string()),town:a.nullish(a.string()),category:a.nullish(a.string())})}};async function Dn(t,{contact:n,job:r}){let i={};if(r){let l=await t.request(Ln,{params:{id:r.id}});if((r.id_type==="internal"?String(l.id):l.external_id)!==r.id)throw new Error("Job lookup returned a different role");for(let d of["city","town","category"]){let u=l[d]?.trim();u&&(i[d]=[u])}}await t.request(yt,{body:{contact:n,alerts:"WEEKLY",filters:i}})}var yt={pathname:"/search/save",method:"POST",schema:{response:C(),body:a.object({contact:a.object({email:a.pipe(a.optional(a.string()),a.string(),a.email()),first_name:a.optional(a.string()),last_name:a.optional(a.string())}),alerts:a.pipe(a.optional(a.string()),a.string(),a.picklist(ft)),filters:Cn})}};import*as A from"valibot";var St=async t=>{let n={method:"GET",pathname:"/search/filters",schema:{response:A.pipe(A.object({country:A.optional(A.array(A.object({value:A.string()})),[])}),A.transform(({country:r})=>r.map(({value:i})=>i))),searchParams:C()}};return t.request(n,{searchParams:{filters:{country:null}}})},ue=new WeakMap,On=t=>(ue.has(t)||(ue.set(t,void 0),St(t).then(async n=>{let{jobCountryCodes:r}=await import("./sdk.country-codes-W6HRF5SA.mjs");ue.set(t,r(n).join(",")||void 0)}).catch(()=>{})),ue.get(t)),bt=(t,n)=>{let r=new Set,i=[];for(let l=0;l<Math.max(t.length,n.length);l++)for(let c of[t[l],n[l]]){if(!c)continue;let d=c.mapbox_id||c.full_address||[c.name,c.place_formatted].filter(Boolean).join(", ");if(!r.has(d)&&(r.add(d),i.push(c),i.length===5))return i}return i},jn=600,Nn=async(t,n,r)=>{if(r?.throwIfAborted(),!n){let i=await t();return r?.throwIfAborted(),i}return new Promise((i,l)=>{let c,d,u,S=!1,E=()=>{S=!0,clearTimeout(u),r?.removeEventListener("abort",U)},U=()=>{E(),l(r?.reason)},D=()=>{E(),c?.status==="fulfilled"&&d?.status==="fulfilled"?i(bt(c.value,d.value)):c?.status==="fulfilled"?i(c.value):d?.status==="fulfilled"?i(d.value):c?.status==="rejected"&&l(c.reason)},me=(p,h)=>{S||(p?c=h:d=h,c&&d?D():h.status==="fulfilled"&&h.value.length>0&&(u=setTimeout(D,jn)))};r?.addEventListener("abort",U,{once:!0});for(let p of[!0,!1])t(p?n:void 0).then(h=>me(p,{status:"fulfilled",value:h}),h=>me(p,{status:"rejected",reason:h}))})};export{qt as ANALYTICS_EVENTS,V as ApiError,z as InploiRpcClient,ft as JOB_ALERT_FREQUENCIES,G as NotFoundError,$ as ParsingError,w as SchemaValidationError,Ne as SdkError,q as UnauthorisedError,On as addressSearchCountry,bt as blendAddressSuggestions,Ie as consentStorageKey,Et as createPlugin,Pn as createTalentBankClient,ie as endpoint,J as generateUUID,Vt as getConsentAcceptance,St as getJobCountries,We as getOrCreateAnonymousId,xe as hashConsentConfig,Gt as initialiseSdk,fe as inploiBrandedLogger,Rt as isApiErrorWithData,kt as isSdkError,Tt as jobCountryCodes,ye as noLogging,kn as ready,Dn as saveClosedRoleJobAlerts,yt as saveSearchEndpoint,Nn as searchAddressSuggestions,$t as setConsentAcceptance,C as typed,Ye as validateEndpointInputs};
1
+ import{b as Gt}from"./chunk-U6WFJKHV.mjs";var se="%c[inploi SDK]",ae="color: #65BC67; font-weight: bold;",_e={warn:(...t)=>console.warn(se,ae,...t),error:(...t)=>console.error(se,ae,...t),info:(...t)=>console.info(se,ae,...t),log:(...t)=>console.log(se,ae,...t)},xe={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Jt=t=>t;function Ae(t,o){if(!t)throw new Error(o)}function J(t,o){return o in t}var Jr=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var $t="Unauthenticated",Wt="This action is unauthorized.",N=class extends Error{constructor(i,s){super(i);this.status=s,this.name="ErrorWithStatus"}},$=class extends N{constructor(o){super(o??"Not found"),this.name="NotFoundError",this.status=404}},W=class extends N{constructor(o,i){super(o??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=i??401}},C=class extends N{constructor(i,s){let d=s?` in ${s}`:"";super(`Schema validation failed${d}`);this.issues=i;this.source=s;this.name="SchemaValidationError",this.status=400}},H=class extends N{constructor(i,s,d){super(i);this.data=d;this.name="ApiError",this.status=s??500}},Ht=t=>t instanceof H&&t.data!==void 0,K=class extends N{constructor(i){super("Error parsing response into JSON.");this.response=i;this.name="ParsingError",this.status=i&&i.status>=300?i.status:500,this.contentType=new Headers(i?.headers).get("content-type")??void 0}};async function Te(t){let i=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(i&&i!=="application/json"&&!i.endsWith("+json"))throw new K(t);return t.json().catch(()=>{throw new K(t)})}var Kt=["message","error","errors","exception","exceptions"];function Yt(t){let o=[];if(typeof t=="object"&&t!==null){for(let i of Kt)if(J(t,i)){let s=t[i];typeof s=="string"&&o.push(s),Array.isArray(s)&&s.every(d=>typeof d=="string")&&o.push(...s)}J(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&J(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&J(t.integration_response.error,"message")&&typeof t.integration_response.error.message=="string"&&o.push(t.integration_response.error.message)}return o.length===0&&o.push("Unknown error"),[...new Set(o)].join(", ")}function Ie(t,o){if(o>=300){let i=Yt(t);throw o===404?new $(i):i===$t?new W("You are not authenticated.",o):i===Wt?new W(i,o):new H(i,o,t)}}var Ge=t=>{let o={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(i,s={})=>{let d={...s,headers:{...s.headers,...o}},p=await fetch(`${t.baseUrl}${i}`,d);if(p.status===404)throw new $;let u=await Te(p);return Ie(u,p.status),u}}},Je={NotFound:$,Unauthorised:W,SchemaValidation:C,Api:H,JsonParsing:K};function zt(t){return Object.values(Je).some(o=>t instanceof o)}var $e="3.1.3";var ce={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},We={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},He=$e;var L="isdk_session",Ke=`${L}-candidate_id`,Ye=`${L}-consent`;var le=new Map,Ee={get:t=>{if(le.has(t))return le.get(t)??null;try{return window.sessionStorage.getItem(t)}catch{return null}},set:(t,o)=>{try{window.sessionStorage.setItem(t,o),le.delete(t)}catch{le.set(t,o)}}};var Q=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+t/4).toString(16));var Qe=7*24*60*60*1e3,Ze=t=>{let o=new Date;return o.setTime(o.getTime()+Qe),`${L}=${t};expires=${o.toUTCString()};path=/`},Zt=(t,o)=>{let i=t.get("session_id");if(o||i)return i;let s=Ee.get(`${L}-session_id`);return typeof s=="string"?s:null},Xt=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(Ke);return typeof t=="string"&&t!==""?t:null}catch{return null}},en=new RegExp(`(?:^|;\\s*)${L}=([^;]+)`),Z=t=>{let o=t?t.headers.get("cookie"):document.cookie;return o?en.exec(o)?.[1]??null:null},Xe=()=>{try{let t=JSON.parse(window.localStorage.getItem(L)??"null");return typeof t!="object"||t===null||!("id"in t)||!("expires"in t)||typeof t.id!="string"||typeof t.expires!="number"?null:t.id!==""&&t.expires>Date.now()?t.id:null}catch{return null}},ze=()=>Z()??(new URL(location.href).searchParams.get("anonymous_id")?null:Xe()),tn=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",et=t=>{if(document.cookie=Ze(t)+tn(),Z()!==t)try{window.localStorage.setItem(L,JSON.stringify({id:t,expires:Date.now()+Qe}))}catch{}},we=t=>{let o=t?t.url:location.href,{searchParams:i}=new URL(o);return{anonymous_id:t?Z(t)??i.get("anonymous_id"):Z()??i.get("anonymous_id")??Xe(),session_id:Zt(i,typeof window>"u")}},tt=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=we().anonymous_id;if(t)return t;let o=Q(),i=we().anonymous_id;return i||(et(o),o)},nn=t=>typeof t!="object"||t===null?null:{anonymous_id:"anonymous_id"in t&&typeof t.anonymous_id=="string"?t.anonymous_id:null,session_id:"session_id"in t&&typeof t.session_id=="string"?t.session_id:null},rn=t=>t==="about:client"?"":t,on={pathname:"/log",method:"POST",schema:{response:j(),body:j()}},nt=({rpcClient:t,logger:o,onEvent:i,persistence:s="device",siteKind:d})=>{let p=null,u=null,h=0,_=0,R=v=>s==="none"?{anonymous_id:null,session_id:v?null:p}:we(v),q=async(v,S,oe)=>{try{let G={library:{name:"inploi-sdk",version:He},page:S},z=R(v.request),ie=s==="none"?null:Xt(),y={anonymous_id:z.anonymous_id,session_id:z.session_id,candidate_id:ie,event:v.event,sent_at:new Date().toISOString(),context:G,properties:v.properties,custom_properties:{...v.customProperties,...oe}},be=s==="none"?null:v.request?Z(v.request):ze(),Me=++h,Mt=await t.request(on,{body:y,...v.keepalive&&{keepalive:!0}}),P=nn(Mt);if(s==="none")return!v.request&&P?.session_id&&Me>_&&(_=Me,P.session_id!==y.session_id&&(p=P.session_id)),y.session_id=v.request?P?.session_id||null:p,i?.(y),{success:!0,data:y};let Se=v.request?be:ze(),qt=Se!==null&&Se!==be,ye=Se??be,qe=!qt&&(!ye||!P?.anonymous_id||ye===P.anonymous_id);return qe?(P?.anonymous_id&&(y.anonymous_id=P.anonymous_id),P?.session_id&&(y.session_id=P.session_id)):y.anonymous_id=ye,!v.request&&typeof window<"u"&&y.anonymous_id&&(qe&&y.session_id&&Ee.set(`${L}-session_id`,y.session_id.toString()),et(y.anonymous_id)),i?.(y),{success:!0,data:y}}catch(G){return o.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:G}}},D=Promise.resolve();return{log:async v=>{Ae(v.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let S="request"in v&&v.request?{href:v.request.url,referrer:rn(v.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(v.page_context==="no_query"){let ie=new URL(S.href),y=S.referrer?new URL(S.referrer):void 0;S={href:ie.origin+ie.pathname,referrer:y?y.origin+y.pathname:""}}s==="none"&&v.event==="FLOW_NODE"&&v.properties&&"trigger"in v.properties&&(v.properties.trigger==="pagehide"||v.properties.trigger==="hidden")&&(v={...v,keepalive:!0});let oe={event_id:Q(),consent_lane:s,site_kind:d};if(s==="device"||v.request||p||v.keepalive)return q(v,S,oe);let G=()=>q(v,S,oe),z=D.then(G,G);return D=z,z},supportsNoQueryPageContext:!0,getHeaders:v=>{let S=new Headers;return s==="none"||!v?.anonymous_id||S.append("Set-Cookie",Ze(v.anonymous_id)),S},getSessionInfo:R,getOrCreateAnonymousId:()=>s==="none"?u??(u=Q()):tt()}};import{stringify as sn}from"neoqs";function Re(t,o,i){let s=t["~standard"].validate(o);if(s instanceof Promise)throw new TypeError("Async schema");if(s.issues)throw new C(s.issues,i);return s.value}function an(t,o,i){try{return{success:!0,output:Re(t,o,i)}}catch(s){if(s instanceof C)return{success:!1,issues:s.issues,source:s.source};throw s}}var X=class{constructor(o){if(this.baseUrl=ce[o.environment],this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json"}),o.apiKey.type==="secret"){if(typeof window<"u")throw new Error("Secret key cannot be used in a browser environment");this.headers.set("x-secret-key",o.apiKey.key)}else this.headers.set("x-publishable-key",o.apiKey.key);this.logger=o.logger,this._environment=o.environment}get environment(){return this._environment}getFetchParams(o,i){let s=i.validateIn??!0,{searchParams:d,body:p}=s?rt(o,i):i,u=new URL(this.baseUrl),h=o.pathname;if("params"in i&&i.params)for(let[_,R]of Object.entries(i.params))h=h.replace(`:${_}`,String(R));return u.pathname=h,o.schema.searchParams&&(u.search=sn(d)),[u.toString(),{method:o.method,body:p?JSON.stringify(p):void 0,headers:this.headers,signal:i.signal,...i.keepalive&&{keepalive:!0}}]}async parseResponse(o,i){let s=await Te(i.response);if(Ie(s,i.response.status),!(i.validateOut??!0))return s;let p=an(o.schema.response,s,"response");if(!p.success)throw new C(p.issues,p.source);return p.output}async request(o,i){try{let s=this.getFetchParams(o,i),d=await fetch(...s);return await this.parseResponse(o,{response:d,validateOut:i.validateOut})}catch(s){throw s instanceof C?this.logger.error(s.message,s.issues):this.logger.error(s),s}}};function j(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function pe(t){return t}function rt(t,o){let i={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(i.searchParams=Re(t.schema.searchParams,"searchParams"in o?o.searchParams:{})),t.schema.body&&(i.body=Re(t.schema.body,"body"in o?o.body:{})),i}function cn({publishableKey:t,env:o,logger:i=_e,onEvent:s,persistence:d,siteKind:p}){let u=Ge({baseUrl:ce[o],publishableKey:t}),h=i===!1?xe:i,_=new X({environment:o,apiKey:{type:"publishable",key:t},logger:h}),R=nt({rpcClient:_,logger:h,onEvent:s,persistence:d,siteKind:p});return{register:D=>D({logger:h,apiClient:u,analytics:R,rpcClient:_,publishableKey:t,env:o}),analytics:R,apiClient:u}}var ln={VIEW_PAGE:"A careers-site page shown (not a job page).",VIEW_JOB:"A job's own page shown; one per job id the page names.",PAGE_ENGAGEMENT:"A page view's attention summary, sent when the view is hidden or left.",VIEW_SEARCH:"A job search seen for two seconds.",SEARCH_SETTLE:"A searched query or filter with results, unchanged for five seconds.",SEARCH_RESULTS:"A search whose results returned, zero included; once per distinct query, filters, place and order.",SEARCH_PAGINATE:"A move to another page of search results.",SEARCH_JOB_CLICK:"A job opened from search results.",SAVE_JOB:"A job saved or unsaved by the candidate.",LINK_CLICK:"A tracked link clicked.",INTERACTION:"A tagged interaction (`tag` names it).",FLOW_START:"An application flow started.",FLOW_INTERACT:"The candidate's first answer in a flow.",FLOW_END:"An application flow ended.",FLOW_NODE:"The candidate's path through an application, summarised when it pauses or ends.",FLOW_SUBMIT:"An application submitted, with the outcome.",FLOW_REDIRECT:"A flow sent the candidate to an external apply page.",FEEDBACK:"A rating or comment.",ADDRESS_SHADOW_COMPARED:"Engineering telemetry: the address lookup's shadow comparison.",SUBMIT_FORM:"Declared but sent by nothing."};function Pe(t){let o=JSON.stringify({message:t.message,acceptLabel:t.acceptLabel??"",declineLabel:t.declineLabel??""}),i=5381;for(let s=0;s<o.length;s++)i=i*33^o.charCodeAt(s);return(i>>>0).toString(36)}function ke(t,o){return`${Ye}:${t}:${o}`}function pn(t,o){if(typeof window>"u")return!1;try{let i=ke(t,Pe(o));return window.localStorage.getItem(i)==="accepted"}catch{return!1}}function dn(t,o){if(!(typeof window>"u"))try{let i=ke(t,Pe(o));window.localStorage.setItem(i,"accepted")}catch{}}import*as c from"valibot";var vn=["agent","sdk","form","integration","migration"],un=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var mn=["screening","cv_match","interview","overall"],gn=["PENDING","IN_PROGRESS","COMPLETED","CANCELLED"],hn=["agent"],fn=["job","company"],bn=["created_at","updated_at","score","interview_score"],Sn=["asc","desc"],yn=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],_n=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written","ats_submission_attempted","ats_submission_succeeded","ats_submission_failed","ats_retry_payload_purged","note","share","verdict","offer_terms","offer_sent","offer_accepted","offer_declined","offer_withdrawn","exported","message_held","message_sent","message_delivered","message_failed","message_uncertain","message_cancelled","message_not_sent","score_override"],xn=["interview","not_for_me"],ot=c.picklist(xn),An=["accept","reject"],it=c.picklist(An),Tn=["transient_pass_through","failed_ats_submission_hold","retention","erasure","demo_reset"],Io=c.picklist(Tn),In=["pending","submitted","failed","not_required"],En=["user","system","automation","integration","candidate"],de=c.picklist(vn),I=c.picklist(un),x=c.pipe(c.string(),c.trim(),c.minLength(1),c.maxLength(100)),ve=c.picklist(mn),st=c.picklist(gn),at=c.picklist(hn),ct=c.picklist(fn),lt=c.picklist(bn),pt=c.picklist(Sn),ee=c.pipe(c.string(),c.trim(),c.minLength(1),c.maxLength(100)),ue=c.picklist(yn),te=c.picklist(_n),dt=c.picklist(En),B=c.picklist(In);var b=c.variant("type",[c.object({type:c.literal("user"),id:c.pipe(c.string(),c.minLength(1)),email:c.pipe(c.string(),c.minLength(1)),name:c.pipe(c.string(),c.minLength(1))}),c.object({type:c.literal("system"),id:c.pipe(c.string(),c.minLength(1)),name:c.optional(c.string())}),c.object({type:c.literal("automation"),id:c.pipe(c.string(),c.minLength(1)),name:c.optional(c.string())}),c.object({type:c.literal("integration"),id:c.pipe(c.string(),c.minLength(1)),name:c.optional(c.string())}),c.object({type:c.literal("candidate"),id:c.pipe(c.string(),c.minLength(1)),email:c.optional(c.string())})]);import*as k from"valibot";var wn=k.object({total:k.number(),page:k.number(),perPage:k.number(),lastPage:k.number()});function vt(t){return k.object({data:k.array(t),pagination:wn})}import*as r from"valibot";import*as m from"valibot";var E=m.pipe(m.string(),m.minLength(1)),U=m.pipe(m.number(),m.integer(),m.minValue(1)),w=m.record(m.string(),m.unknown()),O=m.pipe(E,m.maxLength(255)),Rn="(?!\\.{1,2}(?:/|$))[A-Za-z0-9._-]{1,128}",Ro=m.pipe(m.string(),m.regex(new RegExp(`^${Rn}$`))),A=m.pipe(m.string(),m.regex(/^\d{4}-\d{2}-\d{2}$/),m.check(t=>{let o=new Date(`${t}T00:00:00Z`);return!Number.isNaN(o.getTime())&&o.toISOString().slice(0,10)===t},"must be a real calendar day"));function ut(t){return/^\p{Zs}*\(?\p{Zs}*(\+|00)[\p{Zs}().-]*\d/u.test(t)}var Ce=r.object({id:r.string(),email:r.nullable(r.string()),firstName:r.nullable(r.string()),lastName:r.nullable(r.string()),phone:r.nullable(r.string()),source:r.nullable(de),identifiedAt:r.nullable(r.string()),createdAt:r.string(),updatedAt:r.string()}),Pn=r.pipe(r.string(),r.trim(),r.minLength(1)),mt=64*1024,ne=r.pipe(r.string(),r.trim(),r.minLength(1),r.maxLength(500)),kn=r.pipe(r.string(),r.regex(/^[A-Z]{2}$/)),Cn=r.pipe(r.string(),r.maxLength(500),r.check(t=>ut(t.trim()),"phone must start with its country code (+ or 00)")),Ln=r.pipe(r.string(),r.regex(/^[\w:-]+$/)),On=new Set(["__proto__","constructor","prototype"]),jn=r.custom(t=>Fn(t),"custom answer must be a JSON value"),Dn=["full_time","part_time","weekends","evenings","flexible","bank"],ht=r.picklist(Dn),jo=r.strictObject({firstName:r.nullable(r.string()),lastName:r.nullable(r.string()),email:r.string(),phone:r.nullable(r.string()),country:r.nullable(r.string()),postcode:r.nullable(r.string()),currentTitle:r.nullable(r.string()),currentEmployer:r.nullable(r.string()),openToRelocation:r.nullable(r.boolean()),availableFrom:r.nullable(r.string()),workingPatterns:r.array(ht),custom:r.record(r.string(),r.unknown())});var gt=r.strictObject({firstName:r.optional(ne),lastName:r.optional(ne),phone:r.optional(r.nullable(Cn)),country:r.optional(r.nullable(kn)),postcode:r.optional(r.nullable(ne)),currentTitle:r.optional(r.nullable(ne)),currentEmployer:r.optional(r.nullable(ne)),openToRelocation:r.optional(r.nullable(r.boolean())),availableFrom:r.optional(r.nullable(A)),workingPatterns:r.optional(r.nullable(r.array(ht))),custom:r.optional(r.pipe(r.custom(t=>Le(t)&&Object.keys(t).every(o=>!On.has(o))&&Vn(t)<=mt,`custom must be a JSON object of at most ${mt} bytes`),r.record(Ln,r.nullable(jn))))}),Nn=r.pipe(r.custom(t=>Le(t)&&Object.keys(t).every(o=>Object.hasOwn(gt.entries,o)),"set must be an object of profile fields"),gt),Bn=r.strictObject({email:Pn}),Do=r.strictObject({talentPool:r.optional(r.boolean())}),No=r.strictObject({identity:Bn,set:Nn,ifVersion:r.optional(r.pipe(r.number(),r.integer(),r.minValue(0))),disclosures:r.optional(r.unknown())}),Un=r.strictObject({noticeId:r.pipe(r.string(),r.minLength(1),r.maxLength(200)),version:r.pipe(r.string(),r.minLength(1),r.maxLength(64)),wordingHash:r.pipe(r.string(),r.minLength(1),r.maxLength(128))}),Bo=r.variant("withdrawTalentPool",[r.strictObject({withdrawTalentPool:r.literal(!1),actorUserId:r.optional(r.pipe(r.string(),r.minLength(1),r.maxLength(200)))}),r.strictObject({withdrawTalentPool:r.literal(!0),notice:Un})]);function Le(t){if(typeof t!="object"||t===null)return!1;let o=Object.getPrototypeOf(t);return o===Object.prototype||o===null}function Fn(t){try{return ft(t,JSON.parse(JSON.stringify(t)))}catch{return!1}}function ft(t,o){if(t===o)return!0;if(typeof t!="object"||t===null||typeof o!="object"||o===null||Array.isArray(t)!==Array.isArray(o)||!Array.isArray(t)&&!Le(t))return!1;let i=Object.keys(t);return i.length!==Object.keys(o).length?!1:i.every(s=>Object.hasOwn(o,s)&&ft(t[s],o[s]))}function Vn(t){try{return new TextEncoder().encode(JSON.stringify(t)).length}catch{return Number.POSITIVE_INFINITY}}import*as n from"valibot";import*as a from"valibot";var St=a.object({id:a.string(),applicationId:a.string(),status:st,conductedBy:at,agentInterviewId:a.nullable(a.string()),generatedScore:a.nullable(a.number()),completedAt:a.nullable(a.string()),meta:a.nullable(w),createdAt:a.string(),updatedAt:a.string()}),Mn=/^[A-Za-z0-9_.:-]{1,128}$/,re=a.pipe(a.string(),a.regex(Mn)),qn=["audio/webm","audio/ogg","audio/mp4","audio/mpeg","audio/wav"],yt=a.pipe(a.string(),a.maxLength(255),a.regex(/^[\x20-\x7e]+$/),a.check(t=>qn.includes(t.split(";")[0].trim().toLowerCase()))),_t=30*1024*1024,Gn=100,Mo=1.5*1024*1024,xt=a.pipe(a.string(),a.regex(/^[0-9a-f]{64}$/)),qo=a.object({questionId:re,contentType:yt,sha256:xt,body:a.pipe(a.instance(ArrayBuffer),a.check(t=>t.byteLength>=1&&t.byteLength<=_t))}),Jn=a.object({questionId:re,text:a.string(),questionType:a.string(),isFollowUp:a.boolean(),parentQuestionId:a.nullable(re)}),$n=a.object({questionId:re,transcript:a.string(),evaluation:a.nullable(w)}),Wn=a.object({questionId:re,contentType:yt,byteLength:a.pipe(a.number(),a.integer(),a.minValue(1),a.maxValue(_t)),sha256:xt}),bt=t=>new Set(t.map(o=>o.questionId)).size===t.length,Go=a.pipe(a.object({questions:a.pipe(a.array(Jn),a.maxLength(Gn)),answers:a.array($n),evaluation:a.nullable(w),generatedScore:a.nullable(a.pipe(a.number(),a.minValue(0),a.maxValue(100))),display:a.object({jobTitle:a.string(),companyName:a.string()}),recordings:a.array(Wn),recordingsWithheld:a.nullable(a.literal("jurisdiction")),completedAt:a.pipe(a.string(),a.isoTimestamp())}),a.check(t=>{let o=new Set(t.questions.map(i=>i.questionId));return o.size===t.questions.length&&bt(t.answers)&&bt(t.recordings)&&[...t.answers,...t.recordings].every(i=>o.has(i.questionId))}));var Hn=n.object({quote:n.string(),source:n.picklist(["cv","answer"])}),Oe=n.object({score:n.number(),reason:n.string(),confidence:n.number(),share:n.optional(n.number()),evidence:n.optional(n.array(Hn))}),je=n.object({categoryId:n.string(),answerKey:n.string(),reason:n.picklist(["unanswered","unrecognised"])}),Tt=n.object({id:n.string(),candidateId:n.string(),jobId:n.number(),stage:x,stageGroup:I,stageEnteredAt:n.string(),rating:n.nullable(n.number()),disqualifiedAt:n.nullable(n.string()),disqualificationReason:n.nullable(ee),disqualificationNote:n.nullable(n.string()),source:ue,sourceDetail:n.nullable(n.string()),sessionId:n.nullable(n.number()),externalApplicationId:n.nullable(n.string()),meta:n.nullable(w),context:n.nullable(w),scoredAt:n.nullable(n.string()),atsSubmissionStatus:n.optional(n.nullable(B)),atsSubmissionAttempts:n.optional(n.number()),atsNextAttemptAt:n.optional(n.nullable(n.string())),atsSubmittedAt:n.optional(n.nullable(n.string())),atsLastErrorCode:n.optional(n.nullable(n.string())),atsLastErrorMessage:n.optional(n.nullable(n.string())),createdAt:n.string(),updatedAt:n.string()}),Kn=n.object({id:n.string(),applicationId:n.string(),scoreType:ve,score:n.nullable(n.number()),reason:n.nullable(n.string()),categories:n.nullable(n.record(n.string(),Oe)),leftOut:n.optional(n.array(je)),reasonsWrittenBlind:n.optional(n.literal(!0)),scoredBy:n.nullable(n.string()),createdAt:n.string()}),F=n.object({...Tt.entries,candidate:n.nullable(Ce),score:n.nullable(Kn),interview:n.nullable(St)}),Yo=n.object({...Ce.entries,applications:n.array(Tt)}),It=n.object({id:n.string(),applicationId:n.string(),action:te,fromStage:n.nullable(x),fromStageGroup:n.nullable(I),toStage:n.nullable(x),toStageGroup:n.nullable(I),disqualificationReason:n.nullable(ee),disqualificationNote:n.nullable(n.string()),actorId:n.nullable(n.string()),actorType:dt,actorEmail:n.nullable(n.string()),actorName:n.nullable(n.string()),meta:n.nullable(w),schemaVersion:n.number(),createdAt:n.string()}),Yn=500,Et=n.object({scoreId:n.pipe(n.string(),n.minLength(1),n.maxLength(255)),scoredBy:n.pipe(n.string(),n.regex(/^scoring:[^:\s]{1,128}:[^:\s]{1,128}$/)),decision:it,reason:n.pipe(n.string(),n.maxLength(Yn),n.check(t=>t.trim().length>0,"reason must not be blank")),score:n.pipe(n.number(),n.finite())}),zn=500,Qn=200,At={from:n.pipe(n.string(),n.isoTimestamp()),to:n.pipe(n.string(),n.isoTimestamp()),actions:n.optional(n.pipe(n.array(te),n.minLength(1))),cursor:n.nullable(n.pipe(n.string(),n.regex(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\|.{1,255}$/))),limit:n.pipe(n.number(),n.integer(),n.minValue(1),n.maxValue(Qn))},zo=n.union([n.strictObject({...At,jobIds:n.pipe(n.array(n.pipe(n.number(),n.integer(),n.minValue(1))),n.minLength(1),n.maxLength(zn))}),n.strictObject({...At,allJobs:n.literal(!0)})]),Zn=500,Qo=n.pipe(n.number(),n.integer(),n.minValue(1)),Zo=n.strictObject({cursor:n.nullable(n.pipe(n.string(),n.regex(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}\|.{1,255}$/))),limit:n.pipe(n.number(),n.integer(),n.minValue(1),n.maxValue(Zn)),actions:n.optional(n.pipe(n.array(te),n.minLength(1))),maxApplications:n.optional(n.pipe(n.number(),n.integer(),n.minValue(0)))}),Xn=n.object({id:n.string(),applicationId:n.string(),action:te,fromStage:n.nullable(x),fromStageGroup:n.nullable(I),toStage:n.nullable(x),toStageGroup:n.nullable(I),createdAt:n.string()}),Xo=n.object({rows:n.array(Xn),nextCursor:n.nullable(n.string()),total:n.nullable(n.pipe(n.number(),n.integer(),n.minValue(0))),applications:n.pipe(n.number(),n.integer(),n.minValue(0))});import*as f from"valibot";var wt=f.object({anonymousId:E,email:E,firstName:f.nullish(f.string()),lastName:f.nullish(f.string()),phone:f.nullish(f.string()),source:f.nullish(de),updateExisting:f.optional(f.boolean())}),De=f.object({candidateId:f.string(),isNew:f.boolean()}),ri=f.union([f.object({ok:f.literal(!0)}),De]);import*as e from"valibot";var er=["note","share","verdict","offer_terms","offer_sent","offer_accepted","offer_declined","offer_withdrawn","exported","score_override"],tr=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate",...er],ge=e.picklist(tr),Ne=e.pipe(e.string(),e.transform(t=>t.split(",").map(o=>o.trim()).filter(o=>o.length>0))),nr=e.pipe(Ne,e.array(x)),rr=e.pipe(Ne,e.array(I)),Rt=e.pipe(e.string(),e.transform(t=>t.split(",").map(o=>Number(o.trim())).filter(o=>Number.isInteger(o)&&o>0))),or=e.pipe(Ne,e.array(B)),Pt=e.object({stages:e.optional(nr),stage_groups:e.optional(rr),job_id:e.optional(e.string()),job_ids:e.optional(Rt),candidate_id:e.optional(e.string()),is_disqualified:e.optional(e.picklist(["true","false"])),created_from:e.optional(e.string()),created_to:e.optional(e.string()),updated_from:e.optional(e.string()),updated_to:e.optional(e.string()),entered_stage_from:e.optional(e.string()),entered_stage_to:e.optional(e.string()),from:e.optional(e.string()),to:e.optional(e.string()),q:e.optional(e.string()),scored:e.optional(e.picklist(["true","false"])),ats_submission_status:e.optional(or),sort:e.optional(lt),order:e.optional(pt),page:e.optional(e.string()),per_page:e.optional(e.string())}),ir=e.object({status:e.picklist(["pending","not_required"]),integrationId:e.nullish(O)}),li=e.pipe(e.object({candidateId:E,disclosures:e.optional(e.unknown()),jobLocation:e.optional(e.unknown()),jobId:U,meta:e.nullish(w),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),externalJobId:e.nullish(e.pipe(E,e.maxLength(255))),context:e.nullish(w),source:e.nullish(ue),sourceDetail:e.nullish(e.string()),stage:e.nullish(x),stageGroup:e.nullish(I),actor:e.nullish(b),atsSubmission:e.nullish(ir),duplicateScope:e.nullish(e.picklist(["job","attempt"])),anonymousId:e.nullish(O)}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together"),e.check(t=>t.duplicateScope!=="attempt"||typeof t.meta?.attempt_id=="string"&&t.meta.attempt_id!=="","duplicateScope attempt needs meta.attempt_id")),kt=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),pi=e.union([e.object({ok:e.literal(!0),duplicate:e.literal(!1),applicationId:e.string(),candidateId:e.string(),atsHeld:e.optional(e.boolean())}),e.object({ok:e.literal(!0),duplicate:e.literal(!0),existingApplication:kt,atsHeld:e.optional(e.boolean())}),e.object({ok:e.literal(!1),refused:e.literal("pass_through_untracked")})]),Ct=e.object({email:e.pipe(e.string(),e.minLength(1),e.maxLength(320)),scope:e.optional(ct,"job"),jobId:e.optional(e.union([e.string(),e.number()]))}),Lt=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(kt)}),sr=Date.UTC(1e4,0,1),Ot=e.pipe(e.string(),e.regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?(Z|[+-]\d{2}:\d{2})$/),e.check(t=>{let[o,i,s]=t.slice(0,10).split("-").map(Number),d=new Date(Date.UTC(o,i-1,s)),p=Date.parse(t);return d.getUTCMonth()===i-1&&d.getUTCDate()===s&&p>=0&&p<sr},"must be a real time")),Be=e.pipe(e.string(),e.regex(/^[A-Za-z0-9_.:-]{1,100}$/)),di=e.object({status:e.picklist(["pending","submitted","failed"]),nextAttemptAt:e.nullish(Ot),errorCode:e.nullish(Be),errorMessage:e.nullish(e.pipe(e.string(),e.maxLength(1e4))),externalApplicationId:e.nullish(O),externalRunId:e.nullish(O),integrationId:e.nullish(O),answeredPending:e.optional(e.boolean())}),ar=e.picklist(["invalid_transition","next_attempt_required","retry_hold_expired"]),vi=e.variant("kind",[e.object({kind:e.literal("recorded"),application:F}),e.object({kind:e.literal("rejected"),applicationId:e.string(),from:e.nullable(B),to:B,reason:ar})]),cr=e.object({integrationId:e.string(),state:e.picklist(["closed","open","half_open"]),coolingUntil:e.nullable(e.string()),transientCount:e.number(),held:e.boolean()}),ui=e.object({groups:e.array(e.object({integrationId:e.nullable(e.string()),status:e.picklist(["pending","failed"]),errorCode:e.nullable(e.string()),count:e.number(),retryable:e.number(),sendable:e.optional(e.number()),nextRetryUntil:e.optional(e.nullable(e.string()))})),oldestPendingAgeSeconds:e.nullable(e.number()),breakers:e.array(cr),restoreHold:e.optional(e.boolean())}),mi=e.object({status:e.picklist(["pending","failed"]),integrationId:e.nullable(O),errorCode:e.nullable(Be)}),gi=e.object({rows:e.array(e.object({id:e.string(),jobId:e.number(),status:e.picklist(["pending","failed"]),errorCode:e.nullable(e.string()),errorMessage:e.nullable(e.string()),attempts:e.number(),nextAttemptAt:e.nullable(e.string()),payloadHeld:e.boolean(),receivedAt:e.nullable(e.string()),retryUntil:e.nullable(e.string()),updatedAt:e.string()})),truncated:e.boolean()}),hi=e.object({actor:b,expectedAtsLogCount:e.optional(e.pipe(e.number(),e.integer(),e.minValue(0)))}),lr=e.picklist(["invalid_transition","retry_payload_missing","retry_hold_expired","stale"]),fi=e.variant("kind",[e.object({kind:e.literal("retried"),application:F}),e.object({kind:e.literal("rejected"),applicationId:e.string(),from:e.nullable(B),reason:lr})]),bi=e.object({status:e.optional(e.picklist(["pending","failed"])),integrationId:e.nullable(O),errorCode:e.nullable(Be),actor:b}),Si=e.object({retried:e.number()}),pr=O,yi=e.object({integrationIds:e.optional(e.pipe(e.array(pr),e.maxLength(100)))}),_i=e.object({integrationId:e.string(),wasOpen:e.boolean()}),xi=e.object({integrationId:e.string(),wasHeld:e.boolean()}),Ai=e.object({applicationId:E,scoreType:ve,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),Oe)),leftOut:e.nullish(e.array(je)),reasonsWrittenBlind:e.nullish(e.boolean()),scoredBy:e.nullish(e.string()),actor:e.nullish(b),idempotencyKey:e.nullish(e.pipe(e.string(),e.maxLength(255)))}),Ti=e.object({scoreId:e.string()}),Ii=vt(F);var Ei=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),wi=e.array(It),me=e.object({stage:e.nullish(x),note:e.nullish(e.string())}),dr=e.object({stage:e.nullish(x),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),vr=e.pipe(e.string(),e.regex(/^[a-z0-9_.:-]{1,64}$/));var V=e.pipe(e.object({mode:e.picklist(["send","hold","none"]),templateKey:e.pipe(e.string(),e.regex(/^(received|rejection|interest_confirmation|campaign:invite|stage:[a-z0-9_-]{1,48})$/)),templateVersion:e.pipe(e.number(),e.integer(),e.minValue(1)),configVersionId:E,voice:e.optional(e.picklist(["casual","formal"])),holdUntil:e.optional(e.pipe(Ot,e.endsWith("Z","must be UTC with a Z suffix"),e.check(t=>Date.parse(t)>Date.now(),"must be in the future"))),subject:e.optional(e.pipe(e.string(),e.maxLength(200))),body:e.optional(e.pipe(e.string(),e.maxLength(2e4)))}),e.check(t=>t.mode==="hold"||t.holdUntil===void 0,"holdUntil is only for hold mode"),e.transform(({subject:t,body:o,...i})=>({...i,...t===void 0||t===""?{}:{subject:t},...o===void 0||o===""?{}:{body:o}}))),ur=e.variant("action",[e.object({action:e.literal("note"),actor:b,message:e.optional(e.never()),meta:e.object({note:E})}),e.object({action:e.literal("share"),actor:b,message:e.optional(e.never()),meta:e.object({subjectUserIds:e.pipe(e.array(E),e.minLength(1),e.maxLength(20)),comment:e.optional(e.string())})}),e.object({action:e.literal("verdict"),actor:b,message:e.optional(e.never()),meta:e.object({code:ot,comment:e.optional(e.string())})}),e.object({action:e.literal("offer_terms"),actor:b,message:e.optional(e.never()),meta:e.object({salary:e.optional(e.string()),startDate:e.optional(e.string()),hours:e.optional(e.string())})}),...["offer_sent","offer_accepted","offer_declined","offer_withdrawn"].map(t=>e.object({action:e.literal(t),actor:b,message:e.optional(e.never()),meta:e.object({reason:e.optional(e.string())})})),e.object({action:e.literal("exported"),actor:b,message:e.optional(e.never()),meta:e.object({presetId:vr,exportId:E})}),e.object({action:e.literal("score_override"),actor:b,message:e.optional(e.never()),meta:e.pipe(Et,e.transform(t=>({...t,reason:t.reason.trim()})))})]),mr=e.variant("action",[ur,e.object({action:e.literal("shortlist"),actor:b,message:e.optional(V),meta:e.nullish(me)}),e.object({action:e.literal("move_to_interview"),actor:b,message:e.optional(V),meta:e.nullish(me)}),e.object({action:e.literal("make_offer"),actor:b,message:e.optional(V),meta:e.nullish(me)}),e.object({action:e.literal("hire"),actor:b,message:e.optional(V),meta:e.nullish(dr)}),e.object({action:e.literal("withdraw"),actor:b,message:e.optional(e.never()),meta:e.nullish(me)}),e.object({action:e.literal("move_to_stage"),actor:b,message:e.optional(e.never()),meta:e.object({stage:x,stageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:b,message:e.optional(V),meta:e.object({toStage:x,toStageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:b,message:e.optional(V),meta:e.object({reason:ee,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:b,message:e.optional(V),meta:e.object({toStage:x,toStageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:b,message:e.optional(e.never()),meta:e.object({rating:e.nullable(e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(5)))})})]),Ri=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:mr}),jt=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),Pi=e.variant("kind",[e.object({kind:e.literal("updated"),action:ge,application:F}),e.object({kind:e.literal("skipped"),action:ge,applicationId:e.string(),reason:jt})]),ki=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:ge,application:F})),skipped:e.array(e.object({kind:e.literal("skipped"),action:ge,applicationId:e.string(),reason:jt})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),g=e.pipe(e.number(),e.integer(),e.minValue(0)),Dt=e.object({APPLIED:g,SHORTLISTED:g,INTERVIEWED:g,OFFERED:g,HIRED:g,REJECTED:g,WITHDRAWN:g}),gr=e.pipe(e.string(),e.minLength(1),e.maxLength(255)),Ci=e.object({pendingShares:e.optional(e.boolean())}),Li=e.object({job_ids:Rt,verdict_by:e.optional(gr),pending_shares:e.optional(e.literal("1"))}),Oi=e.object({counts:e.record(e.string(),Dt),existingAppliedCounts:e.optional(e.record(e.string(),g)),awaitingVerdictCounts:e.optional(e.record(e.string(),g)),pendingShareCounts:e.optional(e.record(e.string(),g))}),ji=e.omit(Pt,["sort","order","page","per_page"]),Di=e.object({counts:Dt}),Nt=92,hr=864e5;function Ue({from:t,to:o}){let i=(Date.parse(`${o}T00:00:00Z`)-Date.parse(`${t}T00:00:00Z`))/hr+1;return i>=1&&i<=Nt}var Fe=`to must be on or after from, and the range must span at most ${Nt} days`,Ni=e.pipe(e.object({from:A,to:A}),e.check(Ue,Fe)),fr=e.object({job_id:U,date:A,received:g,scored:g,shortlisted:g}),Bi=e.object({rows:e.array(fr)}),br=5e3,Ui=e.pipe(e.object({from:A,to:A,jobIds:e.pipe(e.array(U),e.maxLength(br))}),e.check(Ue,Fe)),Sr=e.object({job_id:U,date:A,received:g}),Fi=e.object({rows:e.array(Sr)}),yr=5e3,_r=e.pipe(e.object({from:A,to:A,jobIds:e.optional(e.pipe(e.array(U),e.maxLength(yr)))}),e.check(Ue,Fe)),Vi=e.pipe(e.object({from:e.string(),to:e.string(),job_ids:e.optional(e.string())}),e.transform(({from:t,to:o,job_ids:i})=>({from:t,to:o,jobIds:i===void 0?void 0:i===""?[]:i.split(",").map(s=>/^\d+$/.test(s.trim())?Number(s):Number.NaN)})),_r),Ve=e.pipe(e.array(g),e.length(5)),xr=e.object({received:g,scored:g,shortlisted:g,histogram:e.pipe(e.array(g),e.length(101)),median_lag_minutes:e.nullable(e.number()),scored_same_day:g}),Ar=e.object({job_id:U,received:g,scored:g,shortlisted:g,score_sum:e.number(),bands:Ve}),Tr=e.object({date:A,received:g,scored:g,score_sum:e.number(),bands:Ve,scored_on_day:g}),Ir=e.object({id:e.string(),label:e.nullable(e.string()),sum:e.number(),count:g}),Er=e.object({template_id:e.string(),scored:g,criteria:e.array(Ir)}),Mi=e.object({totals:xr,by_job:e.array(Ar),by_day:e.array(Tr),criteria:e.array(Er)}),wr=e.object({date:A,scored:g,bands:Ve}),qi=e.object({rows:e.array(wr)});var Gi=e.object({...e.omit(Pt,["page","per_page"]).entries,per_group:e.optional(e.string())}),M=e.object({data:e.array(F),total:g}),Ji=e.object({board:e.object({APPLIED:M,SHORTLISTED:M,INTERVIEWED:M,OFFERED:M,HIRED:M,REJECTED:M,WITHDRAWN:M})});import*as Y from"valibot";var Rr=({environment:t,publishableKey:o,logger:i})=>{let s=We[t];return{async checkDuplicate(d){let p;try{p=Y.parse(Ct,{email:d.email,scope:d.scope,...d.scope==="job"&&d.jobId!=null?{jobId:d.jobId}:{}})}catch{return i.error("[TalentBankClient] checkDuplicate input failed validation"),{isDuplicate:!1}}try{let u=await fetch(`${s}/applications/check-duplicate`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-publishable-key":o},body:JSON.stringify(p)});if(!u.ok)return i.error(`[TalentBankClient] checkDuplicate failed with status ${u.status}`),{isDuplicate:!1};let h=await u.json(),_=Y.safeParse(Lt,h);return _.success?_.output:(i.error("[TalentBankClient] checkDuplicate response failed strict validation; falling back to isDuplicate flag"),typeof h=="object"&&h!=null&&typeof h.isDuplicate=="boolean"?{isDuplicate:h.isDuplicate}:{isDuplicate:!1})}catch(u){return i.error("[TalentBankClient] checkDuplicate failed:",u),{isDuplicate:!1}}},async identify(d){try{if(!d.anonymousId)return i.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let p={email:d.email,firstName:d.firstName,lastName:d.lastName,phone:d.phone,anonymousId:d.anonymousId,source:d.source??"sdk"},u=Y.safeParse(wt,p);if(!u.success)return i.error("[TalentBankClient] identify received invalid input"),null;let h=await fetch(`${s}/identify`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-publishable-key":o},body:JSON.stringify(u.output)});if(!h.ok)return i.error(`[TalentBankClient] identify failed with status ${h.status}`),null;let _=Y.safeParse(De,await h.json());return _.success?_.output:(i.error("[TalentBankClient] identify returned an invalid response"),null)}catch(p){return i.error("[TalentBankClient] identify failed:",p),null}}}};function Pr(t){if(!(typeof document>"u")){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",t,{once:!0});return}Promise.resolve().then(t)}}import*as l from"valibot";var Bt=["DAILY","WEEKLY","MONTHLY"],kr=l.record(l.string(),l.union([l.string(),l.array(l.string()),l.object({type:l.literal("provided"),lat:l.number(),lng:l.number(),radius:l.number(),unit:l.optional(l.picklist(["miles","km"])),label:l.optional(l.string())})])),Cr={pathname:"/job/:id",method:"GET",schema:{response:l.object({id:l.number(),external_id:l.nullish(l.string()),city:l.nullish(l.string()),town:l.nullish(l.string()),category:l.nullish(l.string())})}};async function Lr(t,{contact:o,job:i}){let s={};if(i){let d=await t.request(Cr,{params:{id:i.id}});if((i.id_type==="internal"?String(d.id):d.external_id)!==i.id)throw new Error("Job lookup returned a different role");for(let u of["city","town","category"]){let h=d[u]?.trim();h&&(s[u]=[h])}}await t.request(Ut,{body:{contact:o,alerts:"WEEKLY",filters:s}})}var Ut={pathname:"/search/save",method:"POST",schema:{response:j(),body:l.object({contact:l.object({email:l.pipe(l.optional(l.string()),l.string(),l.email()),first_name:l.optional(l.string()),last_name:l.optional(l.string())}),alerts:l.pipe(l.optional(l.string()),l.string(),l.picklist(Bt)),filters:kr})}};import*as T from"valibot";var Ft=async t=>{let o={method:"GET",pathname:"/search/filters",schema:{response:T.pipe(T.object({country:T.optional(T.array(T.object({value:T.string()})),[])}),T.transform(({country:i})=>i.map(({value:s})=>s))),searchParams:j()}};return t.request(o,{searchParams:{filters:{country:null}}})},he=new WeakMap,Or=t=>(he.has(t)||(he.set(t,void 0),Ft(t).then(async o=>{let{jobCountryCodes:i}=await import("./sdk.country-codes-R6CUZ3IG.mjs");he.set(t,i(o).join(",")||void 0)}).catch(()=>{})),he.get(t)),Vt=(t,o)=>{let i=new Set,s=[];for(let d=0;d<Math.max(t.length,o.length);d++)for(let p of[t[d],o[d]]){if(!p)continue;let u=p.mapbox_id||p.full_address||[p.name,p.place_formatted].filter(Boolean).join(", ");if(!i.has(u)&&(i.add(u),s.push(p),s.length===5))return s}return s},jr=600,Dr=async(t,o,i)=>{if(i?.throwIfAborted(),!o){let s=await t();return i?.throwIfAborted(),s}return new Promise((s,d)=>{let p,u,h,_=!1,R=()=>{_=!0,clearTimeout(h),i?.removeEventListener("abort",q)},q=()=>{R(),d(i?.reason)},D=()=>{R(),p?.status==="fulfilled"&&u?.status==="fulfilled"?s(Vt(p.value,u.value)):p?.status==="fulfilled"?s(p.value):u?.status==="fulfilled"?s(u.value):p?.status==="rejected"&&d(p.reason)},fe=(v,S)=>{_||(v?p=S:u=S,p&&u?D():S.status==="fulfilled"&&S.value.length>0&&(h=setTimeout(D,jr)))};i?.addEventListener("abort",q,{once:!0});for(let v of[!0,!1])t(v?o:void 0).then(S=>fe(v,{status:"fulfilled",value:S}),S=>fe(v,{status:"rejected",reason:S}))})};export{ln as ANALYTICS_EVENTS,H as ApiError,X as InploiRpcClient,Bt as JOB_ALERT_FREQUENCIES,$ as NotFoundError,K as ParsingError,C as SchemaValidationError,Je as SdkError,W as UnauthorisedError,Or as addressSearchCountry,Vt as blendAddressSuggestions,ke as consentStorageKey,Jt as createPlugin,Rr as createTalentBankClient,pe as endpoint,Q as generateUUID,pn as getConsentAcceptance,Ft as getJobCountries,tt as getOrCreateAnonymousId,Pe as hashConsentConfig,cn as initialiseSdk,_e as inploiBrandedLogger,Ht as isApiErrorWithData,zt as isSdkError,Gt as jobCountryCodes,xe as noLogging,Pr as ready,Lr as saveClosedRoleJobAlerts,Ut as saveSearchEndpoint,Dr as searchAddressSuggestions,dn as setConsentAcceptance,j as typed,rt as validateEndpointInputs};
2
2
  //# sourceMappingURL=index.mjs.map