@sinequa/atomic 0.0.139 → 1.0.1
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/atomic.js +606 -559
- package/dist/atomic.umd.cjs +1 -1
- package/dist/authentication/constants.d.ts +5 -0
- package/dist/authentication/constants.d.ts.map +1 -0
- package/dist/authentication/events/emit-authenticated-event.d.ts.map +1 -1
- package/dist/authentication/providers/oauth-authentication.d.ts +6 -0
- package/dist/authentication/providers/oauth-authentication.d.ts.map +1 -1
- package/dist/authentication/providers/saml-authentication.d.ts +6 -0
- package/dist/authentication/providers/saml-authentication.d.ts.map +1 -1
- package/dist/authentication/session/logout.d.ts.map +1 -1
- package/dist/authentication/tokens/delete-web-token-cookie.d.ts +1 -1
- package/dist/authentication/tokens/delete-web-token-cookie.d.ts.map +1 -1
- package/dist/authentication/tokens/get-csrf-token.d.ts +4 -4
- package/dist/authentication/tokens/get-csrf-token.d.ts.map +1 -1
- package/dist/authentication/tokens/get-jwt-token.d.ts +10 -8
- package/dist/authentication/tokens/get-jwt-token.d.ts.map +1 -1
- package/dist/authentication/tokens/get-token.d.ts +2 -2
- package/dist/authentication/tokens/get-token.d.ts.map +1 -1
- package/dist/types/audit/AuditEventType.d.ts +9 -2
- package/dist/types/audit/AuditEventType.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-app.d.ts +2 -1
- package/dist/web-api/v1/fetch-app.d.ts.map +1 -1
- package/package.json +5 -2
package/dist/atomic.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(o,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(o=typeof globalThis<"u"?globalThis:o||self,m(o.atomic={}))})(this,(function(o){"use strict";function m(e){const t=new CustomEvent("authenticated",{bubbles:!0,cancelable:!1,detail:{authenticated:e}});dispatchEvent(t)}const d={loginPath:"/login",createRoutes:!1};function p(e){Object.assign(d,e)}function L(e){const t=j(),r=new Headers(e);r.append("Sinequa-Force-Camel-Case","true"),r.append("accept","application/json"),t&&r.append("Sinequa-csrf-token",t);const{userOverride:n,userOverrideActive:a,bearerToken:s}=d;return s&&r.append("Authorization",`Bearer ${s}`),n&&a&&(r.append("sinequa-override-user",n.username),r.append("sinequa-override-domain",n.domain)),r}class C extends Error{status;constructor(t,r){super(t),this.name="ApiError",this.status=r}}class V extends C{constructor(t="Server error"){super(t,500),this.name="ServerError"}}class Z extends C{constructor(t="Request timed out"){super(t,408),this.name="TimeoutError"}}class D extends C{constructor(t="Unauthorized access"){super(t,401),this.name="UnauthorizedError"}}const E=/.*\:\(?([><=\d\-\.AND ]+)\)?/;function Ie(e,t){return!e?.items||e?.items?.length===0?[]:e.items.reduce((a,s)=>{if(!s.value||s.value==="")return a;const i=T(s,e.column);return a.push({operator:i.operator,value:i.value,display:s.display||i.display,filters:i.filters,disabled:s.count===0,hidden:s.count===0&&e.isDistribution?!t:!1}),a},[])}function T(e,t){const r=t,n=e.value.match(E);if(n?.[1]){const s=(n?.[1].split(" AND ")).map(i=>{const l=i.indexOf(">=")!==-1?"gte":"lt";let c=i.substring(i.indexOf(" ")+1);return{field:r,operator:l,value:c,display:e.display||e.value}});if(s.length===2)return{field:r,operator:"and",filters:s,value:e.value,display:s[0].display||s[0].value};if(s.length===1)return{...s[0],field:r};throw new Error("Failed to parse distribution expression")}return{field:r,operator:"eq",value:e.value,display:e.display}}function De(e,t,r){return e.valuesAreExpressions?t.display===r.display:t.value===r.value}function ee(e){return e.items&&(e.items=e.items.map(t=>ee(t))),e.items&&e.items.some(t=>t.$selected||t.$opened)&&(e.$opened=!0),e}function Fe(e,t){const r=[];if(e.length>0){const n=new Map,s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g,""),i=new RegExp("\\b"+s,"i");e.forEach(l=>{if(l.display.length>1){const c=l.display.normalize("NFD").replace(/[\u0300-\u036f]/g,""),f=i.exec(c);te(r,n,"/",l.display,+(l.frequency||0),1,(f?.index||0)+t.length)}})}return r}function te(e,t,r,n,a,s,i){const l=n.indexOf("/",r.length),c=n.substring(0,l+1);let f=t.get(c);if(!f){const b=c.replace(/^\/|\/$/g,"");f={value:n.substring(r.length,l),count:a,items:[],hasChildren:!1,$level:s,$opened:i>=c.length,$path:b},t.set(c,f),e.push(f)}c.length<n.length&&(f.hasChildren=!0,te(f.items,t,c,n,a,s+1,i))}function Ne(e,t){return e.reduce((r,n)=>(t(n)?r.true.push(n):r.false.push(n),r),{true:[],false:[]})}const qe=/(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g,Be=2,re=3,Qe=5,ne=6,je=8,ae=9,Ve=11,oe=12,Ge=14,se=15;function $(e){if(!e)return[];const t=[],r=e.matchAll(qe);for(let n of r)n[re]?t.push({type:"group",value:n[re],op:n[Be]}):n[ne]?t.push({type:"adjacent",value:n[ne],op:n[Qe]}):n[ae]?t.push({type:"exact",value:n[ae],op:n[je]}):n[oe]?t.push({type:"regex",value:n[oe],op:n[Ve]}):n[se]&&t.push({type:"token",value:n[se],op:n[Ge]});return t}function F(e){return e.map(t=>{const r=t.op||"";switch(t.type){case"group":return`${r}(${t.value})`;case"adjacent":return`${r}[${t.value}]`;case"exact":return`${r}"${t.value}"`;case"regex":return`${r}/${t.value}/`;case"token":return`${r}${t.value}`}}).join(" ")}function xe(e,t,r){let n=$(e);for(let a of t)n.push({type:"adjacent",value:a,op:r});return F(n)}function ze(e,t){const r=$(t),n=r.findIndex(a=>a.value===e);return n!==-1?(r.splice(n,1),t=F(r)):t}function Me(e){const t=$(e).filter(r=>r.type!=="adjacent");return F(t)}function He(e){return $(e).filter(t=>t.type==="adjacent").map(t=>t.value)}function Je(e,t,r){const n=new Intl.RelativeTimeFormat(e,{numeric:"auto"}),{offset:a,unit:s,isFuture:i}=ie(t,r);return n.format(a*(i?1:-1),s)}function ie(e,t){const r=new Date(e),n=t?new Date(t):new Date,a=Math.abs(n.getTime()-r.getTime());return{offset:Math.floor(a/(1e3*60*60*24)),unit:"day",isFuture:r>n}}function We(e){const t=e.target;return t&&t.nodeName!=="INPUT"&&t.nodeName!=="TEXTAREA"}function Xe(e){if(e===void 0)return;const{q:t,f:r,p:n,s:a,t:s,n:i,b:l}=P(e),[c]=e.split("?");return{path:c,text:t,filters:r?G(r):void 0,page:n?parseInt(n,10):void 0,sort:a,tab:s,name:i,basket:l}}function Ye(e){if(!e)return"";const{text:t,filters:r,page:n,sort:a,tab:s,name:i,basket:l}=e,c={};t&&(c.q=t),r&&(c.f=JSON.stringify(r)),n&&(c.p=n.toString()),a&&(c.s=a),s&&(c.t=s),i&&(c.n=i),l&&(c.b=l);const f=new URLSearchParams(c).toString();return f||""}function Ke(e){if(e===void 0)return[];const{f:t}=P(e);return G(t)}function G(e){const t=decodeURIComponent(e);try{return JSON.parse(t??"[]")}catch{return console.error(`Error parsing filters from URI: ${e}`),[]}}function P(e){const t=e.split("?")[1];if(t===void 0)return{};const r=new URLSearchParams(t);return Object.fromEntries(r)}function Ze(e){const{q:t=""}=P(e);return t}function Ee(e){const{id:t}=P(e);return decodeURIComponent(t)}function Te(e){const{p:t="0"}=P(e);return parseInt(t,10)}function et(e){const{t}=P(e);return t}function tt(e,t){if(!e)return e;let r=0;const n=e.length;let a=0;if(e[a]==="["){for(;a<n&&/[0-9]/.test(e[a]);)a++;e[a]==="]"&&(r=a+1)}const s=x(e,r,!1);if(!s)return e;const i=t.charCodeAt(0),l=t.charCodeAt(1);let c=s;for(;c;)if(i===c.lang1&&l===c.lang2){const b=x(e,c.end+4,!0);return e.substring(b.start,b.end)}else c=x(e,c.end+4,!1);const f=e.substring(s.start,s.end);return f||e}function x(e,t,r){for(let n=t,a=e.length-3;n<a;n++)if(e[n]==="["&&e[n+3]==="]")return{start:t,end:n,lang1:e.charCodeAt(n+1),lang2:e.charCodeAt(n+2)};if(r)return{start:t,end:e.length,lang1:-1,lang2:-1}}function rt(e,t){const{useLocale:r,useLocaleAsPrefix:n,indexFile:a,path:s,folder:i}=t,l=r?`${e}/`:null,c=n?`${e}.${a}`:a??"";return[s,i,`${l||""}${c}`].filter(f=>f!==void 0).join("/")}function N(e){const t=new CustomEvent("notification",{bubbles:!0,cancelable:!1,detail:e});dispatchEvent(t)}const nt={success:(e,t)=>{N({type:"success",message:e,options:t})},info:(e,t)=>{N({type:"info",message:e,options:t})},warning:(e,t)=>{N({type:"warning",message:e,options:t})},error:(e,t)=>{N({type:"error",message:e,options:t})}};var z=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE",e))(z||{});let q={level:1,enableConsoleOutput:!0};function at(e){q={...q,...e}}function B(e,t,r){if(e<q.level)return;const a=`${`[${z[e]}]`} ${t}`;if(q.enableConsoleOutput)switch(e){case 0:console.debug(a,r||"");break;case 1:console.info(a,r||"");break;case 2:console.warn(a,r||"");break;case 3:console.error(a,r||"");break}}function R(e,t){B(0,e,t)}function k(e,t){B(1,e,t)}function U(e,t){B(2,e,t)}function h(e,t){B(3,e,t)}async function y(e,t="json"){const r=e.headers.get("sinequa-jwt-refresh");if(r!==null&&I(r),e.status===200)switch(t){case"arraybuffer":return await e.arrayBuffer();case"blob":return await e.blob();case"text":return await e.text();default:return await e.json()}if(e.status===401){if(d.userOverrideActive)throw U("Unauthorized access attempt with user override",{endpoint:e.url}),new D("Unauthorized... User override failed.");return await M(e,401)}return e.status===500?(h("Server error occurred",{endpoint:e.url}),await M(e,500)):(U(`Unexpected response status: ${e.status}`,{endpoint:e.url}),await M(e,e.status))}async function M(e,t){try{const{done:r,value:n}=await e.body?.getReader().read()||{done:!0,value:void 0};if(r||!n)throw t===401?new D:t===500?new V:new C(`Request failed with status ${t}`,t);const a=JSON.parse(new TextDecoder().decode(n));throw new Error(a.errorMessage||a.message||`Request failed with status ${t}`,{cause:{errorCode:a.errorCode,errorCodeTest:a.errorCodeTest}})}catch(r){throw r instanceof C?r:t===401?new D(r.message):t===500?new V(r.message):new C(r.message??`Request failed with status ${t}`,t)}}async function ce(e,t,r){const n=L(r?.headers),{backendUrl:a}=d,s=t?`?${new URLSearchParams(t)}`:"",i=a?`${a}/${e}${s}`:`${e}${s}`;R(`Making DELETE request to: ${i}`);try{const l=await fetch(i,{method:"DELETE",credentials:"include",headers:n});return y(l,r?.responseType)}catch(l){throw h("Error making DELETE request:",l),l}}async function S(e,t,r){const n=L(r?.headers),{backendUrl:a}=d,s=t?`?${new URLSearchParams(t)}`:"";e.startsWith("plugin")&&(e=`api/v1/${e}`);const i=a?`${a}/${e}${s}`:`${e}${s}`;R(`Making GET request to: ${i}`);try{const l=await fetch(i,{method:"GET",credentials:"include",headers:n,signal:r?.signal});return y(l,r?.responseType)}catch(l){throw h("Error making GET request:",l),l}}async function le(e,t,r){const n=L(r?.headers);n.append("content-type","application/json");const{app:a,backendUrl:s}=d,i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},l=s?`${s}/${e}`:`${e}`;R(`Making PATCH request to: ${l}`);try{const c=await fetch(l,{method:"PATCH",headers:n,credentials:"include",body:JSON.stringify(i)});return y(c,r?.responseType)}catch(c){throw h("Error making PATCH request:",c),c}}async function u(e,t,r){const n=L(r?.headers),{app:a,backendUrl:s}=d;n.has("Content-Type")||n.set("Content-Type","application/json");const i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0};e.startsWith("plugin")&&(e=`api/v1/${e}`);const l=s?`${s}/${e}`:`${e}`;R(`Making POST request to: ${l}`);try{const c=await fetch(l,{method:"POST",headers:n,credentials:"include",body:JSON.stringify(i),signal:r?.signal});return y(c,r?.responseType)}catch(c){throw h("Error making POST request:",c),c}}async function ot(e,t,r){const n=L(r?.headers),{app:a,backendUrl:s}=d,i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},l=`${s}/${e}`;R(`Making PUT request to: ${l}`);try{const c=await fetch(l,{method:"PUT",headers:n,credentials:"include",body:JSON.stringify(i)});return y(c,r?.responseType)}catch(c){throw h("Error making PUT request:",c),c}}function st(e){const t=new AbortController,{signal:r}=t;return e&&setTimeout(()=>{r.aborted||t.abort(new Z(`Request timed out after ${e}ms`))},e),{controller:t,signal:r}}function H(e){if(!e)return;const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t}function it(e){const t=H(e);return!!t&&t.getTime()<=Date.now()}function ct(e,t=7){const r=H(e);if(!r)return!1;const n=Date.now(),a=n+t*24*60*60*1e3,s=r.getTime();return s>n&&s<=a}async function lt(e,t=0,r=1e3){let n;for(let a=0;a<=t;a++)try{return await e()}catch(s){if(n=s,s instanceof C&&s.status>=400&&s.status<500&&s.status!==429||s instanceof DOMException&&s.name==="AbortError")throw s;a<t&&(U(`Retrying request (${a+1}/${t})`,{error:s}),await new Promise(i=>setTimeout(i,r)))}throw n}function ut(e,t,r){if(!e||!t)return;if(r){const s=Object.keys(t.queries).find(c=>c===r?.toLowerCase());let i;s&&(i=t.queries[s]);const l=(i?.columnsInfo?.columns||[])?.find(c=>c.aliases?.split(",")?.includes(e));if(l)return l.name}const n=t.indexes?._?.columns,a=Object.entries(n).find(s=>s[1].aliases?.includes(e));if(a)return a[0]}var v=(e=>(e.None="None",e.Search_FirstPage="Search_FirstPage",e.Search_Text="Search_Text",e.Search_Refine="Search_Refine",e.Search_Select_Item="Search_Select_Item",e.Search_Select_Custom="Search_Select_Custom",e.Search_Select_Concept="Search_Select_Concept",e.Search_Select_Correction="Search_Select_Correction",e.Search_GotoPage="Search_GotoPage",e.Search_GotoTab="Search_GotoTab",e.Search_DisplayResult="Search_DisplayResult",e.Search_RemoveResult="Search_RemoveResult",e.Search_RemoveAdvanced="Search_RemoveAdvanced",e.Search_SavedQuery="Search_SavedQuery",e.Search_WebService="Search_WebService",e.Search_DidYouMean_Original="Search_DidYouMean_Original",e.Search_DidYouMean_Correction="Search_DidYouMean_Correction",e.Search_ExportCSV="Search_ExportCSV",e.Search_SavedQuery_ExportCSV="Search_SavedQuery_ExportCSV",e.Search_Selection_ExportCSV="Search_Selection_ExportCSV",e.Search_AlertQuery="Search_AlertQuery",e.Search_Select_AnalyticsItem="Search_Select_AnalyticsItem",e.Search_Sort="Search_Sort",e.Search_Exit_Logout="Search_Exit_Logout",e.Search_Timeline_Usage="Search_Timeline_Usage",e.Search_AutoComplete="Search_Autocomplete",e.Search_Login_Success="Login_Success_Form",e.Search_QueryIntent_Detected="Search_QueryIntent_Detected",e.SavedQuery_Add="SavedQuery_Add",e.SavedQuery_Delete="SavedQuery_Delete",e.SavedQuery_DeleteAll="SavedQuery_DeleteAll",e.SavedQuery_Rename="SavedQuery_Rename",e.Alert_Edit="Alert_Edit",e.Alert_Delete="Alert_Delete",e.Alert_DeleteAll="Alert_DeleteAll",e.Link_Display="Link_Display",e.Link_Click="Link_Click",e.Basket_Add="Basket_Add",e.Basket_Delete="Basket_Delete",e.Basket_DeleteAll="Basket_DeleteAll",e.Basket_Rename="Basket_Rename",e.Basket_AddDoc="Basket_AddDoc",e.Basket_RemoveDoc="Basket_RemoveDoc",e.Basket_Open="Basket_Open",e.Basket_ExportCSV="Basket_ExportCSV",e.Label_Add="Label_Add",e.Label_Delete="Label_Delete",e.Label_Rename="Label_Rename",e.Label_Open="Label_Open",e.Label_AddDoc="Label_AddDoc",e.Label_RemoveDoc="Label_RemoveDoc",e.Label_ExportCSV="Label_ExportCSV",e.Label_Menu_ExportCSV="Label_Menu_ExportCSV",e.Rating_Set="Rating_Set",e.Rating_Delete="Rating_Delete",e.Doc_Preview="Doc_Preview",e.Doc_CacheHtml="Doc_CacheHtml",e.Doc_CachePdf="Doc_CachePdf",e.Doc_CacheOriginal="Doc_CacheOriginal",e.Doc_Url1="Doc_Url1",e.Doc_Url2="Doc_Url2",e.Preview_Close="Preview_Close",e.Click_ResultLink="Click_ResultLink",e.Click_ResultLink1="Click_ResultLink1",e.Click_ResultLink2="Click_ResultLink2",e.Click_ResultLink3="Click_ResultLink3",e.Click_ResultLink4="Click_ResultLink4",e.Click_ResultLink5="Click_ResultLink5",e.Click_ResultLink6="Click_ResultLink6",e.Click_ResultLink7="Click_ResultLink7",e.Click_ResultLink8="Click_ResultLink8",e.Click_ResultLink9="Click_ResultLink9",e.Click_ResultLink10="Click_ResultLink10",e.Click_PreviewLink1="Click_PreviewLink1",e.Click_PreviewLink2="Click_PreviewLink2",e.Click_PreviewLink3="Click_PreviewLink3",e.Click_PreviewLink4="Click_PreviewLink4",e.Click_PreviewLink5="Click_PreviewLink5",e.Click_PreviewLink6="Click_PreviewLink6",e.Click_PreviewLink7="Click_PreviewLink7",e.Click_PreviewLink8="Click_PreviewLink8",e.Click_PreviewLink9="Click_PreviewLink9",e.Click_PreviewLink10="Click_PreviewLink10",e.RFM_ClickSet="RFM_ClickSet",e.RFM_ClickReset="RFM_ClickReset",e.RFM_Like="RFM_Like",e.RFM_LikeReset="RFM_LikeReset",e.RFM_Dislike="RFM_Dislike",e.RFM_Important="RFM_Important",e.RFM_ImportantReset="RFM_ImportantReset",e.RFM_Ban="RFM_Ban",e.Navigation_Exit="Navigation_Exit",e.Navigation_Return="Navigation_Return",e.Navigation_Route="Navigation_Route",e.Answer_Display="Answer_Display",e.Answer_Click="Answer_Click",e.Answer_Result="Answer_Result",e.Answer_Liked="Answer_Liked",e.Answer_Disliked="Answer_Disliked",e.Answer_Liked_Cancelled="Answer_Liked_Cancelled",e.Answer_Disliked_Cancelled="Answer_Disliked_Cancelled",e.TopPassages_Display="TopPassages_Display",e.TopPassages_Click="TopPassages_Click",e.UserSettings_Reset="UserSettings_Reset",e))(v||{}),g=(e=>(e[e.none=0]="none",e[e.bool=1]="bool",e[e.date=2]="date",e[e.dateTime=3]="dateTime",e[e.time=4]="time",e[e.unsigned=5]="unsigned",e[e.integer=6]="integer",e[e.float=7]="float",e[e.double=8]="double",e[e.dates=9]="dates",e[e.dateTimes=10]="dateTimes",e[e.times=11]="times",e[e.varchar=12]="varchar",e[e.binary=13]="binary",e[e.string=14]="string",e[e.csv=15]="csv",e))(g||{}),_=(e=>(e[e.none=0]="none",e[e.a=2053]="a",e[e.c=4]="c",e[e.d=8]="d",e[e.e=2068]="e",e[e.i=256]="i",e[e.l=2052]="l",e[e.n=8192]="n",e[e.t=524292]="t",e[e.x=8388608]="x",e[e.z=33554432]="z",e[e.f_ordinal=8192]="f_ordinal",e[e.f_multidates=8192]="f_multidates",e[e.f_varchar=33554432]="f_varchar",e[e.f_binary=33562624]="f_binary",e[e.f_string=33562888]="f_string",e[e.f_csv=42477853]="f_csv",e[e.f_overridable=33554696]="f_overridable",e))(_||{});const dt="1.0";var ue=(e=>(e[e.Original=0]="Original",e[e.Corrected=1]="Corrected",e))(ue||{}),de=(e=>(e[e.none=0]="none",e[e.positiveRate=1]="positiveRate",e[e.mainlyPosRate=2]="mainlyPosRate",e[e.unrate=4]="unrate",e[e.mainlyNegRate=8]="mainlyNegRate",e[e.negativeRate=16]="negativeRate",e[e.all=31]="all",e[e.positiveOnly=7]="positiveOnly",e[e.negativeOnly=28]="negativeOnly",e[e.personalAll=21]="personalAll",e[e.personalPosOnly=5]="personalPosOnly",e[e.personalNegOnly=20]="personalNegOnly",e))(de||{});function ft(e){if(!e)return g.none;switch(e.toLocaleLowerCase()){case"bool":case"boolean":return g.bool;case"date":return g.date;case"datetime":return g.dateTime;case"time":return g.time;case"unsigned":return g.unsigned;case"integer":return g.integer;case"float":return g.float;case"double":return g.double;case"dates":return g.dates;case"datetimes":return g.dateTimes;case"times":return g.times;case"varchar":return g.varchar;case"binary":return g.binary;case"string":return g.string;case"csv":return g.csv;default:return g.none}}function ht(e){switch(e){case"a":return _.a;case"c":return _.c;case"d":return _.d;case"e":return _.e;case"i":return _.i;case"l":return _.l;case"n":return _.n;case"t":return _.t;case"x":return _.x;case"z":return _.z;default:return _.none}}function gt(e){let t=_.none;if(e)for(const r of e)t|=ht(r);return t}function w(e,t,r,n){const a=ft(t),s=gt(r||"");return{name:e,type:t,typeModifier:r,eType:a,eTypeModifier:s,aliases:n}}const mt={id:w("id","string"),text:w("text","varchar"),documentlanguages:w("documentlanguages","csv","ci",["language"]),databasealias:w("databasealias","varchar"),globalrelevance:w("globalrelevance","double"),matchingpartnames:w("matchingpartnames","csv"),matchlocations:w("matchlocations","csv"),matchlocationsperpartname:w("matchlocationsperpartname","varchar"),extracts:w("extracts","csv"),extractsperpartname:w("extractsperpartname","varchar"),extractslocations:w("extractslocations","csv"),documentweight:w("documentweight","varchar"),groupcount:w("groupcount","integer"),accesslists:w("accesslists","varchar",void 0,["accessLists"])};function wt(e,t){let r=e[t];return r===void 0?[]:(typeof r=="string"&&(r=String(r).split(",")),Array.isArray(r)?r.map(n=>{if(typeof n=="string")return n.trim();if(typeof n=="object"&&n!==null&&"display"in n)return n.display.trim()}).filter(n=>n!==void 0):[String(r).trim()])}function St(e,t){let r=e[t];if(r===void 0)return[];if(typeof r=="string"&&(r=String(r).split(",")),Array.isArray(r))return r.map(a=>{if(typeof a=="string")return{display:a.trim(),value:a.trim()};if(typeof a=="object"&&a!==null&&"display"in a){const s=a.display.trim(),i="value"in a?String(a.value).trim():s;return{display:s,value:i}}}).filter(a=>a!==void 0);const n=String(r).trim();return[{display:n,value:n}]}function A(e){return e!==null&&typeof e=="object"}function fe(e){return A(e)&&Object.prototype.toString.call(e)==="[object ArrayBuffer]"}function he(e){return A(e)&&Object.prototype.toString.call(e)==="[object Blob]"}function ge(e){return Object.prototype.toString.call(e)==="[object Date]"}function me(e){return typeof e=="string"}function _t(e){return(A(e)||Array.isArray(e))&&!fe(e)&&!he(e)&&!me(e)}function we(e){return e?(e.getHours()*60*60+e.getMinutes()*60+e.getSeconds())*1e3+e.getMilliseconds():0}function Se(e=!0){let t=Date.now();return(e?"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx":"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g,n=>{const a=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(n==="x"?a:a&3|8).toString(16)})}function pt(e){if(!e)return"``";if(e=String(e),e.search(/[\\`]/)===-1)return`\`${e}\``;const t=["`"];for(let r=0,n=e.length;r<n;r++){const a=e[r];(a==="\\"||a==="`")&&t.push("\\"),t.push(a)}return t.push("`"),t.join("")}function kt(e){if(typeof crypto<"u"&&crypto.subtle&&typeof crypto.subtle.digest=="function")try{return crypto.subtle.digest("SHA-512",new TextEncoder().encode(e)).then(t=>Array.prototype.map.call(new Uint8Array(t),r=>`00${r.toString(16)}`.slice(-2)).join("")).catch(()=>Promise.resolve(J(e)))}catch{return Promise.resolve(J(e))}return Promise.resolve(J(e))}function J(e){let n=2166136261;for(let b=0;b<e.length;b++)n^=e.charCodeAt(b),n=n*16777619>>>0;const a=n.toString(16).padStart(8,"0"),s=((n^2863311530)>>>0).toString(16).padStart(8,"0"),i=((n^1431655765)>>>0).toString(16).padStart(8,"0"),l=((n^3435973836)>>>0).toString(16).padStart(8,"0"),c=a+s+i+l;return(c+c+c+c).substring(0,128)}let W,_e;function O(e,t=!0){let r=bt(e.$auditRecord);r&&(pe(r),t&&ke(r)),e.$auditRecord=r}function bt(e){if(!e)return;let t;if(Array.isArray(e))t=e;else if(A(e)){const r=e;if(r.auditEvents||r.mlAuditEvents)return r;t=[e]}return{auditEvents:t}}function pe(e){const t=vt();return e.auditEvents?.forEach(r=>{r.detail||(r.detail={}),r.detail.sessionid=t}),e}function ke(e){const t=typeof window<"u"?decodeURIComponent(window.location.href):"http://localhost";return e?.auditEvents?.forEach(r=>{r.detail||(r.detail={}),r.detail.url=t}),e}function vt(){return(!W||Ct())&&(W=Se()),_e=new Date,W}function Ct(){return new Date().getTime()-_e.getTime()>600*1e3}async function yt(e,t=!0){const r={event:v.None,$auditRecord:e};return O(r,t),u("api/v1/audit.notify",r)}const Pt={notify:yt};async function Rt(e,t,r){const n=e.items?.length||0,a=10,s={query:{...t,action:"aggregate",aggregations:{[e.name]:{skip:n,count:a}}},$auditRecord:{auditEvents:[r]}};O(s);const i=await u("api/v1/query",s),l=await y(i),{aggregations:c}=l,f=c[0];return f.$hasMore=f.items.length>a,f.items=[...e.items,...f.items],Promise.resolve(f)}async function Lt(){const{app:e}=d,t=new URLSearchParams({app:e||""});return S("api/v1/app",t)}async function be(){const{app:e}=d,t=new URLSearchParams({app:e||"",preLogin:"true"});return S("api/v1/app",t)}function Ut(){let{backendUrl:e,app:t,useCredentials:r}=d;if(typeof window<"u"){if(e||(e=window.location.origin),!t){const n=window.location.pathname.match(/\/app(?:-debug)?\/([^/#]+)/);n&&(t=n[1])}p({...d,backendUrl:e,app:t})}return r?(p({...d,useCredentials:!0,useSSO:!1,autoOAuthProvider:void 0,autoSAMLProvider:void 0,bearerToken:void 0,useSAML:void 0}),Promise.resolve({})):be().then(n=>{const{autoOAuthProvider:a,autoSAMLProvider:s}=d,i=!a&&!n.autoOAuthProvider&&!s&&!n.autoSAMLProvider;return p({...d,autoOAuthProvider:a||n.autoOAuthProvider,autoSAMLProvider:s||n.autoSAMLProvider,useCredentials:i,useSSO:i}),n}).catch(n=>{throw h("atomic:fetchAppPreLogin error",n),n})}async function Ot(e,t,r={}){const n=`api/v1/search.dataset/${e}/${t}`,a=await u(n,{parameters:r}),s=t[0].toLowerCase()+t.slice(1),i=a.datasets[s];if("errorCode"in i&&"errorMessage"in i)throw new Error(i.errorMessage);return i}async function $t(e,t){const r=`api/v1/search.dataset/${e}`,{parameters:n={},datasets:a=[]}=t;return(await u(r,{parameters:n,datasets:a})).datasets}async function At(e){return await S(`api/v1/search.dataset/${e}`)}async function It(e,t=!0,r){try{return(await u("api/v1/labels",{action:"list",q:e,public:t,locale:r,localize:!1})).labels}catch(n){throw h("Error in fetchLabels",n),n}}async function Dt(){try{const{app:e=""}=d,t=new URLSearchParams({app:e,action:"getUserRights"});return S("api/v1/labels",t)}catch(e){throw h("Error in getUserRights",e),e}}async function Ft(e,t,r=!0){try{const n={action:"add",labels:e,ids:t,public:r,$auditRecord:{auditEvents:[{type:v.Label_AddDoc,detail:{public:r,label:e?e.toString():null,doccount:t?t.length:0}}],mlAuditEvents:[{actionType:"addToLabel",documentIds:t}]}};return u("api/v1/labels",n)}catch(n){throw h("Error in add",n),n}}async function Nt(e,t,r=!0){try{const n={action:"remove",labels:e,ids:t,public:r,$auditRecord:{auditEvents:[{type:v.Label_RemoveDoc,detail:{public:r,label:e?e.toString():null,doccount:t?t.length:0}}],mlAuditEvents:[{actionType:"removeFromLabel",documentIds:t}]}};return u("api/v1/labels",n)}catch(n){throw h("Error in remove",n),n}}async function qt(e,t,r=!0){try{const n={action:"rename",labels:e,newLabel:t,public:r,auditEvents:{type:v.Label_Rename,detail:{public:r,oldlabel:e?e.toString():null,label:t}}};return u("api/v1/labels",n)}catch(n){throw h("Error in rename",n),n}}async function Bt(e,t=!0){try{const r={action:"delete",labels:e,public:t,auditEvents:{type:v.Label_Delete,detail:{public:t,label:e?e.toString():null}}};return u("api/v1/labels",r)}catch(r){throw h("Error in deleteLabels",r),r}}async function Qt(e,t,r=!0){try{const n={action:"bulkAdd",labels:e,query:t,public:r,auditEvents:{type:v.Label_Add,detail:{public:r,label:e?e.toString():null,query:t!==null?t.name:null}}};return u("api/v1/labels",n)}catch(n){throw h("Error in bulkAdd",n),n}}async function jt(e,t,r=!0){try{const n={action:"bulkRemove",labels:e,query:t,public:r,auditEvents:{type:v.Label_Delete,detail:{public:r,label:e?e.toString():null,query:t!==null?t.name:null}}};return u("api/v1/labels",n)}catch(n){throw h("Error in bulkRemove",n),n}}const Vt={getUserRights:Dt,add:Ft,remove:Nt,rename:qt,delete:Bt,bulkAdd:Qt,bulkRemove:jt};async function Gt(e,t){if(typeof window>"u")return u("api/v1/preview",{action:"get",id:e,query:t});const r=`${window.location.origin}${window.location.pathname}`,n={name:t?.name,text:t?.text};return u("api/v1/preview",{action:"get",id:e,query:n,browserUrl:r})}async function xt(e){const t=new Headers;t.append("content-type","text");const r=await fetch(e,{method:"GET",headers:t});y(r)}async function X(){const e=new URLSearchParams({action:"get",noAutoAuthentication:"true"});return S("api/v1/principal",e)}async function ve(e){const t={noAutoAuthentication:"true",...e},r=new URLSearchParams;return Object.entries(t).forEach(([n,a])=>{a!==void 0&&r.append(n,String(a))}),S("api/v1/principal/list",r)}async function Ce(e){if(!e)return Promise.reject(new Error("userid is required"));const t=new URLSearchParams({action:"userid",noAutoAuthentication:"true",userid:e});return S("api/v1/principal",t)}async function ye(e){if(e.length===0)return Promise.reject(new Error("userids is required"));const t=new URLSearchParams({noAutoAuthentication:"true",userids:[...e].join(",")});return S("api/v1/principal/userids",t)}const zt={principal:{get:X,list:ve,userid:Ce,userids:ye}},Pe=11;async function Mt(e,t,r){const a=await u("api/v1/query",{query:e,$auditRecord:t,queryIntentData:r});a.aggregations.forEach(i=>{i.$hasMore=!1,!i.isDistribution&&!i.isTree&&i.items&&(i.$hasMore=i.items.length===Pe),i.isTree&&i.items&&Q(i)}),a.records?.map(i=>Object.assign(i,{value:i.title,type:"default"}));const s={...a,nextPage:a.page<Math.ceil(a.rowCount/a.pageSize)?a.page+1:void 0,previousPage:a.page>1?a.page-1:void 0};return Promise.resolve(s)}async function Ht(e,t,r){const{app:n=""}=d,a={methods:[],mode:t,propagateErrors:!0,$auditRecord:{auditEvents:[r]}};for(const l of e)a.methods.push({method:"query",app:n,query:l});const s=await u("api/v1/multi",a);s.results.forEach(l=>{l.aggregations.forEach(c=>{c.$hasMore=!1,!c.isDistribution&&!c.isTree&&c.items&&(c.$hasMore=c.items.length===Pe),c.isTree&&Q(c)})}),s.results.forEach(l=>l.records?.map(c=>Object.assign(c,{value:c.title,type:"default"})));const i=s.results.map(l=>({...l,nextPage:l.page<Math.ceil(l.rowCount/l.pageSize)?l.page+1:void 0,previousPage:l.page>1?l.page-1:void 0}));return Promise.resolve(i)}function Q(e,t="",r=0){let n=[];return e.items&&e.items.forEach(a=>{let s=t?`${t}/${a.value}`:a.value,i=r+1;n.push({path:s,level:i}),a.$path=s,a.$level=i,a.hasChildren?n=n.concat(Q(a,s,i)):a.hasChildren=!1}),n}async function Jt({model:e,appName:t,query:r,article:n}){const{webservice:a,format:s,maxcount:i,exportedColumns:l,export:c}=e,f={app:t,webservice:a,query:r,type:c,format:s,maxcount:i,exportedColumns:l,$auditRecord:{auditEvents:[{type:"Search_ExportCSV",detail:{resultid:n?n.id:void 0}}]}};return O(f),await u("api/v1/search.queryexport",f,{responseType:"blob"})}async function Wt(e){return(await u("api/v1/queryintent",{query:e}))?.intents}async function Xt(e,t,r){return(await u("api/v1/similardocuments",{sourceDocumentId:e,query:{name:t}},{signal:r})).data}async function Yt(e,t){return(await u("api/v1/query.links",{webservice:e,query:t}))?.links?.map(a=>({...a,query:t}))}function Kt(e,t){if(typeof e=="number")return`${e}`;if(ge(e))return Zt(e);if(typeof e=="boolean")return e?"true":"false";if(e===null)return"null";if(Array.isArray(e)){const r=[];return e.forEach(n=>{r.length>0&&r.push(","),n?typeof n=="string"?r.push(n):r.push(n.display||n.value||""):r.push("null")}),r.splice(0,0,"["),r.push("]"),r.join("")}return e}function Zt(e){if(!e)return"";try{if(we(e)===0)return new Intl.DateTimeFormat("en-CA",{year:"numeric",month:"2-digit",day:"2-digit"}).format(e);{const t=new Intl.DateTimeFormat("en-CA").format(e),r=new Intl.DateTimeFormat("en-CA",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(e);return`${t} ${r}`}}catch{return"Invalid date"}}async function Et(e,t,r,n,a){const{app:s}=d,i={app:s||"",suggestQuery:e,text:t,filter:r,kinds:n,showSource:a};try{return(await u("api/v1/search.suggest",i)).suggests}catch(l){throw console.error("Error fetching suggestions:",l),l}}async function Tt(e,t,r,n){const{app:a}=d;return(await u("api/v1/suggestquery",{app:a||"",suggestQuery:e,text:t,query:r,kinds:n})).suggests}async function er(e,t,r){if(!t)return Promise.resolve([]);const{app:n}=d,s=await u("api/v1/suggestfield",{app:n||"",text:e,fields:t,query:r});return s.suggests.forEach(i=>{i.display=Kt(i.display)}),s.suggests}async function tr(e,t,r,n,a,s){return u("api/v1/doc.textchunks",{id:e,textChunks:t,highlights:r,query:n,leftSentencesCount:a,rightSentencesCount:s})}async function rr(){const{app:e}=d,t=new URLSearchParams({app:e||"",action:"load"});return S("api/v1/usersettings",t)}async function Re(e,t){const r={action:"save",userSettings:e,$auditRecord:{auditEvents:[t]}};return O(r),u("api/v1/usersettings",r)}async function nr(e,t){const n={action:"patch",userSettings:e,$auditRecord:t?{auditEvents:[t]}:void 0};return O(n),u("api/v1/usersettings",n)}async function ar(){return Re({},{type:"UserSettings_Reset"})}async function or(e,t){return u("api/v2/security/password/change",{newPassword:e,currentPassword:t})}async function sr(e){const t="api/v2/security/password/ask-reset-email",n={changePasswordRedirectUrl:`${window.location.origin}/login?mode=changepassword`,userName:e};return u(t,n)}async function ir(e){return await S(`api/v2/user-profile/${e}`)}async function cr(e){return await u("api/v2/user-profile",e)}async function lr(e,t,r){return await le(`api/v2/user-profile/${e.data?.id}/${t}/${r}`,e)}async function ur(e,t,r){try{return(await ce(`api/v2/user-profile/${e.data?.id}/${t}/${r}`)).success===!0}catch{return!1}}async function dr(){return await S("api/v2/version")}const Le=async()=>{const{autoOAuthProvider:e}=d;if(typeof window>"u")return u("security.oauth",{action:"getcode",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"});const t={action:"getcode",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const r=await u("api/v1/security.oauth",t);return r.redirectUrl&&(window.location.href=r.redirectUrl),r}catch(r){throw console.error("Failed to authenticate with OAuth",r),r}},Ue=async()=>{const{autoSAMLProvider:e}=d;if(typeof window>"u")return u("security.saml",{action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"});const t={action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const r=await u("api/v1/security.saml",t);return r.redirectUrl&&(window.location.href=r.redirectUrl),r}catch(r){throw console.error("Failed to authenticate with SAML",r),r}},Y={store:{},getItem(e){return this.store[e]??null},setItem(e,t){this.store[e]=t.toString()},removeItem(e){delete this.store[e]},clear(){this.store={}}},K=Y;function fr(e){return typeof window>"u"||!window.localStorage?Y.getItem(e):window.localStorage.getItem(e)}function hr(e){typeof window>"u"||!window.localStorage?Y.removeItem(e):window.localStorage.removeItem(e)}function gr(e){return typeof window>"u"||!window.sessionStorage?K.getItem(e):window.sessionStorage.getItem(e)}function mr(e,t){typeof window>"u"||!window.sessionStorage?K.setItem(e,t):window.sessionStorage.setItem(e,t)}function wr(e){typeof window>"u"||!window.sessionStorage?K.removeItem(e):window.sessionStorage.removeItem(e)}const I=e=>mr("sinequa-credentials",JSON.stringify({data:{csrfToken:e}})),Oe=async()=>{try{const e=await S("api/v1/challenge?action=getCsrfToken&suppressErrors=true");return e?.csrfToken?(I(e.csrfToken),e.csrfToken):null}catch(e){throw h("Failed to get CSRF token",e),e}};async function $e(e){if(e){const{username:t,password:r}=e,n={action:"get",tokenInCookie:!0,user:t,password:r,noUserOverride:!0,noAutoAuthentication:!0};try{const a=await u("api/v1/security.webtoken",n);return a?.csrfToken?(I(a.csrfToken),a.csrfToken):null}catch(a){throw console.error("Failed to get JWT",a),a}}else{const t={action:"get",tokenInCookie:!0,noUserOverride:!0,noAutoAuthentication:!1},{bearerToken:r}=d;if(!r)throw new Error("Bearer token is required in globalConfig for credentialless JWT retrieval.");const n=new Headers;n.append("Sinequa-Force-Camel-Case","true"),n.append("accept","application/json"),n.append("Content-Type","application/json"),n.append("Authorization",`Bearer ${r}`);try{const a=await u("api/v1/security.webtoken",t,{headers:n});return a.csrfToken?(I(a.csrfToken),a.csrfToken):null}catch(a){throw console.error("Failed to get JWT without credentials",a),a}}}const j=()=>{const e=gr("sinequa-credentials");if(e)try{const n=JSON.parse(e).data?.csrfToken;if(n!==void 0)return n}catch{}const t=fr("csrfToken");return t!==null?t:null},Sr=async e=>{if(e)k("Attempting authentication using credentials"),p({useCredentials:!0,useSSO:!1});else{let l=null;try{k("Attempting to retrieve CSRF token from the backend"),l=await Oe(),R("CSRF token retrieval result",l?"success":"failed")}catch(c){h("Failed to retrieve CSRF token",c)}try{if(l===null){const{autoOAuthProvider:c,autoSAMLProvider:f,useSAML:b}=d;if(c&&!b)return k("Initiating OAuth authentication flow"),await Le(),U("OAuth authentication flow did not redirect as expected"),m(!1),!1;if(f)return k("Initiating SAML authentication flow"),await Ue(),U("SAML authentication flow did not redirect as expected"),m(!1),!1;k("No direct authentication method available, will try SSO then credentials"),p({useCredentials:!0,useSSO:!0})}else return k("User authenticated via existing token"),m(!0),!0}catch(c){throw h("Unexpected error during authentication",c),m(!1),c}}if(d.useCredentials&&d.useSSO)try{if(k("Checking if user is authenticated via SSO"),await X())return k("User authenticated using SSO"),p({useCredentials:!1,useSSO:!0}),m(!0),!0}catch(l){if(l?.status===401)return k("SSO authentication failed with 401, falling back to credentials"),p({useCredentials:!0,useSSO:!1}),!1;throw h("SSO authentication failed with unexpected error",l),m(!1),h}const{useSSO:r}=d,n=j();if(n&&n!==null||r)return k("user already authenticated",n),p({isRedirectUrl:!1}),m(!0),!0;const{useCredentials:a}=d,{username:s,password:i}=e||{};if(a&&!s&&!i)return h("Credentials are required for authentication"),m(!1),!1;if(s&&i)try{k("authentication using credentials..."),p({useCredentials:!0,useSSO:!1});const{userOverrideActive:l,useroverride:c}=d;return p({userOverrideActive:!1,useroverride:void 0}),await $e({username:s,password:i}),p({userOverrideActive:l,useroverride:c}),m(!0),!0}catch(l){throw m(!1),l}return m(!1),h("No authentication method available. Please provide credentials or configure OAuth/SAML."),!1},Ae=async()=>{const e=new URLSearchParams({action:"deleteWebTokenCookie",noUserOverride:"true",noAutoAuthentication:"true"});return S("api/v1/challenge",e)},_r=async()=>{const{useCredentials:e,userOverrideActive:t}=d;hr("csrfToken"),wr("sinequa-credentials"),e&&!t?(await Ae()).methodresult==="ok"?m(!1):console.error("logout failed"):m(!1)},pr=()=>!!j();o.API=zt,o.ApiError=C,o.Audit=Pt,o.AuditEventType=v,o.DidYouMeanKind=ue,o.EngineType=g,o.EngineTypeModifier=_,o.LogLevel=z,o.MINIMUM_COMPATIBLE_SERVER_API_VERSION=dt,o.RFMDisplay=de,o.ServerError=V,o.TimeoutError=Z,o.UnauthorizedError=D,o.addAuditAdditionalInfo=O,o.addConcepts=xe,o.addSessionId=pe,o.addUrl=ke,o.aggItemRegex=E,o.aggregationItemStrictCompare=De,o.appInitializerFn=Ut,o.bisect=Ne,o.buildPathsAndLevels=Q,o.configureLogger=at,o.createHeaders=L,o.createTimeoutController=st,o.createUserProfile=cr,o.debug=R,o.del=ce,o.deleteUserProfileProperty=ur,o.deleteUserSettings=ar,o.deleteWebTokenCookie=Ae,o.emitAuthenticatedEvent=m,o.error=h,o.escapeExpr=pt,o.expiresSoon=ct,o.extraColumns=mt,o.fetchAggregation=Rt,o.fetchApp=Lt,o.fetchAppPreLogin=be,o.fetchBulkQuery=Ht,o.fetchChangePassword=or,o.fetchDataset=Ot,o.fetchDatasetList=At,o.fetchDatasets=$t,o.fetchLabels=It,o.fetchPreview=Gt,o.fetchPreviewUrl=xt,o.fetchPrincipal=X,o.fetchPrincipalList=ve,o.fetchPrincipalUserid=Ce,o.fetchPrincipalUserids=ye,o.fetchQuery=Mt,o.fetchQueryExport=Jt,o.fetchQueryIntent=Wt,o.fetchSendPasswordResetEmail=sr,o.fetchSimilarDocuments=Xt,o.fetchSponsoredLinks=Yt,o.fetchSuggest=Et,o.fetchSuggestField=er,o.fetchSuggestQuery=Tt,o.fetchTextChunks=tr,o.fetchUserProfile=ir,o.fetchUserSettings=rr,o.fetchVersion=dr,o.get=S,o.getConcepts=He,o.getCsrfToken=Oe,o.getFiltersFromURI=G,o.getFiltersFromUrl=Ke,o.getHelpIndexUrl=rt,o.getIdFromUrl=Ee,o.getJWToken=$e,o.getMetadata=wt,o.getMetadataWithValues=St,o.getOffsetFromDates=ie,o.getQueryPageFromUrl=Te,o.getQueryParamsFromUrl=Xe,o.getQueryTabFromUrl=et,o.getQueryTextFromUrl=Ze,o.getRelativeDate=Je,o.getTime=we,o.getToken=j,o.getUrlParamsFromQueryParams=Ye,o.globalConfig=d,o.guid=Se,o.handleResponse=y,o.info=k,o.isArrayBuffer=fe,o.isAuthenticated=pr,o.isBlob=he,o.isDate=ge,o.isExpired=it,o.isJsonable=_t,o.isNotInputEvent=We,o.isObject=A,o.isString=me,o.labels=Vt,o.login=Sr,o.logout=_r,o.makeColumn=w,o.notify=nt,o.openParentNodes=ee,o.parseText=$,o.parseValueAndOperatorFromItem=T,o.patch=le,o.patchUserProfile=lr,o.patchUserSettings=nr,o.post=u,o.put=ot,o.queryParamsFromUrl=P,o.removeConcept=ze,o.removeConcepts=Me,o.resolveToColumnName=ut,o.rewriteText=F,o.saveUserSettings=Re,o.setGlobalConfig=p,o.setToken=I,o.sha512=kt,o.suggestionsToTreeAggregationNodes=Fe,o.sysLang=tt,o.toDate=H,o.translateAggregationToDateOptions=Ie,o.tryOAuthAuthentication=Le,o.trySAMLAuthentication=Ue,o.warn=U,o.withRetry=lt,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(o,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(o=typeof globalThis<"u"?globalThis:o||self,g(o.atomic={}))})(this,(function(o){"use strict";function g(e){if(typeof CustomEvent>"u"||typeof dispatchEvent>"u")return;const t=new CustomEvent("authenticated",{bubbles:!0,cancelable:!1,detail:{authenticated:e}});dispatchEvent(t)}const d={loginPath:"/login",createRoutes:!1};function p(e){Object.assign(d,e)}const T=/.*\:\(?([><=\d\-\.AND ]+)\)?/;function Fe(e,t){return!e?.items||e?.items?.length===0?[]:e.items.reduce((a,s)=>{if(!s.value||s.value==="")return a;const i=ee(s,e.column);return a.push({operator:i.operator,value:i.value,display:s.display||i.display,filters:i.filters,disabled:s.count===0,hidden:s.count===0&&e.isDistribution?!t:!1}),a},[])}function ee(e,t){const r=t,n=e.value.match(T);if(n?.[1]){const s=(n?.[1].split(" AND ")).map(i=>{const c=i.indexOf(">=")!==-1?"gte":"lt";let l=i.substring(i.indexOf(" ")+1);return{field:r,operator:c,value:l,display:e.display||e.value}});if(s.length===2)return{field:r,operator:"and",filters:s,value:e.value,display:s[0].display||s[0].value};if(s.length===1)return{...s[0],field:r};throw new Error("Failed to parse distribution expression")}return{field:r,operator:"eq",value:e.value,display:e.display}}function Ne(e,t,r){return e.valuesAreExpressions?t.display===r.display:t.value===r.value}function te(e){return e.items&&(e.items=e.items.map(t=>te(t))),e.items&&e.items.some(t=>t.$selected||t.$opened)&&(e.$opened=!0),e}function qe(e,t){const r=[];if(e.length>0){const n=new Map,s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g,""),i=new RegExp("\\b"+s,"i");e.forEach(c=>{if(c.display.length>1){const l=c.display.normalize("NFD").replace(/[\u0300-\u036f]/g,""),h=i.exec(l);re(r,n,"/",c.display,+(c.frequency||0),1,(h?.index||0)+t.length)}})}return r}function re(e,t,r,n,a,s,i){const c=n.indexOf("/",r.length),l=n.substring(0,c+1);let h=t.get(l);if(!h){const b=l.replace(/^\/|\/$/g,"");h={value:n.substring(r.length,c),count:a,items:[],hasChildren:!1,$level:s,$opened:i>=l.length,$path:b},t.set(l,h),e.push(h)}l.length<n.length&&(h.hasChildren=!0,re(h.items,t,l,n,a,s+1,i))}function Be(e,t){return e.reduce((r,n)=>(t(n)?r.true.push(n):r.false.push(n),r),{true:[],false:[]})}const Qe=/(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g,je=2,ne=3,Ve=5,ae=6,xe=8,oe=9,Ge=11,se=12,Me=14,ie=15;function I(e){if(!e)return[];const t=[],r=e.matchAll(Qe);for(let n of r)n[ne]?t.push({type:"group",value:n[ne],op:n[je]}):n[ae]?t.push({type:"adjacent",value:n[ae],op:n[Ve]}):n[oe]?t.push({type:"exact",value:n[oe],op:n[xe]}):n[se]?t.push({type:"regex",value:n[se],op:n[Ge]}):n[ie]&&t.push({type:"token",value:n[ie],op:n[Me]});return t}function N(e){return e.map(t=>{const r=t.op||"";switch(t.type){case"group":return`${r}(${t.value})`;case"adjacent":return`${r}[${t.value}]`;case"exact":return`${r}"${t.value}"`;case"regex":return`${r}/${t.value}/`;case"token":return`${r}${t.value}`}}).join(" ")}function ze(e,t,r){let n=I(e);for(let a of t)n.push({type:"adjacent",value:a,op:r});return N(n)}function He(e,t){const r=I(t),n=r.findIndex(a=>a.value===e);return n!==-1?(r.splice(n,1),t=N(r)):t}function Je(e){const t=I(e).filter(r=>r.type!=="adjacent");return N(t)}function We(e){return I(e).filter(t=>t.type==="adjacent").map(t=>t.value)}function Xe(e,t,r){const n=new Intl.RelativeTimeFormat(e,{numeric:"auto"}),{offset:a,unit:s,isFuture:i}=ce(t,r);return n.format(a*(i?1:-1),s)}function ce(e,t){const r=new Date(e),n=t?new Date(t):new Date,a=Math.abs(n.getTime()-r.getTime());return{offset:Math.floor(a/(1e3*60*60*24)),unit:"day",isFuture:r>n}}function Ye(e){const t=e.target;return t&&t.nodeName!=="INPUT"&&t.nodeName!=="TEXTAREA"}function Ke(e){if(e===void 0)return;const{q:t,f:r,p:n,s:a,t:s,n:i,b:c}=L(e),[l]=e.split("?");return{path:l,text:t,filters:r?G(r):void 0,page:n?parseInt(n,10):void 0,sort:a,tab:s,name:i,basket:c}}function Ze(e){if(!e)return"";const{text:t,filters:r,page:n,sort:a,tab:s,name:i,basket:c}=e,l={};t&&(l.q=t),r&&(l.f=JSON.stringify(r)),n&&(l.p=n.toString()),a&&(l.s=a),s&&(l.t=s),i&&(l.n=i),c&&(l.b=c);const h=new URLSearchParams(l).toString();return h||""}function Ee(e){if(e===void 0)return[];const{f:t}=L(e);return G(t)}function G(e){const t=decodeURIComponent(e);try{return JSON.parse(t??"[]")}catch{return console.error(`Error parsing filters from URI: ${e}`),[]}}function L(e){const t=e.split("?")[1];if(t===void 0)return{};const r=new URLSearchParams(t);return Object.fromEntries(r)}function Te(e){const{q:t=""}=L(e);return t}function et(e){const{id:t}=L(e);return decodeURIComponent(t)}function tt(e){const{p:t="0"}=L(e);return parseInt(t,10)}function rt(e){const{t}=L(e);return t}function nt(e,t){if(!e)return e;let r=0;const n=e.length;let a=0;if(e[a]==="["){for(;a<n&&/[0-9]/.test(e[a]);)a++;e[a]==="]"&&(r=a+1)}const s=M(e,r,!1);if(!s)return e;const i=t.charCodeAt(0),c=t.charCodeAt(1);let l=s;for(;l;)if(i===l.lang1&&c===l.lang2){const b=M(e,l.end+4,!0);return e.substring(b.start,b.end)}else l=M(e,l.end+4,!1);const h=e.substring(s.start,s.end);return h||e}function M(e,t,r){for(let n=t,a=e.length-3;n<a;n++)if(e[n]==="["&&e[n+3]==="]")return{start:t,end:n,lang1:e.charCodeAt(n+1),lang2:e.charCodeAt(n+2)};if(r)return{start:t,end:e.length,lang1:-1,lang2:-1}}function at(e,t){const{useLocale:r,useLocaleAsPrefix:n,indexFile:a,path:s,folder:i}=t,c=r?`${e}/`:null,l=n?`${e}.${a}`:a??"";return[s,i,`${c||""}${l}`].filter(h=>h!==void 0).join("/")}function q(e){const t=new CustomEvent("notification",{bubbles:!0,cancelable:!1,detail:e});dispatchEvent(t)}const ot={success:(e,t)=>{q({type:"success",message:e,options:t})},info:(e,t)=>{q({type:"info",message:e,options:t})},warning:(e,t)=>{q({type:"warning",message:e,options:t})},error:(e,t)=>{q({type:"error",message:e,options:t})}};var z=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE",e))(z||{});let B={level:1,enableConsoleOutput:!0};function st(e){B={...B,...e}}function Q(e,t,r){if(e<B.level)return;const a=`${`[${z[e]}]`} ${t}`;if(B.enableConsoleOutput)switch(e){case 0:console.debug(a,r||"");break;case 1:console.info(a,r||"");break;case 2:console.warn(a,r||"");break;case 3:console.error(a,r||"");break}}function U(e,t){Q(0,e,t)}function k(e,t){Q(1,e,t)}function O(e,t){Q(2,e,t)}function f(e,t){Q(3,e,t)}function $(e){const t=x(),r=new Headers(e);r.append("Sinequa-Force-Camel-Case","true"),r.append("accept","application/json"),t&&r.append("Sinequa-csrf-token",t);const{userOverride:n,userOverrideActive:a,bearerToken:s}=d;return s&&r.append("Authorization",`Bearer ${s}`),n&&a&&(r.append("sinequa-override-user",n.username),r.append("sinequa-override-domain",n.domain)),r}class P extends Error{status;constructor(t,r){super(t),this.name="ApiError",this.status=r}}class H extends P{constructor(t="Server error"){super(t,500),this.name="ServerError"}}class le extends P{constructor(t="Request timed out"){super(t,408),this.name="TimeoutError"}}class j extends P{constructor(t="Unauthorized access"){super(t,401),this.name="UnauthorizedError"}}async function y(e,t="json"){const r=e.headers.get("sinequa-jwt-refresh");if(r!==null&&F(r),e.status===200)switch(t){case"arraybuffer":return await e.arrayBuffer();case"blob":return await e.blob();case"text":return await e.text();default:return await e.json()}if(e.status===401){if(d.userOverrideActive)throw O("Unauthorized access attempt with user override",{endpoint:e.url}),new j("Unauthorized... User override failed.");return await J(e,401)}return e.status===500?(f("Server error occurred",{endpoint:e.url}),await J(e,500)):(O(`Unexpected response status: ${e.status}`,{endpoint:e.url}),await J(e,e.status))}async function J(e,t){try{const{done:r,value:n}=await e.body?.getReader().read()||{done:!0,value:void 0};if(r||!n)throw t===401?new j:t===500?new H:new P(`Request failed with status ${t}`,t);const a=JSON.parse(new TextDecoder().decode(n));throw new Error(a.errorMessage||a.message||`Request failed with status ${t}`,{cause:{errorCode:a.errorCode,errorCodeTest:a.errorCodeTest}})}catch(r){throw r instanceof P?r:t===401?new j(r.message):t===500?new H(r.message):new P(r.message??`Request failed with status ${t}`,t)}}async function ue(e,t,r){const n=$(r?.headers),{backendUrl:a}=d,s=t?`?${new URLSearchParams(t)}`:"",i=a?`${a}/${e}${s}`:`${e}${s}`;U(`Making DELETE request to: ${i}`);try{const c=await fetch(i,{method:"DELETE",credentials:"include",headers:n});return y(c,r?.responseType)}catch(c){throw f("Error making DELETE request:",c),c}}async function _(e,t,r){const n=$(r?.headers),{backendUrl:a}=d,s=t?`?${new URLSearchParams(t)}`:"";e.startsWith("plugin")&&(e=`api/v1/${e}`);const i=a?`${a}/${e}${s}`:`${e}${s}`;U(`Making GET request to: ${i}`);try{const c=await fetch(i,{method:"GET",credentials:"include",headers:n,signal:r?.signal});return y(c,r?.responseType)}catch(c){throw f("Error making GET request:",c),c}}async function de(e,t,r){const n=$(r?.headers);n.append("content-type","application/json");const{app:a,backendUrl:s}=d,i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},c=s?`${s}/${e}`:`${e}`;U(`Making PATCH request to: ${c}`);try{const l=await fetch(c,{method:"PATCH",headers:n,credentials:"include",body:JSON.stringify(i)});return y(l,r?.responseType)}catch(l){throw f("Error making PATCH request:",l),l}}async function u(e,t,r){const n=$(r?.headers),{app:a,backendUrl:s}=d;n.has("Content-Type")||n.set("Content-Type","application/json");const i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0};e.startsWith("plugin")&&(e=`api/v1/${e}`);const c=s?`${s}/${e}`:`${e}`;U(`Making POST request to: ${c}`);try{const l=await fetch(c,{method:"POST",headers:n,credentials:"include",body:JSON.stringify(i),signal:r?.signal});return y(l,r?.responseType)}catch(l){throw f("Error making POST request:",l),l}}async function it(e,t,r){const n=$(r?.headers),{app:a,backendUrl:s}=d,i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},c=`${s}/${e}`;U(`Making PUT request to: ${c}`);try{const l=await fetch(c,{method:"PUT",headers:n,credentials:"include",body:JSON.stringify(i)});return y(l,r?.responseType)}catch(l){throw f("Error making PUT request:",l),l}}function v(e){const t=new AbortController,{signal:r}=t;return e&&setTimeout(()=>{r.aborted||t.abort(new le(`Request timed out after ${e}ms`))},e),{controller:t,signal:r}}function W(e){if(!e)return;const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t}function ct(e){const t=W(e);return!!t&&t.getTime()<=Date.now()}function lt(e,t=7){const r=W(e);if(!r)return!1;const n=Date.now(),a=n+t*24*60*60*1e3,s=r.getTime();return s>n&&s<=a}async function ut(e,t=0,r=1e3){let n;for(let a=0;a<=t;a++)try{return await e()}catch(s){if(n=s,s instanceof P&&s.status>=400&&s.status<500&&s.status!==429||s instanceof DOMException&&s.name==="AbortError")throw s;a<t&&(O(`Retrying request (${a+1}/${t})`,{error:s}),await new Promise(i=>setTimeout(i,r)))}throw n}function dt(e,t,r){if(!e||!t)return;if(r){const s=Object.keys(t.queries).find(l=>l===r?.toLowerCase());let i;s&&(i=t.queries[s]);const c=(i?.columnsInfo?.columns||[])?.find(l=>l.aliases?.split(",")?.includes(e));if(c)return c.name}const n=t.indexes?._?.columns,a=Object.entries(n).find(s=>s[1].aliases?.includes(e));if(a)return a[0]}var C=(e=>(e.None="None",e.Search_FirstPage="Search_FirstPage",e.Search_Text="Search_Text",e.Search_Refine="Search_Refine",e.Search_Select_Item="Search_Select_Item",e.Search_Select_Custom="Search_Select_Custom",e.Search_Select_Concept="Search_Select_Concept",e.Search_Select_Correction="Search_Select_Correction",e.Search_GotoPage="Search_GotoPage",e.Search_GotoTab="Search_GotoTab",e.Search_DisplayResult="Search_DisplayResult",e.Search_RemoveResult="Search_RemoveResult",e.Search_RemoveAdvanced="Search_RemoveAdvanced",e.Search_SavedQuery="Search_SavedQuery",e.Search_WebService="Search_WebService",e.Search_DidYouMean_Original="Search_DidYouMean_Original",e.Search_DidYouMean_Correction="Search_DidYouMean_Correction",e.Search_ExportCSV="Search_ExportCSV",e.Search_SavedQuery_ExportCSV="Search_SavedQuery_ExportCSV",e.Search_Selection_ExportCSV="Search_Selection_ExportCSV",e.Search_AlertQuery="Search_AlertQuery",e.Search_Select_AnalyticsItem="Search_Select_AnalyticsItem",e.Search_Sort="Search_Sort",e.Search_Exit_Logout="Search_Exit_Logout",e.Search_Timeline_Usage="Search_Timeline_Usage",e.Search_AutoComplete="Search_Autocomplete",e.Search_Login_Success="Login_Success_Form",e.Search_QueryIntent_Detected="Search_QueryIntent_Detected",e.SavedQuery_Add="SavedQuery_Add",e.SavedQuery_Delete="SavedQuery_Delete",e.SavedQuery_DeleteAll="SavedQuery_DeleteAll",e.SavedQuery_Rename="SavedQuery_Rename",e.Alert_Edit="Alert_Edit",e.Alert_Delete="Alert_Delete",e.Alert_DeleteAll="Alert_DeleteAll",e.Link_Display="Link_Display",e.Link_Click="Link_Click",e.Basket_Add="Basket_Add",e.Basket_Delete="Basket_Delete",e.Basket_DeleteAll="Basket_DeleteAll",e.Basket_Rename="Basket_Rename",e.Basket_AddDoc="Basket_AddDoc",e.Basket_RemoveDoc="Basket_RemoveDoc",e.Basket_Open="Basket_Open",e.Basket_ExportCSV="Basket_ExportCSV",e.Label_Add="Label_Add",e.Label_Delete="Label_Delete",e.Label_Rename="Label_Rename",e.Label_Open="Label_Open",e.Label_AddDoc="Label_AddDoc",e.Label_RemoveDoc="Label_RemoveDoc",e.Label_ExportCSV="Label_ExportCSV",e.Label_Menu_ExportCSV="Label_Menu_ExportCSV",e.Rating_Set="Rating_Set",e.Rating_Delete="Rating_Delete",e.Doc_Preview="Doc_Preview",e.Doc_CacheHtml="Doc_CacheHtml",e.Doc_CachePdf="Doc_CachePdf",e.Doc_CacheOriginal="Doc_CacheOriginal",e.Doc_Url1="Doc_Url1",e.Doc_Url2="Doc_Url2",e.Preview_Close="Preview_Close",e.Click_ResultLink="Click_ResultLink",e.Click_ResultLink1="Click_ResultLink1",e.Click_ResultLink2="Click_ResultLink2",e.Click_ResultLink3="Click_ResultLink3",e.Click_ResultLink4="Click_ResultLink4",e.Click_ResultLink5="Click_ResultLink5",e.Click_ResultLink6="Click_ResultLink6",e.Click_ResultLink7="Click_ResultLink7",e.Click_ResultLink8="Click_ResultLink8",e.Click_ResultLink9="Click_ResultLink9",e.Click_ResultLink10="Click_ResultLink10",e.Click_PreviewLink1="Click_PreviewLink1",e.Click_PreviewLink2="Click_PreviewLink2",e.Click_PreviewLink3="Click_PreviewLink3",e.Click_PreviewLink4="Click_PreviewLink4",e.Click_PreviewLink5="Click_PreviewLink5",e.Click_PreviewLink6="Click_PreviewLink6",e.Click_PreviewLink7="Click_PreviewLink7",e.Click_PreviewLink8="Click_PreviewLink8",e.Click_PreviewLink9="Click_PreviewLink9",e.Click_PreviewLink10="Click_PreviewLink10",e.RFM_ClickSet="RFM_ClickSet",e.RFM_ClickReset="RFM_ClickReset",e.RFM_Like="RFM_Like",e.RFM_LikeReset="RFM_LikeReset",e.RFM_Dislike="RFM_Dislike",e.RFM_Important="RFM_Important",e.RFM_ImportantReset="RFM_ImportantReset",e.RFM_Ban="RFM_Ban",e.Navigation_Exit="Navigation_Exit",e.Navigation_Return="Navigation_Return",e.Navigation_Route="Navigation_Route",e.Answer_Display="Answer_Display",e.Answer_Click="Answer_Click",e.Answer_Result="Answer_Result",e.Answer_Liked="Answer_Liked",e.Answer_Disliked="Answer_Disliked",e.Answer_Liked_Cancelled="Answer_Liked_Cancelled",e.Answer_Disliked_Cancelled="Answer_Disliked_Cancelled",e.TopPassages_Display="TopPassages_Display",e.TopPassages_Click="TopPassages_Click",e.UserSettings_Reset="UserSettings_Reset",e.Change_Password_Failed="change.password.failed",e.Change_Password_Success_Form="change.password.success.form",e.Forgot_Password_Request="forgot.password.request",e.Login_Denied="login.denied",e.Login_Success_Form="login.success.form",e.Send_Reset_Password_Link="send.reset.password.link",e.Xrest_ChangePassword="xrest.changepassword",e))(C||{}),m=(e=>(e[e.none=0]="none",e[e.bool=1]="bool",e[e.date=2]="date",e[e.dateTime=3]="dateTime",e[e.time=4]="time",e[e.unsigned=5]="unsigned",e[e.integer=6]="integer",e[e.float=7]="float",e[e.double=8]="double",e[e.dates=9]="dates",e[e.dateTimes=10]="dateTimes",e[e.times=11]="times",e[e.varchar=12]="varchar",e[e.binary=13]="binary",e[e.string=14]="string",e[e.csv=15]="csv",e))(m||{}),S=(e=>(e[e.none=0]="none",e[e.a=2053]="a",e[e.c=4]="c",e[e.d=8]="d",e[e.e=2068]="e",e[e.i=256]="i",e[e.l=2052]="l",e[e.n=8192]="n",e[e.t=524292]="t",e[e.x=8388608]="x",e[e.z=33554432]="z",e[e.f_ordinal=8192]="f_ordinal",e[e.f_multidates=8192]="f_multidates",e[e.f_varchar=33554432]="f_varchar",e[e.f_binary=33562624]="f_binary",e[e.f_string=33562888]="f_string",e[e.f_csv=42477853]="f_csv",e[e.f_overridable=33554696]="f_overridable",e))(S||{});const ft="1.0";var fe=(e=>(e[e.Original=0]="Original",e[e.Corrected=1]="Corrected",e))(fe||{}),he=(e=>(e[e.none=0]="none",e[e.positiveRate=1]="positiveRate",e[e.mainlyPosRate=2]="mainlyPosRate",e[e.unrate=4]="unrate",e[e.mainlyNegRate=8]="mainlyNegRate",e[e.negativeRate=16]="negativeRate",e[e.all=31]="all",e[e.positiveOnly=7]="positiveOnly",e[e.negativeOnly=28]="negativeOnly",e[e.personalAll=21]="personalAll",e[e.personalPosOnly=5]="personalPosOnly",e[e.personalNegOnly=20]="personalNegOnly",e))(he||{});function ht(e){if(!e)return m.none;switch(e.toLocaleLowerCase()){case"bool":case"boolean":return m.bool;case"date":return m.date;case"datetime":return m.dateTime;case"time":return m.time;case"unsigned":return m.unsigned;case"integer":return m.integer;case"float":return m.float;case"double":return m.double;case"dates":return m.dates;case"datetimes":return m.dateTimes;case"times":return m.times;case"varchar":return m.varchar;case"binary":return m.binary;case"string":return m.string;case"csv":return m.csv;default:return m.none}}function gt(e){switch(e){case"a":return S.a;case"c":return S.c;case"d":return S.d;case"e":return S.e;case"i":return S.i;case"l":return S.l;case"n":return S.n;case"t":return S.t;case"x":return S.x;case"z":return S.z;default:return S.none}}function mt(e){let t=S.none;if(e)for(const r of e)t|=gt(r);return t}function w(e,t,r,n){const a=ht(t),s=mt(r||"");return{name:e,type:t,typeModifier:r,eType:a,eTypeModifier:s,aliases:n}}const wt={id:w("id","string"),text:w("text","varchar"),documentlanguages:w("documentlanguages","csv","ci",["language"]),databasealias:w("databasealias","varchar"),globalrelevance:w("globalrelevance","double"),matchingpartnames:w("matchingpartnames","csv"),matchlocations:w("matchlocations","csv"),matchlocationsperpartname:w("matchlocationsperpartname","varchar"),extracts:w("extracts","csv"),extractsperpartname:w("extractsperpartname","varchar"),extractslocations:w("extractslocations","csv"),documentweight:w("documentweight","varchar"),groupcount:w("groupcount","integer"),accesslists:w("accesslists","varchar",void 0,["accessLists"])};function _t(e,t){let r=e[t];return r===void 0?[]:(typeof r=="string"&&(r=String(r).split(",")),Array.isArray(r)?r.map(n=>{if(typeof n=="string")return n.trim();if(typeof n=="object"&&n!==null&&"display"in n)return n.display.trim()}).filter(n=>n!==void 0):[String(r).trim()])}function St(e,t){let r=e[t];if(r===void 0)return[];if(typeof r=="string"&&(r=String(r).split(",")),Array.isArray(r))return r.map(a=>{if(typeof a=="string")return{display:a.trim(),value:a.trim()};if(typeof a=="object"&&a!==null&&"display"in a){const s=a.display.trim(),i="value"in a?String(a.value).trim():s;return{display:s,value:i}}}).filter(a=>a!==void 0);const n=String(r).trim();return[{display:n,value:n}]}function D(e){return e!==null&&typeof e=="object"}function ge(e){return D(e)&&Object.prototype.toString.call(e)==="[object ArrayBuffer]"}function me(e){return D(e)&&Object.prototype.toString.call(e)==="[object Blob]"}function we(e){return Object.prototype.toString.call(e)==="[object Date]"}function _e(e){return typeof e=="string"}function pt(e){return(D(e)||Array.isArray(e))&&!ge(e)&&!me(e)&&!_e(e)}function Se(e){return e?(e.getHours()*60*60+e.getMinutes()*60+e.getSeconds())*1e3+e.getMilliseconds():0}function pe(e=!0){let t=Date.now();return(e?"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx":"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g,n=>{const a=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(n==="x"?a:a&3|8).toString(16)})}function kt(e){if(!e)return"``";if(e=String(e),e.search(/[\\`]/)===-1)return`\`${e}\``;const t=["`"];for(let r=0,n=e.length;r<n;r++){const a=e[r];(a==="\\"||a==="`")&&t.push("\\"),t.push(a)}return t.push("`"),t.join("")}function bt(e){if(typeof crypto<"u"&&crypto.subtle&&typeof crypto.subtle.digest=="function")try{return crypto.subtle.digest("SHA-512",new TextEncoder().encode(e)).then(t=>Array.prototype.map.call(new Uint8Array(t),r=>`00${r.toString(16)}`.slice(-2)).join("")).catch(()=>Promise.resolve(X(e)))}catch{return Promise.resolve(X(e))}return Promise.resolve(X(e))}function X(e){let n=2166136261;for(let b=0;b<e.length;b++)n^=e.charCodeAt(b),n=n*16777619>>>0;const a=n.toString(16).padStart(8,"0"),s=((n^2863311530)>>>0).toString(16).padStart(8,"0"),i=((n^1431655765)>>>0).toString(16).padStart(8,"0"),c=((n^3435973836)>>>0).toString(16).padStart(8,"0"),l=a+s+i+c;return(l+l+l+l).substring(0,128)}let Y,ke;function A(e,t=!0){let r=vt(e.$auditRecord);r&&(be(r),t&&ve(r)),e.$auditRecord=r}function vt(e){if(!e)return;let t;if(Array.isArray(e))t=e;else if(D(e)){const r=e;if(r.auditEvents||r.mlAuditEvents)return r;t=[e]}return{auditEvents:t}}function be(e){const t=Ct();return e.auditEvents?.forEach(r=>{r.detail||(r.detail={}),r.detail.sessionid=t}),e}function ve(e){const t=typeof window<"u"?decodeURIComponent(window.location.href):"http://localhost";return e?.auditEvents?.forEach(r=>{r.detail||(r.detail={}),r.detail.url=t}),e}function Ct(){return(!Y||Pt())&&(Y=pe()),ke=new Date,Y}function Pt(){return new Date().getTime()-ke.getTime()>600*1e3}async function yt(e,t=!0){const r={event:C.None,$auditRecord:e};return A(r,t),u("api/v1/audit.notify",r)}const Rt={notify:yt};async function Lt(e,t,r){const n=e.items?.length||0,a=10,s={query:{...t,action:"aggregate",aggregations:{[e.name]:{skip:n,count:a}}},$auditRecord:{auditEvents:[r]}};A(s);const i=await u("api/v1/query",s),c=await y(i),{aggregations:l}=c,h=l[0];return h.$hasMore=h.items.length>a,h.items=[...e.items,...h.items],Promise.resolve(h)}async function Ut(e){const t=e||d.app,r=new URLSearchParams({app:t||""});return _("api/v1/app",r)}async function Ce(){const{app:e}=d,t=new URLSearchParams({app:e||"",preLogin:"true"});return _("api/v1/app",t)}function Ot(){let{backendUrl:e,app:t,useCredentials:r}=d;if(typeof window<"u"){if(e||(e=window.location.origin),!t){const n=window.location.pathname.match(/\/app(?:-debug)?\/([^/#]+)/);n&&(t=n[1])}p({...d,backendUrl:e,app:t})}return r?(p({...d,useCredentials:!0,useSSO:!1,autoOAuthProvider:void 0,autoSAMLProvider:void 0,bearerToken:void 0,useSAML:void 0}),Promise.resolve({})):Ce().then(n=>{const{autoOAuthProvider:a,autoSAMLProvider:s}=d,i=!a&&!n.autoOAuthProvider&&!s&&!n.autoSAMLProvider;return p({...d,autoOAuthProvider:a||n.autoOAuthProvider,autoSAMLProvider:s||n.autoSAMLProvider,useCredentials:i,useSSO:i}),n}).catch(n=>{throw f("atomic:fetchAppPreLogin error",n),n})}async function $t(e,t,r={}){const n=`api/v1/search.dataset/${e}/${t}`,a=await u(n,{parameters:r}),s=t[0].toLowerCase()+t.slice(1),i=a.datasets[s];if("errorCode"in i&&"errorMessage"in i)throw new Error(i.errorMessage);return i}async function At(e,t){const r=`api/v1/search.dataset/${e}`,{parameters:n={},datasets:a=[]}=t;return(await u(r,{parameters:n,datasets:a})).datasets}async function It(e){return await _(`api/v1/search.dataset/${e}`)}async function Dt(e,t=!0,r){try{return(await u("api/v1/labels",{action:"list",q:e,public:t,locale:r,localize:!1})).labels}catch(n){throw f("Error in fetchLabels",n),n}}async function Ft(){try{const{app:e=""}=d,t=new URLSearchParams({app:e,action:"getUserRights"});return _("api/v1/labels",t)}catch(e){throw f("Error in getUserRights",e),e}}async function Nt(e,t,r=!0){try{const n={action:"add",labels:e,ids:t,public:r,$auditRecord:{auditEvents:[{type:C.Label_AddDoc,detail:{public:r,label:e?e.toString():null,doccount:t?t.length:0}}],mlAuditEvents:[{actionType:"addToLabel",documentIds:t}]}};return u("api/v1/labels",n)}catch(n){throw f("Error in add",n),n}}async function qt(e,t,r=!0){try{const n={action:"remove",labels:e,ids:t,public:r,$auditRecord:{auditEvents:[{type:C.Label_RemoveDoc,detail:{public:r,label:e?e.toString():null,doccount:t?t.length:0}}],mlAuditEvents:[{actionType:"removeFromLabel",documentIds:t}]}};return u("api/v1/labels",n)}catch(n){throw f("Error in remove",n),n}}async function Bt(e,t,r=!0){try{const n={action:"rename",labels:e,newLabel:t,public:r,auditEvents:{type:C.Label_Rename,detail:{public:r,oldlabel:e?e.toString():null,label:t}}};return u("api/v1/labels",n)}catch(n){throw f("Error in rename",n),n}}async function Qt(e,t=!0){try{const r={action:"delete",labels:e,public:t,auditEvents:{type:C.Label_Delete,detail:{public:t,label:e?e.toString():null}}};return u("api/v1/labels",r)}catch(r){throw f("Error in deleteLabels",r),r}}async function jt(e,t,r=!0){try{const n={action:"bulkAdd",labels:e,query:t,public:r,auditEvents:{type:C.Label_Add,detail:{public:r,label:e?e.toString():null,query:t!==null?t.name:null}}};return u("api/v1/labels",n)}catch(n){throw f("Error in bulkAdd",n),n}}async function Vt(e,t,r=!0){try{const n={action:"bulkRemove",labels:e,query:t,public:r,auditEvents:{type:C.Label_Delete,detail:{public:r,label:e?e.toString():null,query:t!==null?t.name:null}}};return u("api/v1/labels",n)}catch(n){throw f("Error in bulkRemove",n),n}}const xt={getUserRights:Ft,add:Nt,remove:qt,rename:Bt,delete:Qt,bulkAdd:jt,bulkRemove:Vt};async function Gt(e,t){if(typeof window>"u")return u("api/v1/preview",{action:"get",id:e,query:t});const r=`${window.location.origin}${window.location.pathname}`,n={name:t?.name,text:t?.text};return u("api/v1/preview",{action:"get",id:e,query:n,browserUrl:r})}async function Mt(e){const t=new Headers;t.append("content-type","text");const r=await fetch(e,{method:"GET",headers:t});y(r)}async function K(){const e=new URLSearchParams({action:"get",noAutoAuthentication:"true"});return _("api/v1/principal",e)}async function Pe(e){const t={noAutoAuthentication:"true",...e},r=new URLSearchParams;return Object.entries(t).forEach(([n,a])=>{a!==void 0&&r.append(n,String(a))}),_("api/v1/principal/list",r)}async function ye(e){if(!e)return Promise.reject(new Error("userid is required"));const t=new URLSearchParams({action:"userid",noAutoAuthentication:"true",userid:e});return _("api/v1/principal",t)}async function Re(e){if(e.length===0)return Promise.reject(new Error("userids is required"));const t=new URLSearchParams({noAutoAuthentication:"true",userids:[...e].join(",")});return _("api/v1/principal/userids",t)}const zt={principal:{get:K,list:Pe,userid:ye,userids:Re}},Le=11;async function Ht(e,t,r){const a=await u("api/v1/query",{query:e,$auditRecord:t,queryIntentData:r});a.aggregations.forEach(i=>{i.$hasMore=!1,!i.isDistribution&&!i.isTree&&i.items&&(i.$hasMore=i.items.length===Le),i.isTree&&i.items&&V(i)}),a.records?.map(i=>Object.assign(i,{value:i.title,type:"default"}));const s={...a,nextPage:a.page<Math.ceil(a.rowCount/a.pageSize)?a.page+1:void 0,previousPage:a.page>1?a.page-1:void 0};return Promise.resolve(s)}async function Jt(e,t,r){const{app:n=""}=d,a={methods:[],mode:t,propagateErrors:!0,$auditRecord:{auditEvents:[r]}};for(const c of e)a.methods.push({method:"query",app:n,query:c});const s=await u("api/v1/multi",a);s.results.forEach(c=>{c.aggregations.forEach(l=>{l.$hasMore=!1,!l.isDistribution&&!l.isTree&&l.items&&(l.$hasMore=l.items.length===Le),l.isTree&&V(l)})}),s.results.forEach(c=>c.records?.map(l=>Object.assign(l,{value:l.title,type:"default"})));const i=s.results.map(c=>({...c,nextPage:c.page<Math.ceil(c.rowCount/c.pageSize)?c.page+1:void 0,previousPage:c.page>1?c.page-1:void 0}));return Promise.resolve(i)}function V(e,t="",r=0){let n=[];return e.items&&e.items.forEach(a=>{let s=t?`${t}/${a.value}`:a.value,i=r+1;n.push({path:s,level:i}),a.$path=s,a.$level=i,a.hasChildren?n=n.concat(V(a,s,i)):a.hasChildren=!1}),n}async function Wt({model:e,appName:t,query:r,article:n}){const{webservice:a,format:s,maxcount:i,exportedColumns:c,export:l}=e,h={app:t,webservice:a,query:r,type:l,format:s,maxcount:i,exportedColumns:c,$auditRecord:{auditEvents:[{type:"Search_ExportCSV",detail:{resultid:n?n.id:void 0}}]}};return A(h),await u("api/v1/search.queryexport",h,{responseType:"blob"})}async function Xt(e){return(await u("api/v1/queryintent",{query:e}))?.intents}async function Yt(e,t,r){return(await u("api/v1/similardocuments",{sourceDocumentId:e,query:{name:t}},{signal:r})).data}async function Kt(e,t){return(await u("api/v1/query.links",{webservice:e,query:t}))?.links?.map(a=>({...a,query:t}))}function Zt(e,t){if(typeof e=="number")return`${e}`;if(we(e))return Et(e);if(typeof e=="boolean")return e?"true":"false";if(e===null)return"null";if(Array.isArray(e)){const r=[];return e.forEach(n=>{r.length>0&&r.push(","),n?typeof n=="string"?r.push(n):r.push(n.display||n.value||""):r.push("null")}),r.splice(0,0,"["),r.push("]"),r.join("")}return e}function Et(e){if(!e)return"";try{if(Se(e)===0)return new Intl.DateTimeFormat("en-CA",{year:"numeric",month:"2-digit",day:"2-digit"}).format(e);{const t=new Intl.DateTimeFormat("en-CA").format(e),r=new Intl.DateTimeFormat("en-CA",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(e);return`${t} ${r}`}}catch{return"Invalid date"}}async function Tt(e,t,r,n,a){const{app:s}=d,i={app:s||"",suggestQuery:e,text:t,filter:r,kinds:n,showSource:a};try{return(await u("api/v1/search.suggest",i)).suggests}catch(c){throw console.error("Error fetching suggestions:",c),c}}async function er(e,t,r,n){const{app:a}=d;return(await u("api/v1/suggestquery",{app:a||"",suggestQuery:e,text:t,query:r,kinds:n})).suggests}async function tr(e,t,r){if(!t)return Promise.resolve([]);const{app:n}=d,s=await u("api/v1/suggestfield",{app:n||"",text:e,fields:t,query:r});return s.suggests.forEach(i=>{i.display=Zt(i.display)}),s.suggests}async function rr(e,t,r,n,a,s){return u("api/v1/doc.textchunks",{id:e,textChunks:t,highlights:r,query:n,leftSentencesCount:a,rightSentencesCount:s})}async function nr(){const{app:e}=d,t=new URLSearchParams({app:e||"",action:"load"});return _("api/v1/usersettings",t)}async function Ue(e,t){const r={action:"save",userSettings:e,$auditRecord:{auditEvents:[t]}};return A(r),u("api/v1/usersettings",r)}async function ar(e,t){const n={action:"patch",userSettings:e,$auditRecord:t?{auditEvents:[t]}:void 0};return A(n),u("api/v1/usersettings",n)}async function or(){return Ue({},{type:"UserSettings_Reset"})}async function sr(e,t){return u("api/v2/security/password/change",{newPassword:e,currentPassword:t})}async function ir(e){const t="api/v2/security/password/ask-reset-email",n={changePasswordRedirectUrl:`${window.location.origin}/login?mode=changepassword`,userName:e};return u(t,n)}async function cr(e){return await _(`api/v2/user-profile/${e}`)}async function lr(e){return await u("api/v2/user-profile",e)}async function ur(e,t,r){return await de(`api/v2/user-profile/${e.data?.id}/${t}/${r}`,e)}async function dr(e,t,r){try{return(await ue(`api/v2/user-profile/${e.data?.id}/${t}/${r}`)).success===!0}catch{return!1}}async function fr(){return await _("api/v2/version")}const R=1e4,Oe=async()=>{const{autoOAuthProvider:e}=d;if(!e)throw new Error("autoOAuthProvider is not configured in globalConfig");if(typeof window>"u")try{const{signal:r}=v(R);return await u("security.oauth",{action:"getcode",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"},{signal:r})}catch(r){throw f("Failed to authenticate with OAuth",r),r}const t={action:"getcode",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const{signal:r}=v(R),n=await u("api/v1/security.oauth",t,{signal:r});if(n.redirectUrl){const a=new URL(n.redirectUrl,window.location.origin);(a.protocol==="https:"||a.protocol==="http:")&&(window.location.href=a.href)}return n}catch(r){throw f("Failed to authenticate with OAuth",r),r}},$e=async()=>{const{autoSAMLProvider:e}=d;if(!e)throw new Error("autoSAMLProvider is not configured in globalConfig");if(typeof window>"u")try{const{signal:r}=v(R);return await u("security.saml",{action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"},{signal:r})}catch(r){throw f("Failed to authenticate with SAML",r),r}const t={action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const{signal:r}=v(R),n=await u("api/v1/security.saml",t,{signal:r});if(n.redirectUrl){const a=new URL(n.redirectUrl,window.location.origin);(a.protocol==="https:"||a.protocol==="http:")&&(window.location.href=a.href)}return n}catch(r){throw f("Failed to authenticate with SAML",r),r}},Z={store:{},getItem(e){return this.store[e]??null},setItem(e,t){this.store[e]=t.toString()},removeItem(e){delete this.store[e]},clear(){this.store={}}},E=Z;function hr(e){return typeof window>"u"||!window.localStorage?Z.getItem(e):window.localStorage.getItem(e)}function gr(e){typeof window>"u"||!window.localStorage?Z.removeItem(e):window.localStorage.removeItem(e)}function mr(e){return typeof window>"u"||!window.sessionStorage?E.getItem(e):window.sessionStorage.getItem(e)}function wr(e,t){typeof window>"u"||!window.sessionStorage?E.setItem(e,t):window.sessionStorage.setItem(e,t)}function _r(e){typeof window>"u"||!window.sessionStorage?E.removeItem(e):window.sessionStorage.removeItem(e)}const F=e=>wr("sinequa-credentials",JSON.stringify({data:{csrfToken:e}})),Ae=async()=>{try{const{signal:e}=v(R),t=await _("api/v1/challenge?action=getCsrfToken&suppressErrors=true",void 0,{signal:e});return t?.csrfToken?(F(t.csrfToken),t.csrfToken):null}catch(e){throw f("Failed to get CSRF token",e),e}};async function Ie(e){if(e){const{username:t,password:r}=e,n={action:"get",tokenInCookie:!0,user:t,password:r,noUserOverride:!0,noAutoAuthentication:!0};try{const{signal:a}=v(R),s=await u("api/v1/security.webtoken",n,{signal:a});return s?.csrfToken?(F(s.csrfToken),s.csrfToken):null}catch(a){throw f("Failed to get JWT",a),a}}else{const t={action:"get",tokenInCookie:!0,noUserOverride:!0,noAutoAuthentication:!1},{bearerToken:r}=d;if(!r)throw new Error("Bearer token is required in globalConfig for credentialless JWT retrieval.");const n=new Headers;n.append("Sinequa-Force-Camel-Case","true"),n.append("accept","application/json"),n.append("Content-Type","application/json"),n.append("Authorization",`Bearer ${r}`);try{const{signal:a}=v(R),s=await u("api/v1/security.webtoken",t,{headers:n,signal:a});return s?.csrfToken?(F(s.csrfToken),s.csrfToken):null}catch(a){throw f("Failed to get JWT without credentials",a),a}}}const x=()=>{const e=mr("sinequa-credentials");if(e)try{const n=JSON.parse(e).data?.csrfToken;if(n)return n}catch(r){O("Failed to parse session storage credentials, falling back to local storage",r)}const t=hr("csrfToken");return t||null},Sr=async e=>{if(e)k("Attempting authentication using credentials"),p({useCredentials:!0,useSSO:!1});else{let c=null;try{k("Attempting to retrieve CSRF token from the backend"),c=await Ae(),U("CSRF token retrieval result",c?"success":"failed")}catch{}try{if(c===null){const{autoOAuthProvider:l,autoSAMLProvider:h,useSAML:b}=d;if(l&&!b)return k("Initiating OAuth authentication flow"),await Oe(),O("OAuth authentication flow did not redirect as expected"),g(!1),!1;if(h)return k("Initiating SAML authentication flow"),await $e(),O("SAML authentication flow did not redirect as expected"),g(!1),!1;k("No direct authentication method available, will try SSO then credentials"),p({useCredentials:!0,useSSO:!0})}else return k("User authenticated via existing token"),g(!0),!0}catch(l){throw f("Unexpected error during authentication",l),g(!1),l}}if(d.useCredentials&&d.useSSO)try{if(k("Checking if user is authenticated via SSO"),await K())return k("User authenticated using SSO"),p({useCredentials:!1,useSSO:!0}),g(!0),!0}catch(c){if(c?.status===401)return k("SSO authentication failed with 401, falling back to credentials"),p({useCredentials:!0,useSSO:!1}),!1;throw f("SSO authentication failed with unexpected error",c),g(!1),c}const{useSSO:r}=d,n=x();if(n||r)return k("user already authenticated",n),p({isRedirectUrl:!1}),g(!0),!0;const{useCredentials:a}=d,{username:s,password:i}=e||{};if(a&&(!s||!i))return f("Credentials are required for authentication"),g(!1),!1;if(s&&i)try{k("authentication using credentials..."),p({useCredentials:!0,useSSO:!1});const{userOverrideActive:c,useroverride:l}=d;return p({userOverrideActive:!1,useroverride:void 0}),await Ie({username:s,password:i}),p({userOverrideActive:c,useroverride:l}),g(!0),!0}catch(c){throw g(!1),c}return g(!1),f("No authentication method available. Please provide credentials or configure OAuth/SAML."),!1},De=async()=>{const e=new URLSearchParams({action:"deleteWebTokenCookie",noUserOverride:"true",noAutoAuthentication:"true"}),{signal:t}=v(R);return _("api/v1/challenge",e,{signal:t})},pr=async()=>{const{useCredentials:e,userOverrideActive:t}=d;if(gr("csrfToken"),_r("sinequa-credentials"),e&&!t)try{(await De()).methodresult==="ok"||f("logout failed"),g(!1)}catch(r){f("logout failed",r),g(!1)}else g(!1)},kr=()=>!!x();o.API=zt,o.ApiError=P,o.Audit=Rt,o.AuditEventType=C,o.DidYouMeanKind=fe,o.EngineType=m,o.EngineTypeModifier=S,o.LogLevel=z,o.MINIMUM_COMPATIBLE_SERVER_API_VERSION=ft,o.RFMDisplay=he,o.ServerError=H,o.TimeoutError=le,o.UnauthorizedError=j,o.addAuditAdditionalInfo=A,o.addConcepts=ze,o.addSessionId=be,o.addUrl=ve,o.aggItemRegex=T,o.aggregationItemStrictCompare=Ne,o.appInitializerFn=Ot,o.bisect=Be,o.buildPathsAndLevels=V,o.configureLogger=st,o.createHeaders=$,o.createTimeoutController=v,o.createUserProfile=lr,o.debug=U,o.del=ue,o.deleteUserProfileProperty=dr,o.deleteUserSettings=or,o.deleteWebTokenCookie=De,o.emitAuthenticatedEvent=g,o.error=f,o.escapeExpr=kt,o.expiresSoon=lt,o.extraColumns=wt,o.fetchAggregation=Lt,o.fetchApp=Ut,o.fetchAppPreLogin=Ce,o.fetchBulkQuery=Jt,o.fetchChangePassword=sr,o.fetchDataset=$t,o.fetchDatasetList=It,o.fetchDatasets=At,o.fetchLabels=Dt,o.fetchPreview=Gt,o.fetchPreviewUrl=Mt,o.fetchPrincipal=K,o.fetchPrincipalList=Pe,o.fetchPrincipalUserid=ye,o.fetchPrincipalUserids=Re,o.fetchQuery=Ht,o.fetchQueryExport=Wt,o.fetchQueryIntent=Xt,o.fetchSendPasswordResetEmail=ir,o.fetchSimilarDocuments=Yt,o.fetchSponsoredLinks=Kt,o.fetchSuggest=Tt,o.fetchSuggestField=tr,o.fetchSuggestQuery=er,o.fetchTextChunks=rr,o.fetchUserProfile=cr,o.fetchUserSettings=nr,o.fetchVersion=fr,o.get=_,o.getConcepts=We,o.getCsrfToken=Ae,o.getFiltersFromURI=G,o.getFiltersFromUrl=Ee,o.getHelpIndexUrl=at,o.getIdFromUrl=et,o.getJWToken=Ie,o.getMetadata=_t,o.getMetadataWithValues=St,o.getOffsetFromDates=ce,o.getQueryPageFromUrl=tt,o.getQueryParamsFromUrl=Ke,o.getQueryTabFromUrl=rt,o.getQueryTextFromUrl=Te,o.getRelativeDate=Xe,o.getTime=Se,o.getToken=x,o.getUrlParamsFromQueryParams=Ze,o.globalConfig=d,o.guid=pe,o.handleResponse=y,o.info=k,o.isArrayBuffer=ge,o.isAuthenticated=kr,o.isBlob=me,o.isDate=we,o.isExpired=ct,o.isJsonable=pt,o.isNotInputEvent=Ye,o.isObject=D,o.isString=_e,o.labels=xt,o.login=Sr,o.logout=pr,o.makeColumn=w,o.notify=ot,o.openParentNodes=te,o.parseText=I,o.parseValueAndOperatorFromItem=ee,o.patch=de,o.patchUserProfile=ur,o.patchUserSettings=ar,o.post=u,o.put=it,o.queryParamsFromUrl=L,o.removeConcept=He,o.removeConcepts=Je,o.resolveToColumnName=dt,o.rewriteText=N,o.saveUserSettings=Ue,o.setGlobalConfig=p,o.setToken=F,o.sha512=bt,o.suggestionsToTreeAggregationNodes=qe,o.sysLang=nt,o.toDate=W,o.translateAggregationToDateOptions=Fe,o.tryOAuthAuthentication=Oe,o.trySAMLAuthentication=$e,o.warn=O,o.withRetry=ut,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/authentication/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-authenticated-event.d.ts","sourceRoot":"","sources":["../../../src/authentication/events/emit-authenticated-event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"emit-authenticated-event.d.ts","sourceRoot":"","sources":["../../../src/authentication/events/emit-authenticated-event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,OAAO,QAa5D"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initiates the OAuth authentication process by sending a POST request to the backend.
|
|
3
|
+
* The server responds with a redirect URL which is used to send the user to the OAuth provider's login page.
|
|
4
|
+
* @returns A promise that resolves to the server response containing the `redirectUrl`.
|
|
5
|
+
* @throws An error if `autoOAuthProvider` is not configured in `globalConfig` or if the request fails.
|
|
6
|
+
*/
|
|
1
7
|
export declare const tryOAuthAuthentication: () => Promise<{
|
|
2
8
|
redirectUrl: string;
|
|
3
9
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/providers/oauth-authentication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oauth-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/providers/oauth-authentication.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;iBAWI,MAAM;EAyC5C,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initiates the SAML authentication process by sending a POST request to the backend.
|
|
3
|
+
* The server responds with a redirect URL which is used to send the user to the SAML identity provider's login page.
|
|
4
|
+
* @returns A promise that resolves to the server response containing the `redirectUrl`.
|
|
5
|
+
* @throws An error if `autoSAMLProvider` is not configured in `globalConfig` or if the request fails.
|
|
6
|
+
*/
|
|
1
7
|
export declare const trySAMLAuthentication: () => Promise<{
|
|
2
8
|
redirectUrl: string;
|
|
3
9
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saml-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/providers/saml-authentication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"saml-authentication.d.ts","sourceRoot":"","sources":["../../../src/authentication/providers/saml-authentication.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;iBAWK,MAAM;EAyC5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/logout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/logout.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,eAAO,MAAM,MAAM,qBAsBlB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Deletes the JSON Web Token (JWT) cookie by sending a GET request to the backend server.
|
|
3
|
-
* @returns
|
|
3
|
+
* @returns A promise that resolves to the server response, containing `methodresult` set to `"ok"` on success.
|
|
4
4
|
*/
|
|
5
5
|
export declare const deleteWebTokenCookie: () => Promise<{
|
|
6
6
|
methodresult: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-web-token-cookie.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/delete-web-token-cookie.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delete-web-token-cookie.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/delete-web-token-cookie.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,oBAAoB;kBAQJ,MAAM;EAClC,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Retrieves the CSRF token from the backend server.
|
|
3
|
-
* If the token is successfully retrieved, it is stored in the session storage
|
|
4
|
-
* If the token is not retrieved, the
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
3
|
+
* If the token is successfully retrieved, it is stored in the session storage.
|
|
4
|
+
* If the token is not retrieved, the caller is responsible for initiating the OAuth/SAML authentication flow.
|
|
5
|
+
* @returns The CSRF token string if successfully retrieved, or `null` if no token was returned.
|
|
6
|
+
* @throws An error if the request to the backend fails.
|
|
7
7
|
*/
|
|
8
8
|
export declare const getCsrfToken: () => Promise<string | null>;
|
|
9
9
|
//# sourceMappingURL=get-csrf-token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-csrf-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-csrf-token.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-csrf-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-csrf-token.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,8BAiBxB,CAAC"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { Credentials } from "../../types";
|
|
2
2
|
/**
|
|
3
|
-
* Retrieves a JSON Web Token (JWT)
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @throws An error if the request to retrieve the JWT fails.
|
|
8
|
-
*
|
|
9
|
-
* The function sends a POST request to the `security.webtoken` endpoint without user credentials,
|
|
10
|
-
* relying on existing authentication mechanisms such as session cookies or existing tokens.
|
|
3
|
+
* Retrieves a JSON Web Token (JWT) using the provided credentials.
|
|
4
|
+
* @param credentials - The user's login credentials (username and password).
|
|
5
|
+
* @returns A promise that resolves to the CSRF token if successful, or `null` if no token is returned.
|
|
6
|
+
* @throws An error if the request to the backend fails.
|
|
11
7
|
*/
|
|
12
8
|
export declare function getJWToken(credentials: Credentials): Promise<string | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves a JSON Web Token (JWT) without explicit credentials.
|
|
11
|
+
* Relies on a bearer token configured in `globalConfig` to authenticate the request.
|
|
12
|
+
* @returns A promise that resolves to the CSRF token if successful, or `null` if no token is returned.
|
|
13
|
+
* @throws An error if `bearerToken` is missing from `globalConfig` or if the request to the backend fails.
|
|
14
|
+
*/
|
|
13
15
|
export declare function getJWToken(): Promise<string | null>;
|
|
14
16
|
//# sourceMappingURL=get-jwt-token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-jwt-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-jwt-token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"get-jwt-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-jwt-token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO/C;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAC7E;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Retrieves the CSRF token
|
|
3
|
-
* @returns The CSRF token.
|
|
2
|
+
* Retrieves the CSRF token, first checking session storage then local storage.
|
|
3
|
+
* @returns The CSRF token string if found, or `null` if not present in either storage.
|
|
4
4
|
*/
|
|
5
5
|
export declare const getToken: () => any;
|
|
6
6
|
//# sourceMappingURL=get-token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-token.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-token.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,eAAO,MAAM,QAAQ,WAmBpB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The standard audit event types
|
|
3
3
|
*/
|
|
4
|
-
export declare
|
|
4
|
+
export declare enum AuditEventType {
|
|
5
5
|
None = "None",
|
|
6
6
|
Search_FirstPage = "Search_FirstPage",
|
|
7
7
|
Search_Text = "Search_Text",
|
|
@@ -105,7 +105,14 @@ export declare const enum AuditEventType {
|
|
|
105
105
|
Answer_Disliked_Cancelled = "Answer_Disliked_Cancelled",
|
|
106
106
|
TopPassages_Display = "TopPassages_Display",
|
|
107
107
|
TopPassages_Click = "TopPassages_Click",
|
|
108
|
-
UserSettings_Reset = "UserSettings_Reset"
|
|
108
|
+
UserSettings_Reset = "UserSettings_Reset",
|
|
109
|
+
Change_Password_Failed = "change.password.failed",
|
|
110
|
+
Change_Password_Success_Form = "change.password.success.form",
|
|
111
|
+
Forgot_Password_Request = "forgot.password.request",
|
|
112
|
+
Login_Denied = "login.denied",
|
|
113
|
+
Login_Success_Form = "login.success.form",
|
|
114
|
+
Send_Reset_Password_Link = "send.reset.password.link",
|
|
115
|
+
Xrest_ChangePassword = "xrest.changepassword"
|
|
109
116
|
}
|
|
110
117
|
/**
|
|
111
118
|
* Helper type to get the values of the AuditEventType enum
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuditEventType.d.ts","sourceRoot":"","sources":["../../../src/types/audit/AuditEventType.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"AuditEventType.d.ts","sourceRoot":"","sources":["../../../src/types/audit/AuditEventType.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,cAAc;IAExB,IAAI,SAAS;IAGb,gBAAgB,qBAAqB;IACrC,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,kBAAkB,uBAAuB;IACzC,oBAAoB,yBAAyB;IAC7C,qBAAqB,0BAA0B;IAC/C,wBAAwB,6BAA6B;IACrD,eAAe,oBAAoB;IACnC,cAAc,mBAAmB;IACjC,oBAAoB,yBAAyB;IAC7C,mBAAmB,wBAAwB;IAC3C,qBAAqB,0BAA0B;IAC/C,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,0BAA0B,+BAA+B;IACzD,4BAA4B,iCAAiC;IAC7D,gBAAgB,qBAAqB;IACrC,2BAA2B,gCAAgC;IAC3D,0BAA0B,+BAA+B;IACzD,iBAAiB,sBAAsB;IACvC,2BAA2B,gCAAgC;IAC3D,WAAW,gBAAgB;IAC3B,kBAAkB,uBAAuB;IACzC,qBAAqB,0BAA0B;IAC/C,mBAAmB,wBAAwB;IAC3C,oBAAoB,uBAAuB;IAC3C,2BAA2B,gCAAgC;IAE3D,cAAc,mBAAmB;IACjC,iBAAiB,sBAAsB;IACvC,oBAAoB,yBAAyB;IAC7C,iBAAiB,sBAAsB;IAEvC,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;IAEnC,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IAEzB,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,gBAAgB,qBAAqB;IACrC,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,gBAAgB,qBAAqB;IACrC,WAAW,gBAAgB;IAC3B,gBAAgB,qBAAqB;IAErC,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC,oBAAoB,yBAAyB;IAE7C,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAE/B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAC7B,iBAAiB,sBAAsB;IACvC,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,aAAa,kBAAkB;IAE/B,gBAAgB,qBAAqB;IACrC,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;IACzC,mBAAmB,wBAAwB;IAE3C,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,QAAQ,aAAa;IACrB,aAAa,kBAAkB;IAC/B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,kBAAkB,uBAAuB;IACzC,OAAO,YAAY;IAEnB,eAAe,oBAAoB;IACnC,iBAAiB,sBAAsB;IACvC,gBAAgB,qBAAqB;IAErC,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;IACnC,sBAAsB,2BAA2B;IACjD,yBAAyB,8BAA8B;IAEvD,mBAAmB,wBAAwB;IAC3C,iBAAiB,sBAAsB;IAEvC,kBAAkB,uBAAuB;IAEzC,sBAAsB,2BAA2B;IACjD,4BAA4B,iCAAiC;IAC7D,uBAAuB,4BAA4B;IACnD,YAAY,iBAAiB;IAC7B,kBAAkB,uBAAuB;IACzC,wBAAwB,6BAA6B;IACrD,oBAAoB,yBAAyB;CAC9C;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,GAAG,cAAc,EAAE,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { CCApp, CCAppPreLogin } from "../../types";
|
|
2
2
|
/**
|
|
3
3
|
* Fetches the CCApp object.
|
|
4
|
+
* @param appName - Optional app name to fetch. Defaults to `globalConfig.app` if not provided.
|
|
4
5
|
* @returns A promise that resolves to the CCApp object.
|
|
5
6
|
*/
|
|
6
|
-
export declare function fetchApp(): Promise<CCApp>;
|
|
7
|
+
export declare function fetchApp(appName?: string): Promise<CCApp>;
|
|
7
8
|
/**
|
|
8
9
|
* Fetches the pre-login information for the app.
|
|
9
10
|
* @returns A promise that resolves to the pre-login information of the app.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-app.d.ts","sourceRoot":"","sources":["../../../src/web-api/v1/fetch-app.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIxD
|
|
1
|
+
{"version":3,"file":"fetch-app.d.ts","sourceRoot":"","sources":["../../../src/web-api/v1/fetch-app.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIxD;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAK/D;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,CAQ/D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,CA0EzD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sinequa/atomic",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/atomic.umd.cjs",
|
|
7
7
|
"module": "./dist/atomic.js",
|
|
@@ -34,7 +34,10 @@
|
|
|
34
34
|
"prepare": "husky"
|
|
35
35
|
},
|
|
36
36
|
"lint-staged": {
|
|
37
|
-
"*.{js,ts,html,scss,css
|
|
37
|
+
"*.{js,ts,html,scss,css}": [
|
|
38
|
+
"npx @biomejs/biome check --write --files-ignore-unknown=true"
|
|
39
|
+
],
|
|
40
|
+
"!(package-lock).json": [
|
|
38
41
|
"npx @biomejs/biome check --write --files-ignore-unknown=true"
|
|
39
42
|
]
|
|
40
43
|
},
|