@sinequa/atomic 1.0.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
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"})}));
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){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 Be(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 Qe(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 je(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 Ve(e,t){return e.reduce((r,n)=>(t(n)?r.true.push(n):r.false.push(n),r),{true:[],false:[]})}const xe=/(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g,Ge=2,ne=3,Me=5,ae=6,ze=8,oe=9,He=11,se=12,Je=14,ie=15;function I(e){if(!e)return[];const t=[],r=e.matchAll(xe);for(let n of r)n[ne]?t.push({type:"group",value:n[ne],op:n[Ge]}):n[ae]?t.push({type:"adjacent",value:n[ae],op:n[Me]}):n[oe]?t.push({type:"exact",value:n[oe],op:n[ze]}):n[se]?t.push({type:"regex",value:n[se],op:n[He]}):n[ie]&&t.push({type:"token",value:n[ie],op:n[Je]});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 We(e,t,r){let n=I(e);for(let a of t)n.push({type:"adjacent",value:a,op:r});return N(n)}function Xe(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 Ye(e){const t=I(e).filter(r=>r.type!=="adjacent");return N(t)}function Ke(e){return I(e).filter(t=>t.type==="adjacent").map(t=>t.value)}function Ze(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 Ee(e){const t=e.target;return t&&t.nodeName!=="INPUT"&&t.nodeName!=="TEXTAREA"}function Te(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 et(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 tt(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 rt(e){const{q:t=""}=L(e);return t}function nt(e){const{id:t}=L(e);return decodeURIComponent(t)}function at(e){const{p:t="0"}=L(e);return parseInt(t,10)}function ot(e){const{t}=L(e);return t}function st(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 it(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 ct={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 lt(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 A(e,t){Q(2,e,t)}function f(e,t){Q(3,e,t)}function O(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){let n={};try{n=await e.clone().json()}catch{}throw A("Unauthorized access attempt with user override",{endpoint:e.url,error:n}),new j(n.errorMessage??n.message??"Unauthorized... User override failed.")}return await J(e,401)}return e.status===500?(f("Server error occurred",{endpoint:e.url}),await J(e,500)):(A(`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=O(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=O(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=O(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=O(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 ut(e,t,r){const n=O(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 dt(e){const t=W(e);return!!t&&t.getTime()<=Date.now()}function ft(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 ht(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&&(A(`Retrying request (${a+1}/${t})`,{error:s}),await new Promise(i=>setTimeout(i,r)))}throw n}function gt(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||{}),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||{}),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 mt="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 wt(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 _t(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 St(e){let t=S.none;if(e)for(const r of e)t|=_t(r);return t}function w(e,t,r,n){const a=wt(t),s=St(r||"");return{name:e,type:t,typeModifier:r,eType:a,eTypeModifier:s,aliases:n}}const pt={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 ge(e){return e.filter(t=>!!t)}const kt={eq:(e,t)=>({field:e,operator:"eq",value:t}),neq:(e,t)=>({field:e,operator:"neq",value:t}),gt:(e,t)=>({field:e,operator:"gt",value:t}),gte:(e,t)=>({field:e,operator:"gte",value:t}),lt:(e,t)=>({field:e,operator:"lt",value:t}),lte:(e,t)=>({field:e,operator:"lte",value:t}),like:(e,t)=>({field:e,operator:"like",value:t}),contains:(e,t)=>({field:e,operator:"contains",value:t}),regex:(e,t)=>({field:e,operator:"regex",value:t}),isNull:e=>({field:e,operator:"null"}),isNotNull:e=>({field:e,operator:"notnull"}),in:(e,t)=>({field:e,operator:"in",values:t}),between:(e,t,r)=>({field:e,operator:"between",start:t,end:r}),and:(...e)=>me("and",e),or:(...e)=>me("or",e),not:(...e)=>{const t=ge(e);return t.length?{operator:"not",filters:t}:void 0}};function me(e,t){const r=ge(t);return r.length===0?void 0:r.length===1?r[0]:{operator:e,filters:r}}function bt(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 vt(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 we(e){return D(e)&&Object.prototype.toString.call(e)==="[object ArrayBuffer]"}function _e(e){return D(e)&&Object.prototype.toString.call(e)==="[object Blob]"}function Se(e){return Object.prototype.toString.call(e)==="[object Date]"}function pe(e){return typeof e=="string"}function Ct(e){return(D(e)||Array.isArray(e))&&!we(e)&&!_e(e)&&!pe(e)}function ke(e){return e?(e.getHours()*60*60+e.getMinutes()*60+e.getSeconds())*1e3+e.getMilliseconds():0}function be(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 yt(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,ve;function $(e,t=!0){let r=Rt(e.$auditRecord);r&&(Ce(r),t&&Pe(r)),e.$auditRecord=r}function Rt(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 Ce(e){const t=Lt();return e.auditEvents?.forEach(r=>{r.detail||(r.detail={}),r.detail.sessionid=t}),e}function Pe(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 Lt(){return(!Y||Ut())&&(Y=be()),ve=new Date,Y}function Ut(){return new Date().getTime()-ve.getTime()>600*1e3}async function Ot(e,t=!0){const r={event:C.None,$auditRecord:e};return $(r,t),u("api/v1/audit.notify",r)}const $t={notify:Ot};async function It(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]}};$(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 At(e){const t=e||d.app,r=new URLSearchParams({app:t||""});return _("api/v1/app",r)}async function ye(){const{app:e}=d,t=new URLSearchParams({app:e||"",preLogin:"true"});return _("api/v1/app",t)}function Dt(){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({})):ye().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 Ft(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 Nt(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 qt(e){return await _(`api/v1/search.dataset/${e}`)}async function Bt(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 Qt(){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 jt(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 Vt(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 xt(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 Gt(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 Mt(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 zt(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 Ht={getUserRights:Qt,add:jt,remove:Vt,rename:xt,delete:Gt,bulkAdd:Mt,bulkRemove:zt};async function Jt(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 Wt(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 Re(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 Le(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 Ue(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 Xt={principal:{get:K,list:Re,userid:Le,userids:Ue}},Oe=11;async function Yt(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===Oe),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 Kt(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===Oe),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 Zt({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 $(h),await u("api/v1/search.queryexport",h,{responseType:"blob"})}async function Et(e){return(await u("api/v1/queryintent",{query:e}))?.intents}async function Tt(e,t,r){return(await u("api/v1/similardocuments",{sourceDocumentId:e,query:{name:t}},{signal:r})).data}async function er(e,t){return(await u("api/v1/query.links",{webservice:e,query:t}))?.links?.map(a=>({...a,query:t}))}function tr(e,t){if(typeof e=="number")return`${e}`;if(Se(e))return rr(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 rr(e){if(!e)return"";try{if(ke(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 nr(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 ar(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 or(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=tr(i.display)}),s.suggests}async function sr(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 ir(){const{app:e}=d,t=new URLSearchParams({app:e||"",action:"load"});return _("api/v1/usersettings",t)}async function $e(e,t){const r={action:"save",userSettings:e,$auditRecord:{auditEvents:[t]}};return $(r),u("api/v1/usersettings",r)}async function cr(e,t){const n={action:"patch",userSettings:e,$auditRecord:t?{auditEvents:[t]}:void 0};return $(n),u("api/v1/usersettings",n)}async function lr(){return $e({},{type:"UserSettings_Reset"})}async function ur(e,t){return u("api/v2/security/password/change",{newPassword:e,currentPassword:t})}async function dr(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 fr(e){return await _(`api/v2/user-profile/${e}`)}async function hr(e){return await u("api/v2/user-profile",e)}async function gr(e,t,r){return await de(`api/v2/user-profile/${e.data?.id}/${t}/${r}`,e)}async function mr(e,t,r){try{return(await ue(`api/v2/user-profile/${e.data?.id}/${t}/${r}`)).success===!0}catch{return!1}}async function wr(){return await _("api/v2/version")}const R=1e4,Ie=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}},Ae=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 _r(e){return typeof window>"u"||!window.localStorage?Z.getItem(e):window.localStorage.getItem(e)}function Sr(e){typeof window>"u"||!window.localStorage?Z.removeItem(e):window.localStorage.removeItem(e)}function pr(e){return typeof window>"u"||!window.sessionStorage?E.getItem(e):window.sessionStorage.getItem(e)}function kr(e,t){typeof window>"u"||!window.sessionStorage?E.setItem(e,t):window.sessionStorage.setItem(e,t)}function br(e){typeof window>"u"||!window.sessionStorage?E.removeItem(e):window.sessionStorage.removeItem(e)}const F=e=>kr("sinequa-credentials",JSON.stringify({data:{csrfToken:e}})),De=async()=>{try{const{signal:e}=v(R),t=await _("api/v1/challenge?action=getCsrfToken&suppressErrors=true",void 0,{signal:e});if(t?.csrfToken)return F(t.csrfToken),t.csrfToken;throw new Error("No CSRF token returned")}catch(e){throw f("Failed to get CSRF token",e),e}};async function Fe(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=pr("sinequa-credentials");if(e)try{const n=JSON.parse(e).data?.csrfToken;if(n)return n}catch(r){A("Failed to parse session storage credentials, falling back to local storage",r)}const t=_r("csrfToken");return t||null},vr=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 De(),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 Ie(),m(!1),!1;if(h)return k("Initiating SAML authentication flow"),await Ae(),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(l){throw f("Unexpected error during authentication",l),m(!1),l}return!1}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}),m(!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),m(!1),c}const{useSSO:r}=d,n=x();if(n||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 f("Credentials are required for authentication"),m(!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 Fe({username:s,password:i}),p({userOverrideActive:c,useroverride:l}),m(!0),!0}catch(c){throw m(!1),c}return m(!1),f("No authentication method available. Please provide credentials or configure OAuth/SAML."),!1},Ne=async()=>{const e=new URLSearchParams({action:"deleteWebTokenCookie",noUserOverride:"true",noAutoAuthentication:"true"}),{signal:t}=v(R);return _("api/v1/challenge",e,{signal:t})};async function Cr(){const{userOverrideActive:e}=d;if(qe(),!e)try{const{methodresult:t,logoutUrl:r}=await Ne();if(t==="ok")return r;f("logout failed")}catch(t){f("logout failed",t)}}function qe(){Sr("csrfToken"),br("sinequa-credentials"),m(!1)}const Pr=()=>!!x();o.API=Xt,o.ApiError=P,o.Audit=$t,o.AuditEventType=C,o.DidYouMeanKind=fe,o.EngineType=g,o.EngineTypeModifier=S,o.LogLevel=z,o.MINIMUM_COMPATIBLE_SERVER_API_VERSION=mt,o.RFMDisplay=he,o.ServerError=H,o.TimeoutError=le,o.UnauthorizedError=j,o.addAuditAdditionalInfo=$,o.addConcepts=We,o.addSessionId=Ce,o.addUrl=Pe,o.aggItemRegex=T,o.aggregationItemStrictCompare=Qe,o.appInitializerFn=Dt,o.bisect=Ve,o.buildPathsAndLevels=V,o.clearSessionTokens=qe,o.configureLogger=lt,o.createHeaders=O,o.createTimeoutController=v,o.createUserProfile=hr,o.debug=U,o.del=ue,o.deleteUserProfileProperty=mr,o.deleteUserSettings=lr,o.deleteWebTokenCookie=Ne,o.emitAuthenticatedEvent=m,o.error=f,o.escapeExpr=Pt,o.expiresSoon=ft,o.extraColumns=pt,o.fetchAggregation=It,o.fetchApp=At,o.fetchAppPreLogin=ye,o.fetchBulkQuery=Kt,o.fetchChangePassword=ur,o.fetchDataset=Ft,o.fetchDatasetList=qt,o.fetchDatasets=Nt,o.fetchLabels=Bt,o.fetchPreview=Jt,o.fetchPreviewUrl=Wt,o.fetchPrincipal=K,o.fetchPrincipalList=Re,o.fetchPrincipalUserid=Le,o.fetchPrincipalUserids=Ue,o.fetchQuery=Yt,o.fetchQueryExport=Zt,o.fetchQueryIntent=Et,o.fetchSendPasswordResetEmail=dr,o.fetchSimilarDocuments=Tt,o.fetchSponsoredLinks=er,o.fetchSuggest=nr,o.fetchSuggestField=or,o.fetchSuggestQuery=ar,o.fetchTextChunks=sr,o.fetchUserProfile=fr,o.fetchUserSettings=ir,o.fetchVersion=wr,o.filter=kt,o.get=_,o.getConcepts=Ke,o.getCsrfToken=De,o.getFiltersFromURI=G,o.getFiltersFromUrl=tt,o.getHelpIndexUrl=it,o.getIdFromUrl=nt,o.getJWToken=Fe,o.getMetadata=bt,o.getMetadataWithValues=vt,o.getOffsetFromDates=ce,o.getQueryPageFromUrl=at,o.getQueryParamsFromUrl=Te,o.getQueryTabFromUrl=ot,o.getQueryTextFromUrl=rt,o.getRelativeDate=Ze,o.getTime=ke,o.getToken=x,o.getUrlParamsFromQueryParams=et,o.globalConfig=d,o.guid=be,o.handleResponse=y,o.info=k,o.isArrayBuffer=we,o.isAuthenticated=Pr,o.isBlob=_e,o.isDate=Se,o.isExpired=dt,o.isJsonable=Ct,o.isNotInputEvent=Ee,o.isObject=D,o.isString=pe,o.labels=Ht,o.login=vr,o.logout=Cr,o.makeColumn=w,o.notify=ct,o.openParentNodes=te,o.parseText=I,o.parseValueAndOperatorFromItem=ee,o.patch=de,o.patchUserProfile=gr,o.patchUserSettings=cr,o.post=u,o.put=ut,o.queryParamsFromUrl=L,o.removeConcept=Xe,o.removeConcepts=Ye,o.resolveToColumnName=gt,o.rewriteText=N,o.saveUserSettings=$e,o.setGlobalConfig=p,o.setToken=F,o.sha512=yt,o.suggestionsToTreeAggregationNodes=je,o.sysLang=st,o.toDate=W,o.translateAggregationToDateOptions=Be,o.tryOAuthAuthentication=Ie,o.trySAMLAuthentication=Ae,o.warn=A,o.withRetry=ht,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
@@ -1,5 +1,5 @@
1
1
  export { emitAuthenticatedEvent } from "./events";
2
2
  export { tryOAuthAuthentication, trySAMLAuthentication } from "./providers";
3
- export { isAuthenticated, login, logout } from "./session";
3
+ export { clearSessionTokens, isAuthenticated, login, logout } from "./session";
4
4
  export { deleteWebTokenCookie, getCsrfToken, getJWToken, getToken, setToken, } from "./tokens";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGlD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,GACT,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGlD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE/E,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,GACT,MAAM,UAAU,CAAC"}
@@ -1,4 +1,4 @@
1
1
  export { login } from "./login";
2
- export { logout } from "./logout";
2
+ export { clearSessionTokens, logout } from "./logout";
3
3
  export { isAuthenticated } from "./user-authentication";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/login.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU/C;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAU,cAAc,WAAW,KAAG,OAAO,CAAC,OAAO,CAwItE,CAAC"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/login.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU/C;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAU,cAAc,WAAW,KAAG,OAAO,CAAC,OAAO,CAqItE,CAAC"}
@@ -1,6 +1,10 @@
1
1
  /**
2
- * Logs out the user.
3
- * @returns {Promise<void>}
2
+ * Logs out the user and delete the web Token Cookie.
3
+ * @returns {Promise<string>} the logout redirectUrl
4
4
  */
5
- export declare const logout: () => Promise<void>;
5
+ export declare function logout(): Promise<string | undefined>;
6
+ /**
7
+ * Clear the authentications tokens and emits authenticated event to false
8
+ */
9
+ export declare function clearSessionTokens(): void;
6
10
  //# sourceMappingURL=logout.d.ts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/authentication/session/logout.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,wBAAsB,MAAM,gCAiB3B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,SAIjC"}
@@ -4,5 +4,6 @@
4
4
  */
5
5
  export declare const deleteWebTokenCookie: () => Promise<{
6
6
  methodresult: string;
7
+ logoutUrl?: string;
7
8
  }>;
8
9
  //# sourceMappingURL=delete-web-token-cookie.d.ts.map
@@ -1 +1 @@
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
+ {"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;gBAAc,MAAM;EAKtD,CAAC"}
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Retrieves the CSRF token from the backend server.
3
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.
4
+ * @returns The CSRF token string if successfully retrieved.
5
+ * @throws An error if the request to the backend fails, or if the response
6
+ * succeeds (HTTP 200) but contains no CSRF token, which is treated as a
7
+ * masked server-side error rather than a valid empty result.
7
8
  */
8
- export declare const getCsrfToken: () => Promise<string | null>;
9
+ export declare const getCsrfToken: () => Promise<string>;
9
10
  //# 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":"AAMA;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,8BAiBxB,CAAC"}
1
+ {"version":3,"file":"get-csrf-token.d.ts","sourceRoot":"","sources":["../../../src/authentication/tokens/get-csrf-token.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,uBAiBxB,CAAC"}
@@ -0,0 +1,82 @@
1
+ import type { BetweenFilter, ExprFilter, Filter, InFilter, NotNullFilter, NullFilter, SimpleFilter } from "../types/filters";
2
+ /** Scalar value accepted by a leaf filter. */
3
+ export type FilterValue = string | number | boolean;
4
+ /**
5
+ * A filter, or a falsy value. Combinators accept these so conditional filters
6
+ * compose without intermediate `if` statements:
7
+ *
8
+ * @example
9
+ * filter.and(
10
+ * text && filter.eq("language", "en"),
11
+ * onlyRecent && filter.gte("modified", "2024-01-01"),
12
+ * );
13
+ */
14
+ type MaybeFilter = Filter | null | undefined | false;
15
+ /**
16
+ * Helpers to build structured `Filter` objects for `query.filters`.
17
+ *
18
+ * These produce plain objects matching the `Filter` model — there is no hidden
19
+ * state and nothing to serialize yourself; the backend interprets them. The
20
+ * combinators (`and`, `or`, `not`) ignore falsy operands and collapse trivial
21
+ * cases (0 operands → `undefined`, 1 operand → the operand itself) so building
22
+ * filters from optional UI state stays terse.
23
+ *
24
+ * @example
25
+ * import { filter } from "@sinequa/atomic";
26
+ *
27
+ * // size > 1000 AND (treepath under /HR/* OR author is "alice")
28
+ * const filters = filter.and(
29
+ * filter.gt("size", 1000),
30
+ * filter.or(
31
+ * filter.eq("treepath", "/HR/*"),
32
+ * filter.eq("authors", "alice"),
33
+ * ),
34
+ * );
35
+ *
36
+ * await fetchQuery({ name: "_query", text: "report", filters });
37
+ */
38
+ export declare const filter: {
39
+ /** `field = value`. */
40
+ eq: (field: string, value: FilterValue) => SimpleFilter;
41
+ /** `field <> value`. */
42
+ neq: (field: string, value: FilterValue) => SimpleFilter;
43
+ /** `field > value`. */
44
+ gt: (field: string, value: FilterValue) => SimpleFilter;
45
+ /** `field >= value`. */
46
+ gte: (field: string, value: FilterValue) => SimpleFilter;
47
+ /** `field < value`. */
48
+ lt: (field: string, value: FilterValue) => SimpleFilter;
49
+ /** `field <= value`. */
50
+ lte: (field: string, value: FilterValue) => SimpleFilter;
51
+ /** SQL `LIKE` pattern match (use `*`/`?` wildcards as supported by the engine). */
52
+ like: (field: string, value: string) => SimpleFilter;
53
+ /** Substring containment. */
54
+ contains: (field: string, value: string) => SimpleFilter;
55
+ /** Regular-expression match. */
56
+ regex: (field: string, value: string) => SimpleFilter;
57
+ /** `field IS NULL` (no value). */
58
+ isNull: (field: string) => NullFilter;
59
+ /** `field IS NOT NULL` (no value). */
60
+ isNotNull: (field: string) => NotNullFilter;
61
+ /**
62
+ * `field IN (...values)` — matches any of the values (logical OR within a field).
63
+ * Prefer this over several `eq` combined with `or` for the same field.
64
+ */
65
+ in: (field: string, values: string[]) => InFilter;
66
+ /** `field BETWEEN start AND end` (inclusive). Works for numbers and ISO dates. */
67
+ between: (field: string, start: string | number, end: string | number) => BetweenFilter;
68
+ /**
69
+ * Combine filters with logical AND. Falsy operands are ignored; with a single
70
+ * effective operand the operand is returned as-is, with none `undefined`.
71
+ */
72
+ and: (...filters: MaybeFilter[]) => Filter | undefined;
73
+ /** Combine filters with logical OR. Same collapsing rules as {@link filter.and}. */
74
+ or: (...filters: MaybeFilter[]) => Filter | undefined;
75
+ /**
76
+ * Negate filters. Falsy operands are ignored; returns `undefined` if nothing
77
+ * remains. A `not` node is always kept (even with a single operand).
78
+ */
79
+ not: (...filters: MaybeFilter[]) => ExprFilter | undefined;
80
+ };
81
+ export {};
82
+ //# sourceMappingURL=filters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/helpers/filters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,MAAM,EACN,QAAQ,EACR,aAAa,EACb,UAAU,EACV,YAAY,EACb,MAAM,kBAAkB,CAAC;AAE1B,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD;;;;;;;;;GASG;AACH,KAAK,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC;AAOrD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,MAAM;IAGjB,uBAAuB;gBACX,MAAM,SAAS,WAAW,KAAG,YAAY;IAKrD,wBAAwB;iBACX,MAAM,SAAS,WAAW,KAAG,YAAY;IAKtD,uBAAuB;gBACX,MAAM,SAAS,WAAW,KAAG,YAAY;IAKrD,wBAAwB;iBACX,MAAM,SAAS,WAAW,KAAG,YAAY;IAKtD,uBAAuB;gBACX,MAAM,SAAS,WAAW,KAAG,YAAY;IAKrD,wBAAwB;iBACX,MAAM,SAAS,WAAW,KAAG,YAAY;IAKtD,mFAAmF;kBACrE,MAAM,SAAS,MAAM,KAAG,YAAY;IAKlD,6BAA6B;sBACX,MAAM,SAAS,MAAM,KAAG,YAAY;IAKtD,gCAAgC;mBACjB,MAAM,SAAS,MAAM,KAAG,YAAY;IAKnD,kCAAkC;oBAClB,MAAM,KAAG,UAAU;IACnC,sCAAsC;uBACnB,MAAM,KAAG,aAAa;IAIzC;;;OAGG;gBACS,MAAM,UAAU,MAAM,EAAE,KAAG,QAAQ;IAK/C,kFAAkF;qBAEzE,MAAM,SACN,MAAM,GAAG,MAAM,OACjB,MAAM,GAAG,MAAM,KACnB,aAAa;IAShB;;;OAGG;sBACe,WAAW,EAAE,KAAG,MAAM,GAAG,SAAS;IAEpD,oFAAoF;qBACnE,WAAW,EAAE,KAAG,MAAM,GAAG,SAAS;IACnD;;;OAGG;sBACe,WAAW,EAAE,KAAG,UAAU,GAAG,SAAS;CAIzD,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export * from "./column-resolver";
2
2
  export * from "./columns";
3
+ export * from "./filters";
3
4
  export * from "./metadata";
4
5
  export * from "./ts-helper";
5
6
  export * from "./utils";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { AggregationOptions } from "../aggregations";
5
5
  import { SpellingCorrectionMode } from "../config";
6
- import { ExprFilter, LegacyFilter } from "../filters";
6
+ import { ExprFilter, Filter, LegacyFilter } from "../filters";
7
7
  import { Open } from "./Open";
8
8
  import { Select } from "./Select";
9
9
  export type Query = {
@@ -26,9 +26,17 @@ export type Query = {
26
26
  */
27
27
  action?: "" | "search" | "open" | "aggregate";
28
28
  /**
29
- * Specifies conditions applied by the user to filter their search results
29
+ * Specifies conditions applied by the user to filter their search results.
30
+ *
31
+ * Prefer the structured `Filter` model — a single leaf `Filter`, an array of
32
+ * them (combined with AND), or an `ExprFilter` tree (`and`/`or`/`not`). The
33
+ * {@link filter} builder helpers create these for you.
34
+ *
35
+ * @remarks
36
+ * `LegacyFilter` is still accepted for backward compatibility and will be
37
+ * removed in a future major version. Migrate to `Filter` / `ExprFilter`.
30
38
  */
31
- filters?: LegacyFilter | LegacyFilter[] | ExprFilter;
39
+ filters?: Filter | Filter[] | ExprFilter | LegacyFilter | LegacyFilter[];
32
40
  /**
33
41
  * Specifies selection-based filtering for this query, typically from UI facets
34
42
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../../src/types/interfaces/Query.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,MAAM,KAAK,GAAG;IAClB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,EAAE,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IAC9C;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,GAAG,UAAU,CAAC;IACrD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC;;OAEG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD;;OAEG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,MAAM,EAAE,CAAC;IAC7D;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAA"}
1
+ {"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../../src/types/interfaces/Query.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,MAAM,KAAK,GAAG;IAClB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,EAAE,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IAC9C;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,YAAY,GAAG,YAAY,EAAE,CAAC;IACzE;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC;;OAEG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD;;OAEG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,MAAM,EAAE,CAAC;IAC7D;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC"}
@@ -1,3 +1,24 @@
1
1
  import { FieldValue } from "./aggregations";
2
+ /**
3
+ * Formats a JavaScript value as its textual representation inside a Sinequa
4
+ * SQL-like / fielded expression (e.g. `` field:`value` ``, `select`, or `open`
5
+ * expressions).
6
+ *
7
+ * - `number` → as-is (`42`)
8
+ * - `boolean` → `true` / `false`
9
+ * - `null` → `null`
10
+ * - `Date` → Sinequa system date string (`YYYY-MM-DD`, quoted when `quote`)
11
+ * - `array` → `[a,b,c]`
12
+ * - `string` → as-is, or single-quoted when `quote` is `true`
13
+ *
14
+ * @remarks
15
+ * **Legacy.** This helper belongs to the legacy expression-string API. For
16
+ * filtering a query, prefer the structured `Filter` model (`query.filters`)
17
+ * and the {@link filter} builder helpers, which the backend serializes for
18
+ * you — no manual value formatting required.
19
+ *
20
+ * @param value The value to format.
21
+ * @param quote When `true`, wraps strings and dates in single quotes.
22
+ */
2
23
  export declare function toSqlValue(value: FieldValue, quote?: boolean): string;
3
24
  //# sourceMappingURL=to-sql.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-sql.d.ts","sourceRoot":"","sources":["../../src/utils/to-sql.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAwCrE"}
1
+ {"version":3,"file":"to-sql.d.ts","sourceRoot":"","sources":["../../src/utils/to-sql.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAwCrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"handle-response.d.ts","sourceRoot":"","sources":["../../../src/web-api/helpers/handle-response.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,QAAQ,EAAE,QAAQ,EAClB,YAAY,GAAE,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,MAAe,GAC9D,OAAO,CAAC,CAAC,CAAC,CAwCZ"}
1
+ {"version":3,"file":"handle-response.d.ts","sourceRoot":"","sources":["../../../src/web-api/helpers/handle-response.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,QAAQ,EAAE,QAAQ,EAClB,YAAY,GAAE,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,MAAe,GAC9D,OAAO,CAAC,CAAC,CAAC,CAoDZ"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sinequa/atomic",
3
3
  "private": false,
4
- "version": "1.0.1",
4
+ "version": "1.1.3",
5
5
  "type": "module",
6
6
  "main": "./dist/atomic.umd.cjs",
7
7
  "module": "./dist/atomic.js",