@inkeep/open-knowledge 0.29.0-beta.0 → 0.29.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/constants-DzwzGnge.mjs +2 -0
- package/dist/{dist-YCnI0BBU.mjs → dist-D1WPeGDD.mjs} +1 -1
- package/dist/{dist-CzszUkVL.mjs → dist-enzS4QJb.mjs} +4 -4
- package/dist/{gh-detect-V88Du2MF.mjs → gh-detect-CkD5P0-7.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/init-BwZjunnX.mjs +1 -0
- package/dist/{init-T4iNBuZr.mjs → init-CD7gPvxY.mjs} +4 -4
- package/dist/loader-B2tdFV2u.mjs +1 -0
- package/dist/{loader-DrYPDE4W.mjs → loader-BNccmd7o.mjs} +2 -2
- package/dist/{open-browser-ngpLclet.mjs → open-browser-DamMPOar.mjs} +2 -2
- package/dist/{preview-DCgISA37.mjs → preview-CJTJyhRe.mjs} +2 -2
- package/dist/preview-CloAm65l.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-9CRsXwpX.js → ActivityModeContent-CxxS8nFq.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-DTQhS7of.js → CodeMirrorPropInput-CI_BdrFO.js} +1 -1
- package/dist/public/assets/{DocumentContext-fCycsmXU.js → DocumentContext-H8ueoY2i.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-Di9PpxcJ.js → EnableSyncConfirmDialog-Bfx-F020.js} +1 -1
- package/dist/public/assets/{GraphPanel-RxqTHyYU.js → GraphPanel-Bq38mdVO.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-OmaGINfG.js → ManagedArtifactProperties-BSPBOnr-.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-ikl9jWLz.js → McpConsentDialogBody-iiKQkaSO.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-DmgH_l9s.js → MermaidDocEditor-DeLvY3mL.js} +1 -1
- package/dist/public/assets/{PropertyPanel-DW-wXPL8.js → PropertyPanel-M1FqAxBu.js} +1 -1
- package/dist/public/assets/{SettingsDialogBody-DLKGYz4m.js → SettingsDialogBody-CI2EJgcM.js} +1 -1
- package/dist/public/assets/{ShareBranchSwitchDialog-BO-B5Z58.js → ShareBranchSwitchDialog-DCB8oBto.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-C2putkgB.js → ShareReceiveDialog-Dd0J6bu0.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-WUihVM0X.js → ShareReceiveMissDialog-CXxQa4KW.js} +1 -1
- package/dist/public/assets/{SkillEditorActions-DBG6FPch.js → SkillEditorActions-CYONKTh4.js} +1 -1
- package/dist/public/assets/{SourceEditor-Dli-GA4u.js → SourceEditor-9SpbjiWH.js} +1 -1
- package/dist/public/assets/{TerminalPanel-B5-ikSnl.js → TerminalPanel-Cc0voOqd.js} +1 -1
- package/dist/public/assets/{agent-presence-EPReOnD1.js → agent-presence-BH_OoZBC.js} +1 -1
- package/dist/public/assets/{auth-state-cache-CwFOes4V.js → auth-state-cache-Chy1TIhv.js} +1 -1
- package/dist/public/assets/{config-provider-idYtRijR.js → config-provider-C8aBdDar.js} +1 -1
- package/dist/public/assets/{dist-wGNuEzOi.js → dist-AuN-WRQ2.js} +1 -1
- package/dist/public/assets/{dist-vGnNU_kt.js → dist-D5fPTJjV.js} +2 -2
- package/dist/public/assets/{doc-hash-DZPPDZDP.js → doc-hash-I00EhzUZ.js} +1 -1
- package/dist/public/assets/{documents-events-C387FFj2.js → documents-events-BvkJvzEE.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-DohgQL5I.js → file-tree-adapter-DvAE1kkw.js} +1 -1
- package/dist/public/assets/{index-BESZ1LvY.js → index-CWW9ADpk.js} +7 -7
- package/dist/public/assets/{keyboard-shortcuts-CKBtlgh1.js → keyboard-shortcuts-BuZN2bTe.js} +1 -1
- package/dist/public/assets/{navigation-targets-v47kYNlN.js → navigation-targets-u2AFSpqT.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-BylvD5LD.js → open-managed-artifact-tab-BX3OwOLJ.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-NlnPJ3yz.js → pending-receive-nav-store-DD8Ei1lo.js} +1 -1
- package/dist/public/assets/{prop-types-DDCTJMGl.js → prop-types-B0pfL-iG.js} +1 -1
- package/dist/public/assets/{receive-store-S3luT2x-.js → receive-store-Dt6o4uQU.js} +1 -1
- package/dist/public/assets/{selection-context-BeAbIsTm.js → selection-context-BVfXsapt.js} +1 -1
- package/dist/public/assets/skill-actions-D6y739v8.js +1 -0
- package/dist/public/assets/{skills-api-CDt3rqi3.js → skills-api-C4PwgAoY.js} +1 -1
- package/dist/public/assets/{src-ePqEpSu0.js → src-ibmWGcks.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-9hvgFXB8.js → target-navigation-intent-P7IapNEj.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-CEJxVkAD.js → typing-burst-detector-DXjPfO7_.js} +1 -1
- package/dist/public/assets/{workspace-paths-Dhhbnhbw.js → workspace-paths-BTMolBhv.js} +1 -1
- package/dist/public/index.html +25 -25
- package/dist/{repair-launch-json-BQQaFuKa.mjs → repair-launch-json-B0B568xb.mjs} +2 -2
- package/dist/{repair-mcp-configs-COKWe8pq.mjs → repair-mcp-configs-Cz7vaVvt.mjs} +2 -2
- package/dist/repair-skills-DRT6PpNy.mjs +1 -0
- package/dist/{repair-skills-q1ij3mTL.mjs → repair-skills-DoroYY8I.mjs} +2 -2
- package/dist/server-lock-GuuouVft-C8t6Ffyt.mjs +1 -0
- package/dist/{server-lock-iLcBw_q0-CU5aT1xR.mjs → server-lock-iLcBw_q0-rwg8rOgA.mjs} +2 -2
- package/dist/{src-D0bM1z_b.mjs → src-BGLE9r6j.mjs} +2 -2
- package/dist/start-CSu4I80l.mjs +1 -0
- package/dist/{start-Sq4c1D8L.mjs → start-D8BbQM4c.mjs} +2 -2
- package/dist/{write-project-skill-IMZdJi1p.mjs → write-project-skill-8alJi7YJ.mjs} +3 -3
- package/package.json +1 -1
- package/dist/constants-Dddf4Zbt.mjs +0 -2
- package/dist/init-CGWSpnxf.mjs +0 -1
- package/dist/loader-u8jcWe4s.mjs +0 -1
- package/dist/preview-CzKjLznn.mjs +0 -1
- package/dist/public/assets/skill-actions-CCgKV1BP.js +0 -1
- package/dist/repair-skills-DAdqIWrM.mjs +0 -1
- package/dist/server-lock-GuuouVft-Bm1fDFIJ.mjs +0 -1
- package/dist/start-rgO6nXNS.mjs +0 -1
|
@@ -380,7 +380,7 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
|
|
|
380
380
|
`,PLUGIN_SECURE_PROXY_MISSING_CHAT_MODEL:`Could not find a chat model defined in the secure proxy plugin configuration.
|
|
381
381
|
Please provide a chat model before proceeding with creating an answer session.
|
|
382
382
|
Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#plugin-secure-proxy
|
|
383
|
-
`,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 hY(e,...t){let n=Error(KJ(mY[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function gY(e){return{raw:Number(e),formatted:XJ(e)}}function _Y(e){if(e.id){if(typeof e.id!=`string`)throw hY(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return QJ()}function vY(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];if(t!==void 0&&!(r===`geopoint`&&typeof t==`object`&&typeof t.lon==`number`&&typeof t.lat==`number`)&&!(r===`enum`&&(typeof t==`string`||typeof t==`number`))){if(r===`enum[]`&&Array.isArray(t)){let e=t.length;for(let r=0;r<e;r++)if(typeof t[r]!=`string`&&typeof t[r]!=`number`)return n+`.`+r;continue}if(SY(r)){let e=TY(r);if(!Array.isArray(t)||t.length!==e)throw hY(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(CY(r)){if(!Array.isArray(t))return n;let e=wY(r),i=t.length;for(let r=0;r<i;r++)if(typeof t[r]!==e)return n+`.`+r;continue}if(typeof r==`object`){if(!t||typeof t!=`object`)return n;let e=vY(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}var yY={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},bY={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function xY(e){return e===`geopoint`}function SY(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function CY(e){return typeof e==`string`&&yY[e]}function wY(e){return bY[e]}function TY(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw hY(`INVALID_VECTOR_VALUE`,e);case t<=0:throw hY(`INVALID_VECTOR_SIZE`,e);default:return t}}function EY(){return{idToInternalId:new Map,internalIdToId:[],save:DY,load:OY}}function DY(e){return{internalIdToId:e.internalIdToId}}function OY(e,t){let{internalIdToId:n}=t;e.internalDocumentIDStore.idToInternalId.clear(),e.internalDocumentIDStore.internalIdToId=[];let r=n.length;for(let t=0;t<r;t++){let r=n[t];e.internalDocumentIDStore.idToInternalId.set(r,t+1),e.internalDocumentIDStore.internalIdToId.push(r)}}function kY(e,t){if(typeof t==`string`){let n=e.idToInternalId.get(t);if(n)return n;let r=e.idToInternalId.size+1;return e.idToInternalId.set(t,r),e.internalIdToId.push(t),r}return t>e.internalIdToId.length?kY(e,t.toString()):t}function AY(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function jY(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function MY(e,t){let n=kY(e.sharedInternalDocumentStore,t);return e.docs[n]}function NY(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=kY(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function PY(e){return e.docs}function FY(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function IY(e,t){let n=kY(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function LY(e){return e.count}function RY(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function zY(e){return{docs:e.docs,count:e.count}}function BY(){return{create:jY,get:MY,getMultiple:NY,getAll:PY,store:FY,remove:IY,count:LY,load:RY,save:zY}}var VY=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function HY(e,t){let n=[],r=e.plugins?.length;if(!r)return n;for(let i=0;i<r;i++)try{let r=e.plugins[i];typeof r[t]==`function`&&n.push(r[t])}catch(e){throw console.error(`Caught error in getAllPluginsByHook:`,e),hY(`PLUGIN_CRASHED`)}return n}var UY=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],WY=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function GY(e,t,n,r){if(e.some(sY))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function KY(e,t,n){if(e.some(sY))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function qY(e,t,n,r,i){if(e.some(sY))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function JY(e,t,n,r){if(e.some(sY))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function YY(e,t){if(e.some(sY))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var XY=class e{k;v;l=null;r=null;h=1;constructor(e,t){this.k=e,this.v=new Set(t)}updateHeight(){this.h=Math.max(e.getHeight(this.l),e.getHeight(this.r))+1}static getHeight(e){return e?e.h:0}getBalanceFactor(){return e.getHeight(this.l)-e.getHeight(this.r)}rotateLeft(){let e=this.r;return this.r=e.l,e.l=this,this.updateHeight(),e.updateHeight(),e}rotateRight(){let e=this.l;return this.l=e.r,e.r=this,this.updateHeight(),e.updateHeight(),e}toJSON(){return{k:this.k,v:Array.from(this.v),l:this.l?this.l.toJSON():null,r:this.r?this.r.toJSON():null,h:this.h}}static fromJSON(t){let n=new e(t.k,t.v);return n.l=t.l?e.fromJSON(t.l):null,n.r=t.r?e.fromJSON(t.r):null,n.h=t.h,n}},ZY=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new XY(e,t))}insert(e,t,n=1e3){this.root=this.insertNode(this.root,e,t,n)}insertMultiple(e,t,n=1e3){for(let r of t)this.insert(e,r,n)}rebalance(){this.root&&=this.rebalanceNode(this.root)}toJSON(){return{root:this.root?this.root.toJSON():null,insertCount:this.insertCount}}static fromJSON(t){let n=new e;return n.root=t.root?XY.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new XY(t,[n]);let i=[],a=e,o=null;for(;a!==null;)if(i.push({parent:o,node:a}),t<a.k)if(a.l===null){a.l=new XY(t,[n]),i.push({parent:a,node:a.l});break}else o=a,a=a.l;else if(t>a.k)if(a.r===null){a.r=new XY(t,[n]),i.push({parent:a,node:a.r});break}else o=a,a=a.r;else return a.v.add(n),e;let s=!1;this.insertCount++%r===0&&(s=!0);for(let t=i.length-1;t>=0;t--){let{parent:n,node:r}=i[t];if(r.updateHeight(),s){let t=this.rebalanceNode(r);n?n.l===r?n.l=t:n.r===r&&(n.r=t):e=t}}return e}rebalanceNode(e){let t=e.getBalanceFactor();if(t>1){if(e.l&&e.l.getBalanceFactor()>=0)return e.rotateRight();if(e.l)return e.l=e.l.rotateLeft(),e.rotateRight()}if(t<-1){if(e.r&&e.r.getBalanceFactor()<=0)return e.rotateLeft();if(e.r)return e.r=e.r.rotateRight(),e.rotateLeft()}return e}find(e){let t=this.findNodeByKey(e);return t?t.v:null}contains(e){return this.find(e)!==null}getSize(){let e=0,t=[],n=this.root;for(;n||t.length>0;){for(;n;)t.push(n),n=n.l;n=t.pop(),e++,n=n.r}return e}isBalanced(){if(!this.root)return!0;let e=[this.root];for(;e.length>0;){let t=e.pop(),n=t.getBalanceFactor();if(Math.abs(n)>1)return!1;t.l&&e.push(t.l),t.r&&e.push(t.r)}return!0}remove(e){this.root=this.removeNode(this.root,e)}removeDocument(e,t){let n=this.findNodeByKey(e);n&&(n.v.size===1?this.root=this.removeNode(this.root,e):n.v=new Set([...n.v.values()].filter(e=>e!==t)))}findNodeByKey(e){let t=this.root;for(;t;)if(e<t.k)t=t.l;else if(e>t.k)t=t.r;else return t;return null}removeNode(e,t){if(e===null)return null;let n=[],r=e;for(;r!==null&&r.k!==t;)n.push(r),r=t<r.k?r.l:r.r;if(r===null)return e;if(r.l===null||r.r===null){let t=r.l?r.l:r.r;if(n.length===0)e=t;else{let e=n[n.length-1];e.l===r?e.l=t:e.r=t}}else{let e=r,t=r.r;for(;t.l!==null;)e=t,t=t.l;r.k=t.k,r.v=t.v,e.l===t?e.l=t.r:e.r=t.r,r=e}n.push(r);for(let t=n.length-1;t>=0;t--){let r=n[t];r.updateHeight();let i=this.rebalanceNode(r);if(t>0){let e=n[t-1];e.l===r?e.l=i:e.r===r&&(e.r=i)}else e=i}return e}rangeSearch(e,t){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),i.k>=e&&i.k<=t)for(let e of i.v)n.add(e);if(i.k>t)break;i=i.r}return n}greaterThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.r;if(i=r.pop(),t&&i.k>=e||!t&&i.k>e)for(let e of i.v)n.add(e);else if(i.k<=e)break;i=i.l}return n}lessThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),t&&i.k<=e||!t&&i.k<e)for(let e of i.v)n.add(e);else if(i.k>e)break;i=i.r}return n}},QY=class e{numberToDocumentId;constructor(){this.numberToDocumentId=new Map}insert(e,t){this.numberToDocumentId.has(e)?this.numberToDocumentId.get(e).add(t):this.numberToDocumentId.set(e,new Set([t]))}find(e){let t=this.numberToDocumentId.get(e);return t?Array.from(t):null}remove(e){this.numberToDocumentId.delete(e)}removeDocument(e,t){let n=this.numberToDocumentId.get(t);n&&(n.delete(e),n.size===0&&this.numberToDocumentId.delete(t))}contains(e){return this.numberToDocumentId.has(e)}getSize(){let e=0;for(let t of this.numberToDocumentId.values())e+=t.size;return e}filter(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`eq`:{let t=e[n],r=this.numberToDocumentId.get(t);return r?Array.from(r):[]}case`in`:{let t=e[n],r=new Set;for(let e of t){let t=this.numberToDocumentId.get(e);if(t)for(let e of t)r.add(e)}return Array.from(r)}case`nin`:{let t=new Set(e[n]),r=new Set;for(let[e,n]of this.numberToDocumentId.entries())if(!t.has(e))for(let e of n)r.add(e);return Array.from(r)}default:throw Error(`Invalid operation`)}}filterArr(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`containsAll`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e].filter(e=>t.has(e))));return Array.from(r)}case`containsAny`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e,...t]));return Array.from(r)}default:throw Error(`Invalid operation`)}}static fromJSON(t){if(!t.numberToDocumentId)throw Error(`Invalid Flat Tree JSON`);let n=new e;for(let[e,r]of t.numberToDocumentId)n.numberToDocumentId.set(e,new Set(r));return n}toJSON(){return{numberToDocumentId:Array.from(this.numberToDocumentId.entries()).map(([e,t])=>[e,Array.from(t)])}}};function $Y(e,t,n){if(n<0)return-1;if(e===t)return 0;let r=e.length,i=t.length;if(r===0)return i<=n?i:-1;if(i===0)return r<=n?r:-1;let a=Math.abs(r-i);if(e.startsWith(t))return a<=n?a:-1;if(t.startsWith(e))return 0;if(a>n)return-1;let o=[];for(let e=0;e<=r;e++){o[e]=[e];for(let t=1;t<=i;t++)o[e][t]=e===0?t:0}for(let a=1;a<=r;a++){let r=1/0;for(let n=1;n<=i;n++)e[a-1]===t[n-1]?o[a][n]=o[a-1][n-1]:o[a][n]=Math.min(o[a-1][n]+1,o[a][n-1]+1,o[a-1][n-1]+1),r=Math.min(r,o[a][n]);if(r>n)return-1}return o[r][i]<=n?o[r][i]:-1}function eX(e,t,n){let r=$Y(e,t,n);return{distance:r,isBounded:r>=0}}var tX=class e{k;s;c=new Map;d=new Set;e;w=``;constructor(e,t,n){this.k=e,this.s=t,this.e=n}updateParent(e){this.w=e.w+this.s}addDocument(e){this.d.add(e)}removeDocument(e){return this.d.delete(e)}findAllWords(e,t,n,r){let i=[this];for(;i.length>0;){let a=i.pop();if(a.e){let{w:i,d:o}=a;if(n&&i!==t)continue;if($J(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&eX(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if($J(e,i)!=null&&o.size>0){let t=e[i];for(let e of o)t.includes(e)||t.push(e)}}a.c.size>0&&i.push(...a.c.values())}return e}insert(t,n){let r=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=r.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c){if(r=s,i+=l,i===a){s.e||=!0,s.addDocument(n);return}continue}let u=o.slice(0,l),d=o.slice(l),f=t.slice(i+l),p=new e(u[0],u,!1);if(r.c.set(u[0],p),p.updateParent(r),s.s=d,s.k=d[0],p.c.set(d[0],s),s.updateParent(p),f){let t=new e(f[0],f,!0);t.addDocument(n),p.c.set(f[0],t),t.updateParent(p)}else p.e=!0,p.addDocument(n);return}else{let a=new e(o,t.slice(i),!0);a.addDocument(n),r.c.set(o,a),a.updateParent(r);return}}r.e||=!0,r.addDocument(n)}_findLevenshtein(e,t,n,r,i){let a=[{node:this,index:t,tolerance:n}];for(;a.length>0;){let{node:t,index:n,tolerance:o}=a.pop();if(t.w.startsWith(e)){t.findAllWords(i,e,!1,0);continue}if(o<0)continue;if(t.e){let{w:n,d:a}=t;if(n&&(eX(e,n,r).isBounded&&(i[n]=[]),$J(i,n)!==void 0&&a.size>0)){let e=new Set(i[n]);for(let t of a)e.add(t);i[n]=Array.from(e)}}if(n>=e.length)continue;let s=e[n];if(t.c.has(s)){let e=t.c.get(s);a.push({node:e,index:n+1,tolerance:o})}a.push({node:t,index:n+1,tolerance:o-1});for(let[e,r]of t.c)a.push({node:r,index:n,tolerance:o-1}),e!==s&&a.push({node:r,index:n+1,tolerance:o-1})}}find(e){let{term:t,exact:n,tolerance:r}=e;if(r&&!n){let e={};return this._findLevenshtein(t,0,r,r,e),e}else{let e=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=e.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c)e=s,i+=l;else if(i+l===a)if(l===a-i){if(n)return{};{let e={};return s.findAllWords(e,t,n,r),e}}else return{};else return{}}else return{}}let o={};return e.findAllWords(o,t,n,r),o}}contains(e){let t=this,n=0,r=e.length;for(;n<r;){let i=e[n],a=t.c.get(i);if(a){let i=a.s,o=i.length,s=0;for(;s<o&&n+s<r&&i[s]===e[n+s];)s++;if(s<o)return!1;n+=o,t=a}else return!1}return!0}removeWord(e){if(!e)return!1;let t=this,n=e.length,r=[];for(let i=0;i<n;i++){let n=e[i];if(t.c.has(n)){let e=t.c.get(n);r.push({parent:t,character:n}),i+=e.s.length-1,t=e}else return!1}for(t.d.clear(),t.e=!1;r.length>0&&t.c.size===0&&!t.e&&t.d.size===0;){let{parent:e,character:n}=r.pop();e.c.delete(n),t=e}return!0}removeDocumentByWord(e,t,n=!0){if(!e)return!0;let r=this,i=e.length;for(let a=0;a<i;a++){let i=e[a];if(r.c.has(i)){let o=r.c.get(i);a+=o.s.length-1,r=o,n&&r.w!==e||r.removeDocument(t)}else return!1}return!0}static getCommonPrefix(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return e.slice(0,r)}toJSON(){return{w:this.w,s:this.s,e:this.e,k:this.k,d:Array.from(this.d),c:Array.from(this.c?.entries())?.map(([e,t])=>[e,t.toJSON()])}}static fromJSON(t){let n=new e(t.k,t.s,t.e);return n.w=t.w,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([t,n])=>[t,e.fromJSON(n)])||[]),n}},nX=class e extends tX{constructor(){super(``,``,!1)}static fromJSON(t){let n=new e;return n.w=t.w,n.s=t.s,n.e=t.e,n.k=t.k,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([e,t])=>[e,tX.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},rX=2,iX=6371e3,aX=class e{point;docIDs;left;right;parent;constructor(e,t){this.point=e,this.docIDs=new Set(t),this.left=null,this.right=null,this.parent=null}toJSON(){return{point:this.point,docIDs:Array.from(this.docIDs),left:this.left?this.left.toJSON():null,right:this.right?this.right.toJSON():null}}static fromJSON(t,n=null){let r=new e(t.point,t.docIDs);return r.parent=n,t.left&&(r.left=e.fromJSON(t.left,r)),t.right&&(r.right=e.fromJSON(t.right,r)),r}},oX=class e{root;nodeMap;constructor(){this.root=null,this.nodeMap=new Map}getPointKey(e){return`${e.lon},${e.lat}`}insert(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);if(r){t.forEach(e=>r.docIDs.add(e));return}let i=new aX(e,t);if(this.nodeMap.set(n,i),this.root==null){this.root=i;return}let a=this.root,o=0;for(;;){if(o%rX===0)if(e.lon<a.point.lon){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}else if(e.lat<a.point.lat){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}o++}}contains(e){let t=this.getPointKey(e);return this.nodeMap.has(t)}getDocIDsByCoordinates(e){let t=this.getPointKey(e),n=this.nodeMap.get(t);return n?Array.from(n.docIDs):null}removeDocByID(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);r&&(r.docIDs.delete(t),r.docIDs.size===0&&(this.nodeMap.delete(n),this.deleteNode(r)))}deleteNode(e){let t=e.parent,n=e.left?e.left:e.right;n&&(n.parent=t),t?t.left===e?t.left=n:t.right===e&&(t.right=n):(this.root=n,this.root&&(this.root.parent=null))}searchByRadius(t,n,r=!0,i=`asc`,a=!1){let o=a?e.vincentyDistance:e.haversineDistance,s=[{node:this.root,depth:0}],c=[];for(;s.length>0;){let{node:e,depth:i}=s.pop();if(e==null)continue;let a=o(t,e.point);(r?a<=n:a>n)&&c.push({point:e.point,docIDs:Array.from(e.docIDs)}),e.left!=null&&s.push({node:e.left,depth:i+1}),e.right!=null&&s.push({node:e.right,depth:i+1})}return i&&c.sort((e,n)=>{let r=o(t,e.point),a=o(t,n.point);return i.toLowerCase()===`asc`?r-a:a-r}),c}searchByPolygon(t,n=!0,r=null,i=!1){let a=[{node:this.root,depth:0}],o=[];for(;a.length>0;){let{node:r,depth:i}=a.pop();if(r==null)continue;r.left!=null&&a.push({node:r.left,depth:i+1}),r.right!=null&&a.push({node:r.right,depth:i+1});let s=e.isPointInPolygon(t,r.point);(s&&n||!s&&!n)&&o.push({point:r.point,docIDs:Array.from(r.docIDs)})}let s=e.calculatePolygonCentroid(t);if(r){let t=i?e.vincentyDistance:e.haversineDistance;o.sort((e,n)=>{let i=t(s,e.point),a=t(s,n.point);return r.toLowerCase()===`asc`?i-a:a-i})}return o}toJSON(){return{root:this.root?this.root.toJSON():null}}static fromJSON(t){let n=new e;return t.root&&(n.root=aX.fromJSON(t.root),n.buildNodeMap(n.root)),n}buildNodeMap(e){if(e==null)return;let t=this.getPointKey(e.point);this.nodeMap.set(t,e),e.left&&this.buildNodeMap(e.left),e.right&&this.buildNodeMap(e.right)}static calculatePolygonCentroid(e){let t=0,n=0,r=0,i=e.length;for(let a=0,o=i-1;a<i;o=a++){let i=e[a].lon,s=e[a].lat,c=e[o].lon,l=e[o].lat,u=i*l-c*s;t+=u,n+=(i+c)*u,r+=(s+l)*u}t/=2;let a=6*t;return n/=a,r/=a,{lon:n,lat:r}}static isPointInPolygon(e,t){let n=!1,r=t.lon,i=t.lat,a=e.length;for(let t=0,o=a-1;t<a;o=t++){let a=e[t].lon,s=e[t].lat,c=e[o].lon,l=e[o].lat;s>i!=l>i&&r<(c-a)*(i-s)/(l-s)+a&&(n=!n)}return n}static haversineDistance(e,t){let n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=(t.lat-e.lat)*n,o=(t.lon-e.lon)*n,s=Math.sin(a/2)*Math.sin(a/2)+Math.cos(r)*Math.cos(i)*Math.sin(o/2)*Math.sin(o/2);return iX*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))}static vincentyDistance(e,t){let n=6378137,r=1/298.257223563,i=(1-r)*n,a=Math.PI/180,o=e.lat*a,s=t.lat*a,c=(t.lon-e.lon)*a,l=Math.atan((1-r)*Math.tan(o)),u=Math.atan((1-r)*Math.tan(s)),d=Math.sin(l),f=Math.cos(l),p=Math.sin(u),m=Math.cos(u),h=c,g,_=1e3,v,y,b,x,S,C;do{let e=Math.sin(h),t=Math.cos(h);if(v=Math.sqrt(m*e*(m*e)+(f*p-d*m*t)*(f*p-d*m*t)),v===0)return 0;y=d*p+f*m*t,b=Math.atan2(v,y),x=f*m*e/v,S=1-x*x,C=y-2*d*p/S,isNaN(C)&&(C=0);let n=r/16*S*(4+r*(4-3*S));g=h,h=c+(1-n)*r*x*(b+n*v*(C+n*y*(-1+2*C*C)))}while(Math.abs(h-g)>1e-12&&--_>0);if(_===0)return NaN;let ee=S*(n*n-i*i)/(i*i),w=1+ee/16384*(4096+ee*(-768+ee*(320-175*ee))),T=ee/1024*(256+ee*(-128+ee*(74-47*ee))),te=T*v*(C+T/4*(y*(-1+2*C*C)-T/6*C*(-3+4*v*v)*(-3+4*C*C)));return i*w*(b-te)}},sX=class e{true;false;constructor(){this.true=new Set,this.false=new Set}insert(e,t){t?this.true.add(e):this.false.add(e)}delete(e,t){t?this.true.delete(e):this.false.delete(e)}getSize(){return this.true.size+this.false.size}toJSON(){return{true:Array.from(this.true),false:Array.from(this.false)}}static fromJSON(t){let n=new e;return n.true=new Set(t.true),n.false=new Set(t.false),n}};function cX(e,t,n,r,i,{k:a,b:o,d:s}){return Math.log(1+(n-t+.5)/(t+.5))*(s+e*(a+1))/(e+a*(1-o+o*r/i))}var lX=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=uX(t,this.size);this.vectors.set(e,[n,t])}remove(e){this.vectors.delete(e)}find(e,t,n){return e instanceof Float32Array||(e=new Float32Array(e)),dX(e,n,this.vectors,this.size,t)}toJSON(){let e=[];for(let[t,[n,r]]of this.vectors)e.push([t,[n,Array.from(r)]]);return{size:this.size,vectors:e}}static fromJSON(t){let n=t,r=new e(n.size);for(let[e,[t,i]]of n.vectors)r.vectors.set(e,[t,new Float32Array(i)]);return r}};function uX(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function dX(e,t,n,r,i){let a=uX(e,r),o=[],s=t||n.keys();for(let t of s){let s=n.get(t);if(!s)continue;let c=s[0],l=s[1],u=0;for(let t=0;t<r;t++)u+=e[t]*l[t];let d=u/(a*c);d>=i&&o.push([t,d])}return o}function fX(e,t,n,r,i){let a=kY(e.sharedInternalDocumentStore,n);e.avgFieldLength[t]=((e.avgFieldLength[t]??0)*(i-1)+r.length)/i,e.fieldLengths[t][a]=r.length,e.frequencies[t][a]={}}function pX(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=kY(e.sharedInternalDocumentStore,n),s=a/r.length;e.frequencies[t][o][i]=s,i in e.tokenOccurrences[t]||(e.tokenOccurrences[t][i]=0),e.tokenOccurrences[t][i]=(e.tokenOccurrences[t][i]??0)+1}function mX(e,t,n,r){let i=kY(e.sharedInternalDocumentStore,n);r>1?e.avgFieldLength[t]=(e.avgFieldLength[t]*r-e.fieldLengths[t][i])/(r-1):e.avgFieldLength[t]=void 0,e.fieldLengths[t][i]=void 0,e.frequencies[t][i]=void 0}function hX(e,t,n){e.tokenOccurrences[t][n]--}function gX(e,t,n,r,i=``){r||={sharedInternalDocumentStore:t,indexes:{},vectorIndexes:{},searchableProperties:[],searchablePropertiesWithTypes:{},frequencies:{},tokenOccurrences:{},avgFieldLength:{},fieldLengths:{}};for(let[a,o]of Object.entries(n)){let n=`${i}${i?`.`:``}${a}`;if(typeof o==`object`&&!Array.isArray(o)){gX(e,t,o,r,n);continue}if(SY(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new lX(TY(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new sX,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new ZY(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new nX,isArray:e},r.avgFieldLength[n]=0,r.frequencies[n]={},r.tokenOccurrences[n]={},r.fieldLengths[n]={};break;case`enum`:case`enum[]`:r.indexes[n]={type:`Flat`,node:new QY,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new oX,isArray:e};break;default:throw hY(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function _X(e,t,n,r,i,a,o,s){return c=>{let{type:l,node:u}=t.indexes[n];switch(l){case`Bool`:u[c?`true`:`false`].add(r);break;case`AVL`:{let e=s?.avlRebalanceThreshold??1;u.insert(c,r,e);break}case`Radix`:{let s=a.tokenize(c,i,n,!1);e.insertDocumentScoreParameters(t,n,r,s,o);for(let i of s)e.insertTokenScoreParameters(t,n,r,s,i),u.insert(i,r);break}case`Flat`:u.insert(c,r);break;case`BKD`:u.insert(c,[r]);break}}}function vX(e,t,n,r,i,a,o,s,c,l,u){if(SY(o))return yX(t,n,a,r,i);let d=_X(e,t,n,i,s,c,l,u);if(!CY(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function yX(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function bX(e,t,n,r,i,a,o,s,c,l){if(SY(o))return t.vectorIndexes[n].node.remove(i),!0;let{type:u,node:d}=t.indexes[n];switch(u){case`AVL`:return d.removeDocument(a,i),!0;case`Bool`:return d[a?`true`:`false`].delete(i),!0;case`Radix`:{let o=c.tokenize(a,s,n);e.removeDocumentScoreParameters(t,n,r,l);for(let r of o)e.removeTokenScoreParameters(t,n,r),d.removeDocumentByWord(r,i);return!0}case`Flat`:return d.removeDocument(i,a),!0;case`BKD`:return d.removeDocByID(a,i),!1}}function xX(e,t,n,r,i,a,o,s,c,l){if(!CY(o))return bX(e,t,n,r,i,a,o,s,c,l);let u=wY(o),d=a,f=d.length;for(let a=0;a<f;a++)bX(e,t,n,r,i,d[a],u,s,c,l);return!0}function SX(e,t,n,r,i,a,o,s,c,l){let u=Array.from(r),d=e.avgFieldLength[t],f=e.fieldLengths[t],p=e.tokenOccurrences[t],m=e.frequencies[t],h=typeof p[n]==`number`?p[n]??0:0,g=u.length;for(let e=0;e<g;e++){let r=u[e];if(c&&!c.has(r))continue;l.has(r)||l.set(r,new Map);let p=l.get(r);p.set(t,(p.get(t)||0)+1);let g=cX(m?.[r]?.[n]??0,h,i,f[r],d,a);o.has(r)?o.set(r,o.get(r)+g*s):o.set(r,g*s)}}function CX(e,t,n,r,i,a,o,s,c,l,u,d=0){let f=n.tokenize(t,r),p=f.length||1,m=new Map,h=new Map,g=new Map;for(let n of i){if(!(n in e.indexes))continue;let r=e.indexes[n],{type:i}=r;if(i!==`Radix`)throw hY(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw hY(`INVALID_BOOST_VALUE`,d);f.length===0&&!t&&f.push(``);let p=f.length;for(let t=0;t<p;t++){let i=f[t],s=r.node.find({term:i,exact:a,tolerance:o}),p=Object.keys(s);p.length>0&&h.set(i,!0);let _=p.length;for(let t=0;t<_;t++){let r=p[t],i=s[r];SX(e,n,r,i,l,c,g,d,u,m)}}}let _=Array.from(g.entries()).map(([e,t])=>[e,t]).sort((e,t)=>t[1]-e[1]);if(_.length===0)return[];if(d===1)return _;if(d===0){if(p===1)return _;for(let e of f)if(!h.get(e))return[];return _.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1})}let v=_.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1});if(v.length>0){let e=_.filter(([e])=>!v.some(([t])=>t===e)),t=Math.ceil(e.length*d);return[...v,...e.slice(0,t)]}return _}function wX(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:lY(...i.map(n=>wX(e,t,n,r)))}if(`or`in n&&n.or&&Array.isArray(n.or)){let i=n.or;return i.length===0?new Set:i.map(n=>wX(e,t,n,r)).reduce((e,t)=>dY(e,t),new Set)}if(`not`in n&&n.not){let i=n.not,a=new Set,o=e.sharedInternalDocumentStore;for(let e=1;e<=o.internalIdToId.length;e++)a.add(e);return fY(a,wX(e,t,i,r))}let i=Object.keys(n),a=i.reduce((e,t)=>({[t]:new Set,...e}),{});for(let o of i){let i=n[o];if(e.indexes[o]===void 0)throw hY(`UNKNOWN_FILTER_PROPERTY`,o);let{node:s,type:c,isArray:l}=e.indexes[o];if(c===`Bool`){let e=s,t=i?e.true:e.false;a[o]=dY(a[o],t);continue}if(c===`BKD`){let e;if(`radius`in i)e=`radius`;else if(`polygon`in i)e=`polygon`;else throw Error(`Invalid operation ${i}`);if(e===`radius`){let{value:t,coordinates:n,unit:r=`m`,inside:c=!0,highPrecision:l=!1}=i[e],u=aY(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=AX(a[o],d)}else{let{coordinates:t,inside:n=!0,highPrecision:r=!1}=i[e],c=s.searchByPolygon(t,n,void 0,r);a[o]=AX(a[o],c)}continue}if(c===`Radix`&&(typeof i==`string`||Array.isArray(i))){for(let e of[i].flat()){let n=t.tokenize(e,r,o);for(let e of n){let t=s.find({term:e,exact:!0});a[o]=PX(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw hY(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=dY(a[o],e);continue}if(c===`AVL`){let e=u[0],t=i[e],n;switch(e){case`gt`:n=s.greaterThan(t,!1);break;case`gte`:n=s.greaterThan(t,!0);break;case`lt`:n=s.lessThan(t,!1);break;case`lte`:n=s.lessThan(t,!0);break;case`eq`:n=s.find(t)??new Set;break;case`between`:{let[e,r]=t;n=s.rangeSearch(e,r);break}default:throw hY(`INVALID_FILTER_OPERATION`,e)}a[o]=dY(a[o],n)}}return lY(...Object.values(a))}function TX(e){return e.searchableProperties}function EX(e){return e.searchablePropertiesWithTypes}function DX(e,t){let{indexes:n,vectorIndexes:r,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}=t,u={},d={};for(let e of Object.keys(n)){let{node:t,type:r,isArray:i}=n[e];switch(r){case`Radix`:u[e]={type:`Radix`,node:nX.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:QY.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:ZY.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:oX.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:sX.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:lX.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function OX(e){let{indexes:t,vectorIndexes:n,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}=e,l={};for(let e of Object.keys(n))l[e]=n[e].node.toJSON();let u={};for(let e of Object.keys(t)){let{type:n,node:r,isArray:i}=t[e];n===`Flat`||n===`Radix`||n===`AVL`||n===`BKD`||n===`Bool`?u[e]={type:n,node:r.toJSON(),isArray:i}:(u[e]=t[e],u[e].node=u[e].node.toJSON())}return{indexes:u,vectorIndexes:l,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}}function kX(){return{create:gX,insert:vX,remove:xX,insertDocumentScoreParameters:fX,insertTokenScoreParameters:pX,removeDocumentScoreParameters:mX,removeTokenScoreParameters:hX,calculateResultScores:SX,search:CX,searchByWhereClause:wX,getSearchableProperties:TX,getSearchablePropertiesWithTypes:EX,load:DX,save:OX}}function AX(e,t){e||=new Set;let n=t.length;for(let r=0;r<n;r++){let n=t[r].docIDs,i=n.length;for(let t=0;t<i;t++)e.add(n[t])}return e}function jX(e,t,n=!1){let r=n?oX.vincentyDistance:oX.haversineDistance,i=[],a=[];for(let{point:n}of e)a.push(r(t,n));let o=Math.max(...a),s=0;for(let{docIDs:t}of e){let e=o-a[s]+1;for(let n of t)i.push([n,e]);s++}return i.sort((e,t)=>t[1]-e[1]),i}function MX(e,t){let n=Object.keys(e);if(n.length!==1)return{isGeoOnly:!1};let r=n[0],i=e[r];if(t.indexes[r]===void 0)return{isGeoOnly:!1};let{type:a}=t.indexes[r];return a===`BKD`&&i&&(`radius`in i||`polygon`in i)?{isGeoOnly:!0,geoProperty:r,geoOperation:i}:{isGeoOnly:!1}}function NX(e,t){let n=e,r=MX(t,n);if(!r.isGeoOnly||!r.geoProperty||!r.geoOperation)return null;let{node:i}=n.indexes[r.geoProperty],a=r.geoOperation,o=i,s;if(`radius`in a){let{value:e,coordinates:t,unit:n=`m`,inside:r=!0,highPrecision:i=!1}=a.radius,c=t,l=aY(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),jX(s,c,i)}else if(`polygon`in a){let{coordinates:e,inside:t=!0,highPrecision:n=!1}=a.polygon;s=o.searchByPolygon(e,t,`asc`,n);let r=oX.calculatePolygonCentroid(e);return jX(s,r,n)}return null}function PX(e,t){e||=new Set;let n=Object.keys(t),r=n.length;for(let i=0;i<r;i++){let r=t[n[i]],a=r.length;for(let t=0;t<a;t++)e.add(r[t])}return e}function FX(e,t,n,r,i){let a={language:e.tokenizer.language,sharedInternalDocumentStore:t,enabled:!0,isSorted:!0,sortableProperties:[],sortablePropertiesWithTypes:{},sorts:{}};for(let[o,s]of Object.entries(n)){let n=`${i}${i?`.`:``}${o}`;if(!r.includes(n)){if(typeof s==`object`&&!Array.isArray(s)){let i=FX(e,t,s,r,n);GJ(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!SY(s))switch(s){case`boolean`:case`number`:case`string`:a.sortableProperties.push(n),a.sortablePropertiesWithTypes[n]=s,a.sorts[n]={docs:new Map,orderedDocsToRemove:new Map,orderedDocs:[],type:s};break;case`geopoint`:case`enum`:continue;case`enum[]`:case`boolean[]`:case`number[]`:case`string[]`:continue;default:throw hY(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function IX(e,t,n,r){return r?.enabled===!1?{disabled:!0}:FX(e,t,n,(r||{}).unsortableProperties||[],``)}function LX(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=kY(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&WX(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function RX(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)HX(e,n);e.isSorted=!0}function zX(e,t,n){return t[1].localeCompare(n[1],RJ(e))}function BX(e,t){return e[1]-t[1]}function VX(e,t){return t[1]?-1:1}function HX(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=zX.bind(null,e.language);break;case`number`:r=BX.bind(null);break;case`boolean`:r=VX.bind(null);break}n.orderedDocs.sort(r);let i=n.orderedDocs.length;for(let e=0;e<i;e++){let t=n.orderedDocs[e][0];n.docs.set(t,e)}}function UX(e){let t=Object.keys(e.sorts);for(let n of t)WX(e,n)}function WX(e,t){let n=e.sorts[t];n.orderedDocsToRemove.size&&(n.orderedDocs=n.orderedDocs.filter(e=>!n.orderedDocsToRemove.has(e[0])),n.orderedDocsToRemove.clear())}function GX(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=kY(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function KX(e,t,n){if(!e.enabled)throw hY(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw hY(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return WX(e,r),RX(e),t.sort((t,n)=>{let r=a.docs.get(kY(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(kY(e.sharedInternalDocumentStore,n[0])),s=r!==void 0,c=o!==void 0;return!s&&!c?0:s?c?i?o-r:r-o:-1:1}),t}function qX(e){return e.enabled?e.sortableProperties:[]}function JX(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function YX(e,t){let n=t;if(!n.enabled)return{enabled:!1};let r=Object.keys(n.sorts).reduce((e,t)=>{let{docs:r,orderedDocs:i,type:a}=n.sorts[t];return e[t]={docs:new Map(Object.entries(r).map(([e,t])=>[+e,t])),orderedDocsToRemove:new Map,orderedDocs:i,type:a},e},{});return{sharedInternalDocumentStore:e,language:n.language,sortableProperties:n.sortableProperties,sortablePropertiesWithTypes:n.sortablePropertiesWithTypes,sorts:r,enabled:!0,isSorted:n.isSorted}}function XX(e){if(!e.enabled)return{enabled:!1};UX(e),RX(e);let t=Object.keys(e.sorts).reduce((t,n)=>{let{docs:r,orderedDocs:i,type:a}=e.sorts[n];return t[n]={docs:Object.fromEntries(r.entries()),orderedDocs:i,type:a},t},{});return{language:e.language,sortableProperties:e.sortableProperties,sortablePropertiesWithTypes:e.sortablePropertiesWithTypes,sorts:t,enabled:e.enabled,isSorted:e.isSorted}}function ZX(){return{create:IX,insert:LX,remove:GX,save:XX,load:YX,sortBy:KX,getSortableProperties:qX,getSortablePropertiesWithTypes:JX}}var QX=192,$X=383,eZ=[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 tZ(e){return e<QX||e>$X?e:eZ[e-QX]||e}function nZ(e){let t=[];for(let n=0;n<e.length;n++)t[n]=tZ(e.charCodeAt(n));return String.fromCharCode(...t)}var rZ={ational:`ate`,tional:`tion`,enci:`ence`,anci:`ance`,izer:`ize`,bli:`ble`,alli:`al`,entli:`ent`,eli:`e`,ousli:`ous`,ization:`ize`,ation:`ate`,ator:`ate`,alism:`al`,iveness:`ive`,fulness:`ful`,ousness:`ous`,aliti:`al`,iviti:`ive`,biliti:`ble`,logi:`log`},iZ={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},aZ=`[^aeiou]`,oZ=`[aeiouy]`,sZ=aZ+`[^aeiouy]*`;oZ+``;var cZ=`^(`+sZ+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,lZ=`^(`+sZ+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`,uZ=`^(`+sZ+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,dZ=`^(`+sZ+`)?[aeiouy]`;function fZ(e){let t,n,r,i,a,o;if(e.length<3)return e;let s=e.substring(0,1);if(s==`y`&&(e=s.toUpperCase()+e.substring(1)),r=/^(.+?)(ss|i)es$/,i=/^(.+?)([^s])s$/,r.test(e)?e=e.replace(r,`$1$2`):i.test(e)&&(e=e.replace(i,`$1$2`)),r=/^(.+?)eed$/,i=/^(.+?)(ed|ing)$/,r.test(e)){let t=r.exec(e);r=new RegExp(cZ),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(dZ),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+sZ+oZ+`[^aeiouwxy]$`),i.test(e)?e+=`e`:a.test(e)?(r=/.$/,e=e.replace(r,``)):o.test(e)&&(e+=`e`)));if(r=/^(.+?)y$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(dZ),t&&r.test(t)&&(e=t+`i`)),r=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(cZ),t&&r.test(t)&&(e=t+rZ[n])}if(r=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(cZ),t&&r.test(t)&&(e=t+iZ[n])}if(r=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,i=/^(.+?)(s|t)(ion)$/,r.test(e))t=r.exec(e)?.[1],r=new RegExp(uZ),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(uZ),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(uZ),i=new RegExp(lZ),a=RegExp(`^`+sZ+oZ+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(uZ),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function pZ(e,t,n=!0){let 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=nZ(t),n&&this.normalizationCache.set(r,t),t)}function mZ(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function hZ(e,t,n,r=!0){if(t&&t!==this.language)throw hY(`LANGUAGE_NOT_SUPPORTED`,t);if(typeof e!=`string`)return[e];let i=this.normalizeToken.bind(this,n??``),a;if(n&&this.tokenizeSkipProperties.has(n))a=[i(e,r)];else{let t=IJ[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=mZ(a);return this.allowDuplicates?o:Array.from(new Set(o))}function gZ(e={}){if(!e.language)e.language=`english`;else if(!LJ.includes(e.language))throw hY(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw hY(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=fZ;else throw hY(`MISSING_STEMMER`,e.language);let n;if(e.stopWords!==!1){if(n=[],Array.isArray(e.stopWords))n=e.stopWords;else if(typeof e.stopWords==`function`)n=e.stopWords(n);else if(e.stopWords)throw hY(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw hY(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw hY(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:hZ,language:e.language,stemmer:t,stemmerSkipProperties:new Set(e.stemmerSkipProperties?[e.stemmerSkipProperties].flat():[]),tokenizeSkipProperties:new Set(e.tokenizeSkipProperties?[e.tokenizeSkipProperties].flat():[]),stopWords:n,allowDuplicates:!!e.allowDuplicates,normalizeToken:pZ,normalizationCache:new Map};return r.tokenize=hZ.bind(r),r.normalizeToken=pZ,r}function _Z(e){return{sharedInternalDocumentStore:e,rules:new Map}}function vZ(e,t){if(e.rules.has(t.id))throw Error(`PINNING_RULE_ALREADY_EXISTS: A pinning rule with id "${t.id}" already exists. Use updateRule to modify it.`);e.rules.set(t.id,t)}function yZ(e,t){if(!e.rules.has(t.id))throw Error(`PINNING_RULE_NOT_FOUND: Cannot update pinning rule with id "${t.id}" because it does not exist. Use addRule to create it.`);e.rules.set(t.id,t)}function bZ(e,t){return e.rules.delete(t)}function xZ(e,t){return e.rules.get(t)}function SZ(e){return Array.from(e.rules.values())}function CZ(e,t){let n=e.toLowerCase().trim(),r=t.pattern.toLowerCase().trim();switch(t.anchoring){case`is`:return n===r;case`starts_with`:return n.startsWith(r);case`contains`:return n.includes(r);default:return!1}}function wZ(e,t){return e?t.conditions.every(t=>CZ(e,t)):!1}function TZ(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())wZ(t,r)&&n.push(r);return n}function EZ(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function DZ(e){return{rules:Array.from(e.rules.entries())}}function OZ(){return{create:_Z,addRule:vZ,updateRule:yZ,removeRule:bZ,getRule:xZ,getAllRules:SZ,getMatchingRules:TZ,load:EZ,save:DZ}}function kZ(e){let t={formatElapsedTime:gY,getDocumentIndexId:_Y,getDocumentProperties:nY,validateSchema:vY};for(let n of WY){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw hY(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!UY.includes(t)&&!WY.includes(t))throw hY(`UNSUPPORTED_COMPONENT`,t)}function AZ({schema:e,sort:t,language:n,components:r,id:i,plugins:a}){r||={};for(let t of a??[]){if(!(`getComponents`in t)||typeof t.getComponents!=`function`)continue;let n=t.getComponents(e),i=Object.keys(n);for(let e of i)if(r[e])throw hY(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=QJ();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:gZ(o):gZ({language:n??`english`}),r.tokenizer&&n)throw hY(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=EY();s||=kX(),l||=ZX(),c||=BY(),u||=OZ(),kZ(r);let{getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,formatElapsedTime:h}=r,g={data:{},caches:{},schema:e,tokenizer:o,index:s,sorter:l,documentsStore:c,pinning:u,internalDocumentIDStore:d,getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,beforeInsert:[],afterInsert:[],beforeRemove:[],afterRemove:[],beforeUpdate:[],afterUpdate:[],beforeUpsert:[],afterUpsert:[],beforeSearch:[],afterSearch:[],beforeInsertMultiple:[],afterInsertMultiple:[],beforeRemoveMultiple:[],afterRemoveMultiple:[],beforeUpdateMultiple:[],afterUpdateMultiple:[],beforeUpsertMultiple:[],afterUpsertMultiple:[],afterCreate:[],formatElapsedTime:h,id:i,plugins:a,version:jZ()};g.data={index:g.index.create(g,d,e),docs:g.documentsStore.create(g,d),sorting:g.sorter.create(g,d,e,t),pinning:g.pinning.create(d)};for(let e of VY)g[e]=(g[e]??[]).concat(HY(g,e));let _=g.afterCreate;return _&&YY(_,g),g}function jZ(){return`{{VERSION}}`}function MZ(e){return e.documentsStore.count(e.data.docs)}function NZ(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw hY(`SCHEMA_VALIDATION_FAILURE`,a);return sY(e.beforeInsert)||sY(e.afterInsert)||sY(e.index.beforeInsert)||sY(e.index.insert)||sY(e.index.afterInsert)?mne(e,t,n,r,i):IZ(e,t,n,r,i)}var PZ=new Set([`enum`,`enum[]`]),FZ=new Set([`string`,`number`]);async function mne(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw hY(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=kY(e.internalDocumentIDStore,s);if(r||await GY(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw hY(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];LZ(n,r,e,t)}return await RZ(e,s,u,f,l,n,t,i),r||await GY(e.afterInsert,e,s,t),s}function IZ(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw hY(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=kY(e.internalDocumentIDStore,s);if(r||GY(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw hY(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];LZ(n,r,e,t)}return zZ(e,s,u,f,l,n,t,i),r||GY(e.afterInsert,e,s,t),s}function LZ(e,t,n,r){if(!(xY(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(SY(t)&&Array.isArray(r))&&!(CY(t)&&Array.isArray(r))&&!(PZ.has(t)&&FZ.has(e))&&e!==t)throw hY(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function RZ(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o];await e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i);let l=e.internalDocumentIDStore.idToInternalId.get(t);await e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),await e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function zZ(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o],l=kY(e.internalDocumentIDStore,t);e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i),e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function BZ(e,t,n,r,i,a){return sY(e.afterInsertMultiple)||sY(e.beforeInsertMultiple)||sY(e.index.beforeInsert)||sY(e.index.insert)||sY(e.index.afterInsert)?VZ(e,t,n,r,i,a):HZ(e,t,n,r,i,a)}async function VZ(e,t,n=1e3,r,i,a=0){let o=[],s=async a=>{let s=Math.min(a+n,t.length),c=t.slice(a,s);for(let t of c){let n=await NZ(e,t,r,i,{avlRebalanceThreshold:c.length});o.push(n)}return s};return await(async()=>{let e=0;for(;e<t.length;){let t=Date.now();if(e=await s(e),a>0){let e=a-(Date.now()-t);e>0&&pY(e)}}})(),i||await KY(e.afterInsertMultiple,e,t),o}function HZ(e,t,n=1e3,r,i,a=0){let o=[],s=0;function c(){let a=t.slice(s*n,(s+1)*n);if(a.length===0)return!1;for(let t of a){let n=NZ(e,t,r,i,{avlRebalanceThreshold:a.length});o.push(n)}return s++,!0}function l(){let e=Date.now();for(;c();)if(a>0){let t=Date.now()-e;if(t>=a){let e=a-t%a;e>0&&pY(e)}}}return l(),i||KY(e.afterInsertMultiple,e,t),o}function UZ(e,t){return e[1]-t[1]}function WZ(e,t){return t[1]-e[1]}function GZ(e=`desc`){return e.toLowerCase()===`asc`?UZ:WZ}function KZ(e,t,n){let r={},i=t.map(([e])=>e),a=e.documentsStore.getMultiple(e.data.docs,i),o=Object.keys(n),s=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e of o){let t;if(s[e]===`number`){let{ranges:r}=n[e],i=r.length,a=Array.from({length:i});for(let e=0;e<i;e++){let t=r[e];a[e]=[`${t.from}-${t.to}`,0]}t=Object.fromEntries(a)}r[e]={count:0,values:t??{}}}let c=a.length;for(let e=0;e<c;e++){let t=a[e];for(let e of o){let i=e.includes(`.`)?rY(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;qZ(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=qZ(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:JZ(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=JZ(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw hY(`FACET_NOT_SUPPORTED`,a)}}}for(let e of o){let t=r[e];if(t.count=Object.keys(t.values).length,s[e]===`string`){let r=n[e],i=GZ(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function qZ(e,t,n){return r=>{for(let i of e){let e=`${i.from}-${i.to}`;n?.has(e)||r>=i.from&&r<=i.to&&(t[e]===void 0?t[e]=1:(t[e]++,n?.add(e)))}}}function JZ(e,t,n){let r=t===`boolean`?`false`:``;return t=>{let i=t?.toString()??r;n?.has(i)||(e[i]=(e[i]??0)+1,n?.add(i))}}var YZ={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},XZ=[`string`,`number`,`boolean`];function ZZ(e,t,n){let r=n.properties,i=r.length,a=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e=0;e<i;e++){let t=r[e];if(a[t]===void 0)throw hY(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!XZ.includes(a[t]))throw hY(`INVALID_GROUP_BY_PROPERTY`,t,XZ.join(`, `),a[t])}let o=t.map(([t])=>AY(e.internalDocumentIDStore,t)),s=e.documentsStore.getMultiple(e.data.docs,o),c=s.length,l=n.maxResult||2**53-1,u=[],d={};for(let e=0;e<i;e++){let t=r[e],n={property:t,perValue:{}},i=new Set;for(let e=0;e<c;e++){let r=s[e],a=rY(r,t);if(a===void 0)continue;let o=typeof a==`boolean`?``+a:a,c=n.perValue[o]??{indexes:[],count:0};c.count>=l||(c.indexes.push(e),c.count++,n.perValue[o]=c,i.add(a))}u.push(Array.from(i)),d[t]=n}let f=QZ(u),p=f.length,m=[];for(let e=0;e<p;e++){let t=f[e],n=t.length,i={values:[],indexes:[]},a=[];for(let e=0;e<n;e++){let n=t[e],o=r[e];a.push(d[o].perValue[typeof n==`boolean`?``+n:n].indexes),i.values.push(n)}i.indexes=tY(a).sort((e,t)=>e-t),i.indexes.length!==0&&m.push(i)}let h=m.length,g=Array.from({length:h});for(let e=0;e<h;e++){let r=m[e],i=n.reduce||YZ,a=r.indexes.map(e=>({id:o[e],score:t[e][1],document:s[e]})),c=i.reducer.bind(null,r.values),l=i.getInitialValue(r.indexes.length),u=a.reduce(c,l);g[e]={values:r.values,result:u}}return g}function QZ(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=QZ(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];GJ(n,t),i.push(n)}return i}function $Z(e,t,n,r){let i=TZ(t,r);if(i.length===0)return n;let a=i.flatMap(e=>e.consequence.promote);a.sort((e,t)=>e.position-t.position);let o=new Set,s=new Map,c=new Set;for(let t of a){let n=kY(e.internalDocumentIDStore,t.doc_id);if(n!==void 0){if(s.has(n)){let e=s.get(n);t.position<e&&s.set(n,t.position);continue}c.has(t.position)||(o.add(n),s.set(n,t.position),c.add(t.position))}}if(s.size===0)return n;let l=n.filter(([e])=>!o.has(e)),u=[];for(let[t,r]of s.entries())n.find(([e])=>e===t)?u.push([t,1e6-r]):e.documentsStore.get(e.data.docs,t)&&u.push([t,0]);u.sort((e,t)=>(s.get(e[0])??1/0)-(s.get(t[0])??1/0));let d=[],f=new Map;for(let e of u){let t=s.get(e[0]);f.set(t,e)}let p=0,m=0;for(;m<l.length+u.length;)if(f.has(m))d.push(f.get(m)),m++;else if(p<l.length)d.push(l[p]),p++,m++;else break;for(let[e,t]of f.entries())e>=d.length&&d.push(t);return d}function eQ(e,t,n){let{term:r,properties:i}=t,a=e.data.index,o=e.caches.propertiesToSearch;if(!o){let t=e.index.getSearchablePropertiesWithTypes(a);o=e.index.getSearchableProperties(a),o=o.filter(e=>t[e].startsWith(`string`)),e.caches.propertiesToSearch=o}if(i&&i!==`*`){for(let e of i)if(!o.includes(e))throw hY(`UNKNOWN_INDEX`,e,o.join(`, `));o=o.filter(e=>i.includes(e))}let s=Object.keys(t.where??{}).length>0,c;s&&(c=e.index.searchByWhereClause(a,e.tokenizer,t.where,n));let l,u=t.threshold!==void 0&&t.threshold!==null?t.threshold:1;if(r||i){let i=MZ(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},aQ(t.relevance),i,c,u),t.exact&&r){let t=r.trim().split(/\s+/);l=l.filter(([n])=>{let r=e.documentsStore.get(e.data.docs,n);if(!r)return!1;for(let e of o){let n=nQ(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${tQ(e)}\\b`).test(n)))return!0}return!1})}}else l=s?NX(a,t.where)||(c?Array.from(c):[]).map(e=>[+e,0]):Object.keys(e.documentsStore.getAll(e.data.docs)).map(e=>[+e,0]);return l}function tQ(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function nQ(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r&&typeof r==`object`&&e in r)r=r[e];else return;return r}function rQ(e,t,n){let r=ZJ();function i(){let i=Object.keys(e.data.index.vectorIndexes),a=t.facets&&Object.keys(t.facets).length>0,{limit:o=10,offset:s=0,distinctOn:c,includeVectors:l=!1}=t,u=t.preflight===!0,d=eQ(e,t,n);if(t.sortBy)if(typeof t.sortBy==`function`){let n=d.map(([e])=>e),r=e.documentsStore.getMultiple(e.data.docs,n).map((e,t)=>[d[t][0],d[t][1],e]);r.sort(t.sortBy),d=r.map(([e,t])=>[e,t])}else d=e.sorter.sortBy(e.data.sorting,d,t.sortBy).map(([t,n])=>[kY(e.internalDocumentIDStore,t),n]);else d=d.sort(eY);d=$Z(e,e.data.pinning,d,t.term);let f;u||(f=c?_Q(e,d,s,o,c):vQ(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||oY(p,i)),a&&(p.facets=KZ(e,d,t.facets)),t.groupBy&&(p.groups=ZZ(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(ZJ()-r),p}async function a(){e.beforeSearch&&await JY(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await qY(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}var iQ={k:1.2,b:.75,d:.5};function aQ(e){let t=e??{};return t.k=t.k??iQ.k,t.b=t.b??iQ.b,t.d=t.d??iQ.d,t}function oQ(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw hY(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw hY(`UNKNOWN_VECTOR_PROPERTY`,r.property);let a=i.node.size;if(r?.value.length!==a)throw r?.property===void 0||r?.value.length===void 0?hY(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):hY(`INVALID_INPUT_VECTOR`,r.property,a,r.value.length);let o=e.data.index,s;return Object.keys(t.where??{}).length>0&&(s=e.index.searchByWhereClause(o,e.tokenizer,t.where,n)),i.node.find(r.value,t.similarity??.8,s)}function sQ(e,t,n=`english`){let r=ZJ();function i(){let i=oQ(e,t,n).sort(eY);i=$Z(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=KZ(e,i,t.facets));let o=t.vector.property,s=t.includeVectors??!1,c=t.limit??10,l=t.offset??0,u=Array.from({length:c});for(let t=0;t<c;t++){let n=i[t+l];if(!n)break;let r=e.data.docs.docs[n[0]];r&&(s||(r[o]=null),u[t]={id:AY(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=ZZ(e,i,t.groupBy));let f=ZJ()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:XJ(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await JY(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await qY(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function cQ(e,t,n){let r=dQ(eQ(e,t,n)),i=oQ(e,t,n),a=t.hybridWeights;return mQ(r,i,t.term??``,a)}function lQ(e,t,n){let r=ZJ();function i(){let i=cQ(e,t,n);i=$Z(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=KZ(e,i,t.facets));let o;t.groupBy&&(o=ZZ(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=vQ(e,i,s,c).filter(Boolean),u=ZJ(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:XJ(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||oY(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await JY(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await qY(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function uQ(e){return e[1]}function dQ(e){let t=Math.max.apply(Math,e.map(uQ));return e.map(([e,n])=>[e,n/t])}function fQ(e,t){return e/t}function pQ(e,t){return(n,r)=>n*e+r*t}function mQ(e,t,n,r){let i=Math.max.apply(Math,e.map(uQ)),a=Math.max.apply(Math,t.map(uQ)),{text:o,vector:s}=r&&r.text&&r.vector?r:hQ(n),c=new Map,l=e.length,u=pQ(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u(fQ(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=fQ(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function hQ(e){return{text:.5,vector:.5}}function gQ(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return rQ(e,t,n);if(r===`vector`)return sQ(e,t);if(r===`hybrid`)return lQ(e,t);throw hY(`INVALID_SEARCH_MODE`,r)}function _Q(e,t,n,r,i){let a=e.data.docs,o=new Map,s=[],c=new Set,l=t.length,u=0;for(let d=0;d<l;d++){let l=t[d];if(l===void 0)continue;let[f,p]=l;if(c.has(f))continue;let m=e.documentsStore.get(a,f),h=rY(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:AY(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function vQ(e,t,n,r){let i=e.data.docs,a=Array.from({length:r}),o=new Set;for(let s=n;s<r+n;s++){let n=t[s];if(n===void 0)break;let[r,c]=n;if(!o.has(r)){let t=e.documentsStore.get(i,r);a[s]={id:AY(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}var yQ=e(PJ(),1),bQ=`0.0.0-unknown`,xQ={protocol:`x-ok-client-protocol`,runtime:`x-ok-client-runtime`,kind:`x-ok-client-kind`};function SQ({kind:e,runtimeVersion:t}){return{[xQ.protocol]:`1`,[xQ.runtime]:t,[xQ.kind]:e}}function CQ({kind:e,runtimeVersion:t}){return{clientProtocolVersion:1,clientRuntimeVersion:t,clientKind:e}}var wQ=8192,TQ=32768,EQ=`…[truncated]`;function DQ(e){let t=e.trim();if(t.length===0||t[0]!==`{`)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!=`object`||!n||Array.isArray(n))return null;let r=n;return{event:typeof r.event==`string`?r.event:void 0,fields:r}}function OQ(e){return e.length<=8192?e:`${e.slice(0,wQ-12)}${EQ}`}var kQ=`source`;function AQ(e){return{ok:!1,error:e}}function jQ(e){return{ok:!0,...e}}function MQ(){return yu.parse({})}function NQ(e,t){let n=e.toString();if(n.length===0)return MQ();let r=_r(n);if(r.errors.length>0)return console.warn(`[bindConfigDoc:${t}] Y.Text contains invalid YAML; returning schema defaults. Errors: ${r.errors.map(e=>e.message).join(`; `)}`),MQ();let i=r.toJSON()??{},a=yu.safeParse(i);return a.success?a.data:(console.warn(`[bindConfigDoc:${t}] Y.Text content fails schema validation; returning schema defaults. First issue: ${a.error.issues[0]?.message??`(unknown)`}`),MQ())}function PQ(e,t,n={}){return xu(`config.bind`,{"config.scope":t,"config.transport":`ytext`},()=>FQ(e,t,n))}function FQ(e,t,n){let{ytextKey:r=kQ}=n,i=e.document,a=i.getText(r),o=new Set,s=new Set,c=!1,l=!1;function u(){if(c)return;let e=NQ(a,t);for(let n of o)try{n(e)}catch(e){console.warn(`[bindConfigDoc:${t}] listener threw:`,e)}}function d(){if(c||(u(),l))return;l=!0;let e=[...s];s.clear();for(let n of e)try{n()}catch(e){console.warn(`[bindConfigDoc:${t}] synced listener threw:`,e)}}a.observe(u),e.on(`synced`,d);function f(e){if(c)return AQ({code:`WRITE_ERROR`,detail:`ConfigBinding (${t}) has been disposed`});let n=Du(e,t);if(n!==null)return AQ(n);let r=_r(a.toString()),o=r.contents!==null&&!g(r.contents);if(r.errors.length>0||o){Su(`config.corrupt-ytext-reset`,{"config.scope":t,"config.parse.errorCount":r.errors.length,"config.parse.topLevelNonMap":o});let e=r.errors.length>0?r.errors.map(e=>e.message).join(`; `):`top-level YAML is not a mapping`;console.warn(`[bindConfigDoc:${t}] dropping corrupt Y.Text and re-applying patch onto empty doc. Reason: ${e}`),r=_r(``)}r.contents===null&&(r.contents=r.createNode({}));let s=ku(r,e),l=r.toJSON()??{},u=xu(`config.validate`,{"config.scope":t,"config.validation.layer":`L1`},e=>{let t=yu.safeParse(l);if(e.setAttribute(`config.outcome`,t.success?`success`:`rejected`),!t.success)for(let e of t.error.issues)Su(`config.validation.issue`,{"issue.path":e.path.map(e=>String(e)).join(`.`),"issue.message":e.message});return t});if(!u.success)return AQ({code:`SCHEMA_INVALID`,issues:u.error.issues.map(Au)});let d=r.toString();return i.transact(()=>{a.length>0&&a.delete(0,a.length),a.insert(0,d)}),jQ({effective:u.data,appliedPaths:s})}return{current(){return NQ(a,t)},patch(e){return xu(`config.patch`,{"config.scope":t,"config.transport":`ytext`},t=>{let n=f(e);return t.setAttribute(`config.outcome`,n.ok?`success`:`rejected`),n.ok||t.setAttribute(`config.error.code`,n.error.code),n})},subscribe(e){return o.add(e),()=>{o.delete(e)}},hasSynced(){return l},subscribeSynced(e){if(c)return()=>{};if(l){let n=!1;return queueMicrotask(()=>{if(!(n||c))try{e()}catch(e){console.warn(`[bindConfigDoc:${t}] synced listener threw:`,e)}}),()=>{n=!0}}return s.add(e),()=>{s.delete(e)}},dispose(){c||(c=!0,a.unobserve(u),e.off(`synced`,d),o.clear(),s.clear())}}}var IQ=`source`,LQ=800;function RQ(e){return{ok:!1,error:e}}function zQ(e){return{ok:!0,...e}}function BQ(e,t={}){let{ytextKey:n=IQ,acceptanceDelayMs:r=LQ}=t,i=e.document,a=i.getText(n),o=new Set,s=new Set,c=new Set,l=!1,u=`idle`,d=null;function f(){d!==null&&(clearTimeout(d),d=null)}function p(e){if(!l&&u!==e){u=e;for(let t of c)try{t(e)}catch(e){console.warn(`[bindOkignoreDoc] status listener threw:`,e)}}}function m(){if(l)return;let e=a.toString();for(let t of o)try{t(e)}catch(e){console.warn(`[bindOkignoreDoc] text listener threw:`,e)}}function h(e){if(!l)for(let t of s)try{t(e)}catch(e){console.warn(`[bindOkignoreDoc] rejection listener threw:`,e)}}return a.observe(m),e.on(`synced`,m),{current(){return a.toString()},patch(e){return l?RQ({code:`WRITE_ERROR`,detail:`OkignoreBinding has been disposed`}):(i.transact(()=>{a.length>0&&a.delete(0,a.length),e.length>0&&a.insert(0,e)}),f(),p(`pending`),d=setTimeout(()=>{d=null,!l&&u===`pending`&&p(`accepted`)},r),zQ({text:e}))},subscribe(e){return o.add(e),()=>{o.delete(e)}},subscribeRejection(e){return s.add(e),()=>{s.delete(e)}},subscribeStatus(e){return c.add(e),()=>{c.delete(e)}},status(){return u},notifyRejection(e){l||(f(),p(`rejected`),h({error:e,text:a.toString()}))},dispose(){l||(l=!0,f(),a.unobserve(m),e.off(`synced`,m),o.clear(),s.clear(),c.clear())}}}function VQ(e,t,n){return HQ([e,t,n],[])}function HQ(e,t){if(t.length>0){let n=Tu(yu,t);if(n?.scope===`user`)return e[0];if(n?.scope===`project`)return e[1]??e[0];if(n?.scope===`project-local`)return e[2]??e[1]??e[0]}let n=UQ(e);if(n===void 0)return;if(n===null)return null;if(Array.isArray(n)||typeof n!=`object`)return n;let r=e.map(e=>WQ(e)?e:void 0),i=new Set;for(let e of r)if(e!==void 0)for(let t of Object.keys(e))i.add(t);let a={};for(let e of i)a[e]=HQ(r.map(t=>t===void 0?void 0:t[e]),[...t,e]);return a}function UQ(e){for(let t=e.length-1;t>=0;t--)if(e[t]!==void 0)return e[t]}function WQ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var GQ=2e3;function KQ(e){let t=Date.now();for(let[n,r]of e.entries()){let i=r;i.timestamp&&t-i.timestamp>3e4&&e.delete(n)}}function qQ(e,t){for(let[,n]of e.entries()){let e=n;if(e.timestamp&&e.timestamp>t)return!0}return!1}var JQ=`__system__`,YQ=`__config__/project`,XQ=`__user__/config.yml`,ZQ=`__local__/project`,QQ=`__config__/okignore`;Object.freeze([YQ,ZQ,XQ,QQ]);var $Q=`__skill__/`,e$=`__template__/`,t$=[`project`,`global`];function n$(e){return e.startsWith(`__skill__/`)||e.startsWith(`__template__/`)}var r$=`.ok/skills`;function i$(e){return`${r$}/${e}/SKILL`}var a$=/^__skill__\/global\/([^/]+)(?:\/(references\/.+))?$/;function o$(e){let t=a$.exec(e);if(!t)return null;let n=t[1],r=t[2];return r===void 0?{name:n,kind:`skill`,rel:null}:{name:n,kind:`reference`,rel:r.slice(11)}}function s$(e,t){return e===`project`?i$(t):`${$Q}${e}/${t}`}function c$(e){if(e===``)return``;try{return e.split(`/`).map(e=>decodeURIComponent(e)).join(`/`)}catch{return e}}function l$(e){if(e.startsWith(`__skill__/`)){let t=e.slice(10),n=t.indexOf(`/`);if(n<0)return null;let r=t.slice(0,n);if(r!==`global`&&r!==`project`)return null;let i=t.slice(n+1);return i?{kind:`skill`,scope:r,name:c$(i)}:null}if(e.startsWith(`__template__/`)){let t=e.slice(13);if(!t)return null;let n=t.lastIndexOf(`/`),r=n<0?t:t.slice(n+1);return r?{kind:`template`,folder:c$(n<0?``:t.slice(0,n)),name:c$(r)}:null}return null}var u$=/^(?:(.+)\/)?\.ok\/templates\/([^/]+?)(?:\.mdx?)?$/;function d$(e){let t=u$.exec(e);if(t){let e=(t[1]??``).replace(/^\/+|\/+$/g,``);return`${e$}${e?`${e}/`:``}${t[2]}`}return null}var f$=[`invalid-args`,`nested-project`,`target-not-empty`,`mkdir-failed`,`git-init-failed`,`init-failed`,`discovery-failed`],p$=[`.mdx`,`.md`],m$=`epoch`,h$=512*1024;function g$(e,t=h$){return typeof e==`number`&&Number.isFinite(e)&&e>t}var _$=[`claude`,`claude-desktop`,`cursor`,`codex`,`opencode`,`openclaw`,`pi`],v$={claude:`Claude`,"claude-desktop":`Claude Desktop`,cursor:`Cursor`,codex:`Codex`,opencode:`OpenCode`,openclaw:`OpenClaw`,pi:`Pi`},y$={claude:`.claude/skills`,"claude-desktop":null,cursor:`.cursor/skills`,codex:`.codex/skills`,opencode:`.opencode/skills`,openclaw:null,pi:`.pi/skills`},b$=_$.filter(e=>y$[e]!==null);b$.filter(e=>e!==`pi`).map(e=>({hostDir:(y$[e]??``).split(`/`)[0],editorId:e}));var x$={claude:`claude-code`,"claude-desktop":`claude-code`,cursor:`cursor`,codex:`codex`,opencode:`opencode`,openclaw:`openclaw`,pi:`pi`},S$={cursor:/\bCursor(?:\([^)]+\))?\/\d/,codex:/\bCodex(?:\([^)]+\))?\/\d/,"claude-desktop":/\bClaude(?:\([^)]+\))?\/\d/};function C$(){if(typeof navigator>`u`)return null;let e=navigator.userAgent;for(let[t,n]of Object.entries(S$))if(n.test(e))return t;return null}var w$=[`incoming`,`outgoing`,`both`];function T$(e){return w$.includes(e)}var E$=`open-knowledge`,D$=[{id:`chart`,title:`Chart`,description:`A bar chart whose series colors track the OK chart palette.`,html:`<div style="font-family:system-ui,sans-serif;padding:20px;color:var(--foreground)">
|
|
383
|
+
`,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 hY(e,...t){let n=Error(KJ(mY[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function gY(e){return{raw:Number(e),formatted:XJ(e)}}function _Y(e){if(e.id){if(typeof e.id!=`string`)throw hY(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return QJ()}function vY(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];if(t!==void 0&&!(r===`geopoint`&&typeof t==`object`&&typeof t.lon==`number`&&typeof t.lat==`number`)&&!(r===`enum`&&(typeof t==`string`||typeof t==`number`))){if(r===`enum[]`&&Array.isArray(t)){let e=t.length;for(let r=0;r<e;r++)if(typeof t[r]!=`string`&&typeof t[r]!=`number`)return n+`.`+r;continue}if(SY(r)){let e=TY(r);if(!Array.isArray(t)||t.length!==e)throw hY(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(CY(r)){if(!Array.isArray(t))return n;let e=wY(r),i=t.length;for(let r=0;r<i;r++)if(typeof t[r]!==e)return n+`.`+r;continue}if(typeof r==`object`){if(!t||typeof t!=`object`)return n;let e=vY(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}var yY={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},bY={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function xY(e){return e===`geopoint`}function SY(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function CY(e){return typeof e==`string`&&yY[e]}function wY(e){return bY[e]}function TY(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw hY(`INVALID_VECTOR_VALUE`,e);case t<=0:throw hY(`INVALID_VECTOR_SIZE`,e);default:return t}}function EY(){return{idToInternalId:new Map,internalIdToId:[],save:DY,load:OY}}function DY(e){return{internalIdToId:e.internalIdToId}}function OY(e,t){let{internalIdToId:n}=t;e.internalDocumentIDStore.idToInternalId.clear(),e.internalDocumentIDStore.internalIdToId=[];let r=n.length;for(let t=0;t<r;t++){let r=n[t];e.internalDocumentIDStore.idToInternalId.set(r,t+1),e.internalDocumentIDStore.internalIdToId.push(r)}}function kY(e,t){if(typeof t==`string`){let n=e.idToInternalId.get(t);if(n)return n;let r=e.idToInternalId.size+1;return e.idToInternalId.set(t,r),e.internalIdToId.push(t),r}return t>e.internalIdToId.length?kY(e,t.toString()):t}function AY(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function jY(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function MY(e,t){let n=kY(e.sharedInternalDocumentStore,t);return e.docs[n]}function NY(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=kY(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function PY(e){return e.docs}function FY(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function IY(e,t){let n=kY(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function LY(e){return e.count}function RY(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function zY(e){return{docs:e.docs,count:e.count}}function BY(){return{create:jY,get:MY,getMultiple:NY,getAll:PY,store:FY,remove:IY,count:LY,load:RY,save:zY}}var VY=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function HY(e,t){let n=[],r=e.plugins?.length;if(!r)return n;for(let i=0;i<r;i++)try{let r=e.plugins[i];typeof r[t]==`function`&&n.push(r[t])}catch(e){throw console.error(`Caught error in getAllPluginsByHook:`,e),hY(`PLUGIN_CRASHED`)}return n}var UY=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],WY=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function GY(e,t,n,r){if(e.some(sY))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function KY(e,t,n){if(e.some(sY))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function qY(e,t,n,r,i){if(e.some(sY))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function JY(e,t,n,r){if(e.some(sY))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function YY(e,t){if(e.some(sY))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var XY=class e{k;v;l=null;r=null;h=1;constructor(e,t){this.k=e,this.v=new Set(t)}updateHeight(){this.h=Math.max(e.getHeight(this.l),e.getHeight(this.r))+1}static getHeight(e){return e?e.h:0}getBalanceFactor(){return e.getHeight(this.l)-e.getHeight(this.r)}rotateLeft(){let e=this.r;return this.r=e.l,e.l=this,this.updateHeight(),e.updateHeight(),e}rotateRight(){let e=this.l;return this.l=e.r,e.r=this,this.updateHeight(),e.updateHeight(),e}toJSON(){return{k:this.k,v:Array.from(this.v),l:this.l?this.l.toJSON():null,r:this.r?this.r.toJSON():null,h:this.h}}static fromJSON(t){let n=new e(t.k,t.v);return n.l=t.l?e.fromJSON(t.l):null,n.r=t.r?e.fromJSON(t.r):null,n.h=t.h,n}},ZY=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new XY(e,t))}insert(e,t,n=1e3){this.root=this.insertNode(this.root,e,t,n)}insertMultiple(e,t,n=1e3){for(let r of t)this.insert(e,r,n)}rebalance(){this.root&&=this.rebalanceNode(this.root)}toJSON(){return{root:this.root?this.root.toJSON():null,insertCount:this.insertCount}}static fromJSON(t){let n=new e;return n.root=t.root?XY.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new XY(t,[n]);let i=[],a=e,o=null;for(;a!==null;)if(i.push({parent:o,node:a}),t<a.k)if(a.l===null){a.l=new XY(t,[n]),i.push({parent:a,node:a.l});break}else o=a,a=a.l;else if(t>a.k)if(a.r===null){a.r=new XY(t,[n]),i.push({parent:a,node:a.r});break}else o=a,a=a.r;else return a.v.add(n),e;let s=!1;this.insertCount++%r===0&&(s=!0);for(let t=i.length-1;t>=0;t--){let{parent:n,node:r}=i[t];if(r.updateHeight(),s){let t=this.rebalanceNode(r);n?n.l===r?n.l=t:n.r===r&&(n.r=t):e=t}}return e}rebalanceNode(e){let t=e.getBalanceFactor();if(t>1){if(e.l&&e.l.getBalanceFactor()>=0)return e.rotateRight();if(e.l)return e.l=e.l.rotateLeft(),e.rotateRight()}if(t<-1){if(e.r&&e.r.getBalanceFactor()<=0)return e.rotateLeft();if(e.r)return e.r=e.r.rotateRight(),e.rotateLeft()}return e}find(e){let t=this.findNodeByKey(e);return t?t.v:null}contains(e){return this.find(e)!==null}getSize(){let e=0,t=[],n=this.root;for(;n||t.length>0;){for(;n;)t.push(n),n=n.l;n=t.pop(),e++,n=n.r}return e}isBalanced(){if(!this.root)return!0;let e=[this.root];for(;e.length>0;){let t=e.pop(),n=t.getBalanceFactor();if(Math.abs(n)>1)return!1;t.l&&e.push(t.l),t.r&&e.push(t.r)}return!0}remove(e){this.root=this.removeNode(this.root,e)}removeDocument(e,t){let n=this.findNodeByKey(e);n&&(n.v.size===1?this.root=this.removeNode(this.root,e):n.v=new Set([...n.v.values()].filter(e=>e!==t)))}findNodeByKey(e){let t=this.root;for(;t;)if(e<t.k)t=t.l;else if(e>t.k)t=t.r;else return t;return null}removeNode(e,t){if(e===null)return null;let n=[],r=e;for(;r!==null&&r.k!==t;)n.push(r),r=t<r.k?r.l:r.r;if(r===null)return e;if(r.l===null||r.r===null){let t=r.l?r.l:r.r;if(n.length===0)e=t;else{let e=n[n.length-1];e.l===r?e.l=t:e.r=t}}else{let e=r,t=r.r;for(;t.l!==null;)e=t,t=t.l;r.k=t.k,r.v=t.v,e.l===t?e.l=t.r:e.r=t.r,r=e}n.push(r);for(let t=n.length-1;t>=0;t--){let r=n[t];r.updateHeight();let i=this.rebalanceNode(r);if(t>0){let e=n[t-1];e.l===r?e.l=i:e.r===r&&(e.r=i)}else e=i}return e}rangeSearch(e,t){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),i.k>=e&&i.k<=t)for(let e of i.v)n.add(e);if(i.k>t)break;i=i.r}return n}greaterThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.r;if(i=r.pop(),t&&i.k>=e||!t&&i.k>e)for(let e of i.v)n.add(e);else if(i.k<=e)break;i=i.l}return n}lessThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),t&&i.k<=e||!t&&i.k<e)for(let e of i.v)n.add(e);else if(i.k>e)break;i=i.r}return n}},QY=class e{numberToDocumentId;constructor(){this.numberToDocumentId=new Map}insert(e,t){this.numberToDocumentId.has(e)?this.numberToDocumentId.get(e).add(t):this.numberToDocumentId.set(e,new Set([t]))}find(e){let t=this.numberToDocumentId.get(e);return t?Array.from(t):null}remove(e){this.numberToDocumentId.delete(e)}removeDocument(e,t){let n=this.numberToDocumentId.get(t);n&&(n.delete(e),n.size===0&&this.numberToDocumentId.delete(t))}contains(e){return this.numberToDocumentId.has(e)}getSize(){let e=0;for(let t of this.numberToDocumentId.values())e+=t.size;return e}filter(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`eq`:{let t=e[n],r=this.numberToDocumentId.get(t);return r?Array.from(r):[]}case`in`:{let t=e[n],r=new Set;for(let e of t){let t=this.numberToDocumentId.get(e);if(t)for(let e of t)r.add(e)}return Array.from(r)}case`nin`:{let t=new Set(e[n]),r=new Set;for(let[e,n]of this.numberToDocumentId.entries())if(!t.has(e))for(let e of n)r.add(e);return Array.from(r)}default:throw Error(`Invalid operation`)}}filterArr(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`containsAll`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e].filter(e=>t.has(e))));return Array.from(r)}case`containsAny`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e,...t]));return Array.from(r)}default:throw Error(`Invalid operation`)}}static fromJSON(t){if(!t.numberToDocumentId)throw Error(`Invalid Flat Tree JSON`);let n=new e;for(let[e,r]of t.numberToDocumentId)n.numberToDocumentId.set(e,new Set(r));return n}toJSON(){return{numberToDocumentId:Array.from(this.numberToDocumentId.entries()).map(([e,t])=>[e,Array.from(t)])}}};function $Y(e,t,n){if(n<0)return-1;if(e===t)return 0;let r=e.length,i=t.length;if(r===0)return i<=n?i:-1;if(i===0)return r<=n?r:-1;let a=Math.abs(r-i);if(e.startsWith(t))return a<=n?a:-1;if(t.startsWith(e))return 0;if(a>n)return-1;let o=[];for(let e=0;e<=r;e++){o[e]=[e];for(let t=1;t<=i;t++)o[e][t]=e===0?t:0}for(let a=1;a<=r;a++){let r=1/0;for(let n=1;n<=i;n++)e[a-1]===t[n-1]?o[a][n]=o[a-1][n-1]:o[a][n]=Math.min(o[a-1][n]+1,o[a][n-1]+1,o[a-1][n-1]+1),r=Math.min(r,o[a][n]);if(r>n)return-1}return o[r][i]<=n?o[r][i]:-1}function eX(e,t,n){let r=$Y(e,t,n);return{distance:r,isBounded:r>=0}}var tX=class e{k;s;c=new Map;d=new Set;e;w=``;constructor(e,t,n){this.k=e,this.s=t,this.e=n}updateParent(e){this.w=e.w+this.s}addDocument(e){this.d.add(e)}removeDocument(e){return this.d.delete(e)}findAllWords(e,t,n,r){let i=[this];for(;i.length>0;){let a=i.pop();if(a.e){let{w:i,d:o}=a;if(n&&i!==t)continue;if($J(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&eX(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if($J(e,i)!=null&&o.size>0){let t=e[i];for(let e of o)t.includes(e)||t.push(e)}}a.c.size>0&&i.push(...a.c.values())}return e}insert(t,n){let r=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=r.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c){if(r=s,i+=l,i===a){s.e||=!0,s.addDocument(n);return}continue}let u=o.slice(0,l),d=o.slice(l),f=t.slice(i+l),p=new e(u[0],u,!1);if(r.c.set(u[0],p),p.updateParent(r),s.s=d,s.k=d[0],p.c.set(d[0],s),s.updateParent(p),f){let t=new e(f[0],f,!0);t.addDocument(n),p.c.set(f[0],t),t.updateParent(p)}else p.e=!0,p.addDocument(n);return}else{let a=new e(o,t.slice(i),!0);a.addDocument(n),r.c.set(o,a),a.updateParent(r);return}}r.e||=!0,r.addDocument(n)}_findLevenshtein(e,t,n,r,i){let a=[{node:this,index:t,tolerance:n}];for(;a.length>0;){let{node:t,index:n,tolerance:o}=a.pop();if(t.w.startsWith(e)){t.findAllWords(i,e,!1,0);continue}if(o<0)continue;if(t.e){let{w:n,d:a}=t;if(n&&(eX(e,n,r).isBounded&&(i[n]=[]),$J(i,n)!==void 0&&a.size>0)){let e=new Set(i[n]);for(let t of a)e.add(t);i[n]=Array.from(e)}}if(n>=e.length)continue;let s=e[n];if(t.c.has(s)){let e=t.c.get(s);a.push({node:e,index:n+1,tolerance:o})}a.push({node:t,index:n+1,tolerance:o-1});for(let[e,r]of t.c)a.push({node:r,index:n,tolerance:o-1}),e!==s&&a.push({node:r,index:n+1,tolerance:o-1})}}find(e){let{term:t,exact:n,tolerance:r}=e;if(r&&!n){let e={};return this._findLevenshtein(t,0,r,r,e),e}else{let e=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=e.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c)e=s,i+=l;else if(i+l===a)if(l===a-i){if(n)return{};{let e={};return s.findAllWords(e,t,n,r),e}}else return{};else return{}}else return{}}let o={};return e.findAllWords(o,t,n,r),o}}contains(e){let t=this,n=0,r=e.length;for(;n<r;){let i=e[n],a=t.c.get(i);if(a){let i=a.s,o=i.length,s=0;for(;s<o&&n+s<r&&i[s]===e[n+s];)s++;if(s<o)return!1;n+=o,t=a}else return!1}return!0}removeWord(e){if(!e)return!1;let t=this,n=e.length,r=[];for(let i=0;i<n;i++){let n=e[i];if(t.c.has(n)){let e=t.c.get(n);r.push({parent:t,character:n}),i+=e.s.length-1,t=e}else return!1}for(t.d.clear(),t.e=!1;r.length>0&&t.c.size===0&&!t.e&&t.d.size===0;){let{parent:e,character:n}=r.pop();e.c.delete(n),t=e}return!0}removeDocumentByWord(e,t,n=!0){if(!e)return!0;let r=this,i=e.length;for(let a=0;a<i;a++){let i=e[a];if(r.c.has(i)){let o=r.c.get(i);a+=o.s.length-1,r=o,n&&r.w!==e||r.removeDocument(t)}else return!1}return!0}static getCommonPrefix(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return e.slice(0,r)}toJSON(){return{w:this.w,s:this.s,e:this.e,k:this.k,d:Array.from(this.d),c:Array.from(this.c?.entries())?.map(([e,t])=>[e,t.toJSON()])}}static fromJSON(t){let n=new e(t.k,t.s,t.e);return n.w=t.w,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([t,n])=>[t,e.fromJSON(n)])||[]),n}},nX=class e extends tX{constructor(){super(``,``,!1)}static fromJSON(t){let n=new e;return n.w=t.w,n.s=t.s,n.e=t.e,n.k=t.k,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([e,t])=>[e,tX.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},rX=2,iX=6371e3,aX=class e{point;docIDs;left;right;parent;constructor(e,t){this.point=e,this.docIDs=new Set(t),this.left=null,this.right=null,this.parent=null}toJSON(){return{point:this.point,docIDs:Array.from(this.docIDs),left:this.left?this.left.toJSON():null,right:this.right?this.right.toJSON():null}}static fromJSON(t,n=null){let r=new e(t.point,t.docIDs);return r.parent=n,t.left&&(r.left=e.fromJSON(t.left,r)),t.right&&(r.right=e.fromJSON(t.right,r)),r}},oX=class e{root;nodeMap;constructor(){this.root=null,this.nodeMap=new Map}getPointKey(e){return`${e.lon},${e.lat}`}insert(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);if(r){t.forEach(e=>r.docIDs.add(e));return}let i=new aX(e,t);if(this.nodeMap.set(n,i),this.root==null){this.root=i;return}let a=this.root,o=0;for(;;){if(o%rX===0)if(e.lon<a.point.lon){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}else if(e.lat<a.point.lat){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}o++}}contains(e){let t=this.getPointKey(e);return this.nodeMap.has(t)}getDocIDsByCoordinates(e){let t=this.getPointKey(e),n=this.nodeMap.get(t);return n?Array.from(n.docIDs):null}removeDocByID(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);r&&(r.docIDs.delete(t),r.docIDs.size===0&&(this.nodeMap.delete(n),this.deleteNode(r)))}deleteNode(e){let t=e.parent,n=e.left?e.left:e.right;n&&(n.parent=t),t?t.left===e?t.left=n:t.right===e&&(t.right=n):(this.root=n,this.root&&(this.root.parent=null))}searchByRadius(t,n,r=!0,i=`asc`,a=!1){let o=a?e.vincentyDistance:e.haversineDistance,s=[{node:this.root,depth:0}],c=[];for(;s.length>0;){let{node:e,depth:i}=s.pop();if(e==null)continue;let a=o(t,e.point);(r?a<=n:a>n)&&c.push({point:e.point,docIDs:Array.from(e.docIDs)}),e.left!=null&&s.push({node:e.left,depth:i+1}),e.right!=null&&s.push({node:e.right,depth:i+1})}return i&&c.sort((e,n)=>{let r=o(t,e.point),a=o(t,n.point);return i.toLowerCase()===`asc`?r-a:a-r}),c}searchByPolygon(t,n=!0,r=null,i=!1){let a=[{node:this.root,depth:0}],o=[];for(;a.length>0;){let{node:r,depth:i}=a.pop();if(r==null)continue;r.left!=null&&a.push({node:r.left,depth:i+1}),r.right!=null&&a.push({node:r.right,depth:i+1});let s=e.isPointInPolygon(t,r.point);(s&&n||!s&&!n)&&o.push({point:r.point,docIDs:Array.from(r.docIDs)})}let s=e.calculatePolygonCentroid(t);if(r){let t=i?e.vincentyDistance:e.haversineDistance;o.sort((e,n)=>{let i=t(s,e.point),a=t(s,n.point);return r.toLowerCase()===`asc`?i-a:a-i})}return o}toJSON(){return{root:this.root?this.root.toJSON():null}}static fromJSON(t){let n=new e;return t.root&&(n.root=aX.fromJSON(t.root),n.buildNodeMap(n.root)),n}buildNodeMap(e){if(e==null)return;let t=this.getPointKey(e.point);this.nodeMap.set(t,e),e.left&&this.buildNodeMap(e.left),e.right&&this.buildNodeMap(e.right)}static calculatePolygonCentroid(e){let t=0,n=0,r=0,i=e.length;for(let a=0,o=i-1;a<i;o=a++){let i=e[a].lon,s=e[a].lat,c=e[o].lon,l=e[o].lat,u=i*l-c*s;t+=u,n+=(i+c)*u,r+=(s+l)*u}t/=2;let a=6*t;return n/=a,r/=a,{lon:n,lat:r}}static isPointInPolygon(e,t){let n=!1,r=t.lon,i=t.lat,a=e.length;for(let t=0,o=a-1;t<a;o=t++){let a=e[t].lon,s=e[t].lat,c=e[o].lon,l=e[o].lat;s>i!=l>i&&r<(c-a)*(i-s)/(l-s)+a&&(n=!n)}return n}static haversineDistance(e,t){let n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=(t.lat-e.lat)*n,o=(t.lon-e.lon)*n,s=Math.sin(a/2)*Math.sin(a/2)+Math.cos(r)*Math.cos(i)*Math.sin(o/2)*Math.sin(o/2);return iX*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))}static vincentyDistance(e,t){let n=6378137,r=1/298.257223563,i=(1-r)*n,a=Math.PI/180,o=e.lat*a,s=t.lat*a,c=(t.lon-e.lon)*a,l=Math.atan((1-r)*Math.tan(o)),u=Math.atan((1-r)*Math.tan(s)),d=Math.sin(l),f=Math.cos(l),p=Math.sin(u),m=Math.cos(u),h=c,g,_=1e3,v,y,b,x,S,C;do{let e=Math.sin(h),t=Math.cos(h);if(v=Math.sqrt(m*e*(m*e)+(f*p-d*m*t)*(f*p-d*m*t)),v===0)return 0;y=d*p+f*m*t,b=Math.atan2(v,y),x=f*m*e/v,S=1-x*x,C=y-2*d*p/S,isNaN(C)&&(C=0);let n=r/16*S*(4+r*(4-3*S));g=h,h=c+(1-n)*r*x*(b+n*v*(C+n*y*(-1+2*C*C)))}while(Math.abs(h-g)>1e-12&&--_>0);if(_===0)return NaN;let ee=S*(n*n-i*i)/(i*i),w=1+ee/16384*(4096+ee*(-768+ee*(320-175*ee))),T=ee/1024*(256+ee*(-128+ee*(74-47*ee))),te=T*v*(C+T/4*(y*(-1+2*C*C)-T/6*C*(-3+4*v*v)*(-3+4*C*C)));return i*w*(b-te)}},sX=class e{true;false;constructor(){this.true=new Set,this.false=new Set}insert(e,t){t?this.true.add(e):this.false.add(e)}delete(e,t){t?this.true.delete(e):this.false.delete(e)}getSize(){return this.true.size+this.false.size}toJSON(){return{true:Array.from(this.true),false:Array.from(this.false)}}static fromJSON(t){let n=new e;return n.true=new Set(t.true),n.false=new Set(t.false),n}};function cX(e,t,n,r,i,{k:a,b:o,d:s}){return Math.log(1+(n-t+.5)/(t+.5))*(s+e*(a+1))/(e+a*(1-o+o*r/i))}var lX=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=uX(t,this.size);this.vectors.set(e,[n,t])}remove(e){this.vectors.delete(e)}find(e,t,n){return e instanceof Float32Array||(e=new Float32Array(e)),dX(e,n,this.vectors,this.size,t)}toJSON(){let e=[];for(let[t,[n,r]]of this.vectors)e.push([t,[n,Array.from(r)]]);return{size:this.size,vectors:e}}static fromJSON(t){let n=t,r=new e(n.size);for(let[e,[t,i]]of n.vectors)r.vectors.set(e,[t,new Float32Array(i)]);return r}};function uX(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function dX(e,t,n,r,i){let a=uX(e,r),o=[],s=t||n.keys();for(let t of s){let s=n.get(t);if(!s)continue;let c=s[0],l=s[1],u=0;for(let t=0;t<r;t++)u+=e[t]*l[t];let d=u/(a*c);d>=i&&o.push([t,d])}return o}function fX(e,t,n,r,i){let a=kY(e.sharedInternalDocumentStore,n);e.avgFieldLength[t]=((e.avgFieldLength[t]??0)*(i-1)+r.length)/i,e.fieldLengths[t][a]=r.length,e.frequencies[t][a]={}}function pX(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=kY(e.sharedInternalDocumentStore,n),s=a/r.length;e.frequencies[t][o][i]=s,i in e.tokenOccurrences[t]||(e.tokenOccurrences[t][i]=0),e.tokenOccurrences[t][i]=(e.tokenOccurrences[t][i]??0)+1}function mX(e,t,n,r){let i=kY(e.sharedInternalDocumentStore,n);r>1?e.avgFieldLength[t]=(e.avgFieldLength[t]*r-e.fieldLengths[t][i])/(r-1):e.avgFieldLength[t]=void 0,e.fieldLengths[t][i]=void 0,e.frequencies[t][i]=void 0}function hX(e,t,n){e.tokenOccurrences[t][n]--}function gX(e,t,n,r,i=``){r||={sharedInternalDocumentStore:t,indexes:{},vectorIndexes:{},searchableProperties:[],searchablePropertiesWithTypes:{},frequencies:{},tokenOccurrences:{},avgFieldLength:{},fieldLengths:{}};for(let[a,o]of Object.entries(n)){let n=`${i}${i?`.`:``}${a}`;if(typeof o==`object`&&!Array.isArray(o)){gX(e,t,o,r,n);continue}if(SY(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new lX(TY(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new sX,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new ZY(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new nX,isArray:e},r.avgFieldLength[n]=0,r.frequencies[n]={},r.tokenOccurrences[n]={},r.fieldLengths[n]={};break;case`enum`:case`enum[]`:r.indexes[n]={type:`Flat`,node:new QY,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new oX,isArray:e};break;default:throw hY(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function _X(e,t,n,r,i,a,o,s){return c=>{let{type:l,node:u}=t.indexes[n];switch(l){case`Bool`:u[c?`true`:`false`].add(r);break;case`AVL`:{let e=s?.avlRebalanceThreshold??1;u.insert(c,r,e);break}case`Radix`:{let s=a.tokenize(c,i,n,!1);e.insertDocumentScoreParameters(t,n,r,s,o);for(let i of s)e.insertTokenScoreParameters(t,n,r,s,i),u.insert(i,r);break}case`Flat`:u.insert(c,r);break;case`BKD`:u.insert(c,[r]);break}}}function vX(e,t,n,r,i,a,o,s,c,l,u){if(SY(o))return yX(t,n,a,r,i);let d=_X(e,t,n,i,s,c,l,u);if(!CY(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function yX(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function bX(e,t,n,r,i,a,o,s,c,l){if(SY(o))return t.vectorIndexes[n].node.remove(i),!0;let{type:u,node:d}=t.indexes[n];switch(u){case`AVL`:return d.removeDocument(a,i),!0;case`Bool`:return d[a?`true`:`false`].delete(i),!0;case`Radix`:{let o=c.tokenize(a,s,n);e.removeDocumentScoreParameters(t,n,r,l);for(let r of o)e.removeTokenScoreParameters(t,n,r),d.removeDocumentByWord(r,i);return!0}case`Flat`:return d.removeDocument(i,a),!0;case`BKD`:return d.removeDocByID(a,i),!1}}function xX(e,t,n,r,i,a,o,s,c,l){if(!CY(o))return bX(e,t,n,r,i,a,o,s,c,l);let u=wY(o),d=a,f=d.length;for(let a=0;a<f;a++)bX(e,t,n,r,i,d[a],u,s,c,l);return!0}function SX(e,t,n,r,i,a,o,s,c,l){let u=Array.from(r),d=e.avgFieldLength[t],f=e.fieldLengths[t],p=e.tokenOccurrences[t],m=e.frequencies[t],h=typeof p[n]==`number`?p[n]??0:0,g=u.length;for(let e=0;e<g;e++){let r=u[e];if(c&&!c.has(r))continue;l.has(r)||l.set(r,new Map);let p=l.get(r);p.set(t,(p.get(t)||0)+1);let g=cX(m?.[r]?.[n]??0,h,i,f[r],d,a);o.has(r)?o.set(r,o.get(r)+g*s):o.set(r,g*s)}}function CX(e,t,n,r,i,a,o,s,c,l,u,d=0){let f=n.tokenize(t,r),p=f.length||1,m=new Map,h=new Map,g=new Map;for(let n of i){if(!(n in e.indexes))continue;let r=e.indexes[n],{type:i}=r;if(i!==`Radix`)throw hY(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw hY(`INVALID_BOOST_VALUE`,d);f.length===0&&!t&&f.push(``);let p=f.length;for(let t=0;t<p;t++){let i=f[t],s=r.node.find({term:i,exact:a,tolerance:o}),p=Object.keys(s);p.length>0&&h.set(i,!0);let _=p.length;for(let t=0;t<_;t++){let r=p[t],i=s[r];SX(e,n,r,i,l,c,g,d,u,m)}}}let _=Array.from(g.entries()).map(([e,t])=>[e,t]).sort((e,t)=>t[1]-e[1]);if(_.length===0)return[];if(d===1)return _;if(d===0){if(p===1)return _;for(let e of f)if(!h.get(e))return[];return _.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1})}let v=_.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1});if(v.length>0){let e=_.filter(([e])=>!v.some(([t])=>t===e)),t=Math.ceil(e.length*d);return[...v,...e.slice(0,t)]}return _}function wX(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:lY(...i.map(n=>wX(e,t,n,r)))}if(`or`in n&&n.or&&Array.isArray(n.or)){let i=n.or;return i.length===0?new Set:i.map(n=>wX(e,t,n,r)).reduce((e,t)=>dY(e,t),new Set)}if(`not`in n&&n.not){let i=n.not,a=new Set,o=e.sharedInternalDocumentStore;for(let e=1;e<=o.internalIdToId.length;e++)a.add(e);return fY(a,wX(e,t,i,r))}let i=Object.keys(n),a=i.reduce((e,t)=>({[t]:new Set,...e}),{});for(let o of i){let i=n[o];if(e.indexes[o]===void 0)throw hY(`UNKNOWN_FILTER_PROPERTY`,o);let{node:s,type:c,isArray:l}=e.indexes[o];if(c===`Bool`){let e=s,t=i?e.true:e.false;a[o]=dY(a[o],t);continue}if(c===`BKD`){let e;if(`radius`in i)e=`radius`;else if(`polygon`in i)e=`polygon`;else throw Error(`Invalid operation ${i}`);if(e===`radius`){let{value:t,coordinates:n,unit:r=`m`,inside:c=!0,highPrecision:l=!1}=i[e],u=aY(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=AX(a[o],d)}else{let{coordinates:t,inside:n=!0,highPrecision:r=!1}=i[e],c=s.searchByPolygon(t,n,void 0,r);a[o]=AX(a[o],c)}continue}if(c===`Radix`&&(typeof i==`string`||Array.isArray(i))){for(let e of[i].flat()){let n=t.tokenize(e,r,o);for(let e of n){let t=s.find({term:e,exact:!0});a[o]=PX(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw hY(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=dY(a[o],e);continue}if(c===`AVL`){let e=u[0],t=i[e],n;switch(e){case`gt`:n=s.greaterThan(t,!1);break;case`gte`:n=s.greaterThan(t,!0);break;case`lt`:n=s.lessThan(t,!1);break;case`lte`:n=s.lessThan(t,!0);break;case`eq`:n=s.find(t)??new Set;break;case`between`:{let[e,r]=t;n=s.rangeSearch(e,r);break}default:throw hY(`INVALID_FILTER_OPERATION`,e)}a[o]=dY(a[o],n)}}return lY(...Object.values(a))}function TX(e){return e.searchableProperties}function EX(e){return e.searchablePropertiesWithTypes}function DX(e,t){let{indexes:n,vectorIndexes:r,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}=t,u={},d={};for(let e of Object.keys(n)){let{node:t,type:r,isArray:i}=n[e];switch(r){case`Radix`:u[e]={type:`Radix`,node:nX.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:QY.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:ZY.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:oX.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:sX.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:lX.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function OX(e){let{indexes:t,vectorIndexes:n,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}=e,l={};for(let e of Object.keys(n))l[e]=n[e].node.toJSON();let u={};for(let e of Object.keys(t)){let{type:n,node:r,isArray:i}=t[e];n===`Flat`||n===`Radix`||n===`AVL`||n===`BKD`||n===`Bool`?u[e]={type:n,node:r.toJSON(),isArray:i}:(u[e]=t[e],u[e].node=u[e].node.toJSON())}return{indexes:u,vectorIndexes:l,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}}function kX(){return{create:gX,insert:vX,remove:xX,insertDocumentScoreParameters:fX,insertTokenScoreParameters:pX,removeDocumentScoreParameters:mX,removeTokenScoreParameters:hX,calculateResultScores:SX,search:CX,searchByWhereClause:wX,getSearchableProperties:TX,getSearchablePropertiesWithTypes:EX,load:DX,save:OX}}function AX(e,t){e||=new Set;let n=t.length;for(let r=0;r<n;r++){let n=t[r].docIDs,i=n.length;for(let t=0;t<i;t++)e.add(n[t])}return e}function jX(e,t,n=!1){let r=n?oX.vincentyDistance:oX.haversineDistance,i=[],a=[];for(let{point:n}of e)a.push(r(t,n));let o=Math.max(...a),s=0;for(let{docIDs:t}of e){let e=o-a[s]+1;for(let n of t)i.push([n,e]);s++}return i.sort((e,t)=>t[1]-e[1]),i}function MX(e,t){let n=Object.keys(e);if(n.length!==1)return{isGeoOnly:!1};let r=n[0],i=e[r];if(t.indexes[r]===void 0)return{isGeoOnly:!1};let{type:a}=t.indexes[r];return a===`BKD`&&i&&(`radius`in i||`polygon`in i)?{isGeoOnly:!0,geoProperty:r,geoOperation:i}:{isGeoOnly:!1}}function NX(e,t){let n=e,r=MX(t,n);if(!r.isGeoOnly||!r.geoProperty||!r.geoOperation)return null;let{node:i}=n.indexes[r.geoProperty],a=r.geoOperation,o=i,s;if(`radius`in a){let{value:e,coordinates:t,unit:n=`m`,inside:r=!0,highPrecision:i=!1}=a.radius,c=t,l=aY(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),jX(s,c,i)}else if(`polygon`in a){let{coordinates:e,inside:t=!0,highPrecision:n=!1}=a.polygon;s=o.searchByPolygon(e,t,`asc`,n);let r=oX.calculatePolygonCentroid(e);return jX(s,r,n)}return null}function PX(e,t){e||=new Set;let n=Object.keys(t),r=n.length;for(let i=0;i<r;i++){let r=t[n[i]],a=r.length;for(let t=0;t<a;t++)e.add(r[t])}return e}function FX(e,t,n,r,i){let a={language:e.tokenizer.language,sharedInternalDocumentStore:t,enabled:!0,isSorted:!0,sortableProperties:[],sortablePropertiesWithTypes:{},sorts:{}};for(let[o,s]of Object.entries(n)){let n=`${i}${i?`.`:``}${o}`;if(!r.includes(n)){if(typeof s==`object`&&!Array.isArray(s)){let i=FX(e,t,s,r,n);GJ(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!SY(s))switch(s){case`boolean`:case`number`:case`string`:a.sortableProperties.push(n),a.sortablePropertiesWithTypes[n]=s,a.sorts[n]={docs:new Map,orderedDocsToRemove:new Map,orderedDocs:[],type:s};break;case`geopoint`:case`enum`:continue;case`enum[]`:case`boolean[]`:case`number[]`:case`string[]`:continue;default:throw hY(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function IX(e,t,n,r){return r?.enabled===!1?{disabled:!0}:FX(e,t,n,(r||{}).unsortableProperties||[],``)}function LX(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=kY(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&WX(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function RX(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)HX(e,n);e.isSorted=!0}function zX(e,t,n){return t[1].localeCompare(n[1],RJ(e))}function BX(e,t){return e[1]-t[1]}function VX(e,t){return t[1]?-1:1}function HX(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=zX.bind(null,e.language);break;case`number`:r=BX.bind(null);break;case`boolean`:r=VX.bind(null);break}n.orderedDocs.sort(r);let i=n.orderedDocs.length;for(let e=0;e<i;e++){let t=n.orderedDocs[e][0];n.docs.set(t,e)}}function UX(e){let t=Object.keys(e.sorts);for(let n of t)WX(e,n)}function WX(e,t){let n=e.sorts[t];n.orderedDocsToRemove.size&&(n.orderedDocs=n.orderedDocs.filter(e=>!n.orderedDocsToRemove.has(e[0])),n.orderedDocsToRemove.clear())}function GX(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=kY(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function KX(e,t,n){if(!e.enabled)throw hY(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw hY(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return WX(e,r),RX(e),t.sort((t,n)=>{let r=a.docs.get(kY(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(kY(e.sharedInternalDocumentStore,n[0])),s=r!==void 0,c=o!==void 0;return!s&&!c?0:s?c?i?o-r:r-o:-1:1}),t}function qX(e){return e.enabled?e.sortableProperties:[]}function JX(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function YX(e,t){let n=t;if(!n.enabled)return{enabled:!1};let r=Object.keys(n.sorts).reduce((e,t)=>{let{docs:r,orderedDocs:i,type:a}=n.sorts[t];return e[t]={docs:new Map(Object.entries(r).map(([e,t])=>[+e,t])),orderedDocsToRemove:new Map,orderedDocs:i,type:a},e},{});return{sharedInternalDocumentStore:e,language:n.language,sortableProperties:n.sortableProperties,sortablePropertiesWithTypes:n.sortablePropertiesWithTypes,sorts:r,enabled:!0,isSorted:n.isSorted}}function XX(e){if(!e.enabled)return{enabled:!1};UX(e),RX(e);let t=Object.keys(e.sorts).reduce((t,n)=>{let{docs:r,orderedDocs:i,type:a}=e.sorts[n];return t[n]={docs:Object.fromEntries(r.entries()),orderedDocs:i,type:a},t},{});return{language:e.language,sortableProperties:e.sortableProperties,sortablePropertiesWithTypes:e.sortablePropertiesWithTypes,sorts:t,enabled:e.enabled,isSorted:e.isSorted}}function ZX(){return{create:IX,insert:LX,remove:GX,save:XX,load:YX,sortBy:KX,getSortableProperties:qX,getSortablePropertiesWithTypes:JX}}var QX=192,$X=383,eZ=[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 tZ(e){return e<QX||e>$X?e:eZ[e-QX]||e}function nZ(e){let t=[];for(let n=0;n<e.length;n++)t[n]=tZ(e.charCodeAt(n));return String.fromCharCode(...t)}var rZ={ational:`ate`,tional:`tion`,enci:`ence`,anci:`ance`,izer:`ize`,bli:`ble`,alli:`al`,entli:`ent`,eli:`e`,ousli:`ous`,ization:`ize`,ation:`ate`,ator:`ate`,alism:`al`,iveness:`ive`,fulness:`ful`,ousness:`ous`,aliti:`al`,iviti:`ive`,biliti:`ble`,logi:`log`},iZ={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},aZ=`[^aeiou]`,oZ=`[aeiouy]`,sZ=aZ+`[^aeiouy]*`;oZ+``;var cZ=`^(`+sZ+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,lZ=`^(`+sZ+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`,uZ=`^(`+sZ+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,dZ=`^(`+sZ+`)?[aeiouy]`;function fZ(e){let t,n,r,i,a,o;if(e.length<3)return e;let s=e.substring(0,1);if(s==`y`&&(e=s.toUpperCase()+e.substring(1)),r=/^(.+?)(ss|i)es$/,i=/^(.+?)([^s])s$/,r.test(e)?e=e.replace(r,`$1$2`):i.test(e)&&(e=e.replace(i,`$1$2`)),r=/^(.+?)eed$/,i=/^(.+?)(ed|ing)$/,r.test(e)){let t=r.exec(e);r=new RegExp(cZ),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(dZ),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+sZ+oZ+`[^aeiouwxy]$`),i.test(e)?e+=`e`:a.test(e)?(r=/.$/,e=e.replace(r,``)):o.test(e)&&(e+=`e`)));if(r=/^(.+?)y$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(dZ),t&&r.test(t)&&(e=t+`i`)),r=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(cZ),t&&r.test(t)&&(e=t+rZ[n])}if(r=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(cZ),t&&r.test(t)&&(e=t+iZ[n])}if(r=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,i=/^(.+?)(s|t)(ion)$/,r.test(e))t=r.exec(e)?.[1],r=new RegExp(uZ),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(uZ),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(uZ),i=new RegExp(lZ),a=RegExp(`^`+sZ+oZ+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(uZ),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function pZ(e,t,n=!0){let 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=nZ(t),n&&this.normalizationCache.set(r,t),t)}function mZ(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function hZ(e,t,n,r=!0){if(t&&t!==this.language)throw hY(`LANGUAGE_NOT_SUPPORTED`,t);if(typeof e!=`string`)return[e];let i=this.normalizeToken.bind(this,n??``),a;if(n&&this.tokenizeSkipProperties.has(n))a=[i(e,r)];else{let t=IJ[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=mZ(a);return this.allowDuplicates?o:Array.from(new Set(o))}function gZ(e={}){if(!e.language)e.language=`english`;else if(!LJ.includes(e.language))throw hY(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw hY(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=fZ;else throw hY(`MISSING_STEMMER`,e.language);let n;if(e.stopWords!==!1){if(n=[],Array.isArray(e.stopWords))n=e.stopWords;else if(typeof e.stopWords==`function`)n=e.stopWords(n);else if(e.stopWords)throw hY(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw hY(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw hY(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:hZ,language:e.language,stemmer:t,stemmerSkipProperties:new Set(e.stemmerSkipProperties?[e.stemmerSkipProperties].flat():[]),tokenizeSkipProperties:new Set(e.tokenizeSkipProperties?[e.tokenizeSkipProperties].flat():[]),stopWords:n,allowDuplicates:!!e.allowDuplicates,normalizeToken:pZ,normalizationCache:new Map};return r.tokenize=hZ.bind(r),r.normalizeToken=pZ,r}function _Z(e){return{sharedInternalDocumentStore:e,rules:new Map}}function vZ(e,t){if(e.rules.has(t.id))throw Error(`PINNING_RULE_ALREADY_EXISTS: A pinning rule with id "${t.id}" already exists. Use updateRule to modify it.`);e.rules.set(t.id,t)}function yZ(e,t){if(!e.rules.has(t.id))throw Error(`PINNING_RULE_NOT_FOUND: Cannot update pinning rule with id "${t.id}" because it does not exist. Use addRule to create it.`);e.rules.set(t.id,t)}function bZ(e,t){return e.rules.delete(t)}function xZ(e,t){return e.rules.get(t)}function SZ(e){return Array.from(e.rules.values())}function CZ(e,t){let n=e.toLowerCase().trim(),r=t.pattern.toLowerCase().trim();switch(t.anchoring){case`is`:return n===r;case`starts_with`:return n.startsWith(r);case`contains`:return n.includes(r);default:return!1}}function wZ(e,t){return e?t.conditions.every(t=>CZ(e,t)):!1}function TZ(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())wZ(t,r)&&n.push(r);return n}function EZ(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function DZ(e){return{rules:Array.from(e.rules.entries())}}function OZ(){return{create:_Z,addRule:vZ,updateRule:yZ,removeRule:bZ,getRule:xZ,getAllRules:SZ,getMatchingRules:TZ,load:EZ,save:DZ}}function kZ(e){let t={formatElapsedTime:gY,getDocumentIndexId:_Y,getDocumentProperties:nY,validateSchema:vY};for(let n of WY){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw hY(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!UY.includes(t)&&!WY.includes(t))throw hY(`UNSUPPORTED_COMPONENT`,t)}function AZ({schema:e,sort:t,language:n,components:r,id:i,plugins:a}){r||={};for(let t of a??[]){if(!(`getComponents`in t)||typeof t.getComponents!=`function`)continue;let n=t.getComponents(e),i=Object.keys(n);for(let e of i)if(r[e])throw hY(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=QJ();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:gZ(o):gZ({language:n??`english`}),r.tokenizer&&n)throw hY(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=EY();s||=kX(),l||=ZX(),c||=BY(),u||=OZ(),kZ(r);let{getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,formatElapsedTime:h}=r,g={data:{},caches:{},schema:e,tokenizer:o,index:s,sorter:l,documentsStore:c,pinning:u,internalDocumentIDStore:d,getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,beforeInsert:[],afterInsert:[],beforeRemove:[],afterRemove:[],beforeUpdate:[],afterUpdate:[],beforeUpsert:[],afterUpsert:[],beforeSearch:[],afterSearch:[],beforeInsertMultiple:[],afterInsertMultiple:[],beforeRemoveMultiple:[],afterRemoveMultiple:[],beforeUpdateMultiple:[],afterUpdateMultiple:[],beforeUpsertMultiple:[],afterUpsertMultiple:[],afterCreate:[],formatElapsedTime:h,id:i,plugins:a,version:jZ()};g.data={index:g.index.create(g,d,e),docs:g.documentsStore.create(g,d),sorting:g.sorter.create(g,d,e,t),pinning:g.pinning.create(d)};for(let e of VY)g[e]=(g[e]??[]).concat(HY(g,e));let _=g.afterCreate;return _&&YY(_,g),g}function jZ(){return`{{VERSION}}`}function MZ(e){return e.documentsStore.count(e.data.docs)}function NZ(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw hY(`SCHEMA_VALIDATION_FAILURE`,a);return sY(e.beforeInsert)||sY(e.afterInsert)||sY(e.index.beforeInsert)||sY(e.index.insert)||sY(e.index.afterInsert)?mne(e,t,n,r,i):IZ(e,t,n,r,i)}var PZ=new Set([`enum`,`enum[]`]),FZ=new Set([`string`,`number`]);async function mne(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw hY(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=kY(e.internalDocumentIDStore,s);if(r||await GY(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw hY(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];LZ(n,r,e,t)}return await RZ(e,s,u,f,l,n,t,i),r||await GY(e.afterInsert,e,s,t),s}function IZ(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw hY(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=kY(e.internalDocumentIDStore,s);if(r||GY(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw hY(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];LZ(n,r,e,t)}return zZ(e,s,u,f,l,n,t,i),r||GY(e.afterInsert,e,s,t),s}function LZ(e,t,n,r){if(!(xY(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(SY(t)&&Array.isArray(r))&&!(CY(t)&&Array.isArray(r))&&!(PZ.has(t)&&FZ.has(e))&&e!==t)throw hY(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function RZ(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o];await e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i);let l=e.internalDocumentIDStore.idToInternalId.get(t);await e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),await e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function zZ(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o],l=kY(e.internalDocumentIDStore,t);e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i),e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function BZ(e,t,n,r,i,a){return sY(e.afterInsertMultiple)||sY(e.beforeInsertMultiple)||sY(e.index.beforeInsert)||sY(e.index.insert)||sY(e.index.afterInsert)?VZ(e,t,n,r,i,a):HZ(e,t,n,r,i,a)}async function VZ(e,t,n=1e3,r,i,a=0){let o=[],s=async a=>{let s=Math.min(a+n,t.length),c=t.slice(a,s);for(let t of c){let n=await NZ(e,t,r,i,{avlRebalanceThreshold:c.length});o.push(n)}return s};return await(async()=>{let e=0;for(;e<t.length;){let t=Date.now();if(e=await s(e),a>0){let e=a-(Date.now()-t);e>0&&pY(e)}}})(),i||await KY(e.afterInsertMultiple,e,t),o}function HZ(e,t,n=1e3,r,i,a=0){let o=[],s=0;function c(){let a=t.slice(s*n,(s+1)*n);if(a.length===0)return!1;for(let t of a){let n=NZ(e,t,r,i,{avlRebalanceThreshold:a.length});o.push(n)}return s++,!0}function l(){let e=Date.now();for(;c();)if(a>0){let t=Date.now()-e;if(t>=a){let e=a-t%a;e>0&&pY(e)}}}return l(),i||KY(e.afterInsertMultiple,e,t),o}function UZ(e,t){return e[1]-t[1]}function WZ(e,t){return t[1]-e[1]}function GZ(e=`desc`){return e.toLowerCase()===`asc`?UZ:WZ}function KZ(e,t,n){let r={},i=t.map(([e])=>e),a=e.documentsStore.getMultiple(e.data.docs,i),o=Object.keys(n),s=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e of o){let t;if(s[e]===`number`){let{ranges:r}=n[e],i=r.length,a=Array.from({length:i});for(let e=0;e<i;e++){let t=r[e];a[e]=[`${t.from}-${t.to}`,0]}t=Object.fromEntries(a)}r[e]={count:0,values:t??{}}}let c=a.length;for(let e=0;e<c;e++){let t=a[e];for(let e of o){let i=e.includes(`.`)?rY(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;qZ(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=qZ(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:JZ(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=JZ(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw hY(`FACET_NOT_SUPPORTED`,a)}}}for(let e of o){let t=r[e];if(t.count=Object.keys(t.values).length,s[e]===`string`){let r=n[e],i=GZ(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function qZ(e,t,n){return r=>{for(let i of e){let e=`${i.from}-${i.to}`;n?.has(e)||r>=i.from&&r<=i.to&&(t[e]===void 0?t[e]=1:(t[e]++,n?.add(e)))}}}function JZ(e,t,n){let r=t===`boolean`?`false`:``;return t=>{let i=t?.toString()??r;n?.has(i)||(e[i]=(e[i]??0)+1,n?.add(i))}}var YZ={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},XZ=[`string`,`number`,`boolean`];function ZZ(e,t,n){let r=n.properties,i=r.length,a=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e=0;e<i;e++){let t=r[e];if(a[t]===void 0)throw hY(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!XZ.includes(a[t]))throw hY(`INVALID_GROUP_BY_PROPERTY`,t,XZ.join(`, `),a[t])}let o=t.map(([t])=>AY(e.internalDocumentIDStore,t)),s=e.documentsStore.getMultiple(e.data.docs,o),c=s.length,l=n.maxResult||2**53-1,u=[],d={};for(let e=0;e<i;e++){let t=r[e],n={property:t,perValue:{}},i=new Set;for(let e=0;e<c;e++){let r=s[e],a=rY(r,t);if(a===void 0)continue;let o=typeof a==`boolean`?``+a:a,c=n.perValue[o]??{indexes:[],count:0};c.count>=l||(c.indexes.push(e),c.count++,n.perValue[o]=c,i.add(a))}u.push(Array.from(i)),d[t]=n}let f=QZ(u),p=f.length,m=[];for(let e=0;e<p;e++){let t=f[e],n=t.length,i={values:[],indexes:[]},a=[];for(let e=0;e<n;e++){let n=t[e],o=r[e];a.push(d[o].perValue[typeof n==`boolean`?``+n:n].indexes),i.values.push(n)}i.indexes=tY(a).sort((e,t)=>e-t),i.indexes.length!==0&&m.push(i)}let h=m.length,g=Array.from({length:h});for(let e=0;e<h;e++){let r=m[e],i=n.reduce||YZ,a=r.indexes.map(e=>({id:o[e],score:t[e][1],document:s[e]})),c=i.reducer.bind(null,r.values),l=i.getInitialValue(r.indexes.length),u=a.reduce(c,l);g[e]={values:r.values,result:u}}return g}function QZ(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=QZ(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];GJ(n,t),i.push(n)}return i}function $Z(e,t,n,r){let i=TZ(t,r);if(i.length===0)return n;let a=i.flatMap(e=>e.consequence.promote);a.sort((e,t)=>e.position-t.position);let o=new Set,s=new Map,c=new Set;for(let t of a){let n=kY(e.internalDocumentIDStore,t.doc_id);if(n!==void 0){if(s.has(n)){let e=s.get(n);t.position<e&&s.set(n,t.position);continue}c.has(t.position)||(o.add(n),s.set(n,t.position),c.add(t.position))}}if(s.size===0)return n;let l=n.filter(([e])=>!o.has(e)),u=[];for(let[t,r]of s.entries())n.find(([e])=>e===t)?u.push([t,1e6-r]):e.documentsStore.get(e.data.docs,t)&&u.push([t,0]);u.sort((e,t)=>(s.get(e[0])??1/0)-(s.get(t[0])??1/0));let d=[],f=new Map;for(let e of u){let t=s.get(e[0]);f.set(t,e)}let p=0,m=0;for(;m<l.length+u.length;)if(f.has(m))d.push(f.get(m)),m++;else if(p<l.length)d.push(l[p]),p++,m++;else break;for(let[e,t]of f.entries())e>=d.length&&d.push(t);return d}function eQ(e,t,n){let{term:r,properties:i}=t,a=e.data.index,o=e.caches.propertiesToSearch;if(!o){let t=e.index.getSearchablePropertiesWithTypes(a);o=e.index.getSearchableProperties(a),o=o.filter(e=>t[e].startsWith(`string`)),e.caches.propertiesToSearch=o}if(i&&i!==`*`){for(let e of i)if(!o.includes(e))throw hY(`UNKNOWN_INDEX`,e,o.join(`, `));o=o.filter(e=>i.includes(e))}let s=Object.keys(t.where??{}).length>0,c;s&&(c=e.index.searchByWhereClause(a,e.tokenizer,t.where,n));let l,u=t.threshold!==void 0&&t.threshold!==null?t.threshold:1;if(r||i){let i=MZ(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},aQ(t.relevance),i,c,u),t.exact&&r){let t=r.trim().split(/\s+/);l=l.filter(([n])=>{let r=e.documentsStore.get(e.data.docs,n);if(!r)return!1;for(let e of o){let n=nQ(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${tQ(e)}\\b`).test(n)))return!0}return!1})}}else l=s?NX(a,t.where)||(c?Array.from(c):[]).map(e=>[+e,0]):Object.keys(e.documentsStore.getAll(e.data.docs)).map(e=>[+e,0]);return l}function tQ(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function nQ(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r&&typeof r==`object`&&e in r)r=r[e];else return;return r}function rQ(e,t,n){let r=ZJ();function i(){let i=Object.keys(e.data.index.vectorIndexes),a=t.facets&&Object.keys(t.facets).length>0,{limit:o=10,offset:s=0,distinctOn:c,includeVectors:l=!1}=t,u=t.preflight===!0,d=eQ(e,t,n);if(t.sortBy)if(typeof t.sortBy==`function`){let n=d.map(([e])=>e),r=e.documentsStore.getMultiple(e.data.docs,n).map((e,t)=>[d[t][0],d[t][1],e]);r.sort(t.sortBy),d=r.map(([e,t])=>[e,t])}else d=e.sorter.sortBy(e.data.sorting,d,t.sortBy).map(([t,n])=>[kY(e.internalDocumentIDStore,t),n]);else d=d.sort(eY);d=$Z(e,e.data.pinning,d,t.term);let f;u||(f=c?_Q(e,d,s,o,c):vQ(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||oY(p,i)),a&&(p.facets=KZ(e,d,t.facets)),t.groupBy&&(p.groups=ZZ(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(ZJ()-r),p}async function a(){e.beforeSearch&&await JY(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await qY(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}var iQ={k:1.2,b:.75,d:.5};function aQ(e){let t=e??{};return t.k=t.k??iQ.k,t.b=t.b??iQ.b,t.d=t.d??iQ.d,t}function oQ(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw hY(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw hY(`UNKNOWN_VECTOR_PROPERTY`,r.property);let a=i.node.size;if(r?.value.length!==a)throw r?.property===void 0||r?.value.length===void 0?hY(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):hY(`INVALID_INPUT_VECTOR`,r.property,a,r.value.length);let o=e.data.index,s;return Object.keys(t.where??{}).length>0&&(s=e.index.searchByWhereClause(o,e.tokenizer,t.where,n)),i.node.find(r.value,t.similarity??.8,s)}function sQ(e,t,n=`english`){let r=ZJ();function i(){let i=oQ(e,t,n).sort(eY);i=$Z(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=KZ(e,i,t.facets));let o=t.vector.property,s=t.includeVectors??!1,c=t.limit??10,l=t.offset??0,u=Array.from({length:c});for(let t=0;t<c;t++){let n=i[t+l];if(!n)break;let r=e.data.docs.docs[n[0]];r&&(s||(r[o]=null),u[t]={id:AY(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=ZZ(e,i,t.groupBy));let f=ZJ()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:XJ(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await JY(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await qY(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function cQ(e,t,n){let r=dQ(eQ(e,t,n)),i=oQ(e,t,n),a=t.hybridWeights;return mQ(r,i,t.term??``,a)}function lQ(e,t,n){let r=ZJ();function i(){let i=cQ(e,t,n);i=$Z(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=KZ(e,i,t.facets));let o;t.groupBy&&(o=ZZ(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=vQ(e,i,s,c).filter(Boolean),u=ZJ(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:XJ(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||oY(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await JY(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await qY(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function uQ(e){return e[1]}function dQ(e){let t=Math.max.apply(Math,e.map(uQ));return e.map(([e,n])=>[e,n/t])}function fQ(e,t){return e/t}function pQ(e,t){return(n,r)=>n*e+r*t}function mQ(e,t,n,r){let i=Math.max.apply(Math,e.map(uQ)),a=Math.max.apply(Math,t.map(uQ)),{text:o,vector:s}=r&&r.text&&r.vector?r:hQ(n),c=new Map,l=e.length,u=pQ(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u(fQ(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=fQ(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function hQ(e){return{text:.5,vector:.5}}function gQ(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return rQ(e,t,n);if(r===`vector`)return sQ(e,t);if(r===`hybrid`)return lQ(e,t);throw hY(`INVALID_SEARCH_MODE`,r)}function _Q(e,t,n,r,i){let a=e.data.docs,o=new Map,s=[],c=new Set,l=t.length,u=0;for(let d=0;d<l;d++){let l=t[d];if(l===void 0)continue;let[f,p]=l;if(c.has(f))continue;let m=e.documentsStore.get(a,f),h=rY(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:AY(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function vQ(e,t,n,r){let i=e.data.docs,a=Array.from({length:r}),o=new Set;for(let s=n;s<r+n;s++){let n=t[s];if(n===void 0)break;let[r,c]=n;if(!o.has(r)){let t=e.documentsStore.get(i,r);a[s]={id:AY(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}var yQ=e(PJ(),1),bQ=`0.0.0-unknown`,xQ={protocol:`x-ok-client-protocol`,runtime:`x-ok-client-runtime`,kind:`x-ok-client-kind`};function SQ({kind:e,runtimeVersion:t}){return{[xQ.protocol]:`1`,[xQ.runtime]:t,[xQ.kind]:e}}function CQ({kind:e,runtimeVersion:t}){return{clientProtocolVersion:1,clientRuntimeVersion:t,clientKind:e}}var wQ=8192,TQ=32768,EQ=`…[truncated]`;function DQ(e){let t=e.trim();if(t.length===0||t[0]!==`{`)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!=`object`||!n||Array.isArray(n))return null;let r=n;return{event:typeof r.event==`string`?r.event:void 0,fields:r}}function OQ(e){return e.length<=8192?e:`${e.slice(0,wQ-12)}${EQ}`}var kQ=`source`;function AQ(e){return{ok:!1,error:e}}function jQ(e){return{ok:!0,...e}}function MQ(){return yu.parse({})}function NQ(e,t){let n=e.toString();if(n.length===0)return MQ();let r=_r(n);if(r.errors.length>0)return console.warn(`[bindConfigDoc:${t}] Y.Text contains invalid YAML; returning schema defaults. Errors: ${r.errors.map(e=>e.message).join(`; `)}`),MQ();let i=r.toJSON()??{},a=yu.safeParse(i);return a.success?a.data:(console.warn(`[bindConfigDoc:${t}] Y.Text content fails schema validation; returning schema defaults. First issue: ${a.error.issues[0]?.message??`(unknown)`}`),MQ())}function PQ(e,t,n={}){return xu(`config.bind`,{"config.scope":t,"config.transport":`ytext`},()=>FQ(e,t,n))}function FQ(e,t,n){let{ytextKey:r=kQ}=n,i=e.document,a=i.getText(r),o=new Set,s=new Set,c=!1,l=!1;function u(){if(c)return;let e=NQ(a,t);for(let n of o)try{n(e)}catch(e){console.warn(`[bindConfigDoc:${t}] listener threw:`,e)}}function d(){if(c||(u(),l))return;l=!0;let e=[...s];s.clear();for(let n of e)try{n()}catch(e){console.warn(`[bindConfigDoc:${t}] synced listener threw:`,e)}}a.observe(u),e.on(`synced`,d);function f(e){if(c)return AQ({code:`WRITE_ERROR`,detail:`ConfigBinding (${t}) has been disposed`});let n=Du(e,t);if(n!==null)return AQ(n);let r=_r(a.toString()),o=r.contents!==null&&!g(r.contents);if(r.errors.length>0||o){Su(`config.corrupt-ytext-reset`,{"config.scope":t,"config.parse.errorCount":r.errors.length,"config.parse.topLevelNonMap":o});let e=r.errors.length>0?r.errors.map(e=>e.message).join(`; `):`top-level YAML is not a mapping`;console.warn(`[bindConfigDoc:${t}] dropping corrupt Y.Text and re-applying patch onto empty doc. Reason: ${e}`),r=_r(``)}r.contents===null&&(r.contents=r.createNode({}));let s=ku(r,e),l=r.toJSON()??{},u=xu(`config.validate`,{"config.scope":t,"config.validation.layer":`L1`},e=>{let t=yu.safeParse(l);if(e.setAttribute(`config.outcome`,t.success?`success`:`rejected`),!t.success)for(let e of t.error.issues)Su(`config.validation.issue`,{"issue.path":e.path.map(e=>String(e)).join(`.`),"issue.message":e.message});return t});if(!u.success)return AQ({code:`SCHEMA_INVALID`,issues:u.error.issues.map(Au)});let d=r.toString();return i.transact(()=>{a.length>0&&a.delete(0,a.length),a.insert(0,d)}),jQ({effective:u.data,appliedPaths:s})}return{current(){return NQ(a,t)},patch(e){return xu(`config.patch`,{"config.scope":t,"config.transport":`ytext`},t=>{let n=f(e);return t.setAttribute(`config.outcome`,n.ok?`success`:`rejected`),n.ok||t.setAttribute(`config.error.code`,n.error.code),n})},subscribe(e){return o.add(e),()=>{o.delete(e)}},hasSynced(){return l},subscribeSynced(e){if(c)return()=>{};if(l){let n=!1;return queueMicrotask(()=>{if(!(n||c))try{e()}catch(e){console.warn(`[bindConfigDoc:${t}] synced listener threw:`,e)}}),()=>{n=!0}}return s.add(e),()=>{s.delete(e)}},dispose(){c||(c=!0,a.unobserve(u),e.off(`synced`,d),o.clear(),s.clear())}}}var IQ=`source`,LQ=800;function RQ(e){return{ok:!1,error:e}}function zQ(e){return{ok:!0,...e}}function BQ(e,t={}){let{ytextKey:n=IQ,acceptanceDelayMs:r=LQ}=t,i=e.document,a=i.getText(n),o=new Set,s=new Set,c=new Set,l=!1,u=`idle`,d=null;function f(){d!==null&&(clearTimeout(d),d=null)}function p(e){if(!l&&u!==e){u=e;for(let t of c)try{t(e)}catch(e){console.warn(`[bindOkignoreDoc] status listener threw:`,e)}}}function m(){if(l)return;let e=a.toString();for(let t of o)try{t(e)}catch(e){console.warn(`[bindOkignoreDoc] text listener threw:`,e)}}function h(e){if(!l)for(let t of s)try{t(e)}catch(e){console.warn(`[bindOkignoreDoc] rejection listener threw:`,e)}}return a.observe(m),e.on(`synced`,m),{current(){return a.toString()},patch(e){return l?RQ({code:`WRITE_ERROR`,detail:`OkignoreBinding has been disposed`}):(i.transact(()=>{a.length>0&&a.delete(0,a.length),e.length>0&&a.insert(0,e)}),f(),p(`pending`),d=setTimeout(()=>{d=null,!l&&u===`pending`&&p(`accepted`)},r),zQ({text:e}))},subscribe(e){return o.add(e),()=>{o.delete(e)}},subscribeRejection(e){return s.add(e),()=>{s.delete(e)}},subscribeStatus(e){return c.add(e),()=>{c.delete(e)}},status(){return u},notifyRejection(e){l||(f(),p(`rejected`),h({error:e,text:a.toString()}))},dispose(){l||(l=!0,f(),a.unobserve(m),e.off(`synced`,m),o.clear(),s.clear(),c.clear())}}}function VQ(e,t,n){return HQ([e,t,n],[])}function HQ(e,t){if(t.length>0){let n=Tu(yu,t);if(n?.scope===`user`)return e[0];if(n?.scope===`project`)return e[1]??e[0];if(n?.scope===`project-local`)return e[2]??e[1]??e[0]}let n=UQ(e);if(n===void 0)return;if(n===null)return null;if(Array.isArray(n)||typeof n!=`object`)return n;let r=e.map(e=>WQ(e)?e:void 0),i=new Set;for(let e of r)if(e!==void 0)for(let t of Object.keys(e))i.add(t);let a={};for(let e of i)a[e]=HQ(r.map(t=>t===void 0?void 0:t[e]),[...t,e]);return a}function UQ(e){for(let t=e.length-1;t>=0;t--)if(e[t]!==void 0)return e[t]}function WQ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var GQ=2e3;function KQ(e){let t=Date.now();for(let[n,r]of e.entries()){let i=r;i.timestamp&&t-i.timestamp>3e4&&e.delete(n)}}function qQ(e,t){for(let[,n]of e.entries()){let e=n;if(e.timestamp&&e.timestamp>t)return!0}return!1}var JQ=`__system__`,YQ=`__config__/project`,XQ=`__user__/config.yml`,ZQ=`__local__/project`,QQ=`__config__/okignore`;Object.freeze([YQ,ZQ,XQ,QQ]);var $Q=`__skill__/`,e$=`__template__/`,t$=[`project`,`global`];function n$(e){return e.startsWith(`__skill__/`)||e.startsWith(`__template__/`)}var r$=`.ok/skills`;function i$(e){return`${r$}/${e}/SKILL`}var a$=/^__skill__\/global\/([^/]+)(?:\/(references\/.+))?$/;function o$(e){let t=a$.exec(e);if(!t)return null;let n=t[1],r=t[2];return r===void 0?{name:n,kind:`skill`,rel:null}:{name:n,kind:`reference`,rel:r.slice(11)}}function s$(e,t){return e===`project`?i$(t):`${$Q}${e}/${t}`}function c$(e){if(e===``)return``;try{return e.split(`/`).map(e=>decodeURIComponent(e)).join(`/`)}catch{return e}}function l$(e){if(e.startsWith(`__skill__/`)){let t=e.slice(10),n=t.indexOf(`/`);if(n<0)return null;let r=t.slice(0,n);if(r!==`global`&&r!==`project`)return null;let i=t.slice(n+1);return i?{kind:`skill`,scope:r,name:c$(i)}:null}if(e.startsWith(`__template__/`)){let t=e.slice(13);if(!t)return null;let n=t.lastIndexOf(`/`),r=n<0?t:t.slice(n+1);return r?{kind:`template`,folder:c$(n<0?``:t.slice(0,n)),name:c$(r)}:null}return null}var u$=/^(?:(.+)\/)?\.ok\/templates\/([^/]+?)(?:\.mdx?)?$/;function d$(e){let t=u$.exec(e);if(t){let e=(t[1]??``).replace(/^\/+|\/+$/g,``);return`${e$}${e?`${e}/`:``}${t[2]}`}return null}var f$=[`invalid-args`,`nested-project`,`target-not-empty`,`mkdir-failed`,`git-init-failed`,`init-failed`,`discovery-failed`],p$=[`.mdx`,`.md`],m$=`epoch`,h$=512*1024;function g$(e,t=h$){return typeof e==`number`&&Number.isFinite(e)&&e>t}var _$=[`claude`,`claude-desktop`,`cursor`,`codex`,`opencode`,`openclaw`,`pi`,`antigravity`],v$={claude:`Claude`,"claude-desktop":`Claude Desktop`,cursor:`Cursor`,codex:`Codex`,opencode:`OpenCode`,openclaw:`OpenClaw`,pi:`Pi`,antigravity:`Antigravity`},y$={claude:`.claude/skills`,"claude-desktop":null,cursor:`.cursor/skills`,codex:`.codex/skills`,opencode:`.opencode/skills`,openclaw:null,pi:`.pi/skills`,antigravity:null},b$=_$.filter(e=>y$[e]!==null);b$.filter(e=>e!==`pi`).map(e=>({hostDir:(y$[e]??``).split(`/`)[0],editorId:e}));var x$={claude:`claude-code`,"claude-desktop":`claude-code`,cursor:`cursor`,codex:`codex`,opencode:`opencode`,openclaw:`openclaw`,pi:`pi`,antigravity:`antigravity`},S$={cursor:/\bCursor(?:\([^)]+\))?\/\d/,codex:/\bCodex(?:\([^)]+\))?\/\d/,"claude-desktop":/\bClaude(?:\([^)]+\))?\/\d/};function C$(){if(typeof navigator>`u`)return null;let e=navigator.userAgent;for(let[t,n]of Object.entries(S$))if(n.test(e))return t;return null}var w$=[`incoming`,`outgoing`,`both`];function T$(e){return w$.includes(e)}var E$=`open-knowledge`,D$=[{id:`chart`,title:`Chart`,description:`A bar chart whose series colors track the OK chart palette.`,html:`<div style="font-family:system-ui,sans-serif;padding:20px;color:var(--foreground)">
|
|
384
384
|
<h3 style="margin:0 0 14px;font-size:15px;font-weight:600">Revenue by region</h3>
|
|
385
385
|
<div id="bars" style="display:flex;align-items:flex-end;gap:14px;height:170px"></div>
|
|
386
386
|
<script>
|
|
@@ -466,7 +466,7 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
|
|
|
466
466
|
`)}function I0(e,t,n){return`The selected passage is ${e===t?`line ${e}`:`lines ${e}-${t}`} of @${n}. Read it from @${n} via the OpenKnowledge MCP server before editing.`}function L0(e){let t=e.map(e=>t0(e)).filter(e=>e!==``);return t.length===0?``:[`Also reference:`,``,...t.map(e=>`@${e}`)].join(`
|
|
467
467
|
`)}function R0(e){return e.scope===`doc`?`Let's work on @${t0(e.docRelativePath)} using OpenKnowledge.`:e.scope===`folder`?`Let's work on the @${t0(e.folderRelativePath)} folder using OpenKnowledge.`:`Let's work on this project using OpenKnowledge.`}function z0(e,t,n,r,i){let a=t.trim();if(!(a!==``||n!==``||r!==``))return i===``?e:`${e} ${i}`;let o=[e];return a!==``&&o.push(N0(a)),n!==``&&o.push(n),r!==``&&o.push(r),i!==``&&o.push(i),o.join(`
|
|
468
468
|
|
|
469
|
-
`)}function B0(e,t,n,r,i,a){if(e.kind===`lines`)return I0(e.startLine,e.endLine,n);if(e.kind===`anchor`)return F0(e.markdown,n);let o=P0(e.markdown);return y0(z0(t,``,o,r,i),a)<=d0?o:F0(e.markdown,n)}function V0(e,t,n,r){let{target:i}=e,a=t0(e.docRelativePath),o=`Let's work on @${a} using OpenKnowledge.`,s=B0(t,o,a,n,r,i);return z0(o,O0(e.instruction,i,e=>z0(o,e,s,n,r)),s,n,r)}function H0(e){let{target:t}=e,n=e.autoOpen?M0:``,r=L0(e.mentions);if(e.scope===`doc`&&e.selection!==void 0)return V0(e,e.selection,r,n);let i=R0(e);return z0(i,O0(e.instruction,t,e=>z0(i,e,``,r,n)),``,r,n)}function U0(e){return`'${e.replace(/'/g,`'\\''`)}'`}var W0=[`mcp__${E$}`,`Bash(ok open:*)`],G0=[`delete`,`move`,`share_link`,`install`].map(e=>`mcp__${E$}__${e}`),K0=`-c ${U0(`mcp_servers.${E$}.default_tools_approval_mode="approve"`)}`;function q0(e){let t={};return e.mcpPreApprove===!0&&(t.enabledMcpjsonServers=[E$]),e.autoApproveOkTools===!0&&(t.permissions={allow:[...W0],deny:[...G0]}),t.enabledMcpjsonServers===void 0&&t.permissions===void 0?``:`--settings ${U0(JSON.stringify(t))}`}var J0={claude:{bin:`claude`,displayName:`Claude`,docsUrl:`https://docs.claude.com/en/docs/claude-code`,handoffTarget:`claude-code`},codex:{bin:`codex`,displayName:`Codex`,docsUrl:`https://developers.openai.com/codex/cli`,handoffTarget:`codex`,autoApproveArg:K0},cursor:{bin:`cursor-agent`,displayName:`Cursor`,docsUrl:`https://cursor.com/docs/cli/overview`,handoffTarget:`cursor`},opencode:{bin:`opencode`,displayName:`OpenCode`,docsUrl:`https://opencode.ai/docs`,handoffTarget:`opencode`,promptFlag:`--prompt`},pi:{bin:`pi`,displayName:`Pi`,docsUrl:`https://pi.dev`,handoffTarget:`pi`}},Y0=[`claude`,`codex`,`opencode`,`cursor`,`pi`];function X0(e,t,n={}){let r=J0[e],i=e===`claude`?q0(n):n.autoApproveOkTools===!0&&r.autoApproveArg?r.autoApproveArg:``,a=i?`${i} `:``;if(t==null||t.length===0)return`${r.bin} ${a}`.trimEnd();let o=r.promptFlag?`${r.promptFlag} `:``;return`${r.bin} ${a}${o}${U0(t)}`}function Z0(e){if(e.length===0)return{ok:!1,reason:`docName must not be empty`};if(e.trim().length===0)return{ok:!1,reason:`docName must not be blank (whitespace only)`};if(e!==e.trim())return{ok:!1,reason:`docName must not have leading or trailing whitespace`};for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return{ok:!1,reason:`docName must not contain control characters`}}if(e.includes(`..`)||e.startsWith(`/`)||e.includes(`\\`))return{ok:!1,reason:`docName must not contain "..", a leading "/", or a backslash`};for(let t of e.split(`/`)){if(t.length===0)return{ok:!1,reason:`docName must not contain empty path segments (no leading, trailing, or doubled "/")`};if(t.startsWith(`.`))return{ok:!1,reason:`docName path segments must not start with "." (hidden files are not addressable)`}}return{ok:!0}}var Q0=new Set([`opencode.json`]);function $0(e){return e.split(`/`).some(e=>e.startsWith(`.`))?!0:Q0.has(e.slice(e.lastIndexOf(`/`)+1))}function e2(e,t){let n=Z0(e);n.ok||t.addIssue({code:`custom`,message:n.reason})}var t2=k().superRefine(e2).optional(),n2={agentId:k().optional(),agentName:k().optional(),colorSeed:k().optional(),clientName:k().optional(),clientVersion:k().optional(),label:k().optional()},r2=k().optional(),i2=/^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;Yc(`kind`,[N({kind:F(`doc`),docPath:k().min(1)}).loose(),N({kind:F(`folder`),folderPath:k()}).loose()]);var a2=P([`no-remote`,`detached-head`,`branch-not-on-origin`,`non-github-remote`,`invalid-path`]),o2=P([`current`,`stale`,`absent`]),s2=Yc(`ok`,[N({ok:F(!0),shareUrl:k().min(1),sharedUrl:k().min(1),branch:k().min(1),freshness:o2.optional().catch(void 0)}).loose(),N({ok:F(!1),error:a2,branch:k().min(1).optional()}).loose()]),c2=P([`user`,`org`]),l2=N({login:k().min(1),kind:c2,avatarUrl:k().optional()}).loose(),u2=P([`auth-required`,`network`]),d2=Yc(`ok`,[N({ok:F(!0),owners:M(l2)}).loose(),N({ok:F(!1),error:u2}).loose()]),f2=Yc(`ok`,[N({ok:F(!0),available:j()}).loose(),N({ok:F(!1),error:u2}).loose()]),p2=P([`public`,`private`]);N({owner:k().min(1),name:k().min(1),visibility:p2,description:k().optional()}).loose();var m2=P([`name-conflict`,`saml-sso`,`auth-required`,`push-failed`,`init-failed`,`network`,`no-project`]),h2=Yc(`ok`,[N({ok:F(!0),ownerLogin:k().min(1),repoName:k().min(1),cloneUrl:k().min(1),defaultBranch:k().min(1)}).loose(),N({ok:F(!1),error:m2}).loose()]);function g2(e){return!(typeof e!=`string`||e.length===0||e.startsWith(`-`)||/[\x00-\x1F\x7F]/.test(e)||/\s/.test(e)||e.includes(`:`)||e.split(`/`).includes(`..`))}var _2=e=>e.refine(g2,`invalid branch name`),v2={shareTargetExists:j(),dirtyConflicts:N({conflicts:j(),files:M(k().min(1))}).loose(),branchIsLocal:j(),shareTargetOnOriginBranch:j().optional()};Yc(`detached`,[N({detached:F(!1),currentBranch:k().min(1).nullable(),currentHeadSha:Rc(),...v2}).loose(),N({detached:F(!0),currentBranch:Rc(),currentHeadSha:k().min(1),...v2}).loose()]),N({branch:_2(k().min(1)),principalId:k().optional(),fastForward:j().optional()}).loose();var y2=P([`dirty-conflict`,`branch-not-found`,`fetch-failed`,`checkout-failed`,`branch-in-other-worktree`,`ff-diverged`]);Yc(`ok`,[N({ok:F(!0)}).loose(),N({ok:F(!1),reason:y2,files:M(k().min(1)).optional(),otherWorktreePath:k().min(1).optional()}).loose()]),P([`on-origin`,`renamed`,`deleted`,`never-on-branch`,`changed-locally`,`unknown`]),N({branch:_2(k().min(1)),path:k(),kind:P([`doc`,`folder`])}).loose(),Yc(`verdict`,[N({verdict:F(`on-origin`)}).loose(),N({verdict:F(`renamed`),renamedTo:k().min(1)}).loose(),N({verdict:F(`deleted`)}).loose(),N({verdict:F(`never-on-branch`)}).loose(),N({verdict:F(`changed-locally`)}).loose(),N({verdict:F(`unknown`)}).loose()]).catch({verdict:`unknown`});var b2=N({startedAt:k().min(1),httpListenMs:A().nonnegative().optional(),seedWalkMs:A().nonnegative().optional(),indexesMs:A().nonnegative().optional(),readyMs:A().nonnegative().optional(),fileCount:A().nonnegative().optional()}),x2=N({serverInstanceId:k().min(1),currentBranch:k().min(1).optional(),currentDiskAckSVs:$c(k().min(1),k().min(1)).optional(),boot:b2.optional()}).loose(),S2=N({id:k().min(1),display_name:k().min(1),display_email:k(),source:P([`git-config`,`synthesized`]),created_at:k().min(1)}).loose();N({collabUrl:k().nullable(),previewUrl:k().nullable(),port:A(),paneTarget:k().nullable(),singleFile:j().default(!1)}).loose();var C2=N({type:P(`urn:ok:error:malformed-upload.urn:ok:error:collision-exhaustion.urn:ok:error:storage-full.urn:ok:error:storage-readonly.urn:ok:error:storage-error.urn:ok:error:no-file-received.urn:ok:error:path-escape.urn:ok:error:method-not-allowed.urn:ok:error:invalid-request.urn:ok:error:payload-too-large.urn:ok:error:request-timeout.urn:ok:error:internal-server-error.urn:ok:error:loopback-required.urn:ok:error:invalid-origin.urn:ok:error:url-not-allowed.urn:ok:error:dir-outside-home.urn:ok:error:concurrent-operation.urn:ok:error:clone-failed.urn:ok:error:clone-timeout.urn:ok:error:server-start-failed.urn:ok:error:reserved-doc-name.urn:ok:error:target-not-found.urn:ok:error:stale-target.urn:ok:error:frontmatter-edit-not-supported.urn:ok:error:invalid-frontmatter-patch.urn:ok:error:frontmatter-malformed.urn:ok:error:no-active-session.urn:ok:error:too-many-agent-sessions.urn:ok:error:disk-divergence.urn:ok:error:doc-not-found.urn:ok:error:doc-already-exists.urn:ok:error:doc-not-open.urn:ok:error:rollback-not-configured.urn:ok:error:doc-not-available.urn:ok:error:backlink-index-not-configured.urn:ok:error:file-rescan-not-configured.urn:ok:error:shadow-not-configured.urn:ok:error:host-not-allowed.urn:ok:error:principal-not-available.urn:ok:error:not-found.urn:ok:error:auth-failed.urn:ok:error:no-project-dir.urn:ok:error:server-open-failed.urn:ok:error:doc-in-conflict.urn:ok:error:no-conflict-tracked.urn:ok:error:sync-not-active.urn:ok:error:project-repo-not-configured.urn:ok:error:seed-prerequisite-missing.urn:ok:error:seed-invalid-root.urn:ok:error:tag-index-not-configured.urn:ok:error:template-not-found.urn:ok:error:unsupported-asset-type.urn:ok:error:asset-not-found.urn:ok:error:single-file-mode.urn:ok:error:collab-server-not-running.urn:ok:error:gateway-timeout.urn:ok:error:cursor-not-installed.urn:ok:error:cursor-spawn-timeout.urn:ok:error:cursor-spawn-failed.urn:ok:error:handoff-target-not-installed.urn:ok:error:handoff-spawn-timeout.urn:ok:error:handoff-spawn-failed`.split(`.`)),title:k().min(1),status:A().int().min(400).max(599),instance:k().regex(i2,`instance must be urn:uuid:<uuid>`).optional(),detail:k().optional()}).loose();N({parentDocName:k().min(1),placement:P([`configured-attachments`,`parent-dir`]).default(`configured-attachments`),agentId:k().min(1).optional(),agentName:k().min(1).optional()}).loose();var w2=N({src:k().min(1),path:k().min(1).optional(),deduped:j().optional()}).loose();N({url:k().min(1),dir:k().min(1),branch:k().min(1).refine(g2,`invalid branch name`).optional()}).loose(),N({type:F(`error`),problem:C2}).loose();var T2=/notionvc:/i,E2=()=>e=>{D2(e)&&(O2(e),k2(e))};function D2(e){if(!(`children`in e)||!Array.isArray(e.children))return!1;for(let t of e.children){if(t.type===`comment`){let e=String(t.value??``);if(T2.test(e))return!0}if(t.type===`element`&&D2(t))return!0}return!1}function O2(e){if(!(`children`in e)||!Array.isArray(e.children))return;for(let t of e.children)t.type===`element`&&O2(t);let t=[];for(let n of e.children){if(n.type!==`text`){t.push(n);continue}let e=String(n.value??``);if(!e.includes(`
|
|
469
|
+
`)}function B0(e,t,n,r,i,a){if(e.kind===`lines`)return I0(e.startLine,e.endLine,n);if(e.kind===`anchor`)return F0(e.markdown,n);let o=P0(e.markdown);return y0(z0(t,``,o,r,i),a)<=d0?o:F0(e.markdown,n)}function V0(e,t,n,r){let{target:i}=e,a=t0(e.docRelativePath),o=`Let's work on @${a} using OpenKnowledge.`,s=B0(t,o,a,n,r,i);return z0(o,O0(e.instruction,i,e=>z0(o,e,s,n,r)),s,n,r)}function H0(e){let{target:t}=e,n=e.autoOpen?M0:``,r=L0(e.mentions);if(e.scope===`doc`&&e.selection!==void 0)return V0(e,e.selection,r,n);let i=R0(e);return z0(i,O0(e.instruction,t,e=>z0(i,e,``,r,n)),``,r,n)}function U0(e){return`'${e.replace(/'/g,`'\\''`)}'`}var W0=[`mcp__${E$}`,`Bash(ok open:*)`],G0=[`delete`,`move`,`share_link`,`install`].map(e=>`mcp__${E$}__${e}`),K0=`-c ${U0(`mcp_servers.${E$}.default_tools_approval_mode="approve"`)}`;function q0(e){let t={};return e.mcpPreApprove===!0&&(t.enabledMcpjsonServers=[E$]),e.autoApproveOkTools===!0&&(t.permissions={allow:[...W0],deny:[...G0]}),t.enabledMcpjsonServers===void 0&&t.permissions===void 0?``:`--settings ${U0(JSON.stringify(t))}`}var J0={claude:{bin:`claude`,displayName:`Claude`,docsUrl:`https://docs.claude.com/en/docs/claude-code`,handoffTarget:`claude-code`},codex:{bin:`codex`,displayName:`Codex`,docsUrl:`https://developers.openai.com/codex/cli`,handoffTarget:`codex`,autoApproveArg:K0},cursor:{bin:`cursor-agent`,displayName:`Cursor`,docsUrl:`https://cursor.com/docs/cli/overview`,handoffTarget:`cursor`},opencode:{bin:`opencode`,displayName:`OpenCode`,docsUrl:`https://opencode.ai/docs`,handoffTarget:`opencode`,promptFlag:`--prompt`},pi:{bin:`pi`,displayName:`Pi`,docsUrl:`https://pi.dev`,handoffTarget:`pi`},antigravity:{bin:`agy`,displayName:`Antigravity`,docsUrl:`https://antigravity.google/docs/cli-getting-started`,handoffTarget:`antigravity`}},Y0=[`claude`,`codex`,`opencode`,`cursor`,`pi`,`antigravity`];function X0(e,t,n={}){let r=J0[e],i=e===`claude`?q0(n):n.autoApproveOkTools===!0&&r.autoApproveArg?r.autoApproveArg:``,a=i?`${i} `:``;if(t==null||t.length===0)return`${r.bin} ${a}`.trimEnd();let o=r.promptFlag?`${r.promptFlag} `:``;return`${r.bin} ${a}${o}${U0(t)}`}function Z0(e){if(e.length===0)return{ok:!1,reason:`docName must not be empty`};if(e.trim().length===0)return{ok:!1,reason:`docName must not be blank (whitespace only)`};if(e!==e.trim())return{ok:!1,reason:`docName must not have leading or trailing whitespace`};for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return{ok:!1,reason:`docName must not contain control characters`}}if(e.includes(`..`)||e.startsWith(`/`)||e.includes(`\\`))return{ok:!1,reason:`docName must not contain "..", a leading "/", or a backslash`};for(let t of e.split(`/`)){if(t.length===0)return{ok:!1,reason:`docName must not contain empty path segments (no leading, trailing, or doubled "/")`};if(t.startsWith(`.`))return{ok:!1,reason:`docName path segments must not start with "." (hidden files are not addressable)`}}return{ok:!0}}var Q0=new Set([`opencode.json`]);function $0(e){return e.split(`/`).some(e=>e.startsWith(`.`))?!0:Q0.has(e.slice(e.lastIndexOf(`/`)+1))}function e2(e,t){let n=Z0(e);n.ok||t.addIssue({code:`custom`,message:n.reason})}var t2=k().superRefine(e2).optional(),n2={agentId:k().optional(),agentName:k().optional(),colorSeed:k().optional(),clientName:k().optional(),clientVersion:k().optional(),label:k().optional()},r2=k().optional(),i2=/^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;Yc(`kind`,[N({kind:F(`doc`),docPath:k().min(1)}).loose(),N({kind:F(`folder`),folderPath:k()}).loose()]);var a2=P([`no-remote`,`detached-head`,`branch-not-on-origin`,`non-github-remote`,`invalid-path`]),o2=P([`current`,`stale`,`absent`]),s2=Yc(`ok`,[N({ok:F(!0),shareUrl:k().min(1),sharedUrl:k().min(1),branch:k().min(1),freshness:o2.optional().catch(void 0)}).loose(),N({ok:F(!1),error:a2,branch:k().min(1).optional()}).loose()]),c2=P([`user`,`org`]),l2=N({login:k().min(1),kind:c2,avatarUrl:k().optional()}).loose(),u2=P([`auth-required`,`network`]),d2=Yc(`ok`,[N({ok:F(!0),owners:M(l2)}).loose(),N({ok:F(!1),error:u2}).loose()]),f2=Yc(`ok`,[N({ok:F(!0),available:j()}).loose(),N({ok:F(!1),error:u2}).loose()]),p2=P([`public`,`private`]);N({owner:k().min(1),name:k().min(1),visibility:p2,description:k().optional()}).loose();var m2=P([`name-conflict`,`saml-sso`,`auth-required`,`push-failed`,`init-failed`,`network`,`no-project`]),h2=Yc(`ok`,[N({ok:F(!0),ownerLogin:k().min(1),repoName:k().min(1),cloneUrl:k().min(1),defaultBranch:k().min(1)}).loose(),N({ok:F(!1),error:m2}).loose()]);function g2(e){return!(typeof e!=`string`||e.length===0||e.startsWith(`-`)||/[\x00-\x1F\x7F]/.test(e)||/\s/.test(e)||e.includes(`:`)||e.split(`/`).includes(`..`))}var _2=e=>e.refine(g2,`invalid branch name`),v2={shareTargetExists:j(),dirtyConflicts:N({conflicts:j(),files:M(k().min(1))}).loose(),branchIsLocal:j(),shareTargetOnOriginBranch:j().optional()};Yc(`detached`,[N({detached:F(!1),currentBranch:k().min(1).nullable(),currentHeadSha:Rc(),...v2}).loose(),N({detached:F(!0),currentBranch:Rc(),currentHeadSha:k().min(1),...v2}).loose()]),N({branch:_2(k().min(1)),principalId:k().optional(),fastForward:j().optional()}).loose();var y2=P([`dirty-conflict`,`branch-not-found`,`fetch-failed`,`checkout-failed`,`branch-in-other-worktree`,`ff-diverged`]);Yc(`ok`,[N({ok:F(!0)}).loose(),N({ok:F(!1),reason:y2,files:M(k().min(1)).optional(),otherWorktreePath:k().min(1).optional()}).loose()]),P([`on-origin`,`renamed`,`deleted`,`never-on-branch`,`changed-locally`,`unknown`]),N({branch:_2(k().min(1)),path:k(),kind:P([`doc`,`folder`])}).loose(),Yc(`verdict`,[N({verdict:F(`on-origin`)}).loose(),N({verdict:F(`renamed`),renamedTo:k().min(1)}).loose(),N({verdict:F(`deleted`)}).loose(),N({verdict:F(`never-on-branch`)}).loose(),N({verdict:F(`changed-locally`)}).loose(),N({verdict:F(`unknown`)}).loose()]).catch({verdict:`unknown`});var b2=N({startedAt:k().min(1),httpListenMs:A().nonnegative().optional(),seedWalkMs:A().nonnegative().optional(),indexesMs:A().nonnegative().optional(),readyMs:A().nonnegative().optional(),fileCount:A().nonnegative().optional()}),x2=N({serverInstanceId:k().min(1),currentBranch:k().min(1).optional(),currentDiskAckSVs:$c(k().min(1),k().min(1)).optional(),boot:b2.optional()}).loose(),S2=N({id:k().min(1),display_name:k().min(1),display_email:k(),source:P([`git-config`,`synthesized`]),created_at:k().min(1)}).loose();N({collabUrl:k().nullable(),previewUrl:k().nullable(),port:A(),paneTarget:k().nullable(),singleFile:j().default(!1)}).loose();var C2=N({type:P(`urn:ok:error:malformed-upload.urn:ok:error:collision-exhaustion.urn:ok:error:storage-full.urn:ok:error:storage-readonly.urn:ok:error:storage-error.urn:ok:error:no-file-received.urn:ok:error:path-escape.urn:ok:error:method-not-allowed.urn:ok:error:invalid-request.urn:ok:error:payload-too-large.urn:ok:error:request-timeout.urn:ok:error:internal-server-error.urn:ok:error:loopback-required.urn:ok:error:invalid-origin.urn:ok:error:url-not-allowed.urn:ok:error:dir-outside-home.urn:ok:error:concurrent-operation.urn:ok:error:clone-failed.urn:ok:error:clone-timeout.urn:ok:error:server-start-failed.urn:ok:error:reserved-doc-name.urn:ok:error:target-not-found.urn:ok:error:stale-target.urn:ok:error:frontmatter-edit-not-supported.urn:ok:error:invalid-frontmatter-patch.urn:ok:error:frontmatter-malformed.urn:ok:error:no-active-session.urn:ok:error:too-many-agent-sessions.urn:ok:error:disk-divergence.urn:ok:error:doc-not-found.urn:ok:error:doc-already-exists.urn:ok:error:doc-not-open.urn:ok:error:rollback-not-configured.urn:ok:error:doc-not-available.urn:ok:error:backlink-index-not-configured.urn:ok:error:file-rescan-not-configured.urn:ok:error:shadow-not-configured.urn:ok:error:host-not-allowed.urn:ok:error:principal-not-available.urn:ok:error:not-found.urn:ok:error:auth-failed.urn:ok:error:no-project-dir.urn:ok:error:server-open-failed.urn:ok:error:doc-in-conflict.urn:ok:error:no-conflict-tracked.urn:ok:error:sync-not-active.urn:ok:error:project-repo-not-configured.urn:ok:error:seed-prerequisite-missing.urn:ok:error:seed-invalid-root.urn:ok:error:tag-index-not-configured.urn:ok:error:template-not-found.urn:ok:error:unsupported-asset-type.urn:ok:error:asset-not-found.urn:ok:error:single-file-mode.urn:ok:error:collab-server-not-running.urn:ok:error:gateway-timeout.urn:ok:error:cursor-not-installed.urn:ok:error:cursor-spawn-timeout.urn:ok:error:cursor-spawn-failed.urn:ok:error:handoff-target-not-installed.urn:ok:error:handoff-spawn-timeout.urn:ok:error:handoff-spawn-failed`.split(`.`)),title:k().min(1),status:A().int().min(400).max(599),instance:k().regex(i2,`instance must be urn:uuid:<uuid>`).optional(),detail:k().optional()}).loose();N({parentDocName:k().min(1),placement:P([`configured-attachments`,`parent-dir`]).default(`configured-attachments`),agentId:k().min(1).optional(),agentName:k().min(1).optional()}).loose();var w2=N({src:k().min(1),path:k().min(1).optional(),deduped:j().optional()}).loose();N({url:k().min(1),dir:k().min(1),branch:k().min(1).refine(g2,`invalid branch name`).optional()}).loose(),N({type:F(`error`),problem:C2}).loose();var T2=/notionvc:/i,E2=()=>e=>{D2(e)&&(O2(e),k2(e))};function D2(e){if(!(`children`in e)||!Array.isArray(e.children))return!1;for(let t of e.children){if(t.type===`comment`){let e=String(t.value??``);if(T2.test(e))return!0}if(t.type===`element`&&D2(t))return!0}return!1}function O2(e){if(!(`children`in e)||!Array.isArray(e.children))return;for(let t of e.children)t.type===`element`&&O2(t);let t=[];for(let n of e.children){if(n.type!==`text`){t.push(n);continue}let e=String(n.value??``);if(!e.includes(`
|
|
470
470
|
`)){t.push(n);continue}let r=e.split(`
|
|
471
471
|
`);for(let e=0;e<r.length;e++)r[e]&&t.push({type:`text`,value:r[e]??``}),e<r.length-1&&t.push({type:`element`,tagName:`br`,properties:{},children:[]})}e.children=t}function k2(e){if(!(!(`children`in e)||!Array.isArray(e.children))){e.children=e.children.filter(e=>e.type===`comment`?!T2.test(String(e.value??``)):!0);for(let t of e.children)t.type===`element`&&k2(t)}}var A2=new Set([`Apple-tab-span`,`Apple-converted-space`,`Apple-style-span`]),j2=()=>e=>{M2(e)};function M2(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&M2(t);e.children=e.children.flatMap(e=>{if(e.type!==`element`)return[e];let t=e;return N2(t)?[]:P2(t)?t.children:[t]})}}function N2(e){if(e.tagName!==`meta`)return!1;let t=e.properties?.name,n=e.properties?.content;return t===`Generator`&&typeof n==`string`&&/Cocoa/i.test(n)}function P2(e){if(e.tagName!==`span`)return!1;let t=e.properties?.className;return Array.isArray(t)?t.length>0&&t.every(e=>A2.has(String(e))):!1}var F2=`docs-internal-guid-`;function I2(e,t){let n=e.children[t];!n||n.type!==`element`||e.children.splice(t,1,...n.children)}var L2=()=>e=>{R2(e)};function R2(e){if(!(`children`in e)||!Array.isArray(e.children))return;for(let t of e.children)t.type===`element`&&R2(t);let t=0;for(;t<e.children.length;){let n=e.children[t];if(!n||n.type!==`element`){t++;continue}let r=n;if(z2(r)||B2(r)){I2(e,t);continue}t++}}function z2(e){if(e.tagName!==`b`)return!1;let t=e.properties?.id;return typeof t==`string`&&t.startsWith(F2)}function B2(e){if(e.tagName!==`div`||e.properties?.dir!==`ltr`)return!1;let t=e.children.filter(e=>e.type===`element`);return t.length===1?t[0]?.tagName===`table`:!1}var V2=new Set([`commit-link`,`user-mention`,`team-mention`,`issue-link`]),H2=()=>e=>{U2(e)};function U2(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&U2(t);for(let t of e.children)t.type===`element`&&W2(t)}}function W2(e){if(!e.properties)return;for(let t of Object.keys(e.properties))t.startsWith(`dataHovercard`)&&delete e.properties[t];let t=e.properties.className;if(Array.isArray(t)){let n=t.filter(e=>!V2.has(String(e)));n.length===0?delete e.properties.className:e.properties.className=n}}var G2=/^gmail_/,K2=()=>e=>{q2(e)};function q2(e){if(!(`children`in e)||!Array.isArray(e.children))return;for(let t of e.children)t.type===`element`&&q2(t);let t=0;for(;t<e.children.length;){let n=e.children[t];if(n.type!==`element`){t++;continue}let r=n;if(r.tagName===`div`&&J2(r,`gmail_quote`)&&(r.tagName=`blockquote`),Y2(r),X2(r)){e.children.splice(t,1,...r.children);continue}t++}}function J2(e,t){let n=e.properties?.className;return Array.isArray(n)?n.some(e=>String(e)===t):!1}function Y2(e){let t=e.properties?.className;if(!Array.isArray(t))return;let n=t.filter(e=>!G2.test(String(e)));n.length===0?delete e.properties?.className:e.properties&&(e.properties.className=n)}function X2(e){if(e.tagName!==`div`||e.properties?.dir!==`ltr`)return!1;let t=e.properties?.className;return t!=null&&!(Array.isArray(t)&&t.length===0)?!1:e.children.filter(e=>e.type===`element`).length<=1}var Z2=()=>e=>{Q2(e)};function Q2(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&Q2(t);e.children=e.children.flatMap(e=>{if(e.type!==`element`)return[e];let t=e;return t.tagName===`google-sheets-html-origin`?t.children:t.tagName===`style`?[]:($2(t),[t])})}}function $2(e){if(e.properties)for(let t of Object.keys(e.properties))t.startsWith(`dataSheets`)&&delete e.properties[t]}var e4=[`o:`,`w:`,`m:`,`v:`,`u1:`],t4=/^Mso[A-Z]/,n4=/^\s*\[if\s+[^\]]*\]/,r4=()=>e=>{i4(e)};function i4(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&i4(t);e.children=e.children.flatMap(e=>{if(e.type===`comment`){let t=String(e.value??``);return n4.test(t)?[]:[e]}if(e.type!==`element`)return[e];let t=e;return a4(t)?[]:(o4(t),[t])})}}function a4(e){return e4.some(t=>e.tagName.startsWith(t))}function o4(e){let t=e.properties;if(!t)return;let n=t.className;if(Array.isArray(n)){let e=n.filter(e=>typeof e==`string`&&!t4.test(e));e.length===0?delete t.className:t.className=e}else typeof n==`string`&&t4.test(n)&&delete t.className;let r=t.style;typeof r==`string`&&/mso-/i.test(r)&&delete t.style;for(let e of Object.keys(t))if(e.startsWith(`xmlns:`)){let n=e.slice(6);e4.some(e=>e===`${n}:`)&&delete t[e]}}var s4=/^c-(message_kit__|message__|compose|timestamp)/,c4=()=>e=>{l4(e)};function l4(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&l4(t);e.children=e.children.flatMap(e=>{if(e.type!==`element`)return[e];let t=e;return u4(t)?[]:(d4(t),[t])})}}function u4(e){let t=e.properties?.className;return Array.isArray(t)?t.some(e=>String(e)===`c-timestamp`||String(e).startsWith(`c-timestamp`)):!1}function d4(e){let t=e.properties?.className;if(!Array.isArray(t))return;let n=t.filter(e=>!s4.test(String(e)));n.length===0?delete e.properties?.className:e.properties&&(e.properties.className=n)}var f4=()=>e=>{p4(e)};function p4(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)t.type===`element`&&p4(t);for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n.type!==`element`)continue;let r=n;m4(r)&&(e.children[t]=g4(r))}}}function m4(e){if(e.tagName!==`div`)return!1;let t=e.children.filter(e=>e.type===`element`&&e.tagName===`div`);return t.length<2?!1:t.some(e=>h4(e))}function h4(e){for(let t of e.children){if(t.type!==`element`)continue;let e=t,n=e.properties?.style;if(typeof n==`string`&&/color\s*:/i.test(n)||h4(e))return!0}return!1}function g4(e){return{type:`element`,tagName:`pre`,properties:{},children:[{type:`element`,tagName:`code`,properties:{},children:[{type:`text`,value:e.children.filter(e=>e.type===`element`&&e.tagName===`div`).map(e=>_4(e)).join(`
|
|
472
472
|
`)}]}]}}function _4(e){let t=``;for(let n of e.children)n.type===`text`?t+=n.value??``:n.type===`element`&&(t+=_4(n));return t}var v4=new Set([`break`,`delete`,`emphasis`,`footnoteReference`,`html`,`image`,`imageReference`,`inlineCode`,`link`,`linkReference`,`strong`,`text`]);function y4(e){let t=e.children;Array.isArray(t)&&t.forEach((e,n)=>{if(e.type===`break`){t[n]={type:`html`,value:`<br />`};return}y4(e)})}function b4(e){let t=e.children;if(Array.isArray(t))for(let e of t)(e.type===`inlineCode`||e.type===`html`)&&(e.value.includes(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e}from"./dist-
|
|
1
|
+
import{K as e}from"./dist-D5fPTJjV.js";var t=/\.(md|mdx)$/i;function n(e){return e.trim().replace(/^\.\/+/,``).replace(/^\/+/,``)}function r(e){return n(e).replace(t,``)}function i(e){let r=n(e);return r?t.test(r)?r:`${r}.md`:`untitled.md`}function a(e){let t=r(e),n=t.lastIndexOf(`/`);return{initialDir:n>0?t.slice(0,n):``,suggestedName:`${n>=0?t.slice(n+1):t||`untitled`}.md`}}function o(t){return e.includes(t)}function s(e){if(e.startsWith(h)||e.startsWith(y)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=g(t),r=n>=0?t.slice(0,n):t;if(!r)return null;try{return r.split(`/`).map(decodeURIComponent).join(`/`)}catch{return r}}function c(e){if(e.startsWith(h)||!e.startsWith(`#/`))return null;let t=e.slice(2),n=t.indexOf(`#`);if(n<0)return null;let r=t.slice(n+1);if(!r)return null;try{return decodeURIComponent(r)}catch{return r}}function l(e,t){let n=`#/${e}`;return t?`${n}#${encodeURIComponent(t)}`:n}function u(e){if(window.location.hash===e)return;let{pathname:t,search:n}=window.location;window.history.replaceState(null,``,`${t}${n}${e}`)}function d(e){return e.endsWith(`.mdx`)?e.slice(0,-4):e.endsWith(`.md`)?e.slice(0,-3):e}function f(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?`#/${n}/`:`#/`;return t?`${r}#${encodeURIComponent(t)}`:r}function p(e,t,n){if(e===`folder`)return f(t);let r=`#/${encodeURIComponent(t)}`;return n==null||n===``?r:`${r}?branch=${encodeURIComponent(n)}`}function m(e){if(e===`#/`)return!0;if(!e.startsWith(`#/`))return!1;let t=e.slice(2);return t.length>0&&t[0]===`?`}var h=`#/__asset__/`;function g(e){let t=e.indexOf(`?`),n=e.indexOf(`#`);return t<0?n:n<0?t:Math.min(t,n)}function _(e){if(!e.startsWith(h))return null;let t=e.slice(12);if(!t)return null;try{return t.split(`/`).map(decodeURIComponent).join(`/`)}catch{return t}}function v(e){return`${h}${e.split(`/`).map(encodeURIComponent).join(`/`)}`}var y=`#/__skill-file__/`;function b(e){return`${y}${[e.scope,e.name].map(encodeURIComponent).join(`/`)}/${e.path.split(`/`).map(encodeURIComponent).join(`/`)}`}function x(e){if(!e.startsWith(y))return null;let t=e.slice(17);if(!t)return null;let n;try{n=t.split(`/`).map(decodeURIComponent)}catch{return null}if(n.length<3)return null;let[r,i,...a]=n,s=a.join(`/`);return!r||!i||!s||!o(r)?null:{scope:r,name:i,path:s}}export{d as a,f as c,u as d,x as f,r as h,p as i,b as l,i as m,_ as n,v as o,a as p,s as r,l as s,c as t,m as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{T as e}from"./dist-
|
|
1
|
+
import{T as e}from"./dist-D5fPTJjV.js";var t=`open-knowledge:documents-changed`,n=new Set(e.options);function r(e){return e===void 0||!Array.isArray(e)?[`files`]:[...new Set(e.filter(e=>n.has(e)))]}function i(e=[`files`]){window.dispatchEvent(new CustomEvent(t,{detail:{channels:r(e)}}))}function a(e){let n=t=>{e(r(t instanceof CustomEvent?t.detail?.channels:void 0))};return window.addEventListener(t,n),()=>window.removeEventListener(t,n)}var o=`open-knowledge:branch-changed`;function s(e){window.dispatchEvent(new CustomEvent(o,{detail:{branch:e}}))}function c(e){let t=t=>{if(!(t instanceof CustomEvent))return;let n=t.detail;e(n?.branch??null)};return window.addEventListener(o,t),()=>window.removeEventListener(o,t)}var l=`open-knowledge:templates-changed`;function u(){window.dispatchEvent(new CustomEvent(l))}function d(e){let t=()=>e();return window.addEventListener(l,t),()=>window.removeEventListener(l,t)}var f=`open-knowledge:skills-changed`;function p(){window.dispatchEvent(new CustomEvent(f))}function m(e){let t=()=>e();return window.addEventListener(f,t),()=>window.removeEventListener(f,t)}export{c as a,d as c,u as i,i as n,a as o,p as r,m as s,s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Hi as e,Ui as t}from"./dist-
|
|
1
|
+
import{Hi as e,Ui as t}from"./dist-D5fPTJjV.js";import{t as n}from"./file-tree-rename-validation-DeKIxKnc.js";import{d as r,i,l as a,u as o}from"./navigation-targets-u2AFSpqT.js";import{c as s,o as c,s as l}from"./doc-hash-I00EhzUZ.js";var u=`application/x-open-knowledge-sidebar-item+json`,d={image:!0,video:!0,audio:!0,pdf:!0,text:!0,mermaid:!0};function f(e){return JSON.stringify(e)}function p(e){return e.kind===`folder`?{target:{kind:`folder`,target:e.folderPath,folderPath:e.folderPath},hash:s(e.folderPath)}:e.kind===`asset`?{target:{kind:`asset`,target:e.assetPath,assetPath:e.assetPath,mediaKind:e.mediaKind},hash:c(e.assetPath)}:{target:i(e.docName,e.size)??{kind:`doc`,target:e.docName,docName:e.docName},hash:l(e.docName)}}function m(e){if(!e||!Array.from(e.types).includes(`application/x-open-knowledge-sidebar-item+json`))return null;let t=e.getData(u);if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!h(n)||n.v!==1||typeof n.kind!=`string`)return null;if(n.kind===`doc`){if(typeof n.docName!=`string`||n.docName.length===0)return null;let e=n.size;return e!==null&&typeof e!=`number`?null:{v:1,kind:`doc`,docName:n.docName,size:e}}if(n.kind===`folder`)return typeof n.folderPath==`string`?{v:1,kind:`folder`,folderPath:n.folderPath}:null;if(n.kind===`asset`){if(typeof n.assetPath!=`string`||n.assetPath.length===0)return null;let e=n.mediaKind;return e!==null&&!g(e)?null:{v:1,kind:`asset`,assetPath:n.assetPath,mediaKind:e}}return null}function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function g(e){return typeof e==`string`&&Object.hasOwn(d,e)}var _={background:`#171717`,foreground:`#e5e5e5`,cursor:`#e5e5e5`,cursorAccent:`#171717`,selectionBackground:`#3a3d41`,black:`#000000`,red:`#cd3131`,green:`#0dbc79`,yellow:`#e5e510`,blue:`#2472c8`,magenta:`#bc3fbc`,cyan:`#11a8cd`,white:`#e5e5e5`,brightBlack:`#666666`,brightRed:`#f14c4c`,brightGreen:`#23d18b`,brightYellow:`#f5f543`,brightBlue:`#3b8eea`,brightMagenta:`#d670d6`,brightCyan:`#29b8db`,brightWhite:`#ffffff`},v={background:`#ffffff`,foreground:`#262626`,cursor:`#262626`,cursorAccent:`#ffffff`,selectionBackground:`#add6ff`,black:`#000000`,red:`#cd3131`,green:`#00bc00`,yellow:`#949800`,blue:`#0451a5`,magenta:`#bc05bc`,cyan:`#0598bc`,white:`#555555`,brightBlack:`#666666`,brightRed:`#cd3131`,brightGreen:`#14ce14`,brightYellow:`#b5ba00`,brightBlue:`#0451a5`,brightMagenta:`#bc05bc`,brightCyan:`#0598bc`,brightWhite:`#a5a5a5`};function y(e){return e===`dark`?_:v}var b=`.md`,x=/\.(md|mdx)$/i;function S(t,n=b){return x.test(t)||e(t)?t:`${t}${n}`}function C(e){return Q(e).replace(x,``)}function w(e,t){let n=Q(e),r=t.find(e=>o(e)&&T(e)===n);if(r)return r.docName;let i=C(n);return t.find(e=>{let t=T(e);return t!==n&&x.test(t)&&C(t)===i})&&x.test(n)?n:i}function T(e){return r(e)?O(e.path):a(e)?e.path:S(e.docName,e.docExt)}function E(e){let t=Q(e).match(x);return t?`.${t[1].toLowerCase()}`:void 0}function D(e){return Q(e)}function O(e){let t=Q(e.trim());return t?`${t}/`:``}function k(e){return e.endsWith(`/`)?D(e):C(e)}function A(e){return e.map(T)}function j(e){return[...e].sort().join(`\0`)}function M(e){return j(A(e))}function N(e){let t=new Set;for(let n of e){let e=(r(n)||a(n)?n.path:n.docName).split(`/`).filter(Boolean);if(e.includes(`.ok`))continue;if(r(n)){let e=O(n.path);e&&t.add(e)}let i=r(n)?e.length:e.length-1;for(let n=1;n<=i;n++)t.add(`${e.slice(0,n).join(`/`)}/`)}return[...t].sort()}function P(e){if(!e)return[];let t=Q(e.replace(x,``)).split(`/`).filter(Boolean),n=[],r=e.endsWith(`/`)?t.length:t.length-1;for(let e=1;e<=r;e++)n.push(`${t.slice(0,e).join(`/`)}/`);return n}function F(e,t,n){let r=E(e);if(r)return r;let i=n.find(e=>o(e)&&e.docName===t);return i?i.docExt??b:Z(e).includes(`.`)?void 0:b}function I(e,t){let n=e.lastIndexOf(`/`),r=n===-1?``:e.slice(0,n+1),i=n===-1?e:e.slice(n+1),o=t.filter(e=>{if(!a(e)||!e.path.startsWith(r))return!1;let t=e.path.slice(r.length);return!t.includes(`/`)&&t.startsWith(`${i}.`)});return o.length===1?o[0].path:null}function L(e,t,n){if(E(e))return null;let r=n.find(e=>a(e)&&e.path===t);return r?r.path:Z(e).includes(`.`)?t:I(t,n)}function R(e,t){let n=e.kind===`directory`,r=n?D(e.path):w(e.path,t);if(n)return{kind:`folder`,name:Q(Z(e.path)).replace(x,``),path:r,treePath:B(e.path,!0)};let i=L(e.path,r,t);if(i)return{kind:`asset`,name:Q(Z(i)),path:i,treePath:i};let a=F(e.path,r,t);return{kind:`file`,name:Q(Z(e.path)).replace(x,``),path:r,treePath:B(e.path,!1),docExt:a}}function z(e){return e.kind===`directory`?D(e.path):e.path}function B(e,t){return t?O(e):x.test(e)?e:`${e}${b}`}function V(e,t,n){let r=O(t),i=new Set(n);for(let t=0;t<100;t++){let n=t===0?``:` ${t+1}`;if(e===`file`){let e=`${r}Untitled${n}${b}`;if(!i.has(e))return{addPath:e,renamePath:e};continue}let a=`${r}New Folder${n}/`;if(!i.has(a))return{addPath:a,renamePath:a}}throw Error(`Could not allocate a unique tree placeholder`)}function H(e,t){return e===`file`?B(t,!1):`${D(t)}/index${b}`}function U(e,t){return t.kind===`root`||t.directoryPath==null?Z(e):`${t.directoryPath}${Z(e)}`}function W(e,t){if(t)return D(O(e));let n=C(e),r=n.lastIndexOf(`/`);return r===-1?``:n.slice(0,r)}function G(e,t){let n=D(O(e));return n?`${n}/${t}`:t}function K(e,t,n){e.append(`parentDocName`,G(t,n)),e.append(`placement`,`parent-dir`)}function q(e,t){return(t.path??G(e,t.src)).replace(/^\/+/,``)}function J(e){let t=e.dataTransfer?.types;if(!t)return!1;let n=Array.from(t);return n.includes(`Files`)&&!n.includes(`application/x-open-knowledge-sidebar-item+json`)}function Y(e){return Array.from(e.dataTransfer?.files??[]).filter(e=>e.name.length>0||e.size>0)}function X(e,r){let i=n(e).toLowerCase();if(i===``)return null;let a=new Date().toISOString();if(i===`.md`||i===`.mdx`)return{kind:`document`,docName:C(e),docExt:i,modified:a,size:r.size};let o=i.startsWith(`.`)?i.slice(1):i;return{kind:`asset`,path:e,assetExt:o,mediaKind:t(o),modified:a,size:r.size}}function Z(e){let t=Q(e),n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function Q(e){return e.endsWith(`/`)?e.slice(0,-1):e}export{f as A,j as C,u as D,y as E,p as O,R as S,q as T,z as _,H as a,C as b,A as c,T as d,Y as f,W as g,B as h,U as i,m as k,M as l,J as m,N as n,V as o,O as p,P as r,S as s,K as t,X as u,I as v,k as w,w as x,D as y};
|