@sinequa/atomic 0.0.134 → 0.0.139
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atomic.js +737 -691
- package/dist/atomic.umd.cjs +1 -1
- package/dist/helpers/utils.d.ts +11 -0
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/types/preview/Conversion.d.ts +10 -0
- package/dist/types/preview/Conversion.d.ts.map +1 -0
- package/dist/types/preview/PreviewData.d.ts +2 -0
- package/dist/types/preview/PreviewData.d.ts.map +1 -1
- package/dist/types/preview/index.d.ts +2 -1
- package/dist/types/preview/index.d.ts.map +1 -1
- package/dist/utils/query-params.d.ts +1 -1
- package/dist/utils/query-params.d.ts.map +1 -1
- package/dist/utils/to-sql.d.ts +3 -0
- package/dist/utils/to-sql.d.ts.map +1 -0
- package/dist/web-api/v1/fetch-suggest.d.ts +2 -2
- package/dist/web-api/v1/fetch-suggest.d.ts.map +1 -1
- package/dist/web-api/v2/fetch-user-profile.d.ts +20 -1
- package/dist/web-api/v2/fetch-user-profile.d.ts.map +1 -1
- package/package.json +6 -3
package/dist/atomic.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(s=typeof globalThis<"u"?globalThis:s||self,h(s.atomic={}))})(this,function(s){"use strict";var vr=Object.defineProperty;var br=(s,h,d)=>h in s?vr(s,h,{enumerable:!0,configurable:!0,writable:!0,value:d}):s[h]=d;var De=(s,h,d)=>br(s,typeof h!="symbol"?h+"":h,d);function h(e){const t=new CustomEvent("authenticated",{bubbles:!0,cancelable:!1,detail:{authenticated:e}});dispatchEvent(t)}const d={loginPath:"/login",createRoutes:!1};function v(e){Object.assign(d,e)}function L(e){const t=j(),r=new Headers(e);r.append("Sinequa-Force-Camel-Case","true"),r.append("accept","application/json"),t&&r.append("Sinequa-csrf-token",t);const{userOverride:n,userOverrideActive:a,bearerToken:o}=d;return o&&r.append("Authorization",`Bearer ${o}`),n&&a&&(r.append("sinequa-override-user",n.username),r.append("sinequa-override-domain",n.domain)),r}class p extends Error{constructor(r,n){super(r);De(this,"status");this.name="ApiError",this.status=n}}class V extends p{constructor(t="Server error"){super(t,500),this.name="ServerError"}}class T extends p{constructor(t="Request timed out"){super(t,408),this.name="TimeoutError"}}class D extends p{constructor(t="Unauthorized access"){super(t,401),this.name="UnauthorizedError"}}const ee=/.*\:\(?([><=\d\-\.AND ]+)\)?/;function Fe(e,t){var a;return!(e!=null&&e.items)||((a=e==null?void 0:e.items)==null?void 0:a.length)===0?[]:e.items.reduce((o,l)=>{if(!l.value||l.value==="")return o;const i=te(l,e.column);return o.push({operator:i.operator,value:i.value,display:l.display||i.display,filters:i.filters,disabled:l.count===0,hidden:l.count===0&&e.isDistribution?!t:!1}),o},[])}function te(e,t){const r=t,n=e.value.match(ee);if(n!=null&&n[1]){const o=(n==null?void 0:n[1].split(" AND ")).map(l=>{const i=l.indexOf(">=")!==-1?"gte":"lt";let c=l.substring(l.indexOf(" ")+1);return{field:r,operator:i,value:c,display:e.display||e.value}});if(o.length===2)return{field:r,operator:"and",filters:o,value:e.value,display:o[0].display||o[0].value};if(o.length===1)return{...o[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 re(e){return e.items&&(e.items=e.items.map(t=>re(t))),e.items&&e.items.some(t=>t.$selected||t.$opened)&&(e.$opened=!0),e}function Be(e,t){const r=[];if(e.length>0){const n=new Map,o=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g,""),l=new RegExp("\\b"+o,"i");e.forEach(i=>{if(i.display.length>1){const c=i.display.normalize("NFD").replace(/[\u0300-\u036f]/g,""),u=l.exec(c);ne(r,n,"/",i.display,+(i.frequency||0),1,((u==null?void 0:u.index)||0)+t.length)}})}return r}function ne(e,t,r,n,a,o,l){const i=n.indexOf("/",r.length),c=n.substring(0,i+1);let u=t.get(c);if(!u){const m=c.replace(/^\/|\/$/g,"");u={value:n.substring(r.length,i),count:a,items:[],hasChildren:!1,$level:o,$opened:l>=c.length,$path:m},t.set(c,u),e.push(u)}c.length<n.length&&(u.hasChildren=!0,ne(u.items,t,c,n,a,o+1,l))}function Qe(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,ae=3,Ve=5,se=6,xe=8,oe=9,Ge=11,ie=12,ze=14,ce=15;function $(e){if(!e)return[];const t=[],r=e.matchAll(qe);for(let n of r)n[ae]?t.push({type:"group",value:n[ae],op:n[je]}):n[se]?t.push({type:"adjacent",value:n[se],op:n[Ve]}):n[oe]?t.push({type:"exact",value:n[oe],op:n[xe]}):n[ie]?t.push({type:"regex",value:n[ie],op:n[Ge]}):n[ce]&&t.push({type:"token",value:n[ce],op:n[ze]});return t}function F(e){return e.map(t=>{const r=t.op||"";switch(t.type){case"group":return`${r}(${t.value})`;case"adjacent":return`${r}[${t.value}]`;case"exact":return`${r}"${t.value}"`;case"regex":return`${r}/${t.value}/`;case"token":return`${r}${t.value}`}}).join(" ")}function He(e,t,r){let n=$(e);for(let a of t)n.push({type:"adjacent",value:a,op:r});return F(n)}function Je(e,t){const r=$(t),n=r.findIndex(a=>a.value===e);return n!==-1?(r.splice(n,1),t=F(r)):t}function Me(e){const t=$(e).filter(r=>r.type!=="adjacent");return F(t)}function We(e){return $(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:o,isFuture:l}=le(t,r);return n.format(a*(l?1:-1),o)}function le(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:o,n:l,b:i}=R(e),[c]=e.split("?");return{path:c,text:t,filters:r?x(r):void 0,page:n?parseInt(n,10):void 0,sort:a,tab:o,name:l,basket:i}}function Ze(e){if(!e)return"";const{text:t,filters:r,page:n,sort:a,tab:o,name:l,basket:i}=e,c={};t&&(c.q=t),r&&(c.f=JSON.stringify(r)),n&&(c.p=n.toString()),a&&(c.s=a),o&&(c.t=o),l&&(c.n=l),i&&(c.b=i);const u=new URLSearchParams(c).toString();return u||""}function Ee(e){if(e===void 0)return[];const{f:t}=R(e);return x(t)}function x(e){const t=decodeURIComponent(e);try{return JSON.parse(t??"[]")}catch{return console.error(`Error parsing filters from URI: ${e}`),[]}}function R(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=""}=R(e);return t}function et(e){const{id:t}=R(e);return decodeURIComponent(t)}function tt(e){const{p:t="0"}=R(e);return parseInt(t,10)}function rt(e){const{t}=R(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 o=G(e,r,!1);if(!o)return e;const l=t.charCodeAt(0),i=t.charCodeAt(1);let c=o;for(;c;)if(l===c.lang1&&i===c.lang2){const m=G(e,c.end+4,!0);return e.substring(m.start,m.end)}else c=G(e,c.end+4,!1);const u=e.substring(o.start,o.end);return u||e}function G(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:o,folder:l}=t,i=r?`${e}/`:null,c=n?`${e}.${a}`:a??"";return[o,l,`${i||""}${c}`].filter(u=>u!==void 0).join("/")}function N(e){const t=new CustomEvent("notification",{bubbles:!0,cancelable:!1,detail:e});dispatchEvent(t)}const st={success:(e,t)=>{N({type:"success",message:e,options:t})},info:(e,t)=>{N({type:"info",message:e,options:t})},warning:(e,t)=>{N({type:"warning",message:e,options:t})},error:(e,t)=>{N({type:"error",message:e,options:t})}};var z=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE",e))(z||{});let B={level:1,enableConsoleOutput:!0};function ot(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 y(e,t){Q(0,e,t)}function b(e,t){Q(1,e,t)}function U(e,t){Q(2,e,t)}function g(e,t){Q(3,e,t)}async function P(e,t="json"){const r=e.headers.get("sinequa-jwt-refresh");if(r!==null&&I(r),e.status===200)switch(t){case"arraybuffer":return await e.arrayBuffer();case"blob":return await e.blob();case"text":return await e.text();default:return await e.json()}if(e.status===401){if(d.userOverrideActive)throw U("Unauthorized access attempt with user override",{endpoint:e.url}),new D("Unauthorized... User override failed.");return await H(e,401)}return e.status===500?(g("Server error occurred",{endpoint:e.url}),await H(e,500)):(U(`Unexpected response status: ${e.status}`,{endpoint:e.url}),await H(e,e.status))}async function H(e,t){var r;try{const{done:n,value:a}=await((r=e.body)==null?void 0:r.getReader().read())||{done:!0,value:void 0};if(n||!a)throw t===401?new D:t===500?new V:new p(`Request failed with status ${t}`,t);const o=JSON.parse(new TextDecoder().decode(a));throw new Error(o.errorMessage||o.message||`Request failed with status ${t}`,{cause:{errorCode:o.errorCode,errorCodeTest:o.errorCodeTest}})}catch(n){throw n instanceof p?n:t===401?new D(n.message):t===500?new V(n.message):new p(n.message??`Request failed with status ${t}`,t)}}async function it(e,t,r){const n=L(r==null?void 0:r.headers),{backendUrl:a}=d,o=t?`?${new URLSearchParams(t)}`:"",l=a?`${a}/${e}${o}`:`${e}${o}`;y(`Making DELETE request to: ${l}`);try{const i=await fetch(l,{method:"DELETE",credentials:"include",headers:n});return P(i,r==null?void 0:r.responseType)}catch(i){throw g("Error making DELETE request:",i),i}}async function _(e,t,r){const n=L(r==null?void 0:r.headers),{backendUrl:a}=d,o=t?`?${new URLSearchParams(t)}`:"";e.startsWith("plugin")&&(e=`api/v1/${e}`);const l=a?`${a}/${e}${o}`:`${e}${o}`;y(`Making GET request to: ${l}`);try{const i=await fetch(l,{method:"GET",credentials:"include",headers:n,signal:r==null?void 0:r.signal});return P(i,r==null?void 0:r.responseType)}catch(i){throw g("Error making GET request:",i),i}}async function ue(e,t,r){const n=L(r==null?void 0:r.headers);n.append("content-type","application/json");const{app:a,backendUrl:o}=d,l={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},i=o?`${o}/${e}`:`${e}`;y(`Making PATCH request to: ${i}`);try{const c=await fetch(i,{method:"PATCH",headers:n,credentials:"include",body:JSON.stringify(l)});return P(c,r==null?void 0:r.responseType)}catch(c){throw g("Error making PATCH request:",c),c}}async function f(e,t,r){const n=L(r==null?void 0:r.headers),{app:a,backendUrl:o}=d;n.has("Content-Type")||n.set("Content-Type","application/json");const l={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0};e.startsWith("plugin")&&(e=`api/v1/${e}`);const i=o?`${o}/${e}`:`${e}`;y(`Making POST request to: ${i}`);try{const c=await fetch(i,{method:"POST",headers:n,credentials:"include",body:JSON.stringify(l),signal:r==null?void 0:r.signal});return P(c,r==null?void 0:r.responseType)}catch(c){throw g("Error making POST request:",c),c}}async function ct(e,t,r){const n=L(r==null?void 0:r.headers),{app:a,backendUrl:o}=d,l={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},i=`${o}/${e}`;y(`Making PUT request to: ${i}`);try{const c=await fetch(i,{method:"PUT",headers:n,credentials:"include",body:JSON.stringify(l)});return P(c,r==null?void 0:r.responseType)}catch(c){throw g("Error making PUT request:",c),c}}function lt(e){const t=new AbortController,{signal:r}=t;return e&&setTimeout(()=>{r.aborted||t.abort(new T(`Request timed out after ${e}ms`))},e),{controller:t,signal:r}}function J(e){if(!e)return;const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t}function ut(e){const t=J(e);return!!t&&t.getTime()<=Date.now()}function dt(e,t=7){const r=J(e);if(!r)return!1;const n=Date.now(),a=n+t*24*60*60*1e3,o=r.getTime();return o>n&&o<=a}async function ft(e,t=0,r=1e3){let n;for(let a=0;a<=t;a++)try{return await e()}catch(o){if(n=o,o instanceof p&&o.status>=400&&o.status<500&&o.status!==429||o instanceof DOMException&&o.name==="AbortError")throw o;a<t&&(U(`Retrying request (${a+1}/${t})`,{error:o}),await new Promise(l=>setTimeout(l,r)))}throw n}function ht(e,t,r){var o,l,i,c;if(!e||!t)return;if(r){const u=Object.keys(t.queries).find(E=>E===(r==null?void 0:r.toLowerCase()));let m;u&&(m=t.queries[u]);const Z=(l=((o=m==null?void 0:m.columnsInfo)==null?void 0:o.columns)||[])==null?void 0:l.find(E=>{var Ae,Ie;return(Ie=(Ae=E.aliases)==null?void 0:Ae.split(","))==null?void 0:Ie.includes(e)});if(Z)return Z.name}const n=(c=(i=t.indexes)==null?void 0:i._)==null?void 0:c.columns,a=Object.entries(n).find(u=>{var m;return(m=u[1].aliases)==null?void 0:m.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))(C||{}),w=(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))(w||{}),k=(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))(k||{});const gt="1.0";var de=(e=>(e[e.Original=0]="Original",e[e.Corrected=1]="Corrected",e))(de||{}),fe=(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))(fe||{});function mt(e){if(!e)return w.none;switch(e.toLocaleLowerCase()){case"bool":case"boolean":return w.bool;case"date":return w.date;case"datetime":return w.dateTime;case"time":return w.time;case"unsigned":return w.unsigned;case"integer":return w.integer;case"float":return w.float;case"double":return w.double;case"dates":return w.dates;case"datetimes":return w.dateTimes;case"times":return w.times;case"varchar":return w.varchar;case"binary":return w.binary;case"string":return w.string;case"csv":return w.csv;default:return w.none}}function wt(e){switch(e){case"a":return k.a;case"c":return k.c;case"d":return k.d;case"e":return k.e;case"i":return k.i;case"l":return k.l;case"n":return k.n;case"t":return k.t;case"x":return k.x;case"z":return k.z;default:return k.none}}function St(e){let t=k.none;if(e)for(const r of e)t|=wt(r);return t}function S(e,t,r,n){const a=mt(t),o=St(r||"");return{name:e,type:t,typeModifier:r,eType:a,eTypeModifier:o,aliases:n}}const _t={id:S("id","string"),text:S("text","varchar"),documentlanguages:S("documentlanguages","csv","ci",["language"]),databasealias:S("databasealias","varchar"),globalrelevance:S("globalrelevance","double"),matchingpartnames:S("matchingpartnames","csv"),matchlocations:S("matchlocations","csv"),matchlocationsperpartname:S("matchlocationsperpartname","varchar"),extracts:S("extracts","csv"),extractsperpartname:S("extractsperpartname","varchar"),extractslocations:S("extractslocations","csv"),documentweight:S("documentweight","varchar"),groupcount:S("groupcount","integer"),accesslists:S("accesslists","varchar",void 0,["accessLists"])};function kt(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 o=a.display.trim(),l="value"in a?String(a.value).trim():o;return{display:o,value:l}}}).filter(a=>a!==void 0);const n=String(r).trim();return[{display:n,value:n}]}function A(e){return e!==null&&typeof e=="object"}function he(e){return A(e)&&Object.prototype.toString.call(e)==="[object ArrayBuffer]"}function ge(e){return A(e)&&Object.prototype.toString.call(e)==="[object Blob]"}function me(e){return typeof e=="string"}function bt(e){return(A(e)||Array.isArray(e))&&!he(e)&&!ge(e)&&!me(e)}function we(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 Ct(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 pt(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(M(e)))}catch{return Promise.resolve(M(e))}return Promise.resolve(M(e))}function M(e){let n=2166136261;for(let m=0;m<e.length;m++)n^=e.charCodeAt(m),n=n*16777619>>>0;const a=n.toString(16).padStart(8,"0"),o=((n^2863311530)>>>0).toString(16).padStart(8,"0"),l=((n^1431655765)>>>0).toString(16).padStart(8,"0"),i=((n^3435973836)>>>0).toString(16).padStart(8,"0"),c=a+o+l+i;return(c+c+c+c).substring(0,128)}let W,Se;function O(e,t=!0){let r=Pt(e.$auditRecord);r&&(_e(r),t&&ke(r)),e.$auditRecord=r}function Pt(e){if(!e)return;let t;if(Array.isArray(e))t=e;else if(A(e)){const r=e;if(r.auditEvents||r.mlAuditEvents)return r;t=[e]}return{auditEvents:t}}function _e(e){var r;const t=Rt();return(r=e.auditEvents)==null||r.forEach(n=>{n.detail||(n.detail={}),n.detail.sessionid=t}),e}function ke(e){var r;const t=typeof window<"u"?decodeURIComponent(window.location.href):"http://localhost";return(r=e==null?void 0:e.auditEvents)==null||r.forEach(n=>{n.detail||(n.detail={}),n.detail.url=t}),e}function Rt(){return(!W||yt())&&(W=we()),Se=new Date,W}function yt(){return new Date().getTime()-Se.getTime()>10*60*1e3}async function Lt(e,t=!0){const r={event:C.None,$auditRecord:e};return O(r,t),f("api/v1/audit.notify",r)}const Ut={notify:Lt};async function Ot(e,t,r){var m;const n=((m=e.items)==null?void 0:m.length)||0,a=10,o={query:{...t,action:"aggregate",aggregations:{[e.name]:{skip:n,count:a}}},$auditRecord:{auditEvents:[r]}};O(o);const l=await f("api/v1/query",o),i=await P(l),{aggregations:c}=i,u=c[0];return u.$hasMore=u.items.length>a,u.items=[...e.items,...u.items],Promise.resolve(u)}async function $t(){const{app:e}=d,t=new URLSearchParams({app:e||""});return _("api/v1/app",t)}async function ve(){const{app:e}=d,t=new URLSearchParams({app:e||"",preLogin:"true"});return _("api/v1/app",t)}function At(){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])}v({...d,backendUrl:e,app:t})}return r?(v({...d,useCredentials:!0,useSSO:!1,autoOAuthProvider:void 0,autoSAMLProvider:void 0,bearerToken:void 0,useSAML:void 0}),Promise.resolve({})):ve().then(n=>{const{autoOAuthProvider:a,autoSAMLProvider:o}=d,l=!a&&!n.autoOAuthProvider&&!o&&!n.autoSAMLProvider;return v({...d,autoOAuthProvider:a||n.autoOAuthProvider,autoSAMLProvider:o||n.autoSAMLProvider,useCredentials:l,useSSO:l}),n}).catch(n=>{throw g("atomic:fetchAppPreLogin error",n),n})}async function It(e,t,r={}){const n=`api/v1/search.dataset/${e}/${t}`,a=await f(n,{parameters:r}),o=t[0].toLowerCase()+t.slice(1),l=a.datasets[o];if("errorCode"in l&&"errorMessage"in l)throw new Error(l.errorMessage);return l}async function Dt(e,t){const r=`api/v1/search.dataset/${e}`,{parameters:n={},datasets:a=[]}=t;return(await f(r,{parameters:n,datasets:a})).datasets}async function Ft(e){return await _(`api/v1/search.dataset/${e}`)}async function Nt(e,t=!0,r){try{return(await f("api/v1/labels",{action:"list",q:e,public:t,locale:r,localize:!1})).labels}catch(n){throw g("Error in fetchLabels",n),n}}async function Bt(){try{const{app:e=""}=d,t=new URLSearchParams({app:e,action:"getUserRights"});return _("api/v1/labels",t)}catch(e){throw g("Error in getUserRights",e),e}}async function Qt(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 f("api/v1/labels",n)}catch(n){throw g("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 f("api/v1/labels",n)}catch(n){throw g("Error in remove",n),n}}async function jt(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 f("api/v1/labels",n)}catch(n){throw g("Error in rename",n),n}}async function Vt(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 f("api/v1/labels",r)}catch(r){throw g("Error in deleteLabels",r),r}}async function xt(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 f("api/v1/labels",n)}catch(n){throw g("Error in bulkAdd",n),n}}async function Gt(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 f("api/v1/labels",n)}catch(n){throw g("Error in bulkRemove",n),n}}const zt={getUserRights:Bt,add:Qt,remove:qt,rename:jt,delete:Vt,bulkAdd:xt,bulkRemove:Gt};async function Ht(e,t){if(typeof window>"u")return f("api/v1/preview",{action:"get",id:e,query:t});const r=`${window.location.origin}${window.location.pathname}`,n={name:t==null?void 0:t.name,text:t==null?void 0:t.text};return f("api/v1/preview",{action:"get",id:e,query:n,browserUrl:r})}async function Jt(e){const t=new Headers;t.append("content-type","text");const r=await fetch(e,{method:"GET",headers:t});P(r)}async function X(){const e=new URLSearchParams({action:"get",noAutoAuthentication:"true"});return _("api/v1/principal",e)}async function be(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 Ce(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 pe(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 Mt={principal:{get:X,list:be,userid:Ce,userids:pe}},Pe=11;async function Wt(e,t,r){var l;const a=await f("api/v1/query",{query:e,$auditRecord:t,queryIntentData:r});a.aggregations.forEach(i=>{i.$hasMore=!1,!i.isDistribution&&!i.isTree&&i.items&&(i.$hasMore=i.items.length===Pe),i.isTree&&i.items&&q(i)}),(l=a.records)==null||l.map(i=>Object.assign(i,{value:i.title,type:"default"}));const o={...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(o)}async function Xt(e,t,r){const{app:n=""}=d,a={methods:[],mode:t,propagateErrors:!0,$auditRecord:{auditEvents:[r]}};for(const i of e)a.methods.push({method:"query",app:n,query:i});const o=await f("api/v1/multi",a);o.results.forEach(i=>{i.aggregations.forEach(c=>{c.$hasMore=!1,!c.isDistribution&&!c.isTree&&c.items&&(c.$hasMore=c.items.length===Pe),c.isTree&&q(c)})}),o.results.forEach(i=>{var c;return(c=i.records)==null?void 0:c.map(u=>Object.assign(u,{value:u.title,type:"default"}))});const l=o.results.map(i=>({...i,nextPage:i.page<Math.ceil(i.rowCount/i.pageSize)?i.page+1:void 0,previousPage:i.page>1?i.page-1:void 0}));return Promise.resolve(l)}function q(e,t="",r=0){let n=[];return e.items&&e.items.forEach(a=>{let o=t?`${t}/${a.value}`:a.value,l=r+1;n.push({path:o,level:l}),a.$path=o,a.$level=l,a.hasChildren?n=n.concat(q(a,o,l)):a.hasChildren=!1}),n}async function Yt({model:e,appName:t,query:r,article:n}){const{webservice:a,format:o,maxcount:l,exportedColumns:i,export:c}=e,u={app:t,webservice:a,query:r,type:c,format:o,maxcount:l,exportedColumns:i,$auditRecord:{auditEvents:[{type:"Search_ExportCSV",detail:{resultid:n?n.id:void 0}}]}};return O(u),await f("api/v1/search.queryexport",u,{responseType:"blob"})}async function Kt(e){const r=await f("api/v1/queryintent",{query:e});return r==null?void 0:r.intents}async function Zt(e,t,r){return(await f("api/v1/similardocuments",{sourceDocumentId:e,query:{name:t}},{signal:r})).data}async function Et(e,t){var a;const n=await f("api/v1/query.links",{webservice:e,query:t});return(a=n==null?void 0:n.links)==null?void 0:a.map(o=>({...o,query:t}))}async function Tt(e,t,r,n,a){const{app:o}=d,l={app:o||"",suggestQuery:e,text:t,filter:r,kinds:n,showSource:a};try{return(await f("api/v1/search.suggest",l)).suggests}catch(i){throw console.error("Error fetching suggestions:",i),i}}async function er(e,t,r,n){const{app:a}=d;return(await f("api/v1/suggestquery",{app:a||"",suggestQuery:e,text:t,query:r,kinds:n})).suggests}async function tr(e,t){if(!t)return Promise.resolve([]);const{app:r}=d;return(await f("api/v1/suggestfield",{app:r||"",text:e,action:"suggests",fields:t})).suggests}async function rr(e,t,r,n,a,o){return f("api/v1/doc.textchunks",{id:e,textChunks:t,highlights:r,query:n,leftSentencesCount:a,rightSentencesCount:o})}async function nr(){const{app:e}=d,t=new URLSearchParams({app:e||"",action:"load"});return _("api/v1/usersettings",t)}async function Re(e,t){const r={action:"save",userSettings:e,$auditRecord:{auditEvents:[t]}};return O(r),f("api/v1/usersettings",r)}async function ar(e,t){const n={action:"patch",userSettings:e,$auditRecord:t?{auditEvents:[t]}:void 0};return O(n),f("api/v1/usersettings",n)}async function sr(){return Re({},{type:"UserSettings_Reset"})}async function or(e,t){return f("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 f(t,n)}async function cr(e){return await _(`api/v2/user-profile/${e}`)}async function lr(e){return await f("api/v2/user-profile",e)}async function ur(e,t,r){var a;return await ue(`api/v2/user-profile/${(a=e.data)==null?void 0:a.id}/${t}/${r}`,e)}async function dr(){return await _("api/v2/version")}const ye=async()=>{const{autoOAuthProvider:e}=d;if(typeof window>"u")return f("security.oauth",{action:"getcode",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"});const t={action:"getcode",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const r=await f("api/v1/security.oauth",t);return r.redirectUrl&&(window.location.href=r.redirectUrl),r}catch(r){throw console.error("Failed to authenticate with OAuth",r),r}},Le=async()=>{const{autoSAMLProvider:e}=d;if(typeof window>"u")return f("security.saml",{action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"});const t={action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const r=await f("api/v1/security.saml",t);return r.redirectUrl&&(window.location.href=r.redirectUrl),r}catch(r){throw console.error("Failed to authenticate with SAML",r),r}},Y={store:{},getItem(e){return this.store[e]??null},setItem(e,t){this.store[e]=t.toString()},removeItem(e){delete this.store[e]},clear(){this.store={}}},K=Y;function fr(e){return typeof window>"u"||!window.localStorage?Y.getItem(e):window.localStorage.getItem(e)}function hr(e){typeof window>"u"||!window.localStorage?Y.removeItem(e):window.localStorage.removeItem(e)}function gr(e){return typeof window>"u"||!window.sessionStorage?K.getItem(e):window.sessionStorage.getItem(e)}function mr(e,t){typeof window>"u"||!window.sessionStorage?K.setItem(e,t):window.sessionStorage.setItem(e,t)}function wr(e){typeof window>"u"||!window.sessionStorage?K.removeItem(e):window.sessionStorage.removeItem(e)}const I=e=>mr("sinequa-credentials",JSON.stringify({data:{csrfToken:e}})),Ue=async()=>{try{const e=await _("api/v1/challenge?action=getCsrfToken&suppressErrors=true");return e!=null&&e.csrfToken?(I(e.csrfToken),e.csrfToken):null}catch(e){throw g("Failed to get CSRF token",e),e}};async function Oe(e){if(e){const{username:t,password:r}=e,n={action:"get",tokenInCookie:!0,user:t,password:r,noUserOverride:!0,noAutoAuthentication:!0};try{const a=await f("api/v1/security.webtoken",n);return a!=null&&a.csrfToken?(I(a.csrfToken),a.csrfToken):null}catch(a){throw console.error("Failed to get JWT",a),a}}else{const t={action:"get",tokenInCookie:!0,noUserOverride:!0,noAutoAuthentication:!1},{bearerToken:r}=d;if(!r)throw new Error("Bearer token is required in globalConfig for credentialless JWT retrieval.");const n=new Headers;n.append("Sinequa-Force-Camel-Case","true"),n.append("accept","application/json"),n.append("Content-Type","application/json"),n.append("Authorization",`Bearer ${r}`);try{const a=await f("api/v1/security.webtoken",t,{headers:n});return a.csrfToken?(I(a.csrfToken),a.csrfToken):null}catch(a){throw console.error("Failed to get JWT without credentials",a),a}}}const j=()=>{var r;const e=gr("sinequa-credentials");if(e)try{const a=(r=JSON.parse(e).data)==null?void 0:r.csrfToken;if(a!==void 0)return a}catch{}const t=fr("csrfToken");return t!==null?t:null},Sr=async e=>{if(e)b("Attempting authentication using credentials"),v({useCredentials:!0,useSSO:!1});else{let i=null;try{b("Attempting to retrieve CSRF token from the backend"),i=await Ue(),y("CSRF token retrieval result",i?"success":"failed")}catch(c){g("Failed to retrieve CSRF token",c)}try{if(i===null){const{autoOAuthProvider:c,autoSAMLProvider:u,useSAML:m}=d;if(c&&!m)return b("Initiating OAuth authentication flow"),await ye(),U("OAuth authentication flow did not redirect as expected"),h(!1),!1;if(u)return b("Initiating SAML authentication flow"),await Le(),U("SAML authentication flow did not redirect as expected"),h(!1),!1;b("No direct authentication method available, will try SSO then credentials"),v({useCredentials:!0,useSSO:!0})}else return b("User authenticated via existing token"),h(!0),!0}catch(c){throw g("Unexpected error during authentication",c),h(!1),c}}if(d.useCredentials&&d.useSSO)try{if(b("Checking if user is authenticated via SSO"),await X())return b("User authenticated using SSO"),v({useCredentials:!1,useSSO:!0}),h(!0),!0}catch(i){if((i==null?void 0:i.status)===401)return b("SSO authentication failed with 401, falling back to credentials"),v({useCredentials:!0,useSSO:!1}),!1;throw g("SSO authentication failed with unexpected error",i),h(!1),g}const{useSSO:r}=d,n=j();if(n&&n!==null||r)return b("user already authenticated",n),v({isRedirectUrl:!1}),h(!0),!0;const{useCredentials:a}=d,{username:o,password:l}=e||{};if(a&&!o&&!l)return g("Credentials are required for authentication"),h(!1),!1;if(o&&l)try{b("authentication using credentials..."),v({useCredentials:!0,useSSO:!1});const{userOverrideActive:i,useroverride:c}=d;return v({userOverrideActive:!1,useroverride:void 0}),await Oe({username:o,password:l}),v({userOverrideActive:i,useroverride:c}),h(!0),!0}catch(i){throw h(!1),i}return h(!1),g("No authentication method available. Please provide credentials or configure OAuth/SAML."),!1},$e=async()=>{const e=new URLSearchParams({action:"deleteWebTokenCookie",noUserOverride:"true",noAutoAuthentication:"true"});return _("api/v1/challenge",e)},_r=async()=>{const{useCredentials:e,userOverrideActive:t}=d;hr("csrfToken"),wr("sinequa-credentials"),e&&!t?(await $e()).methodresult==="ok"?h(!1):console.error("logout failed"):h(!1)},kr=()=>!!j();s.API=Mt,s.ApiError=p,s.Audit=Ut,s.AuditEventType=C,s.DidYouMeanKind=de,s.EngineType=w,s.EngineTypeModifier=k,s.LogLevel=z,s.MINIMUM_COMPATIBLE_SERVER_API_VERSION=gt,s.RFMDisplay=fe,s.ServerError=V,s.TimeoutError=T,s.UnauthorizedError=D,s.addAuditAdditionalInfo=O,s.addConcepts=He,s.addSessionId=_e,s.addUrl=ke,s.aggItemRegex=ee,s.aggregationItemStrictCompare=Ne,s.appInitializerFn=At,s.bisect=Qe,s.buildPathsAndLevels=q,s.configureLogger=ot,s.createHeaders=L,s.createTimeoutController=lt,s.createUserProfile=lr,s.debug=y,s.del=it,s.deleteUserSettings=sr,s.deleteWebTokenCookie=$e,s.emitAuthenticatedEvent=h,s.error=g,s.escapeExpr=Ct,s.expiresSoon=dt,s.extraColumns=_t,s.fetchAggregation=Ot,s.fetchApp=$t,s.fetchAppPreLogin=ve,s.fetchBulkQuery=Xt,s.fetchChangePassword=or,s.fetchDataset=It,s.fetchDatasetList=Ft,s.fetchDatasets=Dt,s.fetchLabels=Nt,s.fetchPreview=Ht,s.fetchPreviewUrl=Jt,s.fetchPrincipal=X,s.fetchPrincipalList=be,s.fetchPrincipalUserid=Ce,s.fetchPrincipalUserids=pe,s.fetchQuery=Wt,s.fetchQueryExport=Yt,s.fetchQueryIntent=Kt,s.fetchSendPasswordResetEmail=ir,s.fetchSimilarDocuments=Zt,s.fetchSponsoredLinks=Et,s.fetchSuggest=Tt,s.fetchSuggestField=tr,s.fetchSuggestQuery=er,s.fetchTextChunks=rr,s.fetchUserProfile=cr,s.fetchUserSettings=nr,s.fetchVersion=dr,s.get=_,s.getConcepts=We,s.getCsrfToken=Ue,s.getFiltersFromURI=x,s.getFiltersFromUrl=Ee,s.getHelpIndexUrl=at,s.getIdFromUrl=et,s.getJWToken=Oe,s.getMetadata=kt,s.getMetadataWithValues=vt,s.getOffsetFromDates=le,s.getQueryPageFromUrl=tt,s.getQueryParamsFromUrl=Ke,s.getQueryTabFromUrl=rt,s.getQueryTextFromUrl=Te,s.getRelativeDate=Xe,s.getToken=j,s.getUrlParamsFromQueryParams=Ze,s.globalConfig=d,s.guid=we,s.handleResponse=P,s.info=b,s.isArrayBuffer=he,s.isAuthenticated=kr,s.isBlob=ge,s.isExpired=ut,s.isJsonable=bt,s.isNotInputEvent=Ye,s.isObject=A,s.isString=me,s.labels=zt,s.login=Sr,s.logout=_r,s.makeColumn=S,s.notify=st,s.openParentNodes=re,s.parseText=$,s.parseValueAndOperatorFromItem=te,s.patch=ue,s.patchUserProfile=ur,s.patchUserSettings=ar,s.post=f,s.put=ct,s.queryParamsFromUrl=R,s.removeConcept=Je,s.removeConcepts=Me,s.resolveToColumnName=ht,s.rewriteText=F,s.saveUserSettings=Re,s.setGlobalConfig=v,s.setToken=I,s.sha512=pt,s.suggestionsToTreeAggregationNodes=Be,s.sysLang=nt,s.toDate=J,s.translateAggregationToDateOptions=Fe,s.tryOAuthAuthentication=ye,s.trySAMLAuthentication=Le,s.warn=U,s.withRetry=ft,Object.defineProperty(s,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){const t=new CustomEvent("authenticated",{bubbles:!0,cancelable:!1,detail:{authenticated:e}});dispatchEvent(t)}const d={loginPath:"/login",createRoutes:!1};function p(e){Object.assign(d,e)}function L(e){const t=j(),r=new Headers(e);r.append("Sinequa-Force-Camel-Case","true"),r.append("accept","application/json"),t&&r.append("Sinequa-csrf-token",t);const{userOverride:n,userOverrideActive:a,bearerToken:s}=d;return s&&r.append("Authorization",`Bearer ${s}`),n&&a&&(r.append("sinequa-override-user",n.username),r.append("sinequa-override-domain",n.domain)),r}class C extends Error{status;constructor(t,r){super(t),this.name="ApiError",this.status=r}}class V extends C{constructor(t="Server error"){super(t,500),this.name="ServerError"}}class Z extends C{constructor(t="Request timed out"){super(t,408),this.name="TimeoutError"}}class D extends C{constructor(t="Unauthorized access"){super(t,401),this.name="UnauthorizedError"}}const E=/.*\:\(?([><=\d\-\.AND ]+)\)?/;function Ie(e,t){return!e?.items||e?.items?.length===0?[]:e.items.reduce((a,s)=>{if(!s.value||s.value==="")return a;const i=T(s,e.column);return a.push({operator:i.operator,value:i.value,display:s.display||i.display,filters:i.filters,disabled:s.count===0,hidden:s.count===0&&e.isDistribution?!t:!1}),a},[])}function T(e,t){const r=t,n=e.value.match(E);if(n?.[1]){const s=(n?.[1].split(" AND ")).map(i=>{const l=i.indexOf(">=")!==-1?"gte":"lt";let c=i.substring(i.indexOf(" ")+1);return{field:r,operator:l,value:c,display:e.display||e.value}});if(s.length===2)return{field:r,operator:"and",filters:s,value:e.value,display:s[0].display||s[0].value};if(s.length===1)return{...s[0],field:r};throw new Error("Failed to parse distribution expression")}return{field:r,operator:"eq",value:e.value,display:e.display}}function De(e,t,r){return e.valuesAreExpressions?t.display===r.display:t.value===r.value}function ee(e){return e.items&&(e.items=e.items.map(t=>ee(t))),e.items&&e.items.some(t=>t.$selected||t.$opened)&&(e.$opened=!0),e}function Fe(e,t){const r=[];if(e.length>0){const n=new Map,s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g,""),i=new RegExp("\\b"+s,"i");e.forEach(l=>{if(l.display.length>1){const c=l.display.normalize("NFD").replace(/[\u0300-\u036f]/g,""),f=i.exec(c);te(r,n,"/",l.display,+(l.frequency||0),1,(f?.index||0)+t.length)}})}return r}function te(e,t,r,n,a,s,i){const l=n.indexOf("/",r.length),c=n.substring(0,l+1);let f=t.get(c);if(!f){const b=c.replace(/^\/|\/$/g,"");f={value:n.substring(r.length,l),count:a,items:[],hasChildren:!1,$level:s,$opened:i>=c.length,$path:b},t.set(c,f),e.push(f)}c.length<n.length&&(f.hasChildren=!0,te(f.items,t,c,n,a,s+1,i))}function Ne(e,t){return e.reduce((r,n)=>(t(n)?r.true.push(n):r.false.push(n),r),{true:[],false:[]})}const qe=/(([\+\-])?\(([^\)]+)\))|(([\+\-])?\[([^\]]+)\])|(([\+\-])?\"([^\"]+)\")|(([\+\-])?\/([^\/]+)\/)|(([\+\-])?(\S+))/g,Be=2,re=3,Qe=5,ne=6,je=8,ae=9,Ve=11,oe=12,Ge=14,se=15;function $(e){if(!e)return[];const t=[],r=e.matchAll(qe);for(let n of r)n[re]?t.push({type:"group",value:n[re],op:n[Be]}):n[ne]?t.push({type:"adjacent",value:n[ne],op:n[Qe]}):n[ae]?t.push({type:"exact",value:n[ae],op:n[je]}):n[oe]?t.push({type:"regex",value:n[oe],op:n[Ve]}):n[se]&&t.push({type:"token",value:n[se],op:n[Ge]});return t}function F(e){return e.map(t=>{const r=t.op||"";switch(t.type){case"group":return`${r}(${t.value})`;case"adjacent":return`${r}[${t.value}]`;case"exact":return`${r}"${t.value}"`;case"regex":return`${r}/${t.value}/`;case"token":return`${r}${t.value}`}}).join(" ")}function xe(e,t,r){let n=$(e);for(let a of t)n.push({type:"adjacent",value:a,op:r});return F(n)}function ze(e,t){const r=$(t),n=r.findIndex(a=>a.value===e);return n!==-1?(r.splice(n,1),t=F(r)):t}function Me(e){const t=$(e).filter(r=>r.type!=="adjacent");return F(t)}function He(e){return $(e).filter(t=>t.type==="adjacent").map(t=>t.value)}function Je(e,t,r){const n=new Intl.RelativeTimeFormat(e,{numeric:"auto"}),{offset:a,unit:s,isFuture:i}=ie(t,r);return n.format(a*(i?1:-1),s)}function ie(e,t){const r=new Date(e),n=t?new Date(t):new Date,a=Math.abs(n.getTime()-r.getTime());return{offset:Math.floor(a/(1e3*60*60*24)),unit:"day",isFuture:r>n}}function We(e){const t=e.target;return t&&t.nodeName!=="INPUT"&&t.nodeName!=="TEXTAREA"}function Xe(e){if(e===void 0)return;const{q:t,f:r,p:n,s:a,t:s,n:i,b:l}=P(e),[c]=e.split("?");return{path:c,text:t,filters:r?G(r):void 0,page:n?parseInt(n,10):void 0,sort:a,tab:s,name:i,basket:l}}function Ye(e){if(!e)return"";const{text:t,filters:r,page:n,sort:a,tab:s,name:i,basket:l}=e,c={};t&&(c.q=t),r&&(c.f=JSON.stringify(r)),n&&(c.p=n.toString()),a&&(c.s=a),s&&(c.t=s),i&&(c.n=i),l&&(c.b=l);const f=new URLSearchParams(c).toString();return f||""}function Ke(e){if(e===void 0)return[];const{f:t}=P(e);return G(t)}function G(e){const t=decodeURIComponent(e);try{return JSON.parse(t??"[]")}catch{return console.error(`Error parsing filters from URI: ${e}`),[]}}function P(e){const t=e.split("?")[1];if(t===void 0)return{};const r=new URLSearchParams(t);return Object.fromEntries(r)}function Ze(e){const{q:t=""}=P(e);return t}function Ee(e){const{id:t}=P(e);return decodeURIComponent(t)}function Te(e){const{p:t="0"}=P(e);return parseInt(t,10)}function et(e){const{t}=P(e);return t}function tt(e,t){if(!e)return e;let r=0;const n=e.length;let a=0;if(e[a]==="["){for(;a<n&&/[0-9]/.test(e[a]);)a++;e[a]==="]"&&(r=a+1)}const s=x(e,r,!1);if(!s)return e;const i=t.charCodeAt(0),l=t.charCodeAt(1);let c=s;for(;c;)if(i===c.lang1&&l===c.lang2){const b=x(e,c.end+4,!0);return e.substring(b.start,b.end)}else c=x(e,c.end+4,!1);const f=e.substring(s.start,s.end);return f||e}function x(e,t,r){for(let n=t,a=e.length-3;n<a;n++)if(e[n]==="["&&e[n+3]==="]")return{start:t,end:n,lang1:e.charCodeAt(n+1),lang2:e.charCodeAt(n+2)};if(r)return{start:t,end:e.length,lang1:-1,lang2:-1}}function rt(e,t){const{useLocale:r,useLocaleAsPrefix:n,indexFile:a,path:s,folder:i}=t,l=r?`${e}/`:null,c=n?`${e}.${a}`:a??"";return[s,i,`${l||""}${c}`].filter(f=>f!==void 0).join("/")}function N(e){const t=new CustomEvent("notification",{bubbles:!0,cancelable:!1,detail:e});dispatchEvent(t)}const nt={success:(e,t)=>{N({type:"success",message:e,options:t})},info:(e,t)=>{N({type:"info",message:e,options:t})},warning:(e,t)=>{N({type:"warning",message:e,options:t})},error:(e,t)=>{N({type:"error",message:e,options:t})}};var z=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE",e))(z||{});let q={level:1,enableConsoleOutput:!0};function at(e){q={...q,...e}}function B(e,t,r){if(e<q.level)return;const a=`${`[${z[e]}]`} ${t}`;if(q.enableConsoleOutput)switch(e){case 0:console.debug(a,r||"");break;case 1:console.info(a,r||"");break;case 2:console.warn(a,r||"");break;case 3:console.error(a,r||"");break}}function R(e,t){B(0,e,t)}function k(e,t){B(1,e,t)}function U(e,t){B(2,e,t)}function h(e,t){B(3,e,t)}async function y(e,t="json"){const r=e.headers.get("sinequa-jwt-refresh");if(r!==null&&I(r),e.status===200)switch(t){case"arraybuffer":return await e.arrayBuffer();case"blob":return await e.blob();case"text":return await e.text();default:return await e.json()}if(e.status===401){if(d.userOverrideActive)throw U("Unauthorized access attempt with user override",{endpoint:e.url}),new D("Unauthorized... User override failed.");return await M(e,401)}return e.status===500?(h("Server error occurred",{endpoint:e.url}),await M(e,500)):(U(`Unexpected response status: ${e.status}`,{endpoint:e.url}),await M(e,e.status))}async function M(e,t){try{const{done:r,value:n}=await e.body?.getReader().read()||{done:!0,value:void 0};if(r||!n)throw t===401?new D:t===500?new V:new C(`Request failed with status ${t}`,t);const a=JSON.parse(new TextDecoder().decode(n));throw new Error(a.errorMessage||a.message||`Request failed with status ${t}`,{cause:{errorCode:a.errorCode,errorCodeTest:a.errorCodeTest}})}catch(r){throw r instanceof C?r:t===401?new D(r.message):t===500?new V(r.message):new C(r.message??`Request failed with status ${t}`,t)}}async function ce(e,t,r){const n=L(r?.headers),{backendUrl:a}=d,s=t?`?${new URLSearchParams(t)}`:"",i=a?`${a}/${e}${s}`:`${e}${s}`;R(`Making DELETE request to: ${i}`);try{const l=await fetch(i,{method:"DELETE",credentials:"include",headers:n});return y(l,r?.responseType)}catch(l){throw h("Error making DELETE request:",l),l}}async function S(e,t,r){const n=L(r?.headers),{backendUrl:a}=d,s=t?`?${new URLSearchParams(t)}`:"";e.startsWith("plugin")&&(e=`api/v1/${e}`);const i=a?`${a}/${e}${s}`:`${e}${s}`;R(`Making GET request to: ${i}`);try{const l=await fetch(i,{method:"GET",credentials:"include",headers:n,signal:r?.signal});return y(l,r?.responseType)}catch(l){throw h("Error making GET request:",l),l}}async function le(e,t,r){const n=L(r?.headers);n.append("content-type","application/json");const{app:a,backendUrl:s}=d,i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},l=s?`${s}/${e}`:`${e}`;R(`Making PATCH request to: ${l}`);try{const c=await fetch(l,{method:"PATCH",headers:n,credentials:"include",body:JSON.stringify(i)});return y(c,r?.responseType)}catch(c){throw h("Error making PATCH request:",c),c}}async function u(e,t,r){const n=L(r?.headers),{app:a,backendUrl:s}=d;n.has("Content-Type")||n.set("Content-Type","application/json");const i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0};e.startsWith("plugin")&&(e=`api/v1/${e}`);const l=s?`${s}/${e}`:`${e}`;R(`Making POST request to: ${l}`);try{const c=await fetch(l,{method:"POST",headers:n,credentials:"include",body:JSON.stringify(i),signal:r?.signal});return y(c,r?.responseType)}catch(c){throw h("Error making POST request:",c),c}}async function ot(e,t,r){const n=L(r?.headers),{app:a,backendUrl:s}=d,i={app:a,...t,locale:t.locale||navigator.language,noUserOverride:!0,noAutoAuthentication:!0},l=`${s}/${e}`;R(`Making PUT request to: ${l}`);try{const c=await fetch(l,{method:"PUT",headers:n,credentials:"include",body:JSON.stringify(i)});return y(c,r?.responseType)}catch(c){throw h("Error making PUT request:",c),c}}function st(e){const t=new AbortController,{signal:r}=t;return e&&setTimeout(()=>{r.aborted||t.abort(new Z(`Request timed out after ${e}ms`))},e),{controller:t,signal:r}}function H(e){if(!e)return;const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t}function it(e){const t=H(e);return!!t&&t.getTime()<=Date.now()}function ct(e,t=7){const r=H(e);if(!r)return!1;const n=Date.now(),a=n+t*24*60*60*1e3,s=r.getTime();return s>n&&s<=a}async function lt(e,t=0,r=1e3){let n;for(let a=0;a<=t;a++)try{return await e()}catch(s){if(n=s,s instanceof C&&s.status>=400&&s.status<500&&s.status!==429||s instanceof DOMException&&s.name==="AbortError")throw s;a<t&&(U(`Retrying request (${a+1}/${t})`,{error:s}),await new Promise(i=>setTimeout(i,r)))}throw n}function ut(e,t,r){if(!e||!t)return;if(r){const s=Object.keys(t.queries).find(c=>c===r?.toLowerCase());let i;s&&(i=t.queries[s]);const l=(i?.columnsInfo?.columns||[])?.find(c=>c.aliases?.split(",")?.includes(e));if(l)return l.name}const n=t.indexes?._?.columns,a=Object.entries(n).find(s=>s[1].aliases?.includes(e));if(a)return a[0]}var v=(e=>(e.None="None",e.Search_FirstPage="Search_FirstPage",e.Search_Text="Search_Text",e.Search_Refine="Search_Refine",e.Search_Select_Item="Search_Select_Item",e.Search_Select_Custom="Search_Select_Custom",e.Search_Select_Concept="Search_Select_Concept",e.Search_Select_Correction="Search_Select_Correction",e.Search_GotoPage="Search_GotoPage",e.Search_GotoTab="Search_GotoTab",e.Search_DisplayResult="Search_DisplayResult",e.Search_RemoveResult="Search_RemoveResult",e.Search_RemoveAdvanced="Search_RemoveAdvanced",e.Search_SavedQuery="Search_SavedQuery",e.Search_WebService="Search_WebService",e.Search_DidYouMean_Original="Search_DidYouMean_Original",e.Search_DidYouMean_Correction="Search_DidYouMean_Correction",e.Search_ExportCSV="Search_ExportCSV",e.Search_SavedQuery_ExportCSV="Search_SavedQuery_ExportCSV",e.Search_Selection_ExportCSV="Search_Selection_ExportCSV",e.Search_AlertQuery="Search_AlertQuery",e.Search_Select_AnalyticsItem="Search_Select_AnalyticsItem",e.Search_Sort="Search_Sort",e.Search_Exit_Logout="Search_Exit_Logout",e.Search_Timeline_Usage="Search_Timeline_Usage",e.Search_AutoComplete="Search_Autocomplete",e.Search_Login_Success="Login_Success_Form",e.Search_QueryIntent_Detected="Search_QueryIntent_Detected",e.SavedQuery_Add="SavedQuery_Add",e.SavedQuery_Delete="SavedQuery_Delete",e.SavedQuery_DeleteAll="SavedQuery_DeleteAll",e.SavedQuery_Rename="SavedQuery_Rename",e.Alert_Edit="Alert_Edit",e.Alert_Delete="Alert_Delete",e.Alert_DeleteAll="Alert_DeleteAll",e.Link_Display="Link_Display",e.Link_Click="Link_Click",e.Basket_Add="Basket_Add",e.Basket_Delete="Basket_Delete",e.Basket_DeleteAll="Basket_DeleteAll",e.Basket_Rename="Basket_Rename",e.Basket_AddDoc="Basket_AddDoc",e.Basket_RemoveDoc="Basket_RemoveDoc",e.Basket_Open="Basket_Open",e.Basket_ExportCSV="Basket_ExportCSV",e.Label_Add="Label_Add",e.Label_Delete="Label_Delete",e.Label_Rename="Label_Rename",e.Label_Open="Label_Open",e.Label_AddDoc="Label_AddDoc",e.Label_RemoveDoc="Label_RemoveDoc",e.Label_ExportCSV="Label_ExportCSV",e.Label_Menu_ExportCSV="Label_Menu_ExportCSV",e.Rating_Set="Rating_Set",e.Rating_Delete="Rating_Delete",e.Doc_Preview="Doc_Preview",e.Doc_CacheHtml="Doc_CacheHtml",e.Doc_CachePdf="Doc_CachePdf",e.Doc_CacheOriginal="Doc_CacheOriginal",e.Doc_Url1="Doc_Url1",e.Doc_Url2="Doc_Url2",e.Preview_Close="Preview_Close",e.Click_ResultLink="Click_ResultLink",e.Click_ResultLink1="Click_ResultLink1",e.Click_ResultLink2="Click_ResultLink2",e.Click_ResultLink3="Click_ResultLink3",e.Click_ResultLink4="Click_ResultLink4",e.Click_ResultLink5="Click_ResultLink5",e.Click_ResultLink6="Click_ResultLink6",e.Click_ResultLink7="Click_ResultLink7",e.Click_ResultLink8="Click_ResultLink8",e.Click_ResultLink9="Click_ResultLink9",e.Click_ResultLink10="Click_ResultLink10",e.Click_PreviewLink1="Click_PreviewLink1",e.Click_PreviewLink2="Click_PreviewLink2",e.Click_PreviewLink3="Click_PreviewLink3",e.Click_PreviewLink4="Click_PreviewLink4",e.Click_PreviewLink5="Click_PreviewLink5",e.Click_PreviewLink6="Click_PreviewLink6",e.Click_PreviewLink7="Click_PreviewLink7",e.Click_PreviewLink8="Click_PreviewLink8",e.Click_PreviewLink9="Click_PreviewLink9",e.Click_PreviewLink10="Click_PreviewLink10",e.RFM_ClickSet="RFM_ClickSet",e.RFM_ClickReset="RFM_ClickReset",e.RFM_Like="RFM_Like",e.RFM_LikeReset="RFM_LikeReset",e.RFM_Dislike="RFM_Dislike",e.RFM_Important="RFM_Important",e.RFM_ImportantReset="RFM_ImportantReset",e.RFM_Ban="RFM_Ban",e.Navigation_Exit="Navigation_Exit",e.Navigation_Return="Navigation_Return",e.Navigation_Route="Navigation_Route",e.Answer_Display="Answer_Display",e.Answer_Click="Answer_Click",e.Answer_Result="Answer_Result",e.Answer_Liked="Answer_Liked",e.Answer_Disliked="Answer_Disliked",e.Answer_Liked_Cancelled="Answer_Liked_Cancelled",e.Answer_Disliked_Cancelled="Answer_Disliked_Cancelled",e.TopPassages_Display="TopPassages_Display",e.TopPassages_Click="TopPassages_Click",e.UserSettings_Reset="UserSettings_Reset",e))(v||{}),g=(e=>(e[e.none=0]="none",e[e.bool=1]="bool",e[e.date=2]="date",e[e.dateTime=3]="dateTime",e[e.time=4]="time",e[e.unsigned=5]="unsigned",e[e.integer=6]="integer",e[e.float=7]="float",e[e.double=8]="double",e[e.dates=9]="dates",e[e.dateTimes=10]="dateTimes",e[e.times=11]="times",e[e.varchar=12]="varchar",e[e.binary=13]="binary",e[e.string=14]="string",e[e.csv=15]="csv",e))(g||{}),_=(e=>(e[e.none=0]="none",e[e.a=2053]="a",e[e.c=4]="c",e[e.d=8]="d",e[e.e=2068]="e",e[e.i=256]="i",e[e.l=2052]="l",e[e.n=8192]="n",e[e.t=524292]="t",e[e.x=8388608]="x",e[e.z=33554432]="z",e[e.f_ordinal=8192]="f_ordinal",e[e.f_multidates=8192]="f_multidates",e[e.f_varchar=33554432]="f_varchar",e[e.f_binary=33562624]="f_binary",e[e.f_string=33562888]="f_string",e[e.f_csv=42477853]="f_csv",e[e.f_overridable=33554696]="f_overridable",e))(_||{});const dt="1.0";var ue=(e=>(e[e.Original=0]="Original",e[e.Corrected=1]="Corrected",e))(ue||{}),de=(e=>(e[e.none=0]="none",e[e.positiveRate=1]="positiveRate",e[e.mainlyPosRate=2]="mainlyPosRate",e[e.unrate=4]="unrate",e[e.mainlyNegRate=8]="mainlyNegRate",e[e.negativeRate=16]="negativeRate",e[e.all=31]="all",e[e.positiveOnly=7]="positiveOnly",e[e.negativeOnly=28]="negativeOnly",e[e.personalAll=21]="personalAll",e[e.personalPosOnly=5]="personalPosOnly",e[e.personalNegOnly=20]="personalNegOnly",e))(de||{});function ft(e){if(!e)return g.none;switch(e.toLocaleLowerCase()){case"bool":case"boolean":return g.bool;case"date":return g.date;case"datetime":return g.dateTime;case"time":return g.time;case"unsigned":return g.unsigned;case"integer":return g.integer;case"float":return g.float;case"double":return g.double;case"dates":return g.dates;case"datetimes":return g.dateTimes;case"times":return g.times;case"varchar":return g.varchar;case"binary":return g.binary;case"string":return g.string;case"csv":return g.csv;default:return g.none}}function ht(e){switch(e){case"a":return _.a;case"c":return _.c;case"d":return _.d;case"e":return _.e;case"i":return _.i;case"l":return _.l;case"n":return _.n;case"t":return _.t;case"x":return _.x;case"z":return _.z;default:return _.none}}function gt(e){let t=_.none;if(e)for(const r of e)t|=ht(r);return t}function w(e,t,r,n){const a=ft(t),s=gt(r||"");return{name:e,type:t,typeModifier:r,eType:a,eTypeModifier:s,aliases:n}}const mt={id:w("id","string"),text:w("text","varchar"),documentlanguages:w("documentlanguages","csv","ci",["language"]),databasealias:w("databasealias","varchar"),globalrelevance:w("globalrelevance","double"),matchingpartnames:w("matchingpartnames","csv"),matchlocations:w("matchlocations","csv"),matchlocationsperpartname:w("matchlocationsperpartname","varchar"),extracts:w("extracts","csv"),extractsperpartname:w("extractsperpartname","varchar"),extractslocations:w("extractslocations","csv"),documentweight:w("documentweight","varchar"),groupcount:w("groupcount","integer"),accesslists:w("accesslists","varchar",void 0,["accessLists"])};function wt(e,t){let r=e[t];return r===void 0?[]:(typeof r=="string"&&(r=String(r).split(",")),Array.isArray(r)?r.map(n=>{if(typeof n=="string")return n.trim();if(typeof n=="object"&&n!==null&&"display"in n)return n.display.trim()}).filter(n=>n!==void 0):[String(r).trim()])}function St(e,t){let r=e[t];if(r===void 0)return[];if(typeof r=="string"&&(r=String(r).split(",")),Array.isArray(r))return r.map(a=>{if(typeof a=="string")return{display:a.trim(),value:a.trim()};if(typeof a=="object"&&a!==null&&"display"in a){const s=a.display.trim(),i="value"in a?String(a.value).trim():s;return{display:s,value:i}}}).filter(a=>a!==void 0);const n=String(r).trim();return[{display:n,value:n}]}function A(e){return e!==null&&typeof e=="object"}function fe(e){return A(e)&&Object.prototype.toString.call(e)==="[object ArrayBuffer]"}function he(e){return A(e)&&Object.prototype.toString.call(e)==="[object Blob]"}function ge(e){return Object.prototype.toString.call(e)==="[object Date]"}function me(e){return typeof e=="string"}function _t(e){return(A(e)||Array.isArray(e))&&!fe(e)&&!he(e)&&!me(e)}function we(e){return e?(e.getHours()*60*60+e.getMinutes()*60+e.getSeconds())*1e3+e.getMilliseconds():0}function Se(e=!0){let t=Date.now();return(e?"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx":"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g,n=>{const a=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(n==="x"?a:a&3|8).toString(16)})}function pt(e){if(!e)return"``";if(e=String(e),e.search(/[\\`]/)===-1)return`\`${e}\``;const t=["`"];for(let r=0,n=e.length;r<n;r++){const a=e[r];(a==="\\"||a==="`")&&t.push("\\"),t.push(a)}return t.push("`"),t.join("")}function kt(e){if(typeof crypto<"u"&&crypto.subtle&&typeof crypto.subtle.digest=="function")try{return crypto.subtle.digest("SHA-512",new TextEncoder().encode(e)).then(t=>Array.prototype.map.call(new Uint8Array(t),r=>`00${r.toString(16)}`.slice(-2)).join("")).catch(()=>Promise.resolve(J(e)))}catch{return Promise.resolve(J(e))}return Promise.resolve(J(e))}function J(e){let n=2166136261;for(let b=0;b<e.length;b++)n^=e.charCodeAt(b),n=n*16777619>>>0;const a=n.toString(16).padStart(8,"0"),s=((n^2863311530)>>>0).toString(16).padStart(8,"0"),i=((n^1431655765)>>>0).toString(16).padStart(8,"0"),l=((n^3435973836)>>>0).toString(16).padStart(8,"0"),c=a+s+i+l;return(c+c+c+c).substring(0,128)}let W,_e;function O(e,t=!0){let r=bt(e.$auditRecord);r&&(pe(r),t&&ke(r)),e.$auditRecord=r}function bt(e){if(!e)return;let t;if(Array.isArray(e))t=e;else if(A(e)){const r=e;if(r.auditEvents||r.mlAuditEvents)return r;t=[e]}return{auditEvents:t}}function pe(e){const t=vt();return e.auditEvents?.forEach(r=>{r.detail||(r.detail={}),r.detail.sessionid=t}),e}function ke(e){const t=typeof window<"u"?decodeURIComponent(window.location.href):"http://localhost";return e?.auditEvents?.forEach(r=>{r.detail||(r.detail={}),r.detail.url=t}),e}function vt(){return(!W||Ct())&&(W=Se()),_e=new Date,W}function Ct(){return new Date().getTime()-_e.getTime()>600*1e3}async function yt(e,t=!0){const r={event:v.None,$auditRecord:e};return O(r,t),u("api/v1/audit.notify",r)}const Pt={notify:yt};async function Rt(e,t,r){const n=e.items?.length||0,a=10,s={query:{...t,action:"aggregate",aggregations:{[e.name]:{skip:n,count:a}}},$auditRecord:{auditEvents:[r]}};O(s);const i=await u("api/v1/query",s),l=await y(i),{aggregations:c}=l,f=c[0];return f.$hasMore=f.items.length>a,f.items=[...e.items,...f.items],Promise.resolve(f)}async function Lt(){const{app:e}=d,t=new URLSearchParams({app:e||""});return S("api/v1/app",t)}async function be(){const{app:e}=d,t=new URLSearchParams({app:e||"",preLogin:"true"});return S("api/v1/app",t)}function Ut(){let{backendUrl:e,app:t,useCredentials:r}=d;if(typeof window<"u"){if(e||(e=window.location.origin),!t){const n=window.location.pathname.match(/\/app(?:-debug)?\/([^/#]+)/);n&&(t=n[1])}p({...d,backendUrl:e,app:t})}return r?(p({...d,useCredentials:!0,useSSO:!1,autoOAuthProvider:void 0,autoSAMLProvider:void 0,bearerToken:void 0,useSAML:void 0}),Promise.resolve({})):be().then(n=>{const{autoOAuthProvider:a,autoSAMLProvider:s}=d,i=!a&&!n.autoOAuthProvider&&!s&&!n.autoSAMLProvider;return p({...d,autoOAuthProvider:a||n.autoOAuthProvider,autoSAMLProvider:s||n.autoSAMLProvider,useCredentials:i,useSSO:i}),n}).catch(n=>{throw h("atomic:fetchAppPreLogin error",n),n})}async function Ot(e,t,r={}){const n=`api/v1/search.dataset/${e}/${t}`,a=await u(n,{parameters:r}),s=t[0].toLowerCase()+t.slice(1),i=a.datasets[s];if("errorCode"in i&&"errorMessage"in i)throw new Error(i.errorMessage);return i}async function $t(e,t){const r=`api/v1/search.dataset/${e}`,{parameters:n={},datasets:a=[]}=t;return(await u(r,{parameters:n,datasets:a})).datasets}async function At(e){return await S(`api/v1/search.dataset/${e}`)}async function It(e,t=!0,r){try{return(await u("api/v1/labels",{action:"list",q:e,public:t,locale:r,localize:!1})).labels}catch(n){throw h("Error in fetchLabels",n),n}}async function Dt(){try{const{app:e=""}=d,t=new URLSearchParams({app:e,action:"getUserRights"});return S("api/v1/labels",t)}catch(e){throw h("Error in getUserRights",e),e}}async function Ft(e,t,r=!0){try{const n={action:"add",labels:e,ids:t,public:r,$auditRecord:{auditEvents:[{type:v.Label_AddDoc,detail:{public:r,label:e?e.toString():null,doccount:t?t.length:0}}],mlAuditEvents:[{actionType:"addToLabel",documentIds:t}]}};return u("api/v1/labels",n)}catch(n){throw h("Error in add",n),n}}async function Nt(e,t,r=!0){try{const n={action:"remove",labels:e,ids:t,public:r,$auditRecord:{auditEvents:[{type:v.Label_RemoveDoc,detail:{public:r,label:e?e.toString():null,doccount:t?t.length:0}}],mlAuditEvents:[{actionType:"removeFromLabel",documentIds:t}]}};return u("api/v1/labels",n)}catch(n){throw h("Error in remove",n),n}}async function qt(e,t,r=!0){try{const n={action:"rename",labels:e,newLabel:t,public:r,auditEvents:{type:v.Label_Rename,detail:{public:r,oldlabel:e?e.toString():null,label:t}}};return u("api/v1/labels",n)}catch(n){throw h("Error in rename",n),n}}async function Bt(e,t=!0){try{const r={action:"delete",labels:e,public:t,auditEvents:{type:v.Label_Delete,detail:{public:t,label:e?e.toString():null}}};return u("api/v1/labels",r)}catch(r){throw h("Error in deleteLabels",r),r}}async function Qt(e,t,r=!0){try{const n={action:"bulkAdd",labels:e,query:t,public:r,auditEvents:{type:v.Label_Add,detail:{public:r,label:e?e.toString():null,query:t!==null?t.name:null}}};return u("api/v1/labels",n)}catch(n){throw h("Error in bulkAdd",n),n}}async function jt(e,t,r=!0){try{const n={action:"bulkRemove",labels:e,query:t,public:r,auditEvents:{type:v.Label_Delete,detail:{public:r,label:e?e.toString():null,query:t!==null?t.name:null}}};return u("api/v1/labels",n)}catch(n){throw h("Error in bulkRemove",n),n}}const Vt={getUserRights:Dt,add:Ft,remove:Nt,rename:qt,delete:Bt,bulkAdd:Qt,bulkRemove:jt};async function Gt(e,t){if(typeof window>"u")return u("api/v1/preview",{action:"get",id:e,query:t});const r=`${window.location.origin}${window.location.pathname}`,n={name:t?.name,text:t?.text};return u("api/v1/preview",{action:"get",id:e,query:n,browserUrl:r})}async function xt(e){const t=new Headers;t.append("content-type","text");const r=await fetch(e,{method:"GET",headers:t});y(r)}async function X(){const e=new URLSearchParams({action:"get",noAutoAuthentication:"true"});return S("api/v1/principal",e)}async function ve(e){const t={noAutoAuthentication:"true",...e},r=new URLSearchParams;return Object.entries(t).forEach(([n,a])=>{a!==void 0&&r.append(n,String(a))}),S("api/v1/principal/list",r)}async function Ce(e){if(!e)return Promise.reject(new Error("userid is required"));const t=new URLSearchParams({action:"userid",noAutoAuthentication:"true",userid:e});return S("api/v1/principal",t)}async function ye(e){if(e.length===0)return Promise.reject(new Error("userids is required"));const t=new URLSearchParams({noAutoAuthentication:"true",userids:[...e].join(",")});return S("api/v1/principal/userids",t)}const zt={principal:{get:X,list:ve,userid:Ce,userids:ye}},Pe=11;async function Mt(e,t,r){const a=await u("api/v1/query",{query:e,$auditRecord:t,queryIntentData:r});a.aggregations.forEach(i=>{i.$hasMore=!1,!i.isDistribution&&!i.isTree&&i.items&&(i.$hasMore=i.items.length===Pe),i.isTree&&i.items&&Q(i)}),a.records?.map(i=>Object.assign(i,{value:i.title,type:"default"}));const s={...a,nextPage:a.page<Math.ceil(a.rowCount/a.pageSize)?a.page+1:void 0,previousPage:a.page>1?a.page-1:void 0};return Promise.resolve(s)}async function Ht(e,t,r){const{app:n=""}=d,a={methods:[],mode:t,propagateErrors:!0,$auditRecord:{auditEvents:[r]}};for(const l of e)a.methods.push({method:"query",app:n,query:l});const s=await u("api/v1/multi",a);s.results.forEach(l=>{l.aggregations.forEach(c=>{c.$hasMore=!1,!c.isDistribution&&!c.isTree&&c.items&&(c.$hasMore=c.items.length===Pe),c.isTree&&Q(c)})}),s.results.forEach(l=>l.records?.map(c=>Object.assign(c,{value:c.title,type:"default"})));const i=s.results.map(l=>({...l,nextPage:l.page<Math.ceil(l.rowCount/l.pageSize)?l.page+1:void 0,previousPage:l.page>1?l.page-1:void 0}));return Promise.resolve(i)}function Q(e,t="",r=0){let n=[];return e.items&&e.items.forEach(a=>{let s=t?`${t}/${a.value}`:a.value,i=r+1;n.push({path:s,level:i}),a.$path=s,a.$level=i,a.hasChildren?n=n.concat(Q(a,s,i)):a.hasChildren=!1}),n}async function Jt({model:e,appName:t,query:r,article:n}){const{webservice:a,format:s,maxcount:i,exportedColumns:l,export:c}=e,f={app:t,webservice:a,query:r,type:c,format:s,maxcount:i,exportedColumns:l,$auditRecord:{auditEvents:[{type:"Search_ExportCSV",detail:{resultid:n?n.id:void 0}}]}};return O(f),await u("api/v1/search.queryexport",f,{responseType:"blob"})}async function Wt(e){return(await u("api/v1/queryintent",{query:e}))?.intents}async function Xt(e,t,r){return(await u("api/v1/similardocuments",{sourceDocumentId:e,query:{name:t}},{signal:r})).data}async function Yt(e,t){return(await u("api/v1/query.links",{webservice:e,query:t}))?.links?.map(a=>({...a,query:t}))}function Kt(e,t){if(typeof e=="number")return`${e}`;if(ge(e))return Zt(e);if(typeof e=="boolean")return e?"true":"false";if(e===null)return"null";if(Array.isArray(e)){const r=[];return e.forEach(n=>{r.length>0&&r.push(","),n?typeof n=="string"?r.push(n):r.push(n.display||n.value||""):r.push("null")}),r.splice(0,0,"["),r.push("]"),r.join("")}return e}function Zt(e){if(!e)return"";try{if(we(e)===0)return new Intl.DateTimeFormat("en-CA",{year:"numeric",month:"2-digit",day:"2-digit"}).format(e);{const t=new Intl.DateTimeFormat("en-CA").format(e),r=new Intl.DateTimeFormat("en-CA",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(e);return`${t} ${r}`}}catch{return"Invalid date"}}async function Et(e,t,r,n,a){const{app:s}=d,i={app:s||"",suggestQuery:e,text:t,filter:r,kinds:n,showSource:a};try{return(await u("api/v1/search.suggest",i)).suggests}catch(l){throw console.error("Error fetching suggestions:",l),l}}async function Tt(e,t,r,n){const{app:a}=d;return(await u("api/v1/suggestquery",{app:a||"",suggestQuery:e,text:t,query:r,kinds:n})).suggests}async function er(e,t,r){if(!t)return Promise.resolve([]);const{app:n}=d,s=await u("api/v1/suggestfield",{app:n||"",text:e,fields:t,query:r});return s.suggests.forEach(i=>{i.display=Kt(i.display)}),s.suggests}async function tr(e,t,r,n,a,s){return u("api/v1/doc.textchunks",{id:e,textChunks:t,highlights:r,query:n,leftSentencesCount:a,rightSentencesCount:s})}async function rr(){const{app:e}=d,t=new URLSearchParams({app:e||"",action:"load"});return S("api/v1/usersettings",t)}async function Re(e,t){const r={action:"save",userSettings:e,$auditRecord:{auditEvents:[t]}};return O(r),u("api/v1/usersettings",r)}async function nr(e,t){const n={action:"patch",userSettings:e,$auditRecord:t?{auditEvents:[t]}:void 0};return O(n),u("api/v1/usersettings",n)}async function ar(){return Re({},{type:"UserSettings_Reset"})}async function or(e,t){return u("api/v2/security/password/change",{newPassword:e,currentPassword:t})}async function sr(e){const t="api/v2/security/password/ask-reset-email",n={changePasswordRedirectUrl:`${window.location.origin}/login?mode=changepassword`,userName:e};return u(t,n)}async function ir(e){return await S(`api/v2/user-profile/${e}`)}async function cr(e){return await u("api/v2/user-profile",e)}async function lr(e,t,r){return await le(`api/v2/user-profile/${e.data?.id}/${t}/${r}`,e)}async function ur(e,t,r){try{return(await ce(`api/v2/user-profile/${e.data?.id}/${t}/${r}`)).success===!0}catch{return!1}}async function dr(){return await S("api/v2/version")}const Le=async()=>{const{autoOAuthProvider:e}=d;if(typeof window>"u")return u("security.oauth",{action:"getcode",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"});const t={action:"getcode",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const r=await u("api/v1/security.oauth",t);return r.redirectUrl&&(window.location.href=r.redirectUrl),r}catch(r){throw console.error("Failed to authenticate with OAuth",r),r}},Ue=async()=>{const{autoSAMLProvider:e}=d;if(typeof window>"u")return u("security.saml",{action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:"http://localhost"});const t={action:"getresponse",provider:e,tokenInCookie:!0,originalUrl:window.location.href};try{const r=await u("api/v1/security.saml",t);return r.redirectUrl&&(window.location.href=r.redirectUrl),r}catch(r){throw console.error("Failed to authenticate with SAML",r),r}},Y={store:{},getItem(e){return this.store[e]??null},setItem(e,t){this.store[e]=t.toString()},removeItem(e){delete this.store[e]},clear(){this.store={}}},K=Y;function fr(e){return typeof window>"u"||!window.localStorage?Y.getItem(e):window.localStorage.getItem(e)}function hr(e){typeof window>"u"||!window.localStorage?Y.removeItem(e):window.localStorage.removeItem(e)}function gr(e){return typeof window>"u"||!window.sessionStorage?K.getItem(e):window.sessionStorage.getItem(e)}function mr(e,t){typeof window>"u"||!window.sessionStorage?K.setItem(e,t):window.sessionStorage.setItem(e,t)}function wr(e){typeof window>"u"||!window.sessionStorage?K.removeItem(e):window.sessionStorage.removeItem(e)}const I=e=>mr("sinequa-credentials",JSON.stringify({data:{csrfToken:e}})),Oe=async()=>{try{const e=await S("api/v1/challenge?action=getCsrfToken&suppressErrors=true");return e?.csrfToken?(I(e.csrfToken),e.csrfToken):null}catch(e){throw h("Failed to get CSRF token",e),e}};async function $e(e){if(e){const{username:t,password:r}=e,n={action:"get",tokenInCookie:!0,user:t,password:r,noUserOverride:!0,noAutoAuthentication:!0};try{const a=await u("api/v1/security.webtoken",n);return a?.csrfToken?(I(a.csrfToken),a.csrfToken):null}catch(a){throw console.error("Failed to get JWT",a),a}}else{const t={action:"get",tokenInCookie:!0,noUserOverride:!0,noAutoAuthentication:!1},{bearerToken:r}=d;if(!r)throw new Error("Bearer token is required in globalConfig for credentialless JWT retrieval.");const n=new Headers;n.append("Sinequa-Force-Camel-Case","true"),n.append("accept","application/json"),n.append("Content-Type","application/json"),n.append("Authorization",`Bearer ${r}`);try{const a=await u("api/v1/security.webtoken",t,{headers:n});return a.csrfToken?(I(a.csrfToken),a.csrfToken):null}catch(a){throw console.error("Failed to get JWT without credentials",a),a}}}const j=()=>{const e=gr("sinequa-credentials");if(e)try{const n=JSON.parse(e).data?.csrfToken;if(n!==void 0)return n}catch{}const t=fr("csrfToken");return t!==null?t:null},Sr=async e=>{if(e)k("Attempting authentication using credentials"),p({useCredentials:!0,useSSO:!1});else{let l=null;try{k("Attempting to retrieve CSRF token from the backend"),l=await Oe(),R("CSRF token retrieval result",l?"success":"failed")}catch(c){h("Failed to retrieve CSRF token",c)}try{if(l===null){const{autoOAuthProvider:c,autoSAMLProvider:f,useSAML:b}=d;if(c&&!b)return k("Initiating OAuth authentication flow"),await Le(),U("OAuth authentication flow did not redirect as expected"),m(!1),!1;if(f)return k("Initiating SAML authentication flow"),await Ue(),U("SAML authentication flow did not redirect as expected"),m(!1),!1;k("No direct authentication method available, will try SSO then credentials"),p({useCredentials:!0,useSSO:!0})}else return k("User authenticated via existing token"),m(!0),!0}catch(c){throw h("Unexpected error during authentication",c),m(!1),c}}if(d.useCredentials&&d.useSSO)try{if(k("Checking if user is authenticated via SSO"),await X())return k("User authenticated using SSO"),p({useCredentials:!1,useSSO:!0}),m(!0),!0}catch(l){if(l?.status===401)return k("SSO authentication failed with 401, falling back to credentials"),p({useCredentials:!0,useSSO:!1}),!1;throw h("SSO authentication failed with unexpected error",l),m(!1),h}const{useSSO:r}=d,n=j();if(n&&n!==null||r)return k("user already authenticated",n),p({isRedirectUrl:!1}),m(!0),!0;const{useCredentials:a}=d,{username:s,password:i}=e||{};if(a&&!s&&!i)return h("Credentials are required for authentication"),m(!1),!1;if(s&&i)try{k("authentication using credentials..."),p({useCredentials:!0,useSSO:!1});const{userOverrideActive:l,useroverride:c}=d;return p({userOverrideActive:!1,useroverride:void 0}),await $e({username:s,password:i}),p({userOverrideActive:l,useroverride:c}),m(!0),!0}catch(l){throw m(!1),l}return m(!1),h("No authentication method available. Please provide credentials or configure OAuth/SAML."),!1},Ae=async()=>{const e=new URLSearchParams({action:"deleteWebTokenCookie",noUserOverride:"true",noAutoAuthentication:"true"});return S("api/v1/challenge",e)},_r=async()=>{const{useCredentials:e,userOverrideActive:t}=d;hr("csrfToken"),wr("sinequa-credentials"),e&&!t?(await Ae()).methodresult==="ok"?m(!1):console.error("logout failed"):m(!1)},pr=()=>!!j();o.API=zt,o.ApiError=C,o.Audit=Pt,o.AuditEventType=v,o.DidYouMeanKind=ue,o.EngineType=g,o.EngineTypeModifier=_,o.LogLevel=z,o.MINIMUM_COMPATIBLE_SERVER_API_VERSION=dt,o.RFMDisplay=de,o.ServerError=V,o.TimeoutError=Z,o.UnauthorizedError=D,o.addAuditAdditionalInfo=O,o.addConcepts=xe,o.addSessionId=pe,o.addUrl=ke,o.aggItemRegex=E,o.aggregationItemStrictCompare=De,o.appInitializerFn=Ut,o.bisect=Ne,o.buildPathsAndLevels=Q,o.configureLogger=at,o.createHeaders=L,o.createTimeoutController=st,o.createUserProfile=cr,o.debug=R,o.del=ce,o.deleteUserProfileProperty=ur,o.deleteUserSettings=ar,o.deleteWebTokenCookie=Ae,o.emitAuthenticatedEvent=m,o.error=h,o.escapeExpr=pt,o.expiresSoon=ct,o.extraColumns=mt,o.fetchAggregation=Rt,o.fetchApp=Lt,o.fetchAppPreLogin=be,o.fetchBulkQuery=Ht,o.fetchChangePassword=or,o.fetchDataset=Ot,o.fetchDatasetList=At,o.fetchDatasets=$t,o.fetchLabels=It,o.fetchPreview=Gt,o.fetchPreviewUrl=xt,o.fetchPrincipal=X,o.fetchPrincipalList=ve,o.fetchPrincipalUserid=Ce,o.fetchPrincipalUserids=ye,o.fetchQuery=Mt,o.fetchQueryExport=Jt,o.fetchQueryIntent=Wt,o.fetchSendPasswordResetEmail=sr,o.fetchSimilarDocuments=Xt,o.fetchSponsoredLinks=Yt,o.fetchSuggest=Et,o.fetchSuggestField=er,o.fetchSuggestQuery=Tt,o.fetchTextChunks=tr,o.fetchUserProfile=ir,o.fetchUserSettings=rr,o.fetchVersion=dr,o.get=S,o.getConcepts=He,o.getCsrfToken=Oe,o.getFiltersFromURI=G,o.getFiltersFromUrl=Ke,o.getHelpIndexUrl=rt,o.getIdFromUrl=Ee,o.getJWToken=$e,o.getMetadata=wt,o.getMetadataWithValues=St,o.getOffsetFromDates=ie,o.getQueryPageFromUrl=Te,o.getQueryParamsFromUrl=Xe,o.getQueryTabFromUrl=et,o.getQueryTextFromUrl=Ze,o.getRelativeDate=Je,o.getTime=we,o.getToken=j,o.getUrlParamsFromQueryParams=Ye,o.globalConfig=d,o.guid=Se,o.handleResponse=y,o.info=k,o.isArrayBuffer=fe,o.isAuthenticated=pr,o.isBlob=he,o.isDate=ge,o.isExpired=it,o.isJsonable=_t,o.isNotInputEvent=We,o.isObject=A,o.isString=me,o.labels=Vt,o.login=Sr,o.logout=_r,o.makeColumn=w,o.notify=nt,o.openParentNodes=ee,o.parseText=$,o.parseValueAndOperatorFromItem=T,o.patch=le,o.patchUserProfile=lr,o.patchUserSettings=nr,o.post=u,o.put=ot,o.queryParamsFromUrl=P,o.removeConcept=ze,o.removeConcepts=Me,o.resolveToColumnName=ut,o.rewriteText=F,o.saveUserSettings=Re,o.setGlobalConfig=p,o.setToken=I,o.sha512=kt,o.suggestionsToTreeAggregationNodes=Fe,o.sysLang=tt,o.toDate=H,o.translateAggregationToDateOptions=Ie,o.tryOAuthAuthentication=Le,o.trySAMLAuthentication=Ue,o.warn=U,o.withRetry=lt,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/helpers/utils.d.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
export declare function isObject(value: unknown): boolean;
|
|
2
2
|
export declare function isArrayBuffer(value: unknown): boolean;
|
|
3
3
|
export declare function isBlob(value: unknown): boolean;
|
|
4
|
+
export declare function isDate(value: unknown): value is Date;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use typeof value === "string"
|
|
7
|
+
*/
|
|
4
8
|
export declare function isString(value: unknown): boolean;
|
|
5
9
|
export declare function isJsonable(obj: unknown): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Converts a `Date` to a Sinequa system date string (`dd-mm-yyyy[ hh:mm:ss]`)
|
|
12
|
+
* If the time component of the date is 0 then only the date portion of the string is included
|
|
13
|
+
*
|
|
14
|
+
* @param date The `Date` to convert
|
|
15
|
+
*/
|
|
16
|
+
export declare function getTime(date: Date): number;
|
|
6
17
|
/**
|
|
7
18
|
* Return a pseudo-GUID value using `Math.random`
|
|
8
19
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/helpers/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhD;AACD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/helpers/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhD;AACD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKrD;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAI9C;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AACD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhD;AACD,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAOhD;AACD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAS1C;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,WAAW,UAAO,GAAG,MAAM,CAY/C;AAED;;;;;;GAMG;AAIH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAkB5D;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Conversion.d.ts","sourceRoot":"","sources":["../../../src/types/preview/Conversion.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Article } from "../search";
|
|
2
|
+
import { Conversion } from "./Conversion";
|
|
2
3
|
import { HighlightDataPerCategory } from "./HighlightDataPerCategory";
|
|
3
4
|
import { HighlightDataPerLocation } from "./HighlightDataPerLocation";
|
|
4
5
|
/**
|
|
@@ -11,5 +12,6 @@ export type PreviewData = {
|
|
|
11
12
|
highlightsPerCategory: HighlightDataPerCategory;
|
|
12
13
|
highlightsPerLocation: HighlightDataPerLocation[];
|
|
13
14
|
documentCachedContentUrl: string;
|
|
15
|
+
conversions: Conversion[];
|
|
14
16
|
};
|
|
15
17
|
//# sourceMappingURL=PreviewData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewData.d.ts","sourceRoot":"","sources":["../../../src/types/preview/PreviewData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;GAEG;AAEH,MAAM,MAAM,WAAW,GAAG;
|
|
1
|
+
{"version":3,"file":"PreviewData.d.ts","sourceRoot":"","sources":["../../../src/types/preview/PreviewData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;GAEG;AAEH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB,EAAE,wBAAwB,CAAC;IAChD,qBAAqB,EAAE,wBAAwB,EAAE,CAAC;IAClD,wBAAwB,EAAE,MAAM,CAAC;IACjC,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export type { CategoryHighlightData } from "./CategoryHighlightData";
|
|
2
|
+
export type { Conversion } from "./Conversion";
|
|
2
3
|
export type { CustomHighlights } from "./CustomHighlights";
|
|
3
4
|
export type { HighlightDataPerCategory } from "./HighlightDataPerCategory";
|
|
4
5
|
export type { HighlightDataPerLocation } from "./HighlightDataPerLocation";
|
|
5
6
|
export type { HighlightValue } from "./HighlightValue";
|
|
6
|
-
export type { PreviewData } from "./PreviewData";
|
|
7
7
|
export type { Location } from "./Location";
|
|
8
|
+
export type { PreviewData } from "./PreviewData";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/preview/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/preview/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../src/utils/query-params.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,GAAG;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,
|
|
1
|
+
{"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../src/utils/query-params.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,GAAG;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB,WAAW,GAAG,SAAS,CAgBzB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,WAAW,GAAG,SAAS,GACnC,MAAM,CAeR;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,EAAE,CAKzE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,EAAE,CAQ7D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOtE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIvD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAItD"}
|
|
@@ -0,0 +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,4 +1,4 @@
|
|
|
1
|
-
import { Suggestion } from "../../types";
|
|
1
|
+
import { Query, Suggestion } from "../../types";
|
|
2
2
|
/**
|
|
3
3
|
* Fetches suggestions based on the provided parameters.
|
|
4
4
|
*
|
|
@@ -51,5 +51,5 @@ export declare function fetchSuggestQuery(suggestQueryName: string, text: string
|
|
|
51
51
|
*
|
|
52
52
|
* @returns A promise that resolves to an array of suggestions.
|
|
53
53
|
*/
|
|
54
|
-
export declare function fetchSuggestField(text: string, fields: string[]): Promise<Suggestion[]>;
|
|
54
|
+
export declare function fetchSuggestField(text: string, fields: string[], query?: Query): Promise<Suggestion[]>;
|
|
55
55
|
//# sourceMappingURL=fetch-suggest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-suggest.d.ts","sourceRoot":"","sources":["../../../src/web-api/v1/fetch-suggest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch-suggest.d.ts","sourceRoot":"","sources":["../../../src/web-api/v1/fetch-suggest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,YAAY,CAChC,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,KAAK,CAAC,EAAE,MAAM,EAAE,EAChB,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAAC,UAAU,EAAE,CAAC,CAqBvB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GACzB,OAAO,CAAC,UAAU,EAAE,CAAC,CAevB;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EAAE,EAChB,KAAK,CAAC,EAAE,KAAK,GACZ,OAAO,CAAC,UAAU,EAAE,CAAC,CAmBvB"}
|
|
@@ -41,10 +41,29 @@ export declare function createUserProfile(userProfile: Partial<UserProfile>): Pr
|
|
|
41
41
|
* ```typescript
|
|
42
42
|
* const updatedProfile = await patchUserProfile(
|
|
43
43
|
* { data: { id: '123', name: 'Jane Doe' } },
|
|
44
|
-
* '
|
|
44
|
+
* 'data',
|
|
45
45
|
* 'name'
|
|
46
46
|
* );
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
49
|
export declare function patchUserProfile(userProfile: Partial<Omit<UserProfile, "created" | "modified">>, category: string, propertyName: string): Promise<UserProfile>;
|
|
50
|
+
/**
|
|
51
|
+
* Deletes a specific property of a user profile.
|
|
52
|
+
*
|
|
53
|
+
* @param userProfile - Partial user profile object containing the data to delete. Cannot include 'created' or 'modified' fields.
|
|
54
|
+
* @param category - The category of the property to delete.
|
|
55
|
+
* @param propertyName - The name of the specific property to delete within the category.
|
|
56
|
+
* @returns A promise that indicated whether the property has been deleted.
|
|
57
|
+
* @throws May throw an error if the API request fails or if the user profile ID is not provided.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const updatedProfile = await deleteUserProfileProperty(
|
|
62
|
+
* { data: { id: '123', name: 'Jane Doe' } },
|
|
63
|
+
* 'data',
|
|
64
|
+
* 'name'
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function deleteUserProfileProperty(userProfile: Partial<Omit<UserProfile, "created" | "modified">>, category: string, propertyName: string): Promise<boolean>;
|
|
50
69
|
//# sourceMappingURL=fetch-user-profile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-user-profile.d.ts","sourceRoot":"","sources":["../../../src/web-api/v2/fetch-user-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAG3E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,GAChC,OAAO,CAAC,WAAW,CAAC,CAGtB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC,EAC/D,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,WAAW,CAAC,CAMtB"}
|
|
1
|
+
{"version":3,"file":"fetch-user-profile.d.ts","sourceRoot":"","sources":["../../../src/web-api/v2/fetch-user-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAG3E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,GAChC,OAAO,CAAC,WAAW,CAAC,CAGtB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC,EAC/D,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,WAAW,CAAC,CAMtB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC,EAC/D,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC,CASlB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sinequa/atomic",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.139",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/atomic.umd.cjs",
|
|
7
7
|
"module": "./dist/atomic.js",
|
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
"npx @biomejs/biome check --write --files-ignore-unknown=true"
|
|
39
39
|
]
|
|
40
40
|
},
|
|
41
|
+
"overrides": {
|
|
42
|
+
"minimatch": "^10.2.3"
|
|
43
|
+
},
|
|
41
44
|
"devDependencies": {
|
|
42
45
|
"@biomejs/biome": "^2.3.11",
|
|
43
46
|
"@types/node": "^20.11.0",
|
|
@@ -45,8 +48,8 @@
|
|
|
45
48
|
"jsdom": "^26.0.0",
|
|
46
49
|
"lint-staged": "^16.2.6",
|
|
47
50
|
"typescript": "^5.7.3",
|
|
48
|
-
"vite": "^
|
|
51
|
+
"vite": "^7.3.1",
|
|
49
52
|
"vite-plugin-dts": "^4.5.4",
|
|
50
|
-
"vitest": "^
|
|
53
|
+
"vitest": "^4.0.18"
|
|
51
54
|
}
|
|
52
55
|
}
|