Files

8 lines
12 KiB
JavaScript

/**
* Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.37.0.
* Original file: ./orama/dist/browser/internals.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
function e(e,t,n){const r=function(e,t,n){if(n<0)return-1;if(e===t)return 0;const r=e.length,o=t.length;if(0===r)return o<=n?o:-1;if(0===o)return r<=n?r:-1;const i=Math.abs(r-o);if(e.startsWith(t))return i<=n?i:-1;if(t.startsWith(e))return 0;if(i>n)return-1;const s=[];for(let e=0;e<=r;e++){s[e]=[e];for(let t=1;t<=o;t++)s[e][t]=0===e?t:0}for(let i=1;i<=r;i++){let r=1/0;for(let n=1;n<=o;n++)e[i-1]===t[n-1]?s[i][n]=s[i-1][n-1]:s[i][n]=Math.min(s[i-1][n]+1,s[i][n-1]+1,s[i-1][n-1]+1),r=Math.min(r,s[i][n]);if(r>n)return-1}return s[r][o]<=n?s[r][o]:-1}(e,t,n);return{distance:r,isBounded:r>=0}}var t="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}var o=n,i=r;function s(e){if(o===setTimeout)return setTimeout(e,0);if((o===n||!o)&&setTimeout)return o=setTimeout,setTimeout(e,0);try{return o(e,0)}catch(t){try{return o.call(null,e,0)}catch(t){return o.call(this,e,0)}}}"function"==typeof t.setTimeout&&(o=setTimeout),"function"==typeof t.clearTimeout&&(i=clearTimeout);var a,u=[],c=!1,l=-1;function p(){c&&a&&(c=!1,a.length?u=a.concat(u):l=-1,u.length&&d())}function d(){if(!c){var e=s(p);c=!0;for(var t=u.length;t;){for(a=u,u=[];++l<t;)a&&a[l].run();l=-1,t=u.length}a=null,c=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===r||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{return i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}f.prototype.run=function(){this.fun.apply(null,this.array)};function m(){}var h=m,g=m,_=m,T=m,N=m,E=m,I=m;var S=t.performance||{},y=S.now||S.mozNow||S.msNow||S.oNow||S.webkitNow||function(){return(new Date).getTime()};var O=new Date;var w={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new f(e,t)),1!==u.length||c||s(d)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:h,addListener:g,once:_,off:T,removeListener:N,removeAllListeners:E,emit:I,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*y.call(S),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-O)/1e3}};const A={NO_LANGUAGE_WITH_CUSTOM_TOKENIZER:"Do not pass the language option to create when using a custom tokenizer.",LANGUAGE_NOT_SUPPORTED:`Language "%s" is not supported.\nSupported languages are:\n - ${Object.keys({arabic:"ar",armenian:"am",bulgarian:"bg",danish:"dk",dutch:"nl",english:"en",finnish:"fi",french:"fr",german:"de",greek:"gr",hungarian:"hu",indian:"in",indonesian:"id",irish:"ie",italian:"it",lithuanian:"lt",nepali:"np",norwegian:"no",portuguese:"pt",romanian:"ro",russian:"ru",serbian:"rs",slovenian:"ru",spanish:"es",swedish:"se",tamil:"ta",turkish:"tr",ukrainian:"uk",sanskrit:"sk"}).join("\n - ")}`,INVALID_STEMMER_FUNCTION_TYPE:"config.stemmer property must be a function.",MISSING_STEMMER:'As of version 1.0.0 @orama/orama does not ship non English stemmers by default. To solve this, please explicitly import and specify the "%s" stemmer from the package @orama/stemmers. See https://docs.orama.com/open-source/text-analysis/stemming for more information.',CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY:"Custom stop words array must only contain strings.",UNSUPPORTED_COMPONENT:'Unsupported component "%s".',COMPONENT_MUST_BE_FUNCTION:'The component "%s" must be a function.',COMPONENT_MUST_BE_FUNCTION_OR_ARRAY_FUNCTIONS:'The component "%s" must be a function or an array of functions.',INVALID_SCHEMA_TYPE:'Unsupported schema type "%s" at "%s". Expected "string", "boolean" or "number" or array of them.',DOCUMENT_ID_MUST_BE_STRING:'Document id must be of type "string". Got "%s" instead.',DOCUMENT_ALREADY_EXISTS:'A document with id "%s" already exists.',DOCUMENT_DOES_NOT_EXIST:'A document with id "%s" does not exists.',MISSING_DOCUMENT_PROPERTY:'Missing searchable property "%s".',INVALID_DOCUMENT_PROPERTY:'Invalid document property "%s": expected "%s", got "%s"',UNKNOWN_INDEX:'Invalid property name "%s". Expected a wildcard string ("*") or array containing one of the following properties: %s',INVALID_BOOST_VALUE:"Boost value must be a number greater than, or less than 0.",INVALID_FILTER_OPERATION:"You can only use one operation per filter, you requested %d.",SCHEMA_VALIDATION_FAILURE:'Cannot insert document due schema validation failure on "%s" property.',INVALID_SORT_SCHEMA_TYPE:'Unsupported sort schema type "%s" at "%s". Expected "string" or "number".',CANNOT_SORT_BY_ARRAY:'Cannot configure sort for "%s" because it is an array (%s).',UNABLE_TO_SORT_ON_UNKNOWN_FIELD:'Unable to sort on unknown field "%s". Allowed fields: %s',SORT_DISABLED:"Sort is disabled. Please read the documentation at https://docs.oramasearch for more information.",UNKNOWN_GROUP_BY_PROPERTY:'Unknown groupBy property "%s".',INVALID_GROUP_BY_PROPERTY:'Invalid groupBy property "%s". Allowed types: "%s", but given "%s".',UNKNOWN_FILTER_PROPERTY:'Unknown filter property "%s".',INVALID_VECTOR_SIZE:'Vector size must be a number greater than 0. Got "%s" instead.',INVALID_VECTOR_VALUE:'Vector value must be a number greater than 0. Got "%s" instead.',INVALID_INPUT_VECTOR:'Property "%s" was declared as a %s-dimensional vector, but got a %s-dimensional vector instead.\nInput vectors must be of the size declared in the schema, as calculating similarity between vectors of different sizes can lead to unexpected results.',WRONG_SEARCH_PROPERTY_TYPE:'Property "%s" is not searchable. Only "string" properties are searchable.',FACET_NOT_SUPPORTED:'Facet doens\'t support the type "%s".',INVALID_DISTANCE_SUFFIX:'Invalid distance suffix "%s". Valid suffixes are: cm, m, km, mi, yd, ft.',INVALID_SEARCH_MODE:'Invalid search mode "%s". Valid modes are: "fulltext", "vector", "hybrid".',MISSING_VECTOR_AND_SECURE_PROXY:"No vector was provided and no secure proxy was configured. Please provide a vector or configure an Orama Secure Proxy to perform hybrid search.",MISSING_TERM:'"term" is a required parameter when performing hybrid search. Please provide a search term.',INVALID_VECTOR_INPUT:'Invalid "vector" property. Expected an object with "value" and "property" properties, but got "%s" instead.',PLUGIN_CRASHED:"A plugin crashed during initialization. Please check the error message for more information:",PLUGIN_SECURE_PROXY_NOT_FOUND:"Could not find '@orama/secure-proxy-plugin' installed in your Orama instance.\nPlease install it before proceeding with creating an answer session.\nRead more at https://docs.orama.com/open-source/plugins/plugin-secure-proxy#plugin-secure-proxy\n",PLUGIN_SECURE_PROXY_MISSING_CHAT_MODEL:"Could not find a chat model defined in the secure proxy plugin configuration.\nPlease provide a chat model before proceeding with creating an answer session.\nRead more at https://docs.orama.com/open-source/plugins/plugin-secure-proxy#plugin-secure-proxy\n",ANSWER_SESSION_LAST_MESSAGE_IS_NOT_ASSISTANT:"The last message in the session is not an assistant message. Cannot regenerate non-assistant messages.",PLUGIN_COMPONENT_CONFLICT:'The component "%s" is already defined. The plugin "%s" is trying to redefine it.'};function R(e,...t){const n=new Error(function(e,...t){return e.replace(/%(?:(?<position>\d+)\$)?(?<width>-?\d*\.?\d*)(?<type>[dfs])/g,(function(...e){const n=e[e.length-1],{width:r,type:o,position:i}=n,s=i?t[Number.parseInt(i)-1]:t.shift(),a=""===r?0:Number.parseInt(r);switch(o){case"d":return s.toString().padStart(a,"0");case"f":{let e=s;const[t,n]=r.split(".").map((e=>Number.parseFloat(e)));return"number"==typeof n&&n>=0&&(e=e.toFixed(n)),"number"==typeof t&&t>=0?e.toString().padStart(a,"0"):e.toString()}case"s":return a<0?s.toString().padEnd(-a," "):s.toString().padStart(a," ");default:return s}}))}(A[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,"captureStackTrace"in Error.prototype&&Error.captureStackTrace(n),n}const b=Date.now().toString().slice(5);let U=0;const C=BigInt(1e3),P=BigInt(1e6),v=BigInt(1e9),D=65535;function M(e,t){if(t.length<D)Array.prototype.push.apply(e,t);else{const n=t.length;for(let r=0;r<n;r+=D)Array.prototype.push.apply(e,t.slice(r,r+D))}}function L(e,t=2){if(0===e)return"0 Bytes";const n=t<0?0:t,r=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,r)).toFixed(n))} ${["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][r]}`}function x(){return BigInt(Math.floor(1e6*performance.now()))}function B(e){return"number"==typeof e&&(e=BigInt(e)),e<C?`${e}ns`:e<P?e/C+"μs":e<v?e/P+"ms":e/v+"s"}function V(){return"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?x():void 0!==w&&w.release&&"node"===w.release.name||void 0!==w&&"function"==typeof w?.hrtime?.bigint?w.hrtime.bigint():"undefined"!=typeof performance?x():BigInt(0)}function k(){return`${b}-${U++}`}const G={cm:.01,m:1,km:1e3,ft:.3048,yd:.9144,mi:1609.344};function Y(e,t){const n=G[t];if(void 0===n)throw new Error(R("INVALID_DISTANCE_SUFFIX",e).message);return e*n}const F="intersection"in new Set;function z(...e){if(0===e.length)return new Set;if(1===e.length)return e[0];if(2===e.length){const t=e[0],n=e[1];if(F)return t.intersection(n);const r=new Set,o=t.size<n.size?t:n,i=o===t?n:t;for(const e of o)i.has(e)&&r.add(e);return r}const t={index:0,size:e[0].size};for(let n=1;n<e.length;n++)e[n].size<t.size&&(t.index=n,t.size=e[n].size);if(F){let n=e[t.index];for(let r=0;r<e.length;r++)r!==t.index&&(n=n.intersection(e[r]));return n}const n=e[t.index];for(let r=0;r<e.length;r++){if(r===t.index)continue;const o=e[r];for(const e of n)o.has(e)||n.delete(e)}return n}const W="union"in new Set;function $(e,t){return W?e?e.union(t):t:e?new Set([...e,...t]):new Set(t)}const H=[65,65,65,65,65,65,65,67,69,69,69,69,73,73,73,73,69,78,79,79,79,79,79,null,79,85,85,85,85,89,80,115,97,97,97,97,97,97,97,99,101,101,101,101,105,105,105,105,101,110,111,111,111,111,111,null,111,117,117,117,117,121,112,121,65,97,65,97,65,97,67,99,67,99,67,99,67,99,68,100,68,100,69,101,69,101,69,101,69,101,69,101,71,103,71,103,71,103,71,103,72,104,72,104,73,105,73,105,73,105,73,105,73,105,73,105,74,106,75,107,107,76,108,76,108,76,108,76,108,76,108,78,110,78,110,78,110,110,78,110,79,111,79,111,79,111,79,111,82,114,82,114,82,114,83,115,83,115,83,115,83,115,84,116,84,116,84,116,85,117,85,117,85,117,85,117,85,117,85,117,87,119,89,121,89,90,122,90,122,90,122,115];function X(e,t,n=!0){const r=`${this.language}:${e}:${t}`;return n&&this.normalizationCache.has(r)?this.normalizationCache.get(r):this.stopWords?.includes(t)?(n&&this.normalizationCache.set(r,""),""):(this.stemmer&&!this.stemmerSkipProperties.has(e)&&(t=this.stemmer(t)),t=function(e){const t=[];for(let r=0;r<e.length;r++)t[r]=(n=e.charCodeAt(r))<192||n>383?n:H[n-192]||n;var n;return String.fromCharCode(...t)}(t),n&&this.normalizationCache.set(r,t),t)}export{e as boundedLevenshtein,Y as convertDistanceToMeters,L as formatBytes,B as formatNanoseconds,V as getNanosecondsTime,X as normalizeToken,M as safeArrayPush,z as setIntersection,$ as setUnion,k as uniqueId};export default null;
//# sourceMappingURL=/sm/56ce815861ca9642a83b872ea4769cfe57976b41b37f9a864dbbdb0ac80ec865.map